@relaybus/postgres 0.3.0 → 0.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 +29 -10
- package/dist/chunk-NNZJR5AB.js +12 -0
- package/dist/chunk-NNZJR5AB.js.map +1 -0
- package/dist/drizzle.cjs +13 -6
- package/dist/drizzle.cjs.map +1 -1
- package/dist/drizzle.d.cts +3 -2
- package/dist/drizzle.d.ts +3 -2
- package/dist/drizzle.js +6 -5
- package/dist/drizzle.js.map +1 -1
- package/dist/index.cjs +457 -404
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +458 -405
- package/dist/index.js.map +1 -1
- package/dist/knex.cjs +14 -5
- package/dist/knex.cjs.map +1 -1
- package/dist/knex.d.cts +3 -2
- package/dist/knex.d.ts +3 -2
- package/dist/knex.js +6 -5
- package/dist/knex.js.map +1 -1
- package/dist/kysely.cjs +13 -6
- package/dist/kysely.cjs.map +1 -1
- package/dist/kysely.d.cts +3 -2
- package/dist/kysely.d.ts +3 -2
- package/dist/kysely.js +6 -6
- package/dist/kysely.js.map +1 -1
- package/dist/prisma.cjs +14 -5
- package/dist/prisma.cjs.map +1 -1
- package/dist/prisma.d.cts +4 -4
- package/dist/prisma.d.ts +4 -4
- package/dist/prisma.js +7 -5
- package/dist/prisma.js.map +1 -1
- package/dist/typeorm.cjs +14 -5
- package/dist/typeorm.cjs.map +1 -1
- package/dist/typeorm.d.cts +3 -2
- package/dist/typeorm.d.ts +3 -2
- package/dist/typeorm.js +7 -5
- package/dist/typeorm.js.map +1 -1
- package/package.json +19 -12
package/dist/knex.cjs
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/adapter-executor.ts
|
|
4
|
+
function adapterExecutor(client) {
|
|
5
|
+
return {
|
|
6
|
+
transaction: client.transaction,
|
|
7
|
+
// eslint-disable-next-line relaybus/max-two-params -- PostgresExecutor port signature
|
|
8
|
+
query: (sql, parameters, transaction) => client.run(transaction ?? client.root, { sql, parameters })
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
// src/positional-sql.ts
|
|
4
13
|
function splitPositionalSql(sql) {
|
|
5
14
|
const parts = [];
|
|
@@ -14,19 +23,19 @@ function splitPositionalSql(sql) {
|
|
|
14
23
|
|
|
15
24
|
// src/knex/knex-executor.ts
|
|
16
25
|
function createKnexExecutor(knex) {
|
|
17
|
-
return {
|
|
26
|
+
return adapterExecutor({
|
|
27
|
+
root: knex,
|
|
18
28
|
transaction: (work) => knex.transaction(work),
|
|
19
|
-
|
|
20
|
-
async query(sql, parameters, transaction) {
|
|
29
|
+
async run(queryable, { sql, parameters }) {
|
|
21
30
|
const parts = splitPositionalSql(sql);
|
|
22
31
|
const knexSql = parts.map((part) => typeof part === "string" ? part : "?").join("");
|
|
23
32
|
const bindings = parts.flatMap(
|
|
24
33
|
(part) => typeof part === "string" ? [] : [parameters[part.parameterIndex]]
|
|
25
34
|
);
|
|
26
|
-
const result = await
|
|
35
|
+
const result = await queryable.raw(knexSql, bindings);
|
|
27
36
|
return result.rows;
|
|
28
37
|
}
|
|
29
|
-
};
|
|
38
|
+
});
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
exports.createKnexExecutor = createKnexExecutor;
|
package/dist/knex.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/positional-sql.ts","../src/knex/knex-executor.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/adapter-executor.ts","../src/positional-sql.ts","../src/knex/knex-executor.ts"],"names":[],"mappings":";;;AAqBO,SAAS,gBACd,MAAA,EAC8B;AAC9B,EAAA,OAAO;AAAA,IACL,aAAa,MAAA,CAAO,WAAA;AAAA;AAAA,IAEpB,KAAA,EAAO,CAAC,GAAA,EAAK,UAAA,EAAY,WAAA,KACvB,MAAA,CAAO,GAAA,CAAI,WAAA,IAAe,MAAA,CAAO,IAAA,EAAM,EAAE,GAAA,EAAK,YAAY;AAAA,GAC9D;AACF;;;ACrBO,SAAS,mBAAmB,GAAA,EAAkC;AACnE,EAAA,MAAM,QAA6B,EAAC;AACpC,EAAA,IAAI,SAAA,GAAY,CAAA;AAChB,EAAA,KAAA,MAAW,KAAA,IAAS,GAAA,CAAI,QAAA,CAAS,UAAU,CAAA,EAAG;AAC5C,IAAA,KAAA,CAAM,IAAA,CAAK,GAAA,CAAI,KAAA,CAAM,SAAA,EAAW,MAAM,KAAK,CAAA,EAAG,EAAE,cAAA,EAAgB,OAAO,KAAA,CAAM,CAAC,CAAC,CAAA,GAAI,GAAG,CAAA;AACtF,IAAA,SAAA,GAAY,KAAA,CAAM,KAAA,GAAQ,KAAA,CAAM,CAAC,CAAA,CAAE,MAAA;AAAA,EACrC;AACA,EAAA,KAAA,CAAM,IAAA,CAAK,GAAA,CAAI,KAAA,CAAM,SAAS,CAAC,CAAA;AAC/B,EAAA,OAAO,KAAA;AACT;;;ACAO,SAAS,mBAAmB,IAAA,EAAiD;AAClF,EAAA,OAAO,eAAA,CAA+B;AAAA,IACpC,IAAA,EAAM,IAAA;AAAA,IACN,WAAA,EAAa,CAAC,IAAA,KAAS,IAAA,CAAK,YAAY,IAAI,CAAA;AAAA,IAC5C,MAAM,GAAA,CAAI,SAAA,EAAW,EAAE,GAAA,EAAK,YAAW,EAAG;AACxC,MAAA,MAAM,KAAA,GAAQ,mBAAmB,GAAG,CAAA;AACpC,MAAA,MAAM,OAAA,GAAU,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,KAAU,OAAO,IAAA,KAAS,QAAA,GAAW,IAAA,GAAO,GAAI,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA;AACpF,MAAA,MAAM,WAAW,KAAA,CAAM,OAAA;AAAA,QAAQ,CAAC,IAAA,KAC9B,OAAO,IAAA,KAAS,QAAA,GAAW,EAAC,GAAI,CAAC,UAAA,CAAW,IAAA,CAAK,cAAc,CAAC;AAAA,OAClE;AACA,MAAA,MAAM,MAAA,GAAS,MAAM,SAAA,CAAU,GAAA,CAAI,SAAS,QAAQ,CAAA;AACpD,MAAA,OAAO,MAAA,CAAO,IAAA;AAAA,IAChB;AAAA,GACD,CAAA;AACH","file":"knex.cjs","sourcesContent":["import type { PostgresExecutor, PostgresParameter, PostgresRow } from './executor.js';\n\n/** One statement the store sends, with its positional parameters. */\nexport type AdapterStatement = {\n readonly sql: string;\n readonly parameters: readonly PostgresParameter[];\n};\n\n/** What an adapter supplies: where statements run outside a transaction, and how it runs one. */\nexport type AdapterClient<TQueryable> = {\n /** The instance itself: statements outside a transaction run on it. */\n readonly root: TQueryable;\n readonly transaction: PostgresExecutor<TQueryable>['transaction'];\n /** Runs one statement on the caller's transaction, else on the root. */\n readonly run: (queryable: TQueryable, statement: AdapterStatement) => Promise<PostgresRow[]>;\n};\n\n/**\n * The executor every library adapter shares: a statement runs on the transaction it is given,\n * else on the root instance. An adapter supplies only how its library runs one statement.\n */\nexport function adapterExecutor<TQueryable>(\n client: AdapterClient<TQueryable>,\n): PostgresExecutor<TQueryable> {\n return {\n transaction: client.transaction,\n // eslint-disable-next-line relaybus/max-two-params -- PostgresExecutor port signature\n query: (sql, parameters, transaction) =>\n client.run(transaction ?? client.root, { sql, parameters }),\n };\n}\n","/** A piece of SQL text, or a reference to the (zero-based) parameter that stands at this position. */\nexport type PositionalSqlPart = string | { readonly parameterIndex: number };\n\n/**\n * Splits SQL written with PostgreSQL `$1, $2, ...` placeholders into text and\n * parameter references, in order of appearance. A placeholder used twice\n * appears twice. Adapters for libraries with their own placeholder syntax\n * (Knex `?`, Drizzle parameter chunks) rebuild the statement from the parts.\n */\nexport function splitPositionalSql(sql: string): PositionalSqlPart[] {\n const parts: PositionalSqlPart[] = [];\n let textStart = 0;\n for (const match of sql.matchAll(/\\$(\\d+)/g)) {\n parts.push(sql.slice(textStart, match.index), { parameterIndex: Number(match[1]) - 1 });\n textStart = match.index + match[0].length;\n }\n parts.push(sql.slice(textStart));\n return parts;\n}\n","import { adapterExecutor } from '../adapter-executor.js';\nimport type { PostgresExecutor, PostgresRow } from '../executor.js';\nimport { splitPositionalSql } from '../positional-sql.js';\n\n/** What a Knex instance and a Knex transaction have in common. */\nexport interface KnexQueryable {\n raw(sql: string, bindings: readonly unknown[]): PromiseLike<{ readonly rows: PostgresRow[] }>;\n}\n\n/** The part of a `Knex` instance the executor uses. */\nexport interface KnexLike extends KnexQueryable {\n transaction<T>(work: (transaction: KnexQueryable) => Promise<T>): Promise<T>;\n}\n\n/**\n * Executor for Knex with the `pg` client. The transaction handle is a Knex\n * transaction: pass `trx` from `knex.transaction(async (trx) => ...)`.\n */\nexport function createKnexExecutor(knex: KnexLike): PostgresExecutor<KnexQueryable> {\n return adapterExecutor<KnexQueryable>({\n root: knex,\n transaction: (work) => knex.transaction(work),\n async run(queryable, { sql, parameters }) {\n const parts = splitPositionalSql(sql);\n const knexSql = parts.map((part) => (typeof part === 'string' ? part : '?')).join('');\n const bindings = parts.flatMap((part) =>\n typeof part === 'string' ? [] : [parameters[part.parameterIndex]],\n );\n const result = await queryable.raw(knexSql, bindings);\n return result.rows;\n },\n });\n}\n"]}
|
package/dist/knex.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostgresRow, PostgresExecutor } from './index.cjs';
|
|
2
2
|
|
|
3
3
|
/** What a Knex instance and a Knex transaction have in common. */
|
|
4
4
|
interface KnexQueryable {
|
|
@@ -16,4 +16,5 @@ interface KnexLike extends KnexQueryable {
|
|
|
16
16
|
*/
|
|
17
17
|
declare function createKnexExecutor(knex: KnexLike): PostgresExecutor<KnexQueryable>;
|
|
18
18
|
|
|
19
|
-
export {
|
|
19
|
+
export { createKnexExecutor };
|
|
20
|
+
export type { KnexLike, KnexQueryable };
|
package/dist/knex.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostgresRow, PostgresExecutor } from './index.js';
|
|
2
2
|
|
|
3
3
|
/** What a Knex instance and a Knex transaction have in common. */
|
|
4
4
|
interface KnexQueryable {
|
|
@@ -16,4 +16,5 @@ interface KnexLike extends KnexQueryable {
|
|
|
16
16
|
*/
|
|
17
17
|
declare function createKnexExecutor(knex: KnexLike): PostgresExecutor<KnexQueryable>;
|
|
18
18
|
|
|
19
|
-
export {
|
|
19
|
+
export { createKnexExecutor };
|
|
20
|
+
export type { KnexLike, KnexQueryable };
|
package/dist/knex.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { splitPositionalSql } from './chunk-UUFSUL2M.js';
|
|
2
|
+
import { adapterExecutor } from './chunk-NNZJR5AB.js';
|
|
2
3
|
|
|
3
4
|
// src/knex/knex-executor.ts
|
|
4
5
|
function createKnexExecutor(knex) {
|
|
5
|
-
return {
|
|
6
|
+
return adapterExecutor({
|
|
7
|
+
root: knex,
|
|
6
8
|
transaction: (work) => knex.transaction(work),
|
|
7
|
-
|
|
8
|
-
async query(sql, parameters, transaction) {
|
|
9
|
+
async run(queryable, { sql, parameters }) {
|
|
9
10
|
const parts = splitPositionalSql(sql);
|
|
10
11
|
const knexSql = parts.map((part) => typeof part === "string" ? part : "?").join("");
|
|
11
12
|
const bindings = parts.flatMap(
|
|
12
13
|
(part) => typeof part === "string" ? [] : [parameters[part.parameterIndex]]
|
|
13
14
|
);
|
|
14
|
-
const result = await
|
|
15
|
+
const result = await queryable.raw(knexSql, bindings);
|
|
15
16
|
return result.rows;
|
|
16
17
|
}
|
|
17
|
-
};
|
|
18
|
+
});
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export { createKnexExecutor };
|
package/dist/knex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/knex/knex-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/knex/knex-executor.ts"],"names":[],"mappings":";;;;AAkBO,SAAS,mBAAmB,IAAA,EAAiD;AAClF,EAAA,OAAO,eAAA,CAA+B;AAAA,IACpC,IAAA,EAAM,IAAA;AAAA,IACN,WAAA,EAAa,CAAC,IAAA,KAAS,IAAA,CAAK,YAAY,IAAI,CAAA;AAAA,IAC5C,MAAM,GAAA,CAAI,SAAA,EAAW,EAAE,GAAA,EAAK,YAAW,EAAG;AACxC,MAAA,MAAM,KAAA,GAAQ,mBAAmB,GAAG,CAAA;AACpC,MAAA,MAAM,OAAA,GAAU,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,KAAU,OAAO,IAAA,KAAS,QAAA,GAAW,IAAA,GAAO,GAAI,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA;AACpF,MAAA,MAAM,WAAW,KAAA,CAAM,OAAA;AAAA,QAAQ,CAAC,IAAA,KAC9B,OAAO,IAAA,KAAS,QAAA,GAAW,EAAC,GAAI,CAAC,UAAA,CAAW,IAAA,CAAK,cAAc,CAAC;AAAA,OAClE;AACA,MAAA,MAAM,MAAA,GAAS,MAAM,SAAA,CAAU,GAAA,CAAI,SAAS,QAAQ,CAAA;AACpD,MAAA,OAAO,MAAA,CAAO,IAAA;AAAA,IAChB;AAAA,GACD,CAAA;AACH","file":"knex.js","sourcesContent":["import { adapterExecutor } from '../adapter-executor.js';\nimport type { PostgresExecutor, PostgresRow } from '../executor.js';\nimport { splitPositionalSql } from '../positional-sql.js';\n\n/** What a Knex instance and a Knex transaction have in common. */\nexport interface KnexQueryable {\n raw(sql: string, bindings: readonly unknown[]): PromiseLike<{ readonly rows: PostgresRow[] }>;\n}\n\n/** The part of a `Knex` instance the executor uses. */\nexport interface KnexLike extends KnexQueryable {\n transaction<T>(work: (transaction: KnexQueryable) => Promise<T>): Promise<T>;\n}\n\n/**\n * Executor for Knex with the `pg` client. The transaction handle is a Knex\n * transaction: pass `trx` from `knex.transaction(async (trx) => ...)`.\n */\nexport function createKnexExecutor(knex: KnexLike): PostgresExecutor<KnexQueryable> {\n return adapterExecutor<KnexQueryable>({\n root: knex,\n transaction: (work) => knex.transaction(work),\n async run(queryable, { sql, parameters }) {\n const parts = splitPositionalSql(sql);\n const knexSql = parts.map((part) => (typeof part === 'string' ? part : '?')).join('');\n const bindings = parts.flatMap((part) =>\n typeof part === 'string' ? [] : [parameters[part.parameterIndex]],\n );\n const result = await queryable.raw(knexSql, bindings);\n return result.rows;\n },\n });\n}\n"]}
|
package/dist/kysely.cjs
CHANGED
|
@@ -2,18 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
var kysely = require('kysely');
|
|
4
4
|
|
|
5
|
-
// src/
|
|
6
|
-
function
|
|
5
|
+
// src/adapter-executor.ts
|
|
6
|
+
function adapterExecutor(client) {
|
|
7
7
|
return {
|
|
8
|
-
transaction:
|
|
8
|
+
transaction: client.transaction,
|
|
9
9
|
// eslint-disable-next-line relaybus/max-two-params -- PostgresExecutor port signature
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
query: (sql, parameters, transaction) => client.run(transaction ?? client.root, { sql, parameters })
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function createKyselyExecutor(database) {
|
|
14
|
+
return adapterExecutor({
|
|
15
|
+
root: database,
|
|
16
|
+
transaction: (work) => database.transaction().execute(work),
|
|
17
|
+
async run(queryable, { sql, parameters }) {
|
|
18
|
+
const result = await queryable.executeQuery(
|
|
12
19
|
kysely.CompiledQuery.raw(sql, [...parameters])
|
|
13
20
|
);
|
|
14
21
|
return result.rows;
|
|
15
22
|
}
|
|
16
|
-
};
|
|
23
|
+
});
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
exports.createKyselyExecutor = createKyselyExecutor;
|
package/dist/kysely.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/kysely/kysely-executor.ts"],"names":["CompiledQuery"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["../src/adapter-executor.ts","../src/kysely/kysely-executor.ts"],"names":["CompiledQuery"],"mappings":";;;;;AAqBO,SAAS,gBACd,MAAA,EAC8B;AAC9B,EAAA,OAAO;AAAA,IACL,aAAa,MAAA,CAAO,WAAA;AAAA;AAAA,IAEpB,KAAA,EAAO,CAAC,GAAA,EAAK,UAAA,EAAY,WAAA,KACvB,MAAA,CAAO,GAAA,CAAI,WAAA,IAAe,MAAA,CAAO,IAAA,EAAM,EAAE,GAAA,EAAK,YAAY;AAAA,GAC9D;AACF;ACTO,SAAS,qBAAqB,QAAA,EAAyD;AAC5F,EAAA,OAAO,eAAA,CAAiC;AAAA,IACtC,IAAA,EAAM,QAAA;AAAA,IACN,aAAa,CAAC,IAAA,KAAS,SAAS,WAAA,EAAY,CAAE,QAAQ,IAAI,CAAA;AAAA,IAC1D,MAAM,GAAA,CAAI,SAAA,EAAW,EAAE,GAAA,EAAK,YAAW,EAAG;AACxC,MAAA,MAAM,MAAA,GAAS,MAAM,SAAA,CAAU,YAAA;AAAA,QAC7BA,qBAAc,GAAA,CAAI,GAAA,EAAK,CAAC,GAAG,UAAU,CAAC;AAAA,OACxC;AACA,MAAA,OAAO,MAAA,CAAO,IAAA;AAAA,IAChB;AAAA,GACD,CAAA;AACH","file":"kysely.cjs","sourcesContent":["import type { PostgresExecutor, PostgresParameter, PostgresRow } from './executor.js';\n\n/** One statement the store sends, with its positional parameters. */\nexport type AdapterStatement = {\n readonly sql: string;\n readonly parameters: readonly PostgresParameter[];\n};\n\n/** What an adapter supplies: where statements run outside a transaction, and how it runs one. */\nexport type AdapterClient<TQueryable> = {\n /** The instance itself: statements outside a transaction run on it. */\n readonly root: TQueryable;\n readonly transaction: PostgresExecutor<TQueryable>['transaction'];\n /** Runs one statement on the caller's transaction, else on the root. */\n readonly run: (queryable: TQueryable, statement: AdapterStatement) => Promise<PostgresRow[]>;\n};\n\n/**\n * The executor every library adapter shares: a statement runs on the transaction it is given,\n * else on the root instance. An adapter supplies only how its library runs one statement.\n */\nexport function adapterExecutor<TQueryable>(\n client: AdapterClient<TQueryable>,\n): PostgresExecutor<TQueryable> {\n return {\n transaction: client.transaction,\n // eslint-disable-next-line relaybus/max-two-params -- PostgresExecutor port signature\n query: (sql, parameters, transaction) =>\n client.run(transaction ?? client.root, { sql, parameters }),\n };\n}\n","import { adapterExecutor } from '../adapter-executor.js';\nimport { CompiledQuery } from 'kysely';\nimport type { PostgresExecutor, PostgresRow } from '../executor.js';\n\n/** What a Kysely instance and a Kysely transaction have in common. */\nexport interface KyselyQueryable {\n executeQuery<R>(query: CompiledQuery<R>): Promise<{ readonly rows: R[] }>;\n}\n\n/** The part of a `Kysely` instance the executor uses. */\nexport interface KyselyLike extends KyselyQueryable {\n transaction(): {\n execute<T>(work: (transaction: KyselyQueryable) => Promise<T>): Promise<T>;\n };\n}\n\n/**\n * Executor for Kysely. The transaction handle is a Kysely `Transaction`: pass\n * `trx` from `db.transaction().execute(async (trx) => ...)` as the\n * `transaction` option of `publish`.\n */\nexport function createKyselyExecutor(database: KyselyLike): PostgresExecutor<KyselyQueryable> {\n return adapterExecutor<KyselyQueryable>({\n root: database,\n transaction: (work) => database.transaction().execute(work),\n async run(queryable, { sql, parameters }) {\n const result = await queryable.executeQuery<PostgresRow>(\n CompiledQuery.raw(sql, [...parameters]),\n );\n return result.rows;\n },\n });\n}\n"]}
|
package/dist/kysely.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CompiledQuery } from 'kysely';
|
|
2
|
-
import {
|
|
2
|
+
import { PostgresExecutor } from './index.cjs';
|
|
3
3
|
|
|
4
4
|
/** What a Kysely instance and a Kysely transaction have in common. */
|
|
5
5
|
interface KyselyQueryable {
|
|
@@ -20,4 +20,5 @@ interface KyselyLike extends KyselyQueryable {
|
|
|
20
20
|
*/
|
|
21
21
|
declare function createKyselyExecutor(database: KyselyLike): PostgresExecutor<KyselyQueryable>;
|
|
22
22
|
|
|
23
|
-
export {
|
|
23
|
+
export { createKyselyExecutor };
|
|
24
|
+
export type { KyselyLike, KyselyQueryable };
|
package/dist/kysely.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CompiledQuery } from 'kysely';
|
|
2
|
-
import {
|
|
2
|
+
import { PostgresExecutor } from './index.js';
|
|
3
3
|
|
|
4
4
|
/** What a Kysely instance and a Kysely transaction have in common. */
|
|
5
5
|
interface KyselyQueryable {
|
|
@@ -20,4 +20,5 @@ interface KyselyLike extends KyselyQueryable {
|
|
|
20
20
|
*/
|
|
21
21
|
declare function createKyselyExecutor(database: KyselyLike): PostgresExecutor<KyselyQueryable>;
|
|
22
22
|
|
|
23
|
-
export {
|
|
23
|
+
export { createKyselyExecutor };
|
|
24
|
+
export type { KyselyLike, KyselyQueryable };
|
package/dist/kysely.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { adapterExecutor } from './chunk-NNZJR5AB.js';
|
|
1
2
|
import { CompiledQuery } from 'kysely';
|
|
2
3
|
|
|
3
|
-
// src/kysely/kysely-executor.ts
|
|
4
4
|
function createKyselyExecutor(database) {
|
|
5
|
-
return {
|
|
5
|
+
return adapterExecutor({
|
|
6
|
+
root: database,
|
|
6
7
|
transaction: (work) => database.transaction().execute(work),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const result = await (transaction ?? database).executeQuery(
|
|
8
|
+
async run(queryable, { sql, parameters }) {
|
|
9
|
+
const result = await queryable.executeQuery(
|
|
10
10
|
CompiledQuery.raw(sql, [...parameters])
|
|
11
11
|
);
|
|
12
12
|
return result.rows;
|
|
13
13
|
}
|
|
14
|
-
};
|
|
14
|
+
});
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export { createKyselyExecutor };
|
package/dist/kysely.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/kysely/kysely-executor.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/kysely/kysely-executor.ts"],"names":[],"mappings":";;;AAqBO,SAAS,qBAAqB,QAAA,EAAyD;AAC5F,EAAA,OAAO,eAAA,CAAiC;AAAA,IACtC,IAAA,EAAM,QAAA;AAAA,IACN,aAAa,CAAC,IAAA,KAAS,SAAS,WAAA,EAAY,CAAE,QAAQ,IAAI,CAAA;AAAA,IAC1D,MAAM,GAAA,CAAI,SAAA,EAAW,EAAE,GAAA,EAAK,YAAW,EAAG;AACxC,MAAA,MAAM,MAAA,GAAS,MAAM,SAAA,CAAU,YAAA;AAAA,QAC7B,cAAc,GAAA,CAAI,GAAA,EAAK,CAAC,GAAG,UAAU,CAAC;AAAA,OACxC;AACA,MAAA,OAAO,MAAA,CAAO,IAAA;AAAA,IAChB;AAAA,GACD,CAAA;AACH","file":"kysely.js","sourcesContent":["import { adapterExecutor } from '../adapter-executor.js';\nimport { CompiledQuery } from 'kysely';\nimport type { PostgresExecutor, PostgresRow } from '../executor.js';\n\n/** What a Kysely instance and a Kysely transaction have in common. */\nexport interface KyselyQueryable {\n executeQuery<R>(query: CompiledQuery<R>): Promise<{ readonly rows: R[] }>;\n}\n\n/** The part of a `Kysely` instance the executor uses. */\nexport interface KyselyLike extends KyselyQueryable {\n transaction(): {\n execute<T>(work: (transaction: KyselyQueryable) => Promise<T>): Promise<T>;\n };\n}\n\n/**\n * Executor for Kysely. The transaction handle is a Kysely `Transaction`: pass\n * `trx` from `db.transaction().execute(async (trx) => ...)` as the\n * `transaction` option of `publish`.\n */\nexport function createKyselyExecutor(database: KyselyLike): PostgresExecutor<KyselyQueryable> {\n return adapterExecutor<KyselyQueryable>({\n root: database,\n transaction: (work) => database.transaction().execute(work),\n async run(queryable, { sql, parameters }) {\n const result = await queryable.executeQuery<PostgresRow>(\n CompiledQuery.raw(sql, [...parameters]),\n );\n return result.rows;\n },\n });\n}\n"]}
|
package/dist/prisma.cjs
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/adapter-executor.ts
|
|
4
|
+
function adapterExecutor(client) {
|
|
5
|
+
return {
|
|
6
|
+
transaction: client.transaction,
|
|
7
|
+
// eslint-disable-next-line relaybus/max-two-params -- PostgresExecutor port signature
|
|
8
|
+
query: (sql, parameters, transaction) => client.run(transaction ?? client.root, { sql, parameters })
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
// src/prisma/prisma-executor.ts
|
|
4
13
|
function createPrismaExecutor(client, transactionOptions = {}) {
|
|
5
|
-
return {
|
|
14
|
+
return adapterExecutor({
|
|
15
|
+
root: client,
|
|
6
16
|
transaction: (work) => client.$transaction(work, transactionOptions),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return await (transaction ?? client).$queryRawUnsafe(sql, ...parameters);
|
|
17
|
+
async run(queryable, { sql, parameters }) {
|
|
18
|
+
return await queryable.$queryRawUnsafe(sql, ...parameters);
|
|
10
19
|
}
|
|
11
|
-
};
|
|
20
|
+
});
|
|
12
21
|
}
|
|
13
22
|
|
|
14
23
|
exports.createPrismaExecutor = createPrismaExecutor;
|
package/dist/prisma.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/prisma/prisma-executor.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/adapter-executor.ts","../src/prisma/prisma-executor.ts"],"names":[],"mappings":";;;AAqBO,SAAS,gBACd,MAAA,EAC8B;AAC9B,EAAA,OAAO;AAAA,IACL,aAAa,MAAA,CAAO,WAAA;AAAA;AAAA,IAEpB,KAAA,EAAO,CAAC,GAAA,EAAK,UAAA,EAAY,WAAA,KACvB,MAAA,CAAO,GAAA,CAAI,WAAA,IAAe,MAAA,CAAO,IAAA,EAAM,EAAE,GAAA,EAAK,YAAY;AAAA,GAC9D;AACF;;;ACDO,SAAS,oBAAA,CACd,MAAA,EACA,kBAAA,GAA+C,EAAC,EACb;AACnC,EAAA,OAAO,eAAA,CAAiC;AAAA,IACtC,IAAA,EAAM,MAAA;AAAA,IACN,aAAa,CAAC,IAAA,KAAS,MAAA,CAAO,YAAA,CAAa,MAAM,kBAAkB,CAAA;AAAA,IACnE,MAAM,GAAA,CAAI,SAAA,EAAW,EAAE,GAAA,EAAK,YAAW,EAAG;AACxC,MAAA,OAAQ,MAAM,SAAA,CAAU,eAAA,CAAgB,GAAA,EAAK,GAAG,UAAU,CAAA;AAAA,IAC5D;AAAA,GACD,CAAA;AACH","file":"prisma.cjs","sourcesContent":["import type { PostgresExecutor, PostgresParameter, PostgresRow } from './executor.js';\n\n/** One statement the store sends, with its positional parameters. */\nexport type AdapterStatement = {\n readonly sql: string;\n readonly parameters: readonly PostgresParameter[];\n};\n\n/** What an adapter supplies: where statements run outside a transaction, and how it runs one. */\nexport type AdapterClient<TQueryable> = {\n /** The instance itself: statements outside a transaction run on it. */\n readonly root: TQueryable;\n readonly transaction: PostgresExecutor<TQueryable>['transaction'];\n /** Runs one statement on the caller's transaction, else on the root. */\n readonly run: (queryable: TQueryable, statement: AdapterStatement) => Promise<PostgresRow[]>;\n};\n\n/**\n * The executor every library adapter shares: a statement runs on the transaction it is given,\n * else on the root instance. An adapter supplies only how its library runs one statement.\n */\nexport function adapterExecutor<TQueryable>(\n client: AdapterClient<TQueryable>,\n): PostgresExecutor<TQueryable> {\n return {\n transaction: client.transaction,\n // eslint-disable-next-line relaybus/max-two-params -- PostgresExecutor port signature\n query: (sql, parameters, transaction) =>\n client.run(transaction ?? client.root, { sql, parameters }),\n };\n}\n","import { adapterExecutor } from '../adapter-executor.js';\nimport type { PostgresExecutor, PostgresRow } from '../executor.js';\n\n/** What a `PrismaClient` and an interactive-transaction client have in common. */\nexport interface PrismaQueryable {\n $queryRawUnsafe(query: string, ...values: unknown[]): PromiseLike<unknown>;\n}\n\n/** The part of a `PrismaClient` the executor uses. */\nexport interface PrismaClientLike extends PrismaQueryable {\n $transaction<T>(\n work: (transaction: PrismaQueryable) => Promise<T>,\n options?: PrismaTransactionOptions,\n ): Promise<T>;\n}\n\n/** Prisma interactive transaction limits. Prisma's defaults (2 s wait, 5 s run) are short for handlers. */\nexport interface PrismaTransactionOptions {\n readonly maxWait?: number;\n readonly timeout?: number;\n}\n\n/**\n * Executor for Prisma, typed structurally so the package has no Prisma\n * dependency. The transaction handle is the client of an interactive\n * transaction: pass `tx` from `prisma.$transaction(async (tx) => ...)`.\n *\n * Integration-tested with a generated Prisma Client 7 on the `@prisma/adapter-pg` driver adapter.\n */\nexport function createPrismaExecutor(\n client: PrismaClientLike,\n transactionOptions: PrismaTransactionOptions = {},\n): PostgresExecutor<PrismaQueryable> {\n return adapterExecutor<PrismaQueryable>({\n root: client,\n transaction: (work) => client.$transaction(work, transactionOptions),\n async run(queryable, { sql, parameters }) {\n return (await queryable.$queryRawUnsafe(sql, ...parameters)) as PostgresRow[];\n },\n });\n}\n"]}
|
package/dist/prisma.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostgresExecutor } from './index.cjs';
|
|
2
2
|
|
|
3
3
|
/** What a `PrismaClient` and an interactive-transaction client have in common. */
|
|
4
4
|
interface PrismaQueryable {
|
|
@@ -18,9 +18,9 @@ interface PrismaTransactionOptions {
|
|
|
18
18
|
* dependency. The transaction handle is the client of an interactive
|
|
19
19
|
* transaction: pass `tx` from `prisma.$transaction(async (tx) => ...)`.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
* unit tests with a structural fake only.
|
|
21
|
+
* Integration-tested with a generated Prisma Client 7 on the `@prisma/adapter-pg` driver adapter.
|
|
23
22
|
*/
|
|
24
23
|
declare function createPrismaExecutor(client: PrismaClientLike, transactionOptions?: PrismaTransactionOptions): PostgresExecutor<PrismaQueryable>;
|
|
25
24
|
|
|
26
|
-
export {
|
|
25
|
+
export { createPrismaExecutor };
|
|
26
|
+
export type { PrismaClientLike, PrismaQueryable, PrismaTransactionOptions };
|
package/dist/prisma.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostgresExecutor } from './index.js';
|
|
2
2
|
|
|
3
3
|
/** What a `PrismaClient` and an interactive-transaction client have in common. */
|
|
4
4
|
interface PrismaQueryable {
|
|
@@ -18,9 +18,9 @@ interface PrismaTransactionOptions {
|
|
|
18
18
|
* dependency. The transaction handle is the client of an interactive
|
|
19
19
|
* transaction: pass `tx` from `prisma.$transaction(async (tx) => ...)`.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
* unit tests with a structural fake only.
|
|
21
|
+
* Integration-tested with a generated Prisma Client 7 on the `@prisma/adapter-pg` driver adapter.
|
|
23
22
|
*/
|
|
24
23
|
declare function createPrismaExecutor(client: PrismaClientLike, transactionOptions?: PrismaTransactionOptions): PostgresExecutor<PrismaQueryable>;
|
|
25
24
|
|
|
26
|
-
export {
|
|
25
|
+
export { createPrismaExecutor };
|
|
26
|
+
export type { PrismaClientLike, PrismaQueryable, PrismaTransactionOptions };
|
package/dist/prisma.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { adapterExecutor } from './chunk-NNZJR5AB.js';
|
|
2
|
+
|
|
1
3
|
// src/prisma/prisma-executor.ts
|
|
2
4
|
function createPrismaExecutor(client, transactionOptions = {}) {
|
|
3
|
-
return {
|
|
5
|
+
return adapterExecutor({
|
|
6
|
+
root: client,
|
|
4
7
|
transaction: (work) => client.$transaction(work, transactionOptions),
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return await (transaction ?? client).$queryRawUnsafe(sql, ...parameters);
|
|
8
|
+
async run(queryable, { sql, parameters }) {
|
|
9
|
+
return await queryable.$queryRawUnsafe(sql, ...parameters);
|
|
8
10
|
}
|
|
9
|
-
};
|
|
11
|
+
});
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export { createPrismaExecutor };
|
package/dist/prisma.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/prisma/prisma-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/prisma/prisma-executor.ts"],"names":[],"mappings":";;;AA6BO,SAAS,oBAAA,CACd,MAAA,EACA,kBAAA,GAA+C,EAAC,EACb;AACnC,EAAA,OAAO,eAAA,CAAiC;AAAA,IACtC,IAAA,EAAM,MAAA;AAAA,IACN,aAAa,CAAC,IAAA,KAAS,MAAA,CAAO,YAAA,CAAa,MAAM,kBAAkB,CAAA;AAAA,IACnE,MAAM,GAAA,CAAI,SAAA,EAAW,EAAE,GAAA,EAAK,YAAW,EAAG;AACxC,MAAA,OAAQ,MAAM,SAAA,CAAU,eAAA,CAAgB,GAAA,EAAK,GAAG,UAAU,CAAA;AAAA,IAC5D;AAAA,GACD,CAAA;AACH","file":"prisma.js","sourcesContent":["import { adapterExecutor } from '../adapter-executor.js';\nimport type { PostgresExecutor, PostgresRow } from '../executor.js';\n\n/** What a `PrismaClient` and an interactive-transaction client have in common. */\nexport interface PrismaQueryable {\n $queryRawUnsafe(query: string, ...values: unknown[]): PromiseLike<unknown>;\n}\n\n/** The part of a `PrismaClient` the executor uses. */\nexport interface PrismaClientLike extends PrismaQueryable {\n $transaction<T>(\n work: (transaction: PrismaQueryable) => Promise<T>,\n options?: PrismaTransactionOptions,\n ): Promise<T>;\n}\n\n/** Prisma interactive transaction limits. Prisma's defaults (2 s wait, 5 s run) are short for handlers. */\nexport interface PrismaTransactionOptions {\n readonly maxWait?: number;\n readonly timeout?: number;\n}\n\n/**\n * Executor for Prisma, typed structurally so the package has no Prisma\n * dependency. The transaction handle is the client of an interactive\n * transaction: pass `tx` from `prisma.$transaction(async (tx) => ...)`.\n *\n * Integration-tested with a generated Prisma Client 7 on the `@prisma/adapter-pg` driver adapter.\n */\nexport function createPrismaExecutor(\n client: PrismaClientLike,\n transactionOptions: PrismaTransactionOptions = {},\n): PostgresExecutor<PrismaQueryable> {\n return adapterExecutor<PrismaQueryable>({\n root: client,\n transaction: (work) => client.$transaction(work, transactionOptions),\n async run(queryable, { sql, parameters }) {\n return (await queryable.$queryRawUnsafe(sql, ...parameters)) as PostgresRow[];\n },\n });\n}\n"]}
|
package/dist/typeorm.cjs
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/adapter-executor.ts
|
|
4
|
+
function adapterExecutor(client) {
|
|
5
|
+
return {
|
|
6
|
+
transaction: client.transaction,
|
|
7
|
+
// eslint-disable-next-line relaybus/max-two-params -- PostgresExecutor port signature
|
|
8
|
+
query: (sql, parameters, transaction) => client.run(transaction ?? client.root, { sql, parameters })
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
// src/typeorm/typeorm-executor.ts
|
|
4
13
|
function createTypeOrmExecutor(dataSource) {
|
|
5
|
-
return {
|
|
14
|
+
return adapterExecutor({
|
|
15
|
+
root: dataSource,
|
|
6
16
|
transaction: (work) => dataSource.transaction(work),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return await (transaction ?? dataSource).query(sql, [...parameters]);
|
|
17
|
+
async run(queryable, { sql, parameters }) {
|
|
18
|
+
return await queryable.query(sql, [...parameters]);
|
|
10
19
|
}
|
|
11
|
-
};
|
|
20
|
+
});
|
|
12
21
|
}
|
|
13
22
|
|
|
14
23
|
exports.createTypeOrmExecutor = createTypeOrmExecutor;
|
package/dist/typeorm.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/typeorm/typeorm-executor.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/adapter-executor.ts","../src/typeorm/typeorm-executor.ts"],"names":[],"mappings":";;;AAqBO,SAAS,gBACd,MAAA,EAC8B;AAC9B,EAAA,OAAO;AAAA,IACL,aAAa,MAAA,CAAO,WAAA;AAAA;AAAA,IAEpB,KAAA,EAAO,CAAC,GAAA,EAAK,UAAA,EAAY,WAAA,KACvB,MAAA,CAAO,GAAA,CAAI,WAAA,IAAe,MAAA,CAAO,IAAA,EAAM,EAAE,GAAA,EAAK,YAAY;AAAA,GAC9D;AACF;;;ACXO,SAAS,sBACd,UAAA,EACoC;AACpC,EAAA,OAAO,eAAA,CAAkC;AAAA,IACvC,IAAA,EAAM,UAAA;AAAA,IACN,WAAA,EAAa,CAAC,IAAA,KAAS,UAAA,CAAW,YAAY,IAAI,CAAA;AAAA,IAClD,MAAM,GAAA,CAAI,SAAA,EAAW,EAAE,GAAA,EAAK,YAAW,EAAG;AACxC,MAAA,OAAQ,MAAM,SAAA,CAAU,KAAA,CAAM,KAAK,CAAC,GAAG,UAAU,CAAC,CAAA;AAAA,IACpD;AAAA,GACD,CAAA;AACH","file":"typeorm.cjs","sourcesContent":["import type { PostgresExecutor, PostgresParameter, PostgresRow } from './executor.js';\n\n/** One statement the store sends, with its positional parameters. */\nexport type AdapterStatement = {\n readonly sql: string;\n readonly parameters: readonly PostgresParameter[];\n};\n\n/** What an adapter supplies: where statements run outside a transaction, and how it runs one. */\nexport type AdapterClient<TQueryable> = {\n /** The instance itself: statements outside a transaction run on it. */\n readonly root: TQueryable;\n readonly transaction: PostgresExecutor<TQueryable>['transaction'];\n /** Runs one statement on the caller's transaction, else on the root. */\n readonly run: (queryable: TQueryable, statement: AdapterStatement) => Promise<PostgresRow[]>;\n};\n\n/**\n * The executor every library adapter shares: a statement runs on the transaction it is given,\n * else on the root instance. An adapter supplies only how its library runs one statement.\n */\nexport function adapterExecutor<TQueryable>(\n client: AdapterClient<TQueryable>,\n): PostgresExecutor<TQueryable> {\n return {\n transaction: client.transaction,\n // eslint-disable-next-line relaybus/max-two-params -- PostgresExecutor port signature\n query: (sql, parameters, transaction) =>\n client.run(transaction ?? client.root, { sql, parameters }),\n };\n}\n","import { adapterExecutor } from '../adapter-executor.js';\nimport type { PostgresExecutor, PostgresRow } from '../executor.js';\n\n/** What a TypeORM `DataSource` and an `EntityManager` have in common. */\nexport interface TypeOrmQueryable {\n query(query: string, parameters?: unknown[]): Promise<unknown>;\n}\n\n/** The part of a `DataSource` the executor uses. */\nexport interface TypeOrmDataSourceLike extends TypeOrmQueryable {\n transaction<T>(work: (manager: TypeOrmQueryable) => Promise<T>): Promise<T>;\n}\n\n/**\n * Executor for TypeORM. The transaction handle is the `EntityManager` of a\n * transaction: pass `manager` from `dataSource.transaction(async (manager) => ...)`\n * (or the manager your transaction decorator provides). Every statement the\n * store sends is a plain SELECT or INSERT, for which `query` returns the rows.\n */\nexport function createTypeOrmExecutor(\n dataSource: TypeOrmDataSourceLike,\n): PostgresExecutor<TypeOrmQueryable> {\n return adapterExecutor<TypeOrmQueryable>({\n root: dataSource,\n transaction: (work) => dataSource.transaction(work),\n async run(queryable, { sql, parameters }) {\n return (await queryable.query(sql, [...parameters])) as PostgresRow[];\n },\n });\n}\n"]}
|
package/dist/typeorm.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostgresExecutor } from './index.cjs';
|
|
2
2
|
|
|
3
3
|
/** What a TypeORM `DataSource` and an `EntityManager` have in common. */
|
|
4
4
|
interface TypeOrmQueryable {
|
|
@@ -16,4 +16,5 @@ interface TypeOrmDataSourceLike extends TypeOrmQueryable {
|
|
|
16
16
|
*/
|
|
17
17
|
declare function createTypeOrmExecutor(dataSource: TypeOrmDataSourceLike): PostgresExecutor<TypeOrmQueryable>;
|
|
18
18
|
|
|
19
|
-
export {
|
|
19
|
+
export { createTypeOrmExecutor };
|
|
20
|
+
export type { TypeOrmDataSourceLike, TypeOrmQueryable };
|
package/dist/typeorm.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostgresExecutor } from './index.js';
|
|
2
2
|
|
|
3
3
|
/** What a TypeORM `DataSource` and an `EntityManager` have in common. */
|
|
4
4
|
interface TypeOrmQueryable {
|
|
@@ -16,4 +16,5 @@ interface TypeOrmDataSourceLike extends TypeOrmQueryable {
|
|
|
16
16
|
*/
|
|
17
17
|
declare function createTypeOrmExecutor(dataSource: TypeOrmDataSourceLike): PostgresExecutor<TypeOrmQueryable>;
|
|
18
18
|
|
|
19
|
-
export {
|
|
19
|
+
export { createTypeOrmExecutor };
|
|
20
|
+
export type { TypeOrmDataSourceLike, TypeOrmQueryable };
|
package/dist/typeorm.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { adapterExecutor } from './chunk-NNZJR5AB.js';
|
|
2
|
+
|
|
1
3
|
// src/typeorm/typeorm-executor.ts
|
|
2
4
|
function createTypeOrmExecutor(dataSource) {
|
|
3
|
-
return {
|
|
5
|
+
return adapterExecutor({
|
|
6
|
+
root: dataSource,
|
|
4
7
|
transaction: (work) => dataSource.transaction(work),
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return await (transaction ?? dataSource).query(sql, [...parameters]);
|
|
8
|
+
async run(queryable, { sql, parameters }) {
|
|
9
|
+
return await queryable.query(sql, [...parameters]);
|
|
8
10
|
}
|
|
9
|
-
};
|
|
11
|
+
});
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export { createTypeOrmExecutor };
|
package/dist/typeorm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/typeorm/typeorm-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/typeorm/typeorm-executor.ts"],"names":[],"mappings":";;;AAmBO,SAAS,sBACd,UAAA,EACoC;AACpC,EAAA,OAAO,eAAA,CAAkC;AAAA,IACvC,IAAA,EAAM,UAAA;AAAA,IACN,WAAA,EAAa,CAAC,IAAA,KAAS,UAAA,CAAW,YAAY,IAAI,CAAA;AAAA,IAClD,MAAM,GAAA,CAAI,SAAA,EAAW,EAAE,GAAA,EAAK,YAAW,EAAG;AACxC,MAAA,OAAQ,MAAM,SAAA,CAAU,KAAA,CAAM,KAAK,CAAC,GAAG,UAAU,CAAC,CAAA;AAAA,IACpD;AAAA,GACD,CAAA;AACH","file":"typeorm.js","sourcesContent":["import { adapterExecutor } from '../adapter-executor.js';\nimport type { PostgresExecutor, PostgresRow } from '../executor.js';\n\n/** What a TypeORM `DataSource` and an `EntityManager` have in common. */\nexport interface TypeOrmQueryable {\n query(query: string, parameters?: unknown[]): Promise<unknown>;\n}\n\n/** The part of a `DataSource` the executor uses. */\nexport interface TypeOrmDataSourceLike extends TypeOrmQueryable {\n transaction<T>(work: (manager: TypeOrmQueryable) => Promise<T>): Promise<T>;\n}\n\n/**\n * Executor for TypeORM. The transaction handle is the `EntityManager` of a\n * transaction: pass `manager` from `dataSource.transaction(async (manager) => ...)`\n * (or the manager your transaction decorator provides). Every statement the\n * store sends is a plain SELECT or INSERT, for which `query` returns the rows.\n */\nexport function createTypeOrmExecutor(\n dataSource: TypeOrmDataSourceLike,\n): PostgresExecutor<TypeOrmQueryable> {\n return adapterExecutor<TypeOrmQueryable>({\n root: dataSource,\n transaction: (work) => dataSource.transaction(work),\n async run(queryable, { sql, parameters }) {\n return (await queryable.query(sql, [...parameters])) as PostgresRow[];\n },\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relaybus/postgres",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "PostgreSQL event store for relaybus: a transactional outbox written in your own transaction (pg, Prisma, TypeORM, Drizzle, Knex, Kysely) with SKIP LOCKED leasing and per-key ordering.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Berkcan Şavur <berkcansavur@gmail.com>",
|
|
@@ -114,24 +114,28 @@
|
|
|
114
114
|
"provenance": true
|
|
115
115
|
},
|
|
116
116
|
"peerDependencies": {
|
|
117
|
-
"
|
|
118
|
-
"kysely": ">=0.27.0",
|
|
117
|
+
"drizzle-orm": ">=0.36.0",
|
|
119
118
|
"knex": ">=3.0.0",
|
|
119
|
+
"kysely": ">=0.27.0",
|
|
120
|
+
"pg": "^8.11.0",
|
|
120
121
|
"typeorm": ">=0.3.0",
|
|
121
|
-
"
|
|
122
|
-
"@relaybus/core": "^0.
|
|
122
|
+
"@prisma/client": "^6.0.0 || ^7.0.0",
|
|
123
|
+
"@relaybus/core": "^0.4.0"
|
|
123
124
|
},
|
|
124
125
|
"devDependencies": {
|
|
125
|
-
"pg": "
|
|
126
|
-
"@
|
|
126
|
+
"@prisma/adapter-pg": "7.10.1",
|
|
127
|
+
"@prisma/client": "7.10.1",
|
|
127
128
|
"@testcontainers/postgresql": "12.2.1",
|
|
128
|
-
"
|
|
129
|
-
"
|
|
129
|
+
"@types/pg": "8.23.1",
|
|
130
|
+
"drizzle-orm": "0.45.4",
|
|
130
131
|
"knex": "3.3.0",
|
|
132
|
+
"kysely": "0.29.7",
|
|
133
|
+
"pg": "8.23.1",
|
|
134
|
+
"prisma": "7.10.1",
|
|
135
|
+
"testcontainers": "12.2.1",
|
|
131
136
|
"typeorm": "1.1.2",
|
|
132
|
-
"
|
|
133
|
-
"@relaybus/testing": "0.
|
|
134
|
-
"@relaybus/core": "0.3.0"
|
|
137
|
+
"@relaybus/core": "0.4.0",
|
|
138
|
+
"@relaybus/testing": "0.4.0"
|
|
135
139
|
},
|
|
136
140
|
"typesVersions": {
|
|
137
141
|
"*": {
|
|
@@ -164,6 +168,9 @@
|
|
|
164
168
|
},
|
|
165
169
|
"drizzle-orm": {
|
|
166
170
|
"optional": true
|
|
171
|
+
},
|
|
172
|
+
"@prisma/client": {
|
|
173
|
+
"optional": true
|
|
167
174
|
}
|
|
168
175
|
},
|
|
169
176
|
"scripts": {
|