@mason-data/cli 0.8.0 → 0.9.0

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.
Files changed (109) hide show
  1. package/README.md +13 -4
  2. package/dist/src/api/postgres/catalog-worker.js +49 -2
  3. package/dist/src/api/postgres/catalog.js +166 -32
  4. package/dist/src/api/postgres/listener.js +11 -3
  5. package/dist/src/api/postgres/proxy.js +283 -0
  6. package/dist/src/api/postgres/schema.js +6 -0
  7. package/dist/src/api/postgres/server.js +505 -99
  8. package/dist/src/api/postgres/translate.js +47 -2
  9. package/dist/src/cli/background.js +18 -19
  10. package/dist/src/cli/bridge-stdin.js +101 -0
  11. package/dist/src/cli/command.js +169 -11
  12. package/dist/src/cli/commands.js +207 -51
  13. package/dist/src/cli/credentials.js +182 -0
  14. package/dist/src/cli/demo.js +2 -2
  15. package/dist/src/cli/deploy.js +574 -0
  16. package/dist/src/cli/dev.js +148 -27
  17. package/dist/src/cli/doctor.js +116 -33
  18. package/dist/src/cli/generated-files.js +143 -0
  19. package/dist/src/cli/guides.js +97 -6
  20. package/dist/src/cli/hosted.js +850 -0
  21. package/dist/src/cli/init.js +47 -11
  22. package/dist/src/cli/login.js +289 -0
  23. package/dist/src/cli/machine.js +1 -1
  24. package/dist/src/cli/main.js +8 -2
  25. package/dist/src/cli/mason.cjs +17 -0
  26. package/dist/src/cli/mcp.js +2 -2
  27. package/dist/src/cli/output-gate.js +176 -0
  28. package/dist/src/cli/page-share.js +96 -0
  29. package/dist/src/cli/pg-tls.js +1 -1
  30. package/dist/src/cli/pin.js +6 -2
  31. package/dist/src/cli/pool-size.cjs +85 -0
  32. package/dist/src/cli/ports.js +2 -0
  33. package/dist/src/cli/preflight.js +130 -39
  34. package/dist/src/cli/project.js +99 -0
  35. package/dist/src/cli/readiness.js +42 -6
  36. package/dist/src/cli/registry.js +12 -4
  37. package/dist/src/cli/replica-hosted.js +665 -0
  38. package/dist/src/cli/replica.js +76 -0
  39. package/dist/src/cli/roles.js +2 -1
  40. package/dist/src/cli/run-server.js +154 -7
  41. package/dist/src/cli/security.js +57 -10
  42. package/dist/src/cli/serve.js +63 -7
  43. package/dist/src/cli/share-run.js +51 -8
  44. package/dist/src/cli/share.js +3 -3
  45. package/dist/src/cli/source-edit.js +10 -4
  46. package/dist/src/cli/source-role.js +344 -0
  47. package/dist/src/cli/sources.js +30 -20
  48. package/dist/src/cli/style.js +2 -1
  49. package/dist/src/cli/supervise.js +15 -23
  50. package/dist/src/cli/token-hosted.js +337 -0
  51. package/dist/src/cli/ui-ssh.js +460 -0
  52. package/dist/src/cli/ui.js +115 -11
  53. package/dist/src/cli/user-hosted.js +299 -0
  54. package/dist/src/cli/user.js +126 -74
  55. package/dist/src/demo/seed.js +26 -0
  56. package/dist/src/duck/analyze.js +36 -20
  57. package/dist/src/duck/collation.js +266 -0
  58. package/dist/src/duck/constant-key.js +94 -0
  59. package/dist/src/duck/distinct-key.js +283 -26
  60. package/dist/src/duck/events.js +39 -8
  61. package/dist/src/duck/executor-worker.js +2 -2
  62. package/dist/src/duck/executor.js +6 -5
  63. package/dist/src/duck/explain.js +4 -0
  64. package/dist/src/duck/functions.js +448 -49
  65. package/dist/src/duck/gaps.js +34 -16
  66. package/dist/src/duck/generated-plan.js +1070 -0
  67. package/dist/src/duck/generated.js +906 -0
  68. package/dist/src/duck/grants.js +1 -1
  69. package/dist/src/duck/held-types.js +64 -0
  70. package/dist/src/duck/history.js +4 -0
  71. package/dist/src/duck/jsonb-order.js +9 -12
  72. package/dist/src/duck/kept-route.js +6 -5
  73. package/dist/src/duck/kept.js +9 -7
  74. package/dist/src/duck/late.js +1469 -40
  75. package/dist/src/duck/libc-bound.js +341 -0
  76. package/dist/src/duck/libc-order.js +892 -126
  77. package/dist/src/duck/pg-eval-worker.js +7 -1
  78. package/dist/src/duck/pg-eval.js +6 -4
  79. package/dist/src/duck/pgtree.js +774 -23
  80. package/dist/src/duck/plan.js +275 -30
  81. package/dist/src/duck/publication.js +14 -0
  82. package/dist/src/duck/requests.js +9 -5
  83. package/dist/src/duck/resolved.js +117 -2
  84. package/dist/src/duck/rewrite.js +4567 -583
  85. package/dist/src/duck/row-filter.js +12 -6
  86. package/dist/src/duck/statement.js +19 -0
  87. package/dist/src/duck/store.js +294 -68
  88. package/dist/src/duck/stream.js +9 -5
  89. package/dist/src/duck/sync.js +602 -126
  90. package/dist/src/duck/token.js +4 -1
  91. package/dist/src/duck/types.js +63 -7
  92. package/dist/src/duck/usage.js +6 -4
  93. package/dist/src/duck/users.js +5 -0
  94. package/dist/src/duck/verified.js +159 -2
  95. package/dist/src/duck/views.js +4 -3
  96. package/dist/src/lib/database-url.js +55 -10
  97. package/dist/src/lib/instant.js +50 -0
  98. package/dist/src/lib/log-buffer.js +13 -4
  99. package/dist/src/lib/log-read.js +196 -0
  100. package/dist/src/lib/pg-numeric.js +387 -49
  101. package/dist/src/lib/secret-mask.js +142 -0
  102. package/dist/src/lib/table-sync.js +24 -9
  103. package/dist/src/web/app.js +9 -4
  104. package/dist/src/web/pages/status.js +178 -13
  105. package/dist/src/web/pages/syncs.js +1 -1
  106. package/dist/src/web/pages/tables.js +8 -3
  107. package/dist/src/web/pages/users.js +4 -3
  108. package/dist/src/web/shared.js +19 -3
  109. package/package.json +8 -7
@@ -292,6 +292,18 @@ export function failureOf(status, text) {
292
292
  next: [{ command: "mason status", what: "whether Mason runs, and why it stopped" }, { command: "mason start", what: "start it" }, { command: "mason ui", what: "this page, for the Mason that is running" }] };
293
293
  }
294
294
 
295
+ /**
296
+ * A FAILURE AS IT IS ON A SERVER'S PAGE (`/api/state` `served`: read through `mason ui --ssh`): the two the page words
297
+ * itself name the commands of a run on this machine, and here what stopped answering is the tunnel, opened from the
298
+ * person's own machine. Every other failure is the run's, and stands.
299
+ */
300
+ export function overTunnel(f) {
301
+ if (f.code !== "unreachable" && f.message !== "this page's cookie is not the running Mason's") return f;
302
+ return { code: f.code, message: "the tunnel to this server has closed", why: f.why,
303
+ fix: "mason ui --ssh <user@server>, on your own machine, opens this page again: each tunnel has its own address",
304
+ next: [{ command: "mason ui --ssh <user@server>", what: "this page, through a new tunnel" }] };
305
+ }
306
+
295
307
  /** A part of a page written from one read: its body rendered, its Failure said where it shows when `says` (not the
296
308
  * page's first read's: that is the banner), or that it is being asked. */
297
309
  export function readPart(ctx, path, render, says) {
@@ -328,7 +340,7 @@ export function statusKind(word) {
328
340
  const w = String(word ?? "").toLowerCase();
329
341
  if (/^(ready|synced|done|copied|completed|ok|streamed|running|live|added)\b/.test(w)) return "ok";
330
342
  if (/^(failed|error|refused|lost|not running|stopped)\b/.test(w)) return "bad";
331
- if (/^(under way|syncing|copying|waiting|catching up|not streamed|not kept current|unsynced|cancelled|warning|left out|pending)\b/.test(w)) return "warn";
343
+ if (/^(under way|syncing|behind|copying|waiting|catching up|not streamed|not kept current|unsynced|cancelled|warning|left out|pending)\b/.test(w)) return "warn";
332
344
  return "unknown";
333
345
  }
334
346
 
@@ -471,16 +483,20 @@ export const USERS_HASH = "#users";
471
483
  * place. `first` (nothing has asked Mason anything yet) leads with what the URL is for. Nothing from a run that does
472
484
  * not say it.
473
485
  */
474
- export function renderConnect(pg, { first = false, table = null } = {}) {
486
+ export function renderConnect(pg, { first = false, table = null, served = false, share = "" } = {}) {
475
487
  if (!pg || typeof pg.shown !== "string") return "";
476
488
  // a first statement to type that the request log lists (one that reads a copied table: UNLISTED_STATEMENTS)
477
489
  const tryIt = first && table ? `<dt>Then try</dt><dd>${copyable("connect-try", `select count(*) from ${entryName(table)};`)} <span class="dim">it shows on Queries</span></dd>` : "";
478
490
  return `<div class="connect${first ? " first" : ""}"><p class="connect-title">${first ? "Connect your first tool" : "Connect"}</p>` +
479
491
  (first ? `<p class="lead">Mason answers SQL over the Postgres protocol, as a read replica of your database would: point psql, a BI tool or your app's analytics code at this URL.</p>` : "") +
480
492
  `<dl class="facts"><dt>URL</dt><dd>${copyable("connect-url", pg.shown)}</dd><dt>psql</dt><dd>${copyable("connect-psql", pg.psql)}</dd>${tryIt}</dl>` +
481
- `<p class="tip"><a class="btn${first ? " primary" : ""}" href="${USERS_HASH}">Create a user</a> <span>Its name and password go in place of ${code("<user>:<password>")}: the Users page shows the whole URL once, as ${code("mason user add <name>")} prints it.</span></p></div>`;
493
+ (served ? `<p class="tip">${serverHostNote(pg)}</p>` : "") +
494
+ `<p class="tip"><a class="btn${first ? " primary" : ""}" href="${USERS_HASH}">Create a user</a> <span>Its name and password go in place of ${code("<user>:<password>")}: the Users page shows the whole URL once, as ${code("mason user add <name>")} prints it.</span></p>${share}</div>`;
482
495
  }
483
496
 
497
+ /** On a server's page the Postgres URL's host is the server's own view of itself: said beside it, as a tool elsewhere needs the server's address. */
498
+ export const serverHostNote = (pg) => `This is the address on the server: from elsewhere a tool connects to the server's own address, in place of ${code(pg.host ?? "localhost")}.`;
499
+
484
500
  /** Nothing to show, quietly: a title and a line under it (`hintHtml`: HTML, a command in code()). */
485
501
  export const empty = (title, hintHtml = "") => `<div class="empty"><p class="empty-title">${esc(title)}</p>${hintHtml ? `<p>${hintHtml}</p>` : ""}</div>`;
486
502
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mason-data/cli",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "mason start: point Mason at your Postgres and pick the tables to copy. Fast analytics for the database your app already has.",
5
5
  "keywords": ["mason", "analytics", "postgres", "duckdb", "cli"],
6
6
  "homepage": "https://github.com/embeddable-hq/mason-data#readme",
7
7
  "repository": { "type": "git", "url": "git+https://github.com/embeddable-hq/mason-data.git", "directory": "cli" },
8
8
  "license": "Apache-2.0",
9
9
  "type": "module",
10
- "bin": { "mason": "dist/src/cli/main.js" },
10
+ "bin": { "mason": "dist/src/cli/mason.cjs" },
11
11
  "files": ["dist", "README.md", "LICENSE"],
12
12
  "engines": { "node": ">=22.13" },
13
13
  "scripts": {
@@ -16,16 +16,17 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@duckdb/node-api": "2.0.0-r.1",
19
+ "@duckdb/node-bindings": "2.0.0-r.1",
19
20
  "@electric-sql/pglite": "^0.5.10",
20
21
  "libpg-query": "^18.1.5",
21
22
  "pgsql-deparser": "18.3.8",
22
23
  "yaml": "^2.6.0"
23
24
  },
24
25
  "optionalDependencies": {
25
- "@mason-data/extensions-darwin-arm64": "0.8.0",
26
- "@mason-data/extensions-darwin-x64": "0.8.0",
27
- "@mason-data/extensions-linux-arm64": "0.8.0",
28
- "@mason-data/extensions-linux-x64": "0.8.0",
29
- "@mason-data/extensions-win32-x64": "0.8.0"
26
+ "@mason-data/extensions-darwin-arm64": "0.9.0",
27
+ "@mason-data/extensions-darwin-x64": "0.9.0",
28
+ "@mason-data/extensions-linux-arm64": "0.9.0",
29
+ "@mason-data/extensions-linux-x64": "0.9.0",
30
+ "@mason-data/extensions-win32-x64": "0.9.0"
30
31
  }
31
32
  }