fullstacked 0.12.0-1273 → 0.12.0-1291
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 +155667 -87447
- package/fullstacked_modules/ai/tools/fs.ts +12 -2
- package/fullstacked_modules/fetch/index.ts +41 -16
- package/fullstacked_modules/fs/fs.ts +1 -1
- 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
|
@@ -318,83 +318,6 @@ test("url validations", () => {
|
|
|
318
318
|
expect(() => url.parse("https://")).toThrow();
|
|
319
319
|
});
|
|
320
320
|
|
|
321
|
-
test("url preserves original input", () => {
|
|
322
|
-
const url = z.string().url();
|
|
323
|
-
|
|
324
|
-
// Test the specific case from the user report
|
|
325
|
-
const input = "https://example.com?key=NUXOmHqWNVTapJkJJHw8BfD155AuqhH_qju_5fNmQ4ZHV7u8";
|
|
326
|
-
const output = url.parse(input);
|
|
327
|
-
expect(output).toBe(input); // Should preserve the original input exactly
|
|
328
|
-
|
|
329
|
-
// Test other cases where URL constructor would normalize
|
|
330
|
-
expect(url.parse("https://example.com?foo=bar")).toBe("https://example.com?foo=bar");
|
|
331
|
-
expect(url.parse("http://example.com?test=123")).toBe("http://example.com?test=123");
|
|
332
|
-
expect(url.parse("https://sub.example.com?param=value&other=data")).toBe(
|
|
333
|
-
"https://sub.example.com?param=value&other=data"
|
|
334
|
-
);
|
|
335
|
-
|
|
336
|
-
// Test cases with trailing slashes are preserved
|
|
337
|
-
expect(url.parse("https://example.com/")).toBe("https://example.com/");
|
|
338
|
-
expect(url.parse("https://example.com/path/")).toBe("https://example.com/path/");
|
|
339
|
-
|
|
340
|
-
// Test cases with paths and query parameters
|
|
341
|
-
expect(url.parse("https://example.com/path?query=param")).toBe("https://example.com/path?query=param");
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
test("url trims whitespace", () => {
|
|
345
|
-
const url = z.string().url();
|
|
346
|
-
|
|
347
|
-
// Test trimming whitespace from URLs
|
|
348
|
-
expect(url.parse(" https://example.com ")).toBe("https://example.com");
|
|
349
|
-
expect(url.parse(" https://example.com/path?query=param ")).toBe("https://example.com/path?query=param");
|
|
350
|
-
expect(url.parse("\t\nhttps://example.com\t\n")).toBe("https://example.com");
|
|
351
|
-
expect(url.parse(" https://example.com?key=value ")).toBe("https://example.com?key=value");
|
|
352
|
-
|
|
353
|
-
// Test that URLs without extra whitespace are unchanged
|
|
354
|
-
expect(url.parse("https://example.com")).toBe("https://example.com");
|
|
355
|
-
expect(url.parse("https://example.com/path")).toBe("https://example.com/path");
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
test("url normalize flag", () => {
|
|
359
|
-
const normalizeUrl = z.url({ normalize: true });
|
|
360
|
-
const preserveUrl = z.url(); // normalize: false/undefined by default
|
|
361
|
-
|
|
362
|
-
// Test that normalize flag causes URL normalization
|
|
363
|
-
expect(normalizeUrl.parse("https://example.com?key=value")).toBe("https://example.com/?key=value");
|
|
364
|
-
expect(normalizeUrl.parse("http://example.com?test=123")).toBe("http://example.com/?test=123");
|
|
365
|
-
|
|
366
|
-
// Test with already normalized URLs
|
|
367
|
-
expect(normalizeUrl.parse("https://example.com/")).toBe("https://example.com/");
|
|
368
|
-
expect(normalizeUrl.parse("https://example.com/path?query=param")).toBe("https://example.com/path?query=param");
|
|
369
|
-
|
|
370
|
-
// Test complex URLs with normalization
|
|
371
|
-
expect(normalizeUrl.parse("https://example.com/../?key=value")).toBe("https://example.com/?key=value");
|
|
372
|
-
expect(normalizeUrl.parse("https://example.com/./path?key=value")).toBe("https://example.com/path?key=value");
|
|
373
|
-
|
|
374
|
-
// Compare with non-normalize behavior
|
|
375
|
-
expect(preserveUrl.parse("https://example.com?key=value")).toBe("https://example.com?key=value");
|
|
376
|
-
expect(preserveUrl.parse("http://example.com?test=123")).toBe("http://example.com?test=123");
|
|
377
|
-
|
|
378
|
-
// Test trimming with normalize
|
|
379
|
-
expect(normalizeUrl.parse(" https://example.com?key=value ")).toBe("https://example.com/?key=value");
|
|
380
|
-
expect(preserveUrl.parse(" https://example.com?key=value ")).toBe("https://example.com?key=value");
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
test("url normalize with hostname and protocol constraints", () => {
|
|
384
|
-
const constrainedNormalizeUrl = z.url({
|
|
385
|
-
normalize: true,
|
|
386
|
-
protocol: /^https$/,
|
|
387
|
-
hostname: /^example\.com$/,
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
// Test that normalization works with constraints
|
|
391
|
-
expect(constrainedNormalizeUrl.parse("https://example.com?key=value")).toBe("https://example.com/?key=value");
|
|
392
|
-
|
|
393
|
-
// Test that constraints are still enforced
|
|
394
|
-
expect(() => constrainedNormalizeUrl.parse("http://example.com?key=value")).toThrow();
|
|
395
|
-
expect(() => constrainedNormalizeUrl.parse("https://other.com?key=value")).toThrow();
|
|
396
|
-
});
|
|
397
|
-
|
|
398
321
|
test("httpurl", () => {
|
|
399
322
|
const httpUrl = z.url({
|
|
400
323
|
protocol: /^https?$/,
|
|
@@ -541,8 +464,8 @@ test(`bad uuid`, () => {
|
|
|
541
464
|
"9491d710-3185-0e06-bea0-6a2f275345e0",
|
|
542
465
|
"9491d710-3185-5e06-0ea0-6a2f275345e0",
|
|
543
466
|
"d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
|
|
544
|
-
"b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC
|
|
545
|
-
"92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC
|
|
467
|
+
"b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
|
|
468
|
+
"92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
|
|
546
469
|
"invalid uuid",
|
|
547
470
|
"9491d710-3185-4e06-bea0-6a2f275345e0X",
|
|
548
471
|
"ffffffff-ffff-ffff-ffff-ffffffffffff",
|
|
@@ -558,8 +481,8 @@ test("good guid", () => {
|
|
|
558
481
|
for (const goodGuid of [
|
|
559
482
|
"9491d710-3185-4e06-bea0-6a2f275345e0",
|
|
560
483
|
"d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
|
|
561
|
-
"b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC
|
|
562
|
-
"92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC
|
|
484
|
+
"b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
|
|
485
|
+
"92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
|
|
563
486
|
"00000000-0000-0000-0000-000000000000",
|
|
564
487
|
"ffffffff-ffff-ffff-ffff-ffffffffffff",
|
|
565
488
|
]) {
|
|
@@ -956,41 +879,3 @@ test("E.164 validation", () => {
|
|
|
956
879
|
expect(validE164Numbers.every((number) => e164Number.safeParse(number).success)).toBe(true);
|
|
957
880
|
expect(invalidE164Numbers.every((number) => e164Number.safeParse(number).success === false)).toBe(true);
|
|
958
881
|
});
|
|
959
|
-
|
|
960
|
-
test("hostname", () => {
|
|
961
|
-
const hostname = z.hostname();
|
|
962
|
-
|
|
963
|
-
// Valid hostnames
|
|
964
|
-
hostname.parse("localhost");
|
|
965
|
-
hostname.parse("example.com");
|
|
966
|
-
hostname.parse("sub.example.com");
|
|
967
|
-
hostname.parse("a-b-c.example.com");
|
|
968
|
-
hostname.parse("123.example.com");
|
|
969
|
-
hostname.parse("example-123.com");
|
|
970
|
-
hostname.parse("example-123.1234");
|
|
971
|
-
hostname.parse("developer.mozilla.org");
|
|
972
|
-
hostname.parse("hello.world.example.com");
|
|
973
|
-
hostname.parse("www.google.com");
|
|
974
|
-
hostname.parse("192.168.1.1");
|
|
975
|
-
hostname.parse("xn--d1acj3b.com");
|
|
976
|
-
hostname.parse("xn--d1acj3b.org");
|
|
977
|
-
hostname.parse("xn--d1acj3b");
|
|
978
|
-
|
|
979
|
-
// Invalid hostnames
|
|
980
|
-
expect(() => hostname.parse("")).toThrow();
|
|
981
|
-
expect(() => hostname.parse("example..com")).toThrow();
|
|
982
|
-
expect(() => hostname.parse("example-.com")).toThrow();
|
|
983
|
-
expect(() => hostname.parse("-example.com")).toThrow();
|
|
984
|
-
expect(() => hostname.parse("example.com-")).toThrow();
|
|
985
|
-
expect(() => hostname.parse("example_com")).toThrow();
|
|
986
|
-
expect(() => hostname.parse("example.com:8080")).toThrow();
|
|
987
|
-
expect(() => hostname.parse("http://example.com")).toThrow();
|
|
988
|
-
expect(() => hostname.parse("ht!tp://invalid.com")).toThrow();
|
|
989
|
-
|
|
990
|
-
expect(() => hostname.parse("xn--d1acj3b..com")).toThrow();
|
|
991
|
-
expect(() => hostname.parse("ex@mple.com")).toThrow();
|
|
992
|
-
expect(() => hostname.parse("[2001:db8::zzzz]")).toThrow();
|
|
993
|
-
expect(() => hostname.parse("exa mple.com")).toThrow();
|
|
994
|
-
expect(() => hostname.parse("-example.com")).toThrow();
|
|
995
|
-
expect(() => hostname.parse("example..com")).toThrow();
|
|
996
|
-
});
|
|
@@ -6,7 +6,6 @@ const hello = z.templateLiteral(["hello"]);
|
|
|
6
6
|
const world = z.templateLiteral(["", z.literal("world")]);
|
|
7
7
|
const one = z.templateLiteral([1]);
|
|
8
8
|
const two = z.templateLiteral(["", z.literal(2)]);
|
|
9
|
-
const onePointOne = z.templateLiteral([z.literal(1.1)]);
|
|
10
9
|
const truee = z.templateLiteral([true]);
|
|
11
10
|
const anotherTrue = z.templateLiteral(["", z.literal(true)]);
|
|
12
11
|
const falsee = z.templateLiteral([false]);
|
|
@@ -290,7 +289,6 @@ test("template literal parsing - success - basic cases", () => {
|
|
|
290
289
|
world.parse("world");
|
|
291
290
|
one.parse("1");
|
|
292
291
|
two.parse("2");
|
|
293
|
-
onePointOne.parse("1.1");
|
|
294
292
|
truee.parse("true");
|
|
295
293
|
anotherTrue.parse("true");
|
|
296
294
|
falsee.parse("false");
|
|
@@ -383,7 +381,6 @@ test("template literal parsing - failure - basic cases", () => {
|
|
|
383
381
|
expect(() => one.parse("2")).toThrow();
|
|
384
382
|
expect(() => one.parse("12")).toThrow();
|
|
385
383
|
expect(() => one.parse("21")).toThrow();
|
|
386
|
-
expect(() => onePointOne.parse("1s1")).toThrow();
|
|
387
384
|
expect(() => two.parse("1")).toThrow();
|
|
388
385
|
expect(() => two.parse("21")).toThrow();
|
|
389
386
|
expect(() => two.parse("12")).toThrow();
|
|
@@ -539,19 +539,6 @@ describe("toJSONSchema", () => {
|
|
|
539
539
|
`);
|
|
540
540
|
});
|
|
541
541
|
|
|
542
|
-
test("number constraints draft-4", () => {
|
|
543
|
-
expect(z.toJSONSchema(z.number().gt(5).lt(10), { target: "draft-4" })).toMatchInlineSnapshot(`
|
|
544
|
-
{
|
|
545
|
-
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
546
|
-
"exclusiveMaximum": true,
|
|
547
|
-
"exclusiveMinimum": true,
|
|
548
|
-
"maximum": 10,
|
|
549
|
-
"minimum": 5,
|
|
550
|
-
"type": "number",
|
|
551
|
-
}
|
|
552
|
-
`);
|
|
553
|
-
});
|
|
554
|
-
|
|
555
542
|
test("arrays", () => {
|
|
556
543
|
expect(z.toJSONSchema(z.array(z.string()))).toMatchInlineSnapshot(`
|
|
557
544
|
{
|
|
@@ -758,19 +745,6 @@ describe("toJSONSchema", () => {
|
|
|
758
745
|
`);
|
|
759
746
|
});
|
|
760
747
|
|
|
761
|
-
test("literal draft-4", () => {
|
|
762
|
-
const a = z.literal("hello");
|
|
763
|
-
expect(z.toJSONSchema(a, { target: "draft-4" })).toMatchInlineSnapshot(`
|
|
764
|
-
{
|
|
765
|
-
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
766
|
-
"enum": [
|
|
767
|
-
"hello",
|
|
768
|
-
],
|
|
769
|
-
"type": "string",
|
|
770
|
-
}
|
|
771
|
-
`);
|
|
772
|
-
});
|
|
773
|
-
|
|
774
748
|
// pipe
|
|
775
749
|
test("pipe", () => {
|
|
776
750
|
const schema = z
|
|
@@ -1978,7 +1952,6 @@ test("input type", () => {
|
|
|
1978
1952
|
"required": [
|
|
1979
1953
|
"a",
|
|
1980
1954
|
"d",
|
|
1981
|
-
"f",
|
|
1982
1955
|
"g",
|
|
1983
1956
|
],
|
|
1984
1957
|
"type": "object",
|
|
@@ -248,107 +248,3 @@ test("async short circuit on dirty", async () => {
|
|
|
248
248
|
]]
|
|
249
249
|
`);
|
|
250
250
|
});
|
|
251
|
-
|
|
252
|
-
test("do not continue by default", () => {
|
|
253
|
-
const A = z
|
|
254
|
-
.string()
|
|
255
|
-
.transform((val, ctx) => {
|
|
256
|
-
ctx.addIssue({
|
|
257
|
-
code: "custom",
|
|
258
|
-
message: `custom error`,
|
|
259
|
-
});
|
|
260
|
-
ctx.addIssue({
|
|
261
|
-
code: "custom",
|
|
262
|
-
message: `custom error`,
|
|
263
|
-
});
|
|
264
|
-
return val;
|
|
265
|
-
})
|
|
266
|
-
.pipe(z.number() as any);
|
|
267
|
-
expect(A.safeParse("asdf")).toMatchInlineSnapshot(`
|
|
268
|
-
{
|
|
269
|
-
"error": [ZodError: [
|
|
270
|
-
{
|
|
271
|
-
"code": "custom",
|
|
272
|
-
"message": "custom error",
|
|
273
|
-
"path": []
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
"code": "custom",
|
|
277
|
-
"message": "custom error",
|
|
278
|
-
"path": []
|
|
279
|
-
}
|
|
280
|
-
]],
|
|
281
|
-
"success": false,
|
|
282
|
-
}
|
|
283
|
-
`);
|
|
284
|
-
|
|
285
|
-
const B = z
|
|
286
|
-
.string()
|
|
287
|
-
.transform((val, ctx) => {
|
|
288
|
-
ctx.issues.push({
|
|
289
|
-
code: "custom",
|
|
290
|
-
message: `custom error`,
|
|
291
|
-
input: val,
|
|
292
|
-
});
|
|
293
|
-
ctx.issues.push({
|
|
294
|
-
code: "custom",
|
|
295
|
-
message: `custom error`,
|
|
296
|
-
input: val,
|
|
297
|
-
});
|
|
298
|
-
return val;
|
|
299
|
-
})
|
|
300
|
-
.pipe(z.number() as any);
|
|
301
|
-
expect(B.safeParse("asdf")).toMatchInlineSnapshot(`
|
|
302
|
-
{
|
|
303
|
-
"error": [ZodError: [
|
|
304
|
-
{
|
|
305
|
-
"code": "custom",
|
|
306
|
-
"message": "custom error",
|
|
307
|
-
"path": []
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
"code": "custom",
|
|
311
|
-
"message": "custom error",
|
|
312
|
-
"path": []
|
|
313
|
-
}
|
|
314
|
-
]],
|
|
315
|
-
"success": false,
|
|
316
|
-
}
|
|
317
|
-
`);
|
|
318
|
-
|
|
319
|
-
const C = z
|
|
320
|
-
.string()
|
|
321
|
-
.transform((val, ctx) => {
|
|
322
|
-
ctx.issues.push({
|
|
323
|
-
code: "custom",
|
|
324
|
-
message: `custom error`,
|
|
325
|
-
input: val,
|
|
326
|
-
continue: true,
|
|
327
|
-
});
|
|
328
|
-
ctx.issues.push({
|
|
329
|
-
code: "custom",
|
|
330
|
-
message: `custom error`,
|
|
331
|
-
input: val,
|
|
332
|
-
continue: true,
|
|
333
|
-
});
|
|
334
|
-
return val;
|
|
335
|
-
})
|
|
336
|
-
.pipe(z.number() as any);
|
|
337
|
-
expect(C.safeParse("asdf")).toMatchInlineSnapshot(`
|
|
338
|
-
{
|
|
339
|
-
"error": [ZodError: [
|
|
340
|
-
{
|
|
341
|
-
"code": "custom",
|
|
342
|
-
"message": "custom error",
|
|
343
|
-
"path": []
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
"code": "custom",
|
|
347
|
-
"message": "custom error",
|
|
348
|
-
"path": []
|
|
349
|
-
}
|
|
350
|
-
]],
|
|
351
|
-
"success": false,
|
|
352
|
-
}
|
|
353
|
-
`);
|
|
354
|
-
});
|
|
@@ -28,9 +28,9 @@ test("successful validation", () => {
|
|
|
28
28
|
expect(r2.error!).toMatchInlineSnapshot(`
|
|
29
29
|
[ZodError: [
|
|
30
30
|
{
|
|
31
|
+
"origin": "array",
|
|
31
32
|
"code": "too_big",
|
|
32
33
|
"maximum": 2,
|
|
33
|
-
"origin": "array",
|
|
34
34
|
"path": [],
|
|
35
35
|
"message": "Too big: expected array to have <2 items"
|
|
36
36
|
}
|
|
@@ -80,9 +80,9 @@ test("async validation", async () => {
|
|
|
80
80
|
expect(r2.error!).toMatchInlineSnapshot(`
|
|
81
81
|
[ZodError: [
|
|
82
82
|
{
|
|
83
|
+
"origin": "array",
|
|
83
84
|
"code": "too_big",
|
|
84
85
|
"maximum": 2,
|
|
85
|
-
"origin": "array",
|
|
86
86
|
"path": [],
|
|
87
87
|
"message": "Too big: expected array to have <2 items"
|
|
88
88
|
}
|
|
@@ -27,7 +27,7 @@ test("return valid over invalid", () => {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
test("return errors from both union arms", () => {
|
|
30
|
-
const result = z.union([z.number(), z.
|
|
30
|
+
const result = z.union([z.number(), z.string().refine(() => false)]).safeParse("a");
|
|
31
31
|
expect(result.success).toEqual(false);
|
|
32
32
|
if (!result.success) {
|
|
33
33
|
expect(result.error.issues).toMatchInlineSnapshot(`
|
|
@@ -45,9 +45,8 @@ test("return errors from both union arms", () => {
|
|
|
45
45
|
],
|
|
46
46
|
[
|
|
47
47
|
{
|
|
48
|
-
"code": "
|
|
49
|
-
"
|
|
50
|
-
"message": "Invalid input: expected boolean, received string",
|
|
48
|
+
"code": "custom",
|
|
49
|
+
"message": "Invalid input",
|
|
51
50
|
"path": [],
|
|
52
51
|
},
|
|
53
52
|
],
|
|
@@ -93,89 +92,3 @@ test("union values", () => {
|
|
|
93
92
|
}
|
|
94
93
|
`);
|
|
95
94
|
});
|
|
96
|
-
|
|
97
|
-
test("non-aborted errors", () => {
|
|
98
|
-
const zItemTest = z.union([
|
|
99
|
-
z.object({
|
|
100
|
-
date: z.number(),
|
|
101
|
-
startDate: z.optional(z.null()),
|
|
102
|
-
endDate: z.optional(z.null()),
|
|
103
|
-
}),
|
|
104
|
-
z
|
|
105
|
-
.object({
|
|
106
|
-
date: z.optional(z.null()),
|
|
107
|
-
startDate: z.number(),
|
|
108
|
-
endDate: z.number(),
|
|
109
|
-
})
|
|
110
|
-
.refine((data) => data.startDate !== data.endDate, {
|
|
111
|
-
error: "startDate and endDate must be different",
|
|
112
|
-
path: ["endDate"],
|
|
113
|
-
}),
|
|
114
|
-
]);
|
|
115
|
-
|
|
116
|
-
const res = zItemTest.safeParse({
|
|
117
|
-
date: null,
|
|
118
|
-
startDate: 1,
|
|
119
|
-
endDate: 1,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
expect(res).toMatchInlineSnapshot(`
|
|
123
|
-
{
|
|
124
|
-
"error": [ZodError: [
|
|
125
|
-
{
|
|
126
|
-
"code": "custom",
|
|
127
|
-
"path": [
|
|
128
|
-
"endDate"
|
|
129
|
-
],
|
|
130
|
-
"message": "startDate and endDate must be different"
|
|
131
|
-
}
|
|
132
|
-
]],
|
|
133
|
-
"success": false,
|
|
134
|
-
}
|
|
135
|
-
`);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
test("surface continuable errors only if they exist", () => {
|
|
139
|
-
const schema = z.union([z.boolean(), z.uuid(), z.jwt()]);
|
|
140
|
-
|
|
141
|
-
expect(schema.safeParse("asdf")).toMatchInlineSnapshot(`
|
|
142
|
-
{
|
|
143
|
-
"error": [ZodError: [
|
|
144
|
-
{
|
|
145
|
-
"code": "invalid_union",
|
|
146
|
-
"errors": [
|
|
147
|
-
[
|
|
148
|
-
{
|
|
149
|
-
"expected": "boolean",
|
|
150
|
-
"code": "invalid_type",
|
|
151
|
-
"path": [],
|
|
152
|
-
"message": "Invalid input: expected boolean, received string"
|
|
153
|
-
}
|
|
154
|
-
],
|
|
155
|
-
[
|
|
156
|
-
{
|
|
157
|
-
"origin": "string",
|
|
158
|
-
"code": "invalid_format",
|
|
159
|
-
"format": "uuid",
|
|
160
|
-
"pattern": "/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/",
|
|
161
|
-
"path": [],
|
|
162
|
-
"message": "Invalid UUID"
|
|
163
|
-
}
|
|
164
|
-
],
|
|
165
|
-
[
|
|
166
|
-
{
|
|
167
|
-
"code": "invalid_format",
|
|
168
|
-
"format": "jwt",
|
|
169
|
-
"path": [],
|
|
170
|
-
"message": "Invalid JWT"
|
|
171
|
-
}
|
|
172
|
-
]
|
|
173
|
-
],
|
|
174
|
-
"path": [],
|
|
175
|
-
"message": "Invalid input"
|
|
176
|
-
}
|
|
177
|
-
]],
|
|
178
|
-
"success": false,
|
|
179
|
-
}
|
|
180
|
-
`);
|
|
181
|
-
});
|