@xyo-network/payload-model 5.1.19 → 5.1.20
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/dist/neutral/PayloadBundle.d.ts +1 -1
- package/dist/neutral/PayloadZod.d.ts +38 -106
- package/dist/neutral/PayloadZod.d.ts.map +1 -1
- package/dist/neutral/Schema.d.ts +3 -3
- package/dist/neutral/Schema.d.ts.map +1 -1
- package/dist/neutral/StorageMeta/DataHash.d.ts +2 -2
- package/dist/neutral/StorageMeta/Hash.d.ts +2 -2
- package/dist/neutral/StorageMeta/Sequence.d.ts +1 -1
- package/dist/neutral/StorageMeta/StorageMeta.d.ts +1 -1
- package/dist/neutral/StorageMeta/sequence/SequenceZod.d.ts +1 -1
- package/dist/neutral/StorageMeta/sequence/SequenceZod.d.ts.map +1 -1
- package/dist/neutral/index.mjs +8 -4
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +9 -9
- package/src/PayloadZod.ts +16 -3
- package/src/Schema.ts +1 -1
- package/src/StorageMeta/sequence/SequenceZod.ts +1 -1
|
@@ -9,5 +9,5 @@ export interface PayloadBundleFields<T extends Payload = Payload> {
|
|
|
9
9
|
export type PayloadBundle = Payload<PayloadBundleFields, PayloadBundleSchema>;
|
|
10
10
|
export declare const isPayloadBundle: (x?: unknown | null) => x is PayloadBundle;
|
|
11
11
|
export declare const asPayloadBundle: import("@xylabs/object").AsTypeFunction<PayloadBundle>;
|
|
12
|
-
export declare const asOptionalPayloadBundle: (value: import(".store/@xylabs-promise-npm-5.0.
|
|
12
|
+
export declare const asOptionalPayloadBundle: (value: import(".store/@xylabs-promise-npm-5.0.24-e9749bb6a6/package").AnyNonPromise) => PayloadBundle | undefined;
|
|
13
13
|
//# sourceMappingURL=PayloadBundle.d.ts.map
|
|
@@ -1,144 +1,76 @@
|
|
|
1
|
-
import
|
|
1
|
+
import z from 'zod';
|
|
2
2
|
export declare const HashMetaZod: z.ZodObject<{
|
|
3
|
-
_hash: z.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readonly __hash: true;
|
|
7
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
8
|
-
readonly __hex: true;
|
|
9
|
-
}>, {
|
|
10
|
-
readonly __hash: true;
|
|
11
|
-
}>, unknown>>;
|
|
12
|
-
_dataHash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
13
|
-
readonly __hex: true;
|
|
14
|
-
}>, {
|
|
15
|
-
readonly __hash: true;
|
|
16
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
17
|
-
readonly __hex: true;
|
|
18
|
-
}>, {
|
|
19
|
-
readonly __hash: true;
|
|
20
|
-
}>, unknown>>;
|
|
21
|
-
}, z.core.$strip>;
|
|
3
|
+
_hash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
4
|
+
_dataHash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
5
|
+
}, z.z.core.$strip>;
|
|
22
6
|
export declare const SequenceMetaZod: z.ZodObject<{
|
|
23
7
|
_sequence: z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").LocalSequence, string>>, z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").QualifiedSequence, string>>]>;
|
|
24
|
-
}, z.core.$strip>;
|
|
8
|
+
}, z.z.core.$strip>;
|
|
25
9
|
export declare const StorageMetaZod: z.ZodObject<{
|
|
26
|
-
_hash: z.
|
|
27
|
-
|
|
28
|
-
}>, {
|
|
29
|
-
readonly __hash: true;
|
|
30
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
31
|
-
readonly __hex: true;
|
|
32
|
-
}>, {
|
|
33
|
-
readonly __hash: true;
|
|
34
|
-
}>, unknown>>;
|
|
35
|
-
_dataHash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
36
|
-
readonly __hex: true;
|
|
37
|
-
}>, {
|
|
38
|
-
readonly __hash: true;
|
|
39
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
40
|
-
readonly __hex: true;
|
|
41
|
-
}>, {
|
|
42
|
-
readonly __hash: true;
|
|
43
|
-
}>, unknown>>;
|
|
10
|
+
_hash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
11
|
+
_dataHash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
44
12
|
_sequence: z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").LocalSequence, string>>, z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").QualifiedSequence, string>>]>;
|
|
45
|
-
}, z.core.$strip>;
|
|
13
|
+
}, z.z.core.$strip>;
|
|
46
14
|
export declare const PayloadZod: z.ZodObject<{
|
|
47
15
|
schema: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
48
16
|
__schema: true;
|
|
49
17
|
}, string>>]>;
|
|
50
|
-
}, z.core.$strip>;
|
|
18
|
+
}, z.z.core.$strip>;
|
|
19
|
+
/** @deprecated use WithStorageMetaZod */
|
|
51
20
|
export declare const PayloadWithStorageMetaZod: z.ZodObject<{
|
|
52
21
|
schema: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
53
22
|
__schema: true;
|
|
54
23
|
}, string>>]>;
|
|
55
|
-
_hash: z.
|
|
56
|
-
|
|
57
|
-
}>, {
|
|
58
|
-
readonly __hash: true;
|
|
59
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
60
|
-
readonly __hex: true;
|
|
61
|
-
}>, {
|
|
62
|
-
readonly __hash: true;
|
|
63
|
-
}>, unknown>>;
|
|
64
|
-
_dataHash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
65
|
-
readonly __hex: true;
|
|
66
|
-
}>, {
|
|
67
|
-
readonly __hash: true;
|
|
68
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
69
|
-
readonly __hex: true;
|
|
70
|
-
}>, {
|
|
71
|
-
readonly __hash: true;
|
|
72
|
-
}>, unknown>>;
|
|
24
|
+
_hash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
25
|
+
_dataHash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
73
26
|
_sequence: z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").LocalSequence, string>>, z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").QualifiedSequence, string>>]>;
|
|
74
|
-
}, z.core.$strip>;
|
|
27
|
+
}, z.z.core.$strip>;
|
|
75
28
|
export declare const AnyPayloadZod: z.ZodObject<{
|
|
76
29
|
schema: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
77
30
|
__schema: true;
|
|
78
31
|
}, string>>]>;
|
|
79
|
-
}, z.core.$catchall<z.ZodJSONSchema>>;
|
|
32
|
+
}, z.z.core.$catchall<z.ZodJSONSchema>>;
|
|
33
|
+
/** @deprecated use WithStorageMetaZod */
|
|
80
34
|
export declare const AnyPayloadWithStorageMetaZod: z.ZodObject<{
|
|
81
35
|
schema: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
82
36
|
__schema: true;
|
|
83
37
|
}, string>>]>;
|
|
84
|
-
_hash: z.
|
|
85
|
-
|
|
86
|
-
}>, {
|
|
87
|
-
readonly __hash: true;
|
|
88
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
89
|
-
readonly __hex: true;
|
|
90
|
-
}>, {
|
|
91
|
-
readonly __hash: true;
|
|
92
|
-
}>, unknown>>;
|
|
93
|
-
_dataHash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
94
|
-
readonly __hex: true;
|
|
95
|
-
}>, {
|
|
96
|
-
readonly __hash: true;
|
|
97
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
98
|
-
readonly __hex: true;
|
|
99
|
-
}>, {
|
|
100
|
-
readonly __hash: true;
|
|
101
|
-
}>, unknown>>;
|
|
38
|
+
_hash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
39
|
+
_dataHash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
102
40
|
_sequence: z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").LocalSequence, string>>, z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").QualifiedSequence, string>>]>;
|
|
103
|
-
}, z.core.$catchall<z.ZodJSONSchema>>;
|
|
41
|
+
}, z.z.core.$catchall<z.ZodJSONSchema>>;
|
|
42
|
+
/** @deprecated use WithStorageMetaZod */
|
|
104
43
|
export type PayloadWithStorageMeta = z.infer<typeof PayloadWithStorageMetaZod>;
|
|
105
44
|
export type AnyPayload = z.infer<typeof AnyPayloadZod>;
|
|
45
|
+
/** @deprecated use WithStorageMetaZod */
|
|
106
46
|
export type AnyPayloadWithStorageMeta = z.infer<typeof AnyPayloadWithStorageMetaZod>;
|
|
107
|
-
export declare function WithStorageMetaZod<T extends
|
|
108
|
-
_hash: z.
|
|
109
|
-
|
|
110
|
-
}>, {
|
|
111
|
-
readonly __hash: true;
|
|
112
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
113
|
-
readonly __hex: true;
|
|
114
|
-
}>, {
|
|
115
|
-
readonly __hash: true;
|
|
116
|
-
}>, unknown>>;
|
|
117
|
-
_dataHash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
118
|
-
readonly __hex: true;
|
|
119
|
-
}>, {
|
|
120
|
-
readonly __hash: true;
|
|
121
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
122
|
-
readonly __hex: true;
|
|
123
|
-
}>, {
|
|
124
|
-
readonly __hash: true;
|
|
125
|
-
}>, unknown>>;
|
|
47
|
+
export declare function WithStorageMetaZod<T extends z.ZodRawShape>(valueZod: z.ZodObject<T>): z.ZodObject<(keyof T & ("_hash" | "_dataHash" | "_sequence") extends never ? T & {
|
|
48
|
+
_hash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
49
|
+
_dataHash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
126
50
|
_sequence: z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").LocalSequence, string>>, z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").QualifiedSequence, string>>]>;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
51
|
+
} : { [K in keyof T as K extends "_hash" | "_dataHash" | "_sequence" ? never : K]: T[K]; } & {
|
|
52
|
+
_hash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
53
|
+
_dataHash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
54
|
+
_sequence: z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").LocalSequence, string>>, z.ZodPipe<z.ZodString, z.ZodTransform<import("./StorageMeta/index.ts").QualifiedSequence, string>>]>;
|
|
55
|
+
}) extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.z.core.$strip>;
|
|
56
|
+
export declare function WithHashMetaZod<T extends z.ZodRawShape>(valueZod: z.ZodObject<T>): z.ZodObject<(keyof T & ("_hash" | "_dataHash") extends never ? T & {
|
|
57
|
+
_hash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
58
|
+
_dataHash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
59
|
+
} : { [K in keyof T as K extends "_hash" | "_dataHash" ? never : K]: T[K]; } & {
|
|
60
|
+
_hash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
61
|
+
_dataHash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
62
|
+
}) extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.z.core.$strip>;
|
|
131
63
|
export declare const PayloadZodStrict: z.ZodObject<{
|
|
132
64
|
schema: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
133
65
|
__schema: true;
|
|
134
66
|
}, string>>]>;
|
|
135
|
-
}, z.core.$strict>;
|
|
67
|
+
}, z.z.core.$strict>;
|
|
136
68
|
export type PayloadZodStrict = typeof PayloadZodStrict;
|
|
137
69
|
export declare const PayloadZodLoose: PayloadZodStrict;
|
|
138
70
|
export declare const PayloadZodStrictOfSchema: <S extends string>(schema: S) => z.ZodObject<{
|
|
139
71
|
schema: z.ZodLiteral<S>;
|
|
140
|
-
}, z.core.$strict>;
|
|
72
|
+
}, z.z.core.$strict>;
|
|
141
73
|
export declare const PayloadZodLooseOfSchema: <S extends string>(schema: S) => z.ZodObject<{
|
|
142
74
|
schema: z.ZodLiteral<S>;
|
|
143
|
-
}, z.core.$strict>;
|
|
75
|
+
}, z.z.core.$strict>;
|
|
144
76
|
//# sourceMappingURL=PayloadZod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayloadZod.d.ts","sourceRoot":"","sources":["../../src/PayloadZod.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"PayloadZod.d.ts","sourceRoot":"","sources":["../../src/PayloadZod.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,KAAK,CAAA;AAKnB,eAAO,MAAM,WAAW;;;mBAGtB,CAAA;AAEF,eAAO,MAAM,eAAe;;mBAAiD,CAAA;AAE7E,eAAO,MAAM,cAAc;;;;mBAIzB,CAAA;AAEF,eAAO,MAAM,UAAU;;;;mBAAkC,CAAA;AAEzD,yCAAyC;AACzC,eAAO,MAAM,yBAAyB;;;;;;;mBAA0C,CAAA;AAEhF,eAAO,MAAM,aAAa;;;;uCAAgC,CAAA;AAE1D,yCAAyC;AACzC,eAAO,MAAM,4BAA4B;;;;;;;uCAA6C,CAAA;AAEtF,yCAAyC;AAEzC,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAE9E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AAEtD,yCAAyC;AAEzC,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAEpF,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;;;;;;;;+EAEnF;AAED,wBAAgB,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;;;;;;+EAEhF;AAED,eAAO,MAAM,gBAAgB;;;;oBAAwC,CAAA;AACrE,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAA;AACtD,eAAO,MAAM,eAAe,EAAE,gBAAuD,CAAA;AAErF,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,MAAM,EAAE,QAAQ,CAAC;;oBAA2D,CAAA;AAC/H,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,MAAM,EAAE,QAAQ,CAAC;;oBAA0D,CAAA"}
|
package/dist/neutral/Schema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EmptyObject } from '@xylabs/object';
|
|
2
|
-
import
|
|
2
|
+
import z from 'zod';
|
|
3
3
|
export declare const SchemaRegEx: RegExp;
|
|
4
4
|
export declare const SchemaZodV1: z.ZodString;
|
|
5
5
|
export declare const SchemaZodV2: z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
@@ -11,9 +11,9 @@ export declare const SchemaZod: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.Zo
|
|
|
11
11
|
__schema: true;
|
|
12
12
|
}, string>>]>;
|
|
13
13
|
export type Schema = z.infer<typeof SchemaZodV1>;
|
|
14
|
-
export declare const makeSchema: <T extends string>(value: T) => z.ZodPipe<z.ZodTemplateLiteral<z.ZodLiteral<T> extends infer T_1 ? T_1 extends z.ZodLiteral<T> ? T_1 extends z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? `${z.core.output<T_1> extends infer T_2 extends string | number | bigint | boolean | null | undefined ? T_2 extends undefined ? "" : T_2 : never}` : never : never : never>, z.ZodTransform<Awaited<(z.ZodLiteral<T> extends infer T_3 ? T_3 extends z.ZodLiteral<T> ? T_3 extends z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? `${z.core.output<T_3> extends infer T_2 extends string | number | bigint | boolean | null | undefined ? T_2 extends undefined ? "" : T_2 : never}` : never : never : never) & {
|
|
14
|
+
export declare const makeSchema: <T extends string>(value: T) => z.ZodPipe<z.ZodTemplateLiteral<z.ZodLiteral<T> extends infer T_1 ? T_1 extends z.ZodLiteral<T> ? T_1 extends z.z.core.$ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>> ? `${z.z.core.output<T_1> extends infer T_2 extends string | number | bigint | boolean | null | undefined ? T_2 extends undefined ? "" : T_2 : never}` : never : never : never>, z.ZodTransform<Awaited<(z.ZodLiteral<T> extends infer T_3 ? T_3 extends z.ZodLiteral<T> ? T_3 extends z.z.core.$ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>> ? `${z.z.core.output<T_3> extends infer T_2 extends string | number | bigint | boolean | null | undefined ? T_2 extends undefined ? "" : T_2 : never}` : never : never : never) & {
|
|
15
15
|
__schema: true;
|
|
16
|
-
}>, z.ZodLiteral<T> extends infer T_4 ? T_4 extends z.ZodLiteral<T> ? T_4 extends z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? `${z.core.output<T_4> extends infer T_2 extends string | number | bigint | boolean | null | undefined ? T_2 extends undefined ? "" : T_2 : never}` : never : never : never>>;
|
|
16
|
+
}>, z.ZodLiteral<T> extends infer T_4 ? T_4 extends z.ZodLiteral<T> ? T_4 extends z.z.core.$ZodType<unknown, unknown, z.z.core.$ZodTypeInternals<unknown, unknown>> ? `${z.z.core.output<T_4> extends infer T_2 extends string | number | bigint | boolean | null | undefined ? T_2 extends undefined ? "" : T_2 : never}` : never : never : never>>;
|
|
17
17
|
export declare const PayloadSchema: "network.xyo.payload";
|
|
18
18
|
export declare const PayloadSchemaZod: z.ZodLiteral<"network.xyo.payload">;
|
|
19
19
|
export type PayloadSchema = z.infer<typeof PayloadSchemaZod>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/Schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,OAAO,
|
|
1
|
+
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/Schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,eAAO,MAAM,WAAW,QAAgC,CAAA;AAExD,eAAO,MAAM,WAAW,aAAgC,CAAA;AACxD,eAAO,MAAM,WAAW;cAA6E,IAAI;WAAI,CAAA;AAC7G,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA;AACnD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA;AACnD,eAAO,MAAM,SAAS;cAH+E,IAAI;aAG7C,CAAA;AAC5D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AAEhD,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,EAAE,OAAO,CAAC;cACwC,IAAI;oVAChG,CAAA;AAED,eAAO,MAAM,aAAa,EAAG,qBAA8B,CAAA;AAC3D,eAAO,MAAM,gBAAgB,qCAA2B,CAAA;AACxD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE5D,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAElD,CAAA;AAED,eAAO,MAAM,QAAQ,iDAAyC,CAAA;AAE9D,yCAAyC;AACzC,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,WAAW,GAAG,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,WAAW,GAAG,YAAY,GAAG,CAAC,GAAG,YAAY,CAAA;AAErH,kCAAkC;AAClC,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAA;CACf"}
|
|
@@ -7,7 +7,7 @@ export type WithDataHashMeta<T extends Payload = Payload> = T & DataHashMeta;
|
|
|
7
7
|
export type WithPartialDataHashMeta<T extends Payload = Payload> = Partial<WithDataHashMeta<T>>;
|
|
8
8
|
export declare const isDataHashMeta: (value: unknown) => value is DataHashMeta;
|
|
9
9
|
export declare const asDataHashMeta: import("@xylabs/object").AsTypeFunction<DataHashMeta>;
|
|
10
|
-
export declare const asOptionalDataHashMeta: (value: import(".store/@xylabs-promise-npm-5.0.
|
|
10
|
+
export declare const asOptionalDataHashMeta: (value: import(".store/@xylabs-promise-npm-5.0.24-e9749bb6a6/package").AnyNonPromise) => DataHashMeta | undefined;
|
|
11
11
|
/** @deprecated use DataHashMeta instead */
|
|
12
12
|
export interface DataHashStorageMeta extends DataHashMeta {
|
|
13
13
|
}
|
|
@@ -20,5 +20,5 @@ export declare const isDataHashStorageMeta: (value: unknown) => value is DataHas
|
|
|
20
20
|
/** @deprecated use asDataHashMeta instead */
|
|
21
21
|
export declare const asDataHashStorageMeta: import("@xylabs/object").AsTypeFunction<DataHashMeta>;
|
|
22
22
|
/** @deprecated use asOptionalDataHashMeta instead */
|
|
23
|
-
export declare const asOptionalDataHashStorageMeta: (value: import(".store/@xylabs-promise-npm-5.0.
|
|
23
|
+
export declare const asOptionalDataHashStorageMeta: (value: import(".store/@xylabs-promise-npm-5.0.24-e9749bb6a6/package").AnyNonPromise) => DataHashMeta | undefined;
|
|
24
24
|
//# sourceMappingURL=DataHash.d.ts.map
|
|
@@ -8,7 +8,7 @@ export type WithHashMeta<T extends Payload = Payload> = T & HashMeta;
|
|
|
8
8
|
export type WithPartialHashMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>;
|
|
9
9
|
export declare const isHashMeta: (value: unknown) => value is HashMeta;
|
|
10
10
|
export declare const asHashMeta: import("@xylabs/object").AsTypeFunction<HashMeta>;
|
|
11
|
-
export declare const asOptionalHashMeta: (value: import(".store/@xylabs-promise-npm-5.0.
|
|
11
|
+
export declare const asOptionalHashMeta: (value: import(".store/@xylabs-promise-npm-5.0.24-e9749bb6a6/package").AnyNonPromise) => HashMeta | undefined;
|
|
12
12
|
/** @deprecated use HashMeta instead */
|
|
13
13
|
export interface HashStorageMeta extends HashMeta {
|
|
14
14
|
}
|
|
@@ -21,5 +21,5 @@ export declare const isHashStorageMeta: (value: unknown) => value is HashMeta;
|
|
|
21
21
|
/** @deprecated use asHashMeta instead */
|
|
22
22
|
export declare const asHashStorageMeta: import("@xylabs/object").AsTypeFunction<HashMeta>;
|
|
23
23
|
/** @deprecated use asOptionalHashMeta instead */
|
|
24
|
-
export declare const asOptionalHashStorageMeta: (value: import(".store/@xylabs-promise-npm-5.0.
|
|
24
|
+
export declare const asOptionalHashStorageMeta: (value: import(".store/@xylabs-promise-npm-5.0.24-e9749bb6a6/package").AnyNonPromise) => HashMeta | undefined;
|
|
25
25
|
//# sourceMappingURL=Hash.d.ts.map
|
|
@@ -7,5 +7,5 @@ export type WithSequenceStorageMeta<T extends Payload = Payload> = T & SequenceS
|
|
|
7
7
|
export type WithPartialSequenceStorageMeta<T extends Payload = Payload> = Partial<WithSequenceStorageMeta<T>>;
|
|
8
8
|
export declare const isSequenceStorageMeta: (value: unknown) => value is SequenceStorageMeta;
|
|
9
9
|
export declare const asSequenceStorageMeta: import("@xylabs/object").AsTypeFunction<SequenceStorageMeta>;
|
|
10
|
-
export declare const asOptionalSequenceStorageMeta: (value: import(".store/@xylabs-promise-npm-5.0.
|
|
10
|
+
export declare const asOptionalSequenceStorageMeta: (value: import(".store/@xylabs-promise-npm-5.0.24-e9749bb6a6/package").AnyNonPromise) => SequenceStorageMeta | undefined;
|
|
11
11
|
//# sourceMappingURL=Sequence.d.ts.map
|
|
@@ -7,5 +7,5 @@ export type WithStorageMeta<T extends Payload = Payload> = T & StorageMeta;
|
|
|
7
7
|
export type WithPartialStorageMeta<T extends Payload = Payload> = T & Partial<StorageMeta>;
|
|
8
8
|
export declare const isStorageMeta: (value: unknown) => value is StorageMeta;
|
|
9
9
|
export declare const asStorageMeta: import("@xylabs/object").AsTypeFunction<StorageMeta>;
|
|
10
|
-
export declare const asOptionalStorageMeta: (value: import(".store/@xylabs-promise-npm-5.0.
|
|
10
|
+
export declare const asOptionalStorageMeta: (value: import(".store/@xylabs-promise-npm-5.0.24-e9749bb6a6/package").AnyNonPromise) => StorageMeta | undefined;
|
|
11
11
|
//# sourceMappingURL=StorageMeta.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import z from 'zod';
|
|
2
2
|
import type { LocalSequence, QualifiedSequence } from './Sequence.ts';
|
|
3
3
|
export declare const LocalSequenceToStringZod: z.ZodString;
|
|
4
4
|
export declare const LocalSequenceFromStringZod: z.ZodPipe<z.ZodString, z.ZodTransform<LocalSequence, string>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SequenceZod.d.ts","sourceRoot":"","sources":["../../../../src/StorageMeta/sequence/SequenceZod.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"SequenceZod.d.ts","sourceRoot":"","sources":["../../../../src/StorageMeta/sequence/SequenceZod.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAIrE,eAAO,MAAM,wBAAwB,aAAuC,CAAA;AAC5E,eAAO,MAAM,0BAA0B,+DAAgG,CAAA;AAGvI,eAAO,MAAM,4BAA4B,aAA2C,CAAA;AACpF,eAAO,MAAM,8BAA8B,mEAA4G,CAAA;AAEvJ,eAAO,MAAM,mBAAmB,iDAAoE,CAAA;AACpG,eAAO,MAAM,qBAAqB,yJAAwE,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -53,11 +53,11 @@ var PayloadSetSchema = "network.xyo.payload.set";
|
|
|
53
53
|
|
|
54
54
|
// src/PayloadZod.ts
|
|
55
55
|
import { HashZod } from "@xylabs/hex";
|
|
56
|
-
import
|
|
56
|
+
import z3 from "zod";
|
|
57
57
|
|
|
58
58
|
// src/Schema.ts
|
|
59
59
|
import { AsTypeFactory } from "@xylabs/object";
|
|
60
|
-
import
|
|
60
|
+
import z from "zod";
|
|
61
61
|
var SchemaRegEx = /^(?:[a-z0-9]+\.)*[a-z0-9]+$/;
|
|
62
62
|
var SchemaZodV1 = z.string().regex(SchemaRegEx);
|
|
63
63
|
var SchemaZodV2 = z.string().regex(SchemaRegEx).transform((x) => x);
|
|
@@ -273,7 +273,7 @@ var SequenceComparer = { local, qualified };
|
|
|
273
273
|
|
|
274
274
|
// src/StorageMeta/sequence/SequenceZod.ts
|
|
275
275
|
import { HexRegExMinMax, toHex as toHex2 } from "@xylabs/hex";
|
|
276
|
-
import
|
|
276
|
+
import z2 from "zod";
|
|
277
277
|
var LocalSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.localSequenceBytes, SequenceConstants.localSequenceBytes));
|
|
278
278
|
var LocalSequenceToStringZod = z2.string().regex(LocalSequenceRegex);
|
|
279
279
|
var LocalSequenceFromStringZod = z2.string().regex(LocalSequenceRegex).transform((v) => toHex2(v));
|
|
@@ -307,7 +307,10 @@ var PayloadWithStorageMetaZod = PayloadZod.extend(StorageMetaZod.shape);
|
|
|
307
307
|
var AnyPayloadZod = PayloadZod.catchall(z3.json());
|
|
308
308
|
var AnyPayloadWithStorageMetaZod = AnyPayloadZod.extend(StorageMetaZod.shape);
|
|
309
309
|
function WithStorageMetaZod(valueZod) {
|
|
310
|
-
return
|
|
310
|
+
return valueZod.extend(StorageMetaZod.shape);
|
|
311
|
+
}
|
|
312
|
+
function WithHashMetaZod(valueZod) {
|
|
313
|
+
return valueZod.extend(HashMetaZod.shape);
|
|
311
314
|
}
|
|
312
315
|
var PayloadZodStrict = z3.strictObject({ schema: SchemaZod });
|
|
313
316
|
var PayloadZodLoose = z3.looseObject({ schema: SchemaZod });
|
|
@@ -348,6 +351,7 @@ export {
|
|
|
348
351
|
SequenceParser,
|
|
349
352
|
SequenceToStringZod,
|
|
350
353
|
StorageMetaZod,
|
|
354
|
+
WithHashMetaZod,
|
|
351
355
|
WithStorageMetaZod,
|
|
352
356
|
asAnyPayload,
|
|
353
357
|
asDataHashMeta,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/isPayloadOfZodType.ts","../../src/PayloadBundle.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/PayloadZod.ts","../../src/Schema.ts","../../src/StorageMeta/DataHash.ts","../../src/StorageMeta/Hash.ts","../../src/StorageMeta/Sequence.ts","../../src/StorageMeta/sequence/Parser.ts","../../src/StorageMeta/sequence/Sequence.ts","../../src/StorageMeta/sequence/Comparer.ts","../../src/StorageMeta/sequence/SequenceZod.ts","../../src/StorageMeta/StorageMeta.ts"],"sourcesContent":["import { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport type { Payload } from './Payload.ts'\n\nexport const isAnyPayload = (value: unknown): value is Payload => {\n if (isObject(value)) {\n return typeof (value as Payload).schema === 'string'\n }\n return false\n}\n\nexport const asAnyPayload = AsObjectFactory.create(isAnyPayload)\n\nexport const isPayload\n = <T extends Payload>(schema: string[]) =>\n (value: unknown): value is T => {\n if (isAnyPayload(value)) {\n return schema.includes(value.schema)\n }\n return false\n }\n\nexport const asPayload = <T extends Payload>(schema: string[]) => AsObjectFactory.create((value: unknown): value is T => isPayload(schema)(value))\n","import { isAnyPayload } from './isPayload.ts'\nimport type { Payload, WithSources } from './Payload.ts'\n\nexport function isPayloadOfSchemaType<T extends Payload | never = never>(schema: T['schema']) {\n return (x?: unknown | null): x is T => isAnyPayload(x) && x?.schema === schema\n}\n\nexport const isPayloadOfSchemaTypeWithSources = <T extends Payload | never = never>(schema: T['schema']) => {\n return (x?: unknown | null): x is WithSources<T> =>\n isPayloadOfSchemaType<WithSources<T>>(schema)(x) && x.$sources != undefined && Array.isArray(x.$sources)\n}\n\nexport const notPayloadOfSchemaType = <T extends Payload | never = never>(schema: T['schema']) => {\n return (x?: unknown | null): x is T => !isAnyPayload(x) || x?.schema !== schema\n}\n\n// test types -- keep for future validation, but comment out\n\n/*\ntype TestSchema = 'network.xyo.test'\nconst TestSchema: TestSchema = 'network.xyo.test'\n\ntype Test = Payload<{ field: string }, TestSchema>\n\nconst testPayload: Test = { field: 'test', schema: TestSchema }\n\nconst testPayloads: Payload[] = [testPayload]\n\nconst isTest: Test[] = testPayloads.filter(isPayloadOfSchemaType<Payload>(TestSchema))\n\nconst isTestFromMetaTyped = testMetaPayloads.filter(isPayloadOfSchemaType<Test>(TestSchema))\n*/\n","import type { Hash } from '@xylabs/hex'\nimport type { JsonValue } from '@xylabs/object'\n\nimport { isPayloadOfSchemaType } from './isPayloadOfSchemaType.ts'\nimport type { Payload } from './Payload.ts'\nimport type { Schema } from './Schema.ts'\n\nexport const ModuleErrorSchema = 'network.xyo.error.module' as const\nexport type ModuleErrorSchema = typeof ModuleErrorSchema\n\nexport type ModuleError = Payload<{\n details?: JsonValue\n message?: string\n name?: string\n query?: Hash | Schema\n schema: ModuleErrorSchema\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","import { isDefined } from '@xylabs/typeof'\nimport type { ZodObject } from 'zod'\n\nimport { isAnyPayload } from './isPayload.ts'\nimport type { Payload } from './Payload.ts'\n\n/**\n * Checks if a value is a payload of a specific Zod type.\n * @param zodSchema The Zod schema to validate against\n * @param schema The schema string to match against the payload. Optional in\n * case you want to validate any payload matching the Zod schema or in case\n * schema is part of the Zod schema.\n * @returns A function that checks if a value is a payload of the specified Zod type\n */\nexport function isPayloadOfZodType<\n T extends Payload | never = never,\n S extends ZodObject = ZodObject,\n>(zodSchema: S, schema?: T['schema']) {\n return (x?: unknown | null): x is T => {\n if (!isAnyPayload(x)) return false\n if (isDefined(schema) && x.schema !== schema) return false\n const { schema: _, ...data } = x\n return zodSchema.safeParse(data).success\n }\n}\n","import type { Hash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\n\nimport { isPayloadOfSchemaType } from './isPayloadOfSchemaType.ts'\nimport type { Payload } from './Payload.ts'\n\n// payload that wraps a complete boundwitness with its payloads for use in systems such as submission queues\nexport const PayloadBundleSchema = 'network.xyo.payload.bundle' as const\nexport type PayloadBundleSchema = typeof PayloadBundleSchema\n\nexport interface PayloadBundleFields<T extends Payload = Payload> {\n payloads: T[]\n root: Hash\n}\n\nexport type PayloadBundle = Payload<PayloadBundleFields, PayloadBundleSchema>\n\nexport const isPayloadBundle = isPayloadOfSchemaType<PayloadBundle>(PayloadBundleSchema)\n\nexport const asPayloadBundle = AsObjectFactory.create(isPayloadBundle)\nexport const asOptionalPayloadBundle = AsObjectFactory.createOptional(isPayloadBundle)\n","export const PayloadSetSchema = 'network.xyo.payload.set' as const\nexport type PayloadSetSchema = typeof PayloadSetSchema\n","import { HashZod } from '@xylabs/hex'\nimport * as z from 'zod'\n\nimport { SchemaZod } from './Schema.ts'\nimport { SequenceFromStringZod } from './StorageMeta/index.ts'\n\nexport const HashMetaZod = z.object({\n _hash: HashZod,\n _dataHash: HashZod,\n})\n\nexport const SequenceMetaZod = z.object({ _sequence: SequenceFromStringZod })\n\nexport const StorageMetaZod = z.object({\n _hash: HashZod,\n _dataHash: HashZod,\n _sequence: SequenceFromStringZod,\n})\n\nexport const PayloadZod = z.object({ schema: SchemaZod })\nexport const PayloadWithStorageMetaZod = PayloadZod.extend(StorageMetaZod.shape)\n\nexport const AnyPayloadZod = PayloadZod.catchall(z.json())\nexport const AnyPayloadWithStorageMetaZod = AnyPayloadZod.extend(StorageMetaZod.shape)\n\nexport type PayloadWithStorageMeta = z.infer<typeof PayloadWithStorageMetaZod>\n\nexport type AnyPayload = z.infer<typeof AnyPayloadZod>\nexport type AnyPayloadWithStorageMeta = z.infer<typeof AnyPayloadWithStorageMetaZod>\n\nexport function WithStorageMetaZod<T extends typeof PayloadZod>(valueZod: T) {\n return StorageMetaZod.extend(valueZod.shape)\n}\n\nexport const PayloadZodStrict = z.strictObject({ schema: SchemaZod })\nexport type PayloadZodStrict = typeof PayloadZodStrict\nexport const PayloadZodLoose: PayloadZodStrict = z.looseObject({ schema: SchemaZod })\n\nexport const PayloadZodStrictOfSchema = <S extends string>(schema: S) => PayloadZodStrict.extend({ schema: z.literal(schema) })\nexport const PayloadZodLooseOfSchema = <S extends string>(schema: S) => PayloadZodLoose.extend({ schema: z.literal(schema) })\n","import type { EmptyObject } from '@xylabs/object'\nimport { AsTypeFactory } from '@xylabs/object'\nimport * as z from 'zod'\n\nexport const SchemaRegEx = /^(?:[a-z0-9]+\\.)*[a-z0-9]+$/\n\nexport const SchemaZodV1 = z.string().regex(SchemaRegEx)\nexport const SchemaZodV2 = z.string().regex(SchemaRegEx).transform(x => x as (typeof x & { __schema: true }))\nexport type SchemaV2 = z.output<typeof SchemaZodV2>\nexport type SchemaV1 = z.output<typeof SchemaZodV1>\nexport const SchemaZod = z.union([SchemaZodV1, SchemaZodV2])\nexport type Schema = z.infer<typeof SchemaZodV1>\n\nexport const makeSchema = <T extends string>(value: T) => {\n return (z.templateLiteral([z.literal(value)])).transform(x => x as (typeof x & { __schema: true }))\n}\n\nexport const PayloadSchema = 'network.xyo.payload' as const\nexport const PayloadSchemaZod = z.literal(PayloadSchema)\nexport type PayloadSchema = z.infer<typeof PayloadSchemaZod>\n\nexport const isSchema = (value: unknown): value is Schema => {\n return SchemaZod.safeParse(value).error === undefined\n}\n\nexport const asSchema = AsTypeFactory.create<Schema>(isSchema)\n\n/** Add the Schema Fields to an object */\nexport type WithSchema<T extends EmptyObject | void = void> = T extends EmptyObject ? SchemaFields & T : SchemaFields\n\n/** Schema fields for a Payload */\nexport interface SchemaFields extends EmptyObject {\n /** Schema of the object */\n schema: Schema\n}\n","import type { Hash } from '@xylabs/hex'\nimport { isHash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\n\nimport type { Payload } from '../Payload.ts'\n\nexport interface DataHashMeta {\n _dataHash: Hash\n}\n\nexport type WithDataHashMeta<T extends Payload = Payload> = T & DataHashMeta\nexport type WithPartialDataHashMeta<T extends Payload = Payload> = Partial<WithDataHashMeta<T>>\n\nexport const isDataHashMeta = (value: unknown): value is DataHashMeta => {\n return isHash((value as WithDataHashMeta)?._dataHash)\n}\n\nexport const asDataHashMeta = AsObjectFactory.create<DataHashMeta>(isDataHashMeta)\nexport const asOptionalDataHashMeta = AsObjectFactory.createOptional<DataHashMeta>(isDataHashMeta)\n\n/** @deprecated use DataHashMeta instead */\nexport interface DataHashStorageMeta extends DataHashMeta {}\n\n/** @deprecated use WithDataHashMeta instead */\nexport type WithDataHashStorageMeta<T extends Payload = Payload> = WithDataHashMeta<T>\n\n/** @deprecated use WithPartialDataHashMeta instead */\nexport type WithPartialDataHashStorageMeta<T extends Payload = Payload> = WithPartialDataHashMeta<T>\n\n/** @deprecated use isDataHashMeta instead */\nexport const isDataHashStorageMeta = isDataHashMeta\n\n/** @deprecated use asDataHashMeta instead */\nexport const asDataHashStorageMeta = asDataHashMeta\n\n/** @deprecated use asOptionalDataHashMeta instead */\nexport const asOptionalDataHashStorageMeta = asOptionalDataHashMeta\n","import type { Hash } from '@xylabs/hex'\nimport { isHash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\n\nimport type { Payload } from '../Payload.ts'\nimport type { DataHashMeta } from './DataHash.ts'\nimport { isDataHashMeta } from './DataHash.ts'\n\nexport interface HashMeta extends DataHashMeta {\n _hash: Hash\n}\n\nexport type WithHashMeta<T extends Payload = Payload> = T & HashMeta\nexport type WithPartialHashMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>\n\nexport const isHashMeta = (value: unknown): value is HashMeta => {\n return isDataHashMeta(value) && isHash((value as WithHashMeta)?._hash)\n}\n\nexport const asHashMeta = AsObjectFactory.create<HashMeta>(isHashMeta)\nexport const asOptionalHashMeta = AsObjectFactory.createOptional<HashMeta>(isHashMeta)\n\n/** @deprecated use HashMeta instead */\nexport interface HashStorageMeta extends HashMeta {}\n\n/** @deprecated use WithHashMeta instead */\nexport type WithHashStorageMeta<T extends Payload = Payload> = WithHashMeta<T>\n\n/** @deprecated use WithPartialHashMeta instead */\nexport type WithPartialHashStorageMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>\n\n/** @deprecated use isHashMeta instead */\nexport const isHashStorageMeta = isHashMeta\n\n/** @deprecated use asHashMeta instead */\nexport const asHashStorageMeta = asHashMeta\n\n/** @deprecated use asOptionalHashMeta instead */\nexport const asOptionalHashStorageMeta = asOptionalHashMeta\n","import { AsObjectFactory } from '@xylabs/object'\n\nimport type { Payload } from '../Payload.ts'\nimport type { Sequence } from './sequence/index.ts'\n\nexport interface SequenceStorageMeta {\n _sequence: Sequence\n}\n\nexport type WithSequenceStorageMeta<T extends Payload = Payload> = T & SequenceStorageMeta\nexport type WithPartialSequenceStorageMeta<T extends Payload = Payload> = Partial<WithSequenceStorageMeta<T>>\n\nexport const isSequenceStorageMeta = (value: unknown): value is SequenceStorageMeta => {\n return (value as WithSequenceStorageMeta)?._sequence != undefined\n}\n\nexport const asSequenceStorageMeta = AsObjectFactory.create(isSequenceStorageMeta)\nexport const asOptionalSequenceStorageMeta = AsObjectFactory.createOptional(isSequenceStorageMeta)\n","import { toUint8Array } from '@xylabs/arraybuffer'\nimport { assertEx } from '@xylabs/assert'\nimport type {\n Address,\n Hash, Hex,\n} from '@xylabs/hex'\nimport {\n isAddress,\n toAddress,\n toHex,\n} from '@xylabs/hex'\n\nimport type {\n Epoch, LocalSequence, Nonce, QualifiedSequence,\n Sequence,\n} from './Sequence.ts'\nimport {\n isQualifiedSequence, isSequence,\n SequenceConstants,\n} from './Sequence.ts'\n\nexport class SequenceParser {\n protected static privateConstructorKey = Date.now().toString()\n\n private readonly data: Readonly<Uint8Array>\n\n protected constructor(privateConstructorKey: string, hex: Hex) {\n assertEx(SequenceParser.privateConstructorKey === privateConstructorKey, () => 'Use create function instead of constructor')\n const paddedHex = toHex(hex, {\n prefix: false,\n bitLength: (hex.length <= SequenceConstants.localSequenceBytes * 2)\n ? SequenceConstants.localSequenceBytes * 8\n : SequenceConstants.qualifiedSequenceBytes * 8,\n })\n this.data = toUint8Array(paddedHex)\n }\n\n get address(): Address {\n const start = SequenceConstants.localSequenceBytes\n const end = SequenceConstants.qualifiedSequenceBytes\n return toAddress(this.data.slice(start, end).buffer, { prefix: false })\n }\n\n get epoch(): Epoch {\n const start = 0\n const end = SequenceConstants.epochBytes\n return toHex(this.data.slice(start, end).buffer, { prefix: false }) as Epoch\n }\n\n get localSequence(): LocalSequence {\n const start = 0\n const end = SequenceConstants.localSequenceBytes\n return toHex(this.data.slice(start, end).buffer, { prefix: false }) as LocalSequence\n }\n\n get nonce(): Nonce {\n const start = SequenceConstants.epochBytes\n const end = SequenceConstants.localSequenceBytes\n return toHex(this.data.slice(start, end).buffer, { prefix: false }) as Nonce\n }\n\n get qualifiedSequence(): QualifiedSequence {\n const start = 0\n const end = SequenceConstants.qualifiedSequenceBytes\n return toHex(this.data.slice(start, end).buffer, { prefix: false }) as QualifiedSequence\n }\n\n static from(sequence: Sequence, address?: Address): SequenceParser\n static from(timestamp: Hex, hash: Hash, address?: Address): SequenceParser\n static from(timestamp: Hex, hash: Hex, address?: Address): SequenceParser\n static from(timestamp: Hex, nonce: Nonce, address?: Address): SequenceParser\n static from(timestamp: Hex, hash: Hash, index?: number, address?: Address): SequenceParser\n static from(timestamp: Hex, hash: Hex, index?: number, address?: Address): SequenceParser\n static from(timestamp: Hex, nonce: Nonce, index?: number, address?: Address): SequenceParser\n static from(timestamp: number, hash: Hash, address?: Address): SequenceParser\n static from(timestamp: number, hash: Hex, address?: Address): SequenceParser\n static from(timestamp: number, nonce: Nonce, address?: Address): SequenceParser\n static from(timestamp: number, hash: Hash, index?: number, address?: Address): SequenceParser\n static from(timestamp: number, hash: Hex, index?: number, address?: Address): SequenceParser\n static from(timestamp: number, nonce: Nonce, index?: number, address?: Address): SequenceParser\n static from(\n timestampOrSequence: Hex | number,\n nonceOrAddress?: Hex,\n addressOrIndex?: Address | number,\n addressOnly?: Address,\n ): SequenceParser {\n const address = typeof addressOrIndex === 'number' ? addressOnly : addressOrIndex\n const index = typeof addressOrIndex === 'number' ? addressOrIndex : undefined\n if (isSequence(timestampOrSequence)) {\n if (nonceOrAddress) {\n assertEx(!isQualifiedSequence(timestampOrSequence), () => 'Providing both a qualified sequence and a address is not allowed')\n assertEx(isAddress(nonceOrAddress), () => 'Invalid address provided')\n return new this(SequenceParser.privateConstructorKey, (timestampOrSequence + address) as Hex)\n }\n return new this(SequenceParser.privateConstructorKey, timestampOrSequence)\n }\n const epoch = SequenceParser.toEpoch(timestampOrSequence)\n const nonce = nonceOrAddress === undefined ? undefined : SequenceParser.toNonce(nonceOrAddress, index)\n const addressHex: Hex = address ? toHex(address, { bitLength: SequenceConstants.addressBytes * 8 }) : SequenceConstants.minAddress\n const hexString = (epoch + nonce + addressHex) as Hex\n assertEx(isSequence(hexString), () => `Invalid sequence [${hexString}] [${epoch}, ${nonce}, ${addressHex}]`)\n return new this(SequenceParser.privateConstructorKey, hexString)\n }\n\n static parse(value: Hex | string | ArrayBufferLike): SequenceParser {\n const hex = toHex(value)\n if (isSequence(hex)) {\n return new this(SequenceParser.privateConstructorKey, hex)\n }\n throw new Error(`Invalid sequence [${value}]`)\n }\n\n // can convert a short number/hex to an epoch (treats it as the whole value) or extract an epoch from a sequence\n static toEpoch(value: number | Hex | Epoch): Epoch {\n assertEx(\n typeof value !== 'number' || Number.isInteger(value),\n () => 'Value must be in integer',\n )\n const hex = toHex(value, { prefix: false })\n if (hex.length <= SequenceConstants.epochBytes * 2) {\n return toHex(value, { prefix: false, bitLength: SequenceConstants.epochBytes * 8 }) as Epoch\n }\n if (isSequence(hex)) {\n return hex.slice(0, SequenceConstants.epochBytes * 2) as Epoch\n }\n throw new Error(`Value could not be converted to epoch [${hex}]`)\n }\n\n // can convert a short number/hex to a nonce (treats it as the whole value) or extract an nonce from a sequence\n static toNonce(value: Hash | Hex, index = 0): Nonce {\n assertEx(\n typeof value !== 'number' || Number.isInteger(value),\n () => 'Value must be in integer',\n )\n const hex = toHex(value, { prefix: false })\n if (isSequence(hex)) {\n return hex.slice(SequenceConstants.epochBytes * 2, SequenceConstants.localSequenceBytes * 2) as Nonce\n }\n const hashHex = toHex((hex as string), { prefix: false, bitLength: SequenceConstants.nonceHashBytes * 8 }).slice(-SequenceConstants.nonceHashBytes * 2)\n const indexHex = toHex(index, { prefix: false, bitLength: SequenceConstants.nonceIndexBytes * 8 }).slice(-SequenceConstants.nonceIndexBytes * 2)\n return (indexHex + hashHex).slice(-SequenceConstants.nonceBytes * 2) as Nonce\n }\n}\n","import type { Address, Hex } from '@xylabs/hex'\nimport { isHex } from '@xylabs/hex'\nimport type { Brand } from '@xylabs/typeof'\n\n// we use Exclude to intentionally make the type not equal to string\nexport type LocalSequence = Brand<Hex, { __localSequence: true }>\nexport type QualifiedSequence = Brand<Hex, { __qualifiedSequence: true }>\nexport type Sequence = LocalSequence | QualifiedSequence\n\nexport type Epoch = Brand<Hex, { __epoch: true }>\n\nexport const isEpoch = (value: unknown): value is Epoch => {\n return isHex(value) && (value as string).length === SequenceConstants.epochBytes * 2\n}\n\nexport type Nonce = Brand<Hex, { __nonce: true }>\n\nexport const isNonce = (value: unknown): value is Nonce => {\n return isHex(value) && (value as string).length === SequenceConstants.nonceBytes * 2\n}\n\nexport const isLocalSequence = (value: unknown): value is LocalSequence => {\n return isHex(value) && (value as string).length === SequenceConstants.localSequenceBytes * 2\n}\n\nexport const isQualifiedSequence = (value: unknown): value is QualifiedSequence => {\n return isHex(value) && (value as string).length === SequenceConstants.qualifiedSequenceBytes * 2\n}\n\nexport const isSequence = (value: unknown): value is Sequence => {\n return isLocalSequence(value) || isQualifiedSequence(value)\n}\n\nexport const SequenceNonceComponentLengths = {\n nonceIndexBytes: 4,\n nonceHashBytes: 4,\n}\n\nexport const SequenceComponentLengths = {\n ...SequenceNonceComponentLengths,\n epochBytes: 8,\n nonceBytes: SequenceNonceComponentLengths.nonceIndexBytes + SequenceNonceComponentLengths.nonceHashBytes,\n addressBytes: 20,\n}\n\nexport const SequenceComponentMinMax = {\n minEpoch: '0'.repeat(SequenceComponentLengths.epochBytes * 2) as Epoch,\n maxEpoch: 'f'.repeat(SequenceComponentLengths.epochBytes * 2) as Epoch,\n minNonce: '0'.repeat(SequenceComponentLengths.nonceBytes * 2) as Nonce,\n maxNonce: 'f'.repeat(SequenceComponentLengths.nonceBytes * 2) as Nonce,\n minAddress: '0'.repeat(SequenceComponentLengths.addressBytes * 2) as Address,\n maxAddress: 'f'.repeat(SequenceComponentLengths.addressBytes * 2) as Address,\n}\n\nexport const LocalSequenceConstants = {\n ...SequenceComponentLengths,\n ...SequenceComponentMinMax,\n localSequenceBytes: SequenceComponentLengths.epochBytes + SequenceComponentLengths.nonceBytes,\n minLocalSequence: SequenceComponentMinMax.minEpoch + SequenceComponentMinMax.minNonce as LocalSequence,\n maxLocalSequence: SequenceComponentMinMax.maxEpoch + SequenceComponentMinMax.maxNonce as LocalSequence,\n}\n\nexport const QualifiedSequenceConstants = {\n qualifiedSequenceBytes: LocalSequenceConstants.localSequenceBytes + SequenceComponentLengths.addressBytes,\n minQualifiedSequence: LocalSequenceConstants.minLocalSequence + SequenceComponentMinMax.minAddress as QualifiedSequence,\n maxQualifiedSequence: LocalSequenceConstants.maxLocalSequence + SequenceComponentMinMax.maxAddress as QualifiedSequence,\n}\n\nexport const SequenceConstants = {\n ...LocalSequenceConstants,\n ...QualifiedSequenceConstants,\n}\n\n// \"11111111111111112222222222222222\" is and example of a local sequence string\n\n// \"111111111111111122222222222222223333333333333333333333333333333333333333\" is and example of a local sequence string\n// epoch = \"1111111111111111\"\n// nonce = \"2222222222222222\"\n// address = \"3333333333333333333333333333333333333333\"\n","import type { Compare } from '@xylabs/object'\n\nimport { SequenceParser } from './Parser.ts'\nimport type { Sequence } from './Sequence.ts'\n\nconst local: Compare<Sequence> = (a, b) => {\n const aa = SequenceParser.from(a)\n const bb = SequenceParser.from(b)\n return aa.localSequence > bb.localSequence ? 1 : aa.localSequence < bb.localSequence ? -1 : 0\n}\n\nconst qualified: Compare<Sequence> = (a, b) => {\n const aa = SequenceParser.from(a)\n const bb = SequenceParser.from(b)\n return aa.qualifiedSequence > bb.qualifiedSequence ? 1 : aa.qualifiedSequence < bb.qualifiedSequence ? -1 : 0\n}\n\nexport const SequenceComparer = { local, qualified }\n","import { HexRegExMinMax, toHex } from '@xylabs/hex'\nimport * as z from 'zod'\n\nimport type { LocalSequence, QualifiedSequence } from './Sequence.ts'\nimport { SequenceConstants } from './Sequence.ts'\n\nconst LocalSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.localSequenceBytes, SequenceConstants.localSequenceBytes))\nexport const LocalSequenceToStringZod = z.string().regex(LocalSequenceRegex)\nexport const LocalSequenceFromStringZod = z.string().regex(LocalSequenceRegex).transform<LocalSequence>(v => toHex(v) as LocalSequence)\n\nconst QualifiedSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.qualifiedSequenceBytes, SequenceConstants.qualifiedSequenceBytes))\nexport const QualifiedSequenceToStringZod = z.string().regex(QualifiedSequenceRegex)\nexport const QualifiedSequenceFromStringZod = z.string().regex(QualifiedSequenceRegex).transform<QualifiedSequence>(v => toHex(v) as QualifiedSequence)\n\nexport const SequenceToStringZod = z.union([LocalSequenceToStringZod, QualifiedSequenceToStringZod])\nexport const SequenceFromStringZod = z.union([LocalSequenceFromStringZod, QualifiedSequenceFromStringZod])\n","import { AsObjectFactory } from '@xylabs/object'\n\nimport type { Payload } from '../Payload.ts'\nimport type { HashMeta } from './Hash.ts'\nimport { isHashMeta } from './Hash.ts'\nimport type { SequenceStorageMeta } from './Sequence.ts'\nimport { isSequenceStorageMeta } from './Sequence.ts'\n\nexport interface StorageMeta extends SequenceStorageMeta, HashMeta {}\n\nexport type WithStorageMeta<T extends Payload = Payload> = T & StorageMeta\nexport type WithPartialStorageMeta<T extends Payload = Payload> = T & Partial<StorageMeta>\n\nexport const isStorageMeta = (value: unknown): value is StorageMeta => {\n return isSequenceStorageMeta(value) && isHashMeta(value)\n}\n\nexport const asStorageMeta = AsObjectFactory.create(isStorageMeta)\nexport const asOptionalStorageMeta = AsObjectFactory.createOptional(isStorageMeta)\n"],"mappings":";AAAA,SAAS,iBAAiB,gBAAgB;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,OAAQ,MAAkB,WAAW;AAAA,EAC9C;AACA,SAAO;AACT;AAEO,IAAM,eAAe,gBAAgB,OAAO,YAAY;AAExD,IAAM,YACT,CAAoB,WACpB,CAAC,UAA+B;AAC9B,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO,OAAO,SAAS,MAAM,MAAM;AAAA,EACrC;AACA,SAAO;AACT;AAEG,IAAM,YAAY,CAAoB,WAAqB,gBAAgB,OAAO,CAAC,UAA+B,UAAU,MAAM,EAAE,KAAK,CAAC;;;ACnB1I,SAAS,sBAAyD,QAAqB;AAC5F,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,mCAAmC,CAAoC,WAAwB;AAC1G,SAAO,CAAC,MACN,sBAAsC,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,UAAa,MAAM,QAAQ,EAAE,QAAQ;AAC3G;AAEO,IAAM,yBAAyB,CAAoC,WAAwB;AAChG,SAAO,CAAC,MAA+B,CAAC,aAAa,CAAC,KAAK,GAAG,WAAW;AAC3E;;;ACPO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iB,OAAO,EAAE,QAAU,WAAQ,MAAM,EAAE,CAAC;AACvH,IAAM,0BAA0B,CAAmB,WAAc,gBAAgB,OAAO,EAAE,QAAU,WAAQ,MAAM,EAAE,CAAC;","names":["AsObjectFactory","AsObjectFactory","z","AsObjectFactory","isHash","AsObjectFactory","isHash","AsObjectFactory","AsObjectFactory","toHex","z","toHex","AsObjectFactory","AsObjectFactory"]}
|
|
1
|
+
{"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/isPayloadOfZodType.ts","../../src/PayloadBundle.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/PayloadZod.ts","../../src/Schema.ts","../../src/StorageMeta/DataHash.ts","../../src/StorageMeta/Hash.ts","../../src/StorageMeta/Sequence.ts","../../src/StorageMeta/sequence/Parser.ts","../../src/StorageMeta/sequence/Sequence.ts","../../src/StorageMeta/sequence/Comparer.ts","../../src/StorageMeta/sequence/SequenceZod.ts","../../src/StorageMeta/StorageMeta.ts"],"sourcesContent":["import { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport type { Payload } from './Payload.ts'\n\nexport const isAnyPayload = (value: unknown): value is Payload => {\n if (isObject(value)) {\n return typeof (value as Payload).schema === 'string'\n }\n return false\n}\n\nexport const asAnyPayload = AsObjectFactory.create(isAnyPayload)\n\nexport const isPayload\n = <T extends Payload>(schema: string[]) =>\n (value: unknown): value is T => {\n if (isAnyPayload(value)) {\n return schema.includes(value.schema)\n }\n return false\n }\n\nexport const asPayload = <T extends Payload>(schema: string[]) => AsObjectFactory.create((value: unknown): value is T => isPayload(schema)(value))\n","import { isAnyPayload } from './isPayload.ts'\nimport type { Payload, WithSources } from './Payload.ts'\n\nexport function isPayloadOfSchemaType<T extends Payload | never = never>(schema: T['schema']) {\n return (x?: unknown | null): x is T => isAnyPayload(x) && x?.schema === schema\n}\n\nexport const isPayloadOfSchemaTypeWithSources = <T extends Payload | never = never>(schema: T['schema']) => {\n return (x?: unknown | null): x is WithSources<T> =>\n isPayloadOfSchemaType<WithSources<T>>(schema)(x) && x.$sources != undefined && Array.isArray(x.$sources)\n}\n\nexport const notPayloadOfSchemaType = <T extends Payload | never = never>(schema: T['schema']) => {\n return (x?: unknown | null): x is T => !isAnyPayload(x) || x?.schema !== schema\n}\n\n// test types -- keep for future validation, but comment out\n\n/*\ntype TestSchema = 'network.xyo.test'\nconst TestSchema: TestSchema = 'network.xyo.test'\n\ntype Test = Payload<{ field: string }, TestSchema>\n\nconst testPayload: Test = { field: 'test', schema: TestSchema }\n\nconst testPayloads: Payload[] = [testPayload]\n\nconst isTest: Test[] = testPayloads.filter(isPayloadOfSchemaType<Payload>(TestSchema))\n\nconst isTestFromMetaTyped = testMetaPayloads.filter(isPayloadOfSchemaType<Test>(TestSchema))\n*/\n","import type { Hash } from '@xylabs/hex'\nimport type { JsonValue } from '@xylabs/object'\n\nimport { isPayloadOfSchemaType } from './isPayloadOfSchemaType.ts'\nimport type { Payload } from './Payload.ts'\nimport type { Schema } from './Schema.ts'\n\nexport const ModuleErrorSchema = 'network.xyo.error.module' as const\nexport type ModuleErrorSchema = typeof ModuleErrorSchema\n\nexport type ModuleError = Payload<{\n details?: JsonValue\n message?: string\n name?: string\n query?: Hash | Schema\n schema: ModuleErrorSchema\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","import { isDefined } from '@xylabs/typeof'\nimport type { ZodObject } from 'zod'\n\nimport { isAnyPayload } from './isPayload.ts'\nimport type { Payload } from './Payload.ts'\n\n/**\n * Checks if a value is a payload of a specific Zod type.\n * @param zodSchema The Zod schema to validate against\n * @param schema The schema string to match against the payload. Optional in\n * case you want to validate any payload matching the Zod schema or in case\n * schema is part of the Zod schema.\n * @returns A function that checks if a value is a payload of the specified Zod type\n */\nexport function isPayloadOfZodType<\n T extends Payload | never = never,\n S extends ZodObject = ZodObject,\n>(zodSchema: S, schema?: T['schema']) {\n return (x?: unknown | null): x is T => {\n if (!isAnyPayload(x)) return false\n if (isDefined(schema) && x.schema !== schema) return false\n const { schema: _, ...data } = x\n return zodSchema.safeParse(data).success\n }\n}\n","import type { Hash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\n\nimport { isPayloadOfSchemaType } from './isPayloadOfSchemaType.ts'\nimport type { Payload } from './Payload.ts'\n\n// payload that wraps a complete boundwitness with its payloads for use in systems such as submission queues\nexport const PayloadBundleSchema = 'network.xyo.payload.bundle' as const\nexport type PayloadBundleSchema = typeof PayloadBundleSchema\n\nexport interface PayloadBundleFields<T extends Payload = Payload> {\n payloads: T[]\n root: Hash\n}\n\nexport type PayloadBundle = Payload<PayloadBundleFields, PayloadBundleSchema>\n\nexport const isPayloadBundle = isPayloadOfSchemaType<PayloadBundle>(PayloadBundleSchema)\n\nexport const asPayloadBundle = AsObjectFactory.create(isPayloadBundle)\nexport const asOptionalPayloadBundle = AsObjectFactory.createOptional(isPayloadBundle)\n","export const PayloadSetSchema = 'network.xyo.payload.set' as const\nexport type PayloadSetSchema = typeof PayloadSetSchema\n","import { HashZod } from '@xylabs/hex'\nimport z from 'zod'\n\nimport { SchemaZod } from './Schema.ts'\nimport { SequenceFromStringZod } from './StorageMeta/index.ts'\n\nexport const HashMetaZod = z.object({\n _hash: HashZod,\n _dataHash: HashZod,\n})\n\nexport const SequenceMetaZod = z.object({ _sequence: SequenceFromStringZod })\n\nexport const StorageMetaZod = z.object({\n _hash: HashZod,\n _dataHash: HashZod,\n _sequence: SequenceFromStringZod,\n})\n\nexport const PayloadZod = z.object({ schema: SchemaZod })\n\n/** @deprecated use WithStorageMetaZod */\nexport const PayloadWithStorageMetaZod = PayloadZod.extend(StorageMetaZod.shape)\n\nexport const AnyPayloadZod = PayloadZod.catchall(z.json())\n\n/** @deprecated use WithStorageMetaZod */\nexport const AnyPayloadWithStorageMetaZod = AnyPayloadZod.extend(StorageMetaZod.shape)\n\n/** @deprecated use WithStorageMetaZod */\n// eslint-disable-next-line sonarjs/deprecation\nexport type PayloadWithStorageMeta = z.infer<typeof PayloadWithStorageMetaZod>\n\nexport type AnyPayload = z.infer<typeof AnyPayloadZod>\n\n/** @deprecated use WithStorageMetaZod */\n// eslint-disable-next-line sonarjs/deprecation\nexport type AnyPayloadWithStorageMeta = z.infer<typeof AnyPayloadWithStorageMetaZod>\n\nexport function WithStorageMetaZod<T extends z.ZodRawShape>(valueZod: z.ZodObject<T>) {\n return valueZod.extend(StorageMetaZod.shape)\n}\n\nexport function WithHashMetaZod<T extends z.ZodRawShape>(valueZod: z.ZodObject<T>) {\n return valueZod.extend(HashMetaZod.shape)\n}\n\nexport const PayloadZodStrict = z.strictObject({ schema: SchemaZod })\nexport type PayloadZodStrict = typeof PayloadZodStrict\nexport const PayloadZodLoose: PayloadZodStrict = z.looseObject({ schema: SchemaZod })\n\nexport const PayloadZodStrictOfSchema = <S extends string>(schema: S) => PayloadZodStrict.extend({ schema: z.literal(schema) })\nexport const PayloadZodLooseOfSchema = <S extends string>(schema: S) => PayloadZodLoose.extend({ schema: z.literal(schema) })\n","import type { EmptyObject } from '@xylabs/object'\nimport { AsTypeFactory } from '@xylabs/object'\nimport z from 'zod'\n\nexport const SchemaRegEx = /^(?:[a-z0-9]+\\.)*[a-z0-9]+$/\n\nexport const SchemaZodV1 = z.string().regex(SchemaRegEx)\nexport const SchemaZodV2 = z.string().regex(SchemaRegEx).transform(x => x as (typeof x & { __schema: true }))\nexport type SchemaV2 = z.output<typeof SchemaZodV2>\nexport type SchemaV1 = z.output<typeof SchemaZodV1>\nexport const SchemaZod = z.union([SchemaZodV1, SchemaZodV2])\nexport type Schema = z.infer<typeof SchemaZodV1>\n\nexport const makeSchema = <T extends string>(value: T) => {\n return (z.templateLiteral([z.literal(value)])).transform(x => x as (typeof x & { __schema: true }))\n}\n\nexport const PayloadSchema = 'network.xyo.payload' as const\nexport const PayloadSchemaZod = z.literal(PayloadSchema)\nexport type PayloadSchema = z.infer<typeof PayloadSchemaZod>\n\nexport const isSchema = (value: unknown): value is Schema => {\n return SchemaZod.safeParse(value).error === undefined\n}\n\nexport const asSchema = AsTypeFactory.create<Schema>(isSchema)\n\n/** Add the Schema Fields to an object */\nexport type WithSchema<T extends EmptyObject | void = void> = T extends EmptyObject ? SchemaFields & T : SchemaFields\n\n/** Schema fields for a Payload */\nexport interface SchemaFields extends EmptyObject {\n /** Schema of the object */\n schema: Schema\n}\n","import type { Hash } from '@xylabs/hex'\nimport { isHash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\n\nimport type { Payload } from '../Payload.ts'\n\nexport interface DataHashMeta {\n _dataHash: Hash\n}\n\nexport type WithDataHashMeta<T extends Payload = Payload> = T & DataHashMeta\nexport type WithPartialDataHashMeta<T extends Payload = Payload> = Partial<WithDataHashMeta<T>>\n\nexport const isDataHashMeta = (value: unknown): value is DataHashMeta => {\n return isHash((value as WithDataHashMeta)?._dataHash)\n}\n\nexport const asDataHashMeta = AsObjectFactory.create<DataHashMeta>(isDataHashMeta)\nexport const asOptionalDataHashMeta = AsObjectFactory.createOptional<DataHashMeta>(isDataHashMeta)\n\n/** @deprecated use DataHashMeta instead */\nexport interface DataHashStorageMeta extends DataHashMeta {}\n\n/** @deprecated use WithDataHashMeta instead */\nexport type WithDataHashStorageMeta<T extends Payload = Payload> = WithDataHashMeta<T>\n\n/** @deprecated use WithPartialDataHashMeta instead */\nexport type WithPartialDataHashStorageMeta<T extends Payload = Payload> = WithPartialDataHashMeta<T>\n\n/** @deprecated use isDataHashMeta instead */\nexport const isDataHashStorageMeta = isDataHashMeta\n\n/** @deprecated use asDataHashMeta instead */\nexport const asDataHashStorageMeta = asDataHashMeta\n\n/** @deprecated use asOptionalDataHashMeta instead */\nexport const asOptionalDataHashStorageMeta = asOptionalDataHashMeta\n","import type { Hash } from '@xylabs/hex'\nimport { isHash } from '@xylabs/hex'\nimport { AsObjectFactory } from '@xylabs/object'\n\nimport type { Payload } from '../Payload.ts'\nimport type { DataHashMeta } from './DataHash.ts'\nimport { isDataHashMeta } from './DataHash.ts'\n\nexport interface HashMeta extends DataHashMeta {\n _hash: Hash\n}\n\nexport type WithHashMeta<T extends Payload = Payload> = T & HashMeta\nexport type WithPartialHashMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>\n\nexport const isHashMeta = (value: unknown): value is HashMeta => {\n return isDataHashMeta(value) && isHash((value as WithHashMeta)?._hash)\n}\n\nexport const asHashMeta = AsObjectFactory.create<HashMeta>(isHashMeta)\nexport const asOptionalHashMeta = AsObjectFactory.createOptional<HashMeta>(isHashMeta)\n\n/** @deprecated use HashMeta instead */\nexport interface HashStorageMeta extends HashMeta {}\n\n/** @deprecated use WithHashMeta instead */\nexport type WithHashStorageMeta<T extends Payload = Payload> = WithHashMeta<T>\n\n/** @deprecated use WithPartialHashMeta instead */\nexport type WithPartialHashStorageMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>\n\n/** @deprecated use isHashMeta instead */\nexport const isHashStorageMeta = isHashMeta\n\n/** @deprecated use asHashMeta instead */\nexport const asHashStorageMeta = asHashMeta\n\n/** @deprecated use asOptionalHashMeta instead */\nexport const asOptionalHashStorageMeta = asOptionalHashMeta\n","import { AsObjectFactory } from '@xylabs/object'\n\nimport type { Payload } from '../Payload.ts'\nimport type { Sequence } from './sequence/index.ts'\n\nexport interface SequenceStorageMeta {\n _sequence: Sequence\n}\n\nexport type WithSequenceStorageMeta<T extends Payload = Payload> = T & SequenceStorageMeta\nexport type WithPartialSequenceStorageMeta<T extends Payload = Payload> = Partial<WithSequenceStorageMeta<T>>\n\nexport const isSequenceStorageMeta = (value: unknown): value is SequenceStorageMeta => {\n return (value as WithSequenceStorageMeta)?._sequence != undefined\n}\n\nexport const asSequenceStorageMeta = AsObjectFactory.create(isSequenceStorageMeta)\nexport const asOptionalSequenceStorageMeta = AsObjectFactory.createOptional(isSequenceStorageMeta)\n","import { toUint8Array } from '@xylabs/arraybuffer'\nimport { assertEx } from '@xylabs/assert'\nimport type {\n Address,\n Hash, Hex,\n} from '@xylabs/hex'\nimport {\n isAddress,\n toAddress,\n toHex,\n} from '@xylabs/hex'\n\nimport type {\n Epoch, LocalSequence, Nonce, QualifiedSequence,\n Sequence,\n} from './Sequence.ts'\nimport {\n isQualifiedSequence, isSequence,\n SequenceConstants,\n} from './Sequence.ts'\n\nexport class SequenceParser {\n protected static privateConstructorKey = Date.now().toString()\n\n private readonly data: Readonly<Uint8Array>\n\n protected constructor(privateConstructorKey: string, hex: Hex) {\n assertEx(SequenceParser.privateConstructorKey === privateConstructorKey, () => 'Use create function instead of constructor')\n const paddedHex = toHex(hex, {\n prefix: false,\n bitLength: (hex.length <= SequenceConstants.localSequenceBytes * 2)\n ? SequenceConstants.localSequenceBytes * 8\n : SequenceConstants.qualifiedSequenceBytes * 8,\n })\n this.data = toUint8Array(paddedHex)\n }\n\n get address(): Address {\n const start = SequenceConstants.localSequenceBytes\n const end = SequenceConstants.qualifiedSequenceBytes\n return toAddress(this.data.slice(start, end).buffer, { prefix: false })\n }\n\n get epoch(): Epoch {\n const start = 0\n const end = SequenceConstants.epochBytes\n return toHex(this.data.slice(start, end).buffer, { prefix: false }) as Epoch\n }\n\n get localSequence(): LocalSequence {\n const start = 0\n const end = SequenceConstants.localSequenceBytes\n return toHex(this.data.slice(start, end).buffer, { prefix: false }) as LocalSequence\n }\n\n get nonce(): Nonce {\n const start = SequenceConstants.epochBytes\n const end = SequenceConstants.localSequenceBytes\n return toHex(this.data.slice(start, end).buffer, { prefix: false }) as Nonce\n }\n\n get qualifiedSequence(): QualifiedSequence {\n const start = 0\n const end = SequenceConstants.qualifiedSequenceBytes\n return toHex(this.data.slice(start, end).buffer, { prefix: false }) as QualifiedSequence\n }\n\n static from(sequence: Sequence, address?: Address): SequenceParser\n static from(timestamp: Hex, hash: Hash, address?: Address): SequenceParser\n static from(timestamp: Hex, hash: Hex, address?: Address): SequenceParser\n static from(timestamp: Hex, nonce: Nonce, address?: Address): SequenceParser\n static from(timestamp: Hex, hash: Hash, index?: number, address?: Address): SequenceParser\n static from(timestamp: Hex, hash: Hex, index?: number, address?: Address): SequenceParser\n static from(timestamp: Hex, nonce: Nonce, index?: number, address?: Address): SequenceParser\n static from(timestamp: number, hash: Hash, address?: Address): SequenceParser\n static from(timestamp: number, hash: Hex, address?: Address): SequenceParser\n static from(timestamp: number, nonce: Nonce, address?: Address): SequenceParser\n static from(timestamp: number, hash: Hash, index?: number, address?: Address): SequenceParser\n static from(timestamp: number, hash: Hex, index?: number, address?: Address): SequenceParser\n static from(timestamp: number, nonce: Nonce, index?: number, address?: Address): SequenceParser\n static from(\n timestampOrSequence: Hex | number,\n nonceOrAddress?: Hex,\n addressOrIndex?: Address | number,\n addressOnly?: Address,\n ): SequenceParser {\n const address = typeof addressOrIndex === 'number' ? addressOnly : addressOrIndex\n const index = typeof addressOrIndex === 'number' ? addressOrIndex : undefined\n if (isSequence(timestampOrSequence)) {\n if (nonceOrAddress) {\n assertEx(!isQualifiedSequence(timestampOrSequence), () => 'Providing both a qualified sequence and a address is not allowed')\n assertEx(isAddress(nonceOrAddress), () => 'Invalid address provided')\n return new this(SequenceParser.privateConstructorKey, (timestampOrSequence + address) as Hex)\n }\n return new this(SequenceParser.privateConstructorKey, timestampOrSequence)\n }\n const epoch = SequenceParser.toEpoch(timestampOrSequence)\n const nonce = nonceOrAddress === undefined ? undefined : SequenceParser.toNonce(nonceOrAddress, index)\n const addressHex: Hex = address ? toHex(address, { bitLength: SequenceConstants.addressBytes * 8 }) : SequenceConstants.minAddress\n const hexString = (epoch + nonce + addressHex) as Hex\n assertEx(isSequence(hexString), () => `Invalid sequence [${hexString}] [${epoch}, ${nonce}, ${addressHex}]`)\n return new this(SequenceParser.privateConstructorKey, hexString)\n }\n\n static parse(value: Hex | string | ArrayBufferLike): SequenceParser {\n const hex = toHex(value)\n if (isSequence(hex)) {\n return new this(SequenceParser.privateConstructorKey, hex)\n }\n throw new Error(`Invalid sequence [${value}]`)\n }\n\n // can convert a short number/hex to an epoch (treats it as the whole value) or extract an epoch from a sequence\n static toEpoch(value: number | Hex | Epoch): Epoch {\n assertEx(\n typeof value !== 'number' || Number.isInteger(value),\n () => 'Value must be in integer',\n )\n const hex = toHex(value, { prefix: false })\n if (hex.length <= SequenceConstants.epochBytes * 2) {\n return toHex(value, { prefix: false, bitLength: SequenceConstants.epochBytes * 8 }) as Epoch\n }\n if (isSequence(hex)) {\n return hex.slice(0, SequenceConstants.epochBytes * 2) as Epoch\n }\n throw new Error(`Value could not be converted to epoch [${hex}]`)\n }\n\n // can convert a short number/hex to a nonce (treats it as the whole value) or extract an nonce from a sequence\n static toNonce(value: Hash | Hex, index = 0): Nonce {\n assertEx(\n typeof value !== 'number' || Number.isInteger(value),\n () => 'Value must be in integer',\n )\n const hex = toHex(value, { prefix: false })\n if (isSequence(hex)) {\n return hex.slice(SequenceConstants.epochBytes * 2, SequenceConstants.localSequenceBytes * 2) as Nonce\n }\n const hashHex = toHex((hex as string), { prefix: false, bitLength: SequenceConstants.nonceHashBytes * 8 }).slice(-SequenceConstants.nonceHashBytes * 2)\n const indexHex = toHex(index, { prefix: false, bitLength: SequenceConstants.nonceIndexBytes * 8 }).slice(-SequenceConstants.nonceIndexBytes * 2)\n return (indexHex + hashHex).slice(-SequenceConstants.nonceBytes * 2) as Nonce\n }\n}\n","import type { Address, Hex } from '@xylabs/hex'\nimport { isHex } from '@xylabs/hex'\nimport type { Brand } from '@xylabs/typeof'\n\n// we use Exclude to intentionally make the type not equal to string\nexport type LocalSequence = Brand<Hex, { __localSequence: true }>\nexport type QualifiedSequence = Brand<Hex, { __qualifiedSequence: true }>\nexport type Sequence = LocalSequence | QualifiedSequence\n\nexport type Epoch = Brand<Hex, { __epoch: true }>\n\nexport const isEpoch = (value: unknown): value is Epoch => {\n return isHex(value) && (value as string).length === SequenceConstants.epochBytes * 2\n}\n\nexport type Nonce = Brand<Hex, { __nonce: true }>\n\nexport const isNonce = (value: unknown): value is Nonce => {\n return isHex(value) && (value as string).length === SequenceConstants.nonceBytes * 2\n}\n\nexport const isLocalSequence = (value: unknown): value is LocalSequence => {\n return isHex(value) && (value as string).length === SequenceConstants.localSequenceBytes * 2\n}\n\nexport const isQualifiedSequence = (value: unknown): value is QualifiedSequence => {\n return isHex(value) && (value as string).length === SequenceConstants.qualifiedSequenceBytes * 2\n}\n\nexport const isSequence = (value: unknown): value is Sequence => {\n return isLocalSequence(value) || isQualifiedSequence(value)\n}\n\nexport const SequenceNonceComponentLengths = {\n nonceIndexBytes: 4,\n nonceHashBytes: 4,\n}\n\nexport const SequenceComponentLengths = {\n ...SequenceNonceComponentLengths,\n epochBytes: 8,\n nonceBytes: SequenceNonceComponentLengths.nonceIndexBytes + SequenceNonceComponentLengths.nonceHashBytes,\n addressBytes: 20,\n}\n\nexport const SequenceComponentMinMax = {\n minEpoch: '0'.repeat(SequenceComponentLengths.epochBytes * 2) as Epoch,\n maxEpoch: 'f'.repeat(SequenceComponentLengths.epochBytes * 2) as Epoch,\n minNonce: '0'.repeat(SequenceComponentLengths.nonceBytes * 2) as Nonce,\n maxNonce: 'f'.repeat(SequenceComponentLengths.nonceBytes * 2) as Nonce,\n minAddress: '0'.repeat(SequenceComponentLengths.addressBytes * 2) as Address,\n maxAddress: 'f'.repeat(SequenceComponentLengths.addressBytes * 2) as Address,\n}\n\nexport const LocalSequenceConstants = {\n ...SequenceComponentLengths,\n ...SequenceComponentMinMax,\n localSequenceBytes: SequenceComponentLengths.epochBytes + SequenceComponentLengths.nonceBytes,\n minLocalSequence: SequenceComponentMinMax.minEpoch + SequenceComponentMinMax.minNonce as LocalSequence,\n maxLocalSequence: SequenceComponentMinMax.maxEpoch + SequenceComponentMinMax.maxNonce as LocalSequence,\n}\n\nexport const QualifiedSequenceConstants = {\n qualifiedSequenceBytes: LocalSequenceConstants.localSequenceBytes + SequenceComponentLengths.addressBytes,\n minQualifiedSequence: LocalSequenceConstants.minLocalSequence + SequenceComponentMinMax.minAddress as QualifiedSequence,\n maxQualifiedSequence: LocalSequenceConstants.maxLocalSequence + SequenceComponentMinMax.maxAddress as QualifiedSequence,\n}\n\nexport const SequenceConstants = {\n ...LocalSequenceConstants,\n ...QualifiedSequenceConstants,\n}\n\n// \"11111111111111112222222222222222\" is and example of a local sequence string\n\n// \"111111111111111122222222222222223333333333333333333333333333333333333333\" is and example of a local sequence string\n// epoch = \"1111111111111111\"\n// nonce = \"2222222222222222\"\n// address = \"3333333333333333333333333333333333333333\"\n","import type { Compare } from '@xylabs/object'\n\nimport { SequenceParser } from './Parser.ts'\nimport type { Sequence } from './Sequence.ts'\n\nconst local: Compare<Sequence> = (a, b) => {\n const aa = SequenceParser.from(a)\n const bb = SequenceParser.from(b)\n return aa.localSequence > bb.localSequence ? 1 : aa.localSequence < bb.localSequence ? -1 : 0\n}\n\nconst qualified: Compare<Sequence> = (a, b) => {\n const aa = SequenceParser.from(a)\n const bb = SequenceParser.from(b)\n return aa.qualifiedSequence > bb.qualifiedSequence ? 1 : aa.qualifiedSequence < bb.qualifiedSequence ? -1 : 0\n}\n\nexport const SequenceComparer = { local, qualified }\n","import { HexRegExMinMax, toHex } from '@xylabs/hex'\nimport z from 'zod'\n\nimport type { LocalSequence, QualifiedSequence } from './Sequence.ts'\nimport { SequenceConstants } from './Sequence.ts'\n\nconst LocalSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.localSequenceBytes, SequenceConstants.localSequenceBytes))\nexport const LocalSequenceToStringZod = z.string().regex(LocalSequenceRegex)\nexport const LocalSequenceFromStringZod = z.string().regex(LocalSequenceRegex).transform<LocalSequence>(v => toHex(v) as LocalSequence)\n\nconst QualifiedSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.qualifiedSequenceBytes, SequenceConstants.qualifiedSequenceBytes))\nexport const QualifiedSequenceToStringZod = z.string().regex(QualifiedSequenceRegex)\nexport const QualifiedSequenceFromStringZod = z.string().regex(QualifiedSequenceRegex).transform<QualifiedSequence>(v => toHex(v) as QualifiedSequence)\n\nexport const SequenceToStringZod = z.union([LocalSequenceToStringZod, QualifiedSequenceToStringZod])\nexport const SequenceFromStringZod = z.union([LocalSequenceFromStringZod, QualifiedSequenceFromStringZod])\n","import { AsObjectFactory } from '@xylabs/object'\n\nimport type { Payload } from '../Payload.ts'\nimport type { HashMeta } from './Hash.ts'\nimport { isHashMeta } from './Hash.ts'\nimport type { SequenceStorageMeta } from './Sequence.ts'\nimport { isSequenceStorageMeta } from './Sequence.ts'\n\nexport interface StorageMeta extends SequenceStorageMeta, HashMeta {}\n\nexport type WithStorageMeta<T extends Payload = Payload> = T & StorageMeta\nexport type WithPartialStorageMeta<T extends Payload = Payload> = T & Partial<StorageMeta>\n\nexport const isStorageMeta = (value: unknown): value is StorageMeta => {\n return isSequenceStorageMeta(value) && isHashMeta(value)\n}\n\nexport const asStorageMeta = AsObjectFactory.create(isStorageMeta)\nexport const asOptionalStorageMeta = AsObjectFactory.createOptional(isStorageMeta)\n"],"mappings":";AAAA,SAAS,iBAAiB,gBAAgB;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,OAAQ,MAAkB,WAAW;AAAA,EAC9C;AACA,SAAO;AACT;AAEO,IAAM,eAAe,gBAAgB,OAAO,YAAY;AAExD,IAAM,YACT,CAAoB,WACpB,CAAC,UAA+B;AAC9B,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO,OAAO,SAAS,MAAM,MAAM;AAAA,EACrC;AACA,SAAO;AACT;AAEG,IAAM,YAAY,CAAoB,WAAqB,gBAAgB,OAAO,CAAC,UAA+B,UAAU,MAAM,EAAE,KAAK,CAAC;;;ACnB1I,SAAS,sBAAyD,QAAqB;AAC5F,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,mCAAmC,CAAoC,WAAwB;AAC1G,SAAO,CAAC,MACN,sBAAsC,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,UAAa,MAAM,QAAQ,EAAE,QAAQ;AAC3G;AAEO,IAAM,yBAAyB,CAAoC,WAAwB;AAChG,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AO,SAAS,OAAO,eAAe,KAAK;AAC7C;AAEO,SAAS,gBAAyC,UAA0B;AACjF,SAAO,SAAS,OAAO,YAAY,KAAK;AAC1C;AAEO,IAAM,mBAAmBA,GAAE,aAAa,EAAE,QAAQ,UAAU,CAAC;AAE7D,IAAM,kBAAoCA,GAAE,YAAY,EAAE,QAAQ,UAAU,CAAC;AAE7E,IAAM,2BAA2B,CAAmB,WAAc,iBAAiB,OAAO,EAAE,QAAQA,GAAE,QAAQ,MAAM,EAAE,CAAC;AACvH,IAAM,0BAA0B,CAAmB,WAAc,gBAAgB,OAAO,EAAE,QAAQA,GAAE,QAAQ,MAAM,EAAE,CAAC;","names":["AsObjectFactory","AsObjectFactory","z","AsObjectFactory","isHash","AsObjectFactory","isHash","AsObjectFactory","AsObjectFactory","toHex","z","z","toHex","AsObjectFactory","AsObjectFactory","z"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/payload-model",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.20",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"src"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@xylabs/arraybuffer": "~5.0.
|
|
37
|
-
"@xylabs/assert": "~5.0.
|
|
38
|
-
"@xylabs/hex": "~5.0.
|
|
39
|
-
"@xylabs/object": "~5.0.
|
|
40
|
-
"@xylabs/typeof": "~5.0.
|
|
36
|
+
"@xylabs/arraybuffer": "~5.0.24",
|
|
37
|
+
"@xylabs/assert": "~5.0.24",
|
|
38
|
+
"@xylabs/hex": "~5.0.24",
|
|
39
|
+
"@xylabs/object": "~5.0.24",
|
|
40
|
+
"@xylabs/typeof": "~5.0.24",
|
|
41
41
|
"zod": "~4.1.12"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@xylabs/ts-scripts-yarn3": "~7.2.
|
|
45
|
-
"@xylabs/tsconfig": "~7.2.
|
|
46
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
44
|
+
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
45
|
+
"@xylabs/tsconfig": "~7.2.8",
|
|
46
|
+
"@xylabs/vitest-extended": "~5.0.24",
|
|
47
47
|
"typescript": "~5.9.3",
|
|
48
48
|
"vitest": "~4.0.8"
|
|
49
49
|
},
|
package/src/PayloadZod.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HashZod } from '@xylabs/hex'
|
|
2
|
-
import
|
|
2
|
+
import z from 'zod'
|
|
3
3
|
|
|
4
4
|
import { SchemaZod } from './Schema.ts'
|
|
5
5
|
import { SequenceFromStringZod } from './StorageMeta/index.ts'
|
|
@@ -18,18 +18,31 @@ export const StorageMetaZod = z.object({
|
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
export const PayloadZod = z.object({ schema: SchemaZod })
|
|
21
|
+
|
|
22
|
+
/** @deprecated use WithStorageMetaZod */
|
|
21
23
|
export const PayloadWithStorageMetaZod = PayloadZod.extend(StorageMetaZod.shape)
|
|
22
24
|
|
|
23
25
|
export const AnyPayloadZod = PayloadZod.catchall(z.json())
|
|
26
|
+
|
|
27
|
+
/** @deprecated use WithStorageMetaZod */
|
|
24
28
|
export const AnyPayloadWithStorageMetaZod = AnyPayloadZod.extend(StorageMetaZod.shape)
|
|
25
29
|
|
|
30
|
+
/** @deprecated use WithStorageMetaZod */
|
|
31
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
26
32
|
export type PayloadWithStorageMeta = z.infer<typeof PayloadWithStorageMetaZod>
|
|
27
33
|
|
|
28
34
|
export type AnyPayload = z.infer<typeof AnyPayloadZod>
|
|
35
|
+
|
|
36
|
+
/** @deprecated use WithStorageMetaZod */
|
|
37
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
29
38
|
export type AnyPayloadWithStorageMeta = z.infer<typeof AnyPayloadWithStorageMetaZod>
|
|
30
39
|
|
|
31
|
-
export function WithStorageMetaZod<T extends
|
|
32
|
-
return
|
|
40
|
+
export function WithStorageMetaZod<T extends z.ZodRawShape>(valueZod: z.ZodObject<T>) {
|
|
41
|
+
return valueZod.extend(StorageMetaZod.shape)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function WithHashMetaZod<T extends z.ZodRawShape>(valueZod: z.ZodObject<T>) {
|
|
45
|
+
return valueZod.extend(HashMetaZod.shape)
|
|
33
46
|
}
|
|
34
47
|
|
|
35
48
|
export const PayloadZodStrict = z.strictObject({ schema: SchemaZod })
|
package/src/Schema.ts
CHANGED