pocketbase-zod-schema 0.1.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +21 -0
  3. package/README.md +167 -0
  4. package/dist/cli/index.cjs +3383 -0
  5. package/dist/cli/index.cjs.map +1 -0
  6. package/dist/cli/index.d.cts +30 -0
  7. package/dist/cli/index.d.ts +30 -0
  8. package/dist/cli/index.js +3331 -0
  9. package/dist/cli/index.js.map +1 -0
  10. package/dist/cli/migrate.cjs +3380 -0
  11. package/dist/cli/migrate.cjs.map +1 -0
  12. package/dist/cli/migrate.d.cts +1 -0
  13. package/dist/cli/migrate.d.ts +1 -0
  14. package/dist/cli/migrate.js +3353 -0
  15. package/dist/cli/migrate.js.map +1 -0
  16. package/dist/cli/utils/index.cjs +540 -0
  17. package/dist/cli/utils/index.cjs.map +1 -0
  18. package/dist/cli/utils/index.d.cts +232 -0
  19. package/dist/cli/utils/index.d.ts +232 -0
  20. package/dist/cli/utils/index.js +487 -0
  21. package/dist/cli/utils/index.js.map +1 -0
  22. package/dist/enums.cjs +19 -0
  23. package/dist/enums.cjs.map +1 -0
  24. package/dist/enums.d.cts +6 -0
  25. package/dist/enums.d.ts +6 -0
  26. package/dist/enums.js +17 -0
  27. package/dist/enums.js.map +1 -0
  28. package/dist/index.cjs +4900 -0
  29. package/dist/index.cjs.map +1 -0
  30. package/dist/index.d.cts +18 -0
  31. package/dist/index.d.ts +18 -0
  32. package/dist/index.js +4726 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/migration/analyzer.cjs +1267 -0
  35. package/dist/migration/analyzer.cjs.map +1 -0
  36. package/dist/migration/analyzer.d.cts +186 -0
  37. package/dist/migration/analyzer.d.ts +186 -0
  38. package/dist/migration/analyzer.js +1232 -0
  39. package/dist/migration/analyzer.js.map +1 -0
  40. package/dist/migration/diff.cjs +557 -0
  41. package/dist/migration/diff.cjs.map +1 -0
  42. package/dist/migration/diff.d.cts +291 -0
  43. package/dist/migration/diff.d.ts +291 -0
  44. package/dist/migration/diff.js +534 -0
  45. package/dist/migration/diff.js.map +1 -0
  46. package/dist/migration/generator.cjs +778 -0
  47. package/dist/migration/generator.cjs.map +1 -0
  48. package/dist/migration/generator.d.cts +225 -0
  49. package/dist/migration/generator.d.ts +225 -0
  50. package/dist/migration/generator.js +737 -0
  51. package/dist/migration/generator.js.map +1 -0
  52. package/dist/migration/index.cjs +3390 -0
  53. package/dist/migration/index.cjs.map +1 -0
  54. package/dist/migration/index.d.cts +103 -0
  55. package/dist/migration/index.d.ts +103 -0
  56. package/dist/migration/index.js +3265 -0
  57. package/dist/migration/index.js.map +1 -0
  58. package/dist/migration/snapshot.cjs +609 -0
  59. package/dist/migration/snapshot.cjs.map +1 -0
  60. package/dist/migration/snapshot.d.cts +167 -0
  61. package/dist/migration/snapshot.d.ts +167 -0
  62. package/dist/migration/snapshot.js +575 -0
  63. package/dist/migration/snapshot.js.map +1 -0
  64. package/dist/migration/utils/index.cjs +672 -0
  65. package/dist/migration/utils/index.cjs.map +1 -0
  66. package/dist/migration/utils/index.d.cts +207 -0
  67. package/dist/migration/utils/index.d.ts +207 -0
  68. package/dist/migration/utils/index.js +641 -0
  69. package/dist/migration/utils/index.js.map +1 -0
  70. package/dist/mutator.cjs +427 -0
  71. package/dist/mutator.cjs.map +1 -0
  72. package/dist/mutator.d.cts +190 -0
  73. package/dist/mutator.d.ts +190 -0
  74. package/dist/mutator.js +425 -0
  75. package/dist/mutator.js.map +1 -0
  76. package/dist/permissions-ZHafVSIx.d.cts +71 -0
  77. package/dist/permissions-ZHafVSIx.d.ts +71 -0
  78. package/dist/schema.cjs +430 -0
  79. package/dist/schema.cjs.map +1 -0
  80. package/dist/schema.d.cts +316 -0
  81. package/dist/schema.d.ts +316 -0
  82. package/dist/schema.js +396 -0
  83. package/dist/schema.js.map +1 -0
  84. package/dist/types-BbTgmg6H.d.cts +91 -0
  85. package/dist/types-z1Dkjg8m.d.ts +91 -0
  86. package/dist/types.cjs +4 -0
  87. package/dist/types.cjs.map +1 -0
  88. package/dist/types.d.cts +14 -0
  89. package/dist/types.d.ts +14 -0
  90. package/dist/types.js +3 -0
  91. package/dist/types.js.map +1 -0
  92. package/dist/user-jS1aYoeD.d.cts +123 -0
  93. package/dist/user-jS1aYoeD.d.ts +123 -0
  94. package/package.json +165 -0
@@ -0,0 +1,291 @@
1
+ import { S as SchemaDefinition, a as SchemaSnapshot, f as SchemaDiff, F as FieldDefinition, b as FieldChange, C as CollectionSchema, d as PermissionChange } from '../types-BbTgmg6H.cjs';
2
+ import '../permissions-ZHafVSIx.cjs';
3
+
4
+ /**
5
+ * Diff Engine component
6
+ * Compares current schema with previous snapshot and identifies changes
7
+ *
8
+ * This module provides a standalone, configurable diff engine that can be used
9
+ * by consumer projects to compare schema definitions and detect changes.
10
+ */
11
+
12
+ /**
13
+ * Configuration options for the diff engine
14
+ */
15
+ interface DiffEngineConfig {
16
+ /**
17
+ * Whether to warn on collection deletions
18
+ * Defaults to true
19
+ */
20
+ warnOnDelete?: boolean;
21
+ /**
22
+ * Whether to require --force flag for destructive changes
23
+ * Defaults to true
24
+ */
25
+ requireForceForDestructive?: boolean;
26
+ /**
27
+ * Severity threshold for requiring force flag
28
+ * 'high' = only collection/field deletions and type changes
29
+ * 'medium' = includes making fields required
30
+ * 'low' = includes any constraint changes
31
+ * Defaults to 'high'
32
+ */
33
+ severityThreshold?: "high" | "medium" | "low";
34
+ /**
35
+ * Custom system collections to exclude from diff
36
+ * These collections will not be created or deleted
37
+ */
38
+ systemCollections?: string[];
39
+ /**
40
+ * Custom system fields to exclude from user collection diffs
41
+ * These fields will not be included in fieldsToAdd for the users collection
42
+ */
43
+ usersSystemFields?: string[];
44
+ }
45
+ /**
46
+ * Destructive change information
47
+ */
48
+ interface DestructiveChange {
49
+ type: "collection_delete" | "field_delete" | "type_change" | "required_change" | "constraint_change";
50
+ severity: "high" | "medium" | "low";
51
+ collection: string;
52
+ field?: string;
53
+ description: string;
54
+ oldValue?: any;
55
+ newValue?: any;
56
+ }
57
+ /**
58
+ * Change summary for status reporting
59
+ */
60
+ interface ChangeSummary {
61
+ totalChanges: number;
62
+ collectionsToCreate: number;
63
+ collectionsToDelete: number;
64
+ collectionsToModify: number;
65
+ fieldsToAdd: number;
66
+ fieldsToRemove: number;
67
+ fieldsToModify: number;
68
+ indexChanges: number;
69
+ ruleChanges: number;
70
+ permissionChanges: number;
71
+ destructiveChanges: DestructiveChange[];
72
+ nonDestructiveChanges: string[];
73
+ }
74
+ /**
75
+ * Checks if a collection is a PocketBase system collection
76
+ * System collections are internal to PocketBase and should not be created or deleted
77
+ *
78
+ * @param collectionName - Name of the collection to check
79
+ * @param config - Optional configuration with custom system collections
80
+ * @returns True if the collection is a system collection
81
+ */
82
+ declare function isSystemCollection(collectionName: string, config?: DiffEngineConfig): boolean;
83
+ /**
84
+ * Returns the list of system field names for the users collection
85
+ * These fields are automatically provided by PocketBase for auth collections
86
+ * and should not be included when generating migrations for users collection extensions
87
+ *
88
+ * @param config - Optional configuration with custom system fields
89
+ * @returns Set of system field names
90
+ */
91
+ declare function getUsersSystemFields(config?: DiffEngineConfig): Set<string>;
92
+ /**
93
+ * Filters system collections from a schema definition
94
+ * Returns a new SchemaDefinition with only custom (non-system) collections
95
+ *
96
+ * @param schema - Schema definition to filter
97
+ * @param config - Optional configuration
98
+ * @returns Filtered SchemaDefinition without system collections
99
+ */
100
+ declare function filterSystemCollections(schema: SchemaDefinition, config?: DiffEngineConfig): SchemaDefinition;
101
+ /**
102
+ * Identifies new collections in schema that don't exist in snapshot
103
+ *
104
+ * @param currentSchema - Current schema definition
105
+ * @param previousSnapshot - Previous schema snapshot
106
+ * @returns Array of new collections
107
+ */
108
+ declare function findNewCollections(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null): CollectionSchema[];
109
+ /**
110
+ * Identifies collections removed from schema (exist in snapshot but not in current schema)
111
+ *
112
+ * @param currentSchema - Current schema definition
113
+ * @param previousSnapshot - Previous schema snapshot
114
+ * @returns Array of removed collections
115
+ */
116
+ declare function findRemovedCollections(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null): CollectionSchema[];
117
+ /**
118
+ * Matches collections by name between current schema and snapshot
119
+ * Returns pairs of [current, previous] for collections that exist in both
120
+ *
121
+ * @param currentSchema - Current schema definition
122
+ * @param previousSnapshot - Previous schema snapshot
123
+ * @returns Array of matched collection pairs
124
+ */
125
+ declare function matchCollectionsByName(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null): Array<[CollectionSchema, CollectionSchema]>;
126
+ /**
127
+ * Identifies new fields in current collection that don't exist in previous
128
+ *
129
+ * @param currentFields - Current collection fields
130
+ * @param previousFields - Previous collection fields
131
+ * @returns Array of new fields
132
+ */
133
+ declare function findNewFields(currentFields: FieldDefinition[], previousFields: FieldDefinition[]): FieldDefinition[];
134
+ /**
135
+ * Identifies fields removed from current collection (exist in previous but not in current)
136
+ *
137
+ * @param currentFields - Current collection fields
138
+ * @param previousFields - Previous collection fields
139
+ * @returns Array of removed fields
140
+ */
141
+ declare function findRemovedFields(currentFields: FieldDefinition[], previousFields: FieldDefinition[]): FieldDefinition[];
142
+ /**
143
+ * Matches fields by name between current and previous collections
144
+ * Returns pairs of [current, previous] for fields that exist in both
145
+ *
146
+ * @param currentFields - Current collection fields
147
+ * @param previousFields - Previous collection fields
148
+ * @returns Array of matched field pairs
149
+ */
150
+ declare function matchFieldsByName(currentFields: FieldDefinition[], previousFields: FieldDefinition[]): Array<[FieldDefinition, FieldDefinition]>;
151
+ /**
152
+ * Compares field types between current and previous
153
+ *
154
+ * @param currentField - Current field definition
155
+ * @param previousField - Previous field definition
156
+ * @returns FieldChange if types differ, null otherwise
157
+ */
158
+ declare function compareFieldTypes(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange | null;
159
+ /**
160
+ * Compares field constraints (required, unique) between current and previous
161
+ *
162
+ * @param currentField - Current field definition
163
+ * @param previousField - Previous field definition
164
+ * @returns Array of FieldChange for constraint differences
165
+ */
166
+ declare function compareFieldConstraints(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange[];
167
+ /**
168
+ * Compares field options (min, max, pattern, etc.) between current and previous
169
+ *
170
+ * @param currentField - Current field definition
171
+ * @param previousField - Previous field definition
172
+ * @returns Array of FieldChange for option differences
173
+ */
174
+ declare function compareFieldOptions(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange[];
175
+ /**
176
+ * Compares relation configurations between current and previous
177
+ *
178
+ * @param currentField - Current field definition
179
+ * @param previousField - Previous field definition
180
+ * @returns Array of FieldChange for relation differences
181
+ */
182
+ declare function compareRelationConfigurations(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange[];
183
+ /**
184
+ * Detects all changes between two field definitions
185
+ * Combines type, constraint, option, and relation changes
186
+ *
187
+ * @param currentField - Current field definition
188
+ * @param previousField - Previous field definition
189
+ * @returns Array of all detected changes
190
+ */
191
+ declare function detectFieldChanges(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange[];
192
+ /**
193
+ * Compares permissions between current and previous collections
194
+ * Detects changes in permission rules defined in schema
195
+ *
196
+ * @param currentPermissions - Current collection permissions
197
+ * @param previousPermissions - Previous collection permissions
198
+ * @returns Array of permission changes
199
+ */
200
+ declare function comparePermissions(currentPermissions: CollectionSchema["permissions"], previousPermissions: CollectionSchema["permissions"]): PermissionChange[];
201
+ /**
202
+ * Aggregates all detected changes into a SchemaDiff
203
+ * Main entry point for diff comparison
204
+ *
205
+ * @param currentSchema - Current schema definition
206
+ * @param previousSnapshot - Previous schema snapshot
207
+ * @param config - Optional configuration
208
+ * @returns Complete SchemaDiff with all changes
209
+ */
210
+ declare function aggregateChanges(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null, config?: DiffEngineConfig): SchemaDiff;
211
+ /**
212
+ * Detects destructive changes in a schema diff
213
+ * Returns detailed information about each destructive change
214
+ *
215
+ * @param diff - Schema diff to analyze
216
+ * @param config - Optional configuration for severity thresholds
217
+ * @returns Array of destructive changes with severity information
218
+ */
219
+ declare function detectDestructiveChanges(diff: SchemaDiff, config?: DiffEngineConfig): DestructiveChange[];
220
+ /**
221
+ * Categorizes changes by severity
222
+ * Returns object with destructive and non-destructive changes
223
+ *
224
+ * @param diff - Schema diff to categorize
225
+ * @param config - Optional configuration
226
+ * @returns Object with categorized changes
227
+ */
228
+ declare function categorizeChangesBySeverity(diff: SchemaDiff, _config?: DiffEngineConfig): {
229
+ destructive: string[];
230
+ nonDestructive: string[];
231
+ };
232
+ /**
233
+ * Generates a summary of all changes in a diff
234
+ * Useful for status reporting and user feedback
235
+ *
236
+ * @param diff - Schema diff to summarize
237
+ * @param config - Optional configuration
238
+ * @returns Change summary with counts and details
239
+ */
240
+ declare function generateChangeSummary(diff: SchemaDiff, config?: DiffEngineConfig): ChangeSummary;
241
+ /**
242
+ * Checks if a diff requires the --force flag based on configuration
243
+ *
244
+ * @param diff - Schema diff to check
245
+ * @param config - Configuration with severity threshold
246
+ * @returns True if force flag is required
247
+ */
248
+ declare function requiresForceFlag(diff: SchemaDiff, config?: DiffEngineConfig): boolean;
249
+ /**
250
+ * Main comparison function
251
+ * Compares current schema with previous snapshot and returns complete diff
252
+ *
253
+ * @param currentSchema - Current schema definition
254
+ * @param previousSnapshot - Previous schema snapshot (null for first run)
255
+ * @param config - Optional configuration
256
+ * @returns Complete SchemaDiff with all detected changes
257
+ */
258
+ declare function compare(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null, config?: DiffEngineConfig): SchemaDiff;
259
+ /**
260
+ * DiffEngine class for object-oriented usage
261
+ * Provides a stateful interface for schema comparison
262
+ */
263
+ declare class DiffEngine {
264
+ private config;
265
+ constructor(config?: DiffEngineConfig);
266
+ /**
267
+ * Compares current schema with previous snapshot
268
+ */
269
+ compare(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null): SchemaDiff;
270
+ /**
271
+ * Detects destructive changes in a diff
272
+ */
273
+ detectDestructiveChanges(diff: SchemaDiff): DestructiveChange[];
274
+ /**
275
+ * Categorizes changes by severity
276
+ */
277
+ categorizeChangesBySeverity(diff: SchemaDiff): {
278
+ destructive: string[];
279
+ nonDestructive: string[];
280
+ };
281
+ /**
282
+ * Generates a summary of changes
283
+ */
284
+ generateChangeSummary(diff: SchemaDiff): ChangeSummary;
285
+ /**
286
+ * Checks if force flag is required
287
+ */
288
+ requiresForceFlag(diff: SchemaDiff): boolean;
289
+ }
290
+
291
+ export { type ChangeSummary, type DestructiveChange, DiffEngine, type DiffEngineConfig, aggregateChanges, categorizeChangesBySeverity, compare, compareFieldConstraints, compareFieldOptions, compareFieldTypes, comparePermissions, compareRelationConfigurations, detectDestructiveChanges, detectFieldChanges, filterSystemCollections, findNewCollections, findNewFields, findRemovedCollections, findRemovedFields, generateChangeSummary, getUsersSystemFields, isSystemCollection, matchCollectionsByName, matchFieldsByName, requiresForceFlag };
@@ -0,0 +1,291 @@
1
+ import { S as SchemaDefinition, a as SchemaSnapshot, f as SchemaDiff, F as FieldDefinition, b as FieldChange, C as CollectionSchema, d as PermissionChange } from '../types-z1Dkjg8m.js';
2
+ import '../permissions-ZHafVSIx.js';
3
+
4
+ /**
5
+ * Diff Engine component
6
+ * Compares current schema with previous snapshot and identifies changes
7
+ *
8
+ * This module provides a standalone, configurable diff engine that can be used
9
+ * by consumer projects to compare schema definitions and detect changes.
10
+ */
11
+
12
+ /**
13
+ * Configuration options for the diff engine
14
+ */
15
+ interface DiffEngineConfig {
16
+ /**
17
+ * Whether to warn on collection deletions
18
+ * Defaults to true
19
+ */
20
+ warnOnDelete?: boolean;
21
+ /**
22
+ * Whether to require --force flag for destructive changes
23
+ * Defaults to true
24
+ */
25
+ requireForceForDestructive?: boolean;
26
+ /**
27
+ * Severity threshold for requiring force flag
28
+ * 'high' = only collection/field deletions and type changes
29
+ * 'medium' = includes making fields required
30
+ * 'low' = includes any constraint changes
31
+ * Defaults to 'high'
32
+ */
33
+ severityThreshold?: "high" | "medium" | "low";
34
+ /**
35
+ * Custom system collections to exclude from diff
36
+ * These collections will not be created or deleted
37
+ */
38
+ systemCollections?: string[];
39
+ /**
40
+ * Custom system fields to exclude from user collection diffs
41
+ * These fields will not be included in fieldsToAdd for the users collection
42
+ */
43
+ usersSystemFields?: string[];
44
+ }
45
+ /**
46
+ * Destructive change information
47
+ */
48
+ interface DestructiveChange {
49
+ type: "collection_delete" | "field_delete" | "type_change" | "required_change" | "constraint_change";
50
+ severity: "high" | "medium" | "low";
51
+ collection: string;
52
+ field?: string;
53
+ description: string;
54
+ oldValue?: any;
55
+ newValue?: any;
56
+ }
57
+ /**
58
+ * Change summary for status reporting
59
+ */
60
+ interface ChangeSummary {
61
+ totalChanges: number;
62
+ collectionsToCreate: number;
63
+ collectionsToDelete: number;
64
+ collectionsToModify: number;
65
+ fieldsToAdd: number;
66
+ fieldsToRemove: number;
67
+ fieldsToModify: number;
68
+ indexChanges: number;
69
+ ruleChanges: number;
70
+ permissionChanges: number;
71
+ destructiveChanges: DestructiveChange[];
72
+ nonDestructiveChanges: string[];
73
+ }
74
+ /**
75
+ * Checks if a collection is a PocketBase system collection
76
+ * System collections are internal to PocketBase and should not be created or deleted
77
+ *
78
+ * @param collectionName - Name of the collection to check
79
+ * @param config - Optional configuration with custom system collections
80
+ * @returns True if the collection is a system collection
81
+ */
82
+ declare function isSystemCollection(collectionName: string, config?: DiffEngineConfig): boolean;
83
+ /**
84
+ * Returns the list of system field names for the users collection
85
+ * These fields are automatically provided by PocketBase for auth collections
86
+ * and should not be included when generating migrations for users collection extensions
87
+ *
88
+ * @param config - Optional configuration with custom system fields
89
+ * @returns Set of system field names
90
+ */
91
+ declare function getUsersSystemFields(config?: DiffEngineConfig): Set<string>;
92
+ /**
93
+ * Filters system collections from a schema definition
94
+ * Returns a new SchemaDefinition with only custom (non-system) collections
95
+ *
96
+ * @param schema - Schema definition to filter
97
+ * @param config - Optional configuration
98
+ * @returns Filtered SchemaDefinition without system collections
99
+ */
100
+ declare function filterSystemCollections(schema: SchemaDefinition, config?: DiffEngineConfig): SchemaDefinition;
101
+ /**
102
+ * Identifies new collections in schema that don't exist in snapshot
103
+ *
104
+ * @param currentSchema - Current schema definition
105
+ * @param previousSnapshot - Previous schema snapshot
106
+ * @returns Array of new collections
107
+ */
108
+ declare function findNewCollections(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null): CollectionSchema[];
109
+ /**
110
+ * Identifies collections removed from schema (exist in snapshot but not in current schema)
111
+ *
112
+ * @param currentSchema - Current schema definition
113
+ * @param previousSnapshot - Previous schema snapshot
114
+ * @returns Array of removed collections
115
+ */
116
+ declare function findRemovedCollections(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null): CollectionSchema[];
117
+ /**
118
+ * Matches collections by name between current schema and snapshot
119
+ * Returns pairs of [current, previous] for collections that exist in both
120
+ *
121
+ * @param currentSchema - Current schema definition
122
+ * @param previousSnapshot - Previous schema snapshot
123
+ * @returns Array of matched collection pairs
124
+ */
125
+ declare function matchCollectionsByName(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null): Array<[CollectionSchema, CollectionSchema]>;
126
+ /**
127
+ * Identifies new fields in current collection that don't exist in previous
128
+ *
129
+ * @param currentFields - Current collection fields
130
+ * @param previousFields - Previous collection fields
131
+ * @returns Array of new fields
132
+ */
133
+ declare function findNewFields(currentFields: FieldDefinition[], previousFields: FieldDefinition[]): FieldDefinition[];
134
+ /**
135
+ * Identifies fields removed from current collection (exist in previous but not in current)
136
+ *
137
+ * @param currentFields - Current collection fields
138
+ * @param previousFields - Previous collection fields
139
+ * @returns Array of removed fields
140
+ */
141
+ declare function findRemovedFields(currentFields: FieldDefinition[], previousFields: FieldDefinition[]): FieldDefinition[];
142
+ /**
143
+ * Matches fields by name between current and previous collections
144
+ * Returns pairs of [current, previous] for fields that exist in both
145
+ *
146
+ * @param currentFields - Current collection fields
147
+ * @param previousFields - Previous collection fields
148
+ * @returns Array of matched field pairs
149
+ */
150
+ declare function matchFieldsByName(currentFields: FieldDefinition[], previousFields: FieldDefinition[]): Array<[FieldDefinition, FieldDefinition]>;
151
+ /**
152
+ * Compares field types between current and previous
153
+ *
154
+ * @param currentField - Current field definition
155
+ * @param previousField - Previous field definition
156
+ * @returns FieldChange if types differ, null otherwise
157
+ */
158
+ declare function compareFieldTypes(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange | null;
159
+ /**
160
+ * Compares field constraints (required, unique) between current and previous
161
+ *
162
+ * @param currentField - Current field definition
163
+ * @param previousField - Previous field definition
164
+ * @returns Array of FieldChange for constraint differences
165
+ */
166
+ declare function compareFieldConstraints(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange[];
167
+ /**
168
+ * Compares field options (min, max, pattern, etc.) between current and previous
169
+ *
170
+ * @param currentField - Current field definition
171
+ * @param previousField - Previous field definition
172
+ * @returns Array of FieldChange for option differences
173
+ */
174
+ declare function compareFieldOptions(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange[];
175
+ /**
176
+ * Compares relation configurations between current and previous
177
+ *
178
+ * @param currentField - Current field definition
179
+ * @param previousField - Previous field definition
180
+ * @returns Array of FieldChange for relation differences
181
+ */
182
+ declare function compareRelationConfigurations(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange[];
183
+ /**
184
+ * Detects all changes between two field definitions
185
+ * Combines type, constraint, option, and relation changes
186
+ *
187
+ * @param currentField - Current field definition
188
+ * @param previousField - Previous field definition
189
+ * @returns Array of all detected changes
190
+ */
191
+ declare function detectFieldChanges(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange[];
192
+ /**
193
+ * Compares permissions between current and previous collections
194
+ * Detects changes in permission rules defined in schema
195
+ *
196
+ * @param currentPermissions - Current collection permissions
197
+ * @param previousPermissions - Previous collection permissions
198
+ * @returns Array of permission changes
199
+ */
200
+ declare function comparePermissions(currentPermissions: CollectionSchema["permissions"], previousPermissions: CollectionSchema["permissions"]): PermissionChange[];
201
+ /**
202
+ * Aggregates all detected changes into a SchemaDiff
203
+ * Main entry point for diff comparison
204
+ *
205
+ * @param currentSchema - Current schema definition
206
+ * @param previousSnapshot - Previous schema snapshot
207
+ * @param config - Optional configuration
208
+ * @returns Complete SchemaDiff with all changes
209
+ */
210
+ declare function aggregateChanges(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null, config?: DiffEngineConfig): SchemaDiff;
211
+ /**
212
+ * Detects destructive changes in a schema diff
213
+ * Returns detailed information about each destructive change
214
+ *
215
+ * @param diff - Schema diff to analyze
216
+ * @param config - Optional configuration for severity thresholds
217
+ * @returns Array of destructive changes with severity information
218
+ */
219
+ declare function detectDestructiveChanges(diff: SchemaDiff, config?: DiffEngineConfig): DestructiveChange[];
220
+ /**
221
+ * Categorizes changes by severity
222
+ * Returns object with destructive and non-destructive changes
223
+ *
224
+ * @param diff - Schema diff to categorize
225
+ * @param config - Optional configuration
226
+ * @returns Object with categorized changes
227
+ */
228
+ declare function categorizeChangesBySeverity(diff: SchemaDiff, _config?: DiffEngineConfig): {
229
+ destructive: string[];
230
+ nonDestructive: string[];
231
+ };
232
+ /**
233
+ * Generates a summary of all changes in a diff
234
+ * Useful for status reporting and user feedback
235
+ *
236
+ * @param diff - Schema diff to summarize
237
+ * @param config - Optional configuration
238
+ * @returns Change summary with counts and details
239
+ */
240
+ declare function generateChangeSummary(diff: SchemaDiff, config?: DiffEngineConfig): ChangeSummary;
241
+ /**
242
+ * Checks if a diff requires the --force flag based on configuration
243
+ *
244
+ * @param diff - Schema diff to check
245
+ * @param config - Configuration with severity threshold
246
+ * @returns True if force flag is required
247
+ */
248
+ declare function requiresForceFlag(diff: SchemaDiff, config?: DiffEngineConfig): boolean;
249
+ /**
250
+ * Main comparison function
251
+ * Compares current schema with previous snapshot and returns complete diff
252
+ *
253
+ * @param currentSchema - Current schema definition
254
+ * @param previousSnapshot - Previous schema snapshot (null for first run)
255
+ * @param config - Optional configuration
256
+ * @returns Complete SchemaDiff with all detected changes
257
+ */
258
+ declare function compare(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null, config?: DiffEngineConfig): SchemaDiff;
259
+ /**
260
+ * DiffEngine class for object-oriented usage
261
+ * Provides a stateful interface for schema comparison
262
+ */
263
+ declare class DiffEngine {
264
+ private config;
265
+ constructor(config?: DiffEngineConfig);
266
+ /**
267
+ * Compares current schema with previous snapshot
268
+ */
269
+ compare(currentSchema: SchemaDefinition, previousSnapshot: SchemaSnapshot | null): SchemaDiff;
270
+ /**
271
+ * Detects destructive changes in a diff
272
+ */
273
+ detectDestructiveChanges(diff: SchemaDiff): DestructiveChange[];
274
+ /**
275
+ * Categorizes changes by severity
276
+ */
277
+ categorizeChangesBySeverity(diff: SchemaDiff): {
278
+ destructive: string[];
279
+ nonDestructive: string[];
280
+ };
281
+ /**
282
+ * Generates a summary of changes
283
+ */
284
+ generateChangeSummary(diff: SchemaDiff): ChangeSummary;
285
+ /**
286
+ * Checks if force flag is required
287
+ */
288
+ requiresForceFlag(diff: SchemaDiff): boolean;
289
+ }
290
+
291
+ export { type ChangeSummary, type DestructiveChange, DiffEngine, type DiffEngineConfig, aggregateChanges, categorizeChangesBySeverity, compare, compareFieldConstraints, compareFieldOptions, compareFieldTypes, comparePermissions, compareRelationConfigurations, detectDestructiveChanges, detectFieldChanges, filterSystemCollections, findNewCollections, findNewFields, findRemovedCollections, findRemovedFields, generateChangeSummary, getUsersSystemFields, isSystemCollection, matchCollectionsByName, matchFieldsByName, requiresForceFlag };