prisma-effect-kysely 6.0.0-next.2 → 6.0.0-next.4
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 +53 -0
- package/README.md +15 -3
- package/dist/kysely/type.d.ts.map +1 -1
- package/dist/kysely/type.js +9 -1
- package/dist/kysely/type.js.map +1 -1
- package/dist/prisma/type.d.ts +14 -2
- package/dist/prisma/type.d.ts.map +1 -1
- package/dist/prisma/type.js +17 -15
- package/dist/prisma/type.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 6.0.0-next.4
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 300d024: fix: only treat `@db.Uuid` columns as UUIDs — drop field-name inference
|
|
8
|
+
|
|
9
|
+
`isUuidField` previously had a third detection tier that inferred UUID from the
|
|
10
|
+
field _name_ (`/^id$/`, `/_id$/`, `/^.*_uuid$/`, `/^uuid$/`) for any `String`
|
|
11
|
+
column. UUID is a column _type_, not a naming convention, so this was a
|
|
12
|
+
false-positive generator: every external-system identifier stored as text — most
|
|
13
|
+
notably Stripe IDs (`acct_…`, `cus_…`, `sub_…`, `price_…`, `txn_…`, `ch_…`,
|
|
14
|
+
`evt_…`), plus slugs and provider/session references — ends in `_id` without
|
|
15
|
+
being a UUID. The generator emitted `Schema.String.check(Schema.isUUID())` for
|
|
16
|
+
those columns, and decoding real data threw `Die`/`ParseError`
|
|
17
|
+
("Expected a UUID, got \"acct\_…\"") at runtime.
|
|
18
|
+
|
|
19
|
+
Prisma always records a genuine `uuid` column via the `@db.Uuid` native type (a
|
|
20
|
+
bare `String` maps to `text`), so the native-type and `@db.Uuid`-documentation
|
|
21
|
+
checks already capture 100% of real UUID columns. The name-pattern tier only
|
|
22
|
+
ever contradicted that authoritative information, so it has been removed.
|
|
23
|
+
|
|
24
|
+
`isUuidField` now returns true only when:
|
|
25
|
+
1. `field.nativeType[0] === 'Uuid'` (a `@db.Uuid` column), or
|
|
26
|
+
2. the field documentation includes `@db.Uuid`.
|
|
27
|
+
|
|
28
|
+
**Migration:** columns that are genuinely UUID-typed are unaffected (they carry
|
|
29
|
+
`@db.Uuid`). Columns that were relying on name inference to get UUID validation
|
|
30
|
+
lose it — which is the fix, since they were text. To keep an explicit UUID check
|
|
31
|
+
on a non-`@db.Uuid` column, add `/// @db.Uuid` to the field, or override its
|
|
32
|
+
schema with `/// @customType(...)`.
|
|
33
|
+
|
|
34
|
+
## 6.0.0-next.3
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- ff58e31: Fix: implicit M:N join tables now expose their physical `A`/`B` columns in the
|
|
39
|
+
Kysely `DB` interface.
|
|
40
|
+
|
|
41
|
+
Kysely uses `DB`-interface field names as literal SQL column identifiers. The
|
|
42
|
+
join-table entry was emitted as `Schema.Schema.Type<typeof JoinTable>`, whose
|
|
43
|
+
keys are the **decoded** semantic names (`product_id`, `product_tag_id`). But an
|
|
44
|
+
implicit many-to-many table's physical Postgres columns are `A`/`B` (Prisma's
|
|
45
|
+
convention), so a query like
|
|
46
|
+
`db.selectFrom('_product_tags').where('_product_tags.product_id', ...)` emitted
|
|
47
|
+
`WHERE product_id` against a table that only has `A`/`B` → runtime SQL error.
|
|
48
|
+
|
|
49
|
+
The join-table `DB` entry is now `Schema.Codec.Encoded<typeof JoinTable>`, whose
|
|
50
|
+
keys are the **encoded** physical columns `A`/`B` (carrying the branded
|
|
51
|
+
`columnType` values, so joins remain type-safe against the parent table's branded
|
|
52
|
+
id). The semantic-name mapping still lives only in the schema's
|
|
53
|
+
`Schema.encodeKeys`, used when decoding a raw DB row. Regular (non-join) model
|
|
54
|
+
tables are unchanged (`Schema.Schema.Type<typeof Model>`).
|
|
55
|
+
|
|
3
56
|
## 6.0.0-next.2
|
|
4
57
|
|
|
5
58
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -121,11 +121,18 @@ Arrays → `Schema.Array(t)`. Nullable → `Schema.NullOr(t)`.
|
|
|
121
121
|
|
|
122
122
|
## UUID Detection
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
A column is treated as a UUID only when Prisma's type information says so:
|
|
125
125
|
|
|
126
126
|
1. Native type: `@db.Uuid`
|
|
127
|
-
2. Documentation: `@db.Uuid` in field comment
|
|
128
|
-
|
|
127
|
+
2. Documentation: `@db.Uuid` in the field comment (`/// @db.Uuid`)
|
|
128
|
+
|
|
129
|
+
UUID is a column type, not a naming convention — a bare `String` maps to `text`,
|
|
130
|
+
so `@db.Uuid` always captures genuine UUID columns. Field-name inference
|
|
131
|
+
(`*_id`, `*_uuid`, …) is intentionally NOT used: external identifiers such as
|
|
132
|
+
Stripe IDs (`acct_…`, `cus_…`) are text but end in `_id`, and inferring UUID
|
|
133
|
+
from the name produced false `Schema.isUUID()` checks that crashed at decode
|
|
134
|
+
time. Mark a non-`@db.Uuid` column as a UUID explicitly via `/// @db.Uuid`, or
|
|
135
|
+
override its schema entirely with `@customType(...)`.
|
|
129
136
|
|
|
130
137
|
## Custom Type Overrides
|
|
131
138
|
|
|
@@ -169,6 +176,11 @@ export const ProductToProductTag = Schema.Struct({
|
|
|
169
176
|
}).pipe(Schema.encodeKeys({ product_id: 'A', product_tag_id: 'B' }));
|
|
170
177
|
```
|
|
171
178
|
|
|
179
|
+
In the Kysely `DB` interface the join table is typed by its **encoded** shape
|
|
180
|
+
(`Schema.Codec.Encoded<typeof ProductToProductTag>` → `{ A, B }`), so you query
|
|
181
|
+
the physical columns directly: `db.selectFrom('_product_tags').where('_product_tags.A', '=', productId)`.
|
|
182
|
+
`Schema.decode` of a raw row maps `A`/`B` back to `product_id`/`product_tag_id`.
|
|
183
|
+
|
|
172
184
|
## Package Exports
|
|
173
185
|
|
|
174
186
|
| Entry | Contents |
|
|
@@ -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;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAI3D;;;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;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,UAc1F;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAK5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,UAEhG;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,UAIzD;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/kysely/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAI3D;;;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;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,UAc1F;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAK5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,UAEhG;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,UAIzD;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,aAAa,UAYzE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,EAC7B,UAAU,GAAE,aAAa,EAAO,UAajC"}
|
package/dist/kysely/type.js
CHANGED
|
@@ -83,7 +83,15 @@ export function generateDBInterfaceEntry(model) {
|
|
|
83
83
|
export function generateJoinTableDBInterfaceEntry(joinTable) {
|
|
84
84
|
const { tableName, relationName } = joinTable;
|
|
85
85
|
const schemaName = toPascalCase(relationName);
|
|
86
|
-
|
|
86
|
+
// Use the ENCODED type (the `Schema.encodeKeys` mapping), NOT the decoded
|
|
87
|
+
// `Schema.Schema.Type`. Kysely uses the DB-interface field names as literal SQL
|
|
88
|
+
// column identifiers, and an implicit M:N join table's physical columns are
|
|
89
|
+
// `A`/`B` (Prisma's convention) — not the semantic `*_id` names. The decoded
|
|
90
|
+
// type has the semantic names (for `Schema.decode` output); the encoded type
|
|
91
|
+
// keeps `A`/`B` with the branded `columnType` values, so queries like
|
|
92
|
+
// `db.selectFrom('_x').where('_x.A', ...)` emit valid SQL while joins stay
|
|
93
|
+
// type-safe against the parent table's branded id.
|
|
94
|
+
return ` ${tableName}: Schema.Codec.Encoded<typeof ${schemaName}>;`;
|
|
87
95
|
}
|
|
88
96
|
/**
|
|
89
97
|
* Generate complete DB interface including join tables
|
package/dist/kysely/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/kysely/type.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,OAAO,eAAe,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAiB;IAC9C,OAAO,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB,EAAE,KAAiB,EAAE,SAAkB;IACzF,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,yEAAyE;QACzE,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACtE,OAAO,cAAc,MAAM,+BAA+B,CAAC;IAC7D,CAAC;SAAM,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,aAAa,SAAS,GAAG,CAAC;IACnC,CAAC;IACD,kFAAkF;IAClF,4EAA4E;IAC5E,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC1B,OAAO,cAAc,SAAS,KAAK,SAA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/**
|
|
3
|
-
* Check if a field is a UUID
|
|
4
|
-
*
|
|
3
|
+
* Check if a field is a UUID, based solely on the authoritative DMMF type info.
|
|
4
|
+
*
|
|
5
|
+
* UUID is a *column type*, not a naming convention. Prisma always records a
|
|
6
|
+
* `uuid` column as the `@db.Uuid` native type (a bare `String` maps to `text`),
|
|
7
|
+
* so the native-type/`@db.Uuid` checks capture every genuine UUID column.
|
|
8
|
+
*
|
|
9
|
+
* A previous third tier inferred UUID from field-name patterns (`id`, `*_id`,
|
|
10
|
+
* `*_uuid`, `uuid`). That was a false-positive generator: any external-system
|
|
11
|
+
* identifier stored as text — Stripe IDs (`acct_…`, `cus_…`, `txn_…`), slugs,
|
|
12
|
+
* provider/session references — ends in `_id` without being a UUID, yet got
|
|
13
|
+
* `Schema.isUUID()` applied and then died at decode time on real data. The DMMF
|
|
14
|
+
* already knows the real type, so the name guess only ever contradicted ground
|
|
15
|
+
* truth. It has been removed; use `/// @db.Uuid` (or a real `@db.Uuid` column)
|
|
16
|
+
* to mark UUID columns explicitly.
|
|
5
17
|
*/
|
|
6
18
|
export declare function isUuidField(field: DMMF.Field): boolean;
|
|
7
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/prisma/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/prisma/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAY5C;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,UAE/C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAEhD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAE1C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAEhD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAE5C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;;;;;;;;;;KAEjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;;;;;;;;;;;;;;;;;;;;;KAE/D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,UAE/C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;;;;;;;;;;KAEvD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;;;;;;;;;;;;;;;;;;;;;KAEvD"}
|
package/dist/prisma/type.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Check if a field is a UUID
|
|
3
|
-
*
|
|
2
|
+
* Check if a field is a UUID, based solely on the authoritative DMMF type info.
|
|
3
|
+
*
|
|
4
|
+
* UUID is a *column type*, not a naming convention. Prisma always records a
|
|
5
|
+
* `uuid` column as the `@db.Uuid` native type (a bare `String` maps to `text`),
|
|
6
|
+
* so the native-type/`@db.Uuid` checks capture every genuine UUID column.
|
|
7
|
+
*
|
|
8
|
+
* A previous third tier inferred UUID from field-name patterns (`id`, `*_id`,
|
|
9
|
+
* `*_uuid`, `uuid`). That was a false-positive generator: any external-system
|
|
10
|
+
* identifier stored as text — Stripe IDs (`acct_…`, `cus_…`, `txn_…`), slugs,
|
|
11
|
+
* provider/session references — ends in `_id` without being a UUID, yet got
|
|
12
|
+
* `Schema.isUUID()` applied and then died at decode time on real data. The DMMF
|
|
13
|
+
* already knows the real type, so the name guess only ever contradicted ground
|
|
14
|
+
* truth. It has been removed; use `/// @db.Uuid` (or a real `@db.Uuid` column)
|
|
15
|
+
* to mark UUID columns explicitly.
|
|
4
16
|
*/
|
|
5
17
|
export function isUuidField(field) {
|
|
6
|
-
//
|
|
18
|
+
// Native type — the authoritative signal for a `uuid` column.
|
|
7
19
|
if (field.nativeType?.[0] === 'Uuid') {
|
|
8
20
|
return true;
|
|
9
21
|
}
|
|
10
|
-
//
|
|
22
|
+
// `@db.Uuid` recorded in the field's documentation/attributes.
|
|
11
23
|
if (field.documentation?.includes('@db.Uuid')) {
|
|
12
24
|
return true;
|
|
13
25
|
}
|
|
14
|
-
|
|
15
|
-
if (field.type !== 'String') {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const uuidFieldPatterns = [
|
|
19
|
-
/^id$/, // Primary ID fields
|
|
20
|
-
/_id$/, // Foreign key ID fields
|
|
21
|
-
/^.*_uuid$/, // uuid suffix
|
|
22
|
-
/^uuid$/, // Direct uuid fields
|
|
23
|
-
];
|
|
24
|
-
return uuidFieldPatterns.some((pattern) => pattern.test(field.name));
|
|
26
|
+
return false;
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
29
|
* Get the database column name for a field (respects @map directive)
|
package/dist/prisma/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/prisma/type.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/prisma/type.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC3C,8DAA8D;IAC9D,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC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