From f61ebef59a47fc6d9f550270ceef4a8b27d496ef Mon Sep 17 00:00:00 2001 From: Drew Haven Date: Tue, 27 May 2025 18:07:26 -0700 Subject: [PATCH] Adds collections and types --- pb_migrations/1748393928_created_campaigns.js | 84 +++++++++++++++++++ pb_migrations/1748394031_created_documents.js | 80 ++++++++++++++++++ pb_migrations/1748394167_updated_campaigns.js | 28 +++++++ pb_migrations/1748394245_updated_documents.js | 58 +++++++++++++ src/lib/types.ts | 10 +++ 5 files changed, 260 insertions(+) create mode 100644 pb_migrations/1748393928_created_campaigns.js create mode 100644 pb_migrations/1748394031_created_documents.js create mode 100644 pb_migrations/1748394167_updated_campaigns.js create mode 100644 pb_migrations/1748394245_updated_documents.js create mode 100644 src/lib/types.ts diff --git a/pb_migrations/1748393928_created_campaigns.js b/pb_migrations/1748393928_created_campaigns.js new file mode 100644 index 0000000..21d6ab8 --- /dev/null +++ b/pb_migrations/1748393928_created_campaigns.js @@ -0,0 +1,84 @@ +/// +migrate((app) => { + const collection = new Collection({ + "createRule": null, + "deleteRule": null, + "fields": [ + { + "autogeneratePattern": "[a-z0-9]{15}", + "hidden": false, + "id": "text3208210256", + "max": 15, + "min": 15, + "name": "id", + "pattern": "^[a-z0-9]+$", + "presentable": false, + "primaryKey": true, + "required": true, + "system": true, + "type": "text" + }, + { + "autogeneratePattern": "", + "hidden": false, + "id": "text1579384326", + "max": 0, + "min": 0, + "name": "name", + "pattern": "", + "presentable": false, + "primaryKey": false, + "required": false, + "system": false, + "type": "text" + }, + { + "cascadeDelete": false, + "collectionId": "_pb_users_auth_", + "hidden": false, + "id": "relation3479234172", + "maxSelect": 1, + "minSelect": 0, + "name": "owner", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }, + { + "hidden": false, + "id": "autodate2990389176", + "name": "created", + "onCreate": true, + "onUpdate": false, + "presentable": false, + "system": false, + "type": "autodate" + }, + { + "hidden": false, + "id": "autodate3332085495", + "name": "updated", + "onCreate": true, + "onUpdate": true, + "presentable": false, + "system": false, + "type": "autodate" + } + ], + "id": "pbc_2270728936", + "indexes": [], + "listRule": null, + "name": "campaigns", + "system": false, + "type": "base", + "updateRule": null, + "viewRule": null + }); + + return app.save(collection); +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_2270728936"); + + return app.delete(collection); +}) diff --git a/pb_migrations/1748394031_created_documents.js b/pb_migrations/1748394031_created_documents.js new file mode 100644 index 0000000..5b79b8d --- /dev/null +++ b/pb_migrations/1748394031_created_documents.js @@ -0,0 +1,80 @@ +/// +migrate((app) => { + const collection = new Collection({ + "createRule": null, + "deleteRule": null, + "fields": [ + { + "autogeneratePattern": "[a-z0-9]{15}", + "hidden": false, + "id": "text3208210256", + "max": 15, + "min": 15, + "name": "id", + "pattern": "^[a-z0-9]+$", + "presentable": false, + "primaryKey": true, + "required": true, + "system": true, + "type": "text" + }, + { + "cascadeDelete": true, + "collectionId": "pbc_2270728936", + "hidden": false, + "id": "relation1542800728", + "maxSelect": 1, + "minSelect": 0, + "name": "field", + "presentable": false, + "required": true, + "system": false, + "type": "relation" + }, + { + "hidden": false, + "id": "json2918445923", + "maxSize": 0, + "name": "data", + "presentable": false, + "required": false, + "system": false, + "type": "json" + }, + { + "hidden": false, + "id": "autodate2990389176", + "name": "created", + "onCreate": true, + "onUpdate": false, + "presentable": false, + "system": false, + "type": "autodate" + }, + { + "hidden": false, + "id": "autodate3332085495", + "name": "updated", + "onCreate": true, + "onUpdate": true, + "presentable": false, + "system": false, + "type": "autodate" + } + ], + "id": "pbc_3332084752", + "indexes": [], + "listRule": null, + "name": "documents", + "system": false, + "type": "base", + "updateRule": null, + "viewRule": null + }); + + return app.save(collection); +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_3332084752"); + + return app.delete(collection); +}) diff --git a/pb_migrations/1748394167_updated_campaigns.js b/pb_migrations/1748394167_updated_campaigns.js new file mode 100644 index 0000000..241a819 --- /dev/null +++ b/pb_migrations/1748394167_updated_campaigns.js @@ -0,0 +1,28 @@ +/// +migrate((app) => { + const collection = app.findCollectionByNameOrId("pbc_2270728936") + + // update collection data + unmarshal({ + "createRule": "", + "deleteRule": "@request.auth.id = owner.id", + "listRule": "@request.auth.id = owner.id", + "updateRule": "@request.auth.id = owner.id", + "viewRule": "@request.auth.id = owner.id" + }, collection) + + return app.save(collection) +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_2270728936") + + // update collection data + unmarshal({ + "createRule": null, + "deleteRule": null, + "listRule": null, + "updateRule": null, + "viewRule": null + }, collection) + + return app.save(collection) +}) diff --git a/pb_migrations/1748394245_updated_documents.js b/pb_migrations/1748394245_updated_documents.js new file mode 100644 index 0000000..f1b7309 --- /dev/null +++ b/pb_migrations/1748394245_updated_documents.js @@ -0,0 +1,58 @@ +/// +migrate((app) => { + const collection = app.findCollectionByNameOrId("pbc_3332084752") + + // update collection data + unmarshal({ + "createRule": "", + "deleteRule": "@request.auth.id = campaign.owner.id", + "listRule": "@request.auth.id = campaign.owner.id", + "updateRule": "@request.auth.id = campaign.owner.id", + "viewRule": "@request.auth.id = campaign.owner.id" + }, collection) + + // update field + collection.fields.addAt(1, new Field({ + "cascadeDelete": true, + "collectionId": "pbc_2270728936", + "hidden": false, + "id": "relation1542800728", + "maxSelect": 1, + "minSelect": 0, + "name": "campaign", + "presentable": false, + "required": true, + "system": false, + "type": "relation" + })) + + return app.save(collection) +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_3332084752") + + // update collection data + unmarshal({ + "createRule": null, + "deleteRule": null, + "listRule": null, + "updateRule": null, + "viewRule": null + }, collection) + + // update field + collection.fields.addAt(1, new Field({ + "cascadeDelete": true, + "collectionId": "pbc_2270728936", + "hidden": false, + "id": "relation1542800728", + "maxSelect": 1, + "minSelect": 0, + "name": "field", + "presentable": false, + "required": true, + "system": false, + "type": "relation" + })) + + return app.save(collection) +}) diff --git a/src/lib/types.ts b/src/lib/types.ts new file mode 100644 index 0000000..6a92e2b --- /dev/null +++ b/src/lib/types.ts @@ -0,0 +1,10 @@ +export type Campaign = { + id: string; + name: string; +}; + +export type Document = { + id: string; + campaign: Campaign; + data: {}; +};