pocketbase-zod-schema 0.3.1 → 0.3.2
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/CHANGELOG.md +7 -0
- package/dist/cli/index.cjs +36 -32
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +36 -32
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/migrate.cjs +36 -32
- package/dist/cli/migrate.cjs.map +1 -1
- package/dist/cli/migrate.js +36 -32
- package/dist/cli/migrate.js.map +1 -1
- package/dist/cli/utils/index.d.cts +2 -2
- package/dist/cli/utils/index.d.ts +2 -2
- package/dist/{fields-RVj26U-O.d.cts → fields-DBBm06VU.d.cts} +34 -7
- package/dist/{fields-RVj26U-O.d.ts → fields-DBBm06VU.d.ts} +34 -7
- package/dist/index.cjs +125 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +125 -66
- package/dist/index.js.map +1 -1
- package/dist/migration/analyzer.cjs.map +1 -1
- package/dist/migration/analyzer.d.cts +2 -2
- package/dist/migration/analyzer.d.ts +2 -2
- package/dist/migration/analyzer.js.map +1 -1
- package/dist/migration/diff.d.cts +2 -2
- package/dist/migration/diff.d.ts +2 -2
- package/dist/migration/generator.cjs +70 -60
- package/dist/migration/generator.cjs.map +1 -1
- package/dist/migration/generator.d.cts +2 -2
- package/dist/migration/generator.d.ts +2 -2
- package/dist/migration/generator.js +70 -60
- package/dist/migration/generator.js.map +1 -1
- package/dist/migration/index.cjs +70 -60
- package/dist/migration/index.cjs.map +1 -1
- package/dist/migration/index.d.cts +3 -3
- package/dist/migration/index.d.ts +3 -3
- package/dist/migration/index.js +70 -60
- package/dist/migration/index.js.map +1 -1
- package/dist/migration/snapshot.d.cts +2 -2
- package/dist/migration/snapshot.d.ts +2 -2
- package/dist/migration/utils/index.cjs.map +1 -1
- package/dist/migration/utils/index.d.cts +2 -2
- package/dist/migration/utils/index.d.ts +2 -2
- package/dist/migration/utils/index.js.map +1 -1
- package/dist/schema.cjs +55 -6
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.cts +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +55 -6
- package/dist/schema.js.map +1 -1
- package/dist/{type-mapper-DaBe-1ph.d.cts → type-mapper-DsGgZwUo.d.cts} +1 -1
- package/dist/{type-mapper-CZzVeDj7.d.ts → type-mapper-Dvh4QTM-.d.ts} +1 -1
- package/dist/{types-D-Fsdn_O.d.cts → types-CVxPCgWX.d.cts} +1 -1
- package/dist/{types-CUVzgZ9k.d.ts → types-Dfp-NP2D.d.ts} +1 -1
- package/package.json +1 -1
package/dist/cli/migrate.js
CHANGED
|
@@ -2145,7 +2145,7 @@ function formatValue(value) {
|
|
|
2145
2145
|
return JSON.stringify(value).replace(/","/g, '", "');
|
|
2146
2146
|
}
|
|
2147
2147
|
if (typeof value === "object") {
|
|
2148
|
-
const entries = Object.entries(value).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
2148
|
+
const entries = Object.entries(value).filter(([_k, v]) => v !== void 0).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
2149
2149
|
return `{ ${entries} }`;
|
|
2150
2150
|
}
|
|
2151
2151
|
return String(value);
|
|
@@ -2439,11 +2439,9 @@ function generateFieldModification(collectionName, modification, varName, isLast
|
|
|
2439
2439
|
function generateFieldDeletion(collectionName, fieldName, varName, isLast = false) {
|
|
2440
2440
|
const lines = [];
|
|
2441
2441
|
const collectionVar = varName || `collection_${collectionName}_${fieldName}`;
|
|
2442
|
-
const fieldVar = `${collectionVar}_field`;
|
|
2443
2442
|
lines.push(` const ${collectionVar} = app.findCollectionByNameOrId("${collectionName}");`);
|
|
2444
|
-
lines.push(` const ${fieldVar} = ${collectionVar}.fields.getByName("${fieldName}");`);
|
|
2445
2443
|
lines.push(``);
|
|
2446
|
-
lines.push(` ${collectionVar}.fields.
|
|
2444
|
+
lines.push(` ${collectionVar}.fields.removeByName("${fieldName}");`);
|
|
2447
2445
|
lines.push(``);
|
|
2448
2446
|
lines.push(isLast ? ` return app.save(${collectionVar});` : ` app.save(${collectionVar});`);
|
|
2449
2447
|
return lines.join("\n");
|
|
@@ -2561,20 +2559,23 @@ function generateOperationUpMigration(operation, collectionIdMap) {
|
|
|
2561
2559
|
lines.push(generateCollectionDeletion(collectionName, varName, true));
|
|
2562
2560
|
}
|
|
2563
2561
|
let code = lines.join("\n");
|
|
2564
|
-
const
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
if (
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2562
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
2563
|
+
if (!hasReturnStatement) {
|
|
2564
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
2565
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
2566
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
2567
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
2568
|
+
const allMatches = [
|
|
2569
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
2570
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
2571
|
+
].sort((a, b) => b.index - a.index);
|
|
2572
|
+
if (allMatches.length > 0) {
|
|
2573
|
+
const lastMatch = allMatches[0];
|
|
2574
|
+
if (lastMatch.type === "save") {
|
|
2575
|
+
code = code.substring(0, lastMatch.match.index) + lastMatch.match[1] + "return app.save(" + lastMatch.match[2] + ");" + code.substring(lastMatch.match.index + lastMatch.match[0].length);
|
|
2576
|
+
} else {
|
|
2577
|
+
code = code.substring(0, lastMatch.match.index) + lastMatch.match[1] + "return app.delete(" + lastMatch.match[2] + ");" + code.substring(lastMatch.match.index + lastMatch.match[0].length);
|
|
2578
|
+
}
|
|
2578
2579
|
}
|
|
2579
2580
|
}
|
|
2580
2581
|
return code;
|
|
@@ -2663,20 +2664,23 @@ function generateOperationDownMigration(operation, collectionIdMap) {
|
|
|
2663
2664
|
}
|
|
2664
2665
|
}
|
|
2665
2666
|
let code = lines.join("\n");
|
|
2666
|
-
const
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
if (
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2667
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
2668
|
+
if (!hasReturnStatement) {
|
|
2669
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
2670
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
2671
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
2672
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
2673
|
+
const allMatches = [
|
|
2674
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
2675
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
2676
|
+
].sort((a, b) => b.index - a.index);
|
|
2677
|
+
if (allMatches.length > 0) {
|
|
2678
|
+
const lastMatch = allMatches[0];
|
|
2679
|
+
if (lastMatch.type === "save") {
|
|
2680
|
+
code = code.substring(0, lastMatch.match.index) + lastMatch.match[1] + "return app.save(" + lastMatch.match[2] + ");" + code.substring(lastMatch.match.index + lastMatch.match[0].length);
|
|
2681
|
+
} else {
|
|
2682
|
+
code = code.substring(0, lastMatch.match.index) + lastMatch.match[1] + "return app.delete(" + lastMatch.match[2] + ");" + code.substring(lastMatch.match.index + lastMatch.match[0].length);
|
|
2683
|
+
}
|
|
2680
2684
|
}
|
|
2681
2685
|
}
|
|
2682
2686
|
return code;
|