@percher/core 0.4.9 → 0.4.11

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 (144) hide show
  1. package/dist/ai-files-manifest.d.ts +1 -1
  2. package/dist/commands/account.d.ts +1 -1
  3. package/dist/commands/account.js +2 -2
  4. package/dist/commands/admin-reconcile-routes.d.ts +1 -1
  5. package/dist/commands/ai-files.d.ts +2 -2
  6. package/dist/commands/ai-files.js +2 -2
  7. package/dist/commands/alerts.d.ts +1 -1
  8. package/dist/commands/app-resources.d.ts +1 -1
  9. package/dist/commands/app-resources.js +2 -2
  10. package/dist/commands/app-topology.d.ts +1 -1
  11. package/dist/commands/app-topology.js +2 -2
  12. package/dist/commands/billing.d.ts +1 -1
  13. package/dist/commands/billing.js +1 -1
  14. package/dist/commands/cache.d.ts +1 -1
  15. package/dist/commands/cache.js +2 -2
  16. package/dist/commands/capabilities.d.ts +1 -1
  17. package/dist/commands/claim.d.ts +1 -1
  18. package/dist/commands/claim.d.ts.map +1 -1
  19. package/dist/commands/claim.js +14 -9
  20. package/dist/commands/claim.js.map +1 -1
  21. package/dist/commands/create.d.ts +2 -2
  22. package/dist/commands/create.js +2 -2
  23. package/dist/commands/dashboard.d.ts +1 -1
  24. package/dist/commands/dashboard.js +2 -2
  25. package/dist/commands/data-export.d.ts +1 -1
  26. package/dist/commands/data-export.js +3 -3
  27. package/dist/commands/data.d.ts +1 -1
  28. package/dist/commands/data.js +2 -2
  29. package/dist/commands/delete.d.ts +1 -1
  30. package/dist/commands/delete.js +2 -2
  31. package/dist/commands/deploys.d.ts +1 -1
  32. package/dist/commands/deploys.js +2 -2
  33. package/dist/commands/dev.d.ts +1 -1
  34. package/dist/commands/dev.js +3 -3
  35. package/dist/commands/diagnose.d.ts +1 -1
  36. package/dist/commands/diagnose.js +2 -2
  37. package/dist/commands/diff.d.ts +1 -1
  38. package/dist/commands/diff.js +2 -2
  39. package/dist/commands/doctor.d.ts +3 -3
  40. package/dist/commands/doctor.js +4 -4
  41. package/dist/commands/domains.d.ts +1 -1
  42. package/dist/commands/domains.js +2 -2
  43. package/dist/commands/env.d.ts +1 -1
  44. package/dist/commands/env.js +2 -2
  45. package/dist/commands/export.d.ts +1 -1
  46. package/dist/commands/export.js +2 -2
  47. package/dist/commands/forgejo.d.ts +1 -1
  48. package/dist/commands/forgejo.js +2 -2
  49. package/dist/commands/generate.d.ts +1 -1
  50. package/dist/commands/generate.js +1 -1
  51. package/dist/commands/github.d.ts +1 -1
  52. package/dist/commands/github.js +2 -2
  53. package/dist/commands/import-project.d.ts +1 -1
  54. package/dist/commands/import-project.js +2 -2
  55. package/dist/commands/init.d.ts +2 -2
  56. package/dist/commands/init.js +3 -3
  57. package/dist/commands/insights.d.ts +1 -1
  58. package/dist/commands/insights.js +2 -2
  59. package/dist/commands/inspect-link.d.ts +1 -1
  60. package/dist/commands/inspect-link.js +2 -2
  61. package/dist/commands/login.d.ts +1 -1
  62. package/dist/commands/login.js +1 -1
  63. package/dist/commands/logs.d.ts +1 -1
  64. package/dist/commands/logs.js +2 -2
  65. package/dist/commands/mcp.d.ts +1 -1
  66. package/dist/commands/migrate-supabase-map.d.ts +1 -1
  67. package/dist/commands/migrate-supabase-recipes.d.ts +28 -0
  68. package/dist/commands/migrate-supabase-recipes.d.ts.map +1 -0
  69. package/dist/commands/migrate-supabase-recipes.js +92 -0
  70. package/dist/commands/migrate-supabase-recipes.js.map +1 -0
  71. package/dist/commands/migrate-supabase-rewrite.d.ts +101 -0
  72. package/dist/commands/migrate-supabase-rewrite.d.ts.map +1 -0
  73. package/dist/commands/migrate-supabase-rewrite.js +459 -0
  74. package/dist/commands/migrate-supabase-rewrite.js.map +1 -0
  75. package/dist/commands/migrate-supabase-scaffold.d.ts +25 -0
  76. package/dist/commands/migrate-supabase-scaffold.d.ts.map +1 -0
  77. package/dist/commands/migrate-supabase-scaffold.js +234 -0
  78. package/dist/commands/migrate-supabase-scaffold.js.map +1 -0
  79. package/dist/commands/migrate-supabase-schema.d.ts +4 -4
  80. package/dist/commands/migrate-supabase-schema.js +4 -4
  81. package/dist/commands/migrate-supabase-scripts.d.ts +1 -1
  82. package/dist/commands/migrate-supabase-sdk.d.ts +34 -0
  83. package/dist/commands/migrate-supabase-sdk.d.ts.map +1 -1
  84. package/dist/commands/migrate-supabase-sdk.js +169 -0
  85. package/dist/commands/migrate-supabase-sdk.js.map +1 -1
  86. package/dist/commands/migrate-supabase-status.d.ts +92 -0
  87. package/dist/commands/migrate-supabase-status.d.ts.map +1 -0
  88. package/dist/commands/migrate-supabase-status.js +470 -0
  89. package/dist/commands/migrate-supabase-status.js.map +1 -0
  90. package/dist/commands/migrate-supabase-walker.d.ts +15 -1
  91. package/dist/commands/migrate-supabase-walker.d.ts.map +1 -1
  92. package/dist/commands/migrate-supabase-walker.js +49 -5
  93. package/dist/commands/migrate-supabase-walker.js.map +1 -1
  94. package/dist/commands/migrate-supabase.d.ts +2 -2
  95. package/dist/commands/migrate-supabase.js +1 -1
  96. package/dist/commands/open.d.ts +1 -1
  97. package/dist/commands/open.js +2 -2
  98. package/dist/commands/preview-branch.d.ts +1 -1
  99. package/dist/commands/preview-branch.js +2 -2
  100. package/dist/commands/publish-api-error.d.ts +1 -1
  101. package/dist/commands/publish-api-error.js +1 -1
  102. package/dist/commands/publish-failure.d.ts +3 -3
  103. package/dist/commands/publish-failure.js +3 -3
  104. package/dist/commands/publish.d.ts +3 -3
  105. package/dist/commands/publish.d.ts.map +1 -1
  106. package/dist/commands/publish.js +19 -21
  107. package/dist/commands/publish.js.map +1 -1
  108. package/dist/commands/push.d.ts +2 -2
  109. package/dist/commands/push.js +8 -8
  110. package/dist/commands/redeploy.d.ts +2 -2
  111. package/dist/commands/redeploy.js +4 -4
  112. package/dist/commands/rename.d.ts +1 -1
  113. package/dist/commands/rename.js +2 -2
  114. package/dist/commands/reproduce.d.ts +1 -1
  115. package/dist/commands/reproduce.js +1 -1
  116. package/dist/commands/reset-superuser.d.ts +1 -1
  117. package/dist/commands/reset-superuser.js +2 -2
  118. package/dist/commands/restore.d.ts +1 -1
  119. package/dist/commands/restore.js +2 -2
  120. package/dist/commands/resume.d.ts +1 -1
  121. package/dist/commands/resume.js +2 -2
  122. package/dist/commands/rollback.d.ts +1 -1
  123. package/dist/commands/rollback.js +2 -2
  124. package/dist/commands/sharing.d.ts +1 -1
  125. package/dist/commands/sharing.js +2 -2
  126. package/dist/commands/status.d.ts +1 -1
  127. package/dist/commands/transfers.d.ts +1 -1
  128. package/dist/commands/transfers.js +2 -2
  129. package/dist/commands/unsuspend.d.ts +1 -1
  130. package/dist/commands/versions.d.ts +1 -1
  131. package/dist/commands/versions.js +2 -2
  132. package/dist/commands/wait-deploy.d.ts +3 -3
  133. package/dist/commands/wait-deploy.js +3 -3
  134. package/dist/commands/whoami.d.ts +1 -1
  135. package/dist/detect.js +1 -1
  136. package/dist/index.d.ts +77 -74
  137. package/dist/index.d.ts.map +1 -1
  138. package/dist/index.js +76 -73
  139. package/dist/index.js.map +1 -1
  140. package/dist/poll-deployment.d.ts +1 -1
  141. package/dist/recovery.d.ts +1 -1
  142. package/dist/structured-error-codes.d.ts +1 -1
  143. package/dist/templates/ai-files/index.js +2 -2
  144. package/package.json +6 -3
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import type { Context } from "../context";
2
+ import type { Context } from "../context.js";
3
3
  export declare const inspectLinkInputSchema: z.ZodObject<{
4
4
  app: z.ZodOptional<z.ZodString>;
5
5
  revoke: z.ZodOptional<z.ZodBoolean>;
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import { readPercherTomlAppName } from "../app-name";
3
- import { PercherCoreError } from "../errors";
2
+ import { readPercherTomlAppName } from "../app-name.js";
3
+ import { PercherCoreError } from "../errors.js";
4
4
  export const inspectLinkInputSchema = z.object({
5
5
  app: z.string().optional().describe("App name (defaults to percher.toml)"),
6
6
  revoke: z.boolean().optional().describe("Revoke the app's inspect link instead of creating one"),
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import type { Context } from "../context";
2
+ import type { Context } from "../context.js";
3
3
  export declare const loginInputSchema: z.ZodObject<{
4
4
  token: z.ZodOptional<z.ZodString>;
5
5
  apiUrl: z.ZodOptional<z.ZodString>;
@@ -1,6 +1,6 @@
1
1
  import { PercherClient, saveConfig } from "@percher/client";
2
2
  import { z } from "zod";
3
- import { PercherCoreError } from "../errors";
3
+ import { PercherCoreError } from "../errors.js";
4
4
  export const loginInputSchema = z.object({
5
5
  token: z.string().optional(),
6
6
  apiUrl: z.string().url().optional(),
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import type { Context } from "../context";
2
+ import type { Context } from "../context.js";
3
3
  /**
4
4
  * FUTURE9 Fas 1 — server-side log filtering exposed to CLI + MCP.
5
5
  * Closes the gap between `percher_doctor` (crash diagnosis) and blind
@@ -1,7 +1,7 @@
1
1
  import { MAX_LOG_SEARCH_LENGTH } from "@percher/shared";
2
2
  import { z } from "zod";
3
- import { readPercherTomlAppName } from "../app-name";
4
- import { PercherCoreError } from "../errors";
3
+ import { readPercherTomlAppName } from "../app-name.js";
4
+ import { PercherCoreError } from "../errors.js";
5
5
  /**
6
6
  * FUTURE9 Fas 1 — server-side log filtering exposed to CLI + MCP.
7
7
  * Closes the gap between `percher_doctor` (crash diagnosis) and blind
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import type { Context } from "../context";
2
+ import type { Context } from "../context.js";
3
3
  export declare const mcpInputSchema: z.ZodObject<{}, z.core.$strip>;
4
4
  export type McpInput = z.infer<typeof mcpInputSchema>;
5
5
  export interface McpConfigResult {
@@ -1,4 +1,4 @@
1
- import type { InspectSupabaseResult } from "./migrate-supabase";
1
+ import type { InspectSupabaseResult } from "./migrate-supabase.js";
2
2
  /**
3
3
  * FUTURE9 Phase B — Supabase → PocketBase schema mapping.
4
4
  *
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Phase D — auth recipes.
3
+ *
4
+ * Centralised PocketBase-equivalent guidance for the Supabase auth patterns
5
+ * the rewriter deliberately does NOT auto-translate. The north star: a
6
+ * compiling-but-wrong getSession/OTP/password-reset is the worst outcome, so
7
+ * these stay flagged (the Supabase call is left in place) and the user gets a
8
+ * concrete recipe instead of a fake rewrite.
9
+ *
10
+ * Keyed by the flag pattern the SDK rewriter emits (`auth.<method>`). Used two
11
+ * ways: the rewriter folds the recipe into the flag's inline note, and the
12
+ * report renders a deduplicated "Recipes" section from the patterns present.
13
+ */
14
+ export interface AuthRecipe {
15
+ /** Short title for the Recipes section heading. */
16
+ title: string;
17
+ /** Concrete PocketBase-equivalent guidance — one tight paragraph. */
18
+ recipe: string;
19
+ }
20
+ export declare const AUTH_RECIPES: Record<string, AuthRecipe>;
21
+ /** Recipe for a flag pattern, or null when there isn't one. */
22
+ export declare function recipeFor(pattern: string): AuthRecipe | null;
23
+ /**
24
+ * Render the "Recipes" section for REWRITE_NOTES.md from the set of flag
25
+ * patterns present. Returns markdown lines (empty when no auth recipe applies).
26
+ */
27
+ export declare function renderRecipesSection(patterns: Iterable<string>): string[];
28
+ //# sourceMappingURL=migrate-supabase-recipes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-supabase-recipes.d.ts","sourceRoot":"","sources":["../../src/commands/migrate-supabase-recipes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,UAAU;IACzB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CA8CnD,CAAC;AAEF,+DAA+D;AAC/D,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAE5D;AAWD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CA0BzE"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Phase D — auth recipes.
3
+ *
4
+ * Centralised PocketBase-equivalent guidance for the Supabase auth patterns
5
+ * the rewriter deliberately does NOT auto-translate. The north star: a
6
+ * compiling-but-wrong getSession/OTP/password-reset is the worst outcome, so
7
+ * these stay flagged (the Supabase call is left in place) and the user gets a
8
+ * concrete recipe instead of a fake rewrite.
9
+ *
10
+ * Keyed by the flag pattern the SDK rewriter emits (`auth.<method>`). Used two
11
+ * ways: the rewriter folds the recipe into the flag's inline note, and the
12
+ * report renders a deduplicated "Recipes" section from the patterns present.
13
+ */
14
+ export const AUTH_RECIPES = {
15
+ "auth.getSession": {
16
+ title: "getSession → pb.authStore",
17
+ recipe: "PocketBase keeps the session in `pb.authStore` (local, synchronous — no await). Replace `const { data: { session } } = await supabase.auth.getSession()` with `pb.authStore.isValid` (logged in?), `pb.authStore.record` (the user record), and `pb.authStore.token` (the JWT).",
18
+ },
19
+ "auth.getClaims": {
20
+ title: "getClaims → pb.authStore.record",
21
+ recipe: "PocketBase has no separate claims endpoint. The authenticated user's fields live on `pb.authStore.record`; use `pb.authStore.isValid` for the logged-in check. Read them directly — no await, no token decode.",
22
+ },
23
+ "auth.getUser": {
24
+ title: "getUser → pb.authStore.record",
25
+ recipe: "`pb.authStore.record` is the current user record (or null), read synchronously. Supabase's `getUser()` returns `Promise<{ data: { user } }>`, so drop the await and the `.data.user` unwrap.",
26
+ },
27
+ "auth.signInWithOtp": {
28
+ title: "signInWithOtp → requestOTP + authWithOTP",
29
+ recipe: "PocketBase email-OTP is two steps: `const req = await pb.collection('users').requestOTP(email)` sends the code, then on a second screen `await pb.collection('users').authWithOTP(req.otpId, code)` verifies it. Supabase's single magic-link `signInWithOtp` maps to the first step — you'll add a code-entry screen for the second.",
30
+ },
31
+ "auth.verifyOtp": {
32
+ title: "verifyOtp → authWithOTP",
33
+ recipe: "Pairs with requestOTP: `await pb.collection('users').authWithOTP(otpId, code)` (otpId comes from the requestOTP response, not from the email link). Supabase's `token_hash` / `type` model doesn't carry over — keep the otpId from step one in component state.",
34
+ },
35
+ "auth.resetPasswordForEmail": {
36
+ title: "resetPasswordForEmail → requestPasswordReset",
37
+ recipe: "`await pb.collection('users').requestPasswordReset(email)` sends the reset email. The confirm step lives on your reset page: `await pb.collection('users').confirmPasswordReset(token, newPassword, newPasswordConfirm)` (token comes from the email link).",
38
+ },
39
+ "auth.updateUser": {
40
+ title: "updateUser → collection('users').update",
41
+ recipe: "PocketBase updates by record id: `await pb.collection('users').update(pb.authStore.record.id, { ... })`. There's no implicit current-user update — pass the id explicitly. Email/password changes use the dedicated `requestEmailChange` / `confirmEmailChange` flows.",
42
+ },
43
+ "auth.refreshSession": {
44
+ title: "refreshSession → authRefresh",
45
+ recipe: "`await pb.collection('users').authRefresh()` re-validates the stored token and refreshes `pb.authStore`. There's no refresh-token rotation to manage — PocketBase reissues the JWT in place.",
46
+ },
47
+ "auth.onAuthStateChange": {
48
+ title: "onAuthStateChange → pb.authStore.onChange",
49
+ recipe: "`const unsubscribe = pb.authStore.onChange((token, record) => { ... })`. The callback receives `(token, record)`, NOT Supabase's `(event, session)` — there's no event-type string, so branch on `pb.authStore.isValid` inside the callback. It returns an unsubscribe function; call it on teardown.",
50
+ },
51
+ };
52
+ /** Recipe for a flag pattern, or null when there isn't one. */
53
+ export function recipeFor(pattern) {
54
+ return AUTH_RECIPES[pattern] ?? null;
55
+ }
56
+ /** General auth guidance worth surfacing whenever any auth call was flagged. */
57
+ const GENERAL_AUTH_RECIPES = [
58
+ {
59
+ title: "Route guards → pb.authStore.isValid",
60
+ recipe: "Gate protected routes on `pb.authStore.isValid` instead of inspecting a session object, e.g. `if (!pb.authStore.isValid) redirect('/login')`. `pb.authStore` is restored from storage on load, so the check works on the first render.",
61
+ },
62
+ ];
63
+ /**
64
+ * Render the "Recipes" section for REWRITE_NOTES.md from the set of flag
65
+ * patterns present. Returns markdown lines (empty when no auth recipe applies).
66
+ */
67
+ export function renderRecipesSection(patterns) {
68
+ const seen = new Set();
69
+ const recipes = [];
70
+ for (const pattern of patterns) {
71
+ const recipe = recipeFor(pattern);
72
+ if (recipe && !seen.has(recipe.title)) {
73
+ seen.add(recipe.title);
74
+ recipes.push(recipe);
75
+ }
76
+ }
77
+ if (recipes.length === 0)
78
+ return [];
79
+ const lines = [];
80
+ lines.push("## Recipes — Supabase auth → PocketBase");
81
+ lines.push("");
82
+ lines.push("Concrete PocketBase equivalents for the auth calls above. These are NOT auto-applied — the Supabase call is left in place so the app keeps working until you migrate it deliberately. See https://pocketbase.io/docs/authentication/.");
83
+ lines.push("");
84
+ for (const recipe of [...recipes, ...GENERAL_AUTH_RECIPES]) {
85
+ lines.push(`### ${recipe.title}`);
86
+ lines.push("");
87
+ lines.push(recipe.recipe);
88
+ lines.push("");
89
+ }
90
+ return lines;
91
+ }
92
+ //# sourceMappingURL=migrate-supabase-recipes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-supabase-recipes.js","sourceRoot":"","sources":["../../src/commands/migrate-supabase-recipes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH,MAAM,CAAC,MAAM,YAAY,GAA+B;IACtD,iBAAiB,EAAE;QACjB,KAAK,EAAE,2BAA2B;QAClC,MAAM,EACJ,iRAAiR;KACpR;IACD,gBAAgB,EAAE;QAChB,KAAK,EAAE,iCAAiC;QACxC,MAAM,EACJ,gNAAgN;KACnN;IACD,cAAc,EAAE;QACd,KAAK,EAAE,+BAA+B;QACtC,MAAM,EACJ,8LAA8L;KACjM;IACD,oBAAoB,EAAE;QACpB,KAAK,EAAE,0CAA0C;QACjD,MAAM,EACJ,uUAAuU;KAC1U;IACD,gBAAgB,EAAE;QAChB,KAAK,EAAE,yBAAyB;QAChC,MAAM,EACJ,kQAAkQ;KACrQ;IACD,4BAA4B,EAAE;QAC5B,KAAK,EAAE,8CAA8C;QACrD,MAAM,EACJ,6PAA6P;KAChQ;IACD,iBAAiB,EAAE;QACjB,KAAK,EAAE,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AM,IAAI,CAAC,GAAG,OAAO,EAAE,GAAG,oBAAoB,CAAC,EAAE,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,101 @@
1
+ import { z } from "zod";
2
+ import type { Context } from "../context.js";
3
+ import { type AskUserRecovery, type NoneRecovery } from "../recovery.js";
4
+ import { type SkippedFile } from "./migrate-supabase-walker.js";
5
+ /**
6
+ * FUTURE9 Phase D chunk 3.3 — user-facing client-rewrite wiring.
7
+ *
8
+ * Ties the existing project walker (`walkSupabaseProject`) and writer
9
+ * (`writeWalkResult`) into one command the CLI + MCP can call. Phase D
10
+ * shipped as library functions in 2026-05; this is the deferred
11
+ * surface that makes it reachable.
12
+ *
13
+ * Two modes, mirroring the dry-run/apply posture of every other
14
+ * migration phase:
15
+ *
16
+ * - preview (default): rewritten copies of every changed file land
17
+ * under `./migration-preview/rewritten/`, mirroring the project
18
+ * tree. The project itself is untouched — the user diffs the
19
+ * preview against their working tree before committing.
20
+ * - apply (`apply: true`): changed files are overwritten in place.
21
+ * Originals are copied to `./migration-preview/backup/` FIRST, so
22
+ * a botched rewrite is always recoverable even outside git.
23
+ *
24
+ * The rewrite is AST-based and high-confidence for auth + CRUD. Two
25
+ * kinds of call still need a human; both are recorded as flags (file +
26
+ * line) collected into a `migration-preview/REWRITE_NOTES.md` report
27
+ * rather than inline markers:
28
+ * - manual_review — rewritten to PocketBase, but the semantics differ
29
+ * (e.g. onAuthStateChange event shape, filter escaping, pagination).
30
+ * - unsupported — no PocketBase equivalent (storage, realtime, rpc,
31
+ * edge functions); LEFT UNTOUCHED for the user to replace by hand.
32
+ * A project that only triggers flags produces no/partial rewrites but is
33
+ * still actionable — it is not "nothing found".
34
+ */
35
+ export declare const rewriteSupabaseClientInputSchema: z.ZodObject<{
36
+ rootDir: z.ZodOptional<z.ZodString>;
37
+ outputDir: z.ZodOptional<z.ZodString>;
38
+ apply: z.ZodOptional<z.ZodBoolean>;
39
+ pbIdentifier: z.ZodOptional<z.ZodString>;
40
+ supabaseIdentifiers: z.ZodOptional<z.ZodArray<z.ZodString>>;
41
+ scaffoldClient: z.ZodOptional<z.ZodBoolean>;
42
+ }, z.core.$strip>;
43
+ export type RewriteSupabaseClientInput = z.infer<typeof rewriteSupabaseClientInputSchema>;
44
+ /**
45
+ * A location needing review. `kind` says which: `manual_review` was
46
+ * rewritten to PocketBase but its semantics differ; `unsupported` has
47
+ * no PocketBase equivalent and was left untouched in the source.
48
+ */
49
+ export interface RewriteClientFlag {
50
+ /** Source file (relative to the project root, forward-slash-normalised). */
51
+ file: string;
52
+ /** 1-based line of the original call. Undefined if the parser couldn't recover it. */
53
+ line?: number;
54
+ /** 0-based column. Undefined if the parser couldn't recover it. */
55
+ column?: number;
56
+ /** "manual_review" = mapped but semantics differ; "unsupported" = no PB equivalent at all. */
57
+ kind: "manual_review" | "unsupported";
58
+ /** Stable pattern id (e.g. `storage.upload`, `channel.subscribe`, `rpc`). */
59
+ pattern: string;
60
+ /** Human-readable explanation of what needs doing. */
61
+ note: string;
62
+ }
63
+ export interface RewriteSupabaseClientResult {
64
+ status: "ok" | "failed";
65
+ /** "preview" writes a sibling tree; "apply" overwrites in place. */
66
+ mode: "preview" | "apply";
67
+ /** Absolute project root that was walked. */
68
+ rootDir: string;
69
+ /** Absolute dir the rewritten files were written to (preview tree, or the root itself in apply mode). */
70
+ writtenTo: string;
71
+ /** Absolute backup dir holding the untouched originals (apply mode with rewritten files). Null otherwise. */
72
+ backupDir: string | null;
73
+ /** Paths (relative to ctx.cwd) of every file written this run — rewritten files plus REWRITE_NOTES.md. */
74
+ filesWritten: string[];
75
+ /** How many files the rewriter actually changed. */
76
+ changedCount: number;
77
+ /** Locations needing review, with file + line: rewritten-with-caveats (manual_review) and untouched (unsupported). Empty when the rewrite was fully automatic. */
78
+ flags: RewriteClientFlag[];
79
+ /** Roll-up of all `flags` by pattern id (e.g. `{ "storage.upload": 2 }`) — both manual_review and unsupported. */
80
+ flagsByPattern: Record<string, number>;
81
+ /** package.json had its @supabase/supabase-js dependency swapped. */
82
+ packageJsonChanged: boolean;
83
+ /** How many .env* files had Supabase keys commented out + stubbed. */
84
+ envFilesChanged: number;
85
+ /** The PocketBase client module that was scaffolded (relative to ctx.cwd), or null
86
+ * when scaffolding was off, skipped (a pb client already exists), or there were
87
+ * no rewrites. */
88
+ clientModule: string | null;
89
+ /** Files the walker couldn't process (parse error, binary, read error). */
90
+ skipped: SkippedFile[];
91
+ recovery: NoneRecovery | AskUserRecovery;
92
+ summary: string;
93
+ error?: {
94
+ code: "rewrite_failed";
95
+ title: string;
96
+ explanation: string;
97
+ suggestion: string;
98
+ };
99
+ }
100
+ export declare function rewriteSupabaseClient(ctx: Context, input: RewriteSupabaseClientInput): Promise<RewriteSupabaseClientResult>;
101
+ //# sourceMappingURL=migrate-supabase-rewrite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-supabase-rewrite.d.ts","sourceRoot":"","sources":["../../src/commands/migrate-supabase-rewrite.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAA6B,MAAM,aAAa,CAAC;AAIjG,OAAO,EACL,KAAK,WAAW,EAIjB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,eAAO,MAAM,gCAAgC;;;;;;;iBAiC3C,CAAC;AACH,MAAM,MAAM,0BAA0B,G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