@postxl/generator 0.73.2 → 0.73.4

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.
@@ -34,7 +34,6 @@ const attributes_1 = require("./attributes");
34
34
  */
35
35
  function parsePrismaSchema({ datamodel: { enums: enumsRaw, models: modelsRaw }, config, }) {
36
36
  ensurePXLSystemModelsExist(modelsRaw);
37
- ensureConsistency({ models: modelsRaw, enums: enumsRaw });
38
37
  // NOTE: We preprocess models and enums so that we can populate relationships.
39
38
  const models = modelsRaw.map((dmmfModel) => parseModelCore({ dmmfModel, config }));
40
39
  const enums = enumsRaw.map((dmmfEnum) => parseEnum({ dmmfEnum, config }));
@@ -73,56 +72,6 @@ function ensurePXLSystemModelsExist(models) {
73
72
  }
74
73
  }
75
74
  }
76
- /**
77
- * Validates:
78
- * - That there are no duplicate model names
79
- * - That model names are singular
80
- * - That model attributes are valid
81
- * - That field attributes are valid
82
- * - That enum attributes are valid
83
- */
84
- function ensureConsistency({ models, enums }) {
85
- const errors = [];
86
- const modelNames = models.map((m) => m.name);
87
- const duplicateModelName = modelNames.find((name, i) => modelNames.indexOf(name) !== i);
88
- if (duplicateModelName) {
89
- errors.push(`Model ${duplicateModelName} is defined more than once.`);
90
- }
91
- for (const model of models) {
92
- if ((0, string_1.isPlural)(model.name)) {
93
- errors.push(`Model ${(0, logger_1.highlight)(model.name)} is plural. Please use singular names for models.`);
94
- }
95
- try {
96
- (0, attributes_1.getModelAttributes)(model);
97
- }
98
- catch (e) {
99
- errors.push(`Model ${(0, logger_1.highlight)(model.name)} has invalid model attributes: ${(0, error_1.extractError)(e)}`);
100
- }
101
- }
102
- for (const model of models) {
103
- for (const field of model.fields) {
104
- try {
105
- (0, attributes_1.getFieldAttributes)(field);
106
- }
107
- catch (e) {
108
- errors.push(`Model ${(0, logger_1.highlight)(model.name)} has invalid attributes for field ${(0, logger_1.highlight)(field.name)}:
109
- ${(0, error_1.extractError)(e)}`);
110
- }
111
- }
112
- }
113
- for (const enumDef of enums) {
114
- try {
115
- (0, attributes_1.getEnumAttributes)(enumDef);
116
- }
117
- catch (e) {
118
- errors.push(`Enum ${(0, logger_1.highlight)(enumDef.name)} has invalid attributes:
119
- ${(0, error_1.extractError)(e)}`);
120
- }
121
- }
122
- if (errors.length > 0) {
123
- (0, error_1.throwError)(`${errors.length} ${(0, string_1.pluralize)('issue', errors.length)} detected in schema:\n * ${errors.join('\n * ')}`);
124
- }
125
- }
126
75
  function isModelNotIgnored(model) {
127
76
  return model !== undefined && !model.attributes.ignore;
128
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/generator",
3
- "version": "0.73.2",
3
+ "version": "0.73.4",
4
4
  "main": "./dist/generator.js",
5
5
  "typings": "./dist/generator.d.ts",
6
6
  "bin": {