prisma-effect-kysely 1.8.0 → 1.8.2

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/CHANGELOG.md CHANGED
@@ -5,6 +5,84 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.8.2] - 2025-10-13
9
+
10
+ ### Fixed
11
+
12
+ #### Kysely Join Type Inference
13
+ - **DB interface now uses pre-resolved SelectEncoded types**: Fixed TypeScript compilation errors when using Kysely `innerJoin()` with junction tables
14
+ - **Problem**: `Schema.Schema.Encoded<typeof _table>` created conditional types too complex for Kysely's deep generic inference
15
+ - **Solution**: Use existing pre-resolved `*SelectEncoded` type aliases that already exist in generated code
16
+ - **Impact**: Kysely can now properly infer types for join operations without "Type instantiation is excessively deep" errors
17
+ - **Breaking**: None - only internal DB interface generation changed, user API remains identical
18
+ - Location: `src/kysely/type.ts:61-72`
19
+
20
+ #### Unused Enum Type Imports
21
+ - **types.ts now imports only Schema wrappers**: Eliminated TypeScript "declared but never read" warnings for enum types
22
+ - **Problem**: Generated `types.ts` imported both plain enum types (e.g., `BudgetStatus`) and schema wrappers (e.g., `BudgetStatusSchema`), but only the schema wrappers were used in field definitions
23
+ - **Solution**: Import generation now only includes `*Schema` wrappers, not plain enum types
24
+ - **Impact**: Eliminates all unused import warnings for enum types in generated code
25
+ - **Breaking**: None - users can still import plain enum types directly from `enums.ts` if needed
26
+ - Location: `src/effect/generator.ts:95-107`
27
+
28
+ ### Added
29
+
30
+ #### Test Coverage
31
+ - Added comprehensive test suite for Kysely join type inference (`src/__tests__/kysely-join-inference.test.ts`)
32
+ - Type-level tests verify TypeScript compilation succeeds
33
+ - Tests junction table joins (e.g., `_product_tags`)
34
+ - Tests complex many-to-many query patterns with aliases
35
+ - Tests multiple junction table joins in single query
36
+ - All tests use TDD approach (failing test first, then fix)
37
+
38
+ ### Technical Details
39
+
40
+ **Kysely Join Fix:**
41
+ - DB interface entries changed from `Table: Schema.Schema.Encoded<typeof _Table>` to `Table: TableSelectEncoded`
42
+ - Join table entries changed from `_table: Schema.Schema.Encoded<typeof _joinTable>` to `_table: joinTableSelectEncoded`
43
+
44
+ **Enum Import Fix:**
45
+ - Import generation changed from `.flatMap()` returning `[baseName, `${baseName}Schema`]` to `.map()` returning only `${baseName}Schema`
46
+ - Generated imports change from `import { Role, RoleSchema, Status, StatusSchema }` to `import { RoleSchema, StatusSchema }`
47
+ - Plain enum types still exported from `enums.ts` for direct use
48
+
49
+ **Overall:**
50
+ - Effect Schema functionality preserved - all 158 tests passing
51
+ - No type coercions introduced
52
+ - No breaking changes
53
+
54
+ ## [1.8.1] - 2025-10-12
55
+
56
+ ### Fixed
57
+
58
+ #### Dynamic Version Management
59
+ - **Generator version now read from package.json**: Removed hardcoded version string in generator manifest
60
+ - Generator now reports correct version dynamically
61
+ - Version always stays in sync with package.json
62
+ - No more manual version updates needed in multiple places
63
+ - Location: `src/generator/index.ts:5,12`
64
+
65
+ #### Custom Relation Name Support for Join Tables
66
+ - **Prisma custom relation names now respected**: Fixed implicit many-to-many join table naming
67
+ - `@relation("product_tags")` now correctly generates `_product_tags` table (not `_ProductToProductTag`)
68
+ - Matches Prisma's actual database table naming convention
69
+ - Both custom and default relation names work correctly
70
+ - Location: `src/prisma/relation.ts:106-115`
71
+
72
+ ### Added
73
+
74
+ #### Test Coverage
75
+ - Added test case for custom relation names in implicit many-to-many relations
76
+ - Product/ProductTag models with `@relation("product_tags")`
77
+ - Validates correct table name generation (`_product_tags`)
78
+ - Location: `src/__tests__/fixtures/test.prisma:166-177`
79
+
80
+ ### Technical Details
81
+ - Uses TypeScript's `resolveJsonModule` to import package.json
82
+ - Prisma's `field.relationName` contains either custom name or Prisma-generated default
83
+ - Maintains alphabetical model ordering for A/B column assignment in join tables
84
+ - Null-safety check added for relationName (defensive programming)
85
+
8
86
  ## [1.8.0] - 2025-10-12
9
87
 
10
88
  ### Added - Enterprise Open Source Standards
@@ -80,13 +80,13 @@ export type ${name}UpdateEncoded = Schema.Schema.Encoded<typeof ${name}.Updateab
80
80
  `import { columnType, generated, getSchemas } from "prisma-effect-kysely";`,
81
81
  ];
82
82
  if (hasEnums) {
83
- // Test 13: Import both enum and Schema wrapper
84
- // Test 14: Use PascalCase naming
85
- // Test 15: No SCREAMING_SNAKE_CASE
83
+ // Only import Schema wrappers (not plain enum types)
84
+ // Use PascalCase naming with Schema suffix
85
+ // No SCREAMING_SNAKE_CASE
86
86
  const enumImports = this.dmmf.datamodel.enums
87
- .flatMap((e) => {
87
+ .map((e) => {
88
88
  const baseName = (0, naming_1.toPascalCase)(e.name);
89
- return [baseName, `${baseName}Schema`];
89
+ return `${baseName}Schema`;
90
90
  })
91
91
  .join(', ');
92
92
  imports.push(`import { ${enumImports} } from "./enums";`);
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/effect/generator.ts"],"names":[],"mappings":";;;AACA,iCAA2C;AAC3C,iCAAwC;AACxC,4CAA+C;AAC/C,8CAAsD;AACtD,6CAAuD;AAGvD;;GAEG;AACH,MAAa,eAAe;IAC1B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD;;OAEG;IACH,aAAa,CAAC,KAAoC;QAChD,OAAO,IAAA,wBAAiB,EAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,KAAiB,EAAE,MAA6B;QACjE,MAAM,gBAAgB,GAAG,MAAM;aAC5B,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,SAAS,GAAG,IAAA,qBAAc,EAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACnD,OAAO,KAAK,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,CAAC,CAAC;aACD,I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sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":";AAMA,cAAc,mBAAmB,CAAC;AAElC,eAAO,MAAM,SAAS,MAUpB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":";AAOA,cAAc,mBAAmB,CAAC;AAElC,eAAO,MAAM,SAAS,MAUpB,CAAC"}
@@ -14,15 +14,19 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
14
14
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
16
  };
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
17
20
  Object.defineProperty(exports, "__esModule", { value: true });
18
21
  exports.generator = void 0;
19
22
  const generator_helper_1 = require("@prisma/generator-helper");
20
23
  const orchestrator_1 = require("./orchestrator");
24
+ const package_json_1 = __importDefault(require("../../package.json"));
21
25
  // Re-export kysely helpers for generated code
22
26
  __exportStar(require("../kysely/helpers"), exports);
23
27
  exports.generator = (0, generator_helper_1.generatorHandler)({
24
28
  onManifest: () => ({
25
- version: '1.7.1',
29
+ version: package_json_1.default.version,
26
30
  defaultOutput: './generated',
27
31
  prettyName: 'Prisma Effect Kysely Generator',
28
32
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA,+DAA4D;AAC5D,iDAAuD;AAEvD,8CAA8C;AAC9C,oDAAkC;AAErB,QAAA,SAAS,GAAG,IAAA,mCAAgB,EAAC;IACxC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QACjB,OAAO,EAAE,OAAO;QAChB,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,gCAAgC;KAC7C,CAAC;IACF,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAC5B,MAAM,YAAY,GAAG,IAAI,oCAAqB,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA,+DAA4D;AAC5D,iDAAuD;AACvD,sEAA6C;AAE7C,8CAA8C;AAC9C,oDAAkC;AAErB,QAAA,SAAS,GAAG,IAAA,mCAAgB,EAAC;IACxC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QACjB,OAAO,EAAE,sBAAW,CAAC,OAAO;QAC5B,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,gCAAgC;KAC7C,CAAC;IACF,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAC5B,MAAM,YAAY,GAAG,IAAI,oCAAqB,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACF,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { DMMF } from "@prisma/generator-helper";
2
- import type { JoinTableInfo } from "../prisma/relation";
1
+ import type { DMMF } from '@prisma/generator-helper';
2
+ import type { JoinTableInfo } from '../prisma/relation';
3
3
  /**
4
4
  * Determine if field needs Kysely columnType wrapper
5
5
  * ID fields with @default are read-only (can't insert/update)
@@ -25,10 +25,12 @@ export declare function applyMapDirective(fieldType: string, field: DMMF.Field):
25
25
  export declare function buildKyselyFieldType(baseFieldType: string, field: DMMF.Field): string;
26
26
  /**
27
27
  * Generate DB interface entry for a model
28
+ * Uses pre-resolved *SelectEncoded type for Kysely compatibility
28
29
  */
29
30
  export declare function generateDBInterfaceEntry(model: DMMF.Model): string;
30
31
  /**
31
32
  * Generate DB interface entry for a join table
33
+ * Uses pre-resolved *SelectEncoded type for Kysely compatibility
32
34
  */
33
35
  export declare function generateJoinTableDBInterfaceEntry(joinTable: JoinTableInfo): string;
34
36
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/kysely/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAEhD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAE/C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,UAOtE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,UAMrE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,UAQ5E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,UAIzD;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,aAAa,UAGzE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,EAC7B,UAAU,GAAE,aAAa,EAAO,UAcjC"}
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/kysely/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAEhD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAE/C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,UAOtE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,UAMrE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,UAQ5E;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,UAIzD;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,aAAa,UAGzE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,EAC7B,UAAU,GAAE,aAAa,EAAO,UAajC"}
@@ -9,6 +9,7 @@ exports.generateDBInterfaceEntry = generateDBInterfaceEntry;
9
9
  exports.generateJoinTableDBInterfaceEntry = generateJoinTableDBInterfaceEntry;
10
10
  exports.generateDBInterface = generateDBInterface;
11
11
  const type_1 = require("../prisma/type");
12
+ const naming_1 = require("../utils/naming");
12
13
  /**
13
14
  * Determine if field needs Kysely columnType wrapper
14
15
  * ID fields with @default are read-only (can't insert/update)
@@ -58,29 +59,29 @@ function buildKyselyFieldType(baseFieldType, field) {
58
59
  }
59
60
  /**
60
61
  * Generate DB interface entry for a model
62
+ * Uses pre-resolved *SelectEncoded type for Kysely compatibility
61
63
  */
62
64
  function generateDBInterfaceEntry(model) {
63
65
  const tableName = model.dbName || model.name;
64
- const baseSchemaName = `_${model.name}`;
65
- return ` ${tableName}: Schema.Schema.Encoded<typeof ${baseSchemaName}>;`;
66
+ const pascalName = (0, naming_1.toPascalCase)(model.name);
67
+ return ` ${tableName}: ${pascalName}SelectEncoded;`;
66
68
  }
67
69
  /**
68
70
  * Generate DB interface entry for a join table
71
+ * Uses pre-resolved *SelectEncoded type for Kysely compatibility
69
72
  */
70
73
  function generateJoinTableDBInterfaceEntry(joinTable) {
71
74
  const { tableName, relationName } = joinTable;
72
- return ` ${tableName}: Schema.Schema.Encoded<typeof _${relationName}>;`;
75
+ return ` ${tableName}: ${relationName}SelectEncoded;`;
73
76
  }
74
77
  /**
75
78
  * Generate complete DB interface including join tables
76
79
  */
77
80
  function generateDBInterface(models, joinTables = []) {
78
- const modelEntries = Array.from(models)
79
- .map(generateDBInterfaceEntry)
80
- .join("\n");
81
+ const modelEntries = Array.from(models).map(generateDBInterfaceEntry).join('\n');
81
82
  const joinTableEntries = joinTables.length > 0
82
- ? "\n" + joinTables.map(generateJoinTableDBInterfaceEntry).join("\n")
83
- : "";
83
+ ? '\n' + joinTables.map(generateJoinTableDBInterfaceEntry).join('\n')
84
+ : '';
84
85
  return `// Kysely Database Interface
85
86
  export interface DB {
86
87
  ${modelEntries}${joinTableEntries}
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/kysely/type.ts"],"names":[],"mappings":";;AAQA,0CAEC;AAMD,wCAEC;AAKD,gDAOC;AAKD,8CAMC;AAMD,oDAQC;AAKD,4DAIC;AAKD,8EAGC;AAKD,kDAgBC;AA5FD,yCAA4E;AAG5E;;;GAGG;AACH,SAAgB,eAAe,CAAC,KAAiB;IAC/C,OAAO,IAAA,sBAAe,EAAC,KAAK,CAAC,IAAI,IAAA,gBAAS,EAAC,KAAK,CAAC,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAAiB;IAC9C,OAAO,IAAA,sBAAe,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,gBAAS,EAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,SAAiB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AU,CAAC,MAAM,GAAG,CAAC;QACnB,CAAC,CAAC,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACrE,CAAC,CAAC,EAAE,CAAC;IAET,OAAO;;EAEP,YAAY,GAAG,gBAAgB;EAC/B,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { DMMF } from "@prisma/generator-helper";
1
+ import type { DMMF } from '@prisma/generator-helper';
2
2
  /**
3
3
  * Metadata for implicit many-to-many join tables
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"relation.d.ts","sourceRoot":"","sources":["../../src/prisma/relation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,YAAY,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,iCAAiC;IACjC,aAAa,EAAE,OAAO,CAAC;CACxB;AAqBD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAmB7D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,GAC5B,aAAa,EAAE,CA6DjB"}
1
+ {"version":3,"file":"relation.d.ts","sourceRoot":"","sources":["../../src/prisma/relation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,YAAY,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,iCAAiC;IACjC,aAAa,EAAE,OAAO,CAAC;CACxB;AAqBD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAiB7D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,GAAG,aAAa,EAAE,CAmEvF"}
@@ -12,7 +12,7 @@ const type_1 = require("./type");
12
12
  * - relationToFields is empty (no explicit relation table)
13
13
  */
14
14
  function isImplicitManyToManyField(field) {
15
- return (field.kind === "object" &&
15
+ return (field.kind === 'object' &&
16
16
  field.isList === true &&
17
17
  field.relationFromFields !== undefined &&
18
18
  field.relationFromFields.length === 0 &&
@@ -65,19 +65,27 @@ function detectImplicitManyToMany(models) {
65
65
  if (model.name === relatedModel.name) {
66
66
  continue;
67
67
  }
68
- // Generate table name (alphabetically sorted model names)
69
- const modelNames = [model.name, relatedModel.name].sort();
70
- const tableName = `_${modelNames[0]}To${modelNames[1]}`;
68
+ // Use Prisma's relation name for table naming
69
+ // For custom @relation("name"), Prisma creates _name
70
+ // For default relations, Prisma creates _ModelAToModelB
71
+ // Note: relationName should always be defined for implicit m-n relations
72
+ if (!field.relationName) {
73
+ continue;
74
+ }
75
+ const tableName = `_${field.relationName}`;
76
+ const relationName = field.relationName;
71
77
  // Skip if we've already processed this relation
72
- if (joinTables.has(tableName)) {
78
+ if (joinTables.has(relationName)) {
73
79
  continue;
74
80
  }
81
+ // Keep alphabetical ordering for A/B column assignment
82
+ const modelNames = [model.name, relatedModel.name].sort();
75
83
  // Extract ID field types
76
84
  const modelAIdField = getModelIdField(models.find((m) => m.name === modelNames[0]));
77
85
  const modelBIdField = getModelIdField(models.find((m) => m.name === modelNames[1]));
78
- joinTables.set(tableName, {
86
+ joinTables.set(relationName, {
79
87
  tableName,
80
- relationName: `${modelNames[0]}To${modelNames[1]}`,
88
+ relationName,
81
89
  modelA: modelNames[0],
82
90
  modelB: modelNames[1],
83
91
  columnAType: modelAIdField.type,
@@ -1 +1 @@
1
- {"version":3,"file":"relation.js","sourceRoot":"","sources":["../../src/prisma/relation.ts"],"names":[],"mappings":";;AAgDA,0CAmBC;AAMD,4DA+DC;AAvID,iCAAqC;AAwBrC;;;;;;;GAOG;AACH,SAAS,yBAAyB,CAAC,KAAiB;IAClD,OAAO,CACL,KAAK,CAAC,IAAI,KAAK,QAAQ;QACvB,KAAK,CAAC,MAAM,KAAK,IAAI;QACrB,KAAK,CAAC,kBAAkB,KAAK,SAAS;QACtC,KAAK,CAAC,kBAAkB,CAAC,MAAM,KAAK,CAAC;QACrC,KAAK,CAAC,gBAAgB,KAAK,SAAS;QACpC,KAAK,CAAC,gBAAgB,CAAC,MAAM,KAAK,CAAC,CACpC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,KAAiB;IAC/C,+BAA+B;IAC/B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC1D,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,0DAA0D;IAC1D,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,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YAED,uDAAuD;YACvD,MAAM,UAAU,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YAE1D,yBAAyB;YACzB,MAAM,aAAa,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;YACrF,MAAM,aAAa,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;YAErF,UAAU,CAAC,GAAG,CAAC,YAAY,EAAE;gBAC3B,SAAS;gBACT,YAAY;gBACZ,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;gBACrB,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;gBACrB,WAAW,EAAE,aAAa,CAAC,IAAI;gBAC/B,WAAW,EAAE,aAAa,CAAC,IAAI;gBAC/B,aAAa,EAAE,IAAA,kBAAW,EAAC,aAAa,CAAC;gBACzC,aAAa,EAAE,IAAA,kBAAW,EAAC,aAAa,CAAC;aAC1C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Configuration for a single Unsupported field
3
+ */
4
+ export interface UnsupportedFieldConfig {
5
+ effectType: string;
6
+ dbType: string;
7
+ dbName: string;
8
+ required: boolean;
9
+ comment?: string;
10
+ }
11
+ /**
12
+ * Full configuration structure
13
+ */
14
+ export interface UnsupportedConfig {
15
+ models: Record<string, Record<string, UnsupportedFieldConfig>>;
16
+ }
17
+ /**
18
+ * Load unsupported fields configuration from JSON file
19
+ * Looks for prisma/unsupported-fields.json relative to schema location
20
+ */
21
+ export declare function loadUnsupportedConfig(schemaPath: string): UnsupportedConfig | null;
22
+ /**
23
+ * Get unsupported fields for a specific model
24
+ */
25
+ export declare function getUnsupportedFields(config: UnsupportedConfig | null, modelName: string): Record<string, UnsupportedFieldConfig>;
26
+ //# sourceMappingURL=unsupported-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsupported-config.d.ts","sourceRoot":"","sources":["../../src/utils/unsupported-config.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC;CAChE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAiBlF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,iBAAiB,GAAG,IAAI,EAChC,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAGxC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadUnsupportedConfig = loadUnsupportedConfig;
4
+ exports.getUnsupportedFields = getUnsupportedFields;
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ /**
8
+ * Load unsupported fields configuration from JSON file
9
+ * Looks for prisma/unsupported-fields.json relative to schema location
10
+ */
11
+ function loadUnsupportedConfig(schemaPath) {
12
+ try {
13
+ // Assume schema is in prisma/schema/ directory
14
+ // Config should be in prisma/unsupported-fields.json
15
+ const schemaDir = (0, path_1.dirname)((0, path_1.dirname)(schemaPath)); // Go up to prisma/
16
+ const configPath = (0, path_1.join)(schemaDir, 'unsupported-fields.json');
17
+ if (!(0, fs_1.existsSync)(configPath)) {
18
+ return null;
19
+ }
20
+ const content = (0, fs_1.readFileSync)(configPath, 'utf-8');
21
+ return JSON.parse(content);
22
+ }
23
+ catch (error) {
24
+ console.warn(`⚠️ Failed to load unsupported-fields.json: ${error}`);
25
+ return null;
26
+ }
27
+ }
28
+ /**
29
+ * Get unsupported fields for a specific model
30
+ */
31
+ function getUnsupportedFields(config, modelName) {
32
+ if (!config)
33
+ return {};
34
+ return config.models[modelName] || {};
35
+ }
36
+ //# sourceMappingURL=unsupported-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsupported-config.js","sourceRoot":"","sources":["../../src/utils/unsupported-config.ts"],"names":[],"mappings":";;AAyBA,sDAiBC;AAKD,oDAMC;AArDD,2BAA8C;AAC9C,+BAAqC;AAoBrC;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,UAAkB;IACtD,IAAI,CAAC;QACH,+CAA+C;QAC/C,qDAAqD;QACrD,MAAM,SAAS,GAAG,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,mBAAmB;QACnE,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;QAE9D,IAAI,CAAC,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,IAAA,iBAAY,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsB,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,+CAA+C,KAAK,EAAE,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAClC,MAAgC,EAChC,SAAiB;IAEjB,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AACxC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-effect-kysely",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "Prisma generator that creates Effect Schema types from Prisma schema compatible with Kysely",
5
5
  "license": "MIT",
6
6
  "author": "Samuel Ho",