@percher/core 0.4.0 → 0.4.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.
- package/dist/commands/account.d.ts +24 -14
- package/dist/commands/account.d.ts.map +1 -1
- package/dist/commands/account.js +17 -4
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/admin-reconcile-routes.d.ts +18 -0
- package/dist/commands/admin-reconcile-routes.d.ts.map +1 -0
- package/dist/commands/admin-reconcile-routes.js +22 -0
- package/dist/commands/admin-reconcile-routes.js.map +1 -0
- package/dist/commands/ai-files.d.ts +5 -17
- package/dist/commands/ai-files.d.ts.map +1 -1
- package/dist/commands/ai-files.js +3 -4
- package/dist/commands/ai-files.js.map +1 -1
- package/dist/commands/alerts.d.ts +69 -0
- package/dist/commands/alerts.d.ts.map +1 -0
- package/dist/commands/alerts.js +80 -0
- package/dist/commands/alerts.js.map +1 -0
- package/dist/commands/app-resources.d.ts +30 -0
- package/dist/commands/app-resources.d.ts.map +1 -0
- package/dist/commands/app-resources.js +34 -0
- package/dist/commands/app-resources.js.map +1 -0
- package/dist/commands/app-topology.d.ts +18 -0
- package/dist/commands/app-topology.d.ts.map +1 -0
- package/dist/commands/app-topology.js +25 -0
- package/dist/commands/app-topology.js.map +1 -0
- package/dist/commands/billing.d.ts +8 -8
- package/dist/commands/billing.d.ts.map +1 -1
- package/dist/commands/billing.js +1 -1
- package/dist/commands/billing.js.map +1 -1
- package/dist/commands/continue.d.ts +1 -1
- package/dist/commands/create.d.ts +2 -12
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +1 -1
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dashboard.d.ts +2 -8
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/data-export.d.ts +2 -8
- package/dist/commands/data-export.d.ts.map +1 -1
- package/dist/commands/data-export.js +1 -1
- package/dist/commands/data-export.js.map +1 -1
- package/dist/commands/data.d.ts +2 -8
- package/dist/commands/data.d.ts.map +1 -1
- package/dist/commands/data.js +1 -1
- package/dist/commands/data.js.map +1 -1
- package/dist/commands/delete.d.ts +2 -8
- package/dist/commands/delete.d.ts.map +1 -1
- package/dist/commands/delete.js +1 -1
- package/dist/commands/delete.js.map +1 -1
- package/dist/commands/deploys.d.ts +4 -28
- package/dist/commands/deploys.d.ts.map +1 -1
- package/dist/commands/deploys.js +1 -1
- package/dist/commands/deploys.js.map +1 -1
- package/dist/commands/dev.d.ts +2 -6
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/diagnose.d.ts +2 -22
- package/dist/commands/diagnose.d.ts.map +1 -1
- package/dist/commands/diagnose.js +1 -1
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/doctor.d.ts +10 -35
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +12 -4
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/domains.d.ts +5 -27
- package/dist/commands/domains.d.ts.map +1 -1
- package/dist/commands/domains.js +1 -1
- package/dist/commands/domains.js.map +1 -1
- package/dist/commands/env-scan.js +1 -1
- package/dist/commands/env-scan.js.map +1 -1
- package/dist/commands/env.d.ts +4 -20
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +1 -1
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/export.d.ts +1 -1
- package/dist/commands/forgejo.d.ts +45 -0
- package/dist/commands/forgejo.d.ts.map +1 -0
- package/dist/commands/forgejo.js +125 -0
- package/dist/commands/forgejo.js.map +1 -0
- package/dist/commands/generate.d.ts +2 -6
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +1 -1
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/github.d.ts +4 -15
- package/dist/commands/github.d.ts.map +1 -1
- package/dist/commands/github.js +17 -1
- package/dist/commands/github.js.map +1 -1
- package/dist/commands/import-project.d.ts +13 -9
- package/dist/commands/import-project.d.ts.map +1 -1
- package/dist/commands/import-project.js +73 -22
- package/dist/commands/import-project.js.map +1 -1
- package/dist/commands/init.d.ts +26 -11
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +103 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/insights.d.ts +2 -6
- package/dist/commands/insights.d.ts.map +1 -1
- package/dist/commands/insights.js +1 -1
- package/dist/commands/insights.js.map +1 -1
- package/dist/commands/login.d.ts +2 -8
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +22 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logs.d.ts +25 -10
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +65 -5
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/mcp.d.ts +2 -2
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/migrate-supabase-map.d.ts +171 -0
- package/dist/commands/migrate-supabase-map.d.ts.map +1 -0
- package/dist/commands/migrate-supabase-map.js +452 -0
- package/dist/commands/migrate-supabase-map.js.map +1 -0
- package/dist/commands/migrate-supabase-schema.d.ts +67 -0
- package/dist/commands/migrate-supabase-schema.d.ts.map +1 -0
- package/dist/commands/migrate-supabase-schema.js +321 -0
- package/dist/commands/migrate-supabase-schema.js.map +1 -0
- package/dist/commands/migrate-supabase-scripts.d.ts +64 -0
- package/dist/commands/migrate-supabase-scripts.d.ts.map +1 -0
- package/dist/commands/migrate-supabase-scripts.js +564 -0
- package/dist/commands/migrate-supabase-scripts.js.map +1 -0
- package/dist/commands/migrate-supabase-sdk.d.ts +133 -0
- package/dist/commands/migrate-supabase-sdk.d.ts.map +1 -0
- package/dist/commands/migrate-supabase-sdk.js +1119 -0
- package/dist/commands/migrate-supabase-sdk.js.map +1 -0
- package/dist/commands/migrate-supabase-walker.d.ts +93 -0
- package/dist/commands/migrate-supabase-walker.d.ts.map +1 -0
- package/dist/commands/migrate-supabase-walker.js +413 -0
- package/dist/commands/migrate-supabase-walker.js.map +1 -0
- package/dist/commands/migrate-supabase.d.ts +81 -0
- package/dist/commands/migrate-supabase.d.ts.map +1 -0
- package/dist/commands/migrate-supabase.js +579 -0
- package/dist/commands/migrate-supabase.js.map +1 -0
- package/dist/commands/open.d.ts +2 -6
- package/dist/commands/open.d.ts.map +1 -1
- package/dist/commands/open.js +1 -1
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/publish-api-error.d.ts +46 -0
- package/dist/commands/publish-api-error.d.ts.map +1 -0
- package/dist/commands/publish-api-error.js +307 -0
- package/dist/commands/publish-api-error.js.map +1 -0
- package/dist/commands/publish.d.ts +40 -17
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +115 -8
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/push.d.ts +2 -12
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +2 -2
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/redeploy.d.ts +2 -8
- package/dist/commands/redeploy.d.ts.map +1 -1
- package/dist/commands/redeploy.js +2 -2
- package/dist/commands/redeploy.js.map +1 -1
- package/dist/commands/rename.d.ts +2 -8
- package/dist/commands/rename.d.ts.map +1 -1
- package/dist/commands/rename.js +1 -1
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/reproduce.d.ts +2 -8
- package/dist/commands/reproduce.d.ts.map +1 -1
- package/dist/commands/reproduce.js +1 -1
- package/dist/commands/reproduce.js.map +1 -1
- package/dist/commands/reset-superuser.d.ts +2 -16
- package/dist/commands/reset-superuser.d.ts.map +1 -1
- package/dist/commands/reset-superuser.js +1 -1
- package/dist/commands/reset-superuser.js.map +1 -1
- package/dist/commands/restore.d.ts +7 -22
- package/dist/commands/restore.d.ts.map +1 -1
- package/dist/commands/restore.js +1 -1
- package/dist/commands/restore.js.map +1 -1
- package/dist/commands/resume.d.ts +2 -6
- package/dist/commands/resume.d.ts.map +1 -1
- package/dist/commands/resume.js +1 -1
- package/dist/commands/resume.js.map +1 -1
- package/dist/commands/rollback.d.ts +2 -8
- package/dist/commands/rollback.d.ts.map +1 -1
- package/dist/commands/rollback.js +1 -1
- package/dist/commands/rollback.js.map +1 -1
- package/dist/commands/sharing.d.ts +48 -0
- package/dist/commands/sharing.d.ts.map +1 -0
- package/dist/commands/sharing.js +85 -0
- package/dist/commands/sharing.js.map +1 -0
- package/dist/commands/status.d.ts +2 -6
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/transfers.d.ts +34 -0
- package/dist/commands/transfers.d.ts.map +1 -0
- package/dist/commands/transfers.js +62 -0
- package/dist/commands/transfers.js.map +1 -0
- package/dist/commands/unsuspend.d.ts +2 -6
- package/dist/commands/unsuspend.d.ts.map +1 -1
- package/dist/commands/unsuspend.js +1 -1
- package/dist/commands/unsuspend.js.map +1 -1
- package/dist/commands/versions.d.ts +2 -6
- package/dist/commands/versions.d.ts.map +1 -1
- package/dist/commands/versions.js +1 -1
- package/dist/commands/versions.js.map +1 -1
- package/dist/commands/wait-deploy.d.ts +2 -12
- package/dist/commands/wait-deploy.d.ts.map +1 -1
- package/dist/commands/wait-deploy.js +1 -1
- package/dist/commands/wait-deploy.js.map +1 -1
- package/dist/context.d.ts +15 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/detect.d.ts +11 -0
- package/dist/detect.d.ts.map +1 -1
- package/dist/detect.js +31 -8
- package/dist/detect.js.map +1 -1
- package/dist/env-scan-source.js +1 -1
- package/dist/env-scan-source.js.map +1 -1
- package/dist/error-classifier.d.ts +17 -0
- package/dist/error-classifier.d.ts.map +1 -1
- package/dist/error-classifier.js +94 -8
- package/dist/error-classifier.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +63 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -42
- package/dist/index.js.map +1 -1
- package/dist/plans.d.ts +61 -5
- package/dist/plans.d.ts.map +1 -1
- package/dist/plans.js +78 -18
- package/dist/plans.js.map +1 -1
- package/dist/recovery.d.ts +60 -3
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +22 -0
- package/dist/recovery.js.map +1 -1
- package/dist/static-docker.d.ts +77 -0
- package/dist/static-docker.d.ts.map +1 -0
- package/dist/static-docker.js +105 -0
- package/dist/static-docker.js.map +1 -0
- package/dist/tarball.js +1 -1
- package/dist/tarball.js.map +1 -1
- package/dist/templates/ai-files/cursor-percher-mdc.d.ts.map +1 -1
- package/dist/templates/ai-files/cursor-percher-mdc.js +12 -9
- package/dist/templates/ai-files/cursor-percher-mdc.js.map +1 -1
- package/dist/templates.js +11 -11
- package/dist/templates.js.map +1 -1
- package/dist/watcher.js +1 -1
- package/dist/watcher.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a Supabase introspection result to a PocketBase migration preview.
|
|
3
|
+
* Pure (no I/O). Safe to call repeatedly.
|
|
4
|
+
*
|
|
5
|
+
* The function never throws on a malformed input — every "I don't
|
|
6
|
+
* know how to map this" case becomes a `MigrationUnsupported` entry
|
|
7
|
+
* so the user gets the full picture in one pass rather than the
|
|
8
|
+
* mapper bailing out on the first weird column.
|
|
9
|
+
*/
|
|
10
|
+
export function mapSupabaseToPocketBase(introspection, options = {}) {
|
|
11
|
+
const generatedAt = (options.now?.() ?? new Date()).toISOString();
|
|
12
|
+
const collections = [];
|
|
13
|
+
const rlsPolicies = [];
|
|
14
|
+
const unsupported = [];
|
|
15
|
+
// Map each introspected table → a PocketBase collection. The
|
|
16
|
+
// mapping is per-table local; cross-table state (FK resolution) is
|
|
17
|
+
// deferred to the user-supplied `collectionName` lookup which uses
|
|
18
|
+
// the SAME collection-name convention we apply here.
|
|
19
|
+
for (const table of introspection.tables) {
|
|
20
|
+
const collection = mapTable(table, introspection.tables, unsupported);
|
|
21
|
+
collections.push(collection);
|
|
22
|
+
for (const policy of table.rlsPolicies) {
|
|
23
|
+
rlsPolicies.push(mapRlsPolicy(table, policy));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const authMigration = introspection.authUsersCount !== null && introspection.authUsersCount > 0
|
|
27
|
+
? {
|
|
28
|
+
userCount: introspection.authUsersCount,
|
|
29
|
+
note: "Supabase bcrypt hashes use a different cost parameter than PocketBase. Users will not be able to sign in with their existing passwords — send a password-reset email after the migration.",
|
|
30
|
+
}
|
|
31
|
+
: null;
|
|
32
|
+
if (authMigration) {
|
|
33
|
+
unsupported.push({
|
|
34
|
+
kind: "auth_user_passwords",
|
|
35
|
+
source: "auth.users",
|
|
36
|
+
reason: `${authMigration.userCount} auth user${authMigration.userCount === 1 ? "" : "s"} cannot keep their existing passwords.`,
|
|
37
|
+
suggestion: authMigration.note,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const storageMigration = introspection.storageBuckets.length > 0
|
|
41
|
+
? {
|
|
42
|
+
buckets: introspection.storageBuckets.map((b) => b.name),
|
|
43
|
+
note: "Storage bucket files do not migrate automatically — Phase C will generate a separate `pb_migrate_storage.js` script that downloads and re-uploads each file via PocketBase's admin SDK.",
|
|
44
|
+
}
|
|
45
|
+
: null;
|
|
46
|
+
if (storageMigration) {
|
|
47
|
+
unsupported.push({
|
|
48
|
+
kind: "storage_bucket_files",
|
|
49
|
+
source: `storage.buckets (${storageMigration.buckets.join(", ")})`,
|
|
50
|
+
reason: "Bucket files are not part of the Postgres schema and need a separate import pass.",
|
|
51
|
+
suggestion: storageMigration.note,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const warnings = collectWarnings(collections, rlsPolicies, unsupported);
|
|
55
|
+
const fieldCount = collections.reduce((acc, c) => acc + c.schema.length, 0);
|
|
56
|
+
const relationFieldCount = collections.reduce((acc, c) => acc + c.schema.filter((f) => f.type === "relation").length, 0);
|
|
57
|
+
const manualRlsPolicyCount = rlsPolicies.filter((p) => p.manual).length;
|
|
58
|
+
return {
|
|
59
|
+
sourceProjectRef: introspection.projectRef,
|
|
60
|
+
generatedAt,
|
|
61
|
+
collections,
|
|
62
|
+
migrationNotes: {
|
|
63
|
+
rlsPolicies,
|
|
64
|
+
unsupported,
|
|
65
|
+
authMigration,
|
|
66
|
+
storageMigration,
|
|
67
|
+
},
|
|
68
|
+
warnings,
|
|
69
|
+
summary: {
|
|
70
|
+
collectionCount: collections.length,
|
|
71
|
+
fieldCount,
|
|
72
|
+
relationFieldCount,
|
|
73
|
+
unsupportedCount: unsupported.length,
|
|
74
|
+
rlsPolicyCount: rlsPolicies.length,
|
|
75
|
+
manualRlsPolicyCount,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function mapTable(table, allTables, unsupported) {
|
|
80
|
+
const collectionName = pbCollectionName(table);
|
|
81
|
+
const fqTable = `${table.schema}.${table.name}`;
|
|
82
|
+
const primaryKeys = table.columns.filter((c) => c.isPrimaryKey);
|
|
83
|
+
if (primaryKeys.length === 0) {
|
|
84
|
+
unsupported.push({
|
|
85
|
+
kind: "no_primary_key",
|
|
86
|
+
source: fqTable,
|
|
87
|
+
reason: "PocketBase requires every record to have an `id`. The source table has no primary key.",
|
|
88
|
+
suggestion: "PocketBase will auto-generate a 15-char id per row. Existing references from other tables (if any) will need manual remapping after import.",
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else if (primaryKeys.length > 1) {
|
|
92
|
+
unsupported.push({
|
|
93
|
+
kind: "composite_primary_key",
|
|
94
|
+
source: fqTable,
|
|
95
|
+
reason: `PocketBase only supports a single \`id\` primary key. The source has a composite key over (${primaryKeys.map((c) => c.name).join(", ")}).`,
|
|
96
|
+
suggestion: "Pick one column as the PB id (PB ids are strings; uuid works directly) and keep the others as regular fields. Add a unique index over the original tuple if cross-row uniqueness still matters.",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const schema = [];
|
|
100
|
+
const droppedSourceColumns = [];
|
|
101
|
+
let sourcePrimaryKey = null;
|
|
102
|
+
for (const col of table.columns) {
|
|
103
|
+
// Drop EVERY single-column primary key from the PB schema —
|
|
104
|
+
// uuid, integer, text, citext, whatever. Three reasons:
|
|
105
|
+
//
|
|
106
|
+
// 1. PocketBase has a built-in `id` field. A user-defined
|
|
107
|
+
// column named `id` would collide; a non-`id`-named PK
|
|
108
|
+
// that we kept as a field would leave PB without a way
|
|
109
|
+
// to resolve foreign-key relations against it.
|
|
110
|
+
// 2. The import script (Phase C) derives a deterministic
|
|
111
|
+
// 15-char PB id from row[<sourcePrimaryKey>] via sha256.
|
|
112
|
+
// That id becomes the PB record's id — within PB's
|
|
113
|
+
// documented id shape AND stable across re-runs.
|
|
114
|
+
// 3. The same id-map is consulted when dependent tables'
|
|
115
|
+
// FK columns get rewritten before insert. Without it, an
|
|
116
|
+
// integer-PK source (`users.id` int → `posts.user_id`
|
|
117
|
+
// int) would have no map to look up against, and the FK
|
|
118
|
+
// rewrite would throw at import time.
|
|
119
|
+
//
|
|
120
|
+
// Multi-column PKs are flagged separately above and we emit
|
|
121
|
+
// each part as a regular field so the user can still see the
|
|
122
|
+
// data in the preview.
|
|
123
|
+
//
|
|
124
|
+
// Codex P1 review 2026-05-17 (round 3): the previous version
|
|
125
|
+
// gated this on `isUuidLike(...)`, leaving integer-PK
|
|
126
|
+
// relation targets without an id-map and forcing every
|
|
127
|
+
// dependent table's import to throw. Universal handling
|
|
128
|
+
// closes the gap.
|
|
129
|
+
if (col.isPrimaryKey && primaryKeys.length === 1) {
|
|
130
|
+
droppedSourceColumns.push(col.name);
|
|
131
|
+
sourcePrimaryKey = col.name;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
// Skip PB built-in timestamp columns when they match Postgres
|
|
135
|
+
// conventions exactly. PB writes `created`/`updated` itself; if
|
|
136
|
+
// we re-emit them as user fields, PB rejects the collection
|
|
137
|
+
// (name collision with built-ins). Per the plan, the import path
|
|
138
|
+
// will overwrite incoming `created`/`updated` with PB's own
|
|
139
|
+
// values — that's the desired outcome for fresh records.
|
|
140
|
+
if ((col.name === "created_at" || col.name === "updated_at") && isDateLike(col.postgresType)) {
|
|
141
|
+
droppedSourceColumns.push(col.name);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const field = mapColumn(col, table, allTables, unsupported);
|
|
145
|
+
schema.push(field);
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
name: collectionName,
|
|
149
|
+
type: "base",
|
|
150
|
+
sourceTable: fqTable,
|
|
151
|
+
schema,
|
|
152
|
+
droppedSourceColumns,
|
|
153
|
+
sourcePrimaryKey,
|
|
154
|
+
listRule: null,
|
|
155
|
+
viewRule: null,
|
|
156
|
+
createRule: null,
|
|
157
|
+
updateRule: null,
|
|
158
|
+
deleteRule: null,
|
|
159
|
+
indexes: [],
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function mapColumn(col, ownerTable, allTables, unsupported) {
|
|
163
|
+
const fqColumn = `${ownerTable.schema}.${ownerTable.name}.${col.name}`;
|
|
164
|
+
// Foreign keys take precedence over the type mapping — even when the
|
|
165
|
+
// underlying column is a uuid we want it as a `relation`, not a `text`.
|
|
166
|
+
if (col.foreignKey) {
|
|
167
|
+
// Detect self-referential FKs (PB supports them but cascade semantics
|
|
168
|
+
// differ); flag for review but still emit the relation.
|
|
169
|
+
if (col.foreignKey.table === ownerTable.name) {
|
|
170
|
+
unsupported.push({
|
|
171
|
+
kind: "self_referential_fk",
|
|
172
|
+
source: fqColumn,
|
|
173
|
+
reason: "Self-referential foreign key — PocketBase supports this but cascade-delete semantics differ from Postgres.",
|
|
174
|
+
suggestion: "Verify cascade behavior after import: PB defaults to no cascade unless `cascadeDelete: true` is set explicitly.",
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// Detect auth.users references — these need to land on PB's
|
|
178
|
+
// built-in `users` collection, NOT a generated one.
|
|
179
|
+
const isAuthUsersRef = col.foreignKey.table === "users" &&
|
|
180
|
+
// We don't see the FK's schema in Phase A introspection — only
|
|
181
|
+
// the table name. The common Supabase pattern is FK → auth.users
|
|
182
|
+
// exposed as `references auth.users(id)`. If no user-schema
|
|
183
|
+
// `users` table exists, treat it as the auth ref.
|
|
184
|
+
!allTables.some((t) => t.name === "users" && t.schema === "public");
|
|
185
|
+
const targetCollection = isAuthUsersRef
|
|
186
|
+
? "users"
|
|
187
|
+
: pbCollectionNameFromRef(col.foreignKey.table, allTables);
|
|
188
|
+
if (isAuthUsersRef) {
|
|
189
|
+
unsupported.push({
|
|
190
|
+
kind: "auth_users_reference",
|
|
191
|
+
source: fqColumn,
|
|
192
|
+
reason: "Foreign key references Supabase's `auth.users` table; PocketBase has its own built-in `users` collection. The Phase C import script does NOT migrate auth users (Supabase bcrypt hashes are incompatible with PB's auth), so there's no id-map to translate this FK against.",
|
|
193
|
+
suggestion: "Phase C generates the field as nullable and the import script writes `null` for every row in this column. After wiring auth migration (separate manual step — Supabase users must re-authenticate against PB), build a `sourceSupabaseUserId → pbUserId` map and back-fill this field with a one-off SQL/admin script.",
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
name: col.name,
|
|
198
|
+
type: "relation",
|
|
199
|
+
// Auth-user references MUST be nullable in PB regardless of
|
|
200
|
+
// the source's nullability — the import script writes null
|
|
201
|
+
// for every row in this column (PB would reject inserts
|
|
202
|
+
// pointing at a non-existent record in the built-in `users`
|
|
203
|
+
// collection). Codex P1 round 3 finding (2026-05-17).
|
|
204
|
+
required: isAuthUsersRef ? false : !col.isNullable,
|
|
205
|
+
unique: false,
|
|
206
|
+
options: {
|
|
207
|
+
collectionName: targetCollection,
|
|
208
|
+
cascadeDelete: false,
|
|
209
|
+
maxSelect: 1,
|
|
210
|
+
},
|
|
211
|
+
source: {
|
|
212
|
+
postgresType: col.postgresType,
|
|
213
|
+
sourceColumn: col.name,
|
|
214
|
+
flag: isAuthUsersRef ? "auth_users_reference" : undefined,
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
// Defensive: treat both formatted (`text[]`) and bare (`ARRAY`)
|
|
219
|
+
// shapes as arrays. Phase A's SQL collapses to the formatted form
|
|
220
|
+
// but we don't want a silent regression if that ever drifts.
|
|
221
|
+
if (col.postgresType === "ARRAY" || col.postgresType.endsWith("[]")) {
|
|
222
|
+
unsupported.push({
|
|
223
|
+
kind: "array_column",
|
|
224
|
+
source: fqColumn,
|
|
225
|
+
reason: `Postgres array (${col.postgresType}) has no PocketBase equivalent.`,
|
|
226
|
+
suggestion: "Mapped to `json`. For arrays of scalars this works fine. For arrays of references, model the relationship as a join collection in PocketBase instead.",
|
|
227
|
+
});
|
|
228
|
+
return jsonField(col, "array_column");
|
|
229
|
+
}
|
|
230
|
+
if (col.postgresType === "USER-DEFINED") {
|
|
231
|
+
unsupported.push({
|
|
232
|
+
kind: "user_defined_type",
|
|
233
|
+
source: fqColumn,
|
|
234
|
+
reason: "Source column uses a user-defined type (likely a Postgres enum). The Phase A introspection does not capture enum values.",
|
|
235
|
+
suggestion: "Mapped to `select` with an empty `values` list — fill in the allowed values manually before importing this collection into PocketBase.",
|
|
236
|
+
});
|
|
237
|
+
return {
|
|
238
|
+
name: col.name,
|
|
239
|
+
type: "select",
|
|
240
|
+
required: !col.isNullable,
|
|
241
|
+
unique: false,
|
|
242
|
+
options: { values: [], maxSelect: 1 },
|
|
243
|
+
source: {
|
|
244
|
+
postgresType: col.postgresType,
|
|
245
|
+
sourceColumn: col.name,
|
|
246
|
+
flag: "user_defined_type",
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
const mapping = mapScalarType(col.postgresType);
|
|
251
|
+
if (mapping.kind === "unmapped") {
|
|
252
|
+
unsupported.push({
|
|
253
|
+
kind: "unmapped_type",
|
|
254
|
+
source: fqColumn,
|
|
255
|
+
reason: `Postgres type \`${col.postgresType}\` has no direct PocketBase mapping.`,
|
|
256
|
+
suggestion: "Mapped to `json` so the data isn't lost. Pick a closer PB type manually if you have one in mind.",
|
|
257
|
+
});
|
|
258
|
+
return jsonField(col, "unmapped_type");
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
name: col.name,
|
|
262
|
+
type: mapping.pbType,
|
|
263
|
+
required: !col.isNullable,
|
|
264
|
+
unique: false,
|
|
265
|
+
options: mapping.options,
|
|
266
|
+
source: {
|
|
267
|
+
postgresType: col.postgresType,
|
|
268
|
+
sourceColumn: col.name,
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function mapScalarType(postgresType) {
|
|
273
|
+
const lower = postgresType.toLowerCase().trim();
|
|
274
|
+
// text family
|
|
275
|
+
if (lower === "text" ||
|
|
276
|
+
lower === "character varying" ||
|
|
277
|
+
lower === "varchar" ||
|
|
278
|
+
lower === "character" ||
|
|
279
|
+
lower === "char" ||
|
|
280
|
+
lower === "name" ||
|
|
281
|
+
lower === "citext") {
|
|
282
|
+
return { kind: "mapped", pbType: "text", options: { min: null, max: null, pattern: "" } };
|
|
283
|
+
}
|
|
284
|
+
// uuid — when not a primary key, PocketBase stores it as a text field.
|
|
285
|
+
if (lower === "uuid") {
|
|
286
|
+
return { kind: "mapped", pbType: "text", options: { min: null, max: null, pattern: "" } };
|
|
287
|
+
}
|
|
288
|
+
// numeric family — PB doesn't distinguish int sizes.
|
|
289
|
+
if (lower === "integer" ||
|
|
290
|
+
lower === "int" ||
|
|
291
|
+
lower === "int2" ||
|
|
292
|
+
lower === "int4" ||
|
|
293
|
+
lower === "int8" ||
|
|
294
|
+
lower === "smallint" ||
|
|
295
|
+
lower === "bigint" ||
|
|
296
|
+
lower === "numeric" ||
|
|
297
|
+
lower === "decimal" ||
|
|
298
|
+
lower === "real" ||
|
|
299
|
+
lower === "double precision" ||
|
|
300
|
+
lower === "float4" ||
|
|
301
|
+
lower === "float8" ||
|
|
302
|
+
lower === "money") {
|
|
303
|
+
return { kind: "mapped", pbType: "number", options: {} };
|
|
304
|
+
}
|
|
305
|
+
// boolean
|
|
306
|
+
if (lower === "boolean" || lower === "bool") {
|
|
307
|
+
return { kind: "mapped", pbType: "bool", options: {} };
|
|
308
|
+
}
|
|
309
|
+
// date/time — PB stores everything as an ISO string in `date` fields.
|
|
310
|
+
if (lower === "timestamp" ||
|
|
311
|
+
lower === "timestamp without time zone" ||
|
|
312
|
+
lower === "timestamp with time zone" ||
|
|
313
|
+
lower === "timestamptz" ||
|
|
314
|
+
lower === "date" ||
|
|
315
|
+
lower === "time" ||
|
|
316
|
+
lower === "time without time zone" ||
|
|
317
|
+
lower === "time with time zone" ||
|
|
318
|
+
lower === "timetz") {
|
|
319
|
+
return { kind: "mapped", pbType: "date", options: {} };
|
|
320
|
+
}
|
|
321
|
+
// json
|
|
322
|
+
if (lower === "json" || lower === "jsonb") {
|
|
323
|
+
return { kind: "mapped", pbType: "json", options: {} };
|
|
324
|
+
}
|
|
325
|
+
// bytea → file. NOTE: bytea in Postgres holds bytes inline; PB's
|
|
326
|
+
// `file` field expects an actual file upload. The import script
|
|
327
|
+
// (Phase C) will need to write each row's bytes to a temp file
|
|
328
|
+
// and upload via the admin SDK. Flag this as soon as a column is
|
|
329
|
+
// seen — but still emit `file` so the collection shape is right.
|
|
330
|
+
if (lower === "bytea") {
|
|
331
|
+
return { kind: "mapped", pbType: "file", options: {} };
|
|
332
|
+
}
|
|
333
|
+
return { kind: "unmapped" };
|
|
334
|
+
}
|
|
335
|
+
function jsonField(col, flag) {
|
|
336
|
+
return {
|
|
337
|
+
name: col.name,
|
|
338
|
+
type: "json",
|
|
339
|
+
required: !col.isNullable,
|
|
340
|
+
unique: false,
|
|
341
|
+
options: {},
|
|
342
|
+
source: {
|
|
343
|
+
postgresType: col.postgresType,
|
|
344
|
+
sourceColumn: col.name,
|
|
345
|
+
flag,
|
|
346
|
+
},
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function isDateLike(postgresType) {
|
|
350
|
+
const lower = postgresType.toLowerCase();
|
|
351
|
+
return lower.startsWith("timestamp") || lower === "date" || lower.startsWith("time");
|
|
352
|
+
}
|
|
353
|
+
function pbCollectionName(table) {
|
|
354
|
+
// PB collection names accept [a-zA-Z0-9_]. Public-schema tables
|
|
355
|
+
// get their bare name (the overwhelmingly common case). Tables in
|
|
356
|
+
// other user schemas get a "<schema>_<name>" prefix to avoid
|
|
357
|
+
// collisions; the user can rename in PB if they want a different
|
|
358
|
+
// convention.
|
|
359
|
+
if (table.schema === "public")
|
|
360
|
+
return sanitizeName(table.name);
|
|
361
|
+
return sanitizeName(`${table.schema}_${table.name}`);
|
|
362
|
+
}
|
|
363
|
+
function pbCollectionNameFromRef(refTableName, allTables) {
|
|
364
|
+
// FK target tables only carry their bare name in Phase A's
|
|
365
|
+
// introspection — no schema. Resolve by preferring a public-schema
|
|
366
|
+
// match first, then any other schema, then fall back to the bare
|
|
367
|
+
// name (with a warning logged elsewhere if the table isn't in the
|
|
368
|
+
// user schema list at all).
|
|
369
|
+
const publicHit = allTables.find((t) => t.name === refTableName && t.schema === "public");
|
|
370
|
+
if (publicHit)
|
|
371
|
+
return pbCollectionName(publicHit);
|
|
372
|
+
const anyHit = allTables.find((t) => t.name === refTableName);
|
|
373
|
+
if (anyHit)
|
|
374
|
+
return pbCollectionName(anyHit);
|
|
375
|
+
return sanitizeName(refTableName);
|
|
376
|
+
}
|
|
377
|
+
function sanitizeName(raw) {
|
|
378
|
+
return raw.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
379
|
+
}
|
|
380
|
+
// ── RLS policy rewriting ──────────────────────────────────────────
|
|
381
|
+
/**
|
|
382
|
+
* Conservative auth.uid() rewriter — recognises only the canonical
|
|
383
|
+
* Supabase pattern `auth.uid() = <column>` (with optional whitespace
|
|
384
|
+
* and parentheses). Anything more complex (`AND`, `OR`, subqueries,
|
|
385
|
+
* function calls, type casts) bypasses the rewriter and lands as
|
|
386
|
+
* `manual: true` so the user must rewrite by hand.
|
|
387
|
+
*
|
|
388
|
+
* The regex is deliberately tight. PB API rules use a different
|
|
389
|
+
* mental model than SQL RLS; a wrong guess is worse than no guess
|
|
390
|
+
* because it'll look plausible until the user notices that
|
|
391
|
+
* `@request.auth.id` doesn't behave the way they expect.
|
|
392
|
+
*/
|
|
393
|
+
const AUTH_UID_EQUALS_COLUMN = /^\s*\(?\s*auth\.uid\(\)\s*=\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\)?\s*$/;
|
|
394
|
+
const COLUMN_EQUALS_AUTH_UID = /^\s*\(?\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*auth\.uid\(\)\s*\)?\s*$/;
|
|
395
|
+
function rewriteRlsExpression(expr) {
|
|
396
|
+
if (!expr)
|
|
397
|
+
return null;
|
|
398
|
+
const m1 = AUTH_UID_EQUALS_COLUMN.exec(expr);
|
|
399
|
+
if (m1)
|
|
400
|
+
return `@request.auth.id = ${m1[1]}`;
|
|
401
|
+
const m2 = COLUMN_EQUALS_AUTH_UID.exec(expr);
|
|
402
|
+
if (m2)
|
|
403
|
+
return `@request.auth.id = ${m2[1]}`;
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
function mapRlsPolicy(table, policy) {
|
|
407
|
+
const rewrittenUsing = rewriteRlsExpression(policy.usingExpr);
|
|
408
|
+
const rewrittenWithCheck = rewriteRlsExpression(policy.withCheckExpr);
|
|
409
|
+
// A policy is "auto-translatable" when EVERY non-null expression
|
|
410
|
+
// matched the narrow rewriter. If either expression was non-null
|
|
411
|
+
// and didn't match, we fall back to manual.
|
|
412
|
+
const usingOk = policy.usingExpr === null || rewrittenUsing !== null;
|
|
413
|
+
const withCheckOk = policy.withCheckExpr === null || rewrittenWithCheck !== null;
|
|
414
|
+
const auto = usingOk && withCheckOk;
|
|
415
|
+
let suggestedRule = null;
|
|
416
|
+
if (auto) {
|
|
417
|
+
// For SELECT/DELETE PB uses listRule/viewRule/deleteRule (USING).
|
|
418
|
+
// For INSERT PB uses createRule (WITH CHECK).
|
|
419
|
+
// For UPDATE both — combine with `&&` if both present.
|
|
420
|
+
if (rewrittenUsing && rewrittenWithCheck && rewrittenUsing !== rewrittenWithCheck) {
|
|
421
|
+
suggestedRule = `${rewrittenUsing} && ${rewrittenWithCheck}`;
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
suggestedRule = rewrittenUsing ?? rewrittenWithCheck;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
table: `${table.schema}.${table.name}`,
|
|
429
|
+
policyName: policy.name,
|
|
430
|
+
command: policy.command,
|
|
431
|
+
originalUsing: policy.usingExpr,
|
|
432
|
+
originalWithCheck: policy.withCheckExpr,
|
|
433
|
+
suggestedRule,
|
|
434
|
+
manual: !auto,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function collectWarnings(collections, rlsPolicies, unsupported) {
|
|
438
|
+
const warnings = [];
|
|
439
|
+
for (const u of unsupported) {
|
|
440
|
+
warnings.push(`[${u.kind}] ${u.source}: ${u.reason}`);
|
|
441
|
+
}
|
|
442
|
+
const manualPolicies = rlsPolicies.filter((p) => p.manual);
|
|
443
|
+
if (manualPolicies.length > 0) {
|
|
444
|
+
warnings.push(`${manualPolicies.length} RLS polic${manualPolicies.length === 1 ? "y" : "ies"} could not be auto-translated to PocketBase API rules — see migrationNotes.rlsPolicies for manual rewrites.`);
|
|
445
|
+
}
|
|
446
|
+
const collectionCount = collections.length;
|
|
447
|
+
if (collectionCount === 0) {
|
|
448
|
+
warnings.push("No user-schema tables found to migrate.");
|
|
449
|
+
}
|
|
450
|
+
return warnings;
|
|
451
|
+
}
|
|
452
|
+
//# sourceMappingURL=migrate-supabase-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-supabase-map.js","sourceRoot":"","sources":["../../src/commands/migrate-supabase-map.ts"],"names":[],"mappings":"AA2LA;;;;;;;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,EAAE,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE;QACtC,UAAU,EAAE,MAAM,CAAC,IAAI;QACvB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa,EAAE,MAAM,CAAC,SAAS;QAC/B,iBAAiB,EAAE,MAAM,CAAC,aAAa;QACvC,aAAa;QACb,MAAM,EAAE,CAAC,IAAI;KACd,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CACtB,WAAmC,EACnC,WAAqC,EACrC,WAAmC;IAEnC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,QAAQ,CAAC,IAAI,CACX,GAAG,cAAc,CAAC,MAAM,aAAa,cAAc,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,6GAA6G,CAC5L,CAAC;IACJ,CAAC;IAED,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC;IAC3C,IAAI,eAAe,KAAK,CAAC,EAAE,CAAC;QAC1B,QAAQ,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Context } from "../context";
|
|
3
|
+
import { type AskUserRecovery, type NoneRecovery, type ToolRecovery } from "../recovery";
|
|
4
|
+
import { type InspectSupabaseError } from "./migrate-supabase";
|
|
5
|
+
import { type MigrationPreview } from "./migrate-supabase-map";
|
|
6
|
+
/**
|
|
7
|
+
* FUTURE9 Phase B chunk 2 — schema migration write step.
|
|
8
|
+
*
|
|
9
|
+
* Wires Phase A (`inspectSupabase`) + Phase B chunk 1
|
|
10
|
+
* (`mapSupabaseToPocketBase`) together and writes the preview files
|
|
11
|
+
* to a sibling directory the user can inspect before committing to
|
|
12
|
+
* the full migration (Phases C–D).
|
|
13
|
+
*
|
|
14
|
+
* Dry-run / apply contract (locked in STATUS_FUTURE9_phase-a.md):
|
|
15
|
+
* - Phase A (`inspectSupabase`) — strictly read-only, no writes.
|
|
16
|
+
* - Phase B (this command) — writes to ./migration-preview/ by
|
|
17
|
+
* default. The sibling dir IS the dry-run posture relative to
|
|
18
|
+
* a future `--apply` flag (Phase C/D) that will write to
|
|
19
|
+
* project root.
|
|
20
|
+
* - `outputDir` override exists for CI/tests/users who already
|
|
21
|
+
* have a `./migration-preview/` they care about.
|
|
22
|
+
*
|
|
23
|
+
* Token stays on the user's machine — same invariant as Phase A.
|
|
24
|
+
* The Supabase PAT is forwarded straight into `inspectSupabase`,
|
|
25
|
+
* which calls api.supabase.com directly; we never round-trip it
|
|
26
|
+
* through Percher's wire.
|
|
27
|
+
*/
|
|
28
|
+
export declare const migrateSupabaseSchemaInputSchema: z.ZodObject<{
|
|
29
|
+
projectRef: z.ZodString;
|
|
30
|
+
token: z.ZodString;
|
|
31
|
+
outputDir: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type MigrateSupabaseSchemaInput = z.infer<typeof migrateSupabaseSchemaInputSchema>;
|
|
34
|
+
export interface MigrateSupabaseSchemaResult {
|
|
35
|
+
status: "ok" | "failed";
|
|
36
|
+
projectRef: string;
|
|
37
|
+
/** Absolute path of the directory the preview files were (or would be) written to. */
|
|
38
|
+
outputDir: string;
|
|
39
|
+
/** Relative paths (from ctx.cwd) of every file written. Empty on failure. */
|
|
40
|
+
filesWritten: string[];
|
|
41
|
+
/** The full preview structure — same shape Phase B chunk 1 emits. */
|
|
42
|
+
preview: MigrationPreview | null;
|
|
43
|
+
recovery: ToolRecovery | NoneRecovery | AskUserRecovery;
|
|
44
|
+
summary: string;
|
|
45
|
+
error?: InspectSupabaseError | MigrateSchemaError;
|
|
46
|
+
}
|
|
47
|
+
export interface MigrateSchemaError {
|
|
48
|
+
code: "write_failed";
|
|
49
|
+
title: string;
|
|
50
|
+
explanation: string;
|
|
51
|
+
suggestion: string;
|
|
52
|
+
}
|
|
53
|
+
export declare function migrateSupabaseSchema(ctx: Context, input: MigrateSupabaseSchemaInput): Promise<MigrateSupabaseSchemaResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Markdown report the user reads before deciding to commit. Sections
|
|
56
|
+
* follow the example in the FUTURE9 plan (Steg 2):
|
|
57
|
+
* 1. Header (projectRef, when generated, totals)
|
|
58
|
+
* 2. Collections — one block per mapped table
|
|
59
|
+
* 3. RLS policies — Supabase original + suggested PB rule (or MANUAL)
|
|
60
|
+
* 4. Unsupported items — every thing the mapper refused to guess at
|
|
61
|
+
* 5. Auth / storage notes
|
|
62
|
+
*
|
|
63
|
+
* Stable wording — tests snapshot-compare. Don't reword on a whim;
|
|
64
|
+
* change the test if you do.
|
|
65
|
+
*/
|
|
66
|
+
export declare function renderMigrationNotes(preview: MigrationPreview): string;
|
|
67
|
+
//# sourceMappingURL=migrate-supabase-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-supabase-schema.d.ts","sourceRoot":"","sources":["../../src/commands/migrate-supabase-schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,YAAY,EAGjB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;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