@chainfuse/types 3.0.8 → 4.0.1

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.
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod/mini';
2
- import type { ZodCoordinate } from '../zod/index.js';
2
+ import type { ZodCoordinate } from '../zod-mini/index.js';
3
3
  import { type CloudflareFunctionModelsEnum, type CloudflareModelsEnum } from './workers-ai/index.js';
4
4
  export interface Coordinate {
5
5
  lat: z.infer<typeof ZodCoordinate>;
@@ -118,7 +118,6 @@ export declare const ZodLanguageModelValues: z.ZodMiniEnum<{
118
118
  "workersai:@cf/meta/llama-3.2-11b-vision-instruct": "workersai:@cf/meta/llama-3.2-11b-vision-instruct";
119
119
  "workersai:@cf/defog/sqlcoder-7b-2": "workersai:@cf/defog/sqlcoder-7b-2";
120
120
  "workersai:@cf/microsoft/phi-2": "workersai:@cf/microsoft/phi-2";
121
- "workersai:@hf/meta-llama/meta-llama-3-8b-instruct": "workersai:@hf/meta-llama/meta-llama-3-8b-instruct";
122
121
  "workersai:@cf/openai/gpt-oss-20b": "workersai:@cf/openai/gpt-oss-20b";
123
122
  "workersai:@hf/google/gemma-7b-it": "workersai:@hf/google/gemma-7b-it";
124
123
  "workersai:@cf/qwen/qwen1.5-14b-chat-awq": "workersai:@cf/qwen/qwen1.5-14b-chat-awq";
@@ -663,16 +663,6 @@ export declare const workersAiCatalog: {
663
663
  readonly context_window: 2048;
664
664
  readonly info: "https://huggingface.co/microsoft/phi-2";
665
665
  };
666
- }, {
667
- readonly id: "1a7b6ad6-9987-4bd3-a329-20ee8de93296";
668
- readonly source: 2;
669
- readonly name: "@hf/meta-llama/meta-llama-3-8b-instruct";
670
- readonly description: "Generation over generation, Meta Llama 3 demonstrates state-of-the-art performance on a wide range of industry benchmarks and offers new capabilities, including improved reasoning.\t";
671
- readonly created_at: "2024-05-22 18:21:04.371";
672
- readonly tags: readonly [];
673
- readonly properties: {
674
- readonly context_window: 8192;
675
- };
676
666
  }, {
677
667
  readonly id: "188a4e1e-253e-46d0-9616-0bf8c149763f";
678
668
  readonly source: 1;
@@ -754,17 +754,6 @@ export const workersAiCatalog = {
754
754
  info: 'https://huggingface.co/microsoft/phi-2',
755
755
  },
756
756
  },
757
- {
758
- id: '1a7b6ad6-9987-4bd3-a329-20ee8de93296',
759
- source: 2,
760
- name: '@hf/meta-llama/meta-llama-3-8b-instruct',
761
- description: 'Generation over generation, Meta Llama 3 demonstrates state-of-the-art performance on a wide range of industry benchmarks and offers new capabilities, including improved reasoning.\t',
762
- created_at: '2024-05-22 18:21:04.371',
763
- tags: [],
764
- properties: {
765
- context_window: 8192,
766
- },
767
- },
768
757
  {
769
758
  id: '188a4e1e-253e-46d0-9616-0bf8c149763f',
770
759
  source: 1,
@@ -1,5 +1,32 @@
1
1
  export type D0Blob = [number, ...number[]];
2
- export declare enum ShardType {
3
- Director = 0,
2
+ export declare enum D0Version {
3
+ v1 = 1
4
+ }
5
+ export declare enum D0SystemType {
6
+ Dataspace = 1,
7
+ Tenant = 2,
8
+ User = 3,
9
+ Workflow = 4
10
+ }
11
+ export declare enum D0CombinedLocations {
12
+ none = 0,
13
+ eu = 1,
14
+ fedramp = 2,
15
+ wnam = 10,
16
+ enam = 11,
17
+ sam = 12,
18
+ weur = 13,
19
+ eeur = 14,
20
+ apac = 15,
21
+ oc = 16,
22
+ afr = 17,
23
+ me = 18
24
+ }
25
+ export declare enum D0ShardType {
26
+ None = 0,
4
27
  Storage = 1
5
28
  }
29
+ export declare enum D0Environment {
30
+ Production = 0,
31
+ Preview = 1
32
+ }
package/dist/d0/index.js CHANGED
@@ -1,5 +1,36 @@
1
- export var ShardType;
2
- (function (ShardType) {
3
- ShardType[ShardType["Director"] = 0] = "Director";
4
- ShardType[ShardType["Storage"] = 1] = "Storage";
5
- })(ShardType || (ShardType = {}));
1
+ export var D0Version;
2
+ (function (D0Version) {
3
+ D0Version[D0Version["v1"] = 1] = "v1";
4
+ })(D0Version || (D0Version = {}));
5
+ export var D0SystemType;
6
+ (function (D0SystemType) {
7
+ D0SystemType[D0SystemType["Dataspace"] = 1] = "Dataspace";
8
+ D0SystemType[D0SystemType["Tenant"] = 2] = "Tenant";
9
+ D0SystemType[D0SystemType["User"] = 3] = "User";
10
+ D0SystemType[D0SystemType["Workflow"] = 4] = "Workflow";
11
+ })(D0SystemType || (D0SystemType = {}));
12
+ export var D0CombinedLocations;
13
+ (function (D0CombinedLocations) {
14
+ D0CombinedLocations[D0CombinedLocations["none"] = 0] = "none";
15
+ D0CombinedLocations[D0CombinedLocations["eu"] = 1] = "eu";
16
+ D0CombinedLocations[D0CombinedLocations["fedramp"] = 2] = "fedramp";
17
+ D0CombinedLocations[D0CombinedLocations["wnam"] = 10] = "wnam";
18
+ D0CombinedLocations[D0CombinedLocations["enam"] = 11] = "enam";
19
+ D0CombinedLocations[D0CombinedLocations["sam"] = 12] = "sam";
20
+ D0CombinedLocations[D0CombinedLocations["weur"] = 13] = "weur";
21
+ D0CombinedLocations[D0CombinedLocations["eeur"] = 14] = "eeur";
22
+ D0CombinedLocations[D0CombinedLocations["apac"] = 15] = "apac";
23
+ D0CombinedLocations[D0CombinedLocations["oc"] = 16] = "oc";
24
+ D0CombinedLocations[D0CombinedLocations["afr"] = 17] = "afr";
25
+ D0CombinedLocations[D0CombinedLocations["me"] = 18] = "me";
26
+ })(D0CombinedLocations || (D0CombinedLocations = {}));
27
+ export var D0ShardType;
28
+ (function (D0ShardType) {
29
+ D0ShardType[D0ShardType["None"] = 0] = "None";
30
+ D0ShardType[D0ShardType["Storage"] = 1] = "Storage";
31
+ })(D0ShardType || (D0ShardType = {}));
32
+ export var D0Environment;
33
+ (function (D0Environment) {
34
+ D0Environment[D0Environment["Production"] = 0] = "Production";
35
+ D0Environment[D0Environment["Preview"] = 1] = "Preview";
36
+ })(D0Environment || (D0Environment = {}));
@@ -1,7 +1,5 @@
1
1
  import type { Buffer } from 'node:buffer';
2
2
  import * as z from 'zod/mini';
3
- import { ShardType } from '../d0/index.js';
4
- import { DOCombinedLocations } from '../index.js';
5
3
  export type PrefixedUuid = `${'t_' | 'd_' | 'u_'}${UuidExport['utf8']}${'' | '_p'}`;
6
4
  export interface UuidExport {
7
5
  utf8: ReturnType<typeof crypto.randomUUID>;
@@ -13,17 +11,7 @@ export interface UuidExport {
13
11
  export declare const UUIDExtract7: z.ZodMiniObject<{
14
12
  date: z.ZodMiniDate<unknown>;
15
13
  }, z.core.$strip>;
16
- export declare const UUIDExtract8: z.ZodMiniObject<{
17
- date: z.ZodMiniDate<unknown>;
18
- location: z.ZodMiniEnum<typeof DOCombinedLocations>;
19
- shardType: z.ZodMiniEnum<typeof ShardType>;
20
- suffix: z.ZodMiniOptional<z.ZodMiniObject<{
21
- hex: z.ZodMiniCustomStringFormat<"hex">;
22
- base64: z.ZodMiniBase64;
23
- base64url: z.ZodMiniBase64URL;
24
- }, z.core.$strip>>;
25
- }, z.core.$strip>;
26
- export type UUIDExtract = z.output<typeof UUIDExtract7> | z.output<typeof UUIDExtract8>;
14
+ export type UUIDExtract = z.output<typeof UUIDExtract7>;
27
15
  export type ISODateString = `${number}-${number}-${number}T${number}:${number}:${number}.${number}Z`;
28
16
  /**
29
17
  * Represents a cron expression string (in UTC time).
package/dist/d1/index.js CHANGED
@@ -1,15 +1,4 @@
1
1
  import * as z from 'zod/mini';
2
- import { ShardType } from '../d0/index.js';
3
- import { DOCombinedLocations } from '../index.js';
4
2
  export const UUIDExtract7 = z.object({
5
3
  date: z.coerce.date(),
6
4
  });
7
- export const UUIDExtract8 = z.extend(UUIDExtract7, {
8
- location: z.enum(DOCombinedLocations),
9
- shardType: z.enum(ShardType),
10
- suffix: z.optional(z.object({
11
- hex: z.hex().check(z.length(3)),
12
- base64: z.base64(),
13
- base64url: z.base64url(),
14
- })),
15
- });
package/dist/index.d.ts CHANGED
@@ -69,18 +69,4 @@ export declare enum DOLocations {
69
69
  'Africa' = "afr",
70
70
  'Middle East' = "me"
71
71
  }
72
- export declare enum DOCombinedLocations {
73
- none = 0,
74
- eu = 1,
75
- fedramp = 2,
76
- wnam = 10,
77
- enam = 11,
78
- sam = 12,
79
- weur = 13,
80
- eeur = 14,
81
- apac = 15,
82
- oc = 16,
83
- afr = 17,
84
- me = 18
85
- }
86
72
  export {};
package/dist/index.js CHANGED
@@ -21,18 +21,3 @@ export var DOLocations;
21
21
  DOLocations["Africa"] = "afr";
22
22
  DOLocations["Middle East"] = "me";
23
23
  })(DOLocations || (DOLocations = {}));
24
- export var DOCombinedLocations;
25
- (function (DOCombinedLocations) {
26
- DOCombinedLocations[DOCombinedLocations["none"] = 0] = "none";
27
- DOCombinedLocations[DOCombinedLocations["eu"] = 1] = "eu";
28
- DOCombinedLocations[DOCombinedLocations["fedramp"] = 2] = "fedramp";
29
- DOCombinedLocations[DOCombinedLocations["wnam"] = 10] = "wnam";
30
- DOCombinedLocations[DOCombinedLocations["enam"] = 11] = "enam";
31
- DOCombinedLocations[DOCombinedLocations["sam"] = 12] = "sam";
32
- DOCombinedLocations[DOCombinedLocations["weur"] = 13] = "weur";
33
- DOCombinedLocations[DOCombinedLocations["eeur"] = 14] = "eeur";
34
- DOCombinedLocations[DOCombinedLocations["apac"] = 15] = "apac";
35
- DOCombinedLocations[DOCombinedLocations["oc"] = 16] = "oc";
36
- DOCombinedLocations[DOCombinedLocations["afr"] = 17] = "afr";
37
- DOCombinedLocations[DOCombinedLocations["me"] = 18] = "me";
38
- })(DOCombinedLocations || (DOCombinedLocations = {}));
@@ -0,0 +1,30 @@
1
+ import type { infer as zInfer, ZodJSONSchema } from 'zod/v4';
2
+ import { z } from 'zod/v4';
3
+ export type JSON = zInfer<ZodJSONSchema>;
4
+ export declare const WorkflowId: z.ZodString;
5
+ export declare const DoId: z.ZodCustomStringFormat<"hex">;
6
+ export declare const ZodCoordinate: z.ZodString;
7
+ export declare const ZodBlob: z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodTransform<Uint8Array<ArrayBuffer>, Buffer<ArrayBufferLike>>>, z.ZodPipe<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<ArrayBuffer, ArrayBuffer>, z.ZodTransform<ArrayBuffer | SharedArrayBuffer, ArrayBuffer>>, z.ZodPipe<z.ZodCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodTransform<ArrayBuffer | SharedArrayBuffer, SharedArrayBuffer>>]>, z.ZodTransform<Uint8Array<ArrayBuffer | SharedArrayBuffer>, ArrayBuffer | SharedArrayBuffer>>, z.ZodPipe<z.ZodTuple<[z.ZodInt], z.ZodInt>, z.ZodTransform<Uint8Array<ArrayBuffer>, [number, ...number[]]>>]>;
8
+ export declare const ZodBlobExport: z.ZodPipe<z.ZodTuple<[z.ZodInt], z.ZodInt>, z.ZodTransform<Uint8Array<ArrayBuffer>, [number, ...number[]]>>;
9
+ export declare const PrefixedUuidRaw: z.ZodString;
10
+ export declare const PrefixedUuid7Raw: z.ZodString;
11
+ export declare const PrefixedUuid: z.ZodPipe<z.ZodString, z.ZodTransform<{
12
+ type: "dataspace" | "tenant" | "user";
13
+ value: string;
14
+ preview: boolean;
15
+ }, string>>;
16
+ export declare const PrefixedUuid7: z.ZodPipe<z.ZodString, z.ZodTransform<{
17
+ type: "dataspace" | "tenant" | "user";
18
+ value: string;
19
+ preview: boolean;
20
+ }, string>>;
21
+ export declare const ZodUuid: z.ZodUnion<readonly [z.ZodString, z.ZodUUID, z.ZodCustomStringFormat<"hex">, z.ZodBase64, z.ZodBase64URL]>;
22
+ export declare const ZodUuid4: z.ZodUnion<readonly [z.ZodUUID, z.ZodCustomStringFormat<"hex">, z.ZodBase64, z.ZodBase64URL]>;
23
+ export declare const ZodUuid7: z.ZodUnion<readonly [z.ZodString, z.ZodUUID, z.ZodCustomStringFormat<"hex">, z.ZodBase64, z.ZodBase64URL]>;
24
+ export declare const Zod4FakeUuidExport: z.ZodObject<{
25
+ utf8: z.ZodUUID;
26
+ hex: z.ZodCustomStringFormat<"hex">;
27
+ base64: z.ZodBase64;
28
+ base64url: z.ZodBase64URL;
29
+ }, z.core.$strip>;
30
+ export declare const ZodSuruId: z.ZodUnion<readonly [z.ZodCustomStringFormat<"hex">, z.ZodBase64, z.ZodBase64URL]>;
@@ -0,0 +1,105 @@
1
+ import { z } from 'zod/v4';
2
+ import { hexUuid4Regex, hexUuid7Regex, hexUuidRegex, prefixedUuid7Regex, prefixedUuidRegex } from '../zod-mini/index.js';
3
+ export const WorkflowId = z
4
+ .string()
5
+ .trim()
6
+ .max(64)
7
+ /**
8
+ * @link https://developers.cloudflare.com/workflows/reference/limits/
9
+ */
10
+ .regex(/^[a-zA-Z0-9_][a-zA-Z0-9-_]*$/);
11
+ export const DoId = z.hex().trim().length(64).toLowerCase();
12
+ export const ZodCoordinate = z
13
+ .string()
14
+ .trim()
15
+ .min(3)
16
+ .regex(new RegExp(/^-?\d+\.\d+$/i));
17
+ export const ZodBlob = z.union([
18
+ // Literal `node:buffer` type
19
+ z.instanceof(Buffer).transform((b) => new Uint8Array(b)),
20
+ // Uint8Array
21
+ z.instanceof(Uint8Array).transform((ui8a) => ui8a),
22
+ // ArrayBuffer
23
+ z
24
+ .union([
25
+ // Each one has to be manually specified
26
+ z.instanceof(ArrayBuffer).transform((ab) => ab),
27
+ z.instanceof(SharedArrayBuffer).transform((sab) => sab),
28
+ ])
29
+ .transform((abl) => new Uint8Array(abl)),
30
+ // D0Blob
31
+ z.tuple([z.int().min(0).max(255)], z.int().min(0).max(255)).transform((arr) => new Uint8Array(arr)),
32
+ ]);
33
+ export const ZodBlobExport = z.tuple([z.int().min(0).max(255)], z.int().min(0).max(255)).transform((arr) => new Uint8Array(arr));
34
+ export const PrefixedUuidRaw = z.string().trim().toLowerCase().min(38).max(40).regex(prefixedUuidRegex);
35
+ export const PrefixedUuid7Raw = z.string().trim().toLowerCase().min(38).max(40).regex(prefixedUuid7Regex);
36
+ export const PrefixedUuid = PrefixedUuidRaw.transform((value) => {
37
+ let type;
38
+ if (value.startsWith('d_')) {
39
+ type = 'dataspace';
40
+ }
41
+ else if (value.startsWith('t_')) {
42
+ type = 'tenant';
43
+ }
44
+ else if (value.startsWith('u_')) {
45
+ type = 'user';
46
+ }
47
+ else {
48
+ throw new Error('Invalid UUID prefix');
49
+ }
50
+ return { type, value, preview: value.endsWith('_p') };
51
+ });
52
+ export const PrefixedUuid7 = PrefixedUuid7Raw.transform((value) => {
53
+ let type;
54
+ if (value.startsWith('d_')) {
55
+ type = 'dataspace';
56
+ }
57
+ else if (value.startsWith('t_')) {
58
+ type = 'tenant';
59
+ }
60
+ else if (value.startsWith('u_')) {
61
+ type = 'user';
62
+ }
63
+ else {
64
+ throw new Error('Invalid UUID prefix');
65
+ }
66
+ return { type, value, preview: value.endsWith('_p') };
67
+ });
68
+ export const ZodUuid = z.union([
69
+ PrefixedUuidRaw,
70
+ // utf-8
71
+ z.uuid().trim().toLowerCase(),
72
+ // hex
73
+ z.hex().trim().toLowerCase().length(32).regex(hexUuidRegex),
74
+ z.base64().trim().nonempty(),
75
+ z.base64url().trim().nonempty(),
76
+ ]);
77
+ export const ZodUuid4 = z.union([
78
+ // utf-8
79
+ z.uuidv4().trim().toLowerCase(),
80
+ // hex
81
+ z.hex().trim().toLowerCase().length(32).regex(hexUuid4Regex),
82
+ z.base64().trim().nonempty(),
83
+ z.base64url().trim().nonempty(),
84
+ ]);
85
+ export const ZodUuid7 = z.union([
86
+ PrefixedUuid7Raw,
87
+ // utf-8
88
+ z.uuidv7().trim().toLowerCase(),
89
+ // hex
90
+ z.hex().trim().toLowerCase().length(32).regex(hexUuid7Regex),
91
+ z.base64().trim().nonempty(),
92
+ z.base64url().trim().nonempty(),
93
+ ]);
94
+ export const Zod4FakeUuidExport = z.object({
95
+ utf8: z.uuid().trim().toLowerCase(),
96
+ hex: z.hex().trim().toLowerCase().length(32).regex(hexUuidRegex),
97
+ base64: z.base64().trim().nonempty(),
98
+ base64url: z.base64url().trim().nonempty(),
99
+ });
100
+ export const ZodSuruId = z.union([
101
+ //
102
+ z.hex().trim().toLowerCase().length(96),
103
+ z.base64().trim().max(64),
104
+ z.base64url().trim().max(64),
105
+ ]);
@@ -0,0 +1,42 @@
1
+ import type { output, infer as zInfer, ZodMiniJSONSchema, ZodMiniObject, ZodMiniOptional } from 'zod/mini';
2
+ import * as z from 'zod/mini';
3
+ export type ZodPick<O extends ZodMiniObject> = Partial<Record<keyof output<O>, boolean>>;
4
+ export type ZodPickedKeys<P extends ZodPick<O>, O extends ZodMiniObject> = Extract<{
5
+ [K in keyof P]: P[K] extends true ? K : never;
6
+ }[keyof P], keyof output<O>>;
7
+ export type ZodPartial<T extends ZodMiniObject> = ZodMiniObject<{
8
+ [k in keyof T['shape']]: ZodMiniOptional<T['shape'][k]>;
9
+ }, T['_zod']['config']>;
10
+ export type JSON = zInfer<ZodMiniJSONSchema>;
11
+ export declare const WorkflowId: z.ZodMiniString<string>;
12
+ export declare const DoId: z.ZodMiniCustomStringFormat<"hex">;
13
+ export declare const ZodCoordinate: z.ZodMiniString<string>;
14
+ export declare const ZodBlob: z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>;
15
+ export declare const ZodBlobExport: z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>;
16
+ export declare const prefixedUuidRegex: RegExp;
17
+ export declare const hexUuidRegex: RegExp;
18
+ export declare const hexUuid4Regex: RegExp;
19
+ export declare const prefixedUuid7Regex: RegExp;
20
+ export declare const hexUuid7Regex: RegExp;
21
+ export declare const PrefixedUuidRaw: z.ZodMiniString<string>;
22
+ export declare const PrefixedUuid7Raw: z.ZodMiniString<string>;
23
+ export declare const PrefixedUuid: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<{
24
+ type: "dataspace" | "tenant" | "user";
25
+ value: string;
26
+ preview: boolean;
27
+ }, string>>;
28
+ export declare const PrefixedUuid7: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<{
29
+ type: "dataspace" | "tenant" | "user";
30
+ value: string;
31
+ preview: boolean;
32
+ }, string>>;
33
+ export declare const ZodUuid: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniUUID, z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniBase64, z.ZodMiniBase64URL]>;
34
+ export declare const ZodUuid4: z.ZodMiniUnion<readonly [z.ZodMiniUUID, z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniBase64, z.ZodMiniBase64URL]>;
35
+ export declare const ZodUuid7: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniUUID, z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniBase64, z.ZodMiniBase64URL]>;
36
+ export declare const Zod4FakeUuidExport: ZodMiniObject<{
37
+ utf8: z.ZodMiniUUID;
38
+ hex: z.ZodMiniCustomStringFormat<"hex">;
39
+ base64: z.ZodMiniBase64;
40
+ base64url: z.ZodMiniBase64URL;
41
+ }, z.core.$strip>;
42
+ export declare const ZodSuruId: z.ZodMiniUnion<readonly [z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>, z.ZodMiniBase64, z.ZodMiniBase64URL]>;
@@ -1,21 +1,33 @@
1
1
  import * as z from 'zod/mini';
2
- export const ZodCoordinate = z.string().check(z.trim(), z.minLength(3), z.regex(new RegExp(/^-?\d+\.\d+$/i)));
3
2
  export const WorkflowId = z.string().check(z.trim(), z.maxLength(64),
4
3
  /**
5
4
  * @link https://developers.cloudflare.com/workflows/reference/limits/
6
5
  */
7
6
  z.regex(/^[a-zA-Z0-9_][a-zA-Z0-9-_]*$/));
8
7
  export const DoId = z.hex().check(z.trim(), z.length(64), z.toLowerCase());
9
- const prefixedUuidRegex = /^((d|t|u)_)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(_p)?$/i;
10
- const hexUuidRegex = /^[0-9a-f]{8}[0-9a-f]{4}[0-9a-f]{4}[0-9a-f]{4}[0-9a-f]{12}$/i;
11
- const hexUuid4Regex = /^[0-9a-f]{8}[0-9a-f]{4}4[0-9a-f]{3}[0-9a-f]{4}[0-9a-f]{12}$/i;
12
- const prefixedUuid7Regex = /^((d|t|u)_)?[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}(_p)?$/i;
13
- const hexUuid7Regex = /^[0-9a-f]{8}[0-9a-f]{4}7[0-9a-f]{3}[0-9a-f]{4}[0-9a-f]{12}$/i;
14
- const prefixedUuid8Regex = /^((d|t|u)_)?[0-9a-f]{8}-[0-9a-f]{4}-8[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}(_p)?$/i;
15
- const hexUuid8Regex = /^[0-9a-f]{8}[0-9a-f]{4}8[0-9a-f]{3}[0-9a-f]{4}[0-9a-f]{12}$/i;
8
+ export const ZodCoordinate = z.string().check(z.trim(), z.minLength(3), z.regex(new RegExp(/^-?\d+\.\d+$/i)));
9
+ export const ZodBlob = z.union([
10
+ // Literal `node:buffer` type
11
+ z.pipe(z.instanceof(Buffer), z.transform((b) => new Uint8Array(b))),
12
+ // Uint8Array
13
+ z.pipe(z.instanceof(Uint8Array), z.transform((ui8a) => ui8a)),
14
+ // ArrayBuffer
15
+ z.pipe(z.union([
16
+ // Each one has to be manually specified
17
+ z.pipe(z.instanceof(ArrayBuffer), z.transform((ab) => ab)),
18
+ z.pipe(z.instanceof(SharedArrayBuffer), z.transform((sab) => sab)),
19
+ ]), z.transform((abl) => new Uint8Array(abl))),
20
+ // D0Blob
21
+ z.pipe(z.tuple([z.int().check(z.minimum(0), z.maximum(255))], z.int().check(z.minimum(0), z.maximum(255))), z.transform((arr) => new Uint8Array(arr))),
22
+ ]);
23
+ export const ZodBlobExport = z.tuple([z.int().check(z.minimum(0), z.maximum(255))], z.int().check(z.minimum(0), z.maximum(255)));
24
+ export const prefixedUuidRegex = /^((d|t|u)_)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(_p)?$/i;
25
+ export const hexUuidRegex = /^[0-9a-f]{8}[0-9a-f]{4}[0-9a-f]{4}[0-9a-f]{4}[0-9a-f]{12}$/i;
26
+ export const hexUuid4Regex = /^[0-9a-f]{8}[0-9a-f]{4}4[0-9a-f]{3}[0-9a-f]{4}[0-9a-f]{12}$/i;
27
+ export const prefixedUuid7Regex = /^((d|t|u)_)?[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}(_p)?$/i;
28
+ export const hexUuid7Regex = /^[0-9a-f]{8}[0-9a-f]{4}7[0-9a-f]{3}[0-9a-f]{4}[0-9a-f]{12}$/i;
16
29
  export const PrefixedUuidRaw = z.string().check(z.trim(), z.toLowerCase(), z.minLength(38), z.maxLength(40), z.regex(prefixedUuidRegex));
17
30
  export const PrefixedUuid7Raw = z.string().check(z.trim(), z.toLowerCase(), z.minLength(38), z.maxLength(40), z.regex(prefixedUuid7Regex));
18
- export const PrefixedUuid8Raw = z.string().check(z.trim(), z.toLowerCase(), z.minLength(38), z.maxLength(40), z.regex(prefixedUuid8Regex));
19
31
  export const PrefixedUuid = z.pipe(PrefixedUuidRaw, z.transform((value) => {
20
32
  let type;
21
33
  if (value.startsWith('d_')) {
@@ -48,22 +60,6 @@ export const PrefixedUuid7 = z.pipe(PrefixedUuid7Raw, z.transform((value) => {
48
60
  }
49
61
  return { type, value, preview: value.endsWith('_p') };
50
62
  }));
51
- export const PrefixedUuid8 = z.pipe(PrefixedUuid8Raw, z.transform((value) => {
52
- let type;
53
- if (value.startsWith('d_')) {
54
- type = 'dataspace';
55
- }
56
- else if (value.startsWith('t_')) {
57
- type = 'tenant';
58
- }
59
- else if (value.startsWith('u_')) {
60
- type = 'user';
61
- }
62
- else {
63
- throw new Error('Invalid UUID prefix');
64
- }
65
- return { type, value, preview: value.endsWith('_p') };
66
- }));
67
63
  export const ZodUuid = z.union([
68
64
  PrefixedUuidRaw,
69
65
  // utf-8
@@ -90,18 +86,16 @@ export const ZodUuid7 = z.union([
90
86
  z.base64().check(z.trim(), z.minLength(1)),
91
87
  z.base64url().check(z.trim(), z.minLength(1)),
92
88
  ]);
93
- export const ZodUuid8 = z.union([
94
- PrefixedUuid8Raw,
95
- // utf-8
96
- z.uuid({ version: 'v8' }).check(z.trim(), z.toLowerCase()),
97
- // hex
98
- z.hex().check(z.trim(), z.toLowerCase(), z.length(32), z.regex(hexUuid8Regex)),
99
- z.base64().check(z.trim(), z.minLength(1)),
100
- z.base64url().check(z.trim(), z.minLength(1)),
101
- ]);
102
89
  export const Zod4FakeUuidExport = z.object({
103
90
  utf8: z.uuid().check(z.trim(), z.toLowerCase()),
104
91
  hex: z.hex().check(z.trim(), z.toLowerCase(), z.length(32), z.regex(hexUuidRegex)),
105
92
  base64: z.base64().check(z.trim(), z.minLength(1)),
106
93
  base64url: z.base64url().check(z.trim(), z.minLength(1)),
107
94
  });
95
+ export const ZodSuruId = z.union([
96
+ //
97
+ z.hex().check(z.trim(), z.toLowerCase(), z.length(96)),
98
+ ZodBlob,
99
+ z.base64().check(z.trim(), z.maxLength(64)),
100
+ z.base64url().check(z.trim(), z.maxLength(64)),
101
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainfuse/types",
3
- "version": "3.0.8",
3
+ "version": "4.0.1",
4
4
  "description": "",
5
5
  "author": "ChainFuse",
6
6
  "homepage": "https://github.com/ChainFuse/packages/tree/main/packages/types#readme",
@@ -87,19 +87,23 @@
87
87
  "import": "./dist/discourse/topic/index.js",
88
88
  "types": "./dist/discourse/topic/index.d.ts"
89
89
  },
90
- "./zod": {
91
- "import": "./dist/zod/index.js",
92
- "types": "./dist/zod/index.d.ts"
90
+ "./zod-mini": {
91
+ "import": "./dist/zod-mini/index.js",
92
+ "types": "./dist/zod-mini/index.d.ts"
93
+ },
94
+ "./zod-4": {
95
+ "import": "./dist/zod-4/index.js",
96
+ "types": "./dist/zod-4/index.d.ts"
93
97
  }
94
98
  },
95
99
  "prettier": "@demosjarco/prettier-config",
96
100
  "dependencies": {
97
101
  "validator": "^13.15.15",
98
- "zod": "^4.1.8"
102
+ "zod": "^4.1.11"
99
103
  },
100
104
  "devDependencies": {
101
- "@cloudflare/workers-types": "^4.20250913.0",
105
+ "@cloudflare/workers-types": "^4.20250923.0",
102
106
  "@types/validator": "^13.15.3"
103
107
  },
104
- "gitHead": "3bcadb3f4996a6725b5530d2dccd72dd0681c6b8"
108
+ "gitHead": "ab58de73242e411360ae80368ee2f69a5798c653"
105
109
  }
@@ -1,41 +0,0 @@
1
- import type { output, infer as zInfer, ZodMiniJSONSchema, ZodMiniObject, ZodMiniOptional } from 'zod/mini';
2
- import * as z from 'zod/mini';
3
- export type ZodPick<O extends ZodMiniObject> = Partial<Record<keyof output<O>, boolean>>;
4
- export type ZodPickedKeys<P extends ZodPick<O>, O extends ZodMiniObject> = Extract<{
5
- [K in keyof P]: P[K] extends true ? K : never;
6
- }[keyof P], keyof output<O>>;
7
- export type ZodPartial<T extends ZodMiniObject> = ZodMiniObject<{
8
- [k in keyof T['shape']]: ZodMiniOptional<T['shape'][k]>;
9
- }, T['_zod']['config']>;
10
- export type JSON = zInfer<ZodMiniJSONSchema>;
11
- export declare const ZodCoordinate: z.ZodMiniString<string>;
12
- export declare const WorkflowId: z.ZodMiniString<string>;
13
- export declare const DoId: z.ZodMiniCustomStringFormat<"hex">;
14
- export declare const PrefixedUuidRaw: z.ZodMiniString<string>;
15
- export declare const PrefixedUuid7Raw: z.ZodMiniString<string>;
16
- export declare const PrefixedUuid8Raw: z.ZodMiniString<string>;
17
- export declare const PrefixedUuid: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<{
18
- type: "dataspace" | "tenant" | "user";
19
- value: string;
20
- preview: boolean;
21
- }, string>>;
22
- export declare const PrefixedUuid7: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<{
23
- type: "dataspace" | "tenant" | "user";
24
- value: string;
25
- preview: boolean;
26
- }, string>>;
27
- export declare const PrefixedUuid8: z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<{
28
- type: "dataspace" | "tenant" | "user";
29
- value: string;
30
- preview: boolean;
31
- }, string>>;
32
- export declare const ZodUuid: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniUUID, z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniBase64, z.ZodMiniBase64URL]>;
33
- export declare const ZodUuid4: z.ZodMiniUnion<readonly [z.ZodMiniUUID, z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniBase64, z.ZodMiniBase64URL]>;
34
- export declare const ZodUuid7: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniUUID, z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniBase64, z.ZodMiniBase64URL]>;
35
- export declare const ZodUuid8: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniUUID, z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniBase64, z.ZodMiniBase64URL]>;
36
- export declare const Zod4FakeUuidExport: ZodMiniObject<{
37
- utf8: z.ZodMiniUUID;
38
- hex: z.ZodMiniCustomStringFormat<"hex">;
39
- base64: z.ZodMiniBase64;
40
- base64url: z.ZodMiniBase64URL;
41
- }, z.core.$strip>;