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.cjs CHANGED
@@ -4009,6 +4009,55 @@ function generateIndexesArray(indexes) {
4009
4009
  ${indexStrings.join(",\n ")},
4010
4010
  ]`;
4011
4011
  }
4012
+ function getSystemFields() {
4013
+ return [
4014
+ // id field - primary key, auto-generated
4015
+ {
4016
+ name: "id",
4017
+ type: "text",
4018
+ required: true,
4019
+ options: {
4020
+ autogeneratePattern: "[a-z0-9]{15}",
4021
+ hidden: false,
4022
+ id: "text3208210256",
4023
+ max: 15,
4024
+ min: 15,
4025
+ pattern: "^[a-z0-9]+$",
4026
+ presentable: false,
4027
+ primaryKey: true,
4028
+ system: true
4029
+ }
4030
+ },
4031
+ // created field - autodate, set on creation
4032
+ {
4033
+ name: "created",
4034
+ type: "autodate",
4035
+ required: true,
4036
+ options: {
4037
+ hidden: false,
4038
+ id: "autodate2990389176",
4039
+ onCreate: true,
4040
+ onUpdate: false,
4041
+ presentable: false,
4042
+ system: false
4043
+ }
4044
+ },
4045
+ // updated field - autodate, set on creation and update
4046
+ {
4047
+ name: "updated",
4048
+ type: "autodate",
4049
+ required: true,
4050
+ options: {
4051
+ hidden: false,
4052
+ id: "autodate3332085495",
4053
+ onCreate: true,
4054
+ onUpdate: true,
4055
+ presentable: false,
4056
+ system: false
4057
+ }
4058
+ }
4059
+ ];
4060
+ }
4012
4061
  function generateCollectionCreation(collection, varName = "collection", isLast = false) {
4013
4062
  const lines = [];
4014
4063
  lines.push(` const ${varName} = new Collection({`);
@@ -4021,7 +4070,9 @@ function generateCollectionCreation(collection, varName = "collection", isLast =
4021
4070
  } else if (rulesCode) {
4022
4071
  lines.push(` ${rulesCode},`);
4023
4072
  }
4024
- lines.push(` fields: ${generateFieldsArray(collection.fields)},`);
4073
+ const systemFields = getSystemFields();
4074
+ const allFields = [...systemFields, ...collection.fields];
4075
+ lines.push(` fields: ${generateFieldsArray(allFields)},`);
4025
4076
  lines.push(` indexes: ${generateIndexesArray(collection.indexes)},`);
4026
4077
  lines.push(` });`);
4027
4078
  lines.push(``);