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/index.js CHANGED
@@ -3982,6 +3982,55 @@ function generateIndexesArray(indexes) {
3982
3982
  ${indexStrings.join(",\n ")},
3983
3983
  ]`;
3984
3984
  }
3985
+ function getSystemFields() {
3986
+ return [
3987
+ // id field - primary key, auto-generated
3988
+ {
3989
+ name: "id",
3990
+ type: "text",
3991
+ required: true,
3992
+ options: {
3993
+ autogeneratePattern: "[a-z0-9]{15}",
3994
+ hidden: false,
3995
+ id: "text3208210256",
3996
+ max: 15,
3997
+ min: 15,
3998
+ pattern: "^[a-z0-9]+$",
3999
+ presentable: false,
4000
+ primaryKey: true,
4001
+ system: true
4002
+ }
4003
+ },
4004
+ // created field - autodate, set on creation
4005
+ {
4006
+ name: "created",
4007
+ type: "autodate",
4008
+ required: true,
4009
+ options: {
4010
+ hidden: false,
4011
+ id: "autodate2990389176",
4012
+ onCreate: true,
4013
+ onUpdate: false,
4014
+ presentable: false,
4015
+ system: false
4016
+ }
4017
+ },
4018
+ // updated field - autodate, set on creation and update
4019
+ {
4020
+ name: "updated",
4021
+ type: "autodate",
4022
+ required: true,
4023
+ options: {
4024
+ hidden: false,
4025
+ id: "autodate3332085495",
4026
+ onCreate: true,
4027
+ onUpdate: true,
4028
+ presentable: false,
4029
+ system: false
4030
+ }
4031
+ }
4032
+ ];
4033
+ }
3985
4034
  function generateCollectionCreation(collection, varName = "collection", isLast = false) {
3986
4035
  const lines = [];
3987
4036
  lines.push(` const ${varName} = new Collection({`);
@@ -3994,7 +4043,9 @@ function generateCollectionCreation(collection, varName = "collection", isLast =
3994
4043
  } else if (rulesCode) {
3995
4044
  lines.push(` ${rulesCode},`);
3996
4045
  }
3997
- lines.push(` fields: ${generateFieldsArray(collection.fields)},`);
4046
+ const systemFields = getSystemFields();
4047
+ const allFields = [...systemFields, ...collection.fields];
4048
+ lines.push(` fields: ${generateFieldsArray(allFields)},`);
3998
4049
  lines.push(` indexes: ${generateIndexesArray(collection.indexes)},`);
3999
4050
  lines.push(` });`);
4000
4051
  lines.push(``);