@scalar/agent-chat 0.2.1 → 0.2.3
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/dist/App.vue.d.ts +6 -1
- package/dist/App.vue.d.ts.map +1 -1
- package/dist/Chat.vue.d.ts.map +1 -1
- package/dist/Tooltip-Cm82QgNj.js +575 -0
- package/dist/__vite-optional-peer-dep_stream-markdown_markstream-vue_false-sdjmOmXd.js +5 -0
- package/dist/__vite-optional-peer-dep_stream-monaco_markstream-vue_false-HdL4xm5U.js +5 -0
- package/dist/__vite-optional-peer-dep_vue-i18n_markstream-vue_false-B9Pwe5kz.js +5 -0
- package/dist/_basePickBy-hHD8tMGb.js +151 -0
- package/dist/_baseUniq-DTF1wuF6.js +614 -0
- package/dist/arc-Dw2RQerU.js +83 -0
- package/dist/architecture-U656AL7Q-B00Z9eXr.js +36 -0
- package/dist/architectureDiagram-VXUJARFQ-BtOffFaM.js +4662 -0
- package/dist/blockDiagram-VD42YOAC-BUqFMMQe.js +2261 -0
- package/dist/c4Diagram-YG6GDRKO-NrM1YcpG.js +1579 -0
- package/dist/channel-105myCGU.js +5 -0
- package/dist/chunk-4BX2VUAB-TAxJli7C.js +8 -0
- package/dist/chunk-55IACEB6-VXFJ4bz5.js +8 -0
- package/dist/chunk-B4BG7PRW-CZDQpfj5.js +1375 -0
- package/dist/chunk-DI55MBZ5-D3l7TA-E.js +1370 -0
- package/dist/chunk-FMBD7UC4-BMXFm8I3.js +19 -0
- package/dist/chunk-QN33PNHL-BOUpbpWp.js +19 -0
- package/dist/chunk-QZHKN3VN-C-TEEx05.js +15 -0
- package/dist/chunk-TZMSLE5B-BUiROKNR.js +64 -0
- package/dist/classDiagram-2ON5EDUG-HQET4ybK.js +16 -0
- package/dist/classDiagram-v2-WZHVMYZB-HQET4ybK.js +16 -0
- package/dist/clone-CIIO71O9.js +8 -0
- package/dist/components/ApprovalSection.vue.d.ts.map +1 -1
- package/dist/components/PaymentSection.vue.d.ts +9 -0
- package/dist/components/PaymentSection.vue.d.ts.map +1 -0
- package/dist/components/RequestPreview.vue.d.ts.map +1 -1
- package/dist/components/ResponseBody/ResponseBody.vue.d.ts +1 -1
- package/dist/components/ResponseBody/ResponseBodyPreview.vue.d.ts +1 -1
- package/dist/cose-bilkent-S5V4N54A-CMsF4n-5.js +2609 -0
- package/dist/cytoscape.esm-DfdJODL8.js +18735 -0
- package/dist/dagre-6UL2VRFP-DqzdQ6Qg.js +444 -0
- package/dist/defaultLocale-BEa-49Qz.js +171 -0
- package/dist/diagram-PSM6KHXK-1xyGntw2.js +531 -0
- package/dist/diagram-QEK2KX5R-DdZdlAm1.js +217 -0
- package/dist/diagram-S2PKOQOG-C80Eo2jp.js +142 -0
- package/dist/erDiagram-Q2GNP2WA-DFVRrMXT.js +841 -0
- package/dist/flowDiagram-NV44I4VS-D9QK_qqB.js +1620 -0
- package/dist/ganttDiagram-LVOFAZNH-Bo1NTkeQ.js +2506 -0
- package/dist/gitGraph-F6HP7TQM-C5hdgcgO.js +27 -0
- package/dist/gitGraphDiagram-NY62KEGX-BZqnqZh6.js +699 -0
- package/dist/graph-Dth4IhEK.js +247 -0
- package/dist/helpers.d.ts +1 -1
- package/dist/hooks/useSearch.d.ts.map +1 -1
- package/dist/index-BOvT43H8.js +111780 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -3
- package/dist/index2-B36B-gt0.js +69 -0
- package/dist/index3-CtIyYUnG.js +70 -0
- package/dist/index4-Dzz91Ao2.js +537 -0
- package/dist/index5-Bmz0gMSP.js +590 -0
- package/dist/index6-DMB3qTSV.js +196 -0
- package/dist/info-NVLQJR56-azt5obk5.js +27 -0
- package/dist/infoDiagram-ER5ION4S-DD4Jtctm.js +24 -0
- package/dist/infographic_markstream-vue_false-BfsmcXxk.js +5 -0
- package/dist/init-DjUOC4st.js +16 -0
- package/dist/journeyDiagram-XKPGCS4Q-CXL6UO0r.js +834 -0
- package/dist/kanban-definition-3W4ZIXB7-B57do5Wg.js +719 -0
- package/dist/katex-SsTUIUTC.js +11688 -0
- package/dist/layout-7TCY8eA2.js +1332 -0
- package/dist/linear-DSm5i91N.js +625 -0
- package/dist/mermaid-parser.core-CUQWpAMM.js +12746 -0
- package/dist/mermaid.core-QjuzH7xx.js +14164 -0
- package/dist/mhchem-XHl7cef5.js +2306 -0
- package/dist/mindmap-definition-VGOIOE7T-DAQyGNAM.js +784 -0
- package/dist/ordinal-DfAQgscy.js +61 -0
- package/dist/package.json +2 -2
- package/dist/packet-BFZMPI3H-CixuxAEA.js +27 -0
- package/dist/pie-7BOR55EZ-D3cgnzR1.js +32 -0
- package/dist/pieDiagram-ADFJNKIX-BqxgYwrL.js +161 -0
- package/dist/quadrantDiagram-AYHSOK5B-CQ4v-9Hh.js +1022 -0
- package/dist/radar-NHE76QYJ-DhV0Od_M.js +27 -0
- package/dist/registry/add-documents-to-store.d.ts +3 -2
- package/dist/registry/add-documents-to-store.d.ts.map +1 -1
- package/dist/requirementDiagram-UZGBJVZJ-ncWNAgFi.js +850 -0
- package/dist/safeRaf-I3a3-dyJ.js +10 -0
- package/dist/sankeyDiagram-TZEHDZUN-yCR2_cH5.js +810 -0
- package/dist/sequenceDiagram-WL72ISMW-DZ7wqFyd.js +2511 -0
- package/dist/state/state.d.ts +7 -3
- package/dist/state/state.d.ts.map +1 -1
- package/dist/stateDiagram-FKZM4ZOC-Dra68Tzi.js +263 -0
- package/dist/stateDiagram-v2-4FDKWEC3-CARbPECD.js +16 -0
- package/dist/style.css +1 -12713
- package/dist/timeline-definition-IT6M3QCI-DEbG9QIM.js +795 -0
- package/dist/treemap-KMMF4GRG-CQbPsyWe.js +81 -0
- package/dist/views/Chat/Chat.vue.d.ts.map +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.d.ts +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.d.ts.map +1 -1
- package/dist/views/Chat/Messages/GetMiniOpenAPIDocTool.vue.d.ts +1 -1
- package/dist/views/Chat/Messages/GetOpenAPISpecsSummary.vue.d.ts +1 -1
- package/dist/views/PromptForm.vue.d.ts.map +1 -1
- package/dist/views/Start.vue.d.ts.map +1 -1
- package/dist/xychartDiagram-PRI3JC2R-C94Pu8hL.js +1340 -0
- package/package.json +1 -1
- package/dist/App.vue.js +0 -29
- package/dist/App.vue.js.map +0 -1
- package/dist/App.vue2.js +0 -5
- package/dist/App.vue2.js.map +0 -1
- package/dist/Chat.vue.js +0 -55
- package/dist/Chat.vue.js.map +0 -1
- package/dist/Chat.vue2.js +0 -5
- package/dist/Chat.vue2.js.map +0 -1
- package/dist/_virtual/_plugin-vue_export-helper.js +0 -11
- package/dist/_virtual/_plugin-vue_export-helper.js.map +0 -1
- package/dist/components/ApprovalSection.vue.js +0 -8
- package/dist/components/ApprovalSection.vue.js.map +0 -1
- package/dist/components/ApprovalSection.vue2.js +0 -47
- package/dist/components/ApprovalSection.vue2.js.map +0 -1
- package/dist/components/AutosendPaused.vue.js +0 -15
- package/dist/components/AutosendPaused.vue.js.map +0 -1
- package/dist/components/ContextItem.vue.js +0 -8
- package/dist/components/ContextItem.vue.js.map +0 -1
- package/dist/components/ContextItem.vue2.js +0 -22
- package/dist/components/ContextItem.vue2.js.map +0 -1
- package/dist/components/Endpoint.vue.js +0 -8
- package/dist/components/Endpoint.vue.js.map +0 -1
- package/dist/components/Endpoint.vue2.js +0 -98
- package/dist/components/Endpoint.vue2.js.map +0 -1
- package/dist/components/ErrorMessage.vue.js +0 -8
- package/dist/components/ErrorMessage.vue.js.map +0 -1
- package/dist/components/ErrorMessage.vue2.js +0 -28
- package/dist/components/ErrorMessage.vue2.js.map +0 -1
- package/dist/components/LoadingMiniOpenAPIDoc.vue.js +0 -16
- package/dist/components/LoadingMiniOpenAPIDoc.vue.js.map +0 -1
- package/dist/components/LoadingOpenAPISpecsSummary.vue.js +0 -16
- package/dist/components/LoadingOpenAPISpecsSummary.vue.js.map +0 -1
- package/dist/components/Logo.vue.js +0 -25
- package/dist/components/Logo.vue.js.map +0 -1
- package/dist/components/RequestApproved.vue.js +0 -15
- package/dist/components/RequestApproved.vue.js.map +0 -1
- package/dist/components/RequestFailed.vue.js +0 -26
- package/dist/components/RequestFailed.vue.js.map +0 -1
- package/dist/components/RequestPreview.vue.js +0 -9
- package/dist/components/RequestPreview.vue.js.map +0 -1
- package/dist/components/RequestPreview.vue2.js +0 -150
- package/dist/components/RequestPreview.vue2.js.map +0 -1
- package/dist/components/RequestRejected.vue.js +0 -24
- package/dist/components/RequestRejected.vue.js.map +0 -1
- package/dist/components/RequestSuccess.vue.js +0 -15
- package/dist/components/RequestSuccess.vue.js.map +0 -1
- package/dist/components/ResponseBody/ResponseBody.vue.js +0 -45
- package/dist/components/ResponseBody/ResponseBody.vue.js.map +0 -1
- package/dist/components/ResponseBody/ResponseBody.vue2.js +0 -5
- package/dist/components/ResponseBody/ResponseBody.vue2.js.map +0 -1
- package/dist/components/ResponseBody/ResponseBodyInfo.vue.js +0 -17
- package/dist/components/ResponseBody/ResponseBodyInfo.vue.js.map +0 -1
- package/dist/components/ResponseBody/ResponseBodyPreview.vue.js +0 -8
- package/dist/components/ResponseBody/ResponseBodyPreview.vue.js.map +0 -1
- package/dist/components/ResponseBody/ResponseBodyPreview.vue2.js +0 -73
- package/dist/components/ResponseBody/ResponseBodyPreview.vue2.js.map +0 -1
- package/dist/components/ResponseBody/ResponseBodyRaw.vue.js +0 -23
- package/dist/components/ResponseBody/ResponseBodyRaw.vue.js.map +0 -1
- package/dist/components/ResponseBody/ResponseBodyRaw.vue2.js +0 -5
- package/dist/components/ResponseBody/ResponseBodyRaw.vue2.js.map +0 -1
- package/dist/components/ResponseBody/ResponseBodyToggle.vue.js +0 -30
- package/dist/components/ResponseBody/ResponseBodyToggle.vue.js.map +0 -1
- package/dist/components/ResponseBody/ResponseBodyToggle.vue2.js +0 -5
- package/dist/components/ResponseBody/ResponseBodyToggle.vue2.js.map +0 -1
- package/dist/components/ResponseBody/helpers/media-types.js +0 -134
- package/dist/components/ResponseBody/helpers/media-types.js.map +0 -1
- package/dist/components/ResponseBody/helpers/process-response-body.js +0 -63
- package/dist/components/ResponseBody/helpers/process-response-body.js.map +0 -1
- package/dist/components/SearchPopover.vue.js +0 -8
- package/dist/components/SearchPopover.vue.js.map +0 -1
- package/dist/components/SearchPopover.vue2.js +0 -78
- package/dist/components/SearchPopover.vue2.js.map +0 -1
- package/dist/components/SendingRequest.vue.js +0 -26
- package/dist/components/SendingRequest.vue.js.map +0 -1
- package/dist/components/Suggestion.vue.js +0 -8
- package/dist/components/Suggestion.vue.js.map +0 -1
- package/dist/components/Suggestion.vue2.js +0 -28
- package/dist/components/Suggestion.vue2.js.map +0 -1
- package/dist/components/TestRequestButton.vue.js +0 -8
- package/dist/components/TestRequestButton.vue.js.map +0 -1
- package/dist/components/TestRequestButton.vue2.js +0 -37
- package/dist/components/TestRequestButton.vue2.js.map +0 -1
- package/dist/helpers.js +0 -201
- package/dist/helpers.js.map +0 -1
- package/dist/hooks/useChatApprovals.js +0 -25
- package/dist/hooks/useChatApprovals.js.map +0 -1
- package/dist/hooks/useChatOperationBlocks.js +0 -29
- package/dist/hooks/useChatOperationBlocks.js.map +0 -1
- package/dist/hooks/useChatScroll.js +0 -22
- package/dist/hooks/useChatScroll.js.map +0 -1
- package/dist/hooks/useSearch.js +0 -36
- package/dist/hooks/useSearch.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/api.js +0 -12
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/api.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/core.js +0 -67
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/core.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/errors.js +0 -25
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/errors.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/parse.js +0 -64
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/parse.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/regexes.js +0 -8
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/regexes.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.js +0 -181
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/util.js +0 -85
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/util.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/versions.js +0 -9
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/versions.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/mini/schemas.js +0 -61
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/mini/schemas.js.map +0 -1
- package/dist/registry/add-documents-to-store.js +0 -42
- package/dist/registry/add-documents-to-store.js.map +0 -1
- package/dist/state/state.js +0 -112
- package/dist/state/state.js.map +0 -1
- package/dist/views/Chat/Chat.vue.js +0 -8
- package/dist/views/Chat/Chat.vue.js.map +0 -1
- package/dist/views/Chat/Chat.vue2.js +0 -84
- package/dist/views/Chat/Chat.vue2.js.map +0 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.js +0 -8
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.js.map +0 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue2.js +0 -39
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue2.js.map +0 -1
- package/dist/views/Chat/Messages/GetMiniOpenAPIDocTool.vue.js +0 -8
- package/dist/views/Chat/Messages/GetMiniOpenAPIDocTool.vue.js.map +0 -1
- package/dist/views/Chat/Messages/GetMiniOpenAPIDocTool.vue2.js +0 -65
- package/dist/views/Chat/Messages/GetMiniOpenAPIDocTool.vue2.js.map +0 -1
- package/dist/views/Chat/Messages/GetOpenAPISpecsSummary.vue.js +0 -32
- package/dist/views/Chat/Messages/GetOpenAPISpecsSummary.vue.js.map +0 -1
- package/dist/views/Chat/Messages/GetOpenAPISpecsSummary.vue2.js +0 -5
- package/dist/views/Chat/Messages/GetOpenAPISpecsSummary.vue2.js.map +0 -1
- package/dist/views/Chat/Messages/Text.vue.js +0 -21
- package/dist/views/Chat/Messages/Text.vue.js.map +0 -1
- package/dist/views/Chat/Messages/Text.vue2.js +0 -5
- package/dist/views/Chat/Messages/Text.vue2.js.map +0 -1
- package/dist/views/Layout.vue.js +0 -8
- package/dist/views/Layout.vue.js.map +0 -1
- package/dist/views/Layout.vue2.js +0 -28
- package/dist/views/Layout.vue2.js.map +0 -1
- package/dist/views/PromptForm.vue.js +0 -8
- package/dist/views/PromptForm.vue.js.map +0 -1
- package/dist/views/PromptForm.vue2.js +0 -182
- package/dist/views/PromptForm.vue2.js.map +0 -1
- package/dist/views/Settings/Auth.vue.js +0 -66
- package/dist/views/Settings/Auth.vue.js.map +0 -1
- package/dist/views/Settings/Auth.vue2.js +0 -5
- package/dist/views/Settings/Auth.vue2.js.map +0 -1
- package/dist/views/Settings/DocSettings.vue.js +0 -8
- package/dist/views/Settings/DocSettings.vue.js.map +0 -1
- package/dist/views/Settings/DocSettings.vue2.js +0 -50
- package/dist/views/Settings/DocSettings.vue2.js.map +0 -1
- package/dist/views/Settings/Settings.vue.js +0 -9
- package/dist/views/Settings/Settings.vue.js.map +0 -1
- package/dist/views/Settings/Settings.vue2.js +0 -78
- package/dist/views/Settings/Settings.vue2.js.map +0 -1
- package/dist/views/Start.vue.js +0 -8
- package/dist/views/Start.vue.js.map +0 -1
- package/dist/views/Start.vue2.js +0 -56
- package/dist/views/Start.vue2.js.map +0 -1
package/dist/helpers.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { getSecuritySchemes } from "@scalar/api-client/v2/blocks/operation-block";
|
|
2
|
-
import { getSelectedSecurity, getSelectedServer } from "@scalar/api-client/v2/features/operation";
|
|
3
|
-
import { isDefined } from "@scalar/helpers/array/is-defined";
|
|
4
|
-
import { isObject } from "@scalar/helpers/object/is-object";
|
|
5
|
-
import { REFERENCE_LS_KEYS, safeLocalStorage } from "@scalar/helpers/object/local-storage";
|
|
6
|
-
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
7
|
-
import { coerceValue } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
8
|
-
import { XScalarSelectedSecuritySchema, SecuritySchemesSchema } from "@scalar/workspace-store/schemas/v3.1/strict/openapi-document";
|
|
9
|
-
const combineParams = (pathParams = [], operationParams = []) => {
|
|
10
|
-
const allParams = [...pathParams, ...operationParams].map((param) => getResolvedRef(param)).filter((e) => isDefined(e) && e.name);
|
|
11
|
-
const uniqueParams = /* @__PURE__ */ new Map();
|
|
12
|
-
for (const param of allParams) {
|
|
13
|
-
const key = `${param.in}:${param.name}`;
|
|
14
|
-
uniqueParams.set(key, param);
|
|
15
|
-
}
|
|
16
|
-
return Array.from(uniqueParams.values());
|
|
17
|
-
};
|
|
18
|
-
function getFirstServer(...availableServers) {
|
|
19
|
-
for (const serverSource of availableServers) {
|
|
20
|
-
if (!serverSource) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (!Array.isArray(serverSource)) {
|
|
24
|
-
const resolvedServer = getResolvedRef(serverSource);
|
|
25
|
-
if (resolvedServer?.url) {
|
|
26
|
-
return resolvedServer;
|
|
27
|
-
}
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
for (const server of serverSource) {
|
|
31
|
-
const resolvedServer = getResolvedRef(server);
|
|
32
|
-
if (resolvedServer?.url) {
|
|
33
|
-
return resolvedServer;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return void 0;
|
|
38
|
-
}
|
|
39
|
-
const getKey = (requirement) => Object.keys(requirement).sort().join(",");
|
|
40
|
-
const filterSelectedSecurity = (document, operation, securitySchemes = {}) => {
|
|
41
|
-
const securityRequirements = operation?.security ?? document.security ?? [];
|
|
42
|
-
const selectedSecurity = getSelectedSecurity(
|
|
43
|
-
document?.["x-scalar-selected-security"],
|
|
44
|
-
operation?.["x-scalar-selected-security"]
|
|
45
|
-
);
|
|
46
|
-
const requirementSet = new Set(securityRequirements.map((r) => getKey(r)));
|
|
47
|
-
const selectedRequirement = selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex];
|
|
48
|
-
if (selectedRequirement && requirementSet.has(getKey(selectedRequirement))) {
|
|
49
|
-
return getSecuritySchemes(securitySchemes, [selectedRequirement]);
|
|
50
|
-
}
|
|
51
|
-
for (const selected of selectedSecurity.selectedSchemes) {
|
|
52
|
-
if (requirementSet.has(getKey(selected))) {
|
|
53
|
-
return getSecuritySchemes(securitySchemes, [selected]);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (operation?.security?.length && !document?.["x-scalar-set-operation-security"]) {
|
|
57
|
-
return getSecuritySchemes(securitySchemes, securityRequirements.slice(0, 1));
|
|
58
|
-
}
|
|
59
|
-
return [];
|
|
60
|
-
};
|
|
61
|
-
function getOperations(doc) {
|
|
62
|
-
return Object.values(doc.paths ?? {}).flatMap(
|
|
63
|
-
(path) => Object.values(path ?? {})
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
function getSecurityFromDocument(document) {
|
|
67
|
-
const selectedSchemes = document["x-scalar-selected-security"]?.selectedSchemes ?? [];
|
|
68
|
-
const schemeKeys = selectedSchemes.flatMap((scheme) => Object.keys(scheme));
|
|
69
|
-
const securitySchemes = document.components?.securitySchemes;
|
|
70
|
-
if (!securitySchemes) return [];
|
|
71
|
-
return schemeKeys.reduce((acc, cur) => {
|
|
72
|
-
const security = securitySchemes[cur];
|
|
73
|
-
if (security) acc.push(getResolvedRef(security));
|
|
74
|
-
return acc;
|
|
75
|
-
}, []);
|
|
76
|
-
}
|
|
77
|
-
function createDocumentSettings(workspaceStore) {
|
|
78
|
-
return Object.fromEntries(
|
|
79
|
-
Object.entries(workspaceStore.workspace.documents).map(
|
|
80
|
-
([key, document]) => [
|
|
81
|
-
key,
|
|
82
|
-
{
|
|
83
|
-
activeServer: getSelectedServer(document),
|
|
84
|
-
securitySchemes: getSecurityFromDocument(document)
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
)
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
const storage = safeLocalStorage();
|
|
91
|
-
const authStorage = () => {
|
|
92
|
-
const schemasKey = REFERENCE_LS_KEYS.AUTH_SCHEMES;
|
|
93
|
-
const selectedSchemesKey = REFERENCE_LS_KEYS.SELECTED_AUTH_SCHEMES;
|
|
94
|
-
const getAuthId = (type, prefix) => {
|
|
95
|
-
const getKey2 = (type2) => {
|
|
96
|
-
return type2 === "schemas" ? schemasKey : selectedSchemesKey;
|
|
97
|
-
};
|
|
98
|
-
return `${prefix}-${getKey2(type)}`;
|
|
99
|
-
};
|
|
100
|
-
return {
|
|
101
|
-
/**
|
|
102
|
-
* Retrieves and coerces the authentication schemes stored in local storage.
|
|
103
|
-
*/
|
|
104
|
-
getSchemas: (slug) => {
|
|
105
|
-
const parsed = JSON.parse(
|
|
106
|
-
storage.getItem(getAuthId("schemas", slug)) ?? "{}"
|
|
107
|
-
);
|
|
108
|
-
return coerceValue(SecuritySchemesSchema, parsed);
|
|
109
|
-
},
|
|
110
|
-
/**
|
|
111
|
-
* Stores the authentication schemes in local storage.
|
|
112
|
-
* @param value The SecuritySchemes object to stringify and store.
|
|
113
|
-
*/
|
|
114
|
-
setSchemas: (slug, value) => {
|
|
115
|
-
storage.setItem(getAuthId("schemas", slug), JSON.stringify(value));
|
|
116
|
-
},
|
|
117
|
-
/**
|
|
118
|
-
* Retrieves and coerces the selected authentication schemes stored in local storage.
|
|
119
|
-
*/
|
|
120
|
-
getSelectedSchemes: (slug) => {
|
|
121
|
-
const parsed = JSON.parse(
|
|
122
|
-
storage.getItem(getAuthId("selectedSchemes", slug)) ?? "{}"
|
|
123
|
-
);
|
|
124
|
-
return coerceValue(XScalarSelectedSecuritySchema, parsed);
|
|
125
|
-
},
|
|
126
|
-
/**
|
|
127
|
-
* Stores the user's selected authentication schemes in local storage.
|
|
128
|
-
* @param value The XScalarSelectedSecurity object to stringify and store.
|
|
129
|
-
*/
|
|
130
|
-
setSelectedSchemes: (slug, value) => {
|
|
131
|
-
storage.setItem(getAuthId("selectedSchemes", slug), JSON.stringify(value));
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
const mergeSecrets = (current, stored) => {
|
|
136
|
-
if (!isObject(current) || !isObject(stored)) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
for (const [key, storedValue] of Object.entries(stored)) {
|
|
140
|
-
if (typeof storedValue !== "object") {
|
|
141
|
-
current[key] = storedValue;
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
mergeSecrets(getResolvedRef(current[key]), storedValue);
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
const isSchemeValid = (scheme, availableSchemes) => Object.keys(scheme).every((key) => availableSchemes.has(key));
|
|
148
|
-
const clampSelectedIndex = (selectedIndex, schemesLength) => selectedIndex >= schemesLength ? schemesLength - 1 : selectedIndex;
|
|
149
|
-
const restoreAuthSecretsFromStorage = ({
|
|
150
|
-
documentName,
|
|
151
|
-
workspaceStore
|
|
152
|
-
}) => {
|
|
153
|
-
const storedAuthSchemes = authStorage().getSchemas(documentName);
|
|
154
|
-
const document = workspaceStore.workspace.documents[documentName];
|
|
155
|
-
if (!document) return;
|
|
156
|
-
const authPersistence = authStorage();
|
|
157
|
-
const storedSelectedAuthSchemes = authPersistence.getSelectedSchemes(documentName);
|
|
158
|
-
const availableSchemes = new Set(
|
|
159
|
-
Object.keys(document.components?.securitySchemes ?? {})
|
|
160
|
-
);
|
|
161
|
-
const selectedSchemes = storedSelectedAuthSchemes["x-scalar-selected-security"]?.selectedSchemes;
|
|
162
|
-
const validSchemes = selectedSchemes?.filter(
|
|
163
|
-
(scheme) => isSchemeValid(scheme, availableSchemes)
|
|
164
|
-
);
|
|
165
|
-
if (!document["x-scalar-selected-security"] && validSchemes && validSchemes.length > 0) {
|
|
166
|
-
const selectedIdx = storedSelectedAuthSchemes["x-scalar-selected-security"]?.selectedIndex;
|
|
167
|
-
const clampedIndex = clampSelectedIndex(
|
|
168
|
-
selectedIdx ?? 0,
|
|
169
|
-
validSchemes.length
|
|
170
|
-
);
|
|
171
|
-
document["x-scalar-selected-security"] = {
|
|
172
|
-
selectedIndex: clampedIndex,
|
|
173
|
-
selectedSchemes: validSchemes
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
const securitySchemes = document.components?.securitySchemes ?? {};
|
|
177
|
-
for (const [key, storedScheme] of Object.entries(storedAuthSchemes)) {
|
|
178
|
-
const currentScheme = getResolvedRef(securitySchemes[key]);
|
|
179
|
-
if (isObject(currentScheme)) mergeSecrets(currentScheme, storedScheme);
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
function safeParseJson(value) {
|
|
183
|
-
try {
|
|
184
|
-
return JSON.parse(value);
|
|
185
|
-
} catch {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
export {
|
|
190
|
-
authStorage,
|
|
191
|
-
combineParams,
|
|
192
|
-
createDocumentSettings,
|
|
193
|
-
filterSelectedSecurity,
|
|
194
|
-
getFirstServer,
|
|
195
|
-
getOperations,
|
|
196
|
-
getSecurityFromDocument,
|
|
197
|
-
mergeSecrets,
|
|
198
|
-
restoreAuthSecretsFromStorage,
|
|
199
|
-
safeParseJson
|
|
200
|
-
};
|
|
201
|
-
//# sourceMappingURL=helpers.js.map
|
package/dist/helpers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../src/helpers.ts"],"sourcesContent":["import type { ToolUIPart, UIDataTypes, UIMessagePart } from 'ai'\n\nimport { getSecuritySchemes } from '@scalar/api-client/v2/blocks/operation-block'\nimport type { MergedSecuritySchemes } from '@scalar/api-client/v2/blocks/scalar-auth-selector-block'\nimport {\n getSelectedSecurity,\n getSelectedServer,\n} from '@scalar/api-client/v2/features/operation'\nimport { isDefined } from '@scalar/helpers/array/is-defined'\nimport { isObject } from '@scalar/helpers/object/is-object'\nimport {\n REFERENCE_LS_KEYS,\n safeLocalStorage,\n} from '@scalar/helpers/object/local-storage'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { AuthenticationConfiguration } from '@scalar/types/api-reference'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport type { XScalarSelectedSecurity } from '@scalar/workspace-store/schemas/extensions/security/x-scalar-selected-security'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport type {\n OpenApiDocument,\n OperationObject,\n ParameterObject,\n PathItemObject,\n SecurityRequirementObject,\n SecuritySchemeObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport {\n type SecuritySchemes,\n SecuritySchemesSchema,\n XScalarSelectedSecuritySchema,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport type { Tools } from '@/state/state'\n\n/** Combine pathItem and operation parameters into a single, dereferenced parameter array */\nexport const combineParams = (\n pathParams: PathItemObject['parameters'] = [],\n operationParams: OperationObject['parameters'] = [],\n): ParameterObject[] => {\n const allParams = [...pathParams, ...operationParams]\n .map((param) => getResolvedRef(param))\n // For unresolved params, coercion is going to generate a template object with an empty name, we don't want to include those\n .filter((e) => isDefined(e) && e.name)\n\n // Use a Map to ensure unique in+name combinations\n // Operation parameters take precedence over path parameters\n const uniqueParams = new Map<string, ParameterObject>()\n\n for (const param of allParams) {\n const key = `${param.in}:${param.name}`\n uniqueParams.set(key, param)\n }\n\n return Array.from(uniqueParams.values())\n}\n\n/**\n * Iterate through all available servers and pick the first one\n *\n * @example\n * getFirstServer([operation.servers, pathItem.servers, server])\n */\nexport function getFirstServer(\n ...availableServers: (ServerObject[] | ServerObject | undefined | null)[]\n): ServerObject | undefined {\n for (const serverSource of availableServers) {\n if (!serverSource) {\n continue\n }\n\n // Handle single server object\n if (!Array.isArray(serverSource)) {\n const resolvedServer = getResolvedRef(serverSource) as ServerObject\n if (resolvedServer?.url) {\n return resolvedServer\n }\n continue\n }\n\n // Handle array of servers, pick the first one with a URL\n for (const server of serverSource) {\n const resolvedServer = getResolvedRef(server) as ServerObject\n if (resolvedServer?.url) {\n return resolvedServer\n }\n }\n }\n\n return undefined\n}\n\n/** Determine if a message part is a tool */\nexport function isToolPart(\n part: UIMessagePart<UIDataTypes, Tools>,\n): part is ToolUIPart<Tools> {\n return part.type.startsWith('tool-')\n}\n\n/**\n * Extracts the default scopes for a security scheme.\n * Only OAuth2 schemes can have default scopes via the x-default-scopes extension.\n */\nexport const getDefaultScopes = (\n scheme: SecuritySchemeObject | undefined,\n): string[] => {\n if (!scheme || scheme.type !== 'oauth2') {\n return []\n }\n\n return scheme['x-default-scopes'] ?? []\n}\n\n/**\n * Processes a single scheme name and adds it to the accumulator with its default scopes.\n */\nconst addSchemeToRequirement = (\n acc: SecurityRequirementObject,\n schemeName: string,\n securitySchemes: MergedSecuritySchemes,\n): void => {\n const scheme = getResolvedRef(securitySchemes[schemeName])\n acc[schemeName] = getDefaultScopes(scheme)\n}\n\n/**\n * Converts the preferred security scheme configuration into a SecurityRequirementObject.\n * Handles both flat arrays and nested arrays (for complex auth scenarios).\n */\nconst buildSecurityRequirementFromPreferred = (\n preferredSecurityScheme: string | (string | string[])[],\n securitySchemes: MergedSecuritySchemes,\n): SecurityRequirementObject => {\n if (!Array.isArray(preferredSecurityScheme)) {\n const scheme = getResolvedRef(securitySchemes[preferredSecurityScheme])\n return { [preferredSecurityScheme]: getDefaultScopes(scheme) }\n }\n\n const requirement: SecurityRequirementObject = {}\n\n for (const item of preferredSecurityScheme) {\n if (Array.isArray(item)) {\n // Handle nested arrays for complex auth (e.g., [['oauth2', 'apiKey'], 'basic'])\n for (const schemeName of item) {\n addSchemeToRequirement(requirement, schemeName, securitySchemes)\n }\n } else {\n addSchemeToRequirement(requirement, item, securitySchemes)\n }\n }\n\n return requirement\n}\n\n/**\n * Determines the default security scheme to use for an operation.\n *\n * Priority order:\n * 1. User-configured preferred security scheme (if provided)\n * 2. First security requirement from the OpenAPI spec\n * 3. null (no security required)\n */\nexport const getDefaultSecurity = (\n securityRequirements: SecurityRequirementObject[],\n preferredSecurityScheme: AuthenticationConfiguration['preferredSecurityScheme'],\n securitySchemes: MergedSecuritySchemes,\n): SecurityRequirementObject | null => {\n if (preferredSecurityScheme) {\n return buildSecurityRequirementFromPreferred(\n preferredSecurityScheme,\n securitySchemes,\n )\n }\n\n const firstRequirement = securityRequirements[0]\n if (firstRequirement) {\n return unpackProxyObject(firstRequirement, { depth: 1 })\n }\n\n return null\n}\n\n/** Builds a quick cache key from the sorted object keys */\nconst getKey = (requirement: SecurityRequirementObject) =>\n Object.keys(requirement).sort().join(',')\n\n/**\n * Find the intersection between which security is selected on the document and what this operation requires\n *\n * If there is no overlap, we return the first requirement\n */\nexport const filterSelectedSecurity = (\n document: OpenApiDocument,\n operation: OperationObject | null,\n securitySchemes: MergedSecuritySchemes = {},\n): SecuritySchemeObject[] => {\n const securityRequirements = operation?.security ?? document.security ?? []\n\n /** The selected security keys for the document */\n const selectedSecurity = getSelectedSecurity(\n document?.['x-scalar-selected-security'],\n operation?.['x-scalar-selected-security'],\n )\n\n /** Build a set for O(1) lookup */\n const requirementSet = new Set(securityRequirements.map((r) => getKey(r)))\n\n // Lets check the selectedIndex first\n const selectedRequirement =\n selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex]\n if (selectedRequirement && requirementSet.has(getKey(selectedRequirement))) {\n return getSecuritySchemes(securitySchemes, [selectedRequirement])\n }\n\n // Otherwise lets loop over all selected\n for (const selected of selectedSecurity.selectedSchemes) {\n if (requirementSet.has(getKey(selected))) {\n return getSecuritySchemes(securitySchemes, [selected])\n }\n }\n\n /**\n * If we are selected security on the document,\n * we should show the first requirement of the operation to show auth is required\n */\n if (\n operation?.security?.length &&\n !document?.['x-scalar-set-operation-security']\n ) {\n return getSecuritySchemes(securitySchemes, securityRequirements.slice(0, 1))\n }\n\n return []\n}\n\nexport function getOperations(doc: Partial<OpenAPIV3_1.Document>) {\n return Object.values(doc.paths ?? {}).flatMap((path) =>\n Object.values(path ?? {}),\n ) as OperationObject[]\n}\n\n/** Flattens all security requirements from a document */\nexport function getSecurityFromDocument(document: WorkspaceDocument) {\n const selectedSchemes =\n document['x-scalar-selected-security']?.selectedSchemes ?? []\n\n const schemeKeys = selectedSchemes.flatMap((scheme) => Object.keys(scheme))\n\n const securitySchemes = document.components?.securitySchemes\n\n if (!securitySchemes) return []\n\n return schemeKeys.reduce<SecuritySchemeObject[]>((acc, cur) => {\n const security = securitySchemes[cur]\n\n if (security) acc.push(getResolvedRef(security))\n\n return acc\n }, [])\n}\n\n/** Generate document settings from workspace store */\nexport function createDocumentSettings(workspaceStore: WorkspaceStore) {\n return Object.fromEntries(\n Object.entries(workspaceStore.workspace.documents).map(\n ([key, document]) => [\n key,\n {\n activeServer: getSelectedServer(document),\n securitySchemes: getSecurityFromDocument(document),\n },\n ],\n ),\n )\n}\n\n// Local storage helper instance, safely wrapped.\nconst storage = safeLocalStorage()\n\n/**\n * Provides an interface to store and retrieve the selected client value\n * in local storage.\n */\nexport const clientStorage = () => {\n const key = REFERENCE_LS_KEYS.SELECTED_CLIENT\n return {\n /**\n * Gets the stored selected client from local storage.\n */\n get: () => {\n return storage.getItem(key)\n },\n /**\n * Stores the selected client value in local storage.\n * @param value The value to store\n */\n set: (value: string) => {\n storage.setItem(key, value as string)\n },\n }\n}\n\n/**\n * Provides an interface to store and retrieve authentication scheme\n * information in local storage, including both the available schemes and\n * the user's selected schemes.\n */\nexport const authStorage = () => {\n const schemasKey = REFERENCE_LS_KEYS.AUTH_SCHEMES\n const selectedSchemesKey = REFERENCE_LS_KEYS.SELECTED_AUTH_SCHEMES\n\n const getAuthId = (type: 'schemas' | 'selectedSchemes', prefix: string) => {\n const getKey = (type: 'schemas' | 'selectedSchemes') => {\n return type === 'schemas' ? schemasKey : selectedSchemesKey\n }\n return `${prefix}-${getKey(type)}`\n }\n\n return {\n /**\n * Retrieves and coerces the authentication schemes stored in local storage.\n */\n getSchemas: (slug: string) => {\n const parsed = JSON.parse(\n storage.getItem(getAuthId('schemas', slug)) ?? '{}',\n )\n return coerceValue(SecuritySchemesSchema, parsed)\n },\n /**\n * Stores the authentication schemes in local storage.\n * @param value The SecuritySchemes object to stringify and store.\n */\n setSchemas: (slug: string, value: SecuritySchemes) => {\n storage.setItem(getAuthId('schemas', slug), JSON.stringify(value))\n },\n /**\n * Retrieves and coerces the selected authentication schemes stored in local storage.\n */\n getSelectedSchemes: (slug: string) => {\n const parsed = JSON.parse(\n storage.getItem(getAuthId('selectedSchemes', slug)) ?? '{}',\n )\n return coerceValue(XScalarSelectedSecuritySchema, parsed)\n },\n /**\n * Stores the user's selected authentication schemes in local storage.\n * @param value The XScalarSelectedSecurity object to stringify and store.\n */\n setSelectedSchemes: (slug: string, value: XScalarSelectedSecurity) => {\n storage.setItem(getAuthId('selectedSchemes', slug), JSON.stringify(value))\n },\n }\n}\n\n/**\n * Recursively merges secret values from stored data into the current schema.\n * Only merges secrets if the corresponding structure exists in the current schema.\n *\n * This function walks through both objects in parallel, copying any keys that\n * start with 'x-scalar-secret-' from the stored object to the current object,\n * but only if the path exists in the current schema.\n *\n * @param current - The current schema object (source of truth for structure)\n * @param stored - The stored object containing secret values to restore\n */\nexport const mergeSecrets = (current: unknown, stored: unknown): void => {\n if (!isObject(current) || !isObject(stored)) {\n return\n }\n\n // Iterate through stored keys to find secrets to restore\n for (const [key, storedValue] of Object.entries(stored)) {\n // If this is a secret key and it has a value, restore it to current\n if (typeof storedValue !== 'object') {\n current[key] = storedValue\n continue\n }\n\n // If the value is an object (and not null), recurse into it\n mergeSecrets(getResolvedRef(current[key]), storedValue)\n }\n}\n\ntype SelectedSecurityScheme = NonNullable<\n XScalarSelectedSecurity['x-scalar-selected-security']\n>['selectedSchemes'][number]\n\n/**\n * Validates that all keys in a security scheme exist in the available schemes.\n */\nconst isSchemeValid = (\n scheme: SelectedSecurityScheme,\n availableSchemes: Set<string>,\n): boolean => Object.keys(scheme).every((key) => availableSchemes.has(key))\n\n/**\n * Clamps the selected index to be within the valid range of schemes.\n * If the index is out of bounds, returns the last valid index.\n */\nconst clampSelectedIndex = (\n selectedIndex: number,\n schemesLength: number,\n): number =>\n selectedIndex >= schemesLength ? schemesLength - 1 : selectedIndex\n\n/**\n * Restores authentication secrets from local storage to the workspace store.\n *\n * This function iterates through stored authentication schemes and restores\n * any secret values (keys starting with x-scalar-secret-) to the active\n * document's security schemes. It uses the current security schemes as the\n * source of truth, only restoring secrets for structures that exist in the\n * current document.\n */\nexport const restoreAuthSecretsFromStorage = ({\n documentName,\n workspaceStore,\n}: {\n documentName: string\n workspaceStore: WorkspaceStore\n}): void => {\n const storedAuthSchemes = authStorage().getSchemas(documentName)\n\n const document = workspaceStore.workspace.documents[documentName]\n\n if (!document) return\n\n const authPersistence = authStorage()\n\n const storedSelectedAuthSchemes =\n authPersistence.getSelectedSchemes(documentName)\n\n const availableSchemes = new Set(\n Object.keys(document.components?.securitySchemes ?? {}),\n )\n\n const selectedSchemes =\n storedSelectedAuthSchemes['x-scalar-selected-security']?.selectedSchemes\n\n const validSchemes = selectedSchemes?.filter((scheme) =>\n isSchemeValid(scheme, availableSchemes),\n )\n\n if (\n !document['x-scalar-selected-security'] &&\n validSchemes &&\n validSchemes.length > 0\n ) {\n const selectedIdx =\n storedSelectedAuthSchemes['x-scalar-selected-security']?.selectedIndex\n\n const clampedIndex = clampSelectedIndex(\n selectedIdx ?? 0,\n validSchemes.length,\n )\n\n document['x-scalar-selected-security'] = {\n selectedIndex: clampedIndex,\n selectedSchemes: validSchemes,\n }\n }\n\n const securitySchemes = document.components?.securitySchemes ?? {}\n\n for (const [key, storedScheme] of Object.entries(storedAuthSchemes)) {\n const currentScheme = getResolvedRef(securitySchemes[key])\n\n if (isObject(currentScheme)) mergeSecrets(currentScheme, storedScheme)\n }\n}\n\nexport function safeParseJson(value: string) {\n try {\n return JSON.parse(value)\n } catch {\n return\n }\n}\n"],"names":["getKey","type"],"mappings":"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"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
2
|
-
import { useState } from "../state/state.js";
|
|
3
|
-
function isRequestedToolPart(part) {
|
|
4
|
-
return part.type.startsWith("tool") && part.state === "approval-requested";
|
|
5
|
-
}
|
|
6
|
-
function useChatApprovals() {
|
|
7
|
-
const state = useState();
|
|
8
|
-
const approvalRequestedParts = computed(() => {
|
|
9
|
-
return state.chat.messages.filter((message) => message.parts.some(isRequestedToolPart)).flatMap((message) => message.parts).filter(isRequestedToolPart);
|
|
10
|
-
});
|
|
11
|
-
async function respondToToolCalls(approved) {
|
|
12
|
-
const approvalPromises = approvalRequestedParts.value.map(
|
|
13
|
-
(toolPart) => state.chat.addToolApprovalResponse({
|
|
14
|
-
id: toolPart.approval.id,
|
|
15
|
-
approved
|
|
16
|
-
})
|
|
17
|
-
);
|
|
18
|
-
await Promise.all(approvalPromises);
|
|
19
|
-
}
|
|
20
|
-
return { approvalRequestedParts, respondToToolCalls };
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
useChatApprovals
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=useChatApprovals.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useChatApprovals.js","sources":["../../src/hooks/useChatApprovals.ts"],"sourcesContent":["import type { ToolUIPart, UIMessagePart, UITools } from 'ai'\nimport { computed } from 'vue'\n\nimport { useState } from '@/state/state'\n\ntype ApprovalRequestedToolPart = ToolUIPart & { state: 'approval-requested' }\n\nfunction isRequestedToolPart(\n part: UIMessagePart<any, UITools>,\n): part is ApprovalRequestedToolPart {\n return (\n part.type.startsWith('tool') &&\n (part as ToolUIPart).state === 'approval-requested'\n )\n}\n\nexport function useChatApprovals() {\n const state = useState()\n\n const approvalRequestedParts = computed(() => {\n return state.chat.messages\n .filter((message) => message.parts.some(isRequestedToolPart))\n .flatMap((message) => message.parts)\n .filter(isRequestedToolPart) as ApprovalRequestedToolPart[]\n })\n\n async function respondToToolCalls(approved: boolean) {\n const approvalPromises = approvalRequestedParts.value.map((toolPart) =>\n state.chat.addToolApprovalResponse({\n id: toolPart.approval.id,\n approved,\n }),\n )\n\n await Promise.all(approvalPromises)\n }\n\n return { approvalRequestedParts, respondToToolCalls }\n}\n"],"names":[],"mappings":";;AAOA,SAAS,oBACP,MACmC;AACnC,SACE,KAAK,KAAK,WAAW,MAAM,KAC1B,KAAoB,UAAU;AAEnC;AAEO,SAAS,mBAAmB;AACjC,QAAM,QAAQ,SAAA;AAEd,QAAM,yBAAyB,SAAS,MAAM;AAC5C,WAAO,MAAM,KAAK,SACf,OAAO,CAAC,YAAY,QAAQ,MAAM,KAAK,mBAAmB,CAAC,EAC3D,QAAQ,CAAC,YAAY,QAAQ,KAAK,EAClC,OAAO,mBAAmB;AAAA,EAC/B,CAAC;AAED,iBAAe,mBAAmB,UAAmB;AACnD,UAAM,mBAAmB,uBAAuB,MAAM;AAAA,MAAI,CAAC,aACzD,MAAM,KAAK,wBAAwB;AAAA,QACjC,IAAI,SAAS,SAAS;AAAA,QACtB;AAAA,MAAA,CACD;AAAA,IAAA;AAGH,UAAM,QAAQ,IAAI,gBAAgB;AAAA,EACpC;AAEA,SAAO,EAAE,wBAAwB,mBAAA;AACnC;"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { watch, createApp } from "vue";
|
|
2
|
-
import Endpoint from "../components/Endpoint.vue.js";
|
|
3
|
-
import { useState } from "../state/state.js";
|
|
4
|
-
import { array, string } from "../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/mini/schemas.js";
|
|
5
|
-
function useChatOperationBlocks(workspaceStore) {
|
|
6
|
-
const state = useState();
|
|
7
|
-
watch(
|
|
8
|
-
() => state.chat.messages,
|
|
9
|
-
() => {
|
|
10
|
-
document.querySelectorAll(".scalar-api").forEach((el) => {
|
|
11
|
-
if ("__vue_app__" in el) return;
|
|
12
|
-
const [method, path] = array(string()).parse(el.getAttribute("method")?.split(" "));
|
|
13
|
-
const app = createApp(Endpoint, {
|
|
14
|
-
workspaceStore,
|
|
15
|
-
method,
|
|
16
|
-
config: state.config,
|
|
17
|
-
eventBus: state.eventBus,
|
|
18
|
-
path
|
|
19
|
-
});
|
|
20
|
-
app.mount(el);
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
{ deep: true }
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
useChatOperationBlocks
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=useChatOperationBlocks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useChatOperationBlocks.js","sources":["../../src/hooks/useChatOperationBlocks.ts"],"sourcesContent":["import { createApp, watch } from 'vue'\nimport { z } from 'zod/mini'\n\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\n\nimport Endpoint from '@/components/Endpoint.vue'\nimport { useState } from '@/state/state'\n\nexport function useChatOperationBlocks(workspaceStore: WorkspaceStore) {\n const state = useState()\n\n watch(\n () => state.chat.messages,\n () => {\n document.querySelectorAll<HTMLElement>('.scalar-api').forEach((el) => {\n if ('__vue_app__' in el) return\n\n const [method, path] = z\n .array(z.string())\n .parse(el.getAttribute('method')?.split(' '))\n\n const app = createApp(Endpoint, {\n workspaceStore,\n method,\n config: state.config,\n eventBus: state.eventBus,\n path,\n })\n\n app.mount(el)\n })\n },\n { deep: true },\n )\n}\n"],"names":["z.array","z.string"],"mappings":";;;;AAQO,SAAS,uBAAuB,gBAAgC;AACrE,QAAM,QAAQ,SAAA;AAEd;AAAA,IACE,MAAM,MAAM,KAAK;AAAA,IACjB,MAAM;AACJ,eAAS,iBAA8B,aAAa,EAAE,QAAQ,CAAC,OAAO;AACpE,YAAI,iBAAiB,GAAI;AAEzB,cAAM,CAAC,QAAQ,IAAI,IAAIA,MACdC,OAAE,CAAQ,EAChB,MAAM,GAAG,aAAa,QAAQ,GAAG,MAAM,GAAG,CAAC;AAE9C,cAAM,MAAM,UAAU,UAAU;AAAA,UAC9B;AAAA,UACA;AAAA,UACA,QAAQ,MAAM;AAAA,UACd,UAAU,MAAM;AAAA,UAChB;AAAA,QAAA,CACD;AAED,YAAI,MAAM,EAAE;AAAA,MACd,CAAC;AAAA,IACH;AAAA,IACA,EAAE,MAAM,KAAA;AAAA,EAAK;AAEjB;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { watch, nextTick } from "vue";
|
|
2
|
-
import { useState } from "../state/state.js";
|
|
3
|
-
function useChatScroll() {
|
|
4
|
-
const state = useState();
|
|
5
|
-
function getMsgContent(msg) {
|
|
6
|
-
const lastPart = msg?.parts.at(-1);
|
|
7
|
-
if (!lastPart) return;
|
|
8
|
-
if (lastPart.type !== "text") return;
|
|
9
|
-
return lastPart.text;
|
|
10
|
-
}
|
|
11
|
-
watch(
|
|
12
|
-
[() => state.chat.status, () => getMsgContent(state.chat.lastMessage)],
|
|
13
|
-
async () => {
|
|
14
|
-
await nextTick();
|
|
15
|
-
window.scrollTo(0, document.body.scrollHeight);
|
|
16
|
-
}
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
useChatScroll
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=useChatScroll.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useChatScroll.js","sources":["../../src/hooks/useChatScroll.ts"],"sourcesContent":["import type { UIMessage } from 'ai'\nimport { nextTick, watch } from 'vue'\n\nimport { useState } from '@/state/state'\n\nexport function useChatScroll() {\n const state = useState()\n\n function getMsgContent(msg?: UIMessage) {\n const lastPart = msg?.parts.at(-1)\n if (!lastPart) return\n\n if (lastPart.type !== 'text') return\n\n return lastPart.text\n }\n\n watch(\n [() => state.chat.status, () => getMsgContent(state.chat.lastMessage)],\n async () => {\n await nextTick()\n window.scrollTo(0, document.body.scrollHeight)\n },\n )\n}\n"],"names":[],"mappings":";;AAKO,SAAS,gBAAgB;AAC9B,QAAM,QAAQ,SAAA;AAEd,WAAS,cAAc,KAAiB;AACtC,UAAM,WAAW,KAAK,MAAM,GAAG,EAAE;AACjC,QAAI,CAAC,SAAU;AAEf,QAAI,SAAS,SAAS,OAAQ;AAE9B,WAAO,SAAS;AAAA,EAClB;AAEA;AAAA,IACE,CAAC,MAAM,MAAM,KAAK,QAAQ,MAAM,cAAc,MAAM,KAAK,WAAW,CAAC;AAAA,IACrE,YAAY;AACV,YAAM,SAAA;AACN,aAAO,SAAS,GAAG,SAAS,KAAK,YAAY;AAAA,IAC/C;AAAA,EAAA;AAEJ;"}
|
package/dist/hooks/useSearch.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { useDebounceFn } from "@vueuse/core";
|
|
2
|
-
import { ref, computed } from "vue";
|
|
3
|
-
import { apiServiceFactory } from "@scalar-org/service-api";
|
|
4
|
-
function useSearch(baseUrl) {
|
|
5
|
-
const queryRef = ref("");
|
|
6
|
-
const api = apiServiceFactory(
|
|
7
|
-
baseUrl,
|
|
8
|
-
() => "no-token",
|
|
9
|
-
async () => {
|
|
10
|
-
}
|
|
11
|
-
);
|
|
12
|
-
const search = useDebounceFn(async (q) => {
|
|
13
|
-
const searchResponse = await api.agent.search(q);
|
|
14
|
-
if (searchResponse.error) return;
|
|
15
|
-
results.value = searchResponse.data.results;
|
|
16
|
-
}, 200);
|
|
17
|
-
const query = computed({
|
|
18
|
-
get: () => {
|
|
19
|
-
return queryRef.value;
|
|
20
|
-
},
|
|
21
|
-
set: (v) => {
|
|
22
|
-
search(v);
|
|
23
|
-
queryRef.value = v;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
const results = ref([]);
|
|
27
|
-
search("");
|
|
28
|
-
return {
|
|
29
|
-
query,
|
|
30
|
-
results
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export {
|
|
34
|
-
useSearch
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=useSearch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSearch.js","sources":["../../src/hooks/useSearch.ts"],"sourcesContent":["import { useDebounceFn } from '@vueuse/core'\nimport { computed, ref } from 'vue'\n\nimport { apiServiceFactory } from '@scalar-org/service-api'\n\nimport type { ApiMetadata } from '@/state/state'\n\nexport function useSearch(baseUrl: string) {\n const queryRef = ref('')\n\n const api = apiServiceFactory(\n baseUrl,\n () => 'no-token',\n async () => {\n // no-op\n },\n )\n\n const search = useDebounceFn(async (q) => {\n const searchResponse = await api.agent.search(q)\n\n if (searchResponse.error) return\n\n results.value = searchResponse.data.results\n }, 200)\n\n const query = computed({\n get: () => {\n return queryRef.value\n },\n set: (v) => {\n search(v)\n queryRef.value = v\n },\n })\n\n const results = ref<ApiMetadata[]>([])\n\n search('')\n\n return {\n query,\n results,\n }\n}\n"],"names":[],"mappings":";;;AAOO,SAAS,UAAU,SAAiB;AACzC,QAAM,WAAW,IAAI,EAAE;AAEvB,QAAM,MAAM;AAAA,IACV;AAAA,IACA,MAAM;AAAA,IACN,YAAY;AAAA,IAEZ;AAAA,EAAA;AAGF,QAAM,SAAS,cAAc,OAAO,MAAM;AACxC,UAAM,iBAAiB,MAAM,IAAI,MAAM,OAAO,CAAC;AAE/C,QAAI,eAAe,MAAO;AAE1B,YAAQ,QAAQ,eAAe,KAAK;AAAA,EACtC,GAAG,GAAG;AAEN,QAAM,QAAQ,SAAS;AAAA,IACrB,KAAK,MAAM;AACT,aAAO,SAAS;AAAA,IAClB;AAAA,IACA,KAAK,CAAC,MAAM;AACV,aAAO,CAAC;AACR,eAAS,QAAQ;AAAA,IACnB;AAAA,EAAA,CACD;AAED,QAAM,UAAU,IAAmB,EAAE;AAErC,SAAO,EAAE;AAET,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sources":["../../../../../../../../../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/api.js"],"sourcesContent":["import * as checks from \"./checks.js\";\nimport * as registries from \"./registries.js\";\nimport * as schemas from \"./schemas.js\";\nimport * as util from \"./util.js\";\n// @__NO_SIDE_EFFECTS__\nexport function _string(Class, params) {\n return new Class({\n type: \"string\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedString(Class, params) {\n return new Class({\n type: \"string\",\n coerce: true,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _email(Class, params) {\n return new Class({\n type: \"string\",\n format: \"email\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _guid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"guid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uuid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"uuid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uuidv4(Class, params) {\n return new Class({\n type: \"string\",\n format: \"uuid\",\n check: \"string_format\",\n abort: false,\n version: \"v4\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uuidv6(Class, params) {\n return new Class({\n type: \"string\",\n format: \"uuid\",\n check: \"string_format\",\n abort: false,\n version: \"v6\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uuidv7(Class, params) {\n return new Class({\n type: \"string\",\n format: \"uuid\",\n check: \"string_format\",\n abort: false,\n version: \"v7\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _url(Class, params) {\n return new Class({\n type: \"string\",\n format: \"url\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _emoji(Class, params) {\n return new Class({\n type: \"string\",\n format: \"emoji\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _nanoid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"nanoid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _cuid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"cuid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _cuid2(Class, params) {\n return new Class({\n type: \"string\",\n format: \"cuid2\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _ulid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"ulid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _xid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"xid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _ksuid(Class, params) {\n return new Class({\n type: \"string\",\n format: \"ksuid\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _ipv4(Class, params) {\n return new Class({\n type: \"string\",\n format: \"ipv4\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _ipv6(Class, params) {\n return new Class({\n type: \"string\",\n format: \"ipv6\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _mac(Class, params) {\n return new Class({\n type: \"string\",\n format: \"mac\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _cidrv4(Class, params) {\n return new Class({\n type: \"string\",\n format: \"cidrv4\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _cidrv6(Class, params) {\n return new Class({\n type: \"string\",\n format: \"cidrv6\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _base64(Class, params) {\n return new Class({\n type: \"string\",\n format: \"base64\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _base64url(Class, params) {\n return new Class({\n type: \"string\",\n format: \"base64url\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _e164(Class, params) {\n return new Class({\n type: \"string\",\n format: \"e164\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _jwt(Class, params) {\n return new Class({\n type: \"string\",\n format: \"jwt\",\n check: \"string_format\",\n abort: false,\n ...util.normalizeParams(params),\n });\n}\nexport const TimePrecision = {\n Any: null,\n Minute: -1,\n Second: 0,\n Millisecond: 3,\n Microsecond: 6,\n};\n// @__NO_SIDE_EFFECTS__\nexport function _isoDateTime(Class, params) {\n return new Class({\n type: \"string\",\n format: \"datetime\",\n check: \"string_format\",\n offset: false,\n local: false,\n precision: null,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _isoDate(Class, params) {\n return new Class({\n type: \"string\",\n format: \"date\",\n check: \"string_format\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _isoTime(Class, params) {\n return new Class({\n type: \"string\",\n format: \"time\",\n check: \"string_format\",\n precision: null,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _isoDuration(Class, params) {\n return new Class({\n type: \"string\",\n format: \"duration\",\n check: \"string_format\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _number(Class, params) {\n return new Class({\n type: \"number\",\n checks: [],\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedNumber(Class, params) {\n return new Class({\n type: \"number\",\n coerce: true,\n checks: [],\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _int(Class, params) {\n return new Class({\n type: \"number\",\n check: \"number_format\",\n abort: false,\n format: \"safeint\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _float32(Class, params) {\n return new Class({\n type: \"number\",\n check: \"number_format\",\n abort: false,\n format: \"float32\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _float64(Class, params) {\n return new Class({\n type: \"number\",\n check: \"number_format\",\n abort: false,\n format: \"float64\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _int32(Class, params) {\n return new Class({\n type: \"number\",\n check: \"number_format\",\n abort: false,\n format: \"int32\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uint32(Class, params) {\n return new Class({\n type: \"number\",\n check: \"number_format\",\n abort: false,\n format: \"uint32\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _boolean(Class, params) {\n return new Class({\n type: \"boolean\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedBoolean(Class, params) {\n return new Class({\n type: \"boolean\",\n coerce: true,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _bigint(Class, params) {\n return new Class({\n type: \"bigint\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedBigint(Class, params) {\n return new Class({\n type: \"bigint\",\n coerce: true,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _int64(Class, params) {\n return new Class({\n type: \"bigint\",\n check: \"bigint_format\",\n abort: false,\n format: \"int64\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uint64(Class, params) {\n return new Class({\n type: \"bigint\",\n check: \"bigint_format\",\n abort: false,\n format: \"uint64\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _symbol(Class, params) {\n return new Class({\n type: \"symbol\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _undefined(Class, params) {\n return new Class({\n type: \"undefined\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _null(Class, params) {\n return new Class({\n type: \"null\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _any(Class) {\n return new Class({\n type: \"any\",\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _unknown(Class) {\n return new Class({\n type: \"unknown\",\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _never(Class, params) {\n return new Class({\n type: \"never\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _void(Class, params) {\n return new Class({\n type: \"void\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _date(Class, params) {\n return new Class({\n type: \"date\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedDate(Class, params) {\n return new Class({\n type: \"date\",\n coerce: true,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _nan(Class, params) {\n return new Class({\n type: \"nan\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _lt(value, params) {\n return new checks.$ZodCheckLessThan({\n check: \"less_than\",\n ...util.normalizeParams(params),\n value,\n inclusive: false,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _lte(value, params) {\n return new checks.$ZodCheckLessThan({\n check: \"less_than\",\n ...util.normalizeParams(params),\n value,\n inclusive: true,\n });\n}\nexport { \n/** @deprecated Use `z.lte()` instead. */\n_lte as _max, };\n// @__NO_SIDE_EFFECTS__\nexport function _gt(value, params) {\n return new checks.$ZodCheckGreaterThan({\n check: \"greater_than\",\n ...util.normalizeParams(params),\n value,\n inclusive: false,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _gte(value, params) {\n return new checks.$ZodCheckGreaterThan({\n check: \"greater_than\",\n ...util.normalizeParams(params),\n value,\n inclusive: true,\n });\n}\nexport { \n/** @deprecated Use `z.gte()` instead. */\n_gte as _min, };\n// @__NO_SIDE_EFFECTS__\nexport function _positive(params) {\n return _gt(0, params);\n}\n// negative\n// @__NO_SIDE_EFFECTS__\nexport function _negative(params) {\n return _lt(0, params);\n}\n// nonpositive\n// @__NO_SIDE_EFFECTS__\nexport function _nonpositive(params) {\n return _lte(0, params);\n}\n// nonnegative\n// @__NO_SIDE_EFFECTS__\nexport function _nonnegative(params) {\n return _gte(0, params);\n}\n// @__NO_SIDE_EFFECTS__\nexport function _multipleOf(value, params) {\n return new checks.$ZodCheckMultipleOf({\n check: \"multiple_of\",\n ...util.normalizeParams(params),\n value,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _maxSize(maximum, params) {\n return new checks.$ZodCheckMaxSize({\n check: \"max_size\",\n ...util.normalizeParams(params),\n maximum,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _minSize(minimum, params) {\n return new checks.$ZodCheckMinSize({\n check: \"min_size\",\n ...util.normalizeParams(params),\n minimum,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _size(size, params) {\n return new checks.$ZodCheckSizeEquals({\n check: \"size_equals\",\n ...util.normalizeParams(params),\n size,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _maxLength(maximum, params) {\n const ch = new checks.$ZodCheckMaxLength({\n check: \"max_length\",\n ...util.normalizeParams(params),\n maximum,\n });\n return ch;\n}\n// @__NO_SIDE_EFFECTS__\nexport function _minLength(minimum, params) {\n return new checks.$ZodCheckMinLength({\n check: \"min_length\",\n ...util.normalizeParams(params),\n minimum,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _length(length, params) {\n return new checks.$ZodCheckLengthEquals({\n check: \"length_equals\",\n ...util.normalizeParams(params),\n length,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _regex(pattern, params) {\n return new checks.$ZodCheckRegex({\n check: \"string_format\",\n format: \"regex\",\n ...util.normalizeParams(params),\n pattern,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _lowercase(params) {\n return new checks.$ZodCheckLowerCase({\n check: \"string_format\",\n format: \"lowercase\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _uppercase(params) {\n return new checks.$ZodCheckUpperCase({\n check: \"string_format\",\n format: \"uppercase\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _includes(includes, params) {\n return new checks.$ZodCheckIncludes({\n check: \"string_format\",\n format: \"includes\",\n ...util.normalizeParams(params),\n includes,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _startsWith(prefix, params) {\n return new checks.$ZodCheckStartsWith({\n check: \"string_format\",\n format: \"starts_with\",\n ...util.normalizeParams(params),\n prefix,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _endsWith(suffix, params) {\n return new checks.$ZodCheckEndsWith({\n check: \"string_format\",\n format: \"ends_with\",\n ...util.normalizeParams(params),\n suffix,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _property(property, schema, params) {\n return new checks.$ZodCheckProperty({\n check: \"property\",\n property,\n schema,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _mime(types, params) {\n return new checks.$ZodCheckMimeType({\n check: \"mime_type\",\n mime: types,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _overwrite(tx) {\n return new checks.$ZodCheckOverwrite({\n check: \"overwrite\",\n tx,\n });\n}\n// normalize\n// @__NO_SIDE_EFFECTS__\nexport function _normalize(form) {\n return _overwrite((input) => input.normalize(form));\n}\n// trim\n// @__NO_SIDE_EFFECTS__\nexport function _trim() {\n return _overwrite((input) => input.trim());\n}\n// toLowerCase\n// @__NO_SIDE_EFFECTS__\nexport function _toLowerCase() {\n return _overwrite((input) => input.toLowerCase());\n}\n// toUpperCase\n// @__NO_SIDE_EFFECTS__\nexport function _toUpperCase() {\n return _overwrite((input) => input.toUpperCase());\n}\n// slugify\n// @__NO_SIDE_EFFECTS__\nexport function _slugify() {\n return _overwrite((input) => util.slugify(input));\n}\n// @__NO_SIDE_EFFECTS__\nexport function _array(Class, element, params) {\n return new Class({\n type: \"array\",\n element,\n // get element() {\n // return element;\n // },\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _union(Class, options, params) {\n return new Class({\n type: \"union\",\n options,\n ...util.normalizeParams(params),\n });\n}\nexport function _xor(Class, options, params) {\n return new Class({\n type: \"union\",\n options,\n inclusive: false,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _discriminatedUnion(Class, discriminator, options, params) {\n return new Class({\n type: \"union\",\n options,\n discriminator,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _intersection(Class, left, right) {\n return new Class({\n type: \"intersection\",\n left,\n right,\n });\n}\n// export function _tuple(\n// Class: util.SchemaClass<schemas.$ZodTuple>,\n// items: [],\n// params?: string | $ZodTupleParams\n// ): schemas.$ZodTuple<[], null>;\n// @__NO_SIDE_EFFECTS__\nexport function _tuple(Class, items, _paramsOrRest, _params) {\n const hasRest = _paramsOrRest instanceof schemas.$ZodType;\n const params = hasRest ? _params : _paramsOrRest;\n const rest = hasRest ? _paramsOrRest : null;\n return new Class({\n type: \"tuple\",\n items,\n rest,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _record(Class, keyType, valueType, params) {\n return new Class({\n type: \"record\",\n keyType,\n valueType,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _map(Class, keyType, valueType, params) {\n return new Class({\n type: \"map\",\n keyType,\n valueType,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _set(Class, valueType, params) {\n return new Class({\n type: \"set\",\n valueType,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _enum(Class, values, params) {\n const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;\n // if (Array.isArray(values)) {\n // for (const value of values) {\n // entries[value] = value;\n // }\n // } else {\n // Object.assign(entries, values);\n // }\n // const entries: util.EnumLike = {};\n // for (const val of values) {\n // entries[val] = val;\n // }\n return new Class({\n type: \"enum\",\n entries,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\n/** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.\n *\n * ```ts\n * enum Colors { red, green, blue }\n * z.enum(Colors);\n * ```\n */\nexport function _nativeEnum(Class, entries, params) {\n return new Class({\n type: \"enum\",\n entries,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _literal(Class, value, params) {\n return new Class({\n type: \"literal\",\n values: Array.isArray(value) ? value : [value],\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _file(Class, params) {\n return new Class({\n type: \"file\",\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _transform(Class, fn) {\n return new Class({\n type: \"transform\",\n transform: fn,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _optional(Class, innerType) {\n return new Class({\n type: \"optional\",\n innerType,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _nullable(Class, innerType) {\n return new Class({\n type: \"nullable\",\n innerType,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _default(Class, innerType, defaultValue) {\n return new Class({\n type: \"default\",\n innerType,\n get defaultValue() {\n return typeof defaultValue === \"function\" ? defaultValue() : util.shallowClone(defaultValue);\n },\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _nonoptional(Class, innerType, params) {\n return new Class({\n type: \"nonoptional\",\n innerType,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _success(Class, innerType) {\n return new Class({\n type: \"success\",\n innerType,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _catch(Class, innerType, catchValue) {\n return new Class({\n type: \"catch\",\n innerType,\n catchValue: (typeof catchValue === \"function\" ? catchValue : () => catchValue),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _pipe(Class, in_, out) {\n return new Class({\n type: \"pipe\",\n in: in_,\n out,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _readonly(Class, innerType) {\n return new Class({\n type: \"readonly\",\n innerType,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _templateLiteral(Class, parts, params) {\n return new Class({\n type: \"template_literal\",\n parts,\n ...util.normalizeParams(params),\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _lazy(Class, getter) {\n return new Class({\n type: \"lazy\",\n getter,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _promise(Class, innerType) {\n return new Class({\n type: \"promise\",\n innerType,\n });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _custom(Class, fn, _params) {\n const norm = util.normalizeParams(_params);\n norm.abort ?? (norm.abort = true); // default to abort:false\n const schema = new Class({\n type: \"custom\",\n check: \"custom\",\n fn: fn,\n ...norm,\n });\n return schema;\n}\n// same as _custom but defaults to abort:false\n// @__NO_SIDE_EFFECTS__\nexport function _refine(Class, fn, _params) {\n const schema = new Class({\n type: \"custom\",\n check: \"custom\",\n fn: fn,\n ...util.normalizeParams(_params),\n });\n return schema;\n}\n// @__NO_SIDE_EFFECTS__\nexport function _superRefine(fn) {\n const ch = _check((payload) => {\n payload.addIssue = (issue) => {\n if (typeof issue === \"string\") {\n payload.issues.push(util.issue(issue, payload.value, ch._zod.def));\n }\n else {\n // for Zod 3 backwards compatibility\n const _issue = issue;\n if (_issue.fatal)\n _issue.continue = false;\n _issue.code ?? (_issue.code = \"custom\");\n _issue.input ?? (_issue.input = payload.value);\n _issue.inst ?? (_issue.inst = ch);\n _issue.continue ?? (_issue.continue = !ch._zod.def.abort); // abort is always undefined, so this is always true...\n payload.issues.push(util.issue(_issue));\n }\n };\n return fn(payload.value, payload);\n });\n return ch;\n}\n// @__NO_SIDE_EFFECTS__\nexport function _check(fn, params) {\n const ch = new checks.$ZodCheck({\n check: \"custom\",\n ...util.normalizeParams(params),\n });\n ch._zod.check = fn;\n return ch;\n}\n// @__NO_SIDE_EFFECTS__\nexport function describe(description) {\n const ch = new checks.$ZodCheck({ check: \"describe\" });\n ch._zod.onattach = [\n (inst) => {\n const existing = registries.globalRegistry.get(inst) ?? {};\n registries.globalRegistry.add(inst, { ...existing, description });\n },\n ];\n ch._zod.check = () => { }; // no-op check\n return ch;\n}\n// @__NO_SIDE_EFFECTS__\nexport function meta(metadata) {\n const ch = new checks.$ZodCheck({ check: \"meta\" });\n ch._zod.onattach = [\n (inst) => {\n const existing = registries.globalRegistry.get(inst) ?? {};\n registries.globalRegistry.add(inst, { ...existing, ...metadata });\n },\n ];\n ch._zod.check = () => { }; // no-op check\n return ch;\n}\n// @__NO_SIDE_EFFECTS__\nexport function _stringbool(Classes, _params) {\n const params = util.normalizeParams(_params);\n let truthyArray = params.truthy ?? [\"true\", \"1\", \"yes\", \"on\", \"y\", \"enabled\"];\n let falsyArray = params.falsy ?? [\"false\", \"0\", \"no\", \"off\", \"n\", \"disabled\"];\n if (params.case !== \"sensitive\") {\n truthyArray = truthyArray.map((v) => (typeof v === \"string\" ? v.toLowerCase() : v));\n falsyArray = falsyArray.map((v) => (typeof v === \"string\" ? v.toLowerCase() : v));\n }\n const truthySet = new Set(truthyArray);\n const falsySet = new Set(falsyArray);\n const _Codec = Classes.Codec ?? schemas.$ZodCodec;\n const _Boolean = Classes.Boolean ?? schemas.$ZodBoolean;\n const _String = Classes.String ?? schemas.$ZodString;\n const stringSchema = new _String({ type: \"string\", error: params.error });\n const booleanSchema = new _Boolean({ type: \"boolean\", error: params.error });\n const codec = new _Codec({\n type: \"pipe\",\n in: stringSchema,\n out: booleanSchema,\n transform: ((input, payload) => {\n let data = input;\n if (params.case !== \"sensitive\")\n data = data.toLowerCase();\n if (truthySet.has(data)) {\n return true;\n }\n else if (falsySet.has(data)) {\n return false;\n }\n else {\n payload.issues.push({\n code: \"invalid_value\",\n expected: \"stringbool\",\n values: [...truthySet, ...falsySet],\n input: payload.value,\n inst: codec,\n continue: false,\n });\n return {};\n }\n }),\n reverseTransform: ((input, _payload) => {\n if (input === true) {\n return truthyArray[0] || \"true\";\n }\n else {\n return falsyArray[0] || \"false\";\n }\n }),\n error: params.error,\n });\n return codec;\n}\n// @__NO_SIDE_EFFECTS__\nexport function _stringFormat(Class, format, fnOrRegex, _params = {}) {\n const params = util.normalizeParams(_params);\n const def = {\n ...util.normalizeParams(_params),\n check: \"string_format\",\n type: \"string\",\n format,\n fn: typeof fnOrRegex === \"function\" ? fnOrRegex : (val) => fnOrRegex.test(val),\n ...params,\n };\n if (fnOrRegex instanceof RegExp) {\n def.pattern = fnOrRegex;\n }\n const inst = new Class(def);\n return inst;\n}\n"],"names":["util.normalizeParams"],"mappings":";;AAKO,SAAS,QAAQ,OAAO,QAAQ;AACnC,SAAO,IAAI,MAAM;AAAA,IACb,MAAM;AAAA,IACN,GAAGA,gBAA2B;AAAA,EACtC,CAAK;AACL;","x_google_ignoreList":[0]}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
function $constructor(name, initializer, params) {
|
|
2
|
-
function init(inst, def) {
|
|
3
|
-
if (!inst._zod) {
|
|
4
|
-
Object.defineProperty(inst, "_zod", {
|
|
5
|
-
value: {
|
|
6
|
-
def,
|
|
7
|
-
constr: _,
|
|
8
|
-
traits: /* @__PURE__ */ new Set()
|
|
9
|
-
},
|
|
10
|
-
enumerable: false
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
if (inst._zod.traits.has(name)) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
inst._zod.traits.add(name);
|
|
17
|
-
initializer(inst, def);
|
|
18
|
-
const proto = _.prototype;
|
|
19
|
-
const keys = Object.keys(proto);
|
|
20
|
-
for (let i = 0; i < keys.length; i++) {
|
|
21
|
-
const k = keys[i];
|
|
22
|
-
if (!(k in inst)) {
|
|
23
|
-
inst[k] = proto[k].bind(inst);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
const Parent = params?.Parent ?? Object;
|
|
28
|
-
class Definition extends Parent {
|
|
29
|
-
}
|
|
30
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
31
|
-
function _(def) {
|
|
32
|
-
var _a;
|
|
33
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
34
|
-
init(inst, def);
|
|
35
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
36
|
-
for (const fn of inst._zod.deferred) {
|
|
37
|
-
fn();
|
|
38
|
-
}
|
|
39
|
-
return inst;
|
|
40
|
-
}
|
|
41
|
-
Object.defineProperty(_, "init", { value: init });
|
|
42
|
-
Object.defineProperty(_, Symbol.hasInstance, {
|
|
43
|
-
value: (inst) => {
|
|
44
|
-
if (params?.Parent && inst instanceof params.Parent)
|
|
45
|
-
return true;
|
|
46
|
-
return inst?._zod?.traits?.has(name);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(_, "name", { value: name });
|
|
50
|
-
return _;
|
|
51
|
-
}
|
|
52
|
-
class $ZodAsyncError extends Error {
|
|
53
|
-
constructor() {
|
|
54
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const globalConfig = {};
|
|
58
|
-
function config(newConfig) {
|
|
59
|
-
return globalConfig;
|
|
60
|
-
}
|
|
61
|
-
export {
|
|
62
|
-
$ZodAsyncError,
|
|
63
|
-
$constructor,
|
|
64
|
-
config,
|
|
65
|
-
globalConfig
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=core.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":["../../../../../../../../../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/core.js"],"sourcesContent":["/** A special constant with type `never` */\nexport const NEVER = Object.freeze({\n status: \"aborted\",\n});\nexport /*@__NO_SIDE_EFFECTS__*/ function $constructor(name, initializer, params) {\n function init(inst, def) {\n if (!inst._zod) {\n Object.defineProperty(inst, \"_zod\", {\n value: {\n def,\n constr: _,\n traits: new Set(),\n },\n enumerable: false,\n });\n }\n if (inst._zod.traits.has(name)) {\n return;\n }\n inst._zod.traits.add(name);\n initializer(inst, def);\n // support prototype modifications\n const proto = _.prototype;\n const keys = Object.keys(proto);\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i];\n if (!(k in inst)) {\n inst[k] = proto[k].bind(inst);\n }\n }\n }\n // doesn't work if Parent has a constructor with arguments\n const Parent = params?.Parent ?? Object;\n class Definition extends Parent {\n }\n Object.defineProperty(Definition, \"name\", { value: name });\n function _(def) {\n var _a;\n const inst = params?.Parent ? new Definition() : this;\n init(inst, def);\n (_a = inst._zod).deferred ?? (_a.deferred = []);\n for (const fn of inst._zod.deferred) {\n fn();\n }\n return inst;\n }\n Object.defineProperty(_, \"init\", { value: init });\n Object.defineProperty(_, Symbol.hasInstance, {\n value: (inst) => {\n if (params?.Parent && inst instanceof params.Parent)\n return true;\n return inst?._zod?.traits?.has(name);\n },\n });\n Object.defineProperty(_, \"name\", { value: name });\n return _;\n}\n////////////////////////////// UTILITIES ///////////////////////////////////////\nexport const $brand = Symbol(\"zod_brand\");\nexport class $ZodAsyncError extends Error {\n constructor() {\n super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);\n }\n}\nexport class $ZodEncodeError extends Error {\n constructor(name) {\n super(`Encountered unidirectional transform during encode: ${name}`);\n this.name = \"ZodEncodeError\";\n }\n}\nexport const globalConfig = {};\nexport function config(newConfig) {\n if (newConfig)\n Object.assign(globalConfig, newConfig);\n return globalConfig;\n}\n"],"names":[],"mappings":"AAIgC,SAAS,aAAa,MAAM,aAAa,QAAQ;AAC7E,WAAS,KAAK,MAAM,KAAK;AACrB,QAAI,CAAC,KAAK,MAAM;AACZ,aAAO,eAAe,MAAM,QAAQ;AAAA,QAChC,OAAO;AAAA,UACH;AAAA,UACA,QAAQ;AAAA,UACR,QAAQ,oBAAI,IAAG;AAAA,QACnC;AAAA,QACgB,YAAY;AAAA,MAC5B,CAAa;AAAA,IACL;AACA,QAAI,KAAK,KAAK,OAAO,IAAI,IAAI,GAAG;AAC5B;AAAA,IACJ;AACA,SAAK,KAAK,OAAO,IAAI,IAAI;AACzB,gBAAY,MAAM,GAAG;AAErB,UAAM,QAAQ,EAAE;AAChB,UAAM,OAAO,OAAO,KAAK,KAAK;AAC9B,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AAClC,YAAM,IAAI,KAAK,CAAC;AAChB,UAAI,EAAE,KAAK,OAAO;AACd,aAAK,CAAC,IAAI,MAAM,CAAC,EAAE,KAAK,IAAI;AAAA,MAChC;AAAA,IACJ;AAAA,EACJ;AAEA,QAAM,SAAS,QAAQ,UAAU;AAAA,EACjC,MAAM,mBAAmB,OAAO;AAAA,EACpC;AACI,SAAO,eAAe,YAAY,QAAQ,EAAE,OAAO,MAAM;AACzD,WAAS,EAAE,KAAK;AACZ,QAAI;AACJ,UAAM,OAAO,QAAQ,SAAS,IAAI,WAAU,IAAK;AACjD,SAAK,MAAM,GAAG;AACd,KAAC,KAAK,KAAK,MAAM,aAAa,GAAG,WAAW;AAC5C,eAAW,MAAM,KAAK,KAAK,UAAU;AACjC,SAAE;AAAA,IACN;AACA,WAAO;AAAA,EACX;AACA,SAAO,eAAe,GAAG,QAAQ,EAAE,OAAO,MAAM;AAChD,SAAO,eAAe,GAAG,OAAO,aAAa;AAAA,IACzC,OAAO,CAAC,SAAS;AACb,UAAI,QAAQ,UAAU,gBAAgB,OAAO;AACzC,eAAO;AACX,aAAO,MAAM,MAAM,QAAQ,IAAI,IAAI;AAAA,IACvC;AAAA,EACR,CAAK;AACD,SAAO,eAAe,GAAG,QAAQ,EAAE,OAAO,MAAM;AAChD,SAAO;AACX;AAGO,MAAM,uBAAuB,MAAM;AAAA,EACtC,cAAc;AACV,UAAM,0EAA0E;AAAA,EACpF;AACJ;AAOY,MAAC,eAAe,CAAA;AACrB,SAAS,OAAO,WAAW;AAG9B,SAAO;AACX;","x_google_ignoreList":[0]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { $constructor } from "./core.js";
|
|
2
|
-
import { jsonStringifyReplacer } from "./util.js";
|
|
3
|
-
const initializer = (inst, def) => {
|
|
4
|
-
inst.name = "$ZodError";
|
|
5
|
-
Object.defineProperty(inst, "_zod", {
|
|
6
|
-
value: inst._zod,
|
|
7
|
-
enumerable: false
|
|
8
|
-
});
|
|
9
|
-
Object.defineProperty(inst, "issues", {
|
|
10
|
-
value: def,
|
|
11
|
-
enumerable: false
|
|
12
|
-
});
|
|
13
|
-
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
14
|
-
Object.defineProperty(inst, "toString", {
|
|
15
|
-
value: () => inst.message,
|
|
16
|
-
enumerable: false
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
const $ZodError = $constructor("$ZodError", initializer);
|
|
20
|
-
const $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
|
|
21
|
-
export {
|
|
22
|
-
$ZodError,
|
|
23
|
-
$ZodRealError
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sources":["../../../../../../../../../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/errors.js"],"sourcesContent":["import { $constructor } from \"./core.js\";\nimport * as util from \"./util.js\";\nconst initializer = (inst, def) => {\n inst.name = \"$ZodError\";\n Object.defineProperty(inst, \"_zod\", {\n value: inst._zod,\n enumerable: false,\n });\n Object.defineProperty(inst, \"issues\", {\n value: def,\n enumerable: false,\n });\n inst.message = JSON.stringify(def, util.jsonStringifyReplacer, 2);\n Object.defineProperty(inst, \"toString\", {\n value: () => inst.message,\n enumerable: false,\n });\n};\nexport const $ZodError = $constructor(\"$ZodError\", initializer);\nexport const $ZodRealError = $constructor(\"$ZodError\", initializer, { Parent: Error });\nexport function flattenError(error, mapper = (issue) => issue.message) {\n const fieldErrors = {};\n const formErrors = [];\n for (const sub of error.issues) {\n if (sub.path.length > 0) {\n fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];\n fieldErrors[sub.path[0]].push(mapper(sub));\n }\n else {\n formErrors.push(mapper(sub));\n }\n }\n return { formErrors, fieldErrors };\n}\nexport function formatError(error, mapper = (issue) => issue.message) {\n const fieldErrors = { _errors: [] };\n const processError = (error) => {\n for (const issue of error.issues) {\n if (issue.code === \"invalid_union\" && issue.errors.length) {\n issue.errors.map((issues) => processError({ issues }));\n }\n else if (issue.code === \"invalid_key\") {\n processError({ issues: issue.issues });\n }\n else if (issue.code === \"invalid_element\") {\n processError({ issues: issue.issues });\n }\n else if (issue.path.length === 0) {\n fieldErrors._errors.push(mapper(issue));\n }\n else {\n let curr = fieldErrors;\n let i = 0;\n while (i < issue.path.length) {\n const el = issue.path[i];\n const terminal = i === issue.path.length - 1;\n if (!terminal) {\n curr[el] = curr[el] || { _errors: [] };\n }\n else {\n curr[el] = curr[el] || { _errors: [] };\n curr[el]._errors.push(mapper(issue));\n }\n curr = curr[el];\n i++;\n }\n }\n }\n };\n processError(error);\n return fieldErrors;\n}\nexport function treeifyError(error, mapper = (issue) => issue.message) {\n const result = { errors: [] };\n const processError = (error, path = []) => {\n var _a, _b;\n for (const issue of error.issues) {\n if (issue.code === \"invalid_union\" && issue.errors.length) {\n // regular union error\n issue.errors.map((issues) => processError({ issues }, issue.path));\n }\n else if (issue.code === \"invalid_key\") {\n processError({ issues: issue.issues }, issue.path);\n }\n else if (issue.code === \"invalid_element\") {\n processError({ issues: issue.issues }, issue.path);\n }\n else {\n const fullpath = [...path, ...issue.path];\n if (fullpath.length === 0) {\n result.errors.push(mapper(issue));\n continue;\n }\n let curr = result;\n let i = 0;\n while (i < fullpath.length) {\n const el = fullpath[i];\n const terminal = i === fullpath.length - 1;\n if (typeof el === \"string\") {\n curr.properties ?? (curr.properties = {});\n (_a = curr.properties)[el] ?? (_a[el] = { errors: [] });\n curr = curr.properties[el];\n }\n else {\n curr.items ?? (curr.items = []);\n (_b = curr.items)[el] ?? (_b[el] = { errors: [] });\n curr = curr.items[el];\n }\n if (terminal) {\n curr.errors.push(mapper(issue));\n }\n i++;\n }\n }\n }\n };\n processError(error);\n return result;\n}\n/** Format a ZodError as a human-readable string in the following form.\n *\n * From\n *\n * ```ts\n * ZodError {\n * issues: [\n * {\n * expected: 'string',\n * code: 'invalid_type',\n * path: [ 'username' ],\n * message: 'Invalid input: expected string'\n * },\n * {\n * expected: 'number',\n * code: 'invalid_type',\n * path: [ 'favoriteNumbers', 1 ],\n * message: 'Invalid input: expected number'\n * }\n * ];\n * }\n * ```\n *\n * to\n *\n * ```\n * username\n * ✖ Expected number, received string at \"username\n * favoriteNumbers[0]\n * ✖ Invalid input: expected number\n * ```\n */\nexport function toDotPath(_path) {\n const segs = [];\n const path = _path.map((seg) => (typeof seg === \"object\" ? seg.key : seg));\n for (const seg of path) {\n if (typeof seg === \"number\")\n segs.push(`[${seg}]`);\n else if (typeof seg === \"symbol\")\n segs.push(`[${JSON.stringify(String(seg))}]`);\n else if (/[^\\w$]/.test(seg))\n segs.push(`[${JSON.stringify(seg)}]`);\n else {\n if (segs.length)\n segs.push(\".\");\n segs.push(seg);\n }\n }\n return segs.join(\"\");\n}\nexport function prettifyError(error) {\n const lines = [];\n // sort by path length\n const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);\n // Process each issue\n for (const issue of issues) {\n lines.push(`✖ ${issue.message}`);\n if (issue.path?.length)\n lines.push(` → at ${toDotPath(issue.path)}`);\n }\n // Convert Map to formatted string\n return lines.join(\"\\n\");\n}\n"],"names":["util.jsonStringifyReplacer"],"mappings":";;AAEA,MAAM,cAAc,CAAC,MAAM,QAAQ;AAC/B,OAAK,OAAO;AACZ,SAAO,eAAe,MAAM,QAAQ;AAAA,IAChC,OAAO,KAAK;AAAA,IACZ,YAAY;AAAA,EACpB,CAAK;AACD,SAAO,eAAe,MAAM,UAAU;AAAA,IAClC,OAAO;AAAA,IACP,YAAY;AAAA,EACpB,CAAK;AACD,OAAK,UAAU,KAAK,UAAU,KAAKA,uBAA4B,CAAC;AAChE,SAAO,eAAe,MAAM,YAAY;AAAA,IACpC,OAAO,MAAM,KAAK;AAAA,IAClB,YAAY;AAAA,EACpB,CAAK;AACL;AACY,MAAC,YAAY,aAAa,aAAa,WAAW;AAClD,MAAC,gBAAgB,aAAa,aAAa,aAAa,EAAE,QAAQ,MAAK,CAAE;","x_google_ignoreList":[0]}
|