@rebasepro/cli 0.23.0 → 0.24.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/README.md +19 -3
- package/bin/rebase.js +1 -1
- package/dist/{branch-pointer-dBiClJ0p.js → branch-pointer-kk9F5FBO.js} +2 -2
- package/dist/{branch-pointer-dBiClJ0p.js.map → branch-pointer-kk9F5FBO.js.map} +1 -1
- package/dist/bundle.d.ts +6 -2
- package/dist/cli.d.ts +21 -0
- package/dist/commands/__test_support__/parser-specs.d.ts +13 -0
- package/dist/commands/agent-setup.d.ts +116 -0
- package/dist/commands/api-keys.d.ts +84 -23
- package/dist/commands/apps.d.ts +17 -0
- package/dist/commands/auth.d.ts +7 -0
- package/dist/commands/build.d.ts +5 -1
- package/dist/commands/cloud/auth.d.ts +4 -3
- package/dist/commands/cloud/bundle-deploy.d.ts +45 -0
- package/dist/commands/cloud/context.d.ts +44 -5
- package/dist/commands/cloud/cron.d.ts +53 -0
- package/dist/commands/cloud/debug.d.ts +134 -0
- package/dist/commands/cloud/index.d.ts +89 -12
- package/dist/commands/cloud/token-capabilities.d.ts +76 -0
- package/dist/commands/cloud/tokens.d.ts +23 -0
- package/dist/commands/db.d.ts +15 -1
- package/dist/commands/dev.d.ts +78 -7
- package/dist/commands/doctor.d.ts +5 -0
- package/dist/commands/generate_sdk.d.ts +3 -2
- package/dist/commands/init.d.ts +57 -14
- package/dist/commands/schema.d.ts +6 -0
- package/dist/commands/skills.d.ts +109 -5
- package/dist/commands/start.d.ts +29 -0
- package/dist/{daemon-DR9Tk0La.js → daemon-C8p32i-n.js} +5 -3
- package/dist/daemon-C8p32i-n.js.map +1 -0
- package/dist/dev-db/daemon.d.ts +10 -0
- package/dist/dev-db/prepare.d.ts +10 -0
- package/dist/fold-static.d.ts +26 -3
- package/dist/index.es.js +12086 -9459
- package/dist/index.es.js.map +1 -1
- package/dist/manifest.d.ts +41 -1
- package/dist/package-manager-CXQevsE1.js +193 -0
- package/dist/package-manager-CXQevsE1.js.map +1 -0
- package/dist/{project-3WCbrrfW.js → project-DmaGLmH2.js} +4 -183
- package/dist/project-DmaGLmH2.js.map +1 -0
- package/dist/upgrade.d.ts +14 -2
- package/dist/utils/path-flags.d.ts +18 -0
- package/dist/version-DsgBmP22.js +58 -0
- package/dist/version-DsgBmP22.js.map +1 -0
- package/package.json +7 -7
- package/templates/eject/backend/src/index.ts +14 -1
- package/templates/overlays/baas/ai-instructions.md +1 -1
- package/templates/overlays/baas/config/storage.ts +5 -3
- package/templates/template/.cursorrules +1 -1
- package/templates/template/.env.example +10 -6
- package/templates/template/.github/copilot-instructions.md +1 -1
- package/templates/template/.mcp.json +2 -2
- package/templates/template/.windsurfrules +1 -1
- package/templates/template/AGENTS.md +1 -1
- package/templates/template/CLAUDE.md +1 -1
- package/templates/template/README.md +10 -11
- package/templates/template/ai-instructions.md +3 -3
- package/templates/template/backend/functions/hello.ts +8 -0
- package/templates/template/backend/package.json +1 -1
- package/templates/template/config/storage.ts +5 -3
- package/templates/template/docker-compose.yml +6 -6
- package/templates/template/gitignore +6 -1
- package/templates/template/package.json +4 -3
- package/templates/template/scripts/example.ts +4 -3
- package/dist/daemon-DR9Tk0La.js.map +0 -1
- package/dist/project-3WCbrrfW.js.map +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type CloudClient } from "./context.js";
|
|
2
|
+
/** The control-plane function that mints runtime tokens. */
|
|
3
|
+
export declare const RUNTIME_TOKEN_FUNCTION = "runtime-token";
|
|
4
|
+
/** The one scope these commands ask the platform for. */
|
|
5
|
+
export declare const CRON_READ_SCOPE = "cron:read";
|
|
6
|
+
/** What `runtime-token` answers. */
|
|
7
|
+
export interface RuntimeTokenResponse {
|
|
8
|
+
/** `rpt_…` — the bearer the runtime accepts. */
|
|
9
|
+
token: string;
|
|
10
|
+
/** ISO timestamp; past it the runtime refuses the token. */
|
|
11
|
+
expiresAt?: string;
|
|
12
|
+
/** What the token was granted, which may be narrower than what was asked. */
|
|
13
|
+
scopes?: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A 404 that is about the route, not the project: the JSON envelope a Rebase
|
|
17
|
+
* backend answers for an unmatched path, or the bare one a router answers
|
|
18
|
+
* before that handler exists.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isMissingRoute(message: string | undefined): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Ask the control plane for a token the project's runtime will accept.
|
|
23
|
+
*
|
|
24
|
+
* A missing route means this control plane has no `runtime-token` function
|
|
25
|
+
* yet, which is a different fix from "no such project" and is said so.
|
|
26
|
+
*/
|
|
27
|
+
export declare function mintRuntimeToken(client: CloudClient, projectId: string, scopes: string[]): Promise<RuntimeTokenResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* GET a path on the runtime with a platform token, and refuse — with what it
|
|
30
|
+
* means for this command — anything but a 2xx.
|
|
31
|
+
*
|
|
32
|
+
* `notFound` words the 404, which means different things per route: no cron
|
|
33
|
+
* surface at all on the list, no such job on its logs.
|
|
34
|
+
*/
|
|
35
|
+
export declare function runtimeGet<T>(origin: string, path: string, token: string, notFound: {
|
|
36
|
+
message: string;
|
|
37
|
+
hint?: string;
|
|
38
|
+
code: string;
|
|
39
|
+
}): Promise<T>;
|
|
40
|
+
/** `2026-10-05T10:31:00.000Z` → `2026-10-05 10:31:00Z`, or `—`. */
|
|
41
|
+
export declare function shortTime(iso: string | undefined): string;
|
|
42
|
+
/** Milliseconds as `850ms`, `2.4s` or `3m 10s`. */
|
|
43
|
+
export declare function shortDuration(ms: number | undefined): string;
|
|
44
|
+
/** The flags `cron list` parses — the help page lists exactly these. */
|
|
45
|
+
export declare const CRON_LIST_FLAGS: {
|
|
46
|
+
"--host": StringConstructor;
|
|
47
|
+
};
|
|
48
|
+
/** The flags `cron logs` parses — the help page lists exactly these. */
|
|
49
|
+
export declare const CRON_LOGS_FLAGS: {
|
|
50
|
+
"--limit": NumberConstructor;
|
|
51
|
+
"--host": StringConstructor;
|
|
52
|
+
};
|
|
53
|
+
export declare function cronCommand(action: string | undefined, rawArgs: string[]): Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CloudClient } from "./context.js";
|
|
1
2
|
/** How a probe's outcome should be read. */
|
|
2
3
|
export type Verdict =
|
|
3
4
|
/** Behaving as a healthy deployment should. */
|
|
@@ -114,5 +115,138 @@ export declare function formatDuration(seconds: number): string;
|
|
|
114
115
|
* into seconds. Returns null when it is not a duration.
|
|
115
116
|
*/
|
|
116
117
|
export declare function parseSince(input: string | undefined): number | null;
|
|
118
|
+
/** One pod's entry in a `runtime-logs` answer. */
|
|
119
|
+
export interface RuntimeLogsPod {
|
|
120
|
+
pod: string;
|
|
121
|
+
state: string;
|
|
122
|
+
/** Lines this pod returned. */
|
|
123
|
+
lines: number;
|
|
124
|
+
message: string | null;
|
|
125
|
+
hint: string | null;
|
|
126
|
+
/** The server's per-pod BYTE budget cut this pod's output. Says nothing about the line limit. */
|
|
127
|
+
truncated?: boolean;
|
|
128
|
+
}
|
|
129
|
+
export interface RuntimeLogsResponse {
|
|
130
|
+
logs?: string;
|
|
131
|
+
pods?: RuntimeLogsPod[];
|
|
132
|
+
ordering?: string;
|
|
133
|
+
/** A byte budget or the pod-count ceiling cut the result. Says nothing about the line limit. */
|
|
134
|
+
truncated?: boolean;
|
|
135
|
+
state?: string;
|
|
136
|
+
message?: string | null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The most lines `runtime-logs` returns per pod.
|
|
140
|
+
*
|
|
141
|
+
* The control plane enforces this (`MAX_TAIL_LINES` in
|
|
142
|
+
* `saas/backend/functions/runtime-logs.ts`) by clamping a larger `tailLines`
|
|
143
|
+
* without saying so: its answer names neither the limit nor the value it used.
|
|
144
|
+
* `--tail 200000` therefore came back as 2000 lines reported as untruncated.
|
|
145
|
+
* The CLI clamps first, with the same number, so the lowering is something it
|
|
146
|
+
* can print rather than something that happened out of sight.
|
|
147
|
+
*/
|
|
148
|
+
export declare const SERVER_MAX_TAIL_LINES = 2000;
|
|
149
|
+
/** How many lines per pod a read asks for, and why that may be less than requested. */
|
|
150
|
+
export interface TailLimit {
|
|
151
|
+
/** What `--tail` asked for, or the view's default. */
|
|
152
|
+
requested: number;
|
|
153
|
+
/** What is sent: `requested`, lowered to {@link SERVER_MAX_TAIL_LINES}. */
|
|
154
|
+
applied: number;
|
|
155
|
+
/** Whether `--tail` was given, so a message can name the flag or the default. */
|
|
156
|
+
explicit: boolean;
|
|
157
|
+
/** Set when `applied < requested`: the sentence that says so. */
|
|
158
|
+
note: string | null;
|
|
159
|
+
}
|
|
160
|
+
export declare function resolveTail(requested: number, explicit: boolean): TailLimit;
|
|
161
|
+
/** What one pod's lines actually cover. */
|
|
162
|
+
export interface PodCoverage extends RuntimeLogsPod {
|
|
163
|
+
/** Earliest and latest timestamps among the lines this pod returned. */
|
|
164
|
+
firstTimestamp: string | null;
|
|
165
|
+
lastTimestamp: string | null;
|
|
166
|
+
/** A limit cut what this pod would otherwise have returned for the window. */
|
|
167
|
+
truncated: boolean;
|
|
168
|
+
/** Which limit: the per-pod line limit, or the server's byte budget. */
|
|
169
|
+
truncatedBy: "tail" | "bytes" | null;
|
|
170
|
+
/** The plain explanation, when truncated. */
|
|
171
|
+
truncatedReason: string | null;
|
|
172
|
+
/**
|
|
173
|
+
* Every line this pod holds in the window came back. With no window (read
|
|
174
|
+
* from the start), its first line is the start of its log.
|
|
175
|
+
*/
|
|
176
|
+
complete: boolean;
|
|
177
|
+
}
|
|
178
|
+
/** The window asked for against the window delivered. */
|
|
179
|
+
export interface LogCoverage {
|
|
180
|
+
/** Start of the window asked for, ISO. Null when reading each pod from its start. */
|
|
181
|
+
requestedFrom: string | null;
|
|
182
|
+
/** Earliest and latest timestamps across every line returned. */
|
|
183
|
+
firstTimestamp: string | null;
|
|
184
|
+
lastTimestamp: string | null;
|
|
185
|
+
pods: PodCoverage[];
|
|
186
|
+
truncated: boolean;
|
|
187
|
+
truncatedReasons: string[];
|
|
188
|
+
}
|
|
189
|
+
/** A span of milliseconds as `29d 23h`, `2h 5m`, `35m`, `40s`. */
|
|
190
|
+
export declare function formatSpan(ms: number): string;
|
|
191
|
+
/**
|
|
192
|
+
* Compare what a read covered with what it asked for.
|
|
193
|
+
*
|
|
194
|
+
* The server's `truncated` describes only its byte budgets and pod ceiling, so
|
|
195
|
+
* a pod that filled the line limit came back marked complete however much of
|
|
196
|
+
* the window it left unread. The line limit is the cut that matters most, and
|
|
197
|
+
* it is detected here: a pod that returned as many lines as the limit, whose
|
|
198
|
+
* earliest line is later than the start of the window, was cut by it.
|
|
199
|
+
*
|
|
200
|
+
* Filling the limit is the half that separates a cut from a young pod. A pod
|
|
201
|
+
* that started an hour ago also has no line older than an hour; it returned
|
|
202
|
+
* fewer lines than the limit, so what came back is its whole log, and nothing
|
|
203
|
+
* was cut.
|
|
204
|
+
*/
|
|
205
|
+
export declare function assessCoverage(opts: {
|
|
206
|
+
res: RuntimeLogsResponse;
|
|
207
|
+
lines: ParsedLogLine[];
|
|
208
|
+
/** The window asked for. Null reads each pod from its start. */
|
|
209
|
+
sinceSeconds: number | null;
|
|
210
|
+
tail: TailLimit;
|
|
211
|
+
now: number;
|
|
212
|
+
}): LogCoverage;
|
|
213
|
+
/**
|
|
214
|
+
* Resolve the public origin a project is served at — or `--host`, when given.
|
|
215
|
+
*
|
|
216
|
+
* Shared with `rebase cloud cron`, which reads the runtime at the same address
|
|
217
|
+
* `debug health` probes.
|
|
218
|
+
*/
|
|
219
|
+
export declare function resolveOrigin(rawArgs: string[], client: CloudClient, url: string, projectId: string): Promise<string>;
|
|
220
|
+
/** What `debug logs`, `errors` and `boot` parse. Their help pairs against this. */
|
|
221
|
+
export declare const LOG_VIEW_FLAGS: {
|
|
222
|
+
readonly "--since": StringConstructor;
|
|
223
|
+
readonly "--tail": NumberConstructor;
|
|
224
|
+
readonly "--previous": BooleanConstructor;
|
|
225
|
+
};
|
|
226
|
+
/** What `debug requests` parses. */
|
|
227
|
+
export declare const REQUESTS_FLAGS: {
|
|
228
|
+
readonly "--since": StringConstructor;
|
|
229
|
+
readonly "--tail": NumberConstructor;
|
|
230
|
+
};
|
|
231
|
+
/** What `debug health` parses. */
|
|
232
|
+
export declare const HEALTH_FLAGS: {
|
|
233
|
+
readonly "--collection": StringConstructor;
|
|
234
|
+
readonly "--function": StringConstructor;
|
|
235
|
+
readonly "--host": StringConstructor;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Whether a boot read reached each pod's start, which is where its startup
|
|
239
|
+
* lines are. A pod whose read was cut has not been looked at there, so finding
|
|
240
|
+
* no startup lines in it means nothing — and a line from later in its life
|
|
241
|
+
* that happens to mention `storage` is not its startup.
|
|
242
|
+
*
|
|
243
|
+
* Under `--since` a pod is never counted as reached: a complete read of the
|
|
244
|
+
* window starts at the pod's first line only if the pod started inside it, and
|
|
245
|
+
* nothing in the answer says whether it did.
|
|
246
|
+
*/
|
|
247
|
+
export declare function bootReach(pods: PodCoverage[], sinceSeconds: number | null): {
|
|
248
|
+
reachedStart: boolean;
|
|
249
|
+
unreached: string[];
|
|
250
|
+
};
|
|
117
251
|
export declare function debugCommand(action: string | undefined, rawArgs: string[]): Promise<void>;
|
|
118
252
|
export declare function printDebugHelp(): void;
|
|
@@ -1,19 +1,96 @@
|
|
|
1
1
|
import { type HelpAction } from "./context.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every flag in the `rebase cloud` family that takes a value, and the short
|
|
4
|
+
* spellings of them — the globals aside, which `GLOBAL_CLOUD_FLAGS` declares.
|
|
5
|
+
*
|
|
6
|
+
* {@link positionals} needs them for one reason: `arg` only consumes a flag's
|
|
7
|
+
* value when the flag is declared, and an undeclared one leaves its value
|
|
8
|
+
* behind as a bare word in the action's position. `rebase cloud deployments
|
|
9
|
+
* --limit 5` dispatched to an action called "5", `rebase cloud debug --host
|
|
10
|
+
* staging.example.com` to one called "staging.example.com", and `rebase cloud
|
|
11
|
+
* projects --name shop create` to one called "shop" — each refused as an unknown
|
|
12
|
+
* command, for a line the command's own help offers.
|
|
13
|
+
*
|
|
14
|
+
* Every value is `String` whatever the command reads it as: only consumption
|
|
15
|
+
* matters here, and the command parses the value itself. One list for the whole
|
|
16
|
+
* family works because no flag takes a value in one command and none in
|
|
17
|
+
* another; `value-flags.test.ts` holds that, and holds this list to the specs
|
|
18
|
+
* the commands declare in both directions, so a new value flag fails a test
|
|
19
|
+
* until it is added here.
|
|
20
|
+
*/
|
|
21
|
+
export declare const CLOUD_VALUE_FLAGS: {
|
|
22
|
+
readonly "--access-key-id": StringConstructor;
|
|
23
|
+
readonly "--autoscale-cpu-target": StringConstructor;
|
|
24
|
+
readonly "--autoscale-max": StringConstructor;
|
|
25
|
+
readonly "--backup-access-key-id": StringConstructor;
|
|
26
|
+
readonly "--backup-bucket": StringConstructor;
|
|
27
|
+
readonly "--backup-endpoint": StringConstructor;
|
|
28
|
+
readonly "--backup-secret-access-key": StringConstructor;
|
|
29
|
+
readonly "--base-domain": StringConstructor;
|
|
30
|
+
readonly "--branch": StringConstructor;
|
|
31
|
+
readonly "--bucket": StringConstructor;
|
|
32
|
+
readonly "--bundle-dir": StringConstructor;
|
|
33
|
+
readonly "--can": StringConstructor;
|
|
34
|
+
readonly "--collection": StringConstructor;
|
|
35
|
+
readonly "--connection-string": StringConstructor;
|
|
36
|
+
readonly "--cpu": StringConstructor;
|
|
37
|
+
readonly "--db": StringConstructor;
|
|
38
|
+
readonly "--db-cpu": StringConstructor;
|
|
39
|
+
readonly "--db-instances": StringConstructor;
|
|
40
|
+
readonly "--db-memory": StringConstructor;
|
|
41
|
+
readonly "--email": StringConstructor;
|
|
42
|
+
readonly "--endpoint": StringConstructor;
|
|
43
|
+
readonly "--events": StringConstructor;
|
|
44
|
+
readonly "--expires-in": StringConstructor;
|
|
45
|
+
readonly "--function": StringConstructor;
|
|
46
|
+
readonly "--host": StringConstructor;
|
|
47
|
+
readonly "--ingress-address": StringConstructor;
|
|
48
|
+
readonly "--kubeconfig": StringConstructor;
|
|
49
|
+
readonly "--limit": StringConstructor;
|
|
50
|
+
readonly "--memory": StringConstructor;
|
|
51
|
+
readonly "--message": StringConstructor;
|
|
52
|
+
readonly "--name": StringConstructor;
|
|
53
|
+
readonly "--org": StringConstructor;
|
|
54
|
+
readonly "--output": StringConstructor;
|
|
55
|
+
readonly "--password": StringConstructor;
|
|
56
|
+
readonly "--platform-rebuilds": StringConstructor;
|
|
57
|
+
readonly "--port": StringConstructor;
|
|
58
|
+
readonly "--provider": StringConstructor;
|
|
59
|
+
readonly "--region": StringConstructor;
|
|
60
|
+
readonly "--replicas": StringConstructor;
|
|
61
|
+
readonly "--repo": StringConstructor;
|
|
62
|
+
readonly "--scale-to-zero": StringConstructor;
|
|
63
|
+
readonly "--secret-access-key": StringConstructor;
|
|
64
|
+
readonly "--since": StringConstructor;
|
|
65
|
+
readonly "--slug": StringConstructor;
|
|
66
|
+
readonly "--source": StringConstructor;
|
|
67
|
+
readonly "--spot": StringConstructor;
|
|
68
|
+
readonly "--storage": StringConstructor;
|
|
69
|
+
readonly "--subdomain": StringConstructor;
|
|
70
|
+
readonly "--table": StringConstructor;
|
|
71
|
+
readonly "--tail": StringConstructor;
|
|
72
|
+
readonly "--target": StringConstructor;
|
|
73
|
+
readonly "--timeout": StringConstructor;
|
|
74
|
+
readonly "--type": StringConstructor;
|
|
75
|
+
readonly "--out": "--output";
|
|
76
|
+
readonly "-e": "--email";
|
|
77
|
+
readonly "-m": "--message";
|
|
78
|
+
readonly "-n": "--name";
|
|
79
|
+
};
|
|
2
80
|
/**
|
|
3
81
|
* Positional tokens after `rebase cloud` (group, action, …).
|
|
4
82
|
*
|
|
5
|
-
* Two things stop a flag being mistaken for the group
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* boolean shifts
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* flag
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* is worse than the handler reporting an unknown group.
|
|
83
|
+
* Two things stop a flag being mistaken for the group or the action.
|
|
84
|
+
* `GLOBAL_CLOUD_FLAGS` and {@link CLOUD_VALUE_FLAGS} are declared so `arg`
|
|
85
|
+
* *consumes* every flag of the family that takes a value — critically together
|
|
86
|
+
* with its value, which is the half that filtering cannot do. The leading-`-`
|
|
87
|
+
* skip then covers a flag nobody declared, so an unrecognised boolean shifts
|
|
88
|
+
* nothing.
|
|
89
|
+
*
|
|
90
|
+
* A flag this family has never heard of, that takes a value, is the one shape
|
|
91
|
+
* still unresolvable here — there is no way to know whether the token after it
|
|
92
|
+
* is its value or the action. The command's own strict parse refuses that flag
|
|
93
|
+
* anyway, so the only cost is which refusal the caller reads.
|
|
17
94
|
*
|
|
18
95
|
* Exported so its tests can drive the real thing. The dispatch test used to
|
|
19
96
|
* re-implement it locally as `slice(3).filter(a => !a.startsWith("-"))` — which
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a Rebase Cloud token may do, named the way a person asks for it.
|
|
3
|
+
*
|
|
4
|
+
* A token is a personal API key on the control plane: it acts as the account
|
|
5
|
+
* that created it, and holds only the scopes it was given. Nobody should have
|
|
6
|
+
* to know that `rebase cloud deploy` reads the `deployments` collection, uploads
|
|
7
|
+
* through the `deploy` function and needs `project:deploy` on one project — so
|
|
8
|
+
* `rebase cloud tokens create --can deploy` and the console's token screen both
|
|
9
|
+
* ask for a capability, and this module turns capabilities into scopes.
|
|
10
|
+
*
|
|
11
|
+
* One map, read by the CLI and by the console. Each capability covers exactly
|
|
12
|
+
* the control-plane calls its commands make, traced from the commands
|
|
13
|
+
* themselves and held there by `token-capabilities.test.ts`, which runs them
|
|
14
|
+
* against a stand-in control plane that refuses everything a token does not
|
|
15
|
+
* hold:
|
|
16
|
+
*
|
|
17
|
+
* - `deploy` — `rebase cloud deploy` (bundle and source paths, uploads, the
|
|
18
|
+
* build follow) and `rebase cloud deployments`.
|
|
19
|
+
* - `logs` — `rebase cloud logs` (build, `--follow`, `--runtime`),
|
|
20
|
+
* `rebase cloud metrics` and `rebase cloud cron` — whose
|
|
21
|
+
* `runtime-token` call is how a token reads the app's own
|
|
22
|
+
* cron history.
|
|
23
|
+
* - `env` — `rebase cloud env list|set|unset|reveal|pull`.
|
|
24
|
+
* - `database` — `rebase cloud db list|info|connect`.
|
|
25
|
+
* - `backups` — `rebase cloud db backup list|create|status|download` and
|
|
26
|
+
* `db pitr status`. Restoring takes `project:restore`, which no
|
|
27
|
+
* capability grants: putting old data over a live database is
|
|
28
|
+
* for a signed-in person.
|
|
29
|
+
*
|
|
30
|
+
* Every project-level scope is narrowed to the one project the token is for
|
|
31
|
+
* (`project:deploy:<projectId>`). The data and function scopes cannot be: they
|
|
32
|
+
* name a collection or a function, not a row, and the control plane's
|
|
33
|
+
* row-level security keeps the token to what its owner can see.
|
|
34
|
+
*
|
|
35
|
+
* Deliberately free of imports, so the control plane's console can read the
|
|
36
|
+
* same file.
|
|
37
|
+
*
|
|
38
|
+
* @module
|
|
39
|
+
*/
|
|
40
|
+
/** A capability a token can be given. */
|
|
41
|
+
export type TokenCapability = "deploy" | "logs" | "env" | "database" | "backups";
|
|
42
|
+
/** Every capability, in the order they are offered. */
|
|
43
|
+
export declare const TOKEN_CAPABILITY_NAMES: readonly TokenCapability[];
|
|
44
|
+
/**
|
|
45
|
+
* Scopes every token holds, whatever it was created for: resolving a project
|
|
46
|
+
* by its slug, reading the deployment a command follows, the organization a
|
|
47
|
+
* project belongs to, and the control plane's public description of itself.
|
|
48
|
+
*/
|
|
49
|
+
export declare const ALWAYS_SCOPES: string[];
|
|
50
|
+
/** Each capability: what it lets a token do, and the scopes that does on one project. */
|
|
51
|
+
export declare const TOKEN_CAPABILITIES: Record<TokenCapability, {
|
|
52
|
+
label: string;
|
|
53
|
+
scopes: (projectId: string) => string[];
|
|
54
|
+
}>;
|
|
55
|
+
/** Whether a word names a capability. */
|
|
56
|
+
export declare function isTokenCapability(value: string): value is TokenCapability;
|
|
57
|
+
/**
|
|
58
|
+
* The scopes a token for `capabilities` on one project holds: {@link ALWAYS_SCOPES}
|
|
59
|
+
* first, then each capability's, each scope once.
|
|
60
|
+
*
|
|
61
|
+
* Throws on a project id a scope cannot carry — empty, or with whitespace — and
|
|
62
|
+
* on an unknown capability, both of which are a caller's mistake rather than
|
|
63
|
+
* something to mint a token from.
|
|
64
|
+
*/
|
|
65
|
+
export declare function scopesForCapabilities(projectId: string, capabilities: readonly TokenCapability[]): string[];
|
|
66
|
+
/**
|
|
67
|
+
* Read a token's scopes back as capabilities: the projects its project scopes
|
|
68
|
+
* name, and, for each, the capabilities it holds every scope of.
|
|
69
|
+
*
|
|
70
|
+
* For showing a token — `rebase cloud tokens list`, `rebase cloud whoami` — so
|
|
71
|
+
* a list of fifteen scope strings reads as "deploy, logs on <project>".
|
|
72
|
+
*/
|
|
73
|
+
export declare function capabilitiesInScopes(scopes: readonly string[]): Array<{
|
|
74
|
+
projectId: string;
|
|
75
|
+
capabilities: TokenCapability[];
|
|
76
|
+
}>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type TokenCapability } from "./token-capabilities.js";
|
|
2
|
+
/** Every action the group dispatches. */
|
|
3
|
+
export declare const TOKENS_ACTIONS: readonly ["list", "create", "revoke"];
|
|
4
|
+
/** What `rebase cloud tokens create` parses, beside the global flags (`--project` among them). */
|
|
5
|
+
export declare const CREATE_TOKEN_FLAGS: {
|
|
6
|
+
"--can": [StringConstructor];
|
|
7
|
+
"--name": StringConstructor;
|
|
8
|
+
"--expires-in": StringConstructor;
|
|
9
|
+
};
|
|
10
|
+
export declare function tokensCommand(action: string | undefined, rawArgs: string[]): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* The capabilities `--can` names, comma-separated or repeated, each once.
|
|
13
|
+
*
|
|
14
|
+
* Exported so its tests can drive it without a session.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseCapabilities(values: readonly string[] | undefined): TokenCapability[];
|
|
17
|
+
/**
|
|
18
|
+
* `--expires-in <days>` as an ISO timestamp, or null for a token that does not
|
|
19
|
+
* expire.
|
|
20
|
+
*
|
|
21
|
+
* Exported so its tests can drive it without a session.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveTokenExpiry(value: string | undefined, now?: Date): string | null;
|
package/dist/commands/db.d.ts
CHANGED
|
@@ -17,6 +17,20 @@ import { type DevDatabase } from "../dev-db/resolve.js";
|
|
|
17
17
|
* it open.
|
|
18
18
|
*/
|
|
19
19
|
export declare function databaseUrlOf(prepared: Pick<PreparedDatabase, "env" | "database">, envFile: Record<string, string>): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The flags whose value is a local path, on every line the CLI relays.
|
|
22
|
+
*
|
|
23
|
+
* All three spellings of the destination, because the driver accepts all
|
|
24
|
+
* three: `backup-cli.ts` maps `--output` and `-o` onto `--out`, and `rebase db
|
|
25
|
+
* backup --help` advertises `--output` as an alias. Only `--out` and `-o` were
|
|
26
|
+
* absolutised once, so the one spelling the help page names was the one that
|
|
27
|
+
* landed in `backend/` — and the success line still echoed the path as typed.
|
|
28
|
+
*
|
|
29
|
+
* And `--collections`, which was not absolutised at all: from the project root,
|
|
30
|
+
* `rebase schema generate --collections ./config/collections` was "not found",
|
|
31
|
+
* while the same spelling worked for `generate-sdk`. See `utils/path-flags.ts`.
|
|
32
|
+
*/
|
|
33
|
+
export declare const LOCAL_PATH_FLAGS: readonly string[];
|
|
20
34
|
/**
|
|
21
35
|
* Rewrite local path arguments so they mean what the user typed.
|
|
22
36
|
*
|
|
@@ -31,7 +45,7 @@ export declare function databaseUrlOf(prepared: Pick<PreparedDatabase, "env" | "
|
|
|
31
45
|
* Absolutising here rather than inside the plugin keeps the fix where the cwd
|
|
32
46
|
* is actually changed, and leaves the plugin usable on its own terms.
|
|
33
47
|
*/
|
|
34
|
-
export declare function absolutizeLocalPathArgs(args: string[], cwd: string): string[];
|
|
48
|
+
export declare function absolutizeLocalPathArgs(args: string[], cwd: string, pathFlags?: readonly string[]): string[];
|
|
35
49
|
/**
|
|
36
50
|
* A managed-database refusal, raised so the caller decides what it costs.
|
|
37
51
|
*
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AppAddress, type RebaseProjectManifest } from "@rebasepro/types";
|
|
1
2
|
import { type PreparedDatabase } from "../dev-db/prepare.js";
|
|
2
3
|
/**
|
|
3
4
|
* The line the watcher prints when it is about to run the entry again.
|
|
@@ -65,15 +66,40 @@ export declare function portMovedNotice(line: string): {
|
|
|
65
66
|
*
|
|
66
67
|
* @param projectRoot Absolute path the relative entries are resolved against.
|
|
67
68
|
* @param paths The `REBASE_DEV_*` map from {@link devRuntimeEnv}.
|
|
68
|
-
* @param includeConfig Whether `config/` is watched here. It is only when
|
|
69
|
-
* auto-generation is off; with `--generate` a dedicated
|
|
70
|
-
* watcher already regenerates the schema and SDK, and tsx
|
|
71
|
-
* restarts on the files that produces.
|
|
72
69
|
*/
|
|
73
70
|
export declare function devWatchIncludes(projectRoot: string, paths: {
|
|
74
71
|
REBASE_DEV_FUNCTIONS?: string;
|
|
75
72
|
REBASE_DEV_CRONS?: string;
|
|
76
|
-
}
|
|
73
|
+
}): string[];
|
|
74
|
+
/**
|
|
75
|
+
* The file dev writes to restart the backend, or `null` when tsx would not see it.
|
|
76
|
+
*
|
|
77
|
+
* Outside the project, so nothing appears in the developer's tree, and keyed by
|
|
78
|
+
* the project so two `rebase dev`s never restart each other. tsx ignores every
|
|
79
|
+
* path with a dot-named segment (its built-in `**\/.*\/**`), so a trigger under
|
|
80
|
+
* `.rebase/` — or under a TMPDIR inside a dot directory — would never fire; in
|
|
81
|
+
* that case there is no trigger and {@link devWatchArgs} leaves the
|
|
82
|
+
* collections to tsx, as before.
|
|
83
|
+
*/
|
|
84
|
+
export declare function devRestartTrigger(projectRoot: string): string | null;
|
|
85
|
+
/**
|
|
86
|
+
* The `tsx watch` argument list for the backend (unquoted).
|
|
87
|
+
*
|
|
88
|
+
* One save of a collection file must restart the backend once. The runtime
|
|
89
|
+
* `import()`s the collections, so tsx tracks them as dependencies and used to
|
|
90
|
+
* restart the moment a file was saved — before dev had regenerated
|
|
91
|
+
* `schema.generated.ts`. That boot warned "schema.generated.ts no longer
|
|
92
|
+
* describes the database … Run `rebase schema generate`", telling the reader to
|
|
93
|
+
* run what dev was running at that moment, and the regeneration then rewrote
|
|
94
|
+
* the file and restarted the backend a second time. So tsx is told to leave the
|
|
95
|
+
* collections directory alone (`--exclude` wins over its dependency tracking),
|
|
96
|
+
* and dev restarts the backend itself, once, after the regeneration — through
|
|
97
|
+
* `restartTrigger`, which tsx watches.
|
|
98
|
+
*/
|
|
99
|
+
export declare function devWatchArgs(projectRoot: string, paths: {
|
|
100
|
+
REBASE_DEV_FUNCTIONS?: string;
|
|
101
|
+
REBASE_DEV_CRONS?: string;
|
|
102
|
+
}, entryTarget: string, restartTrigger: string | null): string[];
|
|
77
103
|
/** Well-known filename the backend writes its actual port to. */
|
|
78
104
|
export declare const DEV_PORT_FILENAME = ".rebase-dev-port";
|
|
79
105
|
/**
|
|
@@ -138,6 +164,53 @@ export declare function resolveStartPort(projectRoot: string, explicitPort?: num
|
|
|
138
164
|
* Exported for its test.
|
|
139
165
|
*/
|
|
140
166
|
export declare function databaseEndpoint(url: string | null | undefined): string | null;
|
|
167
|
+
/**
|
|
168
|
+
* What the start banner needs to know about a project's static apps.
|
|
169
|
+
*
|
|
170
|
+
* `rebase dev` runs one frontend: Vite in `frontend/`, at the root of its own
|
|
171
|
+
* localhost port, whatever path or hostname the manifest declares for it. So an
|
|
172
|
+
* app's local address and its deployed one are different things, and for an app
|
|
173
|
+
* with a hostname of its own they share nothing at all — appending its address
|
|
174
|
+
* to the local URL would print `http://localhost:5173https://admin.example.com`.
|
|
175
|
+
*/
|
|
176
|
+
export interface DevStaticShape {
|
|
177
|
+
declaresStaticApp: boolean;
|
|
178
|
+
/** The declared app whose `root` is the `frontend/` that `rebase dev` runs, if one is. */
|
|
179
|
+
served?: {
|
|
180
|
+
appName: string;
|
|
181
|
+
address: AppAddress;
|
|
182
|
+
};
|
|
183
|
+
/** Where the CMS is, when an app declares one. */
|
|
184
|
+
cms?: {
|
|
185
|
+
appName: string;
|
|
186
|
+
/** Always a path. */
|
|
187
|
+
path: string;
|
|
188
|
+
/** The serving app's hostname, when its `path` names one. */
|
|
189
|
+
host?: string;
|
|
190
|
+
/** Whether the app serving it is the one `rebase dev` runs, so it has a local address. */
|
|
191
|
+
servedLocally: boolean;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Read {@link DevStaticShape} out of a loaded manifest. Exported for its test.
|
|
196
|
+
*
|
|
197
|
+
* Which declared app is running is decided by its `root` being `frontend/`,
|
|
198
|
+
* because that directory is what `startFrontend` launches and nothing else is.
|
|
199
|
+
* When no declared app has that root, which app serves the CMS cannot be told,
|
|
200
|
+
* and it is read as the frontend that does run — what the banner has always
|
|
201
|
+
* assumed, and right for every project `rebase init` scaffolds.
|
|
202
|
+
*/
|
|
203
|
+
export declare function devStaticShape(manifest: RebaseProjectManifest, projectRoot: string, frontendDir: string | null): DevStaticShape;
|
|
204
|
+
/**
|
|
205
|
+
* The banner's lines for a project with a frontend. Exported for its test.
|
|
206
|
+
*
|
|
207
|
+
* Every address is printed whole, once: the local one Vite answers on, and —
|
|
208
|
+
* for an app with a hostname — the https URL it answers on once deployed, on a
|
|
209
|
+
* line of its own beneath it. A CMS in an app `rebase dev` does not run gets its
|
|
210
|
+
* deployed address and a note saying so, rather than a localhost URL that the
|
|
211
|
+
* running frontend's SPA fallback would answer with the wrong app.
|
|
212
|
+
*/
|
|
213
|
+
export declare function appBannerLines(frontendUrl: string, api: string, shape: DevStaticShape): Array<[string, string]>;
|
|
141
214
|
/**
|
|
142
215
|
* The `↳ Database =` line: which database, why it was chosen, and where it is.
|
|
143
216
|
*
|
|
@@ -206,7 +279,6 @@ export declare const DEV_FLAGS: {
|
|
|
206
279
|
readonly "--backend-only": BooleanConstructor;
|
|
207
280
|
readonly "--frontend-only": BooleanConstructor;
|
|
208
281
|
readonly "--port": NumberConstructor;
|
|
209
|
-
readonly "--generate": BooleanConstructor;
|
|
210
282
|
/**
|
|
211
283
|
* Point this run at a database of your own, ahead of everything else.
|
|
212
284
|
*
|
|
@@ -220,7 +292,6 @@ export declare const DEV_FLAGS: {
|
|
|
220
292
|
readonly "-b": "--backend-only";
|
|
221
293
|
readonly "-f": "--frontend-only";
|
|
222
294
|
readonly "-P": "--port";
|
|
223
|
-
readonly "-g": "--generate";
|
|
224
295
|
readonly "--no-db": BooleanConstructor;
|
|
225
296
|
};
|
|
226
297
|
/**
|
|
@@ -57,4 +57,9 @@ export declare const DOCTOR_FLAGS: {
|
|
|
57
57
|
readonly "--sdk": StringConstructor;
|
|
58
58
|
readonly "-k": "--sdk";
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* The line handed to the driver, every path on it resolved from where the
|
|
62
|
+
* command was run — the driver runs in `backend/`. See `utils/path-flags.ts`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function doctorDriverArgs(rawArgs: string[], cwd: string): string[];
|
|
60
65
|
export declare function doctorCommand(rawArgs: string[]): Promise<void>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLI command: generate-sdk
|
|
3
3
|
*
|
|
4
|
-
* Reads collection
|
|
5
|
-
*
|
|
4
|
+
* Reads every collection file in a directory (default: ./config/collections) —
|
|
5
|
+
* the files the backend serves, not the barrel's list — generates a typed
|
|
6
|
+
* TypeScript SDK, and writes it to the output directory (default: ./generated/sdk).
|
|
6
7
|
*
|
|
7
8
|
* Uses jiti for dynamic TypeScript import of collection files.
|
|
8
9
|
*/
|