fullstacked 0.12.0-1273 → 0.12.0-1290
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/fullstacked_modules/@fullstacked/ai-agent/index.ts +20 -2
- package/fullstacked_modules/@fullstacked/ai-agent/lock.json +469 -38
- package/fullstacked_modules/@fullstacked/ai-agent/package.json +11 -1
- package/fullstacked_modules/@fullstacked/ai-agent/src/conversation.ts +72 -14
- package/fullstacked_modules/@fullstacked/ai-agent/src/index.ts +1 -2
- package/fullstacked_modules/@fullstacked/ai-agent/src/markdown.ts +8 -4
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/anthropic.ts +46 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/deepseek.ts +46 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/google.ts +40 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/index.ts +41 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/interface.ts +19 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/mistral.ts +47 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/ollama.ts +26 -9
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/openai.ts +21 -9
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/xai.ts +43 -0
- package/fullstacked_modules/@fullstacked/ai-agent/summary.txt +7 -0
- package/fullstacked_modules/ai/index.js +155662 -87448
- package/fullstacked_modules/fetch/index.ts +1 -4
- package/fullstacked_modules/zod/README.md +3 -3
- package/fullstacked_modules/zod/index.d.cts +2 -2
- package/fullstacked_modules/zod/index.d.ts +2 -2
- package/fullstacked_modules/zod/package.json +10 -26
- package/fullstacked_modules/zod/src/index.ts +2 -2
- package/fullstacked_modules/zod/src/v3/tests/string.test.ts +2 -2
- package/fullstacked_modules/zod/src/v3/types.ts +1 -3
- package/fullstacked_modules/zod/src/v4/classic/checks.ts +0 -1
- package/fullstacked_modules/zod/src/v4/classic/compat.ts +0 -4
- package/fullstacked_modules/zod/src/v4/classic/errors.ts +2 -9
- package/fullstacked_modules/zod/src/v4/classic/schemas.ts +47 -24
- package/fullstacked_modules/zod/src/v4/classic/tests/catch.test.ts +5 -4
- package/fullstacked_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -6
- package/fullstacked_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -42
- package/fullstacked_modules/zod/src/v4/classic/tests/error-utils.test.ts +2 -70
- package/fullstacked_modules/zod/src/v4/classic/tests/file.test.ts +2 -5
- package/fullstacked_modules/zod/src/v4/classic/tests/literal.test.ts +0 -25
- package/fullstacked_modules/zod/src/v4/classic/tests/number.test.ts +0 -23
- package/fullstacked_modules/zod/src/v4/classic/tests/optional.test.ts +0 -13
- package/fullstacked_modules/zod/src/v4/classic/tests/partial.test.ts +0 -193
- package/fullstacked_modules/zod/src/v4/classic/tests/pickomit.test.ts +5 -5
- package/fullstacked_modules/zod/src/v4/classic/tests/preprocess.test.ts +15 -4
- package/fullstacked_modules/zod/src/v4/classic/tests/record.test.ts +1 -15
- package/fullstacked_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -121
- package/fullstacked_modules/zod/src/v4/classic/tests/string.test.ts +4 -119
- package/fullstacked_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -3
- package/fullstacked_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -27
- package/fullstacked_modules/zod/src/v4/classic/tests/transform.test.ts +0 -104
- package/fullstacked_modules/zod/src/v4/classic/tests/tuple.test.ts +2 -2
- package/fullstacked_modules/zod/src/v4/classic/tests/union.test.ts +3 -90
- package/fullstacked_modules/zod/src/v4/core/api.ts +96 -130
- package/fullstacked_modules/zod/src/v4/core/checks.ts +2 -4
- package/fullstacked_modules/zod/src/v4/core/doc.ts +2 -2
- package/fullstacked_modules/zod/src/v4/core/errors.ts +44 -43
- package/fullstacked_modules/zod/src/v4/core/json-schema.ts +3 -6
- package/fullstacked_modules/zod/src/v4/core/regexes.ts +6 -9
- package/fullstacked_modules/zod/src/v4/core/registries.ts +2 -3
- package/fullstacked_modules/zod/src/v4/core/schemas.ts +107 -165
- package/fullstacked_modules/zod/src/v4/core/to-json-schema.ts +11 -38
- package/fullstacked_modules/zod/src/v4/core/util.ts +105 -157
- package/fullstacked_modules/zod/src/v4/core/versions.ts +1 -1
- package/fullstacked_modules/zod/src/v4/locales/index.ts +0 -3
- package/fullstacked_modules/zod/src/v4/mini/schemas.ts +1 -14
- package/fullstacked_modules/zod/src/v4/mini/tests/assignability.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/computed.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/error.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/index.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/number.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/object.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/prototypes.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/recursive-types.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/string.test.ts +1 -1
- package/fullstacked_modules/zod/v3/ZodError.d.cts +6 -6
- package/fullstacked_modules/zod/v3/ZodError.d.ts +6 -6
- package/fullstacked_modules/zod/v3/locales/en.d.cts +1 -1
- package/fullstacked_modules/zod/v3/types.d.cts +1 -4
- package/fullstacked_modules/zod/v3/types.d.ts +1 -4
- package/fullstacked_modules/zod/v4/classic/checks.d.cts +1 -1
- package/fullstacked_modules/zod/v4/classic/checks.d.ts +1 -1
- package/fullstacked_modules/zod/v4/classic/compat.d.cts +0 -4
- package/fullstacked_modules/zod/v4/classic/compat.d.ts +0 -4
- package/fullstacked_modules/zod/v4/classic/schemas.d.cts +20 -9
- package/fullstacked_modules/zod/v4/classic/schemas.d.ts +20 -9
- package/fullstacked_modules/zod/v4/core/api.d.cts +72 -84
- package/fullstacked_modules/zod/v4/core/api.d.ts +72 -84
- package/fullstacked_modules/zod/v4/core/checks.d.cts +2 -2
- package/fullstacked_modules/zod/v4/core/checks.d.ts +2 -2
- package/fullstacked_modules/zod/v4/core/doc.d.cts +1 -1
- package/fullstacked_modules/zod/v4/core/doc.d.ts +1 -1
- package/fullstacked_modules/zod/v4/core/errors.d.cts +22 -24
- package/fullstacked_modules/zod/v4/core/errors.d.ts +22 -24
- package/fullstacked_modules/zod/v4/core/json-schema.d.cts +3 -3
- package/fullstacked_modules/zod/v4/core/json-schema.d.ts +3 -3
- package/fullstacked_modules/zod/v4/core/regexes.d.cts +2 -2
- package/fullstacked_modules/zod/v4/core/regexes.d.ts +2 -2
- package/fullstacked_modules/zod/v4/core/registries.d.cts +1 -1
- package/fullstacked_modules/zod/v4/core/registries.d.ts +1 -1
- package/fullstacked_modules/zod/v4/core/schemas.d.cts +6 -20
- package/fullstacked_modules/zod/v4/core/schemas.d.ts +6 -20
- package/fullstacked_modules/zod/v4/core/to-json-schema.d.cts +3 -4
- package/fullstacked_modules/zod/v4/core/to-json-schema.d.ts +3 -4
- package/fullstacked_modules/zod/v4/core/util.d.cts +0 -2
- package/fullstacked_modules/zod/v4/core/util.d.ts +0 -2
- package/fullstacked_modules/zod/v4/locales/ar.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/az.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/be.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ca.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/cs.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/de.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/es.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/fa.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/fi.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/fr-CA.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/fr.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/he.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/hu.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/id.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/index.d.cts +0 -3
- package/fullstacked_modules/zod/v4/locales/index.d.ts +0 -3
- package/fullstacked_modules/zod/v4/locales/it.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ja.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/kh.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ko.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/mk.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ms.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/nl.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/no.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ota.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/pl.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ps.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/pt.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ru.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/sl.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/sv.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ta.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/th.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ua.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ur.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/vi.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/zh-CN.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/zh-TW.d.cts +1 -2
- package/fullstacked_modules/zod/v4/mini/schemas.d.cts +0 -2
- package/fullstacked_modules/zod/v4/mini/schemas.d.ts +0 -2
- package/package.json +1 -1
- package/fullstacked_modules/zod/locales/index.d.cts +0 -1
- package/fullstacked_modules/zod/locales/index.d.ts +0 -1
- package/fullstacked_modules/zod/mini/index.d.cts +0 -1
- package/fullstacked_modules/zod/mini/index.d.ts +0 -1
- package/fullstacked_modules/zod/src/locales/index.ts +0 -1
- package/fullstacked_modules/zod/src/mini/index.ts +0 -1
- package/fullstacked_modules/zod/src/v4/core/tests/extend.test.ts +0 -18
- package/fullstacked_modules/zod/src/v4/locales/bg.ts +0 -136
- package/fullstacked_modules/zod/src/v4/locales/da.ts +0 -141
- package/fullstacked_modules/zod/src/v4/locales/is.ts +0 -127
- package/fullstacked_modules/zod/src/v4/locales/yo.ts +0 -131
- package/fullstacked_modules/zod/v4/locales/bg.d.cts +0 -5
- package/fullstacked_modules/zod/v4/locales/bg.d.ts +0 -5
- package/fullstacked_modules/zod/v4/locales/da.d.cts +0 -5
- package/fullstacked_modules/zod/v4/locales/da.d.ts +0 -4
- package/fullstacked_modules/zod/v4/locales/is.d.cts +0 -5
- package/fullstacked_modules/zod/v4/locales/is.d.ts +0 -5
- package/fullstacked_modules/zod/v4/locales/yo.d.cts +0 -5
- package/fullstacked_modules/zod/v4/locales/yo.d.ts +0 -4
|
@@ -10,9 +10,8 @@ interface JSONSchemaGeneratorParams {
|
|
|
10
10
|
metadata?: $ZodRegistry<Record<string, any>>;
|
|
11
11
|
/** The JSON Schema version to target.
|
|
12
12
|
* - `"draft-2020-12"` — Default. JSON Schema Draft 2020-12
|
|
13
|
-
* - `"draft-7"` — JSON Schema Draft 7
|
|
14
|
-
|
|
15
|
-
target?: "draft-4" | "draft-7" | "draft-2020-12";
|
|
13
|
+
* - `"draft-7"` — JSON Schema Draft 7 */
|
|
14
|
+
target?: "draft-7" | "draft-2020-12";
|
|
16
15
|
/** How to handle unrepresentable types.
|
|
17
16
|
* - `"throw"` — Default. Unrepresentable types throw an error
|
|
18
17
|
* - `"any"` — Unrepresentable types become `{}` */
|
|
@@ -72,7 +71,7 @@ interface Seen {
|
|
|
72
71
|
|
|
73
72
|
export class JSONSchemaGenerator {
|
|
74
73
|
metadataRegistry: $ZodRegistry<Record<string, any>>;
|
|
75
|
-
target: "draft-
|
|
74
|
+
target: "draft-7" | "draft-2020-12";
|
|
76
75
|
unrepresentable: "throw" | "any";
|
|
77
76
|
override: (ctx: {
|
|
78
77
|
zodSchema: schemas.$ZodTypes;
|
|
@@ -164,7 +163,7 @@ export class JSONSchemaGenerator {
|
|
|
164
163
|
else if (regexes.length > 1) {
|
|
165
164
|
result.schema.allOf = [
|
|
166
165
|
...regexes.map((regex) => ({
|
|
167
|
-
...(this.target === "draft-7"
|
|
166
|
+
...(this.target === "draft-7" ? ({ type: "string" } as const) : {}),
|
|
168
167
|
pattern: regex.source,
|
|
169
168
|
})),
|
|
170
169
|
];
|
|
@@ -179,33 +178,19 @@ export class JSONSchemaGenerator {
|
|
|
179
178
|
if (typeof format === "string" && format.includes("int")) json.type = "integer";
|
|
180
179
|
else json.type = "number";
|
|
181
180
|
|
|
182
|
-
if (typeof exclusiveMinimum === "number")
|
|
183
|
-
if (this.target === "draft-4") {
|
|
184
|
-
json.minimum = exclusiveMinimum;
|
|
185
|
-
json.exclusiveMinimum = true;
|
|
186
|
-
} else {
|
|
187
|
-
json.exclusiveMinimum = exclusiveMinimum;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
181
|
+
if (typeof exclusiveMinimum === "number") json.exclusiveMinimum = exclusiveMinimum;
|
|
190
182
|
if (typeof minimum === "number") {
|
|
191
183
|
json.minimum = minimum;
|
|
192
|
-
if (typeof exclusiveMinimum === "number"
|
|
184
|
+
if (typeof exclusiveMinimum === "number") {
|
|
193
185
|
if (exclusiveMinimum >= minimum) delete json.minimum;
|
|
194
186
|
else delete json.exclusiveMinimum;
|
|
195
187
|
}
|
|
196
188
|
}
|
|
197
189
|
|
|
198
|
-
if (typeof exclusiveMaximum === "number")
|
|
199
|
-
if (this.target === "draft-4") {
|
|
200
|
-
json.maximum = exclusiveMaximum;
|
|
201
|
-
json.exclusiveMaximum = true;
|
|
202
|
-
} else {
|
|
203
|
-
json.exclusiveMaximum = exclusiveMaximum;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
190
|
+
if (typeof exclusiveMaximum === "number") json.exclusiveMaximum = exclusiveMaximum;
|
|
206
191
|
if (typeof maximum === "number") {
|
|
207
192
|
json.maximum = maximum;
|
|
208
|
-
if (typeof exclusiveMaximum === "number"
|
|
193
|
+
if (typeof exclusiveMaximum === "number") {
|
|
209
194
|
if (exclusiveMaximum <= maximum) delete json.maximum;
|
|
210
195
|
else delete json.exclusiveMaximum;
|
|
211
196
|
}
|
|
@@ -394,12 +379,7 @@ export class JSONSchemaGenerator {
|
|
|
394
379
|
case "record": {
|
|
395
380
|
const json: JSONSchema.ObjectSchema = _json as any;
|
|
396
381
|
json.type = "object";
|
|
397
|
-
|
|
398
|
-
json.propertyNames = this.process(def.keyType, {
|
|
399
|
-
...params,
|
|
400
|
-
path: [...params.path, "propertyNames"],
|
|
401
|
-
});
|
|
402
|
-
}
|
|
382
|
+
json.propertyNames = this.process(def.keyType, { ...params, path: [...params.path, "propertyNames"] });
|
|
403
383
|
json.additionalProperties = this.process(def.valueType, {
|
|
404
384
|
...params,
|
|
405
385
|
path: [...params.path, "additionalProperties"],
|
|
@@ -452,11 +432,7 @@ export class JSONSchemaGenerator {
|
|
|
452
432
|
} else if (vals.length === 1) {
|
|
453
433
|
const val = vals[0]!;
|
|
454
434
|
json.type = val === null ? ("null" as const) : (typeof val as any);
|
|
455
|
-
|
|
456
|
-
json.enum = [val];
|
|
457
|
-
} else {
|
|
458
|
-
json.const = val;
|
|
459
|
-
}
|
|
435
|
+
json.const = val;
|
|
460
436
|
} else {
|
|
461
437
|
if (vals.every((v) => typeof v === "number")) json.type = "number";
|
|
462
438
|
if (vals.every((v) => typeof v === "string")) json.type = "string";
|
|
@@ -773,7 +749,7 @@ export class JSONSchemaGenerator {
|
|
|
773
749
|
|
|
774
750
|
// merge referenced schema into current
|
|
775
751
|
const refSchema = this.seen.get(ref)!.schema;
|
|
776
|
-
if (refSchema.$ref &&
|
|
752
|
+
if (refSchema.$ref && params.target === "draft-7") {
|
|
777
753
|
schema.allOf = schema.allOf ?? [];
|
|
778
754
|
schema.allOf.push(refSchema);
|
|
779
755
|
} else {
|
|
@@ -800,10 +776,7 @@ export class JSONSchemaGenerator {
|
|
|
800
776
|
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
801
777
|
} else if (this.target === "draft-7") {
|
|
802
778
|
result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
803
|
-
} else if (this.target === "draft-4") {
|
|
804
|
-
result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
805
779
|
} else {
|
|
806
|
-
// @ts-ignore
|
|
807
780
|
console.warn(`Invalid target: ${this.target}`);
|
|
808
781
|
}
|
|
809
782
|
|
|
@@ -123,7 +123,6 @@ export type Identity<T> = T;
|
|
|
123
123
|
export type Flatten<T> = Identity<{ [k in keyof T]: T[k] }>;
|
|
124
124
|
export type Mapped<T> = { [k in keyof T]: T[k] };
|
|
125
125
|
export type Prettify<T> = {
|
|
126
|
-
// @ts-ignore
|
|
127
126
|
[K in keyof T]: T[K];
|
|
128
127
|
} & {};
|
|
129
128
|
|
|
@@ -242,36 +241,23 @@ export function cleanRegex(source: string): string {
|
|
|
242
241
|
|
|
243
242
|
export function floatSafeRemainder(val: number, step: number): number {
|
|
244
243
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
245
|
-
const
|
|
246
|
-
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
247
|
-
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
248
|
-
const match = stepString.match(/\d?e-(\d?)/);
|
|
249
|
-
if (match?.[1]) {
|
|
250
|
-
stepDecCount = Number.parseInt(match[1]);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
244
|
+
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
254
245
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
255
246
|
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
256
247
|
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
257
248
|
return (valInt % stepInt) / 10 ** decCount;
|
|
258
249
|
}
|
|
259
250
|
|
|
260
|
-
const EVALUATING = Symbol("evaluating");
|
|
261
|
-
|
|
262
251
|
export function defineLazy<T, K extends keyof T>(object: T, key: K, getter: () => T[K]): void {
|
|
263
|
-
|
|
252
|
+
const set = false;
|
|
264
253
|
Object.defineProperty(object, key, {
|
|
265
254
|
get() {
|
|
266
|
-
if (
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (value === undefined) {
|
|
271
|
-
value = EVALUATING;
|
|
272
|
-
value = getter();
|
|
255
|
+
if (!set) {
|
|
256
|
+
const value = getter();
|
|
257
|
+
object[key] = value;
|
|
258
|
+
return value;
|
|
273
259
|
}
|
|
274
|
-
|
|
260
|
+
throw new Error("cached value already set");
|
|
275
261
|
},
|
|
276
262
|
set(v) {
|
|
277
263
|
Object.defineProperty(object, key, {
|
|
@@ -297,21 +283,6 @@ export function assignProp<T extends object, K extends PropertyKey>(
|
|
|
297
283
|
});
|
|
298
284
|
}
|
|
299
285
|
|
|
300
|
-
export function mergeDefs(...defs: Record<string, any>[]): any {
|
|
301
|
-
const mergedDescriptors: Record<string, PropertyDescriptor> = {};
|
|
302
|
-
|
|
303
|
-
for (const def of defs) {
|
|
304
|
-
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
305
|
-
Object.assign(mergedDescriptors, descriptors);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return Object.defineProperties({}, mergedDescriptors);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export function cloneDef(schema: schemas.$ZodType): any {
|
|
312
|
-
return mergeDefs(schema._zod.def);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
286
|
export function getElementAtPath(obj: any, path: (string | number)[] | null | undefined): any {
|
|
316
287
|
if (!path) return obj;
|
|
317
288
|
return path.reduce((acc, key) => acc?.[key], obj);
|
|
@@ -343,16 +314,15 @@ export function esc(str: string): string {
|
|
|
343
314
|
return JSON.stringify(str);
|
|
344
315
|
}
|
|
345
316
|
|
|
346
|
-
export const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void =
|
|
347
|
-
|
|
348
|
-
)
|
|
317
|
+
export const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void = Error.captureStackTrace
|
|
318
|
+
? Error.captureStackTrace
|
|
319
|
+
: (..._args) => {};
|
|
349
320
|
|
|
350
321
|
export function isObject(data: any): data is Record<PropertyKey, unknown> {
|
|
351
322
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
352
323
|
}
|
|
353
324
|
|
|
354
325
|
export const allowsEval: { value: boolean } = cached(() => {
|
|
355
|
-
// @ts-ignore
|
|
356
326
|
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
357
327
|
return false;
|
|
358
328
|
}
|
|
@@ -439,7 +409,6 @@ export const getParsedType = (data: any): ParsedTypes => {
|
|
|
439
409
|
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
440
410
|
return "date";
|
|
441
411
|
}
|
|
442
|
-
// @ts-ignore
|
|
443
412
|
if (typeof File !== "undefined" && data instanceof File) {
|
|
444
413
|
return "file";
|
|
445
414
|
}
|
|
@@ -566,81 +535,71 @@ export const BIGINT_FORMAT_RANGES: Record<checks.$ZodBigIntFormats, [bigint, big
|
|
|
566
535
|
};
|
|
567
536
|
|
|
568
537
|
export function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>): any {
|
|
569
|
-
const
|
|
538
|
+
const newShape: Writeable<schemas.$ZodShape> = {};
|
|
539
|
+
const currDef = schema._zod.def; //.shape;
|
|
570
540
|
|
|
571
|
-
const
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
throw new Error(`Unrecognized key: "${key}"`);
|
|
577
|
-
}
|
|
578
|
-
if (!mask[key]) continue;
|
|
579
|
-
newShape[key] = currDef.shape[key]!;
|
|
580
|
-
}
|
|
541
|
+
for (const key in mask) {
|
|
542
|
+
if (!(key in currDef.shape)) {
|
|
543
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
544
|
+
}
|
|
545
|
+
if (!mask[key]) continue;
|
|
581
546
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
checks: [],
|
|
586
|
-
});
|
|
547
|
+
// pick key
|
|
548
|
+
newShape[key] = currDef.shape[key]!;
|
|
549
|
+
}
|
|
587
550
|
|
|
588
|
-
return clone(schema,
|
|
551
|
+
return clone(schema, {
|
|
552
|
+
...schema._zod.def,
|
|
553
|
+
shape: newShape,
|
|
554
|
+
checks: [],
|
|
555
|
+
}) as any;
|
|
589
556
|
}
|
|
590
557
|
|
|
591
558
|
export function omit(schema: schemas.$ZodObject, mask: object): any {
|
|
592
|
-
const
|
|
559
|
+
const newShape: Writeable<schemas.$ZodShape> = { ...schema._zod.def.shape };
|
|
560
|
+
const currDef = schema._zod.def; //.shape;
|
|
561
|
+
for (const key in mask) {
|
|
562
|
+
if (!(key in currDef.shape)) {
|
|
563
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
564
|
+
}
|
|
565
|
+
if (!(mask as any)[key]) continue;
|
|
593
566
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
throw new Error(`Unrecognized key: "${key}"`);
|
|
600
|
-
}
|
|
601
|
-
if (!(mask as any)[key]) continue;
|
|
602
|
-
|
|
603
|
-
delete newShape[key];
|
|
604
|
-
}
|
|
605
|
-
assignProp(this, "shape", newShape); // self-caching
|
|
606
|
-
return newShape;
|
|
607
|
-
},
|
|
567
|
+
delete newShape[key];
|
|
568
|
+
}
|
|
569
|
+
return clone(schema, {
|
|
570
|
+
...schema._zod.def,
|
|
571
|
+
shape: newShape,
|
|
608
572
|
checks: [],
|
|
609
573
|
});
|
|
610
|
-
|
|
611
|
-
return clone(schema, def);
|
|
612
574
|
}
|
|
613
575
|
|
|
614
576
|
export function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any {
|
|
615
577
|
if (!isPlainObject(shape)) {
|
|
616
578
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
617
579
|
}
|
|
618
|
-
|
|
619
|
-
|
|
580
|
+
const def = {
|
|
581
|
+
...schema._zod.def,
|
|
620
582
|
get shape() {
|
|
621
583
|
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
622
584
|
assignProp(this, "shape", _shape); // self-caching
|
|
623
585
|
return _shape;
|
|
624
586
|
},
|
|
625
|
-
checks: [],
|
|
626
|
-
}
|
|
587
|
+
checks: [], // delete existing checks
|
|
588
|
+
} as any;
|
|
627
589
|
return clone(schema, def) as any;
|
|
628
590
|
}
|
|
629
591
|
|
|
630
592
|
export function merge(a: schemas.$ZodObject, b: schemas.$ZodObject): any {
|
|
631
|
-
|
|
593
|
+
return clone(a, {
|
|
594
|
+
...a._zod.def,
|
|
632
595
|
get shape() {
|
|
633
596
|
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
634
597
|
assignProp(this, "shape", _shape); // self-caching
|
|
635
598
|
return _shape;
|
|
636
599
|
},
|
|
637
|
-
|
|
638
|
-
return b._zod.def.catchall;
|
|
639
|
-
},
|
|
600
|
+
catchall: b._zod.def.catchall,
|
|
640
601
|
checks: [], // delete existing checks
|
|
641
|
-
});
|
|
642
|
-
|
|
643
|
-
return clone(a, def) as any;
|
|
602
|
+
}) as any;
|
|
644
603
|
}
|
|
645
604
|
|
|
646
605
|
export function partial(
|
|
@@ -648,44 +607,40 @@ export function partial(
|
|
|
648
607
|
schema: schemas.$ZodObject,
|
|
649
608
|
mask: object | undefined
|
|
650
609
|
): any {
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
if (
|
|
657
|
-
|
|
658
|
-
if (!(key in oldShape)) {
|
|
659
|
-
throw new Error(`Unrecognized key: "${key}"`);
|
|
660
|
-
}
|
|
661
|
-
if (!(mask as any)[key]) continue;
|
|
662
|
-
// if (oldShape[key]!._zod.optin === "optional") continue;
|
|
663
|
-
shape[key] = Class
|
|
664
|
-
? new Class({
|
|
665
|
-
type: "optional",
|
|
666
|
-
innerType: oldShape[key]!,
|
|
667
|
-
})
|
|
668
|
-
: oldShape[key]!;
|
|
669
|
-
}
|
|
670
|
-
} else {
|
|
671
|
-
for (const key in oldShape) {
|
|
672
|
-
// if (oldShape[key]!._zod.optin === "optional") continue;
|
|
673
|
-
shape[key] = Class
|
|
674
|
-
? new Class({
|
|
675
|
-
type: "optional",
|
|
676
|
-
innerType: oldShape[key]!,
|
|
677
|
-
})
|
|
678
|
-
: oldShape[key]!;
|
|
679
|
-
}
|
|
610
|
+
const oldShape = schema._zod.def.shape;
|
|
611
|
+
const shape: Writeable<schemas.$ZodShape> = { ...oldShape };
|
|
612
|
+
|
|
613
|
+
if (mask) {
|
|
614
|
+
for (const key in mask) {
|
|
615
|
+
if (!(key in oldShape)) {
|
|
616
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
680
617
|
}
|
|
618
|
+
if (!(mask as any)[key]) continue;
|
|
619
|
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
|
620
|
+
shape[key] = Class
|
|
621
|
+
? new Class({
|
|
622
|
+
type: "optional",
|
|
623
|
+
innerType: oldShape[key]!,
|
|
624
|
+
})
|
|
625
|
+
: oldShape[key]!;
|
|
626
|
+
}
|
|
627
|
+
} else {
|
|
628
|
+
for (const key in oldShape) {
|
|
629
|
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
|
630
|
+
shape[key] = Class
|
|
631
|
+
? new Class({
|
|
632
|
+
type: "optional",
|
|
633
|
+
innerType: oldShape[key]!,
|
|
634
|
+
})
|
|
635
|
+
: oldShape[key]!;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
681
638
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
639
|
+
return clone(schema, {
|
|
640
|
+
...schema._zod.def,
|
|
641
|
+
shape,
|
|
685
642
|
checks: [],
|
|
686
|
-
});
|
|
687
|
-
|
|
688
|
-
return clone(schema, def) as any;
|
|
643
|
+
}) as any;
|
|
689
644
|
}
|
|
690
645
|
|
|
691
646
|
export function required(
|
|
@@ -693,50 +648,44 @@ export function required(
|
|
|
693
648
|
schema: schemas.$ZodObject,
|
|
694
649
|
mask: object | undefined
|
|
695
650
|
): any {
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
if (
|
|
702
|
-
|
|
703
|
-
if (!(key in shape)) {
|
|
704
|
-
throw new Error(`Unrecognized key: "${key}"`);
|
|
705
|
-
}
|
|
706
|
-
if (!(mask as any)[key]) continue;
|
|
707
|
-
// overwrite with non-optional
|
|
708
|
-
shape[key] = new Class({
|
|
709
|
-
type: "nonoptional",
|
|
710
|
-
innerType: oldShape[key]!,
|
|
711
|
-
});
|
|
712
|
-
}
|
|
713
|
-
} else {
|
|
714
|
-
for (const key in oldShape) {
|
|
715
|
-
// overwrite with non-optional
|
|
716
|
-
shape[key] = new Class({
|
|
717
|
-
type: "nonoptional",
|
|
718
|
-
innerType: oldShape[key]!,
|
|
719
|
-
});
|
|
720
|
-
}
|
|
651
|
+
const oldShape = schema._zod.def.shape;
|
|
652
|
+
const shape: Writeable<schemas.$ZodShape> = { ...oldShape };
|
|
653
|
+
|
|
654
|
+
if (mask) {
|
|
655
|
+
for (const key in mask) {
|
|
656
|
+
if (!(key in shape)) {
|
|
657
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
721
658
|
}
|
|
659
|
+
if (!(mask as any)[key]) continue;
|
|
660
|
+
// overwrite with non-optional
|
|
661
|
+
shape[key] = new Class({
|
|
662
|
+
type: "nonoptional",
|
|
663
|
+
innerType: oldShape[key]!,
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
} else {
|
|
667
|
+
for (const key in oldShape) {
|
|
668
|
+
// overwrite with non-optional
|
|
669
|
+
shape[key] = new Class({
|
|
670
|
+
type: "nonoptional",
|
|
671
|
+
innerType: oldShape[key]!,
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
}
|
|
722
675
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
676
|
+
return clone(schema, {
|
|
677
|
+
...schema._zod.def,
|
|
678
|
+
shape,
|
|
679
|
+
// optional: [],
|
|
726
680
|
checks: [],
|
|
727
|
-
});
|
|
728
|
-
|
|
729
|
-
return clone(schema, def) as any;
|
|
681
|
+
}) as any;
|
|
730
682
|
}
|
|
731
683
|
|
|
732
684
|
export type Constructor<T, Def extends any[] = any[]> = new (...args: Def) => T;
|
|
733
685
|
|
|
734
|
-
// invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
|
|
735
686
|
export function aborted(x: schemas.ParsePayload, startIndex = 0): boolean {
|
|
736
687
|
for (let i = startIndex; i < x.issues.length; i++) {
|
|
737
|
-
if (x.issues[i]?.continue !== true)
|
|
738
|
-
return true;
|
|
739
|
-
}
|
|
688
|
+
if (x.issues[i]?.continue !== true) return true;
|
|
740
689
|
}
|
|
741
690
|
return false;
|
|
742
691
|
}
|
|
@@ -784,7 +733,6 @@ export function finalizeIssue(
|
|
|
784
733
|
export function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown" {
|
|
785
734
|
if (input instanceof Set) return "set";
|
|
786
735
|
if (input instanceof Map) return "map";
|
|
787
|
-
// @ts-ignore
|
|
788
736
|
if (input instanceof File) return "file";
|
|
789
737
|
return "unknown";
|
|
790
738
|
}
|
|
@@ -3,7 +3,6 @@ export { default as az } from "./az.js";
|
|
|
3
3
|
export { default as be } from "./be.js";
|
|
4
4
|
export { default as ca } from "./ca.js";
|
|
5
5
|
export { default as cs } from "./cs.js";
|
|
6
|
-
export { default as da } from "./da.js";
|
|
7
6
|
export { default as de } from "./de.js";
|
|
8
7
|
export { default as en } from "./en.js";
|
|
9
8
|
export { default as eo } from "./eo.js";
|
|
@@ -15,7 +14,6 @@ export { default as frCA } from "./fr-CA.js";
|
|
|
15
14
|
export { default as he } from "./he.js";
|
|
16
15
|
export { default as hu } from "./hu.js";
|
|
17
16
|
export { default as id } from "./id.js";
|
|
18
|
-
export { default as is } from "./is.js";
|
|
19
17
|
export { default as it } from "./it.js";
|
|
20
18
|
export { default as ja } from "./ja.js";
|
|
21
19
|
export { default as kh } from "./kh.js";
|
|
@@ -39,4 +37,3 @@ export { default as ur } from "./ur.js";
|
|
|
39
37
|
export { default as vi } from "./vi.js";
|
|
40
38
|
export { default as zhCN } from "./zh-CN.js";
|
|
41
39
|
export { default as zhTW } from "./zh-TW.js";
|
|
42
|
-
export { default as yo } from "./yo.js";
|
|
@@ -436,10 +436,6 @@ export function stringFormat<Format extends string>(
|
|
|
436
436
|
return core._stringFormat(ZodMiniCustomStringFormat, format, fnOrRegex, _params) as any;
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
-
export function hostname(_params?: string | core.$ZodStringFormatParams): ZodMiniCustomStringFormat<"hostname"> {
|
|
440
|
-
return core._stringFormat(ZodMiniCustomStringFormat, "hostname", core.regexes.hostname, _params) as any;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
439
|
// ZodMiniNumber
|
|
444
440
|
interface _ZodMiniNumber<T extends core.$ZodNumberInternals<unknown> = core.$ZodNumberInternals<unknown>>
|
|
445
441
|
extends _ZodMiniType<T>,
|
|
@@ -1028,11 +1024,9 @@ export function partialRecord<Key extends core.$ZodRecordKey, Value extends Some
|
|
|
1028
1024
|
valueType: Value,
|
|
1029
1025
|
params?: string | core.$ZodRecordParams
|
|
1030
1026
|
): ZodMiniRecord<Key & core.$partial, Value> {
|
|
1031
|
-
const k = core.clone(keyType);
|
|
1032
|
-
k._zod.values = undefined;
|
|
1033
1027
|
return new ZodMiniRecord({
|
|
1034
1028
|
type: "record",
|
|
1035
|
-
keyType:
|
|
1029
|
+
keyType: union([keyType, never()]),
|
|
1036
1030
|
valueType: valueType as any,
|
|
1037
1031
|
...util.normalizeParams(params),
|
|
1038
1032
|
}) as any;
|
|
@@ -1524,13 +1518,6 @@ export function refine<T>(
|
|
|
1524
1518
|
return core._refine(ZodMiniCustom, fn, _params);
|
|
1525
1519
|
}
|
|
1526
1520
|
|
|
1527
|
-
// superRefine
|
|
1528
|
-
export function superRefine<T>(
|
|
1529
|
-
fn: (arg: T, payload: core.$RefinementCtx<T>) => void | Promise<void>
|
|
1530
|
-
): core.$ZodCheck<T> {
|
|
1531
|
-
return core._superRefine(fn);
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
1521
|
// instanceof
|
|
1535
1522
|
abstract class Class {
|
|
1536
1523
|
constructor(..._args: any[]) {}
|
|
@@ -10,21 +10,21 @@ export type typeToFlattenedError<T, U = string> = {
|
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
export declare const ZodIssueCode: {
|
|
13
|
-
custom: "custom";
|
|
14
13
|
invalid_type: "invalid_type";
|
|
15
|
-
unrecognized_keys: "unrecognized_keys";
|
|
16
|
-
too_big: "too_big";
|
|
17
|
-
too_small: "too_small";
|
|
18
|
-
not_multiple_of: "not_multiple_of";
|
|
19
|
-
invalid_union: "invalid_union";
|
|
20
14
|
invalid_literal: "invalid_literal";
|
|
15
|
+
custom: "custom";
|
|
16
|
+
invalid_union: "invalid_union";
|
|
21
17
|
invalid_union_discriminator: "invalid_union_discriminator";
|
|
22
18
|
invalid_enum_value: "invalid_enum_value";
|
|
19
|
+
unrecognized_keys: "unrecognized_keys";
|
|
23
20
|
invalid_arguments: "invalid_arguments";
|
|
24
21
|
invalid_return_type: "invalid_return_type";
|
|
25
22
|
invalid_date: "invalid_date";
|
|
26
23
|
invalid_string: "invalid_string";
|
|
24
|
+
too_small: "too_small";
|
|
25
|
+
too_big: "too_big";
|
|
27
26
|
invalid_intersection_types: "invalid_intersection_types";
|
|
27
|
+
not_multiple_of: "not_multiple_of";
|
|
28
28
|
not_finite: "not_finite";
|
|
29
29
|
};
|
|
30
30
|
export type ZodIssueCode = keyof typeof ZodIssueCode;
|