Schema

The schema follows the official JSON Schema specification, available in the official documentation.

Permguard allow the creation of a schema file to be named schema.json and placed in the root of the workspace.

Below is an example of a directory structure that includes the schema file:

.
├── .permguard
├── schema.json

Below is a sample schema:

{
    "MagicFarmacia::Platform": {
      "entityTypes": {
        "Branch": {
          "shape": {
            "type": "Record",
            "attributes": {
              "city": {
                "type": "String"
              }
            }
          },
          "memberOfTypes": [
            "Account"
          ]
        },
        "Account": {
          "shape": {
            "type": "Record",
            "attributes": {
              "active": {
                "type": "Boolean"
              }
            }
          },
          "memberOfTypes": []
        }
      },
      "actions": {
        "create": {
          "appliesTo": {
            "principalTypes": [
              "Permguard::IAM::User",
              "Permguard::IAM::Actor"
            ],
            "resourceTypes": [
              "Account",
              "Branch"
            ]
          }
        },
        "update": {
          "appliesTo": {
            "principalTypes": [
              "Permguard::IAM::User",
              "Permguard::IAM::Actor"
            ],
            "resourceTypes": [
              "Account",
              "Branch"
            ]
          }
        },
        "delete": {
          "appliesTo": {
            "principalTypes": [
              "Permguard::IAM::User",
              "Permguard::IAM::Actor"
            ],
            "resourceTypes": [
              "Account",
              "Branch"
            ]
          }
        },
        "view": {
          "appliesTo": {
            "principalTypes": [
              "Permguard::IAM::User",
              "Permguard::IAM::Actor"
            ],
            "resourceTypes": [
              "Account",
              "Branch"
            ],
            "context": {
              "type": "Record",
              "attributes": {
                "isSuperUser": {
                  "type": "Boolean",
                  "required": true
                }
              }
            }
          }
        }
      }
    }
  }