Compare commits
10 Commits
v0.0.1
...
v0.1.0-dev
Author | SHA1 | Date |
---|---|---|
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,6 @@
|
|||
# [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
|
||||
|
||||
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:
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "@lumeweb/kernel-network-registry",
|
||||
"version": "0.1.0-develop.1",
|
||||
"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.20"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lumeweb/presetter-kernel-module-preset": "^0.1.0-develop.43"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
import { ActiveQuery, addHandler } from "@lumeweb/libkernel/module";
|
||||
|
||||
const types: Set<string> = new Set<string>();
|
||||
const networks: Map<string, Set<string>> = new Map<string, Set<string>>();
|
||||
|
||||
addHandler("registerType", handleRegisterType);
|
||||
addHandler("getTypes", handleGetTypes);
|
||||
addHandler("getNetworkTypes", handleGetNetworkType);
|
||||
addHandler("registerNetwork", handleRegisterNetwork);
|
||||
|
||||
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]));
|
||||
}
|
||||
|
||||
aq.respond();
|
||||
}
|
||||
|
||||
function handleGetNetworkType(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(),
|
||||
]);
|
||||
}
|
Loading…
Reference in New Issue