c8y-nitro 0.9.0 → 0.9.2

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.
@@ -1,4 +1,4 @@
1
- import { n as name, r as version, t as description } from "../package-gK1cGX1w.mjs";
1
+ import { n as name, r as version, t as description } from "../package-bl4QZvAk.mjs";
2
2
  import { defineCommand, runMain } from "citty";
3
3
  //#region src/cli/index.ts
4
4
  runMain(defineCommand({
@@ -414,6 +414,18 @@ interface C8yCacheOptions {
414
414
  //#endregion
415
415
  //#region src/types/docker.d.ts
416
416
  interface C8yDockerOptions {
417
+ /**
418
+ * Path to a custom Dockerfile, relative to the Nitro config file location
419
+ * (`rootDir`).
420
+ *
421
+ * When set, the built-in Dockerfile template is **not** generated. The file
422
+ * at this path is copied into the build context and used as-is for the Docker
423
+ * build. The `baseImage` and `extraInstructions` options are ignored when a
424
+ * custom Dockerfile is provided.
425
+ *
426
+ * @example 'docker/Dockerfile'
427
+ */
428
+ dockerfile?: string;
417
429
  /**
418
430
  * Base image for the generated Dockerfile.
419
431
  *
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as C8yNitroModuleOptions } from "./index-Dil1PcDr.mjs";
1
+ import { n as C8yNitroModuleOptions } from "./index-DHd7xpBX.mjs";
2
2
  import { t as TenantCredentials } from "./credentials-eKnJ7m9Y.mjs";
3
3
  import { NitroModule } from "nitro/types";
4
4
  //#region src/index.d.ts
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { _ as GENERATED_READINESS_ROUTE, g as GENERATED_LIVENESS_ROUTE, h as GENERATED_INVALIDATE_TENANT_OPTIONS_ROUTE, m as createC8yManifestFromNitro, p as createC8yManifest } from "./c8y-api-DpCWhaJU.mjs";
2
2
  import { t as autoBootstrap } from "./autoBootstrap-qCcCgset.mjs";
3
- import { n as name } from "./package-gK1cGX1w.mjs";
4
- import { basename, dirname, join, relative } from "node:path";
5
- import { mkdir, writeFile } from "node:fs/promises";
3
+ import { n as name } from "./package-bl4QZvAk.mjs";
4
+ import { basename, dirname, join, relative, resolve } from "node:path";
5
+ import { copyFile, mkdir, writeFile } from "node:fs/promises";
6
6
  import { x } from "tinyexec";
7
7
  import { join as join$1 } from "pathe";
8
8
  import { mkdir as mkdir$1, readFile as readFile$1, stat, writeFile as writeFile$1 } from "fs/promises";
@@ -249,12 +249,12 @@ async function checkDockerInstalled() {
249
249
  return false;
250
250
  }
251
251
  }
252
- async function writeDockerfile(outputDir, options) {
253
- const outputDirName = basename(outputDir);
252
+ async function writeDockerfile(outputDir, rootDir, options) {
254
253
  const c8yDir = join(outputDir, "../.c8y");
255
254
  const dockerfilePath = join(c8yDir, "Dockerfile");
256
255
  await mkdir(c8yDir, { recursive: true });
257
- await writeFile(dockerfilePath, getDockerfileContent(outputDirName, options), "utf-8");
256
+ if (options.dockerfile) await copyFile(resolve(rootDir, options.dockerfile), dockerfilePath);
257
+ else await writeFile(dockerfilePath, getDockerfileContent(basename(outputDir), options), "utf-8");
258
258
  return c8yDir;
259
259
  }
260
260
  async function buildDockerImage(nitro, c8yDir) {
@@ -309,7 +309,7 @@ async function saveDockerImageToTar(nitro, c8yDir, imageName) {
309
309
  async function createDockerImage(nitro, options = {}) {
310
310
  if (!await checkDockerInstalled()) throw new Error("Docker is not installed or not available in PATH. Please install Docker to build images.");
311
311
  nitro.logger.debug("Creating Docker image...");
312
- const c8yDir = await writeDockerfile(nitro.options.output.dir, options);
312
+ const c8yDir = await writeDockerfile(nitro.options.output.dir, nitro.options.rootDir, options);
313
313
  const imageTarPath = await saveDockerImageToTar(nitro, c8yDir, await buildDockerImage(nitro, c8yDir));
314
314
  nitro.logger.debug("Docker image creation complete.");
315
315
  return imageTarPath;
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "c8y-nitro";
3
- var version = "0.9.0";
3
+ var version = "0.9.2";
4
4
  var description = "Lightning fast Cumulocity IoT microservice development powered by Nitro";
5
5
  //#endregion
6
6
  export { name as n, version as r, description as t };
package/dist/types.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { a as C8YTenantOptionKey, c as C8yDockerOptions, d as C8YManifest, f as C8YManifestOptions, g as C8YAPIClientOptions, h as C8YKnownRole, i as C8YSettingsCategory, l as C8yCacheOptions, m as C8YRoles, n as C8yNitroModuleOptions, o as C8YTenantOptionKeysCacheConfig, p as C8YRole, r as C8yOpenAPIOptions, s as C8yRealtimeOptions, t as C8yDevOptions, u as C8YZipOptions } from "./index-Dil1PcDr.mjs";
1
+ import { a as C8YTenantOptionKey, c as C8yDockerOptions, d as C8YManifest, f as C8YManifestOptions, g as C8YAPIClientOptions, h as C8YKnownRole, i as C8YSettingsCategory, l as C8yCacheOptions, m as C8YRoles, n as C8yNitroModuleOptions, o as C8YTenantOptionKeysCacheConfig, p as C8YRole, r as C8yOpenAPIOptions, s as C8yRealtimeOptions, t as C8yDevOptions, u as C8YZipOptions } from "./index-DHd7xpBX.mjs";
2
2
  import { t as TenantCredentials } from "./credentials-eKnJ7m9Y.mjs";
3
3
  export { C8YAPIClientOptions, type C8YKnownRole, type C8YManifest, type C8YManifestOptions, C8YRole, C8YRoles, C8YSettingsCategory, C8YTenantOptionKey, C8YTenantOptionKeysCacheConfig, type C8YZipOptions, type C8yCacheOptions, C8yDevOptions, type C8yDockerOptions, C8yNitroModuleOptions, C8yOpenAPIOptions, type C8yRealtimeOptions, type TenantCredentials };
package/dist/utils.mjs CHANGED
@@ -12,6 +12,7 @@ import { defineHandler } from "nitro/h3";
12
12
  import { c8yManifest } from "c8y-nitro/runtime";
13
13
  import { Cron } from "croner";
14
14
  import { ms } from "itty-time";
15
+ import { WebSocket } from "ws";
15
16
  //#region src/utils/internal/common.ts
16
17
  /**
17
18
  * Whether two sets of tenant credentials are equivalent for the purposes of
@@ -1156,6 +1157,21 @@ function c8yTasks() {
1156
1157
  }
1157
1158
  //#endregion
1158
1159
  //#region src/utils/realtime.ts
1160
+ /**
1161
+ * `ws` as the factory type c8y-realtime asks for.
1162
+ *
1163
+ * The cast is needed, and it is safe. TypeScript only compares the *first*
1164
+ * overload of an overloaded member, and `ws` is overloaded twice over:
1165
+ * `@types/ws` declares `constructor(address: null)` first (the socket
1166
+ * `WebSocketServer` builds for an incoming connection), and its `on` is declared
1167
+ * per event (`on('close', …)`, `on('error', …)`). So TS never looks at the
1168
+ * signatures we actually use.
1169
+ *
1170
+ * At runtime `ws` has all seven methods `WebSocketInstanceLike` lists. The global
1171
+ * WebSocket, which assigns with no cast at all, has four — it lacks `ping`,
1172
+ * `terminate` and `removeAllListeners`.
1173
+ */
1174
+ const wsWebSocketImpl = WebSocket;
1159
1175
  const REPAIR_SWEEP_INTERVAL_MS = 3e4;
1160
1176
  const pool = /* @__PURE__ */ new Map();
1161
1177
  let lifecycleWired = false;
@@ -1191,6 +1207,7 @@ function createRealtimeClientForTenant(tenantId, creds) {
1191
1207
  return createRealtimeClient({
1192
1208
  ...realtimeConfig(),
1193
1209
  ...toLibCredentials(tenantId, creds),
1210
+ webSocketImpl: wsWebSocketImpl,
1194
1211
  logger: console
1195
1212
  });
1196
1213
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c8y-nitro",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "type": "module",
5
5
  "description": "Lightning fast Cumulocity IoT microservice development powered by Nitro",
6
6
  "keywords": [
@@ -49,13 +49,15 @@
49
49
  "pathe": "^2.0.3",
50
50
  "pkg-types": "^2.3.1",
51
51
  "spinnies": "^0.5.1",
52
- "tinyexec": "^1.2.4"
52
+ "tinyexec": "^1.2.4",
53
+ "ws": "^8.21.3"
53
54
  },
54
55
  "devDependencies": {
55
56
  "@c8y/client": "^1023.97.0",
56
57
  "@schplitt/eslint-config": "^1.5.2",
57
58
  "@types/node": "^24.12.3",
58
59
  "@types/spinnies": "^0.5.3",
60
+ "@types/ws": "^8.18.1",
59
61
  "bumpp": "^11.1.0",
60
62
  "changelogithub": "^14.0.0",
61
63
  "eslint": "^10.7.0",