pocketbase-zod-schema 0.2.2 → 0.2.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.3](https://github.com/dastron/pocketbase-zod-schema/compare/pocketbase-zod-schema-v0.2.2...pocketbase-zod-schema-v0.2.3) (2025-12-20)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * include default system fields (id, updated, created) ([d89ef2e](https://github.com/dastron/pocketbase-zod-schema/commit/d89ef2ec7c3dec52cafce826c12e4e9288d05255))
9
+
3
10
  ## [0.2.2](https://github.com/dastron/pocketbase-zod-schema/compare/pocketbase-zod-schema-v0.2.1...pocketbase-zod-schema-v0.2.2) (2025-12-20)
4
11
 
5
12
 
@@ -2100,6 +2100,55 @@ function generateIndexesArray(indexes) {
2100
2100
  ${indexStrings.join(",\n ")},
2101
2101
  ]`;
2102
2102
  }
2103
+ function getSystemFields() {
2104
+ return [
2105
+ // id field - primary key, auto-generated
2106
+ {
2107
+ name: "id",
2108
+ type: "text",
2109
+ required: true,
2110
+ options: {
2111
+ autogeneratePattern: "[a-z0-9]{15}",
2112
+ hidden: false,
2113
+ id: "text3208210256",
2114
+ max: 15,
2115
+ min: 15,
2116
+ pattern: "^[a-z0-9]+$",
2117
+ presentable: false,
2118
+ primaryKey: true,
2119
+ system: true
2120
+ }
2121
+ },
2122
+ // created field - autodate, set on creation
2123
+ {
2124
+ name: "created",
2125
+ type: "autodate",
2126
+ required: true,
2127
+ options: {
2128
+ hidden: false,
2129
+ id: "autodate2990389176",
2130
+ onCreate: true,
2131
+ onUpdate: false,
2132
+ presentable: false,
2133
+ system: false
2134
+ }
2135
+ },
2136
+ // updated field - autodate, set on creation and update
2137
+ {
2138
+ name: "updated",
2139
+ type: "autodate",
2140
+ required: true,
2141
+ options: {
2142
+ hidden: false,
2143
+ id: "autodate3332085495",
2144
+ onCreate: true,
2145
+ onUpdate: true,
2146
+ presentable: false,
2147
+ system: false
2148
+ }
2149
+ }
2150
+ ];
2151
+ }
2103
2152
  function generateCollectionCreation(collection, varName = "collection", isLast = false) {
2104
2153
  const lines = [];
2105
2154
  lines.push(` const ${varName} = new Collection({`);
@@ -2112,7 +2161,9 @@ function generateCollectionCreation(collection, varName = "collection", isLast =
2112
2161
  } else if (rulesCode) {
2113
2162
  lines.push(` ${rulesCode},`);
2114
2163
  }
2115
- lines.push(` fields: ${generateFieldsArray(collection.fields)},`);
2164
+ const systemFields = getSystemFields();
2165
+ const allFields = [...systemFields, ...collection.fields];
2166
+ lines.push(` fields: ${generateFieldsArray(allFields)},`);
2116
2167
  lines.push(` indexes: ${generateIndexesArray(collection.indexes)},`);
2117
2168
  lines.push(` });`);
2118
2169
  lines.push(``);