@xyo-network/payload-model 2.90.7 → 2.90.8

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.
Files changed (76) hide show
  1. package/dist/browser/Meta.d.cts +10 -0
  2. package/dist/browser/Meta.d.cts.map +1 -0
  3. package/dist/browser/Meta.d.mts +10 -0
  4. package/dist/browser/Meta.d.mts.map +1 -0
  5. package/dist/browser/Meta.d.ts +10 -0
  6. package/dist/browser/Meta.d.ts.map +1 -0
  7. package/dist/browser/Payload.d.cts +4 -6
  8. package/dist/browser/Payload.d.cts.map +1 -1
  9. package/dist/browser/Payload.d.mts +4 -6
  10. package/dist/browser/Payload.d.mts.map +1 -1
  11. package/dist/browser/Payload.d.ts +4 -6
  12. package/dist/browser/Payload.d.ts.map +1 -1
  13. package/dist/browser/index.cjs +1 -1
  14. package/dist/browser/index.cjs.map +1 -1
  15. package/dist/browser/index.d.cts +1 -1
  16. package/dist/browser/index.d.cts.map +1 -1
  17. package/dist/browser/index.d.mts +1 -1
  18. package/dist/browser/index.d.mts.map +1 -1
  19. package/dist/browser/index.d.ts +1 -1
  20. package/dist/browser/index.d.ts.map +1 -1
  21. package/dist/browser/index.js +1 -1
  22. package/dist/browser/index.js.map +1 -1
  23. package/dist/browser/isPayloadOfSchemaType.d.cts +1 -1
  24. package/dist/browser/isPayloadOfSchemaType.d.cts.map +1 -1
  25. package/dist/browser/isPayloadOfSchemaType.d.mts +1 -1
  26. package/dist/browser/isPayloadOfSchemaType.d.mts.map +1 -1
  27. package/dist/browser/isPayloadOfSchemaType.d.ts +1 -1
  28. package/dist/browser/isPayloadOfSchemaType.d.ts.map +1 -1
  29. package/dist/browser/isPayloadWithHash.d.cts +1 -1
  30. package/dist/browser/isPayloadWithHash.d.cts.map +1 -1
  31. package/dist/browser/isPayloadWithHash.d.mts +1 -1
  32. package/dist/browser/isPayloadWithHash.d.mts.map +1 -1
  33. package/dist/browser/isPayloadWithHash.d.ts +1 -1
  34. package/dist/browser/isPayloadWithHash.d.ts.map +1 -1
  35. package/dist/node/Meta.d.cts +10 -0
  36. package/dist/node/Meta.d.cts.map +1 -0
  37. package/dist/node/Meta.d.mts +10 -0
  38. package/dist/node/Meta.d.mts.map +1 -0
  39. package/dist/node/Meta.d.ts +10 -0
  40. package/dist/node/Meta.d.ts.map +1 -0
  41. package/dist/node/Payload.d.cts +4 -6
  42. package/dist/node/Payload.d.cts.map +1 -1
  43. package/dist/node/Payload.d.mts +4 -6
  44. package/dist/node/Payload.d.mts.map +1 -1
  45. package/dist/node/Payload.d.ts +4 -6
  46. package/dist/node/Payload.d.ts.map +1 -1
  47. package/dist/node/index.cjs +1 -1
  48. package/dist/node/index.cjs.map +1 -1
  49. package/dist/node/index.d.cts +1 -1
  50. package/dist/node/index.d.cts.map +1 -1
  51. package/dist/node/index.d.mts +1 -1
  52. package/dist/node/index.d.mts.map +1 -1
  53. package/dist/node/index.d.ts +1 -1
  54. package/dist/node/index.d.ts.map +1 -1
  55. package/dist/node/index.js +1 -1
  56. package/dist/node/index.js.map +1 -1
  57. package/dist/node/isPayloadOfSchemaType.d.cts +1 -1
  58. package/dist/node/isPayloadOfSchemaType.d.cts.map +1 -1
  59. package/dist/node/isPayloadOfSchemaType.d.mts +1 -1
  60. package/dist/node/isPayloadOfSchemaType.d.mts.map +1 -1
  61. package/dist/node/isPayloadOfSchemaType.d.ts +1 -1
  62. package/dist/node/isPayloadOfSchemaType.d.ts.map +1 -1
  63. package/dist/node/isPayloadWithHash.d.cts +1 -1
  64. package/dist/node/isPayloadWithHash.d.cts.map +1 -1
  65. package/dist/node/isPayloadWithHash.d.mts +1 -1
  66. package/dist/node/isPayloadWithHash.d.mts.map +1 -1
  67. package/dist/node/isPayloadWithHash.d.ts +1 -1
  68. package/dist/node/isPayloadWithHash.d.ts.map +1 -1
  69. package/package.json +1 -1
  70. package/src/Meta.ts +18 -0
  71. package/src/Payload.ts +2 -13
  72. package/src/index.ts +1 -1
  73. package/src/isPayloadOfSchemaType.ts +3 -1
  74. package/src/isPayloadWithHash.ts +2 -1
  75. package/types.browser.d.cts +2 -2
  76. package/types.node.d.cts +2 -2
@@ -0,0 +1,10 @@
1
+ import { EmptyObject, JsonObject } from '@xylabs/object';
2
+ import { Payload, PayloadMetaFields } from './Payload';
3
+ import { Schema, WithSchema } from './Schema';
4
+ export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
5
+ export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
6
+ export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
7
+ export declare const unMeta: <T extends WithMeta<{
8
+ schema: string;
9
+ } & object, void>>(payload?: T | undefined) => T | undefined;
10
+ //# sourceMappingURL=Meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../../src/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE7C,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAChH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACrH,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AAE/B,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAEvI,eAAO,MAAM,MAAM;;4DAMlB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { EmptyObject, JsonObject } from '@xylabs/object';
2
+ import { Payload, PayloadMetaFields } from './Payload';
3
+ import { Schema, WithSchema } from './Schema';
4
+ export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
5
+ export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
6
+ export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
7
+ export declare const unMeta: <T extends WithMeta<{
8
+ schema: string;
9
+ } & object, void>>(payload?: T | undefined) => T | undefined;
10
+ //# sourceMappingURL=Meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../../src/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE7C,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAChH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACrH,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AAE/B,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAEvI,eAAO,MAAM,MAAM;;4DAMlB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { EmptyObject, JsonObject } from '@xylabs/object';
2
+ import { Payload, PayloadMetaFields } from './Payload';
3
+ import { Schema, WithSchema } from './Schema';
4
+ export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
5
+ export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
6
+ export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
7
+ export declare const unMeta: <T extends WithMeta<{
8
+ schema: string;
9
+ } & object, void>>(payload?: T | undefined) => T | undefined;
10
+ //# sourceMappingURL=Meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../../src/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE7C,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAChH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACrH,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AAE/B,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAEvI,eAAO,MAAM,MAAM;;4DAMlB,CAAA"}
@@ -24,10 +24,8 @@ export type Payload<T extends void | EmptyObject | WithSchema = void, S extends
24
24
  export type OverridablePayload<T extends Payload> = Omit<T, 'schema'> & {
25
25
  schema: string;
26
26
  };
27
- export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
28
- export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
29
- export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
30
- export declare const unMeta: <T extends WithMeta<{
31
- schema: string;
32
- } & object, void>>(payload?: T | undefined) => T | undefined;
27
+ export type WithSources<T extends EmptyObject> = T & {
28
+ sources?: string[];
29
+ };
30
+ export type PayloadWithSources<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithSources<Payload<T, S>>;
33
31
  //# sourceMappingURL=Payload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Payload.d.ts","sourceRoot":"","sources":["../../src/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W,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAC3E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA"}
@@ -24,10 +24,8 @@ export type Payload<T extends void | EmptyObject | WithSchema = void, S extends
24
24
  export type OverridablePayload<T extends Payload> = Omit<T, 'schema'> & {
25
25
  schema: string;
26
26
  };
27
- export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
28
- export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
29
- export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
30
- export declare const unMeta: <T extends WithMeta<{
31
- schema: string;
32
- } & object, void>>(payload?: T | undefined) => T | undefined;
27
+ export type WithSources<T extends EmptyObject> = T & {
28
+ sources?: string[];
29
+ };
30
+ export type PayloadWithSources<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithSources<Payload<T, S>>;
33
31
  //# sourceMappingURL=Payload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Payload.d.ts","sourceRoot":"","sources":["../../src/Payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE7C,sFAAsF;AACtF,MAAM,WAAW,iBAAiB,CAAC,eAAe,SAAS,UAAU,GAAG,IAAI,GA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AE,CAAC,CAAC,CAAC,CAAA"}
@@ -24,10 +24,8 @@ export type Payload<T extends void | EmptyObject | WithSchema = void, S extends
24
24
  export type OverridablePayload<T extends Payload> = Omit<T, 'schema'> & {
25
25
  schema: string;
26
26
  };
27
- export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
28
- export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
29
- export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
30
- export declare const unMeta: <T extends WithMeta<{
31
- schema: string;
32
- } & object, void>>(payload?: T | undefined) => T | undefined;
27
+ export type WithSources<T extends EmptyObject> = T & {
28
+ sources?: string[];
29
+ };
30
+ export type PayloadWithSources<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithSources<Payload<T, S>>;
33
31
  //# sourceMappingURL=Payload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Payload.d.ts","sourceRoot":"","sources":["../../src/Payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE7C,sFAAsF;AACtF,MAAM,WAAW,iBAAiB,CAAC,eAAe,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,CAAE,SAAQ,WAAW;IACtG,8EAA8E;IAC9E,KAAK,EAAE,IAAI,CAAA;IACX,wEAAwE;IACxE,KAAK,CAAC,EAAE,eAAe,SAAS,IAAI,GAAG,UAAU,GAAG,UAAU,GAAG,eAAe,CAAA;CACjF;AAED,sCAAsC;AACtC,MAAM,MAAM,aAAa,GAAG,WAAW,CAAA;AAEvC,MAAM,MAAM,WAAW,CAAC,CAAC,SA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AAC,SAAS,UAAU,GACxH,CAAC,SAAS,MAAM,GAEd,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,EAAE,CAAC,CAAA;CAAE,GAAG,aAAa,CAAC,GAE9D,WAAW,CAAC,CAAC,CAAC,GAChB,CAAC,SAAS,MAAM,GACd,CAAC,SAAS,MAAM,GAEd,WAAW,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,CAAC,CAAA;CAAE,GAAG,aAAa,CAAC,GAE9C,WAAW,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC,GAErD,AADA,8CAA8C,CAC9C;IACE,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,MAAM,CAAA;CACtC,GAAG,aAAa,CAAA;AAEvB,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,OAAO,IAAI,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1F,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAC3E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA"}
@@ -80,7 +80,7 @@ var isPayloadWithHash = /* @__PURE__ */ __name((value) => {
80
80
  return isAnyPayload(value) && isWithHash(value);
81
81
  }, "isPayloadWithHash");
82
82
 
83
- // src/Payload.ts
83
+ // src/Meta.ts
84
84
  var unMeta = /* @__PURE__ */ __name((payload) => {
85
85
  if (payload) {
86
86
  const { $meta, $hash, ...result } = payload;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/isPayloadWithHash.ts","../../src/Payload.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["export * from './Error'\nexport * from './isPayload'\nexport * from './isPayloadOfSchemaType'\nexport * from './isPayloadWithHash'\nexport * from './Payload'\nexport * from './PayloadFindFilter'\nexport * from './PayloadSet'\nexport * from './Query'\nexport * from './Schema'\nexport type * from './types'\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport { Payload } from './Payload'\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","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { isAnyPayload } from './isPayload'\nimport { Payload, PayloadWithMeta, WithMeta } from './Payload'\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 && x.$meta !== undefined\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 { isPayloadOfSchemaType } from './isPayloadOfSchemaType'\nimport { Payload } from './Payload'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n message?: string\n name?: string\n query?: string\n schema: ModuleErrorSchema\n sources?: string[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","import { isAnyPayload } from './isPayload'\nimport { Payload, WithMeta } from './Payload'\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 { Hash } from '@xylabs/hex'\nimport { EmptyObject, JsonObject } from '@xylabs/object'\n\nimport { Schema, WithSchema } from './Schema'\n\n/** Meta fields for a payload - Either both $hash and $meta should exist or neither */\nexport interface PayloadMetaFields<TAdditionalMeta extends JsonObject | void = void> extends EmptyObject {\n /** Hash of the body of the payload excluding the items in the $meta object */\n $hash: Hash\n /** Meta data that should be included in the main hash of the payload */\n $meta?: TAdditionalMeta extends void ? JsonObject : JsonObject & TAdditionalMeta\n}\n\n/** Additional fields for a payload */\nexport type PayloadFields = EmptyObject\n\nexport type WithPayload<T extends EmptyObject | void = void> = WithSchema<T extends EmptyObject ? PayloadFields & T : PayloadFields>\n\n/** Base Type for Payloads */\nexport type Payload<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = T extends WithSchema\n ? S extends Schema\n ? /* T (w/Schema) & S provided */\n WithPayload<Omit<T, 'schema'> & { schema: S } & PayloadFields>\n : /* Only T (w/Schema) provided */\n WithPayload<T>\n : T extends object\n ? S extends Schema\n ? /* T (w/o Schema) & S provided */\n WithPayload<T & { schema: S } & PayloadFields>\n : /* Only T (w/o Schema) provided */\n WithPayload<T & { schema: Schema } & PayloadFields>\n : /* Either just S or neither S or T provided */\n {\n schema: S extends Schema ? S : Schema\n } & PayloadFields\n\nexport type OverridablePayload<T extends Payload> = Omit<T, 'schema'> & { schema: string }\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>\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'\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n if (typeof value === 'string') {\n return true\n }\n return false\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;;;;;;;;;;;;;;;;;;;;;;ACCA,oBAA0C;AAInC,IAAMA,eAAe,wBAACC,UAAAA;AAC3B,UAAIC,wBAASD,KAAAA,GAAQ;AACnB,WAAO,OAAOA,MAAME,WAAW;EACjC;AACA,SAAO;AACT,GAL4B;AAOrB,IAAMC,eAAeC,8BAAgBC,OAAON,YAAAA;AAE5C,IAAMO,YACX,wBAAoBJ,WACpB,CAACF,UAAAA;AACC,MAAID,aAAaC,KAAAA,GAAQ;AACvB,WAAOE,OAAOK,SAASP,MAAME,MAAM;EACrC;AACA,SAAO;AACT,GANA;AAQK,IAAMM,YAAY,wBAAoBN,WAAqBE,8BAAgBC,OAAO,CAACL,UAA+BM,UAAUJ,MAAAA,EAAQF,KAAAA,CAAAA,GAAlH;;;ACnBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC1E,GAFqC;AAI9B,IAAMG,gCAAgC,wBAAoBH,WAAAA;AAC/D,SAAO,CAACC,MAAyCF,sBAAmCC,MAAAA,EAAQC,CAAAA,KAAMA,EAAEG,UAAUC,UAAaJ,EAAEK,UAAUD;AACzI,GAF6C;AAItC,IAAME,yBAAyB,wBAAoBP,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC3E,GAFsC;;;ACR/B,IAAMQ,oBAAuC;AAU7C,IAAMC,gBAAgBC,sBAAmCF,iBAAAA;;;ACNzD,IAAMG,aAAa,wBAAoBC,UAAAA;AAC5C,SAAO,OAAQA,OAAuBC,UAAU;AAClD,GAF0B;AASnB,IAAMC,oBAAoB,wBAAoBF,UAAAA;AACnD,SAAOG,aAAaH,KAAAA,KAAUD,WAAWC,KAAAA;AAC3C,GAFiC;;;AC2B1B,IAAMI,SAAS,wBAA8BC,YAAAA;AAClD,MAAIA,SAAS;AAEX,UAAM,EAAEC,OAAOC,OAAO,GAAGC,OAAAA,IAAWH;AACpC,WAAOG;EACT;AACF,GANsB;;;AC3Cf,IAAMC,mBAAqC;;;ACDlD,IAAAC,iBAA2C;AAKpC,IAAMC,gBAAgB;AAGtB,IAAMC,WAAW,wBAACC,UAAAA;AACvB,MAAI,OAAOA,UAAU,UAAU;AAC7B,WAAO;EACT;AACA,SAAO;AACT,GALwB;AAOjB,IAAMC,WAAWC,6BAAcC,OAAeJ,QAAAA;","names":["isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","isPayloadOfSchemaTypeWithMeta","$hash","undefined","$meta","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","unMeta","payload","$meta","$hash","result","PayloadSetSchema","import_object","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/isPayloadWithHash.ts","../../src/Meta.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["export * from './Error'\nexport * from './isPayload'\nexport * from './isPayloadOfSchemaType'\nexport * from './isPayloadWithHash'\nexport * from './Meta'\nexport * from './Payload'\nexport * from './PayloadFindFilter'\nexport * from './PayloadSet'\nexport * from './Query'\nexport * from './Schema'\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport { Payload } from './Payload'\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","/* eslint-disable @typescript-eslint/no-unused-vars */\n\nimport { isAnyPayload } from './isPayload'\nimport { WithMeta } from './Meta'\nimport { Payload } from './Payload'\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 && x.$meta !== undefined\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 { isPayloadOfSchemaType } from './isPayloadOfSchemaType'\nimport { Payload } from './Payload'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n message?: string\n name?: string\n query?: string\n schema: ModuleErrorSchema\n sources?: string[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","import { isAnyPayload } from './isPayload'\nimport { WithMeta } from './Meta'\nimport { Payload } from './Payload'\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'\nimport { Schema, WithSchema } from './Schema'\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>\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'\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n if (typeof value === 'string') {\n return true\n }\n return false\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;;;;;;;;;;;;;;;;;;;;;;ACCA,oBAA0C;AAInC,IAAMA,eAAe,wBAACC,UAAAA;AAC3B,UAAIC,wBAASD,KAAAA,GAAQ;AACnB,WAAO,OAAOA,MAAME,WAAW;EACjC;AACA,SAAO;AACT,GAL4B;AAOrB,IAAMC,eAAeC,8BAAgBC,OAA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AACT,GALwB;AAOjB,IAAMC,WAAWC,6BAAcC,OAAeJ,QAAAA;","names":["isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","isPayloadOfSchemaTypeWithMeta","$hash","undefined","$meta","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","unMeta","payload","$meta","$hash","result","PayloadSetSchema","import_object","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
@@ -2,10 +2,10 @@ export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
4
  export * from './isPayloadWithHash';
5
+ export * from './Meta';
5
6
  export * from './Payload';
6
7
  export * from './PayloadFindFilter';
7
8
  export * from './PayloadSet';
8
9
  export * from './Query';
9
10
  export * from './Schema';
10
- export type * from './types';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,mBAAmB,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -2,10 +2,10 @@ export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
4
  export * from './isPayloadWithHash';
5
+ export * from './Meta';
5
6
  export * from './Payload';
6
7
  export * from './PayloadFindFilter';
7
8
  export * from './PayloadSet';
8
9
  export * from './Query';
9
10
  export * from './Schema';
10
- export type * from './types';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,mBAAmB,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -2,10 +2,10 @@ export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
4
  export * from './isPayloadWithHash';
5
+ export * from './Meta';
5
6
  export * from './Payload';
6
7
  export * from './PayloadFindFilter';
7
8
  export * from './PayloadSet';
8
9
  export * from './Query';
9
10
  export * from './Schema';
10
- export type * from './types';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,mBAAmB,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -41,7 +41,7 @@ var isPayloadWithHash = /* @__PURE__ */ __name((value) => {
41
41
  return isAnyPayload(value) && isWithHash(value);
42
42
  }, "isPayloadWithHash");
43
43
 
44
- // src/Payload.ts
44
+ // src/Meta.ts
45
45
  var unMeta = /* @__PURE__ */ __name((payload) => {
46
46
  if (payload) {
47
47
  const { $meta, $hash, ...result } = payload;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/isPayloadWithHash.ts","../../src/Payload.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport { Payload } from './Payload'\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","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { isAnyPayload } from './isPayload'\nimport { Payload, PayloadWithMeta, WithMeta } from './Payload'\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 && x.$meta !== undefined\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 { isPayloadOfSchemaType } from './isPayloadOfSchemaType'\nimport { Payload } from './Payload'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n message?: string\n name?: string\n query?: string\n schema: ModuleErrorSchema\n sources?: string[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","import { isAnyPayload } from './isPayload'\nimport { Payload, WithMeta } from './Payload'\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 { Hash } from '@xylabs/hex'\nimport { EmptyObject, JsonObject } from '@xylabs/object'\n\nimport { Schema, WithSchema } from './Schema'\n\n/** Meta fields for a payload - Either both $hash and $meta should exist or neither */\nexport interface PayloadMetaFields<TAdditionalMeta extends JsonObject | void = void> extends EmptyObject {\n /** Hash of the body of the payload excluding the items in the $meta object */\n $hash: Hash\n /** Meta data that should be included in the main hash of the payload */\n $meta?: TAdditionalMeta extends void ? JsonObject : JsonObject & TAdditionalMeta\n}\n\n/** Additional fields for a payload */\nexport type PayloadFields = EmptyObject\n\nexport type WithPayload<T extends EmptyObject | void = void> = WithSchema<T extends EmptyObject ? PayloadFields & T : PayloadFields>\n\n/** Base Type for Payloads */\nexport type Payload<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = T extends WithSchema\n ? S extends Schema\n ? /* T (w/Schema) & S provided */\n WithPayload<Omit<T, 'schema'> & { schema: S } & PayloadFields>\n : /* Only T (w/Schema) provided */\n WithPayload<T>\n : T extends object\n ? S extends Schema\n ? /* T (w/o Schema) & S provided */\n WithPayload<T & { schema: S } & PayloadFields>\n : /* Only T (w/o Schema) provided */\n WithPayload<T & { schema: Schema } & PayloadFields>\n : /* Either just S or neither S or T provided */\n {\n schema: S extends Schema ? S : Schema\n } & PayloadFields\n\nexport type OverridablePayload<T extends Payload> = Omit<T, 'schema'> & { schema: string }\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>\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'\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n if (typeof value === 'string') {\n return true\n }\n return false\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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GAAGC,OAAAA,IAAWH;AACpC,WAAOG;EACT;AACF,GANsB;;;AC3Cf,IAAMC,mBAAqC;;;ACDlD,SAASC,qBAAkC;AAKpC,IAAMC,gBAAgB;AAGtB,IAAMC,WAAW,wBAACC,UAAAA;AACvB,MAAI,OAAOA,UAAU,UAAU;AAC7B,WAAO;EACT;AACA,SAAO;AACT,GALwB;AAOjB,IAAMC,WAAWC,cAAcC,OAAeJ,QAAAA;","names":["AsObjectFactory","isObject","isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","isPayloadOfSchemaTypeWithMeta","$hash","undefined","$meta","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","unMeta","payload","$meta","$hash","result","PayloadSetSchema","AsTypeFactory","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
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":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport { Payload } from './Payload'\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","/* eslint-disable @typescript-eslint/no-unused-vars */\n\nimport { isAnyPayload } from './isPayload'\nimport { WithMeta } from './Meta'\nimport { Payload } from './Payload'\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 && x.$meta !== undefined\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 { isPayloadOfSchemaType } from './isPayloadOfSchemaType'\nimport { Payload } from './Payload'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n message?: string\n name?: string\n query?: string\n schema: ModuleErrorSchema\n sources?: string[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","import { isAnyPayload } from './isPayload'\nimport { WithMeta } from './Meta'\nimport { Payload } from './Payload'\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'\nimport { Schema, WithSchema } from './Schema'\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>\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'\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n if (typeof value === 'string') {\n return true\n }\n return false\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":";;;;AACA,SAASA,iBAAiBC,gBAAgB;AAInC,IAAMC,eAAe,wBAACC,UAAAA;AAC3B,MAAIC,SAASD,KAAAA,GAAQ;AACnB,WAAO,OAAOA,MAAME,WAAW;EACjC;AACA,SAAO;AACT,GAL4B;AAOrB,IAAMC,eAAeC,gBAAgBC,OAAON,YAAAA;AAE5C,IAAMO,YACX,wBAAoBJ,WACpB,CAACF,UAAAA;AACC,MAAID,aAAaC,KAAAA,GAAQ;AACvB,WAAOE,OAAOK,SAASP,MAAME,MAAM;EACrC;AACA,SAAO;AACT,GANA;AAQK,IAAMM,YAAY,wBAAoBN,WAAqBE,gBAAgBC,OAAO,CAACL,UAA+BM,UAAUJ,MAAAA,EAAQF,KAAAA,CAAAA,GAAlH;;;ACjBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC1E,GAFqC;AAI9B,IAAMG,gCAAgC,wBAAoBH,WAAAA;AAC/D,SAAO,CAACC,MAAyCF,sBAAmCC,MAAAA,EAAQC,CAAAA,KAAMA,EAAEG,UAAUC,UAAaJ,EAAEK,UAAUD;AACzI,GAF6C;AAItC,IAAME,yBAAyB,wBAAoBP,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC3E,GAFsC;;;ACV/B,IAAMQ,oBAAuC;AAU7C,IAAMC,gBAAgBC,sBAAmCF,iBAAAA;;;ACLzD,IAAMG,aAAa,wBAAoBC,UAAAA;AAC5C,SAAO,OAAQA,OAAuBC,UAAU;AAClD,GAF0B;AASnB,IAAMC,oBAAoB,wBAAoBF,UAAAA;AACnD,SAAOG,aAAaH,KAAAA,KAAUD,WAAWC,KAAAA;AAC3C,GAFiC;;;ACP1B,IAAMI,SAAS,wBAA8BC,YAAAA;AAClD,MAAIA,SAAS;AAEX,UAAM,EAAEC,OAAOC,OAAO,GAAGC,OAAAA,IAAWH;AACpC,WAAOG;EACT;AACF,GANsB;;;ACVf,IAAMC,mBAAqC;;;ACDlD,SAASC,qBAAkC;AAKpC,IAAMC,gBAAgB;AAGtB,IAAMC,WAAW,wBAACC,UAAAA;AACvB,MAAI,OAAOA,UAAU,UAAU;AAC7B,WAAO;EACT;AACA,SAAO;AACT,GALwB;AAOjB,IAAMC,WAAWC,cAAcC,OAAeJ,QAAAA;","names":["AsObjectFactory","isObject","isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","isPayloadOfSchemaTypeWithMeta","$hash","undefined","$meta","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","unMeta","payload","$meta","$hash","result","PayloadSetSchema","AsTypeFactory","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  export declare const isPayloadOfSchemaType: <T extends {
3
3
  schema: string;
4
4
  } & object>(schema: string) => (x?: unknown | null) => x is T;
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
1
+ {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  export declare const isPayloadOfSchemaType: <T extends {
3
3
  schema: string;
4
4
  } & object>(schema: string) => (x?: unknown | null) => x is T;
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
1
+ {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  export declare const isPayloadOfSchemaType: <T extends {
3
3
  schema: string;
4
4
  } & object>(schema: string) => (x?: unknown | null) => x is T;
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
1
+ {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  /**
3
3
  * Return true if the value is a payload with the required meta fields
4
4
  * @param value The value to check
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE7C;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
1
+ {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  /**
3
3
  * Return true if the value is a payload with the required meta fields
4
4
  * @param value The value to check
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE7C;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
1
+ {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  /**
3
3
  * Return true if the value is a payload with the required meta fields
4
4
  * @param value The value to check
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE7C;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
1
+ {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { EmptyObject, JsonObject } from '@xylabs/object';
2
+ import { Payload, PayloadMetaFields } from './Payload';
3
+ import { Schema, WithSchema } from './Schema';
4
+ export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
5
+ export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
6
+ export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
7
+ export declare const unMeta: <T extends WithMeta<{
8
+ schema: string;
9
+ } & object, void>>(payload?: T | undefined) => T | undefined;
10
+ //# sourceMappingURL=Meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../../src/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE7C,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAChH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACrH,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AAE/B,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAEvI,eAAO,MAAM,MAAM;;4DAMlB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { EmptyObject, JsonObject } from '@xylabs/object';
2
+ import { Payload, PayloadMetaFields } from './Payload';
3
+ import { Schema, WithSchema } from './Schema';
4
+ export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
5
+ export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
6
+ export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
7
+ export declare const unMeta: <T extends WithMeta<{
8
+ schema: string;
9
+ } & object, void>>(payload?: T | undefined) => T | undefined;
10
+ //# sourceMappingURL=Meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../../src/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE7C,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAChH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACrH,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AAE/B,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAEvI,eAAO,MAAM,MAAM;;4DAMlB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { EmptyObject, JsonObject } from '@xylabs/object';
2
+ import { Payload, PayloadMetaFields } from './Payload';
3
+ import { Schema, WithSchema } from './Schema';
4
+ export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
5
+ export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
6
+ export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
7
+ export declare const unMeta: <T extends WithMeta<{
8
+ schema: string;
9
+ } & object, void>>(payload?: T | undefined) => T | undefined;
10
+ //# sourceMappingURL=Meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../../src/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE7C,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAChH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,CAAC,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACrH,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AAE/B,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAEvI,eAAO,MAAM,MAAM;;4DAMlB,CAAA"}
@@ -24,10 +24,8 @@ export type Payload<T extends void | EmptyObject | WithSchema = void, S extends
24
24
  export type OverridablePayload<T extends Payload> = Omit<T, 'schema'> & {
25
25
  schema: string;
26
26
  };
27
- export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
28
- export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
29
- export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
30
- export declare const unMeta: <T extends WithMeta<{
31
- schema: string;
32
- } & object, void>>(payload?: T | undefined) => T | undefined;
27
+ export type WithSources<T extends EmptyObject> = T & {
28
+ sources?: string[];
29
+ };
30
+ export type PayloadWithSources<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithSources<Payload<T, S>>;
33
31
  //# sourceMappingURL=Payload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Payload.d.ts","sourceRoot":"","sources":["../../src/Payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE7C,sFAAsF;AACtF,MAAM,WAAW,iBAAiB,CAAC,eAAe,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,CAAE,SAAQ,WAAW;IACtG,8EAA8E;IAC9E,KAAK,EAAE,IAAI,CAAA;IACX,wEAAwE;IACxE,KAAK,CAAC,EAAE,eAAe,SAAS,IAAI,GAAG,UAAU,GAAG,UAAU,GAAG,eAAe,CAAA;CACjF;AAED,sCAAsC;AACtC,MAAM,MAAM,aAAa,GAAG,WAAW,CAAA;AAEvC,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,GAAG,IAAI,GAAG,IAAI,IAAI,UAAU,CAAC,CAAC,SAAS,WAAW,GAAG,aAAa,GAAG,CAAC,GAAG,aAAa,CAAC,CAAA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AE,CAAC,CAAA;CAAE,GAAG,aAAa,CAAC,GAE9D,WAAW,CAAC,CAAC,CAAC,GAChB,CAAC,SAAS,MAAM,GACd,CAAC,SAAS,MAAM,GAEd,WAAW,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,CAAC,CAAA;CAAE,GAAG,aAAa,CAAC,GAE9C,WAAW,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC,GAErD,AADA,8CAA8C,CAC9C;IACE,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,MAAM,CAAA;CACtC,GAAG,aAAa,CAAA;AAEvB,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,OAAO,IAAI,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1F,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAC3E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA"}
@@ -24,10 +24,8 @@ export type Payload<T extends void | EmptyObject | WithSchema = void, S extends
24
24
  export type OverridablePayload<T extends Payload> = Omit<T, 'schema'> & {
25
25
  schema: string;
26
26
  };
27
- export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
28
- export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
29
- export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
30
- export declare const unMeta: <T extends WithMeta<{
31
- schema: string;
32
- } & object, void>>(payload?: T | undefined) => T | undefined;
27
+ export type WithSources<T extends EmptyObject> = T & {
28
+ sources?: string[];
29
+ };
30
+ export type PayloadWithSources<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithSources<Payload<T, S>>;
33
31
  //# sourceMappingURL=Payload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Payload.d.ts","sourceRoot":"","sources":["../../src/Payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE7C,sFAAsF;AACtF,MAAM,WAAW,iBAAiB,CAAC,eAAe,SAAS,UAAU,GAAG,IAAI,GAAG,IAAI,CAAE,SAAQ,WAAW;IACtG,8EAA8E;IAC9E,KAAK,EAAE,IAAI,CAAA;IACX,wEAAwE;IACxE,KAAK,CAAC,EAAE,eAAe,SAAS,IAAI,GAAG,UAAU,GAAG,UAAU,GAAG,eAAe,CAAA;CACjF;AAED,sCAAsC;AACtC,MAAM,MAAM,aAAa,GAAG,WAAW,CAAA;AAEvC,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,GAAG,IAAI,GAAG,IAAI,IAAI,UAAU,CAAC,CAAC,SAAS,WAAW,GAAG,aAAa,GAAG,CAAC,GAAG,aAAa,CAAC,CAAA;AAEpI,6BAA6B;AAC7B,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,UAAU,GACxH,CAAC,SAAS,MAAM,GAEd,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,E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G,aAAa,CAAC,GAErD,AADA,8CAA8C,CAC9C;IACE,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,MAAM,CAAA;CACtC,GAAG,aAAa,CAAA;AAEvB,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,OAAO,IAAI,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1F,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAC3E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA"}
@@ -24,10 +24,8 @@ export type Payload<T extends void | EmptyObject | WithSchema = void, S extends
24
24
  export type OverridablePayload<T extends Payload> = Omit<T, 'schema'> & {
25
25
  schema: string;
26
26
  };
27
- export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>;
28
- export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> & Omit<WithMeta<T, M>, '$hash'>;
29
- export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>;
30
- export declare const unMeta: <T extends WithMeta<{
31
- schema: string;
32
- } & object, void>>(payload?: T | undefined) => T | undefined;
27
+ export type WithSources<T extends EmptyObject> = T & {
28
+ sources?: string[];
29
+ };
30
+ export type PayloadWithSources<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithSources<Payload<T, S>>;
33
31
  //# sourceMappingURL=Payload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Payload.d.ts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AAE1F,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAC3E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA"}
@@ -80,7 +80,7 @@ var isPayloadWithHash = /* @__PURE__ */ __name((value) => {
80
80
  return isAnyPayload(value) && isWithHash(value);
81
81
  }, "isPayloadWithHash");
82
82
 
83
- // src/Payload.ts
83
+ // src/Meta.ts
84
84
  var unMeta = /* @__PURE__ */ __name((payload) => {
85
85
  if (payload) {
86
86
  const { $meta, $hash, ...result } = payload;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/isPayloadWithHash.ts","../../src/Payload.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["export * from './Error'\nexport * from './isPayload'\nexport * from './isPayloadOfSchemaType'\nexport * from './isPayloadWithHash'\nexport * from './Payload'\nexport * from './PayloadFindFilter'\nexport * from './PayloadSet'\nexport * from './Query'\nexport * from './Schema'\nexport type * from './types'\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport { Payload } from './Payload'\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","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { isAnyPayload } from './isPayload'\nimport { Payload, PayloadWithMeta, WithMeta } from './Payload'\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 && x.$meta !== undefined\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 { isPayloadOfSchemaType } from './isPayloadOfSchemaType'\nimport { Payload } from './Payload'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n message?: string\n name?: string\n query?: string\n schema: ModuleErrorSchema\n sources?: string[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","import { isAnyPayload } from './isPayload'\nimport { Payload, WithMeta } from './Payload'\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 { Hash } from '@xylabs/hex'\nimport { EmptyObject, JsonObject } from '@xylabs/object'\n\nimport { Schema, WithSchema } from './Schema'\n\n/** Meta fields for a payload - Either both $hash and $meta should exist or neither */\nexport interface PayloadMetaFields<TAdditionalMeta extends JsonObject | void = void> extends EmptyObject {\n /** Hash of the body of the payload excluding the items in the $meta object */\n $hash: Hash\n /** Meta data that should be included in the main hash of the payload */\n $meta?: TAdditionalMeta extends void ? JsonObject : JsonObject & TAdditionalMeta\n}\n\n/** Additional fields for a payload */\nexport type PayloadFields = EmptyObject\n\nexport type WithPayload<T extends EmptyObject | void = void> = WithSchema<T extends EmptyObject ? PayloadFields & T : PayloadFields>\n\n/** Base Type for Payloads */\nexport type Payload<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = T extends WithSchema\n ? S extends Schema\n ? /* T (w/Schema) & S provided */\n WithPayload<Omit<T, 'schema'> & { schema: S } & PayloadFields>\n : /* Only T (w/Schema) provided */\n WithPayload<T>\n : T extends object\n ? S extends Schema\n ? /* T (w/o Schema) & S provided */\n WithPayload<T & { schema: S } & PayloadFields>\n : /* Only T (w/o Schema) provided */\n WithPayload<T & { schema: Schema } & PayloadFields>\n : /* Either just S or neither S or T provided */\n {\n schema: S extends Schema ? S : Schema\n } & PayloadFields\n\nexport type OverridablePayload<T extends Payload> = Omit<T, 'schema'> & { schema: string }\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>\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'\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n if (typeof value === 'string') {\n return true\n }\n return false\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;;;;;;;;;;;;;;;;;;;;;;ACCA,oBAA0C;AAInC,IAAMA,eAAe,wBAACC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qC;;;ACDlD,IAAAC,iBAA2C;AAKpC,IAAMC,gBAAgB;AAGtB,IAAMC,WAAW,wBAACC,UAAAA;AACvB,MAAI,OAAOA,UAAU,UAAU;AAC7B,WAAO;EACT;AACA,SAAO;AACT,GALwB;AAOjB,IAAMC,WAAWC,6BAAcC,OAAeJ,QAAAA;","names":["isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","isPayloadOfSchemaTypeWithMeta","$hash","undefined","$meta","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","unMeta","payload","$meta","$hash","result","PayloadSetSchema","import_object","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/isPayloadWithHash.ts","../../src/Meta.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["export * from './Error'\nexport * from './isPayload'\nexport * from './isPayloadOfSchemaType'\nexport * from './isPayloadWithHash'\nexport * from './Meta'\nexport * from './Payload'\nexport * from './PayloadFindFilter'\nexport * from './PayloadSet'\nexport * from './Query'\nexport * from './Schema'\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport { Payload } from './Payload'\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","/* eslint-disable @typescript-eslint/no-unused-vars */\n\nimport { isAnyPayload } from './isPayload'\nimport { WithMeta } from './Meta'\nimport { Payload } from './Payload'\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 && x.$meta !== undefined\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 { isPayloadOfSchemaType } from './isPayloadOfSchemaType'\nimport { Payload } from './Payload'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n message?: string\n name?: string\n query?: string\n schema: ModuleErrorSchema\n sources?: string[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","import { isAnyPayload } from './isPayload'\nimport { WithMeta } from './Meta'\nimport { Payload } from './Payload'\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'\nimport { Schema, WithSchema } from './Schema'\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>\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'\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n if (typeof value === 'string') {\n return true\n }\n return false\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;;;;;;;;;;;;;;;;;;;;;;ACCA,oBAA0C;AAInC,IAAMA,eAAe,wBAACC,UAAAA;AAC3B,UAAIC,wBAASD,KAAAA,GAAQ;AACnB,WAAO,OAAOA,MAAME,WAAW;EACjC;AACA,SAAO;AACT,GAL4B;AAOrB,IAAMC,eAAeC,8BAAgBC,OAAON,YAAAA;AAE5C,IAAMO,YACX,wBAAoBJ,WACpB,CAACF,UAAAA;AACC,MAAID,aAAaC,KAAAA,GAAQ;AACvB,WAAOE,OAAOK,SAASP,MAAME,MAAM;EACrC;AACA,SAAO;AACT,GANA;AAQK,IAAMM,YAAY,wBAAoBN,WAAqBE,8BAAgBC,OAAO,CAACL,UAA+BM,UAAUJ,MAAAA,EAAQF,KAAAA,CAAAA,GAAlH;;;ACjBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC1E,GAFqC;AAI9B,IAAMG,gCAAgC,wBAAoBH,WAAAA;AAC/D,SAAO,CAACC,MAAyCF,sBAAmCC,MAAAA,EAAQC,CAAAA,KAAMA,EAAEG,UAAUC,UAAaJ,EAAEK,UAAUD;AACzI,GAF6C;AAItC,IAAME,yBAAyB,wBAAoBP,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC3E,GAFsC;;;ACV/B,IAAMQ,oBAAuC;AAU7C,IAAMC,gBAAgBC,sBAAmCF,iBAAAA;;;ACLzD,IAAMG,aAAa,wBAAoBC,UAAAA;AAC5C,SAAO,QAAQA,+BAAuBC,WAAU;AAClD,GAF0B;AASnB,IAAMC,oBAAoB,wBAAoBF,UAAAA;AACnD,SAAOG,aAAaH,KAAAA,KAAUD,WAAWC,KAAAA;AAC3C,GAFiC;;;ACP1B,IAAMI,SAAS,wBAA8BC,YAAAA;AAClD,MAAIA,SAAS;AAEX,UAAM,EAAEC,OAAOC,OAAO,GAAGC,OAAAA,IAAWH;AACpC,WAAOG;EACT;AACF,GANsB;;;ACVf,IAAMC,mBAAqC;;;ACDlD,IAAAC,iBAA2C;AAKpC,IAAMC,gBAAgB;AAGtB,IAAMC,WAAW,wBAACC,UAAAA;AACvB,MAAI,OAAOA,UAAU,UAAU;AAC7B,WAAO;EACT;AACA,SAAO;AACT,GALwB;AAOjB,IAAMC,WAAWC,6BAAcC,OAAeJ,QAAAA;","names":["isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","isPayloadOfSchemaTypeWithMeta","$hash","undefined","$meta","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","unMeta","payload","$meta","$hash","result","PayloadSetSchema","import_object","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
@@ -2,10 +2,10 @@ export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
4
  export * from './isPayloadWithHash';
5
+ export * from './Meta';
5
6
  export * from './Payload';
6
7
  export * from './PayloadFindFilter';
7
8
  export * from './PayloadSet';
8
9
  export * from './Query';
9
10
  export * from './Schema';
10
- export type * from './types';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,mBAAmB,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -2,10 +2,10 @@ export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
4
  export * from './isPayloadWithHash';
5
+ export * from './Meta';
5
6
  export * from './Payload';
6
7
  export * from './PayloadFindFilter';
7
8
  export * from './PayloadSet';
8
9
  export * from './Query';
9
10
  export * from './Schema';
10
- export type * from './types';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,mBAAmB,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -2,10 +2,10 @@ export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
4
  export * from './isPayloadWithHash';
5
+ export * from './Meta';
5
6
  export * from './Payload';
6
7
  export * from './PayloadFindFilter';
7
8
  export * from './PayloadSet';
8
9
  export * from './Query';
9
10
  export * from './Schema';
10
- export type * from './types';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,mBAAmB,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -41,7 +41,7 @@ var isPayloadWithHash = /* @__PURE__ */ __name((value) => {
41
41
  return isAnyPayload(value) && isWithHash(value);
42
42
  }, "isPayloadWithHash");
43
43
 
44
- // src/Payload.ts
44
+ // src/Meta.ts
45
45
  var unMeta = /* @__PURE__ */ __name((payload) => {
46
46
  if (payload) {
47
47
  const { $meta, $hash, ...result } = payload;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/Error.ts","../../src/isPayloadWithHash.ts","../../src/Payload.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport { Payload } from './Payload'\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","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { isAnyPayload } from './isPayload'\nimport { Payload, PayloadWithMeta, WithMeta } from './Payload'\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 && x.$meta !== undefined\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 { isPayloadOfSchemaType } from './isPayloadOfSchemaType'\nimport { Payload } from './Payload'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n message?: string\n name?: string\n query?: string\n schema: ModuleErrorSchema\n sources?: string[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","import { isAnyPayload } from './isPayload'\nimport { Payload, WithMeta } from './Payload'\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 { Hash } from '@xylabs/hex'\nimport { EmptyObject, JsonObject } from '@xylabs/object'\n\nimport { Schema, WithSchema } from './Schema'\n\n/** Meta fields for a payload - Either both $hash and $meta should exist or neither */\nexport interface PayloadMetaFields<TAdditionalMeta extends JsonObject | void = void> extends EmptyObject {\n /** Hash of the body of the payload excluding the items in the $meta object */\n $hash: Hash\n /** Meta data that should be included in the main hash of the payload */\n $meta?: TAdditionalMeta extends void ? JsonObject : JsonObject & TAdditionalMeta\n}\n\n/** Additional fields for a payload */\nexport type PayloadFields = EmptyObject\n\nexport type WithPayload<T extends EmptyObject | void = void> = WithSchema<T extends EmptyObject ? PayloadFields & T : PayloadFields>\n\n/** Base Type for Payloads */\nexport type Payload<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = T extends WithSchema\n ? S extends Schema\n ? /* T (w/Schema) & S provided */\n WithPayload<Omit<T, 'schema'> & { schema: S } & PayloadFields>\n : /* Only T (w/Schema) provided */\n WithPayload<T>\n : T extends object\n ? S extends Schema\n ? /* T (w/o Schema) & S provided */\n WithPayload<T & { schema: S } & PayloadFields>\n : /* Only T (w/o Schema) provided */\n WithPayload<T & { schema: Schema } & PayloadFields>\n : /* Either just S or neither S or T provided */\n {\n schema: S extends Schema ? S : Schema\n } & PayloadFields\n\nexport type OverridablePayload<T extends Payload> = Omit<T, 'schema'> & { schema: string }\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>\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'\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n if (typeof value === 'string') {\n return true\n }\n return false\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":";;;;AACA,SAASA,iBAAiBC,gBAAgB;AAInC,IAAMC,eAAe,wBAACC,UAAAA;AAC3B,MAAIC,SAASD,KAAAA,GAAQ;AACnB,WAAO,OAAOA,MAAME,WAAW;EACjC;AACA,SAAO;AACT,GAL4B;AAOrB,IAAMC,eAAeC,gBAAgBC,OAAON,YAAAA;AAE5C,IAAMO,YACX,wBAAoBJ,WACpB,CAACF,UAAAA;AACC,MAAID,aAAaC,KAAAA,GAAQ;AACvB,WAAOE,OAAOK,SAASP,MAAME,MAAM;EACrC;AACA,SAAO;AACT,GANA;AAQK,IAAMM,YAAY,wBAAoBN,WAAqBE,gBAAgBC,OAAO,CAACL,UAA+BM,UAAUJ,MAAAA,EAAQF,KAAAA,CAAAA,GAAlH;;;ACnBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC1E,GAFqC;AAI9B,IAAMG,gCAAgC,wBAAoBH,WAAAA;AAC/D,SAAO,CAACC,MAAyCF,sBAAmCC,MAAAA,EAAQC,CAAAA,KAAMA,EAAEG,UAAUC,UAAaJ,EAAEK,UAAUD;AACzI,GAF6C;AAItC,IAAME,yBAAyB,wBAAoBP,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC3E,GAFsC;;;ACR/B,IAAMQ,oBAAuC;AAU7C,IAAMC,gBAAgBC,sBAAmCF,iBAAAA;;;ACNzD,IAAMG,aAAa,wBAAoBC,UAAAA;AAC5C,SAAO,QAAQA,+BAAuBC,WAAU;AAClD,GAF0B;AASnB,IAAMC,oBAAoB,wBAAoBF,UAAAA;AACnD,SAAOG,aAAaH,KAAAA,KAAUD,WAAWC,KAAAA;AAC3C,GAFiC;;;AC2B1B,IAAMI,SAAS,wBAA8BC,YAAAA;AAClD,MAAIA,SAAS;AAEX,UAAM,EAAEC,OAAOC,OAAO,GAAGC,OAAAA,IAAWH;AACpC,WAAOG;EACT;AACF,GANsB;;;AC3Cf,IAAMC,mBAAqC;;;ACDlD,SAASC,qBAAkC;AAKpC,IAAMC,gBAAgB;AAGtB,IAAMC,WAAW,wBAACC,UAAAA;AACvB,MAAI,OAAOA,UAAU,UAAU;AAC7B,WAAO;EACT;AACA,SAAO;AACT,GALwB;AAOjB,IAAMC,WAAWC,cAAcC,OAAeJ,QAAAA;","names":["AsObjectFactory","isObject","isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","isPayloadOfSchemaTypeWithMeta","$hash","undefined","$meta","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","unMeta","payload","$meta","$hash","result","PayloadSetSchema","AsTypeFactory","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
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":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { AsObjectFactory, isObject } from '@xylabs/object'\n\nimport { Payload } from './Payload'\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","/* eslint-disable @typescript-eslint/no-unused-vars */\n\nimport { isAnyPayload } from './isPayload'\nimport { WithMeta } from './Meta'\nimport { Payload } from './Payload'\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 && x.$meta !== undefined\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 { isPayloadOfSchemaType } from './isPayloadOfSchemaType'\nimport { Payload } from './Payload'\n\nexport type ModuleErrorSchema = 'network.xyo.error.module'\nexport const ModuleErrorSchema: ModuleErrorSchema = 'network.xyo.error.module'\n\nexport type ModuleError = Payload<{\n message?: string\n name?: string\n query?: string\n schema: ModuleErrorSchema\n sources?: string[]\n}>\n\nexport const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)\n","import { isAnyPayload } from './isPayload'\nimport { WithMeta } from './Meta'\nimport { Payload } from './Payload'\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'\nimport { Schema, WithSchema } from './Schema'\n\nexport type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>\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'\nexport type PayloadSchema = typeof PayloadSchema\n\nexport const isSchema = (value: unknown): value is Schema => {\n if (typeof value === 'string') {\n return true\n }\n return false\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":";;;;AACA,SAASA,iBAAiBC,gBAAgB;AAInC,IAAMC,eAAe,wBAACC,UAAAA;AAC3B,MAAIC,SAASD,KAAAA,GAAQ;AACnB,WAAO,OAAOA,MAAME,WAAW;EACjC;AACA,SAAO;AACT,GAL4B;AAOrB,IAAMC,eAAeC,gBAAgBC,OAAON,YAAAA;AAE5C,IAAMO,YACX,wBAAoBJ,WACpB,CAACF,UAAAA;AACC,MAAID,aAAaC,KAAAA,GAAQ;AACvB,WAAOE,OAAOK,SAASP,MAAME,MAAM;EACrC;AACA,SAAO;AACT,GANA;AAQK,IAAMM,YAAY,wBAAoBN,WAAqBE,gBAAgBC,OAAO,CAACL,UAA+BM,UAAUJ,MAAAA,EAAQF,KAAAA,CAAAA,GAAlH;;;ACjBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC1E,GAFqC;AAI9B,IAAMG,gCAAgC,wBAAoBH,WAAAA;AAC/D,SAAO,CAACC,MAAyCF,sBAAmCC,MAAAA,EAAQC,CAAAA,KAAMA,EAAEG,UAAUC,UAAaJ,EAAEK,UAAUD;AACzI,GAF6C;AAItC,IAAME,yBAAyB,wBAAoBP,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC3E,GAFsC;;;ACV/B,IAAMQ,oBAAuC;AAU7C,IAAMC,gBAAgBC,sBAAmCF,iBAAAA;;;ACLzD,IAAMG,aAAa,wBAAoBC,UAAAA;AAC5C,SAAO,QAAQA,+BAAuBC,WAAU;AAClD,GAF0B;AASnB,IAAMC,oBAAoB,wBAAoBF,UAAAA;AACnD,SAAOG,aAAaH,KAAAA,KAAUD,WAAWC,KAAAA;AAC3C,GAFiC;;;ACP1B,IAAMI,SAAS,wBAA8BC,YAAAA;AAClD,MAAIA,SAAS;AAEX,UAAM,EAAEC,OAAOC,OAAO,GAAGC,OAAAA,IAAWH;AACpC,WAAOG;EACT;AACF,GANsB;;;ACVf,IAAMC,mBAAqC;;;ACDlD,SAASC,qBAAkC;AAKpC,IAAMC,gBAAgB;AAGtB,IAAMC,WAAW,wBAACC,UAAAA;AACvB,MAAI,OAAOA,UAAU,UAAU;AAC7B,WAAO;EACT;AACA,SAAO;AACT,GALwB;AAOjB,IAAMC,WAAWC,cAAcC,OAAeJ,QAAAA;","names":["AsObjectFactory","isObject","isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","isPayloadOfSchemaTypeWithMeta","$hash","undefined","$meta","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","unMeta","payload","$meta","$hash","result","PayloadSetSchema","AsTypeFactory","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  export declare const isPayloadOfSchemaType: <T extends {
3
3
  schema: string;
4
4
  } & object>(schema: string) => (x?: unknown | null) => x is T;
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
1
+ {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  export declare const isPayloadOfSchemaType: <T extends {
3
3
  schema: string;
4
4
  } & object>(schema: string) => (x?: unknown | null) => x is T;
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
1
+ {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  export declare const isPayloadOfSchemaType: <T extends {
3
3
  schema: string;
4
4
  } & object>(schema: string) => (x?: unknown | null) => x is T;
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE9D,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
1
+ {"version":3,"file":"isPayloadOfSchemaType.d.ts","sourceRoot":"","sources":["../../src/isPayloadOfSchemaType.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC,eAAO,MAAM,qBAAqB;;oBAA+B,MAAM,UACzD,OAAO,GAAG,IAAI,WAC3B,CAAA;AAED,eAAO,MAAM,6BAA6B;;oBAA+B,MAAM,UACjE,OAAO,GAAG,IAAI,qBAC3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;oBAA+B,MAAM,UAC1D,OAAO,GAAG,IAAI,WAC3B,CAAA"}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  /**
3
3
  * Return true if the value is a payload with the required meta fields
4
4
  * @param value The value to check
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE7C;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
1
+ {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  /**
3
3
  * Return true if the value is a payload with the required meta fields
4
4
  * @param value The value to check
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE7C;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
1
+ {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
@@ -1,4 +1,4 @@
1
- import { WithMeta } from './Payload';
1
+ import { WithMeta } from './Meta';
2
2
  /**
3
3
  * Return true if the value is a payload with the required meta fields
4
4
  * @param value The value to check
@@ -1 +1 @@
1
- {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE7C;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
1
+ {"version":3,"file":"isPayloadWithHash.d.ts","sourceRoot":"","sources":["../../src/isPayloadWithHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC;;;;GAIG;AACH,eAAO,MAAM,UAAU;;6CAEtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;mBAA8B,OAAO,yBAElE,CAAA"}
package/package.json CHANGED
@@ -57,6 +57,6 @@
57
57
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
58
58
  },
59
59
  "sideEffects": false,
60
- "version": "2.90.7",
60
+ "version": "2.90.8",
61
61
  "type": "module"
62
62
  }
package/src/Meta.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { EmptyObject, JsonObject } from '@xylabs/object'
2
+
3
+ import { Payload, PayloadMetaFields } from './Payload'
4
+ import { Schema, WithSchema } from './Schema'
5
+
6
+ export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>
7
+ export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> &
8
+ Omit<WithMeta<T, M>, '$hash'>
9
+
10
+ export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>
11
+
12
+ export const unMeta = <T extends WithMeta<Payload>>(payload?: T): T | undefined => {
13
+ if (payload) {
14
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
+ const { $meta, $hash, ...result } = payload
16
+ return result as T
17
+ }
18
+ }
package/src/Payload.ts CHANGED
@@ -36,16 +36,5 @@ export type Payload<T extends void | EmptyObject | WithSchema = void, S extends
36
36
 
37
37
  export type OverridablePayload<T extends Payload> = Omit<T, 'schema'> & { schema: string }
38
38
 
39
- export type WithMeta<T extends Payload = Payload, M extends JsonObject | void = void> = T & PayloadMetaFields<M>
40
- export type WithOptionalMeta<T extends Payload = Payload, M extends JsonObject | void = void> = Partial<WithMeta<T, M>> &
41
- Omit<WithMeta<T, M>, '$hash'>
42
-
43
- export type PayloadWithMeta<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithMeta<Payload<T, S>>
44
-
45
- export const unMeta = <T extends WithMeta<Payload>>(payload?: T): T | undefined => {
46
- if (payload) {
47
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
- const { $meta, $hash, ...result } = payload
49
- return result as T
50
- }
51
- }
39
+ export type WithSources<T extends EmptyObject> = T & { sources?: string[] }
40
+ export type PayloadWithSources<T extends void | EmptyObject | WithSchema = void, S extends Schema | void = void> = WithSources<Payload<T, S>>
package/src/index.ts CHANGED
@@ -2,9 +2,9 @@ export * from './Error'
2
2
  export * from './isPayload'
3
3
  export * from './isPayloadOfSchemaType'
4
4
  export * from './isPayloadWithHash'
5
+ export * from './Meta'
5
6
  export * from './Payload'
6
7
  export * from './PayloadFindFilter'
7
8
  export * from './PayloadSet'
8
9
  export * from './Query'
9
10
  export * from './Schema'
10
- export type * from './types'
@@ -1,6 +1,8 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
+
2
3
  import { isAnyPayload } from './isPayload'
3
- import { Payload, PayloadWithMeta, WithMeta } from './Payload'
4
+ import { WithMeta } from './Meta'
5
+ import { Payload } from './Payload'
4
6
 
5
7
  export const isPayloadOfSchemaType = <T extends Payload>(schema: string) => {
6
8
  return (x?: unknown | null): x is T => isAnyPayload(x) && x?.schema === schema
@@ -1,5 +1,6 @@
1
1
  import { isAnyPayload } from './isPayload'
2
- import { Payload, WithMeta } from './Payload'
2
+ import { WithMeta } from './Meta'
3
+ import { Payload } from './Payload'
3
4
 
4
5
  /**
5
6
  * Return true if the value is a payload with the required meta fields
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable import/no-internal-modules */
2
- export * from './dist/browser/index.js'
3
- export * from './src/types.js'
2
+ export * from './dist/browser/index.d.js'
3
+ export * from './src/types.d.js'
package/types.node.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable import/no-internal-modules */
2
- export * from './dist/node/index.js'
3
- export * from './src/types.js'
2
+ export * from './dist/node/index.d.js'
3
+ export * from './src/types.d.js'