@prisma/adapter-pg
Advanced tools
Comparing version 5.6.0-dev.23 to 5.6.0-integration-chore-client-adapter-porting-nits.1
@@ -1,6 +0,76 @@ | ||
import { DriverAdapter, Result, Transaction, Queryable, Query, ResultSet } from '@prisma/driver-adapter-utils'; | ||
import pg from 'pg'; | ||
import type pg from 'pg'; | ||
type StdClient = pg.Pool; | ||
type TransactionClient = pg.PoolClient; | ||
declare type ColumnType = (typeof ColumnTypeEnum)[keyof typeof ColumnTypeEnum]; | ||
declare const ColumnTypeEnum: { | ||
readonly Int32: 0; | ||
readonly Int64: 1; | ||
readonly Float: 2; | ||
readonly Double: 3; | ||
readonly Numeric: 4; | ||
readonly Boolean: 5; | ||
readonly Char: 6; | ||
readonly Text: 7; | ||
readonly Date: 8; | ||
readonly Time: 9; | ||
readonly DateTime: 10; | ||
readonly Json: 11; | ||
readonly Enum: 12; | ||
readonly Bytes: 13; | ||
readonly Set: 14; | ||
readonly Uuid: 15; | ||
readonly Int32Array: 64; | ||
readonly Int64Array: 65; | ||
readonly FloatArray: 66; | ||
readonly DoubleArray: 67; | ||
readonly NumericArray: 68; | ||
readonly BooleanArray: 69; | ||
readonly CharArray: 70; | ||
readonly TextArray: 71; | ||
readonly DateArray: 72; | ||
readonly TimeArray: 73; | ||
readonly DateTimeArray: 74; | ||
readonly JsonArray: 75; | ||
readonly EnumArray: 76; | ||
readonly BytesArray: 77; | ||
readonly UuidArray: 78; | ||
readonly UnknownNumber: 128; | ||
}; | ||
declare interface DriverAdapter extends Queryable { | ||
/** | ||
* Starts new transation. | ||
*/ | ||
startTransaction(): Promise<Result<Transaction>>; | ||
/** | ||
* Closes the connection to the database, if any. | ||
*/ | ||
close: () => Promise<Result<void>>; | ||
} | ||
declare type Error_2 = { | ||
kind: 'GenericJs'; | ||
id: number; | ||
} | { | ||
kind: 'Postgres'; | ||
code: string; | ||
severity: string; | ||
message: string; | ||
detail: string | undefined; | ||
column: string | undefined; | ||
hint: string | undefined; | ||
} | { | ||
kind: 'Mysql'; | ||
code: number; | ||
message: string; | ||
state: string; | ||
} | { | ||
kind: 'Sqlite'; | ||
/** | ||
* Sqlite extended error code: https://www.sqlite.org/rescode.html | ||
*/ | ||
extendedCode: number; | ||
message: string; | ||
}; | ||
declare class PgQueryable<ClientT extends StdClient | TransactionClient> implements Queryable { | ||
@@ -27,3 +97,4 @@ protected readonly client: ClientT; | ||
} | ||
declare class PrismaPg extends PgQueryable<StdClient> implements DriverAdapter { | ||
export declare class PrismaPg extends PgQueryable<StdClient> implements DriverAdapter { | ||
constructor(client: pg.Pool); | ||
@@ -34,2 +105,89 @@ startTransaction(): Promise<Result<Transaction>>; | ||
export { PrismaPg }; | ||
declare type Query = { | ||
sql: string; | ||
args: Array<unknown>; | ||
}; | ||
declare interface Queryable { | ||
readonly flavour: 'mysql' | 'postgres' | 'sqlite'; | ||
/** | ||
* Execute a query given as SQL, interpolating the given parameters, | ||
* and returning the type-aware result set of the query. | ||
* | ||
* This is the preferred way of executing `SELECT` queries. | ||
*/ | ||
queryRaw(params: Query): Promise<Result<ResultSet>>; | ||
/** | ||
* Execute a query given as SQL, interpolating the given parameters, | ||
* and returning the number of affected rows. | ||
* | ||
* This is the preferred way of executing `INSERT`, `UPDATE`, `DELETE` queries, | ||
* as well as transactional queries. | ||
*/ | ||
executeRaw(params: Query): Promise<Result<number>>; | ||
} | ||
declare type Result<T> = { | ||
map<U>(fn: (value: T) => U): Result<U>; | ||
flatMap<U>(fn: (value: T) => Result<U>): Result<U>; | ||
} & ({ | ||
readonly ok: true; | ||
readonly value: T; | ||
} | { | ||
readonly ok: false; | ||
readonly error: Error_2; | ||
}); | ||
declare interface ResultSet { | ||
/** | ||
* List of column types appearing in a database query, in the same order as `columnNames`. | ||
* They are used within the Query Engine to convert values from JS to Quaint values. | ||
*/ | ||
columnTypes: Array<ColumnType>; | ||
/** | ||
* List of column names appearing in a database query, in the same order as `columnTypes`. | ||
*/ | ||
columnNames: Array<string>; | ||
/** | ||
* List of rows retrieved from a database query. | ||
* Each row is a list of values, whose length matches `columnNames` and `columnTypes`. | ||
*/ | ||
rows: Array<Array<unknown>>; | ||
/** | ||
* The last ID of an `INSERT` statement, if any. | ||
* This is required for `AUTO_INCREMENT` columns in MySQL and SQLite-flavoured databases. | ||
*/ | ||
lastInsertId?: string; | ||
} | ||
declare type StdClient = pg.Pool; | ||
declare interface Transaction extends Queryable { | ||
/** | ||
* Transaction options. | ||
*/ | ||
readonly options: TransactionOptions; | ||
/** | ||
* Commit the transaction. | ||
*/ | ||
commit(): Promise<Result<void>>; | ||
/** | ||
* Rolls back the transaction. | ||
*/ | ||
rollback(): Promise<Result<void>>; | ||
/** | ||
* Discards and closes the transaction which may or may not have been committed or rolled back. | ||
* This operation must be synchronous. If the implementation requires calling creating new | ||
* asynchronous tasks on the event loop, the driver is responsible for handling the errors | ||
* appropriately to ensure they don't crash the application. | ||
*/ | ||
dispose(): Result<void>; | ||
} | ||
declare type TransactionClient = pg.PoolClient; | ||
declare type TransactionOptions = { | ||
usePhantomQuery: boolean; | ||
}; | ||
export { } |
{ | ||
"name": "@prisma/adapter-pg", | ||
"version": "5.6.0-dev.23", | ||
"version": "5.6.0-integration-chore-client-adapter-porting-nits.1", | ||
"description": "Prisma's driver adapter for \"pg\"", | ||
@@ -16,9 +16,9 @@ "main": "dist/index.js", | ||
"sideEffects": false, | ||
"dependencies": { | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/pg": "8.10.2", | ||
"postgres-array": "3.0.2", | ||
"@prisma/driver-adapter-utils": "5.6.0-dev.23" | ||
}, | ||
"devDependencies": { | ||
"pg": "8.11.3", | ||
"@types/pg": "8.10.2" | ||
"@prisma/debug": "5.6.0-integration-chore-client-adapter-porting-nits.1", | ||
"@prisma/driver-adapter-utils": "5.6.0-integration-chore-client-adapter-porting-nits.1" | ||
}, | ||
@@ -29,5 +29,5 @@ "peerDependencies": { | ||
"scripts": { | ||
"build": "tsup ./src/index.ts --format cjs,esm --dts", | ||
"lint": "tsc -p ./tsconfig.build.json" | ||
"dev": "DEV=true node -r esbuild-register helpers/build.ts", | ||
"build": "node -r esbuild-register helpers/build.ts" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 9 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
413168
1
11987
5
6
38
6
- Removedpostgres-array@3.0.2
- Removed@prisma/driver-adapter-utils@5.6.0-dev.23(transitive)
- Removeddebug@4.3.4(transitive)
- Removedms@2.1.2(transitive)
- Removedpostgres-array@3.0.2(transitive)