@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.
- package/dependencies/yarn.lock +723 -3
- package/manifest.json +46 -29
- package/package.json +4 -2
- package/src/features/chat/logic-functions/teams-activities-enqueue.mjs +366 -152
- package/src/features/chat/logic-functions/teams-activities-enqueue.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-activities-enqueue.ts +1 -1
- package/src/features/chat/logic-functions/teams-activities-resolver.mjs +500 -40
- package/src/features/chat/logic-functions/teams-activities-resolver.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-activities-resolver.ts +13 -2
- package/src/features/chat/logic-functions/teams-list-unlinked-users.mjs +95 -61
- package/src/features/chat/logic-functions/teams-list-unlinked-users.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-match-user-links.mjs +105 -86
- package/src/features/chat/logic-functions/teams-match-user-links.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-register-connection.mjs +119 -101
- package/src/features/chat/logic-functions/teams-register-connection.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-register-connection.ts +1 -1
- package/src/features/chat/logic-functions/teams-search-users.mjs +96 -62
- package/src/features/chat/logic-functions/teams-search-users.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-set-user-link.mjs +88 -54
- package/src/features/chat/logic-functions/teams-set-user-link.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-tenant-release.mjs +72 -41
- package/src/features/chat/logic-functions/teams-tenant-release.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-count-transcript-history.mjs +99 -68
- package/src/features/transcripts/logic-functions/teams-count-transcript-history.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-import-transcript-history.mjs +99 -68
- package/src/features/transcripts/logic-functions/teams-import-transcript-history.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-import-transcript.mjs +96 -65
- package/src/features/transcripts/logic-functions/teams-import-transcript.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-list-organizer-transcripts.mjs +89 -58
- package/src/features/transcripts/logic-functions/teams-list-organizer-transcripts.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-sync-transcript.mjs +96 -65
- package/src/features/transcripts/logic-functions/teams-sync-transcript.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-transcript-history-count.mjs +0 -1
- package/src/features/transcripts/logic-functions/teams-transcript-history-count.mjs.map +2 -2
- package/src/features/transcripts/logic-functions/teams-transcript-history-import.mjs +0 -1
- package/src/features/transcripts/logic-functions/teams-transcript-history-import.mjs.map +2 -2
- package/src/features/transcripts/logic-functions/teams-transcript-history-status.mjs +0 -1
- package/src/features/transcripts/logic-functions/teams-transcript-history-status.mjs.map +2 -2
- package/src/features/transcripts/logic-functions/teams-transcripts-webhook.mjs +104 -73
- package/src/features/transcripts/logic-functions/teams-transcripts-webhook.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-uninstall.mjs +72 -41
- package/src/features/transcripts/logic-functions/teams-uninstall.mjs.map +4 -4
- package/src/front-components/settings.front-component.mjs +113 -113
- package/src/front-components/settings.front-component.mjs.map +4 -4
- package/src/logic-functions/teams-health-check.mjs +46 -25
- package/src/logic-functions/teams-health-check.mjs.map +4 -4
- package/src/logic-functions/teams-health-check.ts +21 -6
- package/src/logic-functions/teams-post-install.mjs +1270 -0
- package/src/logic-functions/teams-post-install.mjs.map +7 -0
- 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 = isNonEmptyArray;
|
|
127
|
-
var
|
|
127
|
+
var isNonEmptyString9 = (term) => {
|
|
128
128
|
return primitives_1.isString(term) && term.length > 0;
|
|
129
129
|
};
|
|
130
|
-
exports.isNonEmptyString =
|
|
130
|
+
exports.isNonEmptyString = isNonEmptyString9;
|
|
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-list-organizer-transcripts.ts
|
|
196
|
-
var
|
|
196
|
+
var import_guards10 = __toESM(require_build());
|
|
197
197
|
|
|
198
198
|
// twenty-sdk-define-stub:__twenty-sdk-define-stub__
|
|
199
199
|
var __defineFactoryStub = (config) => ({
|
|
@@ -444,10 +444,10 @@ var getTeamsConnectionForRequestOrThrow = async (context, {
|
|
|
444
444
|
};
|
|
445
445
|
|
|
446
446
|
// src/features/transcripts/logic-functions/utils/list-teams-calendar-page.ts
|
|
447
|
-
var
|
|
447
|
+
var import_guards6 = __toESM(require_build());
|
|
448
448
|
|
|
449
449
|
// src/features/transcripts/logic-functions/utils/fetch-graph-response.ts
|
|
450
|
-
var
|
|
450
|
+
var import_guards4 = __toESM(require_build());
|
|
451
451
|
|
|
452
452
|
// src/features/transcripts/logic-functions/constants/graph-request-max-attempts.ts
|
|
453
453
|
var GRAPH_REQUEST_MAX_ATTEMPTS = 4;
|
|
@@ -484,62 +484,93 @@ var resolveGraphUrlOrThrow = (url) => {
|
|
|
484
484
|
return resolvedUrl.toString();
|
|
485
485
|
};
|
|
486
486
|
|
|
487
|
-
// src/
|
|
487
|
+
// src/utils/parse-retry-after-ms.ts
|
|
488
|
+
var import_guards3 = __toESM(require_build());
|
|
489
|
+
var parseRetryAfterMs = (retryAfter) => {
|
|
490
|
+
if (!(0, import_guards3.isNonEmptyString)(retryAfter)) {
|
|
491
|
+
return void 0;
|
|
492
|
+
}
|
|
493
|
+
const retryAfterSeconds = Number(retryAfter);
|
|
494
|
+
if (Number.isFinite(retryAfterSeconds)) {
|
|
495
|
+
return Math.max(retryAfterSeconds * 1e3, 0);
|
|
496
|
+
}
|
|
497
|
+
const retryAtMs = Date.parse(retryAfter);
|
|
498
|
+
return Number.isNaN(retryAtMs) ? void 0 : Math.max(retryAtMs - Date.now(), 0);
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
// src/utils/sleep-for-milliseconds.ts
|
|
488
502
|
var sleepForMilliseconds = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
489
503
|
|
|
504
|
+
// src/utils/fetch-with-retries.ts
|
|
505
|
+
var fetchWithRetries = async ({
|
|
506
|
+
sendRequest,
|
|
507
|
+
maxAttempts,
|
|
508
|
+
isRetryableStatus,
|
|
509
|
+
getRetryDelayMs,
|
|
510
|
+
retryAbortSignal
|
|
511
|
+
}) => {
|
|
512
|
+
const sendAttempt = async ({
|
|
513
|
+
attempt,
|
|
514
|
+
waitedMs
|
|
515
|
+
}) => {
|
|
516
|
+
const response = await sendRequest();
|
|
517
|
+
if (response.ok || !isRetryableStatus(response.status) || attempt + 1 >= maxAttempts) {
|
|
518
|
+
return response;
|
|
519
|
+
}
|
|
520
|
+
const delayMs = getRetryDelayMs({
|
|
521
|
+
attempt,
|
|
522
|
+
retryAfterMs: parseRetryAfterMs(response.headers.get("retry-after")),
|
|
523
|
+
waitedMs
|
|
524
|
+
});
|
|
525
|
+
if (!o(delayMs)) {
|
|
526
|
+
return response;
|
|
527
|
+
}
|
|
528
|
+
await sleepForMilliseconds(delayMs);
|
|
529
|
+
if (o(retryAbortSignal) && retryAbortSignal.aborted) {
|
|
530
|
+
return response;
|
|
531
|
+
}
|
|
532
|
+
await response.body?.cancel();
|
|
533
|
+
return sendAttempt({ attempt: attempt + 1, waitedMs: waitedMs + delayMs });
|
|
534
|
+
};
|
|
535
|
+
return sendAttempt({ attempt: 0, waitedMs: 0 });
|
|
536
|
+
};
|
|
537
|
+
|
|
490
538
|
// src/features/transcripts/logic-functions/utils/fetch-graph-response.ts
|
|
491
|
-
var
|
|
539
|
+
var fetchGraphResponse = async ({
|
|
492
540
|
accessToken,
|
|
493
541
|
url,
|
|
494
542
|
accept,
|
|
495
543
|
method,
|
|
496
|
-
body
|
|
497
|
-
attempt
|
|
544
|
+
body
|
|
498
545
|
}) => {
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
546
|
+
const resolvedUrl = resolveGraphUrlOrThrow(url);
|
|
547
|
+
const response = await fetchWithRetries({
|
|
548
|
+
sendRequest: () => fetch(resolvedUrl, {
|
|
549
|
+
method,
|
|
550
|
+
redirect: "error",
|
|
551
|
+
headers: {
|
|
552
|
+
Authorization: `Bearer ${accessToken}`,
|
|
553
|
+
Accept: accept,
|
|
554
|
+
...o(body) ? { "Content-Type": "application/json" } : {}
|
|
555
|
+
},
|
|
556
|
+
body: o(body) ? JSON.stringify(body) : void 0
|
|
557
|
+
}),
|
|
558
|
+
maxAttempts: GRAPH_REQUEST_MAX_ATTEMPTS,
|
|
559
|
+
isRetryableStatus: (status) => GRAPH_RETRYABLE_STATUSES.has(status),
|
|
560
|
+
getRetryDelayMs: ({ attempt, retryAfterMs }) => o(retryAfterMs) && retryAfterMs > 0 ? retryAfterMs : GRAPH_REQUEST_RETRY_BASE_DELAY_MILLISECONDS * 2 ** attempt
|
|
508
561
|
});
|
|
509
562
|
if (response.ok) {
|
|
510
563
|
return response;
|
|
511
564
|
}
|
|
512
|
-
if (GRAPH_RETRYABLE_STATUSES.has(response.status) && attempt + 1 < GRAPH_REQUEST_MAX_ATTEMPTS) {
|
|
513
|
-
const retryAfterSeconds = Number(response.headers.get("Retry-After"));
|
|
514
|
-
await sleepForMilliseconds(
|
|
515
|
-
retryAfterSeconds > 0 ? retryAfterSeconds * 1e3 : GRAPH_REQUEST_RETRY_BASE_DELAY_MILLISECONDS * 2 ** attempt
|
|
516
|
-
);
|
|
517
|
-
return fetchGraphResponseWithRetries({
|
|
518
|
-
accessToken,
|
|
519
|
-
url,
|
|
520
|
-
accept,
|
|
521
|
-
method,
|
|
522
|
-
body,
|
|
523
|
-
attempt: attempt + 1
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
565
|
const errorBody = await response.json().catch(() => ({}));
|
|
527
|
-
const innerErrorCode = (0,
|
|
528
|
-
const message = (0,
|
|
566
|
+
const innerErrorCode = (0, import_guards4.isNonEmptyString)(errorBody.error?.innerError?.code) ? errorBody.error.innerError.code : void 0;
|
|
567
|
+
const message = (0, import_guards4.isNonEmptyString)(errorBody.error?.message) ? errorBody.error.message : response.statusText;
|
|
529
568
|
throw new GraphRequestError({
|
|
530
|
-
message: `Microsoft Graph request failed (${response.status}${(0,
|
|
569
|
+
message: `Microsoft Graph request failed (${response.status}${(0, import_guards4.isNonEmptyString)(innerErrorCode) ? ` ${innerErrorCode}` : ""}): ${message}`,
|
|
531
570
|
status: response.status,
|
|
532
571
|
innerErrorCode
|
|
533
572
|
});
|
|
534
573
|
};
|
|
535
|
-
var fetchGraphResponse = ({
|
|
536
|
-
url,
|
|
537
|
-
...request
|
|
538
|
-
}) => fetchGraphResponseWithRetries({
|
|
539
|
-
...request,
|
|
540
|
-
url: resolveGraphUrlOrThrow(url),
|
|
541
|
-
attempt: 0
|
|
542
|
-
});
|
|
543
574
|
|
|
544
575
|
// src/features/transcripts/logic-functions/utils/fetch-graph-json.ts
|
|
545
576
|
var fetchGraphJson = async ({
|
|
@@ -560,7 +591,7 @@ var fetchGraphJson = async ({
|
|
|
560
591
|
};
|
|
561
592
|
|
|
562
593
|
// src/features/transcripts/logic-functions/utils/to-teams-meeting-occurrence.ts
|
|
563
|
-
var
|
|
594
|
+
var import_guards5 = __toESM(require_build());
|
|
564
595
|
|
|
565
596
|
// src/features/transcripts/logic-functions/utils/parse-graph-utc-date-time.ts
|
|
566
597
|
var parseGraphUtcDateTime = (dateTimeTimeZone) => {
|
|
@@ -576,12 +607,12 @@ var toTeamsMeetingOccurrence = (event) => {
|
|
|
576
607
|
const joinWebUrl = event.onlineMeeting?.joinUrl;
|
|
577
608
|
const startDateTime = parseGraphUtcDateTime(event.start);
|
|
578
609
|
const endDateTime = parseGraphUtcDateTime(event.end);
|
|
579
|
-
if (!event.isOrganizer || event.isCancelled || event.onlineMeetingProvider !== "teamsForBusiness" || !(0,
|
|
610
|
+
if (!event.isOrganizer || event.isCancelled || event.onlineMeetingProvider !== "teamsForBusiness" || !(0, import_guards5.isNonEmptyString)(joinWebUrl) || !(0, import_guards5.isNonEmptyString)(event.id) || !o(startDateTime) || !o(endDateTime)) {
|
|
580
611
|
return void 0;
|
|
581
612
|
}
|
|
582
|
-
const calendarReference = (0,
|
|
613
|
+
const calendarReference = (0, import_guards5.isNonEmptyString)(event.seriesMasterId) ? { eventExternalId: event.seriesMasterId } : {
|
|
583
614
|
eventExternalId: event.id,
|
|
584
|
-
...(0,
|
|
615
|
+
...(0, import_guards5.isNonEmptyString)(event.iCalUId) ? { iCalUId: event.iCalUId } : {}
|
|
585
616
|
};
|
|
586
617
|
return { joinWebUrl, startDateTime, endDateTime, calendarReference };
|
|
587
618
|
};
|
|
@@ -601,12 +632,12 @@ var listTeamsCalendarPage = async ({
|
|
|
601
632
|
});
|
|
602
633
|
return {
|
|
603
634
|
occurrences,
|
|
604
|
-
nextPageUrl: (0,
|
|
635
|
+
nextPageUrl: (0, import_guards6.isNonEmptyString)(page["@odata.nextLink"]) ? page["@odata.nextLink"] : void 0
|
|
605
636
|
};
|
|
606
637
|
};
|
|
607
638
|
|
|
608
639
|
// src/features/transcripts/logic-functions/utils/is-transcript-during-occurrence.ts
|
|
609
|
-
var
|
|
640
|
+
var import_guards7 = __toESM(require_build());
|
|
610
641
|
|
|
611
642
|
// src/features/transcripts/logic-functions/constants/teams-occurrence-margin-milliseconds.ts
|
|
612
643
|
var TEAMS_OCCURRENCE_MARGIN_MILLISECONDS = 15 * 60 * 1e3;
|
|
@@ -616,7 +647,7 @@ var isTranscriptDuringOccurrence = ({
|
|
|
616
647
|
transcript,
|
|
617
648
|
occurrence
|
|
618
649
|
}) => {
|
|
619
|
-
if (!(0,
|
|
650
|
+
if (!(0, import_guards7.isNonEmptyString)(transcript.createdDateTime)) {
|
|
620
651
|
return false;
|
|
621
652
|
}
|
|
622
653
|
const createdMilliseconds = Date.parse(transcript.createdDateTime);
|
|
@@ -663,7 +694,7 @@ var GRAPH_ACCESS_TO_TRANSCRIPTS_DISABLED_ERROR_CODE = "GraphAccessToTranscriptsD
|
|
|
663
694
|
var isUnavailableTeamsTranscriptError = (error) => error instanceof GraphRequestError && (error.status === 404 || error.status === 403 && error.innerErrorCode !== GRAPH_ACCESS_TO_TRANSCRIPTS_DISABLED_ERROR_CODE);
|
|
664
695
|
|
|
665
696
|
// src/features/transcripts/logic-functions/utils/list-meeting-transcripts.ts
|
|
666
|
-
var
|
|
697
|
+
var import_guards8 = __toESM(require_build());
|
|
667
698
|
|
|
668
699
|
// src/features/transcripts/logic-functions/constants/max-graph-transcript-list-pages.ts
|
|
669
700
|
var MAX_GRAPH_TRANSCRIPT_LIST_PAGES = 200;
|
|
@@ -683,7 +714,7 @@ var listMeetingTranscriptPages = async ({
|
|
|
683
714
|
});
|
|
684
715
|
const transcripts = page.value ?? [];
|
|
685
716
|
const nextPageUrl = page["@odata.nextLink"];
|
|
686
|
-
if (!(0,
|
|
717
|
+
if (!(0, import_guards8.isNonEmptyString)(nextPageUrl)) {
|
|
687
718
|
return transcripts;
|
|
688
719
|
}
|
|
689
720
|
return [
|
|
@@ -789,7 +820,7 @@ var resolveTeamsCalendarNextPageUrlOrThrow = (nextPageUrl) => {
|
|
|
789
820
|
};
|
|
790
821
|
|
|
791
822
|
// src/features/transcripts/logic-functions/utils/resolve-teams-meeting-window-or-throw.ts
|
|
792
|
-
var
|
|
823
|
+
var import_guards9 = __toESM(require_build());
|
|
793
824
|
|
|
794
825
|
// src/features/transcripts/logic-functions/constants/teams-default-lookback-milliseconds.ts
|
|
795
826
|
var TEAMS_DEFAULT_LOOKBACK_MILLISECONDS = 31 * 24 * 60 * 60 * 1e3;
|
|
@@ -801,8 +832,8 @@ var resolveTeamsMeetingWindowOrThrow = ({
|
|
|
801
832
|
}) => {
|
|
802
833
|
const now = Date.now();
|
|
803
834
|
const window = {
|
|
804
|
-
startDateTime: (0,
|
|
805
|
-
endDateTime: (0,
|
|
835
|
+
startDateTime: (0, import_guards9.isNonEmptyString)(startDateTime) ? startDateTime : new Date(now - TEAMS_DEFAULT_LOOKBACK_MILLISECONDS).toISOString(),
|
|
836
|
+
endDateTime: (0, import_guards9.isNonEmptyString)(endDateTime) ? endDateTime : new Date(now).toISOString()
|
|
806
837
|
};
|
|
807
838
|
const startMilliseconds = Date.parse(window.startDateTime);
|
|
808
839
|
const endMilliseconds = Date.parse(window.endDateTime);
|
|
@@ -854,7 +885,7 @@ var teamsListOrganizerTranscriptsHandler = async (parameters, context) => {
|
|
|
854
885
|
return { success: false, error: "Teams transcripts are not enabled." };
|
|
855
886
|
}
|
|
856
887
|
try {
|
|
857
|
-
const calendarPageUrl = (0,
|
|
888
|
+
const calendarPageUrl = (0, import_guards10.isNonEmptyString)(parameters.nextPageUrl) ? resolveTeamsCalendarNextPageUrlOrThrow(parameters.nextPageUrl) : buildTeamsCalendarViewUrl(resolveTeamsMeetingWindowOrThrow(parameters));
|
|
858
889
|
const connection = await getTeamsConnectionForRequestOrThrow(context);
|
|
859
890
|
const accessToken = getConnectionAccessTokenOrThrow(connection);
|
|
860
891
|
const page = await listTeamsCalendarPage({
|
|
@@ -872,8 +903,8 @@ var teamsListOrganizerTranscriptsHandler = async (parameters, context) => {
|
|
|
872
903
|
({ meeting, transcript }) => ({
|
|
873
904
|
transcriptId: transcript.id,
|
|
874
905
|
meetingId: meeting.id,
|
|
875
|
-
subject: (0,
|
|
876
|
-
createdDateTime: (0,
|
|
906
|
+
subject: (0, import_guards10.isNonEmptyString)(meeting.subject) ? meeting.subject : void 0,
|
|
907
|
+
createdDateTime: (0, import_guards10.isNonEmptyString)(transcript.createdDateTime) ? transcript.createdDateTime : void 0
|
|
877
908
|
})
|
|
878
909
|
),
|
|
879
910
|
nextPageUrl: page.nextPageUrl
|