@chainfuse/types 3.0.8 → 4.0.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.
@@ -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>;
@@ -0,0 +1,34 @@
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 PrefixedUuidRaw: z.ZodString;
8
+ export declare const PrefixedUuid7Raw: z.ZodString;
9
+ export declare const PrefixedUuid8Raw: z.ZodString;
10
+ export declare const PrefixedUuid: z.ZodPipe<z.ZodString, z.ZodTransform<{
11
+ type: "dataspace" | "tenant" | "user";
12
+ value: string;
13
+ preview: boolean;
14
+ }, string>>;
15
+ export declare const PrefixedUuid7: z.ZodPipe<z.ZodString, z.ZodTransform<{
16
+ type: "dataspace" | "tenant" | "user";
17
+ value: string;
18
+ preview: boolean;
19
+ }, string>>;
20
+ export declare const PrefixedUuid8: z.ZodPipe<z.ZodString, z.ZodTransform<{
21
+ type: "dataspace" | "tenant" | "user";
22
+ value: string;
23
+ preview: boolean;
24
+ }, string>>;
25
+ export declare const ZodUuid: z.ZodUnion<readonly [z.ZodString, z.ZodUUID, z.ZodCustomStringFormat<"hex">, z.ZodBase64, z.ZodBase64URL]>;
26
+ export declare const ZodUuid4: z.ZodUnion<readonly [z.ZodUUID, z.ZodCustomStringFormat<"hex">, z.ZodBase64, z.ZodBase64URL]>;
27
+ export declare const ZodUuid7: z.ZodUnion<readonly [z.ZodString, z.ZodUUID, z.ZodCustomStringFormat<"hex">, z.ZodBase64, z.ZodBase64URL]>;
28
+ export declare const ZodUuid8: z.ZodUnion<readonly [z.ZodString, z.ZodUUID, z.ZodCustomStringFormat<"hex">, z.ZodBase64, z.ZodBase64URL]>;
29
+ export declare const Zod4FakeUuidExport: z.ZodObject<{
30
+ utf8: z.ZodUUID;
31
+ hex: z.ZodCustomStringFormat<"hex">;
32
+ base64: z.ZodBase64;
33
+ base64url: z.ZodBase64URL;
34
+ }, z.core.$strip>;
@@ -0,0 +1,108 @@
1
+ import { z } from 'zod/v4';
2
+ import { hexUuid4Regex, hexUuid7Regex, hexUuid8Regex, hexUuidRegex, prefixedUuid7Regex, prefixedUuid8Regex, 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 PrefixedUuidRaw = z.string().trim().toLowerCase().min(38).max(40).regex(prefixedUuidRegex);
18
+ export const PrefixedUuid7Raw = z.string().trim().toLowerCase().min(38).max(40).regex(prefixedUuid7Regex);
19
+ export const PrefixedUuid8Raw = z.string().trim().toLowerCase().min(38).max(40).regex(prefixedUuid8Regex);
20
+ export const PrefixedUuid = PrefixedUuidRaw.transform((value) => {
21
+ let type;
22
+ if (value.startsWith('d_')) {
23
+ type = 'dataspace';
24
+ }
25
+ else if (value.startsWith('t_')) {
26
+ type = 'tenant';
27
+ }
28
+ else if (value.startsWith('u_')) {
29
+ type = 'user';
30
+ }
31
+ else {
32
+ throw new Error('Invalid UUID prefix');
33
+ }
34
+ return { type, value, preview: value.endsWith('_p') };
35
+ });
36
+ export const PrefixedUuid7 = PrefixedUuid7Raw.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 PrefixedUuid8 = PrefixedUuid8Raw.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 ZodUuid8 = z.union([
95
+ PrefixedUuid8Raw,
96
+ // utf-8
97
+ z.uuid({ version: 'v8' }).trim().toLowerCase(),
98
+ // hex
99
+ z.hex().trim().toLowerCase().length(32).regex(hexUuid8Regex),
100
+ z.base64().trim().nonempty(),
101
+ z.base64url().trim().nonempty(),
102
+ ]);
103
+ export const Zod4FakeUuidExport = z.object({
104
+ utf8: z.uuid().trim().toLowerCase(),
105
+ hex: z.hex().trim().toLowerCase().length(32).regex(hexUuidRegex),
106
+ base64: z.base64().trim().nonempty(),
107
+ base64url: z.base64url().trim().nonempty(),
108
+ });
@@ -8,9 +8,16 @@ export type ZodPartial<T extends ZodMiniObject> = ZodMiniObject<{
8
8
  [k in keyof T['shape']]: ZodMiniOptional<T['shape'][k]>;
9
9
  }, T['_zod']['config']>;
10
10
  export type JSON = zInfer<ZodMiniJSONSchema>;
11
- export declare const ZodCoordinate: z.ZodMiniString<string>;
12
11
  export declare const WorkflowId: z.ZodMiniString<string>;
13
12
  export declare const DoId: z.ZodMiniCustomStringFormat<"hex">;
13
+ export declare const ZodCoordinate: z.ZodMiniString<string>;
14
+ export declare const prefixedUuidRegex: RegExp;
15
+ export declare const hexUuidRegex: RegExp;
16
+ export declare const hexUuid4Regex: RegExp;
17
+ export declare const prefixedUuid7Regex: RegExp;
18
+ export declare const hexUuid7Regex: RegExp;
19
+ export declare const prefixedUuid8Regex: RegExp;
20
+ export declare const hexUuid8Regex: RegExp;
14
21
  export declare const PrefixedUuidRaw: z.ZodMiniString<string>;
15
22
  export declare const PrefixedUuid7Raw: z.ZodMiniString<string>;
16
23
  export declare const PrefixedUuid8Raw: z.ZodMiniString<string>;
@@ -1,18 +1,18 @@
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 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
+ export const hexUuidRegex = /^[0-9a-f]{8}[0-9a-f]{4}[0-9a-f]{4}[0-9a-f]{4}[0-9a-f]{12}$/i;
11
+ 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;
12
+ 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;
13
+ 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;
14
+ export 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
+ export const hexUuid8Regex = /^[0-9a-f]{8}[0-9a-f]{4}8[0-9a-f]{3}[0-9a-f]{4}[0-9a-f]{12}$/i;
16
16
  export const PrefixedUuidRaw = z.string().check(z.trim(), z.toLowerCase(), z.minLength(38), z.maxLength(40), z.regex(prefixedUuidRegex));
17
17
  export const PrefixedUuid7Raw = z.string().check(z.trim(), z.toLowerCase(), z.minLength(38), z.maxLength(40), z.regex(prefixedUuid7Regex));
18
18
  export const PrefixedUuid8Raw = z.string().check(z.trim(), z.toLowerCase(), z.minLength(38), z.maxLength(40), z.regex(prefixedUuid8Regex));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainfuse/types",
3
- "version": "3.0.8",
3
+ "version": "4.0.0",
4
4
  "description": "",
5
5
  "author": "ChainFuse",
6
6
  "homepage": "https://github.com/ChainFuse/packages/tree/main/packages/types#readme",
@@ -87,9 +87,13 @@
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",
@@ -101,5 +105,5 @@
101
105
  "@cloudflare/workers-types": "^4.20250913.0",
102
106
  "@types/validator": "^13.15.3"
103
107
  },
104
- "gitHead": "3bcadb3f4996a6725b5530d2dccd72dd0681c6b8"
108
+ "gitHead": "024d8452ccb2992f76e33377742270639c53b7e9"
105
109
  }