@xyo-network/payload-model 5.1.24 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/Error.d.ts +1 -1
- package/dist/neutral/Error.d.ts.map +1 -1
- package/dist/neutral/PayloadBundle.d.ts +3 -2
- package/dist/neutral/PayloadBundle.d.ts.map +1 -1
- package/dist/neutral/PayloadSet/PayloadSetSchema.d.ts +2 -1
- package/dist/neutral/PayloadSet/PayloadSetSchema.d.ts.map +1 -1
- package/dist/neutral/PayloadZod.d.ts +7 -17
- package/dist/neutral/PayloadZod.d.ts.map +1 -1
- package/dist/neutral/Schema.d.ts +11 -12
- 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/index.mjs +8 -12
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +8 -7
- package/src/Error.ts +1 -1
- package/src/PayloadBundle.ts +2 -1
- package/src/PayloadSet/PayloadSetSchema.ts +3 -1
- package/src/PayloadZod.ts +1 -1
- package/src/Schema.ts +6 -12
package/dist/neutral/Error.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Hash } from '@xylabs/hex';
|
|
|
2
2
|
import type { JsonValue } from '@xylabs/object';
|
|
3
3
|
import type { Payload } from './Payload.ts';
|
|
4
4
|
import type { Schema } from './Schema.ts';
|
|
5
|
-
export declare const ModuleErrorSchema:
|
|
5
|
+
export declare const ModuleErrorSchema: Schema;
|
|
6
6
|
export type ModuleErrorSchema = typeof ModuleErrorSchema;
|
|
7
7
|
export type ModuleError = Payload<{
|
|
8
8
|
details?: JsonValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,eAAO,MAAM,iBAAiB,EAAiC,MAAM,CAAA;AACrE,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAA;AAExD,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,MAAM,EAAE,iBAAiB,CAAA;CAC1B,CAAC,CAAA;AAEF,eAAO,MAAM,aAAa,0CAAwD,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/hex';
|
|
2
2
|
import type { Payload } from './Payload.ts';
|
|
3
|
-
|
|
3
|
+
import type { Schema } from './Schema.ts';
|
|
4
|
+
export declare const PayloadBundleSchema: Schema;
|
|
4
5
|
export type PayloadBundleSchema = typeof PayloadBundleSchema;
|
|
5
6
|
export interface PayloadBundleFields<T extends Payload = Payload> {
|
|
6
7
|
payloads: T[];
|
|
@@ -9,5 +10,5 @@ export interface PayloadBundleFields<T extends Payload = Payload> {
|
|
|
9
10
|
export type PayloadBundle = Payload<PayloadBundleFields, PayloadBundleSchema>;
|
|
10
11
|
export declare const isPayloadBundle: (x?: unknown | null) => x is PayloadBundle;
|
|
11
12
|
export declare const asPayloadBundle: import("@xylabs/object").AsTypeFunction<PayloadBundle>;
|
|
12
|
-
export declare const asOptionalPayloadBundle: (value: import(".store/@xylabs-promise-npm-5.0.
|
|
13
|
+
export declare const asOptionalPayloadBundle: (value: import(".store/@xylabs-promise-npm-5.0.39-909d8d4932/package").AnyNonPromise) => PayloadBundle | undefined;
|
|
13
14
|
//# sourceMappingURL=PayloadBundle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayloadBundle.d.ts","sourceRoot":"","sources":["../../src/PayloadBundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAIvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"PayloadBundle.d.ts","sourceRoot":"","sources":["../../src/PayloadBundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAIvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGzC,eAAO,MAAM,mBAAmB,EAAmC,MAAM,CAAA;AACzE,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAA;AAE5D,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO;IAC9D,QAAQ,EAAE,CAAC,EAAE,CAAA;IACb,IAAI,EAAE,IAAI,CAAA;CACX;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAA;AAE7E,eAAO,MAAM,eAAe,4CAA4D,CAAA;AAExF,eAAO,MAAM,eAAe,wDAA0C,CAAA;AACtE,eAAO,MAAM,uBAAuB,oHAAkD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayloadSetSchema.d.ts","sourceRoot":"","sources":["../../../src/PayloadSet/PayloadSetSchema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"PayloadSetSchema.d.ts","sourceRoot":"","sources":["../../../src/PayloadSet/PayloadSetSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,eAAO,MAAM,gBAAgB,EAAgC,MAAM,CAAA;AACnE,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAA"}
|
|
@@ -12,33 +12,25 @@ export declare const StorageMetaZod: z.ZodObject<{
|
|
|
12
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>>]>;
|
|
13
13
|
}, z.z.core.$strip>;
|
|
14
14
|
export declare const PayloadZod: z.ZodObject<{
|
|
15
|
-
schema: z.
|
|
16
|
-
__schema: true;
|
|
17
|
-
}, string>>]>;
|
|
15
|
+
schema: z.ZodString;
|
|
18
16
|
}, z.z.core.$strip>;
|
|
19
17
|
/** @deprecated use WithStorageMetaZod */
|
|
20
18
|
export declare const PayloadWithStorageMetaZod: z.ZodObject<{
|
|
21
|
-
schema: z.
|
|
22
|
-
__schema: true;
|
|
23
|
-
}, string>>]>;
|
|
19
|
+
schema: z.ZodString;
|
|
24
20
|
_hash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
25
21
|
_dataHash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
26
22
|
_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>>]>;
|
|
27
23
|
}, z.z.core.$strip>;
|
|
28
24
|
export declare const AnyPayloadZod: z.ZodObject<{
|
|
29
|
-
schema: z.
|
|
30
|
-
|
|
31
|
-
}, string>>]>;
|
|
32
|
-
}, z.z.core.$catchall<z.ZodJSONSchema>>;
|
|
25
|
+
schema: z.ZodString;
|
|
26
|
+
}, z.z.core.$loose>;
|
|
33
27
|
/** @deprecated use WithStorageMetaZod */
|
|
34
28
|
export declare const AnyPayloadWithStorageMetaZod: z.ZodObject<{
|
|
35
|
-
schema: z.
|
|
36
|
-
__schema: true;
|
|
37
|
-
}, string>>]>;
|
|
29
|
+
schema: z.ZodString;
|
|
38
30
|
_hash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
39
31
|
_dataHash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
40
32
|
_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>>]>;
|
|
41
|
-
}, z.z.core.$
|
|
33
|
+
}, z.z.core.$loose>;
|
|
42
34
|
/** @deprecated use WithStorageMetaZod */
|
|
43
35
|
export type PayloadWithStorageMeta = z.infer<typeof PayloadWithStorageMetaZod>;
|
|
44
36
|
export type AnyPayload = z.infer<typeof AnyPayloadZod>;
|
|
@@ -61,9 +53,7 @@ export declare function WithHashMetaZod<T extends z.ZodRawShape>(valueZod: z.Zod
|
|
|
61
53
|
_dataHash: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Hash, string>>;
|
|
62
54
|
}) extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.z.core.$strip>;
|
|
63
55
|
export declare const PayloadZodStrict: z.ZodObject<{
|
|
64
|
-
schema: z.
|
|
65
|
-
__schema: true;
|
|
66
|
-
}, string>>]>;
|
|
56
|
+
schema: z.ZodString;
|
|
67
57
|
}, z.z.core.$strict>;
|
|
68
58
|
export type PayloadZodStrict = typeof PayloadZodStrict;
|
|
69
59
|
export declare const PayloadZodLoose: PayloadZodStrict;
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;mBAAqB,CAAA;AAE/C,yCAAyC;AACzC,eAAO,MAAM,4BAA4B;;;;;mBAA6C,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,24 +1,23 @@
|
|
|
1
1
|
import type { EmptyObject } from '@xylabs/object';
|
|
2
2
|
import z from 'zod';
|
|
3
3
|
export declare const SchemaRegEx: RegExp;
|
|
4
|
-
export declare const
|
|
5
|
-
export
|
|
6
|
-
__schema: true;
|
|
7
|
-
}, string>>;
|
|
8
|
-
export type SchemaV2 = z.output<typeof SchemaZodV2>;
|
|
9
|
-
export type SchemaV1 = z.output<typeof SchemaZodV1>;
|
|
10
|
-
export declare const SchemaZod: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string & {
|
|
11
|
-
__schema: true;
|
|
12
|
-
}, string>>]>;
|
|
13
|
-
export type Schema = z.infer<typeof SchemaZodV1>;
|
|
4
|
+
export declare const SchemaZod: z.ZodString;
|
|
5
|
+
export type Schema = z.infer<typeof SchemaZod>;
|
|
14
6
|
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
7
|
__schema: true;
|
|
16
8
|
}>, 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
9
|
export declare const PayloadSchema: "network.xyo.payload";
|
|
18
10
|
export declare const PayloadSchemaZod: z.ZodLiteral<"network.xyo.payload">;
|
|
19
11
|
export type PayloadSchema = z.infer<typeof PayloadSchemaZod>;
|
|
20
|
-
export declare const isSchema: (value: unknown) => value is
|
|
21
|
-
export declare const asSchema:
|
|
12
|
+
export declare const isSchema: (value: unknown) => value is string;
|
|
13
|
+
export declare const asSchema: {
|
|
14
|
+
(value: unknown): string | undefined;
|
|
15
|
+
(value: unknown, assert: import("@xylabs/zod").ZodFactoryConfig): string;
|
|
16
|
+
};
|
|
17
|
+
export declare const toSchema: {
|
|
18
|
+
(value: unknown): string | undefined;
|
|
19
|
+
(value: unknown, assert: import("@xylabs/zod").ZodFactoryConfig): string;
|
|
20
|
+
};
|
|
22
21
|
/** Add the Schema Fields to an object */
|
|
23
22
|
export type WithSchema<T extends EmptyObject | void = void> = T extends EmptyObject ? SchemaFields & T : SchemaFields;
|
|
24
23
|
/** Schema fields for a Payload */
|
|
@@ -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,CAAC,MAAM,KAAK,CAAA;AAEnB,eAAO,MAAM,WAAW,QAAgC,CAAA;AAExD,eAAO,MAAM,
|
|
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,SAAS,aAAgC,CAAA;AACtD,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAE9C,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,qCAA0B,CAAA;AAC/C,eAAO,MAAM,QAAQ;;;CAAsC,CAAA;AAC3D,eAAO,MAAM,QAAQ;;;CAAsC,CAAA;AAE3D,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.39-909d8d4932/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.39-909d8d4932/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.39-909d8d4932/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.39-909d8d4932/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.39-909d8d4932/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.39-909d8d4932/package").AnyNonPromise) => StorageMeta | undefined;
|
|
11
11
|
//# sourceMappingURL=StorageMeta.d.ts.map
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -56,21 +56,18 @@ import { HashZod } from "@xylabs/hex";
|
|
|
56
56
|
import z3 from "zod";
|
|
57
57
|
|
|
58
58
|
// src/Schema.ts
|
|
59
|
-
import {
|
|
59
|
+
import { zodAsFactory, zodIsFactory } from "@xylabs/zod";
|
|
60
60
|
import z from "zod";
|
|
61
61
|
var SchemaRegEx = /^(?:[a-z0-9]+\.)*[a-z0-9]+$/;
|
|
62
|
-
var
|
|
63
|
-
var SchemaZodV2 = z.string().regex(SchemaRegEx).transform((x) => x);
|
|
64
|
-
var SchemaZod = z.union([SchemaZodV1, SchemaZodV2]);
|
|
62
|
+
var SchemaZod = z.string().regex(SchemaRegEx);
|
|
65
63
|
var makeSchema = (value) => {
|
|
66
64
|
return z.templateLiteral([z.literal(value)]).transform((x) => x);
|
|
67
65
|
};
|
|
68
66
|
var PayloadSchema = "network.xyo.payload";
|
|
69
67
|
var PayloadSchemaZod = z.literal(PayloadSchema);
|
|
70
|
-
var isSchema = (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var asSchema = AsTypeFactory.create(isSchema);
|
|
68
|
+
var isSchema = zodIsFactory(SchemaZod);
|
|
69
|
+
var asSchema = zodAsFactory(SchemaZod, "asSchema");
|
|
70
|
+
var toSchema = zodAsFactory(SchemaZod, "toSchema");
|
|
74
71
|
|
|
75
72
|
// src/StorageMeta/DataHash.ts
|
|
76
73
|
import { isHash } from "@xylabs/hex";
|
|
@@ -304,7 +301,7 @@ var StorageMetaZod = z3.object({
|
|
|
304
301
|
});
|
|
305
302
|
var PayloadZod = z3.object({ schema: SchemaZod });
|
|
306
303
|
var PayloadWithStorageMetaZod = PayloadZod.extend(StorageMetaZod.shape);
|
|
307
|
-
var AnyPayloadZod = PayloadZod.
|
|
304
|
+
var AnyPayloadZod = PayloadZod.loose();
|
|
308
305
|
var AnyPayloadWithStorageMetaZod = AnyPayloadZod.extend(StorageMetaZod.shape);
|
|
309
306
|
function WithStorageMetaZod(valueZod) {
|
|
310
307
|
return valueZod.extend(StorageMetaZod.shape);
|
|
@@ -339,8 +336,6 @@ export {
|
|
|
339
336
|
QualifiedSequenceToStringZod,
|
|
340
337
|
SchemaRegEx,
|
|
341
338
|
SchemaZod,
|
|
342
|
-
SchemaZodV1,
|
|
343
|
-
SchemaZodV2,
|
|
344
339
|
SequenceComparer,
|
|
345
340
|
SequenceComponentLengths,
|
|
346
341
|
SequenceComponentMinMax,
|
|
@@ -390,6 +385,7 @@ export {
|
|
|
390
385
|
isSequenceStorageMeta,
|
|
391
386
|
isStorageMeta,
|
|
392
387
|
makeSchema,
|
|
393
|
-
notPayloadOfSchemaType
|
|
388
|
+
notPayloadOfSchemaType,
|
|
389
|
+
toSchema
|
|
394
390
|
};
|
|
395
391
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -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 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,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,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,cAAcC,GAAE,OAAO;AAAA,EAClC,OAAO;AAAA,EACP,WAAW;AACb,CAAC;AAEM,IAAM,kBAAkBA,GAAE,OAAO,EAAE,WAAW,sBAAsB,CAAC;AAErE,IAAM,iBAAiBA,GAAE,OAAO;AAAA,EACrC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,WAAW;AACb,CAAC;AAEM,IAAM,aAAaA,GAAE,OAAO,EAAE,QAAQ,UAAU,CAAC;AAGjD,IAAM,4BAA4B,WAAW,OAAO,eAAe,KAAK;AAExE,IAAM,gBAAgB,WAAW,SAASA,GAAE,KAAK,CAAC;AAGlD,IAAM,+BAA+B,cAAc,OAAO,eAAe,KAAK;AAY9E,SAAS,mBAA4C,UAA0B;AACpF,SAAO,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"]}
|
|
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 Schema\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'\nimport type { Schema } from './Schema.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 Schema\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","import type { Schema } from '../Schema.ts'\n\nexport const PayloadSetSchema = 'network.xyo.payload.set' as Schema\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.loose()\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 { zodAsFactory, zodIsFactory } from '@xylabs/zod'\nimport z from 'zod'\n\nexport const SchemaRegEx = /^(?:[a-z0-9]+\\.)*[a-z0-9]+$/\n\nexport const SchemaZod = z.string().regex(SchemaRegEx)\nexport type Schema = z.infer<typeof SchemaZod>\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 = zodIsFactory(SchemaZod)\nexport const asSchema = zodAsFactory(SchemaZod, 'asSchema')\nexport const toSchema = zodAsFactory(SchemaZod, 'toSchema')\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,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,UAAU,MAAM,KAAK,EAAE,WAAW,OAAQ,QAAO;AACrD,UAAM,EAAE,QAAQ,GAAG,GAAG,KAAK,IAAI;AAC/B,WAAO,UAAU,UAAU,IAAI,EAAE;AAAA,EACnC;AACF;;;ACvBA,SAAS,m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AAS,mBAAAE,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,cAAcC,GAAE,OAAO;AAAA,EAClC,OAAO;AAAA,EACP,WAAW;AACb,CAAC;AAEM,IAAM,kBAAkBA,GAAE,OAAO,EAAE,WAAW,sBAAsB,CAAC;AAErE,IAAM,iBAAiBA,GAAE,OAAO;AAAA,EACrC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,WAAW;AACb,CAAC;AAEM,IAAM,aAAaA,GAAE,OAAO,EAAE,QAAQ,UAAU,CAAC;AAGjD,IAAM,4BAA4B,WAAW,OAAO,eAAe,KAAK;AAExE,IAAM,gBAAgB,WAAW,MAAM;AAGvC,IAAM,+BAA+B,cAAc,OAAO,eAAe,KAAK;AAY9E,SAAS,mBAA4C,UAA0B;AACpF,SAAO,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.2.1",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -36,17 +36,18 @@
|
|
|
36
36
|
"!**/*.test.*"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xylabs/arraybuffer": "~5.0.
|
|
40
|
-
"@xylabs/assert": "~5.0.
|
|
41
|
-
"@xylabs/hex": "~5.0.
|
|
42
|
-
"@xylabs/object": "~5.0.
|
|
43
|
-
"@xylabs/typeof": "~5.0.
|
|
39
|
+
"@xylabs/arraybuffer": "~5.0.39",
|
|
40
|
+
"@xylabs/assert": "~5.0.39",
|
|
41
|
+
"@xylabs/hex": "~5.0.39",
|
|
42
|
+
"@xylabs/object": "~5.0.39",
|
|
43
|
+
"@xylabs/typeof": "~5.0.39",
|
|
44
|
+
"@xylabs/zod": "~5.0.39",
|
|
44
45
|
"zod": "~4.1.12"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
48
49
|
"@xylabs/tsconfig": "~7.2.8",
|
|
49
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
50
|
+
"@xylabs/vitest-extended": "~5.0.39",
|
|
50
51
|
"typescript": "~5.9.3",
|
|
51
52
|
"vitest": "~4.0.10"
|
|
52
53
|
},
|
package/src/Error.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { isPayloadOfSchemaType } from './isPayloadOfSchemaType.ts'
|
|
|
5
5
|
import type { Payload } from './Payload.ts'
|
|
6
6
|
import type { Schema } from './Schema.ts'
|
|
7
7
|
|
|
8
|
-
export const ModuleErrorSchema = 'network.xyo.error.module' as
|
|
8
|
+
export const ModuleErrorSchema = 'network.xyo.error.module' as Schema
|
|
9
9
|
export type ModuleErrorSchema = typeof ModuleErrorSchema
|
|
10
10
|
|
|
11
11
|
export type ModuleError = Payload<{
|
package/src/PayloadBundle.ts
CHANGED
|
@@ -3,9 +3,10 @@ import { AsObjectFactory } from '@xylabs/object'
|
|
|
3
3
|
|
|
4
4
|
import { isPayloadOfSchemaType } from './isPayloadOfSchemaType.ts'
|
|
5
5
|
import type { Payload } from './Payload.ts'
|
|
6
|
+
import type { Schema } from './Schema.ts'
|
|
6
7
|
|
|
7
8
|
// payload that wraps a complete boundwitness with its payloads for use in systems such as submission queues
|
|
8
|
-
export const PayloadBundleSchema = 'network.xyo.payload.bundle' as
|
|
9
|
+
export const PayloadBundleSchema = 'network.xyo.payload.bundle' as Schema
|
|
9
10
|
export type PayloadBundleSchema = typeof PayloadBundleSchema
|
|
10
11
|
|
|
11
12
|
export interface PayloadBundleFields<T extends Payload = Payload> {
|
package/src/PayloadZod.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const PayloadZod = z.object({ schema: SchemaZod })
|
|
|
22
22
|
/** @deprecated use WithStorageMetaZod */
|
|
23
23
|
export const PayloadWithStorageMetaZod = PayloadZod.extend(StorageMetaZod.shape)
|
|
24
24
|
|
|
25
|
-
export const AnyPayloadZod = PayloadZod.
|
|
25
|
+
export const AnyPayloadZod = PayloadZod.loose()
|
|
26
26
|
|
|
27
27
|
/** @deprecated use WithStorageMetaZod */
|
|
28
28
|
export const AnyPayloadWithStorageMetaZod = AnyPayloadZod.extend(StorageMetaZod.shape)
|
package/src/Schema.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import type { EmptyObject } from '@xylabs/object'
|
|
2
|
-
import {
|
|
2
|
+
import { zodAsFactory, zodIsFactory } from '@xylabs/zod'
|
|
3
3
|
import z from 'zod'
|
|
4
4
|
|
|
5
5
|
export const SchemaRegEx = /^(?:[a-z0-9]+\.)*[a-z0-9]+$/
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
export
|
|
9
|
-
export type SchemaV2 = z.output<typeof SchemaZodV2>
|
|
10
|
-
export type SchemaV1 = z.output<typeof SchemaZodV1>
|
|
11
|
-
export const SchemaZod = z.union([SchemaZodV1, SchemaZodV2])
|
|
12
|
-
export type Schema = z.infer<typeof SchemaZodV1>
|
|
7
|
+
export const SchemaZod = z.string().regex(SchemaRegEx)
|
|
8
|
+
export type Schema = z.infer<typeof SchemaZod>
|
|
13
9
|
|
|
14
10
|
export const makeSchema = <T extends string>(value: T) => {
|
|
15
11
|
return (z.templateLiteral([z.literal(value)])).transform(x => x as (typeof x & { __schema: true }))
|
|
@@ -19,11 +15,9 @@ export const PayloadSchema = 'network.xyo.payload' as const
|
|
|
19
15
|
export const PayloadSchemaZod = z.literal(PayloadSchema)
|
|
20
16
|
export type PayloadSchema = z.infer<typeof PayloadSchemaZod>
|
|
21
17
|
|
|
22
|
-
export const isSchema = (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export const asSchema = AsTypeFactory.create<Schema>(isSchema)
|
|
18
|
+
export const isSchema = zodIsFactory(SchemaZod)
|
|
19
|
+
export const asSchema = zodAsFactory(SchemaZod, 'asSchema')
|
|
20
|
+
export const toSchema = zodAsFactory(SchemaZod, 'toSchema')
|
|
27
21
|
|
|
28
22
|
/** Add the Schema Fields to an object */
|
|
29
23
|
export type WithSchema<T extends EmptyObject | void = void> = T extends EmptyObject ? SchemaFields & T : SchemaFields
|