From 4e9b48ed70f8604c52520190d267ddc08059840a Mon Sep 17 00:00:00 2001 From: Benjamin <5719034+bnjjj@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:51:00 +0100 Subject: [PATCH] feat(cli): add warehouse recovery controls and layout examples --- apps/cli/scripts/api-command-reference.ts | 8 + .../src/commands/api/api-command-policy.ts | 27 +- .../cli/src/commands/api/api-command.model.ts | 2 + .../api/api-commands.integration.test.ts | 197 ++- apps/cli/src/commands/api/generated.md | 37 +- apps/cli/src/commands/api/generated.ts | 51 +- apps/cli/src/commands/api/runtime.ts | 5 +- packages/api/scripts/openapi-overrides.json | 682 ++++++++++- packages/api/src/generated/contracts.ts | 422 +++++-- packages/api/src/generated/effect-client.ts | 16 + packages/api/src/generated/openapi.json | 1063 +++++++++++++---- packages/api/src/generated/permissions.ts | 4 + 12 files changed, 2222 insertions(+), 292 deletions(-) diff --git a/apps/cli/scripts/api-command-reference.ts b/apps/cli/scripts/api-command-reference.ts index 3b67c0f5f6..b82dc0e7cd 100644 --- a/apps/cli/scripts/api-command-reference.ts +++ b/apps/cli/scripts/api-command-reference.ts @@ -152,6 +152,14 @@ const commandSection = ( "", entry.summary, "", + ...(entry.examples ?? []).flatMap((example) => [ + example.description, + "", + "```sh", + example.command, + "```", + "", + ]), ...(entry.description === undefined ? [] : [entry.description, ""]), `- Access: ${entry.readOnly ? "read-only, no consent" : "mutation, consent defaults to No (`--yes` when it cannot prompt)"}.`, ...experimentalLine(entry, input), diff --git a/apps/cli/src/commands/api/api-command-policy.ts b/apps/cli/src/commands/api/api-command-policy.ts index 68993f0230..531b307ea1 100644 --- a/apps/cli/src/commands/api/api-command-policy.ts +++ b/apps/cli/src/commands/api/api-command-policy.ts @@ -1,3 +1,4 @@ +import type { ApiCommandEntry } from "./api-command.model.ts"; import type { OpenApiOperationId } from "@supabase/api/effect"; import type { ExperimentalFeature } from "../../shared/config/experimental-feature.ts"; @@ -26,19 +27,43 @@ export const generatedOperations: ReadonlyArray = [ "v2-add-warehouse-replication", "v2-remove-warehouse-replication", "v2-resync-warehouse-replication", + "v2-restart-warehouse-replication", ]; export interface ApiCommandPolicy { readonly confirmDescription?: true; + readonly examples?: ApiCommandEntry["examples"]; } /** CLI presentation choices, independent of the API's operation metadata. */ export const commandPolicies = { "v2-disable-warehouse": { confirmDescription: true }, - "v2-update-warehouse-table-layout": { confirmDescription: true }, + "v2-update-warehouse-table-layout": { + confirmDescription: true, + examples: [ + { + command: `supabase warehouse tables layout update --partition-by '[{"column":"event_at","transform":{"kind":"day"}}]' --sort-by '{"kind":"columns","columns":[{"name":"tenant_id","direction":"asc"},{"name":"event_at","direction":"desc","nulls":"last"}]}'`, + description: + "Partition new files by event day and sort within files; preserve historical files.", + }, + { + command: `supabase warehouse tables layout update --partition-by '[{"column":"tenant_id","transform":{"kind":"bucket","count":8}}]' --dry-run`, + description: "Preview eight hash buckets locally without changing the Warehouse.", + }, + { + command: `supabase warehouse tables layout update --partition-by '[]' --sort-by '{"kind":"none"}'`, + description: "Clear partitioning and sorting for future writes.", + }, + { + command: `supabase warehouse tables layout update --partition-by 'null' --sort-by 'null'`, + description: "Stop managing both settings; omitted flags preserve their saved values.", + }, + ], + }, "v2-add-warehouse-replication": { confirmDescription: true }, "v2-remove-warehouse-replication": { confirmDescription: true }, "v2-resync-warehouse-replication": { confirmDescription: true }, + "v2-restart-warehouse-replication": { confirmDescription: true }, } satisfies Partial>; export const nouns = { diff --git a/apps/cli/src/commands/api/api-command.model.ts b/apps/cli/src/commands/api/api-command.model.ts index 65e087a17e..f647118a1b 100644 --- a/apps/cli/src/commands/api/api-command.model.ts +++ b/apps/cli/src/commands/api/api-command.model.ts @@ -87,6 +87,8 @@ export interface ApiCommandEntry { readonly name: string; readonly description?: string; }; + /** Concrete invocation examples maintained by the CLI command policy. */ + readonly examples?: readonly { readonly command: string; readonly description: string }[]; readonly flags: readonly ApiCommandFlag[]; readonly bindings: readonly ApiCommandBinding[]; readonly wait?: ApiCommandWait; diff --git a/apps/cli/src/commands/api/api-commands.integration.test.ts b/apps/cli/src/commands/api/api-commands.integration.test.ts index 47d34cdd1f..5d0d6fda84 100644 --- a/apps/cli/src/commands/api/api-commands.integration.test.ts +++ b/apps/cli/src/commands/api/api-commands.integration.test.ts @@ -453,6 +453,64 @@ describe("generated warehouse commands", () => { }); }); + describe("warehouse replication restart", () => { + const argv = ["warehouse", "replication", "restart"]; + const response = { + data: { + type: "warehouse_replication_restart", + id: "pipeline-1", + attributes: { + pipeline_id: "pipeline-1", + action: "start", + application_status: "accepted", + pipeline_status_before: "stopped", + }, + }, + }; + + it.effect("sends one restart and returns acceptance without polling old readiness", () => { + const { sent, out, run } = setup(argv, { + yes: true, + route: () => ({ status: 202, body: response }), + outputFormat: "json", + }); + return Effect.gen(function* () { + yield* run; + expect(sent).toEqual([ + { + method: "POST", + path: `/v2/projects/${VALID_REF}/warehouse/replication/restart`, + search: "", + body: undefined, + }, + ]); + expect(decodeJson(out.stdoutText)).toEqual(response); + }); + }); + + it.effect("does not retry an uncertain restart", () => { + const { sent, run } = setup(argv, { + yes: true, + route: () => ({ + status: 503, + body: { message: "Inspect pipeline state before retrying." }, + }), + }); + return Effect.gen(function* () { + expect(Exit.isFailure(yield* Effect.exit(run))).toBe(true); + expect(sent).toHaveLength(1); + }); + }); + + it.effect("rejects --wait without sending a request", () => { + const { sent, run } = setup([...argv, "--wait"], { yes: true, route: accepted }); + return Effect.gen(function* () { + expect(Exit.isFailure(yield* Effect.exit(run))).toBe(true); + expect(sent).toEqual([]); + }); + }); + }); + describe("consolidated warehouse status", () => { const attributes = { project_ref: VALID_REF, @@ -475,6 +533,7 @@ describe("generated warehouse commands", () => { unavailable_reason: null, observed_at: "2026-11-17T10:00:00Z", items: [], + progress: null, }, replication: { status: "unavailable", @@ -487,6 +546,7 @@ describe("generated warehouse commands", () => { query_explain: false, replication_add: false, replication_remove: true, + replication_restart: true, table_layout_read: true, table_layout_update: false, table_resync: false, @@ -556,11 +616,75 @@ describe("generated warehouse commands", () => { }); }); + it.effect("shows runtime diagnostics beside last-known table errors and progress", () => { + const response = { + data: { + ...body.data, + attributes: { + ...attributes, + pipeline: { + id: "pipeline-1", + status: "failed", + diagnostic: { + code: "process_exited", + message: "The pipeline process exited unsuccessfully.", + exit_code: 1, + }, + observed_at: attributes.observed_at, + unavailable_reason: null, + }, + tables: { + ...attributes.tables, + progress: { + observation: "last_known", + selected: 1, + queued: 0, + copying_table: 0, + copied_table: 0, + following_wal: 0, + error: 1, + unknown: 0, + }, + items: [ + { + id: 16385, + schema: "public", + name: "orders", + replication_state: "error", + state_observation: "last_known", + sync_lag: null, + error: { + reason: "The table layout could not be applied.", + solution: "Inspect the saved layout.", + retry_policy: { policy: "manual_retry" }, + }, + }, + ], + }, + }, + }, + }; + const { out, run } = setup(["warehouse", "status"], { + route: ok(response), + stdoutIsTty: true, + }); + return Effect.gen(function* () { + yield* run; + expect(out.stdoutText).toContain("process_exited"); + expect(out.stdoutText).toContain("The table layout could not be applied."); + expect(out.stdoutText).toContain("manual_retry"); + expect(out.stdoutText).toMatch(/Observation\s+last_known/); + expect(out.stdoutText).toMatch(/Selected\s+1/); + }); + }); + it.effect("lists every table of a large warehouse in terminal output", () => { const items = Array.from({ length: 12 }, (_, index) => ({ id: 20000 + index, schema: "public", name: `table_${index}`, + error: null, + state_observation: "current" as const, replication_state: index === 0 ? ("error" as const) : ("following_wal" as const), sync_lag: index === 1 @@ -586,7 +710,7 @@ describe("generated warehouse commands", () => { return Effect.gen(function* () { yield* run; expect(out.stdoutText).toMatch( - /ID\s+20000\n\s+Schema\s+public\n\s+Name\s+table_0\n\s+Replication state\s+error\n/, + /ID\s+20000\n\s+Schema\s+public\n\s+Name\s+table_0\n\s+Error\s+-\n\s+State observation\s+current\n\s+Replication state\s+error\n/, ); for (const item of items) expect(out.stdoutText).toContain(String(item.id)); expect(out.stdoutText).not.toContain("omitted"); @@ -1094,6 +1218,48 @@ describe("generated warehouse commands", () => { }); }); + it.effect("accepts every displayed layout JSON example through the parser", () => { + const examples = entryOf("warehouse tables layout update").examples ?? []; + const expected = [ + { + partition_by: [{ column: "event_at", transform: { kind: "day" } }], + sort_by: { + kind: "columns", + columns: [ + { name: "tenant_id", direction: "asc" }, + { name: "event_at", direction: "desc", nulls: "last" }, + ], + }, + }, + { partition_by: [{ column: "tenant_id", transform: { kind: "bucket", count: 8 } }] }, + { partition_by: [], sort_by: { kind: "none" } }, + { partition_by: null, sort_by: null }, + ]; + expect(examples).toHaveLength(expected.length); + return Effect.gen(function* () { + for (const [index, example] of examples.entries()) { + const args = + example.command + .replace(/^supabase /, "") + .replace("", "16385") + .match(/'[^']*'|\S+/g) + ?.map((token) => token.replace(/^'|'$/g, "")) ?? []; + const preview = args.includes("--dry-run"); + const { sent, out, run } = setup(args, { yes: true, route: accepted }); + yield* run; + const body = preview + ? (yield* Schema.decodeEffect( + Schema.fromJsonString(Schema.Struct({ body: Schema.Unknown })), + )(out.stdoutText)).body + : sent[0]?.body; + expect(body).toEqual({ + data: { type: "warehouse_table_layout", attributes: expected[index] }, + }); + expect(sent).toHaveLength(preview ? 0 : 1); + } + }); + }); + it.effect("keeps a JSON null from --sort-by as unmanaged sorting", () => { const { sent, out, run } = setup([...argv, "--sort-by", "null", "--dry-run"], { route: accepted, @@ -1996,6 +2162,16 @@ describe("generated warehouse commands", () => { }); describe("help", () => { + it.effect("distinguishes Management API capabilities from SQL EXPLAIN in status help", () => { + const { console, calls } = fakeConsole(); + const { run } = setup(["warehouse", "status", "--help"], { route: accepted }); + return Effect.gen(function* () { + yield* run.pipe(Effect.provideService(Console.Console, console)); + expect(calls.join("\n")).toContain("Capabilities describe Management API operations"); + expect(calls.join("\n")).toContain("SQL EXPLAIN"); + }); + }); + it.effect("shows a body file in the layout update example", () => { const { console, calls } = fakeConsole(); const { run } = setup(["warehouse", "tables", "layout", "update", "--help"], { @@ -2006,6 +2182,10 @@ describe("generated warehouse commands", () => { expect(calls.join("\n")).toContain( "supabase warehouse tables layout update --file ", ); + expect(calls.join("\n")).toContain( + `--partition-by '[{"column":"event_at","transform":{"kind":"day"}}]'`, + ); + expect(calls.join("\n")).toContain(`--sort-by '{"kind":"none"}'`); }); }); @@ -2827,3 +3007,18 @@ describeHostedConsent("warehouse replication resync", { }; }, }); + +describeHostedConsent("warehouse replication restart", { + command: commandTreeFor({ apiFeatures: ["warehouse"] }).get("warehouse replication restart")! + .command, + invoke: ({ workdir, yes }) => { + const { args, sent, run } = execute(["warehouse", "replication", "restart"], { + yes, + route: accepted, + }); + return { + run: run.pipe(Effect.provide(cliServices(workdir, args))), + mutations: () => sent.filter((request) => request.method !== "GET").length, + }; + }, +}); diff --git a/apps/cli/src/commands/api/generated.md b/apps/cli/src/commands/api/generated.md index 86ae4c63e9..424d5b48ff 100644 --- a/apps/cli/src/commands/api/generated.md +++ b/apps/cli/src/commands/api/generated.md @@ -154,6 +154,17 @@ Removes one selected source table or all selected tables in a schema as a batch. | `--schema ` | string | yes, unless `--body` or `--file` has the field | no | body `/data/attributes/schema` | | `--table ` | string | no | no | body `/data/attributes/table` | +## `supabase warehouse replication restart` + +Start or restart Warehouse replication + +Starts a stopped managed pipeline or restarts a starting, started or failed pipeline, preserving the selected tables and saved layouts. Restart interrupts replication; in-progress initial copies may restart from scratch. If lost-slot recreation is configured, startup can rebuild destination tables. The response confirms acceptance only. Inspect warehouse status for runtime diagnostics and observed table progress; these observations do not identify completion of this request. Inspect state before retrying an uncertain response. + +- Access: mutation, consent defaults to No (`--yes` when it cannot prompt). +- Experimental: enable with `experimental.warehouse` or `SUPABASE_EXPERIMENTAL_WAREHOUSE=1`. +- Consent: prints the API description before the interactive confirmation. +- Request: `POST /v2/projects/{ref}/warehouse/replication/restart` (`v2-restart-warehouse-replication`), success 202 json. + ## `supabase warehouse replication resync` Reset and rebuild one Warehouse table @@ -177,7 +188,7 @@ Resets replication for one selected source table using its currently saved layou Get consolidated Warehouse status and capabilities -Returns provisioning, configured compute, replication, cleanup lifecycle and supported capabilities, including when individual dependencies are unavailable. Enabled Warehouse state is independent of the selected table count. Readiness is inferred from configuration and replication; query connectivity is not checked. Does not inspect the FDW. Observation timestamps are retrieval times, separate from table sync lag, pipeline apply lag and feedback age. Read access remains available without a replication entitlement; mutation endpoints enforce their own entitlements and permissions. +Returns provisioning, configured compute, replication, cleanup lifecycle and supported capabilities, including when individual dependencies are unavailable. Enabled Warehouse state is independent of the selected table count. Readiness is inferred from configuration and replication; query connectivity is not checked. Does not inspect the FDW. Observation timestamps are retrieval times, separate from table sync lag, pipeline apply lag and feedback age. Read access remains available without a replication entitlement; mutation endpoints enforce their own entitlements and permissions. Runtime diagnostics classify current failures. Table errors and progress are explicitly current, last-known or unavailable; they do not establish completion of a particular restart or resync. Capabilities describe Management API operations: workload_metrics includes query-stats and capacity; query_explain does not describe SQL EXPLAIN through the Warehouse connection. - Access: read-only, no consent. - Experimental: enable with `experimental.warehouse` or `SUPABASE_EXPERIMENTAL_WAREHOUSE=1`. @@ -209,6 +220,30 @@ Returns the sorting and partitioning rules saved for one replicated table, by so Update the layout of a table replicated to Warehouse +Partition new files by event day and sort within files; preserve historical files. + +```sh +supabase warehouse tables layout update --partition-by '[{"column":"event_at","transform":{"kind":"day"}}]' --sort-by '{"kind":"columns","columns":[{"name":"tenant_id","direction":"asc"},{"name":"event_at","direction":"desc","nulls":"last"}]}' +``` + +Preview eight hash buckets locally without changing the Warehouse. + +```sh +supabase warehouse tables layout update --partition-by '[{"column":"tenant_id","transform":{"kind":"bucket","count":8}}]' --dry-run +``` + +Clear partitioning and sorting for future writes. + +```sh +supabase warehouse tables layout update --partition-by '[]' --sort-by '{"kind":"none"}' +``` + +Stop managing both settings; omitted flags preserve their saved values. + +```sh +supabase warehouse tables layout update --partition-by 'null' --sort-by 'null' +``` + Updates saved sorting and partitioning rules for one source table object identifier (OID). Provide sort_by or partition_by; empty and reset-only patches are rejected. Omitted settings are preserved. Null makes a setting unmanaged. An empty partition list clears partitioning, and the none sort selector clears sorting. The backend validates the source schema and preserves other tables. When the layout changes, an active pipeline is restarted. A stopped pipeline stays stopped. reset_table defaults to false, preserving historical files and replication progress. When the layout changes, --reset-table resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never restarts the pipeline or resets the table. Acceptance and application_status report orchestration. Run warehouse tables layout get to compare the desired and observed rules. Run warehouse tables get to check table replication status. These reads do not establish completion of this specific update. There is no revision, idempotency, resolved preview, or durable operation contract. A failed update can leave partial effects, including a completed reset. Inspect the saved layout, pipeline, and table state before retrying. - Access: mutation, consent defaults to No (`--yes` when it cannot prompt). diff --git a/apps/cli/src/commands/api/generated.ts b/apps/cli/src/commands/api/generated.ts index 977e85bd82..750afc0ba7 100644 --- a/apps/cli/src/commands/api/generated.ts +++ b/apps/cli/src/commands/api/generated.ts @@ -449,6 +449,24 @@ export const apiCommands = [ }, ], }, + { + command: ["warehouse", "replication", "restart"], + operationId: "v2-restart-warehouse-replication", + definition: "v2RestartWarehouseReplication", + summary: "Start or restart Warehouse replication", + description: + "Starts a stopped managed pipeline or restarts a starting, started or failed pipeline, preserving the selected tables and saved layouts. Restart interrupts replication; in-progress initial copies may restart from scratch. If lost-slot recreation is configured, startup can rebuild destination tables. The response confirms acceptance only. Inspect warehouse status for runtime diagnostics and observed table progress; these observations do not identify completion of this request. Inspect state before retrying an uncertain response.", + readOnly: false, + confirmDescription: true, + flags: [], + bindings: [ + { + location: "path", + name: "ref", + source: "target", + }, + ], + }, { command: ["warehouse", "replication", "resync"], operationId: "v2-resync-warehouse-replication", @@ -506,7 +524,7 @@ export const apiCommands = [ definition: "v2GetWarehouseStatus", summary: "Get consolidated Warehouse status and capabilities", description: - "Returns provisioning, configured compute, replication, cleanup lifecycle and supported capabilities, including when individual dependencies are unavailable. Enabled Warehouse state is independent of the selected table count. Readiness is inferred from configuration and replication; query connectivity is not checked. Does not inspect the FDW. Observation timestamps are retrieval times, separate from table sync lag, pipeline apply lag and feedback age. Read access remains available without a replication entitlement; mutation endpoints enforce their own entitlements and permissions.", + "Returns provisioning, configured compute, replication, cleanup lifecycle and supported capabilities, including when individual dependencies are unavailable. Enabled Warehouse state is independent of the selected table count. Readiness is inferred from configuration and replication; query connectivity is not checked. Does not inspect the FDW. Observation timestamps are retrieval times, separate from table sync lag, pipeline apply lag and feedback age. Read access remains available without a replication entitlement; mutation endpoints enforce their own entitlements and permissions. Runtime diagnostics classify current failures. Table errors and progress are explicitly current, last-known or unavailable; they do not establish completion of a particular restart or resync. Capabilities describe Management API operations: workload_metrics includes query-stats and capacity; query_explain does not describe SQL EXPLAIN through the Warehouse connection.", readOnly: true, flags: [], bindings: [ @@ -580,13 +598,36 @@ export const apiCommands = [ "Updates saved sorting and partitioning rules for one source table object identifier (OID). Provide sort_by or partition_by; empty and reset-only patches are rejected. Omitted settings are preserved. Null makes a setting unmanaged. An empty partition list clears partitioning, and the none sort selector clears sorting. The backend validates the source schema and preserves other tables. When the layout changes, an active pipeline is restarted. A stopped pipeline stays stopped. reset_table defaults to false, preserving historical files and replication progress. When the layout changes, --reset-table resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never restarts the pipeline or resets the table. Acceptance and application_status report orchestration. Run warehouse tables layout get to compare the desired and observed rules. Run warehouse tables get to check table replication status. These reads do not establish completion of this specific update. There is no revision, idempotency, resolved preview, or durable operation contract. A failed update can leave partial effects, including a completed reset. Inspect the saved layout, pipeline, and table state before retrying.", readOnly: false, confirmDescription: true, + examples: [ + { + command: + 'supabase warehouse tables layout update --partition-by \'[{"column":"event_at","transform":{"kind":"day"}}]\' --sort-by \'{"kind":"columns","columns":[{"name":"tenant_id","direction":"asc"},{"name":"event_at","direction":"desc","nulls":"last"}]}\'', + description: + "Partition new files by event day and sort within files; preserve historical files.", + }, + { + command: + 'supabase warehouse tables layout update --partition-by \'[{"column":"tenant_id","transform":{"kind":"bucket","count":8}}]\' --dry-run', + description: "Preview eight hash buckets locally without changing the Warehouse.", + }, + { + command: + "supabase warehouse tables layout update --partition-by '[]' --sort-by '{\"kind\":\"none\"}'", + description: "Clear partitioning and sorting for future writes.", + }, + { + command: + "supabase warehouse tables layout update --partition-by 'null' --sort-by 'null'", + description: "Stop managing both settings; omitted flags preserve their saved values.", + }, + ], body: { contentType: "application/json", type: "warehouse_table_layout", }, argument: { name: "table-id", - description: "Source Postgres table OID from the Warehouse tables list.", + description: "Source PostgreSQL table OID, as returned by the Warehouse tables list.", }, flags: [ { @@ -595,7 +636,7 @@ export const apiCommands = [ repeatable: false, required: false, description: - "Omit to preserve the saved partitioning. Null makes partitioning unmanaged. An empty list explicitly clears partitioning. Otherwise, supply all ordered partition keys.", + 'Omit to preserve the saved partitioning. Null makes partitioning unmanaged. An empty list explicitly clears partitioning. Otherwise, supply all ordered partition keys. Day example: `[{"column":"event_at","transform":{"kind":"day"}}]`. Bucket example: `[{"column":"tenant_id","transform":{"kind":"bucket","count":8}}]`. Use `[]` to clear or `null` to stop managing partitioning.', }, { name: "reset-table", @@ -603,7 +644,7 @@ export const apiCommands = [ repeatable: false, required: false, description: - "Defaults to false, preserving historical files and replication progress. When the layout changes, --reset-table resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", + "Defaults to false, preserving historical files and replication progress. When the layout changes, true resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", }, { name: "sort-by", @@ -611,7 +652,7 @@ export const apiCommands = [ repeatable: false, required: false, description: - "Omit to preserve the saved sorting. Null makes sorting unmanaged. The none selector explicitly clears sorting. Otherwise, supply the complete sort selector.", + 'Omit to preserve the saved sorting. Null makes sorting unmanaged. The none selector explicitly clears sorting. Otherwise, supply the complete sort selector. Example: `{"kind":"columns","columns":[{"name":"tenant_id","direction":"asc"},{"name":"event_at","direction":"desc","nulls":"last"}]}`. Sort by the primary key with `{"kind":"primary_key"}` or clear sorting with `{"kind":"none"}`.', }, ], bindings: [ diff --git a/apps/cli/src/commands/api/runtime.ts b/apps/cli/src/commands/api/runtime.ts index 31e22f348d..4a8f78e457 100644 --- a/apps/cli/src/commands/api/runtime.ts +++ b/apps/cli/src/commands/api/runtime.ts @@ -326,7 +326,10 @@ const leafOf = (entry: ApiCommandEntry) => { return Command.make(verb, config).pipe( Command.withDescription(entry.description ?? entry.summary), Command.withShortDescription(`${entry.summary} (experimental)`), - Command.withExamples([{ command: exampleFor(entry), description: entry.summary }]), + Command.withExamples([ + { command: exampleFor(entry), description: entry.summary }, + ...(entry.examples ?? []), + ]), withPermissions(permissionsOf(entry, resolved)), Command.withHandler((flags) => { const { api: _generated, argument: _argument, ...recorded } = flags; diff --git a/packages/api/scripts/openapi-overrides.json b/packages/api/scripts/openapi-overrides.json index a7329da8a0..1a4df091e1 100644 --- a/packages/api/scripts/openapi-overrides.json +++ b/packages/api/scripts/openapi-overrides.json @@ -158,7 +158,7 @@ "path": "/paths/~1v2~1projects~1{ref}~1warehouse~1status", "value": { "get": { - "description": "Returns provisioning, configured compute, replication, cleanup lifecycle and supported capabilities, including when individual dependencies are unavailable. Enabled Warehouse state is independent of the selected table count. Readiness is inferred from configuration and replication; query connectivity is not checked. Does not inspect the FDW. Observation timestamps are retrieval times, separate from table sync lag, pipeline apply lag and feedback age. Read access remains available without a replication entitlement; mutation endpoints enforce their own entitlements and permissions.\n\nThis endpoint is currently in its **Alpha** stage.", + "description": "Returns provisioning, configured compute, replication, cleanup lifecycle and supported capabilities, including when individual dependencies are unavailable. Enabled Warehouse state is independent of the selected table count. Readiness is inferred from configuration and replication; query connectivity is not checked. Does not inspect the FDW. Observation timestamps are retrieval times, separate from table sync lag, pipeline apply lag and feedback age. Read access remains available without a replication entitlement; mutation endpoints enforce their own entitlements and permissions. Runtime diagnostics classify current failures. Table errors and progress are explicitly current, last-known or unavailable; they do not establish completion of a particular restart or resync. Capabilities describe Management API operations: workload_metrics includes query-stats and capacity; query_explain does not describe SQL EXPLAIN through the Warehouse connection.\n\nThis endpoint is currently in its **Alpha** stage.", "operationId": "v2-get-warehouse-status", "parameters": [ { @@ -272,6 +272,7 @@ "type": "boolean" }, "query_explain": { + "description": "Whether the Management API supports a query-explain operation. SQL EXPLAIN through the Warehouse connection is independent of this flag.", "type": "boolean" }, "replication_add": { @@ -280,6 +281,9 @@ "replication_remove": { "type": "boolean" }, + "replication_restart": { + "type": "boolean" + }, "table_layout_read": { "type": "boolean" }, @@ -290,6 +294,7 @@ "type": "boolean" }, "workload_metrics": { + "description": "Query statistics and capacity inspection are supported by the Management API. Metric availability is reported separately.", "type": "boolean" } }, @@ -298,6 +303,7 @@ "query_explain", "replication_add", "replication_remove", + "replication_restart", "table_layout_read", "table_layout_update", "table_resync", @@ -387,6 +393,35 @@ "pipeline": { "nullable": true, "properties": { + "diagnostic": { + "description": "Safe classification of the current runtime failure. Does not include worker logs or establish its underlying cause.", + "nullable": true, + "properties": { + "code": { + "enum": [ + "configuration_error", + "crash_loop", + "image_unavailable", + "out_of_memory", + "process_exited", + "runtime_failed", + "startup_failed" + ], + "type": "string" + }, + "exit_code": { + "maximum": 9007199254740991, + "minimum": -9007199254740991, + "nullable": true, + "type": "integer" + }, + "message": { + "type": "string" + } + }, + "required": ["code", "exit_code", "message"], + "type": "object" + }, "id": { "minLength": 1, "type": "string" @@ -423,7 +458,7 @@ "type": "string" } }, - "required": ["id", "observed_at", "status", "unavailable_reason"], + "required": ["diagnostic", "id", "observed_at", "status", "unavailable_reason"], "type": "object" }, "project_ref": { @@ -537,6 +572,57 @@ "items": { "items": { "properties": { + "error": { + "nullable": true, + "properties": { + "reason": { + "type": "string" + }, + "retry_policy": { + "oneOf": [ + { + "properties": { + "policy": { + "enum": ["no_retry"], + "type": "string" + } + }, + "required": ["policy"], + "type": "object" + }, + { + "properties": { + "policy": { + "enum": ["manual_retry"], + "type": "string" + } + }, + "required": ["policy"], + "type": "object" + }, + { + "properties": { + "next_retry": { + "type": "string" + }, + "policy": { + "enum": ["timed_retry"], + "type": "string" + } + }, + "required": ["next_retry", "policy"], + "type": "object" + } + ] + }, + "solution": { + "nullable": true, + "type": "string" + } + }, + "required": ["reason", "retry_policy", "solution"], + "type": "object" + }, "id": { "exclusiveMinimum": true, "maximum": 9007199254740991, @@ -561,6 +647,10 @@ "schema": { "type": "string" }, + "state_observation": { + "enum": ["current", "last_known", "unavailable"], + "type": "string" + }, "sync_lag": { "description": "Postgres replication feedback. Null means Postgres reported no value; lag times also become null shortly after a caught-up slot sees no new WAL, while flush_lag_bytes, the WAL not yet confirmed flushed, reads 0. Feedback age measures time since the last response and does not establish how current query results are.", "nullable": true, @@ -613,7 +703,15 @@ "type": "object" } }, - "required": ["id", "name", "replication_state", "schema", "sync_lag"], + "required": [ + "error", + "id", + "name", + "replication_state", + "schema", + "state_observation", + "sync_lag" + ], "type": "object" }, "type": "array" @@ -625,6 +723,62 @@ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$", "type": "string" }, + "progress": { + "description": "Observed states of the selected tables, not completion or percentage of a specific mutation. Last-known states may predate a restart or resync. Null when the selection is unavailable.", + "nullable": true, + "properties": { + "copied_table": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "copying_table": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "error": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "following_wal": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "observation": { + "enum": ["current", "last_known", "unavailable"], + "type": "string" + }, + "queued": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "selected": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "unknown": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + } + }, + "required": [ + "copied_table", + "copying_table", + "error", + "following_wal", + "observation", + "queued", + "selected", + "unknown" + ], + "type": "object" + }, "status": { "enum": ["available", "not_provisioned", "unavailable"], "type": "string" @@ -642,7 +796,7 @@ "type": "string" } }, - "required": ["items", "observed_at", "status", "unavailable_reason"], + "required": ["items", "observed_at", "progress", "status", "unavailable_reason"], "type": "object" } }, @@ -1922,7 +2076,7 @@ } }, { - "description": "Source Postgres table OID from the Warehouse tables list.", + "description": "Source PostgreSQL table OID, as returned by the Warehouse tables list.", "in": "path", "name": "table_id", "required": true, @@ -2255,14 +2409,175 @@ "additionalProperties": false, "properties": { "partition_by": { - "$ref": "#/components/schemas/V2WarehouseTableLayoutPartitionBy" + "description": "Omit to preserve the saved partitioning. Null makes partitioning unmanaged. An empty list explicitly clears partitioning. Otherwise, supply all ordered partition keys. Day example: `[{\"column\":\"event_at\",\"transform\":{\"kind\":\"day\"}}]`. Bucket example: `[{\"column\":\"tenant_id\",\"transform\":{\"kind\":\"bucket\",\"count\":8}}]`. Use `[]` to clear or `null` to stop managing partitioning.", + "items": { + "additionalProperties": false, + "properties": { + "column": { + "description": "Source column name.", + "minLength": 1, + "type": "string" + }, + "transform": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["identity"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["year"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["month"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["day"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["hour"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "count": { + "description": "Number of hash buckets.", + "exclusiveMinimum": true, + "maximum": 2147483647, + "minimum": 0, + "type": "integer" + }, + "kind": { + "enum": ["bucket"], + "type": "string" + } + }, + "required": ["count", "kind"], + "type": "object" + } + ] + } + }, + "required": ["column", "transform"], + "type": "object" + }, + "nullable": true, + "type": "array" }, "reset_table": { - "description": "Defaults to false, preserving historical files and replication progress. When the layout changes, --reset-table resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", + "description": "Defaults to false, preserving historical files and replication progress. When the layout changes, true resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", "type": "boolean" }, "sort_by": { - "$ref": "#/components/schemas/V2WarehouseTableLayoutSortBy" + "anyOf": [ + { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["none"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["primary_key"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "columns": { + "items": { + "additionalProperties": false, + "properties": { + "direction": { + "enum": ["asc", "desc"], + "type": "string" + }, + "name": { + "description": "Source column name.", + "minLength": 1, + "type": "string" + }, + "nulls": { + "description": "Null placement. Null uses DuckLake's default placement.", + "enum": ["first", "last", null], + "nullable": true, + "type": "string" + } + }, + "required": ["direction", "name"], + "type": "object" + }, + "minItems": 1, + "type": "array" + }, + "kind": { + "enum": ["columns"], + "type": "string" + } + }, + "required": ["columns", "kind"], + "type": "object" + } + ] + }, + { + "enum": [null], + "nullable": true, + "type": "object" + } + ], + "description": "Omit to preserve the saved sorting. Null makes sorting unmanaged. The none selector explicitly clears sorting. Otherwise, supply the complete sort selector. Example: `{\"kind\":\"columns\",\"columns\":[{\"name\":\"tenant_id\",\"direction\":\"asc\"},{\"name\":\"event_at\",\"direction\":\"desc\",\"nulls\":\"last\"}]}`. Sort by the primary key with `{\"kind\":\"primary_key\"}` or clear sorting with `{\"kind\":\"none\"}`." } }, "required": ["sort_by"], @@ -2272,14 +2587,175 @@ "additionalProperties": false, "properties": { "partition_by": { - "$ref": "#/components/schemas/V2WarehouseTableLayoutPartitionBy" + "description": "Omit to preserve the saved partitioning. Null makes partitioning unmanaged. An empty list explicitly clears partitioning. Otherwise, supply all ordered partition keys. Day example: `[{\"column\":\"event_at\",\"transform\":{\"kind\":\"day\"}}]`. Bucket example: `[{\"column\":\"tenant_id\",\"transform\":{\"kind\":\"bucket\",\"count\":8}}]`. Use `[]` to clear or `null` to stop managing partitioning.", + "items": { + "additionalProperties": false, + "properties": { + "column": { + "description": "Source column name.", + "minLength": 1, + "type": "string" + }, + "transform": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["identity"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["year"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["month"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["day"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["hour"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "count": { + "description": "Number of hash buckets.", + "exclusiveMinimum": true, + "maximum": 2147483647, + "minimum": 0, + "type": "integer" + }, + "kind": { + "enum": ["bucket"], + "type": "string" + } + }, + "required": ["count", "kind"], + "type": "object" + } + ] + } + }, + "required": ["column", "transform"], + "type": "object" + }, + "nullable": true, + "type": "array" }, "reset_table": { - "description": "Defaults to false, preserving historical files and replication progress. When the layout changes, --reset-table resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", + "description": "Defaults to false, preserving historical files and replication progress. When the layout changes, true resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", "type": "boolean" }, "sort_by": { - "$ref": "#/components/schemas/V2WarehouseTableLayoutSortBy" + "anyOf": [ + { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["none"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["primary_key"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "columns": { + "items": { + "additionalProperties": false, + "properties": { + "direction": { + "enum": ["asc", "desc"], + "type": "string" + }, + "name": { + "description": "Source column name.", + "minLength": 1, + "type": "string" + }, + "nulls": { + "description": "Null placement. Null uses DuckLake's default placement.", + "enum": ["first", "last", null], + "nullable": true, + "type": "string" + } + }, + "required": ["direction", "name"], + "type": "object" + }, + "minItems": 1, + "type": "array" + }, + "kind": { + "enum": ["columns"], + "type": "string" + } + }, + "required": ["columns", "kind"], + "type": "object" + } + ] + }, + { + "enum": [null], + "nullable": true, + "type": "object" + } + ], + "description": "Omit to preserve the saved sorting. Null makes sorting unmanaged. The none selector explicitly clears sorting. Otherwise, supply the complete sort selector. Example: `{\"kind\":\"columns\",\"columns\":[{\"name\":\"tenant_id\",\"direction\":\"asc\"},{\"name\":\"event_at\",\"direction\":\"desc\",\"nulls\":\"last\"}]}`. Sort by the primary key with `{\"kind\":\"primary_key\"}` or clear sorting with `{\"kind\":\"none\"}`." } }, "required": ["partition_by"], @@ -4043,5 +4519,189 @@ } }, "$comment": "The Warehouse replication resync contract is not yet in the deployed Management API specification." + }, + { + "op": "add", + "path": "/paths/~1v2~1projects~1{ref}~1warehouse~1replication~1restart", + "value": { + "post": { + "description": "Starts a stopped managed pipeline or restarts a starting, started or failed pipeline, preserving the selected tables and saved layouts. Restart interrupts replication; in-progress initial copies may restart from scratch. If lost-slot recreation is configured, startup can rebuild destination tables. The response confirms acceptance only. Inspect warehouse status for runtime diagnostics and observed table progress; these observations do not identify completion of this request. Inspect state before retrying an uncertain response.\n\nThis endpoint is currently in its **Alpha** stage.", + "operationId": "v2-restart-warehouse-replication", + "parameters": [ + { + "description": "Project ref", + "in": "path", + "name": "ref", + "required": true, + "schema": { + "example": "abcdefghijklmnopqrst", + "maxLength": 20, + "minLength": 20, + "pattern": "^[a-z]+$", + "type": "string" + } + } + ], + "responses": { + "202": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/V2WarehouseRestartResponse_Output" + } + } + }, + "description": "" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Unauthorized" + }, + "402": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "This feature requires the Pro, Team, or Enterprise organization plan." + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Forbidden action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Managed Warehouse pipeline not found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Warehouse lifecycle or runtime state does not permit restart" + }, + "429": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Rate limit exceeded" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Restart outcome uncertain; inspect runtime and table state before retrying" + } + }, + "security": [ + { + "bearer": [] + } + ], + "summary": "Start or restart Warehouse replication", + "tags": ["Projects Warehouse"], + "x-allowed-plans": ["Enterprise", "Pro", "Team"], + "x-badges": [ + { + "name": "OAuth scope: database:write", + "position": "after" + }, + { + "name": "Only available on Pro, Team, Enterprise", + "position": "before" + }, + { + "name": "Alpha", + "position": "before" + } + ], + "x-endpoint-owners": ["pipelines"], + "x-fga-permissions": [["database_write", "project_admin_write"]], + "x-oauth-scope": "database:write", + "x-operation": { + "group": "warehouse.replication", + "method": "restart" + }, + "x-scalar-stability": "experimental" + } + }, + "$comment": "Warehouse diagnostics and restart contract pending deployment." + }, + { + "op": "add", + "path": "/components/schemas/V2WarehouseRestartResponse_Output", + "value": { + "properties": { + "data": { + "properties": { + "attributes": { + "properties": { + "action": { + "enum": ["restart", "start"], + "type": "string" + }, + "application_status": { + "description": "The runtime request was accepted. This does not establish resumed replication or completed initial copies.", + "enum": ["accepted"], + "type": "string" + }, + "pipeline_id": { + "type": "string" + }, + "pipeline_status_before": { + "type": "string" + } + }, + "required": ["action", "application_status", "pipeline_id", "pipeline_status_before"], + "type": "object" + }, + "id": { + "type": "string" + }, + "type": { + "description": "Resource type.", + "enum": ["warehouse_replication_restart"], + "type": "string" + } + }, + "required": ["attributes", "id", "type"], + "type": "object" + } + }, + "required": ["data"], + "type": "object" + }, + "$comment": "Warehouse diagnostics and restart contract pending deployment." } ] diff --git a/packages/api/src/generated/contracts.ts b/packages/api/src/generated/contracts.ts index f89d73e3d8..2ac4f09ea4 100644 --- a/packages/api/src/generated/contracts.ts +++ b/packages/api/src/generated/contracts.ts @@ -357,68 +357,6 @@ export const ThirdPartyAuth_Output = Schema.Struct({ updated_at: Schema.String, resolved_at: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])), }).annotate({ identifier: "ThirdPartyAuth_Output" }); -export const V2WarehouseTableLayoutPartitionBy = Schema.Union([ - Schema.Array( - Schema.Struct({ - column: Schema.String.annotate({ description: "Source column name." }).check( - Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" }), - ), - transform: Schema.Union( - [ - Schema.Struct({ kind: Schema.Literal("identity") }), - Schema.Struct({ kind: Schema.Literal("year") }), - Schema.Struct({ kind: Schema.Literal("month") }), - Schema.Struct({ kind: Schema.Literal("day") }), - Schema.Struct({ kind: Schema.Literal("hour") }), - Schema.Struct({ - count: Schema.Number.annotate({ description: "Number of hash buckets." }) - .check(Schema.isInt().annotate({ expected: "an integer" })) - .check( - Schema.isLessThanOrEqualTo(2147483647).annotate({ - expected: "a value less than or equal to 2147483647", - }), - ) - .check(Schema.isGreaterThan(0).annotate({ expected: "a value greater than 0" })), - kind: Schema.Literal("bucket"), - }), - ], - { mode: "oneOf" }, - ), - }), - ).annotate({ - description: - "Omit to preserve the saved partitioning. Null makes partitioning unmanaged. An empty list explicitly clears partitioning. Otherwise, supply all ordered partition keys.", - }), - Schema.Null, -]).annotate({ identifier: "V2WarehouseTableLayoutPartitionBy" }); -export const V2WarehouseTableLayoutSortBy = Schema.Union( - [ - Schema.Struct({ kind: Schema.Literal("none") }), - Schema.Struct({ kind: Schema.Literal("primary_key") }), - Schema.Struct({ - columns: Schema.Array( - Schema.Struct({ - direction: Schema.Literals(["asc", "desc"]), - name: Schema.String.annotate({ description: "Source column name." }).check( - Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" }), - ), - nulls: Schema.optionalKey( - Schema.Union([Schema.Literals(["first", "last"]), Schema.Null]).annotate({ - description: "Null placement. Null uses DuckLake's default placement.", - }), - ), - }), - ).check(Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" })), - kind: Schema.Literal("columns"), - }), - Schema.Null, - ], - { mode: "oneOf" }, -).annotate({ - description: - "Omit to preserve the saved sorting. Null makes sorting unmanaged. The none selector explicitly clears sorting. Otherwise, supply the complete sort selector.", - identifier: "V2WarehouseTableLayoutSortBy", -}); // recursive definitions export type JsonValue_Output = | string @@ -15313,13 +15251,20 @@ export const V2GetWarehouseStatusOutput = Schema.Struct({ attributes: Schema.Struct({ capabilities: Schema.Struct({ context: Schema.Boolean, - query_explain: Schema.Boolean, + query_explain: Schema.Boolean.annotate({ + description: + "Whether the Management API supports a query-explain operation. SQL EXPLAIN through the Warehouse connection is independent of this flag.", + }), replication_add: Schema.Boolean, replication_remove: Schema.Boolean, table_layout_read: Schema.Boolean, table_layout_update: Schema.Boolean, table_resync: Schema.Boolean, - workload_metrics: Schema.Boolean, + workload_metrics: Schema.Boolean.annotate({ + description: + "Query statistics and capacity inspection are supported by the Management API. Metric availability is reported separately.", + }), + replication_restart: Schema.Boolean, }).annotate({ description: "Complete operations supported by this API, not caller authorization. Each operation still requires its feature, entitlement and project permission checks.", @@ -15423,6 +15368,41 @@ export const V2GetWarehouseStatusOutput = Schema.Struct({ ]), OpenString, ]), + diagnostic: Schema.Union([ + Schema.Struct({ + code: Schema.Union([ + Schema.Literals([ + "configuration_error", + "crash_loop", + "image_unavailable", + "out_of_memory", + "process_exited", + "runtime_failed", + "startup_failed", + ]), + OpenString, + ]), + exit_code: Schema.Union([ + Schema.Number.check(Schema.isInt().annotate({ expected: "an integer" })) + .check( + Schema.isGreaterThanOrEqualTo(-9007199254740991).annotate({ + expected: "a value greater than or equal to -9007199254740991", + }), + ) + .check( + Schema.isLessThanOrEqualTo(9007199254740991).annotate({ + expected: "a value less than or equal to 9007199254740991", + }), + ), + Schema.Null, + ]), + message: Schema.String, + }).annotate({ + description: + "Safe classification of the current runtime failure. Does not include worker logs or establish its underlying cause.", + }), + Schema.Null, + ]), }), Schema.Null, ]), @@ -15636,6 +15616,28 @@ export const V2GetWarehouseStatusOutput = Schema.Struct({ }), Schema.Null, ]), + error: Schema.Union([ + Schema.Struct({ + reason: Schema.String, + retry_policy: Schema.Union( + [ + Schema.Struct({ policy: Schema.Literal("no_retry") }), + Schema.Struct({ policy: Schema.Literal("manual_retry") }), + Schema.Struct({ + next_retry: Schema.String, + policy: Schema.Literal("timed_retry"), + }), + ], + { mode: "oneOf" }, + ), + solution: Schema.Union([Schema.String, Schema.Null]), + }), + Schema.Null, + ]), + state_observation: Schema.Union([ + Schema.Literals(["current", "last_known", "unavailable"]), + OpenString, + ]), }), ), observed_at: Schema.Union([ @@ -15663,6 +15665,95 @@ export const V2GetWarehouseStatusOutput = Schema.Struct({ ]), OpenString, ]), + progress: Schema.Union([ + Schema.Struct({ + copied_table: Schema.Number.check(Schema.isInt().annotate({ expected: "an integer" })) + .check( + Schema.isGreaterThanOrEqualTo(0).annotate({ + expected: "a value greater than or equal to 0", + }), + ) + .check( + Schema.isLessThanOrEqualTo(9007199254740991).annotate({ + expected: "a value less than or equal to 9007199254740991", + }), + ), + copying_table: Schema.Number.check(Schema.isInt().annotate({ expected: "an integer" })) + .check( + Schema.isGreaterThanOrEqualTo(0).annotate({ + expected: "a value greater than or equal to 0", + }), + ) + .check( + Schema.isLessThanOrEqualTo(9007199254740991).annotate({ + expected: "a value less than or equal to 9007199254740991", + }), + ), + error: Schema.Number.check(Schema.isInt().annotate({ expected: "an integer" })) + .check( + Schema.isGreaterThanOrEqualTo(0).annotate({ + expected: "a value greater than or equal to 0", + }), + ) + .check( + Schema.isLessThanOrEqualTo(9007199254740991).annotate({ + expected: "a value less than or equal to 9007199254740991", + }), + ), + following_wal: Schema.Number.check(Schema.isInt().annotate({ expected: "an integer" })) + .check( + Schema.isGreaterThanOrEqualTo(0).annotate({ + expected: "a value greater than or equal to 0", + }), + ) + .check( + Schema.isLessThanOrEqualTo(9007199254740991).annotate({ + expected: "a value less than or equal to 9007199254740991", + }), + ), + observation: Schema.Union([ + Schema.Literals(["current", "last_known", "unavailable"]), + OpenString, + ]), + queued: Schema.Number.check(Schema.isInt().annotate({ expected: "an integer" })) + .check( + Schema.isGreaterThanOrEqualTo(0).annotate({ + expected: "a value greater than or equal to 0", + }), + ) + .check( + Schema.isLessThanOrEqualTo(9007199254740991).annotate({ + expected: "a value less than or equal to 9007199254740991", + }), + ), + selected: Schema.Number.check(Schema.isInt().annotate({ expected: "an integer" })) + .check( + Schema.isGreaterThanOrEqualTo(0).annotate({ + expected: "a value greater than or equal to 0", + }), + ) + .check( + Schema.isLessThanOrEqualTo(9007199254740991).annotate({ + expected: "a value less than or equal to 9007199254740991", + }), + ), + unknown: Schema.Number.check(Schema.isInt().annotate({ expected: "an integer" })) + .check( + Schema.isGreaterThanOrEqualTo(0).annotate({ + expected: "a value greater than or equal to 0", + }), + ) + .check( + Schema.isLessThanOrEqualTo(9007199254740991).annotate({ + expected: "a value less than or equal to 9007199254740991", + }), + ), + }).annotate({ + description: + "Observed states of the selected tables, not completion or percentage of a specific mutation. Last-known states may predate a restart or resync. Null when the selection is unavailable.", + }), + Schema.Null, + ]), }), }), id: Schema.String.annotate({ description: "Project ref" }) @@ -20254,6 +20345,36 @@ export const V2RemoveWarehouseReplicationOutput = Schema.Struct({ }), }), }); +export const V2RestartWarehouseReplicationInput = Schema.Struct({ + ref: Schema.String.check( + Schema.isMinCodePoints(20).annotate({ expected: "a string with at least 20 code points" }), + ) + .check( + Schema.isMaxCodePoints(20).annotate({ expected: "a string with at most 20 code points" }), + ) + .check( + Schema.isPattern(new RegExp("^[a-z]+$", "u")).annotate({ + expected: "a string matching the RegExp ^[a-z]+$", + }), + ), +}); +export const V2RestartWarehouseReplicationOutput = Schema.Struct({ + data: Schema.Struct({ + attributes: Schema.Struct({ + action: Schema.Union([Schema.Literals(["restart", "start"]), OpenString]), + application_status: Schema.Literal("accepted").annotate({ + description: + "The runtime request was accepted. This does not establish resumed replication or completed initial copies.", + }), + pipeline_id: Schema.String, + pipeline_status_before: Schema.String, + }), + id: Schema.String, + type: Schema.Literal("warehouse_replication_restart").annotate({ + description: "Resource type.", + }), + }), +}); export const V2ResyncWarehouseReplicationInput = Schema.Struct({ ref: Schema.String.check( Schema.isMinCodePoints(20).annotate({ expected: "a string with at least 20 code points" }), @@ -21194,24 +21315,168 @@ export const V2UpdateWarehouseTableLayoutInput = Schema.Struct({ data: Schema.Struct({ attributes: Schema.Union([ Schema.Struct({ - partition_by: Schema.optionalKey(V2WarehouseTableLayoutPartitionBy), + partition_by: Schema.optionalKey( + Schema.Union([ + Schema.Array( + Schema.Struct({ + column: Schema.String.annotate({ description: "Source column name." }).check( + Schema.isMinLength(1).annotate({ + expected: "a value with a length of at least 1", + }), + ), + transform: Schema.Union( + [ + Schema.Struct({ kind: Schema.Literal("identity") }), + Schema.Struct({ kind: Schema.Literal("year") }), + Schema.Struct({ kind: Schema.Literal("month") }), + Schema.Struct({ kind: Schema.Literal("day") }), + Schema.Struct({ kind: Schema.Literal("hour") }), + Schema.Struct({ + count: Schema.Number.annotate({ description: "Number of hash buckets." }) + .check(Schema.isInt().annotate({ expected: "an integer" })) + .check( + Schema.isLessThanOrEqualTo(2147483647).annotate({ + expected: "a value less than or equal to 2147483647", + }), + ) + .check( + Schema.isGreaterThan(0).annotate({ expected: "a value greater than 0" }), + ), + kind: Schema.Literal("bucket"), + }), + ], + { mode: "oneOf" }, + ), + }), + ).annotate({ + description: + 'Omit to preserve the saved partitioning. Null makes partitioning unmanaged. An empty list explicitly clears partitioning. Otherwise, supply all ordered partition keys. Day example: `[{"column":"event_at","transform":{"kind":"day"}}]`. Bucket example: `[{"column":"tenant_id","transform":{"kind":"bucket","count":8}}]`. Use `[]` to clear or `null` to stop managing partitioning.', + }), + Schema.Null, + ]), + ), reset_table: Schema.optionalKey( Schema.Boolean.annotate({ description: - "Defaults to false, preserving historical files and replication progress. When the layout changes, --reset-table resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", + "Defaults to false, preserving historical files and replication progress. When the layout changes, true resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", }), ), - sort_by: V2WarehouseTableLayoutSortBy, + sort_by: Schema.Union([ + Schema.Union( + [ + Schema.Struct({ kind: Schema.Literal("none") }), + Schema.Struct({ kind: Schema.Literal("primary_key") }), + Schema.Struct({ + columns: Schema.Array( + Schema.Struct({ + direction: Schema.Literals(["asc", "desc"]), + name: Schema.String.annotate({ description: "Source column name." }).check( + Schema.isMinLength(1).annotate({ + expected: "a value with a length of at least 1", + }), + ), + nulls: Schema.optionalKey( + Schema.Union([Schema.Literals(["first", "last"]), Schema.Null]).annotate({ + description: "Null placement. Null uses DuckLake's default placement.", + }), + ), + }), + ).check( + Schema.isMinLength(1).annotate({ + expected: "a value with a length of at least 1", + }), + ), + kind: Schema.Literal("columns"), + }), + ], + { mode: "oneOf" }, + ), + Schema.Null, + ]).annotate({ + description: + 'Omit to preserve the saved sorting. Null makes sorting unmanaged. The none selector explicitly clears sorting. Otherwise, supply the complete sort selector. Example: `{"kind":"columns","columns":[{"name":"tenant_id","direction":"asc"},{"name":"event_at","direction":"desc","nulls":"last"}]}`. Sort by the primary key with `{"kind":"primary_key"}` or clear sorting with `{"kind":"none"}`.', + }), }), Schema.Struct({ - partition_by: V2WarehouseTableLayoutPartitionBy, + partition_by: Schema.Union([ + Schema.Array( + Schema.Struct({ + column: Schema.String.annotate({ description: "Source column name." }).check( + Schema.isMinLength(1).annotate({ expected: "a value with a length of at least 1" }), + ), + transform: Schema.Union( + [ + Schema.Struct({ kind: Schema.Literal("identity") }), + Schema.Struct({ kind: Schema.Literal("year") }), + Schema.Struct({ kind: Schema.Literal("month") }), + Schema.Struct({ kind: Schema.Literal("day") }), + Schema.Struct({ kind: Schema.Literal("hour") }), + Schema.Struct({ + count: Schema.Number.annotate({ description: "Number of hash buckets." }) + .check(Schema.isInt().annotate({ expected: "an integer" })) + .check( + Schema.isLessThanOrEqualTo(2147483647).annotate({ + expected: "a value less than or equal to 2147483647", + }), + ) + .check( + Schema.isGreaterThan(0).annotate({ expected: "a value greater than 0" }), + ), + kind: Schema.Literal("bucket"), + }), + ], + { mode: "oneOf" }, + ), + }), + ).annotate({ + description: + 'Omit to preserve the saved partitioning. Null makes partitioning unmanaged. An empty list explicitly clears partitioning. Otherwise, supply all ordered partition keys. Day example: `[{"column":"event_at","transform":{"kind":"day"}}]`. Bucket example: `[{"column":"tenant_id","transform":{"kind":"bucket","count":8}}]`. Use `[]` to clear or `null` to stop managing partitioning.', + }), + Schema.Null, + ]), reset_table: Schema.optionalKey( Schema.Boolean.annotate({ description: - "Defaults to false, preserving historical files and replication progress. When the layout changes, --reset-table resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", + "Defaults to false, preserving historical files and replication progress. When the layout changes, true resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", + }), + ), + sort_by: Schema.optionalKey( + Schema.Union([ + Schema.Union( + [ + Schema.Struct({ kind: Schema.Literal("none") }), + Schema.Struct({ kind: Schema.Literal("primary_key") }), + Schema.Struct({ + columns: Schema.Array( + Schema.Struct({ + direction: Schema.Literals(["asc", "desc"]), + name: Schema.String.annotate({ description: "Source column name." }).check( + Schema.isMinLength(1).annotate({ + expected: "a value with a length of at least 1", + }), + ), + nulls: Schema.optionalKey( + Schema.Union([Schema.Literals(["first", "last"]), Schema.Null]).annotate({ + description: "Null placement. Null uses DuckLake's default placement.", + }), + ), + }), + ).check( + Schema.isMinLength(1).annotate({ + expected: "a value with a length of at least 1", + }), + ), + kind: Schema.Literal("columns"), + }), + ], + { mode: "oneOf" }, + ), + Schema.Null, + ]).annotate({ + description: + 'Omit to preserve the saved sorting. Null makes sorting unmanaged. The none selector explicitly clears sorting. Otherwise, supply the complete sort selector. Example: `{"kind":"columns","columns":[{"name":"tenant_id","direction":"asc"},{"name":"event_at","direction":"desc","nulls":"last"}]}`. Sort by the primary key with `{"kind":"primary_key"}` or clear sorting with `{"kind":"none"}`.', }), ), - sort_by: Schema.optionalKey(V2WarehouseTableLayoutSortBy), }), ]), type: Schema.Literal("warehouse_table_layout").annotate({ description: "Resource type." }), @@ -21641,6 +21906,7 @@ export const openApiOperationIdMap = { "v2-projects-ref-webhooks-endpoints-post": "v2ProjectsRefWebhooksEndpointsPost", "v2-remove-organization-members": "v2RemoveOrganizationMembers", "v2-remove-warehouse-replication": "v2RemoveWarehouseReplication", + "v2-restart-warehouse-replication": "v2RestartWarehouseReplication", "v2-resync-warehouse-replication": "v2ResyncWarehouseReplication", "v2-run-project-advisors": "v2RunProjectAdvisors", "v2-transfer-a-project": "v2TransferAProject", @@ -24896,7 +25162,7 @@ export const operationDefinitions = { v2GetWarehouseStatus: { id: "v2GetWarehouseStatus", description: - "Returns provisioning, configured compute, replication, cleanup lifecycle and supported capabilities, including when individual dependencies are unavailable. Enabled Warehouse state is independent of the selected table count. Readiness is inferred from configuration and replication; query connectivity is not checked. Does not inspect the FDW. Observation timestamps are retrieval times, separate from table sync lag, pipeline apply lag and feedback age. Read access remains available without a replication entitlement; mutation endpoints enforce their own entitlements and permissions.\n\nThis endpoint is currently in its **Alpha** stage.", + "Returns provisioning, configured compute, replication, cleanup lifecycle and supported capabilities, including when individual dependencies are unavailable. Enabled Warehouse state is independent of the selected table count. Readiness is inferred from configuration and replication; query connectivity is not checked. Does not inspect the FDW. Observation timestamps are retrieval times, separate from table sync lag, pipeline apply lag and feedback age. Read access remains available without a replication entitlement; mutation endpoints enforce their own entitlements and permissions. Runtime diagnostics classify current failures. Table errors and progress are explicitly current, last-known or unavailable; they do not establish completion of a particular restart or resync. Capabilities describe Management API operations: workload_metrics includes query-stats and capacity; query_explain does not describe SQL EXPLAIN through the Warehouse connection.\n\nThis endpoint is currently in its **Alpha** stage.", method: "GET", path: "/v2/projects/{ref}/warehouse/status", pathParams: ["ref"], @@ -25398,6 +25664,20 @@ export const operationDefinitions = { inputSchema: V2RemoveWarehouseReplicationInput, outputSchema: V2RemoveWarehouseReplicationOutput, }, + v2RestartWarehouseReplication: { + id: "v2RestartWarehouseReplication", + description: + "Starts a stopped managed pipeline or restarts a starting, started or failed pipeline, preserving the selected tables and saved layouts. Restart interrupts replication; in-progress initial copies may restart from scratch. If lost-slot recreation is configured, startup can rebuild destination tables. The response confirms acceptance only. Inspect warehouse status for runtime diagnostics and observed table progress; these observations do not identify completion of this request. Inspect state before retrying an uncertain response.\n\nThis endpoint is currently in its **Alpha** stage.", + method: "POST", + path: "/v2/projects/{ref}/warehouse/replication/restart", + pathParams: ["ref"], + queryParams: [], + headerParams: [], + requestBody: { kind: "none" }, + response: { kind: "json" }, + inputSchema: V2RestartWarehouseReplicationInput, + outputSchema: V2RestartWarehouseReplicationOutput, + }, v2ResyncWarehouseReplication: { id: "v2ResyncWarehouseReplication", description: diff --git a/packages/api/src/generated/effect-client.ts b/packages/api/src/generated/effect-client.ts index 07abc05da8..c774514db3 100644 --- a/packages/api/src/generated/effect-client.ts +++ b/packages/api/src/generated/effect-client.ts @@ -3812,6 +3812,22 @@ export const versionedEffectOperations = { options, ); }), + restartWarehouseReplication: ( + input: typeof operationDefinitions.v2RestartWarehouseReplication.inputSchema.Type, + options?: SupabaseApiRequestOptions, + ): Effect.Effect< + typeof operationDefinitions.v2RestartWarehouseReplication.outputSchema.Type, + SupabaseApiError, + SupabaseApiClient + > => + Effect.gen(function* () { + const client = yield* SupabaseApiClient; + return yield* client.execute<"v2RestartWarehouseReplication">( + operationDefinitions.v2RestartWarehouseReplication, + input, + options, + ); + }), resyncWarehouseReplication: ( input: typeof operationDefinitions.v2ResyncWarehouseReplication.inputSchema.Type, options?: SupabaseApiRequestOptions, diff --git a/packages/api/src/generated/openapi.json b/packages/api/src/generated/openapi.json index 34311bf765..c5e3af9156 100644 --- a/packages/api/src/generated/openapi.json +++ b/packages/api/src/generated/openapi.json @@ -13542,7 +13542,7 @@ }, "/v2/projects/{ref}/warehouse/status": { "get": { - "description": "Returns provisioning, configured compute, replication, cleanup lifecycle and supported capabilities, including when individual dependencies are unavailable. Enabled Warehouse state is independent of the selected table count. Readiness is inferred from configuration and replication; query connectivity is not checked. Does not inspect the FDW. Observation timestamps are retrieval times, separate from table sync lag, pipeline apply lag and feedback age. Read access remains available without a replication entitlement; mutation endpoints enforce their own entitlements and permissions.\n\nThis endpoint is currently in its **Alpha** stage.", + "description": "Returns provisioning, configured compute, replication, cleanup lifecycle and supported capabilities, including when individual dependencies are unavailable. Enabled Warehouse state is independent of the selected table count. Readiness is inferred from configuration and replication; query connectivity is not checked. Does not inspect the FDW. Observation timestamps are retrieval times, separate from table sync lag, pipeline apply lag and feedback age. Read access remains available without a replication entitlement; mutation endpoints enforce their own entitlements and permissions. Runtime diagnostics classify current failures. Table errors and progress are explicitly current, last-known or unavailable; they do not establish completion of a particular restart or resync. Capabilities describe Management API operations: workload_metrics includes query-stats and capacity; query_explain does not describe SQL EXPLAIN through the Warehouse connection.\n\nThis endpoint is currently in its **Alpha** stage.", "operationId": "v2-get-warehouse-status", "parameters": [ { @@ -14101,7 +14101,7 @@ } }, { - "description": "Source Postgres table OID from the Warehouse tables list.", + "description": "Source PostgreSQL table OID, as returned by the Warehouse tables list.", "in": "path", "name": "table_id", "required": true, @@ -34448,6 +34448,139 @@ "summary": "Retry delivery", "description": "Retry delivering the same event again.\n\nAutomatic retries are not applicable to manual retries - if the delivery fails, there won't be any automatic retries attempted.\n\nThis endpoint is heavy rate-limited to allow for 10 request within 60 seconds." } + }, + "/v2/projects/{ref}/warehouse/replication/restart": { + "post": { + "description": "Starts a stopped managed pipeline or restarts a starting, started or failed pipeline, preserving the selected tables and saved layouts. Restart interrupts replication; in-progress initial copies may restart from scratch. If lost-slot recreation is configured, startup can rebuild destination tables. The response confirms acceptance only. Inspect warehouse status for runtime diagnostics and observed table progress; these observations do not identify completion of this request. Inspect state before retrying an uncertain response.\n\nThis endpoint is currently in its **Alpha** stage.", + "operationId": "v2-restart-warehouse-replication", + "parameters": [ + { + "description": "Project ref", + "in": "path", + "name": "ref", + "required": true, + "schema": { + "example": "abcdefghijklmnopqrst", + "maxLength": 20, + "minLength": 20, + "pattern": "^[a-z]+$", + "type": "string" + } + } + ], + "responses": { + "202": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/V2WarehouseRestartResponse_Output" + } + } + }, + "description": "" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Unauthorized" + }, + "402": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "This feature requires the Pro, Team, or Enterprise organization plan." + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Forbidden action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Managed Warehouse pipeline not found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Warehouse lifecycle or runtime state does not permit restart" + }, + "429": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Rate limit exceeded" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseBody" + } + } + }, + "description": "Restart outcome uncertain; inspect runtime and table state before retrying" + } + }, + "security": [ + { + "bearer": [] + } + ], + "summary": "Start or restart Warehouse replication", + "tags": ["Projects Warehouse"], + "x-allowed-plans": ["Enterprise", "Pro", "Team"], + "x-badges": [ + { + "name": "OAuth scope: database:write", + "position": "after" + }, + { + "name": "Only available on Pro, Team, Enterprise", + "position": "before" + }, + { + "name": "Alpha", + "position": "before" + } + ], + "x-endpoint-owners": ["pipelines"], + "x-fga-permissions": [["database_write", "project_admin_write"]], + "x-oauth-scope": "database:write", + "x-operation": { + "group": "warehouse.replication", + "method": "restart" + }, + "x-scalar-stability": "experimental" + } } }, "components": { @@ -46106,7 +46239,8 @@ "type": "boolean" }, "query_explain": { - "type": "boolean" + "type": "boolean", + "description": "Whether the Management API supports a query-explain operation. SQL EXPLAIN through the Warehouse connection is independent of this flag." }, "replication_add": { "type": "boolean" @@ -46124,6 +46258,10 @@ "type": "boolean" }, "workload_metrics": { + "type": "boolean", + "description": "Query statistics and capacity inspection are supported by the Management API. Metric availability is reported separately." + }, + "replication_restart": { "type": "boolean" } }, @@ -46132,6 +46270,7 @@ "query_explain", "replication_add", "replication_remove", + "replication_restart", "table_layout_read", "table_layout_update", "table_resync", @@ -46255,9 +46394,38 @@ ], "nullable": true, "type": "string" + }, + "diagnostic": { + "description": "Safe classification of the current runtime failure. Does not include worker logs or establish its underlying cause.", + "nullable": true, + "properties": { + "code": { + "enum": [ + "configuration_error", + "crash_loop", + "image_unavailable", + "out_of_memory", + "process_exited", + "runtime_failed", + "startup_failed" + ], + "type": "string" + }, + "exit_code": { + "maximum": 9007199254740991, + "minimum": -9007199254740991, + "nullable": true, + "type": "integer" + }, + "message": { + "type": "string" + } + }, + "required": ["code", "exit_code", "message"], + "type": "object" } }, - "required": ["id", "observed_at", "status", "unavailable_reason"], + "required": ["diagnostic", "id", "observed_at", "status", "unavailable_reason"], "type": "object" }, "project_ref": { @@ -46445,9 +46613,72 @@ "write_lag_ms" ], "type": "object" + }, + "error": { + "nullable": true, + "properties": { + "reason": { + "type": "string" + }, + "retry_policy": { + "oneOf": [ + { + "properties": { + "policy": { + "enum": ["no_retry"], + "type": "string" + } + }, + "required": ["policy"], + "type": "object" + }, + { + "properties": { + "policy": { + "enum": ["manual_retry"], + "type": "string" + } + }, + "required": ["policy"], + "type": "object" + }, + { + "properties": { + "next_retry": { + "type": "string" + }, + "policy": { + "enum": ["timed_retry"], + "type": "string" + } + }, + "required": ["next_retry", "policy"], + "type": "object" + } + ] + }, + "solution": { + "nullable": true, + "type": "string" + } + }, + "required": ["reason", "retry_policy", "solution"], + "type": "object" + }, + "state_observation": { + "enum": ["current", "last_known", "unavailable"], + "type": "string" } }, - "required": ["id", "name", "replication_state", "schema", "sync_lag"], + "required": [ + "error", + "id", + "name", + "replication_state", + "schema", + "state_observation", + "sync_lag" + ], "type": "object" }, "type": "array" @@ -46474,9 +46705,71 @@ ], "nullable": true, "type": "string" + }, + "progress": { + "description": "Observed states of the selected tables, not completion or percentage of a specific mutation. Last-known states may predate a restart or resync. Null when the selection is unavailable.", + "nullable": true, + "properties": { + "copied_table": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "copying_table": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "error": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "following_wal": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "observation": { + "enum": ["current", "last_known", "unavailable"], + "type": "string" + }, + "queued": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "selected": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + }, + "unknown": { + "maximum": 9007199254740991, + "minimum": 0, + "type": "integer" + } + }, + "required": [ + "copied_table", + "copying_table", + "error", + "following_wal", + "observation", + "queued", + "selected", + "unknown" + ], + "type": "object" } }, - "required": ["items", "observed_at", "status", "unavailable_reason"], + "required": [ + "items", + "observed_at", + "progress", + "status", + "unavailable_reason" + ], "type": "object" } }, @@ -47048,210 +47341,532 @@ "type": "array" }, "sort_by": { - "description": "Configured sort order. none explicitly clears sorting, primary_key sorts by the source primary-key columns in key order, and columns lists them. Null leaves sorting unmanaged.", - "oneOf": [ - { - "properties": { - "kind": { - "enum": ["none"], - "type": "string" - } - }, - "required": ["kind"], - "type": "object" - }, - { - "properties": { - "kind": { - "enum": ["primary_key"], - "type": "string" - } - }, - "required": ["kind"], - "type": "object" - }, + "description": "Configured sort order. none explicitly clears sorting, primary_key sorts by the source primary-key columns in key order, and columns lists them. Null leaves sorting unmanaged.", + "oneOf": [ + { + "properties": { + "kind": { + "enum": ["none"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "properties": { + "kind": { + "enum": ["primary_key"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "properties": { + "columns": { + "items": { + "properties": { + "direction": { + "enum": ["asc", "desc"], + "type": "string" + }, + "name": { + "description": "Source column name.", + "type": "string" + }, + "nulls": { + "description": "Null placement. Null uses DuckLake's default placement.", + "enum": ["first", "last", null], + "nullable": true, + "type": "string" + } + }, + "required": ["direction", "name", "nulls"], + "type": "object" + }, + "type": "array" + }, + "kind": { + "enum": ["columns"], + "type": "string" + } + }, + "required": ["columns", "kind"], + "type": "object" + }, + { + "type": "object", + "nullable": true, + "enum": [null] + } + ] + } + }, + "required": ["partition_by", "sort_by"], + "type": "object" + }, + "name": { + "description": "Source PostgreSQL table name.", + "type": "string" + }, + "observation_status": { + "description": "observed when the DuckLake catalog was read, table_missing when the catalog has no table for it yet, unavailable when the catalog could not be read, and not_requested when an update returned without reading the catalog.", + "enum": ["not_requested", "observed", "table_missing", "unavailable"], + "type": "string" + }, + "observed": { + "description": "Layout recorded in the DuckLake catalog, null unless observation_status is observed. Catalog metadata governs files written after it changes and does not establish that existing files are sorted or partitioned.", + "nullable": true, + "properties": { + "observed_at": { + "description": "Time the catalog metadata was read.", + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$", + "type": "string" + }, + "partition_by": { + "description": "Active partition keys in key order, with transforms as the catalog reports them, for example bucket(16).", + "items": { + "properties": { + "column": { + "type": "string" + }, + "transform": { + "type": "string" + } + }, + "required": ["column", "transform"], + "type": "object" + }, + "type": "array" + }, + "sort_by": { + "description": "Active sort expressions in key order, as the catalog reports them.", + "items": { + "properties": { + "direction": { + "type": "string" + }, + "expression": { + "type": "string" + }, + "nulls": { + "type": "string" + } + }, + "required": ["direction", "expression", "nulls"], + "type": "object" + }, + "type": "array" + } + }, + "required": ["observed_at", "partition_by", "sort_by"], + "type": "object" + }, + "pipeline_id": { + "description": "Warehouse replication pipeline identity.", + "type": "string" + }, + "reset_table": { + "description": "Whether this update reset source replication state. False for unchanged layouts and reads; reads do not retain reset history. True does not establish completion of recopy.", + "type": "boolean" + }, + "schema": { + "description": "Source PostgreSQL schema of the table.", + "type": "string" + } + }, + "required": [ + "application_status", + "desired", + "name", + "observation_status", + "observed", + "pipeline_id", + "reset_table", + "schema" + ], + "type": "object" + }, + "id": { + "description": "Source PostgreSQL table OID, as returned by the Warehouse tables list.", + "example": "16385", + "maxLength": 10, + "pattern": "^[1-9]\\d*$", + "type": "string" + }, + "type": { + "description": "Resource type.", + "enum": ["warehouse_table_layout"], + "type": "string" + } + }, + "required": ["attributes", "id", "type"], + "type": "object" + } + }, + "required": ["data"], + "type": "object" + }, + "V2WarehouseTableLayoutUpdateRequest": { + "properties": { + "data": { + "properties": { + "attributes": { + "anyOf": [ + { + "additionalProperties": false, + "properties": { + "partition_by": { + "description": "Omit to preserve the saved partitioning. Null makes partitioning unmanaged. An empty list explicitly clears partitioning. Otherwise, supply all ordered partition keys. Day example: `[{\"column\":\"event_at\",\"transform\":{\"kind\":\"day\"}}]`. Bucket example: `[{\"column\":\"tenant_id\",\"transform\":{\"kind\":\"bucket\",\"count\":8}}]`. Use `[]` to clear or `null` to stop managing partitioning.", + "items": { + "additionalProperties": false, + "properties": { + "column": { + "description": "Source column name.", + "minLength": 1, + "type": "string" + }, + "transform": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["identity"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["year"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["month"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["day"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["hour"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "count": { + "description": "Number of hash buckets.", + "exclusiveMinimum": true, + "maximum": 2147483647, + "minimum": 0, + "type": "integer" + }, + "kind": { + "enum": ["bucket"], + "type": "string" + } + }, + "required": ["count", "kind"], + "type": "object" + } + ] + } + }, + "required": ["column", "transform"], + "type": "object" + }, + "nullable": true, + "type": "array" + }, + "reset_table": { + "description": "Defaults to false, preserving historical files and replication progress. When the layout changes, true resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", + "type": "boolean" + }, + "sort_by": { + "anyOf": [ + { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["none"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["primary_key"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "columns": { + "items": { + "additionalProperties": false, + "properties": { + "direction": { + "enum": ["asc", "desc"], + "type": "string" + }, + "name": { + "description": "Source column name.", + "minLength": 1, + "type": "string" + }, + "nulls": { + "description": "Null placement. Null uses DuckLake's default placement.", + "enum": ["first", "last", null], + "nullable": true, + "type": "string" + } + }, + "required": ["direction", "name"], + "type": "object" + }, + "minItems": 1, + "type": "array" + }, + "kind": { + "enum": ["columns"], + "type": "string" + } + }, + "required": ["columns", "kind"], + "type": "object" + } + ] + }, + { + "enum": [null], + "nullable": true, + "type": "object" + } + ], + "description": "Omit to preserve the saved sorting. Null makes sorting unmanaged. The none selector explicitly clears sorting. Otherwise, supply the complete sort selector. Example: `{\"kind\":\"columns\",\"columns\":[{\"name\":\"tenant_id\",\"direction\":\"asc\"},{\"name\":\"event_at\",\"direction\":\"desc\",\"nulls\":\"last\"}]}`. Sort by the primary key with `{\"kind\":\"primary_key\"}` or clear sorting with `{\"kind\":\"none\"}`." + } + }, + "required": ["sort_by"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "partition_by": { + "description": "Omit to preserve the saved partitioning. Null makes partitioning unmanaged. An empty list explicitly clears partitioning. Otherwise, supply all ordered partition keys. Day example: `[{\"column\":\"event_at\",\"transform\":{\"kind\":\"day\"}}]`. Bucket example: `[{\"column\":\"tenant_id\",\"transform\":{\"kind\":\"bucket\",\"count\":8}}]`. Use `[]` to clear or `null` to stop managing partitioning.", + "items": { + "additionalProperties": false, + "properties": { + "column": { + "description": "Source column name.", + "minLength": 1, + "type": "string" + }, + "transform": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["identity"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["year"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["month"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["day"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["hour"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "count": { + "description": "Number of hash buckets.", + "exclusiveMinimum": true, + "maximum": 2147483647, + "minimum": 0, + "type": "integer" + }, + "kind": { + "enum": ["bucket"], + "type": "string" + } + }, + "required": ["count", "kind"], + "type": "object" + } + ] + } + }, + "required": ["column", "transform"], + "type": "object" + }, + "nullable": true, + "type": "array" + }, + "reset_table": { + "description": "Defaults to false, preserving historical files and replication progress. When the layout changes, true resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", + "type": "boolean" + }, + "sort_by": { + "anyOf": [ { - "properties": { - "columns": { - "items": { - "properties": { - "direction": { - "enum": ["asc", "desc"], - "type": "string" - }, - "name": { - "description": "Source column name.", - "type": "string" + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["none"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "enum": ["primary_key"], + "type": "string" + } + }, + "required": ["kind"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "columns": { + "items": { + "additionalProperties": false, + "properties": { + "direction": { + "enum": ["asc", "desc"], + "type": "string" + }, + "name": { + "description": "Source column name.", + "minLength": 1, + "type": "string" + }, + "nulls": { + "description": "Null placement. Null uses DuckLake's default placement.", + "enum": ["first", "last", null], + "nullable": true, + "type": "string" + } + }, + "required": ["direction", "name"], + "type": "object" }, - "nulls": { - "description": "Null placement. Null uses DuckLake's default placement.", - "enum": ["first", "last", null], - "nullable": true, - "type": "string" - } + "minItems": 1, + "type": "array" }, - "required": ["direction", "name", "nulls"], - "type": "object" + "kind": { + "enum": ["columns"], + "type": "string" + } }, - "type": "array" - }, - "kind": { - "enum": ["columns"], - "type": "string" + "required": ["columns", "kind"], + "type": "object" } - }, - "required": ["columns", "kind"], - "type": "object" + ] }, { - "type": "object", + "enum": [null], "nullable": true, - "enum": [null] + "type": "object" } - ] - } - }, - "required": ["partition_by", "sort_by"], - "type": "object" - }, - "name": { - "description": "Source PostgreSQL table name.", - "type": "string" - }, - "observation_status": { - "description": "observed when the DuckLake catalog was read, table_missing when the catalog has no table for it yet, unavailable when the catalog could not be read, and not_requested when an update returned without reading the catalog.", - "enum": ["not_requested", "observed", "table_missing", "unavailable"], - "type": "string" - }, - "observed": { - "description": "Layout recorded in the DuckLake catalog, null unless observation_status is observed. Catalog metadata governs files written after it changes and does not establish that existing files are sorted or partitioned.", - "nullable": true, - "properties": { - "observed_at": { - "description": "Time the catalog metadata was read.", - "format": "date-time", - "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$", - "type": "string" - }, - "partition_by": { - "description": "Active partition keys in key order, with transforms as the catalog reports them, for example bucket(16).", - "items": { - "properties": { - "column": { - "type": "string" - }, - "transform": { - "type": "string" - } - }, - "required": ["column", "transform"], - "type": "object" - }, - "type": "array" - }, - "sort_by": { - "description": "Active sort expressions in key order, as the catalog reports them.", - "items": { - "properties": { - "direction": { - "type": "string" - }, - "expression": { - "type": "string" - }, - "nulls": { - "type": "string" - } - }, - "required": ["direction", "expression", "nulls"], - "type": "object" - }, - "type": "array" - } - }, - "required": ["observed_at", "partition_by", "sort_by"], - "type": "object" - }, - "pipeline_id": { - "description": "Warehouse replication pipeline identity.", - "type": "string" - }, - "reset_table": { - "description": "Whether this update reset source replication state. False for unchanged layouts and reads; reads do not retain reset history. True does not establish completion of recopy.", - "type": "boolean" - }, - "schema": { - "description": "Source PostgreSQL schema of the table.", - "type": "string" - } - }, - "required": [ - "application_status", - "desired", - "name", - "observation_status", - "observed", - "pipeline_id", - "reset_table", - "schema" - ], - "type": "object" - }, - "id": { - "description": "Source PostgreSQL table OID, as returned by the Warehouse tables list.", - "example": "16385", - "maxLength": 10, - "pattern": "^[1-9]\\d*$", - "type": "string" - }, - "type": { - "description": "Resource type.", - "enum": ["warehouse_table_layout"], - "type": "string" - } - }, - "required": ["attributes", "id", "type"], - "type": "object" - } - }, - "required": ["data"], - "type": "object" - }, - "V2WarehouseTableLayoutUpdateRequest": { - "properties": { - "data": { - "properties": { - "attributes": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "partition_by": { - "$ref": "#/components/schemas/V2WarehouseTableLayoutPartitionBy" - }, - "reset_table": { - "description": "Defaults to false, preserving historical files and replication progress. When the layout changes, --reset-table resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", - "type": "boolean" - }, - "sort_by": { - "$ref": "#/components/schemas/V2WarehouseTableLayoutSortBy" - } - }, - "required": ["sort_by"], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "partition_by": { - "$ref": "#/components/schemas/V2WarehouseTableLayoutPartitionBy" - }, - "reset_table": { - "description": "Defaults to false, preserving historical files and replication progress. When the layout changes, --reset-table resets the table and copies it again. This requires initial sync to be enabled. Reads are disrupted during the copy. An unchanged layout never resets the table.", - "type": "boolean" - }, - "sort_by": { - "$ref": "#/components/schemas/V2WarehouseTableLayoutSortBy" + ], + "description": "Omit to preserve the saved sorting. Null makes sorting unmanaged. The none selector explicitly clears sorting. Otherwise, supply the complete sort selector. Example: `{\"kind\":\"columns\",\"columns\":[{\"name\":\"tenant_id\",\"direction\":\"asc\"},{\"name\":\"event_at\",\"direction\":\"desc\",\"nulls\":\"last\"}]}`. Sort by the primary key with `{\"kind\":\"primary_key\"}` or clear sorting with `{\"kind\":\"none\"}`." } }, "required": ["partition_by"], @@ -52055,6 +52670,52 @@ "enum": [null] } ] + }, + "V2WarehouseRestartResponse_Output": { + "properties": { + "data": { + "properties": { + "attributes": { + "properties": { + "action": { + "enum": ["restart", "start"], + "type": "string" + }, + "application_status": { + "description": "The runtime request was accepted. This does not establish resumed replication or completed initial copies.", + "enum": ["accepted"], + "type": "string" + }, + "pipeline_id": { + "type": "string" + }, + "pipeline_status_before": { + "type": "string" + } + }, + "required": [ + "action", + "application_status", + "pipeline_id", + "pipeline_status_before" + ], + "type": "object" + }, + "id": { + "type": "string" + }, + "type": { + "description": "Resource type.", + "enum": ["warehouse_replication_restart"], + "type": "string" + } + }, + "required": ["attributes", "id", "type"], + "type": "object" + } + }, + "required": ["data"], + "type": "object" } } } diff --git a/packages/api/src/generated/permissions.ts b/packages/api/src/generated/permissions.ts index ae7fbabf62..0619fa3cd8 100644 --- a/packages/api/src/generated/permissions.ts +++ b/packages/api/src/generated/permissions.ts @@ -480,4 +480,8 @@ export const operationPermissions: Readonly "v2-organizations-slug-webhooks-endpoints-id-test-post": { fga: [] }, "v2-organizations-slug-webhooks-deliveries-id-get": { fga: [] }, "v2-organizations-slug-webhooks-deliveries-id-retry-post": { fga: [] }, + "v2-restart-warehouse-replication": { + fga: [["database_write", "project_admin_write"]], + oauthScope: "database:write", + }, };