@@ -26,7 +26,7 @@ import {
2626 type Model ,
2727} from '@zenstackhq/sdk/ast' ;
2828import { getDMMF , getPrismaClientImportSpec , getPrismaVersion , type DMMF } from '@zenstackhq/sdk/prisma' ;
29- import { upperCaseFirst } from '@zenstackhq/runtime/local-helpers' ;
29+ import { invariant , upperCaseFirst } from '@zenstackhq/runtime/local-helpers' ;
3030import fs from 'fs' ;
3131import path from 'path' ;
3232import semver from 'semver' ;
@@ -493,32 +493,6 @@ export type Enhanced<Client> =
493493 private async processClientTypesNewPrismaGenerator ( prismaClientDir : string , delegateInfo : DelegateInfo ) {
494494 const project = new Project ( ) ;
495495
496- // remove delegate_aux_* fields from the prismaNamespace.ts
497- const internalFilename = `${ prismaClientDir } /internal/prismaNamespace.ts`
498- const internalFilenameFixed = `${ prismaClientDir } /internal/prismaNamespace-fixed.ts`
499- const internalSf = project . addSourceFileAtPath ( internalFilename ) ;
500- const syntaxList = internalSf . getChildren ( ) [ 0 ] ;
501- if ( ! Node . isSyntaxList ( syntaxList ) ) {
502- throw new PluginError ( name , `Unexpected syntax list structure in ${ internalFilename } ` ) ;
503- }
504- const statements : ( string | StatementStructures ) [ ] = [ ] ;
505-
506- syntaxList . getChildren ( ) . forEach ( ( node ) => {
507- if ( Node . isVariableStatement ( node ) ) {
508- statements . push ( this . transformVariableStatementProps ( node ) ) ;
509- } else {
510- statements . push ( node . getText ( ) ) ;
511- }
512- } ) ;
513- const structure = internalSf . getStructure ( ) ;
514- structure . statements = statements ;
515-
516- const internalSfNew = project . createSourceFile ( internalFilenameFixed , structure , {
517- overwrite : true ,
518- } ) ;
519- await internalSfNew . save ( ) ;
520- fs . renameSync ( internalFilenameFixed , internalFilename ) ;
521-
522496 // Create a shared file for all JSON fields type definitions
523497 const jsonFieldsFile = project . createSourceFile ( path . join ( this . outDir , 'json-types.ts' ) , undefined , {
524498 overwrite : true ,
@@ -687,6 +661,7 @@ export type Enhanced<Client> =
687661 if ( variable . initializer ) {
688662 let source = variable . initializer ;
689663 auxFields . forEach ( ( f ) => {
664+ invariant ( typeof source === 'string' ) ;
690665 source = this . removeFromSource ( source , f . getText ( ) ) ;
691666 } ) ;
692667 variable . initializer = source ;
@@ -1036,7 +1011,7 @@ export type Enhanced<Client> =
10361011 }
10371012
10381013 private trimEmptyLines ( source : string ) : string {
1039- return source . replace ( / ^ \s * \ ,? [ \r \n ] / gm, '' ) ;
1014+ return source . replace ( / ^ \s * , ? [ \r \n ] / gm, '' ) ;
10401015 }
10411016
10421017 private get isNewPrismaClientGenerator ( ) {
0 commit comments