@xyo-network/payload-model 2.84.6 → 2.84.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ ModuleErrorSchema: () => ModuleErrorSchema,
24
+ PayloadSchema: () => PayloadSchema,
25
+ PayloadSetSchema: () => PayloadSetSchema,
26
+ asAnyPayload: () => asAnyPayload,
27
+ asPayload: () => asPayload,
28
+ asSchema: () => asSchema,
29
+ isAnyPayload: () => isAnyPayload,
30
+ isPayload: () => isPayload,
31
+ isPayloadOfSchemaType: () => isPayloadOfSchemaType,
32
+ isSchema: () => isSchema,
33
+ notPayloadOfSchemaType: () => notPayloadOfSchemaType
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+
37
+ // src/Error.ts
38
+ var ModuleErrorSchema = "network.xyo.error.module";
39
+
40
+ // src/isPayload.ts
41
+ var import_object = require("@xyo-network/object");
42
+ var isAnyPayload = (value) => {
43
+ if ((0, import_object.isObject)(value)) {
44
+ return typeof value.schema === "string";
45
+ }
46
+ return false;
47
+ };
48
+ var asAnyPayload = import_object.AsObjectFactory.create(isAnyPayload);
49
+ var isPayload = (schema) => (value) => {
50
+ if (isAnyPayload(value)) {
51
+ return schema.includes(value.schema);
52
+ }
53
+ return false;
54
+ };
55
+ var asPayload = (schema) => import_object.AsObjectFactory.create((value) => isPayload(schema)(value));
56
+
57
+ // src/isPayloadOfSchemaType.ts
58
+ var isPayloadOfSchemaType = (schema) => {
59
+ return (x) => isAnyPayload(x) && (x == null ? void 0 : x.schema) === schema;
60
+ };
61
+ var notPayloadOfSchemaType = (schema) => {
62
+ return (x) => !isAnyPayload(x) || (x == null ? void 0 : x.schema) !== schema;
63
+ };
64
+
65
+ // src/PayloadSet/PayloadSetSchema.ts
66
+ var PayloadSetSchema = "network.xyo.payload.set";
67
+
68
+ // src/Schema.ts
69
+ var import_object2 = require("@xyo-network/object");
70
+ var PayloadSchema = "network.xyo.payload";
71
+ var isSchema = (value) => {
72
+ if (typeof value === "string") {
73
+ return true;
74
+ }
75
+ return false;
76
+ };
77
+ var asSchema = import_object2.AsTypeFactory.create(isSchema);
78
+ // Annotate the CommonJS export names for ESM import in node:
79
+ 0 && (module.exports = {
80
+ ModuleErrorSchema,
81
+ PayloadSchema,
82
+ PayloadSetSchema,
83
+ asAnyPayload,
84
+ asPayload,
85
+ asSchema,
86
+ isAnyPayload,
87
+ isPayload,
88
+ isPayloadOfSchemaType,
89
+ isSchema,
90
+ notPayloadOfSchemaType
91
+ });
92
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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 '@xyo-network/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 '@xyo-network/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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,oBAAuC;;;ACFpD,oBAA0C;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,UAAI,wBAAS,KAAK,GAAG;AACnB,WAAO,OAAO,MAAM,WAAW;AAAA,EACjC;AACA,SAAO;AACT;AAEO,IAAM,eAAe,8BAAgB,OAAO,YAAY;AAExD,IAAM,YACX,CAAoB,WACpB,CAAC,UAA+B;AAC9B,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO,OAAO,SAAS,MAAM,MAAM;AAAA,EACrC;AACA,SAAO;AACT;AAEK,IAAM,YAAY,CAAoB,WAAqB,8BAAgB,OAAO,CAAC,UAA+B,UAAU,MAAM,EAAE,KAAK,CAAC;;;ACpB1I,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,MAAK,uBAAG,YAAW;AAC1E;AAEO,IAAM,yBAAyB,CAAoB,WAAmB;AAC3E,SAAO,CAAC,MAA+B,CAAC,aAAa,CAAC,MAAK,uBAAG,YAAW;AAC3E;;;ACRO,IAAM,mBAAqC;;;ACDlD,IAAAA,iBAA2C;AAKpC,IAAM,gBAAgB;AAGtB,IAAM,WAAW,CAAC,UAAoC;AAC3D,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,IAAM,WAAW,6BAAc,OAAe,QAAQ;","names":["import_object"]}
@@ -1,58 +1,22 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- ModuleErrorSchema: () => ModuleErrorSchema,
24
- PayloadSchema: () => PayloadSchema,
25
- PayloadSetSchema: () => PayloadSetSchema,
26
- asAnyPayload: () => asAnyPayload,
27
- asPayload: () => asPayload,
28
- asSchema: () => asSchema,
29
- isAnyPayload: () => isAnyPayload,
30
- isPayload: () => isPayload,
31
- isPayloadOfSchemaType: () => isPayloadOfSchemaType,
32
- isSchema: () => isSchema,
33
- notPayloadOfSchemaType: () => notPayloadOfSchemaType
34
- });
35
- module.exports = __toCommonJS(src_exports);
36
-
37
1
  // src/Error.ts
38
2
  var ModuleErrorSchema = "network.xyo.error.module";
39
3
 
40
4
  // src/isPayload.ts
41
- var import_object = require("@xyo-network/object");
5
+ import { AsObjectFactory, isObject } from "@xyo-network/object";
42
6
  var isAnyPayload = (value) => {
43
- if ((0, import_object.isObject)(value)) {
7
+ if (isObject(value)) {
44
8
  return typeof value.schema === "string";
45
9
  }
46
10
  return false;
47
11
  };
48
- var asAnyPayload = import_object.AsObjectFactory.create(isAnyPayload);
12
+ var asAnyPayload = AsObjectFactory.create(isAnyPayload);
49
13
  var isPayload = (schema) => (value) => {
50
14
  if (isAnyPayload(value)) {
51
15
  return schema.includes(value.schema);
52
16
  }
53
17
  return false;
54
18
  };
55
- var asPayload = (schema) => import_object.AsObjectFactory.create((value) => isPayload(schema)(value));
19
+ var asPayload = (schema) => AsObjectFactory.create((value) => isPayload(schema)(value));
56
20
 
57
21
  // src/isPayloadOfSchemaType.ts
58
22
  var isPayloadOfSchemaType = (schema) => {
@@ -66,7 +30,7 @@ var notPayloadOfSchemaType = (schema) => {
66
30
  var PayloadSetSchema = "network.xyo.payload.set";
67
31
 
68
32
  // src/Schema.ts
69
- var import_object2 = require("@xyo-network/object");
33
+ import { AsTypeFactory } from "@xyo-network/object";
70
34
  var PayloadSchema = "network.xyo.payload";
71
35
  var isSchema = (value) => {
72
36
  if (typeof value === "string") {
@@ -74,9 +38,8 @@ var isSchema = (value) => {
74
38
  }
75
39
  return false;
76
40
  };
77
- var asSchema = import_object2.AsTypeFactory.create(isSchema);
78
- // Annotate the CommonJS export names for ESM import in node:
79
- 0 && (module.exports = {
41
+ var asSchema = AsTypeFactory.create(isSchema);
42
+ export {
80
43
  ModuleErrorSchema,
81
44
  PayloadSchema,
82
45
  PayloadSetSchema,
@@ -88,5 +51,5 @@ var asSchema = import_object2.AsTypeFactory.create(isSchema);
88
51
  isPayloadOfSchemaType,
89
52
  isSchema,
90
53
  notPayloadOfSchemaType
91
- });
54
+ };
92
55
  //# sourceMappingURL=index.js.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 '@xyo-network/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 '@xyo-network/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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,oBAAuC;;;ACFpD,oBAA0C;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,UAAI,wBAAS,KAAK,GAAG;AACnB,WAAO,OAAO,MAAM,WAAW;AAAA,EACjC;AACA,SAAO;AACT;AAEO,IAAM,eAAe,8BAAgB,OAAO,YAAY;AAExD,IAAM,YACX,CAAoB,WACpB,CAAC,UAA+B;AAC9B,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO,OAAO,SAAS,MAAM,MAAM;AAAA,EACrC;AACA,SAAO;AACT;AAEK,IAAM,YAAY,CAAoB,WAAqB,8BAAgB,OAAO,CAAC,UAA+B,UAAU,MAAM,EAAE,KAAK,CAAC;;;ACpB1I,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,MAAK,uBAAG,YAAW;AAC1E;AAEO,IAAM,yBAAyB,CAAoB,WAAmB;AAC3E,SAAO,CAAC,MAA+B,CAAC,aAAa,CAAC,MAAK,uBAAG,YAAW;AAC3E;;;ACRO,IAAM,mBAAqC;;;ACDlD,IAAAA,iBAA2C;AAKpC,IAAM,gBAAgB;AAGtB,IAAM,WAAW,CAAC,UAAoC;AAC3D,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,IAAM,WAAW,6BAAc,OAAe,QAAQ;","names":["import_object"]}
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 '@xyo-network/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 '@xyo-network/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,IAAM,oBAAuC;;;ACFpD,SAAS,iBAAiB,gBAAgB;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,OAAO,MAAM,WAAW;AAAA,EACjC;AACA,SAAO;AACT;AAEO,IAAM,eAAe,gBAAgB,OAAO,YAAY;AAExD,IAAM,YACX,CAAoB,WACpB,CAAC,UAA+B;AAC9B,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO,OAAO,SAAS,MAAM,MAAM;AAAA,EACrC;AACA,SAAO;AACT;AAEK,IAAM,YAAY,CAAoB,WAAqB,gBAAgB,OAAO,CAAC,UAA+B,UAAU,MAAM,EAAE,KAAK,CAAC;;;ACpB1I,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,MAAK,uBAAG,YAAW;AAC1E;AAEO,IAAM,yBAAyB,CAAoB,WAAmB;AAC3E,SAAO,CAAC,MAA+B,CAAC,aAAa,CAAC,MAAK,uBAAG,YAAW;AAC3E;;;ACRO,IAAM,mBAAqC;;;ACDlD,SAAS,qBAAkC;AAKpC,IAAM,gBAAgB;AAGtB,IAAM,WAAW,CAAC,UAAoC;AAC3D,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,IAAM,WAAW,cAAc,OAAe,QAAQ;","names":[]}
package/package.json CHANGED
@@ -10,15 +10,14 @@
10
10
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
11
11
  },
12
12
  "dependencies": {
13
- "@xyo-network/object": "~2.84.6"
13
+ "@xyo-network/object": "~2.84.7"
14
14
  },
15
15
  "devDependencies": {
16
- "@xylabs/ts-scripts-yarn3": "^3.2.19",
17
- "@xylabs/tsconfig": "^3.2.19",
16
+ "@xylabs/ts-scripts-yarn3": "^3.2.24",
17
+ "@xylabs/tsconfig": "^3.2.24",
18
18
  "typescript": "^5.3.3"
19
19
  },
20
20
  "description": "Primary SDK for using XYO Protocol 2.0",
21
- "docs": "dist/docs.json",
22
21
  "exports": {
23
22
  ".": {
24
23
  "browser": {
@@ -33,19 +32,19 @@
33
32
  },
34
33
  "node": {
35
34
  "require": {
36
- "types": "./dist/node/index.d.ts",
37
- "default": "./dist/node/index.js"
35
+ "types": "./dist/node/index.d.cts",
36
+ "default": "./dist/node/index.cjs"
38
37
  },
39
38
  "import": {
40
39
  "types": "./dist/node/index.d.mts",
41
- "default": "./dist/node/index.mjs"
40
+ "default": "./dist/node/index.js"
42
41
  }
43
42
  }
44
43
  },
45
44
  "./package.json": "./package.json"
46
45
  },
47
- "main": "dist/node/index.js",
48
- "module": "dist/node/index.mjs",
46
+ "main": "dist/node/index.cjs",
47
+ "module": "dist/node/index.js",
49
48
  "homepage": "https://xyo.network",
50
49
  "license": "LGPL-3.0-only",
51
50
  "publishConfig": {
@@ -57,5 +56,6 @@
57
56
  },
58
57
  "sideEffects": false,
59
58
  "types": "dist/node/index.d.ts",
60
- "version": "2.84.6"
59
+ "version": "2.84.7",
60
+ "type": "module"
61
61
  }
@@ -1,55 +0,0 @@
1
- // src/Error.ts
2
- var ModuleErrorSchema = "network.xyo.error.module";
3
-
4
- // src/isPayload.ts
5
- import { AsObjectFactory, isObject } from "@xyo-network/object";
6
- var isAnyPayload = (value) => {
7
- if (isObject(value)) {
8
- return typeof value.schema === "string";
9
- }
10
- return false;
11
- };
12
- var asAnyPayload = AsObjectFactory.create(isAnyPayload);
13
- var isPayload = (schema) => (value) => {
14
- if (isAnyPayload(value)) {
15
- return schema.includes(value.schema);
16
- }
17
- return false;
18
- };
19
- var asPayload = (schema) => AsObjectFactory.create((value) => isPayload(schema)(value));
20
-
21
- // src/isPayloadOfSchemaType.ts
22
- var isPayloadOfSchemaType = (schema) => {
23
- return (x) => isAnyPayload(x) && (x == null ? void 0 : x.schema) === schema;
24
- };
25
- var notPayloadOfSchemaType = (schema) => {
26
- return (x) => !isAnyPayload(x) || (x == null ? void 0 : x.schema) !== schema;
27
- };
28
-
29
- // src/PayloadSet/PayloadSetSchema.ts
30
- var PayloadSetSchema = "network.xyo.payload.set";
31
-
32
- // src/Schema.ts
33
- import { AsTypeFactory } from "@xyo-network/object";
34
- var PayloadSchema = "network.xyo.payload";
35
- var isSchema = (value) => {
36
- if (typeof value === "string") {
37
- return true;
38
- }
39
- return false;
40
- };
41
- var asSchema = AsTypeFactory.create(isSchema);
42
- export {
43
- ModuleErrorSchema,
44
- PayloadSchema,
45
- PayloadSetSchema,
46
- asAnyPayload,
47
- asPayload,
48
- asSchema,
49
- isAnyPayload,
50
- isPayload,
51
- isPayloadOfSchemaType,
52
- isSchema,
53
- notPayloadOfSchemaType
54
- };
55
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
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 '@xyo-network/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 '@xyo-network/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,IAAM,oBAAuC;;;ACFpD,SAAS,iBAAiB,gBAAgB;AAInC,IAAM,eAAe,CAAC,UAAqC;AAChE,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,OAAO,MAAM,WAAW;AAAA,EACjC;AACA,SAAO;AACT;AAEO,IAAM,eAAe,gBAAgB,OAAO,YAAY;AAExD,IAAM,YACX,CAAoB,WACpB,CAAC,UAA+B;AAC9B,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO,OAAO,SAAS,MAAM,MAAM;AAAA,EACrC;AACA,SAAO;AACT;AAEK,IAAM,YAAY,CAAoB,WAAqB,gBAAgB,OAAO,CAAC,UAA+B,UAAU,MAAM,EAAE,KAAK,CAAC;;;ACpB1I,IAAM,wBAAwB,CAAoB,WAAmB;AAC1E,SAAO,CAAC,MAA+B,aAAa,CAAC,MAAK,uBAAG,YAAW;AAC1E;AAEO,IAAM,yBAAyB,CAAoB,WAAmB;AAC3E,SAAO,CAAC,MAA+B,CAAC,aAAa,CAAC,MAAK,uBAAG,YAAW;AAC3E;;;ACRO,IAAM,mBAAqC;;;ACDlD,SAAS,qBAAkC;AAKpC,IAAM,gBAAgB;AAGtB,IAAM,WAAW,CAAC,UAAoC;AAC3D,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,IAAM,WAAW,cAAc,OAAe,QAAQ;","names":[]}