2d6c8be7df
## Summary - **Make app-synced objects searchable**: `isSearchable` was hardcoded to `false` and the `searchVector` field was missing the `GENERATED ALWAYS AS (...)` expression, causing all records to have a `NULL` search vector and be excluded from search results. Fixed by defaulting `isSearchable` to `true` (configurable via the object manifest), computing the `asExpression` from the label identifier field, and allowing the update-field-action-handler to handle the `null` → defined `asExpression` transition. - **Make `isSearchable` updatable on an object**: The property had `toCompare: false` in the entity properties configuration, so updates via the API were silently ignored and never persisted. Fixed by setting `toCompare: true`.
92 lines
2.3 KiB
TypeScript
92 lines
2.3 KiB
TypeScript
import { type ObjectManifest } from 'twenty-shared/application';
|
|
import { FieldMetadataType } from 'twenty-shared/types';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
export const buildDefaultObjectManifest = ({
|
|
nameSingular,
|
|
namePlural,
|
|
labelSingular,
|
|
labelPlural,
|
|
description,
|
|
icon = 'IconTicket',
|
|
additionalFields = [],
|
|
universalIdentifier,
|
|
labelIdentifierFieldMetadataUniversalIdentifier,
|
|
}: {
|
|
nameSingular: string;
|
|
namePlural: string;
|
|
labelSingular: string;
|
|
labelPlural: string;
|
|
description?: string;
|
|
icon?: string;
|
|
additionalFields?: ObjectManifest['fields'];
|
|
universalIdentifier?: string;
|
|
labelIdentifierFieldMetadataUniversalIdentifier?: string;
|
|
}): ObjectManifest => {
|
|
const idFieldUniversalIdentifier = uuidv4();
|
|
|
|
return {
|
|
universalIdentifier: universalIdentifier ?? uuidv4(),
|
|
labelIdentifierFieldMetadataUniversalIdentifier:
|
|
labelIdentifierFieldMetadataUniversalIdentifier ??
|
|
idFieldUniversalIdentifier,
|
|
nameSingular,
|
|
namePlural,
|
|
labelSingular,
|
|
labelPlural,
|
|
description,
|
|
icon,
|
|
fields: [
|
|
{
|
|
universalIdentifier: idFieldUniversalIdentifier,
|
|
type: FieldMetadataType.UUID,
|
|
name: 'id',
|
|
label: 'Id',
|
|
},
|
|
{
|
|
universalIdentifier: uuidv4(),
|
|
type: FieldMetadataType.DATE_TIME,
|
|
name: 'createdAt',
|
|
label: 'Creation date',
|
|
},
|
|
{
|
|
universalIdentifier: uuidv4(),
|
|
type: FieldMetadataType.DATE_TIME,
|
|
name: 'updatedAt',
|
|
label: 'Last update',
|
|
},
|
|
{
|
|
universalIdentifier: uuidv4(),
|
|
type: FieldMetadataType.DATE_TIME,
|
|
name: 'deletedAt',
|
|
label: 'Deleted at',
|
|
},
|
|
{
|
|
universalIdentifier: uuidv4(),
|
|
type: FieldMetadataType.ACTOR,
|
|
name: 'createdBy',
|
|
label: 'Created by',
|
|
},
|
|
{
|
|
universalIdentifier: uuidv4(),
|
|
type: FieldMetadataType.ACTOR,
|
|
name: 'updatedBy',
|
|
label: 'Updated by',
|
|
},
|
|
{
|
|
universalIdentifier: uuidv4(),
|
|
type: FieldMetadataType.POSITION,
|
|
name: 'position',
|
|
label: 'Position',
|
|
},
|
|
{
|
|
universalIdentifier: uuidv4(),
|
|
type: FieldMetadataType.TS_VECTOR,
|
|
name: 'searchVector',
|
|
label: 'Search vector',
|
|
},
|
|
...additionalFields,
|
|
],
|
|
};
|
|
};
|