@xyo-network/payload-model 3.6.0-rc.1 → 3.6.0-rc.3

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.
@@ -0,0 +1,29 @@
1
+ import { type Hash, type Hex } from '@xylabs/hex';
2
+ import type { Payload } from './Payload.ts';
3
+ export interface SequenceMeta {
4
+ _sequence: Hex;
5
+ }
6
+ export type WithPartialSequenceMeta<T extends Payload = Payload> = Partial<WithSequenceMeta<T>>;
7
+ export type WithSequenceMeta<T extends Payload = Payload> = T & SequenceMeta;
8
+ export interface HashMeta {
9
+ _dataHash: Hash;
10
+ _hash: Hash;
11
+ }
12
+ export type WithPartialHashMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>;
13
+ export type WithHashMeta<T extends Payload = Payload> = T & HashMeta;
14
+ export interface StorageMeta extends SequenceMeta, HashMeta {
15
+ }
16
+ export type WithPartialStorageMeta<T extends Payload = Payload> = Partial<WithStorageMeta<T>>;
17
+ export type WithStorageMeta<T extends Payload = Payload> = T & StorageMeta;
18
+ export declare const StorageMetaConstants: {
19
+ epochBytes: number;
20
+ nonceBytes: number;
21
+ addressBytes: number;
22
+ maxEpoch: number;
23
+ localSequenceBytes: number;
24
+ qualifiedSequenceBytes: number;
25
+ };
26
+ export declare const isSequenceMeta: (value: unknown) => value is SequenceMeta;
27
+ export declare const isHashMeta: (value: unknown) => value is HashMeta;
28
+ export declare const isStorageMeta: (value: unknown) => value is StorageMeta;
29
+ //# sourceMappingURL=StorageMeta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageMeta.d.ts","sourceRoot":"","sources":["../../src/StorageMeta.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAAE,KAAK,GAAG,EACpB,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,GAAG,CAAA;CACf;AAED,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAA;AAE/F,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,YAAY,CAAA;AAE5E,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,IAAI,CAAA;IACf,KAAK,EAAE,IAAI,CAAA;CACZ;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AAEvF,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,QAAQ,CAAA;AAEpE,MAAM,WAAW,WAAY,SAAQ,YAAY,EAAE,QAAQ;CAAG;AAE9D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;AAE7F,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,WAAW,CAAA;AAc1E,eAAO,MAAM,oBAAoB;;;;;;;CAGhC,CAAA;AAED,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,KAAK,IAAI,YAExD,CAAA;AAED,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,KAAK,IAAI,QAEpD,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,KAAK,IAAI,WAEvD,CAAA"}
@@ -8,4 +8,5 @@ export * from './PayloadValidationFunction.ts';
8
8
  export * from './PayloadValueExpression.ts';
9
9
  export * from './Query.ts';
10
10
  export * from './Schema.ts';
11
+ export * from './StorageMeta.ts';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA"}
@@ -40,19 +40,51 @@ var isSchema = (value) => {
40
40
  return typeof value === "string";
41
41
  };
42
42
  var asSchema = AsTypeFactory.create(isSchema);
43
+
44
+ // src/StorageMeta.ts
45
+ import {
46
+ isHash
47
+ } from "@xylabs/hex";
48
+ var StorageMetaComponentConstants = {
49
+ epochBytes: 8,
50
+ nonceBytes: 8,
51
+ addressBytes: 20
52
+ };
53
+ var StorageMetaLocalConstants = {
54
+ maxEpoch: Math.pow(256, StorageMetaComponentConstants.epochBytes) - 1,
55
+ localSequenceBytes: StorageMetaComponentConstants.epochBytes + StorageMetaComponentConstants.nonceBytes,
56
+ ...StorageMetaComponentConstants
57
+ };
58
+ var StorageMetaConstants = {
59
+ qualifiedSequenceBytes: StorageMetaLocalConstants.localSequenceBytes + StorageMetaComponentConstants.addressBytes,
60
+ ...StorageMetaLocalConstants
61
+ };
62
+ var isSequenceMeta = (value) => {
63
+ return value?._sequence !== void 0;
64
+ };
65
+ var isHashMeta = (value) => {
66
+ return isHash(value?._hash) && isHash(value?._dataHash);
67
+ };
68
+ var isStorageMeta = (value) => {
69
+ return isSequenceMeta(value) && isHashMeta(value);
70
+ };
43
71
  export {
44
72
  ModuleErrorSchema,
45
73
  PayloadSchema,
46
74
  PayloadSetSchema,
75
+ StorageMetaConstants,
47
76
  asAnyPayload,
48
77
  asPayload,
49
78
  asSchema,
50
79
  isAnyPayload,
80
+ isHashMeta,
51
81
  isModuleError,
52
82
  isPayload,
53
83
  isPayloadOfSchemaType,
54
84
  isPayloadOfSchemaTypeWithSources,
55
85
  isSchema,
86
+ isSequenceMeta,
87
+ isStorageMeta,
56
88
  notPayloadOfSchemaType
57
89
  };
58
90
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.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.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 const isPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => isAnyPayload(x) && x?.schema === schema\n}\n\nexport const isPayloadOfSchemaTypeWithSources = <T extends Payload>(schema: string) => {\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>(schema: string) => {\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(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'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n details?: JsonValue\n message?: string\n name?: string\n query?: Hash\n schema: ModuleErrorSchema\n sources?: Hash[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","export type PayloadSetSchema = 'network.xyo.payload.set'\nexport const PayloadSetSchema: PayloadSetSchema = 'network.xyo.payload.set'\n","import type { EmptyObject } from '@xylabs/object'\nimport { AsTypeFactory } from '@xylabs/object'\n\n/** Schema type in Javascript is a string */\nexport type Schema = string\n\nexport const PayloadSchema = 'network.xyo.payload' as const\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n return typeof value === 'string'\n}\n\nexport const asSchema = AsTypeFactory.create<Schema>(isSchema)\n\n/** Schema fields for a Payload */\nexport interface SchemaFields extends EmptyObject {\n /** Schema of the object */\n schema: Schema\n}\n\n/** Add the Schema Fields to an object */\nexport type WithSchema<T extends EmptyObject | void = void> = T extends EmptyObject ? SchemaFields & T : SchemaFields\n"],"mappings":";AAAA,SAAS,iBAAiB,gBAAgB;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,OAAO,MAAM,WAAW;AAAA,EACjC;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,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,mCAAmC,CAAoB,WAAmB;AACrF,SAAO,CAAC,MACN,sBAAsC,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,UAAa,MAAM,QAAQ,EAAE,OAAO;AAC1G;AAEO,IAAM,yBAAyB,CAAoB,WAAmB;AAC3E,SAAO,CAAC,MAA+B,CAAC,aAAa,CAAC,KAAK,GAAG,WAAW;AAC3E;;;ACPO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACjB1E,IAAM,mBAAqC;;;ACAlD,SAAS,qBAAqB;AAKvB,IAAM,gBAAgB;AAGtB,IAAM,WAAW,CAAC,UAAoC;AAC3D,SAAO,OAAO,UAAU;AAC1B;AAEO,IAAM,WAAW,cAAc,OAAe,QAAQ;","names":[]}
1
+ {"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts","../../src/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.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 const isPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => isAnyPayload(x) && x?.schema === schema\n}\n\nexport const isPayloadOfSchemaTypeWithSources = <T extends Payload>(schema: string) => {\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>(schema: string) => {\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(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'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n details?: JsonValue\n message?: string\n name?: string\n query?: Hash\n schema: ModuleErrorSchema\n sources?: Hash[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","export type PayloadSetSchema = 'network.xyo.payload.set'\nexport const PayloadSetSchema: PayloadSetSchema = 'network.xyo.payload.set'\n","import type { EmptyObject } from '@xylabs/object'\nimport { AsTypeFactory } from '@xylabs/object'\n\n/** Schema type in Javascript is a string */\nexport type Schema = string\n\nexport const PayloadSchema = 'network.xyo.payload' as const\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n return typeof value === 'string'\n}\n\nexport const asSchema = AsTypeFactory.create<Schema>(isSchema)\n\n/** Schema fields for a Payload */\nexport interface SchemaFields extends EmptyObject {\n /** Schema of the object */\n schema: Schema\n}\n\n/** Add the Schema Fields to an object */\nexport type WithSchema<T extends EmptyObject | void = void> = T extends EmptyObject ? SchemaFields & T : SchemaFields\n","import {\n type Hash, type Hex, isHash,\n} from '@xylabs/hex'\n\nimport type { Payload } from './Payload.ts'\n\nexport interface SequenceMeta {\n _sequence: Hex\n}\n\nexport type WithPartialSequenceMeta<T extends Payload = Payload> = Partial<WithSequenceMeta<T>>\n\nexport type WithSequenceMeta<T extends Payload = Payload> = T & SequenceMeta\n\nexport interface HashMeta {\n _dataHash: Hash\n _hash: Hash\n}\n\nexport type WithPartialHashMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>\n\nexport type WithHashMeta<T extends Payload = Payload> = T & HashMeta\n\nexport interface StorageMeta extends SequenceMeta, HashMeta {}\n\nexport type WithPartialStorageMeta<T extends Payload = Payload> = Partial<WithStorageMeta<T>>\n\nexport type WithStorageMeta<T extends Payload = Payload> = T & StorageMeta\n\nconst StorageMetaComponentConstants = {\n epochBytes: 8,\n nonceBytes: 8,\n addressBytes: 20,\n}\n\nconst StorageMetaLocalConstants = {\n maxEpoch: Math.pow(256, StorageMetaComponentConstants.epochBytes) - 1,\n localSequenceBytes: StorageMetaComponentConstants.epochBytes + StorageMetaComponentConstants.nonceBytes,\n ...StorageMetaComponentConstants,\n}\n\nexport const StorageMetaConstants = {\n qualifiedSequenceBytes: StorageMetaLocalConstants.localSequenceBytes + StorageMetaComponentConstants.addressBytes,\n ...StorageMetaLocalConstants,\n}\n\nexport const isSequenceMeta = (value: unknown): value is SequenceMeta => {\n return (value as WithSequenceMeta)?._sequence !== undefined\n}\n\nexport const isHashMeta = (value: unknown): value is HashMeta => {\n return isHash((value as WithHashMeta)?._hash) && isHash((value as WithHashMeta)?._dataHash)\n}\n\nexport const isStorageMeta = (value: unknown): value is StorageMeta => {\n return isSequenceMeta(value) && isHashMeta(value)\n}\n\n// \"00005a7f354762f3ac1bc5ddc6cfd08d14\" is and example of a local sequence string\n\n// \"00005a7f354762f3ac1bc5ddc6cfd08d14a123456789abcdef0123\" is and example of a local sequence string\n// epoch = \"00005a7f354762f3ac\"\n// nonce = \"1bc5ddc6cfd08d14\"\n// address = \"a123456789abcdef0123\"\n"],"mappings":";AAAA,SAAS,iBAAiB,gBAAgB;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,OAAO,MAAM,WAAW;AAAA,EACjC;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,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,mCAAmC,CAAoB,WAAmB;AACrF,SAAO,CAAC,MACN,sBAAsC,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,UAAa,MAAM,QAAQ,EAAE,OAAO;AAC1G;AAEO,IAAM,yBAAyB,CAAoB,WAAmB;AAC3E,SAAO,CAAC,MAA+B,CAAC,aAAa,CAAC,KAAK,GAAG,WAAW;AAC3E;;;ACPO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACjB1E,IAAM,mBAAqC;;;ACAlD,SAAS,qBAAqB;AAKvB,IAAM,gBAAgB;AAGtB,IAAM,WAAW,CAAC,UAAoC;AAC3D,SAAO,OAAO,UAAU;AAC1B;AAEO,IAAM,WAAW,cAAc,OAAe,QAAQ;;;ACb7D;AAAA,EACuB;AAAA,OAChB;AA2BP,IAAM,gCAAgC;AAAA,EACpC,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,cAAc;AAChB;AAEA,IAAM,4BAA4B;AAAA,EAChC,UAAU,KAAK,IAAI,KAAK,8BAA8B,UAAU,IAAI;AAAA,EACpE,oBAAoB,8BAA8B,aAAa,8BAA8B;AAAA,EAC7F,GAAG;AACL;AAEO,IAAM,uBAAuB;AAAA,EAClC,wBAAwB,0BAA0B,qBAAqB,8BAA8B;AAAA,EACrG,GAAG;AACL;AAEO,IAAM,iBAAiB,CAAC,UAA0C;AACvE,SAAQ,OAA4B,cAAc;AACpD;AAEO,IAAM,aAAa,CAAC,UAAsC;AAC/D,SAAO,OAAQ,OAAwB,KAAK,KAAK,OAAQ,OAAwB,SAAS;AAC5F;AAEO,IAAM,gBAAgB,CAAC,UAAyC;AACrE,SAAO,eAAe,KAAK,KAAK,WAAW,KAAK;AAClD;","names":[]}
@@ -0,0 +1,29 @@
1
+ import { type Hash, type Hex } from '@xylabs/hex';
2
+ import type { Payload } from './Payload.ts';
3
+ export interface SequenceMeta {
4
+ _sequence: Hex;
5
+ }
6
+ export type WithPartialSequenceMeta<T extends Payload = Payload> = Partial<WithSequenceMeta<T>>;
7
+ export type WithSequenceMeta<T extends Payload = Payload> = T & SequenceMeta;
8
+ export interface HashMeta {
9
+ _dataHash: Hash;
10
+ _hash: Hash;
11
+ }
12
+ export type WithPartialHashMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>;
13
+ export type WithHashMeta<T extends Payload = Payload> = T & HashMeta;
14
+ export interface StorageMeta extends SequenceMeta, HashMeta {
15
+ }
16
+ export type WithPartialStorageMeta<T extends Payload = Payload> = Partial<WithStorageMeta<T>>;
17
+ export type WithStorageMeta<T extends Payload = Payload> = T & StorageMeta;
18
+ export declare const StorageMetaConstants: {
19
+ epochBytes: number;
20
+ nonceBytes: number;
21
+ addressBytes: number;
22
+ maxEpoch: number;
23
+ localSequenceBytes: number;
24
+ qualifiedSequenceBytes: number;
25
+ };
26
+ export declare const isSequenceMeta: (value: unknown) => value is SequenceMeta;
27
+ export declare const isHashMeta: (value: unknown) => value is HashMeta;
28
+ export declare const isStorageMeta: (value: unknown) => value is StorageMeta;
29
+ //# sourceMappingURL=StorageMeta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageMeta.d.ts","sourceRoot":"","sources":["../../src/StorageMeta.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAAE,KAAK,GAAG,EACpB,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,GAAG,CAAA;CACf;AAED,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAA;AAE/F,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,YAAY,CAAA;AAE5E,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,IAAI,CAAA;IACf,KAAK,EAAE,IAAI,CAAA;CACZ;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AAEvF,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,QAAQ,CAAA;AAEpE,MAAM,WAAW,WAAY,SAAQ,YAAY,EAAE,QAAQ;CAAG;AAE9D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;AAE7F,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,WAAW,CAAA;AAc1E,eAAO,MAAM,oBAAoB;;;;;;;CAGhC,CAAA;AAED,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,KAAK,IAAI,YAExD,CAAA;AAED,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,KAAK,IAAI,QAEpD,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,KAAK,IAAI,WAEvD,CAAA"}
@@ -8,4 +8,5 @@ export * from './PayloadValidationFunction.ts';
8
8
  export * from './PayloadValueExpression.ts';
9
9
  export * from './Query.ts';
10
10
  export * from './Schema.ts';
11
+ export * from './StorageMeta.ts';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA"}
@@ -40,19 +40,51 @@ var isSchema = (value) => {
40
40
  return typeof value === "string";
41
41
  };
42
42
  var asSchema = AsTypeFactory.create(isSchema);
43
+
44
+ // src/StorageMeta.ts
45
+ import {
46
+ isHash
47
+ } from "@xylabs/hex";
48
+ var StorageMetaComponentConstants = {
49
+ epochBytes: 8,
50
+ nonceBytes: 8,
51
+ addressBytes: 20
52
+ };
53
+ var StorageMetaLocalConstants = {
54
+ maxEpoch: Math.pow(256, StorageMetaComponentConstants.epochBytes) - 1,
55
+ localSequenceBytes: StorageMetaComponentConstants.epochBytes + StorageMetaComponentConstants.nonceBytes,
56
+ ...StorageMetaComponentConstants
57
+ };
58
+ var StorageMetaConstants = {
59
+ qualifiedSequenceBytes: StorageMetaLocalConstants.localSequenceBytes + StorageMetaComponentConstants.addressBytes,
60
+ ...StorageMetaLocalConstants
61
+ };
62
+ var isSequenceMeta = (value) => {
63
+ return value?._sequence !== void 0;
64
+ };
65
+ var isHashMeta = (value) => {
66
+ return isHash(value?._hash) && isHash(value?._dataHash);
67
+ };
68
+ var isStorageMeta = (value) => {
69
+ return isSequenceMeta(value) && isHashMeta(value);
70
+ };
43
71
  export {
44
72
  ModuleErrorSchema,
45
73
  PayloadSchema,
46
74
  PayloadSetSchema,
75
+ StorageMetaConstants,
47
76
  asAnyPayload,
48
77
  asPayload,
49
78
  asSchema,
50
79
  isAnyPayload,
80
+ isHashMeta,
51
81
  isModuleError,
52
82
  isPayload,
53
83
  isPayloadOfSchemaType,
54
84
  isPayloadOfSchemaTypeWithSources,
55
85
  isSchema,
86
+ isSequenceMeta,
87
+ isStorageMeta,
56
88
  notPayloadOfSchemaType
57
89
  };
58
90
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.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.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 const isPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => isAnyPayload(x) && x?.schema === schema\n}\n\nexport const isPayloadOfSchemaTypeWithSources = <T extends Payload>(schema: string) => {\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>(schema: string) => {\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(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'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n details?: JsonValue\n message?: string\n name?: string\n query?: Hash\n schema: ModuleErrorSchema\n sources?: Hash[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","export type PayloadSetSchema = 'network.xyo.payload.set'\nexport const PayloadSetSchema: PayloadSetSchema = 'network.xyo.payload.set'\n","import type { EmptyObject } from '@xylabs/object'\nimport { AsTypeFactory } from '@xylabs/object'\n\n/** Schema type in Javascript is a string */\nexport type Schema = string\n\nexport const PayloadSchema = 'network.xyo.payload' as const\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n return typeof value === 'string'\n}\n\nexport const asSchema = AsTypeFactory.create<Schema>(isSchema)\n\n/** Schema fields for a Payload */\nexport interface SchemaFields extends EmptyObject {\n /** Schema of the object */\n schema: Schema\n}\n\n/** Add the Schema Fields to an object */\nexport type WithSchema<T extends EmptyObject | void = void> = T extends EmptyObject ? SchemaFields & T : SchemaFields\n"],"mappings":";AAAA,SAAS,iBAAiB,gBAAgB;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,OAAO,MAAM,WAAW;AAAA,EACjC;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,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,mCAAmC,CAAoB,WAAmB;AACrF,SAAO,CAAC,MACN,sBAAsC,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,UAAa,MAAM,QAAQ,EAAE,OAAO;AAC1G;AAEO,IAAM,yBAAyB,CAAoB,WAAmB;AAC3E,SAAO,CAAC,MAA+B,CAAC,aAAa,CAAC,KAAK,GAAG,WAAW;AAC3E;;;ACPO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACjB1E,IAAM,mBAAqC;;;ACAlD,SAAS,qBAAqB;AAKvB,IAAM,gBAAgB;AAGtB,IAAM,WAAW,CAAC,UAAoC;AAC3D,SAAO,OAAO,UAAU;AAC1B;AAEO,IAAM,WAAW,cAAc,OAAe,QAAQ;","names":[]}
1
+ {"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts","../../src/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.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 const isPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => isAnyPayload(x) && x?.schema === schema\n}\n\nexport const isPayloadOfSchemaTypeWithSources = <T extends Payload>(schema: string) => {\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>(schema: string) => {\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(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'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n details?: JsonValue\n message?: string\n name?: string\n query?: Hash\n schema: ModuleErrorSchema\n sources?: Hash[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","export type PayloadSetSchema = 'network.xyo.payload.set'\nexport const PayloadSetSchema: PayloadSetSchema = 'network.xyo.payload.set'\n","import type { EmptyObject } from '@xylabs/object'\nimport { AsTypeFactory } from '@xylabs/object'\n\n/** Schema type in Javascript is a string */\nexport type Schema = string\n\nexport const PayloadSchema = 'network.xyo.payload' as const\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n return typeof value === 'string'\n}\n\nexport const asSchema = AsTypeFactory.create<Schema>(isSchema)\n\n/** Schema fields for a Payload */\nexport interface SchemaFields extends EmptyObject {\n /** Schema of the object */\n schema: Schema\n}\n\n/** Add the Schema Fields to an object */\nexport type WithSchema<T extends EmptyObject | void = void> = T extends EmptyObject ? SchemaFields & T : SchemaFields\n","import {\n type Hash, type Hex, isHash,\n} from '@xylabs/hex'\n\nimport type { Payload } from './Payload.ts'\n\nexport interface SequenceMeta {\n _sequence: Hex\n}\n\nexport type WithPartialSequenceMeta<T extends Payload = Payload> = Partial<WithSequenceMeta<T>>\n\nexport type WithSequenceMeta<T extends Payload = Payload> = T & SequenceMeta\n\nexport interface HashMeta {\n _dataHash: Hash\n _hash: Hash\n}\n\nexport type WithPartialHashMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>\n\nexport type WithHashMeta<T extends Payload = Payload> = T & HashMeta\n\nexport interface StorageMeta extends SequenceMeta, HashMeta {}\n\nexport type WithPartialStorageMeta<T extends Payload = Payload> = Partial<WithStorageMeta<T>>\n\nexport type WithStorageMeta<T extends Payload = Payload> = T & StorageMeta\n\nconst StorageMetaComponentConstants = {\n epochBytes: 8,\n nonceBytes: 8,\n addressBytes: 20,\n}\n\nconst StorageMetaLocalConstants = {\n maxEpoch: Math.pow(256, StorageMetaComponentConstants.epochBytes) - 1,\n localSequenceBytes: StorageMetaComponentConstants.epochBytes + StorageMetaComponentConstants.nonceBytes,\n ...StorageMetaComponentConstants,\n}\n\nexport const StorageMetaConstants = {\n qualifiedSequenceBytes: StorageMetaLocalConstants.localSequenceBytes + StorageMetaComponentConstants.addressBytes,\n ...StorageMetaLocalConstants,\n}\n\nexport const isSequenceMeta = (value: unknown): value is SequenceMeta => {\n return (value as WithSequenceMeta)?._sequence !== undefined\n}\n\nexport const isHashMeta = (value: unknown): value is HashMeta => {\n return isHash((value as WithHashMeta)?._hash) && isHash((value as WithHashMeta)?._dataHash)\n}\n\nexport const isStorageMeta = (value: unknown): value is StorageMeta => {\n return isSequenceMeta(value) && isHashMeta(value)\n}\n\n// \"00005a7f354762f3ac1bc5ddc6cfd08d14\" is and example of a local sequence string\n\n// \"00005a7f354762f3ac1bc5ddc6cfd08d14a123456789abcdef0123\" is and example of a local sequence string\n// epoch = \"00005a7f354762f3ac\"\n// nonce = \"1bc5ddc6cfd08d14\"\n// address = \"a123456789abcdef0123\"\n"],"mappings":";AAAA,SAAS,iBAAiB,gBAAgB;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,OAAO,MAAM,WAAW;AAAA,EACjC;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,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,mCAAmC,CAAoB,WAAmB;AACrF,SAAO,CAAC,MACN,sBAAsC,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,UAAa,MAAM,QAAQ,EAAE,OAAO;AAC1G;AAEO,IAAM,yBAAyB,CAAoB,WAAmB;AAC3E,SAAO,CAAC,MAA+B,CAAC,aAAa,CAAC,KAAK,GAAG,WAAW;AAC3E;;;ACPO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACjB1E,IAAM,mBAAqC;;;ACAlD,SAAS,qBAAqB;AAKvB,IAAM,gBAAgB;AAGtB,IAAM,WAAW,CAAC,UAAoC;AAC3D,SAAO,OAAO,UAAU;AAC1B;AAEO,IAAM,WAAW,cAAc,OAAe,QAAQ;;;ACb7D;AAAA,EACuB;AAAA,OAChB;AA2BP,IAAM,gCAAgC;AAAA,EACpC,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,cAAc;AAChB;AAEA,IAAM,4BAA4B;AAAA,EAChC,UAAU,KAAK,IAAI,KAAK,8BAA8B,UAAU,IAAI;AAAA,EACpE,oBAAoB,8BAA8B,aAAa,8BAA8B;AAAA,EAC7F,GAAG;AACL;AAEO,IAAM,uBAAuB;AAAA,EAClC,wBAAwB,0BAA0B,qBAAqB,8BAA8B;AAAA,EACrG,GAAG;AACL;AAEO,IAAM,iBAAiB,CAAC,UAA0C;AACvE,SAAQ,OAA4B,cAAc;AACpD;AAEO,IAAM,aAAa,CAAC,UAAsC;AAC/D,SAAO,OAAQ,OAAwB,KAAK,KAAK,OAAQ,OAAwB,SAAS;AAC5F;AAEO,IAAM,gBAAgB,CAAC,UAAyC;AACrE,SAAO,eAAe,KAAK,KAAK,WAAW,KAAK;AAClD;","names":[]}
@@ -0,0 +1,29 @@
1
+ import { type Hash, type Hex } from '@xylabs/hex';
2
+ import type { Payload } from './Payload.ts';
3
+ export interface SequenceMeta {
4
+ _sequence: Hex;
5
+ }
6
+ export type WithPartialSequenceMeta<T extends Payload = Payload> = Partial<WithSequenceMeta<T>>;
7
+ export type WithSequenceMeta<T extends Payload = Payload> = T & SequenceMeta;
8
+ export interface HashMeta {
9
+ _dataHash: Hash;
10
+ _hash: Hash;
11
+ }
12
+ export type WithPartialHashMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>;
13
+ export type WithHashMeta<T extends Payload = Payload> = T & HashMeta;
14
+ export interface StorageMeta extends SequenceMeta, HashMeta {
15
+ }
16
+ export type WithPartialStorageMeta<T extends Payload = Payload> = Partial<WithStorageMeta<T>>;
17
+ export type WithStorageMeta<T extends Payload = Payload> = T & StorageMeta;
18
+ export declare const StorageMetaConstants: {
19
+ epochBytes: number;
20
+ nonceBytes: number;
21
+ addressBytes: number;
22
+ maxEpoch: number;
23
+ localSequenceBytes: number;
24
+ qualifiedSequenceBytes: number;
25
+ };
26
+ export declare const isSequenceMeta: (value: unknown) => value is SequenceMeta;
27
+ export declare const isHashMeta: (value: unknown) => value is HashMeta;
28
+ export declare const isStorageMeta: (value: unknown) => value is StorageMeta;
29
+ //# sourceMappingURL=StorageMeta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageMeta.d.ts","sourceRoot":"","sources":["../../src/StorageMeta.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAAE,KAAK,GAAG,EACpB,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,GAAG,CAAA;CACf;AAED,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAA;AAE/F,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,YAAY,CAAA;AAE5E,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,IAAI,CAAA;IACf,KAAK,EAAE,IAAI,CAAA;CACZ;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AAEvF,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,QAAQ,CAAA;AAEpE,MAAM,WAAW,WAAY,SAAQ,YAAY,EAAE,QAAQ;CAAG;AAE9D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;AAE7F,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,WAAW,CAAA;AAc1E,eAAO,MAAM,oBAAoB;;;;;;;CAGhC,CAAA;AAED,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,KAAK,IAAI,YAExD,CAAA;AAED,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,KAAK,IAAI,QAEpD,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,KAAK,IAAI,WAEvD,CAAA"}
@@ -8,4 +8,5 @@ export * from './PayloadValidationFunction.ts';
8
8
  export * from './PayloadValueExpression.ts';
9
9
  export * from './Query.ts';
10
10
  export * from './Schema.ts';
11
+ export * from './StorageMeta.ts';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA"}
@@ -40,19 +40,51 @@ var isSchema = (value) => {
40
40
  return typeof value === "string";
41
41
  };
42
42
  var asSchema = AsTypeFactory.create(isSchema);
43
+
44
+ // src/StorageMeta.ts
45
+ import {
46
+ isHash
47
+ } from "@xylabs/hex";
48
+ var StorageMetaComponentConstants = {
49
+ epochBytes: 8,
50
+ nonceBytes: 8,
51
+ addressBytes: 20
52
+ };
53
+ var StorageMetaLocalConstants = {
54
+ maxEpoch: Math.pow(256, StorageMetaComponentConstants.epochBytes) - 1,
55
+ localSequenceBytes: StorageMetaComponentConstants.epochBytes + StorageMetaComponentConstants.nonceBytes,
56
+ ...StorageMetaComponentConstants
57
+ };
58
+ var StorageMetaConstants = {
59
+ qualifiedSequenceBytes: StorageMetaLocalConstants.localSequenceBytes + StorageMetaComponentConstants.addressBytes,
60
+ ...StorageMetaLocalConstants
61
+ };
62
+ var isSequenceMeta = (value) => {
63
+ return value?._sequence !== void 0;
64
+ };
65
+ var isHashMeta = (value) => {
66
+ return isHash(value?._hash) && isHash(value?._dataHash);
67
+ };
68
+ var isStorageMeta = (value) => {
69
+ return isSequenceMeta(value) && isHashMeta(value);
70
+ };
43
71
  export {
44
72
  ModuleErrorSchema,
45
73
  PayloadSchema,
46
74
  PayloadSetSchema,
75
+ StorageMetaConstants,
47
76
  asAnyPayload,
48
77
  asPayload,
49
78
  asSchema,
50
79
  isAnyPayload,
80
+ isHashMeta,
51
81
  isModuleError,
52
82
  isPayload,
53
83
  isPayloadOfSchemaType,
54
84
  isPayloadOfSchemaTypeWithSources,
55
85
  isSchema,
86
+ isSequenceMeta,
87
+ isStorageMeta,
56
88
  notPayloadOfSchemaType
57
89
  };
58
90
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.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.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 const isPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => isAnyPayload(x) && x?.schema === schema\n}\n\nexport const isPayloadOfSchemaTypeWithSources = <T extends Payload>(schema: string) => {\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>(schema: string) => {\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(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'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n details?: JsonValue\n message?: string\n name?: string\n query?: Hash\n schema: ModuleErrorSchema\n sources?: Hash[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","export type PayloadSetSchema = 'network.xyo.payload.set'\nexport const PayloadSetSchema: PayloadSetSchema = 'network.xyo.payload.set'\n","import type { EmptyObject } from '@xylabs/object'\nimport { AsTypeFactory } from '@xylabs/object'\n\n/** Schema type in Javascript is a string */\nexport type Schema = string\n\nexport const PayloadSchema = 'network.xyo.payload' as const\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n return typeof value === 'string'\n}\n\nexport const asSchema = AsTypeFactory.create<Schema>(isSchema)\n\n/** Schema fields for a Payload */\nexport interface SchemaFields extends EmptyObject {\n /** Schema of the object */\n schema: Schema\n}\n\n/** Add the Schema Fields to an object */\nexport type WithSchema<T extends EmptyObject | void = void> = T extends EmptyObject ? SchemaFields & T : SchemaFields\n"],"mappings":";AAAA,SAAS,iBAAiB,gBAAgB;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,OAAO,MAAM,WAAW;AAAA,EACjC;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,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,mCAAmC,CAAoB,WAAmB;AACrF,SAAO,CAAC,MACN,sBAAsC,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,UAAa,MAAM,QAAQ,EAAE,OAAO;AAC1G;AAEO,IAAM,yBAAyB,CAAoB,WAAmB;AAC3E,SAAO,CAAC,MAA+B,CAAC,aAAa,CAAC,KAAK,GAAG,WAAW;AAC3E;;;ACPO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACjB1E,IAAM,mBAAqC;;;ACAlD,SAAS,qBAAqB;AAKvB,IAAM,gBAAgB;AAGtB,IAAM,WAAW,CAAC,UAAoC;AAC3D,SAAO,OAAO,UAAU;AAC1B;AAEO,IAAM,WAAW,cAAc,OAAe,QAAQ;","names":[]}
1
+ {"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts","../../src/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.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 const isPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => isAnyPayload(x) && x?.schema === schema\n}\n\nexport const isPayloadOfSchemaTypeWithSources = <T extends Payload>(schema: string) => {\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>(schema: string) => {\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(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'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n details?: JsonValue\n message?: string\n name?: string\n query?: Hash\n schema: ModuleErrorSchema\n sources?: Hash[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","export type PayloadSetSchema = 'network.xyo.payload.set'\nexport const PayloadSetSchema: PayloadSetSchema = 'network.xyo.payload.set'\n","import type { EmptyObject } from '@xylabs/object'\nimport { AsTypeFactory } from '@xylabs/object'\n\n/** Schema type in Javascript is a string */\nexport type Schema = string\n\nexport const PayloadSchema = 'network.xyo.payload' as const\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n return typeof value === 'string'\n}\n\nexport const asSchema = AsTypeFactory.create<Schema>(isSchema)\n\n/** Schema fields for a Payload */\nexport interface SchemaFields extends EmptyObject {\n /** Schema of the object */\n schema: Schema\n}\n\n/** Add the Schema Fields to an object */\nexport type WithSchema<T extends EmptyObject | void = void> = T extends EmptyObject ? SchemaFields & T : SchemaFields\n","import {\n type Hash, type Hex, isHash,\n} from '@xylabs/hex'\n\nimport type { Payload } from './Payload.ts'\n\nexport interface SequenceMeta {\n _sequence: Hex\n}\n\nexport type WithPartialSequenceMeta<T extends Payload = Payload> = Partial<WithSequenceMeta<T>>\n\nexport type WithSequenceMeta<T extends Payload = Payload> = T & SequenceMeta\n\nexport interface HashMeta {\n _dataHash: Hash\n _hash: Hash\n}\n\nexport type WithPartialHashMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>\n\nexport type WithHashMeta<T extends Payload = Payload> = T & HashMeta\n\nexport interface StorageMeta extends SequenceMeta, HashMeta {}\n\nexport type WithPartialStorageMeta<T extends Payload = Payload> = Partial<WithStorageMeta<T>>\n\nexport type WithStorageMeta<T extends Payload = Payload> = T & StorageMeta\n\nconst StorageMetaComponentConstants = {\n epochBytes: 8,\n nonceBytes: 8,\n addressBytes: 20,\n}\n\nconst StorageMetaLocalConstants = {\n maxEpoch: Math.pow(256, StorageMetaComponentConstants.epochBytes) - 1,\n localSequenceBytes: StorageMetaComponentConstants.epochBytes + StorageMetaComponentConstants.nonceBytes,\n ...StorageMetaComponentConstants,\n}\n\nexport const StorageMetaConstants = {\n qualifiedSequenceBytes: StorageMetaLocalConstants.localSequenceBytes + StorageMetaComponentConstants.addressBytes,\n ...StorageMetaLocalConstants,\n}\n\nexport const isSequenceMeta = (value: unknown): value is SequenceMeta => {\n return (value as WithSequenceMeta)?._sequence !== undefined\n}\n\nexport const isHashMeta = (value: unknown): value is HashMeta => {\n return isHash((value as WithHashMeta)?._hash) && isHash((value as WithHashMeta)?._dataHash)\n}\n\nexport const isStorageMeta = (value: unknown): value is StorageMeta => {\n return isSequenceMeta(value) && isHashMeta(value)\n}\n\n// \"00005a7f354762f3ac1bc5ddc6cfd08d14\" is and example of a local sequence string\n\n// \"00005a7f354762f3ac1bc5ddc6cfd08d14a123456789abcdef0123\" is and example of a local sequence string\n// epoch = \"00005a7f354762f3ac\"\n// nonce = \"1bc5ddc6cfd08d14\"\n// address = \"a123456789abcdef0123\"\n"],"mappings":";AAAA,SAAS,iBAAiB,gBAAgB;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,OAAO,MAAM,WAAW;AAAA,EACjC;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,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,mCAAmC,CAAoB,WAAmB;AACrF,SAAO,CAAC,MACN,sBAAsC,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,UAAa,MAAM,QAAQ,EAAE,OAAO;AAC1G;AAEO,IAAM,yBAAyB,CAAoB,WAAmB;AAC3E,SAAO,CAAC,MAA+B,CAAC,aAAa,CAAC,KAAK,GAAG,WAAW;AAC3E;;;ACPO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACjB1E,IAAM,mBAAqC;;;ACAlD,SAAS,qBAAqB;AAKvB,IAAM,gBAAgB;AAGtB,IAAM,WAAW,CAAC,UAAoC;AAC3D,SAAO,OAAO,UAAU;AAC1B;AAEO,IAAM,WAAW,cAAc,OAAe,QAAQ;;;ACb7D;AAAA,EACuB;AAAA,OAChB;AA2BP,IAAM,gCAAgC;AAAA,EACpC,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,cAAc;AAChB;AAEA,IAAM,4BAA4B;AAAA,EAChC,UAAU,KAAK,IAAI,KAAK,8BAA8B,UAAU,IAAI;AAAA,EACpE,oBAAoB,8BAA8B,aAAa,8BAA8B;AAAA,EAC7F,GAAG;AACL;AAEO,IAAM,uBAAuB;AAAA,EAClC,wBAAwB,0BAA0B,qBAAqB,8BAA8B;AAAA,EACrG,GAAG;AACL;AAEO,IAAM,iBAAiB,CAAC,UAA0C;AACvE,SAAQ,OAA4B,cAAc;AACpD;AAEO,IAAM,aAAa,CAAC,UAAsC;AAC/D,SAAO,OAAQ,OAAwB,KAAK,KAAK,OAAQ,OAAwB,SAAS;AAC5F;AAEO,IAAM,gBAAgB,CAAC,UAAyC;AACrE,SAAO,eAAe,KAAK,KAAK,WAAW,KAAK;AAClD;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/payload-model",
3
- "version": "3.6.0-rc.1",
3
+ "version": "3.6.0-rc.3",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -0,0 +1,64 @@
1
+ import {
2
+ type Hash, type Hex, isHash,
3
+ } from '@xylabs/hex'
4
+
5
+ import type { Payload } from './Payload.ts'
6
+
7
+ export interface SequenceMeta {
8
+ _sequence: Hex
9
+ }
10
+
11
+ export type WithPartialSequenceMeta<T extends Payload = Payload> = Partial<WithSequenceMeta<T>>
12
+
13
+ export type WithSequenceMeta<T extends Payload = Payload> = T & SequenceMeta
14
+
15
+ export interface HashMeta {
16
+ _dataHash: Hash
17
+ _hash: Hash
18
+ }
19
+
20
+ export type WithPartialHashMeta<T extends Payload = Payload> = Partial<WithHashMeta<T>>
21
+
22
+ export type WithHashMeta<T extends Payload = Payload> = T & HashMeta
23
+
24
+ export interface StorageMeta extends SequenceMeta, HashMeta {}
25
+
26
+ export type WithPartialStorageMeta<T extends Payload = Payload> = Partial<WithStorageMeta<T>>
27
+
28
+ export type WithStorageMeta<T extends Payload = Payload> = T & StorageMeta
29
+
30
+ const StorageMetaComponentConstants = {
31
+ epochBytes: 8,
32
+ nonceBytes: 8,
33
+ addressBytes: 20,
34
+ }
35
+
36
+ const StorageMetaLocalConstants = {
37
+ maxEpoch: Math.pow(256, StorageMetaComponentConstants.epochBytes) - 1,
38
+ localSequenceBytes: StorageMetaComponentConstants.epochBytes + StorageMetaComponentConstants.nonceBytes,
39
+ ...StorageMetaComponentConstants,
40
+ }
41
+
42
+ export const StorageMetaConstants = {
43
+ qualifiedSequenceBytes: StorageMetaLocalConstants.localSequenceBytes + StorageMetaComponentConstants.addressBytes,
44
+ ...StorageMetaLocalConstants,
45
+ }
46
+
47
+ export const isSequenceMeta = (value: unknown): value is SequenceMeta => {
48
+ return (value as WithSequenceMeta)?._sequence !== undefined
49
+ }
50
+
51
+ export const isHashMeta = (value: unknown): value is HashMeta => {
52
+ return isHash((value as WithHashMeta)?._hash) && isHash((value as WithHashMeta)?._dataHash)
53
+ }
54
+
55
+ export const isStorageMeta = (value: unknown): value is StorageMeta => {
56
+ return isSequenceMeta(value) && isHashMeta(value)
57
+ }
58
+
59
+ // "00005a7f354762f3ac1bc5ddc6cfd08d14" is and example of a local sequence string
60
+
61
+ // "00005a7f354762f3ac1bc5ddc6cfd08d14a123456789abcdef0123" is and example of a local sequence string
62
+ // epoch = "00005a7f354762f3ac"
63
+ // nonce = "1bc5ddc6cfd08d14"
64
+ // address = "a123456789abcdef0123"
package/src/index.ts CHANGED
@@ -8,3 +8,4 @@ export * from './PayloadValidationFunction.ts'
8
8
  export * from './PayloadValueExpression.ts'
9
9
  export * from './Query.ts'
10
10
  export * from './Schema.ts'
11
+ export * from './StorageMeta.ts'