prisma-effect-kysely 1.7.0 → 1.7.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,96 +5,42 @@ 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.7.0] - 2025-10-12
8
+ ## [1.7.2] - 2025-10-12
9
9
 
10
10
  ### Fixed
11
11
 
12
- - **CRITICAL: TypeScript TS7022 Compilation Error**: Fixed circular reference errors in generated enum code that prevented TypeScript compilation
13
- - v1.6.0-v1.6.1 used namespace merging pattern that caused unavoidable TS7022 errors: `'Schema' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer`
14
- - Reverted to proven v1.5.3 suffix pattern (`RoleSchema`, `RoleType`) which compiles without errors
15
- - Tests were masking the compilation failures by only checking string patterns, never actually running TypeScript compiler on generated code
12
+ - **Enum PascalCase Aliases**: Added missing const and type aliases for better ergonomics
13
+ - Now exports: `export const BudgetStatus = BUDGET_STATUS` (const alias)
14
+ - Now exports: `export type BudgetStatus = BudgetStatusType` (type alias)
15
+ - Allows consuming code to use PascalCase imports: `import { BudgetStatus } from './enums'`
16
+ - Maintains backward compatibility with SCREAMING_SNAKE_CASE enums
17
+ - This was documented in 1.7.1 but not actually implemented in the generated output
16
18
 
17
- ### Changed
18
-
19
- - **BREAKING: Reverted to Suffix Pattern for Enums**
20
- - Enum exports now use suffix pattern instead of namespace pattern from v1.6.x
21
- - **Before (v1.6.x - broken)**: `Role.Schema`, `Role.Type`
22
- - **After (v1.7.0 - working)**: `RoleSchema`, `RoleType`
23
- - This ensures generated code compiles with TypeScript strict mode without errors
24
- - **Migration from v1.6.x**:
25
- - `Role.Schema` → `RoleSchema`
26
- - `Role.Type` → `RoleType`
27
- - `Status.Schema` → `StatusSchema`
28
- - `Status.Type` → `StatusType`
29
-
30
- ### Added
31
-
32
- - **JSDoc Documentation**: All generated enum exports now include comprehensive JSDoc comments
33
- - Self-documenting code with `@see` references between related exports
34
- - Clear `@example` tags showing how to use Effect Schema validation
35
- - Generated TypeScript type unions documented inline (e.g., `'ADMIN' | 'USER' | 'GUEST'`)
36
- - Improves IDE IntelliSense and developer experience
37
-
38
- ## [1.6.1] - 2025-10-12
39
-
40
- ### Fixed
41
-
42
- - **TypeScript Namespace Collision (TS7022)**: Fixed circular reference error in generated enum code where namespace export `Schema` collided with imported `Schema` from Effect library
43
- - Changed import pattern from `import { Schema } from "effect"` to `import * as Effect from "effect"`
44
- - Added module-level alias `const Schema = Effect.Schema` for clean, readable code throughout generated files
45
- - Only use fully-qualified `Effect.Schema` inside enum namespaces where collision occurs
46
- - This maintains 95% of generated code with clean `Schema.*` patterns while avoiding namespace collision
47
-
48
- - **Optional Field Pattern**: Updated optional field generation from `Schema.Union(type, Schema.Undefined)` to correct `Schema.UndefinedOr(type)` combinator per Effect Schema API
19
+ ## [1.7.1] - 2025-10-12
49
20
 
50
21
  ### Changed
51
22
 
52
- - Generated code now uses `import * as Effect from "effect"` pattern (industry standard)
53
- - All generated files include module-level alias `const Schema = Effect.Schema` for clean API
23
+ - **Enum naming convention improved**:
24
+ - Enum declarations preserve original Prisma schema names (e.g., `export enum ACTIVE_STATUS`)
25
+ - Schema wrappers use PascalCase for idiomatic TypeScript (e.g., `ActiveStatusSchema`)
26
+ - Type aliases use PascalCase (e.g., `ActiveStatusType`)
27
+ - **Usage**: Access enum values with original name: `ACTIVE_STATUS.ACTIVE`, validate with PascalCase schema: `ActiveStatusSchema`
54
28
 
55
- ## [1.6.0] - 2025-10-12
29
+ ### Example
56
30
 
57
- ### Changed
31
+ ```typescript
32
+ // Generated from: enum ACTIVE_STATUS { ACTIVE, INACTIVE }
33
+ export enum ACTIVE_STATUS {
34
+ ACTIVE = "ACTIVE",
35
+ INACTIVE = "INACTIVE"
36
+ }
37
+ export const ActiveStatusSchema = Schema.Enums(ACTIVE_STATUS);
38
+ export type ActiveStatusType = Schema.Schema.Type<typeof ActiveStatusSchema>;
58
39
 
59
- - **BREAKING: TypeScript Namespace Pattern for Complete Name Preservation**
60
- - **Zero name transformations** - All user-declared names from Prisma schema are preserved exactly throughout the generated code
61
- - **Enums**: Now use TypeScript namespace pattern instead of suffix pattern
62
- - Before v1.6.0: `ACTIVE_STATUS` enum generated `ACTIVE_STATUSSchema` and `ACTIVE_STATUSType` (awkward)
63
- - v1.6.0+: Uses namespace merging for clean API:
64
- ```typescript
65
- export enum ACTIVE_STATUS { ACTIVE, INACTIVE }
66
- export namespace ACTIVE_STATUS {
67
- export const Schema = Schema.Enums(ACTIVE_STATUS);
68
- export type Type = Schema.Schema.Type<typeof Schema>;
69
- }
70
- // Usage: ACTIVE_STATUS.ACTIVE, ACTIVE_STATUS.Schema, ACTIVE_STATUS.Type
71
- ```
72
- - **Models**: Operational schemas and type exports moved into namespaces
73
- - Before v1.6.0: `export const User = getSchemas(_User)`, `export type UserSelect = ...`
74
- - v1.6.0+: Everything grouped in namespace:
75
- ```typescript
76
- export namespace User {
77
- const schemas = getSchemas(_User);
78
- export const Selectable = schemas.Selectable;
79
- export const Insertable = schemas.Insertable;
80
- export const Updateable = schemas.Updateable;
81
- export type Select = Schema.Schema.Type<typeof User.Selectable>;
82
- export type Insert = Schema.Schema.Type<typeof User.Insertable>;
83
- // ...
84
- }
85
- ```
86
- - **Join Tables**: Same namespace pattern for consistency
87
- - **No PascalCase conversion**: `session_model_preference` stays `session_model_preference` (not converted to `SessionModelPreference`)
88
- - **Benefits**:
89
- - ✨ Complete bridge from Prisma → Effect → Kysely → TypeScript with stable names
90
- - ✨ No naming conflicts without transformations
91
- - ✨ Cleaner API with grouped related exports
92
- - ✨ User's Prisma schema names are the source of truth
93
- - **Migration Guide**:
94
- - Enum access: `ACTIVE_STATUSSchema` → `ACTIVE_STATUS.Schema`, `ACTIVE_STATUSType` → `ACTIVE_STATUS.Type`
95
- - Model operational schemas: `User.Selectable` stays the same (namespace merging)
96
- - Type imports: `UserSelect` → `User.Select`, `UserInsert` → `User.Insert`, etc.
97
- - Encoded types: `UserSelectEncoded` → `User.SelectEncoded`, etc.
40
+ // Usage:
41
+ const status = ACTIVE_STATUS.ACTIVE; // Direct enum access
42
+ Schema.decodeSync(ActiveStatusSchema)(input); // Validation
43
+ ```
98
44
 
99
45
  ## [1.5.3] - 2025-10-12
100
46
 
package/README.md CHANGED
@@ -43,135 +43,38 @@ Generates three files in the configured output directory:
43
43
 
44
44
  ### enums.ts
45
45
 
46
- Native TypeScript enums with Effect Schema validators and comprehensive JSDoc:
46
+ Effect Schema enums from Prisma enums with exact literal types:
47
47
 
48
48
  ```typescript
49
- /**
50
- * UserRole enum from Prisma schema.
51
- * @see {@link UserRoleSchema} for Effect Schema validation
52
- * @see {@link UserRoleType} for TypeScript type
53
- */
54
- export enum UserRole {
55
- ADMIN = "ADMIN",
56
- USER = "USER",
57
- GUEST = "GUEST"
58
- }
59
-
60
- /**
61
- * Effect Schema validator for UserRole enum.
62
- * Validates that a value is a valid UserRole enum member.
63
- *
64
- * @example
65
- * const validated = Schema.decodeSync(UserRoleSchema)("ADMIN");
66
- */
67
- export const UserRoleSchema = Schema.Enums(UserRole);
68
-
69
- /**
70
- * TypeScript type for UserRole enum values.
71
- * Equivalent to: 'ADMIN' | 'USER' | 'GUEST'
72
- */
73
- export type UserRoleType = Schema.Schema.Type<typeof UserRoleSchema>;
74
-
75
- // Usage:
76
- // - Access enum values: UserRole.ADMIN, UserRole.USER
77
- // - Access Effect Schema: UserRoleSchema
78
- // - Access TypeScript type: UserRoleType
49
+ export const UserRole = Schema.Literal('admin', 'user', 'guest');
50
+ export type UserRole = Schema.Schema.Type<typeof UserRole>;
79
51
  ```
80
52
 
81
53
  ### types.ts
82
54
 
83
- Effect Schema structs from Prisma models with Kysely integration:
55
+ Effect Schema structs from Prisma models:
84
56
 
85
57
  ```typescript
86
- // Base schema with underscore prefix
87
- export const _User = Schema.Struct({
88
- id: columnType(Schema.UUID, Schema.Never, Schema.Never), // Read-only ID
58
+ export const User = Schema.Struct({
59
+ id: Schema.UUID,
89
60
  email: Schema.String,
90
- name: Schema.Union(Schema.String, Schema.Undefined), // Optional field
91
- role: UserRoleSchema,
92
- createdAt: generated(Schema.Date), // Generated field
61
+ name: Schema.optional(Schema.String),
62
+ role: UserRole,
63
+ createdAt: Schema.Date,
93
64
  });
94
-
95
- // Operational schemas and types in namespace
96
- export namespace User {
97
- const schemas = getSchemas(_User);
98
- export const Selectable = schemas.Selectable; // For SELECT queries
99
- export const Insertable = schemas.Insertable; // For INSERT (generated fields optional)
100
- export const Updateable = schemas.Updateable; // For UPDATE (all fields optional)
101
-
102
- export type Select = Schema.Schema.Type<typeof User.Selectable>;
103
- export type Insert = Schema.Schema.Type<typeof User.Insertable>;
104
- export type Update = Schema.Schema.Type<typeof User.Updateable>;
105
- export type SelectEncoded = Schema.Schema.Encoded<typeof User.Selectable>;
106
- export type InsertEncoded = Schema.Schema.Encoded<typeof User.Insertable>;
107
- export type UpdateEncoded = Schema.Schema.Encoded<typeof User.Updateable>;
108
- }
109
-
110
- // Kysely DB interface for type-safe queries
111
- export interface DB {
112
- User: Schema.Schema.Encoded<typeof _User>;
113
- // ... other models
114
- }
65
+ export type User = Schema.Schema.Type<typeof User>;
115
66
  ```
116
67
 
117
- **Name Preservation**: All names from your Prisma schema are preserved exactly:
118
- - Model `User` → `User` namespace with `User.Select`, `User.Insert`, `User.Update`
119
- - Model `session_preference` → `session_preference` namespace
120
- - Enum `ACTIVE_STATUS` → `ACTIVE_STATUS` enum and namespace
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`
121
71
 
122
- This creates a complete bridge from Prisma Effect Kysely TypeScript with stable, predictable names.
72
+ This ensures consistent TypeScript identifier naming while preserving the original model names for internal schemas.
123
73
 
124
74
  ### index.ts
125
75
 
126
76
  Re-exports all generated types for easy importing
127
77
 
128
- ## Namespace Pattern
129
-
130
- The generator uses TypeScript namespaces to organize generated code while preserving your Prisma schema names exactly.
131
-
132
- ### Benefits
133
-
134
- - **Zero Name Transformations**: Your Prisma names flow unchanged through Effect, Kysely, and TypeScript
135
- - **No Naming Conflicts**: Namespaces eliminate collisions without requiring name transformations
136
- - **Grouped Exports**: Related schemas, types, and values are logically grouped
137
- - **Clean API**: Access everything through a single identifier (e.g., `User.Select`, `User.Insertable`)
138
-
139
- ### Structure
140
-
141
- **For Enums:**
142
- ```typescript
143
- // Native TypeScript enum preserving Prisma schema naming
144
- export enum ACTIVE_STATUS { ACTIVE, INACTIVE }
145
-
146
- // Effect Schema validator with suffix pattern
147
- export const ACTIVE_STATUSSchema = Schema.Enums(ACTIVE_STATUS);
148
-
149
- // TypeScript type export
150
- export type ACTIVE_STATUSType = Schema.Schema.Type<typeof ACTIVE_STATUSSchema>;
151
- ```
152
-
153
- **For Models:**
154
- ```typescript
155
- export const _User = Schema.Struct({ ... }); // Base schema (underscore prefix)
156
- export namespace User { // Namespace for operational schemas
157
- const schemas = getSchemas(_User);
158
- export const Selectable = schemas.Selectable;
159
- export const Insertable = schemas.Insertable;
160
- export const Updateable = schemas.Updateable;
161
- export type Select = ...;
162
- export type Insert = ...;
163
- // ... more types
164
- }
165
- ```
166
-
167
- **For Join Tables:**
168
- ```typescript
169
- export const _CategoryToPost = Schema.Struct({ A, B });
170
- export namespace CategoryToPost {
171
- // Same pattern as models
172
- }
173
- ```
174
-
175
78
  ## Type Mappings
176
79
 
177
80
  | Prisma Type | Effect Schema Type | Notes |
@@ -1 +1 @@
1
- {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/effect/enum.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAKrD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,UA8C7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,aAAa,EAAE,UAMrE"}
1
+ {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/effect/enum.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAKrD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,UAiC7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,aAAa,EAAE,UAMrE"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateEnumSchema = generateEnumSchema;
4
4
  exports.generateEnumsFile = generateEnumsFile;
5
5
  const enum_1 = require("../prisma/enum");
6
+ const naming_1 = require("../utils/naming");
6
7
  const codegen_1 = require("../utils/codegen");
7
8
  /**
8
9
  * Generate TypeScript enum + Effect Schema.Enums wrapper
@@ -15,47 +16,36 @@ const codegen_1 = require("../utils/codegen");
15
16
  * - Type alias for convenience
16
17
  */
17
18
  function generateEnumSchema(enumDef) {
18
- // Preserve original enum name from Prisma schema
19
+ // Preserve original enum name for the enum itself
19
20
  const enumName = enumDef.name;
20
- const schemaName = `${enumName}Schema`;
21
- const typeName = `${enumName}Type`;
22
- // Generate native TypeScript enum members
21
+ // Use PascalCase for Schema and Type exports
22
+ const pascalName = (0, naming_1.toPascalCase)(enumDef.name);
23
+ const schemaName = `${pascalName}Schema`;
24
+ const typeName = `${pascalName}Type`;
25
+ // Generate native TypeScript enum members (Tests 1-2)
23
26
  const enumMembers = enumDef.values
24
27
  .map((v) => {
25
28
  const value = (0, enum_1.getEnumValueDbName)(v);
26
29
  return ` ${v.name} = "${value}"`;
27
30
  })
28
31
  .join(",\n");
29
- // Get first enum value for example
30
- const firstValue = enumDef.values[0]?.name || 'VALUE';
31
- // Get enum values as type union for JSDoc
32
- const enumValueUnion = enumDef.values
33
- .map(v => `'${(0, enum_1.getEnumValueDbName)(v)}'`)
34
- .join(' | ');
35
- // Generate: enum + Schema.Enums() wrapper + type with JSDoc
36
- return `/**
37
- * ${enumName} enum from Prisma schema.
38
- * @see {@link ${schemaName}} for Effect Schema validation
39
- * @see {@link ${typeName}} for TypeScript type
40
- */
41
- export enum ${enumName} {
32
+ // Generate: enum + Schema.Enums() wrapper + type (Tests 3-4)
33
+ // Explicitly NOT using Schema.Literal (Test 6)
34
+ //
35
+ // Also generate PascalCase aliases for better ergonomics:
36
+ // - const alias: allows using PascalCase in runtime code
37
+ // - type alias: provides PascalCase type name
38
+ return `export enum ${enumName} {
42
39
  ${enumMembers}
43
40
  }
44
41
 
45
- /**
46
- * Effect Schema validator for ${enumName} enum.
47
- * Validates that a value is a valid ${enumName} enum member.
48
- *
49
- * @example
50
- * const validated = Schema.decodeSync(${schemaName})("${firstValue}");
51
- */
52
42
  export const ${schemaName} = Schema.Enums(${enumName});
53
43
 
54
- /**
55
- * TypeScript type for ${enumName} enum values.
56
- * Equivalent to: ${enumValueUnion}
57
- */
58
- export type ${typeName} = Schema.Schema.Type<typeof ${schemaName}>;`;
44
+ export type ${typeName} = Schema.Schema.Type<typeof ${schemaName}>;
45
+
46
+ // PascalCase aliases for better ergonomics
47
+ export const ${pascalName} = ${enumName};
48
+ export type ${pascalName} = ${typeName};`;
59
49
  }
60
50
  /**
61
51
  * Generate all enum schemas as a single file content
@@ -1 +1 @@
1
- {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/effect/enum.ts"],"names":[],"mappings":";;AAeA,gDA8CC;AAKD,8CAMC;AAvED,yCAAoD;AAEpD,8CAAsD;AAEtD;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CAAC,OAA2B;IAC5D,iDAAiD;IACjD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CA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M,CAAC,CAAC;IAE/D,OAAO,GAAG,MAAM,OAAO,OAAO,OAAO,WAAW,EAAE,CAAC;AACrD,CAAC"}
@@ -15,11 +15,11 @@ export declare class EffectGenerator {
15
15
  */
16
16
  generateBaseSchema(model: DMMF.Model, fields: readonly DMMF.Field[]): string;
17
17
  /**
18
- * Generate operational schemas as namespace (ModelName.Selectable, etc.)
18
+ * Generate operational schemas (ModelName.Selectable, etc.)
19
19
  */
20
20
  generateOperationalSchemas(model: DMMF.Model): string;
21
21
  /**
22
- * Generate TypeScript type exports as namespace
22
+ * Generate TypeScript type exports
23
23
  */
24
24
  generateTypeExports(model: DMMF.Model): string;
25
25
  /**
@@ -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;IAoBrC;;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;IAO5C;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK;IAiBrC;;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"}
@@ -3,6 +3,7 @@ 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");
6
7
  const codegen_1 = require("../utils/codegen");
7
8
  const join_table_1 = require("./join-table");
8
9
  /**
@@ -35,31 +36,28 @@ ${fieldDefinitions}
35
36
  });`;
36
37
  }
37
38
  /**
38
- * Generate operational schemas as namespace (ModelName.Selectable, etc.)
39
+ * Generate operational schemas (ModelName.Selectable, etc.)
39
40
  */
40
41
  generateOperationalSchemas(model) {
41
42
  const baseSchemaName = `_${model.name}`;
42
- const modelName = model.name;
43
- return `export namespace ${modelName} {
44
- const schemas = getSchemas(${baseSchemaName});
45
- export const Selectable = schemas.Selectable;
46
- export const Insertable = schemas.Insertable;
47
- export const Updateable = schemas.Updateable;
48
- }`;
43
+ const operationalSchemaName = (0, naming_1.toPascalCase)(model.name);
44
+ return `export const ${operationalSchemaName} = getSchemas(${baseSchemaName});`;
49
45
  }
50
46
  /**
51
- * Generate TypeScript type exports as namespace
47
+ * Generate TypeScript type exports
52
48
  */
53
49
  generateTypeExports(model) {
54
- const name = model.name;
55
- return `export namespace ${name} {
56
- export type Select = Schema.Schema.Type<typeof ${name}.Selectable>;
57
- export type Insert = Schema.Schema.Type<typeof ${name}.Insertable>;
58
- export type Update = Schema.Schema.Type<typeof ${name}.Updateable>;
59
- export type SelectEncoded = Schema.Schema.Encoded<typeof ${name}.Selectable>;
60
- export type InsertEncoded = Schema.Schema.Encoded<typeof ${name}.Insertable>;
61
- export type UpdateEncoded = Schema.Schema.Encoded<typeof ${name}.Updateable>;
62
- }`;
50
+ const name = (0, naming_1.toPascalCase)(model.name);
51
+ // Application-side types (decoded - for repository layer)
52
+ const applicationTypes = `export type ${name}Select = Schema.Schema.Type<typeof ${name}.Selectable>;
53
+ export type ${name}Insert = Schema.Schema.Type<typeof ${name}.Insertable>;
54
+ export type ${name}Update = Schema.Schema.Type<typeof ${name}.Updateable>;`;
55
+ // Database-side encoded types (for queries layer)
56
+ const encodedTypes = `
57
+ export type ${name}SelectEncoded = Schema.Schema.Encoded<typeof ${name}.Selectable>;
58
+ export type ${name}InsertEncoded = Schema.Schema.Encoded<typeof ${name}.Insertable>;
59
+ export type ${name}UpdateEncoded = Schema.Schema.Encoded<typeof ${name}.Updateable>;`;
60
+ return applicationTypes + encodedTypes;
63
61
  }
64
62
  /**
65
63
  * Generate complete model schema (base + operational + types)
@@ -82,11 +80,16 @@ ${fieldDefinitions}
82
80
  `import { columnType, generated, getSchemas } from "prisma-effect-kysely";`,
83
81
  ];
84
82
  if (hasEnums) {
85
- // Import enums and their schemas with suffix pattern
86
- const enumNames = this.dmmf.datamodel.enums.map((e) => e.name);
87
- const enumImports = enumNames.join(', ');
88
- const schemaImports = enumNames.map(name => `${name}Schema`).join(', ');
89
- imports.push(`import { ${enumImports}, ${schemaImports} } from "./enums";`);
83
+ // Test 13: Import both enum and Schema wrapper
84
+ // Test 14: Use PascalCase naming
85
+ // Test 15: No SCREAMING_SNAKE_CASE
86
+ const enumImports = this.dmmf.datamodel.enums
87
+ .flatMap((e) => {
88
+ const baseName = (0, naming_1.toPascalCase)(e.name);
89
+ return [baseName, `${baseName}Schema`];
90
+ })
91
+ .join(', ');
92
+ imports.push(`import { ${enumImports} } from "./enums";`);
90
93
  }
91
94
  return `${header}\n\n${imports.join('\n')}`;
92
95
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/effect/generator.ts"],"names":[],"mappings":";;;AACA,iCAA2C;AAC3C,iCAAwC;AAGxC,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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AAQ,GAClB,MAAM,CAqCR"}
1
+ {"version":3,"file":"join-table.d.ts","sourceRoot":"","sources":["../../src/effect/join-table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAuBxD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,aAAa,EACxB,IAAI,EAAE,IAAI,CAAC,QAAQ,GAClB,MAAM,CAgCR"}
@@ -39,22 +39,16 @@ export const _${relationName} = Schema.Struct({
39
39
  ${columnAField},
40
40
  ${columnBField},
41
41
  });`;
42
- // Generate operational schemas as namespace
43
- const operationalSchema = `export namespace ${relationName} {
44
- const schemas = getSchemas(_${relationName});
45
- export const Selectable = schemas.Selectable;
46
- export const Insertable = schemas.Insertable;
47
- export const Updateable = schemas.Updateable;
48
- }`;
49
- // Generate Type exports as namespace
50
- const typeExports = `export namespace ${relationName} {
51
- export type Select = Schema.Schema.Type<typeof ${relationName}.Selectable>;
52
- export type Insert = Schema.Schema.Type<typeof ${relationName}.Insertable>;
53
- export type Update = Schema.Schema.Type<typeof ${relationName}.Updateable>;
54
- export type SelectEncoded = Schema.Schema.Encoded<typeof ${relationName}.Selectable>;
55
- export type InsertEncoded = Schema.Schema.Encoded<typeof ${relationName}.Insertable>;
56
- export type UpdateEncoded = Schema.Schema.Encoded<typeof ${relationName}.Updateable>;
57
- }`;
58
- return `${baseSchema}\n\n${operationalSchema}\n\n${typeExports}`;
42
+ // Generate operational schemas
43
+ const operationalSchema = `export const ${relationName} = getSchemas(_${relationName});`;
44
+ // Generate Type exports
45
+ const typeExports = `export type ${relationName}Select = Schema.Schema.Type<typeof ${relationName}.Selectable>;
46
+ export type ${relationName}Insert = Schema.Schema.Type<typeof ${relationName}.Insertable>;
47
+ export type ${relationName}Update = Schema.Schema.Type<typeof ${relationName}.Updateable>;`;
48
+ // Generate Encoded type exports
49
+ const encodedExports = `export type ${relationName}SelectEncoded = Schema.Schema.Encoded<typeof ${relationName}.Selectable>;
50
+ export type ${relationName}InsertEncoded = Schema.Schema.Encoded<typeof ${relationName}.Insertable>;
51
+ export type ${relationName}UpdateEncoded = Schema.Schema.Encoded<typeof ${relationName}.Updateable>;`;
52
+ return `${baseSchema}\n\n${operationalSchema}\n\n${typeExports}\n${encodedExports}`;
59
53
  }
60
54
  //# sourceMappingURL=join-table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"join-table.js","sourceRoot":"","sources":["../../src/effect/join-table.ts"],"names":[],"mappings":";;AAiCA,0DAwCC;AAtED;;;GAGG;AACH,SAAS,aAAa,CACpB,UAAkB,EAClB,MAAe;IAEf,IAAI,UAAU,KAAK,QAAQ,IAAI,MAAM,EAAE,CAAC;QACtC,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,SAAS,GAA2B;QACxC,MAAM,EAAE,eAAe;QACvB,GAAG,EAAE,eAAe;QACpB,MAAM,EAAE,eAAe;KACxB,CAAC;IAEF,OAAO,SAAS,CAAC,UAAU,CAAC,IAAI,gBAAgB,CAAC;AACnD,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,uBAAuB,CACrC,SAAwB,EACxB,IAAmB;IAEnB,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAEtG,0CAA0C;IAC1C,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAChE,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAEhE,0EAA0E;IAC1E,MAAM,YAAY,GAAG,mBAAmB,aAAa,+BAA+B,CAAC;IACrF,MAAM,YAAY,GAAG,mBAAmB,aAAa,+BAA+B,CAAC;IAErF,uBAAuB;IACvB,MAAM,UAAU,GAAG,MAAM,SAAS;gBACpB,YAAY;EAC1B,Y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AAM,SAAS;gBACpB,YAAY;EAC1B,YAAY;EACZ,YAAY;IACV,CAAC;IAEH,+BAA+B;IAC/B,MAAM,iBAAiB,GAAG,gBAAgB,YAAY,kBAAkB,YAAY,IAAI,CAAC;IAEzF,wBAAwB;IACxB,MAAM,WAAW,GAAG,eAAe,YAAY,sCAAsC,YAAY;cACrF,YAAY,sCAAsC,YAAY;cAC9D,YAAY,sCAAsC,YAAY,eAAe,CAAC;IAE1F,gCAAgC;IAChC,MAAM,cAAc,GAAG,eAAe,YAAY,gDAAgD,YAAY;cAClG,YAAY,gDAAgD,YAAY;cACxE,YAAY,gDAAgD,YAAY,eAAe,CAAC;IAEpG,OAAO,GAAG,UAAU,OAAO,iBAAiB,OAAO,WAAW,KAAK,cAAc,EAAE,CAAC;AACtF,CAAC"}
@@ -4,6 +4,7 @@ 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");
7
8
  /**
8
9
  * Prisma scalar type mapping to Effect Schema types
9
10
  * Uses const assertion to avoid type guards
@@ -42,9 +43,9 @@ function mapFieldToEffectType(field, dmmf) {
42
43
  // TDD: Satisfies tests 11-12 in field-type-generation.test.ts
43
44
  const enumDef = dmmf.datamodel.enums.find((e) => e.name === field.type);
44
45
  if (enumDef) {
45
- // Return Schema with suffix pattern (v1.7.0+)
46
- // Preserve original enum name with Schema suffix
47
- return `${enumDef.name}Schema`;
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');
48
49
  }
49
50
  // PRIORITY 5: Fallback to Unknown
50
51
  return "Schema.Unknown";
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/effect/type.ts"],"names":[],"mappings":";;AA8BA,oDA8BC;AAKD,wCAcC;AA9ED,yCAKw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D;IAC9D,MAAM,UAAU,GACd,iBAAiB,CAAC,KAAK,CAAC,IAAsC,CAAC,CAAC;IAClE,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,oCAAoC;IACpC,8DAA8D;IAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC;IACxE,IAAI,OAAO,EAAE,CAAC;QACZ,gDAAgD;QAChD,2CAA2C;QAC3C,OAAO,IAAA,qBAAY,EAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC5C,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"}
@@ -22,7 +22,7 @@ const orchestrator_1 = require("./orchestrator");
22
22
  __exportStar(require("../kysely/helpers"), exports);
23
23
  exports.generator = (0, generator_helper_1.generatorHandler)({
24
24
  onManifest: () => ({
25
- version: '1.6.0',
25
+ version: '1.7.1',
26
26
  defaultOutput: './generated',
27
27
  prettyName: 'Prisma Effect Kysely Generator',
28
28
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-effect-kysely",
3
- "version": "1.7.0",
3
+ "version": "1.7.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",
@@ -1,26 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,36 +0,0 @@
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
@@ -1 +0,0 @@
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"}