Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema: Typescript Codegen #1243

Open
junwen-k opened this issue May 7, 2024 · 0 comments
Open

Schema: Typescript Codegen #1243

junwen-k opened this issue May 7, 2024 · 0 comments
Assignees
Labels
feature request New feature or request

Comments

@junwen-k
Copy link
Contributor

junwen-k commented May 7, 2024

Is your feature request related to a problem? Please describe.

Currently, client that talks to Permify API is loosely typed.

Describe the solution you'd like

It would be amazing to have Typescript client automatically generated using some sort of codegen based on Permify schema, think of it like Prisma's prisma-client-js.

E.g,

entity user {} 

entity organization {
    relation admin @user    
    relation member @user     
    
    action view_files = admin or member
    action edit_files = admin
} 

Generates a client that allow us to do:

import { Permify } from '@permify/client'

const client = new Permify({
    endpoint: "localhost:3478",
})

// orm-like syntax
client.permission.tenantId("t1").organization("organization-001").permission("view_files").user("user-001").check({
    metadata: {
        snapToken: "",
        schemaVersion: "",
        depth: 20
    },
}).then(...);

// strongly typed, you will get compile error if you attempt to check against something that is not written in your schema
const response = await client.permission.tenantId("t1").organization().permission("edit_files").user().subjectPermission();

Describe alternatives you've considered

  1. Manually writing types and using the default client.
  2. Standalone orm builder that can be used in all services.

Additional context

Having a strongly typed client automatically generated will greatly improve DX.

Caveats

Not sure about the complexity of implementing it and how it will work for Data service / attribute, etc. The above example roughly demonstrates the idea.

@junwen-k junwen-k added the feature request New feature or request label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants