@epam/ai-dial-chat-hooks 1.1.0-dev.423 → 1.1.0-dev.426
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/{api-error-DuLNy43N.js → api-error/api-error.js} +1 -1
- package/api-transport/create-csrf-middleware.js +21 -0
- package/api-transport/create-unauthorized-middleware.js +41 -0
- package/attachment/useAttachmentAction/useAttachmentAction.js +74 -0
- package/attachment/useAttachmentValidation/useAttachmentValidation.js +35 -0
- package/attachments.js +3 -2
- package/catalog/catalog-derivations.js +10 -0
- package/catalog/catalog-primary-action.js +21 -0
- package/catalog/create-publish-api.js +27 -0
- package/catalog/deployment-endpoint-url.js +34 -0
- package/{deployment-id-CxWgJTs9.js → catalog/deployment-id.js} +1 -1
- package/catalog/entity-details.js +6 -0
- package/catalog/map-deployment-limits-to-catalog.js +73 -0
- package/catalog/map-deployment-limits-to-input.js +14 -0
- package/catalog/map-deployment-to-catalog-item.js +92 -0
- package/catalog/map-entity-details-to-catalog.js +350 -0
- package/catalog/map-prompt-to-catalog-item.js +49 -0
- package/catalog/map-skill-to-catalog-item.js +123 -0
- package/catalog/mcp-endpoint-url.js +26 -0
- package/catalog/publish.js +18 -0
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +109 -0
- package/catalog/useCatalogItemDetails.js +101 -0
- package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js +146 -0
- package/catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js +50 -0
- package/catalog/usePublishFolders/usePublishFolders.js +72 -0
- package/catalog.js +22 -3
- package/conversation/announcement-message.js +42 -0
- package/conversation/conversation-transfer/async.js +18 -0
- package/conversation/conversation-transfer/attachment-refs.js +11 -0
- package/conversation/conversation-transfer/build-upload-path.js +27 -0
- package/{date-BeuD8G79.js → conversation/conversation-transfer/date.js} +1 -1
- package/conversation/conversation-transfer/dial-file-resolve.js +18 -0
- package/conversation/conversation-transfer/export-conversation.js +32 -0
- package/conversation/conversation-transfer/import-conversation.js +93 -0
- package/conversation/conversation-transfer/progress.js +39 -0
- package/conversation/conversation-transfer/queue.js +84 -0
- package/conversation/conversation-transfer/types.js +9 -0
- package/conversation/conversation-transfer/zip-export.js +19 -0
- package/conversation/conversation-transfer/zip-import.js +29 -0
- package/conversation/create-chat-stream-api.js +96 -0
- package/conversation/deriveConversationRowActionState/deriveConversationRowActionState.js +14 -0
- package/conversation/display-name-watch.js +5 -0
- package/conversation/footer-message.js +23 -0
- package/conversation/get-model-id-from-conversation-id.js +14 -0
- package/conversation/greeting.js +7 -0
- package/conversation/message-factory.js +19 -0
- package/conversation/message-utils.js +13 -0
- package/conversation/overlay-messages.js +8 -0
- package/conversation/quick-app-conversation-starters.js +29 -0
- package/conversation/starter-option.js +27 -0
- package/conversation/useActiveConversationSync/useActiveConversationSync.js +19 -0
- package/conversation/useAsyncConfirmDialog/useAsyncConfirmDialog.js +39 -0
- package/conversation/useAttachmentUpload/useAttachmentUpload.js +33 -0
- package/conversation/useConversationExport/useConversationExport.js +285 -0
- package/conversation/useConversationHandlers/attachment-to-dto.js +13 -0
- package/conversation/useConversationHandlers/message-factory.js +21 -0
- package/conversation/useConversationHandlers/message-utils.js +8 -0
- package/conversation/useConversationHandlers/starter-option.js +11 -0
- package/conversation/useConversationHandlers/useConversationHandlers.js +263 -0
- package/conversation/useConversationImport/useConversationImport.js +239 -0
- package/conversation/useConversationLookupMaps/useConversationLookupMaps.js +11 -0
- package/conversation/useConversationPanelItems/useConversationPanelItems.js +35 -0
- package/{useConversationScroll-CliIMnjP.js → conversation/useConversationScroll/useConversationScroll.js} +1 -1
- package/conversation/useConversationStream/apply-chunk.js +78 -0
- package/conversation/useConversationStream/buffered-generation.js +18 -0
- package/conversation/useConversationStream/conversation-path.js +8 -0
- package/conversation/useConversationStream/generation-resume.js +126 -0
- package/conversation/useConversationStream/useConversationStream.js +148 -0
- package/conversation/useImportFilePicker/useImportFilePicker.js +20 -0
- package/conversation/useTranscribeAudio/audio-transcription-error.js +12 -0
- package/conversation/useTranscribeAudio/transcription-retry.js +38 -0
- package/conversation/useTranscribeAudio/useTranscribeAudio.js +41 -0
- package/{useConversationSources-DKaKvjXZ.js → conversation-sources/useConversationSources/useConversationSources.js} +1 -1
- package/conversation-sources.js +1 -1
- package/conversation-transfer.js +7 -3
- package/conversation.d.ts +66 -0
- package/conversation.js +31 -2
- package/file-manager.d.ts +3 -4
- package/file-manager.js +28 -3
- package/files/annotation.js +15 -0
- package/files/attachment-canvas.js +218 -0
- package/files/attachment-dto-to-display.js +15 -0
- package/files/attachment-types.js +16 -0
- package/files/create-files-api.js +40 -0
- package/files/create-upload-file-with-progress.js +42 -0
- package/files/dial-file-manager-copy-move.util.js +55 -0
- package/files/dial-file-manager-mapping.util.js +140 -0
- package/files/dial-file-manager-path.util.js +72 -0
- package/files/dial-file-manager.model.js +25 -0
- package/files/dial-file-manager.types.js +10 -0
- package/files/dial-file-to-attachment.js +37 -0
- package/files/dial-file.js +30 -0
- package/files/dial-files-api.js +6 -0
- package/files/download-destination.js +6 -0
- package/files/file-manager-variant.js +11 -0
- package/files/file-name.js +19 -0
- package/files/prepare-download-destination.js +24 -0
- package/files/resolve-dial-file-api-path.js +33 -0
- package/files/source-content.js +37 -0
- package/files/useDialFileListing/useDialFileListing.js +295 -0
- package/files/useDialFileManager/useDialFileManager.js +146 -0
- package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +23 -0
- package/files/useDialFileMetadata/useDialFileMetadata.js +42 -0
- package/files/useDialFileMutations/useDialFileMutations.js +359 -0
- package/files/useDialFileSharing/useDialFileSharing.js +70 -0
- package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +156 -0
- package/index.d.ts +69 -4
- package/index.js +134 -28
- package/mcp-apps/mcp-apps-api-client.js +48 -0
- package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +26 -0
- package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +26 -0
- package/mcp-apps/useMcpAppTools/useMcpAppTools.js +71 -0
- package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +58 -0
- package/mcp-apps.js +6 -2
- package/oauth/authorize-url.js +12 -0
- package/oauth/handshake.js +65 -0
- package/oauth/popup.js +29 -0
- package/oauth/toolset-id.js +10 -0
- package/oauth/types.js +24 -0
- package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.js +94 -0
- package/oauth/useToolsetLogin/useToolsetLogin.js +73 -0
- package/oauth.js +9 -3
- package/package.json +35 -23
- package/prompt/export-prompt.js +28 -0
- package/prompt/prompt-resource.js +15 -0
- package/prompt/prompt.js +12 -0
- package/prompt/usePromptsState/usePromptsState.js +42 -0
- package/scheduled-task/scheduled-task-mapping.js +6 -0
- package/{scheduled-task-trigger-D9RZCk52.js → scheduled-task/scheduled-task-trigger.js} +39 -40
- package/scheduled-tasks.js +3 -2
- package/scroll-anchoring.js +1 -1
- package/shared/application-schema.js +4 -0
- package/shared/browser-timezone.js +10 -0
- package/{cron-weekday-B4w29eAC.js → shared/cron-weekday.js} +1 -1
- package/shared/custom-apps.js +30 -0
- package/shared/external-services.js +18 -0
- package/{formatting-CZyyxBG3.js → shared/formatting.js} +1 -1
- package/{prompt-resource-Bt1I-8ri.js → shared/locale.js} +2 -13
- package/{string-utils-iBi2Y55C.js → shared/string-utils.js} +1 -1
- package/shared/toolset-login-events.js +13 -0
- package/sharing.js +3 -3
- package/skill/skill-file-batch-validation.js +48 -0
- package/skill/skill-file-preview.js +15 -0
- package/skill/skill-manifest.js +70 -0
- package/skill/skill-types.js +15 -0
- package/skill/skill.js +48 -0
- package/skill/useSkillEditorLoad.js +103 -0
- package/skill/useSkillEditorSubmit.js +135 -0
- package/skill/useSkillFileActions.js +99 -0
- package/skill/useSkillFilePreview.js +29 -0
- package/{useSkillsState-BoLlwmzb.js → skill/useSkillsState/useSkillsState.js} +1 -1
- package/skill-editor.js +8 -3
- package/skills-state.js +1 -1
- package/source-content.d.ts +29 -0
- package/source-content.js +2 -0
- package/usage/useUsageData/useUsageData.js +32 -0
- package/useChatSettingsFormConfig/useChatSettingsFormConfig.js +74 -0
- package/{usePanelMaxWidth-BEZYuqF9.js → usePageFileDrag/usePageFileDrag.js} +1 -11
- package/usePanelMaxWidth/usePanelMaxWidth.js +8 -0
- package/{useShareLink-xkiaxATt.js → useShareLink/useShareLink.js} +1 -1
- package/{useShareRecipientsCount-BgwCLKY0.js → useShareRecipientsCount/useShareRecipientsCount.js} +1 -1
- package/useToolsMenu/useToolsMenu.js +50 -0
- package/useViewportWidth/useViewportWidth.js +12 -0
- package/utils.js +17 -7
- package/viewport-layout.js +4 -2
- package/attachment-types-AAoN9E95.js +0 -7760
- package/browser-Btsa0Lmr.js +0 -607
- package/skill-manifest-CeG6-WSK.js +0 -4056
- package/useAttachmentValidation-CkMTd5lA.js +0 -102
- package/useConversationImport-CDRs7JF1.js +0 -826
- package/useDialFileManagerTabConfig-CjI46lMo.js +0 -2291
- package/useOAuthCallbackCompletion-CvyTKLER.js +0 -93
- package/useOpenMcpAppCanvas-C7-AMseH.js +0 -207
- package/useSkillFileActions-B-VaGD20.js +0 -373
- package/useSkillFilePreview-B5o1n_0F.js +0 -1244
- package/useToolsMenu-zURpMEn1.js +0 -1882
- package/useToolsetLogin-B05m134e.js +0 -195
- package/useUsageData-D7BxloKZ.js +0 -201
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { generateUUID as e } from "@epam/ai-dial-chat-shared";
|
|
2
|
-
import { useCallback as t } from "react";
|
|
3
|
-
//#region src/oauth/toolset-id.ts
|
|
4
|
-
var n = "toolsets/", r = "public", i = (e) => e.split("/").map((e) => encodeURIComponent(e)).join("/"), a = (e) => e.split("/").map((e) => {
|
|
5
|
-
try {
|
|
6
|
-
return decodeURIComponent(e);
|
|
7
|
-
} catch {
|
|
8
|
-
return e;
|
|
9
|
-
}
|
|
10
|
-
}).join("/"), o = (e) => e.startsWith(n) ? e.slice(9).split("/")[0] === r : !1, s = /* @__PURE__ */ function(e) {
|
|
11
|
-
return e.None = "NONE", e.ApiKey = "API_KEY", e.OAuth = "OAUTH", e;
|
|
12
|
-
}({}), c = /* @__PURE__ */ function(e) {
|
|
13
|
-
return e.SignedIn = "SIGNED_IN", e.SignedOut = "SIGNED_OUT", e.Failed = "FAILED", e;
|
|
14
|
-
}({}), l = /* @__PURE__ */ function(e) {
|
|
15
|
-
return e.Global = "GLOBAL", e.User = "USER", e.App = "APP", e;
|
|
16
|
-
}({}), u = /* @__PURE__ */ function(e) {
|
|
17
|
-
return e.WithLogin = "with-login", e.WithoutLogin = "without-login", e.WithConfig = "with-config", e;
|
|
18
|
-
}({}), d = /* @__PURE__ */ function(e) {
|
|
19
|
-
return e.Toolset = "toolset", e.ExternalService = "external-service", e.OfflineCredentials = "offline-credentials", e;
|
|
20
|
-
}({}), f = /* @__PURE__ */ function(e) {
|
|
21
|
-
return e.Started = "started", e.Blocked = "blocked", e.InvalidConfig = "invalid-config", e;
|
|
22
|
-
}({}), p = /* @__PURE__ */ function(e) {
|
|
23
|
-
return e.Success = "success", e.Failure = "failure", e.Cancelled = "cancelled", e;
|
|
24
|
-
}({}), m = /* @__PURE__ */ function(e) {
|
|
25
|
-
return e.MissingCode = "missing-code", e.MissingRedirectState = "missing-redirect-state", e.StateMismatch = "state-mismatch", e.LoginRequestFailed = "login-request-failed", e;
|
|
26
|
-
}({}), h = /* @__PURE__ */ function(e) {
|
|
27
|
-
return e.ResultAcknowledged = "result-acknowledged", e;
|
|
28
|
-
}({}), g = /* @__PURE__ */ function(e) {
|
|
29
|
-
return e.Result = "toolsetOAuthResult", e.FailureReason = "toolsetOAuthFailureReason", e;
|
|
30
|
-
}({}), _ = "toolset-redirect-state", v = "toolset-login-success", y = new EventTarget(), b = (e) => {
|
|
31
|
-
y.dispatchEvent(new CustomEvent(v, { detail: e }));
|
|
32
|
-
}, x = (e) => {
|
|
33
|
-
let t = (t) => {
|
|
34
|
-
e(t.detail);
|
|
35
|
-
};
|
|
36
|
-
return y.addEventListener(v, t), () => {
|
|
37
|
-
y.removeEventListener(v, t);
|
|
38
|
-
};
|
|
39
|
-
}, S = "toolset-oauth-", C = (e) => `${S}${e}`, w = 300 * 1e3, T = 500, E = (e) => {
|
|
40
|
-
switch (e) {
|
|
41
|
-
case m.MissingCode:
|
|
42
|
-
case m.MissingRedirectState:
|
|
43
|
-
case m.StateMismatch:
|
|
44
|
-
case m.LoginRequestFailed: return e;
|
|
45
|
-
default: return m.LoginRequestFailed;
|
|
46
|
-
}
|
|
47
|
-
}, D = (e) => typeof e == "object" && !!e && "type" in e && (e.type === p.Success || e.type === p.Failure), O = (e, t, { toolsetId: n, credentialsLevel: r, callbackPath: i, timeoutMs: a = w, pollIntervalMs: o = T }) => new Promise((s) => {
|
|
48
|
-
let c, l = !1, u = () => {
|
|
49
|
-
let e = c;
|
|
50
|
-
c = void 0, e != null && setTimeout(() => e.close(), 0);
|
|
51
|
-
}, d = (e) => {
|
|
52
|
-
l || (l = !0, clearInterval(v), clearTimeout(y), window.removeEventListener("focus", _), u(), s(e));
|
|
53
|
-
}, f = (t) => {
|
|
54
|
-
c?.postMessage({ type: h.ResultAcknowledged });
|
|
55
|
-
try {
|
|
56
|
-
e.close();
|
|
57
|
-
} catch {}
|
|
58
|
-
d(t);
|
|
59
|
-
}, m = () => {
|
|
60
|
-
try {
|
|
61
|
-
let t = new URL(e.location.href);
|
|
62
|
-
if (t.origin !== window.location.origin || t.pathname !== i) return null;
|
|
63
|
-
let a = t.searchParams.get(g.Result);
|
|
64
|
-
if (a === p.Success) return {
|
|
65
|
-
type: p.Success,
|
|
66
|
-
toolsetId: n,
|
|
67
|
-
credentialsLevel: r
|
|
68
|
-
};
|
|
69
|
-
if (a === p.Failure) return {
|
|
70
|
-
type: p.Failure,
|
|
71
|
-
reason: E(t.searchParams.get(g.FailureReason))
|
|
72
|
-
};
|
|
73
|
-
} catch {}
|
|
74
|
-
return null;
|
|
75
|
-
}, _ = () => {
|
|
76
|
-
let t = m();
|
|
77
|
-
if (t != null) {
|
|
78
|
-
f(t);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
e.closed && d({ type: p.Cancelled });
|
|
82
|
-
};
|
|
83
|
-
try {
|
|
84
|
-
c = new BroadcastChannel(C(t)), c.onmessage = (e) => {
|
|
85
|
-
D(e.data) && f(e.data);
|
|
86
|
-
};
|
|
87
|
-
} catch {}
|
|
88
|
-
window.addEventListener("focus", _);
|
|
89
|
-
let v = setInterval(() => {
|
|
90
|
-
let e = m();
|
|
91
|
-
if (e != null) {
|
|
92
|
-
f(e);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
}, o), y = setTimeout(() => {
|
|
96
|
-
e.close(), d({ type: p.Cancelled });
|
|
97
|
-
}, a), b = m();
|
|
98
|
-
b != null && f(b);
|
|
99
|
-
}), k = (e) => `${window.location.origin}${e}`, A = (e) => e === "localhost" || e === "[::1]" || /^127(?:\.\d{1,3}){3}$/.test(e), j = (e) => e.protocol === "https:" ? !0 : e.protocol === "http:" && A(e.hostname), M = (e, t, n) => {
|
|
100
|
-
if (!e.authorizationEndpoint?.trim() || !e.clientId?.trim()) return null;
|
|
101
|
-
try {
|
|
102
|
-
let r = new URL(e.authorizationEndpoint.trim());
|
|
103
|
-
return j(r) ? (r.searchParams.set("response_type", "code"), r.searchParams.set("client_id", e.clientId.trim()), r.searchParams.set("redirect_uri", t), e.codeChallenge && r.searchParams.set("code_challenge", e.codeChallenge), e.codeChallengeMethod && r.searchParams.set("code_challenge_method", e.codeChallengeMethod), r.searchParams.set("state", n), e.scopes && e.scopes.length > 0 && r.searchParams.set("scope", e.scopes.join(" ")), r.toString()) : null;
|
|
104
|
-
} catch {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
}, N = (e, t, n, r, i, a, o = d.Toolset, s) => {
|
|
108
|
-
let c = {
|
|
109
|
-
toolsetId: r,
|
|
110
|
-
credentialsLevel: i,
|
|
111
|
-
redirectUri: a,
|
|
112
|
-
state: n,
|
|
113
|
-
resourceKind: o,
|
|
114
|
-
offlineUsageConsent: s
|
|
115
|
-
};
|
|
116
|
-
return e.sessionStorage.setItem(_, JSON.stringify(c)), e.opener = null, e.location.href = t, {
|
|
117
|
-
type: f.Started,
|
|
118
|
-
popup: e,
|
|
119
|
-
flowId: n
|
|
120
|
-
};
|
|
121
|
-
}, P = () => window.open("", "_blank"), F = (t, n, r, i, a = l.User, o = d.Toolset, s) => {
|
|
122
|
-
let c = k(i), u = e(), p = M(n, c, u);
|
|
123
|
-
return p ? N(t, p, u, r, a, c, o, s) : (t.close(), { type: f.InvalidConfig });
|
|
124
|
-
}, I = (t, n, r, i = l.User, a) => {
|
|
125
|
-
let o = k(r), s = e(), c = M(t, o, s);
|
|
126
|
-
if (!c) return { type: f.InvalidConfig };
|
|
127
|
-
let u = P();
|
|
128
|
-
return u ? N(u, c, s, n, i, o, d.Toolset, a) : { type: f.Blocked };
|
|
129
|
-
}, L = /* @__PURE__ */ function(e) {
|
|
130
|
-
return e.Success = "success", e.Failure = "failure", e.PopupBlocked = "popup-blocked", e.Cancelled = "cancelled", e;
|
|
131
|
-
}({}), R = ({ callbackPath: e, loginToolset: n, logoutToolset: r, getToolset: i }) => {
|
|
132
|
-
let a = t(async (e, t, n) => {
|
|
133
|
-
try {
|
|
134
|
-
await r(e, {
|
|
135
|
-
url: e,
|
|
136
|
-
credentialsLevel: t,
|
|
137
|
-
authenticationType: n
|
|
138
|
-
});
|
|
139
|
-
} catch {}
|
|
140
|
-
}, [r]), o = t(async (t) => {
|
|
141
|
-
let { toolsetId: n, credentialsLevel: r, oauthSettings: o, forceStale: u, offlineUsageConsent: m } = t, h = {
|
|
142
|
-
clientId: o?.clientId,
|
|
143
|
-
authorizationEndpoint: o?.authorizationEndpoint,
|
|
144
|
-
scopes: o?.scopes,
|
|
145
|
-
codeChallenge: o?.codeChallenge,
|
|
146
|
-
codeChallengeMethod: o?.codeChallengeMethod
|
|
147
|
-
}, g = u ? await (async () => {
|
|
148
|
-
let t = P();
|
|
149
|
-
return t ? (await a(n, r, s.OAuth), F(t, h, n, e, r, d.Toolset, m)) : { type: f.Blocked };
|
|
150
|
-
})() : I(h, n, e, r, m);
|
|
151
|
-
if (g.type === f.Blocked) return { type: "popup-blocked" };
|
|
152
|
-
if (g.type !== f.Started) return { type: "failure" };
|
|
153
|
-
let _ = await O(g.popup, g.flowId, {
|
|
154
|
-
toolsetId: n,
|
|
155
|
-
credentialsLevel: r,
|
|
156
|
-
callbackPath: e
|
|
157
|
-
});
|
|
158
|
-
if (_.type === p.Success) return b({
|
|
159
|
-
toolsetId: n,
|
|
160
|
-
credentialsLevel: r
|
|
161
|
-
}), { type: "success" };
|
|
162
|
-
if (_.type === p.Failure) return { type: "failure" };
|
|
163
|
-
try {
|
|
164
|
-
let e = await i(n);
|
|
165
|
-
if ((r === l.User ? e.authSettings?.userLevelAuthStatus : e.authSettings?.globalAuthStatus) === c.SignedIn) return b({
|
|
166
|
-
toolsetId: n,
|
|
167
|
-
credentialsLevel: r
|
|
168
|
-
}), { type: "success" };
|
|
169
|
-
} catch {}
|
|
170
|
-
return { type: "cancelled" };
|
|
171
|
-
}, [
|
|
172
|
-
e,
|
|
173
|
-
i,
|
|
174
|
-
a
|
|
175
|
-
]), u = t(async (e) => {
|
|
176
|
-
let { toolsetId: t, credentialsLevel: r, authenticationType: i, apiKey: o, isCurrentlyFailed: s, forceStale: c, offlineUsageConsent: l } = e;
|
|
177
|
-
try {
|
|
178
|
-
return (c || s) && await a(t, r, i), await n(t, {
|
|
179
|
-
url: t,
|
|
180
|
-
credentialsLevel: r,
|
|
181
|
-
authenticationType: i,
|
|
182
|
-
apiKey: o?.trim(),
|
|
183
|
-
offlineUsageConsent: l
|
|
184
|
-
}), b({
|
|
185
|
-
toolsetId: t,
|
|
186
|
-
credentialsLevel: r
|
|
187
|
-
}), { type: "success" };
|
|
188
|
-
} catch {
|
|
189
|
-
return { type: "failure" };
|
|
190
|
-
}
|
|
191
|
-
}, [n, a]);
|
|
192
|
-
return { login: t((e) => e.authenticationType === s.OAuth ? o(e) : u(e), [o, u]) };
|
|
193
|
-
};
|
|
194
|
-
//#endregion
|
|
195
|
-
export { a as C, u as S, o as T, g as _, P as a, f as b, C as c, x as d, d as f, l as g, s as h, F as i, O as l, c as m, R as n, M as o, _ as p, I as r, k as s, L as t, b as u, h as v, i as w, p as x, m as y };
|
package/useUsageData-D7BxloKZ.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { n as e } from "./date-BeuD8G79.js";
|
|
2
|
-
import { useCallback as t, useEffect as n, useMemo as r, useState as i } from "react";
|
|
3
|
-
//#region src/api-transport/create-csrf-middleware.ts
|
|
4
|
-
var a = (e) => ({
|
|
5
|
-
pre: async (t) => {
|
|
6
|
-
let n = e.getCsrfToken();
|
|
7
|
-
if (t.init.method === "GET" || n === null) return t;
|
|
8
|
-
let r = new Headers(t.init.headers);
|
|
9
|
-
return r.set("X-CSRF-Token", n), {
|
|
10
|
-
...t,
|
|
11
|
-
init: {
|
|
12
|
-
...t.init,
|
|
13
|
-
headers: r
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
},
|
|
17
|
-
post: async (t) => {
|
|
18
|
-
let n = t.response.headers.get("x-csrf-token");
|
|
19
|
-
return n && e.setCsrfToken(n), t.response;
|
|
20
|
-
}
|
|
21
|
-
}), o = async (e) => {
|
|
22
|
-
try {
|
|
23
|
-
return await e.clone().text();
|
|
24
|
-
} catch {
|
|
25
|
-
return "";
|
|
26
|
-
}
|
|
27
|
-
}, s = (e) => new Headers(e.headers).get("X-CSRF-Token"), c = (e, t) => {
|
|
28
|
-
let n = new Headers(e.init.headers);
|
|
29
|
-
return e.init.method !== "GET" && n.set("X-CSRF-Token", t), fetch(e.url, {
|
|
30
|
-
...e.init,
|
|
31
|
-
headers: n
|
|
32
|
-
});
|
|
33
|
-
}, l = (e) => {
|
|
34
|
-
let t = async (t) => {
|
|
35
|
-
let n = s(t.init), r = e.getCsrfToken();
|
|
36
|
-
if (r !== null && r !== n) return c(t, r);
|
|
37
|
-
let i = await e.refreshCsrfToken();
|
|
38
|
-
if (i.status === "unauthorized") throw e.notifyUnauthorized(t.url), e.createUnauthorizedError(t.url);
|
|
39
|
-
if (i.status !== "ok") throw Error(`CSRF refresh failed for ${t.url}`);
|
|
40
|
-
return c(t, i.token);
|
|
41
|
-
}, n = async (t, n) => {
|
|
42
|
-
let r = n.headers.get("x-csrf-token");
|
|
43
|
-
if (r && e.setCsrfToken(r), n.status === 401) throw e.notifyUnauthorized(t.url), e.createUnauthorizedError(t.url);
|
|
44
|
-
if (!n.ok) {
|
|
45
|
-
let r = await o(n);
|
|
46
|
-
throw n.status === 403 && e.isInvalidCsrfErrorBody(r) ? (e.notifyUnauthorized(t.url), e.createUnauthorizedError(t.url)) : Error(`Request failed with status ${n.status} for ${t.init.method ?? "GET"} ${t.url}: ${r}`);
|
|
47
|
-
}
|
|
48
|
-
return n;
|
|
49
|
-
};
|
|
50
|
-
return { post: async (r) => {
|
|
51
|
-
if (r.response.status === 401) throw e.notifyUnauthorized(r.url), e.createUnauthorizedError(r.url);
|
|
52
|
-
if (r.response.status === 403) {
|
|
53
|
-
let i = await o(r.response);
|
|
54
|
-
if (e.isInvalidCsrfErrorBody(i)) return n(r, await t(r));
|
|
55
|
-
}
|
|
56
|
-
return r.response;
|
|
57
|
-
} };
|
|
58
|
-
}, u = (e) => {
|
|
59
|
-
let t = e.split("/").filter(Boolean);
|
|
60
|
-
return t.map((e, n) => {
|
|
61
|
-
let r = t.slice(0, n).join("/");
|
|
62
|
-
return {
|
|
63
|
-
id: t.slice(0, n + 1).join("/"),
|
|
64
|
-
name: e,
|
|
65
|
-
...r ? { folderId: r } : void 0
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
}, d = (e) => ({
|
|
69
|
-
version: 5,
|
|
70
|
-
prompts: [{
|
|
71
|
-
id: e.id,
|
|
72
|
-
name: e.name,
|
|
73
|
-
description: e.description ?? "",
|
|
74
|
-
content: e.content,
|
|
75
|
-
...e.folderId ? { folderId: e.folderId } : void 0
|
|
76
|
-
}],
|
|
77
|
-
folders: u(e.folderId)
|
|
78
|
-
}), f = (e) => new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), p = /[^a-zA-Z0-9._-]+/g, m = (t, n, r = /* @__PURE__ */ new Date()) => {
|
|
79
|
-
let i = t.replace(p, "_");
|
|
80
|
-
return `${e(r)}_${n}_prompt_${i}.json`;
|
|
81
|
-
}, h = /* @__PURE__ */ function(e) {
|
|
82
|
-
return e.Required = "required", e.TooLong = "tooLong", e.InvalidName = "invalidName", e.Conflict = "conflict", e;
|
|
83
|
-
}({}), g = /^(?!\.{1,2}$)[a-zA-Z0-9 _.-]+$/, _ = 256, v = 2e3, y = 5e4, b = 10, x = (e) => {
|
|
84
|
-
let t = e.trim();
|
|
85
|
-
return t.length === 0 ? "required" : t.length > 256 ? "tooLong" : g.test(t) ? null : "invalidName";
|
|
86
|
-
}, S = (e) => e.length > 2e3 ? "tooLong" : null, C = (e) => e.trim().length === 0 ? "required" : e.length > 5e4 ? "tooLong" : null, w = (e, t) => {
|
|
87
|
-
let n = t - e.length;
|
|
88
|
-
return n <= 10 ? n : null;
|
|
89
|
-
}, T = (e, t) => e ? `${e}/${t}` : t, E = ({ listPrompts: e }) => {
|
|
90
|
-
let [a, o] = i([]), [s, c] = i([]), [l, u] = i([]), [d, f] = i([]), [p, m] = i([]), [h, g] = i(!0), [_, v] = i(null), y = t(async () => {
|
|
91
|
-
try {
|
|
92
|
-
let t = await e();
|
|
93
|
-
o(t.prompts), c(t.folders), u(t.sharedWithMe), f(t.publicPrompts ?? []), m(t.publicFolders ?? []), v(null);
|
|
94
|
-
} catch (e) {
|
|
95
|
-
v(e);
|
|
96
|
-
}
|
|
97
|
-
}, [e]);
|
|
98
|
-
return n(() => {
|
|
99
|
-
let t = { value: !1 };
|
|
100
|
-
return (async () => {
|
|
101
|
-
let n = await e().catch((e) => (t.value || v(e), null));
|
|
102
|
-
t.value || (n != null && (o(n.prompts), c(n.folders), u(n.sharedWithMe), f(n.publicPrompts ?? []), m(n.publicFolders ?? []), v(null)), g(!1));
|
|
103
|
-
})(), () => {
|
|
104
|
-
t.value = !0;
|
|
105
|
-
};
|
|
106
|
-
}, [e]), r(() => ({
|
|
107
|
-
prompts: a,
|
|
108
|
-
folders: s,
|
|
109
|
-
sharedWithMe: l,
|
|
110
|
-
publicPrompts: d,
|
|
111
|
-
publicFolders: p,
|
|
112
|
-
isLoading: h,
|
|
113
|
-
error: _,
|
|
114
|
-
refetch: y,
|
|
115
|
-
refetchPublicPrompts: y
|
|
116
|
-
}), [
|
|
117
|
-
a,
|
|
118
|
-
s,
|
|
119
|
-
l,
|
|
120
|
-
d,
|
|
121
|
-
p,
|
|
122
|
-
h,
|
|
123
|
-
_,
|
|
124
|
-
y
|
|
125
|
-
]);
|
|
126
|
-
}, D = "custom_app", O = (e) => !!e && e.id === D, k = (e) => !!e && (!!e.id?.endsWith("quickapps2") || e.displayName === "Quick app 2.0"), A = () => {
|
|
127
|
-
try {
|
|
128
|
-
return Intl.DateTimeFormat().resolvedOptions().timeZone || void 0;
|
|
129
|
-
} catch {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
}, j = (e) => {
|
|
133
|
-
let t = e.trim();
|
|
134
|
-
if (!t || !/^https?:\/\//.test(t)) return !1;
|
|
135
|
-
try {
|
|
136
|
-
return !!new URL(t);
|
|
137
|
-
} catch {
|
|
138
|
-
return !1;
|
|
139
|
-
}
|
|
140
|
-
}, M = (e) => {
|
|
141
|
-
let t = e.trim();
|
|
142
|
-
if (t) try {
|
|
143
|
-
return JSON.parse(t);
|
|
144
|
-
} catch {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
}, N = ["rate_endpoint", "configuration_endpoint"], P = (e) => {
|
|
148
|
-
let t = e.trim();
|
|
149
|
-
if (!t) return !0;
|
|
150
|
-
try {
|
|
151
|
-
let e = JSON.parse(t);
|
|
152
|
-
if (typeof e != "object" || !e || Array.isArray(e)) return !1;
|
|
153
|
-
let n = Object.keys(e);
|
|
154
|
-
return n.length > 0 && n.every((e) => N.includes(e));
|
|
155
|
-
} catch {
|
|
156
|
-
return !1;
|
|
157
|
-
}
|
|
158
|
-
}, F = "/external_services/", I = (e) => {
|
|
159
|
-
let t = e.indexOf(F);
|
|
160
|
-
if (t === -1) return null;
|
|
161
|
-
let n = e.slice(0, t), r = e.slice(t + 19);
|
|
162
|
-
return !n || !r ? null : {
|
|
163
|
-
appId: n,
|
|
164
|
-
serviceName: r
|
|
165
|
-
};
|
|
166
|
-
}, L = (e, t) => `${e}${F}${t}`, R = (e) => {
|
|
167
|
-
try {
|
|
168
|
-
return decodeURIComponent(e);
|
|
169
|
-
} catch {
|
|
170
|
-
return e;
|
|
171
|
-
}
|
|
172
|
-
}, z = (e) => e instanceof Error ? e : Error(String(e)), B = (e, t = !0) => {
|
|
173
|
-
let [r, a] = i(), [o, s] = i(t), [c, l] = i();
|
|
174
|
-
return n(() => {
|
|
175
|
-
if (!t) {
|
|
176
|
-
s(!1);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
let n = !1;
|
|
180
|
-
return s(!0), (async () => {
|
|
181
|
-
try {
|
|
182
|
-
let t = await e();
|
|
183
|
-
if (n) return;
|
|
184
|
-
a(t);
|
|
185
|
-
} catch (e) {
|
|
186
|
-
if (n) return;
|
|
187
|
-
l(z(e));
|
|
188
|
-
} finally {
|
|
189
|
-
n || s(!1);
|
|
190
|
-
}
|
|
191
|
-
})(), () => {
|
|
192
|
-
n = !0;
|
|
193
|
-
};
|
|
194
|
-
}, [t, e]), {
|
|
195
|
-
usage: r,
|
|
196
|
-
isLoading: o,
|
|
197
|
-
usageError: c
|
|
198
|
-
};
|
|
199
|
-
};
|
|
200
|
-
//#endregion
|
|
201
|
-
export { m as C, a as E, d as S, l as T, T as _, j as a, S as b, A as c, E as d, y as f, h as g, _ as h, I as i, O as l, v as m, L as n, P as o, b as p, R as r, M as s, B as t, k as u, w as v, f as w, x, C as y };
|