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,103 @@
1
+ export { SchemaAnalyzer, SchemaAnalyzerConfig, buildFieldDefinition, buildSchemaDefinition, convertZodSchemaToCollectionSchema, discoverSchemaFiles, extractFieldDefinitions, extractIndexes, extractSchemaDefinitions, getCollectionNameFromFile, importSchemaModule, isAuthCollection, parseSchemaFiles, selectSchemaForCollection } from './analyzer.cjs';
2
+ export { SnapshotConfig, SnapshotManager, convertPocketBaseMigration, findLatestSnapshot, getSnapshotPath, getSnapshotVersion, loadBaseMigration, loadSnapshot, loadSnapshotIfExists, mergeSnapshots, saveSnapshot, snapshotExists, validateSnapshot } from './snapshot.cjs';
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
+ 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 { e as CollectionModification, C as CollectionSchema, b as FieldChange, F as FieldDefinition, c as FieldModification, d as PermissionChange, P as PocketBaseFieldType, R as RuleUpdate, S as SchemaDefinition, f as SchemaDiff, a as SchemaSnapshot } from '../types-BbTgmg6H.cjs';
6
+ export { ExtractedFieldOptions, FIELD_TYPE_INFO, FieldTypeInfo, FieldTypeResult, POCKETBASE_FIELD_TYPES, extractComprehensiveFieldOptions, extractFieldOptions, getArrayElementType, getDefaultValue, getFieldTypeInfo, getMaxSelect, getMinSelect, isArrayType, isEditorField, isFieldRequired, isFileFieldByName, isGeoPointType, isMultipleRelationField, isRelationField, isSingleRelationField, mapZodArrayType, mapZodBooleanType, mapZodDateType, mapZodEnumType, mapZodNumberType, mapZodRecordType, mapZodStringType, mapZodTypeToPocketBase, pluralize, resolveTargetCollection, singularize, toCollectionName, unwrapZodType } from './utils/index.cjs';
7
+ export { A as APIRuleType } from '../permissions-ZHafVSIx.cjs';
8
+ import 'zod';
9
+
10
+ /**
11
+ * Custom error classes for migration tool
12
+ * Provides specific error types for better error handling and user feedback
13
+ */
14
+ /**
15
+ * Base error class for all migration-related errors
16
+ */
17
+ declare class MigrationError extends Error {
18
+ constructor(message: string);
19
+ }
20
+ /**
21
+ * Error thrown when schema parsing fails
22
+ * Used when Zod schemas cannot be parsed or are invalid
23
+ */
24
+ declare class SchemaParsingError extends MigrationError {
25
+ readonly filePath?: string;
26
+ readonly originalError?: Error;
27
+ constructor(message: string, filePath?: string, originalError?: Error);
28
+ /**
29
+ * Creates a formatted error message with file path and original error details
30
+ */
31
+ getDetailedMessage(): string;
32
+ }
33
+ /**
34
+ * Error thrown when snapshot operations fail
35
+ * Used for snapshot file read/write/parse errors
36
+ */
37
+ declare class SnapshotError extends MigrationError {
38
+ readonly snapshotPath?: string;
39
+ readonly operation?: "read" | "write" | "parse" | "validate";
40
+ readonly originalError?: Error;
41
+ constructor(message: string, snapshotPath?: string, operation?: "read" | "write" | "parse" | "validate", originalError?: Error);
42
+ /**
43
+ * Creates a formatted error message with snapshot path and operation details
44
+ */
45
+ getDetailedMessage(): string;
46
+ }
47
+ /**
48
+ * Error thrown when migration file generation fails
49
+ * Used when migration files cannot be created or written
50
+ */
51
+ declare class MigrationGenerationError extends MigrationError {
52
+ readonly migrationPath?: string;
53
+ readonly originalError?: Error;
54
+ constructor(message: string, migrationPath?: string, originalError?: Error);
55
+ /**
56
+ * Creates a formatted error message with migration path and original error details
57
+ */
58
+ getDetailedMessage(): string;
59
+ }
60
+ /**
61
+ * Error thrown when file system operations fail
62
+ * Used for directory creation, file permissions, disk space issues
63
+ */
64
+ declare class FileSystemError extends MigrationError {
65
+ readonly path?: string;
66
+ readonly operation?: "read" | "write" | "create" | "delete" | "access";
67
+ readonly code?: string;
68
+ readonly originalError?: Error;
69
+ constructor(message: string, path?: string, operation?: "read" | "write" | "create" | "delete" | "access", code?: string, originalError?: Error);
70
+ /**
71
+ * Creates a formatted error message with path, operation, and error code details
72
+ */
73
+ getDetailedMessage(): string;
74
+ }
75
+ /**
76
+ * Error thrown when configuration is invalid
77
+ * Used for configuration file parsing, validation, and path resolution errors
78
+ */
79
+ declare class ConfigurationError extends MigrationError {
80
+ readonly configPath?: string;
81
+ readonly invalidFields?: string[];
82
+ readonly originalError?: Error;
83
+ constructor(message: string, configPath?: string, invalidFields?: string[], originalError?: Error);
84
+ /**
85
+ * Creates a formatted error message with configuration details
86
+ */
87
+ getDetailedMessage(): string;
88
+ }
89
+ /**
90
+ * Error thrown when CLI command usage is incorrect
91
+ * Used for invalid arguments, missing required options, etc.
92
+ */
93
+ declare class CLIUsageError extends MigrationError {
94
+ readonly command?: string;
95
+ readonly suggestion?: string;
96
+ constructor(message: string, command?: string, suggestion?: string);
97
+ /**
98
+ * Creates a formatted error message with usage suggestions
99
+ */
100
+ getDetailedMessage(): string;
101
+ }
102
+
103
+ export { CLIUsageError, ConfigurationError, FileSystemError, MigrationError, MigrationGenerationError, SchemaParsingError, SnapshotError };
@@ -0,0 +1,103 @@
1
+ export { SchemaAnalyzer, SchemaAnalyzerConfig, buildFieldDefinition, buildSchemaDefinition, convertZodSchemaToCollectionSchema, discoverSchemaFiles, extractFieldDefinitions, extractIndexes, extractSchemaDefinitions, getCollectionNameFromFile, importSchemaModule, isAuthCollection, parseSchemaFiles, selectSchemaForCollection } from './analyzer.js';
2
+ export { SnapshotConfig, SnapshotManager, convertPocketBaseMigration, findLatestSnapshot, getSnapshotPath, getSnapshotVersion, loadBaseMigration, loadSnapshot, loadSnapshotIfExists, mergeSnapshots, saveSnapshot, snapshotExists, validateSnapshot } from './snapshot.js';
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
+ 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 { e as CollectionModification, C as CollectionSchema, b as FieldChange, F as FieldDefinition, c as FieldModification, d as PermissionChange, P as PocketBaseFieldType, R as RuleUpdate, S as SchemaDefinition, f as SchemaDiff, a as SchemaSnapshot } from '../types-z1Dkjg8m.js';
6
+ export { ExtractedFieldOptions, FIELD_TYPE_INFO, FieldTypeInfo, FieldTypeResult, POCKETBASE_FIELD_TYPES, extractComprehensiveFieldOptions, extractFieldOptions, getArrayElementType, getDefaultValue, getFieldTypeInfo, getMaxSelect, getMinSelect, isArrayType, isEditorField, isFieldRequired, isFileFieldByName, isGeoPointType, isMultipleRelationField, isRelationField, isSingleRelationField, mapZodArrayType, mapZodBooleanType, mapZodDateType, mapZodEnumType, mapZodNumberType, mapZodRecordType, mapZodStringType, mapZodTypeToPocketBase, pluralize, resolveTargetCollection, singularize, toCollectionName, unwrapZodType } from './utils/index.js';
7
+ export { A as APIRuleType } from '../permissions-ZHafVSIx.js';
8
+ import 'zod';
9
+
10
+ /**
11
+ * Custom error classes for migration tool
12
+ * Provides specific error types for better error handling and user feedback
13
+ */
14
+ /**
15
+ * Base error class for all migration-related errors
16
+ */
17
+ declare class MigrationError extends Error {
18
+ constructor(message: string);
19
+ }
20
+ /**
21
+ * Error thrown when schema parsing fails
22
+ * Used when Zod schemas cannot be parsed or are invalid
23
+ */
24
+ declare class SchemaParsingError extends MigrationError {
25
+ readonly filePath?: string;
26
+ readonly originalError?: Error;
27
+ constructor(message: string, filePath?: string, originalError?: Error);
28
+ /**
29
+ * Creates a formatted error message with file path and original error details
30
+ */
31
+ getDetailedMessage(): string;
32
+ }
33
+ /**
34
+ * Error thrown when snapshot operations fail
35
+ * Used for snapshot file read/write/parse errors
36
+ */
37
+ declare class SnapshotError extends MigrationError {
38
+ readonly snapshotPath?: string;
39
+ readonly operation?: "read" | "write" | "parse" | "validate";
40
+ readonly originalError?: Error;
41
+ constructor(message: string, snapshotPath?: string, operation?: "read" | "write" | "parse" | "validate", originalError?: Error);
42
+ /**
43
+ * Creates a formatted error message with snapshot path and operation details
44
+ */
45
+ getDetailedMessage(): string;
46
+ }
47
+ /**
48
+ * Error thrown when migration file generation fails
49
+ * Used when migration files cannot be created or written
50
+ */
51
+ declare class MigrationGenerationError extends MigrationError {
52
+ readonly migrationPath?: string;
53
+ readonly originalError?: Error;
54
+ constructor(message: string, migrationPath?: string, originalError?: Error);
55
+ /**
56
+ * Creates a formatted error message with migration path and original error details
57
+ */
58
+ getDetailedMessage(): string;
59
+ }
60
+ /**
61
+ * Error thrown when file system operations fail
62
+ * Used for directory creation, file permissions, disk space issues
63
+ */
64
+ declare class FileSystemError extends MigrationError {
65
+ readonly path?: string;
66
+ readonly operation?: "read" | "write" | "create" | "delete" | "access";
67
+ readonly code?: string;
68
+ readonly originalError?: Error;
69
+ constructor(message: string, path?: string, operation?: "read" | "write" | "create" | "delete" | "access", code?: string, originalError?: Error);
70
+ /**
71
+ * Creates a formatted error message with path, operation, and error code details
72
+ */
73
+ getDetailedMessage(): string;
74
+ }
75
+ /**
76
+ * Error thrown when configuration is invalid
77
+ * Used for configuration file parsing, validation, and path resolution errors
78
+ */
79
+ declare class ConfigurationError extends MigrationError {
80
+ readonly configPath?: string;
81
+ readonly invalidFields?: string[];
82
+ readonly originalError?: Error;
83
+ constructor(message: string, configPath?: string, invalidFields?: string[], originalError?: Error);
84
+ /**
85
+ * Creates a formatted error message with configuration details
86
+ */
87
+ getDetailedMessage(): string;
88
+ }
89
+ /**
90
+ * Error thrown when CLI command usage is incorrect
91
+ * Used for invalid arguments, missing required options, etc.
92
+ */
93
+ declare class CLIUsageError extends MigrationError {
94
+ readonly command?: string;
95
+ readonly suggestion?: string;
96
+ constructor(message: string, command?: string, suggestion?: string);
97
+ /**
98
+ * Creates a formatted error message with usage suggestions
99
+ */
100
+ getDetailedMessage(): string;
101
+ }
102
+
103
+ export { CLIUsageError, ConfigurationError, FileSystemError, MigrationError, MigrationGenerationError, SchemaParsingError, SnapshotError };