prisma-effect-kysely 6.0.0-next.3 → 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 CHANGED
@@ -1,5 +1,36 @@
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
+
3
34
  ## 6.0.0-next.3
4
35
 
5
36
  ### 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
- Priority order:
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
- 3. Field name pattern: `id`, `*_id`, `*_uuid`, `uuid`
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
 
@@ -1,7 +1,19 @@
1
1
  import type { DMMF } from '@prisma/generator-helper';
2
2
  /**
3
- * Check if a field is a UUID using native DMMF type information
4
- * 3-tier detection: native type � documentation � field name patterns
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;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAwB5C;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"}
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"}
@@ -1,27 +1,29 @@
1
1
  /**
2
- * Check if a field is a UUID using native DMMF type information
3
- * 3-tier detection: native type � documentation � field name patterns
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
- // 1. Check native type (most reliable)
18
+ // Native type the authoritative signal for a `uuid` column.
7
19
  if (field.nativeType?.[0] === 'Uuid') {
8
20
  return true;
9
21
  }
10
- // 2. Check documentation for @db.Uuid
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
- // 3. Fallback: Field name patterns (only for String type)
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)
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/prisma/type.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC3C,uCAAuC;IACvC,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sCAAsC;IACtC,IAAI,KAAK,CAAC,aAAa,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9C,OAAO,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;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAA6B;IACtD,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACrE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-effect-kysely",
3
- "version": "6.0.0-next.3",
3
+ "version": "6.0.0-next.4",
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",