Files
twenty/packages/twenty-server/test/integration/metadata/suites/application/utils/build-default-object-manifest.util.ts
T
Marie 2d6c8be7df [Apps] Fix - app-synced object should be searchable (#19206)
## 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`.
2026-04-02 17:14:37 +00:00

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,
],
};
};