Skip to content

Conversation

margani
Copy link

@margani margani commented Jun 23, 2025

This pull request updates the parsing logic to support both legacy and newer versions of PocketBase collection exports.

PocketBase v0.22 (or possibly an earlier version) introduced changes to the exported collection JSON structure:

The fields array has been renamed to schema.

Each field's configuration options is now nested under an options object.

This update ensures that PocketBaseUML remains compatible with both the older and newer formats by conditionally checking for fields or schema, and accessing field options appropriately.
Since the exact version introducing this change is unclear, the update is designed to be backward compatible.

Let me know if you'd like a suggested changelog entry or commit message too.

Example

image

[
    {
        "id": "_pb_users_auth_",
        "name": "users",
        "type": "auth",
        "system": false,
        "schema": [
            {
                "system": false,
                "id": "users_name",
                "name": "name",
                "type": "text",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "min": null,
                    "max": null,
                    "pattern": ""
                }
            },
            {
                "system": false,
                "id": "users_avatar",
                "name": "avatar",
                "type": "file",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "mimeTypes": [
                        "image/jpeg",
                        "image/png",
                        "image/svg+xml",
                        "image/gif",
                        "image/webp"
                    ],
                    "thumbs": null,
                    "maxSelect": 1,
                    "maxSize": 5242880,
                    "protected": false
                }
            }
        ],
        "indexes": [],
        "listRule": "id = @request.auth.id",
        "viewRule": "id = @request.auth.id",
        "createRule": "",
        "updateRule": "id = @request.auth.id",
        "deleteRule": "id = @request.auth.id",
        "options": {
            "allowEmailAuth": true,
            "allowOAuth2Auth": true,
            "allowUsernameAuth": true,
            "exceptEmailDomains": null,
            "manageRule": null,
            "minPasswordLength": 8,
            "onlyEmailDomains": null,
            "onlyVerified": true,
            "requireEmail": true
        }
    },
    {
        "id": "bmugtuznd5yyc6x",
        "name": "expenses",
        "type": "base",
        "system": false,
        "schema": [
            {
                "system": false,
                "id": "lxtocwtw",
                "name": "date",
                "type": "date",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "min": "",
                    "max": ""
                }
            },
            {
                "system": false,
                "id": "fokddwhk",
                "name": "notes",
                "type": "text",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "min": null,
                    "max": null,
                    "pattern": ""
                }
            },
            {
                "system": false,
                "id": "sxj2ifb1",
                "name": "amount",
                "type": "number",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "min": null,
                    "max": null,
                    "noDecimal": false
                }
            },
            {
                "system": false,
                "id": "8rccoolk",
                "name": "user",
                "type": "relation",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "collectionId": "_pb_users_auth_",
                    "cascadeDelete": false,
                    "minSelect": null,
                    "maxSelect": 1,
                    "displayFields": null
                }
            },
            {
                "system": false,
                "id": "wtm1dpsu",
                "name": "receipt",
                "type": "file",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "mimeTypes": [
                        "image/png",
                        "image/jpeg"
                    ],
                    "thumbs": [],
                    "maxSelect": 1,
                    "maxSize": 5242880,
                    "protected": false
                }
            }
        ],
        "indexes": [],
        "listRule": "@request.auth.id = user.id",
        "viewRule": "@request.auth.id = user.id",
        "createRule": "@request.auth.id = user.id",
        "updateRule": "@request.auth.id = user.id",
        "deleteRule": "@request.auth.id = user.id",
        "options": {}
    },
    {
        "id": "d2c92wgetu1tknt",
        "name": "images",
        "type": "base",
        "system": false,
        "schema": [
            {
                "system": false,
                "id": "eazrkfy4",
                "name": "user",
                "type": "relation",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "collectionId": "_pb_users_auth_",
                    "cascadeDelete": true,
                    "minSelect": null,
                    "maxSelect": 1,
                    "displayFields": null
                }
            },
            {
                "system": false,
                "id": "znwbtcjy",
                "name": "image",
                "type": "file",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "mimeTypes": [],
                    "thumbs": [],
                    "maxSelect": 1,
                    "maxSize": 5242880,
                    "protected": false
                }
            },
            {
                "system": false,
                "id": "2ahjbc17",
                "name": "title",
                "type": "text",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "min": null,
                    "max": null,
                    "pattern": ""
                }
            },
            {
                "system": false,
                "id": "y1zgikys",
                "name": "description",
                "type": "editor",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "convertUrls": false
                }
            },
            {
                "system": false,
                "id": "0uhst2qy",
                "name": "tags",
                "type": "json",
                "required": false,
                "presentable": false,
                "unique": false,
                "options": {
                    "maxSize": 2000000
                }
            }
        ],
        "indexes": [
            "CREATE INDEX `idx_x3QfWsZ` ON `images` (\n  `title`,\n  `description`,\n  `tags`\n)"
        ],
        "listRule": "@request.auth.id = user.id",
        "viewRule": "@request.auth.id = user.id",
        "createRule": "@request.auth.id = user.id",
        "updateRule": "@request.auth.id = user.id",
        "deleteRule": "@request.auth.id = user.id",
        "options": {}
    }
]

@margani
Copy link
Author

margani commented Jun 25, 2025

@icflorescu @karimodm Can you review this PR please? Thank you.

@margani
Copy link
Author

margani commented Sep 24, 2025

@Amarosuli Thank you for merging. I thought the deployment to pocketbase-uml.github.io/ is done automatically after merge.

@Amarosuli
Copy link

@margani but i'm a bit confused, why do i can merge since this repo is not mine. 😄

@margani
Copy link
Author

margani commented Sep 24, 2025

@Amarosuli oh okay, my bad, I thought you also merged it. thanks for the approval btw.

@Amarosuli
Copy link

@margani i just tried the link with latest version pocketbase collection. It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants