pocketbase-zod-schema 0.3.7 → 0.3.9
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 +15 -0
- package/dist/cli/index.cjs +14 -30
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +14 -30
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/migrate.cjs +14 -30
- package/dist/cli/migrate.cjs.map +1 -1
- package/dist/cli/migrate.js +14 -30
- package/dist/cli/migrate.js.map +1 -1
- package/dist/index.cjs +14 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -30
- package/dist/index.js.map +1 -1
- package/dist/migration/analyzer.cjs +12 -28
- package/dist/migration/analyzer.cjs.map +1 -1
- package/dist/migration/analyzer.js +12 -28
- package/dist/migration/analyzer.js.map +1 -1
- package/dist/migration/generator.cjs +2 -2
- package/dist/migration/generator.cjs.map +1 -1
- package/dist/migration/generator.js +2 -2
- package/dist/migration/generator.js.map +1 -1
- package/dist/migration/index.cjs +14 -30
- package/dist/migration/index.cjs.map +1 -1
- package/dist/migration/index.js +14 -30
- package/dist/migration/index.js.map +1 -1
- package/dist/migration/utils/index.cjs +12 -28
- package/dist/migration/utils/index.cjs.map +1 -1
- package/dist/migration/utils/index.js +12 -28
- package/dist/migration/utils/index.js.map +1 -1
- package/package.json +3 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.9](https://github.com/dastron/pocketbase-zod-schema/compare/pocketbase-zod-schema-v0.3.8...pocketbase-zod-schema-v0.3.9) (2026-01-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* recursive unwrap of zod types for correct field type mapping ([212c2d1](https://github.com/dastron/pocketbase-zod-schema/commit/212c2d189ae27b57146075dc4481f794538c7a53))
|
|
9
|
+
* update @vitest/coverage-v8 version to match vitest ([f4d0fa6](https://github.com/dastron/pocketbase-zod-schema/commit/f4d0fa6060319742042e250bb7078f34deb1f788))
|
|
10
|
+
|
|
11
|
+
## [0.3.8](https://github.com/dastron/pocketbase-zod-schema/compare/pocketbase-zod-schema-v0.3.7...pocketbase-zod-schema-v0.3.8) (2026-01-15)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* remove peer dep ([a5b85f6](https://github.com/dastron/pocketbase-zod-schema/commit/a5b85f65b2acd6e04f93a600e812204066ed5d2e))
|
|
17
|
+
|
|
3
18
|
## [0.3.7](https://github.com/dastron/pocketbase-zod-schema/compare/pocketbase-zod-schema-v0.3.6...pocketbase-zod-schema-v0.3.7) (2026-01-15)
|
|
4
19
|
|
|
5
20
|
|
package/dist/cli/index.cjs
CHANGED
|
@@ -977,16 +977,7 @@ function mapZodRecordType(_zodType) {
|
|
|
977
977
|
return "json";
|
|
978
978
|
}
|
|
979
979
|
function mapZodTypeToPocketBase(zodType, fieldName) {
|
|
980
|
-
|
|
981
|
-
if (zodType instanceof zod.z.ZodOptional) {
|
|
982
|
-
unwrappedType = zodType.unwrap();
|
|
983
|
-
}
|
|
984
|
-
if (unwrappedType instanceof zod.z.ZodNullable) {
|
|
985
|
-
unwrappedType = unwrappedType.unwrap();
|
|
986
|
-
}
|
|
987
|
-
if (unwrappedType instanceof zod.z.ZodDefault) {
|
|
988
|
-
unwrappedType = unwrappedType.unwrap();
|
|
989
|
-
}
|
|
980
|
+
const unwrappedType = unwrapZodType(zodType);
|
|
990
981
|
if (unwrappedType instanceof zod.z.ZodFile) {
|
|
991
982
|
return "file";
|
|
992
983
|
}
|
|
@@ -1015,16 +1006,7 @@ function mapZodTypeToPocketBase(zodType, fieldName) {
|
|
|
1015
1006
|
}
|
|
1016
1007
|
function extractFieldOptions(zodType) {
|
|
1017
1008
|
const options = {};
|
|
1018
|
-
|
|
1019
|
-
if (zodType instanceof zod.z.ZodOptional) {
|
|
1020
|
-
unwrappedType = zodType.unwrap();
|
|
1021
|
-
}
|
|
1022
|
-
if (unwrappedType instanceof zod.z.ZodNullable) {
|
|
1023
|
-
unwrappedType = unwrappedType.unwrap();
|
|
1024
|
-
}
|
|
1025
|
-
if (unwrappedType instanceof zod.z.ZodDefault) {
|
|
1026
|
-
unwrappedType = unwrappedType.unwrap();
|
|
1027
|
-
}
|
|
1009
|
+
const unwrappedType = unwrapZodType(zodType);
|
|
1028
1010
|
const checks = getChecks2(unwrappedType);
|
|
1029
1011
|
if (unwrappedType instanceof zod.z.ZodString) {
|
|
1030
1012
|
for (const check of checks) {
|
|
@@ -1115,14 +1097,16 @@ function isFieldRequired(zodType) {
|
|
|
1115
1097
|
}
|
|
1116
1098
|
function unwrapZodType(zodType) {
|
|
1117
1099
|
let unwrapped = zodType;
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
unwrapped
|
|
1100
|
+
let previous = null;
|
|
1101
|
+
while (unwrapped !== previous) {
|
|
1102
|
+
previous = unwrapped;
|
|
1103
|
+
if (unwrapped instanceof zod.z.ZodOptional) {
|
|
1104
|
+
unwrapped = unwrapped.unwrap();
|
|
1105
|
+
} else if (unwrapped instanceof zod.z.ZodNullable) {
|
|
1106
|
+
unwrapped = unwrapped.unwrap();
|
|
1107
|
+
} else if (unwrapped instanceof zod.z.ZodDefault) {
|
|
1108
|
+
unwrapped = unwrapped.unwrap();
|
|
1109
|
+
}
|
|
1126
1110
|
}
|
|
1127
1111
|
return unwrapped;
|
|
1128
1112
|
}
|
|
@@ -2120,7 +2104,7 @@ function splitDiffByCollection(diff, baseTimestamp) {
|
|
|
2120
2104
|
for (const collection of diff.collectionsToDelete) {
|
|
2121
2105
|
operations.push({
|
|
2122
2106
|
type: "delete",
|
|
2123
|
-
collection
|
|
2107
|
+
collection,
|
|
2124
2108
|
// Handle both object and string
|
|
2125
2109
|
timestamp: currentTimestamp.toString()
|
|
2126
2110
|
});
|
|
@@ -2137,7 +2121,7 @@ function generateCollectionMigrationFilename(operation) {
|
|
|
2137
2121
|
} else {
|
|
2138
2122
|
collectionName = operation.collection.name;
|
|
2139
2123
|
}
|
|
2140
|
-
const sanitizedName = collectionName.replace(/[^a-zA-Z0-9_]/g, "_")
|
|
2124
|
+
const sanitizedName = collectionName.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
2141
2125
|
return `${timestamp}_${operationType}_${sanitizedName}.js`;
|
|
2142
2126
|
}
|
|
2143
2127
|
function createMigrationFileStructure(upCode, downCode, config) {
|