Compare commits
3 Commits
v0.1.0-dev
...
v0.1.0-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | ebb8302123 | |
Derrick Hammer | 32638417df | |
Derrick Hammer | 75c25d7cab |
|
@ -1,3 +1,10 @@
|
|||
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/kernel-network-registry/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-07-19)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add getNetworksByType api call ([75c25d7](https://git.lumeweb.com/LumeWeb/kernel-network-registry/commit/75c25d7cab1240d6f2b194af9f262f76f98c6b48))
|
||||
|
||||
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/kernel-network-registry/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-07-19)
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@lumeweb/kernel-network-registry",
|
||||
"version": "0.1.0-develop.2",
|
||||
"version": "0.1.0-develop.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lumeweb/kernel-network-registry",
|
||||
"version": "0.1.0-develop.2",
|
||||
"version": "0.1.0-develop.3",
|
||||
"dependencies": {
|
||||
"@lumeweb/libkernel": "^0.1.0-develop.20"
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lumeweb/kernel-network-registry",
|
||||
"version": "0.1.0-develop.2",
|
||||
"version": "0.1.0-develop.3",
|
||||
"type": "module",
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
|
|
21
src/index.ts
21
src/index.ts
|
@ -6,6 +6,7 @@ const networks: Map<string, Set<string>> = new Map<string, Set<string>>();
|
|||
addHandler("registerType", handleRegisterType);
|
||||
addHandler("getTypes", handleGetTypes);
|
||||
addHandler("getNetworkTypes", handleGetNetworkTypes);
|
||||
addHandler("getNetworksByType", handleGetNetworksByType);
|
||||
addHandler("registerNetwork", handleRegisterNetwork);
|
||||
|
||||
function handleRegisterType(aq: ActiveQuery) {
|
||||
|
@ -55,3 +56,23 @@ function handleGetNetworkTypes(aq: ActiveQuery) {
|
|||
...(networks.get(aq.callerInput.module) as Set<string>).values(),
|
||||
]);
|
||||
}
|
||||
|
||||
function handleGetNetworksByType(aq: ActiveQuery) {
|
||||
if (!("type" in aq.callerInput)) {
|
||||
aq.reject("type missing");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!types.has(aq.callerInput)) {
|
||||
aq.reject("type not registered");
|
||||
return;
|
||||
}
|
||||
|
||||
aq.respond(
|
||||
[...networks.entries()]
|
||||
.filter((item) => {
|
||||
return item[1].has(aq.callerInput);
|
||||
})
|
||||
.map((item) => item[0]),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue