@zenstackhq/sdk 3.0.0-beta.2 → 3.0.0-beta.20

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.cjs CHANGED
@@ -33,8 +33,7 @@ var src_exports = {};
33
33
  __export(src_exports, {
34
34
  ModelUtils: () => model_utils_exports,
35
35
  PrismaSchemaGenerator: () => PrismaSchemaGenerator,
36
- TsSchemaGenerator: () => TsSchemaGenerator,
37
- ZModelCodeGenerator: () => ZModelCodeGenerator
36
+ TsSchemaGenerator: () => TsSchemaGenerator
38
37
  });
39
38
  module.exports = __toCommonJS(src_exports);
40
39
 
@@ -121,7 +120,7 @@ function resolved(ref) {
121
120
  }
122
121
  __name(resolved, "resolved");
123
122
  function getAuthDecl(model) {
124
- let found = model.declarations.find((d) => (0, import_ast.isDataModel)(d) && d.attributes.some((attr) => attr.decl.$refText === "@@auth"));
123
+ let found = model.declarations.find((d) => ((0, import_ast.isDataModel)(d) || (0, import_ast.isTypeDef)(d)) && d.attributes.some((attr) => attr.decl.$refText === "@@auth"));
125
124
  if (!found) {
126
125
  found = model.declarations.find((d) => (0, import_ast.isDataModel)(d) && d.name === "User");
127
126
  }
@@ -136,6 +135,7 @@ var DELEGATE_AUX_RELATION_PREFIX = "delegate_aux";
136
135
 
137
136
  // src/prisma/prisma-schema-generator.ts
138
137
  var import_common_helpers = require("@zenstackhq/common-helpers");
138
+ var import_language = require("@zenstackhq/language");
139
139
  var import_ast2 = require("@zenstackhq/language/ast");
140
140
  var import_utils2 = require("@zenstackhq/language/utils");
141
141
  var import_langium = require("langium");
@@ -619,13 +619,20 @@ var PrismaSchemaGenerator = class {
619
619
  }
620
620
  }
621
621
  const allAttributes = (0, import_utils2.getAllAttributes)(decl);
622
- for (const attr of allAttributes.filter((attr2) => this.isPrismaAttribute(attr2))) {
622
+ for (const attr of allAttributes.filter((attr2) => this.isPrismaAttribute(attr2) && !this.isInheritedMapAttribute(attr2, decl))) {
623
623
  this.generateContainerAttribute(model, attr);
624
624
  }
625
625
  decl.comments.forEach((c) => model.addComment(c));
626
626
  this.generateDelegateRelationForBase(model, decl);
627
627
  this.generateDelegateRelationForConcrete(model, decl);
628
628
  }
629
+ isInheritedMapAttribute(attr, contextModel) {
630
+ if (attr.$container === contextModel) {
631
+ return false;
632
+ }
633
+ const attrName = attr.decl.ref?.name ?? attr.decl.$refText;
634
+ return attrName === "@@map";
635
+ }
629
636
  isPrismaAttribute(attr) {
630
637
  if (!attr.decl.ref) {
631
638
  return false;
@@ -671,7 +678,7 @@ var PrismaSchemaGenerator = class {
671
678
  (0, import_ast2.isTypeDef)(field.type.reference?.ref) ? false : field.type.array
672
679
  );
673
680
  const type = new ModelFieldType(fieldType, isArray, field.type.optional);
674
- const attributes = field.attributes.filter((attr) => this.isPrismaAttribute(attr)).filter((attr) => !this.isDefaultWithPluginInvocation(attr)).filter((attr) => (
681
+ const attributes = field.attributes.filter((attr) => this.isPrismaAttribute(attr)).filter((attr) => !this.isDefaultWithAuthInvocation(attr)).filter((attr) => (
675
682
  // when building physical schema, exclude `@default` for id fields inherited from delegate base
676
683
  !(model_utils_exports.isIdField(field, contextModel) && this.isInheritedFromDelegate(field, contextModel) && attr.decl.$refText === "@default")
677
684
  )).map((attr) => this.makeFieldAttribute(attr));
@@ -681,7 +688,7 @@ var PrismaSchemaGenerator = class {
681
688
  const result = model.addField(field.name, type, attributes, docs, addToFront);
682
689
  return result;
683
690
  }
684
- isDefaultWithPluginInvocation(attr) {
691
+ isDefaultWithAuthInvocation(attr) {
685
692
  if (attr.decl.ref?.name !== "@default") {
686
693
  return false;
687
694
  }
@@ -689,11 +696,7 @@ var PrismaSchemaGenerator = class {
689
696
  if (!expr) {
690
697
  return false;
691
698
  }
692
- return import_langium.AstUtils.streamAst(expr).some((node) => (0, import_ast2.isInvocationExpr)(node) && this.isFromPlugin(node.function.ref));
693
- }
694
- isFromPlugin(node) {
695
- const model = import_langium.AstUtils.getContainerOfType(node, import_ast2.isModel);
696
- return !!model && !!model.$document && model.$document.uri.path.endsWith("plugin.zmodel");
699
+ return import_langium.AstUtils.streamAst(expr).some(import_utils2.isAuthInvocation);
697
700
  }
698
701
  isInheritedFromDelegate(field, contextModel) {
699
702
  return field.$container !== contextModel && model_utils_exports.isDelegateModel(field.$container);
@@ -720,7 +723,7 @@ var PrismaSchemaGenerator = class {
720
723
  }
721
724
  }
722
725
  exprToText(expr) {
723
- return new ZModelCodeGenerator({
726
+ return new import_language.ZModelCodeGenerator({
724
727
  quote: "double"
725
728
  }).generate(expr);
726
729
  }
@@ -821,38 +824,58 @@ var TsSchemaGenerator = class {
821
824
  static {
822
825
  __name(this, "TsSchemaGenerator");
823
826
  }
824
- async generate(model, outputDir) {
825
- import_node_fs.default.mkdirSync(outputDir, {
827
+ usedExpressionUtils = false;
828
+ async generate(model, options) {
829
+ import_node_fs.default.mkdirSync(options.outDir, {
826
830
  recursive: true
827
831
  });
828
- this.generateSchema(model, outputDir);
829
- this.generateModelsAndTypeDefs(model, outputDir);
830
- this.generateInputTypes(model, outputDir);
831
- }
832
- generateSchema(model, outputDir) {
833
- const statements = [];
834
- this.generateSchemaStatements(model, statements);
835
- this.generateBannerComments(statements);
836
- const schemaOutputFile = import_node_path.default.join(outputDir, "schema.ts");
837
- const sourceFile = ts.createSourceFile(schemaOutputFile, "", ts.ScriptTarget.ESNext, false, ts.ScriptKind.TS);
838
- const printer = ts.createPrinter();
839
- const result = printer.printList(ts.ListFormat.MultiLine, ts.factory.createNodeArray(statements), sourceFile);
840
- import_node_fs.default.writeFileSync(schemaOutputFile, result);
832
+ this.usedExpressionUtils = false;
833
+ this.generateSchema(model, options);
834
+ this.generateModelsAndTypeDefs(model, options);
835
+ this.generateInputTypes(model, options);
836
+ }
837
+ generateSchema(model, options) {
838
+ const targets = [];
839
+ if (!options.liteOnly) {
840
+ targets.push({
841
+ lite: false,
842
+ file: "schema.ts"
843
+ });
844
+ }
845
+ if (options.lite || options.liteOnly) {
846
+ targets.push({
847
+ lite: true,
848
+ file: "schema-lite.ts"
849
+ });
850
+ }
851
+ for (const { lite, file } of targets) {
852
+ const statements = [];
853
+ this.generateSchemaStatements(model, statements, lite);
854
+ this.generateBannerComments(statements);
855
+ const schemaOutputFile = import_node_path.default.join(options.outDir, file);
856
+ const sourceFile = ts.createSourceFile(schemaOutputFile, "", ts.ScriptTarget.ESNext, false, ts.ScriptKind.TS);
857
+ const printer = ts.createPrinter();
858
+ const result = printer.printList(ts.ListFormat.MultiLine, ts.factory.createNodeArray(statements), sourceFile);
859
+ import_node_fs.default.writeFileSync(schemaOutputFile, result);
860
+ }
841
861
  }
842
- generateSchemaStatements(model, statements) {
862
+ generateSchemaStatements(model, statements, lite) {
843
863
  const hasComputedFields = model.declarations.some((d) => (0, import_ast3.isDataModel)(d) && d.fields.some((f) => hasAttribute(f, "@computed")));
864
+ const schemaObject = this.createSchemaObject(model, lite);
844
865
  const runtimeImportDecl = ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, void 0, ts.factory.createNamedImports([
845
866
  ts.factory.createImportSpecifier(true, void 0, ts.factory.createIdentifier("SchemaDef")),
846
867
  ...hasComputedFields ? [
847
868
  ts.factory.createImportSpecifier(true, void 0, ts.factory.createIdentifier("OperandExpression"))
848
869
  ] : [],
849
- ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier("ExpressionUtils"))
850
- ])), ts.factory.createStringLiteral("@zenstackhq/runtime/schema"));
870
+ ...this.usedExpressionUtils ? [
871
+ ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier("ExpressionUtils"))
872
+ ] : []
873
+ ])), ts.factory.createStringLiteral("@zenstackhq/orm/schema"));
851
874
  statements.push(runtimeImportDecl);
852
875
  const declaration = ts.factory.createVariableStatement([
853
876
  ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)
854
877
  ], ts.factory.createVariableDeclarationList([
855
- ts.factory.createVariableDeclaration("schema", void 0, void 0, ts.factory.createSatisfiesExpression(ts.factory.createAsExpression(this.createSchemaObject(model), ts.factory.createTypeReferenceNode("const")), ts.factory.createTypeReferenceNode("SchemaDef")))
878
+ ts.factory.createVariableDeclaration("schema", void 0, void 0, ts.factory.createSatisfiesExpression(ts.factory.createAsExpression(schemaObject, ts.factory.createTypeReferenceNode("const")), ts.factory.createTypeReferenceNode("SchemaDef")))
856
879
  ], ts.NodeFlags.Const));
857
880
  statements.push(declaration);
858
881
  const typeDeclaration = ts.factory.createTypeAliasDeclaration([
@@ -860,15 +883,19 @@ var TsSchemaGenerator = class {
860
883
  ], "SchemaType", void 0, ts.factory.createTypeReferenceNode("typeof schema"));
861
884
  statements.push(typeDeclaration);
862
885
  }
863
- createSchemaObject(model) {
886
+ createExpressionUtilsCall(method, args) {
887
+ this.usedExpressionUtils = true;
888
+ return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("ExpressionUtils"), method), void 0, args || []);
889
+ }
890
+ createSchemaObject(model, lite) {
864
891
  const properties = [
865
892
  // provider
866
893
  ts.factory.createPropertyAssignment("provider", this.createProviderObject(model)),
867
894
  // models
868
- ts.factory.createPropertyAssignment("models", this.createModelsObject(model)),
895
+ ts.factory.createPropertyAssignment("models", this.createModelsObject(model, lite)),
869
896
  // typeDefs
870
897
  ...model.declarations.some(import_ast3.isTypeDef) ? [
871
- ts.factory.createPropertyAssignment("typeDefs", this.createTypeDefsObject(model))
898
+ ts.factory.createPropertyAssignment("typeDefs", this.createTypeDefsObject(model, lite))
872
899
  ] : []
873
900
  ];
874
901
  const enums = model.declarations.filter(import_ast3.isEnum);
@@ -892,15 +919,15 @@ var TsSchemaGenerator = class {
892
919
  ts.factory.createPropertyAssignment("type", ts.factory.createStringLiteral(dsProvider.type))
893
920
  ], true);
894
921
  }
895
- createModelsObject(model) {
896
- return ts.factory.createObjectLiteralExpression(model.declarations.filter((d) => (0, import_ast3.isDataModel)(d) && !hasAttribute(d, "@@ignore")).map((dm) => ts.factory.createPropertyAssignment(dm.name, this.createDataModelObject(dm))), true);
922
+ createModelsObject(model, lite) {
923
+ return ts.factory.createObjectLiteralExpression(model.declarations.filter((d) => (0, import_ast3.isDataModel)(d) && !hasAttribute(d, "@@ignore")).map((dm) => ts.factory.createPropertyAssignment(dm.name, this.createDataModelObject(dm, lite))), true);
897
924
  }
898
- createTypeDefsObject(model) {
899
- return ts.factory.createObjectLiteralExpression(model.declarations.filter((d) => (0, import_ast3.isTypeDef)(d)).map((td) => ts.factory.createPropertyAssignment(td.name, this.createTypeDefObject(td))), true);
925
+ createTypeDefsObject(model, lite) {
926
+ return ts.factory.createObjectLiteralExpression(model.declarations.filter((d) => (0, import_ast3.isTypeDef)(d)).map((td) => ts.factory.createPropertyAssignment(td.name, this.createTypeDefObject(td, lite))), true);
900
927
  }
901
- createDataModelObject(dm) {
928
+ createDataModelObject(dm, lite) {
902
929
  const allFields = (0, import_utils3.getAllFields)(dm);
903
- const allAttributes = (0, import_utils3.getAllAttributes)(dm).filter((attr) => {
930
+ const allAttributes = lite ? [] : (0, import_utils3.getAllAttributes)(dm).filter((attr) => {
904
931
  if (attr.decl.$refText === "@@delegate" && attr.$container !== dm) {
905
932
  return false;
906
933
  }
@@ -915,7 +942,7 @@ var TsSchemaGenerator = class {
915
942
  ts.factory.createPropertyAssignment("baseModel", ts.factory.createStringLiteral(dm.baseModel.$refText))
916
943
  ] : [],
917
944
  // fields
918
- ts.factory.createPropertyAssignment("fields", ts.factory.createObjectLiteralExpression(allFields.map((field) => ts.factory.createPropertyAssignment(field.name, this.createDataFieldObject(field, dm))), true)),
945
+ ts.factory.createPropertyAssignment("fields", ts.factory.createObjectLiteralExpression(allFields.map((field) => ts.factory.createPropertyAssignment(field.name, this.createDataFieldObject(field, dm, lite))), true)),
919
946
  // attributes
920
947
  ...allAttributes.length > 0 ? [
921
948
  ts.factory.createPropertyAssignment("attributes", ts.factory.createArrayLiteralExpression(allAttributes.map((attr) => this.createAttributeObject(attr)), true))
@@ -931,6 +958,9 @@ var TsSchemaGenerator = class {
931
958
  // subModels
932
959
  ...subModels.length > 0 ? [
933
960
  ts.factory.createPropertyAssignment("subModels", ts.factory.createArrayLiteralExpression(subModels.map((subModel) => ts.factory.createStringLiteral(subModel))))
961
+ ] : [],
962
+ ...dm.isView ? [
963
+ ts.factory.createPropertyAssignment("isView", ts.factory.createTrue())
934
964
  ] : []
935
965
  ];
936
966
  const computedFields = dm.fields.filter((f) => hasAttribute(f, "@computed"));
@@ -942,14 +972,14 @@ var TsSchemaGenerator = class {
942
972
  getSubModels(dm) {
943
973
  return dm.$container.declarations.filter(import_ast3.isDataModel).filter((d) => d.baseModel?.ref === dm).map((d) => d.name);
944
974
  }
945
- createTypeDefObject(td) {
975
+ createTypeDefObject(td, lite) {
946
976
  const allFields = (0, import_utils3.getAllFields)(td);
947
977
  const allAttributes = (0, import_utils3.getAllAttributes)(td);
948
978
  const fields = [
949
979
  // name
950
980
  ts.factory.createPropertyAssignment("name", ts.factory.createStringLiteral(td.name)),
951
981
  // fields
952
- ts.factory.createPropertyAssignment("fields", ts.factory.createObjectLiteralExpression(allFields.map((field) => ts.factory.createPropertyAssignment(field.name, this.createDataFieldObject(field, void 0))), true)),
982
+ ts.factory.createPropertyAssignment("fields", ts.factory.createObjectLiteralExpression(allFields.map((field) => ts.factory.createPropertyAssignment(field.name, this.createDataFieldObject(field, void 0, lite))), true)),
953
983
  // attributes
954
984
  ...allAttributes.length > 0 ? [
955
985
  ts.factory.createPropertyAssignment("attributes", ts.factory.createArrayLiteralExpression(allAttributes.map((attr) => this.createAttributeObject(attr)), true))
@@ -959,9 +989,9 @@ var TsSchemaGenerator = class {
959
989
  }
960
990
  createComputedFieldsObject(fields) {
961
991
  return ts.factory.createObjectLiteralExpression(fields.map((field) => ts.factory.createMethodDeclaration(void 0, void 0, field.name, void 0, void 0, [
962
- // parameter: `context: { currentModel: string }`
992
+ // parameter: `context: { modelAlias: string }`
963
993
  ts.factory.createParameterDeclaration(void 0, void 0, "_context", void 0, ts.factory.createTypeLiteralNode([
964
- ts.factory.createPropertySignature(void 0, "currentModel", void 0, ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword))
994
+ ts.factory.createPropertySignature(void 0, "modelAlias", void 0, ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword))
965
995
  ]), void 0)
966
996
  ], ts.factory.createTypeReferenceNode("OperandExpression", [
967
997
  ts.factory.createTypeReferenceNode(this.mapFieldTypeToTSType(field.type))
@@ -981,7 +1011,7 @@ var TsSchemaGenerator = class {
981
1011
  }
982
1012
  return result;
983
1013
  }
984
- createDataFieldObject(field, contextModel) {
1014
+ createDataFieldObject(field, contextModel, lite) {
985
1015
  const objectFields = [
986
1016
  // name
987
1017
  ts.factory.createPropertyAssignment("name", ts.factory.createStringLiteral(field.name)),
@@ -1010,22 +1040,24 @@ var TsSchemaGenerator = class {
1010
1040
  if (this.isDiscriminatorField(field)) {
1011
1041
  objectFields.push(ts.factory.createPropertyAssignment("isDiscriminator", ts.factory.createTrue()));
1012
1042
  }
1013
- if (field.attributes.length > 0) {
1043
+ if (!lite && field.attributes.length > 0) {
1014
1044
  objectFields.push(ts.factory.createPropertyAssignment("attributes", ts.factory.createArrayLiteralExpression(field.attributes.map((attr) => this.createAttributeObject(attr)))));
1015
1045
  }
1016
1046
  const defaultValue = this.getFieldMappedDefault(field);
1017
1047
  if (defaultValue !== void 0) {
1018
1048
  if (typeof defaultValue === "object" && !Array.isArray(defaultValue)) {
1019
1049
  if ("call" in defaultValue) {
1020
- objectFields.push(ts.factory.createPropertyAssignment("default", ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.call"), void 0, [
1050
+ objectFields.push(ts.factory.createPropertyAssignment("default", this.createExpressionUtilsCall("call", [
1021
1051
  ts.factory.createStringLiteral(defaultValue.call),
1022
1052
  ...defaultValue.args.length > 0 ? [
1023
- ts.factory.createArrayLiteralExpression(defaultValue.args.map((arg) => this.createLiteralNode(arg)))
1053
+ ts.factory.createArrayLiteralExpression(defaultValue.args.map((arg) => this.createExpressionUtilsCall("literal", [
1054
+ this.createLiteralNode(arg)
1055
+ ])))
1024
1056
  ] : []
1025
1057
  ])));
1026
1058
  } else if ("authMember" in defaultValue) {
1027
- objectFields.push(ts.factory.createPropertyAssignment("default", ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.member"), void 0, [
1028
- ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.call"), void 0, [
1059
+ objectFields.push(ts.factory.createPropertyAssignment("default", this.createExpressionUtilsCall("member", [
1060
+ this.createExpressionUtilsCall("call", [
1029
1061
  ts.factory.createStringLiteral("auth")
1030
1062
  ]),
1031
1063
  ts.factory.createArrayLiteralExpression(defaultValue.authMember.map((m) => ts.factory.createStringLiteral(m)))
@@ -1135,12 +1167,16 @@ var TsSchemaGenerator = class {
1135
1167
  relationFields.push(ts.factory.createPropertyAssignment("name", ts.factory.createStringLiteral(relationName)));
1136
1168
  }
1137
1169
  const relation = getAttribute(field, "@relation");
1170
+ const fkFields = [];
1138
1171
  if (relation) {
1139
1172
  for (const arg of relation.args) {
1140
1173
  const param = arg.$resolvedParam.name;
1141
1174
  if (param === "fields" || param === "references") {
1142
1175
  const fieldNames = this.getReferenceNames(arg.value);
1143
1176
  if (fieldNames) {
1177
+ if (param === "fields") {
1178
+ fkFields.push(...fieldNames);
1179
+ }
1144
1180
  relationFields.push(ts.factory.createPropertyAssignment(param, ts.factory.createArrayLiteralExpression(fieldNames.map((el) => ts.factory.createStringLiteral(el)))));
1145
1181
  }
1146
1182
  }
@@ -1150,6 +1186,15 @@ var TsSchemaGenerator = class {
1150
1186
  }
1151
1187
  }
1152
1188
  }
1189
+ if (fkFields.length > 0) {
1190
+ const allHaveDefault = fkFields.every((fieldName) => {
1191
+ const fieldDef = field.$container.fields.find((f) => f.name === fieldName);
1192
+ return fieldDef && hasAttribute(fieldDef, "@default");
1193
+ });
1194
+ if (allHaveDefault) {
1195
+ relationFields.push(ts.factory.createPropertyAssignment("hasDefault", ts.factory.createTrue()));
1196
+ }
1197
+ }
1153
1198
  return ts.factory.createObjectLiteralExpression(relationFields);
1154
1199
  }
1155
1200
  getReferenceNames(expr) {
@@ -1339,7 +1384,7 @@ var TsSchemaGenerator = class {
1339
1384
  });
1340
1385
  }
1341
1386
  createThisExpression() {
1342
- return ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils._this"), void 0, []);
1387
+ return this.createExpressionUtilsCall("_this");
1343
1388
  }
1344
1389
  createMemberExpression(expr) {
1345
1390
  const members = [];
@@ -1353,32 +1398,32 @@ var TsSchemaGenerator = class {
1353
1398
  this.createExpression(receiver),
1354
1399
  ts.factory.createArrayLiteralExpression(members.map((m) => ts.factory.createStringLiteral(m)))
1355
1400
  ];
1356
- return ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.member"), void 0, args);
1401
+ return this.createExpressionUtilsCall("member", args);
1357
1402
  }
1358
1403
  createNullExpression() {
1359
- return ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils._null"), void 0, []);
1404
+ return this.createExpressionUtilsCall("_null");
1360
1405
  }
1361
1406
  createBinaryExpression(expr) {
1362
- return ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.binary"), void 0, [
1407
+ return this.createExpressionUtilsCall("binary", [
1363
1408
  this.createExpression(expr.left),
1364
1409
  this.createLiteralNode(expr.operator),
1365
1410
  this.createExpression(expr.right)
1366
1411
  ]);
1367
1412
  }
1368
1413
  createUnaryExpression(expr) {
1369
- return ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.unary"), void 0, [
1414
+ return this.createExpressionUtilsCall("unary", [
1370
1415
  this.createLiteralNode(expr.operator),
1371
1416
  this.createExpression(expr.operand)
1372
1417
  ]);
1373
1418
  }
1374
1419
  createArrayExpression(expr) {
1375
- return ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.array"), void 0, [
1420
+ return this.createExpressionUtilsCall("array", [
1376
1421
  ts.factory.createArrayLiteralExpression(expr.items.map((item) => this.createExpression(item)))
1377
1422
  ]);
1378
1423
  }
1379
1424
  createRefExpression(expr) {
1380
1425
  if ((0, import_ast3.isDataField)(expr.target.ref)) {
1381
- return ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.field"), void 0, [
1426
+ return this.createExpressionUtilsCall("field", [
1382
1427
  this.createLiteralNode(expr.target.$refText)
1383
1428
  ]);
1384
1429
  } else if ((0, import_ast3.isEnumField)(expr.target.ref)) {
@@ -1388,7 +1433,7 @@ var TsSchemaGenerator = class {
1388
1433
  }
1389
1434
  }
1390
1435
  createCallExpression(expr) {
1391
- return ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.call"), void 0, [
1436
+ return this.createExpressionUtilsCall("call", [
1392
1437
  ts.factory.createStringLiteral(expr.function.$refText),
1393
1438
  ...expr.args.length > 0 ? [
1394
1439
  ts.factory.createArrayLiteralExpression(expr.args.map((arg) => this.createExpression(arg.value)))
@@ -1396,25 +1441,25 @@ var TsSchemaGenerator = class {
1396
1441
  ]);
1397
1442
  }
1398
1443
  createLiteralExpression(type, value) {
1399
- return (0, import_ts_pattern2.match)(type).with("BooleanLiteral", () => ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.literal"), void 0, [
1444
+ return (0, import_ts_pattern2.match)(type).with("BooleanLiteral", () => this.createExpressionUtilsCall("literal", [
1400
1445
  this.createLiteralNode(value)
1401
- ])).with("NumberLiteral", () => ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.literal"), void 0, [
1446
+ ])).with("NumberLiteral", () => this.createExpressionUtilsCall("literal", [
1402
1447
  ts.factory.createIdentifier(value)
1403
- ])).with("StringLiteral", () => ts.factory.createCallExpression(ts.factory.createIdentifier("ExpressionUtils.literal"), void 0, [
1448
+ ])).with("StringLiteral", () => this.createExpressionUtilsCall("literal", [
1404
1449
  this.createLiteralNode(value)
1405
1450
  ])).otherwise(() => {
1406
1451
  throw new Error(`Unsupported literal type: ${type}`);
1407
1452
  });
1408
1453
  }
1409
- generateModelsAndTypeDefs(model, outputDir) {
1454
+ generateModelsAndTypeDefs(model, options) {
1410
1455
  const statements = [];
1411
- statements.push(this.generateSchemaImport(model, true, true));
1456
+ statements.push(this.generateSchemaImport(model, true, true, !!(options.lite || options.liteOnly)));
1412
1457
  statements.push(ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, void 0, ts.factory.createNamedImports([
1413
1458
  ts.factory.createImportSpecifier(true, void 0, ts.factory.createIdentifier(`ModelResult as $ModelResult`)),
1414
1459
  ...model.declarations.some(import_ast3.isTypeDef) ? [
1415
1460
  ts.factory.createImportSpecifier(true, void 0, ts.factory.createIdentifier(`TypeDefResult as $TypeDefResult`))
1416
1461
  ] : []
1417
- ])), ts.factory.createStringLiteral("@zenstackhq/runtime")));
1462
+ ])), ts.factory.createStringLiteral("@zenstackhq/orm")));
1418
1463
  const dataModels = model.declarations.filter(import_ast3.isDataModel);
1419
1464
  for (const dm of dataModels) {
1420
1465
  let modelType = ts.factory.createTypeAliasDeclaration([
@@ -1461,13 +1506,13 @@ var TsSchemaGenerator = class {
1461
1506
  statements.push(typeAlias);
1462
1507
  }
1463
1508
  this.generateBannerComments(statements);
1464
- const outputFile = import_node_path.default.join(outputDir, "models.ts");
1509
+ const outputFile = import_node_path.default.join(options.outDir, "models.ts");
1465
1510
  const sourceFile = ts.createSourceFile(outputFile, "", ts.ScriptTarget.ESNext, false, ts.ScriptKind.TS);
1466
1511
  const printer = ts.createPrinter();
1467
1512
  const result = printer.printList(ts.ListFormat.MultiLine, ts.factory.createNodeArray(statements), sourceFile);
1468
1513
  import_node_fs.default.writeFileSync(outputFile, result);
1469
1514
  }
1470
- generateSchemaImport(model, schemaObject, schemaType) {
1515
+ generateSchemaImport(model, schemaObject, schemaType, useLite) {
1471
1516
  const importSpecifiers = [];
1472
1517
  if (schemaObject) {
1473
1518
  if (model.declarations.some(import_ast3.isEnum)) {
@@ -1477,17 +1522,17 @@ var TsSchemaGenerator = class {
1477
1522
  if (schemaType) {
1478
1523
  importSpecifiers.push(ts.factory.createImportSpecifier(true, ts.factory.createIdentifier("SchemaType"), ts.factory.createIdentifier("$Schema")));
1479
1524
  }
1480
- return ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, void 0, ts.factory.createNamedImports(importSpecifiers)), ts.factory.createStringLiteral("./schema"));
1525
+ return ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, void 0, ts.factory.createNamedImports(importSpecifiers)), ts.factory.createStringLiteral(useLite ? "./schema-lite" : "./schema"));
1481
1526
  }
1482
1527
  generateDocs(tsDecl, decl) {
1483
1528
  return ts.addSyntheticLeadingComment(tsDecl, ts.SyntaxKind.MultiLineCommentTrivia, `*
1484
1529
  * ${decl.comments.map((c) => c.replace(/^\s*\/*\s*/, "")).join("\n * ")}
1485
1530
  `, true);
1486
1531
  }
1487
- generateInputTypes(model, outputDir) {
1532
+ generateInputTypes(model, options) {
1488
1533
  const dataModels = model.declarations.filter(import_ast3.isDataModel);
1489
1534
  const statements = [];
1490
- statements.push(this.generateSchemaImport(model, false, true));
1535
+ statements.push(this.generateSchemaImport(model, false, true, !!(options.lite || options.liteOnly)));
1491
1536
  const inputTypes = [
1492
1537
  "FindManyArgs",
1493
1538
  "FindUniqueArgs",
@@ -1514,11 +1559,11 @@ var TsSchemaGenerator = class {
1514
1559
  IncludeInput: "Include",
1515
1560
  OmitInput: "Omit"
1516
1561
  };
1517
- statements.push(ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(true, void 0, ts.factory.createNamedImports(inputTypes.map((inputType) => ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier(`${inputType} as $${inputType}`))))), ts.factory.createStringLiteral("@zenstackhq/runtime")));
1562
+ statements.push(ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(true, void 0, ts.factory.createNamedImports(inputTypes.map((inputType) => ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier(`${inputType} as $${inputType}`))))), ts.factory.createStringLiteral("@zenstackhq/orm")));
1518
1563
  statements.push(ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(true, void 0, ts.factory.createNamedImports([
1519
1564
  ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier("SimplifiedModelResult as $SimplifiedModelResult")),
1520
1565
  ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier("SelectIncludeOmit as $SelectIncludeOmit"))
1521
- ])), ts.factory.createStringLiteral("@zenstackhq/runtime")));
1566
+ ])), ts.factory.createStringLiteral("@zenstackhq/orm")));
1522
1567
  for (const dm of dataModels) {
1523
1568
  for (const inputType of inputTypes) {
1524
1569
  const exportName = inputTypeNameFixes[inputType] ? `${dm.name}${inputTypeNameFixes[inputType]}` : `${dm.name}${inputType}`;
@@ -1544,518 +1589,17 @@ var TsSchemaGenerator = class {
1544
1589
  ])));
1545
1590
  }
1546
1591
  this.generateBannerComments(statements);
1547
- const outputFile = import_node_path.default.join(outputDir, "input.ts");
1592
+ const outputFile = import_node_path.default.join(options.outDir, "input.ts");
1548
1593
  const sourceFile = ts.createSourceFile(outputFile, "", ts.ScriptTarget.ESNext, false, ts.ScriptKind.TS);
1549
1594
  const printer = ts.createPrinter();
1550
1595
  const result = printer.printList(ts.ListFormat.MultiLine, ts.factory.createNodeArray(statements), sourceFile);
1551
1596
  import_node_fs.default.writeFileSync(outputFile, result);
1552
1597
  }
1553
1598
  };
1554
-
1555
- // src/zmodel-code-generator.ts
1556
- var import_ast4 = require("@zenstackhq/language/ast");
1557
- function _ts_decorate(decorators, target, key, desc) {
1558
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1559
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1560
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1561
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1562
- }
1563
- __name(_ts_decorate, "_ts_decorate");
1564
- function _ts_metadata(k, v) {
1565
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1566
- }
1567
- __name(_ts_metadata, "_ts_metadata");
1568
- var generationHandlers = /* @__PURE__ */ new Map();
1569
- function gen(name) {
1570
- return function(_target, _propertyKey, descriptor) {
1571
- if (!generationHandlers.get(name)) {
1572
- generationHandlers.set(name, descriptor);
1573
- }
1574
- return descriptor;
1575
- };
1576
- }
1577
- __name(gen, "gen");
1578
- var ZModelCodeGenerator = class {
1579
- static {
1580
- __name(this, "ZModelCodeGenerator");
1581
- }
1582
- options;
1583
- constructor(options) {
1584
- this.options = {
1585
- binaryExprNumberOfSpaces: options?.binaryExprNumberOfSpaces ?? 1,
1586
- unaryExprNumberOfSpaces: options?.unaryExprNumberOfSpaces ?? 0,
1587
- indent: options?.indent ?? 4,
1588
- quote: options?.quote ?? "single"
1589
- };
1590
- }
1591
- /**
1592
- * Generates ZModel source code from AST.
1593
- */
1594
- generate(ast) {
1595
- const handler = generationHandlers.get(ast.$type);
1596
- if (!handler) {
1597
- throw new Error(`No generation handler found for ${ast.$type}`);
1598
- }
1599
- return handler.value.call(this, ast);
1600
- }
1601
- _generateModel(ast) {
1602
- return ast.declarations.map((d) => this.generate(d)).join("\n\n");
1603
- }
1604
- _generateDataSource(ast) {
1605
- return `datasource ${ast.name} {
1606
- ${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}
1607
- }`;
1608
- }
1609
- _generateEnum(ast) {
1610
- return `enum ${ast.name} {
1611
- ${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}
1612
- }`;
1613
- }
1614
- _generateEnumField(ast) {
1615
- return `${ast.name}${ast.attributes.length > 0 ? " " + ast.attributes.map((x) => this.generate(x)).join(" ") : ""}`;
1616
- }
1617
- _generateGenerator(ast) {
1618
- return `generator ${ast.name} {
1619
- ${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}
1620
- }`;
1621
- }
1622
- _generateConfigField(ast) {
1623
- return `${ast.name} = ${this.generate(ast.value)}`;
1624
- }
1625
- _generateConfigArrayExpr(ast) {
1626
- return `[${ast.items.map((x) => this.generate(x)).join(", ")}]`;
1627
- }
1628
- _generateConfigInvocationExpr(ast) {
1629
- if (ast.args.length === 0) {
1630
- return ast.name;
1631
- } else {
1632
- return `${ast.name}(${ast.args.map((x) => (x.name ? x.name + ": " : "") + this.generate(x.value)).join(", ")})`;
1633
- }
1634
- }
1635
- _generatePlugin(ast) {
1636
- return `plugin ${ast.name} {
1637
- ${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}
1638
- }`;
1639
- }
1640
- _generatePluginField(ast) {
1641
- return `${ast.name} = ${this.generate(ast.value)}`;
1642
- }
1643
- _generateDataModel(ast) {
1644
- return `${ast.isView ? "view" : "model"} ${ast.name}${ast.mixins.length > 0 ? " mixes " + ast.mixins.map((x) => x.ref?.name).join(", ") : ""} {
1645
- ${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}${ast.attributes.length > 0 ? "\n\n" + ast.attributes.map((x) => this.indent + this.generate(x)).join("\n") : ""}
1646
- }`;
1647
- }
1648
- _generateDataField(ast) {
1649
- return `${ast.name} ${this.fieldType(ast.type)}${ast.attributes.length > 0 ? " " + ast.attributes.map((x) => this.generate(x)).join(" ") : ""}`;
1650
- }
1651
- fieldType(type) {
1652
- const baseType = type.type ? type.type : type.$type == "DataFieldType" && type.unsupported ? "Unsupported(" + this.generate(type.unsupported.value) + ")" : type.reference?.$refText;
1653
- return `${baseType}${type.array ? "[]" : ""}${type.optional ? "?" : ""}`;
1654
- }
1655
- _generateDataModelAttribute(ast) {
1656
- return this.attribute(ast);
1657
- }
1658
- _generateDataFieldAttribute(ast) {
1659
- return this.attribute(ast);
1660
- }
1661
- attribute(ast) {
1662
- const args = ast.args.length ? `(${ast.args.map((x) => this.generate(x)).join(", ")})` : "";
1663
- return `${resolved(ast.decl).name}${args}`;
1664
- }
1665
- _generateAttributeArg(ast) {
1666
- if (ast.name) {
1667
- return `${ast.name}: ${this.generate(ast.value)}`;
1668
- } else {
1669
- return this.generate(ast.value);
1670
- }
1671
- }
1672
- _generateObjectExpr(ast) {
1673
- return `{ ${ast.fields.map((field) => this.objectField(field)).join(", ")} }`;
1674
- }
1675
- objectField(field) {
1676
- return `${field.name}: ${this.generate(field.value)}`;
1677
- }
1678
- _generateArrayExpr(ast) {
1679
- return `[${ast.items.map((item) => this.generate(item)).join(", ")}]`;
1680
- }
1681
- _generateLiteralExpr(ast) {
1682
- return this.options.quote === "single" ? `'${ast.value}'` : `"${ast.value}"`;
1683
- }
1684
- _generateNumberLiteral(ast) {
1685
- return ast.value.toString();
1686
- }
1687
- _generateBooleanLiteral(ast) {
1688
- return ast.value.toString();
1689
- }
1690
- _generateUnaryExpr(ast) {
1691
- return `${ast.operator}${this.unaryExprSpace}${this.generate(ast.operand)}`;
1692
- }
1693
- _generateBinaryExpr(ast) {
1694
- const operator = ast.operator;
1695
- const isCollectionPredicate = this.isCollectionPredicateOperator(operator);
1696
- const rightExpr = this.generate(ast.right);
1697
- const { left: isLeftParenthesis, right: isRightParenthesis } = this.isParenthesesNeededForBinaryExpr(ast);
1698
- return `${isLeftParenthesis ? "(" : ""}${this.generate(ast.left)}${isLeftParenthesis ? ")" : ""}${isCollectionPredicate ? "" : this.binaryExprSpace}${operator}${isCollectionPredicate ? "" : this.binaryExprSpace}${isRightParenthesis ? "(" : ""}${isCollectionPredicate ? `[${rightExpr}]` : rightExpr}${isRightParenthesis ? ")" : ""}`;
1699
- }
1700
- _generateReferenceExpr(ast) {
1701
- const args = ast.args.length ? `(${ast.args.map((x) => this.generate(x)).join(", ")})` : "";
1702
- return `${ast.target.ref?.name}${args}`;
1703
- }
1704
- _generateReferenceArg(ast) {
1705
- return `${ast.name}:${this.generate(ast.value)}`;
1706
- }
1707
- _generateMemberExpr(ast) {
1708
- return `${this.generate(ast.operand)}.${ast.member.ref?.name}`;
1709
- }
1710
- _generateInvocationExpr(ast) {
1711
- return `${ast.function.ref?.name}(${ast.args.map((x) => this.argument(x)).join(", ")})`;
1712
- }
1713
- _generateNullExpr() {
1714
- return "null";
1715
- }
1716
- _generateThisExpr() {
1717
- return "this";
1718
- }
1719
- _generateAttribute(ast) {
1720
- return `attribute ${ast.name}(${ast.params.map((x) => this.generate(x)).join(", ")})`;
1721
- }
1722
- _generateAttributeParam(ast) {
1723
- return `${ast.default ? "_ " : ""}${ast.name}: ${this.generate(ast.type)}`;
1724
- }
1725
- _generateAttributeParamType(ast) {
1726
- return `${ast.type ?? ast.reference?.$refText}${ast.array ? "[]" : ""}${ast.optional ? "?" : ""}`;
1727
- }
1728
- _generateFunctionDecl(ast) {
1729
- return `function ${ast.name}(${ast.params.map((x) => this.generate(x)).join(", ")}) ${ast.returnType ? ": " + this.generate(ast.returnType) : ""} {}`;
1730
- }
1731
- _generateFunctionParam(ast) {
1732
- return `${ast.name}: ${this.generate(ast.type)}`;
1733
- }
1734
- _generateFunctionParamType(ast) {
1735
- return `${ast.type ?? ast.reference?.$refText}${ast.array ? "[]" : ""}`;
1736
- }
1737
- _generateTypeDef(ast) {
1738
- return `type ${ast.name} {
1739
- ${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}${ast.attributes.length > 0 ? "\n\n" + ast.attributes.map((x) => this.indent + this.generate(x)).join("\n") : ""}
1740
- }`;
1741
- }
1742
- argument(ast) {
1743
- return this.generate(ast.value);
1744
- }
1745
- get binaryExprSpace() {
1746
- return " ".repeat(this.options.binaryExprNumberOfSpaces);
1747
- }
1748
- get unaryExprSpace() {
1749
- return " ".repeat(this.options.unaryExprNumberOfSpaces);
1750
- }
1751
- get indent() {
1752
- return " ".repeat(this.options.indent);
1753
- }
1754
- isParenthesesNeededForBinaryExpr(ast) {
1755
- const result = {
1756
- left: false,
1757
- right: false
1758
- };
1759
- const operator = ast.operator;
1760
- const isCollectionPredicate = this.isCollectionPredicateOperator(operator);
1761
- const currentPriority = import_ast4.BinaryExprOperatorPriority[operator];
1762
- if (ast.left.$type === import_ast4.BinaryExpr && import_ast4.BinaryExprOperatorPriority[ast.left["operator"]] < currentPriority) {
1763
- result.left = true;
1764
- }
1765
- if (!isCollectionPredicate && ast.right.$type === import_ast4.BinaryExpr && import_ast4.BinaryExprOperatorPriority[ast.right["operator"]] <= currentPriority) {
1766
- result.right = true;
1767
- }
1768
- return result;
1769
- }
1770
- isCollectionPredicateOperator(op) {
1771
- return [
1772
- "?",
1773
- "!",
1774
- "^"
1775
- ].includes(op);
1776
- }
1777
- };
1778
- _ts_decorate([
1779
- gen(import_ast4.Model),
1780
- _ts_metadata("design:type", Function),
1781
- _ts_metadata("design:paramtypes", [
1782
- typeof import_ast4.Model === "undefined" ? Object : import_ast4.Model
1783
- ]),
1784
- _ts_metadata("design:returntype", void 0)
1785
- ], ZModelCodeGenerator.prototype, "_generateModel", null);
1786
- _ts_decorate([
1787
- gen(import_ast4.DataSource),
1788
- _ts_metadata("design:type", Function),
1789
- _ts_metadata("design:paramtypes", [
1790
- typeof import_ast4.DataSource === "undefined" ? Object : import_ast4.DataSource
1791
- ]),
1792
- _ts_metadata("design:returntype", void 0)
1793
- ], ZModelCodeGenerator.prototype, "_generateDataSource", null);
1794
- _ts_decorate([
1795
- gen(import_ast4.Enum),
1796
- _ts_metadata("design:type", Function),
1797
- _ts_metadata("design:paramtypes", [
1798
- typeof import_ast4.Enum === "undefined" ? Object : import_ast4.Enum
1799
- ]),
1800
- _ts_metadata("design:returntype", void 0)
1801
- ], ZModelCodeGenerator.prototype, "_generateEnum", null);
1802
- _ts_decorate([
1803
- gen(import_ast4.EnumField),
1804
- _ts_metadata("design:type", Function),
1805
- _ts_metadata("design:paramtypes", [
1806
- typeof import_ast4.EnumField === "undefined" ? Object : import_ast4.EnumField
1807
- ]),
1808
- _ts_metadata("design:returntype", void 0)
1809
- ], ZModelCodeGenerator.prototype, "_generateEnumField", null);
1810
- _ts_decorate([
1811
- gen(import_ast4.GeneratorDecl),
1812
- _ts_metadata("design:type", Function),
1813
- _ts_metadata("design:paramtypes", [
1814
- typeof import_ast4.GeneratorDecl === "undefined" ? Object : import_ast4.GeneratorDecl
1815
- ]),
1816
- _ts_metadata("design:returntype", void 0)
1817
- ], ZModelCodeGenerator.prototype, "_generateGenerator", null);
1818
- _ts_decorate([
1819
- gen(import_ast4.ConfigField),
1820
- _ts_metadata("design:type", Function),
1821
- _ts_metadata("design:paramtypes", [
1822
- typeof import_ast4.ConfigField === "undefined" ? Object : import_ast4.ConfigField
1823
- ]),
1824
- _ts_metadata("design:returntype", void 0)
1825
- ], ZModelCodeGenerator.prototype, "_generateConfigField", null);
1826
- _ts_decorate([
1827
- gen(import_ast4.ConfigArrayExpr),
1828
- _ts_metadata("design:type", Function),
1829
- _ts_metadata("design:paramtypes", [
1830
- typeof import_ast4.ConfigArrayExpr === "undefined" ? Object : import_ast4.ConfigArrayExpr
1831
- ]),
1832
- _ts_metadata("design:returntype", void 0)
1833
- ], ZModelCodeGenerator.prototype, "_generateConfigArrayExpr", null);
1834
- _ts_decorate([
1835
- gen(import_ast4.ConfigInvocationExpr),
1836
- _ts_metadata("design:type", Function),
1837
- _ts_metadata("design:paramtypes", [
1838
- typeof import_ast4.ConfigInvocationExpr === "undefined" ? Object : import_ast4.ConfigInvocationExpr
1839
- ]),
1840
- _ts_metadata("design:returntype", void 0)
1841
- ], ZModelCodeGenerator.prototype, "_generateConfigInvocationExpr", null);
1842
- _ts_decorate([
1843
- gen(import_ast4.Plugin),
1844
- _ts_metadata("design:type", Function),
1845
- _ts_metadata("design:paramtypes", [
1846
- typeof import_ast4.Plugin === "undefined" ? Object : import_ast4.Plugin
1847
- ]),
1848
- _ts_metadata("design:returntype", void 0)
1849
- ], ZModelCodeGenerator.prototype, "_generatePlugin", null);
1850
- _ts_decorate([
1851
- gen(import_ast4.PluginField),
1852
- _ts_metadata("design:type", Function),
1853
- _ts_metadata("design:paramtypes", [
1854
- typeof import_ast4.PluginField === "undefined" ? Object : import_ast4.PluginField
1855
- ]),
1856
- _ts_metadata("design:returntype", void 0)
1857
- ], ZModelCodeGenerator.prototype, "_generatePluginField", null);
1858
- _ts_decorate([
1859
- gen(import_ast4.DataModel),
1860
- _ts_metadata("design:type", Function),
1861
- _ts_metadata("design:paramtypes", [
1862
- typeof import_ast4.DataModel === "undefined" ? Object : import_ast4.DataModel
1863
- ]),
1864
- _ts_metadata("design:returntype", void 0)
1865
- ], ZModelCodeGenerator.prototype, "_generateDataModel", null);
1866
- _ts_decorate([
1867
- gen(import_ast4.DataField),
1868
- _ts_metadata("design:type", Function),
1869
- _ts_metadata("design:paramtypes", [
1870
- typeof import_ast4.DataField === "undefined" ? Object : import_ast4.DataField
1871
- ]),
1872
- _ts_metadata("design:returntype", void 0)
1873
- ], ZModelCodeGenerator.prototype, "_generateDataField", null);
1874
- _ts_decorate([
1875
- gen(import_ast4.DataModelAttribute),
1876
- _ts_metadata("design:type", Function),
1877
- _ts_metadata("design:paramtypes", [
1878
- typeof import_ast4.DataModelAttribute === "undefined" ? Object : import_ast4.DataModelAttribute
1879
- ]),
1880
- _ts_metadata("design:returntype", void 0)
1881
- ], ZModelCodeGenerator.prototype, "_generateDataModelAttribute", null);
1882
- _ts_decorate([
1883
- gen(import_ast4.DataFieldAttribute),
1884
- _ts_metadata("design:type", Function),
1885
- _ts_metadata("design:paramtypes", [
1886
- typeof import_ast4.DataFieldAttribute === "undefined" ? Object : import_ast4.DataFieldAttribute
1887
- ]),
1888
- _ts_metadata("design:returntype", void 0)
1889
- ], ZModelCodeGenerator.prototype, "_generateDataFieldAttribute", null);
1890
- _ts_decorate([
1891
- gen(import_ast4.AttributeArg),
1892
- _ts_metadata("design:type", Function),
1893
- _ts_metadata("design:paramtypes", [
1894
- typeof import_ast4.AttributeArg === "undefined" ? Object : import_ast4.AttributeArg
1895
- ]),
1896
- _ts_metadata("design:returntype", void 0)
1897
- ], ZModelCodeGenerator.prototype, "_generateAttributeArg", null);
1898
- _ts_decorate([
1899
- gen(import_ast4.ObjectExpr),
1900
- _ts_metadata("design:type", Function),
1901
- _ts_metadata("design:paramtypes", [
1902
- typeof import_ast4.ObjectExpr === "undefined" ? Object : import_ast4.ObjectExpr
1903
- ]),
1904
- _ts_metadata("design:returntype", void 0)
1905
- ], ZModelCodeGenerator.prototype, "_generateObjectExpr", null);
1906
- _ts_decorate([
1907
- gen(import_ast4.ArrayExpr),
1908
- _ts_metadata("design:type", Function),
1909
- _ts_metadata("design:paramtypes", [
1910
- typeof import_ast4.ArrayExpr === "undefined" ? Object : import_ast4.ArrayExpr
1911
- ]),
1912
- _ts_metadata("design:returntype", void 0)
1913
- ], ZModelCodeGenerator.prototype, "_generateArrayExpr", null);
1914
- _ts_decorate([
1915
- gen(import_ast4.StringLiteral),
1916
- _ts_metadata("design:type", Function),
1917
- _ts_metadata("design:paramtypes", [
1918
- typeof import_ast4.LiteralExpr === "undefined" ? Object : import_ast4.LiteralExpr
1919
- ]),
1920
- _ts_metadata("design:returntype", void 0)
1921
- ], ZModelCodeGenerator.prototype, "_generateLiteralExpr", null);
1922
- _ts_decorate([
1923
- gen(import_ast4.NumberLiteral),
1924
- _ts_metadata("design:type", Function),
1925
- _ts_metadata("design:paramtypes", [
1926
- typeof import_ast4.NumberLiteral === "undefined" ? Object : import_ast4.NumberLiteral
1927
- ]),
1928
- _ts_metadata("design:returntype", void 0)
1929
- ], ZModelCodeGenerator.prototype, "_generateNumberLiteral", null);
1930
- _ts_decorate([
1931
- gen(import_ast4.BooleanLiteral),
1932
- _ts_metadata("design:type", Function),
1933
- _ts_metadata("design:paramtypes", [
1934
- typeof import_ast4.BooleanLiteral === "undefined" ? Object : import_ast4.BooleanLiteral
1935
- ]),
1936
- _ts_metadata("design:returntype", void 0)
1937
- ], ZModelCodeGenerator.prototype, "_generateBooleanLiteral", null);
1938
- _ts_decorate([
1939
- gen(import_ast4.UnaryExpr),
1940
- _ts_metadata("design:type", Function),
1941
- _ts_metadata("design:paramtypes", [
1942
- typeof import_ast4.UnaryExpr === "undefined" ? Object : import_ast4.UnaryExpr
1943
- ]),
1944
- _ts_metadata("design:returntype", void 0)
1945
- ], ZModelCodeGenerator.prototype, "_generateUnaryExpr", null);
1946
- _ts_decorate([
1947
- gen(import_ast4.BinaryExpr),
1948
- _ts_metadata("design:type", Function),
1949
- _ts_metadata("design:paramtypes", [
1950
- typeof import_ast4.BinaryExpr === "undefined" ? Object : import_ast4.BinaryExpr
1951
- ]),
1952
- _ts_metadata("design:returntype", void 0)
1953
- ], ZModelCodeGenerator.prototype, "_generateBinaryExpr", null);
1954
- _ts_decorate([
1955
- gen(import_ast4.ReferenceExpr),
1956
- _ts_metadata("design:type", Function),
1957
- _ts_metadata("design:paramtypes", [
1958
- typeof import_ast4.ReferenceExpr === "undefined" ? Object : import_ast4.ReferenceExpr
1959
- ]),
1960
- _ts_metadata("design:returntype", void 0)
1961
- ], ZModelCodeGenerator.prototype, "_generateReferenceExpr", null);
1962
- _ts_decorate([
1963
- gen(import_ast4.ReferenceArg),
1964
- _ts_metadata("design:type", Function),
1965
- _ts_metadata("design:paramtypes", [
1966
- typeof import_ast4.ReferenceArg === "undefined" ? Object : import_ast4.ReferenceArg
1967
- ]),
1968
- _ts_metadata("design:returntype", void 0)
1969
- ], ZModelCodeGenerator.prototype, "_generateReferenceArg", null);
1970
- _ts_decorate([
1971
- gen(import_ast4.MemberAccessExpr),
1972
- _ts_metadata("design:type", Function),
1973
- _ts_metadata("design:paramtypes", [
1974
- typeof import_ast4.MemberAccessExpr === "undefined" ? Object : import_ast4.MemberAccessExpr
1975
- ]),
1976
- _ts_metadata("design:returntype", void 0)
1977
- ], ZModelCodeGenerator.prototype, "_generateMemberExpr", null);
1978
- _ts_decorate([
1979
- gen(import_ast4.InvocationExpr),
1980
- _ts_metadata("design:type", Function),
1981
- _ts_metadata("design:paramtypes", [
1982
- typeof import_ast4.InvocationExpr === "undefined" ? Object : import_ast4.InvocationExpr
1983
- ]),
1984
- _ts_metadata("design:returntype", void 0)
1985
- ], ZModelCodeGenerator.prototype, "_generateInvocationExpr", null);
1986
- _ts_decorate([
1987
- gen(import_ast4.NullExpr),
1988
- _ts_metadata("design:type", Function),
1989
- _ts_metadata("design:paramtypes", []),
1990
- _ts_metadata("design:returntype", void 0)
1991
- ], ZModelCodeGenerator.prototype, "_generateNullExpr", null);
1992
- _ts_decorate([
1993
- gen(import_ast4.ThisExpr),
1994
- _ts_metadata("design:type", Function),
1995
- _ts_metadata("design:paramtypes", []),
1996
- _ts_metadata("design:returntype", void 0)
1997
- ], ZModelCodeGenerator.prototype, "_generateThisExpr", null);
1998
- _ts_decorate([
1999
- gen(import_ast4.Attribute),
2000
- _ts_metadata("design:type", Function),
2001
- _ts_metadata("design:paramtypes", [
2002
- typeof import_ast4.Attribute === "undefined" ? Object : import_ast4.Attribute
2003
- ]),
2004
- _ts_metadata("design:returntype", void 0)
2005
- ], ZModelCodeGenerator.prototype, "_generateAttribute", null);
2006
- _ts_decorate([
2007
- gen(import_ast4.AttributeParam),
2008
- _ts_metadata("design:type", Function),
2009
- _ts_metadata("design:paramtypes", [
2010
- typeof import_ast4.AttributeParam === "undefined" ? Object : import_ast4.AttributeParam
2011
- ]),
2012
- _ts_metadata("design:returntype", void 0)
2013
- ], ZModelCodeGenerator.prototype, "_generateAttributeParam", null);
2014
- _ts_decorate([
2015
- gen(import_ast4.AttributeParamType),
2016
- _ts_metadata("design:type", Function),
2017
- _ts_metadata("design:paramtypes", [
2018
- typeof import_ast4.AttributeParamType === "undefined" ? Object : import_ast4.AttributeParamType
2019
- ]),
2020
- _ts_metadata("design:returntype", void 0)
2021
- ], ZModelCodeGenerator.prototype, "_generateAttributeParamType", null);
2022
- _ts_decorate([
2023
- gen(import_ast4.FunctionDecl),
2024
- _ts_metadata("design:type", Function),
2025
- _ts_metadata("design:paramtypes", [
2026
- typeof import_ast4.FunctionDecl === "undefined" ? Object : import_ast4.FunctionDecl
2027
- ]),
2028
- _ts_metadata("design:returntype", void 0)
2029
- ], ZModelCodeGenerator.prototype, "_generateFunctionDecl", null);
2030
- _ts_decorate([
2031
- gen(import_ast4.FunctionParam),
2032
- _ts_metadata("design:type", Function),
2033
- _ts_metadata("design:paramtypes", [
2034
- typeof import_ast4.FunctionParam === "undefined" ? Object : import_ast4.FunctionParam
2035
- ]),
2036
- _ts_metadata("design:returntype", void 0)
2037
- ], ZModelCodeGenerator.prototype, "_generateFunctionParam", null);
2038
- _ts_decorate([
2039
- gen(import_ast4.FunctionParamType),
2040
- _ts_metadata("design:type", Function),
2041
- _ts_metadata("design:paramtypes", [
2042
- typeof import_ast4.FunctionParamType === "undefined" ? Object : import_ast4.FunctionParamType
2043
- ]),
2044
- _ts_metadata("design:returntype", void 0)
2045
- ], ZModelCodeGenerator.prototype, "_generateFunctionParamType", null);
2046
- _ts_decorate([
2047
- gen(import_ast4.TypeDef),
2048
- _ts_metadata("design:type", Function),
2049
- _ts_metadata("design:paramtypes", [
2050
- typeof import_ast4.TypeDef === "undefined" ? Object : import_ast4.TypeDef
2051
- ]),
2052
- _ts_metadata("design:returntype", void 0)
2053
- ], ZModelCodeGenerator.prototype, "_generateTypeDef", null);
2054
1599
  // Annotate the CommonJS export names for ESM import in node:
2055
1600
  0 && (module.exports = {
2056
1601
  ModelUtils,
2057
1602
  PrismaSchemaGenerator,
2058
- TsSchemaGenerator,
2059
- ZModelCodeGenerator
1603
+ TsSchemaGenerator
2060
1604
  });
2061
1605
  //# sourceMappingURL=index.cjs.map