@xyo-network/payload-model 5.1.17 → 5.1.19
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 -47
- package/dist/neutral/PayloadZod.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/index.mjs +11 -4
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/PayloadZod.ts +12 -5
|
@@ -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.19-2caad636a4/package").AnyNonPromise) => PayloadBundle | undefined;
|
|
13
13
|
//# sourceMappingURL=PayloadBundle.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
-
export declare const
|
|
3
|
-
_hash: z.
|
|
2
|
+
export declare const HashMetaZod: z.ZodObject<{
|
|
3
|
+
_hash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
4
4
|
readonly __hex: true;
|
|
5
5
|
}>, {
|
|
6
6
|
readonly __hash: true;
|
|
@@ -8,12 +8,22 @@ export declare const StorageMetaZod: z.ZodObject<{
|
|
|
8
8
|
readonly __hex: true;
|
|
9
9
|
}>, {
|
|
10
10
|
readonly __hash: true;
|
|
11
|
-
}>, unknown
|
|
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>, {
|
|
12
17
|
readonly __hex: true;
|
|
13
18
|
}>, {
|
|
14
19
|
readonly __hash: true;
|
|
15
|
-
}
|
|
16
|
-
|
|
20
|
+
}>, unknown>>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export declare const SequenceMetaZod: z.ZodObject<{
|
|
23
|
+
_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>;
|
|
25
|
+
export declare const StorageMetaZod: z.ZodObject<{
|
|
26
|
+
_hash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
17
27
|
readonly __hex: true;
|
|
18
28
|
}>, {
|
|
19
29
|
readonly __hash: true;
|
|
@@ -21,12 +31,17 @@ export declare const StorageMetaZod: z.ZodObject<{
|
|
|
21
31
|
readonly __hex: true;
|
|
22
32
|
}>, {
|
|
23
33
|
readonly __hash: true;
|
|
24
|
-
}>, unknown
|
|
34
|
+
}>, unknown>>;
|
|
35
|
+
_dataHash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
25
36
|
readonly __hex: true;
|
|
26
37
|
}>, {
|
|
27
38
|
readonly __hash: true;
|
|
28
|
-
}
|
|
29
|
-
|
|
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>>;
|
|
44
|
+
_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>>]>;
|
|
30
45
|
}, z.core.$strip>;
|
|
31
46
|
export declare const PayloadZod: z.ZodObject<{
|
|
32
47
|
schema: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
@@ -37,7 +52,7 @@ export declare const PayloadWithStorageMetaZod: z.ZodObject<{
|
|
|
37
52
|
schema: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
38
53
|
__schema: true;
|
|
39
54
|
}, string>>]>;
|
|
40
|
-
_hash: z.
|
|
55
|
+
_hash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
41
56
|
readonly __hex: true;
|
|
42
57
|
}>, {
|
|
43
58
|
readonly __hash: true;
|
|
@@ -45,12 +60,8 @@ export declare const PayloadWithStorageMetaZod: z.ZodObject<{
|
|
|
45
60
|
readonly __hex: true;
|
|
46
61
|
}>, {
|
|
47
62
|
readonly __hash: true;
|
|
48
|
-
}>, unknown
|
|
49
|
-
|
|
50
|
-
}>, {
|
|
51
|
-
readonly __hash: true;
|
|
52
|
-
}>>>;
|
|
53
|
-
_dataHash: z.ZodPipe<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
63
|
+
}>, unknown>>;
|
|
64
|
+
_dataHash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
54
65
|
readonly __hex: true;
|
|
55
66
|
}>, {
|
|
56
67
|
readonly __hash: true;
|
|
@@ -58,12 +69,8 @@ export declare const PayloadWithStorageMetaZod: z.ZodObject<{
|
|
|
58
69
|
readonly __hex: true;
|
|
59
70
|
}>, {
|
|
60
71
|
readonly __hash: true;
|
|
61
|
-
}>, unknown
|
|
62
|
-
|
|
63
|
-
}>, {
|
|
64
|
-
readonly __hash: true;
|
|
65
|
-
}>>>;
|
|
66
|
-
_sequence: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
72
|
+
}>, unknown>>;
|
|
73
|
+
_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>>]>;
|
|
67
74
|
}, z.core.$strip>;
|
|
68
75
|
export declare const AnyPayloadZod: z.ZodObject<{
|
|
69
76
|
schema: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
@@ -74,7 +81,7 @@ export declare const AnyPayloadWithStorageMetaZod: z.ZodObject<{
|
|
|
74
81
|
schema: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
75
82
|
__schema: true;
|
|
76
83
|
}, string>>]>;
|
|
77
|
-
_hash: z.
|
|
84
|
+
_hash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
78
85
|
readonly __hex: true;
|
|
79
86
|
}>, {
|
|
80
87
|
readonly __hash: true;
|
|
@@ -82,12 +89,8 @@ export declare const AnyPayloadWithStorageMetaZod: z.ZodObject<{
|
|
|
82
89
|
readonly __hex: true;
|
|
83
90
|
}>, {
|
|
84
91
|
readonly __hash: true;
|
|
85
|
-
}>, unknown
|
|
86
|
-
|
|
87
|
-
}>, {
|
|
88
|
-
readonly __hash: true;
|
|
89
|
-
}>>>;
|
|
90
|
-
_dataHash: z.ZodPipe<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
92
|
+
}>, unknown>>;
|
|
93
|
+
_dataHash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
91
94
|
readonly __hex: true;
|
|
92
95
|
}>, {
|
|
93
96
|
readonly __hash: true;
|
|
@@ -95,18 +98,14 @@ export declare const AnyPayloadWithStorageMetaZod: z.ZodObject<{
|
|
|
95
98
|
readonly __hex: true;
|
|
96
99
|
}>, {
|
|
97
100
|
readonly __hash: true;
|
|
98
|
-
}>, unknown
|
|
99
|
-
|
|
100
|
-
}>, {
|
|
101
|
-
readonly __hash: true;
|
|
102
|
-
}>>>;
|
|
103
|
-
_sequence: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
101
|
+
}>, unknown>>;
|
|
102
|
+
_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>>]>;
|
|
104
103
|
}, z.core.$catchall<z.ZodJSONSchema>>;
|
|
105
104
|
export type PayloadWithStorageMeta = z.infer<typeof PayloadWithStorageMetaZod>;
|
|
106
105
|
export type AnyPayload = z.infer<typeof AnyPayloadZod>;
|
|
107
106
|
export type AnyPayloadWithStorageMeta = z.infer<typeof AnyPayloadWithStorageMetaZod>;
|
|
108
107
|
export declare function WithStorageMetaZod<T extends typeof PayloadZod>(valueZod: T): z.ZodObject<{
|
|
109
|
-
_hash: z.
|
|
108
|
+
_hash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
110
109
|
readonly __hex: true;
|
|
111
110
|
}>, {
|
|
112
111
|
readonly __hash: true;
|
|
@@ -114,12 +113,8 @@ export declare function WithStorageMetaZod<T extends typeof PayloadZod>(valueZod
|
|
|
114
113
|
readonly __hex: true;
|
|
115
114
|
}>, {
|
|
116
115
|
readonly __hash: true;
|
|
117
|
-
}>, unknown
|
|
118
|
-
|
|
119
|
-
}>, {
|
|
120
|
-
readonly __hash: true;
|
|
121
|
-
}>>>;
|
|
122
|
-
_dataHash: z.ZodPipe<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
116
|
+
}>, unknown>>;
|
|
117
|
+
_dataHash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
123
118
|
readonly __hex: true;
|
|
124
119
|
}>, {
|
|
125
120
|
readonly __hash: true;
|
|
@@ -127,12 +122,8 @@ export declare function WithStorageMetaZod<T extends typeof PayloadZod>(valueZod
|
|
|
127
122
|
readonly __hex: true;
|
|
128
123
|
}>, {
|
|
129
124
|
readonly __hash: true;
|
|
130
|
-
}>, unknown
|
|
131
|
-
|
|
132
|
-
}>, {
|
|
133
|
-
readonly __hash: true;
|
|
134
|
-
}>>>;
|
|
135
|
-
_sequence: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
125
|
+
}>, unknown>>;
|
|
126
|
+
_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>>]>;
|
|
136
127
|
schema: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
137
128
|
__schema: true;
|
|
138
129
|
}, string>>]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayloadZod.d.ts","sourceRoot":"","sources":["../../src/PayloadZod.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAKxB,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"Pay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|
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.19-2caad636a4/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.19-2caad636a4/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.19-2caad636a4/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.19-2caad636a4/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.19-2caad636a4/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.19-2caad636a4/package").AnyNonPromise) => StorageMeta | undefined;
|
|
11
11
|
//# sourceMappingURL=StorageMeta.d.ts.map
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -52,7 +52,7 @@ var asOptionalPayloadBundle = AsObjectFactory2.createOptional(isPayloadBundle);
|
|
|
52
52
|
var PayloadSetSchema = "network.xyo.payload.set";
|
|
53
53
|
|
|
54
54
|
// src/PayloadZod.ts
|
|
55
|
-
import {
|
|
55
|
+
import { HashZod } from "@xylabs/hex";
|
|
56
56
|
import * as z3 from "zod";
|
|
57
57
|
|
|
58
58
|
// src/Schema.ts
|
|
@@ -292,10 +292,15 @@ var asStorageMeta = AsObjectFactory6.create(isStorageMeta);
|
|
|
292
292
|
var asOptionalStorageMeta = AsObjectFactory6.createOptional(isStorageMeta);
|
|
293
293
|
|
|
294
294
|
// src/PayloadZod.ts
|
|
295
|
+
var HashMetaZod = z3.object({
|
|
296
|
+
_hash: HashZod,
|
|
297
|
+
_dataHash: HashZod
|
|
298
|
+
});
|
|
299
|
+
var SequenceMetaZod = z3.object({ _sequence: SequenceFromStringZod });
|
|
295
300
|
var StorageMetaZod = z3.object({
|
|
296
|
-
_hash:
|
|
297
|
-
_dataHash:
|
|
298
|
-
_sequence:
|
|
301
|
+
_hash: HashZod,
|
|
302
|
+
_dataHash: HashZod,
|
|
303
|
+
_sequence: SequenceFromStringZod
|
|
299
304
|
});
|
|
300
305
|
var PayloadZod = z3.object({ schema: SchemaZod });
|
|
301
306
|
var PayloadWithStorageMetaZod = PayloadZod.extend(StorageMetaZod.shape);
|
|
@@ -311,6 +316,7 @@ var PayloadZodLooseOfSchema = (schema) => PayloadZodLoose.extend({ schema: z3.li
|
|
|
311
316
|
export {
|
|
312
317
|
AnyPayloadWithStorageMetaZod,
|
|
313
318
|
AnyPayloadZod,
|
|
319
|
+
HashMetaZod,
|
|
314
320
|
LocalSequenceConstants,
|
|
315
321
|
LocalSequenceFromStringZod,
|
|
316
322
|
LocalSequenceToStringZod,
|
|
@@ -337,6 +343,7 @@ export {
|
|
|
337
343
|
SequenceComponentMinMax,
|
|
338
344
|
SequenceConstants,
|
|
339
345
|
SequenceFromStringZod,
|
|
346
|
+
SequenceMetaZod,
|
|
340
347
|
SequenceNonceComponentLengths,
|
|
341
348
|
SequenceParser,
|
|
342
349
|
SequenceToStringZod,
|
|
@@ -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 { HashToJsonZod } from '@xylabs/hex'\nimport * as z from 'zod'\n\nimport { SchemaZod } from './Schema.ts'\nimport { SequenceToStringZod } from './StorageMeta/index.ts'\n\nexport const StorageMetaZod = z.object({\n _hash: HashToJsonZod,\n _dataHash: HashToJsonZod,\n _sequence: SequenceToStringZod,\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,IAAM,oBAAoB;AAW1B,IAAM,gBAAgB,sBAAmC,iBAAiB;;;AClBjF,SAAS,iBAAiB;AAcnB,SAAS,mBAGd,WAAc,QAAsB;AACpC,SAAO,CAAC,MAA+B;AACrC,QAAI,CAAC,aAAa,CAAC,EAAG,QAAO;AAC7B,QAAI,UAA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AE,MAAM,sBAAsB;AAC5E,IAAM,iCAAmC,UAAO,EAAE,MAAM,sBAAsB,EAAE,UAA6B,OAAKA,OAAM,CAAC,CAAsB;AAE/I,IAAM,sBAAwB,SAAM,CAAC,0BAA0B,4BAA4B,CAAC;AAC5F,IAAM,wBAA0B,SAAM,CAAC,4BAA4B,8BAA8B,CAAC;;;ACfzG,SAAS,mBAAAC,wBAAuB;AAazB,IAAM,gBAAgB,CAAC,UAAyC;AACrE,SAAO,sBAAsB,KAAK,KAAK,WAAW,KAAK;AACzD;AAEO,IAAM,gBAAgBC,iBAAgB,OAAO,aAAa;AAC1D,IAAM,wBAAwBA,iBAAgB,eAAe,aAAa;;;ATZ1E,IAAM,iBAAmB,UAAO;AAAA,EACrC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,WAAW;AACb,CAAC;AAEM,IAAM,aAAe,UAAO,EAAE,QAAQ,UAAU,CAAC;AACjD,IAAM,4BAA4B,WAAW,OAAO,eAAe,KAAK;AAExE,IAAM,gBAAgB,WAAW,SAAW,QAAK,CAAC;AAClD,IAAM,+BAA+B,cAAc,OAAO,eAAe,KAAK;AAO9E,SAAS,mBAAgD,UAAa;AAC3E,SAAO,eAAe,OAAO,SAAS,KAAK;AAC7C;AAEO,IAAM,mBAAqB,gBAAa,EAAE,QAAQ,UAAU,CAAC;AAE7D,IAAM,kBAAsC,eAAY,EAAE,QAAQ,UAAU,CAAC;AAE7E,IAAM,2BAA2B,CAAmB,WAAc,iBAAiB,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 * 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,IAA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K,KAAK,WAAW,KAAK;AACzD;AAEO,IAAM,gBAAgBC,iBAAgB,OAAO,aAAa;AAC1D,IAAM,wBAAwBA,iBAAgB,eAAe,aAAa;;;ATZ1E,IAAM,cAAgB,UAAO;AAAA,EAClC,OAAO;AAAA,EACP,WAAW;AACb,CAAC;AAEM,IAAM,kBAAoB,UAAO,EAAE,WAAW,sBAAsB,CAAC;AAErE,IAAM,iBAAmB,UAAO;AAAA,EACrC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,WAAW;AACb,CAAC;AAEM,IAAM,aAAe,UAAO,EAAE,QAAQ,UAAU,CAAC;AACjD,IAAM,4BAA4B,WAAW,OAAO,eAAe,KAAK;AAExE,IAAM,gBAAgB,WAAW,SAAW,QAAK,CAAC;AAClD,IAAM,+BAA+B,cAAc,OAAO,eAAe,KAAK;AAO9E,SAAS,mBAAgD,UAAa;AAC3E,SAAO,eAAe,OAAO,SAAS,KAAK;AAC7C;AAEO,IAAM,mBAAqB,gBAAa,EAAE,QAAQ,UAAU,CAAC;AAE7D,IAAM,kBAAsC,eAAY,EAAE,QAAQ,UAAU,CAAC;AAE7E,IAAM,2BAA2B,CAAmB,WAAc,iBAAiB,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"]}
|
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.19",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -33,19 +33,19 @@
|
|
|
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.19",
|
|
37
|
+
"@xylabs/assert": "~5.0.19",
|
|
38
|
+
"@xylabs/hex": "~5.0.19",
|
|
39
|
+
"@xylabs/object": "~5.0.19",
|
|
40
|
+
"@xylabs/typeof": "~5.0.19",
|
|
41
41
|
"zod": "~4.1.12"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@xylabs/ts-scripts-yarn3": "~7.2.4",
|
|
45
45
|
"@xylabs/tsconfig": "~7.2.4",
|
|
46
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
46
|
+
"@xylabs/vitest-extended": "~5.0.19",
|
|
47
47
|
"typescript": "~5.9.3",
|
|
48
|
-
"vitest": "~4.0.
|
|
48
|
+
"vitest": "~4.0.8"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
package/src/PayloadZod.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HashZod } from '@xylabs/hex'
|
|
2
2
|
import * as z from 'zod'
|
|
3
3
|
|
|
4
4
|
import { SchemaZod } from './Schema.ts'
|
|
5
|
-
import {
|
|
5
|
+
import { SequenceFromStringZod } from './StorageMeta/index.ts'
|
|
6
|
+
|
|
7
|
+
export const HashMetaZod = z.object({
|
|
8
|
+
_hash: HashZod,
|
|
9
|
+
_dataHash: HashZod,
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
export const SequenceMetaZod = z.object({ _sequence: SequenceFromStringZod })
|
|
6
13
|
|
|
7
14
|
export const StorageMetaZod = z.object({
|
|
8
|
-
_hash:
|
|
9
|
-
_dataHash:
|
|
10
|
-
_sequence:
|
|
15
|
+
_hash: HashZod,
|
|
16
|
+
_dataHash: HashZod,
|
|
17
|
+
_sequence: SequenceFromStringZod,
|
|
11
18
|
})
|
|
12
19
|
|
|
13
20
|
export const PayloadZod = z.object({ schema: SchemaZod })
|