@xyo-network/bridge-http 2.103.9 → 2.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{HttpBridge.d.cts → HttpBridgeBase.d.cts} +3 -3
- package/dist/browser/HttpBridgeBase.d.cts.map +1 -0
- package/dist/browser/{HttpBridge.d.ts → HttpBridgeBase.d.mts} +3 -3
- package/dist/browser/HttpBridgeBase.d.mts.map +1 -0
- package/dist/browser/{HttpBridge.d.mts → HttpBridgeBase.d.ts} +3 -3
- package/dist/browser/HttpBridgeBase.d.ts.map +1 -0
- package/dist/browser/HttpBridgeClientOnly.d.cts +9 -0
- package/dist/browser/HttpBridgeClientOnly.d.cts.map +1 -0
- package/dist/browser/HttpBridgeClientOnly.d.mts +9 -0
- package/dist/browser/HttpBridgeClientOnly.d.mts.map +1 -0
- package/dist/browser/HttpBridgeClientOnly.d.ts +9 -0
- package/dist/browser/HttpBridgeClientOnly.d.ts.map +1 -0
- package/dist/browser/HttpBridgeConfig.d.cts +7 -0
- package/dist/browser/HttpBridgeConfig.d.cts.map +1 -1
- package/dist/browser/HttpBridgeConfig.d.mts +7 -0
- package/dist/browser/HttpBridgeConfig.d.mts.map +1 -1
- package/dist/browser/HttpBridgeConfig.d.ts +7 -0
- package/dist/browser/HttpBridgeConfig.d.ts.map +1 -1
- package/dist/browser/HttpBridgeFull.d.cts +29 -0
- package/dist/browser/HttpBridgeFull.d.cts.map +1 -0
- package/dist/browser/HttpBridgeFull.d.mts +29 -0
- package/dist/browser/HttpBridgeFull.d.mts.map +1 -0
- package/dist/browser/HttpBridgeFull.d.ts +29 -0
- package/dist/browser/HttpBridgeFull.d.ts.map +1 -0
- package/dist/browser/{index.cjs → index-browser.cjs} +45 -21
- package/dist/browser/index-browser.cjs.map +1 -0
- package/dist/browser/index-browser.d.cts +3 -0
- package/dist/browser/index-browser.d.cts.map +1 -0
- package/dist/browser/index-browser.d.mts +3 -0
- package/dist/browser/index-browser.d.mts.map +1 -0
- package/dist/browser/index-browser.d.ts +3 -0
- package/dist/browser/index-browser.d.ts.map +1 -0
- package/dist/browser/{index.js → index-browser.js} +41 -17
- package/dist/browser/index-browser.js.map +1 -0
- package/dist/browser/index.d.cts +1 -1
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +1 -1
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/neutral/{HttpBridge.d.cts → HttpBridgeBase.d.cts} +3 -3
- package/dist/neutral/HttpBridgeBase.d.cts.map +1 -0
- package/dist/neutral/HttpBridgeBase.d.mts +43 -0
- package/dist/neutral/HttpBridgeBase.d.mts.map +1 -0
- package/dist/neutral/HttpBridgeBase.d.ts +43 -0
- package/dist/neutral/HttpBridgeBase.d.ts.map +1 -0
- package/dist/neutral/HttpBridgeClientOnly.d.cts +9 -0
- package/dist/neutral/HttpBridgeClientOnly.d.cts.map +1 -0
- package/dist/neutral/HttpBridgeClientOnly.d.mts +9 -0
- package/dist/neutral/HttpBridgeClientOnly.d.mts.map +1 -0
- package/dist/neutral/HttpBridgeClientOnly.d.ts +9 -0
- package/dist/neutral/HttpBridgeClientOnly.d.ts.map +1 -0
- package/dist/neutral/HttpBridgeConfig.d.cts +7 -0
- package/dist/neutral/HttpBridgeConfig.d.cts.map +1 -1
- package/dist/neutral/HttpBridgeConfig.d.mts +7 -0
- package/dist/neutral/HttpBridgeConfig.d.mts.map +1 -1
- package/dist/neutral/HttpBridgeConfig.d.ts +7 -0
- package/dist/neutral/HttpBridgeConfig.d.ts.map +1 -1
- package/dist/neutral/HttpBridgeFull.d.cts +29 -0
- package/dist/neutral/HttpBridgeFull.d.cts.map +1 -0
- package/dist/neutral/HttpBridgeFull.d.mts +29 -0
- package/dist/neutral/HttpBridgeFull.d.mts.map +1 -0
- package/dist/neutral/HttpBridgeFull.d.ts +29 -0
- package/dist/neutral/HttpBridgeFull.d.ts.map +1 -0
- package/dist/neutral/{index.cjs → index-browser.cjs} +45 -21
- package/dist/neutral/index-browser.cjs.map +1 -0
- package/dist/neutral/index-browser.d.cts +3 -0
- package/dist/neutral/index-browser.d.cts.map +1 -0
- package/dist/neutral/index-browser.d.mts +3 -0
- package/dist/neutral/index-browser.d.mts.map +1 -0
- package/dist/neutral/index-browser.d.ts +3 -0
- package/dist/neutral/index-browser.d.ts.map +1 -0
- package/dist/neutral/{index.js → index-browser.js} +41 -17
- package/dist/neutral/index-browser.js.map +1 -0
- package/dist/neutral/index.d.cts +1 -1
- package/dist/neutral/index.d.cts.map +1 -1
- package/dist/neutral/index.d.mts +1 -1
- package/dist/neutral/index.d.mts.map +1 -1
- package/dist/neutral/index.d.ts +1 -1
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/node/HttpBridgeBase.d.cts +43 -0
- package/dist/node/HttpBridgeBase.d.cts.map +1 -0
- package/dist/node/HttpBridgeBase.d.mts +43 -0
- package/dist/node/HttpBridgeBase.d.mts.map +1 -0
- package/dist/node/HttpBridgeBase.d.ts +43 -0
- package/dist/node/HttpBridgeBase.d.ts.map +1 -0
- package/dist/node/HttpBridgeClientOnly.d.cts +9 -0
- package/dist/node/HttpBridgeClientOnly.d.cts.map +1 -0
- package/dist/node/HttpBridgeClientOnly.d.mts +9 -0
- package/dist/node/HttpBridgeClientOnly.d.mts.map +1 -0
- package/dist/node/HttpBridgeClientOnly.d.ts +9 -0
- package/dist/node/HttpBridgeClientOnly.d.ts.map +1 -0
- package/dist/node/HttpBridgeConfig.d.cts +7 -0
- package/dist/node/HttpBridgeConfig.d.cts.map +1 -1
- package/dist/node/HttpBridgeConfig.d.mts +7 -0
- package/dist/node/HttpBridgeConfig.d.mts.map +1 -1
- package/dist/node/HttpBridgeConfig.d.ts +7 -0
- package/dist/node/HttpBridgeConfig.d.ts.map +1 -1
- package/dist/node/HttpBridgeFull.d.cts +29 -0
- package/dist/node/HttpBridgeFull.d.cts.map +1 -0
- package/dist/node/HttpBridgeFull.d.mts +29 -0
- package/dist/node/HttpBridgeFull.d.mts.map +1 -0
- package/dist/node/HttpBridgeFull.d.ts +29 -0
- package/dist/node/HttpBridgeFull.d.ts.map +1 -0
- package/dist/node/index-browser.d.cts +3 -0
- package/dist/node/index-browser.d.cts.map +1 -0
- package/dist/node/index-browser.d.mts +3 -0
- package/dist/node/index-browser.d.mts.map +1 -0
- package/dist/node/index-browser.d.ts +3 -0
- package/dist/node/index-browser.d.ts.map +1 -0
- package/dist/node/index.cjs +195 -27
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1 -1
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +186 -27
- package/dist/node/index.js.map +1 -1
- package/package.json +38 -33
- package/src/{HttpBridge.ts → HttpBridgeBase.ts} +14 -13
- package/src/HttpBridgeClientOnly.ts +10 -0
- package/src/HttpBridgeConfig.ts +7 -0
- package/src/HttpBridgeFull.ts +143 -0
- package/src/index-browser.ts +2 -0
- package/src/index.ts +1 -1
- package/xy.config.ts +17 -0
- package/dist/browser/HttpBridge.d.cts.map +0 -1
- package/dist/browser/HttpBridge.d.mts.map +0 -1
- package/dist/browser/HttpBridge.d.ts.map +0 -1
- package/dist/browser/index.cjs.map +0 -1
- package/dist/browser/index.js.map +0 -1
- package/dist/neutral/HttpBridge.d.cts.map +0 -1
- package/dist/neutral/HttpBridge.d.mts +0 -43
- package/dist/neutral/HttpBridge.d.mts.map +0 -1
- package/dist/neutral/HttpBridge.d.ts +0 -43
- package/dist/neutral/HttpBridge.d.ts.map +0 -1
- package/dist/neutral/index.cjs.map +0 -1
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/HttpBridge.d.cts +0 -43
- package/dist/node/HttpBridge.d.cts.map +0 -1
- package/dist/node/HttpBridge.d.mts +0 -43
- package/dist/node/HttpBridge.d.mts.map +0 -1
- package/dist/node/HttpBridge.d.ts +0 -43
- package/dist/node/HttpBridge.d.ts.map +0 -1
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/HttpBridge.ts","../../src/HttpBridgeConfig.ts","../../src/HttpBridgeModuleResolver.ts","../../src/ModuleProxy/ModuleProxy.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { AxiosError, AxiosJson } from '@xylabs/axios'\nimport { exists } from '@xylabs/exists'\nimport { forget } from '@xylabs/forget'\nimport { Address } from '@xylabs/hex'\nimport { toJsonString } from '@xylabs/object'\nimport { Promisable } from '@xylabs/promise'\nimport { ApiEnvelope } from '@xyo-network/api-models'\nimport { QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractBridge } from '@xyo-network/bridge-abstract'\nimport {\n BridgeExposeOptions,\n BridgeModule,\n BridgeParams,\n BridgeUnexposeOptions,\n QuerySendFinishedEventArgs,\n QuerySendStartedEventArgs,\n} from '@xyo-network/bridge-model'\nimport { NodeManifestPayload, NodeManifestPayloadSchema } from '@xyo-network/manifest-model'\nimport {\n AnyConfigSchema,\n creatableModule,\n ModuleInstance,\n ModuleQueryResult,\n ModuleResolverInstance,\n ModuleStateQuery,\n ModuleStateQuerySchema,\n} from '@xyo-network/module-model'\nimport { asAttachableNodeInstance } from '@xyo-network/node-model'\nimport { isPayloadOfSchemaType, Payload, Schema, WithMeta } from '@xyo-network/payload-model'\nimport { Mutex, Semaphore } from 'async-mutex'\nimport { LRUCache } from 'lru-cache'\n\nimport { HttpBridgeConfig, HttpBridgeConfigSchema } from './HttpBridgeConfig'\nimport { HttpBridgeModuleResolver } from './HttpBridgeModuleResolver'\nimport { BridgeQuerySender } from './ModuleProxy'\n\nexport interface HttpBridgeParams extends BridgeParams<AnyConfigSchema<HttpBridgeConfig>> {}\n\n@creatableModule()\nexport class HttpBridge<TParams extends HttpBridgeParams> extends AbstractBridge<TParams> implements BridgeModule<TParams>, BridgeQuerySender {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, HttpBridgeConfigSchema]\n static override readonly defaultConfigSchema: Schema = HttpBridgeConfigSchema\n static defaultFailureRetryTime = 1000 * 60\n static defaultMaxConnections = 4\n static defaultMaxPayloadSizeWarning = 256 * 256\n static maxFailureCacheSize = 1000\n\n private _axios?: AxiosJson\n private _discoverRootsMutex = new Mutex()\n private _failureTimeCache = new LRUCache<Address, number>({ max: HttpBridge.maxFailureCacheSize })\n private _querySemaphore?: Semaphore\n private _resolver?: HttpBridgeModuleResolver\n\n get axios() {\n this._axios = this._axios ?? new AxiosJson()\n return this._axios\n }\n\n get failureRetryTime() {\n return this.config.failureRetryTime ?? HttpBridge.defaultFailureRetryTime\n }\n\n get maxConnections() {\n return this.config.maxConnections ?? HttpBridge.defaultMaxConnections\n }\n\n get maxPayloadSizeWarning() {\n return this.config.maxPayloadSizeWarning ?? HttpBridge.defaultMaxPayloadSizeWarning\n }\n\n get nodeUrl() {\n return assertEx(this.config.nodeUrl, () => 'No Url Set')\n }\n\n get querySemaphore() {\n this._querySemaphore = this._querySemaphore ?? new Semaphore(this.maxConnections)\n return this._querySemaphore\n }\n\n override get resolver() {\n this._resolver =\n this._resolver ??\n new HttpBridgeModuleResolver({\n additionalSigners: this.additionalSigners,\n archiving: { ...this.archiving, resolveArchivists: this.resolveArchivingArchivists.bind(this) },\n bridge: this,\n onQuerySendFinished: (args: Omit<QuerySendFinishedEventArgs, 'module'>) => {\n forget(this.emit('querySendFinished', { module: this, ...args }))\n },\n onQuerySendStarted: (args: Omit<QuerySendStartedEventArgs, 'module'>) => {\n forget(this.emit('querySendStarted', { module: this, ...args }))\n },\n querySender: this,\n root: this,\n rootUrl: this.nodeUrl,\n wrapperAccount: this.account,\n })\n return this._resolver\n }\n\n override exposeHandler(_id: string, _options?: BridgeExposeOptions | undefined): Promisable<ModuleInstance[]> {\n throw new Error('Unsupported')\n }\n\n override exposedHandler(): Promisable<Address[]> {\n throw new Error('Unsupported')\n }\n\n async getRoots(force?: boolean): Promise<ModuleInstance[]> {\n return await this._discoverRootsMutex.runExclusive(async () => {\n if (this._roots === undefined || force) {\n const state = await this.getRootState()\n this.logger?.debug(`HttpBridge:discoverRoots.state [${state?.length}]`)\n const nodeManifest = state?.find(isPayloadOfSchemaType<WithMeta<NodeManifestPayload>>(NodeManifestPayloadSchema))\n if (nodeManifest) {\n const mods = (await this.resolveRootNode(nodeManifest)).filter(exists)\n this.logger?.debug(`HttpBridge:discoverRoots [${mods.length}]`)\n this._roots = mods\n } else {\n this._roots = []\n }\n }\n return this._roots\n })\n }\n\n moduleUrl(address: Address) {\n return new URL(address, this.nodeUrl)\n }\n\n async sendBridgeQuery<TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(\n targetAddress: Address,\n query: TQuery,\n payloads?: TIn[],\n ): Promise<ModuleQueryResult<TOut>> {\n const lastFailureTime = this._failureTimeCache.get(targetAddress)\n if (lastFailureTime !== undefined) {\n const now = Date.now()\n const timeSincePreviousFailure = now - lastFailureTime\n if (timeSincePreviousFailure > this.failureRetryTime) {\n throw new Error(`target module failed recently [${targetAddress}] [${timeSincePreviousFailure}ms ago]`)\n }\n this._failureTimeCache.delete(targetAddress)\n }\n try {\n await this.querySemaphore.acquire()\n const payloadSize = JSON.stringify([query, payloads]).length\n if (payloadSize > this.maxPayloadSizeWarning) {\n this.logger?.warn(\n `Large targetQuery being sent: ${payloadSize} bytes [${this.address}][${this.moduleAddress}] [${query.schema}] [${payloads?.length}]`,\n )\n }\n const moduleUrl = this.moduleUrl(targetAddress).href\n const result = await this.axios.post<ApiEnvelope<ModuleQueryResult<TOut>>>(moduleUrl, [query, payloads])\n if (result.status === 404) {\n throw `target module not found [${moduleUrl}] [${result.status}]`\n }\n if (result.status >= 400) {\n this.logger?.error(`targetQuery failed [${moduleUrl}]`)\n throw `targetQuery failed [${moduleUrl}] [${result.status}]`\n }\n return result.data?.data\n } catch (ex) {\n const error = ex as AxiosError\n this.logger?.error(`Error: ${toJsonString(error)}`)\n throw error\n } finally {\n this.querySemaphore.release()\n }\n }\n\n override unexposeHandler(_id: string, _options?: BridgeUnexposeOptions | undefined): Promisable<ModuleInstance[]> {\n throw new Error('Unsupported')\n }\n\n private async getRootState() {\n const queryPayload: ModuleStateQuery = { schema: ModuleStateQuerySchema }\n const boundQuery = await this.bindQuery(queryPayload)\n try {\n const response = await this.axios.post<ApiEnvelope<ModuleQueryResult>>(this.nodeUrl.toString(), boundQuery)\n if (response.status === 404) {\n return []\n }\n const [, payloads, errors] = response.data.data\n if (errors.length > 0) {\n throw new Error(`getRootState failed: ${JSON.stringify(errors, null, 2)}`)\n }\n return payloads\n } catch (ex) {\n const error = ex as Error\n this.logger?.warn(`Unable to connect to remote node: ${error.message} [${this.nodeUrl}]`)\n }\n }\n\n private async resolveRootNode(nodeManifest: NodeManifestPayload): Promise<ModuleInstance[]> {\n const rootModule = assertEx(\n (await this.resolver.resolveHandler(assertEx(nodeManifest.status?.address, () => 'Root has no address'))).at(0),\n () => `Root not found [${nodeManifest.status?.address}]`,\n )\n assertEx(rootModule.constructor.name !== 'HttpModuleProxy', () => 'rootModule is not a Wrapper')\n const rootNode = asAttachableNodeInstance(rootModule, 'Root modules is not a node')\n if (rootNode) {\n this.logger.debug(`rootNode: ${rootNode.id}`)\n this.downResolver.addResolver(rootNode as unknown as ModuleResolverInstance)\n return [rootNode]\n }\n return []\n }\n}\n","import { EmptyObject } from '@xylabs/object'\nimport { BridgeConfig } from '@xyo-network/bridge-model'\n\nexport type HttpBridgeConfigSchema = 'network.xyo.bridge.http.config'\nexport const HttpBridgeConfigSchema: HttpBridgeConfigSchema = 'network.xyo.bridge.http.config'\n\nexport type HttpBridgeConfig<TConfig extends EmptyObject = EmptyObject, TSchema extends string | void = void> = BridgeConfig<\n {\n failureRetryTime?: number\n failureTimeCacheMax?: number\n maxConnections?: number\n maxPayloadSizeWarning?: number\n nodeUrl?: string\n schema: HttpBridgeConfigSchema\n } & TConfig,\n TSchema extends string ? TSchema : HttpBridgeConfigSchema\n>\n","import { assertEx } from '@xylabs/assert'\nimport { Address, isAddress } from '@xylabs/hex'\nimport { Account } from '@xyo-network/account'\nimport { AbstractBridgeModuleResolver, BridgeModuleResolverParams, wrapModuleWithType } from '@xyo-network/bridge-abstract'\nimport { ConfigPayload, ConfigSchema } from '@xyo-network/config-payload-plugin'\nimport {\n asModuleInstance,\n ModuleConfig,\n ModuleConfigSchema,\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleInstance,\n ResolveHelper,\n} from '@xyo-network/module-model'\n\nimport { BridgeQuerySender, HttpModuleProxy, HttpModuleProxyParams } from './ModuleProxy'\n\nexport interface HttpBridgeModuleResolverParams extends BridgeModuleResolverParams {\n querySender: BridgeQuerySender\n rootUrl: string\n}\n\nexport class HttpBridgeModuleResolver<\n T extends HttpBridgeModuleResolverParams = HttpBridgeModuleResolverParams,\n> extends AbstractBridgeModuleResolver<T> {\n get querySender() {\n return this.params.querySender\n }\n\n moduleUrl(address: Address) {\n return new URL(address, this.params.rootUrl)\n }\n\n override async resolveHandler<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ModuleFilterOptions<T>): Promise<T[]> {\n const parentResult = await super.resolveHandler(id, options)\n if (parentResult.length > 0) {\n return parentResult\n }\n if (id === '*') {\n return []\n }\n const idParts = id.split(':')\n const untransformedFirstPart = assertEx(idParts.shift(), () => `Invalid module identifier: ${id}`)\n const firstPart = await ResolveHelper.transformModuleIdentifier(untransformedFirstPart)\n const moduleAddress = firstPart as Address\n assertEx(isAddress(firstPart), () => `Invalid module address: ${firstPart}`)\n const remainderParts = idParts.join(':')\n const params: HttpModuleProxyParams = {\n account: Account.randomSync(),\n additionalSigners: this.params.additionalSigners,\n archiving: this.params.archiving,\n config: { schema: ModuleConfigSchema },\n host: this,\n moduleAddress,\n onQuerySendFinished: this.params.onQuerySendFinished,\n onQuerySendStarted: this.params.onQuerySendStarted,\n querySender: this.querySender,\n }\n\n this.logger?.debug(`creating HttpProxy [${moduleAddress}] ${id}`)\n\n const proxy = new HttpModuleProxy<T, HttpModuleProxyParams>(params)\n //calling state here to get the config\n if (proxy) {\n const state = await proxy.state()\n if (state) {\n const configSchema = (state.find((payload) => payload.schema === ConfigSchema) as ConfigPayload | undefined)?.config\n const config = assertEx(\n state.find((payload) => payload.schema === configSchema),\n () => 'Unable to locate config',\n ) as ModuleConfig\n proxy.setConfig(config)\n }\n }\n\n await proxy.start()\n\n const wrapped = assertEx(wrapModuleWithType(proxy, Account.randomSync()) as unknown as T, () => `Failed to wrapModuleWithType [${id}]`)\n const instance = assertEx(asModuleInstance<T>(wrapped, {}), () => `Failed to asModuleInstance [${id}]`)\n proxy.upResolver.add(instance)\n proxy.downResolver.add(instance)\n\n if (remainderParts.length > 0) {\n const result = await wrapped.resolve<T>(remainderParts, options)\n return result ? [result] : []\n }\n\n //console.log(`resolved: ${proxy.address} [${wrapped.constructor.name}] [${as.constructor.name}]`)\n return [instance]\n }\n}\n","import { forget } from '@xylabs/forget'\nimport { Address } from '@xylabs/hex'\nimport { QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractModuleProxy, ModuleProxyParams } from '@xyo-network/bridge-abstract'\nimport { AttachableModuleInstance, ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport interface BridgeQuerySender {\n sendBridgeQuery: <TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(\n targetAddress: Address,\n query: TQuery,\n payloads?: TIn[],\n ) => Promise<ModuleQueryResult<TOut>>\n}\n\nexport type HttpModuleProxyParams = ModuleProxyParams & {\n querySender: BridgeQuerySender\n}\n\nexport class HttpModuleProxy<\n TWrappedModule extends ModuleInstance = ModuleInstance,\n TParams extends Omit<HttpModuleProxyParams, 'config'> & { config: TWrappedModule['config'] } = Omit<HttpModuleProxyParams, 'config'> & {\n config: TWrappedModule['config']\n },\n >\n extends AbstractModuleProxy<TWrappedModule, TParams>\n implements AttachableModuleInstance<TParams, TWrappedModule['eventData']>\n{\n static createCount = 0\n\n constructor(params: TParams) {\n HttpModuleProxy.createCount = HttpModuleProxy.createCount + 1\n if (Math.floor(HttpModuleProxy.createCount / 10) === HttpModuleProxy.createCount / 10) {\n console.log(`HttpModuleProxy.createCount: ${HttpModuleProxy.createCount}`)\n }\n super(params)\n }\n\n async proxyQueryHandler<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads: Payload[] = []): Promise<ModuleQueryResult> {\n if (this.archiving && this.isAllowedArchivingQuery(query.schema)) {\n forget(this.storeToArchivists([query, ...(payloads ?? [])]))\n }\n const result = await this.params.querySender.sendBridgeQuery(this.params.moduleAddress, query, payloads)\n if (this.archiving && this.isAllowedArchivingQuery(query.schema)) {\n forget(this.storeToArchivists(result.flat()))\n }\n return result\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAASA,YAAAA,iBAAgB;AACzB,SAAqBC,iBAAiB;AACtC,SAASC,cAAc;AACvB,SAASC,UAAAA,eAAc;AAEvB,SAASC,oBAAoB;AAI7B,SAASC,sBAAsB;AAS/B,SAA8BC,iCAAiC;AAC/D,SAEEC,iBAKAC,8BACK;AACP,SAASC,gCAAgC;AACzC,SAASC,6BAAwD;AACjE,SAASC,OAAOC,iBAAiB;AACjC,SAASC,gBAAgB;;;AC3BlB,IAAMC,yBAAiD;;;ACJ9D,SAASC,gBAAgB;AACzB,SAAkBC,iBAAiB;AACnC,SAASC,eAAe;AACxB,SAASC,8BAA0DC,0BAA0B;AAC7F,SAAwBC,oBAAoB;AAC5C,SACEC,kBAEAC,oBAIAC,qBACK;;;ACbP,SAASC,cAAc;AAGvB,SAASC,2BAA8C;AAgBhD,IAAMC,mBAAN,MAAMA,yBAMHC,oBAAAA;EAKRC,YAAYC,QAAiB;AAC3BH,qBAAgBI,cAAcJ,iBAAgBI,cAAc;AAC5D,QAAIC,KAAKC,MAAMN,iBA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MF,QAAQE;AACd,iBAAKrC,WAAL,mBAAa4B,KAAK,qCAAqCO,MAAMa,OAAO,KAAK,KAAKnF,OAAO;IACvF;EACF;EAEA,MAAc2C,gBAAgBL,cAA8D;;AAC1F,UAAM8C,aAAanF,WAChB,MAAM,KAAKG,SAASiF,eAAepF,WAASqC,kBAAa+B,WAAb/B,mBAAqBS,SAAS,MAAM,qBAAA,CAAA,GAAyBuC,GAAG,CAAA,GAC7G,MAAA;;AAAM,iCAAmBhD,MAAAA,aAAa+B,WAAb/B,gBAAAA,IAAqBS,OAAAA;KAAU;AAE1D9C,IAAAA,UAASmF,WAAWG,YAAYC,SAAS,mBAAmB,MAAM,6BAAA;AAClE,UAAMC,WAAWC,yBAAyBN,YAAY,4BAAA;AACtD,QAAIK,UAAU;AACZ,WAAKtD,OAAOC,MAAM,aAAaqD,SAASE,EAAE,EAAE;AAC5C,WAAKC,aAAaC,YAAYJ,QAAAA;AAC9B,aAAO;QAACA;;IACV;AACA,WAAO,CAAA;EACT;AACF;AAzKkE5G;AAChE,cADWD,aACckH,iBAA0B;KAAI,qCAAMA;EAAeC;;AAC5E,cAFWnH,aAEcoH,uBAA8BD;AACvD,cAHWnH,aAGJe,2BAA0B,MAAO;AACxC,cAJWf,aAIJiB,yBAAwB;AAC/B,cALWjB,aAKJmB,gCAA+B,MAAM;AAC5C,cANWnB,aAMJQ,uBAAsB;AANxB,IAAMR,aAAN;AAAMA,aAAAA,aAAAA;EADZqH,gBAAAA;GACYrH,UAAAA;","names":["assertEx","AxiosJson","exists","forget","toJsonString","AbstractBridge","NodeManifestPayloadSchema","creatableModule","ModuleStateQuerySchema","asAttachableNodeInstance","isPayloadOfSchemaType","Mutex","Semaphore","LRUCache","HttpBridgeConfigSchema","assertEx","isAddress","Account","AbstractBridgeModuleResolver","wrapModuleWithType","ConfigSchema","asModuleInstance","ModuleConfigSchema","ResolveHelper","forget","AbstractModuleProxy","HttpModuleProxy","AbstractModuleProxy","constructor","params","createCount","Math","floor","console","log","proxyQueryHandler","query","payloads","archiving","isAllowedArchivingQuery","schema","forget","storeToArchivists","result","querySender","sendBridgeQuery","moduleAddress","flat","HttpBridgeModuleResolver","AbstractBridgeModuleResolver","querySender","params","moduleUrl","address","URL","rootUrl","resolveHandler","id","options","parentResult","length","idParts","split","untransformedFirstPart","assertEx","shift","firstPart","ResolveHelper","transformModuleIdentifier","moduleAddress","isAddress","remainderParts","join","account","Account","randomSync","additionalSigners","archiving","config","schema","ModuleConfigSchema","host","onQuerySendFinished","onQuerySendStarted","logger","debug","proxy","HttpModuleProxy","state","configSchema","find","payload","ConfigSchema","setConfig","start","wrapped","wrapModuleWithType","instance","asModuleInstance","upResolver","add","downResolver","result","resolve","HttpBridge","AbstractBridge","_axios","_discoverRootsMutex","Mutex","_failureTimeCache","LRUCache","max","maxFailureCacheSize","_querySemaphore","_resolver","axios","AxiosJson","failureRetryTime","config","defaultFailureRetryTime","maxConnections","defaultMaxConnections","maxPayloadSizeWarning","defaultMaxPayloadSizeWarning","nodeUrl","assertEx","querySemaphore","Semaphore","resolver","HttpBridgeModuleResolver","additionalSigners","archiving","resolveArchivists","resolveArchivingArchivists","bind","bridge","onQuerySendFinished","args","forget","emit","module","onQuerySendStarted","querySender","root","rootUrl","wrapperAccount","account","exposeHandler","_id","_options","Error","exposedHandler","getRoots","force","runExclusive","_roots","undefined","state","getRootState","logger","debug","length","nodeManifest","find","isPayloadOfSchemaType","NodeManifestPayloadSchema","mods","resolveRootNode","filter","exists","moduleUrl","address","URL","sendBridgeQuery","targetAddress","query","payloads","lastFailureTime","get","now","Date","timeSincePreviousFailure","delete","acquire","payloadSize","JSON","stringify","warn","moduleAddress","schema","href","result","post","status","error","data","ex","toJsonString","release","unexposeHandler","queryPayload","ModuleStateQuerySchema","boundQuery","bindQuery","response","toString","errors","message","rootModule","resolveHandler","at","constructor","name","rootNode","asAttachableNodeInstance","id","downResolver","addResolver","configSchemas","HttpBridgeConfigSchema","defaultConfigSchema","creatableModule"]}
|
|
1
|
+
{"version":3,"sources":["../../src/HttpBridgeConfig.ts","../../src/HttpBridgeFull.ts","../../src/HttpBridgeBase.ts","../../src/HttpBridgeModuleResolver.ts","../../src/ModuleProxy/ModuleProxy.ts"],"sourcesContent":["import { EmptyObject } from '@xylabs/object'\nimport { BridgeConfig } from '@xyo-network/bridge-model'\n\nexport type HttpBridgeConfigSchema = 'network.xyo.bridge.http.config'\nexport const HttpBridgeConfigSchema: HttpBridgeConfigSchema = 'network.xyo.bridge.http.config'\n\nexport type HttpBridgeConfig<TConfig extends EmptyObject = EmptyObject, TSchema extends string | void = void> = BridgeConfig<\n {\n client?: BridgeConfig['client'] & {\n url: string\n }\n failureRetryTime?: number\n failureTimeCacheMax?: number\n host?: {\n port: number\n }\n maxConnections?: number\n maxPayloadSizeWarning?: number\n /** @deprecated use client.url instead */\n nodeUrl?: string\n schema: HttpBridgeConfigSchema\n } & TConfig,\n TSchema extends string ? TSchema : HttpBridgeConfigSchema\n>\n","import { Server } from 'node:http'\n\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { Address } from '@xylabs/hex'\nimport { toJsonString } from '@xylabs/object'\nimport { ApiEnvelopeSuccess } from '@xyo-network/api-models'\nimport { isQueryBoundWitness, QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BridgeExposeOptions, BridgeParams, BridgeUnexposeOptions } from '@xyo-network/bridge-model'\nimport { AnyConfigSchema, creatableModule, ModuleInstance, ModuleQueryResult, resolveAddressToInstanceUp } from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport express, { Application, Request, Response } from 'express'\n\nimport { HttpBridgeBase } from './HttpBridgeBase'\nimport { HttpBridgeConfig } from './HttpBridgeConfig'\n\nexport interface HttpBridgeParams extends BridgeParams<AnyConfigSchema<HttpBridgeConfig>> {}\n\n@creatableModule()\nexport class HttpBridge<TParams extends HttpBridgeParams> extends HttpBridgeBase<TParams> {\n protected _app?: Application\n protected _exposedModules: WeakRef<ModuleInstance>[] = []\n protected _server?: Server\n\n get app() {\n this._app =\n this._app ??\n (() => {\n const app = express()\n app.use(express.json())\n\n app.post<Payload[]>('/', (req, res) => {\n this.handlePost(req, res)\n })\n\n return app\n })()\n return this._app\n }\n\n async exposeChild(mod: ModuleInstance, options?: BridgeExposeOptions | undefined): Promise<ModuleInstance[]> {\n const { maxDepth = 5 } = options ?? {}\n console.log(`exposeChild: ${mod.address} ${mod?.id} ${maxDepth}`)\n assertEx(this.config.host, () => 'Not configured as a host')\n this._exposedModules.push(new WeakRef(mod))\n const children = maxDepth > 0 ? (await mod.publicChildren?.()) ?? [] : []\n this.logger.log(`childrenToExpose [${mod.id}][${mod.address}]: ${toJsonString(children.map((child) => child.id))}`)\n const exposedChildren = (await Promise.all(children.map((child) => this.exposeChild(child, { maxDepth: maxDepth - 1, required: false }))))\n .flat()\n .filter(exists)\n const allExposed = [mod, ...exposedChildren]\n\n for (const exposedMod of allExposed) this.logger?.log(`exposed: ${exposedMod.address} [${mod.id}]`)\n\n return allExposed\n }\n\n override async exposeHandler(address: Address, options?: BridgeExposeOptions | undefined): Promise<ModuleInstance[]> {\n const { required = true } = options ?? {}\n const mod = await resolveAddressToInstanceUp(this, address)\n console.log(`exposeHandler: ${address} ${mod?.id}`)\n if (required && !mod) {\n throw new Error(`Unable to find required module: ${address}`)\n }\n if (mod) {\n return this.exposeChild(mod, options)\n }\n return []\n }\n\n override exposedHandler(): Address[] {\n return this._exposedModules.map((ref) => ref.deref()?.address).filter(exists)\n }\n\n override async startHandler(): Promise<boolean> {\n return (await super.startHandler()) && this.startHttpServer()\n }\n\n override async stopHandler(_timeout?: number | undefined): Promise<boolean> {\n return (await super.stopHandler()) && this.stopHttpServer()\n }\n\n override async unexposeHandler(address: Address, options?: BridgeUnexposeOptions | undefined): Promise<ModuleInstance[]> {\n const { maxDepth = 2, required = true } = options ?? {}\n assertEx(this.config.host, () => 'Not configured as a host')\n const mod = this._exposedModules.find((ref) => ref.deref()?.address === address)?.deref()\n assertEx(!required || mod, () => `Module not exposed: ${address}`)\n this._exposedModules = this._exposedModules.filter((ref) => ref.deref()?.address !== address)\n if (mod) {\n const children = maxDepth > 0 ? (await mod.publicChildren?.()) ?? [] : []\n const exposedChildren = (\n await Promise.all(children.map((child) => this.unexposeHandler(child.address, { maxDepth: maxDepth - 1, required: false })))\n )\n .flat()\n .filter(exists)\n return [mod, ...exposedChildren]\n }\n return []\n }\n\n protected async callLocalModule(address: Address, query: QueryBoundWitness, payloads: Payload[]): Promise<ModuleQueryResult | null> {\n const mod = this._exposedModules.find((ref) => ref.deref()?.address === address)?.deref()\n if (mod) {\n return await mod.query(query, payloads)\n }\n return null\n }\n\n protected handlePost(req: Request<Payload[]>, res: Response) {\n const allPayloads = req.body as Payload[]\n const query = allPayloads.find(isQueryBoundWitness) as QueryBoundWitness\n const payloads = allPayloads.filter((payload) => !isQueryBoundWitness(payload))\n this.callLocalModule(req.route, query, payloads)\n .then((result) => {\n if (result === null) {\n res.status(404).json({ error: 'Module not found' })\n } else {\n const envelope = {\n data: result,\n } as ApiEnvelopeSuccess<ModuleQueryResult>\n res.json(envelope)\n }\n })\n .catch((ex) => {\n res.status(500).json({ error: (ex as Error).message })\n })\n }\n\n protected startHttpServer() {\n if (this.config.host) {\n assertEx(!this._server, () => 'Server already started')\n this._server = this.app.listen(this.config.host?.port ?? 3030)\n }\n return true\n }\n\n protected stopHttpServer() {\n const server = assertEx(this._server, () => 'Server not started')\n server.close()\n this._server = undefined\n return true\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosError, AxiosJson } from '@xylabs/axios'\nimport { exists } from '@xylabs/exists'\nimport { forget } from '@xylabs/forget'\nimport { Address } from '@xylabs/hex'\nimport { toJsonString } from '@xylabs/object'\nimport { Promisable } from '@xylabs/promise'\nimport { ApiEnvelope } from '@xyo-network/api-models'\nimport { QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractBridge } from '@xyo-network/bridge-abstract'\nimport {\n BridgeExposeOptions,\n BridgeModule,\n BridgeParams,\n BridgeUnexposeOptions,\n QuerySendFinishedEventArgs,\n QuerySendStartedEventArgs,\n} from '@xyo-network/bridge-model'\nimport { NodeManifestPayload, NodeManifestPayloadSchema } from '@xyo-network/manifest-model'\nimport {\n AnyConfigSchema,\n creatableModule,\n ModuleInstance,\n ModuleQueryResult,\n ModuleResolverInstance,\n ModuleStateQuery,\n ModuleStateQuerySchema,\n} from '@xyo-network/module-model'\nimport { asAttachableNodeInstance } from '@xyo-network/node-model'\nimport { isPayloadOfSchemaType, Payload, Schema, WithMeta } from '@xyo-network/payload-model'\nimport { Mutex, Semaphore } from 'async-mutex'\nimport { LRUCache } from 'lru-cache'\n\nimport { HttpBridgeConfig, HttpBridgeConfigSchema } from './HttpBridgeConfig'\nimport { HttpBridgeModuleResolver } from './HttpBridgeModuleResolver'\nimport { BridgeQuerySender } from './ModuleProxy'\n\nexport interface HttpBridgeParams extends BridgeParams<AnyConfigSchema<HttpBridgeConfig>> {}\n\n@creatableModule()\nexport class HttpBridgeBase<TParams extends HttpBridgeParams> extends AbstractBridge<TParams> implements BridgeModule<TParams>, BridgeQuerySender {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, HttpBridgeConfigSchema]\n static override readonly defaultConfigSchema: Schema = HttpBridgeConfigSchema\n static defaultFailureRetryTime = 1000 * 60\n static defaultMaxConnections = 4\n static defaultMaxPayloadSizeWarning = 256 * 256\n static maxFailureCacheSize = 1000\n\n private _axios?: AxiosJson\n private _discoverRootsMutex = new Mutex()\n private _failureTimeCache = new LRUCache<Address, number>({ max: HttpBridgeBase.maxFailureCacheSize })\n private _querySemaphore?: Semaphore\n private _resolver?: HttpBridgeModuleResolver\n\n get axios() {\n this._axios = this._axios ?? new AxiosJson()\n return this._axios\n }\n\n get clientUrl() {\n // eslint-disable-next-line deprecation/deprecation\n return assertEx(this.config.client?.url ?? this.config.nodeUrl, () => 'No Url Set')\n }\n\n get failureRetryTime() {\n return this.config.failureRetryTime ?? HttpBridgeBase.defaultFailureRetryTime\n }\n\n get maxConnections() {\n return this.config.maxConnections ?? HttpBridgeBase.defaultMaxConnections\n }\n\n get maxPayloadSizeWarning() {\n return this.config.maxPayloadSizeWarning ?? HttpBridgeBase.defaultMaxPayloadSizeWarning\n }\n\n get querySemaphore() {\n this._querySemaphore = this._querySemaphore ?? new Semaphore(this.maxConnections)\n return this._querySemaphore\n }\n\n override get resolver() {\n this._resolver =\n this._resolver ??\n new HttpBridgeModuleResolver({\n additionalSigners: this.additionalSigners,\n archiving: { ...this.archiving, resolveArchivists: this.resolveArchivingArchivists.bind(this) },\n bridge: this,\n onQuerySendFinished: (args: Omit<QuerySendFinishedEventArgs, 'module'>) => {\n forget(this.emit('querySendFinished', { module: this, ...args }))\n },\n onQuerySendStarted: (args: Omit<QuerySendStartedEventArgs, 'module'>) => {\n forget(this.emit('querySendStarted', { module: this, ...args }))\n },\n querySender: this,\n root: this,\n rootUrl: this.clientUrl,\n wrapperAccount: this.account,\n })\n return this._resolver\n }\n\n override exposeHandler(_id: string, _options?: BridgeExposeOptions | undefined): Promisable<ModuleInstance[]> {\n throw new Error('Unsupported')\n }\n\n override exposedHandler(): Promisable<Address[]> {\n throw new Error('Unsupported')\n }\n\n async getRoots(force?: boolean): Promise<ModuleInstance[]> {\n return await this._discoverRootsMutex.runExclusive(async () => {\n if (this._roots === undefined || force) {\n const state = await this.getRootState()\n this.logger?.debug(`HttpBridge:discoverRoots.state [${state?.length}]`)\n const nodeManifest = state?.find(isPayloadOfSchemaType<WithMeta<NodeManifestPayload>>(NodeManifestPayloadSchema))\n if (nodeManifest) {\n const mods = (await this.resolveRootNode(nodeManifest)).filter(exists)\n this.logger?.debug(`HttpBridge:discoverRoots [${mods.length}]`)\n this._roots = mods\n } else {\n this._roots = []\n }\n }\n return this._roots\n })\n }\n\n moduleUrl(address: Address) {\n return new URL(address, this.clientUrl)\n }\n\n async sendBridgeQuery<TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(\n targetAddress: Address,\n query: TQuery,\n payloads?: TIn[],\n ): Promise<ModuleQueryResult<TOut>> {\n const lastFailureTime = this._failureTimeCache.get(targetAddress)\n if (lastFailureTime !== undefined) {\n const now = Date.now()\n const timeSincePreviousFailure = now - lastFailureTime\n if (timeSincePreviousFailure > this.failureRetryTime) {\n throw new Error(`target module failed recently [${targetAddress}] [${timeSincePreviousFailure}ms ago]`)\n }\n this._failureTimeCache.delete(targetAddress)\n }\n try {\n await this.querySemaphore.acquire()\n const payloadSize = JSON.stringify([query, payloads]).length\n if (payloadSize > this.maxPayloadSizeWarning) {\n this.logger?.warn(\n `Large targetQuery being sent: ${payloadSize} bytes [${this.address}][${this.moduleAddress}] [${query.schema}] [${payloads?.length}]`,\n )\n }\n const moduleUrl = this.moduleUrl(targetAddress).href\n const result = await this.axios.post<ApiEnvelope<ModuleQueryResult<TOut>>>(moduleUrl, [query, payloads])\n if (result.status === 404) {\n throw `target module not found [${moduleUrl}] [${result.status}]`\n }\n if (result.status >= 400) {\n this.logger?.error(`targetQuery failed [${moduleUrl}]`)\n throw `targetQuery failed [${moduleUrl}] [${result.status}]`\n }\n return result.data?.data\n } catch (ex) {\n const error = ex as AxiosError\n this.logger?.error(`Error: ${toJsonString(error)}`)\n throw error\n } finally {\n this.querySemaphore.release()\n }\n }\n\n override unexposeHandler(_id: string, _options?: BridgeUnexposeOptions | undefined): Promisable<ModuleInstance[]> {\n throw new Error('Unsupported')\n }\n\n private async getRootState() {\n const queryPayload: ModuleStateQuery = { schema: ModuleStateQuerySchema }\n const boundQuery = await this.bindQuery(queryPayload)\n try {\n const response = await this.axios.post<ApiEnvelope<ModuleQueryResult>>(this.clientUrl.toString(), boundQuery)\n if (response.status === 404) {\n return []\n }\n const [, payloads, errors] = response.data.data\n if (errors.length > 0) {\n throw new Error(`getRootState failed: ${JSON.stringify(errors, null, 2)}`)\n }\n return payloads\n } catch (ex) {\n const error = ex as Error\n this.logger?.warn(`Unable to connect to remote node: ${error.message} [${this.clientUrl}]`)\n }\n }\n\n private async resolveRootNode(nodeManifest: NodeManifestPayload): Promise<ModuleInstance[]> {\n const rootModule = assertEx(\n (await this.resolver.resolveHandler(assertEx(nodeManifest.status?.address, () => 'Root has no address'))).at(0),\n () => `Root not found [${nodeManifest.status?.address}]`,\n )\n assertEx(rootModule.constructor.name !== 'HttpModuleProxy', () => 'rootModule is not a Wrapper')\n const rootNode = asAttachableNodeInstance(rootModule, 'Root modules is not a node')\n if (rootNode) {\n this.logger.debug(`rootNode: ${rootNode.id}`)\n this.downResolver.addResolver(rootNode as unknown as ModuleResolverInstance)\n return [rootNode]\n }\n return []\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Address, isAddress } from '@xylabs/hex'\nimport { Account } from '@xyo-network/account'\nimport { AbstractBridgeModuleResolver, BridgeModuleResolverParams, wrapModuleWithType } from '@xyo-network/bridge-abstract'\nimport { ConfigPayload, ConfigSchema } from '@xyo-network/config-payload-plugin'\nimport {\n asModuleInstance,\n ModuleConfig,\n ModuleConfigSchema,\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleInstance,\n ResolveHelper,\n} from '@xyo-network/module-model'\n\nimport { BridgeQuerySender, HttpModuleProxy, HttpModuleProxyParams } from './ModuleProxy'\n\nexport interface HttpBridgeModuleResolverParams extends BridgeModuleResolverParams {\n querySender: BridgeQuerySender\n rootUrl: string\n}\n\nexport class HttpBridgeModuleResolver<\n T extends HttpBridgeModuleResolverParams = HttpBridgeModuleResolverParams,\n> extends AbstractBridgeModuleResolver<T> {\n get querySender() {\n return this.params.querySender\n }\n\n moduleUrl(address: Address) {\n return new URL(address, this.params.rootUrl)\n }\n\n override async resolveHandler<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ModuleFilterOptions<T>): Promise<T[]> {\n const parentResult = await super.resolveHandler(id, options)\n if (parentResult.length > 0) {\n return parentResult\n }\n if (id === '*') {\n return []\n }\n const idParts = id.split(':')\n const untransformedFirstPart = assertEx(idParts.shift(), () => `Invalid module identifier: ${id}`)\n const firstPart = await ResolveHelper.transformModuleIdentifier(untransformedFirstPart)\n const moduleAddress = firstPart as Address\n assertEx(isAddress(firstPart), () => `Invalid module address: ${firstPart}`)\n const remainderParts = idParts.join(':')\n const params: HttpModuleProxyParams = {\n account: Account.randomSync(),\n additionalSigners: this.params.additionalSigners,\n archiving: this.params.archiving,\n config: { schema: ModuleConfigSchema },\n host: this,\n moduleAddress,\n onQuerySendFinished: this.params.onQuerySendFinished,\n onQuerySendStarted: this.params.onQuerySendStarted,\n querySender: this.querySender,\n }\n\n this.logger?.debug(`creating HttpProxy [${moduleAddress}] ${id}`)\n\n const proxy = new HttpModuleProxy<T, HttpModuleProxyParams>(params)\n //calling state here to get the config\n if (proxy) {\n const state = await proxy.state()\n if (state) {\n const configSchema = (state.find((payload) => payload.schema === ConfigSchema) as ConfigPayload | undefined)?.config\n const config = assertEx(\n state.find((payload) => payload.schema === configSchema),\n () => 'Unable to locate config',\n ) as ModuleConfig\n proxy.setConfig(config)\n }\n }\n\n await proxy.start()\n\n const wrapped = assertEx(wrapModuleWithType(proxy, Account.randomSync()) as unknown as T, () => `Failed to wrapModuleWithType [${id}]`)\n const instance = assertEx(asModuleInstance<T>(wrapped, {}), () => `Failed to asModuleInstance [${id}]`)\n proxy.upResolver.add(instance)\n proxy.downResolver.add(instance)\n\n if (remainderParts.length > 0) {\n const result = await wrapped.resolve<T>(remainderParts, options)\n return result ? [result] : []\n }\n\n //console.log(`resolved: ${proxy.address} [${wrapped.constructor.name}] [${as.constructor.name}]`)\n return [instance]\n }\n}\n","import { forget } from '@xylabs/forget'\nimport { Address } from '@xylabs/hex'\nimport { QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractModuleProxy, ModuleProxyParams } from '@xyo-network/bridge-abstract'\nimport { AttachableModuleInstance, ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport interface BridgeQuerySender {\n sendBridgeQuery: <TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(\n targetAddress: Address,\n query: TQuery,\n payloads?: TIn[],\n ) => Promise<ModuleQueryResult<TOut>>\n}\n\nexport type HttpModuleProxyParams = ModuleProxyParams & {\n querySender: BridgeQuerySender\n}\n\nexport class HttpModuleProxy<\n TWrappedModule extends ModuleInstance = ModuleInstance,\n TParams extends Omit<HttpModuleProxyParams, 'config'> & { config: TWrappedModule['config'] } = Omit<HttpModuleProxyParams, 'config'> & {\n config: TWrappedModule['config']\n },\n >\n extends AbstractModuleProxy<TWrappedModule, TParams>\n implements AttachableModuleInstance<TParams, TWrappedModule['eventData']>\n{\n static createCount = 0\n\n constructor(params: TParams) {\n HttpModuleProxy.createCount = HttpModuleProxy.createCount + 1\n if (Math.floor(HttpModuleProxy.createCount / 10) === HttpModuleProxy.createCount / 10) {\n console.log(`HttpModuleProxy.createCount: ${HttpModuleProxy.createCount}`)\n }\n super(params)\n }\n\n async proxyQueryHandler<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads: Payload[] = []): Promise<ModuleQueryResult> {\n if (this.archiving && this.isAllowedArchivingQuery(query.schema)) {\n forget(this.storeToArchivists([query, ...(payloads ?? [])]))\n }\n const result = await this.params.querySender.sendBridgeQuery(this.params.moduleAddress, query, payloads)\n if (this.archiving && this.isAllowedArchivingQuery(query.schema)) {\n forget(this.storeToArchivists(result.flat()))\n }\n return result\n }\n}\n"],"mappings":";;;;;;;;;;;;AAIO,IAAMA,yBAAiD;;;ACF9D,SAASC,YAAAA,iBAAgB;AACzB,SAASC,UAAAA,eAAc;AAEvB,SAASC,gBAAAA,qBAAoB;AAE7B,SAASC,2BAA8C;AAEvD,SAA0BC,mBAAAA,kBAAoDC,kCAAkC;AAEhH,OAAOC,aAAiD;;;ACXxD,SAASC,YAAAA,iBAAgB;AACzB,SAAqBC,iBAAiB;AACtC,SAASC,cAAc;AACvB,SAASC,UAAAA,eAAc;AAEvB,SA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yD,OAAO;QAAmB,CAAA;MACnD,OAAO;AACL,cAAMC,WAAW;UACfC,MAAMJ;QACR;AACApD,YAAIH,KAAK0D,QAAAA;MACX;IACF,CAAA,EACCE,MAAM,CAACC,OAAAA;AACN1D,UAAIqD,OAAO,GAAA,EAAKxD,KAAK;QAAEyD,OAAQI,GAAaC;MAAQ,CAAA;IACtD,CAAA;EACJ;EAEUtB,kBAAkB;;AAC1B,QAAI,KAAK1B,OAAOC,MAAM;AACpBF,MAAAA,UAAS,CAAC,KAAKjB,SAAS,MAAM,wBAAA;AAC9B,WAAKA,UAAU,KAAKC,IAAIkE,SAAO,UAAKjD,OAAOC,SAAZ,mBAAkBiD,SAAQ,IAAA;IAC3D;AACA,WAAO;EACT;EAEUrB,iBAAiB;AACzB,UAAMsB,SAASpD,UAAS,KAAKjB,SAAS,MAAM,oBAAA;AAC5CqE,WAAOC,MAAK;AACZ,SAAKtE,UAAUuE;AACf,WAAO;EACT;AACF;AA3HkE1E;AAA3D,IAAMD,aAAN;AAAMA,aAAAA,cAAAA;EADZ4E,iBAAAA;GACY5E,UAAAA;","names":["HttpBridgeConfigSchema","assertEx","exists","toJsonString","isQueryBoundWitness","creatableModule","resolveAddressToInstanceUp","express","assertEx","AxiosJson","exists","forget","toJsonString","AbstractBridge","NodeManifestPayloadSchema","creatableModule","ModuleStateQuerySchema","asAttachableNodeInstance","isPayloadOfSchemaType","Mutex","Semaphore","LRUCache","assertEx","isAddress","Account","AbstractBridgeModuleResolver","wrapModuleWithType","ConfigSchema","asModuleInstance","ModuleConfigSchema","ResolveHelper","forget","AbstractModuleProxy","HttpModuleProxy","AbstractModuleProxy","constructor","params","createCount","Math","floor","console","log","proxyQueryHandler","query","payloads","archiving","isAllowedArchivingQuery","schema","forget","storeToArchivists","result","querySender","sendBridgeQuery","moduleAddress","flat","HttpBridgeModuleResolver","AbstractBridgeModuleResolver","querySender","params","moduleUrl","address","URL","rootUrl","resolveHandler","id","options","parentResult","length","idParts","split","untransformedFirstPart","assertEx","shift","firstPart","ResolveHelper","transformModuleIdentifier","moduleAddress","isAddress","remainderParts","join","account","Account","randomSync","additionalSigners","archiving","config","schema","ModuleConfigSchema","host","onQuerySendFinished","onQuerySendStarted","logger","debug","proxy","HttpModuleProxy","state","configSchema","find","payload","ConfigSchema","setConfig","start","wrapped","wrapModuleWithType","instance","asModuleInstance","upResolver","add","downResolver","result","resolve","HttpBridgeBase","AbstractBridge","_axios","_discoverRootsMutex","Mutex","_failureTimeCache","LRUCache","max","maxFailureCacheSize","_querySemaphore","_resolver","axios","AxiosJson","clientUrl","assertEx","config","client","url","nodeUrl","failureRetryTime","defaultFailureRetryTime","maxConnections","defaultMaxConnections","maxPayloadSizeWarning","defaultMaxPayloadSizeWarning","querySemaphore","Semaphore","resolver","HttpBridgeModuleResolver","additionalSigners","archiving","resolveArchivists","resolveArchivingArchivists","bind","bridge","onQuerySendFinished","args","forget","emit","module","onQuerySendStarted","querySender","root","rootUrl","wrapperAccount","account","exposeHandler","_id","_options","Error","exposedHandler","getRoots","force","runExclusive","_roots","undefined","state","getRootState","logger","debug","length","nodeManifest","find","isPayloadOfSchemaType","NodeManifestPayloadSchema","mods","resolveRootNode","filter","exists","moduleUrl","address","URL","sendBridgeQuery","targetAddress","query","payloads","lastFailureTime","get","now","Date","timeSincePreviousFailure","delete","acquire","payloadSize","JSON","stringify","warn","moduleAddress","schema","href","result","post","status","error","data","ex","toJsonString","release","unexposeHandler","queryPayload","ModuleStateQuerySchema","boundQuery","bindQuery","response","toString","errors","message","rootModule","resolveHandler","at","constructor","name","rootNode","asAttachableNodeInstance","id","downResolver","addResolver","configSchemas","HttpBridgeConfigSchema","defaultConfigSchema","creatableModule","HttpBridge","HttpBridgeBase","_app","_exposedModules","_server","app","express","use","json","post","req","res","handlePost","exposeChild","mod","options","maxDepth","console","log","address","id","assertEx","config","host","push","WeakRef","children","publicChildren","logger","toJsonString","map","child","exposedChildren","Promise","all","required","flat","filter","exists","allExposed","exposedMod","exposeHandler","resolveAddressToInstanceUp","Error","exposedHandler","ref","deref","startHandler","startHttpServer","stopHandler","_timeout","stopHttpServer","unexposeHandler","find","callLocalModule","query","payloads","allPayloads","body","isQueryBoundWitness","payload","route","then","result","status","error","envelope","data","catch","ex","message","listen","port","server","close","undefined","creatableModule"]}
|
package/package.json
CHANGED
|
@@ -10,51 +10,55 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^3.5.
|
|
14
|
-
"@xylabs/axios": "^3.5.
|
|
15
|
-
"@xylabs/exists": "^3.5.
|
|
16
|
-
"@xylabs/forget": "^3.5.
|
|
17
|
-
"@xylabs/hex": "^3.5.
|
|
18
|
-
"@xylabs/object": "^3.5.
|
|
19
|
-
"@xylabs/promise": "^3.5.
|
|
20
|
-
"@xyo-network/account": "~2.
|
|
21
|
-
"@xyo-network/api-models": "~2.
|
|
22
|
-
"@xyo-network/boundwitness-model": "~2.
|
|
23
|
-
"@xyo-network/bridge-abstract": "~2.
|
|
24
|
-
"@xyo-network/bridge-model": "~2.
|
|
25
|
-
"@xyo-network/config-payload-plugin": "~2.
|
|
26
|
-
"@xyo-network/manifest-model": "~2.
|
|
27
|
-
"@xyo-network/module-model": "~2.
|
|
28
|
-
"@xyo-network/node-model": "~2.
|
|
29
|
-
"@xyo-network/payload-model": "~2.
|
|
13
|
+
"@xylabs/assert": "^3.5.1",
|
|
14
|
+
"@xylabs/axios": "^3.5.1",
|
|
15
|
+
"@xylabs/exists": "^3.5.1",
|
|
16
|
+
"@xylabs/forget": "^3.5.1",
|
|
17
|
+
"@xylabs/hex": "^3.5.1",
|
|
18
|
+
"@xylabs/object": "^3.5.1",
|
|
19
|
+
"@xylabs/promise": "^3.5.1",
|
|
20
|
+
"@xyo-network/account": "~2.104.0",
|
|
21
|
+
"@xyo-network/api-models": "~2.104.0",
|
|
22
|
+
"@xyo-network/boundwitness-model": "~2.104.0",
|
|
23
|
+
"@xyo-network/bridge-abstract": "~2.104.0",
|
|
24
|
+
"@xyo-network/bridge-model": "~2.104.0",
|
|
25
|
+
"@xyo-network/config-payload-plugin": "~2.104.0",
|
|
26
|
+
"@xyo-network/manifest-model": "~2.104.0",
|
|
27
|
+
"@xyo-network/module-model": "~2.104.0",
|
|
28
|
+
"@xyo-network/node-model": "~2.104.0",
|
|
29
|
+
"@xyo-network/payload-model": "~2.104.0",
|
|
30
30
|
"async-mutex": "^0.5.0",
|
|
31
31
|
"lru-cache": "^10.2.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
+
"@types/express": "^4.17.21",
|
|
34
35
|
"@xylabs/ts-scripts-yarn3": "^3.10.4",
|
|
35
36
|
"@xylabs/tsconfig": "^3.10.4",
|
|
36
|
-
"@xyo-network/account": "~2.
|
|
37
|
-
"@xyo-network/archivist-model": "~2.
|
|
38
|
-
"@xyo-network/diviner-model": "~2.
|
|
39
|
-
"@xyo-network/module-resolver": "~2.
|
|
40
|
-
"@xyo-network/node-memory": "~2.
|
|
41
|
-
"@xyo-network/node-model": "~2.
|
|
42
|
-
"@xyo-network/payload-builder": "~2.
|
|
43
|
-
"@xyo-network/payload-wrapper": "~2.
|
|
37
|
+
"@xyo-network/account": "~2.104.0",
|
|
38
|
+
"@xyo-network/archivist-model": "~2.104.0",
|
|
39
|
+
"@xyo-network/diviner-model": "~2.104.0",
|
|
40
|
+
"@xyo-network/module-resolver": "~2.104.0",
|
|
41
|
+
"@xyo-network/node-memory": "~2.104.0",
|
|
42
|
+
"@xyo-network/node-model": "~2.104.0",
|
|
43
|
+
"@xyo-network/payload-builder": "~2.104.0",
|
|
44
|
+
"@xyo-network/payload-wrapper": "~2.104.0",
|
|
45
|
+
"express": "^4.19.2",
|
|
44
46
|
"typescript": "^5.4.5"
|
|
45
47
|
},
|
|
48
|
+
"optionalDependencies": {
|
|
49
|
+
"express": "^4.19.2"
|
|
50
|
+
},
|
|
46
51
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
47
|
-
"types": "dist/node/index.d.ts",
|
|
48
52
|
"exports": {
|
|
49
53
|
".": {
|
|
50
54
|
"browser": {
|
|
51
55
|
"require": {
|
|
52
|
-
"types": "./dist/browser/index.d.cts",
|
|
53
|
-
"default": "./dist/browser/index.cjs"
|
|
56
|
+
"types": "./dist/browser/index-browser.d.cts",
|
|
57
|
+
"default": "./dist/browser/index-browser.cjs"
|
|
54
58
|
},
|
|
55
59
|
"import": {
|
|
56
|
-
"types": "./dist/browser/index.d.mts",
|
|
57
|
-
"default": "./dist/browser/index.js"
|
|
60
|
+
"types": "./dist/browser/index-browser.d.mts",
|
|
61
|
+
"default": "./dist/browser/index-browser.js"
|
|
58
62
|
}
|
|
59
63
|
},
|
|
60
64
|
"node": {
|
|
@@ -70,8 +74,9 @@
|
|
|
70
74
|
},
|
|
71
75
|
"./package.json": "./package.json"
|
|
72
76
|
},
|
|
73
|
-
"main": "dist/
|
|
74
|
-
"module": "dist/
|
|
77
|
+
"main": "dist/neutral/index-browser.cjs",
|
|
78
|
+
"module": "dist/neutral/index-browser.js",
|
|
79
|
+
"types": "dist/neutral/index-browser.d.ts",
|
|
75
80
|
"homepage": "https://xyo.network",
|
|
76
81
|
"license": "LGPL-3.0-only",
|
|
77
82
|
"publishConfig": {
|
|
@@ -82,6 +87,6 @@
|
|
|
82
87
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
83
88
|
},
|
|
84
89
|
"sideEffects": false,
|
|
85
|
-
"version": "2.
|
|
90
|
+
"version": "2.104.0",
|
|
86
91
|
"type": "module"
|
|
87
92
|
}
|
|
@@ -38,7 +38,7 @@ import { BridgeQuerySender } from './ModuleProxy'
|
|
|
38
38
|
export interface HttpBridgeParams extends BridgeParams<AnyConfigSchema<HttpBridgeConfig>> {}
|
|
39
39
|
|
|
40
40
|
@creatableModule()
|
|
41
|
-
export class
|
|
41
|
+
export class HttpBridgeBase<TParams extends HttpBridgeParams> extends AbstractBridge<TParams> implements BridgeModule<TParams>, BridgeQuerySender {
|
|
42
42
|
static override readonly configSchemas: Schema[] = [...super.configSchemas, HttpBridgeConfigSchema]
|
|
43
43
|
static override readonly defaultConfigSchema: Schema = HttpBridgeConfigSchema
|
|
44
44
|
static defaultFailureRetryTime = 1000 * 60
|
|
@@ -48,7 +48,7 @@ export class HttpBridge<TParams extends HttpBridgeParams> extends AbstractBridge
|
|
|
48
48
|
|
|
49
49
|
private _axios?: AxiosJson
|
|
50
50
|
private _discoverRootsMutex = new Mutex()
|
|
51
|
-
private _failureTimeCache = new LRUCache<Address, number>({ max:
|
|
51
|
+
private _failureTimeCache = new LRUCache<Address, number>({ max: HttpBridgeBase.maxFailureCacheSize })
|
|
52
52
|
private _querySemaphore?: Semaphore
|
|
53
53
|
private _resolver?: HttpBridgeModuleResolver
|
|
54
54
|
|
|
@@ -57,20 +57,21 @@ export class HttpBridge<TParams extends HttpBridgeParams> extends AbstractBridge
|
|
|
57
57
|
return this._axios
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
get clientUrl() {
|
|
61
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
62
|
+
return assertEx(this.config.client?.url ?? this.config.nodeUrl, () => 'No Url Set')
|
|
63
|
+
}
|
|
64
|
+
|
|
60
65
|
get failureRetryTime() {
|
|
61
|
-
return this.config.failureRetryTime ??
|
|
66
|
+
return this.config.failureRetryTime ?? HttpBridgeBase.defaultFailureRetryTime
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
get maxConnections() {
|
|
65
|
-
return this.config.maxConnections ??
|
|
70
|
+
return this.config.maxConnections ?? HttpBridgeBase.defaultMaxConnections
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
get maxPayloadSizeWarning() {
|
|
69
|
-
return this.config.maxPayloadSizeWarning ??
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
get nodeUrl() {
|
|
73
|
-
return assertEx(this.config.nodeUrl, () => 'No Url Set')
|
|
74
|
+
return this.config.maxPayloadSizeWarning ?? HttpBridgeBase.defaultMaxPayloadSizeWarning
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
get querySemaphore() {
|
|
@@ -93,7 +94,7 @@ export class HttpBridge<TParams extends HttpBridgeParams> extends AbstractBridge
|
|
|
93
94
|
},
|
|
94
95
|
querySender: this,
|
|
95
96
|
root: this,
|
|
96
|
-
rootUrl: this.
|
|
97
|
+
rootUrl: this.clientUrl,
|
|
97
98
|
wrapperAccount: this.account,
|
|
98
99
|
})
|
|
99
100
|
return this._resolver
|
|
@@ -126,7 +127,7 @@ export class HttpBridge<TParams extends HttpBridgeParams> extends AbstractBridge
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
moduleUrl(address: Address) {
|
|
129
|
-
return new URL(address, this.
|
|
130
|
+
return new URL(address, this.clientUrl)
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
async sendBridgeQuery<TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(
|
|
@@ -178,7 +179,7 @@ export class HttpBridge<TParams extends HttpBridgeParams> extends AbstractBridge
|
|
|
178
179
|
const queryPayload: ModuleStateQuery = { schema: ModuleStateQuerySchema }
|
|
179
180
|
const boundQuery = await this.bindQuery(queryPayload)
|
|
180
181
|
try {
|
|
181
|
-
const response = await this.axios.post<ApiEnvelope<ModuleQueryResult>>(this.
|
|
182
|
+
const response = await this.axios.post<ApiEnvelope<ModuleQueryResult>>(this.clientUrl.toString(), boundQuery)
|
|
182
183
|
if (response.status === 404) {
|
|
183
184
|
return []
|
|
184
185
|
}
|
|
@@ -189,7 +190,7 @@ export class HttpBridge<TParams extends HttpBridgeParams> extends AbstractBridge
|
|
|
189
190
|
return payloads
|
|
190
191
|
} catch (ex) {
|
|
191
192
|
const error = ex as Error
|
|
192
|
-
this.logger?.warn(`Unable to connect to remote node: ${error.message} [${this.
|
|
193
|
+
this.logger?.warn(`Unable to connect to remote node: ${error.message} [${this.clientUrl}]`)
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BridgeParams } from '@xyo-network/bridge-model'
|
|
2
|
+
import { AnyConfigSchema, creatableModule } from '@xyo-network/module-model'
|
|
3
|
+
|
|
4
|
+
import { HttpBridgeBase } from './HttpBridgeBase'
|
|
5
|
+
import { HttpBridgeConfig } from './HttpBridgeConfig'
|
|
6
|
+
|
|
7
|
+
export interface HttpBridgeParams extends BridgeParams<AnyConfigSchema<HttpBridgeConfig>> {}
|
|
8
|
+
|
|
9
|
+
@creatableModule()
|
|
10
|
+
export class HttpBridge<TParams extends HttpBridgeParams> extends HttpBridgeBase<TParams> {}
|
package/src/HttpBridgeConfig.ts
CHANGED
|
@@ -6,10 +6,17 @@ export const HttpBridgeConfigSchema: HttpBridgeConfigSchema = 'network.xyo.bridg
|
|
|
6
6
|
|
|
7
7
|
export type HttpBridgeConfig<TConfig extends EmptyObject = EmptyObject, TSchema extends string | void = void> = BridgeConfig<
|
|
8
8
|
{
|
|
9
|
+
client?: BridgeConfig['client'] & {
|
|
10
|
+
url: string
|
|
11
|
+
}
|
|
9
12
|
failureRetryTime?: number
|
|
10
13
|
failureTimeCacheMax?: number
|
|
14
|
+
host?: {
|
|
15
|
+
port: number
|
|
16
|
+
}
|
|
11
17
|
maxConnections?: number
|
|
12
18
|
maxPayloadSizeWarning?: number
|
|
19
|
+
/** @deprecated use client.url instead */
|
|
13
20
|
nodeUrl?: string
|
|
14
21
|
schema: HttpBridgeConfigSchema
|
|
15
22
|
} & TConfig,
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Server } from 'node:http'
|
|
2
|
+
|
|
3
|
+
import { assertEx } from '@xylabs/assert'
|
|
4
|
+
import { exists } from '@xylabs/exists'
|
|
5
|
+
import { Address } from '@xylabs/hex'
|
|
6
|
+
import { toJsonString } from '@xylabs/object'
|
|
7
|
+
import { ApiEnvelopeSuccess } from '@xyo-network/api-models'
|
|
8
|
+
import { isQueryBoundWitness, QueryBoundWitness } from '@xyo-network/boundwitness-model'
|
|
9
|
+
import { BridgeExposeOptions, BridgeParams, BridgeUnexposeOptions } from '@xyo-network/bridge-model'
|
|
10
|
+
import { AnyConfigSchema, creatableModule, ModuleInstance, ModuleQueryResult, resolveAddressToInstanceUp } from '@xyo-network/module-model'
|
|
11
|
+
import { Payload } from '@xyo-network/payload-model'
|
|
12
|
+
import express, { Application, Request, Response } from 'express'
|
|
13
|
+
|
|
14
|
+
import { HttpBridgeBase } from './HttpBridgeBase'
|
|
15
|
+
import { HttpBridgeConfig } from './HttpBridgeConfig'
|
|
16
|
+
|
|
17
|
+
export interface HttpBridgeParams extends BridgeParams<AnyConfigSchema<HttpBridgeConfig>> {}
|
|
18
|
+
|
|
19
|
+
@creatableModule()
|
|
20
|
+
export class HttpBridge<TParams extends HttpBridgeParams> extends HttpBridgeBase<TParams> {
|
|
21
|
+
protected _app?: Application
|
|
22
|
+
protected _exposedModules: WeakRef<ModuleInstance>[] = []
|
|
23
|
+
protected _server?: Server
|
|
24
|
+
|
|
25
|
+
get app() {
|
|
26
|
+
this._app =
|
|
27
|
+
this._app ??
|
|
28
|
+
(() => {
|
|
29
|
+
const app = express()
|
|
30
|
+
app.use(express.json())
|
|
31
|
+
|
|
32
|
+
app.post<Payload[]>('/', (req, res) => {
|
|
33
|
+
this.handlePost(req, res)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return app
|
|
37
|
+
})()
|
|
38
|
+
return this._app
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async exposeChild(mod: ModuleInstance, options?: BridgeExposeOptions | undefined): Promise<ModuleInstance[]> {
|
|
42
|
+
const { maxDepth = 5 } = options ?? {}
|
|
43
|
+
console.log(`exposeChild: ${mod.address} ${mod?.id} ${maxDepth}`)
|
|
44
|
+
assertEx(this.config.host, () => 'Not configured as a host')
|
|
45
|
+
this._exposedModules.push(new WeakRef(mod))
|
|
46
|
+
const children = maxDepth > 0 ? (await mod.publicChildren?.()) ?? [] : []
|
|
47
|
+
this.logger.log(`childrenToExpose [${mod.id}][${mod.address}]: ${toJsonString(children.map((child) => child.id))}`)
|
|
48
|
+
const exposedChildren = (await Promise.all(children.map((child) => this.exposeChild(child, { maxDepth: maxDepth - 1, required: false }))))
|
|
49
|
+
.flat()
|
|
50
|
+
.filter(exists)
|
|
51
|
+
const allExposed = [mod, ...exposedChildren]
|
|
52
|
+
|
|
53
|
+
for (const exposedMod of allExposed) this.logger?.log(`exposed: ${exposedMod.address} [${mod.id}]`)
|
|
54
|
+
|
|
55
|
+
return allExposed
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override async exposeHandler(address: Address, options?: BridgeExposeOptions | undefined): Promise<ModuleInstance[]> {
|
|
59
|
+
const { required = true } = options ?? {}
|
|
60
|
+
const mod = await resolveAddressToInstanceUp(this, address)
|
|
61
|
+
console.log(`exposeHandler: ${address} ${mod?.id}`)
|
|
62
|
+
if (required && !mod) {
|
|
63
|
+
throw new Error(`Unable to find required module: ${address}`)
|
|
64
|
+
}
|
|
65
|
+
if (mod) {
|
|
66
|
+
return this.exposeChild(mod, options)
|
|
67
|
+
}
|
|
68
|
+
return []
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
override exposedHandler(): Address[] {
|
|
72
|
+
return this._exposedModules.map((ref) => ref.deref()?.address).filter(exists)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override async startHandler(): Promise<boolean> {
|
|
76
|
+
return (await super.startHandler()) && this.startHttpServer()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
override async stopHandler(_timeout?: number | undefined): Promise<boolean> {
|
|
80
|
+
return (await super.stopHandler()) && this.stopHttpServer()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
override async unexposeHandler(address: Address, options?: BridgeUnexposeOptions | undefined): Promise<ModuleInstance[]> {
|
|
84
|
+
const { maxDepth = 2, required = true } = options ?? {}
|
|
85
|
+
assertEx(this.config.host, () => 'Not configured as a host')
|
|
86
|
+
const mod = this._exposedModules.find((ref) => ref.deref()?.address === address)?.deref()
|
|
87
|
+
assertEx(!required || mod, () => `Module not exposed: ${address}`)
|
|
88
|
+
this._exposedModules = this._exposedModules.filter((ref) => ref.deref()?.address !== address)
|
|
89
|
+
if (mod) {
|
|
90
|
+
const children = maxDepth > 0 ? (await mod.publicChildren?.()) ?? [] : []
|
|
91
|
+
const exposedChildren = (
|
|
92
|
+
await Promise.all(children.map((child) => this.unexposeHandler(child.address, { maxDepth: maxDepth - 1, required: false })))
|
|
93
|
+
)
|
|
94
|
+
.flat()
|
|
95
|
+
.filter(exists)
|
|
96
|
+
return [mod, ...exposedChildren]
|
|
97
|
+
}
|
|
98
|
+
return []
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
protected async callLocalModule(address: Address, query: QueryBoundWitness, payloads: Payload[]): Promise<ModuleQueryResult | null> {
|
|
102
|
+
const mod = this._exposedModules.find((ref) => ref.deref()?.address === address)?.deref()
|
|
103
|
+
if (mod) {
|
|
104
|
+
return await mod.query(query, payloads)
|
|
105
|
+
}
|
|
106
|
+
return null
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
protected handlePost(req: Request<Payload[]>, res: Response) {
|
|
110
|
+
const allPayloads = req.body as Payload[]
|
|
111
|
+
const query = allPayloads.find(isQueryBoundWitness) as QueryBoundWitness
|
|
112
|
+
const payloads = allPayloads.filter((payload) => !isQueryBoundWitness(payload))
|
|
113
|
+
this.callLocalModule(req.route, query, payloads)
|
|
114
|
+
.then((result) => {
|
|
115
|
+
if (result === null) {
|
|
116
|
+
res.status(404).json({ error: 'Module not found' })
|
|
117
|
+
} else {
|
|
118
|
+
const envelope = {
|
|
119
|
+
data: result,
|
|
120
|
+
} as ApiEnvelopeSuccess<ModuleQueryResult>
|
|
121
|
+
res.json(envelope)
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
.catch((ex) => {
|
|
125
|
+
res.status(500).json({ error: (ex as Error).message })
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
protected startHttpServer() {
|
|
130
|
+
if (this.config.host) {
|
|
131
|
+
assertEx(!this._server, () => 'Server already started')
|
|
132
|
+
this._server = this.app.listen(this.config.host?.port ?? 3030)
|
|
133
|
+
}
|
|
134
|
+
return true
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
protected stopHttpServer() {
|
|
138
|
+
const server = assertEx(this._server, () => 'Server not started')
|
|
139
|
+
server.close()
|
|
140
|
+
this._server = undefined
|
|
141
|
+
return true
|
|
142
|
+
}
|
|
143
|
+
}
|
package/src/index.ts
CHANGED
package/xy.config.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
|
|
2
|
+
const config: XyTsupConfig = {
|
|
3
|
+
compile: {
|
|
4
|
+
browser: {
|
|
5
|
+
src: { entry: ['./src/index-browser.ts'] },
|
|
6
|
+
},
|
|
7
|
+
neutral: {
|
|
8
|
+
src: { entry: ['./src/index-browser.ts'] },
|
|
9
|
+
},
|
|
10
|
+
node: {
|
|
11
|
+
src: { entry: ['./src/index.ts'] },
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line import/no-default-export
|
|
17
|
+
export default config
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpBridge.d.ts","sourceRoot":"","sources":["../../src/HttpBridge.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,SAAS,EAAE,MAAM,eAAe,CAAA;AAGrD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EACL,m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