add new @WorkspaceIsSearchable decorator + updates services + add migration command (#10507)

closes https://github.com/twentyhq/core-team-issues/issues/345
This commit is contained in:
Etienne
2025-02-27 13:57:07 +01:00
committed by GitHub
parent 17dbb634ca
commit 39543872e6
54 changed files with 297 additions and 145 deletions

View File

@ -24,7 +24,7 @@ const documents = {
"\n \n query GetManyDatabaseConnections($input: RemoteServerTypeInput!) {\n findManyRemoteServersByType(input: $input) {\n ...RemoteServerFields\n }\n }\n": types.GetManyDatabaseConnectionsDocument, "\n \n query GetManyDatabaseConnections($input: RemoteServerTypeInput!) {\n findManyRemoteServersByType(input: $input) {\n ...RemoteServerFields\n }\n }\n": types.GetManyDatabaseConnectionsDocument,
"\n \n query GetManyRemoteTables($input: FindManyRemoteTablesInput!) {\n findDistantTablesWithStatus(input: $input) {\n ...RemoteTableFields\n }\n }\n": types.GetManyRemoteTablesDocument, "\n \n query GetManyRemoteTables($input: FindManyRemoteTablesInput!) {\n findDistantTablesWithStatus(input: $input) {\n ...RemoteTableFields\n }\n }\n": types.GetManyRemoteTablesDocument,
"\n \n query GetOneDatabaseConnection($input: RemoteServerIdInput!) {\n findOneRemoteServerById(input: $input) {\n ...RemoteServerFields\n }\n }\n": types.GetOneDatabaseConnectionDocument, "\n \n query GetOneDatabaseConnection($input: RemoteServerIdInput!) {\n findOneRemoteServerById(input: $input) {\n ...RemoteServerFields\n }\n }\n": types.GetOneDatabaseConnectionDocument,
"\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n }\n }\n": types.CreateOneObjectMetadataItemDocument, "\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n }\n }\n": types.CreateOneObjectMetadataItemDocument,
"\n mutation CreateOneFieldMetadataItem($input: CreateOneFieldMetadataInput!) {\n createOneField(input: $input) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n defaultValue\n options\n }\n }\n": types.CreateOneFieldMetadataItemDocument, "\n mutation CreateOneFieldMetadataItem($input: CreateOneFieldMetadataInput!) {\n createOneField(input: $input) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n defaultValue\n options\n }\n }\n": types.CreateOneFieldMetadataItemDocument,
"\n mutation CreateOneRelationMetadataItem(\n $input: CreateOneRelationMetadataInput!\n ) {\n createOneRelationMetadata(input: $input) {\n id\n relationType\n fromObjectMetadataId\n toObjectMetadataId\n fromFieldMetadataId\n toFieldMetadataId\n createdAt\n updatedAt\n }\n }\n": types.CreateOneRelationMetadataItemDocument, "\n mutation CreateOneRelationMetadataItem(\n $input: CreateOneRelationMetadataInput!\n ) {\n createOneRelationMetadata(input: $input) {\n id\n relationType\n fromObjectMetadataId\n toObjectMetadataId\n fromFieldMetadataId\n toFieldMetadataId\n createdAt\n updatedAt\n }\n }\n": types.CreateOneRelationMetadataItemDocument,
"\n mutation UpdateOneFieldMetadataItem(\n $idToUpdate: UUID!\n $updatePayload: UpdateFieldInput!\n ) {\n updateOneField(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n isLabelSyncedWithName\n }\n }\n": types.UpdateOneFieldMetadataItemDocument, "\n mutation UpdateOneFieldMetadataItem(\n $idToUpdate: UUID!\n $updatePayload: UpdateFieldInput!\n ) {\n updateOneField(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n isLabelSyncedWithName\n }\n }\n": types.UpdateOneFieldMetadataItemDocument,
@ -32,7 +32,7 @@ const documents = {
"\n mutation DeleteOneObjectMetadataItem($idToDelete: UUID!) {\n deleteOneObject(input: { id: $idToDelete }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n }\n }\n": types.DeleteOneObjectMetadataItemDocument, "\n mutation DeleteOneObjectMetadataItem($idToDelete: UUID!) {\n deleteOneObject(input: { id: $idToDelete }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n }\n }\n": types.DeleteOneObjectMetadataItemDocument,
"\n mutation DeleteOneFieldMetadataItem($idToDelete: UUID!) {\n deleteOneField(input: { id: $idToDelete }) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n }\n }\n": types.DeleteOneFieldMetadataItemDocument, "\n mutation DeleteOneFieldMetadataItem($idToDelete: UUID!) {\n deleteOneField(input: { id: $idToDelete }) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n }\n }\n": types.DeleteOneFieldMetadataItemDocument,
"\n mutation DeleteOneRelationMetadataItem($idToDelete: UUID!) {\n deleteOneRelation(input: { id: $idToDelete }) {\n id\n }\n }\n": types.DeleteOneRelationMetadataItemDocument, "\n mutation DeleteOneRelationMetadataItem($idToDelete: UUID!) {\n deleteOneRelation(input: { id: $idToDelete }) {\n id\n }\n }\n": types.DeleteOneRelationMetadataItemDocument,
"\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isRemote\n isActive\n isSystem\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n shortcut\n isLabelSyncedWithName\n duplicateCriteria\n indexMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n name\n indexWhereClause\n indexType\n isUnique\n indexFieldMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n order\n fieldMetadataId\n }\n }\n }\n }\n }\n }\n fieldsList {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isSystem\n isNullable\n isUnique\n createdAt\n updatedAt\n defaultValue\n options\n settings\n isLabelSyncedWithName\n relationDefinition {\n relationId\n direction\n sourceObjectMetadata {\n id\n nameSingular\n namePlural\n }\n sourceFieldMetadata {\n id\n name\n }\n targetObjectMetadata {\n id\n nameSingular\n namePlural\n }\n targetFieldMetadata {\n id\n name\n }\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n": types.ObjectMetadataItemsDocument, "\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isRemote\n isActive\n isSystem\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n shortcut\n isLabelSyncedWithName\n isSearchable\n duplicateCriteria\n indexMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n name\n indexWhereClause\n indexType\n isUnique\n indexFieldMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n order\n fieldMetadataId\n }\n }\n }\n }\n }\n }\n fieldsList {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isSystem\n isNullable\n isUnique\n createdAt\n updatedAt\n defaultValue\n options\n settings\n isLabelSyncedWithName\n relationDefinition {\n relationId\n direction\n sourceObjectMetadata {\n id\n nameSingular\n namePlural\n }\n sourceFieldMetadata {\n id\n name\n }\n targetObjectMetadata {\n id\n nameSingular\n namePlural\n }\n targetFieldMetadata {\n id\n name\n }\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n": types.ObjectMetadataItemsDocument,
"\n fragment ServerlessFunctionFields on ServerlessFunction {\n id\n name\n description\n runtime\n timeoutSeconds\n syncStatus\n latestVersion\n latestVersionInputSchema\n publishedVersions\n createdAt\n updatedAt\n }\n": types.ServerlessFunctionFieldsFragmentDoc, "\n fragment ServerlessFunctionFields on ServerlessFunction {\n id\n name\n description\n runtime\n timeoutSeconds\n syncStatus\n latestVersion\n latestVersionInputSchema\n publishedVersions\n createdAt\n updatedAt\n }\n": types.ServerlessFunctionFieldsFragmentDoc,
"\n \n mutation CreateOneServerlessFunctionItem(\n $input: CreateServerlessFunctionInput!\n ) {\n createOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.CreateOneServerlessFunctionItemDocument, "\n \n mutation CreateOneServerlessFunctionItem(\n $input: CreateServerlessFunctionInput!\n ) {\n createOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.CreateOneServerlessFunctionItemDocument,
"\n \n mutation DeleteOneServerlessFunction($input: ServerlessFunctionIdInput!) {\n deleteOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.DeleteOneServerlessFunctionDocument, "\n \n mutation DeleteOneServerlessFunction($input: ServerlessFunctionIdInput!) {\n deleteOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.DeleteOneServerlessFunctionDocument,
@ -106,7 +106,7 @@ export function graphql(source: "\n \n query GetOneDatabaseConnection($input:
/** /**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/ */
export function graphql(source: "\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n }\n }\n"): (typeof documents)["\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n }\n }\n"]; export function graphql(source: "\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n }\n }\n"): (typeof documents)["\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n }\n }\n"];
/** /**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/ */
@ -138,7 +138,7 @@ export function graphql(source: "\n mutation DeleteOneRelationMetadataItem($idT
/** /**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/ */
export function graphql(source: "\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isRemote\n isActive\n isSystem\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n shortcut\n isLabelSyncedWithName\n duplicateCriteria\n indexMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n name\n indexWhereClause\n indexType\n isUnique\n indexFieldMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n order\n fieldMetadataId\n }\n }\n }\n }\n }\n }\n fieldsList {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isSystem\n isNullable\n isUnique\n createdAt\n updatedAt\n defaultValue\n options\n settings\n isLabelSyncedWithName\n relationDefinition {\n relationId\n direction\n sourceObjectMetadata {\n id\n nameSingular\n namePlural\n }\n sourceFieldMetadata {\n id\n name\n }\n targetObjectMetadata {\n id\n nameSingular\n namePlural\n }\n targetFieldMetadata {\n id\n name\n }\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n"): (typeof documents)["\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isRemote\n isActive\n isSystem\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n shortcut\n isLabelSyncedWithName\n duplicateCriteria\n indexMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n name\n indexWhereClause\n indexType\n isUnique\n indexFieldMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n order\n fieldMetadataId\n }\n }\n }\n }\n }\n }\n fieldsList {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isSystem\n isNullable\n isUnique\n createdAt\n updatedAt\n defaultValue\n options\n settings\n isLabelSyncedWithName\n relationDefinition {\n relationId\n direction\n sourceObjectMetadata {\n id\n nameSingular\n namePlural\n }\n sourceFieldMetadata {\n id\n name\n }\n targetObjectMetadata {\n id\n nameSingular\n namePlural\n }\n targetFieldMetadata {\n id\n name\n }\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n"]; export function graphql(source: "\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isRemote\n isActive\n isSystem\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n shortcut\n isLabelSyncedWithName\n isSearchable\n duplicateCriteria\n indexMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n name\n indexWhereClause\n indexType\n isUnique\n indexFieldMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n order\n fieldMetadataId\n }\n }\n }\n }\n }\n }\n fieldsList {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isSystem\n isNullable\n isUnique\n createdAt\n updatedAt\n defaultValue\n options\n settings\n isLabelSyncedWithName\n relationDefinition {\n relationId\n direction\n sourceObjectMetadata {\n id\n nameSingular\n namePlural\n }\n sourceFieldMetadata {\n id\n name\n }\n targetObjectMetadata {\n id\n nameSingular\n namePlural\n }\n targetFieldMetadata {\n id\n name\n }\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n"): (typeof documents)["\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isRemote\n isActive\n isSystem\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n shortcut\n isLabelSyncedWithName\n isSearchable\n duplicateCriteria\n indexMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n name\n indexWhereClause\n indexType\n isUnique\n indexFieldMetadatas(paging: { first: 100 }) {\n edges {\n node {\n id\n createdAt\n updatedAt\n order\n fieldMetadataId\n }\n }\n }\n }\n }\n }\n fieldsList {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isSystem\n isNullable\n isUnique\n createdAt\n updatedAt\n defaultValue\n options\n settings\n isLabelSyncedWithName\n relationDefinition {\n relationId\n direction\n sourceObjectMetadata {\n id\n nameSingular\n namePlural\n }\n sourceFieldMetadata {\n id\n name\n }\n targetObjectMetadata {\n id\n nameSingular\n namePlural\n }\n targetFieldMetadata {\n id\n name\n }\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n"];
/** /**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/ */

File diff suppressed because one or more lines are too long

View File

@ -1147,6 +1147,7 @@ export type Object = {
isCustom: Scalars['Boolean']; isCustom: Scalars['Boolean'];
isLabelSyncedWithName: Scalars['Boolean']; isLabelSyncedWithName: Scalars['Boolean'];
isRemote: Scalars['Boolean']; isRemote: Scalars['Boolean'];
isSearchable: Scalars['Boolean'];
isSystem: Scalars['Boolean']; isSystem: Scalars['Boolean'];
labelIdentifierFieldMetadataId?: Maybe<Scalars['String']>; labelIdentifierFieldMetadataId?: Maybe<Scalars['String']>;
labelPlural: Scalars['String']; labelPlural: Scalars['String'];
@ -1199,6 +1200,7 @@ export type ObjectFilter = {
isActive?: InputMaybe<BooleanFieldComparison>; isActive?: InputMaybe<BooleanFieldComparison>;
isCustom?: InputMaybe<BooleanFieldComparison>; isCustom?: InputMaybe<BooleanFieldComparison>;
isRemote?: InputMaybe<BooleanFieldComparison>; isRemote?: InputMaybe<BooleanFieldComparison>;
isSearchable?: InputMaybe<BooleanFieldComparison>;
isSystem?: InputMaybe<BooleanFieldComparison>; isSystem?: InputMaybe<BooleanFieldComparison>;
or?: InputMaybe<Array<ObjectFilter>>; or?: InputMaybe<Array<ObjectFilter>>;
}; };

View File

@ -7,7 +7,6 @@ import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSi
import { EMPTY_QUERY } from '@/object-record/constants/EmptyQuery'; import { EMPTY_QUERY } from '@/object-record/constants/EmptyQuery';
import { useGenerateCombinedSearchRecordsQuery } from '@/object-record/multiple-objects/hooks/useGenerateCombinedSearchRecordsQuery'; import { useGenerateCombinedSearchRecordsQuery } from '@/object-record/multiple-objects/hooks/useGenerateCombinedSearchRecordsQuery';
import { MultiObjectRecordQueryResult } from '@/object-record/multiple-objects/types/MultiObjectRecordQueryResult'; import { MultiObjectRecordQueryResult } from '@/object-record/multiple-objects/types/MultiObjectRecordQueryResult';
import { isObjectMetadataItemSearchableInCombinedRequest } from '@/object-record/utils/isObjectMetadataItemSearchableInCombinedRequest';
import { isDefined } from 'twenty-shared'; import { isDefined } from 'twenty-shared';
export const useMultiObjectSearch = ({ export const useMultiObjectSearch = ({
@ -21,14 +20,11 @@ export const useMultiObjectSearch = ({
}) => { }) => {
const objectMetadataItems = useRecoilValue(objectMetadataItemsState); const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
const selectableObjectMetadataItems = objectMetadataItems const selectableObjectMetadataItems = objectMetadataItems.filter(
.filter(({ isSystem, isRemote }) => !isSystem && !isRemote) ({ nameSingular, isSearchable }) =>
.filter(({ nameSingular }) => { !excludedObjects?.includes(nameSingular as CoreObjectNameSingular) &&
return !excludedObjects?.includes(nameSingular as CoreObjectNameSingular); isSearchable,
}) );
.filter((objectMetadataItem) =>
isObjectMetadataItemSearchableInCombinedRequest(objectMetadataItem),
);
const { limitPerMetadataItem } = useLimitPerMetadataItem({ const { limitPerMetadataItem } = useLimitPerMetadataItem({
objectMetadataItems, objectMetadataItems,

View File

@ -13,6 +13,7 @@ export const CREATE_ONE_OBJECT_METADATA_ITEM = gql`
icon icon
isCustom isCustom
isActive isActive
isSearchable
createdAt createdAt
updatedAt updatedAt
labelIdentifierFieldMetadataId labelIdentifierFieldMetadataId
@ -98,6 +99,7 @@ export const UPDATE_ONE_OBJECT_METADATA_ITEM = gql`
icon icon
isCustom isCustom
isActive isActive
isSearchable
createdAt createdAt
updatedAt updatedAt
labelIdentifierFieldMetadataId labelIdentifierFieldMetadataId
@ -119,6 +121,7 @@ export const DELETE_ONE_OBJECT_METADATA_ITEM = gql`
icon icon
isCustom isCustom
isActive isActive
isSearchable
createdAt createdAt
updatedAt updatedAt
labelIdentifierFieldMetadataId labelIdentifierFieldMetadataId

View File

@ -23,6 +23,7 @@ export const FIND_MANY_OBJECT_METADATA_ITEMS = gql`
imageIdentifierFieldMetadataId imageIdentifierFieldMetadataId
shortcut shortcut
isLabelSyncedWithName isLabelSyncedWithName
isSearchable
duplicateCriteria duplicateCriteria
indexMetadatas(paging: { first: 100 }) { indexMetadatas(paging: { first: 100 }) {
edges { edges {

View File

@ -13,6 +13,7 @@ export const query = gql`
icon icon
isCustom isCustom
isActive isActive
isSearchable
createdAt createdAt
updatedAt updatedAt
labelIdentifierFieldMetadataId labelIdentifierFieldMetadataId
@ -79,6 +80,7 @@ export const responseData = {
icon: '', icon: '',
isCustom: false, isCustom: false,
isActive: true, isActive: true,
isSearchable: false,
createdAt: '', createdAt: '',
updatedAt: '', updatedAt: '',
labelIdentifierFieldMetadataId: '20202020-72ba-4e11-a36d-e17b544541e1', labelIdentifierFieldMetadataId: '20202020-72ba-4e11-a36d-e17b544541e1',

View File

@ -13,6 +13,7 @@ export const query = gql`
icon icon
isCustom isCustom
isActive isActive
isSearchable
createdAt createdAt
updatedAt updatedAt
labelIdentifierFieldMetadataId labelIdentifierFieldMetadataId
@ -34,6 +35,7 @@ export const responseData = {
icon: '', icon: '',
isCustom: false, isCustom: false,
isActive: true, isActive: true,
isSearchable: false,
createdAt: '', createdAt: '',
updatedAt: '', updatedAt: '',
labelIdentifierFieldMetadataId: '20202020-72ba-4e11-a36d-e17b544541e1', labelIdentifierFieldMetadataId: '20202020-72ba-4e11-a36d-e17b544541e1',

View File

@ -21,6 +21,7 @@ describe('useLimitPerMetadataItem', () => {
isCustom: true, isCustom: true,
isSystem: true, isSystem: true,
isRemote: false, isRemote: false,
isSearchable: true,
labelPlural: 'labelPlural', labelPlural: 'labelPlural',
labelSingular: 'labelSingular', labelSingular: 'labelSingular',
namePlural: 'namePlural', namePlural: 'namePlural',

View File

@ -20,6 +20,7 @@ export const objectMetadataItemSchema = z.object({
isCustom: z.boolean(), isCustom: z.boolean(),
isRemote: z.boolean(), isRemote: z.boolean(),
isSystem: z.boolean(), isSystem: z.boolean(),
isSearchable: z.boolean(),
labelIdentifierFieldMetadataId: z.string().uuid(), labelIdentifierFieldMetadataId: z.string().uuid(),
labelPlural: metadataLabelSchema(), labelPlural: metadataLabelSchema(),
labelSingular: metadataLabelSchema(), labelSingular: metadataLabelSchema(),

View File

@ -17,6 +17,7 @@ const mockObjectMetadataItem: ObjectMetadataItem = {
labelSingular: 'Company', labelSingular: 'Company',
labelPlural: 'Companies', labelPlural: 'Companies',
isCustom: false, isCustom: false,
isSearchable: false,
labelIdentifierFieldMetadataId: '20202020-dd4a-4ea4-bb7b-1c7300491b65', labelIdentifierFieldMetadataId: '20202020-dd4a-4ea4-bb7b-1c7300491b65',
isActive: true, isActive: true,
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),

View File

@ -6,7 +6,6 @@ import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadat
import { mapObjectMetadataToGraphQLQuery } from '@/object-metadata/utils/mapObjectMetadataToGraphQLQuery'; import { mapObjectMetadataToGraphQLQuery } from '@/object-metadata/utils/mapObjectMetadataToGraphQLQuery';
import { RecordGqlOperationSignature } from '@/object-record/graphql/types/RecordGqlOperationSignature'; import { RecordGqlOperationSignature } from '@/object-record/graphql/types/RecordGqlOperationSignature';
import { getSearchRecordsQueryResponseField } from '@/object-record/utils/getSearchRecordsQueryResponseField'; import { getSearchRecordsQueryResponseField } from '@/object-record/utils/getSearchRecordsQueryResponseField';
import { isObjectMetadataItemSearchable } from '@/object-record/utils/isObjectMetadataItemSearchable';
import { capitalize } from 'twenty-shared'; import { capitalize } from 'twenty-shared';
import { isNonEmptyArray } from '~/utils/isNonEmptyArray'; import { isNonEmptyArray } from '~/utils/isNonEmptyArray';
@ -55,8 +54,8 @@ export const useGenerateCombinedSearchRecordsQuery = ({
); );
const filteredQueryKeyWithObjectMetadataItemArray = const filteredQueryKeyWithObjectMetadataItemArray =
queryKeyWithObjectMetadataItemArray.filter(({ objectMetadataItem }) => queryKeyWithObjectMetadataItemArray.filter(
isObjectMetadataItemSearchable(objectMetadataItem), ({ objectMetadataItem }) => objectMetadataItem.isSearchable,
); );
return gql` return gql`

View File

@ -29,6 +29,7 @@ const objectMetadataItemWithPositionField: ObjectMetadataItem = {
isSystem: false, isSystem: false,
isCustom: false, isCustom: false,
isRemote: false, isRemote: false,
isSearchable: false,
labelPlural: 'object1s', labelPlural: 'object1s',
labelSingular: 'object1', labelSingular: 'object1',
isLabelSyncedWithName: true, isLabelSyncedWithName: true,

View File

@ -18,6 +18,7 @@ describe('buildRecordGqlFieldsAggregateForView', () => {
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isRemote: false, isRemote: false,
isSearchable: false,
labelIdentifierFieldMetadataId: '06b33746-5293-4d07-9f7f-ebf5ad396064', labelIdentifierFieldMetadataId: '06b33746-5293-4d07-9f7f-ebf5ad396064',
imageIdentifierFieldMetadataId: null, imageIdentifierFieldMetadataId: null,
isLabelSyncedWithName: true, isLabelSyncedWithName: true,

View File

@ -12,6 +12,7 @@ describe('generateAggregateQuery', () => {
labelIdentifierFieldMetadataId: '20202020-72ba-4e11-a36d-e17b544541e1', labelIdentifierFieldMetadataId: '20202020-72ba-4e11-a36d-e17b544541e1',
isCustom: false, isCustom: false,
isActive: true, isActive: true,
isSearchable: false,
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(), updatedAt: new Date().toISOString(),
fields: [], fields: [],
@ -50,6 +51,7 @@ describe('generateAggregateQuery', () => {
labelIdentifierFieldMetadataId: '20202020-72ba-4e11-a36d-e17b544541e1', labelIdentifierFieldMetadataId: '20202020-72ba-4e11-a36d-e17b544541e1',
isCustom: false, isCustom: false,
isActive: true, isActive: true,
isSearchable: false,
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(), updatedAt: new Date().toISOString(),
fields: [], fields: [],

View File

@ -1,17 +0,0 @@
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
const SEARCHABLE_STANDARD_OBJECTS_NAMES_PLURAL = [
'companies',
'people',
'opportunities',
];
export const isObjectMetadataItemSearchable = (
objectMetadataItem: ObjectMetadataItem,
) => {
return (
objectMetadataItem.isCustom ||
SEARCHABLE_STANDARD_OBJECTS_NAMES_PLURAL.includes(
objectMetadataItem.namePlural,
)
);
};

View File

@ -1,17 +0,0 @@
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
const SEARCHABLE_STANDARD_OBJECTS_IN_COMBINED_REQUEST_NAMES_PLURAL = [
'companies',
'people',
'opportunities',
];
export const isObjectMetadataItemSearchableInCombinedRequest = (
objectMetadataItem: ObjectMetadataItem,
) => {
return (
objectMetadataItem.isCustom ||
SEARCHABLE_STANDARD_OBJECTS_IN_COMBINED_REQUEST_NAMES_PLURAL.includes(
objectMetadataItem.namePlural,
)
);
};

View File

@ -31,6 +31,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "0171f47e-f1e8-4e28-949e-b0a8e1a17356", labelIdentifierFieldMetadataId: "0171f47e-f1e8-4e28-949e-b0a8e1a17356",
@ -501,6 +502,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "f8ffb39e-dafb-4b61-b2be-e5b41a548ef0", labelIdentifierFieldMetadataId: "f8ffb39e-dafb-4b61-b2be-e5b41a548ef0",
@ -856,6 +858,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "d1d1ff00-7330-4c8d-b9b6-ae9f713e5c38", labelIdentifierFieldMetadataId: "d1d1ff00-7330-4c8d-b9b6-ae9f713e5c38",
@ -1516,6 +1519,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "61946ba1-4743-4ced-a6d7-0d06a8c12f07", labelIdentifierFieldMetadataId: "61946ba1-4743-4ced-a6d7-0d06a8c12f07",
@ -2207,6 +2211,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "db996c62-eb44-4381-bcc2-46989d681f3a", labelIdentifierFieldMetadataId: "db996c62-eb44-4381-bcc2-46989d681f3a",
@ -3025,6 +3030,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isSearchable: true,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "585c1f2f-21d0-49d6-9d63-f830010a79da", labelIdentifierFieldMetadataId: "585c1f2f-21d0-49d6-9d63-f830010a79da",
@ -3987,6 +3993,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isSearchable: true,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "28d93256-a262-422a-8f19-fbe1329fedfb", labelIdentifierFieldMetadataId: "28d93256-a262-422a-8f19-fbe1329fedfb",
@ -4434,6 +4441,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "9db27f2b-a332-4017-9f55-142d877b2fee", labelIdentifierFieldMetadataId: "9db27f2b-a332-4017-9f55-142d877b2fee",
@ -4925,6 +4933,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "08b10273-9750-4bc6-9f83-8cbad795bf18", labelIdentifierFieldMetadataId: "08b10273-9750-4bc6-9f83-8cbad795bf18",
@ -5809,6 +5818,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "f14938c3-58cc-4896-85a7-cea1c6fe9d0f", labelIdentifierFieldMetadataId: "f14938c3-58cc-4896-85a7-cea1c6fe9d0f",
@ -5976,6 +5986,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "029ea2ee-6ffe-45a5-93f2-85cefc83f019", labelIdentifierFieldMetadataId: "029ea2ee-6ffe-45a5-93f2-85cefc83f019",
@ -6372,6 +6383,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "6572b4bf-c981-4db9-8f90-309522762cc2", labelIdentifierFieldMetadataId: "6572b4bf-c981-4db9-8f90-309522762cc2",
@ -6686,6 +6698,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "dba26a5c-e28a-46cc-b864-6e44ccc75cc7", labelIdentifierFieldMetadataId: "dba26a5c-e28a-46cc-b864-6e44ccc75cc7",
@ -7601,6 +7614,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "cbf8a777-7bea-4fc6-94e5-a5183bc5567b", labelIdentifierFieldMetadataId: "cbf8a777-7bea-4fc6-94e5-a5183bc5567b",
@ -7807,6 +7821,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "f5dbede2-acbb-43b9-82a0-c7bff8155a3f", labelIdentifierFieldMetadataId: "f5dbede2-acbb-43b9-82a0-c7bff8155a3f",
@ -8288,6 +8303,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "1d9070ea-776b-4a86-b5ec-08f57d84a87d", labelIdentifierFieldMetadataId: "1d9070ea-776b-4a86-b5ec-08f57d84a87d",
@ -8538,6 +8554,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "c8e0cf61-e509-4019-82a4-41482cb9f875", labelIdentifierFieldMetadataId: "c8e0cf61-e509-4019-82a4-41482cb9f875",
@ -8906,6 +8923,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "a74894a3-4065-4b87-ab17-3252c709235b", labelIdentifierFieldMetadataId: "a74894a3-4065-4b87-ab17-3252c709235b",
@ -9115,6 +9133,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "7a9d535e-6665-4de0-a301-d3ffaf94e1fb", labelIdentifierFieldMetadataId: "7a9d535e-6665-4de0-a301-d3ffaf94e1fb",
@ -10507,6 +10526,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "b3df551f-1afb-4a2b-b899-3b49d111b16b", labelIdentifierFieldMetadataId: "b3df551f-1afb-4a2b-b899-3b49d111b16b",
@ -10820,6 +10840,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "7a836cd1-9002-44c6-8ce4-17558bb97a34", labelIdentifierFieldMetadataId: "7a836cd1-9002-44c6-8ce4-17558bb97a34",
@ -11059,6 +11080,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "6f4cc8ad-8342-4e36-b689-2474d767885f", labelIdentifierFieldMetadataId: "6f4cc8ad-8342-4e36-b689-2474d767885f",
@ -11719,6 +11741,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "dafe5e84-56d7-4cb8-a11e-7423e9e1c414", labelIdentifierFieldMetadataId: "dafe5e84-56d7-4cb8-a11e-7423e9e1c414",
@ -12063,6 +12086,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "002c37a7-caa7-48de-b453-c409528fb789", labelIdentifierFieldMetadataId: "002c37a7-caa7-48de-b453-c409528fb789",
@ -12807,6 +12831,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "321ef6c3-e01f-4080-9e8e-938810622ed8", labelIdentifierFieldMetadataId: "321ef6c3-e01f-4080-9e8e-938810622ed8",
@ -13426,6 +13451,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isSearchable: true,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "d4ee3d39-1df1-46a4-a9aa-569119458656", labelIdentifierFieldMetadataId: "d4ee3d39-1df1-46a4-a9aa-569119458656",
@ -14235,6 +14261,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isSearchable: true,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "9a08e8f4-4cf2-4586-b188-4542fe24c4e0", labelIdentifierFieldMetadataId: "9a08e8f4-4cf2-4586-b188-4542fe24c4e0",
@ -15282,6 +15309,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "91acce03-f503-4d7b-99ae-03898590baf6", labelIdentifierFieldMetadataId: "91acce03-f503-4d7b-99ae-03898590baf6",
@ -16586,6 +16614,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "a325a92e-c357-43cd-9a9f-042bbb5f8cd0", labelIdentifierFieldMetadataId: "a325a92e-c357-43cd-9a9f-042bbb5f8cd0",
@ -17112,6 +17141,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isSearchable: true,
createdAt: "2025-02-11T09:14:40.039Z", createdAt: "2025-02-11T09:14:40.039Z",
updatedAt: "2025-02-11T09:14:40.043Z", updatedAt: "2025-02-11T09:14:40.043Z",
labelIdentifierFieldMetadataId: "5bdf1a3a-986b-48d0-87c4-8fa683f005f3", labelIdentifierFieldMetadataId: "5bdf1a3a-986b-48d0-87c4-8fa683f005f3",
@ -17722,6 +17752,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "84cc32f8-52cf-4988-873d-43860a6ca370", labelIdentifierFieldMetadataId: "84cc32f8-52cf-4988-873d-43860a6ca370",
@ -17905,6 +17936,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "43b566c4-0d50-47c8-818a-b2b0475181a4", labelIdentifierFieldMetadataId: "43b566c4-0d50-47c8-818a-b2b0475181a4",
@ -18316,6 +18348,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isSearchable: true,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "f9ef48ef-c0a1-49cc-ad51-35a4e2a8a6e0", labelIdentifierFieldMetadataId: "f9ef48ef-c0a1-49cc-ad51-35a4e2a8a6e0",
@ -18935,6 +18968,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "ed8938cf-bb8d-46a0-8f8c-1e2132978716", labelIdentifierFieldMetadataId: "ed8938cf-bb8d-46a0-8f8c-1e2132978716",
@ -19418,6 +19452,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "ed2a4301-ae23-41ad-85e7-04e7082c478e", labelIdentifierFieldMetadataId: "ed2a4301-ae23-41ad-85e7-04e7082c478e",
@ -20027,6 +20062,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "2df3fe9d-60af-46a9-917f-dec16c0a9c33", labelIdentifierFieldMetadataId: "2df3fe9d-60af-46a9-917f-dec16c0a9c33",
@ -20315,6 +20351,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isSearchable: true,
createdAt: "2025-02-11T09:14:39.321Z", createdAt: "2025-02-11T09:14:39.321Z",
updatedAt: "2025-02-11T09:14:39.327Z", updatedAt: "2025-02-11T09:14:39.327Z",
labelIdentifierFieldMetadataId: "0c3bb20e-2d2d-4c1b-a1aa-5a44d7e55818", labelIdentifierFieldMetadataId: "0c3bb20e-2d2d-4c1b-a1aa-5a44d7e55818",
@ -21261,6 +21298,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
isRemote: false, isRemote: false,
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isSearchable: false,
createdAt: "2025-02-11T09:14:32.715Z", createdAt: "2025-02-11T09:14:32.715Z",
updatedAt: "2025-02-11T09:14:32.715Z", updatedAt: "2025-02-11T09:14:32.715Z",
labelIdentifierFieldMetadataId: "251826b3-199d-44f8-93ce-5165f17701b3", labelIdentifierFieldMetadataId: "251826b3-199d-44f8-93ce-5165f17701b3",

View File

@ -2,17 +2,17 @@ import chalk from 'chalk';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
import { import {
ActiveWorkspacesMigrationCommandOptions, MaintainedWorkspacesMigrationCommandOptions,
ActiveWorkspacesMigrationCommandRunner, MaintainedWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/active-workspaces-migration-command.runner'; } from 'src/database/commands/migration-command/maintained-workspaces-migration-command.runner';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { WorkspaceDataSource } from 'src/engine/twenty-orm/datasource/workspace.datasource'; import { WorkspaceDataSource } from 'src/engine/twenty-orm/datasource/workspace.datasource';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager'; import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
export abstract class BatchActiveWorkspacesMigrationCommandRunner< export abstract class BatchMaintainedWorkspacesMigrationCommandRunner<
Options extends Options extends
ActiveWorkspacesMigrationCommandOptions = ActiveWorkspacesMigrationCommandOptions, MaintainedWorkspacesMigrationCommandOptions = MaintainedWorkspacesMigrationCommandOptions,
> extends ActiveWorkspacesMigrationCommandRunner<Options> { > extends MaintainedWorkspacesMigrationCommandRunner<Options> {
constructor( constructor(
protected readonly workspaceRepository: Repository<Workspace>, protected readonly workspaceRepository: Repository<Workspace>,
protected readonly twentyORMGlobalManager: TwentyORMGlobalManager, protected readonly twentyORMGlobalManager: TwentyORMGlobalManager,
@ -20,7 +20,7 @@ export abstract class BatchActiveWorkspacesMigrationCommandRunner<
super(workspaceRepository, twentyORMGlobalManager); super(workspaceRepository, twentyORMGlobalManager);
} }
async runMigrationCommandOnActiveWorkspaces( async runMigrationCommandOnMaintainedWorkspaces(
_passedParams: string[], _passedParams: string[],
_options: Options, _options: Options,
activeWorkspaceIds: string[], activeWorkspaceIds: string[],

View File

@ -10,16 +10,16 @@ import {
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager'; import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
export type ActiveWorkspacesMigrationCommandOptions = export type MaintainedWorkspacesMigrationCommandOptions =
MigrationCommandOptions & { MigrationCommandOptions & {
workspaceId?: string; workspaceId?: string;
startFromWorkspaceId?: string; startFromWorkspaceId?: string;
workspaceCountLimit?: number; workspaceCountLimit?: number;
}; };
export abstract class ActiveWorkspacesMigrationCommandRunner< export abstract class MaintainedWorkspacesMigrationCommandRunner<
Options extends Options extends
ActiveWorkspacesMigrationCommandOptions = ActiveWorkspacesMigrationCommandOptions, MaintainedWorkspacesMigrationCommandOptions = MaintainedWorkspacesMigrationCommandOptions,
> extends MigrationCommandRunner<Options> { > extends MigrationCommandRunner<Options> {
private workspaceIds: string[] = []; private workspaceIds: string[] = [];
private startFromWorkspaceId: string | undefined; private startFromWorkspaceId: string | undefined;
@ -124,14 +124,14 @@ export abstract class ActiveWorkspacesMigrationCommandRunner<
this.logger.log(chalk.yellow('Dry run mode: No changes will be applied')); this.logger.log(chalk.yellow('Dry run mode: No changes will be applied'));
} }
await this.runMigrationCommandOnActiveWorkspaces( await this.runMigrationCommandOnMaintainedWorkspaces(
passedParams, passedParams,
options, options,
activeWorkspaceIds, activeWorkspaceIds,
); );
} }
protected abstract runMigrationCommandOnActiveWorkspaces( protected abstract runMigrationCommandOnMaintainedWorkspaces(
passedParams: string[], passedParams: string[],
options: Options, options: Options,
activeWorkspaceIds: string[], activeWorkspaceIds: string[],

View File

@ -6,9 +6,9 @@ import { In, Repository } from 'typeorm';
import { isCommandLogger } from 'src/database/commands/logger'; import { isCommandLogger } from 'src/database/commands/logger';
import { import {
ActiveWorkspacesMigrationCommandOptions, MaintainedWorkspacesMigrationCommandOptions,
ActiveWorkspacesMigrationCommandRunner, MaintainedWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/active-workspaces-migration-command.runner'; } from 'src/database/commands/migration-command/maintained-workspaces-migration-command.runner';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity'; import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
import { WorkspaceMetadataVersionService } from 'src/engine/metadata-modules/workspace-metadata-version/services/workspace-metadata-version.service'; import { WorkspaceMetadataVersionService } from 'src/engine/metadata-modules/workspace-metadata-version/services/workspace-metadata-version.service';
@ -20,7 +20,7 @@ import { ViewWorkspaceEntity } from 'src/modules/view/standard-objects/view.work
name: 'upgrade-0.42:fix-body-v2-view-field-position', name: 'upgrade-0.42:fix-body-v2-view-field-position',
description: 'Make bodyV2 field position to match body field position', description: 'Make bodyV2 field position to match body field position',
}) })
export class FixBodyV2ViewFieldPositionCommand extends ActiveWorkspacesMigrationCommandRunner { export class FixBodyV2ViewFieldPositionCommand extends MaintainedWorkspacesMigrationCommandRunner {
constructor( constructor(
@InjectRepository(Workspace, 'core') @InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>, protected readonly workspaceRepository: Repository<Workspace>,
@ -32,9 +32,9 @@ export class FixBodyV2ViewFieldPositionCommand extends ActiveWorkspacesMigration
super(workspaceRepository, twentyORMGlobalManager); super(workspaceRepository, twentyORMGlobalManager);
} }
async runMigrationCommandOnActiveWorkspaces( async runMigrationCommandOnMaintainedWorkspaces(
_passedParam: string[], _passedParam: string[],
options: ActiveWorkspacesMigrationCommandOptions, options: MaintainedWorkspacesMigrationCommandOptions,
workspaceIds: string[], workspaceIds: string[],
): Promise<void> { ): Promise<void> {
this.logger.log('Running command to fix bodyV2 field position'); this.logger.log('Running command to fix bodyV2 field position');

View File

@ -4,11 +4,11 @@ import chalk from 'chalk';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
import { CommandLogger } from 'src/database/commands/logger'; import { CommandLogger } from 'src/database/commands/logger';
import {
ActiveWorkspacesMigrationCommandOptions,
ActiveWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/active-workspaces-migration-command.runner';
import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator'; import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator';
import {
MaintainedWorkspacesMigrationCommandOptions,
MaintainedWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/maintained-workspaces-migration-command.runner';
import { settings } from 'src/engine/constants/settings'; import { settings } from 'src/engine/constants/settings';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager'; import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
@ -20,7 +20,7 @@ import { ViewWorkspaceEntity } from 'src/modules/view/standard-objects/view.work
description: 'Limit amount of view field.', description: 'Limit amount of view field.',
version: '0.42', version: '0.42',
}) })
export class LimitAmountOfViewFieldCommand extends ActiveWorkspacesMigrationCommandRunner { export class LimitAmountOfViewFieldCommand extends MaintainedWorkspacesMigrationCommandRunner {
protected readonly logger: CommandLogger; protected readonly logger: CommandLogger;
constructor( constructor(
@ -95,9 +95,9 @@ export class LimitAmountOfViewFieldCommand extends ActiveWorkspacesMigrationComm
} }
} }
async runMigrationCommandOnActiveWorkspaces( async runMigrationCommandOnMaintainedWorkspaces(
_passedParam: string[], _passedParam: string[],
options: ActiveWorkspacesMigrationCommandOptions, options: MaintainedWorkspacesMigrationCommandOptions,
workspaceIds: string[], workspaceIds: string[],
): Promise<void> { ): Promise<void> {
this.logger.log(`Running limit-amount-of-view-field command`); this.logger.log(`Running limit-amount-of-view-field command`);

View File

@ -7,11 +7,11 @@ import { FieldMetadataType, isDefined } from 'twenty-shared';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
import { isCommandLogger } from 'src/database/commands/logger'; import { isCommandLogger } from 'src/database/commands/logger';
import {
ActiveWorkspacesMigrationCommandOptions,
ActiveWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/active-workspaces-migration-command.runner';
import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator'; import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator';
import {
MaintainedWorkspacesMigrationCommandOptions,
MaintainedWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/maintained-workspaces-migration-command.runner';
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum'; import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
import { FeatureFlag } from 'src/engine/core-modules/feature-flag/feature-flag.entity'; import { FeatureFlag } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
@ -59,7 +59,7 @@ type ProcessRichTextFieldsArgs = {
}; };
type MigrateRichTextFieldCommandOptions = type MigrateRichTextFieldCommandOptions =
ActiveWorkspacesMigrationCommandOptions & { MaintainedWorkspacesMigrationCommandOptions & {
force?: boolean; force?: boolean;
}; };
@ -68,7 +68,7 @@ type MigrateRichTextFieldCommandOptions =
description: 'Migrate RICH_TEXT fields to new composite structure', description: 'Migrate RICH_TEXT fields to new composite structure',
version: '0.42', version: '0.42',
}) })
export class MigrateRichTextFieldCommand extends ActiveWorkspacesMigrationCommandRunner<MigrateRichTextFieldCommandOptions> { export class MigrateRichTextFieldCommand extends MaintainedWorkspacesMigrationCommandRunner<MigrateRichTextFieldCommandOptions> {
private options: MigrateRichTextFieldCommandOptions; private options: MigrateRichTextFieldCommandOptions;
constructor( constructor(
@ -99,7 +99,7 @@ export class MigrateRichTextFieldCommand extends ActiveWorkspacesMigrationComman
return val ?? false; return val ?? false;
} }
async runMigrationCommandOnActiveWorkspaces( async runMigrationCommandOnMaintainedWorkspaces(
_passedParam: string[], _passedParam: string[],
options: MigrateRichTextFieldCommandOptions, options: MigrateRichTextFieldCommandOptions,
workspaceIds: string[], workspaceIds: string[],

View File

@ -5,11 +5,11 @@ import { FieldMetadataType } from 'twenty-shared';
import { IsNull, Repository } from 'typeorm'; import { IsNull, Repository } from 'typeorm';
import { CommandLogger } from 'src/database/commands/logger'; import { CommandLogger } from 'src/database/commands/logger';
import {
ActiveWorkspacesMigrationCommandOptions,
ActiveWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/active-workspaces-migration-command.runner';
import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator'; import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator';
import {
MaintainedWorkspacesMigrationCommandOptions,
MaintainedWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/maintained-workspaces-migration-command.runner';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { WorkspaceMetadataVersionService } from 'src/engine/metadata-modules/workspace-metadata-version/services/workspace-metadata-version.service'; import { WorkspaceMetadataVersionService } from 'src/engine/metadata-modules/workspace-metadata-version/services/workspace-metadata-version.service';
@ -20,7 +20,7 @@ import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.
description: 'Add context to actor composite type.', description: 'Add context to actor composite type.',
version: '0.42', version: '0.42',
}) })
export class StandardizationOfActorCompositeContextTypeCommand extends ActiveWorkspacesMigrationCommandRunner { export class StandardizationOfActorCompositeContextTypeCommand extends MaintainedWorkspacesMigrationCommandRunner {
protected readonly logger; protected readonly logger;
constructor( constructor(
@ -40,9 +40,9 @@ export class StandardizationOfActorCompositeContextTypeCommand extends ActiveWor
this.logger.setVerbose(false); this.logger.setVerbose(false);
} }
async runMigrationCommandOnActiveWorkspaces( async runMigrationCommandOnMaintainedWorkspaces(
_passedParam: string[], _passedParam: string[],
options: ActiveWorkspacesMigrationCommandOptions, options: MaintainedWorkspacesMigrationCommandOptions,
workspaceIds: string[], workspaceIds: string[],
): Promise<void> { ): Promise<void> {
this.logger.log(`Running add-context-to-actor-composite-type command`); this.logger.log(`Running add-context-to-actor-composite-type command`);

View File

@ -1,7 +1,7 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { MigrationCommandModule } from 'src/database/commands/migration-command/miration-command.module'; import { MigrationCommandModule } from 'src/database/commands/migration-command/migration-command.module';
import { FixBodyV2ViewFieldPositionCommand } from 'src/database/commands/upgrade-version/0-42/0-42-fix-body-v2-view-field-position.command'; import { FixBodyV2ViewFieldPositionCommand } from 'src/database/commands/upgrade-version/0-42/0-42-fix-body-v2-view-field-position.command';
import { LimitAmountOfViewFieldCommand } from 'src/database/commands/upgrade-version/0-42/0-42-limit-amount-of-view-field'; import { LimitAmountOfViewFieldCommand } from 'src/database/commands/upgrade-version/0-42/0-42-limit-amount-of-view-field';
import { MigrateRichTextFieldCommand } from 'src/database/commands/upgrade-version/0-42/0-42-migrate-rich-text-field.command'; import { MigrateRichTextFieldCommand } from 'src/database/commands/upgrade-version/0-42/0-42-migrate-rich-text-field.command';

View File

@ -5,11 +5,11 @@ import { Repository } from 'typeorm';
import { v4 } from 'uuid'; import { v4 } from 'uuid';
import { isCommandLogger } from 'src/database/commands/logger'; import { isCommandLogger } from 'src/database/commands/logger';
import {
ActiveWorkspacesMigrationCommandOptions,
ActiveWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/active-workspaces-migration-command.runner';
import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator'; import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator';
import {
MaintainedWorkspacesMigrationCommandOptions,
MaintainedWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/maintained-workspaces-migration-command.runner';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { FieldMetadataDefaultOption } from 'src/engine/metadata-modules/field-metadata/dtos/options.input'; import { FieldMetadataDefaultOption } from 'src/engine/metadata-modules/field-metadata/dtos/options.input';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
@ -29,7 +29,7 @@ import { ViewWorkspaceEntity } from 'src/modules/view/standard-objects/view.work
description: 'Add tasks assigned to me view', description: 'Add tasks assigned to me view',
version: '0.43', version: '0.43',
}) })
export class AddTasksAssignedToMeViewCommand extends ActiveWorkspacesMigrationCommandRunner { export class AddTasksAssignedToMeViewCommand extends MaintainedWorkspacesMigrationCommandRunner {
constructor( constructor(
@InjectRepository(Workspace, 'core') @InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>, protected readonly workspaceRepository: Repository<Workspace>,
@ -43,9 +43,9 @@ export class AddTasksAssignedToMeViewCommand extends ActiveWorkspacesMigrationCo
super(workspaceRepository, twentyORMGlobalManager); super(workspaceRepository, twentyORMGlobalManager);
} }
async runMigrationCommandOnActiveWorkspaces( async runMigrationCommandOnMaintainedWorkspaces(
_passedParam: string[], _passedParam: string[],
options: ActiveWorkspacesMigrationCommandOptions, options: MaintainedWorkspacesMigrationCommandOptions,
workspaceIds: string[], workspaceIds: string[],
): Promise<void> { ): Promise<void> {
this.logger.log('Running command to create many to one relations'); this.logger.log('Running command to create many to one relations');

View File

@ -0,0 +1,74 @@
import { InjectRepository } from '@nestjs/typeorm';
import chalk from 'chalk';
import { Repository } from 'typeorm';
import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator';
import {
MaintainedWorkspacesMigrationCommandOptions,
MaintainedWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/maintained-workspaces-migration-command.runner';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
@MigrationCommand({
name: 'migrate-is-searchable-for-custom-object-metadata',
description: 'Set isSearchable true for custom object metadata',
version: '0.43',
})
export class MigrateIsSearchableForCustomObjectMetadataCommand extends MaintainedWorkspacesMigrationCommandRunner {
constructor(
@InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>,
protected readonly twentyORMGlobalManager: TwentyORMGlobalManager,
@InjectRepository(ObjectMetadataEntity, 'metadata')
protected readonly objectMetadataRepository: Repository<ObjectMetadataEntity>,
) {
super(workspaceRepository, twentyORMGlobalManager);
}
async runMigrationCommandOnMaintainedWorkspaces(
_passedParam: string[],
_options: MaintainedWorkspacesMigrationCommandOptions,
workspaceIds: string[],
): Promise<void> {
this.logger.log(
chalk.green(
'Running command to set isSearchable true for custom object metadata',
),
);
for (const [index, workspaceId] of workspaceIds.entries()) {
await this.processWorkspace(workspaceId, index, workspaceIds.length);
}
this.logger.log(chalk.green('Command completed!'));
}
private async processWorkspace(
workspaceId: string,
index: number,
total: number,
): Promise<void> {
try {
this.logger.log(
`Running command for workspace ${workspaceId} ${index + 1}/${total}`,
);
await this.objectMetadataRepository.update(
{
workspaceId,
isCustom: true,
},
{
isSearchable: true,
},
);
} catch (error) {
this.logger.log(
chalk.red(`Error in workspace ${workspaceId} - ${error.message}`),
);
}
}
}

View File

@ -7,11 +7,11 @@ import { In, Repository } from 'typeorm';
import { RelationType } from 'src/engine/metadata-modules/field-metadata/interfaces/relation-type.interface'; import { RelationType } from 'src/engine/metadata-modules/field-metadata/interfaces/relation-type.interface';
import { isCommandLogger } from 'src/database/commands/logger'; import { isCommandLogger } from 'src/database/commands/logger';
import {
ActiveWorkspacesMigrationCommandOptions,
ActiveWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/active-workspaces-migration-command.runner';
import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator'; import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator';
import {
MaintainedWorkspacesMigrationCommandOptions,
MaintainedWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/maintained-workspaces-migration-command.runner';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager'; import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
@ -26,7 +26,7 @@ import { isFieldMetadataOfType } from 'src/engine/utils/is-field-metadata-of-typ
description: 'Migrate relations to field metadata', description: 'Migrate relations to field metadata',
version: '0.43', version: '0.43',
}) })
export class MigrateRelationsToFieldMetadataCommand extends ActiveWorkspacesMigrationCommandRunner { export class MigrateRelationsToFieldMetadataCommand extends MaintainedWorkspacesMigrationCommandRunner {
constructor( constructor(
@InjectRepository(Workspace, 'core') @InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>, protected readonly workspaceRepository: Repository<Workspace>,
@ -37,9 +37,9 @@ export class MigrateRelationsToFieldMetadataCommand extends ActiveWorkspacesMigr
super(workspaceRepository, twentyORMGlobalManager); super(workspaceRepository, twentyORMGlobalManager);
} }
async runMigrationCommandOnActiveWorkspaces( async runMigrationCommandOnMaintainedWorkspaces(
_passedParam: string[], _passedParam: string[],
options: ActiveWorkspacesMigrationCommandOptions, options: MaintainedWorkspacesMigrationCommandOptions,
workspaceIds: string[], workspaceIds: string[],
): Promise<void> { ): Promise<void> {
this.logger.log('Running command to create many to one relations'); this.logger.log('Running command to create many to one relations');

View File

@ -3,11 +3,11 @@ import { InjectRepository } from '@nestjs/typeorm';
import chalk from 'chalk'; import chalk from 'chalk';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
import {
ActiveWorkspacesMigrationCommandOptions,
ActiveWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/active-workspaces-migration-command.runner';
import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator'; import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator';
import {
MaintainedWorkspacesMigrationCommandOptions,
MaintainedWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/maintained-workspaces-migration-command.runner';
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum'; import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
import { FeatureFlag } from 'src/engine/core-modules/feature-flag/feature-flag.entity'; import { FeatureFlag } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
@ -24,7 +24,7 @@ import { SEARCH_FIELDS_FOR_TASKS } from 'src/modules/task/standard-objects/task.
description: 'Migrate search vector on note and task entities', description: 'Migrate search vector on note and task entities',
version: '0.43', version: '0.43',
}) })
export class MigrateSearchVectorOnNoteAndTaskEntitiesCommand extends ActiveWorkspacesMigrationCommandRunner { export class MigrateSearchVectorOnNoteAndTaskEntitiesCommand extends MaintainedWorkspacesMigrationCommandRunner {
constructor( constructor(
@InjectRepository(Workspace, 'core') @InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>, protected readonly workspaceRepository: Repository<Workspace>,
@ -40,9 +40,9 @@ export class MigrateSearchVectorOnNoteAndTaskEntitiesCommand extends ActiveWorks
super(workspaceRepository, twentyORMGlobalManager); super(workspaceRepository, twentyORMGlobalManager);
} }
async runMigrationCommandOnActiveWorkspaces( async runMigrationCommandOnMaintainedWorkspaces(
_passedParam: string[], _passedParam: string[],
options: ActiveWorkspacesMigrationCommandOptions, options: MaintainedWorkspacesMigrationCommandOptions,
workspaceIds: string[], workspaceIds: string[],
): Promise<void> { ): Promise<void> {
this.logger.log( this.logger.log(

View File

@ -3,7 +3,7 @@ import { InjectRepository } from '@nestjs/typeorm';
import chalk from 'chalk'; import chalk from 'chalk';
import { In, Repository } from 'typeorm'; import { In, Repository } from 'typeorm';
import { BatchActiveWorkspacesMigrationCommandRunner } from 'src/database/commands/migration-command/batch-active-workspaces-migration-command.runner'; import { BatchMaintainedWorkspacesMigrationCommandRunner } from 'src/database/commands/migration-command/batch-maintained-workspaces-migration-command.runner';
import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator'; import { MigrationCommand } from 'src/database/commands/migration-command/decorators/migration-command.decorator';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity'; import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
@ -17,7 +17,7 @@ import { ViewOpenRecordInType } from 'src/modules/view/standard-objects/view.wor
'Update default view record opening on workflow objects to record page', 'Update default view record opening on workflow objects to record page',
version: '0.43', version: '0.43',
}) })
export class UpdateDefaultViewRecordOpeningOnWorkflowObjectsCommand extends BatchActiveWorkspacesMigrationCommandRunner { export class UpdateDefaultViewRecordOpeningOnWorkflowObjectsCommand extends BatchMaintainedWorkspacesMigrationCommandRunner {
constructor( constructor(
@InjectRepository(Workspace, 'core') @InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>, protected readonly workspaceRepository: Repository<Workspace>,

View File

@ -1,9 +1,10 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { MigrationCommandModule } from 'src/database/commands/migration-command/miration-command.module'; import { MigrationCommandModule } from 'src/database/commands/migration-command/migration-command.module';
import { StandardizationOfActorCompositeContextTypeCommand } from 'src/database/commands/upgrade-version/0-42/0-42-standardization-of-actor-composite-context-type'; import { StandardizationOfActorCompositeContextTypeCommand } from 'src/database/commands/upgrade-version/0-42/0-42-standardization-of-actor-composite-context-type';
import { AddTasksAssignedToMeViewCommand } from 'src/database/commands/upgrade-version/0-43/0-43-add-tasks-assigned-to-me-view.command'; import { AddTasksAssignedToMeViewCommand } from 'src/database/commands/upgrade-version/0-43/0-43-add-tasks-assigned-to-me-view.command';
import { MigrateIsSearchableForCustomObjectMetadataCommand } from 'src/database/commands/upgrade-version/0-43/0-43-migrate-is-searchable-for-custom-object-metadata.command';
import { MigrateRelationsToFieldMetadataCommand } from 'src/database/commands/upgrade-version/0-43/0-43-migrate-relations-to-field-metadata.command'; import { MigrateRelationsToFieldMetadataCommand } from 'src/database/commands/upgrade-version/0-43/0-43-migrate-relations-to-field-metadata.command';
import { MigrateSearchVectorOnNoteAndTaskEntitiesCommand } from 'src/database/commands/upgrade-version/0-43/0-43-migrate-search-vector-on-note-and-task-entities.command'; import { MigrateSearchVectorOnNoteAndTaskEntitiesCommand } from 'src/database/commands/upgrade-version/0-43/0-43-migrate-search-vector-on-note-and-task-entities.command';
import { UpdateDefaultViewRecordOpeningOnWorkflowObjectsCommand } from 'src/database/commands/upgrade-version/0-43/0-43-update-default-view-record-opening-on-workflow-objects.command'; import { UpdateDefaultViewRecordOpeningOnWorkflowObjectsCommand } from 'src/database/commands/upgrade-version/0-43/0-43-update-default-view-record-opening-on-workflow-objects.command';
@ -33,6 +34,7 @@ import { WorkspaceMigrationRunnerModule } from 'src/engine/workspace-manager/wor
providers: [ providers: [
AddTasksAssignedToMeViewCommand, AddTasksAssignedToMeViewCommand,
MigrateSearchVectorOnNoteAndTaskEntitiesCommand, MigrateSearchVectorOnNoteAndTaskEntitiesCommand,
MigrateIsSearchableForCustomObjectMetadataCommand,
UpdateDefaultViewRecordOpeningOnWorkflowObjectsCommand, UpdateDefaultViewRecordOpeningOnWorkflowObjectsCommand,
StandardizationOfActorCompositeContextTypeCommand, StandardizationOfActorCompositeContextTypeCommand,
MigrateRelationsToFieldMetadataCommand, MigrateRelationsToFieldMetadataCommand,

View File

@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class AddIsSearchableColumnInObjectMetadataTable1740478150675
implements MigrationInterface
{
name = 'AddIsSearchableColumnInObjectMetadataTable1740478150675';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "metadata"."objectMetadata" ADD "isSearchable" boolean NOT NULL DEFAULT false`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "metadata"."objectMetadata" DROP COLUMN "isSearchable"`,
);
}
}

View File

@ -19,6 +19,7 @@ export const mockPersonObjectMetadata = (
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isAuditLogged: true, isAuditLogged: true,
isSearchable: true,
duplicateCriteria: duplicateCriteria, duplicateCriteria: duplicateCriteria,
fromRelations: [], fromRelations: [],
toRelations: [], toRelations: [],

View File

@ -6,6 +6,7 @@ import { WorkspaceResolverBuilderMethodNames } from 'src/engine/api/graphql/work
import { ObjectMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/object-metadata.interface'; import { ObjectMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/object-metadata.interface';
import { FindDuplicatesResolverFactory } from 'src/engine/api/graphql/workspace-resolver-builder/factories/find-duplicates-resolver.factory'; import { FindDuplicatesResolverFactory } from 'src/engine/api/graphql/workspace-resolver-builder/factories/find-duplicates-resolver.factory';
import { SearchResolverFactory } from 'src/engine/api/graphql/workspace-resolver-builder/factories/search-resolver-factory';
@Injectable() @Injectable()
export class WorkspaceResolverBuilderService { export class WorkspaceResolverBuilderService {
@ -18,6 +19,8 @@ export class WorkspaceResolverBuilderService {
switch (methodName) { switch (methodName) {
case FindDuplicatesResolverFactory.methodName: case FindDuplicatesResolverFactory.methodName:
return isDefined(objectMetadata.duplicateCriteria); return isDefined(objectMetadata.duplicateCriteria);
case SearchResolverFactory.methodName:
return objectMetadata.isSearchable;
default: default:
return true; return true;
} }

View File

@ -7,22 +7,22 @@ import { Command } from 'nest-commander';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
import { import {
ActiveWorkspacesMigrationCommandOptions, MaintainedWorkspacesMigrationCommandOptions,
ActiveWorkspacesMigrationCommandRunner, MaintainedWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/active-workspaces-migration-command.runner'; } from 'src/database/commands/migration-command/maintained-workspaces-migration-command.runner';
import { BillingCustomer } from 'src/engine/core-modules/billing/entities/billing-customer.entity'; import { BillingCustomer } from 'src/engine/core-modules/billing/entities/billing-customer.entity';
import { StripeSubscriptionService } from 'src/engine/core-modules/billing/stripe/services/stripe-subscription.service'; import { StripeSubscriptionService } from 'src/engine/core-modules/billing/stripe/services/stripe-subscription.service';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager'; import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
interface SyncCustomerDataCommandOptions interface SyncCustomerDataCommandOptions
extends ActiveWorkspacesMigrationCommandOptions {} extends MaintainedWorkspacesMigrationCommandOptions {}
@Command({ @Command({
name: 'billing:sync-customer-data', name: 'billing:sync-customer-data',
description: 'Sync customer data from Stripe for all active workspaces', description: 'Sync customer data from Stripe for all active workspaces',
}) })
export class BillingSyncCustomerDataCommand extends ActiveWorkspacesMigrationCommandRunner { export class BillingSyncCustomerDataCommand extends MaintainedWorkspacesMigrationCommandRunner {
constructor( constructor(
@InjectRepository(Workspace, 'core') @InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>, protected readonly workspaceRepository: Repository<Workspace>,
@ -34,7 +34,7 @@ export class BillingSyncCustomerDataCommand extends ActiveWorkspacesMigrationCom
super(workspaceRepository, twentyORMGlobalManager); super(workspaceRepository, twentyORMGlobalManager);
} }
async runMigrationCommandOnActiveWorkspaces( async runMigrationCommandOnMaintainedWorkspaces(
_passedParam: string[], _passedParam: string[],
options: SyncCustomerDataCommandOptions, options: SyncCustomerDataCommandOptions,
workspaceIds: string[], workspaceIds: string[],

View File

@ -20,6 +20,7 @@ const mockObjectMetadata: ObjectMetadataInterface = {
isActive: true, isActive: true,
isRemote: false, isRemote: false,
isAuditLogged: true, isAuditLogged: true,
isSearchable: true,
}; };
describe('objectRecordChangedValues', () => { describe('objectRecordChangedValues', () => {

View File

@ -18,6 +18,7 @@ export const mockObjectMetadataItemsWithFieldMaps: ObjectMetadataItemWithFieldMa
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isAuditLogged: true, isAuditLogged: true,
isSearchable: true,
fromRelations: [], fromRelations: [],
toRelations: [], toRelations: [],
labelIdentifierFieldMetadataId: 'nameFieldMetadataId', labelIdentifierFieldMetadataId: 'nameFieldMetadataId',
@ -76,6 +77,7 @@ export const mockObjectMetadataItemsWithFieldMaps: ObjectMetadataItemWithFieldMa
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isAuditLogged: true, isAuditLogged: true,
isSearchable: true,
fromRelations: [], fromRelations: [],
toRelations: [], toRelations: [],
labelIdentifierFieldMetadataId: 'nameFieldMetadataId', labelIdentifierFieldMetadataId: 'nameFieldMetadataId',
@ -153,6 +155,7 @@ export const mockObjectMetadataItemsWithFieldMaps: ObjectMetadataItemWithFieldMa
isActive: true, isActive: true,
isSystem: false, isSystem: false,
isAuditLogged: true, isAuditLogged: true,
isSearchable: true,
fromRelations: [], fromRelations: [],
toRelations: [], toRelations: [],
labelIdentifierFieldMetadataId: 'nameFieldMetadataId', labelIdentifierFieldMetadataId: 'nameFieldMetadataId',
@ -230,6 +233,7 @@ export const mockObjectMetadataItemsWithFieldMaps: ObjectMetadataItemWithFieldMa
isActive: true, isActive: true,
isSystem: true, isSystem: true,
isAuditLogged: true, isAuditLogged: true,
isSearchable: false,
fromRelations: [], fromRelations: [],
toRelations: [], toRelations: [],
labelIdentifierFieldMetadataId: '', labelIdentifierFieldMetadataId: '',

View File

@ -19,7 +19,7 @@ describe('GlobalSearchService', () => {
}); });
describe('filterObjectMetadataItems', () => { describe('filterObjectMetadataItems', () => {
it('should return searchable object metadata items -- TODO isSearchable only', () => { it('should return searchable object metadata items', () => {
const objectMetadataItems = service.filterObjectMetadataItems( const objectMetadataItems = service.filterObjectMetadataItems(
mockObjectMetadataItemsWithFieldMaps, mockObjectMetadataItemsWithFieldMaps,
[], [],

View File

@ -22,20 +22,9 @@ export class GlobalSearchService {
excludedObjectNameSingulars: string[] | undefined, excludedObjectNameSingulars: string[] | undefined,
) { ) {
return objectMetadataItemWithFieldMaps.filter( return objectMetadataItemWithFieldMaps.filter(
({ nameSingular, isSystem, isRemote, isCustom }) => { ({ nameSingular, isSearchable }) => {
if (excludedObjectNameSingulars?.includes(nameSingular)) {
return false;
}
//TODO - #345 issue - IsSearchable decorator
if (isSystem || isRemote) {
return false;
}
return ( return (
isCustom || !excludedObjectNameSingulars?.includes(nameSingular) && isSearchable
['company', 'person', 'opportunity', 'note', 'task'].includes(
nameSingular,
)
); );
}, },
); );

View File

@ -24,6 +24,7 @@ export interface ObjectMetadataInterface {
isActive: boolean; isActive: boolean;
isRemote: boolean; isRemote: boolean;
isAuditLogged: boolean; isAuditLogged: boolean;
isSearchable: boolean;
duplicateCriteria?: WorkspaceEntityDuplicateCriteria[]; duplicateCriteria?: WorkspaceEntityDuplicateCriteria[];
labelIdentifierFieldMetadataId?: string | null; labelIdentifierFieldMetadataId?: string | null;
imageIdentifierFieldMetadataId?: string | null; imageIdentifierFieldMetadataId?: string | null;

View File

@ -69,6 +69,9 @@ export class ObjectMetadataDTO {
@FilterableField() @FilterableField()
isSystem: boolean; isSystem: boolean;
@FilterableField()
isSearchable: boolean;
@HideField() @HideField()
workspaceId: string; workspaceId: string;

View File

@ -70,6 +70,9 @@ export class ObjectMetadataEntity implements ObjectMetadataInterface {
@Column({ default: true }) @Column({ default: true })
isAuditLogged: boolean; isAuditLogged: boolean;
@Column({ default: false })
isSearchable: boolean;
@Column({ type: 'jsonb', nullable: true }) @Column({ type: 'jsonb', nullable: true })
duplicateCriteria?: WorkspaceEntityDuplicateCriteria[]; duplicateCriteria?: WorkspaceEntityDuplicateCriteria[];

View File

@ -120,6 +120,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
isCustom: !objectMetadataInput.isRemote, isCustom: !objectMetadataInput.isRemote,
isSystem: false, isSystem: false,
isRemote: objectMetadataInput.isRemote, isRemote: objectMetadataInput.isRemote,
isSearchable: !objectMetadataInput.isRemote,
fields: objectMetadataInput.isRemote fields: objectMetadataInput.isRemote
? [] ? []
: buildDefaultFieldsForCustomObject(objectMetadataInput.workspaceId), : buildDefaultFieldsForCustomObject(objectMetadataInput.workspaceId),

View File

@ -37,6 +37,11 @@ export function WorkspaceEntity(
'workspace:duplicate-criteria-metadata-args', 'workspace:duplicate-criteria-metadata-args',
target, target,
); );
const isSearchable =
TypedReflect.getMetadata(
'workspace:is-searchable-metadata-args',
target,
) ?? false;
const objectName = convertClassNameToObjectMetadataName(target.name); const objectName = convertClassNameToObjectMetadataName(target.name);
@ -57,6 +62,7 @@ export function WorkspaceEntity(
isSystem, isSystem,
gate, gate,
duplicateCriteria, duplicateCriteria,
isSearchable,
}); });
}; };
} }

View File

@ -0,0 +1,11 @@
import { TypedReflect } from 'src/utils/typed-reflect';
export function WorkspaceIsSearchable() {
return function (target: any): void {
TypedReflect.defineMetadata(
'workspace:is-searchable-metadata-args',
true,
target,
);
};
}

View File

@ -72,4 +72,9 @@ export interface WorkspaceEntityMetadataArgs {
* Duplicate criteria. * Duplicate criteria.
*/ */
readonly duplicateCriteria?: WorkspaceEntityDuplicateCriteria[]; readonly duplicateCriteria?: WorkspaceEntityDuplicateCriteria[];
/**
* Is searchable object.
*/
readonly isSearchable: boolean;
} }

View File

@ -4,9 +4,9 @@ import { Command, Option } from 'nest-commander';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
import { import {
ActiveWorkspacesMigrationCommandOptions, MaintainedWorkspacesMigrationCommandOptions,
ActiveWorkspacesMigrationCommandRunner, MaintainedWorkspacesMigrationCommandRunner,
} from 'src/database/commands/migration-command/active-workspaces-migration-command.runner'; } from 'src/database/commands/migration-command/maintained-workspaces-migration-command.runner';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service'; import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager'; import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
@ -16,7 +16,7 @@ import { WorkspaceSyncMetadataService } from 'src/engine/workspace-manager/works
import { SyncWorkspaceLoggerService } from './services/sync-workspace-logger.service'; import { SyncWorkspaceLoggerService } from './services/sync-workspace-logger.service';
interface RunWorkspaceMigrationsOptions interface RunWorkspaceMigrationsOptions
extends ActiveWorkspacesMigrationCommandOptions { extends MaintainedWorkspacesMigrationCommandOptions {
force?: boolean; force?: boolean;
} }
@ -24,7 +24,7 @@ interface RunWorkspaceMigrationsOptions
name: 'workspace:sync-metadata', name: 'workspace:sync-metadata',
description: 'Sync metadata', description: 'Sync metadata',
}) })
export class SyncWorkspaceMetadataCommand extends ActiveWorkspacesMigrationCommandRunner { export class SyncWorkspaceMetadataCommand extends MaintainedWorkspacesMigrationCommandRunner {
constructor( constructor(
@InjectRepository(Workspace, 'core') @InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>, protected readonly workspaceRepository: Repository<Workspace>,
@ -37,7 +37,7 @@ export class SyncWorkspaceMetadataCommand extends ActiveWorkspacesMigrationComma
super(workspaceRepository, twentyORMGlobalManager); super(workspaceRepository, twentyORMGlobalManager);
} }
async runMigrationCommandOnActiveWorkspaces( async runMigrationCommandOnMaintainedWorkspaces(
_passedParam: string[], _passedParam: string[],
options: RunWorkspaceMigrationsOptions, options: RunWorkspaceMigrationsOptions,
workspaceIds: string[], workspaceIds: string[],

View File

@ -20,6 +20,7 @@ import { WorkspaceFieldIndex } from 'src/engine/twenty-orm/decorators/workspace-
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator'; import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
import { WorkspaceIsDeprecated } from 'src/engine/twenty-orm/decorators/workspace-is-deprecated.decorator'; import { WorkspaceIsDeprecated } from 'src/engine/twenty-orm/decorators/workspace-is-deprecated.decorator';
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator'; import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
import { WorkspaceIsSearchable } from 'src/engine/twenty-orm/decorators/workspace-is-searchable.decorator';
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator'; import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
import { WorkspaceIsUnique } from 'src/engine/twenty-orm/decorators/workspace-is-unique.decorator'; import { WorkspaceIsUnique } from 'src/engine/twenty-orm/decorators/workspace-is-unique.decorator';
import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator'; import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator';
@ -59,6 +60,7 @@ export const SEARCH_FIELDS_FOR_COMPANY: FieldTypeAndNameMetadata[] = [
labelIdentifierStandardId: COMPANY_STANDARD_FIELD_IDS.name, labelIdentifierStandardId: COMPANY_STANDARD_FIELD_IDS.name,
}) })
@WorkspaceDuplicateCriteria([['name'], ['domainNamePrimaryLinkUrl']]) @WorkspaceDuplicateCriteria([['name'], ['domainNamePrimaryLinkUrl']])
@WorkspaceIsSearchable()
export class CompanyWorkspaceEntity extends BaseWorkspaceEntity { export class CompanyWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceField({ @WorkspaceField({
standardId: COMPANY_STANDARD_FIELD_IDS.name, standardId: COMPANY_STANDARD_FIELD_IDS.name,

View File

@ -16,6 +16,7 @@ import { WorkspaceEntity } from 'src/engine/twenty-orm/decorators/workspace-enti
import { WorkspaceFieldIndex } from 'src/engine/twenty-orm/decorators/workspace-field-index.decorator'; import { WorkspaceFieldIndex } from 'src/engine/twenty-orm/decorators/workspace-field-index.decorator';
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator'; import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator'; import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
import { WorkspaceIsSearchable } from 'src/engine/twenty-orm/decorators/workspace-is-searchable.decorator';
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator'; import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator'; import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
import { NOTE_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids'; import { NOTE_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
@ -48,6 +49,7 @@ export const SEARCH_FIELDS_FOR_NOTES: FieldTypeAndNameMetadata[] = [
shortcut: 'N', shortcut: 'N',
labelIdentifierStandardId: NOTE_STANDARD_FIELD_IDS.title, labelIdentifierStandardId: NOTE_STANDARD_FIELD_IDS.title,
}) })
@WorkspaceIsSearchable()
export class NoteWorkspaceEntity extends BaseWorkspaceEntity { export class NoteWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceField({ @WorkspaceField({
standardId: NOTE_STANDARD_FIELD_IDS.position, standardId: NOTE_STANDARD_FIELD_IDS.position,

View File

@ -18,6 +18,7 @@ import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field
import { WorkspaceIsDeprecated } from 'src/engine/twenty-orm/decorators/workspace-is-deprecated.decorator'; import { WorkspaceIsDeprecated } from 'src/engine/twenty-orm/decorators/workspace-is-deprecated.decorator';
import { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator'; import { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator';
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator'; import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
import { WorkspaceIsSearchable } from 'src/engine/twenty-orm/decorators/workspace-is-searchable.decorator';
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator'; import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator'; import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator';
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator'; import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
@ -53,6 +54,7 @@ export const SEARCH_FIELDS_FOR_OPPORTUNITY: FieldTypeAndNameMetadata[] = [
labelIdentifierStandardId: OPPORTUNITY_STANDARD_FIELD_IDS.name, labelIdentifierStandardId: OPPORTUNITY_STANDARD_FIELD_IDS.name,
}) })
@WorkspaceIsNotAuditLogged() @WorkspaceIsNotAuditLogged()
@WorkspaceIsSearchable()
export class OpportunityWorkspaceEntity extends BaseWorkspaceEntity { export class OpportunityWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceField({ @WorkspaceField({
standardId: OPPORTUNITY_STANDARD_FIELD_IDS.name, standardId: OPPORTUNITY_STANDARD_FIELD_IDS.name,

View File

@ -21,6 +21,7 @@ import { WorkspaceFieldIndex } from 'src/engine/twenty-orm/decorators/workspace-
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator'; import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
import { WorkspaceIsDeprecated } from 'src/engine/twenty-orm/decorators/workspace-is-deprecated.decorator'; import { WorkspaceIsDeprecated } from 'src/engine/twenty-orm/decorators/workspace-is-deprecated.decorator';
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator'; import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
import { WorkspaceIsSearchable } from 'src/engine/twenty-orm/decorators/workspace-is-searchable.decorator';
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator'; import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
import { WorkspaceIsUnique } from 'src/engine/twenty-orm/decorators/workspace-is-unique.decorator'; import { WorkspaceIsUnique } from 'src/engine/twenty-orm/decorators/workspace-is-unique.decorator';
import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator'; import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator';
@ -68,6 +69,7 @@ export const SEARCH_FIELDS_FOR_PERSON: FieldTypeAndNameMetadata[] = [
['linkedinLinkPrimaryLinkUrl'], ['linkedinLinkPrimaryLinkUrl'],
['emailsPrimaryEmail'], ['emailsPrimaryEmail'],
]) ])
@WorkspaceIsSearchable()
export class PersonWorkspaceEntity extends BaseWorkspaceEntity { export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceField({ @WorkspaceField({
standardId: PERSON_STANDARD_FIELD_IDS.name, standardId: PERSON_STANDARD_FIELD_IDS.name,

View File

@ -16,6 +16,7 @@ import { WorkspaceEntity } from 'src/engine/twenty-orm/decorators/workspace-enti
import { WorkspaceFieldIndex } from 'src/engine/twenty-orm/decorators/workspace-field-index.decorator'; import { WorkspaceFieldIndex } from 'src/engine/twenty-orm/decorators/workspace-field-index.decorator';
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator'; import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator'; import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
import { WorkspaceIsSearchable } from 'src/engine/twenty-orm/decorators/workspace-is-searchable.decorator';
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator'; import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator'; import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator';
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator'; import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
@ -51,6 +52,7 @@ export const SEARCH_FIELDS_FOR_TASKS: FieldTypeAndNameMetadata[] = [
shortcut: 'T', shortcut: 'T',
labelIdentifierStandardId: TASK_STANDARD_FIELD_IDS.title, labelIdentifierStandardId: TASK_STANDARD_FIELD_IDS.title,
}) })
@WorkspaceIsSearchable()
export class TaskWorkspaceEntity extends BaseWorkspaceEntity { export class TaskWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceField({ @WorkspaceField({
standardId: TASK_STANDARD_FIELD_IDS.position, standardId: TASK_STANDARD_FIELD_IDS.position,

View File

@ -15,6 +15,7 @@ export interface ReflectMetadataTypeMap {
['workspace:is-unique-metadata-args']: true; ['workspace:is-unique-metadata-args']: true;
['workspace:duplicate-criteria-metadata-args']: WorkspaceEntityDuplicateCriteria[]; ['workspace:duplicate-criteria-metadata-args']: WorkspaceEntityDuplicateCriteria[];
['environment-variables']: EnvironmentVariablesMetadataMap; ['environment-variables']: EnvironmentVariablesMetadataMap;
['workspace:is-searchable-metadata-args']: boolean;
} }
export class TypedReflect { export class TypedReflect {