prisma-effect-kysely 1.12.0 → 1.13.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
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.13.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix Kysely table interface enum types to use Schema type extraction instead of raw enum names
8
+
9
+ Previously, Kysely table interfaces referenced raw enum type names (e.g., MATCH_TYPE) which weren't imported - only Schema wrappers (e.g., MatchTypeSchema) were imported. This caused "Cannot find name" TypeScript errors.
10
+
11
+ Now enum fields in Kysely interfaces use `Schema.Schema.Type<typeof EnumSchema>` to extract the type from the imported Schema wrapper.
12
+
13
+ ## 1.13.0
14
+
15
+ ### Minor Changes
16
+
17
+ - feat: use Schema.DateFromSelf for native Date types
18
+
19
+ BREAKING CHANGE: DateTime fields now use Schema.DateFromSelf instead of Schema.Date
20
+ - DateTime fields now encode to native Date objects instead of ISO strings
21
+ - This enables Kysely to work with native Date objects directly without requiring `.toISOString()` conversions
22
+ - Added Effect Schema validation for generator config and scaffold results
23
+ - Removed type assertions in favor of strict Schema validation
24
+ - Added multi-domain support with contract library scaffolding
25
+
3
26
  All notable changes to this project will be documented in this file.
4
27
 
5
28
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -10,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
33
  ### Fixed
11
34
 
12
35
  #### Dependency Configuration
36
+
13
37
  - **Fixed Effect as peer dependency** to prevent version conflicts and follow best practices
14
38
  - **Problem**: `effect` was listed as a regular dependency, causing potential version conflicts in user projects
15
39
  - **Solution**: Moved `effect` to `peerDependencies` (required, not optional)
@@ -23,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
47
  ### Removed
24
48
 
25
49
  #### Unused Dependencies
50
+
26
51
  - **Removed `@prisma/client` and `@prisma/dmmf`** from dependencies
27
52
  - **Analysis**: Code analysis revealed these packages are never imported in the codebase
28
53
  - **Impact**: Smaller package size, cleaner dependency tree
@@ -30,7 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
30
55
  ### Changed
31
56
 
32
57
  #### Package Structure
58
+
33
59
  **Before:**
60
+
34
61
  ```json
35
62
  "dependencies": {
36
63
  "@prisma/client": "6.16.3",
@@ -42,6 +69,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
42
69
  ```
43
70
 
44
71
  **After:**
72
+
45
73
  ```json
46
74
  "dependencies": {
47
75
  "@prisma/generator-helper": "^6.17.0",
@@ -56,14 +84,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
56
84
  ### Migration Guide
57
85
 
58
86
  **For New Users:**
87
+
59
88
  - Install Effect explicitly: `npm install effect` or `pnpm install effect`
60
89
 
61
90
  **For Existing Users:**
91
+
62
92
  - If you already have `effect` installed: No action needed
63
93
  - If you don't have `effect`: Run `npm install effect` or `pnpm install effect`
64
94
  - npm 7+ will automatically install peer dependencies
65
95
 
66
96
  **Benefits:**
97
+
67
98
  - ✅ Prevents Effect version conflicts between your project and the generator
68
99
  - ✅ You control which Effect version to use
69
100
  - ✅ Smaller package size (removed unused dependencies)
@@ -74,6 +105,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
74
105
  ### Fixed
75
106
 
76
107
  #### TypeScript Schema [TypeId] Preservation Bug
108
+
77
109
  - **Fixed `generated()` and `columnType()` helpers losing Schema [TypeId] symbol**
78
110
  - **Problem**: Helpers returned result of `.annotations()` directly, causing TypeScript compilation errors in generated code: `Property '[TypeId]' is missing in type 'typeof Date$'`
79
111
  - **Root Cause**: `.annotations()` doesn't automatically preserve Schema type for TypeScript's type system without explicit wrapping
@@ -88,6 +120,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
120
  ### Added
89
121
 
90
122
  #### Enhanced Test Coverage for Type Safety
123
+
91
124
  - **Added TypeScript compile-time validation tests** to prevent future regressions
92
125
  - Type assertions that fail at compile-time if Schema types lose [TypeId]
93
126
  - Runtime validation using `Schema.isSchema()` checks
@@ -103,16 +136,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
103
136
  ### Technical Details
104
137
 
105
138
  **Why the Bug Occurred**:
139
+
106
140
  - Effect Schema's `.annotations()` method creates a new schema with modified annotations
107
141
  - TypeScript's type inference doesn't automatically preserve the `Schema<T>` type with its `[TypeId]` symbol
108
142
  - Without `Schema.asSchema()` wrapper, TypeScript sees the result as a plain object losing Schema type information
109
143
 
110
144
  **Prevention Strategy**:
145
+
111
146
  - Always use explicit return types for functions returning schemas
112
147
  - Always wrap `.annotations()` results with `Schema.asSchema()`
113
148
  - Include both compile-time type assertions AND runtime validation in tests
114
149
 
115
150
  **Example Fix**:
151
+
116
152
  ```typescript
117
153
  // Before (incorrect):
118
154
  export const generated = <T>(schema: Schema.Schema<T>) => {
@@ -130,6 +166,7 @@ export const generated = <T>(schema: Schema.Schema<T>): Schema.Schema<T> => {
130
166
  ### Fixed
131
167
 
132
168
  #### TypeScript Type Inference for Generated Fields - Explicit Omit Types
169
+
133
170
  - **Generate explicit Insert type definitions using TypeScript's Omit utility for compile-time type safety**
134
171
  - **Problem**: v1.8.4 fixed runtime behavior (generated fields correctly omitted from Insertable schema), but TypeScript's `Schema.Schema.Type` inference couldn't see runtime AST field filtering, causing all fields to appear in Insert types
135
172
  - **Root Cause**: TypeScript's structural type inference works on static schema structure; runtime AST transformations are invisible to the type system
@@ -145,6 +182,7 @@ export const generated = <T>(schema: Schema.Schema<T>): Schema.Schema<T> => {
145
182
  - Non-ID fields with `@default` (e.g., `@default(now())`)
146
183
  - Fields with `@updatedAt` directive (auto-managed by database)
147
184
  - **Example**:
185
+
148
186
  ```typescript
149
187
  // Prisma schema:
150
188
  model User {
@@ -173,6 +211,7 @@ export const generated = <T>(schema: Schema.Schema<T>): Schema.Schema<T> => {
173
211
  name: 'John Doe'
174
212
  };
175
213
  ```
214
+
176
215
  - **Implementation**:
177
216
  - Added `getOmittedInsertFields()` helper in `src/effect/generator.ts` to identify fields during code generation
178
217
  - Uses DMMF properties: `hasDefaultValue` and `isUpdatedAt`
@@ -182,6 +221,7 @@ export const generated = <T>(schema: Schema.Schema<T>): Schema.Schema<T> => {
182
221
  - Tests: `src/__tests__/type-inference-generated.test.ts` (10 new tests, all passing)
183
222
 
184
223
  ### Technical Details
224
+
185
225
  - **Architecture**: Explicit type generation (industry standard for code generators)
186
226
  - **Rationale**: TypeScript's structural type inference works on static schema structure; runtime AST transformations are invisible to the type system
187
227
  - **Not a Workaround**: Standard practice when type inference can't capture runtime behavior (same approach as Prisma Client, Drizzle ORM, tRPC)
@@ -191,7 +231,9 @@ export const generated = <T>(schema: Schema.Schema<T>): Schema.Schema<T> => {
191
231
  - **Type Safety Guarantee**: Models without generated fields continue to use plain `Schema.Schema.Type` (no unnecessary `Omit`)
192
232
 
193
233
  ### Breaking Changes
234
+
194
235
  None - This is a non-breaking enhancement. The change is purely additive at the type level:
236
+
195
237
  - Runtime behavior unchanged from v1.8.4
196
238
  - Generated schemas remain the same
197
239
  - Only TypeScript type definitions become more restrictive (catching bugs earlier)
@@ -201,6 +243,7 @@ None - This is a non-breaking enhancement. The change is purely additive at the
201
243
  ### Fixed
202
244
 
203
245
  #### Native @effect/sql Pattern for Generated Fields
246
+
204
247
  - **Implemented native field filtering for `generated()` fields following @effect/sql Model.Generated pattern**
205
248
  - **Problem**: Generated fields (those with `@default` in Prisma schema) were incorrectly made optional in Insertable schema using `Union(T, Undefined)`, which doesn't properly reflect TypeScript optionality and doesn't follow Effect ecosystem patterns
206
249
  - **Solution**: OMIT generated fields entirely from Insertable schema (not make them optional) following @effect/sql's `Model.Generated` pattern
@@ -217,6 +260,7 @@ None - This is a non-breaking enhancement. The change is purely additive at the
217
260
  - Respects TypeScript optionality semantics (property optional `?:` vs value optional `| undefined`)
218
261
  - Cleaner implementation with fewer special cases
219
262
  - **Example**:
263
+
220
264
  ```typescript
221
265
  // Prisma schema:
222
266
  model Agent {
@@ -238,6 +282,7 @@ None - This is a non-breaking enhancement. The change is purely additive at the
238
282
  // Insert only requires 'name' - generated fields completely absent
239
283
  const insert: AgentInsert = { name: 'test' };
240
284
  ```
285
+
241
286
  - **Test Coverage**: 15 tests passing including comprehensive runtime validation and AST structure verification
242
287
  - Location: `src/kysely/helpers.ts:43-119, 188-224`
243
288
  - Tests: `src/__tests__/kysely-helpers.test.ts:186-283`
@@ -245,21 +290,28 @@ None - This is a non-breaking enhancement. The change is purely additive at the
245
290
  ### Known Limitations
246
291
 
247
292
  #### TypeScript Type Inference for Insertable Types
293
+
248
294
  - **TypeScript's `Schema.Schema.Type` inference still includes all fields in Insert types**
249
295
  - **Issue**: While runtime validation correctly omits generated fields, TypeScript type inference from `Schema.Schema.Type<typeof Model.Insertable>` cannot see runtime AST field filtering and still infers all fields as required
250
296
  - **Root Cause**: TypeScript's structural type inference works on the base schema structure before runtime transformations
251
297
  - **Workaround**: Use explicit type annotations or runtime validation (Effect Schema will filter out extra fields)
252
298
  - **Planned Fix**: Update code generator (`src/effect/generator.ts`) to create explicit TypeScript type definitions using `Omit` utility type:
299
+
253
300
  ```typescript
254
301
  // Current:
255
302
  export type AgentInsert = Schema.Schema.Type<typeof Agent.Insertable>;
256
303
 
257
304
  // Planned:
258
- export type AgentInsert = Omit<Schema.Schema.Type<typeof Agent.Insertable>, 'id' | 'session_id'>;
305
+ export type AgentInsert = Omit<
306
+ Schema.Schema.Type<typeof Agent.Insertable>,
307
+ 'id' | 'session_id'
308
+ >;
259
309
  ```
310
+
260
311
  - **Status**: Code generation fix planned for v1.9.0
261
312
 
262
313
  ### Technical Details
314
+
263
315
  - **Quality Assurance**: All 15 kysely-helpers tests passing, zero TypeScript errors in implementation
264
316
  - **Test Approach**: TDD (Test-Driven Development) - wrote failing tests first, then implemented to make them pass
265
317
  - **Research**: Validated approach against @effect/sql's `Model.Generated` pattern (official Effect ecosystem standard)
@@ -271,6 +323,7 @@ None - This is a non-breaking enhancement. The change is purely additive at the
271
323
  ### Added
272
324
 
273
325
  #### Semantic Join Table Column Names
326
+
274
327
  - **Generated join tables now use semantic snake_case field names** instead of Prisma's generic A/B columns
275
328
  - **Problem**: Prisma's implicit M2M join tables use non-semantic `A` and `B` column names, causing poor developer experience and forcing developers to remember alphabetical model ordering
276
329
  - **Solution**: Map semantic names like `product_id`, `product_tag_id` to actual database columns using Effect Schema's `propertySignature` with `fromKey`
@@ -280,6 +333,7 @@ None - This is a non-breaking enhancement. The change is purely additive at the
280
333
  - Type-safe bidirectional transformation (encode/decode)
281
334
  - Follows snake_case convention for database identifiers (Prisma best practice)
282
335
  - **Example**:
336
+
283
337
  ```typescript
284
338
  // Before (v1.8.2):
285
339
  export const _ProductToProductTag = Schema.Struct({
@@ -289,16 +343,22 @@ None - This is a non-breaking enhancement. The change is purely additive at the
289
343
 
290
344
  // After (v1.8.3):
291
345
  export const _ProductToProductTag = Schema.Struct({
292
- product_id: Schema.propertySignature(columnType(Schema.UUID, Schema.Never, Schema.Never)).pipe(Schema.fromKey("A")),
293
- product_tag_id: Schema.propertySignature(columnType(Schema.UUID, Schema.Never, Schema.Never)).pipe(Schema.fromKey("B")),
346
+ product_id: Schema.propertySignature(
347
+ columnType(Schema.UUID, Schema.Never, Schema.Never)
348
+ ).pipe(Schema.fromKey('A')),
349
+ product_tag_id: Schema.propertySignature(
350
+ columnType(Schema.UUID, Schema.Never, Schema.Never)
351
+ ).pipe(Schema.fromKey('B')),
294
352
  });
295
353
  ```
354
+
296
355
  - Location: `src/effect/join-table.ts:37-69`
297
356
  - New utility: `toSnakeCase()` in `src/utils/naming.ts:61-73`
298
357
 
299
358
  ### Fixed
300
359
 
301
360
  #### Unused Enum Type Imports
361
+
302
362
  - **types.ts now imports only Schema wrappers**: Eliminated TypeScript "declared but never read" warnings
303
363
  - **Problem**: Generated `types.ts` imported both plain enum types (e.g., `BudgetStatus`) and schema wrappers (e.g., `BudgetStatusSchema`), but only schema wrappers were used
304
364
  - **Solution**: Import generation now only includes `*Schema` wrappers
@@ -306,6 +366,7 @@ None - This is a non-breaking enhancement. The change is purely additive at the
306
366
  - Location: `src/effect/generator.ts:95-107`
307
367
 
308
368
  ### Technical Details
369
+
309
370
  - **Quality Assurance**: All 165 tests passing (15 naming tests + 10 join table tests + 140 existing), zero TypeScript errors
310
371
  - **Test Coverage**: New comprehensive tests for `toSnakeCase` utility and semantic join table column generation
311
372
  - **Documentation**: Updated CLAUDE.md with join table naming behavior explanation
@@ -320,6 +381,7 @@ None - This is a non-breaking enhancement. The change is purely additive at the
320
381
  This release transforms the project into an enterprise-ready open source package following 2025 best practices.
321
382
 
322
383
  #### Code Quality & Formatting
384
+
323
385
  - **ESLint 9**: Flat config format with TypeScript and Jest support (2025 standard)
324
386
  - Comprehensive rules for source and test files
325
387
  - Automatic unused import detection
@@ -338,6 +400,7 @@ This release transforms the project into an enterprise-ready open source package
338
400
  - `npm run format:check` - Check formatting without changes
339
401
 
340
402
  #### Governance Documentation
403
+
341
404
  - **SECURITY.md**: Professional vulnerability reporting process
342
405
  - Supported versions table
343
406
  - Response timeline SLAs (Critical: 7 days, High: 14 days, Medium: 30 days)
@@ -357,6 +420,7 @@ This release transforms the project into an enterprise-ready open source package
357
420
  - **Governance docs added to npm package**: All governance files now distributed with package
358
421
 
359
422
  #### Automated Dependency Management
423
+
360
424
  - **renovate.json**: Renovate Cloud (free tier) configuration
361
425
  - Weekly automated updates (Mondays at 3am UTC)
362
426
  - Auto-merge for patch updates after CI passes
@@ -369,6 +433,7 @@ This release transforms the project into an enterprise-ready open source package
369
433
  - Effect package pinned to prevent breaking changes
370
434
 
371
435
  ### Changed
436
+
372
437
  - **prepublishOnly script**: Now includes linting step (`npm run lint && npm run typecheck && npm run test && npm run build`)
373
438
  - **prepare script**: Updated from `npm run build` to `husky` for pre-commit hook initialization
374
439
  - **Source code cleanup**: Removed unused imports detected by ESLint
@@ -378,6 +443,7 @@ This release transforms the project into an enterprise-ready open source package
378
443
  - `src/effect/join-table.ts`: Prefixed unused parameter with underscore
379
444
 
380
445
  ### Technical Details
446
+
381
447
  - **Quality Assurance**: All 154 tests passing, zero TypeScript errors
382
448
  - **ESLint Status**: Passing with 2 minor warnings in test files (acceptable for test code)
383
449
  - **Build**: Clean compilation to dist/ directory
@@ -385,6 +451,7 @@ This release transforms the project into an enterprise-ready open source package
385
451
  - **Compliance**: Follows OpenSSF Best Practices baseline
386
452
 
387
453
  ### Dependencies
454
+
388
455
  - **Added devDependencies**:
389
456
  - `@eslint/js@^9.37.0`
390
457
  - `typescript-eslint@^8.46.0`
@@ -421,15 +488,15 @@ This release transforms the project into an enterprise-ready open source package
421
488
  ```typescript
422
489
  // Generated from: enum ACTIVE_STATUS { ACTIVE, INACTIVE }
423
490
  export enum ACTIVE_STATUS {
424
- ACTIVE = "ACTIVE",
425
- INACTIVE = "INACTIVE"
491
+ ACTIVE = 'ACTIVE',
492
+ INACTIVE = 'INACTIVE',
426
493
  }
427
494
  export const ActiveStatusSchema = Schema.Enums(ACTIVE_STATUS);
428
495
  export type ActiveStatusType = Schema.Schema.Type<typeof ActiveStatusSchema>;
429
496
 
430
497
  // Usage:
431
- const status = ACTIVE_STATUS.ACTIVE; // Direct enum access
432
- Schema.decodeSync(ActiveStatusSchema)(input); // Validation
498
+ const status = ACTIVE_STATUS.ACTIVE; // Direct enum access
499
+ Schema.decodeSync(ActiveStatusSchema)(input); // Validation
433
500
  ```
434
501
 
435
502
  ## [1.5.3] - 2025-10-12
@@ -452,6 +519,7 @@ Schema.decodeSync(ActiveStatusSchema)(input); // Validation
452
519
  - Generates operational schemas (`Selectable`, `Insertable`, `Updateable`) for join tables
453
520
  - Both `Type` and `Encoded` exports for complete type coverage
454
521
  - Example:
522
+
455
523
  ```typescript
456
524
  // Generated join table schema
457
525
  export const _CategoryToPost = Schema.Struct({
@@ -468,6 +536,7 @@ Schema.decodeSync(ActiveStatusSchema)(input); // Validation
468
536
  _CategoryToPost: Schema.Schema.Encoded<typeof _CategoryToPost>;
469
537
  }
470
538
  ```
539
+
471
540
  - **Benefits**:
472
541
  - ✨ Type-safe Kysely queries through intermediate tables
473
542
  - ✨ Complete database schema representation
@@ -515,9 +584,9 @@ Schema.decodeSync(ActiveStatusSchema)(input); // Validation
515
584
  - ✅ **New Pattern**: Native TypeScript enum + Effect Schema wrapper
516
585
  ```typescript
517
586
  export enum ProductStatus {
518
- ACTIVE = "ACTIVE",
519
- DRAFT = "DRAFT",
520
- ARCHIVED = "ARCHIVED"
587
+ ACTIVE = 'ACTIVE',
588
+ DRAFT = 'DRAFT',
589
+ ARCHIVED = 'ARCHIVED',
521
590
  }
522
591
  export const ProductStatusSchema = Schema.Enums(ProductStatus);
523
592
  export type ProductStatusType = Schema.Schema.Type<typeof ProductStatusSchema>;
@@ -562,15 +631,18 @@ Schema.decodeSync(ActiveStatusSchema)(input); // Validation
562
631
  ### Technical Details
563
632
 
564
633
  **TDD Implementation**: All changes developed using Test-Driven Development (Red-Green-Refactor)
634
+
565
635
  - 18+ new tests covering enum generation, property access, field mapping, and imports
566
636
  - All 134 tests passing with strict TypeScript configuration
567
637
  - Zero type coercions - maintains full type safety
568
638
 
569
639
  **Expert Validation**:
640
+
570
641
  - ✅ Effect Architecture Specialist: Confirmed Schema.Enums is canonical pattern for Effect v3.18+
571
642
  - ✅ TypeScript Pro: Validated all optimizations are type-safe with zero runtime overhead
572
643
 
573
644
  **Changed Files**:
645
+
574
646
  - `src/effect/enum.ts`: Complete rewrite of enum generation logic
575
647
  - `src/effect/type.ts`: Updated to return Schema wrappers for enum fields
576
648
  - `src/effect/generator.ts`: Optimized import generation, removed Array.from()
@@ -579,6 +651,7 @@ Schema.decodeSync(ActiveStatusSchema)(input); // Validation
579
651
  - `src/__tests__/helpers/dmmf-mocks.ts`: New test helpers without type coercions
580
652
 
581
653
  **Test Coverage**:
654
+
582
655
  - `src/__tests__/enum-generation.test.ts`: Tests 1-6 (Schema.Enums pattern)
583
656
  - `src/__tests__/enum-property-access.test.ts`: Tests 7-10 (property access validation)
584
657
  - `src/__tests__/field-type-generation.test.ts`: Tests 11-12 (field type mapping)
@@ -588,21 +661,23 @@ Schema.decodeSync(ActiveStatusSchema)(input); // Validation
588
661
  **Migration Guide**:
589
662
 
590
663
  Before (v1.4.x):
664
+
591
665
  ```typescript
592
666
  // Generated code
593
- export const PRODUCT_STATUS = Schema.Literal("ACTIVE", "DRAFT", "ARCHIVED");
667
+ export const PRODUCT_STATUS = Schema.Literal('ACTIVE', 'DRAFT', 'ARCHIVED');
594
668
 
595
669
  // Usage
596
670
  const status = PRODUCT_STATUS.literals[0]; // "ACTIVE"
597
671
  ```
598
672
 
599
673
  After (v1.5.0):
674
+
600
675
  ```typescript
601
676
  // Generated code
602
677
  export enum ProductStatus {
603
- ACTIVE = "ACTIVE",
604
- DRAFT = "DRAFT",
605
- ARCHIVED = "ARCHIVED"
678
+ ACTIVE = 'ACTIVE',
679
+ DRAFT = 'DRAFT',
680
+ ARCHIVED = 'ARCHIVED',
606
681
  }
607
682
  export const ProductStatusSchema = Schema.Enums(ProductStatus);
608
683
 
@@ -630,6 +705,7 @@ const status = ProductStatus.ACTIVE; // "ACTIVE"
630
705
  **Problem**: When TypeScript compiled helper functions to `.d.ts` files, the return types of AST transformation functions (`selectable()`, `insertable()`, `updateable()`) were inferred as `S.Schema<unknown, unknown, never>` instead of preserving the Kysely mapped types. This caused downstream type resolution to fail when consumers used compiled declaration files (dist/ paths) instead of source files.
631
706
 
632
707
  **Solution**: Added explicit return type annotations with type assertions to all helper functions:
708
+
633
709
  - `selectable()` → `: S.Schema<Selectable<Type>, Selectable<Encoded>, never>`
634
710
  - `insertable()` → `: S.Schema<Insertable<Type>, Insertable<Encoded>, never>`
635
711
  - `updateable()` → `: S.Schema<Updateable<Type>, Updateable<Encoded>, never>`
@@ -640,6 +716,7 @@ const status = ProductStatus.ACTIVE; // "ACTIVE"
640
716
  **Testing**: Added comprehensive test suite (`declaration-inference.test.ts`) with 7 tests validating type preservation in compiled declarations, following TDD principles (Red-Green-Refactor).
641
717
 
642
718
  **Changed files:**
719
+
643
720
  - `src/kysely/helpers.ts`: Added return type annotations (4 functions)
644
721
  - `src/__tests__/declaration-inference.test.ts`: New test suite (260 lines)
645
722
 
@@ -669,6 +746,7 @@ const status = ProductStatus.ACTIVE; // "ACTIVE"
669
746
  **Impact**: Projects using `prisma-effect-kysely` v1.4.0 or earlier may have experienced TypeScript compilation errors when using `Schema.decode()` or `Schema.decodeUnknownSync()`. This release resolves those errors without requiring any code changes in consuming projects.
670
747
 
671
748
  **Changed files:**
749
+
672
750
  - `src/kysely/helpers.ts`: Added `S.asSchema()` wrappers (6 locations)
673
751
  - `src/prisma/enum.ts`: Added return type annotation
674
752
  - `src/prisma/generator.ts`: Added return type annotations (3 methods)
@@ -699,6 +777,7 @@ The generator now converts all model names to PascalCase when creating TypeScrip
699
777
  **Impact**: Projects using snake_case model names will see different export names (breaking change for those projects). Projects using PascalCase models (recommended Prisma convention) will see no changes.
700
778
 
701
779
  **Changed files:**
780
+
702
781
  - `src/utils/naming.ts`: New naming utility
703
782
  - `src/effect/generator.ts`: Updated to use PascalCase for all exports
704
783
  - `src/__tests__/fixtures/test.prisma`: Added snake_case test model
@@ -725,20 +804,24 @@ The generator now converts all model names to PascalCase when creating TypeScrip
725
804
  ### Why This Matters
726
805
 
727
806
  Effect Schema has bidirectional transformations:
807
+
728
808
  - **Application types** (`Schema.Schema.Type`) - Decoded types with `Date` objects (for repository layer)
729
809
  - **Database types** (`Schema.Schema.Encoded`) - Encoded types with ISO strings (for queries layer)
730
810
 
731
811
  Previously, only Application types were exported, forcing queries to use `any` types. Now both sides of the transformation are properly typed.
732
812
 
733
813
  **Example Usage:**
814
+
734
815
  ```typescript
735
816
  import { agentInsertEncoded } from '@libs/types';
736
817
 
737
818
  // Queries layer - uses Encoded types (ISO strings)
738
- insert: (rowData: agentInsertEncoded) => db.insertInto('agent').values(rowData)
819
+ insert: (rowData: agentInsertEncoded) => db.insertInto('agent').values(rowData);
739
820
 
740
821
  // Repository layer - uses Application types (Date objects)
741
- const input: CreateAgentInput = { /* ... Date objects ... */ };
822
+ const input: CreateAgentInput = {
823
+ /* ... Date objects ... */
824
+ };
742
825
  const encoded = Schema.encode(AgentSchemas.Insertable)(input); // Encoded to ISO strings
743
826
  ```
744
827
 
@@ -25,6 +25,7 @@ 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
  * Map Prisma scalar types to plain TypeScript types (for Kysely)
28
+ * For enums, uses Schema.Schema.Type extraction to get the type from the imported Schema
28
29
  */
29
30
  export declare function mapPrismaTypeToTS(field: DMMF.Field, _dmmf: DMMF.Document): string;
30
31
  /**
@@ -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;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;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,KA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AAC,KAAK,UAMrE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,UAQ5E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,UA2BxE;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAY5E;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,UAe7E;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,EAC7B,IAAI,EAAE,IAAI,CAAC,QAAQ,GAClB,MAAM,CAcR;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"}
@@ -63,11 +63,13 @@ function buildKyselyFieldType(baseFieldType, field) {
63
63
  }
64
64
  /**
65
65
  * Map Prisma scalar types to plain TypeScript types (for Kysely)
66
+ * For enums, uses Schema.Schema.Type extraction to get the type from the imported Schema
66
67
  */
67
68
  function mapPrismaTypeToTS(field, _dmmf) {
68
- // Handle enums
69
+ // Handle enums - use Schema type extraction since we only import Schema wrappers
69
70
  if (field.kind === 'enum') {
70
- return field.type;
71
+ const schemaName = (0, naming_1.toEnumSchemaName)(field.type);
72
+ return `Schema.Schema.Type<typeof ${schemaName}>`;
71
73
  }
72
74
  // UUID detection
73
75
  if ((0, type_1.isUuidField)(field)) {
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/kysely/type.ts"],"names":[],"mappings":";;AASA,0CAEC;AAMD,wCAEC;AAKD,gDAOC;AAKD,8CAMC;AAMD,oDAQC;AAKD,8CA0BC;AAMD,8DAYC;AAKD,0DAeC;AAKD,oEAkBC;AAMD,4DAIC;AAMD,8EAGC;AAKD,kDAeC;AA1LD,yCAAyF;AAEzF,4CAA+C;AAE/C;;;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,EAAE,KAAiB;IACrE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,cAAc,SAAS,+BAA+B,CAAC;IAChE,CAAC;SAAM,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,aAAa,SAAS,GAAG,CAAC;IACnC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,SAAiB,EAAE,KAAiB;IACpE,MAAM,MAAM,GAAG,IAAA,qBAAc,EAAC,KAAK,CAAC,CAAC;IACrC,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;QAChD,OAAO,4BAA4B,SAAS,0BAA0B,MAAM,KAAK,CAAC;IACpF,CAAC;IACD,OAAO,SAAS,CAAC;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C;IAC5C,OAAO,KAAK,SAAS,KAAK,UAAU,QAAQ,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,SAAgB,iCAAiC,CAAC,SAAwB;IACxE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC;IAC9C,OAAO,KAAK,SAAS,KAAK,YAAY,QAAQ,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CACjC,MAA6B,EAC7B,aAA8B,EAAE;IAEhC,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjF,MAAM,gBAAgB,GACpB,UAAU,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"}
@@ -27,4 +27,15 @@ export declare function toPascalCase(str: string, suffix?: string): string;
27
27
  * toSnakeCase('ProductStatus') // 'product_status'
28
28
  */
29
29
  export declare function toSnakeCase(str: string): string;
30
+ /**
31
+ * Convert an enum name to its Schema wrapper name
32
+ * Used for generating type references in Kysely interfaces
33
+ *
34
+ * @param enumName - The original enum name (e.g., MATCH_TYPE, AD_STATUS)
35
+ *
36
+ * @example
37
+ * toEnumSchemaName('MATCH_TYPE') // 'MatchTypeSchema'
38
+ * toEnumSchemaName('AD_STATUS') // 'AdStatusSchema'
39
+ */
40
+ export declare function toEnumSchemaName(enumName: string): string;
30
41
  //# sourceMappingURL=naming.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/utils/naming.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,UA8BxD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,UAYtC"}
1
+ {"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/utils/naming.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,UA8BxD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,UAYtC;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,UAEhD"}
@@ -5,6 +5,7 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.toPascalCase = toPascalCase;
7
7
  exports.toSnakeCase = toSnakeCase;
8
+ exports.toEnumSchemaName = toEnumSchemaName;
8
9
  /**
9
10
  * Convert any string to PascalCase with optional suffix
10
11
  * Handles: snake_case, camelCase, kebab-case, or mixed formats
@@ -70,4 +71,17 @@ function toSnakeCase(str) {
70
71
  // Convert to lowercase
71
72
  .toLowerCase());
72
73
  }
74
+ /**
75
+ * Convert an enum name to its Schema wrapper name
76
+ * Used for generating type references in Kysely interfaces
77
+ *
78
+ * @param enumName - The original enum name (e.g., MATCH_TYPE, AD_STATUS)
79
+ *
80
+ * @example
81
+ * toEnumSchemaName('MATCH_TYPE') // 'MatchTypeSchema'
82
+ * toEnumSchemaName('AD_STATUS') // 'AdStatusSchema'
83
+ */
84
+ function toEnumSchemaName(enumName) {
85
+ return toPascalCase(enumName, 'Schema');
86
+ }
73
87
  //# sourceMappingURL=naming.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"naming.js","sourceRoot":"","sources":["../../src/utils/naming.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAeH,oCA8BC;AAaD,kCA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AC7C,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;SAAM,CAAC;QACN,kCAAkC;QAClC,UAAU,GAAG,KAAK;aACf,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,uBAAuB;aACzD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;aACzE,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;AACxD,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,WAAW,CAAC,GAAW;IACrC,IAAI,CAAC,GAAG;QAAE,OAAO,GAAG,CAAC;IAErB,OAAO,CACL,GAAG;QACD,+DAA+D;SAC9D,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;QAC3B,uCAAuC;SACtC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAClB,uBAAuB;SACtB,WAAW,EAAE,CACjB,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-effect-kysely",
3
- "version": "1.12.0",
3
+ "version": "1.13.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",
@@ -81,6 +81,7 @@
81
81
  }
82
82
  },
83
83
  "devDependencies": {
84
+ "@changesets/cli": "^2.29.8",
84
85
  "@eslint/js": "^9.39.1",
85
86
  "@prisma/internals": "^7.0.0",
86
87
  "@types/jest": "^30.0.0",