Twenty standard application Objects and fields as allFlatEntityMaps ID non-agnostic (#16298)
# Introduction Related to https://github.com/twentyhq/core-team-issues/issues/1995 This PR introduces the basis of the `twentyStandard` application as code on demand, it's highly tied to `ids` where it will becomes workspace agnostic following the builder and runner `universalIdentifier` refactor later. The goal here to allow computing the `allFlatEntityMaps` `to` of the `twentyStandard` application on a empty workspace ( workspace creation ). Allowing installing the twenty standard app through a workspace migration instead of passing by the sync metadata Nothing done will be run in production for the moment if it's not the small validation refactor we've introduced Please note that everything introduced here will be replaced at some point by a twenty app instance when the twenty sdk is mature enough to handle of the edge cases we need here ## How we've proceeded We've been iterating over every workspace entity both objects and their fields, and transpiled them to flatEntity. Being sure we migrate the defaultValue, settings and so on accordingly. We've also compute all the ids in prior of the whole entities computation so we don't face any hoisting issue. ## Current state At the moment only handling all of the 29 standard objects and their fields Settings a unique universalIdentifier for all of them Will come views, agent role targets and so on later ## `workspace:compute-twenty-standard-migration` command This command allow generating a workspace migration that will result in installing the twenty standard app in an empty workspace It's temporary and aims to allow debugging for the moment we might not keep it in the future as it is right now It contains debug writeFileSync which is expected no worries greptile ## `LabelFieldMetadataIdentifierId` Small refactor allowing defining the label identifier field metadata id of a uuid field metadata type for system object, as some of our standard object don't have a name field and don't aim to Also please note that we might remove this build options later in the sake of the currently installed universal identifier application that we could compare with the deterministic twenty standard one ## `runFlatFieldMetadataValidators` Deprecated this pattern which was redundant and not v2 friendly pattern ## Current errors that will address in upcoming PR Current standard objects and fields metadata does not pass the validation that we have in place, as historically the sync metadata would directly consume the repositories and would just ignore the validation. This is about to change. Will handle the below errors in dedicated PRs as they will required upgrade commands in order to migrate the data, or will handle that from the sync metadata instead still to be determined but nothing critical here - camel case field metadata name - options label invalid format ```json { "status": "fail", "report": { "fieldMetadata": [ { "status": "fail", "errors": [ { "code": "INVALID_FIELD_INPUT", "message": "Name should be in camelCase", "userFriendlyMessage": { "id": "P+jdmX", "message": "Name should be in camelCase" }, "value": "iCalUID" } ], "flatEntityMinimalInformation": { "id": "68dd83cd-92c8-4233-bb28-47939bab6124", "name": "iCalUID", "objectMetadataId": "11c16ab6-9176-439e-a2db-a12c5a58a524" }, "type": "create_field" }, { "status": "fail", "errors": [ { "code": "INVALID_FIELD_INPUT", "message": "Value must be in UPPER_CASE and follow snake_case \"email\"", "userFriendlyMessage": { "id": "UBPzFQ", "message": "Value must be in UPPER_CASE and follow snake_case \"{sanitizedValue}\"", "values": { "sanitizedValue": "email" } }, "value": "email" }, { "code": "INVALID_FIELD_INPUT", "message": "Value must be in UPPER_CASE and follow snake_case \"sms\"", "userFriendlyMessage": { "id": "UBPzFQ", "message": "Value must be in UPPER_CASE and follow snake_case \"{sanitizedValue}\"", "values": { "sanitizedValue": "sms" } }, "value": "sms" } ], "flatEntityMinimalInformation": { "id": "e3caaf2a-e07d-4146-8dfc-9eef904e82c9", "name": "type", "objectMetadataId": "4b777de5-4c7b-4af4-9b92-655c0f87512b" }, "type": "create_field" }, { "status": "fail", "errors": [ { "code": "INVALID_FIELD_INPUT", "message": "Value must be in UPPER_CASE and follow snake_case \"incoming\"", "userFriendlyMessage": { "id": "UBPzFQ", "message": "Value must be in UPPER_CASE and follow snake_case \"{sanitizedValue}\"", "values": { "sanitizedValue": "incoming" } }, "value": "incoming" }, { "code": "INVALID_FIELD_INPUT", "message": "Value must be in UPPER_CASE and follow snake_case \"outgoing\"", "userFriendlyMessage": { "id": "UBPzFQ", "message": "Value must be in UPPER_CASE and follow snake_case \"{sanitizedValue}\"", "values": { "sanitizedValue": "outgoing" } }, "value": "outgoing" } ], "flatEntityMinimalInformation": { "id": "d96233a4-93be-45ea-9548-3b50f3c700cf", "name": "direction", "objectMetadataId": "480a648a-d2e5-482a-992f-ef053e1b4bb0" }, "type": "create_field" }, { "status": "fail", "errors": [ { "code": "INVALID_FIELD_INPUT", "message": "Value must be in UPPER_CASE and follow snake_case \"from\"", "userFriendlyMessage": { "id": "UBPzFQ", "message": "Value must be in UPPER_CASE and follow snake_case \"{sanitizedValue}\"", "values": { "sanitizedValue": "from" } }, "value": "from" }, { "code": "INVALID_FIELD_INPUT", "message": "Value must be in UPPER_CASE and follow snake_case \"to\"", "userFriendlyMessage": { "id": "UBPzFQ", "message": "Value must be in UPPER_CASE and follow snake_case \"{sanitizedValue}\"", "values": { "sanitizedValue": "to" } }, "value": "to" }, { "code": "INVALID_FIELD_INPUT", "message": "Value must be in UPPER_CASE and follow snake_case \"cc\"", "userFriendlyMessage": { "id": "UBPzFQ", "message": "Value must be in UPPER_CASE and follow snake_case \"{sanitizedValue}\"", "values": { "sanitizedValue": "cc" } }, "value": "cc" }, { "code": "INVALID_FIELD_INPUT", "message": "Value must be in UPPER_CASE and follow snake_case \"bcc\"", "userFriendlyMessage": { "id": "UBPzFQ", "message": "Value must be in UPPER_CASE and follow snake_case \"{sanitizedValue}\"", "values": { "sanitizedValue": "bcc" } }, "value": "bcc" } ], "flatEntityMinimalInformation": { "id": "961c598e-67c3-452d-8bb2-b92c0bc64404", "name": "role", "objectMetadataId": "8af8a13c-ff97-4cd3-b70d-52a7dc2924b4" }, "type": "create_field" }, { "status": "fail", "errors": [ { "code": "INVALID_FIELD_INPUT", "message": "Label must not contain a comma", "userFriendlyMessage": { "id": "k731jp", "message": "Label must not contain a comma" }, "value": "Commas and dot (1,234.56)" }, { "code": "INVALID_FIELD_INPUT", "message": "Label must not contain a comma", "userFriendlyMessage": { "id": "k731jp", "message": "Label must not contain a comma" }, "value": "Spaces and comma (1 234,56)" }, { "code": "INVALID_FIELD_INPUT", "message": "Label must not contain a comma", "userFriendlyMessage": { "id": "k731jp", "message": "Label must not contain a comma" }, "value": "Dots and comma (1.234,56)" } ], "flatEntityMinimalInformation": { "id": "7fa20caf-2597-42e3-84e5-15a91b125b9b", "name": "numberFormat", "objectMetadataId": "a6974302-9e72-461c-aa09-9390f4ff16fc" }, "type": "create_field" } ], "objectMetadata": [], "view": [], "viewField": [], "viewGroup": [], "index": [], "serverlessFunction": [], "cronTrigger": [], "databaseEventTrigger": [], "routeTrigger": [], "viewFilter": [], "role": [], "roleTarget": [], "agent": [] } } ```
This commit is contained in:
+1
-1
@@ -5,7 +5,6 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
import { ApplicationService } from 'src/engine/core-modules/application/application.service';
|
||||
import { TWENTY_STANDARD_APPLICATION } from 'src/engine/core-modules/application/constants/twenty-standard-applications';
|
||||
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
||||
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
@@ -23,6 +22,7 @@ import { seedPageLayoutWidgets } from 'src/engine/workspace-manager/dev-seeder/c
|
||||
import { seedPageLayouts } from 'src/engine/workspace-manager/dev-seeder/core/utils/seed-page-layouts.util';
|
||||
import { DevSeederDataService } from 'src/engine/workspace-manager/dev-seeder/data/services/dev-seeder-data.service';
|
||||
import { DevSeederMetadataService } from 'src/engine/workspace-manager/dev-seeder/metadata/services/dev-seeder-metadata.service';
|
||||
import { TWENTY_STANDARD_APPLICATION } from 'src/engine/workspace-manager/twenty-standard-application/constants/twenty-standard-applications';
|
||||
import { WorkspaceSyncMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.service';
|
||||
|
||||
@Injectable()
|
||||
|
||||
+1
-1
@@ -2,11 +2,11 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { DEFAULT_VIEW_FIELD_SIZE } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/constants/DEFAULT_VIEW_FIELD_SIZE';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
CALENDAR_EVENT_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -3,11 +3,11 @@ import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { DEFAULT_VIEW_FIELD_SIZE } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/constants/DEFAULT_VIEW_FIELD_SIZE';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
COMPANY_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -2,11 +2,11 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { ViewOpenRecordInType } from 'src/engine/metadata-modules/view/types/view-open-record-in-type.type';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
DASHBOARD_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -2,11 +2,11 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { DEFAULT_VIEW_FIELD_SIZE } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/constants/DEFAULT_VIEW_FIELD_SIZE';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
MESSAGE_THREAD_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -2,11 +2,11 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { DEFAULT_VIEW_FIELD_SIZE } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/constants/DEFAULT_VIEW_FIELD_SIZE';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
MESSAGE_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -2,10 +2,10 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
NOTE_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -3,10 +3,10 @@ import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import { OPPORTUNITY_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
|
||||
export const opportunitiesAllView = ({
|
||||
|
||||
+1
-1
@@ -3,10 +3,10 @@ import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import { OPPORTUNITY_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
|
||||
export const opportunitiesByStageView = ({
|
||||
|
||||
+1
-1
@@ -3,10 +3,10 @@ import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
PERSON_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -2,10 +2,10 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
TASK_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -3,10 +3,10 @@ import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { ViewFilterOperand } from 'twenty-shared/types';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
TASK_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -2,10 +2,10 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
TASK_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -2,12 +2,12 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { ViewOpenRecordInType } from 'src/engine/metadata-modules/view/types/view-open-record-in-type.type';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { DEFAULT_VIEW_FIELD_SIZE } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/constants/DEFAULT_VIEW_FIELD_SIZE';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import { TIMELINE_ACTIVITY_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
|
||||
export const timelineActivitiesAllView = ({
|
||||
|
||||
+1
-1
@@ -2,11 +2,11 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { ViewOpenRecordInType } from 'src/engine/metadata-modules/view/types/view-open-record-in-type.type';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import { WORKFLOW_RUN_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
|
||||
export const workflowRunsAllView = ({
|
||||
|
||||
+1
-1
@@ -2,11 +2,11 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { ViewOpenRecordInType } from 'src/engine/metadata-modules/view/types/view-open-record-in-type.type';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
WORKFLOW_VERSION_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -2,11 +2,11 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { ViewOpenRecordInType } from 'src/engine/metadata-modules/view/types/view-open-record-in-type.type';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
WORKFLOW_STANDARD_FIELD_IDS,
|
||||
|
||||
+1
-1
@@ -2,11 +2,11 @@ import { msg } from '@lingui/core/macro';
|
||||
import { STANDARD_OBJECT_IDS } from 'twenty-shared/metadata';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/core-modules/application/constants/standard-object.constant';
|
||||
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface';
|
||||
import { DEFAULT_VIEW_FIELD_SIZE } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/constants/DEFAULT_VIEW_FIELD_SIZE';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
WORKSPACE_MEMBER_STANDARD_FIELD_IDS,
|
||||
|
||||
+1782
File diff suppressed because it is too large
Load Diff
+19
@@ -0,0 +1,19 @@
|
||||
import { type ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
|
||||
|
||||
export const TWENTY_STANDARD_APPLICATION = {
|
||||
universalIdentifier: '20202020-64aa-4b6f-b003-9c74b97cee20',
|
||||
name: 'Twenty Standard',
|
||||
description:
|
||||
'Twenty is an open-source CRM that allows you to manage your sales and customer relationships',
|
||||
version: '1.0.0',
|
||||
sourcePath: 'cli-sync',
|
||||
sourceType: 'local',
|
||||
} as const satisfies Pick<
|
||||
ApplicationEntity,
|
||||
| 'universalIdentifier'
|
||||
| 'name'
|
||||
| 'description'
|
||||
| 'version'
|
||||
| 'sourcePath'
|
||||
| 'sourceType'
|
||||
>;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { type STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import { type AllStandardObjectName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-name.type';
|
||||
|
||||
export type AllStandardObjectFieldName<T extends AllStandardObjectName> =
|
||||
keyof (typeof STANDARD_OBJECTS)[T]['fields'];
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { type STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
|
||||
export type AllStandardObjectName = keyof typeof STANDARD_OBJECTS;
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
import { type FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';
|
||||
import { addFlatEntityToFlatEntityMapsOrThrow } from 'src/engine/metadata-modules/flat-entity/utils/add-flat-entity-to-flat-entity-maps-or-throw.util';
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-name.type';
|
||||
import { buildAttachmentStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-attachment-standard-flat-field-metadata.util';
|
||||
import { buildBlocklistStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-blocklist-standard-flat-field-metadata.util';
|
||||
import { buildCalendarChannelEventAssociationStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-calendar-channel-event-association-standard-flat-field-metadata.util';
|
||||
import { buildCalendarChannelStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-calendar-channel-standard-flat-field-metadata.util';
|
||||
import { buildCalendarEventParticipantStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-calendar-event-participant-standard-flat-field-metadata.util';
|
||||
import { buildCalendarEventStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-calendar-event-standard-flat-field-metadata.util';
|
||||
import { buildCompanyStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-company-standard-flat-field-metadata.util';
|
||||
import { buildConnectedAccountStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-connected-account-standard-flat-field-metadata.util';
|
||||
import { buildDashboardStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-dashboard-standard-flat-field-metadata.util';
|
||||
import { buildFavoriteFolderStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-favorite-folder-standard-flat-field-metadata.util';
|
||||
import { buildFavoriteStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-favorite-standard-flat-field-metadata.util';
|
||||
import { buildMessageChannelMessageAssociationStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-message-channel-message-association-standard-flat-field-metadata.util';
|
||||
import { buildMessageChannelStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-message-channel-standard-flat-field-metadata.util';
|
||||
import { buildMessageFolderStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-message-folder-standard-flat-field-metadata.util';
|
||||
import { buildMessageParticipantStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-message-participant-standard-flat-field-metadata.util';
|
||||
import { buildMessageStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-message-standard-flat-field-metadata.util';
|
||||
import { buildMessageThreadStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-message-thread-standard-flat-field-metadata.util';
|
||||
import { buildNoteStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-note-standard-flat-field-metadata.util';
|
||||
import { buildNoteTargetStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-note-target-standard-flat-field-metadata.util';
|
||||
import { buildOpportunityStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-opportunity-standard-flat-field-metadata.util';
|
||||
import { buildPersonStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-person-standard-flat-field-metadata.util';
|
||||
import { buildTaskStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-task-standard-flat-field-metadata.util';
|
||||
import { buildTaskTargetStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-task-target-standard-flat-field-metadata.util';
|
||||
import { buildTimelineActivityStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-timeline-activity-standard-flat-field-metadata.util';
|
||||
import { buildWorkflowAutomatedTriggerStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-workflow-automated-trigger-standard-flat-field-metadata.util';
|
||||
import { buildWorkflowRunStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-workflow-run-standard-flat-field-metadata.util';
|
||||
import { buildWorkflowStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-workflow-standard-flat-field-metadata.util';
|
||||
import { buildWorkflowVersionStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-workflow-version-standard-flat-field-metadata.util';
|
||||
import { buildWorkspaceMemberStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/compute-workspace-member-standard-flat-field-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
type BuildStandardFlatFieldMetadataMapsArgs = {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
};
|
||||
|
||||
type StandardFlatFieldMetadataBuilder = (
|
||||
args: BuildStandardFlatFieldMetadataMapsArgs,
|
||||
) => Record<string, FlatFieldMetadata>;
|
||||
|
||||
const STANDARD_FLAT_FIELD_METADATA_BUILDERS_BY_OBJECT_NAME = {
|
||||
attachment: buildAttachmentStandardFlatFieldMetadatas,
|
||||
blocklist: buildBlocklistStandardFlatFieldMetadatas,
|
||||
calendarChannelEventAssociation:
|
||||
buildCalendarChannelEventAssociationStandardFlatFieldMetadatas,
|
||||
calendarChannel: buildCalendarChannelStandardFlatFieldMetadatas,
|
||||
calendarEventParticipant:
|
||||
buildCalendarEventParticipantStandardFlatFieldMetadatas,
|
||||
calendarEvent: buildCalendarEventStandardFlatFieldMetadatas,
|
||||
company: buildCompanyStandardFlatFieldMetadatas,
|
||||
connectedAccount: buildConnectedAccountStandardFlatFieldMetadatas,
|
||||
dashboard: buildDashboardStandardFlatFieldMetadatas,
|
||||
favorite: buildFavoriteStandardFlatFieldMetadatas,
|
||||
favoriteFolder: buildFavoriteFolderStandardFlatFieldMetadatas,
|
||||
message: buildMessageStandardFlatFieldMetadatas,
|
||||
messageChannel: buildMessageChannelStandardFlatFieldMetadatas,
|
||||
messageChannelMessageAssociation:
|
||||
buildMessageChannelMessageAssociationStandardFlatFieldMetadatas,
|
||||
messageFolder: buildMessageFolderStandardFlatFieldMetadatas,
|
||||
messageParticipant: buildMessageParticipantStandardFlatFieldMetadatas,
|
||||
messageThread: buildMessageThreadStandardFlatFieldMetadatas,
|
||||
note: buildNoteStandardFlatFieldMetadatas,
|
||||
noteTarget: buildNoteTargetStandardFlatFieldMetadatas,
|
||||
opportunity: buildOpportunityStandardFlatFieldMetadatas,
|
||||
person: buildPersonStandardFlatFieldMetadatas,
|
||||
task: buildTaskStandardFlatFieldMetadatas,
|
||||
taskTarget: buildTaskTargetStandardFlatFieldMetadatas,
|
||||
timelineActivity: buildTimelineActivityStandardFlatFieldMetadatas,
|
||||
workflow: buildWorkflowStandardFlatFieldMetadatas,
|
||||
workflowAutomatedTrigger:
|
||||
buildWorkflowAutomatedTriggerStandardFlatFieldMetadatas,
|
||||
workflowRun: buildWorkflowRunStandardFlatFieldMetadatas,
|
||||
workflowVersion: buildWorkflowVersionStandardFlatFieldMetadatas,
|
||||
workspaceMember: buildWorkspaceMemberStandardFlatFieldMetadatas,
|
||||
} satisfies Record<AllStandardObjectName, StandardFlatFieldMetadataBuilder>;
|
||||
|
||||
const createEmptyFlatFieldMetadataMaps =
|
||||
(): FlatEntityMaps<FlatFieldMetadata> => ({
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
});
|
||||
|
||||
export const buildStandardFlatFieldMetadataMaps = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: BuildStandardFlatFieldMetadataMapsArgs): FlatEntityMaps<FlatFieldMetadata> => {
|
||||
const builderArgs = {
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
};
|
||||
|
||||
// Collect all field metadatas from all standard objects
|
||||
const allFieldMetadatas: FlatFieldMetadata[] = Object.values(
|
||||
STANDARD_FLAT_FIELD_METADATA_BUILDERS_BY_OBJECT_NAME,
|
||||
).flatMap((builder) => Object.values(builder(builderArgs)));
|
||||
|
||||
// Build maps using addFlatEntityToFlatEntityMapsOrThrow to prevent duplicate IDs
|
||||
let flatFieldMetadataMaps = createEmptyFlatFieldMetadataMaps();
|
||||
|
||||
for (const fieldMetadata of allFieldMetadatas) {
|
||||
flatFieldMetadataMaps = addFlatEntityToFlatEntityMapsOrThrow({
|
||||
flatEntity: fieldMetadata,
|
||||
flatEntityMaps: flatFieldMetadataMaps,
|
||||
});
|
||||
}
|
||||
|
||||
return flatFieldMetadataMaps;
|
||||
};
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import { type FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';
|
||||
import { addFlatEntityToFlatEntityMapsOrThrow } from 'src/engine/metadata-modules/flat-entity/utils/add-flat-entity-to-flat-entity-maps-or-throw.util';
|
||||
import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
|
||||
import {
|
||||
type BuildStandardFlatObjectMetadatasArgs,
|
||||
STANDARD_FLAT_OBJECT_METADATA_BUILDERS_BY_OBJECT_NAME,
|
||||
} from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-flat-object-metadata.util';
|
||||
|
||||
const createEmptyFlatObjectMetadataMaps =
|
||||
(): FlatEntityMaps<FlatObjectMetadata> => ({
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
});
|
||||
|
||||
export const buildStandardFlatObjectMetadataMaps = (
|
||||
args: BuildStandardFlatObjectMetadatasArgs,
|
||||
): FlatEntityMaps<FlatObjectMetadata> => {
|
||||
// Collect all object metadatas from all standard objects
|
||||
const allObjectMetadatas: FlatObjectMetadata[] = Object.values(
|
||||
STANDARD_FLAT_OBJECT_METADATA_BUILDERS_BY_OBJECT_NAME,
|
||||
).map((builder) => builder(args));
|
||||
|
||||
// Build maps using addFlatEntityToFlatEntityMapsOrThrow to prevent duplicate IDs
|
||||
let flatObjectMetadataMaps = createEmptyFlatObjectMetadataMaps();
|
||||
|
||||
for (const objectMetadata of allObjectMetadatas) {
|
||||
flatObjectMetadataMaps = addFlatEntityToFlatEntityMapsOrThrow({
|
||||
flatEntity: objectMetadata,
|
||||
flatEntityMaps: flatObjectMetadataMaps,
|
||||
});
|
||||
}
|
||||
|
||||
return flatObjectMetadataMaps;
|
||||
};
|
||||
+399
@@ -0,0 +1,399 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildAttachmentStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'attachment'>, FlatFieldMetadata> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Attachment-specific fields
|
||||
name: createStandardFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'name',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Name',
|
||||
description: 'Attachment name',
|
||||
icon: 'IconFileUpload',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
fullPath: createStandardFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'fullPath',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Full path',
|
||||
description: 'Attachment full path',
|
||||
icon: 'IconLink',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
type: createStandardFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'type',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Type (deprecated)',
|
||||
description: 'Attachment type (deprecated - use fileCategory)',
|
||||
icon: 'IconList',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
fileCategory: createStandardFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'fileCategory',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'File category',
|
||||
description: 'Attachment file category',
|
||||
icon: 'IconList',
|
||||
isNullable: false,
|
||||
defaultValue: "'OTHER'",
|
||||
options: [
|
||||
{ value: 'ARCHIVE', label: 'Archive', position: 0, color: 'gray' },
|
||||
{ value: 'AUDIO', label: 'Audio', position: 1, color: 'pink' },
|
||||
{ value: 'IMAGE', label: 'Image', position: 2, color: 'yellow' },
|
||||
{
|
||||
value: 'PRESENTATION',
|
||||
label: 'Presentation',
|
||||
position: 3,
|
||||
color: 'orange',
|
||||
},
|
||||
{
|
||||
value: 'SPREADSHEET',
|
||||
label: 'Spreadsheet',
|
||||
position: 4,
|
||||
color: 'turquoise',
|
||||
},
|
||||
{
|
||||
value: 'TEXT_DOCUMENT',
|
||||
label: 'Text Document',
|
||||
position: 5,
|
||||
color: 'blue',
|
||||
},
|
||||
{ value: 'VIDEO', label: 'Video', position: 6, color: 'purple' },
|
||||
{ value: 'OTHER', label: 'Other', position: 7, color: 'gray' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdBy: createStandardFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdBy',
|
||||
type: FieldMetadataType.ACTOR,
|
||||
label: 'Created by',
|
||||
description: 'The creator of the record',
|
||||
icon: 'IconCreativeCommonsSa',
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
author: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'author',
|
||||
label: 'Author',
|
||||
description: 'Attachment author (deprecated - use createdBy)',
|
||||
icon: 'IconCircleUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workspaceMember',
|
||||
targetFieldName: 'authoredAttachments',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'authorId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
activity: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'activity',
|
||||
label: 'Activity',
|
||||
description: 'Attachment activity',
|
||||
icon: 'IconNotes',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
// Activity is deprecated, pointing to a non-existent target
|
||||
targetObjectName: 'note',
|
||||
targetFieldName: 'attachments',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'activityId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
task: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'task',
|
||||
label: 'Task',
|
||||
description: 'Attachment task',
|
||||
icon: 'IconNotes',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'task',
|
||||
targetFieldName: 'attachments',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'taskId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
note: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'note',
|
||||
label: 'Note',
|
||||
description: 'Attachment note',
|
||||
icon: 'IconNotes',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'note',
|
||||
targetFieldName: 'attachments',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'noteId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
person: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'person',
|
||||
label: 'Person',
|
||||
description: 'Attachment person',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'person',
|
||||
targetFieldName: 'attachments',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'personId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
company: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'company',
|
||||
label: 'Company',
|
||||
description: 'Attachment company',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'company',
|
||||
targetFieldName: 'attachments',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'companyId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
opportunity: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'opportunity',
|
||||
label: 'Opportunity',
|
||||
description: 'Attachment opportunity',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'opportunity',
|
||||
targetFieldName: 'attachments',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'opportunityId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
dashboard: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'dashboard',
|
||||
label: 'Dashboard',
|
||||
description: 'Attachment dashboard',
|
||||
icon: 'IconLayout',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'dashboard',
|
||||
targetFieldName: 'attachments',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'dashboardId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflow: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workflow',
|
||||
label: 'Workflow',
|
||||
description: 'Attachment workflow',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workflow',
|
||||
targetFieldName: 'attachments',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
custom: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'attachment',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'custom',
|
||||
label: 'Custom',
|
||||
description: 'Attachment custom object',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
// Custom is a dynamic relation, pointing to custom objects
|
||||
targetObjectName: 'note',
|
||||
targetFieldName: 'attachments',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'customId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildBlocklistStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'blocklist'>, FlatFieldMetadata> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'blocklist',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'blocklist',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'blocklist',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'blocklist',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Blocklist-specific fields
|
||||
handle: createStandardFieldFlatMetadata({
|
||||
objectName: 'blocklist',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'handle',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Handle',
|
||||
description: 'Handle',
|
||||
icon: 'IconAt',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
workspaceMember: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'blocklist',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workspaceMember',
|
||||
label: 'WorkspaceMember',
|
||||
description: 'WorkspaceMember',
|
||||
icon: 'IconCircleUser',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'workspaceMember',
|
||||
targetFieldName: 'blocklist',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'workspaceMemberId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildCalendarChannelEventAssociationStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'calendarChannelEventAssociation'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannelEventAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannelEventAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannelEventAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannelEventAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
eventExternalId: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannelEventAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'eventExternalId',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Event external ID',
|
||||
description: 'Event external ID',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
recurringEventExternalId: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannelEventAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'recurringEventExternalId',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Recurring Event ID',
|
||||
description: 'Recurring Event ID',
|
||||
icon: 'IconHistory',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarChannel: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'calendarChannelEventAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'calendarChannel',
|
||||
label: 'Channel ID',
|
||||
description: 'Channel ID',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'calendarChannel',
|
||||
targetFieldName: 'calendarChannelEventAssociations',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'calendarChannelId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarEvent: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'calendarChannelEventAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'calendarEvent',
|
||||
label: 'Event ID',
|
||||
description: 'Event ID',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'calendarEvent',
|
||||
targetFieldName: 'calendarChannelEventAssociations',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'calendarEventId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+389
@@ -0,0 +1,389 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildCalendarChannelStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'calendarChannel'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
handle: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'handle',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Handle',
|
||||
description: 'Handle',
|
||||
icon: 'IconAt',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
visibility: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'visibility',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Visibility',
|
||||
description: 'Visibility',
|
||||
icon: 'IconEyeglass',
|
||||
isNullable: false,
|
||||
defaultValue: "'SHARE_EVERYTHING'",
|
||||
options: [
|
||||
{ value: 'METADATA', label: 'Metadata', position: 0, color: 'green' },
|
||||
{
|
||||
value: 'SHARE_EVERYTHING',
|
||||
label: 'Share Everything',
|
||||
position: 1,
|
||||
color: 'orange',
|
||||
},
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
isContactAutoCreationEnabled: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'isContactAutoCreationEnabled',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is Contact Auto Creation Enabled',
|
||||
description: 'Is Contact Auto Creation Enabled',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: false,
|
||||
defaultValue: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
contactAutoCreationPolicy: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'contactAutoCreationPolicy',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Contact auto creation policy',
|
||||
description:
|
||||
'Automatically create records for people you participated with in an event.',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: false,
|
||||
defaultValue: "'AS_PARTICIPANT_AND_ORGANIZER'",
|
||||
options: [
|
||||
{
|
||||
value: 'AS_PARTICIPANT_AND_ORGANIZER',
|
||||
label: 'As Participant and Organizer',
|
||||
color: 'green',
|
||||
position: 0,
|
||||
},
|
||||
{
|
||||
value: 'AS_PARTICIPANT',
|
||||
label: 'As Participant',
|
||||
color: 'orange',
|
||||
position: 1,
|
||||
},
|
||||
{
|
||||
value: 'AS_ORGANIZER',
|
||||
label: 'As Organizer',
|
||||
color: 'blue',
|
||||
position: 2,
|
||||
},
|
||||
{ value: 'NONE', label: 'None', color: 'red', position: 3 },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
isSyncEnabled: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'isSyncEnabled',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is Sync Enabled',
|
||||
description: 'Is Sync Enabled',
|
||||
icon: 'IconRefresh',
|
||||
isNullable: false,
|
||||
defaultValue: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
syncCursor: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'syncCursor',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Sync Cursor',
|
||||
description:
|
||||
'Sync Cursor. Used for syncing events from the calendar provider',
|
||||
icon: 'IconReload',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
syncStatus: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'syncStatus',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Sync status',
|
||||
description: 'Sync status',
|
||||
icon: 'IconStatusChange',
|
||||
isNullable: true,
|
||||
options: [
|
||||
{ value: 'ONGOING', label: 'Ongoing', position: 1, color: 'yellow' },
|
||||
{
|
||||
value: 'NOT_SYNCED',
|
||||
label: 'Not Synced',
|
||||
position: 2,
|
||||
color: 'blue',
|
||||
},
|
||||
{ value: 'ACTIVE', label: 'Active', position: 3, color: 'green' },
|
||||
{
|
||||
value: 'FAILED_INSUFFICIENT_PERMISSIONS',
|
||||
label: 'Failed Insufficient Permissions',
|
||||
position: 4,
|
||||
color: 'red',
|
||||
},
|
||||
{
|
||||
value: 'FAILED_UNKNOWN',
|
||||
label: 'Failed Unknown',
|
||||
position: 5,
|
||||
color: 'red',
|
||||
},
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
syncStage: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'syncStage',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Sync stage',
|
||||
description: 'Sync stage',
|
||||
icon: 'IconStatusChange',
|
||||
isNullable: false,
|
||||
defaultValue: "'PENDING_CONFIGURATION'",
|
||||
options: [
|
||||
{
|
||||
value: 'CALENDAR_EVENT_LIST_FETCH_PENDING',
|
||||
label: 'Calendar event list fetch pending',
|
||||
position: 0,
|
||||
color: 'blue',
|
||||
},
|
||||
{
|
||||
value: 'CALENDAR_EVENT_LIST_FETCH_SCHEDULED',
|
||||
label: 'Calendar event list fetch scheduled',
|
||||
position: 1,
|
||||
color: 'green',
|
||||
},
|
||||
{
|
||||
value: 'CALENDAR_EVENT_LIST_FETCH_ONGOING',
|
||||
label: 'Calendar event list fetch ongoing',
|
||||
position: 2,
|
||||
color: 'orange',
|
||||
},
|
||||
{
|
||||
value: 'CALENDAR_EVENTS_IMPORT_PENDING',
|
||||
label: 'Calendar events import pending',
|
||||
position: 3,
|
||||
color: 'blue',
|
||||
},
|
||||
{
|
||||
value: 'CALENDAR_EVENTS_IMPORT_SCHEDULED',
|
||||
label: 'Calendar events import scheduled',
|
||||
position: 4,
|
||||
color: 'green',
|
||||
},
|
||||
{
|
||||
value: 'CALENDAR_EVENTS_IMPORT_ONGOING',
|
||||
label: 'Calendar events import ongoing',
|
||||
position: 5,
|
||||
color: 'orange',
|
||||
},
|
||||
{ value: 'FAILED', label: 'Failed', position: 6, color: 'red' },
|
||||
{
|
||||
value: 'PENDING_CONFIGURATION',
|
||||
label: 'Pending configuration',
|
||||
position: 9,
|
||||
color: 'gray',
|
||||
},
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
syncStageStartedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'syncStageStartedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Sync stage started at',
|
||||
description: 'Sync stage started at',
|
||||
icon: 'IconHistory',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
syncedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'syncedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last sync date',
|
||||
description: 'Last sync date',
|
||||
icon: 'IconHistory',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
throttleFailureCount: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'throttleFailureCount',
|
||||
type: FieldMetadataType.NUMBER,
|
||||
label: 'Throttle Failure Count',
|
||||
description: 'Throttle Failure Count',
|
||||
icon: 'IconX',
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
connectedAccount: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'connectedAccount',
|
||||
label: 'Connected Account',
|
||||
description: 'Connected Account',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'connectedAccount',
|
||||
targetFieldName: 'calendarChannels',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'connectedAccountId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarChannelEventAssociations: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'calendarChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'calendarChannelEventAssociations',
|
||||
label: 'Calendar Channel Event Associations',
|
||||
description: 'Calendar Channel Event Associations',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'calendarChannelEventAssociation',
|
||||
targetFieldName: 'calendarChannel',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildCalendarEventParticipantStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'calendarEventParticipant'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEventParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEventParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEventParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEventParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
handle: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEventParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'handle',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Handle',
|
||||
description: 'Handle',
|
||||
icon: 'IconMail',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
displayName: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEventParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'displayName',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Display Name',
|
||||
description: 'Display Name',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
isOrganizer: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEventParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'isOrganizer',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is Organizer',
|
||||
description: 'Is Organizer',
|
||||
icon: 'IconUser',
|
||||
isNullable: false,
|
||||
defaultValue: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
responseStatus: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEventParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'responseStatus',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Response Status',
|
||||
description: 'Response Status',
|
||||
icon: 'IconUser',
|
||||
isNullable: false,
|
||||
defaultValue: "'NEEDS_ACTION'",
|
||||
options: [
|
||||
{
|
||||
value: 'NEEDS_ACTION',
|
||||
label: 'Needs Action',
|
||||
position: 0,
|
||||
color: 'orange',
|
||||
},
|
||||
{ value: 'DECLINED', label: 'Declined', position: 1, color: 'red' },
|
||||
{
|
||||
value: 'TENTATIVE',
|
||||
label: 'Tentative',
|
||||
position: 2,
|
||||
color: 'yellow',
|
||||
},
|
||||
{ value: 'ACCEPTED', label: 'Accepted', position: 3, color: 'green' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarEvent: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'calendarEventParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'calendarEvent',
|
||||
label: 'Event ID',
|
||||
description: 'Event ID',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'calendarEvent',
|
||||
targetFieldName: 'calendarEventParticipants',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'calendarEventId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
person: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'calendarEventParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'person',
|
||||
label: 'Person',
|
||||
description: 'Person',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'person',
|
||||
targetFieldName: 'calendarEventParticipants',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'personId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workspaceMember: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'calendarEventParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workspaceMember',
|
||||
label: 'Workspace Member',
|
||||
description: 'Workspace Member',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workspaceMember',
|
||||
targetFieldName: 'calendarEventParticipants',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'workspaceMemberId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+291
@@ -0,0 +1,291 @@
|
||||
import { FieldMetadataType, RelationType } from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildCalendarEventStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'calendarEvent'>, FlatFieldMetadata> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
title: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'title',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Title',
|
||||
description: 'Title',
|
||||
icon: 'IconH1',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
isCanceled: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'isCanceled',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is canceled',
|
||||
description: 'Is canceled',
|
||||
icon: 'IconCalendarCancel',
|
||||
isNullable: false,
|
||||
defaultValue: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
isFullDay: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'isFullDay',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is Full Day',
|
||||
description: 'Is Full Day',
|
||||
icon: 'IconHours24',
|
||||
isNullable: false,
|
||||
defaultValue: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
startsAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'startsAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Start Date',
|
||||
description: 'Start Date',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
endsAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'endsAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'End Date',
|
||||
description: 'End Date',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
externalCreatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'externalCreatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation DateTime',
|
||||
description: 'Creation DateTime',
|
||||
icon: 'IconCalendarPlus',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
externalUpdatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'externalUpdatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Update DateTime',
|
||||
description: 'Update DateTime',
|
||||
icon: 'IconCalendarCog',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
description: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'description',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Description',
|
||||
description: 'Description',
|
||||
icon: 'IconFileDescription',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
location: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'location',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Location',
|
||||
description: 'Location',
|
||||
icon: 'IconMapPin',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
iCalUID: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'iCalUID',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'iCal UID',
|
||||
description: 'iCal UID',
|
||||
icon: 'IconKey',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
conferenceSolution: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'conferenceSolution',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Conference Solution',
|
||||
description: 'Conference Solution',
|
||||
icon: 'IconScreenShare',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
conferenceLink: createStandardFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'conferenceLink',
|
||||
type: FieldMetadataType.LINKS,
|
||||
label: 'Meet Link',
|
||||
description: 'Meet Link',
|
||||
icon: 'IconLink',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarChannelEventAssociations: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'calendarChannelEventAssociations',
|
||||
label: 'Calendar Channel Event Associations',
|
||||
description: 'Calendar Channel Event Associations',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'calendarChannelEventAssociation',
|
||||
targetFieldName: 'calendarEvent',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarEventParticipants: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'calendarEvent',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'calendarEventParticipants',
|
||||
label: 'Event Participants',
|
||||
description: 'Event Participants',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'calendarEventParticipant',
|
||||
targetFieldName: 'calendarEvent',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+433
@@ -0,0 +1,433 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildCompanyStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'company'>, FlatFieldMetadata> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Company-specific fields
|
||||
name: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'name',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Name',
|
||||
description: 'The company name',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
domainName: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'domainName',
|
||||
type: FieldMetadataType.LINKS,
|
||||
label: 'Domain Name',
|
||||
description:
|
||||
'The company website URL. We use this url to fetch the company icon',
|
||||
icon: 'IconLink',
|
||||
isNullable: true,
|
||||
isUnique: true,
|
||||
settings: {
|
||||
maxNumberOfValues: 1,
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
address: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'address',
|
||||
type: FieldMetadataType.ADDRESS,
|
||||
label: 'Address',
|
||||
description: 'Address of the company',
|
||||
icon: 'IconMap',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
addressOld: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'addressOld',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Address (deprecated)',
|
||||
description:
|
||||
'Address of the company - deprecated in favor of new address field',
|
||||
icon: 'IconMap',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
employees: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'employees',
|
||||
type: FieldMetadataType.NUMBER,
|
||||
label: 'Employees',
|
||||
description: 'Number of employees in the company',
|
||||
icon: 'IconUsers',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
linkedinLink: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'linkedinLink',
|
||||
type: FieldMetadataType.LINKS,
|
||||
label: 'Linkedin',
|
||||
description: 'The company Linkedin account',
|
||||
icon: 'IconBrandLinkedin',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
xLink: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'xLink',
|
||||
type: FieldMetadataType.LINKS,
|
||||
label: 'X',
|
||||
description: 'The company Twitter/X account',
|
||||
icon: 'IconBrandX',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
annualRecurringRevenue: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'annualRecurringRevenue',
|
||||
type: FieldMetadataType.CURRENCY,
|
||||
label: 'ARR',
|
||||
description:
|
||||
'Annual Recurring Revenue: The actual or estimated annual revenue of the company',
|
||||
icon: 'IconMoneybag',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
idealCustomerProfile: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'idealCustomerProfile',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'ICP',
|
||||
description:
|
||||
'Ideal Customer Profile: Indicates whether the company is the most suitable and valuable customer for you',
|
||||
icon: 'IconTarget',
|
||||
isNullable: false,
|
||||
defaultValue: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.POSITION,
|
||||
label: 'Position',
|
||||
description: 'Company record position',
|
||||
icon: 'IconHierarchy2',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdBy: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdBy',
|
||||
type: FieldMetadataType.ACTOR,
|
||||
label: 'Created by',
|
||||
description: 'The creator of the record',
|
||||
icon: 'IconCreativeCommonsSa',
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
searchVector: createStandardFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'searchVector',
|
||||
type: FieldMetadataType.TS_VECTOR,
|
||||
label: 'Search vector',
|
||||
description: 'Field used for full-text search',
|
||||
icon: 'IconUser',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
people: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'people',
|
||||
label: 'People',
|
||||
description: 'People linked to the company.',
|
||||
icon: 'IconUsers',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'person',
|
||||
targetFieldName: 'company',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
accountOwner: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'accountOwner',
|
||||
label: 'Account Owner',
|
||||
description:
|
||||
'Your team member responsible for managing the company account',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workspaceMember',
|
||||
targetFieldName: 'accountOwnerForCompanies',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'accountOwnerId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
taskTargets: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'taskTargets',
|
||||
label: 'Tasks',
|
||||
description: 'Tasks tied to the company',
|
||||
icon: 'IconCheckbox',
|
||||
isUIReadOnly: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'taskTarget',
|
||||
targetFieldName: 'company',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
noteTargets: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'noteTargets',
|
||||
label: 'Notes',
|
||||
description: 'Notes tied to the company',
|
||||
icon: 'IconNotes',
|
||||
isUIReadOnly: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'noteTarget',
|
||||
targetFieldName: 'company',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
opportunities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'opportunities',
|
||||
label: 'Opportunities',
|
||||
description: 'Opportunities linked to the company.',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'opportunity',
|
||||
targetFieldName: 'company',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favorites: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favorites',
|
||||
label: 'Favorites',
|
||||
description: 'Favorites linked to the company',
|
||||
icon: 'IconHeart',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'favorite',
|
||||
targetFieldName: 'company',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
attachments: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'attachments',
|
||||
label: 'Attachments',
|
||||
description: 'Attachments linked to the company',
|
||||
icon: 'IconFileImport',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'attachment',
|
||||
targetFieldName: 'company',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timelineActivities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'company',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timelineActivities',
|
||||
label: 'Timeline Activities',
|
||||
description: 'Timeline Activities linked to the company',
|
||||
icon: 'IconIconTimelineEvent',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'company',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildConnectedAccountStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'connectedAccount'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
handle: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'handle',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'handle',
|
||||
description: 'The account handle (email, username, phone number, etc.)',
|
||||
icon: 'IconMail',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
provider: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'provider',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'provider',
|
||||
description: 'The account provider',
|
||||
icon: 'IconSettings',
|
||||
isNullable: false,
|
||||
defaultValue: "'google'",
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
accessToken: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'accessToken',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Access Token',
|
||||
description: 'Messaging provider access token',
|
||||
icon: 'IconKey',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
refreshToken: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'refreshToken',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Refresh Token',
|
||||
description: 'Messaging provider refresh token',
|
||||
icon: 'IconKey',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
lastSyncHistoryId: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'lastSyncHistoryId',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Last sync history ID',
|
||||
description: 'Last sync history ID',
|
||||
icon: 'IconHistory',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
authFailedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'authFailedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Auth failed at',
|
||||
description: 'Auth failed at',
|
||||
icon: 'IconX',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
lastCredentialsRefreshedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'lastCredentialsRefreshedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last credentials refreshed at',
|
||||
description: 'Last credentials refreshed at',
|
||||
icon: 'IconHistory',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
handleAliases: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'handleAliases',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Handle Aliases',
|
||||
description: 'Handle Aliases',
|
||||
icon: 'IconMail',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
scopes: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'scopes',
|
||||
type: FieldMetadataType.ARRAY,
|
||||
label: 'Scopes',
|
||||
description: 'Scopes',
|
||||
icon: 'IconSettings',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
connectionParameters: createStandardFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'connectionParameters',
|
||||
type: FieldMetadataType.RAW_JSON,
|
||||
label: 'Custom Connection Parameters',
|
||||
description: 'JSON object containing custom connection parameters',
|
||||
icon: 'IconSettings',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
accountOwner: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'accountOwner',
|
||||
label: 'Account Owner',
|
||||
description: 'Account Owner',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'workspaceMember',
|
||||
targetFieldName: 'connectedAccounts',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'accountOwnerId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageChannels: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageChannels',
|
||||
label: 'Message Channels',
|
||||
description: 'Message Channels',
|
||||
icon: 'IconMessage',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'messageChannel',
|
||||
targetFieldName: 'connectedAccount',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarChannels: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'connectedAccount',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'calendarChannels',
|
||||
label: 'Calendar Channels',
|
||||
description: 'Calendar Channels',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'calendarChannel',
|
||||
targetFieldName: 'connectedAccount',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+222
@@ -0,0 +1,222 @@
|
||||
import { FieldMetadataType, RelationType } from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildDashboardStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'dashboard'>, FlatFieldMetadata> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Dashboard-specific fields
|
||||
title: createStandardFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'title',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Title',
|
||||
description: 'Dashboard title',
|
||||
icon: 'IconNotes',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.POSITION,
|
||||
label: 'Position',
|
||||
description: 'Dashboard record Position',
|
||||
icon: 'IconHierarchy2',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
pageLayoutId: createStandardFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'pageLayoutId',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Page Layout ID',
|
||||
description: 'Dashboard page layout',
|
||||
icon: 'IconLayout',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdBy: createStandardFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdBy',
|
||||
type: FieldMetadataType.ACTOR,
|
||||
label: 'Created by',
|
||||
description: 'The creator of the record',
|
||||
icon: 'IconCreativeCommonsSa',
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
searchVector: createStandardFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'searchVector',
|
||||
type: FieldMetadataType.TS_VECTOR,
|
||||
label: 'Search vector',
|
||||
description: 'Field used for full-text search',
|
||||
icon: 'IconUser',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
timelineActivities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timelineActivities',
|
||||
label: 'Timeline Activities',
|
||||
description: 'Timeline activities linked to the dashboard',
|
||||
icon: 'IconTimelineEvent',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'dashboard',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favorites: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favorites',
|
||||
label: 'Favorites',
|
||||
description: 'Favorites linked to the dashboard',
|
||||
icon: 'IconHeart',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'favorite',
|
||||
targetFieldName: 'dashboard',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
attachments: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'dashboard',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'attachments',
|
||||
label: 'Attachments',
|
||||
description: 'Attachments linked to the dashboard',
|
||||
icon: 'IconFileImport',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'attachment',
|
||||
targetFieldName: 'dashboard',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
import { FieldMetadataType, RelationType } from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildFavoriteFolderStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'favoriteFolder'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'favoriteFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'favoriteFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'favoriteFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'favoriteFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// FavoriteFolder-specific fields
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'favoriteFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.NUMBER,
|
||||
label: 'Position',
|
||||
description: 'Favorite folder position',
|
||||
icon: 'IconList',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
name: createStandardFieldFlatMetadata({
|
||||
objectName: 'favoriteFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'name',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Name',
|
||||
description: 'Name of the favorite folder',
|
||||
icon: 'IconText',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
favorites: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favoriteFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favorites',
|
||||
label: 'Favorites',
|
||||
description: 'Favorites in this folder',
|
||||
icon: 'IconHeart',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'favorite',
|
||||
targetFieldName: 'favoriteFolder',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+364
@@ -0,0 +1,364 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildFavoriteStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'favorite'>, FlatFieldMetadata> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Favorite-specific fields
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.NUMBER,
|
||||
label: 'Position',
|
||||
description: 'Favorite position',
|
||||
icon: 'IconList',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
view: createStandardFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'view',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'ViewId',
|
||||
description: 'ViewId',
|
||||
icon: 'IconView',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
forWorkspaceMember: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'forWorkspaceMember',
|
||||
label: 'Workspace Member',
|
||||
description: 'Favorite workspace member',
|
||||
icon: 'IconCircleUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workspaceMember',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'forWorkspaceMemberId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
person: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'person',
|
||||
label: 'Person',
|
||||
description: 'Favorite person',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'person',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'personId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
company: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'company',
|
||||
label: 'Company',
|
||||
description: 'Favorite company',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'company',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'companyId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
opportunity: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'opportunity',
|
||||
label: 'Opportunity',
|
||||
description: 'Favorite opportunity',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'opportunity',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'opportunityId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflow: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workflow',
|
||||
label: 'Workflow',
|
||||
description: 'Favorite workflow',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workflow',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflowVersion: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workflowVersion',
|
||||
label: 'Workflow',
|
||||
description: 'Favorite workflow version',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workflowVersion',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowVersionId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflowRun: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workflowRun',
|
||||
label: 'Workflow',
|
||||
description: 'Favorite workflow run',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workflowRun',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowRunId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
task: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'task',
|
||||
label: 'Task',
|
||||
description: 'Favorite task',
|
||||
icon: 'IconCheckbox',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'task',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'taskId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
note: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'note',
|
||||
label: 'Note',
|
||||
description: 'Favorite note',
|
||||
icon: 'IconNotes',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'note',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'noteId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
dashboard: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'dashboard',
|
||||
label: 'Dashboard',
|
||||
description: 'Favorite dashboard',
|
||||
icon: 'IconLayoutDashboard',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'dashboard',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'dashboardId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favoriteFolder: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favoriteFolder',
|
||||
label: 'Favorite Folder',
|
||||
description: 'The folder this favorite belongs to',
|
||||
icon: 'IconFolder',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'favoriteFolder',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'favoriteFolderId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
custom: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'favorite',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'custom',
|
||||
label: 'Custom',
|
||||
description: 'Favorite custom object',
|
||||
icon: 'IconHeart',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'note',
|
||||
targetFieldName: 'favorites',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'customId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+200
@@ -0,0 +1,200 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildMessageChannelMessageAssociationStandardFlatFieldMetadatas =
|
||||
({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'messageChannelMessageAssociation'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannelMessageAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannelMessageAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannelMessageAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannelMessageAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageExternalId: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannelMessageAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageExternalId',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Message External Id',
|
||||
description: 'Message id from the messaging provider',
|
||||
icon: 'IconHash',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageThreadExternalId: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannelMessageAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageThreadExternalId',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Thread External Id',
|
||||
description: 'Thread id from the messaging provider',
|
||||
icon: 'IconHash',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
direction: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannelMessageAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'direction',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Direction',
|
||||
description: 'Message Direction',
|
||||
icon: 'IconDirection',
|
||||
isNullable: false,
|
||||
defaultValue: "'incoming'",
|
||||
options: [
|
||||
{ value: 'incoming', label: 'Incoming', position: 0, color: 'green' },
|
||||
{ value: 'outgoing', label: 'Outgoing', position: 1, color: 'blue' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageChannel: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageChannelMessageAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageChannel',
|
||||
label: 'Message Channel Id',
|
||||
description: 'Message Channel Id',
|
||||
icon: 'IconHash',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'messageChannel',
|
||||
targetFieldName: 'messageChannelMessageAssociations',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'messageChannelId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageThread: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageChannelMessageAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageThread',
|
||||
label: 'Message Thread Id',
|
||||
description: 'Message Thread Id',
|
||||
icon: 'IconHash',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'messageThread',
|
||||
targetFieldName: 'messageChannelMessageAssociations',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'messageThreadId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
message: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageChannelMessageAssociation',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'message',
|
||||
label: 'Message Id',
|
||||
description: 'Message Id',
|
||||
icon: 'IconHash',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'message',
|
||||
targetFieldName: 'messageChannelMessageAssociations',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'messageId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+504
@@ -0,0 +1,504 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildMessageChannelStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'messageChannel'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
visibility: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'visibility',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Visibility',
|
||||
description: 'Visibility',
|
||||
icon: 'IconEyeglass',
|
||||
isNullable: false,
|
||||
defaultValue: "'SHARE_EVERYTHING'",
|
||||
options: [
|
||||
{ value: 'METADATA', label: 'Metadata', position: 0, color: 'green' },
|
||||
{ value: 'SUBJECT', label: 'Subject', position: 1, color: 'blue' },
|
||||
{
|
||||
value: 'SHARE_EVERYTHING',
|
||||
label: 'Share Everything',
|
||||
position: 2,
|
||||
color: 'orange',
|
||||
},
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
handle: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'handle',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Handle',
|
||||
description: 'Handle',
|
||||
icon: 'IconAt',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
type: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'type',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Type',
|
||||
description: 'Channel Type',
|
||||
icon: 'IconMessage',
|
||||
isNullable: false,
|
||||
defaultValue: "'email'",
|
||||
options: [
|
||||
{ value: 'email', label: 'Email', position: 0, color: 'green' },
|
||||
{ value: 'sms', label: 'SMS', position: 1, color: 'blue' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
isContactAutoCreationEnabled: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'isContactAutoCreationEnabled',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is Contact Auto Creation Enabled',
|
||||
description: 'Is Contact Auto Creation Enabled',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: false,
|
||||
defaultValue: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
contactAutoCreationPolicy: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'contactAutoCreationPolicy',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Contact auto creation policy',
|
||||
description:
|
||||
'Automatically create People records when receiving or sending emails',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: false,
|
||||
defaultValue: "'SENT'",
|
||||
options: [
|
||||
{
|
||||
value: 'SENT_AND_RECEIVED',
|
||||
label: 'Sent and Received',
|
||||
position: 0,
|
||||
color: 'green',
|
||||
},
|
||||
{ value: 'SENT', label: 'Sent', position: 1, color: 'blue' },
|
||||
{ value: 'NONE', label: 'None', position: 2, color: 'red' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageFolderImportPolicy: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageFolderImportPolicy',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Message folder import policy',
|
||||
description: 'Message folder import policy',
|
||||
icon: 'IconFolder',
|
||||
isNullable: false,
|
||||
defaultValue: "'ALL_FOLDERS'",
|
||||
options: [
|
||||
{
|
||||
value: 'ALL_FOLDERS',
|
||||
label: 'All folders',
|
||||
position: 0,
|
||||
color: 'green',
|
||||
},
|
||||
{
|
||||
value: 'SELECTED_FOLDERS',
|
||||
label: 'Selected folders',
|
||||
position: 1,
|
||||
color: 'blue',
|
||||
},
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
excludeNonProfessionalEmails: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'excludeNonProfessionalEmails',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Exclude non professional emails',
|
||||
description: 'Exclude non professional emails',
|
||||
icon: 'IconBriefcase',
|
||||
isNullable: false,
|
||||
defaultValue: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
excludeGroupEmails: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'excludeGroupEmails',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Exclude group emails',
|
||||
description: 'Exclude group emails',
|
||||
icon: 'IconUsersGroup',
|
||||
isNullable: false,
|
||||
defaultValue: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
pendingGroupEmailsAction: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'pendingGroupEmailsAction',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Pending group emails action',
|
||||
description: 'Pending action for group emails',
|
||||
icon: 'IconUsersGroup',
|
||||
isNullable: false,
|
||||
defaultValue: "'NONE'",
|
||||
options: [
|
||||
{
|
||||
value: 'GROUP_EMAILS_DELETION',
|
||||
label: 'Group emails deletion',
|
||||
position: 0,
|
||||
color: 'red',
|
||||
},
|
||||
{
|
||||
value: 'GROUP_EMAILS_IMPORT',
|
||||
label: 'Group emails import',
|
||||
position: 1,
|
||||
color: 'green',
|
||||
},
|
||||
{ value: 'NONE', label: 'None', position: 2, color: 'blue' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
isSyncEnabled: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'isSyncEnabled',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is Sync Enabled',
|
||||
description: 'Is Sync Enabled',
|
||||
icon: 'IconRefresh',
|
||||
isNullable: false,
|
||||
defaultValue: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
syncCursor: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'syncCursor',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Last sync cursor',
|
||||
description: 'Last sync cursor',
|
||||
icon: 'IconHistory',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
syncedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'syncedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last sync date',
|
||||
description: 'Last sync date',
|
||||
icon: 'IconHistory',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
syncStatus: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'syncStatus',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Sync status',
|
||||
description: 'Sync status',
|
||||
icon: 'IconStatusChange',
|
||||
isNullable: true,
|
||||
options: [
|
||||
{ value: 'ONGOING', label: 'Ongoing', position: 1, color: 'yellow' },
|
||||
{
|
||||
value: 'NOT_SYNCED',
|
||||
label: 'Not Synced',
|
||||
position: 2,
|
||||
color: 'blue',
|
||||
},
|
||||
{ value: 'ACTIVE', label: 'Active', position: 3, color: 'green' },
|
||||
{
|
||||
value: 'FAILED_INSUFFICIENT_PERMISSIONS',
|
||||
label: 'Failed Insufficient Permissions',
|
||||
position: 4,
|
||||
color: 'red',
|
||||
},
|
||||
{
|
||||
value: 'FAILED_UNKNOWN',
|
||||
label: 'Failed Unknown',
|
||||
position: 5,
|
||||
color: 'red',
|
||||
},
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
syncStage: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'syncStage',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Sync stage',
|
||||
description: 'Sync stage',
|
||||
icon: 'IconStatusChange',
|
||||
isNullable: false,
|
||||
defaultValue: "'PENDING_CONFIGURATION'",
|
||||
options: [
|
||||
{
|
||||
value: 'MESSAGE_LIST_FETCH_PENDING',
|
||||
label: 'Messages list fetch pending',
|
||||
position: 0,
|
||||
color: 'blue',
|
||||
},
|
||||
{
|
||||
value: 'MESSAGE_LIST_FETCH_SCHEDULED',
|
||||
label: 'Messages list fetch scheduled',
|
||||
position: 1,
|
||||
color: 'green',
|
||||
},
|
||||
{
|
||||
value: 'MESSAGE_LIST_FETCH_ONGOING',
|
||||
label: 'Messages list fetch ongoing',
|
||||
position: 2,
|
||||
color: 'orange',
|
||||
},
|
||||
{
|
||||
value: 'MESSAGES_IMPORT_PENDING',
|
||||
label: 'Messages import pending',
|
||||
position: 3,
|
||||
color: 'blue',
|
||||
},
|
||||
{
|
||||
value: 'MESSAGES_IMPORT_SCHEDULED',
|
||||
label: 'Messages import scheduled',
|
||||
position: 4,
|
||||
color: 'green',
|
||||
},
|
||||
{
|
||||
value: 'MESSAGES_IMPORT_ONGOING',
|
||||
label: 'Messages import ongoing',
|
||||
position: 5,
|
||||
color: 'orange',
|
||||
},
|
||||
{ value: 'FAILED', label: 'Failed', position: 6, color: 'red' },
|
||||
{
|
||||
value: 'PENDING_CONFIGURATION',
|
||||
label: 'Pending configuration',
|
||||
position: 7,
|
||||
color: 'gray',
|
||||
},
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
syncStageStartedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'syncStageStartedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Sync stage started at',
|
||||
description: 'Sync stage started at',
|
||||
icon: 'IconHistory',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
throttleFailureCount: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'throttleFailureCount',
|
||||
type: FieldMetadataType.NUMBER,
|
||||
label: 'Throttle Failure Count',
|
||||
description: 'Throttle Failure Count',
|
||||
icon: 'IconX',
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
connectedAccount: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'connectedAccount',
|
||||
label: 'Connected Account',
|
||||
description: 'Connected Account',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'connectedAccount',
|
||||
targetFieldName: 'messageChannels',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'connectedAccountId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageChannelMessageAssociations: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageChannelMessageAssociations',
|
||||
label: 'Message Channel Association',
|
||||
description: 'Messages from the channel.',
|
||||
icon: 'IconMessage',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'messageChannelMessageAssociation',
|
||||
targetFieldName: 'messageChannel',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageFolders: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageChannel',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageFolders',
|
||||
label: 'Message Folders',
|
||||
description: 'Message Folders',
|
||||
icon: 'IconFolder',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'messageFolder',
|
||||
targetFieldName: 'messageChannel',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+219
@@ -0,0 +1,219 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildMessageFolderStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'messageFolder'>, FlatFieldMetadata> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
name: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'name',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Name',
|
||||
description: 'Folder name',
|
||||
icon: 'IconFolder',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
syncCursor: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'syncCursor',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Sync Cursor',
|
||||
description: 'Sync Cursor',
|
||||
icon: 'IconHash',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
isSentFolder: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'isSentFolder',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is Sent Folder',
|
||||
description: 'Is Sent Folder',
|
||||
icon: 'IconCheck',
|
||||
isNullable: false,
|
||||
defaultValue: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
isSynced: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'isSynced',
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is Synced',
|
||||
description: 'Is Synced',
|
||||
icon: 'IconCheck',
|
||||
isNullable: false,
|
||||
defaultValue: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
parentFolderId: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'parentFolderId',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Parent Folder ID',
|
||||
description: 'Parent Folder ID',
|
||||
icon: 'IconFolder',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
externalId: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'externalId',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'External ID',
|
||||
description: 'External ID',
|
||||
icon: 'IconHash',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
pendingSyncAction: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'pendingSyncAction',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Pending Sync Action',
|
||||
description: 'Pending action for folder sync',
|
||||
icon: 'IconReload',
|
||||
isNullable: false,
|
||||
defaultValue: "'NONE'",
|
||||
options: [
|
||||
{
|
||||
value: 'FOLDER_DELETION',
|
||||
label: 'Folder deletion',
|
||||
position: 0,
|
||||
color: 'red',
|
||||
},
|
||||
{ value: 'NONE', label: 'None', position: 1, color: 'blue' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageChannel: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageFolder',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageChannel',
|
||||
label: 'Message Channel',
|
||||
description: 'Message Channel',
|
||||
icon: 'IconMessage',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'messageChannel',
|
||||
targetFieldName: 'messageFolders',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'messageChannelId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildMessageParticipantStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'messageParticipant'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
role: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'role',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Role',
|
||||
description: 'Role',
|
||||
icon: 'IconAt',
|
||||
isNullable: false,
|
||||
defaultValue: "'from'",
|
||||
options: [
|
||||
{ value: 'from', label: 'From', position: 0, color: 'green' },
|
||||
{ value: 'to', label: 'To', position: 1, color: 'blue' },
|
||||
{ value: 'cc', label: 'Cc', position: 2, color: 'orange' },
|
||||
{ value: 'bcc', label: 'Bcc', position: 3, color: 'red' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
handle: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'handle',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Handle',
|
||||
description: 'Handle',
|
||||
icon: 'IconAt',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
displayName: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'displayName',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Display Name',
|
||||
description: 'Display Name',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
message: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'message',
|
||||
label: 'Message',
|
||||
description: 'Message',
|
||||
icon: 'IconMessage',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'message',
|
||||
targetFieldName: 'messageParticipants',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'messageId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
person: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'person',
|
||||
label: 'Person',
|
||||
description: 'Person',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'person',
|
||||
targetFieldName: 'messageParticipants',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'personId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workspaceMember: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageParticipant',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workspaceMember',
|
||||
label: 'Workspace Member',
|
||||
description: 'Workspace member',
|
||||
icon: 'IconCircleUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workspaceMember',
|
||||
targetFieldName: 'messageParticipants',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'workspaceMemberId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildMessageStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'message'>, FlatFieldMetadata> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
headerMessageId: createStandardFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'headerMessageId',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Header message Id',
|
||||
description: 'Message id from the message header',
|
||||
icon: 'IconHash',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
direction: createStandardFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'direction',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Direction',
|
||||
description: 'Message Direction',
|
||||
icon: 'IconDirection',
|
||||
isNullable: false,
|
||||
defaultValue: "'INCOMING'",
|
||||
options: [
|
||||
{ value: 'INCOMING', label: 'Incoming', position: 0, color: 'green' },
|
||||
{ value: 'OUTGOING', label: 'Outgoing', position: 1, color: 'blue' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
subject: createStandardFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'subject',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Subject',
|
||||
description: 'Subject',
|
||||
icon: 'IconMessage',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
text: createStandardFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'text',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Text',
|
||||
description: 'Text',
|
||||
icon: 'IconMessage',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
receivedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'receivedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Received At',
|
||||
description: 'The date the message was received',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageThread: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageThread',
|
||||
label: 'Message Thread Id',
|
||||
description: 'Message Thread Id',
|
||||
icon: 'IconHash',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'messageThread',
|
||||
targetFieldName: 'messages',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'messageThreadId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageParticipants: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageParticipants',
|
||||
label: 'Message Participants',
|
||||
description: 'Message Participants',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'messageParticipant',
|
||||
targetFieldName: 'message',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageChannelMessageAssociations: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'message',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageChannelMessageAssociations',
|
||||
label: 'Message Channel Association',
|
||||
description: 'Messages from the channel.',
|
||||
icon: 'IconMessage',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'messageChannelMessageAssociation',
|
||||
targetFieldName: 'message',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
import { FieldMetadataType, RelationType } from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildMessageThreadStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'messageThread'>, FlatFieldMetadata> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageThread',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageThread',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageThread',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'messageThread',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messages: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageThread',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messages',
|
||||
label: 'Messages',
|
||||
description: 'Messages from the thread.',
|
||||
icon: 'IconMessage',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'message',
|
||||
targetFieldName: 'messageThread',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageChannelMessageAssociations: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'messageThread',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageChannelMessageAssociations',
|
||||
label: 'Message Channel Association',
|
||||
description: 'Messages from the channel.',
|
||||
icon: 'IconMessage',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'messageChannelMessageAssociation',
|
||||
targetFieldName: 'messageThread',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
import { FieldMetadataType, RelationType } from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildNoteStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'note'>, FlatFieldMetadata> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Note-specific fields
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.POSITION,
|
||||
label: 'Position',
|
||||
description: 'Note record position',
|
||||
icon: 'IconHierarchy2',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
title: createStandardFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'title',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Title',
|
||||
description: 'Note title',
|
||||
icon: 'IconNotes',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
body: createStandardFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'body',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Body (deprecated)',
|
||||
description: 'Note body (deprecated - use bodyV2)',
|
||||
icon: 'IconFilePencil',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
bodyV2: createStandardFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'bodyV2',
|
||||
type: FieldMetadataType.RICH_TEXT_V2,
|
||||
label: 'Body',
|
||||
description: 'Note body',
|
||||
icon: 'IconFilePencil',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdBy: createStandardFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdBy',
|
||||
type: FieldMetadataType.ACTOR,
|
||||
label: 'Created by',
|
||||
description: 'The creator of the record',
|
||||
icon: 'IconCreativeCommonsSa',
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
searchVector: createStandardFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'searchVector',
|
||||
type: FieldMetadataType.TS_VECTOR,
|
||||
label: 'Search vector',
|
||||
description: 'Field used for full-text search',
|
||||
icon: 'IconUser',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
noteTargets: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'noteTargets',
|
||||
label: 'Relations',
|
||||
description: 'Note targets',
|
||||
icon: 'IconArrowUpRight',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'noteTarget',
|
||||
targetFieldName: 'note',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
attachments: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'attachments',
|
||||
label: 'Attachments',
|
||||
description: 'Note attachments',
|
||||
icon: 'IconFileImport',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'attachment',
|
||||
targetFieldName: 'note',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timelineActivities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timelineActivities',
|
||||
label: 'Timeline Activities',
|
||||
description: 'Timeline Activities linked to the note.',
|
||||
icon: 'IconTimelineEvent',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'note',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favorites: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'note',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favorites',
|
||||
label: 'Favorites',
|
||||
description: 'Favorites linked to the note',
|
||||
icon: 'IconHeart',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'favorite',
|
||||
targetFieldName: 'note',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildNoteTargetStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'noteTarget'>, FlatFieldMetadata> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'noteTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'noteTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'noteTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'noteTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
note: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'noteTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'note',
|
||||
label: 'Note',
|
||||
description: 'NoteTarget note',
|
||||
icon: 'IconNotes',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'note',
|
||||
targetFieldName: 'noteTargets',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'noteId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
person: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'noteTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'person',
|
||||
label: 'Person',
|
||||
description: 'NoteTarget person',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'person',
|
||||
targetFieldName: 'noteTargets',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'personId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
company: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'noteTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'company',
|
||||
label: 'Company',
|
||||
description: 'NoteTarget company',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'company',
|
||||
targetFieldName: 'noteTargets',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'companyId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
opportunity: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'noteTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'opportunity',
|
||||
label: 'Opportunity',
|
||||
description: 'NoteTarget opportunity',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'opportunity',
|
||||
targetFieldName: 'noteTargets',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'opportunityId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
custom: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'noteTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'custom',
|
||||
label: 'Custom',
|
||||
description: 'NoteTarget custom object',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
// Custom is a dynamic relation
|
||||
targetObjectName: 'note',
|
||||
targetFieldName: 'noteTargets',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'customId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+355
@@ -0,0 +1,355 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildOpportunityStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'opportunity'>, FlatFieldMetadata> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Opportunity-specific fields
|
||||
name: createStandardFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'name',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Name',
|
||||
description: 'The opportunity name',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
amount: createStandardFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'amount',
|
||||
type: FieldMetadataType.CURRENCY,
|
||||
label: 'Amount',
|
||||
description: 'Opportunity amount',
|
||||
icon: 'IconCurrencyDollar',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
closeDate: createStandardFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'closeDate',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Close date',
|
||||
description: 'Opportunity close date',
|
||||
icon: 'IconCalendarEvent',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
stage: createStandardFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'stage',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Stage',
|
||||
description: 'Opportunity stage',
|
||||
icon: 'IconProgressCheck',
|
||||
isNullable: false,
|
||||
defaultValue: "'NEW'",
|
||||
options: [
|
||||
{ value: 'NEW', label: 'New', position: 0, color: 'red' },
|
||||
{
|
||||
value: 'SCREENING',
|
||||
label: 'Screening',
|
||||
position: 1,
|
||||
color: 'purple',
|
||||
},
|
||||
{ value: 'MEETING', label: 'Meeting', position: 2, color: 'sky' },
|
||||
{
|
||||
value: 'PROPOSAL',
|
||||
label: 'Proposal',
|
||||
position: 3,
|
||||
color: 'turquoise',
|
||||
},
|
||||
{ value: 'CUSTOMER', label: 'Customer', position: 4, color: 'yellow' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.POSITION,
|
||||
label: 'Position',
|
||||
description: 'Opportunity record position',
|
||||
icon: 'IconHierarchy2',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdBy: createStandardFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdBy',
|
||||
type: FieldMetadataType.ACTOR,
|
||||
label: 'Created by',
|
||||
description: 'The creator of the record',
|
||||
icon: 'IconCreativeCommonsSa',
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
searchVector: createStandardFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'searchVector',
|
||||
type: FieldMetadataType.TS_VECTOR,
|
||||
label: 'Search vector',
|
||||
description: 'Field used for full-text search',
|
||||
icon: 'IconUser',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
pointOfContact: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'pointOfContact',
|
||||
label: 'Point of Contact',
|
||||
description: 'Opportunity point of contact',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'person',
|
||||
targetFieldName: 'pointOfContactForOpportunities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'pointOfContactId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
company: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'company',
|
||||
label: 'Company',
|
||||
description: 'Opportunity company',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'company',
|
||||
targetFieldName: 'opportunities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'companyId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favorites: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favorites',
|
||||
label: 'Favorites',
|
||||
description: 'Favorites linked to the opportunity',
|
||||
icon: 'IconHeart',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'favorite',
|
||||
targetFieldName: 'opportunity',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
taskTargets: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'taskTargets',
|
||||
label: 'Tasks',
|
||||
description: 'Tasks tied to the opportunity',
|
||||
icon: 'IconCheckbox',
|
||||
isUIReadOnly: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'taskTarget',
|
||||
targetFieldName: 'opportunity',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
noteTargets: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'noteTargets',
|
||||
label: 'Notes',
|
||||
description: 'Notes tied to the opportunity',
|
||||
icon: 'IconNotes',
|
||||
isUIReadOnly: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'noteTarget',
|
||||
targetFieldName: 'opportunity',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
attachments: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'attachments',
|
||||
label: 'Attachments',
|
||||
description: 'Attachments linked to the opportunity',
|
||||
icon: 'IconFileImport',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'attachment',
|
||||
targetFieldName: 'opportunity',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timelineActivities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'opportunity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timelineActivities',
|
||||
label: 'Timeline Activities',
|
||||
description: 'Timeline Activities linked to the opportunity.',
|
||||
icon: 'IconTimelineEvent',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'opportunity',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+466
@@ -0,0 +1,466 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildPersonStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'person'>, FlatFieldMetadata> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Person-specific fields
|
||||
name: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'name',
|
||||
type: FieldMetadataType.FULL_NAME,
|
||||
label: 'Name',
|
||||
description: "Contact's name",
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
email: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'email',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Email',
|
||||
description: "Contact's Email (deprecated)",
|
||||
icon: 'IconMail',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
emails: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'emails',
|
||||
type: FieldMetadataType.EMAILS,
|
||||
label: 'Emails',
|
||||
description: "Contact's Emails",
|
||||
icon: 'IconMail',
|
||||
isNullable: true,
|
||||
isUnique: true,
|
||||
settings: {
|
||||
maxNumberOfValues: 1,
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
linkedinLink: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'linkedinLink',
|
||||
type: FieldMetadataType.LINKS,
|
||||
label: 'Linkedin',
|
||||
description: "Contact's Linkedin account",
|
||||
icon: 'IconBrandLinkedin',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
xLink: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'xLink',
|
||||
type: FieldMetadataType.LINKS,
|
||||
label: 'X',
|
||||
description: "Contact's X/Twitter account",
|
||||
icon: 'IconBrandX',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
jobTitle: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'jobTitle',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Job Title',
|
||||
description: "Contact's job title",
|
||||
icon: 'IconBriefcase',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
phone: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'phone',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Phone',
|
||||
description: "Contact's phone number (deprecated)",
|
||||
icon: 'IconPhone',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
phones: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'phones',
|
||||
type: FieldMetadataType.PHONES,
|
||||
label: 'Phones',
|
||||
description: "Contact's phone numbers",
|
||||
icon: 'IconPhone',
|
||||
isNullable: true,
|
||||
settings: {
|
||||
maxNumberOfValues: 1,
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
city: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'city',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'City',
|
||||
description: "Contact's city",
|
||||
icon: 'IconMap',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
avatarUrl: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'avatarUrl',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Avatar',
|
||||
description: "Contact's avatar",
|
||||
icon: 'IconFileUpload',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.POSITION,
|
||||
label: 'Position',
|
||||
description: 'Person record Position',
|
||||
icon: 'IconHierarchy2',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdBy: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdBy',
|
||||
type: FieldMetadataType.ACTOR,
|
||||
label: 'Created by',
|
||||
description: 'The creator of the record',
|
||||
icon: 'IconCreativeCommonsSa',
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
company: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'company',
|
||||
label: 'Company',
|
||||
description: "Contact's company",
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'company',
|
||||
targetFieldName: 'people',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'companyId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
pointOfContactForOpportunities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'pointOfContactForOpportunities',
|
||||
label: 'Opportunities',
|
||||
description:
|
||||
'List of opportunities for which that person is the point of contact',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'opportunity',
|
||||
targetFieldName: 'pointOfContact',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
taskTargets: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'taskTargets',
|
||||
label: 'Tasks',
|
||||
description: 'Tasks tied to the contact',
|
||||
icon: 'IconCheckbox',
|
||||
isUIReadOnly: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'taskTarget',
|
||||
targetFieldName: 'person',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
noteTargets: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'noteTargets',
|
||||
label: 'Notes',
|
||||
description: 'Notes tied to the contact',
|
||||
icon: 'IconNotes',
|
||||
isUIReadOnly: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'noteTarget',
|
||||
targetFieldName: 'person',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favorites: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favorites',
|
||||
label: 'Favorites',
|
||||
description: 'Favorites linked to the contact',
|
||||
icon: 'IconHeart',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'favorite',
|
||||
targetFieldName: 'person',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
attachments: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'attachments',
|
||||
label: 'Attachments',
|
||||
description: 'Attachments linked to the contact.',
|
||||
icon: 'IconFileImport',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'attachment',
|
||||
targetFieldName: 'person',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageParticipants: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageParticipants',
|
||||
label: 'Message Participants',
|
||||
description: 'Message Participants',
|
||||
icon: 'IconUserCircle',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'messageParticipant',
|
||||
targetFieldName: 'person',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarEventParticipants: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'calendarEventParticipants',
|
||||
label: 'Calendar Event Participants',
|
||||
description: 'Calendar Event Participants',
|
||||
icon: 'IconCalendar',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'calendarEventParticipant',
|
||||
targetFieldName: 'person',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timelineActivities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timelineActivities',
|
||||
label: 'Events',
|
||||
description: 'Events linked to the person',
|
||||
icon: 'IconTimelineEvent',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'person',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
searchVector: createStandardFieldFlatMetadata({
|
||||
objectName: 'person',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'searchVector',
|
||||
type: FieldMetadataType.TS_VECTOR,
|
||||
label: 'Search vector',
|
||||
description: 'Field used for full-text search',
|
||||
icon: 'IconUser',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+323
@@ -0,0 +1,323 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildTaskStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'task'>, FlatFieldMetadata> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Task-specific fields
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.POSITION,
|
||||
label: 'Position',
|
||||
description: 'Task record position',
|
||||
icon: 'IconHierarchy2',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
title: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'title',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Title',
|
||||
description: 'Task title',
|
||||
icon: 'IconNotes',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
body: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'body',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Body (deprecated)',
|
||||
description: 'Task body (deprecated - use bodyV2)',
|
||||
icon: 'IconFilePencil',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
bodyV2: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'bodyV2',
|
||||
type: FieldMetadataType.RICH_TEXT_V2,
|
||||
label: 'Body',
|
||||
description: 'Task body',
|
||||
icon: 'IconFilePencil',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
dueAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'dueAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Due Date',
|
||||
description: 'Task due date',
|
||||
icon: 'IconCalendarEvent',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
status: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'status',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Status',
|
||||
description: 'Task status',
|
||||
icon: 'IconCheck',
|
||||
isNullable: true,
|
||||
defaultValue: "'TODO'",
|
||||
options: [
|
||||
{ value: 'TODO', label: 'To do', position: 0, color: 'sky' },
|
||||
{
|
||||
value: 'IN_PROGRESS',
|
||||
label: 'In progress',
|
||||
position: 1,
|
||||
color: 'purple',
|
||||
},
|
||||
{ value: 'DONE', label: 'Done', position: 2, color: 'green' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdBy: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdBy',
|
||||
type: FieldMetadataType.ACTOR,
|
||||
label: 'Created by',
|
||||
description: 'The creator of the record',
|
||||
icon: 'IconCreativeCommonsSa',
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
searchVector: createStandardFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'searchVector',
|
||||
type: FieldMetadataType.TS_VECTOR,
|
||||
label: 'Search vector',
|
||||
description: 'Field used for full-text search',
|
||||
icon: 'IconUser',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
taskTargets: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'taskTargets',
|
||||
label: 'Relations',
|
||||
description: 'Task targets',
|
||||
icon: 'IconArrowUpRight',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'taskTarget',
|
||||
targetFieldName: 'task',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
attachments: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'attachments',
|
||||
label: 'Attachments',
|
||||
description: 'Task attachments',
|
||||
icon: 'IconFileImport',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'attachment',
|
||||
targetFieldName: 'task',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
assignee: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'assignee',
|
||||
label: 'Assignee',
|
||||
description: 'Task assignee',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workspaceMember',
|
||||
targetFieldName: 'assignedTasks',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'assigneeId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timelineActivities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timelineActivities',
|
||||
label: 'Timeline Activities',
|
||||
description: 'Timeline Activities linked to the task.',
|
||||
icon: 'IconTimelineEvent',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'task',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favorites: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'task',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favorites',
|
||||
label: 'Favorites',
|
||||
description: 'Favorites linked to the task',
|
||||
icon: 'IconHeart',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'favorite',
|
||||
targetFieldName: 'task',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildTaskTargetStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'taskTarget'>, FlatFieldMetadata> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'taskTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'taskTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'taskTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'taskTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: {
|
||||
displayFormat: 'RELATIVE',
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
task: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'taskTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'task',
|
||||
label: 'Task',
|
||||
description: 'TaskTarget task',
|
||||
icon: 'IconCheckbox',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'task',
|
||||
targetFieldName: 'taskTargets',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'taskId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
person: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'taskTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'person',
|
||||
label: 'Person',
|
||||
description: 'TaskTarget person',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'person',
|
||||
targetFieldName: 'taskTargets',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'personId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
company: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'taskTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'company',
|
||||
label: 'Company',
|
||||
description: 'TaskTarget company',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'company',
|
||||
targetFieldName: 'taskTargets',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'companyId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
opportunity: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'taskTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'opportunity',
|
||||
label: 'Opportunity',
|
||||
description: 'TaskTarget opportunity',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'opportunity',
|
||||
targetFieldName: 'taskTargets',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'opportunityId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
custom: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'taskTarget',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'custom',
|
||||
label: 'Custom',
|
||||
description: 'TaskTarget custom object',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
// Custom is a dynamic relation
|
||||
targetObjectName: 'task',
|
||||
targetFieldName: 'taskTargets',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'customId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+402
@@ -0,0 +1,402 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'timelineActivity'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
// Base fields from BaseWorkspaceEntity
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// TimelineActivity-specific fields
|
||||
happensAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'happensAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
defaultValue: 'now',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
name: createStandardFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'name',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Event name',
|
||||
description: 'Event name',
|
||||
icon: 'IconAbc',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
properties: createStandardFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'properties',
|
||||
type: FieldMetadataType.RAW_JSON,
|
||||
label: 'Event details',
|
||||
description: 'Json value for event details',
|
||||
icon: 'IconListDetails',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
linkedRecordCachedName: createStandardFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'linkedRecordCachedName',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Linked Record cached name',
|
||||
description: 'Cached record name',
|
||||
icon: 'IconAbc',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
linkedRecordId: createStandardFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'linkedRecordId',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Linked Record id',
|
||||
description: 'Linked Record id',
|
||||
icon: 'IconAbc',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
linkedObjectMetadataId: createStandardFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'linkedObjectMetadataId',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Linked Object Metadata Id',
|
||||
description: 'Linked Object Metadata Id',
|
||||
icon: 'IconAbc',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
|
||||
// Relation fields
|
||||
workspaceMember: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workspaceMember',
|
||||
label: 'Workspace Member',
|
||||
description: 'Event workspace member',
|
||||
icon: 'IconCircleUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workspaceMember',
|
||||
targetFieldName: 'timelineActivities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workspaceMemberId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
person: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'person',
|
||||
label: 'Person',
|
||||
description: 'Event person',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'person',
|
||||
targetFieldName: 'timelineActivities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'personId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
company: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'company',
|
||||
label: 'Company',
|
||||
description: 'Event company',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'company',
|
||||
targetFieldName: 'timelineActivities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'companyId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
opportunity: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'opportunity',
|
||||
label: 'Opportunity',
|
||||
description: 'Event opportunity',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'opportunity',
|
||||
targetFieldName: 'timelineActivities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'opportunityId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
note: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'note',
|
||||
label: 'Note',
|
||||
description: 'Event note',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'note',
|
||||
targetFieldName: 'timelineActivities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'noteId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
task: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'task',
|
||||
label: 'Task',
|
||||
description: 'Event task',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'task',
|
||||
targetFieldName: 'timelineActivities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'taskId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflow: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workflow',
|
||||
label: 'Workflow',
|
||||
description: 'Event workflow',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workflow',
|
||||
targetFieldName: 'timelineActivities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflowVersion: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workflowVersion',
|
||||
label: 'WorkflowVersion',
|
||||
description: 'Event workflow version',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workflowVersion',
|
||||
targetFieldName: 'timelineActivities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowVersionId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflowRun: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workflowRun',
|
||||
label: 'Workflow Run',
|
||||
description: 'Event workflow run',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workflowRun',
|
||||
targetFieldName: 'timelineActivities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowRunId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
dashboard: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'dashboard',
|
||||
label: 'Dashboard',
|
||||
description: 'Event dashboard',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'dashboard',
|
||||
targetFieldName: 'timelineActivities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'dashboardId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
custom: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'timelineActivity',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'custom',
|
||||
label: 'Custom',
|
||||
description: 'Timeline Activity custom object',
|
||||
icon: 'IconTimeline',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'note',
|
||||
targetFieldName: 'timelineActivities',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'customId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildWorkflowAutomatedTriggerStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'workflowAutomatedTrigger'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowAutomatedTrigger',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowAutomatedTrigger',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowAutomatedTrigger',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowAutomatedTrigger',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
type: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowAutomatedTrigger',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'type',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Automated Trigger Type',
|
||||
description: 'The workflow automated trigger type',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: false,
|
||||
options: [
|
||||
{
|
||||
value: 'DATABASE_EVENT',
|
||||
label: 'Database Event',
|
||||
position: 0,
|
||||
color: 'green',
|
||||
},
|
||||
{ value: 'CRON', label: 'Cron', position: 1, color: 'blue' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
settings: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowAutomatedTrigger',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'settings',
|
||||
type: FieldMetadataType.RAW_JSON,
|
||||
label: 'Settings',
|
||||
description: 'The workflow automated trigger settings',
|
||||
icon: 'IconSettings',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflow: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflowAutomatedTrigger',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workflow',
|
||||
label: 'Workflow',
|
||||
description: 'WorkflowAutomatedTrigger workflow',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'workflow',
|
||||
targetFieldName: 'automatedTriggers',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+339
@@ -0,0 +1,339 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildWorkflowRunStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'workflowRun'>, FlatFieldMetadata> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
name: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'name',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Name',
|
||||
description: 'Name of the workflow run',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
enqueuedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'enqueuedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Workflow run enqueued at',
|
||||
description: 'Workflow run enqueued at',
|
||||
icon: 'IconHistory',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
startedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'startedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Workflow run started at',
|
||||
description: 'Workflow run started at',
|
||||
icon: 'IconHistory',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
endedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'endedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Workflow run ended at',
|
||||
description: 'Workflow run ended at',
|
||||
icon: 'IconHistory',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
status: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'status',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Workflow run status',
|
||||
description: 'Workflow run status',
|
||||
icon: 'IconStatusChange',
|
||||
isNullable: false,
|
||||
defaultValue: "'NOT_STARTED'",
|
||||
options: [
|
||||
{
|
||||
value: 'NOT_STARTED',
|
||||
label: 'Not started',
|
||||
position: 0,
|
||||
color: 'gray',
|
||||
},
|
||||
{ value: 'RUNNING', label: 'Running', position: 1, color: 'yellow' },
|
||||
{ value: 'COMPLETED', label: 'Completed', position: 2, color: 'green' },
|
||||
{ value: 'FAILED', label: 'Failed', position: 3, color: 'red' },
|
||||
{ value: 'ENQUEUED', label: 'Enqueued', position: 4, color: 'blue' },
|
||||
{ value: 'STOPPING', label: 'Stopping', position: 5, color: 'orange' },
|
||||
{ value: 'STOPPED', label: 'Stopped', position: 6, color: 'gray' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdBy: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdBy',
|
||||
type: FieldMetadataType.ACTOR,
|
||||
label: 'Executed by',
|
||||
description: 'The executor of the workflow',
|
||||
icon: 'IconCreativeCommonsSa',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
state: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'state',
|
||||
type: FieldMetadataType.RAW_JSON,
|
||||
label: 'State',
|
||||
description: 'State of the workflow run',
|
||||
icon: 'IconHierarchy2',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
context: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'context',
|
||||
type: FieldMetadataType.RAW_JSON,
|
||||
label: 'Context',
|
||||
description: 'Context of the workflow run',
|
||||
icon: 'IconHierarchy2',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
output: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'output',
|
||||
type: FieldMetadataType.RAW_JSON,
|
||||
label: 'Output',
|
||||
description: 'Output of the workflow run',
|
||||
icon: 'IconHierarchy2',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.POSITION,
|
||||
label: 'Position',
|
||||
description: 'Workflow run position',
|
||||
icon: 'IconHierarchy2',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
searchVector: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'searchVector',
|
||||
type: FieldMetadataType.TS_VECTOR,
|
||||
label: 'Search vector',
|
||||
description: 'Field used for full-text search',
|
||||
icon: 'IconUser',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflowVersion: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workflowVersion',
|
||||
label: 'Workflow version',
|
||||
description: 'Workflow version linked to the run.',
|
||||
icon: 'IconVersions',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'workflowVersion',
|
||||
targetFieldName: 'runs',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'workflowVersionId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflow: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workflow',
|
||||
label: 'Workflow',
|
||||
description: 'Workflow linked to the run.',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'workflow',
|
||||
targetFieldName: 'runs',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favorites: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favorites',
|
||||
label: 'Favorites',
|
||||
description: 'Favorites linked to the workflow run',
|
||||
icon: 'IconHeart',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'favorite',
|
||||
targetFieldName: 'workflowRun',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timelineActivities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflowRun',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timelineActivities',
|
||||
label: 'Timeline Activities',
|
||||
description: 'Timeline activities linked to the run',
|
||||
icon: 'IconTimelineEvent',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'workflowRun',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+320
@@ -0,0 +1,320 @@
|
||||
import { FieldMetadataType, RelationType } from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildWorkflowStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<AllStandardObjectFieldName<'workflow'>, FlatFieldMetadata> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
name: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'name',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Name',
|
||||
description: 'The workflow name',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
lastPublishedVersionId: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'lastPublishedVersionId',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Last published Version Id',
|
||||
description: 'The workflow last published version id',
|
||||
icon: 'IconVersions',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
statuses: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'statuses',
|
||||
type: FieldMetadataType.MULTI_SELECT,
|
||||
label: 'Statuses',
|
||||
description: 'The current statuses of the workflow versions',
|
||||
icon: 'IconStatusChange',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
options: [
|
||||
{ value: 'DRAFT', label: 'Draft', position: 0, color: 'yellow' },
|
||||
{ value: 'ACTIVE', label: 'Active', position: 1, color: 'green' },
|
||||
{
|
||||
value: 'DEACTIVATED',
|
||||
label: 'Deactivated',
|
||||
position: 2,
|
||||
color: 'gray',
|
||||
},
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.POSITION,
|
||||
label: 'Position',
|
||||
description: 'Workflow record position',
|
||||
icon: 'IconHierarchy2',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdBy: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdBy',
|
||||
type: FieldMetadataType.ACTOR,
|
||||
label: 'Created by',
|
||||
description: 'The creator of the record',
|
||||
icon: 'IconCreativeCommonsSa',
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
searchVector: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'searchVector',
|
||||
type: FieldMetadataType.TS_VECTOR,
|
||||
label: 'Search vector',
|
||||
description: 'Field used for full-text search',
|
||||
icon: 'IconUser',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
versions: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'versions',
|
||||
label: 'Versions',
|
||||
description: 'Workflow versions linked to the workflow.',
|
||||
icon: 'IconVersions',
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'workflowVersion',
|
||||
targetFieldName: 'workflow',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
runs: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'runs',
|
||||
label: 'Runs',
|
||||
description: 'Workflow runs linked to the workflow.',
|
||||
icon: 'IconRun',
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'workflowRun',
|
||||
targetFieldName: 'workflow',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
eventListeners: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'eventListeners',
|
||||
label: 'Event Listeners',
|
||||
description: 'Workflow event listeners linked to the workflow.',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isSystem: true,
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'workflowAutomatedTrigger',
|
||||
targetFieldName: 'workflow',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
automatedTriggers: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'automatedTriggers',
|
||||
label: 'Automated Triggers',
|
||||
description: 'Workflow automated triggers linked to the workflow.',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isSystem: true,
|
||||
isUIReadOnly: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'workflowAutomatedTrigger',
|
||||
targetFieldName: 'workflow',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favorites: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favorites',
|
||||
label: 'Favorites',
|
||||
description: 'Favorites linked to the workflow',
|
||||
icon: 'IconHeart',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'favorite',
|
||||
targetFieldName: 'workflow',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timelineActivities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timelineActivities',
|
||||
label: 'Timeline Activities',
|
||||
description: 'Timeline activities linked to the workflow',
|
||||
icon: 'IconTimelineEvent',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'workflow',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
attachments: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflow',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'attachments',
|
||||
label: 'Attachments',
|
||||
description: 'Attachments linked to the workflow',
|
||||
icon: 'IconFileUpload',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'attachment',
|
||||
targetFieldName: 'workflow',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildWorkflowVersionStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'workflowVersion'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
name: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'name',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Name',
|
||||
description: 'The workflow version name',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
trigger: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'trigger',
|
||||
type: FieldMetadataType.RAW_JSON,
|
||||
label: 'Version trigger',
|
||||
description: 'Json object to provide trigger',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
steps: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'steps',
|
||||
type: FieldMetadataType.RAW_JSON,
|
||||
label: 'Version steps',
|
||||
description: 'Json object to provide steps',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
status: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'status',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Version status',
|
||||
description: 'The workflow version status',
|
||||
icon: 'IconStatusChange',
|
||||
isNullable: false,
|
||||
defaultValue: "'DRAFT'",
|
||||
options: [
|
||||
{ value: 'DRAFT', label: 'Draft', position: 0, color: 'yellow' },
|
||||
{ value: 'ACTIVE', label: 'Active', position: 1, color: 'green' },
|
||||
{
|
||||
value: 'DEACTIVATED',
|
||||
label: 'Deactivated',
|
||||
position: 2,
|
||||
color: 'orange',
|
||||
},
|
||||
{ value: 'ARCHIVED', label: 'Archived', position: 3, color: 'gray' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.POSITION,
|
||||
label: 'Position',
|
||||
description: 'Workflow version position',
|
||||
icon: 'IconHierarchy2',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
searchVector: createStandardFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'searchVector',
|
||||
type: FieldMetadataType.TS_VECTOR,
|
||||
label: 'Search vector',
|
||||
description: 'Field used for full-text search',
|
||||
icon: 'IconUser',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflow: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'workflow',
|
||||
label: 'Workflow',
|
||||
description: 'WorkflowVersion workflow',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workflow',
|
||||
targetFieldName: 'versions',
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowId',
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
runs: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'runs',
|
||||
label: 'Runs',
|
||||
description: 'Workflow runs linked to the version.',
|
||||
icon: 'IconRun',
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'workflowRun',
|
||||
targetFieldName: 'workflowVersion',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favorites: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favorites',
|
||||
label: 'Favorites',
|
||||
description: 'Favorites linked to the workflow version',
|
||||
icon: 'IconHeart',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'favorite',
|
||||
targetFieldName: 'workflowVersion',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timelineActivities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workflowVersion',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timelineActivities',
|
||||
label: 'Timeline Activities',
|
||||
description: 'Timeline activities linked to the version',
|
||||
icon: 'IconTimelineEvent',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'workflowVersion',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+510
@@ -0,0 +1,510 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
NumberDataType,
|
||||
RelationType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { createStandardFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-relation-field-flat-metadata.util';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const buildWorkspaceMemberStandardFlatFieldMetadatas = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): Record<
|
||||
AllStandardObjectFieldName<'workspaceMember'>,
|
||||
FlatFieldMetadata
|
||||
> => ({
|
||||
id: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'id',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'Id',
|
||||
description: 'Id',
|
||||
icon: 'Icon123',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'uuid',
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
createdAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'createdAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Creation date',
|
||||
description: 'Creation date',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
updatedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'updatedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last update',
|
||||
description: 'Last time the record was changed',
|
||||
icon: 'IconCalendarClock',
|
||||
isNullable: false,
|
||||
isUIReadOnly: true,
|
||||
defaultValue: 'now',
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
deletedAt: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'deletedAt',
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Deleted at',
|
||||
description: 'Date when the record was deleted',
|
||||
icon: 'IconCalendarMinus',
|
||||
isNullable: true,
|
||||
isUIReadOnly: true,
|
||||
settings: { displayFormat: 'RELATIVE' },
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
position: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'position',
|
||||
type: FieldMetadataType.POSITION,
|
||||
label: 'Position',
|
||||
description: 'Workspace member position',
|
||||
icon: 'IconHierarchy2',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 0,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
name: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'name',
|
||||
type: FieldMetadataType.FULL_NAME,
|
||||
label: 'Name',
|
||||
description: 'Workspace member name',
|
||||
icon: 'IconCircleUser',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
colorScheme: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'colorScheme',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Color Scheme',
|
||||
description: 'Preferred color scheme',
|
||||
icon: 'IconColorSwatch',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: "'System'",
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
locale: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'locale',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Language',
|
||||
description: 'Preferred language',
|
||||
icon: 'IconLanguage',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: "'en'",
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
avatarUrl: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'avatarUrl',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Avatar Url',
|
||||
description: 'Workspace member avatar',
|
||||
icon: 'IconFileUpload',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
userEmail: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'userEmail',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'User Email',
|
||||
description: 'Related user email address',
|
||||
icon: 'IconMail',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
isUnique: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarStartDay: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'calendarStartDay',
|
||||
type: FieldMetadataType.NUMBER,
|
||||
label: 'Start of the week',
|
||||
description: "User's preferred start day of the week",
|
||||
icon: 'IconCalendar',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: 7,
|
||||
settings: {
|
||||
dataType: NumberDataType.INT,
|
||||
},
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
userId: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'userId',
|
||||
type: FieldMetadataType.UUID,
|
||||
label: 'User Id',
|
||||
description: 'Associated User Id',
|
||||
icon: 'IconCircleUsers',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timeZone: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timeZone',
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Time zone',
|
||||
description: 'User time zone',
|
||||
icon: 'IconTimezone',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: "'system'",
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
dateFormat: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'dateFormat',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Date format',
|
||||
description: "User's preferred date format",
|
||||
icon: 'IconCalendarEvent',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: "'SYSTEM'",
|
||||
options: [
|
||||
{ value: 'SYSTEM', label: 'System', position: 0, color: 'turquoise' },
|
||||
{
|
||||
value: 'MONTH_FIRST',
|
||||
label: 'Month First',
|
||||
position: 1,
|
||||
color: 'red',
|
||||
},
|
||||
{
|
||||
value: 'DAY_FIRST',
|
||||
label: 'Day First',
|
||||
position: 2,
|
||||
color: 'purple',
|
||||
},
|
||||
{ value: 'YEAR_FIRST', label: 'Year First', position: 3, color: 'sky' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timeFormat: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timeFormat',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Time format',
|
||||
description: "User's preferred time format",
|
||||
icon: 'IconClock2',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: "'SYSTEM'",
|
||||
options: [
|
||||
{ value: 'SYSTEM', label: 'System', position: 0, color: 'sky' },
|
||||
{ value: 'HOUR_24', label: '24HRS', position: 1, color: 'red' },
|
||||
{ value: 'HOUR_12', label: '12HRS', position: 2, color: 'purple' },
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
numberFormat: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'numberFormat',
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Number format',
|
||||
description: "User's preferred number format",
|
||||
icon: 'IconNumbers',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
defaultValue: "'SYSTEM'",
|
||||
options: [
|
||||
{ value: 'SYSTEM', label: 'System', position: 0, color: 'turquoise' },
|
||||
{
|
||||
value: 'COMMAS_AND_DOT',
|
||||
label: 'Commas and dot (1,234.56)',
|
||||
position: 1,
|
||||
color: 'blue',
|
||||
},
|
||||
{
|
||||
value: 'SPACES_AND_COMMA',
|
||||
label: 'Spaces and comma (1 234,56)',
|
||||
position: 2,
|
||||
color: 'green',
|
||||
},
|
||||
{
|
||||
value: 'DOTS_AND_COMMA',
|
||||
label: 'Dots and comma (1.234,56)',
|
||||
position: 3,
|
||||
color: 'orange',
|
||||
},
|
||||
{
|
||||
value: 'APOSTROPHE_AND_DOT',
|
||||
label: "Apostrophe and dot (1'234.56)",
|
||||
position: 4,
|
||||
color: 'purple',
|
||||
},
|
||||
],
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
searchVector: createStandardFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'searchVector',
|
||||
type: FieldMetadataType.TS_VECTOR,
|
||||
label: 'Search vector',
|
||||
description: 'Field used for full-text search',
|
||||
icon: 'IconUser',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
assignedTasks: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'assignedTasks',
|
||||
label: 'Assigned tasks',
|
||||
description: 'Tasks assigned to the workspace member',
|
||||
icon: 'IconCheckbox',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'task',
|
||||
targetFieldName: 'assignee',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favorites: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'favorites',
|
||||
label: 'Favorites',
|
||||
description: 'Favorites linked to the workspace member',
|
||||
icon: 'IconHeart',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'favorite',
|
||||
targetFieldName: 'forWorkspaceMember',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
accountOwnerForCompanies: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'accountOwnerForCompanies',
|
||||
label: 'Account Owner For Companies',
|
||||
description: 'Account owner for companies',
|
||||
icon: 'IconBriefcase',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'company',
|
||||
targetFieldName: 'accountOwner',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
authoredAttachments: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'authoredAttachments',
|
||||
label: 'Authored attachments',
|
||||
description: 'Attachments created by the workspace member',
|
||||
icon: 'IconFileImport',
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'attachment',
|
||||
targetFieldName: 'author',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
connectedAccounts: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'connectedAccounts',
|
||||
label: 'Connected accounts',
|
||||
description: 'Connected accounts',
|
||||
icon: 'IconAt',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'connectedAccount',
|
||||
targetFieldName: 'accountOwner',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageParticipants: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'messageParticipants',
|
||||
label: 'Message Participants',
|
||||
description: 'Message Participants',
|
||||
icon: 'IconUserCircle',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'messageParticipant',
|
||||
targetFieldName: 'workspaceMember',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
blocklist: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'blocklist',
|
||||
label: 'Blocklist',
|
||||
description: 'Blocklisted handles',
|
||||
icon: 'IconForbid2',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'blocklist',
|
||||
targetFieldName: 'workspaceMember',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarEventParticipants: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'calendarEventParticipants',
|
||||
label: 'Calendar Event Participants',
|
||||
description: 'Calendar Event Participants',
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
createdAt,
|
||||
targetObjectName: 'calendarEventParticipant',
|
||||
targetFieldName: 'workspaceMember',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timelineActivities: createStandardRelationFieldFlatMetadata({
|
||||
objectName: 'workspaceMember',
|
||||
workspaceId,
|
||||
options: {
|
||||
fieldName: 'timelineActivities',
|
||||
label: 'Events',
|
||||
description: 'Events linked to the workspace member',
|
||||
icon: 'IconTimelineEvent',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
createdAt,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'workspaceMember',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
},
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
});
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
import {
|
||||
type FieldMetadataComplexOption,
|
||||
type FieldMetadataDefaultOption,
|
||||
type FieldMetadataDefaultValueForAnyType,
|
||||
type FieldMetadataType,
|
||||
} from 'twenty-shared/types';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import { TWENTY_STANDARD_APPLICATION } from 'src/engine/workspace-manager/twenty-standard-application/constants/twenty-standard-applications';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { type AllStandardObjectName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-name.type';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
const TWENTY_STANDARD_APPLICATION_ID =
|
||||
TWENTY_STANDARD_APPLICATION.universalIdentifier;
|
||||
|
||||
export type CreateStandardFieldOptions<O extends AllStandardObjectName> = {
|
||||
fieldName: AllStandardObjectFieldName<O>;
|
||||
type: Exclude<FieldMetadataType, typeof FieldMetadataType.RELATION>;
|
||||
label: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
isSystem?: boolean;
|
||||
isNullable?: boolean;
|
||||
isUnique?: boolean;
|
||||
isUIReadOnly?: boolean;
|
||||
defaultValue?: FieldMetadataDefaultValueForAnyType;
|
||||
settings?: Record<string, unknown> | null;
|
||||
options?: FieldMetadataDefaultOption[] | FieldMetadataComplexOption[] | null;
|
||||
createdAt: Date;
|
||||
};
|
||||
|
||||
export type CreateStandardFieldArgs<O extends AllStandardObjectName> = {
|
||||
objectName: O;
|
||||
workspaceId: string;
|
||||
options: CreateStandardFieldOptions<O>;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
};
|
||||
|
||||
export const createStandardFieldFlatMetadata = <
|
||||
O extends AllStandardObjectName,
|
||||
>({
|
||||
objectName,
|
||||
workspaceId,
|
||||
options,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: CreateStandardFieldArgs<O>): FlatFieldMetadata => {
|
||||
const {
|
||||
fieldName,
|
||||
type,
|
||||
label,
|
||||
description,
|
||||
icon,
|
||||
isSystem = false,
|
||||
isNullable = true,
|
||||
isUnique = false,
|
||||
isUIReadOnly = false,
|
||||
defaultValue = null,
|
||||
settings = null,
|
||||
options: fieldOptions = null,
|
||||
createdAt,
|
||||
} = options;
|
||||
|
||||
const objectFields = STANDARD_OBJECTS[objectName].fields;
|
||||
const fieldDefinition = objectFields[fieldName as keyof typeof objectFields];
|
||||
const fieldIds =
|
||||
standardFieldMetadataIdByObjectAndFieldName[objectName].fields;
|
||||
|
||||
const name = fieldName.toString();
|
||||
|
||||
return {
|
||||
id: fieldIds[fieldName],
|
||||
universalIdentifier: fieldDefinition.universalIdentifier,
|
||||
standardId: null,
|
||||
applicationId: TWENTY_STANDARD_APPLICATION_ID,
|
||||
workspaceId,
|
||||
objectMetadataId:
|
||||
standardFieldMetadataIdByObjectAndFieldName[objectName].id,
|
||||
type,
|
||||
name,
|
||||
label,
|
||||
description,
|
||||
icon,
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
isSystem,
|
||||
isNullable,
|
||||
isUnique,
|
||||
isUIReadOnly,
|
||||
isLabelSyncedWithName: false,
|
||||
standardOverrides: null,
|
||||
defaultValue,
|
||||
settings,
|
||||
options: fieldOptions?.map((option) => ({ ...option, id: v4() })) ?? null,
|
||||
relationTargetFieldMetadataId: null,
|
||||
relationTargetObjectMetadataId: null,
|
||||
morphId: null,
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
mainGroupByFieldMetadataViewIds: [],
|
||||
createdAt,
|
||||
updatedAt: createdAt,
|
||||
};
|
||||
};
|
||||
+616
@@ -0,0 +1,616 @@
|
||||
import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import { type AllStandardObjectName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-name.type';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
import { createStandardObjectFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/create-standard-object-flat-metadata.util';
|
||||
|
||||
export type BuildStandardFlatObjectMetadatasArgs = {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
};
|
||||
|
||||
export type StandardFlatObjectMetadataBuilder = (
|
||||
args: BuildStandardFlatObjectMetadatasArgs,
|
||||
) => FlatObjectMetadata;
|
||||
|
||||
/**
|
||||
* Record mapping each standard object name to its corresponding object metadata builder.
|
||||
* Using `satisfies` ensures type safety: if a new standard object is added to STANDARD_OBJECTS,
|
||||
* TypeScript will error until a builder is added here.
|
||||
*/
|
||||
export const STANDARD_FLAT_OBJECT_METADATA_BUILDERS_BY_OBJECT_NAME = {
|
||||
attachment: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.attachment.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.attachment.universalIdentifier,
|
||||
nameSingular: 'attachment',
|
||||
namePlural: 'attachments',
|
||||
labelSingular: 'Attachment',
|
||||
labelPlural: 'Attachments',
|
||||
description: 'An attachment',
|
||||
icon: 'IconFileImport',
|
||||
isSystem: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'name',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
blocklist: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.blocklist.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.blocklist.universalIdentifier,
|
||||
nameSingular: 'blocklist',
|
||||
namePlural: 'blocklists',
|
||||
labelSingular: 'Blocklist',
|
||||
labelPlural: 'Blocklists',
|
||||
description: 'Blocklist',
|
||||
icon: 'IconForbid2',
|
||||
isSystem: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'handle',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarChannelEventAssociation: (
|
||||
args: BuildStandardFlatObjectMetadatasArgs,
|
||||
) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.calendarChannelEventAssociation.universalIdentifier,
|
||||
standardId:
|
||||
STANDARD_OBJECTS.calendarChannelEventAssociation.universalIdentifier,
|
||||
nameSingular: 'calendarChannelEventAssociation',
|
||||
namePlural: 'calendarChannelEventAssociations',
|
||||
labelSingular: 'Calendar Channel Event Association',
|
||||
labelPlural: 'Calendar Channel Event Associations',
|
||||
description: 'Calendar Channel Event Associations',
|
||||
icon: 'IconCalendar',
|
||||
isSystem: true,
|
||||
isAuditLogged: false,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'id',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarChannel: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.calendarChannel.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.calendarChannel.universalIdentifier,
|
||||
nameSingular: 'calendarChannel',
|
||||
namePlural: 'calendarChannels',
|
||||
labelSingular: 'Calendar Channel',
|
||||
labelPlural: 'Calendar Channels',
|
||||
description: 'Calendar Channels',
|
||||
icon: 'IconCalendar',
|
||||
isSystem: true,
|
||||
isAuditLogged: false,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'handle',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarEventParticipant: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.calendarEventParticipant.universalIdentifier,
|
||||
standardId:
|
||||
STANDARD_OBJECTS.calendarEventParticipant.universalIdentifier,
|
||||
nameSingular: 'calendarEventParticipant',
|
||||
namePlural: 'calendarEventParticipants',
|
||||
labelSingular: 'Calendar event participant',
|
||||
labelPlural: 'Calendar event participants',
|
||||
description: 'Calendar event participants',
|
||||
icon: 'IconCalendar',
|
||||
isSystem: true,
|
||||
isAuditLogged: false,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'handle',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
calendarEvent: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.calendarEvent.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.calendarEvent.universalIdentifier,
|
||||
nameSingular: 'calendarEvent',
|
||||
namePlural: 'calendarEvents',
|
||||
labelSingular: 'Calendar event',
|
||||
labelPlural: 'Calendar events',
|
||||
description: 'Calendar events',
|
||||
icon: 'IconCalendar',
|
||||
isSystem: true,
|
||||
isAuditLogged: false,
|
||||
isUIReadOnly: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'title',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
company: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.company.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.company.universalIdentifier,
|
||||
nameSingular: 'company',
|
||||
namePlural: 'companies',
|
||||
labelSingular: 'Company',
|
||||
labelPlural: 'Companies',
|
||||
description: 'A company',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isSearchable: true,
|
||||
shortcut: 'C',
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'name',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
connectedAccount: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.connectedAccount.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.connectedAccount.universalIdentifier,
|
||||
nameSingular: 'connectedAccount',
|
||||
namePlural: 'connectedAccounts',
|
||||
labelSingular: 'Connected Account',
|
||||
labelPlural: 'Connected Accounts',
|
||||
description: 'A connected account',
|
||||
icon: 'IconAt',
|
||||
isSystem: true,
|
||||
isAuditLogged: false,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'handle',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
dashboard: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.dashboard.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.dashboard.universalIdentifier,
|
||||
nameSingular: 'dashboard',
|
||||
namePlural: 'dashboards',
|
||||
labelSingular: 'Dashboard',
|
||||
labelPlural: 'Dashboards',
|
||||
description: 'A dashboard',
|
||||
icon: 'IconLayoutDashboard',
|
||||
isSearchable: true,
|
||||
shortcut: 'D',
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'title',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favorite: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.favorite.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.favorite.universalIdentifier,
|
||||
nameSingular: 'favorite',
|
||||
namePlural: 'favorites',
|
||||
labelSingular: 'Favorite',
|
||||
labelPlural: 'Favorites',
|
||||
description: 'A favorite',
|
||||
icon: 'IconHeart',
|
||||
isSystem: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'id',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
favoriteFolder: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.favoriteFolder.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.favoriteFolder.universalIdentifier,
|
||||
nameSingular: 'favoriteFolder',
|
||||
namePlural: 'favoriteFolders',
|
||||
labelSingular: 'Favorite Folder',
|
||||
labelPlural: 'Favorite Folders',
|
||||
description: 'A favorite folder',
|
||||
icon: 'IconFolder',
|
||||
isSystem: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'id',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageChannelMessageAssociation: (
|
||||
args: BuildStandardFlatObjectMetadatasArgs,
|
||||
) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.messageChannelMessageAssociation.universalIdentifier,
|
||||
standardId:
|
||||
STANDARD_OBJECTS.messageChannelMessageAssociation.universalIdentifier,
|
||||
nameSingular: 'messageChannelMessageAssociation',
|
||||
namePlural: 'messageChannelMessageAssociations',
|
||||
labelSingular: 'Message Channel Message Association',
|
||||
labelPlural: 'Message Channel Message Associations',
|
||||
description: 'Message Synced with a Message Channel',
|
||||
icon: 'IconMessage',
|
||||
isSystem: true,
|
||||
isAuditLogged: false,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'id',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageChannel: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.messageChannel.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.messageChannel.universalIdentifier,
|
||||
nameSingular: 'messageChannel',
|
||||
namePlural: 'messageChannels',
|
||||
labelSingular: 'Message Channel',
|
||||
labelPlural: 'Message Channels',
|
||||
description: 'Message Channels',
|
||||
icon: 'IconMessage',
|
||||
isSystem: true,
|
||||
isAuditLogged: false,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'handle',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageFolder: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.messageFolder.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.messageFolder.universalIdentifier,
|
||||
nameSingular: 'messageFolder',
|
||||
namePlural: 'messageFolders',
|
||||
labelSingular: 'Message Folder',
|
||||
labelPlural: 'Message Folders',
|
||||
description: 'Message Folders',
|
||||
icon: 'IconFolder',
|
||||
isSystem: true,
|
||||
isAuditLogged: false,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'id',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageParticipant: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.messageParticipant.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.messageParticipant.universalIdentifier,
|
||||
nameSingular: 'messageParticipant',
|
||||
namePlural: 'messageParticipants',
|
||||
labelSingular: 'Message Participant',
|
||||
labelPlural: 'Message Participants',
|
||||
description: 'Message Participants',
|
||||
icon: 'IconUserCircle',
|
||||
isSystem: true,
|
||||
isAuditLogged: false,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'handle',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
messageThread: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.messageThread.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.messageThread.universalIdentifier,
|
||||
nameSingular: 'messageThread',
|
||||
namePlural: 'messageThreads',
|
||||
labelSingular: 'Message Thread',
|
||||
labelPlural: 'Message Threads',
|
||||
description: 'Message Thread',
|
||||
icon: 'IconMessage',
|
||||
isSystem: true,
|
||||
isAuditLogged: false,
|
||||
isUIReadOnly: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'id',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
message: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.message.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.message.universalIdentifier,
|
||||
nameSingular: 'message',
|
||||
namePlural: 'messages',
|
||||
labelSingular: 'Message',
|
||||
labelPlural: 'Messages',
|
||||
description: 'Message',
|
||||
icon: 'IconMessage',
|
||||
isSystem: true,
|
||||
isAuditLogged: false,
|
||||
isUIReadOnly: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'subject',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
note: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.note.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.note.universalIdentifier,
|
||||
nameSingular: 'note',
|
||||
namePlural: 'notes',
|
||||
labelSingular: 'Note',
|
||||
labelPlural: 'Notes',
|
||||
description: 'A note',
|
||||
icon: 'IconNotes',
|
||||
isSearchable: true,
|
||||
shortcut: 'N',
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'title',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
noteTarget: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.noteTarget.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.noteTarget.universalIdentifier,
|
||||
nameSingular: 'noteTarget',
|
||||
namePlural: 'noteTargets',
|
||||
labelSingular: 'Note Target',
|
||||
labelPlural: 'Note Targets',
|
||||
description: 'A note target',
|
||||
icon: 'IconCheckbox',
|
||||
isSystem: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'id',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
opportunity: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.opportunity.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.opportunity.universalIdentifier,
|
||||
nameSingular: 'opportunity',
|
||||
namePlural: 'opportunities',
|
||||
labelSingular: 'Opportunity',
|
||||
labelPlural: 'Opportunities',
|
||||
description: 'An opportunity',
|
||||
icon: 'IconTargetArrow',
|
||||
isSearchable: true,
|
||||
shortcut: 'O',
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'name',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
person: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.person.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.person.universalIdentifier,
|
||||
nameSingular: 'person',
|
||||
namePlural: 'people',
|
||||
labelSingular: 'Person',
|
||||
labelPlural: 'People',
|
||||
description: 'A person',
|
||||
icon: 'IconUser',
|
||||
isSearchable: true,
|
||||
shortcut: 'P',
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'name',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
task: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.task.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.task.universalIdentifier,
|
||||
nameSingular: 'task',
|
||||
namePlural: 'tasks',
|
||||
labelSingular: 'Task',
|
||||
labelPlural: 'Tasks',
|
||||
description: 'A task',
|
||||
icon: 'IconCheckbox',
|
||||
isSearchable: true,
|
||||
shortcut: 'T',
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'title',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
taskTarget: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.taskTarget.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.taskTarget.universalIdentifier,
|
||||
nameSingular: 'taskTarget',
|
||||
namePlural: 'taskTargets',
|
||||
labelSingular: 'Task Target',
|
||||
labelPlural: 'Task Targets',
|
||||
description: 'A task target',
|
||||
icon: 'IconCheckbox',
|
||||
isSystem: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'id',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
timelineActivity: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.timelineActivity.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.timelineActivity.universalIdentifier,
|
||||
nameSingular: 'timelineActivity',
|
||||
namePlural: 'timelineActivities',
|
||||
labelSingular: 'Timeline Activity',
|
||||
labelPlural: 'Timeline Activities',
|
||||
description:
|
||||
'Aggregated / filtered event to be displayed on the timeline',
|
||||
icon: 'IconTimelineEvent',
|
||||
isSystem: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'name',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflow: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.workflow.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.workflow.universalIdentifier,
|
||||
nameSingular: 'workflow',
|
||||
namePlural: 'workflows',
|
||||
labelSingular: 'Workflow',
|
||||
labelPlural: 'Workflows',
|
||||
description: 'A workflow',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isSearchable: true,
|
||||
shortcut: 'W',
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'name',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflowAutomatedTrigger: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.workflowAutomatedTrigger.universalIdentifier,
|
||||
standardId:
|
||||
STANDARD_OBJECTS.workflowAutomatedTrigger.universalIdentifier,
|
||||
nameSingular: 'workflowAutomatedTrigger',
|
||||
namePlural: 'workflowAutomatedTriggers',
|
||||
labelSingular: 'Workflow Automated Trigger',
|
||||
labelPlural: 'Workflow Automated Triggers',
|
||||
description: 'A workflow automated trigger',
|
||||
icon: 'IconSettingsAutomation',
|
||||
isSystem: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'id',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflowRun: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier: STANDARD_OBJECTS.workflowRun.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.workflowRun.universalIdentifier,
|
||||
nameSingular: 'workflowRun',
|
||||
namePlural: 'workflowRuns',
|
||||
labelSingular: 'Workflow Run',
|
||||
labelPlural: 'Workflow Runs',
|
||||
description: 'A workflow run',
|
||||
icon: 'IconHistoryToggle',
|
||||
isSearchable: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'name',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workflowVersion: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.workflowVersion.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.workflowVersion.universalIdentifier,
|
||||
nameSingular: 'workflowVersion',
|
||||
namePlural: 'workflowVersions',
|
||||
labelSingular: 'Workflow Version',
|
||||
labelPlural: 'Workflow Versions',
|
||||
description: 'A workflow version',
|
||||
icon: 'IconVersions',
|
||||
isSearchable: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'name',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
workspaceMember: (args: BuildStandardFlatObjectMetadatasArgs) =>
|
||||
createStandardObjectFlatMetadata({
|
||||
options: {
|
||||
universalIdentifier:
|
||||
STANDARD_OBJECTS.workspaceMember.universalIdentifier,
|
||||
standardId: STANDARD_OBJECTS.workspaceMember.universalIdentifier,
|
||||
nameSingular: 'workspaceMember',
|
||||
namePlural: 'workspaceMembers',
|
||||
labelSingular: 'Workspace Member',
|
||||
labelPlural: 'Workspace Members',
|
||||
description: 'A workspace member',
|
||||
icon: 'IconUserCircle',
|
||||
isSystem: true,
|
||||
createdAt: args.createdAt,
|
||||
labelIdentifierFieldMetadataName: 'name',
|
||||
},
|
||||
workspaceId: args.workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName:
|
||||
args.standardFieldMetadataIdByObjectAndFieldName,
|
||||
}),
|
||||
} satisfies Record<AllStandardObjectName, StandardFlatObjectMetadataBuilder>;
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
|
||||
import { TWENTY_STANDARD_APPLICATION } from 'src/engine/workspace-manager/twenty-standard-application/constants/twenty-standard-applications';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { type AllStandardObjectName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-name.type';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
const TWENTY_STANDARD_APPLICATION_ID =
|
||||
TWENTY_STANDARD_APPLICATION.universalIdentifier;
|
||||
|
||||
export const createStandardObjectFlatMetadata = <
|
||||
T extends AllStandardObjectName,
|
||||
>({
|
||||
options: {
|
||||
universalIdentifier,
|
||||
standardId,
|
||||
nameSingular,
|
||||
namePlural,
|
||||
labelSingular,
|
||||
labelPlural,
|
||||
description,
|
||||
icon,
|
||||
isSystem = false,
|
||||
isSearchable = false,
|
||||
isAuditLogged = true,
|
||||
isUIReadOnly = false,
|
||||
shortcut = null,
|
||||
createdAt,
|
||||
labelIdentifierFieldMetadataName,
|
||||
},
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: {
|
||||
options: {
|
||||
universalIdentifier: string;
|
||||
standardId: string;
|
||||
nameSingular: T;
|
||||
namePlural: string;
|
||||
labelSingular: string;
|
||||
labelPlural: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
isSystem?: boolean;
|
||||
isSearchable?: boolean;
|
||||
isAuditLogged?: boolean;
|
||||
isUIReadOnly?: boolean;
|
||||
shortcut?: string | null;
|
||||
createdAt: Date;
|
||||
labelIdentifierFieldMetadataName: AllStandardObjectFieldName<T>;
|
||||
};
|
||||
workspaceId: string;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
}): FlatObjectMetadata => ({
|
||||
universalIdentifier,
|
||||
standardId,
|
||||
applicationId: TWENTY_STANDARD_APPLICATION_ID,
|
||||
workspaceId,
|
||||
nameSingular,
|
||||
namePlural,
|
||||
labelSingular,
|
||||
labelPlural,
|
||||
description,
|
||||
icon,
|
||||
isCustom: false,
|
||||
isRemote: false,
|
||||
isActive: true,
|
||||
isSystem,
|
||||
isSearchable,
|
||||
isAuditLogged,
|
||||
isUIReadOnly,
|
||||
isLabelSyncedWithName: false,
|
||||
standardOverrides: null,
|
||||
duplicateCriteria: null,
|
||||
shortcut,
|
||||
labelIdentifierFieldMetadataId:
|
||||
standardFieldMetadataIdByObjectAndFieldName[nameSingular].fields[
|
||||
labelIdentifierFieldMetadataName
|
||||
],
|
||||
imageIdentifierFieldMetadataId: null,
|
||||
targetTableName: 'DEPRECATED',
|
||||
fieldMetadataIds: [],
|
||||
indexMetadataIds: [],
|
||||
viewIds: [],
|
||||
createdAt,
|
||||
updatedAt: createdAt,
|
||||
id: standardFieldMetadataIdByObjectAndFieldName[nameSingular].id,
|
||||
});
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
import {
|
||||
type FieldMetadataComplexOption,
|
||||
type FieldMetadataDefaultOption,
|
||||
type FieldMetadataDefaultValueForAnyType,
|
||||
type FieldMetadataSettings,
|
||||
FieldMetadataType,
|
||||
} from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import { TWENTY_STANDARD_APPLICATION } from 'src/engine/workspace-manager/twenty-standard-application/constants/twenty-standard-applications';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { type AllStandardObjectName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-name.type';
|
||||
import { type StandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
const TWENTY_STANDARD_APPLICATION_ID =
|
||||
TWENTY_STANDARD_APPLICATION.universalIdentifier;
|
||||
|
||||
export type CreateStandardRelationFieldOptions<
|
||||
O extends AllStandardObjectName,
|
||||
T extends AllStandardObjectName,
|
||||
> = {
|
||||
fieldName: AllStandardObjectFieldName<O>;
|
||||
label: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
targetObjectName: T;
|
||||
targetFieldName: AllStandardObjectFieldName<T>;
|
||||
isSystem?: boolean;
|
||||
isNullable?: boolean;
|
||||
isUIReadOnly?: boolean;
|
||||
defaultValue?: FieldMetadataDefaultValueForAnyType;
|
||||
settings: FieldMetadataSettings<FieldMetadataType.RELATION>;
|
||||
options?: FieldMetadataDefaultOption[] | FieldMetadataComplexOption[] | null;
|
||||
createdAt: Date;
|
||||
};
|
||||
|
||||
export type CreateStandardRelationFieldArgs<
|
||||
O extends AllStandardObjectName,
|
||||
T extends AllStandardObjectName,
|
||||
> = {
|
||||
objectName: O;
|
||||
workspaceId: string;
|
||||
options: CreateStandardRelationFieldOptions<O, T>;
|
||||
standardFieldMetadataIdByObjectAndFieldName: StandardFieldMetadataIdByObjectAndFieldName;
|
||||
};
|
||||
|
||||
export const createStandardRelationFieldFlatMetadata = <
|
||||
O extends AllStandardObjectName,
|
||||
T extends AllStandardObjectName,
|
||||
>({
|
||||
objectName,
|
||||
workspaceId,
|
||||
options,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
}: CreateStandardRelationFieldArgs<O, T>): FlatFieldMetadata => {
|
||||
const {
|
||||
fieldName,
|
||||
label,
|
||||
description,
|
||||
icon,
|
||||
targetObjectName,
|
||||
targetFieldName,
|
||||
isSystem = false,
|
||||
isNullable = true,
|
||||
isUIReadOnly = false,
|
||||
defaultValue = null,
|
||||
settings,
|
||||
options: fieldOptions = null,
|
||||
createdAt,
|
||||
} = options;
|
||||
|
||||
const objectFields = STANDARD_OBJECTS[objectName].fields;
|
||||
const fieldDefinition = objectFields[fieldName as keyof typeof objectFields];
|
||||
const fieldIds =
|
||||
standardFieldMetadataIdByObjectAndFieldName[objectName].fields;
|
||||
|
||||
const targetFieldIds =
|
||||
standardFieldMetadataIdByObjectAndFieldName[targetObjectName].fields;
|
||||
|
||||
return {
|
||||
id: fieldIds[fieldName as keyof typeof fieldIds],
|
||||
universalIdentifier: fieldDefinition.universalIdentifier,
|
||||
standardId: null,
|
||||
applicationId: TWENTY_STANDARD_APPLICATION_ID,
|
||||
workspaceId,
|
||||
objectMetadataId:
|
||||
standardFieldMetadataIdByObjectAndFieldName[objectName].id,
|
||||
type: FieldMetadataType.RELATION,
|
||||
name: fieldName.toString(),
|
||||
label,
|
||||
description,
|
||||
icon,
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
isSystem,
|
||||
isNullable,
|
||||
isUnique: false,
|
||||
isUIReadOnly,
|
||||
isLabelSyncedWithName: false,
|
||||
standardOverrides: null,
|
||||
defaultValue,
|
||||
settings,
|
||||
options: fieldOptions,
|
||||
relationTargetFieldMetadataId: targetFieldIds[targetFieldName],
|
||||
relationTargetObjectMetadataId:
|
||||
standardFieldMetadataIdByObjectAndFieldName[targetObjectName].id,
|
||||
morphId: null,
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
mainGroupByFieldMetadataViewIds: [],
|
||||
createdAt,
|
||||
updatedAt: createdAt,
|
||||
};
|
||||
};
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { type AllStandardObjectName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-name.type';
|
||||
|
||||
export type StandardFieldMetadataIdByObjectAndFieldName = {
|
||||
[O in AllStandardObjectName]: {
|
||||
id: string;
|
||||
fields: Record<AllStandardObjectFieldName<O>, string>;
|
||||
};
|
||||
};
|
||||
|
||||
// TODO remove once we have refactored the builder to iterate over universalIdentifier only
|
||||
export const getStandardFieldMetadataIdByObjectAndFieldName =
|
||||
(): StandardFieldMetadataIdByObjectAndFieldName => {
|
||||
const result = {} as StandardFieldMetadataIdByObjectAndFieldName;
|
||||
|
||||
for (const objectName of Object.keys(
|
||||
STANDARD_OBJECTS,
|
||||
) as AllStandardObjectName[]) {
|
||||
const fieldNames = Object.keys(
|
||||
STANDARD_OBJECTS[objectName].fields,
|
||||
) as AllStandardObjectFieldName<typeof objectName>[];
|
||||
|
||||
const fieldIds = {} as Record<
|
||||
AllStandardObjectFieldName<typeof objectName>,
|
||||
string
|
||||
>;
|
||||
|
||||
for (const fieldName of fieldNames) {
|
||||
fieldIds[fieldName] = v4();
|
||||
}
|
||||
|
||||
result[objectName] = {
|
||||
// @ts-expect-error ignore this
|
||||
fields: fieldIds,
|
||||
id: v4(),
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
import { type AllFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/all-flat-entity-maps.type';
|
||||
import { buildStandardFlatFieldMetadataMaps } from 'src/engine/workspace-manager/twenty-standard-application/utils/build-standard-flat-field-metadata-maps.util';
|
||||
import { buildStandardFlatObjectMetadataMaps } from 'src/engine/workspace-manager/twenty-standard-application/utils/build-standard-flat-object-metadata-maps.util';
|
||||
import { getStandardFieldMetadataIdByObjectAndFieldName } from 'src/engine/workspace-manager/twenty-standard-application/utils/get-standard-field-metadata-id-by-object-and-field-name.util';
|
||||
|
||||
export const computeTwentyStandardApplicationAllFlatEntityMaps = ({
|
||||
createdAt,
|
||||
workspaceId,
|
||||
}: {
|
||||
createdAt: Date;
|
||||
workspaceId: string;
|
||||
}): AllFlatEntityMaps => {
|
||||
const standardFieldMetadataIdByObjectAndFieldName =
|
||||
getStandardFieldMetadataIdByObjectAndFieldName();
|
||||
|
||||
const builderArgs = {
|
||||
createdAt,
|
||||
workspaceId,
|
||||
standardFieldMetadataIdByObjectAndFieldName,
|
||||
};
|
||||
|
||||
// Build object metadata maps using addFlatEntityToFlatEntityMapsOrThrow to prevent duplicate IDs
|
||||
const flatObjectMetadataMaps =
|
||||
buildStandardFlatObjectMetadataMaps(builderArgs);
|
||||
|
||||
// Build field metadata maps using addFlatEntityToFlatEntityMapsOrThrow to prevent duplicate IDs
|
||||
const flatFieldMetadataMaps = buildStandardFlatFieldMetadataMaps(builderArgs);
|
||||
|
||||
return {
|
||||
flatAgentMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
flatCronTriggerMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
flatDatabaseEventTriggerMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
flatFieldMetadataMaps,
|
||||
flatIndexMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
flatObjectMetadataMaps,
|
||||
flatRoleMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
flatRoleTargetMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
flatRouteTriggerMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
flatServerlessFunctionMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
flatViewFieldMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
flatViewFilterMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
flatViewGroupMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
flatViewMaps: {
|
||||
byId: {},
|
||||
idByUniversalIdentifier: {},
|
||||
universalIdentifiersByApplicationId: {},
|
||||
},
|
||||
};
|
||||
};
|
||||
+10
-2
@@ -131,11 +131,15 @@ export class FlatFieldMetadataValidatorService {
|
||||
|
||||
if (updates.some((update) => update.property === 'name')) {
|
||||
validationResult.errors.push(
|
||||
...validateFlatFieldMetadataName(flatFieldMetadataToValidate.name),
|
||||
...validateFlatFieldMetadataName({
|
||||
name: flatFieldMetadataToValidate.name,
|
||||
buildOptions,
|
||||
}),
|
||||
...validateFlatFieldMetadataNameAvailability({
|
||||
name: flatFieldMetadataToValidate.name,
|
||||
flatFieldMetadataMaps: optimisticFlatFieldMetadataMaps,
|
||||
flatObjectMetadata,
|
||||
buildOptions,
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -307,6 +311,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
name: flatFieldMetadataToValidate.name,
|
||||
flatFieldMetadataMaps: optimisticFlatFieldMetadataMaps,
|
||||
flatObjectMetadata: parentFlatObjectMetadata,
|
||||
buildOptions,
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -324,7 +329,10 @@ export class FlatFieldMetadataValidatorService {
|
||||
}
|
||||
|
||||
validationResult.errors.push(
|
||||
...validateFlatFieldMetadataName(flatFieldMetadataToValidate.name),
|
||||
...validateFlatFieldMetadataName({
|
||||
name: flatFieldMetadataToValidate.name,
|
||||
buildOptions,
|
||||
}),
|
||||
);
|
||||
|
||||
validationResult.errors.push(
|
||||
|
||||
+4
@@ -19,6 +19,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
public validateFlatObjectMetadataUpdate({
|
||||
flatEntityId,
|
||||
flatEntityUpdates,
|
||||
buildOptions,
|
||||
optimisticFlatEntityMapsAndRelatedFlatEntityMaps: {
|
||||
flatObjectMetadataMaps: optimisticFlatObjectMetadataMaps,
|
||||
flatFieldMetadataMaps,
|
||||
@@ -85,6 +86,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
...validateFlatObjectMetadataIdentifiers({
|
||||
flatObjectMetadata: updatedFlatObjectMetadata,
|
||||
flatFieldMetadataMaps,
|
||||
buildOptions,
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -154,6 +156,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
flatObjectMetadataMaps: optimisticFlatObjectMetadataMaps,
|
||||
flatFieldMetadataMaps,
|
||||
},
|
||||
buildOptions,
|
||||
}: FlatEntityValidationArgs<
|
||||
typeof ALL_METADATA_NAME.objectMetadata
|
||||
>): FailedFlatEntityValidation<FlatObjectMetadata> {
|
||||
@@ -192,6 +195,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
...validateFlatObjectMetadataIdentifiers({
|
||||
flatObjectMetadata: flatObjectMetadataToValidate,
|
||||
flatFieldMetadataMaps,
|
||||
buildOptions,
|
||||
}),
|
||||
);
|
||||
objectValidationResult.errors.push(
|
||||
|
||||
Reference in New Issue
Block a user