@xyo-network/payload-model 2.89.0-rc.9 → 2.89.0

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 (48) hide show
  1. package/dist/browser/Error.d.cts +7 -0
  2. package/dist/browser/Error.d.cts.map +1 -1
  3. package/dist/browser/Error.d.mts +7 -0
  4. package/dist/browser/Error.d.mts.map +1 -1
  5. package/dist/browser/Error.d.ts +7 -0
  6. package/dist/browser/Error.d.ts.map +1 -1
  7. package/dist/browser/index.cjs +15 -3
  8. package/dist/browser/index.cjs.map +1 -1
  9. package/dist/browser/index.d.cts +1 -0
  10. package/dist/browser/index.d.cts.map +1 -1
  11. package/dist/browser/index.d.mts +1 -0
  12. package/dist/browser/index.d.mts.map +1 -1
  13. package/dist/browser/index.d.ts +1 -0
  14. package/dist/browser/index.d.ts.map +1 -1
  15. package/dist/browser/index.js +15 -3
  16. package/dist/browser/index.js.map +1 -1
  17. package/dist/browser/isPayloadWithHash.d.cts +18 -0
  18. package/dist/browser/isPayloadWithHash.d.cts.map +1 -0
  19. package/dist/browser/isPayloadWithHash.d.mts +18 -0
  20. package/dist/browser/isPayloadWithHash.d.mts.map +1 -0
  21. package/dist/browser/isPayloadWithHash.d.ts +18 -0
  22. package/dist/browser/isPayloadWithHash.d.ts.map +1 -0
  23. package/dist/node/Error.d.cts +7 -0
  24. package/dist/node/Error.d.cts.map +1 -1
  25. package/dist/node/Error.d.mts +7 -0
  26. package/dist/node/Error.d.mts.map +1 -1
  27. package/dist/node/Error.d.ts +7 -0
  28. package/dist/node/Error.d.ts.map +1 -1
  29. package/dist/node/index.cjs +18 -3
  30. package/dist/node/index.cjs.map +1 -1
  31. package/dist/node/index.d.cts +1 -0
  32. package/dist/node/index.d.cts.map +1 -1
  33. package/dist/node/index.d.mts +1 -0
  34. package/dist/node/index.d.mts.map +1 -1
  35. package/dist/node/index.d.ts +1 -0
  36. package/dist/node/index.d.ts.map +1 -1
  37. package/dist/node/index.js +15 -3
  38. package/dist/node/index.js.map +1 -1
  39. package/dist/node/isPayloadWithHash.d.cts +18 -0
  40. package/dist/node/isPayloadWithHash.d.cts.map +1 -0
  41. package/dist/node/isPayloadWithHash.d.mts +18 -0
  42. package/dist/node/isPayloadWithHash.d.mts.map +1 -0
  43. package/dist/node/isPayloadWithHash.d.ts +18 -0
  44. package/dist/node/isPayloadWithHash.d.ts.map +1 -0
  45. package/package.json +2 -3
  46. package/src/Error.ts +3 -0
  47. package/src/index.ts +1 -0
  48. package/src/isPayloadWithHash.ts +20 -0
@@ -8,4 +8,11 @@ export type ModuleError = Payload<{
8
8
  schema: ModuleErrorSchema;
9
9
  sources?: string[];
10
10
  }>;
11
+ export declare const isModuleError: (x?: unknown) => x is import("./Schema").SchemaFields & object & {
12
+ message?: string | undefined;
13
+ name?: string | undefined;
14
+ query?: string | undefined;
15
+ schema: ModuleErrorSchema;
16
+ sources?: string[] | undefined;
17
+ };
11
18
  //# sourceMappingURL=Error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA"}
1
+ {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA;AAEF,eAAO,MAAM,aAAa;;;;YAJhB,iBAAiB;;CAIuD,CAAA"}
@@ -8,4 +8,11 @@ export type ModuleError = Payload<{
8
8
  schema: ModuleErrorSchema;
9
9
  sources?: string[];
10
10
  }>;
11
+ export declare const isModuleError: (x?: unknown) => x is import("./Schema").SchemaFields & object & {
12
+ message?: string | undefined;
13
+ name?: string | undefined;
14
+ query?: string | undefined;
15
+ schema: ModuleErrorSchema;
16
+ sources?: string[] | undefined;
17
+ };
11
18
  //# sourceMappingURL=Error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA"}
1
+ {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA;AAEF,eAAO,MAAM,aAAa;;;;YAJhB,iBAAiB;;CAIuD,CAAA"}
@@ -8,4 +8,11 @@ export type ModuleError = Payload<{
8
8
  schema: ModuleErrorSchema;
9
9
  sources?: string[];
10
10
  }>;
11
+ export declare const isModuleError: (x?: unknown) => x is import("./Schema").SchemaFields & object & {
12
+ message?: string | undefined;
13
+ name?: string | undefined;
14
+ query?: string | undefined;
15
+ schema: ModuleErrorSchema;
16
+ sources?: string[] | undefined;
17
+ };
11
18
  //# sourceMappingURL=Error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA"}
1
+ {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA;AAEF,eAAO,MAAM,aAAa;;;;YAJhB,iBAAiB;;CAIuD,CAAA"}
@@ -28,16 +28,16 @@ __export(src_exports, {
28
28
  asPayload: () => asPayload,
29
29
  asSchema: () => asSchema,
30
30
  isAnyPayload: () => isAnyPayload,
31
+ isModuleError: () => isModuleError,
31
32
  isPayload: () => isPayload,
32
33
  isPayloadOfSchemaType: () => isPayloadOfSchemaType,
34
+ isPayloadWithHash: () => isPayloadWithHash,
33
35
  isSchema: () => isSchema,
36
+ isWithHash: () => isWithHash,
34
37
  notPayloadOfSchemaType: () => notPayloadOfSchemaType
35
38
  });
36
39
  module.exports = __toCommonJS(src_exports);
37
40
 
38
- // src/Error.ts
39
- var ModuleErrorSchema = "network.xyo.error.module";
40
-
41
41
  // src/isPayload.ts
42
42
  var import_object = require("@xylabs/object");
43
43
  var isAnyPayload = /* @__PURE__ */ __name((value) => {
@@ -63,6 +63,18 @@ var notPayloadOfSchemaType = /* @__PURE__ */ __name((schema) => {
63
63
  return (x) => !isAnyPayload(x) || x?.schema !== schema;
64
64
  }, "notPayloadOfSchemaType");
65
65
 
66
+ // src/Error.ts
67
+ var ModuleErrorSchema = "network.xyo.error.module";
68
+ var isModuleError = isPayloadOfSchemaType(ModuleErrorSchema);
69
+
70
+ // src/isPayloadWithHash.ts
71
+ var isWithHash = /* @__PURE__ */ __name((value) => {
72
+ return typeof value?.$hash === "string";
73
+ }, "isWithHash");
74
+ var isPayloadWithHash = /* @__PURE__ */ __name((value) => {
75
+ return isAnyPayload(value) && isWithHash(value);
76
+ }, "isPayloadWithHash");
77
+
66
78
  // src/PayloadSet/PayloadSetSchema.ts
67
79
  var PayloadSetSchema = "network.xyo.payload.set";
68
80
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/Error.ts","../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["export * from './Error'\nexport * from './isPayload'\nexport * from './isPayloadOfSchemaType'\nexport * from './Payload'\nexport * from './PayloadFindFilter'\nexport * from './PayloadSet'\nexport * from './Query'\nexport * from './Schema'\n","import { 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","/* 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","import { isAnyPayload } from './isPayload'\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 notPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => !isAnyPayload(x) || x?.schema !== schema\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;;;;;;;;;;;;;;;;;ACGO,IAAMA,oBAAuC;;;ACFpD,oBAA0C;AAInC,IAAMC,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;;;ACpBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC1E,GAFqC;AAI9B,IAAMG,yBAAyB,wBAAoBH,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC3E,GAFsC;;;ACN/B,IAAMI,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":["ModuleErrorSchema","isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","notPayloadOfSchemaType","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/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'\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","import { isAnyPayload } from './isPayload'\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 notPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => !isAnyPayload(x) || x?.schema !== schema\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","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;;;ACpBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC1E,GAFqC;AAI9B,IAAMG,yBAAyB,wBAAoBH,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC3E,GAFsC;;;ACH/B,IAAMI,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;;;AChB1B,IAAMI,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","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","PayloadSetSchema","import_object","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
@@ -1,6 +1,7 @@
1
1
  export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
+ export * from './isPayloadWithHash';
4
5
  export * from './Payload';
5
6
  export * from './PayloadFindFilter';
6
7
  export * from './PayloadSet';
@@ -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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
+ export * from './isPayloadWithHash';
4
5
  export * from './Payload';
5
6
  export * from './PayloadFindFilter';
6
7
  export * from './PayloadSet';
@@ -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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
+ export * from './isPayloadWithHash';
4
5
  export * from './Payload';
5
6
  export * from './PayloadFindFilter';
6
7
  export * from './PayloadSet';
@@ -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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
- // src/Error.ts
5
- var ModuleErrorSchema = "network.xyo.error.module";
6
-
7
4
  // src/isPayload.ts
8
5
  import { AsObjectFactory, isObject } from "@xylabs/object";
9
6
  var isAnyPayload = /* @__PURE__ */ __name((value) => {
@@ -29,6 +26,18 @@ var notPayloadOfSchemaType = /* @__PURE__ */ __name((schema) => {
29
26
  return (x) => !isAnyPayload(x) || x?.schema !== schema;
30
27
  }, "notPayloadOfSchemaType");
31
28
 
29
+ // src/Error.ts
30
+ var ModuleErrorSchema = "network.xyo.error.module";
31
+ var isModuleError = isPayloadOfSchemaType(ModuleErrorSchema);
32
+
33
+ // src/isPayloadWithHash.ts
34
+ var isWithHash = /* @__PURE__ */ __name((value) => {
35
+ return typeof value?.$hash === "string";
36
+ }, "isWithHash");
37
+ var isPayloadWithHash = /* @__PURE__ */ __name((value) => {
38
+ return isAnyPayload(value) && isWithHash(value);
39
+ }, "isPayloadWithHash");
40
+
32
41
  // src/PayloadSet/PayloadSetSchema.ts
33
42
  var PayloadSetSchema = "network.xyo.payload.set";
34
43
 
@@ -50,9 +59,12 @@ export {
50
59
  asPayload,
51
60
  asSchema,
52
61
  isAnyPayload,
62
+ isModuleError,
53
63
  isPayload,
54
64
  isPayloadOfSchemaType,
65
+ isPayloadWithHash,
55
66
  isSchema,
67
+ isWithHash,
56
68
  notPayloadOfSchemaType
57
69
  };
58
70
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Error.ts","../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["import { 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","/* 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","import { isAnyPayload } from './isPayload'\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 notPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => !isAnyPayload(x) || x?.schema !== schema\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":";;;;AAGO,IAAMA,oBAAuC;;;ACFpD,SAASC,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;;;ACpBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC1E,GAFqC;AAI9B,IAAMG,yBAAyB,wBAAoBH,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC3E,GAFsC;;;ACN/B,IAAMI,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":["ModuleErrorSchema","AsObjectFactory","isObject","isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","notPayloadOfSchemaType","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/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","import { isAnyPayload } from './isPayload'\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 notPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => !isAnyPayload(x) || x?.schema !== schema\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","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;;;ACpBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC1E,GAFqC;AAI9B,IAAMG,yBAAyB,wBAAoBH,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,KAAMA,GAAGD,WAAWA;AAC3E,GAFsC;;;ACH/B,IAAMI,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;;;AChB1B,IAAMI,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","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","PayloadSetSchema","AsTypeFactory","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
@@ -0,0 +1,18 @@
1
+ import { WithMeta } from './Payload';
2
+ /**
3
+ * Return true if the value is a payload with the required meta fields
4
+ * @param value The value to check
5
+ * @returns True if the value is a payload with the required meta fields
6
+ */
7
+ export declare const isWithHash: <T extends {
8
+ schema: string;
9
+ } & object>(value: T) => value is WithMeta<T>;
10
+ /**
11
+ * Return true if the value is a payload with the required meta fields
12
+ * @param value The value to check
13
+ * @returns True if the value is a payload with the required meta fields
14
+ */
15
+ export declare const isPayloadWithHash: <T extends {
16
+ schema: string;
17
+ } & object>(value: unknown) => value is WithMeta<T>;
18
+ //# sourceMappingURL=isPayloadWithHash.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,18 @@
1
+ import { WithMeta } from './Payload';
2
+ /**
3
+ * Return true if the value is a payload with the required meta fields
4
+ * @param value The value to check
5
+ * @returns True if the value is a payload with the required meta fields
6
+ */
7
+ export declare const isWithHash: <T extends {
8
+ schema: string;
9
+ } & object>(value: T) => value is WithMeta<T>;
10
+ /**
11
+ * Return true if the value is a payload with the required meta fields
12
+ * @param value The value to check
13
+ * @returns True if the value is a payload with the required meta fields
14
+ */
15
+ export declare const isPayloadWithHash: <T extends {
16
+ schema: string;
17
+ } & object>(value: unknown) => value is WithMeta<T>;
18
+ //# sourceMappingURL=isPayloadWithHash.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,18 @@
1
+ import { WithMeta } from './Payload';
2
+ /**
3
+ * Return true if the value is a payload with the required meta fields
4
+ * @param value The value to check
5
+ * @returns True if the value is a payload with the required meta fields
6
+ */
7
+ export declare const isWithHash: <T extends {
8
+ schema: string;
9
+ } & object>(value: T) => value is WithMeta<T>;
10
+ /**
11
+ * Return true if the value is a payload with the required meta fields
12
+ * @param value The value to check
13
+ * @returns True if the value is a payload with the required meta fields
14
+ */
15
+ export declare const isPayloadWithHash: <T extends {
16
+ schema: string;
17
+ } & object>(value: unknown) => value is WithMeta<T>;
18
+ //# sourceMappingURL=isPayloadWithHash.d.ts.map
@@ -0,0 +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"}
@@ -8,4 +8,11 @@ export type ModuleError = Payload<{
8
8
  schema: ModuleErrorSchema;
9
9
  sources?: string[];
10
10
  }>;
11
+ export declare const isModuleError: (x?: unknown) => x is import("./Schema").SchemaFields & object & {
12
+ message?: string | undefined;
13
+ name?: string | undefined;
14
+ query?: string | undefined;
15
+ schema: ModuleErrorSchema;
16
+ sources?: string[] | undefined;
17
+ };
11
18
  //# sourceMappingURL=Error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA"}
1
+ {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA;AAEF,eAAO,MAAM,aAAa;;;;YAJhB,iBAAiB;;CAIuD,CAAA"}
@@ -8,4 +8,11 @@ export type ModuleError = Payload<{
8
8
  schema: ModuleErrorSchema;
9
9
  sources?: string[];
10
10
  }>;
11
+ export declare const isModuleError: (x?: unknown) => x is import("./Schema").SchemaFields & object & {
12
+ message?: string | undefined;
13
+ name?: string | undefined;
14
+ query?: string | undefined;
15
+ schema: ModuleErrorSchema;
16
+ sources?: string[] | undefined;
17
+ };
11
18
  //# sourceMappingURL=Error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA"}
1
+ {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA;AAEF,eAAO,MAAM,aAAa;;;;YAJhB,iBAAiB;;CAIuD,CAAA"}
@@ -8,4 +8,11 @@ export type ModuleError = Payload<{
8
8
  schema: ModuleErrorSchema;
9
9
  sources?: string[];
10
10
  }>;
11
+ export declare const isModuleError: (x?: unknown) => x is import("./Schema").SchemaFields & object & {
12
+ message?: string | undefined;
13
+ name?: string | undefined;
14
+ query?: string | undefined;
15
+ schema: ModuleErrorSchema;
16
+ sources?: string[] | undefined;
17
+ };
11
18
  //# sourceMappingURL=Error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA"}
1
+ {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,EAAE,iBAA8C,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAC,CAAA;AAEF,eAAO,MAAM,aAAa;;;;YAJhB,iBAAiB;;CAIuD,CAAA"}
@@ -28,16 +28,16 @@ __export(src_exports, {
28
28
  asPayload: () => asPayload,
29
29
  asSchema: () => asSchema,
30
30
  isAnyPayload: () => isAnyPayload,
31
+ isModuleError: () => isModuleError,
31
32
  isPayload: () => isPayload,
32
33
  isPayloadOfSchemaType: () => isPayloadOfSchemaType,
34
+ isPayloadWithHash: () => isPayloadWithHash,
33
35
  isSchema: () => isSchema,
36
+ isWithHash: () => isWithHash,
34
37
  notPayloadOfSchemaType: () => notPayloadOfSchemaType
35
38
  });
36
39
  module.exports = __toCommonJS(src_exports);
37
40
 
38
- // src/Error.ts
39
- var ModuleErrorSchema = "network.xyo.error.module";
40
-
41
41
  // src/isPayload.ts
42
42
  var import_object = require("@xylabs/object");
43
43
  var isAnyPayload = /* @__PURE__ */ __name((value) => {
@@ -63,6 +63,18 @@ var notPayloadOfSchemaType = /* @__PURE__ */ __name((schema) => {
63
63
  return (x) => !isAnyPayload(x) || (x == null ? void 0 : x.schema) !== schema;
64
64
  }, "notPayloadOfSchemaType");
65
65
 
66
+ // src/Error.ts
67
+ var ModuleErrorSchema = "network.xyo.error.module";
68
+ var isModuleError = isPayloadOfSchemaType(ModuleErrorSchema);
69
+
70
+ // src/isPayloadWithHash.ts
71
+ var isWithHash = /* @__PURE__ */ __name((value) => {
72
+ return typeof (value == null ? void 0 : value.$hash) === "string";
73
+ }, "isWithHash");
74
+ var isPayloadWithHash = /* @__PURE__ */ __name((value) => {
75
+ return isAnyPayload(value) && isWithHash(value);
76
+ }, "isPayloadWithHash");
77
+
66
78
  // src/PayloadSet/PayloadSetSchema.ts
67
79
  var PayloadSetSchema = "network.xyo.payload.set";
68
80
 
@@ -85,9 +97,12 @@ var asSchema = import_object2.AsTypeFactory.create(isSchema);
85
97
  asPayload,
86
98
  asSchema,
87
99
  isAnyPayload,
100
+ isModuleError,
88
101
  isPayload,
89
102
  isPayloadOfSchemaType,
103
+ isPayloadWithHash,
90
104
  isSchema,
105
+ isWithHash,
91
106
  notPayloadOfSchemaType
92
107
  });
93
108
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/Error.ts","../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["export * from './Error'\nexport * from './isPayload'\nexport * from './isPayloadOfSchemaType'\nexport * from './Payload'\nexport * from './PayloadFindFilter'\nexport * from './PayloadSet'\nexport * from './Query'\nexport * from './Schema'\n","import { 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","/* 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","import { isAnyPayload } from './isPayload'\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 notPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => !isAnyPayload(x) || x?.schema !== schema\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;;;;;;;;;;;;;;;;;ACGO,IAAMA,oBAAuC;;;ACFpD,oBAA0C;AAInC,IAAMC,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;;;ACpBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC1E,GAFqC;AAI9B,IAAMG,yBAAyB,wBAAoBH,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC3E,GAFsC;;;ACN/B,IAAMI,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":["ModuleErrorSchema","isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","notPayloadOfSchemaType","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/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'\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","import { isAnyPayload } from './isPayload'\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 notPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => !isAnyPayload(x) || x?.schema !== schema\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","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;;;ACpBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC1E,GAFqC;AAI9B,IAAMG,yBAAyB,wBAAoBH,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC3E,GAFsC;;;ACH/B,IAAMI,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;;;AChB1B,IAAMI,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","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","PayloadSetSchema","import_object","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
@@ -1,6 +1,7 @@
1
1
  export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
+ export * from './isPayloadWithHash';
4
5
  export * from './Payload';
5
6
  export * from './PayloadFindFilter';
6
7
  export * from './PayloadSet';
@@ -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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
+ export * from './isPayloadWithHash';
4
5
  export * from './Payload';
5
6
  export * from './PayloadFindFilter';
6
7
  export * from './PayloadSet';
@@ -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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export * from './Error';
2
2
  export * from './isPayload';
3
3
  export * from './isPayloadOfSchemaType';
4
+ export * from './isPayloadWithHash';
4
5
  export * from './Payload';
5
6
  export * from './PayloadFindFilter';
6
7
  export * from './PayloadSet';
@@ -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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,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,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
- // src/Error.ts
5
- var ModuleErrorSchema = "network.xyo.error.module";
6
-
7
4
  // src/isPayload.ts
8
5
  import { AsObjectFactory, isObject } from "@xylabs/object";
9
6
  var isAnyPayload = /* @__PURE__ */ __name((value) => {
@@ -29,6 +26,18 @@ var notPayloadOfSchemaType = /* @__PURE__ */ __name((schema) => {
29
26
  return (x) => !isAnyPayload(x) || (x == null ? void 0 : x.schema) !== schema;
30
27
  }, "notPayloadOfSchemaType");
31
28
 
29
+ // src/Error.ts
30
+ var ModuleErrorSchema = "network.xyo.error.module";
31
+ var isModuleError = isPayloadOfSchemaType(ModuleErrorSchema);
32
+
33
+ // src/isPayloadWithHash.ts
34
+ var isWithHash = /* @__PURE__ */ __name((value) => {
35
+ return typeof (value == null ? void 0 : value.$hash) === "string";
36
+ }, "isWithHash");
37
+ var isPayloadWithHash = /* @__PURE__ */ __name((value) => {
38
+ return isAnyPayload(value) && isWithHash(value);
39
+ }, "isPayloadWithHash");
40
+
32
41
  // src/PayloadSet/PayloadSetSchema.ts
33
42
  var PayloadSetSchema = "network.xyo.payload.set";
34
43
 
@@ -50,9 +59,12 @@ export {
50
59
  asPayload,
51
60
  asSchema,
52
61
  isAnyPayload,
62
+ isModuleError,
53
63
  isPayload,
54
64
  isPayloadOfSchemaType,
65
+ isPayloadWithHash,
55
66
  isSchema,
67
+ isWithHash,
56
68
  notPayloadOfSchemaType
57
69
  };
58
70
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Error.ts","../../src/isPayload.ts","../../src/isPayloadOfSchemaType.ts","../../src/PayloadSet/PayloadSetSchema.ts","../../src/Schema.ts"],"sourcesContent":["import { 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","/* 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","import { isAnyPayload } from './isPayload'\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 notPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => !isAnyPayload(x) || x?.schema !== schema\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":";;;;AAGO,IAAMA,oBAAuC;;;ACFpD,SAASC,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;;;ACpBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC1E,GAFqC;AAI9B,IAAMG,yBAAyB,wBAAoBH,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC3E,GAFsC;;;ACN/B,IAAMI,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":["ModuleErrorSchema","AsObjectFactory","isObject","isAnyPayload","value","isObject","schema","asAnyPayload","AsObjectFactory","create","isPayload","includes","asPayload","isPayloadOfSchemaType","schema","x","isAnyPayload","notPayloadOfSchemaType","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/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","import { isAnyPayload } from './isPayload'\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 notPayloadOfSchemaType = <T extends Payload>(schema: string) => {\n return (x?: unknown | null): x is T => !isAnyPayload(x) || x?.schema !== schema\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","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;;;ACpBlB,IAAMS,wBAAwB,wBAAoBC,WAAAA;AACvD,SAAO,CAACC,MAA+BC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC1E,GAFqC;AAI9B,IAAMG,yBAAyB,wBAAoBH,WAAAA;AACxD,SAAO,CAACC,MAA+B,CAACC,aAAaD,CAAAA,MAAMA,uBAAGD,YAAWA;AAC3E,GAFsC;;;ACH/B,IAAMI,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;;;AChB1B,IAAMI,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","notPayloadOfSchemaType","ModuleErrorSchema","isModuleError","isPayloadOfSchemaType","isWithHash","value","$hash","isPayloadWithHash","isAnyPayload","PayloadSetSchema","AsTypeFactory","PayloadSchema","isSchema","value","asSchema","AsTypeFactory","create"]}
@@ -0,0 +1,18 @@
1
+ import { WithMeta } from './Payload';
2
+ /**
3
+ * Return true if the value is a payload with the required meta fields
4
+ * @param value The value to check
5
+ * @returns True if the value is a payload with the required meta fields
6
+ */
7
+ export declare const isWithHash: <T extends {
8
+ schema: string;
9
+ } & object>(value: T) => value is WithMeta<T>;
10
+ /**
11
+ * Return true if the value is a payload with the required meta fields
12
+ * @param value The value to check
13
+ * @returns True if the value is a payload with the required meta fields
14
+ */
15
+ export declare const isPayloadWithHash: <T extends {
16
+ schema: string;
17
+ } & object>(value: unknown) => value is WithMeta<T>;
18
+ //# sourceMappingURL=isPayloadWithHash.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,18 @@
1
+ import { WithMeta } from './Payload';
2
+ /**
3
+ * Return true if the value is a payload with the required meta fields
4
+ * @param value The value to check
5
+ * @returns True if the value is a payload with the required meta fields
6
+ */
7
+ export declare const isWithHash: <T extends {
8
+ schema: string;
9
+ } & object>(value: T) => value is WithMeta<T>;
10
+ /**
11
+ * Return true if the value is a payload with the required meta fields
12
+ * @param value The value to check
13
+ * @returns True if the value is a payload with the required meta fields
14
+ */
15
+ export declare const isPayloadWithHash: <T extends {
16
+ schema: string;
17
+ } & object>(value: unknown) => value is WithMeta<T>;
18
+ //# sourceMappingURL=isPayloadWithHash.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,18 @@
1
+ import { WithMeta } from './Payload';
2
+ /**
3
+ * Return true if the value is a payload with the required meta fields
4
+ * @param value The value to check
5
+ * @returns True if the value is a payload with the required meta fields
6
+ */
7
+ export declare const isWithHash: <T extends {
8
+ schema: string;
9
+ } & object>(value: T) => value is WithMeta<T>;
10
+ /**
11
+ * Return true if the value is a payload with the required meta fields
12
+ * @param value The value to check
13
+ * @returns True if the value is a payload with the required meta fields
14
+ */
15
+ export declare const isPayloadWithHash: <T extends {
16
+ schema: string;
17
+ } & object>(value: unknown) => value is WithMeta<T>;
18
+ //# sourceMappingURL=isPayloadWithHash.d.ts.map
@@ -0,0 +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"}
package/package.json CHANGED
@@ -57,7 +57,6 @@
57
57
  },
58
58
  "sideEffects": false,
59
59
  "types": "dist/node/index.d.ts",
60
- "version": "2.89.0-rc.9",
61
- "type": "module",
62
- "stableVersion": "2.88.3"
60
+ "version": "2.89.0",
61
+ "type": "module"
63
62
  }
package/src/Error.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { isPayloadOfSchemaType } from './isPayloadOfSchemaType'
1
2
  import { Payload } from './Payload'
2
3
 
3
4
  export type ModuleErrorSchema = 'network.xyo.error.module'
@@ -10,3 +11,5 @@ export type ModuleError = Payload<{
10
11
  schema: ModuleErrorSchema
11
12
  sources?: string[]
12
13
  }>
14
+
15
+ export const isModuleError = isPayloadOfSchemaType<ModuleError>(ModuleErrorSchema)
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './Error'
2
2
  export * from './isPayload'
3
3
  export * from './isPayloadOfSchemaType'
4
+ export * from './isPayloadWithHash'
4
5
  export * from './Payload'
5
6
  export * from './PayloadFindFilter'
6
7
  export * from './PayloadSet'
@@ -0,0 +1,20 @@
1
+ import { isAnyPayload } from './isPayload'
2
+ import { Payload, WithMeta } from './Payload'
3
+
4
+ /**
5
+ * Return true if the value is a payload with the required meta fields
6
+ * @param value The value to check
7
+ * @returns True if the value is a payload with the required meta fields
8
+ */
9
+ export const isWithHash = <T extends Payload>(value: T): value is WithMeta<T> => {
10
+ return typeof (value as WithMeta<T>)?.$hash === 'string'
11
+ }
12
+
13
+ /**
14
+ * Return true if the value is a payload with the required meta fields
15
+ * @param value The value to check
16
+ * @returns True if the value is a payload with the required meta fields
17
+ */
18
+ export const isPayloadWithHash = <T extends Payload>(value: unknown): value is WithMeta<T> => {
19
+ return isAnyPayload(value) && isWithHash(value)
20
+ }