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.cjs
CHANGED
|
@@ -2173,7 +2173,7 @@ function formatValue(value) {
|
|
|
2173
2173
|
return JSON.stringify(value).replace(/","/g, '", "');
|
|
2174
2174
|
}
|
|
2175
2175
|
if (typeof value === "object") {
|
|
2176
|
-
const entries = Object.entries(value).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
2176
|
+
const entries = Object.entries(value).filter(([_k, v]) => v !== void 0).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
2177
2177
|
return `{ ${entries} }`;
|
|
2178
2178
|
}
|
|
2179
2179
|
return String(value);
|
|
@@ -2467,11 +2467,9 @@ function generateFieldModification(collectionName, modification, varName, isLast
|
|
|
2467
2467
|
function generateFieldDeletion(collectionName, fieldName, varName, isLast = false) {
|
|
2468
2468
|
const lines = [];
|
|
2469
2469
|
const collectionVar = varName || `collection_${collectionName}_${fieldName}`;
|
|
2470
|
-
const fieldVar = `${collectionVar}_field`;
|
|
2471
2470
|
lines.push(` const ${collectionVar} = app.findCollectionByNameOrId("${collectionName}");`);
|
|
2472
|
-
lines.push(` const ${fieldVar} = ${collectionVar}.fields.getByName("${fieldName}");`);
|
|
2473
2471
|
lines.push(``);
|
|
2474
|
-
lines.push(` ${collectionVar}.fields.
|
|
2472
|
+
lines.push(` ${collectionVar}.fields.removeByName("${fieldName}");`);
|
|
2475
2473
|
lines.push(``);
|
|
2476
2474
|
lines.push(isLast ? ` return app.save(${collectionVar});` : ` app.save(${collectionVar});`);
|
|
2477
2475
|
return lines.join("\n");
|
|
@@ -2589,20 +2587,23 @@ function generateOperationUpMigration(operation, collectionIdMap) {
|
|
|
2589
2587
|
lines.push(generateCollectionDeletion(collectionName, varName, true));
|
|
2590
2588
|
}
|
|
2591
2589
|
let code = lines.join("\n");
|
|
2592
|
-
const
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
if (
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2590
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
2591
|
+
if (!hasReturnStatement) {
|
|
2592
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
2593
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
2594
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
2595
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
2596
|
+
const allMatches = [
|
|
2597
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
2598
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
2599
|
+
].sort((a, b) => b.index - a.index);
|
|
2600
|
+
if (allMatches.length > 0) {
|
|
2601
|
+
const lastMatch = allMatches[0];
|
|
2602
|
+
if (lastMatch.type === "save") {
|
|
2603
|
+
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);
|
|
2604
|
+
} else {
|
|
2605
|
+
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);
|
|
2606
|
+
}
|
|
2606
2607
|
}
|
|
2607
2608
|
}
|
|
2608
2609
|
return code;
|
|
@@ -2691,20 +2692,23 @@ function generateOperationDownMigration(operation, collectionIdMap) {
|
|
|
2691
2692
|
}
|
|
2692
2693
|
}
|
|
2693
2694
|
let code = lines.join("\n");
|
|
2694
|
-
const
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
if (
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2695
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
2696
|
+
if (!hasReturnStatement) {
|
|
2697
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
2698
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
2699
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
2700
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
2701
|
+
const allMatches = [
|
|
2702
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
2703
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
2704
|
+
].sort((a, b) => b.index - a.index);
|
|
2705
|
+
if (allMatches.length > 0) {
|
|
2706
|
+
const lastMatch = allMatches[0];
|
|
2707
|
+
if (lastMatch.type === "save") {
|
|
2708
|
+
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);
|
|
2709
|
+
} else {
|
|
2710
|
+
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);
|
|
2711
|
+
}
|
|
2708
2712
|
}
|
|
2709
2713
|
}
|
|
2710
2714
|
return code;
|