@rebasepro/cli 0.33.1 → 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.
Files changed (95) hide show
  1. package/dist/{agent-setup-Cg_zBWoW.js → agent-setup-CGeAuP0Q.js} +2 -2
  2. package/dist/{agent-setup-Cg_zBWoW.js.map → agent-setup-CGeAuP0Q.js.map} +1 -1
  3. package/dist/{api-keys-fPQ55DCm.js → api-keys-DaWN8dyI.js} +3 -3
  4. package/dist/{api-keys-fPQ55DCm.js.map → api-keys-DaWN8dyI.js.map} +1 -1
  5. package/dist/{api-TbmW33D7.js → api-zx1wSK5a.js} +2 -2
  6. package/dist/{api-TbmW33D7.js.map → api-zx1wSK5a.js.map} +1 -1
  7. package/dist/{apps-DBTRoOeP.js → apps-D6vtDrkJ.js} +3 -3
  8. package/dist/{apps-DBTRoOeP.js.map → apps-D6vtDrkJ.js.map} +1 -1
  9. package/dist/{auth-BpyYLEFY.js → auth-DY7kU0z-.js} +8 -8
  10. package/dist/{auth-BpyYLEFY.js.map → auth-DY7kU0z-.js.map} +1 -1
  11. package/dist/{auth-session-B6aT0Dyj.js → auth-session-DCG96UGH.js} +4 -4
  12. package/dist/{auth-session-B6aT0Dyj.js.map → auth-session-DCG96UGH.js.map} +1 -1
  13. package/dist/{build-E5hfEWKj.js → build-D0egCUfU.js} +4 -4
  14. package/dist/{build-E5hfEWKj.js.map → build-D0egCUfU.js.map} +1 -1
  15. package/dist/{bundle-CIiKGrte.js → bundle-DhdhtD8K.js} +3 -3
  16. package/dist/{bundle-CIiKGrte.js.map → bundle-DhdhtD8K.js.map} +1 -1
  17. package/dist/{cloud-DNJyUU0T.js → cloud-DOR7bxDw.js} +218 -27
  18. package/dist/cloud-DOR7bxDw.js.map +1 -0
  19. package/dist/{command-Bks5xkrQ.js → command-BzSP5gBh.js} +2 -2
  20. package/dist/{command-Bks5xkrQ.js.map → command-BzSP5gBh.js.map} +1 -1
  21. package/dist/commands/cloud/db-connect.d.ts +31 -1
  22. package/dist/commands/cloud/db-query.d.ts +16 -0
  23. package/dist/commands/cloud/index.d.ts +1 -0
  24. package/dist/commands/cloud/resources.d.ts +19 -1
  25. package/dist/commands/dev.d.ts +15 -0
  26. package/dist/commands/users.d.ts +1 -0
  27. package/dist/{context-BOMEoKxn.js → context-xt20FMFA.js} +5 -1
  28. package/dist/{context-BOMEoKxn.js.map → context-xt20FMFA.js.map} +1 -1
  29. package/dist/{cron-CpUsQ739.js → cron-BGkXIB1N.js} +4 -4
  30. package/dist/{cron-CpUsQ739.js.map → cron-BGkXIB1N.js.map} +1 -1
  31. package/dist/{cron-ZRXsla0v.js → cron-CJ6Xk42E.js} +3 -3
  32. package/dist/{cron-ZRXsla0v.js.map → cron-CJ6Xk42E.js.map} +1 -1
  33. package/dist/{data-BJ9AZFUC.js → data-BpkvtCUe.js} +3 -3
  34. package/dist/{data-BJ9AZFUC.js.map → data-BpkvtCUe.js.map} +1 -1
  35. package/dist/{debug-nNbbxAeo.js → debug-C7Ss34XB.js} +2 -2
  36. package/dist/{debug-nNbbxAeo.js.map → debug-C7Ss34XB.js.map} +1 -1
  37. package/dist/{derive-Mky_u59_.js → derive-ChP6vgfi.js} +2 -2
  38. package/dist/{derive-Mky_u59_.js.map → derive-ChP6vgfi.js.map} +1 -1
  39. package/dist/{dev-bj6dEeSQ.js → dev-C7n36E6f.js} +23 -2
  40. package/dist/dev-C7n36E6f.js.map +1 -0
  41. package/dist/{doctor-FaBObSlb.js → doctor-D0o54XSQ.js} +2 -2
  42. package/dist/{doctor-FaBObSlb.js.map → doctor-D0o54XSQ.js.map} +1 -1
  43. package/dist/{fold-static-2t3UUX4z.js → fold-static-DTpaqbB0.js} +2 -2
  44. package/dist/{fold-static-2t3UUX4z.js.map → fold-static-DTpaqbB0.js.map} +1 -1
  45. package/dist/{function-portability-BIvlvR9q.js → function-portability-Dppl6uqg.js} +24 -5
  46. package/dist/{function-portability-BIvlvR9q.js.map → function-portability-Dppl6uqg.js.map} +1 -1
  47. package/dist/function-portability.d.ts +9 -0
  48. package/dist/{functions-B4JR6EZL.js → functions-DLuuldt2.js} +4 -4
  49. package/dist/{functions-B4JR6EZL.js.map → functions-DLuuldt2.js.map} +1 -1
  50. package/dist/{generate_sdk-ByD-gTsK.js → generate_sdk-UT1lwwRT.js} +2 -2
  51. package/dist/{generate_sdk-ByD-gTsK.js.map → generate_sdk-UT1lwwRT.js.map} +1 -1
  52. package/dist/index.es.js +39 -39
  53. package/dist/{init-DHCe5mJ5.js → init-u5Xmr1Ct.js} +4 -4
  54. package/dist/{init-DHCe5mJ5.js.map → init-u5Xmr1Ct.js.map} +1 -1
  55. package/dist/{logs-DpuMukJe.js → logs-DBYRSs6W.js} +4 -4
  56. package/dist/{logs-DpuMukJe.js.map → logs-DBYRSs6W.js.map} +1 -1
  57. package/dist/{migrate-CSY9ZDKy.js → migrate-Cw1FkvUK.js} +3 -3
  58. package/dist/{migrate-CSY9ZDKy.js.map → migrate-Cw1FkvUK.js.map} +1 -1
  59. package/dist/{normalize-imports-P86NVfpo.js → normalize-imports-E4yA1HfW.js} +2 -2
  60. package/dist/{normalize-imports-P86NVfpo.js.map → normalize-imports-E4yA1HfW.js.map} +1 -1
  61. package/dist/{project-command-Cl9EZzjr.js → project-command-7EGMemEy.js} +5 -5
  62. package/dist/{project-command-Cl9EZzjr.js.map → project-command-7EGMemEy.js.map} +1 -1
  63. package/dist/{resources-Db3USuPO.js → resources-CE6BeL94.js} +2 -2
  64. package/dist/{resources-Db3USuPO.js.map → resources-CE6BeL94.js.map} +1 -1
  65. package/dist/{rls-BxrQ0P50.js → rls-BxWLfEKl.js} +3 -3
  66. package/dist/{rls-BxrQ0P50.js.map → rls-BxWLfEKl.js.map} +1 -1
  67. package/dist/{schema-_FzZEoB8.js → schema-D8xFSBbN.js} +7 -6
  68. package/dist/{schema-_FzZEoB8.js.map → schema-D8xFSBbN.js.map} +1 -1
  69. package/dist/schema-reconcile-D_wvZY91.js +2 -0
  70. package/dist/{schema-show-h72UJ9zH.js → schema-show-C7bY7SgE.js} +3 -3
  71. package/dist/{schema-show-h72UJ9zH.js.map → schema-show-C7bY7SgE.js.map} +1 -1
  72. package/dist/{skills-DQ2bZGkj.js → skills-C8WdRTFg.js} +4 -4
  73. package/dist/{skills-DQ2bZGkj.js.map → skills-C8WdRTFg.js.map} +1 -1
  74. package/dist/{start-Cjx4W0bJ.js → start-CN_9C205.js} +2 -2
  75. package/dist/{start-Cjx4W0bJ.js.map → start-CN_9C205.js.map} +1 -1
  76. package/dist/{status-CDBk25VO.js → status-HWlZbY1E.js} +2 -2
  77. package/dist/{status-CDBk25VO.js.map → status-HWlZbY1E.js.map} +1 -1
  78. package/dist/{storage-Clc8dLG8.js → storage-DBE8lgH-.js} +9 -9
  79. package/dist/{storage-Clc8dLG8.js.map → storage-DBE8lgH-.js.map} +1 -1
  80. package/dist/{storage-objects-CfRKlTDe.js → storage-objects-ljDmtuH7.js} +3 -3
  81. package/dist/{storage-objects-CfRKlTDe.js.map → storage-objects-ljDmtuH7.js.map} +1 -1
  82. package/dist/{users-5PkqBY6R.js → users-DrJEtL9k.js} +9 -6
  83. package/dist/users-DrJEtL9k.js.map +1 -0
  84. package/package.json +10 -10
  85. package/templates/template/.cursorrules +2 -1
  86. package/templates/template/.github/copilot-instructions.md +2 -1
  87. package/templates/template/.windsurfrules +2 -1
  88. package/templates/template/AGENTS.md +2 -1
  89. package/templates/template/CLAUDE.md +2 -1
  90. package/templates/template/ai-instructions.md +5 -2
  91. package/templates/template/frontend/src/index.css +13 -0
  92. package/dist/cloud-DNJyUU0T.js.map +0 -1
  93. package/dist/dev-bj6dEeSQ.js.map +0 -1
  94. package/dist/schema-reconcile-DV14XY4o.js +0 -2
  95. package/dist/users-5PkqBY6R.js.map +0 -1
@@ -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, r as parsedLine } from "./project-command-Cl9EZzjr.js";
4
- import { M as note, l as confirmDestructive, m as emit, st as success } from "./context-BOMEoKxn.js";
5
- import { shortDuration, shortTime } from "./cron-ZRXsla0v.js";
3
+ import { a as projectTarget, c as requestJson, d as PROJECT_TARGET_FLAGS, i as printProjectHelp, l as startProjectCommand, n as isRecord, r as parsedLine } from "./project-command-7EGMemEy.js";
4
+ import { M as note, l as confirmDestructive, m as emit, st as success } from "./context-xt20FMFA.js";
5
+ import { shortDuration, shortTime } from "./cron-CJ6Xk42E.js";
6
6
  import chalk from "chalk";
7
7
  //#region src/commands/cron.ts
8
8
  /** Everything the switch below dispatches, for the did-you-mean. */
@@ -295,4 +295,4 @@ function printCronHelp() {
295
295
  //#endregion
296
296
  export { CRON_SUBCOMMANDS, cronCommand };
297
297
 
298
- //# sourceMappingURL=cron-CpUsQ739.js.map
298
+ //# sourceMappingURL=cron-BGkXIB1N.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cron-CpUsQ739.js","names":[],"sources":["../src/commands/cron.ts"],"sourcesContent":["/**\n * CLI command: rebase cron <action>\n *\n * A running app's scheduled jobs (`backend/crons/*`): list them, read a job's\n * run history, run one now, switch one off or back on. Through the app's\n * `/api/admin/cron` surface, with the target every project command resolves.\n *\n * On a Rebase Cloud project (`--project`, `--cloud`) this needs no Studio\n * access: reads ask the control plane for a short `cron:read` platform token,\n * which any member who may read the project's logs holds, and runs or\n * switches ask for `cron:write`, which an organization owner or admin holds on\n * a project whose Studio switch is on. Nothing long-lived is kept.\n * `rebase cloud cron` is the older, read-only spelling of `list` and `logs`.\n */\nimport type arg from \"arg\";\nimport chalk from \"chalk\";\nimport type { CronJobLogEntry, CronJobStatus } from \"@rebasepro/types\";\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 requestJson,\n startProjectCommand,\n type HelpAction\n} from \"../utils/project-command\";\nimport { confirmDestructive, note, success } from \"./cloud/context\";\nimport { shortDuration, shortTime } from \"./cloud/cron\";\n\n/** Everything the switch below dispatches, for the did-you-mean. */\nexport const CRON_SUBCOMMANDS = [\"list\", \"get\", \"logs\", \"run\", \"enable\", \"disable\", \"reset\"] as const;\n\nconst CRON_PATH = \"/api/admin/cron\";\n\nexport async function cronCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void> {\n startProjectCommand(rawArgs);\n if (subcommand === \"--help\" || wantsHelp(rawArgs)) {\n printCronHelp();\n return;\n }\n switch (subcommand ?? \"list\") {\n case \"list\":\n await listJobs(rawArgs);\n break;\n case \"get\":\n await getJob(rawArgs);\n break;\n case \"logs\":\n await jobLogs(rawArgs);\n break;\n case \"run\":\n await runJob(rawArgs);\n break;\n case \"enable\":\n await switchJob(rawArgs, \"enable\");\n break;\n case \"disable\":\n await switchJob(rawArgs, \"disable\");\n break;\n case \"reset\":\n await switchJob(rawArgs, \"reset\");\n break;\n default:\n unknownCommand(subcommand, CRON_SUBCOMMANDS, \"cron\");\n }\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Reading a job\n ═══════════════════════════════════════════════════════════════ */\n\nfunction isJob(value: unknown): value is CronJobStatus {\n return isRecord(value) && typeof value.id === \"string\" && typeof value.schedule === \"string\";\n}\n\nfunction jobsOf(body: unknown): CronJobStatus[] {\n return isRecord(body) && Array.isArray(body.jobs) ? body.jobs.filter(isJob) : [];\n}\n\nfunction jobOf(body: unknown): CronJobStatus | undefined {\n if (isRecord(body) && isJob(body.job)) return body.job;\n return isJob(body) ? body : undefined;\n}\n\nfunction isLogEntry(value: unknown): value is CronJobLogEntry {\n return isRecord(value) && typeof value.startedAt === \"string\";\n}\n\nfunction stateColor(state: string): string {\n if (state === \"error\") return chalk.red(state);\n if (state === \"running\") return chalk.cyan(state);\n if (state === \"disabled\") return chalk.gray(state);\n return chalk.green(state);\n}\n\nfunction printJob(job: CronJobStatus): void {\n console.log(` ${chalk.bold(job.id)} ${job.schedule} ${stateColor(job.state)}${job.enabled ? \"\" : chalk.gray(\" (off)\")}`);\n if (job.description) console.log(chalk.gray(` ${job.description}`));\n const last = job.lastRunAt ? `${shortTime(job.lastRunAt)} ${chalk.gray(shortDuration(job.lastDurationMs))}` : chalk.gray(\"never\");\n console.log(chalk.gray(\" last \") + last + chalk.gray(\" next \") + shortTime(job.nextRunAt));\n if (job.state === \"error\" && job.lastError) console.log(chalk.red(` ${job.lastError}`));\n}\n\nfunction requireJobId(positionals: string[], command: string): string {\n if (!positionals[0]) throw new UsageError(`rebase ${command} needs a job id: rebase ${command} <job> (\\`rebase cron list\\` names them).`);\n return positionals[0];\n}\n\n/* ═══════════════════════════════════════════════════════════════\n list / get / logs\n ═══════════════════════════════════════════════════════════════ */\n\nexport const CRON_LIST_FLAGS = { ...PROJECT_TARGET_FLAGS } satisfies arg.Spec;\n\nasync function listJobs(rawArgs: string[]): Promise<void> {\n const { flags } = parsedLine(() => parseCommandArgs({\n spec: CRON_LIST_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"cron list\",\n maxPositionals: 0\n }));\n const target = await projectTarget(flags, { command: \"cron list\", platformScopes: [\"cron:read\"] });\n const body = await requestJson(target, CRON_PATH, \"Failed to list cron jobs\");\n const jobs = jobsOf(body);\n emit(() => {\n if (jobs.length === 0) note(`No cron jobs are scheduled on ${target.label}.`);\n for (const job of jobs) printJob(job);\n if (isRecord(body) && typeof body.note === \"string\") note(chalk.yellow(body.note));\n }, body);\n}\n\nexport const CRON_GET_FLAGS = { ...PROJECT_TARGET_FLAGS } satisfies arg.Spec;\n\nasync function getJob(rawArgs: string[]): Promise<void> {\n const { flags, positionals } = parsedLine(() => parseCommandArgs({\n spec: CRON_GET_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"cron get\",\n maxPositionals: 1\n }));\n const id = parsedLine(() => requireJobId(positionals, \"cron get\"));\n const target = await projectTarget(flags, { command: \"cron get\", platformScopes: [\"cron:read\"] });\n const body = await requestJson(target, `${CRON_PATH}/${encodeURIComponent(id)}`, `Failed to read cron job ${id}`);\n const job = jobOf(body);\n emit(() => (job ? printJob(job) : console.log(JSON.stringify(body, null, 2))), job ?? body);\n}\n\nexport const CRON_LOGS_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--limit\": Number,\n \"-n\": \"--limit\"\n} satisfies arg.Spec;\n\nasync function jobLogs(rawArgs: string[]): Promise<void> {\n const { flags, positionals } = parsedLine(() => parseCommandArgs({\n spec: CRON_LOGS_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"cron logs\",\n maxPositionals: 1\n }));\n const id = parsedLine(() => {\n const job = requireJobId(positionals, \"cron logs\");\n const limit = flags[\"--limit\"];\n if (limit !== undefined && (!Number.isInteger(limit) || limit < 1)) throw new UsageError(\"--limit takes a positive whole number.\");\n return job;\n });\n const target = await projectTarget(flags, { command: \"cron logs\", platformScopes: [\"cron:read\"] });\n const body = await requestJson(target, `${CRON_PATH}/${encodeURIComponent(id)}/logs`, `Failed to read the runs of ${id}`, {\n query: { limit: flags[\"--limit\"]?.toString() }\n });\n const logs = isRecord(body) && Array.isArray(body.logs) ? body.logs.filter(isLogEntry) : [];\n emit(() => {\n if (logs.length === 0) return note(`${id} has no recorded runs.`);\n for (const run of logs) {\n const mark = run.success ? chalk.green(\"✓\") : chalk.red(\"✗\");\n const tags = [shortDuration(run.durationMs), run.manual ? \"manual\" : undefined].filter(Boolean).join(\" \");\n console.log(` ${mark} ${shortTime(run.startedAt)} ${chalk.gray(tags)}`);\n if (run.error) console.log(chalk.red(` ${run.error}`));\n for (const line of run.logs ?? []) console.log(` ${line}`);\n }\n }, body);\n}\n\n/* ═══════════════════════════════════════════════════════════════\n run / enable / disable / reset\n ═══════════════════════════════════════════════════════════════ */\n\nexport const CRON_RUN_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--async\": Boolean\n} satisfies arg.Spec;\n\nasync function runJob(rawArgs: string[]): Promise<void> {\n const { flags, positionals } = parsedLine(() => parseCommandArgs({\n spec: CRON_RUN_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"cron run\",\n maxPositionals: 1\n }));\n const id = parsedLine(() => requireJobId(positionals, \"cron run\"));\n const target = await projectTarget(flags, { command: \"cron run\", platformScopes: [\"cron:write\"] });\n // A run is not undoable — it sends the emails, charges the cards, prunes\n // the rows its code says to — so it says what it is about to do and waits.\n await confirmDestructive({ yes: flags[\"--yes\"] === true, prompt: `Run cron job ${id} now on ${target.label}?` });\n const body = await requestJson(target, `${CRON_PATH}/${encodeURIComponent(id)}/trigger`, `Failed to run ${id}`, {\n method: \"POST\",\n query: flags[\"--async\"] ? { async: \"1\" } : undefined,\n // A synchronous run lasts as long as the job does.\n timeoutMs: flags[\"--async\"] ? 60_000 : 15 * 60_000\n });\n const log = isRecord(body) && isLogEntry(body.log) ? body.log : undefined;\n emit(() => {\n if (flags[\"--async\"]) return success(`Started ${id}; \\`rebase cron logs ${id}\\` shows how it ends.`);\n if (log && !log.success) {\n console.log(chalk.red(` ✗ ${id} failed after ${shortDuration(log.durationMs)}: ${log.error ?? \"no message\"}`));\n for (const line of log.logs ?? []) console.log(` ${line}`);\n process.exitCode = 1;\n return;\n }\n success(`Ran ${id}${log ? ` in ${shortDuration(log.durationMs)}` : \"\"}.`);\n for (const line of log?.logs ?? []) console.log(` ${line}`);\n }, body);\n if (log && !log.success) process.exitCode = 1;\n}\n\nexport const CRON_SWITCH_FLAGS = { ...PROJECT_TARGET_FLAGS } satisfies arg.Spec;\n\n/**\n * `enable` and `disable` override the job's code for every process, across\n * redeploys; `reset` drops the override, so the code decides again.\n */\nasync function switchJob(rawArgs: string[], how: \"enable\" | \"disable\" | \"reset\"): Promise<void> {\n const command = `cron ${how}`;\n // One literal call per action: the help and parse guards read the command\n // name out of each call.\n const parse = {\n enable: () => parseCommandArgs({ spec: CRON_SWITCH_FLAGS, rawArgs, commandWords: 2, command: \"cron enable\", maxPositionals: 1 }),\n disable: () => parseCommandArgs({ spec: CRON_SWITCH_FLAGS, rawArgs, commandWords: 2, command: \"cron disable\", maxPositionals: 1 }),\n reset: () => parseCommandArgs({ spec: CRON_SWITCH_FLAGS, rawArgs, commandWords: 2, command: \"cron reset\", maxPositionals: 1 })\n }[how];\n const { flags, positionals } = parsedLine(parse);\n const id = parsedLine(() => requireJobId(positionals, command));\n const target = await projectTarget(flags, { command, platformScopes: [\"cron:write\"] });\n if (how === \"disable\") {\n // Silently stopping a scheduled backup is the failure this prompt is for.\n await confirmDestructive({ yes: flags[\"--yes\"] === true, prompt: `Switch off cron job ${id} on ${target.label}, until it is enabled again?` });\n }\n const enabled = how === \"enable\" ? true : how === \"disable\" ? false : null;\n const body = await requestJson(target, `${CRON_PATH}/${encodeURIComponent(id)}`, `Failed to ${how} ${id}`, {\n method: \"PUT\",\n json: { enabled }\n });\n const job = jobOf(body);\n emit(() => {\n success(how === \"reset\" ? `${id} follows its code again.` : `${id} is ${how === \"enable\" ? \"on\" : \"off\"}.`);\n if (job) printJob(job);\n }, body);\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Help\n ═══════════════════════════════════════════════════════════════ */\n\nexport const CRON_ACTIONS: HelpAction[] = [\n { action: \"list\", description: \"The scheduled jobs: schedule, state, last and next run (the default)\" },\n { action: \"get\", args: \"<job>\", description: \"One job\" },\n { action: \"logs\", args: \"<job>\", description: \"A job's run history, newest first\", flags: [[\"--limit, -n <n>\", \"At most this many runs\"]] },\n { action: \"run\", args: \"<job>\", description: \"Run a job now (confirms)\", flags: [[\"--async\", \"Answer once it has started; `logs` shows how it ends\"]] },\n { action: \"enable\", args: \"<job>\", description: \"Switch a job on for every process, across redeploys\" },\n { action: \"disable\", args: \"<job>\", description: \"Switch a job off (confirms)\" },\n { action: \"reset\", args: \"<job>\", description: \"Drop the on/off override: the job's code decides again\" }\n];\n\nfunction printCronHelp(): void {\n printProjectHelp({\n command: \"cron\",\n title: \"A running app's scheduled jobs: list, history, run now, switch off\",\n actions: CRON_ACTIONS,\n notes: [\n \"On a Rebase Cloud project, reads need log access and run/enable/disable/reset need an organization owner or admin with Studio switched on.\",\n \"Examples:\",\n \" rebase cron run cleanup-sessions --yes\",\n \" rebase cron logs nightly-backup -n 5 --project acme\"\n ]\n });\n}\n"],"mappings":";;;;;;;;AAmCA,IAAa,mBAAmB;CAAC;CAAQ;CAAO;CAAQ;CAAO;CAAU;CAAW;AAAO;AAE3F,IAAM,YAAY;AAElB,eAAsB,YAAY,YAAgC,SAAkC;CAChG,oBAAoB,OAAO;CAC3B,IAAI,eAAe,YAAY,UAAU,OAAO,GAAG;EAC/C,cAAc;EACd;CACJ;CACA,QAAQ,cAAc,QAAtB;EACI,KAAK;GACD,MAAM,SAAS,OAAO;GACtB;EACJ,KAAK;GACD,MAAM,OAAO,OAAO;GACpB;EACJ,KAAK;GACD,MAAM,QAAQ,OAAO;GACrB;EACJ,KAAK;GACD,MAAM,OAAO,OAAO;GACpB;EACJ,KAAK;GACD,MAAM,UAAU,SAAS,QAAQ;GACjC;EACJ,KAAK;GACD,MAAM,UAAU,SAAS,SAAS;GAClC;EACJ,KAAK;GACD,MAAM,UAAU,SAAS,OAAO;GAChC;EACJ,SACI,eAAe,YAAY,kBAAkB,MAAM;CAC3D;AACJ;AAMA,SAAS,MAAM,OAAwC;CACnD,OAAO,SAAS,KAAK,KAAK,OAAO,MAAM,OAAO,YAAY,OAAO,MAAM,aAAa;AACxF;AAEA,SAAS,OAAO,MAAgC;CAC5C,OAAO,SAAS,IAAI,KAAK,MAAM,QAAQ,KAAK,IAAI,IAAI,KAAK,KAAK,OAAO,KAAK,IAAI,CAAC;AACnF;AAEA,SAAS,MAAM,MAA0C;CACrD,IAAI,SAAS,IAAI,KAAK,MAAM,KAAK,GAAG,GAAG,OAAO,KAAK;CACnD,OAAO,MAAM,IAAI,IAAI,OA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EAAU,MAAM;EAAS,aAAa;CAAsD;CACtG;EAAE,QAAQ;EAAW,MAAM;EAAS,aAAa;CAA8B;CAC/E;EAAE,QAAQ;EAAS,MAAM;EAAS,aAAa;CAAyD;AAC5G;AAEA,SAAS,gBAAsB;CAC3B,iBAAiB;EACb,SAAS;EACT,OAAO;EACP,SAAS;EACT,OAAO;GACH;GACA;GACA;GACA;EACJ;CACJ,CAAC;AACL"}
1
+ {"version":3,"file":"cron-BGkXIB1N.js","names":[],"sources":["../src/commands/cron.ts"],"sourcesContent":["/**\n * CLI command: rebase cron <action>\n *\n * A running app's scheduled jobs (`backend/crons/*`): list them, read a job's\n * run history, run one now, switch one off or back on. Through the app's\n * `/api/admin/cron` surface, with the target every project command resolves.\n *\n * On a Rebase Cloud project (`--project`, `--cloud`) this needs no Studio\n * access: reads ask the control plane for a short `cron:read` platform token,\n * which any member who may read the project's logs holds, and runs or\n * switches ask for `cron:write`, which an organization owner or admin holds on\n * a project whose Studio switch is on. Nothing long-lived is kept.\n * `rebase cloud cron` is the older, read-only spelling of `list` and `logs`.\n */\nimport type arg from \"arg\";\nimport chalk from \"chalk\";\nimport type { CronJobLogEntry, CronJobStatus } from \"@rebasepro/types\";\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 requestJson,\n startProjectCommand,\n type HelpAction\n} from \"../utils/project-command\";\nimport { confirmDestructive, note, success } from \"./cloud/context\";\nimport { shortDuration, shortTime } from \"./cloud/cron\";\n\n/** Everything the switch below dispatches, for the did-you-mean. */\nexport const CRON_SUBCOMMANDS = [\"list\", \"get\", \"logs\", \"run\", \"enable\", \"disable\", \"reset\"] as const;\n\nconst CRON_PATH = \"/api/admin/cron\";\n\nexport async function cronCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void> {\n startProjectCommand(rawArgs);\n if (subcommand === \"--help\" || wantsHelp(rawArgs)) {\n printCronHelp();\n return;\n }\n switch (subcommand ?? \"list\") {\n case \"list\":\n await listJobs(rawArgs);\n break;\n case \"get\":\n await getJob(rawArgs);\n break;\n case \"logs\":\n await jobLogs(rawArgs);\n break;\n case \"run\":\n await runJob(rawArgs);\n break;\n case \"enable\":\n await switchJob(rawArgs, \"enable\");\n break;\n case \"disable\":\n await switchJob(rawArgs, \"disable\");\n break;\n case \"reset\":\n await switchJob(rawArgs, \"reset\");\n break;\n default:\n unknownCommand(subcommand, CRON_SUBCOMMANDS, \"cron\");\n }\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Reading a job\n ═══════════════════════════════════════════════════════════════ */\n\nfunction isJob(value: unknown): value is CronJobStatus {\n return isRecord(value) && typeof value.id === \"string\" && typeof value.schedule === \"string\";\n}\n\nfunction jobsOf(body: unknown): CronJobStatus[] {\n return isRecord(body) && Array.isArray(body.jobs) ? body.jobs.filter(isJob) : [];\n}\n\nfunction jobOf(body: unknown): CronJobStatus | undefined {\n if (isRecord(body) && isJob(body.job)) return body.job;\n return isJob(body) ? body : undefined;\n}\n\nfunction isLogEntry(value: unknown): value is CronJobLogEntry {\n return isRecord(value) && typeof value.startedAt === \"string\";\n}\n\nfunction stateColor(state: string): string {\n if (state === \"error\") return chalk.red(state);\n if (state === \"running\") return chalk.cyan(state);\n if (state === \"disabled\") return chalk.gray(state);\n return chalk.green(state);\n}\n\nfunction printJob(job: CronJobStatus): void {\n console.log(` ${chalk.bold(job.id)} ${job.schedule} ${stateColor(job.state)}${job.enabled ? \"\" : chalk.gray(\" (off)\")}`);\n if (job.description) console.log(chalk.gray(` ${job.description}`));\n const last = job.lastRunAt ? `${shortTime(job.lastRunAt)} ${chalk.gray(shortDuration(job.lastDurationMs))}` : chalk.gray(\"never\");\n console.log(chalk.gray(\" last \") + last + chalk.gray(\" next \") + shortTime(job.nextRunAt));\n if (job.state === \"error\" && job.lastError) console.log(chalk.red(` ${job.lastError}`));\n}\n\nfunction requireJobId(positionals: string[], command: string): string {\n if (!positionals[0]) throw new UsageError(`rebase ${command} needs a job id: rebase ${command} <job> (\\`rebase cron list\\` names them).`);\n return positionals[0];\n}\n\n/* ═══════════════════════════════════════════════════════════════\n list / get / logs\n ═══════════════════════════════════════════════════════════════ */\n\nexport const CRON_LIST_FLAGS = { ...PROJECT_TARGET_FLAGS } satisfies arg.Spec;\n\nasync function listJobs(rawArgs: string[]): Promise<void> {\n const { flags } = parsedLine(() => parseCommandArgs({\n spec: CRON_LIST_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"cron list\",\n maxPositionals: 0\n }));\n const target = await projectTarget(flags, { command: \"cron list\", platformScopes: [\"cron:read\"] });\n const body = await requestJson(target, CRON_PATH, \"Failed to list cron jobs\");\n const jobs = jobsOf(body);\n emit(() => {\n if (jobs.length === 0) note(`No cron jobs are scheduled on ${target.label}.`);\n for (const job of jobs) printJob(job);\n if (isRecord(body) && typeof body.note === \"string\") note(chalk.yellow(body.note));\n }, body);\n}\n\nexport const CRON_GET_FLAGS = { ...PROJECT_TARGET_FLAGS } satisfies arg.Spec;\n\nasync function getJob(rawArgs: string[]): Promise<void> {\n const { flags, positionals } = parsedLine(() => parseCommandArgs({\n spec: CRON_GET_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"cron get\",\n maxPositionals: 1\n }));\n const id = parsedLine(() => requireJobId(positionals, \"cron get\"));\n const target = await projectTarget(flags, { command: \"cron get\", platformScopes: [\"cron:read\"] });\n const body = await requestJson(target, `${CRON_PATH}/${encodeURIComponent(id)}`, `Failed to read cron job ${id}`);\n const job = jobOf(body);\n emit(() => (job ? printJob(job) : console.log(JSON.stringify(body, null, 2))), job ?? body);\n}\n\nexport const CRON_LOGS_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--limit\": Number,\n \"-n\": \"--limit\"\n} satisfies arg.Spec;\n\nasync function jobLogs(rawArgs: string[]): Promise<void> {\n const { flags, positionals } = parsedLine(() => parseCommandArgs({\n spec: CRON_LOGS_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"cron logs\",\n maxPositionals: 1\n }));\n const id = parsedLine(() => {\n const job = requireJobId(positionals, \"cron logs\");\n const limit = flags[\"--limit\"];\n if (limit !== undefined && (!Number.isInteger(limit) || limit < 1)) throw new UsageError(\"--limit takes a positive whole number.\");\n return job;\n });\n const target = await projectTarget(flags, { command: \"cron logs\", platformScopes: [\"cron:read\"] });\n const body = await requestJson(target, `${CRON_PATH}/${encodeURIComponent(id)}/logs`, `Failed to read the runs of ${id}`, {\n query: { limit: flags[\"--limit\"]?.toString() }\n });\n const logs = isRecord(body) && Array.isArray(body.logs) ? body.logs.filter(isLogEntry) : [];\n emit(() => {\n if (logs.length === 0) return note(`${id} has no recorded runs.`);\n for (const run of logs) {\n const mark = run.success ? chalk.green(\"✓\") : chalk.red(\"✗\");\n const tags = [shortDuration(run.durationMs), run.manual ? \"manual\" : undefined].filter(Boolean).join(\" \");\n console.log(` ${mark} ${shortTime(run.startedAt)} ${chalk.gray(tags)}`);\n if (run.error) console.log(chalk.red(` ${run.error}`));\n for (const line of run.logs ?? []) console.log(` ${line}`);\n }\n }, body);\n}\n\n/* ═══════════════════════════════════════════════════════════════\n run / enable / disable / reset\n ═══════════════════════════════════════════════════════════════ */\n\nexport const CRON_RUN_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--async\": Boolean\n} satisfies arg.Spec;\n\nasync function runJob(rawArgs: string[]): Promise<void> {\n const { flags, positionals } = parsedLine(() => parseCommandArgs({\n spec: CRON_RUN_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"cron run\",\n maxPositionals: 1\n }));\n const id = parsedLine(() => requireJobId(positionals, \"cron run\"));\n const target = await projectTarget(flags, { command: \"cron run\", platformScopes: [\"cron:write\"] });\n // A run is not undoable — it sends the emails, charges the cards, prunes\n // the rows its code says to — so it says what it is about to do and waits.\n await confirmDestructive({ yes: flags[\"--yes\"] === true, prompt: `Run cron job ${id} now on ${target.label}?` });\n const body = await requestJson(target, `${CRON_PATH}/${encodeURIComponent(id)}/trigger`, `Failed to run ${id}`, {\n method: \"POST\",\n query: flags[\"--async\"] ? { async: \"1\" } : undefined,\n // A synchronous run lasts as long as the job does.\n timeoutMs: flags[\"--async\"] ? 60_000 : 15 * 60_000\n });\n const log = isRecord(body) && isLogEntry(body.log) ? body.log : undefined;\n emit(() => {\n if (flags[\"--async\"]) return success(`Started ${id}; \\`rebase cron logs ${id}\\` shows how it ends.`);\n if (log && !log.success) {\n console.log(chalk.red(` ✗ ${id} failed after ${shortDuration(log.durationMs)}: ${log.error ?? \"no message\"}`));\n for (const line of log.logs ?? []) console.log(` ${line}`);\n process.exitCode = 1;\n return;\n }\n success(`Ran ${id}${log ? ` in ${shortDuration(log.durationMs)}` : \"\"}.`);\n for (const line of log?.logs ?? []) console.log(` ${line}`);\n }, body);\n if (log && !log.success) process.exitCode = 1;\n}\n\nexport const CRON_SWITCH_FLAGS = { ...PROJECT_TARGET_FLAGS } satisfies arg.Spec;\n\n/**\n * `enable` and `disable` override the job's code for every process, across\n * redeploys; `reset` drops the override, so the code decides again.\n */\nasync function switchJob(rawArgs: string[], how: \"enable\" | \"disable\" | \"reset\"): Promise<void> {\n const command = `cron ${how}`;\n // One literal call per action: the help and parse guards read the command\n // name out of each call.\n const parse = {\n enable: () => parseCommandArgs({ spec: CRON_SWITCH_FLAGS, rawArgs, commandWords: 2, command: \"cron enable\", maxPositionals: 1 }),\n disable: () => parseCommandArgs({ spec: CRON_SWITCH_FLAGS, rawArgs, commandWords: 2, command: \"cron disable\", maxPositionals: 1 }),\n reset: () => parseCommandArgs({ spec: CRON_SWITCH_FLAGS, rawArgs, commandWords: 2, command: \"cron reset\", maxPositionals: 1 })\n }[how];\n const { flags, positionals } = parsedLine(parse);\n const id = parsedLine(() => requireJobId(positionals, command));\n const target = await projectTarget(flags, { command, platformScopes: [\"cron:write\"] });\n if (how === \"disable\") {\n // Silently stopping a scheduled backup is the failure this prompt is for.\n await confirmDestructive({ yes: flags[\"--yes\"] === true, prompt: `Switch off cron job ${id} on ${target.label}, until it is enabled again?` });\n }\n const enabled = how === \"enable\" ? true : how === \"disable\" ? false : null;\n const body = await requestJson(target, `${CRON_PATH}/${encodeURIComponent(id)}`, `Failed to ${how} ${id}`, {\n method: \"PUT\",\n json: { enabled }\n });\n const job = jobOf(body);\n emit(() => {\n success(how === \"reset\" ? `${id} follows its code again.` : `${id} is ${how === \"enable\" ? \"on\" : \"off\"}.`);\n if (job) printJob(job);\n }, body);\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Help\n ═══════════════════════════════════════════════════════════════ */\n\nexport const CRON_ACTIONS: HelpAction[] = [\n { action: \"list\", description: \"The scheduled jobs: schedule, state, last and next run (the default)\" },\n { action: \"get\", args: \"<job>\", description: \"One job\" },\n { action: \"logs\", args: \"<job>\", description: \"A job's run history, newest first\", flags: [[\"--limit, -n <n>\", \"At most this many runs\"]] },\n { action: \"run\", args: \"<job>\", description: \"Run a job now (confirms)\", flags: [[\"--async\", \"Answer once it has started; `logs` shows how it ends\"]] },\n { action: \"enable\", args: \"<job>\", description: \"Switch a job on for every process, across redeploys\" },\n { action: \"disable\", args: \"<job>\", description: \"Switch a job off (confirms)\" },\n { action: \"reset\", args: \"<job>\", description: \"Drop the on/off override: the job's code decides again\" }\n];\n\nfunction printCronHelp(): void {\n printProjectHelp({\n command: \"cron\",\n title: \"A running app's scheduled jobs: list, history, run now, switch off\",\n actions: CRON_ACTIONS,\n notes: [\n \"On a Rebase Cloud project, reads need log access and run/enable/disable/reset need an organization owner or admin with Studio switched on.\",\n \"Examples:\",\n \" rebase cron run cleanup-sessions --yes\",\n \" rebase cron logs nightly-backup -n 5 --project acme\"\n ]\n });\n}\n"],"mappings":";;;;;;;;AAmCA,IAAa,mBAAmB;CAAC;CAAQ;CAAO;CAAQ;CAAO;CAAU;CAAW;AAAO;AAE3F,IAAM,YAAY;AAElB,eAAsB,YAAY,YAAgC,SAAk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Q,WAER,MAAM,mBAAmB;EAAE,KAAK,MAAM,aAAa;EAAM,QAAQ,uBAAuB,GAAG,MAAM,OAAO,MAAM;CAA8B,CAAC;CAEjJ,MAAM,UAAU,QAAQ,WAAW,OAAO,QAAQ,YAAY,QAAQ;CACtE,MAAM,OAAO,MAAM,YAAY,QAAQ,GAAG,UAAU,GAAG,mBAAmB,EAAE,KAAK,aAAa,IAAI,GAAG,MAAM;EACvG,QAAQ;EACR,MAAM,EAAE,QAAQ;CACpB,CAAC;CACD,MAAM,MAAM,MAAM,IAAI;CACtB,WAAW;EACP,QAAQ,QAAQ,UAAU,GAAG,GAAG,4BAA4B,GAAG,GAAG,MAAM,QAAQ,WAAW,OAAO,MAAM,EAAE;EAC1G,IAAI,KAAK,SAAS,GAAG;CACzB,GAAG,IAAI;AACX;AAMA,IAAa,eAA6B;CACtC;EAAE,QAAQ;EAAQ,aAAa;CAAuE;CACtG;EAAE,QAAQ;EAAO,MAAM;EAAS,aAAa;CAAU;CACvD;EAAE,QAAQ;EAAQ,MAAM;EAAS,aAAa;EAAqC,OAAO,CAAC,CAAC,mBAAmB,wBAAwB,CAAC;CAAE;CAC1I;EAAE,QAAQ;EAAO,MAAM;EAAS,aAAa;EAA4B,OAAO,CAAC,CAAC,WAAW,sDAAsD,CAAC;CAAE;CACtJ;EAAE,QAAQ;EAAU,MAAM;EAAS,aAAa;CAAsD;CACtG;EAAE,QAAQ;EAAW,MAAM;EAAS,aAAa;CAA8B;CAC/E;EAAE,QAAQ;EAAS,MAAM;EAAS,aAAa;CAAyD;AAC5G;AAEA,SAAS,gBAAsB;CAC3B,iBAAiB;EACb,SAAS;EACT,OAAO;EACP,SAAS;EACT,OAAO;GACH;GACA;GACA;GACA;EACJ;CACJ,CAAC;AACL"}
@@ -1,5 +1,5 @@
1
- import { F as parseCloudArgs, G as reportError, K as requireClient, X as requireProject, Y as requireKnownAction, f as displayProjectRef, m as emit, v as fail } from "./context-BOMEoKxn.js";
2
- import { c as resolveOrigin } from "./debug-nNbbxAeo.js";
1
+ import { F as parseCloudArgs, G as reportError, K as requireClient, X as requireProject, Y as requireKnownAction, f as displayProjectRef, m as emit, v as fail } from "./context-xt20FMFA.js";
2
+ import { c as resolveOrigin } from "./debug-C7Ss34XB.js";
3
3
  import chalk from "chalk";
4
4
  //#region src/commands/cloud/cron.ts
5
5
  /**
@@ -256,4 +256,4 @@ async function cronCommand(action, rawArgs) {
256
256
  //#endregion
257
257
  export { cronCommand, isMissingRoute, mintRuntimeToken, shortDuration, shortTime };
258
258
 
259
- //# sourceMappingURL=cron-ZRXsla0v.js.map
259
+ //# sourceMappingURL=cron-CJ6Xk42E.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cron-ZRXsla0v.js","names":[],"sources":["../src/commands/cloud/cron.ts"],"sourcesContent":["/**\n * `rebase cloud cron` — a deployed project's scheduled jobs and their run\n * history, read with the `rebase cloud` login.\n *\n * ## Why this is not just `curl /api/admin/cron`\n *\n * The run history lives in the app itself — `rebase.cron_logs`, served by the\n * runtime's `/api/admin/cron/:id/logs` — behind the app's admin gate. A project\n * owner is signed in to the *control plane*, which that gate has never heard\n * of, and holds none of what it accepts: often no admin account in the app yet,\n * no `rk_` key, and rightly not the service key, which is admin on the whole API.\n * Pod stdout (`rebase cloud debug logs`) covers the last half hour or so; the\n * history covers every run.\n *\n * ## How it reaches the runtime\n *\n * Two legs, each over a channel `rebase cloud debug` already uses:\n *\n * 1. The control plane, as the signed-in person (`debug logs`' channel):\n * `POST /api/functions/runtime-token/<project>` checks the caller may read\n * this project's logs and answers a token — `rpt_…`, ES256, bound to this\n * project, `cron:read` only, minutes long.\n * 2. The runtime at its public address (`debug health`'s channel), with that\n * token as the bearer. The runtime verifies it against the platform's\n * public key and grants `cron:read` and nothing else — it cannot trigger,\n * disable, or read anything but cron.\n *\n * A fresh token per command: nothing is cached, so nothing long-lived ends up\n * on this machine.\n */\nimport chalk from \"chalk\";\nimport type { CronJobLogEntry, CronJobStatus } from \"@rebasepro/types\";\nimport {\n requireClient,\n requireProject,\n parseCloudArgs,\n displayProjectRef,\n emit,\n fail,\n reportError,\n requireKnownAction,\n type CloudClient\n} from \"./context\";\nimport { resolveOrigin } from \"./debug\";\n\n/** The control-plane function that mints runtime tokens. */\nexport const RUNTIME_TOKEN_FUNCTION = \"runtime-token\";\n\n/** The one scope these commands ask the platform for. */\nexport const CRON_READ_SCOPE = \"cron:read\";\n\n/** Where the runtime serves its cron surface. */\nconst CRON_PATH = \"/api/admin/cron\";\n\nconst RUNTIME_TIMEOUT_MS = 15_000;\n\n/** What `runtime-token` answers. */\nexport interface RuntimeTokenResponse {\n /** `rpt_…` — the bearer the runtime accepts. */\n token: string;\n /** ISO timestamp; past it the runtime refuses the token. */\n expiresAt?: string;\n /** What the token was granted, which may be narrower than what was asked. */\n scopes?: string[];\n}\n\n/** What the runtime's `GET /api/admin/cron` answers. */\ninterface CronListResponse {\n jobs?: CronJobStatus[];\n skipped?: number;\n rejected?: Array<{ id: string; name: string; schedule: string; reason: string }>;\n note?: string;\n}\n\n/** The runtime's error envelope, as far as these commands read it. */\ninterface ErrorEnvelope {\n error?: { code?: string; message?: string };\n}\n\n/**\n * A 404 that is about the route, not the project: the JSON envelope a Rebase\n * backend answers for an unmatched path, or the bare one a router answers\n * before that handler exists.\n */\nexport function isMissingRoute(message: string | undefined): boolean {\n return /^No route for |^(404 )?Not Found$/i.test((message ?? \"\").trim());\n}\n\n/**\n * Ask the control plane for a token the project's runtime will accept.\n *\n * A missing route means this control plane has no `runtime-token` function\n * yet, which is a different fix from \"no such project\" and is said so.\n */\nexport async function mintRuntimeToken(\n client: CloudClient,\n projectId: string,\n scopes: string[]\n): Promise<RuntimeTokenResponse> {\n let res: RuntimeTokenResponse;\n try {\n res = await client.functions.invoke<RuntimeTokenResponse>(RUNTIME_TOKEN_FUNCTION, { scopes }, {\n method: \"POST\",\n path: projectId\n });\n } catch (e) {\n const err = e as { status?: number; message?: string };\n if (err.status === 404 && isMissingRoute(err.message)) {\n fail(\n \"This control plane does not issue runtime tokens yet, so the CLI cannot read the app's cron history.\",\n \"Until it does, `rebase cloud debug logs` shows what jobs printed in the last half hour.\",\n \"runtime_token_unavailable\"\n );\n }\n reportError(e, \"Failed to get a runtime token from the control plane\");\n }\n if (typeof res?.token !== \"string\" || res.token.length === 0) {\n fail(\"The control plane answered without a runtime token.\", undefined, \"runtime_token_unavailable\");\n }\n return res;\n}\n\n/**\n * GET a path on the runtime with a platform token, and refuse — with what it\n * means for this command — anything but a 2xx.\n *\n * `notFound` words the 404, which means different things per route: no cron\n * surface at all on the list, no such job on its logs.\n */\nexport async function runtimeGet<T>(\n origin: string,\n path: string,\n token: string,\n notFound: { message: string; hint?: string; code: string }\n): Promise<T> {\n let res: Response;\n try {\n res = await fetch(`${origin}${path}`, {\n headers: { Authorization: `Bearer ${token}`, Accept: \"application/json\" },\n redirect: \"manual\",\n signal: AbortSignal.timeout(RUNTIME_TIMEOUT_MS)\n });\n } catch (e) {\n fail(\n `Could not reach the app at ${origin}: ${e instanceof Error ? e.message : String(e)}`,\n \"`rebase cloud debug health` checks whether the deployment is answering at all.\",\n \"runtime_unreachable\"\n );\n }\n\n const text = await res.text();\n let body: unknown;\n try {\n body = text ? JSON.parse(text) : undefined;\n } catch {\n body = undefined;\n }\n if (res.ok) return body as T;\n\n const error = (body as ErrorEnvelope | undefined)?.error;\n const said = error?.message ? ` (${error.message})` : \"\";\n\n if (res.status === 401) {\n if (error?.code === \"PLATFORM_TOKENS_OFF\" || error?.code === \"INVALID_PLATFORM_TOKEN\") {\n fail(\n `The app refused the platform's token${said}.`,\n \"The platform sets the key it verifies with when it deploys; redeploying the project picks it up.\",\n \"runtime_token_refused\"\n );\n }\n // A runtime that predates platform tokens parses `rpt_…` as a user\n // session and answers the generic refusal.\n fail(\n `This deployment's runtime does not accept platform tokens${said}.`,\n \"Runtimes from before platform tokens accept only an admin of the app, an `rk_` key or the service key. \" +\n \"Redeploy to move to a runtime that accepts them.\",\n \"runtime_token_refused\"\n );\n }\n if (res.status === 404) fail(notFound.message, notFound.hint, notFound.code);\n if (res.status === 501 && error?.code === \"ADMIN_SURFACE_UNAVAILABLE\") {\n fail(`The app has its admin surfaces switched off${said}.`, undefined, \"admin_surface_unavailable\");\n }\n fail(\n `The app answered ${res.status} for ${path}${said}.`,\n res.status >= 500 ? \"`rebase cloud debug errors` shows what the server logged.\" : undefined,\n res.status === 400 ? \"usage\" : \"runtime_error\"\n );\n}\n\n/** Everything both actions need before their one request. */\nasync function connect(rawArgs: string[]): Promise<{ origin: string; token: string }> {\n const { client, url } = await requireClient(rawArgs);\n const projectId = await requireProject(rawArgs, client);\n // The origin first: a project with no address cannot be read, and that is\n // worth knowing before asking anyone to mint anything.\n const origin = await resolveOrigin(rawArgs, client, url, projectId);\n const { token } = await mintRuntimeToken(client, projectId, [CRON_READ_SCOPE]);\n return { origin, token };\n}\n\nconst NO_CRON_SURFACE = {\n message: \"This deployment serves no cron surface.\",\n hint: \"The app was built without a crons directory, or its runtime does not serve the cron admin routes.\",\n code: \"cron_not_served\"\n};\n\n/** `2026-10-05T10:31:00.000Z` → `2026-10-05 10:31:00Z`, or `—`. */\nexport function shortTime(iso: string | undefined): string {\n if (!iso) return \"—\";\n const date = new Date(iso);\n return Number.isNaN(date.getTime()) ? iso : `${date.toISOString().slice(0, 19).replace(\"T\", \" \")}Z`;\n}\n\n/** Milliseconds as `850ms`, `2.4s` or `3m 10s`. */\nexport function shortDuration(ms: number | undefined): string {\n if (ms === undefined || !Number.isFinite(ms)) return \"\";\n if (ms < 1000) return `${Math.round(ms)}ms`;\n if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`;\n return `${Math.floor(ms / 60_000)}m ${Math.round((ms % 60_000) / 1000)}s`;\n}\n\nfunction stateColor(state: string): string {\n if (state === \"error\") return chalk.red(state);\n if (state === \"running\") return chalk.cyan(state);\n if (state === \"disabled\") return chalk.gray(state);\n if (state === \"success\") return chalk.green(state);\n return state;\n}\n\n/* ═══════════════════════════════════════════════════════════════\n cron list\n ═══════════════════════════════════════════════════════════════ */\n\n/** The flags `cron list` parses — the help page lists exactly these. */\nexport const CRON_LIST_FLAGS = { \"--host\": String };\n\nasync function listCommand(rawArgs: string[]): Promise<void> {\n parseCloudArgs({\n spec: CRON_LIST_FLAGS,\n rawArgs,\n commandWords: 3,\n command: \"cloud cron list\",\n maxPositionals: 0\n });\n const { origin, token } = await connect(rawArgs);\n const res = await runtimeGet<CronListResponse>(origin, CRON_PATH, token, NO_CRON_SURFACE);\n const jobs = res?.jobs ?? [];\n\n emit(\n () => {\n console.log(\"\");\n console.log(chalk.bold(` ⏰ Cron — ${displayProjectRef(rawArgs)}`) + chalk.gray(` ${origin}`));\n console.log(\"\");\n if (jobs.length === 0) {\n console.log(chalk.gray(\" No cron jobs are scheduled on this deployment.\"));\n } else {\n // Padded on the plain text: a colour code has length and no width.\n const lastRun = (job: CronJobStatus): { at: string; took: string } => ({\n at: shortTime(job.lastRunAt),\n took: job.lastRunAt ? shortDuration(job.lastDurationMs) : \"\"\n });\n const lastText = (job: CronJobStatus): string => [lastRun(job).at, lastRun(job).took].filter(Boolean).join(\" \");\n const idWidth = Math.max(3, ...jobs.map(job => job.id.length));\n const scheduleWidth = Math.max(8, ...jobs.map(job => job.schedule.length));\n const stateWidth = Math.max(5, ...jobs.map(job => job.state.length));\n const lastWidth = Math.max(8, ...jobs.map(job => lastText(job).length));\n console.log(chalk.gray(\n ` ${\"JOB\".padEnd(idWidth)} ${\"SCHEDULE\".padEnd(scheduleWidth)} ${\"STATE\".padEnd(stateWidth)} ` +\n `${\"LAST RUN\".padEnd(lastWidth)} NEXT RUN`\n ));\n for (const job of jobs) {\n const { at, took } = lastRun(job);\n const pad = (text: string, width: number) => \" \".repeat(Math.max(0, width - text.length));\n console.log(\n ` ${chalk.bold(job.id)}${pad(job.id, idWidth)} ${job.schedule.padEnd(scheduleWidth)} ` +\n `${stateColor(job.state)}${pad(job.state, stateWidth)} ` +\n `${at}${took ? ` ${chalk.gray(took)}` : \"\"}${pad(lastText(job), lastWidth)} ${shortTime(job.nextRunAt)}`\n );\n if (job.state === \"error\" && job.lastError) {\n console.log(chalk.red(` ${\" \".repeat(idWidth)} ${job.lastError}`));\n }\n }\n }\n if (res?.note) {\n console.log(\"\");\n console.log(chalk.yellow(` ⚠ ${res.note}`));\n for (const rejected of res.rejected ?? []) {\n console.log(chalk.yellow(` ${rejected.id} (${rejected.schedule}): ${rejected.reason}`));\n }\n }\n console.log(\"\");\n if (jobs.length > 0) {\n console.log(chalk.gray(\" A job's run history: \") + chalk.bold(\"rebase cloud cron logs <job>\"));\n console.log(\"\");\n }\n },\n {\n origin,\n jobs,\n skipped: res?.skipped ?? 0,\n rejected: res?.rejected ?? [],\n note: res?.note ?? null\n }\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n cron logs <job>\n ═══════════════════════════════════════════════════════════════ */\n\n/** The flags `cron logs` parses — the help page lists exactly these. */\nexport const CRON_LOGS_FLAGS = { \"--limit\": Number, \"--host\": String };\n\nasync function logsCommand(rawArgs: string[]): Promise<void> {\n const { flags, positionals } = parseCloudArgs({\n spec: CRON_LOGS_FLAGS,\n rawArgs,\n commandWords: 3,\n command: \"cloud cron logs\",\n maxPositionals: 1\n });\n const jobId = positionals[0];\n if (!jobId) {\n fail(\"Name the job: `rebase cloud cron logs <job>`.\", \"`rebase cloud cron list` names them.\", \"usage\");\n }\n const limit = flags[\"--limit\"];\n if (limit !== undefined && (!Number.isInteger(limit) || limit < 1)) {\n fail(`--limit must be a positive whole number; received ${String(limit)}.`, undefined, \"usage\");\n }\n\n const { origin, token } = await connect(rawArgs);\n const query = limit !== undefined ? `?limit=${limit}` : \"\";\n const res = await runtimeGet<{ logs?: CronJobLogEntry[] }>(\n origin,\n `${CRON_PATH}/${encodeURIComponent(jobId)}/logs${query}`,\n token,\n {\n message: `No cron job named \"${jobId}\" on this deployment (or no cron surface at all).`,\n hint: \"`rebase cloud cron list` names the jobs it runs.\",\n code: \"not_found\"\n }\n );\n const logs = res?.logs ?? [];\n\n emit(\n () => {\n console.log(\"\");\n console.log(\n chalk.bold(` 📜 Cron runs — ${jobId} on ${displayProjectRef(rawArgs)}`) +\n chalk.gray(` newest first, ${logs.length} run${logs.length === 1 ? \"\" : \"s\"}`)\n );\n console.log(\"\");\n if (logs.length === 0) {\n console.log(chalk.gray(\" This job has no recorded runs.\"));\n console.log(\"\");\n return;\n }\n for (const run of logs) {\n const mark = run.success ? chalk.green(\"✓\") : chalk.red(\"✗\");\n const tags = [shortDuration(run.durationMs), run.manual ? \"manual\" : undefined].filter(Boolean).join(\" \");\n console.log(` ${mark} ${shortTime(run.startedAt)} ${chalk.gray(tags)}`);\n if (run.error) console.log(chalk.red(` ${run.error}`));\n for (const line of run.logs ?? []) console.log(` ${line}`);\n }\n console.log(\"\");\n },\n { origin, job: jobId, logs }\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Dispatch\n ═══════════════════════════════════════════════════════════════ */\n\nconst CRON_ACTIONS = [\"list\", \"logs\"] as const;\n\nexport async function cronCommand(action: string | undefined, rawArgs: string[]): Promise<void> {\n requireKnownAction(\"cron\", action, CRON_ACTIONS);\n if (action === \"logs\") {\n await logsCommand(rawArgs);\n return;\n }\n await listCommand(rawArgs);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAa,yBAAyB;;AAGtC,IAAa,kBAAkB;;AAG/B,IAAM,YAAY;AAElB,IAAM,qBAAqB;;;;;;AA8B3B,SAAgB,eAAe,SAAsC;CACjE,OAAO,qCAAqC,MAAM,WAAW,GAAA,CAAI,KAAK,CAAC;AAC3E;;;;;;;AAQA,eAAsB,iBAClB,QACA,WACA,QAC6B;CAC7B,IAAI;CACJ,IAAI;EACA,MAAM,MAAM,OAAO,UAAU,OAA6B,wBAAwB,EAAE,OAAO,GAAG;GAC1F,QAAQ;GACR,MAAM;EACV,CAAC;CACL,SAAS,GAAG;EACR,MAAM,MAAM;EACZ,IAAI,IAAI,W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AI,IAAI,OAAO,QAAQ,IAAI,MAAM,IAAI,SAAS,IAAI,OAAO,CAAC;GAC1D,KAAK,MAAM,QAAQ,IAAI,QAAQ,CAAC,GAAG,QAAQ,IAAI,SAAS,MAAM;EAClE;EACA,QAAQ,IAAI,EAAE;CAClB,GACA;EAAE;EAAQ,KAAK;EAAO;CAAK,CAC/B;AACJ;AAMA,IAAM,eAAe,CAAC,QAAQ,MAAM;AAEpC,eAAsB,YAAY,QAA4B,SAAkC;CAC5F,mBAAmB,QAAQ,QAAQ,YAAY;CAC/C,IAAI,WAAW,QAAQ;EACnB,MAAM,YAAY,OAAO;EACzB;CACJ;CACA,MAAM,YAAY,OAAO;AAC7B"}
1
+ {"version":3,"file":"cron-CJ6Xk42E.js","names":[],"sources":["../src/commands/cloud/cron.ts"],"sourcesContent":["/**\n * `rebase cloud cron` — a deployed project's scheduled jobs and their run\n * history, read with the `rebase cloud` login.\n *\n * ## Why this is not just `curl /api/admin/cron`\n *\n * The run history lives in the app itself — `rebase.cron_logs`, served by the\n * runtime's `/api/admin/cron/:id/logs` — behind the app's admin gate. A project\n * owner is signed in to the *control plane*, which that gate has never heard\n * of, and holds none of what it accepts: often no admin account in the app yet,\n * no `rk_` key, and rightly not the service key, which is admin on the whole API.\n * Pod stdout (`rebase cloud debug logs`) covers the last half hour or so; the\n * history covers every run.\n *\n * ## How it reaches the runtime\n *\n * Two legs, each over a channel `rebase cloud debug` already uses:\n *\n * 1. The control plane, as the signed-in person (`debug logs`' channel):\n * `POST /api/functions/runtime-token/<project>` checks the caller may read\n * this project's logs and answers a token — `rpt_…`, ES256, bound to this\n * project, `cron:read` only, minutes long.\n * 2. The runtime at its public address (`debug health`'s channel), with that\n * token as the bearer. The runtime verifies it against the platform's\n * public key and grants `cron:read` and nothing else — it cannot trigger,\n * disable, or read anything but cron.\n *\n * A fresh token per command: nothing is cached, so nothing long-lived ends up\n * on this machine.\n */\nimport chalk from \"chalk\";\nimport type { CronJobLogEntry, CronJobStatus } from \"@rebasepro/types\";\nimport {\n requireClient,\n requireProject,\n parseCloudArgs,\n displayProjectRef,\n emit,\n fail,\n reportError,\n requireKnownAction,\n type CloudClient\n} from \"./context\";\nimport { resolveOrigin } from \"./debug\";\n\n/** The control-plane function that mints runtime tokens. */\nexport const RUNTIME_TOKEN_FUNCTION = \"runtime-token\";\n\n/** The one scope these commands ask the platform for. */\nexport const CRON_READ_SCOPE = \"cron:read\";\n\n/** Where the runtime serves its cron surface. */\nconst CRON_PATH = \"/api/admin/cron\";\n\nconst RUNTIME_TIMEOUT_MS = 15_000;\n\n/** What `runtime-token` answers. */\nexport interface RuntimeTokenResponse {\n /** `rpt_…` — the bearer the runtime accepts. */\n token: string;\n /** ISO timestamp; past it the runtime refuses the token. */\n expiresAt?: string;\n /** What the token was granted, which may be narrower than what was asked. */\n scopes?: string[];\n}\n\n/** What the runtime's `GET /api/admin/cron` answers. */\ninterface CronListResponse {\n jobs?: CronJobStatus[];\n skipped?: number;\n rejected?: Array<{ id: string; name: string; schedule: string; reason: string }>;\n note?: string;\n}\n\n/** The runtime's error envelope, as far as these commands read it. */\ninterface ErrorEnvelope {\n error?: { code?: string; message?: string };\n}\n\n/**\n * A 404 that is about the route, not the project: the JSON envelope a Rebase\n * backend answers for an unmatched path, or the bare one a router answers\n * before that handler exists.\n */\nexport function isMissingRoute(message: string | undefined): boolean {\n return /^No route for |^(404 )?Not Found$/i.test((message ?? \"\").trim());\n}\n\n/**\n * Ask the control plane for a token the project's runtime will accept.\n *\n * A missing route means this control plane has no `runtime-token` function\n * yet, which is a different fix from \"no such project\" and is said so.\n */\nexport async function mintRuntimeToken(\n client: CloudClient,\n projectId: string,\n scopes: string[]\n): Promise<RuntimeTokenResponse> {\n let res: RuntimeTokenResponse;\n try {\n res = await client.functions.invoke<RuntimeTokenResponse>(RUNTIME_TOKEN_FUNCTION, { scopes }, {\n method: \"POST\",\n path: projectId\n });\n } catch (e) {\n const err = e as { status?: number; message?: string };\n if (err.status === 404 && isMissingRoute(err.message)) {\n fail(\n \"This control plane does not issue runtime tokens yet, so the CLI cannot read the app's cron history.\",\n \"Until it does, `rebase cloud debug logs` shows what jobs printed in the last half hour.\",\n \"runtime_token_unavailable\"\n );\n }\n reportError(e, \"Failed to get a runtime token from the control plane\");\n }\n if (typeof res?.token !== \"string\" || res.token.length === 0) {\n fail(\"The control plane answered without a runtime token.\", undefined, \"runtime_token_unavailable\");\n }\n return res;\n}\n\n/**\n * GET a path on the runtime with a platform token, and refuse — with what it\n * means for this command — anything but a 2xx.\n *\n * `notFound` words the 404, which means different things per route: no cron\n * surface at all on the list, no such job on its logs.\n */\nexport async function runtimeGet<T>(\n origin: string,\n path: string,\n token: string,\n notFound: { message: string; hint?: string; code: string }\n): Promise<T> {\n let res: Response;\n try {\n res = await fetch(`${origin}${path}`, {\n headers: { Authorization: `Bearer ${token}`, Accept: \"application/json\" },\n redirect: \"manual\",\n signal: AbortSignal.timeout(RUNTIME_TIMEOUT_MS)\n });\n } catch (e) {\n fail(\n `Could not reach the app at ${origin}: ${e instanceof Error ? e.message : String(e)}`,\n \"`rebase cloud debug health` checks whether the deployment is answering at all.\",\n \"runtime_unreachable\"\n );\n }\n\n const text = await res.text();\n let body: unknown;\n try {\n body = text ? JSON.parse(text) : undefined;\n } catch {\n body = undefined;\n }\n if (res.ok) return body as T;\n\n const error = (body as ErrorEnvelope | undefined)?.error;\n const said = error?.message ? ` (${error.message})` : \"\";\n\n if (res.status === 401) {\n if (error?.code === \"PLATFORM_TOKENS_OFF\" || error?.code === \"INVALID_PLATFORM_TOKEN\") {\n fail(\n `The app refused the platform's token${said}.`,\n \"The platform sets the key it verifies with when it deploys; redeploying the project picks it up.\",\n \"runtime_token_refused\"\n );\n }\n // A runtime that predates platform tokens parses `rpt_…` as a user\n // session and answers the generic refusal.\n fail(\n `This deployment's runtime does not accept platform tokens${said}.`,\n \"Runtimes from before platform tokens accept only an admin of the app, an `rk_` key or the service key. \" +\n \"Redeploy to move to a runtime that accepts them.\",\n \"runtime_token_refused\"\n );\n }\n if (res.status === 404) fail(notFound.message, notFound.hint, notFound.code);\n if (res.status === 501 && error?.code === \"ADMIN_SURFACE_UNAVAILABLE\") {\n fail(`The app has its admin surfaces switched off${said}.`, undefined, \"admin_surface_unavailable\");\n }\n fail(\n `The app answered ${res.status} for ${path}${said}.`,\n res.status >= 500 ? \"`rebase cloud debug errors` shows what the server logged.\" : undefined,\n res.status === 400 ? \"usage\" : \"runtime_error\"\n );\n}\n\n/** Everything both actions need before their one request. */\nasync function connect(rawArgs: string[]): Promise<{ origin: string; token: string }> {\n const { client, url } = await requireClient(rawArgs);\n const projectId = await requireProject(rawArgs, client);\n // The origin first: a project with no address cannot be read, and that is\n // worth knowing before asking anyone to mint anything.\n const origin = await resolveOrigin(rawArgs, client, url, projectId);\n const { token } = await mintRuntimeToken(client, projectId, [CRON_READ_SCOPE]);\n return { origin, token };\n}\n\nconst NO_CRON_SURFACE = {\n message: \"This deployment serves no cron surface.\",\n hint: \"The app was built without a crons directory, or its runtime does not serve the cron admin routes.\",\n code: \"cron_not_served\"\n};\n\n/** `2026-10-05T10:31:00.000Z` → `2026-10-05 10:31:00Z`, or `—`. */\nexport function shortTime(iso: string | undefined): string {\n if (!iso) return \"—\";\n const date = new Date(iso);\n return Number.isNaN(date.getTime()) ? iso : `${date.toISOString().slice(0, 19).replace(\"T\", \" \")}Z`;\n}\n\n/** Milliseconds as `850ms`, `2.4s` or `3m 10s`. */\nexport function shortDuration(ms: number | undefined): string {\n if (ms === undefined || !Number.isFinite(ms)) return \"\";\n if (ms < 1000) return `${Math.round(ms)}ms`;\n if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`;\n return `${Math.floor(ms / 60_000)}m ${Math.round((ms % 60_000) / 1000)}s`;\n}\n\nfunction stateColor(state: string): string {\n if (state === \"error\") return chalk.red(state);\n if (state === \"running\") return chalk.cyan(state);\n if (state === \"disabled\") return chalk.gray(state);\n if (state === \"success\") return chalk.green(state);\n return state;\n}\n\n/* ═══════════════════════════════════════════════════════════════\n cron list\n ═══════════════════════════════════════════════════════════════ */\n\n/** The flags `cron list` parses — the help page lists exactly these. */\nexport const CRON_LIST_FLAGS = { \"--host\": String };\n\nasync function listCommand(rawArgs: string[]): Promise<void> {\n parseCloudArgs({\n spec: CRON_LIST_FLAGS,\n rawArgs,\n commandWords: 3,\n command: \"cloud cron list\",\n maxPositionals: 0\n });\n const { origin, token } = await connect(rawArgs);\n const res = await runtimeGet<CronListResponse>(origin, CRON_PATH, token, NO_CRON_SURFACE);\n const jobs = res?.jobs ?? [];\n\n emit(\n () => {\n console.log(\"\");\n console.log(chalk.bold(` ⏰ Cron — ${displayProjectRef(rawArgs)}`) + chalk.gray(` ${origin}`));\n console.log(\"\");\n if (jobs.length === 0) {\n console.log(chalk.gray(\" No cron jobs are scheduled on this deployment.\"));\n } else {\n // Padded on the plain text: a colour code has length and no width.\n const lastRun = (job: CronJobStatus): { at: string; took: string } => ({\n at: shortTime(job.lastRunAt),\n took: job.lastRunAt ? shortDuration(job.lastDurationMs) : \"\"\n });\n const lastText = (job: CronJobStatus): string => [lastRun(job).at, lastRun(job).took].filter(Boolean).join(\" \");\n const idWidth = Math.max(3, ...jobs.map(job => job.id.length));\n const scheduleWidth = Math.max(8, ...jobs.map(job => job.schedule.length));\n const stateWidth = Math.max(5, ...jobs.map(job => job.state.length));\n const lastWidth = Math.max(8, ...jobs.map(job => lastText(job).length));\n console.log(chalk.gray(\n ` ${\"JOB\".padEnd(idWidth)} ${\"SCHEDULE\".padEnd(scheduleWidth)} ${\"STATE\".padEnd(stateWidth)} ` +\n `${\"LAST RUN\".padEnd(lastWidth)} NEXT RUN`\n ));\n for (const job of jobs) {\n const { at, took } = lastRun(job);\n const pad = (text: string, width: number) => \" \".repeat(Math.max(0, width - text.length));\n console.log(\n ` ${chalk.bold(job.id)}${pad(job.id, idWidth)} ${job.schedule.padEnd(scheduleWidth)} ` +\n `${stateColor(job.state)}${pad(job.state, stateWidth)} ` +\n `${at}${took ? ` ${chalk.gray(took)}` : \"\"}${pad(lastText(job), lastWidth)} ${shortTime(job.nextRunAt)}`\n );\n if (job.state === \"error\" && job.lastError) {\n console.log(chalk.red(` ${\" \".repeat(idWidth)} ${job.lastError}`));\n }\n }\n }\n if (res?.note) {\n console.log(\"\");\n console.log(chalk.yellow(` ⚠ ${res.note}`));\n for (const rejected of res.rejected ?? []) {\n console.log(chalk.yellow(` ${rejected.id} (${rejected.schedule}): ${rejected.reason}`));\n }\n }\n console.log(\"\");\n if (jobs.length > 0) {\n console.log(chalk.gray(\" A job's run history: \") + chalk.bold(\"rebase cloud cron logs <job>\"));\n console.log(\"\");\n }\n },\n {\n origin,\n jobs,\n skipped: res?.skipped ?? 0,\n rejected: res?.rejected ?? [],\n note: res?.note ?? null\n }\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n cron logs <job>\n ═══════════════════════════════════════════════════════════════ */\n\n/** The flags `cron logs` parses — the help page lists exactly these. */\nexport const CRON_LOGS_FLAGS = { \"--limit\": Number, \"--host\": String };\n\nasync function logsCommand(rawArgs: string[]): Promise<void> {\n const { flags, positionals } = parseCloudArgs({\n spec: CRON_LOGS_FLAGS,\n rawArgs,\n commandWords: 3,\n command: \"cloud cron logs\",\n maxPositionals: 1\n });\n const jobId = positionals[0];\n if (!jobId) {\n fail(\"Name the job: `rebase cloud cron logs <job>`.\", \"`rebase cloud cron list` names them.\", \"usage\");\n }\n const limit = flags[\"--limit\"];\n if (limit !== undefined && (!Number.isInteger(limit) || limit < 1)) {\n fail(`--limit must be a positive whole number; received ${String(limit)}.`, undefined, \"usage\");\n }\n\n const { origin, token } = await connect(rawArgs);\n const query = limit !== undefined ? `?limit=${limit}` : \"\";\n const res = await runtimeGet<{ logs?: CronJobLogEntry[] }>(\n origin,\n `${CRON_PATH}/${encodeURIComponent(jobId)}/logs${query}`,\n token,\n {\n message: `No cron job named \"${jobId}\" on this deployment (or no cron surface at all).`,\n hint: \"`rebase cloud cron list` names the jobs it runs.\",\n code: \"not_found\"\n }\n );\n const logs = res?.logs ?? [];\n\n emit(\n () => {\n console.log(\"\");\n console.log(\n chalk.bold(` 📜 Cron runs — ${jobId} on ${displayProjectRef(rawArgs)}`) +\n chalk.gray(` newest first, ${logs.length} run${logs.length === 1 ? \"\" : \"s\"}`)\n );\n console.log(\"\");\n if (logs.length === 0) {\n console.log(chalk.gray(\" This job has no recorded runs.\"));\n console.log(\"\");\n return;\n }\n for (const run of logs) {\n const mark = run.success ? chalk.green(\"✓\") : chalk.red(\"✗\");\n const tags = [shortDuration(run.durationMs), run.manual ? \"manual\" : undefined].filter(Boolean).join(\" \");\n console.log(` ${mark} ${shortTime(run.startedAt)} ${chalk.gray(tags)}`);\n if (run.error) console.log(chalk.red(` ${run.error}`));\n for (const line of run.logs ?? []) console.log(` ${line}`);\n }\n console.log(\"\");\n },\n { origin, job: jobId, logs }\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Dispatch\n ═══════════════════════════════════════════════════════════════ */\n\nconst CRON_ACTIONS = [\"list\", \"logs\"] as const;\n\nexport async function cronCommand(action: string | undefined, rawArgs: string[]): Promise<void> {\n requireKnownAction(\"cron\", action, CRON_ACTIONS);\n if (action === \"logs\") {\n await logsCommand(rawArgs);\n return;\n }\n await listCommand(rawArgs);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAa,yBAAyB;;AAGtC,IAAa,kBAAkB;;AAG/B,IAAM,YAAY;AAElB,IAAM,qBAAqB;;;;;;AA8B3B,SAAgB,eAAe,SAAsC;CACjE,OAAO,qCAAqC,MAAM,WAAW,GAAA,CAAI,KAAK,CAAC;AAC3E;;;;;;;AAQA,eAAsB,iBAClB,QACA,WACA,QAC6B;CAC7B,IAAI;CACJ,IAAI;EACA,MAAM,MAAM,OAAO,UAAU,OAA6B,wBAAwB,EAAE,OAAO,GAAG;GAC1F,QAAQ;GACR,MAAM;EACV,CAAC;CACL,SAAS,GAAG;EACR,MAAM,MAAM;EACZ,IA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G;GACxE,IAAI,IAAI,OAAO,QAAQ,IAAI,MAAM,IAAI,SAAS,IAAI,OAAO,CAAC;GAC1D,KAAK,MAAM,QAAQ,IAAI,QAAQ,CAAC,GAAG,QAAQ,IAAI,SAAS,MAAM;EAClE;EACA,QAAQ,IAAI,EAAE;CAClB,GACA;EAAE;EAAQ,KAAK;EAAO;CAAK,CAC/B;AACJ;AAMA,IAAM,eAAe,CAAC,QAAQ,MAAM;AAEpC,eAAsB,YAAY,QAA4B,SAAkC;CAC5F,mBAAmB,QAAQ,QAAQ,YAAY;CAC/C,IAAI,WAAW,QAAQ;EACnB,MAAM,YAAY,OAAO;EACzB;CACJ;CACA,MAAM,YAAY,OAAO;AAC7B"}
@@ -1,7 +1,7 @@
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, g as readJson, i as printProjectHelp, l as startProjectCommand, n as isRecord, o as recordsOf, r as parsedLine, s as reportTargetError, t as cellText, u as stringOf } from "./project-command-Cl9EZzjr.js";
4
- import { D as isJsonMode, M as note, k as keyValues, l as confirmDestructive, m as emit, st as success, v as fail } from "./context-BOMEoKxn.js";
3
+ import { a as projectTarget, c as requestJson, d as PROJECT_TARGET_FLAGS, g as readJson, i as printProjectHelp, l as startProjectCommand, n as isRecord, o as recordsOf, r as parsedLine, s as reportTargetError, t as cellText, u as stringOf } from "./project-command-7EGMemEy.js";
4
+ import { D as isJsonMode, M as note, k as keyValues, l as confirmDestructive, m as emit, st as success, v as fail } from "./context-xt20FMFA.js";
5
5
  import chalk from "chalk";
6
6
  import fs from "fs";
7
7
  //#region src/commands/data.ts
@@ -944,4 +944,4 @@ function printDataHelp() {
944
944
  //#endregion
945
945
  export { DATA_SUBCOMMANDS, dataCommand };
946
946
 
947
- //# sourceMappingURL=data-BJ9AZFUC.js.map
947
+ //# sourceMappingURL=data-BpkvtCUe.js.map