pocketbase-zod-schema 0.2.5 → 0.3.0

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 (66) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cli/index.cjs +374 -296
  3. package/dist/cli/index.cjs.map +1 -1
  4. package/dist/cli/index.d.cts +2 -2
  5. package/dist/cli/index.d.ts +2 -2
  6. package/dist/cli/index.js +374 -296
  7. package/dist/cli/index.js.map +1 -1
  8. package/dist/cli/migrate.cjs +374 -296
  9. package/dist/cli/migrate.cjs.map +1 -1
  10. package/dist/cli/migrate.js +374 -296
  11. package/dist/cli/migrate.js.map +1 -1
  12. package/dist/cli/utils/index.d.cts +2 -2
  13. package/dist/cli/utils/index.d.ts +2 -2
  14. package/dist/{fields-YjcpBXVp.d.cts → fields-UcOPu1OQ.d.cts} +16 -0
  15. package/dist/{fields-YjcpBXVp.d.ts → fields-UcOPu1OQ.d.ts} +16 -0
  16. package/dist/index.cjs +413 -114
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +4 -4
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +414 -103
  21. package/dist/index.js.map +1 -1
  22. package/dist/migration/analyzer.cjs +12 -2
  23. package/dist/migration/analyzer.cjs.map +1 -1
  24. package/dist/migration/analyzer.d.cts +2 -2
  25. package/dist/migration/analyzer.d.ts +2 -2
  26. package/dist/migration/analyzer.js +12 -2
  27. package/dist/migration/analyzer.js.map +1 -1
  28. package/dist/migration/diff.cjs +76 -1
  29. package/dist/migration/diff.cjs.map +1 -1
  30. package/dist/migration/diff.d.cts +2 -2
  31. package/dist/migration/diff.d.ts +2 -2
  32. package/dist/migration/diff.js +76 -1
  33. package/dist/migration/diff.js.map +1 -1
  34. package/dist/migration/generator.cjs +323 -46
  35. package/dist/migration/generator.cjs.map +1 -1
  36. package/dist/migration/generator.d.cts +59 -12
  37. package/dist/migration/generator.d.ts +59 -12
  38. package/dist/migration/generator.js +319 -47
  39. package/dist/migration/generator.js.map +1 -1
  40. package/dist/migration/index.cjs +399 -49
  41. package/dist/migration/index.cjs.map +1 -1
  42. package/dist/migration/index.d.cts +3 -3
  43. package/dist/migration/index.d.ts +3 -3
  44. package/dist/migration/index.js +399 -49
  45. package/dist/migration/index.js.map +1 -1
  46. package/dist/migration/snapshot.cjs.map +1 -1
  47. package/dist/migration/snapshot.d.cts +2 -2
  48. package/dist/migration/snapshot.d.ts +2 -2
  49. package/dist/migration/snapshot.js.map +1 -1
  50. package/dist/migration/utils/index.cjs +64 -0
  51. package/dist/migration/utils/index.cjs.map +1 -1
  52. package/dist/migration/utils/index.d.cts +39 -202
  53. package/dist/migration/utils/index.d.ts +39 -202
  54. package/dist/migration/utils/index.js +63 -1
  55. package/dist/migration/utils/index.js.map +1 -1
  56. package/dist/schema.cjs +0 -61
  57. package/dist/schema.cjs.map +1 -1
  58. package/dist/schema.d.cts +2 -86
  59. package/dist/schema.d.ts +2 -86
  60. package/dist/schema.js +1 -50
  61. package/dist/schema.js.map +1 -1
  62. package/dist/type-mapper-DrQmtznD.d.cts +208 -0
  63. package/dist/type-mapper-n231Fspm.d.ts +208 -0
  64. package/dist/{types-LFBGHl9Y.d.ts → types-Ds3NQvny.d.ts} +33 -2
  65. package/dist/{types-mhQXWNi3.d.cts → types-YoBjsa-A.d.cts} +33 -2
  66. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { Ora } from 'ora';
2
- import { e as SchemaDiff } from '../../types-mhQXWNi3.cjs';
3
- import '../../fields-YjcpBXVp.cjs';
2
+ import { e as SchemaDiff } from '../../types-YoBjsa-A.cjs';
3
+ import '../../fields-UcOPu1OQ.cjs';
4
4
  import 'zod';
5
5
  import '../../permissions-ZHafVSIx.cjs';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { Ora } from 'ora';
2
- import { e as SchemaDiff } from '../../types-LFBGHl9Y.js';
3
- import '../../fields-YjcpBXVp.js';
2
+ import { e as SchemaDiff } from '../../types-Ds3NQvny.js';
3
+ import '../../fields-UcOPu1OQ.js';
4
4
  import 'zod';
5
5
  import '../../permissions-ZHafVSIx.js';
6
6
 
@@ -67,6 +67,15 @@ interface NumberFieldOptions {
67
67
  * Whether to disallow decimal values (integers only)
68
68
  */
69
69
  noDecimal?: boolean;
70
+ /**
71
+ * Whether the field is required
72
+ * @default false
73
+ *
74
+ * Note: In PocketBase, `required: true` for number fields means the value must be non-zero.
75
+ * If you want to allow zero values (e.g., for progress: 0-100), keep this as `false`.
76
+ * Set to `true` only if you want to enforce non-zero values.
77
+ */
78
+ required?: boolean;
70
79
  }
71
80
  /**
72
81
  * Date field configuration options
@@ -169,7 +178,14 @@ declare function BoolField(): z.ZodBoolean;
169
178
  * price: NumberField({ min: 0 }),
170
179
  * quantity: NumberField({ min: 0, noDecimal: true }),
171
180
  * rating: NumberField({ min: 0, max: 5 }),
181
+ * progress: NumberField({ min: 0, max: 100 }), // required defaults to false, allowing zero
182
+ * score: NumberField({ min: 1, max: 10, required: true }), // requires non-zero value
172
183
  * });
184
+ *
185
+ * @remarks
186
+ * By default, number fields are not required (`required: false`), which allows zero values.
187
+ * In PocketBase, `required: true` for number fields means the value must be non-zero.
188
+ * If you set `min: 0` and want to allow zero, keep `required: false` (the default).
173
189
  */
174
190
  declare function NumberField(options?: NumberFieldOptions): z.ZodNumber;
175
191
  /**
@@ -67,6 +67,15 @@ interface NumberFieldOptions {
67
67
  * Whether to disallow decimal values (integers only)
68
68
  */
69
69
  noDecimal?: boolean;
70
+ /**
71
+ * Whether the field is required
72
+ * @default false
73
+ *
74
+ * Note: In PocketBase, `required: true` for number fields means the value must be non-zero.
75
+ * If you want to allow zero values (e.g., for progress: 0-100), keep this as `false`.
76
+ * Set to `true` only if you want to enforce non-zero values.
77
+ */
78
+ required?: boolean;
70
79
  }
71
80
  /**
72
81
  * Date field configuration options
@@ -169,7 +178,14 @@ declare function BoolField(): z.ZodBoolean;
169
178
  * price: NumberField({ min: 0 }),
170
179
  * quantity: NumberField({ min: 0, noDecimal: true }),
171
180
  * rating: NumberField({ min: 0, max: 5 }),
181
+ * progress: NumberField({ min: 0, max: 100 }), // required defaults to false, allowing zero
182
+ * score: NumberField({ min: 1, max: 10, required: true }), // requires non-zero value
172
183
  * });
184
+ *
185
+ * @remarks
186
+ * By default, number fields are not required (`required: false`), which allows zero values.
187
+ * In PocketBase, `required: true` for number fields means the value must be non-zero.
188
+ * If you set `min: 0` and want to allow zero, keep `required: false` (the default).
173
189
  */
174
190
  declare function NumberField(options?: NumberFieldOptions): z.ZodNumber;
175
191
  /**