@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,744 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { cancelRecallBot } from 'src/logic-functions/recall-api/cancel-recall-bot.util';
|
|
4
|
-
import { createAsyncRecallTranscript } from 'src/logic-functions/recall-api/create-async-recall-transcript.util';
|
|
5
|
-
import { ejectRecallBot } from 'src/logic-functions/recall-api/eject-recall-bot.util';
|
|
6
|
-
import { getRecallBot } from 'src/logic-functions/recall-api/get-recall-bot.util';
|
|
7
|
-
import { listRecallTranscripts } from 'src/logic-functions/recall-api/list-recall-transcripts.util';
|
|
8
|
-
import { listScheduledRecallBots } from 'src/logic-functions/recall-api/list-scheduled-recall-bots.util';
|
|
9
|
-
import { rescheduleRecallBot } from 'src/logic-functions/recall-api/reschedule-recall-bot.util';
|
|
10
|
-
import { retrieveRecallTranscript } from 'src/logic-functions/recall-api/retrieve-recall-transcript.util';
|
|
11
|
-
import { scheduleRecallBot } from 'src/logic-functions/recall-api/schedule-recall-bot.util';
|
|
12
|
-
import { CALL_RECORDER_RECORDING_RETENTION_HOURS_ENV_VAR_NAME } from 'src/logic-functions/constants/call-recorder-recording-retention-hours-env-var-name';
|
|
13
|
-
|
|
14
|
-
const getRecallApiConfigMock = vi.hoisted(() => vi.fn());
|
|
15
|
-
const WORKSPACE_ID = '123e4567-e89b-12d3-a456-426614174000';
|
|
16
|
-
const RECALL_ROUTING_METADATA = {
|
|
17
|
-
twentyWorkspaceId: WORKSPACE_ID,
|
|
18
|
-
twentyCallRecordingId: 'call-recording-id',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
vi.mock('src/logic-functions/recall-api/get-recall-api-config.util', () => ({
|
|
22
|
-
getRecallApiConfig: getRecallApiConfigMock,
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
describe('recall bot api', () => {
|
|
26
|
-
const fetchMock = vi.fn();
|
|
27
|
-
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
delete process.env[CALL_RECORDER_RECORDING_RETENTION_HOURS_ENV_VAR_NAME];
|
|
30
|
-
getRecallApiConfigMock.mockReset();
|
|
31
|
-
getRecallApiConfigMock.mockReturnValue({
|
|
32
|
-
success: true,
|
|
33
|
-
config: {
|
|
34
|
-
apiKey: 'recall-api-key',
|
|
35
|
-
baseUrl: 'https://ap-northeast-1.recall.ai/api/v1',
|
|
36
|
-
botName: 'Call Recorder',
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
fetchMock.mockReset();
|
|
40
|
-
fetchMock.mockResolvedValue({
|
|
41
|
-
ok: true,
|
|
42
|
-
status: 201,
|
|
43
|
-
json: async () => ({ id: 'recall-bot-id' }),
|
|
44
|
-
});
|
|
45
|
-
vi.stubGlobal('fetch', fetchMock);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('creates Recall bot requests with the Token authorization scheme', async () => {
|
|
49
|
-
const result = await scheduleRecallBot({
|
|
50
|
-
meetingUrl: 'https://meet.google.com/abc-defg-hij',
|
|
51
|
-
joinAt: '2026-01-01T13:00:00.000Z',
|
|
52
|
-
metadata: RECALL_ROUTING_METADATA,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
expect(result).toEqual({ ok: true, externalBotId: 'recall-bot-id' });
|
|
56
|
-
expect(fetchMock).toHaveBeenCalledWith(
|
|
57
|
-
'https://ap-northeast-1.recall.ai/api/v1/bot/',
|
|
58
|
-
expect.objectContaining({
|
|
59
|
-
method: 'POST',
|
|
60
|
-
headers: expect.objectContaining({
|
|
61
|
-
Authorization: 'Token recall-api-key',
|
|
62
|
-
'Content-Type': 'application/json',
|
|
63
|
-
}),
|
|
64
|
-
}),
|
|
65
|
-
);
|
|
66
|
-
expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({
|
|
67
|
-
meeting_url: 'https://meet.google.com/abc-defg-hij',
|
|
68
|
-
join_at: '2026-01-01T13:00:00.000Z',
|
|
69
|
-
bot_name: 'Call Recorder',
|
|
70
|
-
recording_config: {
|
|
71
|
-
video_mixed_mp4: {},
|
|
72
|
-
audio_mixed_mp3: {},
|
|
73
|
-
retention: { type: 'timed', hours: 166 },
|
|
74
|
-
},
|
|
75
|
-
metadata: RECALL_ROUTING_METADATA,
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('uses the configured Recall recording retention hours when scheduling a bot', async () => {
|
|
80
|
-
process.env[CALL_RECORDER_RECORDING_RETENTION_HOURS_ENV_VAR_NAME] = '240';
|
|
81
|
-
|
|
82
|
-
const result = await scheduleRecallBot({
|
|
83
|
-
meetingUrl: 'https://meet.google.com/abc-defg-hij',
|
|
84
|
-
joinAt: '2026-01-01T13:00:00.000Z',
|
|
85
|
-
metadata: RECALL_ROUTING_METADATA,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
expect(result).toEqual({ ok: true, externalBotId: 'recall-bot-id' });
|
|
89
|
-
expect(
|
|
90
|
-
JSON.parse(fetchMock.mock.calls[0][1].body).recording_config,
|
|
91
|
-
).toEqual({
|
|
92
|
-
video_mixed_mp4: {},
|
|
93
|
-
audio_mixed_mp3: {},
|
|
94
|
-
retention: { type: 'timed', hours: 240 },
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('falls back to safe Recall recording retention hours when the configured value is invalid', async () => {
|
|
99
|
-
process.env[CALL_RECORDER_RECORDING_RETENTION_HOURS_ENV_VAR_NAME] =
|
|
100
|
-
'seven-days';
|
|
101
|
-
|
|
102
|
-
const result = await scheduleRecallBot({
|
|
103
|
-
meetingUrl: 'https://meet.google.com/abc-defg-hij',
|
|
104
|
-
joinAt: '2026-01-01T13:00:00.000Z',
|
|
105
|
-
metadata: RECALL_ROUTING_METADATA,
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
expect(result).toEqual({ ok: true, externalBotId: 'recall-bot-id' });
|
|
109
|
-
expect(
|
|
110
|
-
JSON.parse(fetchMock.mock.calls[0][1].body).recording_config,
|
|
111
|
-
).toEqual({
|
|
112
|
-
video_mixed_mp4: {},
|
|
113
|
-
audio_mixed_mp3: {},
|
|
114
|
-
retention: { type: 'timed', hours: 166 },
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('fails when the create response does not include a bot id', async () => {
|
|
119
|
-
fetchMock.mockResolvedValue({
|
|
120
|
-
ok: true,
|
|
121
|
-
status: 201,
|
|
122
|
-
json: async () => ({}),
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const result = await scheduleRecallBot({
|
|
126
|
-
meetingUrl: 'https://meet.google.com/abc-defg-hij',
|
|
127
|
-
joinAt: '2026-01-01T13:00:00.000Z',
|
|
128
|
-
metadata: RECALL_ROUTING_METADATA,
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
expect(result).toEqual({
|
|
132
|
-
ok: false,
|
|
133
|
-
status: null,
|
|
134
|
-
errorMessage:
|
|
135
|
-
'Recall API created a bot but the response did not include a bot id',
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('reports the HTTP status when rescheduling a bot that no longer exists', async () => {
|
|
140
|
-
fetchMock.mockResolvedValue({
|
|
141
|
-
ok: false,
|
|
142
|
-
status: 404,
|
|
143
|
-
json: async () => ({ detail: 'Not found.' }),
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
const result = await rescheduleRecallBot({
|
|
147
|
-
externalBotId: 'recall-bot-gone',
|
|
148
|
-
meetingUrl: 'https://meet.google.com/abc-defg-hij',
|
|
149
|
-
joinAt: '2026-01-01T13:00:00.000Z',
|
|
150
|
-
metadata: RECALL_ROUTING_METADATA,
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
expect(result).toEqual({
|
|
154
|
-
ok: false,
|
|
155
|
-
status: 404,
|
|
156
|
-
errorMessage:
|
|
157
|
-
'Recall API responded with HTTP 404: {"detail":"Not found."}',
|
|
158
|
-
});
|
|
159
|
-
expect(
|
|
160
|
-
JSON.parse(fetchMock.mock.calls[0][1].body).recording_config,
|
|
161
|
-
).toEqual({
|
|
162
|
-
video_mixed_mp4: {},
|
|
163
|
-
audio_mixed_mp3: {},
|
|
164
|
-
retention: { type: 'timed', hours: 166 },
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('does not duplicate an existing Token authorization prefix', async () => {
|
|
169
|
-
getRecallApiConfigMock.mockReturnValue({
|
|
170
|
-
success: true,
|
|
171
|
-
config: {
|
|
172
|
-
apiKey: 'Token recall-api-key',
|
|
173
|
-
baseUrl: 'https://ap-northeast-1.recall.ai/api/v1',
|
|
174
|
-
botName: 'Call Recorder',
|
|
175
|
-
},
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
await scheduleRecallBot({
|
|
179
|
-
meetingUrl: 'https://meet.google.com/abc-defg-hij',
|
|
180
|
-
joinAt: '2026-01-01T13:00:00.000Z',
|
|
181
|
-
metadata: RECALL_ROUTING_METADATA,
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
expect(fetchMock).toHaveBeenCalledWith(
|
|
185
|
-
expect.any(String),
|
|
186
|
-
expect.objectContaining({
|
|
187
|
-
headers: expect.objectContaining({
|
|
188
|
-
Authorization: 'Token recall-api-key',
|
|
189
|
-
}),
|
|
190
|
-
}),
|
|
191
|
-
);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('lists scheduled bots in a join-at window and follows pagination', async () => {
|
|
195
|
-
fetchMock
|
|
196
|
-
.mockResolvedValueOnce({
|
|
197
|
-
ok: true,
|
|
198
|
-
status: 200,
|
|
199
|
-
json: async () => ({
|
|
200
|
-
next: 'https://ap-northeast-1.recall.ai/api/v1/bot/?cursor=page-2',
|
|
201
|
-
results: [
|
|
202
|
-
{ id: 'bot-1', metadata: { twentyCallRecordingId: 'recording-1' } },
|
|
203
|
-
],
|
|
204
|
-
}),
|
|
205
|
-
})
|
|
206
|
-
.mockResolvedValueOnce({
|
|
207
|
-
ok: true,
|
|
208
|
-
status: 200,
|
|
209
|
-
json: async () => ({
|
|
210
|
-
next: null,
|
|
211
|
-
results: [{ id: 'bot-2' }],
|
|
212
|
-
}),
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
const result = await listScheduledRecallBots({
|
|
216
|
-
joinAtAfter: '2026-01-01T08:00:00.000Z',
|
|
217
|
-
joinAtBefore: '2026-01-02T12:00:00.000Z',
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
expect(result).toEqual({
|
|
221
|
-
ok: true,
|
|
222
|
-
bots: [
|
|
223
|
-
{ id: 'bot-1', metadata: { twentyCallRecordingId: 'recording-1' } },
|
|
224
|
-
{ id: 'bot-2', metadata: {} },
|
|
225
|
-
],
|
|
226
|
-
});
|
|
227
|
-
expect(fetchMock).toHaveBeenNthCalledWith(
|
|
228
|
-
1,
|
|
229
|
-
'https://ap-northeast-1.recall.ai/api/v1/bot/?join_at_after=2026-01-01T08%3A00%3A00.000Z&join_at_before=2026-01-02T12%3A00%3A00.000Z',
|
|
230
|
-
expect.objectContaining({ method: 'GET' }),
|
|
231
|
-
);
|
|
232
|
-
expect(fetchMock).toHaveBeenNthCalledWith(
|
|
233
|
-
2,
|
|
234
|
-
'https://ap-northeast-1.recall.ai/api/v1/bot/?cursor=page-2',
|
|
235
|
-
expect.objectContaining({ method: 'GET' }),
|
|
236
|
-
);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it('fails the scheduled bot list when the pagination cap would truncate results', async () => {
|
|
240
|
-
for (let pageIndex = 1; pageIndex <= 10; pageIndex++) {
|
|
241
|
-
fetchMock.mockResolvedValueOnce({
|
|
242
|
-
ok: true,
|
|
243
|
-
status: 200,
|
|
244
|
-
json: async () => ({
|
|
245
|
-
next: `https://ap-northeast-1.recall.ai/api/v1/bot/?cursor=page-${pageIndex + 1}`,
|
|
246
|
-
results: [{ id: `bot-${pageIndex}` }],
|
|
247
|
-
}),
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const result = await listScheduledRecallBots({
|
|
252
|
-
joinAtAfter: '2026-01-01T08:00:00.000Z',
|
|
253
|
-
joinAtBefore: '2026-01-02T12:00:00.000Z',
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
expect(result).toEqual({
|
|
257
|
-
ok: false,
|
|
258
|
-
status: null,
|
|
259
|
-
errorMessage: 'Recall bot list exceeded 10 pages',
|
|
260
|
-
});
|
|
261
|
-
expect(fetchMock).toHaveBeenCalledTimes(10);
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it('stops paginating when the next link points outside the configured region', async () => {
|
|
265
|
-
fetchMock.mockResolvedValue({
|
|
266
|
-
ok: true,
|
|
267
|
-
status: 200,
|
|
268
|
-
json: async () => ({
|
|
269
|
-
next: 'https://evil.example.com/api/v1/bot/?cursor=page-2',
|
|
270
|
-
results: [{ id: 'bot-1' }],
|
|
271
|
-
}),
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
const result = await listScheduledRecallBots({
|
|
275
|
-
joinAtAfter: '2026-01-01T08:00:00.000Z',
|
|
276
|
-
joinAtBefore: '2026-01-02T12:00:00.000Z',
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
expect(result).toEqual({
|
|
280
|
-
ok: true,
|
|
281
|
-
bots: [{ id: 'bot-1', metadata: {} }],
|
|
282
|
-
});
|
|
283
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
it('cancels a scheduled Recall bot request', async () => {
|
|
287
|
-
fetchMock.mockResolvedValue({
|
|
288
|
-
ok: true,
|
|
289
|
-
status: 204,
|
|
290
|
-
json: async () => ({}),
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
const result = await cancelRecallBot({
|
|
294
|
-
externalBotId: 'recall-bot-id',
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
expect(result).toEqual({ ok: true });
|
|
298
|
-
expect(fetchMock).toHaveBeenCalledWith(
|
|
299
|
-
'https://ap-northeast-1.recall.ai/api/v1/bot/recall-bot-id/',
|
|
300
|
-
expect.objectContaining({ method: 'DELETE' }),
|
|
301
|
-
);
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
it('ejects a bot through the leave_call endpoint', async () => {
|
|
305
|
-
fetchMock.mockResolvedValue({
|
|
306
|
-
ok: true,
|
|
307
|
-
status: 200,
|
|
308
|
-
json: async () => ({ id: 'recall-bot-id' }),
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
const result = await ejectRecallBot({
|
|
312
|
-
externalBotId: 'recall-bot-id',
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
expect(result).toEqual({ ok: true });
|
|
316
|
-
expect(fetchMock).toHaveBeenCalledWith(
|
|
317
|
-
'https://ap-northeast-1.recall.ai/api/v1/bot/recall-bot-id/leave_call/',
|
|
318
|
-
expect.objectContaining({ method: 'POST' }),
|
|
319
|
-
);
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it('fetches a single bot and returns the raw response', async () => {
|
|
323
|
-
const botResponse = {
|
|
324
|
-
id: 'recall-bot-id',
|
|
325
|
-
status_changes: [{ code: 'done' }],
|
|
326
|
-
recordings: [{ id: 'recall-recording-id' }],
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
fetchMock.mockResolvedValue({
|
|
330
|
-
ok: true,
|
|
331
|
-
status: 200,
|
|
332
|
-
json: async () => botResponse,
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
const result = await getRecallBot({ externalBotId: 'recall-bot-id' });
|
|
336
|
-
|
|
337
|
-
expect(result).toEqual({ ok: true, bot: botResponse });
|
|
338
|
-
expect(fetchMock).toHaveBeenCalledWith(
|
|
339
|
-
'https://ap-northeast-1.recall.ai/api/v1/bot/recall-bot-id/',
|
|
340
|
-
expect.objectContaining({ method: 'GET' }),
|
|
341
|
-
);
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
it('reports the HTTP status when fetching a bot that no longer exists', async () => {
|
|
345
|
-
fetchMock.mockResolvedValue({
|
|
346
|
-
ok: false,
|
|
347
|
-
status: 404,
|
|
348
|
-
json: async () => ({ detail: 'Not found.' }),
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
const result = await getRecallBot({ externalBotId: 'recall-bot-gone' });
|
|
352
|
-
|
|
353
|
-
expect(result).toEqual({
|
|
354
|
-
ok: false,
|
|
355
|
-
status: 404,
|
|
356
|
-
errorMessage:
|
|
357
|
-
'Recall API responded with HTTP 404: {"detail":"Not found."}',
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
it('lists transcripts for a recording id and normalizes status fields', async () => {
|
|
362
|
-
fetchMock.mockResolvedValue({
|
|
363
|
-
ok: true,
|
|
364
|
-
status: 200,
|
|
365
|
-
json: async () => ({
|
|
366
|
-
next: null,
|
|
367
|
-
results: [
|
|
368
|
-
{
|
|
369
|
-
id: 'recall-transcript-id',
|
|
370
|
-
status: { code: 'done', sub_code: null },
|
|
371
|
-
},
|
|
372
|
-
],
|
|
373
|
-
}),
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
const result = await listRecallTranscripts({
|
|
377
|
-
externalRecordingId: 'recall-recording-id',
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
expect(result).toEqual({
|
|
381
|
-
ok: true,
|
|
382
|
-
transcripts: [
|
|
383
|
-
{
|
|
384
|
-
id: 'recall-transcript-id',
|
|
385
|
-
statusCode: 'done',
|
|
386
|
-
statusSubCode: undefined,
|
|
387
|
-
},
|
|
388
|
-
],
|
|
389
|
-
});
|
|
390
|
-
expect(fetchMock).toHaveBeenCalledWith(
|
|
391
|
-
'https://ap-northeast-1.recall.ai/api/v1/transcript/?recording_id=recall-recording-id',
|
|
392
|
-
expect.objectContaining({ method: 'GET' }),
|
|
393
|
-
);
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
it('follows transcript list pagination within the configured Recall region', async () => {
|
|
397
|
-
fetchMock
|
|
398
|
-
.mockResolvedValueOnce({
|
|
399
|
-
ok: true,
|
|
400
|
-
status: 200,
|
|
401
|
-
json: async () => ({
|
|
402
|
-
next: 'https://ap-northeast-1.recall.ai/api/v1/transcript/?cursor=page-2',
|
|
403
|
-
results: [
|
|
404
|
-
{
|
|
405
|
-
id: 'recall-transcript-id-1',
|
|
406
|
-
status: { code: 'processing' },
|
|
407
|
-
},
|
|
408
|
-
],
|
|
409
|
-
}),
|
|
410
|
-
})
|
|
411
|
-
.mockResolvedValueOnce({
|
|
412
|
-
ok: true,
|
|
413
|
-
status: 200,
|
|
414
|
-
json: async () => ({
|
|
415
|
-
next: null,
|
|
416
|
-
results: [
|
|
417
|
-
{
|
|
418
|
-
id: 'recall-transcript-id-2',
|
|
419
|
-
status: { code: 'failed', sub_code: 'audio_missing' },
|
|
420
|
-
},
|
|
421
|
-
],
|
|
422
|
-
}),
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
const result = await listRecallTranscripts({
|
|
426
|
-
externalRecordingId: 'recall-recording-id',
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
expect(result).toEqual({
|
|
430
|
-
ok: true,
|
|
431
|
-
transcripts: [
|
|
432
|
-
{
|
|
433
|
-
id: 'recall-transcript-id-1',
|
|
434
|
-
statusCode: 'processing',
|
|
435
|
-
statusSubCode: undefined,
|
|
436
|
-
},
|
|
437
|
-
{
|
|
438
|
-
id: 'recall-transcript-id-2',
|
|
439
|
-
statusCode: 'failed',
|
|
440
|
-
statusSubCode: 'audio_missing',
|
|
441
|
-
},
|
|
442
|
-
],
|
|
443
|
-
});
|
|
444
|
-
expect(fetchMock).toHaveBeenNthCalledWith(
|
|
445
|
-
2,
|
|
446
|
-
'https://ap-northeast-1.recall.ai/api/v1/transcript/?cursor=page-2',
|
|
447
|
-
expect.objectContaining({ method: 'GET' }),
|
|
448
|
-
);
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
it('rejects malformed transcript lists', async () => {
|
|
452
|
-
fetchMock.mockResolvedValue({
|
|
453
|
-
ok: true,
|
|
454
|
-
status: 200,
|
|
455
|
-
json: async () => ({
|
|
456
|
-
next: null,
|
|
457
|
-
results: [{}],
|
|
458
|
-
}),
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
const result = await listRecallTranscripts({
|
|
462
|
-
externalRecordingId: 'recall-recording-id',
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
expect(result).toEqual({
|
|
466
|
-
ok: false,
|
|
467
|
-
status: 200,
|
|
468
|
-
errorMessage: 'Recall API returned malformed transcript list',
|
|
469
|
-
});
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
it('creates an async transcript with the locked provider settings', async () => {
|
|
473
|
-
fetchMock.mockResolvedValue({
|
|
474
|
-
ok: true,
|
|
475
|
-
status: 201,
|
|
476
|
-
json: async () => ({ id: 'recall-transcript-id' }),
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
const result = await createAsyncRecallTranscript({
|
|
480
|
-
externalRecordingId: 'recall-recording-id',
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
expect(result).toEqual({ ok: true, transcriptId: 'recall-transcript-id' });
|
|
484
|
-
expect(fetchMock).toHaveBeenCalledWith(
|
|
485
|
-
'https://ap-northeast-1.recall.ai/api/v1/recording/recall-recording-id/create_transcript/',
|
|
486
|
-
expect.objectContaining({ method: 'POST' }),
|
|
487
|
-
);
|
|
488
|
-
expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({
|
|
489
|
-
provider: { recallai_async: { language_code: 'auto' } },
|
|
490
|
-
diarization: { use_separate_streams_when_available: true },
|
|
491
|
-
});
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
it('does not retry async transcript creation failures', async () => {
|
|
495
|
-
fetchMock.mockResolvedValue({
|
|
496
|
-
ok: false,
|
|
497
|
-
status: 503,
|
|
498
|
-
json: async () => ({ detail: 'service unavailable' }),
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
const result = await createAsyncRecallTranscript({
|
|
502
|
-
externalRecordingId: 'recall-recording-id',
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
expect(result).toEqual({
|
|
506
|
-
ok: false,
|
|
507
|
-
status: 503,
|
|
508
|
-
errorMessage:
|
|
509
|
-
'Recall API responded with HTTP 503: {"detail":"service unavailable"}',
|
|
510
|
-
});
|
|
511
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
it('fails when the transcript creation response has no id', async () => {
|
|
515
|
-
fetchMock.mockResolvedValue({
|
|
516
|
-
ok: true,
|
|
517
|
-
status: 201,
|
|
518
|
-
json: async () => ({}),
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
const result = await createAsyncRecallTranscript({
|
|
522
|
-
externalRecordingId: 'recall-recording-id',
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
expect(result).toEqual({
|
|
526
|
-
ok: false,
|
|
527
|
-
status: null,
|
|
528
|
-
errorMessage:
|
|
529
|
-
'Recall API created a transcript but the response did not include a transcript id',
|
|
530
|
-
});
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
it('retrieves transcript details with the download URL and status', async () => {
|
|
534
|
-
fetchMock.mockResolvedValue({
|
|
535
|
-
ok: true,
|
|
536
|
-
status: 200,
|
|
537
|
-
json: async () => ({
|
|
538
|
-
id: 'recall-transcript-id',
|
|
539
|
-
status: { code: 'done', sub_code: null },
|
|
540
|
-
data: {
|
|
541
|
-
download_url: 'https://recall-transcripts.example.com/transcript',
|
|
542
|
-
},
|
|
543
|
-
}),
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
const result = await retrieveRecallTranscript({
|
|
547
|
-
transcriptId: 'recall-transcript-id',
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
expect(result).toEqual({
|
|
551
|
-
ok: true,
|
|
552
|
-
transcript: {
|
|
553
|
-
downloadUrl: 'https://recall-transcripts.example.com/transcript',
|
|
554
|
-
statusCode: 'done',
|
|
555
|
-
statusSubCode: undefined,
|
|
556
|
-
},
|
|
557
|
-
});
|
|
558
|
-
expect(fetchMock).toHaveBeenCalledWith(
|
|
559
|
-
'https://ap-northeast-1.recall.ai/api/v1/transcript/recall-transcript-id/',
|
|
560
|
-
expect.objectContaining({ method: 'GET' }),
|
|
561
|
-
);
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
it('surfaces the failure sub code of an errored transcript', async () => {
|
|
565
|
-
fetchMock.mockResolvedValue({
|
|
566
|
-
ok: true,
|
|
567
|
-
status: 200,
|
|
568
|
-
json: async () => ({
|
|
569
|
-
id: 'recall-transcript-id',
|
|
570
|
-
status: { code: 'error', sub_code: 'audio_missing' },
|
|
571
|
-
data: {},
|
|
572
|
-
}),
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
const result = await retrieveRecallTranscript({
|
|
576
|
-
transcriptId: 'recall-transcript-id',
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
expect(result).toEqual({
|
|
580
|
-
ok: true,
|
|
581
|
-
transcript: {
|
|
582
|
-
downloadUrl: undefined,
|
|
583
|
-
statusCode: 'error',
|
|
584
|
-
statusSubCode: 'audio_missing',
|
|
585
|
-
},
|
|
586
|
-
});
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
it('rejects malformed transcript details', async () => {
|
|
590
|
-
fetchMock
|
|
591
|
-
.mockResolvedValueOnce({
|
|
592
|
-
ok: true,
|
|
593
|
-
status: 200,
|
|
594
|
-
json: async () => ({
|
|
595
|
-
id: 'recall-transcript-id',
|
|
596
|
-
status: { code: 'done' },
|
|
597
|
-
data: {},
|
|
598
|
-
}),
|
|
599
|
-
})
|
|
600
|
-
.mockResolvedValueOnce({
|
|
601
|
-
ok: true,
|
|
602
|
-
status: 200,
|
|
603
|
-
json: async () => ({
|
|
604
|
-
id: 'recall-transcript-id',
|
|
605
|
-
data: {},
|
|
606
|
-
}),
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
await expect(
|
|
610
|
-
retrieveRecallTranscript({ transcriptId: 'recall-transcript-id' }),
|
|
611
|
-
).resolves.toEqual({
|
|
612
|
-
ok: false,
|
|
613
|
-
status: 200,
|
|
614
|
-
errorMessage: 'Recall API returned malformed transcript details',
|
|
615
|
-
});
|
|
616
|
-
await expect(
|
|
617
|
-
retrieveRecallTranscript({ transcriptId: 'recall-transcript-id' }),
|
|
618
|
-
).resolves.toEqual({
|
|
619
|
-
ok: false,
|
|
620
|
-
status: 200,
|
|
621
|
-
errorMessage: 'Recall API returned malformed transcript details',
|
|
622
|
-
});
|
|
623
|
-
});
|
|
624
|
-
|
|
625
|
-
describe('transient failure retries', () => {
|
|
626
|
-
beforeEach(() => {
|
|
627
|
-
vi.useFakeTimers();
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
afterEach(() => {
|
|
631
|
-
vi.useRealTimers();
|
|
632
|
-
});
|
|
633
|
-
|
|
634
|
-
it('retries a network failure and succeeds on the next attempt', async () => {
|
|
635
|
-
fetchMock.mockRejectedValueOnce(new Error('socket hang up'));
|
|
636
|
-
fetchMock.mockResolvedValueOnce({
|
|
637
|
-
ok: true,
|
|
638
|
-
status: 200,
|
|
639
|
-
json: async () => ({ id: 'recall-bot-id' }),
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
const resultPromise = getRecallBot({ externalBotId: 'recall-bot-id' });
|
|
643
|
-
|
|
644
|
-
await vi.runAllTimersAsync();
|
|
645
|
-
|
|
646
|
-
expect(await resultPromise).toEqual({
|
|
647
|
-
ok: true,
|
|
648
|
-
bot: { id: 'recall-bot-id' },
|
|
649
|
-
});
|
|
650
|
-
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
it('retries a 503 response and succeeds on the next attempt', async () => {
|
|
654
|
-
fetchMock.mockResolvedValueOnce({
|
|
655
|
-
ok: false,
|
|
656
|
-
status: 503,
|
|
657
|
-
json: async () => ({ detail: 'service unavailable' }),
|
|
658
|
-
});
|
|
659
|
-
fetchMock.mockResolvedValueOnce({
|
|
660
|
-
ok: true,
|
|
661
|
-
status: 200,
|
|
662
|
-
json: async () => ({ id: 'recall-bot-id' }),
|
|
663
|
-
});
|
|
664
|
-
|
|
665
|
-
const resultPromise = getRecallBot({ externalBotId: 'recall-bot-id' });
|
|
666
|
-
|
|
667
|
-
await vi.runAllTimersAsync();
|
|
668
|
-
|
|
669
|
-
expect(await resultPromise).toEqual({
|
|
670
|
-
ok: true,
|
|
671
|
-
bot: { id: 'recall-bot-id' },
|
|
672
|
-
});
|
|
673
|
-
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
it('gives up after the attempt budget on persistent server errors', async () => {
|
|
677
|
-
fetchMock.mockResolvedValue({
|
|
678
|
-
ok: false,
|
|
679
|
-
status: 500,
|
|
680
|
-
json: async () => ({ detail: 'server error' }),
|
|
681
|
-
});
|
|
682
|
-
|
|
683
|
-
const resultPromise = getRecallBot({ externalBotId: 'recall-bot-id' });
|
|
684
|
-
|
|
685
|
-
await vi.runAllTimersAsync();
|
|
686
|
-
|
|
687
|
-
expect(await resultPromise).toEqual({
|
|
688
|
-
ok: false,
|
|
689
|
-
status: 500,
|
|
690
|
-
errorMessage:
|
|
691
|
-
'Recall API responded with HTTP 500: {"detail":"server error"}',
|
|
692
|
-
});
|
|
693
|
-
expect(fetchMock).toHaveBeenCalledTimes(3);
|
|
694
|
-
});
|
|
695
|
-
|
|
696
|
-
it('does not retry client errors', async () => {
|
|
697
|
-
fetchMock.mockResolvedValue({
|
|
698
|
-
ok: false,
|
|
699
|
-
status: 400,
|
|
700
|
-
json: async () => ({ detail: 'bad request' }),
|
|
701
|
-
});
|
|
702
|
-
|
|
703
|
-
const result = await getRecallBot({ externalBotId: 'recall-bot-id' });
|
|
704
|
-
|
|
705
|
-
expect(result).toEqual({
|
|
706
|
-
ok: false,
|
|
707
|
-
status: 400,
|
|
708
|
-
errorMessage:
|
|
709
|
-
'Recall API responded with HTTP 400: {"detail":"bad request"}',
|
|
710
|
-
});
|
|
711
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
it('does not retry an allowed 404 on cancel', async () => {
|
|
715
|
-
fetchMock.mockResolvedValue({
|
|
716
|
-
ok: false,
|
|
717
|
-
status: 404,
|
|
718
|
-
json: async () => ({ detail: 'not found' }),
|
|
719
|
-
});
|
|
720
|
-
|
|
721
|
-
const result = await cancelRecallBot({
|
|
722
|
-
externalBotId: 'recall-bot-id',
|
|
723
|
-
});
|
|
724
|
-
|
|
725
|
-
expect(result).toEqual({ ok: true });
|
|
726
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
727
|
-
});
|
|
728
|
-
|
|
729
|
-
it('does not retry an allowed 404 on eject', async () => {
|
|
730
|
-
fetchMock.mockResolvedValue({
|
|
731
|
-
ok: false,
|
|
732
|
-
status: 404,
|
|
733
|
-
json: async () => ({ detail: 'not found' }),
|
|
734
|
-
});
|
|
735
|
-
|
|
736
|
-
const result = await ejectRecallBot({
|
|
737
|
-
externalBotId: 'recall-bot-id',
|
|
738
|
-
});
|
|
739
|
-
|
|
740
|
-
expect(result).toEqual({ ok: true });
|
|
741
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
742
|
-
});
|
|
743
|
-
});
|
|
744
|
-
});
|