@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,425 +0,0 @@
|
|
|
1
|
-
import { type CoreApiClient } from 'twenty-client-sdk/core';
|
|
2
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
-
|
|
4
|
-
import { reapOrphanedCallRecorders } from 'src/logic-functions/flows/reap-orphaned-call-recorders.util';
|
|
5
|
-
|
|
6
|
-
const listScheduledRecallBotsMock = vi.hoisted(() => vi.fn());
|
|
7
|
-
const cancelRecallBotMock = vi.hoisted(() => vi.fn());
|
|
8
|
-
const ejectRecallBotMock = vi.hoisted(() => vi.fn());
|
|
9
|
-
const getCurrentWorkspaceIdMock = vi.hoisted(() => vi.fn());
|
|
10
|
-
|
|
11
|
-
vi.mock('src/logic-functions/data/get-current-workspace-id.util', () => ({
|
|
12
|
-
getCurrentWorkspaceId: getCurrentWorkspaceIdMock,
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
vi.mock(
|
|
16
|
-
'src/logic-functions/recall-api/list-scheduled-recall-bots.util',
|
|
17
|
-
() => ({
|
|
18
|
-
listScheduledRecallBots: listScheduledRecallBotsMock,
|
|
19
|
-
}),
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
vi.mock('src/logic-functions/recall-api/cancel-recall-bot.util', () => ({
|
|
23
|
-
cancelRecallBot: cancelRecallBotMock,
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
vi.mock('src/logic-functions/recall-api/eject-recall-bot.util', () => ({
|
|
27
|
-
ejectRecallBot: ejectRecallBotMock,
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
const JOIN_AT_AFTER = '2026-01-01T08:00:00.000Z';
|
|
31
|
-
const JOIN_AT_BEFORE = '2026-01-02T12:00:00.000Z';
|
|
32
|
-
const CURRENT_WORKSPACE_ID = '123e4567-e89b-12d3-a456-426614174000';
|
|
33
|
-
const OTHER_WORKSPACE_ID = '123e4567-e89b-12d3-a456-426614174999';
|
|
34
|
-
|
|
35
|
-
type CallRecordingNode = {
|
|
36
|
-
id: string;
|
|
37
|
-
recordingRequestStatus?: string | null;
|
|
38
|
-
externalBotId?: string | null;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
class FakeCoreApiClient {
|
|
42
|
-
constructor(private callRecordings: CallRecordingNode[]) {}
|
|
43
|
-
|
|
44
|
-
async query(query: any): Promise<any> {
|
|
45
|
-
const callRecordingIds = query.callRecordings.__args.filter.id.in;
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
callRecordings: {
|
|
49
|
-
pageInfo: { hasNextPage: false, endCursor: undefined },
|
|
50
|
-
edges: this.callRecordings
|
|
51
|
-
.filter((callRecording) =>
|
|
52
|
-
callRecordingIds.includes(callRecording.id),
|
|
53
|
-
)
|
|
54
|
-
.map((node) => ({ node })),
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const buildClient = (callRecordings: CallRecordingNode[]): CoreApiClient =>
|
|
61
|
-
new FakeCoreApiClient(callRecordings) as unknown as CoreApiClient;
|
|
62
|
-
|
|
63
|
-
const buildBot = ({
|
|
64
|
-
id,
|
|
65
|
-
twentyCallRecordingId,
|
|
66
|
-
twentyWorkspaceId,
|
|
67
|
-
}: {
|
|
68
|
-
id: string;
|
|
69
|
-
twentyCallRecordingId?: string;
|
|
70
|
-
twentyWorkspaceId?: string;
|
|
71
|
-
}) => ({
|
|
72
|
-
id,
|
|
73
|
-
metadata: {
|
|
74
|
-
...(twentyCallRecordingId === undefined ? {} : { twentyCallRecordingId }),
|
|
75
|
-
...(twentyWorkspaceId === undefined ? {} : { twentyWorkspaceId }),
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const buildCurrentWorkspaceBot = ({
|
|
80
|
-
id,
|
|
81
|
-
twentyCallRecordingId,
|
|
82
|
-
}: {
|
|
83
|
-
id: string;
|
|
84
|
-
twentyCallRecordingId: string;
|
|
85
|
-
}) =>
|
|
86
|
-
buildBot({
|
|
87
|
-
id,
|
|
88
|
-
twentyCallRecordingId,
|
|
89
|
-
twentyWorkspaceId: CURRENT_WORKSPACE_ID,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe('reapOrphanedCallRecorders', () => {
|
|
93
|
-
beforeEach(() => {
|
|
94
|
-
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
95
|
-
getCurrentWorkspaceIdMock.mockReset();
|
|
96
|
-
getCurrentWorkspaceIdMock.mockReturnValue(CURRENT_WORKSPACE_ID);
|
|
97
|
-
listScheduledRecallBotsMock.mockReset();
|
|
98
|
-
cancelRecallBotMock.mockReset();
|
|
99
|
-
cancelRecallBotMock.mockResolvedValue({ ok: true });
|
|
100
|
-
ejectRecallBotMock.mockReset();
|
|
101
|
-
ejectRecallBotMock.mockResolvedValue({ ok: true });
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('keeps bots that their call recording still references', async () => {
|
|
105
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
106
|
-
ok: true,
|
|
107
|
-
bots: [
|
|
108
|
-
buildCurrentWorkspaceBot({
|
|
109
|
-
id: 'claimed-bot',
|
|
110
|
-
twentyCallRecordingId: 'call-recording-1',
|
|
111
|
-
}),
|
|
112
|
-
],
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const result = await reapOrphanedCallRecorders({
|
|
116
|
-
client: buildClient([
|
|
117
|
-
{
|
|
118
|
-
id: 'call-recording-1',
|
|
119
|
-
recordingRequestStatus: 'REQUESTED',
|
|
120
|
-
externalBotId: 'claimed-bot',
|
|
121
|
-
},
|
|
122
|
-
]),
|
|
123
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
124
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
expect(result).toEqual({
|
|
128
|
-
scannedBotCount: 1,
|
|
129
|
-
canceledExternalBotIds: [],
|
|
130
|
-
});
|
|
131
|
-
expect(cancelRecallBotMock).not.toHaveBeenCalled();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('cancels bots whose call recording request was canceled locally', async () => {
|
|
135
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
136
|
-
ok: true,
|
|
137
|
-
bots: [
|
|
138
|
-
buildCurrentWorkspaceBot({
|
|
139
|
-
id: 'stale-cancel-bot',
|
|
140
|
-
twentyCallRecordingId: 'call-recording-1',
|
|
141
|
-
}),
|
|
142
|
-
],
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const result = await reapOrphanedCallRecorders({
|
|
146
|
-
client: buildClient([
|
|
147
|
-
{
|
|
148
|
-
id: 'call-recording-1',
|
|
149
|
-
recordingRequestStatus: 'CANCELED',
|
|
150
|
-
externalBotId: 'stale-cancel-bot',
|
|
151
|
-
},
|
|
152
|
-
]),
|
|
153
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
154
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
expect(result).toEqual({
|
|
158
|
-
scannedBotCount: 1,
|
|
159
|
-
canceledExternalBotIds: ['stale-cancel-bot'],
|
|
160
|
-
});
|
|
161
|
-
expect(cancelRecallBotMock).toHaveBeenCalledWith({
|
|
162
|
-
externalBotId: 'stale-cancel-bot',
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('cancels bots whose call recording references another bot', async () => {
|
|
167
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
168
|
-
ok: true,
|
|
169
|
-
bots: [
|
|
170
|
-
buildCurrentWorkspaceBot({
|
|
171
|
-
id: 'superseded-bot',
|
|
172
|
-
twentyCallRecordingId: 'call-recording-1',
|
|
173
|
-
}),
|
|
174
|
-
buildCurrentWorkspaceBot({
|
|
175
|
-
id: 'claimed-bot',
|
|
176
|
-
twentyCallRecordingId: 'call-recording-1',
|
|
177
|
-
}),
|
|
178
|
-
],
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
const result = await reapOrphanedCallRecorders({
|
|
182
|
-
client: buildClient([
|
|
183
|
-
{
|
|
184
|
-
id: 'call-recording-1',
|
|
185
|
-
recordingRequestStatus: 'REQUESTED',
|
|
186
|
-
externalBotId: 'claimed-bot',
|
|
187
|
-
},
|
|
188
|
-
]),
|
|
189
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
190
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
expect(result).toEqual({
|
|
194
|
-
scannedBotCount: 2,
|
|
195
|
-
canceledExternalBotIds: ['superseded-bot'],
|
|
196
|
-
});
|
|
197
|
-
expect(cancelRecallBotMock).toHaveBeenCalledTimes(1);
|
|
198
|
-
expect(cancelRecallBotMock).toHaveBeenCalledWith({
|
|
199
|
-
externalBotId: 'superseded-bot',
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it('cancels bots whose call recording no longer exists', async () => {
|
|
204
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
205
|
-
ok: true,
|
|
206
|
-
bots: [
|
|
207
|
-
buildCurrentWorkspaceBot({
|
|
208
|
-
id: 'orphan-bot',
|
|
209
|
-
twentyCallRecordingId: 'call-recording-gone',
|
|
210
|
-
}),
|
|
211
|
-
],
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
const result = await reapOrphanedCallRecorders({
|
|
215
|
-
client: buildClient([]),
|
|
216
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
217
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
expect(result).toEqual({
|
|
221
|
-
scannedBotCount: 1,
|
|
222
|
-
canceledExternalBotIds: ['orphan-bot'],
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('grants a grace round to requested recordings without a bot id yet', async () => {
|
|
227
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
228
|
-
ok: true,
|
|
229
|
-
bots: [
|
|
230
|
-
buildCurrentWorkspaceBot({
|
|
231
|
-
id: 'pending-bot',
|
|
232
|
-
twentyCallRecordingId: 'call-recording-1',
|
|
233
|
-
}),
|
|
234
|
-
],
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
const result = await reapOrphanedCallRecorders({
|
|
238
|
-
client: buildClient([
|
|
239
|
-
{
|
|
240
|
-
id: 'call-recording-1',
|
|
241
|
-
recordingRequestStatus: 'REQUESTED',
|
|
242
|
-
externalBotId: null,
|
|
243
|
-
},
|
|
244
|
-
]),
|
|
245
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
246
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
expect(result).toEqual({
|
|
250
|
-
scannedBotCount: 1,
|
|
251
|
-
canceledExternalBotIds: [],
|
|
252
|
-
});
|
|
253
|
-
expect(cancelRecallBotMock).not.toHaveBeenCalled();
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('ignores bots that were not created by this app', async () => {
|
|
257
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
258
|
-
ok: true,
|
|
259
|
-
bots: [buildBot({ id: 'unrelated-bot' })],
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
const result = await reapOrphanedCallRecorders({
|
|
263
|
-
client: buildClient([]),
|
|
264
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
265
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
expect(result).toEqual({
|
|
269
|
-
scannedBotCount: 1,
|
|
270
|
-
canceledExternalBotIds: [],
|
|
271
|
-
});
|
|
272
|
-
expect(cancelRecallBotMock).not.toHaveBeenCalled();
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it('ignores untagged bots even when they carry call recording metadata', async () => {
|
|
276
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
277
|
-
ok: true,
|
|
278
|
-
bots: [
|
|
279
|
-
buildBot({
|
|
280
|
-
id: 'untagged-bot',
|
|
281
|
-
twentyCallRecordingId: 'call-recording-gone',
|
|
282
|
-
}),
|
|
283
|
-
],
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
const result = await reapOrphanedCallRecorders({
|
|
287
|
-
client: buildClient([]),
|
|
288
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
289
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
expect(result).toEqual({
|
|
293
|
-
scannedBotCount: 1,
|
|
294
|
-
canceledExternalBotIds: [],
|
|
295
|
-
});
|
|
296
|
-
expect(cancelRecallBotMock).not.toHaveBeenCalled();
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it('ignores bots claimed by another workspace', async () => {
|
|
300
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
301
|
-
ok: true,
|
|
302
|
-
bots: [
|
|
303
|
-
buildBot({
|
|
304
|
-
id: 'other-workspace-bot',
|
|
305
|
-
twentyCallRecordingId: 'call-recording-gone',
|
|
306
|
-
twentyWorkspaceId: OTHER_WORKSPACE_ID,
|
|
307
|
-
}),
|
|
308
|
-
],
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
const result = await reapOrphanedCallRecorders({
|
|
312
|
-
client: buildClient([]),
|
|
313
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
314
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
expect(result).toEqual({
|
|
318
|
-
scannedBotCount: 1,
|
|
319
|
-
canceledExternalBotIds: [],
|
|
320
|
-
});
|
|
321
|
-
expect(cancelRecallBotMock).not.toHaveBeenCalled();
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it('cancels orphaned bots claimed by this workspace', async () => {
|
|
325
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
326
|
-
ok: true,
|
|
327
|
-
bots: [
|
|
328
|
-
buildCurrentWorkspaceBot({
|
|
329
|
-
id: 'same-workspace-bot',
|
|
330
|
-
twentyCallRecordingId: 'call-recording-gone',
|
|
331
|
-
}),
|
|
332
|
-
],
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
const result = await reapOrphanedCallRecorders({
|
|
336
|
-
client: buildClient([]),
|
|
337
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
338
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
expect(result).toEqual({
|
|
342
|
-
scannedBotCount: 1,
|
|
343
|
-
canceledExternalBotIds: ['same-workspace-bot'],
|
|
344
|
-
});
|
|
345
|
-
expect(cancelRecallBotMock).toHaveBeenCalledWith({
|
|
346
|
-
externalBotId: 'same-workspace-bot',
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
it('ejects an orphaned bot that already joined when deletion is rejected', async () => {
|
|
351
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
352
|
-
ok: true,
|
|
353
|
-
bots: [
|
|
354
|
-
buildCurrentWorkspaceBot({
|
|
355
|
-
id: 'in-call-orphan',
|
|
356
|
-
twentyCallRecordingId: 'call-recording-gone',
|
|
357
|
-
}),
|
|
358
|
-
],
|
|
359
|
-
});
|
|
360
|
-
cancelRecallBotMock.mockResolvedValue({
|
|
361
|
-
ok: false,
|
|
362
|
-
status: 409,
|
|
363
|
-
errorMessage: 'Recall API responded with HTTP 409',
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
const result = await reapOrphanedCallRecorders({
|
|
367
|
-
client: buildClient([]),
|
|
368
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
369
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
expect(result).toEqual({
|
|
373
|
-
scannedBotCount: 1,
|
|
374
|
-
canceledExternalBotIds: ['in-call-orphan'],
|
|
375
|
-
});
|
|
376
|
-
expect(ejectRecallBotMock).toHaveBeenCalledWith({
|
|
377
|
-
externalBotId: 'in-call-orphan',
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
it('reports nothing reaped when listing Recall bots fails', async () => {
|
|
382
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
383
|
-
ok: false,
|
|
384
|
-
status: 500,
|
|
385
|
-
errorMessage: 'Recall API responded with HTTP 500',
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
const result = await reapOrphanedCallRecorders({
|
|
389
|
-
client: buildClient([]),
|
|
390
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
391
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
expect(result).toEqual({
|
|
395
|
-
scannedBotCount: 0,
|
|
396
|
-
canceledExternalBotIds: [],
|
|
397
|
-
});
|
|
398
|
-
expect(cancelRecallBotMock).not.toHaveBeenCalled();
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
it('skips reaping when the current workspace cannot be resolved', async () => {
|
|
402
|
-
getCurrentWorkspaceIdMock.mockReturnValue(undefined);
|
|
403
|
-
listScheduledRecallBotsMock.mockResolvedValue({
|
|
404
|
-
ok: true,
|
|
405
|
-
bots: [
|
|
406
|
-
buildCurrentWorkspaceBot({
|
|
407
|
-
id: 'same-workspace-bot',
|
|
408
|
-
twentyCallRecordingId: 'call-recording-gone',
|
|
409
|
-
}),
|
|
410
|
-
],
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
const result = await reapOrphanedCallRecorders({
|
|
414
|
-
client: buildClient([]),
|
|
415
|
-
joinAtAfter: JOIN_AT_AFTER,
|
|
416
|
-
joinAtBefore: JOIN_AT_BEFORE,
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
expect(result).toEqual({
|
|
420
|
-
scannedBotCount: 1,
|
|
421
|
-
canceledExternalBotIds: [],
|
|
422
|
-
});
|
|
423
|
-
expect(cancelRecallBotMock).not.toHaveBeenCalled();
|
|
424
|
-
});
|
|
425
|
-
});
|