@xyo-network/payload-model 3.0.2 → 3.0.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.
@@ -1,15 +1,15 @@
1
1
  import { Hash, Address } from '@xylabs/hex';
2
2
  import * as _xylabs_object from '@xylabs/object';
3
3
  import { EmptyObject, JsonObject, JsonValue } from '@xylabs/object';
4
- import * as _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package from '.store/@xylabs-promise-npm-4.0.0-20e48b6e2f/package';
4
+ import * as _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package from '.store/@xylabs-promise-npm-4.0.2-e41c5d98a1/package';
5
5
 
6
6
  type Schema = string;
7
7
  declare const PayloadSchema: "network.xyo.payload";
8
8
  type PayloadSchema = typeof PayloadSchema;
9
9
  declare const isSchema: (value: unknown) => value is Schema;
10
10
  declare const asSchema: {
11
- <TType extends string>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
12
- <TType extends string>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<string>, config?: _xylabs_object.TypeCheckConfig): TType;
11
+ <TType extends string>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
12
+ <TType extends string>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<string>, config?: _xylabs_object.TypeCheckConfig): TType;
13
13
  };
14
14
  interface SchemaFields extends EmptyObject {
15
15
  schema: Schema;
@@ -67,17 +67,17 @@ declare const isAnyPayload: (value: unknown) => value is Payload;
67
67
  declare const asAnyPayload: {
68
68
  <TType extends {
69
69
  schema: string;
70
- } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
70
+ } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
71
71
  <TType extends {
72
72
  schema: string;
73
- } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<{
73
+ } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<{
74
74
  schema: string;
75
75
  } & PayloadFields>, config?: _xylabs_object.TypeCheckConfig): TType;
76
76
  };
77
77
  declare const isPayload: <T extends Payload>(schema: string[]) => (value: unknown) => value is T;
78
78
  declare const asPayload: <T extends Payload>(schema: string[]) => {
79
- <TType extends T>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
80
- <TType extends T>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<T>, config?: _xylabs_object.TypeCheckConfig): TType;
79
+ <TType extends T>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
80
+ <TType extends T>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<T>, config?: _xylabs_object.TypeCheckConfig): TType;
81
81
  };
82
82
 
83
83
  type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = PayloadMetaFields<M> & T;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/isPayloadWithHash.ts","../../src/Meta.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["import { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport { 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 { WithMeta } from './Meta.ts'\nimport { 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 isPayloadOfSchemaTypeWithMeta = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is WithMeta<T> => isPayloadOfSchemaType<WithMeta<T>>(schema)(x) && x.$hash !== undefined\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 }\nconst testWithMeta: WithMeta<Test> = { $hash: '1234abcd', $meta: { timestamp: Date.now() }, field: 'test', schema: TestSchema }\n\nconst testPayloads: Payload[] = [testPayload]\nconst testMetaPayloads: WithMeta<Payload>[] = [testWithMeta]\n\nconst testType: Test = testWithMeta\n\nconst isTest: Test[] = testPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMeta: Payload[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMetaWithMeta: PayloadWithMeta[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestFromMetaTyped = testMetaPayloads.filter(isPayloadOfSchemaType<Test>(TestSchema))\n\nconst isTestFromMetaTypedWithMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestWithMeta: WithMeta<Test>[] = testPayloads.filter(isPayloadOfSchemaTypeWithMeta(TestSchema))\nconst isTestWithMetaFromMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaTypeWithMeta(TestSchema))\n*/\n","import { Hash } from '@xylabs/hex'\nimport { JsonValue } from '@xylabs/object'\n\nimport { isPayloadOfSchemaType } from './isPayloadOfSchemaType.ts'\nimport { 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","import { isAnyPayload } from './isPayload.ts'\nimport { WithMeta } from './Meta.ts'\nimport { Payload } from './Payload.ts'\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isWithHash = <T extends Payload>(value: T): value is WithMeta<T> => {\n return typeof (value as WithMeta<T>)?.$hash === 'string'\n}\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isPayloadWithHash = <T extends Payload>(value: unknown): value is WithMeta<T> => {\n return isAnyPayload(value) && isWithHash(value)\n}\n","import { EmptyObject, JsonObject } from '@xylabs/object'\n\nimport { Payload, PayloadMetaFields } from './Payload.ts'\nimport { Schema, WithSchema } from './Schema.ts'\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = PayloadMetaFields<M> & T\nexport type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> &\n Omit<WithMeta<T, M>, '$hash'>\n\nexport type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>\n\nexport const unMeta = <T extends WithMeta<Payload>>(payload?: T): T | undefined => {\n if (payload) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { $meta, $hash, ...result } = payload\n return result as T\n }\n}\n","export type PayloadSetSchema = 'network.xyo.payload.set'\nexport const PayloadSetSchema: PayloadSetSchema = 'network.xyo.payload.set'\n","import { AsTypeFactory, EmptyObject } 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;;;AClB1I,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,gCAAgC,CAAoB,WAAmB;AAClF,SAAO,CAAC,MAAyC,sBAAmC,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU;AAChH;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;;;ACZO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACT1E,IAAM,aAAa,CAAoB,UAAmC;AAC/E,SAAO,OAAQ,OAAuB,UAAU;AAClD;AAOO,IAAM,oBAAoB,CAAoB,UAAyC;AAC5F,SAAO,aAAa,KAAK,KAAK,WAAW,KAAK;AAChD;;;ACTO,IAAM,SAAS,CAA8B,YAA+B;AACjF,MAAI,SAAS;AAEX,UAAM,EAAE,OAAO,OAAO,GAAG,OAAO,IAAI;AACpC,WAAO;AAAA,EACT;AACF;;;AChBO,IAAM,mBAAqC;;;ACDlD,SAAS,qBAAkC;AAKpC,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/isPayloadWithHash.ts","../../src/Meta.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 { WithMeta } from './Meta.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 isPayloadOfSchemaTypeWithMeta = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is WithMeta<T> => isPayloadOfSchemaType<WithMeta<T>>(schema)(x) && x.$hash !== undefined\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 }\nconst testWithMeta: WithMeta<Test> = { $hash: '1234abcd', $meta: { timestamp: Date.now() }, field: 'test', schema: TestSchema }\n\nconst testPayloads: Payload[] = [testPayload]\nconst testMetaPayloads: WithMeta<Payload>[] = [testWithMeta]\n\nconst testType: Test = testWithMeta\n\nconst isTest: Test[] = testPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMeta: Payload[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMetaWithMeta: PayloadWithMeta[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestFromMetaTyped = testMetaPayloads.filter(isPayloadOfSchemaType<Test>(TestSchema))\n\nconst isTestFromMetaTypedWithMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestWithMeta: WithMeta<Test>[] = testPayloads.filter(isPayloadOfSchemaTypeWithMeta(TestSchema))\nconst isTestWithMetaFromMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaTypeWithMeta(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","import { isAnyPayload } from './isPayload.ts'\nimport type { WithMeta } from './Meta.ts'\nimport type { Payload } from './Payload.ts'\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isWithHash = <T extends Payload>(value: T): value is WithMeta<T> => {\n return typeof (value as WithMeta<T>)?.$hash === 'string'\n}\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isPayloadWithHash = <T extends Payload>(value: unknown): value is WithMeta<T> => {\n return isAnyPayload(value) && isWithHash(value)\n}\n","import type { EmptyObject, JsonObject } from '@xylabs/object'\n\nimport type { Payload, PayloadMetaFields } from './Payload.ts'\nimport type { Schema, WithSchema } from './Schema.ts'\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = PayloadMetaFields<M> & T\nexport type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> &\n Omit<WithMeta<T, M>, '$hash'>\n\nexport type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>\n\nexport const unMeta = <T extends WithMeta<Payload>>(payload?: T): T | undefined => {\n if (payload) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { $meta, $hash, ...result } = payload\n return result as T\n }\n}\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;;;AClB1I,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,gCAAgC,CAAoB,WAAmB;AAClF,SAAO,CAAC,MAAyC,sBAAmC,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU;AAChH;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;;;ACZO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACT1E,IAAM,aAAa,CAAoB,UAAmC;AAC/E,SAAO,OAAQ,OAAuB,UAAU;AAClD;AAOO,IAAM,oBAAoB,CAAoB,UAAyC;AAC5F,SAAO,aAAa,KAAK,KAAK,WAAW,KAAK;AAChD;;;ACTO,IAAM,SAAS,CAA8B,YAA+B;AACjF,MAAI,SAAS;AAEX,UAAM,EAAE,OAAO,OAAO,GAAG,OAAO,IAAI;AACpC,WAAO;AAAA,EACT;AACF;;;AChBO,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,15 +1,15 @@
1
1
  import { Hash, Address } from '@xylabs/hex';
2
2
  import * as _xylabs_object from '@xylabs/object';
3
3
  import { EmptyObject, JsonObject, JsonValue } from '@xylabs/object';
4
- import * as _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package from '.store/@xylabs-promise-npm-4.0.0-20e48b6e2f/package';
4
+ import * as _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package from '.store/@xylabs-promise-npm-4.0.2-e41c5d98a1/package';
5
5
 
6
6
  type Schema = string;
7
7
  declare const PayloadSchema: "network.xyo.payload";
8
8
  type PayloadSchema = typeof PayloadSchema;
9
9
  declare const isSchema: (value: unknown) => value is Schema;
10
10
  declare const asSchema: {
11
- <TType extends string>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
12
- <TType extends string>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<string>, config?: _xylabs_object.TypeCheckConfig): TType;
11
+ <TType extends string>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
12
+ <TType extends string>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<string>, config?: _xylabs_object.TypeCheckConfig): TType;
13
13
  };
14
14
  interface SchemaFields extends EmptyObject {
15
15
  schema: Schema;
@@ -67,17 +67,17 @@ declare const isAnyPayload: (value: unknown) => value is Payload;
67
67
  declare const asAnyPayload: {
68
68
  <TType extends {
69
69
  schema: string;
70
- } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
70
+ } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
71
71
  <TType extends {
72
72
  schema: string;
73
- } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<{
73
+ } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<{
74
74
  schema: string;
75
75
  } & PayloadFields>, config?: _xylabs_object.TypeCheckConfig): TType;
76
76
  };
77
77
  declare const isPayload: <T extends Payload>(schema: string[]) => (value: unknown) => value is T;
78
78
  declare const asPayload: <T extends Payload>(schema: string[]) => {
79
- <TType extends T>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
80
- <TType extends T>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<T>, config?: _xylabs_object.TypeCheckConfig): TType;
79
+ <TType extends T>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
80
+ <TType extends T>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<T>, config?: _xylabs_object.TypeCheckConfig): TType;
81
81
  };
82
82
 
83
83
  type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = PayloadMetaFields<M> & T;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/isPayloadWithHash.ts","../../src/Meta.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["import { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport { 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 { WithMeta } from './Meta.ts'\nimport { 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 isPayloadOfSchemaTypeWithMeta = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is WithMeta<T> => isPayloadOfSchemaType<WithMeta<T>>(schema)(x) && x.$hash !== undefined\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 }\nconst testWithMeta: WithMeta<Test> = { $hash: '1234abcd', $meta: { timestamp: Date.now() }, field: 'test', schema: TestSchema }\n\nconst testPayloads: Payload[] = [testPayload]\nconst testMetaPayloads: WithMeta<Payload>[] = [testWithMeta]\n\nconst testType: Test = testWithMeta\n\nconst isTest: Test[] = testPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMeta: Payload[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMetaWithMeta: PayloadWithMeta[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestFromMetaTyped = testMetaPayloads.filter(isPayloadOfSchemaType<Test>(TestSchema))\n\nconst isTestFromMetaTypedWithMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestWithMeta: WithMeta<Test>[] = testPayloads.filter(isPayloadOfSchemaTypeWithMeta(TestSchema))\nconst isTestWithMetaFromMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaTypeWithMeta(TestSchema))\n*/\n","import { Hash } from '@xylabs/hex'\nimport { JsonValue } from '@xylabs/object'\n\nimport { isPayloadOfSchemaType } from './isPayloadOfSchemaType.ts'\nimport { 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","import { isAnyPayload } from './isPayload.ts'\nimport { WithMeta } from './Meta.ts'\nimport { Payload } from './Payload.ts'\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isWithHash = <T extends Payload>(value: T): value is WithMeta<T> => {\n return typeof (value as WithMeta<T>)?.$hash === 'string'\n}\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isPayloadWithHash = <T extends Payload>(value: unknown): value is WithMeta<T> => {\n return isAnyPayload(value) && isWithHash(value)\n}\n","import { EmptyObject, JsonObject } from '@xylabs/object'\n\nimport { Payload, PayloadMetaFields } from './Payload.ts'\nimport { Schema, WithSchema } from './Schema.ts'\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = PayloadMetaFields<M> & T\nexport type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> &\n Omit<WithMeta<T, M>, '$hash'>\n\nexport type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>\n\nexport const unMeta = <T extends WithMeta<Payload>>(payload?: T): T | undefined => {\n if (payload) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { $meta, $hash, ...result } = payload\n return result as T\n }\n}\n","export type PayloadSetSchema = 'network.xyo.payload.set'\nexport const PayloadSetSchema: PayloadSetSchema = 'network.xyo.payload.set'\n","import { AsTypeFactory, EmptyObject } 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;;;AClB1I,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,gCAAgC,CAAoB,WAAmB;AAClF,SAAO,CAAC,MAAyC,sBAAmC,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU;AAChH;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;;;ACZO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACT1E,IAAM,aAAa,CAAoB,UAAmC;AAC/E,SAAO,OAAQ,OAAuB,UAAU;AAClD;AAOO,IAAM,oBAAoB,CAAoB,UAAyC;AAC5F,SAAO,aAAa,KAAK,KAAK,WAAW,KAAK;AAChD;;;ACTO,IAAM,SAAS,CAA8B,YAA+B;AACjF,MAAI,SAAS;AAEX,UAAM,EAAE,OAAO,OAAO,GAAG,OAAO,IAAI;AACpC,WAAO;AAAA,EACT;AACF;;;AChBO,IAAM,mBAAqC;;;ACDlD,SAAS,qBAAkC;AAKpC,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/isPayloadWithHash.ts","../../src/Meta.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 { WithMeta } from './Meta.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 isPayloadOfSchemaTypeWithMeta = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is WithMeta<T> => isPayloadOfSchemaType<WithMeta<T>>(schema)(x) && x.$hash !== undefined\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 }\nconst testWithMeta: WithMeta<Test> = { $hash: '1234abcd', $meta: { timestamp: Date.now() }, field: 'test', schema: TestSchema }\n\nconst testPayloads: Payload[] = [testPayload]\nconst testMetaPayloads: WithMeta<Payload>[] = [testWithMeta]\n\nconst testType: Test = testWithMeta\n\nconst isTest: Test[] = testPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMeta: Payload[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMetaWithMeta: PayloadWithMeta[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestFromMetaTyped = testMetaPayloads.filter(isPayloadOfSchemaType<Test>(TestSchema))\n\nconst isTestFromMetaTypedWithMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestWithMeta: WithMeta<Test>[] = testPayloads.filter(isPayloadOfSchemaTypeWithMeta(TestSchema))\nconst isTestWithMetaFromMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaTypeWithMeta(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","import { isAnyPayload } from './isPayload.ts'\nimport type { WithMeta } from './Meta.ts'\nimport type { Payload } from './Payload.ts'\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isWithHash = <T extends Payload>(value: T): value is WithMeta<T> => {\n return typeof (value as WithMeta<T>)?.$hash === 'string'\n}\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isPayloadWithHash = <T extends Payload>(value: unknown): value is WithMeta<T> => {\n return isAnyPayload(value) && isWithHash(value)\n}\n","import type { EmptyObject, JsonObject } from '@xylabs/object'\n\nimport type { Payload, PayloadMetaFields } from './Payload.ts'\nimport type { Schema, WithSchema } from './Schema.ts'\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = PayloadMetaFields<M> & T\nexport type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> &\n Omit<WithMeta<T, M>, '$hash'>\n\nexport type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>\n\nexport const unMeta = <T extends WithMeta<Payload>>(payload?: T): T | undefined => {\n if (payload) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { $meta, $hash, ...result } = payload\n return result as T\n }\n}\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;;;AClB1I,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,gCAAgC,CAAoB,WAAmB;AAClF,SAAO,CAAC,MAAyC,sBAAmC,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU;AAChH;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;;;ACZO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACT1E,IAAM,aAAa,CAAoB,UAAmC;AAC/E,SAAO,OAAQ,OAAuB,UAAU;AAClD;AAOO,IAAM,oBAAoB,CAAoB,UAAyC;AAC5F,SAAO,aAAa,KAAK,KAAK,WAAW,KAAK;AAChD;;;ACTO,IAAM,SAAS,CAA8B,YAA+B;AACjF,MAAI,SAAS;AAEX,UAAM,EAAE,OAAO,OAAO,GAAG,OAAO,IAAI;AACpC,WAAO;AAAA,EACT;AACF;;;AChBO,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,15 +1,15 @@
1
1
  import { Hash, Address } from '@xylabs/hex';
2
2
  import * as _xylabs_object from '@xylabs/object';
3
3
  import { EmptyObject, JsonObject, JsonValue } from '@xylabs/object';
4
- import * as _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package from '.store/@xylabs-promise-npm-4.0.0-20e48b6e2f/package';
4
+ import * as _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package from '.store/@xylabs-promise-npm-4.0.2-e41c5d98a1/package';
5
5
 
6
6
  type Schema = string;
7
7
  declare const PayloadSchema: "network.xyo.payload";
8
8
  type PayloadSchema = typeof PayloadSchema;
9
9
  declare const isSchema: (value: unknown) => value is Schema;
10
10
  declare const asSchema: {
11
- <TType extends string>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
12
- <TType extends string>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<string>, config?: _xylabs_object.TypeCheckConfig): TType;
11
+ <TType extends string>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
12
+ <TType extends string>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<string>, config?: _xylabs_object.TypeCheckConfig): TType;
13
13
  };
14
14
  interface SchemaFields extends EmptyObject {
15
15
  schema: Schema;
@@ -67,17 +67,17 @@ declare const isAnyPayload: (value: unknown) => value is Payload;
67
67
  declare const asAnyPayload: {
68
68
  <TType extends {
69
69
  schema: string;
70
- } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
70
+ } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
71
71
  <TType extends {
72
72
  schema: string;
73
- } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<{
73
+ } & PayloadFields>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<{
74
74
  schema: string;
75
75
  } & PayloadFields>, config?: _xylabs_object.TypeCheckConfig): TType;
76
76
  };
77
77
  declare const isPayload: <T extends Payload>(schema: string[]) => (value: unknown) => value is T;
78
78
  declare const asPayload: <T extends Payload>(schema: string[]) => {
79
- <TType extends T>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
80
- <TType extends T>(value: _store__xylabs_promise_npm_4_0_0_20e48b6e2f_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<T>, config?: _xylabs_object.TypeCheckConfig): TType;
79
+ <TType extends T>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, config?: _xylabs_object.TypeCheckConfig): TType | undefined;
80
+ <TType extends T>(value: _store__xylabs_promise_npm_4_0_2_e41c5d98a1_package.AnyNonPromise, assert: _xylabs_object.StringOrAlertFunction<T>, config?: _xylabs_object.TypeCheckConfig): TType;
81
81
  };
82
82
 
83
83
  type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = PayloadMetaFields<M> & T;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/isPayloadWithHash.ts","../../src/Meta.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["import { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport { 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 { WithMeta } from './Meta.ts'\nimport { 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 isPayloadOfSchemaTypeWithMeta = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is WithMeta<T> => isPayloadOfSchemaType<WithMeta<T>>(schema)(x) && x.$hash !== undefined\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 }\nconst testWithMeta: WithMeta<Test> = { $hash: '1234abcd', $meta: { timestamp: Date.now() }, field: 'test', schema: TestSchema }\n\nconst testPayloads: Payload[] = [testPayload]\nconst testMetaPayloads: WithMeta<Payload>[] = [testWithMeta]\n\nconst testType: Test = testWithMeta\n\nconst isTest: Test[] = testPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMeta: Payload[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMetaWithMeta: PayloadWithMeta[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestFromMetaTyped = testMetaPayloads.filter(isPayloadOfSchemaType<Test>(TestSchema))\n\nconst isTestFromMetaTypedWithMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestWithMeta: WithMeta<Test>[] = testPayloads.filter(isPayloadOfSchemaTypeWithMeta(TestSchema))\nconst isTestWithMetaFromMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaTypeWithMeta(TestSchema))\n*/\n","import { Hash } from '@xylabs/hex'\nimport { JsonValue } from '@xylabs/object'\n\nimport { isPayloadOfSchemaType } from './isPayloadOfSchemaType.ts'\nimport { 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","import { isAnyPayload } from './isPayload.ts'\nimport { WithMeta } from './Meta.ts'\nimport { Payload } from './Payload.ts'\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isWithHash = <T extends Payload>(value: T): value is WithMeta<T> => {\n return typeof (value as WithMeta<T>)?.$hash === 'string'\n}\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isPayloadWithHash = <T extends Payload>(value: unknown): value is WithMeta<T> => {\n return isAnyPayload(value) && isWithHash(value)\n}\n","import { EmptyObject, JsonObject } from '@xylabs/object'\n\nimport { Payload, PayloadMetaFields } from './Payload.ts'\nimport { Schema, WithSchema } from './Schema.ts'\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = PayloadMetaFields<M> & T\nexport type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> &\n Omit<WithMeta<T, M>, '$hash'>\n\nexport type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>\n\nexport const unMeta = <T extends WithMeta<Payload>>(payload?: T): T | undefined => {\n if (payload) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { $meta, $hash, ...result } = payload\n return result as T\n }\n}\n","export type PayloadSetSchema = 'network.xyo.payload.set'\nexport const PayloadSetSchema: PayloadSetSchema = 'network.xyo.payload.set'\n","import { AsTypeFactory, EmptyObject } 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;;;AClB1I,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,gCAAgC,CAAoB,WAAmB;AAClF,SAAO,CAAC,MAAyC,sBAAmC,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU;AAChH;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;;;ACZO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACT1E,IAAM,aAAa,CAAoB,UAAmC;AAC/E,SAAO,OAAQ,OAAuB,UAAU;AAClD;AAOO,IAAM,oBAAoB,CAAoB,UAAyC;AAC5F,SAAO,aAAa,KAAK,KAAK,WAAW,KAAK;AAChD;;;ACTO,IAAM,SAAS,CAA8B,YAA+B;AACjF,MAAI,SAAS;AAEX,UAAM,EAAE,OAAO,OAAO,GAAG,OAAO,IAAI;AACpC,WAAO;AAAA,EACT;AACF;;;AChBO,IAAM,mBAAqC;;;ACDlD,SAAS,qBAAkC;AAKpC,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/isPayloadWithHash.ts","../../src/Meta.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 { WithMeta } from './Meta.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 isPayloadOfSchemaTypeWithMeta = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is WithMeta<T> => isPayloadOfSchemaType<WithMeta<T>>(schema)(x) && x.$hash !== undefined\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 }\nconst testWithMeta: WithMeta<Test> = { $hash: '1234abcd', $meta: { timestamp: Date.now() }, field: 'test', schema: TestSchema }\n\nconst testPayloads: Payload[] = [testPayload]\nconst testMetaPayloads: WithMeta<Payload>[] = [testWithMeta]\n\nconst testType: Test = testWithMeta\n\nconst isTest: Test[] = testPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMeta: Payload[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\nconst isTestFromMetaWithMeta: PayloadWithMeta[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestFromMetaTyped = testMetaPayloads.filter(isPayloadOfSchemaType<Test>(TestSchema))\n\nconst isTestFromMetaTypedWithMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaType(TestSchema))\n\nconst isTestWithMeta: WithMeta<Test>[] = testPayloads.filter(isPayloadOfSchemaTypeWithMeta(TestSchema))\nconst isTestWithMetaFromMeta: WithMeta<Test>[] = testMetaPayloads.filter(isPayloadOfSchemaTypeWithMeta(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","import { isAnyPayload } from './isPayload.ts'\nimport type { WithMeta } from './Meta.ts'\nimport type { Payload } from './Payload.ts'\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isWithHash = <T extends Payload>(value: T): value is WithMeta<T> => {\n return typeof (value as WithMeta<T>)?.$hash === 'string'\n}\n\n/**\n * Return true if the value is a payload with the required meta fields\n * @param value The value to check\n * @returns True if the value is a payload with the required meta fields\n */\nexport const isPayloadWithHash = <T extends Payload>(value: unknown): value is WithMeta<T> => {\n return isAnyPayload(value) && isWithHash(value)\n}\n","import type { EmptyObject, JsonObject } from '@xylabs/object'\n\nimport type { Payload, PayloadMetaFields } from './Payload.ts'\nimport type { Schema, WithSchema } from './Schema.ts'\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = PayloadMetaFields<M> & T\nexport type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> &\n Omit<WithMeta<T, M>, '$hash'>\n\nexport type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>\n\nexport const unMeta = <T extends WithMeta<Payload>>(payload?: T): T | undefined => {\n if (payload) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { $meta, $hash, ...result } = payload\n return result as T\n }\n}\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;;;AClB1I,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,KAAK,GAAG,WAAW;AAC1E;AAEO,IAAM,gCAAgC,CAAoB,WAAmB;AAClF,SAAO,CAAC,MAAyC,sBAAmC,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU;AAChH;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;;;ACZO,IAAM,oBAAuC;AAW7C,IAAM,gBAAgB,sBAAmC,iBAAiB;;;ACT1E,IAAM,aAAa,CAAoB,UAAmC;AAC/E,SAAO,OAAQ,OAAuB,UAAU;AAClD;AAOO,IAAM,oBAAoB,CAAoB,UAAyC;AAC5F,SAAO,aAAa,KAAK,KAAK,WAAW,KAAK;AAChD;;;ACTO,IAAM,SAAS,CAA8B,YAA+B;AACjF,MAAI,SAAS;AAEX,UAAM,EAAE,OAAO,OAAO,GAAG,OAAO,IAAI;AACpC,WAAO;AAAA,EACT;AACF;;;AChBO,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":[]}
package/package.json CHANGED
@@ -7,15 +7,15 @@
7
7
  },
8
8
  "bugs": {
9
9
  "email": "support@xyo.network",
10
- "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
10
+ "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
11
11
  },
12
12
  "dependencies": {
13
- "@xylabs/hex": "^4.0.0",
14
- "@xylabs/object": "^4.0.0"
13
+ "@xylabs/hex": "^4.0.2",
14
+ "@xylabs/object": "^4.0.2"
15
15
  },
16
16
  "devDependencies": {
17
- "@xylabs/ts-scripts-yarn3": "^4.0.0-rc.15",
18
- "@xylabs/tsconfig": "^4.0.0-rc.15",
17
+ "@xylabs/ts-scripts-yarn3": "^4.0.0-rc.20",
18
+ "@xylabs/tsconfig": "^4.0.0-rc.20",
19
19
  "typescript": "^5.5.4"
20
20
  },
21
21
  "description": "Primary SDK for using XYO Protocol 2.0",
@@ -45,9 +45,9 @@
45
45
  },
46
46
  "repository": {
47
47
  "type": "git",
48
- "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
48
+ "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
49
49
  },
50
50
  "sideEffects": false,
51
- "version": "3.0.2",
51
+ "version": "3.0.3",
52
52
  "type": "module"
53
53
  }
package/src/Error.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Hash } from '@xylabs/hex'
2
- import { JsonValue } from '@xylabs/object'
1
+ import type { Hash } from '@xylabs/hex'
2
+ import type { JsonValue } from '@xylabs/object'
3
3
 
4
4
  import { isPayloadOfSchemaType } from './isPayloadOfSchemaType.ts'
5
- import { Payload } from './Payload.ts'
5
+ import type { Payload } from './Payload.ts'
6
6
 
7
7
  export type ModuleErrorSchema = 'network.xyo.error.module'
8
8
  export const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'
package/src/Meta.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { EmptyObject, JsonObject } from '@xylabs/object'
1
+ import type { EmptyObject, JsonObject } from '@xylabs/object'
2
2
 
3
- import { Payload, PayloadMetaFields } from './Payload.ts'
4
- import { Schema, WithSchema } from './Schema.ts'
3
+ import type { Payload, PayloadMetaFields } from './Payload.ts'
4
+ import type { Schema, WithSchema } from './Schema.ts'
5
5
 
6
6
  export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = PayloadMetaFields<M> & T
7
7
  export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> &
package/src/Payload.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Hash } from '@xylabs/hex'
2
- import { EmptyObject, JsonObject } from '@xylabs/object'
1
+ import type { Hash } from '@xylabs/hex'
2
+ import type { EmptyObject, JsonObject } from '@xylabs/object'
3
3
 
4
- import { Schema, WithSchema } from './Schema.ts'
4
+ import type { Schema, WithSchema } from './Schema.ts'
5
5
 
6
6
  /** Meta fields for a payload - Either both $hash and $meta should exist or neither */
7
7
  export interface PayloadMetaFields<TAdditionalMeta extends EmptyObject | void = void> extends EmptyObject {
@@ -1,4 +1,4 @@
1
- import { Hash } from '@xylabs/hex'
1
+ import type { Hash } from '@xylabs/hex'
2
2
 
3
3
  export interface PayloadFindFilter {
4
4
  limit?: number
@@ -1,5 +1,5 @@
1
- import { Payload } from '../Payload.ts'
2
- import { PayloadSetSchema } from './PayloadSetSchema.ts'
1
+ import type { Payload } from '../Payload.ts'
2
+ import type { PayloadSetSchema } from './PayloadSetSchema.ts'
3
3
 
4
4
  export interface PayloadSet {
5
5
  optional?: Record<string, number>
@@ -1,4 +1,4 @@
1
- import { Payload } from './Payload.ts'
1
+ import type { Payload } from './Payload.ts'
2
2
 
3
3
  /**
4
4
  * A function that validates the supplied payload
@@ -1,4 +1,4 @@
1
- import { Payload } from './Payload.ts'
1
+ import type { Payload } from './Payload.ts'
2
2
 
3
3
  /**
4
4
  * Type corresponding to the properties of a payload
package/src/Query.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Address } from '@xylabs/hex'
2
- import { EmptyObject } from '@xylabs/object'
1
+ import type { Address } from '@xylabs/hex'
2
+ import type { EmptyObject } from '@xylabs/object'
3
3
 
4
- import { Payload } from './Payload.ts'
5
- import { Schema, WithSchema } from './Schema.ts'
4
+ import type { Payload } from './Payload.ts'
5
+ import type { Schema, WithSchema } from './Schema.ts'
6
6
 
7
7
  export interface QueryFields {
8
8
  /** @field The addresses of the intended handlers */
package/src/Schema.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { AsTypeFactory, EmptyObject } from '@xylabs/object'
1
+ import type { EmptyObject } from '@xylabs/object'
2
+ import { AsTypeFactory } from '@xylabs/object'
2
3
 
3
4
  /** Schema type in Javascript is a string */
4
5
  export type Schema = string
package/src/Timestamp.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { EmptyObject } from '@xylabs/object'
1
+ import type { EmptyObject } from '@xylabs/object'
2
2
 
3
3
  /** Object with a timestamp */
4
4
  export interface Timestamp {
package/src/isPayload.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AsObjectFactory, isObject } from '@xylabs/object'
2
2
 
3
- import { Payload } from './Payload.ts'
3
+ import type { Payload } from './Payload.ts'
4
4
 
5
5
  export const isAnyPayload = (value: unknown): value is Payload => {
6
6
  if (isObject(value)) {
@@ -1,6 +1,6 @@
1
1
  import { isAnyPayload } from './isPayload.ts'
2
- import { WithMeta } from './Meta.ts'
3
- import { Payload, WithSources } from './Payload.ts'
2
+ import type { WithMeta } from './Meta.ts'
3
+ import type { Payload, WithSources } from './Payload.ts'
4
4
 
5
5
  export const isPayloadOfSchemaType = <T extends Payload>(schema: string) => {
6
6
  return (x?: unknown | null): x is T => isAnyPayload(x) && x?.schema === schema
@@ -1,6 +1,6 @@
1
1
  import { isAnyPayload } from './isPayload.ts'
2
- import { WithMeta } from './Meta.ts'
3
- import { Payload } from './Payload.ts'
2
+ import type { WithMeta } from './Meta.ts'
3
+ import type { Payload } from './Payload.ts'
4
4
 
5
5
  /**
6
6
  * Return true if the value is a payload with the required meta fields