@xyo-network/sdk 8.1.0 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/dist/neutral/account-custody.d.ts +2 -0
- package/dist/neutral/account-custody.d.ts.map +1 -0
- package/dist/neutral/account-custody.mjs +542 -0
- package/dist/neutral/account-custody.mjs.map +7 -0
- package/dist/neutral/address-payload-plugin.mjs +3 -14
- package/dist/neutral/address-payload-plugin.mjs.map +4 -4
- package/dist/neutral/api-location-diviner.mjs +0 -2
- package/dist/neutral/api-location-diviner.mjs.map +2 -2
- package/dist/neutral/archivist-memory.mjs +1 -4
- package/dist/neutral/archivist-memory.mjs.map +2 -2
- package/dist/neutral/bridge-abstract.mjs +4 -7
- package/dist/neutral/bridge-abstract.mjs.map +2 -2
- package/dist/neutral/bridge-http.mjs +1 -1
- package/dist/neutral/bridge-http.mjs.map +2 -2
- package/dist/neutral/diviner-boundwitness.memory.mjs +1 -1
- package/dist/neutral/diviner-boundwitness.memory.mjs.map +2 -2
- package/dist/neutral/diviner-boundwitness.mjs +1 -1
- package/dist/neutral/diviner-boundwitness.mjs.map +2 -2
- package/dist/neutral/diviner-payload-generic.mjs +3 -3
- package/dist/neutral/diviner-payload-generic.mjs.map +2 -2
- package/dist/neutral/index.d.ts +1 -0
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +1 -0
- package/dist/neutral/index.mjs.map +2 -2
- package/dist/neutral/module-abstract.mjs +4 -4
- package/dist/neutral/module-abstract.mjs.map +3 -3
- package/dist/neutral/module-resolver.mjs +3 -6
- package/dist/neutral/module-resolver.mjs.map +2 -2
- package/dist/neutral/modules/account-custody/AccountCustody.d.ts +14 -0
- package/dist/neutral/modules/account-custody/AccountCustody.d.ts.map +1 -0
- package/dist/neutral/modules/account-custody/AccountCustodyClient.d.ts +4 -0
- package/dist/neutral/modules/account-custody/AccountCustodyClient.d.ts.map +1 -0
- package/dist/neutral/modules/account-custody/clientExecution.d.ts +11 -0
- package/dist/neutral/modules/account-custody/clientExecution.d.ts.map +1 -0
- package/dist/neutral/modules/account-custody/clientModel.d.ts +49 -0
- package/dist/neutral/modules/account-custody/clientModel.d.ts.map +1 -0
- package/dist/neutral/modules/account-custody/clientOwner.d.ts +7 -0
- package/dist/neutral/modules/account-custody/clientOwner.d.ts.map +1 -0
- package/dist/neutral/modules/account-custody/clientSignals.d.ts +4 -0
- package/dist/neutral/modules/account-custody/clientSignals.d.ts.map +1 -0
- package/dist/neutral/modules/account-custody/clientState.d.ts +31 -0
- package/dist/neutral/modules/account-custody/clientState.d.ts.map +1 -0
- package/dist/neutral/modules/account-custody/error.d.ts +8 -0
- package/dist/neutral/modules/account-custody/error.d.ts.map +1 -0
- package/dist/neutral/modules/account-custody/index.d.ts +7 -0
- package/dist/neutral/modules/account-custody/index.d.ts.map +1 -0
- package/dist/neutral/modules/account-custody/model.d.ts +65 -0
- package/dist/neutral/modules/account-custody/model.d.ts.map +1 -0
- package/dist/neutral/modules/account-custody/realmRegistry.d.ts +2 -0
- package/dist/neutral/modules/account-custody/realmRegistry.d.ts.map +1 -0
- package/dist/neutral/modules/address-payload-plugin/Plugin.d.ts.map +1 -1
- package/dist/neutral/modules/address-payload-plugin/index.d.ts +0 -1
- package/dist/neutral/modules/address-payload-plugin/index.d.ts.map +1 -1
- package/dist/neutral/modules/api-location-diviner/RemoteDivinerConfig.d.ts +0 -2
- package/dist/neutral/modules/api-location-diviner/RemoteDivinerConfig.d.ts.map +1 -1
- package/dist/neutral/modules/archivist-memory/MemoryDriver.d.ts.map +1 -1
- package/dist/neutral/modules/bridge-abstract/AbstractModuleProxy/ModuleProxyResolver.d.ts.map +1 -1
- package/dist/neutral/modules/bridge-http/HttpBridge.d.ts.map +1 -1
- package/dist/neutral/modules/diviner-boundwitness/applyBoundWitnessDivinerQueryPayload.d.ts.map +1 -1
- package/dist/neutral/modules/diviner-payload-generic/Diviner.d.ts.map +1 -1
- package/dist/neutral/modules/module-resolver/AbstractModuleResolver.d.ts.map +1 -1
- package/dist/neutral/modules/module-resolver/ResolverEventEmitter.d.ts.map +1 -1
- package/dist/neutral/modules/node-memory/MemoryNode.d.ts.map +1 -1
- package/dist/neutral/node-memory.mjs +1 -4
- package/dist/neutral/node-memory.mjs.map +2 -2
- package/dist/node/account-custody.d.ts +2 -0
- package/dist/node/account-custody.d.ts.map +1 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.mjs +1 -0
- package/dist/node/index.mjs.map +2 -2
- package/dist/node/modules/account-custody/clientExecution.d.ts +11 -0
- package/dist/node/modules/account-custody/clientExecution.d.ts.map +1 -0
- package/dist/node/modules/account-custody/clientSignals.d.ts +4 -0
- package/dist/node/modules/account-custody/clientSignals.d.ts.map +1 -0
- package/dist/node/modules/account-custody/realmRegistry.d.ts +2 -0
- package/dist/node/modules/account-custody/realmRegistry.d.ts.map +1 -0
- package/dist/node/modules/archivist-memory/MemoryDriver.d.ts.map +1 -1
- package/package.json +17 -11
- package/dist/neutral/modules/address-payload-plugin/Template.d.ts +0 -3
- package/dist/neutral/modules/address-payload-plugin/Template.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/modules/module-resolver/AbstractModuleResolver.ts", "../../src/modules/module-resolver/CompositeModuleResolver.ts", "../../src/modules/module-resolver/ResolveHelper/resolveAddressToInstance.ts", "../../src/modules/module-resolver/ResolveHelper/resolveAll.ts", "../../src/modules/module-resolver/ResolveHelper/ResolveHelper.ts", "../../src/modules/module-resolver/ResolveHelper/ResolveHelperStatic.ts", "../../src/modules/module-resolver/ResolveHelper/resolvePathToInstance.ts", "../../src/modules/module-resolver/ResolveHelper/resolveLocalNameToInstance.ts", "../../src/modules/module-resolver/ResolveHelper/resolveLocalNameToAddress.ts", "../../src/modules/module-resolver/ResolveHelper/transformModuleIdentifier.ts", "../../src/modules/module-resolver/ResolveHelper/resolvePathToAddress.ts", "../../src/modules/module-resolver/ResolveHelper/traceModuleIdentifier.ts", "../../src/modules/module-resolver/SimpleModuleResolver.ts", "../../src/modules/module-resolver/NameRegistrarTransformer.ts", "../../src/modules/module-resolver/ResolverEventEmitter.ts"],
|
|
4
|
-
"sourcesContent": ["import type { BaseParams, Promisable } from '@ariestools/sdk'\nimport {\n assertEx, Base, toSafeJsonString,\n} from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type {\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleInstance,\n ModuleResolverInstance,\n ObjectFilterOptions,\n} from '#module-model'\nimport {\n asModuleInstance,\n ObjectResolverPriority,\n} from '#module-model'\n\nexport interface ModuleResolverParams extends BaseParams {\n priority?: ObjectResolverPriority\n root: ModuleInstance\n}\n\nexport abstract class AbstractModuleResolver<TParams extends ModuleResolverParams = ModuleResolverParams>\n extends Base<TParams>\n implements ModuleResolverInstance {\n get priority() {\n return this.params.priority ?? ObjectResolverPriority.Normal\n }\n\n set priority(value: ObjectResolverPriority) {\n this.params.priority = value\n }\n\n get root(): ModuleInstance {\n return assertEx(this.params.root, () => 'root is not set')\n }\n\n async resolve<T extends ModuleInstance = ModuleInstance>(): Promise<T[]>\n async resolve<T extends ModuleInstance = ModuleInstance>(all: '*', options?: ModuleFilterOptions<T>): Promise<T[]>\n async resolve<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ModuleFilterOptions<T>): Promise<T | undefined>\n async resolve<T extends ModuleInstance = ModuleInstance>(\n id: ModuleIdentifier = '*',\n options?: ModuleFilterOptions<T>,\n ): Promise<T[] | T | undefined> {\n if (id === '*') {\n const values = await this.resolveHandler(id, options)\n assertEx(Array.isArray(values), () => 'resolveHandler returned a non-array')\n return values.map(value =>\n asModuleInstance<T>(value, () => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n return `resolveHandler returned invalid result (*) [${(value as any)?.constructor?.name}][${toSafeJsonString(value)}]`\n }, { required: true }))\n }\n switch (typeof id) {\n case 'string': {\n const [value] = await this.resolveHandler(id, options)\n return asModuleInstance<T>(\n value,\n () =>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n `resolveHandler returned invalid result (string) [${(value as any)?.constructor?.name}][${toSafeJsonString(value)}]`,\n )\n }\n default: {\n break\n }\n }\n }\n\n async resolvePrivate<T extends ModuleInstance = ModuleInstance>(all: '*', options?: ObjectFilterOptions<T>): Promise<T[]>\n async resolvePrivate<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ObjectFilterOptions<T>): Promise<T | undefined>\n async resolvePrivate<T extends ModuleInstance = ModuleInstance>(\n id: ModuleIdentifier,\n _options?: ObjectFilterOptions<T>,\n ): Promise<T | T[] | undefined> {\n if (id === '*') return []\n }\n\n abstract addResolver(resolver: ModuleResolverInstance): this\n abstract removeResolver(resolver: ModuleResolverInstance): this\n\n abstract resolveHandler<T extends ModuleInstance = ModuleInstance>(\n id: ModuleIdentifier,\n options?: ModuleFilterOptions<T>,\n ): Promisable<T[]>\n\n abstract resolveIdentifier(id: ModuleIdentifier, options?: ObjectFilterOptions): Promisable<XyoAddress | undefined>\n}\n", "/* eslint-disable max-statements */\nimport type { Promisable } from '@ariestools/sdk'\nimport {\n assertEx,\n exists, isDefined, isString,\n} from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk-protocol'\nimport { LRUCache } from 'lru-cache'\n\nimport type {\n CacheConfig,\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleIdentifierPart,\n ModuleIdentifierTransformer,\n ModuleInstance,\n ModuleRepository,\n ModuleResolverInstance,\n ObjectFilterOptions,\n} from '#module-model'\nimport {\n duplicateModules,\n ObjectResolverPriority,\n} from '#module-model'\n\nimport type { ModuleResolverParams } from './AbstractModuleResolver.ts'\nimport { AbstractModuleResolver } from './AbstractModuleResolver.ts'\nimport { ResolveHelper } from './ResolveHelper/index.ts'\nimport { SimpleModuleResolver } from './SimpleModuleResolver.ts'\n\nexport interface CompositeModuleResolverParams extends ModuleResolverParams {\n allowNameResolution?: boolean\n cache?: CacheConfig\n moduleIdentifierTransformers?: ModuleIdentifierTransformer[]\n}\n\nconst moduleIdentifierParts = (moduleIdentifier: ModuleIdentifier): ModuleIdentifierPart[] => {\n return moduleIdentifier?.split(':')\n}\n\nexport class CompositeModuleResolver<T extends CompositeModuleResolverParams = CompositeModuleResolverParams>\n extends AbstractModuleResolver<T>\n implements ModuleRepository, ModuleResolverInstance {\n static readonly defaultMaxDepth = 3\n\n protected _cache: LRUCache<ModuleIdentifier, ModuleInstance>\n protected resolvers: ModuleResolverInstance[] = []\n private _allowAddResolver = true\n private _localResolver: SimpleModuleResolver\n\n constructor(params: T) {\n super(params)\n const localResolver = new SimpleModuleResolver({ allowNameResolution: params.allowNameResolution, root: params.root })\n this.addResolver(localResolver)\n const { max = 100, ttl = 1000 * 5 /* five seconds */ } = params.cache ?? {}\n this._cache = new LRUCache<ModuleIdentifier, ModuleInstance>({\n max, ttl, ...params.cache,\n })\n this._localResolver = localResolver\n }\n\n get allowAddResolver() {\n return this._allowAddResolver\n }\n\n set allowAddResolver(value: boolean) {\n this.resolvers = [this._localResolver]\n this._allowAddResolver = value\n }\n\n get allowNameResolution(): boolean {\n return this.params.allowNameResolution ?? true\n }\n\n private get moduleIdentifierTransformers() {\n return this.params.moduleIdentifierTransformers ?? ResolveHelper.transformers\n }\n\n add(mod: ModuleInstance): this\n add(mod: ModuleInstance[]): this\n add(mod: ModuleInstance | ModuleInstance[]): this {\n if (Array.isArray(mod)) {\n for (const modItem of mod) this.addSingleModule(modItem)\n } else {\n this.addSingleModule(mod)\n }\n return this\n }\n\n addResolver(resolver: ModuleResolverInstance): this {\n if (this.allowAddResolver) {\n this.resolvers.push(resolver)\n }\n return this\n }\n\n remove(addresses: XyoAddress[] | XyoAddress): this {\n if (Array.isArray(addresses)) {\n for (const address of addresses) this.removeSingleModule(address)\n } else {\n this.removeSingleModule(addresses)\n }\n return this\n }\n\n removeResolver(resolver: ModuleResolverInstance): this {\n this.resolvers = this.resolvers.filter(item => item !== resolver)\n return this\n }\n\n // eslint-disable-next-line complexity\n async resolveHandler<T extends ModuleInstance = ModuleInstance>(\n id: ModuleIdentifier = '*',\n options: ModuleFilterOptions<T> = {},\n ): Promise<T[]> {\n const mutatedOptions = { ...options, maxDepth: options?.maxDepth ?? CompositeModuleResolver.defaultMaxDepth }\n\n // resolve all\n if (id === '*') {\n // wen't too far?\n if (mutatedOptions.maxDepth < 0) {\n return []\n }\n\n // identity resolve?\n if (mutatedOptions.maxDepth === 0) {\n return (await this._localResolver.resolve('*', mutatedOptions)) ?? []\n }\n\n const childOptions = { ...mutatedOptions, maxDepth: mutatedOptions?.maxDepth - 1 }\n\n const result = await Promise.all(\n this.resolvers.map(async (resolver) => {\n const result: T[] = await resolver.resolve<T>('*', childOptions)\n return result\n }),\n )\n const flatResult: T[] = result.flat().filter(exists)\n return flatResult.filter((v, i, a) => duplicateModules(v, i, a))\n }\n\n if (typeof id === 'string') {\n // wen't too far?\n if (mutatedOptions.maxDepth < 0) {\n return []\n }\n\n // resolve ModuleIdentifier\n const idParts = moduleIdentifierParts(id)\n if (idParts.length > 1) {\n const mod = await this.resolveMultipartIdentifier<T>(id)\n return (\n mod\n ? Array.isArray(mod)\n ? mod\n : [mod]\n : []\n )\n }\n const resolvedId = await ResolveHelper.transformModuleIdentifier(id, this.moduleIdentifierTransformers)\n if (isString(resolvedId)) {\n if (mutatedOptions.maxDepth < 0) {\n return []\n }\n const cachedResult = this._cache.get(resolvedId)\n if (cachedResult) {\n if (cachedResult.status === 'error') {\n this._cache.delete(id)\n } else {\n return [cachedResult] as T[]\n }\n }\n\n // identity resolve?\n if (mutatedOptions.maxDepth === 0) {\n const mod = await this._localResolver.resolve(resolvedId, mutatedOptions)\n return (\n isDefined(mod)\n ? Array.isArray(mod)\n ? mod\n : [mod]\n : []\n )\n }\n\n // recursive function to resolve by priority\n const resolvePriority = async (priority: ObjectResolverPriority): Promise<T | undefined> => {\n const resolvers = this.resolvers.filter(resolver => resolver.priority === priority)\n const resolved = await Promise.all(\n resolvers.map(async (resolver) => {\n const result: T | undefined = await resolver.resolve<T>(resolvedId, mutatedOptions)\n return result\n }),\n )\n const results: T[] = resolved.filter(exists)\n\n const result: T | undefined = results.filter(exists).findLast((v, i, a) => duplicateModules(v, i, a))\n if (result) {\n this._cache.set(resolvedId, result)\n return result\n }\n // we know that ObjectResolverPriority.VeryLow is the minimum priority, so we can subtract 1 from the rest\n return priority === ObjectResolverPriority.VeryLow ? undefined : await resolvePriority((priority - 1) as ObjectResolverPriority)\n }\n const mod = await resolvePriority(ObjectResolverPriority.VeryHigh)\n return (\n mod\n ? Array.isArray(mod)\n ? mod\n : [mod]\n : []\n )\n }\n }\n return []\n }\n\n async resolveIdentifier(id: ModuleIdentifier, _options?: ObjectFilterOptions): Promise<XyoAddress | undefined> {\n const idParts = id.split(':')\n if (idParts.length > 1) {\n return this.resolveComplexIdentifier(id)\n }\n const resolved = await Promise.all(\n this.resolvers.map(async (resolver) => {\n return await resolver.resolveIdentifier(id)\n }),\n )\n const results = resolved.filter(exists)\n const result = results.shift()\n for (const altResult of results) {\n assertEx(altResult === result, () => `Inconsistent results for ${id} [${result}][${altResult}]`)\n }\n return result\n }\n\n protected resolveComplexIdentifier(_id: ModuleIdentifier, _options?: ObjectFilterOptions): Promisable<XyoAddress | undefined> {\n throw new Error('Method not implemented.')\n }\n\n private addSingleModule(mod?: ModuleInstance) {\n if (mod) {\n this._localResolver.add(mod)\n }\n }\n\n private removeSingleModule(address: XyoAddress) {\n this._localResolver.remove(address)\n }\n\n private async resolveMultipartIdentifier<T extends ModuleInstance = ModuleInstance>(moduleIdentifier: ModuleIdentifier): Promise<T | undefined> {\n const idParts = moduleIdentifierParts(moduleIdentifier)\n assertEx(idParts.length >= 2, () => 'Not a valid multipart identifier')\n const id = assertEx(idParts.shift())\n const mod = (await this.resolve<T>(id)) ?? (await this.resolvePrivate<T>(id))\n return (await mod?.resolve<T>(idParts.join(':'))) ?? (await mod?.resolvePrivate<T>(idParts.join(':')))\n }\n}\n", "import type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { ModuleInstance } from '#module-model'\n\nimport type { ModuleResolveDirection } from './model.ts'\n\nexport const resolveAddressToInstanceDown = async (\n root: ModuleInstance,\n address: XyoAddress,\n includePrivate?: boolean,\n ignore: XyoAddress[] = [],\n): Promise<ModuleInstance | undefined> => {\n if (root.address === address) {\n return root\n }\n const cache = root.addressCache?.('up', includePrivate ?? false)\n const privateChildren = (includePrivate === true ? 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: XyoAddress,\n includePrivate?: boolean,\n ignore: XyoAddress[] = [],\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: XyoAddress,\n includePrivate?: boolean,\n ignore: XyoAddress[] = [],\n): Promise<ModuleInstance | undefined> => {\n const cache = root.addressCache?.('up', includePrivate ?? true)\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 resolveAddressToInstanceAll = async (\n root: ModuleInstance,\n address: XyoAddress,\n includePrivate?: boolean,\n ignore: XyoAddress[] = [],\n): Promise<ModuleInstance | undefined> => {\n const cache = root.addressCache?.('all', includePrivate ?? false)\n const result\n = (await resolveAddressToInstanceDown(root, address, includePrivate ?? false, ignore))\n ?? (await resolveAddressToInstanceUp(root, address, includePrivate ?? true, ignore))\n cache?.set(address, result ? new WeakRef(result) : null)\n return result\n}\n\nexport const resolveAddressToInstance = async (\n root: ModuleInstance,\n address: XyoAddress,\n includePrivate?: boolean,\n ignore: XyoAddress[] = [],\n direction: ModuleResolveDirection = 'all',\n): Promise<ModuleInstance | undefined> => {\n switch (direction) {\n case 'all': {\n return await resolveAddressToInstanceAll(root, address, includePrivate, ignore)\n }\n case 'up': {\n return await resolveAddressToInstanceUp(root, address, includePrivate ?? true, ignore)\n }\n case 'down': {\n return await resolveAddressToInstanceDown(root, address, includePrivate ?? false, ignore)\n }\n }\n}\n", "import type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { ModuleInstance } from '#module-model'\nimport { duplicateModules } from '#module-model'\n\nexport const resolveAllUp = async (root: ModuleInstance, maxDepth = 10, exclude: XyoAddress[] = []): Promise<ModuleInstance[]> => {\n if (maxDepth === 0) {\n return [root].filter(mod => !exclude.includes(mod.address))\n }\n const allParents = await root.parents()\n const parents = allParents.filter(mod => !exclude.includes(mod.address))\n if (maxDepth <= 1) {\n return [...parents, root]\n }\n const upResults = await Promise.all(parents.map(async mod => await resolveAllUp(mod, maxDepth - 1, [...exclude, root.address])))\n const downResults = await Promise.all(parents.map(async mod => await resolveAllDown(mod, maxDepth - 1, [...exclude, root.address], true)))\n return [...upResults.flat(), ...downResults.flat(), ...parents, root]\n}\n\nexport const resolveAllDown = async (\n root: ModuleInstance,\n maxDepth = 10,\n exclude: XyoAddress[] = [],\n includePrivate = false,\n): Promise<ModuleInstance[]> => {\n if (maxDepth === 0) {\n return [root]\n }\n const publicModules = await root.publicChildren()\n const children = publicModules.filter(mod => !exclude.includes(mod.address))\n if (maxDepth <= 1) {\n return [...children, root]\n }\n const privateModules = includePrivate ? await root.privateChildren() : []\n const privateChildren = privateModules.filter(mod => !exclude.includes(mod.address))\n const childResults = await Promise.all(children.map(child => resolveAllDown(child, maxDepth - 1, [...exclude, root.address])))\n const privateChildResults = await Promise.all(privateChildren.map(child => resolveAllDown(child, maxDepth - 1, [...exclude, root.address])))\n return [...children, ...childResults.flat(), ...privateChildResults.flat(), root]\n}\n\nexport const resolveAll = async (root: ModuleInstance, maxDepth = 10, exclude: XyoAddress[] = []): Promise<ModuleInstance[]> => {\n return maxDepth === 0 ? [root] : [...(await resolveAllUp(root, maxDepth, exclude)), ...(await resolveAllDown(root, maxDepth, exclude))].filter(duplicateModules)\n}\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type { Logger } from '@ariestools/sdk'\nimport {\n assertEx,\n exists,\n IdLogger,\n isAddress,\n isDefined, isString, isTruthy,\n} from '@ariestools/sdk'\nimport type { XyoAddress, XyoQuantAddress } from '@xyo-network/sdk-protocol'\n\nimport type {\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleIdentifierTransformer,\n ModuleInstance,\n ModuleResolver,\n} from '#module-model'\nimport {\n asModuleInstance, duplicateModules, isModuleInstance,\n} from '#module-model'\n\nimport { ResolveHelperStatic } from './ResolveHelperStatic.ts'\nimport { resolvePathToAddress } from './resolvePathToAddress.ts'\nimport { traceModuleIdentifier } from './traceModuleIdentifier.ts'\nimport { transformModuleIdentifier } from './transformModuleIdentifier.ts'\n\nfunction resolvingModule(resolver: ModuleResolver): ModuleInstance | undefined {\n if (!('root' in resolver) || typeof resolver.root !== 'object' || resolver.root === null) {\n return undefined\n }\n return isModuleInstance(resolver.root) ? resolver.root : undefined\n}\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 1: If someone were to name a module with a valid address, that name will not be resolvable.\n 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: XyoAddress\n dead?: boolean\n downResolver?: ModuleResolver\n logger?: Logger\n mod: ModuleInstance\n privateResolver?: ModuleResolver\n transformers: ModuleIdentifierTransformer[]\n upResolver?: ModuleResolver\n}\n\nexport class ResolveHelper extends ResolveHelperStatic {\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 id: ModuleIdentifier,\n options?: ModuleFilterOptions<T>,\n ): Promise<T | undefined>\n static async resolve<T extends ModuleInstance = ModuleInstance>(\n config: ResolveHelperConfig,\n id: ModuleIdentifier = '*',\n {\n maxDepth = 3, required = 'log', ...options\n }: ModuleFilterOptions<T> = {},\n ): Promise<T | T[] | undefined> {\n const {\n transformers, mod, logger = this.defaultLogger, dead = false, upResolver, downResolver, privateResolver,\n } = config\n const log = logger ? new IdLogger(logger, () => `ResolveHelper [${mod.id}][${id}]`) : undefined\n\n const direction = options.direction ?? 'all'\n const downLocalOptions: ModuleFilterOptions<T> = {\n ...options, direction: 'down', maxDepth, required: false,\n }\n const upLocalOptions: ModuleFilterOptions<T> = { ...downLocalOptions, direction: 'up' }\n\n // Children must be expanded downward. direction `all` would let each child look up and\n // surface the parent's private children back into this result.\n const childOptions: ModuleFilterOptions<T> = {\n ...options,\n direction: direction === 'all' ? 'down' : direction,\n maxDepth: maxDepth - 1,\n required: false,\n }\n const up = direction === 'up' || direction === 'all'\n const down = direction === 'down' || direction === 'all'\n log?.debug('start', id, maxDepth)\n if (id === '*') {\n if (dead) {\n log?.warn('failed [dead]', id)\n return []\n }\n const modules = [\n ...(down ? await (downResolver!).resolve<T>('*', downLocalOptions) : []),\n ...(up ? await (upResolver!).resolve<T>('*', upLocalOptions) : []),\n ].filter(duplicateModules)\n\n if (modules.length > 0) {\n log?.debug('modules [count]', modules.length)\n }\n\n if (maxDepth === 0) {\n return modules\n }\n const resolvedChildren = await Promise.all(modules.map(async mod => await mod.resolve<T>('*', childOptions)))\n const childModules = resolvedChildren.flat().filter(duplicateModules)\n return [...modules, ...childModules, mod as T].filter(duplicateModules)\n }\n let result: T | T[] | undefined\n switch (typeof id) {\n case 'string': {\n if (dead) {\n return undefined\n }\n\n const resolvedId = assertEx((await resolvePathToAddress(mod, id, false, transformers)) ?? id, () => 'Invalid resolvedId')\n\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 result ??= await this.resolveModuleIdentifier<T>(resolverInstance, resolvedId)\n }\n\n break\n }\n default: {\n break\n }\n }\n this.validateRequiredResolve(required, result, id, 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 ?? (isString(first) ? await resolver.resolvePrivate(first, { maxDepth: firstIsAddress ? 10 : 1 }) : undefined)\n const finalModule = required === true ? assertEx(resolvedModule, () => `Failed to resolve [${first}] [${firstIsAddress}]`) : resolvedModule\n const firstModule = asModuleInstance(finalModule, () => `Resolved invalid module instance [${first}]`)\n if (!isDefined(firstModule)) {\n return undefined\n }\n if (parts.length === 0) {\n return firstModule as T\n }\n // A first segment that names the module being resolved from is not a child hop.\n return resolvingModule(resolver)?.address === firstModule.address ? undefined : (await this.resolveModuleIdentifier<T>(firstModule, parts.join(':')))\n }\n\n // translates a complex module path to addresses\n static traceModuleIdentifier(resolver: ModuleResolver, path: ModuleIdentifier): Promise<((Lowercase<string> & {\n readonly __hex: true\n } & {\n readonly __address: true\n }) | XyoQuantAddress)[]> {\n return traceModuleIdentifier(resolver, path)\n }\n\n static transformModuleIdentifier(identifier: ModuleIdentifier, transformers: ModuleIdentifierTransformer[] = this.transformers): Promise<ModuleIdentifier | undefined> {\n return transformModuleIdentifier(identifier, transformers)\n }\n\n static validateRequiredResolve(\n required: boolean | 'warn' | 'log',\n result: ModuleInstance[] | ModuleInstance | undefined,\n id: ModuleIdentifier,\n logger: Logger | undefined = this.defaultLogger,\n ): void {\n const log = logger ? new IdLogger(logger, () => `validateRequiredResolve [${id}][${JSON.stringify(result)}]`) : undefined\n if (isTruthy(required) && (result === undefined || (Array.isArray(result) && result.length > 0))) {\n switch (required) {\n case 'warn': {\n log?.warn('resolve failed', id)\n break\n }\n case 'log': {\n log?.log('resolve failed', id)\n break\n }\n default: {\n throw new Error(`resolve failed [${id}]`)\n }\n }\n }\n }\n}\n", "import type { Logger } from '@ariestools/sdk'\n\nimport type { ModuleIdentifierTransformer } from '#module-model'\n\nexport class ResolveHelperStatic {\n static readonly defaultLogger?: Logger\n static transformers: ModuleIdentifierTransformer[] = []\n}\n", "import { asAddress, assertEx } from '@ariestools/sdk'\n\nimport type { ModuleIdentifierTransformer, ModuleInstance } from '#module-model'\nimport { MODULE_PATH_SEPARATOR } from '#module-model'\n\nimport { resolveAddressToInstance } from './resolveAddressToInstance.ts'\nimport { ResolveHelperStatic } from './ResolveHelperStatic.ts'\nimport { resolveLocalNameToAddress } from './resolveLocalNameToAddress.ts'\nimport { transformModuleIdentifier } from './transformModuleIdentifier.ts'\n\nexport const resolvePathToInstance = async (\n root: ModuleInstance,\n path: string,\n includePrivate?: boolean,\n transformers: ModuleIdentifierTransformer[] = ResolveHelperStatic.transformers,\n): Promise<ModuleInstance | 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 === undefined || first === '') {\n return undefined\n }\n\n const firstAddress = asAddress(first) ?? (await resolveLocalNameToAddress(root, first, includePrivate))\n\n if (!firstAddress) {\n return\n }\n\n const firstModule = await resolveAddressToInstance(root, firstAddress, includePrivate)\n return firstModule && parts.length > 0 ? resolvePathToInstance(firstModule, parts.join(MODULE_PATH_SEPARATOR)) : firstModule\n}\n", "import type { ModuleInstance, ModuleName } from '#module-model'\n\nimport type { ModuleResolveDirection } from './model.ts'\n\nexport const resolveLocalNameToInstanceUp = async (root: ModuleInstance, modName: ModuleName): Promise<ModuleInstance | undefined> => {\n const parents = (await root.parents?.()) ?? []\n return parents.find(parent => parent.config.name === modName)\n}\n\n// since this is a modName, it only checks the children of the root module\nexport const resolveLocalNameToInstanceDown = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate?: boolean,\n): Promise<ModuleInstance | undefined> => {\n const privateChildren = (includePrivate === true ? await root.privateChildren?.() : []) ?? []\n const publicChildren = (await root.publicChildren?.()) ?? []\n const children = [...privateChildren, ...publicChildren]\n return children.find(child => child.config.name === modName)\n}\n\nexport const resolveLocalNameToInstanceAll = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate = false,\n): Promise<ModuleInstance | undefined> => {\n return (await resolveLocalNameToInstanceDown(root, modName, includePrivate)) ?? (await resolveLocalNameToInstanceUp(root, modName))\n}\n\nexport const resolveLocalNameToInstance = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate = false,\n direction: ModuleResolveDirection = 'all',\n): Promise<ModuleInstance | undefined> => {\n switch (direction) {\n case 'all': {\n return await resolveLocalNameToInstanceAll(root, modName, includePrivate)\n }\n case 'up': {\n return await resolveLocalNameToInstanceUp(root, modName)\n }\n case 'down': {\n return await resolveLocalNameToInstanceDown(root, modName, includePrivate)\n }\n }\n}\n", "import type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { ModuleInstance, ModuleName } from '#module-model'\n\nimport type { ModuleResolveDirection } from './model.ts'\nimport {\n resolveLocalNameToInstance,\n resolveLocalNameToInstanceAll,\n resolveLocalNameToInstanceDown,\n resolveLocalNameToInstanceUp,\n} from './resolveLocalNameToInstance.ts'\n\nexport const resolveLocalNameToAddressUp = async (root: ModuleInstance, modName: ModuleName): Promise<XyoAddress | undefined> => {\n const instance = await resolveLocalNameToInstanceUp(root, modName)\n return instance?.address\n}\n\nexport const resolveLocalNameToAddressDown = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate?: boolean,\n): Promise<XyoAddress | undefined> => {\n const instance = await resolveLocalNameToInstanceDown(root, modName, includePrivate)\n return instance?.address\n}\n\nexport const resolveLocalNameToAddressAll = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate?: boolean,\n): Promise<XyoAddress | undefined> => {\n const instance = await resolveLocalNameToInstanceAll(root, modName, includePrivate)\n return instance?.address\n}\n\nexport const resolveLocalNameToAddress = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate?: boolean,\n direction: ModuleResolveDirection = 'all',\n): Promise<XyoAddress | undefined> => {\n const instance = await resolveLocalNameToInstance(root, modName, includePrivate, direction)\n return instance?.address\n}\n", "import type { ModuleIdentifier, ModuleIdentifierTransformer } from '#module-model'\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 type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { ModuleIdentifierTransformer, ModuleInstance } from '#module-model'\n\nimport { ResolveHelperStatic } from './ResolveHelperStatic.ts'\nimport { resolvePathToInstance } from './resolvePathToInstance.ts'\n\nexport const resolvePathToAddress = async (\n root: ModuleInstance,\n path: string,\n includePrivate?: boolean,\n transformers: ModuleIdentifierTransformer[] = ResolveHelperStatic.transformers,\n): Promise<XyoAddress | undefined> => {\n const instance = await resolvePathToInstance(root, path, includePrivate, transformers)\n return instance?.address\n}\n", "import { assertEx } from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { ModuleIdentifier, ModuleResolver } from '#module-model'\nimport { asModuleInstance } from '#module-model'\n\nexport const traceModuleIdentifier = async (resolver: ModuleResolver, path: ModuleIdentifier): Promise<XyoAddress[]> => {\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 type { Promisable } from '@ariestools/sdk'\nimport {\n assertEx, exists, isAddress,\n} from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type {\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleInstance,\n ModuleName,\n ModuleRepository,\n ModuleResolverInstance,\n ObjectFilterOptions,\n} from '#module-model'\nimport { isModuleName } from '#module-model'\n\nimport type { ModuleResolverParams } from './AbstractModuleResolver.ts'\nimport { AbstractModuleResolver } from './AbstractModuleResolver.ts'\n\nexport type SimpleModuleResolverParams = ModuleResolverParams & {\n allowNameResolution?: boolean\n}\n\nexport class SimpleModuleResolver extends AbstractModuleResolver<SimpleModuleResolverParams> implements ModuleRepository {\n private modules: Record<XyoAddress, ModuleInstance> = {}\n private nameToModule: Record<ModuleName, ModuleInstance> = {}\n\n constructor(params: SimpleModuleResolverParams) {\n super(params)\n }\n\n get allowNameResolution(): boolean {\n return this.params.allowNameResolution ?? true\n }\n\n add(mods: ModuleInstance): this\n add(mods: ModuleInstance[]): this\n add(mods: ModuleInstance | ModuleInstance[]): this {\n if (Array.isArray(mods)) {\n for (const mod of mods) this.addSingleModule(mod)\n } else {\n this.addSingleModule(mods)\n }\n return this\n }\n\n addResolver(_resolver: ModuleResolverInstance): this {\n throw new Error('Adding resolvers not supported')\n }\n\n remove(address: XyoAddress | XyoAddress[]): this {\n if (Array.isArray(address)) {\n for (const addr of address) this.removeSingleModule(addr)\n } else {\n this.removeSingleModule(address)\n }\n return this\n }\n\n removeResolver(_resolver: ModuleResolverInstance): this {\n throw new Error('Removing resolvers not supported')\n }\n\n resolveHandler<T extends ModuleInstance = ModuleInstance>(\n id: ModuleIdentifier = '*',\n options?: ModuleFilterOptions<T>,\n ): Promisable<T[]> {\n const unfiltered = (() => {\n if (id === '') {\n return Object.values(this.modules) as T[]\n }\n if (typeof id !== 'string') {\n return\n }\n\n if (id === '*') {\n return Object.values(this.modules) as T[]\n }\n const name = isModuleName(id) ? id : undefined\n const address = isAddress(id) ? id : undefined\n assertEx(name ?? address, () => 'module identifier must be a ModuleName or Address')\n return (\n (name !== undefined && name !== '' ? this.resolveByName<T>(Object.values(this.modules), [name]).pop() : undefined)\n ?? (address ? this.resolveByAddress<T>(this.modules, [address]).pop() : undefined)\n )\n })()\n const identity = options?.identity\n if (identity) {\n return (\n Array.isArray(unfiltered)\n ? unfiltered?.filter(mod => identity(mod))\n : identity(unfiltered)\n ? [unfiltered]\n : []\n )\n }\n return (\n unfiltered\n ? Array.isArray(unfiltered)\n ? unfiltered\n : [unfiltered]\n : []\n )\n }\n\n resolveIdentifier(id: ModuleIdentifier, _options?: ObjectFilterOptions): Promisable<XyoAddress | undefined> {\n // check if id is a name of one of modules in the resolver\n const moduleFromName = this.nameToModule[id]\n if (moduleFromName !== undefined) {\n return moduleFromName.address\n }\n\n // check if any of the modules have the id as an address\n for (const mod of Object.values(this.modules)) {\n if (mod.address === id) {\n return mod.address\n }\n }\n }\n\n private addSingleModule(mod?: ModuleInstance) {\n if (!mod) {\n return\n }\n\n const modName = mod.modName\n if (modName !== undefined && modName !== '' && this.allowNameResolution) {\n // check for collision\n assertEx(this.nameToModule[modName] === undefined, () => `Module with name ${modName} already added`)\n this.nameToModule[modName] = mod\n }\n this.modules[mod.address] = mod\n }\n\n private removeSingleModule(address: XyoAddress) {\n assertEx(isAddress(address), () => 'Invalid address')\n const mod = assertEx(this.modules[address], () => 'Address not found in modules')\n delete this.modules[address]\n const modName = mod.modName\n if (modName !== undefined && modName !== '') {\n delete this.nameToModule[modName]\n }\n }\n\n private resolveByAddress<T extends ModuleInstance = ModuleInstance>(modules: Record<XyoAddress, ModuleInstance>, address: XyoAddress[]): T[] {\n return (\n address.map((address) => {\n return modules[address]\n })\n ).filter(exists) as T[]\n }\n\n private resolveByName<T extends ModuleInstance = ModuleInstance>(modules: ModuleInstance[], name: ModuleName[]): T[] {\n return (\n name.map((name) => {\n return modules.find(mod => mod.modName === name)\n })\n ).filter(exists) as T[]\n }\n\n private resolveByQuery<T extends ModuleInstance = ModuleInstance>(modules: ModuleInstance[], query: string[][]): T[] {\n return (\n modules.filter((mod) => {\n const queryLists = query ?? []\n return queryLists.some(queryList => queryList.every(querySchema => mod.queries.includes(querySchema)))\n })\n ).filter(exists) as T[]\n }\n}\n", "import { isDefined, isUndefined } from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk-protocol'\nimport { LRUCache } from 'lru-cache'\n\nimport type { DivinerInstance } from '#diviner-model'\nimport { PayloadDivinerQuerySchema } from '#diviner-payload-model'\nimport type { ModuleIdentifier, ModuleIdentifierTransformer } from '#module-model'\n\nexport class NameRegistrarTransformer implements ModuleIdentifierTransformer {\n private _cache: LRUCache<ModuleIdentifier, ModuleIdentifier> = new LRUCache<ModuleIdentifier, ModuleIdentifier>({ max: 1000, ttl: 1000 * 5 })\n\n private registrarDiviner: DivinerInstance\n private root: string\n\n constructor(\n registrarDiviner: DivinerInstance,\n root: string,\n ) {\n this.registrarDiviner = registrarDiviner\n this.root = root\n }\n\n async transform(identifier: ModuleIdentifier): Promise<ModuleIdentifier> {\n const parts = identifier.split(':')\n const first = parts.shift()\n const nameParts = first?.split('.')\n if (nameParts?.length === 2 && nameParts[1] === this.root) {\n // check cache\n const cachedResult = this._cache.get(identifier)\n if (isDefined(cachedResult)) return cachedResult\n\n // not cached, so check registrar\n const query = {\n domain: nameParts[0], order: 'desc' as const, schema: PayloadDivinerQuerySchema, tld: nameParts[1],\n }\n const result = await this.registrarDiviner?.divine([query])\n const resultPayload = result?.shift()\n if (isUndefined(resultPayload)) {\n throw new Error(`Unable to resolve registrar name (failed) [${first}]`)\n }\n // TODO: Use proper types for this check\n if (isDefined(resultPayload)) {\n const address = (resultPayload as unknown as { address: XyoAddress[] }).address?.shift()\n if (address) {\n this._cache.set(identifier, address)\n return address\n }\n }\n throw new Error(`Unable to resolve registrar name (not found) [${first}]`)\n }\n return identifier\n }\n}\n", "import type {\n ModuleIdentifier, ModuleResolver,\n QueryableModule,\n} from '#module-model'\n\nexport interface ModuleResolvedEventArgs {\n id?: ModuleIdentifier\n mod: QueryableModule\n}\n\nexport interface ResolverEventEmitter {\n on(event: 'moduleResolved', listener: (args: ModuleResolvedEventArgs) => void): void\n}\n\ntype ListenerFunction = (args: ModuleResolvedEventArgs) => void\n\nconst getMixin = <T extends ModuleResolver = ModuleResolver>(resolver: T) => {\n const listeners: ListenerFunction[] = []\n const emit = (event: 'moduleResolved', args: ModuleResolvedEventArgs): boolean => {\n if (listeners.length === 0) return false\n for (const listener of listeners) listener(args)\n return true\n }\n const onModuleResolved = (mod: QueryableModule, id?: ModuleIdentifier) => {\n const args = { id, mod }\n emit('moduleResolved', args)\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { resolve } = resolver\n function originalResolve(filter?: ModuleIdentifier) {\n return resolve.bind(resolver)(filter)\n }\n\n return {\n on: (event: 'moduleResolved', listener: (args: ModuleResolvedEventArgs) => void) => {\n listeners.push(listener)\n },\n resolve: async (id?: ModuleIdentifier): Promise<QueryableModule[]> => {\n const modulesResult = await originalResolve(id) ?? []\n const modules = Array.isArray(modulesResult) ? modulesResult : [modulesResult]\n\n // eslint-disable-next-line @typescript-eslint/await-thenable\n await Promise.allSettled(modules.map(mod => onModuleResolved(mod, id)))\n return modules\n },\n }\n}\n\nexport const mixinResolverEventEmitter = <T extends ModuleResolver = ModuleResolver>(resolver: T): T & ResolverEventEmitter => {\n const mixin = getMixin(resolver)\n return Object.assign(resolver, mixin)\n}\n"],
|
|
5
|
-
"mappings": ";AACA;AAAA,EACE;AAAA,EAAU;AAAA,EAAM;AAAA,OACX;AAUP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAOA,IAAe,yBAAf,cACG,KAC0B;AAAA,EAClC,IAAI,WAAW;AACb,WAAO,KAAK,OAAO,YAAY,uBAAuB;AAAA,EACxD;AAAA,EAEA,IAAI,SAAS,OAA+B;AAC1C,SAAK,OAAO,WAAW;AAAA,EACzB;AAAA,EAEA,IAAI,OAAuB;AACzB,WAAO,SAAS,KAAK,OAAO,MAAM,MAAM,iBAAiB;AAAA,EAC3D;AAAA,EAKA,MAAM,QACJ,KAAuB,KACvB,SAC8B;AAC9B,QAAI,OAAO,KAAK;AACd,YAAM,SAAS,MAAM,KAAK,eAAe,IAAI,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AAAA,IACA,SAAS,OAAO,OAAsD;AACpE,YAAM,gBAAgB,MAAM,gBAAgB,EAAE,KAAK,CAAC;AACpD,YAAM,UAAU,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa;AAG7E,YAAM,QAAQ,WAAW,QAAQ,IAAI,SAAO,iBAAiB,KAAK,EAAE,CAAC,CAAC;AACtE,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,IAAM,4BAA4B,CAA4C,aAA0C;AAC7H,QAAM,QAAQ,SAAS,QAAQ;AAC/B,SAAO,OAAO,OAAO,UAAU,KAAK;AACtC;",
|
|
4
|
+
"sourcesContent": ["import type { BaseParams, Promisable } from '@ariestools/sdk'\nimport {\n assertEx, Base, toSafeJsonString,\n} from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type {\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleInstance,\n ModuleResolverInstance,\n ObjectFilterOptions,\n} from '#module-model'\nimport {\n asModuleInstance,\n ObjectResolverPriority,\n} from '#module-model'\n\nexport interface ModuleResolverParams extends BaseParams {\n priority?: ObjectResolverPriority\n root: ModuleInstance\n}\n\nexport abstract class AbstractModuleResolver<TParams extends ModuleResolverParams = ModuleResolverParams>\n extends Base<TParams>\n implements ModuleResolverInstance {\n get priority() {\n return this.params.priority ?? ObjectResolverPriority.Normal\n }\n\n set priority(value: ObjectResolverPriority) {\n this.params.priority = value\n }\n\n get root(): ModuleInstance {\n return assertEx(this.params.root, () => 'root is not set')\n }\n\n async resolve<T extends ModuleInstance = ModuleInstance>(): Promise<T[]>\n async resolve<T extends ModuleInstance = ModuleInstance>(all: '*', options?: ModuleFilterOptions<T>): Promise<T[]>\n async resolve<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ModuleFilterOptions<T>): Promise<T | undefined>\n async resolve<T extends ModuleInstance = ModuleInstance>(\n id: ModuleIdentifier = '*',\n options?: ModuleFilterOptions<T>,\n ): Promise<T[] | T | undefined> {\n if (id === '*') {\n const values = await this.resolveHandler(id, options)\n assertEx(Array.isArray(values), () => 'resolveHandler returned a non-array')\n return values.map(value =>\n asModuleInstance<T>(value, () => {\n return `resolveHandler returned invalid result (*) [${toSafeJsonString(value)}]`\n }, { required: true }))\n }\n switch (typeof id) {\n case 'string': {\n const [value] = await this.resolveHandler(id, options)\n return asModuleInstance<T>(\n value,\n () => `resolveHandler returned invalid result (string) [${toSafeJsonString(value)}]`,\n )\n }\n default: {\n break\n }\n }\n }\n\n async resolvePrivate<T extends ModuleInstance = ModuleInstance>(all: '*', options?: ObjectFilterOptions<T>): Promise<T[]>\n async resolvePrivate<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ObjectFilterOptions<T>): Promise<T | undefined>\n async resolvePrivate<T extends ModuleInstance = ModuleInstance>(\n id: ModuleIdentifier,\n _options?: ObjectFilterOptions<T>,\n ): Promise<T | T[] | undefined> {\n if (id === '*') return []\n }\n\n abstract addResolver(resolver: ModuleResolverInstance): this\n abstract removeResolver(resolver: ModuleResolverInstance): this\n\n abstract resolveHandler<T extends ModuleInstance = ModuleInstance>(\n id: ModuleIdentifier,\n options?: ModuleFilterOptions<T>,\n ): Promisable<T[]>\n\n abstract resolveIdentifier(id: ModuleIdentifier, options?: ObjectFilterOptions): Promisable<XyoAddress | undefined>\n}\n", "/* eslint-disable max-statements */\nimport type { Promisable } from '@ariestools/sdk'\nimport {\n assertEx,\n exists, isDefined, isString,\n} from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk-protocol'\nimport { LRUCache } from 'lru-cache'\n\nimport type {\n CacheConfig,\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleIdentifierPart,\n ModuleIdentifierTransformer,\n ModuleInstance,\n ModuleRepository,\n ModuleResolverInstance,\n ObjectFilterOptions,\n} from '#module-model'\nimport {\n duplicateModules,\n ObjectResolverPriority,\n} from '#module-model'\n\nimport type { ModuleResolverParams } from './AbstractModuleResolver.ts'\nimport { AbstractModuleResolver } from './AbstractModuleResolver.ts'\nimport { ResolveHelper } from './ResolveHelper/index.ts'\nimport { SimpleModuleResolver } from './SimpleModuleResolver.ts'\n\nexport interface CompositeModuleResolverParams extends ModuleResolverParams {\n allowNameResolution?: boolean\n cache?: CacheConfig\n moduleIdentifierTransformers?: ModuleIdentifierTransformer[]\n}\n\nconst moduleIdentifierParts = (moduleIdentifier: ModuleIdentifier): ModuleIdentifierPart[] => {\n return moduleIdentifier?.split(':')\n}\n\nexport class CompositeModuleResolver<T extends CompositeModuleResolverParams = CompositeModuleResolverParams>\n extends AbstractModuleResolver<T>\n implements ModuleRepository, ModuleResolverInstance {\n static readonly defaultMaxDepth = 3\n\n protected _cache: LRUCache<ModuleIdentifier, ModuleInstance>\n protected resolvers: ModuleResolverInstance[] = []\n private _allowAddResolver = true\n private _localResolver: SimpleModuleResolver\n\n constructor(params: T) {\n super(params)\n const localResolver = new SimpleModuleResolver({ allowNameResolution: params.allowNameResolution, root: params.root })\n this.addResolver(localResolver)\n const { max = 100, ttl = 1000 * 5 /* five seconds */ } = params.cache ?? {}\n this._cache = new LRUCache<ModuleIdentifier, ModuleInstance>({\n max, ttl, ...params.cache,\n })\n this._localResolver = localResolver\n }\n\n get allowAddResolver() {\n return this._allowAddResolver\n }\n\n set allowAddResolver(value: boolean) {\n this.resolvers = [this._localResolver]\n this._allowAddResolver = value\n }\n\n get allowNameResolution(): boolean {\n return this.params.allowNameResolution ?? true\n }\n\n private get moduleIdentifierTransformers() {\n return this.params.moduleIdentifierTransformers ?? ResolveHelper.transformers\n }\n\n add(mod: ModuleInstance): this\n add(mod: ModuleInstance[]): this\n add(mod: ModuleInstance | ModuleInstance[]): this {\n if (Array.isArray(mod)) {\n for (const modItem of mod) this.addSingleModule(modItem)\n } else {\n this.addSingleModule(mod)\n }\n return this\n }\n\n addResolver(resolver: ModuleResolverInstance): this {\n if (this.allowAddResolver) {\n this.resolvers.push(resolver)\n }\n return this\n }\n\n remove(addresses: XyoAddress[] | XyoAddress): this {\n if (Array.isArray(addresses)) {\n for (const address of addresses) this.removeSingleModule(address)\n } else {\n this.removeSingleModule(addresses)\n }\n return this\n }\n\n removeResolver(resolver: ModuleResolverInstance): this {\n this.resolvers = this.resolvers.filter(item => item !== resolver)\n return this\n }\n\n // eslint-disable-next-line complexity\n async resolveHandler<T extends ModuleInstance = ModuleInstance>(\n id: ModuleIdentifier = '*',\n options: ModuleFilterOptions<T> = {},\n ): Promise<T[]> {\n const mutatedOptions = { ...options, maxDepth: options?.maxDepth ?? CompositeModuleResolver.defaultMaxDepth }\n\n // resolve all\n if (id === '*') {\n // wen't too far?\n if (mutatedOptions.maxDepth < 0) {\n return []\n }\n\n // identity resolve?\n if (mutatedOptions.maxDepth === 0) {\n return (await this._localResolver.resolve('*', mutatedOptions)) ?? []\n }\n\n const childOptions = { ...mutatedOptions, maxDepth: mutatedOptions?.maxDepth - 1 }\n\n const result = await Promise.all(\n this.resolvers.map(async (resolver) => {\n const result: T[] = await resolver.resolve<T>('*', childOptions)\n return result\n }),\n )\n const flatResult: T[] = result.flat().filter(exists)\n return flatResult.filter((v, i, a) => duplicateModules(v, i, a))\n }\n\n if (typeof id === 'string') {\n // wen't too far?\n if (mutatedOptions.maxDepth < 0) {\n return []\n }\n\n // resolve ModuleIdentifier\n const idParts = moduleIdentifierParts(id)\n if (idParts.length > 1) {\n const mod = await this.resolveMultipartIdentifier<T>(id)\n return (\n mod\n ? Array.isArray(mod)\n ? mod\n : [mod]\n : []\n )\n }\n const resolvedId = await ResolveHelper.transformModuleIdentifier(id, this.moduleIdentifierTransformers)\n if (isString(resolvedId)) {\n if (mutatedOptions.maxDepth < 0) {\n return []\n }\n const cachedResult = this._cache.get(resolvedId)\n if (cachedResult) {\n if (cachedResult.status === 'error') {\n this._cache.delete(id)\n } else {\n return [cachedResult] as T[]\n }\n }\n\n // identity resolve?\n if (mutatedOptions.maxDepth === 0) {\n const mod = await this._localResolver.resolve(resolvedId, mutatedOptions)\n return (\n isDefined(mod)\n ? Array.isArray(mod)\n ? mod\n : [mod]\n : []\n )\n }\n\n // recursive function to resolve by priority\n const resolvePriority = async (priority: ObjectResolverPriority): Promise<T | undefined> => {\n const resolvers = this.resolvers.filter(resolver => resolver.priority === priority)\n const resolved = await Promise.all(\n resolvers.map(async (resolver) => {\n const result: T | undefined = await resolver.resolve<T>(resolvedId, mutatedOptions)\n return result\n }),\n )\n const results: T[] = resolved.filter(exists)\n\n const result: T | undefined = results.filter(exists).findLast((v, i, a) => duplicateModules(v, i, a))\n if (result) {\n this._cache.set(resolvedId, result)\n return result\n }\n // we know that ObjectResolverPriority.VeryLow is the minimum priority, so we can subtract 1 from the rest\n return priority === ObjectResolverPriority.VeryLow ? undefined : await resolvePriority((priority - 1) as ObjectResolverPriority)\n }\n const mod = await resolvePriority(ObjectResolverPriority.VeryHigh)\n return (\n mod\n ? Array.isArray(mod)\n ? mod\n : [mod]\n : []\n )\n }\n }\n return []\n }\n\n async resolveIdentifier(id: ModuleIdentifier, _options?: ObjectFilterOptions): Promise<XyoAddress | undefined> {\n const idParts = id.split(':')\n if (idParts.length > 1) {\n return this.resolveComplexIdentifier(id)\n }\n const resolved = await Promise.all(\n this.resolvers.map(async (resolver) => {\n return await resolver.resolveIdentifier(id)\n }),\n )\n const results = resolved.filter(exists)\n const result = results.shift()\n for (const altResult of results) {\n assertEx(altResult === result, () => `Inconsistent results for ${id} [${result}][${altResult}]`)\n }\n return result\n }\n\n protected resolveComplexIdentifier(_id: ModuleIdentifier, _options?: ObjectFilterOptions): Promisable<XyoAddress | undefined> {\n throw new Error('Method not implemented.')\n }\n\n private addSingleModule(mod?: ModuleInstance) {\n if (mod) {\n this._localResolver.add(mod)\n }\n }\n\n private removeSingleModule(address: XyoAddress) {\n this._localResolver.remove(address)\n }\n\n private async resolveMultipartIdentifier<T extends ModuleInstance = ModuleInstance>(moduleIdentifier: ModuleIdentifier): Promise<T | undefined> {\n const idParts = moduleIdentifierParts(moduleIdentifier)\n assertEx(idParts.length >= 2, () => 'Not a valid multipart identifier')\n const id = assertEx(idParts.shift())\n const mod = (await this.resolve<T>(id)) ?? (await this.resolvePrivate<T>(id))\n return (await mod?.resolve<T>(idParts.join(':'))) ?? (await mod?.resolvePrivate<T>(idParts.join(':')))\n }\n}\n", "import type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { ModuleInstance } from '#module-model'\n\nimport type { ModuleResolveDirection } from './model.ts'\n\nexport const resolveAddressToInstanceDown = async (\n root: ModuleInstance,\n address: XyoAddress,\n includePrivate?: boolean,\n ignore: XyoAddress[] = [],\n): Promise<ModuleInstance | undefined> => {\n if (root.address === address) {\n return root\n }\n const cache = root.addressCache?.('up', includePrivate ?? false)\n const privateChildren = (includePrivate === true ? 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: XyoAddress,\n includePrivate?: boolean,\n ignore: XyoAddress[] = [],\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: XyoAddress,\n includePrivate?: boolean,\n ignore: XyoAddress[] = [],\n): Promise<ModuleInstance | undefined> => {\n const cache = root.addressCache?.('up', includePrivate ?? true)\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 resolveAddressToInstanceAll = async (\n root: ModuleInstance,\n address: XyoAddress,\n includePrivate?: boolean,\n ignore: XyoAddress[] = [],\n): Promise<ModuleInstance | undefined> => {\n const cache = root.addressCache?.('all', includePrivate ?? false)\n const result\n = (await resolveAddressToInstanceDown(root, address, includePrivate ?? false, ignore))\n ?? (await resolveAddressToInstanceUp(root, address, includePrivate ?? true, ignore))\n cache?.set(address, result ? new WeakRef(result) : null)\n return result\n}\n\nexport const resolveAddressToInstance = async (\n root: ModuleInstance,\n address: XyoAddress,\n includePrivate?: boolean,\n ignore: XyoAddress[] = [],\n direction: ModuleResolveDirection = 'all',\n): Promise<ModuleInstance | undefined> => {\n switch (direction) {\n case 'all': {\n return await resolveAddressToInstanceAll(root, address, includePrivate, ignore)\n }\n case 'up': {\n return await resolveAddressToInstanceUp(root, address, includePrivate ?? true, ignore)\n }\n case 'down': {\n return await resolveAddressToInstanceDown(root, address, includePrivate ?? false, ignore)\n }\n }\n}\n", "import type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { ModuleInstance } from '#module-model'\nimport { duplicateModules } from '#module-model'\n\nexport const resolveAllUp = async (root: ModuleInstance, maxDepth = 10, exclude: XyoAddress[] = []): Promise<ModuleInstance[]> => {\n if (maxDepth === 0) {\n return [root].filter(mod => !exclude.includes(mod.address))\n }\n const allParents = await root.parents()\n const parents = allParents.filter(mod => !exclude.includes(mod.address))\n if (maxDepth <= 1) {\n return [...parents, root]\n }\n const upResults = await Promise.all(parents.map(async mod => await resolveAllUp(mod, maxDepth - 1, [...exclude, root.address])))\n const downResults = await Promise.all(parents.map(async mod => await resolveAllDown(mod, maxDepth - 1, [...exclude, root.address], true)))\n return [...upResults.flat(), ...downResults.flat(), ...parents, root]\n}\n\nexport const resolveAllDown = async (\n root: ModuleInstance,\n maxDepth = 10,\n exclude: XyoAddress[] = [],\n includePrivate = false,\n): Promise<ModuleInstance[]> => {\n if (maxDepth === 0) {\n return [root]\n }\n const publicModules = await root.publicChildren()\n const children = publicModules.filter(mod => !exclude.includes(mod.address))\n if (maxDepth <= 1) {\n return [...children, root]\n }\n const privateModules = includePrivate ? await root.privateChildren() : []\n const privateChildren = privateModules.filter(mod => !exclude.includes(mod.address))\n const childResults = await Promise.all(children.map(child => resolveAllDown(child, maxDepth - 1, [...exclude, root.address])))\n const privateChildResults = await Promise.all(privateChildren.map(child => resolveAllDown(child, maxDepth - 1, [...exclude, root.address])))\n return [...children, ...childResults.flat(), ...privateChildResults.flat(), root]\n}\n\nexport const resolveAll = async (root: ModuleInstance, maxDepth = 10, exclude: XyoAddress[] = []): Promise<ModuleInstance[]> => {\n return maxDepth === 0 ? [root] : [...(await resolveAllUp(root, maxDepth, exclude)), ...(await resolveAllDown(root, maxDepth, exclude))].filter(duplicateModules)\n}\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type { Logger } from '@ariestools/sdk'\nimport {\n assertEx,\n exists,\n IdLogger,\n isAddress,\n isDefined, isString, isTruthy,\n} from '@ariestools/sdk'\nimport type { XyoAddress, XyoQuantAddress } from '@xyo-network/sdk-protocol'\n\nimport type {\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleIdentifierTransformer,\n ModuleInstance,\n ModuleResolver,\n} from '#module-model'\nimport {\n asModuleInstance, duplicateModules, isModuleInstance,\n} from '#module-model'\n\nimport { ResolveHelperStatic } from './ResolveHelperStatic.ts'\nimport { resolvePathToAddress } from './resolvePathToAddress.ts'\nimport { traceModuleIdentifier } from './traceModuleIdentifier.ts'\nimport { transformModuleIdentifier } from './transformModuleIdentifier.ts'\n\nfunction resolvingModule(resolver: ModuleResolver): ModuleInstance | undefined {\n if (!('root' in resolver) || typeof resolver.root !== 'object' || resolver.root === null) {\n return undefined\n }\n return isModuleInstance(resolver.root) ? resolver.root : undefined\n}\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 1: If someone were to name a module with a valid address, that name will not be resolvable.\n 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: XyoAddress\n dead?: boolean\n downResolver?: ModuleResolver\n logger?: Logger\n mod: ModuleInstance\n privateResolver?: ModuleResolver\n transformers: ModuleIdentifierTransformer[]\n upResolver?: ModuleResolver\n}\n\nexport class ResolveHelper extends ResolveHelperStatic {\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 id: ModuleIdentifier,\n options?: ModuleFilterOptions<T>,\n ): Promise<T | undefined>\n static async resolve<T extends ModuleInstance = ModuleInstance>(\n config: ResolveHelperConfig,\n id: ModuleIdentifier = '*',\n {\n maxDepth = 3, required = 'log', ...options\n }: ModuleFilterOptions<T> = {},\n ): Promise<T | T[] | undefined> {\n const {\n transformers, mod, logger = this.defaultLogger, dead = false, upResolver, downResolver, privateResolver,\n } = config\n const log = logger ? new IdLogger(logger, () => `ResolveHelper [${mod.id}][${id}]`) : undefined\n\n const direction = options.direction ?? 'all'\n const downLocalOptions: ModuleFilterOptions<T> = {\n ...options, direction: 'down', maxDepth, required: false,\n }\n const upLocalOptions: ModuleFilterOptions<T> = { ...downLocalOptions, direction: 'up' }\n\n // Children must be expanded downward. direction `all` would let each child look up and\n // surface the parent's private children back into this result.\n const childOptions: ModuleFilterOptions<T> = {\n ...options,\n direction: direction === 'all' ? 'down' : direction,\n maxDepth: maxDepth - 1,\n required: false,\n }\n const up = direction === 'up' || direction === 'all'\n const down = direction === 'down' || direction === 'all'\n log?.debug('start', id, maxDepth)\n if (id === '*') {\n if (dead) {\n log?.warn('failed [dead]', id)\n return []\n }\n const modules = [\n ...(down ? await (downResolver!).resolve<T>('*', downLocalOptions) : []),\n ...(up ? await (upResolver!).resolve<T>('*', upLocalOptions) : []),\n ].filter(duplicateModules)\n\n if (modules.length > 0) {\n log?.debug('modules [count]', modules.length)\n }\n\n if (maxDepth === 0) {\n return modules\n }\n const resolvedChildren = await Promise.all(modules.map(async mod => await mod.resolve<T>('*', childOptions)))\n const childModules = resolvedChildren.flat().filter(duplicateModules)\n return [...modules, ...childModules, mod as T].filter(duplicateModules)\n }\n let result: T | T[] | undefined\n switch (typeof id) {\n case 'string': {\n if (dead) {\n return undefined\n }\n\n const resolvedId = assertEx((await resolvePathToAddress(mod, id, false, transformers)) ?? id, () => 'Invalid resolvedId')\n\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 result ??= await this.resolveModuleIdentifier<T>(resolverInstance, resolvedId)\n }\n\n break\n }\n default: {\n break\n }\n }\n this.validateRequiredResolve(required, result, id, 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 ?? (isString(first) ? await resolver.resolvePrivate(first, { maxDepth: firstIsAddress ? 10 : 1 }) : undefined)\n const finalModule = required === true ? assertEx(resolvedModule, () => `Failed to resolve [${first}] [${firstIsAddress}]`) : resolvedModule\n const firstModule = asModuleInstance(finalModule, () => `Resolved invalid module instance [${first}]`)\n if (!isDefined(firstModule)) {\n return undefined\n }\n if (parts.length === 0) {\n return firstModule as T\n }\n // A first segment that names the module being resolved from is not a child hop.\n return resolvingModule(resolver)?.address === firstModule.address ? undefined : (await this.resolveModuleIdentifier<T>(firstModule, parts.join(':')))\n }\n\n // translates a complex module path to addresses\n static traceModuleIdentifier(resolver: ModuleResolver, path: ModuleIdentifier): Promise<((Lowercase<string> & {\n readonly __hex: true\n } & {\n readonly __address: true\n }) | XyoQuantAddress)[]> {\n return traceModuleIdentifier(resolver, path)\n }\n\n static transformModuleIdentifier(identifier: ModuleIdentifier, transformers: ModuleIdentifierTransformer[] = this.transformers): Promise<ModuleIdentifier | undefined> {\n return transformModuleIdentifier(identifier, transformers)\n }\n\n static validateRequiredResolve(\n required: boolean | 'warn' | 'log',\n result: ModuleInstance[] | ModuleInstance | undefined,\n id: ModuleIdentifier,\n logger: Logger | undefined = this.defaultLogger,\n ): void {\n const log = logger ? new IdLogger(logger, () => `validateRequiredResolve [${id}][${JSON.stringify(result)}]`) : undefined\n if (isTruthy(required) && (result === undefined || (Array.isArray(result) && result.length > 0))) {\n switch (required) {\n case 'warn': {\n log?.warn('resolve failed', id)\n break\n }\n case 'log': {\n log?.log('resolve failed', id)\n break\n }\n default: {\n throw new Error(`resolve failed [${id}]`)\n }\n }\n }\n }\n}\n", "import type { Logger } from '@ariestools/sdk'\n\nimport type { ModuleIdentifierTransformer } from '#module-model'\n\nexport class ResolveHelperStatic {\n static readonly defaultLogger?: Logger\n static transformers: ModuleIdentifierTransformer[] = []\n}\n", "import { asAddress, assertEx } from '@ariestools/sdk'\n\nimport type { ModuleIdentifierTransformer, ModuleInstance } from '#module-model'\nimport { MODULE_PATH_SEPARATOR } from '#module-model'\n\nimport { resolveAddressToInstance } from './resolveAddressToInstance.ts'\nimport { ResolveHelperStatic } from './ResolveHelperStatic.ts'\nimport { resolveLocalNameToAddress } from './resolveLocalNameToAddress.ts'\nimport { transformModuleIdentifier } from './transformModuleIdentifier.ts'\n\nexport const resolvePathToInstance = async (\n root: ModuleInstance,\n path: string,\n includePrivate?: boolean,\n transformers: ModuleIdentifierTransformer[] = ResolveHelperStatic.transformers,\n): Promise<ModuleInstance | 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 === undefined || first === '') {\n return undefined\n }\n\n const firstAddress = asAddress(first) ?? (await resolveLocalNameToAddress(root, first, includePrivate))\n\n if (!firstAddress) {\n return\n }\n\n const firstModule = await resolveAddressToInstance(root, firstAddress, includePrivate)\n return firstModule && parts.length > 0 ? resolvePathToInstance(firstModule, parts.join(MODULE_PATH_SEPARATOR)) : firstModule\n}\n", "import type { ModuleInstance, ModuleName } from '#module-model'\n\nimport type { ModuleResolveDirection } from './model.ts'\n\nexport const resolveLocalNameToInstanceUp = async (root: ModuleInstance, modName: ModuleName): Promise<ModuleInstance | undefined> => {\n const parents = (await root.parents?.()) ?? []\n return parents.find(parent => parent.config.name === modName)\n}\n\n// since this is a modName, it only checks the children of the root module\nexport const resolveLocalNameToInstanceDown = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate?: boolean,\n): Promise<ModuleInstance | undefined> => {\n const privateChildren = (includePrivate === true ? await root.privateChildren?.() : []) ?? []\n const publicChildren = (await root.publicChildren?.()) ?? []\n const children = [...privateChildren, ...publicChildren]\n return children.find(child => child.config.name === modName)\n}\n\nexport const resolveLocalNameToInstanceAll = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate = false,\n): Promise<ModuleInstance | undefined> => {\n return (await resolveLocalNameToInstanceDown(root, modName, includePrivate)) ?? (await resolveLocalNameToInstanceUp(root, modName))\n}\n\nexport const resolveLocalNameToInstance = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate = false,\n direction: ModuleResolveDirection = 'all',\n): Promise<ModuleInstance | undefined> => {\n switch (direction) {\n case 'all': {\n return await resolveLocalNameToInstanceAll(root, modName, includePrivate)\n }\n case 'up': {\n return await resolveLocalNameToInstanceUp(root, modName)\n }\n case 'down': {\n return await resolveLocalNameToInstanceDown(root, modName, includePrivate)\n }\n }\n}\n", "import type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { ModuleInstance, ModuleName } from '#module-model'\n\nimport type { ModuleResolveDirection } from './model.ts'\nimport {\n resolveLocalNameToInstance,\n resolveLocalNameToInstanceAll,\n resolveLocalNameToInstanceDown,\n resolveLocalNameToInstanceUp,\n} from './resolveLocalNameToInstance.ts'\n\nexport const resolveLocalNameToAddressUp = async (root: ModuleInstance, modName: ModuleName): Promise<XyoAddress | undefined> => {\n const instance = await resolveLocalNameToInstanceUp(root, modName)\n return instance?.address\n}\n\nexport const resolveLocalNameToAddressDown = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate?: boolean,\n): Promise<XyoAddress | undefined> => {\n const instance = await resolveLocalNameToInstanceDown(root, modName, includePrivate)\n return instance?.address\n}\n\nexport const resolveLocalNameToAddressAll = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate?: boolean,\n): Promise<XyoAddress | undefined> => {\n const instance = await resolveLocalNameToInstanceAll(root, modName, includePrivate)\n return instance?.address\n}\n\nexport const resolveLocalNameToAddress = async (\n root: ModuleInstance,\n modName: ModuleName,\n includePrivate?: boolean,\n direction: ModuleResolveDirection = 'all',\n): Promise<XyoAddress | undefined> => {\n const instance = await resolveLocalNameToInstance(root, modName, includePrivate, direction)\n return instance?.address\n}\n", "import type { ModuleIdentifier, ModuleIdentifierTransformer } from '#module-model'\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 type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { ModuleIdentifierTransformer, ModuleInstance } from '#module-model'\n\nimport { ResolveHelperStatic } from './ResolveHelperStatic.ts'\nimport { resolvePathToInstance } from './resolvePathToInstance.ts'\n\nexport const resolvePathToAddress = async (\n root: ModuleInstance,\n path: string,\n includePrivate?: boolean,\n transformers: ModuleIdentifierTransformer[] = ResolveHelperStatic.transformers,\n): Promise<XyoAddress | undefined> => {\n const instance = await resolvePathToInstance(root, path, includePrivate, transformers)\n return instance?.address\n}\n", "import { assertEx } from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { ModuleIdentifier, ModuleResolver } from '#module-model'\nimport { asModuleInstance } from '#module-model'\n\nexport const traceModuleIdentifier = async (resolver: ModuleResolver, path: ModuleIdentifier): Promise<XyoAddress[]> => {\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 type { Promisable } from '@ariestools/sdk'\nimport {\n assertEx, exists, isAddress,\n} from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type {\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleInstance,\n ModuleName,\n ModuleRepository,\n ModuleResolverInstance,\n ObjectFilterOptions,\n} from '#module-model'\nimport { isModuleName } from '#module-model'\n\nimport type { ModuleResolverParams } from './AbstractModuleResolver.ts'\nimport { AbstractModuleResolver } from './AbstractModuleResolver.ts'\n\nexport type SimpleModuleResolverParams = ModuleResolverParams & {\n allowNameResolution?: boolean\n}\n\nexport class SimpleModuleResolver extends AbstractModuleResolver<SimpleModuleResolverParams> implements ModuleRepository {\n private modules: Record<XyoAddress, ModuleInstance> = {}\n private nameToModule: Record<ModuleName, ModuleInstance> = {}\n\n constructor(params: SimpleModuleResolverParams) {\n super(params)\n }\n\n get allowNameResolution(): boolean {\n return this.params.allowNameResolution ?? true\n }\n\n add(mods: ModuleInstance): this\n add(mods: ModuleInstance[]): this\n add(mods: ModuleInstance | ModuleInstance[]): this {\n if (Array.isArray(mods)) {\n for (const mod of mods) this.addSingleModule(mod)\n } else {\n this.addSingleModule(mods)\n }\n return this\n }\n\n addResolver(_resolver: ModuleResolverInstance): this {\n throw new Error('Adding resolvers not supported')\n }\n\n remove(address: XyoAddress | XyoAddress[]): this {\n if (Array.isArray(address)) {\n for (const addr of address) this.removeSingleModule(addr)\n } else {\n this.removeSingleModule(address)\n }\n return this\n }\n\n removeResolver(_resolver: ModuleResolverInstance): this {\n throw new Error('Removing resolvers not supported')\n }\n\n resolveHandler<T extends ModuleInstance = ModuleInstance>(\n id: ModuleIdentifier = '*',\n options?: ModuleFilterOptions<T>,\n ): Promisable<T[]> {\n const unfiltered = (() => {\n if (id === '') {\n return Object.values(this.modules) as T[]\n }\n if (typeof id !== 'string') {\n return\n }\n\n if (id === '*') {\n return Object.values(this.modules) as T[]\n }\n const name = isModuleName(id) ? id : undefined\n const address = isAddress(id) ? id : undefined\n assertEx(name ?? address, () => 'module identifier must be a ModuleName or Address')\n return (\n (name === undefined || name === '' ? undefined : this.resolveByName<T>(Object.values(this.modules), [name]).pop())\n ?? (address ? this.resolveByAddress<T>(this.modules, [address]).pop() : undefined)\n )\n })()\n const identity = options?.identity\n if (identity) {\n return (\n Array.isArray(unfiltered)\n ? unfiltered?.filter(mod => identity(mod))\n : identity(unfiltered)\n ? [unfiltered]\n : []\n )\n }\n return (\n unfiltered\n ? Array.isArray(unfiltered)\n ? unfiltered\n : [unfiltered]\n : []\n )\n }\n\n resolveIdentifier(id: ModuleIdentifier, _options?: ObjectFilterOptions): Promisable<XyoAddress | undefined> {\n // check if id is a name of one of modules in the resolver\n const moduleFromName = this.nameToModule[id]\n if (moduleFromName !== undefined) {\n return moduleFromName.address\n }\n\n // check if any of the modules have the id as an address\n for (const mod of Object.values(this.modules)) {\n if (mod.address === id) {\n return mod.address\n }\n }\n }\n\n private addSingleModule(mod?: ModuleInstance) {\n if (!mod) {\n return\n }\n\n const modName = mod.modName\n if (modName !== undefined && modName !== '' && this.allowNameResolution) {\n // check for collision\n assertEx(this.nameToModule[modName] === undefined, () => `Module with name ${modName} already added`)\n this.nameToModule[modName] = mod\n }\n this.modules[mod.address] = mod\n }\n\n private removeSingleModule(address: XyoAddress) {\n assertEx(isAddress(address), () => 'Invalid address')\n const mod = assertEx(this.modules[address], () => 'Address not found in modules')\n delete this.modules[address]\n const modName = mod.modName\n if (modName !== undefined && modName !== '') {\n delete this.nameToModule[modName]\n }\n }\n\n private resolveByAddress<T extends ModuleInstance = ModuleInstance>(modules: Record<XyoAddress, ModuleInstance>, address: XyoAddress[]): T[] {\n return (\n address.map((address) => {\n return modules[address]\n })\n ).filter(exists) as T[]\n }\n\n private resolveByName<T extends ModuleInstance = ModuleInstance>(modules: ModuleInstance[], name: ModuleName[]): T[] {\n return (\n name.map((name) => {\n return modules.find(mod => mod.modName === name)\n })\n ).filter(exists) as T[]\n }\n\n private resolveByQuery<T extends ModuleInstance = ModuleInstance>(modules: ModuleInstance[], query: string[][]): T[] {\n return (\n modules.filter((mod) => {\n const queryLists = query ?? []\n return queryLists.some(queryList => queryList.every(querySchema => mod.queries.includes(querySchema)))\n })\n ).filter(exists) as T[]\n }\n}\n", "import { isDefined, isUndefined } from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk-protocol'\nimport { LRUCache } from 'lru-cache'\n\nimport type { DivinerInstance } from '#diviner-model'\nimport { PayloadDivinerQuerySchema } from '#diviner-payload-model'\nimport type { ModuleIdentifier, ModuleIdentifierTransformer } from '#module-model'\n\nexport class NameRegistrarTransformer implements ModuleIdentifierTransformer {\n private _cache: LRUCache<ModuleIdentifier, ModuleIdentifier> = new LRUCache<ModuleIdentifier, ModuleIdentifier>({ max: 1000, ttl: 1000 * 5 })\n\n private registrarDiviner: DivinerInstance\n private root: string\n\n constructor(\n registrarDiviner: DivinerInstance,\n root: string,\n ) {\n this.registrarDiviner = registrarDiviner\n this.root = root\n }\n\n async transform(identifier: ModuleIdentifier): Promise<ModuleIdentifier> {\n const parts = identifier.split(':')\n const first = parts.shift()\n const nameParts = first?.split('.')\n if (nameParts?.length === 2 && nameParts[1] === this.root) {\n // check cache\n const cachedResult = this._cache.get(identifier)\n if (isDefined(cachedResult)) return cachedResult\n\n // not cached, so check registrar\n const query = {\n domain: nameParts[0], order: 'desc' as const, schema: PayloadDivinerQuerySchema, tld: nameParts[1],\n }\n const result = await this.registrarDiviner?.divine([query])\n const resultPayload = result?.shift()\n if (isUndefined(resultPayload)) {\n throw new Error(`Unable to resolve registrar name (failed) [${first}]`)\n }\n // TODO: Use proper types for this check\n if (isDefined(resultPayload)) {\n const address = (resultPayload as unknown as { address: XyoAddress[] }).address?.shift()\n if (address) {\n this._cache.set(identifier, address)\n return address\n }\n }\n throw new Error(`Unable to resolve registrar name (not found) [${first}]`)\n }\n return identifier\n }\n}\n", "import type {\n ModuleIdentifier, ModuleResolver,\n QueryableModule,\n} from '#module-model'\n\nexport interface ModuleResolvedEventArgs {\n id?: ModuleIdentifier\n mod: QueryableModule\n}\n\nexport interface ResolverEventEmitter {\n on(event: 'moduleResolved', listener: (args: ModuleResolvedEventArgs) => void): void\n}\n\nconst getMixin = <T extends ModuleResolver = ModuleResolver>(resolver: T) => {\n type ListenerFunction = (args: ModuleResolvedEventArgs) => void\n const listeners: ListenerFunction[] = []\n const emit = (event: 'moduleResolved', args: ModuleResolvedEventArgs): boolean => {\n if (listeners.length === 0) return false\n for (const listener of listeners) listener(args)\n return true\n }\n const onModuleResolved = (mod: QueryableModule, id?: ModuleIdentifier) => {\n const args = { id, mod }\n emit('moduleResolved', args)\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { resolve } = resolver\n function originalResolve(filter?: ModuleIdentifier) {\n return resolve.bind(resolver)(filter)\n }\n\n return {\n on: (event: 'moduleResolved', listener: (args: ModuleResolvedEventArgs) => void) => {\n listeners.push(listener)\n },\n resolve: async (id?: ModuleIdentifier): Promise<QueryableModule[]> => {\n const modulesResult = await originalResolve(id) ?? []\n const modules = Array.isArray(modulesResult) ? modulesResult : [modulesResult]\n\n // eslint-disable-next-line @typescript-eslint/await-thenable\n await Promise.allSettled(modules.map(mod => onModuleResolved(mod, id)))\n return modules\n },\n }\n}\n\nexport const mixinResolverEventEmitter = <T extends ModuleResolver = ModuleResolver>(resolver: T): T & ResolverEventEmitter => {\n const mixin = getMixin(resolver)\n return Object.assign(resolver, mixin)\n}\n"],
|
|
5
|
+
"mappings": ";AACA;AAAA,EACE;AAAA,EAAU;AAAA,EAAM;AAAA,OACX;AAUP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAOA,IAAe,yBAAf,cACG,KAC0B;AAAA,EAClC,IAAI,WAAW;AACb,WAAO,KAAK,OAAO,YAAY,uBAAuB;AAAA,EACxD;AAAA,EAEA,IAAI,SAAS,OAA+B;AAC1C,SAAK,OAAO,WAAW;AAAA,EACzB;AAAA,EAEA,IAAI,OAAuB;AACzB,WAAO,SAAS,KAAK,OAAO,MAAM,MAAM,iBAAiB;AAAA,EAC3D;AAAA,EAKA,MAAM,QACJ,KAAuB,KACvB,SAC8B;AAC9B,QAAI,OAAO,KAAK;AACd,YAAM,SAA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AAM,gBAAgB,MAAM,gBAAgB,EAAE,KAAK,CAAC;AACpD,YAAM,UAAU,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa;AAG7E,YAAM,QAAQ,WAAW,QAAQ,IAAI,SAAO,iBAAiB,KAAK,EAAE,CAAC,CAAC;AACtE,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,IAAM,4BAA4B,CAA4C,aAA0C;AAC7H,QAAM,QAAQ,SAAS,QAAQ;AAC/B,SAAO,OAAO,OAAO,UAAU,KAAK;AACtC;",
|
|
6
6
|
"names": ["assertEx", "exists", "isDefined", "isString", "duplicateModules", "ObjectResolverPriority", "assertEx", "asModuleInstance", "duplicateModules", "assertEx", "assertEx", "assertEx", "asModuleInstance", "duplicateModules", "mod", "assertEx", "asModuleInstance", "assertEx", "exists", "isAddress", "isAddress", "assertEx", "address", "exists", "name", "result", "exists", "duplicateModules", "isString", "mod", "isDefined", "ObjectResolverPriority", "assertEx", "isDefined", "LRUCache"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { AccountCustodyError } from './error.js';
|
|
2
|
+
import type { AccountCustody, AccountCustodyOptions, AccountCustodyOwner, InRealmAccountCustodyOwnerOptions } from './model.js';
|
|
3
|
+
/**
|
|
4
|
+
* Trusted provisioner entry. A live-state declaration is not cryptographic proof
|
|
5
|
+
* of a never-used key, restart recovery, physical isolation or cross-host custody.
|
|
6
|
+
* Unknown state reserves a stopped owner, and reservations never reset in this realm.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createInRealmAccountCustodyOwner(options: InRealmAccountCustodyOwnerOptions): AccountCustodyOwner;
|
|
9
|
+
/**
|
|
10
|
+
* Wraps a trusted, fixed operation builder. The complete native operation is
|
|
11
|
+
* serialized across all contexts sharing the owner; only content is caller input.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAccountCustody<Request, Result>(options: AccountCustodyOptions<Request, Result>): AccountCustody<Request, Result>;
|
|
14
|
+
//# sourceMappingURL=AccountCustody.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountCustody.d.ts","sourceRoot":"","sources":["../../../../src/modules/account-custody/AccountCustody.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,KAAK,EACV,cAAc,EAKd,qBAAqB,EACrB,mBAAmB,EAEnB,iCAAiC,EAClC,MAAM,YAAY,CAAA;AAqEnB;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,iCAAiC,GAAG,mBAAmB,CAmBhH;AA6ID;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CA8CtI"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AccountCustodyClient, AccountCustodyClientOptions } from './clientModel.js';
|
|
2
|
+
/** Trusted issuer creates a single fenced client; clean close preserves its resident owner. */
|
|
3
|
+
export declare function createAccountCustodyClient<Request, Result>(input: AccountCustodyClientOptions<Request, Result>): AccountCustodyClient<Request, Result>;
|
|
4
|
+
//# sourceMappingURL=AccountCustodyClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountCustodyClient.d.ts","sourceRoot":"","sources":["../../../../src/modules/account-custody/AccountCustodyClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;AAsEzF,+FAA+F;AAC/F,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,2BAA2B,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAqBtJ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AccountCustodyClientOptions } from './clientModel.js';
|
|
2
|
+
import { type ClientExecution, type ClientOwnerState, type ClientState } from './clientState.js';
|
|
3
|
+
export declare function afterClientQueue<Request, Result>(before: Promise<void>, owner: ClientOwnerState, client: ClientState, options: AccountCustodyClientOptions<Request, Result>, execution: ClientExecution, request: Request): Promise<Result>;
|
|
4
|
+
export declare function observeClientExecution<Result>(owner: ClientOwnerState, execution: ClientExecution, caller?: AbortSignal): {
|
|
5
|
+
result: Promise<Result>;
|
|
6
|
+
resolve: (value: Result | PromiseLike<Result>) => void;
|
|
7
|
+
reject: (reason?: any) => void;
|
|
8
|
+
cleanup: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function settleClientExecution<Result>(pending: Promise<Result>, observer: ReturnType<typeof observeClientExecution<Result>>): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=clientExecution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientExecution.d.ts","sourceRoot":"","sources":["../../../../src/modules/account-custody/clientExecution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;AAInE,OAAO,EAC8C,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EACjH,MAAM,kBAAkB,CAAA;AAwCzB,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EACpD,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EACrB,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,2BAA2B,CAAC,OAAO,EAAE,MAAM,CAAC,EACrD,SAAS,EAAE,eAAe,EAC1B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW;;;;;EAwBvH;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAQxJ"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AccountInstance, XyoAddress } from '@xyo-network/sdk-protocol';
|
|
2
|
+
import type { AccountCustodyExecuteOptions, AccountCustodyLimits, AccountCustodyOperationControl, AccountCustodyStatus } from './model.js';
|
|
3
|
+
export interface AccountCustodyClientAssurance {
|
|
4
|
+
readonly crossHostOwnership: 'unqualified';
|
|
5
|
+
readonly physicalKeyIsolation: 'unqualified';
|
|
6
|
+
readonly profile: 'in-realm-exclusive-scoped-client-v1';
|
|
7
|
+
readonly scope: 'participating instances and module copies in one globalThis realm';
|
|
8
|
+
}
|
|
9
|
+
/** Trusted resident issuer; execution callers receive only its client. */
|
|
10
|
+
export interface AccountCustodyClientOwner {
|
|
11
|
+
readonly address: XyoAddress;
|
|
12
|
+
readonly assurance: AccountCustodyClientAssurance;
|
|
13
|
+
readonly limits: AccountCustodyLimits;
|
|
14
|
+
readonly outstandingOperations: number;
|
|
15
|
+
readonly status: AccountCustodyStatus;
|
|
16
|
+
drain(): Promise<void>;
|
|
17
|
+
/** Permanently stops the owner; it never releases the address reservation. */
|
|
18
|
+
stop(): void;
|
|
19
|
+
}
|
|
20
|
+
export interface InRealmAccountCustodyClientOwnerOptions {
|
|
21
|
+
readonly account: AccountInstance;
|
|
22
|
+
readonly limits?: AccountCustodyLimits;
|
|
23
|
+
readonly nativeState: 'established-live' | 'unknown';
|
|
24
|
+
}
|
|
25
|
+
export interface AccountCustodyClientOptions<Request, Result> {
|
|
26
|
+
readonly binding: {
|
|
27
|
+
readonly address: XyoAddress;
|
|
28
|
+
readonly domain: string;
|
|
29
|
+
};
|
|
30
|
+
readonly createOperation: (account: AccountInstance, control: AccountCustodyOperationControl) => (request: Request) => Promise<Result>;
|
|
31
|
+
readonly owner: AccountCustodyClientOwner;
|
|
32
|
+
readonly snapshot: (request: Request) => Request;
|
|
33
|
+
}
|
|
34
|
+
/** Content-only, permanently closable generation capability. No owner/key escapes. */
|
|
35
|
+
export interface AccountCustodyClient<Request, Result> {
|
|
36
|
+
readonly assurance: AccountCustodyClientAssurance;
|
|
37
|
+
readonly binding: {
|
|
38
|
+
readonly address: XyoAddress;
|
|
39
|
+
readonly domain: string;
|
|
40
|
+
};
|
|
41
|
+
readonly outstandingOperations: number;
|
|
42
|
+
readonly status: AccountCustodyStatus;
|
|
43
|
+
drain(): Promise<void>;
|
|
44
|
+
execute(request: Request, options?: AccountCustodyExecuteOptions): Promise<Result>;
|
|
45
|
+
/** Close admission; queued pre-effect work cancels, started work retains ownership. */
|
|
46
|
+
stop(): void;
|
|
47
|
+
}
|
|
48
|
+
export type AccountCustodyClientErrorCode = 'account-reserved' | 'binding-mismatch' | 'cancelled-before-operation' | 'capacity-exhausted' | 'client-active' | 'client-not-drained' | 'invalid-limits' | 'invalid-request' | 'stopped' | 'uncertain-operation' | 'unissued-owner';
|
|
49
|
+
//# sourceMappingURL=clientModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientModel.d.ts","sourceRoot":"","sources":["../../../../src/modules/account-custody/clientModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAE5E,OAAO,KAAK,EACV,4BAA4B,EAAE,oBAAoB,EAAE,8BAA8B,EAAE,oBAAoB,EACzG,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,kBAAkB,EAAE,aAAa,CAAA;IAC1C,QAAQ,CAAC,oBAAoB,EAAE,aAAa,CAAA;IAC5C,QAAQ,CAAC,OAAO,EAAE,qCAAqC,CAAA;IACvD,QAAQ,CAAC,KAAK,EAAE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MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3E,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAA;IACtC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;IACrC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAClF,uFAAuF;IACvF,IAAI,IAAI,IAAI,CAAA;CACb;AAED,MAAM,MAAM,6BAA6B,GACrC,kBAAkB,GAAG,kBAAkB,GAAG,4BAA4B,GAAG,oBAAoB,GAC3F,eAAe,GAAG,oBAAoB,GAAG,gBAAgB,GAAG,iBAAiB,GAC7E,SAAS,GAAG,qBAAqB,GAAG,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AccountCustodyClientAssurance, AccountCustodyClientOwner, InRealmAccountCustodyClientOwnerOptions } from './clientModel.js';
|
|
2
|
+
import { type ClientOwnerState } from './clientState.js';
|
|
3
|
+
export declare const scopedClientAssurance: AccountCustodyClientAssurance;
|
|
4
|
+
/** Resident owner with no restoration/remint. Shares legacy's permanent account reservation. */
|
|
5
|
+
export declare function createInRealmAccountCustodyClientOwner(options: InRealmAccountCustodyClientOwnerOptions): AccountCustodyClientOwner;
|
|
6
|
+
export declare function getClientOwnerState(owner: AccountCustodyClientOwner): ClientOwnerState;
|
|
7
|
+
//# sourceMappingURL=clientOwner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientOwner.d.ts","sourceRoot":"","sources":["../../../../src/modules/account-custody/clientOwner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAAE,yBAAyB,EAAE,uCAAuC,EAClG,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACsB,KAAK,gBAAgB,EACjD,MAAM,kBAAkB,CAAA;AAIzB,eAAO,MAAM,qBAAqB,EAAE,6BAKlC,CAAA;AAYF,gGAAgG;AAChG,wBAAgB,sCAAsC,CAAC,OAAO,EAAE,uCAAuC,GAAG,yBAAyB,CAmBlI;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,yBAAyB,GAAG,gBAAgB,CAItF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function clientSignalAborted(signal: AbortSignal): boolean;
|
|
2
|
+
export declare function listenClientSignal(signal: AbortSignal, listener: () => void): void;
|
|
3
|
+
export declare function removeClientSignal(signal: AbortSignal, listener: () => void): void;
|
|
4
|
+
//# sourceMappingURL=clientSignals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientSignals.d.ts","sourceRoot":"","sources":["../../../../src/modules/account-custody/clientSignals.ts"],"names":[],"mappings":"AAeA,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAIhE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAElF;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAMlF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AccountInstance, XyoAddress } from '@xyo-network/sdk-protocol';
|
|
2
|
+
import type { AccountCustodyClientErrorCode } from './clientModel.js';
|
|
3
|
+
import type { AccountCustodyLimits } from './model.js';
|
|
4
|
+
export interface ClientExecution {
|
|
5
|
+
controller: AbortController;
|
|
6
|
+
hasCompleted: boolean;
|
|
7
|
+
hasStarted: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ClientState {
|
|
10
|
+
closed: boolean;
|
|
11
|
+
executions: Set<ClientExecution>;
|
|
12
|
+
tail: Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export interface ClientOwnerState {
|
|
15
|
+
account: AccountInstance;
|
|
16
|
+
address: XyoAddress;
|
|
17
|
+
current?: ClientState;
|
|
18
|
+
executions: Set<ClientExecution>;
|
|
19
|
+
limits: AccountCustodyLimits;
|
|
20
|
+
stopped: boolean;
|
|
21
|
+
tail: Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export declare class AccountCustodyClientError extends Error {
|
|
24
|
+
readonly code: AccountCustodyClientErrorCode;
|
|
25
|
+
name: string;
|
|
26
|
+
constructor(code: AccountCustodyClientErrorCode);
|
|
27
|
+
}
|
|
28
|
+
export declare function stopClientOwner(state: ClientOwnerState): void;
|
|
29
|
+
export declare function assertClientOwnerReady(state: ClientOwnerState): void;
|
|
30
|
+
export declare function settleClientTail(pending: Promise<unknown>): Promise<void>;
|
|
31
|
+
//# sourceMappingURL=clientState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientState.d.ts","sourceRoot":"","sources":["../../../../src/modules/account-custody/clientState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAE5E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEtD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,eAAe,CAAA;IAC3B,YAAY,EAAE,OAAO,CAAA;IACrB,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,GAAG,CAAC,eAAe,CAAC,CAAA;IAChC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,eAAe,CAAA;IACxB,OAAO,EAAE,UAAU,CAAA;IACnB,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,UAAU,EAAE,GAAG,CAAC,eAAe,CAAC,CAAA;IAChC,MAAM,EAAE,oBAAoB,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;CACpB;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,EAAE,6BAA6B,CAAA;IACnC,IAAI,SAA8B;gBAE/B,IAAI,EAAE,6BAA6B;CAIhD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAG7D;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAQpE;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAM/E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AccountCustodyErrorCode } from './model.js';
|
|
2
|
+
/** Classified failure with no private native exception, key material or request contents. */
|
|
3
|
+
export declare class AccountCustodyError extends Error {
|
|
4
|
+
readonly code: AccountCustodyErrorCode;
|
|
5
|
+
name: string;
|
|
6
|
+
constructor(code: AccountCustodyErrorCode);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../src/modules/account-custody/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAEzD,6FAA6F;AAC7F,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAA;IAC7B,IAAI,SAAwB;gBAEzB,IAAI,EAAE,uBAAuB;CAI1C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './AccountCustody.js';
|
|
2
|
+
export { createAccountCustodyClient } from './AccountCustodyClient.js';
|
|
3
|
+
export type * from './clientModel.js';
|
|
4
|
+
export { createInRealmAccountCustodyClientOwner } from './clientOwner.js';
|
|
5
|
+
export { AccountCustodyClientError } from './clientState.js';
|
|
6
|
+
export * from './model.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/account-custody/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAA;AACtE,mBAAmB,kBAAkB,CAAA;AACrC,OAAO,EAAE,sCAAsC,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { AccountInstance, XyoAddress } from '@xyo-network/sdk-protocol';
|
|
2
|
+
/** Actual implementation boundary; selecting it does not qualify deployment key isolation. */
|
|
3
|
+
export interface AccountCustodyAssurance {
|
|
4
|
+
readonly crossHostOwnership: 'unqualified';
|
|
5
|
+
readonly physicalKeyIsolation: 'unqualified';
|
|
6
|
+
readonly profile: 'in-realm-exclusive-v1';
|
|
7
|
+
readonly scope: 'participating instances and module copies in one globalThis realm';
|
|
8
|
+
}
|
|
9
|
+
/** Opaque owner issued by the implementation, never a structural ownership assertion. */
|
|
10
|
+
export interface AccountCustodyOwner {
|
|
11
|
+
readonly address: XyoAddress;
|
|
12
|
+
readonly assurance: AccountCustodyAssurance;
|
|
13
|
+
readonly limits: AccountCustodyLimits;
|
|
14
|
+
}
|
|
15
|
+
/** Finite engineering guards shared by all operation contexts of one owner. */
|
|
16
|
+
export interface AccountCustodyLimits {
|
|
17
|
+
/** Monotonic cooperative deadline (1..2,147,483,647ms); expiry never proves effects drained. */
|
|
18
|
+
readonly maxOperationMilliseconds: number;
|
|
19
|
+
/** Zero through 1024 waiting operations in addition to one active operation. */
|
|
20
|
+
readonly maxQueuedOperations: number;
|
|
21
|
+
}
|
|
22
|
+
/** Trusted host provisioning only. Missing/unknown state is stopped, never reconstructed. */
|
|
23
|
+
export interface InRealmAccountCustodyOwnerOptions {
|
|
24
|
+
account: AccountInstance;
|
|
25
|
+
/** Defaults: eight waiting operations and 30,000ms, engineering guards only. */
|
|
26
|
+
limits?: AccountCustodyLimits;
|
|
27
|
+
nativeState: 'established-live' | 'unknown';
|
|
28
|
+
}
|
|
29
|
+
export interface AccountCustodyBinding {
|
|
30
|
+
readonly address: XyoAddress;
|
|
31
|
+
/** Fixed caller-approved signing domain; its native interpretation belongs to the trusted adapter. */
|
|
32
|
+
readonly domain: string;
|
|
33
|
+
}
|
|
34
|
+
/** Guard for trusted adapter preparation and native effects within the complete operation. */
|
|
35
|
+
export interface AccountCustodyOperationControl {
|
|
36
|
+
readonly signal: AbortSignal;
|
|
37
|
+
assertActive(): void;
|
|
38
|
+
}
|
|
39
|
+
export interface AccountCustodyOptions<Request, Result> {
|
|
40
|
+
binding: AccountCustodyBinding;
|
|
41
|
+
owner: AccountCustodyOwner;
|
|
42
|
+
/** Trusted composition: created inside admission, before predecessor capture; never supplied by execute callers. */
|
|
43
|
+
createOperation(this: void, account: AccountInstance, control: AccountCustodyOperationControl): (request: Request) => Promise<Result>;
|
|
44
|
+
/** Synchronous trusted finite-profile validation/copy; output is still structured-cloned before queueing. */
|
|
45
|
+
snapshot(this: void, request: Request): Request;
|
|
46
|
+
}
|
|
47
|
+
export interface AccountCustodyExecuteOptions {
|
|
48
|
+
signal?: AbortSignal;
|
|
49
|
+
}
|
|
50
|
+
export type AccountCustodyStatus = 'ready' | 'running' | 'stopped';
|
|
51
|
+
/** Execution callers receive content-only operations, not native accounts, keys or callbacks. */
|
|
52
|
+
export interface AccountCustody<Request, Result> {
|
|
53
|
+
readonly assurance: AccountCustodyAssurance;
|
|
54
|
+
readonly binding: AccountCustodyBinding;
|
|
55
|
+
/** Admitted operations not yet truly drained, including late work after stop. */
|
|
56
|
+
readonly outstandingOperations: number;
|
|
57
|
+
readonly status: AccountCustodyStatus;
|
|
58
|
+
/** Waits for all admitted work, including a late callback after cancellation/stop. */
|
|
59
|
+
drain(): Promise<void>;
|
|
60
|
+
execute(request: Request, options?: AccountCustodyExecuteOptions): Promise<Result>;
|
|
61
|
+
/** Permanently closes admission in this realm; does not undo accepted work or enable takeover. */
|
|
62
|
+
stop(): void;
|
|
63
|
+
}
|
|
64
|
+
export type AccountCustodyErrorCode = 'account-reserved' | 'capacity-exhausted' | 'binding-mismatch' | 'cancelled-before-operation' | 'invalid-limits' | 'invalid-request' | 'stopped' | 'uncertain-operation' | 'unissued-owner';
|
|
65
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../src/modules/account-custody/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAE5E,8FAA8F;AAC9F,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,kBAAkB,EAAE,aAAa,CAAA;IAC1C,QAAQ,CAAC,oBAAoB,EAAE,aAAa,CAAA;IAC5C,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAA;IACzC,QAAQ,CAAC,KAAK,EAAE,mEAAmE,CAAA;CACpF;AAED,yFAAyF;AACzF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,uBAAuB,CAAA;IAC3C,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;CACtC;AAED,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC,gGAAgG;IAChG,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAA;IACzC,gFAAgF;IAChF,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;CACrC;AAED,6FAA6F;AAC7F,MAA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AAC,IAAI,CAAC,CAAA;IACtB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAClF,kGAAkG;IAClG,IAAI,IAAI,IAAI,CAAA;CACb;AAED,MAAM,MAAM,uBAAuB,GAC7B,kBAAkB,GAClB,oBAAoB,GACpB,kBAAkB,GAClB,4BAA4B,GAC5B,gBAAgB,GAChB,iBAAiB,GACjB,SAAS,GACT,qBAAqB,GACrB,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realmRegistry.d.ts","sourceRoot":"","sources":["../../../../src/modules/account-custody/realmRegistry.ts"],"names":[],"mappings":"AAkCA,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,MAA0B,GAAG,OAAO,CAEjG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../../../src/modules/address-payload-plugin/Plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../../../src/modules/address-payload-plugin/Plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGnD,eAAO,MAAM,oBAAoB,QAAO,aAAa,CAAC,cAAc,CAIhE,CAAA"}
|