pdpAPI example using https://github.com/astahmer/openapi-zod-client

## To Run the demo code

```bash
npm install
./run.sh
# Set `TOKEN` in `src/example_script.ts` to a valid bearer token.
npm start
```

Output from the script

```
My roles: {
  "cursor": {
    "cursor": null,
    "shorthand": null
  },
  "errors": {},
  "tenants": {
    "0268C3328E7C4C4E9Bb304532Eb51C82": {
      "tenantType": "account",
      "tenantUuid": "0268c332-8e7c-4c4e-9bb3-04532eb51c82",
      "roles": [
        {
          "role": "audience_development_analyst"
        }
      ]
    },
    "a2Dbe1E9E1004Ec188Ae75D4F8Cec8F6": {
      "tenantType": "subaccount",
      "tenantUuid": "a2dbe1e9-e100-4ec1-88ae-75d4f8cec8f6",
      "roles": [
        {
          "role": "audience_development_client"
        }
      ]
    }
  }
}
My Allowed Tenants: {
  "resourceType": "audience",
  "action": "view",
  "tenants": [
    {
      "tenantType": "account",
      "tenantUuid": "0268c332-8e7c-4c4e-9bb3-04532eb51c82"
    },
    {
      "tenantType": "subaccount",
      "tenantUuid": "a2dbe1e9-e100-4ec1-88ae-75d4f8cec8f6"
    }
  ]
}
Check Resources: {
  "requestId": "601d5860-8f14-4179-8e68-d2f70946f138",
  "resources": [
    {
      "resource": {
        "resourceId": "0",
        "resourceType": "audience",
        "attributes": {}
      },
      "action": "view",
      "effect": "deny",
      "errors": {
        "validationErrors": null
      }
    }
  ]
}
```

## Pros / Cons

**Pros**

1. The Zod schemas look correct at first glance.
2. We can separate models into separate files by "tag" (`--group-strategy="tag-file"`).
3. We can roll own `ApiClient` class to include `OwsDataSource`
   behavior that want to preserve from the `OwsPdpDataSource` implementations.

**Cons**[identity.ts](src%2Fzod_openapi%2Fmodels%2Fidentity.ts)

1. Not actively maintained. Last updated 2 weeks ago then last updated back in `July 2024`.
2. Does not export the types and does not use `z.infer` to generate the types: https://github.com/astahmer/openapi-zod-client/issues/317
3. Not easy to filter down useful models like “ignore” in openapi generator.
4. The generated code breaks if we remove `infra` and `temp` models. We’ll need to pre-process the `openapi.json`.
5. Does not handle camelCase to snake_case.
