prisma-effect-kysely 6.0.0-next.0 → 6.0.0-next.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 +42 -0
- package/README.md +33 -10
- package/dist/effect/join-table.d.ts +4 -2
- package/dist/effect/join-table.d.ts.map +1 -1
- package/dist/effect/join-table.js +8 -5
- package/dist/effect/join-table.js.map +1 -1
- package/dist/generator/orchestrator.d.ts +7 -0
- package/dist/generator/orchestrator.d.ts.map +1 -1
- package/dist/generator/orchestrator.js +25 -0
- package/dist/generator/orchestrator.js.map +1 -1
- package/dist/kysely/helpers.d.ts +2 -9
- package/dist/kysely/helpers.d.ts.map +1 -1
- package/dist/kysely/helpers.js +22 -20
- package/dist/kysely/helpers.js.map +1 -1
- package/dist/utils/annotations.d.ts +15 -4
- package/dist/utils/annotations.d.ts.map +1 -1
- package/dist/utils/annotations.js +125 -4
- package/dist/utils/annotations.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 6.0.0-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ded938b: Warn on Effect 3 syntax in `@customType` annotations.
|
|
8
|
+
|
|
9
|
+
`@customType(...)` expressions are emitted verbatim, so an Effect 3 expression
|
|
10
|
+
(e.g. `Schema.Number.pipe(Schema.int(), Schema.between(1, 5))` or the variadic
|
|
11
|
+
`Schema.Union(A, B)`) compiles against Effect 3 but breaks against Effect 4. The
|
|
12
|
+
generator now scans `@customType` strings at `prisma generate` time and prints a
|
|
13
|
+
warning that names the field and the v4 replacement — for filters
|
|
14
|
+
(`Schema.int()` → `Schema.check(Schema.isInt())`, `Schema.between(a, b)` →
|
|
15
|
+
`Schema.check(Schema.isBetween({ minimum, maximum }))`, etc.), variadic
|
|
16
|
+
combinators (`Schema.Union(a, b)` → `Schema.Union([a, b])`), and removed schemas
|
|
17
|
+
(`Schema.UUID`, `Schema.DateFromSelf`). It only warns; it never rewrites the
|
|
18
|
+
expression (regex-transforming arbitrary user TypeScript is unsafe).
|
|
19
|
+
|
|
20
|
+
Also bumps the dev/test Effect pin to `4.0.0-beta.70` and documents that
|
|
21
|
+
consumers must pin the exact `6.0.0-next.x` version — a `"*"` range resolves to
|
|
22
|
+
the stable `5.x` line because npm/pnpm exclude prereleases from version ranges.
|
|
23
|
+
|
|
24
|
+
## 6.0.0-next.1
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 5722a22: Fix Insertable/Updateable semantics surfaced by validation of the Effect 4 beta line:
|
|
29
|
+
- **`Insertable` now accepts an explicit `null` for nullable columns.** A
|
|
30
|
+
`Schema.NullOr(T)` field is optional on insert and retains `null` in its type,
|
|
31
|
+
so `{ col: null }` (set the column to NULL) decodes successfully — matching SQL
|
|
32
|
+
and Kysely's `Insertable`, which permit omit / value / explicit null. Previously
|
|
33
|
+
`null` was stripped and an explicit `null` was rejected at decode.
|
|
34
|
+
- **Implicit many-to-many join-table FK columns are now insertable.** They emit
|
|
35
|
+
`columnType(Id, Id, Never)` instead of `columnType(Id, Never, Never)`: the
|
|
36
|
+
foreign keys are provided on INSERT (you supply both keys when linking a row)
|
|
37
|
+
and read-only on UPDATE (a composite-PK join row is inserted/deleted, not
|
|
38
|
+
updated). Previously `Insertable<JoinTable>` resolved to an empty `{}`, making
|
|
39
|
+
join rows impossible to insert through the generated types.
|
|
40
|
+
- **Internal robustness:** Generated-field detection is gated on the `GeneratedId`
|
|
41
|
+
annotation rather than a bare `.from` property, so a `Schema.encodeKeys(...)`
|
|
42
|
+
transform nested as a struct field (which also exposes `.from`) is no longer
|
|
43
|
+
misclassified as a generated field.
|
|
44
|
+
|
|
3
45
|
## 6.0.0-next.0
|
|
4
46
|
|
|
5
47
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -22,11 +22,18 @@ bun add prisma-effect-kysely@next effect@beta
|
|
|
22
22
|
|
|
23
23
|
> **Effect 4 support is a pre-release.** It requires `effect@^4.0.0-beta` and is
|
|
24
24
|
> published under the `next` dist-tag, not `latest`. It is **tested against
|
|
25
|
-
> `effect@4.0.0-beta.
|
|
25
|
+
> `effect@4.0.0-beta.70`**; later betas may introduce breaking Schema changes. A
|
|
26
26
|
> generator-output compile check (`bun run test:emit`) guards the emitted code
|
|
27
27
|
> against the installed Effect, but pin `effect` if you need stability during the
|
|
28
28
|
> beta. The `next` line will be promoted to `latest` when Effect 4 goes stable.
|
|
29
29
|
>
|
|
30
|
+
> **Pin the exact version — do not use `"*"` or `"latest"`.** A `"prisma-effect-kysely": "*"`
|
|
31
|
+
> (or any range) dependency resolves to the **stable** `5.x` line, NOT the
|
|
32
|
+
> pre-release, because npm/pnpm semver excludes prereleases from ranges. In a
|
|
33
|
+
> workspace, depend on `"6.0.0-next.x"` exactly (or add a `pnpm.overrides` /
|
|
34
|
+
> `resolutions` entry). Symptom of getting this wrong: the v3 `5.x` types resolve
|
|
35
|
+
> and consumers see cascading `Schema.Top` / `unknown` type errors.
|
|
36
|
+
>
|
|
30
37
|
> Effect 4 and Effect 3 are not interchangeable: the generated output uses
|
|
31
38
|
> Effect-4-only Schema APIs (`Schema.Date`, `Schema.String.check(Schema.isUUID())`,
|
|
32
39
|
> `Schema.encodeKeys`, `Schema.Enum`, …). Stay on the `latest` line if you are on
|
|
@@ -135,26 +142,42 @@ model User {
|
|
|
135
142
|
|
|
136
143
|
Supported on all Prisma scalar types.
|
|
137
144
|
|
|
145
|
+
`@customType(...)` expressions are emitted **verbatim** — they must be valid
|
|
146
|
+
Effect 4 syntax. The generator does not rewrite them, but it **warns** at
|
|
147
|
+
`prisma generate` time when it detects Effect 3 syntax, pointing at the v4 form.
|
|
148
|
+
Effect 4 moved all filters under `.check(Schema.is*)` and made the variadic
|
|
149
|
+
combinators take an array:
|
|
150
|
+
|
|
151
|
+
| Effect 3 (`@customType`) | Effect 4 |
|
|
152
|
+
| ------------------------------------- | ---------------------------------------------------------------------- |
|
|
153
|
+
| `Schema.Number.pipe(Schema.int())` | `Schema.Number.pipe(Schema.check(Schema.isInt()))` |
|
|
154
|
+
| `Schema.positive()` | `Schema.check(Schema.isGreaterThan(0))` |
|
|
155
|
+
| `Schema.between(1, 5)` | `Schema.check(Schema.isBetween({ minimum: 1, maximum: 5 }))` |
|
|
156
|
+
| `Schema.minLength(3)` | `Schema.check(Schema.isMinLength(3))` |
|
|
157
|
+
| `Schema.Union(A, B)` | `Schema.Union([A, B])` |
|
|
158
|
+
| `Schema.Literal('a', 'b')` | `Schema.Literals(['a', 'b'])` (single `Schema.Literal('x')` unchanged) |
|
|
159
|
+
| `Schema.UUID` / `Schema.DateFromSelf` | `Schema.String.check(Schema.isUUID())` / `Schema.Date` |
|
|
160
|
+
|
|
138
161
|
## Implicit M2M Join Tables
|
|
139
162
|
|
|
140
163
|
Prisma columns `A`/`B` map to semantic snake_case fields via `Schema.encodeKeys`:
|
|
141
164
|
|
|
142
165
|
```typescript
|
|
143
166
|
export const ProductToProductTag = Schema.Struct({
|
|
144
|
-
product_id: columnType(ProductId,
|
|
145
|
-
product_tag_id: columnType(ProductTagId,
|
|
167
|
+
product_id: columnType(ProductId, ProductId, Schema.Never),
|
|
168
|
+
product_tag_id: columnType(ProductTagId, ProductTagId, Schema.Never),
|
|
146
169
|
}).pipe(Schema.encodeKeys({ product_id: 'A', product_tag_id: 'B' }));
|
|
147
170
|
```
|
|
148
171
|
|
|
149
172
|
## Package Exports
|
|
150
173
|
|
|
151
|
-
| Entry | Contents
|
|
152
|
-
| -------------------------------- |
|
|
153
|
-
| `prisma-effect-kysely` | Type utilities + runtime helpers (default import)
|
|
154
|
-
| `prisma-effect-kysely/generator` | Prisma generator binary entry
|
|
155
|
-
| `prisma-effect-kysely/kysely` | `
|
|
156
|
-
| `prisma-effect-kysely/error` | `NotFoundError`, `QueryError`, `DatabaseError`
|
|
157
|
-
| `prisma-effect-kysely/runtime` | All runtime utilities
|
|
174
|
+
| Entry | Contents |
|
|
175
|
+
| -------------------------------- | -------------------------------------------------- |
|
|
176
|
+
| `prisma-effect-kysely` | Type utilities + runtime helpers (default import) |
|
|
177
|
+
| `prisma-effect-kysely/generator` | Prisma generator binary entry |
|
|
178
|
+
| `prisma-effect-kysely/kysely` | `columnType`, `generated`, `JsonValue`, type utils |
|
|
179
|
+
| `prisma-effect-kysely/error` | `NotFoundError`, `QueryError`, `DatabaseError` |
|
|
180
|
+
| `prisma-effect-kysely/runtime` | All runtime utilities |
|
|
158
181
|
|
|
159
182
|
## Development
|
|
160
183
|
|
|
@@ -6,13 +6,15 @@ import type { JoinTableInfo } from '../prisma/relation.js';
|
|
|
6
6
|
* Structure:
|
|
7
7
|
* - Direct export with semantic snake_case field names
|
|
8
8
|
* - Maps TypeScript names to database A/B columns using Schema.encodeKeys
|
|
9
|
-
* - Uses columnType
|
|
9
|
+
* - Uses columnType(Id, Id, Never) for the FK columns: provided on INSERT (you
|
|
10
|
+
* supply both foreign keys when linking a row) but read-only on UPDATE — a
|
|
11
|
+
* composite-PK join row is inserted or deleted, never updated in place
|
|
10
12
|
* - No type exports - consumers use type utilities: Selectable<JoinTable>
|
|
11
13
|
*
|
|
12
14
|
* Example:
|
|
13
15
|
* - Database columns: A, B (Prisma requirement for implicit many-to-many)
|
|
14
16
|
* - TypeScript fields: product_id, product_tag_id (semantic names)
|
|
15
|
-
* - Types: columnType(ProductId,
|
|
17
|
+
* - Types: columnType(ProductId, ProductId, Schema.Never) (insertable, read-only on update, branded)
|
|
16
18
|
*/
|
|
17
19
|
export declare function generateJoinTableSchema(joinTable: JoinTableInfo, _dmmf: DMMF.Document): string;
|
|
18
20
|
//# sourceMappingURL=join-table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,uBAAuB,CAAC;AAG3D
|
|
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,uBAAuB,CAAC;AAG3D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,UAgCrF"}
|
|
@@ -5,13 +5,15 @@ import { toPascalCase, toSnakeCase } from '../utils/naming.js';
|
|
|
5
5
|
* Structure:
|
|
6
6
|
* - Direct export with semantic snake_case field names
|
|
7
7
|
* - Maps TypeScript names to database A/B columns using Schema.encodeKeys
|
|
8
|
-
* - Uses columnType
|
|
8
|
+
* - Uses columnType(Id, Id, Never) for the FK columns: provided on INSERT (you
|
|
9
|
+
* supply both foreign keys when linking a row) but read-only on UPDATE — a
|
|
10
|
+
* composite-PK join row is inserted or deleted, never updated in place
|
|
9
11
|
* - No type exports - consumers use type utilities: Selectable<JoinTable>
|
|
10
12
|
*
|
|
11
13
|
* Example:
|
|
12
14
|
* - Database columns: A, B (Prisma requirement for implicit many-to-many)
|
|
13
15
|
* - TypeScript fields: product_id, product_tag_id (semantic names)
|
|
14
|
-
* - Types: columnType(ProductId,
|
|
16
|
+
* - Types: columnType(ProductId, ProductId, Schema.Never) (insertable, read-only on update, branded)
|
|
15
17
|
*/
|
|
16
18
|
export function generateJoinTableSchema(joinTable, _dmmf) {
|
|
17
19
|
const { tableName, relationName, modelA, modelB } = joinTable;
|
|
@@ -22,12 +24,13 @@ export function generateJoinTableSchema(joinTable, _dmmf) {
|
|
|
22
24
|
// Reference branded ID schemas (e.g., ProductId, SellerId) generated earlier in the output
|
|
23
25
|
const modelASchemaType = `${toPascalCase(modelA)}Id`;
|
|
24
26
|
const modelBSchemaType = `${toPascalCase(modelB)}Id`;
|
|
25
|
-
//
|
|
27
|
+
// columnType(Id, Id, Never): the FK is supplied on INSERT and read-only on
|
|
28
|
+
// UPDATE (composite-PK join rows are inserted/deleted, not updated).
|
|
26
29
|
// The struct uses semantic field names; Schema.encodeKeys renames them to the
|
|
27
30
|
// database A/B columns on the encoded side (Effect 4 replacement for the old
|
|
28
31
|
// Schema.propertySignature(...).pipe(Schema.fromKey(...)) pattern).
|
|
29
|
-
const columnAField = ` ${columnAFieldName}: columnType(${modelASchemaType},
|
|
30
|
-
const columnBField = ` ${columnBFieldName}: columnType(${modelBSchemaType},
|
|
32
|
+
const columnAField = ` ${columnAFieldName}: columnType(${modelASchemaType}, ${modelASchemaType}, Schema.Never)`;
|
|
33
|
+
const columnBField = ` ${columnBFieldName}: columnType(${modelBSchemaType}, ${modelBSchemaType}, Schema.Never)`;
|
|
31
34
|
// Use PascalCase for exported name (consistent with regular models)
|
|
32
35
|
const pascalName = toPascalCase(relationName);
|
|
33
36
|
// Generate schema with semantic names mapped to A/B
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"join-table.js","sourceRoot":"","sources":["../../src/effect/join-table.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE/D
|
|
1
|
+
{"version":3,"file":"join-table.js","sourceRoot":"","sources":["../../src/effect/join-table.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE/D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAAwB,EAAE,KAAoB;IACpF,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAE9D,4DAA4D;IAC5D,oEAAoE;IACpE,MAAM,gBAAgB,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;IACrD,MAAM,gBAAgB,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;IAErD,2FAA2F;IAC3F,MAAM,gBAAgB,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;IACrD,MAAM,gBAAgB,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;IAErD,2EAA2E;IAC3E,qEAAqE;IACrE,8EAA8E;IAC9E,6EAA6E;IAC7E,oEAAoE;IACpE,MAAM,YAAY,GAAG,KAAK,gBAAgB,gBAAgB,gBAAgB,KAAK,gBAAgB,iBAAiB,CAAC;IACjH,MAAM,YAAY,GAAG,KAAK,gBAAgB,gBAAgB,gBAAgB,KAAK,gBAAgB,iBAAiB,CAAC;IAEjH,oEAAoE;IACpE,MAAM,UAAU,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;IAE9C,oDAAoD;IACpD,OAAO,MAAM,SAAS;0BACE,MAAM,SAAS,MAAM;wBACvB,gBAAgB,KAAK,gBAAgB;eAC9C,UAAU;EACvB,YAAY;EACZ,YAAY;8BACgB,gBAAgB,UAAU,gBAAgB;cAC1D,UAAU,aAAa,UAAU,GAAG,CAAC;AACnD,CAAC"}
|
|
@@ -54,6 +54,13 @@ export declare class GeneratorOrchestrator {
|
|
|
54
54
|
* Log generation start with stats
|
|
55
55
|
*/
|
|
56
56
|
private logStart;
|
|
57
|
+
/**
|
|
58
|
+
* Scan every field's `@customType(...)` annotation for Effect 3 syntax and warn
|
|
59
|
+
* (to stderr, which Prisma surfaces to the user). `@customType` strings are
|
|
60
|
+
* emitted verbatim, so a v3 expression silently breaks once compiled against
|
|
61
|
+
* Effect 4. We never rewrite — only point at the v4 replacement.
|
|
62
|
+
*/
|
|
63
|
+
private warnLegacyAnnotations;
|
|
57
64
|
/**
|
|
58
65
|
* Log generation completion
|
|
59
66
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/generator/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/generator/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAejE;;;;;;;GAOG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;gBAEhC,OAAO,EAAE,gBAAgB;IASrC;;;;;;;;OAQG;IACG,QAAQ,CAAC,OAAO,EAAE,gBAAgB;IAcxC;;;OAGG;YACW,oBAAoB;IAQlC;;;OAGG;YACW,mBAAmB;IAiBjC;;OAEG;YACW,iBAAiB;IAmE/B;;OAEG;YACW,aAAa;IAM3B;;OAEG;YACW,aAAa;IAiD3B;;OAEG;YACW,aAAa;IAK3B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAWhB;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAoB7B;;OAEG;IACH,OAAO,CAAC,WAAW;CASpB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EffectGenerator } from '../effect/generator.js';
|
|
2
2
|
import { KyselyGenerator } from '../kysely/generator.js';
|
|
3
3
|
import { PrismaGenerator } from '../prisma/generator.js';
|
|
4
|
+
import { detectLegacyEffectV3Syntax, extractEffectTypeOverride } from '../utils/annotations.js';
|
|
4
5
|
import { FileManager } from '../utils/file-manager.js';
|
|
5
6
|
import { isMultiDomainEnabled, isScaffoldingEnabled, parseGeneratorConfig, } from './config.js';
|
|
6
7
|
import { logScaffoldResults, scaffoldContractLibraries } from './contract-scaffolder.js';
|
|
@@ -37,6 +38,7 @@ export class GeneratorOrchestrator {
|
|
|
37
38
|
*/
|
|
38
39
|
async generate(options) {
|
|
39
40
|
this.logStart(options);
|
|
41
|
+
this.warnLegacyAnnotations(options);
|
|
40
42
|
// Check if multi-domain mode is enabled
|
|
41
43
|
if (isMultiDomainEnabled(this.config)) {
|
|
42
44
|
await this.generateMultiDomain(options);
|
|
@@ -198,6 +200,29 @@ export class GeneratorOrchestrator {
|
|
|
198
200
|
}
|
|
199
201
|
}
|
|
200
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Scan every field's `@customType(...)` annotation for Effect 3 syntax and warn
|
|
205
|
+
* (to stderr, which Prisma surfaces to the user). `@customType` strings are
|
|
206
|
+
* emitted verbatim, so a v3 expression silently breaks once compiled against
|
|
207
|
+
* Effect 4. We never rewrite — only point at the v4 replacement.
|
|
208
|
+
*/
|
|
209
|
+
warnLegacyAnnotations(options) {
|
|
210
|
+
const warnings = [];
|
|
211
|
+
for (const model of options.dmmf.datamodel.models) {
|
|
212
|
+
for (const field of model.fields) {
|
|
213
|
+
const override = extractEffectTypeOverride(field);
|
|
214
|
+
if (!override)
|
|
215
|
+
continue;
|
|
216
|
+
for (const hint of detectLegacyEffectV3Syntax(override)) {
|
|
217
|
+
warnings.push(` ${model.name}.${field.name}: ${hint}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (warnings.length > 0) {
|
|
222
|
+
console.warn(`[prisma-effect-kysely] @customType annotations use Effect 3 syntax that does not ` +
|
|
223
|
+
`compile against Effect 4. Update them in your Prisma schema:\n${warnings.join('\n')}`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
201
226
|
/**
|
|
202
227
|
* Log generation completion
|
|
203
228
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/generator/orchestrator.ts"],"names":[],"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[T] extends [{
|
|
|
219
219
|
* A field is optional for insert if its InsertType can be null or undefined.
|
|
220
220
|
*/
|
|
221
221
|
type IsOptionalInsert<T> = undefined extends ExtractInsertType<T> ? true : null extends ExtractInsertType<T> ? true : false;
|
|
222
|
-
/**
|
|
223
|
-
* Extract the base type without null/undefined for optional fields.
|
|
224
|
-
* Keeps the type as-is (including null) for the property type,
|
|
225
|
-
* since the optionality is expressed via `?` not the type itself.
|
|
226
|
-
*/
|
|
227
|
-
type ExtractInsertBaseType<T> = ExtractInsertType<T>;
|
|
228
222
|
/**
|
|
229
223
|
* Extract the update type from a field using the __update__ phantom property:
|
|
230
224
|
* - ColumnType<S, I, U> -> U (via __update__)
|
|
@@ -248,7 +242,7 @@ type ExtractUpdateType<T> = [T] extends [{
|
|
|
248
242
|
type CustomInsertable<T> = {
|
|
249
243
|
-readonly [K in keyof T as ExtractInsertType<T[K]> extends never ? never : IsOptionalInsert<T[K]> extends true ? never : K]: ExtractInsertType<T[K]>;
|
|
250
244
|
} & {
|
|
251
|
-
-readonly [K in keyof T as ExtractInsertType<T[K]> extends never ? never : IsOptionalInsert<T[K]> extends true ? K : never]?:
|
|
245
|
+
-readonly [K in keyof T as ExtractInsertType<T[K]> extends never ? never : IsOptionalInsert<T[K]> extends true ? K : never]?: ExtractInsertType<T[K]>;
|
|
252
246
|
};
|
|
253
247
|
/**
|
|
254
248
|
* Custom Updateable type that properly omits fields with `never` update types.
|
|
@@ -256,7 +250,6 @@ type CustomInsertable<T> = {
|
|
|
256
250
|
type CustomUpdateable<T> = {
|
|
257
251
|
-readonly [K in keyof T as ExtractUpdateType<T[K]> extends never ? never : K]?: ExtractUpdateType<T[K]>;
|
|
258
252
|
};
|
|
259
|
-
type MutableInsert<Type> = CustomInsertable<Type>;
|
|
260
253
|
/**
|
|
261
254
|
* Strip Generated<T> wrapper, returning the underlying type T.
|
|
262
255
|
* For non-Generated types, returns as-is.
|
|
@@ -292,7 +285,7 @@ export declare function Selectable<Type, Encoded>(schema: Schema.Codec<Type, Enc
|
|
|
292
285
|
* Create Insertable schema from base schema
|
|
293
286
|
* Generated fields (@default) are made optional, not excluded
|
|
294
287
|
*/
|
|
295
|
-
export declare function Insertable<Type, Encoded>(schema: Schema.Codec<Type, Encoded>): Schema.Codec<
|
|
288
|
+
export declare function Insertable<Type, Encoded>(schema: Schema.Codec<Type, Encoded>): Schema.Codec<CustomInsertable<Type>, CustomInsertable<Encoded>, never, never>;
|
|
296
289
|
/**
|
|
297
290
|
* Create Updateable schema from base schema
|
|
298
291
|
*/
|
|
@@ -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;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,CAAC;AAEF,eAAO,MAAM,YAAY,eAA8B,CAAC;AACxD,eAAO,MAAM,WAAW,eAA6B,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,OAAO,MAAuD,CAAC;AAC3F,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC;AASjD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,aAAa,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;IAC/C,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE;QACxB,QAAQ,EAAE,CAAC,IAAI,QAAQ,GAAG,QAAQ,GAAG,CAAC,SAA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A6B,CAAC,OAAO,CAAC,EACtC,KAAK,EACL,KAAK,CACN,CAiCA;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,iFAgD5E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,iFAsC5E;AAQD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,IAAI,6BAA6B,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpG;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvF;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/kysely/helpers.js
CHANGED
|
@@ -101,8 +101,23 @@ const getColumnTypeSchemas = (field) => {
|
|
|
101
101
|
}
|
|
102
102
|
return readAnnotation(field, ColumnTypeId);
|
|
103
103
|
};
|
|
104
|
-
/**
|
|
105
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Resolve the base schema of a Generated field, or undefined if not generated.
|
|
106
|
+
*
|
|
107
|
+
* Detection is gated on the `GeneratedId` annotation — the authoritative marker
|
|
108
|
+
* that `generated()` always sets. A bare `.from` own-property is NOT sufficient:
|
|
109
|
+
* `Schema.encodeKeys(...)` transforms (used for join tables) also expose a `.from`
|
|
110
|
+
* property, so trusting `.from` alone would misclassify a nested encodeKeys field
|
|
111
|
+
* as generated. When the marker is present, the `.from` own-property is preferred
|
|
112
|
+
* (it survives the field→Struct round-trip) with the annotation's `from` as the
|
|
113
|
+
* fallback for a consumer-`.annotate()`d schema where own-props were dropped.
|
|
114
|
+
*/
|
|
115
|
+
const getGeneratedFrom = (field) => {
|
|
116
|
+
const annotation = readAnnotation(field, GeneratedId);
|
|
117
|
+
if (annotation === undefined)
|
|
118
|
+
return undefined;
|
|
119
|
+
return field.from ?? annotation.from;
|
|
120
|
+
};
|
|
106
121
|
const isGeneratedField = (field) => getGeneratedFrom(field) !== undefined;
|
|
107
122
|
const isNeverSchema = (schema) => AST.isNever(schema.ast);
|
|
108
123
|
const isArraySchema = (schema) => AST.isArrays(schema.ast);
|
|
@@ -114,22 +129,6 @@ const isNullableUnion = (schema) => {
|
|
|
114
129
|
const members = schema.members;
|
|
115
130
|
return Array.isArray(members) && members.some((m) => AST.isNull(m.ast));
|
|
116
131
|
};
|
|
117
|
-
/**
|
|
118
|
-
* Strip null from a `NullOr` schema for Insertable fields.
|
|
119
|
-
* For INSERT, omitting a field = NULL in the DB, so explicit null is unnecessary.
|
|
120
|
-
* Returns the non-null member; otherwise returns the schema unchanged.
|
|
121
|
-
*/
|
|
122
|
-
const stripNull = (schema) => {
|
|
123
|
-
const members = schema.members;
|
|
124
|
-
if (!Array.isArray(members))
|
|
125
|
-
return schema;
|
|
126
|
-
const nonNull = members.filter((m) => !AST.isNull(m.ast));
|
|
127
|
-
if (nonNull.length === 1)
|
|
128
|
-
return nonNull[0];
|
|
129
|
-
if (nonNull.length > 1)
|
|
130
|
-
return Schema.Union(nonNull);
|
|
131
|
-
return schema;
|
|
132
|
-
};
|
|
133
132
|
/** Apply `Schema.mutable` only to array fields (it throws on scalars in v4). */
|
|
134
133
|
const mutableIfArray = (schema) => isArraySchema(schema)
|
|
135
134
|
? Schema.mutable(schema)
|
|
@@ -214,8 +213,11 @@ export function Insertable(schema) {
|
|
|
214
213
|
continue;
|
|
215
214
|
}
|
|
216
215
|
if (isNullableUnion(field)) {
|
|
217
|
-
// Union(T, null) -> optional
|
|
218
|
-
|
|
216
|
+
// Union(T, null) -> optional on insert. Null is RETAINED so a caller can
|
|
217
|
+
// explicitly set the column to NULL (`{ x: null }`), matching SQL and
|
|
218
|
+
// Kysely's Insertable, which both permit omit / value / explicit null for
|
|
219
|
+
// a nullable column. (Omitting the key also leaves the column NULL.)
|
|
220
|
+
insertFields[key] = Schema.optional(mutableIfArray(field));
|
|
219
221
|
continue;
|
|
220
222
|
}
|
|
221
223
|
insertFields[key] = mutableIfArray(field);
|
|
@@ -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;AAgDxC,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;AAwI3F;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,YAAe,EACf,YAAe,EACf,YAAe,EACf,EAAE;IACF,MAAM,OAAO,GAAsB,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;IAChF,8EAA8E;IAC9E,4EAA4E;IAC5E,sEAAsE;IACtE,2EAA2E;IAC3E,sEAAsE;IACtE,yBAAyB;IACzB,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IACrE,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE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7
|
* WORKS FOR: Prisma scalar types (String, Int, Boolean, DateTime, etc.)
|
|
8
8
|
*
|
|
9
|
-
* USE CASES:
|
|
10
|
-
* //
|
|
11
|
-
* /// @customType(Schema.String.
|
|
9
|
+
* USE CASES (Effect 4 syntax — emitted verbatim, so must be v4-valid):
|
|
10
|
+
* // Length constraint for String field
|
|
11
|
+
* /// @customType(Schema.String.check(Schema.isMinLength(3)))
|
|
12
12
|
* email String
|
|
13
13
|
*
|
|
14
14
|
* // Positive number constraint for Int field
|
|
15
|
-
* /// @customType(Schema.Number.
|
|
15
|
+
* /// @customType(Schema.Number.check(Schema.isGreaterThan(0)))
|
|
16
16
|
* age Int
|
|
17
17
|
*
|
|
18
18
|
* // Custom branded type
|
|
@@ -23,6 +23,17 @@ import type { DMMF } from '@prisma/generator-helper';
|
|
|
23
23
|
* @returns Extracted type string or null if no annotation found
|
|
24
24
|
*/
|
|
25
25
|
export declare function extractEffectTypeOverride(field: DMMF.Field): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Detect Effect 3 syntax in a `@customType` expression and return human-readable
|
|
28
|
+
* upgrade hints. Returns an empty array when the expression looks v4-clean.
|
|
29
|
+
*
|
|
30
|
+
* Detection is heuristic (string matching), so it is WARN-ONLY — callers should
|
|
31
|
+
* surface these as build warnings, never block generation or rewrite the string.
|
|
32
|
+
*
|
|
33
|
+
* @param typeStr - The raw `@customType(...)` expression
|
|
34
|
+
* @returns v4 upgrade hints for each matched legacy pattern
|
|
35
|
+
*/
|
|
36
|
+
export declare function detectLegacyEffectV3Syntax(typeStr: string): string[];
|
|
26
37
|
/**
|
|
27
38
|
* Check if field has any custom type annotations
|
|
28
39
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/utils/annotations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,iBAiC1D;
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/utils/annotations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,iBAiC1D;AA8ID;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,WAKrE"}
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
*
|
|
6
6
|
* WORKS FOR: Prisma scalar types (String, Int, Boolean, DateTime, etc.)
|
|
7
7
|
*
|
|
8
|
-
* USE CASES:
|
|
9
|
-
* //
|
|
10
|
-
* /// @customType(Schema.String.
|
|
8
|
+
* USE CASES (Effect 4 syntax — emitted verbatim, so must be v4-valid):
|
|
9
|
+
* // Length constraint for String field
|
|
10
|
+
* /// @customType(Schema.String.check(Schema.isMinLength(3)))
|
|
11
11
|
* email String
|
|
12
12
|
*
|
|
13
13
|
* // Positive number constraint for Int field
|
|
14
|
-
* /// @customType(Schema.Number.
|
|
14
|
+
* /// @customType(Schema.Number.check(Schema.isGreaterThan(0)))
|
|
15
15
|
* age Int
|
|
16
16
|
*
|
|
17
17
|
* // Custom branded type
|
|
@@ -65,6 +65,127 @@ export function extractEffectTypeOverride(field) {
|
|
|
65
65
|
function isCustomType(typeStr) {
|
|
66
66
|
return /^[A-Z][A-Za-z0-9]*$/.test(typeStr);
|
|
67
67
|
}
|
|
68
|
+
const LEGACY_V3_PATTERNS = [
|
|
69
|
+
// Filters: Schema.<name>(...) used as a pipeable, now `.check(Schema.is<Name>(...))`.
|
|
70
|
+
{ test: /\bSchema\.int\s*\(/, hint: 'Schema.int() → Schema.check(Schema.isInt())' },
|
|
71
|
+
{
|
|
72
|
+
test: /\bSchema\.between\s*\(/,
|
|
73
|
+
hint: 'Schema.between(min, max) → Schema.check(Schema.isBetween({ minimum, maximum })) (v4 takes an object, not positional args)',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
test: /\bSchema\.minLength\s*\(/,
|
|
77
|
+
hint: 'Schema.minLength(n) → Schema.check(Schema.isMinLength(n))',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
test: /\bSchema\.maxLength\s*\(/,
|
|
81
|
+
hint: 'Schema.maxLength(n) → Schema.check(Schema.isMaxLength(n))',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
test: /\bSchema\.length\s*\(/,
|
|
85
|
+
hint: 'Schema.length(n) → Schema.check(Schema.isLengthBetween(n, n))',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
test: /\bSchema\.greaterThanOrEqualTo\s*\(/,
|
|
89
|
+
hint: 'Schema.greaterThanOrEqualTo(n) → Schema.check(Schema.isGreaterThanOrEqualTo(n))',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
test: /\bSchema\.greaterThan\s*\(/,
|
|
93
|
+
hint: 'Schema.greaterThan(n) → Schema.check(Schema.isGreaterThan(n))',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
test: /\bSchema\.lessThanOrEqualTo\s*\(/,
|
|
97
|
+
hint: 'Schema.lessThanOrEqualTo(n) → Schema.check(Schema.isLessThanOrEqualTo(n))',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
test: /\bSchema\.lessThan\s*\(/,
|
|
101
|
+
hint: 'Schema.lessThan(n) → Schema.check(Schema.isLessThan(n))',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
test: /\bSchema\.multipleOf\s*\(/,
|
|
105
|
+
hint: 'Schema.multipleOf(n) → Schema.check(Schema.isMultipleOf(n))',
|
|
106
|
+
},
|
|
107
|
+
{ test: /\bSchema\.finite\s*\(/, hint: 'Schema.finite() → Schema.check(Schema.isFinite())' },
|
|
108
|
+
{
|
|
109
|
+
test: /\bSchema\.positive\s*\(/,
|
|
110
|
+
hint: 'Schema.positive() → Schema.check(Schema.isGreaterThan(0))',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
test: /\bSchema\.nonNegative\s*\(/,
|
|
114
|
+
hint: 'Schema.nonNegative() → Schema.check(Schema.isGreaterThanOrEqualTo(0))',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
test: /\bSchema\.negative\s*\(/,
|
|
118
|
+
hint: 'Schema.negative() → Schema.check(Schema.isLessThan(0))',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
test: /\bSchema\.nonPositive\s*\(/,
|
|
122
|
+
hint: 'Schema.nonPositive() → Schema.check(Schema.isLessThanOrEqualTo(0))',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
test: /\bSchema\.nonEmpty\s*\(/,
|
|
126
|
+
hint: 'Schema.nonEmpty() → Schema.check(Schema.isNonEmpty())',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
test: /\bSchema\.pattern\s*\(/,
|
|
130
|
+
hint: 'Schema.pattern(re) → Schema.check(Schema.isPattern(re))',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
test: /\bSchema\.startsWith\s*\(/,
|
|
134
|
+
hint: 'Schema.startsWith(s) → Schema.check(Schema.isStartsWith(s))',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
test: /\bSchema\.endsWith\s*\(/,
|
|
138
|
+
hint: 'Schema.endsWith(s) → Schema.check(Schema.isEndsWith(s))',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
test: /\bSchema\.lowercased\s*\(/,
|
|
142
|
+
hint: 'Schema.lowercased() → Schema.check(Schema.isLowercased())',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
test: /\bSchema\.uppercased\s*\(/,
|
|
146
|
+
hint: 'Schema.uppercased() → Schema.check(Schema.isUppercased())',
|
|
147
|
+
},
|
|
148
|
+
{ test: /\bSchema\.trimmed\s*\(/, hint: 'Schema.trimmed() → Schema.check(Schema.isTrimmed())' },
|
|
149
|
+
// Removed / renamed schemas.
|
|
150
|
+
{
|
|
151
|
+
test: /\bSchema\.DateFromSelf\b/,
|
|
152
|
+
hint: 'Schema.DateFromSelf → Schema.Date (v4 Schema.Date is the native-Date schema)',
|
|
153
|
+
},
|
|
154
|
+
{ test: /\bSchema\.UUID\b/, hint: 'Schema.UUID → Schema.String.check(Schema.isUUID())' },
|
|
155
|
+
{
|
|
156
|
+
test: /\bSchema\.optionalWith\s*\(/,
|
|
157
|
+
hint: 'Schema.optionalWith({ exact: true }) → Schema.optionalKey',
|
|
158
|
+
},
|
|
159
|
+
// Variadic combinators that now take an array (non-array first arg = v3 form).
|
|
160
|
+
// `Schema.Union(A, B)` → `Schema.Union([A, B])`; single-member calls are fine.
|
|
161
|
+
{
|
|
162
|
+
test: /\bSchema\.Union\s*\(\s*[^[)]/,
|
|
163
|
+
hint: 'Schema.Union(a, b, …) is variadic in v3 → Schema.Union([a, b, …]) (array) in v4',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
test: /\bSchema\.Tuple\s*\(\s*[^[)]/,
|
|
167
|
+
hint: 'Schema.Tuple(a, b, …) is variadic in v3 → Schema.Tuple([a, b, …]) (array) in v4',
|
|
168
|
+
},
|
|
169
|
+
// Multi-arg Literal → Literals([...]). Single Schema.Literal('x') is unchanged,
|
|
170
|
+
// so only flag when a comma appears before the closing paren.
|
|
171
|
+
{
|
|
172
|
+
test: /\bSchema\.Literal\s*\([^)]*,/,
|
|
173
|
+
hint: "Schema.Literal(a, b, …) → Schema.Literals([a, b, …]) (single Schema.Literal('x') is unchanged)",
|
|
174
|
+
},
|
|
175
|
+
];
|
|
176
|
+
/**
|
|
177
|
+
* Detect Effect 3 syntax in a `@customType` expression and return human-readable
|
|
178
|
+
* upgrade hints. Returns an empty array when the expression looks v4-clean.
|
|
179
|
+
*
|
|
180
|
+
* Detection is heuristic (string matching), so it is WARN-ONLY — callers should
|
|
181
|
+
* surface these as build warnings, never block generation or rewrite the string.
|
|
182
|
+
*
|
|
183
|
+
* @param typeStr - The raw `@customType(...)` expression
|
|
184
|
+
* @returns v4 upgrade hints for each matched legacy pattern
|
|
185
|
+
*/
|
|
186
|
+
export function detectLegacyEffectV3Syntax(typeStr) {
|
|
187
|
+
return LEGACY_V3_PATTERNS.filter((p) => p.test.test(typeStr)).map((p) => p.hint);
|
|
188
|
+
}
|
|
68
189
|
/**
|
|
69
190
|
* Check if field has any custom type annotations
|
|
70
191
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../src/utils/annotations.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAiB;IACzD,IAAI,CAAC,KAAK,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IAEtC,6DAA6D;IAC7D,MAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACtE,IAAI,CAAC,eAAe;QAAE,OAAO,IAAI,CAAC;IAElC,wCAAwC;IACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC;IACrF,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,MAAM,GAAG,QAAQ,CAAC;IAEtB,KAAK,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7E,IAAI,KAAK,CAAC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C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-effect-kysely",
|
|
3
|
-
"version": "6.0.0-next.
|
|
3
|
+
"version": "6.0.0-next.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",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"@typescript-eslint/parser": "^8.59.1",
|
|
111
111
|
"@vitest/coverage-v8": "^4.1.5",
|
|
112
112
|
"@vitest/eslint-plugin": "^1.6.16",
|
|
113
|
-
"effect": "4.0.0-beta.
|
|
113
|
+
"effect": "4.0.0-beta.70",
|
|
114
114
|
"eslint": "^10.0.0",
|
|
115
115
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
116
116
|
"eslint-plugin-import": "^2.32.0",
|