pocketbase-zod-schema 0.7.0 → 0.7.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 (70) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cli/index.cjs +449 -50
  3. package/dist/cli/index.cjs.map +1 -1
  4. package/dist/cli/index.d.cts +1 -1
  5. package/dist/cli/index.d.ts +1 -1
  6. package/dist/cli/index.js +449 -50
  7. package/dist/cli/index.js.map +1 -1
  8. package/dist/cli/migrate.cjs +455 -53
  9. package/dist/cli/migrate.cjs.map +1 -1
  10. package/dist/cli/migrate.js +455 -53
  11. package/dist/cli/migrate.js.map +1 -1
  12. package/dist/cli/utils/index.cjs +8 -1
  13. package/dist/cli/utils/index.cjs.map +1 -1
  14. package/dist/cli/utils/index.d.cts +1 -1
  15. package/dist/cli/utils/index.d.ts +1 -1
  16. package/dist/cli/utils/index.js +8 -1
  17. package/dist/cli/utils/index.js.map +1 -1
  18. package/dist/index.cjs +90 -1
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +87 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/migration/analyzer.cjs +87 -14
  25. package/dist/migration/analyzer.cjs.map +1 -1
  26. package/dist/migration/analyzer.d.cts +12 -4
  27. package/dist/migration/analyzer.d.ts +12 -4
  28. package/dist/migration/analyzer.js +87 -15
  29. package/dist/migration/analyzer.js.map +1 -1
  30. package/dist/migration/diff.cjs +64 -9
  31. package/dist/migration/diff.cjs.map +1 -1
  32. package/dist/migration/diff.d.cts +12 -2
  33. package/dist/migration/diff.d.ts +12 -2
  34. package/dist/migration/diff.js +64 -10
  35. package/dist/migration/diff.js.map +1 -1
  36. package/dist/migration/generator.cjs +206 -39
  37. package/dist/migration/generator.cjs.map +1 -1
  38. package/dist/migration/generator.d.cts +54 -2
  39. package/dist/migration/generator.d.ts +54 -2
  40. package/dist/migration/generator.js +203 -40
  41. package/dist/migration/generator.js.map +1 -1
  42. package/dist/migration/index.cjs +501 -63
  43. package/dist/migration/index.cjs.map +1 -1
  44. package/dist/migration/index.d.cts +2 -2
  45. package/dist/migration/index.d.ts +2 -2
  46. package/dist/migration/index.js +501 -63
  47. package/dist/migration/index.js.map +1 -1
  48. package/dist/migration/snapshot.cjs +147 -1
  49. package/dist/migration/snapshot.cjs.map +1 -1
  50. package/dist/migration/snapshot.d.cts +3 -1
  51. package/dist/migration/snapshot.d.ts +3 -1
  52. package/dist/migration/snapshot.js +147 -1
  53. package/dist/migration/snapshot.js.map +1 -1
  54. package/dist/migration/utils/index.d.cts +1 -1
  55. package/dist/migration/utils/index.d.ts +1 -1
  56. package/dist/schema.cjs +90 -1
  57. package/dist/schema.cjs.map +1 -1
  58. package/dist/schema.d.cts +128 -2
  59. package/dist/schema.d.ts +128 -2
  60. package/dist/schema.js +87 -2
  61. package/dist/schema.js.map +1 -1
  62. package/dist/server.cjs +545 -65
  63. package/dist/server.cjs.map +1 -1
  64. package/dist/server.d.cts +2 -2
  65. package/dist/server.d.ts +2 -2
  66. package/dist/server.js +542 -66
  67. package/dist/server.js.map +1 -1
  68. package/dist/{types-CWHV6ATd.d.cts → types-CnzfX6JH.d.cts} +20 -2
  69. package/dist/{types-C2nGWHLV.d.ts → types-Do3jyFBm.d.ts} +20 -2
  70. package/package.json +1 -1
@@ -23,7 +23,7 @@ interface FieldDefinition {
23
23
  }
24
24
  interface CollectionSchema {
25
25
  name: string;
26
- type: "base" | "auth";
26
+ type: "base" | "auth" | "view";
27
27
  /**
28
28
  * Pre-generated collection ID for use in migrations
29
29
  * Format: pb_ followed by 15 alphanumeric lowercase characters
@@ -31,6 +31,12 @@ interface CollectionSchema {
31
31
  * This ID is generated during migration creation to avoid runtime lookups
32
32
  */
33
33
  id?: string;
34
+ /**
35
+ * SQL SELECT statement backing a view collection (type: "view" only)
36
+ * PocketBase derives the collection's fields from this query, so `fields`
37
+ * is not emitted into migrations for view collections
38
+ */
39
+ viewQuery?: string;
34
40
  fields: FieldDefinition[];
35
41
  indexes?: string[];
36
42
  rules?: {
@@ -82,6 +88,14 @@ interface PermissionChange {
82
88
  oldValue: string | null;
83
89
  newValue: string | null;
84
90
  }
91
+ /**
92
+ * View query change tracking for view collections
93
+ * Applied in place so the collection ID stays stable
94
+ */
95
+ interface ViewQueryUpdate {
96
+ oldValue: string | null;
97
+ newValue: string;
98
+ }
85
99
  interface CollectionModification {
86
100
  collection: string;
87
101
  fieldsToAdd: FieldDefinition[];
@@ -91,6 +105,10 @@ interface CollectionModification {
91
105
  indexesToRemove: string[];
92
106
  rulesToUpdate: RuleUpdate[];
93
107
  permissionsToUpdate: PermissionChange[];
108
+ /**
109
+ * Set when a view collection's SQL query changed (view collections only)
110
+ */
111
+ viewQueryUpdate?: ViewQueryUpdate;
94
112
  }
95
113
  interface SchemaDiff {
96
114
  collectionsToCreate: CollectionSchema[];
@@ -127,4 +145,4 @@ interface CollectionOperation {
127
145
  timestamp: string;
128
146
  }
129
147
 
130
- export type { CollectionSchema as C, FieldDefinition as F, PermissionChange as P, RuleUpdate as R, SchemaDefinition as S, SchemaSnapshot as a, FieldChange as b, FieldModification as c, CollectionModification as d, SchemaDiff as e, CollectionOperation as f };
148
+ export type { CollectionSchema as C, FieldDefinition as F, PermissionChange as P, RuleUpdate as R, SchemaDefinition as S, ViewQueryUpdate as V, SchemaSnapshot as a, FieldChange as b, FieldModification as c, CollectionModification as d, SchemaDiff as e, CollectionOperation as f };
@@ -23,7 +23,7 @@ interface FieldDefinition {
23
23
  }
24
24
  interface CollectionSchema {
25
25
  name: string;
26
- type: "base" | "auth";
26
+ type: "base" | "auth" | "view";
27
27
  /**
28
28
  * Pre-generated collection ID for use in migrations
29
29
  * Format: pb_ followed by 15 alphanumeric lowercase characters
@@ -31,6 +31,12 @@ interface CollectionSchema {
31
31
  * This ID is generated during migration creation to avoid runtime lookups
32
32
  */
33
33
  id?: string;
34
+ /**
35
+ * SQL SELECT statement backing a view collection (type: "view" only)
36
+ * PocketBase derives the collection's fields from this query, so `fields`
37
+ * is not emitted into migrations for view collections
38
+ */
39
+ viewQuery?: string;
34
40
  fields: FieldDefinition[];
35
41
  indexes?: string[];
36
42
  rules?: {
@@ -82,6 +88,14 @@ interface PermissionChange {
82
88
  oldValue: string | null;
83
89
  newValue: string | null;
84
90
  }
91
+ /**
92
+ * View query change tracking for view collections
93
+ * Applied in place so the collection ID stays stable
94
+ */
95
+ interface ViewQueryUpdate {
96
+ oldValue: string | null;
97
+ newValue: string;
98
+ }
85
99
  interface CollectionModification {
86
100
  collection: string;
87
101
  fieldsToAdd: FieldDefinition[];
@@ -91,6 +105,10 @@ interface CollectionModification {
91
105
  indexesToRemove: string[];
92
106
  rulesToUpdate: RuleUpdate[];
93
107
  permissionsToUpdate: PermissionChange[];
108
+ /**
109
+ * Set when a view collection's SQL query changed (view collections only)
110
+ */
111
+ viewQueryUpdate?: ViewQueryUpdate;
94
112
  }
95
113
  interface SchemaDiff {
96
114
  collectionsToCreate: CollectionSchema[];
@@ -127,4 +145,4 @@ interface CollectionOperation {
127
145
  timestamp: string;
128
146
  }
129
147
 
130
- export type { CollectionSchema as C, FieldDefinition as F, PermissionChange as P, RuleUpdate as R, SchemaDefinition as S, SchemaSnapshot as a, FieldChange as b, FieldModification as c, CollectionModification as d, SchemaDiff as e, CollectionOperation as f };
148
+ export type { CollectionSchema as C, FieldDefinition as F, PermissionChange as P, RuleUpdate as R, SchemaDefinition as S, ViewQueryUpdate as V, SchemaSnapshot as a, FieldChange as b, FieldModification as c, CollectionModification as d, SchemaDiff as e, CollectionOperation as f };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pocketbase-zod-schema",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "PocketBase migration generator using Zod schemas for type-safe database migrations",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",