@xyo-network/module-model 2.84.2 → 2.84.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,62 @@
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
+ AddressPreviousHashSchema: () => AddressPreviousHashSchema,
24
+ IsInstanceFactory: () => IsInstanceFactory,
25
+ IsModuleFactory: () => IsModuleFactory,
26
+ ModuleAddressQuerySchema: () => ModuleAddressQuerySchema,
27
+ ModuleConfigSchema: () => ModuleConfigSchema,
28
+ ModuleDescribeQuerySchema: () => ModuleDescribeQuerySchema,
29
+ ModuleDescriptionSchema: () => ModuleDescriptionSchema,
30
+ ModuleDiscoverQuerySchema: () => ModuleDiscoverQuerySchema,
31
+ ModuleFactory: () => ModuleFactory,
32
+ ModuleFactoryLocator: () => ModuleFactoryLocator,
33
+ ModuleManifestQuerySchema: () => ModuleManifestQuerySchema,
34
+ ModuleStateSchema: () => ModuleStateSchema,
35
+ ModuleSubscribeQuerySchema: () => ModuleSubscribeQuerySchema,
36
+ WithFactory: () => WithFactory,
37
+ asModule: () => asModule,
38
+ asModuleInstance: () => asModuleInstance,
39
+ asModuleObject: () => asModuleObject,
40
+ assignCreatableModuleRegistry: () => assignCreatableModuleRegistry,
41
+ creatableModule: () => creatableModule,
42
+ duplicateModules: () => duplicateModules,
43
+ hasAllLabels: () => hasAllLabels,
44
+ hasLabels: () => hasLabels,
45
+ isModule: () => isModule,
46
+ isModuleInstance: () => isModuleInstance,
47
+ isModuleObject: () => isModuleObject,
48
+ isModuleState: () => isModuleState,
49
+ requiredModuleInstanceFunctions: () => requiredModuleInstanceFunctions,
50
+ requiredModuleQueries: () => requiredModuleQueries,
51
+ requiredModuleShape: () => requiredModuleShape,
52
+ serializable: () => serializable,
53
+ serializableField: () => serializableField,
54
+ toCreatableModuleRegistry: () => toCreatableModuleRegistry,
55
+ withModule: () => withModule,
56
+ withModuleInstance: () => withModuleInstance
57
+ });
58
+ module.exports = __toCommonJS(src_exports);
59
+
1
60
  // src/Config.ts
2
61
  var ModuleConfigSchema = "network.xyo.module.config";
3
62
 
@@ -33,8 +92,8 @@ var hasLabels = (factory4) => {
33
92
  };
34
93
 
35
94
  // src/CreatableModule/ModuleFactory.ts
36
- import { assertEx } from "@xylabs/assert";
37
- import { merge } from "@xylabs/lodash";
95
+ var import_assert = require("@xylabs/assert");
96
+ var import_lodash = require("@xylabs/lodash");
38
97
  var ModuleFactory = class _ModuleFactory {
39
98
  configSchemas;
40
99
  creatableModule;
@@ -63,14 +122,14 @@ var ModuleFactory = class _ModuleFactory {
63
122
  _noOverride(functionName) {
64
123
  const thisFunc = this[functionName];
65
124
  const rootFunc = this._getRootFunction(functionName);
66
- assertEx(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`);
125
+ (0, import_assert.assertEx)(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`);
67
126
  }
68
127
  create(params) {
69
128
  var _a;
70
129
  const factory4 = this;
71
130
  const schema = factory4.creatableModule.configSchema;
72
- const mergedParams = merge({}, factory4.defaultParams, params, {
73
- config: merge({}, (_a = factory4.defaultParams) == null ? void 0 : _a.config, params == null ? void 0 : params.config, { schema })
131
+ const mergedParams = (0, import_lodash.merge)({}, factory4.defaultParams, params, {
132
+ config: (0, import_lodash.merge)({}, (_a = factory4.defaultParams) == null ? void 0 : _a.config, params == null ? void 0 : params.config, { schema })
74
133
  });
75
134
  return factory4.creatableModule.create(mergedParams);
76
135
  }
@@ -80,7 +139,7 @@ var ModuleFactory = class _ModuleFactory {
80
139
  };
81
140
 
82
141
  // src/CreatableModule/ModuleFactoryLocator.ts
83
- import { assertEx as assertEx2 } from "@xylabs/assert";
142
+ var import_assert2 = require("@xylabs/assert");
84
143
 
85
144
  // src/Labels/Labels.ts
86
145
  var hasAllLabels = (source, required) => {
@@ -109,7 +168,7 @@ var ModuleFactoryLocator = class {
109
168
  * @returns A module factory that matches the supplied schema and labels or throws if one is not found
110
169
  */
111
170
  locate(schema, labels) {
112
- return assertEx2(this.tryLocate(schema, labels), () => {
171
+ return (0, import_assert2.assertEx)(this.tryLocate(schema, labels), () => {
113
172
  const configString = `config schema [${schema}]`;
114
173
  const labelsString = labels ? ` & labels [${JSON.stringify(labels)}]` : "";
115
174
  return `No module factory for the supplied ${configString}${labelsString} registered`;
@@ -166,13 +225,13 @@ var ModuleFactoryLocator = class {
166
225
  };
167
226
 
168
227
  // src/instance/asModuleInstance.ts
169
- import { AsObjectFactory as AsObjectFactory3 } from "@xyo-network/object";
228
+ var import_object5 = require("@xyo-network/object");
170
229
 
171
230
  // src/instance/isModuleInstance.ts
172
- import { IsObjectFactory as IsObjectFactory2 } from "@xyo-network/object";
231
+ var import_object4 = require("@xyo-network/object");
173
232
 
174
233
  // src/module/asModule.ts
175
- import { AsObjectFactory as AsObjectFactory2 } from "@xyo-network/object";
234
+ var import_object3 = require("@xyo-network/object");
176
235
 
177
236
  // src/Queries/Describe/Payload.ts
178
237
  var ModuleDescriptionSchema = "network.xyo.module.description";
@@ -187,8 +246,8 @@ var ModuleDiscoverQuerySchema = "network.xyo.query.module.discover";
187
246
  var ModuleManifestQuerySchema = "network.xyo.query.module.manifest";
188
247
 
189
248
  // src/Queries/ModuleAddress/Payload.ts
190
- import { AddressSchema } from "@xyo-network/address-payload-plugin";
191
- var AddressPreviousHashSchema = `${AddressSchema}.hash.previous`;
249
+ var import_address_payload_plugin = require("@xyo-network/address-payload-plugin");
250
+ var AddressPreviousHashSchema = `${import_address_payload_plugin.AddressSchema}.hash.previous`;
192
251
 
193
252
  // src/Queries/ModuleAddress/Query.ts
194
253
  var ModuleAddressQuerySchema = "network.xyo.query.module.address";
@@ -197,10 +256,10 @@ var ModuleAddressQuerySchema = "network.xyo.query.module.address";
197
256
  var ModuleSubscribeQuerySchema = "network.xyo.query.module.subscribe";
198
257
 
199
258
  // src/module/asModuleObject.ts
200
- import { AsObjectFactory } from "@xyo-network/object";
259
+ var import_object2 = require("@xyo-network/object");
201
260
 
202
261
  // src/module/isModuleObject.ts
203
- import { IsObjectFactory } from "@xyo-network/object";
262
+ var import_object = require("@xyo-network/object");
204
263
  var requiredModuleShape = {
205
264
  address: "string",
206
265
  config: "object",
@@ -209,18 +268,18 @@ var requiredModuleShape = {
209
268
  query: "function",
210
269
  queryable: "function"
211
270
  };
212
- var factory = new IsObjectFactory();
271
+ var factory = new import_object.IsObjectFactory();
213
272
  var isModuleObject = factory.create(requiredModuleShape);
214
273
 
215
274
  // src/module/asModuleObject.ts
216
- var asModuleObject = AsObjectFactory.create(isModuleObject);
275
+ var asModuleObject = import_object2.AsObjectFactory.create(isModuleObject);
217
276
 
218
277
  // src/module/IsModuleFactory.ts
219
278
  var IsModuleFactory = class {
220
279
  create(expectedQueries, additionalChecks) {
221
280
  return (obj, config) => {
222
- const module = asModuleObject(obj);
223
- const result = isModuleObject(module, config) && ((expectedQueries == null ? void 0 : expectedQueries.reduce((prev, query) => prev && module.queries.includes(query), true)) ?? true) && //perform additional checks
281
+ const module2 = asModuleObject(obj);
282
+ const result = isModuleObject(module2, config) && ((expectedQueries == null ? void 0 : expectedQueries.reduce((prev, query) => prev && module2.queries.includes(query), true)) ?? true) && //perform additional checks
224
283
  ((additionalChecks == null ? void 0 : additionalChecks.reduce((prev, check) => prev && check(obj, config), true)) ?? true);
225
284
  return result;
226
285
  };
@@ -240,7 +299,7 @@ var factory2 = new IsModuleFactory();
240
299
  var isModule = factory2.create(requiredModuleQueries, [isModuleObject]);
241
300
 
242
301
  // src/module/asModule.ts
243
- var asModule = AsObjectFactory2.create(isModule);
302
+ var asModule = import_object3.AsObjectFactory.create(isModule);
244
303
 
245
304
  // src/instance/isModuleInstance.ts
246
305
  var requiredModuleInstanceFunctions = {
@@ -249,15 +308,15 @@ var requiredModuleInstanceFunctions = {
249
308
  manifest: "function",
250
309
  moduleAddress: "function"
251
310
  };
252
- var factory3 = new IsObjectFactory2();
311
+ var factory3 = new import_object4.IsObjectFactory();
253
312
  var isModuleInstance = factory3.create(requiredModuleInstanceFunctions, [isModule]);
254
313
 
255
314
  // src/instance/asModuleInstance.ts
256
- var asModuleInstance = AsObjectFactory3.create(isModuleInstance);
315
+ var asModuleInstance = import_object5.AsObjectFactory.create(isModuleInstance);
257
316
 
258
317
  // src/instance/ModuleInstance.ts
259
- import { IsObjectFactory as IsObjectFactory3 } from "@xyo-network/object";
260
- var IsInstanceFactory = class extends IsObjectFactory3 {
318
+ var import_object6 = require("@xyo-network/object");
319
+ var IsInstanceFactory = class extends import_object6.IsObjectFactory {
261
320
  };
262
321
 
263
322
  // src/lib/duplicateModules.ts
@@ -266,9 +325,9 @@ var duplicateModules = (value, index, array) => {
266
325
  };
267
326
 
268
327
  // src/lib/serializable.ts
269
- import { every, isArray, isBoolean, isNull, isNumber, isPlainObject, isString, isUndefined, overSome } from "@xylabs/lodash";
270
- var JSONPrimitiveChecks = [isUndefined, isNull, isBoolean, isNumber, isString];
271
- var JSONComplexChecks = [isPlainObject, isArray];
328
+ var import_lodash2 = require("@xylabs/lodash");
329
+ var JSONPrimitiveChecks = [import_lodash2.isUndefined, import_lodash2.isNull, import_lodash2.isBoolean, import_lodash2.isNumber, import_lodash2.isString];
330
+ var JSONComplexChecks = [import_lodash2.isPlainObject, import_lodash2.isArray];
272
331
  var serializable = (field, depth) => {
273
332
  let depthExceeded = false;
274
333
  const decrementDepth = () => depth ? depth-- : void 0;
@@ -278,34 +337,35 @@ var serializable = (field, depth) => {
278
337
  return false;
279
338
  }
280
339
  decrementDepth();
281
- const nestedSerializable = (field3) => overSome(JSONComplexChecks)(field3) && every(field3, recursiveSerializable);
282
- return overSome([...JSONPrimitiveChecks, nestedSerializable])(field2);
340
+ const nestedSerializable = (field3) => (0, import_lodash2.overSome)(JSONComplexChecks)(field3) && (0, import_lodash2.every)(field3, recursiveSerializable);
341
+ return (0, import_lodash2.overSome)([...JSONPrimitiveChecks, nestedSerializable])(field2);
283
342
  };
284
343
  const valid = recursiveSerializable(field);
285
344
  return depthExceeded ? null : valid;
286
345
  };
287
346
  var serializableField = (field) => {
288
- return overSome([...JSONPrimitiveChecks, ...JSONComplexChecks])(field);
347
+ return (0, import_lodash2.overSome)([...JSONPrimitiveChecks, ...JSONComplexChecks])(field);
289
348
  };
290
349
 
291
350
  // src/Payload/ModuleState.ts
292
- import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
351
+ var import_payload_model = require("@xyo-network/payload-model");
293
352
  var ModuleStateSchema = "network.xyo.module.state";
294
353
  var isModuleState = (payload) => {
295
- return isPayloadOfSchemaType(ModuleStateSchema)(payload);
354
+ return (0, import_payload_model.isPayloadOfSchemaType)(ModuleStateSchema)(payload);
296
355
  };
297
356
 
298
357
  // src/withModule.ts
299
358
  var WithFactory = {
300
359
  create: (typeCheck) => {
301
- return (module, closure) => {
302
- return typeCheck(module) ? closure(module) : void 0;
360
+ return (module2, closure) => {
361
+ return typeCheck(module2) ? closure(module2) : void 0;
303
362
  };
304
363
  }
305
364
  };
306
365
  var withModule = WithFactory.create(isModule);
307
366
  var withModuleInstance = WithFactory.create(isModuleInstance);
308
- export {
367
+ // Annotate the CommonJS export names for ESM import in node:
368
+ 0 && (module.exports = {
309
369
  AddressPreviousHashSchema,
310
370
  IsInstanceFactory,
311
371
  IsModuleFactory,
@@ -340,5 +400,5 @@ export {
340
400
  toCreatableModuleRegistry,
341
401
  withModule,
342
402
  withModuleInstance
343
- };
344
- //# sourceMappingURL=index.mjs.map
403
+ });
404
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts","../../src/Config.ts","../../src/CreatableModule/CreatableModule.ts","../../src/CreatableModule/CreatableModuleRegistry.ts","../../src/CreatableModule/LabeledCreatableModuleFactory.ts","../../src/CreatableModule/ModuleFactory.ts","../../src/CreatableModule/ModuleFactoryLocator.ts","../../src/Labels/Labels.ts","../../src/instance/asModuleInstance.ts","../../src/instance/isModuleInstance.ts","../../src/module/asModule.ts","../../src/Queries/Describe/Payload.ts","../../src/Queries/Describe/Query.ts","../../src/Queries/Discover.ts","../../src/Queries/Manifest.ts","../../src/Queries/ModuleAddress/Payload.ts","../../src/Queries/ModuleAddress/Query.ts","../../src/Queries/Subscribe.ts","../../src/module/asModuleObject.ts","../../src/module/isModuleObject.ts","../../src/module/IsModuleFactory.ts","../../src/module/isModule.ts","../../src/instance/ModuleInstance.ts","../../src/lib/duplicateModules.ts","../../src/lib/serializable.ts","../../src/Payload/ModuleState.ts","../../src/withModule.ts"],"sourcesContent":["export * from './Config'\nexport * from './CreatableModule'\nexport * from './EventsModels'\nexport * from './instance'\nexport * from './Labels'\nexport * from './lib'\nexport * from './module'\nexport * from './ModuleDescription'\nexport * from './ModuleParams'\nexport * from './ModuleQueryHandlerResult'\nexport * from './ModuleQueryResult'\nexport * from './Payload'\nexport * from './Queries'\nexport * from './withModule'\n","import { Address } from '@xylabs/hex'\nimport { EmptyObject, WithAdditional } from '@xyo-network/object'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { Labels } from './Labels'\n\nexport type ModuleConfigSchema = 'network.xyo.module.config'\nexport const ModuleConfigSchema: ModuleConfigSchema = 'network.xyo.module.config'\n\nexport type CosigningAddressSet = string[]\nexport type SchemaString = string\nexport type ModuleName = string\nexport type NameOrAddress = Address | ModuleName\n\n/** @deprecated */\nexport interface IndividualArchivistConfig {\n readonly commit?: NameOrAddress\n readonly read?: NameOrAddress\n readonly write?: NameOrAddress\n}\n\n/** @deprecated */\nexport type ArchivistModuleConfig = NameOrAddress | IndividualArchivistConfig\n\nexport interface ArchivingModuleConfig {\n readonly archiving?: {\n readonly archivists?: NameOrAddress[]\n }\n}\n\nexport type ModuleConfig<\n TConfig extends Payload | void = void,\n TAdditionalParams extends EmptyObject | void = void,\n TSchema extends Schema | void = void,\n> = Payload<\n WithAdditional<\n WithAdditional<\n {\n /** @field The path to use when creating the account */\n accountDerivationPath?: string\n\n /** @field The name/address of the Archivist to use for this module */\n readonly archivist?: ArchivistModuleConfig\n\n /**\n * @field The labels used for this module. If a label is specified, then the\n * ModuleFactoryLocator will attempt to find a ModuleFactory with the corresponding\n * labels to construct this module.\n */\n readonly labels?: Labels\n\n /** @field Friendly name of module (not collision resistent). Can be used to resolve module when registered/attached to Node. */\n readonly name?: string\n\n /** @field paging settings for queries */\n readonly paging?: Record<string, { size?: number }>\n\n /** @field The query schemas and allowed/disallowed addresses which are allowed to issue them against the module. If both allowed and disallowed is specified, then disallowed takes priority. */\n readonly security?: {\n /** @field Will the module process queries that have unsigned BoundWitness in query tuples */\n readonly allowAnonymous?: boolean\n\n /** @field If schema in record, then only these address sets can access query */\n readonly allowed?: Record<SchemaString, (Address | CosigningAddressSet)[]>\n\n /** @field If schema in record, then anyone except these addresses can access query */\n readonly disallowed?: Record<SchemaString, Address[]>\n }\n\n /** @field sign every query */\n readonly sign?: boolean\n\n /** @field Store the queries made to the module in an archivist if possible */\n readonly storeQueries?: boolean\n\n /** @field add a timestamp payload to every query */\n readonly timestamp?: boolean\n } & ArchivingModuleConfig,\n TConfig\n >,\n TAdditionalParams\n >,\n TSchema extends Schema ? TSchema : TConfig extends Payload ? TConfig['schema'] : ModuleConfigSchema\n>\n\nexport type AnyConfigSchema<TConfig extends Omit<ModuleConfig, 'schema'> & { schema: string } = Omit<ModuleConfig, 'schema'> & { schema: string }> =\n ModuleConfig<\n {\n schema: string\n },\n Omit<TConfig, 'schema'>\n >\n\nexport type OptionalConfigSchema<TConfig extends AnyConfigSchema<ModuleConfig> = AnyConfigSchema<ModuleConfig>> = Omit<TConfig, 'schema'> & {\n schema?: TConfig['schema']\n}\n\nexport type AnyModuleConfig = AnyConfigSchema<ModuleConfig>\n","import { Logger } from '@xylabs/logger'\nimport { AccountInstance } from '@xyo-network/account-model'\n\nimport { ModuleInstance } from '../instance'\n\nexport type CreatableModuleFactory<T extends ModuleInstance = ModuleInstance> = Omit<Omit<CreatableModule<T>, 'new'>, 'create'> & {\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: T['params']): Promise<T>\n}\n\nexport interface CreatableModule<T extends ModuleInstance = ModuleInstance> {\n configSchema: string\n configSchemas: string[]\n defaultLogger?: Logger\n new (privateConstructorKey: string, params: T['params'], account: AccountInstance): T\n _noOverride(functionName: string): void\n create<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): Promise<T>\n factory<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): CreatableModuleFactory<T>\n}\n\n/**\n * Class annotation to be used to decorate Modules which support\n * an asynchronous creation pattern\n * @returns The decorated Module requiring it implement the members\n * of the CreatableModule as statics properties/methods\n */\nexport function creatableModule<TModule extends ModuleInstance = ModuleInstance>() {\n return <U extends CreatableModule<TModule>>(constructor: U) => {\n constructor\n }\n}\n","import { CreatableModuleFactory } from './CreatableModule'\nimport { CreatableModuleDictionary } from './CreatableModuleDictionary'\nimport { LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\nexport interface CreatableModuleRegistry {\n [key: string]: (CreatableModuleFactory | LabeledCreatableModuleFactory)[] | undefined\n}\n\nexport const toCreatableModuleRegistry = (dict: CreatableModuleDictionary | CreatableModuleRegistry): CreatableModuleRegistry => {\n return Object.entries(dict).reduce((registry, [schema, factory]) => {\n registry[schema] = Array.isArray(factory) ? factory : [factory]\n return registry\n }, {} as CreatableModuleRegistry)\n}\n\nexport const assignCreatableModuleRegistry = (\n target: CreatableModuleRegistry = {},\n ...sources: CreatableModuleRegistry[]\n): CreatableModuleRegistry => {\n sources.map((source) =>\n Object.entries(source).map(([schema, factories]) => {\n if (factories) {\n const existingFactories = target[schema]\n target[schema] = existingFactories ? (target[schema] = [...existingFactories, ...factories]) : factories\n }\n }),\n )\n return target\n}\n","import { ModuleInstance } from '../instance'\nimport { WithOptionalLabels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\n\nexport type LabeledCreatableModuleFactory<T extends ModuleInstance = ModuleInstance> = CreatableModuleFactory<T> & WithOptionalLabels\n\nexport const hasLabels = (factory: CreatableModuleFactory | LabeledCreatableModuleFactory): factory is LabeledCreatableModuleFactory => {\n return (factory as LabeledCreatableModuleFactory).labels !== undefined\n}\n","import { assertEx } from '@xylabs/assert'\nimport { merge } from '@xylabs/lodash'\nimport { Logger } from '@xylabs/logger'\n\nimport { ModuleInstance } from '../instance'\nimport { Labels, WithOptionalLabels } from '../Labels'\nimport { CreatableModule, CreatableModuleFactory } from './CreatableModule'\n\nexport class ModuleFactory<TModule extends ModuleInstance> implements CreatableModuleFactory<TModule> {\n configSchemas: CreatableModuleFactory<TModule>['configSchemas']\n\n creatableModule: CreatableModule<TModule>\n\n defaultLogger?: Logger | undefined\n\n defaultParams?: Omit<TModule['params'], 'config'> & { config?: Partial<TModule['params']['config']> }\n\n labels?: Labels\n\n constructor(\n creatableModule: CreatableModule<TModule>,\n params?: Omit<TModule['params'], 'config'> & { config?: Partial<TModule['params']['config']> },\n labels: Labels = {},\n ) {\n this.creatableModule = creatableModule\n this.defaultParams = params\n this.configSchemas = creatableModule.configSchemas\n this.labels = Object.assign({}, (creatableModule as WithOptionalLabels).labels ?? {}, labels ?? {})\n }\n\n get configSchema(): string {\n return this.configSchemas[0]\n }\n\n static withParams<T extends ModuleInstance>(\n creatableModule: CreatableModule<T>,\n params?: Omit<T['params'], 'config'> & { config?: T['params']['config'] },\n labels: Labels = {},\n ) {\n return new ModuleFactory(creatableModule, params, labels)\n }\n\n _getRootFunction(funcName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let anyThis = this as any\n while (anyThis.__proto__[funcName]) {\n anyThis = anyThis.__proto__\n }\n return anyThis[funcName]\n }\n\n _noOverride(functionName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const thisFunc = (this as any)[functionName]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const rootFunc = this._getRootFunction(functionName)\n assertEx(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`)\n }\n\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: TModule['params'] | undefined): Promise<T> {\n const factory = this as ModuleFactory<T>\n const schema = factory.creatableModule.configSchema\n const mergedParams: TModule['params'] = merge({}, factory.defaultParams, params, {\n config: merge({}, factory.defaultParams?.config, params?.config, { schema }),\n })\n return factory.creatableModule.create<T>(mergedParams)\n }\n\n factory<T extends ModuleInstance>(this: CreatableModule<T>, _params?: T['params'] | undefined): CreatableModuleFactory<T> {\n throw new Error('Method not implemented.')\n }\n}\n","import { assertEx } from '@xylabs/assert'\n\nimport { ModuleInstance } from '../instance'\nimport { hasAllLabels, Labels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\nimport { CreatableModuleRegistry } from './CreatableModuleRegistry'\nimport { hasLabels, LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\n/**\n * A class which encapsulates the Service Locator Pattern for Module Factories\n */\nexport class ModuleFactoryLocator {\n constructor(protected readonly _registry: CreatableModuleRegistry = {}) {}\n\n /**\n * The current registry for the module factory\n */\n get registry(): Readonly<CreatableModuleRegistry> {\n return this._registry\n }\n\n /**\n * Locates a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or throws if one is not found\n */\n locate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory {\n return assertEx(this.tryLocate(schema, labels), () => {\n const configString = `config schema [${schema}]`\n const labelsString = labels ? ` & labels [${JSON.stringify(labels)}]` : ''\n return `No module factory for the supplied ${configString}${labelsString} registered`\n })\n }\n\n /**\n * Registers a single module factory (with optional tags) with the locator\n * @param additional Additional module factories to register\n */\n register<TModule extends ModuleInstance>(mod: CreatableModuleFactory<TModule>, labels?: Labels): this {\n mod.configSchemas.map((schema) => {\n const existingFactories = this._registry[schema]\n const factory: LabeledCreatableModuleFactory<TModule> = {\n // Destructure instance properties\n ...mod,\n // Copy static methods\n create: mod.create.bind(mod) as LabeledCreatableModuleFactory<TModule>['create'],\n // Merge module & supplied labels\n labels: Object.assign({}, (mod as LabeledCreatableModuleFactory).labels ?? {}, labels ?? {}),\n }\n this._registry[schema] = existingFactories ? [...existingFactories, factory] : [factory]\n })\n return this\n }\n\n /**\n * Registers multiple module factories with the locator\n * @param additional Additional module factories to register\n */\n registerMany(additional: CreatableModuleRegistry): this {\n Object.entries(additional).map(([schema, factories]) => {\n if (factories) {\n const existingFactories = this._registry[schema]\n this._registry[schema] = existingFactories ? [...existingFactories, ...factories] : factories\n }\n })\n return this\n }\n\n /**\n * Tries to locate a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or undefined\n */\n tryLocate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory | undefined {\n // If labels were provided\n return labels\n ? // Find the first factory that has labels and has all the labels provided\n this._registry[schema]?.filter(hasLabels).find((factory) => hasAllLabels(factory?.labels, labels))\n : // Otherwise, return the first factory\n this._registry[schema]?.[0]\n }\n}\n","/**\n * Object used to represent labels identifying a resource.\n */\nexport interface Labels {\n [key: string]: string | undefined\n}\n\n/**\n * Interface for objects that have labels.\n */\nexport interface WithLabels<T extends Labels = Labels> {\n labels: T\n}\n\n/**\n * Interface for objects that have labels.\n */\nexport interface WithOptionalLabels<T extends Labels = Labels> {\n labels?: T\n}\n\n/**\n * Returns true if the source object has all the labels from the required set\n * @param source Source object to check against\n * @param required Set of labels to check for in source\n * @returns True of the source object has all the labels from the required set\n */\nexport const hasAllLabels = (source?: Labels, required?: Labels): boolean => {\n if (!required) return true\n return Object.entries(required).every(([key, value]) => {\n // eslint-disable-next-line no-prototype-builtins\n return source?.hasOwnProperty(key as keyof typeof source) && source?.[key as keyof typeof source] === value\n })\n}\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModuleInstance } from './isModuleInstance'\n\nexport const asModuleInstance = AsObjectFactory.create(isModuleInstance)\n","import { IsObjectFactory, ObjectTypeShape, TypeCheck } from '@xyo-network/object'\n\nimport { isModule } from '../module'\nimport { ModuleInstance } from './ModuleInstance'\n\nexport const requiredModuleInstanceFunctions: ObjectTypeShape = {\n describe: 'function',\n discover: 'function',\n manifest: 'function',\n moduleAddress: 'function',\n}\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsObjectFactory<ModuleInstance>()\n\nexport const isModuleInstance: TypeCheck<ModuleInstance> = factory.create(requiredModuleInstanceFunctions, [isModule])\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModule } from './isModule'\n\nexport const asModule = AsObjectFactory.create(isModule)\n","import { Payload } from '@xyo-network/payload-model'\n\nimport { ModuleDescription } from '../../ModuleDescription'\n\nexport const ModuleDescriptionSchema = 'network.xyo.module.description'\nexport type ModuleDescriptionSchema = typeof ModuleDescriptionSchema\n\nexport type ModuleDescriptionPayload = Payload<ModuleDescription, ModuleDescriptionSchema>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\nexport const ModuleDescribeQuerySchema: ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\n\nexport type ModuleDescribeQuery = Query<{\n schema: ModuleDescribeQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\nexport const ModuleDiscoverQuerySchema: ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\n\nexport type ModuleDiscoverQuery = Query<{\n maxDepth?: number\n schema: ModuleDiscoverQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\nexport const ModuleManifestQuerySchema: ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\n\nexport type ModuleManifestQuery = Query<{\n maxDepth?: number\n schema: ModuleManifestQuerySchema\n}>\n","import { AddressSchema } from '@xyo-network/address-payload-plugin'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport const AddressPreviousHashSchema = `${AddressSchema}.hash.previous`\nexport type AddressPreviousHashSchema = typeof AddressPreviousHashSchema\n\nexport type AddressPreviousHashPayload = Payload<{\n address: string\n previousHash?: string\n schema: AddressPreviousHashSchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleAddressQuerySchema = 'network.xyo.query.module.address'\nexport const ModuleAddressQuerySchema: ModuleAddressQuerySchema = 'network.xyo.query.module.address'\n\nexport type ModuleAddressQuery = Query<{\n schema: ModuleAddressQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\nexport const ModuleSubscribeQuerySchema: ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\n\nexport interface ModuleSubscribeFilter {\n /** @field if specified, at least one of the schemas must be present in the boundwtness to generate a notification */\n schema?: string[]\n}\n\n//requests notification when a boundwitness is added to the modules chain that meets the filter criteria\nexport type ModuleSubscribeQuery = Query<{\n /** @field The address that will receive notifications */\n address: string\n /** @field A subscribe with a null for filter is an unsubscribe */\n filter?: ModuleSubscribeFilter | null\n /** @field The maximum events queued per send [may increase frequency] */\n maxQueue?: number\n schema: ModuleSubscribeQuerySchema\n}>\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModuleObject } from './isModuleObject'\n\nexport const asModuleObject = AsObjectFactory.create(isModuleObject)\n","import { IsObjectFactory, ObjectTypeShape } from '@xyo-network/object'\n\nimport { Module } from './Module'\n\nexport const requiredModuleShape: ObjectTypeShape = {\n address: 'string',\n config: 'object',\n params: 'object',\n queries: 'array',\n query: 'function',\n queryable: 'function',\n}\n\nconst factory = new IsObjectFactory<Module>()\n\nexport const isModuleObject = factory.create(requiredModuleShape)\n","import { AnyObject, EmptyObject, TypeCheck } from '@xyo-network/object'\n\nimport { asModuleObject } from './asModuleObject'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport type ModuleTypeCheck<T extends Module = Module> = TypeCheck<T>\n\nexport class IsModuleFactory<T extends Module = Module> {\n create(expectedQueries?: string[], additionalChecks?: TypeCheck<AnyObject | EmptyObject>[]): ModuleTypeCheck<T> {\n return (obj: unknown, config): obj is T => {\n const module = asModuleObject(obj)\n const result =\n isModuleObject(module, config) &&\n (expectedQueries?.reduce((prev, query) => prev && module.queries.includes(query), true) ?? true) &&\n //perform additional checks\n (additionalChecks?.reduce((prev, check) => prev && check(obj, config), true) ?? true)\n return result\n }\n }\n}\n","import { TypeCheck } from '@xyo-network/object'\n\nimport { ModuleDiscoverQuerySchema } from '../Queries'\nimport { IsModuleFactory } from './IsModuleFactory'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport const requiredModuleQueries: string[] = [\n /* We need to update this once live module conform */\n //ModuleDescribeQuerySchema,\n //ModuleAddressQuerySchema,\n ModuleDiscoverQuerySchema,\n //ModuleManifestQuerySchema,\n //ModuleSubscribeQuerySchema,\n]\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsModuleFactory<Module>()\n\nexport const isModule: TypeCheck<Module> = factory.create(requiredModuleQueries, [isModuleObject])\n","import { Promisable } from '@xylabs/promise'\nimport { IsObjectFactory, TypeCheck } from '@xyo-network/object'\n\nimport { ModuleEventData } from '../EventsModels'\nimport { Module, ModuleQueryFunctions } from '../module'\nimport { ModuleParams } from '../ModuleParams'\n\nexport interface ResolveFunctions {\n resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter<T>, options?: ModuleFilterOptions<T>): Promisable<T[]>\n resolve<T extends ModuleInstance = ModuleInstance>(nameOrAddress: string, options?: ModuleFilterOptions<T>): Promisable<T | undefined>\n resolve<T extends ModuleInstance = ModuleInstance>(\n nameOrAddressOrFilter?: ModuleFilter<T> | string,\n options?: ModuleFilterOptions<T>,\n ): Promisable<T | T[] | undefined>\n}\n\nexport interface ModuleResolver extends ResolveFunctions {\n addResolver: (resolver: ModuleResolver) => this\n isModuleResolver: boolean\n removeResolver: (resolver: ModuleResolver) => this\n}\n\nexport type ModuleInstance<TParams extends ModuleParams = ModuleParams, TEventData extends ModuleEventData = ModuleEventData> = Module<\n TParams,\n TEventData\n> &\n ResolveFunctions &\n ModuleQueryFunctions & {\n /* The resolver is a 'down' resolver. It can resolve the module or any children (if it is a node for example), that are in the module*/\n readonly downResolver: Omit<ModuleResolver, 'resolve'>\n\n /* The resolver is a 'up' resolver. It can resolve the parent or any children of the parent*/\n /* This is set by a NodeModule when attaching to the module */\n readonly upResolver: Omit<ModuleResolver, 'resolve'>\n }\n\nexport type InstanceTypeCheck<T extends ModuleInstance = ModuleInstance> = TypeCheck<T>\n\nexport class IsInstanceFactory<T extends ModuleInstance = ModuleInstance> extends IsObjectFactory<T> {}\n\nexport interface ModuleFilterOptions<T extends ModuleInstance = ModuleInstance> {\n direction?: 'up' | 'down' | 'all'\n identity?: InstanceTypeCheck<T>\n maxDepth?: number\n visibility?: 'public' | 'private' | 'all'\n}\n\nexport interface AddressModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n address: string[]\n}\n\nexport interface NameModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n name: string[]\n}\n\nexport interface QueryModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n query: string[][]\n}\n\nexport type AnyModuleFilter<T extends ModuleInstance = ModuleInstance> = Partial<AddressModuleFilter<T>> &\n Partial<NameModuleFilter<T>> &\n Partial<QueryModuleFilter<T>>\n\nexport type ModuleFilter<T extends ModuleInstance = ModuleInstance> =\n | ModuleFilterOptions<T>\n | AddressModuleFilter<T>\n | NameModuleFilter<T>\n | QueryModuleFilter<T>\n","import { Module } from '../module'\n\n/**\n * Used to filter duplicates from an array of modules\n * @example: modulesArray.filter(duplicateModules)\n * @param value Current Module\n * @param index Current Module's index\n * @param array Module Array\n * @returns True if the Module's address is the first occurrence of\n * that address in the array, false otherwise\n */\nexport const duplicateModules = (value: Module, index: number, array: Module[]): value is Module => {\n return array.findIndex((v) => v.address === value.address) === index\n}\n","// Inspired by https://stackoverflow.com/a/49079549/2803259\n\nimport { every, isArray, isBoolean, isNull, isNumber, isPlainObject, isString, isUndefined, overSome } from '@xylabs/lodash'\n\nconst JSONPrimitiveChecks = [isUndefined, isNull, isBoolean, isNumber, isString]\nconst JSONComplexChecks = [isPlainObject, isArray]\n\nexport const serializable = (field: unknown, depth?: number): boolean | null => {\n let depthExceeded = false\n const decrementDepth = () => (depth ? depth-- : undefined)\n\n const recursiveSerializable = (field: unknown) => {\n if (depth !== undefined && depth < 1) {\n depthExceeded = true\n return false\n }\n\n // decrement during every recursion\n decrementDepth()\n\n const nestedSerializable = (field: unknown): boolean => overSome(JSONComplexChecks)(field) && every(field as object, recursiveSerializable)\n\n return overSome([...JSONPrimitiveChecks, nestedSerializable])(field)\n }\n\n const valid = recursiveSerializable(field)\n\n return depthExceeded ? null : valid\n}\n\nexport const serializableField = (field: unknown) => {\n return overSome([...JSONPrimitiveChecks, ...JSONComplexChecks])(field)\n}\n","import { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nexport interface StateDictionary {\n [key: string]: string | number | undefined\n}\nexport interface State<T extends StateDictionary = StateDictionary> {\n state: T\n}\n\nexport const ModuleStateSchema = 'network.xyo.module.state' as const\nexport type ModuleStateSchema = typeof ModuleStateSchema\n\nexport type ModuleState<T extends StateDictionary = StateDictionary> = Payload<State<T>, ModuleStateSchema>\n\nexport const isModuleState = <T extends StateDictionary = StateDictionary>(payload?: Payload | null): payload is ModuleState<T> => {\n return isPayloadOfSchemaType<ModuleState<T>>(ModuleStateSchema)(payload)\n}\n","import { TypeCheck } from '@xyo-network/object'\n\nimport { isModuleInstance } from './instance'\nimport { isModule } from './module'\n\nexport const WithFactory = {\n create: <T extends object>(typeCheck: TypeCheck<T>) => {\n return <R>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n module: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n closure: (module: T) => R,\n ): R | undefined => {\n return typeCheck(module) ? closure(module) : undefined\n }\n },\n}\n\nexport const withModule = WithFactory.create(isModule)\nexport const withModuleInstance = WithFactory.create(isModuleInstance)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,qBAAyC;;;ACkB/C,SAAS,kBAAmE;AACjF,SAAO,CAAqC,gBAAmB;AAC7D;AAAA,EACF;AACF;;;ACrBO,IAAM,4BAA4B,CAAC,SAAuF;AAC/H,SAAO,OAAO,QAAQ,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQA,QAAO,MAAM;AAClE,aAAS,MAAM,IAAI,MAAM,QAAQA,QAAO,IAAIA,WAAU,CAACA,QAAO;AAC9D,WAAO;AAAA,EACT,GAAG,CAAC,CAA4B;AAClC;AAEO,IAAM,gCAAgC,CAC3C,SAAkC,CAAC,M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M,EAAE,YAAY,MAAM,OAAO,MAAM;AACjE;;;ACXA,IAAAC,iBAA4G;AAE5G,IAAM,sBAAsB,CAAC,4BAAa,uBAAQ,0BAAW,yBAAU,uBAAQ;AAC/E,IAAM,oBAAoB,CAAC,8BAAe,sBAAO;AAE1C,IAAM,eAAe,CAAC,OAAgB,UAAmC;AAC9E,MAAI,gBAAgB;AACpB,QAAM,iBAAiB,MAAO,QAAQ,UAAU;AAEhD,QAAM,wBAAwB,CAACC,WAAmB;AAChD,QAAI,UAAU,UAAa,QAAQ,GAAG;AACpC,sBAAgB;AAChB,aAAO;AAAA,IACT;AAGA,mBAAe;AAEf,UAAM,qBAAqB,CAACA,eAA4B,yBAAS,iBAAiB,EAAEA,MAAK,SAAK,sBAAMA,QAAiB,qBAAqB;AAE1I,eAAO,yBAAS,CAAC,GAAG,qBAAqB,kBAAkB,CAAC,EAAEA,MAAK;AAAA,EACrE;AAEA,QAAM,QAAQ,sBAAsB,KAAK;AAEzC,SAAO,gBAAgB,OAAO;AAChC;AAEO,IAAM,oBAAoB,CAAC,UAAmB;AACnD,aAAO,yBAAS,CAAC,GAAG,qBAAqB,GAAG,iBAAiB,CAAC,EAAE,KAAK;AACvE;;;AChCA,2BAA+C;AASxC,IAAM,oBAAoB;AAK1B,IAAM,gBAAgB,CAA8C,YAAwD;AACjI,aAAO,4CAAsC,iBAAiB,EAAE,OAAO;AACzE;;;ACXO,IAAM,cAAc;AAAA,EACzB,QAAQ,CAAmB,cAA4B;AACrD,WAAO,CAELC,SAEA,YACkB;AAClB,aAAO,UAAUA,OAAM,IAAI,QAAQA,OAAM,IAAI;AAAA,IAC/C;AAAA,EACF;AACF;AAEO,IAAM,aAAa,YAAY,OAAO,QAAQ;AAC9C,IAAM,qBAAqB,YAAY,OAAO,gBAAgB;","names":["factory","factory","creatableModule","factory","import_assert","factory","import_object","import_object","import_object","import_object","module","factory","factory","import_object","import_lodash","field","module"]}
@@ -1,62 +1,3 @@
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
- AddressPreviousHashSchema: () => AddressPreviousHashSchema,
24
- IsInstanceFactory: () => IsInstanceFactory,
25
- IsModuleFactory: () => IsModuleFactory,
26
- ModuleAddressQuerySchema: () => ModuleAddressQuerySchema,
27
- ModuleConfigSchema: () => ModuleConfigSchema,
28
- ModuleDescribeQuerySchema: () => ModuleDescribeQuerySchema,
29
- ModuleDescriptionSchema: () => ModuleDescriptionSchema,
30
- ModuleDiscoverQuerySchema: () => ModuleDiscoverQuerySchema,
31
- ModuleFactory: () => ModuleFactory,
32
- ModuleFactoryLocator: () => ModuleFactoryLocator,
33
- ModuleManifestQuerySchema: () => ModuleManifestQuerySchema,
34
- ModuleStateSchema: () => ModuleStateSchema,
35
- ModuleSubscribeQuerySchema: () => ModuleSubscribeQuerySchema,
36
- WithFactory: () => WithFactory,
37
- asModule: () => asModule,
38
- asModuleInstance: () => asModuleInstance,
39
- asModuleObject: () => asModuleObject,
40
- assignCreatableModuleRegistry: () => assignCreatableModuleRegistry,
41
- creatableModule: () => creatableModule,
42
- duplicateModules: () => duplicateModules,
43
- hasAllLabels: () => hasAllLabels,
44
- hasLabels: () => hasLabels,
45
- isModule: () => isModule,
46
- isModuleInstance: () => isModuleInstance,
47
- isModuleObject: () => isModuleObject,
48
- isModuleState: () => isModuleState,
49
- requiredModuleInstanceFunctions: () => requiredModuleInstanceFunctions,
50
- requiredModuleQueries: () => requiredModuleQueries,
51
- requiredModuleShape: () => requiredModuleShape,
52
- serializable: () => serializable,
53
- serializableField: () => serializableField,
54
- toCreatableModuleRegistry: () => toCreatableModuleRegistry,
55
- withModule: () => withModule,
56
- withModuleInstance: () => withModuleInstance
57
- });
58
- module.exports = __toCommonJS(src_exports);
59
-
60
1
  // src/Config.ts
61
2
  var ModuleConfigSchema = "network.xyo.module.config";
62
3
 
@@ -92,8 +33,8 @@ var hasLabels = (factory4) => {
92
33
  };
93
34
 
94
35
  // src/CreatableModule/ModuleFactory.ts
95
- var import_assert = require("@xylabs/assert");
96
- var import_lodash = require("@xylabs/lodash");
36
+ import { assertEx } from "@xylabs/assert";
37
+ import { merge } from "@xylabs/lodash";
97
38
  var ModuleFactory = class _ModuleFactory {
98
39
  configSchemas;
99
40
  creatableModule;
@@ -122,14 +63,14 @@ var ModuleFactory = class _ModuleFactory {
122
63
  _noOverride(functionName) {
123
64
  const thisFunc = this[functionName];
124
65
  const rootFunc = this._getRootFunction(functionName);
125
- (0, import_assert.assertEx)(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`);
66
+ assertEx(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`);
126
67
  }
127
68
  create(params) {
128
69
  var _a;
129
70
  const factory4 = this;
130
71
  const schema = factory4.creatableModule.configSchema;
131
- const mergedParams = (0, import_lodash.merge)({}, factory4.defaultParams, params, {
132
- config: (0, import_lodash.merge)({}, (_a = factory4.defaultParams) == null ? void 0 : _a.config, params == null ? void 0 : params.config, { schema })
72
+ const mergedParams = merge({}, factory4.defaultParams, params, {
73
+ config: merge({}, (_a = factory4.defaultParams) == null ? void 0 : _a.config, params == null ? void 0 : params.config, { schema })
133
74
  });
134
75
  return factory4.creatableModule.create(mergedParams);
135
76
  }
@@ -139,7 +80,7 @@ var ModuleFactory = class _ModuleFactory {
139
80
  };
140
81
 
141
82
  // src/CreatableModule/ModuleFactoryLocator.ts
142
- var import_assert2 = require("@xylabs/assert");
83
+ import { assertEx as assertEx2 } from "@xylabs/assert";
143
84
 
144
85
  // src/Labels/Labels.ts
145
86
  var hasAllLabels = (source, required) => {
@@ -168,7 +109,7 @@ var ModuleFactoryLocator = class {
168
109
  * @returns A module factory that matches the supplied schema and labels or throws if one is not found
169
110
  */
170
111
  locate(schema, labels) {
171
- return (0, import_assert2.assertEx)(this.tryLocate(schema, labels), () => {
112
+ return assertEx2(this.tryLocate(schema, labels), () => {
172
113
  const configString = `config schema [${schema}]`;
173
114
  const labelsString = labels ? ` & labels [${JSON.stringify(labels)}]` : "";
174
115
  return `No module factory for the supplied ${configString}${labelsString} registered`;
@@ -225,13 +166,13 @@ var ModuleFactoryLocator = class {
225
166
  };
226
167
 
227
168
  // src/instance/asModuleInstance.ts
228
- var import_object5 = require("@xyo-network/object");
169
+ import { AsObjectFactory as AsObjectFactory3 } from "@xyo-network/object";
229
170
 
230
171
  // src/instance/isModuleInstance.ts
231
- var import_object4 = require("@xyo-network/object");
172
+ import { IsObjectFactory as IsObjectFactory2 } from "@xyo-network/object";
232
173
 
233
174
  // src/module/asModule.ts
234
- var import_object3 = require("@xyo-network/object");
175
+ import { AsObjectFactory as AsObjectFactory2 } from "@xyo-network/object";
235
176
 
236
177
  // src/Queries/Describe/Payload.ts
237
178
  var ModuleDescriptionSchema = "network.xyo.module.description";
@@ -246,8 +187,8 @@ var ModuleDiscoverQuerySchema = "network.xyo.query.module.discover";
246
187
  var ModuleManifestQuerySchema = "network.xyo.query.module.manifest";
247
188
 
248
189
  // src/Queries/ModuleAddress/Payload.ts
249
- var import_address_payload_plugin = require("@xyo-network/address-payload-plugin");
250
- var AddressPreviousHashSchema = `${import_address_payload_plugin.AddressSchema}.hash.previous`;
190
+ import { AddressSchema } from "@xyo-network/address-payload-plugin";
191
+ var AddressPreviousHashSchema = `${AddressSchema}.hash.previous`;
251
192
 
252
193
  // src/Queries/ModuleAddress/Query.ts
253
194
  var ModuleAddressQuerySchema = "network.xyo.query.module.address";
@@ -256,10 +197,10 @@ var ModuleAddressQuerySchema = "network.xyo.query.module.address";
256
197
  var ModuleSubscribeQuerySchema = "network.xyo.query.module.subscribe";
257
198
 
258
199
  // src/module/asModuleObject.ts
259
- var import_object2 = require("@xyo-network/object");
200
+ import { AsObjectFactory } from "@xyo-network/object";
260
201
 
261
202
  // src/module/isModuleObject.ts
262
- var import_object = require("@xyo-network/object");
203
+ import { IsObjectFactory } from "@xyo-network/object";
263
204
  var requiredModuleShape = {
264
205
  address: "string",
265
206
  config: "object",
@@ -268,18 +209,18 @@ var requiredModuleShape = {
268
209
  query: "function",
269
210
  queryable: "function"
270
211
  };
271
- var factory = new import_object.IsObjectFactory();
212
+ var factory = new IsObjectFactory();
272
213
  var isModuleObject = factory.create(requiredModuleShape);
273
214
 
274
215
  // src/module/asModuleObject.ts
275
- var asModuleObject = import_object2.AsObjectFactory.create(isModuleObject);
216
+ var asModuleObject = AsObjectFactory.create(isModuleObject);
276
217
 
277
218
  // src/module/IsModuleFactory.ts
278
219
  var IsModuleFactory = class {
279
220
  create(expectedQueries, additionalChecks) {
280
221
  return (obj, config) => {
281
- const module2 = asModuleObject(obj);
282
- const result = isModuleObject(module2, config) && ((expectedQueries == null ? void 0 : expectedQueries.reduce((prev, query) => prev && module2.queries.includes(query), true)) ?? true) && //perform additional checks
222
+ const module = asModuleObject(obj);
223
+ const result = isModuleObject(module, config) && ((expectedQueries == null ? void 0 : expectedQueries.reduce((prev, query) => prev && module.queries.includes(query), true)) ?? true) && //perform additional checks
283
224
  ((additionalChecks == null ? void 0 : additionalChecks.reduce((prev, check) => prev && check(obj, config), true)) ?? true);
284
225
  return result;
285
226
  };
@@ -299,7 +240,7 @@ var factory2 = new IsModuleFactory();
299
240
  var isModule = factory2.create(requiredModuleQueries, [isModuleObject]);
300
241
 
301
242
  // src/module/asModule.ts
302
- var asModule = import_object3.AsObjectFactory.create(isModule);
243
+ var asModule = AsObjectFactory2.create(isModule);
303
244
 
304
245
  // src/instance/isModuleInstance.ts
305
246
  var requiredModuleInstanceFunctions = {
@@ -308,15 +249,15 @@ var requiredModuleInstanceFunctions = {
308
249
  manifest: "function",
309
250
  moduleAddress: "function"
310
251
  };
311
- var factory3 = new import_object4.IsObjectFactory();
252
+ var factory3 = new IsObjectFactory2();
312
253
  var isModuleInstance = factory3.create(requiredModuleInstanceFunctions, [isModule]);
313
254
 
314
255
  // src/instance/asModuleInstance.ts
315
- var asModuleInstance = import_object5.AsObjectFactory.create(isModuleInstance);
256
+ var asModuleInstance = AsObjectFactory3.create(isModuleInstance);
316
257
 
317
258
  // src/instance/ModuleInstance.ts
318
- var import_object6 = require("@xyo-network/object");
319
- var IsInstanceFactory = class extends import_object6.IsObjectFactory {
259
+ import { IsObjectFactory as IsObjectFactory3 } from "@xyo-network/object";
260
+ var IsInstanceFactory = class extends IsObjectFactory3 {
320
261
  };
321
262
 
322
263
  // src/lib/duplicateModules.ts
@@ -325,9 +266,9 @@ var duplicateModules = (value, index, array) => {
325
266
  };
326
267
 
327
268
  // src/lib/serializable.ts
328
- var import_lodash2 = require("@xylabs/lodash");
329
- var JSONPrimitiveChecks = [import_lodash2.isUndefined, import_lodash2.isNull, import_lodash2.isBoolean, import_lodash2.isNumber, import_lodash2.isString];
330
- var JSONComplexChecks = [import_lodash2.isPlainObject, import_lodash2.isArray];
269
+ import { every, isArray, isBoolean, isNull, isNumber, isPlainObject, isString, isUndefined, overSome } from "@xylabs/lodash";
270
+ var JSONPrimitiveChecks = [isUndefined, isNull, isBoolean, isNumber, isString];
271
+ var JSONComplexChecks = [isPlainObject, isArray];
331
272
  var serializable = (field, depth) => {
332
273
  let depthExceeded = false;
333
274
  const decrementDepth = () => depth ? depth-- : void 0;
@@ -337,35 +278,34 @@ var serializable = (field, depth) => {
337
278
  return false;
338
279
  }
339
280
  decrementDepth();
340
- const nestedSerializable = (field3) => (0, import_lodash2.overSome)(JSONComplexChecks)(field3) && (0, import_lodash2.every)(field3, recursiveSerializable);
341
- return (0, import_lodash2.overSome)([...JSONPrimitiveChecks, nestedSerializable])(field2);
281
+ const nestedSerializable = (field3) => overSome(JSONComplexChecks)(field3) && every(field3, recursiveSerializable);
282
+ return overSome([...JSONPrimitiveChecks, nestedSerializable])(field2);
342
283
  };
343
284
  const valid = recursiveSerializable(field);
344
285
  return depthExceeded ? null : valid;
345
286
  };
346
287
  var serializableField = (field) => {
347
- return (0, import_lodash2.overSome)([...JSONPrimitiveChecks, ...JSONComplexChecks])(field);
288
+ return overSome([...JSONPrimitiveChecks, ...JSONComplexChecks])(field);
348
289
  };
349
290
 
350
291
  // src/Payload/ModuleState.ts
351
- var import_payload_model = require("@xyo-network/payload-model");
292
+ import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
352
293
  var ModuleStateSchema = "network.xyo.module.state";
353
294
  var isModuleState = (payload) => {
354
- return (0, import_payload_model.isPayloadOfSchemaType)(ModuleStateSchema)(payload);
295
+ return isPayloadOfSchemaType(ModuleStateSchema)(payload);
355
296
  };
356
297
 
357
298
  // src/withModule.ts
358
299
  var WithFactory = {
359
300
  create: (typeCheck) => {
360
- return (module2, closure) => {
361
- return typeCheck(module2) ? closure(module2) : void 0;
301
+ return (module, closure) => {
302
+ return typeCheck(module) ? closure(module) : void 0;
362
303
  };
363
304
  }
364
305
  };
365
306
  var withModule = WithFactory.create(isModule);
366
307
  var withModuleInstance = WithFactory.create(isModuleInstance);
367
- // Annotate the CommonJS export names for ESM import in node:
368
- 0 && (module.exports = {
308
+ export {
369
309
  AddressPreviousHashSchema,
370
310
  IsInstanceFactory,
371
311
  IsModuleFactory,
@@ -400,5 +340,5 @@ var withModuleInstance = WithFactory.create(isModuleInstance);
400
340
  toCreatableModuleRegistry,
401
341
  withModule,
402
342
  withModuleInstance
403
- });
343
+ };
404
344
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/Config.ts","../../src/CreatableModule/CreatableModule.ts","../../src/CreatableModule/CreatableModuleRegistry.ts","../../src/CreatableModule/LabeledCreatableModuleFactory.ts","../../src/CreatableModule/ModuleFactory.ts","../../src/CreatableModule/ModuleFactoryLocator.ts","../../src/Labels/Labels.ts","../../src/instance/asModuleInstance.ts","../../src/instance/isModuleInstance.ts","../../src/module/asModule.ts","../../src/Queries/Describe/Payload.ts","../../src/Queries/Describe/Query.ts","../../src/Queries/Discover.ts","../../src/Queries/Manifest.ts","../../src/Queries/ModuleAddress/Payload.ts","../../src/Queries/ModuleAddress/Query.ts","../../src/Queries/Subscribe.ts","../../src/module/asModuleObject.ts","../../src/module/isModuleObject.ts","../../src/module/IsModuleFactory.ts","../../src/module/isModule.ts","../../src/instance/ModuleInstance.ts","../../src/lib/duplicateModules.ts","../../src/lib/serializable.ts","../../src/Payload/ModuleState.ts","../../src/withModule.ts"],"sourcesContent":["export * from './Config'\nexport * from './CreatableModule'\nexport * from './EventsModels'\nexport * from './instance'\nexport * from './Labels'\nexport * from './lib'\nexport * from './module'\nexport * from './ModuleDescription'\nexport * from './ModuleParams'\nexport * from './ModuleQueryHandlerResult'\nexport * from './ModuleQueryResult'\nexport * from './Payload'\nexport * from './Queries'\nexport * from './withModule'\n","import { Address } from '@xylabs/hex'\nimport { EmptyObject, WithAdditional } from '@xyo-network/object'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { Labels } from './Labels'\n\nexport type ModuleConfigSchema = 'network.xyo.module.config'\nexport const ModuleConfigSchema: ModuleConfigSchema = 'network.xyo.module.config'\n\nexport type CosigningAddressSet = string[]\nexport type SchemaString = string\nexport type ModuleName = string\nexport type NameOrAddress = Address | ModuleName\n\n/** @deprecated */\nexport interface IndividualArchivistConfig {\n readonly commit?: NameOrAddress\n readonly read?: NameOrAddress\n readonly write?: NameOrAddress\n}\n\n/** @deprecated */\nexport type ArchivistModuleConfig = NameOrAddress | IndividualArchivistConfig\n\nexport interface ArchivingModuleConfig {\n readonly archiving?: {\n readonly archivists?: NameOrAddress[]\n }\n}\n\nexport type ModuleConfig<\n TConfig extends Payload | void = void,\n TAdditionalParams extends EmptyObject | void = void,\n TSchema extends Schema | void = void,\n> = Payload<\n WithAdditional<\n WithAdditional<\n {\n /** @field The path to use when creating the account */\n accountDerivationPath?: string\n\n /** @field The name/address of the Archivist to use for this module */\n readonly archivist?: ArchivistModuleConfig\n\n /**\n * @field The labels used for this module. If a label is specified, then the\n * ModuleFactoryLocator will attempt to find a ModuleFactory with the corresponding\n * labels to construct this module.\n */\n readonly labels?: Labels\n\n /** @field Friendly name of module (not collision resistent). Can be used to resolve module when registered/attached to Node. */\n readonly name?: string\n\n /** @field paging settings for queries */\n readonly paging?: Record<string, { size?: number }>\n\n /** @field The query schemas and allowed/disallowed addresses which are allowed to issue them against the module. If both allowed and disallowed is specified, then disallowed takes priority. */\n readonly security?: {\n /** @field Will the module process queries that have unsigned BoundWitness in query tuples */\n readonly allowAnonymous?: boolean\n\n /** @field If schema in record, then only these address sets can access query */\n readonly allowed?: Record<SchemaString, (Address | CosigningAddressSet)[]>\n\n /** @field If schema in record, then anyone except these addresses can access query */\n readonly disallowed?: Record<SchemaString, Address[]>\n }\n\n /** @field sign every query */\n readonly sign?: boolean\n\n /** @field Store the queries made to the module in an archivist if possible */\n readonly storeQueries?: boolean\n\n /** @field add a timestamp payload to every query */\n readonly timestamp?: boolean\n } & ArchivingModuleConfig,\n TConfig\n >,\n TAdditionalParams\n >,\n TSchema extends Schema ? TSchema : TConfig extends Payload ? TConfig['schema'] : ModuleConfigSchema\n>\n\nexport type AnyConfigSchema<TConfig extends Omit<ModuleConfig, 'schema'> & { schema: string } = Omit<ModuleConfig, 'schema'> & { schema: string }> =\n ModuleConfig<\n {\n schema: string\n },\n Omit<TConfig, 'schema'>\n >\n\nexport type OptionalConfigSchema<TConfig extends AnyConfigSchema<ModuleConfig> = AnyConfigSchema<ModuleConfig>> = Omit<TConfig, 'schema'> & {\n schema?: TConfig['schema']\n}\n\nexport type AnyModuleConfig = AnyConfigSchema<ModuleConfig>\n","import { Logger } from '@xylabs/logger'\nimport { AccountInstance } from '@xyo-network/account-model'\n\nimport { ModuleInstance } from '../instance'\n\nexport type CreatableModuleFactory<T extends ModuleInstance = ModuleInstance> = Omit<Omit<CreatableModule<T>, 'new'>, 'create'> & {\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: T['params']): Promise<T>\n}\n\nexport interface CreatableModule<T extends ModuleInstance = ModuleInstance> {\n configSchema: string\n configSchemas: string[]\n defaultLogger?: Logger\n new (privateConstructorKey: string, params: T['params'], account: AccountInstance): T\n _noOverride(functionName: string): void\n create<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): Promise<T>\n factory<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): CreatableModuleFactory<T>\n}\n\n/**\n * Class annotation to be used to decorate Modules which support\n * an asynchronous creation pattern\n * @returns The decorated Module requiring it implement the members\n * of the CreatableModule as statics properties/methods\n */\nexport function creatableModule<TModule extends ModuleInstance = ModuleInstance>() {\n return <U extends CreatableModule<TModule>>(constructor: U) => {\n constructor\n }\n}\n","import { CreatableModuleFactory } from './CreatableModule'\nimport { CreatableModuleDictionary } from './CreatableModuleDictionary'\nimport { LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\nexport interface CreatableModuleRegistry {\n [key: string]: (CreatableModuleFactory | LabeledCreatableModuleFactory)[] | undefined\n}\n\nexport const toCreatableModuleRegistry = (dict: CreatableModuleDictionary | CreatableModuleRegistry): CreatableModuleRegistry => {\n return Object.entries(dict).reduce((registry, [schema, factory]) => {\n registry[schema] = Array.isArray(factory) ? factory : [factory]\n return registry\n }, {} as CreatableModuleRegistry)\n}\n\nexport const assignCreatableModuleRegistry = (\n target: CreatableModuleRegistry = {},\n ...sources: CreatableModuleRegistry[]\n): CreatableModuleRegistry => {\n sources.map((source) =>\n Object.entries(source).map(([schema, factories]) => {\n if (factories) {\n const existingFactories = target[schema]\n target[schema] = existingFactories ? (target[schema] = [...existingFactories, ...factories]) : factories\n }\n }),\n )\n return target\n}\n","import { ModuleInstance } from '../instance'\nimport { WithOptionalLabels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\n\nexport type LabeledCreatableModuleFactory<T extends ModuleInstance = ModuleInstance> = CreatableModuleFactory<T> & WithOptionalLabels\n\nexport const hasLabels = (factory: CreatableModuleFactory | LabeledCreatableModuleFactory): factory is LabeledCreatableModuleFactory => {\n return (factory as LabeledCreatableModuleFactory).labels !== undefined\n}\n","import { assertEx } from '@xylabs/assert'\nimport { merge } from '@xylabs/lodash'\nimport { Logger } from '@xylabs/logger'\n\nimport { ModuleInstance } from '../instance'\nimport { Labels, WithOptionalLabels } from '../Labels'\nimport { CreatableModule, CreatableModuleFactory } from './CreatableModule'\n\nexport class ModuleFactory<TModule extends ModuleInstance> implements CreatableModuleFactory<TModule> {\n configSchemas: CreatableModuleFactory<TModule>['configSchemas']\n\n creatableModule: CreatableModule<TModule>\n\n defaultLogger?: Logger | undefined\n\n defaultParams?: Omit<TModule['params'], 'config'> & { config?: Partial<TModule['params']['config']> }\n\n labels?: Labels\n\n constructor(\n creatableModule: CreatableModule<TModule>,\n params?: Omit<TModule['params'], 'config'> & { config?: Partial<TModule['params']['config']> },\n labels: Labels = {},\n ) {\n this.creatableModule = creatableModule\n this.defaultParams = params\n this.configSchemas = creatableModule.configSchemas\n this.labels = Object.assign({}, (creatableModule as WithOptionalLabels).labels ?? {}, labels ?? {})\n }\n\n get configSchema(): string {\n return this.configSchemas[0]\n }\n\n static withParams<T extends ModuleInstance>(\n creatableModule: CreatableModule<T>,\n params?: Omit<T['params'], 'config'> & { config?: T['params']['config'] },\n labels: Labels = {},\n ) {\n return new ModuleFactory(creatableModule, params, labels)\n }\n\n _getRootFunction(funcName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let anyThis = this as any\n while (anyThis.__proto__[funcName]) {\n anyThis = anyThis.__proto__\n }\n return anyThis[funcName]\n }\n\n _noOverride(functionName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const thisFunc = (this as any)[functionName]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const rootFunc = this._getRootFunction(functionName)\n assertEx(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`)\n }\n\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: TModule['params'] | undefined): Promise<T> {\n const factory = this as ModuleFactory<T>\n const schema = factory.creatableModule.configSchema\n const mergedParams: TModule['params'] = merge({}, factory.defaultParams, params, {\n config: merge({}, factory.defaultParams?.config, params?.config, { schema }),\n })\n return factory.creatableModule.create<T>(mergedParams)\n }\n\n factory<T extends ModuleInstance>(this: CreatableModule<T>, _params?: T['params'] | undefined): CreatableModuleFactory<T> {\n throw new Error('Method not implemented.')\n }\n}\n","import { assertEx } from '@xylabs/assert'\n\nimport { ModuleInstance } from '../instance'\nimport { hasAllLabels, Labels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\nimport { CreatableModuleRegistry } from './CreatableModuleRegistry'\nimport { hasLabels, LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\n/**\n * A class which encapsulates the Service Locator Pattern for Module Factories\n */\nexport class ModuleFactoryLocator {\n constructor(protected readonly _registry: CreatableModuleRegistry = {}) {}\n\n /**\n * The current registry for the module factory\n */\n get registry(): Readonly<CreatableModuleRegistry> {\n return this._registry\n }\n\n /**\n * Locates a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or throws if one is not found\n */\n locate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory {\n return assertEx(this.tryLocate(schema, labels), () => {\n const configString = `config schema [${schema}]`\n const labelsString = labels ? ` & labels [${JSON.stringify(labels)}]` : ''\n return `No module factory for the supplied ${configString}${labelsString} registered`\n })\n }\n\n /**\n * Registers a single module factory (with optional tags) with the locator\n * @param additional Additional module factories to register\n */\n register<TModule extends ModuleInstance>(mod: CreatableModuleFactory<TModule>, labels?: Labels): this {\n mod.configSchemas.map((schema) => {\n const existingFactories = this._registry[schema]\n const factory: LabeledCreatableModuleFactory<TModule> = {\n // Destructure instance properties\n ...mod,\n // Copy static methods\n create: mod.create.bind(mod) as LabeledCreatableModuleFactory<TModule>['create'],\n // Merge module & supplied labels\n labels: Object.assign({}, (mod as LabeledCreatableModuleFactory).labels ?? {}, labels ?? {}),\n }\n this._registry[schema] = existingFactories ? [...existingFactories, factory] : [factory]\n })\n return this\n }\n\n /**\n * Registers multiple module factories with the locator\n * @param additional Additional module factories to register\n */\n registerMany(additional: CreatableModuleRegistry): this {\n Object.entries(additional).map(([schema, factories]) => {\n if (factories) {\n const existingFactories = this._registry[schema]\n this._registry[schema] = existingFactories ? [...existingFactories, ...factories] : factories\n }\n })\n return this\n }\n\n /**\n * Tries to locate a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or undefined\n */\n tryLocate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory | undefined {\n // If labels were provided\n return labels\n ? // Find the first factory that has labels and has all the labels provided\n this._registry[schema]?.filter(hasLabels).find((factory) => hasAllLabels(factory?.labels, labels))\n : // Otherwise, return the first factory\n this._registry[schema]?.[0]\n }\n}\n","/**\n * Object used to represent labels identifying a resource.\n */\nexport interface Labels {\n [key: string]: string | undefined\n}\n\n/**\n * Interface for objects that have labels.\n */\nexport interface WithLabels<T extends Labels = Labels> {\n labels: T\n}\n\n/**\n * Interface for objects that have labels.\n */\nexport interface WithOptionalLabels<T extends Labels = Labels> {\n labels?: T\n}\n\n/**\n * Returns true if the source object has all the labels from the required set\n * @param source Source object to check against\n * @param required Set of labels to check for in source\n * @returns True of the source object has all the labels from the required set\n */\nexport const hasAllLabels = (source?: Labels, required?: Labels): boolean => {\n if (!required) return true\n return Object.entries(required).every(([key, value]) => {\n // eslint-disable-next-line no-prototype-builtins\n return source?.hasOwnProperty(key as keyof typeof source) && source?.[key as keyof typeof source] === value\n })\n}\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModuleInstance } from './isModuleInstance'\n\nexport const asModuleInstance = AsObjectFactory.create(isModuleInstance)\n","import { IsObjectFactory, ObjectTypeShape, TypeCheck } from '@xyo-network/object'\n\nimport { isModule } from '../module'\nimport { ModuleInstance } from './ModuleInstance'\n\nexport const requiredModuleInstanceFunctions: ObjectTypeShape = {\n describe: 'function',\n discover: 'function',\n manifest: 'function',\n moduleAddress: 'function',\n}\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsObjectFactory<ModuleInstance>()\n\nexport const isModuleInstance: TypeCheck<ModuleInstance> = factory.create(requiredModuleInstanceFunctions, [isModule])\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModule } from './isModule'\n\nexport const asModule = AsObjectFactory.create(isModule)\n","import { Payload } from '@xyo-network/payload-model'\n\nimport { ModuleDescription } from '../../ModuleDescription'\n\nexport const ModuleDescriptionSchema = 'network.xyo.module.description'\nexport type ModuleDescriptionSchema = typeof ModuleDescriptionSchema\n\nexport type ModuleDescriptionPayload = Payload<ModuleDescription, ModuleDescriptionSchema>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\nexport const ModuleDescribeQuerySchema: ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\n\nexport type ModuleDescribeQuery = Query<{\n schema: ModuleDescribeQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\nexport const ModuleDiscoverQuerySchema: ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\n\nexport type ModuleDiscoverQuery = Query<{\n maxDepth?: number\n schema: ModuleDiscoverQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\nexport const ModuleManifestQuerySchema: ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\n\nexport type ModuleManifestQuery = Query<{\n maxDepth?: number\n schema: ModuleManifestQuerySchema\n}>\n","import { AddressSchema } from '@xyo-network/address-payload-plugin'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport const AddressPreviousHashSchema = `${AddressSchema}.hash.previous`\nexport type AddressPreviousHashSchema = typeof AddressPreviousHashSchema\n\nexport type AddressPreviousHashPayload = Payload<{\n address: string\n previousHash?: string\n schema: AddressPreviousHashSchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleAddressQuerySchema = 'network.xyo.query.module.address'\nexport const ModuleAddressQuerySchema: ModuleAddressQuerySchema = 'network.xyo.query.module.address'\n\nexport type ModuleAddressQuery = Query<{\n schema: ModuleAddressQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\nexport const ModuleSubscribeQuerySchema: ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\n\nexport interface ModuleSubscribeFilter {\n /** @field if specified, at least one of the schemas must be present in the boundwtness to generate a notification */\n schema?: string[]\n}\n\n//requests notification when a boundwitness is added to the modules chain that meets the filter criteria\nexport type ModuleSubscribeQuery = Query<{\n /** @field The address that will receive notifications */\n address: string\n /** @field A subscribe with a null for filter is an unsubscribe */\n filter?: ModuleSubscribeFilter | null\n /** @field The maximum events queued per send [may increase frequency] */\n maxQueue?: number\n schema: ModuleSubscribeQuerySchema\n}>\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModuleObject } from './isModuleObject'\n\nexport const asModuleObject = AsObjectFactory.create(isModuleObject)\n","import { IsObjectFactory, ObjectTypeShape } from '@xyo-network/object'\n\nimport { Module } from './Module'\n\nexport const requiredModuleShape: ObjectTypeShape = {\n address: 'string',\n config: 'object',\n params: 'object',\n queries: 'array',\n query: 'function',\n queryable: 'function',\n}\n\nconst factory = new IsObjectFactory<Module>()\n\nexport const isModuleObject = factory.create(requiredModuleShape)\n","import { AnyObject, EmptyObject, TypeCheck } from '@xyo-network/object'\n\nimport { asModuleObject } from './asModuleObject'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport type ModuleTypeCheck<T extends Module = Module> = TypeCheck<T>\n\nexport class IsModuleFactory<T extends Module = Module> {\n create(expectedQueries?: string[], additionalChecks?: TypeCheck<AnyObject | EmptyObject>[]): ModuleTypeCheck<T> {\n return (obj: unknown, config): obj is T => {\n const module = asModuleObject(obj)\n const result =\n isModuleObject(module, config) &&\n (expectedQueries?.reduce((prev, query) => prev && module.queries.includes(query), true) ?? true) &&\n //perform additional checks\n (additionalChecks?.reduce((prev, check) => prev && check(obj, config), true) ?? true)\n return result\n }\n }\n}\n","import { TypeCheck } from '@xyo-network/object'\n\nimport { ModuleDiscoverQuerySchema } from '../Queries'\nimport { IsModuleFactory } from './IsModuleFactory'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport const requiredModuleQueries: string[] = [\n /* We need to update this once live module conform */\n //ModuleDescribeQuerySchema,\n //ModuleAddressQuerySchema,\n ModuleDiscoverQuerySchema,\n //ModuleManifestQuerySchema,\n //ModuleSubscribeQuerySchema,\n]\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsModuleFactory<Module>()\n\nexport const isModule: TypeCheck<Module> = factory.create(requiredModuleQueries, [isModuleObject])\n","import { Promisable } from '@xylabs/promise'\nimport { IsObjectFactory, TypeCheck } from '@xyo-network/object'\n\nimport { ModuleEventData } from '../EventsModels'\nimport { Module, ModuleQueryFunctions } from '../module'\nimport { ModuleParams } from '../ModuleParams'\n\nexport interface ResolveFunctions {\n resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter<T>, options?: ModuleFilterOptions<T>): Promisable<T[]>\n resolve<T extends ModuleInstance = ModuleInstance>(nameOrAddress: string, options?: ModuleFilterOptions<T>): Promisable<T | undefined>\n resolve<T extends ModuleInstance = ModuleInstance>(\n nameOrAddressOrFilter?: ModuleFilter<T> | string,\n options?: ModuleFilterOptions<T>,\n ): Promisable<T | T[] | undefined>\n}\n\nexport interface ModuleResolver extends ResolveFunctions {\n addResolver: (resolver: ModuleResolver) => this\n isModuleResolver: boolean\n removeResolver: (resolver: ModuleResolver) => this\n}\n\nexport type ModuleInstance<TParams extends ModuleParams = ModuleParams, TEventData extends ModuleEventData = ModuleEventData> = Module<\n TParams,\n TEventData\n> &\n ResolveFunctions &\n ModuleQueryFunctions & {\n /* The resolver is a 'down' resolver. It can resolve the module or any children (if it is a node for example), that are in the module*/\n readonly downResolver: Omit<ModuleResolver, 'resolve'>\n\n /* The resolver is a 'up' resolver. It can resolve the parent or any children of the parent*/\n /* This is set by a NodeModule when attaching to the module */\n readonly upResolver: Omit<ModuleResolver, 'resolve'>\n }\n\nexport type InstanceTypeCheck<T extends ModuleInstance = ModuleInstance> = TypeCheck<T>\n\nexport class IsInstanceFactory<T extends ModuleInstance = ModuleInstance> extends IsObjectFactory<T> {}\n\nexport interface ModuleFilterOptions<T extends ModuleInstance = ModuleInstance> {\n direction?: 'up' | 'down' | 'all'\n identity?: InstanceTypeCheck<T>\n maxDepth?: number\n visibility?: 'public' | 'private' | 'all'\n}\n\nexport interface AddressModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n address: string[]\n}\n\nexport interface NameModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n name: string[]\n}\n\nexport interface QueryModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n query: string[][]\n}\n\nexport type AnyModuleFilter<T extends ModuleInstance = ModuleInstance> = Partial<AddressModuleFilter<T>> &\n Partial<NameModuleFilter<T>> &\n Partial<QueryModuleFilter<T>>\n\nexport type ModuleFilter<T extends ModuleInstance = ModuleInstance> =\n | ModuleFilterOptions<T>\n | AddressModuleFilter<T>\n | NameModuleFilter<T>\n | QueryModuleFilter<T>\n","import { Module } from '../module'\n\n/**\n * Used to filter duplicates from an array of modules\n * @example: modulesArray.filter(duplicateModules)\n * @param value Current Module\n * @param index Current Module's index\n * @param array Module Array\n * @returns True if the Module's address is the first occurrence of\n * that address in the array, false otherwise\n */\nexport const duplicateModules = (value: Module, index: number, array: Module[]): value is Module => {\n return array.findIndex((v) => v.address === value.address) === index\n}\n","// Inspired by https://stackoverflow.com/a/49079549/2803259\n\nimport { every, isArray, isBoolean, isNull, isNumber, isPlainObject, isString, isUndefined, overSome } from '@xylabs/lodash'\n\nconst JSONPrimitiveChecks = [isUndefined, isNull, isBoolean, isNumber, isString]\nconst JSONComplexChecks = [isPlainObject, isArray]\n\nexport const serializable = (field: unknown, depth?: number): boolean | null => {\n let depthExceeded = false\n const decrementDepth = () => (depth ? depth-- : undefined)\n\n const recursiveSerializable = (field: unknown) => {\n if (depth !== undefined && depth < 1) {\n depthExceeded = true\n return false\n }\n\n // decrement during every recursion\n decrementDepth()\n\n const nestedSerializable = (field: unknown): boolean => overSome(JSONComplexChecks)(field) && every(field as object, recursiveSerializable)\n\n return overSome([...JSONPrimitiveChecks, nestedSerializable])(field)\n }\n\n const valid = recursiveSerializable(field)\n\n return depthExceeded ? null : valid\n}\n\nexport const serializableField = (field: unknown) => {\n return overSome([...JSONPrimitiveChecks, ...JSONComplexChecks])(field)\n}\n","import { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nexport interface StateDictionary {\n [key: string]: string | number | undefined\n}\nexport interface State<T extends StateDictionary = StateDictionary> {\n state: T\n}\n\nexport const ModuleStateSchema = 'network.xyo.module.state' as const\nexport type ModuleStateSchema = typeof ModuleStateSchema\n\nexport type ModuleState<T extends StateDictionary = StateDictionary> = Payload<State<T>, ModuleStateSchema>\n\nexport const isModuleState = <T extends StateDictionary = StateDictionary>(payload?: Payload | null): payload is ModuleState<T> => {\n return isPayloadOfSchemaType<ModuleState<T>>(ModuleStateSchema)(payload)\n}\n","import { TypeCheck } from '@xyo-network/object'\n\nimport { isModuleInstance } from './instance'\nimport { isModule } from './module'\n\nexport const WithFactory = {\n create: <T extends object>(typeCheck: TypeCheck<T>) => {\n return <R>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n module: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n closure: (module: T) => R,\n ): R | undefined => {\n return typeCheck(module) ? closure(module) : undefined\n }\n },\n}\n\nexport const withModule = WithFactory.create(isModule)\nexport const withModuleInstance = WithFactory.create(isModuleInstance)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,qBAAyC;;;ACkB/C,SAAS,kBAAmE;AACjF,SAAO,CAAqC,gBAAmB;AAC7D;AAAA,EACF;AACF;;;ACrBO,IAAM,4BAA4B,CAAC,SAAuF;AAC/H,SAAO,OAAO,QAAQ,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQA,QAAO,MAAM;AAClE,aAAS,MAAM,IAAI,MAAM,QAAQA,QAAO,IAAIA,WAAU,CAACA,QAAO;AAC9D,WAAO;AAAA,EACT,GAAG,CAAC,CAA4B;AAClC;AAEO,IAAM,gCAAgC,CAC3C,SAAkC,CAAC,MAChC,YACyB;AAC5B,UAAQ;AAAA,IAAI,CAAC,WACX,OAAO,QAAQ,MAAM,EAAE,IAAI,CAAC,CAAC,QAAQ,SAAS,MAAM;AAClD,UAAI,WAAW;AACb,cAAM,oBAAoB,OAAO,MAAM;AACvC,eAAO,MAAM,IAAI,oBAAqB,OAAO,MAAM,IAAI,CAAC,GAAG,mBA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AAgB;AACpB,QAAM,iBAAiB,MAAO,QAAQ,UAAU;AAEhD,QAAM,wBAAwB,CAACC,WAAmB;AAChD,QAAI,UAAU,UAAa,QAAQ,GAAG;AACpC,sBAAgB;AAChB,aAAO;AAAA,IACT;AAGA,mBAAe;AAEf,UAAM,qBAAqB,CAACA,eAA4B,yBAAS,iBAAiB,EAAEA,MAAK,SAAK,sBAAMA,QAAiB,qBAAqB;AAE1I,eAAO,yBAAS,CAAC,GAAG,qBAAqB,kBAAkB,CAAC,EAAEA,MAAK;AAAA,EACrE;AAEA,QAAM,QAAQ,sBAAsB,KAAK;AAEzC,SAAO,gBAAgB,OAAO;AAChC;AAEO,IAAM,oBAAoB,CAAC,UAAmB;AACnD,aAAO,yBAAS,CAAC,GAAG,qBAAqB,GAAG,iBAAiB,CAAC,EAAE,KAAK;AACvE;;;AChCA,2BAA+C;AASxC,IAAM,oBAAoB;AAK1B,IAAM,gBAAgB,CAA8C,YAAwD;AACjI,aAAO,4CAAsC,iBAAiB,EAAE,OAAO;AACzE;;;ACXO,IAAM,cAAc;AAAA,EACzB,QAAQ,CAAmB,cAA4B;AACrD,WAAO,CAELC,SAEA,YACkB;AAClB,aAAO,UAAUA,OAAM,IAAI,QAAQA,OAAM,IAAI;AAAA,IAC/C;AAAA,EACF;AACF;AAEO,IAAM,aAAa,YAAY,OAAO,QAAQ;AAC9C,IAAM,qBAAqB,YAAY,OAAO,gBAAgB;","names":["factory","factory","creatableModule","factory","import_assert","factory","import_object","import_object","import_object","import_object","module","factory","factory","import_object","import_lodash","field","module"]}
1
+ {"version":3,"sources":["../../src/Config.ts","../../src/CreatableModule/CreatableModule.ts","../../src/CreatableModule/CreatableModuleRegistry.ts","../../src/CreatableModule/LabeledCreatableModuleFactory.ts","../../src/CreatableModule/ModuleFactory.ts","../../src/CreatableModule/ModuleFactoryLocator.ts","../../src/Labels/Labels.ts","../../src/instance/asModuleInstance.ts","../../src/instance/isModuleInstance.ts","../../src/module/asModule.ts","../../src/Queries/Describe/Payload.ts","../../src/Queries/Describe/Query.ts","../../src/Queries/Discover.ts","../../src/Queries/Manifest.ts","../../src/Queries/ModuleAddress/Payload.ts","../../src/Queries/ModuleAddress/Query.ts","../../src/Queries/Subscribe.ts","../../src/module/asModuleObject.ts","../../src/module/isModuleObject.ts","../../src/module/IsModuleFactory.ts","../../src/module/isModule.ts","../../src/instance/ModuleInstance.ts","../../src/lib/duplicateModules.ts","../../src/lib/serializable.ts","../../src/Payload/ModuleState.ts","../../src/withModule.ts"],"sourcesContent":["import { Address } from '@xylabs/hex'\nimport { EmptyObject, WithAdditional } from '@xyo-network/object'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { Labels } from './Labels'\n\nexport type ModuleConfigSchema = 'network.xyo.module.config'\nexport const ModuleConfigSchema: ModuleConfigSchema = 'network.xyo.module.config'\n\nexport type CosigningAddressSet = string[]\nexport type SchemaString = string\nexport type ModuleName = string\nexport type NameOrAddress = Address | ModuleName\n\n/** @deprecated */\nexport interface IndividualArchivistConfig {\n readonly commit?: NameOrAddress\n readonly read?: NameOrAddress\n readonly write?: NameOrAddress\n}\n\n/** @deprecated */\nexport type ArchivistModuleConfig = NameOrAddress | IndividualArchivistConfig\n\nexport interface ArchivingModuleConfig {\n readonly archiving?: {\n readonly archivists?: NameOrAddress[]\n }\n}\n\nexport type ModuleConfig<\n TConfig extends Payload | void = void,\n TAdditionalParams extends EmptyObject | void = void,\n TSchema extends Schema | void = void,\n> = Payload<\n WithAdditional<\n WithAdditional<\n {\n /** @field The path to use when creating the account */\n accountDerivationPath?: string\n\n /** @field The name/address of the Archivist to use for this module */\n readonly archivist?: ArchivistModuleConfig\n\n /**\n * @field The labels used for this module. If a label is specified, then the\n * ModuleFactoryLocator will attempt to find a ModuleFactory with the corresponding\n * labels to construct this module.\n */\n readonly labels?: Labels\n\n /** @field Friendly name of module (not collision resistent). Can be used to resolve module when registered/attached to Node. */\n readonly name?: string\n\n /** @field paging settings for queries */\n readonly paging?: Record<string, { size?: number }>\n\n /** @field The query schemas and allowed/disallowed addresses which are allowed to issue them against the module. If both allowed and disallowed is specified, then disallowed takes priority. */\n readonly security?: {\n /** @field Will the module process queries that have unsigned BoundWitness in query tuples */\n readonly allowAnonymous?: boolean\n\n /** @field If schema in record, then only these address sets can access query */\n readonly allowed?: Record<SchemaString, (Address | CosigningAddressSet)[]>\n\n /** @field If schema in record, then anyone except these addresses can access query */\n readonly disallowed?: Record<SchemaString, Address[]>\n }\n\n /** @field sign every query */\n readonly sign?: boolean\n\n /** @field Store the queries made to the module in an archivist if possible */\n readonly storeQueries?: boolean\n\n /** @field add a timestamp payload to every query */\n readonly timestamp?: boolean\n } & ArchivingModuleConfig,\n TConfig\n >,\n TAdditionalParams\n >,\n TSchema extends Schema ? TSchema : TConfig extends Payload ? TConfig['schema'] : ModuleConfigSchema\n>\n\nexport type AnyConfigSchema<TConfig extends Omit<ModuleConfig, 'schema'> & { schema: string } = Omit<ModuleConfig, 'schema'> & { schema: string }> =\n ModuleConfig<\n {\n schema: string\n },\n Omit<TConfig, 'schema'>\n >\n\nexport type OptionalConfigSchema<TConfig extends AnyConfigSchema<ModuleConfig> = AnyConfigSchema<ModuleConfig>> = Omit<TConfig, 'schema'> & {\n schema?: TConfig['schema']\n}\n\nexport type AnyModuleConfig = AnyConfigSchema<ModuleConfig>\n","import { Logger } from '@xylabs/logger'\nimport { AccountInstance } from '@xyo-network/account-model'\n\nimport { ModuleInstance } from '../instance'\n\nexport type CreatableModuleFactory<T extends ModuleInstance = ModuleInstance> = Omit<Omit<CreatableModule<T>, 'new'>, 'create'> & {\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: T['params']): Promise<T>\n}\n\nexport interface CreatableModule<T extends ModuleInstance = ModuleInstance> {\n configSchema: string\n configSchemas: string[]\n defaultLogger?: Logger\n new (privateConstructorKey: string, params: T['params'], account: AccountInstance): T\n _noOverride(functionName: string): void\n create<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): Promise<T>\n factory<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): CreatableModuleFactory<T>\n}\n\n/**\n * Class annotation to be used to decorate Modules which support\n * an asynchronous creation pattern\n * @returns The decorated Module requiring it implement the members\n * of the CreatableModule as statics properties/methods\n */\nexport function creatableModule<TModule extends ModuleInstance = ModuleInstance>() {\n return <U extends CreatableModule<TModule>>(constructor: U) => {\n constructor\n }\n}\n","import { CreatableModuleFactory } from './CreatableModule'\nimport { CreatableModuleDictionary } from './CreatableModuleDictionary'\nimport { LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\nexport interface CreatableModuleRegistry {\n [key: string]: (CreatableModuleFactory | LabeledCreatableModuleFactory)[] | undefined\n}\n\nexport const toCreatableModuleRegistry = (dict: CreatableModuleDictionary | CreatableModuleRegistry): CreatableModuleRegistry => {\n return Object.entries(dict).reduce((registry, [schema, factory]) => {\n registry[schema] = Array.isArray(factory) ? factory : [factory]\n return registry\n }, {} as CreatableModuleRegistry)\n}\n\nexport const assignCreatableModuleRegistry = (\n target: CreatableModuleRegistry = {},\n ...sources: CreatableModuleRegistry[]\n): CreatableModuleRegistry => {\n sources.map((source) =>\n Object.entries(source).map(([schema, factories]) => {\n if (factories) {\n const existingFactories = target[schema]\n target[schema] = existingFactories ? (target[schema] = [...existingFactories, ...factories]) : factories\n }\n }),\n )\n return target\n}\n","import { ModuleInstance } from '../instance'\nimport { WithOptionalLabels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\n\nexport type LabeledCreatableModuleFactory<T extends ModuleInstance = ModuleInstance> = CreatableModuleFactory<T> & WithOptionalLabels\n\nexport const hasLabels = (factory: CreatableModuleFactory | LabeledCreatableModuleFactory): factory is LabeledCreatableModuleFactory => {\n return (factory as LabeledCreatableModuleFactory).labels !== undefined\n}\n","import { assertEx } from '@xylabs/assert'\nimport { merge } from '@xylabs/lodash'\nimport { Logger } from '@xylabs/logger'\n\nimport { ModuleInstance } from '../instance'\nimport { Labels, WithOptionalLabels } from '../Labels'\nimport { CreatableModule, CreatableModuleFactory } from './CreatableModule'\n\nexport class ModuleFactory<TModule extends ModuleInstance> implements CreatableModuleFactory<TModule> {\n configSchemas: CreatableModuleFactory<TModule>['configSchemas']\n\n creatableModule: CreatableModule<TModule>\n\n defaultLogger?: Logger | undefined\n\n defaultParams?: Omit<TModule['params'], 'config'> & { config?: Partial<TModule['params']['config']> }\n\n labels?: Labels\n\n constructor(\n creatableModule: CreatableModule<TModule>,\n params?: Omit<TModule['params'], 'config'> & { config?: Partial<TModule['params']['config']> },\n labels: Labels = {},\n ) {\n this.creatableModule = creatableModule\n this.defaultParams = params\n this.configSchemas = creatableModule.configSchemas\n this.labels = Object.assign({}, (creatableModule as WithOptionalLabels).labels ?? {}, labels ?? {})\n }\n\n get configSchema(): string {\n return this.configSchemas[0]\n }\n\n static withParams<T extends ModuleInstance>(\n creatableModule: CreatableModule<T>,\n params?: Omit<T['params'], 'config'> & { config?: T['params']['config'] },\n labels: Labels = {},\n ) {\n return new ModuleFactory(creatableModule, params, labels)\n }\n\n _getRootFunction(funcName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let anyThis = this as any\n while (anyThis.__proto__[funcName]) {\n anyThis = anyThis.__proto__\n }\n return anyThis[funcName]\n }\n\n _noOverride(functionName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const thisFunc = (this as any)[functionName]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const rootFunc = this._getRootFunction(functionName)\n assertEx(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`)\n }\n\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: TModule['params'] | undefined): Promise<T> {\n const factory = this as ModuleFactory<T>\n const schema = factory.creatableModule.configSchema\n const mergedParams: TModule['params'] = merge({}, factory.defaultParams, params, {\n config: merge({}, factory.defaultParams?.config, params?.config, { schema }),\n })\n return factory.creatableModule.create<T>(mergedParams)\n }\n\n factory<T extends ModuleInstance>(this: CreatableModule<T>, _params?: T['params'] | undefined): CreatableModuleFactory<T> {\n throw new Error('Method not implemented.')\n }\n}\n","import { assertEx } from '@xylabs/assert'\n\nimport { ModuleInstance } from '../instance'\nimport { hasAllLabels, Labels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\nimport { CreatableModuleRegistry } from './CreatableModuleRegistry'\nimport { hasLabels, LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\n/**\n * A class which encapsulates the Service Locator Pattern for Module Factories\n */\nexport class ModuleFactoryLocator {\n constructor(protected readonly _registry: CreatableModuleRegistry = {}) {}\n\n /**\n * The current registry for the module factory\n */\n get registry(): Readonly<CreatableModuleRegistry> {\n return this._registry\n }\n\n /**\n * Locates a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or throws if one is not found\n */\n locate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory {\n return assertEx(this.tryLocate(schema, labels), () => {\n const configString = `config schema [${schema}]`\n const labelsString = labels ? ` & labels [${JSON.stringify(labels)}]` : ''\n return `No module factory for the supplied ${configString}${labelsString} registered`\n })\n }\n\n /**\n * Registers a single module factory (with optional tags) with the locator\n * @param additional Additional module factories to register\n */\n register<TModule extends ModuleInstance>(mod: CreatableModuleFactory<TModule>, labels?: Labels): this {\n mod.configSchemas.map((schema) => {\n const existingFactories = this._registry[schema]\n const factory: LabeledCreatableModuleFactory<TModule> = {\n // Destructure instance properties\n ...mod,\n // Copy static methods\n create: mod.create.bind(mod) as LabeledCreatableModuleFactory<TModule>['create'],\n // Merge module & supplied labels\n labels: Object.assign({}, (mod as LabeledCreatableModuleFactory).labels ?? {}, labels ?? {}),\n }\n this._registry[schema] = existingFactories ? [...existingFactories, factory] : [factory]\n })\n return this\n }\n\n /**\n * Registers multiple module factories with the locator\n * @param additional Additional module factories to register\n */\n registerMany(additional: CreatableModuleRegistry): this {\n Object.entries(additional).map(([schema, factories]) => {\n if (factories) {\n const existingFactories = this._registry[schema]\n this._registry[schema] = existingFactories ? [...existingFactories, ...factories] : factories\n }\n })\n return this\n }\n\n /**\n * Tries to locate a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or undefined\n */\n tryLocate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory | undefined {\n // If labels were provided\n return labels\n ? // Find the first factory that has labels and has all the labels provided\n this._registry[schema]?.filter(hasLabels).find((factory) => hasAllLabels(factory?.labels, labels))\n : // Otherwise, return the first factory\n this._registry[schema]?.[0]\n }\n}\n","/**\n * Object used to represent labels identifying a resource.\n */\nexport interface Labels {\n [key: string]: string | undefined\n}\n\n/**\n * Interface for objects that have labels.\n */\nexport interface WithLabels<T extends Labels = Labels> {\n labels: T\n}\n\n/**\n * Interface for objects that have labels.\n */\nexport interface WithOptionalLabels<T extends Labels = Labels> {\n labels?: T\n}\n\n/**\n * Returns true if the source object has all the labels from the required set\n * @param source Source object to check against\n * @param required Set of labels to check for in source\n * @returns True of the source object has all the labels from the required set\n */\nexport const hasAllLabels = (source?: Labels, required?: Labels): boolean => {\n if (!required) return true\n return Object.entries(required).every(([key, value]) => {\n // eslint-disable-next-line no-prototype-builtins\n return source?.hasOwnProperty(key as keyof typeof source) && source?.[key as keyof typeof source] === value\n })\n}\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModuleInstance } from './isModuleInstance'\n\nexport const asModuleInstance = AsObjectFactory.create(isModuleInstance)\n","import { IsObjectFactory, ObjectTypeShape, TypeCheck } from '@xyo-network/object'\n\nimport { isModule } from '../module'\nimport { ModuleInstance } from './ModuleInstance'\n\nexport const requiredModuleInstanceFunctions: ObjectTypeShape = {\n describe: 'function',\n discover: 'function',\n manifest: 'function',\n moduleAddress: 'function',\n}\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsObjectFactory<ModuleInstance>()\n\nexport const isModuleInstance: TypeCheck<ModuleInstance> = factory.create(requiredModuleInstanceFunctions, [isModule])\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModule } from './isModule'\n\nexport const asModule = AsObjectFactory.create(isModule)\n","import { Payload } from '@xyo-network/payload-model'\n\nimport { ModuleDescription } from '../../ModuleDescription'\n\nexport const ModuleDescriptionSchema = 'network.xyo.module.description'\nexport type ModuleDescriptionSchema = typeof ModuleDescriptionSchema\n\nexport type ModuleDescriptionPayload = Payload<ModuleDescription, ModuleDescriptionSchema>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\nexport const ModuleDescribeQuerySchema: ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\n\nexport type ModuleDescribeQuery = Query<{\n schema: ModuleDescribeQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\nexport const ModuleDiscoverQuerySchema: ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\n\nexport type ModuleDiscoverQuery = Query<{\n maxDepth?: number\n schema: ModuleDiscoverQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\nexport const ModuleManifestQuerySchema: ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\n\nexport type ModuleManifestQuery = Query<{\n maxDepth?: number\n schema: ModuleManifestQuerySchema\n}>\n","import { AddressSchema } from '@xyo-network/address-payload-plugin'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport const AddressPreviousHashSchema = `${AddressSchema}.hash.previous`\nexport type AddressPreviousHashSchema = typeof AddressPreviousHashSchema\n\nexport type AddressPreviousHashPayload = Payload<{\n address: string\n previousHash?: string\n schema: AddressPreviousHashSchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleAddressQuerySchema = 'network.xyo.query.module.address'\nexport const ModuleAddressQuerySchema: ModuleAddressQuerySchema = 'network.xyo.query.module.address'\n\nexport type ModuleAddressQuery = Query<{\n schema: ModuleAddressQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\nexport const ModuleSubscribeQuerySchema: ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\n\nexport interface ModuleSubscribeFilter {\n /** @field if specified, at least one of the schemas must be present in the boundwtness to generate a notification */\n schema?: string[]\n}\n\n//requests notification when a boundwitness is added to the modules chain that meets the filter criteria\nexport type ModuleSubscribeQuery = Query<{\n /** @field The address that will receive notifications */\n address: string\n /** @field A subscribe with a null for filter is an unsubscribe */\n filter?: ModuleSubscribeFilter | null\n /** @field The maximum events queued per send [may increase frequency] */\n maxQueue?: number\n schema: ModuleSubscribeQuerySchema\n}>\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModuleObject } from './isModuleObject'\n\nexport const asModuleObject = AsObjectFactory.create(isModuleObject)\n","import { IsObjectFactory, ObjectTypeShape } from '@xyo-network/object'\n\nimport { Module } from './Module'\n\nexport const requiredModuleShape: ObjectTypeShape = {\n address: 'string',\n config: 'object',\n params: 'object',\n queries: 'array',\n query: 'function',\n queryable: 'function',\n}\n\nconst factory = new IsObjectFactory<Module>()\n\nexport const isModuleObject = factory.create(requiredModuleShape)\n","import { AnyObject, EmptyObject, TypeCheck } from '@xyo-network/object'\n\nimport { asModuleObject } from './asModuleObject'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport type ModuleTypeCheck<T extends Module = Module> = TypeCheck<T>\n\nexport class IsModuleFactory<T extends Module = Module> {\n create(expectedQueries?: string[], additionalChecks?: TypeCheck<AnyObject | EmptyObject>[]): ModuleTypeCheck<T> {\n return (obj: unknown, config): obj is T => {\n const module = asModuleObject(obj)\n const result =\n isModuleObject(module, config) &&\n (expectedQueries?.reduce((prev, query) => prev && module.queries.includes(query), true) ?? true) &&\n //perform additional checks\n (additionalChecks?.reduce((prev, check) => prev && check(obj, config), true) ?? true)\n return result\n }\n }\n}\n","import { TypeCheck } from '@xyo-network/object'\n\nimport { ModuleDiscoverQuerySchema } from '../Queries'\nimport { IsModuleFactory } from './IsModuleFactory'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport const requiredModuleQueries: string[] = [\n /* We need to update this once live module conform */\n //ModuleDescribeQuerySchema,\n //ModuleAddressQuerySchema,\n ModuleDiscoverQuerySchema,\n //ModuleManifestQuerySchema,\n //ModuleSubscribeQuerySchema,\n]\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsModuleFactory<Module>()\n\nexport const isModule: TypeCheck<Module> = factory.create(requiredModuleQueries, [isModuleObject])\n","import { Promisable } from '@xylabs/promise'\nimport { IsObjectFactory, TypeCheck } from '@xyo-network/object'\n\nimport { ModuleEventData } from '../EventsModels'\nimport { Module, ModuleQueryFunctions } from '../module'\nimport { ModuleParams } from '../ModuleParams'\n\nexport interface ResolveFunctions {\n resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter<T>, options?: ModuleFilterOptions<T>): Promisable<T[]>\n resolve<T extends ModuleInstance = ModuleInstance>(nameOrAddress: string, options?: ModuleFilterOptions<T>): Promisable<T | undefined>\n resolve<T extends ModuleInstance = ModuleInstance>(\n nameOrAddressOrFilter?: ModuleFilter<T> | string,\n options?: ModuleFilterOptions<T>,\n ): Promisable<T | T[] | undefined>\n}\n\nexport interface ModuleResolver extends ResolveFunctions {\n addResolver: (resolver: ModuleResolver) => this\n isModuleResolver: boolean\n removeResolver: (resolver: ModuleResolver) => this\n}\n\nexport type ModuleInstance<TParams extends ModuleParams = ModuleParams, TEventData extends ModuleEventData = ModuleEventData> = Module<\n TParams,\n TEventData\n> &\n ResolveFunctions &\n ModuleQueryFunctions & {\n /* The resolver is a 'down' resolver. It can resolve the module or any children (if it is a node for example), that are in the module*/\n readonly downResolver: Omit<ModuleResolver, 'resolve'>\n\n /* The resolver is a 'up' resolver. It can resolve the parent or any children of the parent*/\n /* This is set by a NodeModule when attaching to the module */\n readonly upResolver: Omit<ModuleResolver, 'resolve'>\n }\n\nexport type InstanceTypeCheck<T extends ModuleInstance = ModuleInstance> = TypeCheck<T>\n\nexport class IsInstanceFactory<T extends ModuleInstance = ModuleInstance> extends IsObjectFactory<T> {}\n\nexport interface ModuleFilterOptions<T extends ModuleInstance = ModuleInstance> {\n direction?: 'up' | 'down' | 'all'\n identity?: InstanceTypeCheck<T>\n maxDepth?: number\n visibility?: 'public' | 'private' | 'all'\n}\n\nexport interface AddressModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n address: string[]\n}\n\nexport interface NameModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n name: string[]\n}\n\nexport interface QueryModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n query: string[][]\n}\n\nexport type AnyModuleFilter<T extends ModuleInstance = ModuleInstance> = Partial<AddressModuleFilter<T>> &\n Partial<NameModuleFilter<T>> &\n Partial<QueryModuleFilter<T>>\n\nexport type ModuleFilter<T extends ModuleInstance = ModuleInstance> =\n | ModuleFilterOptions<T>\n | AddressModuleFilter<T>\n | NameModuleFilter<T>\n | QueryModuleFilter<T>\n","import { Module } from '../module'\n\n/**\n * Used to filter duplicates from an array of modules\n * @example: modulesArray.filter(duplicateModules)\n * @param value Current Module\n * @param index Current Module's index\n * @param array Module Array\n * @returns True if the Module's address is the first occurrence of\n * that address in the array, false otherwise\n */\nexport const duplicateModules = (value: Module, index: number, array: Module[]): value is Module => {\n return array.findIndex((v) => v.address === value.address) === index\n}\n","// Inspired by https://stackoverflow.com/a/49079549/2803259\n\nimport { every, isArray, isBoolean, isNull, isNumber, isPlainObject, isString, isUndefined, overSome } from '@xylabs/lodash'\n\nconst JSONPrimitiveChecks = [isUndefined, isNull, isBoolean, isNumber, isString]\nconst JSONComplexChecks = [isPlainObject, isArray]\n\nexport const serializable = (field: unknown, depth?: number): boolean | null => {\n let depthExceeded = false\n const decrementDepth = () => (depth ? depth-- : undefined)\n\n const recursiveSerializable = (field: unknown) => {\n if (depth !== undefined && depth < 1) {\n depthExceeded = true\n return false\n }\n\n // decrement during every recursion\n decrementDepth()\n\n const nestedSerializable = (field: unknown): boolean => overSome(JSONComplexChecks)(field) && every(field as object, recursiveSerializable)\n\n return overSome([...JSONPrimitiveChecks, nestedSerializable])(field)\n }\n\n const valid = recursiveSerializable(field)\n\n return depthExceeded ? null : valid\n}\n\nexport const serializableField = (field: unknown) => {\n return overSome([...JSONPrimitiveChecks, ...JSONComplexChecks])(field)\n}\n","import { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nexport interface StateDictionary {\n [key: string]: string | number | undefined\n}\nexport interface State<T extends StateDictionary = StateDictionary> {\n state: T\n}\n\nexport const ModuleStateSchema = 'network.xyo.module.state' as const\nexport type ModuleStateSchema = typeof ModuleStateSchema\n\nexport type ModuleState<T extends StateDictionary = StateDictionary> = Payload<State<T>, ModuleStateSchema>\n\nexport const isModuleState = <T extends StateDictionary = StateDictionary>(payload?: Payload | null): payload is ModuleState<T> => {\n return isPayloadOfSchemaType<ModuleState<T>>(ModuleStateSchema)(payload)\n}\n","import { TypeCheck } from '@xyo-network/object'\n\nimport { isModuleInstance } from './instance'\nimport { isModule } from './module'\n\nexport const WithFactory = {\n create: <T extends object>(typeCheck: TypeCheck<T>) => {\n return <R>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n module: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n closure: (module: T) => R,\n ): R | undefined => {\n return typeCheck(module) ? closure(module) : undefined\n }\n },\n}\n\nexport const withModule = WithFactory.create(isModule)\nexport const withModuleInstance = WithFactory.create(isModuleInstance)\n"],"mappings":";AAOO,IAAM,qBAAyC;;;ACkB/C,SAAS,kBAAmE;AACjF,SAAO,CAAqC,gBAAmB;AAC7D;AAAA,EACF;AACF;;;ACrBO,IAAM,4BAA4B,CAAC,SAA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EACzB,QAAQ,CAAmB,cAA4B;AACrD,WAAO,CAEL,QAEA,YACkB;AAClB,aAAO,UAAU,MAAM,IAAI,QAAQ,MAAM,IAAI;AAAA,IAC/C;AAAA,EACF;AACF;AAEO,IAAM,aAAa,YAAY,OAAO,QAAQ;AAC9C,IAAM,qBAAqB,YAAY,OAAO,gBAAgB;","names":["factory","factory","creatableModule","factory","assertEx","assertEx","factory","AsObjectFactory","IsObjectFactory","AsObjectFactory","factory","AsObjectFactory","factory","IsObjectFactory","AsObjectFactory","IsObjectFactory","field"]}
package/package.json CHANGED
@@ -15,22 +15,21 @@
15
15
  "@xylabs/lodash": "^2.13.20",
16
16
  "@xylabs/logger": "^2.13.20",
17
17
  "@xylabs/promise": "^2.13.20",
18
- "@xyo-network/account-model": "~2.84.2",
19
- "@xyo-network/address-payload-plugin": "^2.83.0",
20
- "@xyo-network/boundwitness-model": "~2.84.2",
21
- "@xyo-network/manifest-model": "~2.84.2",
22
- "@xyo-network/module-events": "~2.84.2",
23
- "@xyo-network/object": "~2.84.2",
24
- "@xyo-network/payload-model": "~2.84.2",
25
- "@xyo-network/wallet-model": "~2.84.2"
18
+ "@xyo-network/account-model": "~2.84.4",
19
+ "@xyo-network/address-payload-plugin": "^2.84.1",
20
+ "@xyo-network/boundwitness-model": "~2.84.4",
21
+ "@xyo-network/manifest-model": "~2.84.4",
22
+ "@xyo-network/module-events": "~2.84.4",
23
+ "@xyo-network/object": "~2.84.4",
24
+ "@xyo-network/payload-model": "~2.84.4",
25
+ "@xyo-network/wallet-model": "~2.84.4"
26
26
  },
27
27
  "devDependencies": {
28
- "@xylabs/ts-scripts-yarn3": "^3.2.10",
29
- "@xylabs/tsconfig": "^3.2.10",
28
+ "@xylabs/ts-scripts-yarn3": "^3.2.19",
29
+ "@xylabs/tsconfig": "^3.2.19",
30
30
  "typescript": "^5.3.3"
31
31
  },
32
32
  "description": "Primary SDK for using XYO Protocol 2.0",
33
- "docs": "dist/docs.json",
34
33
  "types": "dist/node/index.d.ts",
35
34
  "exports": {
36
35
  ".": {
@@ -46,19 +45,19 @@
46
45
  },
47
46
  "node": {
48
47
  "require": {
49
- "types": "./dist/node/index.d.ts",
50
- "default": "./dist/node/index.js"
48
+ "types": "./dist/node/index.d.cts",
49
+ "default": "./dist/node/index.cjs"
51
50
  },
52
51
  "import": {
53
52
  "types": "./dist/node/index.d.mts",
54
- "default": "./dist/node/index.mjs"
53
+ "default": "./dist/node/index.js"
55
54
  }
56
55
  }
57
56
  },
58
57
  "./package.json": "./package.json"
59
58
  },
60
- "main": "dist/node/index.js",
61
- "module": "dist/node/index.mjs",
59
+ "main": "dist/node/index.cjs",
60
+ "module": "dist/node/index.js",
62
61
  "homepage": "https://xyo.network",
63
62
  "license": "LGPL-3.0-only",
64
63
  "publishConfig": {
@@ -69,5 +68,6 @@
69
68
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
70
69
  },
71
70
  "sideEffects": false,
72
- "version": "2.84.2"
71
+ "version": "2.84.4",
72
+ "type": "module"
73
73
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Config.ts","../../src/CreatableModule/CreatableModule.ts","../../src/CreatableModule/CreatableModuleRegistry.ts","../../src/CreatableModule/LabeledCreatableModuleFactory.ts","../../src/CreatableModule/ModuleFactory.ts","../../src/CreatableModule/ModuleFactoryLocator.ts","../../src/Labels/Labels.ts","../../src/instance/asModuleInstance.ts","../../src/instance/isModuleInstance.ts","../../src/module/asModule.ts","../../src/Queries/Describe/Payload.ts","../../src/Queries/Describe/Query.ts","../../src/Queries/Discover.ts","../../src/Queries/Manifest.ts","../../src/Queries/ModuleAddress/Payload.ts","../../src/Queries/ModuleAddress/Query.ts","../../src/Queries/Subscribe.ts","../../src/module/asModuleObject.ts","../../src/module/isModuleObject.ts","../../src/module/IsModuleFactory.ts","../../src/module/isModule.ts","../../src/instance/ModuleInstance.ts","../../src/lib/duplicateModules.ts","../../src/lib/serializable.ts","../../src/Payload/ModuleState.ts","../../src/withModule.ts"],"sourcesContent":["import { Address } from '@xylabs/hex'\nimport { EmptyObject, WithAdditional } from '@xyo-network/object'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { Labels } from './Labels'\n\nexport type ModuleConfigSchema = 'network.xyo.module.config'\nexport const ModuleConfigSchema: ModuleConfigSchema = 'network.xyo.module.config'\n\nexport type CosigningAddressSet = string[]\nexport type SchemaString = string\nexport type ModuleName = string\nexport type NameOrAddress = Address | ModuleName\n\n/** @deprecated */\nexport interface IndividualArchivistConfig {\n readonly commit?: NameOrAddress\n readonly read?: NameOrAddress\n readonly write?: NameOrAddress\n}\n\n/** @deprecated */\nexport type ArchivistModuleConfig = NameOrAddress | IndividualArchivistConfig\n\nexport interface ArchivingModuleConfig {\n readonly archiving?: {\n readonly archivists?: NameOrAddress[]\n }\n}\n\nexport type ModuleConfig<\n TConfig extends Payload | void = void,\n TAdditionalParams extends EmptyObject | void = void,\n TSchema extends Schema | void = void,\n> = Payload<\n WithAdditional<\n WithAdditional<\n {\n /** @field The path to use when creating the account */\n accountDerivationPath?: string\n\n /** @field The name/address of the Archivist to use for this module */\n readonly archivist?: ArchivistModuleConfig\n\n /**\n * @field The labels used for this module. If a label is specified, then the\n * ModuleFactoryLocator will attempt to find a ModuleFactory with the corresponding\n * labels to construct this module.\n */\n readonly labels?: Labels\n\n /** @field Friendly name of module (not collision resistent). Can be used to resolve module when registered/attached to Node. */\n readonly name?: string\n\n /** @field paging settings for queries */\n readonly paging?: Record<string, { size?: number }>\n\n /** @field The query schemas and allowed/disallowed addresses which are allowed to issue them against the module. If both allowed and disallowed is specified, then disallowed takes priority. */\n readonly security?: {\n /** @field Will the module process queries that have unsigned BoundWitness in query tuples */\n readonly allowAnonymous?: boolean\n\n /** @field If schema in record, then only these address sets can access query */\n readonly allowed?: Record<SchemaString, (Address | CosigningAddressSet)[]>\n\n /** @field If schema in record, then anyone except these addresses can access query */\n readonly disallowed?: Record<SchemaString, Address[]>\n }\n\n /** @field sign every query */\n readonly sign?: boolean\n\n /** @field Store the queries made to the module in an archivist if possible */\n readonly storeQueries?: boolean\n\n /** @field add a timestamp payload to every query */\n readonly timestamp?: boolean\n } & ArchivingModuleConfig,\n TConfig\n >,\n TAdditionalParams\n >,\n TSchema extends Schema ? TSchema : TConfig extends Payload ? TConfig['schema'] : ModuleConfigSchema\n>\n\nexport type AnyConfigSchema<TConfig extends Omit<ModuleConfig, 'schema'> & { schema: string } = Omit<ModuleConfig, 'schema'> & { schema: string }> =\n ModuleConfig<\n {\n schema: string\n },\n Omit<TConfig, 'schema'>\n >\n\nexport type OptionalConfigSchema<TConfig extends AnyConfigSchema<ModuleConfig> = AnyConfigSchema<ModuleConfig>> = Omit<TConfig, 'schema'> & {\n schema?: TConfig['schema']\n}\n\nexport type AnyModuleConfig = AnyConfigSchema<ModuleConfig>\n","import { Logger } from '@xylabs/logger'\nimport { AccountInstance } from '@xyo-network/account-model'\n\nimport { ModuleInstance } from '../instance'\n\nexport type CreatableModuleFactory<T extends ModuleInstance = ModuleInstance> = Omit<Omit<CreatableModule<T>, 'new'>, 'create'> & {\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: T['params']): Promise<T>\n}\n\nexport interface CreatableModule<T extends ModuleInstance = ModuleInstance> {\n configSchema: string\n configSchemas: string[]\n defaultLogger?: Logger\n new (privateConstructorKey: string, params: T['params'], account: AccountInstance): T\n _noOverride(functionName: string): void\n create<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): Promise<T>\n factory<T extends ModuleInstance>(this: CreatableModule<T>, params?: T['params']): CreatableModuleFactory<T>\n}\n\n/**\n * Class annotation to be used to decorate Modules which support\n * an asynchronous creation pattern\n * @returns The decorated Module requiring it implement the members\n * of the CreatableModule as statics properties/methods\n */\nexport function creatableModule<TModule extends ModuleInstance = ModuleInstance>() {\n return <U extends CreatableModule<TModule>>(constructor: U) => {\n constructor\n }\n}\n","import { CreatableModuleFactory } from './CreatableModule'\nimport { CreatableModuleDictionary } from './CreatableModuleDictionary'\nimport { LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\nexport interface CreatableModuleRegistry {\n [key: string]: (CreatableModuleFactory | LabeledCreatableModuleFactory)[] | undefined\n}\n\nexport const toCreatableModuleRegistry = (dict: CreatableModuleDictionary | CreatableModuleRegistry): CreatableModuleRegistry => {\n return Object.entries(dict).reduce((registry, [schema, factory]) => {\n registry[schema] = Array.isArray(factory) ? factory : [factory]\n return registry\n }, {} as CreatableModuleRegistry)\n}\n\nexport const assignCreatableModuleRegistry = (\n target: CreatableModuleRegistry = {},\n ...sources: CreatableModuleRegistry[]\n): CreatableModuleRegistry => {\n sources.map((source) =>\n Object.entries(source).map(([schema, factories]) => {\n if (factories) {\n const existingFactories = target[schema]\n target[schema] = existingFactories ? (target[schema] = [...existingFactories, ...factories]) : factories\n }\n }),\n )\n return target\n}\n","import { ModuleInstance } from '../instance'\nimport { WithOptionalLabels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\n\nexport type LabeledCreatableModuleFactory<T extends ModuleInstance = ModuleInstance> = CreatableModuleFactory<T> & WithOptionalLabels\n\nexport const hasLabels = (factory: CreatableModuleFactory | LabeledCreatableModuleFactory): factory is LabeledCreatableModuleFactory => {\n return (factory as LabeledCreatableModuleFactory).labels !== undefined\n}\n","import { assertEx } from '@xylabs/assert'\nimport { merge } from '@xylabs/lodash'\nimport { Logger } from '@xylabs/logger'\n\nimport { ModuleInstance } from '../instance'\nimport { Labels, WithOptionalLabels } from '../Labels'\nimport { CreatableModule, CreatableModuleFactory } from './CreatableModule'\n\nexport class ModuleFactory<TModule extends ModuleInstance> implements CreatableModuleFactory<TModule> {\n configSchemas: CreatableModuleFactory<TModule>['configSchemas']\n\n creatableModule: CreatableModule<TModule>\n\n defaultLogger?: Logger | undefined\n\n defaultParams?: Omit<TModule['params'], 'config'> & { config?: Partial<TModule['params']['config']> }\n\n labels?: Labels\n\n constructor(\n creatableModule: CreatableModule<TModule>,\n params?: Omit<TModule['params'], 'config'> & { config?: Partial<TModule['params']['config']> },\n labels: Labels = {},\n ) {\n this.creatableModule = creatableModule\n this.defaultParams = params\n this.configSchemas = creatableModule.configSchemas\n this.labels = Object.assign({}, (creatableModule as WithOptionalLabels).labels ?? {}, labels ?? {})\n }\n\n get configSchema(): string {\n return this.configSchemas[0]\n }\n\n static withParams<T extends ModuleInstance>(\n creatableModule: CreatableModule<T>,\n params?: Omit<T['params'], 'config'> & { config?: T['params']['config'] },\n labels: Labels = {},\n ) {\n return new ModuleFactory(creatableModule, params, labels)\n }\n\n _getRootFunction(funcName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let anyThis = this as any\n while (anyThis.__proto__[funcName]) {\n anyThis = anyThis.__proto__\n }\n return anyThis[funcName]\n }\n\n _noOverride(functionName: string) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const thisFunc = (this as any)[functionName]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const rootFunc = this._getRootFunction(functionName)\n assertEx(thisFunc === rootFunc, `Override not allowed for [${functionName}] - override ${functionName}Handler instead`)\n }\n\n create<T extends ModuleInstance>(this: CreatableModuleFactory<T>, params?: TModule['params'] | undefined): Promise<T> {\n const factory = this as ModuleFactory<T>\n const schema = factory.creatableModule.configSchema\n const mergedParams: TModule['params'] = merge({}, factory.defaultParams, params, {\n config: merge({}, factory.defaultParams?.config, params?.config, { schema }),\n })\n return factory.creatableModule.create<T>(mergedParams)\n }\n\n factory<T extends ModuleInstance>(this: CreatableModule<T>, _params?: T['params'] | undefined): CreatableModuleFactory<T> {\n throw new Error('Method not implemented.')\n }\n}\n","import { assertEx } from '@xylabs/assert'\n\nimport { ModuleInstance } from '../instance'\nimport { hasAllLabels, Labels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\nimport { CreatableModuleRegistry } from './CreatableModuleRegistry'\nimport { hasLabels, LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\n/**\n * A class which encapsulates the Service Locator Pattern for Module Factories\n */\nexport class ModuleFactoryLocator {\n constructor(protected readonly _registry: CreatableModuleRegistry = {}) {}\n\n /**\n * The current registry for the module factory\n */\n get registry(): Readonly<CreatableModuleRegistry> {\n return this._registry\n }\n\n /**\n * Locates a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or throws if one is not found\n */\n locate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory {\n return assertEx(this.tryLocate(schema, labels), () => {\n const configString = `config schema [${schema}]`\n const labelsString = labels ? ` & labels [${JSON.stringify(labels)}]` : ''\n return `No module factory for the supplied ${configString}${labelsString} registered`\n })\n }\n\n /**\n * Registers a single module factory (with optional tags) with the locator\n * @param additional Additional module factories to register\n */\n register<TModule extends ModuleInstance>(mod: CreatableModuleFactory<TModule>, labels?: Labels): this {\n mod.configSchemas.map((schema) => {\n const existingFactories = this._registry[schema]\n const factory: LabeledCreatableModuleFactory<TModule> = {\n // Destructure instance properties\n ...mod,\n // Copy static methods\n create: mod.create.bind(mod) as LabeledCreatableModuleFactory<TModule>['create'],\n // Merge module & supplied labels\n labels: Object.assign({}, (mod as LabeledCreatableModuleFactory).labels ?? {}, labels ?? {}),\n }\n this._registry[schema] = existingFactories ? [...existingFactories, factory] : [factory]\n })\n return this\n }\n\n /**\n * Registers multiple module factories with the locator\n * @param additional Additional module factories to register\n */\n registerMany(additional: CreatableModuleRegistry): this {\n Object.entries(additional).map(([schema, factories]) => {\n if (factories) {\n const existingFactories = this._registry[schema]\n this._registry[schema] = existingFactories ? [...existingFactories, ...factories] : factories\n }\n })\n return this\n }\n\n /**\n * Tries to locate a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or undefined\n */\n tryLocate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory | undefined {\n // If labels were provided\n return labels\n ? // Find the first factory that has labels and has all the labels provided\n this._registry[schema]?.filter(hasLabels).find((factory) => hasAllLabels(factory?.labels, labels))\n : // Otherwise, return the first factory\n this._registry[schema]?.[0]\n }\n}\n","/**\n * Object used to represent labels identifying a resource.\n */\nexport interface Labels {\n [key: string]: string | undefined\n}\n\n/**\n * Interface for objects that have labels.\n */\nexport interface WithLabels<T extends Labels = Labels> {\n labels: T\n}\n\n/**\n * Interface for objects that have labels.\n */\nexport interface WithOptionalLabels<T extends Labels = Labels> {\n labels?: T\n}\n\n/**\n * Returns true if the source object has all the labels from the required set\n * @param source Source object to check against\n * @param required Set of labels to check for in source\n * @returns True of the source object has all the labels from the required set\n */\nexport const hasAllLabels = (source?: Labels, required?: Labels): boolean => {\n if (!required) return true\n return Object.entries(required).every(([key, value]) => {\n // eslint-disable-next-line no-prototype-builtins\n return source?.hasOwnProperty(key as keyof typeof source) && source?.[key as keyof typeof source] === value\n })\n}\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModuleInstance } from './isModuleInstance'\n\nexport const asModuleInstance = AsObjectFactory.create(isModuleInstance)\n","import { IsObjectFactory, ObjectTypeShape, TypeCheck } from '@xyo-network/object'\n\nimport { isModule } from '../module'\nimport { ModuleInstance } from './ModuleInstance'\n\nexport const requiredModuleInstanceFunctions: ObjectTypeShape = {\n describe: 'function',\n discover: 'function',\n manifest: 'function',\n moduleAddress: 'function',\n}\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsObjectFactory<ModuleInstance>()\n\nexport const isModuleInstance: TypeCheck<ModuleInstance> = factory.create(requiredModuleInstanceFunctions, [isModule])\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModule } from './isModule'\n\nexport const asModule = AsObjectFactory.create(isModule)\n","import { Payload } from '@xyo-network/payload-model'\n\nimport { ModuleDescription } from '../../ModuleDescription'\n\nexport const ModuleDescriptionSchema = 'network.xyo.module.description'\nexport type ModuleDescriptionSchema = typeof ModuleDescriptionSchema\n\nexport type ModuleDescriptionPayload = Payload<ModuleDescription, ModuleDescriptionSchema>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\nexport const ModuleDescribeQuerySchema: ModuleDescribeQuerySchema = 'network.xyo.query.module.describe'\n\nexport type ModuleDescribeQuery = Query<{\n schema: ModuleDescribeQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\nexport const ModuleDiscoverQuerySchema: ModuleDiscoverQuerySchema = 'network.xyo.query.module.discover'\n\nexport type ModuleDiscoverQuery = Query<{\n maxDepth?: number\n schema: ModuleDiscoverQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\nexport const ModuleManifestQuerySchema: ModuleManifestQuerySchema = 'network.xyo.query.module.manifest'\n\nexport type ModuleManifestQuery = Query<{\n maxDepth?: number\n schema: ModuleManifestQuerySchema\n}>\n","import { AddressSchema } from '@xyo-network/address-payload-plugin'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport const AddressPreviousHashSchema = `${AddressSchema}.hash.previous`\nexport type AddressPreviousHashSchema = typeof AddressPreviousHashSchema\n\nexport type AddressPreviousHashPayload = Payload<{\n address: string\n previousHash?: string\n schema: AddressPreviousHashSchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleAddressQuerySchema = 'network.xyo.query.module.address'\nexport const ModuleAddressQuerySchema: ModuleAddressQuerySchema = 'network.xyo.query.module.address'\n\nexport type ModuleAddressQuery = Query<{\n schema: ModuleAddressQuerySchema\n}>\n","import { Query } from '@xyo-network/payload-model'\n\nexport type ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\nexport const ModuleSubscribeQuerySchema: ModuleSubscribeQuerySchema = 'network.xyo.query.module.subscribe'\n\nexport interface ModuleSubscribeFilter {\n /** @field if specified, at least one of the schemas must be present in the boundwtness to generate a notification */\n schema?: string[]\n}\n\n//requests notification when a boundwitness is added to the modules chain that meets the filter criteria\nexport type ModuleSubscribeQuery = Query<{\n /** @field The address that will receive notifications */\n address: string\n /** @field A subscribe with a null for filter is an unsubscribe */\n filter?: ModuleSubscribeFilter | null\n /** @field The maximum events queued per send [may increase frequency] */\n maxQueue?: number\n schema: ModuleSubscribeQuerySchema\n}>\n","import { AsObjectFactory } from '@xyo-network/object'\n\nimport { isModuleObject } from './isModuleObject'\n\nexport const asModuleObject = AsObjectFactory.create(isModuleObject)\n","import { IsObjectFactory, ObjectTypeShape } from '@xyo-network/object'\n\nimport { Module } from './Module'\n\nexport const requiredModuleShape: ObjectTypeShape = {\n address: 'string',\n config: 'object',\n params: 'object',\n queries: 'array',\n query: 'function',\n queryable: 'function',\n}\n\nconst factory = new IsObjectFactory<Module>()\n\nexport const isModuleObject = factory.create(requiredModuleShape)\n","import { AnyObject, EmptyObject, TypeCheck } from '@xyo-network/object'\n\nimport { asModuleObject } from './asModuleObject'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport type ModuleTypeCheck<T extends Module = Module> = TypeCheck<T>\n\nexport class IsModuleFactory<T extends Module = Module> {\n create(expectedQueries?: string[], additionalChecks?: TypeCheck<AnyObject | EmptyObject>[]): ModuleTypeCheck<T> {\n return (obj: unknown, config): obj is T => {\n const module = asModuleObject(obj)\n const result =\n isModuleObject(module, config) &&\n (expectedQueries?.reduce((prev, query) => prev && module.queries.includes(query), true) ?? true) &&\n //perform additional checks\n (additionalChecks?.reduce((prev, check) => prev && check(obj, config), true) ?? true)\n return result\n }\n }\n}\n","import { TypeCheck } from '@xyo-network/object'\n\nimport { ModuleDiscoverQuerySchema } from '../Queries'\nimport { IsModuleFactory } from './IsModuleFactory'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport const requiredModuleQueries: string[] = [\n /* We need to update this once live module conform */\n //ModuleDescribeQuerySchema,\n //ModuleAddressQuerySchema,\n ModuleDiscoverQuerySchema,\n //ModuleManifestQuerySchema,\n //ModuleSubscribeQuerySchema,\n]\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsModuleFactory<Module>()\n\nexport const isModule: TypeCheck<Module> = factory.create(requiredModuleQueries, [isModuleObject])\n","import { Promisable } from '@xylabs/promise'\nimport { IsObjectFactory, TypeCheck } from '@xyo-network/object'\n\nimport { ModuleEventData } from '../EventsModels'\nimport { Module, ModuleQueryFunctions } from '../module'\nimport { ModuleParams } from '../ModuleParams'\n\nexport interface ResolveFunctions {\n resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter<T>, options?: ModuleFilterOptions<T>): Promisable<T[]>\n resolve<T extends ModuleInstance = ModuleInstance>(nameOrAddress: string, options?: ModuleFilterOptions<T>): Promisable<T | undefined>\n resolve<T extends ModuleInstance = ModuleInstance>(\n nameOrAddressOrFilter?: ModuleFilter<T> | string,\n options?: ModuleFilterOptions<T>,\n ): Promisable<T | T[] | undefined>\n}\n\nexport interface ModuleResolver extends ResolveFunctions {\n addResolver: (resolver: ModuleResolver) => this\n isModuleResolver: boolean\n removeResolver: (resolver: ModuleResolver) => this\n}\n\nexport type ModuleInstance<TParams extends ModuleParams = ModuleParams, TEventData extends ModuleEventData = ModuleEventData> = Module<\n TParams,\n TEventData\n> &\n ResolveFunctions &\n ModuleQueryFunctions & {\n /* The resolver is a 'down' resolver. It can resolve the module or any children (if it is a node for example), that are in the module*/\n readonly downResolver: Omit<ModuleResolver, 'resolve'>\n\n /* The resolver is a 'up' resolver. It can resolve the parent or any children of the parent*/\n /* This is set by a NodeModule when attaching to the module */\n readonly upResolver: Omit<ModuleResolver, 'resolve'>\n }\n\nexport type InstanceTypeCheck<T extends ModuleInstance = ModuleInstance> = TypeCheck<T>\n\nexport class IsInstanceFactory<T extends ModuleInstance = ModuleInstance> extends IsObjectFactory<T> {}\n\nexport interface ModuleFilterOptions<T extends ModuleInstance = ModuleInstance> {\n direction?: 'up' | 'down' | 'all'\n identity?: InstanceTypeCheck<T>\n maxDepth?: number\n visibility?: 'public' | 'private' | 'all'\n}\n\nexport interface AddressModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n address: string[]\n}\n\nexport interface NameModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n name: string[]\n}\n\nexport interface QueryModuleFilter<T extends ModuleInstance = ModuleInstance> extends ModuleFilterOptions<T> {\n query: string[][]\n}\n\nexport type AnyModuleFilter<T extends ModuleInstance = ModuleInstance> = Partial<AddressModuleFilter<T>> &\n Partial<NameModuleFilter<T>> &\n Partial<QueryModuleFilter<T>>\n\nexport type ModuleFilter<T extends ModuleInstance = ModuleInstance> =\n | ModuleFilterOptions<T>\n | AddressModuleFilter<T>\n | NameModuleFilter<T>\n | QueryModuleFilter<T>\n","import { Module } from '../module'\n\n/**\n * Used to filter duplicates from an array of modules\n * @example: modulesArray.filter(duplicateModules)\n * @param value Current Module\n * @param index Current Module's index\n * @param array Module Array\n * @returns True if the Module's address is the first occurrence of\n * that address in the array, false otherwise\n */\nexport const duplicateModules = (value: Module, index: number, array: Module[]): value is Module => {\n return array.findIndex((v) => v.address === value.address) === index\n}\n","// Inspired by https://stackoverflow.com/a/49079549/2803259\n\nimport { every, isArray, isBoolean, isNull, isNumber, isPlainObject, isString, isUndefined, overSome } from '@xylabs/lodash'\n\nconst JSONPrimitiveChecks = [isUndefined, isNull, isBoolean, isNumber, isString]\nconst JSONComplexChecks = [isPlainObject, isArray]\n\nexport const serializable = (field: unknown, depth?: number): boolean | null => {\n let depthExceeded = false\n const decrementDepth = () => (depth ? depth-- : undefined)\n\n const recursiveSerializable = (field: unknown) => {\n if (depth !== undefined && depth < 1) {\n depthExceeded = true\n return false\n }\n\n // decrement during every recursion\n decrementDepth()\n\n const nestedSerializable = (field: unknown): boolean => overSome(JSONComplexChecks)(field) && every(field as object, recursiveSerializable)\n\n return overSome([...JSONPrimitiveChecks, nestedSerializable])(field)\n }\n\n const valid = recursiveSerializable(field)\n\n return depthExceeded ? null : valid\n}\n\nexport const serializableField = (field: unknown) => {\n return overSome([...JSONPrimitiveChecks, ...JSONComplexChecks])(field)\n}\n","import { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nexport interface StateDictionary {\n [key: string]: string | number | undefined\n}\nexport interface State<T extends StateDictionary = StateDictionary> {\n state: T\n}\n\nexport const ModuleStateSchema = 'network.xyo.module.state' as const\nexport type ModuleStateSchema = typeof ModuleStateSchema\n\nexport type ModuleState<T extends StateDictionary = StateDictionary> = Payload<State<T>, ModuleStateSchema>\n\nexport const isModuleState = <T extends StateDictionary = StateDictionary>(payload?: Payload | null): payload is ModuleState<T> => {\n return isPayloadOfSchemaType<ModuleState<T>>(ModuleStateSchema)(payload)\n}\n","import { TypeCheck } from '@xyo-network/object'\n\nimport { isModuleInstance } from './instance'\nimport { isModule } from './module'\n\nexport const WithFactory = {\n create: <T extends object>(typeCheck: TypeCheck<T>) => {\n return <R>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n module: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n closure: (module: T) => R,\n ): R | undefined => {\n return typeCheck(module) ? closure(module) : undefined\n }\n },\n}\n\nexport const withModule = WithFactory.create(isModule)\nexport const withModuleInstance = WithFactory.create(isModuleInstance)\n"],"mappings":";AAOO,IAAM,qBAAyC;;;ACkB/C,SAAS,kBAAmE;AACjF,SAAO,CAAqC,gBAAmB;AAC7D;AAAA,EACF;AACF;;;ACrBO,IAAM,4BAA4B,CAAC,SAAuF;AAC/H,SAAO,OAAO,QAAQ,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQA,QAAO,MAAM;AAClE,aAAS,MAAM,IAAI,MAAM,QAAQA,QAAO,IAAIA,WAAU,CAACA,QAAO;AAC9D,WAAO;AAAA,EACT,GAAG,CAAC,CAA4B;AAClC;AAEO,IAAM,gCAAgC,CAC3C,SAAkC,CAAC,MAChC,YACyB;AAC5B,UAAQ;AAAA,IAAI,CAAC,WACX,OAAO,QAAQ,MAA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,MAAM,OAAO,MAAM;AACjE;;;ACXA,SAAS,OAAO,SAAS,WAAW,QAAQ,UAAU,eAAe,UAAU,aAAa,gBAAgB;AAE5G,IAAM,sBAAsB,CAAC,aAAa,QAAQ,WAAW,UAAU,QAAQ;AAC/E,IAAM,oBAAoB,CAAC,eAAe,OAAO;AAE1C,IAAM,eAAe,CAAC,OAAgB,UAAmC;AAC9E,MAAI,gBAAgB;AACpB,QAAM,iBAAiB,MAAO,QAAQ,UAAU;AAEhD,QAAM,wBAAwB,CAACC,WAAmB;AAChD,QAAI,UAAU,UAAa,QAAQ,GAAG;AACpC,sBAAgB;AAChB,aAAO;AAAA,IACT;AAGA,mBAAe;AAEf,UAAM,qBAAqB,CAACA,WAA4B,SAAS,iBAAiB,EAAEA,MAAK,KAAK,MAAMA,QAAiB,qBAAqB;AAE1I,WAAO,SAAS,CAAC,GAAG,qBAAqB,kBAAkB,CAAC,EAAEA,MAAK;AAAA,EACrE;AAEA,QAAM,QAAQ,sBAAsB,KAAK;AAEzC,SAAO,gBAAgB,OAAO;AAChC;AAEO,IAAM,oBAAoB,CAAC,UAAmB;AACnD,SAAO,SAAS,CAAC,GAAG,qBAAqB,GAAG,iBAAiB,CAAC,EAAE,KAAK;AACvE;;;AChCA,SAAS,6BAAsC;AASxC,IAAM,oBAAoB;AAK1B,IAAM,gBAAgB,CAA8C,YAAwD;AACjI,SAAO,sBAAsC,iBAAiB,EAAE,OAAO;AACzE;;;ACXO,IAAM,cAAc;AAAA,EACzB,QAAQ,CAAmB,cAA4B;AACrD,WAAO,CAEL,QAEA,YACkB;AAClB,aAAO,UAAU,MAAM,IAAI,QAAQ,MAAM,IAAI;AAAA,IAC/C;AAAA,EACF;AACF;AAEO,IAAM,aAAa,YAAY,OAAO,QAAQ;AAC9C,IAAM,qBAAqB,YAAY,OAAO,gBAAgB;","names":["factory","factory","creatableModule","factory","assertEx","assertEx","factory","AsObjectFactory","IsObjectFactory","AsObjectFactory","factory","AsObjectFactory","factory","IsObjectFactory","AsObjectFactory","IsObjectFactory","field"]}