@twentyhq/teams 1.1.2 → 1.2.0

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.
Files changed (50) hide show
  1. package/dependencies/yarn.lock +723 -3
  2. package/manifest.json +46 -29
  3. package/package.json +4 -2
  4. package/src/features/chat/logic-functions/teams-activities-enqueue.mjs +366 -152
  5. package/src/features/chat/logic-functions/teams-activities-enqueue.mjs.map +4 -4
  6. package/src/features/chat/logic-functions/teams-activities-enqueue.ts +1 -1
  7. package/src/features/chat/logic-functions/teams-activities-resolver.mjs +500 -40
  8. package/src/features/chat/logic-functions/teams-activities-resolver.mjs.map +4 -4
  9. package/src/features/chat/logic-functions/teams-activities-resolver.ts +13 -2
  10. package/src/features/chat/logic-functions/teams-list-unlinked-users.mjs +95 -61
  11. package/src/features/chat/logic-functions/teams-list-unlinked-users.mjs.map +4 -4
  12. package/src/features/chat/logic-functions/teams-match-user-links.mjs +105 -86
  13. package/src/features/chat/logic-functions/teams-match-user-links.mjs.map +4 -4
  14. package/src/features/chat/logic-functions/teams-register-connection.mjs +119 -101
  15. package/src/features/chat/logic-functions/teams-register-connection.mjs.map +4 -4
  16. package/src/features/chat/logic-functions/teams-register-connection.ts +1 -1
  17. package/src/features/chat/logic-functions/teams-search-users.mjs +96 -62
  18. package/src/features/chat/logic-functions/teams-search-users.mjs.map +4 -4
  19. package/src/features/chat/logic-functions/teams-set-user-link.mjs +88 -54
  20. package/src/features/chat/logic-functions/teams-set-user-link.mjs.map +4 -4
  21. package/src/features/chat/logic-functions/teams-tenant-release.mjs +72 -41
  22. package/src/features/chat/logic-functions/teams-tenant-release.mjs.map +4 -4
  23. package/src/features/transcripts/logic-functions/teams-count-transcript-history.mjs +99 -68
  24. package/src/features/transcripts/logic-functions/teams-count-transcript-history.mjs.map +4 -4
  25. package/src/features/transcripts/logic-functions/teams-import-transcript-history.mjs +99 -68
  26. package/src/features/transcripts/logic-functions/teams-import-transcript-history.mjs.map +4 -4
  27. package/src/features/transcripts/logic-functions/teams-import-transcript.mjs +96 -65
  28. package/src/features/transcripts/logic-functions/teams-import-transcript.mjs.map +4 -4
  29. package/src/features/transcripts/logic-functions/teams-list-organizer-transcripts.mjs +89 -58
  30. package/src/features/transcripts/logic-functions/teams-list-organizer-transcripts.mjs.map +4 -4
  31. package/src/features/transcripts/logic-functions/teams-sync-transcript.mjs +96 -65
  32. package/src/features/transcripts/logic-functions/teams-sync-transcript.mjs.map +4 -4
  33. package/src/features/transcripts/logic-functions/teams-transcript-history-count.mjs +0 -1
  34. package/src/features/transcripts/logic-functions/teams-transcript-history-count.mjs.map +2 -2
  35. package/src/features/transcripts/logic-functions/teams-transcript-history-import.mjs +0 -1
  36. package/src/features/transcripts/logic-functions/teams-transcript-history-import.mjs.map +2 -2
  37. package/src/features/transcripts/logic-functions/teams-transcript-history-status.mjs +0 -1
  38. package/src/features/transcripts/logic-functions/teams-transcript-history-status.mjs.map +2 -2
  39. package/src/features/transcripts/logic-functions/teams-transcripts-webhook.mjs +104 -73
  40. package/src/features/transcripts/logic-functions/teams-transcripts-webhook.mjs.map +4 -4
  41. package/src/features/transcripts/logic-functions/teams-uninstall.mjs +72 -41
  42. package/src/features/transcripts/logic-functions/teams-uninstall.mjs.map +4 -4
  43. package/src/front-components/settings.front-component.mjs +113 -113
  44. package/src/front-components/settings.front-component.mjs.map +4 -4
  45. package/src/logic-functions/teams-health-check.mjs +46 -25
  46. package/src/logic-functions/teams-health-check.mjs.map +4 -4
  47. package/src/logic-functions/teams-health-check.ts +21 -6
  48. package/src/logic-functions/teams-post-install.mjs +1270 -0
  49. package/src/logic-functions/teams-post-install.mjs.map +7 -0
  50. package/src/logic-functions/teams-post-install.ts +15 -0
@@ -124,10 +124,10 @@ var require_convenience = __commonJS({
124
124
  return structural_1.isArray(term) && term.length > 0;
125
125
  };
126
126
  exports.isNonEmptyArray = isNonEmptyArray2;
127
- var isNonEmptyString15 = (term) => {
127
+ var isNonEmptyString16 = (term) => {
128
128
  return primitives_1.isString(term) && term.length > 0;
129
129
  };
130
- exports.isNonEmptyString = isNonEmptyString15;
130
+ exports.isNonEmptyString = isNonEmptyString16;
131
131
  var isNumberOrNaN = (term) => {
132
132
  return typeof term === "number";
133
133
  };
@@ -193,7 +193,7 @@ var require_build = __commonJS({
193
193
  });
194
194
 
195
195
  // src/features/transcripts/logic-functions/teams-transcripts-webhook.ts
196
- var import_guards16 = __toESM(require_build());
196
+ var import_guards17 = __toESM(require_build());
197
197
 
198
198
  // twenty-sdk-define-stub:__twenty-sdk-define-stub__
199
199
  var __defineFactoryStub = (config) => ({
@@ -530,7 +530,7 @@ var GRAPH_SPEAKER_ATTRIBUTION_NOT_ALLOWED_ERROR_CODE = "SpeakerAttributionNotAll
530
530
  var GRAPH_UNATTRIBUTED_TRANSCRIPT_FORMAT = "application/vnd.microsoft.graph.transcript+text";
531
531
 
532
532
  // src/features/transcripts/logic-functions/utils/fetch-graph-response.ts
533
- var import_guards4 = __toESM(require_build());
533
+ var import_guards5 = __toESM(require_build());
534
534
 
535
535
  // src/features/transcripts/logic-functions/constants/graph-request-max-attempts.ts
536
536
  var GRAPH_REQUEST_MAX_ATTEMPTS = 4;
@@ -553,62 +553,93 @@ var resolveGraphUrlOrThrow = (url) => {
553
553
  return resolvedUrl.toString();
554
554
  };
555
555
 
556
- // src/features/transcripts/logic-functions/utils/sleep-for-milliseconds.ts
556
+ // src/utils/parse-retry-after-ms.ts
557
+ var import_guards4 = __toESM(require_build());
558
+ var parseRetryAfterMs = (retryAfter) => {
559
+ if (!(0, import_guards4.isNonEmptyString)(retryAfter)) {
560
+ return void 0;
561
+ }
562
+ const retryAfterSeconds = Number(retryAfter);
563
+ if (Number.isFinite(retryAfterSeconds)) {
564
+ return Math.max(retryAfterSeconds * 1e3, 0);
565
+ }
566
+ const retryAtMs = Date.parse(retryAfter);
567
+ return Number.isNaN(retryAtMs) ? void 0 : Math.max(retryAtMs - Date.now(), 0);
568
+ };
569
+
570
+ // src/utils/sleep-for-milliseconds.ts
557
571
  var sleepForMilliseconds = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
558
572
 
573
+ // src/utils/fetch-with-retries.ts
574
+ var fetchWithRetries = async ({
575
+ sendRequest,
576
+ maxAttempts,
577
+ isRetryableStatus,
578
+ getRetryDelayMs,
579
+ retryAbortSignal
580
+ }) => {
581
+ const sendAttempt = async ({
582
+ attempt,
583
+ waitedMs
584
+ }) => {
585
+ const response = await sendRequest();
586
+ if (response.ok || !isRetryableStatus(response.status) || attempt + 1 >= maxAttempts) {
587
+ return response;
588
+ }
589
+ const delayMs = getRetryDelayMs({
590
+ attempt,
591
+ retryAfterMs: parseRetryAfterMs(response.headers.get("retry-after")),
592
+ waitedMs
593
+ });
594
+ if (!o(delayMs)) {
595
+ return response;
596
+ }
597
+ await sleepForMilliseconds(delayMs);
598
+ if (o(retryAbortSignal) && retryAbortSignal.aborted) {
599
+ return response;
600
+ }
601
+ await response.body?.cancel();
602
+ return sendAttempt({ attempt: attempt + 1, waitedMs: waitedMs + delayMs });
603
+ };
604
+ return sendAttempt({ attempt: 0, waitedMs: 0 });
605
+ };
606
+
559
607
  // src/features/transcripts/logic-functions/utils/fetch-graph-response.ts
560
- var fetchGraphResponseWithRetries = async ({
608
+ var fetchGraphResponse = async ({
561
609
  accessToken,
562
610
  url,
563
611
  accept,
564
612
  method,
565
- body,
566
- attempt
613
+ body
567
614
  }) => {
568
- const response = await fetch(url, {
569
- method,
570
- redirect: "error",
571
- headers: {
572
- Authorization: `Bearer ${accessToken}`,
573
- Accept: accept,
574
- ...o(body) ? { "Content-Type": "application/json" } : {}
575
- },
576
- body: o(body) ? JSON.stringify(body) : void 0
615
+ const resolvedUrl = resolveGraphUrlOrThrow(url);
616
+ const response = await fetchWithRetries({
617
+ sendRequest: () => fetch(resolvedUrl, {
618
+ method,
619
+ redirect: "error",
620
+ headers: {
621
+ Authorization: `Bearer ${accessToken}`,
622
+ Accept: accept,
623
+ ...o(body) ? { "Content-Type": "application/json" } : {}
624
+ },
625
+ body: o(body) ? JSON.stringify(body) : void 0
626
+ }),
627
+ maxAttempts: GRAPH_REQUEST_MAX_ATTEMPTS,
628
+ isRetryableStatus: (status) => GRAPH_RETRYABLE_STATUSES.has(status),
629
+ getRetryDelayMs: ({ attempt, retryAfterMs }) => o(retryAfterMs) && retryAfterMs > 0 ? retryAfterMs : GRAPH_REQUEST_RETRY_BASE_DELAY_MILLISECONDS * 2 ** attempt
577
630
  });
578
631
  if (response.ok) {
579
632
  return response;
580
633
  }
581
- if (GRAPH_RETRYABLE_STATUSES.has(response.status) && attempt + 1 < GRAPH_REQUEST_MAX_ATTEMPTS) {
582
- const retryAfterSeconds = Number(response.headers.get("Retry-After"));
583
- await sleepForMilliseconds(
584
- retryAfterSeconds > 0 ? retryAfterSeconds * 1e3 : GRAPH_REQUEST_RETRY_BASE_DELAY_MILLISECONDS * 2 ** attempt
585
- );
586
- return fetchGraphResponseWithRetries({
587
- accessToken,
588
- url,
589
- accept,
590
- method,
591
- body,
592
- attempt: attempt + 1
593
- });
594
- }
595
634
  const errorBody = await response.json().catch(() => ({}));
596
- const innerErrorCode = (0, import_guards4.isNonEmptyString)(errorBody.error?.innerError?.code) ? errorBody.error.innerError.code : void 0;
597
- const message = (0, import_guards4.isNonEmptyString)(errorBody.error?.message) ? errorBody.error.message : response.statusText;
635
+ const innerErrorCode = (0, import_guards5.isNonEmptyString)(errorBody.error?.innerError?.code) ? errorBody.error.innerError.code : void 0;
636
+ const message = (0, import_guards5.isNonEmptyString)(errorBody.error?.message) ? errorBody.error.message : response.statusText;
598
637
  throw new GraphRequestError({
599
- message: `Microsoft Graph request failed (${response.status}${(0, import_guards4.isNonEmptyString)(innerErrorCode) ? ` ${innerErrorCode}` : ""}): ${message}`,
638
+ message: `Microsoft Graph request failed (${response.status}${(0, import_guards5.isNonEmptyString)(innerErrorCode) ? ` ${innerErrorCode}` : ""}): ${message}`,
600
639
  status: response.status,
601
640
  innerErrorCode
602
641
  });
603
642
  };
604
- var fetchGraphResponse = ({
605
- url,
606
- ...request
607
- }) => fetchGraphResponseWithRetries({
608
- ...request,
609
- url: resolveGraphUrlOrThrow(url),
610
- attempt: 0
611
- });
612
643
 
613
644
  // src/features/transcripts/logic-functions/utils/fetch-graph-text.ts
614
645
  var fetchGraphText = async ({
@@ -700,7 +731,7 @@ var fetchTeamsTranscriptData = async ({
700
731
  };
701
732
 
702
733
  // src/features/transcripts/logic-functions/utils/find-teams-transcript-calendar-event-id-or-throw.ts
703
- var import_guards11 = __toESM(require_build());
734
+ var import_guards12 = __toESM(require_build());
704
735
 
705
736
  // src/features/transcripts/logic-functions/constants/teams-occurrence-margin-milliseconds.ts
706
737
  var TEAMS_OCCURRENCE_MARGIN_MILLISECONDS = 15 * 60 * 1e3;
@@ -730,7 +761,7 @@ var buildTeamsCalendarViewUrl = ({
730
761
  };
731
762
 
732
763
  // src/features/transcripts/logic-functions/utils/find-teams-calendar-event-ids-or-throw.ts
733
- var import_guards7 = __toESM(require_build());
764
+ var import_guards8 = __toESM(require_build());
734
765
 
735
766
  // src/features/transcripts/logic-functions/constants/teams-calendar-event-lookup-concurrency.ts
736
767
  var TEAMS_CALENDAR_EVENT_LOOKUP_CONCURRENCY = 4;
@@ -745,7 +776,7 @@ var chunkIntoBatches = (items, batchSize) => Array.from(
745
776
  );
746
777
 
747
778
  // src/features/transcripts/logic-functions/utils/get-teams-calendar-event-ical-uid-or-throw.ts
748
- var import_guards5 = __toESM(require_build());
779
+ var import_guards6 = __toESM(require_build());
749
780
  var getTeamsCalendarEventICalUIdOrThrow = async ({
750
781
  accessToken,
751
782
  eventId
@@ -755,7 +786,7 @@ var getTeamsCalendarEventICalUIdOrThrow = async ({
755
786
  accessToken,
756
787
  url: `me/events/${encodeURIComponent(eventId)}?$select=iCalUId`
757
788
  });
758
- return (0, import_guards5.isNonEmptyString)(event.iCalUId) ? event.iCalUId : void 0;
789
+ return (0, import_guards6.isNonEmptyString)(event.iCalUId) ? event.iCalUId : void 0;
759
790
  } catch (error) {
760
791
  if (!(error instanceof GraphRequestError)) {
761
792
  throw error;
@@ -782,7 +813,7 @@ var groupCalendarEventIdsByKey = (entries) => {
782
813
  };
783
814
 
784
815
  // src/features/transcripts/logic-functions/utils/match-teams-calendar-event-ids.ts
785
- var import_guards6 = __toESM(require_build());
816
+ var import_guards7 = __toESM(require_build());
786
817
  var findUniqueCalendarEventId = (calendarEventIds) => calendarEventIds?.size === 1 ? [...calendarEventIds][0] : void 0;
787
818
  var matchTeamsCalendarEventIds = ({
788
819
  references,
@@ -799,7 +830,7 @@ var matchTeamsCalendarEventIds = ({
799
830
  );
800
831
  const calendarEventIdsByICalUid = groupCalendarEventIdsByKey(
801
832
  calendarEvents.flatMap(
802
- ({ id, iCalUid }) => (0, import_guards6.isNonEmptyString)(iCalUid) ? [[iCalUid, id]] : []
833
+ ({ id, iCalUid }) => (0, import_guards7.isNonEmptyString)(iCalUid) ? [[iCalUid, id]] : []
803
834
  )
804
835
  );
805
836
  return new Map(
@@ -823,7 +854,7 @@ var listAllNodesInBatchesOrThrow = async ({
823
854
  do {
824
855
  const connection = await fetchPage({ batch, after });
825
856
  nodes.push(...connection?.edges.map((edge) => edge.node) ?? []);
826
- after = connection?.pageInfo.hasNextPage && (0, import_guards7.isNonEmptyString)(connection.pageInfo.endCursor) ? connection.pageInfo.endCursor : void 0;
857
+ after = connection?.pageInfo.hasNextPage && (0, import_guards8.isNonEmptyString)(connection.pageInfo.endCursor) ? connection.pageInfo.endCursor : void 0;
827
858
  } while (o(after));
828
859
  }
829
860
  return nodes;
@@ -855,7 +886,7 @@ var listCalendarChannelEventAssociationsOrThrow = ({
855
886
  ({
856
887
  node
857
888
  }) => {
858
- if (!(0, import_guards7.isNonEmptyString)(node.eventExternalId) || !(0, import_guards7.isNonEmptyString)(node.calendarEventId)) {
889
+ if (!(0, import_guards8.isNonEmptyString)(node.eventExternalId) || !(0, import_guards8.isNonEmptyString)(node.calendarEventId)) {
859
890
  return [];
860
891
  }
861
892
  return [
@@ -961,7 +992,7 @@ var findTeamsCalendarEventIdsOrThrow = async ({
961
992
  });
962
993
  const fallbackICalUIds = [
963
994
  ...new Set(
964
- iCalUIdFallbackReferences.map(({ iCalUId }) => iCalUId).filter(import_guards7.isNonEmptyString)
995
+ iCalUIdFallbackReferences.map(({ iCalUId }) => iCalUId).filter(import_guards8.isNonEmptyString)
965
996
  )
966
997
  ];
967
998
  return matchTeamsCalendarEventIds({
@@ -975,12 +1006,12 @@ var findTeamsCalendarEventIdsOrThrow = async ({
975
1006
  };
976
1007
 
977
1008
  // src/features/transcripts/logic-functions/utils/is-transcript-during-occurrence.ts
978
- var import_guards8 = __toESM(require_build());
1009
+ var import_guards9 = __toESM(require_build());
979
1010
  var isTranscriptDuringOccurrence = ({
980
1011
  transcript,
981
1012
  occurrence
982
1013
  }) => {
983
- if (!(0, import_guards8.isNonEmptyString)(transcript.createdDateTime)) {
1014
+ if (!(0, import_guards9.isNonEmptyString)(transcript.createdDateTime)) {
984
1015
  return false;
985
1016
  }
986
1017
  const createdMilliseconds = Date.parse(transcript.createdDateTime);
@@ -999,10 +1030,10 @@ var findTeamsTranscriptCalendarReference = ({
999
1030
  };
1000
1031
 
1001
1032
  // src/features/transcripts/logic-functions/utils/list-teams-calendar-page.ts
1002
- var import_guards10 = __toESM(require_build());
1033
+ var import_guards11 = __toESM(require_build());
1003
1034
 
1004
1035
  // src/features/transcripts/logic-functions/utils/to-teams-meeting-occurrence.ts
1005
- var import_guards9 = __toESM(require_build());
1036
+ var import_guards10 = __toESM(require_build());
1006
1037
 
1007
1038
  // src/features/transcripts/logic-functions/utils/parse-graph-utc-date-time.ts
1008
1039
  var parseGraphUtcDateTime = (dateTimeTimeZone) => {
@@ -1018,12 +1049,12 @@ var toTeamsMeetingOccurrence = (event) => {
1018
1049
  const joinWebUrl = event.onlineMeeting?.joinUrl;
1019
1050
  const startDateTime = parseGraphUtcDateTime(event.start);
1020
1051
  const endDateTime = parseGraphUtcDateTime(event.end);
1021
- if (!event.isOrganizer || event.isCancelled || event.onlineMeetingProvider !== "teamsForBusiness" || !(0, import_guards9.isNonEmptyString)(joinWebUrl) || !(0, import_guards9.isNonEmptyString)(event.id) || !o(startDateTime) || !o(endDateTime)) {
1052
+ if (!event.isOrganizer || event.isCancelled || event.onlineMeetingProvider !== "teamsForBusiness" || !(0, import_guards10.isNonEmptyString)(joinWebUrl) || !(0, import_guards10.isNonEmptyString)(event.id) || !o(startDateTime) || !o(endDateTime)) {
1022
1053
  return void 0;
1023
1054
  }
1024
- const calendarReference = (0, import_guards9.isNonEmptyString)(event.seriesMasterId) ? { eventExternalId: event.seriesMasterId } : {
1055
+ const calendarReference = (0, import_guards10.isNonEmptyString)(event.seriesMasterId) ? { eventExternalId: event.seriesMasterId } : {
1025
1056
  eventExternalId: event.id,
1026
- ...(0, import_guards9.isNonEmptyString)(event.iCalUId) ? { iCalUId: event.iCalUId } : {}
1057
+ ...(0, import_guards10.isNonEmptyString)(event.iCalUId) ? { iCalUId: event.iCalUId } : {}
1027
1058
  };
1028
1059
  return { joinWebUrl, startDateTime, endDateTime, calendarReference };
1029
1060
  };
@@ -1043,7 +1074,7 @@ var listTeamsCalendarPage = async ({
1043
1074
  });
1044
1075
  return {
1045
1076
  occurrences,
1046
- nextPageUrl: (0, import_guards10.isNonEmptyString)(page["@odata.nextLink"]) ? page["@odata.nextLink"] : void 0
1077
+ nextPageUrl: (0, import_guards11.isNonEmptyString)(page["@odata.nextLink"]) ? page["@odata.nextLink"] : void 0
1047
1078
  };
1048
1079
  };
1049
1080
 
@@ -1115,7 +1146,7 @@ var findTeamsTranscriptCalendarEventIdOrThrow = async ({
1115
1146
  meeting,
1116
1147
  transcript
1117
1148
  }) => {
1118
- if (!(0, import_guards11.isNonEmptyString)(meeting.joinWebUrl) || !(0, import_guards11.isNonEmptyString)(transcript.createdDateTime)) {
1149
+ if (!(0, import_guards12.isNonEmptyString)(meeting.joinWebUrl) || !(0, import_guards12.isNonEmptyString)(transcript.createdDateTime)) {
1119
1150
  return void 0;
1120
1151
  }
1121
1152
  const transcriptStartMilliseconds = Date.parse(transcript.createdDateTime);
@@ -1144,7 +1175,7 @@ var findTeamsTranscriptCalendarEventIdOrThrow = async ({
1144
1175
  };
1145
1176
 
1146
1177
  // src/features/transcripts/logic-functions/utils/map-teams-transcript-to-entries.ts
1147
- var import_guards12 = __toESM(require_build());
1178
+ var import_guards13 = __toESM(require_build());
1148
1179
  var isCueTimingLine = (line) => /^-?(?:\d+:)?\d{1,2}:\d{2}[.,]\d{1,3}\s+-->\s+-?(?:\d+:)?\d{1,2}:\d{2}[.,]\d{1,3}/.test(
1149
1180
  line.trim()
1150
1181
  );
@@ -1160,7 +1191,7 @@ var parseCueStartSeconds = (timingLine) => {
1160
1191
  var splitIntoBlocks = (content) => {
1161
1192
  const blocks = [[]];
1162
1193
  for (const line of content.replace(/^/, "").split(/\r?\n/)) {
1163
- if ((0, import_guards12.isNonEmptyString)(line.trim())) {
1194
+ if ((0, import_guards13.isNonEmptyString)(line.trim())) {
1164
1195
  blocks[blocks.length - 1].push(line);
1165
1196
  } else {
1166
1197
  blocks.push([]);
@@ -1203,12 +1234,12 @@ var toUtterance = ({
1203
1234
  /<v(?:\.[^\s>]*)?\s+([^>]*)>/i.exec(cueText)?.[1] ?? ""
1204
1235
  ).trim();
1205
1236
  const text = decodeHtmlEntities(stripCueTags(cueText)).replace(/\s+/g, " ").trim();
1206
- if (!(0, import_guards12.isNonEmptyString)(text)) {
1237
+ if (!(0, import_guards13.isNonEmptyString)(text)) {
1207
1238
  return void 0;
1208
1239
  }
1209
1240
  return {
1210
1241
  startSeconds,
1211
- speakerName: (0, import_guards12.isNonEmptyString)(speakerName) ? speakerName : void 0,
1242
+ speakerName: (0, import_guards13.isNonEmptyString)(speakerName) ? speakerName : void 0,
1212
1243
  text
1213
1244
  };
1214
1245
  };
@@ -1430,9 +1461,9 @@ var importTeamsTranscriptOrScheduleRetry = async ({
1430
1461
  };
1431
1462
 
1432
1463
  // src/features/transcripts/logic-functions/utils/parse-teams-transcript-resource.ts
1433
- var import_guards13 = __toESM(require_build());
1464
+ var import_guards14 = __toESM(require_build());
1434
1465
  var parseTeamsTranscriptResource = (resource) => {
1435
- if (!(0, import_guards13.isNonEmptyString)(resource)) {
1466
+ if (!(0, import_guards14.isNonEmptyString)(resource)) {
1436
1467
  return void 0;
1437
1468
  }
1438
1469
  const match = /^\/?users\/[^/]+\/onlineMeetings\('([^']+)'\)\/transcripts\('([^']+)'\)$/.exec(
@@ -1457,22 +1488,22 @@ var parseTeamsTranscriptResource = (resource) => {
1457
1488
  };
1458
1489
 
1459
1490
  // src/features/transcripts/logic-functions/utils/parse-teams-transcript-subscription-notifications.ts
1460
- var import_guards14 = __toESM(require_build());
1491
+ var import_guards15 = __toESM(require_build());
1461
1492
  import { timingSafeEqual } from "node:crypto";
1462
1493
  var isMatchingClientState = (receivedClientState, expectedClientState) => {
1463
- if (!(0, import_guards14.isNonEmptyString)(receivedClientState)) {
1494
+ if (!(0, import_guards15.isNonEmptyString)(receivedClientState)) {
1464
1495
  return false;
1465
1496
  }
1466
1497
  const received = Buffer.from(receivedClientState);
1467
1498
  const expected = Buffer.from(expectedClientState);
1468
1499
  return received.length === expected.length && timingSafeEqual(received, expected);
1469
1500
  };
1470
- var isSubscriptionNotification = (notification, subscription) => (0, import_guards14.isObject)(notification) && notification.subscriptionId === subscription.subscriptionId && isMatchingClientState(notification.clientState, subscription.clientState);
1501
+ var isSubscriptionNotification = (notification, subscription) => (0, import_guards15.isObject)(notification) && notification.subscriptionId === subscription.subscriptionId && isMatchingClientState(notification.clientState, subscription.clientState);
1471
1502
  var parseTeamsTranscriptSubscriptionNotifications = ({
1472
1503
  body,
1473
1504
  subscription
1474
1505
  }) => {
1475
- if (!(0, import_guards14.isObject)(body) || !Array.isArray(body.value)) {
1506
+ if (!(0, import_guards15.isObject)(body) || !Array.isArray(body.value)) {
1476
1507
  return void 0;
1477
1508
  }
1478
1509
  const notifications = body.value;
@@ -1483,7 +1514,7 @@ var parseTeamsTranscriptSubscriptionNotifications = ({
1483
1514
  };
1484
1515
 
1485
1516
  // src/features/transcripts/logic-functions/utils/renew-teams-transcript-subscription.ts
1486
- var import_guards15 = __toESM(require_build());
1517
+ var import_guards16 = __toESM(require_build());
1487
1518
 
1488
1519
  // src/features/transcripts/logic-functions/constants/teams-transcript-subscription-lifetime-milliseconds.ts
1489
1520
  var TEAMS_TRANSCRIPT_SUBSCRIPTION_LIFETIME_MILLISECONDS = (4320 - 5) * 60 * 1e3;
@@ -1503,7 +1534,7 @@ var renewTeamsTranscriptSubscription = async ({
1503
1534
  ).toISOString()
1504
1535
  }
1505
1536
  });
1506
- if (!(0, import_guards15.isNonEmptyString)(subscription.expirationDateTime)) {
1537
+ if (!(0, import_guards16.isNonEmptyString)(subscription.expirationDateTime)) {
1507
1538
  throw new Error(
1508
1539
  "Microsoft Graph returned an invalid transcript subscription"
1509
1540
  );
@@ -1551,7 +1582,7 @@ var importTeamsTranscriptFromResourceOrThrow = async ({
1551
1582
  };
1552
1583
  var teamsTranscriptsWebhookHandler = async (routePayload) => {
1553
1584
  const connectedAccountId = routePayload.queryStringParameters?.[TEAMS_TRANSCRIPTS_WEBHOOK_CONNECTION_QUERY_PARAMETER];
1554
- if (!(0, import_guards16.isNonEmptyString)(connectedAccountId)) {
1585
+ if (!(0, import_guards17.isNonEmptyString)(connectedAccountId)) {
1555
1586
  return { success: false, error: "Missing Teams connection identifier" };
1556
1587
  }
1557
1588
  const subscriptionKvKey = buildTeamsTranscriptSubscriptionKvKey(connectedAccountId);