@epam/ai-dial-chat-hooks 1.3.0-dev.326 → 1.3.0-dev.331
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/catalog/resource-folder.d.ts +8 -0
- package/catalog/resource-folder.d.ts.map +1 -0
- package/catalog/resource-folder.js +13 -0
- package/catalog/resource-save-adapter.d.ts +36 -0
- package/catalog/resource-save-adapter.d.ts.map +1 -0
- package/catalog/resource-save-adapter.js +4 -0
- package/catalog/resource-save-adapters.d.ts +93 -0
- package/catalog/resource-save-adapters.d.ts.map +1 -0
- package/catalog/resource-save-adapters.js +116 -0
- package/catalog/resource-save.d.ts +76 -0
- package/catalog/resource-save.d.ts.map +1 -0
- package/catalog/resource-save.js +52 -0
- package/catalog/useApplicationCredentialActions/useApplicationCredentialActions.d.ts +57 -0
- package/catalog/useApplicationCredentialActions/useApplicationCredentialActions.d.ts.map +1 -0
- package/catalog/useApplicationCredentialActions/useApplicationCredentialActions.js +67 -0
- package/catalog/useResourceFolders/useResourceFolders.d.ts +33 -0
- package/catalog/useResourceFolders/useResourceFolders.d.ts.map +1 -0
- package/catalog/useResourceFolders/useResourceFolders.js +58 -0
- package/catalog/useResourceSavePanel/useResourceSavePanel.d.ts +64 -0
- package/catalog/useResourceSavePanel/useResourceSavePanel.d.ts.map +1 -0
- package/catalog/useResourceSavePanel/useResourceSavePanel.js +173 -0
- package/catalog.js +11 -4
- package/entry-points/catalog.d.ts +6 -0
- package/entry-points/catalog.d.ts.map +1 -1
- package/entry-points/external-services.d.ts +4 -0
- package/entry-points/external-services.d.ts.map +1 -1
- package/entry-points/oauth.d.ts +1 -0
- package/entry-points/oauth.d.ts.map +1 -1
- package/entry-points/sharing.d.ts +4 -0
- package/entry-points/sharing.d.ts.map +1 -1
- package/external-services.js +5 -1
- package/index.d.ts +15 -0
- package/index.d.ts.map +1 -1
- package/index.js +183 -169
- package/oauth/callback-exchange.d.ts +49 -0
- package/oauth/callback-exchange.d.ts.map +1 -0
- package/oauth/callback-exchange.js +29 -0
- package/oauth.js +3 -2
- package/package.json +17 -17
- package/scheduled-task/scheduled-task-description.d.ts +2 -3
- package/scheduled-task/scheduled-task-description.d.ts.map +1 -1
- package/scheduled-task/scheduled-task-description.js +26 -26
- package/scheduled-task/scheduled-task-display.d.ts +1 -3
- package/scheduled-task/scheduled-task-display.d.ts.map +1 -1
- package/scheduled-task/scheduled-task-display.js +16 -17
- package/scheduled-task/scheduled-task-next-occurrence.d.ts +3 -3
- package/scheduled-task/scheduled-task-next-occurrence.d.ts.map +1 -1
- package/scheduled-task/scheduled-task-next-occurrence.js +2 -2
- package/scheduled-task/scheduled-task-trigger.d.ts.map +1 -1
- package/scheduled-task/scheduled-task-trigger.js +67 -70
- package/share-invitation/models.d.ts +46 -0
- package/share-invitation/models.d.ts.map +1 -0
- package/share-invitation/share-invitation-error.d.ts +6 -0
- package/share-invitation/share-invitation-error.d.ts.map +1 -0
- package/share-invitation/share-invitation-error.js +37 -0
- package/share-invitation/types.d.ts +10 -0
- package/share-invitation/types.d.ts.map +1 -0
- package/share-invitation/types.js +6 -0
- package/share-invitation/useAcceptShareInvitation/useAcceptShareInvitation.d.ts +9 -0
- package/share-invitation/useAcceptShareInvitation/useAcceptShareInvitation.d.ts.map +1 -0
- package/share-invitation/useAcceptShareInvitation/useAcceptShareInvitation.js +26 -0
- package/sharing.js +5 -2
- package/signin-interrupt/models.d.ts +48 -0
- package/signin-interrupt/models.d.ts.map +1 -0
- package/signin-interrupt/signin-row-info.d.ts +10 -0
- package/signin-interrupt/signin-row-info.d.ts.map +1 -0
- package/signin-interrupt/signin-row-info.js +21 -0
- package/signin-interrupt/types.d.ts +28 -0
- package/signin-interrupt/types.d.ts.map +1 -0
- package/signin-interrupt/types.js +10 -0
- package/signin-interrupt/useSigninInterrupt/useSigninInterrupt.d.ts +52 -0
- package/signin-interrupt/useSigninInterrupt/useSigninInterrupt.d.ts.map +1 -0
- package/signin-interrupt/useSigninInterrupt/useSigninInterrupt.js +270 -0
- package/skill/useSkillEditorSubmit.d.ts +13 -1
- package/skill/useSkillEditorSubmit.d.ts.map +1 -1
- package/skill/useSkillEditorSubmit.js +158 -79
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AcceptInvitationResponseDto, DeploymentItemDto, DialToolsetDto, SkillMetadataItemDto } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
import { AcceptShareInvitationErrorKind } from './types';
|
|
3
|
+
/** Localized sentences shown when accepting a share invitation fails. */
|
|
4
|
+
export interface AcceptShareInvitationErrorLabels {
|
|
5
|
+
/** Sentence for an expired or unknown link. Defaults to `'We are sorry, but the link you are trying to access has expired or does not exist.'`. */
|
|
6
|
+
notFound: string;
|
|
7
|
+
/** Sentence for a reached users limit, given the shared item's name. Defaults to `` (name) => `"${name}" has already been shared with the maximum specified number of users.` ``. */
|
|
8
|
+
usersLimitReached: (name: string) => string;
|
|
9
|
+
/** Sentence for a reached users limit when the backend sent no item name. Defaults to `'This item has already been shared with the maximum specified number of users.'`. */
|
|
10
|
+
usersLimitReachedUnnamed: string;
|
|
11
|
+
/** Sentence for any other failure that carries no message of its own. Defaults to `'This share link is invalid or has expired.'`. */
|
|
12
|
+
acceptError: string;
|
|
13
|
+
}
|
|
14
|
+
/** A classified share-invitation accept failure, ready to show as an error notification. */
|
|
15
|
+
export interface AcceptShareInvitationError {
|
|
16
|
+
/** Why the accept failed. */
|
|
17
|
+
kind: AcceptShareInvitationErrorKind;
|
|
18
|
+
/** User-facing sentence for the failure. */
|
|
19
|
+
message: string;
|
|
20
|
+
/** Trace id to show as the Request ID; set only for `Failed`, since expired and over-the-limit links are expected outcomes. */
|
|
21
|
+
requestId?: string;
|
|
22
|
+
/** Shared item's title sent with a `UsersLimitReached` refusal, when the backend sent one. */
|
|
23
|
+
itemName?: string;
|
|
24
|
+
/** The original thrown value. */
|
|
25
|
+
cause: unknown;
|
|
26
|
+
}
|
|
27
|
+
/** Options for {@link useAcceptShareInvitation}. */
|
|
28
|
+
export interface UseAcceptShareInvitationOptions {
|
|
29
|
+
/** Invitation id from the opened share link; nothing is accepted while it is `undefined`. */
|
|
30
|
+
invitationId: string | undefined;
|
|
31
|
+
/** Already-configured call that accepts the invitation in DIAL Core. */
|
|
32
|
+
acceptInvitation: (invitationId: string) => Promise<AcceptInvitationResponseDto>;
|
|
33
|
+
/** Refreshes the host's lists after the accept and before the shared summaries are merged. Skipped when omitted. */
|
|
34
|
+
refreshLists?: (response: AcceptInvitationResponseDto) => Promise<unknown>;
|
|
35
|
+
/** Receives the backend-resolved model, application or toolset summary, after `refreshLists` settles. */
|
|
36
|
+
onSharedItem?: (item: DeploymentItemDto | DialToolsetDto) => void;
|
|
37
|
+
/** Receives the backend-resolved skill summary, after `refreshLists` settles. */
|
|
38
|
+
onSharedSkill?: (skill: SkillMetadataItemDto) => void;
|
|
39
|
+
/** Called last once the invitation is accepted, e.g. to redirect to `response.itemId`. */
|
|
40
|
+
onAccepted: (response: AcceptInvitationResponseDto) => void;
|
|
41
|
+
/** Called with the classified failure, e.g. to show a notification and redirect to a fallback. */
|
|
42
|
+
onError: (error: AcceptShareInvitationError) => void;
|
|
43
|
+
/** Overrides for the failure sentences. Defaults to {@link DEFAULT_ACCEPT_SHARE_INVITATION_ERROR_LABELS}. */
|
|
44
|
+
labels?: Partial<AcceptShareInvitationErrorLabels>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/share-invitation/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAE9D,yEAAyE;AACzE,MAAM,WAAW,gCAAgC;IAC/C,mJAAmJ;IACnJ,QAAQ,EAAE,MAAM,CAAC;IACjB,qLAAqL;IACrL,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5C,4KAA4K;IAC5K,wBAAwB,EAAE,MAAM,CAAC;IACjC,qIAAqI;IACrI,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,4FAA4F;AAC5F,MAAM,WAAW,0BAA0B;IACzC,6BAA6B;IAC7B,IAAI,EAAE,8BAA8B,CAAC;IACrC,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,+HAA+H;IAC/H,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,oDAAoD;AACpD,MAAM,WAAW,+BAA+B;IAC9C,6FAA6F;IAC7F,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,wEAAwE;IACxE,gBAAgB,EAAE,CAChB,YAAY,EAAE,MAAM,KACjB,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC1C,oHAAoH;IACpH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,2BAA2B,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3E,yGAAyG;IACzG,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,KAAK,IAAI,CAAC;IAClE,iFAAiF;IACjF,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACtD,0FAA0F;IAC1F,UAAU,EAAE,CAAC,QAAQ,EAAE,2BAA2B,KAAK,IAAI,CAAC;IAC5D,kGAAkG;IAClG,OAAO,EAAE,CAAC,KAAK,EAAE,0BAA0B,KAAK,IAAI,CAAC;IACrD,6GAA6G;IAC7G,MAAM,CAAC,EAAE,OAAO,CAAC,gCAAgC,CAAC,CAAC;CACpD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AcceptShareInvitationError, AcceptShareInvitationErrorLabels } from './models';
|
|
2
|
+
/** English sentences used when a host passes no {@link AcceptShareInvitationErrorLabels}. */
|
|
3
|
+
export declare const DEFAULT_ACCEPT_SHARE_INVITATION_ERROR_LABELS: AcceptShareInvitationErrorLabels;
|
|
4
|
+
/** Returns the kind, user-facing sentence and Request ID for a failed share-invitation accept. */
|
|
5
|
+
export declare const resolveAcceptShareInvitationError: (error: unknown, labels?: Partial<AcceptShareInvitationErrorLabels>) => Promise<AcceptShareInvitationError>;
|
|
6
|
+
//# sourceMappingURL=share-invitation-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-invitation-error.d.ts","sourceRoot":"","sources":["../../src/share-invitation/share-invitation-error.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,0BAA0B,EAC1B,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAGlB,6FAA6F;AAC7F,eAAO,MAAM,4CAA4C,EAAE,gCASxD,CAAC;AAEJ,kGAAkG;AAClG,eAAO,MAAM,iCAAiC,GAC5C,OAAO,OAAO,EACd,SAAQ,OAAO,CAAC,gCAAgC,CAAM,KACrD,OAAO,CAAC,0BAA0B,CAuCpC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getAcceptInvitationErrorItemName as e, getApiErrorDetails as t } from "../api-error/api-error.js";
|
|
2
|
+
import { AcceptShareInvitationErrorKind as n } from "./types.js";
|
|
3
|
+
import { ShareInvitationErrorCode as r } from "@epam/ai-dial-chat-api-client";
|
|
4
|
+
//#region src/share-invitation/share-invitation-error.ts
|
|
5
|
+
var i = {
|
|
6
|
+
notFound: "We are sorry, but the link you are trying to access has expired or does not exist.",
|
|
7
|
+
usersLimitReached: (e) => `"${e}" has already been shared with the maximum specified number of users.`,
|
|
8
|
+
usersLimitReachedUnnamed: "This item has already been shared with the maximum specified number of users.",
|
|
9
|
+
acceptError: "This share link is invalid or has expired."
|
|
10
|
+
}, a = async (a, o = {}) => {
|
|
11
|
+
let s = {
|
|
12
|
+
...i,
|
|
13
|
+
...o
|
|
14
|
+
}, { message: c, traceId: l, code: u } = await t(a);
|
|
15
|
+
if (u === r.ShareInvitationNotFound) return {
|
|
16
|
+
kind: n.NotFound,
|
|
17
|
+
message: s.notFound,
|
|
18
|
+
cause: a
|
|
19
|
+
};
|
|
20
|
+
if (u === r.ShareInvitationAcceptedUsersLimitReached) {
|
|
21
|
+
let t = await e(a);
|
|
22
|
+
return {
|
|
23
|
+
kind: n.UsersLimitReached,
|
|
24
|
+
message: t ? s.usersLimitReached(t) : s.usersLimitReachedUnnamed,
|
|
25
|
+
...t ? { itemName: t } : {},
|
|
26
|
+
cause: a
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
kind: n.Failed,
|
|
31
|
+
message: c ?? s.acceptError,
|
|
32
|
+
...l ? { requestId: l } : {},
|
|
33
|
+
cause: a
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { i as DEFAULT_ACCEPT_SHARE_INVITATION_ERROR_LABELS, a as resolveAcceptShareInvitationError };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Why accepting a share invitation failed. */
|
|
2
|
+
export declare enum AcceptShareInvitationErrorKind {
|
|
3
|
+
/** The link has expired or never existed (`ShareInvitationErrorCode.ShareInvitationNotFound`). */
|
|
4
|
+
NotFound = "not-found",
|
|
5
|
+
/** The item is already shared with the maximum number of users (`ShareInvitationErrorCode.ShareInvitationAcceptedUsersLimitReached`). */
|
|
6
|
+
UsersLimitReached = "users-limit-reached",
|
|
7
|
+
/** Any other failure, including a refresh or callback that threw after the accept. */
|
|
8
|
+
Failed = "failed"
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/share-invitation/types.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,oBAAY,8BAA8B;IACxC,kGAAkG;IAClG,QAAQ,cAAc;IACtB,yIAAyI;IACzI,iBAAiB,wBAAwB;IACzC,sFAAsF;IACtF,MAAM,WAAW;CAClB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UseAcceptShareInvitationOptions } from '../models';
|
|
2
|
+
/**
|
|
3
|
+
* Accepts a share invitation once per mount, then refreshes the host's lists,
|
|
4
|
+
* merges the backend-resolved summaries and calls `onAccepted`; any failure
|
|
5
|
+
* goes to `onError` already classified. Callbacks are read at call time, so
|
|
6
|
+
* new identities never re-run the accept.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useAcceptShareInvitation: (options: UseAcceptShareInvitationOptions) => void;
|
|
9
|
+
//# sourceMappingURL=useAcceptShareInvitation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAcceptShareInvitation.d.ts","sourceRoot":"","sources":["../../../src/share-invitation/useAcceptShareInvitation/useAcceptShareInvitation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,WAAW,CAAC;AAGjE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,+BAA+B,KACvC,IA2CF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { resolveAcceptShareInvitationError as e } from "../share-invitation-error.js";
|
|
2
|
+
import { useEffect as t, useRef as n } from "react";
|
|
3
|
+
//#region src/share-invitation/useAcceptShareInvitation/useAcceptShareInvitation.ts
|
|
4
|
+
var r = (r) => {
|
|
5
|
+
let i = n(r);
|
|
6
|
+
t(() => {
|
|
7
|
+
i.current = r;
|
|
8
|
+
});
|
|
9
|
+
let a = n(!1), { invitationId: o } = r;
|
|
10
|
+
t(() => {
|
|
11
|
+
o && !a.current && (a.current = !0, (async () => {
|
|
12
|
+
let { acceptInvitation: t, refreshLists: n, onSharedItem: r, onSharedSkill: a, onAccepted: s } = i.current;
|
|
13
|
+
try {
|
|
14
|
+
let e = await t(o);
|
|
15
|
+
n && await n(e);
|
|
16
|
+
let { sharedDeployment: i, sharedToolset: c, sharedSkill: l } = e, u = i ?? c;
|
|
17
|
+
u && r?.(u), l && a?.(l), s(e);
|
|
18
|
+
} catch (t) {
|
|
19
|
+
let { labels: n, onError: r } = i.current;
|
|
20
|
+
r(await e(t, n));
|
|
21
|
+
}
|
|
22
|
+
})());
|
|
23
|
+
}, [o]);
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { r as useAcceptShareInvitation };
|
package/sharing.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { RecipientsCountStatus as e, useShareRecipientsCount as t } from "./useShareRecipientsCount/useShareRecipientsCount.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { AcceptShareInvitationErrorKind as n } from "./share-invitation/types.js";
|
|
3
|
+
import { DEFAULT_ACCEPT_SHARE_INVITATION_ERROR_LABELS as r, resolveAcceptShareInvitationError as i } from "./share-invitation/share-invitation-error.js";
|
|
4
|
+
import { useAcceptShareInvitation as a } from "./share-invitation/useAcceptShareInvitation/useAcceptShareInvitation.js";
|
|
5
|
+
import { useShareLink as o } from "./useShareLink/useShareLink.js";
|
|
6
|
+
export { n as AcceptShareInvitationErrorKind, r as DEFAULT_ACCEPT_SHARE_INVITATION_ERROR_LABELS, e as RecipientsCountStatus, i as resolveAcceptShareInvitationError, a as useAcceptShareInvitation, o as useShareLink, t as useShareRecipientsCount };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ExternalServiceAuthType, ExternalServiceCredentialsLevel, ExternalServiceOAuthSettings } from '../external-services/useExternalServiceLogin';
|
|
2
|
+
import { ToolsetCredentialsLevel } from '../oauth/types';
|
|
3
|
+
import { PendingSigninEvent } from '../shared/client-channel';
|
|
4
|
+
import { SigninInterruptAnnouncementKind, SigninInterruptRowError, SigninInterruptRowStatus } from './types';
|
|
5
|
+
/** Display and login metadata resolved for the resource behind a pending sign-in event. */
|
|
6
|
+
export interface SigninRowInfo {
|
|
7
|
+
/** Resource display name, or a fallback derived from its id while metadata is missing. */
|
|
8
|
+
displayName: string;
|
|
9
|
+
/** Resource version shown next to the name, when known. */
|
|
10
|
+
displayVersion?: string;
|
|
11
|
+
/** Authentication mechanism, or `undefined` while metadata is missing. */
|
|
12
|
+
authenticationType?: ExternalServiceAuthType;
|
|
13
|
+
/** Credentials level the login targets. */
|
|
14
|
+
credentialsLevel: ToolsetCredentialsLevel | ExternalServiceCredentialsLevel;
|
|
15
|
+
/** OAuth client settings for the authorize URL, when the resource uses OAuth. */
|
|
16
|
+
oauthSettings?: ExternalServiceOAuthSettings;
|
|
17
|
+
}
|
|
18
|
+
/** One pending sign-in event with its resolved metadata and local row state. */
|
|
19
|
+
export interface SigninInterruptRow {
|
|
20
|
+
/** The pending client-channel event this row resolves. */
|
|
21
|
+
event: PendingSigninEvent;
|
|
22
|
+
/** Resolved display and login metadata. */
|
|
23
|
+
info: SigninRowInfo;
|
|
24
|
+
/** Whether a login or decline is in flight. */
|
|
25
|
+
status: SigninInterruptRowStatus;
|
|
26
|
+
/** Shorthand for `status === SigninInterruptRowStatus.Processing`. */
|
|
27
|
+
isProcessing: boolean;
|
|
28
|
+
/** Recoverable failure of the last attempt, if any. */
|
|
29
|
+
error?: SigninInterruptRowError;
|
|
30
|
+
/** API key typed into the row; `''` until the user types. */
|
|
31
|
+
apiKey: string;
|
|
32
|
+
/** Whether the resource takes an API key, so the row shows a key field. */
|
|
33
|
+
requiresApiKey: boolean;
|
|
34
|
+
/** Whether the resource needs no credentials, so the row offers no actions. */
|
|
35
|
+
requiresNoCredentials: boolean;
|
|
36
|
+
/** Whether the resource uses DIAL-native offline credentials. */
|
|
37
|
+
isDialNative: boolean;
|
|
38
|
+
/** Whether `Log in` can be submitted: always, except an API-key row with a blank key. */
|
|
39
|
+
canSubmitLogin: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Status a sign-in interrupt announces after resolving an event. */
|
|
42
|
+
export interface SigninInterruptAnnouncement {
|
|
43
|
+
/** Which resolution happened. */
|
|
44
|
+
kind: SigninInterruptAnnouncementKind;
|
|
45
|
+
/** Display name of the resolved resource; `''` when it is no longer known. */
|
|
46
|
+
name: string;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/signin-interrupt/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,+BAA+B,EAC/B,4BAA4B,EAC7B,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EACV,+BAA+B,EAC/B,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC5B,0FAA0F;IAC1F,WAAW,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,uBAAuB,CAAC;IAC7C,2CAA2C;IAC3C,gBAAgB,EAAE,uBAAuB,GAAG,+BAA+B,CAAC;IAC5E,iFAAiF;IACjF,aAAa,CAAC,EAAE,4BAA4B,CAAC;CAC9C;AAED,gFAAgF;AAChF,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,KAAK,EAAE,kBAAkB,CAAC;IAC1B,2CAA2C;IAC3C,IAAI,EAAE,aAAa,CAAC;IACpB,+CAA+C;IAC/C,MAAM,EAAE,wBAAwB,CAAC;IACjC,sEAAsE;IACtE,YAAY,EAAE,OAAO,CAAC;IACtB,uDAAuD;IACvD,KAAK,CAAC,EAAE,uBAAuB,CAAC;IAChC,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,cAAc,EAAE,OAAO,CAAC;IACxB,+EAA+E;IAC/E,qBAAqB,EAAE,OAAO,CAAC;IAC/B,iEAAiE;IACjE,YAAY,EAAE,OAAO,CAAC;IACtB,yFAAyF;IACzF,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,qEAAqE;AACrE,MAAM,WAAW,2BAA2B;IAC1C,iCAAiC;IACjC,IAAI,EAAE,+BAA+B,CAAC;IACtC,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DialToolsetDto, GetExternalServiceResponseDto } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
import { PendingSigninEvent } from '../shared/client-channel';
|
|
3
|
+
import { SigninRowInfo } from './models';
|
|
4
|
+
/** Returns the key of a pending event's underlying resource: the toolset id, or the external-service scope id. */
|
|
5
|
+
export declare const getSigninEventResourceKey: (event: PendingSigninEvent) => string;
|
|
6
|
+
/** Returns the row metadata for a toolset, falling back to a name derived from its id while `toolset` is unknown. */
|
|
7
|
+
export declare const resolveToolsetSigninRowInfo: (toolsetId: string, toolset: DialToolsetDto | undefined, activeLocale: string, primaryLocale: string) => SigninRowInfo;
|
|
8
|
+
/** Returns the row metadata for an application's external service, falling back to its decoded name while `service` is unknown. */
|
|
9
|
+
export declare const resolveExternalServiceSigninRowInfo: (serviceName: string, service: GetExternalServiceResponseDto | undefined) => SigninRowInfo;
|
|
10
|
+
//# sourceMappingURL=signin-row-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signin-row-info.d.ts","sourceRoot":"","sources":["../../src/signin-interrupt/signin-row-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AAWvC,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,kHAAkH;AAClH,eAAO,MAAM,yBAAyB,GAAI,OAAO,kBAAkB,KAAG,MAGL,CAAC;AAElE,qHAAqH;AACrH,eAAO,MAAM,2BAA2B,GACtC,WAAW,MAAM,EACjB,SAAS,cAAc,GAAG,SAAS,EACnC,cAAc,MAAM,EACpB,eAAe,MAAM,KACpB,aASD,CAAC;AAEH,mIAAmI;AACnI,eAAO,MAAM,mCAAmC,GAC9C,aAAa,MAAM,EACnB,SAAS,6BAA6B,GAAG,SAAS,KACjD,aAiBD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getToolsetFallbackName as e, resolveToolsetCredentialsLevel as t } from "../oauth/toolset-id.js";
|
|
2
|
+
import { resolveLocalizedText as n } from "../shared/locale.js";
|
|
3
|
+
import { toToolsetOAuthSettings as r } from "../oauth/authorize-url.js";
|
|
4
|
+
import { buildExternalServiceScopeId as i, getExternalServiceFallbackName as a } from "../shared/external-services.js";
|
|
5
|
+
import { ExternalServiceAuthStatus as o, ExternalServiceCredentialsLevel as s } from "../external-services/useExternalServiceLogin.js";
|
|
6
|
+
import { PendingSigninEventKind as c } from "../shared/client-channel.js";
|
|
7
|
+
//#region src/signin-interrupt/signin-row-info.ts
|
|
8
|
+
var l = (e) => e.kind === c.Toolset ? e.toolsetId : i(e.appId, e.serviceName), u = (i, a, o, s) => ({
|
|
9
|
+
displayName: n(a?.displayName, o, s) || e(i),
|
|
10
|
+
displayVersion: a?.displayVersion,
|
|
11
|
+
authenticationType: a?.authSettings?.authenticationType,
|
|
12
|
+
credentialsLevel: t(i),
|
|
13
|
+
oauthSettings: r(a?.authSettings)
|
|
14
|
+
}), d = (e, t) => ({
|
|
15
|
+
displayName: t?.displayName || a(e),
|
|
16
|
+
authenticationType: t?.authenticationType,
|
|
17
|
+
credentialsLevel: t?.globalAuthStatus != null && t.globalAuthStatus !== o.SignedIn && t.userLevelAuthStatus == null ? s.Global : s.User,
|
|
18
|
+
oauthSettings: r(t)
|
|
19
|
+
});
|
|
20
|
+
//#endregion
|
|
21
|
+
export { l as getSigninEventResourceKey, d as resolveExternalServiceSigninRowInfo, u as resolveToolsetSigninRowInfo };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Progress of one sign-in interrupt row. */
|
|
2
|
+
export declare enum SigninInterruptRowStatus {
|
|
3
|
+
/** Awaiting the user's login or decline. */
|
|
4
|
+
Idle = "idle",
|
|
5
|
+
/** A login or decline for this row is in flight. */
|
|
6
|
+
Processing = "processing"
|
|
7
|
+
}
|
|
8
|
+
/** Recoverable failure shown on a sign-in interrupt row; the event stays pending. */
|
|
9
|
+
export declare enum SigninInterruptRowError {
|
|
10
|
+
/** The login failed, or reporting its success to DIAL Core failed. */
|
|
11
|
+
LoginFailed = "login-failed",
|
|
12
|
+
/** The browser blocked the OAuth popup. */
|
|
13
|
+
PopupBlocked = "popup-blocked",
|
|
14
|
+
/** Reporting the decline to DIAL Core failed. */
|
|
15
|
+
DeclineFailed = "decline-failed",
|
|
16
|
+
/** A DIAL administrator must approve the application's access first. */
|
|
17
|
+
AdminConsentRequired = "admin-consent-required",
|
|
18
|
+
/** Offline access is not configured for the user's account. */
|
|
19
|
+
OfflineUnavailable = "offline-unavailable"
|
|
20
|
+
}
|
|
21
|
+
/** Kind of status a sign-in interrupt announces after resolving an event. */
|
|
22
|
+
export declare enum SigninInterruptAnnouncementKind {
|
|
23
|
+
/** A login succeeded and its event was reported as `success`. */
|
|
24
|
+
LoginSucceeded = "login-succeeded",
|
|
25
|
+
/** An event was declined and reported as `denied`. */
|
|
26
|
+
Declined = "declined"
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/signin-interrupt/types.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,oBAAY,wBAAwB;IAClC,4CAA4C;IAC5C,IAAI,SAAS;IACb,oDAAoD;IACpD,UAAU,eAAe;CAC1B;AAED,qFAAqF;AACrF,oBAAY,uBAAuB;IACjC,sEAAsE;IACtE,WAAW,iBAAiB;IAC5B,2CAA2C;IAC3C,YAAY,kBAAkB;IAC9B,iDAAiD;IACjD,aAAa,mBAAmB;IAChC,wEAAwE;IACxE,oBAAoB,2BAA2B;IAC/C,+DAA+D;IAC/D,kBAAkB,wBAAwB;CAC3C;AAED,6EAA6E;AAC7E,oBAAY,+BAA+B;IACzC,iEAAiE;IACjE,cAAc,oBAAoB;IAClC,sDAAsD;IACtD,QAAQ,aAAa;CACtB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/signin-interrupt/types.ts
|
|
2
|
+
var e = /* @__PURE__ */ function(e) {
|
|
3
|
+
return e.Idle = "idle", e.Processing = "processing", e;
|
|
4
|
+
}({}), t = /* @__PURE__ */ function(e) {
|
|
5
|
+
return e.LoginFailed = "login-failed", e.PopupBlocked = "popup-blocked", e.DeclineFailed = "decline-failed", e.AdminConsentRequired = "admin-consent-required", e.OfflineUnavailable = "offline-unavailable", e;
|
|
6
|
+
}({}), n = /* @__PURE__ */ function(e) {
|
|
7
|
+
return e.LoginSucceeded = "login-succeeded", e.Declined = "declined", e;
|
|
8
|
+
}({});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { n as SigninInterruptAnnouncementKind, t as SigninInterruptRowError, e as SigninInterruptRowStatus };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DialToolsetDto, GetExternalServiceResponseDto, ReportClientChannelDtoResultEnum } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
import { ExternalServiceLoginOutcome, ExternalServiceLoginParams } from '../../external-services/useExternalServiceLogin';
|
|
3
|
+
import { ToolsetLoginOutcome, ToolsetLoginParams } from '../../oauth/useToolsetLogin/useToolsetLogin';
|
|
4
|
+
import { PendingSigninEvent } from '../../shared/client-channel';
|
|
5
|
+
import { SigninInterruptAnnouncement, SigninInterruptRow } from '../models';
|
|
6
|
+
/** Host data and operations `useSigninInterrupt` resolves pending sign-in events with. */
|
|
7
|
+
export interface UseSigninInterruptOptions {
|
|
8
|
+
/** Pending client-channel sign-in events, in display order. */
|
|
9
|
+
pendingEvents: PendingSigninEvent[];
|
|
10
|
+
/** Toolsets the host already has loaded; a listed toolset is not fetched again. */
|
|
11
|
+
toolsets: DialToolsetDto[];
|
|
12
|
+
/** Locale toolset display names are resolved for. */
|
|
13
|
+
activeLocale: string;
|
|
14
|
+
/** Locale used when a display name has no entry for `activeLocale`. */
|
|
15
|
+
primaryLocale: string;
|
|
16
|
+
/** Fetches a toolset that `toolsets` does not list; a rejection keeps the fallback name. */
|
|
17
|
+
getToolset: (toolsetId: string) => Promise<DialToolsetDto>;
|
|
18
|
+
/** Fetches an application's external service; a rejection keeps the fallback name. */
|
|
19
|
+
getExternalService: (appId: string, serviceName: string) => Promise<GetExternalServiceResponseDto>;
|
|
20
|
+
/** Logs in to a toolset, e.g. `useToolsetLogin().login`. */
|
|
21
|
+
loginToolset: (params: ToolsetLoginParams) => Promise<ToolsetLoginOutcome>;
|
|
22
|
+
/** Logs in to an external service, e.g. `useExternalServiceLogin().login`. */
|
|
23
|
+
loginExternalService: (params: ExternalServiceLoginParams) => Promise<ExternalServiceLoginOutcome>;
|
|
24
|
+
/** Refreshes the host's toolset list after a successful toolset login, before success is reported. */
|
|
25
|
+
refetchToolsets: () => Promise<unknown>;
|
|
26
|
+
/** Reports an event's resolution on the client channel; a rejection leaves the event pending. */
|
|
27
|
+
reportEvent: (eventId: string, result: ReportClientChannelDtoResultEnum) => Promise<unknown>;
|
|
28
|
+
}
|
|
29
|
+
/** Rows, announcement and actions of a sign-in interrupt dialog. */
|
|
30
|
+
export interface UseSigninInterruptResult {
|
|
31
|
+
/** One row per pending event, in `pendingEvents` order. */
|
|
32
|
+
rows: SigninInterruptRow[];
|
|
33
|
+
/** Latest resolution to announce, or `undefined` before the first one. */
|
|
34
|
+
announcement?: SigninInterruptAnnouncement;
|
|
35
|
+
/** Whether logins grant offline-use consent. Defaults to `true`. */
|
|
36
|
+
offlineUsageConsent: boolean;
|
|
37
|
+
/** Sets `offlineUsageConsent`. */
|
|
38
|
+
setOfflineUsageConsent: (value: boolean) => void;
|
|
39
|
+
/** Whether any row uses an API key or OAuth, so the offline-use consent control applies. */
|
|
40
|
+
isOfflineUsageConsentShown: boolean;
|
|
41
|
+
/** Stores a row's typed API key and clears its error. */
|
|
42
|
+
changeApiKey: (eventId: string, value: string) => void;
|
|
43
|
+
/** Starts a login for a row; synchronous up to the login call so an OAuth popup stays inside the click. */
|
|
44
|
+
login: (eventId: string) => void;
|
|
45
|
+
/** Reports a row as `denied`. */
|
|
46
|
+
decline: (eventId: string) => Promise<void>;
|
|
47
|
+
/** Declines every pending event. */
|
|
48
|
+
declineAll: () => void;
|
|
49
|
+
}
|
|
50
|
+
/** Resolves pending sign-in events into dialog rows and runs their login, decline and result reporting. */
|
|
51
|
+
export declare const useSigninInterrupt: ({ pendingEvents, toolsets, activeLocale, primaryLocale, getToolset, getExternalService, loginToolset, loginExternalService, refetchToolsets, reportEvent, }: UseSigninInterruptOptions) => UseSigninInterruptResult;
|
|
52
|
+
//# sourceMappingURL=useSigninInterrupt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSigninInterrupt.d.ts","sourceRoot":"","sources":["../../../src/signin-interrupt/useSigninInterrupt/useSigninInterrupt.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,6BAA6B,EAClC,gCAAgC,EACjC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAGL,KAAK,2BAA2B,EAEhC,KAAK,0BAA0B,EAChC,MAAM,iDAAiD,CAAC;AAKzD,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,kBAAkB,EACxB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAEL,KAAK,kBAAkB,EAGxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EACV,2BAA2B,EAC3B,kBAAkB,EAEnB,MAAM,WAAW,CAAC;AAYnB,0FAA0F;AAC1F,MAAM,WAAW,yBAAyB;IACxC,+DAA+D;IAC/D,aAAa,EAAE,kBAAkB,EAAE,CAAC;IACpC,mFAAmF;IACnF,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,qDAAqD;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,4FAA4F;IAC5F,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3D,sFAAsF;IACtF,kBAAkB,EAAE,CAClB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,KAChB,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC5C,4DAA4D;IAC5D,YAAY,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC3E,8EAA8E;IAC9E,oBAAoB,EAAE,CACpB,MAAM,EAAE,0BAA0B,KAC/B,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC1C,sGAAsG;IACtG,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,iGAAiG;IACjG,WAAW,EAAE,CACX,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gCAAgC,KACrC,OAAO,CAAC,OAAO,CAAC,CAAC;CACvB;AAED,oEAAoE;AACpE,MAAM,WAAW,wBAAwB;IACvC,2DAA2D;IAC3D,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,0EAA0E;IAC1E,YAAY,CAAC,EAAE,2BAA2B,CAAC;IAC3C,oEAAoE;IACpE,mBAAmB,EAAE,OAAO,CAAC;IAC7B,kCAAkC;IAClC,sBAAsB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,4FAA4F;IAC5F,0BAA0B,EAAE,OAAO,CAAC;IACpC,yDAAyD;IACzD,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,2GAA2G;IAC3G,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,iCAAiC;IACjC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,oCAAoC;IACpC,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AA0BD,2GAA2G;AAC3G,eAAO,MAAM,kBAAkB,GAAI,6JAWhC,yBAAyB,KAAG,wBA4a9B,CAAC"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { ToolsetAuthTypes as e } from "../../oauth/types.js";
|
|
2
|
+
import { ToolsetLoginOutcomeType as t } from "../../oauth/useToolsetLogin/useToolsetLogin.js";
|
|
3
|
+
import { buildExternalServiceScopeId as n } from "../../shared/external-services.js";
|
|
4
|
+
import { ExternalServiceAuthType as r, ExternalServiceLoginOutcomeType as i } from "../../external-services/useExternalServiceLogin.js";
|
|
5
|
+
import { PendingSigninEventKind as a } from "../../shared/client-channel.js";
|
|
6
|
+
import { getSigninEventResourceKey as o, resolveExternalServiceSigninRowInfo as s, resolveToolsetSigninRowInfo as c } from "../signin-row-info.js";
|
|
7
|
+
import { SigninInterruptAnnouncementKind as l, SigninInterruptRowError as u, SigninInterruptRowStatus as d } from "../types.js";
|
|
8
|
+
import { ReportClientChannelDtoResultEnum as f } from "@epam/ai-dial-chat-api-client";
|
|
9
|
+
import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
|
|
10
|
+
//#region src/signin-interrupt/useSigninInterrupt/useSigninInterrupt.ts
|
|
11
|
+
var v = {
|
|
12
|
+
status: d.Idle,
|
|
13
|
+
apiKey: ""
|
|
14
|
+
}, y = (e, t) => e.kind === a.Toolset ? c(e.toolsetId, void 0, t, t) : s(e.serviceName, void 0), b = ({ pendingEvents: b, toolsets: x, activeLocale: S, primaryLocale: C, getToolset: w, getExternalService: T, loginToolset: E, loginExternalService: D, refetchToolsets: O, reportEvent: k }) => {
|
|
15
|
+
let [A, j] = _({}), [M, N] = _({}), [P, F] = _({}), [I, L] = _(), [R, z] = _(!0), B = g(/* @__PURE__ */ new Set()), V = g(/* @__PURE__ */ new Set()), H = g(/* @__PURE__ */ new Set()), U = p((e) => A[e] ?? v, [A]);
|
|
16
|
+
m(() => {
|
|
17
|
+
let e = new Set(b.map((e) => e.id));
|
|
18
|
+
j((t) => {
|
|
19
|
+
let n = !1, r = {};
|
|
20
|
+
for (let [i, a] of Object.entries(t)) e.has(i) ? r[i] = a : n = !0;
|
|
21
|
+
return n ? r : t;
|
|
22
|
+
});
|
|
23
|
+
for (let t of Array.from(H.current)) e.has(t) || H.current.delete(t);
|
|
24
|
+
}, [b]);
|
|
25
|
+
let W = p((e, t) => {
|
|
26
|
+
j((n) => ({
|
|
27
|
+
...n,
|
|
28
|
+
[e]: {
|
|
29
|
+
...n[e] ?? v,
|
|
30
|
+
...t
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
}, []);
|
|
34
|
+
m(() => {
|
|
35
|
+
let e = async (e) => {
|
|
36
|
+
try {
|
|
37
|
+
let t = await w(e);
|
|
38
|
+
N((n) => ({
|
|
39
|
+
...n,
|
|
40
|
+
[e]: t
|
|
41
|
+
}));
|
|
42
|
+
} catch {} finally {
|
|
43
|
+
B.current.delete(e);
|
|
44
|
+
}
|
|
45
|
+
}, t = async (e, t, n) => {
|
|
46
|
+
try {
|
|
47
|
+
let r = await T(e, t);
|
|
48
|
+
F((e) => ({
|
|
49
|
+
...e,
|
|
50
|
+
[n]: r
|
|
51
|
+
}));
|
|
52
|
+
} catch {} finally {
|
|
53
|
+
V.current.delete(n);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
for (let r of b) if (r.kind === a.Toolset) {
|
|
57
|
+
if ((x.find((e) => e.id === r.toolsetId) ?? M[r.toolsetId]) || B.current.has(r.toolsetId)) continue;
|
|
58
|
+
B.current.add(r.toolsetId), e(r.toolsetId);
|
|
59
|
+
} else {
|
|
60
|
+
let { appId: e, serviceName: i } = r, a = n(e, i);
|
|
61
|
+
if (P[a] || V.current.has(a)) continue;
|
|
62
|
+
V.current.add(a), t(e, i, a);
|
|
63
|
+
}
|
|
64
|
+
}, [
|
|
65
|
+
b,
|
|
66
|
+
x,
|
|
67
|
+
M,
|
|
68
|
+
P,
|
|
69
|
+
w,
|
|
70
|
+
T
|
|
71
|
+
]);
|
|
72
|
+
let G = h(() => {
|
|
73
|
+
let e = /* @__PURE__ */ new Map();
|
|
74
|
+
for (let t of b) {
|
|
75
|
+
let n = o(t);
|
|
76
|
+
if (!e.has(n)) {
|
|
77
|
+
if (t.kind === a.Toolset) {
|
|
78
|
+
let r = x.find((e) => e.id === t.toolsetId) ?? M[t.toolsetId];
|
|
79
|
+
e.set(n, c(t.toolsetId, r, S, C));
|
|
80
|
+
} else e.set(n, s(t.serviceName, P[n]));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return e;
|
|
84
|
+
}, [
|
|
85
|
+
b,
|
|
86
|
+
x,
|
|
87
|
+
M,
|
|
88
|
+
P,
|
|
89
|
+
S,
|
|
90
|
+
C
|
|
91
|
+
]), K = p((e) => G.get(o(e)) ?? y(e, C), [G, C]), q = p(async (e, t) => {
|
|
92
|
+
await k(e, f.Success), L({
|
|
93
|
+
kind: l.LoginSucceeded,
|
|
94
|
+
name: t
|
|
95
|
+
});
|
|
96
|
+
}, [k]);
|
|
97
|
+
m(() => {
|
|
98
|
+
for (let e of b) {
|
|
99
|
+
if (e.kind !== a.ExternalService) continue;
|
|
100
|
+
let t = G.get(o(e));
|
|
101
|
+
t?.authenticationType === r.None && (H.current.has(e.id) || (H.current.add(e.id), q(e.id, t.displayName)));
|
|
102
|
+
}
|
|
103
|
+
}, [
|
|
104
|
+
b,
|
|
105
|
+
G,
|
|
106
|
+
q
|
|
107
|
+
]);
|
|
108
|
+
let ee = p((e, t) => {
|
|
109
|
+
W(e, {
|
|
110
|
+
apiKey: t,
|
|
111
|
+
error: void 0
|
|
112
|
+
});
|
|
113
|
+
}, [W]), J = p(async (e) => {
|
|
114
|
+
W(e, {
|
|
115
|
+
status: d.Processing,
|
|
116
|
+
error: void 0
|
|
117
|
+
});
|
|
118
|
+
try {
|
|
119
|
+
await k(e, f.Denied);
|
|
120
|
+
let t = b.find((t) => t.id === e);
|
|
121
|
+
L({
|
|
122
|
+
kind: l.Declined,
|
|
123
|
+
name: t ? G.get(o(t))?.displayName ?? "" : ""
|
|
124
|
+
});
|
|
125
|
+
} catch {
|
|
126
|
+
W(e, {
|
|
127
|
+
status: d.Idle,
|
|
128
|
+
error: u.DeclineFailed
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}, [
|
|
132
|
+
k,
|
|
133
|
+
W,
|
|
134
|
+
b,
|
|
135
|
+
G
|
|
136
|
+
]), te = p(() => {
|
|
137
|
+
for (let e of b) J(e.id);
|
|
138
|
+
}, [b, J]), Y = p((e, t) => b.filter((n) => n.id !== e.id && n.kind === e.kind && o(n) === o(e) && G.get(o(n))?.credentialsLevel === t.credentialsLevel).map((e) => e.id), [b, G]), X = p(async (e, t) => {
|
|
139
|
+
let n = Y(e, t);
|
|
140
|
+
try {
|
|
141
|
+
await q(e.id, t.displayName);
|
|
142
|
+
} catch {
|
|
143
|
+
W(e.id, {
|
|
144
|
+
status: d.Idle,
|
|
145
|
+
error: u.LoginFailed
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
for (let e of n) k(e, f.Success);
|
|
150
|
+
}, [
|
|
151
|
+
Y,
|
|
152
|
+
q,
|
|
153
|
+
k,
|
|
154
|
+
W
|
|
155
|
+
]), Z = p((e, t) => {
|
|
156
|
+
W(e, {
|
|
157
|
+
status: d.Idle,
|
|
158
|
+
error: t
|
|
159
|
+
});
|
|
160
|
+
}, [W]), Q = p(async (n, r, i) => {
|
|
161
|
+
switch ((await E({
|
|
162
|
+
toolsetId: n.toolsetId,
|
|
163
|
+
credentialsLevel: r.credentialsLevel,
|
|
164
|
+
authenticationType: r.authenticationType ?? e.ApiKey,
|
|
165
|
+
apiKey: i,
|
|
166
|
+
oauthSettings: r.oauthSettings,
|
|
167
|
+
forceStale: !0,
|
|
168
|
+
offlineUsageConsent: R
|
|
169
|
+
})).type) {
|
|
170
|
+
case t.Success:
|
|
171
|
+
await O(), await X(n, r);
|
|
172
|
+
return;
|
|
173
|
+
case t.PopupBlocked:
|
|
174
|
+
Z(n.id, u.PopupBlocked);
|
|
175
|
+
return;
|
|
176
|
+
case t.Failure:
|
|
177
|
+
Z(n.id, u.LoginFailed);
|
|
178
|
+
return;
|
|
179
|
+
default: Z(n.id);
|
|
180
|
+
}
|
|
181
|
+
}, [
|
|
182
|
+
E,
|
|
183
|
+
R,
|
|
184
|
+
O,
|
|
185
|
+
X,
|
|
186
|
+
Z
|
|
187
|
+
]), $ = p(async (e, t, n) => {
|
|
188
|
+
switch ((await D({
|
|
189
|
+
appId: e.appId,
|
|
190
|
+
serviceId: e.serviceName,
|
|
191
|
+
credentialsLevel: t.credentialsLevel,
|
|
192
|
+
authenticationType: t.authenticationType ?? r.ApiKey,
|
|
193
|
+
apiKey: n,
|
|
194
|
+
oauthSettings: t.oauthSettings,
|
|
195
|
+
forceStale: !0,
|
|
196
|
+
offlineUsageConsent: R
|
|
197
|
+
})).type) {
|
|
198
|
+
case i.Success:
|
|
199
|
+
await X(e, t);
|
|
200
|
+
return;
|
|
201
|
+
case i.AdminConsentRequired:
|
|
202
|
+
Z(e.id, u.AdminConsentRequired);
|
|
203
|
+
return;
|
|
204
|
+
case i.OfflineUnavailable:
|
|
205
|
+
Z(e.id, u.OfflineUnavailable);
|
|
206
|
+
return;
|
|
207
|
+
case i.PopupBlocked:
|
|
208
|
+
Z(e.id, u.PopupBlocked);
|
|
209
|
+
return;
|
|
210
|
+
case i.Failure:
|
|
211
|
+
Z(e.id, u.LoginFailed);
|
|
212
|
+
return;
|
|
213
|
+
default: Z(e.id);
|
|
214
|
+
}
|
|
215
|
+
}, [
|
|
216
|
+
D,
|
|
217
|
+
R,
|
|
218
|
+
X,
|
|
219
|
+
Z
|
|
220
|
+
]), ne = p((e) => {
|
|
221
|
+
let t = b.find((t) => t.id === e);
|
|
222
|
+
if (!t) return;
|
|
223
|
+
let n = K(t), { apiKey: r } = U(e);
|
|
224
|
+
W(e, {
|
|
225
|
+
status: d.Processing,
|
|
226
|
+
error: void 0
|
|
227
|
+
}), t.kind === a.Toolset ? Q(t, n, r) : $(t, n, r);
|
|
228
|
+
}, [
|
|
229
|
+
b,
|
|
230
|
+
K,
|
|
231
|
+
U,
|
|
232
|
+
W,
|
|
233
|
+
Q,
|
|
234
|
+
$
|
|
235
|
+
]);
|
|
236
|
+
return {
|
|
237
|
+
rows: h(() => b.map((e) => {
|
|
238
|
+
let t = K(e), { status: n, error: i, apiKey: a } = U(e.id), o = t.authenticationType === r.ApiKey;
|
|
239
|
+
return {
|
|
240
|
+
event: e,
|
|
241
|
+
info: t,
|
|
242
|
+
status: n,
|
|
243
|
+
isProcessing: n === d.Processing,
|
|
244
|
+
error: i,
|
|
245
|
+
apiKey: a,
|
|
246
|
+
requiresApiKey: o,
|
|
247
|
+
requiresNoCredentials: t.authenticationType === r.None,
|
|
248
|
+
isDialNative: t.authenticationType === r.DialNative,
|
|
249
|
+
canSubmitLogin: !o || a.trim().length > 0
|
|
250
|
+
};
|
|
251
|
+
}), [
|
|
252
|
+
b,
|
|
253
|
+
K,
|
|
254
|
+
U
|
|
255
|
+
]),
|
|
256
|
+
announcement: I,
|
|
257
|
+
offlineUsageConsent: R,
|
|
258
|
+
setOfflineUsageConsent: z,
|
|
259
|
+
isOfflineUsageConsentShown: h(() => b.some((e) => {
|
|
260
|
+
let t = G.get(o(e))?.authenticationType;
|
|
261
|
+
return t === r.ApiKey || t === r.OAuth;
|
|
262
|
+
}), [b, G]),
|
|
263
|
+
changeApiKey: ee,
|
|
264
|
+
login: ne,
|
|
265
|
+
decline: J,
|
|
266
|
+
declineAll: te
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
//#endregion
|
|
270
|
+
export { b as useSigninInterrupt };
|