prisma-effect-kysely 4.5.3 → 4.6.0
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 +47 -0
- package/dist/kysely/helpers.d.ts +69 -36
- package/dist/kysely/helpers.d.ts.map +1 -1
- package/dist/kysely/helpers.js +15 -4
- package/dist/kysely/helpers.js.map +1 -1
- package/package.json +16 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fix: Use mapped type pattern to survive TypeScript declaration emit
|
|
8
|
+
|
|
9
|
+
Previously, the `Generated<T>` type used static properties that TypeScript would inline/simplify during declaration emit (.d.ts generation). This caused the brand to be lost when consumers imported the types, making `CustomInsertable` unable to properly filter out generated fields.
|
|
10
|
+
|
|
11
|
+
This release adopts Effect's proven `Brand<K>` pattern using mapped types:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// Effect's Brand pattern - mapped types cannot be simplified
|
|
15
|
+
interface Brand<K> {
|
|
16
|
+
readonly [BrandTypeId]: { readonly [k in K]: K };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Our new VariantMarker pattern
|
|
20
|
+
interface VariantMarker<I, U> {
|
|
21
|
+
readonly [VariantTypeId]: {
|
|
22
|
+
readonly [K in 'insert' | 'update']: K extends 'insert' ? I : U;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Key changes:
|
|
28
|
+
- Added `VariantMarker<I, U>` interface with mapped type that survives declaration emit
|
|
29
|
+
- Updated `Generated<T>` to use `VariantMarker<never, T>`
|
|
30
|
+
- Updated `ColumnType<S, I, U>` to use `VariantMarker<I, U>`
|
|
31
|
+
- Added `GeneratedSchema<S>` named interface for `generated()` return type (named interfaces are preserved)
|
|
32
|
+
- Updated type extractors to use `VariantMarker` for reliable type inference
|
|
33
|
+
|
|
34
|
+
This is a **breaking change** for internal type structure but **not breaking** for consumers:
|
|
35
|
+
- `Insertable<T>`, `Selectable<T>`, `Updateable<T>` work identically
|
|
36
|
+
- Generated types must be regenerated after upgrading
|
|
37
|
+
|
|
38
|
+
## 4.5.4
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- 2d2a0e9: Fix: properly brand `generated()` return type for type-level Insertable filtering
|
|
43
|
+
|
|
44
|
+
The `generated()` function was returning `Schema<SType, ...>` instead of `Schema<Generated<SType>, ...>`, which meant the Generated brand was not present at the type level.
|
|
45
|
+
|
|
46
|
+
Also fixed `Generated<T>` type to use `__insert__: never` (instead of `T | undefined`) to match the runtime behavior where `Insertable()` completely filters out generated fields rather than making them optional.
|
|
47
|
+
|
|
48
|
+
This fixes type errors in consuming projects where `Insertable<T>` was including all fields instead of excluding generated ones.
|
|
49
|
+
|
|
3
50
|
## 4.5.3
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
package/dist/kysely/helpers.d.ts
CHANGED
|
@@ -24,6 +24,32 @@ import type { DeepMutable } from 'effect/Types';
|
|
|
24
24
|
export type { KyselySelectable, KyselyInsertable, KyselyUpdateable, KyselyColumnType, KyselyGenerated, };
|
|
25
25
|
export declare const ColumnTypeId: unique symbol;
|
|
26
26
|
export declare const GeneratedId: unique symbol;
|
|
27
|
+
/**
|
|
28
|
+
* Symbol for VariantMarker - used in mapped type pattern that survives declaration emit.
|
|
29
|
+
*/
|
|
30
|
+
export declare const VariantTypeId: unique symbol;
|
|
31
|
+
export type VariantTypeId = typeof VariantTypeId;
|
|
32
|
+
/**
|
|
33
|
+
* Variant marker using mapped type pattern from Effect's Brand.
|
|
34
|
+
*
|
|
35
|
+
* TypeScript cannot simplify mapped types that depend on generic parameters.
|
|
36
|
+
* This ensures the variant information survives declaration emit (.d.ts generation).
|
|
37
|
+
*
|
|
38
|
+
* Pattern derived from Effect's Brand<K>:
|
|
39
|
+
* ```typescript
|
|
40
|
+
* readonly [BrandTypeId]: { readonly [k in K]: K } // Mapped type - cannot be simplified!
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Our pattern uses a conditional type within the mapped type to encode both I and U:
|
|
44
|
+
* ```typescript
|
|
45
|
+
* readonly [VariantTypeId]: { readonly [K in "insert" | "update"]: K extends "insert" ? I : U }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export interface VariantMarker<in out I, in out U> {
|
|
49
|
+
readonly [VariantTypeId]: {
|
|
50
|
+
readonly [K in 'insert' | 'update']: K extends 'insert' ? I : U;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
27
53
|
/**
|
|
28
54
|
* Branded ColumnType that extends S while carrying phantom insert/update type information.
|
|
29
55
|
*
|
|
@@ -32,7 +58,7 @@ export declare const GeneratedId: unique symbol;
|
|
|
32
58
|
* 2. Schema.make<KyselyColumnType<...>>(ast) doesn't work because AST represents S, not the struct
|
|
33
59
|
* 3. Our ColumnType<S,I,U> = S & Brand IS a subtype of S, so Schema.make works correctly
|
|
34
60
|
*
|
|
35
|
-
*
|
|
61
|
+
* Uses VariantMarker with mapped types to survive TypeScript declaration emit.
|
|
36
62
|
*
|
|
37
63
|
* Usage is identical to Kysely's ColumnType:
|
|
38
64
|
* ```typescript
|
|
@@ -40,30 +66,24 @@ export declare const GeneratedId: unique symbol;
|
|
|
40
66
|
* type CreatedAt = ColumnType<Date, Date | undefined, Date>; // Optional on insert
|
|
41
67
|
* ```
|
|
42
68
|
*/
|
|
43
|
-
export type ColumnType<S, I = S, U = S> = S &
|
|
44
|
-
readonly [ColumnTypeId]: {
|
|
45
|
-
readonly __insert__: I;
|
|
46
|
-
readonly __update__: U;
|
|
47
|
-
};
|
|
48
|
-
readonly __select__: S;
|
|
49
|
-
};
|
|
69
|
+
export type ColumnType<S, I = S, U = S> = S & VariantMarker<I, U>;
|
|
50
70
|
/**
|
|
51
71
|
* Branded Generated type for database-generated fields.
|
|
52
72
|
*
|
|
53
|
-
*
|
|
73
|
+
* Follows @effect/sql Model.Generated pattern - the field is:
|
|
54
74
|
* - Required on select (T)
|
|
55
|
-
* -
|
|
75
|
+
* - EXCLUDED from insert (never) - database generates the value
|
|
56
76
|
* - Allowed on update (T)
|
|
57
77
|
*
|
|
58
|
-
*
|
|
78
|
+
* This matches the runtime behavior of Insertable() which filters out
|
|
79
|
+
* generated fields entirely (not optional, completely absent).
|
|
80
|
+
*
|
|
81
|
+
* Uses VariantMarker with mapped types to survive TypeScript declaration emit.
|
|
82
|
+
* The mapped type pattern `[_ in "insert"]: I` cannot be simplified by TypeScript,
|
|
83
|
+
* ensuring the brand is preserved in .d.ts files.
|
|
59
84
|
*/
|
|
60
|
-
export type Generated<T> = T & {
|
|
85
|
+
export type Generated<T> = T & VariantMarker<never, T> & {
|
|
61
86
|
readonly [GeneratedId]: true;
|
|
62
|
-
readonly [ColumnTypeId]: {
|
|
63
|
-
readonly __insert__: T | undefined;
|
|
64
|
-
readonly __update__: T;
|
|
65
|
-
};
|
|
66
|
-
readonly __select__: T;
|
|
67
87
|
};
|
|
68
88
|
/**
|
|
69
89
|
* Mark a field as having different types for select/insert/update
|
|
@@ -76,6 +96,18 @@ export type Generated<T> = T & {
|
|
|
76
96
|
* in generated code via type declarations, not via runtime type assertions.
|
|
77
97
|
*/
|
|
78
98
|
export declare const columnType: <SType, SEncoded, SR, IType, IEncoded, IR, UType, UEncoded, UR>(selectSchema: Schema.Schema<SType, SEncoded, SR>, insertSchema: Schema.Schema<IType, IEncoded, IR>, updateSchema: Schema.Schema<UType, UEncoded, UR>) => Schema.Schema<SType, SEncoded, SR>;
|
|
99
|
+
/**
|
|
100
|
+
* Interface for Generated schema - preserves type parameter in declaration emit.
|
|
101
|
+
*
|
|
102
|
+
* Named interfaces with type parameters are preserved by TypeScript in declaration files,
|
|
103
|
+
* unlike anonymous intersection types which may be simplified.
|
|
104
|
+
*
|
|
105
|
+
* This follows the Schema.brand pattern from Effect which returns a named interface.
|
|
106
|
+
*/
|
|
107
|
+
export interface GeneratedSchema<S extends Schema.Schema.All> extends Schema.Schema<Generated<Schema.Schema.Type<S>>, Generated<Schema.Schema.Encoded<S>>, Schema.Schema.Context<S>> {
|
|
108
|
+
/** The original schema before Generated wrapper */
|
|
109
|
+
readonly from: S;
|
|
110
|
+
}
|
|
79
111
|
/**
|
|
80
112
|
* Mark a field as database-generated (omitted from insert)
|
|
81
113
|
* Used for fields with @default
|
|
@@ -84,32 +116,33 @@ export declare const columnType: <SType, SEncoded, SR, IType, IEncoded, IR, UTyp
|
|
|
84
116
|
* - Present in select and update schemas
|
|
85
117
|
* - OMITTED from insert schema (not optional, completely absent)
|
|
86
118
|
*
|
|
87
|
-
* Returns
|
|
88
|
-
*
|
|
119
|
+
* Returns a GeneratedSchema<S> which:
|
|
120
|
+
* 1. Is a named interface (preserved in declaration emit)
|
|
121
|
+
* 2. Contains the Generated<T> brand using VariantMarker (mapped types survive emit)
|
|
122
|
+
* 3. Includes the original schema via `from` property
|
|
123
|
+
*
|
|
124
|
+
* This enables CustomInsertable to filter out generated fields at compile time.
|
|
89
125
|
*/
|
|
90
|
-
export declare const generated: <
|
|
126
|
+
export declare const generated: <S extends Schema.Schema.All>(schema: S) => GeneratedSchema<S>;
|
|
91
127
|
/**
|
|
92
|
-
* Extract the insert type from a field:
|
|
93
|
-
* - ColumnType<S, I, U> -> I (via
|
|
94
|
-
* - Generated<T> ->
|
|
128
|
+
* Extract the insert type from a field using VariantMarker:
|
|
129
|
+
* - ColumnType<S, I, U> -> I (via VariantMarker)
|
|
130
|
+
* - Generated<T> -> never (via VariantMarker)
|
|
95
131
|
* - Other types -> as-is
|
|
132
|
+
*
|
|
133
|
+
* Uses the mapped type in VariantMarker which survives declaration emit.
|
|
134
|
+
* TypeScript cannot simplify `[_ in "insert"]: I` so the type information is preserved.
|
|
96
135
|
*/
|
|
97
|
-
type ExtractInsertType<T> = T extends
|
|
98
|
-
readonly [ColumnTypeId]: {
|
|
99
|
-
readonly __insert__: infer I;
|
|
100
|
-
};
|
|
101
|
-
} ? I : T;
|
|
136
|
+
type ExtractInsertType<T> = T extends VariantMarker<infer I, unknown> ? I : T;
|
|
102
137
|
/**
|
|
103
|
-
* Extract the update type from a field:
|
|
104
|
-
* - ColumnType<S, I, U> -> U (via
|
|
105
|
-
* - Generated<T> -> T (via
|
|
138
|
+
* Extract the update type from a field using VariantMarker:
|
|
139
|
+
* - ColumnType<S, I, U> -> U (via VariantMarker)
|
|
140
|
+
* - Generated<T> -> T (via VariantMarker)
|
|
106
141
|
* - Other types -> as-is
|
|
142
|
+
*
|
|
143
|
+
* Uses the mapped type in VariantMarker which survives declaration emit.
|
|
107
144
|
*/
|
|
108
|
-
type ExtractUpdateType<T> = T extends
|
|
109
|
-
readonly [ColumnTypeId]: {
|
|
110
|
-
readonly __update__: infer U;
|
|
111
|
-
};
|
|
112
|
-
} ? U : T;
|
|
145
|
+
type ExtractUpdateType<T> = T extends VariantMarker<unknown, infer U> ? U : T;
|
|
113
146
|
/**
|
|
114
147
|
* Custom Insertable type that properly omits fields with `never` insert types.
|
|
115
148
|
* This handles ColumnType<S, never, U> fields (read-only ID fields).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/kysely/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,EACV,UAAU,IAAI,gBAAgB,EAC9B,UAAU,IAAI,gBAAgB,EAC9B,UAAU,IAAI,gBAAgB,EAC9B,UAAU,IAAI,gBAAgB,EAC9B,SAAS,IAAI,eAAe,EAC7B,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,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AC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;CAAE,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
package/dist/kysely/helpers.js
CHANGED
|
@@ -2,6 +2,10 @@ import { Schema } from 'effect';
|
|
|
2
2
|
import * as AST from 'effect/SchemaAST';
|
|
3
3
|
export const ColumnTypeId = Symbol.for('/ColumnTypeId');
|
|
4
4
|
export const GeneratedId = Symbol.for('/GeneratedId');
|
|
5
|
+
/**
|
|
6
|
+
* Symbol for VariantMarker - used in mapped type pattern that survives declaration emit.
|
|
7
|
+
*/
|
|
8
|
+
export const VariantTypeId = Symbol.for('prisma-effect-kysely/VariantType');
|
|
5
9
|
/**
|
|
6
10
|
* Mark a field as having different types for select/insert/update
|
|
7
11
|
* Used for ID fields with @default (read-only)
|
|
@@ -29,12 +33,19 @@ export const columnType = (selectSchema, insertSchema, updateSchema) => {
|
|
|
29
33
|
* - Present in select and update schemas
|
|
30
34
|
* - OMITTED from insert schema (not optional, completely absent)
|
|
31
35
|
*
|
|
32
|
-
* Returns
|
|
33
|
-
*
|
|
36
|
+
* Returns a GeneratedSchema<S> which:
|
|
37
|
+
* 1. Is a named interface (preserved in declaration emit)
|
|
38
|
+
* 2. Contains the Generated<T> brand using VariantMarker (mapped types survive emit)
|
|
39
|
+
* 3. Includes the original schema via `from` property
|
|
40
|
+
*
|
|
41
|
+
* This enables CustomInsertable to filter out generated fields at compile time.
|
|
34
42
|
*/
|
|
35
43
|
export const generated = (schema) => {
|
|
36
|
-
// Return annotated schema
|
|
37
|
-
|
|
44
|
+
// Return annotated schema with Generated brand at type level
|
|
45
|
+
// The runtime annotation enables filtering in Insertable() function
|
|
46
|
+
// The type-level brand enables filtering in CustomInsertable type utility
|
|
47
|
+
const annotated = schema.annotations({ [GeneratedId]: true });
|
|
48
|
+
return Object.assign(annotated, { from: schema });
|
|
38
49
|
};
|
|
39
50
|
/**
|
|
40
51
|
* Schema for validating column type annotations structure
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/kysely/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAwCxC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/kysely/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAwCxC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAkB,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAgF3F;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,YAAgD,EAChD,YAAgD,EAChD,YAAgD,EACZ,EAAE;IACtC,MAAM,OAAO,GACX;QACE,YAAY;QACZ,YAAY;QACZ,YAAY;KACb,CAAC;IACJ,6DAA6D;IAC7D,OAAO,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/D,CAAC,CAAC;AAmBF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAA8B,MAAS,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IAEF,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAItC,CAAC;AACJ,CAAC;AAyDD,MAAM,UAAU,UAAU,CAIxB,UAAsB,EACtB,QAAmB;IAQnB,MAAM,kBAAkB,GAAG,UAA2C,CAAC;IAEvE,MAAM,IAAI,GAAwB;QAChC,KAAK,EAAE,UAAU;QACjB,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC;QAC1C,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC;QAC1C,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC;KAC3C,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-effect-kysely",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
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",
|
|
@@ -51,23 +51,6 @@
|
|
|
51
51
|
"node": ">=20.0.0",
|
|
52
52
|
"pnpm": ">=8.0.0"
|
|
53
53
|
},
|
|
54
|
-
"packageManager": "pnpm@10.0.0",
|
|
55
|
-
"scripts": {
|
|
56
|
-
"build": "tsc -p tsconfig.lib.json",
|
|
57
|
-
"prepare": "husky",
|
|
58
|
-
"test": "vitest run",
|
|
59
|
-
"test:watch": "vitest",
|
|
60
|
-
"test:coverage": "vitest run --coverage",
|
|
61
|
-
"typecheck": "tsc --noEmit -p tsconfig.lib.json",
|
|
62
|
-
"lint": "eslint .",
|
|
63
|
-
"lint:fix": "eslint . --fix",
|
|
64
|
-
"format": "prettier --write .",
|
|
65
|
-
"format:check": "prettier --check .",
|
|
66
|
-
"changeset": "changeset",
|
|
67
|
-
"changeset:version": "changeset version",
|
|
68
|
-
"changeset:publish": "changeset publish",
|
|
69
|
-
"prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run build"
|
|
70
|
-
},
|
|
71
54
|
"lint-staged": {
|
|
72
55
|
"*.ts": [
|
|
73
56
|
"eslint --fix",
|
|
@@ -110,5 +93,19 @@
|
|
|
110
93
|
"typescript": "^5.9.3",
|
|
111
94
|
"typescript-eslint": "^8.50.0",
|
|
112
95
|
"vitest": "^4.0.16"
|
|
96
|
+
},
|
|
97
|
+
"scripts": {
|
|
98
|
+
"build": "tsc -p tsconfig.lib.json",
|
|
99
|
+
"test": "vitest run",
|
|
100
|
+
"test:watch": "vitest",
|
|
101
|
+
"test:coverage": "vitest run --coverage",
|
|
102
|
+
"typecheck": "tsc --noEmit -p tsconfig.lib.json",
|
|
103
|
+
"lint": "eslint .",
|
|
104
|
+
"lint:fix": "eslint . --fix",
|
|
105
|
+
"format": "prettier --write .",
|
|
106
|
+
"format:check": "prettier --check .",
|
|
107
|
+
"changeset": "changeset",
|
|
108
|
+
"changeset:version": "changeset version",
|
|
109
|
+
"changeset:publish": "changeset publish"
|
|
113
110
|
}
|
|
114
|
-
}
|
|
111
|
+
}
|