@xyo-network/bridge-module-resolver 2.75.0 → 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.
@@ -0,0 +1,84 @@
1
+ import { QueryBoundWitness } from '@xyo-network/boundwitness-builder';
2
+ import { BridgeModule } from '@xyo-network/bridge-model';
3
+ import { ModuleManifestPayload } from '@xyo-network/manifest-model';
4
+ import { AddressPreviousHashPayload, BaseEmitter, CompositeModuleResolver, ModuleConfig, ModuleDescription, ModuleEventData, ModuleFilter, ModuleFilterOptions, ModuleInstance, ModuleParams, ModuleQueryResult } from '@xyo-network/module';
5
+ import { Payload } from '@xyo-network/payload-model';
6
+ import { Promisable } from '@xyo-network/promise';
7
+ export type ProxyModuleConfigSchema = 'network.xyo.module.proxy.config';
8
+ export declare const ProxyModuleConfigSchema: ProxyModuleConfigSchema;
9
+ export type TProxyModuleConfig = ModuleConfig<{
10
+ schema: ProxyModuleConfigSchema;
11
+ }>;
12
+ export type ProxyModuleParams = ModuleParams<TProxyModuleConfig, {
13
+ address: string;
14
+ bridge: BridgeModule;
15
+ }>;
16
+ export declare class ProxyModule extends BaseEmitter<ModuleParams, ModuleEventData> implements ModuleInstance<ModuleParams, ModuleEventData> {
17
+ proxyParams: ProxyModuleParams;
18
+ readonly upResolver: CompositeModuleResolver;
19
+ private _busyCount;
20
+ constructor(proxyParams: ProxyModuleParams);
21
+ get address(): string;
22
+ get bridge(): BridgeModule<import("@xyo-network/core").BaseParamsFields & {
23
+ account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
24
+ config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<{
25
+ accountDerivationPath?: string | undefined;
26
+ readonly archivist?: import("@xyo-network/module").ArchivistModuleConfig | undefined;
27
+ readonly labels?: import("@xyo-network/module").Labels | undefined;
28
+ readonly name?: string | undefined;
29
+ readonly paging?: Record<string, {
30
+ size?: number | undefined;
31
+ }> | undefined;
32
+ readonly security?: {
33
+ readonly allowAnonymous?: boolean | undefined;
34
+ readonly allowed?: Record<string, (string | import("@xyo-network/module").CosigningAddressSet)[]> | undefined;
35
+ readonly disallowed?: Record<string, string[]> | undefined;
36
+ } | undefined;
37
+ readonly sign?: boolean | undefined;
38
+ readonly storeQueries?: boolean | undefined;
39
+ readonly timestamp?: boolean | undefined;
40
+ } & Omit<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<{
41
+ accountDerivationPath?: string | undefined;
42
+ readonly archivist?: import("@xyo-network/module").ArchivistModuleConfig | undefined;
43
+ readonly labels?: import("@xyo-network/module").Labels | undefined;
44
+ readonly name?: string | undefined;
45
+ readonly paging?: Record<string, {
46
+ size?: number | undefined;
47
+ }> | undefined;
48
+ readonly security?: {
49
+ readonly allowAnonymous?: boolean | undefined;
50
+ readonly allowed?: Record<string, (string | import("@xyo-network/module").CosigningAddressSet)[]> | undefined;
51
+ readonly disallowed?: Record<string, string[]> | undefined;
52
+ } | undefined;
53
+ readonly sign?: boolean | undefined;
54
+ readonly storeQueries?: boolean | undefined;
55
+ readonly timestamp?: boolean | undefined;
56
+ } & {
57
+ discoverCache?: true | import("@xyo-network/bridge-model").CacheConfig | undefined;
58
+ schema: "network.xyo.bridge.config";
59
+ }, "schema"> & {
60
+ schema: "network.xyo.bridge.config";
61
+ }, "schema"> & {
62
+ schema: string;
63
+ }, "schema"> & {
64
+ schema: string;
65
+ };
66
+ ephemeralQueryAccountEnabled?: boolean | undefined;
67
+ wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
68
+ }, ModuleEventData<object>>;
69
+ get config(): ModuleConfig;
70
+ get downResolver(): import("@xyo-network/module").ModuleResolver;
71
+ get queries(): string[];
72
+ addressPreviousHash(): Promise<AddressPreviousHashPayload>;
73
+ busy<R>(closure: () => Promise<R>): Promise<R>;
74
+ describe(): Promise<ModuleDescription>;
75
+ discover(): Promise<Payload[]>;
76
+ manifest(): Promisable<ModuleManifestPayload>;
77
+ moduleAddress(): Promise<AddressPreviousHashPayload[]>;
78
+ previousHash(): Promise<string | undefined>;
79
+ query<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads?: Payload[]): Promise<ModuleQueryResult>;
80
+ queryable(query: QueryBoundWitness, payloads?: Payload[], queryConfig?: ModuleConfig): Promise<boolean>;
81
+ resolve(filter?: ModuleFilter, options?: ModuleFilterOptions): Promise<ModuleInstance[]>;
82
+ resolve(nameOrAddress: string, options?: ModuleFilterOptions): Promise<ModuleInstance | undefined>;
83
+ }
84
+ //# sourceMappingURL=ProxyModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProxyModule.d.ts","sourceRoot":"","sources":["../../src/ProxyModule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAyB,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAC1F,OAAO,EACL,0BAA0B,EAC1B,WAAW,EACX,uBAAuB,EAEvB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,iBAAiB,EAClB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD,MAAM,MAAM,uBAAuB,GAAG,iCAAiC,CAAA;AACvE,eAAO,MAAM,uBAAuB,EAAE,uBAA2D,CAAA;AAEjG,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC;IAAE,MAAM,EAAE,uBAAuB,CAAA;CAAE,CAAC,CAAA;AAElF,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAC1C,kBAAkB,EAClB;IACE,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,YAAY,CAAA;CACrB,CACF,CAAA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C,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;CAanG"}
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/ProxyModule.ts
19
21
  var ProxyModule_exports = {};
20
22
  __export(ProxyModule_exports, {
21
23
  ProxyModule: () => ProxyModule,
@@ -27,8 +29,8 @@ var import_lodash = require("@xylabs/lodash");
27
29
  var import_address_payload_plugin = require("@xyo-network/address-payload-plugin");
28
30
  var import_manifest_model = require("@xyo-network/manifest-model");
29
31
  var import_module = require("@xyo-network/module");
30
- const ProxyModuleConfigSchema = "network.xyo.module.proxy.config";
31
- class ProxyModule extends import_module.BaseEmitter {
32
+ var ProxyModuleConfigSchema = "network.xyo.module.proxy.config";
33
+ var ProxyModule = class extends import_module.BaseEmitter {
32
34
  constructor(proxyParams) {
33
35
  super({ config: proxyParams.bridge.targetConfig(proxyParams.address) });
34
36
  this.proxyParams = proxyParams;
@@ -83,10 +85,10 @@ class ProxyModule extends import_module.BaseEmitter {
83
85
  }
84
86
  const discover = await this.discover();
85
87
  description.children = (0, import_lodash.compact)(
86
- discover?.map((payload) => {
88
+ (discover == null ? void 0 : discover.map((payload) => {
87
89
  const address = payload.schema === import_address_payload_plugin.AddressSchema ? payload.address : void 0;
88
90
  return address != this.address ? address : void 0;
89
- }) ?? []
91
+ })) ?? []
90
92
  );
91
93
  return description;
92
94
  });
@@ -125,7 +127,7 @@ class ProxyModule extends import_module.BaseEmitter {
125
127
  }
126
128
  });
127
129
  }
128
- }
130
+ };
129
131
  // Annotate the CommonJS export names for ESM import in node:
130
132
  0 && (module.exports = {
131
133
  ProxyModule,
@@ -1 +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,MAAM,0BAAmD;AAYzD,MAAM,oBAAoB,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,EACxF;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,OAAO,cAAc,KAAK,OAAO;AAAA,EAC/C;AAAA,EAEA,sBAA2D;AACzD,UAAM,MAAM,iBAAiB;AAAA,EAC/B;AAAA,EAEA,MAAM,KAAQ,SAA2B;AACvC,QAAI,KAAK,cAAc,GAAG;AACxB,WAAK,aAAa;AAClB,YAAM,OAA4B,EAAE,MAAM,MAAM,QAAQ,KAAK;AAC7D,YAAM,KAAK,KAAK,cAAc,IAAI;AAAA,IACpC;AACA,SAAK;AACL,QAAI;AACF,aAAO,MAAM,QAAQ;AAAA,IACvB,UAAE;AACA,WAAK;AACL,UAAI,KAAK,cAAc,GAAG;AACxB,aAAK,aAA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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":[]}
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,S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,MAAM,KAAK,KAAK,YAAY;AACjC,aAAO,MAAM,KAAK,OAAO,eAAe;AAAA,IAC1C,CAAC;AAAA,EACH;AAAA,EAEA,WAA8C;AAC5C,UAAM,OAAO,KAAK,OAAO,QAAQ;AACjC,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":[]}
@@ -1,3 +1,4 @@
1
+ // src/ProxyModule.ts
1
2
  import { assertEx } from "@xylabs/assert";
2
3
  import { compact } from "@xylabs/lodash";
3
4
  import { AddressSchema } from "@xyo-network/address-payload-plugin";
@@ -6,8 +7,8 @@ import {
6
7
  BaseEmitter,
7
8
  CompositeModuleResolver
8
9
  } from "@xyo-network/module";
9
- const ProxyModuleConfigSchema = "network.xyo.module.proxy.config";
10
- class ProxyModule extends BaseEmitter {
10
+ var ProxyModuleConfigSchema = "network.xyo.module.proxy.config";
11
+ var ProxyModule = class extends BaseEmitter {
11
12
  constructor(proxyParams) {
12
13
  super({ config: proxyParams.bridge.targetConfig(proxyParams.address) });
13
14
  this.proxyParams = proxyParams;
@@ -62,10 +63,10 @@ class ProxyModule extends BaseEmitter {
62
63
  }
63
64
  const discover = await this.discover();
64
65
  description.children = compact(
65
- discover?.map((payload) => {
66
+ (discover == null ? void 0 : discover.map((payload) => {
66
67
  const address = payload.schema === AddressSchema ? payload.address : void 0;
67
68
  return address != this.address ? address : void 0;
68
- }) ?? []
69
+ })) ?? []
69
70
  );
70
71
  return description;
71
72
  });
@@ -104,7 +105,7 @@ class ProxyModule extends BaseEmitter {
104
105
  }
105
106
  });
106
107
  }
107
- }
108
+ };
108
109
  export {
109
110
  ProxyModule,
110
111
  ProxyModuleConfigSchema
@@ -1 +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,MAAM,0BAAmD;AAYzD,MAAM,oBAAoB,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,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A,EACH;AACF;","names":[]}
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;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,WAAO,SAAS,KAAK,OAAO,mBAAmB,KAAK,OAAO,GAAG,wBAAwB;AAAA,EACxF;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,OAAO,cAAc,KAAK,OAAO;AAAA,EAC/C;AAAA,EAEA,sBAA2D;AACzD,UAAM,MAAM,iBAAiB;AAAA,EAC/B;AAAA,EAEA,MAAM,KAAQ,SAA2B;AACvC,QAAI,KAAK,cAAc,GAAG;AACxB,WAAK,aAAa;AAClB,YAAM,OAA4B,EAAE,MAAM,MAAM,QAAQ,KAAK;AAC7D,YAAM,KAAK,KAAK,cAAc,IAA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AAK,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,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"}
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
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
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -11,15 +15,295 @@ var __copyProps = (to, from, except, desc) => {
11
15
  }
12
16
  return to;
13
17
  };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
16
21
  var src_exports = {};
22
+ __export(src_exports, {
23
+ BridgeModuleResolver: () => BridgeModuleResolver,
24
+ ProxyModule: () => ProxyModule,
25
+ ProxyModuleConfigSchema: () => ProxyModuleConfigSchema
26
+ });
17
27
  module.exports = __toCommonJS(src_exports);
18
- __reExport(src_exports, require("./ModuleResolver"), module.exports);
19
- __reExport(src_exports, require("./ProxyModule"), module.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
+ };
20
303
  // Annotate the CommonJS export names for ESM import in node:
21
304
  0 && (module.exports = {
22
- ...require("./ModuleResolver"),
23
- ...require("./ProxyModule")
305
+ BridgeModuleResolver,
306
+ ProxyModule,
307
+ ProxyModuleConfigSchema
24
308
  });
25
309
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './ModuleResolver'\nexport * from './ProxyModule'\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,6BAAd;AACA,wBAAc,0BADd;","names":[]}
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,sBAAkD;AAClD,2BAAgC;AAChC,6BAA+B;;;ACxB/B,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,EACxF;AAAA,EAEA,IAAI,UAAU;AACZ,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