better-supabase 0.2.0 → 0.4.0
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/README.md +37 -33
- package/dist/base64-D2gsioCY.js +42 -0
- package/dist/claims-BAf6c7is.js +48 -0
- package/dist/cli/_format-Cax5EsM9.js +101 -0
- package/dist/cli/bin.js +39 -6
- package/dist/cli/command-CK14fP91.js +502 -0
- package/dist/cli/compare-BmIWVEui.js +9 -0
- package/dist/cli/config-D9R0o1LH.js +1895 -0
- package/dist/cli/config-SSKSTUl2.js +2 -0
- package/dist/cli/db-DOBPt660.js +52 -0
- package/dist/cli/dist-B1MvLv-M.js +129 -0
- package/dist/cli/dist-CFgGknmZ.js +1112 -0
- package/dist/cli/dist-Du7VnEUG.js +621 -0
- package/dist/cli/doctor-BOym3mbL.js +2382 -0
- package/dist/cli/env-BZ0uy8XK.js +108 -0
- package/dist/cli/env-jIFUADLY.js +511 -0
- package/dist/cli/errors-4v4DTtda.js +56 -0
- package/dist/cli/fastest-levenshtein-CFN-lNDv.js +120 -0
- package/dist/cli/gen-Ccn_p90L.js +2008 -0
- package/dist/cli/gen-D5cLCULx.js +2 -0
- package/dist/cli/index.d.ts +295 -28
- package/dist/cli/index.js +184 -3
- package/dist/cli/init-ClnxRYBF.js +550 -0
- package/dist/cli/introspect-DxqfkVIv.js +81 -0
- package/dist/cli/io-k41_z-jT.js +24 -0
- package/dist/cli/json5-ChRycquj.js +787 -0
- package/dist/cli/jsonc-BUniUpOk.js +2 -0
- package/dist/cli/jsonc-D5Fu67jw.js +45 -0
- package/dist/cli/keys-ByKHnvP9.js +83 -0
- package/dist/cli/ohash-D7bG_EOb.js +277 -0
- package/dist/cli/openapi-8WHjxiTJ.js +66 -0
- package/dist/cli/project-B_GeXyHh.js +70 -0
- package/dist/cli/prompts-BNcNfAve.js +1142 -0
- package/dist/cli/prompts-BTYQGunc.js +2 -0
- package/dist/cli/read-sets-CMa29t9a.js +971 -0
- package/dist/cli/rolldown-runtime-BPOCksWG.js +24 -0
- package/dist/cli/run-CP20LKk_.js +347 -0
- package/dist/cli/seed-5J6eu_Xg.js +98 -0
- package/dist/cli/skills-LJJIhLFR.js +137 -0
- package/dist/cli/sql-D4VbqmXi.js +199 -0
- package/dist/cli/style-C0NFdJRL.js +29 -0
- package/dist/cli/toml-DB-MNnFs.js +424 -0
- package/dist/{version-Cqq1m3UY.js → cli/version-5mW_8sY1.js} +1 -1
- package/dist/cli/yaml-CYCbJ6et.js +2252 -0
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +15 -25
- package/dist/{compiler-CZ9nIuqy.d.ts → compiler-DB3aSFOA.d.ts} +2 -2
- package/dist/config/index.d.ts +4 -3
- package/dist/config/index.js +5 -3
- package/dist/config-BpxDfnbg.js +129 -0
- package/dist/{index-DOsjFvMf.d.ts → config-C1CYcm6o.d.ts} +49 -49
- package/dist/{config-ClDXmVtY.js → config-CbvFmGD8.js} +14 -137
- package/dist/{define-BXMYD9AY.js → define-Bh0AqTik.js} +221 -120
- package/dist/{define-e3zI4_4g.d.ts → define-CRS2MRV3.d.ts} +36 -31
- package/dist/edge/index.d.ts +9 -13
- package/dist/edge/index.js +51 -25
- package/dist/{entitlements-Dng-ctuT.d.ts → entitlements-Dm-FHpNH.d.ts} +2 -2
- package/dist/env/index.js +203 -1
- package/dist/{errors-Bl3rkOzo.js → errors-L0xK41y_.js} +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +139 -1
- package/dist/{events-DOt3nSO-.d.ts → events-B21UOhvP.d.ts} +4 -4
- package/dist/{executor-CGdNQ27g.d.ts → executor-B5IoUxLE.d.ts} +2 -2
- package/dist/{executor-DeppvirK.js → executor-CVt6dD0B.js} +9 -4
- package/dist/{executor-BYXQ9AGn.d.ts → executor-CZ7ImRiD.d.ts} +2 -2
- package/dist/hono/index.d.ts +17 -24
- package/dist/hono/index.js +11 -11
- package/dist/{index-DuP14VHo.d.ts → index-528Ugmyp.d.ts} +30 -10
- package/dist/{index-Bw1bwtC0.d.ts → index-BAy4tsAP.d.ts} +28 -15
- package/dist/{index-CBDufH1M.d.ts → index-BBdvo-5d.d.ts} +24 -26
- package/dist/{index-DbxFr7XG.d.ts → index-BhHEC04r.d.ts} +9 -4
- package/dist/index-Cf-D2jk1.d.ts +50 -0
- package/dist/{index-Ciu5Xlml.d.ts → index-D5IfUIDh.d.ts} +6 -5
- package/dist/{index-K-3WM2Hp.d.ts → index-DFmOpBGC.d.ts} +13 -13
- package/dist/{index-D4v7sncu.d.ts → index-RlLXd8dL.d.ts} +13 -13
- package/dist/index.d.ts +17 -17
- package/dist/index.js +23 -14
- package/dist/{invalidate-DbxuL2jL.js → invalidate-CgxmRamI.js} +7 -1
- package/dist/jobs/index.d.ts +33 -26
- package/dist/jobs/index.js +44 -22
- package/dist/{json-schema-BpYqkCKf.js → json-schema-DP6V7cbr.js} +8 -3
- package/dist/lint/index.js +1 -1
- package/dist/list/index.d.ts +2 -2
- package/dist/list/index.js +131 -96
- package/dist/{live-DJyZMD6w.d.ts → live-BHakSWWo.d.ts} +26 -16
- package/dist/{live-D8rV1Ldw.js → live-CdJBOc4f.js} +13 -9
- package/dist/lookup-BaP5bI27.js +18 -0
- package/dist/mcp/index.d.ts +34 -27
- package/dist/mcp/index.js +59 -25
- package/dist/{mfa-TVia554c.d.ts → mfa-C7MNQ1Ob.d.ts} +1 -1
- package/dist/{mfa-CpLfJSde.js → mfa-byfjruR9.js} +190 -46
- package/dist/next/image/index.js +6 -3
- package/dist/next/index.d.ts +64 -48
- package/dist/next/index.js +63 -50
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +61 -38
- package/dist/orpc/index.d.ts +18 -21
- package/dist/orpc/index.js +12 -12
- package/dist/otel/index.d.ts +5 -5
- package/dist/otel/index.js +84 -63
- package/dist/{permdock-sql-CghlHPuH.js → permdock-sql-C4KFzLc9.js} +12 -7
- package/dist/permdock-sql-DImJULY-.d.ts +17 -0
- package/dist/{plugin-C4TR9J0Z.d.ts → plugin-bNhvJwRh.d.ts} +5 -4
- package/dist/plugins/actor/index.d.ts +1 -1
- package/dist/plugins/actor/index.js +1 -1
- package/dist/plugins/rules/index.d.ts +2 -2
- package/dist/plugins/rules/index.js +46 -16
- package/dist/plugins/soft-delete/index.d.ts +3 -3
- package/dist/plugins/soft-delete/index.js +4 -4
- package/dist/plugins/tenant/index.d.ts +3 -3
- package/dist/plugins/tenant/index.js +10 -4
- package/dist/plugins/timestamps/index.d.ts +1 -1
- package/dist/plugins/timestamps/index.js +2 -2
- package/dist/plugins/validation/index.d.ts +2 -2
- package/dist/plugins/validation/index.js +3 -3
- package/dist/pool-DFwEQwmN.d.ts +78 -0
- package/dist/postgres/index.d.ts +10 -5
- package/dist/postgres/index.js +37 -16
- package/dist/{postgrest-cAEQ_IQN.d.ts → postgrest-Bc-0Xw62.d.ts} +1 -1
- package/dist/{problem-BTkTtRV9.js → problem-BihjPR0t.js} +11 -5
- package/dist/{problem-DlgB0lYl.d.ts → problem-U8UEKccv.d.ts} +6 -4
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +2 -2
- package/dist/{query-ChvDbsDE.js → query-BMMSWbI7.js} +19 -19
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +2 -2
- package/dist/react/server.d.ts +6 -6
- package/dist/react/server.js +3 -3
- package/dist/react/session.d.ts +21 -2
- package/dist/react/session.js +19 -1
- package/dist/{react-C83BdBGt.js → react-CQHMaESR.js} +59 -55
- package/dist/{read-set-4lI3W_gZ.js → read-set-FWK8qQ58.js} +51 -16
- package/dist/realtime/index.d.ts +4 -3
- package/dist/realtime/index.js +19 -17
- package/dist/{index-CG69s15v.d.ts → refresh-BwYkyNOQ.d.ts} +7 -3
- package/dist/{resolve-CjHILk2w.d.ts → resolve-BAqQcwMW.d.ts} +17 -11
- package/dist/{resource-CgZa3YG_.d.ts → resource-BJcaIfxi.d.ts} +17 -8
- package/dist/{resource-BHEWmQJK.js → resource-My_y-Syh.js} +43 -21
- package/dist/{respond-Dne1ARSa.d.ts → respond-DgIbdrt8.d.ts} +39 -14
- package/dist/{result-DWXatkd6.js → result-Bj6yt33D.js} +2 -2
- package/dist/{result-CTkCZ6JA.d.ts → result-CqEsbgYs.d.ts} +16 -11
- package/dist/server/index.d.ts +38 -13
- package/dist/server/index.js +43 -14
- package/dist/{respond-DMcbQwfN.js → server-BA75B0mT.js} +151 -96
- package/dist/{shared-_6-uPL7E.js → shared-DnoCdMDr.js} +4 -3
- package/dist/{simplify-bwJpLnaS.js → simplify-Cqvfr9dj.js} +76 -39
- package/dist/sql/index.d.ts +139 -0
- package/dist/sql/index.js +1983 -0
- package/dist/{sql-DTjA1LPj.js → sql-B34HU2DI.js} +74 -17
- package/dist/ssr/index.d.ts +4 -4
- package/dist/ssr/index.js +2 -2
- package/dist/{standard-FUi3Z3-7.js → standard-BRyBGTtp.js} +2 -2
- package/dist/{standard-CyhRzctb.d.ts → standard-BsaCYQJc.d.ts} +1 -1
- package/dist/{stats-C5W-rBfR.js → stats-C_YxA2r1.js} +40 -14
- package/dist/storage/index.d.ts +4 -3
- package/dist/storage/index.js +548 -1
- package/dist/{tables-rZxRxNPW.js → tables-Cb-3_VWc.js} +19 -5
- package/dist/temporal-BwshQk0W.js +27 -0
- package/dist/temporal-required-CBNHT6ni.js +19 -0
- package/dist/testing/index.d.ts +25 -24
- package/dist/testing/index.js +165 -66
- package/dist/{types-C83v5SQz.d.ts → types-DONv9SHN.d.ts} +14 -11
- package/dist/version-Bmf7_FzM.js +4 -0
- package/dist/{view-D1s0wa0T.d.ts → view-B64o81wp.d.ts} +36 -6
- package/dist/{view-aOYizTeE.js → view-BrJI2LKp.js} +11 -2
- package/dist/webhooks/index.d.ts +19 -17
- package/dist/webhooks/index.js +1 -1
- package/dist/{webhooks-DMipjhSP.js → webhooks-Bh_Jf_-l.js} +45 -24
- package/package.json +50 -22
- package/schemas/config-v1.json +31 -1
- package/schemas/doctor-report-v1.json +17 -1
- package/schemas/snapshot-v2.json +35 -0
- package/skills/better-supabase/SKILL.md +77 -18
- package/skills/better-supabase/references/plugins.md +21 -22
- package/skills/better-supabase/references/troubleshooting.md +38 -18
- package/skills/better-supabase-api/SKILL.md +66 -18
- package/skills/better-supabase-api/references/adapters.md +64 -41
- package/skills/better-supabase-auth/SKILL.md +146 -0
- package/skills/better-supabase-auth/references/permdock.md +55 -0
- package/skills/better-supabase-testing/SKILL.md +68 -11
- package/dist/casing-da0uRTqt.js +0 -14
- package/dist/claims-CoTobNC-.js +0 -25
- package/dist/cli-DrSgDOQC.js +0 -6646
- package/dist/env-BEToab0I.js +0 -204
- package/dist/events-BuzTgn2D.js +0 -135
- package/dist/pool-R2m_DkXi.d.ts +0 -37
- package/dist/seed-CzecODcJ.js +0 -101
- package/dist/session-C3LxnQ0e.d.ts +0 -22
- package/dist/session-CqEwzVup.js +0 -20
- package/dist/storage-DuGn38fr.js +0 -527
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
const DEFAULT_CONFIG = {
|
|
2
|
+
lang: void 0,
|
|
3
|
+
message: void 0,
|
|
4
|
+
abortEarly: void 0,
|
|
5
|
+
abortPipeEarly: void 0
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Returns the global configuration.
|
|
9
|
+
*
|
|
10
|
+
* @param config The config to merge.
|
|
11
|
+
*
|
|
12
|
+
* @returns The configuration.
|
|
13
|
+
*/
|
|
14
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
15
|
+
function getGlobalConfig(config$1) {
|
|
16
|
+
if (!config$1 && true) return DEFAULT_CONFIG;
|
|
17
|
+
return {
|
|
18
|
+
lang: config$1?.lang ?? void 0,
|
|
19
|
+
message: config$1?.message,
|
|
20
|
+
abortEarly: config$1?.abortEarly ?? void 0,
|
|
21
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? void 0
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Stringifies an unknown input to a literal or type string.
|
|
26
|
+
*
|
|
27
|
+
* @param input The unknown input.
|
|
28
|
+
*
|
|
29
|
+
* @returns A literal or type string.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
34
|
+
function _stringify(input) {
|
|
35
|
+
const type = typeof input;
|
|
36
|
+
if (type === "string") return `"${input}"`;
|
|
37
|
+
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
38
|
+
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
39
|
+
return type;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Adds an issue to the dataset.
|
|
43
|
+
*
|
|
44
|
+
* @param context The issue context.
|
|
45
|
+
* @param label The issue label.
|
|
46
|
+
* @param dataset The input dataset.
|
|
47
|
+
* @param config The configuration.
|
|
48
|
+
* @param other The optional props.
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
function _addIssue(context, label, dataset, config$1, other) {
|
|
53
|
+
const input = other && "input" in other ? other.input : dataset.value;
|
|
54
|
+
const expected = other?.expected ?? context.expects ?? null;
|
|
55
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
56
|
+
const issue = {
|
|
57
|
+
kind: context.kind,
|
|
58
|
+
type: context.type,
|
|
59
|
+
input,
|
|
60
|
+
expected,
|
|
61
|
+
received,
|
|
62
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
63
|
+
requirement: context.requirement,
|
|
64
|
+
path: other?.path,
|
|
65
|
+
issues: other?.issues,
|
|
66
|
+
lang: config$1.lang,
|
|
67
|
+
abortEarly: config$1.abortEarly,
|
|
68
|
+
abortPipeEarly: config$1.abortPipeEarly
|
|
69
|
+
};
|
|
70
|
+
const isSchema = context.kind === "schema";
|
|
71
|
+
const message$1 = other?.message ?? context.message ?? (context.reference, issue.lang, void 0) ?? (isSchema ? (issue.lang, void 0) : null) ?? config$1.message ?? (issue.lang, void 0);
|
|
72
|
+
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
73
|
+
if (isSchema) dataset.typed = false;
|
|
74
|
+
if (dataset.issues) dataset.issues.push(issue);
|
|
75
|
+
else dataset.issues = [issue];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Compares two values using the SameValueZero algorithm, which treats `NaN`
|
|
79
|
+
* as equal to itself unlike `===`.
|
|
80
|
+
*
|
|
81
|
+
* @param value1 The first value.
|
|
82
|
+
* @param value2 The second value.
|
|
83
|
+
*
|
|
84
|
+
* @returns Whether the values are equal.
|
|
85
|
+
*
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
89
|
+
function _isSameValueZero(value1, value2) {
|
|
90
|
+
return value1 === value2 || Number.isNaN(value1) && Number.isNaN(value2);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Disallows inherited object properties and prevents object prototype
|
|
94
|
+
* pollution by disallowing certain keys.
|
|
95
|
+
*
|
|
96
|
+
* @param object The object to check.
|
|
97
|
+
* @param key The key to check.
|
|
98
|
+
*
|
|
99
|
+
* @returns Whether the key is allowed.
|
|
100
|
+
*
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
104
|
+
function _isValidObjectKey(object$1, key) {
|
|
105
|
+
return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Joins multiple `expects` values with the given separator.
|
|
109
|
+
*
|
|
110
|
+
* @param values The `expects` values.
|
|
111
|
+
* @param separator The separator.
|
|
112
|
+
*
|
|
113
|
+
* @returns The joined `expects` property.
|
|
114
|
+
*
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
118
|
+
function _joinExpects(values$1, separator) {
|
|
119
|
+
const list = [...new Set(values$1)];
|
|
120
|
+
if (list.length > 1) return `(${list.join(` ${separator} `)})`;
|
|
121
|
+
return list[0] ?? "never";
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Eagerly creates and attaches the Standard Schema properties of a schema.
|
|
125
|
+
*
|
|
126
|
+
* Hint: The contextual `this` type includes the standard properties that are
|
|
127
|
+
* attached before the schema is returned.
|
|
128
|
+
*
|
|
129
|
+
* @param schema The schema to attach standard properties to.
|
|
130
|
+
*
|
|
131
|
+
* @returns The schema with standard properties attached.
|
|
132
|
+
*
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
function _standardSchema(schema) {
|
|
136
|
+
schema["~standard"] = {
|
|
137
|
+
version: 1,
|
|
138
|
+
vendor: "valibot",
|
|
139
|
+
validate: (value$1) => schema["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig())
|
|
140
|
+
};
|
|
141
|
+
return schema;
|
|
142
|
+
}
|
|
143
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
144
|
+
function getDotPath(issue) {
|
|
145
|
+
if (issue.path) {
|
|
146
|
+
let key = "";
|
|
147
|
+
for (const item of issue.path) if (typeof item.key === "string" || typeof item.key === "number") if (key) key += `.${item.key}`;
|
|
148
|
+
else key += item.key;
|
|
149
|
+
else return null;
|
|
150
|
+
return key;
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
155
|
+
function url(message$1) {
|
|
156
|
+
return {
|
|
157
|
+
kind: "validation",
|
|
158
|
+
type: "url",
|
|
159
|
+
reference: url,
|
|
160
|
+
async: false,
|
|
161
|
+
expects: null,
|
|
162
|
+
requirement(input) {
|
|
163
|
+
try {
|
|
164
|
+
if (URL.canParse) return URL.canParse(input);
|
|
165
|
+
new URL(input);
|
|
166
|
+
return true;
|
|
167
|
+
} catch {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
message: message$1,
|
|
172
|
+
"~run"(dataset, config$1) {
|
|
173
|
+
if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "URL", dataset, config$1);
|
|
174
|
+
return dataset;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Returns the fallback value of the schema.
|
|
180
|
+
*
|
|
181
|
+
* @param schema The schema to get it from.
|
|
182
|
+
* @param dataset The output dataset if available.
|
|
183
|
+
* @param config The config if available.
|
|
184
|
+
*
|
|
185
|
+
* @returns The fallback value.
|
|
186
|
+
*/
|
|
187
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
188
|
+
function getFallback(schema, dataset, config$1) {
|
|
189
|
+
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns the default value of the schema.
|
|
193
|
+
*
|
|
194
|
+
* @param schema The schema to get it from.
|
|
195
|
+
* @param dataset The input dataset if available.
|
|
196
|
+
* @param config The config if available.
|
|
197
|
+
*
|
|
198
|
+
* @returns The default value.
|
|
199
|
+
*/
|
|
200
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
201
|
+
function getDefault(schema, dataset, config$1) {
|
|
202
|
+
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
203
|
+
}
|
|
204
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
205
|
+
function array(item, message$1) {
|
|
206
|
+
return _standardSchema({
|
|
207
|
+
kind: "schema",
|
|
208
|
+
type: "array",
|
|
209
|
+
reference: array,
|
|
210
|
+
expects: "Array",
|
|
211
|
+
async: false,
|
|
212
|
+
item,
|
|
213
|
+
message: message$1,
|
|
214
|
+
"~run"(dataset, config$1) {
|
|
215
|
+
const input = dataset.value;
|
|
216
|
+
if (Array.isArray(input)) {
|
|
217
|
+
dataset.typed = true;
|
|
218
|
+
dataset.value = [];
|
|
219
|
+
for (let key = 0; key < input.length; key++) {
|
|
220
|
+
const value$1 = input[key];
|
|
221
|
+
const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
|
|
222
|
+
if (itemDataset.issues) {
|
|
223
|
+
const pathItem = {
|
|
224
|
+
type: "array",
|
|
225
|
+
origin: "value",
|
|
226
|
+
input,
|
|
227
|
+
key,
|
|
228
|
+
value: value$1
|
|
229
|
+
};
|
|
230
|
+
for (const issue of itemDataset.issues) {
|
|
231
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
232
|
+
else issue.path = [pathItem];
|
|
233
|
+
dataset.issues?.push(issue);
|
|
234
|
+
}
|
|
235
|
+
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
236
|
+
if (config$1.abortEarly) {
|
|
237
|
+
dataset.typed = false;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (!itemDataset.typed) dataset.typed = false;
|
|
242
|
+
dataset.value.push(itemDataset.value);
|
|
243
|
+
}
|
|
244
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
245
|
+
return dataset;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
250
|
+
function boolean(message$1) {
|
|
251
|
+
return _standardSchema({
|
|
252
|
+
kind: "schema",
|
|
253
|
+
type: "boolean",
|
|
254
|
+
reference: boolean,
|
|
255
|
+
expects: "boolean",
|
|
256
|
+
async: false,
|
|
257
|
+
message: message$1,
|
|
258
|
+
"~run"(dataset, config$1) {
|
|
259
|
+
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
260
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
261
|
+
return dataset;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
266
|
+
function custom(check$1, message$1) {
|
|
267
|
+
return _standardSchema({
|
|
268
|
+
kind: "schema",
|
|
269
|
+
type: "custom",
|
|
270
|
+
reference: custom,
|
|
271
|
+
expects: "unknown",
|
|
272
|
+
async: false,
|
|
273
|
+
check: check$1,
|
|
274
|
+
message: message$1,
|
|
275
|
+
"~run"(dataset, config$1) {
|
|
276
|
+
if (this.check(dataset.value)) dataset.typed = true;
|
|
277
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
278
|
+
return dataset;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
283
|
+
function literal(literal_, message$1) {
|
|
284
|
+
return _standardSchema({
|
|
285
|
+
kind: "schema",
|
|
286
|
+
type: "literal",
|
|
287
|
+
reference: literal,
|
|
288
|
+
expects: /* @__PURE__ */ _stringify(literal_),
|
|
289
|
+
async: false,
|
|
290
|
+
literal: literal_,
|
|
291
|
+
message: message$1,
|
|
292
|
+
"~run"(dataset, config$1) {
|
|
293
|
+
if (/* @__PURE__ */ _isSameValueZero(dataset.value, this.literal)) dataset.typed = true;
|
|
294
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
295
|
+
return dataset;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
300
|
+
function number(message$1) {
|
|
301
|
+
return _standardSchema({
|
|
302
|
+
kind: "schema",
|
|
303
|
+
type: "number",
|
|
304
|
+
reference: number,
|
|
305
|
+
expects: "number",
|
|
306
|
+
async: false,
|
|
307
|
+
message: message$1,
|
|
308
|
+
"~run"(dataset, config$1) {
|
|
309
|
+
if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
|
|
310
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
311
|
+
return dataset;
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
316
|
+
function optional(wrapped, default_) {
|
|
317
|
+
return _standardSchema({
|
|
318
|
+
kind: "schema",
|
|
319
|
+
type: "optional",
|
|
320
|
+
reference: optional,
|
|
321
|
+
expects: `(${wrapped.expects} | undefined)`,
|
|
322
|
+
async: false,
|
|
323
|
+
wrapped,
|
|
324
|
+
default: default_,
|
|
325
|
+
"~run"(dataset, config$1) {
|
|
326
|
+
if (dataset.value === void 0) {
|
|
327
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
|
|
328
|
+
if (dataset.value === void 0) {
|
|
329
|
+
dataset.typed = true;
|
|
330
|
+
return dataset;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return this.wrapped["~run"](dataset, config$1);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
338
|
+
function picklist(options, message$1) {
|
|
339
|
+
return _standardSchema({
|
|
340
|
+
kind: "schema",
|
|
341
|
+
type: "picklist",
|
|
342
|
+
reference: picklist,
|
|
343
|
+
expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
|
|
344
|
+
async: false,
|
|
345
|
+
options,
|
|
346
|
+
message: message$1,
|
|
347
|
+
"~run"(dataset, config$1) {
|
|
348
|
+
if (this.options.includes(dataset.value)) dataset.typed = true;
|
|
349
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
350
|
+
return dataset;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
355
|
+
function record(key, value$1, message$1) {
|
|
356
|
+
return _standardSchema({
|
|
357
|
+
kind: "schema",
|
|
358
|
+
type: "record",
|
|
359
|
+
reference: record,
|
|
360
|
+
expects: "Object",
|
|
361
|
+
async: false,
|
|
362
|
+
key,
|
|
363
|
+
value: value$1,
|
|
364
|
+
message: message$1,
|
|
365
|
+
"~run"(dataset, config$1) {
|
|
366
|
+
const input = dataset.value;
|
|
367
|
+
if (input && typeof input === "object") {
|
|
368
|
+
dataset.typed = true;
|
|
369
|
+
dataset.value = {};
|
|
370
|
+
for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
371
|
+
const entryValue = input[entryKey];
|
|
372
|
+
const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
|
|
373
|
+
if (keyDataset.issues) {
|
|
374
|
+
const pathItem = {
|
|
375
|
+
type: "object",
|
|
376
|
+
origin: "key",
|
|
377
|
+
input,
|
|
378
|
+
key: entryKey,
|
|
379
|
+
value: entryValue
|
|
380
|
+
};
|
|
381
|
+
for (const issue of keyDataset.issues) {
|
|
382
|
+
issue.path = [pathItem];
|
|
383
|
+
dataset.issues?.push(issue);
|
|
384
|
+
}
|
|
385
|
+
if (!dataset.issues) dataset.issues = keyDataset.issues;
|
|
386
|
+
if (config$1.abortEarly) {
|
|
387
|
+
dataset.typed = false;
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
|
|
392
|
+
if (valueDataset.issues) {
|
|
393
|
+
const pathItem = {
|
|
394
|
+
type: "object",
|
|
395
|
+
origin: "value",
|
|
396
|
+
input,
|
|
397
|
+
key: entryKey,
|
|
398
|
+
value: entryValue
|
|
399
|
+
};
|
|
400
|
+
for (const issue of valueDataset.issues) {
|
|
401
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
402
|
+
else issue.path = [pathItem];
|
|
403
|
+
dataset.issues?.push(issue);
|
|
404
|
+
}
|
|
405
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
406
|
+
if (config$1.abortEarly) {
|
|
407
|
+
dataset.typed = false;
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
|
|
412
|
+
if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
|
|
413
|
+
}
|
|
414
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
415
|
+
return dataset;
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
420
|
+
function strictObject(entries$1, message$1) {
|
|
421
|
+
return _standardSchema({
|
|
422
|
+
kind: "schema",
|
|
423
|
+
type: "strict_object",
|
|
424
|
+
reference: strictObject,
|
|
425
|
+
expects: "Object",
|
|
426
|
+
async: false,
|
|
427
|
+
entries: entries$1,
|
|
428
|
+
message: message$1,
|
|
429
|
+
"~run"(dataset, config$1) {
|
|
430
|
+
const input = dataset.value;
|
|
431
|
+
if (input && typeof input === "object") {
|
|
432
|
+
dataset.typed = true;
|
|
433
|
+
dataset.value = {};
|
|
434
|
+
for (const key in this.entries) {
|
|
435
|
+
const valueSchema = this.entries[key];
|
|
436
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
437
|
+
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
438
|
+
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
439
|
+
if (valueDataset.issues) {
|
|
440
|
+
const pathItem = {
|
|
441
|
+
type: "object",
|
|
442
|
+
origin: "value",
|
|
443
|
+
input,
|
|
444
|
+
key,
|
|
445
|
+
value: value$1
|
|
446
|
+
};
|
|
447
|
+
for (const issue of valueDataset.issues) {
|
|
448
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
449
|
+
else issue.path = [pathItem];
|
|
450
|
+
dataset.issues?.push(issue);
|
|
451
|
+
}
|
|
452
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
453
|
+
if (config$1.abortEarly) {
|
|
454
|
+
dataset.typed = false;
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
459
|
+
dataset.value[key] = valueDataset.value;
|
|
460
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
461
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
462
|
+
_addIssue(this, "key", dataset, config$1, {
|
|
463
|
+
input: void 0,
|
|
464
|
+
expected: `"${key}"`,
|
|
465
|
+
path: [{
|
|
466
|
+
type: "object",
|
|
467
|
+
origin: "key",
|
|
468
|
+
input,
|
|
469
|
+
key,
|
|
470
|
+
value: input[key]
|
|
471
|
+
}]
|
|
472
|
+
});
|
|
473
|
+
if (config$1.abortEarly) break;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (!dataset.issues || !config$1.abortEarly) {
|
|
477
|
+
for (const key in input) if (!Object.prototype.hasOwnProperty.call(this.entries, key)) {
|
|
478
|
+
_addIssue(this, "key", dataset, config$1, {
|
|
479
|
+
input: key,
|
|
480
|
+
expected: "never",
|
|
481
|
+
path: [{
|
|
482
|
+
type: "object",
|
|
483
|
+
origin: "key",
|
|
484
|
+
input,
|
|
485
|
+
key,
|
|
486
|
+
value: input[key]
|
|
487
|
+
}]
|
|
488
|
+
});
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
493
|
+
return dataset;
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
498
|
+
function string(message$1) {
|
|
499
|
+
return _standardSchema({
|
|
500
|
+
kind: "schema",
|
|
501
|
+
type: "string",
|
|
502
|
+
reference: string,
|
|
503
|
+
expects: "string",
|
|
504
|
+
async: false,
|
|
505
|
+
message: message$1,
|
|
506
|
+
"~run"(dataset, config$1) {
|
|
507
|
+
if (typeof dataset.value === "string") dataset.typed = true;
|
|
508
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
509
|
+
return dataset;
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Returns the sub issues of the provided datasets for the union issue.
|
|
515
|
+
*
|
|
516
|
+
* @param datasets The datasets.
|
|
517
|
+
*
|
|
518
|
+
* @returns The sub issues.
|
|
519
|
+
*
|
|
520
|
+
* @internal
|
|
521
|
+
*/
|
|
522
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
523
|
+
function _subIssues(datasets) {
|
|
524
|
+
let issues;
|
|
525
|
+
if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
|
|
526
|
+
else issues = dataset.issues;
|
|
527
|
+
return issues;
|
|
528
|
+
}
|
|
529
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
530
|
+
function union(options, message$1) {
|
|
531
|
+
return _standardSchema({
|
|
532
|
+
kind: "schema",
|
|
533
|
+
type: "union",
|
|
534
|
+
reference: union,
|
|
535
|
+
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
|
|
536
|
+
async: false,
|
|
537
|
+
options,
|
|
538
|
+
message: message$1,
|
|
539
|
+
"~run"(dataset, config$1) {
|
|
540
|
+
let validDataset;
|
|
541
|
+
let typedDatasets;
|
|
542
|
+
let untypedDatasets;
|
|
543
|
+
for (const schema of this.options) {
|
|
544
|
+
const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
|
|
545
|
+
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
|
|
546
|
+
else typedDatasets = [optionDataset];
|
|
547
|
+
else {
|
|
548
|
+
validDataset = optionDataset;
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
else if (untypedDatasets) untypedDatasets.push(optionDataset);
|
|
552
|
+
else untypedDatasets = [optionDataset];
|
|
553
|
+
}
|
|
554
|
+
if (validDataset) return validDataset;
|
|
555
|
+
if (typedDatasets) {
|
|
556
|
+
if (typedDatasets.length === 1) return typedDatasets[0];
|
|
557
|
+
_addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
|
|
558
|
+
dataset.typed = true;
|
|
559
|
+
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
560
|
+
else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
|
|
561
|
+
return dataset;
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Creates a unknown schema.
|
|
567
|
+
*
|
|
568
|
+
* @returns A unknown schema.
|
|
569
|
+
*/
|
|
570
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
571
|
+
function unknown() {
|
|
572
|
+
return _standardSchema({
|
|
573
|
+
kind: "schema",
|
|
574
|
+
type: "unknown",
|
|
575
|
+
reference: unknown,
|
|
576
|
+
expects: "unknown",
|
|
577
|
+
async: false,
|
|
578
|
+
"~run"(dataset) {
|
|
579
|
+
dataset.typed = true;
|
|
580
|
+
return dataset;
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
585
|
+
function pipe(...pipe$1) {
|
|
586
|
+
return _standardSchema({
|
|
587
|
+
...pipe$1[0],
|
|
588
|
+
pipe: pipe$1,
|
|
589
|
+
"~run"(dataset, config$1) {
|
|
590
|
+
for (const item of pipe$1) if (item.kind !== "metadata") {
|
|
591
|
+
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
592
|
+
dataset.typed = false;
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
|
|
596
|
+
}
|
|
597
|
+
return dataset;
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Parses an unknown input based on a schema.
|
|
603
|
+
*
|
|
604
|
+
* @param schema The schema to be used.
|
|
605
|
+
* @param input The input to be parsed.
|
|
606
|
+
* @param config The parse configuration.
|
|
607
|
+
*
|
|
608
|
+
* @returns The parse result.
|
|
609
|
+
*/
|
|
610
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
611
|
+
function safeParse(schema, input, config$1) {
|
|
612
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
|
|
613
|
+
return {
|
|
614
|
+
typed: dataset.typed,
|
|
615
|
+
success: !dataset.issues,
|
|
616
|
+
output: dataset.value,
|
|
617
|
+
issues: dataset.issues
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
//#endregion
|
|
621
|
+
export { literal as a, picklist as c, safeParse as d, strictObject as f, url as g, unknown as h, getDotPath as i, pipe as l, union as m, boolean as n, number as o, string as p, custom as r, optional as s, array as t, record as u };
|