@xyo-network/module-model 2.64.4 → 2.64.6

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.
package/dist/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './Config';
2
2
  export * from './CreatableModule';
3
3
  export * from './Error';
4
+ export * from './isModule';
4
5
  export * from './Module';
5
6
  export * from './ModuleDescription';
6
7
  export * from './ModuleFilter';
@@ -9,4 +10,5 @@ export * from './ModuleQueryResult';
9
10
  export * from './ModuleRepository';
10
11
  export * from './Queries';
11
12
  export * from './Query';
13
+ export * from './withModule';
12
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA"}
@@ -0,0 +1,14 @@
1
+ export const IsModuleFactory = {
2
+ create: (baseCheck, expectedFunctions,
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ additionalCheck) => {
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ return (module) => {
7
+ return ((baseCheck?.(module) || true) &&
8
+ (additionalCheck?.(module) ?? true) &&
9
+ (expectedFunctions?.reduce((prev, value) => prev && typeof module[value] === 'function', true) ?? true));
10
+ };
11
+ },
12
+ };
13
+ export const isModule = IsModuleFactory.create(undefined, ['query'], (module) => typeof module.config === 'object');
14
+ //# sourceMappingURL=isModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isModule.js","sourceRoot":"","sources":["../../src/isModule.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,CACN,SAA2B,EAC3B,iBAA4B;IAC5B,8DAA8D;IAC9D,eAA0C,EACtB,EAAE;QACtB,8DAA8D;QAC9D,OAAO,CAAC,MAAW,EAAe,EAAE;YAClC,OAAO,CACL,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAC7B,CAAC,eAAe,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBACnC,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,UAAU,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,CACxG,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAA4B,eAAe,CAAC,MAAM,CAAS,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { isModule } from './isModule';
2
+ export const WithModuleFactory = {
3
+ create: (typeCheck) => {
4
+ return (
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ module,
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ closure) => {
9
+ return typeCheck(module) ? closure(module) : undefined;
10
+ };
11
+ },
12
+ };
13
+ export const withModule = WithModuleFactory.create(isModule);
14
+ //# sourceMappingURL=withModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withModule.js","sourceRoot":"","sources":["../../src/withModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAmB,MAAM,YAAY,CAAA;AAGtD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,CAA4B,SAA6B,EAAE,EAAE;QACnE,OAAO;QACL,8DAA8D;QAC9D,MAAW;QACX,8DAA8D;QAC9D,OAA2B,EACZ,EAAE;YACjB,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACxD,CAAC,CAAA;IACH,CAAC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export * from './Config';
2
2
  export * from './CreatableModule';
3
3
  export * from './Error';
4
+ export * from './isModule';
4
5
  export * from './Module';
5
6
  export * from './ModuleDescription';
6
7
  export * from './ModuleFilter';
@@ -9,4 +10,5 @@ export * from './ModuleQueryResult';
9
10
  export * from './ModuleRepository';
10
11
  export * from './Queries';
11
12
  export * from './Query';
13
+ export * from './withModule';
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { Module } from './Module';
2
+ export type ModuleTypeCheck<T extends Module = Module> = (module: any) => module is T;
3
+ export declare const IsModuleFactory: {
4
+ create: <T extends Module = Module>(baseCheck?: ModuleTypeCheck, expectedFunctions?: string[], additionalCheck?: ((module: any) => boolean) | undefined) => ModuleTypeCheck<T>;
5
+ };
6
+ export declare const isModule: ModuleTypeCheck<Module>;
7
+ //# sourceMappingURL=isModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isModule.d.ts","sourceRoot":"","sources":["../../src/isModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,MAAM,IAAI,CAAC,CAAA;AAErF,eAAO,MAAM,eAAe;oDAEZ,eAAe,sBACP,MAAM,EAAE,8BAED,GAAG,KAAK,OAAO;CAW7C,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,eAAe,CAAC,MAAM,CAAuG,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { ModuleTypeCheck } from './isModule';
2
+ import { Module } from './Module';
3
+ export declare const WithModuleFactory: {
4
+ create: <T extends Module = Module>(typeCheck: ModuleTypeCheck<T>) => <R extends void = void>(module: any, closure: (module: any) => R) => R | undefined;
5
+ };
6
+ export declare const withModule: <R extends void = void>(module: any, closure: (module: any) => R) => R | undefined;
7
+ //# sourceMappingURL=withModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withModule.d.ts","sourceRoot":"","sources":["../../src/withModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,eAAe,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,eAAO,MAAM,iBAAiB;0GAIhB,GAAG,oBAEO,GAAG;CAK1B,CAAA;AAED,eAAO,MAAM,UAAU,kCATT,GAAG,oBAEO,GAAG,wBAOiC,CAAA"}
package/package.json CHANGED
@@ -10,15 +10,15 @@
10
10
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
11
11
  },
12
12
  "dependencies": {
13
- "@xyo-network/account-model": "^2.64.4",
14
- "@xyo-network/address-payload-plugin": "^2.64.4",
15
- "@xyo-network/boundwitness-model": "^2.64.4",
16
- "@xyo-network/core": "^2.64.4",
17
- "@xyo-network/manifest-model": "^2.64.4",
18
- "@xyo-network/module-events": "^2.64.4",
19
- "@xyo-network/payload-model": "^2.64.4",
20
- "@xyo-network/promise": "^2.64.4",
21
- "@xyo-network/wallet-model": "^2.64.4"
13
+ "@xyo-network/account-model": "^2.64.6",
14
+ "@xyo-network/address-payload-plugin": "^2.64.6",
15
+ "@xyo-network/boundwitness-model": "^2.64.6",
16
+ "@xyo-network/core": "^2.64.6",
17
+ "@xyo-network/manifest-model": "^2.64.6",
18
+ "@xyo-network/module-events": "^2.64.6",
19
+ "@xyo-network/payload-model": "^2.64.6",
20
+ "@xyo-network/promise": "^2.64.6",
21
+ "@xyo-network/wallet-model": "^2.64.6"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@xylabs/ts-scripts-yarn3": "^2.18.5",
@@ -58,5 +58,5 @@
58
58
  },
59
59
  "sideEffects": false,
60
60
  "types": "dist/types/index.d.ts",
61
- "version": "2.64.4"
61
+ "version": "2.64.6"
62
62
  }
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './Config'
2
2
  export * from './CreatableModule'
3
3
  export * from './Error'
4
+ export * from './isModule'
4
5
  export * from './Module'
5
6
  export * from './ModuleDescription'
6
7
  export * from './ModuleFilter'
@@ -9,3 +10,4 @@ export * from './ModuleQueryResult'
9
10
  export * from './ModuleRepository'
10
11
  export * from './Queries'
11
12
  export * from './Query'
13
+ export * from './withModule'
@@ -0,0 +1,24 @@
1
+ import { Module } from './Module'
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ export type ModuleTypeCheck<T extends Module = Module> = (module: any) => module is T
5
+
6
+ export const IsModuleFactory = {
7
+ create: <T extends Module = Module>(
8
+ baseCheck?: ModuleTypeCheck,
9
+ expectedFunctions?: string[],
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ additionalCheck?: (module: any) => boolean,
12
+ ): ModuleTypeCheck<T> => {
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ return (module: any): module is T => {
15
+ return (
16
+ (baseCheck?.(module) || true) &&
17
+ (additionalCheck?.(module) ?? true) &&
18
+ (expectedFunctions?.reduce((prev, value) => prev && typeof module[value] === 'function', true) ?? true)
19
+ )
20
+ }
21
+ },
22
+ }
23
+
24
+ export const isModule: ModuleTypeCheck<Module> = IsModuleFactory.create<Module>(undefined, ['query'], (module) => typeof module.config === 'object')
@@ -0,0 +1,17 @@
1
+ import { isModule, ModuleTypeCheck } from './isModule'
2
+ import { Module } from './Module'
3
+
4
+ export const WithModuleFactory = {
5
+ create: <T extends Module = Module>(typeCheck: ModuleTypeCheck<T>) => {
6
+ return <R extends void = void>(
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ module: any,
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ closure: (module: any) => R,
11
+ ): R | undefined => {
12
+ return typeCheck(module) ? closure(module) : undefined
13
+ }
14
+ },
15
+ }
16
+
17
+ export const withModule = WithModuleFactory.create(isModule)