Compare commits
34 Commits
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | 8b411113ff | |
Derrick Hammer | 237d936fe7 | |
Derrick Hammer | f11297d5cd | |
semantic-release-bot | 09edbc1658 | |
Derrick Hammer | 78c02b260b | |
Derrick Hammer | dc62f4b4f7 | |
semantic-release-bot | cdf1925d3c | |
Derrick Hammer | c994baa8a6 | |
Derrick Hammer | a3fafcd698 | |
semantic-release-bot | 10e03b6065 | |
Derrick Hammer | 4454e8efaa | |
Derrick Hammer | dc50c7a068 | |
semantic-release-bot | 034f2ff9c8 | |
Derrick Hammer | 767b85b380 | |
Derrick Hammer | faae706847 | |
semantic-release-bot | 17b6aa5cc8 | |
Derrick Hammer | 2a30fd69f0 | |
Derrick Hammer | c5dd605571 | |
semantic-release-bot | ebb8302123 | |
Derrick Hammer | 32638417df | |
Derrick Hammer | 75c25d7cab | |
semantic-release-bot | 6b3f1122a2 | |
Derrick Hammer | 8bac2e4aab | |
Derrick Hammer | d9163a4e53 | |
semantic-release-bot | 8736eba69b | |
Derrick Hammer | d6c8e85871 | |
Derrick Hammer | 31593ed793 | |
Derrick Hammer | 9bb3dd8726 | |
Derrick Hammer | 8e34937cff | |
Derrick Hammer | b1f6fcbdc9 | |
Derrick Hammer | 86bede9499 | |
Derrick Hammer | 1c8cec3a15 | |
Derrick Hammer | b05aa99d52 | |
Derrick Hammer | 60be134659 |
|
@ -0,0 +1,13 @@
|
||||||
|
name: Build/Publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- develop-*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
|
||||||
|
secrets: inherit
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"preset": [
|
||||||
|
"@lumeweb/presetter-kernel-module-preset"
|
||||||
|
],
|
||||||
|
"config": {
|
||||||
|
"official": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
# [0.1.0-develop.9](https://git.lumeweb.com/LumeWeb/kernel-network-registry/compare/v0.1.0-develop.8...v0.1.0-develop.9) (2023-10-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add subscribeToUpdates method to listen for updates ([f11297d](https://git.lumeweb.com/LumeWeb/kernel-network-registry/commit/f11297d5cd0dc06d0f7ed5b43cf1b5d939596b7a))
|
||||||
|
|
||||||
|
# [0.1.0-develop.8](https://git.lumeweb.com/LumeWeb/kernel-network-registry/compare/v0.1.0-develop.7...v0.1.0-develop.8) (2023-09-03)
|
||||||
|
|
||||||
|
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/kernel-network-registry/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-09-02)
|
||||||
|
|
||||||
|
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/kernel-network-registry/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-07-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* array handling ([dc50c7a](https://git.lumeweb.com/LumeWeb/kernel-network-registry/commit/dc50c7a068b03b6c48a72884693e1989e9ba9dec))
|
||||||
|
|
||||||
|
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/kernel-network-registry/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-07-21)
|
||||||
|
|
||||||
|
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/kernel-network-registry/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-07-19)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* inconsistent input use on handleGetNetworksByType ([c5dd605](https://git.lumeweb.com/LumeWeb/kernel-network-registry/commit/c5dd60557129586fc0c0afb1a0f2c93e28deebcf))
|
||||||
|
|
||||||
|
# [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)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* rename handleGetNetworkType ([d9163a4](https://git.lumeweb.com/LumeWeb/kernel-network-registry/commit/d9163a4e530745d36a26ea8cbad5fb8ef35c3b93))
|
||||||
|
|
||||||
|
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/kernel-network-registry/compare/v0.0.1...v0.1.0-develop.1) (2023-07-19)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* initial version ([60be134](https://git.lumeweb.com/LumeWeb/kernel-network-registry/commit/60be1346596c3413134d97dd195567ba2a2e5314))
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2023 LumeWeb
|
Copyright (c) 2023 Hammer Technologies LLC
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"name": "@lumeweb/kernel-network-registry",
|
||||||
|
"version": "0.1.0-develop.9",
|
||||||
|
"type": "module",
|
||||||
|
"readme": "ERROR: No README data found!",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "gitea@git.lumeweb.com:LumeWeb/kernel-network-registry.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"prepare": "presetter bootstrap",
|
||||||
|
"build": "run build",
|
||||||
|
"semantic-release": "semantic-release"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@lumeweb/libkernel": "^0.1.0-develop.39"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@lumeweb/presetter-kernel-module-preset": "^0.1.0-develop.43"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
import { ActiveQuery, addHandler } from "@lumeweb/libkernel/module";
|
||||||
|
import { EventEmitter } from "events";
|
||||||
|
|
||||||
|
const types: Set<string> = new Set<string>();
|
||||||
|
const networks: Map<string, Set<string>> = new Map<string, Set<string>>();
|
||||||
|
|
||||||
|
const events = new EventEmitter();
|
||||||
|
|
||||||
|
addHandler("registerType", handleRegisterType);
|
||||||
|
addHandler("getTypes", handleGetTypes);
|
||||||
|
addHandler("getNetworkTypes", handleGetNetworkTypes);
|
||||||
|
addHandler("getNetworksByType", handleGetNetworksByType);
|
||||||
|
addHandler("registerNetwork", handleRegisterNetwork);
|
||||||
|
addHandler("subscribeToUpdates", handleSubscribeToUpdates, {
|
||||||
|
receiveUpdates: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleRegisterType(aq: ActiveQuery) {
|
||||||
|
types.add(aq.callerInput);
|
||||||
|
|
||||||
|
aq.respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleGetTypes(aq: ActiveQuery) {
|
||||||
|
aq.respond([...types.values()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRegisterNetwork(aq: ActiveQuery) {
|
||||||
|
if (!("types" in aq.callerInput)) {
|
||||||
|
aq.reject("types missing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Array.isArray(aq.callerInput.types)) {
|
||||||
|
aq.reject("types must be an array");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let network = networks.get(aq.domain);
|
||||||
|
|
||||||
|
if (network) {
|
||||||
|
[...aq.callerInput.type].forEach((item) => network?.add(item));
|
||||||
|
} else {
|
||||||
|
networks.set(aq.domain, new Set([...aq.callerInput.types]));
|
||||||
|
}
|
||||||
|
|
||||||
|
events.emit("update");
|
||||||
|
|
||||||
|
aq.respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleGetNetworkTypes(aq: ActiveQuery) {
|
||||||
|
if (!("module" in aq.callerInput)) {
|
||||||
|
aq.reject("module missing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!networks.has(aq.callerInput.module)) {
|
||||||
|
aq.reject("module is not registered");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
aq.respond([
|
||||||
|
...(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.type)) {
|
||||||
|
aq.reject("type not registered");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
aq.respond(
|
||||||
|
[...networks.entries()]
|
||||||
|
.filter((item) => {
|
||||||
|
return item[1].has(aq.callerInput.type);
|
||||||
|
})
|
||||||
|
.map((item) => item[0]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSubscribeToUpdates(aq: ActiveQuery) {
|
||||||
|
const cb = () => {
|
||||||
|
aq.sendUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
|
events.on("update", cb);
|
||||||
|
|
||||||
|
aq.setReceiveUpdate?.(() => {
|
||||||
|
events.off("update", cb);
|
||||||
|
aq.respond();
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue