@xyo-network/module-abstract 2.70.3 → 2.70.4
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/cjs/Resolver/SimpleModuleResolver.js +27 -21
- package/dist/cjs/Resolver/SimpleModuleResolver.js.map +1 -1
- package/dist/docs.json +622 -489
- package/dist/esm/Resolver/SimpleModuleResolver.js +27 -21
- package/dist/esm/Resolver/SimpleModuleResolver.js.map +1 -1
- package/dist/types/Resolver/SimpleModuleResolver.d.ts +3 -3
- package/dist/types/Resolver/SimpleModuleResolver.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/Resolver/SimpleModuleResolver.ts +61 -47
|
@@ -31,27 +31,33 @@ export class SimpleModuleResolver {
|
|
|
31
31
|
removeResolver(_resolver) {
|
|
32
32
|
throw 'Removing resolvers not supported';
|
|
33
33
|
}
|
|
34
|
-
resolve(nameOrAddressOrFilter) {
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
resolve(nameOrAddressOrFilter, options) {
|
|
35
|
+
const unfiltered = (() => {
|
|
36
|
+
if (nameOrAddressOrFilter) {
|
|
37
|
+
if (typeof nameOrAddressOrFilter === 'string') {
|
|
38
|
+
return (this.resolveByName(Object.values(this.modules), [nameOrAddressOrFilter]).pop() ??
|
|
39
|
+
this.resolveByAddress(Object.values(this.modules), [nameOrAddressOrFilter]).pop());
|
|
40
|
+
}
|
|
41
|
+
else if (nameOrAddressOrFilter.address) {
|
|
42
|
+
return this.resolveByAddress(Object.values(this.modules), nameOrAddressOrFilter.address);
|
|
43
|
+
}
|
|
44
|
+
else if (nameOrAddressOrFilter.name) {
|
|
45
|
+
return this.resolveByName(Object.values(this.modules), nameOrAddressOrFilter.name);
|
|
46
|
+
}
|
|
47
|
+
else if (nameOrAddressOrFilter.query) {
|
|
48
|
+
return this.resolveByQuery(Object.values(this.modules), nameOrAddressOrFilter.query);
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
|
-
else
|
|
50
|
-
return
|
|
51
|
+
else {
|
|
52
|
+
return Object.values(this.modules);
|
|
51
53
|
}
|
|
54
|
+
})();
|
|
55
|
+
const identity = options?.identity;
|
|
56
|
+
if (identity) {
|
|
57
|
+
return Array.isArray(unfiltered) ? unfiltered?.filter((module) => identity(module)) : identity(unfiltered) ? unfiltered : undefined;
|
|
52
58
|
}
|
|
53
59
|
else {
|
|
54
|
-
return
|
|
60
|
+
return unfiltered;
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
addSingleModule(module) {
|
|
@@ -71,11 +77,11 @@ export class SimpleModuleResolver {
|
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
resolveByAddress(modules, address) {
|
|
74
|
-
return address
|
|
80
|
+
return (address
|
|
75
81
|
? compact(flatten(address?.map((address) => {
|
|
76
82
|
return modules.filter((module) => module.address === address);
|
|
77
83
|
})))
|
|
78
|
-
: modules;
|
|
84
|
+
: modules);
|
|
79
85
|
}
|
|
80
86
|
resolveByName(modules, name) {
|
|
81
87
|
if (name) {
|
|
@@ -84,14 +90,14 @@ export class SimpleModuleResolver {
|
|
|
84
90
|
return modules;
|
|
85
91
|
}
|
|
86
92
|
resolveByQuery(modules, query) {
|
|
87
|
-
return query
|
|
93
|
+
return (query
|
|
88
94
|
? compact(modules.filter((module) => query?.reduce((supported, queryList) => {
|
|
89
95
|
return (queryList.reduce((supported, query) => {
|
|
90
96
|
const queryable = module.queries.includes(query);
|
|
91
97
|
return supported && queryable;
|
|
92
98
|
}, true) || supported);
|
|
93
99
|
}, false)))
|
|
94
|
-
: modules;
|
|
100
|
+
: modules);
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
103
|
//# sourceMappingURL=SimpleModuleResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleModuleResolver.js","sourceRoot":"","sources":["../../../src/Resolver/SimpleModuleResolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SimpleModuleResolver.js","sourceRoot":"","sources":["../../../src/Resolver/SimpleModuleResolver.ts"],"names":[],"mappings":"AAWA,OAAO,OAAO,MAAM,gBAAgB,CAAA;AACpC,OAAO,OAAO,MAAM,gBAAgB,CAAA;AAEpC,gEAAgE;AAChE,MAAM,OAAO,oBAAoB;IACvB,aAAa,GAA2B,EAAE,CAAA;IAC1C,OAAO,GAAmC,EAAE,CAAA;IAEpD,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAID,GAAG,CAAC,MAAyC;QAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzB,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;SACzD;aAAM;YACL,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;SAC7B;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,WAAW,CAAC,SAAyB;QACnC,MAAM,gCAAgC,CAAA;IACxC,CAAC;IAED,MAAM,CAAC,OAA0B;QAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC1B,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAA;SAC/D;aAAM;YACL,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;SACjC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,cAAc,CAAC,SAAyB;QACtC,MAAM,kCAAkC,CAAA;IAC1C,CAAC;IAID,OAAO,CACL,qBAAgD,EAChD,OAAgC;QAEhC,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE;YACvB,IAAI,q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OAAO,OAAc,CAAA;IACvB,CAAC;IAEO,cAAc,CAA4C,OAAyB,EAAE,KAAkB;QAC7G,OAAO,CACL,KAAK;YACH,CAAC,CAAC,OAAO,CACL,OAAO,CAAC,MAAM,CACZ,CAAC,MAAM,EAAE,EAAE,CACT,KAAK,EAAE,MAAM,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;gBACrC,OAAO,CACL,SAAS,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;oBACpC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;oBAChD,OAAO,SAAS,IAAI,SAAS,CAAA;gBAC/B,CAAC,EAAE,IAAI,CAAC,IAAI,SAAS,CACtB,CAAA;YACH,CAAC,EAAE,KAAK,CAAC,CACZ,CACF;YACH,CAAC,CAAC,OAAO,CACL,CAAA;IACV,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleFilter, ModuleInstance, ModuleRepository, ModuleResolver } from '@xyo-network/module-model';
|
|
1
|
+
import { ModuleFilter, ModuleFilterOptions, ModuleInstance, ModuleRepository, ModuleResolver } from '@xyo-network/module-model';
|
|
2
2
|
import { Promisable } from '@xyo-network/promise';
|
|
3
3
|
export declare class SimpleModuleResolver implements ModuleRepository {
|
|
4
4
|
private addressToName;
|
|
@@ -9,8 +9,8 @@ export declare class SimpleModuleResolver implements ModuleRepository {
|
|
|
9
9
|
addResolver(_resolver: ModuleResolver): this;
|
|
10
10
|
remove(address: string | string[]): this;
|
|
11
11
|
removeResolver(_resolver: ModuleResolver): this;
|
|
12
|
-
resolve(filter?: ModuleFilter): Promisable<
|
|
13
|
-
resolve(nameOrAddress: string): Promisable<
|
|
12
|
+
resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter<T>, options?: ModuleFilterOptions<T>): Promisable<T[]>;
|
|
13
|
+
resolve<T extends ModuleInstance = ModuleInstance>(nameOrAddress: string, options?: ModuleFilterOptions<T>): Promisable<T | undefined>;
|
|
14
14
|
private addSingleModule;
|
|
15
15
|
private removeSingleModule;
|
|
16
16
|
private resolveByAddress;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleModuleResolver.d.ts","sourceRoot":"","sources":["../../../src/Resolver/SimpleModuleResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,cAAc,EAGf,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAKjD,qBAAa,oBAAqB,YAAW,gBAAgB;IAC3D,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,OAAO,CAAqC;IAEpD,IAAI,gBAAgB,YAEnB;IAED,GAAG,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IACjC,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI;IAUnC,WAAW,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI;IAI5C,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IASxC,cAAc,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI;IAI/C,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"SimpleModuleResolver.d.ts","sourceRoot":"","sources":["../../../src/Resolver/SimpleModuleResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,cAAc,EAGf,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAKjD,qBAAa,oBAAqB,YAAW,gBAAgB;IAC3D,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,OAAO,CAAqC;IAEpD,IAAI,gBAAgB,YAEnB;IAED,GAAG,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IACjC,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI;IAUnC,WAAW,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI;IAI5C,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IASxC,cAAc,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI;IAI/C,OAAO,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,EAAE,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC;IAC/H,OAAO,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC;IA+BtI,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,cAAc;CAmBvB"}
|
package/package.json
CHANGED
|
@@ -12,23 +12,23 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/assert": "^2.9.3",
|
|
14
14
|
"@xylabs/exists": "^2.9.3",
|
|
15
|
-
"@xyo-network/account": "~2.70.
|
|
16
|
-
"@xyo-network/account-model": "~2.70.
|
|
17
|
-
"@xyo-network/address-payload-plugin": "~2.70.
|
|
18
|
-
"@xyo-network/archivist-model": "~2.70.
|
|
19
|
-
"@xyo-network/boundwitness-builder": "~2.70.
|
|
20
|
-
"@xyo-network/boundwitness-model": "~2.70.
|
|
21
|
-
"@xyo-network/config-payload-plugin": "~2.70.
|
|
22
|
-
"@xyo-network/core": "~2.70.
|
|
23
|
-
"@xyo-network/error": "~2.70.
|
|
24
|
-
"@xyo-network/manifest-model": "~2.70.
|
|
25
|
-
"@xyo-network/module-events": "~2.70.
|
|
26
|
-
"@xyo-network/module-model": "~2.70.
|
|
27
|
-
"@xyo-network/payload-builder": "~2.70.
|
|
28
|
-
"@xyo-network/payload-model": "~2.70.
|
|
29
|
-
"@xyo-network/promise": "~2.70.
|
|
30
|
-
"@xyo-network/query-payload-plugin": "~2.70.
|
|
31
|
-
"@xyo-network/shared": "~2.70.
|
|
15
|
+
"@xyo-network/account": "~2.70.4",
|
|
16
|
+
"@xyo-network/account-model": "~2.70.4",
|
|
17
|
+
"@xyo-network/address-payload-plugin": "~2.70.4",
|
|
18
|
+
"@xyo-network/archivist-model": "~2.70.4",
|
|
19
|
+
"@xyo-network/boundwitness-builder": "~2.70.4",
|
|
20
|
+
"@xyo-network/boundwitness-model": "~2.70.4",
|
|
21
|
+
"@xyo-network/config-payload-plugin": "~2.70.4",
|
|
22
|
+
"@xyo-network/core": "~2.70.4",
|
|
23
|
+
"@xyo-network/error": "~2.70.4",
|
|
24
|
+
"@xyo-network/manifest-model": "~2.70.4",
|
|
25
|
+
"@xyo-network/module-events": "~2.70.4",
|
|
26
|
+
"@xyo-network/module-model": "~2.70.4",
|
|
27
|
+
"@xyo-network/payload-builder": "~2.70.4",
|
|
28
|
+
"@xyo-network/payload-model": "~2.70.4",
|
|
29
|
+
"@xyo-network/promise": "~2.70.4",
|
|
30
|
+
"@xyo-network/query-payload-plugin": "~2.70.4",
|
|
31
|
+
"@xyo-network/shared": "~2.70.4",
|
|
32
32
|
"lodash": "^4.17.21"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
},
|
|
72
72
|
"sideEffects": false,
|
|
73
73
|
"types": "dist/types/index.d.ts",
|
|
74
|
-
"version": "2.70.
|
|
74
|
+
"version": "2.70.4"
|
|
75
75
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AddressModuleFilter,
|
|
3
3
|
ModuleFilter,
|
|
4
|
+
ModuleFilterOptions,
|
|
4
5
|
ModuleInstance,
|
|
5
6
|
ModuleRepository,
|
|
6
7
|
ModuleResolver,
|
|
@@ -48,26 +49,35 @@ export class SimpleModuleResolver implements ModuleRepository {
|
|
|
48
49
|
throw 'Removing resolvers not supported'
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
resolve(filter?: ModuleFilter): Promisable<
|
|
52
|
-
resolve(nameOrAddress: string): Promisable<
|
|
53
|
-
resolve
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter<T>, options?: ModuleFilterOptions<T>): Promisable<T[]>
|
|
53
|
+
resolve<T extends ModuleInstance = ModuleInstance>(nameOrAddress: string, options?: ModuleFilterOptions<T>): Promisable<T | undefined>
|
|
54
|
+
resolve<T extends ModuleInstance = ModuleInstance>(
|
|
55
|
+
nameOrAddressOrFilter?: ModuleFilter<T> | string,
|
|
56
|
+
options?: ModuleFilterOptions<T>,
|
|
57
|
+
): Promisable<T[] | T | undefined> {
|
|
58
|
+
const unfiltered = (() => {
|
|
59
|
+
if (nameOrAddressOrFilter) {
|
|
60
|
+
if (typeof nameOrAddressOrFilter === 'string') {
|
|
61
|
+
return (
|
|
62
|
+
this.resolveByName<T>(Object.values(this.modules), [nameOrAddressOrFilter]).pop() ??
|
|
63
|
+
this.resolveByAddress<T>(Object.values(this.modules), [nameOrAddressOrFilter]).pop()
|
|
64
|
+
)
|
|
65
|
+
} else if ((nameOrAddressOrFilter as AddressModuleFilter).address) {
|
|
66
|
+
return this.resolveByAddress<T>(Object.values(this.modules), (nameOrAddressOrFilter as AddressModuleFilter).address)
|
|
67
|
+
} else if ((nameOrAddressOrFilter as NameModuleFilter).name) {
|
|
68
|
+
return this.resolveByName<T>(Object.values(this.modules), (nameOrAddressOrFilter as NameModuleFilter).name)
|
|
69
|
+
} else if ((nameOrAddressOrFilter as QueryModuleFilter).query) {
|
|
70
|
+
return this.resolveByQuery<T>(Object.values(this.modules), (nameOrAddressOrFilter as QueryModuleFilter).query)
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
return Object.values(this.modules) as T[]
|
|
68
74
|
}
|
|
75
|
+
})()
|
|
76
|
+
const identity = options?.identity
|
|
77
|
+
if (identity) {
|
|
78
|
+
return Array.isArray(unfiltered) ? unfiltered?.filter((module) => identity(module)) : identity(unfiltered) ? unfiltered : undefined
|
|
69
79
|
} else {
|
|
70
|
-
return
|
|
80
|
+
return unfiltered
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
83
|
|
|
@@ -89,40 +99,44 @@ export class SimpleModuleResolver implements ModuleRepository {
|
|
|
89
99
|
}
|
|
90
100
|
}
|
|
91
101
|
|
|
92
|
-
private resolveByAddress<T extends ModuleInstance = ModuleInstance>(modules:
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
private resolveByAddress<T extends ModuleInstance = ModuleInstance>(modules: ModuleInstance[], address?: string[]): T[] {
|
|
103
|
+
return (
|
|
104
|
+
address
|
|
105
|
+
? compact(
|
|
106
|
+
flatten(
|
|
107
|
+
address?.map((address) => {
|
|
108
|
+
return modules.filter((module) => module.address === address)
|
|
109
|
+
}),
|
|
110
|
+
),
|
|
111
|
+
)
|
|
112
|
+
: modules
|
|
113
|
+
) as T[]
|
|
102
114
|
}
|
|
103
115
|
|
|
104
|
-
private resolveByName<T extends ModuleInstance = ModuleInstance>(modules:
|
|
116
|
+
private resolveByName<T extends ModuleInstance = ModuleInstance>(modules: ModuleInstance[], name?: string[]): T[] {
|
|
105
117
|
if (name) {
|
|
106
|
-
return compact(name.map((name) => modules.filter((module) => module.config?.name === name)).flat())
|
|
118
|
+
return compact(name.map((name) => modules.filter((module) => module.config?.name === name)).flat()) as T[]
|
|
107
119
|
}
|
|
108
|
-
return modules
|
|
120
|
+
return modules as T[]
|
|
109
121
|
}
|
|
110
122
|
|
|
111
|
-
private resolveByQuery<T extends ModuleInstance = ModuleInstance>(modules:
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
private resolveByQuery<T extends ModuleInstance = ModuleInstance>(modules: ModuleInstance[], query?: string[][]): T[] {
|
|
124
|
+
return (
|
|
125
|
+
query
|
|
126
|
+
? compact(
|
|
127
|
+
modules.filter(
|
|
128
|
+
(module) =>
|
|
129
|
+
query?.reduce((supported, queryList) => {
|
|
130
|
+
return (
|
|
131
|
+
queryList.reduce((supported, query) => {
|
|
132
|
+
const queryable = module.queries.includes(query)
|
|
133
|
+
return supported && queryable
|
|
134
|
+
}, true) || supported
|
|
135
|
+
)
|
|
136
|
+
}, false),
|
|
137
|
+
),
|
|
138
|
+
)
|
|
139
|
+
: modules
|
|
140
|
+
) as T[]
|
|
127
141
|
}
|
|
128
142
|
}
|