@rebasepro/cli 0.33.2 → 0.34.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-Cg_zBWoW.js → agent-setup-CGeAuP0Q.js} +2 -2
- package/dist/{agent-setup-Cg_zBWoW.js.map → agent-setup-CGeAuP0Q.js.map} +1 -1
- package/dist/{api-keys-fPQ55DCm.js → api-keys-DaWN8dyI.js} +3 -3
- package/dist/{api-keys-fPQ55DCm.js.map → api-keys-DaWN8dyI.js.map} +1 -1
- package/dist/{api-TbmW33D7.js → api-zx1wSK5a.js} +2 -2
- package/dist/{api-TbmW33D7.js.map → api-zx1wSK5a.js.map} +1 -1
- package/dist/{apps-DBTRoOeP.js → apps-D6vtDrkJ.js} +3 -3
- package/dist/{apps-DBTRoOeP.js.map → apps-D6vtDrkJ.js.map} +1 -1
- package/dist/{auth-BpyYLEFY.js → auth-DY7kU0z-.js} +8 -8
- package/dist/{auth-BpyYLEFY.js.map → auth-DY7kU0z-.js.map} +1 -1
- package/dist/{auth-session-B6aT0Dyj.js → auth-session-DCG96UGH.js} +4 -4
- package/dist/{auth-session-B6aT0Dyj.js.map → auth-session-DCG96UGH.js.map} +1 -1
- package/dist/{build-E5hfEWKj.js → build-D0egCUfU.js} +4 -4
- package/dist/{build-E5hfEWKj.js.map → build-D0egCUfU.js.map} +1 -1
- package/dist/{bundle-CIiKGrte.js → bundle-DhdhtD8K.js} +3 -3
- package/dist/{bundle-CIiKGrte.js.map → bundle-DhdhtD8K.js.map} +1 -1
- package/dist/{cloud-DNJyUU0T.js → cloud-DOR7bxDw.js} +218 -27
- package/dist/cloud-DOR7bxDw.js.map +1 -0
- package/dist/{command-Bks5xkrQ.js → command-BzSP5gBh.js} +2 -2
- package/dist/{command-Bks5xkrQ.js.map → command-BzSP5gBh.js.map} +1 -1
- package/dist/commands/cloud/db-connect.d.ts +31 -1
- package/dist/commands/cloud/db-query.d.ts +16 -0
- package/dist/commands/cloud/index.d.ts +1 -0
- package/dist/commands/cloud/resources.d.ts +19 -1
- package/dist/commands/dev.d.ts +15 -0
- package/dist/commands/users.d.ts +1 -0
- package/dist/{context-BOMEoKxn.js → context-xt20FMFA.js} +5 -1
- package/dist/{context-BOMEoKxn.js.map → context-xt20FMFA.js.map} +1 -1
- package/dist/{cron-CpUsQ739.js → cron-BGkXIB1N.js} +4 -4
- package/dist/{cron-CpUsQ739.js.map → cron-BGkXIB1N.js.map} +1 -1
- package/dist/{cron-ZRXsla0v.js → cron-CJ6Xk42E.js} +3 -3
- package/dist/{cron-ZRXsla0v.js.map → cron-CJ6Xk42E.js.map} +1 -1
- package/dist/{data-BJ9AZFUC.js → data-BpkvtCUe.js} +3 -3
- package/dist/{data-BJ9AZFUC.js.map → data-BpkvtCUe.js.map} +1 -1
- package/dist/{debug-nNbbxAeo.js → debug-C7Ss34XB.js} +2 -2
- package/dist/{debug-nNbbxAeo.js.map → debug-C7Ss34XB.js.map} +1 -1
- package/dist/{derive-Mky_u59_.js → derive-ChP6vgfi.js} +2 -2
- package/dist/{derive-Mky_u59_.js.map → derive-ChP6vgfi.js.map} +1 -1
- package/dist/{dev-bj6dEeSQ.js → dev-C7n36E6f.js} +23 -2
- package/dist/dev-C7n36E6f.js.map +1 -0
- package/dist/{doctor-FaBObSlb.js → doctor-D0o54XSQ.js} +2 -2
- package/dist/{doctor-FaBObSlb.js.map → doctor-D0o54XSQ.js.map} +1 -1
- package/dist/{fold-static-2t3UUX4z.js → fold-static-DTpaqbB0.js} +2 -2
- package/dist/{fold-static-2t3UUX4z.js.map → fold-static-DTpaqbB0.js.map} +1 -1
- package/dist/{function-portability-BIvlvR9q.js → function-portability-Dppl6uqg.js} +24 -5
- package/dist/{function-portability-BIvlvR9q.js.map → function-portability-Dppl6uqg.js.map} +1 -1
- package/dist/function-portability.d.ts +9 -0
- package/dist/{functions-B4JR6EZL.js → functions-DLuuldt2.js} +4 -4
- package/dist/{functions-B4JR6EZL.js.map → functions-DLuuldt2.js.map} +1 -1
- package/dist/{generate_sdk-ByD-gTsK.js → generate_sdk-UT1lwwRT.js} +2 -2
- package/dist/{generate_sdk-ByD-gTsK.js.map → generate_sdk-UT1lwwRT.js.map} +1 -1
- package/dist/index.es.js +39 -39
- package/dist/{init-DHCe5mJ5.js → init-u5Xmr1Ct.js} +4 -4
- package/dist/{init-DHCe5mJ5.js.map → init-u5Xmr1Ct.js.map} +1 -1
- package/dist/{logs-DpuMukJe.js → logs-DBYRSs6W.js} +4 -4
- package/dist/{logs-DpuMukJe.js.map → logs-DBYRSs6W.js.map} +1 -1
- package/dist/{migrate-CSY9ZDKy.js → migrate-Cw1FkvUK.js} +3 -3
- package/dist/{migrate-CSY9ZDKy.js.map → migrate-Cw1FkvUK.js.map} +1 -1
- package/dist/{normalize-imports-P86NVfpo.js → normalize-imports-E4yA1HfW.js} +2 -2
- package/dist/{normalize-imports-P86NVfpo.js.map → normalize-imports-E4yA1HfW.js.map} +1 -1
- package/dist/{project-command-Cl9EZzjr.js → project-command-7EGMemEy.js} +5 -5
- package/dist/{project-command-Cl9EZzjr.js.map → project-command-7EGMemEy.js.map} +1 -1
- package/dist/{resources-Db3USuPO.js → resources-CE6BeL94.js} +2 -2
- package/dist/{resources-Db3USuPO.js.map → resources-CE6BeL94.js.map} +1 -1
- package/dist/{rls-BxrQ0P50.js → rls-BxWLfEKl.js} +3 -3
- package/dist/{rls-BxrQ0P50.js.map → rls-BxWLfEKl.js.map} +1 -1
- package/dist/{schema-_FzZEoB8.js → schema-D8xFSBbN.js} +7 -6
- package/dist/{schema-_FzZEoB8.js.map → schema-D8xFSBbN.js.map} +1 -1
- package/dist/schema-reconcile-D_wvZY91.js +2 -0
- package/dist/{schema-show-h72UJ9zH.js → schema-show-C7bY7SgE.js} +3 -3
- package/dist/{schema-show-h72UJ9zH.js.map → schema-show-C7bY7SgE.js.map} +1 -1
- package/dist/{skills-DQ2bZGkj.js → skills-C8WdRTFg.js} +4 -4
- package/dist/{skills-DQ2bZGkj.js.map → skills-C8WdRTFg.js.map} +1 -1
- package/dist/{start-Cjx4W0bJ.js → start-CN_9C205.js} +2 -2
- package/dist/{start-Cjx4W0bJ.js.map → start-CN_9C205.js.map} +1 -1
- package/dist/{status-CDBk25VO.js → status-HWlZbY1E.js} +2 -2
- package/dist/{status-CDBk25VO.js.map → status-HWlZbY1E.js.map} +1 -1
- package/dist/{storage-Clc8dLG8.js → storage-DBE8lgH-.js} +9 -9
- package/dist/{storage-Clc8dLG8.js.map → storage-DBE8lgH-.js.map} +1 -1
- package/dist/{storage-objects-CfRKlTDe.js → storage-objects-ljDmtuH7.js} +3 -3
- package/dist/{storage-objects-CfRKlTDe.js.map → storage-objects-ljDmtuH7.js.map} +1 -1
- package/dist/{users-5PkqBY6R.js → users-DrJEtL9k.js} +9 -6
- package/dist/users-DrJEtL9k.js.map +1 -0
- package/package.json +10 -10
- package/templates/template/.cursorrules +2 -1
- package/templates/template/.github/copilot-instructions.md +2 -1
- package/templates/template/.windsurfrules +2 -1
- package/templates/template/AGENTS.md +2 -1
- package/templates/template/CLAUDE.md +2 -1
- package/templates/template/ai-instructions.md +5 -2
- package/templates/template/frontend/src/index.css +13 -0
- package/dist/cloud-DNJyUU0T.js.map +0 -1
- package/dist/dev-bj6dEeSQ.js.map +0 -1
- package/dist/schema-reconcile-DV14XY4o.js +0 -2
- package/dist/users-5PkqBY6R.js.map +0 -1
|
@@ -33,6 +33,15 @@ export interface FunctionPortability {
|
|
|
33
33
|
*/
|
|
34
34
|
resourceImports: string[];
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Whether a line reads `process.env.X` with nothing to fall back on.
|
|
38
|
+
*
|
|
39
|
+
* `process.env.X ?? ""` and `process.env.X || "default"` cannot fail an
|
|
40
|
+
* import: the variable being unset is the case they handle. Flagging them
|
|
41
|
+
* printed 25 warnings for one ported project, each saying its file "fails to
|
|
42
|
+
* import if unset", none of which could. Exported for testing.
|
|
43
|
+
*/
|
|
44
|
+
export declare function hasUnguardedEnvRead(line: string): boolean;
|
|
36
45
|
/** Analyse one function file's source. Exported for testing. */
|
|
37
46
|
export declare function analyseFunctionSource(source: string, name: string, file: string): FunctionPortability;
|
|
38
47
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as unknownCommand } from "./unknown-command-DnZ2uhGs.js";
|
|
2
2
|
import { a as wantsHelp, n as parseCommandArgs, t as UsageError } from "./args-DHyrshtI.js";
|
|
3
|
-
import { a as projectTarget, c as requestJson, d as PROJECT_TARGET_FLAGS, i as printProjectHelp, l as startProjectCommand, n as isRecord, o as recordsOf, r as parsedLine, u as stringOf } from "./project-command-
|
|
4
|
-
import { M as note, m as emit } from "./context-
|
|
5
|
-
import { buildApiPlan, sendApiPlan } from "./api-
|
|
3
|
+
import { a as projectTarget, c as requestJson, d as PROJECT_TARGET_FLAGS, i as printProjectHelp, l as startProjectCommand, n as isRecord, o as recordsOf, r as parsedLine, u as stringOf } from "./project-command-7EGMemEy.js";
|
|
4
|
+
import { M as note, m as emit } from "./context-xt20FMFA.js";
|
|
5
|
+
import { buildApiPlan, sendApiPlan } from "./api-zx1wSK5a.js";
|
|
6
6
|
import chalk from "chalk";
|
|
7
7
|
//#region src/commands/functions.ts
|
|
8
8
|
/** Everything the switch below dispatches, for the did-you-mean. */
|
|
@@ -117,4 +117,4 @@ function printFunctionsHelp() {
|
|
|
117
117
|
//#endregion
|
|
118
118
|
export { FUNCTIONS_SUBCOMMANDS, functionsCommand };
|
|
119
119
|
|
|
120
|
-
//# sourceMappingURL=functions-
|
|
120
|
+
//# sourceMappingURL=functions-DLuuldt2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions-
|
|
1
|
+
{"version":3,"file":"functions-DLuuldt2.js","names":[],"sources":["../src/commands/functions.ts"],"sourcesContent":["/**\n * CLI command: rebase functions <action>\n *\n * A running app's own routes — one per file in `backend/functions/`, served at\n * `/api/functions/<name>/*` — listed, or called with the project's credential.\n * `invoke` is `rebase api` aimed at one function: the same fields, body and\n * headers, and the answer printed as it came.\n *\n * Functions are public by default and decide their own access\n * (`requireAuth`, `requireRole`, `requireScope`), so the credential matters:\n * the service key is admin, `--token` tests a narrower one, `--session` a\n * person, and `--anon` what a visitor gets.\n */\nimport type arg from \"arg\";\nimport chalk from \"chalk\";\n\nimport { parseCommandArgs, UsageError, wantsHelp } from \"../utils/args\";\nimport { unknownCommand } from \"../utils/unknown-command\";\nimport { PROJECT_TARGET_FLAGS } from \"../utils/project-target\";\nimport {\n emit,\n isRecord,\n parsedLine,\n printProjectHelp,\n projectTarget,\n recordsOf,\n requestJson,\n startProjectCommand,\n stringOf,\n type HelpAction\n} from \"../utils/project-command\";\nimport { note } from \"./cloud/context\";\nimport { buildApiPlan, sendApiPlan } from \"./api\";\n\n/** Everything the switch below dispatches, for the did-you-mean. */\nexport const FUNCTIONS_SUBCOMMANDS = [\"list\", \"invoke\"] as const;\n\nexport async function functionsCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void> {\n startProjectCommand(rawArgs);\n if (subcommand === \"--help\" || wantsHelp(rawArgs)) {\n printFunctionsHelp();\n return;\n }\n switch (subcommand ?? \"list\") {\n case \"list\":\n await listFunctions(rawArgs);\n break;\n case \"invoke\":\n await invokeFunction(rawArgs);\n break;\n default:\n unknownCommand(subcommand, FUNCTIONS_SUBCOMMANDS, \"functions\");\n }\n}\n\nexport const FUNCTIONS_LIST_FLAGS = { ...PROJECT_TARGET_FLAGS } satisfies arg.Spec;\n\nasync function listFunctions(rawArgs: string[]): Promise<void> {\n const { flags } = parsedLine(() => parseCommandArgs({\n spec: FUNCTIONS_LIST_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"functions list\",\n maxPositionals: 0\n }));\n const target = await projectTarget(flags, { command: \"functions list\" });\n const body = await requestJson(target, \"/api/functions\", \"Failed to list functions\");\n const list = recordsOf(isRecord(body) ? body.functions ?? body.data : body);\n emit(() => {\n if (list.length === 0) return note(`${target.label} serves no functions (backend/functions/ is empty, or no file loaded).`);\n for (const fn of list) {\n const name = stringOf(fn.name) ?? \"?\";\n console.log(` ${chalk.bold(name)} ${chalk.gray(stringOf(fn.path) ?? `/api/functions/${name}`)}`);\n }\n if (isRecord(body) && typeof body.skipped === \"number\" && body.skipped > 0) {\n note(chalk.yellow(`${body.skipped} file(s) did not load; the server log says why.`));\n }\n }, body);\n}\n\nexport const FUNCTIONS_INVOKE_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--method\": String,\n \"-X\": \"--method\",\n \"--field\": [String],\n \"-f\": \"--field\",\n \"--raw-field\": [String],\n \"-F\": \"--raw-field\",\n \"--input\": String,\n \"--header\": [String],\n \"-H\": \"--header\",\n \"--include\": Boolean,\n \"-i\": \"--include\"\n} satisfies arg.Spec;\n\nasync function invokeFunction(rawArgs: string[]): Promise<void> {\n const { flags, plan } = parsedLine(() => {\n const parsed = parseCommandArgs({\n spec: FUNCTIONS_INVOKE_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"functions invoke\",\n maxPositionals: 2\n });\n const [name, rest] = parsed.positionals;\n if (!name) throw new UsageError(\"rebase functions invoke needs a function name: rebase functions invoke <name> [path].\");\n if (name.includes(\"/\")) throw new UsageError(`\"${name}\" is not a function name: the path after it is the second argument.`);\n const sub = rest ? `/${rest.replace(/^\\/+/, \"\")}` : \"\";\n return {\n flags: parsed.flags,\n plan: buildApiPlan({\n method: parsed.flags[\"--method\"],\n path: `/api/functions/${encodeURIComponent(name)}${sub}`,\n fields: parsed.flags[\"--field\"],\n rawFields: parsed.flags[\"--raw-field\"],\n input: parsed.flags[\"--input\"],\n headers: parsed.flags[\"--header\"]\n })\n };\n });\n const target = await projectTarget(flags, { command: \"functions invoke\" });\n await sendApiPlan(target, plan, { include: flags[\"--include\"] === true });\n}\n\nconst FUNCTIONS_ACTIONS: HelpAction[] = [\n { action: \"list\", description: \"The functions the server loaded (the default)\" },\n {\n action: \"invoke\",\n args: \"<name> [path]\",\n description: \"Call one: /api/functions/<name>/<path>, the answer printed as it came\",\n flags: [\n [\"--method, -X <method>\", \"The HTTP method (else GET; POST with --input — a field alone never writes)\"],\n [\"--field, -f <key=value>\", \"A string field: query string on GET/HEAD/DELETE, JSON body otherwise\"],\n [\"--raw-field, -F <key=value>\", \"A typed field: true/false/null, numbers, JSON, @file\"],\n [\"--input <file|->\", \"The whole request body\"],\n [\"--header, -H <\\\"Name: value\\\">\", \"An extra request header\"],\n [\"--include, -i\", \"Print the status line and response headers first\"]\n ]\n }\n];\n\nfunction printFunctionsHelp(): void {\n printProjectHelp({\n command: \"functions\",\n title: \"A running app's own routes (backend/functions): list them, call one\",\n actions: FUNCTIONS_ACTIONS,\n notes: [\n \"Examples:\",\n \" rebase functions invoke hello --anon\",\n \" rebase functions invoke billing webhook -X POST --input event.json\",\n \"A non-2xx answer is printed and exits 1. Functions decide their own access, so the credential matters: --anon shows what a visitor gets.\"\n ]\n });\n}\n"],"mappings":";;;;;;;;AAmCA,IAAa,wBAAwB,CAAC,QAAQ,QAAQ;AAEtD,eAAsB,iBAAiB,YAAgC,SAAkC;CACrG,oBAAoB,OAAO;CAC3B,IAAI,eAAe,YAAY,UAAU,OAAO,GAAG;EAC/C,mBAAmB;EACnB;CACJ;CACA,QAAQ,cAAc,QAAtB;EACI,KAAK;GACD,MAAM,cAAc,OAAO;GAC3B;EACJ,KAAK;GACD,MAAM,eAAe,OAAO;GAC5B;EACJ,SACI,eAAe,YAAY,uBAAuB,WAAW;CACrE;AACJ;AAEA,IAAa,uBAAuB,EAAE,GAAG,qBAAqB;AAE9D,eAAe,cAAc,SAAkC;CAC3D,MAAM,EAAE,UAAU,iBAAiB,iBAAiB;EAChD,MAAM;EACN;EACA,cAAc;EACd,SAAS;EACT,gBAAgB;CACpB,CAAC,CAAC;CACF,MAAM,SAAS,MAAM,cAAc,OAAO,EAAE,SAAS,iBAAiB,CAAC;CACvE,MAAM,OAAO,MAAM,YAAY,QAAQ,kBAAkB,0BAA0B;CACnF,MAAM,OAAO,UAAU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IACpB,SAAS,OAAO,MAAM;GAC1B,CAAC;EACL;CACJ,CAAC;CAED,MAAM,YAAY,MADG,cAAc,OAAO,EAAE,SAAS,mBAAmB,CAAC,GAC/C,MAAM,EAAE,SAAS,MAAM,iBAAiB,KAAK,CAAC;AAC5E;AAEA,IAAM,oBAAkC,CACpC;CAAE,QAAQ;CAAQ,aAAa;AAAgD,GAC/E;CACI,QAAQ;CACR,MAAM;CACN,aAAa;CACb,OAAO;EACH,CAAC,yBAAyB,4EAA4E;EACtG,CAAC,2BAA2B,sEAAsE;EAClG,CAAC,+BAA+B,sDAAsD;EACtF,CAAC,oBAAoB,wBAAwB;EAC7C,CAAC,kCAAkC,yBAAyB;EAC5D,CAAC,iBAAiB,kDAAkD;CACxE;AACJ,CACJ;AAEA,SAAS,qBAA2B;CAChC,iBAAiB;EACb,SAAS;EACT,OAAO;EACP,SAAS;EACT,OAAO;GACH;GACA;GACA;GACA;EACJ;CACJ,CAAC;AACL"}
|
|
@@ -3,7 +3,7 @@ import { O as writeManifest, _ as findBackendApp, b as loadManifest, o as GENERA
|
|
|
3
3
|
import { n as SCHEMA_DIR_FLAG_HELP, t as PATH_RESOLUTION_RULE } from "./path-flags-ekLdkbra.js";
|
|
4
4
|
import { t as loadProjectSchema } from "./project-schema-Dm6Jk0Y_.js";
|
|
5
5
|
import { t as DEV_BACKEND_URL_ENV } from "./dev-server-2XHSHM_q.js";
|
|
6
|
-
import { H as readLink } from "./context-
|
|
6
|
+
import { H as readLink } from "./context-xt20FMFA.js";
|
|
7
7
|
import { t as Refusal } from "./refusal-ReeeGP8a.js";
|
|
8
8
|
import chalk from "chalk";
|
|
9
9
|
import fs from "fs";
|
|
@@ -505,4 +505,4 @@ export const SCHEMA_VERSION = ${JSON.stringify(schemaVersion)};
|
|
|
505
505
|
//#endregion
|
|
506
506
|
export { generateSdkCommand, writeRegistrationForBuild };
|
|
507
507
|
|
|
508
|
-
//# sourceMappingURL=generate_sdk-
|
|
508
|
+
//# sourceMappingURL=generate_sdk-UT1lwwRT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_sdk-ByD-gTsK.js","names":[],"sources":["../src/commands/generate_sdk.ts"],"sourcesContent":["/**\n * CLI command: generate-sdk\n *\n * Reads the project's tables — `backend/schema`, through the loader the\n * backend boots from, so the SDK describes exactly the tables served — or,\n * with `--from`, a running project's contract, and writes a typed TypeScript\n * SDK to the output directory (default: ./generated/sdk).\n */\n\nimport fs from \"fs\";\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { computeSchemaVersion, type TableDescriptor } from \"@rebasepro/types\";\nimport { CodegenError, generateSDK, GeneratedFile, toTableAccessor } from \"@rebasepro/codegen\";\nimport { isSchemaDefinitionError } from \"@rebasepro/common\";\nimport { findProjectRoot, readEnvFile } from \"../utils/project\";\nimport { DEV_BACKEND_URL_ENV } from \"../utils/dev-server\";\nimport { Refusal } from \"../utils/refusal\";\nimport { findBackendApp, GENERATED_DIR, loadManifest, manifestExists, writeManifest } from \"../manifest\";\nimport { readLink } from \"./cloud/context\";\nimport { SCHEMA_DIR_FLAG_HELP, PATH_RESOLUTION_RULE } from \"../utils/path-flags\";\nimport { loadProjectSchema, type ModuleAliases } from \"../utils/project-schema\";\n\ninterface GenerateSDKArgs {\n /** The schema directory: the one whose index exports the tables. */\n schemaDir: string;\n output: string;\n cwd: string;\n /**\n * Where to read the schema from instead of local source.\n *\n * `link` uses this checkout's linked project; anything else is treated as\n * the base URL of a Rebase backend. This is what lets a repository that\n * contains no tables — a separate frontend, a second web app — generate\n * a typed client from the project it talks to.\n */\n from?: string;\n /** Bearer token for the contract endpoint. Falls back to REBASE_SERVICE_KEY. */\n token?: string;\n /**\n * Also register the generated `Database` for server-side code: write the\n * types and the `Register` augmentation into `backend/generated/`. See\n * {@link writeRegistration}.\n */\n register?: boolean;\n /**\n * The directory holding `rebase.json`, where `--register` is remembered\n * and under which `backend/generated/` is. Found from `cwd` when not given.\n */\n projectRoot?: string;\n /** Module specifiers mapped to files when importing the schema (in-repo runs and tests). */\n moduleAliases?: ModuleAliases;\n help?: boolean;\n}\n\n/** What `--register` writes, and what marks a project as having opted in. */\nexport const REGISTER_FILE = \"register.ts\";\n\n/** The first line of {@link REGISTER_FILE}: a file without it is the developer's own. */\nconst REGISTER_MARKER = \"// Auto-generated by `rebase generate-sdk --register`. Do not edit.\";\n\nconst REGISTER_SOURCE = `${REGISTER_MARKER}\n//\n// Registers this project's generated \\`Database\\` on \\`@rebasepro/types\\`, so\n// \\`context.data\\` in table hooks, \\`rebase.dataAsAdmin\\`, and the\n// \\`rebase\\` a function or a cron receives are typed from it. Every later\n// \\`rebase generate-sdk\\` (and \\`rebase dev\\`) refreshes this directory; delete\n// it to go back to untyped server-side data.\nimport type { Database } from \"./database.types\";\n\ndeclare module \"@rebasepro/types\" {\n interface Register {\n database: Database;\n }\n}\n`;\n\n/**\n * Where `--register` writes: `backend/generated/` under the project root.\n *\n * Inside `backend/` because that is the program the hooks, functions and\n * crons it types are compiled in. The types are copied in beside the\n * registration rather than imported from `generated/sdk`, which is outside\n * the backend's `rootDir`.\n */\nexport function registrationDir(projectRoot: string): string {\n return path.join(projectRoot, GENERATED_DIR);\n}\n\n/** Whether this project opted in: the registration is there, and it is ours. */\nfunction hasRegistration(dir: string): boolean {\n try {\n return fs.readFileSync(path.join(dir, REGISTER_FILE), \"utf-8\").startsWith(REGISTER_MARKER);\n } catch {\n return false;\n }\n}\n\n/** Write a file only when its content changed, so a watcher on the directory does not restart for nothing. */\nfunction writeIfChanged(filePath: string, content: string): void {\n try {\n if (fs.readFileSync(filePath, \"utf-8\") === content) return;\n } catch {\n // Not there yet.\n }\n fs.writeFileSync(filePath, content, \"utf-8\");\n}\n\n/**\n * Write the generated `Database` and its `Register` augmentation into\n * {@link registrationDir}. Refuses to overwrite a `register.ts` it did not\n * write.\n */\nfunction writeRegistration(dir: string, databaseTypes: string): void {\n const registerPath = path.join(dir, REGISTER_FILE);\n if (fs.existsSync(registerPath) && !hasRegistration(dir)) {\n throw new Error(\n `${registerPath} exists and was not written by \"rebase generate-sdk --register\". ` +\n \"Move it, or register the Database there yourself.\"\n );\n }\n fs.mkdirSync(dir, { recursive: true });\n writeIfChanged(path.join(dir, \"database.types.ts\"), databaseTypes);\n writeIfChanged(registerPath, REGISTER_SOURCE);\n}\n\n/**\n * Write the server-side registration from the build's tables, exactly as\n * `rebase generate-sdk` writes it.\n *\n * Only for a project that asked for it: `registerDatabase` in `rebase.json`,\n * or a registration an earlier `--register` left, which is kept current. The\n * registration lives in gitignored `backend/generated/`, so a fresh clone (a\n * CI job) has none until something writes it, and a bundle compiled without\n * it types `context.data` as untyped rows: hooks that read a typed column fail\n * to compile there while they compile locally.\n *\n * Returns the directory written, or null when there was nothing to do.\n * Throws when a `register.ts` there is not ours, as `generate-sdk` refuses.\n */\nexport async function writeRegistrationForBuild(\n projectRoot: string,\n tables: readonly TableDescriptor[],\n registerDatabase: boolean\n): Promise<string | null> {\n const dir = registrationDir(projectRoot);\n if (!registerDatabase && !hasRegistration(dir)) return null;\n if (tables.length === 0) return null;\n const databaseTypes = generateSDK(sortedBySlug(tables), { includeReadme: false })\n .find((file) => file.path === \"database.types.ts\")?.content;\n if (databaseTypes === undefined) return null;\n writeRegistration(dir, databaseTypes);\n return dir;\n}\n\n/** Tables sorted by slug: the same schema generates the same bytes, whatever order the index lists it in. */\nfunction sortedBySlug(tables: readonly TableDescriptor[]): TableDescriptor[] {\n return [...tables].sort((a, b) => a.slug.localeCompare(b.slug));\n}\n\n/**\n * Whether `rebase.json` asks for the registration (`registerDatabase: true` on\n * the backend app). That is what survives a clone: `generated/` is gitignored,\n * so a `register.ts` from an earlier run is not there to say it.\n *\n * An unreadable manifest answers no; `rebase build` is where it is reported.\n */\nfunction manifestRegisters(projectRoot: string | undefined): boolean {\n if (!projectRoot || !manifestExists(projectRoot)) return false;\n try {\n return findBackendApp(loadManifest(projectRoot).manifest)?.app.registerDatabase === true;\n } catch {\n return false;\n }\n}\n\n/**\n * Remember `--register` in `rebase.json`, so later runs, `rebase dev` and a\n * fresh clone keep registering. Returns where it was written, or why not.\n *\n * Never creates the file: a project without one is synthesized from its\n * layout, and writing one is `rebase apps init`'s decision, not this flag's.\n */\nfunction rememberRegistration(projectRoot: string | undefined): { written: string } | { skipped: string } {\n if (!projectRoot || !manifestExists(projectRoot)) {\n return { skipped: \"No rebase.json here, so the choice lasts as long as the generated files.\" };\n }\n let loaded: ReturnType<typeof loadManifest>;\n try {\n loaded = loadManifest(projectRoot);\n } catch (error) {\n return { skipped: `rebase.json could not be read (${error instanceof Error ? error.message : String(error)}).` };\n }\n const backend = findBackendApp(loaded.manifest);\n if (!backend) return { skipped: \"rebase.json declares no backend app to remember it on.\" };\n if (backend.app.registerDatabase === true) return { written: loaded.filePath ?? projectRoot };\n const manifest = {\n ...loaded.manifest,\n apps: { ...loaded.manifest.apps, [backend.name]: { ...backend.app, registerDatabase: true } }\n };\n return { written: writeManifest(projectRoot, manifest) };\n}\n\n/**\n * The tables the backend serves, read the way it reads them: the schema\n * directory's index, through `loadBackendSchema`, compiled to descriptors.\n *\n * A definition the backend would refuse is fatal here too, as it is at boot:\n * `rebase dev` runs this on every save, and skipping a table would overwrite\n * good types with a `Database` that is silently short one. A missing\n * directory is a `Refusal`: the message says all there is. A module that\n * throws on import is not: that is the project's own code failing, and the\n * stack `--debug` prints points at the line.\n */\nasync function loadTables(projectRoot: string, schemaDir: string, aliases?: ModuleAliases): Promise<TableDescriptor[]> {\n const absDir = path.resolve(schemaDir);\n if (!fs.existsSync(absDir)) {\n throw new Refusal(`Schema directory not found: ${absDir} (${PATH_RESOLUTION_RULE})`);\n }\n const { compiled } = await loadProjectSchema(projectRoot, absDir, aliases);\n return compiled.descriptors;\n}\n\n/**\n * Write generated files to the output directory.\n */\nfunction writeFiles(outputDir: string, files: GeneratedFile[]): void {\n const absOutput = path.resolve(outputDir);\n\n // Create output directory\n fs.mkdirSync(absOutput, { recursive: true });\n\n for (const file of files) {\n const filePath = path.join(absOutput, file.path);\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n fs.writeFileSync(filePath, file.content, \"utf-8\");\n }\n}\n\nfunction printSdkHelp(): void {\n console.log(`\n${chalk.bold(\"rebase generate-sdk\")} — generate a typed client from a project's schema\n\n${chalk.bold(\"Usage\")}\n rebase generate-sdk [options]\n\n${chalk.bold(\"Options\")}\n --schema-dir <dir> ${SCHEMA_DIR_FLAG_HELP}\n -o, --output <dir> Where to write the SDK (default: ./generated/sdk)\n (--out is accepted too, as on 'rebase build')\n --from <link|url> Fetch the schema from a running project instead of\n local source. \"link\" uses this checkout's linked project.\n --token <token> Bearer token for the contract endpoint\n (default: $REBASE_SERVICE_KEY)\n --register Also type server-side data: write the types and the\n Register declaration to backend/generated/, and\n remember it in rebase.json so later runs keep it.\n -h, --help Show this help\n\n${chalk.bold(\"Examples\")}\n rebase generate-sdk From backend/schema\n rebase generate-sdk --from link From the linked project\n rebase generate-sdk --from https://api.acme.com From any Rebase backend\n rebase generate-sdk --register Type context.data and rebase.dataAsAdmin too\n`.trim());\n}\n\n/** What `--from` sent to the contract endpoint, and which keys it left behind. */\ninterface ContractCredential {\n /** The bearer token sent: `--token`, the shell's key, or none. */\n sent: \"token\" | \"ambient\" | null;\n /** `REBASE_SERVICE_KEY` is in the shell environment. */\n shellKey: boolean;\n /** `REBASE_SERVICE_KEY` is in the project's `.env`. */\n envFileKey: boolean;\n}\n\n/**\n * What to say when the contract endpoint refuses, by what was and was not sent.\n *\n * \"Set REBASE_SERVICE_KEY\" is only right when no key exists. The shell's key is\n * withheld from every host but the linked project, and `.env`'s is never read\n * here — it is the local backend's key, and the linked project is usually a\n * deployed one — so telling a reader whose key is in `.env` to set it sends them\n * to fix something that is not broken.\n */\nfunction contractRefusalHint(credential: ContractCredential): string[] {\n if (credential.sent === \"token\") {\n return [\"The token passed with --token was refused: pass a service key, or an admin's token.\"];\n }\n if (credential.sent === \"ambient\") {\n return [\"REBASE_SERVICE_KEY was sent and refused: it is not this project's service key. Pass the right one with --token.\"];\n }\n if (credential.shellKey) {\n return [\n \"REBASE_SERVICE_KEY is set, but it is only sent to this checkout's linked project, and this host is not it.\",\n \"Pass the key with --token to send it here.\"\n ];\n }\n if (credential.envFileKey) {\n return [\n \"REBASE_SERVICE_KEY in .env is not sent: --from sends the shell's REBASE_SERVICE_KEY, and only to this checkout's linked project.\",\n \"Pass the key with --token.\"\n ];\n }\n return [\"Pass --token <key>, a service key or an admin's token. The shell's REBASE_SERVICE_KEY is sent only to this checkout's linked project.\"];\n}\n\n/**\n * Whether one entry of a contract's `tables` is a table descriptor, as far as\n * the generator reads one: a slug, a SQL name, columns and relations.\n */\nfunction isTableDescriptor(value: unknown): value is TableDescriptor {\n return typeof value === \"object\" && value !== null\n && \"slug\" in value && typeof value.slug === \"string\"\n && \"table\" in value && typeof value.table === \"string\"\n && \"columns\" in value && Array.isArray(value.columns)\n && \"relations\" in value && Array.isArray(value.relations);\n}\n\n/**\n * The tables a running project serves, from its contract endpoint\n * (`{ schemaVersion, runtime, tables: TableDescriptor[] }`). The descriptors\n * are plain data — no thunks to rehydrate — so they go to the generator as\n * they arrive.\n */\nasync function fetchRemoteTables(\n baseUrl: string,\n token: string | undefined,\n credential: ContractCredential\n): Promise<{ tables: TableDescriptor[]; schemaVersion: string }> {\n const url = `${baseUrl.replace(/\\/+$/, \"\")}/api/meta/contract`;\n\n const headers: Record<string, string> = { accept: \"application/json\" };\n if (token) headers.authorization = `Bearer ${token}`;\n\n let response: Response;\n try {\n response = await fetch(url, { headers });\n } catch (err) {\n console.log(chalk.red(` ✗ Could not reach ${url}`));\n console.log(chalk.gray(` ${err instanceof Error ? err.message : String(err)}`));\n process.exit(1);\n }\n\n if (response.status === 401 || response.status === 403) {\n console.log(chalk.red(` ✗ Not authorized to read the project contract (${response.status}).`));\n console.log(chalk.gray(\" The contract describes every table and relation, so it is admin-only.\"));\n for (const line of contractRefusalHint(credential)) console.log(chalk.gray(` ${line}`));\n process.exit(1);\n }\n\n if (response.status === 404) {\n console.log(chalk.red(\" ✗ This server has no contract endpoint.\"));\n console.log(chalk.gray(\" It needs to be running Rebase 0.11 or newer.\"));\n process.exit(1);\n }\n\n if (!response.ok) {\n console.log(chalk.red(` ✗ Contract request failed with ${response.status}.`));\n process.exit(1);\n }\n\n const contract: unknown = await response.json();\n const field = (key: string): unknown =>\n typeof contract === \"object\" && contract !== null && key in contract\n ? Object.entries(contract).find(([name]) => name === key)?.[1]\n : undefined;\n const tables = field(\"tables\");\n const schemaVersion = field(\"schemaVersion\");\n\n if (!Array.isArray(tables)) {\n if (Array.isArray(field(\"collections\"))) {\n // A server from before tables: its contract lists collections, a\n // shape this CLI no longer generates from.\n console.log(chalk.red(\" ✗ This server answers the contract with collections: it runs a Rebase release from before tables.\"));\n console.log(chalk.gray(\" Upgrade the server to a release that serves `tables`, or generate from this project's\"));\n console.log(chalk.gray(\" own backend/schema by running `rebase generate-sdk` without --from.\"));\n process.exit(1);\n }\n console.log(chalk.red(\" ✗ The contract response did not contain tables.\"));\n process.exit(1);\n }\n const invalid = tables.findIndex(entry => !isTableDescriptor(entry));\n if (invalid !== -1) {\n console.log(chalk.red(` ✗ The contract's tables[${invalid}] is not a table descriptor (no slug, table, columns or relations).`));\n process.exit(1);\n }\n\n return {\n tables: tables.filter(isTableDescriptor),\n schemaVersion: typeof schemaVersion === \"string\" ? schemaVersion : \"unknown\"\n };\n}\n\n/**\n * Decide whether the ambient service key may be sent to this host.\n *\n * `REBASE_SERVICE_KEY` grants full admin bypass. Attaching it to whatever URL\n * happened to be passed — or, worse, to whatever a committed `.rebase/cloud.json`\n * points at — would hand the project's most powerful credential to a host nobody\n * vetted. An explicit `--token` is a decision the caller made; the ambient\n * variable is not, so it only travels to the project this checkout is linked to.\n */\nfunction mayUseAmbientKey(target: string, cwd: string): boolean {\n const link = readLink(findProjectRoot(cwd) ?? cwd);\n if (!link?.apiUrl) return false;\n try {\n // Origin, not host: with a link recorded as https, an `http://` target\n // for the same host would otherwise pass and send the key in cleartext.\n return new URL(link.apiUrl).origin === new URL(target).origin;\n } catch {\n return false;\n }\n}\n\n/**\n * The base URL to show in the printed usage example.\n *\n * `rebase dev` binds a port derived from the project path, not 3001, and writes\n * the one it actually got to `.rebase/state.json`. Printing a hardcoded\n * `localhost:3001` sent people to a port nothing was listening on — or, with\n * several projects on one machine, to a different project's backend. Prefer the\n * port `rebase dev` says it is starting the backend on (`DEV_BACKEND_URL_ENV`:\n * it regenerates the SDK before the backend binds), then the port this project\n * last ran on; fall back to the literal only when the project has never been\n * started.\n */\nexport function resolveExampleBaseUrl(cwd: string): string {\n const fromDev = process.env[DEV_BACKEND_URL_ENV]?.trim();\n if (fromDev) return fromDev;\n const projectRoot = findProjectRoot(cwd) ?? cwd;\n try {\n const state = JSON.parse(fs.readFileSync(path.join(projectRoot, \".rebase\", \"state.json\"), \"utf-8\"));\n if (typeof state.baseUrl === \"string\" && state.baseUrl) return state.baseUrl;\n if (typeof state.port === \"number\") return `http://localhost:${state.port}`;\n } catch {\n // Never started, or the file is unreadable — fall through.\n }\n return \"http://localhost:3001\";\n}\n\n/** Whether a slug can be written as `rebase.data.<slug>` rather than a lookup. */\nexport function isIdentifierLike(slug: string): boolean {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(slug);\n}\n\n/** Resolve `--from` into a base URL, following the link file when asked. */\nfunction resolveSchemaSource(from: string, cwd: string): string {\n if (from !== \"link\") {\n // A bare hostname or a typo would otherwise be handed to `fetch` and fail\n // with something unhelpful; a non-http scheme has no business here at all.\n let parsed: URL;\n try {\n parsed = new URL(from);\n } catch {\n console.log(chalk.red(` ✗ \"${from}\" is not a valid URL.`));\n console.log(chalk.gray(\" Pass a full URL, e.g. https://api.example.com, or \\\"link\\\".\"));\n process.exit(1);\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n console.log(chalk.red(\" ✗ The project URL must be http or https.\"));\n process.exit(1);\n }\n return from;\n }\n\n const projectRoot = findProjectRoot(cwd) ?? cwd;\n const link = readLink(projectRoot);\n\n if (!link) {\n console.log(chalk.red(\" ✗ This checkout is not linked to a project.\"));\n console.log(chalk.gray(\" Run `rebase cloud link <url>`, or pass --from <url>.\"));\n process.exit(1);\n }\n\n const apiUrl = link.apiUrl;\n if (!apiUrl) {\n console.log(chalk.red(\" ✗ The project link has no API URL.\"));\n console.log(chalk.gray(\" Re-link with `rebase cloud link <url>` to record one.\"));\n process.exit(1);\n }\n\n return apiUrl;\n}\n\n/**\n * Main entry point for the generate-sdk command.\n */\nexport async function generateSdkCommand(args: GenerateSDKArgs): Promise<void> {\n const { schemaDir, output, cwd } = args;\n\n if (args.help) {\n printSdkHelp();\n return;\n }\n\n const resolvedSchemaDir = path.isAbsolute(schemaDir)\n ? schemaDir\n : path.join(cwd, schemaDir);\n const projectRoot = args.projectRoot ?? findProjectRoot(cwd) ?? undefined;\n\n const resolvedOutput = path.isAbsolute(output)\n ? output\n : path.join(cwd, output);\n\n console.log(\"\");\n console.log(chalk.bold(\" 🔧 Rebase SDK Generator\"));\n console.log(\"\");\n\n let tables: TableDescriptor[];\n let remoteSchemaVersion: string | undefined;\n\n if (args.from) {\n const baseUrl = resolveSchemaSource(args.from, cwd);\n console.log(` ${chalk.gray(\"Project:\")} ${baseUrl}`);\n console.log(` ${chalk.gray(\"Output:\")} ${resolvedOutput}`);\n console.log(\"\");\n console.log(chalk.cyan(\" → Fetching the project contract...\"));\n\n const ambient = mayUseAmbientKey(baseUrl, cwd)\n ? process.env.REBASE_SERVICE_KEY\n : undefined;\n\n if (!args.token && !ambient && process.env.REBASE_SERVICE_KEY) {\n console.log(chalk.dim(\n \" (not sending REBASE_SERVICE_KEY — this host is not the linked project; pass --token to override)\"\n ));\n }\n\n const remote = await fetchRemoteTables(baseUrl, args.token || ambient, {\n sent: args.token ? \"token\" : ambient ? \"ambient\" : null,\n shellKey: Boolean(process.env.REBASE_SERVICE_KEY),\n envFileKey: Boolean(readEnvFile(findProjectRoot(cwd) ?? cwd).REBASE_SERVICE_KEY)\n });\n tables = remote.tables;\n remoteSchemaVersion = remote.schemaVersion;\n } else {\n // A headless project has no schema directory by design: its API is\n // introspected from the live database at boot, and there is nothing here\n // to generate a client from. The scaffold ships `pnpm generate:sdk`\n // anyway, so the documented headless path had a script that could only\n // ever fail — and it failed with a path, which reads as a broken install\n // rather than a question with an answer.\n if (!fs.existsSync(resolvedSchemaDir)) {\n console.log(chalk.gray(\n \" ○ This project derives its API from the database — \"\n + \"there is no backend/schema to generate a client from.\"\n ));\n console.log(chalk.gray(\n ` Nothing to generate from: ${resolvedSchemaDir} does not exist.`\n ));\n console.log(\"\");\n return;\n }\n console.log(` ${chalk.gray(\"Schema:\")} ${resolvedSchemaDir}`);\n console.log(` ${chalk.gray(\"Output:\")} ${resolvedOutput}`);\n console.log(\"\");\n console.log(chalk.cyan(\" → Loading the tables...\"));\n try {\n tables = await loadTables(projectRoot ?? cwd, resolvedSchemaDir, args.moduleAliases);\n } catch (err) {\n // A definition the backend would refuse to boot on: every problem,\n // one per line, each naming its table.\n if (isSchemaDefinitionError(err)) {\n console.log(\"\");\n console.log(chalk.red(` ✗ ${err.message}`));\n process.exit(1);\n }\n throw err;\n }\n }\n\n // Sorted by slug, so the same schema generates the same SDK.\n tables = sortedBySlug(tables);\n\n if (tables.length === 0) {\n console.log(chalk.red(\" ✗ No tables found. Nothing to generate.\"));\n process.exit(1);\n }\n\n console.log(chalk.green(` ✓ Found ${tables.length} table(s): ${tables.map(table => table.slug).join(\", \")}`));\n console.log(\"\");\n\n // 2. Generate SDK files\n console.log(chalk.cyan(\" → Generating SDK files...\"));\n let files: GeneratedFile[];\n try {\n files = generateSDK(tables, { baseUrl: resolveExampleBaseUrl(cwd) });\n } catch (err) {\n // A schema that cannot be expressed as valid TypeScript — two slugs\n // that collide on one accessor, a slug with no usable name. The\n // generator refuses rather than emitting a file that does not compile,\n // or one that silently routes a table's reads to another's.\n if (err instanceof CodegenError) {\n console.log(\"\");\n console.log(chalk.red(` ✗ ${err.message}`));\n process.exit(1);\n }\n throw err;\n }\n\n // Stamp the schema this SDK was built from.\n //\n // Without it, an app in a separate repository has no way to know its client\n // is stale: the backend moves on, the frontend keeps compiling against types\n // captured weeks ago, and the mismatch only surfaces as a runtime error. With\n // it, CI can compare against `/api/meta/schema-version` and say so.\n //\n // No generation timestamp. Tables are sorted above precisely so that\n // the same schema produces the same bytes; a timestamp put that back,\n // turning every regeneration into a diff and making the obvious staleness\n // gate — `rebase generate-sdk && git diff --exit-code` — impossible to pass.\n // `SCHEMA_VERSION` already identifies what this was built from, and does it\n // in a way that can be compared against a running project.\n const schemaVersion = remoteSchemaVersion ?? computeSchemaVersion(tables);\n files.push({\n path: \"schema.meta.ts\",\n content: `// Auto-generated by \\`rebase generate-sdk\\`. Do not edit.\n//\n// The schema version this SDK was generated from. Compare it against the\n// project's current version to detect drift:\n//\n// curl -s <api-url>/api/meta/schema-version\n//\n// Pass it to the client as \\`schemaVersion\\` and every request carries it in\n// the \\`x-rebase-schema\\` header, so the server can name the drift instead of\n// answering a renamed field with a bare 400.\nexport const SCHEMA_VERSION = ${JSON.stringify(schemaVersion)};\n`\n });\n\n console.log(chalk.green(` ✓ Generated ${files.length} file(s)`));\n console.log(chalk.gray(` schema ${schemaVersion}`));\n\n // 3. Write to disk\n console.log(chalk.cyan(` → Writing to ${resolvedOutput}...`));\n writeFiles(resolvedOutput, files);\n\n // 4. The server-side registration: on request, and kept current once a\n // project has it, so `rebase dev` regenerating the SDK never leaves the\n // server typed against an older schema than the client.\n const registerDir = projectRoot ? registrationDir(projectRoot) : undefined;\n if (args.register || (registerDir && hasRegistration(registerDir)) || manifestRegisters(projectRoot)) {\n if (!registerDir || !fs.existsSync(path.dirname(registerDir))) {\n console.log(chalk.red(` ✗ No backend/ directory to register the Database in${registerDir ? ` (${path.dirname(registerDir)})` : \"\"}.`));\n console.log(chalk.gray(\" --register writes backend/generated/register.ts; run it inside a project with a backend.\"));\n process.exit(1);\n return;\n }\n const databaseTypes = files.find((file) => file.path === \"database.types.ts\")?.content;\n if (databaseTypes !== undefined) {\n try {\n writeRegistration(registerDir, databaseTypes);\n } catch (error) {\n console.log(chalk.red(` ✗ ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n return;\n }\n console.log(chalk.green(` ✓ Registered the Database for server-side code in ${registerDir}`));\n if (args.register) {\n const remembered = rememberRegistration(projectRoot);\n if (\"written\" in remembered) {\n console.log(chalk.gray(` Remembered in ${path.relative(cwd, remembered.written) || \"rebase.json\"} (registerDatabase).`));\n } else {\n console.log(chalk.yellow(` ${remembered.skipped}`));\n }\n }\n }\n }\n\n console.log(\"\");\n console.log(chalk.green.bold(\" ✓ SDK generated successfully!\"));\n console.log(\"\");\n const typesImport = `./${path.relative(cwd, path.join(resolvedOutput, \"database.types\"))}`;\n const metaImport = `./${path.relative(cwd, path.join(resolvedOutput, \"schema.meta\"))}`;\n const exampleSlug = tables[0]?.slug || \"my_table\";\n\n console.log(chalk.gray(\" Usage:\"));\n console.log(chalk.gray(\" import { createRebaseClient } from '@rebasepro/client';\"));\n console.log(chalk.gray(` import { tablesDictionary, type Database } from '${typesImport}';`));\n console.log(chalk.gray(` import { SCHEMA_VERSION } from '${metaImport}';`));\n console.log(\"\");\n console.log(chalk.gray(\" const rebase = createRebaseClient<Database>({\"));\n console.log(chalk.gray(` baseUrl: '${resolveExampleBaseUrl(cwd)}',`));\n // Sent as `x-rebase-schema` on every request. Costs one line here and is\n // the difference between a server that can say \"this client is three\n // deploys behind\" and one that can only reject a field it does not know.\n console.log(chalk.gray(\" schemaVersion: SCHEMA_VERSION,\"));\n // Without the dictionary a hyphenated slug is not resolvable from the\n // property name alone, and the request 404s at runtime.\n console.log(chalk.gray(\" tables: tablesDictionary,\"));\n console.log(chalk.gray(\" // token: 'your-jwt-token',\"));\n console.log(chalk.gray(\" });\"));\n console.log(\"\");\n // `rebase.data.<accessor>` is the typed surface, so it is what gets printed.\n // `rebase.data.table(slug)` exists too, but it is generic over\n // `Record<string, unknown>` and has no link to `Database` — it was the\n // headline example here for a while, which advertised the one call shape\n // that throws away the types this command just generated.\n const exampleAccessor = toTableAccessor(exampleSlug);\n const exampleAccess = isIdentifierLike(exampleAccessor)\n ? `rebase.data.${exampleAccessor}`\n : `rebase.data[${JSON.stringify(exampleAccessor)}]`;\n console.log(chalk.gray(` const { data } = await ${exampleAccess}.find();`));\n console.log(\"\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwDA,IAAa,gBAAgB;;AAG7B,IAAM,kBAAkB;AAExB,IAAM,kBAAkB,GAAG,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;AAwB3C,SAAgB,gBAAgB,aAA6B;CACzD,OAAO,KAAK,KAAK,aAAa,aAAa;AAC/C;;AAGA,SAAS,gBAAgB,KAAsB;CAC3C,IAAI;EACA,OAAO,GAAG,aAAa,KAAK,KAAK,KAAK,aAAa,GAAG,OAAO,CAAC,CAAC,WAAW,eAAe;CAC7F,QAAQ;EACJ,OAAO;CACX;AACJ;;AAGA,SAAS,eAAe,UAAkB,SAAuB;CAC7D,IAAI;EACA,IAAI,GAAG,aAAa,UAAU,OAAO,MAAM,SAAS;CACxD,QAAQ,CAER;CACA,GAAG,cAAc,UAAU,SAAS,OAAO;AAC/C;;;;;;AAOA,SAAS,kBAAkB,KAAa,eAA6B;CACjE,MAAM,eAAe,KAAK,KAAK,KAAK,aAAa;CACjD,IAAI,GAAG,WAAW,YAAY,KAAK,CAAC,gBAAgB,GAAG,GACnD,MAAM,IAAI,MACN,GAAG,aAAa,mHAEpB;CAEJ,GAAG,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;CACrC,eAAe,KAAK,KAAK,KAAK,mBAAmB,GAAG,aAAa;CACjE,eAAe,cAAc,eAAe;AAChD;;;;;;;;;;;;;;;AAgBA,eAAsB,0BAClB,aACA,QACA,kBACsB;CACtB,MAAM,MAAM,gBAAgB,WAAW;CACvC,IAAI,CAAC,oBAAoB,CAA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AAK,gBAAgB,gBAAgB,CAAC;CACvF,MAAM,aAAa,KAAK,KAAK,SAAS,KAAK,KAAK,KAAK,gBAAgB,aAAa,CAAC;CACnF,MAAM,cAAc,OAAO,EAAE,EAAE,QAAQ;CAEvC,QAAQ,IAAI,MAAM,KAAK,UAAU,CAAC;CAClC,QAAQ,IAAI,MAAM,KAAK,6DAA6D,CAAC;CACrF,QAAQ,IAAI,MAAM,KAAK,wDAAwD,YAAY,GAAG,CAAC;CAC/F,QAAQ,IAAI,MAAM,KAAK,uCAAuC,WAAW,GAAG,CAAC;CAC7E,QAAQ,IAAI,EAAE;CACd,QAAQ,IAAI,MAAM,KAAK,mDAAmD,CAAC;CAC3E,QAAQ,IAAI,MAAM,KAAK,qBAAqB,sBAAsB,GAAG,EAAE,GAAG,CAAC;CAI3E,QAAQ,IAAI,MAAM,KAAK,wCAAwC,CAAC;CAGhE,QAAQ,IAAI,MAAM,KAAK,mCAAmC,CAAC;CAC3D,QAAQ,IAAI,MAAM,KAAK,qCAAqC,CAAC;CAC7D,QAAQ,IAAI,MAAM,KAAK,SAAS,CAAC;CACjC,QAAQ,IAAI,EAAE;CAMd,MAAM,kBAAkB,gBAAgB,WAAW;CACnD,MAAM,gBAAgB,iBAAiB,eAAe,IAChD,eAAe,oBACf,eAAe,KAAK,UAAU,eAAe,EAAE;CACrD,QAAQ,IAAI,MAAM,KAAK,8BAA8B,cAAc,SAAS,CAAC;CAC7E,QAAQ,IAAI,EAAE;AAClB"}
|
|
1
|
+
{"version":3,"file":"generate_sdk-UT1lwwRT.js","names":[],"sources":["../src/commands/generate_sdk.ts"],"sourcesContent":["/**\n * CLI command: generate-sdk\n *\n * Reads the project's tables — `backend/schema`, through the loader the\n * backend boots from, so the SDK describes exactly the tables served — or,\n * with `--from`, a running project's contract, and writes a typed TypeScript\n * SDK to the output directory (default: ./generated/sdk).\n */\n\nimport fs from \"fs\";\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { computeSchemaVersion, type TableDescriptor } from \"@rebasepro/types\";\nimport { CodegenError, generateSDK, GeneratedFile, toTableAccessor } from \"@rebasepro/codegen\";\nimport { isSchemaDefinitionError } from \"@rebasepro/common\";\nimport { findProjectRoot, readEnvFile } from \"../utils/project\";\nimport { DEV_BACKEND_URL_ENV } from \"../utils/dev-server\";\nimport { Refusal } from \"../utils/refusal\";\nimport { findBackendApp, GENERATED_DIR, loadManifest, manifestExists, writeManifest } from \"../manifest\";\nimport { readLink } from \"./cloud/context\";\nimport { SCHEMA_DIR_FLAG_HELP, PATH_RESOLUTION_RULE } from \"../utils/path-flags\";\nimport { loadProjectSchema, type ModuleAliases } from \"../utils/project-schema\";\n\ninterface GenerateSDKArgs {\n /** The schema directory: the one whose index exports the tables. */\n schemaDir: string;\n output: string;\n cwd: string;\n /**\n * Where to read the schema from instead of local source.\n *\n * `link` uses this checkout's linked project; anything else is treated as\n * the base URL of a Rebase backend. This is what lets a repository that\n * contains no tables — a separate frontend, a second web app — generate\n * a typed client from the project it talks to.\n */\n from?: string;\n /** Bearer token for the contract endpoint. Falls back to REBASE_SERVICE_KEY. */\n token?: string;\n /**\n * Also register the generated `Database` for server-side code: write the\n * types and the `Register` augmentation into `backend/generated/`. See\n * {@link writeRegistration}.\n */\n register?: boolean;\n /**\n * The directory holding `rebase.json`, where `--register` is remembered\n * and under which `backend/generated/` is. Found from `cwd` when not given.\n */\n projectRoot?: string;\n /** Module specifiers mapped to files when importing the schema (in-repo runs and tests). */\n moduleAliases?: ModuleAliases;\n help?: boolean;\n}\n\n/** What `--register` writes, and what marks a project as having opted in. */\nexport const REGISTER_FILE = \"register.ts\";\n\n/** The first line of {@link REGISTER_FILE}: a file without it is the developer's own. */\nconst REGISTER_MARKER = \"// Auto-generated by `rebase generate-sdk --register`. Do not edit.\";\n\nconst REGISTER_SOURCE = `${REGISTER_MARKER}\n//\n// Registers this project's generated \\`Database\\` on \\`@rebasepro/types\\`, so\n// \\`context.data\\` in table hooks, \\`rebase.dataAsAdmin\\`, and the\n// \\`rebase\\` a function or a cron receives are typed from it. Every later\n// \\`rebase generate-sdk\\` (and \\`rebase dev\\`) refreshes this directory; delete\n// it to go back to untyped server-side data.\nimport type { Database } from \"./database.types\";\n\ndeclare module \"@rebasepro/types\" {\n interface Register {\n database: Database;\n }\n}\n`;\n\n/**\n * Where `--register` writes: `backend/generated/` under the project root.\n *\n * Inside `backend/` because that is the program the hooks, functions and\n * crons it types are compiled in. The types are copied in beside the\n * registration rather than imported from `generated/sdk`, which is outside\n * the backend's `rootDir`.\n */\nexport function registrationDir(projectRoot: string): string {\n return path.join(projectRoot, GENERATED_DIR);\n}\n\n/** Whether this project opted in: the registration is there, and it is ours. */\nfunction hasRegistration(dir: string): boolean {\n try {\n return fs.readFileSync(path.join(dir, REGISTER_FILE), \"utf-8\").startsWith(REGISTER_MARKER);\n } catch {\n return false;\n }\n}\n\n/** Write a file only when its content changed, so a watcher on the directory does not restart for nothing. */\nfunction writeIfChanged(filePath: string, content: string): void {\n try {\n if (fs.readFileSync(filePath, \"utf-8\") === content) return;\n } catch {\n // Not there yet.\n }\n fs.writeFileSync(filePath, content, \"utf-8\");\n}\n\n/**\n * Write the generated `Database` and its `Register` augmentation into\n * {@link registrationDir}. Refuses to overwrite a `register.ts` it did not\n * write.\n */\nfunction writeRegistration(dir: string, databaseTypes: string): void {\n const registerPath = path.join(dir, REGISTER_FILE);\n if (fs.existsSync(registerPath) && !hasRegistration(dir)) {\n throw new Error(\n `${registerPath} exists and was not written by \"rebase generate-sdk --register\". ` +\n \"Move it, or register the Database there yourself.\"\n );\n }\n fs.mkdirSync(dir, { recursive: true });\n writeIfChanged(path.join(dir, \"database.types.ts\"), databaseTypes);\n writeIfChanged(registerPath, REGISTER_SOURCE);\n}\n\n/**\n * Write the server-side registration from the build's tables, exactly as\n * `rebase generate-sdk` writes it.\n *\n * Only for a project that asked for it: `registerDatabase` in `rebase.json`,\n * or a registration an earlier `--register` left, which is kept current. The\n * registration lives in gitignored `backend/generated/`, so a fresh clone (a\n * CI job) has none until something writes it, and a bundle compiled without\n * it types `context.data` as untyped rows: hooks that read a typed column fail\n * to compile there while they compile locally.\n *\n * Returns the directory written, or null when there was nothing to do.\n * Throws when a `register.ts` there is not ours, as `generate-sdk` refuses.\n */\nexport async function writeRegistrationForBuild(\n projectRoot: string,\n tables: readonly TableDescriptor[],\n registerDatabase: boolean\n): Promise<string | null> {\n const dir = registrationDir(projectRoot);\n if (!registerDatabase && !hasRegistration(dir)) return null;\n if (tables.length === 0) return null;\n const databaseTypes = generateSDK(sortedBySlug(tables), { includeReadme: false })\n .find((file) => file.path === \"database.types.ts\")?.content;\n if (databaseTypes === undefined) return null;\n writeRegistration(dir, databaseTypes);\n return dir;\n}\n\n/** Tables sorted by slug: the same schema generates the same bytes, whatever order the index lists it in. */\nfunction sortedBySlug(tables: readonly TableDescriptor[]): TableDescriptor[] {\n return [...tables].sort((a, b) => a.slug.localeCompare(b.slug));\n}\n\n/**\n * Whether `rebase.json` asks for the registration (`registerDatabase: true` on\n * the backend app). That is what survives a clone: `generated/` is gitignored,\n * so a `register.ts` from an earlier run is not there to say it.\n *\n * An unreadable manifest answers no; `rebase build` is where it is reported.\n */\nfunction manifestRegisters(projectRoot: string | undefined): boolean {\n if (!projectRoot || !manifestExists(projectRoot)) return false;\n try {\n return findBackendApp(loadManifest(projectRoot).manifest)?.app.registerDatabase === true;\n } catch {\n return false;\n }\n}\n\n/**\n * Remember `--register` in `rebase.json`, so later runs, `rebase dev` and a\n * fresh clone keep registering. Returns where it was written, or why not.\n *\n * Never creates the file: a project without one is synthesized from its\n * layout, and writing one is `rebase apps init`'s decision, not this flag's.\n */\nfunction rememberRegistration(projectRoot: string | undefined): { written: string } | { skipped: string } {\n if (!projectRoot || !manifestExists(projectRoot)) {\n return { skipped: \"No rebase.json here, so the choice lasts as long as the generated files.\" };\n }\n let loaded: ReturnType<typeof loadManifest>;\n try {\n loaded = loadManifest(projectRoot);\n } catch (error) {\n return { skipped: `rebase.json could not be read (${error instanceof Error ? error.message : String(error)}).` };\n }\n const backend = findBackendApp(loaded.manifest);\n if (!backend) return { skipped: \"rebase.json declares no backend app to remember it on.\" };\n if (backend.app.registerDatabase === true) return { written: loaded.filePath ?? projectRoot };\n const manifest = {\n ...loaded.manifest,\n apps: { ...loaded.manifest.apps, [backend.name]: { ...backend.app, registerDatabase: true } }\n };\n return { written: writeManifest(projectRoot, manifest) };\n}\n\n/**\n * The tables the backend serves, read the way it reads them: the schema\n * directory's index, through `loadBackendSchema`, compiled to descriptors.\n *\n * A definition the backend would refuse is fatal here too, as it is at boot:\n * `rebase dev` runs this on every save, and skipping a table would overwrite\n * good types with a `Database` that is silently short one. A missing\n * directory is a `Refusal`: the message says all there is. A module that\n * throws on import is not: that is the project's own code failing, and the\n * stack `--debug` prints points at the line.\n */\nasync function loadTables(projectRoot: string, schemaDir: string, aliases?: ModuleAliases): Promise<TableDescriptor[]> {\n const absDir = path.resolve(schemaDir);\n if (!fs.existsSync(absDir)) {\n throw new Refusal(`Schema directory not found: ${absDir} (${PATH_RESOLUTION_RULE})`);\n }\n const { compiled } = await loadProjectSchema(projectRoot, absDir, aliases);\n return compiled.descriptors;\n}\n\n/**\n * Write generated files to the output directory.\n */\nfunction writeFiles(outputDir: string, files: GeneratedFile[]): void {\n const absOutput = path.resolve(outputDir);\n\n // Create output directory\n fs.mkdirSync(absOutput, { recursive: true });\n\n for (const file of files) {\n const filePath = path.join(absOutput, file.path);\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n fs.writeFileSync(filePath, file.content, \"utf-8\");\n }\n}\n\nfunction printSdkHelp(): void {\n console.log(`\n${chalk.bold(\"rebase generate-sdk\")} — generate a typed client from a project's schema\n\n${chalk.bold(\"Usage\")}\n rebase generate-sdk [options]\n\n${chalk.bold(\"Options\")}\n --schema-dir <dir> ${SCHEMA_DIR_FLAG_HELP}\n -o, --output <dir> Where to write the SDK (default: ./generated/sdk)\n (--out is accepted too, as on 'rebase build')\n --from <link|url> Fetch the schema from a running project instead of\n local source. \"link\" uses this checkout's linked project.\n --token <token> Bearer token for the contract endpoint\n (default: $REBASE_SERVICE_KEY)\n --register Also type server-side data: write the types and the\n Register declaration to backend/generated/, and\n remember it in rebase.json so later runs keep it.\n -h, --help Show this help\n\n${chalk.bold(\"Examples\")}\n rebase generate-sdk From backend/schema\n rebase generate-sdk --from link From the linked project\n rebase generate-sdk --from https://api.acme.com From any Rebase backend\n rebase generate-sdk --register Type context.data and rebase.dataAsAdmin too\n`.trim());\n}\n\n/** What `--from` sent to the contract endpoint, and which keys it left behind. */\ninterface ContractCredential {\n /** The bearer token sent: `--token`, the shell's key, or none. */\n sent: \"token\" | \"ambient\" | null;\n /** `REBASE_SERVICE_KEY` is in the shell environment. */\n shellKey: boolean;\n /** `REBASE_SERVICE_KEY` is in the project's `.env`. */\n envFileKey: boolean;\n}\n\n/**\n * What to say when the contract endpoint refuses, by what was and was not sent.\n *\n * \"Set REBASE_SERVICE_KEY\" is only right when no key exists. The shell's key is\n * withheld from every host but the linked project, and `.env`'s is never read\n * here — it is the local backend's key, and the linked project is usually a\n * deployed one — so telling a reader whose key is in `.env` to set it sends them\n * to fix something that is not broken.\n */\nfunction contractRefusalHint(credential: ContractCredential): string[] {\n if (credential.sent === \"token\") {\n return [\"The token passed with --token was refused: pass a service key, or an admin's token.\"];\n }\n if (credential.sent === \"ambient\") {\n return [\"REBASE_SERVICE_KEY was sent and refused: it is not this project's service key. Pass the right one with --token.\"];\n }\n if (credential.shellKey) {\n return [\n \"REBASE_SERVICE_KEY is set, but it is only sent to this checkout's linked project, and this host is not it.\",\n \"Pass the key with --token to send it here.\"\n ];\n }\n if (credential.envFileKey) {\n return [\n \"REBASE_SERVICE_KEY in .env is not sent: --from sends the shell's REBASE_SERVICE_KEY, and only to this checkout's linked project.\",\n \"Pass the key with --token.\"\n ];\n }\n return [\"Pass --token <key>, a service key or an admin's token. The shell's REBASE_SERVICE_KEY is sent only to this checkout's linked project.\"];\n}\n\n/**\n * Whether one entry of a contract's `tables` is a table descriptor, as far as\n * the generator reads one: a slug, a SQL name, columns and relations.\n */\nfunction isTableDescriptor(value: unknown): value is TableDescriptor {\n return typeof value === \"object\" && value !== null\n && \"slug\" in value && typeof value.slug === \"string\"\n && \"table\" in value && typeof value.table === \"string\"\n && \"columns\" in value && Array.isArray(value.columns)\n && \"relations\" in value && Array.isArray(value.relations);\n}\n\n/**\n * The tables a running project serves, from its contract endpoint\n * (`{ schemaVersion, runtime, tables: TableDescriptor[] }`). The descriptors\n * are plain data — no thunks to rehydrate — so they go to the generator as\n * they arrive.\n */\nasync function fetchRemoteTables(\n baseUrl: string,\n token: string | undefined,\n credential: ContractCredential\n): Promise<{ tables: TableDescriptor[]; schemaVersion: string }> {\n const url = `${baseUrl.replace(/\\/+$/, \"\")}/api/meta/contract`;\n\n const headers: Record<string, string> = { accept: \"application/json\" };\n if (token) headers.authorization = `Bearer ${token}`;\n\n let response: Response;\n try {\n response = await fetch(url, { headers });\n } catch (err) {\n console.log(chalk.red(` ✗ Could not reach ${url}`));\n console.log(chalk.gray(` ${err instanceof Error ? err.message : String(err)}`));\n process.exit(1);\n }\n\n if (response.status === 401 || response.status === 403) {\n console.log(chalk.red(` ✗ Not authorized to read the project contract (${response.status}).`));\n console.log(chalk.gray(\" The contract describes every table and relation, so it is admin-only.\"));\n for (const line of contractRefusalHint(credential)) console.log(chalk.gray(` ${line}`));\n process.exit(1);\n }\n\n if (response.status === 404) {\n console.log(chalk.red(\" ✗ This server has no contract endpoint.\"));\n console.log(chalk.gray(\" It needs to be running Rebase 0.11 or newer.\"));\n process.exit(1);\n }\n\n if (!response.ok) {\n console.log(chalk.red(` ✗ Contract request failed with ${response.status}.`));\n process.exit(1);\n }\n\n const contract: unknown = await response.json();\n const field = (key: string): unknown =>\n typeof contract === \"object\" && contract !== null && key in contract\n ? Object.entries(contract).find(([name]) => name === key)?.[1]\n : undefined;\n const tables = field(\"tables\");\n const schemaVersion = field(\"schemaVersion\");\n\n if (!Array.isArray(tables)) {\n if (Array.isArray(field(\"collections\"))) {\n // A server from before tables: its contract lists collections, a\n // shape this CLI no longer generates from.\n console.log(chalk.red(\" ✗ This server answers the contract with collections: it runs a Rebase release from before tables.\"));\n console.log(chalk.gray(\" Upgrade the server to a release that serves `tables`, or generate from this project's\"));\n console.log(chalk.gray(\" own backend/schema by running `rebase generate-sdk` without --from.\"));\n process.exit(1);\n }\n console.log(chalk.red(\" ✗ The contract response did not contain tables.\"));\n process.exit(1);\n }\n const invalid = tables.findIndex(entry => !isTableDescriptor(entry));\n if (invalid !== -1) {\n console.log(chalk.red(` ✗ The contract's tables[${invalid}] is not a table descriptor (no slug, table, columns or relations).`));\n process.exit(1);\n }\n\n return {\n tables: tables.filter(isTableDescriptor),\n schemaVersion: typeof schemaVersion === \"string\" ? schemaVersion : \"unknown\"\n };\n}\n\n/**\n * Decide whether the ambient service key may be sent to this host.\n *\n * `REBASE_SERVICE_KEY` grants full admin bypass. Attaching it to whatever URL\n * happened to be passed — or, worse, to whatever a committed `.rebase/cloud.json`\n * points at — would hand the project's most powerful credential to a host nobody\n * vetted. An explicit `--token` is a decision the caller made; the ambient\n * variable is not, so it only travels to the project this checkout is linked to.\n */\nfunction mayUseAmbientKey(target: string, cwd: string): boolean {\n const link = readLink(findProjectRoot(cwd) ?? cwd);\n if (!link?.apiUrl) return false;\n try {\n // Origin, not host: with a link recorded as https, an `http://` target\n // for the same host would otherwise pass and send the key in cleartext.\n return new URL(link.apiUrl).origin === new URL(target).origin;\n } catch {\n return false;\n }\n}\n\n/**\n * The base URL to show in the printed usage example.\n *\n * `rebase dev` binds a port derived from the project path, not 3001, and writes\n * the one it actually got to `.rebase/state.json`. Printing a hardcoded\n * `localhost:3001` sent people to a port nothing was listening on — or, with\n * several projects on one machine, to a different project's backend. Prefer the\n * port `rebase dev` says it is starting the backend on (`DEV_BACKEND_URL_ENV`:\n * it regenerates the SDK before the backend binds), then the port this project\n * last ran on; fall back to the literal only when the project has never been\n * started.\n */\nexport function resolveExampleBaseUrl(cwd: string): string {\n const fromDev = process.env[DEV_BACKEND_URL_ENV]?.trim();\n if (fromDev) return fromDev;\n const projectRoot = findProjectRoot(cwd) ?? cwd;\n try {\n const state = JSON.parse(fs.readFileSync(path.join(projectRoot, \".rebase\", \"state.json\"), \"utf-8\"));\n if (typeof state.baseUrl === \"string\" && state.baseUrl) return state.baseUrl;\n if (typeof state.port === \"number\") return `http://localhost:${state.port}`;\n } catch {\n // Never started, or the file is unreadable — fall through.\n }\n return \"http://localhost:3001\";\n}\n\n/** Whether a slug can be written as `rebase.data.<slug>` rather than a lookup. */\nexport function isIdentifierLike(slug: string): boolean {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(slug);\n}\n\n/** Resolve `--from` into a base URL, following the link file when asked. */\nfunction resolveSchemaSource(from: string, cwd: string): string {\n if (from !== \"link\") {\n // A bare hostname or a typo would otherwise be handed to `fetch` and fail\n // with something unhelpful; a non-http scheme has no business here at all.\n let parsed: URL;\n try {\n parsed = new URL(from);\n } catch {\n console.log(chalk.red(` ✗ \"${from}\" is not a valid URL.`));\n console.log(chalk.gray(\" Pass a full URL, e.g. https://api.example.com, or \\\"link\\\".\"));\n process.exit(1);\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n console.log(chalk.red(\" ✗ The project URL must be http or https.\"));\n process.exit(1);\n }\n return from;\n }\n\n const projectRoot = findProjectRoot(cwd) ?? cwd;\n const link = readLink(projectRoot);\n\n if (!link) {\n console.log(chalk.red(\" ✗ This checkout is not linked to a project.\"));\n console.log(chalk.gray(\" Run `rebase cloud link <url>`, or pass --from <url>.\"));\n process.exit(1);\n }\n\n const apiUrl = link.apiUrl;\n if (!apiUrl) {\n console.log(chalk.red(\" ✗ The project link has no API URL.\"));\n console.log(chalk.gray(\" Re-link with `rebase cloud link <url>` to record one.\"));\n process.exit(1);\n }\n\n return apiUrl;\n}\n\n/**\n * Main entry point for the generate-sdk command.\n */\nexport async function generateSdkCommand(args: GenerateSDKArgs): Promise<void> {\n const { schemaDir, output, cwd } = args;\n\n if (args.help) {\n printSdkHelp();\n return;\n }\n\n const resolvedSchemaDir = path.isAbsolute(schemaDir)\n ? schemaDir\n : path.join(cwd, schemaDir);\n const projectRoot = args.projectRoot ?? findProjectRoot(cwd) ?? undefined;\n\n const resolvedOutput = path.isAbsolute(output)\n ? output\n : path.join(cwd, output);\n\n console.log(\"\");\n console.log(chalk.bold(\" 🔧 Rebase SDK Generator\"));\n console.log(\"\");\n\n let tables: TableDescriptor[];\n let remoteSchemaVersion: string | undefined;\n\n if (args.from) {\n const baseUrl = resolveSchemaSource(args.from, cwd);\n console.log(` ${chalk.gray(\"Project:\")} ${baseUrl}`);\n console.log(` ${chalk.gray(\"Output:\")} ${resolvedOutput}`);\n console.log(\"\");\n console.log(chalk.cyan(\" → Fetching the project contract...\"));\n\n const ambient = mayUseAmbientKey(baseUrl, cwd)\n ? process.env.REBASE_SERVICE_KEY\n : undefined;\n\n if (!args.token && !ambient && process.env.REBASE_SERVICE_KEY) {\n console.log(chalk.dim(\n \" (not sending REBASE_SERVICE_KEY — this host is not the linked project; pass --token to override)\"\n ));\n }\n\n const remote = await fetchRemoteTables(baseUrl, args.token || ambient, {\n sent: args.token ? \"token\" : ambient ? \"ambient\" : null,\n shellKey: Boolean(process.env.REBASE_SERVICE_KEY),\n envFileKey: Boolean(readEnvFile(findProjectRoot(cwd) ?? cwd).REBASE_SERVICE_KEY)\n });\n tables = remote.tables;\n remoteSchemaVersion = remote.schemaVersion;\n } else {\n // A headless project has no schema directory by design: its API is\n // introspected from the live database at boot, and there is nothing here\n // to generate a client from. The scaffold ships `pnpm generate:sdk`\n // anyway, so the documented headless path had a script that could only\n // ever fail — and it failed with a path, which reads as a broken install\n // rather than a question with an answer.\n if (!fs.existsSync(resolvedSchemaDir)) {\n console.log(chalk.gray(\n \" ○ This project derives its API from the database — \"\n + \"there is no backend/schema to generate a client from.\"\n ));\n console.log(chalk.gray(\n ` Nothing to generate from: ${resolvedSchemaDir} does not exist.`\n ));\n console.log(\"\");\n return;\n }\n console.log(` ${chalk.gray(\"Schema:\")} ${resolvedSchemaDir}`);\n console.log(` ${chalk.gray(\"Output:\")} ${resolvedOutput}`);\n console.log(\"\");\n console.log(chalk.cyan(\" → Loading the tables...\"));\n try {\n tables = await loadTables(projectRoot ?? cwd, resolvedSchemaDir, args.moduleAliases);\n } catch (err) {\n // A definition the backend would refuse to boot on: every problem,\n // one per line, each naming its table.\n if (isSchemaDefinitionError(err)) {\n console.log(\"\");\n console.log(chalk.red(` ✗ ${err.message}`));\n process.exit(1);\n }\n throw err;\n }\n }\n\n // Sorted by slug, so the same schema generates the same SDK.\n tables = sortedBySlug(tables);\n\n if (tables.length === 0) {\n console.log(chalk.red(\" ✗ No tables found. Nothing to generate.\"));\n process.exit(1);\n }\n\n console.log(chalk.green(` ✓ Found ${tables.length} table(s): ${tables.map(table => table.slug).join(\", \")}`));\n console.log(\"\");\n\n // 2. Generate SDK files\n console.log(chalk.cyan(\" → Generating SDK files...\"));\n let files: GeneratedFile[];\n try {\n files = generateSDK(tables, { baseUrl: resolveExampleBaseUrl(cwd) });\n } catch (err) {\n // A schema that cannot be expressed as valid TypeScript — two slugs\n // that collide on one accessor, a slug with no usable name. The\n // generator refuses rather than emitting a file that does not compile,\n // or one that silently routes a table's reads to another's.\n if (err instanceof CodegenError) {\n console.log(\"\");\n console.log(chalk.red(` ✗ ${err.message}`));\n process.exit(1);\n }\n throw err;\n }\n\n // Stamp the schema this SDK was built from.\n //\n // Without it, an app in a separate repository has no way to know its client\n // is stale: the backend moves on, the frontend keeps compiling against types\n // captured weeks ago, and the mismatch only surfaces as a runtime error. With\n // it, CI can compare against `/api/meta/schema-version` and say so.\n //\n // No generation timestamp. Tables are sorted above precisely so that\n // the same schema produces the same bytes; a timestamp put that back,\n // turning every regeneration into a diff and making the obvious staleness\n // gate — `rebase generate-sdk && git diff --exit-code` — impossible to pass.\n // `SCHEMA_VERSION` already identifies what this was built from, and does it\n // in a way that can be compared against a running project.\n const schemaVersion = remoteSchemaVersion ?? computeSchemaVersion(tables);\n files.push({\n path: \"schema.meta.ts\",\n content: `// Auto-generated by \\`rebase generate-sdk\\`. Do not edit.\n//\n// The schema version this SDK was generated from. Compare it against the\n// project's current version to detect drift:\n//\n// curl -s <api-url>/api/meta/schema-version\n//\n// Pass it to the client as \\`schemaVersion\\` and every request carries it in\n// the \\`x-rebase-schema\\` header, so the server can name the drift instead of\n// answering a renamed field with a bare 400.\nexport const SCHEMA_VERSION = ${JSON.stringify(schemaVersion)};\n`\n });\n\n console.log(chalk.green(` ✓ Generated ${files.length} file(s)`));\n console.log(chalk.gray(` schema ${schemaVersion}`));\n\n // 3. Write to disk\n console.log(chalk.cyan(` → Writing to ${resolvedOutput}...`));\n writeFiles(resolvedOutput, files);\n\n // 4. The server-side registration: on request, and kept current once a\n // project has it, so `rebase dev` regenerating the SDK never leaves the\n // server typed against an older schema than the client.\n const registerDir = projectRoot ? registrationDir(projectRoot) : undefined;\n if (args.register || (registerDir && hasRegistration(registerDir)) || manifestRegisters(projectRoot)) {\n if (!registerDir || !fs.existsSync(path.dirname(registerDir))) {\n console.log(chalk.red(` ✗ No backend/ directory to register the Database in${registerDir ? ` (${path.dirname(registerDir)})` : \"\"}.`));\n console.log(chalk.gray(\" --register writes backend/generated/register.ts; run it inside a project with a backend.\"));\n process.exit(1);\n return;\n }\n const databaseTypes = files.find((file) => file.path === \"database.types.ts\")?.content;\n if (databaseTypes !== undefined) {\n try {\n writeRegistration(registerDir, databaseTypes);\n } catch (error) {\n console.log(chalk.red(` ✗ ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n return;\n }\n console.log(chalk.green(` ✓ Registered the Database for server-side code in ${registerDir}`));\n if (args.register) {\n const remembered = rememberRegistration(projectRoot);\n if (\"written\" in remembered) {\n console.log(chalk.gray(` Remembered in ${path.relative(cwd, remembered.written) || \"rebase.json\"} (registerDatabase).`));\n } else {\n console.log(chalk.yellow(` ${remembered.skipped}`));\n }\n }\n }\n }\n\n console.log(\"\");\n console.log(chalk.green.bold(\" ✓ SDK generated successfully!\"));\n console.log(\"\");\n const typesImport = `./${path.relative(cwd, path.join(resolvedOutput, \"database.types\"))}`;\n const metaImport = `./${path.relative(cwd, path.join(resolvedOutput, \"schema.meta\"))}`;\n const exampleSlug = tables[0]?.slug || \"my_table\";\n\n console.log(chalk.gray(\" Usage:\"));\n console.log(chalk.gray(\" import { createRebaseClient } from '@rebasepro/client';\"));\n console.log(chalk.gray(` import { tablesDictionary, type Database } from '${typesImport}';`));\n console.log(chalk.gray(` import { SCHEMA_VERSION } from '${metaImport}';`));\n console.log(\"\");\n console.log(chalk.gray(\" const rebase = createRebaseClient<Database>({\"));\n console.log(chalk.gray(` baseUrl: '${resolveExampleBaseUrl(cwd)}',`));\n // Sent as `x-rebase-schema` on every request. Costs one line here and is\n // the difference between a server that can say \"this client is three\n // deploys behind\" and one that can only reject a field it does not know.\n console.log(chalk.gray(\" schemaVersion: SCHEMA_VERSION,\"));\n // Without the dictionary a hyphenated slug is not resolvable from the\n // property name alone, and the request 404s at runtime.\n console.log(chalk.gray(\" tables: tablesDictionary,\"));\n console.log(chalk.gray(\" // token: 'your-jwt-token',\"));\n console.log(chalk.gray(\" });\"));\n console.log(\"\");\n // `rebase.data.<accessor>` is the typed surface, so it is what gets printed.\n // `rebase.data.table(slug)` exists too, but it is generic over\n // `Record<string, unknown>` and has no link to `Database` — it was the\n // headline example here for a while, which advertised the one call shape\n // that throws away the types this command just generated.\n const exampleAccessor = toTableAccessor(exampleSlug);\n const exampleAccess = isIdentifierLike(exampleAccessor)\n ? `rebase.data.${exampleAccessor}`\n : `rebase.data[${JSON.stringify(exampleAccessor)}]`;\n console.log(chalk.gray(` const { data } = await ${exampleAccess}.find();`));\n console.log(\"\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwDA,IAAa,gBAAgB;;AAG7B,IAAM,kBAAkB;AAExB,IAAM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AAQ,IAAI,EAAE;CACd,QAAQ,IAAI,MAAM,KAAK,mDAAmD,CAAC;CAC3E,QAAQ,IAAI,MAAM,KAAK,qBAAqB,sBAAsB,GAAG,EAAE,GAAG,CAAC;CAI3E,QAAQ,IAAI,MAAM,KAAK,wCAAwC,CAAC;CAGhE,QAAQ,IAAI,MAAM,KAAK,mCAAmC,CAAC;CAC3D,QAAQ,IAAI,MAAM,KAAK,qCAAqC,CAAC;CAC7D,QAAQ,IAAI,MAAM,KAAK,SAAS,CAAC;CACjC,QAAQ,IAAI,EAAE;CAMd,MAAM,kBAAkB,gBAAgB,WAAW;CACnD,MAAM,gBAAgB,iBAAiB,eAAe,IAChD,eAAe,oBACf,eAAe,KAAK,UAAU,eAAe,EAAE;CACrD,QAAQ,IAAI,MAAM,KAAK,8BAA8B,cAAc,SAAS,CAAC;CAC7E,QAAQ,IAAI,EAAE;AAClB"}
|
package/dist/index.es.js
CHANGED
|
@@ -5,7 +5,7 @@ import { i as failAsJson, p as requireProjectRoot, y as wantsJsonOutput } from "
|
|
|
5
5
|
import { C as resolveBackendPaths, D as validateManifest, E as synthesizeManifest, O as writeManifest, S as manifestPath, T as staticAppAddress, _ as findBackendApp, a as DEFAULT_TABLES_DIR, b as loadManifest, c as LEGACY_CONFIG_DIR, d as STORAGE_FILE, f as TABLES_INDEX_FILES, g as compareMountOrder, h as cmsMountOf, i as DEFAULT_SCHEMA_FILE, l as ManifestError, m as buildableApps, n as DEFAULT_CRONS_DIR, o as GENERATED_DIR, p as assessManagedCompatibility, r as DEFAULT_FUNCTIONS_DIR, s as HOOKS_FILE, t as CURRENT_RUNTIME_RANGE, u as RESOURCES_FILE, v as findTablesIndex, w as selectDeployApp, x as manifestExists, y as formatAppAddress } from "./manifest-RjqxfCpb.js";
|
|
6
6
|
import { a as refuseRemovedCollectionsFlag } from "./path-flags-ekLdkbra.js";
|
|
7
7
|
import { n as cliVersion } from "./version-ONIeo7jl.js";
|
|
8
|
-
import { C as normalizeEsmSpecifiers, S as foldStaticIntoBundle, T as vendorDependencies, _ as detectFrameworkDepDrift, a as VENDOR_SIZE_WARN_BYTES, b as findIgnoredConfigStorageAuthorize, c as buildBundle, d as bundledNpmrc, f as collectDeclaredDependencies, g as detectDeclaredDepConflicts, h as describeDepConflicts, i as VENDOR_SIZE_MAX_BYTES, l as buildStaticBundle, m as composeBundleManifest, n as DEFAULT_BUNDLE_DIR, o as VENDOR_TARGET_CPU, p as commentSpans, r as UNVENDORED_COST, s as VENDOR_TARGET_OS, t as BUNDLED_UI_CONFIG, u as bundleUiConfig, v as detectNativeDependencies, w as unvendoredReason, x as findUnusedServerEntry, y as detectStorageAuthorize } from "./bundle-
|
|
8
|
+
import { C as normalizeEsmSpecifiers, S as foldStaticIntoBundle, T as vendorDependencies, _ as detectFrameworkDepDrift, a as VENDOR_SIZE_WARN_BYTES, b as findIgnoredConfigStorageAuthorize, c as buildBundle, d as bundledNpmrc, f as collectDeclaredDependencies, g as detectDeclaredDepConflicts, h as describeDepConflicts, i as VENDOR_SIZE_MAX_BYTES, l as buildStaticBundle, m as composeBundleManifest, n as DEFAULT_BUNDLE_DIR, o as VENDOR_TARGET_CPU, p as commentSpans, r as UNVENDORED_COST, s as VENDOR_TARGET_OS, t as BUNDLED_UI_CONFIG, u as bundleUiConfig, v as detectNativeDependencies, w as unvendoredReason, x as findUnusedServerEntry, y as detectStorageAuthorize } from "./bundle-DhdhtD8K.js";
|
|
9
9
|
import chalk from "chalk";
|
|
10
10
|
import arg from "arg";
|
|
11
11
|
import path from "path";
|
|
@@ -101,7 +101,7 @@ var NO_VOCABULARY = {
|
|
|
101
101
|
async function commandVocabulary(command) {
|
|
102
102
|
switch (command) {
|
|
103
103
|
case "schema": return {
|
|
104
|
-
subcommands: (await import("./schema-
|
|
104
|
+
subcommands: (await import("./schema-D8xFSBbN.js")).SCHEMA_SUBCOMMANDS,
|
|
105
105
|
aliases: {}
|
|
106
106
|
};
|
|
107
107
|
case "db": return {
|
|
@@ -109,43 +109,43 @@ async function commandVocabulary(command) {
|
|
|
109
109
|
aliases: {}
|
|
110
110
|
};
|
|
111
111
|
case "auth": return {
|
|
112
|
-
subcommands: (await import("./auth-
|
|
112
|
+
subcommands: (await import("./auth-DY7kU0z-.js")).AUTH_SUBCOMMANDS,
|
|
113
113
|
aliases: {}
|
|
114
114
|
};
|
|
115
115
|
case "skills": return {
|
|
116
|
-
subcommands: (await import("./skills-
|
|
116
|
+
subcommands: (await import("./skills-C8WdRTFg.js").then((n) => n.u)).SKILLS_SUBCOMMANDS,
|
|
117
117
|
aliases: {}
|
|
118
118
|
};
|
|
119
119
|
case "api-keys": return {
|
|
120
|
-
subcommands: (await import("./api-keys-
|
|
120
|
+
subcommands: (await import("./api-keys-DaWN8dyI.js").then((n) => n.t)).API_KEYS_SUBCOMMANDS,
|
|
121
121
|
aliases: {}
|
|
122
122
|
};
|
|
123
123
|
case "storage": return {
|
|
124
|
-
subcommands: (await import("./storage-
|
|
124
|
+
subcommands: (await import("./storage-DBE8lgH-.js")).STORAGE_SUBCOMMANDS,
|
|
125
125
|
aliases: {}
|
|
126
126
|
};
|
|
127
127
|
case "data": return {
|
|
128
|
-
subcommands: (await import("./data-
|
|
128
|
+
subcommands: (await import("./data-BpkvtCUe.js")).DATA_SUBCOMMANDS,
|
|
129
129
|
aliases: {}
|
|
130
130
|
};
|
|
131
131
|
case "users": return {
|
|
132
|
-
subcommands: (await import("./users-
|
|
132
|
+
subcommands: (await import("./users-DrJEtL9k.js")).USERS_SUBCOMMANDS,
|
|
133
133
|
aliases: {}
|
|
134
134
|
};
|
|
135
135
|
case "cron": return {
|
|
136
|
-
subcommands: (await import("./cron-
|
|
136
|
+
subcommands: (await import("./cron-BGkXIB1N.js")).CRON_SUBCOMMANDS,
|
|
137
137
|
aliases: {}
|
|
138
138
|
};
|
|
139
139
|
case "functions": return {
|
|
140
|
-
subcommands: (await import("./functions-
|
|
140
|
+
subcommands: (await import("./functions-DLuuldt2.js")).FUNCTIONS_SUBCOMMANDS,
|
|
141
141
|
aliases: {}
|
|
142
142
|
};
|
|
143
143
|
case "rls": return {
|
|
144
|
-
subcommands: (await import("./rls-
|
|
144
|
+
subcommands: (await import("./rls-BxWLfEKl.js")).RLS_SUBCOMMANDS,
|
|
145
145
|
aliases: {}
|
|
146
146
|
};
|
|
147
147
|
case "apps": return {
|
|
148
|
-
subcommands: (await import("./apps-
|
|
148
|
+
subcommands: (await import("./apps-D6vtDrkJ.js")).APPS_SUBCOMMANDS,
|
|
149
149
|
aliases: {}
|
|
150
150
|
};
|
|
151
151
|
case "telemetry": return {
|
|
@@ -157,11 +157,11 @@ async function commandVocabulary(command) {
|
|
|
157
157
|
aliases: {}
|
|
158
158
|
};
|
|
159
159
|
case "migrate": return {
|
|
160
|
-
subcommands: (await import("./migrate-
|
|
160
|
+
subcommands: (await import("./migrate-Cw1FkvUK.js")).MIGRATE_SUBCOMMANDS,
|
|
161
161
|
aliases: {}
|
|
162
162
|
};
|
|
163
163
|
case "cloud": {
|
|
164
|
-
const cloud = await import("./cloud-
|
|
164
|
+
const cloud = await import("./cloud-DOR7bxDw.js");
|
|
165
165
|
return {
|
|
166
166
|
subcommands: cloud.CLOUD_GROUP_NAMES,
|
|
167
167
|
aliases: cloud.GROUP_ALIASES
|
|
@@ -289,7 +289,7 @@ async function dispatch(command, effectiveSubcommand, args, parsedArgs, namespac
|
|
|
289
289
|
return;
|
|
290
290
|
}
|
|
291
291
|
case "init": {
|
|
292
|
-
const { createRebaseApp } = await import("./init-
|
|
292
|
+
const { createRebaseApp } = await import("./init-u5Xmr1Ct.js");
|
|
293
293
|
await createRebaseApp(args);
|
|
294
294
|
break;
|
|
295
295
|
}
|
|
@@ -311,7 +311,7 @@ async function dispatch(command, effectiveSubcommand, args, parsedArgs, namespac
|
|
|
311
311
|
maxPositionals: 0
|
|
312
312
|
});
|
|
313
313
|
const sdkRoot = sdkHelp ? process.cwd() : requireProjectRoot();
|
|
314
|
-
const { generateSdkCommand } = await import("./generate_sdk-
|
|
314
|
+
const { generateSdkCommand } = await import("./generate_sdk-UT1lwwRT.js");
|
|
315
315
|
await generateSdkCommand({
|
|
316
316
|
schemaDir: sdkArgs["--schema-dir"] || (sdkHelp ? sdkRoot : (await import("./schema-dir-ChcYfWjP.js").then((n) => n.i)).resolveSchemaDir(sdkRoot)),
|
|
317
317
|
output: sdkArgs["--output"] || path.join(sdkRoot, "generated/sdk"),
|
|
@@ -325,7 +325,7 @@ async function dispatch(command, effectiveSubcommand, args, parsedArgs, namespac
|
|
|
325
325
|
break;
|
|
326
326
|
}
|
|
327
327
|
case "schema": {
|
|
328
|
-
const { schemaCommand } = await import("./schema-
|
|
328
|
+
const { schemaCommand } = await import("./schema-D8xFSBbN.js");
|
|
329
329
|
await schemaCommand(effectiveSubcommand, args);
|
|
330
330
|
break;
|
|
331
331
|
}
|
|
@@ -340,22 +340,22 @@ async function dispatch(command, effectiveSubcommand, args, parsedArgs, namespac
|
|
|
340
340
|
break;
|
|
341
341
|
}
|
|
342
342
|
case "dev": {
|
|
343
|
-
const { devCommand } = await import("./dev-
|
|
343
|
+
const { devCommand } = await import("./dev-C7n36E6f.js");
|
|
344
344
|
await devCommand(args);
|
|
345
345
|
break;
|
|
346
346
|
}
|
|
347
347
|
case "normalize-imports": {
|
|
348
|
-
const { normalizeImportsCommand } = await import("./normalize-imports-
|
|
348
|
+
const { normalizeImportsCommand } = await import("./normalize-imports-E4yA1HfW.js");
|
|
349
349
|
await normalizeImportsCommand(args);
|
|
350
350
|
break;
|
|
351
351
|
}
|
|
352
352
|
case "build": {
|
|
353
|
-
const { buildCommand } = await import("./build-
|
|
353
|
+
const { buildCommand } = await import("./build-D0egCUfU.js").then((n) => n.n);
|
|
354
354
|
await buildCommand(args);
|
|
355
355
|
break;
|
|
356
356
|
}
|
|
357
357
|
case "start": {
|
|
358
|
-
const { startCommand } = await import("./start-
|
|
358
|
+
const { startCommand } = await import("./start-CN_9C205.js");
|
|
359
359
|
await startCommand(args);
|
|
360
360
|
break;
|
|
361
361
|
}
|
|
@@ -365,12 +365,12 @@ async function dispatch(command, effectiveSubcommand, args, parsedArgs, namespac
|
|
|
365
365
|
break;
|
|
366
366
|
}
|
|
367
367
|
case "migrate": {
|
|
368
|
-
const { migrateCommand } = await import("./migrate-
|
|
368
|
+
const { migrateCommand } = await import("./migrate-Cw1FkvUK.js");
|
|
369
369
|
await migrateCommand(effectiveSubcommand, args);
|
|
370
370
|
break;
|
|
371
371
|
}
|
|
372
372
|
case "apps": {
|
|
373
|
-
const { appsCommand } = await import("./apps-
|
|
373
|
+
const { appsCommand } = await import("./apps-D6vtDrkJ.js");
|
|
374
374
|
await appsCommand(effectiveSubcommand, args);
|
|
375
375
|
break;
|
|
376
376
|
}
|
|
@@ -385,22 +385,22 @@ async function dispatch(command, effectiveSubcommand, args, parsedArgs, namespac
|
|
|
385
385
|
break;
|
|
386
386
|
}
|
|
387
387
|
case "auth": {
|
|
388
|
-
const { authCommand } = await import("./auth-
|
|
388
|
+
const { authCommand } = await import("./auth-DY7kU0z-.js");
|
|
389
389
|
await authCommand(effectiveSubcommand, args);
|
|
390
390
|
break;
|
|
391
391
|
}
|
|
392
392
|
case "status": {
|
|
393
|
-
const { statusCommand } = await import("./status-
|
|
393
|
+
const { statusCommand } = await import("./status-HWlZbY1E.js");
|
|
394
394
|
await statusCommand(args);
|
|
395
395
|
break;
|
|
396
396
|
}
|
|
397
397
|
case "resources": {
|
|
398
|
-
const { resourcesCommand } = await import("./resources-
|
|
398
|
+
const { resourcesCommand } = await import("./resources-CE6BeL94.js");
|
|
399
399
|
await resourcesCommand(args);
|
|
400
400
|
break;
|
|
401
401
|
}
|
|
402
402
|
case "doctor": {
|
|
403
|
-
const { doctorCommand } = await import("./doctor-
|
|
403
|
+
const { doctorCommand } = await import("./doctor-D0o54XSQ.js");
|
|
404
404
|
await doctorCommand(args);
|
|
405
405
|
break;
|
|
406
406
|
}
|
|
@@ -410,22 +410,22 @@ async function dispatch(command, effectiveSubcommand, args, parsedArgs, namespac
|
|
|
410
410
|
break;
|
|
411
411
|
}
|
|
412
412
|
case "skills": {
|
|
413
|
-
const { skillsCommand } = await import("./skills-
|
|
413
|
+
const { skillsCommand } = await import("./skills-C8WdRTFg.js").then((n) => n.u);
|
|
414
414
|
await skillsCommand(effectiveSubcommand, args);
|
|
415
415
|
break;
|
|
416
416
|
}
|
|
417
417
|
case "api-keys": {
|
|
418
|
-
const { apiKeysCommand } = await import("./api-keys-
|
|
418
|
+
const { apiKeysCommand } = await import("./api-keys-DaWN8dyI.js").then((n) => n.t);
|
|
419
419
|
await apiKeysCommand(effectiveSubcommand, args);
|
|
420
420
|
break;
|
|
421
421
|
}
|
|
422
422
|
case "storage": {
|
|
423
|
-
const { storageCommand } = await import("./storage-
|
|
423
|
+
const { storageCommand } = await import("./storage-DBE8lgH-.js");
|
|
424
424
|
await storageCommand(effectiveSubcommand, args);
|
|
425
425
|
break;
|
|
426
426
|
}
|
|
427
427
|
case "cloud": {
|
|
428
|
-
const { cloudCommand } = await import("./cloud-
|
|
428
|
+
const { cloudCommand } = await import("./cloud-DOR7bxDw.js");
|
|
429
429
|
await cloudCommand(effectiveSubcommand, args);
|
|
430
430
|
break;
|
|
431
431
|
}
|
|
@@ -435,41 +435,41 @@ async function dispatch(command, effectiveSubcommand, args, parsedArgs, namespac
|
|
|
435
435
|
break;
|
|
436
436
|
}
|
|
437
437
|
case "api": {
|
|
438
|
-
const { apiCommand } = await import("./api-
|
|
438
|
+
const { apiCommand } = await import("./api-zx1wSK5a.js");
|
|
439
439
|
await apiCommand(args);
|
|
440
440
|
break;
|
|
441
441
|
}
|
|
442
442
|
case "data": {
|
|
443
|
-
const { dataCommand } = await import("./data-
|
|
443
|
+
const { dataCommand } = await import("./data-BpkvtCUe.js");
|
|
444
444
|
await dataCommand(effectiveSubcommand, args);
|
|
445
445
|
break;
|
|
446
446
|
}
|
|
447
447
|
case "users": {
|
|
448
|
-
const { usersCommand } = await import("./users-
|
|
448
|
+
const { usersCommand } = await import("./users-DrJEtL9k.js");
|
|
449
449
|
await usersCommand(effectiveSubcommand, args);
|
|
450
450
|
break;
|
|
451
451
|
}
|
|
452
452
|
case "cron": {
|
|
453
|
-
const { cronCommand } = await import("./cron-
|
|
453
|
+
const { cronCommand } = await import("./cron-BGkXIB1N.js");
|
|
454
454
|
await cronCommand(effectiveSubcommand, args);
|
|
455
455
|
break;
|
|
456
456
|
}
|
|
457
457
|
case "logs": {
|
|
458
|
-
const { logsCommand } = await import("./logs-
|
|
458
|
+
const { logsCommand } = await import("./logs-DBYRSs6W.js");
|
|
459
459
|
await logsCommand(args);
|
|
460
460
|
break;
|
|
461
461
|
}
|
|
462
462
|
case "functions": {
|
|
463
|
-
const { functionsCommand } = await import("./functions-
|
|
463
|
+
const { functionsCommand } = await import("./functions-DLuuldt2.js");
|
|
464
464
|
await functionsCommand(effectiveSubcommand, args);
|
|
465
465
|
break;
|
|
466
466
|
}
|
|
467
467
|
case "rls": {
|
|
468
|
-
const { rlsCommand } = await import("./rls-
|
|
468
|
+
const { rlsCommand } = await import("./rls-BxWLfEKl.js");
|
|
469
469
|
await rlsCommand(effectiveSubcommand, args);
|
|
470
470
|
break;
|
|
471
471
|
}
|
|
472
|
-
default: unknownCommand(command, namespacedCommands, "", { cloud: (await import("./cloud-
|
|
472
|
+
default: unknownCommand(command, namespacedCommands, "", { cloud: (await import("./cloud-DOR7bxDw.js")).CLOUD_GROUP_NAMES });
|
|
473
473
|
}
|
|
474
474
|
}
|
|
475
475
|
/** The global help. Exported so its Options block can be held against {@link ROOT_FLAGS}. */
|
|
@@ -2,9 +2,9 @@ import { i as recordEvent, l as durationBucket } from "./telemetry-EVtASbKb.js";
|
|
|
2
2
|
import { n as getPMCommands, t as detectPackageManager } from "./package-manager-DSEOwTqM.js";
|
|
3
3
|
import { a as wantsHelp, n as parseCommandArgs } from "./args-DHyrshtI.js";
|
|
4
4
|
import { n as cliVersion } from "./version-ONIeo7jl.js";
|
|
5
|
-
import { c as reportRootPointers, d as writeRootPointers, l as resolveAgentNames, n as AGENT_KEYS, t as AGENTS } from "./skills-
|
|
6
|
-
import { configureAgents, printAgentSetup, promptForAgents, retargetScaffoldMcpConfig } from "./agent-setup-
|
|
7
|
-
import { et as resolveCloudUrl, lt as writeLink } from "./context-
|
|
5
|
+
import { c as reportRootPointers, d as writeRootPointers, l as resolveAgentNames, n as AGENT_KEYS, t as AGENTS } from "./skills-C8WdRTFg.js";
|
|
6
|
+
import { configureAgents, printAgentSetup, promptForAgents, retargetScaffoldMcpConfig } from "./agent-setup-CGeAuP0Q.js";
|
|
7
|
+
import { et as resolveCloudUrl, lt as writeLink } from "./context-xt20FMFA.js";
|
|
8
8
|
import { t as Refusal } from "./refusal-ReeeGP8a.js";
|
|
9
9
|
import { r as dockerClaimedPorts } from "./dev-preflight-BMOf2N6r.js";
|
|
10
10
|
import { t as invokedRebaseCommand } from "./invoked-command-FBeIBS8o.js";
|
|
@@ -1382,4 +1382,4 @@ async function configureEnvFile(targetDirectory, databaseUrl) {
|
|
|
1382
1382
|
//#endregion
|
|
1383
1383
|
export { createRebaseApp };
|
|
1384
1384
|
|
|
1385
|
-
//# sourceMappingURL=init-
|
|
1385
|
+
//# sourceMappingURL=init-u5Xmr1Ct.js.map
|