data-api-client 2.3.0 → 2.4.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/README.md CHANGED
@@ -5,23 +5,32 @@
5
5
 
6
6
  > **Using v1.x?** See [README_v1.md](README_v1.md) for v1.x documentation.
7
7
 
8
- The **Data API Client** is a lightweight wrapper that makes working with the Amazon Aurora Serverless Data API incredibly easy. The Data API makes you annotate every field value with its type, both going in and coming back, which gets old fast. This library handles that for you, mapping native JavaScript types to the Data API's format and back automatically. It's basically a [DocumentClient](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html) for the Data API, with clean **transactions** and **automatic retry logic** for scale-to-zero clusters built in. It also gives you drop-in **compatibility layers** for mysql2 and pg, so you can plug the Data API into your favorite ORMs and query builders. Point **Drizzle**, **Kysely**, or **Knex** at it and keep writing the queries you already know.
8
+ The **Data API Client** is a lightweight wrapper that makes using the Amazon Aurora Serverless Data API with your favorite ORMs and query builders incredibly easy. It ships with drop-in **compatibility layers** for the `mysql2` and `pg` drivers, plus dedicated adapters for **Knex** and **Prisma**. Point **Drizzle**, **Kysely**, **Knex**, or **Prisma** at the Data API and keep writing the queries you already know, with no changes to your models or query code.
9
9
 
10
- For more information about the Aurora Serverless Data API, you can review the [official documentation](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) or read [Aurora Serverless Data API: An (updated) First Look](https://www.jeremydaly.com/aurora-serverless-data-api-a-first-look/) for some more insights on performance.
10
+ Prefer raw SQL? The client gives you a clean, [DocumentClient](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html)-style interface and handles the tedious part for you. The Data API makes you annotate every field value with its type, both going in and coming back, which gets old fast. This library maps native JavaScript types to the Data API's format and back automatically.
11
11
 
12
- ## What's New in v2.3
12
+ Either way, you get clean **transactions** and **automatic retry logic** for scale-to-zero clusters built in.
13
13
 
14
- - **Knex support**: the `data-api-client/compat/knex` helpers let Knex run on the Data API for both MySQL and PostgreSQL.
15
- - `createKnexMySQLClient()` and `createKnexPgClient()` return a custom Knex `client` wired to the Data API
16
- - **Transactions** work: `db.transaction()` commits on success and rolls back when the callback throws. Nested transactions are rejected, since the Data API has no `SAVEPOINT` primitive.
17
- - The common query-builder surface is covered by integration tests for both engines: selects, the `where` family, joins, aggregates, ordering/pagination, unions, subqueries, CTEs, `insert`/`update`/`del`, `returning`, `increment`/`decrement`, and `onConflict().merge()` upserts
18
- - `knex` is an optional peer dependency
19
- - Fixes two latent compatibility-layer bugs that also affected non-Knex callers: pg parameter binding via the config-object callback form, and mysql2 callback parsing
14
+ For more information about the Aurora Serverless Data API, you can review the [official documentation](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html).
20
15
 
21
- See the [Knex section](#knex-query-builder) for usage.
16
+ ## What's New in v2.4
17
+
18
+ - **Prisma support**: the `data-api-client/compat/prisma` adapter lets Prisma Client run on the Data API for both PostgreSQL and MySQL.
19
+ - `createPrismaPgAdapter()` and `createPrismaMySQLAdapter()` return a Prisma 7 driver adapter you hand straight to `new PrismaClient({ adapter })`
20
+ - The full Prisma Client query API is covered for both engines: CRUD, aggregation and `groupBy`, the filter operators, pagination and cursors, `select`/`include`/`omit`, nested writes, relation filters, atomic number updates, JSON, `Decimal`/`BigInt`/`DateTime`, PostgreSQL scalar arrays, raw queries, and transactions
21
+ - **Transactions** map to the native Data API lifecycle; nested savepoints are rejected, same as the other layers
22
+ - **Migrations** run through Prisma's schema engine, which needs a direct connection the Data API doesn't provide. Point it at your Aurora cluster endpoint (the same split Neon and PlanetScale use) or generate the SQL offline. See the Prisma section for details.
23
+ - `@prisma/driver-adapter-utils` is an optional peer dependency
24
+
25
+ See the [Prisma section](#prisma) for usage.
22
26
 
23
27
  ## Changelog
24
28
 
29
+ ### v2.3
30
+
31
+ - **Knex support**: `data-api-client/compat/knex` (`createKnexMySQLClient()` / `createKnexPgClient()`) runs Knex on the Data API for MySQL and PostgreSQL, including transactions (nested transactions rejected, since the Data API has no `SAVEPOINT` primitive). `knex` is an optional peer dependency. See the [Knex section](#knex-query-builder).
32
+ - Fixed two latent compatibility-layer bugs that also affected non-Knex callers: pg parameter binding via the config-object callback form, and mysql2 callback parsing
33
+
25
34
  ### v2.2
26
35
 
27
36
  - Dependency updates, including a raised `@aws-sdk/client-rds-data` peer dependency floor
@@ -222,7 +231,7 @@ Below is a table containing all of the possible configuration options for the `d
222
231
 
223
232
  ### Automatic Retry Logic
224
233
 
225
- Version 2.1 includes built-in retry logic to handle Aurora Serverless scale-to-zero cluster wake-ups automatically. When your cluster is paused and needs to resume, the client will automatically retry your queries with optimized delays.
234
+ Version 2.1 introduced built-in retry logic to handle Aurora Serverless scale-to-zero cluster wake-ups automatically. When your cluster is paused and needs to resume, the client will automatically retry your queries with optimized delays.
226
235
 
227
236
  **Features:**
228
237
 
@@ -574,7 +583,7 @@ const data = dataApiClient({
574
583
 
575
584
  ## mysql2 and pg Compatibility Layers
576
585
 
577
- Version 2.1 introduces compatibility layers that allow you to use the Data API Client as a drop-in replacement for popular database libraries. This makes it easy to migrate existing applications or use ORMs without modification.
586
+ Version 2.1 introduced compatibility layers that allow you to use the Data API Client as a drop-in replacement for popular database libraries. This makes it easy to migrate existing applications or use ORMs without modification.
578
587
 
579
588
  ### mysql2 Compatibility
580
589
 
@@ -913,10 +922,52 @@ selects/`distinct`/`pluck`/`first`, the `where` family (`whereIn`, `whereNull`,
913
922
  `returning` (PostgreSQL), `increment`/`decrement`, and `onConflict().merge()` upserts.
914
923
  Streaming via `.stream()` is not supported, since the Data API has no cursor API.
915
924
 
925
+ #### Prisma
926
+
927
+ A drop-in Prisma 7 driver adapter so Prisma Client runs over the Aurora Data API, for both PostgreSQL and MySQL.
928
+
929
+ **Install:**
930
+
931
+ You need `@prisma/client` and `prisma` installed in your project. The adapter uses `@prisma/driver-adapter-utils`, which is an optional peer dependency of `data-api-client`. Install it alongside:
932
+
933
+ ```bash
934
+ npm install @prisma/client prisma @prisma/driver-adapter-utils
935
+ ```
936
+
937
+ **Usage (PostgreSQL):**
938
+
939
+ ```typescript
940
+ import { PrismaClient } from '@prisma/client'
941
+ import { createPrismaPgAdapter } from 'data-api-client/compat/prisma'
942
+
943
+ const adapter = createPrismaPgAdapter({
944
+ secretArn: process.env.SECRET_ARN,
945
+ resourceArn: process.env.RESOURCE_ARN,
946
+ database: 'mydb'
947
+ })
948
+
949
+ const prisma = new PrismaClient({ adapter })
950
+ ```
951
+
952
+ Use `createPrismaMySQLAdapter` for MySQL. It takes the same config shape.
953
+
954
+ **Limitations:**
955
+
956
+ - **Nested transactions** are not supported. They require SQL `SAVEPOINT`s, which the RDS Data API has no primitive for. Top-level interactive transactions (via `prisma.$transaction()`) work correctly.
957
+ - **Array parameters**: the Data API cannot bind array parameters directly. The Prisma adapter handles this for PostgreSQL native array columns by rewriting array values to `ARRAY[...]` constructor syntax automatically. The underlying Data API constraint remains; the rewrite happens in the adapter before the query reaches the wire.
958
+
959
+ **Migrations:**
960
+
961
+ Prisma driver adapters cover the **runtime query path only**. Prisma's Schema Engine (`prisma migrate`, `db push`, `db pull`) requires a direct database connection URL, which the Data API does not provide. This is the same split every serverless driver has. Neon uses a `directUrl`, PlanetScale uses a connection string, and driver adapters handle runtime while schema operations need a real connection.
962
+
963
+ The recommended approach: Aurora Serverless v2 also exposes a standard PostgreSQL/MySQL cluster endpoint. Point Prisma's migration `url` in `prisma.config.ts` at that direct Aurora endpoint, exactly like Neon's `directUrl` pattern, and use the Data API adapter at runtime only. This requires network access to the cluster endpoint (in-VPC CI, a bastion/tunnel/VPN, or a publicly accessible dev cluster).
964
+
965
+ If direct endpoint access is not available: generate migration SQL offline with `prisma migrate diff` (no live database connection needed; use schema-to-schema diffs to avoid the shadow-database requirement) and apply it over the Data API adapter.
966
+
916
967
  **Benefits of Compatibility Layers:**
917
968
 
918
969
  - **Zero code changes** when migrating from mysql2 or pg
919
- - **Full ORM support** (Drizzle, Kysely, Knex)
970
+ - **Full ORM support** (Drizzle, Kysely, Knex, Prisma)
920
971
  - **Automatic retry logic** for cluster wake-ups
921
972
  - **Connection pooling simulation** (getConnection, release)
922
973
  - **Both Promise and callback APIs** supported
@@ -981,7 +1032,7 @@ Despite these input limitations, **all array results are automatically converted
981
1032
 
982
1033
  ## PostgreSQL Data Type Support
983
1034
 
984
- Version 2.0 provides comprehensive support for PostgreSQL data types:
1035
+ Version 2.0 introduced comprehensive support for PostgreSQL data types:
985
1036
 
986
1037
  ### Numeric Types
987
1038
 
@@ -1107,7 +1158,7 @@ await data.query('INSERT INTO bookings (date_range) VALUES (:range::INT4RANGE)',
1107
1158
 
1108
1159
  ## TypeScript Support
1109
1160
 
1110
- Version 2.0 is written in TypeScript and provides comprehensive type definitions:
1161
+ Version 2.x is written in TypeScript and provides comprehensive type definitions:
1111
1162
 
1112
1163
  ```typescript
1113
1164
  import dataApiClient from 'data-api-client'
@@ -1144,6 +1195,12 @@ The RDS Data API does **not support binding array parameters** directly. Attempt
1144
1195
 
1145
1196
  Despite parameter limitations, array **results** work great! The Data API Client automatically converts PostgreSQL arrays in query results to native JavaScript arrays.
1146
1197
 
1198
+ ### Large result sets are capped at ~1 MB
1199
+
1200
+ The Data API returns at most about 1 MB of data per statement, and it has no server-side pagination. There's no cursor or `nextToken` to fetch the next chunk, so a single query that returns more than ~1 MB fails instead of paging.
1201
+
1202
+ The fix is to page the query yourself. Add a `LIMIT` and walk through the rows, and prefer keyset pagination (a `WHERE id > :lastId ORDER BY id LIMIT :pageSize` style) over `OFFSET`, which gets slow on deep pages. If you're using one of the ORM or query-builder layers, you already have this: Drizzle, Kysely, Knex, and Prisma all expose `take`/`skip`/`cursor`, so page the way you normally would and you won't hit the cap.
1203
+
1147
1204
  ### Some Advanced Types Have Limitations
1148
1205
 
1149
1206
  - **MACADDR**: Not supported by the Data API
@@ -1156,27 +1213,19 @@ Batch operations don't return `numberOfRecordsUpdated` for UPDATE/DELETE stateme
1156
1213
 
1157
1214
  ## Enabling Data API
1158
1215
 
1159
- In order to use the Data API, you must enable it on your Aurora Serverless Cluster and create a Secret. You also must grant your execution environment a number of permissions as outlined in the following sections.
1160
-
1161
- ### Enable Data API on your Aurora Cluster
1162
-
1163
- ![Enable Data API in Network & Security settings of your cluster](https://user-images.githubusercontent.com/2053544/58768968-79ee4300-8570-11e9-9266-1433182e0db2.png)
1164
-
1165
- You need to modify your Aurora cluster by clicking "ACTIONS" and then "Modify Cluster". Check the Data API box in the _Network & Security_ section and you're good to go. This works for Aurora Serverless v1, Aurora Serverless v2, and Aurora provisioned clusters.
1166
-
1167
- ### Set up a secret in the Secrets Manager
1168
-
1169
- Next you need to set up a secret in the Secrets Manager. This is actually quite straightforward. User name, password, encryption key (the default is probably fine for you), and select the database you want to access with the secret.
1170
-
1171
- ![Enter database credentials and select database to access](https://user-images.githubusercontent.com/2053544/58768974-912d3080-8570-11e9-8878-636dfb742b00.png)
1216
+ To use the Data API you need three things:
1172
1217
 
1173
- Next we give it a name, this is important, because this will be part of the arn when we set up permissions later. You can give it a description as well so you don't forget what this secret is about when you look at it in a few weeks.
1218
+ 1. **The Data API enabled on your Aurora cluster.** It's supported on Aurora Serverless v2 and Aurora provisioned clusters (Aurora Serverless v1 uses the original Data API). You can enable it when you create the cluster or by modifying an existing one.
1219
+ 2. **A Secrets Manager secret** with the database credentials. The Data API reads the secret instead of you passing credentials on every call.
1220
+ 3. **IAM permissions** for your execution environment (covered below).
1174
1221
 
1175
- ![Give your secret a name and add a description](https://user-images.githubusercontent.com/2053544/58768984-a7d38780-8570-11e9-8b21-199db5548c73.png)
1222
+ The AWS console and the list of supported engines change often, so rather than walk through a screenshot tour that goes stale, follow the official docs. They stay current:
1176
1223
 
1177
- You can then configure your rotation settings, if you want, and then you review and create your secret. Then you can click on your newly created secret and grab the arn, we're gonna need that next.
1224
+ - [Enabling the RDS Data API](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.enabling.html)
1225
+ - [Authorizing access to the Data API](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.access.html) (storing credentials in Secrets Manager and the IAM setup)
1226
+ - [Region and version availability](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.regions.html)
1178
1227
 
1179
- ![Click on your secret to get the arn.](https://user-images.githubusercontent.com/2053544/58768989-bae65780-8570-11e9-94fb-51f6fa7d34bf.png)
1228
+ You'll need your cluster's ARN and the secret's ARN to configure the client. See [Configuration Options](#configuration-options).
1180
1229
 
1181
1230
  ### Required Permissions
1182
1231
 
@@ -1188,7 +1237,6 @@ In order to use the Data API, your execution environment requires several IAM pe
1188
1237
  Statement:
1189
1238
  - Effect: 'Allow'
1190
1239
  Action:
1191
- - 'rds-data:ExecuteSql'
1192
1240
  - 'rds-data:ExecuteStatement'
1193
1241
  - 'rds-data:BatchExecuteStatement'
1194
1242
  - 'rds-data:BeginTransaction'
@@ -1208,7 +1256,6 @@ Statement:
1208
1256
  {
1209
1257
  "Effect": "Allow",
1210
1258
  "Action": [
1211
- "rds-data:ExecuteSql",
1212
1259
  "rds-data:ExecuteStatement",
1213
1260
  "rds-data:BatchExecuteStatement",
1214
1261
  "rds-data:BeginTransaction",
@@ -25,4 +25,5 @@ export interface MySQLError extends Error {
25
25
  }
26
26
  export declare function mapToPostgresError(error: any): PostgresError;
27
27
  export declare function mapToMySQLError(error: any): MySQLError;
28
+ export declare function mapToPrismaError(error: any, engine: 'pg' | 'mysql'): Error;
28
29
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/compat/errors.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,aAAc,SAAQ,KAAK;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EA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AAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAKD,MAAM,WAAW,UAAW,SAAQ,KAAK;IACvC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AA6BD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,GAAG,GAAG,aAAa,CAgE5D;AAKD,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,UAAU,CA+GtD;AAOD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAG,OAAO,GAAG,KAAK,CA+B1E"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapToPostgresError = mapToPostgresError;
4
4
  exports.mapToMySQLError = mapToMySQLError;
5
+ exports.mapToPrismaError = mapToPrismaError;
5
6
  function extractConstraintName(message) {
6
7
  const match = message.match(/constraint "([^"]+)"/);
7
8
  return match ? match[1] : undefined;
@@ -161,3 +162,39 @@ function mapToMySQLError(error) {
161
162
  }
162
163
  return mysqlError;
163
164
  }
165
+ function mapToPrismaError(error, engine) {
166
+ const message = (error === null || error === void 0 ? void 0 : error.message) || String(error);
167
+ const lower = message.toLowerCase();
168
+ let kind;
169
+ if (lower.includes('unique constraint') || lower.includes('duplicate')) {
170
+ kind = { kind: 'UniqueConstraintViolation' };
171
+ }
172
+ else if (lower.includes('foreign key')) {
173
+ kind = { kind: 'ForeignKeyConstraintViolation' };
174
+ }
175
+ else if (lower.includes('not-null') || lower.includes('null value') || lower.includes('cannot be null')) {
176
+ kind = { kind: 'NullConstraintViolation' };
177
+ }
178
+ else if ((lower.includes('relation') || lower.includes('table')) && lower.includes('does not exist')) {
179
+ kind = { kind: 'TableDoesNotExist' };
180
+ }
181
+ else if (lower.includes('column') && lower.includes('does not exist')) {
182
+ kind = { kind: 'ColumnNotFound' };
183
+ }
184
+ else if (engine === 'pg') {
185
+ kind = { kind: 'postgres', code: (error === null || error === void 0 ? void 0 : error.code) || '', severity: 'ERROR', message, detail: undefined, column: undefined, hint: undefined };
186
+ }
187
+ else {
188
+ kind = { kind: 'mysql', code: Number(error === null || error === void 0 ? void 0 : error.code) || 0, message, state: '' };
189
+ }
190
+ try {
191
+ const { DriverAdapterError } = require('@prisma/driver-adapter-utils');
192
+ return new DriverAdapterError(kind);
193
+ }
194
+ catch (_a) {
195
+ const fallback = new Error(message);
196
+ fallback.name = 'DriverAdapterError';
197
+ fallback.cause = kind;
198
+ return fallback;
199
+ }
200
+ }
@@ -3,6 +3,7 @@ export type { PgCompatClient, PgCompatPool, PgQueryResult } from './pg';
3
3
  export { createMySQLConnection, createMySQLPool } from './mysql2';
4
4
  export type { Connection, Pool, PoolConnection, MySQL2QueryResult } from './mysql2';
5
5
  export { createKnexMySQLClient, createKnexPgClient } from './knex';
6
+ export { createPrismaPgAdapter, createPrismaMySQLAdapter } from './prisma';
6
7
  export { mapToPostgresError, mapToMySQLError } from './errors';
7
8
  export type { PostgresError, MySQLError } from './errors';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compat/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACnD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAEvE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACjE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEnF,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAElE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC9D,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compat/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACnD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAEvE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACjE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEnF,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAClE,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAE1E,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC9D,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapToMySQLError = exports.mapToPostgresError = exports.createKnexPgClient = exports.createKnexMySQLClient = exports.createMySQLPool = exports.createMySQLConnection = exports.createPgPool = exports.createPgClient = void 0;
3
+ exports.mapToMySQLError = exports.mapToPostgresError = exports.createPrismaMySQLAdapter = exports.createPrismaPgAdapter = exports.createKnexPgClient = exports.createKnexMySQLClient = exports.createMySQLPool = exports.createMySQLConnection = exports.createPgPool = exports.createPgClient = void 0;
4
4
  var pg_1 = require("./pg");
5
5
  Object.defineProperty(exports, "createPgClient", { enumerable: true, get: function () { return pg_1.createPgClient; } });
6
6
  Object.defineProperty(exports, "createPgPool", { enumerable: true, get: function () { return pg_1.createPgPool; } });
@@ -10,6 +10,9 @@ Object.defineProperty(exports, "createMySQLPool", { enumerable: true, get: funct
10
10
  var knex_1 = require("./knex");
11
11
  Object.defineProperty(exports, "createKnexMySQLClient", { enumerable: true, get: function () { return knex_1.createKnexMySQLClient; } });
12
12
  Object.defineProperty(exports, "createKnexPgClient", { enumerable: true, get: function () { return knex_1.createKnexPgClient; } });
13
+ var prisma_1 = require("./prisma");
14
+ Object.defineProperty(exports, "createPrismaPgAdapter", { enumerable: true, get: function () { return prisma_1.createPrismaPgAdapter; } });
15
+ Object.defineProperty(exports, "createPrismaMySQLAdapter", { enumerable: true, get: function () { return prisma_1.createPrismaMySQLAdapter; } });
13
16
  var errors_1 = require("./errors");
14
17
  Object.defineProperty(exports, "mapToPostgresError", { enumerable: true, get: function () { return errors_1.mapToPostgresError; } });
15
18
  Object.defineProperty(exports, "mapToMySQLError", { enumerable: true, get: function () { return errors_1.mapToMySQLError; } });
@@ -0,0 +1,24 @@
1
+ import type { Engine } from './prisma-types';
2
+ export type Arity = 'scalar' | 'list';
3
+ export interface PrismaArgType {
4
+ scalarType: string;
5
+ arity: Arity;
6
+ dbType?: string;
7
+ }
8
+ export interface PrismaSqlQuery {
9
+ sql: string;
10
+ args: unknown[];
11
+ argTypes: PrismaArgType[];
12
+ }
13
+ export interface DataApiParam {
14
+ name: string;
15
+ value: Record<string, unknown>;
16
+ typeHint?: string;
17
+ cast?: string;
18
+ }
19
+ export interface BuiltQuery {
20
+ sql: string;
21
+ parameters: DataApiParam[];
22
+ }
23
+ export declare function buildQuery(query: PrismaSqlQuery, engine: Engine): BuiltQuery;
24
+ //# sourceMappingURL=prisma-params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-params.d.ts","sourceRoot":"","sources":["../../src/compat/prisma-params.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;AACrC,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AACD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,QAAQ,EAAE,aAAa,EAAE,CAAA;CAC1B;AACD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AACD,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,YAAY,EAAE,CAAA;CAC3B;AA+DD,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CA+C5E"}
@@ -0,0 +1,99 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildQuery = buildQuery;
4
+ function escapeRe(s) {
5
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
6
+ }
7
+ const PG_EMPTY_ARRAY_CAST = {
8
+ int: 'bigint',
9
+ bigint: 'bigint',
10
+ float: 'double precision',
11
+ decimal: 'numeric',
12
+ boolean: 'boolean',
13
+ uuid: 'uuid',
14
+ datetime: 'timestamp',
15
+ string: 'text',
16
+ enum: 'text'
17
+ };
18
+ function buildScalarParam(name, value, argType) {
19
+ if (value === null || value === undefined) {
20
+ return { name, value: { isNull: true } };
21
+ }
22
+ switch (argType.scalarType) {
23
+ case 'int':
24
+ return { name, value: { longValue: Number(value) } };
25
+ case 'bigint': {
26
+ const n = typeof value === 'bigint' ? value : BigInt(value);
27
+ if (n > BigInt(Number.MAX_SAFE_INTEGER) || n < BigInt(Number.MIN_SAFE_INTEGER)) {
28
+ return { name, value: { stringValue: n.toString() } };
29
+ }
30
+ return { name, value: { longValue: Number(n) } };
31
+ }
32
+ case 'float':
33
+ return { name, value: { doubleValue: Number(value) } };
34
+ case 'decimal':
35
+ return { name, value: { stringValue: String(value) }, typeHint: 'DECIMAL' };
36
+ case 'boolean':
37
+ return { name, value: { booleanValue: Boolean(value) } };
38
+ case 'uuid':
39
+ return { name, value: { stringValue: String(value) }, typeHint: 'UUID' };
40
+ case 'json':
41
+ return {
42
+ name,
43
+ value: { stringValue: typeof value === 'string' ? value : JSON.stringify(value) },
44
+ typeHint: 'JSON'
45
+ };
46
+ case 'datetime': {
47
+ const d = value instanceof Date ? value : new Date(value);
48
+ const iso = d.toISOString().replace('T', ' ').replace('Z', '');
49
+ return { name, value: { stringValue: iso }, typeHint: 'TIMESTAMP' };
50
+ }
51
+ case 'bytes': {
52
+ const buf = typeof value === 'string' ? Buffer.from(value, 'base64') : Buffer.from(value);
53
+ return { name, value: { blobValue: buf } };
54
+ }
55
+ case 'enum':
56
+ case 'string':
57
+ default:
58
+ return { name, value: { stringValue: String(value) } };
59
+ }
60
+ }
61
+ function buildQuery(query, engine) {
62
+ let sql;
63
+ if (engine === 'pg') {
64
+ sql = query.sql.replace(/\$(\d+)/g, (_m, n) => `:p${n}`);
65
+ }
66
+ else {
67
+ let i = 0;
68
+ sql = query.sql.replace(/\?/g, () => `:p${++i}`);
69
+ }
70
+ const parameters = [];
71
+ query.args.forEach((arg, idx) => {
72
+ var _a, _b;
73
+ const argType = (_a = query.argTypes[idx]) !== null && _a !== void 0 ? _a : { scalarType: 'unknown', arity: 'scalar' };
74
+ const name = `p${idx + 1}`;
75
+ const isPgArray = engine === 'pg' && Array.isArray(arg) && argType.scalarType !== 'json';
76
+ if (isPgArray) {
77
+ const elements = arg;
78
+ const placeholder = `:p${idx + 1}`;
79
+ if (elements.length === 0) {
80
+ const cast = (_b = PG_EMPTY_ARRAY_CAST[argType.scalarType]) !== null && _b !== void 0 ? _b : 'text';
81
+ sql = sql.replace(new RegExp(escapeRe(placeholder) + '\\b', 'g'), `ARRAY[]::${cast}[]`);
82
+ return;
83
+ }
84
+ const names = elements.map((el, k) => {
85
+ const pname = `p${idx + 1}_${k}`;
86
+ parameters.push(buildScalarParam(pname, el, { ...argType, arity: 'scalar' }));
87
+ return `:${pname}`;
88
+ });
89
+ sql = sql.replace(new RegExp(escapeRe(placeholder) + '\\b', 'g'), `ARRAY[${names.join(', ')}]`);
90
+ return;
91
+ }
92
+ const param = buildScalarParam(name, arg, argType);
93
+ if (engine === 'pg' && argType.scalarType === 'json') {
94
+ param.cast = 'jsonb';
95
+ }
96
+ parameters.push(param);
97
+ });
98
+ return { sql, parameters };
99
+ }
@@ -0,0 +1,34 @@
1
+ export declare const ColumnType: {
2
+ readonly Int32: 0;
3
+ readonly Int64: 1;
4
+ readonly Float: 2;
5
+ readonly Double: 3;
6
+ readonly Numeric: 4;
7
+ readonly Boolean: 5;
8
+ readonly Character: 6;
9
+ readonly Text: 7;
10
+ readonly Date: 8;
11
+ readonly Time: 9;
12
+ readonly DateTime: 10;
13
+ readonly Json: 11;
14
+ readonly Enum: 12;
15
+ readonly Bytes: 13;
16
+ readonly Uuid: 15;
17
+ readonly Int32Array: 64;
18
+ readonly Int64Array: 65;
19
+ readonly FloatArray: 66;
20
+ readonly DoubleArray: 67;
21
+ readonly NumericArray: 68;
22
+ readonly BooleanArray: 69;
23
+ readonly CharacterArray: 70;
24
+ readonly TextArray: 71;
25
+ readonly DateArray: 72;
26
+ readonly TimeArray: 73;
27
+ readonly DateTimeArray: 74;
28
+ readonly JsonArray: 75;
29
+ readonly BytesArray: 77;
30
+ readonly UuidArray: 78;
31
+ };
32
+ export type Engine = 'pg' | 'mysql';
33
+ export declare function mapColumnType(typeName: string, engine: Engine): number;
34
+ //# sourceMappingURL=prisma-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-types.d.ts","sourceRoot":"","sources":["../../src/compat/prisma-types.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Bb,CAAA;AAEV,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,OAAO,CAAA;AAkGnC,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE"}
@@ -0,0 +1,132 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColumnType = void 0;
4
+ exports.mapColumnType = mapColumnType;
5
+ exports.ColumnType = {
6
+ Int32: 0,
7
+ Int64: 1,
8
+ Float: 2,
9
+ Double: 3,
10
+ Numeric: 4,
11
+ Boolean: 5,
12
+ Character: 6,
13
+ Text: 7,
14
+ Date: 8,
15
+ Time: 9,
16
+ DateTime: 10,
17
+ Json: 11,
18
+ Enum: 12,
19
+ Bytes: 13,
20
+ Uuid: 15,
21
+ Int32Array: 64,
22
+ Int64Array: 65,
23
+ FloatArray: 66,
24
+ DoubleArray: 67,
25
+ NumericArray: 68,
26
+ BooleanArray: 69,
27
+ CharacterArray: 70,
28
+ TextArray: 71,
29
+ DateArray: 72,
30
+ TimeArray: 73,
31
+ DateTimeArray: 74,
32
+ JsonArray: 75,
33
+ BytesArray: 77,
34
+ UuidArray: 78
35
+ };
36
+ const PG_ARRAY = {
37
+ _int2: exports.ColumnType.Int32Array,
38
+ _int4: exports.ColumnType.Int32Array,
39
+ _int8: exports.ColumnType.Int64Array,
40
+ _float4: exports.ColumnType.FloatArray,
41
+ _float8: exports.ColumnType.DoubleArray,
42
+ _numeric: exports.ColumnType.NumericArray,
43
+ _bool: exports.ColumnType.BooleanArray,
44
+ _text: exports.ColumnType.TextArray,
45
+ _varchar: exports.ColumnType.TextArray,
46
+ _bpchar: exports.ColumnType.TextArray,
47
+ _uuid: exports.ColumnType.UuidArray,
48
+ _json: exports.ColumnType.JsonArray,
49
+ _jsonb: exports.ColumnType.JsonArray,
50
+ _timestamp: exports.ColumnType.DateTimeArray,
51
+ _timestamptz: exports.ColumnType.DateTimeArray,
52
+ _date: exports.ColumnType.DateArray,
53
+ _time: exports.ColumnType.TimeArray,
54
+ _bytea: exports.ColumnType.BytesArray
55
+ };
56
+ const PG_SCALAR = {
57
+ int2: exports.ColumnType.Int32,
58
+ int4: exports.ColumnType.Int32,
59
+ serial: exports.ColumnType.Int32,
60
+ int8: exports.ColumnType.Int64,
61
+ bigserial: exports.ColumnType.Int64,
62
+ float4: exports.ColumnType.Float,
63
+ float8: exports.ColumnType.Double,
64
+ numeric: exports.ColumnType.Numeric,
65
+ money: exports.ColumnType.Numeric,
66
+ bool: exports.ColumnType.Boolean,
67
+ text: exports.ColumnType.Text,
68
+ varchar: exports.ColumnType.Text,
69
+ bpchar: exports.ColumnType.Text,
70
+ name: exports.ColumnType.Text,
71
+ citext: exports.ColumnType.Text,
72
+ char: exports.ColumnType.Character,
73
+ date: exports.ColumnType.Date,
74
+ time: exports.ColumnType.Time,
75
+ timetz: exports.ColumnType.Time,
76
+ timestamp: exports.ColumnType.DateTime,
77
+ timestamptz: exports.ColumnType.DateTime,
78
+ json: exports.ColumnType.Json,
79
+ jsonb: exports.ColumnType.Json,
80
+ uuid: exports.ColumnType.Uuid,
81
+ bytea: exports.ColumnType.Bytes
82
+ };
83
+ function mapPg(typeName) {
84
+ const t = typeName.toLowerCase();
85
+ if (t in PG_ARRAY)
86
+ return PG_ARRAY[t];
87
+ if (t in PG_SCALAR)
88
+ return PG_SCALAR[t];
89
+ return exports.ColumnType.Text;
90
+ }
91
+ function mapMysql(typeName) {
92
+ const raw = typeName.toUpperCase();
93
+ if (raw.startsWith('TINYINT(1)'))
94
+ return exports.ColumnType.Boolean;
95
+ const t = raw.replace(/\(.*$/, '');
96
+ const map = {
97
+ TINYINT: exports.ColumnType.Int32,
98
+ SMALLINT: exports.ColumnType.Int32,
99
+ MEDIUMINT: exports.ColumnType.Int32,
100
+ INT: exports.ColumnType.Int32,
101
+ INTEGER: exports.ColumnType.Int32,
102
+ BIGINT: exports.ColumnType.Int64,
103
+ FLOAT: exports.ColumnType.Float,
104
+ DOUBLE: exports.ColumnType.Double,
105
+ DECIMAL: exports.ColumnType.Numeric,
106
+ NUMERIC: exports.ColumnType.Numeric,
107
+ BIT: exports.ColumnType.Bytes,
108
+ CHAR: exports.ColumnType.Text,
109
+ VARCHAR: exports.ColumnType.Text,
110
+ TINYTEXT: exports.ColumnType.Text,
111
+ TEXT: exports.ColumnType.Text,
112
+ MEDIUMTEXT: exports.ColumnType.Text,
113
+ LONGTEXT: exports.ColumnType.Text,
114
+ ENUM: exports.ColumnType.Enum,
115
+ DATE: exports.ColumnType.Date,
116
+ TIME: exports.ColumnType.Time,
117
+ YEAR: exports.ColumnType.Int32,
118
+ DATETIME: exports.ColumnType.DateTime,
119
+ TIMESTAMP: exports.ColumnType.DateTime,
120
+ JSON: exports.ColumnType.Json,
121
+ BINARY: exports.ColumnType.Bytes,
122
+ VARBINARY: exports.ColumnType.Bytes,
123
+ TINYBLOB: exports.ColumnType.Bytes,
124
+ BLOB: exports.ColumnType.Bytes,
125
+ MEDIUMBLOB: exports.ColumnType.Bytes,
126
+ LONGBLOB: exports.ColumnType.Bytes
127
+ };
128
+ return t in map ? map[t] : exports.ColumnType.Text;
129
+ }
130
+ function mapColumnType(typeName, engine) {
131
+ return engine === 'pg' ? mapPg(typeName) : mapMysql(typeName);
132
+ }
@@ -0,0 +1,53 @@
1
+ import type { DataAPIClient, DataAPIClientConfig } from '../types';
2
+ import { type Engine } from './prisma-types';
3
+ import { type PrismaSqlQuery } from './prisma-params';
4
+ interface SqlResultSet {
5
+ columnNames: string[];
6
+ columnTypes: number[];
7
+ rows: unknown[][];
8
+ lastInsertId?: string;
9
+ }
10
+ declare class Queryable {
11
+ protected core: DataAPIClient;
12
+ protected engine: Engine;
13
+ protected transactionId?: string | undefined;
14
+ readonly provider: 'postgres' | 'mysql';
15
+ readonly adapterName = "data-api-client";
16
+ constructor(core: DataAPIClient, engine: Engine, transactionId?: string | undefined);
17
+ protected run(query: PrismaSqlQuery): Promise<any>;
18
+ queryRaw(query: PrismaSqlQuery): Promise<SqlResultSet>;
19
+ executeRaw(query: PrismaSqlQuery): Promise<number>;
20
+ }
21
+ declare class DataApiTransaction extends Queryable {
22
+ readonly options: {
23
+ usePhantomQuery: boolean;
24
+ };
25
+ constructor(core: DataAPIClient, engine: Engine, transactionId: string);
26
+ commit(): Promise<void>;
27
+ rollback(): Promise<void>;
28
+ createSavepoint(): Promise<void>;
29
+ rollbackToSavepoint(): Promise<void>;
30
+ releaseSavepoint(): Promise<void>;
31
+ }
32
+ declare class DataApiAdapter extends Queryable {
33
+ executeScript(script: string): Promise<void>;
34
+ startTransaction(): Promise<DataApiTransaction>;
35
+ getConnectionInfo(): {
36
+ supportsRelationJoins: boolean;
37
+ maxBindValues: number;
38
+ };
39
+ dispose(): Promise<void>;
40
+ }
41
+ declare class PrismaDataApiAdapterFactory {
42
+ private config;
43
+ private engine;
44
+ readonly provider: 'postgres' | 'mysql';
45
+ readonly adapterName = "data-api-client";
46
+ constructor(config: DataAPIClientConfig, engine: Engine);
47
+ connect(): Promise<DataApiAdapter>;
48
+ }
49
+ export declare function createPrismaPgAdapter(config: DataAPIClientConfig): PrismaDataApiAdapterFactory;
50
+ export declare function createPrismaMySQLAdapter(config: DataAPIClientConfig): PrismaDataApiAdapterFactory;
51
+ export declare const __AdapterForTest: typeof DataApiAdapter;
52
+ export {};
53
+ //# sourceMappingURL=prisma.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/compat/prisma.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EA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AAM,cAAe,SAAQ,SAAS;IAC9B,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5C,gBAAgB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAIrD,iBAAiB;;;;IAIX,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B;AAED,cAAM,2BAA2B;IAI7B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IAJhB,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAA;IACvC,QAAQ,CAAC,WAAW,qBAAe;gBAEzB,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM;IAIlB,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC;CASzC;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,mBAAmB,GAAG,2BAA2B,CAE9F;AACD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,mBAAmB,GAAG,2BAA2B,CAEjG;AAGD,eAAO,MAAM,gBAAgB,uBAAiB,CAAA"}
@@ -0,0 +1,121 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.__AdapterForTest = void 0;
4
+ exports.createPrismaPgAdapter = createPrismaPgAdapter;
5
+ exports.createPrismaMySQLAdapter = createPrismaMySQLAdapter;
6
+ const client_1 = require("../client");
7
+ const prisma_types_1 = require("./prisma-types");
8
+ const prisma_params_1 = require("./prisma-params");
9
+ const errors_1 = require("./errors");
10
+ const PROVIDER = { pg: 'postgres', mysql: 'mysql' };
11
+ const ADAPTER_NAME = 'data-api-client';
12
+ const NESTED_TX_MESSAGE = 'Nested transactions (savepoints) are not supported over the RDS Data API.';
13
+ class Queryable {
14
+ constructor(core, engine, transactionId) {
15
+ this.core = core;
16
+ this.engine = engine;
17
+ this.transactionId = transactionId;
18
+ this.adapterName = ADAPTER_NAME;
19
+ this.provider = PROVIDER[engine];
20
+ }
21
+ async run(query) {
22
+ const { sql, parameters } = (0, prisma_params_1.buildQuery)(query, this.engine);
23
+ const opts = { sql, parameters, hydrateColumnNames: false, includeResultMetadata: true };
24
+ if (this.transactionId)
25
+ opts.transactionId = this.transactionId;
26
+ try {
27
+ return await this.core.query(opts);
28
+ }
29
+ catch (e) {
30
+ throw (0, errors_1.mapToPrismaError)(e, this.engine);
31
+ }
32
+ }
33
+ async queryRaw(query) {
34
+ var _a, _b;
35
+ const result = await this.run(query);
36
+ const meta = (_a = result.columnMetadata) !== null && _a !== void 0 ? _a : [];
37
+ const columnTypes = meta.map((m) => { var _a; return (0, prisma_types_1.mapColumnType)((_a = m.typeName) !== null && _a !== void 0 ? _a : '', this.engine); });
38
+ const rawRows = (_b = result.records) !== null && _b !== void 0 ? _b : [];
39
+ const rows = rawRows.map((row) => row.map((cell, i) => {
40
+ if (columnTypes[i] === prisma_types_1.ColumnType.Json && cell !== null && typeof cell !== 'string') {
41
+ return JSON.stringify(cell);
42
+ }
43
+ return cell;
44
+ }));
45
+ return {
46
+ columnNames: meta.map((m) => { var _a, _b; return (_b = (_a = m.label) !== null && _a !== void 0 ? _a : m.name) !== null && _b !== void 0 ? _b : ''; }),
47
+ columnTypes,
48
+ rows,
49
+ lastInsertId: result.insertId !== undefined ? String(result.insertId) : undefined
50
+ };
51
+ }
52
+ async executeRaw(query) {
53
+ var _a;
54
+ const result = await this.run(query);
55
+ return (_a = result.numberOfRecordsUpdated) !== null && _a !== void 0 ? _a : 0;
56
+ }
57
+ }
58
+ class DataApiTransaction extends Queryable {
59
+ constructor(core, engine, transactionId) {
60
+ super(core, engine, transactionId);
61
+ this.options = { usePhantomQuery: false };
62
+ }
63
+ async commit() {
64
+ await this.core.commitTransaction({ transactionId: this.transactionId });
65
+ }
66
+ async rollback() {
67
+ await this.core.rollbackTransaction({ transactionId: this.transactionId });
68
+ }
69
+ async createSavepoint() {
70
+ throw new Error(NESTED_TX_MESSAGE);
71
+ }
72
+ async rollbackToSavepoint() {
73
+ throw new Error(NESTED_TX_MESSAGE);
74
+ }
75
+ async releaseSavepoint() {
76
+ throw new Error(NESTED_TX_MESSAGE);
77
+ }
78
+ }
79
+ class DataApiAdapter extends Queryable {
80
+ async executeScript(script) {
81
+ const statements = script
82
+ .split(';')
83
+ .map((s) => s.trim())
84
+ .filter((s) => s.length > 0);
85
+ for (const stmt of statements) {
86
+ await this.run({ sql: stmt, args: [], argTypes: [] });
87
+ }
88
+ }
89
+ async startTransaction() {
90
+ const res = await this.core.beginTransaction();
91
+ return new DataApiTransaction(this.core, this.engine, res.transactionId);
92
+ }
93
+ getConnectionInfo() {
94
+ return { supportsRelationJoins: false, maxBindValues: 1000 };
95
+ }
96
+ async dispose() {
97
+ }
98
+ }
99
+ class PrismaDataApiAdapterFactory {
100
+ constructor(config, engine) {
101
+ this.config = config;
102
+ this.engine = engine;
103
+ this.adapterName = ADAPTER_NAME;
104
+ this.provider = PROVIDER[engine];
105
+ }
106
+ async connect() {
107
+ const core = (0, client_1.init)({
108
+ ...this.config,
109
+ engine: this.engine,
110
+ formatOptions: { ...(this.config.formatOptions || {}), deserializeDate: false }
111
+ });
112
+ return new DataApiAdapter(core, this.engine);
113
+ }
114
+ }
115
+ function createPrismaPgAdapter(config) {
116
+ return new PrismaDataApiAdapterFactory(config, 'pg');
117
+ }
118
+ function createPrismaMySQLAdapter(config) {
119
+ return new PrismaDataApiAdapterFactory(config, 'mysql');
120
+ }
121
+ exports.__AdapterForTest = DataApiAdapter;
package/dist/params.d.ts CHANGED
@@ -13,7 +13,7 @@ export declare const processParams: (engine: string, sql: string, sqlParams: Rec
13
13
  processedParams: (FormattedParameter | FormattedParameter[])[];
14
14
  escapedSql: string;
15
15
  };
16
- export declare const formatParam: (n: string, v: ParameterValue, formatOptions: Required<FormatOptions>) => FormattedParameter;
16
+ export declare const formatParam: (n: string, v: ParameterValue, formatOptions: Required<FormatOptions>, explicitTypeHint?: string) => FormattedParameter;
17
17
  export declare const splitParams: (p: Record<string, ParameterValue>) => NamedParameter[];
18
18
  export declare const formatType: (name: string, value: ParameterValue, type: SupportedType | null | undefined, typeHint: string | undefined, formatOptions: Required<FormatOptions>) => FormattedParameter;
19
19
  //# sourceMappingURL=params.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../src/params.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,aAAa,EACd,MAAM,SAAS,CAAA;AAahB,eAAO,MAAM,WAAW,GAAI,MAAM,GAAG,EAAE,KAAG,UAAU,EAa5C,CAAA;AAGR,eAAO,MAAM,aAAa,GAAI,QAAQ,cAAc,EAAE,MAAM,GAAG,EAAE,KAAG,MAAM,GAAG,SAS9D,CAAA;AAGf,eAAO,MAAM,YAAY,GAAI,QAAQ,cAAc,EAAE,MAAM,GAAG,EAAE,KAAG,OAKpC,CAAA;AAG/B,eAAO,MAAM,kBAAkB,GAAI,QAAQ,cAAc,EAAE,MAAM,GAAG,EAAE,KAAG,QAAQ,CAAC,aAAa,CAkBrE,CAAA;AAG1B,eAAO,MAAM,aAAa,GACxB,4BAA4B,cAAc,EAC1C,MAAM,GAAG,EAAE,KACV;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAK9D,CAAA;AAOD,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,EAAE,KAAG,CAAC,cAAc,GAAG,cAAc,EAAE,CAAC,EAavF,CAAA;AAGH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,EACd,KAAK,MAAM,EACX,WAAW,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EACvC,QAAQ,CAAC,cAAc,GAAG,cAAc,EAAE,CAAC,EAAE,EAC7C,eAAe,QAAQ,CAAC,aAAa,CAAC,EACtC,MAAK,MAAU,KACd;IAAE,eAAe,EAAE,C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MAAM,GAAG,GAAG,CAAA;CAK9D,CAAA;AAgBD,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,EAAE,KAAG,CAAC,cAAc,GAAG,cAAc,EAAE,CAAC,EASvF,CAAA;AAGH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,EACd,KAAK,MAAM,EACX,WAAW,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EACvC,QAAQ,CAAC,cAAc,GAAG,cAAc,EAAE,CAAC,EAAE,EAC7C,eAAe,QAAQ,CAAC,aAAa,CAAC,EACtC,MAAK,MAAU,KACd;IAAE,eAAe,EAAE,CAAC,kBAAkB,GAAG,kBAAkB,EAAE,CAAC,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAsCtF,CAAA;AAGD,eAAO,MAAM,WAAW,GACtB,GAAG,MAAM,EACT,GAAG,cAAc,EACjB,eAAe,QAAQ,CAAC,aAAa,CAAC,EACtC,mBAAmB,MAAM,KACxB,kBAAqG,CAAA;AAGxG,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,KAAG,cAAc,EACiB,CAAA;AAG/F,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,OAAO,cAAc,EACrB,MAAM,aAAa,GAAG,IAAI,GAAG,SAAS,EACtC,UAAU,MAAM,GAAG,SAAS,EAC5B,eAAe,QAAQ,CAAC,aAAa,CAAC,KACrC,kBAkBF,CAAA"}
package/dist/params.js CHANGED
@@ -98,13 +98,15 @@ const prepareParams = ({ secretArn, resourceArn }, args) => {
98
98
  };
99
99
  exports.prepareParams = prepareParams;
100
100
  const omit = (obj, values) => Object.keys(obj).reduce((acc, x) => (values.includes(x) ? acc : Object.assign(acc, { [x]: obj[x] })), {});
101
+ const NAMED_PARAM_OPTIONAL_KEYS = new Set(['cast', 'typeHint']);
102
+ const isNamedParam = (p) => {
103
+ if (!('name' in p) || typeof p.value === 'undefined')
104
+ return false;
105
+ return Object.keys(p).every((k) => k === 'name' || k === 'value' || NAMED_PARAM_OPTIONAL_KEYS.has(k));
106
+ };
101
107
  const normalizeParams = (params) => params.reduce((acc, p) => Array.isArray(p)
102
108
  ? acc.concat([(0, exports.normalizeParams)(p)])
103
- : (Object.keys(p).length === 2 && 'name' in p && typeof p.value !== 'undefined') ||
104
- (Object.keys(p).length === 3 &&
105
- 'name' in p &&
106
- typeof p.value !== 'undefined' &&
107
- 'cast' in p)
109
+ : isNamedParam(p)
108
110
  ? acc.concat(p)
109
111
  : acc.concat(...(0, exports.splitParams)(p)), []);
110
112
  exports.normalizeParams = normalizeParams;
@@ -129,7 +131,7 @@ const processParams = (engine, sql, sqlParams, params, formatOptions, row = 0) =
129
131
  const regex = new RegExp(':' + p.name + '\\b', 'g');
130
132
  sql = sql.replace(regex, `:${p.name}::jsonb`);
131
133
  }
132
- acc.push((0, exports.formatParam)(p.name, p.value, formatOptions));
134
+ acc.push((0, exports.formatParam)(p.name, p.value, formatOptions, p.typeHint));
133
135
  }
134
136
  else if (row === 0) {
135
137
  const regex = new RegExp('::' + p.name + '\\b', 'g');
@@ -148,7 +150,7 @@ const processParams = (engine, sql, sqlParams, params, formatOptions, row = 0) =
148
150
  };
149
151
  };
150
152
  exports.processParams = processParams;
151
- const formatParam = (n, v, formatOptions) => (0, exports.formatType)(n, v, (0, utils_1.getType)(v), (0, utils_1.getTypeHint)(v), formatOptions);
153
+ const formatParam = (n, v, formatOptions, explicitTypeHint) => (0, exports.formatType)(n, v, (0, utils_1.getType)(v), explicitTypeHint !== null && explicitTypeHint !== void 0 ? explicitTypeHint : (0, utils_1.getTypeHint)(v), formatOptions);
152
154
  exports.formatParam = formatParam;
153
155
  const splitParams = (p) => Object.keys(p).reduce((arr, x) => arr.concat({ name: x, value: p[x] }), []);
154
156
  exports.splitParams = splitParams;
package/dist/results.js CHANGED
@@ -23,13 +23,13 @@ const formatRecords = (recs, columns, hydrate, formatOptions) => {
23
23
  if (field.isNull === true) {
24
24
  return hydrate
25
25
  ? Object.assign(acc, { [fmap[i].label]: null })
26
- : acc.concat(null);
26
+ : [...acc, null];
27
27
  }
28
28
  else if (fmap[i] && fmap[i].field) {
29
29
  const value = (0, exports.formatRecordValue)(field[fmap[i].field], fmap[i].typeName, formatOptions);
30
30
  return hydrate
31
31
  ? Object.assign(acc, { [fmap[i].label]: value })
32
- : acc.concat(value);
32
+ : [...acc, value];
33
33
  }
34
34
  else {
35
35
  Object.keys(field).map((type) => {
@@ -40,7 +40,7 @@ const formatRecords = (recs, columns, hydrate, formatOptions) => {
40
40
  const value = (0, exports.formatRecordValue)(field[fmap[i].field], fmap[i].typeName, formatOptions);
41
41
  return hydrate
42
42
  ? Object.assign(acc, { [fmap[i].label]: value })
43
- : acc.concat(value);
43
+ : [...acc, value];
44
44
  }
45
45
  }, hydrate ? {} : []);
46
46
  })
package/dist/types.d.ts CHANGED
@@ -44,6 +44,7 @@ export interface NamedParameter {
44
44
  name: string;
45
45
  value: ParameterValue;
46
46
  cast?: string;
47
+ typeHint?: string;
47
48
  }
48
49
  export type Parameters = Record<string, ParameterValue> | NamedParameter[];
49
50
  export interface QueryOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,6BAA6B,EAC7B,kCAAkC,EAClC,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,EAChC,4BAA4B,EAC5B,iCAAiC,EACjC,cAAc,EACd,gBAAgB,EACjB,MAAM,0BAA0B,CAAA;AAGjC,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,WAAW,GACX,cAAc,GACd,aAAa,GACb,QAAQ,GACR,WAAW,GACX,aAAa,GACb,aAAa,CAAA;AAGjB,MAAM,WAAW,WAAW;IAE1B,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB,UAAU,CAAC,E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CAAA;IACrF,QAAQ,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,WAAW,CAAA;IAC9D,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;CACzB;AAGD,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;IACxF,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9D,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,WAAW,CAAA;IACzD,qBAAqB,CAAC,IAAI,EAAE,iCAAiC,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAA;IAC3G,gBAAgB,CAAC,IAAI,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAA;IAC7F,iBAAiB,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAA;IAC/F,gBAAgB,CAAC,IAAI,EAAE,4BAA4B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAA;IAC5F,mBAAmB,CAAC,IAAI,EAAE,+BAA+B,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAA;CACtG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-api-client",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "A lightweight wrapper that simplifies working with the Amazon Aurora Serverless Data API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,6 +25,11 @@
25
25
  "import": "./dist/compat/knex.js",
26
26
  "require": "./dist/compat/knex.js"
27
27
  },
28
+ "./compat/prisma": {
29
+ "types": "./dist/compat/prisma.d.ts",
30
+ "import": "./dist/compat/prisma.js",
31
+ "require": "./dist/compat/prisma.js"
32
+ },
28
33
  "./compat": {
29
34
  "types": "./dist/compat/index.d.ts",
30
35
  "import": "./dist/compat/index.js",
@@ -57,6 +62,12 @@
57
62
  "test:int:orm:knex": "npm run build && vitest run integration-tests/knex-mysql.int.test.ts integration-tests/knex-pg.int.test.ts integration-tests/knex-mysql-querybuilder.int.test.ts integration-tests/knex-pg-querybuilder.int.test.ts",
58
63
  "test:int:orm:knex:pg": "npm run build && vitest run integration-tests/knex-pg.int.test.ts integration-tests/knex-pg-querybuilder.int.test.ts",
59
64
  "test:int:orm:knex:mysql": "npm run build && vitest run integration-tests/knex-mysql.int.test.ts integration-tests/knex-mysql-querybuilder.int.test.ts",
65
+ "test:int:orm:prisma": "npm run build && vitest run integration-tests/prisma-pg.int.test.ts integration-tests/prisma-mysql.int.test.ts",
66
+ "test:int:orm:prisma:pg": "npm run build && vitest run integration-tests/prisma-pg.int.test.ts",
67
+ "test:int:orm:prisma:mysql": "npm run build && vitest run integration-tests/prisma-mysql.int.test.ts",
68
+ "test:int:orm:prisma:coverage": "npm run test:int:orm:prisma:coverage:pg && npm run test:int:orm:prisma:coverage:mysql",
69
+ "test:int:orm:prisma:coverage:pg": "npm run build && prisma generate --schema integration-tests/prisma/schema-pg-coverage.prisma && vitest run integration-tests/prisma-pg-coverage.int.test.ts",
70
+ "test:int:orm:prisma:coverage:mysql": "npm run build && prisma generate --schema integration-tests/prisma/schema-mysql-coverage.prisma && vitest run integration-tests/prisma-mysql-coverage.int.test.ts",
60
71
  "test-ci": "npm run build && eslint src && vitest run src/",
61
72
  "lint": "eslint src",
62
73
  "prepublishOnly": "npm run build"
@@ -82,6 +93,8 @@
82
93
  },
83
94
  "devDependencies": {
84
95
  "@aws-sdk/client-rds-data": "^3.1048.0",
96
+ "@prisma/client": "^7.8.0",
97
+ "@prisma/driver-adapter-utils": "^7.8.0",
85
98
  "@types/node": "^24.6.2",
86
99
  "@types/pg": "^8.15.5",
87
100
  "@types/sqlstring": "^2.3.2",
@@ -95,6 +108,7 @@
95
108
  "kysely": "^0.28.7",
96
109
  "pg": "^8.16.3",
97
110
  "prettier": "^2.6.2",
111
+ "prisma": "^7.8.0",
98
112
  "tsx": "^4.20.6",
99
113
  "typescript": "^5.9.3",
100
114
  "vitest": "^4.1.8"
@@ -104,6 +118,7 @@
104
118
  },
105
119
  "peerDependencies": {
106
120
  "@aws-sdk/client-rds-data": "^3.1048.0",
121
+ "@prisma/driver-adapter-utils": "^7.0.0",
107
122
  "knex": "^3.0.0"
108
123
  },
109
124
  "peerDependenciesMeta": {
@@ -112,6 +127,9 @@
112
127
  },
113
128
  "knex": {
114
129
  "optional": true
130
+ },
131
+ "@prisma/driver-adapter-utils": {
132
+ "optional": true
115
133
  }
116
134
  },
117
135
  "files": [