@rebasepro/cli 0.28.1 → 0.29.0-canary.g0e3a0e7

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 (38) hide show
  1. package/dist/{apps-BpYRGOaM.js → apps-Dg0NnmmJ.js} +3 -3
  2. package/dist/{apps-BpYRGOaM.js.map → apps-Dg0NnmmJ.js.map} +1 -1
  3. package/dist/{build-CS-Z75eK.js → build-1Zo35L6a.js} +3 -3
  4. package/dist/{build-CS-Z75eK.js.map → build-1Zo35L6a.js.map} +1 -1
  5. package/dist/{bundle-C0IBCVpV.js → bundle-CTkzO2WG.js} +2 -2
  6. package/dist/{bundle-C0IBCVpV.js.map → bundle-CTkzO2WG.js.map} +1 -1
  7. package/dist/{cloud-nwWkzAHu.js → cloud-CFotGK2-.js} +948 -39
  8. package/dist/cloud-CFotGK2-.js.map +1 -0
  9. package/dist/commands/cloud/connect.d.ts +81 -0
  10. package/dist/commands/cloud/databases.d.ts +1 -0
  11. package/dist/commands/cloud/db-access.d.ts +25 -0
  12. package/dist/commands/cloud/index.d.ts +9 -0
  13. package/dist/commands/cloud/maintenance.d.ts +44 -0
  14. package/dist/commands/cloud/resources.d.ts +1 -1
  15. package/dist/{context-DvIUbE-b.js → context-DN1b9pCR.js} +2 -1
  16. package/dist/context-DN1b9pCR.js.map +1 -0
  17. package/dist/{fold-static-BMO8LC01.js → fold-static-vbZJeo37.js} +2 -2
  18. package/dist/{fold-static-BMO8LC01.js.map → fold-static-vbZJeo37.js.map} +1 -1
  19. package/dist/{generate_sdk-_SQuSbJW.js → generate_sdk-DCUUogIP.js} +2 -2
  20. package/dist/{generate_sdk-_SQuSbJW.js.map → generate_sdk-DCUUogIP.js.map} +1 -1
  21. package/dist/index.es.js +13 -13
  22. package/dist/{init-CHtpYLlh.js → init-YzfyEffT.js} +2 -2
  23. package/dist/{init-CHtpYLlh.js.map → init-YzfyEffT.js.map} +1 -1
  24. package/dist/{normalize-imports-BN0fzZS8.js → normalize-imports-xpSL_GuU.js} +2 -2
  25. package/dist/{normalize-imports-BN0fzZS8.js.map → normalize-imports-xpSL_GuU.js.map} +1 -1
  26. package/dist/{schema-2A0dd-Bv.js → schema-CApM25cs.js} +10 -9
  27. package/dist/schema-CApM25cs.js.map +1 -0
  28. package/dist/schema-reconcile-CX1_6Xqm.js +2 -0
  29. package/dist/{start-21GRsZKc.js → start-28EztR4R.js} +2 -2
  30. package/dist/{start-21GRsZKc.js.map → start-28EztR4R.js.map} +1 -1
  31. package/package.json +8 -8
  32. package/templates/template/ai-instructions.md +1 -1
  33. package/templates/views/AppView.tsx.tmpl +19 -32
  34. package/templates/views/EntityView.tsx.tmpl +8 -7
  35. package/dist/cloud-nwWkzAHu.js.map +0 -1
  36. package/dist/context-DvIUbE-b.js.map +0 -1
  37. package/dist/schema-2A0dd-Bv.js.map +0 -1
  38. package/dist/schema-reconcile-C3ToVnHr.js +0 -2
@@ -2,11 +2,11 @@ import { i as recordEvent, l as durationBucket } from "./telemetry-CgwJPVMO.js";
2
2
  import { C as switchOn, D as unknownCommandMessage, c as findProjectRoot, p as requireProjectRoot } from "./project-CasK56vN.js";
3
3
  import { t as cliUserAgent } from "./version-Buyyo1ut.js";
4
4
  import { _ as selectDeployApp, d as findBackendApp, f as formatAppAddress, l as cmsMountOf, p as loadManifest } from "./manifest-BtzDy7KQ.js";
5
- import { C as toolStdio, n as UNVENDORED_COST, s as buildBundle, x as unvendoredReason } from "./bundle-C0IBCVpV.js";
6
- import { $ as resolveCloudUrl, A as lookupProjectId, B as projectLinkPath, C as grantForLink, D as isKnownControlPlane, E as isJsonMode, F as printGroupHelp, G as requireClient, H as refuseDirectLink, I as printJson, J as requireKnownAction, K as requireCloudRow, L as probeToken, M as noteBlank, N as openUrl, O as keyValues, P as parseCloudArgs, Q as resolveCloudTarget, R as projectDotenvSetsAppKey, S as getContextOrg, T as initOutputMode, U as removeLink, V as readLink, W as reportError, X as requireProjectRef, Y as requireProject, Z as requireSessionClient, _ as fail, _t as orgCapabilitiesInScopes, a as billingAccountIdOf, at as storedGrantForLink, b as forgetEphemeralGrant, bt as wantsRawError, c as colorStatus, ct as writeLink, d as displayProjectRef, dt as ORG_CAPABILITY_NAMES, et as resolveProjectRef, f as dotenvSets, ft as TOKEN_CAPABILITIES, g as ephemeralGrantFor, gt as isTokenCapability, h as envToken, ht as isOrgCapability, i as appKeyExpiryNote, it as setCurrentContext, j as note, k as linkedEphemeralGrant, l as confirmDestructive, lt as ALWAYS_SCOPES, m as emitHelp, mt as capabilitiesInScopes, n as GLOBAL_HELP_FLAGS, nt as saveEphemeralGrant, o as cloudRow, ot as success, p as emit, pt as TOKEN_CAPABILITY_NAMES, q as requireInteractive, r as TOKEN_ENV, rt as setContextOrg, s as cloudRows, st as warn, t as GLOBAL_CLOUD_FLAGS, tt as resolveTimeoutMs, u as createCloudClient, ut as ORG_CAPABILITIES, v as fetchDeployTargets, vt as scopesForCapabilities, w as grantProjectOf, x as freshAccessToken, y as fetchTenantBaseDomain, yt as scopesForOrgCapabilities, z as projectHost } from "./context-DvIUbE-b.js";
7
- import { n as foldFrontendIntoBundle, r as foldableApps } from "./fold-static-BMO8LC01.js";
5
+ import { C as toolStdio, n as UNVENDORED_COST, s as buildBundle, x as unvendoredReason } from "./bundle-CTkzO2WG.js";
6
+ import { $ as resolveCloudUrl, A as lookupProjectId, B as projectLinkPath, C as grantForLink, D as isKnownControlPlane, E as isJsonMode, F as printGroupHelp, G as requireClient, H as refuseDirectLink, I as printJson, J as requireKnownAction, K as requireCloudRow, L as probeToken, M as noteBlank, N as openUrl, O as keyValues, P as parseCloudArgs, Q as resolveCloudTarget, R as projectDotenvSetsAppKey, S as getContextOrg, T as initOutputMode, U as removeLink, V as readLink, W as reportError, X as requireProjectRef, Y as requireProject, Z as requireSessionClient, _ as fail, _t as orgCapabilitiesInScopes, a as billingAccountIdOf, at as storedGrantForLink, b as forgetEphemeralGrant, bt as wantsRawError, c as colorStatus, ct as writeLink, d as displayProjectRef, dt as ORG_CAPABILITY_NAMES, et as resolveProjectRef, f as dotenvSets, ft as TOKEN_CAPABILITIES, g as ephemeralGrantFor, gt as isTokenCapability, h as envToken, ht as isOrgCapability, i as appKeyExpiryNote, it as setCurrentContext, j as note, k as linkedEphemeralGrant, l as confirmDestructive, lt as ALWAYS_SCOPES, m as emitHelp, mt as capabilitiesInScopes, n as GLOBAL_HELP_FLAGS, nt as saveEphemeralGrant, o as cloudRow, ot as success, p as emit, pt as TOKEN_CAPABILITY_NAMES, q as requireInteractive, r as TOKEN_ENV, rt as setContextOrg, s as cloudRows, st as warn, t as GLOBAL_CLOUD_FLAGS, tt as resolveTimeoutMs, u as createCloudClient, ut as ORG_CAPABILITIES, v as fetchDeployTargets, vt as scopesForCapabilities, w as grantProjectOf, x as freshAccessToken, y as fetchTenantBaseDomain, yt as scopesForOrgCapabilities, z as projectHost } from "./context-DN1b9pCR.js";
7
+ import { n as foldFrontendIntoBundle, r as foldableApps } from "./fold-static-vbZJeo37.js";
8
8
  import { n as deriveOptionsFor, r as deriveResourceGraph } from "./derive-ae9UOoOB.js";
9
- import { t as buildAssetApp } from "./build-CS-Z75eK.js";
9
+ import { t as buildAssetApp } from "./build-1Zo35L6a.js";
10
10
  import chalk from "chalk";
11
11
  import arg from "arg";
12
12
  import fs from "fs";
@@ -18,7 +18,211 @@ import { DEFAULT_STORAGE_SOURCE_KEY } from "@rebasepro/types";
18
18
  import inquirer from "inquirer";
19
19
  import { RebaseApiError, createRebaseClient } from "@rebasepro/client";
20
20
  import net from "node:net";
21
+ import fs$1 from "node:fs";
21
22
  import { parse } from "acorn";
23
+ //#region src/commands/cloud/maintenance.ts
24
+ /**
25
+ * A project's maintenance window, what its database is waiting on, and its
26
+ * events — from the terminal.
27
+ *
28
+ * rebase cloud compute apply [--yes] restart the database at its new size now
29
+ * rebase cloud compute window show the weekly window
30
+ * rebase cloud compute window --day sun --hour 3 move it (UTC)
31
+ * rebase cloud events [--limit 20] what happened to the backend, newest first
32
+ *
33
+ * All of it is the control plane's `maintenance` function
34
+ * (`saas/backend/functions/maintenance.ts`). A database change that restarts
35
+ * Postgres never happens on `compute set`: it waits for the window, and
36
+ * `compute apply` is how someone who would rather take the restart now says so.
37
+ */
38
+ var COMPUTE_WINDOW_FLAGS = {
39
+ "--day": String,
40
+ "--hour": Number
41
+ };
42
+ var EVENTS_FLAGS = { "--limit": Number };
43
+ var DAYS = [
44
+ "sun",
45
+ "mon",
46
+ "tue",
47
+ "wed",
48
+ "thu",
49
+ "fri",
50
+ "sat"
51
+ ];
52
+ var DAY_NAMES = [
53
+ "sunday",
54
+ "monday",
55
+ "tuesday",
56
+ "wednesday",
57
+ "thursday",
58
+ "friday",
59
+ "saturday"
60
+ ];
61
+ /** `sun`, `sunday`, `0` → 0. Undefined for anything else, including the ambiguous `t` and `s`. */
62
+ function parseDay(value) {
63
+ const v = value.trim().toLowerCase();
64
+ if (/^[0-6]$/.test(v)) return Number(v);
65
+ if (v.length < 2) return void 0;
66
+ const i = DAY_NAMES.findIndex((d) => d.startsWith(v));
67
+ return i >= 0 ? i : void 0;
68
+ }
69
+ /** The project's maintenance status, or undefined from a control plane that has no maintenance function yet. */
70
+ async function fetchMaintenance(client, projectId) {
71
+ try {
72
+ return await client.functions.invoke("maintenance", void 0, {
73
+ method: "GET",
74
+ path: `projects/${encodeURIComponent(projectId)}`
75
+ });
76
+ } catch {
77
+ return;
78
+ }
79
+ }
80
+ /** One line for a waiting batch: "Database 0.16 → 0.5 vCPU — applies Sunday 9 November, 03:00 UTC". */
81
+ function describePending(open) {
82
+ if (!open) return void 0;
83
+ if (open.state === "applying") return `${open.summary} — ${chalk.yellow("applying now")}`;
84
+ const when = open.scheduledLabel ?? (open.scheduledFor ? new Date(open.scheduledFor).toUTCString() : "when the project starts");
85
+ return `${open.summary} — applies ${when}`;
86
+ }
87
+ async function computeApplyCommand(rawArgs) {
88
+ const { flags } = parseCloudArgs({
89
+ spec: {},
90
+ rawArgs,
91
+ commandWords: 3,
92
+ command: "cloud compute apply",
93
+ maxPositionals: 0
94
+ });
95
+ const { client } = await requireClient(rawArgs);
96
+ const projectId = await requireProject(rawArgs, client);
97
+ const ref = displayProjectRef(rawArgs);
98
+ const status = await fetchMaintenance(client, projectId);
99
+ if (!status) fail("This control plane does not schedule database changes yet.", void 0, "unsupported");
100
+ const open = status.open;
101
+ if (!open || open.state !== "pending" && open.state !== "notified") {
102
+ if (open?.state === "applying") {
103
+ emit(() => note(`${open.summary} is being applied now.`), {
104
+ status: "applying",
105
+ maintenance: open
106
+ });
107
+ return;
108
+ }
109
+ emit(() => success(`Nothing is waiting: ${ref}'s database already matches its settings.`), {
110
+ status: "nothing",
111
+ maintenance: null
112
+ });
113
+ return;
114
+ }
115
+ await confirmDestructive({
116
+ yes: Boolean(flags["--yes"]),
117
+ prompt: `Apply "${open.summary}" to ${ref} now? ${open.expectedImpact ?? "The database restarts."}`
118
+ });
119
+ try {
120
+ await client.functions.invoke("maintenance", {}, { path: `projects/${encodeURIComponent(projectId)}/apply` });
121
+ } catch (error) {
122
+ reportError(error, "Could not apply the database change");
123
+ }
124
+ emit(() => {
125
+ success(`Applying ${open.summary}.`);
126
+ note("The database restarts first, then the app. Follow it with `rebase cloud events`.");
127
+ }, {
128
+ status: "applying",
129
+ maintenance: open
130
+ });
131
+ }
132
+ async function computeWindowCommand(rawArgs) {
133
+ const { flags } = parseCloudArgs({
134
+ spec: COMPUTE_WINDOW_FLAGS,
135
+ rawArgs,
136
+ commandWords: 3,
137
+ command: "cloud compute window",
138
+ maxPositionals: 0
139
+ });
140
+ const { client } = await requireClient(rawArgs);
141
+ const projectId = await requireProject(rawArgs, client);
142
+ const dayFlag = flags["--day"];
143
+ const hourFlag = flags["--hour"];
144
+ if (dayFlag === void 0 && hourFlag === void 0) {
145
+ const status = await fetchMaintenance(client, projectId);
146
+ if (!status) fail("This control plane does not schedule database changes yet.", void 0, "unsupported");
147
+ emit(() => {
148
+ console.log("");
149
+ keyValues([
150
+ ["Window", status.window.label],
151
+ ["Next", new Date(status.window.nextAt).toUTCString()],
152
+ ["Waiting", describePending(status.open) ?? chalk.gray("nothing")]
153
+ ]);
154
+ console.log("");
155
+ noteBlank();
156
+ note("Move it with:");
157
+ note(chalk.cyan(" rebase cloud compute window --day sun --hour 3"));
158
+ console.log("");
159
+ }, {
160
+ window: status.window,
161
+ open: status.open
162
+ });
163
+ return;
164
+ }
165
+ if (dayFlag === void 0 || hourFlag === void 0) fail("Give both --day and --hour.", "e.g. `rebase cloud compute window --day sun --hour 3` (UTC)", "bad_request");
166
+ const day = parseDay(dayFlag);
167
+ if (day === void 0) fail(`--day ${dayFlag} is not a day.`, "Use sun, mon, … sat, or 0 (Sunday) to 6.", "bad_request");
168
+ if (!Number.isInteger(hourFlag) || hourFlag < 0 || hourFlag > 23) fail(`--hour ${String(hourFlag)} is not an hour.`, "Use 0 to 23, in UTC.", "bad_request");
169
+ let res;
170
+ try {
171
+ res = await client.functions.invoke("maintenance", {
172
+ day,
173
+ hour: hourFlag
174
+ }, {
175
+ method: "PUT",
176
+ path: `projects/${encodeURIComponent(projectId)}/window`
177
+ });
178
+ } catch (error) {
179
+ reportError(error, "Could not move the maintenance window");
180
+ }
181
+ emit(() => success(`Maintenance window: ${res?.window?.label ?? `${DAYS[day]} ${hourFlag}:00 UTC`}.`), { window: res?.window ?? {
182
+ day,
183
+ hour: hourFlag
184
+ } });
185
+ }
186
+ var SEVERITY_DOT = {
187
+ warning: chalk.yellow("●"),
188
+ notice: chalk.blue("●"),
189
+ info: chalk.gray("●")
190
+ };
191
+ async function eventsCommand(rawArgs) {
192
+ const { flags } = parseCloudArgs({
193
+ spec: EVENTS_FLAGS,
194
+ rawArgs,
195
+ commandWords: 2,
196
+ command: "cloud events",
197
+ maxPositionals: 0
198
+ });
199
+ const { client } = await requireClient(rawArgs);
200
+ const projectId = await requireProject(rawArgs, client);
201
+ const limit = Math.min(200, Math.max(1, flags["--limit"] ?? 20));
202
+ let events = [];
203
+ try {
204
+ events = (await client.functions.invoke("maintenance", void 0, {
205
+ method: "GET",
206
+ path: `projects/${encodeURIComponent(projectId)}/events?limit=${limit}`
207
+ })).events ?? [];
208
+ } catch (error) {
209
+ reportError(error, "Could not read the project's events");
210
+ }
211
+ emit(() => {
212
+ console.log("");
213
+ if (events.length === 0) {
214
+ note("Nothing has happened yet. Scaling, database changes and failovers appear here.");
215
+ console.log("");
216
+ return;
217
+ }
218
+ for (const e of events) {
219
+ const when = new Date(e.at).toLocaleString();
220
+ console.log(` ${SEVERITY_DOT[e.severity] ?? SEVERITY_DOT.info} ${chalk.bold(e.title)} ${chalk.gray(when)}${e.emailed ? chalk.gray(" · emailed") : ""}`);
221
+ if (e.body) note(` ${e.body}`);
222
+ }
223
+ console.log("");
224
+ }, { events });
225
+ }
22
226
  /**
23
227
  * The remedy for a step that needs a terminal when there is none: a token,
24
228
  * which needs neither a password nor a code. Minted in the console because a
@@ -1215,14 +1419,15 @@ async function statusCommand(rawArgs) {
1215
1419
  try {
1216
1420
  const project = await client.data.collection("projects").findById(projectId);
1217
1421
  if (!project) fail(`Project ${displayProjectRef(rawArgs)} not found.`, void 0, "not_found");
1218
- const [db, storage, deploy, baseDomain] = await Promise.all([
1422
+ const [db, storage, deploy, baseDomain, maintenance] = await Promise.all([
1219
1423
  firstRow(client, "databases", projectId),
1220
1424
  client.functions.invoke("storage-provision", void 0, {
1221
1425
  method: "GET",
1222
1426
  path: projectId
1223
1427
  }).catch(() => void 0),
1224
1428
  latestDeployment(client, projectId),
1225
- fetchTenantBaseDomain(client, url)
1429
+ fetchTenantBaseDomain(client, url),
1430
+ fetchMaintenance(client, projectId)
1226
1431
  ]);
1227
1432
  const storageLine = describeStorageState(storage);
1228
1433
  const databaseLine = describeDatabaseState(db);
@@ -1245,6 +1450,7 @@ async function statusCommand(rawArgs) {
1245
1450
  ["Runtime", describeRuntime(project)],
1246
1451
  ["Database", databaseLine],
1247
1452
  ["Storage", storageLine],
1453
+ ["Maintenance", describePending(maintenance?.open)],
1248
1454
  ["Claim URL", grant ? chalk.bold(grant.claimUrl) : void 0],
1249
1455
  ["Expires", grant ? `${new Date(grant.expiresAt).toLocaleString()} unless claimed, then deleted` : void 0]
1250
1456
  ]);
@@ -1285,6 +1491,10 @@ async function statusCommand(rawArgs) {
1285
1491
  connectionStatus: db.connectionStatus ?? null
1286
1492
  } : null,
1287
1493
  storage: storage ?? null,
1494
+ maintenance: maintenance ? {
1495
+ window: maintenance.window,
1496
+ pending: maintenance.open
1497
+ } : null,
1288
1498
  unclaimed: grant ? {
1289
1499
  claimUrl: grant.claimUrl,
1290
1500
  expiresAt: grant.expiresAt,
@@ -2165,7 +2375,12 @@ async function billingCommand(rawArgs) {
2165
2375
  * The action words `rebase cloud compute` dispatches. No word, or `show`,
2166
2376
  * prints the dials and the quote.
2167
2377
  */
2168
- var COMPUTE_ACTIONS = ["show", "set"];
2378
+ var COMPUTE_ACTIONS = [
2379
+ "show",
2380
+ "set",
2381
+ "apply",
2382
+ "window"
2383
+ ];
2169
2384
  /** The dials, and the flag that sets each. */
2170
2385
  var DIAL_FLAGS = {
2171
2386
  "--cpu": "cpu",
@@ -2177,7 +2392,9 @@ var DIAL_FLAGS = {
2177
2392
  "--db-memory": "databaseMemory",
2178
2393
  "--storage": "storageMode",
2179
2394
  "--autoscale-max": "autoscaleMaxReplicas",
2180
- "--autoscale-cpu-target": "autoscaleTargetCpuPercent"
2395
+ "--autoscale-cpu-target": "autoscaleTargetCpuPercent",
2396
+ "--db-autoscale-max-cpu": "dbAutoscaleMaxCpu",
2397
+ "--db-autoscale-max-memory": "dbAutoscaleMaxMemory"
2181
2398
  };
2182
2399
  /**
2183
2400
  * The flags `resources set` accepts, in the shape a spec is written in.
@@ -2193,7 +2410,8 @@ var DIAL_FLAGS = {
2193
2410
  */
2194
2411
  var COMPUTE_SET_FLAGS = {
2195
2412
  ...Object.fromEntries(Object.keys(DIAL_FLAGS).map((flag) => [flag, String])),
2196
- "--no-autoscale": Boolean
2413
+ "--no-autoscale": Boolean,
2414
+ "--no-db-autoscale": Boolean
2197
2415
  };
2198
2416
  /**
2199
2417
  * The flag that used to set `scaleToZero`. Still parsed, so a script that passes
@@ -2236,6 +2454,8 @@ var BOOLEAN_DIALS = /* @__PURE__ */ new Set(["preemptible"]);
2236
2454
  */
2237
2455
  async function computeCommand(action, rawArgs) {
2238
2456
  requireKnownAction("compute", action, COMPUTE_ACTIONS);
2457
+ if (action === "apply") return computeApplyCommand(rawArgs);
2458
+ if (action === "window") return computeWindowCommand(rawArgs);
2239
2459
  parseCloudArgs({
2240
2460
  spec: action === "set" ? {
2241
2461
  ...COMPUTE_SET_FLAGS,
@@ -2252,6 +2472,7 @@ async function computeCommand(action, rawArgs) {
2252
2472
  if (!project) fail(`Project ${displayProjectRef(rawArgs)} not found.`, void 0, "not_found");
2253
2473
  if (action !== "set") {
2254
2474
  let quote;
2475
+ const maintenance = await fetchMaintenance(client, projectId);
2255
2476
  try {
2256
2477
  quote = await client.functions.invoke("pricing", project, {
2257
2478
  method: "POST",
@@ -2277,8 +2498,11 @@ async function computeCommand(action, rawArgs) {
2277
2498
  ["Database instances", dialLine(project.databaseInstances)],
2278
2499
  ["Database CPU", dialLine(project.databaseCpu)],
2279
2500
  ["Database memory", dialLine(project.databaseMemory)],
2501
+ ["Database autoscaling", project.dbAutoscaleMaxCpu || project.dbAutoscaleMaxMemory ? `up to ${[project.dbAutoscaleMaxCpu ? `${String(project.dbAutoscaleMaxCpu)} CPU` : null, project.dbAutoscaleMaxMemory ? `${String(project.dbAutoscaleMaxMemory)} memory` : null].filter(Boolean).join(", ")}` : chalk.gray("off")],
2280
2502
  ["Object storage", dialLine(project.storageMode)],
2281
- ["Per month", quote ? `€${quote.totalEur.toFixed(2)}` : void 0]
2503
+ ["Per month", quote ? `€${quote.totalEur.toFixed(2)}` : void 0],
2504
+ ["Waiting", describePending(maintenance?.open)],
2505
+ ["Maintenance window", maintenance?.window.label]
2282
2506
  ]);
2283
2507
  if (quote) {
2284
2508
  console.log("");
@@ -2305,7 +2529,13 @@ async function computeCommand(action, rawArgs) {
2305
2529
  databaseInstances: project.databaseInstances ?? null,
2306
2530
  databaseCpu: project.databaseCpu ?? null,
2307
2531
  databaseMemory: project.databaseMemory ?? null,
2308
- storageMode: project.storageMode ?? null
2532
+ dbAutoscaleMaxCpu: project.dbAutoscaleMaxCpu ?? null,
2533
+ dbAutoscaleMaxMemory: project.dbAutoscaleMaxMemory ?? null,
2534
+ storageMode: project.storageMode ?? null,
2535
+ maintenance: maintenance ? {
2536
+ window: maintenance.window,
2537
+ pending: maintenance.open
2538
+ } : null
2309
2539
  });
2310
2540
  return;
2311
2541
  }
@@ -2318,14 +2548,23 @@ async function computeCommand(action, rawArgs) {
2318
2548
  reportError(error, "Could not change resources");
2319
2549
  return;
2320
2550
  }
2551
+ const maintenance = await fetchMaintenance(client, projectId);
2321
2552
  emit(() => {
2322
2553
  success("Resources updated.");
2323
2554
  noteBlank();
2324
2555
  for (const [field, value] of Object.entries(patch)) note(` ${field} → ${String(value)}`);
2325
2556
  noteBlank();
2326
2557
  note("Applied now: the app rolls its pods and your subscription is prorated from today.");
2327
- note("A change that restarts the database waits for a maintenance window.");
2328
- }, { updated: patch });
2558
+ const pending = describePending(maintenance?.open);
2559
+ if (pending) {
2560
+ note(`Scheduled: ${pending}.`);
2561
+ if (maintenance?.open?.expectedImpact) note(` ${maintenance.open.expectedImpact}. Billed at the current size until then.`);
2562
+ note(` Apply it sooner with ${chalk.cyan("rebase cloud compute apply")}, or move the window with ${chalk.cyan("rebase cloud compute window")}.`);
2563
+ }
2564
+ }, {
2565
+ updated: patch,
2566
+ maintenance: maintenance?.open ?? null
2567
+ });
2329
2568
  }
2330
2569
  /**
2331
2570
  * A dial's value, or a marker that the platform default decides it.
@@ -2353,6 +2592,10 @@ function buildDialPatch(rawArgs, opts) {
2353
2592
  patch.autoscaleMaxReplicas = null;
2354
2593
  patch.autoscaleTargetCpuPercent = null;
2355
2594
  }
2595
+ if (switchOn(rawArgs, "--no-db-autoscale")) {
2596
+ patch.dbAutoscaleMaxCpu = null;
2597
+ patch.dbAutoscaleMaxMemory = null;
2598
+ }
2356
2599
  const retired = rawArgs.indexOf(RETIRED_SCALE_TO_ZERO);
2357
2600
  if (retired !== -1) {
2358
2601
  const value = rawArgs[retired + 1];
@@ -2391,7 +2634,7 @@ function buildDialPatch(rawArgs, opts) {
2391
2634
  }
2392
2635
  if (opts?.requireOne !== false && Object.keys(patch).length === 0) return {
2393
2636
  patch: {},
2394
- error: `Nothing to set. Pass one of: ${Object.keys(DIAL_FLAGS).join(", ")}, --no-autoscale.`
2637
+ error: `Nothing to set. Pass one of: ${Object.keys(DIAL_FLAGS).join(", ")}, --no-autoscale, --no-db-autoscale.`
2395
2638
  };
2396
2639
  return { patch };
2397
2640
  }
@@ -2638,6 +2881,164 @@ function pipeThroughTunnel(socket, endpoint, token) {
2638
2881
  socket.on("error", () => closeBoth());
2639
2882
  }
2640
2883
  //#endregion
2884
+ //#region src/commands/cloud/db-access.ts
2885
+ /**
2886
+ * `rebase cloud db access` — read-only access to the managed database from
2887
+ * named addresses outside the platform, for a tool that cannot run a tunnel: a
2888
+ * hosted BI dashboard, a notebook service, a warehouse loader.
2889
+ *
2890
+ * db access What is open, to whom, and how to connect
2891
+ * db access enable --allow … Open it (or change who and what): the whole desired state
2892
+ * db access disable Close it, and drop the role
2893
+ * db access reveal The read-only role's password and a connection URL
2894
+ *
2895
+ * The control plane's `db-access` function does the work; how it keeps this
2896
+ * read-only and to the named addresses is documented there.
2897
+ */
2898
+ var DB_ACCESS_ACTIONS = [
2899
+ "status",
2900
+ "enable",
2901
+ "disable",
2902
+ "reveal"
2903
+ ];
2904
+ var DB_ACCESS_FLAGS = {
2905
+ "--allow": [String],
2906
+ "--schemas": [String],
2907
+ "--tables": [String],
2908
+ "--ca-out": String
2909
+ };
2910
+ /** Repeated or comma-separated, either way. */
2911
+ function list(values) {
2912
+ if (!values) return void 0;
2913
+ const out = values.flatMap((v) => v.split(",")).map((v) => v.trim()).filter(Boolean);
2914
+ return out.length > 0 ? out : void 0;
2915
+ }
2916
+ function writeCa(path, pem) {
2917
+ if (!path) return void 0;
2918
+ if (!pem) fail("The database's CA certificate is not available yet.", "Try again in a minute.", "ca_unavailable");
2919
+ fs$1.writeFileSync(path, pem);
2920
+ return path;
2921
+ }
2922
+ function printStatus$1(status, projectRef, caPath) {
2923
+ console.log("");
2924
+ console.log(chalk.bold(` 🔓 External database access — project ${projectRef}`));
2925
+ console.log("");
2926
+ if (!status.enabled) {
2927
+ console.log(chalk.gray(" Off. The database is reachable only from inside the platform and through"));
2928
+ console.log(chalk.gray(" `rebase cloud db connect`. To let a tool connect from its own address:"));
2929
+ console.log("");
2930
+ console.log(` ${chalk.cyan("rebase cloud db access enable --allow <ip>")}`);
2931
+ console.log("");
2932
+ return;
2933
+ }
2934
+ keyValues([
2935
+ ["Host", status.host ?? chalk.yellow("allocating…")],
2936
+ ["Port", String(status.port)],
2937
+ ["Database", status.database],
2938
+ ["Username", status.username],
2939
+ ["Password", chalk.gray("hidden — `rebase cloud db access reveal`")],
2940
+ ["TLS", `required (${status.sslmode} with the cluster CA)`],
2941
+ ["Allowed from", status.allow.join(", ")],
2942
+ ["Reads", [...status.schemas.map((s) => `${s}.*`), ...status.tables].join(", ")],
2943
+ ["Connections", status.connectionLimit === void 0 ? void 0 : `up to ${status.connectionLimit} at once`],
2944
+ ["CA written to", caPath]
2945
+ ]);
2946
+ if (status.pending) {
2947
+ console.log("");
2948
+ console.log(chalk.yellow(` ${status.pending}`));
2949
+ }
2950
+ console.log("");
2951
+ }
2952
+ async function dbAccessCommand(rawArgs) {
2953
+ const { flags, positionals } = parseCloudArgs({
2954
+ spec: DB_ACCESS_FLAGS,
2955
+ rawArgs,
2956
+ commandWords: 3,
2957
+ command: "cloud db access",
2958
+ maxPositionals: 1
2959
+ });
2960
+ const action = positionals[0] || "status";
2961
+ requireKnownAction("db access", action, DB_ACCESS_ACTIONS);
2962
+ if (action !== "enable" && (flags["--allow"] || flags["--schemas"] || flags["--tables"])) fail("--allow, --schemas and --tables go with `enable`.", "Run `rebase cloud db access --help`.", "invalid_flags");
2963
+ const { client } = await requireClient(rawArgs);
2964
+ const projectId = await requireProject(rawArgs, client);
2965
+ const projectRef = displayProjectRef(rawArgs);
2966
+ try {
2967
+ if (action === "status") {
2968
+ const status = await client.functions.invoke("db-access", void 0, {
2969
+ method: "GET",
2970
+ path: projectId
2971
+ });
2972
+ const caPath = status.enabled ? writeCa(flags["--ca-out"], status.caCertificate) : void 0;
2973
+ emit(() => printStatus$1(status, projectRef, caPath), {
2974
+ projectId,
2975
+ ...status
2976
+ });
2977
+ return;
2978
+ }
2979
+ if (action === "enable") {
2980
+ const allow = list(flags["--allow"]);
2981
+ if (!allow) fail("Name the addresses the database may be reached from.", "e.g. --allow 34.89.253.13 (repeat it, or separate with commas).", "missing_allow");
2982
+ const status = await client.functions.invoke("db-access", {
2983
+ allow,
2984
+ schemas: list(flags["--schemas"]),
2985
+ tables: list(flags["--tables"])
2986
+ }, {
2987
+ method: "PUT",
2988
+ path: projectId
2989
+ });
2990
+ const caPath = writeCa(flags["--ca-out"], status.caCertificate);
2991
+ emit(() => {
2992
+ success(`External read-only access is on for ${status.allow.join(", ")}.`);
2993
+ printStatus$1(status, projectRef, caPath);
2994
+ console.log(chalk.gray(" Get the password and a ready connection URL with `rebase cloud db access reveal`."));
2995
+ console.log("");
2996
+ }, {
2997
+ projectId,
2998
+ ...status
2999
+ });
3000
+ return;
3001
+ }
3002
+ if (action === "disable") {
3003
+ await confirmDestructive({
3004
+ yes: Boolean(flags["--yes"]),
3005
+ prompt: "Close external access? Tools connected with the read-only role will stop working, and its password is deleted."
3006
+ });
3007
+ emit(() => success("External access is off, and the read-only role is dropped."), {
3008
+ projectId,
3009
+ ...await client.functions.invoke("db-access", void 0, {
3010
+ method: "DELETE",
3011
+ path: projectId
3012
+ })
3013
+ });
3014
+ return;
3015
+ }
3016
+ const revealed = await client.functions.invoke("db-access", void 0, {
3017
+ method: "POST",
3018
+ path: `${projectId}/reveal`
3019
+ });
3020
+ const caPath = writeCa(flags["--ca-out"], revealed.caCertificate);
3021
+ emit(() => {
3022
+ console.log("");
3023
+ keyValues([
3024
+ ["Host", revealed.host ?? chalk.yellow("allocating…")],
3025
+ ["Username", revealed.username],
3026
+ ["Password", revealed.password],
3027
+ ["Connection", revealed.connectionString ?? void 0],
3028
+ ["CA written to", caPath]
3029
+ ]);
3030
+ console.log("");
3031
+ if (!caPath) console.log(chalk.gray(" For sslmode=verify-ca, save the CA with --ca-out <file> and pass it as sslrootcert."));
3032
+ console.log("");
3033
+ }, {
3034
+ projectId,
3035
+ ...revealed
3036
+ });
3037
+ } catch (e) {
3038
+ reportError(e, `Failed to ${action === "status" ? "read" : action} external database access`);
3039
+ }
3040
+ }
3041
+ //#endregion
2641
3042
  //#region src/commands/cloud/databases.ts
2642
3043
  /** The filename a backup is restored and downloaded by. */
2643
3044
  function backupName(row) {
@@ -2663,6 +3064,9 @@ async function dbCommand(subcommand, rawArgs) {
2663
3064
  case "connect":
2664
3065
  await dbConnect(rawArgs);
2665
3066
  break;
3067
+ case "access":
3068
+ await dbAccessCommand(rawArgs);
3069
+ break;
2666
3070
  case "test":
2667
3071
  await testDatabase(rawArgs);
2668
3072
  break;
@@ -3264,6 +3668,17 @@ function printDbHelp() {
3264
3668
  section: "Database",
3265
3669
  description: "Test database connectivity"
3266
3670
  },
3671
+ {
3672
+ action: "access",
3673
+ section: "Database",
3674
+ description: "Read-only access from named addresses, for a BI or analytics tool (status|enable|disable|reveal)",
3675
+ flags: [
3676
+ ["--allow <ip|cidr>", "With enable: an address the database may be reached from. Repeatable"],
3677
+ ["--schemas <name>", "With enable: schemas to read whole. Default: public"],
3678
+ ["--tables <schema.table>", "With enable: single tables to read as well. Repeatable"],
3679
+ ["--ca-out <file>", "Write the cluster's CA certificate, for sslmode=verify-ca"]
3680
+ ]
3681
+ },
3267
3682
  {
3268
3683
  action: "backup list",
3269
3684
  section: "Backups",
@@ -4996,7 +5411,7 @@ function stateColor(state) {
4996
5411
  }
4997
5412
  /** The flags `cron list` parses — the help page lists exactly these. */
4998
5413
  var CRON_LIST_FLAGS = { "--host": String };
4999
- async function listCommand$1(rawArgs) {
5414
+ async function listCommand$2(rawArgs) {
5000
5415
  parseCloudArgs({
5001
5416
  spec: CRON_LIST_FLAGS,
5002
5417
  rawArgs,
@@ -5102,7 +5517,7 @@ async function cronCommand(action, rawArgs) {
5102
5517
  await logsCommand$1(rawArgs);
5103
5518
  return;
5104
5519
  }
5105
- await listCommand$1(rawArgs);
5520
+ await listCommand$2(rawArgs);
5106
5521
  }
5107
5522
  //#endregion
5108
5523
  //#region src/commands/cloud/env.ts
@@ -6416,11 +6831,11 @@ async function uploadBundle(url, token, projectId, tarPath) {
6416
6831
  if (!data.bundleId) throw new Error("Bundle upload endpoint did not return a bundle id.");
6417
6832
  return data.bundleId;
6418
6833
  }
6419
- function isRecord$1(value) {
6834
+ function isRecord$2(value) {
6420
6835
  return typeof value === "object" && value !== null && !Array.isArray(value);
6421
6836
  }
6422
6837
  function recordFrom(value) {
6423
- if (!isRecord$1(value) || typeof value.type !== "string" || typeof value.name !== "string") return null;
6838
+ if (!isRecord$2(value) || typeof value.type !== "string" || typeof value.name !== "string") return null;
6424
6839
  const values = Array.isArray(value.values) ? value.values.filter((v) => typeof v === "string") : [];
6425
6840
  return values.length > 0 ? {
6426
6841
  type: value.type,
@@ -6439,10 +6854,10 @@ function recordFrom(value) {
6439
6854
  * not print as live.
6440
6855
  */
6441
6856
  function deployHostsFrom(response) {
6442
- if (!isRecord$1(response) || !Array.isArray(response.hosts)) return void 0;
6857
+ if (!isRecord$2(response) || !Array.isArray(response.hosts)) return void 0;
6443
6858
  const hosts = [];
6444
6859
  for (const entry of response.hosts) {
6445
- if (!isRecord$1(entry) || typeof entry.host !== "string" || entry.host === "") continue;
6860
+ if (!isRecord$2(entry) || typeof entry.host !== "string" || entry.host === "") continue;
6446
6861
  const records = Array.isArray(entry.records) ? entry.records.map(recordFrom).filter((r) => r !== null) : [];
6447
6862
  hosts.push({
6448
6863
  host: entry.host,
@@ -7372,7 +7787,7 @@ function normalizePreviewName(raw) {
7372
7787
  if (name.includes("--")) usage("`--` is what separates it from the project's name in the address");
7373
7788
  return name;
7374
7789
  }
7375
- function isRecord(value) {
7790
+ function isRecord$1(value) {
7376
7791
  return typeof value === "object" && value !== null && !Array.isArray(value);
7377
7792
  }
7378
7793
  function text(row, ...keys) {
@@ -7388,7 +7803,7 @@ function text(row, ...keys) {
7388
7803
  * address, which is the one field a preview cannot be reported without.
7389
7804
  */
7390
7805
  function previewFrom(value) {
7391
- if (!isRecord(value)) return null;
7806
+ if (!isRecord$1(value)) return null;
7392
7807
  const name = text(value, "name");
7393
7808
  const url = text(value, "url");
7394
7809
  if (!name || !url) return null;
@@ -7429,7 +7844,7 @@ function previewsUnavailable(e) {
7429
7844
  */
7430
7845
  var PREVIEW_STATIC_UNSERVED = "PREVIEW_STATIC_UNSERVED";
7431
7846
  function intakeCodeOf(e) {
7432
- if (!isRecord(e) || !isRecord(e.details)) return void 0;
7847
+ if (!isRecord$1(e) || !isRecord$1(e.details)) return void 0;
7433
7848
  return typeof e.details.intakeCode === "string" ? e.details.intakeCode : void 0;
7434
7849
  }
7435
7850
  /**
@@ -7462,9 +7877,9 @@ async function triggerPreview(client, projectId, body, refusal) {
7462
7877
  refusal(e);
7463
7878
  reportError(e, "Preview deploy failed to start");
7464
7879
  }
7465
- const deployment = isRecord(res) && isRecord(res.deployment) ? res.deployment : void 0;
7880
+ const deployment = isRecord$1(res) && isRecord$1(res.deployment) ? res.deployment : void 0;
7466
7881
  const deploymentId = deployment ? text(deployment, "id") : null;
7467
- const preview = isRecord(res) ? previewFrom(res.preview) : null;
7882
+ const preview = isRecord$1(res) ? previewFrom(res.preview) : null;
7468
7883
  if (!deploymentId || !preview) fail("The control plane started a preview but did not say where it will be served.", "Run `rebase cloud previews` to find it.", "invalid_response");
7469
7884
  return {
7470
7885
  deploymentId,
@@ -7488,7 +7903,7 @@ var PREVIEW_PRICING_DOCS = "https://rebase.pro/docs/deployment/cloud/#preview-a-
7488
7903
  /** The billing rule in words: what is printed when the control plane cannot put a number on it. */
7489
7904
  var PREVIEW_PRICING_RULE = "A backend preview is billed like one app unit at the default size, at your app's rate for its region and capacity, prorated for as long as it exists.";
7490
7905
  function quoteAnswerFrom(value) {
7491
- if (!isRecord(value) || typeof value.totalEur !== "number" || !Number.isFinite(value.totalEur)) return null;
7906
+ if (!isRecord$1(value) || typeof value.totalEur !== "number" || !Number.isFinite(value.totalEur)) return null;
7492
7907
  return {
7493
7908
  totalEur: value.totalEur,
7494
7909
  backendPreviews: typeof value.backendPreviews === "number" ? value.backendPreviews : void 0
@@ -7525,13 +7940,13 @@ async function previewCost(client, url, projectId) {
7525
7940
  } catch {
7526
7941
  return cost;
7527
7942
  }
7528
- if (!isRecord(project)) return cost;
7943
+ if (!isRecord$1(project)) return cost;
7529
7944
  try {
7530
7945
  const res = await client.functions.invoke(PREVIEWS_FUNCTION, void 0, {
7531
7946
  method: "GET",
7532
7947
  path: projectId
7533
7948
  });
7534
- const rows = isRecord(res) && Array.isArray(res.previews) ? res.previews : void 0;
7949
+ const rows = isRecord$1(res) && Array.isArray(res.previews) ? res.previews : void 0;
7535
7950
  if (rows) cost.backendPreviews = Math.max(1, rows.map(previewFrom).filter((p) => p !== null && p.backend !== "production").length);
7536
7951
  } catch {}
7537
7952
  const counts = [0, 1];
@@ -7551,7 +7966,7 @@ async function previewCost(client, url, projectId) {
7551
7966
  });
7552
7967
  if (!res.ok) return cost;
7553
7968
  const body = await res.json();
7554
- quotes = isRecord(body) && Array.isArray(body.quotes) ? body.quotes.map(quoteAnswerFrom) : [];
7969
+ quotes = isRecord$1(body) && Array.isArray(body.quotes) ? body.quotes.map(quoteAnswerFrom) : [];
7555
7970
  } catch {
7556
7971
  return cost;
7557
7972
  }
@@ -7575,7 +7990,7 @@ function previewCostLines(cost, previewName) {
7575
7990
  }
7576
7991
  /** The flags `previews list` parses — the help page lists exactly these. */
7577
7992
  var PREVIEWS_LIST_FLAGS = {};
7578
- async function listCommand(rawArgs) {
7993
+ async function listCommand$1(rawArgs) {
7579
7994
  parseCloudArgs({
7580
7995
  spec: PREVIEWS_LIST_FLAGS,
7581
7996
  rawArgs,
@@ -7595,7 +8010,7 @@ async function listCommand(rawArgs) {
7595
8010
  previewsUnavailable(e);
7596
8011
  reportError(e, "Failed to list previews");
7597
8012
  }
7598
- const previews = (isRecord(res) && Array.isArray(res.previews) ? res.previews : []).map(previewFrom).filter((p) => p !== null);
8013
+ const previews = (isRecord$1(res) && Array.isArray(res.previews) ? res.previews : []).map(previewFrom).filter((p) => p !== null);
7599
8014
  emit(() => {
7600
8015
  console.log("");
7601
8016
  console.log(chalk.bold(` 🔍 Previews — project ${displayProjectRef(rawArgs)}`));
@@ -7665,7 +8080,7 @@ async function previewsCommand(action, rawArgs) {
7665
8080
  await deleteCommand(rawArgs);
7666
8081
  return;
7667
8082
  }
7668
- await listCommand(rawArgs);
8083
+ await listCommand$1(rawArgs);
7669
8084
  }
7670
8085
  //#endregion
7671
8086
  //#region src/commands/cloud/runtime-logs.ts
@@ -11728,6 +12143,389 @@ async function powerCommand(action, rawArgs) {
11728
12143
  }
11729
12144
  }
11730
12145
  //#endregion
12146
+ //#region src/commands/cloud/connect.ts
12147
+ /**
12148
+ * `rebase cloud connect <url>` — add a self-hosted Rebase instance to your
12149
+ * Rebase account, so the Rebase connector in Claude reaches it as it reaches
12150
+ * every Cloud project.
12151
+ *
12152
+ * ## What it does
12153
+ *
12154
+ * 1. Registers the instance's origin with the control plane
12155
+ * (`POST /api/functions/linked-instances`). The control plane answers the
12156
+ * two variables the instance needs to accept the connector's short-lived
12157
+ * tokens: the platform's public key and the audience it signs them for.
12158
+ * Registering is idempotent per organization and origin, so the command
12159
+ * can be rerun any time.
12160
+ * 2. Prints those two lines, and offers to write them into `./.env` when
12161
+ * there is one and somebody is at the terminal to say yes.
12162
+ * 3. Waits for the instance to accept the connector
12163
+ * (`POST …/linked-instances/:id/check`), which happens once it restarts
12164
+ * with the variables set.
12165
+ *
12166
+ * `--list` and `--remove` manage what is registered. Nothing here touches the
12167
+ * instance itself: the control plane only ever calls it, and only with tokens
12168
+ * the instance verifies against the key printed here.
12169
+ */
12170
+ /** The control-plane function that holds linked instances. */
12171
+ var LINKED_INSTANCES_FUNCTION = "linked-instances";
12172
+ /** Where the hosted connector lives, for the line that says what to do next. */
12173
+ var CONNECTOR_URL = "https://app.rebase.pro/mcp";
12174
+ /** The two variables the instance reads to accept the connector's tokens. */
12175
+ var PLATFORM_TOKEN_KEY_ENV = "REBASE_PLATFORM_TOKEN_KEY";
12176
+ var PLATFORM_TOKEN_AUDIENCE_ENV = "REBASE_PLATFORM_TOKEN_AUDIENCE";
12177
+ var CHECK_TIMEOUT_MS = 10 * 6e4;
12178
+ /** The flags `cloud connect` parses — the help page lists exactly these. */
12179
+ var CONNECT_FLAGS = {
12180
+ "--name": String,
12181
+ "--org": String,
12182
+ "--list": Boolean,
12183
+ "--remove": String,
12184
+ "--no-wait": Boolean
12185
+ };
12186
+ function isRecord(value) {
12187
+ return typeof value === "object" && value !== null && !Array.isArray(value);
12188
+ }
12189
+ function isLinkedInstance(value) {
12190
+ return isRecord(value) && typeof value.id === "string" && typeof value.url === "string" && (typeof value.name === "string" || value.name === void 0) && (typeof value.verifiedAt === "string" || value.verifiedAt === null || value.verifiedAt === void 0);
12191
+ }
12192
+ function isLinkResponse(value) {
12193
+ return isRecord(value) && isLinkedInstance(value.instance) && isRecord(value.env) && typeof value.env["REBASE_PLATFORM_TOKEN_KEY"] === "string" && typeof value.env["REBASE_PLATFORM_TOKEN_AUDIENCE"] === "string";
12194
+ }
12195
+ function isCheckResult(value) {
12196
+ if (!isRecord(value) || typeof value.ok !== "boolean") return false;
12197
+ return value.ok ? isLinkedInstance(value.instance) : typeof value.reason === "string";
12198
+ }
12199
+ /** The organizations an `organization_required` refusal lists. */
12200
+ function organizationsIn(details) {
12201
+ if (!isRecord(details) || !Array.isArray(details.organizations)) return [];
12202
+ const found = [];
12203
+ for (const org of details.organizations) {
12204
+ if (!isRecord(org) || typeof org.id !== "string" && typeof org.id !== "number") continue;
12205
+ found.push({
12206
+ id: String(org.id),
12207
+ name: typeof org.name === "string" ? org.name : String(org.id)
12208
+ });
12209
+ }
12210
+ return found;
12211
+ }
12212
+ /** An instance's organization, for a reader: its name when the control plane sent one. */
12213
+ function organizationLabel(organization) {
12214
+ if (typeof organization === "string" || typeof organization === "number") return String(organization);
12215
+ if (isRecord(organization)) {
12216
+ if (typeof organization.name === "string") return organization.name;
12217
+ if (typeof organization.id === "string" || typeof organization.id === "number") return String(organization.id);
12218
+ }
12219
+ return "";
12220
+ }
12221
+ /**
12222
+ * The origin of what the person typed: `your-app.com` → `https://your-app.com`,
12223
+ * `https://your-app.com/admin?x=1` → `https://your-app.com`. Null when it is
12224
+ * not an http(s) address at all.
12225
+ */
12226
+ function normalizeInstanceUrl(input) {
12227
+ const trimmed = input.trim();
12228
+ if (!trimmed) return null;
12229
+ const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
12230
+ let parsed;
12231
+ try {
12232
+ parsed = new URL(withScheme);
12233
+ } catch {
12234
+ return null;
12235
+ }
12236
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
12237
+ if (!parsed.hostname) return null;
12238
+ return parsed.origin;
12239
+ }
12240
+ function requireInstanceUrl(input) {
12241
+ const origin = normalizeInstanceUrl(input);
12242
+ if (!origin) fail(`"${input}" is not an address the connector can reach.`, "Pass the instance's public address, e.g. `rebase cloud connect your-app.com`.", "invalid_url");
12243
+ return origin;
12244
+ }
12245
+ /** Refuse, with what it means here, a call the control plane answered with an error. */
12246
+ function reportLinkError(e, context) {
12247
+ if (e instanceof RebaseApiError) {
12248
+ if (e.status === 404 && isMissingRoute(e.message)) fail("This control plane cannot add self-hosted instances yet.", "Cloud projects already reach the connector; self-hosted ones need a newer control plane.", "linked_instances_unavailable");
12249
+ if (e.code === "invalid_url") fail(e.message || "The control plane refused that address.", "Pass the instance's public https address.", "invalid_url");
12250
+ if (e.status === 403 || e.code === "forbidden") fail(e.message || "Only an owner or admin of the organization can add instances to it.", "Ask an owner or admin of the organization, or pass --org with one you administer.", "forbidden");
12251
+ }
12252
+ reportError(e, context);
12253
+ }
12254
+ async function createLink(client, body) {
12255
+ const res = await client.functions.invoke(LINKED_INSTANCES_FUNCTION, body, { method: "POST" });
12256
+ if (!isLinkResponse(res)) fail("The control plane answered without the instance's variables.", void 0, "bad_response");
12257
+ return res;
12258
+ }
12259
+ /**
12260
+ * Register the instance, picking an organization when the account has several
12261
+ * and none was named — interactively when somebody can answer, otherwise by
12262
+ * listing them and naming `--org`.
12263
+ */
12264
+ async function linkInstance(client, body, commandLine) {
12265
+ try {
12266
+ return await createLink(client, body);
12267
+ } catch (e) {
12268
+ if (!(e instanceof RebaseApiError) || e.code !== "organization_required") reportLinkError(e, "Failed to add the instance");
12269
+ const organizations = organizationsIn(e.details);
12270
+ if (!isJsonMode() && process.stdin.isTTY === true && organizations.length > 0) {
12271
+ const { picked } = await inquirer.prompt([{
12272
+ type: "select",
12273
+ name: "picked",
12274
+ message: "You belong to several organizations. Add the instance to which one?",
12275
+ choices: organizations.map((org) => ({
12276
+ name: `${org.name} ${chalk.gray(org.id)}`,
12277
+ value: org.id
12278
+ }))
12279
+ }]);
12280
+ try {
12281
+ return await createLink(client, {
12282
+ ...body,
12283
+ organizationId: picked
12284
+ });
12285
+ } catch (retry) {
12286
+ reportLinkError(retry, "Failed to add the instance");
12287
+ }
12288
+ }
12289
+ const message = "You belong to several organizations; say which one the instance belongs to.";
12290
+ const hint = `Rerun with --org <id>: ${commandLine} --org ${organizations[0]?.id ?? "<id>"}. \`rebase cloud use <org>\` makes one the default.`;
12291
+ if (isJsonMode()) {
12292
+ printJson({ error: {
12293
+ message,
12294
+ code: "organization_required",
12295
+ hint,
12296
+ organizations
12297
+ } });
12298
+ process.exit(1);
12299
+ }
12300
+ console.error("");
12301
+ console.error(chalk.red(` ✗ ${message}`));
12302
+ console.error("");
12303
+ for (const org of organizations) console.error(` ${chalk.bold(org.id)} ${org.name}`);
12304
+ console.error("");
12305
+ console.error(chalk.gray(` ${hint}`));
12306
+ console.error("");
12307
+ process.exit(1);
12308
+ }
12309
+ }
12310
+ /** Ask the control plane whether the instance accepts the connector now. */
12311
+ async function checkInstance(client, id) {
12312
+ const res = await client.functions.invoke(LINKED_INSTANCES_FUNCTION, void 0, {
12313
+ method: "POST",
12314
+ path: `${encodeURIComponent(id)}/check`
12315
+ });
12316
+ if (!isCheckResult(res)) fail("The control plane answered the check with something this CLI cannot read.", void 0, "bad_response");
12317
+ return res;
12318
+ }
12319
+ /** A check that failed on the way — the control plane briefly down — rather than with an answer. */
12320
+ function isTransient(e) {
12321
+ return e instanceof RebaseApiError && (e.status === 0 || e.status !== void 0 && e.status >= 500);
12322
+ }
12323
+ /** What a failed check means, for the waiting line. */
12324
+ function describeCheckFailure(result) {
12325
+ switch (result.reason) {
12326
+ case "unreachable": return "the control plane cannot reach it yet";
12327
+ case "not_configured": return "it does not have the variables yet";
12328
+ case "rejected": return `it refused the connector's token${result.message ? ` (${result.message})` : ""}`;
12329
+ default: return result.message ?? result.reason;
12330
+ }
12331
+ }
12332
+ /**
12333
+ * Check every `intervalMs` until the instance accepts the connector or
12334
+ * `timeoutMs` passes. `onWaiting` hears each refusal, so the caller can keep
12335
+ * one status line current.
12336
+ */
12337
+ async function waitForInstance(client, id, opts = {}) {
12338
+ const intervalMs = opts.intervalMs ?? 5e3;
12339
+ const timeoutMs = opts.timeoutMs ?? 6e5;
12340
+ const sleep = opts.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
12341
+ const now = opts.now ?? Date.now;
12342
+ const deadline = now() + timeoutMs;
12343
+ let last = {
12344
+ ok: false,
12345
+ reason: "unreachable"
12346
+ };
12347
+ for (;;) {
12348
+ try {
12349
+ last = await checkInstance(client, id);
12350
+ if (last.ok) return last;
12351
+ opts.onWaiting?.(last);
12352
+ } catch (e) {
12353
+ if (!isTransient(e)) reportLinkError(e, "Failed to check the instance");
12354
+ }
12355
+ if (now() + intervalMs > deadline) return last;
12356
+ await sleep(intervalMs);
12357
+ }
12358
+ }
12359
+ function connectedLine(name) {
12360
+ return `Connected. Ask Claude about ${name} through the Rebase connector (${CONNECTOR_URL}).`;
12361
+ }
12362
+ /** Offer to write the two variables into `./.env`, when there is one and somebody to ask. */
12363
+ async function offerDotenv(env, yes) {
12364
+ const file = path.resolve(".env");
12365
+ if (!fs.existsSync(file) || process.stdin.isTTY !== true || isJsonMode()) return null;
12366
+ if (!yes) {
12367
+ const { write } = await inquirer.prompt([{
12368
+ type: "confirm",
12369
+ name: "write",
12370
+ default: true,
12371
+ message: "Add them to ./.env?"
12372
+ }]);
12373
+ if (!write) return null;
12374
+ }
12375
+ upsertDotenv(file, PLATFORM_TOKEN_KEY_ENV, env[PLATFORM_TOKEN_KEY_ENV]);
12376
+ upsertDotenv(file, PLATFORM_TOKEN_AUDIENCE_ENV, env[PLATFORM_TOKEN_AUDIENCE_ENV]);
12377
+ return file;
12378
+ }
12379
+ async function connectInstance(client, controlPlane, input, flags) {
12380
+ const origin = requireInstanceUrl(input);
12381
+ const name = flags.name?.trim() || new URL(origin).hostname;
12382
+ const organizationId = flags.org || getContextOrg(controlPlane);
12383
+ const linked = await linkInstance(client, {
12384
+ url: origin,
12385
+ name,
12386
+ ...organizationId ? { organizationId } : {}
12387
+ }, `rebase cloud connect ${input}`);
12388
+ const instance = linked.instance;
12389
+ const shownName = instance.name || name;
12390
+ let check;
12391
+ try {
12392
+ check = await checkInstance(client, instance.id);
12393
+ } catch (e) {
12394
+ if (!isTransient(e)) reportLinkError(e, "Failed to check the instance");
12395
+ check = null;
12396
+ }
12397
+ if (isJsonMode()) {
12398
+ printJson({
12399
+ ...linked,
12400
+ check
12401
+ });
12402
+ return;
12403
+ }
12404
+ if (check?.ok) {
12405
+ success(instance.verifiedAt ? `${instance.url} is already connected to your Rebase account.` : `${instance.url} is in your Rebase account and accepts the connector.`);
12406
+ console.log(` ${connectedLine(shownName)}`);
12407
+ console.log("");
12408
+ return;
12409
+ }
12410
+ const lines = [PLATFORM_TOKEN_KEY_ENV, PLATFORM_TOKEN_AUDIENCE_ENV].map((key) => dotenvLine(key, linked.env[key]) ?? `${key}=${linked.env[key]}`);
12411
+ console.log("");
12412
+ console.log(chalk.bold.green(linked.created ? ` ✓ Added ${instance.url} to your Rebase account as "${shownName}".` : ` ✓ ${instance.url} is already in your Rebase account as "${shownName}".`));
12413
+ console.log("");
12414
+ console.log(" Set these two variables on that server:");
12415
+ console.log("");
12416
+ for (const line of lines) console.log(line);
12417
+ console.log("");
12418
+ console.log(" Then restart it.");
12419
+ console.log("");
12420
+ const wrote = await offerDotenv(linked.env, flags.yes);
12421
+ if (wrote) success(`Set ${PLATFORM_TOKEN_KEY_ENV} and ${PLATFORM_TOKEN_AUDIENCE_ENV} in ${wrote}. Restart the server to load them.`);
12422
+ if (flags.noWait) {
12423
+ note(`Once it has restarted, ${chalk.bold(`rebase cloud connect ${input}`)} checks the connection.`);
12424
+ noteBlank();
12425
+ return;
12426
+ }
12427
+ const waiting = `Waiting for ${instance.url} to accept the connector — restart it with these variables. Ctrl+C to stop; rerun this command any time.`;
12428
+ const live = process.stderr.isTTY === true;
12429
+ if (live) process.stderr.write(` ${waiting}`);
12430
+ else note(waiting);
12431
+ const result = await waitForInstance(client, instance.id, { onWaiting: (failure) => {
12432
+ if (live) process.stderr.write(`\r\x1b[2K ${waiting} ${chalk.gray(`(${describeCheckFailure(failure)})`)}`);
12433
+ } });
12434
+ if (live) process.stderr.write("\n");
12435
+ if (!result.ok) fail(`${instance.url} did not accept the connector within ${CHECK_TIMEOUT_MS / 6e4} minutes: ${describeCheckFailure(result)}.`, `Set the two variables on that server, restart it, then run \`rebase cloud connect ${input}\` again.`, "not_connected");
12436
+ console.log("");
12437
+ console.log(chalk.bold.green(` ✓ ${connectedLine(shownName)}`));
12438
+ console.log("");
12439
+ }
12440
+ async function listInstances(client) {
12441
+ let res;
12442
+ try {
12443
+ res = await client.functions.invoke(LINKED_INSTANCES_FUNCTION, void 0, { method: "GET" });
12444
+ } catch (e) {
12445
+ reportLinkError(e, "Failed to list linked instances");
12446
+ }
12447
+ if (!isRecord(res) || !Array.isArray(res.instances)) fail("The control plane answered without a list of instances.", void 0, "bad_response");
12448
+ return res.instances.filter(isLinkedInstance);
12449
+ }
12450
+ async function listCommand(client) {
12451
+ const instances = await listInstances(client);
12452
+ emit(() => {
12453
+ console.log("");
12454
+ if (instances.length === 0) {
12455
+ console.log(chalk.gray(" No self-hosted instances in your Rebase account."));
12456
+ console.log(chalk.gray(" Add one with ") + chalk.bold("rebase cloud connect <url>"));
12457
+ console.log("");
12458
+ return;
12459
+ }
12460
+ const nameWidth = Math.max(4, ...instances.map((i) => (i.name ?? "").length));
12461
+ const urlWidth = Math.max(3, ...instances.map((i) => i.url.length));
12462
+ console.log(chalk.gray(` ${"NAME".padEnd(nameWidth)} ${"URL".padEnd(urlWidth)} ${"STATUS".padEnd(9)} ORG`));
12463
+ for (const instance of instances) {
12464
+ const status = instance.verifiedAt ? chalk.green("connected") : chalk.yellow("waiting ");
12465
+ console.log(` ${chalk.bold((instance.name ?? "").padEnd(nameWidth))} ${instance.url.padEnd(urlWidth)} ${status} ` + chalk.gray(organizationLabel(instance.organization)));
12466
+ }
12467
+ console.log("");
12468
+ }, { instances });
12469
+ }
12470
+ async function removeCommand(client, ref, yes) {
12471
+ const instances = await listInstances(client);
12472
+ const origin = normalizeInstanceUrl(ref);
12473
+ const target = instances.find((i) => i.id === ref) ?? (origin ? instances.find((i) => normalizeInstanceUrl(i.url) === origin) : void 0);
12474
+ if (!target) fail(`No linked instance matches "${ref}".`, "`rebase cloud connect --list` names them.", "not_found");
12475
+ await confirmDestructive({
12476
+ yes,
12477
+ prompt: `Remove ${target.name || target.url} (${target.url}) from your Rebase account? The connector stops reaching it.`
12478
+ });
12479
+ try {
12480
+ await client.functions.invoke(LINKED_INSTANCES_FUNCTION, void 0, {
12481
+ method: "DELETE",
12482
+ path: encodeURIComponent(target.id)
12483
+ });
12484
+ } catch (e) {
12485
+ reportLinkError(e, "Failed to remove the instance");
12486
+ }
12487
+ success(`Removed ${target.url} from your Rebase account.`);
12488
+ emit(() => {}, {
12489
+ deleted: true,
12490
+ instance: target
12491
+ });
12492
+ }
12493
+ async function connectCommand(rawArgs) {
12494
+ const { flags, positionals } = parseCloudArgs({
12495
+ spec: CONNECT_FLAGS,
12496
+ rawArgs,
12497
+ commandWords: 2,
12498
+ command: "cloud connect",
12499
+ maxPositionals: 1
12500
+ });
12501
+ const input = positionals[0];
12502
+ const list = flags["--list"] === true;
12503
+ const remove = flags["--remove"];
12504
+ const yes = flags["--yes"] === true;
12505
+ if ([
12506
+ list,
12507
+ remove !== void 0,
12508
+ input !== void 0
12509
+ ].filter(Boolean).length > 1) fail("Pass one of: an address, --list, or --remove <url-or-id>.", "Run `rebase cloud connect --help`.", "usage");
12510
+ if (!list && remove === void 0 && !input) fail("Name the instance to add: `rebase cloud connect <url>`.", "Its public address, e.g. `rebase cloud connect your-app.com`. `--list` shows the ones already added.", "usage");
12511
+ const { client, url: controlPlane } = await requireClient(rawArgs);
12512
+ if (list) {
12513
+ await listCommand(client);
12514
+ return;
12515
+ }
12516
+ if (remove !== void 0) {
12517
+ await removeCommand(client, remove, yes);
12518
+ return;
12519
+ }
12520
+ if (!input) return;
12521
+ await connectInstance(client, controlPlane, input, {
12522
+ name: flags["--name"],
12523
+ org: flags["--org"],
12524
+ noWait: flags["--no-wait"] === true,
12525
+ yes
12526
+ });
12527
+ }
12528
+ //#endregion
11731
12529
  //#region src/commands/cloud/usage.ts
11732
12530
  /**
11733
12531
  * `rebase cloud usage [org] [--month YYYY-MM]`: what a project — or every
@@ -12997,6 +13795,30 @@ var ACTION_HELP = {
12997
13795
  ],
12998
13796
  notes: ["`restore` replaces the live database. Nothing about it is undoable from here — `--yes`, the global flag listed below, is what skips that confirmation.", "Backups are the project's own: a base backup on a schedule, plus continuous WAL archiving for point-in-time recovery."]
12999
13797
  },
13798
+ "db access": {
13799
+ command: "cloud db access",
13800
+ usage: "cloud db access [status|enable|disable|reveal] [--allow <ip|cidr>]... [--schemas <name>]... [--tables <schema.table>]... [--ca-out <file>] [--yes]",
13801
+ summary: "Let a tool that cannot run a tunnel — a hosted BI dashboard, a notebook, a warehouse loader — read the managed database from its own address. `enable` creates a read-only role, a load balancer that admits only the addresses you name, and requires TLS; the role reads the schemas and tables you choose and nothing else. `enable` takes the whole desired state, so running it again with other addresses replaces them. `reveal` prints the role's password and a connection URL. `status` is the default.",
13802
+ flags: [
13803
+ ["--allow <ip|cidr>", "An IPv4 address or range the database may be reached from (at most a /16). Repeatable, or comma-separated"],
13804
+ ["--schemas <name>", "Schemas the role reads whole, tables created later included. Default: public"],
13805
+ ["--tables <schema.table>", "Single tables the role reads as well, e.g. rebase.cron_logs. Repeatable"],
13806
+ ["--ca-out <file>", "Write the cluster's CA certificate here, to verify the server with sslmode=verify-ca"]
13807
+ ],
13808
+ examples: [
13809
+ "rebase cloud db access enable --allow 34.89.253.13",
13810
+ "rebase cloud db access enable --allow 34.89.253.13 --tables rebase.metric_samples,rebase.cron_logs",
13811
+ "rebase cloud db access reveal --ca-out db-ca.pem",
13812
+ "rebase cloud db access disable --yes"
13813
+ ],
13814
+ notes: [
13815
+ "Owner or admin only, as for the database password. Every change and every reveal is in `rebase cloud activity`.",
13816
+ "The `rebase` schema holds users, password hashes and session tokens: it is never granted whole, and its credential tables never at all.",
13817
+ "Managed databases on GCP capacity only for now. Each project with access on has its own network load balancer, which is billed.",
13818
+ "The role holds up to 25 connections at once — enough for a dashboard that loads its widgets in parallel, one connection per query — and the app keeps the rest. A tool that opens more is refused the extra ones.",
13819
+ "`disable` closes the address, drops the role and deletes its password. `--yes`, the global flag listed below, skips the confirmation."
13820
+ ]
13821
+ },
13000
13822
  "db pitr": {
13001
13823
  command: "cloud db pitr",
13002
13824
  usage: "cloud db pitr <status|restore|cutover|discard> [--target <timestamp>] [--yes]",
@@ -13275,15 +14097,46 @@ var ACTION_HELP = {
13275
14097
  },
13276
14098
  compute: {
13277
14099
  command: "cloud compute",
13278
- usage: "cloud compute [set] [options]",
14100
+ usage: "cloud compute [set|apply|window] [options]",
13279
14101
  summary: "What this project reserves, and what the control plane would invoice for it. Bare, it prints every dial and an itemised €/month; `set` changes one. An empty dial means the platform default, which moves when the default moves — a dial pinned to the same number does not.",
13280
14102
  flags: [],
13281
14103
  examples: [
13282
14104
  "rebase cloud compute",
13283
14105
  "rebase cloud compute --json",
13284
- "rebase cloud compute set --help"
14106
+ "rebase cloud compute set --help",
14107
+ "rebase cloud compute apply",
14108
+ "rebase cloud compute window --day sun --hour 3"
13285
14109
  ],
13286
- notes: ["The price is the control plane's own quote for these dials, itemised line by line — not a tier, and not a number this CLI computes."]
14110
+ notes: ["The price is the control plane's own quote for these dials, itemised line by line — not a tier, and not a number this CLI computes.", "`Waiting` is a database change a `set` scheduled for the maintenance window and has not applied yet; the project is billed at the size it runs until then."]
14111
+ },
14112
+ "compute apply": {
14113
+ command: "cloud compute apply",
14114
+ usage: "cloud compute apply [--yes]",
14115
+ summary: "Apply the database change this project is waiting on now, instead of in its maintenance window. The database restarts first and the app after it; with one database instance it is unavailable for about one to three minutes, with a standby for a few seconds.",
14116
+ flags: [],
14117
+ examples: ["rebase cloud compute apply", "rebase cloud compute apply --yes --json"],
14118
+ notes: [
14119
+ "Asks before restarting anything; `--yes` skips the question, and is required off a terminal.",
14120
+ "Needs the organization's owner or admin role.",
14121
+ "Nothing waiting is not an error: it says so and exits 0.",
14122
+ "Follow it with `rebase cloud events`."
14123
+ ]
14124
+ },
14125
+ "compute window": {
14126
+ command: "cloud compute window",
14127
+ usage: "cloud compute window [--day <day> --hour <0-23>]",
14128
+ summary: "The weekly hour in which changes that restart the database are applied, in UTC. Bare, it prints the window and what is waiting for it; with both flags it moves the window, and anything waiting moves with it.",
14129
+ flags: [["--day <day>", "sun, mon, … sat, or 0 (Sunday) to 6"], ["--hour <0-23>", "The hour it opens, in UTC"]],
14130
+ examples: ["rebase cloud compute window", "rebase cloud compute window --day sat --hour 2"],
14131
+ notes: ["The default is Sunday at 03:00 UTC. You are emailed 24 hours before anything is applied in it."]
14132
+ },
14133
+ events: {
14134
+ command: "cloud events",
14135
+ usage: "cloud events [--limit <n>]",
14136
+ summary: "What happened to this project's backend, newest first: the app scaling, database changes scheduled and applied, a standby taking over, the disk growing. Problems are alerts; this is the record.",
14137
+ flags: [["--limit <n>", "How many, 1–200. Default: 20"]],
14138
+ examples: ["rebase cloud events", "rebase cloud events --limit 100 --json"],
14139
+ notes: ["Lines that were also emailed to the organization say so."]
13287
14140
  },
13288
14141
  "compute set": {
13289
14142
  command: "cloud compute set",
@@ -13300,16 +14153,20 @@ var ACTION_HELP = {
13300
14153
  ["--storage <mode>", "Object storage: shared-prefix or dedicated-bucket"],
13301
14154
  ["--autoscale-max <n>", "1–16. The ceiling the app may reach, and the worst case it may be billed"],
13302
14155
  ["--autoscale-cpu-target <pct>", "10–95. CPU utilisation the autoscaler holds, against the request. Default: 70"],
13303
- ["--no-autoscale", "Turn autoscaling off. The only way to: a ceiling at or below --replicas is refused"]
14156
+ ["--no-autoscale", "Turn autoscaling off. The only way to: a ceiling at or below --replicas is refused"],
14157
+ ["--db-autoscale-max-cpu <n>", "Let the database grow its CPU on its own under sustained load, up to this, e.g. 2. Unset: off"],
14158
+ ["--db-autoscale-max-memory <size>", "Let it grow its memory under load or connection pressure, up to this, e.g. 8Gi. Unset: off"],
14159
+ ["--no-db-autoscale", "Turn database autoscaling off"]
13304
14160
  ],
13305
14161
  examples: [
13306
14162
  "rebase cloud compute set --cpu 500m --memory 2Gi",
13307
14163
  "rebase cloud compute set --replicas 2 --autoscale-max 6",
13308
- "rebase cloud compute set --db-instances 2 --db-memory 4Gi"
14164
+ "rebase cloud compute set --db-instances 2 --db-memory 4Gi",
14165
+ "rebase cloud compute set --db-autoscale-max-cpu 2 --db-autoscale-max-memory 8Gi"
13309
14166
  ],
13310
14167
  notes: [
13311
14168
  "Run `rebase cloud compute` first — it prints the current dials and the €/month this project is quoted.",
13312
- "Applied immediately: the app rolls its pods and the subscription is prorated from today. A change that restarts the database waits for a maintenance window.",
14169
+ "Applied immediately: the app rolls its pods and the subscription is prorated from today. A change that restarts the database is scheduled for the project's maintenance window, billed from when it is applied; apply it sooner with `rebase cloud compute apply`.",
13313
14170
  "The valid ranges are the target cluster's, not this CLI's — GKE Autopilot bills a 250m/512Mi floor and rewrites a memory:CPU ratio outside 1:1–6.5:1, a Hetzner node has neither constraint. The control plane refuses what it cannot honour and names the field."
13314
14171
  ]
13315
14172
  },
@@ -13444,6 +14301,32 @@ var ACTION_HELP = {
13444
14301
  flags: [],
13445
14302
  examples: ["rebase cloud open"]
13446
14303
  },
14304
+ connect: {
14305
+ command: "cloud connect",
14306
+ usage: "cloud connect <url> [--name <name>] [--org <id>] [--no-wait] | --list | --remove <url-or-id>",
14307
+ summary: "Add a self-hosted Rebase instance to your Rebase account, so the Rebase connector in Claude (https://app.rebase.pro/mcp) reaches it as it reaches your Cloud projects. Prints the two variables the instance needs, offers to write them into ./.env, then waits for the instance to accept the connector once you restart it. Run it once per instance; rerunning it is safe and checks the connection.",
14308
+ flags: [
14309
+ ["--name <name>", "What to call the instance. Default: its hostname"],
14310
+ ["--org <id>", "The organization it belongs to. Default: the active one (`rebase cloud use`)"],
14311
+ ["--no-wait", "Print the variables and return, without waiting for the instance to accept the connector"],
14312
+ ["--list", "List the self-hosted instances in your account"],
14313
+ ["--remove <url-or-id>", "Remove one from your account. Confirms first unless --yes"]
14314
+ ],
14315
+ examples: [
14316
+ "rebase cloud connect your-app.com",
14317
+ "rebase cloud connect https://api.example.com --name \"Shop (EU)\" --org 3f2a9c1e",
14318
+ "rebase cloud connect your-app.com --no-wait --json",
14319
+ "rebase cloud connect --list",
14320
+ "rebase cloud connect --remove your-app.com --yes"
14321
+ ],
14322
+ notes: [
14323
+ "An address without a scheme is https; only the origin is kept, so a path or query is dropped.",
14324
+ "The two variables are REBASE_PLATFORM_TOKEN_KEY and REBASE_PLATFORM_TOKEN_AUDIENCE: what the instance needs to accept the connector's short-lived tokens.",
14325
+ "Adding an instance takes an owner or admin of the organization.",
14326
+ "With --json it prints what the control plane answered and one check of the connection, and never prompts or waits.",
14327
+ "Not `rebase cloud link`, which binds a directory to a project."
14328
+ ]
14329
+ },
13447
14330
  rollback: {
13448
14331
  command: "cloud rollback",
13449
14332
  usage: "cloud rollback [<deploymentId>] [--yes]",
@@ -13589,6 +14472,7 @@ var CLOUD_VALUE_FLAGS = {
13589
14472
  "--access-key-id": String,
13590
14473
  "--action": String,
13591
14474
  "--actor": String,
14475
+ "--allow": String,
13592
14476
  "--autoscale-cpu-target": String,
13593
14477
  "--autoscale-max": String,
13594
14478
  "--backup-access-key-id": String,
@@ -13600,11 +14484,15 @@ var CLOUD_VALUE_FLAGS = {
13600
14484
  "--branch": String,
13601
14485
  "--bucket": String,
13602
14486
  "--bundle-dir": String,
14487
+ "--ca-out": String,
13603
14488
  "--can": String,
13604
14489
  "--collection": String,
13605
14490
  "--connection-string": String,
13606
14491
  "--cpu": String,
14492
+ "--day": String,
13607
14493
  "--db": String,
14494
+ "--db-autoscale-max-cpu": String,
14495
+ "--db-autoscale-max-memory": String,
13608
14496
  "--db-cpu": String,
13609
14497
  "--db-instances": String,
13610
14498
  "--db-memory": String,
@@ -13616,6 +14504,7 @@ var CLOUD_VALUE_FLAGS = {
13616
14504
  "--function": String,
13617
14505
  "--grep": String,
13618
14506
  "--host": String,
14507
+ "--hour": String,
13619
14508
  "--ingress-address": String,
13620
14509
  "--kubeconfig": String,
13621
14510
  "--level": String,
@@ -13636,11 +14525,13 @@ var CLOUD_VALUE_FLAGS = {
13636
14525
  "--pull-key-file": String,
13637
14526
  "--push-service-account": String,
13638
14527
  "--region": String,
14528
+ "--remove": String,
13639
14529
  "--replicas": String,
13640
14530
  "--repo": String,
13641
14531
  "--repository": String,
13642
14532
  "--role": String,
13643
14533
  "--scale-to-zero": String,
14534
+ "--schemas": String,
13644
14535
  "--secret-access-key": String,
13645
14536
  "--since": String,
13646
14537
  "--slug": String,
@@ -13649,6 +14540,7 @@ var CLOUD_VALUE_FLAGS = {
13649
14540
  "--storage": String,
13650
14541
  "--subdomain": String,
13651
14542
  "--tail": String,
14543
+ "--tables": String,
13652
14544
  "--target": String,
13653
14545
  "--timeout": String,
13654
14546
  "--type": String,
@@ -13784,6 +14676,9 @@ async function cloudCommand(subcommand, rawArgs) {
13784
14676
  case "open":
13785
14677
  openCommand(rawArgs);
13786
14678
  break;
14679
+ case "connect":
14680
+ await connectCommand(rawArgs);
14681
+ break;
13787
14682
  case "init":
13788
14683
  await cloudInitCommand(rawArgs);
13789
14684
  break;
@@ -13865,6 +14760,9 @@ async function cloudCommand(subcommand, rawArgs) {
13865
14760
  case "compute":
13866
14761
  await computeCommand(action, rawArgs);
13867
14762
  break;
14763
+ case "events":
14764
+ await eventsCommand(rawArgs);
14765
+ break;
13868
14766
  case "resources":
13869
14767
  if (action === "set") fail("`rebase cloud resources set` is now `rebase cloud compute set` — CPU, memory, replicas and cost.", "`rebase cloud resources` lists what this project declares against what the platform provisioned.", "renamed");
13870
14768
  await declaredResourcesCommand(action, rawArgs);
@@ -13989,6 +14887,12 @@ var CLOUD_GROUPS = [
13989
14887
  section: "Project link",
13990
14888
  description: "Open the console in a browser"
13991
14889
  },
14890
+ {
14891
+ action: "connect",
14892
+ section: "Project link",
14893
+ args: "<url>",
14894
+ description: "Add a self-hosted instance to your account, so the Rebase connector in Claude reaches it"
14895
+ },
13992
14896
  {
13993
14897
  action: "init",
13994
14898
  section: "Projects",
@@ -14149,6 +15053,11 @@ var CLOUD_GROUPS = [
14149
15053
  section: "Other resources",
14150
15054
  description: "What this project reserves, what it costs, and how to change it"
14151
15055
  },
15056
+ {
15057
+ action: "events",
15058
+ section: "Other resources",
15059
+ description: "What happened to the backend: scaling, database changes, failovers"
15060
+ },
14152
15061
  {
14153
15062
  action: "clusters",
14154
15063
  section: "Other resources",
@@ -14184,4 +15093,4 @@ function printCloudHelp() {
14184
15093
  //#endregion
14185
15094
  export { CLOUD_GROUP_NAMES, GROUP_ALIASES, cloudCommand };
14186
15095
 
14187
- //# sourceMappingURL=cloud-nwWkzAHu.js.map
15096
+ //# sourceMappingURL=cloud-CFotGK2-.js.map