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/migration/index.cjs
CHANGED
|
@@ -3494,7 +3494,7 @@ function formatValue(value) {
|
|
|
3494
3494
|
return JSON.stringify(value).replace(/","/g, '", "');
|
|
3495
3495
|
}
|
|
3496
3496
|
if (typeof value === "object") {
|
|
3497
|
-
const entries = Object.entries(value).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
3497
|
+
const entries = Object.entries(value).filter(([_k, v]) => v !== void 0).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
3498
3498
|
return `{ ${entries} }`;
|
|
3499
3499
|
}
|
|
3500
3500
|
return String(value);
|
|
@@ -3788,11 +3788,9 @@ function generateFieldModification(collectionName, modification, varName, isLast
|
|
|
3788
3788
|
function generateFieldDeletion(collectionName, fieldName, varName, isLast = false) {
|
|
3789
3789
|
const lines = [];
|
|
3790
3790
|
const collectionVar = varName || `collection_${collectionName}_${fieldName}`;
|
|
3791
|
-
const fieldVar = `${collectionVar}_field`;
|
|
3792
3791
|
lines.push(` const ${collectionVar} = app.findCollectionByNameOrId("${collectionName}");`);
|
|
3793
|
-
lines.push(` const ${fieldVar} = ${collectionVar}.fields.getByName("${fieldName}");`);
|
|
3794
3792
|
lines.push(``);
|
|
3795
|
-
lines.push(` ${collectionVar}.fields.
|
|
3793
|
+
lines.push(` ${collectionVar}.fields.removeByName("${fieldName}");`);
|
|
3796
3794
|
lines.push(``);
|
|
3797
3795
|
lines.push(isLast ? ` return app.save(${collectionVar});` : ` app.save(${collectionVar});`);
|
|
3798
3796
|
return lines.join("\n");
|
|
@@ -3910,20 +3908,23 @@ function generateOperationUpMigration(operation, collectionIdMap) {
|
|
|
3910
3908
|
lines.push(generateCollectionDeletion(collectionName, varName, true));
|
|
3911
3909
|
}
|
|
3912
3910
|
let code = lines.join("\n");
|
|
3913
|
-
const
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
if (
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3911
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
3912
|
+
if (!hasReturnStatement) {
|
|
3913
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
3914
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
3915
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
3916
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
3917
|
+
const allMatches = [
|
|
3918
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
3919
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
3920
|
+
].sort((a, b) => b.index - a.index);
|
|
3921
|
+
if (allMatches.length > 0) {
|
|
3922
|
+
const lastMatch = allMatches[0];
|
|
3923
|
+
if (lastMatch.type === "save") {
|
|
3924
|
+
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);
|
|
3925
|
+
} else {
|
|
3926
|
+
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);
|
|
3927
|
+
}
|
|
3927
3928
|
}
|
|
3928
3929
|
}
|
|
3929
3930
|
return code;
|
|
@@ -4012,20 +4013,23 @@ function generateOperationDownMigration(operation, collectionIdMap) {
|
|
|
4012
4013
|
}
|
|
4013
4014
|
}
|
|
4014
4015
|
let code = lines.join("\n");
|
|
4015
|
-
const
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
if (
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4016
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
4017
|
+
if (!hasReturnStatement) {
|
|
4018
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
4019
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
4020
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
4021
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
4022
|
+
const allMatches = [
|
|
4023
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
4024
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
4025
|
+
].sort((a, b) => b.index - a.index);
|
|
4026
|
+
if (allMatches.length > 0) {
|
|
4027
|
+
const lastMatch = allMatches[0];
|
|
4028
|
+
if (lastMatch.type === "save") {
|
|
4029
|
+
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);
|
|
4030
|
+
} else {
|
|
4031
|
+
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);
|
|
4032
|
+
}
|
|
4029
4033
|
}
|
|
4030
4034
|
}
|
|
4031
4035
|
return code;
|
|
@@ -4126,20 +4130,23 @@ function generateUpMigration(diff) {
|
|
|
4126
4130
|
lines.push(``);
|
|
4127
4131
|
}
|
|
4128
4132
|
let code = lines.join("\n");
|
|
4129
|
-
const
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
if (
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4133
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
4134
|
+
if (!hasReturnStatement) {
|
|
4135
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
4136
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
4137
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
4138
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
4139
|
+
const allMatches = [
|
|
4140
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
4141
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
4142
|
+
].sort((a, b) => b.index - a.index);
|
|
4143
|
+
if (allMatches.length > 0) {
|
|
4144
|
+
const lastMatch = allMatches[0];
|
|
4145
|
+
if (lastMatch.type === "save") {
|
|
4146
|
+
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);
|
|
4147
|
+
} else {
|
|
4148
|
+
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);
|
|
4149
|
+
}
|
|
4143
4150
|
}
|
|
4144
4151
|
}
|
|
4145
4152
|
return code;
|
|
@@ -4256,20 +4263,23 @@ function generateDownMigration(diff) {
|
|
|
4256
4263
|
lines.push(``);
|
|
4257
4264
|
}
|
|
4258
4265
|
let code = lines.join("\n");
|
|
4259
|
-
const
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
if (
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4266
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
4267
|
+
if (!hasReturnStatement) {
|
|
4268
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
4269
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
4270
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
4271
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
4272
|
+
const allMatches = [
|
|
4273
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
4274
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
4275
|
+
].sort((a, b) => b.index - a.index);
|
|
4276
|
+
if (allMatches.length > 0) {
|
|
4277
|
+
const lastMatch = allMatches[0];
|
|
4278
|
+
if (lastMatch.type === "save") {
|
|
4279
|
+
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);
|
|
4280
|
+
} else {
|
|
4281
|
+
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);
|
|
4282
|
+
}
|
|
4273
4283
|
}
|
|
4274
4284
|
}
|
|
4275
4285
|
return code;
|