@xyo-network/bridge-module-resolver 2.91.2 → 2.92.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.cjs +2 -319
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +1 -2
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +1 -2
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +1 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +3 -320
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +3 -321
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1 -2
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +1 -2
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +1 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +3 -319
- package/dist/node/index.js.map +1 -1
- package/package.json +3 -29
- package/src/index.ts +2 -2
- package/dist/browser/ModuleResolver.d.cts +0 -31
- package/dist/browser/ModuleResolver.d.cts.map +0 -1
- package/dist/browser/ModuleResolver.d.mts +0 -31
- package/dist/browser/ModuleResolver.d.mts.map +0 -1
- package/dist/browser/ModuleResolver.d.ts +0 -31
- package/dist/browser/ModuleResolver.d.ts.map +0 -1
- package/dist/browser/ProxyModule.d.cts +0 -123
- package/dist/browser/ProxyModule.d.cts.map +0 -1
- package/dist/browser/ProxyModule.d.mts +0 -123
- package/dist/browser/ProxyModule.d.mts.map +0 -1
- package/dist/browser/ProxyModule.d.ts +0 -123
- package/dist/browser/ProxyModule.d.ts.map +0 -1
- package/dist/node/ModuleResolver.d.cts +0 -31
- package/dist/node/ModuleResolver.d.cts.map +0 -1
- package/dist/node/ModuleResolver.d.mts +0 -31
- package/dist/node/ModuleResolver.d.mts.map +0 -1
- package/dist/node/ModuleResolver.d.ts +0 -31
- package/dist/node/ModuleResolver.d.ts.map +0 -1
- package/dist/node/ProxyModule.d.cts +0 -123
- package/dist/node/ProxyModule.d.cts.map +0 -1
- package/dist/node/ProxyModule.d.mts +0 -123
- package/dist/node/ProxyModule.d.mts.map +0 -1
- package/dist/node/ProxyModule.d.ts +0 -123
- package/dist/node/ProxyModule.d.ts.map +0 -1
- package/src/ModuleResolver.ts +0 -242
- package/src/ProxyModule.ts +0 -165
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { Address } from '@xylabs/hex';
|
|
2
|
-
import { Promisable } from '@xylabs/promise';
|
|
3
|
-
import { QueryBoundWitness } from '@xyo-network/boundwitness-model';
|
|
4
|
-
import { BridgeModule } from '@xyo-network/bridge-model';
|
|
5
|
-
import { ModuleManifestPayload } from '@xyo-network/manifest-model';
|
|
6
|
-
import { BaseEmitter } from '@xyo-network/module-abstract';
|
|
7
|
-
import { AddressPreviousHashPayload, ModuleConfig, ModuleDescription, ModuleEventData, ModuleFilter, ModuleFilterOptions, ModuleInstance, ModuleParams, ModuleQueryResult } from '@xyo-network/module-model';
|
|
8
|
-
import { CompositeModuleResolver } from '@xyo-network/module-resolver';
|
|
9
|
-
import { Payload } from '@xyo-network/payload-model';
|
|
10
|
-
export type ProxyModuleConfigSchema = 'network.xyo.module.proxy.config';
|
|
11
|
-
export declare const ProxyModuleConfigSchema: ProxyModuleConfigSchema;
|
|
12
|
-
export type TProxyModuleConfig = ModuleConfig<{
|
|
13
|
-
schema: ProxyModuleConfigSchema;
|
|
14
|
-
}>;
|
|
15
|
-
export type ProxyModuleParams = ModuleParams<TProxyModuleConfig, {
|
|
16
|
-
address: Address;
|
|
17
|
-
bridge: BridgeModule;
|
|
18
|
-
}>;
|
|
19
|
-
export declare class ProxyModule extends BaseEmitter<ModuleParams, ModuleEventData> implements ModuleInstance<ModuleParams, ModuleEventData> {
|
|
20
|
-
proxyParams: ProxyModuleParams;
|
|
21
|
-
readonly upResolver: CompositeModuleResolver;
|
|
22
|
-
private _busyCount;
|
|
23
|
-
constructor(proxyParams: ProxyModuleParams);
|
|
24
|
-
get address(): Lowercase<string>;
|
|
25
|
-
get bridge(): BridgeModule<import("@xyo-network/bridge-model").BridgeParams<import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
26
|
-
readonly archivist?: string | undefined;
|
|
27
|
-
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
28
|
-
readonly name?: string | undefined;
|
|
29
|
-
readonly paging?: Record<string, {
|
|
30
|
-
size?: number | undefined;
|
|
31
|
-
}> | undefined;
|
|
32
|
-
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
33
|
-
schema: "network.xyo.bridge.config";
|
|
34
|
-
readonly security?: {
|
|
35
|
-
readonly allowAnonymous?: boolean | undefined;
|
|
36
|
-
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
37
|
-
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
38
|
-
} | undefined;
|
|
39
|
-
readonly sign?: boolean | undefined;
|
|
40
|
-
readonly storeQueries?: boolean | undefined;
|
|
41
|
-
readonly timestamp?: boolean | undefined;
|
|
42
|
-
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
43
|
-
readonly archivist?: string | undefined;
|
|
44
|
-
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
45
|
-
readonly name?: string | undefined;
|
|
46
|
-
readonly paging?: Record<string, {
|
|
47
|
-
size?: number | undefined;
|
|
48
|
-
}> | undefined;
|
|
49
|
-
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
50
|
-
schema: "network.xyo.bridge.config";
|
|
51
|
-
readonly security?: {
|
|
52
|
-
readonly allowAnonymous?: boolean | undefined;
|
|
53
|
-
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
54
|
-
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
55
|
-
} | undefined;
|
|
56
|
-
readonly sign?: boolean | undefined;
|
|
57
|
-
readonly storeQueries?: boolean | undefined;
|
|
58
|
-
readonly timestamp?: boolean | undefined;
|
|
59
|
-
} & {
|
|
60
|
-
discoverCache?: true | import("@xyo-network/bridge-model").CacheConfig | undefined;
|
|
61
|
-
maxDepth?: number | undefined;
|
|
62
|
-
schema: "network.xyo.bridge.config";
|
|
63
|
-
}, "schema"> & {
|
|
64
|
-
schema: string;
|
|
65
|
-
}>, ModuleEventData<object>>;
|
|
66
|
-
get config(): ModuleConfig;
|
|
67
|
-
get downResolver(): import("@xyo-network/module-model").ModuleResolverInstance<ModuleInstance<import("@xylabs/object").BaseParamsFields & {
|
|
68
|
-
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
69
|
-
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
70
|
-
readonly archivist?: string | undefined;
|
|
71
|
-
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
72
|
-
readonly name?: string | undefined;
|
|
73
|
-
readonly paging?: Record<string, {
|
|
74
|
-
size?: number | undefined;
|
|
75
|
-
}> | undefined;
|
|
76
|
-
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
77
|
-
schema: "network.xyo.module.config";
|
|
78
|
-
readonly security?: {
|
|
79
|
-
readonly allowAnonymous?: boolean | undefined;
|
|
80
|
-
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
81
|
-
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
82
|
-
} | undefined;
|
|
83
|
-
readonly sign?: boolean | undefined;
|
|
84
|
-
readonly storeQueries?: boolean | undefined;
|
|
85
|
-
readonly timestamp?: boolean | undefined;
|
|
86
|
-
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
87
|
-
readonly archivist?: string | undefined;
|
|
88
|
-
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
89
|
-
readonly name?: string | undefined;
|
|
90
|
-
readonly paging?: Record<string, {
|
|
91
|
-
size?: number | undefined;
|
|
92
|
-
}> | undefined;
|
|
93
|
-
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
94
|
-
schema: "network.xyo.module.config";
|
|
95
|
-
readonly security?: {
|
|
96
|
-
readonly allowAnonymous?: boolean | undefined;
|
|
97
|
-
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
98
|
-
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
99
|
-
} | undefined;
|
|
100
|
-
readonly sign?: boolean | undefined;
|
|
101
|
-
readonly storeQueries?: boolean | undefined;
|
|
102
|
-
readonly timestamp?: boolean | undefined;
|
|
103
|
-
}, "schema"> & {
|
|
104
|
-
schema: string;
|
|
105
|
-
};
|
|
106
|
-
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
107
|
-
}, ModuleEventData<object>>>;
|
|
108
|
-
get id(): string;
|
|
109
|
-
get queries(): string[];
|
|
110
|
-
addressPreviousHash(): Promise<AddressPreviousHashPayload>;
|
|
111
|
-
busy<R>(closure: () => Promise<R>): Promise<R>;
|
|
112
|
-
describe(): Promise<ModuleDescription>;
|
|
113
|
-
discover(): Promise<Payload[]>;
|
|
114
|
-
manifest(_depth?: number): Promisable<ModuleManifestPayload>;
|
|
115
|
-
moduleAddress(): Promise<AddressPreviousHashPayload[]>;
|
|
116
|
-
previousHash(): Promise<string | undefined>;
|
|
117
|
-
query<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads?: Payload[]): Promise<ModuleQueryResult>;
|
|
118
|
-
queryable(query: QueryBoundWitness, payloads?: Payload[], queryConfig?: ModuleConfig): Promise<boolean>;
|
|
119
|
-
resolve(filter?: ModuleFilter, options?: ModuleFilterOptions): Promise<ModuleInstance[]>;
|
|
120
|
-
resolve(nameOrAddress: string, options?: ModuleFilterOptions): Promise<ModuleInstance | undefined>;
|
|
121
|
-
state(): never[];
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=ProxyModule.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProxyModule.d.ts","sourceRoot":"","sources":["../../src/ProxyModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,qBAAqB,EAA+B,MAAM,6BAA6B,CAAA;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EACL,0BAA0B,EAE1B,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,iBAAiB,EAClB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,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,OAAO,CAAA;IAChB,MAAM,EAAE,YAAY,CAAA;CACrB,CACF,CAAA;AAED,qBAAa,WAAY,SAAQ,WAAW,CAAC,YAAY,EAAE,eAAe,CAAE,YAAW,cAAc,CAAC,YAAY,EAAE,eAAe,CAAC;IAK/G,WAAW,EAAE,iB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C,cAAc,GAAG,SAAS,CAAC;IAYlG,KAAK;CAGN"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { Address } from '@xylabs/hex';
|
|
2
|
-
import { Promisable } from '@xylabs/promise';
|
|
3
|
-
import { QueryBoundWitness } from '@xyo-network/boundwitness-model';
|
|
4
|
-
import { BridgeModule } from '@xyo-network/bridge-model';
|
|
5
|
-
import { ModuleManifestPayload } from '@xyo-network/manifest-model';
|
|
6
|
-
import { BaseEmitter } from '@xyo-network/module-abstract';
|
|
7
|
-
import { AddressPreviousHashPayload, ModuleConfig, ModuleDescription, ModuleEventData, ModuleFilter, ModuleFilterOptions, ModuleInstance, ModuleParams, ModuleQueryResult } from '@xyo-network/module-model';
|
|
8
|
-
import { CompositeModuleResolver } from '@xyo-network/module-resolver';
|
|
9
|
-
import { Payload } from '@xyo-network/payload-model';
|
|
10
|
-
export type ProxyModuleConfigSchema = 'network.xyo.module.proxy.config';
|
|
11
|
-
export declare const ProxyModuleConfigSchema: ProxyModuleConfigSchema;
|
|
12
|
-
export type TProxyModuleConfig = ModuleConfig<{
|
|
13
|
-
schema: ProxyModuleConfigSchema;
|
|
14
|
-
}>;
|
|
15
|
-
export type ProxyModuleParams = ModuleParams<TProxyModuleConfig, {
|
|
16
|
-
address: Address;
|
|
17
|
-
bridge: BridgeModule;
|
|
18
|
-
}>;
|
|
19
|
-
export declare class ProxyModule extends BaseEmitter<ModuleParams, ModuleEventData> implements ModuleInstance<ModuleParams, ModuleEventData> {
|
|
20
|
-
proxyParams: ProxyModuleParams;
|
|
21
|
-
readonly upResolver: CompositeModuleResolver;
|
|
22
|
-
private _busyCount;
|
|
23
|
-
constructor(proxyParams: ProxyModuleParams);
|
|
24
|
-
get address(): Lowercase<string>;
|
|
25
|
-
get bridge(): BridgeModule<import("@xyo-network/bridge-model").BridgeParams<import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
26
|
-
readonly archivist?: string | undefined;
|
|
27
|
-
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
28
|
-
readonly name?: string | undefined;
|
|
29
|
-
readonly paging?: Record<string, {
|
|
30
|
-
size?: number | undefined;
|
|
31
|
-
}> | undefined;
|
|
32
|
-
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
33
|
-
schema: "network.xyo.bridge.config";
|
|
34
|
-
readonly security?: {
|
|
35
|
-
readonly allowAnonymous?: boolean | undefined;
|
|
36
|
-
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
37
|
-
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
38
|
-
} | undefined;
|
|
39
|
-
readonly sign?: boolean | undefined;
|
|
40
|
-
readonly storeQueries?: boolean | undefined;
|
|
41
|
-
readonly timestamp?: boolean | undefined;
|
|
42
|
-
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
43
|
-
readonly archivist?: string | undefined;
|
|
44
|
-
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
45
|
-
readonly name?: string | undefined;
|
|
46
|
-
readonly paging?: Record<string, {
|
|
47
|
-
size?: number | undefined;
|
|
48
|
-
}> | undefined;
|
|
49
|
-
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
50
|
-
schema: "network.xyo.bridge.config";
|
|
51
|
-
readonly security?: {
|
|
52
|
-
readonly allowAnonymous?: boolean | undefined;
|
|
53
|
-
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
54
|
-
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
55
|
-
} | undefined;
|
|
56
|
-
readonly sign?: boolean | undefined;
|
|
57
|
-
readonly storeQueries?: boolean | undefined;
|
|
58
|
-
readonly timestamp?: boolean | undefined;
|
|
59
|
-
} & {
|
|
60
|
-
discoverCache?: true | import("@xyo-network/bridge-model").CacheConfig | undefined;
|
|
61
|
-
maxDepth?: number | undefined;
|
|
62
|
-
schema: "network.xyo.bridge.config";
|
|
63
|
-
}, "schema"> & {
|
|
64
|
-
schema: string;
|
|
65
|
-
}>, ModuleEventData<object>>;
|
|
66
|
-
get config(): ModuleConfig;
|
|
67
|
-
get downResolver(): import("@xyo-network/module-model").ModuleResolverInstance<ModuleInstance<import("@xylabs/object").BaseParamsFields & {
|
|
68
|
-
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
69
|
-
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
70
|
-
readonly archivist?: string | undefined;
|
|
71
|
-
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
72
|
-
readonly name?: string | undefined;
|
|
73
|
-
readonly paging?: Record<string, {
|
|
74
|
-
size?: number | undefined;
|
|
75
|
-
}> | undefined;
|
|
76
|
-
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
77
|
-
schema: "network.xyo.module.config";
|
|
78
|
-
readonly security?: {
|
|
79
|
-
readonly allowAnonymous?: boolean | undefined;
|
|
80
|
-
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
81
|
-
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
82
|
-
} | undefined;
|
|
83
|
-
readonly sign?: boolean | undefined;
|
|
84
|
-
readonly storeQueries?: boolean | undefined;
|
|
85
|
-
readonly timestamp?: boolean | undefined;
|
|
86
|
-
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
87
|
-
readonly archivist?: string | undefined;
|
|
88
|
-
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
89
|
-
readonly name?: string | undefined;
|
|
90
|
-
readonly paging?: Record<string, {
|
|
91
|
-
size?: number | undefined;
|
|
92
|
-
}> | undefined;
|
|
93
|
-
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
94
|
-
schema: "network.xyo.module.config";
|
|
95
|
-
readonly security?: {
|
|
96
|
-
readonly allowAnonymous?: boolean | undefined;
|
|
97
|
-
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
98
|
-
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
99
|
-
} | undefined;
|
|
100
|
-
readonly sign?: boolean | undefined;
|
|
101
|
-
readonly storeQueries?: boolean | undefined;
|
|
102
|
-
readonly timestamp?: boolean | undefined;
|
|
103
|
-
}, "schema"> & {
|
|
104
|
-
schema: string;
|
|
105
|
-
};
|
|
106
|
-
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
107
|
-
}, ModuleEventData<object>>>;
|
|
108
|
-
get id(): string;
|
|
109
|
-
get queries(): string[];
|
|
110
|
-
addressPreviousHash(): Promise<AddressPreviousHashPayload>;
|
|
111
|
-
busy<R>(closure: () => Promise<R>): Promise<R>;
|
|
112
|
-
describe(): Promise<ModuleDescription>;
|
|
113
|
-
discover(): Promise<Payload[]>;
|
|
114
|
-
manifest(_depth?: number): Promisable<ModuleManifestPayload>;
|
|
115
|
-
moduleAddress(): Promise<AddressPreviousHashPayload[]>;
|
|
116
|
-
previousHash(): Promise<string | undefined>;
|
|
117
|
-
query<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads?: Payload[]): Promise<ModuleQueryResult>;
|
|
118
|
-
queryable(query: QueryBoundWitness, payloads?: Payload[], queryConfig?: ModuleConfig): Promise<boolean>;
|
|
119
|
-
resolve(filter?: ModuleFilter, options?: ModuleFilterOptions): Promise<ModuleInstance[]>;
|
|
120
|
-
resolve(nameOrAddress: string, options?: ModuleFilterOptions): Promise<ModuleInstance | undefined>;
|
|
121
|
-
state(): never[];
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=ProxyModule.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProxyModule.d.ts","sourceRoot":"","sources":["../../src/ProxyModule.ts"],"names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
|
-
import { AccountInstance } from '@xyo-network/account-model'
|
|
5
|
-
import { AddressPayload, AddressSchema } from '@xyo-network/address-payload-plugin'
|
|
6
|
-
import { isArchivistModule } from '@xyo-network/archivist-model'
|
|
7
|
-
import { ArchivistWrapper } from '@xyo-network/archivist-wrapper'
|
|
8
|
-
import { BridgeModule } from '@xyo-network/bridge-model'
|
|
9
|
-
import { isDivinerModule } from '@xyo-network/diviner-model'
|
|
10
|
-
import { DivinerWrapper } from '@xyo-network/diviner-wrapper'
|
|
11
|
-
import {
|
|
12
|
-
AddressModuleFilter,
|
|
13
|
-
Module,
|
|
14
|
-
ModuleFilter,
|
|
15
|
-
ModuleFilterOptions,
|
|
16
|
-
ModuleIdentifier,
|
|
17
|
-
ModuleInstance,
|
|
18
|
-
ModuleResolverInstance,
|
|
19
|
-
NameModuleFilter,
|
|
20
|
-
QueryModuleFilter,
|
|
21
|
-
} from '@xyo-network/module-model'
|
|
22
|
-
import { CompositeModuleResolver } from '@xyo-network/module-resolver'
|
|
23
|
-
import { ModuleWrapper } from '@xyo-network/module-wrapper'
|
|
24
|
-
import { isNodeModule } from '@xyo-network/node-model'
|
|
25
|
-
import { NodeWrapper } from '@xyo-network/node-wrapper'
|
|
26
|
-
import { isSentinelModule } from '@xyo-network/sentinel-model'
|
|
27
|
-
import { SentinelWrapper } from '@xyo-network/sentinel-wrapper'
|
|
28
|
-
import { isWitnessModule } from '@xyo-network/witness-model'
|
|
29
|
-
import { WitnessWrapper } from '@xyo-network/witness-wrapper'
|
|
30
|
-
|
|
31
|
-
import { ProxyModule, ProxyModuleConfigSchema, ProxyModuleParams } from './ProxyModule'
|
|
32
|
-
|
|
33
|
-
export class BridgeModuleResolver<T extends ModuleInstance = ModuleInstance> extends CompositeModuleResolver implements ModuleResolverInstance {
|
|
34
|
-
private primed: Promise<boolean> | undefined = undefined
|
|
35
|
-
private remoteAddresses?: Promise<Address[]>
|
|
36
|
-
private resolvedModules: Record<Address, Promise<ModuleInstance>> = {}
|
|
37
|
-
|
|
38
|
-
// TODO: Allow optional ctor param for supplying address for nested Nodes
|
|
39
|
-
// protected readonly address?: string,
|
|
40
|
-
constructor(
|
|
41
|
-
protected readonly bridge: BridgeModule,
|
|
42
|
-
protected wrapperAccount: AccountInstance,
|
|
43
|
-
protected options?: ModuleFilterOptions<T>,
|
|
44
|
-
) {
|
|
45
|
-
super()
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
override add(module: Module): this
|
|
49
|
-
override add(module: Module[]): this
|
|
50
|
-
override add(_module: Module | Module[]): this {
|
|
51
|
-
throw new Error('Method not implemented.')
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async currentResolvedModules<T extends ModuleInstance = ModuleInstance>(): Promise<Record<string, T>> {
|
|
55
|
-
const result: Record<string, T> = {}
|
|
56
|
-
await Promise.all(
|
|
57
|
-
Object.entries(this.resolvedModules).map(async ([key, value]) => {
|
|
58
|
-
result[key] = (await value) as T
|
|
59
|
-
}),
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
return result
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async getRemoteAddresses() {
|
|
66
|
-
this.remoteAddresses =
|
|
67
|
-
this.remoteAddresses ??
|
|
68
|
-
(async () => {
|
|
69
|
-
const discover = await this.bridge.targetDiscover(undefined, this.options?.maxDepth)
|
|
70
|
-
return compact(
|
|
71
|
-
discover?.map((payload) => {
|
|
72
|
-
if (payload.schema === AddressSchema) {
|
|
73
|
-
const schemaPayload = payload as AddressPayload
|
|
74
|
-
return schemaPayload.address
|
|
75
|
-
} else {
|
|
76
|
-
return null
|
|
77
|
-
}
|
|
78
|
-
}),
|
|
79
|
-
)
|
|
80
|
-
})()
|
|
81
|
-
return await this.remoteAddresses
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
prime() {
|
|
85
|
-
this.primed =
|
|
86
|
-
this.primed ??
|
|
87
|
-
(async () => {
|
|
88
|
-
await this.resolveRemoteModules()
|
|
89
|
-
return true
|
|
90
|
-
})()
|
|
91
|
-
return this.primed
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
override remove(_address: Address | Address[]): this {
|
|
95
|
-
throw new Error('Method not implemented.')
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
reset() {
|
|
99
|
-
this.primed = undefined
|
|
100
|
-
this.remoteAddresses = undefined
|
|
101
|
-
this.resolvedModules = {}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
override async resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter<T>, options?: ModuleFilterOptions<T>): Promise<T[]>
|
|
105
|
-
override async resolve<T extends ModuleInstance = ModuleInstance>(
|
|
106
|
-
nameOrAddress: ModuleIdentifier,
|
|
107
|
-
options?: ModuleFilterOptions<T>,
|
|
108
|
-
): Promise<T | undefined>
|
|
109
|
-
override async resolve<T extends ModuleInstance = ModuleInstance>(
|
|
110
|
-
nameOrAddressOrFilter?: ModuleFilter<T> | ModuleIdentifier,
|
|
111
|
-
options?: ModuleFilterOptions<T>,
|
|
112
|
-
): Promise<T | T[] | undefined> {
|
|
113
|
-
const unfiltered = await (async () => {
|
|
114
|
-
const mutatedOptions = { ...options, maxDepth: (options?.maxDepth ?? BridgeModuleResolver.defaultMaxDepth) - 1 }
|
|
115
|
-
await this.prime()
|
|
116
|
-
await this.resolveRemoteModules()
|
|
117
|
-
if (typeof nameOrAddressOrFilter === 'string') {
|
|
118
|
-
if (mutatedOptions.maxDepth < 0) {
|
|
119
|
-
return
|
|
120
|
-
}
|
|
121
|
-
const result: T | undefined =
|
|
122
|
-
(await this.resolveByAddress<T>(nameOrAddressOrFilter as Address)) ?? (await this.resolveByName<T>(nameOrAddressOrFilter))
|
|
123
|
-
return result
|
|
124
|
-
} else {
|
|
125
|
-
if (mutatedOptions.maxDepth < 0) {
|
|
126
|
-
return []
|
|
127
|
-
}
|
|
128
|
-
const result: T[] = await this.resolveRemoteModules<T>(nameOrAddressOrFilter)
|
|
129
|
-
return result
|
|
130
|
-
}
|
|
131
|
-
})()
|
|
132
|
-
|
|
133
|
-
const identity = options?.identity
|
|
134
|
-
if (identity) {
|
|
135
|
-
return (
|
|
136
|
-
Array.isArray(unfiltered) ? unfiltered?.filter((module) => identity(module))
|
|
137
|
-
: identity(unfiltered) ? unfiltered
|
|
138
|
-
: undefined
|
|
139
|
-
)
|
|
140
|
-
} else {
|
|
141
|
-
return unfiltered
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
private async resolveByAddress<T extends ModuleInstance = ModuleInstance>(targetAddress: Address): Promise<T | undefined> {
|
|
146
|
-
const remoteAddresses = await this.getRemoteAddresses()
|
|
147
|
-
|
|
148
|
-
//check if it is even there
|
|
149
|
-
if (!remoteAddresses.includes(targetAddress)) {
|
|
150
|
-
//this.logger?.log(`Not in RA: ${targetAddress}`)
|
|
151
|
-
return undefined
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const cached = this.resolvedModules[targetAddress]
|
|
155
|
-
if (cached !== undefined) return (await cached) as T
|
|
156
|
-
|
|
157
|
-
this.resolvedModules[targetAddress] =
|
|
158
|
-
this.resolvedModules[targetAddress] ??
|
|
159
|
-
(async (address: Address) => {
|
|
160
|
-
//discover it to set the config in the bridge
|
|
161
|
-
await this.bridge.targetDiscover(address)
|
|
162
|
-
|
|
163
|
-
const mod: Module = new ProxyModule({ address, bridge: this.bridge, config: { schema: ProxyModuleConfigSchema } } as ProxyModuleParams)
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
if (isArchivistModule(mod)) {
|
|
167
|
-
return ArchivistWrapper.wrap(mod, this.wrapperAccount)
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (isDivinerModule(mod)) {
|
|
171
|
-
return DivinerWrapper.wrap(mod, this.wrapperAccount)
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (isWitnessModule(mod)) {
|
|
175
|
-
return WitnessWrapper.wrap(mod, this.wrapperAccount)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (isNodeModule(mod)) {
|
|
179
|
-
return NodeWrapper.wrap(mod, this.wrapperAccount)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (isSentinelModule(mod)) {
|
|
183
|
-
return SentinelWrapper.wrap(mod, this.wrapperAccount)
|
|
184
|
-
}
|
|
185
|
-
console.warn(`BridgeModuleResolver: Unknown Module Type: [${targetAddress}]`)
|
|
186
|
-
return ModuleWrapper.wrap(mod, this.wrapperAccount)
|
|
187
|
-
} catch (ex) {
|
|
188
|
-
handleError(ex, (error) => {
|
|
189
|
-
console.error(`BridgeModuleResolver.resolveByAddress: ${error.message} [${targetAddress}]`)
|
|
190
|
-
})
|
|
191
|
-
}
|
|
192
|
-
})(targetAddress)
|
|
193
|
-
|
|
194
|
-
return (await this.resolvedModules[targetAddress]) as T
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
private async resolveByName<T extends ModuleInstance = ModuleInstance>(name: string): Promise<T | undefined> {
|
|
198
|
-
const modules = await this.currentResolvedModules()
|
|
199
|
-
return Object.values(modules)
|
|
200
|
-
.filter((module) => module.config.name === name)
|
|
201
|
-
.pop() as T
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
private async resolveByQuery<T extends ModuleInstance = ModuleInstance>(queries: string[]): Promise<T[]> {
|
|
205
|
-
return Object.values(await this.currentResolvedModules()).filter((module) => {
|
|
206
|
-
//filter out the requested queries
|
|
207
|
-
const found = module.queries.filter((query) => queries.find((q) => q === query))
|
|
208
|
-
|
|
209
|
-
//did we find all the requested queries?
|
|
210
|
-
return queries.length === found.length
|
|
211
|
-
}) as T[]
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
private async resolveRemoteModules<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter): Promise<T[]> {
|
|
215
|
-
if ((filter as AddressModuleFilter)?.address) {
|
|
216
|
-
return await this.resolveRemoteModulesByAddress<T>(filter as AddressModuleFilter)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if ((filter as NameModuleFilter)?.name) {
|
|
220
|
-
return await this.resolveRemoteModulesByName<T>(filter as NameModuleFilter)
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if ((filter as QueryModuleFilter)?.query) {
|
|
224
|
-
return await this.resolveRemoteModulesByQuery<T>(filter as QueryModuleFilter)
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
//get all of them
|
|
228
|
-
return await this.resolveRemoteModulesByAddress<T>({ address: await this.getRemoteAddresses() })
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
private async resolveRemoteModulesByAddress<T extends ModuleInstance = ModuleInstance>(filter: AddressModuleFilter): Promise<T[]> {
|
|
232
|
-
return compact(await Promise.all(filter.address.map((address) => this.resolveByAddress<T>(address))))
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
private async resolveRemoteModulesByName<T extends ModuleInstance = ModuleInstance>(filter: NameModuleFilter): Promise<T[]> {
|
|
236
|
-
return compact(await Promise.all(filter.name.map(async (name) => await this.resolveByName<T>(name))))
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
private async resolveRemoteModulesByQuery<T extends ModuleInstance = ModuleInstance>(filter: QueryModuleFilter): Promise<T[]> {
|
|
240
|
-
return compact((await Promise.all(filter.query.map(async (query) => await this.resolveByQuery<T>(query)))).flat())
|
|
241
|
-
}
|
|
242
|
-
}
|
package/src/ProxyModule.ts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import { Address } from '@xylabs/hex'
|
|
3
|
-
import { compact } from '@xylabs/lodash'
|
|
4
|
-
import { Promisable } from '@xylabs/promise'
|
|
5
|
-
import { AddressPayload, AddressSchema } from '@xyo-network/address-payload-plugin'
|
|
6
|
-
import { QueryBoundWitness } from '@xyo-network/boundwitness-model'
|
|
7
|
-
import { BridgeModule } from '@xyo-network/bridge-model'
|
|
8
|
-
import { ModuleManifestPayload, ModuleManifestPayloadSchema } from '@xyo-network/manifest-model'
|
|
9
|
-
import { BaseEmitter } from '@xyo-network/module-abstract'
|
|
10
|
-
import {
|
|
11
|
-
AddressPreviousHashPayload,
|
|
12
|
-
ModuleBusyEventArgs,
|
|
13
|
-
ModuleConfig,
|
|
14
|
-
ModuleDescription,
|
|
15
|
-
ModuleEventData,
|
|
16
|
-
ModuleFilter,
|
|
17
|
-
ModuleFilterOptions,
|
|
18
|
-
ModuleInstance,
|
|
19
|
-
ModuleParams,
|
|
20
|
-
ModuleQueryResult,
|
|
21
|
-
} from '@xyo-network/module-model'
|
|
22
|
-
import { CompositeModuleResolver } from '@xyo-network/module-resolver'
|
|
23
|
-
import { Payload } from '@xyo-network/payload-model'
|
|
24
|
-
|
|
25
|
-
export type ProxyModuleConfigSchema = 'network.xyo.module.proxy.config'
|
|
26
|
-
export const ProxyModuleConfigSchema: ProxyModuleConfigSchema = 'network.xyo.module.proxy.config'
|
|
27
|
-
|
|
28
|
-
export type TProxyModuleConfig = ModuleConfig<{ schema: ProxyModuleConfigSchema }>
|
|
29
|
-
|
|
30
|
-
export type ProxyModuleParams = ModuleParams<
|
|
31
|
-
TProxyModuleConfig,
|
|
32
|
-
{
|
|
33
|
-
address: Address
|
|
34
|
-
bridge: BridgeModule
|
|
35
|
-
}
|
|
36
|
-
>
|
|
37
|
-
|
|
38
|
-
export class ProxyModule extends BaseEmitter<ModuleParams, ModuleEventData> implements ModuleInstance<ModuleParams, ModuleEventData> {
|
|
39
|
-
readonly upResolver = new CompositeModuleResolver()
|
|
40
|
-
|
|
41
|
-
private _busyCount = 0
|
|
42
|
-
|
|
43
|
-
constructor(public proxyParams: ProxyModuleParams) {
|
|
44
|
-
super({ config: proxyParams.bridge.targetConfig(proxyParams.address) })
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
get address() {
|
|
48
|
-
return this.proxyParams.address
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get bridge() {
|
|
52
|
-
return this.proxyParams.bridge
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get config(): ModuleConfig {
|
|
56
|
-
return this.bridge.targetConfig(this.address)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
get downResolver() {
|
|
60
|
-
return assertEx(this.bridge.targetDownResolver(this.address), 'Unable to get resolver')
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get id() {
|
|
64
|
-
return this.config.name ?? this.address
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
get queries() {
|
|
68
|
-
return this.bridge.targetQueries(this.address)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
addressPreviousHash(): Promise<AddressPreviousHashPayload> {
|
|
72
|
-
throw new Error('Not Implemented')
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async busy<R>(closure: () => Promise<R>) {
|
|
76
|
-
if (this._busyCount <= 0) {
|
|
77
|
-
this._busyCount = 0
|
|
78
|
-
const args: ModuleBusyEventArgs = { busy: true, module: this }
|
|
79
|
-
await this.emit('moduleBusy', args)
|
|
80
|
-
}
|
|
81
|
-
this._busyCount++
|
|
82
|
-
try {
|
|
83
|
-
return await closure()
|
|
84
|
-
} finally {
|
|
85
|
-
this._busyCount--
|
|
86
|
-
if (this._busyCount <= 0) {
|
|
87
|
-
this._busyCount = 0
|
|
88
|
-
const args: ModuleBusyEventArgs = { busy: false, module: this }
|
|
89
|
-
await this.emit('moduleBusy', args)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async describe(): Promise<ModuleDescription> {
|
|
95
|
-
return await this.busy(async () => {
|
|
96
|
-
const description: ModuleDescription = {
|
|
97
|
-
address: this.address,
|
|
98
|
-
queries: this.queries,
|
|
99
|
-
}
|
|
100
|
-
if (this.config.name) {
|
|
101
|
-
description.name = this.config.name
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const discover = await this.discover()
|
|
105
|
-
|
|
106
|
-
description.children = compact(
|
|
107
|
-
discover?.map((payload) => {
|
|
108
|
-
const address = payload.schema === AddressSchema ? (payload as AddressPayload).address : undefined
|
|
109
|
-
return address == this.address ? undefined : address
|
|
110
|
-
}) ?? [],
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
return description
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async discover(): Promise<Payload[]> {
|
|
118
|
-
return await this.busy(async () => {
|
|
119
|
-
return await this.bridge.targetDiscover()
|
|
120
|
-
})
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
manifest(_depth?: number): Promisable<ModuleManifestPayload> {
|
|
124
|
-
const name = this.config.name ?? 'Anonymous'
|
|
125
|
-
return { config: { name, ...this.config }, schema: ModuleManifestPayloadSchema }
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
moduleAddress(): Promise<AddressPreviousHashPayload[]> {
|
|
129
|
-
throw new Error('Not Implemented')
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
previousHash(): Promise<string | undefined> {
|
|
133
|
-
throw new Error('Not Implemented')
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async query<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads?: Payload[]): Promise<ModuleQueryResult> {
|
|
137
|
-
return await this.busy(async () => {
|
|
138
|
-
const result = assertEx(await this.bridge.targetQuery(this.address, query, payloads), 'Remote Query Failed')
|
|
139
|
-
await this.emit('moduleQueried', { module: this, payloads, query, result })
|
|
140
|
-
return result
|
|
141
|
-
})
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async queryable(query: QueryBoundWitness, payloads?: Payload[], queryConfig?: ModuleConfig): Promise<boolean> {
|
|
145
|
-
return await this.bridge.targetQueryable(this.address, query, payloads, queryConfig)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/* Resolves a filter from the perspective of the module, including through the parent/gateway module */
|
|
149
|
-
resolve(filter?: ModuleFilter, options?: ModuleFilterOptions): Promise<ModuleInstance[]>
|
|
150
|
-
resolve(nameOrAddress: string, options?: ModuleFilterOptions): Promise<ModuleInstance | undefined>
|
|
151
|
-
async resolve(
|
|
152
|
-
nameOrAddressOrFilter?: ModuleFilter | string,
|
|
153
|
-
options?: ModuleFilterOptions,
|
|
154
|
-
): Promise<ModuleInstance | ModuleInstance[] | undefined> {
|
|
155
|
-
return await this.busy(async () => {
|
|
156
|
-
return await (typeof nameOrAddressOrFilter === 'string' ?
|
|
157
|
-
this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options)
|
|
158
|
-
: this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options))
|
|
159
|
-
})
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
state() {
|
|
163
|
-
return []
|
|
164
|
-
}
|
|
165
|
-
}
|