@@ -20,7 +20,6 @@ import {
2020 isDataModel ,
2121 isInvocationExpr ,
2222 isLiteralExpr ,
23- isModel ,
2423 isNullExpr ,
2524 isReferenceExpr ,
2625 isStringLiteral ,
@@ -31,7 +30,7 @@ import {
3130 StringLiteral ,
3231 type AstNode ,
3332} from '@zenstackhq/language/ast' ;
34- import { getAllAttributes , getAllFields , isDelegateModel } from '@zenstackhq/language/utils' ;
33+ import { getAllAttributes , getAllFields , isAuthInvocation , isDelegateModel } from '@zenstackhq/language/utils' ;
3534import { AstUtils } from 'langium' ;
3635import { match } from 'ts-pattern' ;
3736import { ModelUtils , ZModelCodeGenerator } from '..' ;
@@ -242,8 +241,8 @@ export class PrismaSchemaGenerator {
242241
243242 const attributes = field . attributes
244243 . filter ( ( attr ) => this . isPrismaAttribute ( attr ) )
245- // `@default` with calling functions from plugin is handled outside Prisma
246- . filter ( ( attr ) => ! this . isDefaultWithPluginInvocation ( attr ) )
244+ // `@default` using `auth()` is handled outside Prisma
245+ . filter ( ( attr ) => ! this . isDefaultWithAuthInvocation ( attr ) )
247246 . filter (
248247 ( attr ) =>
249248 // when building physical schema, exclude `@default` for id fields inherited from delegate base
@@ -260,7 +259,7 @@ export class PrismaSchemaGenerator {
260259 return result ;
261260 }
262261
263- private isDefaultWithPluginInvocation ( attr : DataFieldAttribute ) {
262+ private isDefaultWithAuthInvocation ( attr : DataFieldAttribute ) {
264263 if ( attr . decl . ref ?. name !== '@default' ) {
265264 return false ;
266265 }
@@ -270,12 +269,7 @@ export class PrismaSchemaGenerator {
270269 return false ;
271270 }
272271
273- return AstUtils . streamAst ( expr ) . some ( ( node ) => isInvocationExpr ( node ) && this . isFromPlugin ( node . function . ref ) ) ;
274- }
275-
276- private isFromPlugin ( node : AstNode | undefined ) {
277- const model = AstUtils . getContainerOfType ( node , isModel ) ;
278- return ! ! model && ! ! model . $document && model . $document . uri . path . endsWith ( 'plugin.zmodel' ) ;
272+ return AstUtils . streamAst ( expr ) . some ( isAuthInvocation ) ;
279273 }
280274
281275 private isInheritedFromDelegate ( field : DataField , contextModel : DataModel ) {
0 commit comments