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