@dokebi/cli 0.4.59 → 0.4.61

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/AI.md CHANGED
@@ -193,6 +193,7 @@ Nothing else sits right under `src/shared/`: `dokebi check` warns `shared-folder
193
193
 
194
194
  ## 5. Settings rules
195
195
 
196
+ - **A settings folder on another file system (0.4.60).** Every change the CLI makes (dokebi.yaml with `config set`, `config secret --stdin`, generated files) is staged in `.dokebi/transaction-*` and renamed into place; when the target sits on another file system — a settings folder mounted into a container, `DOKEBI_CONFIG` on a mounted volume — that rename fails (EXDEV), so the CLI stages beside the target instead (a hidden `.<name>.transaction-*` file in its own folder, renamed from there: still one atomic replace) and keeps the original there until the commit stands. A symlink is still refused (`UNSAFE_PATH`): mount the folder, do not link it.
196
197
  - **Reloadable options (D-0154).** Options marked `reloadable` in their schema (`x-dokebi-reloadable: true`; `(reloadable)` in the option tables of the plugin guides) apply while the app runs: saving dokebi.yaml (the app watches it, `options.reload.watch`), `npx dokebi reload` after `dokebi start`, or `dokebi dev` reloading in place. The CLI writes `# reloadable` after each such key it writes into dokebi.yaml and dokebi.example.yaml, and `config show` marks them (JSON `reloadable`). A change of any other option needs a restart: the app refuses the whole reload (`CONFIG_RELOAD_RESTART_REQUIRED`, nothing applied) and keeps running. `options.reload` (core): `watch` (true), `debounceMs` (50–60000, 300), `signal` (true; SIGHUP), `prepareTimeoutMs` (1000–600000, 30000), `watchRetryMs` (1000–3600000, 5000), all reloadable; `config set reload.<key>=…` checks them.
197
198
  - **Settings of the application (D-0155).** Settings your own code needs (limits, sizes, times of a feature) go into a section declared with `npx dokebi settings add <section>`, never a hand-made `options.<name>` read with your own parser: only a declared section is checked at start and known to `config`, doctor, the example and reloads.
198
199
  - On install, the safe defaults and descriptions the schema states go into the YAML, and existing values and comments are kept. Secrets and connection URLs are never generated (`writeOnly: true` marks a sensitive value).
package/catalog.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "$comment": "Generated by scripts/catalog/build.ts from package.json dokebiCatalog fields and packages/cli/catalog-src (D-0065). Do not edit; run node scripts/catalog/build.ts.",
3
3
  "schemaVersion": 1,
4
- "cli": "0.4.59",
4
+ "cli": "0.4.61",
5
5
  "core": {
6
6
  "package": "@dokebi/core",
7
- "version": "0.4.7"
7
+ "version": "0.4.8"
8
8
  },
9
9
  "capabilities": {
10
10
  "admin.ui": {
@@ -259,6 +259,10 @@
259
259
  "summary": "WebSocket routes, rooms and broadcast (across servers and workers)",
260
260
  "en": "websocket socket realtime chat"
261
261
  },
262
+ "realtime.websocket-client": {
263
+ "summary": "the client side of a Dokebi WebSocket alone: a heartbeat that hears a server gone silent with its TCP connection open, without the server stack",
264
+ "en": "websocket client heartbeat keepalive ping pong agent dead server reconnect"
265
+ },
262
266
  "redis.connection": {
263
267
  "summary": "named Redis connections",
264
268
  "en": "redis"
@@ -825,7 +829,7 @@
825
829
  {
826
830
  "id": null,
827
831
  "package": "@dokebi/cli",
828
- "version": "0.4.59",
832
+ "version": "0.4.61",
829
833
  "kind": "cli",
830
834
  "summary": "Commands to create a project, browse the plugin catalog, run recipes, install plugins and verify (dokebi)",
831
835
  "description": "Project scaffolding, plugin catalog, recipes, install and verification CLI for Dokebi.",
@@ -972,7 +976,7 @@
972
976
  {
973
977
  "id": null,
974
978
  "package": "@dokebi/core",
975
- "version": "0.4.7",
979
+ "version": "0.4.8",
976
980
  "kind": "core",
977
981
  "summary": "Application core: settings loading, plugin registration, lifecycle, logger and shared libraries (required)",
978
982
  "description": "Minimal composable Node.js application and plugin lifecycle framework.",
@@ -1697,7 +1701,7 @@
1697
1701
  {
1698
1702
  "id": "dokebi-job",
1699
1703
  "package": "@dokebi/job",
1700
- "version": "0.4.6",
1704
+ "version": "0.4.7",
1701
1705
  "kind": "plugin",
1702
1706
  "summary": "NATS JetStream job queue (at least once, retries, DLQ)",
1703
1707
  "description": "Bounded durable jobs over the Dokebi NATS provider: retries, delayed redelivery and a dead-letter stream.",
@@ -1710,7 +1714,7 @@
1710
1714
  "jetstream"
1711
1715
  ],
1712
1716
  "maturity": "preview",
1713
- "core": "^0.4.0",
1717
+ "core": "^0.4.8",
1714
1718
  "provides": [
1715
1719
  "job.durable"
1716
1720
  ],
@@ -2179,7 +2183,7 @@
2179
2183
  {
2180
2184
  "id": "dokebi-nats",
2181
2185
  "package": "@dokebi/nats",
2182
- "version": "0.4.2",
2186
+ "version": "0.4.3",
2183
2187
  "kind": "plugin",
2184
2188
  "summary": "Named NATS connections (Core and JetStream publishing, durable consumers)",
2185
2189
  "description": "Named NATS connections and bounded JetStream publication for Dokebi.",
@@ -2191,7 +2195,7 @@
2191
2195
  "messaging"
2192
2196
  ],
2193
2197
  "maturity": "preview",
2194
- "core": "^0.4.2",
2198
+ "core": "^0.4.8",
2195
2199
  "provides": [
2196
2200
  "messaging.nats"
2197
2201
  ],
@@ -2866,7 +2870,7 @@
2866
2870
  {
2867
2871
  "id": "dokebi-rollups",
2868
2872
  "package": "@dokebi/rollups",
2869
- "version": "0.2.0",
2873
+ "version": "0.2.1",
2870
2874
  "kind": "plugin",
2871
2875
  "summary": "Report roll-ups by @dokebi/db AI.md 6.9: facts recorded as small rows in the caller's transaction (no hot row), folded in parallel by outbox lanes into UTC hour rows and day and month rows per whole-hour time zone (rebuilt from the hours when a zone is added), bounded reads with an as-of time, running totals and a report budget (429, 503)",
2872
2876
  "description": "Report roll-ups for Dokebi by @dokebi/db AI.md 6.9: facts recorded as small rows in the caller's transaction, folded by outbox lanes into UTC hour rows and day and month rows per time zone, bounded reads with an as-of time and a report budget.",
@@ -3061,7 +3065,7 @@
3061
3065
  {
3062
3066
  "id": "dokebi-seal",
3063
3067
  "package": "@dokebi/seal",
3064
- "version": "0.4.4",
3068
+ "version": "0.4.5",
3065
3069
  "kind": "plugin",
3066
3070
  "summary": "Seals WebSocket frames and HTTP bodies (obfuscation, replay protection) with a browser client (WASM)",
3067
3071
  "description": "Payload sealing (obfuscation, replay defence, in-transit encryption) for seal hosts: @dokebi/websocket frames and @dokebi/web HTTP bodies, with browser socket, fetch and Inertia clients and their WASM loader",
@@ -3751,7 +3755,7 @@
3751
3755
  {
3752
3756
  "id": "dokebi-websocket",
3753
3757
  "package": "@dokebi/websocket",
3754
- "version": "0.4.5",
3758
+ "version": "0.4.7",
3755
3759
  "kind": "plugin",
3756
3760
  "summary": "WebSocket routes, rooms and broadcast on top of dokebi-web (at most once)",
3757
3761
  "description": "WebSocket routes on @dokebi/web with rooms and broadcast across servers through @dokebi/websocket-hub.",
@@ -3808,6 +3812,41 @@
3808
3812
  },
3809
3813
  "install": "npx dokebi add @dokebi/websocket"
3810
3814
  },
3815
+ {
3816
+ "id": null,
3817
+ "package": "@dokebi/websocket-client",
3818
+ "version": "0.1.0",
3819
+ "kind": "library",
3820
+ "summary": "The client side of a Dokebi WebSocket on its own: heartbeat pings that ask for a pong and report a server gone silent with its TCP connection open, and the control frames; no dependencies, for Node agents and browsers",
3821
+ "description": "The client side of a Dokebi WebSocket on its own: a heartbeat that hears a server gone silent with its TCP connection open (ping-v1 asking for pong-v1), and the control frames. No dependencies; Node's WebSocket, ws or a browser's.",
3822
+ "keywords": [
3823
+ "dokebi",
3824
+ "websocket",
3825
+ "client",
3826
+ "heartbeat",
3827
+ "keep-alive"
3828
+ ],
3829
+ "maturity": "experimental",
3830
+ "core": null,
3831
+ "provides": [
3832
+ "realtime.websocket-client"
3833
+ ],
3834
+ "variants": [],
3835
+ "doesNot": [
3836
+ "Not a plugin you app.register: npm install it in the process or page that connects",
3837
+ "No connection, reconnect or message envelope of its own (the @dokebi/seal client has those for pages)",
3838
+ "No server: the gateway is @dokebi/websocket"
3839
+ ],
3840
+ "recipes": [],
3841
+ "requires": [],
3842
+ "optional": [],
3843
+ "optionKeys": [],
3844
+ "docs": {
3845
+ "ai": "AI.md",
3846
+ "readme": "README.md"
3847
+ },
3848
+ "install": "npm install @dokebi/websocket-client"
3849
+ },
3811
3850
  {
3812
3851
  "id": "dokebi-websocket-hub",
3813
3852
  "package": "@dokebi/websocket-hub",
package/dist/output.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare const CLI_VERSION = "0.4.59";
1
+ export declare const CLI_VERSION = "0.4.61";
2
2
  export declare function envelope(command: string, result: unknown, ok?: boolean): object;
3
3
  export declare function failure(command: string, error: unknown, mutationStarted: boolean): object;
package/dist/output.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CliError } from './errors.js';
2
- export const CLI_VERSION = '0.4.59';
2
+ export const CLI_VERSION = '0.4.61';
3
3
  export function envelope(command, result, ok = true) {
4
4
  return { schemaVersion: 1, cliVersion: CLI_VERSION, command, ok, result, error: null };
5
5
  }
@@ -1,4 +1,5 @@
1
- import { link, lstat, mkdir, mkdtemp, open, readdir, readFile, rename, rm, rmdir, unlink, writeFile, } from 'node:fs/promises';
1
+ import { constants as fsConstants } from 'node:fs';
2
+ import { copyFile, link, lstat, mkdir, mkdtemp, open, readdir, readFile, rename, rm, rmdir, unlink, writeFile, } from 'node:fs/promises';
2
3
  import { basename, dirname, join, relative } from 'node:path';
3
4
  import { hash as hashing } from '@dokebi/core/libraries';
4
5
  import { debug, debugEnabled, describeError, reportError } from './diagnostics.js';
@@ -421,11 +422,15 @@ export class Transaction {
421
422
  }
422
423
  await mkdir(dirname(target), { recursive: true });
423
424
  if (change.existed) {
424
- await rename(target, change.backup);
425
+ // A target on another file system (a settings folder mounted into a container) cannot
426
+ // be renamed into the transaction folder (EXDEV): its original goes beside it instead,
427
+ // under a hidden name, and the journal says where.
428
+ change.backup = await this.#moveAside(target, change.backup, `old-${index}`);
425
429
  change.backedUp = true;
430
+ await writeFile(join(this.directory, 'journal.json'), json(journal));
426
431
  }
427
432
  if (change.source) {
428
- await rename(change.source, target);
433
+ await this.#install(change.source, target, index);
429
434
  change.installed = true;
430
435
  }
431
436
  }
@@ -439,6 +444,11 @@ export class Transaction {
439
444
  });
440
445
  await this.#rollback(journal, cause);
441
446
  }
447
+ // The commit stands: originals kept beside their targets (another file system) go now; the
448
+ // ones in the transaction folder go with it in close(). A leftover is said, never hidden.
449
+ for (const change of journal)
450
+ if (change.backedUp && dirname(change.backup) !== this.directory)
451
+ await rm(change.backup, { force: true }).catch((error) => reportError('TRANSACTION_BACKUP_LEFT', `Transaction could not remove the original kept beside ${relative(this.root, change.backup)}`, error));
442
452
  }
443
453
  async #rollback(journal, cause) {
444
454
  const failures = [];
@@ -522,9 +532,9 @@ export class Transaction {
522
532
  return { path: change.path, reason: differs(change.installs, now), ...backup };
523
533
  // Move it aside (atomic), then look again: an edit between the look and the move is
524
534
  // found here and put back, never deleted.
525
- const aside = join(this.directory, `rollback-${index}`);
535
+ let aside = join(this.directory, `rollback-${index}`);
526
536
  try {
527
- await rename(target, aside);
537
+ aside = await this.#moveAside(target, aside, `rollback-${index}`);
528
538
  }
529
539
  catch (error) {
530
540
  if (error.code !== 'ENOENT')
@@ -548,6 +558,58 @@ export class Transaction {
548
558
  return { path: change.path, reason: 'created', ...backup };
549
559
  return undefined;
550
560
  }
561
+ /**
562
+ * Renames `target` to `aside`; across file systems (EXDEV: `target` on a mount) to a hidden name
563
+ * in `target`'s own folder instead. Returns where it went.
564
+ */
565
+ async #moveAside(target, aside, label) {
566
+ try {
567
+ await rename(target, aside);
568
+ return aside;
569
+ }
570
+ catch (error) {
571
+ if (error.code !== 'EXDEV')
572
+ throw error;
573
+ }
574
+ const beside = this.#beside(target, label);
575
+ debug('Transaction keeps an original beside it (another file system)', { path: target });
576
+ await rename(target, beside);
577
+ return beside;
578
+ }
579
+ /**
580
+ * Puts a staged file at `target`. Across file systems (EXDEV) it is copied to a hidden name in
581
+ * `target`'s folder first and renamed from there, so the replacement stays one atomic rename.
582
+ */
583
+ async #install(source, target, index) {
584
+ try {
585
+ await rename(source, target);
586
+ return;
587
+ }
588
+ catch (error) {
589
+ if (error.code !== 'EXDEV')
590
+ throw error;
591
+ }
592
+ if ((await lstat(source)).isDirectory())
593
+ throw new CliError('UNSAFE_PATH', `A folder cannot be installed across file systems: ${relative(this.root, target)}`);
594
+ const beside = this.#beside(target, `new-${index}`);
595
+ debug('Transaction installs through a file beside the target (another file system)', {
596
+ path: target,
597
+ });
598
+ try {
599
+ // COPYFILE_EXCL: never over a file of that name; the mode (0600) comes along.
600
+ await copyFile(source, beside, fsConstants.COPYFILE_EXCL);
601
+ await rename(beside, target);
602
+ }
603
+ catch (error) {
604
+ await rm(beside, { force: true });
605
+ throw error;
606
+ }
607
+ await rm(source, { force: true });
608
+ }
609
+ /** A hidden name in `target`'s folder that belongs to this transaction. */
610
+ #beside(target, label) {
611
+ return join(dirname(target), `.${basename(target)}.${basename(this.directory)}.${label}`);
612
+ }
551
613
  /**
552
614
  * Moves `from` to `to` without replacing anything at `to`: false when something is there. A
553
615
  * file goes by link + unlink (link fails on an existing name); a folder (or a file system
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dokebi/cli",
3
- "version": "0.4.59",
3
+ "version": "0.4.61",
4
4
  "description": "Project scaffolding, plugin catalog, recipes, install and verification CLI for Dokebi.",
5
5
  "keywords": [
6
6
  "dokebi",