@rebasepro/cms 0.25.0-canary.ge06257e → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/collection_editor/liveSchemaClient.d.ts +3 -3
  2. package/dist/collection_editor/liveSchemaClient.js.map +1 -1
  3. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +52 -48
  4. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
  5. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js +22 -22
  6. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
  7. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js +14 -14
  8. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js.map +1 -1
  9. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js +24 -24
  10. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js.map +1 -1
  11. package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js +1 -1
  12. package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js.map +1 -1
  13. package/dist/components/DeleteEntityDialog.js +9 -9
  14. package/dist/components/DeleteEntityDialog.js.map +1 -1
  15. package/dist/components/PropertyConfigBadge.js +1 -1
  16. package/dist/components/PropertyConfigBadge.js.map +1 -1
  17. package/dist/components/ReferenceTable/SelectionTableBinding.js +4 -3
  18. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
  19. package/dist/components/RelationSelector.js +2 -2
  20. package/dist/components/RelationSelector.js.map +1 -1
  21. package/dist/components/app/Scaffold.js.map +1 -1
  22. package/dist/editor/editor.js +2 -2
  23. package/dist/editor/editor.js.map +1 -1
  24. package/dist/editor/extensions/drag-and-drop.js +1 -1
  25. package/dist/editor/extensions/drag-and-drop.js.map +1 -1
  26. package/package.json +9 -9
@@ -17,7 +17,7 @@
17
17
  * JSON, which had lost every handler, shared property and imported value.
18
18
  * A new collection is still sent whole.
19
19
  */
20
- import type { CollectionPatch } from "@rebasepro/types";
20
+ import type { CollectionPatch, SchemaChangeVerdict } from "@rebasepro/types";
21
21
  /** A constraint the change asks for that the statements will not carry. */
22
22
  export interface WithheldConstraint {
23
23
  target: string;
@@ -28,10 +28,10 @@ export interface WithheldConstraint {
28
28
  /** What the server says a change would do. Mirrors `SchemaChangePlan`. */
29
29
  export interface LiveSchemaPlan {
30
30
  applicable: boolean;
31
- verdict: "safe" | "diverges" | "needs-migration";
31
+ verdict: SchemaChangeVerdict;
32
32
  changes: Array<{
33
33
  kind: string;
34
- verdict: "safe" | "diverges" | "needs-migration";
34
+ verdict: SchemaChangeVerdict;
35
35
  collection: string;
36
36
  property?: string;
37
37
  detail: string;
@@ -1 +1 @@
1
- {"version":3,"file":"liveSchemaClient.js","names":[],"sources":["../../src/collection_editor/liveSchemaClient.ts"],"sourcesContent":["/**\n * The panel's client for live schema editing.\n *\n * Three calls, mirroring the routes: ask whether this backend can do it, ask\n * what a change would do, then do it. `plan` and `apply` are deliberately\n * separate here as well as on the server, because a UI that could only\n * try-and-see would be asking somebody to discover that their change is refused\n * by pressing a button on a live database.\n *\n * ## A change to an existing collection is a patch\n *\n * What the person changed — the difference between the collection the editor\n * loaded and the one it is saving, from `diffCollections` in\n * `@rebasepro/types` — not the collection. The server applies it to the\n * collection as it is to plan the change, and writes only those keys into the\n * file. Posting the whole collection had the server write back the panel's\n * JSON, which had lost every handler, shared property and imported value.\n * A new collection is still sent whole.\n */\n\nimport type { CollectionPatch } from \"@rebasepro/types\";\n\n/** A constraint the change asks for that the statements will not carry. */\nexport interface WithheldConstraint {\n target: string;\n kind: \"not-null\";\n reason: string;\n remedy: string;\n}\n\n/** What the server says a change would do. Mirrors `SchemaChangePlan`. */\nexport interface LiveSchemaPlan {\n applicable: boolean;\n verdict: \"safe\" | \"diverges\" | \"needs-migration\";\n changes: Array<{\n kind: string;\n verdict: \"safe\" | \"diverges\" | \"needs-migration\";\n collection: string;\n property?: string;\n detail: string;\n remedy?: string;\n /**\n * What \"Edit source only\" leaves behind for this change. Absent on a\n * change that may not be written to the source alone.\n */\n sourceOnly?: string;\n kept?: string;\n }>;\n statements: string[];\n files: string[];\n message: string;\n /**\n * Applicable, and still not fully enforced.\n *\n * Not a refusal, so it does not belong in `changes` — but it is the one\n * thing on a plan somebody might want to stop and read, so the dialog gives\n * it its own place rather than another bullet in the list.\n */\n withheldConstraints: WithheldConstraint[];\n /**\n * What still has to happen after this lands.\n *\n * Empty almost always. The case it exists for: a project that replays\n * versioned migrations, where applying here changes *this* database and\n * commits the collection, but writes no migration — so the next\n * environment built from migrations would not have the change.\n */\n followUp?: string[];\n}\n\nexport interface LiveSchemaResult {\n applied: boolean;\n /** Committed as \"Edit source only\": nothing was meant to run. */\n sourceOnly?: boolean;\n applyError?: string;\n /**\n * How many statements ran before the one that failed. The statements run\n * one at a time with no transaction around them, so a failure part-way\n * leaves the earlier ones applied. `undefined` when the server could not\n * say.\n */\n appliedStatements?: number;\n committed: { sha: string; branch: string; files: string[] };\n statements: string[];\n summary: string;\n withheldConstraints: WithheldConstraint[];\n followUp?: string[];\n}\n\n/**\n * Whether this backend can edit its schema, and what is missing when it cannot.\n *\n * `canPlan` is separate from `enabled` deliberately: previewing a change needs\n * no repository, so a deployment running from a bundle can still show somebody\n * exactly what their change would do. Greying out the preview as well would be\n * a worse answer than the truth.\n */\nexport interface LiveSchemaStatus {\n enabled: boolean;\n canPlan: boolean;\n /**\n * Whether *this caller* may apply, as opposed to whether the server can.\n *\n * Applying commits to the repository under an author, and a credential is\n * not an author — so an API key or the service key may preview a change and\n * not make one. Reported here so the panel can grey out the button and say\n * why, rather than letting somebody read a plan, decide, press, and only\n * then be refused.\n */\n canApply: boolean;\n applyRefusedBecause?: string;\n applyRefusedCode?: string;\n repository?: string;\n /** The branch a commit would land on. */\n branch?: string;\n code?: string;\n reason?: string;\n}\n\n/**\n * Why live editing is not available here.\n *\n * Distinguished from an ordinary failure because both are expected states with\n * their own explanation, and a UI should say which rather than showing a\n * stack: a Mongo backend will never support this, and a bundle deployment has\n * no source to edit.\n */\nexport type LiveSchemaUnavailable =\n | { reason: \"unsupported\"; message: string }\n | { reason: \"no-repository\"; message: string };\n\nexport class LiveSchemaError extends Error {\n constructor(\n message: string,\n readonly code: string | undefined,\n readonly changes?: LiveSchemaPlan[\"changes\"]\n ) {\n super(message);\n this.name = \"LiveSchemaError\";\n }\n}\n\nconst UNAVAILABLE: Record<string, LiveSchemaUnavailable[\"reason\"]> = {\n SCHEMA_EDITING_UNSUPPORTED: \"unsupported\",\n SCHEMA_EDITING_NO_REPOSITORY: \"no-repository\"\n};\n\nexport interface LiveSchemaClientOptions {\n /** Base for the routes, e.g. `https://api.example.com/api/schema`. */\n baseUrl: string;\n getAuthToken?: () => Promise<string | null> | string | null;\n fetchImpl?: typeof fetch;\n}\n\nexport interface ProposedCollectionChange {\n collectionId: string;\n /** A new collection, whole. */\n collection?: Record<string, unknown>;\n /** What changed about an existing one. See the module comment. */\n patch?: CollectionPatch;\n /** Delete the collection's source — its file and its `index.ts` entry. The table stays. */\n remove?: true;\n}\n\nexport function createLiveSchemaClient(options: LiveSchemaClientOptions) {\n const doFetch = options.fetchImpl ?? fetch;\n const base = options.baseUrl.replace(/\\/$/, \"\");\n\n const post = async <T>(path: string, body: ProposedCollectionChange & { sourceOnly?: boolean }): Promise<T> => {\n const token = await options.getAuthToken?.();\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (token) headers.Authorization = `Bearer ${token}`;\n\n const response = await doFetch(`${base}${path}`, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body)\n });\n\n if (response.ok) return await response.json() as T;\n\n // Parsed rather than assumed: the server answers a structured error, and\n // the code is what tells an expected refusal from a broken request.\n let payload: { error?: { code?: string; message?: string; details?: { changes?: LiveSchemaPlan[\"changes\"] } } } = {};\n try {\n payload = await response.json() as typeof payload;\n } catch {\n payload = { error: { message: await response.text().catch(() => \"\") } };\n }\n\n throw new LiveSchemaError(\n payload.error?.message || `Schema request failed with ${response.status}`,\n payload.error?.code,\n payload.error?.details?.changes\n );\n };\n\n return {\n /**\n * Whether this backend can edit its schema.\n *\n * Never throws. Every way of failing to get an answer — a backend too\n * old to have the endpoint, an unreachable one, a session that is not\n * an admin — means the same thing to a caller deciding whether to offer\n * the control, and turning that into an exception each caller has to\n * catch would only produce four copies of this `catch`.\n */\n status: async (): Promise<LiveSchemaStatus> => {\n try {\n const token = await options.getAuthToken?.();\n const response = await doFetch(`${base}/status`, {\n headers: token ? { Authorization: `Bearer ${token}` } : {}\n });\n const body = await response.json().catch(() => ({})) as\n Partial<LiveSchemaStatus> & { error?: { code?: string; message?: string } };\n\n if (response.ok) {\n return {\n enabled: body.enabled === true,\n canPlan: body.canPlan === true,\n // Absent on a backend from before capabilities existed.\n // Read as \"yes\" there, because on that server being\n // through the admin gate *was* the whole permission —\n // defaulting to no would take the feature away from\n // every deployment that has not upgraded.\n canApply: body.canApply ?? body.enabled === true,\n applyRefusedBecause: body.applyRefusedBecause,\n applyRefusedCode: body.applyRefusedCode,\n repository: body.repository,\n branch: body.branch,\n code: body.code,\n reason: body.reason\n };\n }\n return {\n enabled: false,\n canPlan: false,\n canApply: false,\n code: body.error?.code,\n reason: body.error?.message\n ?? `The backend refused to say whether its schema is editable (HTTP ${response.status}).`\n };\n } catch (err) {\n return {\n enabled: false,\n canPlan: false,\n canApply: false,\n reason: err instanceof Error ? err.message : \"The backend could not be reached.\"\n };\n }\n },\n\n /** What the change would do. No side effects. */\n plan: (change: ProposedCollectionChange) => post<LiveSchemaPlan>(\"/plan\", change),\n\n /**\n * Commit the change, then apply it — or, with `sourceOnly`, commit it\n * and run nothing (\"Edit source only\").\n */\n apply: (change: ProposedCollectionChange & { sourceOnly?: boolean }) => post<LiveSchemaResult>(\"/apply\", change)\n };\n}\n\n/** The client's shape, for the hook and the tests that fake it. */\nexport type LiveSchemaClient = ReturnType<typeof createLiveSchemaClient>;\n\n/**\n * Whether an error means live editing is unavailable here, rather than that the\n * change was wrong.\n *\n * Returns the reason so a caller can say which, and `undefined` for anything\n * else — a refused change is not an unavailable feature, and conflating them\n * would hide the refusal that the user needs to read.\n */\nexport function asUnavailable(err: unknown): LiveSchemaUnavailable | undefined {\n if (!(err instanceof LiveSchemaError) || !err.code) return undefined;\n const reason = UNAVAILABLE[err.code];\n return reason ? { reason, message: err.message } : undefined;\n}\n\n/** The person closed the dialog without applying. Not an error; an answer. */\nexport class SchemaChangeCancelled extends Error {\n constructor() {\n super(\"The schema change was not applied.\");\n this.name = \"SchemaChangeCancelled\";\n }\n}\n\n/**\n * Was this rejection the person saying no?\n *\n * A save has to *reject* when it is cancelled — resolving would leave the form\n * believing it saved. But a caller that treats every rejection as a failure\n * then reports the user's own choice back to them as an error, which is what\n * the collection editor did: a console error and a red snackbar reading \"Error\n * persisting collection: The schema change was not applied.\"\n *\n * Matched by name rather than `instanceof`, which is unreliable the moment two\n * copies of this module end up in one bundle — the class is then a different\n * identity and every check silently answers false.\n */\nexport function isSchemaChangeCancelled(err: unknown): boolean {\n return err instanceof Error && err.name === \"SchemaChangeCancelled\";\n}\n"],"mappings":";AAmIA,IAAa,kBAAb,cAAqC,MAAM;CAG1B;CACA;CAHb,YACI,SACA,MACA,SACF;EACE,MAAM,OAAO;EAHJ,KAAA,OAAA;EACA,KAAA,UAAA;EAGT,KAAK,OAAO;CAChB;AACJ;AAEA,IAAM,cAA+D;CACjE,4BAA4B;CAC5B,8BAA8B;AAClC;AAmBA,SAAgB,uBAAuB,SAAkC;CACrE,MAAM,UAAU,QAAQ,aAAa;CACrC,MAAM,OAAO,QAAQ,QAAQ,QAAQ,OAAO,EAAE;CAE9C,MAAM,OAAO,OAAU,MAAc,SAA0E;EAC3G,MAAM,QAAQ,MAAM,QAAQ,eAAe;EAC3C,MAAM,UAAkC,EAAE,gBAAgB,mBAAmB;EAC7E,IAAI,OAAO,QAAQ,gBAAgB,UAAU;EAE7C,MAAM,WAAW,M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;;;;EAMhF,QAAQ,WAAgE,KAAuB,UAAU,MAAM;CACnH;AACJ;;;;;;;;;AAaA,SAAgB,cAAc,KAAiD;CAC3E,IAAI,EAAE,eAAe,oBAAoB,CAAC,IAAI,MAAM,OAAO,KAAA;CAC3D,MAAM,SAAS,YAAY,IAAI;CAC/B,OAAO,SAAS;EAAE;EAAQ,SAAS,IAAI;CAAQ,IAAI,KAAA;AACvD;;AAGA,IAAa,wBAAb,cAA2C,MAAM;CAC7C,cAAc;EACV,MAAM,oCAAoC;EAC1C,KAAK,OAAO;CAChB;AACJ;;;;;;;;;;;;;;AAeA,SAAgB,wBAAwB,KAAuB;CAC3D,OAAO,eAAe,SAAS,IAAI,SAAS;AAChD"}
1
+ {"version":3,"file":"liveSchemaClient.js","names":[],"sources":["../../src/collection_editor/liveSchemaClient.ts"],"sourcesContent":["/**\n * The panel's client for live schema editing.\n *\n * Three calls, mirroring the routes: ask whether this backend can do it, ask\n * what a change would do, then do it. `plan` and `apply` are deliberately\n * separate here as well as on the server, because a UI that could only\n * try-and-see would be asking somebody to discover that their change is refused\n * by pressing a button on a live database.\n *\n * ## A change to an existing collection is a patch\n *\n * What the person changed — the difference between the collection the editor\n * loaded and the one it is saving, from `diffCollections` in\n * `@rebasepro/types` — not the collection. The server applies it to the\n * collection as it is to plan the change, and writes only those keys into the\n * file. Posting the whole collection had the server write back the panel's\n * JSON, which had lost every handler, shared property and imported value.\n * A new collection is still sent whole.\n */\n\nimport type { CollectionPatch, SchemaChangeVerdict } from \"@rebasepro/types\";\n\n/** A constraint the change asks for that the statements will not carry. */\nexport interface WithheldConstraint {\n target: string;\n kind: \"not-null\";\n reason: string;\n remedy: string;\n}\n\n/** What the server says a change would do. Mirrors `SchemaChangePlan`. */\nexport interface LiveSchemaPlan {\n applicable: boolean;\n verdict: SchemaChangeVerdict;\n changes: Array<{\n kind: string;\n verdict: SchemaChangeVerdict;\n collection: string;\n property?: string;\n detail: string;\n remedy?: string;\n /**\n * What \"Edit source only\" leaves behind for this change. Absent on a\n * change that may not be written to the source alone.\n */\n sourceOnly?: string;\n kept?: string;\n }>;\n statements: string[];\n files: string[];\n message: string;\n /**\n * Applicable, and still not fully enforced.\n *\n * Not a refusal, so it does not belong in `changes` — but it is the one\n * thing on a plan somebody might want to stop and read, so the dialog gives\n * it its own place rather than another bullet in the list.\n */\n withheldConstraints: WithheldConstraint[];\n /**\n * What still has to happen after this lands.\n *\n * Empty almost always. The case it exists for: a project that replays\n * versioned migrations, where applying here changes *this* database and\n * commits the collection, but writes no migration — so the next\n * environment built from migrations would not have the change.\n */\n followUp?: string[];\n}\n\nexport interface LiveSchemaResult {\n applied: boolean;\n /** Committed as \"Edit source only\": nothing was meant to run. */\n sourceOnly?: boolean;\n applyError?: string;\n /**\n * How many statements ran before the one that failed. The statements run\n * one at a time with no transaction around them, so a failure part-way\n * leaves the earlier ones applied. `undefined` when the server could not\n * say.\n */\n appliedStatements?: number;\n committed: { sha: string; branch: string; files: string[] };\n statements: string[];\n summary: string;\n withheldConstraints: WithheldConstraint[];\n followUp?: string[];\n}\n\n/**\n * Whether this backend can edit its schema, and what is missing when it cannot.\n *\n * `canPlan` is separate from `enabled` deliberately: previewing a change needs\n * no repository, so a deployment running from a bundle can still show somebody\n * exactly what their change would do. Greying out the preview as well would be\n * a worse answer than the truth.\n */\nexport interface LiveSchemaStatus {\n enabled: boolean;\n canPlan: boolean;\n /**\n * Whether *this caller* may apply, as opposed to whether the server can.\n *\n * Applying commits to the repository under an author, and a credential is\n * not an author — so an API key or the service key may preview a change and\n * not make one. Reported here so the panel can grey out the button and say\n * why, rather than letting somebody read a plan, decide, press, and only\n * then be refused.\n */\n canApply: boolean;\n applyRefusedBecause?: string;\n applyRefusedCode?: string;\n repository?: string;\n /** The branch a commit would land on. */\n branch?: string;\n code?: string;\n reason?: string;\n}\n\n/**\n * Why live editing is not available here.\n *\n * Distinguished from an ordinary failure because both are expected states with\n * their own explanation, and a UI should say which rather than showing a\n * stack: a Mongo backend will never support this, and a bundle deployment has\n * no source to edit.\n */\nexport type LiveSchemaUnavailable =\n | { reason: \"unsupported\"; message: string }\n | { reason: \"no-repository\"; message: string };\n\nexport class LiveSchemaError extends Error {\n constructor(\n message: string,\n readonly code: string | undefined,\n readonly changes?: LiveSchemaPlan[\"changes\"]\n ) {\n super(message);\n this.name = \"LiveSchemaError\";\n }\n}\n\nconst UNAVAILABLE: Record<string, LiveSchemaUnavailable[\"reason\"]> = {\n SCHEMA_EDITING_UNSUPPORTED: \"unsupported\",\n SCHEMA_EDITING_NO_REPOSITORY: \"no-repository\"\n};\n\nexport interface LiveSchemaClientOptions {\n /** Base for the routes, e.g. `https://api.example.com/api/schema`. */\n baseUrl: string;\n getAuthToken?: () => Promise<string | null> | string | null;\n fetchImpl?: typeof fetch;\n}\n\nexport interface ProposedCollectionChange {\n collectionId: string;\n /** A new collection, whole. */\n collection?: Record<string, unknown>;\n /** What changed about an existing one. See the module comment. */\n patch?: CollectionPatch;\n /** Delete the collection's source — its file and its `index.ts` entry. The table stays. */\n remove?: true;\n}\n\nexport function createLiveSchemaClient(options: LiveSchemaClientOptions) {\n const doFetch = options.fetchImpl ?? fetch;\n const base = options.baseUrl.replace(/\\/$/, \"\");\n\n const post = async <T>(path: string, body: ProposedCollectionChange & { sourceOnly?: boolean }): Promise<T> => {\n const token = await options.getAuthToken?.();\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (token) headers.Authorization = `Bearer ${token}`;\n\n const response = await doFetch(`${base}${path}`, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body)\n });\n\n if (response.ok) return await response.json() as T;\n\n // Parsed rather than assumed: the server answers a structured error, and\n // the code is what tells an expected refusal from a broken request.\n let payload: { error?: { code?: string; message?: string; details?: { changes?: LiveSchemaPlan[\"changes\"] } } } = {};\n try {\n payload = await response.json() as typeof payload;\n } catch {\n payload = { error: { message: await response.text().catch(() => \"\") } };\n }\n\n throw new LiveSchemaError(\n payload.error?.message || `Schema request failed with ${response.status}`,\n payload.error?.code,\n payload.error?.details?.changes\n );\n };\n\n return {\n /**\n * Whether this backend can edit its schema.\n *\n * Never throws. Every way of failing to get an answer — a backend too\n * old to have the endpoint, an unreachable one, a session that is not\n * an admin — means the same thing to a caller deciding whether to offer\n * the control, and turning that into an exception each caller has to\n * catch would only produce four copies of this `catch`.\n */\n status: async (): Promise<LiveSchemaStatus> => {\n try {\n const token = await options.getAuthToken?.();\n const response = await doFetch(`${base}/status`, {\n headers: token ? { Authorization: `Bearer ${token}` } : {}\n });\n const body = await response.json().catch(() => ({})) as\n Partial<LiveSchemaStatus> & { error?: { code?: string; message?: string } };\n\n if (response.ok) {\n return {\n enabled: body.enabled === true,\n canPlan: body.canPlan === true,\n // Absent on a backend from before capabilities existed.\n // Read as \"yes\" there, because on that server being\n // through the admin gate *was* the whole permission —\n // defaulting to no would take the feature away from\n // every deployment that has not upgraded.\n canApply: body.canApply ?? body.enabled === true,\n applyRefusedBecause: body.applyRefusedBecause,\n applyRefusedCode: body.applyRefusedCode,\n repository: body.repository,\n branch: body.branch,\n code: body.code,\n reason: body.reason\n };\n }\n return {\n enabled: false,\n canPlan: false,\n canApply: false,\n code: body.error?.code,\n reason: body.error?.message\n ?? `The backend refused to say whether its schema is editable (HTTP ${response.status}).`\n };\n } catch (err) {\n return {\n enabled: false,\n canPlan: false,\n canApply: false,\n reason: err instanceof Error ? err.message : \"The backend could not be reached.\"\n };\n }\n },\n\n /** What the change would do. No side effects. */\n plan: (change: ProposedCollectionChange) => post<LiveSchemaPlan>(\"/plan\", change),\n\n /**\n * Commit the change, then apply it — or, with `sourceOnly`, commit it\n * and run nothing (\"Edit source only\").\n */\n apply: (change: ProposedCollectionChange & { sourceOnly?: boolean }) => post<LiveSchemaResult>(\"/apply\", change)\n };\n}\n\n/** The client's shape, for the hook and the tests that fake it. */\nexport type LiveSchemaClient = ReturnType<typeof createLiveSchemaClient>;\n\n/**\n * Whether an error means live editing is unavailable here, rather than that the\n * change was wrong.\n *\n * Returns the reason so a caller can say which, and `undefined` for anything\n * else — a refused change is not an unavailable feature, and conflating them\n * would hide the refusal that the user needs to read.\n */\nexport function asUnavailable(err: unknown): LiveSchemaUnavailable | undefined {\n if (!(err instanceof LiveSchemaError) || !err.code) return undefined;\n const reason = UNAVAILABLE[err.code];\n return reason ? { reason, message: err.message } : undefined;\n}\n\n/** The person closed the dialog without applying. Not an error; an answer. */\nexport class SchemaChangeCancelled extends Error {\n constructor() {\n super(\"The schema change was not applied.\");\n this.name = \"SchemaChangeCancelled\";\n }\n}\n\n/**\n * Was this rejection the person saying no?\n *\n * A save has to *reject* when it is cancelled — resolving would leave the form\n * believing it saved. But a caller that treats every rejection as a failure\n * then reports the user's own choice back to them as an error, which is what\n * the collection editor did: a console error and a red snackbar reading \"Error\n * persisting collection: The schema change was not applied.\"\n *\n * Matched by name rather than `instanceof`, which is unreliable the moment two\n * copies of this module end up in one bundle — the class is then a different\n * identity and every check silently answers false.\n */\nexport function isSchemaChangeCancelled(err: unknown): boolean {\n return err instanceof Error && err.name === \"SchemaChangeCancelled\";\n}\n"],"mappings":";AAmIA,IAAa,kBAAb,cAAqC,MAAM;CAG1B;CACA;CAHb,YACI,SACA,MACA,SACF;EACE,MAAM,OAAO;EAHJ,KAAA,OAAA;EACA,KAAA,UAAA;EAGT,KAAK,OAAO;CAChB;AACJ;AAEA,IAAM,cAA+D;CACjE,4BAA4B;CAC5B,8BAA8B;AAClC;AAmBA,SAAgB,uBAAuB,SAAkC;CACrE,MAAM,UAAU,QAAQ,aAAa;CACrC,MAAM,OAAO,QAAQ,QAAQ,QAAQ,OAAO,EAAE;CAE9C,MAAM,OAAO,OAAU,MAAc,SAA0E;EAC3G,MAAM,QAAQ,MAAM,QAAQ,eAAe;EAC3C,MAAM,UAAkC,EAAE,gBAAgB,mBAAmB;EAC7E,IAAI,OAAO,QAAQ,gBAAgB,UAAU;EAE7C,MAAM,WAAW,MAAM,QAAQ,GAAG,OAAO,QAAQ;GAC7C,QAAQ;GACR;GACA,MAAM,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;;;;;AAaA,SAAgB,cAAc,KAAiD;CAC3E,IAAI,EAAE,eAAe,oBAAoB,CAAC,IAAI,MAAM,OAAO,KAAA;CAC3D,MAAM,SAAS,YAAY,IAAI;CAC/B,OAAO,SAAS;EAAE;EAAQ,SAAS,IAAI;CAAQ,IAAI,KAAA;AACvD;;AAGA,IAAa,wBAAb,cAA2C,MAAM;CAC7C,cAAc;EACV,MAAM,oCAAoC;EAC1C,KAAK,OAAO;CAChB;AACJ;;;;;;;;;;;;;;AAeA,SAAgB,wBAAwB,KAAuB;CAC3D,OAAO,eAAe,SAAS,IAAI,SAAS;AAChD"}
@@ -1,8 +1,8 @@
1
1
  import "react";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { Alert, Button, Chip, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle, ExpandablePanel, Typography, cls } from "@rebasepro/ui";
4
+ import { useTranslation } from "@rebasepro/app";
4
5
  //#region src/collection_editor/ui/collection_editor/SchemaChangeDialog.tsx
5
- /** What the verdict means, in the words the reader needs rather than the enum's. */
6
6
  /**
7
7
  * What the verdict means, in the words the reader needs rather than the enum's.
8
8
  *
@@ -14,32 +14,32 @@ import { Alert, Button, Chip, CircularProgress, Dialog, DialogActions, DialogCon
14
14
  */
15
15
  var VERDICT_COPY = {
16
16
  safe: {
17
- title: "Ready to apply",
18
- body: "Every change here can be made against the running database.",
17
+ titleKey: "schema_change_verdict_safe_title",
18
+ bodyKey: "schema_change_verdict_safe_body",
19
19
  color: "info"
20
20
  },
21
21
  diverges: {
22
- title: "This would leave the database out of step",
23
- body: "The change can be written, but the database will not end up matching it. The details below say which part, and what would make it applicable.",
22
+ titleKey: "schema_change_verdict_diverges_title",
23
+ bodyKey: "schema_change_verdict_diverges_body",
24
24
  color: "warning"
25
25
  },
26
26
  "needs-migration": {
27
- title: "This needs a migration",
28
- body: "Some of this cannot be done to a running database at all — it drops or rewrites something, and that belongs in a migration somebody has read.",
27
+ titleKey: "schema_change_verdict_migration_title",
28
+ bodyKey: "schema_change_verdict_migration_body",
29
29
  color: "error"
30
30
  }
31
31
  };
32
32
  var VERDICT_CHIP = {
33
33
  safe: {
34
- label: "safe",
34
+ labelKey: "schema_change_chip_safe",
35
35
  scheme: "greenLighter"
36
36
  },
37
37
  diverges: {
38
- label: "diverges",
38
+ labelKey: "schema_change_chip_diverges",
39
39
  scheme: "orangeLighter"
40
40
  },
41
41
  "needs-migration": {
42
- label: "needs migration",
42
+ labelKey: "schema_change_chip_migration",
43
43
  scheme: "redLighter"
44
44
  }
45
45
  };
@@ -73,13 +73,14 @@ function Details({ summary, count, children }) {
73
73
  * to be done or a later environment will differ from this one.
74
74
  */
75
75
  function FollowUp({ items }) {
76
+ const { t } = useTranslation();
76
77
  if (items.length === 0) return null;
77
78
  return /* @__PURE__ */ jsxs(Alert, {
78
79
  color: "info",
79
80
  children: [/* @__PURE__ */ jsx(Typography, {
80
81
  variant: "body2",
81
82
  className: "font-medium mb-1",
82
- children: items.length === 1 ? "One thing to do afterwards" : "To do afterwards"
83
+ children: items.length === 1 ? t("schema_change_follow_up_one") : t("schema_change_follow_up")
83
84
  }), /* @__PURE__ */ jsx("ul", {
84
85
  className: "space-y-2",
85
86
  children: items.map((item) => /* @__PURE__ */ jsx("li", {
@@ -102,13 +103,14 @@ function repositoryLabel(repository) {
102
103
  return repository.split("/").filter(Boolean).pop() ?? repository;
103
104
  }
104
105
  function WithheldConstraints({ constraints }) {
106
+ const { t } = useTranslation();
105
107
  if (constraints.length === 0) return null;
106
108
  return /* @__PURE__ */ jsxs(Alert, {
107
109
  color: "warning",
108
110
  children: [/* @__PURE__ */ jsx(Typography, {
109
111
  variant: "body2",
110
112
  className: "font-medium mb-1",
111
- children: constraints.length === 1 ? "One constraint will not be enforced" : `${constraints.length} constraints will not be enforced`
113
+ children: constraints.length === 1 ? t("schema_change_withheld_one") : t("schema_change_withheld_many", { count: constraints.length })
112
114
  }), /* @__PURE__ */ jsx("ul", {
113
115
  className: "space-y-2",
114
116
  children: constraints.map((constraint) => /* @__PURE__ */ jsxs("li", {
@@ -142,14 +144,18 @@ function WithheldConstraints({ constraints }) {
142
144
  * The statements run one at a time with no transaction around them, so only
143
145
  * "none ran" means the database is as it was.
144
146
  */
145
- function partialApplyHeading(result) {
147
+ function partialApplyHeading(result, t) {
146
148
  const ran = result.appliedStatements;
147
- if (ran === 0) return "The database was not changed";
148
- if (ran === void 0) return "The database may have been changed in part";
149
- return `${ran} of ${result.statements.length} statements ran, then one failed`;
149
+ if (ran === 0) return t("schema_change_db_not_changed");
150
+ if (ran === void 0) return t("schema_change_db_maybe_changed");
151
+ return t("schema_change_statements_partial", {
152
+ ran,
153
+ total: result.statements.length
154
+ });
150
155
  }
151
156
  /** The receipt. Shown in place of the plan once the change has been applied. */
152
157
  function Applied({ result }) {
158
+ const { t } = useTranslation();
153
159
  return /* @__PURE__ */ jsxs("div", {
154
160
  className: "flex flex-col gap-4",
155
161
  children: [
@@ -166,24 +172,16 @@ function Applied({ result }) {
166
172
  /* @__PURE__ */ jsx(Typography, {
167
173
  variant: "body2",
168
174
  className: "font-medium mb-1",
169
- children: partialApplyHeading(result)
175
+ children: partialApplyHeading(result, t)
170
176
  }),
171
177
  /* @__PURE__ */ jsx(Typography, {
172
178
  variant: "body2",
173
179
  children: result.applyError
174
180
  }),
175
- /* @__PURE__ */ jsxs(Typography, {
181
+ /* @__PURE__ */ jsx(Typography, {
176
182
  variant: "body2",
177
183
  className: "mt-2",
178
- children: [
179
- "The commit is on ",
180
- /* @__PURE__ */ jsx(Typography, {
181
- component: "code",
182
- variant: "mono",
183
- children: result.committed.branch
184
- }),
185
- " either way, so whatever did not run will be applied on the next boot."
186
- ]
184
+ children: t("schema_change_commit_holds", { branch: result.committed.branch })
187
185
  })
188
186
  ]
189
187
  }),
@@ -192,13 +190,14 @@ function Applied({ result }) {
192
190
  /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
193
191
  variant: "label",
194
192
  color: "secondary",
195
- children: "Committed"
193
+ children: t("schema_change_committed")
196
194
  }), /* @__PURE__ */ jsxs("div", {
197
195
  className: cls(codeBlock, "mt-1"),
198
196
  children: [
199
- result.committed.sha.slice(0, 9),
200
- " on ",
201
- result.committed.branch,
197
+ t("schema_change_committed_on", {
198
+ sha: result.committed.sha.slice(0, 9),
199
+ branch: result.committed.branch
200
+ }),
202
201
  "\n",
203
202
  result.committed.files.map((file) => ` ${file}`).join("\n")
204
203
  ]
@@ -207,14 +206,19 @@ function Applied({ result }) {
207
206
  });
208
207
  }
209
208
  function SchemaChangeDialog({ open, collectionId, plan, planError, result, applying, applyError, onConfirm, onRetry, onSourceOnly, onClose, applyRefusedBecause, target }) {
209
+ const { t } = useTranslation();
210
210
  const verdict = plan?.verdict;
211
211
  const statements = plan?.statements.length ?? 0;
212
212
  const commitOnly = Boolean(plan?.applicable) && statements === 0;
213
213
  const copy = verdict === "safe" && commitOnly ? {
214
- title: "Ready to commit",
215
- body: plan && plan.changes.length > 0 ? "Nothing runs against the database now. Each change below says what it does and when it takes effect." : "This changes what your project declares. Nothing runs against the database — there is no schema change to make.",
214
+ title: t("schema_change_commit_only_title"),
215
+ body: plan && plan.changes.length > 0 ? t("schema_change_commit_only_body") : t("schema_change_commit_only_body_no_changes"),
216
216
  color: "info"
217
- } : verdict ? VERDICT_COPY[verdict] : void 0;
217
+ } : verdict ? {
218
+ title: t(VERDICT_COPY[verdict].titleKey),
219
+ body: t(VERDICT_COPY[verdict].bodyKey),
220
+ color: VERDICT_COPY[verdict].color
221
+ } : void 0;
218
222
  return /* @__PURE__ */ jsxs(Dialog, {
219
223
  open,
220
224
  onOpenChange: (value) => {
@@ -224,7 +228,7 @@ function SchemaChangeDialog({ open, collectionId, plan, planError, result, apply
224
228
  children: [
225
229
  /* @__PURE__ */ jsxs(DialogTitle, {
226
230
  className: "flex items-center gap-2",
227
- children: [result ? result.sourceOnly ? "Schema change committed" : "Schema change applied" : "Review schema change", /* @__PURE__ */ jsx(Typography, {
231
+ children: [result ? result.sourceOnly ? t("schema_change_title_committed") : t("schema_change_title_applied") : t("schema_change_title_review"), /* @__PURE__ */ jsx(Typography, {
228
232
  component: "code",
229
233
  variant: "mono",
230
234
  color: "secondary",
@@ -239,7 +243,7 @@ function SchemaChangeDialog({ open, collectionId, plan, planError, result, apply
239
243
  children: [/* @__PURE__ */ jsx(Typography, {
240
244
  variant: "body2",
241
245
  className: "font-medium mb-1",
242
- children: "The change could not be planned"
246
+ children: t("schema_change_plan_failed")
243
247
  }), /* @__PURE__ */ jsx(Typography, {
244
248
  variant: "body2",
245
249
  children: planError
@@ -250,7 +254,7 @@ function SchemaChangeDialog({ open, collectionId, plan, planError, result, apply
250
254
  children: [/* @__PURE__ */ jsx(CircularProgress, { size: "small" }), /* @__PURE__ */ jsx(Typography, {
251
255
  variant: "body2",
252
256
  color: "secondary",
253
- children: "Working out what this change would do…"
257
+ children: t("schema_change_planning")
254
258
  })]
255
259
  }),
256
260
  result && /* @__PURE__ */ jsx(Applied, { result }),
@@ -276,14 +280,14 @@ function SchemaChangeDialog({ open, collectionId, plan, planError, result, apply
276
280
  plan.changes.length === 0 && /* @__PURE__ */ jsx(Typography, {
277
281
  variant: "body2",
278
282
  color: "secondary",
279
- children: "Nothing here changes the shape of your data. Only the collection source changes, and it is committed."
283
+ children: t("schema_change_source_only_changes")
280
284
  }),
281
285
  !plan.applicable && onSourceOnly && /* @__PURE__ */ jsxs(Alert, {
282
286
  color: "warning",
283
287
  children: [/* @__PURE__ */ jsx(Typography, {
284
288
  variant: "body2",
285
289
  className: "font-medium mb-1",
286
- children: "Edit source only: commit the collection, leave the database"
290
+ children: t("schema_change_source_only_title")
287
291
  }), /* @__PURE__ */ jsx("ul", {
288
292
  className: "space-y-1",
289
293
  children: plan.changes.filter((change) => change.verdict !== "safe" && change.sourceOnly).map((change, index) => /* @__PURE__ */ jsx("li", {
@@ -300,7 +304,7 @@ function SchemaChangeDialog({ open, collectionId, plan, planError, result, apply
300
304
  size: "smallest",
301
305
  colorScheme: VERDICT_CHIP[change.verdict].scheme,
302
306
  className: "shrink-0 mt-0.5",
303
- children: VERDICT_CHIP[change.verdict].label
307
+ children: t(VERDICT_CHIP[change.verdict].labelKey)
304
308
  }), /* @__PURE__ */ jsxs("div", {
305
309
  className: "min-w-0",
306
310
  children: [/* @__PURE__ */ jsx(Typography, {
@@ -322,14 +326,14 @@ function SchemaChangeDialog({ open, collectionId, plan, planError, result, apply
322
326
  children: [/* @__PURE__ */ jsx(Typography, {
323
327
  variant: "body2",
324
328
  className: "font-medium mb-1",
325
- children: "You can preview this change, but not apply it"
329
+ children: t("schema_change_preview_only")
326
330
  }), /* @__PURE__ */ jsx(Typography, {
327
331
  variant: "body2",
328
332
  children: applyRefusedBecause
329
333
  })]
330
334
  }),
331
335
  /* @__PURE__ */ jsx(Details, {
332
- summary: "Statements that will run",
336
+ summary: t("schema_change_statements"),
333
337
  count: plan.statements.length,
334
338
  children: /* @__PURE__ */ jsx("div", {
335
339
  className: codeBlock,
@@ -337,7 +341,7 @@ function SchemaChangeDialog({ open, collectionId, plan, planError, result, apply
337
341
  })
338
342
  }),
339
343
  /* @__PURE__ */ jsx(Details, {
340
- summary: "Files that will be committed",
344
+ summary: t("schema_change_files"),
341
345
  count: plan.files.length,
342
346
  children: /* @__PURE__ */ jsx("div", {
343
347
  className: codeBlock,
@@ -345,7 +349,7 @@ function SchemaChangeDialog({ open, collectionId, plan, planError, result, apply
345
349
  })
346
350
  }),
347
351
  /* @__PURE__ */ jsx(Details, {
348
- summary: "Commit message",
352
+ summary: t("schema_change_message"),
349
353
  count: plan.message ? 1 : 0,
350
354
  children: /* @__PURE__ */ jsx("div", {
351
355
  className: codeBlock,
@@ -370,25 +374,25 @@ function SchemaChangeDialog({ open, collectionId, plan, planError, result, apply
370
374
  variant: "text",
371
375
  onClick: onClose,
372
376
  disabled: applying,
373
- children: result ? "Close" : "Cancel"
377
+ children: result ? t("close") : t("cancel")
374
378
  }),
375
379
  !result && planError && onRetry && /* @__PURE__ */ jsx(Button, {
376
380
  variant: "outlined",
377
381
  onClick: onRetry,
378
- children: "Try again"
382
+ children: t("retry")
379
383
  }),
380
384
  !result && plan && !plan.applicable && onSourceOnly && /* @__PURE__ */ jsx(Button, {
381
385
  variant: "outlined",
382
386
  onClick: onSourceOnly,
383
387
  disabled: applying,
384
- children: "Edit source only"
388
+ children: t("schema_change_edit_source_only")
385
389
  }),
386
390
  !result && /* @__PURE__ */ jsx(Button, {
387
391
  variant: "filled",
388
392
  color: "primary",
389
393
  onClick: onConfirm,
390
394
  disabled: !plan?.applicable || applying || Boolean(applyRefusedBecause),
391
- children: applying ? commitOnly ? "Committing…" : "Applying…" : commitOnly ? "Commit" : "Commit and apply"
395
+ children: applying ? commitOnly ? t("schema_change_committing") : t("schema_change_applying") : commitOnly ? t("schema_change_commit") : t("schema_change_commit_and_apply")
392
396
  })
393
397
  ] })
394
398
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaChangeDialog.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/SchemaChangeDialog.tsx"],"sourcesContent":["/**\n * What a schema change would do, before it does it.\n *\n * The dialog exists because a schema change has three possible verdicts and two\n * of them are refusals. Without a preview, the only way to discover that a\n * change is refused is to press a button on a live database and read what comes\n * back — which is a fine way to learn and a poor way to work.\n *\n * ## What it shows, in the order somebody reads it\n *\n * The verdict first, in a sentence, because it decides whether the rest is\n * worth reading. Then the changes, each with what it does and — when it is\n * refused — what to do instead. Then the things that are easy to skip past and\n * expensive to have skipped: constraints the change asks for that the database\n * will not end up enforcing. The SQL and the file list come last, collapsed,\n * for the reader who wants them; they are the evidence, not the summary.\n *\n * ## Why the button says \"Commit and apply\"\n *\n * Because that is the order, and the order is the feature. The commit lands\n * first, so a failed apply leaves the repository ahead of the database — the\n * ordinary state of every project between an edit and a deploy, which the next\n * boot reconciles. A button labelled \"Save\" would be describing a different,\n * worse thing.\n */\nimport React from \"react\";\nimport {\n Alert,\n Button,\n Chip,\n CircularProgress,\n cls,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n ExpandablePanel,\n Typography\n} from \"@rebasepro/ui\";\n\nimport type { LiveSchemaPlan, LiveSchemaResult, WithheldConstraint } from \"../../liveSchemaClient\";\n\nexport interface SchemaChangeDialogProps {\n open: boolean;\n /** The collection being changed, for the title. */\n collectionId: string;\n /** `undefined` while the plan is still being fetched. */\n plan?: LiveSchemaPlan;\n /** Set when planning itself failed — a network error, a refusal, a 500. */\n planError?: string;\n /** Set once the change has been applied, which turns this into a receipt. */\n result?: LiveSchemaResult;\n applying: boolean;\n /** Set when the apply threw rather than returning a result. */\n applyError?: string;\n onConfirm: () => void;\n /**\n * Ask again, when planning failed.\n *\n * A dropped connection should cost a click, not the whole wizard. The form\n * is already filled in, and making somebody redo it for a transient failure\n * teaches them to distrust the preview rather than the network.\n */\n onRetry?: () => void;\n /**\n * Write the collection source and leave the database alone.\n *\n * Offered only when the change is refused, and it is what keeps the editor\n * usable while it is. Removing a property is the ordinary case: the ensure\n * path has no `DROP COLUMN`, so a removal can never be applied — and\n * refusing the whole save over it would mean a dev could no longer delete a\n * field from a collection they are still designing.\n *\n * This is exactly what the editor did before live editing existed, so it is\n * not a new hazard; the difference is that it now says what it leaves\n * behind instead of reporting success.\n */\n onSourceOnly?: () => void;\n onClose: () => void;\n /**\n * Why this caller may preview but not apply, when that is the case.\n *\n * A person signed in with an API key, most often. Shown next to a disabled\n * button so the refusal arrives while they are deciding rather than after\n * they have decided.\n */\n applyRefusedBecause?: string;\n /**\n * Where a confirmation would land — `owner/repo` and a branch.\n *\n * On screen before the button, not in the receipt after it. A commit is\n * going somewhere, and which branch it is going to is the one fact somebody\n * cannot recover from being wrong about.\n */\n target?: { repository?: string; branch?: string };\n}\n\ntype Verdict = LiveSchemaPlan[\"verdict\"];\n\n/** What the verdict means, in the words the reader needs rather than the enum's. */\n/**\n * What the verdict means, in the words the reader needs rather than the enum's.\n *\n * `safe` is written twice because the two cases are genuinely different, and\n * saying \"can be made against the running database\" when nothing will be run is\n * the kind of small lie that teaches people to stop reading. A document\n * database has no table to alter, and a change that needs no DDL on a\n * relational one is in the same position: the commit *is* the change.\n */\nconst VERDICT_COPY: Record<Verdict, { title: string; body: string; color: \"info\" | \"warning\" | \"error\" }> = {\n safe: {\n title: \"Ready to apply\",\n body: \"Every change here can be made against the running database.\",\n color: \"info\"\n },\n diverges: {\n title: \"This would leave the database out of step\",\n body: \"The change can be written, but the database will not end up matching it. \" +\n \"The details below say which part, and what would make it applicable.\",\n color: \"warning\"\n },\n \"needs-migration\": {\n title: \"This needs a migration\",\n body: \"Some of this cannot be done to a running database at all — it drops or rewrites \" +\n \"something, and that belongs in a migration somebody has read.\",\n color: \"error\"\n }\n};\n\nconst VERDICT_CHIP: Record<Verdict, { label: string; scheme: \"greenLighter\" | \"orangeLighter\" | \"redLighter\" }> = {\n safe: { label: \"safe\", scheme: \"greenLighter\" },\n diverges: { label: \"diverges\", scheme: \"orangeLighter\" },\n \"needs-migration\": { label: \"needs migration\", scheme: \"redLighter\" }\n};\n\nconst monospace = \"font-mono text-xs leading-relaxed\";\nconst codeBlock = cls(\n monospace,\n \"bg-surface-raised rounded-md p-3 overflow-x-auto whitespace-pre\"\n);\n\n/** A disclosure that starts closed. The evidence, for the reader who wants it. */\nfunction Details({ summary, count, children }: {\n summary: string;\n count: number;\n children: React.ReactNode;\n}) {\n if (count === 0) return null;\n return (\n <ExpandablePanel\n initiallyExpanded={false}\n titleClassName=\"!min-h-0 !py-2 px-3\"\n innerClassName=\"p-3\"\n title={<Typography variant=\"body2\" color=\"secondary\">{summary} ({count})</Typography>}\n >\n {children}\n </ExpandablePanel>\n );\n}\n\n/**\n * What still has to happen after this lands.\n *\n * Above the evidence and below the changes, because it is not a refusal and not\n * a detail: the change will apply, and something outside this dialog still has\n * to be done or a later environment will differ from this one.\n */\nfunction FollowUp({ items }: { items: string[] }) {\n if (items.length === 0) return null;\n return (\n <Alert color=\"info\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {items.length === 1 ? \"One thing to do afterwards\" : \"To do afterwards\"}\n </Typography>\n <ul className=\"space-y-2\">\n {items.map(item => (\n <li key={item} className=\"text-sm\">{item}</li>\n ))}\n </ul>\n </Alert>\n );\n}\n\n/**\n * The destination, short enough to read at a glance.\n *\n * A remote repository already reports itself as `owner/repo`, which is exactly\n * what somebody recognises. A local one reports an absolute path, and the\n * leading directories are the part nobody needs: what matters is which\n * checkout, and its name says that.\n */\nfunction repositoryLabel(repository: string): string {\n if (!repository.startsWith(\"/\")) return repository;\n return repository.split(\"/\").filter(Boolean).pop() ?? repository;\n}\n\nfunction WithheldConstraints({ constraints }: { constraints: WithheldConstraint[] }) {\n if (constraints.length === 0) return null;\n return (\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {constraints.length === 1\n ? \"One constraint will not be enforced\"\n : `${constraints.length} constraints will not be enforced`}\n </Typography>\n <ul className=\"space-y-2\">\n {constraints.map(constraint => (\n <li key={constraint.target} className=\"text-sm\">\n <Typography component=\"code\" variant=\"mono\" className=\"bg-surface-raised px-1 rounded-md\">\n {constraint.target}\n </Typography>\n <Typography variant=\"body2\" className=\"mt-1\">{constraint.reason}</Typography>\n <Typography variant=\"body2\" color=\"secondary\" className=\"mt-1\">\n {constraint.remedy}\n </Typography>\n </li>\n ))}\n </ul>\n </Alert>\n );\n}\n\n/**\n * How far a failed apply got, in a heading.\n *\n * The statements run one at a time with no transaction around them, so only\n * \"none ran\" means the database is as it was.\n */\nfunction partialApplyHeading(result: LiveSchemaResult): string {\n const ran = result.appliedStatements;\n if (ran === 0) return \"The database was not changed\";\n if (ran === undefined) return \"The database may have been changed in part\";\n return `${ran} of ${result.statements.length} statements ran, then one failed`;\n}\n\n/** The receipt. Shown in place of the plan once the change has been applied. */\nfunction Applied({ result }: { result: LiveSchemaResult }) {\n return (\n <div className=\"flex flex-col gap-4\">\n <Alert color={result.applied || result.sourceOnly ? \"success\" : \"warning\"}>\n <Typography variant=\"body2\">{result.summary}</Typography>\n </Alert>\n\n {!result.applied && !result.sourceOnly && result.applyError && (\n // Deliberately not an error state. The commit landed, which is\n // the durable half; the database is now behind the repository,\n // which is where every project sits between an edit and a\n // deploy, and boot reconciles it.\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {partialApplyHeading(result)}\n </Typography>\n <Typography variant=\"body2\">{result.applyError}</Typography>\n <Typography variant=\"body2\" className=\"mt-2\">\n The commit is on <Typography component=\"code\" variant=\"mono\">{result.committed.branch}</Typography> either way, so\n whatever did not run will be applied on the next boot.\n </Typography>\n </Alert>\n )}\n\n <WithheldConstraints constraints={result.withheldConstraints ?? []}/>\n <FollowUp items={result.followUp ?? []}/>\n\n <div>\n <Typography variant=\"label\" color=\"secondary\">Committed</Typography>\n <div className={cls(codeBlock, \"mt-1\")}>\n {result.committed.sha.slice(0, 9)} on {result.committed.branch}\n {\"\\n\"}\n {result.committed.files.map(file => ` ${file}`).join(\"\\n\")}\n </div>\n </div>\n </div>\n );\n}\n\nexport function SchemaChangeDialog({\n open,\n collectionId,\n plan,\n planError,\n result,\n applying,\n applyError,\n onConfirm,\n onRetry,\n onSourceOnly,\n onClose,\n applyRefusedBecause,\n target\n}: SchemaChangeDialogProps) {\n\n const verdict = plan?.verdict;\n const statements = plan?.statements.length ?? 0;\n\n // \"Commit\" only when we positively know there is nothing to apply: a plan\n // that is going ahead and has no statements. A *refused* plan also has none\n // — because it will not run — and labelling that button \"Commit\" would be\n // describing the change it is refusing to make. Unknown reads as the fuller\n // action, which is the safer way to be wrong about a label.\n const commitOnly = Boolean(plan?.applicable) && statements === 0;\n\n // Described from the plan rather than from an assumption about the engine.\n // A document database runs nothing; so does a relational change that only\n // moves source. Both are a commit, and calling either one \"apply\" would be\n // describing something that does not happen.\n // A plan with changes and no statements still changes something — a\n // security rule takes effect when the server next starts — so \"there is\n // no schema change to make\" is said only when there is none.\n const copy = verdict === \"safe\" && commitOnly\n ? {\n title: \"Ready to commit\",\n body: plan && plan.changes.length > 0\n ? \"Nothing runs against the database now. Each change below says what it does and \" +\n \"when it takes effect.\"\n : \"This changes what your project declares. Nothing runs against the database — \" +\n \"there is no schema change to make.\",\n color: \"info\" as const\n }\n : verdict\n ? VERDICT_COPY[verdict]\n : undefined;\n\n return (\n <Dialog open={open} onOpenChange={value => { if (!value) onClose(); }} maxWidth=\"3xl\">\n <DialogTitle className=\"flex items-center gap-2\">\n {result ? (result.sourceOnly ? \"Schema change committed\" : \"Schema change applied\") : \"Review schema change\"}\n <Typography component=\"code\" variant=\"mono\" color=\"secondary\">\n {collectionId}\n </Typography>\n </DialogTitle>\n\n <DialogContent className=\"flex flex-col gap-4\">\n {planError && (\n <Alert color=\"error\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n The change could not be planned\n </Typography>\n <Typography variant=\"body2\">{planError}</Typography>\n </Alert>\n )}\n\n {!plan && !planError && !result && (\n <div className=\"flex items-center gap-3 py-6\">\n <CircularProgress size=\"small\"/>\n <Typography variant=\"body2\" color=\"secondary\">\n Working out what this change would do…\n </Typography>\n </div>\n )}\n\n {result && <Applied result={result}/>}\n\n {plan && !result && copy && (\n <>\n <Alert color={copy.color}>\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {copy.title}\n </Typography>\n <Typography variant=\"body2\">{copy.body}</Typography>\n </Alert>\n\n {applyError && (\n <Alert color=\"error\">\n <Typography variant=\"body2\">{applyError}</Typography>\n </Alert>\n )}\n\n {plan.changes.length === 0 && (\n <Typography variant=\"body2\" color=\"secondary\">\n Nothing here changes the shape of your data. Only the collection\n source changes, and it is committed.\n </Typography>\n )}\n\n {!plan.applicable && onSourceOnly && (\n // Said per change: what a removal leaves behind is\n // not what a type change or a new required field\n // does, and the one that breaks every insert has to\n // be on screen before the button is pressed.\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n Edit source only: commit the collection, leave the database\n </Typography>\n <ul className=\"space-y-1\">\n {plan.changes.filter(change => change.verdict !== \"safe\" && change.sourceOnly).map((change, index) => (\n <li key={`${change.property ?? change.collection}.${index}`} className=\"text-sm\">\n {change.sourceOnly}\n </li>\n ))}\n </ul>\n </Alert>\n )}\n\n {plan.changes.length > 0 && (\n <ul className=\"flex flex-col gap-3\">\n {plan.changes.map((change, index) => (\n <li\n key={`${change.collection}.${change.property ?? \"\"}.${index}`}\n className=\"flex gap-3\"\n >\n <Chip\n size=\"smallest\"\n colorScheme={VERDICT_CHIP[change.verdict].scheme}\n className=\"shrink-0 mt-0.5\"\n >\n {VERDICT_CHIP[change.verdict].label}\n </Chip>\n <div className=\"min-w-0\">\n <Typography variant=\"body2\">{change.detail}</Typography>\n {change.remedy && (\n <Typography\n variant=\"body2\"\n color=\"secondary\"\n className=\"mt-1\"\n >\n {change.remedy}\n </Typography>\n )}\n </div>\n </li>\n ))}\n </ul>\n )}\n\n <WithheldConstraints constraints={plan.withheldConstraints ?? []}/>\n <FollowUp items={plan.followUp ?? []}/>\n\n {applyRefusedBecause && (\n <Alert color=\"info\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n You can preview this change, but not apply it\n </Typography>\n <Typography variant=\"body2\">{applyRefusedBecause}</Typography>\n </Alert>\n )}\n\n <Details summary=\"Statements that will run\" count={plan.statements.length}>\n <div className={codeBlock}>{plan.statements.join(\"\\n\")}</div>\n </Details>\n\n <Details summary=\"Files that will be committed\" count={plan.files.length}>\n <div className={codeBlock}>{plan.files.join(\"\\n\")}</div>\n </Details>\n\n <Details summary=\"Commit message\" count={plan.message ? 1 : 0}>\n <div className={codeBlock}>{plan.message}</div>\n </Details>\n </>\n )}\n </DialogContent>\n\n <DialogActions>\n {!result && target?.repository && (\n <Typography variant=\"caption\" color=\"secondary\" className={cls(monospace, \"mr-auto truncate\")}>\n → {repositoryLabel(target.repository)}{target.branch ? ` · ${target.branch}` : \"\"}\n </Typography>\n )}\n <Button variant=\"text\" onClick={onClose} disabled={applying}>\n {result ? \"Close\" : \"Cancel\"}\n </Button>\n {!result && planError && onRetry && (\n <Button variant=\"outlined\" onClick={onRetry}>\n Try again\n </Button>\n )}\n {!result && plan && !plan.applicable && onSourceOnly && (\n <Button variant=\"outlined\" onClick={onSourceOnly} disabled={applying}>\n Edit source only\n </Button>\n )}\n {!result && (\n <Button\n variant=\"filled\"\n color=\"primary\"\n onClick={onConfirm}\n // `applicable` is the server's word, not a\n // re-derivation from the verdicts on screen:\n // `applySchemaChange` re-checks it before it writes\n // anything, so a button that disagreed would only\n // produce the same refusal one click later. The same\n // goes for the permission — `/apply` checks it too, and\n // this only saves somebody the round trip.\n disabled={!plan?.applicable || applying || Boolean(applyRefusedBecause)}\n >\n {applying\n ? (commitOnly ? \"Committing…\" : \"Applying…\")\n : (commitOnly ? \"Commit\" : \"Commit and apply\")}\n </Button>\n )}\n </DialogActions>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA6GA,IAAM,eAAsG;CACxG,MAAM;EACF,OAAO;EACP,MAAM;EACN,OAAO;CACX;CACA,UAAU;EACN,OAAO;EACP,MAAM;EAEN,OAAO;CACX;CACA,mBAAmB;EACf,OAAO;EACP,MAAM;EAEN,OAAO;CACX;AACJ;AAEA,IAAM,eAA4G;CAC9G,MAAM;EAAE,OAAO;EAAQ,QAAQ;CAAe;CAC9C,UAAU;EAAE,OAAO;EAAY,QAAQ;CAAgB;CACvD,mBAAmB;EAAE,OAAO;EAAmB,QAAQ;CAAa;AACxE;AAEA,IAAM,YAAY;AAClB,IAAM,YAAY,IACd,WACA,iEACJ;;AAGA,SAAS,QAAQ,EAAE,SAAS,OAAO,YAIhC;CACC,IAAI,UAAU,GAAG,OAAO;CACxB,OACI,oBAAC,iBAAD;EACI,mBAAmB;EACnB,gBAAe;EACf,gBAAe;EACf,OAAO,qBAAC,YAAD;GAAY,SAAQ;GAAQ,OAAM;aAAlC;IAA+C;IAAQ;IAAG;IAAM;GAAa;;EAEnF;CACY,CAAA;AAEzB;;;;;;;;AASA,SAAS,SAAS,EAAE,S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
+ {"version":3,"file":"SchemaChangeDialog.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/SchemaChangeDialog.tsx"],"sourcesContent":["/**\n * What a schema change would do, before it does it.\n *\n * The dialog exists because a schema change has three possible verdicts and two\n * of them are refusals. Without a preview, the only way to discover that a\n * change is refused is to press a button on a live database and read what comes\n * back — which is a fine way to learn and a poor way to work.\n *\n * ## What it shows, in the order somebody reads it\n *\n * The verdict first, in a sentence, because it decides whether the rest is\n * worth reading. Then the changes, each with what it does and — when it is\n * refused — what to do instead. Then the things that are easy to skip past and\n * expensive to have skipped: constraints the change asks for that the database\n * will not end up enforcing. The SQL and the file list come last, collapsed,\n * for the reader who wants them; they are the evidence, not the summary.\n *\n * ## Why the button says \"Commit and apply\"\n *\n * Because that is the order, and the order is the feature. The commit lands\n * first, so a failed apply leaves the repository ahead of the database — the\n * ordinary state of every project between an edit and a deploy, which the next\n * boot reconciles. A button labelled \"Save\" would be describing a different,\n * worse thing.\n */\nimport React from \"react\";\nimport {\n Alert,\n Button,\n Chip,\n CircularProgress,\n cls,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n ExpandablePanel,\n Typography\n} from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\n\nimport type { LiveSchemaPlan, LiveSchemaResult, WithheldConstraint } from \"../../liveSchemaClient\";\n\nexport interface SchemaChangeDialogProps {\n open: boolean;\n /** The collection being changed, for the title. */\n collectionId: string;\n /** `undefined` while the plan is still being fetched. */\n plan?: LiveSchemaPlan;\n /** Set when planning itself failed — a network error, a refusal, a 500. */\n planError?: string;\n /** Set once the change has been applied, which turns this into a receipt. */\n result?: LiveSchemaResult;\n applying: boolean;\n /** Set when the apply threw rather than returning a result. */\n applyError?: string;\n onConfirm: () => void;\n /**\n * Ask again, when planning failed.\n *\n * A dropped connection should cost a click, not the whole wizard. The form\n * is already filled in, and making somebody redo it for a transient failure\n * teaches them to distrust the preview rather than the network.\n */\n onRetry?: () => void;\n /**\n * Write the collection source and leave the database alone.\n *\n * Offered only when the change is refused, and it is what keeps the editor\n * usable while it is. Removing a property is the ordinary case: the ensure\n * path has no `DROP COLUMN`, so a removal can never be applied — and\n * refusing the whole save over it would mean a dev could no longer delete a\n * field from a collection they are still designing.\n *\n * This is exactly what the editor did before live editing existed, so it is\n * not a new hazard; the difference is that it now says what it leaves\n * behind instead of reporting success.\n */\n onSourceOnly?: () => void;\n onClose: () => void;\n /**\n * Why this caller may preview but not apply, when that is the case.\n *\n * A person signed in with an API key, most often. Shown next to a disabled\n * button so the refusal arrives while they are deciding rather than after\n * they have decided.\n */\n applyRefusedBecause?: string;\n /**\n * Where a confirmation would land — `owner/repo` and a branch.\n *\n * On screen before the button, not in the receipt after it. A commit is\n * going somewhere, and which branch it is going to is the one fact somebody\n * cannot recover from being wrong about.\n */\n target?: { repository?: string; branch?: string };\n}\n\ntype Verdict = LiveSchemaPlan[\"verdict\"];\n\ntype Translate = ReturnType<typeof useTranslation>[\"t\"];\n\n/**\n * What the verdict means, in the words the reader needs rather than the enum's.\n *\n * `safe` is written twice because the two cases are genuinely different, and\n * saying \"can be made against the running database\" when nothing will be run is\n * the kind of small lie that teaches people to stop reading. A document\n * database has no table to alter, and a change that needs no DDL on a\n * relational one is in the same position: the commit *is* the change.\n */\nconst VERDICT_COPY: Record<Verdict, { titleKey: string; bodyKey: string; color: \"info\" | \"warning\" | \"error\" }> = {\n safe: {\n titleKey: \"schema_change_verdict_safe_title\",\n bodyKey: \"schema_change_verdict_safe_body\",\n color: \"info\"\n },\n diverges: {\n titleKey: \"schema_change_verdict_diverges_title\",\n bodyKey: \"schema_change_verdict_diverges_body\",\n color: \"warning\"\n },\n \"needs-migration\": {\n titleKey: \"schema_change_verdict_migration_title\",\n bodyKey: \"schema_change_verdict_migration_body\",\n color: \"error\"\n }\n};\n\nconst VERDICT_CHIP: Record<Verdict, { labelKey: string; scheme: \"greenLighter\" | \"orangeLighter\" | \"redLighter\" }> = {\n safe: { labelKey: \"schema_change_chip_safe\", scheme: \"greenLighter\" },\n diverges: { labelKey: \"schema_change_chip_diverges\", scheme: \"orangeLighter\" },\n \"needs-migration\": { labelKey: \"schema_change_chip_migration\", scheme: \"redLighter\" }\n};\n\nconst monospace = \"font-mono text-xs leading-relaxed\";\nconst codeBlock = cls(\n monospace,\n \"bg-surface-raised rounded-md p-3 overflow-x-auto whitespace-pre\"\n);\n\n/** A disclosure that starts closed. The evidence, for the reader who wants it. */\nfunction Details({ summary, count, children }: {\n summary: string;\n count: number;\n children: React.ReactNode;\n}) {\n if (count === 0) return null;\n return (\n <ExpandablePanel\n initiallyExpanded={false}\n titleClassName=\"!min-h-0 !py-2 px-3\"\n innerClassName=\"p-3\"\n title={<Typography variant=\"body2\" color=\"secondary\">{summary} ({count})</Typography>}\n >\n {children}\n </ExpandablePanel>\n );\n}\n\n/**\n * What still has to happen after this lands.\n *\n * Above the evidence and below the changes, because it is not a refusal and not\n * a detail: the change will apply, and something outside this dialog still has\n * to be done or a later environment will differ from this one.\n */\nfunction FollowUp({ items }: { items: string[] }) {\n const { t } = useTranslation();\n if (items.length === 0) return null;\n return (\n <Alert color=\"info\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {items.length === 1 ? t(\"schema_change_follow_up_one\") : t(\"schema_change_follow_up\")}\n </Typography>\n <ul className=\"space-y-2\">\n {items.map(item => (\n <li key={item} className=\"text-sm\">{item}</li>\n ))}\n </ul>\n </Alert>\n );\n}\n\n/**\n * The destination, short enough to read at a glance.\n *\n * A remote repository already reports itself as `owner/repo`, which is exactly\n * what somebody recognises. A local one reports an absolute path, and the\n * leading directories are the part nobody needs: what matters is which\n * checkout, and its name says that.\n */\nfunction repositoryLabel(repository: string): string {\n if (!repository.startsWith(\"/\")) return repository;\n return repository.split(\"/\").filter(Boolean).pop() ?? repository;\n}\n\nfunction WithheldConstraints({ constraints }: { constraints: WithheldConstraint[] }) {\n const { t } = useTranslation();\n if (constraints.length === 0) return null;\n return (\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {constraints.length === 1\n ? t(\"schema_change_withheld_one\")\n : t(\"schema_change_withheld_many\", { count: constraints.length })}\n </Typography>\n <ul className=\"space-y-2\">\n {constraints.map(constraint => (\n <li key={constraint.target} className=\"text-sm\">\n <Typography component=\"code\" variant=\"mono\" className=\"bg-surface-raised px-1 rounded-md\">\n {constraint.target}\n </Typography>\n <Typography variant=\"body2\" className=\"mt-1\">{constraint.reason}</Typography>\n <Typography variant=\"body2\" color=\"secondary\" className=\"mt-1\">\n {constraint.remedy}\n </Typography>\n </li>\n ))}\n </ul>\n </Alert>\n );\n}\n\n/**\n * How far a failed apply got, in a heading.\n *\n * The statements run one at a time with no transaction around them, so only\n * \"none ran\" means the database is as it was.\n */\nfunction partialApplyHeading(result: LiveSchemaResult, t: Translate): string {\n const ran = result.appliedStatements;\n if (ran === 0) return t(\"schema_change_db_not_changed\");\n if (ran === undefined) return t(\"schema_change_db_maybe_changed\");\n return t(\"schema_change_statements_partial\", { ran, total: result.statements.length });\n}\n\n/** The receipt. Shown in place of the plan once the change has been applied. */\nfunction Applied({ result }: { result: LiveSchemaResult }) {\n const { t } = useTranslation();\n return (\n <div className=\"flex flex-col gap-4\">\n <Alert color={result.applied || result.sourceOnly ? \"success\" : \"warning\"}>\n <Typography variant=\"body2\">{result.summary}</Typography>\n </Alert>\n\n {!result.applied && !result.sourceOnly && result.applyError && (\n // Deliberately not an error state. The commit landed, which is\n // the durable half; the database is now behind the repository,\n // which is where every project sits between an edit and a\n // deploy, and boot reconciles it.\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {partialApplyHeading(result, t)}\n </Typography>\n <Typography variant=\"body2\">{result.applyError}</Typography>\n <Typography variant=\"body2\" className=\"mt-2\">\n {t(\"schema_change_commit_holds\", { branch: result.committed.branch })}\n </Typography>\n </Alert>\n )}\n\n <WithheldConstraints constraints={result.withheldConstraints ?? []}/>\n <FollowUp items={result.followUp ?? []}/>\n\n <div>\n <Typography variant=\"label\" color=\"secondary\">{t(\"schema_change_committed\")}</Typography>\n <div className={cls(codeBlock, \"mt-1\")}>\n {t(\"schema_change_committed_on\", { sha: result.committed.sha.slice(0, 9), branch: result.committed.branch })}\n {\"\\n\"}\n {result.committed.files.map(file => ` ${file}`).join(\"\\n\")}\n </div>\n </div>\n </div>\n );\n}\n\nexport function SchemaChangeDialog({\n open,\n collectionId,\n plan,\n planError,\n result,\n applying,\n applyError,\n onConfirm,\n onRetry,\n onSourceOnly,\n onClose,\n applyRefusedBecause,\n target\n}: SchemaChangeDialogProps) {\n\n const { t } = useTranslation();\n const verdict = plan?.verdict;\n const statements = plan?.statements.length ?? 0;\n\n // \"Commit\" only when we positively know there is nothing to apply: a plan\n // that is going ahead and has no statements. A *refused* plan also has none\n // — because it will not run — and labelling that button \"Commit\" would be\n // describing the change it is refusing to make. Unknown reads as the fuller\n // action, which is the safer way to be wrong about a label.\n const commitOnly = Boolean(plan?.applicable) && statements === 0;\n\n // Described from the plan rather than from an assumption about the engine.\n // A document database runs nothing; so does a relational change that only\n // moves source. Both are a commit, and calling either one \"apply\" would be\n // describing something that does not happen.\n // A plan with changes and no statements still changes something — a\n // security rule takes effect when the server next starts — so \"there is\n // no schema change to make\" is said only when there is none.\n const copy = verdict === \"safe\" && commitOnly\n ? {\n title: t(\"schema_change_commit_only_title\"),\n body: plan && plan.changes.length > 0\n ? t(\"schema_change_commit_only_body\")\n : t(\"schema_change_commit_only_body_no_changes\"),\n color: \"info\" as const\n }\n : verdict\n ? {\n title: t(VERDICT_COPY[verdict].titleKey),\n body: t(VERDICT_COPY[verdict].bodyKey),\n color: VERDICT_COPY[verdict].color\n }\n : undefined;\n\n return (\n <Dialog open={open} onOpenChange={value => { if (!value) onClose(); }} maxWidth=\"3xl\">\n <DialogTitle className=\"flex items-center gap-2\">\n {result\n ? (result.sourceOnly ? t(\"schema_change_title_committed\") : t(\"schema_change_title_applied\"))\n : t(\"schema_change_title_review\")}\n <Typography component=\"code\" variant=\"mono\" color=\"secondary\">\n {collectionId}\n </Typography>\n </DialogTitle>\n\n <DialogContent className=\"flex flex-col gap-4\">\n {planError && (\n <Alert color=\"error\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {t(\"schema_change_plan_failed\")}\n </Typography>\n <Typography variant=\"body2\">{planError}</Typography>\n </Alert>\n )}\n\n {!plan && !planError && !result && (\n <div className=\"flex items-center gap-3 py-6\">\n <CircularProgress size=\"small\"/>\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"schema_change_planning\")}\n </Typography>\n </div>\n )}\n\n {result && <Applied result={result}/>}\n\n {plan && !result && copy && (\n <>\n <Alert color={copy.color}>\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {copy.title}\n </Typography>\n <Typography variant=\"body2\">{copy.body}</Typography>\n </Alert>\n\n {applyError && (\n <Alert color=\"error\">\n <Typography variant=\"body2\">{applyError}</Typography>\n </Alert>\n )}\n\n {plan.changes.length === 0 && (\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"schema_change_source_only_changes\")}\n </Typography>\n )}\n\n {!plan.applicable && onSourceOnly && (\n // Said per change: what a removal leaves behind is\n // not what a type change or a new required field\n // does, and the one that breaks every insert has to\n // be on screen before the button is pressed.\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {t(\"schema_change_source_only_title\")}\n </Typography>\n <ul className=\"space-y-1\">\n {plan.changes.filter(change => change.verdict !== \"safe\" && change.sourceOnly).map((change, index) => (\n <li key={`${change.property ?? change.collection}.${index}`} className=\"text-sm\">\n {change.sourceOnly}\n </li>\n ))}\n </ul>\n </Alert>\n )}\n\n {plan.changes.length > 0 && (\n <ul className=\"flex flex-col gap-3\">\n {plan.changes.map((change, index) => (\n <li\n key={`${change.collection}.${change.property ?? \"\"}.${index}`}\n className=\"flex gap-3\"\n >\n <Chip\n size=\"smallest\"\n colorScheme={VERDICT_CHIP[change.verdict].scheme}\n className=\"shrink-0 mt-0.5\"\n >\n {t(VERDICT_CHIP[change.verdict].labelKey)}\n </Chip>\n <div className=\"min-w-0\">\n <Typography variant=\"body2\">{change.detail}</Typography>\n {change.remedy && (\n <Typography\n variant=\"body2\"\n color=\"secondary\"\n className=\"mt-1\"\n >\n {change.remedy}\n </Typography>\n )}\n </div>\n </li>\n ))}\n </ul>\n )}\n\n <WithheldConstraints constraints={plan.withheldConstraints ?? []}/>\n <FollowUp items={plan.followUp ?? []}/>\n\n {applyRefusedBecause && (\n <Alert color=\"info\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {t(\"schema_change_preview_only\")}\n </Typography>\n <Typography variant=\"body2\">{applyRefusedBecause}</Typography>\n </Alert>\n )}\n\n <Details summary={t(\"schema_change_statements\")} count={plan.statements.length}>\n <div className={codeBlock}>{plan.statements.join(\"\\n\")}</div>\n </Details>\n\n <Details summary={t(\"schema_change_files\")} count={plan.files.length}>\n <div className={codeBlock}>{plan.files.join(\"\\n\")}</div>\n </Details>\n\n <Details summary={t(\"schema_change_message\")} count={plan.message ? 1 : 0}>\n <div className={codeBlock}>{plan.message}</div>\n </Details>\n </>\n )}\n </DialogContent>\n\n <DialogActions>\n {!result && target?.repository && (\n <Typography variant=\"caption\" color=\"secondary\" className={cls(monospace, \"mr-auto truncate\")}>\n → {repositoryLabel(target.repository)}{target.branch ? ` · ${target.branch}` : \"\"}\n </Typography>\n )}\n <Button variant=\"text\" onClick={onClose} disabled={applying}>\n {result ? t(\"close\") : t(\"cancel\")}\n </Button>\n {!result && planError && onRetry && (\n <Button variant=\"outlined\" onClick={onRetry}>\n {t(\"retry\")}\n </Button>\n )}\n {!result && plan && !plan.applicable && onSourceOnly && (\n <Button variant=\"outlined\" onClick={onSourceOnly} disabled={applying}>\n {t(\"schema_change_edit_source_only\")}\n </Button>\n )}\n {!result && (\n <Button\n variant=\"filled\"\n color=\"primary\"\n onClick={onConfirm}\n // `applicable` is the server's word, not a\n // re-derivation from the verdicts on screen:\n // `applySchemaChange` re-checks it before it writes\n // anything, so a button that disagreed would only\n // produce the same refusal one click later. The same\n // goes for the permission — `/apply` checks it too, and\n // this only saves somebody the round trip.\n disabled={!plan?.applicable || applying || Boolean(applyRefusedBecause)}\n >\n {applying\n ? (commitOnly ? t(\"schema_change_committing\") : t(\"schema_change_applying\"))\n : (commitOnly ? t(\"schema_change_commit\") : t(\"schema_change_commit_and_apply\"))}\n </Button>\n )}\n </DialogActions>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA+GA,IAAM,eAA4G;CAC9G,MAAM;EACF,UAAU;EACV,SAAS;EACT,OAAO;CACX;CACA,UAAU;EACN,UAAU;EACV,SAAS;EACT,OAAO;CACX;CACA,mBAAmB;EACf,UAAU;EACV,SAAS;EACT,OAAO;CACX;AACJ;AAEA,IAAM,eAA+G;CACjH,MAAM;EAAE,UAAU;EAA2B,QAAQ;CAAe;CACpE,UAAU;EAAE,UAAU;EAA+B,QAAQ;CAAgB;CAC7E,mBAAmB;EAAE,UAAU;EAAgC,QAAQ;CAAa;AACxF;AAEA,IAAM,YAAY;AAClB,IAAM,YAAY,IACd,WACA,iEACJ;;AAGA,SAAS,QAAQ,EAAE,SAAS,OAAO,YAIhC;CACC,IAAI,UAAU,GAAG,OAAO;CACxB,OACI,oBAAC,iBAAD;EACI,mBAAmB;EACnB,gBAAe;EACf,gBAAe;EACf,OAAO,qBAAC,YAAD;GAAY,SAAQ;GAAQ,OAAM;aAAlC;IAA+C;IAAQ;IAAG;IAAM;GAAa;;EAEnF;CACY,CAAA;AAEzB;;;;;;;;AASA,SAAS,SAAS,EAAE,SAA8B;CAC9C,MAAM,EAAE,MAAM,eAAe;CAC7B,IAAI,MAAM,WAAW,GAAG,OAAO;CAC/B,OACI,qBAAC,OAAD;EAAO,OAAM;YAAb,CACI,oBAAC,YAAD;GAAY,SAAQ;GAAQ,WAAU;aACjC,MAAM,WAAW,IAAI,EAAE,6BAA6B,IAAI,EAAE,yBAAyB;EAC5E,CAAA,GACZ,oBAAC,M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