@thxgg/steward 0.1.16 → 0.1.17
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/.env.example +6 -0
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/{wbjFvimm.js → 4r0X30JV.js} +1 -1
- package/.output/public/_nuxt/{ynmyrfyT.js → BMdjSp24.js} +1 -1
- package/.output/public/_nuxt/{BWVTacYj.js → BSZqAKg4.js} +1 -1
- package/.output/public/_nuxt/{Dum5qplW.js → BdjPva1I.js} +1 -1
- package/.output/public/_nuxt/Beeir9iR.js +1 -0
- package/.output/public/_nuxt/Bh3vsUvl.js +1 -0
- package/.output/public/_nuxt/{Bibm_IDv.js → BlTKcjLJ.js} +2 -2
- package/.output/public/_nuxt/{CxHOXVf6.js → By7gAVcL.js} +1 -1
- package/.output/public/_nuxt/CbJfCtEa.js +1 -0
- package/.output/public/_nuxt/CbkpNvIu.js +141 -0
- package/.output/public/_nuxt/CmhLcqDu.js +1 -0
- package/.output/public/_nuxt/DC6iPLz1.js +30 -0
- package/.output/public/_nuxt/{BSA0RJ-H.js → DD--ojY9.js} +1 -1
- package/.output/public/_nuxt/Detail.DSyVQNdr.css +1 -0
- package/.output/public/_nuxt/DhKWRjCh.js +60 -0
- package/.output/public/_nuxt/_prd_.BkpxMFSV.css +1 -0
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/f3f42dbd-d501-442b-871c-3d06157e7aa1.json +1 -0
- package/.output/public/_nuxt/c1sXju8w.js +1 -0
- package/.output/public/_nuxt/eGCjCghR.js +1 -0
- package/.output/public/_nuxt/nX8Sf7cz.js +13 -0
- package/.output/server/chunks/_/git-api.mjs +100 -7
- package/.output/server/chunks/_/git-api.mjs.map +1 -1
- package/.output/server/chunks/_/git.mjs +3 -10
- package/.output/server/chunks/_/git.mjs.map +1 -1
- package/.output/server/chunks/_/prd-service.mjs +234 -0
- package/.output/server/chunks/_/prd-service.mjs.map +1 -0
- package/.output/server/chunks/_/task-graph.mjs +3 -3
- package/.output/server/chunks/_/task-graph.mjs.map +1 -1
- package/.output/server/chunks/_/watcher.mjs +26 -46
- package/.output/server/chunks/_/watcher.mjs.map +1 -1
- package/.output/server/chunks/build/{Detail-CUfU85GY.mjs → Detail-MGwP_u2d.mjs} +63 -34
- package/.output/server/chunks/build/Detail-MGwP_u2d.mjs.map +1 -0
- package/.output/server/chunks/build/DiffViewer-styles-1.mjs-BFsE2PCW.mjs +4 -0
- package/.output/server/chunks/build/DiffViewer-styles-1.mjs-BFsE2PCW.mjs.map +1 -0
- package/.output/server/chunks/build/DiffViewer-styles.D2bqX3nK.mjs +8 -0
- package/.output/server/chunks/build/DiffViewer-styles.D2bqX3nK.mjs.map +1 -0
- package/.output/server/chunks/build/DiffViewer-styles.FoV36wuV.mjs +10 -0
- package/.output/server/chunks/build/DiffViewer-styles.FoV36wuV.mjs.map +1 -0
- package/.output/server/chunks/build/Viewer-styles.D6wYWFb1.mjs +8 -0
- package/.output/server/chunks/build/Viewer-styles.D6wYWFb1.mjs.map +1 -0
- package/.output/server/chunks/build/{_prd_-CeVnQzOV.mjs → _prd_-C-Aj4fVa.mjs} +75 -33
- package/.output/server/chunks/build/_prd_-C-Aj4fVa.mjs.map +1 -0
- package/.output/server/chunks/build/client.precomputed.mjs +1 -1
- package/.output/server/chunks/build/{default-DWCOHHTE.mjs → default-Cao5eO80.mjs} +4 -3
- package/.output/server/chunks/build/default-Cao5eO80.mjs.map +1 -0
- package/.output/server/chunks/build/error-404-Bf6kdO80.mjs +2 -1
- package/.output/server/chunks/build/error-500-D_bcARXN.mjs +2 -1
- package/.output/server/chunks/build/{index-CckL_NBD.mjs → index-ByZO4Bvq.mjs} +2 -2
- package/.output/server/chunks/build/index-ByZO4Bvq.mjs.map +1 -0
- package/.output/server/chunks/build/{index-QVeSHT3L.mjs → index-ljj9uTXI.mjs} +8 -5
- package/.output/server/chunks/build/index-ljj9uTXI.mjs.map +1 -0
- package/.output/server/chunks/build/nuxt-link-SvT1nf8Z.mjs +1 -1
- package/.output/server/chunks/build/{repo-graph-CHNl58mY.mjs → repo-graph-EuhMeFt7.mjs} +25 -10
- package/.output/server/chunks/build/repo-graph-EuhMeFt7.mjs.map +1 -0
- package/.output/server/chunks/build/server.mjs +7 -6
- package/.output/server/chunks/build/styles.mjs +4 -4
- package/.output/server/chunks/build/{usePrd-SqcxGyFU.mjs → usePrd-f7ylhIqs.mjs} +10 -34
- package/.output/server/chunks/build/usePrd-f7ylhIqs.mjs.map +1 -0
- package/.output/server/chunks/nitro/nitro.mjs +1106 -677
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/browse.get.mjs +12 -6
- package/.output/server/chunks/routes/api/browse.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/index.get.mjs +2 -1
- package/.output/server/chunks/routes/api/index.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/index.post.mjs +3 -2
- package/.output/server/chunks/routes/api/index.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/git/commits.get.mjs +11 -13
- package/.output/server/chunks/routes/api/repos/_repoId/git/commits.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/git/diff.get.mjs +11 -6
- package/.output/server/chunks/routes/api/repos/_repoId/git/diff.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/git/file-content.get.mjs +31 -12
- package/.output/server/chunks/routes/api/repos/_repoId/git/file-content.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/git/file-diff.get.mjs +13 -13
- package/.output/server/chunks/routes/api/repos/_repoId/git/file-diff.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/graph.get.mjs +5 -1
- package/.output/server/chunks/routes/api/repos/_repoId/graph.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/graph.get.mjs +14 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/graph.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/progress.get.mjs +20 -9
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/progress.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/tasks/_taskId/commits.get.mjs +20 -85
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/tasks/_taskId/commits.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/tasks.get.mjs +20 -9
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug/tasks.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug_.get.mjs +30 -50
- package/.output/server/chunks/routes/api/repos/_repoId/prd/_prdSlug_.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/prds.get.mjs +19 -49
- package/.output/server/chunks/routes/api/repos/_repoId/prds.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId/refresh-git-repos.post.mjs +6 -13
- package/.output/server/chunks/routes/api/repos/_repoId/refresh-git-repos.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repos/_repoId_.delete.mjs +2 -1
- package/.output/server/chunks/routes/api/repos/_repoId_.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/runtime.get.mjs +3 -2
- package/.output/server/chunks/routes/api/runtime.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/watch.get.mjs +5 -4
- package/.output/server/chunks/routes/api/watch.get.mjs.map +1 -1
- package/.output/server/chunks/routes/renderer.mjs +1 -1
- package/.output/server/index.mjs +3 -2
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/zod/index.js +4 -0
- package/.output/server/node_modules/zod/package.json +118 -0
- package/.output/server/node_modules/zod/v3/ZodError.js +133 -0
- package/.output/server/node_modules/zod/v3/errors.js +9 -0
- package/.output/server/node_modules/zod/v3/external.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/.output/server/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/.output/server/node_modules/zod/v3/helpers/util.js +133 -0
- package/.output/server/node_modules/zod/v3/locales/en.js +109 -0
- package/.output/server/node_modules/zod/v3/types.js +3693 -0
- package/.output/server/package.json +2 -1
- package/README.md +7 -2
- package/dist/host/src/api/prds.js +6 -172
- package/dist/host/src/api/repos.js +3 -16
- package/dist/host/src/api/state.js +7 -2
- package/dist/host/src/executor-runner.js +368 -0
- package/dist/host/src/executor.js +138 -260
- package/dist/host/src/index.js +7 -2
- package/dist/host/src/mcp.js +27 -1
- package/dist/host/src/ui.js +18 -3
- package/dist/server/utils/change-events.js +33 -0
- package/dist/server/utils/git.js +11 -16
- package/dist/server/utils/prd-service.js +235 -0
- package/dist/server/utils/prd-state.js +57 -45
- package/dist/server/utils/repos.js +58 -13
- package/dist/server/utils/state-schema.js +61 -0
- package/dist/server/utils/task-graph.js +2 -2
- package/package.json +2 -1
- package/.output/public/_nuxt/CVJh28bx.js +0 -1
- package/.output/public/_nuxt/CyZuidLG.js +0 -60
- package/.output/public/_nuxt/D0op9E2g.js +0 -1
- package/.output/public/_nuxt/DX8awZaa.js +0 -1
- package/.output/public/_nuxt/Detail.z33AHKev.css +0 -1
- package/.output/public/_nuxt/DiTJUZOC.js +0 -1
- package/.output/public/_nuxt/T_3JE9C-.js +0 -1
- package/.output/public/_nuxt/WOI2tLsR.js +0 -42
- package/.output/public/_nuxt/_prd_.KTotLoF_.css +0 -1
- package/.output/public/_nuxt/builds/meta/029070b0-b8e2-4988-84f4-d0c9ff55c998.json +0 -1
- package/.output/public/_nuxt/odRGDGwj.js +0 -1
- package/.output/server/chunks/build/Detail-CUfU85GY.mjs.map +0 -1
- package/.output/server/chunks/build/DiffViewer-styles-1.mjs-CS8FTppg.mjs +0 -4
- package/.output/server/chunks/build/DiffViewer-styles-1.mjs-CS8FTppg.mjs.map +0 -1
- package/.output/server/chunks/build/DiffViewer-styles.AUfwwelI.mjs +0 -10
- package/.output/server/chunks/build/DiffViewer-styles.AUfwwelI.mjs.map +0 -1
- package/.output/server/chunks/build/DiffViewer-styles.D_it8zfk.mjs +0 -8
- package/.output/server/chunks/build/DiffViewer-styles.D_it8zfk.mjs.map +0 -1
- package/.output/server/chunks/build/Viewer-styles.CshnetGw.mjs +0 -8
- package/.output/server/chunks/build/Viewer-styles.CshnetGw.mjs.map +0 -1
- package/.output/server/chunks/build/_prd_-CeVnQzOV.mjs.map +0 -1
- package/.output/server/chunks/build/default-DWCOHHTE.mjs.map +0 -1
- package/.output/server/chunks/build/index-CckL_NBD.mjs.map +0 -1
- package/.output/server/chunks/build/index-QVeSHT3L.mjs.map +0 -1
- package/.output/server/chunks/build/repo-graph-CHNl58mY.mjs.map +0 -1
- package/.output/server/chunks/build/usePrd-SqcxGyFU.mjs.map +0 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zod",
|
|
3
|
+
"version": "3.25.76",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"author": "Colin McDonnell <zod@colinhacks.com>",
|
|
6
|
+
"description": "TypeScript-first schema declaration and validation library with static type inference",
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"**/*.js",
|
|
10
|
+
"**/*.mjs",
|
|
11
|
+
"**/*.cjs",
|
|
12
|
+
"**/*.d.ts",
|
|
13
|
+
"**/*.d.mts",
|
|
14
|
+
"**/*.d.cts"
|
|
15
|
+
],
|
|
16
|
+
"funding": "https://github.com/sponsors/colinhacks",
|
|
17
|
+
"homepage": "https://zod.dev",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"typescript",
|
|
20
|
+
"schema",
|
|
21
|
+
"validation",
|
|
22
|
+
"type",
|
|
23
|
+
"inference"
|
|
24
|
+
],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "./index.cjs",
|
|
28
|
+
"types": "./index.d.cts",
|
|
29
|
+
"module": "./index.js",
|
|
30
|
+
"zshy": {
|
|
31
|
+
"exports": {
|
|
32
|
+
"./package.json": "./package.json",
|
|
33
|
+
".": "./src/index.ts",
|
|
34
|
+
"./v3": "./src/v3/index.ts",
|
|
35
|
+
"./v4": "./src/v4/index.ts",
|
|
36
|
+
"./v4-mini": "./src/v4-mini/index.ts",
|
|
37
|
+
"./v4/mini": "./src/v4/mini/index.ts",
|
|
38
|
+
"./v4/core": "./src/v4/core/index.ts",
|
|
39
|
+
"./v4/locales": "./src/v4/locales/index.ts",
|
|
40
|
+
"./v4/locales/*": "./src/v4/locales/*"
|
|
41
|
+
},
|
|
42
|
+
"sourceDialects": [
|
|
43
|
+
"@zod/source"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"exports": {
|
|
47
|
+
"./package.json": "./package.json",
|
|
48
|
+
".": {
|
|
49
|
+
"@zod/source": "./src/index.ts",
|
|
50
|
+
"types": "./index.d.cts",
|
|
51
|
+
"import": "./index.js",
|
|
52
|
+
"require": "./index.cjs"
|
|
53
|
+
},
|
|
54
|
+
"./v3": {
|
|
55
|
+
"@zod/source": "./src/v3/index.ts",
|
|
56
|
+
"types": "./v3/index.d.cts",
|
|
57
|
+
"import": "./v3/index.js",
|
|
58
|
+
"require": "./v3/index.cjs"
|
|
59
|
+
},
|
|
60
|
+
"./v4": {
|
|
61
|
+
"@zod/source": "./src/v4/index.ts",
|
|
62
|
+
"types": "./v4/index.d.cts",
|
|
63
|
+
"import": "./v4/index.js",
|
|
64
|
+
"require": "./v4/index.cjs"
|
|
65
|
+
},
|
|
66
|
+
"./v4-mini": {
|
|
67
|
+
"@zod/source": "./src/v4-mini/index.ts",
|
|
68
|
+
"types": "./v4-mini/index.d.cts",
|
|
69
|
+
"import": "./v4-mini/index.js",
|
|
70
|
+
"require": "./v4-mini/index.cjs"
|
|
71
|
+
},
|
|
72
|
+
"./v4/mini": {
|
|
73
|
+
"@zod/source": "./src/v4/mini/index.ts",
|
|
74
|
+
"types": "./v4/mini/index.d.cts",
|
|
75
|
+
"import": "./v4/mini/index.js",
|
|
76
|
+
"require": "./v4/mini/index.cjs"
|
|
77
|
+
},
|
|
78
|
+
"./v4/core": {
|
|
79
|
+
"@zod/source": "./src/v4/core/index.ts",
|
|
80
|
+
"types": "./v4/core/index.d.cts",
|
|
81
|
+
"import": "./v4/core/index.js",
|
|
82
|
+
"require": "./v4/core/index.cjs"
|
|
83
|
+
},
|
|
84
|
+
"./v4/locales": {
|
|
85
|
+
"@zod/source": "./src/v4/locales/index.ts",
|
|
86
|
+
"types": "./v4/locales/index.d.cts",
|
|
87
|
+
"import": "./v4/locales/index.js",
|
|
88
|
+
"require": "./v4/locales/index.cjs"
|
|
89
|
+
},
|
|
90
|
+
"./v4/locales/*": {
|
|
91
|
+
"@zod/source": "./src/v4/locales/*",
|
|
92
|
+
"types": "./v4/locales/*",
|
|
93
|
+
"import": "./v4/locales/*",
|
|
94
|
+
"require": "./v4/locales/*"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"repository": {
|
|
98
|
+
"type": "git",
|
|
99
|
+
"url": "git+https://github.com/colinhacks/zod.git"
|
|
100
|
+
},
|
|
101
|
+
"bugs": {
|
|
102
|
+
"url": "https://github.com/colinhacks/zod/issues"
|
|
103
|
+
},
|
|
104
|
+
"support": {
|
|
105
|
+
"backing": {
|
|
106
|
+
"npm-funding": true
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"scripts": {
|
|
110
|
+
"clean": "git clean -xdf . -e node_modules",
|
|
111
|
+
"build": "zshy --project tsconfig.build.json",
|
|
112
|
+
"postbuild": "pnpm biome check --write .",
|
|
113
|
+
"test:watch": "pnpm vitest",
|
|
114
|
+
"test": "pnpm vitest run",
|
|
115
|
+
"bump:beta": "pnpm version \"v$(pnpm pkg get version | jq -r)-beta.$(date +%Y%m%dT%H%M%S)\"",
|
|
116
|
+
"pub:beta": "pnpm bump:beta && pnpm publish --tag next --publish-branch v4 --no-git-checks --dry-run"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { util } from "./helpers/util.js";
|
|
2
|
+
export const ZodIssueCode = util.arrayToEnum([
|
|
3
|
+
"invalid_type",
|
|
4
|
+
"invalid_literal",
|
|
5
|
+
"custom",
|
|
6
|
+
"invalid_union",
|
|
7
|
+
"invalid_union_discriminator",
|
|
8
|
+
"invalid_enum_value",
|
|
9
|
+
"unrecognized_keys",
|
|
10
|
+
"invalid_arguments",
|
|
11
|
+
"invalid_return_type",
|
|
12
|
+
"invalid_date",
|
|
13
|
+
"invalid_string",
|
|
14
|
+
"too_small",
|
|
15
|
+
"too_big",
|
|
16
|
+
"invalid_intersection_types",
|
|
17
|
+
"not_multiple_of",
|
|
18
|
+
"not_finite",
|
|
19
|
+
]);
|
|
20
|
+
export const quotelessJson = (obj) => {
|
|
21
|
+
const json = JSON.stringify(obj, null, 2);
|
|
22
|
+
return json.replace(/"([^"]+)":/g, "$1:");
|
|
23
|
+
};
|
|
24
|
+
export class ZodError extends Error {
|
|
25
|
+
get errors() {
|
|
26
|
+
return this.issues;
|
|
27
|
+
}
|
|
28
|
+
constructor(issues) {
|
|
29
|
+
super();
|
|
30
|
+
this.issues = [];
|
|
31
|
+
this.addIssue = (sub) => {
|
|
32
|
+
this.issues = [...this.issues, sub];
|
|
33
|
+
};
|
|
34
|
+
this.addIssues = (subs = []) => {
|
|
35
|
+
this.issues = [...this.issues, ...subs];
|
|
36
|
+
};
|
|
37
|
+
const actualProto = new.target.prototype;
|
|
38
|
+
if (Object.setPrototypeOf) {
|
|
39
|
+
// eslint-disable-next-line ban/ban
|
|
40
|
+
Object.setPrototypeOf(this, actualProto);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.__proto__ = actualProto;
|
|
44
|
+
}
|
|
45
|
+
this.name = "ZodError";
|
|
46
|
+
this.issues = issues;
|
|
47
|
+
}
|
|
48
|
+
format(_mapper) {
|
|
49
|
+
const mapper = _mapper ||
|
|
50
|
+
function (issue) {
|
|
51
|
+
return issue.message;
|
|
52
|
+
};
|
|
53
|
+
const fieldErrors = { _errors: [] };
|
|
54
|
+
const processError = (error) => {
|
|
55
|
+
for (const issue of error.issues) {
|
|
56
|
+
if (issue.code === "invalid_union") {
|
|
57
|
+
issue.unionErrors.map(processError);
|
|
58
|
+
}
|
|
59
|
+
else if (issue.code === "invalid_return_type") {
|
|
60
|
+
processError(issue.returnTypeError);
|
|
61
|
+
}
|
|
62
|
+
else if (issue.code === "invalid_arguments") {
|
|
63
|
+
processError(issue.argumentsError);
|
|
64
|
+
}
|
|
65
|
+
else if (issue.path.length === 0) {
|
|
66
|
+
fieldErrors._errors.push(mapper(issue));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
let curr = fieldErrors;
|
|
70
|
+
let i = 0;
|
|
71
|
+
while (i < issue.path.length) {
|
|
72
|
+
const el = issue.path[i];
|
|
73
|
+
const terminal = i === issue.path.length - 1;
|
|
74
|
+
if (!terminal) {
|
|
75
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
76
|
+
// if (typeof el === "string") {
|
|
77
|
+
// curr[el] = curr[el] || { _errors: [] };
|
|
78
|
+
// } else if (typeof el === "number") {
|
|
79
|
+
// const errorArray: any = [];
|
|
80
|
+
// errorArray._errors = [];
|
|
81
|
+
// curr[el] = curr[el] || errorArray;
|
|
82
|
+
// }
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
86
|
+
curr[el]._errors.push(mapper(issue));
|
|
87
|
+
}
|
|
88
|
+
curr = curr[el];
|
|
89
|
+
i++;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
processError(this);
|
|
95
|
+
return fieldErrors;
|
|
96
|
+
}
|
|
97
|
+
static assert(value) {
|
|
98
|
+
if (!(value instanceof ZodError)) {
|
|
99
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
toString() {
|
|
103
|
+
return this.message;
|
|
104
|
+
}
|
|
105
|
+
get message() {
|
|
106
|
+
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
107
|
+
}
|
|
108
|
+
get isEmpty() {
|
|
109
|
+
return this.issues.length === 0;
|
|
110
|
+
}
|
|
111
|
+
flatten(mapper = (issue) => issue.message) {
|
|
112
|
+
const fieldErrors = {};
|
|
113
|
+
const formErrors = [];
|
|
114
|
+
for (const sub of this.issues) {
|
|
115
|
+
if (sub.path.length > 0) {
|
|
116
|
+
const firstEl = sub.path[0];
|
|
117
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
118
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
formErrors.push(mapper(sub));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { formErrors, fieldErrors };
|
|
125
|
+
}
|
|
126
|
+
get formErrors() {
|
|
127
|
+
return this.flatten();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
ZodError.create = (issues) => {
|
|
131
|
+
const error = new ZodError(issues);
|
|
132
|
+
return error;
|
|
133
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var errorUtil;
|
|
2
|
+
(function (errorUtil) {
|
|
3
|
+
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
4
|
+
// biome-ignore lint:
|
|
5
|
+
errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
6
|
+
})(errorUtil || (errorUtil = {}));
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { getErrorMap } from "../errors.js";
|
|
2
|
+
import defaultErrorMap from "../locales/en.js";
|
|
3
|
+
export const makeIssue = (params) => {
|
|
4
|
+
const { data, path, errorMaps, issueData } = params;
|
|
5
|
+
const fullPath = [...path, ...(issueData.path || [])];
|
|
6
|
+
const fullIssue = {
|
|
7
|
+
...issueData,
|
|
8
|
+
path: fullPath,
|
|
9
|
+
};
|
|
10
|
+
if (issueData.message !== undefined) {
|
|
11
|
+
return {
|
|
12
|
+
...issueData,
|
|
13
|
+
path: fullPath,
|
|
14
|
+
message: issueData.message,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
let errorMessage = "";
|
|
18
|
+
const maps = errorMaps
|
|
19
|
+
.filter((m) => !!m)
|
|
20
|
+
.slice()
|
|
21
|
+
.reverse();
|
|
22
|
+
for (const map of maps) {
|
|
23
|
+
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
...issueData,
|
|
27
|
+
path: fullPath,
|
|
28
|
+
message: errorMessage,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export const EMPTY_PATH = [];
|
|
32
|
+
export function addIssueToContext(ctx, issueData) {
|
|
33
|
+
const overrideMap = getErrorMap();
|
|
34
|
+
const issue = makeIssue({
|
|
35
|
+
issueData: issueData,
|
|
36
|
+
data: ctx.data,
|
|
37
|
+
path: ctx.path,
|
|
38
|
+
errorMaps: [
|
|
39
|
+
ctx.common.contextualErrorMap, // contextual error map is first priority
|
|
40
|
+
ctx.schemaErrorMap, // then schema-bound map if available
|
|
41
|
+
overrideMap, // then global override map
|
|
42
|
+
overrideMap === defaultErrorMap ? undefined : defaultErrorMap, // then global default map
|
|
43
|
+
].filter((x) => !!x),
|
|
44
|
+
});
|
|
45
|
+
ctx.common.issues.push(issue);
|
|
46
|
+
}
|
|
47
|
+
export class ParseStatus {
|
|
48
|
+
constructor() {
|
|
49
|
+
this.value = "valid";
|
|
50
|
+
}
|
|
51
|
+
dirty() {
|
|
52
|
+
if (this.value === "valid")
|
|
53
|
+
this.value = "dirty";
|
|
54
|
+
}
|
|
55
|
+
abort() {
|
|
56
|
+
if (this.value !== "aborted")
|
|
57
|
+
this.value = "aborted";
|
|
58
|
+
}
|
|
59
|
+
static mergeArray(status, results) {
|
|
60
|
+
const arrayValue = [];
|
|
61
|
+
for (const s of results) {
|
|
62
|
+
if (s.status === "aborted")
|
|
63
|
+
return INVALID;
|
|
64
|
+
if (s.status === "dirty")
|
|
65
|
+
status.dirty();
|
|
66
|
+
arrayValue.push(s.value);
|
|
67
|
+
}
|
|
68
|
+
return { status: status.value, value: arrayValue };
|
|
69
|
+
}
|
|
70
|
+
static async mergeObjectAsync(status, pairs) {
|
|
71
|
+
const syncPairs = [];
|
|
72
|
+
for (const pair of pairs) {
|
|
73
|
+
const key = await pair.key;
|
|
74
|
+
const value = await pair.value;
|
|
75
|
+
syncPairs.push({
|
|
76
|
+
key,
|
|
77
|
+
value,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
81
|
+
}
|
|
82
|
+
static mergeObjectSync(status, pairs) {
|
|
83
|
+
const finalObject = {};
|
|
84
|
+
for (const pair of pairs) {
|
|
85
|
+
const { key, value } = pair;
|
|
86
|
+
if (key.status === "aborted")
|
|
87
|
+
return INVALID;
|
|
88
|
+
if (value.status === "aborted")
|
|
89
|
+
return INVALID;
|
|
90
|
+
if (key.status === "dirty")
|
|
91
|
+
status.dirty();
|
|
92
|
+
if (value.status === "dirty")
|
|
93
|
+
status.dirty();
|
|
94
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
95
|
+
finalObject[key.value] = value.value;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return { status: status.value, value: finalObject };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export const INVALID = Object.freeze({
|
|
102
|
+
status: "aborted",
|
|
103
|
+
});
|
|
104
|
+
export const DIRTY = (value) => ({ status: "dirty", value });
|
|
105
|
+
export const OK = (value) => ({ status: "valid", value });
|
|
106
|
+
export const isAborted = (x) => x.status === "aborted";
|
|
107
|
+
export const isDirty = (x) => x.status === "dirty";
|
|
108
|
+
export const isValid = (x) => x.status === "valid";
|
|
109
|
+
export const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export var util;
|
|
2
|
+
(function (util) {
|
|
3
|
+
util.assertEqual = (_) => { };
|
|
4
|
+
function assertIs(_arg) { }
|
|
5
|
+
util.assertIs = assertIs;
|
|
6
|
+
function assertNever(_x) {
|
|
7
|
+
throw new Error();
|
|
8
|
+
}
|
|
9
|
+
util.assertNever = assertNever;
|
|
10
|
+
util.arrayToEnum = (items) => {
|
|
11
|
+
const obj = {};
|
|
12
|
+
for (const item of items) {
|
|
13
|
+
obj[item] = item;
|
|
14
|
+
}
|
|
15
|
+
return obj;
|
|
16
|
+
};
|
|
17
|
+
util.getValidEnumValues = (obj) => {
|
|
18
|
+
const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
19
|
+
const filtered = {};
|
|
20
|
+
for (const k of validKeys) {
|
|
21
|
+
filtered[k] = obj[k];
|
|
22
|
+
}
|
|
23
|
+
return util.objectValues(filtered);
|
|
24
|
+
};
|
|
25
|
+
util.objectValues = (obj) => {
|
|
26
|
+
return util.objectKeys(obj).map(function (e) {
|
|
27
|
+
return obj[e];
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
|
|
31
|
+
? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
|
|
32
|
+
: (object) => {
|
|
33
|
+
const keys = [];
|
|
34
|
+
for (const key in object) {
|
|
35
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
36
|
+
keys.push(key);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return keys;
|
|
40
|
+
};
|
|
41
|
+
util.find = (arr, checker) => {
|
|
42
|
+
for (const item of arr) {
|
|
43
|
+
if (checker(item))
|
|
44
|
+
return item;
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
};
|
|
48
|
+
util.isInteger = typeof Number.isInteger === "function"
|
|
49
|
+
? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
|
|
50
|
+
: (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
51
|
+
function joinValues(array, separator = " | ") {
|
|
52
|
+
return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
|
|
53
|
+
}
|
|
54
|
+
util.joinValues = joinValues;
|
|
55
|
+
util.jsonStringifyReplacer = (_, value) => {
|
|
56
|
+
if (typeof value === "bigint") {
|
|
57
|
+
return value.toString();
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
};
|
|
61
|
+
})(util || (util = {}));
|
|
62
|
+
export var objectUtil;
|
|
63
|
+
(function (objectUtil) {
|
|
64
|
+
objectUtil.mergeShapes = (first, second) => {
|
|
65
|
+
return {
|
|
66
|
+
...first,
|
|
67
|
+
...second, // second overwrites first
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
})(objectUtil || (objectUtil = {}));
|
|
71
|
+
export const ZodParsedType = util.arrayToEnum([
|
|
72
|
+
"string",
|
|
73
|
+
"nan",
|
|
74
|
+
"number",
|
|
75
|
+
"integer",
|
|
76
|
+
"float",
|
|
77
|
+
"boolean",
|
|
78
|
+
"date",
|
|
79
|
+
"bigint",
|
|
80
|
+
"symbol",
|
|
81
|
+
"function",
|
|
82
|
+
"undefined",
|
|
83
|
+
"null",
|
|
84
|
+
"array",
|
|
85
|
+
"object",
|
|
86
|
+
"unknown",
|
|
87
|
+
"promise",
|
|
88
|
+
"void",
|
|
89
|
+
"never",
|
|
90
|
+
"map",
|
|
91
|
+
"set",
|
|
92
|
+
]);
|
|
93
|
+
export const getParsedType = (data) => {
|
|
94
|
+
const t = typeof data;
|
|
95
|
+
switch (t) {
|
|
96
|
+
case "undefined":
|
|
97
|
+
return ZodParsedType.undefined;
|
|
98
|
+
case "string":
|
|
99
|
+
return ZodParsedType.string;
|
|
100
|
+
case "number":
|
|
101
|
+
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
102
|
+
case "boolean":
|
|
103
|
+
return ZodParsedType.boolean;
|
|
104
|
+
case "function":
|
|
105
|
+
return ZodParsedType.function;
|
|
106
|
+
case "bigint":
|
|
107
|
+
return ZodParsedType.bigint;
|
|
108
|
+
case "symbol":
|
|
109
|
+
return ZodParsedType.symbol;
|
|
110
|
+
case "object":
|
|
111
|
+
if (Array.isArray(data)) {
|
|
112
|
+
return ZodParsedType.array;
|
|
113
|
+
}
|
|
114
|
+
if (data === null) {
|
|
115
|
+
return ZodParsedType.null;
|
|
116
|
+
}
|
|
117
|
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
|
118
|
+
return ZodParsedType.promise;
|
|
119
|
+
}
|
|
120
|
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
121
|
+
return ZodParsedType.map;
|
|
122
|
+
}
|
|
123
|
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
124
|
+
return ZodParsedType.set;
|
|
125
|
+
}
|
|
126
|
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
127
|
+
return ZodParsedType.date;
|
|
128
|
+
}
|
|
129
|
+
return ZodParsedType.object;
|
|
130
|
+
default:
|
|
131
|
+
return ZodParsedType.unknown;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ZodIssueCode } from "../ZodError.js";
|
|
2
|
+
import { util, ZodParsedType } from "../helpers/util.js";
|
|
3
|
+
const errorMap = (issue, _ctx) => {
|
|
4
|
+
let message;
|
|
5
|
+
switch (issue.code) {
|
|
6
|
+
case ZodIssueCode.invalid_type:
|
|
7
|
+
if (issue.received === ZodParsedType.undefined) {
|
|
8
|
+
message = "Required";
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
12
|
+
}
|
|
13
|
+
break;
|
|
14
|
+
case ZodIssueCode.invalid_literal:
|
|
15
|
+
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
|
|
16
|
+
break;
|
|
17
|
+
case ZodIssueCode.unrecognized_keys:
|
|
18
|
+
message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
|
|
19
|
+
break;
|
|
20
|
+
case ZodIssueCode.invalid_union:
|
|
21
|
+
message = `Invalid input`;
|
|
22
|
+
break;
|
|
23
|
+
case ZodIssueCode.invalid_union_discriminator:
|
|
24
|
+
message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
|
|
25
|
+
break;
|
|
26
|
+
case ZodIssueCode.invalid_enum_value:
|
|
27
|
+
message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
|
|
28
|
+
break;
|
|
29
|
+
case ZodIssueCode.invalid_arguments:
|
|
30
|
+
message = `Invalid function arguments`;
|
|
31
|
+
break;
|
|
32
|
+
case ZodIssueCode.invalid_return_type:
|
|
33
|
+
message = `Invalid function return type`;
|
|
34
|
+
break;
|
|
35
|
+
case ZodIssueCode.invalid_date:
|
|
36
|
+
message = `Invalid date`;
|
|
37
|
+
break;
|
|
38
|
+
case ZodIssueCode.invalid_string:
|
|
39
|
+
if (typeof issue.validation === "object") {
|
|
40
|
+
if ("includes" in issue.validation) {
|
|
41
|
+
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
42
|
+
if (typeof issue.validation.position === "number") {
|
|
43
|
+
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if ("startsWith" in issue.validation) {
|
|
47
|
+
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
48
|
+
}
|
|
49
|
+
else if ("endsWith" in issue.validation) {
|
|
50
|
+
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
util.assertNever(issue.validation);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (issue.validation !== "regex") {
|
|
57
|
+
message = `Invalid ${issue.validation}`;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
message = "Invalid";
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case ZodIssueCode.too_small:
|
|
64
|
+
if (issue.type === "array")
|
|
65
|
+
message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
66
|
+
else if (issue.type === "string")
|
|
67
|
+
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
68
|
+
else if (issue.type === "number")
|
|
69
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
70
|
+
else if (issue.type === "bigint")
|
|
71
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
72
|
+
else if (issue.type === "date")
|
|
73
|
+
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
74
|
+
else
|
|
75
|
+
message = "Invalid input";
|
|
76
|
+
break;
|
|
77
|
+
case ZodIssueCode.too_big:
|
|
78
|
+
if (issue.type === "array")
|
|
79
|
+
message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
80
|
+
else if (issue.type === "string")
|
|
81
|
+
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
82
|
+
else if (issue.type === "number")
|
|
83
|
+
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
84
|
+
else if (issue.type === "bigint")
|
|
85
|
+
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
86
|
+
else if (issue.type === "date")
|
|
87
|
+
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
88
|
+
else
|
|
89
|
+
message = "Invalid input";
|
|
90
|
+
break;
|
|
91
|
+
case ZodIssueCode.custom:
|
|
92
|
+
message = `Invalid input`;
|
|
93
|
+
break;
|
|
94
|
+
case ZodIssueCode.invalid_intersection_types:
|
|
95
|
+
message = `Intersection results could not be merged`;
|
|
96
|
+
break;
|
|
97
|
+
case ZodIssueCode.not_multiple_of:
|
|
98
|
+
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
99
|
+
break;
|
|
100
|
+
case ZodIssueCode.not_finite:
|
|
101
|
+
message = "Number must be finite";
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
message = _ctx.defaultError;
|
|
105
|
+
util.assertNever(issue);
|
|
106
|
+
}
|
|
107
|
+
return { message };
|
|
108
|
+
};
|
|
109
|
+
export default errorMap;
|