pocketbase-zod-schema 0.2.2 → 0.2.4

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cli/index.cjs +52 -1
  3. package/dist/cli/index.cjs.map +1 -1
  4. package/dist/cli/index.js +52 -1
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/cli/migrate.cjs +52 -1
  7. package/dist/cli/migrate.cjs.map +1 -1
  8. package/dist/cli/migrate.js +52 -1
  9. package/dist/cli/migrate.js.map +1 -1
  10. package/dist/index.cjs +658 -690
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +1 -3
  13. package/dist/index.d.ts +1 -3
  14. package/dist/index.js +658 -683
  15. package/dist/index.js.map +1 -1
  16. package/dist/migration/generator.cjs +52 -1
  17. package/dist/migration/generator.cjs.map +1 -1
  18. package/dist/migration/generator.d.cts +0 -7
  19. package/dist/migration/generator.d.ts +0 -7
  20. package/dist/migration/generator.js +52 -1
  21. package/dist/migration/generator.js.map +1 -1
  22. package/dist/migration/index.cjs +52 -1
  23. package/dist/migration/index.cjs.map +1 -1
  24. package/dist/migration/index.js +52 -1
  25. package/dist/migration/index.js.map +1 -1
  26. package/dist/migration/snapshot.cjs.map +1 -1
  27. package/dist/migration/snapshot.js.map +1 -1
  28. package/dist/mutator.cjs +2 -98
  29. package/dist/mutator.cjs.map +1 -1
  30. package/dist/mutator.d.cts +4 -31
  31. package/dist/mutator.d.ts +4 -31
  32. package/dist/mutator.js +2 -98
  33. package/dist/mutator.js.map +1 -1
  34. package/dist/schema.cjs +0 -78
  35. package/dist/schema.cjs.map +1 -1
  36. package/dist/schema.d.cts +0 -1
  37. package/dist/schema.d.ts +0 -1
  38. package/dist/schema.js +1 -72
  39. package/dist/schema.js.map +1 -1
  40. package/package.json +1 -6
  41. package/dist/types.cjs +0 -4
  42. package/dist/types.cjs.map +0 -1
  43. package/dist/types.d.cts +0 -14
  44. package/dist/types.d.ts +0 -14
  45. package/dist/types.js +0 -3
  46. package/dist/types.js.map +0 -1
  47. package/dist/user-BnFWg5tw.d.cts +0 -161
  48. package/dist/user-BnFWg5tw.d.ts +0 -161
@@ -3333,6 +3333,55 @@ function generateIndexesArray(indexes) {
3333
3333
  ${indexStrings.join(",\n ")},
3334
3334
  ]`;
3335
3335
  }
3336
+ function getSystemFields() {
3337
+ return [
3338
+ // id field - primary key, auto-generated
3339
+ {
3340
+ name: "id",
3341
+ type: "text",
3342
+ required: true,
3343
+ options: {
3344
+ autogeneratePattern: "[a-z0-9]{15}",
3345
+ hidden: false,
3346
+ id: "text3208210256",
3347
+ max: 15,
3348
+ min: 15,
3349
+ pattern: "^[a-z0-9]+$",
3350
+ presentable: false,
3351
+ primaryKey: true,
3352
+ system: true
3353
+ }
3354
+ },
3355
+ // created field - autodate, set on creation
3356
+ {
3357
+ name: "created",
3358
+ type: "autodate",
3359
+ required: true,
3360
+ options: {
3361
+ hidden: false,
3362
+ id: "autodate2990389176",
3363
+ onCreate: true,
3364
+ onUpdate: false,
3365
+ presentable: false,
3366
+ system: false
3367
+ }
3368
+ },
3369
+ // updated field - autodate, set on creation and update
3370
+ {
3371
+ name: "updated",
3372
+ type: "autodate",
3373
+ required: true,
3374
+ options: {
3375
+ hidden: false,
3376
+ id: "autodate3332085495",
3377
+ onCreate: true,
3378
+ onUpdate: true,
3379
+ presentable: false,
3380
+ system: false
3381
+ }
3382
+ }
3383
+ ];
3384
+ }
3336
3385
  function generateCollectionCreation(collection, varName = "collection", isLast = false) {
3337
3386
  const lines = [];
3338
3387
  lines.push(` const ${varName} = new Collection({`);
@@ -3345,7 +3394,9 @@ function generateCollectionCreation(collection, varName = "collection", isLast =
3345
3394
  } else if (rulesCode) {
3346
3395
  lines.push(` ${rulesCode},`);
3347
3396
  }
3348
- lines.push(` fields: ${generateFieldsArray(collection.fields)},`);
3397
+ const systemFields = getSystemFields();
3398
+ const allFields = [...systemFields, ...collection.fields];
3399
+ lines.push(` fields: ${generateFieldsArray(allFields)},`);
3349
3400
  lines.push(` indexes: ${generateIndexesArray(collection.indexes)},`);
3350
3401
  lines.push(` });`);
3351
3402
  lines.push(``);