pocketbase-zod-schema 0.3.2 → 0.3.3
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 +28 -6
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +28 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/migrate.cjs +28 -6
- package/dist/cli/migrate.cjs.map +1 -1
- package/dist/cli/migrate.js +28 -6
- package/dist/cli/migrate.js.map +1 -1
- package/dist/cli/utils/index.d.cts +1 -1
- package/dist/cli/utils/index.d.ts +1 -1
- package/dist/index.cjs +42 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -9
- package/dist/index.js.map +1 -1
- package/dist/migration/analyzer.d.cts +1 -1
- package/dist/migration/analyzer.d.ts +1 -1
- package/dist/migration/diff.cjs +10 -1
- package/dist/migration/diff.cjs.map +1 -1
- package/dist/migration/diff.d.cts +1 -1
- package/dist/migration/diff.d.ts +1 -1
- package/dist/migration/diff.js +10 -1
- package/dist/migration/diff.js.map +1 -1
- package/dist/migration/generator.cjs +32 -8
- 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 +32 -8
- package/dist/migration/generator.js.map +1 -1
- package/dist/migration/index.cjs +42 -9
- package/dist/migration/index.cjs.map +1 -1
- package/dist/migration/index.d.cts +1 -1
- package/dist/migration/index.d.ts +1 -1
- package/dist/migration/index.js +42 -9
- package/dist/migration/index.js.map +1 -1
- package/dist/migration/snapshot.d.cts +1 -1
- package/dist/migration/snapshot.d.ts +1 -1
- package/dist/{types-Dfp-NP2D.d.ts → types-BWhwQxG-.d.ts} +5 -0
- package/dist/{types-CVxPCgWX.d.cts → types-d0yBwHoN.d.cts} +5 -0
- package/package.json +1 -1
package/dist/cli/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
3
|
+
import '../types-d0yBwHoN.cjs';
|
|
4
4
|
import '../fields-DBBm06VU.cjs';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '../permissions-ZHafVSIx.cjs';
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
3
|
+
import '../types-BWhwQxG-.js';
|
|
4
4
|
import '../fields-DBBm06VU.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '../permissions-ZHafVSIx.js';
|
package/dist/cli/index.js
CHANGED
|
@@ -1935,10 +1935,19 @@ function aggregateChanges(currentSchema, previousSnapshot, config) {
|
|
|
1935
1935
|
collectionsToModify.push(modification);
|
|
1936
1936
|
}
|
|
1937
1937
|
}
|
|
1938
|
+
const existingCollectionIds = /* @__PURE__ */ new Map();
|
|
1939
|
+
if (previousSnapshot) {
|
|
1940
|
+
for (const [name, collection] of previousSnapshot.collections) {
|
|
1941
|
+
if (collection.id) {
|
|
1942
|
+
existingCollectionIds.set(name, collection.id);
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1938
1946
|
return {
|
|
1939
1947
|
collectionsToCreate: collectionsWithIds,
|
|
1940
1948
|
collectionsToDelete: filteredCollectionsToDelete,
|
|
1941
|
-
collectionsToModify
|
|
1949
|
+
collectionsToModify,
|
|
1950
|
+
existingCollectionIds
|
|
1942
1951
|
};
|
|
1943
1952
|
}
|
|
1944
1953
|
function categorizeChangesBySeverity(diff, _config) {
|
|
@@ -2404,7 +2413,7 @@ function generateFieldAddition(collectionName, field, varName, isLast = false, c
|
|
|
2404
2413
|
lines.push(isLast ? ` return app.save(${collectionVar});` : ` app.save(${collectionVar});`);
|
|
2405
2414
|
return lines.join("\n");
|
|
2406
2415
|
}
|
|
2407
|
-
function generateFieldModification(collectionName, modification, varName, isLast = false) {
|
|
2416
|
+
function generateFieldModification(collectionName, modification, varName, isLast = false, collectionIdMap) {
|
|
2408
2417
|
const lines = [];
|
|
2409
2418
|
const collectionVar = varName || `collection_${collectionName}_${modification.fieldName}`;
|
|
2410
2419
|
const fieldVar = `${collectionVar}_field`;
|
|
@@ -2419,7 +2428,14 @@ function generateFieldModification(collectionName, modification, varName, isLast
|
|
|
2419
2428
|
const relationKey = change.property.replace("relation.", "");
|
|
2420
2429
|
if (relationKey === "collection") {
|
|
2421
2430
|
const isUsersCollection = String(change.newValue).toLowerCase() === "users";
|
|
2422
|
-
|
|
2431
|
+
let collectionIdValue;
|
|
2432
|
+
if (isUsersCollection) {
|
|
2433
|
+
collectionIdValue = '"_pb_users_auth_"';
|
|
2434
|
+
} else if (collectionIdMap && collectionIdMap.has(String(change.newValue))) {
|
|
2435
|
+
collectionIdValue = `"${collectionIdMap.get(String(change.newValue))}"`;
|
|
2436
|
+
} else {
|
|
2437
|
+
collectionIdValue = `app.findCollectionByNameOrId("${change.newValue}").id`;
|
|
2438
|
+
}
|
|
2423
2439
|
lines.push(` ${fieldVar}.collectionId = ${collectionIdValue};`);
|
|
2424
2440
|
} else {
|
|
2425
2441
|
lines.push(` ${fieldVar}.${relationKey} = ${formatValue(change.newValue)};`);
|
|
@@ -2495,9 +2511,10 @@ function generateOperationUpMigration(operation, collectionIdMap) {
|
|
|
2495
2511
|
const collectionName = typeof operation.collection === "string" ? operation.collection : operation.collection?.name ?? modification.collection;
|
|
2496
2512
|
let operationCount = 0;
|
|
2497
2513
|
const totalOperations = modification.fieldsToAdd.length + modification.fieldsToModify.length + modification.fieldsToRemove.length + modification.indexesToAdd.length + modification.indexesToRemove.length + modification.rulesToUpdate.length + modification.permissionsToUpdate.length;
|
|
2498
|
-
for (
|
|
2514
|
+
for (let i = 0; i < modification.fieldsToAdd.length; i++) {
|
|
2515
|
+
const field = modification.fieldsToAdd[i];
|
|
2499
2516
|
operationCount++;
|
|
2500
|
-
const varName = `collection_${collectionName}_add_${field.name}`;
|
|
2517
|
+
const varName = `collection_${collectionName}_add_${field.name}_${i}`;
|
|
2501
2518
|
const isLast = operationCount === totalOperations;
|
|
2502
2519
|
lines.push(generateFieldAddition(collectionName, field, varName, isLast, collectionIdMap));
|
|
2503
2520
|
if (!isLast) lines.push("");
|
|
@@ -2506,7 +2523,7 @@ function generateOperationUpMigration(operation, collectionIdMap) {
|
|
|
2506
2523
|
operationCount++;
|
|
2507
2524
|
const varName = `collection_${collectionName}_modify_${fieldMod.fieldName}`;
|
|
2508
2525
|
const isLast = operationCount === totalOperations;
|
|
2509
|
-
lines.push(generateFieldModification(collectionName, fieldMod, varName, isLast));
|
|
2526
|
+
lines.push(generateFieldModification(collectionName, fieldMod, varName, isLast, collectionIdMap));
|
|
2510
2527
|
if (!isLast) lines.push("");
|
|
2511
2528
|
}
|
|
2512
2529
|
for (const field of modification.fieldsToRemove) {
|
|
@@ -2700,6 +2717,11 @@ function generate(diff, config) {
|
|
|
2700
2717
|
collectionIdMap.set(collection.name, collection.id);
|
|
2701
2718
|
}
|
|
2702
2719
|
}
|
|
2720
|
+
if (diff.existingCollectionIds) {
|
|
2721
|
+
for (const [name, id] of diff.existingCollectionIds) {
|
|
2722
|
+
collectionIdMap.set(name, id);
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2703
2725
|
const baseTimestamp = generateTimestamp(normalizedConfig);
|
|
2704
2726
|
const operations = splitDiffByCollection(diff, baseTimestamp);
|
|
2705
2727
|
const filePaths = [];
|