@rebasepro/cli 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-setup-DqAcoDcn.js → agent-setup-Cg_zBWoW.js} +3 -3
- package/dist/{agent-setup-DqAcoDcn.js.map → agent-setup-Cg_zBWoW.js.map} +1 -1
- package/dist/api-TbmW33D7.js +275 -0
- package/dist/api-TbmW33D7.js.map +1 -0
- package/dist/{api-keys-eIUjMqWn.js → api-keys-fPQ55DCm.js} +151 -158
- package/dist/api-keys-fPQ55DCm.js.map +1 -0
- package/dist/{apps-DExO4PEl.js → apps-DBTRoOeP.js} +18 -13
- package/dist/apps-DBTRoOeP.js.map +1 -0
- package/dist/{args-CaCcrYE1.js → args-DHyrshtI.js} +3 -132
- package/dist/args-DHyrshtI.js.map +1 -0
- package/dist/{atlas-dev-database-DOCKk6ht.js → atlas-dev-database-D6h65f2x.js} +3 -3
- package/dist/{atlas-dev-database-DOCKk6ht.js.map → atlas-dev-database-D6h65f2x.js.map} +1 -1
- package/dist/{auth-ofQETpM5.js → auth-BpyYLEFY.js} +93 -12
- package/dist/auth-BpyYLEFY.js.map +1 -0
- package/dist/auth-session-B6aT0Dyj.js +371 -0
- package/dist/auth-session-B6aT0Dyj.js.map +1 -0
- package/dist/{backend-guard-C0mVkXBw.js → backend-guard-Cf8eMK_f.js} +2 -2
- package/dist/{backend-guard-C0mVkXBw.js.map → backend-guard-Cf8eMK_f.js.map} +1 -1
- package/dist/{branch-pointer-DMPyvZoK.js → branch-pointer-BJOF2Ubv.js} +1 -1
- package/dist/{build-CA5R07tw.js → build-BfdT-AUR.js} +12 -10
- package/dist/{build-CA5R07tw.js.map → build-BfdT-AUR.js.map} +1 -1
- package/dist/{bundle-DgILeA5b.js → bundle-CIiKGrte.js} +78 -12
- package/dist/bundle-CIiKGrte.js.map +1 -0
- package/dist/bundle.d.ts +31 -1
- package/dist/{cloud-CYMk92iG.js → cloud-MqnyPnmX.js} +1540 -1531
- package/dist/cloud-MqnyPnmX.js.map +1 -0
- package/dist/{cms-directories-BK3vcswg.js → cms-directories-BaV-Is9a.js} +2 -2
- package/dist/{cms-directories-BK3vcswg.js.map → cms-directories-BaV-Is9a.js.map} +1 -1
- package/dist/codemod/collections-to-tables/backend.d.ts +0 -2
- package/dist/codemod/collections-to-tables/customization.d.ts +2 -1
- package/dist/codemod/collections-to-tables/modules.d.ts +32 -0
- package/dist/codemod/collections-to-tables/plan-context.d.ts +7 -1
- package/dist/{command-D5lhW_-B.js → command-D9g46gg9.js} +68 -42
- package/dist/command-D9g46gg9.js.map +1 -0
- package/dist/commands/api-keys.d.ts +89 -52
- package/dist/commands/api.d.ts +114 -0
- package/dist/commands/auth-session.d.ts +94 -0
- package/dist/commands/auth.d.ts +1 -1
- package/dist/commands/cloud/alerts.d.ts +29 -0
- package/dist/commands/cloud/context.d.ts +8 -0
- package/dist/commands/cloud/debug.d.ts +16 -1
- package/dist/commands/cloud/deploy-hooks.d.ts +19 -0
- package/dist/commands/cloud/deploy.d.ts +25 -0
- package/dist/commands/cloud/env.d.ts +1 -0
- package/dist/commands/cloud/index.d.ts +5 -0
- package/dist/commands/cloud/maintenance.d.ts +26 -1
- package/dist/commands/cloud/not-served.d.ts +27 -0
- package/dist/commands/cloud/orgs.d.ts +5 -0
- package/dist/commands/cloud/resources.d.ts +82 -2
- package/dist/commands/cloud/runtime-logs.d.ts +57 -0
- package/dist/commands/cloud/settings.d.ts +3 -0
- package/dist/commands/cron.d.ts +68 -0
- package/dist/commands/data.d.ts +197 -0
- package/dist/commands/functions.d.ts +38 -0
- package/dist/commands/logs.d.ts +22 -0
- package/dist/commands/rls.d.ts +31 -0
- package/dist/commands/schema-reconcile.d.ts +2 -1
- package/dist/commands/schema-show.d.ts +38 -0
- package/dist/commands/storage-objects.d.ts +88 -0
- package/dist/commands/storage.d.ts +18 -2
- package/dist/commands/users.d.ts +147 -0
- package/dist/{consent-BXLIrMl8.js → consent-UV6ObCME.js} +2 -2
- package/dist/{consent-BXLIrMl8.js.map → consent-UV6ObCME.js.map} +1 -1
- package/dist/{console-DjThnr3f.js → console-BVoYOLAO.js} +6 -6
- package/dist/{console-DjThnr3f.js.map → console-BVoYOLAO.js.map} +1 -1
- package/dist/{context--JwaHaZp.js → context-BOMEoKxn.js} +80 -9
- package/dist/{context--JwaHaZp.js.map → context-BOMEoKxn.js.map} +1 -1
- package/dist/cron-CpUsQ739.js +298 -0
- package/dist/cron-CpUsQ739.js.map +1 -0
- package/dist/cron-ZRXsla0v.js +259 -0
- package/dist/cron-ZRXsla0v.js.map +1 -0
- package/dist/{daemon-w30PsdwV.js → daemon-D5gdG7gx.js} +3 -3
- package/dist/{daemon-w30PsdwV.js.map → daemon-D5gdG7gx.js.map} +1 -1
- package/dist/{daemon-entry-zOC1revO.js → daemon-entry--ummUJnk.js} +2 -2
- package/dist/{daemon-entry-zOC1revO.js.map → daemon-entry--ummUJnk.js.map} +1 -1
- package/dist/data-BJ9AZFUC.js +947 -0
- package/dist/data-BJ9AZFUC.js.map +1 -0
- package/dist/{db-Bz2RFGJj.js → db-D_iF4E-v.js} +38 -34
- package/dist/{db-Bz2RFGJj.js.map → db-D_iF4E-v.js.map} +1 -1
- package/dist/debug-nNbbxAeo.js +1114 -0
- package/dist/debug-nNbbxAeo.js.map +1 -0
- package/dist/{derive-C3ezmY-p.js → derive-Mky_u59_.js} +3 -3
- package/dist/{derive-C3ezmY-p.js.map → derive-Mky_u59_.js.map} +1 -1
- package/dist/{dev-D8TxrE_I.js → dev-bj6dEeSQ.js} +13 -13
- package/dist/{dev-D8TxrE_I.js.map → dev-bj6dEeSQ.js.map} +1 -1
- package/dist/dev-db/pull.d.ts +13 -3
- package/dist/{dev-preflight-DjvcV6SK.js → dev-preflight-BMOf2N6r.js} +2 -2
- package/dist/{dev-preflight-DjvcV6SK.js.map → dev-preflight-BMOf2N6r.js.map} +1 -1
- package/dist/{dev-server-BLxCbQEP.js → dev-server-2XHSHM_q.js} +2 -2
- package/dist/{dev-server-BLxCbQEP.js.map → dev-server-2XHSHM_q.js.map} +1 -1
- package/dist/{doctor-Du-mSxoE.js → doctor-2Jlau0Rm.js} +9 -8
- package/dist/{doctor-Du-mSxoE.js.map → doctor-2Jlau0Rm.js.map} +1 -1
- package/dist/{eject-Bhzd6hgb.js → eject-DK_M9kor.js} +4 -4
- package/dist/{eject-Bhzd6hgb.js.map → eject-DK_M9kor.js.map} +1 -1
- package/dist/{fold-static-CKewnAPX.js → fold-static-2t3UUX4z.js} +10 -6
- package/dist/fold-static-2t3UUX4z.js.map +1 -0
- package/dist/fold-static.d.ts +7 -0
- package/dist/functions-B4JR6EZL.js +120 -0
- package/dist/functions-B4JR6EZL.js.map +1 -0
- package/dist/{generate-view-CTOluXvH.js → generate-view-BMaLQm8H.js} +5 -5
- package/dist/{generate-view-CTOluXvH.js.map → generate-view-BMaLQm8H.js.map} +1 -1
- package/dist/{generate_sdk-De-aLC1L.js → generate_sdk-ByD-gTsK.js} +7 -7
- package/dist/{generate_sdk-De-aLC1L.js.map → generate_sdk-ByD-gTsK.js.map} +1 -1
- package/dist/index.es.js +123 -47
- package/dist/index.es.js.map +1 -1
- package/dist/{init-Dtl-IcXf.js → init-DHCe5mJ5.js} +59 -11
- package/dist/init-DHCe5mJ5.js.map +1 -0
- package/dist/{invoked-command-CG_rIa_o.js → invoked-command-FBeIBS8o.js} +2 -2
- package/dist/{invoked-command-CG_rIa_o.js.map → invoked-command-FBeIBS8o.js.map} +1 -1
- package/dist/last-dev-database-CBVkEUEl.js +2 -0
- package/dist/logs-CIgfLBsu.js +192 -0
- package/dist/logs-CIgfLBsu.js.map +1 -0
- package/dist/{manifest-C3uLDrrJ.js → manifest-RjqxfCpb.js} +114 -5
- package/dist/manifest-RjqxfCpb.js.map +1 -0
- package/dist/{migrate-VrKoi3nB.js → migrate-Cx8-Y4TG.js} +5 -4
- package/dist/{migrate-VrKoi3nB.js.map → migrate-Cx8-Y4TG.js.map} +1 -1
- package/dist/{normalize-imports-DwxqEMYq.js → normalize-imports-P86NVfpo.js} +3 -3
- package/dist/{normalize-imports-DwxqEMYq.js.map → normalize-imports-P86NVfpo.js.map} +1 -1
- package/dist/{path-flags-7O5uPBcQ.js → path-flags-ekLdkbra.js} +3 -3
- package/dist/{path-flags-7O5uPBcQ.js.map → path-flags-ekLdkbra.js.map} +1 -1
- package/dist/{prepare-Ccxspoj-.js → prepare-BaJe0Zik.js} +4 -4
- package/dist/{prepare-Ccxspoj-.js.map → prepare-BaJe0Zik.js.map} +1 -1
- package/dist/{project-CLcF5i8c.js → project-DALmhb5R.js} +2 -2
- package/dist/{project-CLcF5i8c.js.map → project-DALmhb5R.js.map} +1 -1
- package/dist/project-command-Cl9EZzjr.js +662 -0
- package/dist/project-command-Cl9EZzjr.js.map +1 -0
- package/dist/{project-schema-CsSOG2gE.js → project-schema-Dm6Jk0Y_.js} +4 -2
- package/dist/{project-schema-CsSOG2gE.js.map → project-schema-Dm6Jk0Y_.js.map} +1 -1
- package/dist/{pull-BMuiUyjb.js → pull-CTIsST6T.js} +66 -5
- package/dist/pull-CTIsST6T.js.map +1 -0
- package/dist/resolve-C36px9tR.js +2 -0
- package/dist/{resources-Dpfs2y8P.js → resources-Db3USuPO.js} +5 -5
- package/dist/{resources-Dpfs2y8P.js.map → resources-Db3USuPO.js.map} +1 -1
- package/dist/rls-BxrQ0P50.js +133 -0
- package/dist/rls-BxrQ0P50.js.map +1 -0
- package/dist/{schema-Dv6nHkb0.js → schema-_FzZEoB8.js} +54 -40
- package/dist/schema-_FzZEoB8.js.map +1 -0
- package/dist/{schema-dir-Cd1kvYbf.js → schema-dir-ChcYfWjP.js} +2 -2
- package/dist/{schema-dir-Cd1kvYbf.js.map → schema-dir-ChcYfWjP.js.map} +1 -1
- package/dist/schema-reconcile-DV14XY4o.js +2 -0
- package/dist/schema-show-h72UJ9zH.js +127 -0
- package/dist/schema-show-h72UJ9zH.js.map +1 -0
- package/dist/{skills-CXjA9TWw.js → skills-DQ2bZGkj.js} +6 -5
- package/dist/{skills-CXjA9TWw.js.map → skills-DQ2bZGkj.js.map} +1 -1
- package/dist/star-nudge.d.ts +28 -0
- package/dist/{start-Bwbtt2W5.js → start-Cjx4W0bJ.js} +7 -7
- package/dist/{start-Bwbtt2W5.js.map → start-Cjx4W0bJ.js.map} +1 -1
- package/dist/{status-BTgTWzlQ.js → status-CDBk25VO.js} +9 -9
- package/dist/{status-BTgTWzlQ.js.map → status-CDBk25VO.js.map} +1 -1
- package/dist/{storage-iTqj5-Av.js → storage-Clc8dLG8.js} +79 -36
- package/dist/storage-Clc8dLG8.js.map +1 -0
- package/dist/storage-objects-CfRKlTDe.js +279 -0
- package/dist/storage-objects-CfRKlTDe.js.map +1 -0
- package/dist/{telemetry-BP_1Cl9r.js → telemetry-DZU2-NCm.js} +5 -4
- package/dist/{telemetry-BP_1Cl9r.js.map → telemetry-DZU2-NCm.js.map} +1 -1
- package/dist/{telemetry-M3HjlyhZ.js → telemetry-EVtASbKb.js} +2 -2
- package/dist/{telemetry-M3HjlyhZ.js.map → telemetry-EVtASbKb.js.map} +1 -1
- package/dist/unknown-command-DnZ2uhGs.js +139 -0
- package/dist/unknown-command-DnZ2uhGs.js.map +1 -0
- package/dist/{upgrade-oZzJ13jM.js → upgrade-DhpUFb6p.js} +5 -5
- package/dist/{upgrade-oZzJ13jM.js.map → upgrade-DhpUFb6p.js.map} +1 -1
- package/dist/users-5PkqBY6R.js +561 -0
- package/dist/users-5PkqBY6R.js.map +1 -0
- package/dist/utils/project-command.d.ts +38 -0
- package/dist/utils/project-target.d.ts +193 -0
- package/dist/{verify-BkUVGLqo.js → verify-BdeqNb-V.js} +138 -12
- package/dist/verify-BdeqNb-V.js.map +1 -0
- package/dist/{version-Buyyo1ut.js → version-ONIeo7jl.js} +7 -2
- package/dist/{version-Buyyo1ut.js.map → version-ONIeo7jl.js.map} +1 -1
- package/package.json +10 -10
- package/dist/api-keys-eIUjMqWn.js.map +0 -1
- package/dist/apps-DExO4PEl.js.map +0 -1
- package/dist/args-CaCcrYE1.js.map +0 -1
- package/dist/auth-ofQETpM5.js.map +0 -1
- package/dist/bundle-DgILeA5b.js.map +0 -1
- package/dist/cloud-CYMk92iG.js.map +0 -1
- package/dist/command-D5lhW_-B.js.map +0 -1
- package/dist/fold-static-CKewnAPX.js.map +0 -1
- package/dist/init-Dtl-IcXf.js.map +0 -1
- package/dist/last-dev-database-Dc8cP01o.js +0 -2
- package/dist/manifest-C3uLDrrJ.js.map +0 -1
- package/dist/pull-BMuiUyjb.js.map +0 -1
- package/dist/resolve-BY7bSFRT.js +0 -2
- package/dist/schema-Dv6nHkb0.js.map +0 -1
- package/dist/schema-reconcile-CjxLaRHB.js +0 -2
- package/dist/storage-iTqj5-Av.js.map +0 -1
- package/dist/verify-BkUVGLqo.js.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { n as unknownCommand } from "./unknown-command-DnZ2uhGs.js";
|
|
3
|
+
import { a as wantsHelp, n as parseCommandArgs, t as UsageError } from "./args-DHyrshtI.js";
|
|
4
|
+
import { c as findProjectRoot } from "./project-DALmhb5R.js";
|
|
5
|
+
import { t as cliUserAgent } from "./version-ONIeo7jl.js";
|
|
6
|
+
import { a as serverUnreachableHint } from "./dev-server-2XHSHM_q.js";
|
|
7
|
+
import { a as projectTarget, d as PROJECT_TARGET_FLAGS, h as projectServiceKey } from "./project-command-Cl9EZzjr.js";
|
|
8
|
+
import { l as confirmDestructive } from "./context-BOMEoKxn.js";
|
|
6
9
|
import chalk from "chalk";
|
|
7
|
-
import
|
|
8
|
-
import path from "path";
|
|
10
|
+
import arg from "arg";
|
|
9
11
|
import { ADMIN_SCOPES, DATA_PLANE_SCOPES, KEY_MANAGEMENT_SCOPES, parseScope } from "@rebasepro/types";
|
|
10
12
|
import { RebaseApiError, createRebaseClient } from "@rebasepro/client";
|
|
11
13
|
//#region src/commands/api-keys.ts
|
|
@@ -30,164 +32,60 @@ var api_keys_exports = /* @__PURE__ */ __exportAll({
|
|
|
30
32
|
RETIRED_CREATE_OPTIONS: () => RETIRED_CREATE_OPTIONS,
|
|
31
33
|
REVOKE_KEY_FLAGS: () => REVOKE_KEY_FLAGS,
|
|
32
34
|
SCOPES_LIST_FLAGS: () => SCOPES_LIST_FLAGS,
|
|
35
|
+
UPDATE_KEY_FLAGS: () => UPDATE_KEY_FLAGS,
|
|
33
36
|
apiKeysCommand: () => apiKeysCommand,
|
|
34
|
-
cloudTargetNote: () => cloudTargetNote,
|
|
35
37
|
describeFailure: () => describeFailure,
|
|
36
38
|
describeKey: () => describeKey,
|
|
37
39
|
describeScopes: () => describeScopes,
|
|
38
40
|
grantableScopes: () => grantableScopes,
|
|
39
|
-
requireBackendUrl: () => requireBackendUrl,
|
|
40
|
-
resolveBackendAddress: () => resolveBackendAddress,
|
|
41
41
|
resolveCreateKeyArgs: () => resolveCreateKeyArgs,
|
|
42
42
|
resolveGetKeyArgs: () => resolveGetKeyArgs,
|
|
43
|
-
resolveRevokeKeyArgs: () => resolveRevokeKeyArgs
|
|
43
|
+
resolveRevokeKeyArgs: () => resolveRevokeKeyArgs,
|
|
44
|
+
resolveUpdateKeyArgs: () => resolveUpdateKeyArgs
|
|
44
45
|
});
|
|
45
46
|
/** Everything the switch below dispatches, for the did-you-mean. */
|
|
46
47
|
var API_KEYS_SUBCOMMANDS = [
|
|
47
48
|
"list",
|
|
48
49
|
"get",
|
|
49
50
|
"create",
|
|
51
|
+
"update",
|
|
50
52
|
"revoke",
|
|
51
53
|
"scopes"
|
|
52
54
|
];
|
|
53
55
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* comment attached and came back 401. See `readEnvFile`.
|
|
58
|
-
*/
|
|
59
|
-
var loadEnv = readEnvFile;
|
|
60
|
-
/** Whether a process with this pid is alive and ours to signal. */
|
|
61
|
-
function isAlive(pid) {
|
|
62
|
-
try {
|
|
63
|
-
process.kill(pid, 0);
|
|
64
|
-
return true;
|
|
65
|
-
} catch {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* The address the service key may be sent to. Shared with `rebase storage`.
|
|
71
|
-
*
|
|
72
|
-
* In order:
|
|
73
|
-
*
|
|
74
|
-
* 1. `REBASE_BASE_URL`, in the shell or in `.env` — the developer said where.
|
|
75
|
-
* 2. `.rebase/state.json`, which this project's backend writes when it binds
|
|
76
|
-
* and removes when it stops — and only while the pid it names is alive,
|
|
77
|
-
* because a backend that was killed leaves the file behind.
|
|
78
|
-
*
|
|
79
|
-
* Nothing else. `.env`'s `PORT` was the fallback, and every scaffold writes
|
|
80
|
-
* `PORT=3001`: with `rebase dev` stopped, `rebase api-keys list` sent this
|
|
81
|
-
* project's service key to whatever listened on 3001 — on the tester's machine,
|
|
82
|
-
* another project's server. `.rebase-dev-url` is not enough on its own either:
|
|
83
|
-
* a `rebase dev` that was killed leaves it behind, pointing at a port some
|
|
84
|
-
* other server may have taken since.
|
|
85
|
-
*/
|
|
86
|
-
function resolveBackendAddress(env, projectRoot) {
|
|
87
|
-
const fromShell = process.env.REBASE_BASE_URL?.trim();
|
|
88
|
-
const configured = fromShell || env.REBASE_BASE_URL?.trim();
|
|
89
|
-
if (configured) {
|
|
90
|
-
const cloudProject = fromShell ? void 0 : linkedCloudProjectAt(projectRoot, configured);
|
|
91
|
-
return cloudProject ? {
|
|
92
|
-
url: configured,
|
|
93
|
-
source: "configured",
|
|
94
|
-
cloudProject
|
|
95
|
-
} : {
|
|
96
|
-
url: configured,
|
|
97
|
-
source: "configured"
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const state = readBackendState(projectRoot);
|
|
101
|
-
if (state && isAlive(state.pid)) return {
|
|
102
|
-
url: state.url,
|
|
103
|
-
source: "running"
|
|
104
|
-
};
|
|
105
|
-
return {
|
|
106
|
-
url: null,
|
|
107
|
-
reason: `This project's server is not running, so the service key was not sent anywhere.${state ? ` The last one recorded here, at ${state.url} (pid ${state.pid}), has stopped.` : ""} Start it with \`rebase dev\`. If it runs some other way — \`rebase start\`, a container — set REBASE_BASE_URL in .env to its address.`
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
/** The slug of the cloud project `.rebase/cloud.json` links, when `url` is its address. */
|
|
111
|
-
function linkedCloudProjectAt(projectRoot, url) {
|
|
112
|
-
let link;
|
|
113
|
-
try {
|
|
114
|
-
link = JSON.parse(fs.readFileSync(path.join(projectRoot, ".rebase", "cloud.json"), "utf-8"));
|
|
115
|
-
} catch {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (!isRecord(link) || link.mode === "direct" || typeof link.apiUrl !== "string") return void 0;
|
|
119
|
-
const bare = (u) => u.trim().replace(/\/+$/, "");
|
|
120
|
-
if (bare(link.apiUrl) !== bare(url)) return void 0;
|
|
121
|
-
const slug = typeof link.slug === "string" && link.slug ? link.slug : link.projectId;
|
|
122
|
-
return typeof slug === "string" && slug ? slug : "linked";
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* What a local command says before it sends the service key to the cloud
|
|
126
|
-
* project `.env` names (see `BackendAddress.cloudProject`), or undefined.
|
|
127
|
-
*/
|
|
128
|
-
function cloudTargetNote(address) {
|
|
129
|
-
if (address.url === null || !address.cloudProject) return void 0;
|
|
130
|
-
return `Sending this to ${address.url}: REBASE_BASE_URL in .env is the address of cloud project ${address.cloudProject} (\`rebase cloud init --claim\` writes it there for the app, the SDK and the MCP server), and that project does not take this project's local service key. To reach the local backend instead, run the command with REBASE_BASE_URL set to it in the shell, e.g. REBASE_BASE_URL=http://localhost:3001.`;
|
|
131
|
-
}
|
|
132
|
-
/** What `.rebase/state.json` says about the backend that wrote it, or null. */
|
|
133
|
-
function readBackendState(projectRoot) {
|
|
134
|
-
let parsed;
|
|
135
|
-
try {
|
|
136
|
-
parsed = JSON.parse(fs.readFileSync(path.join(projectRoot, ".rebase", "state.json"), "utf-8"));
|
|
137
|
-
} catch {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
if (!isRecord(parsed) || typeof parsed.pid !== "number" || !Number.isInteger(parsed.pid) || parsed.pid <= 0) return null;
|
|
141
|
-
const url = typeof parsed.baseUrl === "string" && parsed.baseUrl.trim() ? parsed.baseUrl.trim() : typeof parsed.port === "number" ? `http://localhost:${parsed.port}` : null;
|
|
142
|
-
return url ? {
|
|
143
|
-
url,
|
|
144
|
-
pid: parsed.pid
|
|
145
|
-
} : null;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* The address to send the service key to, or the end of the command.
|
|
149
|
-
*
|
|
150
|
-
* Exits before any request is made: the refusal is the point.
|
|
151
|
-
*/
|
|
152
|
-
function requireBackendUrl(env, projectRoot) {
|
|
153
|
-
const address = resolveBackendAddress(env, projectRoot);
|
|
154
|
-
const note = cloudTargetNote(address);
|
|
155
|
-
if (note) console.error(chalk.yellow(` ⚠ ${note}`));
|
|
156
|
-
if (address.url !== null) return address.url;
|
|
157
|
-
console.error(chalk.red("✗ No server to send the request to."));
|
|
158
|
-
console.error(chalk.gray(` ${address.reason}`));
|
|
159
|
-
process.exit(1);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* An SDK client for this project's backend, holding the service key.
|
|
56
|
+
* An SDK client for this project's backend, holding the service key — or the
|
|
57
|
+
* credential the target flags name, resolved as every project command
|
|
58
|
+
* resolves it (`--project`, `--cloud`, `--url`, `--token`, `--session`).
|
|
163
59
|
*
|
|
164
60
|
* The service key is the project's own machine identity — the `admin` role,
|
|
165
61
|
* every scope — so it is what may list, mint and revoke service keys. It is a
|
|
166
|
-
* static bearer token: no session to restore or refresh, and no socket.
|
|
62
|
+
* static bearer token: no session to restore or refresh, and no socket. An
|
|
63
|
+
* `rk_` key is refused on these routes whatever it holds.
|
|
64
|
+
*
|
|
65
|
+
* The line was already parsed strictly by the action's own spec, which
|
|
66
|
+
* declares the target flags; they are read again here only for their values.
|
|
167
67
|
*/
|
|
168
|
-
function connect() {
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
68
|
+
async function connect(rawArgs) {
|
|
69
|
+
const target = await projectTarget(arg(PROJECT_TARGET_FLAGS, {
|
|
70
|
+
argv: rawArgs.slice(2),
|
|
71
|
+
permissive: true
|
|
72
|
+
}), { command: "api-keys" });
|
|
73
|
+
const token = await target.bearer();
|
|
74
|
+
const client = createRebaseClient({
|
|
75
|
+
baseUrl: target.baseUrl,
|
|
76
|
+
...token ? { token } : {},
|
|
77
|
+
realtime: false,
|
|
78
|
+
headers: { "User-Agent": cliUserAgent() },
|
|
79
|
+
auth: {
|
|
80
|
+
persistSession: false,
|
|
81
|
+
autoRefresh: false
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const keyVariable = target.credential === "service-key" ? projectServiceKey(findProjectRoot())?.variable : void 0;
|
|
178
85
|
return {
|
|
179
|
-
client
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
realtime: false,
|
|
183
|
-
headers: { "User-Agent": cliUserAgent() },
|
|
184
|
-
auth: {
|
|
185
|
-
persistSession: false,
|
|
186
|
-
autoRefresh: false
|
|
187
|
-
}
|
|
188
|
-
}),
|
|
189
|
-
baseUrl,
|
|
190
|
-
keyVariable
|
|
86
|
+
client,
|
|
87
|
+
baseUrl: target.label,
|
|
88
|
+
keyVariable: keyVariable === "SERVICE_KEY" ? "SERVICE_KEY" : "REBASE_SERVICE_KEY"
|
|
191
89
|
};
|
|
192
90
|
}
|
|
193
91
|
/**
|
|
@@ -235,6 +133,9 @@ async function apiKeysCommand(subcommand, rawArgs) {
|
|
|
235
133
|
case "create":
|
|
236
134
|
await createKey(rawArgs);
|
|
237
135
|
break;
|
|
136
|
+
case "update":
|
|
137
|
+
await updateKey(rawArgs);
|
|
138
|
+
break;
|
|
238
139
|
case "revoke":
|
|
239
140
|
await revokeKey(rawArgs);
|
|
240
141
|
break;
|
|
@@ -276,7 +177,7 @@ function describeKey(key, now = /* @__PURE__ */ new Date()) {
|
|
|
276
177
|
return lines;
|
|
277
178
|
}
|
|
278
179
|
/** The flags `rebase api-keys list` takes: none of its own. */
|
|
279
|
-
var LIST_KEYS_FLAGS = {};
|
|
180
|
+
var LIST_KEYS_FLAGS = { ...PROJECT_TARGET_FLAGS };
|
|
280
181
|
async function listKeys(rawArgs) {
|
|
281
182
|
parseCommandArgs({
|
|
282
183
|
spec: LIST_KEYS_FLAGS,
|
|
@@ -285,7 +186,7 @@ async function listKeys(rawArgs) {
|
|
|
285
186
|
command: "api-keys list",
|
|
286
187
|
maxPositionals: 0
|
|
287
188
|
});
|
|
288
|
-
const connection = connect();
|
|
189
|
+
const connection = await connect(rawArgs);
|
|
289
190
|
const { client } = connection;
|
|
290
191
|
let keys;
|
|
291
192
|
try {
|
|
@@ -308,7 +209,10 @@ async function listKeys(rawArgs) {
|
|
|
308
209
|
}
|
|
309
210
|
}
|
|
310
211
|
/** The flags `rebase api-keys get` takes. */
|
|
311
|
-
var GET_KEY_FLAGS = {
|
|
212
|
+
var GET_KEY_FLAGS = {
|
|
213
|
+
...PROJECT_TARGET_FLAGS,
|
|
214
|
+
"--id": String
|
|
215
|
+
};
|
|
312
216
|
/**
|
|
313
217
|
* Which key this invocation names, as a positional or as `--id`.
|
|
314
218
|
*
|
|
@@ -327,7 +231,7 @@ function resolveGetKeyArgs(rawArgs) {
|
|
|
327
231
|
async function getKey(rawArgs) {
|
|
328
232
|
const { id } = resolveGetKeyArgs(rawArgs);
|
|
329
233
|
if (!id) throw new UsageError("Key ID is required: rebase api-keys get <key-id> (`rebase api-keys list` shows them).");
|
|
330
|
-
const connection = connect();
|
|
234
|
+
const connection = await connect(rawArgs);
|
|
331
235
|
const { client } = connection;
|
|
332
236
|
let key;
|
|
333
237
|
try {
|
|
@@ -341,6 +245,7 @@ async function getKey(rawArgs) {
|
|
|
341
245
|
}
|
|
342
246
|
/** The flags `rebase api-keys create` takes. */
|
|
343
247
|
var CREATE_KEY_FLAGS = {
|
|
248
|
+
...PROJECT_TARGET_FLAGS,
|
|
344
249
|
"--name": String,
|
|
345
250
|
"--scopes": [String],
|
|
346
251
|
"--full-access": Boolean,
|
|
@@ -449,7 +354,7 @@ function grantableScopes(held) {
|
|
|
449
354
|
}
|
|
450
355
|
async function createKey(rawArgs) {
|
|
451
356
|
const plan = resolveCreateKeyArgs(rawArgs);
|
|
452
|
-
const connection = connect();
|
|
357
|
+
const connection = await connect(rawArgs);
|
|
453
358
|
const { client } = connection;
|
|
454
359
|
let scopes;
|
|
455
360
|
if (plan.scopes === "held") {
|
|
@@ -488,8 +393,70 @@ async function createKey(rawArgs) {
|
|
|
488
393
|
console.log(` ${chalk.cyan(created.key)}`);
|
|
489
394
|
console.log("");
|
|
490
395
|
}
|
|
396
|
+
/** The flags `rebase api-keys update` takes. */
|
|
397
|
+
var UPDATE_KEY_FLAGS = {
|
|
398
|
+
...PROJECT_TARGET_FLAGS,
|
|
399
|
+
"--id": String,
|
|
400
|
+
"--name": String,
|
|
401
|
+
"--scopes": [String],
|
|
402
|
+
"--roles": [String],
|
|
403
|
+
"--rate-limit": Number,
|
|
404
|
+
"--no-rate-limit": Boolean,
|
|
405
|
+
"--expires-in": String,
|
|
406
|
+
"--expires-at": String,
|
|
407
|
+
"--no-expiry": Boolean,
|
|
408
|
+
"-n": "--name"
|
|
409
|
+
};
|
|
410
|
+
/**
|
|
411
|
+
* Which key, and what to change on it: only what the line names is sent, so
|
|
412
|
+
* an update never resets a field it did not mention. Exported for its tests.
|
|
413
|
+
*/
|
|
414
|
+
function resolveUpdateKeyArgs(rawArgs, now = /* @__PURE__ */ new Date()) {
|
|
415
|
+
const { flags, positionals } = parseCommandArgs({
|
|
416
|
+
spec: UPDATE_KEY_FLAGS,
|
|
417
|
+
rawArgs,
|
|
418
|
+
commandWords: 2,
|
|
419
|
+
command: "api-keys update",
|
|
420
|
+
maxPositionals: 1
|
|
421
|
+
});
|
|
422
|
+
if (flags["--rate-limit"] !== void 0 && flags["--no-rate-limit"]) throw new UsageError("--rate-limit sets a limit and --no-rate-limit removes it; give one.");
|
|
423
|
+
if ((flags["--expires-in"] !== void 0 || flags["--expires-at"] !== void 0) && flags["--no-expiry"]) throw new UsageError("--expires-in/--expires-at set an expiry and --no-expiry removes it; give one.");
|
|
424
|
+
const change = {};
|
|
425
|
+
if (flags["--name"] !== void 0) change.name = flags["--name"];
|
|
426
|
+
if (flags["--scopes"] !== void 0) change.scopes = splitList(flags["--scopes"]);
|
|
427
|
+
if (flags["--roles"] !== void 0) change.roles = splitList(flags["--roles"]);
|
|
428
|
+
if (flags["--rate-limit"] !== void 0) change.rate_limit = flags["--rate-limit"];
|
|
429
|
+
if (flags["--no-rate-limit"]) change.rate_limit = null;
|
|
430
|
+
const expiry = resolveExpiry(flags["--expires-in"], flags["--expires-at"], now);
|
|
431
|
+
if (expiry !== null) change.expires_at = expiry;
|
|
432
|
+
if (flags["--no-expiry"]) change.expires_at = null;
|
|
433
|
+
if (Object.keys(change).length === 0) throw new UsageError("Nothing to change: pass --name, --scopes, --roles, --rate-limit, --no-rate-limit, --expires-in, --expires-at or --no-expiry.");
|
|
434
|
+
return {
|
|
435
|
+
id: flags["--id"] || positionals[0],
|
|
436
|
+
change
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
async function updateKey(rawArgs) {
|
|
440
|
+
const { id, change } = resolveUpdateKeyArgs(rawArgs);
|
|
441
|
+
if (!id) throw new UsageError("Key ID is required: rebase api-keys update <key-id> --scopes … (`rebase api-keys list` shows them).");
|
|
442
|
+
const connection = await connect(rawArgs);
|
|
443
|
+
let key;
|
|
444
|
+
try {
|
|
445
|
+
({key} = await connection.client.apiKeys.updateKey(id, change));
|
|
446
|
+
} catch (e) {
|
|
447
|
+
fail("Failed to update API key", e, connection);
|
|
448
|
+
}
|
|
449
|
+
console.log("");
|
|
450
|
+
console.log(chalk.bold.green(" ✓ API key updated"));
|
|
451
|
+
console.log("");
|
|
452
|
+
for (const line of describeKey(key)) console.log(line);
|
|
453
|
+
console.log("");
|
|
454
|
+
}
|
|
491
455
|
/** The flags `rebase api-keys revoke` takes. */
|
|
492
|
-
var REVOKE_KEY_FLAGS = {
|
|
456
|
+
var REVOKE_KEY_FLAGS = {
|
|
457
|
+
...PROJECT_TARGET_FLAGS,
|
|
458
|
+
"--id": String
|
|
459
|
+
};
|
|
493
460
|
/**
|
|
494
461
|
* Which key this invocation names.
|
|
495
462
|
*
|
|
@@ -508,12 +475,19 @@ function resolveRevokeKeyArgs(rawArgs) {
|
|
|
508
475
|
command: "api-keys revoke",
|
|
509
476
|
maxPositionals: 1
|
|
510
477
|
});
|
|
511
|
-
return {
|
|
478
|
+
return {
|
|
479
|
+
id: flags["--id"] || positionals[0],
|
|
480
|
+
yes: flags["--yes"] === true
|
|
481
|
+
};
|
|
512
482
|
}
|
|
513
483
|
async function revokeKey(rawArgs) {
|
|
514
|
-
const { id } = resolveRevokeKeyArgs(rawArgs);
|
|
484
|
+
const { id, yes } = resolveRevokeKeyArgs(rawArgs);
|
|
515
485
|
if (!id) throw new UsageError("Key ID is required: rebase api-keys revoke <key-id> (`rebase api-keys list` shows them).");
|
|
516
|
-
const connection = connect();
|
|
486
|
+
const connection = await connect(rawArgs);
|
|
487
|
+
await confirmDestructive({
|
|
488
|
+
yes,
|
|
489
|
+
prompt: `Revoke API key ${id} on ${connection.baseUrl}? Anything using it stops working.`
|
|
490
|
+
});
|
|
517
491
|
const { client } = connection;
|
|
518
492
|
try {
|
|
519
493
|
await client.apiKeys.revokeKey(id);
|
|
@@ -526,7 +500,7 @@ async function revokeKey(rawArgs) {
|
|
|
526
500
|
console.log("");
|
|
527
501
|
}
|
|
528
502
|
/** The flags `rebase api-keys scopes` takes: none of its own. */
|
|
529
|
-
var SCOPES_LIST_FLAGS = {};
|
|
503
|
+
var SCOPES_LIST_FLAGS = { ...PROJECT_TARGET_FLAGS };
|
|
530
504
|
var PLANES = [
|
|
531
505
|
{
|
|
532
506
|
plane: "data",
|
|
@@ -576,7 +550,7 @@ async function listScopes(rawArgs) {
|
|
|
576
550
|
command: "api-keys scopes",
|
|
577
551
|
maxPositionals: 0
|
|
578
552
|
});
|
|
579
|
-
const connection = connect();
|
|
553
|
+
const connection = await connect(rawArgs);
|
|
580
554
|
const { client } = connection;
|
|
581
555
|
let catalogue;
|
|
582
556
|
try {
|
|
@@ -601,7 +575,8 @@ ${chalk.green.bold("Commands")}
|
|
|
601
575
|
${chalk.blue.bold("list")} List the service keys: kind, scopes, roles
|
|
602
576
|
${chalk.blue.bold("get")} ${chalk.gray("<id>")} Show one key
|
|
603
577
|
${chalk.blue.bold("create")} Create a service key
|
|
604
|
-
${chalk.blue.bold("
|
|
578
|
+
${chalk.blue.bold("update")} ${chalk.gray("<id>")} Change a key's name, scopes, roles, limit or expiry
|
|
579
|
+
${chalk.blue.bold("revoke")} ${chalk.gray("<id>")} Revoke a key ${chalk.gray("(asks first; --yes skips)")}
|
|
605
580
|
${chalk.blue.bold("scopes")} List the scopes this backend knows, and which you hold
|
|
606
581
|
|
|
607
582
|
${chalk.green.bold("create Options")}
|
|
@@ -614,9 +589,26 @@ ${chalk.green.bold("create Options")}
|
|
|
614
589
|
${chalk.blue("--expires-in")} Days until the key expires
|
|
615
590
|
${chalk.blue("--expires-at")} Expiry as an ISO date, e.g. 2027-01-31
|
|
616
591
|
|
|
617
|
-
${chalk.green.bold("
|
|
592
|
+
${chalk.green.bold("update Options")} ${chalk.gray("only what you name changes")}
|
|
593
|
+
${chalk.blue("--name, -n")} New name
|
|
594
|
+
${chalk.blue("--scopes")} Replace the scopes ${chalk.gray("(never more than you hold)")}
|
|
595
|
+
${chalk.blue("--roles")} Replace the roles
|
|
596
|
+
${chalk.blue("--rate-limit")} Requests per 15-min window; ${chalk.blue("--no-rate-limit")} back to the server's
|
|
597
|
+
${chalk.blue("--expires-in")} Days from now; ${chalk.blue("--expires-at")} an ISO date; ${chalk.blue("--no-expiry")} never
|
|
598
|
+
|
|
599
|
+
${chalk.green.bold("get / update / revoke Options")}
|
|
618
600
|
${chalk.blue("--id")} API key ID ${chalk.gray("(or the first argument)")}
|
|
619
601
|
|
|
602
|
+
${chalk.green.bold("Target options")} ${chalk.gray("(every command)")}
|
|
603
|
+
${chalk.blue("--project <slug>")} A Rebase Cloud project, through the console's Studio proxy
|
|
604
|
+
${chalk.blue("--cloud")} The Rebase Cloud project this directory is linked to
|
|
605
|
+
${chalk.blue("--url <server>")} A server at this address ${chalk.gray("(else REBASE_BASE_URL, then `rebase dev`)")}
|
|
606
|
+
${chalk.blue("--token <bearer>")} Send this bearer instead of the service key ${chalk.gray("(an rk_ key is always refused here)")}
|
|
607
|
+
${chalk.blue("--session")} Send the session \`rebase auth login\` stored ${chalk.gray("(an admin's)")}
|
|
608
|
+
${chalk.blue("--anon")} Send no credential
|
|
609
|
+
${chalk.blue("--json")} Accepted; these commands print text
|
|
610
|
+
${chalk.blue("--yes")} Skip the revoke prompt
|
|
611
|
+
|
|
620
612
|
${chalk.green.bold("Scopes")}
|
|
621
613
|
A scope is ${chalk.blue("resource:action")}, optionally narrowed to one target:
|
|
622
614
|
${chalk.blue("data:read:posts")} reads the posts table and nothing else.
|
|
@@ -632,10 +624,11 @@ ${chalk.green.bold("Examples")}
|
|
|
632
624
|
rebase api-keys create -n "Mailer" --scopes "functions:invoke:send-email,storage:read:(default)"
|
|
633
625
|
rebase api-keys create -n "Ops" --full-access --roles admin --expires-at 2027-01-31
|
|
634
626
|
rebase api-keys get abc123-def456
|
|
635
|
-
rebase api-keys
|
|
627
|
+
rebase api-keys update abc123-def456 --scopes data:read:posts --expires-in 30
|
|
628
|
+
rebase api-keys revoke abc123-def456 --yes
|
|
636
629
|
`);
|
|
637
630
|
}
|
|
638
631
|
//#endregion
|
|
639
|
-
export {
|
|
632
|
+
export { describeFailure as n, api_keys_exports as t };
|
|
640
633
|
|
|
641
|
-
//# sourceMappingURL=api-keys-
|
|
634
|
+
//# sourceMappingURL=api-keys-fPQ55DCm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-keys-fPQ55DCm.js","names":[],"sources":["../src/commands/api-keys.ts"],"sourcesContent":["/**\n * CLI command: rebase api-keys <action>\n *\n * The project's service keys, through `/api/admin/api-keys`, authenticated with\n * the service key from `.env`.\n *\n * Subcommands:\n * list — List the service keys (masked): kind, scopes, roles\n * get — Show one key\n * create — Create a service key holding the scopes named on the line\n * revoke — Revoke a key\n * scopes — List the scopes this backend knows, and which the caller holds\n */\nimport chalk from \"chalk\";\nimport arg from \"arg\";\nimport { createRebaseClient, RebaseApiError } from \"@rebasepro/client\";\nimport {\n ADMIN_SCOPES,\n DATA_PLANE_SCOPES,\n KEY_MANAGEMENT_SCOPES,\n parseScope,\n type ApiKeyMasked,\n type ApiKeyWithSecret,\n type CreateApiKeyRequest,\n type UpdateApiKeyRequest,\n type ScopeSummary\n} from \"@rebasepro/types\";\nimport { findProjectRoot } from \"../utils/project\";\nimport { PROJECT_TARGET_FLAGS, cloudTargetNote, projectServiceKey, resolveBackendAddress } from \"../utils/project-target\";\nimport { projectTarget } from \"../utils/project-command\";\nimport { confirmDestructive } from \"./cloud/context\";\nimport { parseCommandArgs, UsageError, wantsHelp } from \"../utils/args\";\nimport { unknownCommand } from \"../utils/unknown-command\";\nimport { cliUserAgent } from \"../utils/version\";\nimport { serverUnreachableHint } from \"../utils/dev-server\";\n\n/** Everything the switch below dispatches, for the did-you-mean. */\nexport const API_KEYS_SUBCOMMANDS = [\"list\", \"get\", \"create\", \"update\", \"revoke\", \"scopes\"] as const;\n\n/* ═══════════════════════════════════════════════════════════════\n Where the backend is — shared with every project command\n ═══════════════════════════════════════════════════════════════ */\n\n// The address rules (REBASE_BASE_URL, then a live `rebase dev`, nothing\n// guessed) moved to `utils/project-target.ts` with the other project\n// commands; re-exported here for the callers and tests that import them\n// from this module.\nexport { cloudTargetNote, resolveBackendAddress, type BackendAddress } from \"../utils/project-target\";\n\n/**\n * The address to send the service key to, or the end of the command.\n *\n * Exits before any request is made: the refusal is the point.\n */\nexport function requireBackendUrl(env: Record<string, string>, projectRoot: string): string {\n const address = resolveBackendAddress(env, projectRoot);\n const note = cloudTargetNote(address);\n if (note) console.error(chalk.yellow(` ⚠ ${note}`));\n if (address.url !== null) return address.url;\n\n console.error(chalk.red(\"✗ No server to send the request to.\"));\n console.error(chalk.gray(` ${address.reason}`));\n process.exit(1);\n}\n\n/* ═══════════════════════════════════════════════════════════════\n The backend, through the SDK\n ═══════════════════════════════════════════════════════════════ */\n\ntype ProjectClient = ReturnType<typeof createRebaseClient>;\n\ninterface Connection {\n client: ProjectClient;\n baseUrl: string;\n /** The variable the service key was read from, for a hint that names it. */\n keyVariable: ServiceKeyVariable;\n}\n\n/** Where a service key is read from: the name a scaffold writes, or the older one. */\ntype ServiceKeyVariable = \"REBASE_SERVICE_KEY\" | \"SERVICE_KEY\";\n\n/**\n * An SDK client for this project's backend, holding the service key — or the\n * credential the target flags name, resolved as every project command\n * resolves it (`--project`, `--cloud`, `--url`, `--token`, `--session`).\n *\n * The service key is the project's own machine identity — the `admin` role,\n * every scope — so it is what may list, mint and revoke service keys. It is a\n * static bearer token: no session to restore or refresh, and no socket. An\n * `rk_` key is refused on these routes whatever it holds.\n *\n * The line was already parsed strictly by the action's own spec, which\n * declares the target flags; they are read again here only for their values.\n */\nasync function connect(rawArgs: string[]): Promise<Connection> {\n const targetFlags = arg(PROJECT_TARGET_FLAGS, { argv: rawArgs.slice(2), permissive: true });\n const target = await projectTarget(targetFlags, { command: \"api-keys\" });\n const token = await target.bearer();\n const client = createRebaseClient({\n baseUrl: target.baseUrl,\n ...(token ? { token } : {}),\n realtime: false,\n headers: { \"User-Agent\": cliUserAgent() },\n auth: { persistSession: false, autoRefresh: false }\n });\n const keyVariable = target.credential === \"service-key\" ? projectServiceKey(findProjectRoot())?.variable : undefined;\n return {\n client,\n baseUrl: target.label,\n keyVariable: keyVariable === \"SERVICE_KEY\" ? \"SERVICE_KEY\" : \"REBASE_SERVICE_KEY\"\n };\n}\n\n/**\n * What to print when a request fails: the server's error code and message,\n * which is what says why — `SCOPE_EXCEEDS_CREATOR`, `INVALID_SCOPES`,\n * `ROLE_EXCEEDS_CREATOR`, `KEY_MANAGEMENT_SCOPE` — and a hint where one helps.\n *\n * Exported so its tests can read the lines without a server.\n */\nexport function describeFailure(\n action: string,\n error: unknown,\n baseUrl: string,\n keyVariable: ServiceKeyVariable = \"REBASE_SERVICE_KEY\"\n): string[] {\n if (!(error instanceof RebaseApiError)) {\n return [`✗ ${action}: ${error instanceof Error ? error.message : String(error)}`];\n }\n if (error.status === 0 || error.code === \"NETWORK_ERROR\") {\n return [`✗ ${action}: ${error.message}`, ...serverUnreachableHint(baseUrl)];\n }\n\n const label = [error.code, error.status ? `(${error.status})` : undefined].filter(Boolean).join(\" \");\n const lines = [`✗ ${action}${label ? ` — ${label}` : \"\"}: ${error.message}`];\n\n if (error.status === 401) {\n lines.push(` The server at ${baseUrl} did not accept ${keyVariable} from .env — is it this project's server?`);\n }\n // The message names the target that is not there; what *is* there rides\n // in `details`, and is the thing to pick from.\n if (error.code === \"UNKNOWN_SCOPE_TARGET\" && isRecord(error.details)) {\n for (const [kind, title] of [[\"collections\", \"Tables\"], [\"buckets\", \"Buckets\"], [\"functions\", \"Functions\"]] as const) {\n const names = error.details[kind];\n if (Array.isArray(names) && names.length > 0) {\n lines.push(` ${title}: ${names.map(String).join(\", \")}`);\n }\n }\n }\n return lines;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction fail(action: string, error: unknown, connection: Connection): never {\n for (const line of describeFailure(action, error, connection.baseUrl, connection.keyVariable)) {\n console.error(line.startsWith(\"✗\") ? chalk.red(line) : chalk.gray(line));\n }\n process.exit(1);\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Entry\n ═══════════════════════════════════════════════════════════════ */\n\nexport async function apiKeysCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void> {\n // `--help` is answered before dispatch, never by a handler. `cli.ts` only\n // rewrites the subcommand to `\"--help\"` when none was named, so\n // `rebase api-keys list --help` used to *list the keys* and\n // `rebase api-keys revoke --help` sent `DELETE /api/admin/api-keys/--help`.\n if (!subcommand || subcommand === \"--help\" || wantsHelp(rawArgs)) {\n printApiKeysHelp();\n return;\n }\n\n switch (subcommand) {\n case \"list\":\n await listKeys(rawArgs);\n break;\n case \"get\":\n await getKey(rawArgs);\n break;\n case \"create\":\n await createKey(rawArgs);\n break;\n case \"update\":\n await updateKey(rawArgs);\n break;\n case \"revoke\":\n await revokeKey(rawArgs);\n break;\n case \"scopes\":\n await listScopes(rawArgs);\n break;\n default:\n // The shape every other family uses. This one printed a bare line\n // to stderr *and* the whole help page to stdout, so a typo wrote\n // twenty lines to a stream a `--json` caller reads, with no `✗`, no\n // pointer at `--help`, and no did-you-mean — `craete` is one\n // transposition from `create`.\n unknownCommand(subcommand, API_KEYS_SUBCOMMANDS, \"api-keys\");\n }\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Showing a key\n ═══════════════════════════════════════════════════════════════ */\n\nfunction keyStatus(key: ApiKeyMasked, now: Date): string {\n if (key.revoked_at) return chalk.red(\"revoked\");\n if (key.expires_at && new Date(key.expires_at) < now) return chalk.yellow(\"expired\");\n return chalk.green(\"active\");\n}\n\n/**\n * The lines that describe one key: what it is, what it may do and whom it\n * runs as.\n *\n * A service key runs as the RLS role `service` plus its own `roles`; a\n * personal key runs as its owner's roles as they are when it is used, so it\n * has none of its own to show.\n *\n * Exported so its tests can read the lines without a server.\n */\nexport function describeKey(key: ApiKeyMasked, now: Date = new Date()): string[] {\n const field = (label: string, value: string) => ` ${chalk.gray(`${label}:`.padEnd(12))}${value}`;\n const roles = key.kind === \"personal\"\n ? `its owner's (${key.owner_uid ?? \"unknown\"})`\n : [\"service\", ...key.roles].join(\", \");\n\n const lines = [\n ` ${chalk.bold(key.name)} ${chalk.gray(`[${key.key_prefix}•••]`)} ${keyStatus(key, now)}`,\n field(\"ID\", key.id),\n field(\"Kind\", key.kind),\n field(\"Scopes\", key.scopes.length > 0 ? key.scopes.join(\", \") : chalk.gray(\"none\")),\n field(\"Roles\", roles)\n ];\n if (key.rate_limit !== null) lines.push(field(\"Rate limit\", `${key.rate_limit} requests / 15 min`));\n if (key.expires_at) lines.push(field(\"Expires\", new Date(key.expires_at).toLocaleDateString()));\n lines.push(field(\"Created\", new Date(key.created_at).toLocaleDateString()));\n if (key.last_used_at) lines.push(field(\"Last used\", new Date(key.last_used_at).toLocaleDateString()));\n return lines;\n}\n\n/* ═══════════════════════════════════════════════════════════════\n list\n ═══════════════════════════════════════════════════════════════ */\n\n/** The flags `rebase api-keys list` takes: none of its own. */\nexport const LIST_KEYS_FLAGS = { ...PROJECT_TARGET_FLAGS } as const;\n\nasync function listKeys(rawArgs: string[]): Promise<void> {\n parseCommandArgs({\n spec: LIST_KEYS_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"api-keys list\",\n maxPositionals: 0\n });\n\n const connection = await connect(rawArgs);\n const { client } = connection;\n let keys: ApiKeyMasked[];\n try {\n ({ keys } = await client.apiKeys.listKeys());\n } catch (e: unknown) {\n fail(\"Failed to list API keys\", e, connection);\n }\n\n console.log(\"\");\n console.log(chalk.bold(\" 🔑 API Keys\"));\n console.log(\"\");\n\n if (keys.length === 0) {\n console.log(chalk.gray(\" No API keys found.\"));\n console.log(\"\");\n return;\n }\n\n const now = new Date();\n for (const key of keys) {\n for (const line of describeKey(key, now)) console.log(line);\n console.log(\"\");\n }\n}\n\n/* ═══════════════════════════════════════════════════════════════\n get\n ═══════════════════════════════════════════════════════════════ */\n\n/** The flags `rebase api-keys get` takes. */\nexport const GET_KEY_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--id\": String\n} as const;\n\n/**\n * Which key this invocation names, as a positional or as `--id`.\n *\n * Exported so its tests can drive the real parser rather than a copy of it.\n */\nexport function resolveGetKeyArgs(rawArgs: string[]): { id?: string } {\n const { flags, positionals } = parseCommandArgs({\n spec: GET_KEY_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"api-keys get\",\n maxPositionals: 1\n });\n\n return { id: flags[\"--id\"] || positionals[0] };\n}\n\nasync function getKey(rawArgs: string[]): Promise<void> {\n const { id } = resolveGetKeyArgs(rawArgs);\n if (!id) {\n throw new UsageError(\"Key ID is required: rebase api-keys get <key-id> (`rebase api-keys list` shows them).\");\n }\n\n const connection = await connect(rawArgs);\n const { client } = connection;\n let key: ApiKeyMasked;\n try {\n ({ key } = await client.apiKeys.getKey(id));\n } catch (e: unknown) {\n fail(\"Failed to read API key\", e, connection);\n }\n\n console.log(\"\");\n for (const line of describeKey(key)) console.log(line);\n console.log(\"\");\n}\n\n/* ═══════════════════════════════════════════════════════════════\n create\n ═══════════════════════════════════════════════════════════════ */\n\n/** The flags `rebase api-keys create` takes. */\nexport const CREATE_KEY_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--name\": String,\n \"--scopes\": [String],\n \"--full-access\": Boolean,\n \"--roles\": [String],\n \"--rate-limit\": Number,\n \"--expires-in\": String,\n \"--expires-at\": String,\n \"-n\": \"--name\"\n} satisfies arg.Spec;\n\n/**\n * Options `create` refuses by name, each with the flag that does that job.\n *\n * Checked before the line is parsed: the strict parser would answer them\n * \"unknown option\", which does not say what to type instead.\n */\nexport const RETIRED_CREATE_OPTIONS: Readonly<Record<string, string>> = {\n \"--permissions\":\n \"--permissions is gone: name what the key may do with --scopes, e.g. \" +\n \"--scopes data:read:posts,data:write:posts (`rebase api-keys scopes` lists them).\",\n \"--admin\":\n \"--admin is gone: give the key the RLS role with --roles admin, and the admin-plane scopes it needs \" +\n \"with --scopes, e.g. --scopes users:read,schema:read.\",\n \"--expires\":\n \"--expires is gone: use --expires-in <days> (e.g. --expires-in 90) or --expires-at <ISO date>.\"\n};\n\n/** Refuse a retired option, wherever on the line and however it is spelled. */\nfunction refuseRetiredOptions(rawArgs: string[]): void {\n for (const token of rawArgs.slice(2)) {\n // Past `--` everything is a value, never an option.\n if (token === \"--\") return;\n const name = token.split(\"=\", 1)[0];\n const replacement = Object.prototype.hasOwnProperty.call(RETIRED_CREATE_OPTIONS, name)\n ? RETIRED_CREATE_OPTIONS[name]\n : undefined;\n if (replacement) throw new UsageError(replacement);\n }\n}\n\n/**\n * A list flag's values, whether repeated (`--scopes a --scopes b`) or\n * comma-separated (`--scopes a,b`) — or both — trimmed and deduplicated.\n * Whitespace separates too: no scope or role name contains any.\n */\nfunction splitList(values: readonly string[] | undefined): string[] {\n const out = new Set<string>();\n for (const value of values ?? []) {\n for (const entry of value.split(/[\\s,]+/)) {\n if (entry) out.add(entry);\n }\n }\n return [...out];\n}\n\nconst DAY_MS = 86_400_000;\n\nfunction resolveExpiry(expiresIn: string | undefined, expiresAt: string | undefined, now: Date): string | null {\n if (expiresIn !== undefined && expiresAt !== undefined) {\n throw new UsageError(\"Pass --expires-in or --expires-at, not both.\");\n }\n if (expiresIn !== undefined) {\n const days = /^\\d+$/.test(expiresIn.trim()) ? Number(expiresIn.trim()) : NaN;\n if (!Number.isSafeInteger(days) || days < 1) {\n throw new UsageError(`--expires-in takes a whole number of days, e.g. --expires-in 90 (got \"${expiresIn}\").`);\n }\n return new Date(now.getTime() + days * DAY_MS).toISOString();\n }\n if (expiresAt !== undefined) {\n const parsed = new Date(expiresAt);\n if (isNaN(parsed.getTime())) {\n throw new UsageError(`--expires-at takes an ISO date, e.g. --expires-at 2027-01-31 (got \"${expiresAt}\").`);\n }\n if (parsed.getTime() <= now.getTime()) {\n throw new UsageError(`--expires-at must be in the future (got ${parsed.toISOString()}).`);\n }\n return parsed.toISOString();\n }\n return null;\n}\n\n/** What `rebase api-keys create` was asked to mint. */\nexport interface CreateKeyPlan {\n name: string;\n /** The scopes named with `--scopes`, or `\"held\"` for `--full-access`. */\n scopes: string[] | \"held\";\n /** RLS roles beside `service`. */\n roles: string[];\n rate_limit: number | null;\n expires_at: string | null;\n}\n\n/**\n * What this invocation asks to be created.\n *\n * The name may be given either way — `--name \"My Key\"` or as the single\n * positional — and under the old permissive parse an undeclared flag became\n * that positional: `rebase api-keys create --debug --full-access` created a\n * key called `--debug` with access to everything, and `--debug` is what the\n * CLI prints after every failure as the thing to re-run with. Strict parsing\n * makes the flag an error instead of a name.\n *\n * What the key may do has to be asked for by name — `--scopes` or\n * `--full-access` — never defaulted: a forgotten flag must not mint a key that\n * reaches everything.\n *\n * Exported so its tests can drive the real parser rather than a copy of it.\n */\nexport function resolveCreateKeyArgs(rawArgs: string[], now: Date = new Date()): CreateKeyPlan {\n refuseRetiredOptions(rawArgs);\n\n const { flags, positionals } = parseCommandArgs({\n spec: CREATE_KEY_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"api-keys create\",\n maxPositionals: 1\n });\n\n const name = (flags[\"--name\"] || positionals[0] || \"\").trim();\n if (!name) {\n throw new UsageError('A key needs a name: rebase api-keys create \"CI\" --scopes data:read');\n }\n\n const named = splitList(flags[\"--scopes\"]);\n const fullAccess = flags[\"--full-access\"] === true;\n if (fullAccess && named.length > 0) {\n throw new UsageError(\"Pass --scopes or --full-access, not both: --full-access already means every scope you hold.\");\n }\n if (!fullAccess && named.length === 0) {\n throw new UsageError(\n \"Name what the key may do: --scopes data:read:posts,data:write:posts, or --full-access for every \" +\n \"scope you hold. `rebase api-keys scopes` lists them.\"\n );\n }\n\n const rateLimit = flags[\"--rate-limit\"];\n if (rateLimit !== undefined && (!Number.isSafeInteger(rateLimit) || rateLimit < 1)) {\n throw new UsageError(\"--rate-limit takes a whole number of requests per 15-minute window, e.g. --rate-limit 500.\");\n }\n\n return {\n name,\n scopes: fullAccess ? \"held\" : named,\n roles: splitList(flags[\"--roles\"]),\n rate_limit: rateLimit ?? null,\n expires_at: resolveExpiry(flags[\"--expires-in\"], flags[\"--expires-at\"], now)\n };\n}\n\n/**\n * The scopes `--full-access` puts on a key: every one the caller holds, less\n * key management, which no key may hold.\n *\n * Exported so its tests can check the subtraction without a server.\n */\nexport function grantableScopes(held: readonly string[]): string[] {\n const management: readonly string[] = KEY_MANAGEMENT_SCOPES;\n return held.filter(entry => !management.includes(parseScope(entry)?.scope ?? entry));\n}\n\nasync function createKey(rawArgs: string[]): Promise<void> {\n const plan = resolveCreateKeyArgs(rawArgs);\n const connection = await connect(rawArgs);\n const { client } = connection;\n\n let scopes: string[];\n if (plan.scopes === \"held\") {\n let held: string[];\n try {\n ({ held } = await client.personalKeys.listScopes());\n } catch (e: unknown) {\n fail(\"Failed to read the scopes you hold\", e, connection);\n }\n scopes = grantableScopes(held);\n if (scopes.length === 0) {\n console.error(chalk.red(\"✗ You hold no scope a key may carry, so --full-access has nothing to grant.\"));\n process.exit(1);\n }\n } else {\n scopes = plan.scopes;\n }\n\n const request: CreateApiKeyRequest = {\n name: plan.name,\n scopes,\n ...(plan.roles.length > 0 ? { roles: plan.roles } : {}),\n ...(plan.rate_limit !== null ? { rate_limit: plan.rate_limit } : {}),\n ...(plan.expires_at !== null ? { expires_at: plan.expires_at } : {})\n };\n\n let created: ApiKeyWithSecret;\n try {\n ({ key: created } = await client.apiKeys.createKey(request));\n } catch (e: unknown) {\n fail(\"Failed to create API key\", e, connection);\n }\n\n console.log(\"\");\n console.log(chalk.bold.green(\" ✓ API key created\"));\n console.log(\"\");\n for (const line of describeKey(created)) console.log(line);\n console.log(\"\");\n console.log(chalk.bold.yellow(\" ⚠ Copy your key now — it won't be shown again:\"));\n console.log(\"\");\n console.log(` ${chalk.cyan(created.key)}`);\n console.log(\"\");\n}\n\n/* ═══════════════════════════════════════════════════════════════\n update\n ═══════════════════════════════════════════════════════════════ */\n\n/** The flags `rebase api-keys update` takes. */\nexport const UPDATE_KEY_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--id\": String,\n \"--name\": String,\n \"--scopes\": [String],\n \"--roles\": [String],\n \"--rate-limit\": Number,\n \"--no-rate-limit\": Boolean,\n \"--expires-in\": String,\n \"--expires-at\": String,\n \"--no-expiry\": Boolean,\n \"-n\": \"--name\"\n} satisfies arg.Spec;\n\n/**\n * Which key, and what to change on it: only what the line names is sent, so\n * an update never resets a field it did not mention. Exported for its tests.\n */\nexport function resolveUpdateKeyArgs(rawArgs: string[], now: Date = new Date()): { id?: string; change: UpdateApiKeyRequest } {\n const { flags, positionals } = parseCommandArgs({\n spec: UPDATE_KEY_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"api-keys update\",\n maxPositionals: 1\n });\n if (flags[\"--rate-limit\"] !== undefined && flags[\"--no-rate-limit\"]) {\n throw new UsageError(\"--rate-limit sets a limit and --no-rate-limit removes it; give one.\");\n }\n if ((flags[\"--expires-in\"] !== undefined || flags[\"--expires-at\"] !== undefined) && flags[\"--no-expiry\"]) {\n throw new UsageError(\"--expires-in/--expires-at set an expiry and --no-expiry removes it; give one.\");\n }\n const change: UpdateApiKeyRequest = {};\n if (flags[\"--name\"] !== undefined) change.name = flags[\"--name\"];\n if (flags[\"--scopes\"] !== undefined) change.scopes = splitList(flags[\"--scopes\"]);\n if (flags[\"--roles\"] !== undefined) change.roles = splitList(flags[\"--roles\"]);\n if (flags[\"--rate-limit\"] !== undefined) change.rate_limit = flags[\"--rate-limit\"];\n if (flags[\"--no-rate-limit\"]) change.rate_limit = null;\n const expiry = resolveExpiry(flags[\"--expires-in\"], flags[\"--expires-at\"], now);\n if (expiry !== null) change.expires_at = expiry;\n if (flags[\"--no-expiry\"]) change.expires_at = null;\n if (Object.keys(change).length === 0) {\n throw new UsageError(\"Nothing to change: pass --name, --scopes, --roles, --rate-limit, --no-rate-limit, --expires-in, --expires-at or --no-expiry.\");\n }\n return { id: flags[\"--id\"] || positionals[0], change };\n}\n\nasync function updateKey(rawArgs: string[]): Promise<void> {\n const { id, change } = resolveUpdateKeyArgs(rawArgs);\n if (!id) {\n throw new UsageError(\"Key ID is required: rebase api-keys update <key-id> --scopes … (`rebase api-keys list` shows them).\");\n }\n const connection = await connect(rawArgs);\n let key: ApiKeyMasked;\n try {\n ({ key } = await connection.client.apiKeys.updateKey(id, change));\n } catch (e: unknown) {\n fail(\"Failed to update API key\", e, connection);\n }\n console.log(\"\");\n console.log(chalk.bold.green(\" ✓ API key updated\"));\n console.log(\"\");\n for (const line of describeKey(key)) console.log(line);\n console.log(\"\");\n}\n\n/* ═══════════════════════════════════════════════════════════════\n revoke\n ═══════════════════════════════════════════════════════════════ */\n\n/** The flags `rebase api-keys revoke` takes. */\nexport const REVOKE_KEY_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--id\": String\n} as const;\n\n/**\n * Which key this invocation names.\n *\n * The id is a positional, so the permissive parse handed one straight to the\n * DELETE: `rebase api-keys revoke --foo` sent\n * `DELETE /api/admin/api-keys/--foo`, and `rebase --debug api-keys revoke <id>`\n * shifted the words along and revoked the key named `revoke`.\n *\n * Exported so its tests can drive the real parser rather than a copy of it.\n */\nexport function resolveRevokeKeyArgs(rawArgs: string[]): { id?: string; yes: boolean } {\n const { flags, positionals } = parseCommandArgs({\n spec: REVOKE_KEY_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"api-keys revoke\",\n maxPositionals: 1\n });\n\n return { id: flags[\"--id\"] || positionals[0], yes: flags[\"--yes\"] === true };\n}\n\nasync function revokeKey(rawArgs: string[]): Promise<void> {\n const { id, yes } = resolveRevokeKeyArgs(rawArgs);\n\n if (!id) {\n throw new UsageError(\"Key ID is required: rebase api-keys revoke <key-id> (`rebase api-keys list` shows them).\");\n }\n\n const connection = await connect(rawArgs);\n // Everything holding the key stops working at once, and a revoked key\n // cannot be restored — only replaced.\n await confirmDestructive({ yes, prompt: `Revoke API key ${id} on ${connection.baseUrl}? Anything using it stops working.` });\n const { client } = connection;\n try {\n await client.apiKeys.revokeKey(id);\n } catch (e: unknown) {\n fail(\"Failed to revoke API key\", e, connection);\n }\n\n console.log(\"\");\n console.log(chalk.bold.green(\" ✓ API key revoked\"));\n console.log(` ${chalk.gray(\"ID:\")} ${id}`);\n console.log(\"\");\n}\n\n/* ═══════════════════════════════════════════════════════════════\n scopes\n ═══════════════════════════════════════════════════════════════ */\n\n/** The flags `rebase api-keys scopes` takes: none of its own. */\nexport const SCOPES_LIST_FLAGS = { ...PROJECT_TARGET_FLAGS } as const;\n\nconst PLANES: ReadonlyArray<{ plane: ScopeSummary[\"plane\"]; title: string; note: string }> = [\n { plane: \"data\", title: \"Data\", note: \"narrow what a key reaches; row-level security still decides the rows\" },\n { plane: \"admin\", title: \"Admin\", note: \"nobody holds these unless a role grants them; the admin role holds all\" },\n { plane: \"app\", title: \"App\", note: \"declared by this app under auth.scopes on the users table\" }\n];\n\n/**\n * The scope catalogue as printed lines: one section per plane, each scope with\n * its label and what its target names, marked when the caller holds it.\n *\n * Exported so its tests can read the lines without a server.\n */\nexport function describeScopes(scopes: readonly ScopeSummary[], held: readonly string[]): string[] {\n const management: readonly string[] = KEY_MANAGEMENT_SCOPES;\n const width = Math.max(0, ...scopes.map(s => s.scope.length)) + 2;\n const labelWidth = Math.max(0, ...scopes.map(s => s.label.length)) + 2;\n const lines: string[] = [];\n for (const { plane, title, note } of PLANES) {\n const inPlane = scopes.filter(s => s.plane === plane);\n if (inPlane.length === 0) continue;\n lines.push(` ${chalk.bold(title)} ${chalk.gray(`— ${note}`)}`);\n for (const s of inPlane) {\n const mark = held.includes(s.scope) ? chalk.green(\"✓\") : \" \";\n const extra = management.includes(s.scope)\n ? chalk.gray(\"never on a key\")\n : s.target ? chalk.gray(`:<${s.target}>`) : \"\";\n lines.push(` ${mark} ${s.scope.padEnd(width)}${extra ? s.label.padEnd(labelWidth) : s.label}${extra}`);\n }\n lines.push(\"\");\n }\n return lines;\n}\n\nasync function listScopes(rawArgs: string[]): Promise<void> {\n parseCommandArgs({\n spec: SCOPES_LIST_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"api-keys scopes\",\n maxPositionals: 0\n });\n\n const connection = await connect(rawArgs);\n const { client } = connection;\n let catalogue: { scopes: ScopeSummary[]; held: string[] };\n try {\n catalogue = await client.personalKeys.listScopes();\n } catch (e: unknown) {\n fail(\"Failed to read the scopes\", e, connection);\n }\n\n console.log(\"\");\n console.log(chalk.bold(\" Scopes\") + chalk.gray(\" (✓ = you hold it; :<target> narrows it to one)\"));\n console.log(\"\");\n for (const line of describeScopes(catalogue.scopes, catalogue.held)) console.log(line);\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Help\n ═══════════════════════════════════════════════════════════════ */\n\nfunction printApiKeysHelp() {\n const keyable = ADMIN_SCOPES.filter(scope => !(KEY_MANAGEMENT_SCOPES as readonly string[]).includes(scope));\n console.log(`\n${chalk.bold(\"rebase api-keys\")} — Manage service API keys\n\n${chalk.green.bold(\"Usage\")}\n rebase api-keys ${chalk.blue(\"<command>\")} [options]\n\n${chalk.green.bold(\"Commands\")}\n ${chalk.blue.bold(\"list\")} List the service keys: kind, scopes, roles\n ${chalk.blue.bold(\"get\")} ${chalk.gray(\"<id>\")} Show one key\n ${chalk.blue.bold(\"create\")} Create a service key\n ${chalk.blue.bold(\"update\")} ${chalk.gray(\"<id>\")} Change a key's name, scopes, roles, limit or expiry\n ${chalk.blue.bold(\"revoke\")} ${chalk.gray(\"<id>\")} Revoke a key ${chalk.gray(\"(asks first; --yes skips)\")}\n ${chalk.blue.bold(\"scopes\")} List the scopes this backend knows, and which you hold\n\n${chalk.green.bold(\"create Options\")}\n ${chalk.blue(\"--name, -n\")} Key name ${chalk.gray(\"(required; or the first argument)\")}\n ${chalk.blue(\"--scopes\")} What the key may do, comma-separated or repeated\n ${chalk.gray(\"(required unless --full-access)\")}\n ${chalk.blue(\"--full-access\")} Every scope you hold, less keys:read and keys:write\n ${chalk.blue(\"--roles\")} RLS roles the key runs as beside ${chalk.gray(\"service\")}, e.g. admin\n ${chalk.blue(\"--rate-limit\")} Requests per 15-min window ${chalk.gray(\"(default: the server's API-key limit)\")}\n ${chalk.blue(\"--expires-in\")} Days until the key expires\n ${chalk.blue(\"--expires-at\")} Expiry as an ISO date, e.g. 2027-01-31\n\n${chalk.green.bold(\"update Options\")} ${chalk.gray(\"only what you name changes\")}\n ${chalk.blue(\"--name, -n\")} New name\n ${chalk.blue(\"--scopes\")} Replace the scopes ${chalk.gray(\"(never more than you hold)\")}\n ${chalk.blue(\"--roles\")} Replace the roles\n ${chalk.blue(\"--rate-limit\")} Requests per 15-min window; ${chalk.blue(\"--no-rate-limit\")} back to the server's\n ${chalk.blue(\"--expires-in\")} Days from now; ${chalk.blue(\"--expires-at\")} an ISO date; ${chalk.blue(\"--no-expiry\")} never\n\n${chalk.green.bold(\"get / update / revoke Options\")}\n ${chalk.blue(\"--id\")} API key ID ${chalk.gray(\"(or the first argument)\")}\n\n${chalk.green.bold(\"Target options\")} ${chalk.gray(\"(every command)\")}\n ${chalk.blue(\"--project <slug>\")} A Rebase Cloud project, through the console's Studio proxy\n ${chalk.blue(\"--cloud\")} The Rebase Cloud project this directory is linked to\n ${chalk.blue(\"--url <server>\")} A server at this address ${chalk.gray(\"(else REBASE_BASE_URL, then \\`rebase dev\\`)\")}\n ${chalk.blue(\"--token <bearer>\")} Send this bearer instead of the service key ${chalk.gray(\"(an rk_ key is always refused here)\")}\n ${chalk.blue(\"--session\")} Send the session \\`rebase auth login\\` stored ${chalk.gray(\"(an admin's)\")}\n ${chalk.blue(\"--anon\")} Send no credential\n ${chalk.blue(\"--json\")} Accepted; these commands print text\n ${chalk.blue(\"--yes\")} Skip the revoke prompt\n\n${chalk.green.bold(\"Scopes\")}\n A scope is ${chalk.blue(\"resource:action\")}, optionally narrowed to one target:\n ${chalk.blue(\"data:read:posts\")} reads the posts table and nothing else.\n Data ${DATA_PLANE_SCOPES.join(\", \")}\n ${chalk.gray(\"target: a table slug, a storage source id (default), a function name\")}\n Admin ${keyable.join(\", \")}\n App whatever the app declares under auth.scopes ${chalk.gray(\"(rebase api-keys scopes)\")}\n\n${chalk.green.bold(\"Examples\")}\n rebase api-keys list\n rebase api-keys create \"Analytics\" --scopes data:read:events\n rebase api-keys create -n \"Blog CI\" --scopes data:read:posts,data:write:posts --expires-in 90\n rebase api-keys create -n \"Mailer\" --scopes \"functions:invoke:send-email,storage:read:(default)\"\n rebase api-keys create -n \"Ops\" --full-access --roles admin --expires-at 2027-01-31\n rebase api-keys get abc123-def456\n rebase api-keys update abc123-def456 --scopes data:read:posts --expires-in 30\n rebase api-keys revoke abc123-def456 --yes\n`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAa,uBAAuB;CAAC;CAAQ;CAAO;CAAU;CAAU;CAAU;AAAQ;;;;;;;;;;;;;;AAyD1F,eAAe,QAAQ,SAAwC;CAE3D,MAAM,SAAS,MAAM,cADD,IAAI,sBAAsB;EAAE,MAAM,QAAQ,MAAM,CAAC;EAAG,YAAY;CAAK,CACtD,GAAa,EAAE,SAAS,WAAW,CAAC;CACvE,MAAM,QAAQ,MAAM,OAAO,OAAO;CAClC,MAAM,SAAS,mBAAmB;EAC9B,SAAS,OAAO;EAChB,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;EACzB,UAAU;EACV,SAAS,EAAE,cAAc,aAAa,EAAE;EACxC,MAAM;GAAE,gBAAgB;GAAO,aAAa;EAAM;CACtD,CAAC;CACD,MAAM,cAAc,OAAO,eAAe,gBAAgB,kBAAkB,gBAAgB,CAAC,CAAC,EAAE,WAAW,KAAA;CAC3G,OAAO;EACH;EACA,SAAS,OAAO;EAChB,aAAa,gBAAgB,gBAAgB,gBAAgB;CACjE;AACJ;;;;;;;;AASA,SAAgB,gBACZ,QACA,OACA,SACA,cAAkC,sBAC1B;CACR,IAAI,EAAE,iBAAiB,iBACnB,OAAO,CAAC,KAAK,OAAO,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;CAEpF,IAAI,MAAM,WAAW,KAAK,MAAM,SAAS,iBACrC,OAAO,CAAC,KAAK,O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MAAM,KAAK,QAAQ,EAAE;IACrB,MAAM,KAAK,QAAQ,EAAE;IACrB,MAAM,KAAK,OAAO,EAAE;;EAEtB,MAAM,MAAM,KAAK,QAAQ,EAAE;eACd,MAAM,KAAK,iBAAiB,EAAE;IACzC,MAAM,KAAK,iBAAiB,EAAE;WACvB,kBAAkB,KAAK,IAAI,EAAE;WAC7B,MAAM,KAAK,sEAAsE,EAAE;WACnF,QAAQ,KAAK,IAAI,EAAE;uDACyB,MAAM,KAAK,0BAA0B,EAAE;;EAE5F,MAAM,MAAM,KAAK,UAAU,EAAE;;;;;;;;;CAS9B;AACD"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { n as unknownCommand } from "./unknown-command-DnZ2uhGs.js";
|
|
2
|
+
import { a as wantsHelp, n as parseCommandArgs } from "./args-DHyrshtI.js";
|
|
3
|
+
import { i as failAsJson, p as requireProjectRoot } from "./project-DALmhb5R.js";
|
|
4
|
+
import { E as synthesizeManifest, O as writeManifest, T as staticAppAddress, _ as findBackendApp, b as loadManifest, l as ManifestError, p as assessManagedCompatibility, x as manifestExists, y as formatAppAddress } from "./manifest-RjqxfCpb.js";
|
|
5
|
+
import { i as runningBackendUrl, n as devServerUrl } from "./dev-server-2XHSHM_q.js";
|
|
6
|
+
import { H as readLink } from "./context-BOMEoKxn.js";
|
|
7
|
+
import { r as foldableApps } from "./fold-static-2t3UUX4z.js";
|
|
7
8
|
import chalk from "chalk";
|
|
8
9
|
import path from "path";
|
|
9
10
|
//#region src/commands/apps.ts
|
|
@@ -139,11 +140,13 @@ function sameRoot(a, b) {
|
|
|
139
140
|
* declaration knows.
|
|
140
141
|
*
|
|
141
142
|
* An inferred app takes the name the file gives the app it matches — the
|
|
142
|
-
* backend, or the static app with the same `root` — and that app's `path
|
|
143
|
-
* `cms`. The name is the app's identity on a
|
|
144
|
-
* would deploy a second app beside the first.
|
|
145
|
-
* app is registered on. `cms` is a client-side
|
|
146
|
-
*
|
|
143
|
+
* backend, or the static app with the same `root` — and that app's `path`,
|
|
144
|
+
* `cms`, `routes` and `frameAncestors`. The name is the app's identity on a
|
|
145
|
+
* deployed project, so renaming it would deploy a second app beside the first.
|
|
146
|
+
* `path` can carry the hostname the app is registered on. `cms` is a client-side
|
|
147
|
+
* route that nothing in the project shows, and the routes and the origins that
|
|
148
|
+
* may frame the app are decisions nothing in the project records. Everything
|
|
149
|
+
* else is inferred again, which is what `--force` asks for.
|
|
147
150
|
*
|
|
148
151
|
* A declared app the inference does not find is returned in `removed`, so the
|
|
149
152
|
* command can say so rather than drop it in silence.
|
|
@@ -171,7 +174,9 @@ function keepDeclaredIdentity(inferred, declared) {
|
|
|
171
174
|
apps[keptName] = {
|
|
172
175
|
...app,
|
|
173
176
|
...address !== void 0 ? { path: address } : {},
|
|
174
|
-
...declaredApp.cms !== void 0 ? { cms: declaredApp.cms } : {}
|
|
177
|
+
...declaredApp.cms !== void 0 ? { cms: declaredApp.cms } : {},
|
|
178
|
+
...declaredApp.routes !== void 0 ? { routes: declaredApp.routes } : {},
|
|
179
|
+
...declaredApp.frameAncestors !== void 0 ? { frameAncestors: declaredApp.frameAncestors } : {}
|
|
175
180
|
};
|
|
176
181
|
}
|
|
177
182
|
const removed = Object.entries(declared.apps).filter(([name]) => !matched.has(name)).map(([name, app]) => ({
|
|
@@ -323,4 +328,4 @@ function loadManifestOrExit(projectRoot, asJson = false) {
|
|
|
323
328
|
//#endregion
|
|
324
329
|
export { APPS_SUBCOMMANDS, appsCommand };
|
|
325
330
|
|
|
326
|
-
//# sourceMappingURL=apps-
|
|
331
|
+
//# sourceMappingURL=apps-DBTRoOeP.js.map
|