@uns-kit/api 3.0.5 → 3.0.7

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/README.md CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
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, automatically publishes API metadata back into the Unified Namespace, and serves a Swagger UI for every registered endpoint.
4
4
 
5
- Note: Apps built with uns-kit are intended to be managed by the **UNS Datahub controller**.
5
+ Note: Apps built with uns-kit are intended to be managed by the **UNS OpenHub controller**.
6
6
  For the MQTT topic registry published by the API plugin, see `../../docs/uns-topics.md`.
7
7
 
8
8
  ## uns-kit in context
9
9
 
10
10
  | Package | Description |
11
11
  | --- | --- |
12
- | [`@uns-kit/core`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-core) | Base runtime (UnsProxyProcess, MQTT helpers, config tooling, gRPC gateway). |
13
- | [`@uns-kit/api`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-api) | Express plugin — HTTP endpoints, JWT/JWKS auth, Swagger, UNS metadata. |
14
- | [`@uns-kit/cron`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-cron) | Cron-driven scheduler that emits UNS events on a fixed cadence. |
15
- | [`@uns-kit/cli`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-cli) | CLI for scaffolding new UNS applications. |
12
+ | [`@uns-kit/core`](https://github.com/uns-openhub/uns-kit/tree/main/packages/uns-core) | Base runtime (UnsProxyProcess, MQTT helpers, config tooling, gRPC gateway). |
13
+ | [`@uns-kit/api`](https://github.com/uns-openhub/uns-kit/tree/main/packages/uns-api) | Express plugin — HTTP endpoints, JWT/JWKS auth, Swagger, UNS metadata. |
14
+ | [`@uns-kit/cron`](https://github.com/uns-openhub/uns-kit/tree/main/packages/uns-cron) | Cron-driven scheduler that emits UNS events on a fixed cadence. |
15
+ | [`@uns-kit/cli`](https://github.com/uns-openhub/uns-kit/tree/main/packages/uns-cli) | CLI for scaffolding new UNS applications. |
16
16
 
17
17
  ## Installation
18
18
 
package/dist/parquet.d.ts CHANGED
@@ -1,8 +1,10 @@
1
+ import { type ColumnSource } from "hyparquet-writer";
1
2
  import type { DataCatalogSchemaRegistration } from "./api-interfaces.js";
3
+ export type CatalogParquetColumn = Omit<ColumnSource, "data">;
2
4
  export declare function writeSchemaRowsToParquet(input: {
3
5
  rows: Array<Record<string, unknown>>;
4
6
  schema: DataCatalogSchemaRegistration;
5
7
  outputDir?: string;
6
8
  fileName?: string;
7
9
  }): Promise<string | null>;
8
- export declare function buildParquetSchemaFromCatalogSchema(schema: DataCatalogSchemaRegistration): any;
10
+ export declare function buildParquetSchemaFromCatalogSchema(schema: DataCatalogSchemaRegistration): CatalogParquetColumn[];
package/dist/parquet.js CHANGED
@@ -1,16 +1,16 @@
1
+ import logger from "@uns-kit/core/logger.js";
1
2
  import { randomUUID } from "crypto";
2
3
  import fs from "fs";
4
+ import { fileWriter, parquetWriteRows } from "hyparquet-writer";
3
5
  import os from "os";
4
6
  import path from "path";
5
- import { ParquetSchema, ParquetWriter } from "parquets";
6
- import logger from "@uns-kit/core/logger.js";
7
7
  const PARQUET_TYPE_MAP = {
8
- string: "UTF8",
8
+ string: "STRING",
9
9
  number: "DOUBLE",
10
10
  integer: "INT64",
11
11
  boolean: "BOOLEAN",
12
- date: "TIMESTAMP_MILLIS",
13
- "date-time": "TIMESTAMP_MILLIS",
12
+ date: "TIMESTAMP",
13
+ "date-time": "TIMESTAMP",
14
14
  };
15
15
  export async function writeSchemaRowsToParquet(input) {
16
16
  try {
@@ -20,11 +20,15 @@ export async function writeSchemaRowsToParquet(input) {
20
20
  if (!fs.existsSync(outputDir)) {
21
21
  fs.mkdirSync(outputDir, { recursive: true });
22
22
  }
23
- const writer = await ParquetWriter.openFile(buildParquetSchemaFromCatalogSchema(input.schema), filePath);
24
- for (const row of input.rows) {
25
- await writer.appendRow(normalizeParquetRow(row));
23
+ const columns = buildParquetSchemaFromCatalogSchema(input.schema);
24
+ if (!columns.length) {
25
+ throw new Error(`Parquet schema '${input.schema.id}' has no supported fields.`);
26
26
  }
27
- await writer.close();
27
+ await parquetWriteRows({
28
+ writer: fileWriter(filePath),
29
+ rows: input.rows.map((row) => normalizeParquetRow(row, columns)),
30
+ columns,
31
+ });
28
32
  return filePath;
29
33
  }
30
34
  catch (error) {
@@ -33,18 +37,19 @@ export async function writeSchemaRowsToParquet(input) {
33
37
  }
34
38
  }
35
39
  export function buildParquetSchemaFromCatalogSchema(schema) {
36
- const schemaDef = {};
40
+ const columns = [];
37
41
  for (const field of schema.fields ?? []) {
38
42
  const parquetType = toParquetType(field.type ?? "string", field.format ?? null);
39
43
  if (!parquetType) {
40
44
  continue;
41
45
  }
42
- schemaDef[field.name] = {
46
+ columns.push({
47
+ name: field.name,
43
48
  type: parquetType,
44
- optional: field.required !== true,
45
- };
49
+ nullable: field.required !== true,
50
+ });
46
51
  }
47
- return new ParquetSchema(schemaDef);
52
+ return columns;
48
53
  }
49
54
  function toParquetType(type, format) {
50
55
  if (format && PARQUET_TYPE_MAP[format]) {
@@ -52,10 +57,11 @@ function toParquetType(type, format) {
52
57
  }
53
58
  return PARQUET_TYPE_MAP[type] ?? null;
54
59
  }
55
- function normalizeParquetRow(row) {
60
+ function normalizeParquetRow(row, columns) {
56
61
  const normalized = {};
57
- for (const [key, value] of Object.entries(row)) {
58
- normalized[key] = value instanceof Date ? new Date(value) : value;
62
+ for (const column of columns) {
63
+ const value = row[column.name];
64
+ normalized[column.name] = column.type === "INT64" && typeof value === "number" ? BigInt(value) : value instanceof Date ? new Date(value) : value;
59
65
  }
60
66
  return normalized;
61
67
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@uns-kit/api",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "Express-powered API gateway plugin for UnsProxyProcess with JWT/JWKS support.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Aljoša Vister <aljosa.vister@gmail.com>",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/uns-datahub/uns-kit.git",
10
+ "url": "https://github.com/uns-openhub/uns-kit.git",
11
11
  "directory": "packages/uns-api"
12
12
  },
13
13
  "keywords": [
@@ -32,18 +32,18 @@
32
32
  "types": "dist/index.d.ts",
33
33
  "dependencies": {
34
34
  "cookie-parser": "^1.4.7",
35
- "express": "^5.1.0",
36
- "jsonwebtoken": "^9.0.2",
37
- "multer": "^2.0.2",
38
- "parquets": "^0.10.10",
39
- "uuid": "^14.0.0",
40
- "@uns-kit/core": "3.0.5"
35
+ "express": "^5.2.1",
36
+ "jsonwebtoken": "^9.0.3",
37
+ "multer": "^2.2.0",
38
+ "hyparquet-writer": "^0.16.5",
39
+ "uuid": "^14.0.1",
40
+ "@uns-kit/core": "3.0.7"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/cookie-parser": "^1.4.9",
44
- "@types/express": "^5.0.3",
43
+ "@types/cookie-parser": "^1.4.10",
44
+ "@types/express": "^5.0.6",
45
45
  "@types/jsonwebtoken": "^9.0.10",
46
- "@types/multer": "^2.0.0"
46
+ "@types/multer": "^2.2.0"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "tsc -p tsconfig.build.json",