@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,141 +0,0 @@
|
|
|
1
|
-
// Duplicates minimal twenty-ui Avatar logic for this app.
|
|
2
|
-
// Remove once twenty-ui can be imported safely in front components.
|
|
3
|
-
import styled from '@emotion/styled';
|
|
4
|
-
import { useState } from 'react';
|
|
5
|
-
|
|
6
|
-
import { recordingThemeCssVariables } from 'src/front-components/constants/recording-theme-css-variables';
|
|
7
|
-
import { isNonEmptyString } from 'src/logic-functions/utils/is-non-empty-string.util';
|
|
8
|
-
|
|
9
|
-
const AVATAR_COLOR_NAMES = [
|
|
10
|
-
'red',
|
|
11
|
-
'ruby',
|
|
12
|
-
'crimson',
|
|
13
|
-
'tomato',
|
|
14
|
-
'orange',
|
|
15
|
-
'amber',
|
|
16
|
-
'yellow',
|
|
17
|
-
'lime',
|
|
18
|
-
'grass',
|
|
19
|
-
'green',
|
|
20
|
-
'jade',
|
|
21
|
-
'mint',
|
|
22
|
-
'turquoise',
|
|
23
|
-
'cyan',
|
|
24
|
-
'sky',
|
|
25
|
-
'blue',
|
|
26
|
-
'iris',
|
|
27
|
-
'violet',
|
|
28
|
-
'purple',
|
|
29
|
-
'plum',
|
|
30
|
-
'pink',
|
|
31
|
-
'bronze',
|
|
32
|
-
'gold',
|
|
33
|
-
'brown',
|
|
34
|
-
'gray',
|
|
35
|
-
] as const;
|
|
36
|
-
|
|
37
|
-
const StyledAvatar = styled.div<{
|
|
38
|
-
$backgroundColor: string;
|
|
39
|
-
$color: string;
|
|
40
|
-
}>`
|
|
41
|
-
align-items: center;
|
|
42
|
-
background: ${({ $backgroundColor }) => $backgroundColor};
|
|
43
|
-
border-radius: 50px;
|
|
44
|
-
box-sizing: border-box;
|
|
45
|
-
color: ${({ $color }) => $color};
|
|
46
|
-
display: flex;
|
|
47
|
-
flex-shrink: 0;
|
|
48
|
-
font-size: ${recordingThemeCssVariables.font.sizeXs};
|
|
49
|
-
font-weight: ${recordingThemeCssVariables.font.weightMedium};
|
|
50
|
-
height: 16px;
|
|
51
|
-
justify-content: center;
|
|
52
|
-
line-height: 15px;
|
|
53
|
-
overflow: hidden;
|
|
54
|
-
width: 16px;
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
const StyledAvatarImage = styled.img`
|
|
58
|
-
height: 100%;
|
|
59
|
-
object-fit: cover;
|
|
60
|
-
width: 100%;
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
type TranscriptSpeakerAvatarProps = {
|
|
64
|
-
speakerName: string;
|
|
65
|
-
avatarUrl: string | undefined;
|
|
66
|
-
placeholderColorSeed: string;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const getSpeakerInitial = (speakerName: string) =>
|
|
70
|
-
speakerName.trim().charAt(0).toUpperCase() || '-';
|
|
71
|
-
|
|
72
|
-
export const TranscriptSpeakerAvatar = ({
|
|
73
|
-
speakerName,
|
|
74
|
-
avatarUrl,
|
|
75
|
-
placeholderColorSeed,
|
|
76
|
-
}: TranscriptSpeakerAvatarProps) => {
|
|
77
|
-
const [erroredAvatarUrl, setErroredAvatarUrl] = useState<string | undefined>(
|
|
78
|
-
undefined,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const shouldShowAvatarImage =
|
|
82
|
-
isNonEmptyString(avatarUrl) && erroredAvatarUrl !== avatarUrl;
|
|
83
|
-
|
|
84
|
-
const handleAvatarImageError = () => {
|
|
85
|
-
if (isNonEmptyString(avatarUrl)) {
|
|
86
|
-
setErroredAvatarUrl(avatarUrl);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const avatarPlaceholderColor = getAvatarPlaceholderColor({
|
|
91
|
-
placeholderColorSeed,
|
|
92
|
-
variant: 12,
|
|
93
|
-
});
|
|
94
|
-
const avatarPlaceholderBackgroundColor = getAvatarPlaceholderColor({
|
|
95
|
-
placeholderColorSeed,
|
|
96
|
-
variant: 4,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<StyledAvatar
|
|
101
|
-
aria-hidden="true"
|
|
102
|
-
$backgroundColor={avatarPlaceholderBackgroundColor}
|
|
103
|
-
$color={avatarPlaceholderColor}
|
|
104
|
-
>
|
|
105
|
-
{shouldShowAvatarImage ? (
|
|
106
|
-
<StyledAvatarImage
|
|
107
|
-
src={avatarUrl}
|
|
108
|
-
alt=""
|
|
109
|
-
onError={handleAvatarImageError}
|
|
110
|
-
/>
|
|
111
|
-
) : (
|
|
112
|
-
getSpeakerInitial(speakerName)
|
|
113
|
-
)}
|
|
114
|
-
</StyledAvatar>
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const getAvatarPlaceholderColor = ({
|
|
119
|
-
placeholderColorSeed,
|
|
120
|
-
variant,
|
|
121
|
-
}: {
|
|
122
|
-
placeholderColorSeed: string;
|
|
123
|
-
variant: 4 | 12;
|
|
124
|
-
}): string => {
|
|
125
|
-
const avatarColorName =
|
|
126
|
-
AVATAR_COLOR_NAMES[
|
|
127
|
-
Math.abs(hashString(placeholderColorSeed)) % AVATAR_COLOR_NAMES.length
|
|
128
|
-
];
|
|
129
|
-
|
|
130
|
-
return `var(--t-color-${avatarColorName}${variant})`;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const hashString = (value: string): number => {
|
|
134
|
-
let hash = 0;
|
|
135
|
-
|
|
136
|
-
for (let valueIndex = 0; valueIndex < value.length; valueIndex++) {
|
|
137
|
-
hash = value.charCodeAt(valueIndex) + ((hash << 5) - hash);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return hash;
|
|
141
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Duplicates minimal twenty-ui Chip logic for this app.
|
|
2
|
-
// Remove once twenty-ui can be imported safely in front components.
|
|
3
|
-
import styled from '@emotion/styled';
|
|
4
|
-
|
|
5
|
-
import { TranscriptSpeakerAvatar } from 'src/front-components/components/TranscriptSpeakerAvatar';
|
|
6
|
-
import { recordingThemeCssVariables } from 'src/front-components/constants/recording-theme-css-variables';
|
|
7
|
-
|
|
8
|
-
const StyledSpeakerChip = styled.span`
|
|
9
|
-
align-items: center;
|
|
10
|
-
border-radius: ${recordingThemeCssVariables.border.radiusSm};
|
|
11
|
-
color: ${recordingThemeCssVariables.font.colorPrimary};
|
|
12
|
-
display: inline-flex;
|
|
13
|
-
font-size: ${recordingThemeCssVariables.font.sizeSm};
|
|
14
|
-
font-weight: ${recordingThemeCssVariables.font.weightMedium};
|
|
15
|
-
gap: ${recordingThemeCssVariables.spacing[1]};
|
|
16
|
-
line-height: 1.4;
|
|
17
|
-
max-width: 100%;
|
|
18
|
-
min-width: 0;
|
|
19
|
-
text-decoration: none;
|
|
20
|
-
white-space: nowrap;
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
const StyledSpeakerName = styled.span`
|
|
24
|
-
flex-shrink: 1;
|
|
25
|
-
min-width: 0;
|
|
26
|
-
overflow: hidden;
|
|
27
|
-
text-overflow: ellipsis;
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
type TranscriptSpeakerChipProps = {
|
|
31
|
-
speakerName: string;
|
|
32
|
-
avatarUrl: string | undefined;
|
|
33
|
-
placeholderColorSeed: string;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const TranscriptSpeakerChip = ({
|
|
37
|
-
speakerName,
|
|
38
|
-
avatarUrl,
|
|
39
|
-
placeholderColorSeed,
|
|
40
|
-
}: TranscriptSpeakerChipProps) => {
|
|
41
|
-
return (
|
|
42
|
-
<StyledSpeakerChip>
|
|
43
|
-
<TranscriptSpeakerAvatar
|
|
44
|
-
speakerName={speakerName}
|
|
45
|
-
avatarUrl={avatarUrl}
|
|
46
|
-
placeholderColorSeed={placeholderColorSeed}
|
|
47
|
-
/>
|
|
48
|
-
<StyledSpeakerName>{speakerName}</StyledSpeakerName>
|
|
49
|
-
</StyledSpeakerChip>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Avoid the SDK UI entrypoint until its bundle is safe for the browser runtime.
|
|
2
|
-
export const recordingThemeCssVariables = {
|
|
3
|
-
accent: {
|
|
4
|
-
primary: 'var(--t-accent-accent9)',
|
|
5
|
-
},
|
|
6
|
-
background: {
|
|
7
|
-
primary: 'var(--t-background-primary)',
|
|
8
|
-
secondary: 'var(--t-background-secondary)',
|
|
9
|
-
transparentBlue: 'var(--t-background-transparent-blue)',
|
|
10
|
-
transparentDanger: 'var(--t-background-transparent-danger)',
|
|
11
|
-
},
|
|
12
|
-
border: {
|
|
13
|
-
colorDanger: 'var(--t-border-color-danger)',
|
|
14
|
-
colorLight: 'var(--t-border-color-light)',
|
|
15
|
-
colorMedium: 'var(--t-border-color-medium)',
|
|
16
|
-
radiusMd: 'var(--t-border-radius-md)',
|
|
17
|
-
radiusSm: 'var(--t-border-radius-sm)',
|
|
18
|
-
},
|
|
19
|
-
boxShadow: {
|
|
20
|
-
light: 'var(--t-box-shadow-light)',
|
|
21
|
-
},
|
|
22
|
-
font: {
|
|
23
|
-
colorDanger: 'var(--t-font-color-danger)',
|
|
24
|
-
colorPrimary: 'var(--t-font-color-primary)',
|
|
25
|
-
colorSecondary: 'var(--t-font-color-secondary)',
|
|
26
|
-
colorTertiary: 'var(--t-font-color-tertiary)',
|
|
27
|
-
family: 'var(--t-font-family)',
|
|
28
|
-
sizeMd: 'var(--t-font-size-md)',
|
|
29
|
-
sizeSm: 'var(--t-font-size-sm)',
|
|
30
|
-
sizeXs: 'var(--t-font-size-xs)',
|
|
31
|
-
weightMedium: 'var(--t-font-weight-medium)',
|
|
32
|
-
},
|
|
33
|
-
spacing: {
|
|
34
|
-
1: 'var(--t-spacing-1)',
|
|
35
|
-
2: 'var(--t-spacing-2)',
|
|
36
|
-
3: 'var(--t-spacing-3)',
|
|
37
|
-
4: 'var(--t-spacing-4)',
|
|
38
|
-
6: 'var(--t-spacing-6)',
|
|
39
|
-
},
|
|
40
|
-
} as const;
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { CoreApiClient } from 'twenty-client-sdk/core';
|
|
3
|
-
|
|
4
|
-
import { type CalendarEventRecordingParticipant } from 'src/front-components/types/calendar-event-recording-participant.type';
|
|
5
|
-
import { getAbsoluteAvatarUrl } from 'src/front-components/utils/get-absolute-avatar-url.util';
|
|
6
|
-
import { isNonEmptyString } from 'src/logic-functions/utils/is-non-empty-string.util';
|
|
7
|
-
|
|
8
|
-
const CALENDAR_EVENT_PARTICIPANT_LOOKUP_LIMIT = 100;
|
|
9
|
-
|
|
10
|
-
type CalendarEventParticipantName = {
|
|
11
|
-
firstName?: string | null;
|
|
12
|
-
lastName?: string | null;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type CalendarEventParticipantRelatedRecord = {
|
|
16
|
-
id?: string | null;
|
|
17
|
-
avatarUrl?: string | null;
|
|
18
|
-
name?: CalendarEventParticipantName | null;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type CalendarEventParticipantNode = {
|
|
22
|
-
id: string;
|
|
23
|
-
displayName?: string | null;
|
|
24
|
-
handle?: string | null;
|
|
25
|
-
personId?: string | null;
|
|
26
|
-
workspaceMemberId?: string | null;
|
|
27
|
-
person?: CalendarEventParticipantRelatedRecord | null;
|
|
28
|
-
workspaceMember?: CalendarEventParticipantRelatedRecord | null;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
type CalendarEventParticipantEdge = {
|
|
32
|
-
node: CalendarEventParticipantNode;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
type UseCalendarEventParticipantsReturn = {
|
|
36
|
-
calendarEventParticipants: CalendarEventRecordingParticipant[];
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const useCalendarEventParticipants = (
|
|
40
|
-
calendarEventId: string | undefined,
|
|
41
|
-
): UseCalendarEventParticipantsReturn => {
|
|
42
|
-
const [calendarEventParticipants, setCalendarEventParticipants] = useState<
|
|
43
|
-
CalendarEventRecordingParticipant[]
|
|
44
|
-
>([]);
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (!isNonEmptyString(calendarEventId)) {
|
|
48
|
-
setCalendarEventParticipants([]);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
let cancelled = false;
|
|
53
|
-
|
|
54
|
-
const fetchCalendarEventParticipants = async () => {
|
|
55
|
-
try {
|
|
56
|
-
const client = new CoreApiClient();
|
|
57
|
-
const queryResult = await client.query({
|
|
58
|
-
calendarEventParticipants: {
|
|
59
|
-
__args: {
|
|
60
|
-
filter: { calendarEventId: { eq: calendarEventId } },
|
|
61
|
-
first: CALENDAR_EVENT_PARTICIPANT_LOOKUP_LIMIT,
|
|
62
|
-
},
|
|
63
|
-
edges: {
|
|
64
|
-
node: {
|
|
65
|
-
id: true,
|
|
66
|
-
displayName: true,
|
|
67
|
-
handle: true,
|
|
68
|
-
personId: true,
|
|
69
|
-
workspaceMemberId: true,
|
|
70
|
-
person: {
|
|
71
|
-
id: true,
|
|
72
|
-
avatarUrl: true,
|
|
73
|
-
name: {
|
|
74
|
-
firstName: true,
|
|
75
|
-
lastName: true,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
workspaceMember: {
|
|
79
|
-
id: true,
|
|
80
|
-
avatarUrl: true,
|
|
81
|
-
name: {
|
|
82
|
-
firstName: true,
|
|
83
|
-
lastName: true,
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
if (cancelled) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const calendarEventParticipantEdges = (queryResult
|
|
96
|
-
.calendarEventParticipants?.edges ??
|
|
97
|
-
[]) as CalendarEventParticipantEdge[];
|
|
98
|
-
|
|
99
|
-
setCalendarEventParticipants(
|
|
100
|
-
calendarEventParticipantEdges.map((calendarEventParticipantEdge) =>
|
|
101
|
-
mapCalendarEventParticipantNode(calendarEventParticipantEdge.node),
|
|
102
|
-
),
|
|
103
|
-
);
|
|
104
|
-
} catch {
|
|
105
|
-
if (cancelled) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
setCalendarEventParticipants([]);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
fetchCalendarEventParticipants();
|
|
114
|
-
|
|
115
|
-
return () => {
|
|
116
|
-
cancelled = true;
|
|
117
|
-
};
|
|
118
|
-
}, [calendarEventId]);
|
|
119
|
-
|
|
120
|
-
return { calendarEventParticipants };
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const mapCalendarEventParticipantNode = (
|
|
124
|
-
calendarEventParticipantNode: CalendarEventParticipantNode,
|
|
125
|
-
): CalendarEventRecordingParticipant => {
|
|
126
|
-
const personName = readFullName(calendarEventParticipantNode.person?.name);
|
|
127
|
-
const workspaceMemberName = readFullName(
|
|
128
|
-
calendarEventParticipantNode.workspaceMember?.name,
|
|
129
|
-
);
|
|
130
|
-
const calendarDisplayName = readOptionalString(
|
|
131
|
-
calendarEventParticipantNode.displayName,
|
|
132
|
-
);
|
|
133
|
-
const handle = readOptionalString(calendarEventParticipantNode.handle);
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
id: calendarEventParticipantNode.id,
|
|
137
|
-
avatarUrl: getAbsoluteAvatarUrl(
|
|
138
|
-
calendarEventParticipantNode.person?.avatarUrl ??
|
|
139
|
-
calendarEventParticipantNode.workspaceMember?.avatarUrl,
|
|
140
|
-
),
|
|
141
|
-
displayName:
|
|
142
|
-
personName ?? workspaceMemberName ?? calendarDisplayName ?? handle,
|
|
143
|
-
nameCandidates: [
|
|
144
|
-
calendarDisplayName,
|
|
145
|
-
personName,
|
|
146
|
-
workspaceMemberName,
|
|
147
|
-
handle,
|
|
148
|
-
].filter((nameCandidate): nameCandidate is string =>
|
|
149
|
-
isNonEmptyString(nameCandidate),
|
|
150
|
-
),
|
|
151
|
-
placeholderColorSeed:
|
|
152
|
-
calendarEventParticipantNode.workspaceMemberId ??
|
|
153
|
-
calendarEventParticipantNode.personId ??
|
|
154
|
-
calendarEventParticipantNode.id,
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const readFullName = (
|
|
159
|
-
name: CalendarEventParticipantName | null | undefined,
|
|
160
|
-
): string | undefined => {
|
|
161
|
-
const firstName = readOptionalString(name?.firstName);
|
|
162
|
-
const lastName = readOptionalString(name?.lastName);
|
|
163
|
-
const fullName = [firstName, lastName]
|
|
164
|
-
.filter((namePart): namePart is string => isNonEmptyString(namePart))
|
|
165
|
-
.join(' ');
|
|
166
|
-
|
|
167
|
-
return isNonEmptyString(fullName) ? fullName : undefined;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const readOptionalString = (
|
|
171
|
-
value: string | null | undefined,
|
|
172
|
-
): string | undefined => (isNonEmptyString(value) ? value.trim() : undefined);
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { isUndefined } from '@sniptt/guards';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import { CoreApiClient } from 'twenty-client-sdk/core';
|
|
4
|
-
|
|
5
|
-
type CalendarEventRecordingState = {
|
|
6
|
-
transcript: unknown;
|
|
7
|
-
videoFile: CalendarEventRecordingVideoFile | undefined;
|
|
8
|
-
isCalendarEventRecordingQueryLoading: boolean;
|
|
9
|
-
errorMessage: string | undefined;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type CalendarEventRecordingVideoFile = {
|
|
13
|
-
fileId: string;
|
|
14
|
-
label: string | null;
|
|
15
|
-
url: string | null;
|
|
16
|
-
extension: string | null;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type CalendarEventRecordingCallRecordingNode = {
|
|
20
|
-
id: string;
|
|
21
|
-
transcript: unknown;
|
|
22
|
-
video: CalendarEventRecordingVideoFile[] | null;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type CalendarEventRecordingCallRecordingEdge = {
|
|
26
|
-
node: CalendarEventRecordingCallRecordingNode;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const CALENDAR_EVENT_RECORDING_LOOKUP_LIMIT = 10;
|
|
30
|
-
const CALENDAR_EVENT_RECORDING_ERROR_MESSAGE = 'Please try again later.';
|
|
31
|
-
|
|
32
|
-
export const useCalendarEventRecording = (
|
|
33
|
-
calendarEventId: string | undefined,
|
|
34
|
-
): CalendarEventRecordingState => {
|
|
35
|
-
const [state, setState] = useState<CalendarEventRecordingState>({
|
|
36
|
-
transcript: undefined,
|
|
37
|
-
videoFile: undefined,
|
|
38
|
-
isCalendarEventRecordingQueryLoading: !isUndefined(calendarEventId),
|
|
39
|
-
errorMessage: undefined,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (isUndefined(calendarEventId)) {
|
|
44
|
-
setState({
|
|
45
|
-
transcript: undefined,
|
|
46
|
-
videoFile: undefined,
|
|
47
|
-
isCalendarEventRecordingQueryLoading: false,
|
|
48
|
-
errorMessage: undefined,
|
|
49
|
-
});
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let cancelled = false;
|
|
54
|
-
|
|
55
|
-
const fetchRecording = async () => {
|
|
56
|
-
setState({
|
|
57
|
-
transcript: undefined,
|
|
58
|
-
videoFile: undefined,
|
|
59
|
-
isCalendarEventRecordingQueryLoading: true,
|
|
60
|
-
errorMessage: undefined,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
const client = new CoreApiClient();
|
|
65
|
-
const queryResult = await client.query({
|
|
66
|
-
callRecordings: {
|
|
67
|
-
__args: {
|
|
68
|
-
filter: { calendarEventId: { eq: calendarEventId } },
|
|
69
|
-
orderBy: [{ startedAt: 'DescNullsLast' }],
|
|
70
|
-
first: CALENDAR_EVENT_RECORDING_LOOKUP_LIMIT,
|
|
71
|
-
},
|
|
72
|
-
edges: {
|
|
73
|
-
node: {
|
|
74
|
-
id: true,
|
|
75
|
-
transcript: true,
|
|
76
|
-
video: {
|
|
77
|
-
fileId: true,
|
|
78
|
-
label: true,
|
|
79
|
-
url: true,
|
|
80
|
-
extension: true,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
if (cancelled) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const callRecordingEdges = (queryResult.callRecordings?.edges ??
|
|
92
|
-
[]) as CalendarEventRecordingCallRecordingEdge[];
|
|
93
|
-
const callRecordingNodes = callRecordingEdges.map(
|
|
94
|
-
(callRecordingEdge) => callRecordingEdge.node,
|
|
95
|
-
);
|
|
96
|
-
const callRecordingNode =
|
|
97
|
-
selectCalendarEventRecording(callRecordingNodes);
|
|
98
|
-
|
|
99
|
-
setState({
|
|
100
|
-
transcript: callRecordingNode?.transcript ?? undefined,
|
|
101
|
-
videoFile: isUndefined(callRecordingNode)
|
|
102
|
-
? undefined
|
|
103
|
-
: getVideoFile(callRecordingNode),
|
|
104
|
-
isCalendarEventRecordingQueryLoading: false,
|
|
105
|
-
errorMessage: undefined,
|
|
106
|
-
});
|
|
107
|
-
} catch {
|
|
108
|
-
if (cancelled) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
setState({
|
|
113
|
-
transcript: undefined,
|
|
114
|
-
videoFile: undefined,
|
|
115
|
-
isCalendarEventRecordingQueryLoading: false,
|
|
116
|
-
errorMessage: CALENDAR_EVENT_RECORDING_ERROR_MESSAGE,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
fetchRecording();
|
|
122
|
-
|
|
123
|
-
return () => {
|
|
124
|
-
cancelled = true;
|
|
125
|
-
};
|
|
126
|
-
}, [calendarEventId]);
|
|
127
|
-
|
|
128
|
-
return state;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const hasTranscript = (
|
|
132
|
-
callRecordingNode: CalendarEventRecordingCallRecordingNode,
|
|
133
|
-
): boolean =>
|
|
134
|
-
!isUndefined(callRecordingNode.transcript) &&
|
|
135
|
-
callRecordingNode.transcript !== null;
|
|
136
|
-
|
|
137
|
-
const getVideoFile = (
|
|
138
|
-
callRecordingNode: CalendarEventRecordingCallRecordingNode,
|
|
139
|
-
): CalendarEventRecordingVideoFile | undefined =>
|
|
140
|
-
callRecordingNode.video?.find(
|
|
141
|
-
(videoFile) => !isUndefined(videoFile.url) && videoFile.url !== null,
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
const selectCalendarEventRecording = (
|
|
145
|
-
callRecordingNodes: CalendarEventRecordingCallRecordingNode[],
|
|
146
|
-
): CalendarEventRecordingCallRecordingNode | undefined =>
|
|
147
|
-
callRecordingNodes.find(
|
|
148
|
-
(callRecordingNode) =>
|
|
149
|
-
hasTranscript(callRecordingNode) &&
|
|
150
|
-
!isUndefined(getVideoFile(callRecordingNode)),
|
|
151
|
-
) ??
|
|
152
|
-
callRecordingNodes.find(hasTranscript) ??
|
|
153
|
-
callRecordingNodes.find(
|
|
154
|
-
(callRecordingNode) => !isUndefined(getVideoFile(callRecordingNode)),
|
|
155
|
-
);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type TranscriptWord = {
|
|
2
|
-
text: string;
|
|
3
|
-
startSeconds: number | undefined;
|
|
4
|
-
endSeconds: number | undefined;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export type TranscriptEntry = {
|
|
8
|
-
speakerName: string;
|
|
9
|
-
startSeconds: number | undefined;
|
|
10
|
-
endSeconds: number | undefined;
|
|
11
|
-
text: string;
|
|
12
|
-
words: TranscriptWord[];
|
|
13
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { type TranscriptEntry } from 'src/front-components/types/transcript-entry.type';
|
|
4
|
-
import { findActiveTranscriptEntryIndex } from 'src/front-components/utils/find-active-transcript-entry-index.util';
|
|
5
|
-
|
|
6
|
-
const makeTranscriptEntry = ({
|
|
7
|
-
startSeconds,
|
|
8
|
-
endSeconds,
|
|
9
|
-
}: {
|
|
10
|
-
startSeconds: number | undefined;
|
|
11
|
-
endSeconds: number | undefined;
|
|
12
|
-
}): TranscriptEntry => ({
|
|
13
|
-
speakerName: 'Ada Lovelace',
|
|
14
|
-
startSeconds,
|
|
15
|
-
endSeconds,
|
|
16
|
-
text: 'Hello',
|
|
17
|
-
words: [{ text: 'Hello', startSeconds, endSeconds }],
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('findActiveTranscriptEntryIndex', () => {
|
|
21
|
-
it('does not keep an open-ended entry active after the next entry starts', () => {
|
|
22
|
-
expect(
|
|
23
|
-
findActiveTranscriptEntryIndex(
|
|
24
|
-
[
|
|
25
|
-
makeTranscriptEntry({ startSeconds: 1, endSeconds: undefined }),
|
|
26
|
-
makeTranscriptEntry({ startSeconds: 10, endSeconds: 20 }),
|
|
27
|
-
],
|
|
28
|
-
25,
|
|
29
|
-
),
|
|
30
|
-
).toBe(-1);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('uses the next known start as the boundary for entries without an end time', () => {
|
|
34
|
-
expect(
|
|
35
|
-
findActiveTranscriptEntryIndex(
|
|
36
|
-
[
|
|
37
|
-
makeTranscriptEntry({ startSeconds: 1, endSeconds: undefined }),
|
|
38
|
-
makeTranscriptEntry({ startSeconds: 10, endSeconds: 20 }),
|
|
39
|
-
],
|
|
40
|
-
9,
|
|
41
|
-
),
|
|
42
|
-
).toBe(0);
|
|
43
|
-
|
|
44
|
-
expect(
|
|
45
|
-
findActiveTranscriptEntryIndex(
|
|
46
|
-
[
|
|
47
|
-
makeTranscriptEntry({ startSeconds: 1, endSeconds: undefined }),
|
|
48
|
-
makeTranscriptEntry({ startSeconds: 10, endSeconds: 20 }),
|
|
49
|
-
],
|
|
50
|
-
10,
|
|
51
|
-
),
|
|
52
|
-
).toBe(1);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('keeps the final open-ended entry active after it starts', () => {
|
|
56
|
-
expect(
|
|
57
|
-
findActiveTranscriptEntryIndex(
|
|
58
|
-
[
|
|
59
|
-
makeTranscriptEntry({ startSeconds: 1, endSeconds: 2 }),
|
|
60
|
-
makeTranscriptEntry({ startSeconds: 10, endSeconds: undefined }),
|
|
61
|
-
],
|
|
62
|
-
25,
|
|
63
|
-
),
|
|
64
|
-
).toBe(1);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { formatTranscriptTimestamp } from 'src/front-components/utils/format-transcript-timestamp.util';
|
|
4
|
-
|
|
5
|
-
describe('formatTranscriptTimestamp', () => {
|
|
6
|
-
it('formats sub-hour durations as minutes and padded seconds', () => {
|
|
7
|
-
expect(formatTranscriptTimestamp(0)).toBe('0:00');
|
|
8
|
-
expect(formatTranscriptTimestamp(5)).toBe('0:05');
|
|
9
|
-
expect(formatTranscriptTimestamp(65)).toBe('1:05');
|
|
10
|
-
expect(formatTranscriptTimestamp(3599)).toBe('59:59');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('adds an hour part with padded minutes past one hour', () => {
|
|
14
|
-
expect(formatTranscriptTimestamp(3600)).toBe('1:00:00');
|
|
15
|
-
expect(formatTranscriptTimestamp(3725)).toBe('1:02:05');
|
|
16
|
-
expect(formatTranscriptTimestamp(7322)).toBe('2:02:02');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('floors fractional seconds', () => {
|
|
20
|
-
expect(formatTranscriptTimestamp(1.9)).toBe('0:01');
|
|
21
|
-
expect(formatTranscriptTimestamp(59.999)).toBe('0:59');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('clamps negative and non-finite input to zero', () => {
|
|
25
|
-
expect(formatTranscriptTimestamp(-12)).toBe('0:00');
|
|
26
|
-
expect(formatTranscriptTimestamp(Number.NaN)).toBe('0:00');
|
|
27
|
-
expect(formatTranscriptTimestamp(Number.POSITIVE_INFINITY)).toBe('0:00');
|
|
28
|
-
});
|
|
29
|
-
});
|