@shivaedev/effect-prisma 0.4.0 → 0.4.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 CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.4.2 - 2026-08-03
6
+
7
+ ### Fixed
8
+
9
+ - Provide a contract-normalization command that corrects Prisma Next's
10
+ PostgreSQL timestamp declarations without recursively expanding large client
11
+ types.
12
+
13
+ ## 0.4.1 - 2026-08-03
14
+
15
+ ### Fixed
16
+
17
+ - Expose PostgreSQL timestamp and timestamp-with-time-zone fields as `Date`,
18
+ matching Prisma Next's runtime codecs even when its generated contract renders
19
+ those fields as branded strings.
20
+
5
21
  ## 0.4.0 - 2026-08-03
6
22
 
7
23
  ### Added
package/README.md CHANGED
@@ -15,6 +15,16 @@ pnpm add @shivaedev/effect-prisma effect
15
15
  Generate a Prisma Next contract in the application, then create its database
16
16
  service:
17
17
 
18
+ ```sh
19
+ prisma-next contract emit
20
+ effect-prisma-normalize path/to/generated/contract.d.ts
21
+ ```
22
+
23
+ The normalization step is idempotent and currently required because Prisma
24
+ Next's generated PostgreSQL timestamp output declarations do not match its
25
+ runtime `Date` codecs. It fails when Prisma emits an unfamiliar timestamp shape
26
+ instead of silently producing weakened types.
27
+
18
28
  ```ts
19
29
  import { makeDatabase } from "@shivaedev/effect-prisma"
20
30
  import { contractJson, type Contract } from "./generated/contract.js"
@@ -95,6 +105,10 @@ ordering, pagination, distinct queries, aggregates, grouping, and
95
105
  create/update/delete terminals. Model variants are deliberately deferred rather
96
106
  than exposed with weakened types.
97
107
 
108
+ PostgreSQL timestamp and timestamp-with-time-zone fields use JavaScript `Date`
109
+ values for reads, writes, filters, selections, includes, and Streams after the
110
+ generated contract is normalized.
111
+
98
112
  ## Transactions
99
113
 
100
114
  Transactions keep the same database API and are implicitly scoped:
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=normalize-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-contract.d.ts","sourceRoot":"","sources":["../../src/bin/normalize-contract.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { readFile, writeFile } from "node:fs/promises";
3
+ import { normalizePrismaNextContractTypes } from "../internal/contract-normalization.js";
4
+ const arguments_ = process.argv.slice(2);
5
+ if (arguments_.length !== 1 || arguments_[0] === undefined) {
6
+ throw new Error("Usage: effect-prisma-normalize <generated-contract.d.ts>");
7
+ }
8
+ const contractPath = arguments_[0];
9
+ const source = await readFile(contractPath, "utf8");
10
+ const normalized = normalizePrismaNextContractTypes(source);
11
+ if (normalized !== source) {
12
+ await writeFile(contractPath, normalized);
13
+ }
14
+ //# sourceMappingURL=normalize-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-contract.js","sourceRoot":"","sources":["../../src/bin/normalize-contract.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAEzF,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACzC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;IAC5D,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AACpD,MAAM,UAAU,GAAG,gCAAgC,CAAC,MAAM,CAAC,CAAC;AAE5D,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;IAC3B,MAAM,SAAS,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Align Prisma Next's generated PostgreSQL timestamp declarations with the
3
+ * JavaScript Dates accepted and returned by its runtime codecs.
4
+ */
5
+ export declare const normalizePrismaNextContractTypes: (source: string) => string;
6
+ //# sourceMappingURL=contract-normalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-normalization.d.ts","sourceRoot":"","sources":["../../src/internal/contract-normalization.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,gCAAgC,GAAI,QAAQ,MAAM,KAAG,MAUjE,CAAC"}
@@ -0,0 +1,14 @@
1
+ const timestampReference = /\b(?:Timestamp|Timestamptz)<(?:\d+|undefined)>/g;
2
+ const unsupportedTimestampReference = /\b(?:Timestamp|Timestamptz)\s*</;
3
+ /**
4
+ * Align Prisma Next's generated PostgreSQL timestamp declarations with the
5
+ * JavaScript Dates accepted and returned by its runtime codecs.
6
+ */
7
+ export const normalizePrismaNextContractTypes = (source) => {
8
+ const normalized = source.replaceAll(timestampReference, "Date");
9
+ if (unsupportedTimestampReference.test(normalized)) {
10
+ throw new Error("Unsupported Prisma Next timestamp declaration; update effect-prisma before using this generated contract");
11
+ }
12
+ return normalized;
13
+ };
14
+ //# sourceMappingURL=contract-normalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-normalization.js","sourceRoot":"","sources":["../../src/internal/contract-normalization.ts"],"names":[],"mappings":"AAAA,MAAM,kBAAkB,GAAG,iDAAiD,CAAC;AAC7E,MAAM,6BAA6B,GAAG,iCAAiC,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,MAAc,EAAU,EAAE;IAC1E,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IAEjE,IAAI,6BAA6B,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACd,0GAA0G,CAC1G,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/effect-prisma",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Effect-native PostgreSQL queries and transactions for Prisma Next",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -17,6 +17,9 @@
17
17
  "node": ">=24"
18
18
  },
19
19
  "sideEffects": false,
20
+ "bin": {
21
+ "effect-prisma-normalize": "./dist/bin/normalize-contract.js"
22
+ },
20
23
  "files": [
21
24
  "dist",
22
25
  "src",
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readFile, writeFile } from "node:fs/promises";
4
+ import { normalizePrismaNextContractTypes } from "../internal/contract-normalization.js";
5
+
6
+ const arguments_ = process.argv.slice(2);
7
+ if (arguments_.length !== 1 || arguments_[0] === undefined) {
8
+ throw new Error("Usage: effect-prisma-normalize <generated-contract.d.ts>");
9
+ }
10
+
11
+ const contractPath = arguments_[0];
12
+ const source = await readFile(contractPath, "utf8");
13
+ const normalized = normalizePrismaNextContractTypes(source);
14
+
15
+ if (normalized !== source) {
16
+ await writeFile(contractPath, normalized);
17
+ }
@@ -0,0 +1,18 @@
1
+ const timestampReference = /\b(?:Timestamp|Timestamptz)<(?:\d+|undefined)>/g;
2
+ const unsupportedTimestampReference = /\b(?:Timestamp|Timestamptz)\s*</;
3
+
4
+ /**
5
+ * Align Prisma Next's generated PostgreSQL timestamp declarations with the
6
+ * JavaScript Dates accepted and returned by its runtime codecs.
7
+ */
8
+ export const normalizePrismaNextContractTypes = (source: string): string => {
9
+ const normalized = source.replaceAll(timestampReference, "Date");
10
+
11
+ if (unsupportedTimestampReference.test(normalized)) {
12
+ throw new Error(
13
+ "Unsupported Prisma Next timestamp declaration; update effect-prisma before using this generated contract",
14
+ );
15
+ }
16
+
17
+ return normalized;
18
+ };