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,232 @@
1
+ import { Ora } from 'ora';
2
+ import { f as SchemaDiff } from '../../types-BbTgmg6H.cjs';
3
+ import '../../permissions-ZHafVSIx.cjs';
4
+
5
+ /**
6
+ * Configuration loader for migration tool
7
+ * Handles loading and merging configuration from various sources
8
+ */
9
+ /**
10
+ * Migration tool configuration
11
+ */
12
+ interface MigrationConfig {
13
+ schema: {
14
+ directory: string;
15
+ exclude: string[];
16
+ };
17
+ migrations: {
18
+ directory: string;
19
+ format: string;
20
+ };
21
+ diff: {
22
+ warnOnDelete: boolean;
23
+ requireForceForDestructive: boolean;
24
+ };
25
+ }
26
+ /**
27
+ * Partial configuration for merging
28
+ */
29
+ type PartialMigrationConfig = {
30
+ schema?: Partial<MigrationConfig["schema"]>;
31
+ migrations?: Partial<MigrationConfig["migrations"]>;
32
+ diff?: Partial<MigrationConfig["diff"]>;
33
+ };
34
+ /**
35
+ * Loads configuration from CLI arguments
36
+ */
37
+ declare function loadConfigFromArgs(options: any): PartialMigrationConfig;
38
+ /**
39
+ * Loads and merges configuration from all sources
40
+ * Priority: CLI args > Environment variables > Config file > Defaults
41
+ */
42
+ declare function loadConfig(options?: any): Promise<MigrationConfig>;
43
+ /**
44
+ * Gets the absolute path to the schema directory
45
+ */
46
+ declare function getSchemaDirectory(config: MigrationConfig): string;
47
+ /**
48
+ * Gets the absolute path to the migrations directory
49
+ */
50
+ declare function getMigrationsDirectory(config: MigrationConfig): string;
51
+ /**
52
+ * Gets the default configuration
53
+ */
54
+ declare function getDefaultConfig(): MigrationConfig;
55
+ /**
56
+ * Creates a sample configuration file content
57
+ */
58
+ declare function getSampleConfig(format: "json" | "js"): string;
59
+
60
+ /**
61
+ * Logging utilities for CLI output
62
+ * Provides colored console output and formatting helpers
63
+ */
64
+
65
+ /**
66
+ * Verbosity levels for logging
67
+ */
68
+ type VerbosityLevel = "quiet" | "normal" | "verbose";
69
+ /**
70
+ * Sets the verbosity level for logging
71
+ *
72
+ * @param level - Verbosity level to set
73
+ */
74
+ declare function setVerbosity(level: VerbosityLevel): void;
75
+ /**
76
+ * Gets the current verbosity level
77
+ *
78
+ * @returns Current verbosity level
79
+ */
80
+ declare function getVerbosity(): VerbosityLevel;
81
+ /**
82
+ * Creates a spinner for long-running operations
83
+ *
84
+ * @param text - Initial spinner text
85
+ * @returns Ora spinner instance
86
+ */
87
+ declare function createSpinner(text: string): Ora;
88
+ /**
89
+ * Logs a success message in green
90
+ *
91
+ * @param message - Message to log
92
+ */
93
+ declare function logSuccess(message: string): void;
94
+ /**
95
+ * Logs an error message in red
96
+ * Always shown regardless of verbosity level
97
+ *
98
+ * @param message - Message to log
99
+ */
100
+ declare function logError(message: string): void;
101
+ /**
102
+ * Logs a warning message in yellow
103
+ *
104
+ * @param message - Message to log
105
+ */
106
+ declare function logWarning(message: string): void;
107
+ /**
108
+ * Logs an info message in blue
109
+ *
110
+ * @param message - Message to log
111
+ */
112
+ declare function logInfo(message: string): void;
113
+ /**
114
+ * Logs a debug message in gray
115
+ * Only shown in verbose mode
116
+ *
117
+ * @param message - Message to log
118
+ */
119
+ declare function logDebug(message: string): void;
120
+ /**
121
+ * Logs a section header
122
+ *
123
+ * @param title - Section title
124
+ */
125
+ declare function logSection(title: string): void;
126
+ /**
127
+ * Formats a change summary for display
128
+ * Creates a formatted, colored summary of detected changes
129
+ *
130
+ * @param diff - Schema diff containing all changes
131
+ * @returns Formatted summary string
132
+ */
133
+ declare function formatChangeSummary(diff: SchemaDiff): string;
134
+ /**
135
+ * Displays a progress indicator for a long operation
136
+ *
137
+ * @param message - Progress message
138
+ * @param operation - Async operation to perform
139
+ * @returns Result of the operation
140
+ */
141
+ declare function withProgress<T>(message: string, operation: () => Promise<T>): Promise<T>;
142
+ /**
143
+ * Logs a step in a multi-step process
144
+ *
145
+ * @param step - Current step number
146
+ * @param total - Total number of steps
147
+ * @param message - Step description
148
+ */
149
+ declare function logStep(step: number, total: number, message: string): void;
150
+ /**
151
+ * Logs a list of items with bullet points
152
+ *
153
+ * @param items - Items to list
154
+ * @param indent - Indentation level (default: 2)
155
+ */
156
+ declare function logList(items: string[], indent?: number): void;
157
+ /**
158
+ * Logs a key-value pair
159
+ *
160
+ * @param key - Key name
161
+ * @param value - Value to display
162
+ * @param indent - Indentation level (default: 2)
163
+ */
164
+ declare function logKeyValue(key: string, value: string, indent?: number): void;
165
+ /**
166
+ * Logs a table of data
167
+ *
168
+ * @param headers - Column headers
169
+ * @param rows - Data rows
170
+ */
171
+ declare function logTable(headers: string[], rows: string[][]): void;
172
+ /**
173
+ * Logs a box with a title and content
174
+ *
175
+ * @param title - Box title
176
+ * @param content - Box content (array of lines)
177
+ */
178
+ declare function logBox(title: string, content: string[]): void;
179
+ /**
180
+ * Creates a progress bar string
181
+ *
182
+ * @param current - Current progress value
183
+ * @param total - Total value
184
+ * @param width - Bar width in characters (default: 20)
185
+ * @returns Formatted progress bar string
186
+ */
187
+ declare function createProgressBar(current: number, total: number, width?: number): string;
188
+ /**
189
+ * Logs a timestamp with a message
190
+ *
191
+ * @param message - Message to log
192
+ */
193
+ declare function logTimestamp(message: string): void;
194
+ /**
195
+ * Formats a duration in milliseconds to a human-readable string
196
+ *
197
+ * @param ms - Duration in milliseconds
198
+ * @returns Formatted duration string
199
+ */
200
+ declare function formatDuration(ms: number): string;
201
+ /**
202
+ * Logs a timed operation result
203
+ *
204
+ * @param message - Operation description
205
+ * @param startTime - Start time from Date.now()
206
+ */
207
+ declare function logTimed(message: string, startTime: number): void;
208
+ /**
209
+ * Status output interface for JSON output mode
210
+ */
211
+ interface StatusOutput {
212
+ status: "up-to-date" | "changes-pending" | "first-time-setup";
213
+ collections: {
214
+ current: number;
215
+ snapshot: number;
216
+ };
217
+ changes: {
218
+ create: number;
219
+ delete: number;
220
+ modify: number;
221
+ };
222
+ destructive: boolean;
223
+ }
224
+ /**
225
+ * Formats status output as JSON
226
+ *
227
+ * @param output - Status output object
228
+ * @returns JSON string
229
+ */
230
+ declare function formatStatusJson(output: StatusOutput): string;
231
+
232
+ export { type MigrationConfig, type PartialMigrationConfig, type StatusOutput, type VerbosityLevel, createProgressBar, createSpinner, formatChangeSummary, formatDuration, formatStatusJson, getDefaultConfig, getMigrationsDirectory, getSampleConfig, getSchemaDirectory, getVerbosity, loadConfig, loadConfigFromArgs, logBox, logDebug, logError, logInfo, logKeyValue, logList, logSection, logStep, logSuccess, logTable, logTimed, logTimestamp, logWarning, setVerbosity, withProgress };
@@ -0,0 +1,232 @@
1
+ import { Ora } from 'ora';
2
+ import { f as SchemaDiff } from '../../types-z1Dkjg8m.js';
3
+ import '../../permissions-ZHafVSIx.js';
4
+
5
+ /**
6
+ * Configuration loader for migration tool
7
+ * Handles loading and merging configuration from various sources
8
+ */
9
+ /**
10
+ * Migration tool configuration
11
+ */
12
+ interface MigrationConfig {
13
+ schema: {
14
+ directory: string;
15
+ exclude: string[];
16
+ };
17
+ migrations: {
18
+ directory: string;
19
+ format: string;
20
+ };
21
+ diff: {
22
+ warnOnDelete: boolean;
23
+ requireForceForDestructive: boolean;
24
+ };
25
+ }
26
+ /**
27
+ * Partial configuration for merging
28
+ */
29
+ type PartialMigrationConfig = {
30
+ schema?: Partial<MigrationConfig["schema"]>;
31
+ migrations?: Partial<MigrationConfig["migrations"]>;
32
+ diff?: Partial<MigrationConfig["diff"]>;
33
+ };
34
+ /**
35
+ * Loads configuration from CLI arguments
36
+ */
37
+ declare function loadConfigFromArgs(options: any): PartialMigrationConfig;
38
+ /**
39
+ * Loads and merges configuration from all sources
40
+ * Priority: CLI args > Environment variables > Config file > Defaults
41
+ */
42
+ declare function loadConfig(options?: any): Promise<MigrationConfig>;
43
+ /**
44
+ * Gets the absolute path to the schema directory
45
+ */
46
+ declare function getSchemaDirectory(config: MigrationConfig): string;
47
+ /**
48
+ * Gets the absolute path to the migrations directory
49
+ */
50
+ declare function getMigrationsDirectory(config: MigrationConfig): string;
51
+ /**
52
+ * Gets the default configuration
53
+ */
54
+ declare function getDefaultConfig(): MigrationConfig;
55
+ /**
56
+ * Creates a sample configuration file content
57
+ */
58
+ declare function getSampleConfig(format: "json" | "js"): string;
59
+
60
+ /**
61
+ * Logging utilities for CLI output
62
+ * Provides colored console output and formatting helpers
63
+ */
64
+
65
+ /**
66
+ * Verbosity levels for logging
67
+ */
68
+ type VerbosityLevel = "quiet" | "normal" | "verbose";
69
+ /**
70
+ * Sets the verbosity level for logging
71
+ *
72
+ * @param level - Verbosity level to set
73
+ */
74
+ declare function setVerbosity(level: VerbosityLevel): void;
75
+ /**
76
+ * Gets the current verbosity level
77
+ *
78
+ * @returns Current verbosity level
79
+ */
80
+ declare function getVerbosity(): VerbosityLevel;
81
+ /**
82
+ * Creates a spinner for long-running operations
83
+ *
84
+ * @param text - Initial spinner text
85
+ * @returns Ora spinner instance
86
+ */
87
+ declare function createSpinner(text: string): Ora;
88
+ /**
89
+ * Logs a success message in green
90
+ *
91
+ * @param message - Message to log
92
+ */
93
+ declare function logSuccess(message: string): void;
94
+ /**
95
+ * Logs an error message in red
96
+ * Always shown regardless of verbosity level
97
+ *
98
+ * @param message - Message to log
99
+ */
100
+ declare function logError(message: string): void;
101
+ /**
102
+ * Logs a warning message in yellow
103
+ *
104
+ * @param message - Message to log
105
+ */
106
+ declare function logWarning(message: string): void;
107
+ /**
108
+ * Logs an info message in blue
109
+ *
110
+ * @param message - Message to log
111
+ */
112
+ declare function logInfo(message: string): void;
113
+ /**
114
+ * Logs a debug message in gray
115
+ * Only shown in verbose mode
116
+ *
117
+ * @param message - Message to log
118
+ */
119
+ declare function logDebug(message: string): void;
120
+ /**
121
+ * Logs a section header
122
+ *
123
+ * @param title - Section title
124
+ */
125
+ declare function logSection(title: string): void;
126
+ /**
127
+ * Formats a change summary for display
128
+ * Creates a formatted, colored summary of detected changes
129
+ *
130
+ * @param diff - Schema diff containing all changes
131
+ * @returns Formatted summary string
132
+ */
133
+ declare function formatChangeSummary(diff: SchemaDiff): string;
134
+ /**
135
+ * Displays a progress indicator for a long operation
136
+ *
137
+ * @param message - Progress message
138
+ * @param operation - Async operation to perform
139
+ * @returns Result of the operation
140
+ */
141
+ declare function withProgress<T>(message: string, operation: () => Promise<T>): Promise<T>;
142
+ /**
143
+ * Logs a step in a multi-step process
144
+ *
145
+ * @param step - Current step number
146
+ * @param total - Total number of steps
147
+ * @param message - Step description
148
+ */
149
+ declare function logStep(step: number, total: number, message: string): void;
150
+ /**
151
+ * Logs a list of items with bullet points
152
+ *
153
+ * @param items - Items to list
154
+ * @param indent - Indentation level (default: 2)
155
+ */
156
+ declare function logList(items: string[], indent?: number): void;
157
+ /**
158
+ * Logs a key-value pair
159
+ *
160
+ * @param key - Key name
161
+ * @param value - Value to display
162
+ * @param indent - Indentation level (default: 2)
163
+ */
164
+ declare function logKeyValue(key: string, value: string, indent?: number): void;
165
+ /**
166
+ * Logs a table of data
167
+ *
168
+ * @param headers - Column headers
169
+ * @param rows - Data rows
170
+ */
171
+ declare function logTable(headers: string[], rows: string[][]): void;
172
+ /**
173
+ * Logs a box with a title and content
174
+ *
175
+ * @param title - Box title
176
+ * @param content - Box content (array of lines)
177
+ */
178
+ declare function logBox(title: string, content: string[]): void;
179
+ /**
180
+ * Creates a progress bar string
181
+ *
182
+ * @param current - Current progress value
183
+ * @param total - Total value
184
+ * @param width - Bar width in characters (default: 20)
185
+ * @returns Formatted progress bar string
186
+ */
187
+ declare function createProgressBar(current: number, total: number, width?: number): string;
188
+ /**
189
+ * Logs a timestamp with a message
190
+ *
191
+ * @param message - Message to log
192
+ */
193
+ declare function logTimestamp(message: string): void;
194
+ /**
195
+ * Formats a duration in milliseconds to a human-readable string
196
+ *
197
+ * @param ms - Duration in milliseconds
198
+ * @returns Formatted duration string
199
+ */
200
+ declare function formatDuration(ms: number): string;
201
+ /**
202
+ * Logs a timed operation result
203
+ *
204
+ * @param message - Operation description
205
+ * @param startTime - Start time from Date.now()
206
+ */
207
+ declare function logTimed(message: string, startTime: number): void;
208
+ /**
209
+ * Status output interface for JSON output mode
210
+ */
211
+ interface StatusOutput {
212
+ status: "up-to-date" | "changes-pending" | "first-time-setup";
213
+ collections: {
214
+ current: number;
215
+ snapshot: number;
216
+ };
217
+ changes: {
218
+ create: number;
219
+ delete: number;
220
+ modify: number;
221
+ };
222
+ destructive: boolean;
223
+ }
224
+ /**
225
+ * Formats status output as JSON
226
+ *
227
+ * @param output - Status output object
228
+ * @returns JSON string
229
+ */
230
+ declare function formatStatusJson(output: StatusOutput): string;
231
+
232
+ export { type MigrationConfig, type PartialMigrationConfig, type StatusOutput, type VerbosityLevel, createProgressBar, createSpinner, formatChangeSummary, formatDuration, formatStatusJson, getDefaultConfig, getMigrationsDirectory, getSampleConfig, getSchemaDirectory, getVerbosity, loadConfig, loadConfigFromArgs, logBox, logDebug, logError, logInfo, logKeyValue, logList, logSection, logStep, logSuccess, logTable, logTimed, logTimestamp, logWarning, setVerbosity, withProgress };