@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.
Files changed (82) hide show
  1. package/README.md +25 -0
  2. package/dist/neutral/account-custody.d.ts +2 -0
  3. package/dist/neutral/account-custody.d.ts.map +1 -0
  4. package/dist/neutral/account-custody.mjs +542 -0
  5. package/dist/neutral/account-custody.mjs.map +7 -0
  6. package/dist/neutral/address-payload-plugin.mjs +3 -14
  7. package/dist/neutral/address-payload-plugin.mjs.map +4 -4
  8. package/dist/neutral/api-location-diviner.mjs +0 -2
  9. package/dist/neutral/api-location-diviner.mjs.map +2 -2
  10. package/dist/neutral/archivist-memory.mjs +1 -4
  11. package/dist/neutral/archivist-memory.mjs.map +2 -2
  12. package/dist/neutral/bridge-abstract.mjs +4 -7
  13. package/dist/neutral/bridge-abstract.mjs.map +2 -2
  14. package/dist/neutral/bridge-http.mjs +1 -1
  15. package/dist/neutral/bridge-http.mjs.map +2 -2
  16. package/dist/neutral/diviner-boundwitness.memory.mjs +1 -1
  17. package/dist/neutral/diviner-boundwitness.memory.mjs.map +2 -2
  18. package/dist/neutral/diviner-boundwitness.mjs +1 -1
  19. package/dist/neutral/diviner-boundwitness.mjs.map +2 -2
  20. package/dist/neutral/diviner-payload-generic.mjs +3 -3
  21. package/dist/neutral/diviner-payload-generic.mjs.map +2 -2
  22. package/dist/neutral/index.d.ts +1 -0
  23. package/dist/neutral/index.d.ts.map +1 -1
  24. package/dist/neutral/index.mjs +1 -0
  25. package/dist/neutral/index.mjs.map +2 -2
  26. package/dist/neutral/module-abstract.mjs +4 -4
  27. package/dist/neutral/module-abstract.mjs.map +3 -3
  28. package/dist/neutral/module-resolver.mjs +3 -6
  29. package/dist/neutral/module-resolver.mjs.map +2 -2
  30. package/dist/neutral/modules/account-custody/AccountCustody.d.ts +14 -0
  31. package/dist/neutral/modules/account-custody/AccountCustody.d.ts.map +1 -0
  32. package/dist/neutral/modules/account-custody/AccountCustodyClient.d.ts +4 -0
  33. package/dist/neutral/modules/account-custody/AccountCustodyClient.d.ts.map +1 -0
  34. package/dist/neutral/modules/account-custody/clientExecution.d.ts +11 -0
  35. package/dist/neutral/modules/account-custody/clientExecution.d.ts.map +1 -0
  36. package/dist/neutral/modules/account-custody/clientModel.d.ts +49 -0
  37. package/dist/neutral/modules/account-custody/clientModel.d.ts.map +1 -0
  38. package/dist/neutral/modules/account-custody/clientOwner.d.ts +7 -0
  39. package/dist/neutral/modules/account-custody/clientOwner.d.ts.map +1 -0
  40. package/dist/neutral/modules/account-custody/clientSignals.d.ts +4 -0
  41. package/dist/neutral/modules/account-custody/clientSignals.d.ts.map +1 -0
  42. package/dist/neutral/modules/account-custody/clientState.d.ts +31 -0
  43. package/dist/neutral/modules/account-custody/clientState.d.ts.map +1 -0
  44. package/dist/neutral/modules/account-custody/error.d.ts +8 -0
  45. package/dist/neutral/modules/account-custody/error.d.ts.map +1 -0
  46. package/dist/neutral/modules/account-custody/index.d.ts +7 -0
  47. package/dist/neutral/modules/account-custody/index.d.ts.map +1 -0
  48. package/dist/neutral/modules/account-custody/model.d.ts +65 -0
  49. package/dist/neutral/modules/account-custody/model.d.ts.map +1 -0
  50. package/dist/neutral/modules/account-custody/realmRegistry.d.ts +2 -0
  51. package/dist/neutral/modules/account-custody/realmRegistry.d.ts.map +1 -0
  52. package/dist/neutral/modules/address-payload-plugin/Plugin.d.ts.map +1 -1
  53. package/dist/neutral/modules/address-payload-plugin/index.d.ts +0 -1
  54. package/dist/neutral/modules/address-payload-plugin/index.d.ts.map +1 -1
  55. package/dist/neutral/modules/api-location-diviner/RemoteDivinerConfig.d.ts +0 -2
  56. package/dist/neutral/modules/api-location-diviner/RemoteDivinerConfig.d.ts.map +1 -1
  57. package/dist/neutral/modules/archivist-memory/MemoryDriver.d.ts.map +1 -1
  58. package/dist/neutral/modules/bridge-abstract/AbstractModuleProxy/ModuleProxyResolver.d.ts.map +1 -1
  59. package/dist/neutral/modules/bridge-http/HttpBridge.d.ts.map +1 -1
  60. package/dist/neutral/modules/diviner-boundwitness/applyBoundWitnessDivinerQueryPayload.d.ts.map +1 -1
  61. package/dist/neutral/modules/diviner-payload-generic/Diviner.d.ts.map +1 -1
  62. package/dist/neutral/modules/module-resolver/AbstractModuleResolver.d.ts.map +1 -1
  63. package/dist/neutral/modules/module-resolver/ResolverEventEmitter.d.ts.map +1 -1
  64. package/dist/neutral/modules/node-memory/MemoryNode.d.ts.map +1 -1
  65. package/dist/neutral/node-memory.mjs +1 -4
  66. package/dist/neutral/node-memory.mjs.map +2 -2
  67. package/dist/node/account-custody.d.ts +2 -0
  68. package/dist/node/account-custody.d.ts.map +1 -0
  69. package/dist/node/index.d.ts +1 -0
  70. package/dist/node/index.d.ts.map +1 -1
  71. package/dist/node/index.mjs +1 -0
  72. package/dist/node/index.mjs.map +2 -2
  73. package/dist/node/modules/account-custody/clientExecution.d.ts +11 -0
  74. package/dist/node/modules/account-custody/clientExecution.d.ts.map +1 -0
  75. package/dist/node/modules/account-custody/clientSignals.d.ts +4 -0
  76. package/dist/node/modules/account-custody/clientSignals.d.ts.map +1 -0
  77. package/dist/node/modules/account-custody/realmRegistry.d.ts +2 -0
  78. package/dist/node/modules/account-custody/realmRegistry.d.ts.map +1 -0
  79. package/dist/node/modules/archivist-memory/MemoryDriver.d.ts.map +1 -1
  80. package/package.json +17 -11
  81. package/dist/neutral/modules/address-payload-plugin/Template.d.ts +0 -3
  82. package/dist/neutral/modules/address-payload-plugin/Template.d.ts.map +0 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/modules/account-custody/error.ts", "../../src/modules/account-custody/realmRegistry.ts", "../../src/modules/account-custody/AccountCustody.ts", "../../src/modules/account-custody/clientState.ts", "../../src/modules/account-custody/clientSignals.ts", "../../src/modules/account-custody/clientExecution.ts", "../../src/modules/account-custody/clientOwner.ts", "../../src/modules/account-custody/AccountCustodyClient.ts"],
4
+ "sourcesContent": ["import type { AccountCustodyErrorCode } from './model.ts'\n\n/** Classified failure with no private native exception, key material or request contents. */\nexport class AccountCustodyError extends Error {\n readonly code: AccountCustodyErrorCode\n override name = 'AccountCustodyError'\n\n constructor(code: AccountCustodyErrorCode) {\n super(`Account custody: ${code}`)\n this.code = code\n }\n}\n", "import { AccountCustodyError } from './error.ts'\n\ninterface RealmRegistry {\n readonly version: 1\n reserve(this: void, key: string, fence: object): boolean\n}\n\nfunction realmRegistry(): RealmRegistry {\n const key = Symbol.for('network.xyo.sdk.account-custody.in-realm.v1')\n const existing: unknown = Reflect.get(globalThis, key)\n if (existing === undefined) {\n const reservations = new Set<string>()\n const registry: RealmRegistry = Object.freeze({\n version: 1,\n reserve(key: string, _fence: object): boolean {\n if (reservations.has(key)) return false\n reservations.add(key)\n return true\n },\n })\n Object.defineProperty(globalThis, key, {\n value: registry, configurable: false, writable: false,\n })\n return registry\n }\n if (typeof existing !== 'object' || existing === null || !Object.isFrozen(existing)\n || !('version' in existing) || existing.version !== 1 || !('reserve' in existing)\n || typeof existing.reserve !== 'function') throw new AccountCustodyError('stopped')\n return existing as RealmRegistry\n}\n\n// One permanent address reservation shared by legacy/scoped modes and module copies.\nconst registry = realmRegistry()\n\nexport function reserveInRealmAccount(address: string, fence: object = Object.freeze({})): boolean {\n return registry.reserve(address.toLowerCase(), fence)\n}\n", "import type { AccountInstance } from '@xyo-network/sdk-protocol'\n\nimport { AccountCustodyError } from './error.ts'\nimport { reserveInRealmAccount } from './realmRegistry.ts'\n\nexport { AccountCustodyError } from './error.ts'\n\nimport type {\n AccountCustody,\n AccountCustodyAssurance,\n AccountCustodyExecuteOptions,\n AccountCustodyLimits,\n AccountCustodyOperationControl,\n AccountCustodyOptions,\n AccountCustodyOwner,\n AccountCustodyStatus,\n InRealmAccountCustodyOwnerOptions,\n} from './model.ts'\n\ninterface RealmFence {\n active?: AbortController\n executions: Set<Execution>\n isStopped: boolean\n reservation: object\n tail: Promise<void>\n}\n\ninterface OwnerState {\n account: AccountInstance\n fence: RealmFence\n limits: AccountCustodyLimits\n reservation: object\n}\n\ninterface Execution {\n controller: AbortController\n hasCompleted: boolean\n hasStarted: boolean\n}\n\ninterface ExecutionObserver<Result> {\n result: Promise<Result>\n cleanup(this: void): void\n reject(this: void, error: unknown): void\n resolve(this: void, result: Result): void\n}\n\n// Native intrinsics ignore caller-owned getters and shadowed event methods.\nfunction intrinsic(prototype: object, property: string, member: 'get' | 'value'): unknown {\n const descriptor: unknown = Object.getOwnPropertyDescriptor(prototype, property)\n return typeof descriptor !== 'object' || descriptor === null ? undefined : (descriptor as Record<string, unknown>)[member]\n}\n\nconst nativeAbortedGetter = intrinsic(AbortSignal.prototype, 'aborted', 'get')\nconst nativeAddListener = intrinsic(EventTarget.prototype, 'addEventListener', 'value')\nconst nativeRemoveListener = intrinsic(EventTarget.prototype, 'removeEventListener', 'value')\n\nfunction nativeCall(method: unknown, receiver: object, args: unknown[]): unknown {\n if (typeof method !== 'function') throw new AccountCustodyError('invalid-request')\n return Reflect.apply(method, receiver, args)\n}\n\nfunction isSignalAborted(signal: AbortSignal): boolean {\n const result = nativeCall(nativeAbortedGetter, signal, [])\n if (typeof result !== 'boolean') throw new AccountCustodyError('invalid-request')\n return result\n}\n\nfunction captureSignal(options: AccountCustodyExecuteOptions): AbortSignal | undefined {\n try {\n const signal = options.signal\n if (signal !== undefined) isSignalAborted(signal)\n return signal\n } catch {\n throw new AccountCustodyError('invalid-request')\n }\n}\n\nconst owners = new WeakMap<AccountCustodyOwner, OwnerState>()\nconst assurance: AccountCustodyAssurance = Object.freeze({\n profile: 'in-realm-exclusive-v1',\n scope: 'participating instances and module copies in one globalThis realm',\n physicalKeyIsolation: 'unqualified',\n crossHostOwnership: 'unqualified',\n})\n\n/**\n * Trusted provisioner entry. A live-state declaration is not cryptographic proof\n * of a never-used key, restart recovery, physical isolation or cross-host custody.\n * Unknown state reserves a stopped owner, and reservations never reset in this realm.\n */\nexport function createInRealmAccountCustodyOwner(options: InRealmAccountCustodyOwnerOptions): AccountCustodyOwner {\n const limits = finiteLimits(options.limits)\n const address = options.account.address\n const key = address.toLowerCase()\n const reservation = Object.freeze({})\n const fence: RealmFence = {\n executions: new Set(),\n reservation,\n isStopped: options.nativeState !== 'established-live',\n tail: Promise.resolve(),\n }\n if (!reserveInRealmAccount(key, fence)) throw new AccountCustodyError('account-reserved')\n const owner: AccountCustodyOwner = Object.freeze({\n address, assurance, limits,\n })\n owners.set(owner, {\n account: options.account, fence, limits, reservation,\n })\n return owner\n}\n\nfunction finiteLimits(selected: AccountCustodyLimits | undefined): AccountCustodyLimits {\n const maxQueuedOperations = selected?.maxQueuedOperations ?? 8\n const maxOperationMilliseconds = selected?.maxOperationMilliseconds ?? 30_000\n if (!Number.isSafeInteger(maxQueuedOperations) || maxQueuedOperations < 0 || maxQueuedOperations > 1024\n || !Number.isSafeInteger(maxOperationMilliseconds) || maxOperationMilliseconds <= 0 || maxOperationMilliseconds > 2_147_483_647) {\n throw new AccountCustodyError('invalid-limits')\n }\n return Object.freeze({ maxQueuedOperations, maxOperationMilliseconds })\n}\n\nfunction stopOwner(state: OwnerState): void {\n if (state.fence.isStopped) return\n state.fence.isStopped = true\n for (const execution of state.fence.executions) execution.controller.abort()\n}\n\nfunction assertReady(state: OwnerState, owner: AccountCustodyOwner): void {\n if (!state.fence.isStopped && state.fence.reservation === state.reservation && state.account.address === owner.address) return\n stopOwner(state)\n throw new AccountCustodyError('stopped')\n}\n\nfunction operationControl(state: OwnerState, execution: Execution, deadline: number): AccountCustodyOperationControl {\n return Object.freeze({\n signal: execution.controller.signal,\n assertActive(): void {\n assertWithinDeadline(deadline)\n if (execution.controller.signal.aborted || state.fence.isStopped) throw new AccountCustodyError('uncertain-operation')\n },\n })\n}\n\nfunction assertWithinDeadline(deadline: number): void {\n if (performance.now() >= deadline) throw new AccountCustodyError('uncertain-operation')\n}\n\nasync function perform<Request, Result>(\n state: OwnerState,\n options: AccountCustodyOptions<Request, Result>,\n execution: Execution,\n request: Request,\n): Promise<Result> {\n if (execution.controller.signal.aborted) throw new AccountCustodyError('cancelled-before-operation')\n assertReady(state, options.owner)\n execution.hasStarted = true\n state.fence.active = execution.controller\n const deadline = performance.now() + state.limits.maxOperationMilliseconds\n const timer = setTimeout(() => execution.controller.abort(), state.limits.maxOperationMilliseconds)\n try {\n const control = operationControl(state, execution, deadline)\n const operation = options.createOperation(state.account, control)\n const result = await operation(request)\n const cloned = structuredClone(result)\n assertWithinDeadline(deadline)\n control.assertActive()\n execution.hasCompleted = true\n return cloned\n } catch {\n stopOwner(state)\n throw new AccountCustodyError('uncertain-operation')\n } finally {\n clearTimeout(timer)\n if (state.fence.active === execution.controller) state.fence.active = undefined\n }\n}\n\nfunction prepareExecution<Result>(\n state: OwnerState,\n execution: Execution,\n signal: AbortSignal | undefined,\n): ExecutionObserver<Result> {\n const deferred = Promise.withResolvers<Result>()\n const local = execution.controller.signal\n const abort = () => execution.controller.abort()\n const aborted = () => {\n if (execution.hasCompleted) return\n if (execution.hasStarted) stopOwner(state)\n const code = execution.hasStarted ? 'uncertain-operation' : state.fence.isStopped ? 'stopped' : 'cancelled-before-operation'\n deferred.reject(new AccountCustodyError(code))\n }\n const cleanup = () => {\n try {\n if (signal !== undefined) nativeCall(nativeRemoveListener, signal, ['abort', abort])\n nativeCall(nativeRemoveListener, local, ['abort', aborted])\n } catch {\n // Cleanup cannot expose native diagnostics or orphan an unhandled rejection.\n }\n }\n try {\n nativeCall(nativeAddListener, local, ['abort', aborted, { once: true }])\n if (signal !== undefined) nativeCall(nativeAddListener, signal, ['abort', abort, { once: true }])\n if (signal !== undefined && isSignalAborted(signal)) abort()\n } catch {\n cleanup()\n throw new AccountCustodyError('invalid-request')\n }\n return {\n result: deferred.promise, resolve: deferred.resolve, reject: deferred.reject, cleanup,\n }\n}\n\nasync function settleExecution<Result>(\n pending: Promise<Result>,\n resolve: (result: Result) => void,\n reject: (error: unknown) => void,\n cleanup: () => void,\n): Promise<void> {\n try {\n resolve(await pending)\n } catch (error) {\n reject(error)\n } finally {\n cleanup()\n }\n}\n\nasync function afterQueue<Request, Result>(\n before: Promise<void>,\n state: OwnerState,\n options: AccountCustodyOptions<Request, Result>,\n execution: Execution,\n request: Request,\n): Promise<Result> {\n try {\n await before\n return await perform(state, options, execution, request)\n } finally {\n state.fence.executions.delete(execution)\n }\n}\n\nasync function drainPending(pending: Promise<unknown>): Promise<void> {\n try {\n await pending\n } catch {\n // Failure is delivered to its caller and does not break queue draining.\n }\n}\n\n/**\n * Wraps a trusted, fixed operation builder. The complete native operation is\n * serialized across all contexts sharing the owner; only content is caller input.\n */\nexport function createAccountCustody<Request, Result>(options: AccountCustodyOptions<Request, Result>): AccountCustody<Request, Result> {\n const state = owners.get(options.owner)\n if (state === undefined) throw new AccountCustodyError('unissued-owner')\n const binding = Object.freeze({ address: options.binding.address, domain: options.binding.domain })\n if (binding.address !== options.owner.address || binding.domain.length === 0) throw new AccountCustodyError('binding-mismatch')\n // Capture immutable composition; later host/caller option mutation cannot retarget work.\n const captured: AccountCustodyOptions<Request, Result> = {\n owner: options.owner, binding, createOperation: options.createOperation, snapshot: options.snapshot,\n }\n return Object.freeze({\n assurance,\n binding,\n get outstandingOperations(): number {\n return state.fence.executions.size\n },\n get status(): AccountCustodyStatus {\n return state.fence.isStopped ? 'stopped' : state.fence.active === undefined ? 'ready' : 'running'\n },\n async execute(request: Request, executionOptions: AccountCustodyExecuteOptions = {}): Promise<Result> {\n assertReady(state, captured.owner)\n if (state.fence.executions.size >= state.limits.maxQueuedOperations + 1) throw new AccountCustodyError('capacity-exhausted')\n const signal = captureSignal(executionOptions)\n if (signal !== undefined && isSignalAborted(signal)) throw new AccountCustodyError('cancelled-before-operation')\n let original: Request\n try {\n original = structuredClone(captured.snapshot(request))\n } catch {\n throw new AccountCustodyError('invalid-request')\n }\n const execution: Execution = {\n controller: new AbortController(), hasCompleted: false, hasStarted: false,\n }\n const observer = prepareExecution<Result>(state, execution, signal)\n state.fence.executions.add(execution)\n const pending = afterQueue(state.fence.tail, state, captured, execution, original)\n state.fence.tail = drainPending(pending)\n void settleExecution(pending, observer.resolve, observer.reject, observer.cleanup)\n return await observer.result\n },\n stop(): void {\n stopOwner(state)\n },\n async drain(): Promise<void> {\n await state.fence.tail\n },\n })\n}\n", "import type { AccountInstance, XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { AccountCustodyClientErrorCode } from './clientModel.ts'\nimport type { AccountCustodyLimits } from './model.ts'\n\nexport interface ClientExecution {\n controller: AbortController\n hasCompleted: boolean\n hasStarted: boolean\n}\n\nexport interface ClientState {\n closed: boolean\n executions: Set<ClientExecution>\n tail: Promise<void>\n}\n\nexport interface ClientOwnerState {\n account: AccountInstance\n address: XyoAddress\n current?: ClientState\n executions: Set<ClientExecution>\n limits: AccountCustodyLimits\n stopped: boolean\n tail: Promise<void>\n}\n\nexport class AccountCustodyClientError extends Error {\n readonly code: AccountCustodyClientErrorCode\n override name = 'AccountCustodyClientError'\n\n constructor(code: AccountCustodyClientErrorCode) {\n super(`Account custody client: ${code}`)\n this.code = code\n }\n}\n\nexport function stopClientOwner(state: ClientOwnerState): void {\n state.stopped = true\n for (const execution of state.executions) execution.controller.abort()\n}\n\nexport function assertClientOwnerReady(state: ClientOwnerState): void {\n try {\n if (!state.stopped && state.account.address === state.address) return\n } catch {\n // Trusted account failure cannot expose private diagnostics or establish state.\n }\n stopClientOwner(state)\n throw new AccountCustodyClientError('stopped')\n}\n\nexport async function settleClientTail(pending: Promise<unknown>): Promise<void> {\n try {\n await pending\n } catch {\n // The operation caller observes failure; this promise retains genuine settlement.\n }\n}\n", "import { AccountCustodyClientError } from './clientState.ts'\n\nfunction intrinsic(prototype: object, property: string, member: 'get' | 'value'): unknown {\n const descriptor: unknown = Object.getOwnPropertyDescriptor(prototype, property)\n return typeof descriptor !== 'object' || descriptor === null ? undefined : (descriptor as Record<string, unknown>)[member]\n}\nconst abortedGetter = intrinsic(AbortSignal.prototype, 'aborted', 'get')\nconst addListener = intrinsic(EventTarget.prototype, 'addEventListener', 'value')\nconst removeListener = intrinsic(EventTarget.prototype, 'removeEventListener', 'value')\n\nfunction nativeCall(method: unknown, receiver: object, args: unknown[]): unknown {\n if (typeof method !== 'function') throw new AccountCustodyClientError('invalid-request')\n return Reflect.apply(method, receiver, args)\n}\n\nexport function clientSignalAborted(signal: AbortSignal): boolean {\n const result = nativeCall(abortedGetter, signal, [])\n if (typeof result !== 'boolean') throw new AccountCustodyClientError('invalid-request')\n return result\n}\n\nexport function listenClientSignal(signal: AbortSignal, listener: () => void): void {\n nativeCall(addListener, signal, ['abort', listener, { once: true }])\n}\n\nexport function removeClientSignal(signal: AbortSignal, listener: () => void): void {\n try {\n nativeCall(removeListener, signal, ['abort', listener])\n } catch {\n // Cleanup cannot leak native diagnostics; actual callback settlement owns capacity.\n }\n}\n", "import type { AccountCustodyClientOptions } from './clientModel.ts'\nimport {\n clientSignalAborted, listenClientSignal, removeClientSignal,\n} from './clientSignals.ts'\nimport {\n AccountCustodyClientError, assertClientOwnerReady, type ClientExecution, type ClientOwnerState, type ClientState, stopClientOwner,\n} from './clientState.ts'\nimport type { AccountCustodyOperationControl } from './model.ts'\n\nfunction operationControl(owner: ClientOwnerState, execution: ClientExecution, deadline: number): AccountCustodyOperationControl {\n return Object.freeze({\n signal: execution.controller.signal,\n assertActive() {\n assertClientOwnerReady(owner)\n if (performance.now() >= deadline || execution.controller.signal.aborted || owner.stopped)\n throw new AccountCustodyClientError('uncertain-operation')\n },\n })\n}\n\nasync function perform<Request, Result>(\n owner: ClientOwnerState,\n client: ClientState,\n options: AccountCustodyClientOptions<Request, Result>,\n execution: ClientExecution,\n request: Request,\n): Promise<Result> {\n if (client.closed || execution.controller.signal.aborted) throw new AccountCustodyClientError('cancelled-before-operation')\n assertClientOwnerReady(owner)\n execution.hasStarted = true\n const deadline = performance.now() + owner.limits.maxOperationMilliseconds\n const timer = setTimeout(() => execution.controller.abort(), owner.limits.maxOperationMilliseconds)\n try {\n const control = operationControl(owner, execution, deadline)\n const result = structuredClone(await options.createOperation(owner.account, control)(request))\n control.assertActive()\n execution.hasCompleted = true\n return result\n } catch {\n stopClientOwner(owner)\n throw new AccountCustodyClientError('uncertain-operation')\n } finally {\n clearTimeout(timer)\n }\n}\n\nexport async function afterClientQueue<Request, Result>(\n before: Promise<void>,\n owner: ClientOwnerState,\n client: ClientState,\n options: AccountCustodyClientOptions<Request, Result>,\n execution: ClientExecution,\n request: Request,\n): Promise<Result> {\n try {\n await before\n return await perform(owner, client, options, execution, request)\n } finally {\n owner.executions.delete(execution)\n client.executions.delete(execution)\n }\n}\n\nexport function observeClientExecution<Result>(owner: ClientOwnerState, execution: ClientExecution, caller?: AbortSignal) {\n const deferred = Promise.withResolvers<Result>()\n const local = execution.controller.signal\n const abort = () => execution.controller.abort()\n const aborted = () => {\n if (execution.hasCompleted) return\n if (execution.hasStarted) stopClientOwner(owner)\n deferred.reject(new AccountCustodyClientError(execution.hasStarted ? 'uncertain-operation' : owner.stopped ? 'stopped' : 'cancelled-before-operation'))\n }\n const cleanup = () => {\n removeClientSignal(local, aborted)\n if (caller !== undefined) removeClientSignal(caller, abort)\n }\n try {\n listenClientSignal(local, aborted)\n if (caller !== undefined) listenClientSignal(caller, abort)\n if (caller !== undefined && clientSignalAborted(caller)) abort()\n } catch {\n cleanup()\n throw new AccountCustodyClientError('invalid-request')\n }\n return {\n result: deferred.promise, resolve: deferred.resolve, reject: deferred.reject, cleanup,\n }\n}\n\nexport async function settleClientExecution<Result>(pending: Promise<Result>, observer: ReturnType<typeof observeClientExecution<Result>>): Promise<void> {\n try {\n observer.resolve(await pending)\n } catch (error) {\n observer.reject(error)\n } finally {\n observer.cleanup()\n }\n}\n", "import type {\n AccountCustodyClientAssurance, AccountCustodyClientOwner, InRealmAccountCustodyClientOwnerOptions,\n} from './clientModel.ts'\nimport {\n AccountCustodyClientError, type ClientOwnerState, stopClientOwner,\n} from './clientState.ts'\nimport type { AccountCustodyLimits } from './model.ts'\nimport { reserveInRealmAccount } from './realmRegistry.ts'\n\nexport const scopedClientAssurance: AccountCustodyClientAssurance = Object.freeze({\n profile: 'in-realm-exclusive-scoped-client-v1',\n scope: 'participating instances and module copies in one globalThis realm',\n physicalKeyIsolation: 'unqualified',\n crossHostOwnership: 'unqualified',\n})\nconst owners = new WeakMap<AccountCustodyClientOwner, ClientOwnerState>()\n\nfunction finiteLimits(selected?: AccountCustodyLimits): AccountCustodyLimits {\n const maxQueuedOperations = selected?.maxQueuedOperations ?? 8\n const maxOperationMilliseconds = selected?.maxOperationMilliseconds ?? 30_000\n if (!Number.isSafeInteger(maxQueuedOperations) || maxQueuedOperations < 0 || maxQueuedOperations > 1024\n || !Number.isSafeInteger(maxOperationMilliseconds) || maxOperationMilliseconds <= 0 || maxOperationMilliseconds > 2_147_483_647)\n throw new AccountCustodyClientError('invalid-limits')\n return Object.freeze({ maxQueuedOperations, maxOperationMilliseconds })\n}\n\n/** Resident owner with no restoration/remint. Shares legacy's permanent account reservation. */\nexport function createInRealmAccountCustodyClientOwner(options: InRealmAccountCustodyClientOwnerOptions): AccountCustodyClientOwner {\n const limits = finiteLimits(options.limits)\n const account = options.account\n const address = account.address\n if (!reserveInRealmAccount(address)) throw new AccountCustodyClientError('account-reserved')\n const state: ClientOwnerState = {\n account, address, limits, stopped: options.nativeState !== 'established-live', executions: new Set(), tail: Promise.resolve(),\n }\n const owner: AccountCustodyClientOwner = Object.freeze({\n address,\n limits,\n assurance: scopedClientAssurance,\n get outstandingOperations() { return state.executions.size },\n get status() { return state.stopped ? 'stopped' : state.executions.size > 0 ? 'running' : 'ready' },\n drain: async () => { await state.tail },\n stop: () => { stopClientOwner(state) },\n })\n owners.set(owner, state)\n return owner\n}\n\nexport function getClientOwnerState(owner: AccountCustodyClientOwner): ClientOwnerState {\n const state = owners.get(owner)\n if (state === undefined) throw new AccountCustodyClientError('unissued-owner')\n return state\n}\n", "import {\n afterClientQueue, observeClientExecution, settleClientExecution,\n} from './clientExecution.ts'\nimport type { AccountCustodyClient, AccountCustodyClientOptions } from './clientModel.ts'\nimport { getClientOwnerState, scopedClientAssurance } from './clientOwner.ts'\nimport { clientSignalAborted } from './clientSignals.ts'\nimport {\n AccountCustodyClientError, assertClientOwnerReady, type ClientExecution, type ClientOwnerState, type ClientState, settleClientTail,\n} from './clientState.ts'\nimport type { AccountCustodyExecuteOptions } from './model.ts'\n\nfunction captureSignal(options: AccountCustodyExecuteOptions): AbortSignal | undefined {\n try {\n const signal = options.signal\n if (signal !== undefined) clientSignalAborted(signal)\n return signal\n } catch {\n throw new AccountCustodyClientError('invalid-request')\n }\n}\n\nfunction claimClient(owner: ClientOwnerState): ClientState {\n assertClientOwnerReady(owner)\n if (owner.current !== undefined && !owner.current.closed) throw new AccountCustodyClientError('client-active')\n if (owner.executions.size > 0 || (owner.current?.executions.size ?? 0) > 0) throw new AccountCustodyClientError('client-not-drained')\n const client: ClientState = {\n closed: false, executions: new Set(), tail: Promise.resolve(),\n }\n owner.current = client\n return client\n}\n\nfunction closeClient(client: ClientState): void {\n client.closed = true\n for (const execution of client.executions) {\n if (!execution.hasStarted) execution.controller.abort()\n }\n}\n\nasync function execute<Request, Result>(\n owner: ClientOwnerState,\n client: ClientState,\n options: AccountCustodyClientOptions<Request, Result>,\n request: Request,\n executeOptions: AccountCustodyExecuteOptions,\n): Promise<Result> {\n if (client.closed) throw new AccountCustodyClientError('stopped')\n assertClientOwnerReady(owner)\n if (owner.executions.size >= owner.limits.maxQueuedOperations + 1) throw new AccountCustodyClientError('capacity-exhausted')\n const signal = captureSignal(executeOptions)\n if (signal !== undefined && clientSignalAborted(signal)) throw new AccountCustodyClientError('cancelled-before-operation')\n let original: Request\n try {\n original = structuredClone(options.snapshot(request))\n } catch {\n throw new AccountCustodyClientError('invalid-request')\n }\n // Snapshot/getters may reenter public lifecycle methods; recheck actual admission.\n if (client.closed || owner.current !== client) throw new AccountCustodyClientError('stopped')\n assertClientOwnerReady(owner)\n if (owner.executions.size >= owner.limits.maxQueuedOperations + 1) throw new AccountCustodyClientError('capacity-exhausted')\n const execution: ClientExecution = {\n controller: new AbortController(), hasCompleted: false, hasStarted: false,\n }\n const observer = observeClientExecution<Result>(owner, execution, signal)\n owner.executions.add(execution)\n client.executions.add(execution)\n const pending = afterClientQueue(owner.tail, owner, client, options, execution, original)\n owner.tail = client.tail = settleClientTail(pending)\n void settleClientExecution(pending, observer)\n return await observer.result\n}\n\n/** Trusted issuer creates a single fenced client; clean close preserves its resident owner. */\nexport function createAccountCustodyClient<Request, Result>(input: AccountCustodyClientOptions<Request, Result>): AccountCustodyClient<Request, Result> {\n const ownerRef = input.owner\n const owner = getClientOwnerState(ownerRef)\n const bindingRef = input.binding\n const binding = Object.freeze({ address: bindingRef.address, domain: bindingRef.domain })\n if (binding.address !== owner.address || typeof binding.domain !== 'string' || binding.domain.length === 0)\n throw new AccountCustodyClientError('binding-mismatch')\n const options = Object.freeze({\n owner: ownerRef, binding, snapshot: input.snapshot, createOperation: input.createOperation,\n })\n if (typeof options.snapshot !== 'function' || typeof options.createOperation !== 'function') throw new AccountCustodyClientError('invalid-request')\n const client = claimClient(owner)\n return Object.freeze({\n binding,\n assurance: scopedClientAssurance,\n get outstandingOperations() { return client.executions.size },\n get status() { return client.closed || owner.stopped ? 'stopped' : client.executions.size > 0 ? 'running' : 'ready' },\n execute: async (request: Request, executeOptions: AccountCustodyExecuteOptions = {}) => await execute(owner, client, options, request, executeOptions),\n stop: () => { closeClient(client) },\n drain: async () => { await client.tail },\n })\n}\n"],
5
+ "mappings": ";AAGO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EACpC;AAAA,EACA,OAAO;AAAA,EAEhB,YAAY,MAA+B;AACzC,UAAM,oBAAoB,IAAI,EAAE;AAChC,SAAK,OAAO;AAAA,EACd;AACF;;;ACJA,SAAS,gBAA+B;AACtC,QAAM,MAAM,uBAAO,IAAI,6CAA6C;AACpE,QAAM,WAAoB,QAAQ,IAAI,YAAY,GAAG;AACrD,MAAI,aAAa,QAAW;AAC1B,UAAM,eA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O,SAAS,2BAA4C,OAA4F;AACtJ,QAAM,WAAW,MAAM;AACvB,QAAM,QAAQ,oBAAoB,QAAQ;AAC1C,QAAM,aAAa,MAAM;AACzB,QAAM,UAAU,OAAO,OAAO,EAAE,SAAS,WAAW,SAAS,QAAQ,WAAW,OAAO,CAAC;AACxF,MAAI,QAAQ,YAAY,MAAM,WAAW,OAAO,QAAQ,WAAW,YAAY,QAAQ,OAAO,WAAW;AACvG,UAAM,IAAI,0BAA0B,kBAAkB;AACxD,QAAM,UAAU,OAAO,OAAO;AAAA,IAC5B,OAAO;AAAA,IAAU;AAAA,IAAS,UAAU,MAAM;AAAA,IAAU,iBAAiB,MAAM;AAAA,EAC7E,CAAC;AACD,MAAI,OAAO,QAAQ,aAAa,cAAc,OAAO,QAAQ,oBAAoB,WAAY,OAAM,IAAI,0BAA0B,iBAAiB;AAClJ,QAAM,SAAS,YAAY,KAAK;AAChC,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,WAAW;AAAA,IACX,IAAI,wBAAwB;AAAE,aAAO,OAAO,WAAW;AAAA,IAAK;AAAA,IAC5D,IAAI,SAAS;AAAE,aAAO,OAAO,UAAU,MAAM,UAAU,YAAY,OAAO,WAAW,OAAO,IAAI,YAAY;AAAA,IAAQ;AAAA,IACpH,SAAS,OAAO,SAAkB,iBAA+C,CAAC,MAAM,MAAM,QAAQ,OAAO,QAAQ,SAAS,SAAS,cAAc;AAAA,IACrJ,MAAM,MAAM;AAAE,kBAAY,MAAM;AAAA,IAAE;AAAA,IAClC,OAAO,YAAY;AAAE,YAAM,OAAO;AAAA,IAAK;AAAA,EACzC,CAAC;AACH;",
6
+ "names": ["registry", "key", "intrinsic", "nativeCall", "operationControl", "perform", "owners", "finiteLimits", "captureSignal"]
7
+ }
@@ -1,23 +1,12 @@
1
1
  // src/modules/address-payload-plugin/Plugin.ts
2
2
  import { createPayloadPlugin } from "@xyo-network/sdk-protocol";
3
- import { AddressSchema as AddressSchema2 } from "#module-model";
4
-
5
- // src/modules/address-payload-plugin/Template.ts
6
- import { ZERO_ADDRESS } from "@ariestools/sdk";
7
- import { AddressSchema } from "#module-model";
8
- var addressPayloadTemplate = () => ({
9
- address: ZERO_ADDRESS,
10
- schema: AddressSchema
11
- });
12
-
13
- // src/modules/address-payload-plugin/Plugin.ts
3
+ import { AddressPayloadZod, AddressSchema } from "#module-model";
14
4
  var AddressPayloadPlugin = () => createPayloadPlugin({
15
- schema: AddressSchema2,
16
- template: addressPayloadTemplate
5
+ schema: AddressSchema,
6
+ zod: AddressPayloadZod
17
7
  });
18
8
  export {
19
9
  AddressPayloadPlugin,
20
- addressPayloadTemplate,
21
10
  AddressPayloadPlugin as default
22
11
  };
23
12
  //# sourceMappingURL=address-payload-plugin.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/modules/address-payload-plugin/Plugin.ts", "../../src/modules/address-payload-plugin/Template.ts"],
4
- "sourcesContent": ["import type { PayloadPlugin } from '@xyo-network/sdk-protocol'\nimport { createPayloadPlugin } from '@xyo-network/sdk-protocol'\n\nimport type { AddressPayload } from '#module-model'\nimport { AddressSchema } from '#module-model'\n\nimport { addressPayloadTemplate } from './Template.ts'\n\nexport const AddressPayloadPlugin = (): PayloadPlugin<AddressPayload> =>\n createPayloadPlugin<AddressPayload>({\n schema: AddressSchema,\n template: addressPayloadTemplate,\n })\n", "import { ZERO_ADDRESS } from '@ariestools/sdk'\n\nimport type { AddressPayload } from '#module-model'\nimport { AddressSchema } from '#module-model'\n\nexport const addressPayloadTemplate = (): AddressPayload => ({\n address: ZERO_ADDRESS,\n schema: AddressSchema,\n})\n"],
5
- "mappings": ";AACA,SAAS,2BAA2B;AAGpC,SAAS,iBAAAA,sBAAqB;;;ACJ9B,SAAS,oBAAoB;AAG7B,SAAS,qBAAqB;AAEvB,IAAM,yBAAyB,OAAuB;AAAA,EAC3D,SAAS;AAAA,EACT,QAAQ;AACV;;;ADAO,IAAM,uBAAuB,MAClC,oBAAoC;AAAA,EAClC,QAAQC;AAAA,EACR,UAAU;AACZ,CAAC;",
6
- "names": ["AddressSchema", "AddressSchema"]
3
+ "sources": ["../../src/modules/address-payload-plugin/Plugin.ts"],
4
+ "sourcesContent": ["import type { PayloadPlugin } from '@xyo-network/sdk-protocol'\nimport { createPayloadPlugin } from '@xyo-network/sdk-protocol'\n\nimport type { AddressPayload } from '#module-model'\nimport { AddressPayloadZod, AddressSchema } from '#module-model'\n\nexport const AddressPayloadPlugin = (): PayloadPlugin<AddressPayload> =>\n createPayloadPlugin<AddressPayload>({\n schema: AddressSchema,\n zod: AddressPayloadZod,\n })\n"],
5
+ "mappings": ";AACA,SAAS,2BAA2B;AAGpC,SAAS,mBAAmB,qBAAqB;AAE1C,IAAM,uBAAuB,MAClC,oBAAoC;AAAA,EAClC,QAAQ;AAAA,EACR,KAAK;AACP,CAAC;",
6
+ "names": []
7
7
  }
@@ -131,8 +131,6 @@ import * as z6 from "zod/mini";
131
131
  import { DivinerConfigZod } from "#diviner-model";
132
132
  var RemoteDivinerConfigSchema = asSchema6("network.xyo.diviner.remote.config", true);
133
133
  var RemoteDivinerConfigZod = z6.extend(DivinerConfigZod, {
134
- /** @deprecated use in params instead */
135
- api: z6.optional(z6.custom()),
136
134
  archive: z6.optional(z6.string()),
137
135
  schema: z6.literal(RemoteDivinerConfigSchema)
138
136
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/modules/api-location-diviner/LocationDiviner/LocationDivinerApi.ts", "../../src/modules/api-location-diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.ts", "../../src/modules/api-location-diviner/LocationDiviner/Witnesses/CurrentLocationWitness.ts", "../../src/modules/api-location-diviner/LocationDiviner/Witnesses/LocationWitness.ts", "../../src/modules/api-location-diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.ts", "../../src/modules/api-location-diviner/LocationDiviner/Queries/LocationQuerySchema.ts", "../../src/modules/api-location-diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts", "../../src/modules/api-location-diviner/RemoteDivinerConfig.ts", "../../src/modules/api-location-diviner/RemoteDivinerError.ts"],
4
- "sourcesContent": ["import { assertEx, fetchJsonClient } from '@ariestools/sdk'\n\nimport type { GetLocationQueryResponse } from './models.ts'\nimport type { LocationQueryCreationResponse, SupportedLocationQueryCreationRequest } from './Queries/index.ts'\n\ninterface LocationDivinerApiConfig {\n apiDomain: string\n}\n\ninterface JsonDataEnvelope<T> {\n data?: T\n}\n\nclass LocationDivinerApi {\n config: LocationDivinerApiConfig\n constructor(config: LocationDivinerApiConfig) {\n this.config = config\n }\n\n async getLocationQuery(hash: string): Promise<GetLocationQueryResponse> {\n const response = await fetchJsonClient.get<JsonDataEnvelope<GetLocationQueryResponse>>(`${this.config.apiDomain}/location/query/${hash}`)\n return assertEx(response.data?.data, () => 'LocationDivinerApi.getLocationQuery: missing response data')\n }\n\n async postLocationQuery(request: SupportedLocationQueryCreationRequest): Promise<LocationQueryCreationResponse> {\n const response = await fetchJsonClient.post<JsonDataEnvelope<LocationQueryCreationResponse>>(`${this.config.apiDomain}/location/query`, { ...request })\n return assertEx(response.data?.data, () => 'LocationDivinerApi.postLocationQuery: missing response data')\n }\n}\n\nexport { LocationDivinerApi }\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationHeatmapQuerySchema: 'network.xyo.location.heatmap.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.query', true)\nexport type LocationHeatmapQuerySchema = typeof LocationHeatmapQuerySchema\n\nexport const LocationHeatmapAnswerSchema: 'network.xyo.location.heatmap.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.answer', true)\nexport type LocationHeatmapAnswerSchema = typeof LocationHeatmapAnswerSchema\n\nexport const LocationHeatmapQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationHeatmapQuery = z.infer<typeof LocationHeatmapQueryZod>\n\nexport const isLocationHeatmapQuery: ReturnType<typeof zodIsFactory<LocationHeatmapQuery>> = zodIsFactory(LocationHeatmapQueryZod)\nexport const asLocationHeatmapQuery: ReturnType<typeof zodAsFactory<LocationHeatmapQuery>> = zodAsFactory(LocationHeatmapQueryZod, 'asLocationHeatmapQuery')\nexport const toLocationHeatmapQuery: ReturnType<typeof zodToFactory<LocationHeatmapQuery>> = zodToFactory(LocationHeatmapQueryZod, 'toLocationHeatmapQuery')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nexport const CurrentLocationWitnessSchema: 'co.coinapp.currentlocationwitness' & {\n readonly __schema: true\n} = asSchema('co.coinapp.currentlocationwitness', true)\nexport type CurrentLocationWitnessSchema = typeof CurrentLocationWitnessSchema\n\nexport const CurrentLocationWitnessPayloadZod: z.ZodMiniObject<{\n altitudeMeters: z.ZodMiniNumber<number>\n directionDegrees: z.ZodMiniNumber<number>\n latitude: z.ZodMiniNumber<number>\n longitude: z.ZodMiniNumber<number>\n quadkey: z.ZodMiniString<string>\n schema: z.ZodMiniLiteral<CurrentLocationWitnessSchema>\n speedKph: z.ZodMiniNumber<number>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(CurrentLocationWitnessSchema), {\n altitudeMeters: z.number(),\n directionDegrees: z.number(),\n latitude: z.number(),\n longitude: z.number(),\n quadkey: z.string(),\n speedKph: z.number(),\n})\n\nexport type CurrentLocationWitnessPayload = z.infer<typeof CurrentLocationWitnessPayloadZod>\n\nexport const isCurrentLocationWitnessPayload: ReturnType<typeof zodIsFactory<CurrentLocationWitnessPayload>>\n = zodIsFactory(CurrentLocationWitnessPayloadZod)\nexport const asCurrentLocationWitnessPayload: ReturnType<typeof zodAsFactory<CurrentLocationWitnessPayload>>\n = zodAsFactory(CurrentLocationWitnessPayloadZod, 'asCurrentLocationWitnessPayload')\nexport const toCurrentLocationWitnessPayload: ReturnType<typeof zodToFactory<CurrentLocationWitnessPayload>>\n = zodToFactory(CurrentLocationWitnessPayloadZod, 'toCurrentLocationWitnessPayload')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nexport const LocationWitnessSchema: 'network.xyo.location' & {\n readonly __schema: true\n} = asSchema('network.xyo.location', true)\nexport type LocationWitnessSchema = typeof LocationWitnessSchema\n\nexport interface Coordinates {\n accuracy: number | null\n altitude: number | null\n altitudeAccuracy: number | null\n heading: number | null\n latitude: number\n longitude: number\n speed: number | null\n}\nexport interface CurrentLocation {\n coords: Coordinates\n timestamp: number\n}\n\nexport const LocationWitnessPayloadZod: z.ZodMiniObject<{\n currentLocation: z.ZodMiniCustom<CurrentLocation, CurrentLocation>\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(LocationWitnessSchema), { currentLocation: z.custom<CurrentLocation>() })\n\nexport type LocationWitnessPayload = z.infer<typeof LocationWitnessPayloadZod>\n\nexport const isLocationWitnessPayload: ReturnType<typeof zodIsFactory<LocationWitnessPayload>> = zodIsFactory(LocationWitnessPayloadZod)\nexport const asLocationWitnessPayload: ReturnType<typeof zodAsFactory<LocationWitnessPayload>> = zodAsFactory(LocationWitnessPayloadZod, 'asLocationWitnessPayload')\nexport const toLocationWitnessPayload: ReturnType<typeof zodToFactory<LocationWitnessPayload>> = zodToFactory(LocationWitnessPayloadZod, 'toLocationWitnessPayload')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationQuadkeyHeatmapQuerySchema: 'network.xyo.location.heatmap.quadkey.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.quadkey.query', true)\nexport type LocationQuadkeyHeatmapQuerySchema = typeof LocationQuadkeyHeatmapQuerySchema\n\nexport const LocationQuadkeyHeatmapAnswerSchema: 'network.xyo.location.heatmap.quadkey.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.quadkey.answer', true)\nexport type LocationQuadkeyHeatmapAnswerSchema = typeof LocationQuadkeyHeatmapAnswerSchema\n\nexport const LocationQuadkeyHeatmapQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationQuadkeyHeatmapQuery = z.infer<typeof LocationQuadkeyHeatmapQueryZod>\n\nexport const isLocationQuadkeyHeatmapQuery: ReturnType<typeof zodIsFactory<LocationQuadkeyHeatmapQuery>>\n = zodIsFactory(LocationQuadkeyHeatmapQueryZod)\nexport const asLocationQuadkeyHeatmapQuery: ReturnType<typeof zodAsFactory<LocationQuadkeyHeatmapQuery>>\n = zodAsFactory(LocationQuadkeyHeatmapQueryZod, 'asLocationQuadkeyHeatmapQuery')\nexport const toLocationQuadkeyHeatmapQuery: ReturnType<typeof zodToFactory<LocationQuadkeyHeatmapQuery>>\n = zodToFactory(LocationQuadkeyHeatmapQueryZod, 'toLocationQuadkeyHeatmapQuery')\n", "import type { Schema } from '@xyo-network/sdk-protocol'\n\nimport type { LocationHeatmapQuerySchema } from './LocationHeatmapQuery/index.ts'\nimport type { LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery/index.ts'\nimport type { LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery/index.ts'\n\nexport type LocationQuerySchema = LocationQuadkeyHeatmapQuerySchema | LocationHeatmapQuerySchema | LocationTimeRangeQuerySchema\n\nconst locationQuerySchemas: Record<string, true> = {\n 'network.xyo.location.heatmap.quadkey.query': true,\n 'network.xyo.location.heatmap.query': true,\n 'network.xyo.location.range.query': true,\n}\n\nexport const isSupportedLocationQuerySchema = (schema: Schema): schema is LocationQuerySchema => {\n return locationQuerySchemas[schema as LocationQuerySchema]\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationTimeRangeQuerySchema: 'network.xyo.location.range.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.range.query', true)\nexport type LocationTimeRangeQuerySchema = typeof LocationTimeRangeQuerySchema\n\nexport const LocationTimeRangeAnswerSchema: 'network.xyo.location.range.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.range.answer', true)\nexport type LocationTimeRangeAnswerSchema = typeof LocationTimeRangeAnswerSchema\n\nexport const LocationTimeRangeQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n // TODO: Bounding rectangle, etc.\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationTimeRangeQuery = z.infer<typeof LocationTimeRangeQueryZod>\n\nexport const isLocationTimeRangeQuery: ReturnType<typeof zodIsFactory<LocationTimeRangeQuery>> = zodIsFactory(LocationTimeRangeQueryZod)\nexport const asLocationTimeRangeQuery: ReturnType<typeof zodAsFactory<LocationTimeRangeQuery>> = zodAsFactory(LocationTimeRangeQueryZod, 'asLocationTimeRangeQuery')\nexport const toLocationTimeRangeQuery: ReturnType<typeof zodToFactory<LocationTimeRangeQuery>> = zodToFactory(LocationTimeRangeQueryZod, 'toLocationTimeRangeQuery')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { DivinerConfigZod } from '#diviner-model'\n\nexport const RemoteDivinerConfigSchema: 'network.xyo.diviner.remote.config' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.remote.config', true)\nexport type RemoteDivinerConfigSchema = typeof RemoteDivinerConfigSchema\n\nexport const RemoteDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n /** @deprecated use in params instead */\n api: z.ZodMiniOptional<z.ZodMiniCustom<object, object>>\n archive: z.ZodMiniOptional<z.ZodMiniString<string>>\n schema: z.ZodMiniLiteral<RemoteDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n /** @deprecated use in params instead */\n api: z.optional(z.custom<object>()),\n archive: z.optional(z.string()),\n schema: z.literal(RemoteDivinerConfigSchema),\n})\n\nexport type RemoteDivinerConfig = z.infer<typeof RemoteDivinerConfigZod>\n\nexport const isRemoteDivinerConfig: ReturnType<typeof zodIsFactory<RemoteDivinerConfig>> = zodIsFactory(RemoteDivinerConfigZod)\nexport const asRemoteDivinerConfig: ReturnType<typeof zodAsFactory<RemoteDivinerConfig>> = zodAsFactory(RemoteDivinerConfigZod, 'asRemoteDivinerConfig')\nexport const toRemoteDivinerConfig: ReturnType<typeof zodToFactory<RemoteDivinerConfig>> = zodToFactory(RemoteDivinerConfigZod, 'toRemoteDivinerConfig')\n", "import { isString } from '@ariestools/sdk'\n\nexport class RemoteDivinerError extends Error {\n isRemoteDivinerError = true\n constructor(action: string, error: Error['cause'], message?: string) {\n const messageString = isString(message) ? ` (${message})` : ''\n super(`Remote Diviner [${action}] failed${messageString}`, { cause: error })\n }\n\n static isRemoteDivinerError(error: unknown): RemoteDivinerError | undefined {\n return (error as RemoteDivinerError).isRemoteDivinerError ? (error as RemoteDivinerError) : undefined\n }\n}\n"],
5
- "mappings": ";AAAA,SAAS,UAAU,uBAAuB;AAa1C,IAAM,qBAAN,MAAyB;AAAA,EACvB;AAAA,EACA,YAAY,QAAkC;AAC5C,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,MAAM,iBAAiB,MAAiD;AACtE,UAAM,WAAW,MAAM,gBAAgB,IAAgD,GAAG,KAAK,OAAO,SAAS,mBAAmB,IAAI,EAAE;AACxI,WAAO,SAAS,SAAS,MAAM,MAAM,MAAM,4DAA4D;AAAA,EACzG;AAAA,EAEA,MAAM,kBAAkB,SAAwF;AAC9G,UAAM,WAAW,MAAM,gBAAgB,KAAsD,GAAG,KAAK,OAAO,SAAS,mBAAmB,EAAE,GAAG,QAAQ,CAAC;AACtJ,WAAO,SAAS,SAAS,MAAM,MAAM,MAAM,6DAA6D;AAAA,EAC1G;AACF;;;AC5BA;AAAA,EACE,gBAAAA;AAAA,EAAc,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,OACvB;AACP,SAAS,YAAAC,iBAAgB;AACzB,YAAYC,QAAO;;;ACJnB;AAAA,EACE;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AACP,SAAS,UAAU,0BAA0B;AAC7C,YAAY,OAAO;AAEZ,IAAM,+BAET,SAAS,qCAAqC,IAAI;AAG/C,IAAM,mCAQS,SAAO,mBAAmB,4BAA4B,GAAG;AAAA,EAC7E,gBAAkB,SAAO;AAAA,EACzB,kBAAoB,SAAO;AAAA,EAC3B,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A8EF,cAAa,sBAAsB;AACvH,IAAM,wBAA8ED,cAAa,wBAAwB,uBAAuB;AAChJ,IAAM,wBAA8EE,cAAa,wBAAwB,uBAAuB;;;AChCvJ,SAAS,gBAAgB;AAElB,IAAM,qBAAN,cAAiC,MAAM;AAAA,EAC5C,uBAAuB;AAAA,EACvB,YAAY,QAAgB,OAAuB,SAAkB;AACnE,UAAM,gBAAgB,SAAS,OAAO,IAAI,KAAK,OAAO,MAAM;AAC5D,UAAM,mBAAmB,MAAM,WAAW,aAAa,IAAI,EAAE,OAAO,MAAM,CAAC;AAAA,EAC7E;AAAA,EAEA,OAAO,qBAAqB,OAAgD;AAC1E,WAAQ,MAA6B,uBAAwB,QAA+B;AAAA,EAC9F;AACF;",
4
+ "sourcesContent": ["import { assertEx, fetchJsonClient } from '@ariestools/sdk'\n\nimport type { GetLocationQueryResponse } from './models.ts'\nimport type { LocationQueryCreationResponse, SupportedLocationQueryCreationRequest } from './Queries/index.ts'\n\ninterface LocationDivinerApiConfig {\n apiDomain: string\n}\n\ninterface JsonDataEnvelope<T> {\n data?: T\n}\n\nclass LocationDivinerApi {\n config: LocationDivinerApiConfig\n constructor(config: LocationDivinerApiConfig) {\n this.config = config\n }\n\n async getLocationQuery(hash: string): Promise<GetLocationQueryResponse> {\n const response = await fetchJsonClient.get<JsonDataEnvelope<GetLocationQueryResponse>>(`${this.config.apiDomain}/location/query/${hash}`)\n return assertEx(response.data?.data, () => 'LocationDivinerApi.getLocationQuery: missing response data')\n }\n\n async postLocationQuery(request: SupportedLocationQueryCreationRequest): Promise<LocationQueryCreationResponse> {\n const response = await fetchJsonClient.post<JsonDataEnvelope<LocationQueryCreationResponse>>(`${this.config.apiDomain}/location/query`, { ...request })\n return assertEx(response.data?.data, () => 'LocationDivinerApi.postLocationQuery: missing response data')\n }\n}\n\nexport { LocationDivinerApi }\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationHeatmapQuerySchema: 'network.xyo.location.heatmap.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.query', true)\nexport type LocationHeatmapQuerySchema = typeof LocationHeatmapQuerySchema\n\nexport const LocationHeatmapAnswerSchema: 'network.xyo.location.heatmap.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.answer', true)\nexport type LocationHeatmapAnswerSchema = typeof LocationHeatmapAnswerSchema\n\nexport const LocationHeatmapQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationHeatmapQuery = z.infer<typeof LocationHeatmapQueryZod>\n\nexport const isLocationHeatmapQuery: ReturnType<typeof zodIsFactory<LocationHeatmapQuery>> = zodIsFactory(LocationHeatmapQueryZod)\nexport const asLocationHeatmapQuery: ReturnType<typeof zodAsFactory<LocationHeatmapQuery>> = zodAsFactory(LocationHeatmapQueryZod, 'asLocationHeatmapQuery')\nexport const toLocationHeatmapQuery: ReturnType<typeof zodToFactory<LocationHeatmapQuery>> = zodToFactory(LocationHeatmapQueryZod, 'toLocationHeatmapQuery')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nexport const CurrentLocationWitnessSchema: 'co.coinapp.currentlocationwitness' & {\n readonly __schema: true\n} = asSchema('co.coinapp.currentlocationwitness', true)\nexport type CurrentLocationWitnessSchema = typeof CurrentLocationWitnessSchema\n\nexport const CurrentLocationWitnessPayloadZod: z.ZodMiniObject<{\n altitudeMeters: z.ZodMiniNumber<number>\n directionDegrees: z.ZodMiniNumber<number>\n latitude: z.ZodMiniNumber<number>\n longitude: z.ZodMiniNumber<number>\n quadkey: z.ZodMiniString<string>\n schema: z.ZodMiniLiteral<CurrentLocationWitnessSchema>\n speedKph: z.ZodMiniNumber<number>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(CurrentLocationWitnessSchema), {\n altitudeMeters: z.number(),\n directionDegrees: z.number(),\n latitude: z.number(),\n longitude: z.number(),\n quadkey: z.string(),\n speedKph: z.number(),\n})\n\nexport type CurrentLocationWitnessPayload = z.infer<typeof CurrentLocationWitnessPayloadZod>\n\nexport const isCurrentLocationWitnessPayload: ReturnType<typeof zodIsFactory<CurrentLocationWitnessPayload>>\n = zodIsFactory(CurrentLocationWitnessPayloadZod)\nexport const asCurrentLocationWitnessPayload: ReturnType<typeof zodAsFactory<CurrentLocationWitnessPayload>>\n = zodAsFactory(CurrentLocationWitnessPayloadZod, 'asCurrentLocationWitnessPayload')\nexport const toCurrentLocationWitnessPayload: ReturnType<typeof zodToFactory<CurrentLocationWitnessPayload>>\n = zodToFactory(CurrentLocationWitnessPayloadZod, 'toCurrentLocationWitnessPayload')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nexport const LocationWitnessSchema: 'network.xyo.location' & {\n readonly __schema: true\n} = asSchema('network.xyo.location', true)\nexport type LocationWitnessSchema = typeof LocationWitnessSchema\n\nexport interface Coordinates {\n accuracy: number | null\n altitude: number | null\n altitudeAccuracy: number | null\n heading: number | null\n latitude: number\n longitude: number\n speed: number | null\n}\nexport interface CurrentLocation {\n coords: Coordinates\n timestamp: number\n}\n\nexport const LocationWitnessPayloadZod: z.ZodMiniObject<{\n currentLocation: z.ZodMiniCustom<CurrentLocation, CurrentLocation>\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(LocationWitnessSchema), { currentLocation: z.custom<CurrentLocation>() })\n\nexport type LocationWitnessPayload = z.infer<typeof LocationWitnessPayloadZod>\n\nexport const isLocationWitnessPayload: ReturnType<typeof zodIsFactory<LocationWitnessPayload>> = zodIsFactory(LocationWitnessPayloadZod)\nexport const asLocationWitnessPayload: ReturnType<typeof zodAsFactory<LocationWitnessPayload>> = zodAsFactory(LocationWitnessPayloadZod, 'asLocationWitnessPayload')\nexport const toLocationWitnessPayload: ReturnType<typeof zodToFactory<LocationWitnessPayload>> = zodToFactory(LocationWitnessPayloadZod, 'toLocationWitnessPayload')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationQuadkeyHeatmapQuerySchema: 'network.xyo.location.heatmap.quadkey.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.quadkey.query', true)\nexport type LocationQuadkeyHeatmapQuerySchema = typeof LocationQuadkeyHeatmapQuerySchema\n\nexport const LocationQuadkeyHeatmapAnswerSchema: 'network.xyo.location.heatmap.quadkey.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.quadkey.answer', true)\nexport type LocationQuadkeyHeatmapAnswerSchema = typeof LocationQuadkeyHeatmapAnswerSchema\n\nexport const LocationQuadkeyHeatmapQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationQuadkeyHeatmapQuery = z.infer<typeof LocationQuadkeyHeatmapQueryZod>\n\nexport const isLocationQuadkeyHeatmapQuery: ReturnType<typeof zodIsFactory<LocationQuadkeyHeatmapQuery>>\n = zodIsFactory(LocationQuadkeyHeatmapQueryZod)\nexport const asLocationQuadkeyHeatmapQuery: ReturnType<typeof zodAsFactory<LocationQuadkeyHeatmapQuery>>\n = zodAsFactory(LocationQuadkeyHeatmapQueryZod, 'asLocationQuadkeyHeatmapQuery')\nexport const toLocationQuadkeyHeatmapQuery: ReturnType<typeof zodToFactory<LocationQuadkeyHeatmapQuery>>\n = zodToFactory(LocationQuadkeyHeatmapQueryZod, 'toLocationQuadkeyHeatmapQuery')\n", "import type { Schema } from '@xyo-network/sdk-protocol'\n\nimport type { LocationHeatmapQuerySchema } from './LocationHeatmapQuery/index.ts'\nimport type { LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery/index.ts'\nimport type { LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery/index.ts'\n\nexport type LocationQuerySchema = LocationQuadkeyHeatmapQuerySchema | LocationHeatmapQuerySchema | LocationTimeRangeQuerySchema\n\nconst locationQuerySchemas: Record<string, true> = {\n 'network.xyo.location.heatmap.quadkey.query': true,\n 'network.xyo.location.heatmap.query': true,\n 'network.xyo.location.range.query': true,\n}\n\nexport const isSupportedLocationQuerySchema = (schema: Schema): schema is LocationQuerySchema => {\n return locationQuerySchemas[schema as LocationQuerySchema]\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationTimeRangeQuerySchema: 'network.xyo.location.range.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.range.query', true)\nexport type LocationTimeRangeQuerySchema = typeof LocationTimeRangeQuerySchema\n\nexport const LocationTimeRangeAnswerSchema: 'network.xyo.location.range.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.range.answer', true)\nexport type LocationTimeRangeAnswerSchema = typeof LocationTimeRangeAnswerSchema\n\nexport const LocationTimeRangeQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n // TODO: Bounding rectangle, etc.\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationTimeRangeQuery = z.infer<typeof LocationTimeRangeQueryZod>\n\nexport const isLocationTimeRangeQuery: ReturnType<typeof zodIsFactory<LocationTimeRangeQuery>> = zodIsFactory(LocationTimeRangeQueryZod)\nexport const asLocationTimeRangeQuery: ReturnType<typeof zodAsFactory<LocationTimeRangeQuery>> = zodAsFactory(LocationTimeRangeQueryZod, 'asLocationTimeRangeQuery')\nexport const toLocationTimeRangeQuery: ReturnType<typeof zodToFactory<LocationTimeRangeQuery>> = zodToFactory(LocationTimeRangeQueryZod, 'toLocationTimeRangeQuery')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { DivinerConfigZod } from '#diviner-model'\n\nexport const RemoteDivinerConfigSchema: 'network.xyo.diviner.remote.config' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.remote.config', true)\nexport type RemoteDivinerConfigSchema = typeof RemoteDivinerConfigSchema\n\nexport const RemoteDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n archive: z.ZodMiniOptional<z.ZodMiniString<string>>\n schema: z.ZodMiniLiteral<RemoteDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n archive: z.optional(z.string()),\n schema: z.literal(RemoteDivinerConfigSchema),\n})\n\nexport type RemoteDivinerConfig = z.infer<typeof RemoteDivinerConfigZod>\n\nexport const isRemoteDivinerConfig: ReturnType<typeof zodIsFactory<RemoteDivinerConfig>> = zodIsFactory(RemoteDivinerConfigZod)\nexport const asRemoteDivinerConfig: ReturnType<typeof zodAsFactory<RemoteDivinerConfig>> = zodAsFactory(RemoteDivinerConfigZod, 'asRemoteDivinerConfig')\nexport const toRemoteDivinerConfig: ReturnType<typeof zodToFactory<RemoteDivinerConfig>> = zodToFactory(RemoteDivinerConfigZod, 'toRemoteDivinerConfig')\n", "import { isString } from '@ariestools/sdk'\n\nexport class RemoteDivinerError extends Error {\n isRemoteDivinerError = true\n constructor(action: string, error: Error['cause'], message?: string) {\n const messageString = isString(message) ? ` (${message})` : ''\n super(`Remote Diviner [${action}] failed${messageString}`, { cause: error })\n }\n\n static isRemoteDivinerError(error: unknown): RemoteDivinerError | undefined {\n return (error as RemoteDivinerError).isRemoteDivinerError ? (error as RemoteDivinerError) : undefined\n }\n}\n"],
5
+ "mappings": ";AAAA,SAAS,UAAU,uBAAuB;AAa1C,IAAM,qBAAN,MAAyB;AAAA,EACvB;AAAA,EACA,YAAY,QAAkC;AAC5C,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,MAAM,iBAAiB,MAAiD;AACtE,UAAM,WAAW,MAAM,gBAAgB,IAAgD,GAAG,KAAK,OAAO,SAAS,mBAAmB,IAAI,EAAE;AACxI,WAAO,SAAS,SAAS,MAAM,MAAM,MAAM,4DAA4D;AAAA,EACzG;AAAA,EAEA,MAAM,kBAAkB,SAAwF;AAC9G,UAAM,WAAW,MAAM,gBAAgB,KAAsD,GAAG,KAAK,OAAO,SAAS,mBAAmB,EAAE,GAAG,QAAQ,CAAC;AACtJ,WAAO,SAAS,SAAS,MAAM,MAAM,MAAM,6DAA6D;AAAA,EAC1G;AACF;;;AC5BA;AAAA,EACE,gBAAAA;AAAA,EAAc,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,OACvB;AACP,SAAS,YAAAC,iBAAgB;AACzB,YAAYC,QAAO;;;ACJnB;AAAA,EACE;AAAA,EAAc;AAAA,EAAc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B,IAAM,4BAETD,UAAS,qCAAqC,IAAI;AAG/C,IAAM,yBAMP,UAAO,kBAAkB;AAAA,EAC7B,SAAW,YAAW,UAAO,CAAC;AAAA,EAC9B,QAAU,WAAQ,yBAAyB;AAC7C,CAAC;AAIM,IAAM,wBAA8EF,cAAa,sBAAsB;AACvH,IAAM,wBAA8ED,cAAa,wBAAwB,uBAAuB;AAChJ,IAAM,wBAA8EE,cAAa,wBAAwB,uBAAuB;;;AC5BvJ,SAAS,gBAAgB;AAElB,IAAM,qBAAN,cAAiC,MAAM;AAAA,EAC5C,uBAAuB;AAAA,EACvB,YAAY,QAAgB,OAAuB,SAAkB;AACnE,UAAM,gBAAgB,SAAS,OAAO,IAAI,KAAK,OAAO,MAAM;AAC5D,UAAM,mBAAmB,MAAM,WAAW,aAAa,IAAI,EAAE,OAAO,MAAM,CAAC;AAAA,EAC7E;AAAA,EAEA,OAAO,qBAAqB,OAAgD;AAC1E,WAAQ,MAA6B,uBAAwB,QAA+B;AAAA,EAC9F;AACF;",
6
6
  "names": ["zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "PayloadZodOfSchema", "z", "asSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z", "asSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z", "asSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z"]
7
7
  }
@@ -87,10 +87,7 @@ var MemoryDriver = class extends AbstractCreatable {
87
87
  }
88
88
  static findIndexFromCursor(payloads, cursor) {
89
89
  const index = payloads.findIndex(({ _sequence }) => _sequence === cursor);
90
- if (index === -1) {
91
- return Infinity;
92
- }
93
- return index;
90
+ return index === -1 ? Infinity : index;
94
91
  }
95
92
  all() {
96
93
  return [...this.sortedValues];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/modules/archivist-memory/Archivist.ts", "../../src/modules/archivist-memory/Config.ts", "../../src/modules/archivist-memory/MemoryDriver.ts"],
4
- "sourcesContent": ["import type { Schema } from '@xyo-network/sdk-protocol'\n\nimport { StorageClassLabel } from '#archivist-abstract'\nimport type { GenericArchivistParams } from '#archivist-generic'\nimport { GenericArchivist } from '#archivist-generic'\nimport type {\n ArchivistModuleEventData,\n AttachableArchivistInstance,\n} from '#archivist-model'\nimport {\n ArchivistAllQuerySchema,\n ArchivistClearQuerySchema,\n ArchivistCommitQuerySchema,\n ArchivistDeleteQuerySchema,\n ArchivistInsertQuerySchema,\n ArchivistNextQuerySchema,\n} from '#archivist-model'\nimport type {\n AnyConfigSchema, AttachableModuleInstance, ModuleInstance,\n} from '#module-model'\nimport { creatableModule } from '#module-model'\n\nimport type { MemoryArchivistConfig } from './Config.ts'\nimport { MemoryArchivistConfigSchema } from './Config.ts'\nimport { MemoryDriver } from './MemoryDriver.ts'\n\nexport type MemoryArchivistParams<TConfig extends AnyConfigSchema<MemoryArchivistConfig> = AnyConfigSchema<MemoryArchivistConfig>>\n = GenericArchivistParams<TConfig>\n@creatableModule()\nexport class MemoryArchivist<\n TParams extends MemoryArchivistParams<AnyConfigSchema<MemoryArchivistConfig>> = MemoryArchivistParams,\n TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,\n>\n extends GenericArchivist<TParams, TEventData>\n implements AttachableArchivistInstance, ModuleInstance {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, MemoryArchivistConfigSchema]\n static override readonly defaultConfigSchema: Schema = MemoryArchivistConfigSchema\n static override readonly labels: {\n 'network.xyo.storage.class': string\n } = { ...super.labels, [StorageClassLabel]: 'memory' }\n\n override get queries(): Schema[] {\n return [\n ArchivistAllQuerySchema,\n ArchivistDeleteQuerySchema,\n ArchivistClearQuerySchema,\n ArchivistInsertQuerySchema,\n ArchivistCommitQuerySchema,\n ArchivistNextQuerySchema,\n ...super.queries,\n ]\n }\n\n static override async paramsHandler<T extends AttachableModuleInstance<MemoryArchivistParams, ArchivistModuleEventData>>(\n inParams?: Partial<T['params']>,\n ): Promise<T['params']> {\n const superParams = await super.paramsHandler(inParams)\n return { ...superParams, driver: superParams.driver ?? await MemoryDriver.create(superParams) }\n }\n}\n", "import type { EmptyObject, WithAdditional } from '@ariestools/sdk'\nimport {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport {\n asSchema, type Payload, type Schema,\n} from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { ArchivistConfig } from '#archivist-model'\nimport { ArchivistConfigZod } from '#archivist-model'\n\nexport const MemoryArchivistConfigSchema: 'network.xyo.archivist.memory.config' & {\n readonly __schema: true\n} = asSchema('network.xyo.archivist.memory.config', true)\nexport type MemoryArchivistConfigSchema = typeof MemoryArchivistConfigSchema\n\nexport const MemoryArchivistConfigZod: z.ZodMiniObject<\n & Omit<(typeof ArchivistConfigZod)['shape'], 'schema'>\n & {\n max: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n schema: z.ZodMiniLiteral<MemoryArchivistConfigSchema>\n },\n z.core.$strip\n> = z.extend(ArchivistConfigZod, {\n max: z.optional(z.number()),\n schema: z.literal(MemoryArchivistConfigSchema),\n})\n\nexport type MemoryArchivistConfigBase = z.infer<typeof MemoryArchivistConfigZod>\n\nexport const isMemoryArchivistConfig: ReturnType<typeof zodIsFactory<MemoryArchivistConfigBase>> = zodIsFactory(MemoryArchivistConfigZod)\nexport const asMemoryArchivistConfig: ReturnType<typeof zodAsFactory<MemoryArchivistConfigBase>> = zodAsFactory(MemoryArchivistConfigZod, 'asMemoryArchivistConfig')\nexport const toMemoryArchivistConfig: ReturnType<typeof zodToFactory<MemoryArchivistConfigBase>> = zodToFactory(MemoryArchivistConfigZod, 'toMemoryArchivistConfig')\n\nexport type MemoryArchivistConfig<TConfig extends Payload | EmptyObject | void = void, TSchema extends Schema | void = void> = ArchivistConfig<\n WithAdditional<\n {\n max?: number\n },\n TConfig\n >,\n TSchema extends Schema ? TSchema : MemoryArchivistConfigSchema | ArchivistConfig['schema']\n>\n", "import type {\n BrandedHash,\n CreatableParams, Hash, Hex, Promisable,\n} from '@ariestools/sdk'\nimport {\n AbstractCreatable, assertEx,\n creatable, exists,\n isDefined,\n} from '@ariestools/sdk'\nimport type { Payload, WithStorageMeta } from '@xyo-network/sdk-protocol'\nimport { PayloadBuilder } from '@xyo-network/sdk-protocol'\nimport { LRUCache } from 'lru-cache'\n\nimport type { ArchivistDriver, ArchivistNextOptions } from '#archivist-model'\n\nexport interface MemoryDriverConfig {\n max?: number\n}\n\nexport interface MemoryDriverParams extends CreatableParams {\n config: MemoryDriverConfig\n}\n\n@creatable()\nexport class MemoryDriver extends AbstractCreatable<MemoryDriverParams>\n implements ArchivistDriver<Hash, Payload, WithStorageMeta<Payload>> {\n private _cache?: LRUCache<Hash, WithStorageMeta<Payload>>\n private _config?: MemoryDriverConfig\n private _dataHashIndex?: LRUCache<Hash, Hash>\n private _sortedValues?: WithStorageMeta<Payload>[]\n\n protected get cache(): LRUCache<BrandedHash, WithStorageMeta<Payload>> {\n this._cache ??= new LRUCache<Hash, WithStorageMeta<Payload>>({\n max: this.max,\n dispose: () => { this._sortedValues = undefined },\n })\n return this._cache\n }\n\n protected get config(): MemoryDriverConfig {\n return assertEx(this._config, () => 'Driver config is not set')\n }\n\n protected get dataHashIndex(): LRUCache<BrandedHash, BrandedHash> {\n this._dataHashIndex ??= new LRUCache<Hash, Hash>({ max: this.max })\n return this._dataHashIndex\n }\n\n protected get max(): number {\n return this.config?.max ?? 10_000\n }\n\n protected get sortedValues(): WithStorageMeta<Payload>[] {\n this._sortedValues ??= this.cache.values().filter(exists).toArray().toSorted(PayloadBuilder.compareStorageMeta)\n return this._sortedValues\n }\n\n private static findIndexFromCursor(payloads: WithStorageMeta[], cursor: Hex) {\n const index = payloads.findIndex(({ _sequence }) => _sequence === cursor)\n if (index === -1) {\n return Infinity // move to the end\n }\n return index\n }\n\n all(): Promisable<WithStorageMeta<Payload>[]> {\n return [...this.sortedValues]\n }\n\n clear(): void {\n this.cache.clear()\n this._dataHashIndex = new LRUCache<Hash, Hash>({ max: this.max })\n this._sortedValues = undefined\n }\n\n count(): number {\n return this.cache.size\n }\n\n override createHandler(): Promisable<void> {\n this._config = this.params.config ?? {}\n }\n\n async delete(hashes: Hash[]): Promise<WithStorageMeta[]> {\n this._sortedValues = undefined\n const candidateDeletions = await Promise.all(this.cache\n .dump()\n .map(async ([key, item]) => {\n const itemValueDataHash = await PayloadBuilder.dataHash(item.value)\n if (!(hashes.includes(key) || hashes.includes(itemValueDataHash))) {\n return\n }\n\n this.cache.delete(key)\n return item.value\n }))\n const deletedPayloads: WithStorageMeta<Payload>[] = candidateDeletions\n .filter(exists)\n this.rebuildDataHashIndex()\n return deletedPayloads\n }\n\n get(hashes: Hash[]): Promisable<WithStorageMeta<Payload>[]> {\n return hashes.map((hash) => {\n const exact = this.cache.get(hash)\n if (exact) return exact\n const resolvedHash = this.dataHashIndex.get(hash) ?? hash\n const result = this.cache.get(resolvedHash)\n if (resolvedHash !== hash && !result) {\n throw new Error('Missing referenced payload')\n }\n return result\n }).filter(exists)\n }\n\n insert(payloads: WithStorageMeta<Payload>[]): WithStorageMeta<Payload>[] {\n this._sortedValues = undefined\n const payloadsWithMeta = payloads.toSorted(PayloadBuilder.compareStorageMeta)\n return payloadsWithMeta.map((payload) => {\n return this.insertPayloadIntoCache(payload)\n })\n }\n\n next(options?: ArchivistNextOptions): Promisable<WithStorageMeta<Payload>[]> {\n const {\n limit = 100, cursor, order, open = true,\n } = options ?? {}\n const all = order === 'desc' ? this.sortedValues.toReversed() : this.sortedValues\n const startIndex = isDefined(cursor)\n ? MemoryDriver.findIndexFromCursor(all, cursor) + (open ? 1 : 0)\n : 0\n return all.slice(startIndex, startIndex + limit)\n }\n\n private insertPayloadIntoCache(payload: WithStorageMeta<Payload>): WithStorageMeta<Payload> {\n this.cache.set(payload._hash, payload)\n this.dataHashIndex.set(payload._dataHash, payload._hash)\n return payload\n }\n\n private rebuildDataHashIndex() {\n this._dataHashIndex = new LRUCache<Hash, Hash>({ max: this.max })\n const payloads = this.cache.dump().map(([, item]) => item.value)\n for (const payload of payloads) {\n this.dataHashIndex.set(payload._dataHash, payload._hash)\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAEA,SAAS,yBAAyB;AAElC,SAAS,wBAAwB;AAKjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,SAAS,uBAAuB;;;ACnBhC;AAAA,EACE;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AACP;AAAA,EACE;AAAA,OACK;AACP,YAAY,OAAO;AAGnB,SAAS,0BAA0B;AAE5B,IAAM,8BAET,SAAS,uCAAuC,IAAI;AAGjD,IAAM,2BAOP,SAAO,oBAAoB;AAAA,EAC/B,KAAO,WAAW,SAAO,CAAC;AAAA,EAC1B,QAAU,UAAQ,2BAA2B;AAC/C,CAAC;AAIM,IAAM,0BAAsF,aAAa,wBAAwB;AACjI,IAAM,0BAAsF,aAAa,0BAA0B,yBAAyB;AAC5J,IAAM,0BAAsF,aAAa,0BAA0B,yBAAyB;;;AC7BnK;AAAA,EACE;AAAA,EAAmB;AAAA,EACnB;AAAA,EAAW;AAAA,EACX;AAAA,OACK;AAEP,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AAalB,IAAM,eAAN,cAA2B,kBACoC;AAAA,EAC5D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,IAAc,QAAyD;AACrE,SAAK,WAAW,IAAI,SAAyC;AAAA,MAC3D,KAAK,KAAK;AAAA,MACV,SAAS,MAAM;AAAE,aAAK,gBAAgB;AAAA,MAAU;AAAA,IAClD,CAAC;AACD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAc,SAA6B;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,KAAK,IAAI,CAAC;AAChE,UAAM,WAAW,KAAK,MAAM,KAAK,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,MAAM,KAAK,KAAK;AAC/D,eAAW,WAAW,UAAU;AAC9B,WAAK,cAAc,IAAI,QAAQ,WAAW,QAAQ,KAAK;AAAA,IACzD;AAAA,EACF;AACF;AA3Ha,eAAN;AAAA,EADN,UAAU;AAAA,GACE;;;AFKN,IAAM,kBAAN,cAIG,iBAC+C;AAAA,EAOvD,IAAa,UAAoB;AAC/B,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG,MAAM;AAAA,IACX;AAAA,EACF;AAAA,EAEA,aAAsB,cACpB,UACsB;AACtB,UAAM,cAAc,MAAM,MAAM,cAAc,QAAQ;AACtD,WAAO,EAAE,GAAG,aAAa,QAAQ,YAAY,UAAU,MAAM,aAAa,OAAO,WAAW,EAAE;AAAA,EAChG;AACF;AAxBE,cANW,iBAMc,iBAA0B,CAAC,GAAG,6CAAM,kBAAe,2BAA2B;AACvG,cAPW,iBAOc,uBAA8B;AACvD,cARW,iBAQc,UAErB,EAAE,GAAG,6CAAM,WAAQ,CAAC,iBAAiB,GAAG,SAAS;AAV1C,kBAAN;AAAA,EADN,gBAAgB;AAAA,GACJ;",
4
+ "sourcesContent": ["import type { Schema } from '@xyo-network/sdk-protocol'\n\nimport { StorageClassLabel } from '#archivist-abstract'\nimport type { GenericArchivistParams } from '#archivist-generic'\nimport { GenericArchivist } from '#archivist-generic'\nimport type {\n ArchivistModuleEventData,\n AttachableArchivistInstance,\n} from '#archivist-model'\nimport {\n ArchivistAllQuerySchema,\n ArchivistClearQuerySchema,\n ArchivistCommitQuerySchema,\n ArchivistDeleteQuerySchema,\n ArchivistInsertQuerySchema,\n ArchivistNextQuerySchema,\n} from '#archivist-model'\nimport type {\n AnyConfigSchema, AttachableModuleInstance, ModuleInstance,\n} from '#module-model'\nimport { creatableModule } from '#module-model'\n\nimport type { MemoryArchivistConfig } from './Config.ts'\nimport { MemoryArchivistConfigSchema } from './Config.ts'\nimport { MemoryDriver } from './MemoryDriver.ts'\n\nexport type MemoryArchivistParams<TConfig extends AnyConfigSchema<MemoryArchivistConfig> = AnyConfigSchema<MemoryArchivistConfig>>\n = GenericArchivistParams<TConfig>\n@creatableModule()\nexport class MemoryArchivist<\n TParams extends MemoryArchivistParams<AnyConfigSchema<MemoryArchivistConfig>> = MemoryArchivistParams,\n TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,\n>\n extends GenericArchivist<TParams, TEventData>\n implements AttachableArchivistInstance, ModuleInstance {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, MemoryArchivistConfigSchema]\n static override readonly defaultConfigSchema: Schema = MemoryArchivistConfigSchema\n static override readonly labels: {\n 'network.xyo.storage.class': string\n } = { ...super.labels, [StorageClassLabel]: 'memory' }\n\n override get queries(): Schema[] {\n return [\n ArchivistAllQuerySchema,\n ArchivistDeleteQuerySchema,\n ArchivistClearQuerySchema,\n ArchivistInsertQuerySchema,\n ArchivistCommitQuerySchema,\n ArchivistNextQuerySchema,\n ...super.queries,\n ]\n }\n\n static override async paramsHandler<T extends AttachableModuleInstance<MemoryArchivistParams, ArchivistModuleEventData>>(\n inParams?: Partial<T['params']>,\n ): Promise<T['params']> {\n const superParams = await super.paramsHandler(inParams)\n return { ...superParams, driver: superParams.driver ?? await MemoryDriver.create(superParams) }\n }\n}\n", "import type { EmptyObject, WithAdditional } from '@ariestools/sdk'\nimport {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport {\n asSchema, type Payload, type Schema,\n} from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { ArchivistConfig } from '#archivist-model'\nimport { ArchivistConfigZod } from '#archivist-model'\n\nexport const MemoryArchivistConfigSchema: 'network.xyo.archivist.memory.config' & {\n readonly __schema: true\n} = asSchema('network.xyo.archivist.memory.config', true)\nexport type MemoryArchivistConfigSchema = typeof MemoryArchivistConfigSchema\n\nexport const MemoryArchivistConfigZod: z.ZodMiniObject<\n & Omit<(typeof ArchivistConfigZod)['shape'], 'schema'>\n & {\n max: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n schema: z.ZodMiniLiteral<MemoryArchivistConfigSchema>\n },\n z.core.$strip\n> = z.extend(ArchivistConfigZod, {\n max: z.optional(z.number()),\n schema: z.literal(MemoryArchivistConfigSchema),\n})\n\nexport type MemoryArchivistConfigBase = z.infer<typeof MemoryArchivistConfigZod>\n\nexport const isMemoryArchivistConfig: ReturnType<typeof zodIsFactory<MemoryArchivistConfigBase>> = zodIsFactory(MemoryArchivistConfigZod)\nexport const asMemoryArchivistConfig: ReturnType<typeof zodAsFactory<MemoryArchivistConfigBase>> = zodAsFactory(MemoryArchivistConfigZod, 'asMemoryArchivistConfig')\nexport const toMemoryArchivistConfig: ReturnType<typeof zodToFactory<MemoryArchivistConfigBase>> = zodToFactory(MemoryArchivistConfigZod, 'toMemoryArchivistConfig')\n\nexport type MemoryArchivistConfig<TConfig extends Payload | EmptyObject | void = void, TSchema extends Schema | void = void> = ArchivistConfig<\n WithAdditional<\n {\n max?: number\n },\n TConfig\n >,\n TSchema extends Schema ? TSchema : MemoryArchivistConfigSchema | ArchivistConfig['schema']\n>\n", "import type {\n BrandedHash,\n CreatableParams, Hash, Hex, Promisable,\n} from '@ariestools/sdk'\nimport {\n AbstractCreatable, assertEx,\n creatable, exists,\n isDefined,\n} from '@ariestools/sdk'\nimport type { Payload, WithStorageMeta } from '@xyo-network/sdk-protocol'\nimport { PayloadBuilder } from '@xyo-network/sdk-protocol'\nimport { LRUCache } from 'lru-cache'\n\nimport type { ArchivistDriver, ArchivistNextOptions } from '#archivist-model'\n\nexport interface MemoryDriverConfig {\n max?: number\n}\n\nexport interface MemoryDriverParams extends CreatableParams {\n config: MemoryDriverConfig\n}\n\n@creatable()\nexport class MemoryDriver extends AbstractCreatable<MemoryDriverParams>\n implements ArchivistDriver<Hash, Payload, WithStorageMeta<Payload>> {\n private _cache?: LRUCache<Hash, WithStorageMeta<Payload>>\n private _config?: MemoryDriverConfig\n private _dataHashIndex?: LRUCache<Hash, Hash>\n private _sortedValues?: WithStorageMeta<Payload>[]\n\n protected get cache(): LRUCache<BrandedHash, WithStorageMeta<Payload>> {\n this._cache ??= new LRUCache<Hash, WithStorageMeta<Payload>>({\n max: this.max,\n dispose: () => { this._sortedValues = undefined },\n })\n return this._cache\n }\n\n protected get config(): MemoryDriverConfig {\n return assertEx(this._config, () => 'Driver config is not set')\n }\n\n protected get dataHashIndex(): LRUCache<BrandedHash, BrandedHash> {\n this._dataHashIndex ??= new LRUCache<Hash, Hash>({ max: this.max })\n return this._dataHashIndex\n }\n\n protected get max(): number {\n return this.config?.max ?? 10_000\n }\n\n protected get sortedValues(): WithStorageMeta<Payload>[] {\n this._sortedValues ??= this.cache.values().filter(exists).toArray().toSorted(PayloadBuilder.compareStorageMeta)\n return this._sortedValues\n }\n\n private static findIndexFromCursor(payloads: WithStorageMeta[], cursor: Hex) {\n const index = payloads.findIndex(({ _sequence }) => _sequence === cursor)\n // move to the end\n return index === -1 ? Infinity : index\n }\n\n all(): Promisable<WithStorageMeta<Payload>[]> {\n return [...this.sortedValues]\n }\n\n clear(): void {\n this.cache.clear()\n this._dataHashIndex = new LRUCache<Hash, Hash>({ max: this.max })\n this._sortedValues = undefined\n }\n\n count(): number {\n return this.cache.size\n }\n\n override createHandler(): Promisable<void> {\n this._config = this.params.config ?? {}\n }\n\n async delete(hashes: Hash[]): Promise<WithStorageMeta[]> {\n this._sortedValues = undefined\n const candidateDeletions = await Promise.all(this.cache\n .dump()\n .map(async ([key, item]) => {\n const itemValueDataHash = await PayloadBuilder.dataHash(item.value)\n if (!(hashes.includes(key) || hashes.includes(itemValueDataHash))) {\n return\n }\n\n this.cache.delete(key)\n return item.value\n }))\n const deletedPayloads: WithStorageMeta<Payload>[] = candidateDeletions\n .filter(exists)\n this.rebuildDataHashIndex()\n return deletedPayloads\n }\n\n get(hashes: Hash[]): Promisable<WithStorageMeta<Payload>[]> {\n return hashes.map((hash) => {\n const exact = this.cache.get(hash)\n if (exact) return exact\n const resolvedHash = this.dataHashIndex.get(hash) ?? hash\n const result = this.cache.get(resolvedHash)\n if (resolvedHash !== hash && !result) {\n throw new Error('Missing referenced payload')\n }\n return result\n }).filter(exists)\n }\n\n insert(payloads: WithStorageMeta<Payload>[]): WithStorageMeta<Payload>[] {\n this._sortedValues = undefined\n const payloadsWithMeta = payloads.toSorted(PayloadBuilder.compareStorageMeta)\n return payloadsWithMeta.map((payload) => {\n return this.insertPayloadIntoCache(payload)\n })\n }\n\n next(options?: ArchivistNextOptions): Promisable<WithStorageMeta<Payload>[]> {\n const {\n limit = 100, cursor, order, open = true,\n } = options ?? {}\n const all = order === 'desc' ? this.sortedValues.toReversed() : this.sortedValues\n const startIndex = isDefined(cursor)\n ? MemoryDriver.findIndexFromCursor(all, cursor) + (open ? 1 : 0)\n : 0\n return all.slice(startIndex, startIndex + limit)\n }\n\n private insertPayloadIntoCache(payload: WithStorageMeta<Payload>): WithStorageMeta<Payload> {\n this.cache.set(payload._hash, payload)\n this.dataHashIndex.set(payload._dataHash, payload._hash)\n return payload\n }\n\n private rebuildDataHashIndex() {\n this._dataHashIndex = new LRUCache<Hash, Hash>({ max: this.max })\n const payloads = this.cache.dump().map(([, item]) => item.value)\n for (const payload of payloads) {\n this.dataHashIndex.set(payload._dataHash, payload._hash)\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAEA,SAAS,yBAAyB;AAElC,SAAS,wBAAwB;AAKjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,SAAS,uBAAuB;;;ACnBhC;AAAA,EACE;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AACP;AAAA,EACE;AAAA,OACK;AACP,YAAY,OAAO;AAGnB,SAAS,0BAA0B;AAE5B,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,OAAO,WAAW,EAAE;AAAA,EAChG;AACF;AAxBE,cANW,iBAMc,iBAA0B,CAAC,GAAG,6CAAM,kBAAe,2BAA2B;AACvG,cAPW,iBAOc,uBAA8B;AACvD,cARW,iBAQc,UAErB,EAAE,GAAG,6CAAM,WAAQ,CAAC,iBAAiB,GAAG,SAAS;AAV1C,kBAAN;AAAA,EADN,gBAAgB;AAAA,GACJ;",
6
6
  "names": []
7
7
  }
@@ -287,19 +287,19 @@ var ModuleProxyResolver = class {
287
287
  if (direction === "down" || direction === "all") {
288
288
  const downResolverModule = await this.downResolver.resolve(firstPartAddress);
289
289
  if (downResolverModule) {
290
- return remainingParts !== void 0 && remainingParts !== "" ? downResolverModule.resolve(remainingParts, options) : downResolverModule;
290
+ return remainingParts === void 0 || remainingParts === "" ? downResolverModule : downResolverModule.resolve(remainingParts, options);
291
291
  }
292
292
  console.log(`ModuleProxyResolver: ${firstPartAddress} | ${this.root.address}`);
293
293
  if (firstPartAddress === this.root.address) {
294
294
  const wrapped = wrapModuleWithType(this.root, await Account.random());
295
- return remainingParts !== void 0 && remainingParts !== "" ? wrapped?.resolve(remainingParts, options) : wrapped;
295
+ return remainingParts === void 0 || remainingParts === "" ? wrapped : wrapped?.resolve(remainingParts, options);
296
296
  }
297
297
  const addressToProxy = Object.keys(this.childAddressMap).includes(firstPartAddress) ? firstPartAddress : Object.entries(this.childAddressMap).find(([_, value]) => value === firstPartAddress)?.[0];
298
298
  if (addressToProxy) {
299
299
  const proxy = await this.host.resolve(addressToProxy, { ...options, direction: "down" });
300
300
  if (proxy) {
301
301
  const wrapped = wrapModuleWithType(proxy, await Account.random());
302
- return remainingParts !== void 0 && remainingParts !== "" ? wrapped?.resolve(remainingParts, options) : wrapped;
302
+ return remainingParts === void 0 || remainingParts === "" ? wrapped : wrapped?.resolve(remainingParts, options);
303
303
  }
304
304
  return;
305
305
  }
@@ -311,10 +311,7 @@ var ModuleProxyResolver = class {
311
311
  if (Object.hasOwn(this.childAddressMap, id)) {
312
312
  return id;
313
313
  }
314
- if (this.root.address === id) {
315
- return this.root.address;
316
- }
317
- if (this.root.modName === id) {
314
+ if (this.root.address === id || this.root.modName === id) {
318
315
  return this.root.address;
319
316
  }
320
317
  const addressFromName = Object.entries(this.childAddressMap).find(([, name]) => name === id)?.[0];