@twentyhq/teams 1.1.2 → 1.2.1
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 +378 -162
- 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 = isNonEmptyArray2;
|
|
127
|
-
var
|
|
127
|
+
var isNonEmptyString11 = (term) => {
|
|
128
128
|
return primitives_1.isString(term) && term.length > 0;
|
|
129
129
|
};
|
|
130
|
-
exports.isNonEmptyString =
|
|
130
|
+
exports.isNonEmptyString = isNonEmptyString11;
|
|
131
131
|
var isNumberOrNaN = (term) => {
|
|
132
132
|
return typeof term === "number";
|
|
133
133
|
};
|
|
@@ -219,7 +219,7 @@ var TEAMS_USER_LINKS_SET_ROUTE_PATH = "/teams-user-links/set";
|
|
|
219
219
|
var TEAMS_SET_USER_LINK_UNIVERSAL_IDENTIFIER = "743c7eaa-91d9-427b-adce-34ceee6e4d51";
|
|
220
220
|
|
|
221
221
|
// src/features/chat/logic-functions/handlers/teams-set-user-link-handler.ts
|
|
222
|
-
var
|
|
222
|
+
var import_guards12 = __toESM(require_build());
|
|
223
223
|
import { CoreApiClient } from "twenty-client-sdk/core";
|
|
224
224
|
|
|
225
225
|
// src/features/chat/logic-functions/data/does-workspace-member-exist.ts
|
|
@@ -319,7 +319,7 @@ var extractTeamsSetUserLinkInput = (payload) => {
|
|
|
319
319
|
};
|
|
320
320
|
|
|
321
321
|
// src/features/chat/logic-functions/utils/get-teams-workspace-graph-access.ts
|
|
322
|
-
var
|
|
322
|
+
var import_guards9 = __toESM(require_build());
|
|
323
323
|
|
|
324
324
|
// node_modules/twenty-sdk/dist/logic-function/index.mjs
|
|
325
325
|
var import_guards4 = __toESM(require_build(), 1);
|
|
@@ -512,10 +512,10 @@ var TEAMS_CONNECTED_ACCOUNT_TENANT_KV_KEY_PREFIX = "teams-connected-account-tena
|
|
|
512
512
|
var buildTeamsConnectedAccountTenantKvKey = (connectedAccountId) => `${TEAMS_CONNECTED_ACCOUNT_TENANT_KV_KEY_PREFIX}:${connectedAccountId}`;
|
|
513
513
|
|
|
514
514
|
// src/features/chat/logic-functions/utils/fetch-teams-tenant-id.ts
|
|
515
|
-
var
|
|
515
|
+
var import_guards8 = __toESM(require_build());
|
|
516
516
|
|
|
517
517
|
// src/features/transcripts/logic-functions/utils/fetch-graph-response.ts
|
|
518
|
-
var
|
|
518
|
+
var import_guards7 = __toESM(require_build());
|
|
519
519
|
|
|
520
520
|
// src/features/transcripts/logic-functions/constants/graph-request-max-attempts.ts
|
|
521
521
|
var GRAPH_REQUEST_MAX_ATTEMPTS = 4;
|
|
@@ -552,62 +552,93 @@ var resolveGraphUrlOrThrow = (url) => {
|
|
|
552
552
|
return resolvedUrl.toString();
|
|
553
553
|
};
|
|
554
554
|
|
|
555
|
-
// src/
|
|
555
|
+
// src/utils/parse-retry-after-ms.ts
|
|
556
|
+
var import_guards6 = __toESM(require_build());
|
|
557
|
+
var parseRetryAfterMs = (retryAfter) => {
|
|
558
|
+
if (!(0, import_guards6.isNonEmptyString)(retryAfter)) {
|
|
559
|
+
return void 0;
|
|
560
|
+
}
|
|
561
|
+
const retryAfterSeconds = Number(retryAfter);
|
|
562
|
+
if (Number.isFinite(retryAfterSeconds)) {
|
|
563
|
+
return Math.max(retryAfterSeconds * 1e3, 0);
|
|
564
|
+
}
|
|
565
|
+
const retryAtMs = Date.parse(retryAfter);
|
|
566
|
+
return Number.isNaN(retryAtMs) ? void 0 : Math.max(retryAtMs - Date.now(), 0);
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
// src/utils/sleep-for-milliseconds.ts
|
|
556
570
|
var sleepForMilliseconds = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
557
571
|
|
|
572
|
+
// src/utils/fetch-with-retries.ts
|
|
573
|
+
var fetchWithRetries = async ({
|
|
574
|
+
sendRequest,
|
|
575
|
+
maxAttempts,
|
|
576
|
+
isRetryableStatus,
|
|
577
|
+
getRetryDelayMs,
|
|
578
|
+
retryAbortSignal
|
|
579
|
+
}) => {
|
|
580
|
+
const sendAttempt = async ({
|
|
581
|
+
attempt,
|
|
582
|
+
waitedMs
|
|
583
|
+
}) => {
|
|
584
|
+
const response = await sendRequest();
|
|
585
|
+
if (response.ok || !isRetryableStatus(response.status) || attempt + 1 >= maxAttempts) {
|
|
586
|
+
return response;
|
|
587
|
+
}
|
|
588
|
+
const delayMs = getRetryDelayMs({
|
|
589
|
+
attempt,
|
|
590
|
+
retryAfterMs: parseRetryAfterMs(response.headers.get("retry-after")),
|
|
591
|
+
waitedMs
|
|
592
|
+
});
|
|
593
|
+
if (!o(delayMs)) {
|
|
594
|
+
return response;
|
|
595
|
+
}
|
|
596
|
+
await sleepForMilliseconds(delayMs);
|
|
597
|
+
if (o(retryAbortSignal) && retryAbortSignal.aborted) {
|
|
598
|
+
return response;
|
|
599
|
+
}
|
|
600
|
+
await response.body?.cancel();
|
|
601
|
+
return sendAttempt({ attempt: attempt + 1, waitedMs: waitedMs + delayMs });
|
|
602
|
+
};
|
|
603
|
+
return sendAttempt({ attempt: 0, waitedMs: 0 });
|
|
604
|
+
};
|
|
605
|
+
|
|
558
606
|
// src/features/transcripts/logic-functions/utils/fetch-graph-response.ts
|
|
559
|
-
var
|
|
607
|
+
var fetchGraphResponse = async ({
|
|
560
608
|
accessToken,
|
|
561
609
|
url,
|
|
562
610
|
accept,
|
|
563
611
|
method,
|
|
564
|
-
body
|
|
565
|
-
attempt
|
|
612
|
+
body
|
|
566
613
|
}) => {
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
614
|
+
const resolvedUrl = resolveGraphUrlOrThrow(url);
|
|
615
|
+
const response = await fetchWithRetries({
|
|
616
|
+
sendRequest: () => fetch(resolvedUrl, {
|
|
617
|
+
method,
|
|
618
|
+
redirect: "error",
|
|
619
|
+
headers: {
|
|
620
|
+
Authorization: `Bearer ${accessToken}`,
|
|
621
|
+
Accept: accept,
|
|
622
|
+
...o(body) ? { "Content-Type": "application/json" } : {}
|
|
623
|
+
},
|
|
624
|
+
body: o(body) ? JSON.stringify(body) : void 0
|
|
625
|
+
}),
|
|
626
|
+
maxAttempts: GRAPH_REQUEST_MAX_ATTEMPTS,
|
|
627
|
+
isRetryableStatus: (status) => GRAPH_RETRYABLE_STATUSES.has(status),
|
|
628
|
+
getRetryDelayMs: ({ attempt, retryAfterMs }) => o(retryAfterMs) && retryAfterMs > 0 ? retryAfterMs : GRAPH_REQUEST_RETRY_BASE_DELAY_MILLISECONDS * 2 ** attempt
|
|
576
629
|
});
|
|
577
630
|
if (response.ok) {
|
|
578
631
|
return response;
|
|
579
632
|
}
|
|
580
|
-
if (GRAPH_RETRYABLE_STATUSES.has(response.status) && attempt + 1 < GRAPH_REQUEST_MAX_ATTEMPTS) {
|
|
581
|
-
const retryAfterSeconds = Number(response.headers.get("Retry-After"));
|
|
582
|
-
await sleepForMilliseconds(
|
|
583
|
-
retryAfterSeconds > 0 ? retryAfterSeconds * 1e3 : GRAPH_REQUEST_RETRY_BASE_DELAY_MILLISECONDS * 2 ** attempt
|
|
584
|
-
);
|
|
585
|
-
return fetchGraphResponseWithRetries({
|
|
586
|
-
accessToken,
|
|
587
|
-
url,
|
|
588
|
-
accept,
|
|
589
|
-
method,
|
|
590
|
-
body,
|
|
591
|
-
attempt: attempt + 1
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
633
|
const errorBody = await response.json().catch(() => ({}));
|
|
595
|
-
const innerErrorCode = (0,
|
|
596
|
-
const message = (0,
|
|
634
|
+
const innerErrorCode = (0, import_guards7.isNonEmptyString)(errorBody.error?.innerError?.code) ? errorBody.error.innerError.code : void 0;
|
|
635
|
+
const message = (0, import_guards7.isNonEmptyString)(errorBody.error?.message) ? errorBody.error.message : response.statusText;
|
|
597
636
|
throw new GraphRequestError({
|
|
598
|
-
message: `Microsoft Graph request failed (${response.status}${(0,
|
|
637
|
+
message: `Microsoft Graph request failed (${response.status}${(0, import_guards7.isNonEmptyString)(innerErrorCode) ? ` ${innerErrorCode}` : ""}): ${message}`,
|
|
599
638
|
status: response.status,
|
|
600
639
|
innerErrorCode
|
|
601
640
|
});
|
|
602
641
|
};
|
|
603
|
-
var fetchGraphResponse = ({
|
|
604
|
-
url,
|
|
605
|
-
...request
|
|
606
|
-
}) => fetchGraphResponseWithRetries({
|
|
607
|
-
...request,
|
|
608
|
-
url: resolveGraphUrlOrThrow(url),
|
|
609
|
-
attempt: 0
|
|
610
|
-
});
|
|
611
642
|
|
|
612
643
|
// src/features/transcripts/logic-functions/utils/fetch-graph-json.ts
|
|
613
644
|
var fetchGraphJson = async ({
|
|
@@ -634,12 +665,15 @@ var fetchTeamsTenantId = async (accessToken) => {
|
|
|
634
665
|
url: "organization?$select=id"
|
|
635
666
|
});
|
|
636
667
|
const tenantId = page.value?.[0]?.id;
|
|
637
|
-
if (!(0,
|
|
668
|
+
if (!(0, import_guards8.isNonEmptyString)(tenantId)) {
|
|
638
669
|
throw new Error("Microsoft Graph returned no organization to claim");
|
|
639
670
|
}
|
|
640
671
|
return tenantId;
|
|
641
672
|
};
|
|
642
673
|
|
|
674
|
+
// src/features/chat/logic-functions/utils/is-working-teams-workspace-connection.ts
|
|
675
|
+
var isWorkingTeamsWorkspaceConnection = (connection) => connection.scope === "WORKSPACE" && !o(connection.authFailedAt);
|
|
676
|
+
|
|
643
677
|
// src/features/transcripts/constants/teams-oauth-config.ts
|
|
644
678
|
var TEAMS_GRAPH_DIRECTORY_SCOPE = "https://graph.microsoft.com/User.ReadBasic.All";
|
|
645
679
|
|
|
@@ -678,9 +712,9 @@ var getTeamsWorkspaceGraphAccess = async () => {
|
|
|
678
712
|
try {
|
|
679
713
|
const connections = await listTeamsConnections();
|
|
680
714
|
const workspaceConnections = connections.filter(
|
|
681
|
-
|
|
715
|
+
isWorkingTeamsWorkspaceConnection
|
|
682
716
|
);
|
|
683
|
-
if (!(0,
|
|
717
|
+
if (!(0, import_guards9.isNonEmptyArray)(workspaceConnections)) {
|
|
684
718
|
return { success: false, error: NOT_CONNECTED_ERROR_MESSAGE };
|
|
685
719
|
}
|
|
686
720
|
const connection = workspaceConnections.find(
|
|
@@ -693,7 +727,7 @@ var getTeamsWorkspaceGraphAccess = async () => {
|
|
|
693
727
|
const storedTenantId = await ge.get(
|
|
694
728
|
buildTeamsConnectedAccountTenantKvKey(connection.id)
|
|
695
729
|
);
|
|
696
|
-
const tenantId = (0,
|
|
730
|
+
const tenantId = (0, import_guards9.isNonEmptyString)(storedTenantId) ? storedTenantId : await fetchTeamsTenantId(accessToken);
|
|
697
731
|
return { success: true, accessToken, tenantId };
|
|
698
732
|
} catch (error) {
|
|
699
733
|
return { success: false, error: toErrorMessage(error) };
|
|
@@ -701,7 +735,7 @@ var getTeamsWorkspaceGraphAccess = async () => {
|
|
|
701
735
|
};
|
|
702
736
|
|
|
703
737
|
// src/features/chat/logic-functions/utils/persist-teams-user-link.ts
|
|
704
|
-
var
|
|
738
|
+
var import_guards11 = __toESM(require_build());
|
|
705
739
|
|
|
706
740
|
// src/features/chat/logic-functions/data/create-teams-user-link.ts
|
|
707
741
|
var createTeamsUserLink = async ({
|
|
@@ -729,7 +763,7 @@ var createTeamsUserLink = async ({
|
|
|
729
763
|
};
|
|
730
764
|
|
|
731
765
|
// src/features/chat/logic-functions/data/update-teams-user-link.ts
|
|
732
|
-
var
|
|
766
|
+
var import_guards10 = __toESM(require_build());
|
|
733
767
|
var updateTeamsUserLink = async ({
|
|
734
768
|
client,
|
|
735
769
|
id,
|
|
@@ -742,8 +776,8 @@ var updateTeamsUserLink = async ({
|
|
|
742
776
|
__args: {
|
|
743
777
|
id,
|
|
744
778
|
data: {
|
|
745
|
-
...(0,
|
|
746
|
-
...(0,
|
|
779
|
+
...(0, import_guards10.isNonEmptyString)(workspaceMemberId) ? { workspaceMemberId } : {},
|
|
780
|
+
...(0, import_guards10.isNonEmptyString)(name) ? { name } : {},
|
|
747
781
|
...o(source) ? { source } : {}
|
|
748
782
|
}
|
|
749
783
|
},
|
|
@@ -776,7 +810,7 @@ var persistTeamsUserLink = async ({
|
|
|
776
810
|
teamsTenantId,
|
|
777
811
|
teamsUserAadObjectId,
|
|
778
812
|
workspaceMemberId,
|
|
779
|
-
name: (0,
|
|
813
|
+
name: (0, import_guards11.isNonEmptyString)(name) ? name : teamsUserAadObjectId,
|
|
780
814
|
source: TEAMS_USER_LINK_SOURCE.MANUAL
|
|
781
815
|
});
|
|
782
816
|
};
|
|
@@ -784,7 +818,7 @@ var persistTeamsUserLink = async ({
|
|
|
784
818
|
// src/features/chat/logic-functions/handlers/teams-set-user-link-handler.ts
|
|
785
819
|
var teamsSetUserLinkHandler = async (payload) => {
|
|
786
820
|
const { workspaceMemberId, teamsUserAadObjectId, name } = extractTeamsSetUserLinkInput(payload);
|
|
787
|
-
if (!(0,
|
|
821
|
+
if (!(0, import_guards12.isNonEmptyString)(workspaceMemberId) || !(0, import_guards12.isNonEmptyString)(teamsUserAadObjectId)) {
|
|
788
822
|
return {
|
|
789
823
|
success: false,
|
|
790
824
|
message: "Missing required fields",
|