zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 88 forks source link

Extensions on latest zenStack #713

Closed Jonatthu closed 1 year ago

Jonatthu commented 1 year ago

When i run generate the next error happens, it's important to notice that I need those extensions, Does ZenStack not support prisma extensions?

$ zenstack generate Validation errors: line 10: Could not resolve reference to ReferenceTarget named 'pg_trgm'. [pg_trgm] line 10: Could not resolve reference to FunctionDecl named 'postgis'. [postgis] line 10: Could not resolve reference to FunctionDecl named 'uuid_ossp'. [uuid_ossp]

ymc9 commented 1 year ago

Hi @Jonatthu , thanks for bringing it up. Extensions are not supported yet but it's only on the ZModel syntax level. Need to support the grammar and then pass it down to Prisma schema.

I understand this is blocking for you, and we should be able to add it in the next release (early next week). Will it work for you?

Do you mind share the exact Prisma snippet that declares the extensions? Just want to make sure it work seamlessly.

Jonatthu commented 1 year ago

@ymc9 That's excellent news! I will be looking forward to it

Jonatthu commented 1 year ago

@ymc9 Here the snippet

generator client {
    provider        = "prisma-client-js"
    previewFeatures = ["fullTextIndex", "fullTextSearch", "multiSchema", "postgresqlExtensions"]
}

datasource db {
    provider   = "postgresql"
    url        = env("SUPABASE_DATABASE_URL")
    directUrl  = env("SUPABASE_DATABASE_DIRECT_URL")
    extensions = [pg_trgm, postgis(version: "3.3.2"), uuid_ossp(map: "uuid-ossp", schema: "extensions")]
    schemas    = ["auth", "public"]
}
ymc9 commented 1 year ago

Awesome. Thank you! Stay tuned to the release notes 😄.

ymc9 commented 1 year ago

Hi @Jonatthu , the latest 1.0.1 release supports extensions syntax now.