Skip to content

The open alternative to Salesforce, designed for AI.

Add Fathom recording import data model (#25540)

nitin22e2b1736b42
diff --git a/packages/twenty-apps/public/fathom/src/constants/universal-identifiers.ts b/packages/twenty-apps/public/fathom/src/constants/universal-identifiers.ts
index 200ea69d16a..e8ac678c4f5 100644
--- a/packages/twenty-apps/public/fathom/src/constants/universal-identifiers.ts
+++ b/packages/twenty-apps/public/fathom/src/constants/universal-identifiers.ts
@@ -27,3 +27,25 @@ export const FATHOM_SYNC_CALL_UNIVERSAL_IDENTIFIER =
'606e8b64-d659-4e45-a292-0cafb08c06ed';
export const FATHOM_LIST_CALLS_BY_PARTICIPANT_UNIVERSAL_IDENTIFIER =
'24e37c59-c458-4cf9-9021-e16f904d62c1';
+export const FATHOM_RECORDING_IMPORT_OBJECT_UNIVERSAL_IDENTIFIER =
+ '2be3fff9-38fb-4851-a5fe-ca0bdfd49c5e';
+export const FATHOM_RECORDING_ID_FIELD_UNIVERSAL_IDENTIFIER =
+ 'dfca5bef-bc80-4b6b-b4b7-5b5ad4609fcd';
+export const FATHOM_RECORDING_IMPORT_CONNECTED_ACCOUNT_ID_FIELD_UNIVERSAL_IDENTIFIER =
+ '10b3209f-7116-4e0d-8924-e81ec12ee90d';
+export const FATHOM_RECORDING_IMPORT_MEDIA_FAILURE_REASON_FIELD_UNIVERSAL_IDENTIFIER =
+ 'fad1dd4f-a1c2-4f2a-a4eb-90e4b77e91a1';
+export const FATHOM_RECORDING_IMPORT_MEDIA_DOWNLOAD_ID_FIELD_UNIVERSAL_IDENTIFIER =
+ '78184f31-9c3a-4d10-919a-6095d18dda7f';
+export const FATHOM_RECORDING_IMPORT_MEDIA_CLAIMED_AT_FIELD_UNIVERSAL_IDENTIFIER =
+ '2fa9cf0b-5989-430d-a64a-2c5d2da5d694';
+export const FATHOM_RECORDING_IMPORT_MEDIA_UPLOAD_CHECKPOINT_FIELD_UNIVERSAL_IDENTIFIER =
+ '6c904f5d-3fd5-4b86-a4d6-4ebda3db0df8';
+export const CALL_RECORDING_ON_FATHOM_RECORDING_IMPORT_FIELD_UNIVERSAL_IDENTIFIER =
+ '150d51e7-04a6-45fe-a4bc-eb9173249891';
+export const FATHOM_RECORDING_IMPORTS_ON_CALL_RECORDING_FIELD_UNIVERSAL_IDENTIFIER =
+ '55f3d725-2b40-4f99-80f5-25d73916aeed';
+export const FATHOM_RECORDING_IMPORT_CALL_RECORDING_INDEX_UNIVERSAL_IDENTIFIER =
+ 'f0c4e74a-a426-46f8-a76d-a78e00202f8a';
+export const FATHOM_RECORDING_IMPORT_CALL_RECORDING_INDEX_FIELD_UNIVERSAL_IDENTIFIER =
+ '130da502-a1ff-4add-818f-8b272978d01c';
diff --git a/packages/twenty-apps/public/fathom/src/default-role.ts b/packages/twenty-apps/public/fathom/src/default-role.ts
index 73ee4df3900..351396688af 100644
--- a/packages/twenty-apps/public/fathom/src/default-role.ts
+++ b/packages/twenty-apps/public/fathom/src/default-role.ts
@@ -6,13 +6,14 @@ import {
import {
APP_DISPLAY_NAME,
DEFAULT_ROLE_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORT_OBJECT_UNIVERSAL_IDENTIFIER,
} from 'src/constants/universal-identifiers';
export default defineApplicationRole({
universalIdentifier: DEFAULT_ROLE_UNIVERSAL_IDENTIFIER,
label: `${APP_DISPLAY_NAME} default role`,
description:
- 'Reads calendar events to match Fathom meetings and writes transcripts, summaries, action items, and metadata to CallRecording records.',
+ 'Reads calendar events, manages Fathom recording imports, and writes canonical recording data to CallRecording records.',
canReadAllObjectRecords: false,
canUpdateAllObjectRecords: false,
canSoftDeleteAllObjectRecords: false,
@@ -47,6 +48,14 @@ export default defineApplicationRole({
canSoftDeleteObjectRecords: false,
canDestroyObjectRecords: false,
},
+ {
+ objectUniversalIdentifier:
+ FATHOM_RECORDING_IMPORT_OBJECT_UNIVERSAL_IDENTIFIER,
+ canReadObjectRecords: true,
+ canUpdateObjectRecords: true,
+ canSoftDeleteObjectRecords: false,
+ canDestroyObjectRecords: true,
+ },
],
fieldPermissions: [],
permissionFlagUniversalIdentifiers: [],
diff --git a/packages/twenty-apps/public/fathom/src/fields/fathom-recording-imports-on-call-recording.field.ts b/packages/twenty-apps/public/fathom/src/fields/fathom-recording-imports-on-call-recording.field.ts
new file mode 100644
index 00000000000..0f2cc57ee7f
--- /dev/null
+++ b/packages/twenty-apps/public/fathom/src/fields/fathom-recording-imports-on-call-recording.field.ts
@@ -0,0 +1,33 @@
+import {
+ defineField,
+ FieldType,
+ RelationType,
+ STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS,
+} from 'twenty-sdk/define';
+
+import {
+ CALL_RECORDING_ON_FATHOM_RECORDING_IMPORT_FIELD_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORT_OBJECT_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORTS_ON_CALL_RECORDING_FIELD_UNIVERSAL_IDENTIFIER,
+} from 'src/constants/universal-identifiers';
+
+export default defineField({
+ universalIdentifier:
+ FATHOM_RECORDING_IMPORTS_ON_CALL_RECORDING_FIELD_UNIVERSAL_IDENTIFIER,
+ objectUniversalIdentifier:
+ STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.callRecording.universalIdentifier,
+ type: FieldType.RELATION,
+ name: 'fathomRecordingImports',
+ label: 'Fathom Recording Imports',
+ description: 'Internal Fathom import state associated with this recording.',
+ icon: 'IconDownload',
+ isNullable: true,
+ isUIEditable: false,
+ relationTargetObjectMetadataUniversalIdentifier:
+ FATHOM_RECORDING_IMPORT_OBJECT_UNIVERSAL_IDENTIFIER,
+ relationTargetFieldMetadataUniversalIdentifier:
+ CALL_RECORDING_ON_FATHOM_RECORDING_IMPORT_FIELD_UNIVERSAL_IDENTIFIER,
+ universalSettings: {
+ relationType: RelationType.ONE_TO_MANY,
+ },
+});
diff --git a/packages/twenty-apps/public/fathom/src/indexes/fathom-recording-import-call-recording.index.ts b/packages/twenty-apps/public/fathom/src/indexes/fathom-recording-import-call-recording.index.ts
new file mode 100644
index 00000000000..3b7a01d5e07
--- /dev/null
+++ b/packages/twenty-apps/public/fathom/src/indexes/fathom-recording-import-call-recording.index.ts
@@ -0,0 +1,23 @@
+import { defineIndex } from 'twenty-sdk/define';
+
+import {
+ CALL_RECORDING_ON_FATHOM_RECORDING_IMPORT_FIELD_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORT_CALL_RECORDING_INDEX_FIELD_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORT_CALL_RECORDING_INDEX_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORT_OBJECT_UNIVERSAL_IDENTIFIER,
+} from 'src/constants/universal-identifiers';
+
+export default defineIndex({
+ universalIdentifier:
+ FATHOM_RECORDING_IMPORT_CALL_RECORDING_INDEX_UNIVERSAL_IDENTIFIER,
+ objectUniversalIdentifier: FATHOM_RECORDING_IMPORT_OBJECT_UNIVERSAL_IDENTIFIER,
+ isUnique: true,
+ fields: [
+ {
+ universalIdentifier:
+ FATHOM_RECORDING_IMPORT_CALL_RECORDING_INDEX_FIELD_UNIVERSAL_IDENTIFIER,
+ fieldUniversalIdentifier:
+ CALL_RECORDING_ON_FATHOM_RECORDING_IMPORT_FIELD_UNIVERSAL_IDENTIFIER,
+ },
+ ],
+});
diff --git a/packages/twenty-apps/public/fathom/src/logic-functions/types/fathom-recording-import-fields.type.ts b/packages/twenty-apps/public/fathom/src/logic-functions/types/fathom-recording-import-fields.type.ts
new file mode 100644
index 00000000000..f49a82ac9f9
--- /dev/null
+++ b/packages/twenty-apps/public/fathom/src/logic-functions/types/fathom-recording-import-fields.type.ts
@@ -0,0 +1,9 @@
+export type FathomRecordingImportFields = {
+ callRecordingId?: string;
+ recordingId?: string;
+ connectedAccountId?: string;
+ mediaDownloadId?: string | null;
+ mediaFailureReason?: string | null;
+ mediaImportClaimedAt?: string | null;
+ mediaUploadCheckpoint?: unknown | null;
+};
diff --git a/packages/twenty-apps/public/fathom/src/logic-functions/utils/upsert-fathom-recording-import.util.ts b/packages/twenty-apps/public/fathom/src/logic-functions/utils/upsert-fathom-recording-import.util.ts
new file mode 100644
index 00000000000..0cc9c66b917
--- /dev/null
+++ b/packages/twenty-apps/public/fathom/src/logic-functions/utils/upsert-fathom-recording-import.util.ts
@@ -0,0 +1,71 @@
+import { type CoreApiClient } from 'twenty-client-sdk/core';
+
+import { type FathomRecordingImportFields } from 'src/logic-functions/types/fathom-recording-import-fields.type';
+import { isDefined } from 'src/utils/is-defined';
+
+export const upsertFathomRecordingImport = async ({
+ coreApiClient,
+ fathomRecordingImportId,
+ fields,
+ expectedUpdatedAt,
+}: {
+ coreApiClient: Pick<CoreApiClient, 'query' | 'mutation'>;
+ fathomRecordingImportId: string;
+ fields: FathomRecordingImportFields & { recordingId: string };
+ expectedUpdatedAt: string | undefined;
+}): Promise<void> => {
+ if (!isDefined(expectedUpdatedAt)) {
+ try {
+ await coreApiClient.mutation({
+ createFathomRecordingImport: {
+ __args: {
+ data: { id: fathomRecordingImportId, ...fields },
+ },
+ id: true,
+ },
+ });
+
+ return;
+ } catch (error) {
+ const result = await coreApiClient.query({
+ fathomRecordingImports: {
+ __args: {
+ filter: { id: { eq: fathomRecordingImportId } },
+ first: 1,
+ },
+ edges: { node: { updatedAt: true } },
+ },
+ });
+ const currentUpdatedAt =
+ result.fathomRecordingImports?.edges[0]?.node?.updatedAt;
+
+ if (!isDefined(currentUpdatedAt)) {
+ throw error;
+ }
+
+ return upsertFathomRecordingImport({
+ coreApiClient,
+ fathomRecordingImportId,
+ fields,
+ expectedUpdatedAt: currentUpdatedAt,
+ });
+ }
+ }
+
+ const result = await coreApiClient.mutation({
+ updateFathomRecordingImports: {
+ __args: {
+ filter: {
+ id: { eq: fathomRecordingImportId },
+ updatedAt: { eq: expectedUpdatedAt },
+ },
+ data: fields,
+ },
+ id: true,
+ },
+ });
+
+ if ((result.updateFathomRecordingImports ?? []).length === 0) {
+ throw new Error('Fathom recording changed during import; retry the import');
+ }
+};
diff --git a/packages/twenty-apps/public/fathom/src/objects/fathom-recording-import.object.ts b/packages/twenty-apps/public/fathom/src/objects/fathom-recording-import.object.ts
new file mode 100644
index 00000000000..b0cb42681f9
--- /dev/null
+++ b/packages/twenty-apps/public/fathom/src/objects/fathom-recording-import.object.ts
@@ -0,0 +1,120 @@
+import {
+ defineObject,
+ FieldType,
+ MetadataWritability,
+ OnDeleteAction,
+ RelationType,
+ STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS,
+} from 'twenty-sdk/define';
+
+import {
+ CALL_RECORDING_ON_FATHOM_RECORDING_IMPORT_FIELD_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_ID_FIELD_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORT_CONNECTED_ACCOUNT_ID_FIELD_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORT_MEDIA_CLAIMED_AT_FIELD_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORT_MEDIA_DOWNLOAD_ID_FIELD_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORT_MEDIA_FAILURE_REASON_FIELD_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORT_MEDIA_UPLOAD_CHECKPOINT_FIELD_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORT_OBJECT_UNIVERSAL_IDENTIFIER,
+ FATHOM_RECORDING_IMPORTS_ON_CALL_RECORDING_FIELD_UNIVERSAL_IDENTIFIER,
+} from 'src/constants/universal-identifiers';
+
+export default defineObject({
+ universalIdentifier: FATHOM_RECORDING_IMPORT_OBJECT_UNIVERSAL_IDENTIFIER,
+ nameSingular: 'fathomRecordingImport',
+ namePlural: 'fathomRecordingImports',
+ labelSingular: 'Fathom Recording Import',
+ labelPlural: 'Fathom Recording Imports',
+ description:
+ 'Internal state for importing one Fathom recording into a call recording.',
+ icon: 'IconDownload',
+ writability: MetadataWritability.APPLICATION,
+ isUICreatable: false,
+ isUIEditable: false,
+ isSearchable: false,
+ labelIdentifierFieldMetadataUniversalIdentifier:
+ FATHOM_RECORDING_ID_FIELD_UNIVERSAL_IDENTIFIER,
+ fields: [
+ {
+ universalIdentifier: FATHOM_RECORDING_ID_FIELD_UNIVERSAL_IDENTIFIER,
+ type: FieldType.TEXT,
+ name: 'recordingId',
+ label: 'Fathom Recording ID',
+ description: 'Recording identifier assigned by Fathom.',
+ icon: 'IconHash',
+ isUnique: true,
+ },
+ {
+ universalIdentifier:
+ FATHOM_RECORDING_IMPORT_CONNECTED_ACCOUNT_ID_FIELD_UNIVERSAL_IDENTIFIER,
+ type: FieldType.TEXT,
+ name: 'connectedAccountId',
+ label: 'Connected Account ID',
+ description:
+ 'Connected account that owns the private Fathom download.',
+ icon: 'IconLink',
+ isNullable: true,
+ },
+ {
+ universalIdentifier:
+ FATHOM_RECORDING_IMPORT_MEDIA_DOWNLOAD_ID_FIELD_UNIVERSAL_IDENTIFIER,
+ type: FieldType.TEXT,
+ name: 'mediaDownloadId',
+ label: 'Media Download ID',
+ description: 'Active asynchronous Fathom media download.',
+ icon: 'IconDownload',
+ isNullable: true,
+ },
+ {
+ universalIdentifier:
+ FATHOM_RECORDING_IMPORT_MEDIA_FAILURE_REASON_FIELD_UNIVERSAL_IDENTIFIER,
+ type: FieldType.TEXT,
+ name: 'mediaFailureReason',
+ label: 'Media Failure Reason',
+ description: 'Why Fathom could not supply video or audio.',
+ icon: 'IconAlertTriangle',
+ isNullable: true,
+ },
+ {
+ universalIdentifier:
+ FATHOM_RECORDING_IMPORT_MEDIA_CLAIMED_AT_FIELD_UNIVERSAL_IDENTIFIER,
+ type: FieldType.DATE_TIME,
+ name: 'mediaImportClaimedAt',
+ label: 'Media Import Claimed At',
+ description:
+ 'Expiring lease held by the worker importing Fathom media.',
+ icon: 'IconLock',
+ isNullable: true,
+ },
+ {
+ universalIdentifier:
+ FATHOM_RECORDING_IMPORT_MEDIA_UPLOAD_CHECKPOINT_FIELD_UNIVERSAL_IDENTIFIER,
+ type: FieldType.RAW_JSON,
+ name: 'mediaUploadCheckpoint',
+ label: 'Media Upload Checkpoint',
+ description: 'Completed upload awaiting attachment to the call recording.',
+ icon: 'IconUpload',
+ isNullable: true,
+ },
+ {
+ universalIdentifier:
+ CALL_RECORDING_ON_FATHOM_RECORDING_IMPORT_FIELD_UNIVERSAL_IDENTIFIER,
+ type: FieldType.RELATION,
+ name: 'callRecording',
+ label: 'Call Recording',
+ description: 'Call recording produced by this Fathom import.',
+ icon: 'IconMicrophone',
+ isNullable: true,
+ relationTargetObjectMetadataUniversalIdentifier:
+ STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.callRecording
+ .universalIdentifier,
+ relationTargetFieldMetadataUniversalIdentifier:
+ FATHOM_RECORDING_IMPORTS_ON_CALL_RECORDING_FIELD_UNIVERSAL_IDENTIFIER,
+ universalSettings: {
+ relationType: RelationType.MANY_TO_ONE,
+ onDelete: OnDeleteAction.CASCADE,
+ joinColumnName: 'callRecordingId',
+ },
+ },
+ ],
+});