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.
@@ -2105,6 +2105,55 @@ function generateIndexesArray(indexes) {
2105
2105
  ${indexStrings.join(",\n ")},
2106
2106
  ]`;
2107
2107
  }
2108
+ function getSystemFields() {
2109
+ return [
2110
+ // id field - primary key, auto-generated
2111
+ {
2112
+ name: "id",
2113
+ type: "text",
2114
+ required: true,
2115
+ options: {
2116
+ autogeneratePattern: "[a-z0-9]{15}",
2117
+ hidden: false,
2118
+ id: "text3208210256",
2119
+ max: 15,
2120
+ min: 15,
2121
+ pattern: "^[a-z0-9]+$",
2122
+ presentable: false,
2123
+ primaryKey: true,
2124
+ system: true
2125
+ }
2126
+ },
2127
+ // created field - autodate, set on creation
2128
+ {
2129
+ name: "created",
2130
+ type: "autodate",
2131
+ required: true,
2132
+ options: {
2133
+ hidden: false,
2134
+ id: "autodate2990389176",
2135
+ onCreate: true,
2136
+ onUpdate: false,
2137
+ presentable: false,
2138
+ system: false
2139
+ }
2140
+ },
2141
+ // updated field - autodate, set on creation and update
2142
+ {
2143
+ name: "updated",
2144
+ type: "autodate",
2145
+ required: true,
2146
+ options: {
2147
+ hidden: false,
2148
+ id: "autodate3332085495",
2149
+ onCreate: true,
2150
+ onUpdate: true,
2151
+ presentable: false,
2152
+ system: false
2153
+ }
2154
+ }
2155
+ ];
2156
+ }
2108
2157
  function generateCollectionCreation(collection, varName = "collection", isLast = false) {
2109
2158
  const lines = [];
2110
2159
  lines.push(` const ${varName} = new Collection({`);
@@ -2117,7 +2166,9 @@ function generateCollectionCreation(collection, varName = "collection", isLast =
2117
2166
  } else if (rulesCode) {
2118
2167
  lines.push(` ${rulesCode},`);
2119
2168
  }
2120
- lines.push(` fields: ${generateFieldsArray(collection.fields)},`);
2169
+ const systemFields = getSystemFields();
2170
+ const allFields = [...systemFields, ...collection.fields];
2171
+ lines.push(` fields: ${generateFieldsArray(allFields)},`);
2121
2172
  lines.push(` indexes: ${generateIndexesArray(collection.indexes)},`);
2122
2173
  lines.push(` });`);
2123
2174
  lines.push(``);