@zenstackhq/sdk 3.0.0-beta.9 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2,8 +2,6 @@ import * as _zenstackhq_language_ast from '@zenstackhq/language/ast';
2
2
  import { DataField, DataModel, TypeDef, Enum, EnumField, FunctionDecl, Attribute, AttributeParam, DataFieldAttribute, DataModelAttribute, AstNode, Model, Reference, InvocationExpr } from '@zenstackhq/language/ast';
3
3
  import { AttributeTarget } from '@zenstackhq/language/utils';
4
4
  import { MaybePromise } from 'langium';
5
- import { E as Expression, L as LiteralExpression, A as ArrayExpression, F as FieldExpression, M as MemberExpression, B as BinaryExpression, U as UnaryExpression, C as CallExpression, T as ThisExpression, N as NullExpression } from './expression-Ce_oulwU.cjs';
6
- import { OperationNodeVisitor, OperationNode, SelectQueryNode, SelectionNode, ColumnNode, AliasNode, TableNode, FromNode, ReferenceNode, AndNode, OrNode, ValueListNode, ParensNode, JoinNode, RawNode, WhereNode, InsertQueryNode, DeleteQueryNode, ReturningNode, CreateTableNode, AddColumnNode, ColumnDefinitionNode, DropTableNode, OrderByNode, OrderByItemNode, GroupByNode, GroupByItemNode, UpdateQueryNode, ColumnUpdateNode, LimitNode, OffsetNode, OnConflictNode, OnDuplicateKeyNode, CheckConstraintNode, DataTypeNode, SelectAllNode, IdentifierNode, SchemableIdentifierNode, ValueNode, PrimitiveValueListNode, OperatorNode, CreateIndexNode, DropIndexNode, ListNode, PrimaryKeyConstraintNode, UniqueConstraintNode, ReferencesNode, WithNode, CommonTableExpressionNode, CommonTableExpressionNameNode, HavingNode, CreateSchemaNode, DropSchemaNode, AlterTableNode, DropColumnNode, RenameColumnNode, AlterColumnNode, ModifyColumnNode, AddConstraintNode, DropConstraintNode, ForeignKeyConstraintNode, CreateViewNode, DropViewNode, GeneratedNode, DefaultValueNode, OnNode, ValuesNode, SelectModifierNode, CreateTypeNode, DropTypeNode, ExplainNode, DefaultInsertValueNode, AggregateFunctionNode, OverNode, PartitionByNode, PartitionByItemNode, SetOperationNode, BinaryOperationNode, UnaryOperationNode, UsingNode, FunctionNode, CaseNode, WhenNode, JSONReferenceNode, JSONPathNode, JSONPathLegNode, JSONOperatorChainNode, TupleNode, MergeQueryNode, MatchedNode, AddIndexNode, CastNode, FetchNode, TopNode, OutputNode } from 'kysely';
7
5
 
8
6
  declare function isIdField(field: DataField, contextModel: DataModel): boolean;
9
7
  declare function hasAttribute(decl: DataModel | TypeDef | DataField | Enum | EnumField | FunctionDecl | Attribute | AttributeParam, name: string): boolean;
@@ -74,116 +72,6 @@ interface CliPlugin {
74
72
  generate(context: CliGeneratorContext): MaybePromise<void>;
75
73
  }
76
74
 
77
- declare class ExpressionVisitor {
78
- visit(expr: Expression): void;
79
- protected visitLiteral(_e: LiteralExpression): void;
80
- protected visitArray(e: ArrayExpression): void;
81
- protected visitField(_e: FieldExpression): void;
82
- protected visitMember(e: MemberExpression): void;
83
- protected visitBinary(e: BinaryExpression): void;
84
- protected visitUnary(e: UnaryExpression): void;
85
- protected visitCall(e: CallExpression): void;
86
- protected visitThis(_e: ThisExpression): void;
87
- protected visitNull(_e: NullExpression): void;
88
- }
89
-
90
- declare class DefaultOperationNodeVisitor extends OperationNodeVisitor {
91
- protected defaultVisit(node: OperationNode): void;
92
- protected visitSelectQuery(node: SelectQueryNode): void;
93
- protected visitSelection(node: SelectionNode): void;
94
- protected visitColumn(node: ColumnNode): void;
95
- protected visitAlias(node: AliasNode): void;
96
- protected visitTable(node: TableNode): void;
97
- protected visitFrom(node: FromNode): void;
98
- protected visitReference(node: ReferenceNode): void;
99
- protected visitAnd(node: AndNode): void;
100
- protected visitOr(node: OrNode): void;
101
- protected visitValueList(node: ValueListNode): void;
102
- protected visitParens(node: ParensNode): void;
103
- protected visitJoin(node: JoinNode): void;
104
- protected visitRaw(node: RawNode): void;
105
- protected visitWhere(node: WhereNode): void;
106
- protected visitInsertQuery(node: InsertQueryNode): void;
107
- protected visitDeleteQuery(node: DeleteQueryNode): void;
108
- protected visitReturning(node: ReturningNode): void;
109
- protected visitCreateTable(node: CreateTableNode): void;
110
- protected visitAddColumn(node: AddColumnNode): void;
111
- protected visitColumnDefinition(node: ColumnDefinitionNode): void;
112
- protected visitDropTable(node: DropTableNode): void;
113
- protected visitOrderBy(node: OrderByNode): void;
114
- protected visitOrderByItem(node: OrderByItemNode): void;
115
- protected visitGroupBy(node: GroupByNode): void;
116
- protected visitGroupByItem(node: GroupByItemNode): void;
117
- protected visitUpdateQuery(node: UpdateQueryNode): void;
118
- protected visitColumnUpdate(node: ColumnUpdateNode): void;
119
- protected visitLimit(node: LimitNode): void;
120
- protected visitOffset(node: OffsetNode): void;
121
- protected visitOnConflict(node: OnConflictNode): void;
122
- protected visitOnDuplicateKey(node: OnDuplicateKeyNode): void;
123
- protected visitCheckConstraint(node: CheckConstraintNode): void;
124
- protected visitDataType(node: DataTypeNode): void;
125
- protected visitSelectAll(node: SelectAllNode): void;
126
- protected visitIdentifier(node: IdentifierNode): void;
127
- protected visitSchemableIdentifier(node: SchemableIdentifierNode): void;
128
- protected visitValue(node: ValueNode): void;
129
- protected visitPrimitiveValueList(node: PrimitiveValueListNode): void;
130
- protected visitOperator(node: OperatorNode): void;
131
- protected visitCreateIndex(node: CreateIndexNode): void;
132
- protected visitDropIndex(node: DropIndexNode): void;
133
- protected visitList(node: ListNode): void;
134
- protected visitPrimaryKeyConstraint(node: PrimaryKeyConstraintNode): void;
135
- protected visitUniqueConstraint(node: UniqueConstraintNode): void;
136
- protected visitReferences(node: ReferencesNode): void;
137
- protected visitWith(node: WithNode): void;
138
- protected visitCommonTableExpression(node: CommonTableExpressionNode): void;
139
- protected visitCommonTableExpressionName(node: CommonTableExpressionNameNode): void;
140
- protected visitHaving(node: HavingNode): void;
141
- protected visitCreateSchema(node: CreateSchemaNode): void;
142
- protected visitDropSchema(node: DropSchemaNode): void;
143
- protected visitAlterTable(node: AlterTableNode): void;
144
- protected visitDropColumn(node: DropColumnNode): void;
145
- protected visitRenameColumn(node: RenameColumnNode): void;
146
- protected visitAlterColumn(node: AlterColumnNode): void;
147
- protected visitModifyColumn(node: ModifyColumnNode): void;
148
- protected visitAddConstraint(node: AddConstraintNode): void;
149
- protected visitDropConstraint(node: DropConstraintNode): void;
150
- protected visitForeignKeyConstraint(node: ForeignKeyConstraintNode): void;
151
- protected visitCreateView(node: CreateViewNode): void;
152
- protected visitDropView(node: DropViewNode): void;
153
- protected visitGenerated(node: GeneratedNode): void;
154
- protected visitDefaultValue(node: DefaultValueNode): void;
155
- protected visitOn(node: OnNode): void;
156
- protected visitValues(node: ValuesNode): void;
157
- protected visitSelectModifier(node: SelectModifierNode): void;
158
- protected visitCreateType(node: CreateTypeNode): void;
159
- protected visitDropType(node: DropTypeNode): void;
160
- protected visitExplain(node: ExplainNode): void;
161
- protected visitDefaultInsertValue(node: DefaultInsertValueNode): void;
162
- protected visitAggregateFunction(node: AggregateFunctionNode): void;
163
- protected visitOver(node: OverNode): void;
164
- protected visitPartitionBy(node: PartitionByNode): void;
165
- protected visitPartitionByItem(node: PartitionByItemNode): void;
166
- protected visitSetOperation(node: SetOperationNode): void;
167
- protected visitBinaryOperation(node: BinaryOperationNode): void;
168
- protected visitUnaryOperation(node: UnaryOperationNode): void;
169
- protected visitUsing(node: UsingNode): void;
170
- protected visitFunction(node: FunctionNode): void;
171
- protected visitCase(node: CaseNode): void;
172
- protected visitWhen(node: WhenNode): void;
173
- protected visitJSONReference(node: JSONReferenceNode): void;
174
- protected visitJSONPath(node: JSONPathNode): void;
175
- protected visitJSONPathLeg(node: JSONPathLegNode): void;
176
- protected visitJSONOperatorChain(node: JSONOperatorChainNode): void;
177
- protected visitTuple(node: TupleNode): void;
178
- protected visitMergeQuery(node: MergeQueryNode): void;
179
- protected visitMatched(node: MatchedNode): void;
180
- protected visitAddIndex(node: AddIndexNode): void;
181
- protected visitCast(node: CastNode): void;
182
- protected visitFetch(node: FetchNode): void;
183
- protected visitTop(node: TopNode): void;
184
- protected visitOutput(node: OutputNode): void;
185
- }
186
-
187
75
  declare class FunctionCall {
188
76
  func: string;
189
77
  args: FunctionCallArg[];
@@ -211,11 +99,13 @@ declare class PrismaSchemaGenerator {
211
99
  private configInvocationArgToText;
212
100
  private literalToText;
213
101
  private generateGenerator;
102
+ private generateDefaultGenerator;
214
103
  private generateModel;
215
- private isInheritedMapAttribute;
104
+ private getDatasourceField;
105
+ private datasourceHasSchemasSetting;
106
+ private getDefaultPostgresSchemaName;
216
107
  private isPrismaAttribute;
217
108
  private getUnsupportedFieldType;
218
- private getStringLiteral;
219
109
  private generateModelField;
220
110
  private isDefaultWithAuthInvocation;
221
111
  private isInheritedFromDelegate;
@@ -233,15 +123,24 @@ declare class PrismaSchemaGenerator {
233
123
  private truncate;
234
124
  }
235
125
 
126
+ type TsSchemaGeneratorOptions = {
127
+ outDir: string;
128
+ lite?: boolean;
129
+ liteOnly?: boolean;
130
+ importWithFileExtension?: string;
131
+ };
236
132
  declare class TsSchemaGenerator {
237
133
  private usedExpressionUtils;
238
- generate(model: Model, outputDir: string): Promise<void>;
134
+ generate(model: Model, options: TsSchemaGeneratorOptions): Promise<void>;
239
135
  private generateSchema;
240
136
  private generateSchemaStatements;
241
137
  private createExpressionUtilsCall;
242
- private createSchemaObject;
138
+ private createSchemaClass;
139
+ private createAsConst;
243
140
  private createProviderObject;
244
141
  private createModelsObject;
142
+ private getAllDataModels;
143
+ private getAllTypeDefs;
245
144
  private createTypeDefsObject;
246
145
  private createDataModelObject;
247
146
  private getSubModels;
@@ -251,6 +150,7 @@ declare class TsSchemaGenerator {
251
150
  private createDataFieldObject;
252
151
  private isDiscriminatorField;
253
152
  private getDataSourceProvider;
153
+ private getDataSourceDefaultSchema;
254
154
  private getFieldMappedDefault;
255
155
  private getMappedValue;
256
156
  private getMemberAccessChain;
@@ -267,6 +167,7 @@ declare class TsSchemaGenerator {
267
167
  private createEnumObject;
268
168
  private getLiteral;
269
169
  private createLiteralNode;
170
+ private createNumberLiteral;
270
171
  private createProceduresObject;
271
172
  private createProcedureObject;
272
173
  private generateBannerComments;
@@ -288,69 +189,4 @@ declare class TsSchemaGenerator {
288
189
  private generateInputTypes;
289
190
  }
290
191
 
291
- /**
292
- * Options for the generator.
293
- */
294
- interface ZModelCodeOptions {
295
- binaryExprNumberOfSpaces: number;
296
- unaryExprNumberOfSpaces: number;
297
- indent: number;
298
- quote: 'single' | 'double';
299
- }
300
- /**
301
- * Generates ZModel source code from AST.
302
- */
303
- declare class ZModelCodeGenerator {
304
- private readonly options;
305
- constructor(options?: Partial<ZModelCodeOptions>);
306
- /**
307
- * Generates ZModel source code from AST.
308
- */
309
- generate(ast: AstNode): string;
310
- private _generateModel;
311
- private _generateDataSource;
312
- private _generateEnum;
313
- private _generateEnumField;
314
- private _generateGenerator;
315
- private _generateConfigField;
316
- private _generateConfigArrayExpr;
317
- private _generateConfigInvocationExpr;
318
- private _generatePlugin;
319
- private _generatePluginField;
320
- private _generateDataModel;
321
- private _generateDataField;
322
- private fieldType;
323
- private _generateDataModelAttribute;
324
- private _generateDataFieldAttribute;
325
- private attribute;
326
- private _generateAttributeArg;
327
- private _generateObjectExpr;
328
- private objectField;
329
- private _generateArrayExpr;
330
- private _generateLiteralExpr;
331
- private _generateNumberLiteral;
332
- private _generateBooleanLiteral;
333
- private _generateUnaryExpr;
334
- private _generateBinaryExpr;
335
- private _generateReferenceExpr;
336
- private _generateReferenceArg;
337
- private _generateMemberExpr;
338
- private _generateInvocationExpr;
339
- private _generateNullExpr;
340
- private _generateThisExpr;
341
- private _generateAttribute;
342
- private _generateAttributeParam;
343
- private _generateAttributeParamType;
344
- private _generateFunctionDecl;
345
- private _generateFunctionParam;
346
- private _generateFunctionParamType;
347
- private _generateTypeDef;
348
- private argument;
349
- private get binaryExprSpace();
350
- private get unaryExprSpace();
351
- private get indent();
352
- private isParenthesesNeededForBinaryExpr;
353
- private isCollectionPredicateOperator;
354
- }
355
-
356
- export { type CliGeneratorContext, type CliPlugin, DefaultOperationNodeVisitor, ExpressionVisitor, modelUtils as ModelUtils, PrismaSchemaGenerator, TsSchemaGenerator, ZModelCodeGenerator, type ZModelCodeOptions };
192
+ export { type CliGeneratorContext, type CliPlugin, modelUtils as ModelUtils, PrismaSchemaGenerator, TsSchemaGenerator, type TsSchemaGeneratorOptions };
package/dist/index.d.ts CHANGED
@@ -2,8 +2,6 @@ import * as _zenstackhq_language_ast from '@zenstackhq/language/ast';
2
2
  import { DataField, DataModel, TypeDef, Enum, EnumField, FunctionDecl, Attribute, AttributeParam, DataFieldAttribute, DataModelAttribute, AstNode, Model, Reference, InvocationExpr } from '@zenstackhq/language/ast';
3
3
  import { AttributeTarget } from '@zenstackhq/language/utils';
4
4
  import { MaybePromise } from 'langium';
5
- import { E as Expression, L as LiteralExpression, A as ArrayExpression, F as FieldExpression, M as MemberExpression, B as BinaryExpression, U as UnaryExpression, C as CallExpression, T as ThisExpression, N as NullExpression } from './expression-Ce_oulwU.js';
6
- import { OperationNodeVisitor, OperationNode, SelectQueryNode, SelectionNode, ColumnNode, AliasNode, TableNode, FromNode, ReferenceNode, AndNode, OrNode, ValueListNode, ParensNode, JoinNode, RawNode, WhereNode, InsertQueryNode, DeleteQueryNode, ReturningNode, CreateTableNode, AddColumnNode, ColumnDefinitionNode, DropTableNode, OrderByNode, OrderByItemNode, GroupByNode, GroupByItemNode, UpdateQueryNode, ColumnUpdateNode, LimitNode, OffsetNode, OnConflictNode, OnDuplicateKeyNode, CheckConstraintNode, DataTypeNode, SelectAllNode, IdentifierNode, SchemableIdentifierNode, ValueNode, PrimitiveValueListNode, OperatorNode, CreateIndexNode, DropIndexNode, ListNode, PrimaryKeyConstraintNode, UniqueConstraintNode, ReferencesNode, WithNode, CommonTableExpressionNode, CommonTableExpressionNameNode, HavingNode, CreateSchemaNode, DropSchemaNode, AlterTableNode, DropColumnNode, RenameColumnNode, AlterColumnNode, ModifyColumnNode, AddConstraintNode, DropConstraintNode, ForeignKeyConstraintNode, CreateViewNode, DropViewNode, GeneratedNode, DefaultValueNode, OnNode, ValuesNode, SelectModifierNode, CreateTypeNode, DropTypeNode, ExplainNode, DefaultInsertValueNode, AggregateFunctionNode, OverNode, PartitionByNode, PartitionByItemNode, SetOperationNode, BinaryOperationNode, UnaryOperationNode, UsingNode, FunctionNode, CaseNode, WhenNode, JSONReferenceNode, JSONPathNode, JSONPathLegNode, JSONOperatorChainNode, TupleNode, MergeQueryNode, MatchedNode, AddIndexNode, CastNode, FetchNode, TopNode, OutputNode } from 'kysely';
7
5
 
8
6
  declare function isIdField(field: DataField, contextModel: DataModel): boolean;
9
7
  declare function hasAttribute(decl: DataModel | TypeDef | DataField | Enum | EnumField | FunctionDecl | Attribute | AttributeParam, name: string): boolean;
@@ -74,116 +72,6 @@ interface CliPlugin {
74
72
  generate(context: CliGeneratorContext): MaybePromise<void>;
75
73
  }
76
74
 
77
- declare class ExpressionVisitor {
78
- visit(expr: Expression): void;
79
- protected visitLiteral(_e: LiteralExpression): void;
80
- protected visitArray(e: ArrayExpression): void;
81
- protected visitField(_e: FieldExpression): void;
82
- protected visitMember(e: MemberExpression): void;
83
- protected visitBinary(e: BinaryExpression): void;
84
- protected visitUnary(e: UnaryExpression): void;
85
- protected visitCall(e: CallExpression): void;
86
- protected visitThis(_e: ThisExpression): void;
87
- protected visitNull(_e: NullExpression): void;
88
- }
89
-
90
- declare class DefaultOperationNodeVisitor extends OperationNodeVisitor {
91
- protected defaultVisit(node: OperationNode): void;
92
- protected visitSelectQuery(node: SelectQueryNode): void;
93
- protected visitSelection(node: SelectionNode): void;
94
- protected visitColumn(node: ColumnNode): void;
95
- protected visitAlias(node: AliasNode): void;
96
- protected visitTable(node: TableNode): void;
97
- protected visitFrom(node: FromNode): void;
98
- protected visitReference(node: ReferenceNode): void;
99
- protected visitAnd(node: AndNode): void;
100
- protected visitOr(node: OrNode): void;
101
- protected visitValueList(node: ValueListNode): void;
102
- protected visitParens(node: ParensNode): void;
103
- protected visitJoin(node: JoinNode): void;
104
- protected visitRaw(node: RawNode): void;
105
- protected visitWhere(node: WhereNode): void;
106
- protected visitInsertQuery(node: InsertQueryNode): void;
107
- protected visitDeleteQuery(node: DeleteQueryNode): void;
108
- protected visitReturning(node: ReturningNode): void;
109
- protected visitCreateTable(node: CreateTableNode): void;
110
- protected visitAddColumn(node: AddColumnNode): void;
111
- protected visitColumnDefinition(node: ColumnDefinitionNode): void;
112
- protected visitDropTable(node: DropTableNode): void;
113
- protected visitOrderBy(node: OrderByNode): void;
114
- protected visitOrderByItem(node: OrderByItemNode): void;
115
- protected visitGroupBy(node: GroupByNode): void;
116
- protected visitGroupByItem(node: GroupByItemNode): void;
117
- protected visitUpdateQuery(node: UpdateQueryNode): void;
118
- protected visitColumnUpdate(node: ColumnUpdateNode): void;
119
- protected visitLimit(node: LimitNode): void;
120
- protected visitOffset(node: OffsetNode): void;
121
- protected visitOnConflict(node: OnConflictNode): void;
122
- protected visitOnDuplicateKey(node: OnDuplicateKeyNode): void;
123
- protected visitCheckConstraint(node: CheckConstraintNode): void;
124
- protected visitDataType(node: DataTypeNode): void;
125
- protected visitSelectAll(node: SelectAllNode): void;
126
- protected visitIdentifier(node: IdentifierNode): void;
127
- protected visitSchemableIdentifier(node: SchemableIdentifierNode): void;
128
- protected visitValue(node: ValueNode): void;
129
- protected visitPrimitiveValueList(node: PrimitiveValueListNode): void;
130
- protected visitOperator(node: OperatorNode): void;
131
- protected visitCreateIndex(node: CreateIndexNode): void;
132
- protected visitDropIndex(node: DropIndexNode): void;
133
- protected visitList(node: ListNode): void;
134
- protected visitPrimaryKeyConstraint(node: PrimaryKeyConstraintNode): void;
135
- protected visitUniqueConstraint(node: UniqueConstraintNode): void;
136
- protected visitReferences(node: ReferencesNode): void;
137
- protected visitWith(node: WithNode): void;
138
- protected visitCommonTableExpression(node: CommonTableExpressionNode): void;
139
- protected visitCommonTableExpressionName(node: CommonTableExpressionNameNode): void;
140
- protected visitHaving(node: HavingNode): void;
141
- protected visitCreateSchema(node: CreateSchemaNode): void;
142
- protected visitDropSchema(node: DropSchemaNode): void;
143
- protected visitAlterTable(node: AlterTableNode): void;
144
- protected visitDropColumn(node: DropColumnNode): void;
145
- protected visitRenameColumn(node: RenameColumnNode): void;
146
- protected visitAlterColumn(node: AlterColumnNode): void;
147
- protected visitModifyColumn(node: ModifyColumnNode): void;
148
- protected visitAddConstraint(node: AddConstraintNode): void;
149
- protected visitDropConstraint(node: DropConstraintNode): void;
150
- protected visitForeignKeyConstraint(node: ForeignKeyConstraintNode): void;
151
- protected visitCreateView(node: CreateViewNode): void;
152
- protected visitDropView(node: DropViewNode): void;
153
- protected visitGenerated(node: GeneratedNode): void;
154
- protected visitDefaultValue(node: DefaultValueNode): void;
155
- protected visitOn(node: OnNode): void;
156
- protected visitValues(node: ValuesNode): void;
157
- protected visitSelectModifier(node: SelectModifierNode): void;
158
- protected visitCreateType(node: CreateTypeNode): void;
159
- protected visitDropType(node: DropTypeNode): void;
160
- protected visitExplain(node: ExplainNode): void;
161
- protected visitDefaultInsertValue(node: DefaultInsertValueNode): void;
162
- protected visitAggregateFunction(node: AggregateFunctionNode): void;
163
- protected visitOver(node: OverNode): void;
164
- protected visitPartitionBy(node: PartitionByNode): void;
165
- protected visitPartitionByItem(node: PartitionByItemNode): void;
166
- protected visitSetOperation(node: SetOperationNode): void;
167
- protected visitBinaryOperation(node: BinaryOperationNode): void;
168
- protected visitUnaryOperation(node: UnaryOperationNode): void;
169
- protected visitUsing(node: UsingNode): void;
170
- protected visitFunction(node: FunctionNode): void;
171
- protected visitCase(node: CaseNode): void;
172
- protected visitWhen(node: WhenNode): void;
173
- protected visitJSONReference(node: JSONReferenceNode): void;
174
- protected visitJSONPath(node: JSONPathNode): void;
175
- protected visitJSONPathLeg(node: JSONPathLegNode): void;
176
- protected visitJSONOperatorChain(node: JSONOperatorChainNode): void;
177
- protected visitTuple(node: TupleNode): void;
178
- protected visitMergeQuery(node: MergeQueryNode): void;
179
- protected visitMatched(node: MatchedNode): void;
180
- protected visitAddIndex(node: AddIndexNode): void;
181
- protected visitCast(node: CastNode): void;
182
- protected visitFetch(node: FetchNode): void;
183
- protected visitTop(node: TopNode): void;
184
- protected visitOutput(node: OutputNode): void;
185
- }
186
-
187
75
  declare class FunctionCall {
188
76
  func: string;
189
77
  args: FunctionCallArg[];
@@ -211,11 +99,13 @@ declare class PrismaSchemaGenerator {
211
99
  private configInvocationArgToText;
212
100
  private literalToText;
213
101
  private generateGenerator;
102
+ private generateDefaultGenerator;
214
103
  private generateModel;
215
- private isInheritedMapAttribute;
104
+ private getDatasourceField;
105
+ private datasourceHasSchemasSetting;
106
+ private getDefaultPostgresSchemaName;
216
107
  private isPrismaAttribute;
217
108
  private getUnsupportedFieldType;
218
- private getStringLiteral;
219
109
  private generateModelField;
220
110
  private isDefaultWithAuthInvocation;
221
111
  private isInheritedFromDelegate;
@@ -233,15 +123,24 @@ declare class PrismaSchemaGenerator {
233
123
  private truncate;
234
124
  }
235
125
 
126
+ type TsSchemaGeneratorOptions = {
127
+ outDir: string;
128
+ lite?: boolean;
129
+ liteOnly?: boolean;
130
+ importWithFileExtension?: string;
131
+ };
236
132
  declare class TsSchemaGenerator {
237
133
  private usedExpressionUtils;
238
- generate(model: Model, outputDir: string): Promise<void>;
134
+ generate(model: Model, options: TsSchemaGeneratorOptions): Promise<void>;
239
135
  private generateSchema;
240
136
  private generateSchemaStatements;
241
137
  private createExpressionUtilsCall;
242
- private createSchemaObject;
138
+ private createSchemaClass;
139
+ private createAsConst;
243
140
  private createProviderObject;
244
141
  private createModelsObject;
142
+ private getAllDataModels;
143
+ private getAllTypeDefs;
245
144
  private createTypeDefsObject;
246
145
  private createDataModelObject;
247
146
  private getSubModels;
@@ -251,6 +150,7 @@ declare class TsSchemaGenerator {
251
150
  private createDataFieldObject;
252
151
  private isDiscriminatorField;
253
152
  private getDataSourceProvider;
153
+ private getDataSourceDefaultSchema;
254
154
  private getFieldMappedDefault;
255
155
  private getMappedValue;
256
156
  private getMemberAccessChain;
@@ -267,6 +167,7 @@ declare class TsSchemaGenerator {
267
167
  private createEnumObject;
268
168
  private getLiteral;
269
169
  private createLiteralNode;
170
+ private createNumberLiteral;
270
171
  private createProceduresObject;
271
172
  private createProcedureObject;
272
173
  private generateBannerComments;
@@ -288,69 +189,4 @@ declare class TsSchemaGenerator {
288
189
  private generateInputTypes;
289
190
  }
290
191
 
291
- /**
292
- * Options for the generator.
293
- */
294
- interface ZModelCodeOptions {
295
- binaryExprNumberOfSpaces: number;
296
- unaryExprNumberOfSpaces: number;
297
- indent: number;
298
- quote: 'single' | 'double';
299
- }
300
- /**
301
- * Generates ZModel source code from AST.
302
- */
303
- declare class ZModelCodeGenerator {
304
- private readonly options;
305
- constructor(options?: Partial<ZModelCodeOptions>);
306
- /**
307
- * Generates ZModel source code from AST.
308
- */
309
- generate(ast: AstNode): string;
310
- private _generateModel;
311
- private _generateDataSource;
312
- private _generateEnum;
313
- private _generateEnumField;
314
- private _generateGenerator;
315
- private _generateConfigField;
316
- private _generateConfigArrayExpr;
317
- private _generateConfigInvocationExpr;
318
- private _generatePlugin;
319
- private _generatePluginField;
320
- private _generateDataModel;
321
- private _generateDataField;
322
- private fieldType;
323
- private _generateDataModelAttribute;
324
- private _generateDataFieldAttribute;
325
- private attribute;
326
- private _generateAttributeArg;
327
- private _generateObjectExpr;
328
- private objectField;
329
- private _generateArrayExpr;
330
- private _generateLiteralExpr;
331
- private _generateNumberLiteral;
332
- private _generateBooleanLiteral;
333
- private _generateUnaryExpr;
334
- private _generateBinaryExpr;
335
- private _generateReferenceExpr;
336
- private _generateReferenceArg;
337
- private _generateMemberExpr;
338
- private _generateInvocationExpr;
339
- private _generateNullExpr;
340
- private _generateThisExpr;
341
- private _generateAttribute;
342
- private _generateAttributeParam;
343
- private _generateAttributeParamType;
344
- private _generateFunctionDecl;
345
- private _generateFunctionParam;
346
- private _generateFunctionParamType;
347
- private _generateTypeDef;
348
- private argument;
349
- private get binaryExprSpace();
350
- private get unaryExprSpace();
351
- private get indent();
352
- private isParenthesesNeededForBinaryExpr;
353
- private isCollectionPredicateOperator;
354
- }
355
-
356
- export { type CliGeneratorContext, type CliPlugin, DefaultOperationNodeVisitor, ExpressionVisitor, modelUtils as ModelUtils, PrismaSchemaGenerator, TsSchemaGenerator, ZModelCodeGenerator, type ZModelCodeOptions };
192
+ export { type CliGeneratorContext, type CliPlugin, modelUtils as ModelUtils, PrismaSchemaGenerator, TsSchemaGenerator, type TsSchemaGeneratorOptions };