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/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { MigrationConfig, StatusOutput, VerbosityLevel, createProgressBar, createSpinner, formatChangeSummary, formatDuration, formatStatusJson, getMigrationsDirectory, getSchemaDirectory, getVerbosity, loadConfig, logBox, logDebug, logError, logInfo, logKeyValue, logList, logSection, logStep, logSuccess, logTable, logTimed, logTimestamp, logWarning, setVerbosity, withProgress } from './utils/index.cjs';
|
|
2
2
|
import 'ora';
|
|
3
|
-
import '../types-
|
|
4
|
-
import '../fields-
|
|
3
|
+
import '../types-CVxPCgWX.cjs';
|
|
4
|
+
import '../fields-DBBm06VU.cjs';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '../permissions-ZHafVSIx.cjs';
|
|
7
7
|
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { MigrationConfig, StatusOutput, VerbosityLevel, createProgressBar, createSpinner, formatChangeSummary, formatDuration, formatStatusJson, getMigrationsDirectory, getSchemaDirectory, getVerbosity, loadConfig, logBox, logDebug, logError, logInfo, logKeyValue, logList, logSection, logStep, logSuccess, logTable, logTimed, logTimestamp, logWarning, setVerbosity, withProgress } from './utils/index.js';
|
|
2
2
|
import 'ora';
|
|
3
|
-
import '../types-
|
|
4
|
-
import '../fields-
|
|
3
|
+
import '../types-Dfp-NP2D.js';
|
|
4
|
+
import '../fields-DBBm06VU.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '../permissions-ZHafVSIx.js';
|
|
7
7
|
|
package/dist/cli/index.js
CHANGED
|
@@ -2141,7 +2141,7 @@ function formatValue(value) {
|
|
|
2141
2141
|
return JSON.stringify(value).replace(/","/g, '", "');
|
|
2142
2142
|
}
|
|
2143
2143
|
if (typeof value === "object") {
|
|
2144
|
-
const entries = Object.entries(value).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
2144
|
+
const entries = Object.entries(value).filter(([_k, v]) => v !== void 0).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
2145
2145
|
return `{ ${entries} }`;
|
|
2146
2146
|
}
|
|
2147
2147
|
return String(value);
|
|
@@ -2435,11 +2435,9 @@ function generateFieldModification(collectionName, modification, varName, isLast
|
|
|
2435
2435
|
function generateFieldDeletion(collectionName, fieldName, varName, isLast = false) {
|
|
2436
2436
|
const lines = [];
|
|
2437
2437
|
const collectionVar = varName || `collection_${collectionName}_${fieldName}`;
|
|
2438
|
-
const fieldVar = `${collectionVar}_field`;
|
|
2439
2438
|
lines.push(` const ${collectionVar} = app.findCollectionByNameOrId("${collectionName}");`);
|
|
2440
|
-
lines.push(` const ${fieldVar} = ${collectionVar}.fields.getByName("${fieldName}");`);
|
|
2441
2439
|
lines.push(``);
|
|
2442
|
-
lines.push(` ${collectionVar}.fields.
|
|
2440
|
+
lines.push(` ${collectionVar}.fields.removeByName("${fieldName}");`);
|
|
2443
2441
|
lines.push(``);
|
|
2444
2442
|
lines.push(isLast ? ` return app.save(${collectionVar});` : ` app.save(${collectionVar});`);
|
|
2445
2443
|
return lines.join("\n");
|
|
@@ -2557,20 +2555,23 @@ function generateOperationUpMigration(operation, collectionIdMap) {
|
|
|
2557
2555
|
lines.push(generateCollectionDeletion(collectionName, varName, true));
|
|
2558
2556
|
}
|
|
2559
2557
|
let code = lines.join("\n");
|
|
2560
|
-
const
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
if (
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2558
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
2559
|
+
if (!hasReturnStatement) {
|
|
2560
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
2561
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
2562
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
2563
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
2564
|
+
const allMatches = [
|
|
2565
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
2566
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
2567
|
+
].sort((a, b) => b.index - a.index);
|
|
2568
|
+
if (allMatches.length > 0) {
|
|
2569
|
+
const lastMatch = allMatches[0];
|
|
2570
|
+
if (lastMatch.type === "save") {
|
|
2571
|
+
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);
|
|
2572
|
+
} else {
|
|
2573
|
+
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);
|
|
2574
|
+
}
|
|
2574
2575
|
}
|
|
2575
2576
|
}
|
|
2576
2577
|
return code;
|
|
@@ -2659,20 +2660,23 @@ function generateOperationDownMigration(operation, collectionIdMap) {
|
|
|
2659
2660
|
}
|
|
2660
2661
|
}
|
|
2661
2662
|
let code = lines.join("\n");
|
|
2662
|
-
const
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
if (
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2663
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
2664
|
+
if (!hasReturnStatement) {
|
|
2665
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
2666
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
2667
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
2668
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
2669
|
+
const allMatches = [
|
|
2670
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
2671
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
2672
|
+
].sort((a, b) => b.index - a.index);
|
|
2673
|
+
if (allMatches.length > 0) {
|
|
2674
|
+
const lastMatch = allMatches[0];
|
|
2675
|
+
if (lastMatch.type === "save") {
|
|
2676
|
+
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);
|
|
2677
|
+
} else {
|
|
2678
|
+
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);
|
|
2679
|
+
}
|
|
2676
2680
|
}
|
|
2677
2681
|
}
|
|
2678
2682
|
return code;
|