prisma-effect-kysely 1.6.0 → 1.6.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ 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.6.1] - 2025-10-12
9
+
10
+ ### Fixed
11
+
12
+ - **TypeScript Namespace Collision (TS7022)**: Fixed circular reference error in generated enum code where namespace export `Schema` collided with imported `Schema` from Effect library
13
+ - Changed import pattern from `import { Schema } from "effect"` to `import * as Effect from "effect"`
14
+ - Added module-level alias `const Schema = Effect.Schema` for clean, readable code throughout generated files
15
+ - Only use fully-qualified `Effect.Schema` inside enum namespaces where collision occurs
16
+ - This maintains 95% of generated code with clean `Schema.*` patterns while avoiding namespace collision
17
+
18
+ - **Optional Field Pattern**: Updated optional field generation from `Schema.Union(type, Schema.Undefined)` to correct `Schema.UndefinedOr(type)` combinator per Effect Schema API
19
+
20
+ ### Changed
21
+
22
+ - Generated code now uses `import * as Effect from "effect"` pattern (industry standard)
23
+ - All generated files include module-level alias `const Schema = Effect.Schema` for clean API
24
+
8
25
  ## [1.6.0] - 2025-10-12
9
26
 
10
27
  ### Changed
package/README.md CHANGED
@@ -43,38 +43,117 @@ Generates three files in the configured output directory:
43
43
 
44
44
  ### enums.ts
45
45
 
46
- Effect Schema enums from Prisma enums with exact literal types:
46
+ Native TypeScript enums with Effect Schema wrappers in namespaces:
47
47
 
48
48
  ```typescript
49
- export const UserRole = Schema.Literal('admin', 'user', 'guest');
50
- export type UserRole = Schema.Schema.Type<typeof UserRole>;
49
+ export enum UserRole {
50
+ ADMIN = "ADMIN",
51
+ USER = "USER",
52
+ GUEST = "GUEST"
53
+ }
54
+
55
+ export namespace UserRole {
56
+ export const Schema = Schema.Enums(UserRole);
57
+ export type Type = Schema.Schema.Type<typeof Schema>;
58
+ }
59
+
60
+ // Usage:
61
+ // - Access enum values: UserRole.ADMIN, UserRole.USER
62
+ // - Access Effect Schema: UserRole.Schema
63
+ // - Access TypeScript type: UserRole.Type
51
64
  ```
52
65
 
53
66
  ### types.ts
54
67
 
55
- Effect Schema structs from Prisma models:
68
+ Effect Schema structs from Prisma models with Kysely integration:
56
69
 
57
70
  ```typescript
58
- export const User = Schema.Struct({
59
- id: Schema.UUID,
71
+ // Base schema with underscore prefix
72
+ export const _User = Schema.Struct({
73
+ id: columnType(Schema.UUID, Schema.Never, Schema.Never), // Read-only ID
60
74
  email: Schema.String,
61
- name: Schema.optional(Schema.String),
62
- role: UserRole,
63
- createdAt: Schema.Date,
75
+ name: Schema.Union(Schema.String, Schema.Undefined), // Optional field
76
+ role: UserRole.Schema,
77
+ createdAt: generated(Schema.Date), // Generated field
64
78
  });
65
- export type User = Schema.Schema.Type<typeof User>;
79
+
80
+ // Operational schemas and types in namespace
81
+ export namespace User {
82
+ const schemas = getSchemas(_User);
83
+ export const Selectable = schemas.Selectable; // For SELECT queries
84
+ export const Insertable = schemas.Insertable; // For INSERT (generated fields optional)
85
+ export const Updateable = schemas.Updateable; // For UPDATE (all fields optional)
86
+
87
+ export type Select = Schema.Schema.Type<typeof User.Selectable>;
88
+ export type Insert = Schema.Schema.Type<typeof User.Insertable>;
89
+ export type Update = Schema.Schema.Type<typeof User.Updateable>;
90
+ export type SelectEncoded = Schema.Schema.Encoded<typeof User.Selectable>;
91
+ export type InsertEncoded = Schema.Schema.Encoded<typeof User.Insertable>;
92
+ export type UpdateEncoded = Schema.Schema.Encoded<typeof User.Updateable>;
93
+ }
94
+
95
+ // Kysely DB interface for type-safe queries
96
+ export interface DB {
97
+ User: Schema.Schema.Encoded<typeof _User>;
98
+ // ... other models
99
+ }
66
100
  ```
67
101
 
68
- **Naming Convention**: All exported schemas and types use PascalCase, regardless of the Prisma model naming convention:
69
- - Model `User` → `User`, `UserSelect`, `UserInsert`
70
- - Model `session_preference` → `SessionPreference`, `SessionPreferenceSelect`, `SessionPreferenceInsert`
102
+ **Name Preservation**: All names from your Prisma schema are preserved exactly:
103
+ - Model `User` → `User` namespace with `User.Select`, `User.Insert`, `User.Update`
104
+ - Model `session_preference` → `session_preference` namespace
105
+ - Enum `ACTIVE_STATUS` → `ACTIVE_STATUS` enum and namespace
71
106
 
72
- This ensures consistent TypeScript identifier naming while preserving the original model names for internal schemas.
107
+ This creates a complete bridge from Prisma Effect Kysely TypeScript with stable, predictable names.
73
108
 
74
109
  ### index.ts
75
110
 
76
111
  Re-exports all generated types for easy importing
77
112
 
113
+ ## Namespace Pattern
114
+
115
+ The generator uses TypeScript namespaces to organize generated code while preserving your Prisma schema names exactly.
116
+
117
+ ### Benefits
118
+
119
+ - **Zero Name Transformations**: Your Prisma names flow unchanged through Effect, Kysely, and TypeScript
120
+ - **No Naming Conflicts**: Namespaces eliminate collisions without requiring name transformations
121
+ - **Grouped Exports**: Related schemas, types, and values are logically grouped
122
+ - **Clean API**: Access everything through a single identifier (e.g., `User.Select`, `User.Insertable`)
123
+
124
+ ### Structure
125
+
126
+ **For Enums:**
127
+ ```typescript
128
+ export enum ACTIVE_STATUS { ACTIVE, INACTIVE } // Native TypeScript enum
129
+ export namespace ACTIVE_STATUS { // Namespace merging
130
+ export const Schema = Schema.Enums(ACTIVE_STATUS); // Effect Schema
131
+ export type Type = Schema.Schema.Type<typeof Schema>; // TypeScript type
132
+ }
133
+ ```
134
+
135
+ **For Models:**
136
+ ```typescript
137
+ export const _User = Schema.Struct({ ... }); // Base schema (underscore prefix)
138
+ export namespace User { // Namespace for operational schemas
139
+ const schemas = getSchemas(_User);
140
+ export const Selectable = schemas.Selectable;
141
+ export const Insertable = schemas.Insertable;
142
+ export const Updateable = schemas.Updateable;
143
+ export type Select = ...;
144
+ export type Insert = ...;
145
+ // ... more types
146
+ }
147
+ ```
148
+
149
+ **For Join Tables:**
150
+ ```typescript
151
+ export const _CategoryToPost = Schema.Struct({ A, B });
152
+ export namespace CategoryToPost {
153
+ // Same pattern as models
154
+ }
155
+ ```
156
+
78
157
  ## Type Mappings
79
158
 
80
159
  | Prisma Type | Effect Schema Type | Notes |
@@ -30,8 +30,8 @@ ${enumMembers}
30
30
  }
31
31
 
32
32
  export namespace ${enumName} {
33
- export const Schema = Schema.Enums(${enumName});
34
- export type Type = Schema.Schema.Type<typeof Schema>;
33
+ export const Schema = Effect.Schema.Enums(${enumName});
34
+ export type Type = Effect.Schema.Schema.Type<typeof Schema>;
35
35
  }`;
36
36
  }
37
37
  /**
@@ -39,7 +39,7 @@ export namespace ${enumName} {
39
39
  */
40
40
  function generateEnumsFile(enums) {
41
41
  const header = (0, codegen_1.generateFileHeader)();
42
- const imports = `import { Schema } from "effect";`;
42
+ const imports = `import * as Effect from "effect";\nconst Schema = Effect.Schema;`;
43
43
  const enumSchemas = enums.map(generateEnumSchema).join("\n\n");
44
44
  return `${header}\n\n${imports}\n\n${enumSchemas}`;
45
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/effect/enum.ts"],"names":[],"mappings":";;AAeA,gDAqBC;AAKD,8CAMC;AA9CD,yCAAoD;AAEpD,8CAAsD;AAEtD;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CAAC,OAA2B;IAC5D,iDAAiD;IACjD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAE9B,0CAA0C;IAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM;SAC/B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,KAAK,GAAG,IAAA,yBAAkB,EAAC,CAAC,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,CAAC,IAAI,OAAO,KAAK,GAAG,CAAC;IACpC,CAAC,CAAC;SACD,IAAI,CAAC,KAAK,CAAC,CAAC;IAEf,kDAAkD;IAClD,OAAO,eAAe,QAAQ;EAC9B,WAAW;;;mBAGM,QAAQ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AAG,MAAM,OAAO,OAAO,OAAO,WAAW,EAAE,CAAC;AACrD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/effect/generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAOrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;GAEG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,IAAI,CAAC,QAAQ;IAEhD;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,aAAa,EAAE;IAIlD;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;IAgBnE;;OAEG;IACH,0BAA0B,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK;IAY5C;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK;IAarC;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE;IAQ3D;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,OAAO;IAyBrC;;OAEG;IACH,wBAAwB,CAAC,UAAU,EAAE,aAAa,EAAE;CAKrD"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/effect/generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAOrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;GAEG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,IAAI,CAAC,QAAQ;IAEhD;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,aAAa,EAAE;IAIlD;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;IAgBnE;;OAEG;IACH,0BAA0B,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK;IAY5C;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK;IAarC;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE;IAQ3D;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,OAAO;IAsBrC;;OAEG;IACH,wBAAwB,CAAC,UAAU,EAAE,aAAa,EAAE;CAKrD"}
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EffectGenerator = void 0;
4
4
  const enum_1 = require("./enum");
5
5
  const type_1 = require("./type");
6
- const naming_1 = require("../utils/naming");
7
6
  const codegen_1 = require("../utils/codegen");
8
7
  const join_table_1 = require("./join-table");
9
8
  /**
@@ -79,18 +78,15 @@ ${fieldDefinitions}
79
78
  generateTypesHeader(hasEnums) {
80
79
  const header = (0, codegen_1.generateFileHeader)();
81
80
  const imports = [
82
- `import { Schema } from "effect";`,
81
+ `import * as Effect from "effect";`,
82
+ `const Schema = Effect.Schema;`,
83
83
  `import { columnType, generated, getSchemas } from "prisma-effect-kysely";`,
84
84
  ];
85
85
  if (hasEnums) {
86
- // Test 13: Import both enum and Schema wrapper
87
- // Test 14: Use PascalCase naming
88
- // Test 15: No SCREAMING_SNAKE_CASE
86
+ // With namespace pattern, we only import the enum itself
87
+ // Access Schema through namespace: EnumName.Schema
89
88
  const enumImports = this.dmmf.datamodel.enums
90
- .flatMap((e) => {
91
- const baseName = (0, naming_1.toPascalCase)(e.name);
92
- return [baseName, `${baseName}Schema`];
93
- })
89
+ .map((e) => e.name) // Preserve original enum names
94
90
  .join(', ');
95
91
  imports.push(`import { ${enumImports} } from "./enums";`);
96
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/effect/generator.ts"],"names":[],"mappings":";;;AACA,iCAA2C;AAC3C,iCAAwC;AAExC,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,IAAI,CAAC,KAAK,CAAC,CAAC;QAEf,MAAM,cAAc,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QAExC,OAAO,MAAM,KAAK,CAAC,IAAI;eACZ,cAAc;EAC3B,gBAAgB;IACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,0BAA0B,CAAC,KAAiB;QAC1C,MAAM,cAAc,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;QAE7B,OAAO,oBAAoB,SAAS;+BACT,cAAc;;;;EAI3C,CAAC;IACD,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,KAAiB;QACnC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAExB,OAAO,oBAAoB,IAAI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,IAAI,CAAC,IAAI,CAAC,CAAC;aACnD,IAAI,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;CACF;AA1GD,0CA0GC"}
@@ -4,7 +4,6 @@ exports.mapFieldToEffectType = mapFieldToEffectType;
4
4
  exports.buildFieldType = buildFieldType;
5
5
  const type_1 = require("../prisma/type");
6
6
  const annotations_1 = require("../utils/annotations");
7
- const naming_1 = require("../utils/naming");
8
7
  /**
9
8
  * Prisma scalar type mapping to Effect Schema types
10
9
  * Uses const assertion to avoid type guards
@@ -43,9 +42,9 @@ function mapFieldToEffectType(field, dmmf) {
43
42
  // TDD: Satisfies tests 11-12 in field-type-generation.test.ts
44
43
  const enumDef = dmmf.datamodel.enums.find((e) => e.name === field.type);
45
44
  if (enumDef) {
46
- // Return Schema wrapper, not raw enum (Test 11)
47
- // Use PascalCase + Schema suffix (Test 12)
48
- return (0, naming_1.toPascalCase)(field.type, 'Schema');
45
+ // Return Schema via namespace pattern (v1.6.0+)
46
+ // Preserve original enum name, access Schema through namespace
47
+ return `${enumDef.name}.Schema`;
49
48
  }
50
49
  // PRIORITY 5: Fallback to Unknown
51
50
  return "Schema.Unknown";
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/effect/type.ts"],"names":[],"mappings":";;AA8BA,oDA8BC;AAKD,wCAcC;AA9ED,yCAKwB;AACxB,sDAAiE;AACjE,4CAA+C;AAE/C;;;GAGG;AACH,MAAM,iBAAiB,GAAG;IACxB,MAAM,EAAE,eAAe;IACvB,GAAG,EAAE,eAAe;IACpB,KAAK,EAAE,eAAe;IACtB,MAAM,EAAE,eAAe;IACvB,OAAO,EAAE,eAAe,EAAE,gBAAgB;IAC1C,OAAO,EAAE,gBAAgB;IACzB,QAAQ,EAAE,aAAa;IACvB,IAAI,EAAE,gBAAgB,EAAE,oBAAoB;IAC5C,KAAK,EAAE,mBAAmB;CAClB,CAAC;AAEX;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,KAAiB,EAA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;QAChD,+DAA+D;QAC/D,OAAO,GAAG,OAAO,CAAC,IAAI,SAAS,CAAC;IAClC,CAAC;IAED,kCAAkC;IAClC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAiB,EAAE,IAAmB;IACnE,IAAI,QAAQ,GAAG,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEjD,gBAAgB;IAChB,IAAI,IAAA,kBAAW,EAAC,KAAK,CAAC,EAAE,CAAC;QACvB,QAAQ,GAAG,gBAAgB,QAAQ,GAAG,CAAC;IACzC,CAAC;IAED,4DAA4D;IAC5D,IAAI,CAAC,IAAA,sBAAe,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,sBAAe,EAAC,KAAK,CAAC,EAAE,CAAC;QACvD,QAAQ,GAAG,sBAAsB,QAAQ,GAAG,CAAC;IAC/C,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,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.6.0",
3
+ "version": "1.6.1",
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",