Compare commits

...

34 Commits

Author SHA1 Message Date
semantic-release-bot 8b411113ff chore(release): 0.1.0-develop.9 [skip ci]
# [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](f11297d5cd))
2023-10-09 03:32:56 +00:00
Derrick Hammer 237d936fe7
Merge remote-tracking branch 'origin/develop' into develop 2023-10-08 23:31:44 -04:00
Derrick Hammer f11297d5cd
feat: add subscribeToUpdates method to listen for updates 2023-10-08 23:31:35 -04:00
semantic-release-bot 09edbc1658 chore(release): 0.1.0-develop.8 [skip ci]
# [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)
2023-09-03 05:04:30 +00:00
Derrick Hammer 78c02b260b
Merge remote-tracking branch 'origin/develop' into develop 2023-09-03 01:03:08 -04:00
Derrick Hammer dc62f4b4f7
dep: update libkernel 2023-09-03 01:03:02 -04:00
semantic-release-bot cdf1925d3c chore(release): 0.1.0-develop.7 [skip ci]
# [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)
2023-09-02 17:30:04 +00:00
Derrick Hammer c994baa8a6
Merge remote-tracking branch 'origin/develop' into develop 2023-09-02 13:29:03 -04:00
Derrick Hammer a3fafcd698
dep: update libkernel 2023-09-02 13:28:51 -04:00
semantic-release-bot 10e03b6065 chore(release): 0.1.0-develop.6 [skip ci]
# [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](dc50c7a068))
2023-07-23 00:49:44 +00:00
Derrick Hammer 4454e8efaa
Merge remote-tracking branch 'origin/develop' into develop 2023-07-22 20:48:47 -04:00
Derrick Hammer dc50c7a068
fix: array handling 2023-07-22 20:48:43 -04:00
semantic-release-bot 034f2ff9c8 chore(release): 0.1.0-develop.5 [skip ci]
# [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)
2023-07-21 17:25:21 +00:00
Derrick Hammer 767b85b380
Merge remote-tracking branch 'origin/develop' into develop 2023-07-21 13:24:24 -04:00
Derrick Hammer faae706847
dep: update libkernel 2023-07-21 13:24:16 -04:00
semantic-release-bot 17b6aa5cc8 chore(release): 0.1.0-develop.4 [skip ci]
# [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](c5dd605571))
2023-07-19 17:19:32 +00:00
Derrick Hammer 2a30fd69f0
Merge remote-tracking branch 'origin/develop' into develop 2023-07-19 13:18:28 -04:00
Derrick Hammer c5dd605571
fix: inconsistent input use on handleGetNetworksByType 2023-07-19 13:17:52 -04:00
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
semantic-release-bot 6b3f1122a2 chore(release): 0.1.0-develop.2 [skip ci]
# [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](d9163a4e53))
2023-07-19 15:19:41 +00:00
Derrick Hammer 8bac2e4aab
Merge remote-tracking branch 'origin/develop' into develop 2023-07-19 11:18:42 -04:00
Derrick Hammer d9163a4e53
fix: rename handleGetNetworkType 2023-07-19 11:18:34 -04:00
semantic-release-bot 8736eba69b chore(release): 0.1.0-develop.1 [skip ci]
# [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](60be134659))
2023-07-19 14:58:46 +00:00
Derrick Hammer d6c8e85871
ci: fix typo 2023-07-19 10:57:41 -04:00
Derrick Hammer 31593ed793
ci: setup 2023-07-19 10:55:47 -04:00
Derrick Hammer 9bb3dd8726
ci: add official to .presetterrc.json 2023-07-19 10:55:26 -04:00
Derrick Hammer 8e34937cff
ci: add presetter-kernel-module-preset 2023-07-19 10:53:27 -04:00
Derrick Hammer b1f6fcbdc9
ci: add npm-shrinkwrap.json 2023-07-19 10:48:28 -04:00
Derrick Hammer 86bede9499
chore: update LICENSE 2023-07-19 10:48:28 -04:00
Derrick Hammer 1c8cec3a15
ci: update package.json 2023-07-19 10:48:28 -04:00
Derrick Hammer b05aa99d52
ci: add .presetterrc.json 2023-07-19 10:48:27 -04:00
Derrick Hammer 60be134659
feat: initial version 2023-07-19 10:48:27 -04:00
8 changed files with 19984 additions and 2 deletions

13
.github/workflows/ci.yml vendored Normal file
View File

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

8
.presetterrc.json Normal file
View File

@ -0,0 +1,8 @@
{
"preset": [
"@lumeweb/presetter-kernel-module-preset"
],
"config": {
"official": true
}
}

47
CHANGELOG.md Normal file
View File

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

View File

@ -1,6 +1,6 @@
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:

View File

@ -1,2 +1,2 @@
# kernel-module-network-registry
# kernel-network-registry

19794
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

21
package.json Normal file
View File

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

99
src/index.ts Normal file
View File

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