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
|
@@ -2,9 +2,9 @@ export { SchemaAnalyzer, SchemaAnalyzerConfig, buildFieldDefinition, buildSchema
|
|
|
2
2
|
export { SnapshotConfig, SnapshotManager, convertPocketBaseMigration, findLatestSnapshot, getSnapshotPath, getSnapshotVersion, loadBaseMigration, loadSnapshot, loadSnapshotIfExists, loadSnapshotWithMigrations, mergeSnapshots, saveSnapshot, snapshotExists, validateSnapshot } from './snapshot.cjs';
|
|
3
3
|
export { ChangeSummary, DestructiveChange, DiffEngine, DiffEngineConfig, aggregateChanges, categorizeChangesBySeverity, compare, compareFieldConstraints, compareFieldOptions, compareFieldTypes, comparePermissions, compareRelationConfigurations, detectDestructiveChanges, detectFieldChanges, filterSystemCollections, findNewCollections, findNewFields, findRemovedCollections, findRemovedFields, generateChangeSummary, getUsersSystemFields, isSystemCollection, matchCollectionsByName, matchFieldsByName, requiresForceFlag } from './diff.cjs';
|
|
4
4
|
export { MigrationGenerator, MigrationGeneratorConfig, createMigrationFileStructure, generate, generateCollectionCreation, generateCollectionPermissions, generateCollectionRules, generateDownMigration, generateFieldAddition, generateFieldDefinitionObject, generateFieldDeletion, generateFieldModification, generateFieldsArray, generateIndexesArray, generateMigrationDescription, generateMigrationFilename, generatePermissionUpdate, generateTimestamp, generateUpMigration, writeMigrationFile } from './generator.cjs';
|
|
5
|
-
export { d as CollectionModification, f as CollectionOperation, C as CollectionSchema, b as FieldChange, F as FieldDefinition, c as FieldModification, P as PermissionChange, R as RuleUpdate, S as SchemaDefinition, e as SchemaDiff, a as SchemaSnapshot } from '../types-
|
|
6
|
-
export { E as ExtractedFieldOptions, d as FIELD_TYPE_INFO, F as FieldTypeInfo, C as FieldTypeResult, P as POCKETBASE_FIELD_TYPES, z as extractComprehensiveFieldOptions, o as extractFieldOptions, x as getArrayElementType, v as getDefaultValue, D as getFieldTypeInfo, g as getMaxSelect, c as getMinSelect, w as isArrayType, A as isEditorField, q as isFieldRequired, B as isFileFieldByName, y as isGeoPointType, a as isMultipleRelationField, b as isRelationField, i as isSingleRelationField, j as mapZodArrayType, f as mapZodBooleanType, k as mapZodDateType, h as mapZodEnumType, e as mapZodNumberType, l as mapZodRecordType, m as mapZodStringType, n as mapZodTypeToPocketBase, p as pluralize, r as resolveTargetCollection, s as singularize, t as toCollectionName, u as unwrapZodType } from '../type-mapper-
|
|
7
|
-
export { F as FIELD_METADATA_KEY, a as FieldMetadata, P as PocketBaseFieldType, e as extractFieldMetadata } from '../fields-
|
|
5
|
+
export { d as CollectionModification, f as CollectionOperation, C as CollectionSchema, b as FieldChange, F as FieldDefinition, c as FieldModification, P as PermissionChange, R as RuleUpdate, S as SchemaDefinition, e as SchemaDiff, a as SchemaSnapshot } from '../types-CVxPCgWX.cjs';
|
|
6
|
+
export { E as ExtractedFieldOptions, d as FIELD_TYPE_INFO, F as FieldTypeInfo, C as FieldTypeResult, P as POCKETBASE_FIELD_TYPES, z as extractComprehensiveFieldOptions, o as extractFieldOptions, x as getArrayElementType, v as getDefaultValue, D as getFieldTypeInfo, g as getMaxSelect, c as getMinSelect, w as isArrayType, A as isEditorField, q as isFieldRequired, B as isFileFieldByName, y as isGeoPointType, a as isMultipleRelationField, b as isRelationField, i as isSingleRelationField, j as mapZodArrayType, f as mapZodBooleanType, k as mapZodDateType, h as mapZodEnumType, e as mapZodNumberType, l as mapZodRecordType, m as mapZodStringType, n as mapZodTypeToPocketBase, p as pluralize, r as resolveTargetCollection, s as singularize, t as toCollectionName, u as unwrapZodType } from '../type-mapper-DsGgZwUo.cjs';
|
|
7
|
+
export { F as FIELD_METADATA_KEY, a as FieldMetadata, P as PocketBaseFieldType, e as extractFieldMetadata } from '../fields-DBBm06VU.cjs';
|
|
8
8
|
export { A as APIRuleType } from '../permissions-ZHafVSIx.cjs';
|
|
9
9
|
import 'zod';
|
|
10
10
|
|
|
@@ -2,9 +2,9 @@ export { SchemaAnalyzer, SchemaAnalyzerConfig, buildFieldDefinition, buildSchema
|
|
|
2
2
|
export { SnapshotConfig, SnapshotManager, convertPocketBaseMigration, findLatestSnapshot, getSnapshotPath, getSnapshotVersion, loadBaseMigration, loadSnapshot, loadSnapshotIfExists, loadSnapshotWithMigrations, mergeSnapshots, saveSnapshot, snapshotExists, validateSnapshot } from './snapshot.js';
|
|
3
3
|
export { ChangeSummary, DestructiveChange, DiffEngine, DiffEngineConfig, aggregateChanges, categorizeChangesBySeverity, compare, compareFieldConstraints, compareFieldOptions, compareFieldTypes, comparePermissions, compareRelationConfigurations, detectDestructiveChanges, detectFieldChanges, filterSystemCollections, findNewCollections, findNewFields, findRemovedCollections, findRemovedFields, generateChangeSummary, getUsersSystemFields, isSystemCollection, matchCollectionsByName, matchFieldsByName, requiresForceFlag } from './diff.js';
|
|
4
4
|
export { MigrationGenerator, MigrationGeneratorConfig, createMigrationFileStructure, generate, generateCollectionCreation, generateCollectionPermissions, generateCollectionRules, generateDownMigration, generateFieldAddition, generateFieldDefinitionObject, generateFieldDeletion, generateFieldModification, generateFieldsArray, generateIndexesArray, generateMigrationDescription, generateMigrationFilename, generatePermissionUpdate, generateTimestamp, generateUpMigration, writeMigrationFile } from './generator.js';
|
|
5
|
-
export { d as CollectionModification, f as CollectionOperation, C as CollectionSchema, b as FieldChange, F as FieldDefinition, c as FieldModification, P as PermissionChange, R as RuleUpdate, S as SchemaDefinition, e as SchemaDiff, a as SchemaSnapshot } from '../types-
|
|
6
|
-
export { E as ExtractedFieldOptions, d as FIELD_TYPE_INFO, F as FieldTypeInfo, C as FieldTypeResult, P as POCKETBASE_FIELD_TYPES, z as extractComprehensiveFieldOptions, o as extractFieldOptions, x as getArrayElementType, v as getDefaultValue, D as getFieldTypeInfo, g as getMaxSelect, c as getMinSelect, w as isArrayType, A as isEditorField, q as isFieldRequired, B as isFileFieldByName, y as isGeoPointType, a as isMultipleRelationField, b as isRelationField, i as isSingleRelationField, j as mapZodArrayType, f as mapZodBooleanType, k as mapZodDateType, h as mapZodEnumType, e as mapZodNumberType, l as mapZodRecordType, m as mapZodStringType, n as mapZodTypeToPocketBase, p as pluralize, r as resolveTargetCollection, s as singularize, t as toCollectionName, u as unwrapZodType } from '../type-mapper-
|
|
7
|
-
export { F as FIELD_METADATA_KEY, a as FieldMetadata, P as PocketBaseFieldType, e as extractFieldMetadata } from '../fields-
|
|
5
|
+
export { d as CollectionModification, f as CollectionOperation, C as CollectionSchema, b as FieldChange, F as FieldDefinition, c as FieldModification, P as PermissionChange, R as RuleUpdate, S as SchemaDefinition, e as SchemaDiff, a as SchemaSnapshot } from '../types-Dfp-NP2D.js';
|
|
6
|
+
export { E as ExtractedFieldOptions, d as FIELD_TYPE_INFO, F as FieldTypeInfo, C as FieldTypeResult, P as POCKETBASE_FIELD_TYPES, z as extractComprehensiveFieldOptions, o as extractFieldOptions, x as getArrayElementType, v as getDefaultValue, D as getFieldTypeInfo, g as getMaxSelect, c as getMinSelect, w as isArrayType, A as isEditorField, q as isFieldRequired, B as isFileFieldByName, y as isGeoPointType, a as isMultipleRelationField, b as isRelationField, i as isSingleRelationField, j as mapZodArrayType, f as mapZodBooleanType, k as mapZodDateType, h as mapZodEnumType, e as mapZodNumberType, l as mapZodRecordType, m as mapZodStringType, n as mapZodTypeToPocketBase, p as pluralize, r as resolveTargetCollection, s as singularize, t as toCollectionName, u as unwrapZodType } from '../type-mapper-Dvh4QTM-.js';
|
|
7
|
+
export { F as FIELD_METADATA_KEY, a as FieldMetadata, P as PocketBaseFieldType, e as extractFieldMetadata } from '../fields-DBBm06VU.js';
|
|
8
8
|
export { A as APIRuleType } from '../permissions-ZHafVSIx.js';
|
|
9
9
|
import 'zod';
|
|
10
10
|
|
package/dist/migration/index.js
CHANGED
|
@@ -3471,7 +3471,7 @@ function formatValue(value) {
|
|
|
3471
3471
|
return JSON.stringify(value).replace(/","/g, '", "');
|
|
3472
3472
|
}
|
|
3473
3473
|
if (typeof value === "object") {
|
|
3474
|
-
const entries = Object.entries(value).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
3474
|
+
const entries = Object.entries(value).filter(([_k, v]) => v !== void 0).map(([k, v]) => `${k}: ${formatValue(v)}`).join(", ");
|
|
3475
3475
|
return `{ ${entries} }`;
|
|
3476
3476
|
}
|
|
3477
3477
|
return String(value);
|
|
@@ -3765,11 +3765,9 @@ function generateFieldModification(collectionName, modification, varName, isLast
|
|
|
3765
3765
|
function generateFieldDeletion(collectionName, fieldName, varName, isLast = false) {
|
|
3766
3766
|
const lines = [];
|
|
3767
3767
|
const collectionVar = varName || `collection_${collectionName}_${fieldName}`;
|
|
3768
|
-
const fieldVar = `${collectionVar}_field`;
|
|
3769
3768
|
lines.push(` const ${collectionVar} = app.findCollectionByNameOrId("${collectionName}");`);
|
|
3770
|
-
lines.push(` const ${fieldVar} = ${collectionVar}.fields.getByName("${fieldName}");`);
|
|
3771
3769
|
lines.push(``);
|
|
3772
|
-
lines.push(` ${collectionVar}.fields.
|
|
3770
|
+
lines.push(` ${collectionVar}.fields.removeByName("${fieldName}");`);
|
|
3773
3771
|
lines.push(``);
|
|
3774
3772
|
lines.push(isLast ? ` return app.save(${collectionVar});` : ` app.save(${collectionVar});`);
|
|
3775
3773
|
return lines.join("\n");
|
|
@@ -3887,20 +3885,23 @@ function generateOperationUpMigration(operation, collectionIdMap) {
|
|
|
3887
3885
|
lines.push(generateCollectionDeletion(collectionName, varName, true));
|
|
3888
3886
|
}
|
|
3889
3887
|
let code = lines.join("\n");
|
|
3890
|
-
const
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
if (
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3888
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
3889
|
+
if (!hasReturnStatement) {
|
|
3890
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
3891
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
3892
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
3893
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
3894
|
+
const allMatches = [
|
|
3895
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
3896
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
3897
|
+
].sort((a, b) => b.index - a.index);
|
|
3898
|
+
if (allMatches.length > 0) {
|
|
3899
|
+
const lastMatch = allMatches[0];
|
|
3900
|
+
if (lastMatch.type === "save") {
|
|
3901
|
+
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);
|
|
3902
|
+
} else {
|
|
3903
|
+
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);
|
|
3904
|
+
}
|
|
3904
3905
|
}
|
|
3905
3906
|
}
|
|
3906
3907
|
return code;
|
|
@@ -3989,20 +3990,23 @@ function generateOperationDownMigration(operation, collectionIdMap) {
|
|
|
3989
3990
|
}
|
|
3990
3991
|
}
|
|
3991
3992
|
let code = lines.join("\n");
|
|
3992
|
-
const
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
if (
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
3993
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
3994
|
+
if (!hasReturnStatement) {
|
|
3995
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
3996
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
3997
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
3998
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
3999
|
+
const allMatches = [
|
|
4000
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
4001
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
4002
|
+
].sort((a, b) => b.index - a.index);
|
|
4003
|
+
if (allMatches.length > 0) {
|
|
4004
|
+
const lastMatch = allMatches[0];
|
|
4005
|
+
if (lastMatch.type === "save") {
|
|
4006
|
+
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);
|
|
4007
|
+
} else {
|
|
4008
|
+
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);
|
|
4009
|
+
}
|
|
4006
4010
|
}
|
|
4007
4011
|
}
|
|
4008
4012
|
return code;
|
|
@@ -4103,20 +4107,23 @@ function generateUpMigration(diff) {
|
|
|
4103
4107
|
lines.push(``);
|
|
4104
4108
|
}
|
|
4105
4109
|
let code = lines.join("\n");
|
|
4106
|
-
const
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
if (
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4110
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
4111
|
+
if (!hasReturnStatement) {
|
|
4112
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
4113
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
4114
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
4115
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
4116
|
+
const allMatches = [
|
|
4117
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
4118
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
4119
|
+
].sort((a, b) => b.index - a.index);
|
|
4120
|
+
if (allMatches.length > 0) {
|
|
4121
|
+
const lastMatch = allMatches[0];
|
|
4122
|
+
if (lastMatch.type === "save") {
|
|
4123
|
+
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);
|
|
4124
|
+
} else {
|
|
4125
|
+
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);
|
|
4126
|
+
}
|
|
4120
4127
|
}
|
|
4121
4128
|
}
|
|
4122
4129
|
return code;
|
|
@@ -4233,20 +4240,23 @@ function generateDownMigration(diff) {
|
|
|
4233
4240
|
lines.push(``);
|
|
4234
4241
|
}
|
|
4235
4242
|
let code = lines.join("\n");
|
|
4236
|
-
const
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
if (
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4243
|
+
const hasReturnStatement = /return\s+app\.(save|delete)\(/m.test(code);
|
|
4244
|
+
if (!hasReturnStatement) {
|
|
4245
|
+
const savePattern = /^(\s*)app\.save\((\w+)\);$/gm;
|
|
4246
|
+
const deletePattern = /^(\s*)app\.delete\((\w+)\);$/gm;
|
|
4247
|
+
const saveMatches = [...code.matchAll(savePattern)];
|
|
4248
|
+
const deleteMatches = [...code.matchAll(deletePattern)];
|
|
4249
|
+
const allMatches = [
|
|
4250
|
+
...saveMatches.map((m) => ({ match: m, type: "save", index: m.index })),
|
|
4251
|
+
...deleteMatches.map((m) => ({ match: m, type: "delete", index: m.index }))
|
|
4252
|
+
].sort((a, b) => b.index - a.index);
|
|
4253
|
+
if (allMatches.length > 0) {
|
|
4254
|
+
const lastMatch = allMatches[0];
|
|
4255
|
+
if (lastMatch.type === "save") {
|
|
4256
|
+
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);
|
|
4257
|
+
} else {
|
|
4258
|
+
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);
|
|
4259
|
+
}
|
|
4250
4260
|
}
|
|
4251
4261
|
}
|
|
4252
4262
|
return code;
|