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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.2](https://github.com/dastron/pocketbase-zod-schema/compare/pocketbase-zod-schema-v0.3.1...pocketbase-zod-schema-v0.3.2) (2026-01-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* update field removal method ([f673f5c](https://github.com/dastron/pocketbase-zod-schema/commit/f673f5c06e972ab4f556666469931c3729614bd4))
|
|
9
|
+
|
|
3
10
|
## [0.3.1](https://github.com/dastron/pocketbase-zod-schema/compare/pocketbase-zod-schema-v0.3.0...pocketbase-zod-schema-v0.3.1) (2026-01-05)
|
|
4
11
|
|
|
5
12
|
|
package/dist/cli/index.cjs
CHANGED
|
@@ -2168,7 +2168,7 @@ function formatValue(value) {
|
|
|
2168
2168
|
return JSON.stringify(value).replace(/","/g, '", "');
|
|
2169
2169
|
}
|
|
2170
2170
|
if (typeof value === "object") {
|
|
2171
|
-
const entries = Object.entries(value).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
2171
|
+
const entries = Object.entries(value).filter(([_k, v]) => v !== void 0).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
2172
2172
|
return `{ ${entries} }`;
|
|
2173
2173
|
}
|
|
2174
2174
|
return String(value);
|
|
@@ -2462,11 +2462,9 @@ function generateFieldModification(collectionName, modification, varName, isLast
|
|
|
2462
2462
|
function generateFieldDeletion(collectionName, fieldName, varName, isLast = false) {
|
|
2463
2463
|
const lines = [];
|
|
2464
2464
|
const collectionVar = varName || `collection_${collectionName}_${fieldName}`;
|
|
2465
|
-
const fieldVar = `${collectionVar}_field`;
|
|
2466
2465
|
lines.push(` const ${collectionVar} = app.findCollectionByNameOrId("${collectionName}");`);
|
|
2467
|
-
lines.push(` const ${fieldVar} = ${collectionVar}.fields.getByName("${fieldName}");`);
|
|
2468
2466
|
lines.push(``);
|
|
2469
|
-
lines.push(` ${collectionVar}.fields.
|
|
2467
|
+
lines.push(` ${collectionVar}.fields.removeByName("${fieldName}");`);
|
|
2470
2468
|
lines.push(``);
|
|
2471
2469
|
lines.push(isLast ? ` return app.save(${collectionVar});` : ` app.save(${collectionVar});`);
|
|
2472
2470
|
return lines.join("\n");
|
|
@@ -2584,20 +2582,23 @@ function generateOperationUpMigration(operation, collectionIdMap) {
|
|
|
2584
2582
|
lines.push(generateCollectionDeletion(collectionName, varName, true));
|
|
2585
2583
|
}
|
|
2586
2584
|
let code = lines.join("\n");
|
|
2587
|
-
const
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
if (
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2585
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
2586
|
+
if (!hasReturnStatement) {
|
|
2587
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
2588
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
2589
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
2590
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
2591
|
+
const allMatches = [
|
|
2592
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
2593
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
2594
|
+
].sort((a, b) => b.index - a.index);
|
|
2595
|
+
if (allMatches.length > 0) {
|
|
2596
|
+
const lastMatch = allMatches[0];
|
|
2597
|
+
if (lastMatch.type === "save") {
|
|
2598
|
+
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);
|
|
2599
|
+
} else {
|
|
2600
|
+
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);
|
|
2601
|
+
}
|
|
2601
2602
|
}
|
|
2602
2603
|
}
|
|
2603
2604
|
return code;
|
|
@@ -2686,20 +2687,23 @@ function generateOperationDownMigration(operation, collectionIdMap) {
|
|
|
2686
2687
|
}
|
|
2687
2688
|
}
|
|
2688
2689
|
let code = lines.join("\n");
|
|
2689
|
-
const
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
if (
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2690
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
2691
|
+
if (!hasReturnStatement) {
|
|
2692
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
2693
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
2694
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
2695
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
2696
|
+
const allMatches = [
|
|
2697
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
2698
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
2699
|
+
].sort((a, b) => b.index - a.index);
|
|
2700
|
+
if (allMatches.length > 0) {
|
|
2701
|
+
const lastMatch = allMatches[0];
|
|
2702
|
+
if (lastMatch.type === "save") {
|
|
2703
|
+
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);
|
|
2704
|
+
} else {
|
|
2705
|
+
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);
|
|
2706
|
+
}
|
|
2703
2707
|
}
|
|
2704
2708
|
}
|
|
2705
2709
|
return code;
|