@autobe/compiler 0.17.1 → 0.19.1

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.
Files changed (33) hide show
  1. package/lib/AutoBeCompiler.d.ts +5 -5
  2. package/lib/AutoBeCompiler.js.map +1 -1
  3. package/lib/interface/AutoBeInterfaceCompiler.js +2 -2
  4. package/lib/interface/AutoBeInterfaceCompiler.js.map +1 -1
  5. package/lib/prisma/validatePrismaApplication.js +259 -73
  6. package/lib/prisma/validatePrismaApplication.js.map +1 -1
  7. package/lib/prisma/writePrismaApplication.js +31 -8
  8. package/lib/prisma/writePrismaApplication.js.map +1 -1
  9. package/lib/raw/AutoBeCompilerRealizeTemplate.js +3 -2
  10. package/lib/raw/AutoBeCompilerRealizeTemplate.js.map +1 -1
  11. package/lib/raw/AutoBeCompilerTestTemplate.js +1 -1
  12. package/lib/raw/nestjs.json +65 -65
  13. package/lib/raw/test.json +60 -60
  14. package/lib/realize/writeRealizeControllers.js +5 -4
  15. package/lib/realize/writeRealizeControllers.js.map +1 -1
  16. package/package.json +10 -10
  17. package/src/AutoBeCompiler.ts +12 -14
  18. package/src/interface/AutoBeInterfaceCompiler.ts +3 -3
  19. package/src/prisma/validatePrismaApplication.ts +265 -79
  20. package/src/prisma/writePrismaApplication.ts +29 -7
  21. package/src/raw/AutoBeCompilerRealizeTemplate.ts +3 -2
  22. package/src/raw/AutoBeCompilerTestTemplate.ts +1 -1
  23. package/src/raw/nestjs.json +65 -65
  24. package/src/raw/test.json +60 -60
  25. package/src/realize/writeRealizeControllers.ts +5 -5
  26. package/lib/interface/createMigrateApplication.d.ts +0 -3
  27. package/lib/interface/createMigrateApplication.js +0 -15
  28. package/lib/interface/createMigrateApplication.js.map +0 -1
  29. package/lib/utils/MapUtil.d.ts +0 -3
  30. package/lib/utils/MapUtil.js +0 -16
  31. package/lib/utils/MapUtil.js.map +0 -1
  32. package/src/interface/createMigrateApplication.ts +0 -18
  33. package/src/utils/MapUtil.ts +0 -10
@@ -13,14 +13,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.writeRealizeControllers = void 0;
16
+ const utils_1 = require("@autobe/utils");
17
+ const migrate_1 = require("@nestia/migrate");
16
18
  const NestiaMigrateNestMethodProgrammer_1 = require("@nestia/migrate/lib/programmers/NestiaMigrateNestMethodProgrammer");
17
19
  const path_1 = __importDefault(require("path"));
18
20
  const typescript_1 = __importDefault(require("typescript"));
19
- const createMigrateApplication_1 = require("../interface/createMigrateApplication");
20
21
  const ArrayUtil_1 = require("../utils/ArrayUtil");
21
22
  const FilePrinter_1 = require("../utils/FilePrinter");
22
23
  const writeRealizeControllers = (props) => __awaiter(void 0, void 0, void 0, function* () {
23
- const app = (0, createMigrateApplication_1.createMigrateApplication)(props.document);
24
+ const app = new migrate_1.NestiaMigrateApplication((0, utils_1.transformOpenApiDocument)(props.document));
24
25
  const result = app.nest({
25
26
  simulate: false,
26
27
  e2e: false,
@@ -33,7 +34,7 @@ const writeRealizeControllers = (props) => __awaiter(void 0, void 0, void 0, fun
33
34
  if (func === undefined || operate === undefined)
34
35
  return method; // unreachable
35
36
  const auth = operate.authorizationRole
36
- ? props.authorizations.find((d) => d.role === operate.authorizationRole)
37
+ ? props.authorizations.find((d) => d.role.name === operate.authorizationRole)
37
38
  : undefined;
38
39
  if (operate.authorizationRole && auth === undefined)
39
40
  return method; // unreachable
@@ -67,7 +68,7 @@ const writeRealizeControllers = (props) => __awaiter(void 0, void 0, void 0, fun
67
68
  .split(".ts")[0],
68
69
  name: auth.decorator.name,
69
70
  })), undefined, [])),
70
- ], undefined, auth.role, undefined, typescript_1.default.factory.createTypeReferenceNode(ctx.importer.external({
71
+ ], undefined, auth.role.name, undefined, typescript_1.default.factory.createTypeReferenceNode(ctx.importer.external({
71
72
  type: "instance",
72
73
  library: path_1.default
73
74
  .relative(ctx.controller.location, auth.payload.location)
@@ -1 +1 @@
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I;iCACV,QAAQ,CACP,GAAG,CAAC,UAAU,CAAC,QAAQ,EACvB,IAAI,CAAC,OAAO,CAAC,QAAQ,CACtB;iCACA,UAAU,CAAC,cAAI,CAAC,GAAG,EAAE,GAAG,CAAC;iCACzB,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;4BAClB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;yBACxB,CAAC,CACH,EACD,SAAS,CACV;wBACD,GAAG,MAAM,CAAC,UAAU;qBACrB;oBACH,CAAC,CAAC,MAAM,CAAC,UAAU,EACrB,MAAM,CAAC,IAAI,EACX,oBAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,oBAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CACjE,CAAC;YACJ,CAAC;SACF;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAuB,MAAM,qBAAS,CAAC,QAAQ,CAC1D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CACtC,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,CACnC,EACD,KAAqB,EAAE,4CAAhB,CAAC,GAAG,EAAE,KAAK,CAAC,IAAK,OAAA,CAAC,GAAG,EAAE,MAAM,yBAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA,GAAA,CACjE,CAAC;IACF,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AA9HW,QAAA,uBAAuB,2BA8HlC"}
1
+ {"version":3,"file":"writeRealizeControllers.js","sourceRoot":"","sources":["../../src/realize/writeRealizeControllers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA,yCAAyD;AACzD,6CAA2D;AAC3D,yHAAsH;AACtH,gDAAwB;AACxB,4DAA4B;AAE5B,kDAA+C;AAC/C,sDAAmD;AAE5C,MAAM,uBA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AAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;4BAClB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;yBACxB,CAAC,CACH,EACD,SAAS,CACV;wBACD,GAAG,MAAM,CAAC,UAAU;qBACrB;oBACH,CAAC,CAAC,MAAM,CAAC,UAAU,EACrB,MAAM,CAAC,IAAI,EACX,oBAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,oBAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CACjE,CAAC;YACJ,CAAC;SACF;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAuB,MAAM,qBAAS,CAAC,QAAQ,CAC1D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CACtC,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,CACnC,EACD,KAAqB,EAAE,4CAAhB,CAAC,GAAG,EAAE,KAAK,CAAC,IAAK,OAAA,CAAC,GAAG,EAAE,MAAM,yBAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA,GAAA,CACjE,CAAC;IACF,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AA9HW,QAAA,uBAAuB,2BA8HlC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobe/compiler",
3
- "version": "0.17.1",
3
+ "version": "0.19.1",
4
4
  "description": "AI backend server code generator",
5
5
  "main": "lib/index.js",
6
6
  "author": "Wrtn Technologies",
@@ -13,22 +13,22 @@
13
13
  "url": "https://github.com/wrtnlabs/autobe/issues"
14
14
  },
15
15
  "dependencies": {
16
- "@nestia/core": "^7.3.2",
17
- "@nestia/migrate": "^7.3.2",
18
- "@samchon/openapi": "^4.6.0",
16
+ "@nestia/core": "^7.4.0",
17
+ "@nestia/migrate": "^7.4.0",
18
+ "@samchon/openapi": "^4.7.1",
19
19
  "@trivago/prettier-plugin-sort-imports": "^5.2.2",
20
20
  "embed-prisma": "^1.1.0",
21
- "embed-typescript": "^1.0.1",
21
+ "embed-typescript": "^1.2.0",
22
22
  "import2": "^1.0.3",
23
23
  "prettier": "^3.5.3",
24
24
  "prettier-plugin-jsdoc": "^1.3.2",
25
25
  "prisma-markdown": "^3.0.0",
26
- "tstl": "^3.0.0",
27
26
  "tgrid": "^1.2.0",
28
- "typia": "^9.6.1",
29
- "@autobe/filesystem": "^0.17.1",
30
- "@autobe/interface": "^0.17.1",
31
- "@autobe/utils": "^0.17.1"
27
+ "tstl": "^3.0.0",
28
+ "typia": "^9.7.1",
29
+ "@autobe/filesystem": "^0.19.1",
30
+ "@autobe/interface": "^0.19.1",
31
+ "@autobe/utils": "^0.19.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^22.15.3",
@@ -37,19 +37,17 @@ import { AutoBeTestCompiler } from "./test/AutoBeTestCompiler";
37
37
  * @author Samchon
38
38
  */
39
39
  export class AutoBeCompiler implements IAutoBeCompiler {
40
- public constructor(private readonly listener: IAutoBeCompilerListener) {}
40
+ public prisma: IAutoBePrismaCompiler;
41
+ public interface: IAutoBeInterfaceCompiler;
42
+ public typescript: IAutoBeTypeScriptCompiler;
43
+ public test: IAutoBeTestCompiler;
44
+ public realize: IAutoBeRealizeCompiler;
41
45
 
42
- public readonly prisma: IAutoBePrismaCompiler = new AutoBePrismaCompiler();
43
-
44
- public readonly interface: IAutoBeInterfaceCompiler =
45
- new AutoBeInterfaceCompiler();
46
-
47
- public readonly typescript: IAutoBeTypeScriptCompiler =
48
- new AutoBeTypeScriptCompiler();
49
-
50
- public readonly test: IAutoBeTestCompiler = new AutoBeTestCompiler();
51
-
52
- public readonly realize: IAutoBeRealizeCompiler = new AutoBeRealizeCompiler(
53
- this.listener.realize,
54
- );
46
+ public constructor(private readonly listener: IAutoBeCompilerListener) {
47
+ this.prisma = new AutoBePrismaCompiler();
48
+ this.interface = new AutoBeInterfaceCompiler();
49
+ this.typescript = new AutoBeTypeScriptCompiler();
50
+ this.test = new AutoBeTestCompiler();
51
+ this.realize = new AutoBeRealizeCompiler(this.listener.realize);
52
+ }
55
53
  }
@@ -6,7 +6,6 @@ import { OpenApi } from "@samchon/openapi";
6
6
  import { AutoBeCompilerInterfaceTemplate } from "../raw/AutoBeCompilerInterfaceTemplate";
7
7
  import { ArrayUtil } from "../utils/ArrayUtil";
8
8
  import { FilePrinter } from "../utils/FilePrinter";
9
- import { createMigrateApplication } from "./createMigrateApplication";
10
9
 
11
10
  /**
12
11
  * Custom Interface compiler that handles API specification and NestJS
@@ -35,8 +34,9 @@ export class AutoBeInterfaceCompiler implements IAutoBeInterfaceCompiler {
35
34
  public async write(
36
35
  document: AutoBeOpenApi.IDocument,
37
36
  ): Promise<Record<string, string>> {
38
- const migrate: NestiaMigrateApplication =
39
- createMigrateApplication(document);
37
+ const migrate: NestiaMigrateApplication = new NestiaMigrateApplication(
38
+ transformOpenApiDocument(document),
39
+ );
40
40
  const files: Record<string, string> = migrate.nest({
41
41
  keyword: true,
42
42
  simulate: true,
@@ -1,9 +1,7 @@
1
1
  import { AutoBePrisma, IAutoBePrismaValidation } from "@autobe/interface";
2
- import { StringUtil } from "@autobe/utils";
2
+ import { MapUtil, StringUtil } from "@autobe/utils";
3
3
  import { HashMap, hash } from "tstl";
4
4
 
5
- import { MapUtil } from "../utils/MapUtil";
6
-
7
5
  export function validatePrismaApplication(
8
6
  application: AutoBePrisma.IApplication,
9
7
  ): IAutoBePrismaValidation {
@@ -85,15 +83,16 @@ function validateDuplicatedFiles(
85
83
  path: `application.files[${container.index}]`,
86
84
  table: null,
87
85
  field: null,
88
- message: [
89
- `File ${container.file.filename} is duplicated.`,
90
- "",
91
- "Accessors of the other duplicated files are:",
92
- "",
93
- ...array
86
+ message: StringUtil.trim`
87
+ File ${container.file.filename} is duplicated.
88
+
89
+ Accessors of the other duplicated files are:
90
+
91
+ ${array
94
92
  .filter((_oppo, j) => i !== j)
95
- .map((oppo) => `- application.files[${oppo.index}]`),
96
- ].join("\n"),
93
+ .map((oppo) => `- application.files[${oppo.index}]`)
94
+ .join("\n")},
95
+ `,
97
96
  });
98
97
  });
99
98
  return errors;
@@ -123,18 +122,19 @@ function validateDuplicatedModels(
123
122
  path: `application.files[${container.fileIndex}].models[${container.modelIndex}]`,
124
123
  table: container.model.name,
125
124
  field: null,
126
- message: [
127
- `Model ${container.model.name} is duplicated.`,
128
- "",
129
- "Accessors of the other duplicated models are:",
130
- "",
131
- ...array
125
+ message: StringUtil.trim`
126
+ Model ${container.model.name} is duplicated.
127
+
128
+ Accessors of the other duplicated models are:
129
+
130
+ ${array
132
131
  .filter((_oppo, j) => i !== j)
133
132
  .map(
134
133
  (oppo) =>
135
134
  `- application.files[${oppo.fileIndex}].models[${oppo.modelIndex}]`,
136
- ),
137
- ].join("\n"),
135
+ )
136
+ .join("\n")},
137
+ `,
138
138
  });
139
139
  });
140
140
  return errors;
@@ -152,11 +152,14 @@ function validateDuplicatedFields(
152
152
  MapUtil.take(group, model.primaryField.name, () => []).push(
153
153
  `${accessor}.primaryField.name`,
154
154
  );
155
- model.foreignFields.forEach((field, i) =>
155
+ model.foreignFields.forEach((field, i) => {
156
156
  MapUtil.take(group, field.name, () => []).push(
157
157
  `${accessor}.foreignFields[${i}].name`,
158
- ),
159
- );
158
+ );
159
+ MapUtil.take(group, field.relation.name, () => []).push(
160
+ `${accessor}.foreignFields[${i}].relation.name`,
161
+ );
162
+ });
160
163
  model.plainFields.forEach((field, i) =>
161
164
  MapUtil.take(group, field.name, () => []).push(
162
165
  `${accessor}.plainFields[${i}].name`,
@@ -169,13 +172,16 @@ function validateDuplicatedFields(
169
172
  path,
170
173
  table: model.name,
171
174
  field,
172
- message: [
173
- `Field ${field} is duplicated.`,
174
- "",
175
- "Accessors of the other duplicated fields are:",
176
- "",
177
- ...array.filter((_oppo, j) => i !== j).map((a) => `- ${a}`),
178
- ].join("\n"),
175
+ message: StringUtil.trim`
176
+ Field ${field} is duplicated.
177
+
178
+ Accessors of the other duplicated fields are:
179
+
180
+ ${array
181
+ .filter((_oppo, j) => i !== j)
182
+ .map((a) => `- ${a}`)
183
+ .join("\n")},
184
+ `,
179
185
  });
180
186
  });
181
187
 
@@ -187,12 +193,37 @@ function validateDuplicatedFields(
187
193
  table: model.name,
188
194
  field: field.name,
189
195
  message: StringUtil.trim`
190
- There's a same named table in the application.
191
-
192
- Check whether the field has been designed for denormalization
193
- like pre-calculation. If do so, remove the field.
194
-
195
- Otherwise, change the field name to something else.
196
+ Field name conflicts with an existing table name.
197
+
198
+ **What happened?**
199
+ The field "${field.name}" in model "${model.name}" has the same name as another table "${field.name}".
200
+ This can cause confusion and potential issues in the generated code.
201
+
202
+ **Why is this a problem?**
203
+ - Naming conflicts can lead to ambiguous references in your code
204
+ - It may cause issues with Prisma's relation inference
205
+ - It makes the schema harder to understand and maintain
206
+
207
+ **How to fix this:**
208
+
209
+ 1. **If this is a denormalization field (pre-calculated value):**
210
+ - Consider if this field is really necessary
211
+ - If it's storing aggregated data from the related table, it might be better to calculate it dynamically
212
+ - Remove the field if it's redundant
213
+
214
+ 2. **If this is a legitimate field:**
215
+ - Rename the field to be more descriptive
216
+ - Good naming examples:
217
+ - Instead of "user", use "user_name" or "user_id"
218
+ - Instead of "order", use "order_status" or "order_count"
219
+ - Instead of "product", use "product_name" or "product_code"
220
+
221
+ 3. **Naming best practices:**
222
+ - Use specific, descriptive names that indicate the field's purpose
223
+ - Avoid using table names as field names
224
+ - Consider adding a suffix or prefix to clarify the field's role
225
+
226
+ Please rename the field or remove it if unnecessary.
196
227
  `,
197
228
  });
198
229
  });
@@ -232,13 +263,16 @@ function validateDuplicatedIndexes(
232
263
  path,
233
264
  table: model.name,
234
265
  field: null,
235
- message: [
236
- `Duplicated index found (${fieldNames.join(", ")}).`,
237
- "",
238
- "Accessors of the other duplicated indexes are:",
239
- "",
240
- ...array.filter((_oppo, j) => i !== j).map((a) => `- ${a}`),
241
- ].join("\n"),
266
+ message: StringUtil.trim`
267
+ Duplicated index found (${fieldNames.join(", ")}).
268
+
269
+ Accessors of the other duplicated indexes are:
270
+
271
+ ${array
272
+ .filter((_oppo, j) => i !== j)
273
+ .map((a) => `- ${a}`)
274
+ .join("\n")},
275
+ `,
242
276
  });
243
277
  });
244
278
 
@@ -278,13 +312,44 @@ function validateDuplicatedIndexes(
278
312
  table: model.name,
279
313
  field: null,
280
314
  message: StringUtil.trim`
281
- Subset unique index found (${subset.join(", ")}).
282
-
283
- You have defined an unique index with multiple fields,
284
- but its subset is already defined as an unique index.
285
-
286
- Consider to change the unique index to a plain index,
287
- or drop the redundant unique index please.
315
+ Redundant subset unique index detected.
316
+
317
+ **What is a subset unique index problem?**
318
+ When you have a unique index on multiple fields, any subset of those fields is automatically unique too.
319
+ This is a fundamental property of unique constraints in databases.
320
+
321
+ **Current situation:**
322
+ - You have a unique index on: (${unique.fieldNames.join(", ")})
323
+ - But there's already a unique index on its subset: (${subset.join(", ")})
324
+ - This makes the larger unique index redundant for uniqueness purposes
325
+
326
+ **Why is this a problem?**
327
+ 1. **Logical redundancy**: If (A) is unique, then (A, B) is automatically unique
328
+ 2. **Performance overhead**: Maintaining unnecessary indexes slows down write operations
329
+ 3. **Storage waste**: Each index consumes disk space
330
+ 4. **Confusion**: It's unclear which uniqueness constraint is the intended one
331
+
332
+ **Example to illustrate:**
333
+ If email is unique, then (email, name) is automatically unique because:
334
+ - No two records can have the same email
335
+ - Therefore, no two records can have the same (email, name) combination
336
+
337
+ **How to fix:**
338
+ Choose one of these solutions based on your needs:
339
+
340
+ 1. **If you need uniqueness only:**
341
+ - Keep just the subset unique index: (${subset.join(", ")})
342
+ - Remove the larger unique index
343
+
344
+ 2. **If you need the multi-field index for query performance:**
345
+ - Keep the subset as unique index: (${subset.join(", ")})
346
+ - Change the larger index to a plain (non-unique) index for performance
347
+
348
+ 3. **If the subset unique was added by mistake:**
349
+ - Remove the subset unique index
350
+ - Keep the multi-field unique index
351
+
352
+ Please review your uniqueness requirements and adjust accordingly.
288
353
  `,
289
354
  });
290
355
  });
@@ -303,12 +368,42 @@ function validateDuplicatedIndexes(
303
368
  table: model.name,
304
369
  field: null,
305
370
  message: StringUtil.trim`
306
- Superset plain index found (${y.fieldNames.join(", ")}).
307
-
308
- You have defined a plain index with multiple fields,
309
- but its superset is already defined as another plain index.
310
-
311
- As subset index is vulnerable, drop this plain index please.
371
+ Inefficient subset index detected - superset index exists.
372
+
373
+ **What is a subset/superset index problem?**
374
+ In database indexing, when you have an index on (A, B, C), it can efficiently serve queries
375
+ that filter by A, or by (A, B), or by (A, B, C). This is called index prefix matching.
376
+
377
+ **Current situation:**
378
+ - You have a plain index on: (${x.fieldNames.join(", ")})
379
+ - But there's already a plain index on its superset: (${y.fieldNames.join(", ")})
380
+ - The subset index is redundant because the superset can handle the same queries
381
+
382
+ **Why is this a problem?**
383
+ 1. **Query efficiency**: The superset index can handle all queries the subset can
384
+ 2. **Storage waste**: You're maintaining two indexes where one would suffice
385
+ 3. **Write performance**: Each index slows down INSERT, UPDATE, and DELETE operations
386
+ 4. **Maintenance overhead**: More indexes mean more work for the database
387
+
388
+ **How indexes work (example):**
389
+ If you have an index on (country, city, street):
390
+ - ✅ Can efficiently find by country
391
+ - ✅ Can efficiently find by country + city
392
+ - ✅ Can efficiently find by country + city + street
393
+ - ❌ Cannot efficiently find by city alone
394
+ - ❌ Cannot efficiently find by street alone
395
+
396
+ **How to fix:**
397
+ Remove the subset index (${x.fieldNames.join(", ")}) because:
398
+ - The superset index (${y.fieldNames.join(", ")}) already covers these queries
399
+ - You'll save storage space and improve write performance
400
+ - Query performance will remain the same
401
+
402
+ **When to keep both indexes:**
403
+ Only if the subset index is UNIQUE (which it isn't in this case), as unique
404
+ constraints serve a different purpose than performance optimization.
405
+
406
+ Please remove the redundant subset index.
312
407
  `,
313
408
  });
314
409
  });
@@ -410,9 +505,37 @@ function validateIndexes(
410
505
  table: model.name,
411
506
  field: null,
412
507
  message: StringUtil.trim`
413
- GIN index can only be used on string typed field.
414
- However, the target field ${gin.fieldName} does not exist
415
- in the {@link plainFields}.
508
+ GIN index cannot be applied to this field.
509
+
510
+ **What is a GIN index?**
511
+ GIN (Generalized Inverted Index) is a special index type in PostgreSQL designed for
512
+ full-text search and operations on complex data types. In AutoBE, GIN indexes are
513
+ used exclusively for string fields to enable efficient text searching.
514
+
515
+ **Current problem:**
516
+ The field "${gin.fieldName}" specified for GIN index does not exist in the plain fields
517
+ of model "${model.name}".
518
+
519
+ **Possible causes:**
520
+ 1. The field name is misspelled
521
+ 2. The field is a foreign key field (not a plain field)
522
+ 3. The field was removed but the index definition remained
523
+
524
+ **How to fix:**
525
+ 1. Check if the field name is correct
526
+ 2. Ensure the field exists in the plainFields array
527
+ 3. Make sure the field is of type "string" (GIN indexes only work with strings)
528
+ 4. If the field doesn't exist, either:
529
+ - Add the missing string field to plainFields
530
+ - Remove this GIN index definition
531
+
532
+ **Example of correct GIN index usage:**
533
+ plainFields: [
534
+ { name: "content", type: "string" } // ✓ Can use GIN index
535
+ ]
536
+ ginIndexes: [
537
+ { fieldName: "content" } // ✓ Correct
538
+ ]
416
539
  `,
417
540
  });
418
541
  else if (model.plainFields[pIndex].type !== "string")
@@ -421,11 +544,43 @@ function validateIndexes(
421
544
  table: model.name,
422
545
  field: model.plainFields[pIndex].name,
423
546
  message: StringUtil.trim`
424
- GIN index can only be used on string typed field.
425
- However, the target field ${gin.fieldName} is not string,
426
- but ${model.plainFields[pIndex].type}.
427
-
428
- - accessor of the wrong typed field: ${`${accessor}.plainFields[${pIndex}].type`},
547
+ GIN index type mismatch - requires string field.
548
+
549
+ **What is a GIN index?**
550
+ GIN (Generalized Inverted Index) is PostgreSQL's specialized index for full-text search.
551
+ It's designed to efficiently search within text content, making it perfect for features like:
552
+ - Search functionality in articles or posts
553
+ - Finding keywords in product descriptions
554
+ - Filtering by text content
555
+
556
+ **Current problem:**
557
+ You're trying to apply a GIN index to field "${gin.fieldName}" which is of type "${model.plainFields[pIndex].type}".
558
+ GIN indexes can ONLY be applied to "string" type fields.
559
+
560
+ **Why string fields only?**
561
+ GIN indexes work by breaking down text into searchable tokens (words, phrases).
562
+ Other data types like numbers, booleans, or dates don't have this text structure.
563
+
564
+ **How to fix:**
565
+
566
+ 1. **If you need text search on this field:**
567
+ - Change the field type to "string"
568
+ - Example: If storing a product code as number, consider storing as string instead
569
+
570
+ 2. **If the field should remain as ${model.plainFields[pIndex].type}:**
571
+ - Remove the GIN index for this field
572
+ - Use a regular index instead (plainIndexes)
573
+ - Consider if you really need an index on this field
574
+
575
+ 3. **Alternative indexing strategies:**
576
+ - For ${model.plainFields[pIndex].type} fields, use plainIndexes for general performance
577
+ - For unique ${model.plainFields[pIndex].type} values, use uniqueIndexes
578
+ - GIN indexes should be reserved for text search scenarios only
579
+
580
+ **Location of the field:**
581
+ - Field definition: ${`${accessor}.plainFields[${pIndex}]`}
582
+
583
+ Please either change the field type to "string" or remove the GIN index.
429
584
  `,
430
585
  });
431
586
  },
@@ -441,6 +596,8 @@ function validateReferences(
441
596
  const errors: IAutoBePrismaValidation.IError[] = [];
442
597
 
443
598
  model.foreignFields.forEach((field, i) => {
599
+ // DUPLICATED NAME
600
+
444
601
  const target = dict.get(field.relation.targetModel);
445
602
  if (target === undefined) {
446
603
  // CHECK EXISTENCE
@@ -461,22 +618,51 @@ function validateReferences(
461
618
  message: StringUtil.trim`
462
619
  Cross-reference dependency detected between models.
463
620
 
464
- - accessor of opposite side: application.files[${target.fileIndex}].models[${target.modelIndex}].foreignFields[${j}].relation.targetModel
465
-
466
- Cross-references (circular dependencies) are not permitted in AutoBe Prisma schemas.
467
-
468
- To resolve this issue:
469
-
470
- 1. Remove one of the foreign key fields from either model
471
- 2. Keep only the foreign key that represents the primary relationship direction
472
- 3. Remove any related indexes that reference the deleted foreign key field
473
-
474
- The foreign key field to remove is typically:
475
-
476
- - A redundant field that can be computed from the existing relationship
477
- - A field that duplicates information already accessible through the primary relationship
478
-
479
- Please eliminate the circular dependency and try again.`,
621
+ **What is Cross-reference dependency?**
622
+ A cross-reference dependency (also known as circular dependency) occurs when two models
623
+ reference each other through foreign key fields. This creates a circular relationship
624
+ where Model A references Model B, and Model B also references Model A.
625
+
626
+ **Current situation:**
627
+ - ${model.name} model has a foreign key field "${field.name}" that references ${field.relation.targetModel}
628
+ - ${field.relation.targetModel} model also has a foreign key field that references ${model.name}
629
+ - Location of opposite reference: application.files[${target.fileIndex}].models[${target.modelIndex}].foreignFields[${j}].relation.targetModel
630
+
631
+ **Why is this a problem?**
632
+ Circular dependencies can cause issues with:
633
+ - Database initialization (which table to create first?)
634
+ - Data insertion (which record to insert first?)
635
+ - Cascading updates and deletes
636
+ - Query performance and complexity
637
+
638
+ **How to fix this:**
639
+ You need to remove one of the foreign key relationships. Here's how to decide:
640
+
641
+ 1. **Identify the primary relationship direction**
642
+ - Which model is the "parent" and which is the "child"?
643
+ - Which relationship is essential for your business logic?
644
+ - Example: In User ↔ Profile, User is typically the parent
645
+
646
+ 2. **Remove the redundant foreign key**
647
+ - Keep the foreign key in the child model pointing to the parent
648
+ - Remove the foreign key in the parent model pointing to the child
649
+ - You can still access the reverse relationship through Prisma's implicit relations
650
+
651
+ 3. **Update any affected indexes**
652
+ - Remove indexes that include the deleted foreign key field
653
+ - Update composite indexes if necessary
654
+
655
+ **Example solution:**
656
+ If you have:
657
+ - User model with profileId foreign key
658
+ - Profile model with userId foreign key
659
+
660
+ You should:
661
+ - Keep userId in Profile (child references parent)
662
+ - Remove profileId from User
663
+ - Access user's profile through: user.profile (Prisma will handle this)
664
+
665
+ Please eliminate the circular dependency and regenerate the schema.`,
480
666
  });
481
667
  }
482
668
  });