@uns-kit/api 0.0.18 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Aljoša Vister
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Aljoša Vister
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,51 +1,51 @@
1
- # @uns-kit/api
2
-
3
- `@uns-kit/api` exposes Express-based HTTP endpoints for UNS deployments. The plugin attaches a `createApiProxy` method to `UnsProxyProcess`, handles JWT/JWKS access control, and automatically publishes API metadata back into the Unified Namespace.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- pnpm add @uns-kit/api
9
- # or
10
- npm install @uns-kit/api
11
- ```
12
-
13
- Make sure `@uns-kit/core` is also installed; the plugin augments its runtime types.
14
-
15
- ## Example
16
-
17
- ```ts
18
- import UnsProxyProcess from "@uns-kit/core/uns/uns-proxy-process";
19
- import type { UnsProxyProcessWithApi } from "@uns-kit/api";
20
- import "@uns-kit/api"; // registers the plugin side-effect
21
-
22
- async function main() {
23
- const process = new UnsProxyProcess("mqtt-broker:1883", { processName: "api-gateway" }) as UnsProxyProcessWithApi;
24
-
25
- const api = await process.createApiProxy("gateway", { jwtSecret: "super-secret" });
26
-
27
- api.get("factory/", "status", {
28
- apiDescription: "Factory status endpoint",
29
- tags: ["status"],
30
- });
31
-
32
- api.event.on("apiGetEvent", (event) => {
33
- event.res.json({ status: "ok" });
34
- });
35
- }
36
-
37
- void main();
38
- ```
39
-
40
- ## Scripts
41
-
42
- ```bash
43
- pnpm run typecheck
44
- pnpm run build
45
- ```
46
-
47
- `build` emits both JavaScript and type declarations to `dist/`.
48
-
49
- ## License
50
-
51
- MIT © Aljoša Vister
1
+ # @uns-kit/api
2
+
3
+ `@uns-kit/api` exposes Express-based HTTP endpoints for UNS deployments. The plugin attaches a `createApiProxy` method to `UnsProxyProcess`, handles JWT/JWKS access control, and automatically publishes API metadata back into the Unified Namespace.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @uns-kit/api
9
+ # or
10
+ npm install @uns-kit/api
11
+ ```
12
+
13
+ Make sure `@uns-kit/core` is also installed; the plugin augments its runtime types.
14
+
15
+ ## Example
16
+
17
+ ```ts
18
+ import UnsProxyProcess from "@uns-kit/core/uns/uns-proxy-process";
19
+ import type { UnsProxyProcessWithApi } from "@uns-kit/api";
20
+ import "@uns-kit/api"; // registers the plugin side-effect
21
+
22
+ async function main() {
23
+ const process = new UnsProxyProcess("mqtt-broker:1883", { processName: "api-gateway" }) as UnsProxyProcessWithApi;
24
+
25
+ const api = await process.createApiProxy("gateway", { jwtSecret: "super-secret" });
26
+
27
+ api.get("factory/", "status", {
28
+ apiDescription: "Factory status endpoint",
29
+ tags: ["status"],
30
+ });
31
+
32
+ api.event.on("apiGetEvent", (event) => {
33
+ event.res.json({ status: "ok" });
34
+ });
35
+ }
36
+
37
+ void main();
38
+ ```
39
+
40
+ ## Scripts
41
+
42
+ ```bash
43
+ pnpm run typecheck
44
+ pnpm run build
45
+ ```
46
+
47
+ `build` emits both JavaScript and type declarations to `dist/`.
48
+
49
+ ## License
50
+
51
+ MIT © Aljoša Vister
package/dist/app.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  /**
2
3
  * Module dependencies.
3
4
  */
package/dist/app.js CHANGED
@@ -5,8 +5,8 @@ import express from "express";
5
5
  import * as http from "http";
6
6
  import * as path from "path";
7
7
  import cookieParser from "cookie-parser";
8
- import { basePath } from "@uns-kit/core/base-path";
9
- import logger from "@uns-kit/core/logger";
8
+ import { basePath } from "@uns-kit/core/base-path.js";
9
+ import logger from "@uns-kit/core/logger.js";
10
10
  import os from 'os';
11
11
  export default class App {
12
12
  expressApplication;
@@ -1,6 +1,6 @@
1
1
  import express from "express";
2
2
  import multer from "multer";
3
- import logger from "@uns-kit/core/logger";
3
+ import logger from "@uns-kit/core/logger.js";
4
4
  export default class Api {
5
5
  router;
6
6
  upload;
@@ -1,5 +1,5 @@
1
- import type { IApiProxyOptions } from "@uns-kit/core/uns/uns-interfaces";
2
- import UnsProxyProcess, { type UnsProxyProcessPlugin } from "@uns-kit/core/uns/uns-proxy-process";
1
+ import type { IApiProxyOptions } from "@uns-kit/core/uns/uns-interfaces.js";
2
+ import UnsProxyProcess, { type UnsProxyProcessPlugin } from "@uns-kit/core/uns/uns-proxy-process.js";
3
3
  import UnsApiProxy from "./uns-api-proxy.js";
4
4
  declare const unsApiPlugin: UnsProxyProcessPlugin;
5
5
  export default unsApiPlugin;
@@ -1,4 +1,4 @@
1
- import UnsProxyProcess from "@uns-kit/core/uns/uns-proxy-process";
1
+ import UnsProxyProcess from "@uns-kit/core/uns/uns-proxy-process.js";
2
2
  import UnsApiProxy from "./uns-api-proxy.js";
3
3
  const apiProxyRegistry = new WeakMap();
4
4
  const getApiProxies = (instance) => {
@@ -1,7 +1,7 @@
1
- import { UnsAttribute } from "@uns-kit/core/uns/uns-interfaces";
2
- import UnsProxy from "@uns-kit/core/uns/uns-proxy";
3
- import { UnsTopics } from "@uns-kit/core/uns/uns-topics";
4
- import { IApiProxyOptions, IGetEndpointOptions } from "@uns-kit/core/uns/uns-interfaces";
1
+ import { UnsAttribute } from "@uns-kit/core/uns/uns-interfaces.js";
2
+ import UnsProxy from "@uns-kit/core/uns/uns-proxy.js";
3
+ import { UnsTopics } from "@uns-kit/core/uns/uns-topics.js";
4
+ import { IApiProxyOptions, IGetEndpointOptions } from "@uns-kit/core/uns/uns-interfaces.js";
5
5
  export default class UnsApiProxy extends UnsProxy {
6
6
  instanceName: string;
7
7
  private topicBuilder;
@@ -2,13 +2,13 @@ import { readFileSync } from "fs";
2
2
  import jwt from "jsonwebtoken";
3
3
  import * as path from "path";
4
4
  import { createPublicKey } from "crypto";
5
- import { basePath } from "@uns-kit/core/base-path";
6
- import { UnsAttributeType } from "@uns-kit/core/graphql/schema";
7
- import logger from "@uns-kit/core/logger";
8
- import { MqttTopicBuilder } from "@uns-kit/core/uns-mqtt/mqtt-topic-builder";
9
- import { UnsPacket } from "@uns-kit/core/uns/uns-packet";
10
- import UnsProxy from "@uns-kit/core/uns/uns-proxy";
11
- import { UnsTopicMatcher } from "@uns-kit/core/uns/uns-topic-matcher";
5
+ import { basePath } from "@uns-kit/core/base-path.js";
6
+ import { UnsAttributeType } from "@uns-kit/core/graphql/schema.js";
7
+ import logger from "@uns-kit/core/logger.js";
8
+ import { MqttTopicBuilder } from "@uns-kit/core/uns-mqtt/mqtt-topic-builder.js";
9
+ import { UnsPacket } from "@uns-kit/core/uns/uns-packet.js";
10
+ import UnsProxy from "@uns-kit/core/uns/uns-proxy.js";
11
+ import { UnsTopicMatcher } from "@uns-kit/core/uns/uns-topic-matcher.js";
12
12
  import App from "./app.js";
13
13
  const packageJsonPath = path.join(basePath, "package.json");
14
14
  const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uns-kit/api",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Express-powered API gateway plugin for UnsProxyProcess with JWT/JWKS support.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "cookie-parser": "^1.4.7",
36
36
  "express": "^5.1.0",
37
37
  "multer": "^2.0.2",
38
- "@uns-kit/core": "0.0.35"
38
+ "@uns-kit/core": "0.0.36"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/jsonwebtoken": "^9.0.10",