prisma-effect-kysely 5.8.0 → 5.10.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 CHANGED
@@ -1,5 +1,54 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - be1a22e: 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
+ ## 5.9.0
35
+
36
+ ### Minor Changes
37
+
38
+ - 5f07c8f: fix: regular tables in DB interface use `Schema.Schema.Type`, join tables use `Schema.Schema.Encoded`
39
+
40
+ 5.7.0 flipped the DB interface to `Schema.Schema.Encoded` for **all** tables to fix the join-table column-name bug (`_product_tags.product_id` was decoded-name; SQL needs `A`). That was the right fix for join tables but accidentally **stripped branded IDs** for regular tables — `Schema.Schema.Encoded<typeof X>` strips `Schema.brand(...)` because brands live on the Type side.
41
+
42
+ Concrete consequence: every Kysely consumer queried `result.seller_id: string` instead of `result.seller_id: string & Brand<"SellerId">`. Branded ID type safety silently disabled across the entire monorepo.
43
+
44
+ Fix: the two table categories need different treatment.
45
+ - **Regular tables**: `Schema.Schema.Type<typeof X>` — preserves branded IDs (`string & Brand<"SellerId">`) and the `ColumnType<S, I, U>` `__select__`/`__insert__`/`__update__` phantoms. Type === Encoded for column names anyway because regular tables don't use `Schema.fromKey`.
46
+ - **Join tables**: `Schema.Schema.Encoded<typeof X>` — only join tables use `Schema.fromKey('A')` to remap DB columns `A`/`B` to semantic names. Type would expose the decoded names that Kysely passes to SQL verbatim → "column does not exist". Encoded preserves real column names.
47
+
48
+ Effectively: pick the side that matches the _intended consumer view_. For non-`fromKey` tables, that's the Type side (richer info, brand info preserved). For `fromKey` tables, that's the Encoded side (matches DB).
49
+
50
+ **Migration**: regular-table consumers regain `Brand<...>` IDs immediately. Join-table consumers (`_product_tags.A`/`B` queries) unchanged from 5.7.0 — those still expose real DB column names.
51
+
3
52
  ## 5.8.0
4
53
 
5
54
  ### Minor Changes
package/README.md CHANGED
@@ -90,11 +90,18 @@ Arrays → `Schema.Array(t)`. Nullable → `Schema.NullOr(t)`. `DateFromInput` a
90
90
 
91
91
  ## UUID Detection
92
92
 
93
- Priority order:
93
+ A column is treated as a UUID only when Prisma's type information says so:
94
94
 
95
95
  1. Native type: `@db.Uuid`
96
- 2. Documentation: `@db.Uuid` in field comment
97
- 3. Field name pattern: `id`, `*_id`, `*_uuid`, `uuid`
96
+ 2. Documentation: `@db.Uuid` in the field comment (`/// @db.Uuid`)
97
+
98
+ UUID is a column type, not a naming convention — a bare `String` maps to `text`,
99
+ so `@db.Uuid` always captures genuine UUID columns. Field-name inference
100
+ (`*_id`, `*_uuid`, …) is intentionally NOT used: external identifiers such as
101
+ Stripe IDs (`acct_…`, `cus_…`) are text but end in `_id`, and inferring UUID
102
+ from the name produced false `Schema.isUUID()` checks that crashed at decode
103
+ time. Mark a non-`@db.Uuid` column as a UUID explicitly via `/// @db.Uuid`, or
104
+ override its schema entirely with `@customType(...)`.
98
105
 
99
106
  ## Custom Type Overrides
100
107
 
@@ -32,20 +32,22 @@ export declare function buildKyselyFieldType(baseFieldType: string, field: DMMF.
32
32
  /**
33
33
  * Generate DB interface entry for a model
34
34
  *
35
- * Uses Schema.Schema.Encoded<Model> because the DB interface IS the SQL
36
- * contract column names and types must match what Postgres actually
37
- * sees. Encoded is the on-the-wire / on-disk shape; Type is the decoded
38
- * runtime shape after `Schema.decode` (which Kysely never runs).
35
+ * Uses Schema.Schema.Type<Model> for regular tables. The Type side
36
+ * preserves branded IDs (e.g. `string & Brand<"SellerId">`), which is
37
+ * what Kysely's Selectable/Insertable/Updateable consumers want.
39
38
  *
40
- * For regular tables: Type === Encoded, behavior unchanged.
39
+ * Regular tables don't use Schema.fromKey, so `Type === Encoded` for
40
+ * column names — both shapes have the same key structure. The
41
+ * difference is at the leaf level: Type preserves brands and refinements,
42
+ * Encoded strips them. For a SQL contract, brand info is harmless and
43
+ * useful (Kysely passes it through to consumers).
41
44
  *
42
- * For tables using Schema.fromKey/propertySignature (e.g. Prisma implicit
43
- * M:N join tables where TS field `product_id` maps to DB column `A`),
44
- * Encoded preserves the real DB column names so Kysely emits valid SQL.
45
+ * Join tables are different see generateJoinTableDBInterfaceEntry —
46
+ * because they use Schema.fromKey to remap column names, and only
47
+ * Encoded preserves the real DB column names.
45
48
  *
46
49
  * ColumnType<S, I, U> brand preserves the __select__/__insert__/__update__
47
- * phantom properties on both sides (Type and Encoded), so INSERT/UPDATE
48
- * type inference still works correctly.
50
+ * phantom properties on both sides, so INSERT/UPDATE inference works.
49
51
  */
50
52
  export declare function generateDBInterfaceEntry(model: DMMF.Model): string;
51
53
  /**
@@ -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;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,UAMrE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,UAQhG;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,UAIzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,aAAa,UAIzE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,EAC7B,UAAU,GAAE,aAAa,EAAO,UAajC"}
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;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,UAMrE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,UAQhG;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,UAIzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,aAAa,UAIzE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,EAC7B,UAAU,GAAE,aAAa,EAAO,UAajC"}
@@ -63,25 +63,27 @@ export function buildKyselyFieldType(baseFieldType, field, modelName) {
63
63
  /**
64
64
  * Generate DB interface entry for a model
65
65
  *
66
- * Uses Schema.Schema.Encoded<Model> because the DB interface IS the SQL
67
- * contract column names and types must match what Postgres actually
68
- * sees. Encoded is the on-the-wire / on-disk shape; Type is the decoded
69
- * runtime shape after `Schema.decode` (which Kysely never runs).
66
+ * Uses Schema.Schema.Type<Model> for regular tables. The Type side
67
+ * preserves branded IDs (e.g. `string & Brand<"SellerId">`), which is
68
+ * what Kysely's Selectable/Insertable/Updateable consumers want.
70
69
  *
71
- * For regular tables: Type === Encoded, behavior unchanged.
70
+ * Regular tables don't use Schema.fromKey, so `Type === Encoded` for
71
+ * column names — both shapes have the same key structure. The
72
+ * difference is at the leaf level: Type preserves brands and refinements,
73
+ * Encoded strips them. For a SQL contract, brand info is harmless and
74
+ * useful (Kysely passes it through to consumers).
72
75
  *
73
- * For tables using Schema.fromKey/propertySignature (e.g. Prisma implicit
74
- * M:N join tables where TS field `product_id` maps to DB column `A`),
75
- * Encoded preserves the real DB column names so Kysely emits valid SQL.
76
+ * Join tables are different see generateJoinTableDBInterfaceEntry —
77
+ * because they use Schema.fromKey to remap column names, and only
78
+ * Encoded preserves the real DB column names.
76
79
  *
77
80
  * ColumnType<S, I, U> brand preserves the __select__/__insert__/__update__
78
- * phantom properties on both sides (Type and Encoded), so INSERT/UPDATE
79
- * type inference still works correctly.
81
+ * phantom properties on both sides, so INSERT/UPDATE inference works.
80
82
  */
81
83
  export function generateDBInterfaceEntry(model) {
82
84
  const tableName = model.dbName || model.name;
83
85
  const modelName = toPascalCase(model.name);
84
- return ` ${tableName}: Schema.Schema.Encoded<typeof ${modelName}>;`;
86
+ return ` ${tableName}: Schema.Schema.Type<typeof ${modelName}>;`;
85
87
  }
86
88
  /**
87
89
  * Generate DB interface entry for a join table
@@ -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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AE,SAAS,CAAC,CAAC;IAEpE,yDAAyD;IACzD,SAAS,GAAG,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAEhD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAiB;IACxD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC;IAC7C,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3C,OAAO,KAAK,SAAS,+BAA+B,SAAS,IAAI,CAAC;AACpE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iCAAiC,CAAC,SAAwB;IACxE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC;IAC9C,MAAM,UAAU,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;IAC9C,OAAO,KAAK,SAAS,kCAAkC,UAAU,IAAI,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,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,KAAK,UAAU,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACrE,CAAC,CAAC,EAAE,CAAC;IAET,OAAO;;EAEP,YAAY,GAAG,gBAAgB;EAC/B,CAAC;AACH,CAAC"}
@@ -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;;;;;;;;;;KA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,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,IAAI,CAAC;IACd,CAAC;IAED,0DAA0D;IAC1D,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,iBAAiB,GAAG;QACxB,MAAM,EAAE,oBAAoB;QAC5B,MAAM,EAAE,wBAAwB;QAChC,WAAW,EAAE,cAAc;QAC3B,QAAQ,EAAE,qBAAqB;KACvB,CAAC;IAEX,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAiB;IAC9C,OAAO,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,OAAO,KAAK,CAAC,eAAe,KAAK,IAAI,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAiB;IACzC,OAAO,KAAK,CAAC,IAAI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B;IAC9D,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAiB;IAC9C,OAAO,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC;AACpC,CAAC;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;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": "5.8.0",
3
+ "version": "5.10.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",