Compare commits

...

3 Commits

Author SHA1 Message Date
semantic-release-bot ebb8302123 chore(release): 0.1.0-develop.3 [skip ci]
# [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](75c25d7cab))
2023-07-19 17:15:25 +00:00
Derrick Hammer 32638417df
Merge remote-tracking branch 'origin/develop' into develop 2023-07-19 13:14:26 -04:00
Derrick Hammer 75c25d7cab
feat: add getNetworksByType api call 2023-07-19 13:14:16 -04:00
4 changed files with 31 additions and 3 deletions

View File

@ -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)

4
npm-shrinkwrap.json generated
View File

@ -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"
},

View File

@ -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": {

View File

@ -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]),
);
}