@rebasepro/cli 0.33.2 → 0.34.1

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 (149) hide show
  1. package/dist/{agent-setup-Cg_zBWoW.js → agent-setup-kjdKozkF.js} +3 -3
  2. package/dist/{agent-setup-Cg_zBWoW.js.map → agent-setup-kjdKozkF.js.map} +1 -1
  3. package/dist/{api-TbmW33D7.js → api-CQh_qTyQ.js} +2 -2
  4. package/dist/{api-TbmW33D7.js.map → api-CQh_qTyQ.js.map} +1 -1
  5. package/dist/{api-keys-fPQ55DCm.js → api-keys-CG2IpknI.js} +5 -5
  6. package/dist/{api-keys-fPQ55DCm.js.map → api-keys-CG2IpknI.js.map} +1 -1
  7. package/dist/{apps-DBTRoOeP.js → apps-DaaWvv3o.js} +6 -6
  8. package/dist/{apps-DBTRoOeP.js.map → apps-DaaWvv3o.js.map} +1 -1
  9. package/dist/{atlas-dev-database-D6h65f2x.js → atlas-dev-database-BiDMUr9W.js} +2 -2
  10. package/dist/{atlas-dev-database-D6h65f2x.js.map → atlas-dev-database-BiDMUr9W.js.map} +1 -1
  11. package/dist/{auth-BpyYLEFY.js → auth-bi8x2YX1.js} +12 -12
  12. package/dist/{auth-BpyYLEFY.js.map → auth-bi8x2YX1.js.map} +1 -1
  13. package/dist/{auth-session-B6aT0Dyj.js → auth-session-BVoxE5tp.js} +4 -4
  14. package/dist/{auth-session-B6aT0Dyj.js.map → auth-session-BVoxE5tp.js.map} +1 -1
  15. package/dist/{backend-guard-Cf8eMK_f.js → backend-guard--SW3MTSh.js} +2 -2
  16. package/dist/{backend-guard-Cf8eMK_f.js.map → backend-guard--SW3MTSh.js.map} +1 -1
  17. package/dist/{branch-pointer-BJOF2Ubv.js → branch-pointer-BjKUoENm.js} +1 -1
  18. package/dist/{build-E5hfEWKj.js → build-D-0VCmbU.js} +11 -11
  19. package/dist/build-D-0VCmbU.js.map +1 -0
  20. package/dist/{bundle-CIiKGrte.js → bundle-BDTVS9XE.js} +7 -7
  21. package/dist/{bundle-CIiKGrte.js.map → bundle-BDTVS9XE.js.map} +1 -1
  22. package/dist/{cloud-DNJyUU0T.js → cloud-CR6Hps3B.js} +222 -31
  23. package/dist/cloud-CR6Hps3B.js.map +1 -0
  24. package/dist/{cms-directories-BaV-Is9a.js → cms-directories-AGHvFwH7.js} +2 -2
  25. package/dist/{cms-directories-BaV-Is9a.js.map → cms-directories-AGHvFwH7.js.map} +1 -1
  26. package/dist/{command-Bks5xkrQ.js → command-nWgittn1.js} +3 -3
  27. package/dist/{command-Bks5xkrQ.js.map → command-nWgittn1.js.map} +1 -1
  28. package/dist/commands/build.d.ts +2 -1
  29. package/dist/commands/cloud/db-connect.d.ts +31 -1
  30. package/dist/commands/cloud/db-query.d.ts +16 -0
  31. package/dist/commands/cloud/index.d.ts +1 -0
  32. package/dist/commands/cloud/resources.d.ts +19 -1
  33. package/dist/commands/dev.d.ts +15 -0
  34. package/dist/commands/users.d.ts +1 -0
  35. package/dist/{consent-UV6ObCME.js → consent-C8_Ik_GK.js} +3 -3
  36. package/dist/{consent-UV6ObCME.js.map → consent-C8_Ik_GK.js.map} +1 -1
  37. package/dist/{console-BVoYOLAO.js → console-BBGRHOFg.js} +5 -5
  38. package/dist/{console-BVoYOLAO.js.map → console-BBGRHOFg.js.map} +1 -1
  39. package/dist/{context-BOMEoKxn.js → context-C9lz1vTS.js} +6 -2
  40. package/dist/{context-BOMEoKxn.js.map → context-C9lz1vTS.js.map} +1 -1
  41. package/dist/{cron-ZRXsla0v.js → cron-BzzNxkBH.js} +3 -3
  42. package/dist/{cron-ZRXsla0v.js.map → cron-BzzNxkBH.js.map} +1 -1
  43. package/dist/{cron-CpUsQ739.js → cron-DuZ3Svjq.js} +4 -4
  44. package/dist/{cron-CpUsQ739.js.map → cron-DuZ3Svjq.js.map} +1 -1
  45. package/dist/{daemon-D5gdG7gx.js → daemon-BCBMn8hE.js} +2 -2
  46. package/dist/{daemon-D5gdG7gx.js.map → daemon-BCBMn8hE.js.map} +1 -1
  47. package/dist/{data-BJ9AZFUC.js → data-1eipHbxJ.js} +3 -3
  48. package/dist/{data-BJ9AZFUC.js.map → data-1eipHbxJ.js.map} +1 -1
  49. package/dist/{db-D_iF4E-v.js → db-DAotpOxs.js} +28 -28
  50. package/dist/{db-D_iF4E-v.js.map → db-DAotpOxs.js.map} +1 -1
  51. package/dist/{debug-nNbbxAeo.js → debug-CkiOcfsU.js} +2 -2
  52. package/dist/{debug-nNbbxAeo.js.map → debug-CkiOcfsU.js.map} +1 -1
  53. package/dist/{derive-Mky_u59_.js → derive-BU5kvcOP.js} +3 -3
  54. package/dist/{derive-Mky_u59_.js.map → derive-BU5kvcOP.js.map} +1 -1
  55. package/dist/{dev-bj6dEeSQ.js → dev-Ce9PVQS8.js} +34 -13
  56. package/dist/dev-Ce9PVQS8.js.map +1 -0
  57. package/dist/{dev-preflight-BMOf2N6r.js → dev-preflight-DROlafgr.js} +2 -2
  58. package/dist/{dev-preflight-BMOf2N6r.js.map → dev-preflight-DROlafgr.js.map} +1 -1
  59. package/dist/{dev-server-2XHSHM_q.js → dev-server-dsabI0UT.js} +2 -2
  60. package/dist/{dev-server-2XHSHM_q.js.map → dev-server-dsabI0UT.js.map} +1 -1
  61. package/dist/{doctor-FaBObSlb.js → doctor-Cdu3Llrw.js} +8 -8
  62. package/dist/{doctor-FaBObSlb.js.map → doctor-Cdu3Llrw.js.map} +1 -1
  63. package/dist/{eject-DK_M9kor.js → eject-Dy-qRYhW.js} +3 -3
  64. package/dist/{eject-DK_M9kor.js.map → eject-Dy-qRYhW.js.map} +1 -1
  65. package/dist/{fold-static-2t3UUX4z.js → fold-static-DzV3EJZm.js} +4 -4
  66. package/dist/{fold-static-2t3UUX4z.js.map → fold-static-DzV3EJZm.js.map} +1 -1
  67. package/dist/{function-portability-BIvlvR9q.js → function-portability-Dppl6uqg.js} +24 -5
  68. package/dist/{function-portability-BIvlvR9q.js.map → function-portability-Dppl6uqg.js.map} +1 -1
  69. package/dist/function-portability.d.ts +9 -0
  70. package/dist/{functions-B4JR6EZL.js → functions-BCEJnISw.js} +4 -4
  71. package/dist/{functions-B4JR6EZL.js.map → functions-BCEJnISw.js.map} +1 -1
  72. package/dist/{generate-view-BMaLQm8H.js → generate-view-CZ0SmsJc.js} +4 -4
  73. package/dist/{generate-view-BMaLQm8H.js.map → generate-view-CZ0SmsJc.js.map} +1 -1
  74. package/dist/{generate_sdk-ByD-gTsK.js → generate_sdk-MAbUUZoK.js} +6 -6
  75. package/dist/{generate_sdk-ByD-gTsK.js.map → generate_sdk-MAbUUZoK.js.map} +1 -1
  76. package/dist/index.es.js +54 -54
  77. package/dist/{init-DHCe5mJ5.js → init-BctfWO3w.js} +44 -24
  78. package/dist/init-BctfWO3w.js.map +1 -0
  79. package/dist/last-dev-database-w-r9T5Xm.js +2 -0
  80. package/dist/{legacy-layout-DI2VeQSV.js → legacy-layout-CiXWalS6.js} +2 -2
  81. package/dist/{legacy-layout-DI2VeQSV.js.map → legacy-layout-CiXWalS6.js.map} +1 -1
  82. package/dist/{logs-DpuMukJe.js → logs-B_mS4gCn.js} +4 -4
  83. package/dist/{logs-DpuMukJe.js.map → logs-B_mS4gCn.js.map} +1 -1
  84. package/dist/{manifest-RjqxfCpb.js → manifest-D6B4LA8x.js} +3 -3
  85. package/dist/{manifest-RjqxfCpb.js.map → manifest-D6B4LA8x.js.map} +1 -1
  86. package/dist/{migrate-CSY9ZDKy.js → migrate-DdcgLMyL.js} +3 -3
  87. package/dist/{migrate-CSY9ZDKy.js.map → migrate-DdcgLMyL.js.map} +1 -1
  88. package/dist/{normalize-imports-P86NVfpo.js → normalize-imports-CVjOssZ2.js} +2 -2
  89. package/dist/{normalize-imports-P86NVfpo.js.map → normalize-imports-CVjOssZ2.js.map} +1 -1
  90. package/dist/{package-manager-DSEOwTqM.js → package-manager-DTNNGHyK.js} +29 -12
  91. package/dist/package-manager-DTNNGHyK.js.map +1 -0
  92. package/dist/{path-flags-ekLdkbra.js → path-flags-B7Ydt5nv.js} +2 -2
  93. package/dist/{path-flags-ekLdkbra.js.map → path-flags-B7Ydt5nv.js.map} +1 -1
  94. package/dist/{prepare-BaJe0Zik.js → prepare-CFpYl1Nt.js} +4 -4
  95. package/dist/{prepare-BaJe0Zik.js.map → prepare-CFpYl1Nt.js.map} +1 -1
  96. package/dist/{project-DALmhb5R.js → project-CQ5nKddJ.js} +2 -2
  97. package/dist/{project-DALmhb5R.js.map → project-CQ5nKddJ.js.map} +1 -1
  98. package/dist/{project-command-Cl9EZzjr.js → project-command-5wM_bJQt.js} +7 -7
  99. package/dist/{project-command-Cl9EZzjr.js.map → project-command-5wM_bJQt.js.map} +1 -1
  100. package/dist/resolve-GDRel2ne.js +2 -0
  101. package/dist/{resources-Db3USuPO.js → resources-ecA0MEjy.js} +4 -4
  102. package/dist/{resources-Db3USuPO.js.map → resources-ecA0MEjy.js.map} +1 -1
  103. package/dist/{rls-BxrQ0P50.js → rls-B4zGbTKY.js} +3 -3
  104. package/dist/{rls-BxrQ0P50.js.map → rls-B4zGbTKY.js.map} +1 -1
  105. package/dist/{schema-_FzZEoB8.js → schema-CWzzn0cY.js} +13 -12
  106. package/dist/{schema-_FzZEoB8.js.map → schema-CWzzn0cY.js.map} +1 -1
  107. package/dist/{schema-dir-ChcYfWjP.js → schema-dir-Dd1Pzqq5.js} +2 -2
  108. package/dist/{schema-dir-ChcYfWjP.js.map → schema-dir-Dd1Pzqq5.js.map} +1 -1
  109. package/dist/schema-reconcile-DGEMmYJI.js +2 -0
  110. package/dist/{schema-show-h72UJ9zH.js → schema-show-DwYtOp4S.js} +5 -5
  111. package/dist/{schema-show-h72UJ9zH.js.map → schema-show-DwYtOp4S.js.map} +1 -1
  112. package/dist/{skills-DQ2bZGkj.js → skills-CWmBTCRW.js} +6 -6
  113. package/dist/{skills-DQ2bZGkj.js.map → skills-CWmBTCRW.js.map} +1 -1
  114. package/dist/{start-Cjx4W0bJ.js → start-4uhCu_md.js} +6 -6
  115. package/dist/{start-Cjx4W0bJ.js.map → start-4uhCu_md.js.map} +1 -1
  116. package/dist/{status-CDBk25VO.js → status-CVEzoSwX.js} +7 -7
  117. package/dist/{status-CDBk25VO.js.map → status-CVEzoSwX.js.map} +1 -1
  118. package/dist/{storage-Clc8dLG8.js → storage-Dqf5tyhs.js} +9 -9
  119. package/dist/{storage-Clc8dLG8.js.map → storage-Dqf5tyhs.js.map} +1 -1
  120. package/dist/{storage-objects-CfRKlTDe.js → storage-objects-DbFsemMV.js} +3 -3
  121. package/dist/{storage-objects-CfRKlTDe.js.map → storage-objects-DbFsemMV.js.map} +1 -1
  122. package/dist/{telemetry-DZU2-NCm.js → telemetry-B5RSeQIc.js} +3 -3
  123. package/dist/{telemetry-DZU2-NCm.js.map → telemetry-B5RSeQIc.js.map} +1 -1
  124. package/dist/{telemetry-EVtASbKb.js → telemetry-CJbrRuG3.js} +2 -2
  125. package/dist/{telemetry-EVtASbKb.js.map → telemetry-CJbrRuG3.js.map} +1 -1
  126. package/dist/{upgrade-ZASvgxWM.js → upgrade-CepjhRrz.js} +6 -6
  127. package/dist/{upgrade-ZASvgxWM.js.map → upgrade-CepjhRrz.js.map} +1 -1
  128. package/dist/{users-5PkqBY6R.js → users-Cx5HuaTn.js} +9 -6
  129. package/dist/users-Cx5HuaTn.js.map +1 -0
  130. package/dist/utils/package-manager.d.ts +12 -13
  131. package/dist/{verify-BdeqNb-V.js → verify-D-1y5HQS.js} +8 -8
  132. package/dist/{verify-BdeqNb-V.js.map → verify-D-1y5HQS.js.map} +1 -1
  133. package/package.json +10 -10
  134. package/templates/template/.cursorrules +2 -1
  135. package/templates/template/.github/copilot-instructions.md +2 -1
  136. package/templates/template/.windsurfrules +2 -1
  137. package/templates/template/AGENTS.md +2 -1
  138. package/templates/template/CLAUDE.md +2 -1
  139. package/templates/template/ai-instructions.md +5 -2
  140. package/templates/template/frontend/src/index.css +13 -0
  141. package/dist/build-E5hfEWKj.js.map +0 -1
  142. package/dist/cloud-DNJyUU0T.js.map +0 -1
  143. package/dist/dev-bj6dEeSQ.js.map +0 -1
  144. package/dist/init-DHCe5mJ5.js.map +0 -1
  145. package/dist/last-dev-database-CBVkEUEl.js +0 -2
  146. package/dist/package-manager-DSEOwTqM.js.map +0 -1
  147. package/dist/resolve-C36px9tR.js +0 -2
  148. package/dist/schema-reconcile-DV14XY4o.js +0 -2
  149. package/dist/users-5PkqBY6R.js.map +0 -1
@@ -1,16 +1,16 @@
1
- import { i as recordEvent, l as durationBucket } from "./telemetry-EVtASbKb.js";
1
+ import { i as recordEvent, l as durationBucket } from "./telemetry-CJbrRuG3.js";
2
2
  import { i as switchOn } from "./args-DHyrshtI.js";
3
- import { c as findProjectRoot, p as requireProjectRoot } from "./project-DALmhb5R.js";
4
- import { C as resolveBackendPaths, _ as findBackendApp, b as loadManifest, h as cmsMountOf, w as selectDeployApp, y as formatAppAddress } from "./manifest-RjqxfCpb.js";
3
+ import { c as findProjectRoot, p as requireProjectRoot } from "./project-CQ5nKddJ.js";
4
+ import { C as resolveBackendPaths, _ as findBackendApp, b as loadManifest, h as cmsMountOf, w as selectDeployApp, y as formatAppAddress } from "./manifest-D6B4LA8x.js";
5
5
  import { t as cliUserAgent } from "./version-ONIeo7jl.js";
6
- import { E as toolStdio, c as buildBundle, r as UNVENDORED_COST, w as unvendoredReason } from "./bundle-CIiKGrte.js";
7
- import { $ as resolveCloudTarget, A as linkedEphemeralGrant, B as projectHost, C as getContextOrg, D as isJsonMode, E as initOutputMode, F as parseCloudArgs, G as reportError, H as readLink, I as printGroupHelp, J as requireInteractive, K as requireClient, L as printJson, M as note, N as noteBlank, O as isKnownControlPlane, P as openUrl, Q as requireSessionClient, R as probeToken, S as freshAccessToken, T as grantProjectOf, U as refuseDirectLink, V as projectLinkPath, W as removeLink, X as requireProject, Y as requireKnownAction, Z as requireProjectRef, _ as ephemeralGrantFor, _t as isTokenCapability, a as billingAccountIdOf, at as setCurrentContext, b as fetchTenantBaseDomain, bt as scopesForOrgCapabilities, c as colorStatus, ct as warn, d as createCloudClient, dt as ORG_CAPABILITIES, et as resolveCloudUrl, f as displayProjectRef, ft as ORG_CAPABILITY_NAMES, g as envToken, gt as isOrgCapability, h as emitHelp, ht as capabilitiesInScopes, i as appKeyExpiryNote, it as setContextOrg, j as lookupProjectId, k as keyValues, l as confirmDestructive, lt as writeLink, m as emit, mt as TOKEN_CAPABILITY_NAMES, n as GLOBAL_HELP_FLAGS, nt as resolveTimeoutMs, o as cloudRow, ot as storedGrantForLink, p as dotenvSets, pt as TOKEN_CAPABILITIES, q as requireCloudRow, r as TOKEN_ENV, rt as saveEphemeralGrant, s as cloudRows, st as success, t as GLOBAL_CLOUD_FLAGS, tt as resolveProjectRef, ut as ALWAYS_SCOPES, v as fail, vt as orgCapabilitiesInScopes, w as grantForLink, x as forgetEphemeralGrant, xt as wantsRawError, y as fetchDeployTargets, yt as scopesForCapabilities, z as projectDotenvSetsAppKey } from "./context-BOMEoKxn.js";
8
- import { n as foldFrontendIntoBundle, r as foldableApps } from "./fold-static-2t3UUX4z.js";
9
- import { n as legacyCollectionsDir, r as legacyLayoutRefusal, t as MIGRATE_COMMAND } from "./legacy-layout-DI2VeQSV.js";
10
- import { n as deriveOptionsFor, r as deriveResourceGraph } from "./derive-Mky_u59_.js";
11
- import { t as buildAssetApp } from "./build-E5hfEWKj.js";
12
- import { a as parseLogLine, c as resolveOrigin, i as isErrorLine, l as resolveTail, n as debugCommand, o as parseSince, s as printDebugHelp, t as SERVER_MAX_TAIL_LINES } from "./debug-nNbbxAeo.js";
13
- import { cronCommand, isMissingRoute } from "./cron-ZRXsla0v.js";
6
+ import { E as toolStdio, c as buildBundle, r as UNVENDORED_COST, w as unvendoredReason } from "./bundle-BDTVS9XE.js";
7
+ import { $ as resolveCloudTarget, A as linkedEphemeralGrant, B as projectHost, C as getContextOrg, D as isJsonMode, E as initOutputMode, F as parseCloudArgs, G as reportError, H as readLink, I as printGroupHelp, J as requireInteractive, K as requireClient, L as printJson, M as note, N as noteBlank, O as isKnownControlPlane, P as openUrl, Q as requireSessionClient, R as probeToken, S as freshAccessToken, T as grantProjectOf, U as refuseDirectLink, V as projectLinkPath, W as removeLink, X as requireProject, Y as requireKnownAction, Z as requireProjectRef, _ as ephemeralGrantFor, _t as isTokenCapability, a as billingAccountIdOf, at as setCurrentContext, b as fetchTenantBaseDomain, bt as scopesForOrgCapabilities, c as colorStatus, ct as warn, d as createCloudClient, dt as ORG_CAPABILITIES, et as resolveCloudUrl, f as displayProjectRef, ft as ORG_CAPABILITY_NAMES, g as envToken, gt as isOrgCapability, h as emitHelp, ht as capabilitiesInScopes, i as appKeyExpiryNote, it as setContextOrg, j as lookupProjectId, k as keyValues, l as confirmDestructive, lt as writeLink, m as emit, mt as TOKEN_CAPABILITY_NAMES, n as GLOBAL_HELP_FLAGS, nt as resolveTimeoutMs, o as cloudRow, ot as storedGrantForLink, p as dotenvSets, pt as TOKEN_CAPABILITIES, q as requireCloudRow, r as TOKEN_ENV, rt as saveEphemeralGrant, s as cloudRows, st as success, t as GLOBAL_CLOUD_FLAGS, tt as resolveProjectRef, ut as ALWAYS_SCOPES, v as fail, vt as orgCapabilitiesInScopes, w as grantForLink, x as forgetEphemeralGrant, xt as wantsRawError, y as fetchDeployTargets, yt as scopesForCapabilities, z as projectDotenvSetsAppKey } from "./context-C9lz1vTS.js";
8
+ import { n as foldFrontendIntoBundle, r as foldableApps } from "./fold-static-DzV3EJZm.js";
9
+ import { n as legacyCollectionsDir, r as legacyLayoutRefusal, t as MIGRATE_COMMAND } from "./legacy-layout-CiXWalS6.js";
10
+ import { n as deriveOptionsFor, r as deriveResourceGraph } from "./derive-BU5kvcOP.js";
11
+ import { t as buildAssetApp } from "./build-D-0VCmbU.js";
12
+ import { a as parseLogLine, c as resolveOrigin, i as isErrorLine, l as resolveTail, n as debugCommand, o as parseSince, s as printDebugHelp, t as SERVER_MAX_TAIL_LINES } from "./debug-CkiOcfsU.js";
13
+ import { cronCommand, isMissingRoute } from "./cron-BzzNxkBH.js";
14
14
  import chalk from "chalk";
15
15
  import arg from "arg";
16
16
  import fs from "fs";
@@ -354,7 +354,7 @@ function readMfaRequired(error) {
354
354
  * once per login: it says both whether codes are mailed and whether device
355
355
  * sign-in is offered.
356
356
  */
357
- async function readAuthConfig(auth) {
357
+ async function readAuthConfig$1(auth) {
358
358
  try {
359
359
  return await auth.getAuthConfig();
360
360
  } catch {
@@ -877,7 +877,7 @@ async function loginCommand(rawArgs) {
877
877
  if (method === "code") requireTerminalForCode();
878
878
  const client = createCloudClient(url);
879
879
  let authConfig;
880
- const config = async () => authConfig === void 0 ? authConfig = await readAuthConfig(client.auth) : authConfig;
880
+ const config = async () => authConfig === void 0 ? authConfig = await readAuthConfig$1(client.auth) : authConfig;
881
881
  if (method === void 0 && !args["--email"] && offersBrowserSignIn(await config())) method = "browser";
882
882
  let email = (args["--email"] || envEmail).trim();
883
883
  let password = args["--password"] || envPassword;
@@ -1546,6 +1546,27 @@ var IN_FLIGHT = /* @__PURE__ */ new Set([
1546
1546
  function bootFailed(logs) {
1547
1547
  return typeof logs === "string" && /did not become ready within/i.test(logs);
1548
1548
  }
1549
+ /**
1550
+ * The live app's public `GET /api/auth/config`, or `undefined` when it does
1551
+ * not answer in time or is not a Rebase backend. Read by `status` for the
1552
+ * sign-in methods the app switched on and cannot offer (`unavailable`).
1553
+ */
1554
+ async function readAuthConfig(appUrl, fetchImpl = fetch) {
1555
+ const origin = /^https?:\/\//.test(appUrl) ? appUrl : `https://${appUrl}`;
1556
+ try {
1557
+ const res = await fetchImpl(`${origin.replace(/\/+$/, "")}/api/auth/config`, {
1558
+ headers: { Accept: "application/json" },
1559
+ signal: AbortSignal.timeout(4e3)
1560
+ });
1561
+ if (!res.ok) return void 0;
1562
+ const body = await res.json();
1563
+ if (typeof body !== "object" || body === null) return void 0;
1564
+ const unavailable = body.unavailable;
1565
+ return typeof unavailable === "object" && unavailable !== null ? { unavailable } : {};
1566
+ } catch {
1567
+ return;
1568
+ }
1569
+ }
1549
1570
  function resolveBlockedState(input) {
1550
1571
  if (!input.database && input.lastDeploy?.status !== "success") return {
1551
1572
  blockedOn: "no_database",
@@ -1567,6 +1588,11 @@ function resolveBlockedState(input) {
1567
1588
  blockedOn: "database_unreachable",
1568
1589
  nextAction: "rebase cloud db test"
1569
1590
  };
1591
+ const unavailable = input.authConfig?.unavailable;
1592
+ if (unavailable?.magicLink === "EMAIL_NOT_CONFIGURED" || unavailable?.emailOtp === "EMAIL_NOT_CONFIGURED") return {
1593
+ blockedOn: "email_not_configured",
1594
+ nextAction: "rebase cloud env set SMTP_HOST <host> (and SMTP_PORT, SMTP_USER, SMTP_PASS, SMTP_FROM), then rebase cloud deploy"
1595
+ };
1570
1596
  return {
1571
1597
  blockedOn: null,
1572
1598
  nextAction: null
@@ -1624,10 +1650,12 @@ async function statusCommand(rawArgs) {
1624
1650
  const link = readLink();
1625
1651
  const grant = link?.projectId === projectId ? grantForLink(link) : void 0;
1626
1652
  const appKeyNote = grant && projectDotenvSetsAppKey() ? appKeyExpiryNote(grant.expiresAt) : void 0;
1653
+ const appUrl = projectHost(project, baseDomain);
1627
1654
  const blocked = resolveBlockedState({
1628
1655
  projectStatus: project.status,
1629
1656
  database: db,
1630
- lastDeploy: deploy
1657
+ lastDeploy: deploy,
1658
+ authConfig: deploy?.status === "success" && appUrl ? await readAuthConfig(appUrl) : void 0
1631
1659
  });
1632
1660
  emit(() => {
1633
1661
  console.log("");
@@ -1752,7 +1780,17 @@ var METRICS_FLAGS = {
1752
1780
  var HISTORY_SERIES = [
1753
1781
  "cpu_millicores",
1754
1782
  "memory_bytes",
1755
- "event_loop_delay_ms"
1783
+ "event_loop_delay_ms",
1784
+ "requests_data",
1785
+ "errors_data",
1786
+ "requests_auth",
1787
+ "errors_auth",
1788
+ "requests_storage",
1789
+ "errors_storage",
1790
+ "requests_functions",
1791
+ "errors_functions",
1792
+ "requests_app",
1793
+ "errors_app"
1756
1794
  ];
1757
1795
  /** The longest window the runtime keeps: fourteen days, in minutes. */
1758
1796
  var HISTORY_MAX_MINUTES = 20160;
@@ -1777,6 +1815,8 @@ function resolveHistoryArgs(flags) {
1777
1815
  function historyValue(series, value) {
1778
1816
  if (series === "memory_bytes") return `${(value / 1024 / 1024).toFixed(0)} MiB`;
1779
1817
  if (series === "cpu_millicores") return `${Math.round(value)}m`;
1818
+ if (series.startsWith("requests_")) return `${Math.round(value)} requests`;
1819
+ if (series.startsWith("errors_")) return `${Math.round(value)} errors`;
1780
1820
  return `${value.toFixed(1)} ms`;
1781
1821
  }
1782
1822
  async function metricsCommand(rawArgs) {
@@ -3202,17 +3242,13 @@ function localDsn(opts) {
3202
3242
  const database = opts.database ?? "rebase";
3203
3243
  return `postgresql://${auth}@127.0.0.1:${opts.port}/${database}`;
3204
3244
  }
3205
- async function dbConnect(rawArgs) {
3206
- const { flags: args } = parseCloudArgs({
3207
- spec: DB_CONNECT_FLAGS,
3208
- rawArgs,
3209
- commandWords: 3,
3210
- command: "cloud db connect",
3211
- maxPositionals: 0
3212
- });
3213
- const { client, url } = await requireClient(rawArgs);
3214
- const projectId = await requireProject(rawArgs, client);
3215
- const projectRef = displayProjectRef(rawArgs);
3245
+ /**
3246
+ * What a tunnel needs from the control plane: the database's name and user,
3247
+ * and its password when `reveal` asks for it (owner or admin only, as the
3248
+ * console's SQL console). Refuses, by `fail`, a project with nothing to tunnel.
3249
+ * Shared by `db connect` and `db query`.
3250
+ */
3251
+ async function loadTunnelAccess(client, projectId, reveal) {
3216
3252
  let info;
3217
3253
  try {
3218
3254
  info = await client.functions.invoke("db-info", void 0, {
@@ -3225,7 +3261,7 @@ async function dbConnect(rawArgs) {
3225
3261
  if (info.type === "byodb") fail("This project uses your own database.", "Connect to it directly — there is nothing for the platform to tunnel.", "byodb");
3226
3262
  if (!info.directAccess) fail("The platform could not resolve this project's database, so it cannot open a path to it.", info.unavailableReason ?? "A managed database is provisioned at the project's first deploy; before then there is nothing to connect to.", "db_unavailable");
3227
3263
  let password;
3228
- if (args["--reveal"]) {
3264
+ if (reveal) {
3229
3265
  if (!info.passwordAvailable) fail("No password is available to reveal for this database.", info.unavailableReason ?? void 0, "password_unavailable");
3230
3266
  try {
3231
3267
  password = (await client.functions.invoke("db-info", { projectId }, { path: "reveal" })).password;
@@ -3233,6 +3269,23 @@ async function dbConnect(rawArgs) {
3233
3269
  return reportError(e, "Failed to reveal the database password");
3234
3270
  }
3235
3271
  }
3272
+ return {
3273
+ info,
3274
+ password
3275
+ };
3276
+ }
3277
+ async function dbConnect(rawArgs) {
3278
+ const { flags: args } = parseCloudArgs({
3279
+ spec: DB_CONNECT_FLAGS,
3280
+ rawArgs,
3281
+ commandWords: 3,
3282
+ command: "cloud db connect",
3283
+ maxPositionals: 0
3284
+ });
3285
+ const { client, url } = await requireClient(rawArgs);
3286
+ const projectId = await requireProject(rawArgs, client);
3287
+ const projectRef = displayProjectRef(rawArgs);
3288
+ const { info, password } = await loadTunnelAccess(client, projectId, args["--reveal"] === true);
3236
3289
  const requested = args["--port"] ?? DEFAULT_LOCAL_PORT;
3237
3290
  if (!Number.isInteger(requested) || requested < 0 || requested > 65535) fail(`--port must be a port number, not ${requested}.`, void 0, "bad_port");
3238
3291
  const server = tunnelListener(client, tunnelUrl(url, projectId));
@@ -3382,6 +3435,107 @@ function pipeThroughTunnel(socket, endpoint, token) {
3382
3435
  socket.on("error", () => closeBoth());
3383
3436
  }
3384
3437
  //#endregion
3438
+ //#region src/commands/cloud/db-query.ts
3439
+ /**
3440
+ * `rebase cloud db query` — run SQL on the project's managed database, from
3441
+ * here, with nothing installed but the CLI.
3442
+ *
3443
+ * Applying a SQL file to a Cloud database used to take `rebase cloud db
3444
+ * connect --reveal --json` held open in the background and a local `psql`
3445
+ * pointed at the URL it printed. This opens the same tunnel on an ephemeral
3446
+ * port for the length of one query, connects with the CLI's own Postgres
3447
+ * driver, runs the text, and closes both.
3448
+ *
3449
+ * The text goes over the simple query protocol, so a file of several
3450
+ * statements (functions, triggers, `DO` blocks) runs as one script and stops at
3451
+ * the first error, the way `psql -v ON_ERROR_STOP=1 -f` does. `COPY … FROM
3452
+ * STDIN` is not supported: it needs a client-side stream (`psql`'s `\copy`).
3453
+ *
3454
+ * The gate is the control plane's: revealing the password needs the
3455
+ * organization's owner or admin role, the same as the console's SQL console.
3456
+ */
3457
+ /** Documented in `action-help.ts`, and paired with it by `action-help.test.ts`. */
3458
+ var DB_QUERY_FLAGS = { "--file": String };
3459
+ /** The most rows of a result printed as a table; the JSON form carries them all. */
3460
+ var MAX_TABLE_ROWS = 200;
3461
+ /** The SQL to run: the file, or the one positional. Exactly one of them. */
3462
+ function querySql(file, positional, read = (p) => fs$1.readFileSync(p, "utf-8")) {
3463
+ if (file !== void 0 && positional !== void 0) fail("Give the SQL as an argument or with --file, not both.", "rebase cloud db query --file schema-extras.sql", "usage");
3464
+ if (file === void 0 && positional === void 0) fail("rebase cloud db query needs SQL: rebase cloud db query \"select 1\", or --file <path>.", void 0, "usage");
3465
+ let sql;
3466
+ if (file !== void 0) try {
3467
+ sql = read(file);
3468
+ } catch (e) {
3469
+ fail(`Could not read ${file}: ${e instanceof Error ? e.message : String(e)}`, void 0, "file_unreadable");
3470
+ }
3471
+ else sql = positional;
3472
+ if (!sql.trim()) fail("The SQL is empty.", void 0, "usage");
3473
+ if (/^\s*\\copy\b|\bfrom\s+stdin\b/im.test(sql)) fail("`COPY … FROM STDIN` needs a client-side stream, which this command does not open.", "Load rows with INSERT statements, or use `rebase cloud db connect` and psql's \\copy.", "copy_from_stdin");
3474
+ return sql;
3475
+ }
3476
+ /** `pg` answers one result for one statement and an array for several. */
3477
+ function summarizeResults(result) {
3478
+ return (Array.isArray(result) ? result : [result]).map((r) => ({
3479
+ command: r.command ?? null,
3480
+ rowCount: r.rowCount ?? null,
3481
+ rows: r.rows
3482
+ }));
3483
+ }
3484
+ async function dbQuery(rawArgs) {
3485
+ const { flags, positionals } = parseCloudArgs({
3486
+ spec: DB_QUERY_FLAGS,
3487
+ rawArgs,
3488
+ commandWords: 3,
3489
+ command: "cloud db query",
3490
+ maxPositionals: 1
3491
+ });
3492
+ const sql = querySql(flags["--file"], positionals[0]);
3493
+ const { client, url } = await requireClient(rawArgs);
3494
+ const projectId = await requireProject(rawArgs, client);
3495
+ const projectRef = displayProjectRef(rawArgs);
3496
+ const { info, password } = await loadTunnelAccess(client, projectId, true);
3497
+ const server = tunnelListener(client, tunnelUrl(url, projectId));
3498
+ await new Promise((resolve, reject) => {
3499
+ server.once("error", reject);
3500
+ server.listen(0, "127.0.0.1", () => resolve());
3501
+ });
3502
+ const port = server.address().port;
3503
+ const { Client } = await import("pg");
3504
+ const db = new Client({ connectionString: localDsn({
3505
+ port,
3506
+ username: info.username,
3507
+ database: info.database,
3508
+ password
3509
+ }) });
3510
+ let summaries;
3511
+ try {
3512
+ await db.connect();
3513
+ summaries = summarizeResults(await db.query(sql));
3514
+ } catch (e) {
3515
+ const err = e;
3516
+ fail(`The database refused the SQL${err.code ? ` (SQLSTATE ${err.code})` : ""}: ${err.message ?? String(e)}`, [err.detail, err.hint].filter(Boolean).join(" ") || "Statements before the failing one have run unless the script wraps itself in BEGIN/COMMIT.", "query_failed");
3517
+ } finally {
3518
+ await db.end().catch(() => {});
3519
+ server.close();
3520
+ }
3521
+ emit(() => {
3522
+ console.log("");
3523
+ console.log(chalk.bold(` 🗄 SQL on project ${projectRef}`));
3524
+ for (const s of summaries) {
3525
+ console.log("");
3526
+ console.log(` ${chalk.green(s.command ?? "OK")}${s.rowCount !== null ? chalk.gray(` ${s.rowCount}`) : ""}`);
3527
+ if (s.rows.length > 0) {
3528
+ console.table(s.rows.slice(0, MAX_TABLE_ROWS));
3529
+ if (s.rows.length > MAX_TABLE_ROWS) console.log(chalk.gray(` … ${s.rows.length - MAX_TABLE_ROWS} more rows (--json prints them all)`));
3530
+ }
3531
+ }
3532
+ console.log("");
3533
+ }, {
3534
+ projectId,
3535
+ results: summaries
3536
+ });
3537
+ }
3538
+ //#endregion
3385
3539
  //#region src/commands/cloud/db-access.ts
3386
3540
  /**
3387
3541
  * `rebase cloud db access` — read-only access to the managed database from
@@ -3574,6 +3728,9 @@ async function dbCommand(subcommand, rawArgs) {
3574
3728
  case "connect":
3575
3729
  await dbConnect(rawArgs);
3576
3730
  break;
3731
+ case "query":
3732
+ await dbQuery(rawArgs);
3733
+ break;
3577
3734
  case "access":
3578
3735
  await dbAccessCommand(rawArgs);
3579
3736
  break;
@@ -4173,6 +4330,13 @@ function printDbHelp() {
4173
4330
  description: "Open a local port that IS the project's database",
4174
4331
  flags: [["--port <n>", "Local port to listen on. Default: 5432"], ["--reveal", "Print the password in the connection URL"]]
4175
4332
  },
4333
+ {
4334
+ action: "query",
4335
+ section: "Database",
4336
+ args: "[sql]",
4337
+ description: "Run SQL on the project's database (owner or admin), with no local psql",
4338
+ flags: [["--file <path>", "Run the statements in a file, stopping at the first error"]]
4339
+ },
4176
4340
  {
4177
4341
  action: "test",
4178
4342
  section: "Database",
@@ -8749,6 +8913,12 @@ async function reportDeployed(o) {
8749
8913
  }
8750
8914
  const verdict = liveVerdict(live, o.liveTimeoutMs);
8751
8915
  const elapsedMs = Date.now() - o.startedAt;
8916
+ const blocked = verdict.live === true && host ? resolveBlockedState({
8917
+ database: {},
8918
+ lastDeploy: { status: "success" },
8919
+ authConfig: await readAuthConfig(host)
8920
+ }) : void 0;
8921
+ const blockedOn = blocked?.blockedOn ? blocked : void 0;
8752
8922
  emit(() => {
8753
8923
  const lines = deploySummaryLines({
8754
8924
  projectRef: o.projectRef,
@@ -8759,6 +8929,7 @@ async function reportDeployed(o) {
8759
8929
  liveTimeoutMs: o.liveTimeoutMs
8760
8930
  });
8761
8931
  if (o.undo) lines.splice(lines.length - 1, 0, chalk.gray(` ${o.undo}`));
8932
+ if (blockedOn) lines.splice(lines.length - 1, 0, chalk.yellow(` ⚠ Live, but nobody can sign in: magic-link sign-in is on and the app has no email service (${blockedOn.blockedOn}).`), chalk.gray(` ${blockedOn.nextAction}`));
8762
8933
  for (const line of lines) console.log(line);
8763
8934
  printPendingHosts(hosts);
8764
8935
  }, {
@@ -8768,7 +8939,9 @@ async function reportDeployed(o) {
8768
8939
  ...hostsField(hosts, o.registeredHosts),
8769
8940
  durationMs: elapsedMs,
8770
8941
  live: verdict.live,
8771
- liveChecks: live ?? []
8942
+ liveChecks: live ?? [],
8943
+ blockedOn: blockedOn?.blockedOn ?? null,
8944
+ nextAction: blockedOn?.nextAction ?? null
8772
8945
  });
8773
8946
  }
8774
8947
  /**
@@ -13855,6 +14028,23 @@ var ACTION_HELP = {
13855
14028
  "A project has exactly one database — attaching a second is refused, because the platform reads one row and it becomes undefined which it deploys against."
13856
14029
  ]
13857
14030
  },
14031
+ "db query": {
14032
+ command: "cloud db query",
14033
+ usage: "cloud db query [sql] [--file <path>]",
14034
+ summary: "Run SQL on the project's managed database and print what it answered. It opens the tunnel `db connect` opens, for the length of one query, and connects with the CLI's own Postgres driver, so nothing else needs to be installed. A file of several statements (functions, triggers, DO blocks) runs as one script and stops at the first error.",
14035
+ flags: [["--file <path>", "Run the statements in a file instead of the argument"]],
14036
+ examples: [
14037
+ "rebase cloud db query \"select count(*) from rebase.users\"",
14038
+ "rebase cloud db query --file sql/extras.sql --project shop",
14039
+ "rebase cloud db query \"select * from orders limit 5\" --json"
14040
+ ],
14041
+ notes: [
14042
+ "Requires the organization's owner or admin role, as `db connect --reveal` does.",
14043
+ "No transaction is added: wrap the file in BEGIN/COMMIT to make it all-or-nothing.",
14044
+ "`COPY … FROM STDIN` (psql's \\copy) is refused; it needs a client-side stream.",
14045
+ "With --json it prints `{ projectId, results: [{ command, rowCount, rows }] }`, one entry per statement."
14046
+ ]
14047
+ },
13858
14048
  "db connect": {
13859
14049
  command: "cloud db connect",
13860
14050
  usage: "cloud db connect [--port <n>] [--reveal]",
@@ -14709,7 +14899,7 @@ var ACTION_HELP = {
14709
14899
  flags: [
14710
14900
  ["--runtime", "Requests, errors, error rate and mean latency, from the app's own counters"],
14711
14901
  ["--history", "A recorded series over a window instead of the live figures"],
14712
- ["--series <name>", "With --history: cpu_millicores (default), memory_bytes or event_loop_delay_ms"],
14902
+ ["--series <name>", "With --history: cpu_millicores (default), memory_bytes, event_loop_delay_ms, or requests_<surface> / errors_<surface> for data, auth, storage, functions, app"],
14713
14903
  ["--minutes <n>", "With --history: how far back, 1 to 20160 (fourteen days). Default: 60"]
14714
14904
  ],
14715
14905
  examples: [
@@ -14881,6 +15071,7 @@ var CLOUD_VALUE_FLAGS = {
14881
15071
  "--endpoint": String,
14882
15072
  "--events": String,
14883
15073
  "--expires-in": String,
15074
+ "--file": String,
14884
15075
  "--format": String,
14885
15076
  "--function": String,
14886
15077
  "--grep": String,
@@ -15018,8 +15209,8 @@ async function cloudCommand(subcommand, rawArgs) {
15018
15209
  initOutputMode(rawArgs);
15019
15210
  const pos = positionals(rawArgs);
15020
15211
  const group = pos[0] ?? (subcommand !== "--help" ? subcommand : void 0);
15021
- if (group === "deploy") initOutputMode(rawArgs, { whenPiped: "human" });
15022
15212
  const wantsHelp = rawArgs.includes("--help") || rawArgs.includes("-h");
15213
+ if (group === "deploy" && !wantsHelp) initOutputMode(rawArgs, { whenPiped: "human" });
15023
15214
  const action = pos.slice(1).find((token) => !token.startsWith("-"));
15024
15215
  if (!group) {
15025
15216
  printCloudHelp();
@@ -15491,4 +15682,4 @@ function printCloudHelp() {
15491
15682
  //#endregion
15492
15683
  export { CLOUD_GROUP_NAMES, GROUP_ALIASES, cloudCommand };
15493
15684
 
15494
- //# sourceMappingURL=cloud-DNJyUU0T.js.map
15685
+ //# sourceMappingURL=cloud-CR6Hps3B.js.map