@xyo-network/bridge-module-resolver 2.74.5 → 2.75.2

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 (70) hide show
  1. package/dist/browser/ModuleResolver.cjs +299 -0
  2. package/dist/browser/ModuleResolver.cjs.map +1 -0
  3. package/dist/browser/ModuleResolver.d.cts.map +1 -0
  4. package/dist/browser/ModuleResolver.d.mts.map +1 -0
  5. package/dist/browser/ModuleResolver.d.ts +30 -0
  6. package/dist/browser/ModuleResolver.d.ts.map +1 -0
  7. package/dist/browser/ModuleResolver.js +170 -0
  8. package/dist/browser/ModuleResolver.js.map +1 -0
  9. package/dist/browser/ProxyModule.cjs +131 -0
  10. package/dist/browser/ProxyModule.cjs.map +1 -0
  11. package/dist/browser/ProxyModule.d.cts.map +1 -0
  12. package/dist/browser/ProxyModule.d.mts.map +1 -0
  13. package/dist/browser/ProxyModule.d.ts +84 -0
  14. package/dist/browser/ProxyModule.d.ts.map +1 -0
  15. package/dist/browser/ProxyModule.js +112 -0
  16. package/dist/browser/ProxyModule.js.map +1 -0
  17. package/dist/{index.js → browser/index.cjs} +1 -7
  18. package/dist/browser/index.cjs.map +1 -0
  19. package/dist/browser/index.d.cts.map +1 -0
  20. package/dist/browser/index.d.mts.map +1 -0
  21. package/dist/browser/index.d.ts +3 -0
  22. package/dist/browser/index.d.ts.map +1 -0
  23. package/dist/browser/index.js +3 -0
  24. package/dist/browser/index.js.map +1 -0
  25. package/dist/docs.json +747 -747
  26. package/dist/node/ModuleResolver.d.cts +30 -0
  27. package/dist/node/ModuleResolver.d.cts.map +1 -0
  28. package/dist/node/ModuleResolver.d.mts +30 -0
  29. package/dist/node/ModuleResolver.d.mts.map +1 -0
  30. package/dist/node/ModuleResolver.d.ts +30 -0
  31. package/dist/node/ModuleResolver.d.ts.map +1 -0
  32. package/dist/node/ModuleResolver.js +303 -0
  33. package/dist/node/ModuleResolver.js.map +1 -0
  34. package/dist/node/ModuleResolver.mjs +281 -0
  35. package/dist/node/ModuleResolver.mjs.map +1 -0
  36. package/dist/node/ProxyModule.d.cts +84 -0
  37. package/dist/node/ProxyModule.d.cts.map +1 -0
  38. package/dist/node/ProxyModule.d.mts +84 -0
  39. package/dist/node/ProxyModule.d.mts.map +1 -0
  40. package/dist/node/ProxyModule.d.ts +84 -0
  41. package/dist/node/ProxyModule.d.ts.map +1 -0
  42. package/dist/node/ProxyModule.js +136 -0
  43. package/dist/node/ProxyModule.js.map +1 -0
  44. package/dist/node/ProxyModule.mjs +113 -0
  45. package/dist/node/ProxyModule.mjs.map +1 -0
  46. package/dist/node/index.d.cts +3 -0
  47. package/dist/node/index.d.cts.map +1 -0
  48. package/dist/node/index.d.mts +3 -0
  49. package/dist/node/index.d.mts.map +1 -0
  50. package/dist/node/index.d.ts +3 -0
  51. package/dist/node/index.d.ts.map +1 -0
  52. package/dist/node/index.js +309 -0
  53. package/dist/node/index.js.map +1 -0
  54. package/dist/{index.mjs → node/index.mjs} +9 -9
  55. package/dist/node/index.mjs.map +1 -0
  56. package/package.json +45 -42
  57. package/dist/ModuleResolver.d.mts.map +0 -1
  58. package/dist/ModuleResolver.d.ts.map +0 -1
  59. package/dist/ProxyModule.d.mts.map +0 -1
  60. package/dist/ProxyModule.d.ts.map +0 -1
  61. package/dist/index.d.mts.map +0 -1
  62. package/dist/index.d.ts.map +0 -1
  63. package/dist/index.js.map +0 -1
  64. package/dist/index.mjs.map +0 -1
  65. /package/dist/{ModuleResolver.d.mts → browser/ModuleResolver.d.cts} +0 -0
  66. /package/dist/{ModuleResolver.d.ts → browser/ModuleResolver.d.mts} +0 -0
  67. /package/dist/{ProxyModule.d.mts → browser/ProxyModule.d.cts} +0 -0
  68. /package/dist/{ProxyModule.d.ts → browser/ProxyModule.d.mts} +0 -0
  69. /package/dist/{index.d.mts → browser/index.d.cts} +0 -0
  70. /package/dist/{index.d.ts → browser/index.d.mts} +0 -0
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/ProxyModule.ts
21
+ var ProxyModule_exports = {};
22
+ __export(ProxyModule_exports, {
23
+ ProxyModule: () => ProxyModule,
24
+ ProxyModuleConfigSchema: () => ProxyModuleConfigSchema
25
+ });
26
+ module.exports = __toCommonJS(ProxyModule_exports);
27
+ var import_assert = require("@xylabs/assert");
28
+ var import_lodash = require("@xylabs/lodash");
29
+ var import_address_payload_plugin = require("@xyo-network/address-payload-plugin");
30
+ var import_manifest_model = require("@xyo-network/manifest-model");
31
+ var import_module = require("@xyo-network/module");
32
+ var ProxyModuleConfigSchema = "network.xyo.module.proxy.config";
33
+ var ProxyModule = class extends import_module.BaseEmitter {
34
+ constructor(proxyParams) {
35
+ super({ config: proxyParams.bridge.targetConfig(proxyParams.address) });
36
+ this.proxyParams = proxyParams;
37
+ }
38
+ upResolver = new import_module.CompositeModuleResolver();
39
+ _busyCount = 0;
40
+ get address() {
41
+ return this.proxyParams.address.toLowerCase();
42
+ }
43
+ get bridge() {
44
+ return this.proxyParams.bridge;
45
+ }
46
+ get config() {
47
+ const config = this.bridge.targetConfig(this.address);
48
+ return config;
49
+ }
50
+ get downResolver() {
51
+ return (0, import_assert.assertEx)(this.bridge.targetDownResolver(this.address), "Unable to get resolver");
52
+ }
53
+ get queries() {
54
+ return this.bridge.targetQueries(this.address);
55
+ }
56
+ addressPreviousHash() {
57
+ throw Error("Not Implemented");
58
+ }
59
+ async busy(closure) {
60
+ if (this._busyCount <= 0) {
61
+ this._busyCount = 0;
62
+ const args = { busy: true, module: this };
63
+ await this.emit("moduleBusy", args);
64
+ }
65
+ this._busyCount++;
66
+ try {
67
+ return await closure();
68
+ } finally {
69
+ this._busyCount--;
70
+ if (this._busyCount <= 0) {
71
+ this._busyCount = 0;
72
+ const args = { busy: false, module: this };
73
+ await this.emit("moduleBusy", args);
74
+ }
75
+ }
76
+ }
77
+ async describe() {
78
+ return await this.busy(async () => {
79
+ const description = {
80
+ address: this.address,
81
+ queries: this.queries
82
+ };
83
+ if (this.config.name) {
84
+ description.name = this.config.name;
85
+ }
86
+ const discover = await this.discover();
87
+ description.children = (0, import_lodash.compact)(
88
+ (discover == null ? void 0 : discover.map((payload) => {
89
+ const address = payload.schema === import_address_payload_plugin.AddressSchema ? payload.address : void 0;
90
+ return address != this.address ? address : void 0;
91
+ })) ?? []
92
+ );
93
+ return description;
94
+ });
95
+ }
96
+ async discover() {
97
+ return await this.busy(async () => {
98
+ return await this.bridge.targetDiscover();
99
+ });
100
+ }
101
+ manifest() {
102
+ const name = this.config.name ?? "Anonymous";
103
+ return { config: { name, ...this.config }, schema: import_manifest_model.ManifestPayloadSchema };
104
+ }
105
+ moduleAddress() {
106
+ throw Error("Not Implemented");
107
+ }
108
+ previousHash() {
109
+ throw Error("Not Implemented");
110
+ }
111
+ async query(query, payloads) {
112
+ return await this.busy(async () => {
113
+ const result = (0, import_assert.assertEx)(await this.bridge.targetQuery(this.address, query, payloads), "Remote Query Failed");
114
+ await this.emit("moduleQueried", { module: this, payloads, query, result });
115
+ return result;
116
+ });
117
+ }
118
+ async queryable(query, payloads, queryConfig) {
119
+ return await this.bridge.targetQueryable(this.address, query, payloads, queryConfig);
120
+ }
121
+ async resolve(nameOrAddressOrFilter, options) {
122
+ return await this.busy(async () => {
123
+ if (typeof nameOrAddressOrFilter === "string") {
124
+ return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options);
125
+ } else {
126
+ return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options);
127
+ }
128
+ });
129
+ }
130
+ };
131
+ // Annotate the CommonJS export names for ESM import in node:
132
+ 0 && (module.exports = {
133
+ ProxyModule,
134
+ ProxyModuleConfigSchema
135
+ });
136
+ //# sourceMappingURL=ProxyModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ProxyModule.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { compact } from '@xylabs/lodash'\nimport { AddressPayload, AddressSchema } from '@xyo-network/address-payload-plugin'\nimport { QueryBoundWitness } from '@xyo-network/boundwitness-builder'\nimport { BridgeModule } from '@xyo-network/bridge-model'\nimport { ManifestPayloadSchema, ModuleManifestPayload } from '@xyo-network/manifest-model'\nimport {\n AddressPreviousHashPayload,\n BaseEmitter,\n CompositeModuleResolver,\n ModuleBusyEventArgs,\n ModuleConfig,\n ModuleDescription,\n ModuleEventData,\n ModuleFilter,\n ModuleFilterOptions,\n ModuleInstance,\n ModuleParams,\n ModuleQueryResult,\n} from '@xyo-network/module'\nimport { Payload } from '@xyo-network/payload-model'\nimport { Promisable } from '@xyo-network/promise'\n\nexport type ProxyModuleConfigSchema = 'network.xyo.module.proxy.config'\nexport const ProxyModuleConfigSchema: ProxyModuleConfigSchema = 'network.xyo.module.proxy.config'\n\nexport type TProxyModuleConfig = ModuleConfig<{ schema: ProxyModuleConfigSchema }>\n\nexport type ProxyModuleParams = ModuleParams<\n TProxyModuleConfig,\n {\n address: string\n bridge: BridgeModule\n }\n>\n\nexport class ProxyModule extends BaseEmitter<ModuleParams, ModuleEventData> implements ModuleInstance<ModuleParams, ModuleEventData> {\n readonly upResolver = new CompositeModuleResolver()\n\n private _busyCount = 0\n\n constructor(public proxyParams: ProxyModuleParams) {\n super({ config: proxyParams.bridge.targetConfig(proxyParams.address) })\n }\n\n get address() {\n return this.proxyParams.address.toLowerCase()\n }\n\n get bridge() {\n return this.proxyParams.bridge\n }\n\n get config(): ModuleConfig {\n const config = this.bridge.targetConfig(this.address)\n return config\n }\n\n get downResolver() {\n return assertEx(this.bridge.targetDownResolver(this.address), 'Unable to get resolver')\n }\n\n get queries() {\n return this.bridge.targetQueries(this.address)\n }\n\n addressPreviousHash(): Promise<AddressPreviousHashPayload> {\n throw Error('Not Implemented')\n }\n\n async busy<R>(closure: () => Promise<R>) {\n if (this._busyCount <= 0) {\n this._busyCount = 0\n const args: ModuleBusyEventArgs = { busy: true, module: this }\n await this.emit('moduleBusy', args)\n }\n this._busyCount++\n try {\n return await closure()\n } finally {\n this._busyCount--\n if (this._busyCount <= 0) {\n this._busyCount = 0\n const args: ModuleBusyEventArgs = { busy: false, module: this }\n await this.emit('moduleBusy', args)\n }\n }\n }\n\n async describe(): Promise<ModuleDescription> {\n return await this.busy(async () => {\n const description: ModuleDescription = {\n address: this.address,\n queries: this.queries,\n }\n if (this.config.name) {\n description.name = this.config.name\n }\n\n const discover = await this.discover()\n\n description.children = compact(\n discover?.map((payload) => {\n const address = payload.schema === AddressSchema ? (payload as AddressPayload).address : undefined\n return address != this.address ? address : undefined\n }) ?? [],\n )\n\n return description\n })\n }\n\n async discover(): Promise<Payload[]> {\n return await this.busy(async () => {\n return await this.bridge.targetDiscover()\n })\n }\n\n manifest(): Promisable<ModuleManifestPayload> {\n const name = this.config.name ?? 'Anonymous'\n return { config: { name, ...this.config }, schema: ManifestPayloadSchema }\n }\n\n moduleAddress(): Promise<AddressPreviousHashPayload[]> {\n throw Error('Not Implemented')\n }\n\n previousHash(): Promise<string | undefined> {\n throw Error('Not Implemented')\n }\n\n async query<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads?: Payload[]): Promise<ModuleQueryResult> {\n return await this.busy(async () => {\n const result = assertEx(await this.bridge.targetQuery(this.address, query, payloads), 'Remote Query Failed')\n await this.emit('moduleQueried', { module: this, payloads, query, result })\n return result\n })\n }\n\n async queryable(query: QueryBoundWitness, payloads?: Payload[], queryConfig?: ModuleConfig): Promise<boolean> {\n return await this.bridge.targetQueryable(this.address, query, payloads, queryConfig)\n }\n\n /* Resolves a filter from the perspective of the module, including through the parent/gateway module */\n resolve(filter?: ModuleFilter, options?: ModuleFilterOptions): Promise<ModuleInstance[]>\n resolve(nameOrAddress: string, options?: ModuleFilterOptions): Promise<ModuleInstance | undefined>\n async resolve(\n nameOrAddressOrFilter?: ModuleFilter | string,\n options?: ModuleFilterOptions,\n ): Promise<ModuleInstance | ModuleInstance[] | undefined> {\n return await this.busy(async () => {\n if (typeof nameOrAddressOrFilter === 'string') {\n return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options)\n } else {\n return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options)\n }\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,oBAAwB;AACxB,oCAA8C;AAG9C,4BAA6D;AAC7D,oBAaO;AAKA,IAAM,0BAAmD;AAYzD,IAAM,cAAN,cAA0B,0BAAoG;AAAA,EAKnI,YAAmB,aAAgC;AACjD,UAAM,EAAE,QAAQ,YAAY,OAAO,aAAa,YAAY,OAAO,EAAE,CAAC;AADrD;AAAA,EAEnB;AAAA,EANS,aAAa,IAAI,sCAAwB;AAAA,EAE1C,aAAa;AAAA,EAMrB,IAAI,UAAU;AACZ,WAAO,KAAK,YAAY,QAAQ,YAAY;AAAA,EAC9C;AAAA,EAEA,IAAI,SAAS;AACX,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEA,IAAI,SAAuB;AACzB,UAAM,SAAS,KAAK,OAAO,aAAa,KAAK,OAAO;AACpD,WAAO;AAAA,EACT;AAAA,EAEA,IAAI,eAAe;AACjB,eAAO,wBAAS,KAAK,OAAO,mBAAmB,KAAK,OAAO,GAAG,wBAAwB;AAAA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C,WAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,OAAO,GAAG,QAAQ,4CAAsB;AAAA,EAC3E;AAAA,EAEA,gBAAuD;AACrD,UAAM,MAAM,iBAAiB;AAAA,EAC/B;AAAA,EAEA,eAA4C;AAC1C,UAAM,MAAM,iBAAiB;AAAA,EAC/B;AAAA,EAEA,MAAM,MAAuD,OAAU,UAAkD;AACvH,WAAO,MAAM,KAAK,KAAK,YAAY;AACjC,YAAM,aAAS,wBAAS,MAAM,KAAK,OAAO,YAAY,KAAK,SAAS,OAAO,QAAQ,GAAG,qBAAqB;AAC3G,YAAM,KAAK,KAAK,iBAAiB,EAAE,QAAQ,MAAM,UAAU,OAAO,OAAO,CAAC;AAC1E,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,UAAU,OAA0B,UAAsB,aAA8C;AAC5G,WAAO,MAAM,KAAK,OAAO,gBAAgB,KAAK,SAAS,OAAO,UAAU,WAAW;AAAA,EACrF;AAAA,EAKA,MAAM,QACJ,uBACA,SACwD;AACxD,WAAO,MAAM,KAAK,KAAK,YAAY;AACjC,UAAI,OAAO,0BAA0B,UAAU;AAC7C,eAAO,MAAM,KAAK,OAAO,cAAc,KAAK,SAAS,uBAAuB,OAAO;AAAA,MACrF,OAAO;AACL,eAAO,MAAM,KAAK,OAAO,cAAc,KAAK,SAAS,uBAAuB,OAAO;AAAA,MACrF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -0,0 +1,113 @@
1
+ // src/ProxyModule.ts
2
+ import { assertEx } from "@xylabs/assert";
3
+ import { compact } from "@xylabs/lodash";
4
+ import { AddressSchema } from "@xyo-network/address-payload-plugin";
5
+ import { ManifestPayloadSchema } from "@xyo-network/manifest-model";
6
+ import {
7
+ BaseEmitter,
8
+ CompositeModuleResolver
9
+ } from "@xyo-network/module";
10
+ var ProxyModuleConfigSchema = "network.xyo.module.proxy.config";
11
+ var ProxyModule = class extends BaseEmitter {
12
+ constructor(proxyParams) {
13
+ super({ config: proxyParams.bridge.targetConfig(proxyParams.address) });
14
+ this.proxyParams = proxyParams;
15
+ }
16
+ upResolver = new CompositeModuleResolver();
17
+ _busyCount = 0;
18
+ get address() {
19
+ return this.proxyParams.address.toLowerCase();
20
+ }
21
+ get bridge() {
22
+ return this.proxyParams.bridge;
23
+ }
24
+ get config() {
25
+ const config = this.bridge.targetConfig(this.address);
26
+ return config;
27
+ }
28
+ get downResolver() {
29
+ return assertEx(this.bridge.targetDownResolver(this.address), "Unable to get resolver");
30
+ }
31
+ get queries() {
32
+ return this.bridge.targetQueries(this.address);
33
+ }
34
+ addressPreviousHash() {
35
+ throw Error("Not Implemented");
36
+ }
37
+ async busy(closure) {
38
+ if (this._busyCount <= 0) {
39
+ this._busyCount = 0;
40
+ const args = { busy: true, module: this };
41
+ await this.emit("moduleBusy", args);
42
+ }
43
+ this._busyCount++;
44
+ try {
45
+ return await closure();
46
+ } finally {
47
+ this._busyCount--;
48
+ if (this._busyCount <= 0) {
49
+ this._busyCount = 0;
50
+ const args = { busy: false, module: this };
51
+ await this.emit("moduleBusy", args);
52
+ }
53
+ }
54
+ }
55
+ async describe() {
56
+ return await this.busy(async () => {
57
+ const description = {
58
+ address: this.address,
59
+ queries: this.queries
60
+ };
61
+ if (this.config.name) {
62
+ description.name = this.config.name;
63
+ }
64
+ const discover = await this.discover();
65
+ description.children = compact(
66
+ (discover == null ? void 0 : discover.map((payload) => {
67
+ const address = payload.schema === AddressSchema ? payload.address : void 0;
68
+ return address != this.address ? address : void 0;
69
+ })) ?? []
70
+ );
71
+ return description;
72
+ });
73
+ }
74
+ async discover() {
75
+ return await this.busy(async () => {
76
+ return await this.bridge.targetDiscover();
77
+ });
78
+ }
79
+ manifest() {
80
+ const name = this.config.name ?? "Anonymous";
81
+ return { config: { name, ...this.config }, schema: ManifestPayloadSchema };
82
+ }
83
+ moduleAddress() {
84
+ throw Error("Not Implemented");
85
+ }
86
+ previousHash() {
87
+ throw Error("Not Implemented");
88
+ }
89
+ async query(query, payloads) {
90
+ return await this.busy(async () => {
91
+ const result = assertEx(await this.bridge.targetQuery(this.address, query, payloads), "Remote Query Failed");
92
+ await this.emit("moduleQueried", { module: this, payloads, query, result });
93
+ return result;
94
+ });
95
+ }
96
+ async queryable(query, payloads, queryConfig) {
97
+ return await this.bridge.targetQueryable(this.address, query, payloads, queryConfig);
98
+ }
99
+ async resolve(nameOrAddressOrFilter, options) {
100
+ return await this.busy(async () => {
101
+ if (typeof nameOrAddressOrFilter === "string") {
102
+ return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options);
103
+ } else {
104
+ return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options);
105
+ }
106
+ });
107
+ }
108
+ };
109
+ export {
110
+ ProxyModule,
111
+ ProxyModuleConfigSchema
112
+ };
113
+ //# sourceMappingURL=ProxyModule.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ProxyModule.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { compact } from '@xylabs/lodash'\nimport { AddressPayload, AddressSchema } from '@xyo-network/address-payload-plugin'\nimport { QueryBoundWitness } from '@xyo-network/boundwitness-builder'\nimport { BridgeModule } from '@xyo-network/bridge-model'\nimport { ManifestPayloadSchema, ModuleManifestPayload } from '@xyo-network/manifest-model'\nimport {\n AddressPreviousHashPayload,\n BaseEmitter,\n CompositeModuleResolver,\n ModuleBusyEventArgs,\n ModuleConfig,\n ModuleDescription,\n ModuleEventData,\n ModuleFilter,\n ModuleFilterOptions,\n ModuleInstance,\n ModuleParams,\n ModuleQueryResult,\n} from '@xyo-network/module'\nimport { Payload } from '@xyo-network/payload-model'\nimport { Promisable } from '@xyo-network/promise'\n\nexport type ProxyModuleConfigSchema = 'network.xyo.module.proxy.config'\nexport const ProxyModuleConfigSchema: ProxyModuleConfigSchema = 'network.xyo.module.proxy.config'\n\nexport type TProxyModuleConfig = ModuleConfig<{ schema: ProxyModuleConfigSchema }>\n\nexport type ProxyModuleParams = ModuleParams<\n TProxyModuleConfig,\n {\n address: string\n bridge: BridgeModule\n }\n>\n\nexport class ProxyModule extends BaseEmitter<ModuleParams, ModuleEventData> implements ModuleInstance<ModuleParams, ModuleEventData> {\n readonly upResolver = new CompositeModuleResolver()\n\n private _busyCount = 0\n\n constructor(public proxyParams: ProxyModuleParams) {\n super({ config: proxyParams.bridge.targetConfig(proxyParams.address) })\n }\n\n get address() {\n return this.proxyParams.address.toLowerCase()\n }\n\n get bridge() {\n return this.proxyParams.bridge\n }\n\n get config(): ModuleConfig {\n const config = this.bridge.targetConfig(this.address)\n return config\n }\n\n get downResolver() {\n return assertEx(this.bridge.targetDownResolver(this.address), 'Unable to get resolver')\n }\n\n get queries() {\n return this.bridge.targetQueries(this.address)\n }\n\n addressPreviousHash(): Promise<AddressPreviousHashPayload> {\n throw Error('Not Implemented')\n }\n\n async busy<R>(closure: () => Promise<R>) {\n if (this._busyCount <= 0) {\n this._busyCount = 0\n const args: ModuleBusyEventArgs = { busy: true, module: this }\n await this.emit('moduleBusy', args)\n }\n this._busyCount++\n try {\n return await closure()\n } finally {\n this._busyCount--\n if (this._busyCount <= 0) {\n this._busyCount = 0\n const args: ModuleBusyEventArgs = { busy: false, module: this }\n await this.emit('moduleBusy', args)\n }\n }\n }\n\n async describe(): Promise<ModuleDescription> {\n return await this.busy(async () => {\n const description: ModuleDescription = {\n address: this.address,\n queries: this.queries,\n }\n if (this.config.name) {\n description.name = this.config.name\n }\n\n const discover = await this.discover()\n\n description.children = compact(\n discover?.map((payload) => {\n const address = payload.schema === AddressSchema ? (payload as AddressPayload).address : undefined\n return address != this.address ? address : undefined\n }) ?? [],\n )\n\n return description\n })\n }\n\n async discover(): Promise<Payload[]> {\n return await this.busy(async () => {\n return await this.bridge.targetDiscover()\n })\n }\n\n manifest(): Promisable<ModuleManifestPayload> {\n const name = this.config.name ?? 'Anonymous'\n return { config: { name, ...this.config }, schema: ManifestPayloadSchema }\n }\n\n moduleAddress(): Promise<AddressPreviousHashPayload[]> {\n throw Error('Not Implemented')\n }\n\n previousHash(): Promise<string | undefined> {\n throw Error('Not Implemented')\n }\n\n async query<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads?: Payload[]): Promise<ModuleQueryResult> {\n return await this.busy(async () => {\n const result = assertEx(await this.bridge.targetQuery(this.address, query, payloads), 'Remote Query Failed')\n await this.emit('moduleQueried', { module: this, payloads, query, result })\n return result\n })\n }\n\n async queryable(query: QueryBoundWitness, payloads?: Payload[], queryConfig?: ModuleConfig): Promise<boolean> {\n return await this.bridge.targetQueryable(this.address, query, payloads, queryConfig)\n }\n\n /* Resolves a filter from the perspective of the module, including through the parent/gateway module */\n resolve(filter?: ModuleFilter, options?: ModuleFilterOptions): Promise<ModuleInstance[]>\n resolve(nameOrAddress: string, options?: ModuleFilterOptions): Promise<ModuleInstance | undefined>\n async resolve(\n nameOrAddressOrFilter?: ModuleFilter | string,\n options?: ModuleFilterOptions,\n ): Promise<ModuleInstance | ModuleInstance[] | undefined> {\n return await this.busy(async () => {\n if (typeof nameOrAddressOrFilter === 'string') {\n return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options)\n } else {\n return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options)\n }\n })\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAyB,qBAAqB;AAG9C,SAAS,6BAAoD;AAC7D;AAAA,EAEE;AAAA,EACA;AAAA,OAUK;AAKA,IAAM,0BAAmD;AAYzD,IAAM,cAAN,cAA0B,YAAoG;AAAA,EAKnI,YAAmB,aAAgC;AACjD,UAAM,EAAE,QAAQ,YAAY,OAAO,aAAa,YAAY,OAAO,EAAE,CAAC;AADrD;AAAA,EAEnB;AAAA,EANS,aAAa,IAAI,wBAAwB;AAAA,EAE1C,aAAa;AAAA,EAMrB,IAAI,UAAU;AACZ,WAAO,KAAK,YAAY,QAAQ,YAAY;AAAA,EAC9C;AAAA,EAEA,IAAI,SAAS;AAC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0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './ModuleResolver';
2
+ export * from './ProxyModule';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './ModuleResolver';
2
+ export * from './ProxyModule';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA"}
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ BridgeModuleResolver: () => BridgeModuleResolver,
24
+ ProxyModule: () => ProxyModule,
25
+ ProxyModuleConfigSchema: () => ProxyModuleConfigSchema
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/ModuleResolver.ts
30
+ var import_lodash2 = require("@xylabs/lodash");
31
+ var import_address_payload_plugin2 = require("@xyo-network/address-payload-plugin");
32
+ var import_archivist_model = require("@xyo-network/archivist-model");
33
+ var import_archivist_wrapper = require("@xyo-network/archivist-wrapper");
34
+ var import_diviner = require("@xyo-network/diviner");
35
+ var import_diviner_model = require("@xyo-network/diviner-model");
36
+ var import_error = require("@xyo-network/error");
37
+ var import_module2 = require("@xyo-network/module");
38
+ var import_node_model = require("@xyo-network/node-model");
39
+ var import_node_wrapper = require("@xyo-network/node-wrapper");
40
+ var import_sentinel = require("@xyo-network/sentinel");
41
+ var import_witness_model = require("@xyo-network/witness-model");
42
+ var import_witness_wrapper = require("@xyo-network/witness-wrapper");
43
+
44
+ // src/ProxyModule.ts
45
+ var import_assert = require("@xylabs/assert");
46
+ var import_lodash = require("@xylabs/lodash");
47
+ var import_address_payload_plugin = require("@xyo-network/address-payload-plugin");
48
+ var import_manifest_model = require("@xyo-network/manifest-model");
49
+ var import_module = require("@xyo-network/module");
50
+ var ProxyModuleConfigSchema = "network.xyo.module.proxy.config";
51
+ var ProxyModule = class extends import_module.BaseEmitter {
52
+ constructor(proxyParams) {
53
+ super({ config: proxyParams.bridge.targetConfig(proxyParams.address) });
54
+ this.proxyParams = proxyParams;
55
+ }
56
+ upResolver = new import_module.CompositeModuleResolver();
57
+ _busyCount = 0;
58
+ get address() {
59
+ return this.proxyParams.address.toLowerCase();
60
+ }
61
+ get bridge() {
62
+ return this.proxyParams.bridge;
63
+ }
64
+ get config() {
65
+ const config = this.bridge.targetConfig(this.address);
66
+ return config;
67
+ }
68
+ get downResolver() {
69
+ return (0, import_assert.assertEx)(this.bridge.targetDownResolver(this.address), "Unable to get resolver");
70
+ }
71
+ get queries() {
72
+ return this.bridge.targetQueries(this.address);
73
+ }
74
+ addressPreviousHash() {
75
+ throw Error("Not Implemented");
76
+ }
77
+ async busy(closure) {
78
+ if (this._busyCount <= 0) {
79
+ this._busyCount = 0;
80
+ const args = { busy: true, module: this };
81
+ await this.emit("moduleBusy", args);
82
+ }
83
+ this._busyCount++;
84
+ try {
85
+ return await closure();
86
+ } finally {
87
+ this._busyCount--;
88
+ if (this._busyCount <= 0) {
89
+ this._busyCount = 0;
90
+ const args = { busy: false, module: this };
91
+ await this.emit("moduleBusy", args);
92
+ }
93
+ }
94
+ }
95
+ async describe() {
96
+ return await this.busy(async () => {
97
+ const description = {
98
+ address: this.address,
99
+ queries: this.queries
100
+ };
101
+ if (this.config.name) {
102
+ description.name = this.config.name;
103
+ }
104
+ const discover = await this.discover();
105
+ description.children = (0, import_lodash.compact)(
106
+ (discover == null ? void 0 : discover.map((payload) => {
107
+ const address = payload.schema === import_address_payload_plugin.AddressSchema ? payload.address : void 0;
108
+ return address != this.address ? address : void 0;
109
+ })) ?? []
110
+ );
111
+ return description;
112
+ });
113
+ }
114
+ async discover() {
115
+ return await this.busy(async () => {
116
+ return await this.bridge.targetDiscover();
117
+ });
118
+ }
119
+ manifest() {
120
+ const name = this.config.name ?? "Anonymous";
121
+ return { config: { name, ...this.config }, schema: import_manifest_model.ManifestPayloadSchema };
122
+ }
123
+ moduleAddress() {
124
+ throw Error("Not Implemented");
125
+ }
126
+ previousHash() {
127
+ throw Error("Not Implemented");
128
+ }
129
+ async query(query, payloads) {
130
+ return await this.busy(async () => {
131
+ const result = (0, import_assert.assertEx)(await this.bridge.targetQuery(this.address, query, payloads), "Remote Query Failed");
132
+ await this.emit("moduleQueried", { module: this, payloads, query, result });
133
+ return result;
134
+ });
135
+ }
136
+ async queryable(query, payloads, queryConfig) {
137
+ return await this.bridge.targetQueryable(this.address, query, payloads, queryConfig);
138
+ }
139
+ async resolve(nameOrAddressOrFilter, options) {
140
+ return await this.busy(async () => {
141
+ if (typeof nameOrAddressOrFilter === "string") {
142
+ return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options);
143
+ } else {
144
+ return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options);
145
+ }
146
+ });
147
+ }
148
+ };
149
+
150
+ // src/ModuleResolver.ts
151
+ var BridgeModuleResolver = class _BridgeModuleResolver extends import_module2.CompositeModuleResolver {
152
+ // TODO: Allow optional ctor param for supplying address for nested Nodes
153
+ // protected readonly address?: string,
154
+ constructor(bridge, wrapperAccount) {
155
+ super();
156
+ this.bridge = bridge;
157
+ this.wrapperAccount = wrapperAccount;
158
+ }
159
+ primed = void 0;
160
+ remoteAddresses;
161
+ resolvedModules = {};
162
+ get isModuleResolver() {
163
+ return true;
164
+ }
165
+ add(_module) {
166
+ throw new Error("Method not implemented.");
167
+ }
168
+ async currentResolvedModules() {
169
+ const result = {};
170
+ await Promise.all(
171
+ Object.entries(this.resolvedModules).map(async ([key, value]) => {
172
+ result[key] = await value;
173
+ })
174
+ );
175
+ return result;
176
+ }
177
+ async getRemoteAddresses() {
178
+ this.remoteAddresses = this.remoteAddresses ?? (async () => {
179
+ const discover = await this.bridge.targetDiscover();
180
+ return (0, import_lodash2.compact)(
181
+ discover == null ? void 0 : discover.map((payload) => {
182
+ if (payload.schema === import_address_payload_plugin2.AddressSchema) {
183
+ const schemaPayload = payload;
184
+ return schemaPayload.address;
185
+ } else {
186
+ return null;
187
+ }
188
+ })
189
+ );
190
+ })();
191
+ return await this.remoteAddresses;
192
+ }
193
+ prime() {
194
+ this.primed = this.primed ?? (async () => {
195
+ await this.resolveRemoteModules();
196
+ return true;
197
+ })();
198
+ return this.primed;
199
+ }
200
+ remove(_address) {
201
+ throw new Error("Method not implemented.");
202
+ }
203
+ reset() {
204
+ this.primed = void 0;
205
+ this.remoteAddresses = void 0;
206
+ this.resolvedModules = {};
207
+ }
208
+ async resolve(nameOrAddressOrFilter, options) {
209
+ const unfiltered = await (async () => {
210
+ const mutatedOptions = { ...options, maxDepth: ((options == null ? void 0 : options.maxDepth) ?? _BridgeModuleResolver.defaultMaxDepth) - 1 };
211
+ await this.prime();
212
+ await this.resolveRemoteModules();
213
+ if (typeof nameOrAddressOrFilter === "string") {
214
+ if (mutatedOptions.maxDepth < 0) {
215
+ return void 0;
216
+ }
217
+ const result = await this.resolveByAddress(nameOrAddressOrFilter) ?? await this.resolveByName(nameOrAddressOrFilter);
218
+ return result;
219
+ } else {
220
+ if (mutatedOptions.maxDepth < 0) {
221
+ return [];
222
+ }
223
+ const result = await this.resolveRemoteModules(nameOrAddressOrFilter);
224
+ return result;
225
+ }
226
+ })();
227
+ const identity = options == null ? void 0 : options.identity;
228
+ if (identity) {
229
+ return Array.isArray(unfiltered) ? unfiltered == null ? void 0 : unfiltered.filter((module2) => identity(module2)) : identity(unfiltered) ? unfiltered : void 0;
230
+ } else {
231
+ return unfiltered;
232
+ }
233
+ }
234
+ async resolveByAddress(targetAddress) {
235
+ const remoteAddresses = await this.getRemoteAddresses();
236
+ if (!remoteAddresses.find((address) => address === targetAddress)) {
237
+ return void 0;
238
+ }
239
+ const cached = this.resolvedModules[targetAddress];
240
+ if (cached)
241
+ return await cached;
242
+ this.resolvedModules[targetAddress] = this.resolvedModules[targetAddress] ?? (async (address) => {
243
+ await this.bridge.targetDiscover(address);
244
+ const mod = new ProxyModule({ address, bridge: this.bridge, config: { schema: ProxyModuleConfigSchema } });
245
+ try {
246
+ if ((0, import_archivist_model.isArchivistModule)(mod)) {
247
+ return import_archivist_wrapper.ArchivistWrapper.wrap(mod, this.wrapperAccount);
248
+ }
249
+ if ((0, import_diviner_model.isDivinerModule)(mod)) {
250
+ return import_diviner.DivinerWrapper.wrap(mod, this.wrapperAccount);
251
+ }
252
+ if ((0, import_witness_model.isWitnessModule)(mod)) {
253
+ return import_witness_wrapper.WitnessWrapper.wrap(mod, this.wrapperAccount);
254
+ }
255
+ if ((0, import_node_model.isNodeModule)(mod)) {
256
+ return import_node_wrapper.NodeWrapper.wrap(mod, this.wrapperAccount);
257
+ }
258
+ if ((0, import_sentinel.isSentinelModule)(mod)) {
259
+ return import_sentinel.SentinelWrapper.wrap(mod, this.wrapperAccount);
260
+ }
261
+ console.warn(`BridgeModuleResolver: Unknown Module Type: [${targetAddress}]`);
262
+ return import_module2.ModuleWrapper.wrap(mod, this.wrapperAccount);
263
+ } catch (ex) {
264
+ (0, import_error.handleError)(ex, (error) => {
265
+ console.error(`BridgeModuleResolver.resolveByAddress: ${error.message} [${targetAddress}]`);
266
+ });
267
+ }
268
+ })(targetAddress);
269
+ return await this.resolvedModules[targetAddress];
270
+ }
271
+ async resolveByName(name) {
272
+ const modules = await this.currentResolvedModules();
273
+ return Object.values(modules).filter((module2) => module2.config.name === name).pop();
274
+ }
275
+ async resolveByQuery(queries) {
276
+ return Object.values(await this.currentResolvedModules()).filter((module2) => {
277
+ const found = module2.queries.filter((query) => queries.find((q) => q === query));
278
+ return queries.length === found.length;
279
+ });
280
+ }
281
+ async resolveRemoteModules(filter) {
282
+ if (filter == null ? void 0 : filter.address) {
283
+ return await this.resolveRemoteModulesByAddress(filter);
284
+ }
285
+ if (filter == null ? void 0 : filter.name) {
286
+ return await this.resolveRemoteModulesByName(filter);
287
+ }
288
+ if (filter == null ? void 0 : filter.query) {
289
+ return await this.resolveRemoteModulesByQuery(filter);
290
+ }
291
+ return await this.resolveRemoteModulesByAddress({ address: await this.getRemoteAddresses() });
292
+ }
293
+ async resolveRemoteModulesByAddress(filter) {
294
+ return (0, import_lodash2.compact)(await Promise.all(filter.address.map((address) => this.resolveByAddress(address))));
295
+ }
296
+ async resolveRemoteModulesByName(filter) {
297
+ return (0, import_lodash2.compact)(await Promise.all(filter.name.map(async (name) => await this.resolveByName(name))));
298
+ }
299
+ async resolveRemoteModulesByQuery(filter) {
300
+ return (0, import_lodash2.compact)((await Promise.all(filter.query.map(async (query) => await this.resolveByQuery(query)))).flat());
301
+ }
302
+ };
303
+ // Annotate the CommonJS export names for ESM import in node:
304
+ 0 && (module.exports = {
305
+ BridgeModuleResolver,
306
+ ProxyModule,
307
+ ProxyModuleConfigSchema
308
+ });
309
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts","../../src/ModuleResolver.ts","../../src/ProxyModule.ts"],"sourcesContent":["export * from './ModuleResolver'\nexport * from './ProxyModule'\n","import { compact } from '@xylabs/lodash'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { AddressPayload, AddressSchema } from '@xyo-network/address-payload-plugin'\nimport { isArchivistModule } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BridgeModule } from '@xyo-network/bridge-model'\nimport { DivinerWrapper } from '@xyo-network/diviner'\nimport { isDivinerModule } from '@xyo-network/diviner-model'\nimport { handleError } from '@xyo-network/error'\nimport { CompositeModuleResolver, ModuleWrapper } from '@xyo-network/module'\nimport {\n AddressModuleFilter,\n Module,\n ModuleFilter,\n ModuleFilterOptions,\n ModuleInstance,\n ModuleResolver,\n NameModuleFilter,\n QueryModuleFilter,\n} from '@xyo-network/module-model'\nimport { isNodeModule } from '@xyo-network/node-model'\nimport { NodeWrapper } from '@xyo-network/node-wrapper'\nimport { isSentinelModule, SentinelWrapper } from '@xyo-network/sentinel'\nimport { isWitnessModule } from '@xyo-network/witness-model'\nimport { WitnessWrapper } from '@xyo-network/witness-wrapper'\n\nimport { ProxyModule, ProxyModuleConfigSchema, ProxyModuleParams } from './ProxyModule'\n\nexport class BridgeModuleResolver extends CompositeModuleResolver implements ModuleResolver {\n private primed: Promise<boolean> | undefined = undefined\n private remoteAddresses?: Promise<string[]>\n private resolvedModules: Record<string, Promise<ModuleInstance>> = {}\n\n // TODO: Allow optional ctor param for supplying address for nested Nodes\n // protected readonly address?: string,\n constructor(\n protected readonly bridge: BridgeModule,\n protected wrapperAccount: AccountInstance,\n ) {\n super()\n }\n\n override get isModuleResolver(): boolean {\n return true\n }\n\n override add(module: Module): this\n override add(module: Module[]): this\n override add(_module: Module | Module[]): this {\n throw new Error('Method not implemented.')\n }\n\n async currentResolvedModules<T extends ModuleInstance = ModuleInstance>(): Promise<Record<string, T>> {\n const result: Record<string, T> = {}\n await Promise.all(\n Object.entries(this.resolvedModules).map(async ([key, value]) => {\n result[key] = (await value) as T\n }),\n )\n\n return result\n }\n\n async getRemoteAddresses() {\n this.remoteAddresses =\n this.remoteAddresses ??\n (async () => {\n const discover = await this.bridge.targetDiscover()\n return compact(\n discover?.map((payload) => {\n if (payload.schema === AddressSchema) {\n const schemaPayload = payload as AddressPayload\n return schemaPayload.address\n } else {\n return null\n }\n }),\n )\n })()\n return await this.remoteAddresses\n }\n\n prime() {\n this.primed =\n this.primed ??\n (async () => {\n await this.resolveRemoteModules()\n return true\n })()\n return this.primed\n }\n\n override remove(_address: string | string[]): this {\n throw new Error('Method not implemented.')\n }\n\n reset() {\n this.primed = undefined\n this.remoteAddresses = undefined\n this.resolvedModules = {}\n }\n\n override async resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter<T>, options?: ModuleFilterOptions<T>): Promise<T[]>\n override async resolve<T extends ModuleInstance = ModuleInstance>(nameOrAddress: string, options?: ModuleFilterOptions<T>): Promise<T | undefined>\n override async resolve<T extends ModuleInstance = ModuleInstance>(\n nameOrAddressOrFilter?: ModuleFilter<T> | string,\n options?: ModuleFilterOptions<T>,\n ): Promise<T | T[] | undefined> {\n const unfiltered = await (async () => {\n const mutatedOptions = { ...options, maxDepth: (options?.maxDepth ?? BridgeModuleResolver.defaultMaxDepth) - 1 }\n await this.prime()\n await this.resolveRemoteModules()\n if (typeof nameOrAddressOrFilter === 'string') {\n if (mutatedOptions.maxDepth < 0) {\n return undefined\n }\n const result: T | undefined = (await this.resolveByAddress<T>(nameOrAddressOrFilter)) ?? (await this.resolveByName<T>(nameOrAddressOrFilter))\n return result\n } else {\n if (mutatedOptions.maxDepth < 0) {\n return []\n }\n const result: T[] = await this.resolveRemoteModules<T>(nameOrAddressOrFilter)\n return result\n }\n })()\n\n const identity = options?.identity\n if (identity) {\n return Array.isArray(unfiltered) ? unfiltered?.filter((module) => identity(module)) : identity(unfiltered) ? unfiltered : undefined\n } else {\n return unfiltered\n }\n }\n\n private async resolveByAddress<T extends ModuleInstance = ModuleInstance>(targetAddress: string): Promise<T | undefined> {\n const remoteAddresses = await this.getRemoteAddresses()\n\n //check if it is even there\n if (!remoteAddresses.find((address) => address === targetAddress)) {\n //this.logger?.log(`Not in RA: ${targetAddress}`)\n return undefined\n }\n\n const cached = this.resolvedModules[targetAddress]\n if (cached) return (await cached) as T\n\n this.resolvedModules[targetAddress] =\n this.resolvedModules[targetAddress] ??\n (async (address: string) => {\n //discover it to set the config in the bridge\n await this.bridge.targetDiscover(address)\n\n const mod: Module = new ProxyModule({ address, bridge: this.bridge, config: { schema: ProxyModuleConfigSchema } } as ProxyModuleParams)\n\n try {\n if (isArchivistModule(mod)) {\n return ArchivistWrapper.wrap(mod, this.wrapperAccount)\n }\n\n if (isDivinerModule(mod)) {\n return DivinerWrapper.wrap(mod, this.wrapperAccount)\n }\n\n if (isWitnessModule(mod)) {\n return WitnessWrapper.wrap(mod, this.wrapperAccount)\n }\n\n if (isNodeModule(mod)) {\n return NodeWrapper.wrap(mod, this.wrapperAccount)\n }\n\n if (isSentinelModule(mod)) {\n return SentinelWrapper.wrap(mod, this.wrapperAccount)\n }\n console.warn(`BridgeModuleResolver: Unknown Module Type: [${targetAddress}]`)\n return ModuleWrapper.wrap(mod, this.wrapperAccount)\n } catch (ex) {\n handleError(ex, (error) => {\n console.error(`BridgeModuleResolver.resolveByAddress: ${error.message} [${targetAddress}]`)\n })\n }\n })(targetAddress)\n\n return (await this.resolvedModules[targetAddress]) as T\n }\n\n private async resolveByName<T extends ModuleInstance = ModuleInstance>(name: string): Promise<T | undefined> {\n const modules = await this.currentResolvedModules()\n return Object.values(modules)\n .filter((module) => module.config.name === name)\n .pop() as T\n }\n\n private async resolveByQuery<T extends ModuleInstance = ModuleInstance>(queries: string[]): Promise<T[]> {\n return Object.values(await this.currentResolvedModules()).filter((module) => {\n //filter out the requested queries\n const found = module.queries.filter((query) => queries.find((q) => q === query))\n\n //did we find all the requested queries?\n return queries.length === found.length\n }) as T[]\n }\n\n private async resolveRemoteModules<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter): Promise<T[]> {\n if ((filter as AddressModuleFilter)?.address) {\n return await this.resolveRemoteModulesByAddress<T>(filter as AddressModuleFilter)\n }\n\n if ((filter as NameModuleFilter)?.name) {\n return await this.resolveRemoteModulesByName<T>(filter as NameModuleFilter)\n }\n\n if ((filter as QueryModuleFilter)?.query) {\n return await this.resolveRemoteModulesByQuery<T>(filter as QueryModuleFilter)\n }\n\n //get all of them\n return await this.resolveRemoteModulesByAddress<T>({ address: await this.getRemoteAddresses() })\n }\n\n private async resolveRemoteModulesByAddress<T extends ModuleInstance = ModuleInstance>(filter: AddressModuleFilter): Promise<T[]> {\n return compact(await Promise.all(filter.address.map((address) => this.resolveByAddress<T>(address))))\n }\n\n private async resolveRemoteModulesByName<T extends ModuleInstance = ModuleInstance>(filter: NameModuleFilter): Promise<T[]> {\n return compact(await Promise.all(filter.name.map(async (name) => await this.resolveByName<T>(name))))\n }\n\n private async resolveRemoteModulesByQuery<T extends ModuleInstance = ModuleInstance>(filter: QueryModuleFilter): Promise<T[]> {\n return compact((await Promise.all(filter.query.map(async (query) => await this.resolveByQuery<T>(query)))).flat())\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { compact } from '@xylabs/lodash'\nimport { AddressPayload, AddressSchema } from '@xyo-network/address-payload-plugin'\nimport { QueryBoundWitness } from '@xyo-network/boundwitness-builder'\nimport { BridgeModule } from '@xyo-network/bridge-model'\nimport { ManifestPayloadSchema, ModuleManifestPayload } from '@xyo-network/manifest-model'\nimport {\n AddressPreviousHashPayload,\n BaseEmitter,\n CompositeModuleResolver,\n ModuleBusyEventArgs,\n ModuleConfig,\n ModuleDescription,\n ModuleEventData,\n ModuleFilter,\n ModuleFilterOptions,\n ModuleInstance,\n ModuleParams,\n ModuleQueryResult,\n} from '@xyo-network/module'\nimport { Payload } from '@xyo-network/payload-model'\nimport { Promisable } from '@xyo-network/promise'\n\nexport type ProxyModuleConfigSchema = 'network.xyo.module.proxy.config'\nexport const ProxyModuleConfigSchema: ProxyModuleConfigSchema = 'network.xyo.module.proxy.config'\n\nexport type TProxyModuleConfig = ModuleConfig<{ schema: ProxyModuleConfigSchema }>\n\nexport type ProxyModuleParams = ModuleParams<\n TProxyModuleConfig,\n {\n address: string\n bridge: BridgeModule\n }\n>\n\nexport class ProxyModule extends BaseEmitter<ModuleParams, ModuleEventData> implements ModuleInstance<ModuleParams, ModuleEventData> {\n readonly upResolver = new CompositeModuleResolver()\n\n private _busyCount = 0\n\n constructor(public proxyParams: ProxyModuleParams) {\n super({ config: proxyParams.bridge.targetConfig(proxyParams.address) })\n }\n\n get address() {\n return this.proxyParams.address.toLowerCase()\n }\n\n get bridge() {\n return this.proxyParams.bridge\n }\n\n get config(): ModuleConfig {\n const config = this.bridge.targetConfig(this.address)\n return config\n }\n\n get downResolver() {\n return assertEx(this.bridge.targetDownResolver(this.address), 'Unable to get resolver')\n }\n\n get queries() {\n return this.bridge.targetQueries(this.address)\n }\n\n addressPreviousHash(): Promise<AddressPreviousHashPayload> {\n throw Error('Not Implemented')\n }\n\n async busy<R>(closure: () => Promise<R>) {\n if (this._busyCount <= 0) {\n this._busyCount = 0\n const args: ModuleBusyEventArgs = { busy: true, module: this }\n await this.emit('moduleBusy', args)\n }\n this._busyCount++\n try {\n return await closure()\n } finally {\n this._busyCount--\n if (this._busyCount <= 0) {\n this._busyCount = 0\n const args: ModuleBusyEventArgs = { busy: false, module: this }\n await this.emit('moduleBusy', args)\n }\n }\n }\n\n async describe(): Promise<ModuleDescription> {\n return await this.busy(async () => {\n const description: ModuleDescription = {\n address: this.address,\n queries: this.queries,\n }\n if (this.config.name) {\n description.name = this.config.name\n }\n\n const discover = await this.discover()\n\n description.children = compact(\n discover?.map((payload) => {\n const address = payload.schema === AddressSchema ? (payload as AddressPayload).address : undefined\n return address != this.address ? address : undefined\n }) ?? [],\n )\n\n return description\n })\n }\n\n async discover(): Promise<Payload[]> {\n return await this.busy(async () => {\n return await this.bridge.targetDiscover()\n })\n }\n\n manifest(): Promisable<ModuleManifestPayload> {\n const name = this.config.name ?? 'Anonymous'\n return { config: { name, ...this.config }, schema: ManifestPayloadSchema }\n }\n\n moduleAddress(): Promise<AddressPreviousHashPayload[]> {\n throw Error('Not Implemented')\n }\n\n previousHash(): Promise<string | undefined> {\n throw Error('Not Implemented')\n }\n\n async query<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads?: Payload[]): Promise<ModuleQueryResult> {\n return await this.busy(async () => {\n const result = assertEx(await this.bridge.targetQuery(this.address, query, payloads), 'Remote Query Failed')\n await this.emit('moduleQueried', { module: this, payloads, query, result })\n return result\n })\n }\n\n async queryable(query: QueryBoundWitness, payloads?: Payload[], queryConfig?: ModuleConfig): Promise<boolean> {\n return await this.bridge.targetQueryable(this.address, query, payloads, queryConfig)\n }\n\n /* Resolves a filter from the perspective of the module, including through the parent/gateway module */\n resolve(filter?: ModuleFilter, options?: ModuleFilterOptions): Promise<ModuleInstance[]>\n resolve(nameOrAddress: string, options?: ModuleFilterOptions): Promise<ModuleInstance | undefined>\n async resolve(\n nameOrAddressOrFilter?: ModuleFilter | string,\n options?: ModuleFilterOptions,\n ): Promise<ModuleInstance | ModuleInstance[] | undefined> {\n return await this.busy(async () => {\n if (typeof nameOrAddressOrFilter === 'string') {\n return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options)\n } else {\n return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options)\n }\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAAwB;AAExB,IAAAC,iCAA8C;AAC9C,6BAAkC;AAClC,+BAAiC;AAEjC,qBAA+B;AAC/B,2BAAgC;AAChC,mBAA4B;AAC5B,IAAAC,iBAAuD;AAWvD,wBAA6B;AAC7B,0BAA4B;AAC5B,sBA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