@twentyhq/call-recorder 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/manifest.json +297 -0
- package/package.json +2 -2
- package/src/front-components/calendar-event-recording.front-component.mjs +269 -0
- package/src/front-components/calendar-event-recording.front-component.mjs.map +7 -0
- package/src/logic-functions/process-recall-webhook.mjs +1744 -0
- package/src/logic-functions/process-recall-webhook.mjs.map +7 -0
- package/src/logic-functions/recall-webhook.mjs +391 -0
- package/src/logic-functions/recall-webhook.mjs.map +7 -0
- package/src/logic-functions/reconcile-call-recorder-calendar-event.mjs +1602 -0
- package/src/logic-functions/reconcile-call-recorder-calendar-event.mjs.map +7 -0
- package/src/logic-functions/reconcile-stale-bot-state.mjs +2268 -0
- package/src/logic-functions/reconcile-stale-bot-state.mjs.map +7 -0
- package/.env.example +0 -5
- package/.nvmrc +0 -1
- package/.oxlintrc.json +0 -20
- package/AGENTS.md +0 -67
- package/CLAUDE.md +0 -67
- package/README.md +0 -24
- package/SETUP.md +0 -95
- package/src/__tests__/global-setup.ts +0 -100
- package/src/__tests__/schema.integration-test.ts +0 -104
- package/src/application-config.ts +0 -96
- package/src/constants/__tests__/call-recording-field-universal-identifiers.test.ts +0 -19
- package/src/constants/app-description.ts +0 -2
- package/src/constants/app-display-name.ts +0 -1
- package/src/constants/application-universal-identifier.ts +0 -2
- package/src/constants/calendar-event-reconciliation-logic-function-universal-identifier.ts +0 -2
- package/src/constants/calendar-event-record-page-layout-universal-identifier.ts +0 -2
- package/src/constants/calendar-event-recording-front-component-universal-identifier.ts +0 -2
- package/src/constants/calendar-event-recording-page-layout-tab-universal-identifier.ts +0 -2
- package/src/constants/calendar-event-recording-page-layout-widget-universal-identifier.ts +0 -2
- package/src/constants/call-recorder-everyone-left-timeout-seconds-app-variable-universal-identifier.ts +0 -2
- package/src/constants/call-recorder-failure-reason-on-call-recording-field-universal-identifier.ts +0 -2
- package/src/constants/call-recorder-join-early-minutes-app-variable-universal-identifier.ts +0 -2
- package/src/constants/call-recorder-name-app-variable-universal-identifier.ts +0 -2
- package/src/constants/call-recorder-noone-joined-timeout-seconds-app-variable-universal-identifier.ts +0 -2
- package/src/constants/call-recorder-preference-off-option-id.ts +0 -2
- package/src/constants/call-recorder-preference-on-calendar-event-field-universal-identifier.ts +0 -2
- package/src/constants/call-recorder-preference-on-calendar-event-view-field-universal-identifier.ts +0 -2
- package/src/constants/call-recorder-preference-on-option-id.ts +0 -2
- package/src/constants/call-recorder-preference.ts +0 -4
- package/src/constants/call-recorder-waiting-room-timeout-seconds-app-variable-universal-identifier.ts +0 -2
- package/src/constants/call-recording-audio-field-universal-identifier.ts +0 -2
- package/src/constants/call-recording-video-field-universal-identifier.ts +0 -2
- package/src/constants/default-role-universal-identifier.ts +0 -2
- package/src/constants/process-recall-webhook-logic-function-universal-identifier.ts +0 -2
- package/src/constants/recall-webhook-logic-function-universal-identifier.ts +0 -2
- package/src/constants/stale-bot-state-logic-function-universal-identifier.ts +0 -2
- package/src/default-role.ts +0 -69
- package/src/fields/call-recorder-failure-reason-on-call-recording.field.ts +0 -22
- package/src/fields/call-recorder-preference-on-calendar-event.field.ts +0 -41
- package/src/front-components/calendar-event-recording.front-component.tsx +0 -13
- package/src/front-components/components/CalendarEventRecording.tsx +0 -39
- package/src/front-components/components/CalendarEventRecordingBody.tsx +0 -96
- package/src/front-components/components/CalendarEventRecordingContent.tsx +0 -111
- package/src/front-components/components/RecordingTranscript.tsx +0 -92
- package/src/front-components/components/RecordingVideoPlayer.tsx +0 -52
- package/src/front-components/components/TranscriptEntryList.tsx +0 -61
- package/src/front-components/components/TranscriptEntryListItem.tsx +0 -115
- package/src/front-components/components/TranscriptErrorBox.tsx +0 -48
- package/src/front-components/components/TranscriptSpeakerAvatar.tsx +0 -141
- package/src/front-components/components/TranscriptSpeakerChip.tsx +0 -51
- package/src/front-components/constants/recording-theme-css-variables.ts +0 -40
- package/src/front-components/hooks/use-calendar-event-participants.ts +0 -172
- package/src/front-components/hooks/use-calendar-event-recording.ts +0 -155
- package/src/front-components/types/calendar-event-participant-by-speaker-name.type.ts +0 -6
- package/src/front-components/types/calendar-event-recording-participant.type.ts +0 -7
- package/src/front-components/types/transcript-entry.type.ts +0 -13
- package/src/front-components/utils/__tests__/find-active-transcript-entry-index.test.ts +0 -66
- package/src/front-components/utils/__tests__/format-transcript-timestamp.test.ts +0 -29
- package/src/front-components/utils/__tests__/get-speaker-name-match-keys.test.ts +0 -22
- package/src/front-components/utils/__tests__/parse-transcript-entries.test.ts +0 -162
- package/src/front-components/utils/build-calendar-event-participant-by-speaker-name.util.ts +0 -45
- package/src/front-components/utils/find-active-transcript-entry-index.util.ts +0 -77
- package/src/front-components/utils/format-transcript-timestamp.util.ts +0 -16
- package/src/front-components/utils/get-absolute-avatar-url.util.ts +0 -48
- package/src/front-components/utils/get-calendar-event-participant-for-speaker-name.util.ts +0 -24
- package/src/front-components/utils/get-speaker-name-match-keys.util.ts +0 -64
- package/src/front-components/utils/get-video-file-extension.util.ts +0 -23
- package/src/front-components/utils/parse-transcript-entries.util.ts +0 -85
- package/src/logic-functions/__tests__/process-recall-webhook.test.ts +0 -62
- package/src/logic-functions/__tests__/recall-webhook.test.ts +0 -180
- package/src/logic-functions/constants/call-recorder-everyone-left-timeout-seconds-env-var-name.ts +0 -2
- package/src/logic-functions/constants/call-recorder-everyone-left-timeout-seconds.ts +0 -1
- package/src/logic-functions/constants/call-recorder-join-early-minutes-env-var-name.ts +0 -2
- package/src/logic-functions/constants/call-recorder-name-env-var-name.ts +0 -1
- package/src/logic-functions/constants/call-recorder-noone-joined-timeout-seconds-env-var-name.ts +0 -2
- package/src/logic-functions/constants/call-recorder-noone-joined-timeout-seconds.ts +0 -1
- package/src/logic-functions/constants/call-recorder-recording-retention-hours-env-var-name.ts +0 -2
- package/src/logic-functions/constants/call-recorder-waiting-room-timeout-seconds-env-var-name.ts +0 -2
- package/src/logic-functions/constants/call-recorder-waiting-room-timeout-seconds.ts +0 -1
- package/src/logic-functions/constants/call-recording-micro-credits-per-hour.ts +0 -1
- package/src/logic-functions/constants/call-recording-request-status.ts +0 -5
- package/src/logic-functions/constants/call-recording-status.ts +0 -9
- package/src/logic-functions/constants/default-call-recorder-join-early-minutes.ts +0 -1
- package/src/logic-functions/constants/default-call-recorder-name.ts +0 -1
- package/src/logic-functions/constants/default-call-recorder-recording-retention-hours.ts +0 -2
- package/src/logic-functions/constants/default-recall-region.ts +0 -1
- package/src/logic-functions/constants/milliseconds-per-minute.ts +0 -1
- package/src/logic-functions/constants/non-terminal-call-recording-statuses.ts +0 -8
- package/src/logic-functions/constants/recall-api-key-env-var-name.ts +0 -1
- package/src/logic-functions/constants/recall-api-max-attempts.ts +0 -1
- package/src/logic-functions/constants/recall-api-retry-delay-ms.ts +0 -1
- package/src/logic-functions/constants/recall-bot-automatic-leave.ts +0 -74
- package/src/logic-functions/constants/recall-bot-everyone-left-min-activate-after-seconds.ts +0 -1
- package/src/logic-functions/constants/recall-bot-recording-config.ts +0 -34
- package/src/logic-functions/constants/recall-region-env-var-name.ts +0 -1
- package/src/logic-functions/constants/recall-webhook-secret-env-var-name.ts +0 -1
- package/src/logic-functions/constants/restricted-field-placeholder.ts +0 -3
- package/src/logic-functions/constants/stale-bot-state-cron-pattern.ts +0 -1
- package/src/logic-functions/constants/twenty-page-size.ts +0 -1
- package/src/logic-functions/data/__tests__/complete-call-recording-ingestion.test.ts +0 -55
- package/src/logic-functions/data/__tests__/fetch-all-nodes.test.ts +0 -43
- package/src/logic-functions/data/__tests__/get-current-workspace-id.test.ts +0 -38
- package/src/logic-functions/data/__tests__/strip-restricted-field-value.test.ts +0 -22
- package/src/logic-functions/data/complete-call-recording-ingestion.util.ts +0 -24
- package/src/logic-functions/data/create-call-recording.util.ts +0 -41
- package/src/logic-functions/data/fetch-all-nodes.util.ts +0 -44
- package/src/logic-functions/data/fetch-calendar-events-by-filter.util.ts +0 -80
- package/src/logic-functions/data/fetch-calendar-events-by-ids.util.ts +0 -20
- package/src/logic-functions/data/fetch-calendar-events-by-starts-at-values.util.ts +0 -19
- package/src/logic-functions/data/find-call-recordings-by-calendar-event-ids.util.ts +0 -17
- package/src/logic-functions/data/find-call-recordings-by-filter.util.ts +0 -102
- package/src/logic-functions/data/find-call-recordings-by-ids.util.ts +0 -17
- package/src/logic-functions/data/find-open-scheduled-call-recordings.util.ts +0 -14
- package/src/logic-functions/data/get-current-workspace-id.util.ts +0 -36
- package/src/logic-functions/data/strip-restricted-field-value.util.ts +0 -6
- package/src/logic-functions/data/update-call-recording.util.ts +0 -24
- package/src/logic-functions/domain/__tests__/build-call-recorder-policy-result.test.ts +0 -47
- package/src/logic-functions/domain/__tests__/compute-call-recording-charge.test.ts +0 -71
- package/src/logic-functions/domain/__tests__/compute-call-recording-id-for-meeting.test.ts +0 -37
- package/src/logic-functions/domain/__tests__/compute-real-meeting-key.test.ts +0 -88
- package/src/logic-functions/domain/__tests__/is-call-recording-ingestion-complete.test.ts +0 -59
- package/src/logic-functions/domain/__tests__/is-call-recording-status-downgrade.test.ts +0 -37
- package/src/logic-functions/domain/__tests__/resolve-call-recorder-policy-result.test.ts +0 -120
- package/src/logic-functions/domain/__tests__/should-complete-call-recording-ingestion.test.ts +0 -102
- package/src/logic-functions/domain/aggregate-call-recorder-policy-results-by-meeting.util.ts +0 -42
- package/src/logic-functions/domain/build-call-recorder-policy-result.util.ts +0 -53
- package/src/logic-functions/domain/build-failed-transcript-marker.util.ts +0 -13
- package/src/logic-functions/domain/build-pending-transcript-marker.util.ts +0 -13
- package/src/logic-functions/domain/build-recall-routing-metadata.util.ts +0 -12
- package/src/logic-functions/domain/build-transcript-failure-reason.util.ts +0 -7
- package/src/logic-functions/domain/compute-call-recording-charge.util.ts +0 -41
- package/src/logic-functions/domain/compute-call-recording-id-for-meeting.util.ts +0 -16
- package/src/logic-functions/domain/compute-real-meeting-key.util.ts +0 -48
- package/src/logic-functions/domain/compute-recall-bot-join-at.util.ts +0 -34
- package/src/logic-functions/domain/is-call-recording-ingestion-complete.util.ts +0 -19
- package/src/logic-functions/domain/is-call-recording-status-downgrade.util.ts +0 -37
- package/src/logic-functions/domain/is-recall-recording-done-signal.util.ts +0 -13
- package/src/logic-functions/domain/map-recall-status-code-to-call-recording-status.util.ts +0 -26
- package/src/logic-functions/domain/parse-transcript-marker.util.ts +0 -29
- package/src/logic-functions/domain/resolve-call-recorder-policy-result.util.ts +0 -72
- package/src/logic-functions/domain/should-complete-call-recording-ingestion.util.ts +0 -32
- package/src/logic-functions/flows/__tests__/charge-completed-call-recording.test.ts +0 -45
- package/src/logic-functions/flows/__tests__/complete-and-charge-call-recording.test.ts +0 -61
- package/src/logic-functions/flows/__tests__/converge-diverged-call-recordings.test.ts +0 -727
- package/src/logic-functions/flows/__tests__/download-transcript.test.ts +0 -74
- package/src/logic-functions/flows/__tests__/handle-recall-webhook.test.ts +0 -1301
- package/src/logic-functions/flows/__tests__/heal-call-recordings-missing-bot.test.ts +0 -225
- package/src/logic-functions/flows/__tests__/ingest-call-recording-media.test.ts +0 -153
- package/src/logic-functions/flows/__tests__/reap-orphaned-call-recorders.test.ts +0 -425
- package/src/logic-functions/flows/__tests__/reconcile-call-recorder.test.ts +0 -1007
- package/src/logic-functions/flows/cancel-call-recording-request.util.ts +0 -46
- package/src/logic-functions/flows/charge-completed-call-recording.util.ts +0 -31
- package/src/logic-functions/flows/complete-and-charge-call-recording.util.ts +0 -29
- package/src/logic-functions/flows/converge-diverged-call-recordings-result.type.ts +0 -8
- package/src/logic-functions/flows/converge-diverged-call-recordings.util.ts +0 -447
- package/src/logic-functions/flows/download-transcript.util.ts +0 -67
- package/src/logic-functions/flows/ensure-call-recorder.util.ts +0 -73
- package/src/logic-functions/flows/handle-recall-webhook.util.ts +0 -672
- package/src/logic-functions/flows/heal-call-recordings-missing-bot.util.ts +0 -82
- package/src/logic-functions/flows/ingest-call-recording-media.util.ts +0 -128
- package/src/logic-functions/flows/persist-call-recording-progress.util.ts +0 -58
- package/src/logic-functions/flows/reap-orphaned-call-recorders.util.ts +0 -183
- package/src/logic-functions/flows/reconcile-call-recorder.util.ts +0 -495
- package/src/logic-functions/flows/reconcile-call-recording-transcript-artifact-result.type.ts +0 -11
- package/src/logic-functions/flows/reconcile-call-recording-transcript-artifact.util.ts +0 -182
- package/src/logic-functions/flows/reschedule-call-recording-bot.util.ts +0 -69
- package/src/logic-functions/process-recall-webhook.ts +0 -23
- package/src/logic-functions/recall-api/__tests__/extract-recall-bot-convergence.test.ts +0 -153
- package/src/logic-functions/recall-api/__tests__/extract-recall-media-urls.test.ts +0 -67
- package/src/logic-functions/recall-api/__tests__/recall-bot-api.test.ts +0 -744
- package/src/logic-functions/recall-api/__tests__/verify-recall-webhook-signature.test.ts +0 -122
- package/src/logic-functions/recall-api/cancel-recall-bot.util.ts +0 -28
- package/src/logic-functions/recall-api/create-async-recall-transcript.util.ts +0 -47
- package/src/logic-functions/recall-api/eject-recall-bot.util.ts +0 -28
- package/src/logic-functions/recall-api/extract-recall-bot-convergence.util.ts +0 -149
- package/src/logic-functions/recall-api/extract-recall-bot-id.util.ts +0 -10
- package/src/logic-functions/recall-api/extract-recall-media-urls.util.ts +0 -30
- package/src/logic-functions/recall-api/extract-twenty-workspace-id-from-recall-webhook.util.ts +0 -8
- package/src/logic-functions/recall-api/get-recall-api-config.util.ts +0 -59
- package/src/logic-functions/recall-api/get-recall-bot.util.ts +0 -42
- package/src/logic-functions/recall-api/get-recall-recording.util.ts +0 -31
- package/src/logic-functions/recall-api/get-recall-webhook-bot-metadata.util.ts +0 -18
- package/src/logic-functions/recall-api/list-recall-transcripts.util.ts +0 -141
- package/src/logic-functions/recall-api/list-scheduled-recall-bots.util.ts +0 -106
- package/src/logic-functions/recall-api/normalize-recall-timestamp.util.ts +0 -14
- package/src/logic-functions/recall-api/parse-recall-webhook-event.util.ts +0 -88
- package/src/logic-functions/recall-api/recall-bot-api-request.util.ts +0 -165
- package/src/logic-functions/recall-api/recall-transcript-summary.type.ts +0 -5
- package/src/logic-functions/recall-api/reschedule-recall-bot.util.ts +0 -56
- package/src/logic-functions/recall-api/retrieve-recall-transcript.util.ts +0 -71
- package/src/logic-functions/recall-api/schedule-recall-bot.util.ts +0 -68
- package/src/logic-functions/recall-api/verify-recall-webhook-signature.util.ts +0 -109
- package/src/logic-functions/recall-webhook.ts +0 -90
- package/src/logic-functions/reconcile-call-recorder-calendar-event.ts +0 -178
- package/src/logic-functions/reconcile-stale-bot-state.ts +0 -106
- package/src/logic-functions/types/calendar-event-record.type.ts +0 -5
- package/src/logic-functions/types/call-recorder-policy-calendar-event-input.type.ts +0 -10
- package/src/logic-functions/types/call-recorder-policy-input.type.ts +0 -9
- package/src/logic-functions/types/call-recorder-policy-not-required-reason.type.ts +0 -5
- package/src/logic-functions/types/call-recorder-policy-required-reason.type.ts +0 -1
- package/src/logic-functions/types/call-recorder-policy-result-for-calendar-event.type.ts +0 -9
- package/src/logic-functions/types/call-recorder-policy-result-for-meeting.type.ts +0 -6
- package/src/logic-functions/types/call-recorder-policy-result.type.ts +0 -12
- package/src/logic-functions/types/call-recorder-reconciliation-result.type.ts +0 -16
- package/src/logic-functions/types/call-recording-media-file.type.ts +0 -1
- package/src/logic-functions/types/call-recording-record.type.ts +0 -15
- package/src/logic-functions/types/call-recording-update-fields.type.ts +0 -20
- package/src/logic-functions/types/files-field-value.type.ts +0 -1
- package/src/logic-functions/types/meeting-recording.type.ts +0 -7
- package/src/logic-functions/types/recall-bot-operation-result.type.ts +0 -19
- package/src/logic-functions/types/recall-routing-metadata.type.ts +0 -4
- package/src/logic-functions/types/removed-call-recorder-occurrence.type.ts +0 -6
- package/src/logic-functions/types/transcript-marker.type.ts +0 -6
- package/src/logic-functions/utils/as-record.util.ts +0 -6
- package/src/logic-functions/utils/get-application-variable-value.util.ts +0 -3
- package/src/logic-functions/utils/get-record-at-path.util.ts +0 -10
- package/src/logic-functions/utils/get-string.util.ts +0 -4
- package/src/logic-functions/utils/get-unique-sorted-ids.util.ts +0 -8
- package/src/logic-functions/utils/is-non-empty-string.util.ts +0 -5
- package/src/page-layouts/calendar-event-recording-tab.ts +0 -33
- package/src/view-fields/call-recorder-preference-on-calendar-event.view-field.ts +0 -27
- package/tsconfig.json +0 -42
- package/tsconfig.spec.json +0 -9
- package/vitest.config.ts +0 -31
- package/vitest.unit.config.ts +0 -14
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import { type CoreApiClient } from 'twenty-client-sdk/core';
|
|
2
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
-
|
|
4
|
-
import { healCallRecordingsMissingBot } from 'src/logic-functions/flows/heal-call-recordings-missing-bot.util';
|
|
5
|
-
|
|
6
|
-
const scheduleRecallBotMock = vi.hoisted(() => vi.fn());
|
|
7
|
-
const getCurrentWorkspaceIdMock = vi.hoisted(() => vi.fn());
|
|
8
|
-
|
|
9
|
-
vi.mock('src/logic-functions/data/get-current-workspace-id.util', () => ({
|
|
10
|
-
getCurrentWorkspaceId: getCurrentWorkspaceIdMock,
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
vi.mock('src/logic-functions/recall-api/schedule-recall-bot.util', () => ({
|
|
14
|
-
scheduleRecallBot: scheduleRecallBotMock,
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
const NOW = new Date('2026-01-01T12:00:00.000Z');
|
|
18
|
-
const WORKSPACE_ID = '123e4567-e89b-12d3-a456-426614174000';
|
|
19
|
-
const UPCOMING_STARTS_AT = '2026-01-01T13:00:00.000Z';
|
|
20
|
-
const UPCOMING_ENDS_AT = '2026-01-01T14:00:00.000Z';
|
|
21
|
-
const PAST_STARTS_AT = '2026-01-01T10:00:00.000Z';
|
|
22
|
-
const PAST_ENDS_AT = '2026-01-01T11:00:00.000Z';
|
|
23
|
-
|
|
24
|
-
type CallRecordingNode = {
|
|
25
|
-
id: string;
|
|
26
|
-
status?: string;
|
|
27
|
-
recordingRequestStatus?: string | null;
|
|
28
|
-
calendarEventId?: string | null;
|
|
29
|
-
externalBotId?: string | null;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type CalendarEventNode = {
|
|
33
|
-
id: string;
|
|
34
|
-
startsAt?: string | null;
|
|
35
|
-
endsAt?: string | null;
|
|
36
|
-
iCalUid?: string | null;
|
|
37
|
-
conferenceLink?: { primaryLinkUrl?: string | null } | null;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
class FakeCoreApiClient {
|
|
41
|
-
callRecordings: CallRecordingNode[];
|
|
42
|
-
calendarEvents: CalendarEventNode[];
|
|
43
|
-
|
|
44
|
-
constructor({
|
|
45
|
-
callRecordings = [],
|
|
46
|
-
calendarEvents = [],
|
|
47
|
-
}: {
|
|
48
|
-
callRecordings?: CallRecordingNode[];
|
|
49
|
-
calendarEvents?: CalendarEventNode[];
|
|
50
|
-
}) {
|
|
51
|
-
this.callRecordings = callRecordings;
|
|
52
|
-
this.calendarEvents = calendarEvents;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async query(query: any): Promise<any> {
|
|
56
|
-
if (query.callRecordings !== undefined) {
|
|
57
|
-
const filter = query.callRecordings.__args.filter;
|
|
58
|
-
const matches =
|
|
59
|
-
filter.id?.in !== undefined
|
|
60
|
-
? this.callRecordings.filter((callRecording) =>
|
|
61
|
-
filter.id.in.includes(callRecording.id),
|
|
62
|
-
)
|
|
63
|
-
: this.callRecordings.filter(
|
|
64
|
-
(callRecording) =>
|
|
65
|
-
callRecording.recordingRequestStatus ===
|
|
66
|
-
filter.recordingRequestStatus.eq &&
|
|
67
|
-
callRecording.status === filter.status.eq,
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
return { callRecordings: buildConnection(matches) };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (query.calendarEvents !== undefined) {
|
|
74
|
-
const calendarEventIds = query.calendarEvents.__args.filter.id.in;
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
calendarEvents: buildConnection(
|
|
78
|
-
this.calendarEvents.filter((calendarEvent) =>
|
|
79
|
-
calendarEventIds.includes(calendarEvent.id),
|
|
80
|
-
),
|
|
81
|
-
),
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
throw new Error(`Unhandled query: ${JSON.stringify(query)}`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async mutation(mutation: any): Promise<any> {
|
|
89
|
-
if (mutation.updateCallRecording !== undefined) {
|
|
90
|
-
const { id, data } = mutation.updateCallRecording.__args;
|
|
91
|
-
const callRecording = this.callRecordings.find(
|
|
92
|
-
(candidate) => candidate.id === id,
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
if (callRecording !== undefined) {
|
|
96
|
-
Object.assign(callRecording, data);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return { updateCallRecording: { id } };
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
throw new Error(`Unhandled mutation: ${JSON.stringify(mutation)}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const buildConnection = <Node>(nodes: Node[]) => ({
|
|
107
|
-
pageInfo: { hasNextPage: false, endCursor: undefined },
|
|
108
|
-
edges: nodes.map((node) => ({ node })),
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const buildBotlessCallRecording = (
|
|
112
|
-
overrides: Partial<CallRecordingNode> = {},
|
|
113
|
-
): CallRecordingNode => ({
|
|
114
|
-
id: 'call-recording-1',
|
|
115
|
-
status: 'SCHEDULED',
|
|
116
|
-
recordingRequestStatus: 'REQUESTED',
|
|
117
|
-
calendarEventId: 'calendar-event-1',
|
|
118
|
-
externalBotId: null,
|
|
119
|
-
...overrides,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const buildCalendarEvent = (
|
|
123
|
-
overrides: Partial<CalendarEventNode> = {},
|
|
124
|
-
): CalendarEventNode => ({
|
|
125
|
-
id: 'calendar-event-1',
|
|
126
|
-
startsAt: UPCOMING_STARTS_AT,
|
|
127
|
-
endsAt: UPCOMING_ENDS_AT,
|
|
128
|
-
iCalUid: 'calendar-event-uid',
|
|
129
|
-
conferenceLink: { primaryLinkUrl: 'https://meet.example.com/customer-sync' },
|
|
130
|
-
...overrides,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
describe('healCallRecordingsMissingBot', () => {
|
|
134
|
-
beforeEach(() => {
|
|
135
|
-
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
136
|
-
getCurrentWorkspaceIdMock.mockReset();
|
|
137
|
-
getCurrentWorkspaceIdMock.mockReturnValue(WORKSPACE_ID);
|
|
138
|
-
scheduleRecallBotMock.mockReset();
|
|
139
|
-
scheduleRecallBotMock.mockResolvedValue({
|
|
140
|
-
ok: true,
|
|
141
|
-
externalBotId: 'recall-bot-1',
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('schedules a bot and writes the id for an upcoming botless recording', async () => {
|
|
146
|
-
const client = new FakeCoreApiClient({
|
|
147
|
-
callRecordings: [buildBotlessCallRecording()],
|
|
148
|
-
calendarEvents: [buildCalendarEvent()],
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const result = await healCallRecordingsMissingBot({
|
|
152
|
-
client: client as unknown as CoreApiClient,
|
|
153
|
-
now: NOW,
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
expect(result.scheduledCallRecordingIds).toEqual(['call-recording-1']);
|
|
157
|
-
expect(scheduleRecallBotMock).toHaveBeenCalledTimes(1);
|
|
158
|
-
expect(scheduleRecallBotMock).toHaveBeenCalledWith(
|
|
159
|
-
expect.objectContaining({
|
|
160
|
-
metadata: expect.objectContaining({
|
|
161
|
-
twentyWorkspaceId: WORKSPACE_ID,
|
|
162
|
-
}),
|
|
163
|
-
}),
|
|
164
|
-
);
|
|
165
|
-
expect(client.callRecordings[0].externalBotId).toBe('recall-bot-1');
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('does not report a recording as scheduled when Recall scheduling fails', async () => {
|
|
169
|
-
scheduleRecallBotMock.mockResolvedValue({
|
|
170
|
-
ok: false,
|
|
171
|
-
status: 500,
|
|
172
|
-
errorMessage: 'Recall API responded with HTTP 500',
|
|
173
|
-
});
|
|
174
|
-
const client = new FakeCoreApiClient({
|
|
175
|
-
callRecordings: [buildBotlessCallRecording()],
|
|
176
|
-
calendarEvents: [buildCalendarEvent()],
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
const result = await healCallRecordingsMissingBot({
|
|
180
|
-
client: client as unknown as CoreApiClient,
|
|
181
|
-
now: NOW,
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
expect(result.scheduledCallRecordingIds).toEqual([]);
|
|
185
|
-
expect(scheduleRecallBotMock).toHaveBeenCalledTimes(1);
|
|
186
|
-
expect(client.callRecordings[0].externalBotId).toBeNull();
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('skips a recording whose meeting has already ended', async () => {
|
|
190
|
-
const client = new FakeCoreApiClient({
|
|
191
|
-
callRecordings: [buildBotlessCallRecording()],
|
|
192
|
-
calendarEvents: [
|
|
193
|
-
buildCalendarEvent({
|
|
194
|
-
startsAt: PAST_STARTS_AT,
|
|
195
|
-
endsAt: PAST_ENDS_AT,
|
|
196
|
-
}),
|
|
197
|
-
],
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
const result = await healCallRecordingsMissingBot({
|
|
201
|
-
client: client as unknown as CoreApiClient,
|
|
202
|
-
now: NOW,
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
expect(result.scheduledCallRecordingIds).toEqual([]);
|
|
206
|
-
expect(scheduleRecallBotMock).not.toHaveBeenCalled();
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('does nothing when every scheduled recording already has a bot', async () => {
|
|
210
|
-
const client = new FakeCoreApiClient({
|
|
211
|
-
callRecordings: [
|
|
212
|
-
buildBotlessCallRecording({ externalBotId: 'recall-bot-existing' }),
|
|
213
|
-
],
|
|
214
|
-
calendarEvents: [buildCalendarEvent()],
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
const result = await healCallRecordingsMissingBot({
|
|
218
|
-
client: client as unknown as CoreApiClient,
|
|
219
|
-
now: NOW,
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
expect(result.scheduledCallRecordingIds).toEqual([]);
|
|
223
|
-
expect(scheduleRecallBotMock).not.toHaveBeenCalled();
|
|
224
|
-
});
|
|
225
|
-
});
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { ingestCallRecordingMedia } from 'src/logic-functions/flows/ingest-call-recording-media.util';
|
|
4
|
-
|
|
5
|
-
const uploadFileMock = vi.hoisted(() => vi.fn());
|
|
6
|
-
const getRecallRecordingMock = vi.hoisted(() => vi.fn());
|
|
7
|
-
|
|
8
|
-
vi.mock('twenty-client-sdk/metadata', () => ({
|
|
9
|
-
MetadataApiClient: class {
|
|
10
|
-
uploadFile = uploadFileMock;
|
|
11
|
-
},
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
vi.mock('src/logic-functions/recall-api/get-recall-recording.util', () => ({
|
|
15
|
-
getRecallRecording: getRecallRecordingMock,
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
const RECORDING_WITH_MEDIA = {
|
|
19
|
-
id: 'recall-recording-1',
|
|
20
|
-
media_shortcuts: {
|
|
21
|
-
video_mixed: { download_url: 'https://media.example.com/video.mp4' },
|
|
22
|
-
audio_mixed: { download_url: 'https://media.example.com/audio.mp3' },
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const buildFetchResponse = () => ({
|
|
27
|
-
ok: true,
|
|
28
|
-
headers: { get: () => 'video/mp4' },
|
|
29
|
-
arrayBuffer: async () => new ArrayBuffer(8),
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe('ingestCallRecordingMedia', () => {
|
|
33
|
-
beforeEach(() => {
|
|
34
|
-
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
35
|
-
uploadFileMock.mockReset();
|
|
36
|
-
getRecallRecordingMock.mockReset();
|
|
37
|
-
getRecallRecordingMock.mockResolvedValue({
|
|
38
|
-
ok: true,
|
|
39
|
-
recording: RECORDING_WITH_MEDIA,
|
|
40
|
-
});
|
|
41
|
-
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(buildFetchResponse()));
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
afterEach(() => {
|
|
45
|
-
vi.unstubAllGlobals();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('downloads and uploads every missing artifact', async () => {
|
|
49
|
-
uploadFileMock
|
|
50
|
-
.mockResolvedValueOnce({ id: 'file-video-1' })
|
|
51
|
-
.mockResolvedValueOnce({ id: 'file-audio-1' });
|
|
52
|
-
|
|
53
|
-
const updateFields = await ingestCallRecordingMedia({
|
|
54
|
-
callRecordingId: 'call-recording-1',
|
|
55
|
-
externalRecordingId: 'recall-recording-1',
|
|
56
|
-
hasAudio: false,
|
|
57
|
-
hasVideo: false,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
expect(updateFields).toEqual({
|
|
61
|
-
video: [{ fileId: 'file-video-1', label: 'video.mp4' }],
|
|
62
|
-
audio: [{ fileId: 'file-audio-1', label: 'audio.mp3' }],
|
|
63
|
-
});
|
|
64
|
-
expect(uploadFileMock).toHaveBeenCalledTimes(2);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('skips artifacts already on the record', async () => {
|
|
68
|
-
uploadFileMock.mockResolvedValue({ id: 'file-audio-1' });
|
|
69
|
-
|
|
70
|
-
const updateFields = await ingestCallRecordingMedia({
|
|
71
|
-
callRecordingId: 'call-recording-1',
|
|
72
|
-
externalRecordingId: 'recall-recording-1',
|
|
73
|
-
hasAudio: false,
|
|
74
|
-
hasVideo: true,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
expect(updateFields).toEqual({
|
|
78
|
-
audio: [{ fileId: 'file-audio-1', label: 'audio.mp3' }],
|
|
79
|
-
});
|
|
80
|
-
expect(uploadFileMock).toHaveBeenCalledTimes(1);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('does not fetch the recording when both artifacts are present', async () => {
|
|
84
|
-
const updateFields = await ingestCallRecordingMedia({
|
|
85
|
-
callRecordingId: 'call-recording-1',
|
|
86
|
-
externalRecordingId: 'recall-recording-1',
|
|
87
|
-
hasAudio: true,
|
|
88
|
-
hasVideo: true,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
expect(updateFields).toEqual({});
|
|
92
|
-
expect(getRecallRecordingMock).not.toHaveBeenCalled();
|
|
93
|
-
expect(uploadFileMock).not.toHaveBeenCalled();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('omits an artifact and warns when its transfer fails', async () => {
|
|
97
|
-
uploadFileMock.mockRejectedValueOnce(new Error('upload exploded'));
|
|
98
|
-
uploadFileMock.mockResolvedValueOnce({ id: 'file-audio-1' });
|
|
99
|
-
|
|
100
|
-
const updateFields = await ingestCallRecordingMedia({
|
|
101
|
-
callRecordingId: 'call-recording-1',
|
|
102
|
-
externalRecordingId: 'recall-recording-1',
|
|
103
|
-
hasAudio: false,
|
|
104
|
-
hasVideo: false,
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
expect(updateFields).toEqual({
|
|
108
|
-
audio: [{ fileId: 'file-audio-1', label: 'audio.mp3' }],
|
|
109
|
-
});
|
|
110
|
-
expect(Object.keys(updateFields)).toEqual(['audio']);
|
|
111
|
-
expect(console.warn).toHaveBeenCalledWith(
|
|
112
|
-
expect.stringContaining('upload exploded'),
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('returns nothing when the recording exposes no media urls', async () => {
|
|
117
|
-
getRecallRecordingMock.mockResolvedValue({
|
|
118
|
-
ok: true,
|
|
119
|
-
recording: { id: 'recall-recording-1' },
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const updateFields = await ingestCallRecordingMedia({
|
|
123
|
-
callRecordingId: 'call-recording-1',
|
|
124
|
-
externalRecordingId: 'recall-recording-1',
|
|
125
|
-
hasAudio: false,
|
|
126
|
-
hasVideo: false,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
expect(updateFields).toEqual({});
|
|
130
|
-
expect(uploadFileMock).not.toHaveBeenCalled();
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('warns and returns nothing when the recording fetch fails', async () => {
|
|
134
|
-
getRecallRecordingMock.mockResolvedValue({
|
|
135
|
-
ok: false,
|
|
136
|
-
status: 500,
|
|
137
|
-
errorMessage: 'recording boom',
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
const updateFields = await ingestCallRecordingMedia({
|
|
141
|
-
callRecordingId: 'call-recording-1',
|
|
142
|
-
externalRecordingId: 'recall-recording-1',
|
|
143
|
-
hasAudio: false,
|
|
144
|
-
hasVideo: false,
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
expect(updateFields).toEqual({});
|
|
148
|
-
expect(uploadFileMock).not.toHaveBeenCalled();
|
|
149
|
-
expect(console.warn).toHaveBeenCalledWith(
|
|
150
|
-
expect.stringContaining('recording boom'),
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
});
|