@xyo-network/module-model 2.98.2 → 2.98.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/browser/CreatableModule/index.d.cts +0 -1
  2. package/dist/browser/CreatableModule/index.d.cts.map +1 -1
  3. package/dist/browser/CreatableModule/index.d.mts +0 -1
  4. package/dist/browser/CreatableModule/index.d.mts.map +1 -1
  5. package/dist/browser/CreatableModule/index.d.ts +0 -1
  6. package/dist/browser/CreatableModule/index.d.ts.map +1 -1
  7. package/dist/browser/index.cjs +15 -101
  8. package/dist/browser/index.cjs.map +1 -1
  9. package/dist/browser/index.js +15 -101
  10. package/dist/browser/index.js.map +1 -1
  11. package/dist/node/CreatableModule/index.d.cts +0 -1
  12. package/dist/node/CreatableModule/index.d.cts.map +1 -1
  13. package/dist/node/CreatableModule/index.d.mts +0 -1
  14. package/dist/node/CreatableModule/index.d.mts.map +1 -1
  15. package/dist/node/CreatableModule/index.d.ts +0 -1
  16. package/dist/node/CreatableModule/index.d.ts.map +1 -1
  17. package/dist/node/index.cjs +15 -102
  18. package/dist/node/index.cjs.map +1 -1
  19. package/dist/node/index.js +15 -101
  20. package/dist/node/index.js.map +1 -1
  21. package/package.json +7 -7
  22. package/src/CreatableModule/index.ts +0 -1
  23. package/dist/browser/CreatableModule/ModuleFactoryLocator.d.cts +0 -47
  24. package/dist/browser/CreatableModule/ModuleFactoryLocator.d.cts.map +0 -1
  25. package/dist/browser/CreatableModule/ModuleFactoryLocator.d.mts +0 -47
  26. package/dist/browser/CreatableModule/ModuleFactoryLocator.d.mts.map +0 -1
  27. package/dist/browser/CreatableModule/ModuleFactoryLocator.d.ts +0 -47
  28. package/dist/browser/CreatableModule/ModuleFactoryLocator.d.ts.map +0 -1
  29. package/dist/node/CreatableModule/ModuleFactoryLocator.d.cts +0 -47
  30. package/dist/node/CreatableModule/ModuleFactoryLocator.d.cts.map +0 -1
  31. package/dist/node/CreatableModule/ModuleFactoryLocator.d.mts +0 -47
  32. package/dist/node/CreatableModule/ModuleFactoryLocator.d.mts.map +0 -1
  33. package/dist/node/CreatableModule/ModuleFactoryLocator.d.ts +0 -47
  34. package/dist/node/CreatableModule/ModuleFactoryLocator.d.ts.map +0 -1
  35. package/src/CreatableModule/ModuleFactoryLocator.ts +0 -96
@@ -111,100 +111,6 @@ var _ModuleFactory = class _ModuleFactory {
111
111
  __name(_ModuleFactory, "ModuleFactory");
112
112
  var ModuleFactory = _ModuleFactory;
113
113
 
114
- // src/CreatableModule/ModuleFactoryLocator.ts
115
- import { assertEx as assertEx2 } from "@xylabs/assert";
116
-
117
- // src/Labels/Labels.ts
118
- var hasAllLabels = /* @__PURE__ */ __name((source, required) => {
119
- if (!required)
120
- return true;
121
- return Object.entries(required).every(([key, value]) => {
122
- return (source == null ? void 0 : source.hasOwnProperty(key)) && (source == null ? void 0 : source[key]) === value;
123
- });
124
- }, "hasAllLabels");
125
-
126
- // src/CreatableModule/ModuleFactoryLocator.ts
127
- var _ModuleFactoryLocator = class _ModuleFactoryLocator {
128
- _registry;
129
- constructor(_registry = {}) {
130
- this._registry = _registry;
131
- }
132
- /**
133
- * The current registry for the module factory
134
- */
135
- get registry() {
136
- return this._registry;
137
- }
138
- /**
139
- * Locates a module factory that matches the supplied schema and labels
140
- * @param schema The config schema for the module
141
- * @param labels The labels for the module factory
142
- * @returns A module factory that matches the supplied schema and labels or throws if one is not found
143
- */
144
- locate(schema, labels) {
145
- return assertEx2(this.tryLocate(schema, labels), () => `No module factory for the supplied ${`config schema [${schema}]`}${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} registered`);
146
- }
147
- /**
148
- * Registers a single module factory (with optional tags) with the locator
149
- * @param additional Additional module factories to register
150
- */
151
- register(mod, labels) {
152
- this.registerOne(mod, mod.defaultConfigSchema, labels, true);
153
- mod.configSchemas.map((schema) => {
154
- this.registerOne(mod, schema, labels, false);
155
- });
156
- return this;
157
- }
158
- /**
159
- * Registers multiple module factories with the locator
160
- * @param additional Additional module factories to register
161
- */
162
- registerMany(mods) {
163
- for (const mod of mods) {
164
- this.register(mod);
165
- }
166
- return this;
167
- }
168
- /**
169
- * Registers a single module factory (with optional tags) with the locator & a specific schema
170
- * @param additional Additional module factories to register
171
- */
172
- registerOne(mod, schema, labels, primary = false) {
173
- const existingFactories = this._registry[schema];
174
- const factory5 = {
175
- // Destructure instance properties
176
- ...mod,
177
- // Copy static methods
178
- create: mod.create.bind(mod),
179
- // Merge module & supplied labels
180
- labels: Object.assign({}, mod.labels ?? {}, labels ?? {})
181
- };
182
- this._registry[schema] = primary ? [
183
- factory5,
184
- ...existingFactories ?? []
185
- ] : [
186
- ...existingFactories ?? [],
187
- factory5
188
- ];
189
- return this;
190
- }
191
- /**
192
- * Tries to locate a module factory that matches the supplied schema and labels
193
- * @param schema The config schema for the module
194
- * @param labels The labels for the module factory
195
- * @returns A module factory that matches the supplied schema and labels or undefined
196
- */
197
- tryLocate(schema, labels) {
198
- var _a, _b;
199
- return labels ? (
200
- // Find the first factory that has labels and has all the labels provided
201
- (_a = this._registry[schema]) == null ? void 0 : _a.filter(hasLabels).find((factory5) => hasAllLabels(factory5 == null ? void 0 : factory5.labels, labels))
202
- ) : (_b = this._registry[schema]) == null ? void 0 : _b[0];
203
- }
204
- };
205
- __name(_ModuleFactoryLocator, "ModuleFactoryLocator");
206
- var ModuleFactoryLocator = _ModuleFactoryLocator;
207
-
208
114
  // src/instance/asModuleInstance.ts
209
115
  import { AsObjectFactory as AsObjectFactory3 } from "@xylabs/object";
210
116
 
@@ -351,6 +257,15 @@ var ObjectResolverPriority;
351
257
  // src/instance/ModuleResolver.ts
352
258
  var isModuleResolver = isObjectResolver;
353
259
 
260
+ // src/Labels/Labels.ts
261
+ var hasAllLabels = /* @__PURE__ */ __name((source, required) => {
262
+ if (!required)
263
+ return true;
264
+ return Object.entries(required).every(([key, value]) => {
265
+ return (source == null ? void 0 : source.hasOwnProperty(key)) && (source == null ? void 0 : source[key]) === value;
266
+ });
267
+ }, "hasAllLabels");
268
+
354
269
  // src/lib/duplicateModules.ts
355
270
  var duplicateModules = /* @__PURE__ */ __name((value, index, array) => {
356
271
  return array.findIndex((v) => v.address === value.address) === index;
@@ -512,18 +427,18 @@ var resolveAddressToInstance = /* @__PURE__ */ __name(async (root, address, incl
512
427
  }, "resolveAddressToInstance");
513
428
 
514
429
  // src/ResolveHelper/ResolveHelper.ts
515
- import { assertEx as assertEx4 } from "@xylabs/assert";
430
+ import { assertEx as assertEx3 } from "@xylabs/assert";
516
431
  import { exists } from "@xylabs/exists";
517
432
  import { isAddress as isAddress2 } from "@xylabs/hex";
518
433
  import { IdLogger } from "@xylabs/logger";
519
434
  import { toJsonString as toJsonString2 } from "@xylabs/object";
520
435
 
521
436
  // src/ResolveHelper/traceModuleIdentifier.ts
522
- import { assertEx as assertEx3 } from "@xylabs/assert";
437
+ import { assertEx as assertEx2 } from "@xylabs/assert";
523
438
  var traceModuleIdentifier = /* @__PURE__ */ __name(async (resolver, path) => {
524
439
  const parts = path.split(":");
525
440
  const first = parts.shift();
526
- const firstModule = asModuleInstance(assertEx3(await resolver.resolve(first, {
441
+ const firstModule = asModuleInstance(assertEx2(await resolver.resolve(first, {
527
442
  maxDepth: 1
528
443
  }), () => `Failed to resolve [${first}]`), () => `Resolved invalid module instance [${first}]`);
529
444
  if (firstModule) {
@@ -649,7 +564,7 @@ var _ResolveHelper = class _ResolveHelper {
649
564
  }) ?? (first ? await resolver.resolvePrivate(first, {
650
565
  maxDepth: firstIsAddress ? 10 : 1
651
566
  }) : void 0);
652
- const finalModule = required ? assertEx4(resolvedModule, () => `Failed to resolve [${first}] [${firstIsAddress}]`) : resolvedModule;
567
+ const finalModule = required ? assertEx3(resolvedModule, () => `Failed to resolve [${first}] [${firstIsAddress}]`) : resolvedModule;
653
568
  const firstModule = asModuleInstance(finalModule, () => `Resolved invalid module instance [${first}]`);
654
569
  if (firstModule) {
655
570
  return parts.length > 0 ? await this.resolveModuleIdentifier(firstModule, parts.join(":")) : firstModule;
@@ -707,11 +622,11 @@ var resolveLocalNameToAddress = /* @__PURE__ */ __name(async (root, localName, i
707
622
  }, "resolveLocalNameToAddress");
708
623
 
709
624
  // src/ResolveHelper/resolvePathToAddress.ts
710
- import { assertEx as assertEx5 } from "@xylabs/assert";
625
+ import { assertEx as assertEx4 } from "@xylabs/assert";
711
626
  import { asAddress } from "@xylabs/hex";
712
627
  var resolvePathToAddress = /* @__PURE__ */ __name(async (root, path, includePrivate = false, transformers = ResolveHelper.transformers) => {
713
628
  const parts = path.split(MODULE_PATH_SEPARATOR);
714
- const first = await transformModuleIdentifier(assertEx5(parts.shift(), () => `First part is invalid [${path}]`), transformers);
629
+ const first = await transformModuleIdentifier(assertEx4(parts.shift(), () => `First part is invalid [${path}]`), transformers);
715
630
  if (!first) {
716
631
  return void 0;
717
632
  }
@@ -747,7 +662,6 @@ export {
747
662
  ModuleConfigSchema,
748
663
  ModuleDescriptionSchema,
749
664
  ModuleFactory,
750
- ModuleFactoryLocator,
751
665
  ModuleManifestQuerySchema,
752
666
  ModuleStateQuerySchema,
753
667
  ModuleStateSchema,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Config/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/Manifest.ts","../../src/Queries/ModuleAddress/Query.ts","../../src/Queries/State.ts","../../src/Queries/Subscribe.ts","../../src/module/asModuleObject.ts","../../src/module/isModuleObject.ts","../../src/module/IsModuleFactory.ts","../../src/module/isModule.ts","../../src/instance/attachable/asAttachableInstance.ts","../../src/instance/attachable/isAttachableInstance.ts","../../src/instance/attachable/AttachableInstance.ts","../../src/instance/Instance.ts","../../src/instance/ObjectFilter.ts","../../src/instance/ModuleFilter.ts","../../src/instance/ObjectResolver.ts","../../src/instance/ModuleResolver.ts","../../src/lib/duplicateModules.ts","../../src/lib/serializable.ts","../../src/ModuleIdentifier.ts","../../src/Payload/AddressPreviousHash.ts","../../src/Payload/Description.ts","../../src/Payload/ModuleState.ts","../../src/ResolveHelper/resolveAddressToInstance.ts","../../src/ResolveHelper/ResolveHelper.ts","../../src/ResolveHelper/traceModuleIdentifier.ts","../../src/ResolveHelper/transformModuleIdentifier.ts","../../src/ResolveHelper/resolveLocalNameToAddress.ts","../../src/ResolveHelper/resolvePathToAddress.ts","../../src/withModule.ts"],"sourcesContent":["import { EmptyObject, WithAdditional } from '@xylabs/object'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { ArchivingModuleConfig } from './Archiving'\nimport { ModuleConfigFields } from './Fields'\n\nexport type ModuleConfigSchema = 'network.xyo.module.config'\nexport const ModuleConfigSchema: ModuleConfigSchema = 'network.xyo.module.config'\n\nexport type ModuleConfig<TConfig extends EmptyObject | Payload | void = void, TSchema extends Schema | void = void> = Payload<\n WithAdditional<ArchivingModuleConfig & ModuleConfigFields, TConfig>,\n TSchema extends Schema ? TSchema\n : TConfig extends Payload ? TConfig['schema']\n : ModuleConfigSchema\n>\n\nexport type AnyConfigSchema<TConfig extends Omit<ModuleConfig, 'schema'> & { schema: string } = Omit<ModuleConfig, 'schema'> & { schema: string }> =\n ModuleConfig<TConfig, string>\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'\nimport { Schema } from '@xyo-network/payload-model'\n\nimport { AttachableModuleInstance } from '../instance'\n\nexport type CreatableModuleFactory<T extends AttachableModuleInstance = AttachableModuleInstance> = Omit<\n Omit<CreatableModule<T>, 'new'>,\n 'create'\n> & {\n create<T extends AttachableModuleInstance>(this: CreatableModuleFactory<T>, params?: T['params']): Promise<T>\n}\n\nexport interface CreatableModule<T extends AttachableModuleInstance = AttachableModuleInstance> {\n configSchemas: Schema[]\n defaultConfigSchema: Schema\n defaultLogger?: Logger\n new (privateConstructorKey: string, params: T['params'], account: AccountInstance): T\n _noOverride(functionName: string): void\n create<T extends AttachableModuleInstance>(this: CreatableModule<T>, params?: T['params']): Promise<T>\n factory<T extends AttachableModuleInstance>(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 AttachableModuleInstance = AttachableModuleInstance>() {\n return <U extends CreatableModule<TModule>>(constructor: U) => {\n constructor\n }\n}\n","import { Schema } from '@xyo-network/payload-model'\n\nimport { CreatableModuleFactory } from './CreatableModule'\nimport { LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\nexport interface CreatableModuleRegistry {\n [key: string]: (CreatableModuleFactory | LabeledCreatableModuleFactory)[] | undefined\n}\n\nexport const registerCreatableModuleFactory = (\n registry: CreatableModuleRegistry,\n factory: CreatableModuleFactory | LabeledCreatableModuleFactory,\n) => {\n //add the defaultConfigSchema as the first key in the registry\n registry[factory.defaultConfigSchema] = [factory, ...(registry[factory.defaultConfigSchema] ?? [])]\n for (const schema of factory.configSchemas) {\n registry[schema] = [...(registry[schema] ?? []), factory]\n }\n}\n\nexport const registerPrimaryCreatableModuleFactory = (\n registry: CreatableModuleRegistry,\n factory: CreatableModuleFactory | LabeledCreatableModuleFactory,\n configSchema: Schema,\n) => {\n registry[configSchema] = [factory, ...(registry[configSchema] ?? [])]\n}\n\nexport const registerCreatableModuleFactories = (\n factories: (CreatableModuleFactory | LabeledCreatableModuleFactory)[],\n registry: CreatableModuleRegistry = {},\n) => {\n for (const factory of factories) {\n registerCreatableModuleFactory(registry, factory)\n }\n return registry\n}\n\n/** @deprecated use registerCreatableModuleFactory instead */\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 { AttachableModuleInstance } from '../instance'\nimport { WithOptionalLabels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\n\nexport type LabeledCreatableModuleFactory<T extends AttachableModuleInstance = AttachableModuleInstance> = CreatableModuleFactory<T> &\n 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'\nimport { Schema } from '@xyo-network/payload-model'\n\nimport { AttachableModuleInstance } from '../instance'\nimport { Labels, WithOptionalLabels } from '../Labels'\nimport { CreatableModule, CreatableModuleFactory } from './CreatableModule'\n\nexport class ModuleFactory<TModule extends AttachableModuleInstance> implements CreatableModuleFactory<TModule> {\n configSchemas: CreatableModuleFactory<TModule>['configSchemas']\n\n creatableModule: CreatableModule<TModule>\n\n defaultConfigSchema: Schema\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.defaultConfigSchema = creatableModule.defaultConfigSchema\n assertEx(this.configSchemas.includes(this.defaultConfigSchema), () => 'defaultConfigSchema must be in configSchemas')\n this.labels = Object.assign({}, (creatableModule as WithOptionalLabels).labels ?? {}, labels ?? {})\n }\n\n static withParams<T extends AttachableModuleInstance>(\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 AttachableModuleInstance>(this: CreatableModuleFactory<T>, params?: TModule['params'] | undefined): Promise<T> {\n const factory = this as ModuleFactory<T>\n const schema = factory.creatableModule.defaultConfigSchema\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 AttachableModuleInstance>(this: CreatableModule<T>, _params?: T['params'] | undefined): CreatableModuleFactory<T> {\n throw new Error('Method not implemented.')\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Schema } from '@xyo-network/payload-model'\n\nimport { AttachableModuleInstance } 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(\n this.tryLocate(schema, labels),\n () => `No module factory for the supplied ${`config schema [${schema}]`}${labels ? ` & labels [${JSON.stringify(labels)}]` : ''} 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(mod: CreatableModuleFactory, labels?: Labels): this {\n this.registerOne(mod, mod.defaultConfigSchema, labels, true)\n mod.configSchemas.map((schema) => {\n this.registerOne(mod, schema, labels, false)\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(mods: CreatableModuleFactory[]): this {\n for (const mod of mods) {\n this.register(mod)\n }\n return this\n }\n\n /**\n * Registers a single module factory (with optional tags) with the locator & a specific schema\n * @param additional Additional module factories to register\n */\n registerOne<TModule extends AttachableModuleInstance>(\n mod: CreatableModuleFactory<TModule>,\n schema: Schema,\n labels?: Labels,\n primary = false,\n ): this {\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] = primary ? [factory, ...(existingFactories ?? [])] : [...(existingFactories ?? []), factory]\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 '@xylabs/object'\n\nimport { isModuleInstance } from './isModuleInstance'\n\nexport const asModuleInstance = AsObjectFactory.create(isModuleInstance)\n","import { IsObjectFactory, ObjectTypeShape, TypeCheck } from '@xylabs/object'\n\nimport { isModule } from '../module'\nimport { ModuleInstance } from './Instance'\n\nexport const requiredModuleInstanceFunctions: ObjectTypeShape = {\n manifest: 'function',\n state: '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 '@xylabs/object'\n\nimport { isModule } from './isModule'\n\nexport const asModule = AsObjectFactory.create(isModule)\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 { 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 const ModuleStateQuerySchema = 'network.xyo.query.module.state'\nexport type ModuleStateQuerySchema = typeof ModuleStateQuerySchema\n\nexport type ModuleStateQuery = Query<void, ModuleStateQuerySchema>\n","import { Address } from '@xylabs/hex'\nimport { 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: Address\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 '@xylabs/object'\n\nimport { isModuleObject } from './isModuleObject'\n\nexport const asModuleObject = AsObjectFactory.create(isModuleObject)\n","import { IsObjectFactory, ObjectTypeShape } from '@xylabs/object'\n\nimport { Module } from './Module'\n\nexport const requiredModuleShape: ObjectTypeShape = {\n address: 'string',\n queries: 'array',\n query: 'function',\n}\n\nconst factory = new IsObjectFactory<Module>()\n\nexport const isModuleObject = factory.create(requiredModuleShape)\n","import { AnyObject, EmptyObject, TypeCheck } from '@xylabs/object'\nimport { AnyNonPromise } from '@xylabs/promise'\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: AnyNonPromise, 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 '@xylabs/object'\nimport { Schema } from '@xyo-network/payload-model'\n\nimport { ModuleStateQuerySchema } from '../Queries'\nimport { IsModuleFactory } from './IsModuleFactory'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport const requiredModuleQueries: Schema[] = [ModuleStateQuerySchema]\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 { AsObjectFactory } from '@xylabs/object'\n\nimport { isAttachableModuleInstance } from './isAttachableInstance'\n\nexport const asAttachableModuleInstance = AsObjectFactory.create(isAttachableModuleInstance)\n","import { IsObjectFactory, ObjectTypeShape, TypeCheck } from '@xylabs/object'\n\nimport { isModuleInstance } from '../isModuleInstance'\nimport { AttachableModuleInstance } from './AttachableInstance'\n\nexport const requiredAttachableModuleInstanceFunctions: ObjectTypeShape = {\n downResolver: 'object',\n upResolver: 'object',\n}\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsObjectFactory<AttachableModuleInstance>()\n\nexport const isAttachableModuleInstance: TypeCheck<AttachableModuleInstance> = factory.create(requiredAttachableModuleInstanceFunctions, [\n isModuleInstance,\n])\n","import { IsObjectFactory, TypeCheck } from '@xylabs/object'\n\nimport { ModuleEventData } from '../../EventsModels'\nimport { ModuleParams } from '../../ModuleParams'\nimport { ModuleInstance } from '../Instance'\nimport { ModuleResolverInstance } from '../ModuleResolver'\n\nexport interface AttachableModuleInstance<TParams extends ModuleParams = ModuleParams, TEventData extends ModuleEventData = ModuleEventData>\n extends ModuleInstance<TParams, TEventData> {\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: ModuleResolverInstance\n\n // The resolver that gets called by children (usually only Nodes have this)\n readonly privateResolver: ModuleResolverInstance\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: ModuleResolverInstance\n}\n\nexport type AttachableModuleInstanceTypeCheck<T extends AttachableModuleInstance = AttachableModuleInstance> = TypeCheck<T>\n\nexport class IsAttachableModuleInstanceFactory<T extends AttachableModuleInstance = AttachableModuleInstance> extends IsObjectFactory<T> {}\n","import { Address } from '@xylabs/hex'\nimport { IsObjectFactory, toJsonString, TypeCheck } from '@xylabs/object'\nimport { Promisable } from '@xylabs/promise'\n\nimport { ModuleEventData } from '../EventsModels'\nimport { Module, ModuleQueryFunctions } from '../module'\nimport { ModuleIdentifier, ModuleName } from '../ModuleIdentifier'\nimport { ModuleParams } from '../ModuleParams'\nimport { Direction } from './ObjectFilter'\nimport { ObjectResolver } from './ObjectResolver'\n\nexport type ModulePipeLine = Lowercase<'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many'>\n\nexport type ModuleStatus = 'started' | 'stopped' | 'dead' | 'wrapped' | 'proxy'\n\nexport class DeadModuleError extends Error {\n constructor(\n public id: ModuleIdentifier,\n public error: Error | undefined,\n msg = 'Dead Module Error',\n ) {\n super(`${msg} [${id}]: ${error?.message ?? toJsonString(error)}`)\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, DeadModuleError.prototype)\n }\n}\n\nexport interface AddressToWeakInstanceCache {\n get: (address: Address) => WeakRef<ModuleInstance> | null\n set: (address: Address, instance: WeakRef<ModuleInstance> | null) => void\n}\n\nexport interface ModuleFamilyFunctions {\n addParent: (module: ModuleInstance) => void\n addressCache?: (direction: Direction, includePrivate: boolean) => AddressToWeakInstanceCache | undefined\n localName: ModuleName | undefined\n parents: () => Promisable<ModuleInstance[]>\n privateChildren: () => Promisable<ModuleInstance[]>\n publicChildren: () => Promisable<ModuleInstance[]>\n removeParent: (address: Address) => void\n siblings: () => Promisable<ModuleInstance[]>\n}\n\nexport interface ModuleInstance<TParams extends ModuleParams = ModuleParams, TEventData extends ModuleEventData = ModuleEventData>\n extends Module<TParams, TEventData>,\n ObjectResolver<ModuleInstance>,\n ModuleQueryFunctions,\n ModuleFamilyFunctions {\n readonly pipeline?: ModulePipeLine\n\n //if the module has become non-functional, such as a broken bridge connection, this will be 'dead'\n readonly status: ModuleStatus\n}\n\nexport type InstanceTypeCheck<T extends ModuleInstance = ModuleInstance> = TypeCheck<T>\n\nexport class IsInstanceFactory<T extends ModuleInstance = ModuleInstance> extends IsObjectFactory<T> {}\n","import { Address } from '@xylabs/hex'\nimport { AnyObject, EmptyObject, TypeCheck } from '@xylabs/object'\n\nimport { ModuleName } from '../ModuleIdentifier'\n\nexport type Direction = 'up' | 'down' | 'all'\nexport type Visibility = 'public' | 'private' | 'all'\n\nexport interface ResolveStrategy {\n maxDepth?: number\n required?: boolean | 'warn' | 'log'\n retry?: number\n timeout?: number\n}\n\nexport interface ObjectFilterOptions<T extends EmptyObject = AnyObject> extends ResolveStrategy {\n direction?: Direction\n identity?: TypeCheck<T>\n}\n\nexport interface AddressObjectFilter<T extends EmptyObject = AnyObject> extends ObjectFilterOptions<T> {\n address: Address[]\n}\n\nexport const isAddressObjectFilter = <T extends EmptyObject = AnyObject>(value: unknown): value is AddressObjectFilter<T> =>\n (value as AddressObjectFilter<T>).address !== undefined\n\nexport interface NameObjectFilter<T extends EmptyObject = AnyObject> extends ObjectFilterOptions<T> {\n name: ModuleName[]\n}\n\nexport const isNameObjectFilter = <T extends EmptyObject = AnyObject>(value: unknown): value is NameObjectFilter<T> =>\n (value as NameObjectFilter<T>).name !== undefined\n\nexport interface QueryObjectFilter<T extends EmptyObject = AnyObject> extends ObjectFilterOptions<T> {\n query: string[][]\n}\n\nexport const isQueryObjectFilter = <T extends EmptyObject = AnyObject>(value: unknown): value is QueryObjectFilter<T> =>\n (value as QueryObjectFilter<T>).query !== undefined\n\nexport type AnyObjectFilter<T extends EmptyObject = AnyObject> = Partial<AddressObjectFilter<T>> &\n Partial<NameObjectFilter<T>> &\n Partial<QueryObjectFilter<T>>\n\nexport type ObjectFilter<T extends EmptyObject> = ObjectFilterOptions<T> | AddressObjectFilter<T> | NameObjectFilter<T> | QueryObjectFilter<T>\n","import { ModuleInstance } from './Instance'\nimport {\n AddressObjectFilter,\n AnyObjectFilter,\n isAddressObjectFilter,\n isNameObjectFilter,\n isQueryObjectFilter,\n NameObjectFilter,\n ObjectFilter,\n ObjectFilterOptions,\n QueryObjectFilter,\n} from './ObjectFilter'\n\nexport interface ModuleFilterOptions<T extends ModuleInstance = ModuleInstance> extends ObjectFilterOptions<T> {}\n\nexport const isAddressModuleFilter = isAddressObjectFilter<ModuleInstance>\n\nexport const isNameModuleFilter = isNameObjectFilter<ModuleInstance>\n\nexport const isQueryModuleFilter = isQueryObjectFilter<ModuleInstance>\n\nexport type AnyModuleFilter<T extends ModuleInstance = ModuleInstance> = AnyObjectFilter<T>\n\nexport type AddressModuleFilter<T extends ModuleInstance = ModuleInstance> = AddressObjectFilter<T>\n\nexport type NameModuleFilter<T extends ModuleInstance = ModuleInstance> = NameObjectFilter<T>\n\nexport type QueryModuleFilter<T extends ModuleInstance = ModuleInstance> = QueryObjectFilter<T>\n\nexport type ModuleFilter<T extends ModuleInstance = ModuleInstance> = ObjectFilter<T>\n","import { AnyObject, EmptyObject } from '@xylabs/object'\nimport { Promisable } from '@xylabs/promise'\n\nimport { ModuleIdentifier } from '../ModuleIdentifier'\nimport { ObjectFilter, ObjectFilterOptions } from './ObjectFilter'\n\nexport const isObjectResolver = <T extends EmptyObject = AnyObject>(value?: unknown): value is ObjectResolver<T> => {\n // eslint-disable-next-line deprecation/deprecation\n return typeof (value as Partial<ObjectResolver<T>>).resolve === 'function'\n}\n\nexport enum ObjectResolverPriority {\n Disabled = -1,\n VeryLow = 0,\n Low = 1,\n Normal = 2,\n High = 3,\n VeryHigh = 4,\n}\n\nexport interface ObjectResolver<TResult extends EmptyObject> {\n priority: ObjectResolverPriority\n /** @deprecated do not pass undefined. If trying to get all, pass '*' */\n resolve<T extends TResult = TResult>(): Promisable<T | undefined>\n resolve<T extends TResult = TResult>(all: '*', options?: ObjectFilterOptions<T>): Promisable<T[]>\n resolve<T extends TResult = TResult>(id: ModuleIdentifier, options?: ObjectFilterOptions<T>): Promisable<T | undefined>\n resolve<T extends TResult = TResult>(filter: ObjectFilter<T>, options?: ObjectFilterOptions<T>): Promisable<T[]>\n /** @deprecated do not pass undefined. If trying to get all, pass '*' */\n resolve<T extends TResult = TResult>(filter?: ObjectFilter<T>, options?: ObjectFilterOptions<T>): Promisable<T[]>\n resolve<T extends TResult = TResult>(\n idOrFilter?: ObjectFilter<T> | ModuleIdentifier,\n options?: ObjectFilterOptions<T>,\n ): Promisable<T | T[] | undefined>\n\n resolvePrivate<T extends TResult = TResult>(all: '*', options?: ObjectFilterOptions<T>): Promise<T[]>\n resolvePrivate<T extends TResult = TResult>(id: ModuleIdentifier, options?: ObjectFilterOptions<T>): Promise<T | undefined>\n resolvePrivate<T extends TResult = TResult>(id: ModuleIdentifier, options?: ObjectFilterOptions<T>): Promise<T | T[] | undefined>\n}\n\nexport interface ObjectResolverInstance<TResult extends EmptyObject> extends ObjectResolver<TResult> {\n addResolver: (resolver: ObjectResolverInstance<TResult>) => this\n removeResolver: (resolver: ObjectResolverInstance<TResult>) => this\n}\n","import { Address } from '@xylabs/hex'\nimport { Promisable } from '@xylabs/promise'\n\nimport { ModuleIdentifier } from '../ModuleIdentifier'\nimport { ModuleInstance } from './Instance'\nimport { ObjectFilterOptions } from './ObjectFilter'\nimport { isObjectResolver, ObjectResolver } from './ObjectResolver'\n\nexport const isModuleResolver = isObjectResolver<ModuleInstance>\n\nexport interface ModuleResolver<TResult extends ModuleInstance = ModuleInstance> extends ObjectResolver<TResult> {}\n\nexport interface ModuleNameResolver {\n readonly root: ModuleInstance\n resolveIdentifier(id: ModuleIdentifier, options?: ObjectFilterOptions): Promisable<Address | undefined>\n}\n\nexport interface ModuleResolverInstance<TResult extends ModuleInstance = ModuleInstance> extends ModuleResolver<TResult>, ModuleNameResolver {\n addResolver: (resolver: ModuleResolverInstance<TResult>) => this\n removeResolver: (resolver: ModuleResolverInstance<TResult>) => this\n}\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 { Address, isAddress } from '@xylabs/hex'\n\nexport const MODULE_PATH_SEPARATOR = ':' as const\n\nexport const DisallowedModuleIdentifierCharacters = {\n ' ': true,\n '!': true,\n '\"': true,\n '#': true,\n $: true,\n '%': true,\n '&': true,\n \"'\": true,\n '(': true,\n ')': true,\n '*': true,\n ',': true,\n '.': true,\n '/': true,\n ':': true,\n ';': true,\n '<': true,\n '=': true,\n '>': true,\n '?': true,\n '@': true,\n '[': true,\n ']': true,\n '^': true,\n _: true,\n '{': true,\n '|': true,\n '}': true,\n '~': true,\n}\nexport type ReservedModuleIdentifierCharacter = keyof typeof DisallowedModuleIdentifierCharacters\nexport const ReservedModuleIdentifierCharacters = new Set<ReservedModuleIdentifierCharacter>(\n Object.keys(DisallowedModuleIdentifierCharacters) as ReservedModuleIdentifierCharacter[],\n)\n\n//using Exclude to make this type not allowed to take a naked string\nexport type ModuleName = Exclude<string, 'reserved-module-name-56487634'>\n\nexport type ModuleIdentifier =\n | ColonPair<ModuleIdentifierPart>\n | ColonPair<ColonPair<ModuleIdentifierPart>>\n | ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>\n | ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>\n | ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>>\n | ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>>>\n | ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>>>>\n\nexport type ColonPair<T extends string> = `${T}:${T}` | T\n\nexport type ModuleIdentifierPart = Exclude<Address | ModuleName, '*'>\n\nexport const isModuleName = (value: unknown): value is ModuleName => {\n return typeof value === 'string' && !isAddress(value) && !includesReservedModuleIdentifierCharacter(value)\n}\n\nexport const includesReservedModuleIdentifierCharacter = (value: unknown): boolean => {\n return typeof value === 'string' && [...value].some((char) => ReservedModuleIdentifierCharacters.has(char as ReservedModuleIdentifierCharacter))\n}\n\nexport const isModuleIdentifierPart = (value: unknown): value is ModuleIdentifierPart => {\n return isModuleName(value) || isAddress(value)\n}\n","import { Address } from '@xylabs/hex'\nimport { 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: Address\n previousHash?: string\n schema: AddressPreviousHashSchema\n}>\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 { isPayloadOfSchemaType, Payload, WithMeta } 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\nexport const isModuleStateWithMeta = <T extends StateDictionary = StateDictionary>(payload?: Payload | null): payload is WithMeta<ModuleState<T>> => {\n return isPayloadOfSchemaType<WithMeta<ModuleState<T>>>(ModuleStateSchema)(payload)\n}\n","import { Address } from '@xylabs/hex'\n\nimport { ModuleInstance } from '../instance'\n\nexport const resolveAddressToInstanceDown = async (\n root: ModuleInstance,\n address: Address,\n includePrivate = false,\n ignore: Address[] = [],\n): Promise<ModuleInstance | undefined> => {\n if (root.address === address) {\n return root\n }\n const cache = root.addressCache?.('up', includePrivate)\n const privateChildren = (includePrivate ? await root.privateChildren?.() : []) ?? []\n const publicChildren = (await root.publicChildren?.()) ?? []\n const children = [...privateChildren, ...publicChildren]\n for (const child of children) {\n const found = await resolveAddressToInstanceDown(child, address, includePrivate, ignore)\n if (found) {\n cache?.set(address, new WeakRef(found))\n return found\n }\n }\n cache?.set(address, null)\n}\n\nexport const resolveAddressToInstanceSiblings = async (\n root: ModuleInstance,\n address: Address,\n includePrivate = false,\n ignore: Address[] = [],\n): Promise<ModuleInstance | undefined> => {\n const siblings = (await root.siblings?.()) ?? []\n for (const sibling of siblings) {\n const found = await resolveAddressToInstanceDown(sibling, address, includePrivate, ignore)\n if (found) {\n return found\n }\n }\n}\n\nexport const resolveAddressToInstanceUp = async (\n root: ModuleInstance,\n address: Address,\n includePrivate = false,\n ignore: Address[] = [],\n): Promise<ModuleInstance | undefined> => {\n const cache = root.addressCache?.('up', includePrivate)\n const parents = (await root.parents?.()) ?? []\n for (const parent of parents) {\n const found = await resolveAddressToInstance(parent, address, includePrivate, ignore)\n if (found) {\n cache?.set(address, new WeakRef(found))\n return found\n }\n }\n cache?.set(address, null)\n}\n\nexport const resolveAddressToInstance = async (\n root: ModuleInstance,\n address: Address,\n includePrivate = false,\n ignore: Address[] = [],\n): Promise<ModuleInstance | undefined> => {\n const cache = root.addressCache?.('all', includePrivate)\n const result =\n (await resolveAddressToInstanceDown(root, address, includePrivate, ignore)) ??\n (await resolveAddressToInstanceUp(root, address, includePrivate, ignore))\n cache?.set(address, result ? new WeakRef(result) : null)\n return result\n}\n","/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { Address, isAddress } from '@xylabs/hex'\nimport { IdLogger, Logger } from '@xylabs/logger'\nimport { toJsonString } from '@xylabs/object'\n\nimport { asModuleInstance, ModuleFilter, ModuleFilterOptions, ModuleInstance, ModuleResolver } from '../instance'\nimport { duplicateModules } from '../lib'\nimport { ModuleIdentifier } from '../ModuleIdentifier'\nimport { ModuleIdentifierTransformer } from '../ModuleIdentifierTransformer'\nimport { traceModuleIdentifier } from './traceModuleIdentifier'\nimport { transformModuleIdentifier } from './transformModuleIdentifier'\n\n/*\n\nResolution rules\n\n1. Resolution is always done from the perspective of the module whose resolve function was called.\n\n2. Requesting '*' will return all the modules that the resolver can see. [limited by maxDepth]\n\n3. Requesting a simple ModuleName (string w/o ':' separator) will return an immediate child that has that name.\n\n4. Requesting a complex ModuleName (string w/ ':' separator) will resolve the first part and then recursively resolve\n the remaining name by calling the first part's resolved module's resolve with the remainder of the name.\n\n5. Requesting an Address (string) will return the module with that address, regardless of how distant it is from the module. [limited by maxDepth]\n\n6. Requesting a ModuleFilter will first request all the modules '*' and then filter them based on the filter settings. [Do we need this mode?]\n\n7. When a string is passed as the ModuleIdentifier, do the following:\n Check if id is complex (contains a ':')\n a) If it is complex, go to #4 above\n b) Call isAddress in the id to see if it is a valid address.\n i) If it is a valid address, go to #5 above\n ii) If it is not a valid address, go to # 3 above\n\n Note 1: If someone were to name a module with a valid address, that name will not be resolvable.\n Note 2: If someone were to name a module with a string containing a ':', that name will not be resolvable.\n\n8. Modules have two resolvers, up and down.\n a) Up Traversal\n i) Every module's upResolver also can call it's parent's upResolver\n ii) An upResolver also can see the parent's children's downResolvers\n iii) This means that when traversing upResolvers, you can traverse all the way up. [limited by maxDepth]\n iv) At any point of the up traversal, it can start traversing down to any immediate child, public or private.\n b) Down Traversal\n i) A down traversal is limited to the public children of the module. [The same as scope as calling the 'resolve' function]\n\n9. An up or a down traversal counts against the maxDepth\n\n*/\n\nexport interface ResolveHelperConfig {\n address: Address\n dead?: boolean\n downResolver?: ModuleResolver\n logger?: Logger\n module: ModuleInstance\n privateResolver?: ModuleResolver\n transformers: ModuleIdentifierTransformer[]\n upResolver?: ModuleResolver\n}\n\nexport class ResolveHelper {\n static defaultLogger?: Logger\n static transformers: ModuleIdentifierTransformer[] = []\n static async resolve<T extends ModuleInstance = ModuleInstance>(\n config: ResolveHelperConfig,\n all: '*',\n options?: ModuleFilterOptions<T>,\n ): Promise<T[]>\n static async resolve<T extends ModuleInstance = ModuleInstance>(\n config: ResolveHelperConfig,\n filter: ModuleFilter,\n options?: ModuleFilterOptions<T>,\n ): Promise<T[]>\n static async resolve<T extends ModuleInstance = ModuleInstance>(\n config: ResolveHelperConfig,\n id: ModuleIdentifier,\n options?: ModuleFilterOptions<T>,\n ): Promise<T | undefined>\n static async resolve<T extends ModuleInstance = ModuleInstance>(\n config: ResolveHelperConfig,\n idOrFilter: ModuleFilter<T> | ModuleIdentifier = '*',\n { maxDepth = 3, required = 'log', ...options }: ModuleFilterOptions<T> = {},\n ): Promise<T | T[] | undefined> {\n const { transformers, module, logger = this.defaultLogger, dead = false, upResolver, downResolver, privateResolver } = config\n const log = logger ? new IdLogger(logger, () => `ResolveHelper [${module.id}][${idOrFilter}]`) : undefined\n\n const downLocalOptions: ModuleFilterOptions<T> = { ...options, direction: 'down', maxDepth, required: false }\n const upLocalOptions: ModuleFilterOptions<T> = { ...downLocalOptions, direction: 'up' }\n\n const childOptions: ModuleFilterOptions<T> = { ...options, maxDepth: maxDepth - 1, required: false }\n\n const direction = options?.direction ?? 'all'\n const up = direction === 'up' || direction === 'all'\n const down = direction === 'down' || direction === 'all'\n let result: T | T[] | undefined\n log?.debug('start', idOrFilter, maxDepth)\n if (idOrFilter === '*') {\n if (dead) {\n log?.warn('failed [dead]', idOrFilter)\n return []\n }\n const modules = [\n ...(down ? await (downResolver as ModuleResolver).resolve<T>('*', downLocalOptions) : []),\n ...(up ? await (upResolver as ModuleResolver).resolve<T>('*', upLocalOptions) : []),\n ]\n .filter(duplicateModules)\n .filter((module) => module.address !== config.address)\n\n if (modules.length > 0) {\n log?.log('modules [count]', modules.length)\n log?.debug('modules', toJsonString(modules, 4))\n }\n\n if (maxDepth === 0) {\n return modules\n }\n const childModules = (await Promise.all(modules.map(async (module) => await module.resolve<T>('*', childOptions))))\n .flat()\n .filter(duplicateModules)\n return [...modules, ...childModules].filter(duplicateModules)\n } else {\n switch (typeof idOrFilter) {\n case 'string': {\n if (dead) {\n return undefined\n }\n\n const id = await this.transformModuleIdentifier(idOrFilter, transformers)\n\n if (id) {\n const resolvers = [\n [downResolver, downLocalOptions],\n [up ? upResolver : undefined, upLocalOptions],\n [up ? privateResolver : undefined, upLocalOptions],\n ].filter(([resolver]) => exists(resolver)) as [ModuleResolver, ModuleFilterOptions<T>][]\n\n for (const resolver of resolvers) {\n const [resolverInstance] = resolver\n if (!result) {\n result = await this.resolveModuleIdentifier<T>(resolverInstance, id)\n }\n }\n }\n\n break\n }\n default: {\n if (dead) {\n return []\n }\n const filter: ModuleFilter<T> | undefined = idOrFilter\n result = [\n ...(down ? await (downResolver as ModuleResolver).resolve<T>(filter, downLocalOptions) : []),\n ...(up ? await (upResolver as ModuleResolver).resolve<T>(filter, upLocalOptions) : []),\n ].filter(duplicateModules)\n break\n }\n }\n }\n this.validateRequiredResolve(required, result, idOrFilter, logger)\n return result\n }\n\n //resolves a complex module path to addresses\n static async resolveModuleIdentifier<T extends ModuleInstance = ModuleInstance>(\n resolver: ModuleResolver,\n path: ModuleIdentifier,\n required?: boolean,\n ): Promise<T | undefined> {\n const parts = path.split(':')\n const first = parts.shift()\n const firstIsAddress = isAddress(first)\n const resolvedModule =\n (await resolver.resolve(first, { maxDepth: firstIsAddress ? 10 : 1 })) ??\n (first ? await resolver.resolvePrivate(first, { maxDepth: firstIsAddress ? 10 : 1 }) : undefined)\n const finalModule = required ? assertEx(resolvedModule, () => `Failed to resolve [${first}] [${firstIsAddress}]`) : resolvedModule\n const firstModule = asModuleInstance(finalModule, () => `Resolved invalid module instance [${first}]`) as T\n if (firstModule) {\n return parts.length > 0 ? await this.resolveModuleIdentifier<T>(firstModule, parts.join(':')) : firstModule\n }\n }\n\n //translates a complex module path to addresses\n static traceModuleIdentifier(resolver: ModuleResolver, path: ModuleIdentifier) {\n return traceModuleIdentifier(resolver, path)\n }\n\n static transformModuleIdentifier(identifier: ModuleIdentifier, transformers: ModuleIdentifierTransformer[] = ResolveHelper.transformers) {\n return transformModuleIdentifier(identifier, transformers)\n }\n\n static validateRequiredResolve(\n required: boolean | 'warn' | 'log',\n result: ModuleInstance[] | ModuleInstance | undefined,\n idOrFilter: ModuleIdentifier | ModuleFilter,\n logger = this.defaultLogger,\n ) {\n const log = logger ? new IdLogger(logger, () => `validateRequiredResolve [${idOrFilter}][${result}]`) : undefined\n if (required && (result === undefined || (Array.isArray(result) && result.length > 0))) {\n switch (required) {\n case 'warn': {\n log?.warn('resolve failed', idOrFilter)\n break\n }\n case 'log': {\n log?.log('resolve failed', idOrFilter)\n break\n }\n default: {\n throw new Error(`resolve failed [${idOrFilter}]`)\n }\n }\n }\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Address } from '@xylabs/hex'\n\nimport { asModuleInstance, ModuleResolver } from '../instance'\nimport { ModuleIdentifier } from '../ModuleIdentifier'\n\nexport const traceModuleIdentifier = async (resolver: ModuleResolver, path: ModuleIdentifier): Promise<Address[]> => {\n const parts = path.split(':')\n const first = parts.shift()\n const firstModule = asModuleInstance(\n assertEx(await resolver.resolve(first, { maxDepth: 1 }), () => `Failed to resolve [${first}]`),\n () => `Resolved invalid module instance [${first}]`,\n )\n if (firstModule) {\n return parts.length > 0 ? [firstModule.address, ...(await traceModuleIdentifier(firstModule, parts.join(':')))] : [firstModule.address]\n }\n return []\n}\n","import { ModuleIdentifier } from '../ModuleIdentifier'\nimport { ModuleIdentifierTransformer } from '../ModuleIdentifierTransformer'\n\nexport const transformModuleIdentifier = async (\n id: ModuleIdentifier,\n transformers: ModuleIdentifierTransformer[],\n): Promise<ModuleIdentifier | undefined> => {\n let result: ModuleIdentifier | undefined = id\n for (const transformer of transformers) {\n result = await transformer.transform(id)\n }\n return result\n}\n","import { Address } from '@xylabs/hex'\n\nimport { ModuleInstance } from '../instance'\nimport { ModuleName } from '../ModuleIdentifier'\n\nexport const resolveLocalNameToAddressUp = async (root: ModuleInstance, localName: ModuleName): Promise<Address | undefined> => {\n const parents = (await root.parents?.()) ?? []\n return parents.find((parent) => parent.localName === localName)?.address\n}\n\n//since this is a localName, it only checks the children of the root module\nexport const resolveLocalNameToAddressDown = async (\n root: ModuleInstance,\n localName: ModuleName,\n includePrivate = false,\n): Promise<Address | undefined> => {\n const privateChildren = (includePrivate ? await root.privateChildren?.() : []) ?? []\n const publicChildren = (await root.publicChildren?.()) ?? []\n const children = [...privateChildren, ...publicChildren]\n return children.find((child) => child.localName === localName)?.address\n}\n\nexport const resolveLocalNameToAddress = async (\n root: ModuleInstance,\n localName: ModuleName,\n includePrivate = false,\n): Promise<Address | undefined> => {\n return (await resolveLocalNameToAddressDown(root, localName, includePrivate)) ?? (await resolveLocalNameToAddressUp(root, localName))\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Address, asAddress } from '@xylabs/hex'\n\nimport { ModuleInstance } from '../instance'\nimport { MODULE_PATH_SEPARATOR } from '../ModuleIdentifier'\nimport { ModuleIdentifierTransformer } from '../ModuleIdentifierTransformer'\nimport { resolveAddressToInstance } from './resolveAddressToInstance'\nimport { ResolveHelper } from './ResolveHelper'\nimport { resolveLocalNameToAddress } from './resolveLocalNameToAddress'\nimport { transformModuleIdentifier } from './transformModuleIdentifier'\n\nexport const resolvePathToAddress = async (\n root: ModuleInstance,\n path: string,\n includePrivate = false,\n transformers: ModuleIdentifierTransformer[] = ResolveHelper.transformers,\n): Promise<Address | undefined> => {\n const parts = path.split(MODULE_PATH_SEPARATOR)\n const first = await transformModuleIdentifier(\n assertEx(parts.shift(), () => `First part is invalid [${path}]`),\n transformers,\n )\n\n if (!first) {\n return undefined\n }\n\n const firstAddress = asAddress(first) ?? (await resolveLocalNameToAddress(root, first, includePrivate))\n\n if (firstAddress) {\n const firstModule = await resolveAddressToInstance(root, firstAddress, includePrivate)\n if (firstModule && parts.length > 0) {\n return resolvePathToAddress(firstModule, parts.join(MODULE_PATH_SEPARATOR))\n }\n return firstAddress\n }\n}\n","import { TypeCheck } from '@xylabs/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,IAAMA,qBAAyC;;;ACsB/C,SAASC,kBAAAA;AACd,SAAO,CAAqCC,gBAAAA;AAC1CA;EACF;AACF;AAJgBD;;;ACpBT,IAAME,iCAAiC,wBAC5CC,UACAC,aAAAA;AAGAD,WAASC,SAAQC,mBAAmB,IAAI;IAACD;OAAaD,SAASC,SAAQC,mBAAmB,KAAK,CAAA;;AAC/F,aAAWC,UAAUF,SAAQG,eAAe;AAC1CJ,aAASG,MAAAA,IAAU;SAAKH,SAASG,MAAAA,KAAW,CAAA;MAAKF;;EACnD;AACF,GAT8C;AAWvC,IAAMI,wCAAwC,wBACnDL,UACAC,UACAK,iBAAAA;AAEAN,WAASM,YAAAA,IAAgB;IAACL;OAAaD,SAASM,YAAAA,KAAiB,CAAA;;AACnE,GANqD;AAQ9C,IAAMC,mCAAmC,wBAC9CC,WACAR,WAAoC,CAAC,MAAC;AAEtC,aAAWC,YAAWO,WAAW;AAC/BT,mCAA+BC,UAAUC,QAAAA;EAC3C;AACA,SAAOD;AACT,GARgD;AAWzC,IAAMS,gCAAgC,wBAC3CC,SAAkC,CAAC,MAChCC,YAAAA;AAEHA,UAAQC,IAAI,CAACC,WACXC,OAAOC,QAAQF,MAAAA,EAAQD,IAAI,CAAC,CAACT,QAAQK,SAAAA,MAAU;AAC7C,QAAIA,WAAW;AACb,YAAMQ,oBAAoBN,OAAOP,MAAAA;AACjCO,aAAOP,MAAAA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AAA;AAGF,MAAI,CAACK,OAAO;AACV,WAAOI;EACT;AAEA,QAAMC,eAAeC,UAAUN,KAAAA,KAAW,MAAMO,0BAA0Bf,MAAMQ,OAAON,cAAAA;AAEvF,MAAIW,cAAc;AAChB,UAAMG,cAAc,MAAMC,yBAAyBjB,MAAMa,cAAcX,cAAAA;AACvE,QAAIc,eAAeX,MAAMa,SAAS,GAAG;AACnC,aAAOnB,qBAAqBiB,aAAaX,MAAMc,KAAKZ,qBAAAA,CAAAA;IACtD;AACA,WAAOM;EACT;AACF,GAzBoC;;;ACN7B,IAAMO,cAAc;EACzBC,QAAQ,CAAmBC,cAAAA;AACzB,WAAO,CAELC,QAEAC,YAAAA;AAEA,aAAOF,UAAUC,MAAAA,IAAUC,QAAQD,MAAAA,IAAUE;IAC/C;EACF;AACF;AAEO,IAAMC,aAAaN,YAAYC,OAAOM,QAAAA;AACtC,IAAMC,qBAAqBR,YAAYC,OAAOQ,gBAAAA;","names":["ModuleConfigSchema","creatableModule","constructor","registerCreatableModuleFactory","registry","factory","defaultConfigSchema","schema","configSchemas","registerPrimaryCreatableModuleFactory","configSchema","registerCreatableModuleFactories","factories","assignCreatableModuleRegistry","target","sources","map","source","Object","entries","existingFactories","hasLabels","factory","labels","undefined","assertEx","merge","ModuleFactory","configSchemas","creatableModule","defaultConfigSchema","defaultLogger","defaultParams","labels","constructor","params","assertEx","includes","Object","assign","withParams","_getRootFunction","funcName","anyThis","__proto__","_noOverride","functionName","thisFunc","rootFunc","create","factory","schema","mergedParams","merge","config","_params","Error","assertEx","hasAllLabels","source","required","Object","entries","every","key","value","hasOwnProperty","ModuleFactoryLocator","constructor","_registry","registry","locate","schema","labels","assertEx","tryLocate","JSON","stringify","register","mod","registerOne","defaultConfigSchema","configSchemas","map","registerMany","mods","primary","existingFactories","factory","create","bind","Object","assign","filter","hasLabels","find","hasAllLabels","AsObjectFactory","IsObjectFactory","AsObjectFactory","ModuleManifestQuerySchema","ModuleAddressQuerySchema","ModuleStateQuerySchema","ModuleSubscribeQuerySchema","AsObjectFactory","IsObjectFactory","requiredModuleShape","address","queries","query","factory","isModuleObject","create","asModuleObject","AsObjectFactory","create","isModuleObject","IsModuleFactory","create","expectedQueries","additionalChecks","obj","config","module","asModuleObject","result","isModuleObject","reduce","prev","query","queries","includes","check","requiredModuleQueries","ModuleStateQuerySchema","factory","IsModuleFactory","isModule","create","isModuleObject","asModule","AsObjectFactory","create","isModule","requiredModuleInstanceFunctions","manifest","state","factory","IsObjectFactory","isModuleInstance","create","isModule","asModuleInstance","AsObjectFactory","create","isModuleInstance","AsObjectFactory","IsObjectFactory","requiredAttachableModuleInstanceFunctions","downResolver","upResolver","factory","IsObjectFactory","isAttachableModuleInstance","create","isModuleInstance","asAttachableModuleInstance","AsObjectFactory","create","isAttachableModuleInstance","IsObjectFactory","IsAttachableModuleInstanceFactory","IsObjectFactory","IsObjectFactory","toJsonString","DeadModuleError","Error","constructor","id","error","msg","message","toJsonString","Object","setPrototypeOf","prototype","IsInstanceFactory","IsObjectFactory","isAddressObjectFilter","value","address","undefined","isNameObjectFilter","name","isQueryObjectFilter","query","isAddressModuleFilter","isAddressObjectFilter","isNameModuleFilter","isNameObjectFilter","isQueryModuleFilter","isQueryObjectFilter","isObjectResolver","value","resolve","ObjectResolverPriority","isModuleResolver","isObjectResolver","duplicateModules","value","index","array","findIndex","v","address","every","isArray","isBoolean","isNull","isNumber","isPlainObject","isString","isUndefined","overSome","JSONPrimitiveChecks","isUndefined","isNull","isBoolean","isNumber","isString","JSONComplexChecks","isPlainObject","isArray","serializable","field","depth","depthExceeded","decrementDepth","undefined","recursiveSerializable","nestedSerializable","overSome","every","valid","serializableField","isAddress","MODULE_PATH_SEPARATOR","DisallowedModuleIdentifierCharacters","$","_","ReservedModuleIdentifierCharacters","Set","Object","keys","isModuleName","value","isAddress","includesReservedModuleIdentifierCharacter","some","char","has","isModuleIdentifierPart","AddressSchema","AddressPreviousHashSchema","ModuleDescriptionSchema","isPayloadOfSchemaType","ModuleStateSchema","isModuleState","payload","isPayloadOfSchemaType","isModuleStateWithMeta","resolveAddressToInstanceDown","root","address","includePrivate","ignore","cache","addressCache","privateChildren","publicChildren","children","child","found","set","WeakRef","resolveAddressToInstanceSiblings","siblings","sibling","resolveAddressToInstanceUp","parents","parent","resolveAddressToInstance","result","assertEx","exists","isAddress","IdLogger","toJsonString","assertEx","traceModuleIdentifier","resolver","path","parts","split","first","shift","firstModule","asModuleInstance","assertEx","resolve","maxDepth","length","address","join","transformModuleIdentifier","id","transformers","result","transformer","transform","ResolveHelper","resolve","config","idOrFilter","maxDepth","required","options","transformers","module","logger","defaultLogger","dead","upResolver","downResolver","privateResolver","log","IdLogger","id","undefined","downLocalOptions","direction","upLocalOptions","childOptions","up","down","result","debug","warn","modules","filter","duplicateModules","address","length","toJsonString","childModules","Promise","all","map","flat","transformModuleIdentifier","resolvers","resolver","exists","resolverInstance","resolveModuleIdentifier","validateRequiredResolve","path","parts","split","first","shift","firstIsAddress","isAddress","resolvedModule","resolvePrivate","finalModule","assertEx","firstModule","asModuleInstance","join","traceModuleIdentifier","identifier","Array","isArray","Error","resolveLocalNameToAddressUp","root","localName","parents","find","parent","address","resolveLocalNameToAddressDown","includePrivate","privateChildren","publicChildren","children","child","resolveLocalNameToAddress","assertEx","asAddress","resolvePathToAddress","root","path","includePrivate","transformers","ResolveHelper","parts","split","MODULE_PATH_SEPARATOR","first","transformModuleIdentifier","assertEx","shift","undefined","firstAddress","asAddress","resolveLocalNameToAddress","firstModule","resolveAddressToInstance","length","join","WithFactory","create","typeCheck","module","closure","undefined","withModule","isModule","withModuleInstance","isModuleInstance"]}
1
+ {"version":3,"sources":["../../src/Config/Config.ts","../../src/CreatableModule/CreatableModule.ts","../../src/CreatableModule/CreatableModuleRegistry.ts","../../src/CreatableModule/LabeledCreatableModuleFactory.ts","../../src/CreatableModule/ModuleFactory.ts","../../src/instance/asModuleInstance.ts","../../src/instance/isModuleInstance.ts","../../src/module/asModule.ts","../../src/Queries/Manifest.ts","../../src/Queries/ModuleAddress/Query.ts","../../src/Queries/State.ts","../../src/Queries/Subscribe.ts","../../src/module/asModuleObject.ts","../../src/module/isModuleObject.ts","../../src/module/IsModuleFactory.ts","../../src/module/isModule.ts","../../src/instance/attachable/asAttachableInstance.ts","../../src/instance/attachable/isAttachableInstance.ts","../../src/instance/attachable/AttachableInstance.ts","../../src/instance/Instance.ts","../../src/instance/ObjectFilter.ts","../../src/instance/ModuleFilter.ts","../../src/instance/ObjectResolver.ts","../../src/instance/ModuleResolver.ts","../../src/Labels/Labels.ts","../../src/lib/duplicateModules.ts","../../src/lib/serializable.ts","../../src/ModuleIdentifier.ts","../../src/Payload/AddressPreviousHash.ts","../../src/Payload/Description.ts","../../src/Payload/ModuleState.ts","../../src/ResolveHelper/resolveAddressToInstance.ts","../../src/ResolveHelper/ResolveHelper.ts","../../src/ResolveHelper/traceModuleIdentifier.ts","../../src/ResolveHelper/transformModuleIdentifier.ts","../../src/ResolveHelper/resolveLocalNameToAddress.ts","../../src/ResolveHelper/resolvePathToAddress.ts","../../src/withModule.ts"],"sourcesContent":["import { EmptyObject, WithAdditional } from '@xylabs/object'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { ArchivingModuleConfig } from './Archiving'\nimport { ModuleConfigFields } from './Fields'\n\nexport type ModuleConfigSchema = 'network.xyo.module.config'\nexport const ModuleConfigSchema: ModuleConfigSchema = 'network.xyo.module.config'\n\nexport type ModuleConfig<TConfig extends EmptyObject | Payload | void = void, TSchema extends Schema | void = void> = Payload<\n WithAdditional<ArchivingModuleConfig & ModuleConfigFields, TConfig>,\n TSchema extends Schema ? TSchema\n : TConfig extends Payload ? TConfig['schema']\n : ModuleConfigSchema\n>\n\nexport type AnyConfigSchema<TConfig extends Omit<ModuleConfig, 'schema'> & { schema: string } = Omit<ModuleConfig, 'schema'> & { schema: string }> =\n ModuleConfig<TConfig, string>\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'\nimport { Schema } from '@xyo-network/payload-model'\n\nimport { AttachableModuleInstance } from '../instance'\n\nexport type CreatableModuleFactory<T extends AttachableModuleInstance = AttachableModuleInstance> = Omit<\n Omit<CreatableModule<T>, 'new'>,\n 'create'\n> & {\n create<T extends AttachableModuleInstance>(this: CreatableModuleFactory<T>, params?: T['params']): Promise<T>\n}\n\nexport interface CreatableModule<T extends AttachableModuleInstance = AttachableModuleInstance> {\n configSchemas: Schema[]\n defaultConfigSchema: Schema\n defaultLogger?: Logger\n new (privateConstructorKey: string, params: T['params'], account: AccountInstance): T\n _noOverride(functionName: string): void\n create<T extends AttachableModuleInstance>(this: CreatableModule<T>, params?: T['params']): Promise<T>\n factory<T extends AttachableModuleInstance>(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 AttachableModuleInstance = AttachableModuleInstance>() {\n return <U extends CreatableModule<TModule>>(constructor: U) => {\n constructor\n }\n}\n","import { Schema } from '@xyo-network/payload-model'\n\nimport { CreatableModuleFactory } from './CreatableModule'\nimport { LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory'\n\nexport interface CreatableModuleRegistry {\n [key: string]: (CreatableModuleFactory | LabeledCreatableModuleFactory)[] | undefined\n}\n\nexport const registerCreatableModuleFactory = (\n registry: CreatableModuleRegistry,\n factory: CreatableModuleFactory | LabeledCreatableModuleFactory,\n) => {\n //add the defaultConfigSchema as the first key in the registry\n registry[factory.defaultConfigSchema] = [factory, ...(registry[factory.defaultConfigSchema] ?? [])]\n for (const schema of factory.configSchemas) {\n registry[schema] = [...(registry[schema] ?? []), factory]\n }\n}\n\nexport const registerPrimaryCreatableModuleFactory = (\n registry: CreatableModuleRegistry,\n factory: CreatableModuleFactory | LabeledCreatableModuleFactory,\n configSchema: Schema,\n) => {\n registry[configSchema] = [factory, ...(registry[configSchema] ?? [])]\n}\n\nexport const registerCreatableModuleFactories = (\n factories: (CreatableModuleFactory | LabeledCreatableModuleFactory)[],\n registry: CreatableModuleRegistry = {},\n) => {\n for (const factory of factories) {\n registerCreatableModuleFactory(registry, factory)\n }\n return registry\n}\n\n/** @deprecated use registerCreatableModuleFactory instead */\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 { AttachableModuleInstance } from '../instance'\nimport { WithOptionalLabels } from '../Labels'\nimport { CreatableModuleFactory } from './CreatableModule'\n\nexport type LabeledCreatableModuleFactory<T extends AttachableModuleInstance = AttachableModuleInstance> = CreatableModuleFactory<T> &\n 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'\nimport { Schema } from '@xyo-network/payload-model'\n\nimport { AttachableModuleInstance } from '../instance'\nimport { Labels, WithOptionalLabels } from '../Labels'\nimport { CreatableModule, CreatableModuleFactory } from './CreatableModule'\n\nexport class ModuleFactory<TModule extends AttachableModuleInstance> implements CreatableModuleFactory<TModule> {\n configSchemas: CreatableModuleFactory<TModule>['configSchemas']\n\n creatableModule: CreatableModule<TModule>\n\n defaultConfigSchema: Schema\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.defaultConfigSchema = creatableModule.defaultConfigSchema\n assertEx(this.configSchemas.includes(this.defaultConfigSchema), () => 'defaultConfigSchema must be in configSchemas')\n this.labels = Object.assign({}, (creatableModule as WithOptionalLabels).labels ?? {}, labels ?? {})\n }\n\n static withParams<T extends AttachableModuleInstance>(\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 AttachableModuleInstance>(this: CreatableModuleFactory<T>, params?: TModule['params'] | undefined): Promise<T> {\n const factory = this as ModuleFactory<T>\n const schema = factory.creatableModule.defaultConfigSchema\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 AttachableModuleInstance>(this: CreatableModule<T>, _params?: T['params'] | undefined): CreatableModuleFactory<T> {\n throw new Error('Method not implemented.')\n }\n}\n","import { AsObjectFactory } from '@xylabs/object'\n\nimport { isModuleInstance } from './isModuleInstance'\n\nexport const asModuleInstance = AsObjectFactory.create(isModuleInstance)\n","import { IsObjectFactory, ObjectTypeShape, TypeCheck } from '@xylabs/object'\n\nimport { isModule } from '../module'\nimport { ModuleInstance } from './Instance'\n\nexport const requiredModuleInstanceFunctions: ObjectTypeShape = {\n manifest: 'function',\n state: '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 '@xylabs/object'\n\nimport { isModule } from './isModule'\n\nexport const asModule = AsObjectFactory.create(isModule)\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 { 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 const ModuleStateQuerySchema = 'network.xyo.query.module.state'\nexport type ModuleStateQuerySchema = typeof ModuleStateQuerySchema\n\nexport type ModuleStateQuery = Query<void, ModuleStateQuerySchema>\n","import { Address } from '@xylabs/hex'\nimport { 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: Address\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 '@xylabs/object'\n\nimport { isModuleObject } from './isModuleObject'\n\nexport const asModuleObject = AsObjectFactory.create(isModuleObject)\n","import { IsObjectFactory, ObjectTypeShape } from '@xylabs/object'\n\nimport { Module } from './Module'\n\nexport const requiredModuleShape: ObjectTypeShape = {\n address: 'string',\n queries: 'array',\n query: 'function',\n}\n\nconst factory = new IsObjectFactory<Module>()\n\nexport const isModuleObject = factory.create(requiredModuleShape)\n","import { AnyObject, EmptyObject, TypeCheck } from '@xylabs/object'\nimport { AnyNonPromise } from '@xylabs/promise'\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: AnyNonPromise, 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 '@xylabs/object'\nimport { Schema } from '@xyo-network/payload-model'\n\nimport { ModuleStateQuerySchema } from '../Queries'\nimport { IsModuleFactory } from './IsModuleFactory'\nimport { isModuleObject } from './isModuleObject'\nimport { Module } from './Module'\n\nexport const requiredModuleQueries: Schema[] = [ModuleStateQuerySchema]\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 { AsObjectFactory } from '@xylabs/object'\n\nimport { isAttachableModuleInstance } from './isAttachableInstance'\n\nexport const asAttachableModuleInstance = AsObjectFactory.create(isAttachableModuleInstance)\n","import { IsObjectFactory, ObjectTypeShape, TypeCheck } from '@xylabs/object'\n\nimport { isModuleInstance } from '../isModuleInstance'\nimport { AttachableModuleInstance } from './AttachableInstance'\n\nexport const requiredAttachableModuleInstanceFunctions: ObjectTypeShape = {\n downResolver: 'object',\n upResolver: 'object',\n}\n\n//we do not use IsInstanceFactory here to prevent a cycle\nconst factory = new IsObjectFactory<AttachableModuleInstance>()\n\nexport const isAttachableModuleInstance: TypeCheck<AttachableModuleInstance> = factory.create(requiredAttachableModuleInstanceFunctions, [\n isModuleInstance,\n])\n","import { IsObjectFactory, TypeCheck } from '@xylabs/object'\n\nimport { ModuleEventData } from '../../EventsModels'\nimport { ModuleParams } from '../../ModuleParams'\nimport { ModuleInstance } from '../Instance'\nimport { ModuleResolverInstance } from '../ModuleResolver'\n\nexport interface AttachableModuleInstance<TParams extends ModuleParams = ModuleParams, TEventData extends ModuleEventData = ModuleEventData>\n extends ModuleInstance<TParams, TEventData> {\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: ModuleResolverInstance\n\n // The resolver that gets called by children (usually only Nodes have this)\n readonly privateResolver: ModuleResolverInstance\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: ModuleResolverInstance\n}\n\nexport type AttachableModuleInstanceTypeCheck<T extends AttachableModuleInstance = AttachableModuleInstance> = TypeCheck<T>\n\nexport class IsAttachableModuleInstanceFactory<T extends AttachableModuleInstance = AttachableModuleInstance> extends IsObjectFactory<T> {}\n","import { Address } from '@xylabs/hex'\nimport { IsObjectFactory, toJsonString, TypeCheck } from '@xylabs/object'\nimport { Promisable } from '@xylabs/promise'\n\nimport { ModuleEventData } from '../EventsModels'\nimport { Module, ModuleQueryFunctions } from '../module'\nimport { ModuleIdentifier, ModuleName } from '../ModuleIdentifier'\nimport { ModuleParams } from '../ModuleParams'\nimport { Direction } from './ObjectFilter'\nimport { ObjectResolver } from './ObjectResolver'\n\nexport type ModulePipeLine = Lowercase<'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many'>\n\nexport type ModuleStatus = 'started' | 'stopped' | 'dead' | 'wrapped' | 'proxy'\n\nexport class DeadModuleError extends Error {\n constructor(\n public id: ModuleIdentifier,\n public error: Error | undefined,\n msg = 'Dead Module Error',\n ) {\n super(`${msg} [${id}]: ${error?.message ?? toJsonString(error)}`)\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, DeadModuleError.prototype)\n }\n}\n\nexport interface AddressToWeakInstanceCache {\n get: (address: Address) => WeakRef<ModuleInstance> | null\n set: (address: Address, instance: WeakRef<ModuleInstance> | null) => void\n}\n\nexport interface ModuleFamilyFunctions {\n addParent: (module: ModuleInstance) => void\n addressCache?: (direction: Direction, includePrivate: boolean) => AddressToWeakInstanceCache | undefined\n localName: ModuleName | undefined\n parents: () => Promisable<ModuleInstance[]>\n privateChildren: () => Promisable<ModuleInstance[]>\n publicChildren: () => Promisable<ModuleInstance[]>\n removeParent: (address: Address) => void\n siblings: () => Promisable<ModuleInstance[]>\n}\n\nexport interface ModuleInstance<TParams extends ModuleParams = ModuleParams, TEventData extends ModuleEventData = ModuleEventData>\n extends Module<TParams, TEventData>,\n ObjectResolver<ModuleInstance>,\n ModuleQueryFunctions,\n ModuleFamilyFunctions {\n readonly pipeline?: ModulePipeLine\n\n //if the module has become non-functional, such as a broken bridge connection, this will be 'dead'\n readonly status: ModuleStatus\n}\n\nexport type InstanceTypeCheck<T extends ModuleInstance = ModuleInstance> = TypeCheck<T>\n\nexport class IsInstanceFactory<T extends ModuleInstance = ModuleInstance> extends IsObjectFactory<T> {}\n","import { Address } from '@xylabs/hex'\nimport { AnyObject, EmptyObject, TypeCheck } from '@xylabs/object'\n\nimport { ModuleName } from '../ModuleIdentifier'\n\nexport type Direction = 'up' | 'down' | 'all'\nexport type Visibility = 'public' | 'private' | 'all'\n\nexport interface ResolveStrategy {\n maxDepth?: number\n required?: boolean | 'warn' | 'log'\n retry?: number\n timeout?: number\n}\n\nexport interface ObjectFilterOptions<T extends EmptyObject = AnyObject> extends ResolveStrategy {\n direction?: Direction\n identity?: TypeCheck<T>\n}\n\nexport interface AddressObjectFilter<T extends EmptyObject = AnyObject> extends ObjectFilterOptions<T> {\n address: Address[]\n}\n\nexport const isAddressObjectFilter = <T extends EmptyObject = AnyObject>(value: unknown): value is AddressObjectFilter<T> =>\n (value as AddressObjectFilter<T>).address !== undefined\n\nexport interface NameObjectFilter<T extends EmptyObject = AnyObject> extends ObjectFilterOptions<T> {\n name: ModuleName[]\n}\n\nexport const isNameObjectFilter = <T extends EmptyObject = AnyObject>(value: unknown): value is NameObjectFilter<T> =>\n (value as NameObjectFilter<T>).name !== undefined\n\nexport interface QueryObjectFilter<T extends EmptyObject = AnyObject> extends ObjectFilterOptions<T> {\n query: string[][]\n}\n\nexport const isQueryObjectFilter = <T extends EmptyObject = AnyObject>(value: unknown): value is QueryObjectFilter<T> =>\n (value as QueryObjectFilter<T>).query !== undefined\n\nexport type AnyObjectFilter<T extends EmptyObject = AnyObject> = Partial<AddressObjectFilter<T>> &\n Partial<NameObjectFilter<T>> &\n Partial<QueryObjectFilter<T>>\n\nexport type ObjectFilter<T extends EmptyObject> = ObjectFilterOptions<T> | AddressObjectFilter<T> | NameObjectFilter<T> | QueryObjectFilter<T>\n","import { ModuleInstance } from './Instance'\nimport {\n AddressObjectFilter,\n AnyObjectFilter,\n isAddressObjectFilter,\n isNameObjectFilter,\n isQueryObjectFilter,\n NameObjectFilter,\n ObjectFilter,\n ObjectFilterOptions,\n QueryObjectFilter,\n} from './ObjectFilter'\n\nexport interface ModuleFilterOptions<T extends ModuleInstance = ModuleInstance> extends ObjectFilterOptions<T> {}\n\nexport const isAddressModuleFilter = isAddressObjectFilter<ModuleInstance>\n\nexport const isNameModuleFilter = isNameObjectFilter<ModuleInstance>\n\nexport const isQueryModuleFilter = isQueryObjectFilter<ModuleInstance>\n\nexport type AnyModuleFilter<T extends ModuleInstance = ModuleInstance> = AnyObjectFilter<T>\n\nexport type AddressModuleFilter<T extends ModuleInstance = ModuleInstance> = AddressObjectFilter<T>\n\nexport type NameModuleFilter<T extends ModuleInstance = ModuleInstance> = NameObjectFilter<T>\n\nexport type QueryModuleFilter<T extends ModuleInstance = ModuleInstance> = QueryObjectFilter<T>\n\nexport type ModuleFilter<T extends ModuleInstance = ModuleInstance> = ObjectFilter<T>\n","import { AnyObject, EmptyObject } from '@xylabs/object'\nimport { Promisable } from '@xylabs/promise'\n\nimport { ModuleIdentifier } from '../ModuleIdentifier'\nimport { ObjectFilter, ObjectFilterOptions } from './ObjectFilter'\n\nexport const isObjectResolver = <T extends EmptyObject = AnyObject>(value?: unknown): value is ObjectResolver<T> => {\n // eslint-disable-next-line deprecation/deprecation\n return typeof (value as Partial<ObjectResolver<T>>).resolve === 'function'\n}\n\nexport enum ObjectResolverPriority {\n Disabled = -1,\n VeryLow = 0,\n Low = 1,\n Normal = 2,\n High = 3,\n VeryHigh = 4,\n}\n\nexport interface ObjectResolver<TResult extends EmptyObject> {\n priority: ObjectResolverPriority\n /** @deprecated do not pass undefined. If trying to get all, pass '*' */\n resolve<T extends TResult = TResult>(): Promisable<T | undefined>\n resolve<T extends TResult = TResult>(all: '*', options?: ObjectFilterOptions<T>): Promisable<T[]>\n resolve<T extends TResult = TResult>(id: ModuleIdentifier, options?: ObjectFilterOptions<T>): Promisable<T | undefined>\n resolve<T extends TResult = TResult>(filter: ObjectFilter<T>, options?: ObjectFilterOptions<T>): Promisable<T[]>\n /** @deprecated do not pass undefined. If trying to get all, pass '*' */\n resolve<T extends TResult = TResult>(filter?: ObjectFilter<T>, options?: ObjectFilterOptions<T>): Promisable<T[]>\n resolve<T extends TResult = TResult>(\n idOrFilter?: ObjectFilter<T> | ModuleIdentifier,\n options?: ObjectFilterOptions<T>,\n ): Promisable<T | T[] | undefined>\n\n resolvePrivate<T extends TResult = TResult>(all: '*', options?: ObjectFilterOptions<T>): Promise<T[]>\n resolvePrivate<T extends TResult = TResult>(id: ModuleIdentifier, options?: ObjectFilterOptions<T>): Promise<T | undefined>\n resolvePrivate<T extends TResult = TResult>(id: ModuleIdentifier, options?: ObjectFilterOptions<T>): Promise<T | T[] | undefined>\n}\n\nexport interface ObjectResolverInstance<TResult extends EmptyObject> extends ObjectResolver<TResult> {\n addResolver: (resolver: ObjectResolverInstance<TResult>) => this\n removeResolver: (resolver: ObjectResolverInstance<TResult>) => this\n}\n","import { Address } from '@xylabs/hex'\nimport { Promisable } from '@xylabs/promise'\n\nimport { ModuleIdentifier } from '../ModuleIdentifier'\nimport { ModuleInstance } from './Instance'\nimport { ObjectFilterOptions } from './ObjectFilter'\nimport { isObjectResolver, ObjectResolver } from './ObjectResolver'\n\nexport const isModuleResolver = isObjectResolver<ModuleInstance>\n\nexport interface ModuleResolver<TResult extends ModuleInstance = ModuleInstance> extends ObjectResolver<TResult> {}\n\nexport interface ModuleNameResolver {\n readonly root: ModuleInstance\n resolveIdentifier(id: ModuleIdentifier, options?: ObjectFilterOptions): Promisable<Address | undefined>\n}\n\nexport interface ModuleResolverInstance<TResult extends ModuleInstance = ModuleInstance> extends ModuleResolver<TResult>, ModuleNameResolver {\n addResolver: (resolver: ModuleResolverInstance<TResult>) => this\n removeResolver: (resolver: ModuleResolverInstance<TResult>) => this\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 { 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 { Address, isAddress } from '@xylabs/hex'\n\nexport const MODULE_PATH_SEPARATOR = ':' as const\n\nexport const DisallowedModuleIdentifierCharacters = {\n ' ': true,\n '!': true,\n '\"': true,\n '#': true,\n $: true,\n '%': true,\n '&': true,\n \"'\": true,\n '(': true,\n ')': true,\n '*': true,\n ',': true,\n '.': true,\n '/': true,\n ':': true,\n ';': true,\n '<': true,\n '=': true,\n '>': true,\n '?': true,\n '@': true,\n '[': true,\n ']': true,\n '^': true,\n _: true,\n '{': true,\n '|': true,\n '}': true,\n '~': true,\n}\nexport type ReservedModuleIdentifierCharacter = keyof typeof DisallowedModuleIdentifierCharacters\nexport const ReservedModuleIdentifierCharacters = new Set<ReservedModuleIdentifierCharacter>(\n Object.keys(DisallowedModuleIdentifierCharacters) as ReservedModuleIdentifierCharacter[],\n)\n\n//using Exclude to make this type not allowed to take a naked string\nexport type ModuleName = Exclude<string, 'reserved-module-name-56487634'>\n\nexport type ModuleIdentifier =\n | ColonPair<ModuleIdentifierPart>\n | ColonPair<ColonPair<ModuleIdentifierPart>>\n | ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>\n | ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>\n | ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>>\n | ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>>>\n | ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ColonPair<ModuleIdentifierPart>>>>>>>\n\nexport type ColonPair<T extends string> = `${T}:${T}` | T\n\nexport type ModuleIdentifierPart = Exclude<Address | ModuleName, '*'>\n\nexport const isModuleName = (value: unknown): value is ModuleName => {\n return typeof value === 'string' && !isAddress(value) && !includesReservedModuleIdentifierCharacter(value)\n}\n\nexport const includesReservedModuleIdentifierCharacter = (value: unknown): boolean => {\n return typeof value === 'string' && [...value].some((char) => ReservedModuleIdentifierCharacters.has(char as ReservedModuleIdentifierCharacter))\n}\n\nexport const isModuleIdentifierPart = (value: unknown): value is ModuleIdentifierPart => {\n return isModuleName(value) || isAddress(value)\n}\n","import { Address } from '@xylabs/hex'\nimport { 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: Address\n previousHash?: string\n schema: AddressPreviousHashSchema\n}>\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 { isPayloadOfSchemaType, Payload, WithMeta } 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\nexport const isModuleStateWithMeta = <T extends StateDictionary = StateDictionary>(payload?: Payload | null): payload is WithMeta<ModuleState<T>> => {\n return isPayloadOfSchemaType<WithMeta<ModuleState<T>>>(ModuleStateSchema)(payload)\n}\n","import { Address } from '@xylabs/hex'\n\nimport { ModuleInstance } from '../instance'\n\nexport const resolveAddressToInstanceDown = async (\n root: ModuleInstance,\n address: Address,\n includePrivate = false,\n ignore: Address[] = [],\n): Promise<ModuleInstance | undefined> => {\n if (root.address === address) {\n return root\n }\n const cache = root.addressCache?.('up', includePrivate)\n const privateChildren = (includePrivate ? await root.privateChildren?.() : []) ?? []\n const publicChildren = (await root.publicChildren?.()) ?? []\n const children = [...privateChildren, ...publicChildren]\n for (const child of children) {\n const found = await resolveAddressToInstanceDown(child, address, includePrivate, ignore)\n if (found) {\n cache?.set(address, new WeakRef(found))\n return found\n }\n }\n cache?.set(address, null)\n}\n\nexport const resolveAddressToInstanceSiblings = async (\n root: ModuleInstance,\n address: Address,\n includePrivate = false,\n ignore: Address[] = [],\n): Promise<ModuleInstance | undefined> => {\n const siblings = (await root.siblings?.()) ?? []\n for (const sibling of siblings) {\n const found = await resolveAddressToInstanceDown(sibling, address, includePrivate, ignore)\n if (found) {\n return found\n }\n }\n}\n\nexport const resolveAddressToInstanceUp = async (\n root: ModuleInstance,\n address: Address,\n includePrivate = false,\n ignore: Address[] = [],\n): Promise<ModuleInstance | undefined> => {\n const cache = root.addressCache?.('up', includePrivate)\n const parents = (await root.parents?.()) ?? []\n for (const parent of parents) {\n const found = await resolveAddressToInstance(parent, address, includePrivate, ignore)\n if (found) {\n cache?.set(address, new WeakRef(found))\n return found\n }\n }\n cache?.set(address, null)\n}\n\nexport const resolveAddressToInstance = async (\n root: ModuleInstance,\n address: Address,\n includePrivate = false,\n ignore: Address[] = [],\n): Promise<ModuleInstance | undefined> => {\n const cache = root.addressCache?.('all', includePrivate)\n const result =\n (await resolveAddressToInstanceDown(root, address, includePrivate, ignore)) ??\n (await resolveAddressToInstanceUp(root, address, includePrivate, ignore))\n cache?.set(address, result ? new WeakRef(result) : null)\n return result\n}\n","/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { Address, isAddress } from '@xylabs/hex'\nimport { IdLogger, Logger } from '@xylabs/logger'\nimport { toJsonString } from '@xylabs/object'\n\nimport { asModuleInstance, ModuleFilter, ModuleFilterOptions, ModuleInstance, ModuleResolver } from '../instance'\nimport { duplicateModules } from '../lib'\nimport { ModuleIdentifier } from '../ModuleIdentifier'\nimport { ModuleIdentifierTransformer } from '../ModuleIdentifierTransformer'\nimport { traceModuleIdentifier } from './traceModuleIdentifier'\nimport { transformModuleIdentifier } from './transformModuleIdentifier'\n\n/*\n\nResolution rules\n\n1. Resolution is always done from the perspective of the module whose resolve function was called.\n\n2. Requesting '*' will return all the modules that the resolver can see. [limited by maxDepth]\n\n3. Requesting a simple ModuleName (string w/o ':' separator) will return an immediate child that has that name.\n\n4. Requesting a complex ModuleName (string w/ ':' separator) will resolve the first part and then recursively resolve\n the remaining name by calling the first part's resolved module's resolve with the remainder of the name.\n\n5. Requesting an Address (string) will return the module with that address, regardless of how distant it is from the module. [limited by maxDepth]\n\n6. Requesting a ModuleFilter will first request all the modules '*' and then filter them based on the filter settings. [Do we need this mode?]\n\n7. When a string is passed as the ModuleIdentifier, do the following:\n Check if id is complex (contains a ':')\n a) If it is complex, go to #4 above\n b) Call isAddress in the id to see if it is a valid address.\n i) If it is a valid address, go to #5 above\n ii) If it is not a valid address, go to # 3 above\n\n Note 1: If someone were to name a module with a valid address, that name will not be resolvable.\n Note 2: If someone were to name a module with a string containing a ':', that name will not be resolvable.\n\n8. Modules have two resolvers, up and down.\n a) Up Traversal\n i) Every module's upResolver also can call it's parent's upResolver\n ii) An upResolver also can see the parent's children's downResolvers\n iii) This means that when traversing upResolvers, you can traverse all the way up. [limited by maxDepth]\n iv) At any point of the up traversal, it can start traversing down to any immediate child, public or private.\n b) Down Traversal\n i) A down traversal is limited to the public children of the module. [The same as scope as calling the 'resolve' function]\n\n9. An up or a down traversal counts against the maxDepth\n\n*/\n\nexport interface ResolveHelperConfig {\n address: Address\n dead?: boolean\n downResolver?: ModuleResolver\n logger?: Logger\n module: ModuleInstance\n privateResolver?: ModuleResolver\n transformers: ModuleIdentifierTransformer[]\n upResolver?: ModuleResolver\n}\n\nexport class ResolveHelper {\n static defaultLogger?: Logger\n static transformers: ModuleIdentifierTransformer[] = []\n static async resolve<T extends ModuleInstance = ModuleInstance>(\n config: ResolveHelperConfig,\n all: '*',\n options?: ModuleFilterOptions<T>,\n ): Promise<T[]>\n static async resolve<T extends ModuleInstance = ModuleInstance>(\n config: ResolveHelperConfig,\n filter: ModuleFilter,\n options?: ModuleFilterOptions<T>,\n ): Promise<T[]>\n static async resolve<T extends ModuleInstance = ModuleInstance>(\n config: ResolveHelperConfig,\n id: ModuleIdentifier,\n options?: ModuleFilterOptions<T>,\n ): Promise<T | undefined>\n static async resolve<T extends ModuleInstance = ModuleInstance>(\n config: ResolveHelperConfig,\n idOrFilter: ModuleFilter<T> | ModuleIdentifier = '*',\n { maxDepth = 3, required = 'log', ...options }: ModuleFilterOptions<T> = {},\n ): Promise<T | T[] | undefined> {\n const { transformers, module, logger = this.defaultLogger, dead = false, upResolver, downResolver, privateResolver } = config\n const log = logger ? new IdLogger(logger, () => `ResolveHelper [${module.id}][${idOrFilter}]`) : undefined\n\n const downLocalOptions: ModuleFilterOptions<T> = { ...options, direction: 'down', maxDepth, required: false }\n const upLocalOptions: ModuleFilterOptions<T> = { ...downLocalOptions, direction: 'up' }\n\n const childOptions: ModuleFilterOptions<T> = { ...options, maxDepth: maxDepth - 1, required: false }\n\n const direction = options?.direction ?? 'all'\n const up = direction === 'up' || direction === 'all'\n const down = direction === 'down' || direction === 'all'\n let result: T | T[] | undefined\n log?.debug('start', idOrFilter, maxDepth)\n if (idOrFilter === '*') {\n if (dead) {\n log?.warn('failed [dead]', idOrFilter)\n return []\n }\n const modules = [\n ...(down ? await (downResolver as ModuleResolver).resolve<T>('*', downLocalOptions) : []),\n ...(up ? await (upResolver as ModuleResolver).resolve<T>('*', upLocalOptions) : []),\n ]\n .filter(duplicateModules)\n .filter((module) => module.address !== config.address)\n\n if (modules.length > 0) {\n log?.log('modules [count]', modules.length)\n log?.debug('modules', toJsonString(modules, 4))\n }\n\n if (maxDepth === 0) {\n return modules\n }\n const childModules = (await Promise.all(modules.map(async (module) => await module.resolve<T>('*', childOptions))))\n .flat()\n .filter(duplicateModules)\n return [...modules, ...childModules].filter(duplicateModules)\n } else {\n switch (typeof idOrFilter) {\n case 'string': {\n if (dead) {\n return undefined\n }\n\n const id = await this.transformModuleIdentifier(idOrFilter, transformers)\n\n if (id) {\n const resolvers = [\n [downResolver, downLocalOptions],\n [up ? upResolver : undefined, upLocalOptions],\n [up ? privateResolver : undefined, upLocalOptions],\n ].filter(([resolver]) => exists(resolver)) as [ModuleResolver, ModuleFilterOptions<T>][]\n\n for (const resolver of resolvers) {\n const [resolverInstance] = resolver\n if (!result) {\n result = await this.resolveModuleIdentifier<T>(resolverInstance, id)\n }\n }\n }\n\n break\n }\n default: {\n if (dead) {\n return []\n }\n const filter: ModuleFilter<T> | undefined = idOrFilter\n result = [\n ...(down ? await (downResolver as ModuleResolver).resolve<T>(filter, downLocalOptions) : []),\n ...(up ? await (upResolver as ModuleResolver).resolve<T>(filter, upLocalOptions) : []),\n ].filter(duplicateModules)\n break\n }\n }\n }\n this.validateRequiredResolve(required, result, idOrFilter, logger)\n return result\n }\n\n //resolves a complex module path to addresses\n static async resolveModuleIdentifier<T extends ModuleInstance = ModuleInstance>(\n resolver: ModuleResolver,\n path: ModuleIdentifier,\n required?: boolean,\n ): Promise<T | undefined> {\n const parts = path.split(':')\n const first = parts.shift()\n const firstIsAddress = isAddress(first)\n const resolvedModule =\n (await resolver.resolve(first, { maxDepth: firstIsAddress ? 10 : 1 })) ??\n (first ? await resolver.resolvePrivate(first, { maxDepth: firstIsAddress ? 10 : 1 }) : undefined)\n const finalModule = required ? assertEx(resolvedModule, () => `Failed to resolve [${first}] [${firstIsAddress}]`) : resolvedModule\n const firstModule = asModuleInstance(finalModule, () => `Resolved invalid module instance [${first}]`) as T\n if (firstModule) {\n return parts.length > 0 ? await this.resolveModuleIdentifier<T>(firstModule, parts.join(':')) : firstModule\n }\n }\n\n //translates a complex module path to addresses\n static traceModuleIdentifier(resolver: ModuleResolver, path: ModuleIdentifier) {\n return traceModuleIdentifier(resolver, path)\n }\n\n static transformModuleIdentifier(identifier: ModuleIdentifier, transformers: ModuleIdentifierTransformer[] = ResolveHelper.transformers) {\n return transformModuleIdentifier(identifier, transformers)\n }\n\n static validateRequiredResolve(\n required: boolean | 'warn' | 'log',\n result: ModuleInstance[] | ModuleInstance | undefined,\n idOrFilter: ModuleIdentifier | ModuleFilter,\n logger = this.defaultLogger,\n ) {\n const log = logger ? new IdLogger(logger, () => `validateRequiredResolve [${idOrFilter}][${result}]`) : undefined\n if (required && (result === undefined || (Array.isArray(result) && result.length > 0))) {\n switch (required) {\n case 'warn': {\n log?.warn('resolve failed', idOrFilter)\n break\n }\n case 'log': {\n log?.log('resolve failed', idOrFilter)\n break\n }\n default: {\n throw new Error(`resolve failed [${idOrFilter}]`)\n }\n }\n }\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Address } from '@xylabs/hex'\n\nimport { asModuleInstance, ModuleResolver } from '../instance'\nimport { ModuleIdentifier } from '../ModuleIdentifier'\n\nexport const traceModuleIdentifier = async (resolver: ModuleResolver, path: ModuleIdentifier): Promise<Address[]> => {\n const parts = path.split(':')\n const first = parts.shift()\n const firstModule = asModuleInstance(\n assertEx(await resolver.resolve(first, { maxDepth: 1 }), () => `Failed to resolve [${first}]`),\n () => `Resolved invalid module instance [${first}]`,\n )\n if (firstModule) {\n return parts.length > 0 ? [firstModule.address, ...(await traceModuleIdentifier(firstModule, parts.join(':')))] : [firstModule.address]\n }\n return []\n}\n","import { ModuleIdentifier } from '../ModuleIdentifier'\nimport { ModuleIdentifierTransformer } from '../ModuleIdentifierTransformer'\n\nexport const transformModuleIdentifier = async (\n id: ModuleIdentifier,\n transformers: ModuleIdentifierTransformer[],\n): Promise<ModuleIdentifier | undefined> => {\n let result: ModuleIdentifier | undefined = id\n for (const transformer of transformers) {\n result = await transformer.transform(id)\n }\n return result\n}\n","import { Address } from '@xylabs/hex'\n\nimport { ModuleInstance } from '../instance'\nimport { ModuleName } from '../ModuleIdentifier'\n\nexport const resolveLocalNameToAddressUp = async (root: ModuleInstance, localName: ModuleName): Promise<Address | undefined> => {\n const parents = (await root.parents?.()) ?? []\n return parents.find((parent) => parent.localName === localName)?.address\n}\n\n//since this is a localName, it only checks the children of the root module\nexport const resolveLocalNameToAddressDown = async (\n root: ModuleInstance,\n localName: ModuleName,\n includePrivate = false,\n): Promise<Address | undefined> => {\n const privateChildren = (includePrivate ? await root.privateChildren?.() : []) ?? []\n const publicChildren = (await root.publicChildren?.()) ?? []\n const children = [...privateChildren, ...publicChildren]\n return children.find((child) => child.localName === localName)?.address\n}\n\nexport const resolveLocalNameToAddress = async (\n root: ModuleInstance,\n localName: ModuleName,\n includePrivate = false,\n): Promise<Address | undefined> => {\n return (await resolveLocalNameToAddressDown(root, localName, includePrivate)) ?? (await resolveLocalNameToAddressUp(root, localName))\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Address, asAddress } from '@xylabs/hex'\n\nimport { ModuleInstance } from '../instance'\nimport { MODULE_PATH_SEPARATOR } from '../ModuleIdentifier'\nimport { ModuleIdentifierTransformer } from '../ModuleIdentifierTransformer'\nimport { resolveAddressToInstance } from './resolveAddressToInstance'\nimport { ResolveHelper } from './ResolveHelper'\nimport { resolveLocalNameToAddress } from './resolveLocalNameToAddress'\nimport { transformModuleIdentifier } from './transformModuleIdentifier'\n\nexport const resolvePathToAddress = async (\n root: ModuleInstance,\n path: string,\n includePrivate = false,\n transformers: ModuleIdentifierTransformer[] = ResolveHelper.transformers,\n): Promise<Address | undefined> => {\n const parts = path.split(MODULE_PATH_SEPARATOR)\n const first = await transformModuleIdentifier(\n assertEx(parts.shift(), () => `First part is invalid [${path}]`),\n transformers,\n )\n\n if (!first) {\n return undefined\n }\n\n const firstAddress = asAddress(first) ?? (await resolveLocalNameToAddress(root, first, includePrivate))\n\n if (firstAddress) {\n const firstModule = await resolveAddressToInstance(root, firstAddress, includePrivate)\n if (firstModule && parts.length > 0) {\n return resolvePathToAddress(firstModule, parts.join(MODULE_PATH_SEPARATOR))\n }\n return firstAddress\n }\n}\n","import { TypeCheck } from '@xylabs/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,IAAMA,qBAAyC;;;ACsB/C,SAASC,kBAAAA;AACd,SAAO,CAAqCC,gBAAAA;AAC1CA;EACF;AACF;AAJgBD;;;ACpBT,IAAME,iCAAiC,wBAC5CC,UACAC,aAAAA;AAGAD,WAASC,SAAQC,mBAAmB,IAAI;IAACD;OAAaD,SAASC,SAAQC,mBAAmB,KAAK,CAAA;;AAC/F,aAAWC,UAAUF,SAAQG,eAAe;AAC1CJ,aAASG,MAAAA,IAAU;SAAKH,SAASG,MAAAA,KAAW,CAAA;MAAKF;;EACnD;AACF,GAT8C;AAWvC,IAAMI,wCAAwC,wBACnDL,UACAC,UACAK,iBAAAA;AAEAN,WAASM,YAAAA,IAAgB;IAACL;OAAaD,SAASM,YAAAA,KAAiB,CAAA;;AACnE,GANqD;AAQ9C,IAAMC,mCAAmC,wBAC9CC,WACAR,WAAoC,CAAC,MAAC;AAEtC,aAAWC,YAAWO,WAAW;AAC/BT,mCAA+BC,UAAUC,QAAAA;EAC3C;AACA,SAAOD;AACT,GARgD;AAWzC,IAAMS,gCAAgC,wBAC3CC,SAAkC,CAAC,MAChCC,YAAAA;AAEHA,UAAQC,IAAI,CAACC,WACXC,OAAOC,QAAQF,MAAAA,EAAQD,IAAI,CAAC,CAACT,QAAQK,SAAAA,MAAU;AAC7C,QAAIA,WAAW;AACb,YAAMQ,oBAAoBN,OAAOP,MAAAA;AACjCO,aAAOP,MAAAA,IAAUa,oBAAqBN,OAAOP,MAAAA,IAAU;WAAIa;WAAsBR;UAAcA;IACjG;EACF,CAAA,CAAA;AAEF,SAAOE;AACT,GAb6C;;;AChCtC,IAAMO,YAAY,wBAACC,aAAAA;AACxB,SAAQA,SAA0CC,WAAWC;AAC/D,GAFyB;;;ACPzB,SAASC,gBAAgB;AACzB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;;ACN7B,IAAMO,cAAc;EACzBC,QAAQ,CAAmBC,cAAAA;AACzB,WAAO,CAELC,QAEAC,YAAAA;AAEA,aAAOF,UAAUC,MAAAA,IAAUC,QAAQD,MAAAA,IAAUE;IAC/C;EACF;AACF;AAEO,IAAMC,aAAaN,YAAYC,OAAOM,QAAAA;AACtC,IAAMC,qBAAqBR,YAAYC,OAAOQ,gBAAAA;","names":["ModuleConfigSchema","creatableModule","constructor","registerCreatableModuleFactory","registry","factory","defaultConfigSchema","schema","configSchemas","registerPrimaryCreatableModuleFactory","configSchema","registerCreatableModuleFactories","factories","assignCreatableModuleRegistry","target","sources","map","source","Object","entries","existingFactories","hasLabels","factory","labels","undefined","assertEx","merge","ModuleFactory","configSchemas","creatableModule","defaultConfigSchema","defaultLogger","defaultParams","labels","constructor","params","assertEx","includes","Object","assign","withParams","_getRootFunction","funcName","anyThis","__proto__","_noOverride","functionName","thisFunc","rootFunc","create","factory","schema","mergedParams","merge","config","_params","Error","AsObjectFactory","IsObjectFactory","AsObjectFactory","ModuleManifestQuerySchema","ModuleAddressQuerySchema","ModuleStateQuerySchema","ModuleSubscribeQuerySchema","AsObjectFactory","IsObjectFactory","requiredModuleShape","address","queries","query","factory","isModuleObject","create","asModuleObject","AsObjectFactory","create","isModuleObject","IsModuleFactory","create","expectedQueries","additionalChecks","obj","config","module","asModuleObject","result","isModuleObject","reduce","prev","query","queries","includes","check","requiredModuleQueries","ModuleStateQuerySchema","factory","IsModuleFactory","isModule","create","isModuleObject","asModule","AsObjectFactory","create","isModule","requiredModuleInstanceFunctions","manifest","state","factory","IsObjectFactory","isModuleInstance","create","isModule","asModuleInstance","AsObjectFactory","create","isModuleInstance","AsObjectFactory","IsObjectFactory","requiredAttachableModuleInstanceFunctions","downResolver","upResolver","factory","IsObjectFactory","isAttachableModuleInstance","create","isModuleInstance","asAttachableModuleInstance","AsObjectFactory","create","isAttachableModuleInstance","IsObjectFactory","IsAttachableModuleInstanceFactory","IsObjectFactory","IsObjectFactory","toJsonString","DeadModuleError","Error","constructor","id","error","msg","message","toJsonString","Object","setPrototypeOf","prototype","IsInstanceFactory","IsObjectFactory","isAddressObjectFilter","value","address","undefined","isNameObjectFilter","name","isQueryObjectFilter","query","isAddressModuleFilter","isAddressObjectFilter","isNameModuleFilter","isNameObjectFilter","isQueryModuleFilter","isQueryObjectFilter","isObjectResolver","value","resolve","ObjectResolverPriority","isModuleResolver","isObjectResolver","hasAllLabels","source","required","Object","entries","every","key","value","hasOwnProperty","duplicateModules","value","index","array","findIndex","v","address","every","isArray","isBoolean","isNull","isNumber","isPlainObject","isString","isUndefined","overSome","JSONPrimitiveChecks","isUndefined","isNull","isBoolean","isNumber","isString","JSONComplexChecks","isPlainObject","isArray","serializable","field","depth","depthExceeded","decrementDepth","undefined","recursiveSerializable","nestedSerializable","overSome","every","valid","serializableField","isAddress","MODULE_PATH_SEPARATOR","DisallowedModuleIdentifierCharacters","$","_","ReservedModuleIdentifierCharacters","Set","Object","keys","isModuleName","value","isAddress","includesReservedModuleIdentifierCharacter","some","char","has","isModuleIdentifierPart","AddressSchema","AddressPreviousHashSchema","ModuleDescriptionSchema","isPayloadOfSchemaType","ModuleStateSchema","isModuleState","payload","isPayloadOfSchemaType","isModuleStateWithMeta","resolveAddressToInstanceDown","root","address","includePrivate","ignore","cache","addressCache","privateChildren","publicChildren","children","child","found","set","WeakRef","resolveAddressToInstanceSiblings","siblings","sibling","resolveAddressToInstanceUp","parents","parent","resolveAddressToInstance","result","assertEx","exists","isAddress","IdLogger","toJsonString","assertEx","traceModuleIdentifier","resolver","path","parts","split","first","shift","firstModule","asModuleInstance","assertEx","resolve","maxDepth","length","address","join","transformModuleIdentifier","id","transformers","result","transformer","transform","ResolveHelper","resolve","config","idOrFilter","maxDepth","required","options","transformers","module","logger","defaultLogger","dead","upResolver","downResolver","privateResolver","log","IdLogger","id","undefined","downLocalOptions","direction","upLocalOptions","childOptions","up","down","result","debug","warn","modules","filter","duplicateModules","address","length","toJsonString","childModules","Promise","all","map","flat","transformModuleIdentifier","resolvers","resolver","exists","resolverInstance","resolveModuleIdentifier","validateRequiredResolve","path","parts","split","first","shift","firstIsAddress","isAddress","resolvedModule","resolvePrivate","finalModule","assertEx","firstModule","asModuleInstance","join","traceModuleIdentifier","identifier","Array","isArray","Error","resolveLocalNameToAddressUp","root","localName","parents","find","parent","address","resolveLocalNameToAddressDown","includePrivate","privateChildren","publicChildren","children","child","resolveLocalNameToAddress","assertEx","asAddress","resolvePathToAddress","root","path","includePrivate","transformers","ResolveHelper","parts","split","MODULE_PATH_SEPARATOR","first","transformModuleIdentifier","assertEx","shift","undefined","firstAddress","asAddress","resolveLocalNameToAddress","firstModule","resolveAddressToInstance","length","join","WithFactory","create","typeCheck","module","closure","undefined","withModule","isModule","withModuleInstance","isModuleInstance"]}
package/package.json CHANGED
@@ -18,12 +18,12 @@
18
18
  "@xylabs/object": "^3.1.10",
19
19
  "@xylabs/promise": "^3.1.10",
20
20
  "@xylabs/retry": "^3.1.10",
21
- "@xyo-network/account-model": "~2.98.2",
22
- "@xyo-network/address-payload-plugin": "~2.98.2",
23
- "@xyo-network/boundwitness-model": "~2.98.2",
24
- "@xyo-network/manifest-model": "~2.98.2",
25
- "@xyo-network/module-events": "~2.98.2",
26
- "@xyo-network/payload-model": "~2.98.2"
21
+ "@xyo-network/account-model": "~2.98.3",
22
+ "@xyo-network/address-payload-plugin": "~2.98.3",
23
+ "@xyo-network/boundwitness-model": "~2.98.3",
24
+ "@xyo-network/manifest-model": "~2.98.3",
25
+ "@xyo-network/module-events": "~2.98.3",
26
+ "@xyo-network/payload-model": "~2.98.3"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@xylabs/ts-scripts-yarn3": "^3.9.1",
@@ -69,6 +69,6 @@
69
69
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
70
70
  },
71
71
  "sideEffects": false,
72
- "version": "2.98.2",
72
+ "version": "2.98.3",
73
73
  "type": "module"
74
74
  }
@@ -2,4 +2,3 @@ export * from './CreatableModule'
2
2
  export * from './CreatableModuleRegistry'
3
3
  export * from './LabeledCreatableModuleFactory'
4
4
  export * from './ModuleFactory'
5
- export * from './ModuleFactoryLocator'
@@ -1,47 +0,0 @@
1
- import { Schema } from '@xyo-network/payload-model';
2
- import { AttachableModuleInstance } from '../instance';
3
- import { Labels } from '../Labels';
4
- import { CreatableModuleFactory } from './CreatableModule';
5
- import { CreatableModuleRegistry } from './CreatableModuleRegistry';
6
- import { LabeledCreatableModuleFactory } from './LabeledCreatableModuleFactory';
7
- /**
8
- * A class which encapsulates the Service Locator Pattern for Module Factories
9
- */
10
- export declare class ModuleFactoryLocator {
11
- protected readonly _registry: CreatableModuleRegistry;
12
- constructor(_registry?: CreatableModuleRegistry);
13
- /**
14
- * The current registry for the module factory
15
- */
16
- get registry(): Readonly<CreatableModuleRegistry>;
17
- /**
18
- * Locates a module factory that matches the supplied schema and labels
19
- * @param schema The config schema for the module
20
- * @param labels The labels for the module factory
21
- * @returns A module factory that matches the supplied schema and labels or throws if one is not found
22
- */
23
- locate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory;
24
- /**
25
- * Registers a single module factory (with optional tags) with the locator
26
- * @param additional Additional module factories to register
27
- */
28
- register(mod: CreatableModuleFactory, labels?: Labels): this;
29
- /**
30
- * Registers multiple module factories with the locator
31
- * @param additional Additional module factories to register
32
- */
33
- registerMany(mods: CreatableModuleFactory[]): this;
34
- /**
35
- * Registers a single module factory (with optional tags) with the locator & a specific schema
36
- * @param additional Additional module factories to register
37
- */
38
- registerOne<TModule extends AttachableModuleInstance>(mod: CreatableModuleFactory<TModule>, schema: Schema, labels?: Labels, primary?: boolean): this;
39
- /**
40
- * Tries to locate a module factory that matches the supplied schema and labels
41
- * @param schema The config schema for the module
42
- * @param labels The labels for the module factory
43
- * @returns A module factory that matches the supplied schema and labels or undefined
44
- */
45
- tryLocate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory | undefined;
46
- }
47
- //# sourceMappingURL=ModuleFactoryLocator.d.ts.map