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.
@@ -2077,6 +2077,55 @@ function generateIndexesArray(indexes) {
2077
2077
  ${indexStrings.join(",\n ")},
2078
2078
  ]`;
2079
2079
  }
2080
+ function getSystemFields() {
2081
+ return [
2082
+ // id field - primary key, auto-generated
2083
+ {
2084
+ name: "id",
2085
+ type: "text",
2086
+ required: true,
2087
+ options: {
2088
+ autogeneratePattern: "[a-z0-9]{15}",
2089
+ hidden: false,
2090
+ id: "text3208210256",
2091
+ max: 15,
2092
+ min: 15,
2093
+ pattern: "^[a-z0-9]+$",
2094
+ presentable: false,
2095
+ primaryKey: true,
2096
+ system: true
2097
+ }
2098
+ },
2099
+ // created field - autodate, set on creation
2100
+ {
2101
+ name: "created",
2102
+ type: "autodate",
2103
+ required: true,
2104
+ options: {
2105
+ hidden: false,
2106
+ id: "autodate2990389176",
2107
+ onCreate: true,
2108
+ onUpdate: false,
2109
+ presentable: false,
2110
+ system: false
2111
+ }
2112
+ },
2113
+ // updated field - autodate, set on creation and update
2114
+ {
2115
+ name: "updated",
2116
+ type: "autodate",
2117
+ required: true,
2118
+ options: {
2119
+ hidden: false,
2120
+ id: "autodate3332085495",
2121
+ onCreate: true,
2122
+ onUpdate: true,
2123
+ presentable: false,
2124
+ system: false
2125
+ }
2126
+ }
2127
+ ];
2128
+ }
2080
2129
  function generateCollectionCreation(collection, varName = "collection", isLast = false) {
2081
2130
  const lines = [];
2082
2131
  lines.push(` const ${varName} = new Collection({`);
@@ -2089,7 +2138,9 @@ function generateCollectionCreation(collection, varName = "collection", isLast =
2089
2138
  } else if (rulesCode) {
2090
2139
  lines.push(` ${rulesCode},`);
2091
2140
  }
2092
- lines.push(` fields: ${generateFieldsArray(collection.fields)},`);
2141
+ const systemFields = getSystemFields();
2142
+ const allFields = [...systemFields, ...collection.fields];
2143
+ lines.push(` fields: ${generateFieldsArray(allFields)},`);
2093
2144
  lines.push(` indexes: ${generateIndexesArray(collection.indexes)},`);
2094
2145
  lines.push(` });`);
2095
2146
  lines.push(``);