@venizia/ignis 0.1.0 → 0.1.1-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/dist/base/datasources/common/types.d.ts +9 -1
- package/dist/base/datasources/common/types.d.ts.map +1 -1
- package/dist/base/metadata/persistents.d.ts +1 -1
- package/dist/base/metadata/persistents.d.ts.map +1 -1
- package/dist/base/metadata/persistents.js.map +1 -1
- package/dist/connectors/postgres/datasources/abstract.d.ts +5 -14
- package/dist/connectors/postgres/datasources/abstract.d.ts.map +1 -1
- package/dist/connectors/postgres/datasources/abstract.js +28 -24
- package/dist/connectors/postgres/datasources/abstract.js.map +1 -1
- package/dist/connectors/postgres/datasources/base.js +1 -1
- package/dist/connectors/postgres/datasources/base.js.map +1 -1
- package/dist/connectors/postgres/drivers/index.d.ts +0 -1
- package/dist/connectors/postgres/drivers/index.d.ts.map +1 -1
- package/dist/connectors/postgres/drivers/index.js +0 -1
- package/dist/connectors/postgres/drivers/index.js.map +1 -1
- package/dist/connectors/postgres/drivers/node-postgres.d.ts +2 -7
- package/dist/connectors/postgres/drivers/node-postgres.d.ts.map +1 -1
- package/dist/connectors/postgres/drivers/node-postgres.js +17 -22
- package/dist/connectors/postgres/drivers/node-postgres.js.map +1 -1
- package/dist/connectors/postgres/drivers/postgres-js.d.ts +0 -6
- package/dist/connectors/postgres/drivers/postgres-js.d.ts.map +1 -1
- package/dist/connectors/postgres/drivers/postgres-js.js +10 -21
- package/dist/connectors/postgres/drivers/postgres-js.js.map +1 -1
- package/dist/connectors/postgres/repositories/core/base.js +2 -2
- package/dist/connectors/postgres/repositories/core/base.js.map +1 -1
- package/dist/helpers/inversion/common/types.d.ts +2 -2
- package/dist/helpers/inversion/common/types.d.ts.map +1 -1
- package/dist/helpers/inversion/mixins/datasource.mixin.d.ts +1 -1
- package/dist/helpers/inversion/mixins/datasource.mixin.d.ts.map +1 -1
- package/dist/helpers/inversion/registry.d.ts +1 -1
- package/package.json +1 -1
- package/dist/connectors/postgres/drivers/resolve.d.ts +0 -15
- package/dist/connectors/postgres/drivers/resolve.d.ts.map +0 -1
- package/dist/connectors/postgres/drivers/resolve.js +0 -44
- package/dist/connectors/postgres/drivers/resolve.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IConfigurable, TConstValue } from '@venizia/ignis-helpers';
|
|
1
|
+
import type { AnyType, IConfigurable, TClass, TConstValue } from '@venizia/ignis-helpers';
|
|
2
2
|
export declare class DataSourceDrivers {
|
|
3
3
|
static readonly NODE_POSTGRES = "node-postgres";
|
|
4
4
|
static readonly POSTGRES_JS = "postgres-js";
|
|
@@ -10,6 +10,14 @@ export declare class DataSourceDrivers {
|
|
|
10
10
|
static isValid(value: string): boolean;
|
|
11
11
|
}
|
|
12
12
|
export type TDataSourceDriver = TConstValue<typeof DataSourceDrivers> | (string & {});
|
|
13
|
+
/**
|
|
14
|
+
* A driver CLASS, named by `@datasource({ driver })`. A class reference is what carries `pg` or
|
|
15
|
+
* `postgres` into the application's bundle - a driver-name string carries nothing, and a bare
|
|
16
|
+
* side-effect import to compensate is one a bundler may delete.
|
|
17
|
+
*
|
|
18
|
+
* Untyped because `IRelationalDriver` lives under `connectors/`, which `base/` must not import.
|
|
19
|
+
*/
|
|
20
|
+
export type TDataSourceDriverClass = TClass<AnyType>;
|
|
13
21
|
export type TAnyDataSourceSchema = Record<string, any>;
|
|
14
22
|
/** Engine-neutral datasource contract - the root every connector family implements. */
|
|
15
23
|
export interface IDataSource<Settings extends object = {}, Schema extends TAnyDataSourceSchema = TAnyDataSourceSchema, ConfigurableOptions extends object = {}> extends IConfigurable<ConfigurableOptions> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/base/datasources/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"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ClC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,8FAA8F;AAC9F,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,iCAAkC,SAAQ,uBAAuB;IAChF,MAAM,CAAC,EAAE;QACP,0DAA0D;QAC1D,MAAM,CAAC,EAAE,OAAO,CAAC;QAEjB,qDAAqD;QACrD,KAAK,CAAC,EAAE,OAAO,CAAC;QAEhB,uDAAuD;QACvD,KAAK,CAAC,EAAE,OAAO,CAAC;QAEhB,0CAA0C;QAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH"}
|
|
@@ -4,7 +4,7 @@ import type { AbstractEntity } from '../models';
|
|
|
4
4
|
/** Registers a model class with its static schema and relations. */
|
|
5
5
|
export declare const model: (metadata: IModelMetadata) => ClassDecorator;
|
|
6
6
|
/** Registers a datasource with driver and auto-discovery settings. */
|
|
7
|
-
export declare const datasource: (metadata
|
|
7
|
+
export declare const datasource: (metadata?: IDataSourceMetadata) => ClassDecorator;
|
|
8
8
|
/** Binds a repository to a model and datasource for schema auto-discovery. */
|
|
9
9
|
export declare const repository: <Model extends AbstractEntity = AbstractEntity, DataSource extends IDataSource = IDataSource>(metadata: IRepositoryMetadata<Model, DataSource>) => ClassDecorator;
|
|
10
10
|
//# sourceMappingURL=persistents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistents.d.ts","sourceRoot":"","sources":["../../../src/base/metadata/persistents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EAEnB,cAAc,EACd,mBAAmB,EAEpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,oEAAoE;AACpE,eAAO,MAAM,KAAK,GAAI,UAAU,cAAc,KAAG,cAiBhD,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,UAAU,GAAI,
|
|
1
|
+
{"version":3,"file":"persistents.d.ts","sourceRoot":"","sources":["../../../src/base/metadata/persistents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EAEnB,cAAc,EACd,mBAAmB,EAEpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,oEAAoE;AACpE,eAAO,MAAM,KAAK,GAAI,UAAU,cAAc,KAAG,cAiBhD,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,UAAU,GAAI,WAAW,mBAAmB,KAAG,cAI3D,CAAC;AAwIF,8EAA8E;AAC9E,eAAO,MAAM,UAAU,GACrB,KAAK,SAAS,cAAc,GAAG,cAAc,EAC7C,UAAU,SAAS,WAAW,GAAG,WAAW,EAE5C,UAAU,mBAAmB,CAAC,KAAK,EAAE,UAAU,CAAC,KAC/C,cAcF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistents.js","sourceRoot":"","sources":["../../../src/base/metadata/persistents.ts"],"names":[],"mappings":";;;AAAA,gDAAsD;AAQtD,mDAAkF;AAClF,0DAA8E;AAE9E,gDAAoD;AAGpD,oEAAoE;AAC7D,MAAM,KAAK,GAAG,CAAC,QAAwB,EAAkB,EAAE;IAChE,OAAO,MAAM,CAAC,EAAE;QACd,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;QACrD,IAAI,YAAY,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAA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AK,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC5C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,aAAa,GAAG,IAAA,4BAAY,EAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,kBAAkB,GAAG,IAAA,4BAAY,EAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAE7D,QAAQ,CAAC,yBAAyB,CAAC;QACjC,UAAU,EAAE,MAAM;QAClB,KAAK,EAAE,aAAa;QACpB,UAAU,EAAE,kBAAkB;KAC/B,CAAC,CAAC;IAEH,2BAA2B,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAEtE,OAAO;QACL,KAAK,EAAE,aAAa;QACpB,UAAU,EAAE,kBAAkB;QAC9B,cAAc,EAAE,QAAQ,CAAC,cAAc;KACxC,CAAC;AACJ,CAAC,CAAC;AAEF,8EAA8E;AACvE,MAAM,UAAU,GAAG,CAIxB,QAAgD,EAChC,EAAE;IAClB,OAAO,MAAM,CAAC,EAAE;QACd,MAAM,QAAQ,GAAG,4BAAgB,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,QAAQ,GAAG,yBAAyB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QAE3E,6FAA6F;QAC7F,wFAAwF;QACxF,QAAQ,CAAC,qBAAqB,CAAC;YAC7B,MAAM;YACN,QAAQ,EAAE,EAAE,GAAG,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAE3C;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,UAAU,cAmBrB"}
|
|
@@ -8,25 +8,15 @@ import type { IDatabaseTransaction, IDatabaseTransactionOptions, IPostgresDataSo
|
|
|
8
8
|
/** SQL branch root: connector, pool, transactions. */
|
|
9
9
|
export declare abstract class AbstractRelationalDataSource<Settings extends object = {}, Schema extends TAnyDataSourceSchema = TAnyDataSourceSchema, ConfigurableOptions extends object = {}, Client = Pool> extends AbstractDataSource<Settings, Schema, ConfigurableOptions> implements IPostgresDataSource<Settings, Schema, ConfigurableOptions, Client> {
|
|
10
10
|
connector: TRelationalConnector<Schema>;
|
|
11
|
-
/**
|
|
12
|
-
* The raw driver client a pool-only datasource was configured with: a `pg.Pool`, a postgres-js
|
|
13
|
-
* `Sql`. Genuinely absent once `configure()` wires a driver instead - every reader guards.
|
|
14
|
-
*/
|
|
15
11
|
protected client?: Client;
|
|
16
|
-
/** Owns connection acquisition and the raw control statements. Assign in `configure()`. */
|
|
17
12
|
protected driver?: IRelationalDriver<Schema>;
|
|
18
13
|
private static queryDialect?;
|
|
19
|
-
private driverResolution?;
|
|
20
14
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* datasource would be noise, not information.
|
|
24
|
-
*
|
|
25
|
-
* Async because the concrete driver is imported on demand - see `resolveDatabaseDriver`. The
|
|
26
|
-
* in-flight promise is cached, not just its result, so concurrent `beginTransaction()` calls
|
|
27
|
-
* share one driver over one pool instead of each constructing their own.
|
|
15
|
+
* Builds the driver class named by `@datasource({ driver })` over the client `configure()`
|
|
16
|
+
* assigned, then wires the connector from it. Idempotent and lazy.
|
|
28
17
|
*/
|
|
29
|
-
protected
|
|
18
|
+
protected wireDriverFromMetadata(): void;
|
|
19
|
+
protected resolveDriver(): IRelationalDriver<Schema>;
|
|
30
20
|
/**
|
|
31
21
|
* Wires a driver in one step: assigns `this.driver` AND builds `this.connector` from it. The
|
|
32
22
|
* two-step form (driver set, connector forgotten) yields a datasource whose pooled queries
|
|
@@ -39,6 +29,7 @@ export declare abstract class AbstractRelationalDataSource<Settings extends obje
|
|
|
39
29
|
}): void;
|
|
40
30
|
abstract getConnectionString(): ValueOrPromise<string>;
|
|
41
31
|
abstract beginTransaction(opts?: IDatabaseTransactionOptions): Promise<IDatabaseTransaction<Schema>>;
|
|
32
|
+
/** Wires the driver on first use, so a `configure()` that only builds `this.client` is enough. */
|
|
42
33
|
getConnector(): TRelationalConnector<Schema>;
|
|
43
34
|
/**
|
|
44
35
|
* The raw driver client: `pg.Pool` for node-postgres, `Sql` for postgres-js. Stays synchronous by
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["../../../../src/connectors/postgres/datasources/abstract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["../../../../src/connectors/postgres/datasources/abstract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAGzF,OAAO,KAAK,EAAU,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EACV,oBAAoB,EACpB,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAElB,sDAAsD;AACtD,8BAAsB,4BAA4B,CAChD,QAAQ,SAAS,MAAM,GAAG,EAAE,EAC5B,MAAM,SAAS,oBAAoB,GAAG,oBAAoB,EAC1D,mBAAmB,SAAS,MAAM,GAAG,EAAE,EACvC,MAAM,GAAG,IAAI,CAEb,SAAQ,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,mBAAmB,CAChE,YAAW,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC;IAE7E,SAAS,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAExC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAE7C,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAA0B;IAEtD;;;OAGG;IACH,SAAS,CAAC,sBAAsB,IAAI,IAAI;IAkCxC,SAAS,CAAC,aAAa,IAAI,iBAAiB,CAAC,MAAM,CAAC;IAKpD;;;;;OAKG;IACH,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAKvF,QAAQ,CAAC,mBAAmB,IAAI,cAAc,CAAC,MAAM,CAAC;aACpC,gBAAgB,CAChC,IAAI,CAAC,EAAE,2BAA2B,GACjC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAExC,kGAAkG;IAClG,YAAY,IAAI,oBAAoB,CAAC,MAAM,CAAC;IAK5C;;;;OAIG;IACH,SAAS,IAAI,MAAM;IAcnB,eAAe,IAAI,uBAAuB;CAK3C"}
|
|
@@ -2,43 +2,45 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractRelationalDataSource = void 0;
|
|
4
4
|
const datasources_1 = require("../../../base/datasources");
|
|
5
|
-
const drivers_1 = require("../../../connectors/postgres/drivers");
|
|
6
5
|
const filter_1 = require("../../../connectors/postgres/repositories/dialect/filter");
|
|
6
|
+
const inversion_1 = require("../../../helpers/inversion");
|
|
7
7
|
const ignis_helpers_1 = require("@venizia/ignis-helpers");
|
|
8
8
|
/** SQL branch root: connector, pool, transactions. */
|
|
9
9
|
class AbstractRelationalDataSource extends datasources_1.AbstractDataSource {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* datasource would be noise, not information.
|
|
14
|
-
*
|
|
15
|
-
* Async because the concrete driver is imported on demand - see `resolveDatabaseDriver`. The
|
|
16
|
-
* in-flight promise is cached, not just its result, so concurrent `beginTransaction()` calls
|
|
17
|
-
* share one driver over one pool instead of each constructing their own.
|
|
11
|
+
* Builds the driver class named by `@datasource({ driver })` over the client `configure()`
|
|
12
|
+
* assigned, then wires the connector from it. Idempotent and lazy.
|
|
18
13
|
*/
|
|
19
|
-
|
|
14
|
+
wireDriverFromMetadata() {
|
|
15
|
+
if (this.connector) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
20
18
|
if (this.driver) {
|
|
21
|
-
|
|
19
|
+
this.connector = this.driver.createConnector({ schema: this.getSchema() });
|
|
20
|
+
return;
|
|
22
21
|
}
|
|
23
22
|
if (!this.client) {
|
|
24
23
|
throw (0, ignis_helpers_1.getError)({
|
|
25
|
-
message: `[${this.constructor.name}][
|
|
24
|
+
message: `[${this.constructor.name}][wireDriverFromMetadata] No driver and no client | Assign this.client in configure(), or wire a custom driver with useDriver()`,
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.error('Driver resolution failed - will retry on the next call | Error: %s', error);
|
|
40
|
-
throw error;
|
|
27
|
+
// Absent for an imperatively-registered datasource.
|
|
28
|
+
const metadata = inversion_1.MetadataRegistry.getInstance().getDataSourceMetadata({
|
|
29
|
+
target: this.constructor,
|
|
30
|
+
});
|
|
31
|
+
const driver = metadata?.driver;
|
|
32
|
+
// The type forbids a driver-name string, so this catches an untyped JavaScript caller - and a
|
|
33
|
+
// string is exactly the mistake to catch, because it carries no module into the bundle.
|
|
34
|
+
if (typeof driver !== 'function') {
|
|
35
|
+
throw (0, ignis_helpers_1.getError)({
|
|
36
|
+
message: `[${this.constructor.name}][wireDriverFromMetadata] @datasource({ driver }) must name a driver CLASS | Got: ${String(driver)} | Use \`@datasource({ driver: NodePostgresDriver })\` with \`import { NodePostgresDriver } from '@venizia/ignis/postgres/node-postgres'\`, or wire a custom driver with useDriver()`,
|
|
37
|
+
});
|
|
41
38
|
}
|
|
39
|
+
const DriverClass = driver;
|
|
40
|
+
this.useDriver({ driver: new DriverClass({ client: this.client }) });
|
|
41
|
+
}
|
|
42
|
+
resolveDriver() {
|
|
43
|
+
this.wireDriverFromMetadata();
|
|
42
44
|
return this.driver;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
@@ -51,7 +53,9 @@ class AbstractRelationalDataSource extends datasources_1.AbstractDataSource {
|
|
|
51
53
|
this.driver = opts.driver;
|
|
52
54
|
this.connector = opts.driver.createConnector({ schema: opts.schema ?? this.getSchema() });
|
|
53
55
|
}
|
|
56
|
+
/** Wires the driver on first use, so a `configure()` that only builds `this.client` is enough. */
|
|
54
57
|
getConnector() {
|
|
58
|
+
this.wireDriverFromMetadata();
|
|
55
59
|
return this.connector;
|
|
56
60
|
}
|
|
57
61
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../src/connectors/postgres/datasources/abstract.ts"],"names":[],"mappings":";;;AACA,oDAAwD;
|
|
1
|
+
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../src/connectors/postgres/datasources/abstract.ts"],"names":[],"mappings":";;;AACA,oDAAwD;AAGxD,8EAAkF;AAClF,mDAAuD;AAEvD,0DAAkD;AASlD,sDAAsD;AACtD,MAAsB,4BAMpB,SAAQ,gCAAyD;IAUjE;;;OAGG;IACO,sBAAsB;QAC9B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,SAA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,EAAE,CAAC,CAAC;IAC5F,CAAC;IAOD,kGAAkG;IAClG,YAAY;QACV,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,EAAY,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAA,wBAAQ,EAAC;gBACb,OAAO,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,0EAA0E;aAC7G,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,eAAe;QACb,4BAA4B,CAAC,YAAY,KAAK,IAAI,sBAAa,EAAE,CAAC;QAElE,OAAO,4BAA4B,CAAC,YAAY,CAAC;IACnD,CAAC;CACF;AAzGD,oEAyGC"}
|
|
@@ -48,7 +48,7 @@ class BaseRelationalDataSource extends abstract_1.AbstractRelationalDataSource {
|
|
|
48
48
|
return { transactions: true };
|
|
49
49
|
}
|
|
50
50
|
async beginTransaction(opts) {
|
|
51
|
-
const driver =
|
|
51
|
+
const driver = this.resolveDriver();
|
|
52
52
|
const connection = await driver.acquire({ schema: this.getSchema() });
|
|
53
53
|
const isolationLevel = opts?.isolationLevel ?? common_1.IsolationLevels.READ_COMMITTED;
|
|
54
54
|
// `isolationLevel` comes from the IsolationLevels const-class, never from user input. It must be
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/connectors/postgres/datasources/base.ts"],"names":[],"mappings":";;;AAAA,mDAAuD;AAEvD,0DAAkD;AAIlD,yCAA0D;AAE1D,qCAA2C;AAE3C,+EAA+E;AAC/E,MAAsB,wBAKpB,SAAQ,uCAA2E;IACnF,YAAY,IAAyD;QACnE,KAA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,GAAG,KAAK,CAAC;YAEjB,IAAI,CAAC;gBACH,MAAM,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;YAC1C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,sCAAsC,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;gBACtF,gBAAgB,GAAG,IAAI,CAAC;gBACxB,UAAU,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;gBACtC,MAAM,KAAK,CAAC;YACd,CAAC;YAED,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC,CAAC;QAEF,OAAO;YACL,cAAc;YACd,SAAS,EAAE,UAAU,CAAC,SAAS;YAE/B,IAAI,QAAQ;gBACV,OAAO,QAAQ,CAAC;YAClB,CAAC;YAED,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC7D,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;SACpE,CAAC;IACJ,CAAC;CACF;AA7ID,4DA6IC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./driver"), exports);
|
|
18
|
-
__exportStar(require("./resolve"), exports);
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|
|
@@ -2,19 +2,14 @@ import type { TAnyDataSourceSchema } from '../../../base/datasources';
|
|
|
2
2
|
import type { TRelationalConnector } from '../../../connectors/postgres/datasources/common';
|
|
3
3
|
import type { Pool } from 'pg';
|
|
4
4
|
import type { IRelationalConnection, IRelationalDriver } from './driver';
|
|
5
|
-
/**
|
|
6
|
-
* `pool` is supplied by the app's `configure()`, because Postgres connection config (credentials,
|
|
7
|
-
* SSL, secrets manager, env) varies per deployment.
|
|
8
|
-
*/
|
|
9
5
|
export declare class NodePostgresDriver<Schema extends TAnyDataSourceSchema = TAnyDataSourceSchema> implements IRelationalDriver<Schema, Pool> {
|
|
10
|
-
private readonly
|
|
6
|
+
private readonly client;
|
|
11
7
|
constructor(opts: {
|
|
12
|
-
|
|
8
|
+
client: Pool;
|
|
13
9
|
});
|
|
14
10
|
createConnector(opts: {
|
|
15
11
|
schema: Schema;
|
|
16
12
|
}): TRelationalConnector<Schema>;
|
|
17
|
-
/** A dedicated `PoolClient`, so BEGIN and COMMIT land on the same backend. */
|
|
18
13
|
acquire(opts: {
|
|
19
14
|
schema: Schema;
|
|
20
15
|
}): Promise<IRelationalConnection<Schema>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-postgres.d.ts","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/node-postgres.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"node-postgres.d.ts","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/node-postgres.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAIrF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEzE,qBAAa,kBAAkB,CAC7B,MAAM,SAAS,oBAAoB,GAAG,oBAAoB,CAC1D,YAAW,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAO;gBAElB,IAAI,EAAE;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE;IAkBlC,eAAe,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,oBAAoB,CAAC,MAAM,CAAC;IAIjE,OAAO,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IA8B/E,SAAS,IAAI,IAAI;IAIjB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrB"}
|
|
@@ -3,30 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NodePostgresDriver = void 0;
|
|
4
4
|
const ignis_helpers_1 = require("@venizia/ignis-helpers");
|
|
5
5
|
const node_postgres_1 = require("drizzle-orm/node-postgres");
|
|
6
|
-
/**
|
|
7
|
-
* `pool` is supplied by the app's `configure()`, because Postgres connection config (credentials,
|
|
8
|
-
* SSL, secrets manager, env) varies per deployment.
|
|
9
|
-
*/
|
|
10
6
|
class NodePostgresDriver {
|
|
11
7
|
constructor(opts) {
|
|
12
|
-
|
|
8
|
+
const { client } = opts;
|
|
9
|
+
// A bare `pg.Client` also exposes connect(), so only the pool accounting tells the two apart -
|
|
10
|
+
// and a Client cannot hand out a dedicated connection per transaction.
|
|
11
|
+
const isPool = typeof client?.connect === 'function' &&
|
|
12
|
+
typeof client?.totalCount === 'number';
|
|
13
|
+
if (!isPool) {
|
|
14
|
+
throw (0, ignis_helpers_1.getError)({
|
|
15
|
+
message: `[${NodePostgresDriver.name}] Expected a \`pg\` Pool | Got a client without pool accounting - a bare \`pg.Client\`? | Construct \`new Pool({ ... })\` instead`,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
this.client = client;
|
|
13
19
|
}
|
|
14
20
|
createConnector(opts) {
|
|
15
|
-
return (0, node_postgres_1.drizzle)({ client: this.
|
|
21
|
+
return (0, node_postgres_1.drizzle)({ client: this.client, schema: opts.schema });
|
|
16
22
|
}
|
|
17
|
-
/** A dedicated `PoolClient`, so BEGIN and COMMIT land on the same backend. */
|
|
18
23
|
async acquire(opts) {
|
|
19
|
-
const client = await this.
|
|
20
|
-
//
|
|
21
|
-
// not a pool. Named here, at the misconfiguration, instead of as a null-deref inside drizzle.
|
|
24
|
+
const client = await this.client.connect();
|
|
25
|
+
// Named here, at the checkout, instead of as a null-deref deep inside drizzle.
|
|
22
26
|
if (!client) {
|
|
23
27
|
throw (0, ignis_helpers_1.getError)({
|
|
24
|
-
message:
|
|
28
|
+
message: `[${NodePostgresDriver.name}][acquire] pool.connect() resolved to no client | The pool cannot hand out a connection`,
|
|
25
29
|
});
|
|
26
30
|
}
|
|
27
|
-
// The connection is already checked OUT of the pool. Anything that throws between here and the
|
|
28
|
-
// caller's `release()` - a malformed discovered schema, a drizzle mismatch - would strand it,
|
|
29
|
-
// and every later beginTransaction() would strand another until the pool is exhausted.
|
|
30
31
|
let connector;
|
|
31
32
|
try {
|
|
32
33
|
connector = (0, node_postgres_1.drizzle)({ client, schema: opts.schema });
|
|
@@ -37,26 +38,20 @@ class NodePostgresDriver {
|
|
|
37
38
|
}
|
|
38
39
|
return {
|
|
39
40
|
connector,
|
|
40
|
-
// pg's native shape is `{ rows, rowCount }`; `rowCount` is null for statements that affect no
|
|
41
|
-
// rows by definition (e.g. DDL). Mapped to the neutral result HERE, where the shape is known
|
|
42
|
-
// statically - callers never see a pg type.
|
|
43
41
|
execute: async (executeOpts) => {
|
|
44
42
|
const result = await client.query(executeOpts.statement);
|
|
45
43
|
return { count: result.rowCount ?? 0 };
|
|
46
44
|
},
|
|
47
|
-
// pg destroys the connection when `release()` receives a truthy argument, rather than handing
|
|
48
|
-
// it back to the pool. That is what a failed COMMIT or ROLLBACK needs: the session may still
|
|
49
|
-
// hold an open transaction, and the next borrower would inherit it.
|
|
50
45
|
release: (releaseOpts) => {
|
|
51
46
|
client.release(releaseOpts?.destroy === true);
|
|
52
47
|
},
|
|
53
48
|
};
|
|
54
49
|
}
|
|
55
50
|
getClient() {
|
|
56
|
-
return this.
|
|
51
|
+
return this.client;
|
|
57
52
|
}
|
|
58
53
|
end() {
|
|
59
|
-
return this.
|
|
54
|
+
return this.client.end();
|
|
60
55
|
}
|
|
61
56
|
}
|
|
62
57
|
exports.NodePostgresDriver = NodePostgresDriver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-postgres.js","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/node-postgres.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"node-postgres.js","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/node-postgres.ts"],"names":[],"mappings":";;;AAGA,0DAAkD;AAClD,6DAAoD;AAIpD,MAAa,kBAAkB;IAK7B,YAAY,IAAsB;QAChC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAExB,+FAA+F;QAC/F,uEAAuE;QACvE,MAAM,MAAM,GACV,OAAQ,MAAkB,EAAE,OAAO,KAAK,UAAU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AAE;gBAC/C,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,CAAC,CAAC;YAChD,CAAC;SACF,CAAC;IACJ,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,GAAG;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;IAC3B,CAAC;CACF;AAhED,gDAgEC"}
|
|
@@ -2,11 +2,6 @@ import type { TAnyDataSourceSchema } from '../../../base/datasources';
|
|
|
2
2
|
import type { TRelationalConnector } from '../../../connectors/postgres/datasources/common';
|
|
3
3
|
import type { Sql } from 'postgres';
|
|
4
4
|
import type { IRelationalConnection, IRelationalDriver } from './driver';
|
|
5
|
-
/**
|
|
6
|
-
* The postgres-js driver. `client` is supplied by the app's `configure()`, exactly as `pool` is for
|
|
7
|
-
* node-postgres. Requires `postgres >= 3.4.0`: that is the release that added `sql.reserve()`, and
|
|
8
|
-
* without a reserved connection a transaction's BEGIN and COMMIT could land on different backends.
|
|
9
|
-
*/
|
|
10
5
|
export declare class PostgresJsDriver<Schema extends TAnyDataSourceSchema = TAnyDataSourceSchema> implements IRelationalDriver<Schema, Sql> {
|
|
11
6
|
private readonly client;
|
|
12
7
|
constructor(opts: {
|
|
@@ -15,7 +10,6 @@ export declare class PostgresJsDriver<Schema extends TAnyDataSourceSchema = TAny
|
|
|
15
10
|
createConnector(opts: {
|
|
16
11
|
schema: Schema;
|
|
17
12
|
}): TRelationalConnector<Schema>;
|
|
18
|
-
/** A dedicated `ReservedSql`, so BEGIN and COMMIT land on the same backend. */
|
|
19
13
|
acquire(opts: {
|
|
20
14
|
schema: Schema;
|
|
21
15
|
}): Promise<IRelationalConnection<Schema>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-js.d.ts","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/postgres-js.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"postgres-js.d.ts","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/postgres-js.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAIrF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEzE,qBAAa,gBAAgB,CAC3B,MAAM,SAAS,oBAAoB,GAAG,oBAAoB,CAC1D,YAAW,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAM;gBAEjB,IAAI,EAAE;QAAE,MAAM,EAAE,GAAG,CAAA;KAAE;IAejC,eAAe,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,oBAAoB,CAAC,MAAM,CAAC;IAIjE,OAAO,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IA6B/E,SAAS,IAAI,GAAG;IAIhB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrB"}
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PostgresJsDriver = void 0;
|
|
4
|
+
const ignis_helpers_1 = require("@venizia/ignis-helpers");
|
|
4
5
|
const postgres_js_1 = require("drizzle-orm/postgres-js");
|
|
5
|
-
/**
|
|
6
|
-
* The postgres-js driver. `client` is supplied by the app's `configure()`, exactly as `pool` is for
|
|
7
|
-
* node-postgres. Requires `postgres >= 3.4.0`: that is the release that added `sql.reserve()`, and
|
|
8
|
-
* without a reserved connection a transaction's BEGIN and COMMIT could land on different backends.
|
|
9
|
-
*/
|
|
10
6
|
class PostgresJsDriver {
|
|
11
7
|
constructor(opts) {
|
|
12
|
-
|
|
8
|
+
const { client } = opts;
|
|
9
|
+
// A `pg.Pool` has neither verb, so naming the wrong driver class fails here rather than at the first transaction.
|
|
10
|
+
const isSql = typeof client?.reserve === 'function' && typeof client?.unsafe === 'function';
|
|
11
|
+
if (!isSql) {
|
|
12
|
+
throw (0, ignis_helpers_1.getError)({
|
|
13
|
+
message: `[${PostgresJsDriver.name}] Expected a \`postgres\` Sql | Got a client without reserve()/unsafe() - a \`pg.Pool\`? | Construct \`postgres({ ... })\`, or name NodePostgresDriver instead`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
this.client = client;
|
|
13
17
|
}
|
|
14
18
|
createConnector(opts) {
|
|
15
19
|
return (0, postgres_js_1.drizzle)({ client: this.client, schema: opts.schema });
|
|
16
20
|
}
|
|
17
|
-
/** A dedicated `ReservedSql`, so BEGIN and COMMIT land on the same backend. */
|
|
18
21
|
async acquire(opts) {
|
|
19
22
|
const reserved = await this.client.reserve();
|
|
20
|
-
// drizzle's constructor reads `client.options.parsers`/`.serializers`, which a real
|
|
21
|
-
// `ReservedSql` does not carry. Point it at the parent Sql's options - the very object drizzle
|
|
22
|
-
// mutates when bound to the pool, so the (idempotent) parser registration lands in the same
|
|
23
|
-
// place either way.
|
|
24
23
|
const reservedClient = reserved;
|
|
25
24
|
reservedClient.options ??= this.client.options;
|
|
26
|
-
// The connection is already RESERVED. Anything that throws between here and the caller's
|
|
27
|
-
// `release()` would strand it, and every later beginTransaction() would strand another.
|
|
28
25
|
let connector;
|
|
29
26
|
try {
|
|
30
27
|
connector = (0, postgres_js_1.drizzle)({
|
|
@@ -38,18 +35,10 @@ class PostgresJsDriver {
|
|
|
38
35
|
}
|
|
39
36
|
return {
|
|
40
37
|
connector,
|
|
41
|
-
// `unsafe()` is postgres-js's raw-string escape. The tagged-template form would bind
|
|
42
|
-
// `BEGIN TRANSACTION ISOLATION LEVEL ${level}` as a query parameter, which is not valid SQL.
|
|
43
|
-
// Its native shape is a RowList - an array carrying `count`. Mapped to the neutral result
|
|
44
|
-
// HERE, where the shape is known statically - callers never see a postgres-js type.
|
|
45
38
|
execute: async (executeOpts) => {
|
|
46
39
|
const result = await reserved.unsafe(executeOpts.statement);
|
|
47
40
|
return { count: result.count ?? 0 };
|
|
48
41
|
},
|
|
49
|
-
// ASYMMETRY, deliberate: `ReservedSql.release()` takes no argument, so postgres-js cannot
|
|
50
|
-
// discard a connection. After a failed COMMIT this returns a possibly-poisoned connection to
|
|
51
|
-
// the pool, where node-postgres would destroy it. The option is accepted and ignored rather
|
|
52
|
-
// than rejected, so `IRelationalConnection` stays substitutable.
|
|
53
42
|
release: () => {
|
|
54
43
|
reserved.release();
|
|
55
44
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-js.js","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/postgres-js.ts"],"names":[],"mappings":";;;AAGA,yDAAkD;AAIlD
|
|
1
|
+
{"version":3,"file":"postgres-js.js","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/postgres-js.ts"],"names":[],"mappings":";;;AAGA,0DAAkD;AAClD,yDAAkD;AAIlD,MAAa,gBAAgB;IAK3B,YAAY,IAAqB;QAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAExB,kHAAkH;QAClH,MAAM,KAAK,GAAG,OAAO,MAAM,EAAE,OAAO,KAAK,UAAU,IAAI,OAAO,MAAM,EAAE,MAAM,KAAK,UAAU,CAAC;QAE5F,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAA,wBAAQ,EAAC;gBACb,OAAO,EAAE,IAAI,gBAAgB,CAAC,IAAI,gKAAgK;aACnM,CAAC,CAAC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,7 +31,7 @@ class RelationalBaseRepository extends core_1.AbstractRepository {
|
|
|
31
31
|
return this.dataSource.getQueryDialect();
|
|
32
32
|
}
|
|
33
33
|
get connector() {
|
|
34
|
-
return this.dataSource.
|
|
34
|
+
return this.dataSource.getConnector();
|
|
35
35
|
}
|
|
36
36
|
setDataSource(opts) {
|
|
37
37
|
super.setDataSource(opts);
|
|
@@ -127,7 +127,7 @@ class RelationalBaseRepository extends core_1.AbstractRepository {
|
|
|
127
127
|
resolveConnector(opts) {
|
|
128
128
|
const { transaction } = opts ?? {};
|
|
129
129
|
if (!transaction) {
|
|
130
|
-
return this.dataSource.
|
|
130
|
+
return this.dataSource.getConnector();
|
|
131
131
|
}
|
|
132
132
|
if (!transaction.isActive) {
|
|
133
133
|
throw (0, ignis_helpers_1.getError)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/connectors/postgres/repositories/core/base.ts"],"names":[],"mappings":";;;AAaA,mDAA8D;AAO9D,mEAA0E;AAQ1E,0DAAkD;AAClD,6CAA8C;AAG9C;8GAC8G;AAC9G,MAAsB,wBAMpB,SAAQ,yBAA2D;IAQnE,YACE,UAAgC,EAChC,IAIC;QAED,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAb1B,yFAAyF;QACjF,uBAAkB,GAAuB,IAAI,CAAC;QACtD,6IAA6I;QACrI,oBAAe,GAA+C,IAAI,CAAC;IAW3E,CAAC;IAED,IAAa,UAAU;QACrB,OAAO,KAAK,CAAC,UAAiC,CAAC;IACjD,CAAC;IAED,IAAa,UAAU,CAAC,KAA0B;QAChD,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,IAAa,MAAM;QACjB,OAAO,KAAK,CAAC,MAA4C,CAAC;IAC5D,CAAC;IAED,IAAa,MAAM,CAAC,KAAyC;QAC3D,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;IAC3C,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/connectors/postgres/repositories/core/base.ts"],"names":[],"mappings":";;;AAaA,mDAA8D;AAO9D,mEAA0E;AAQ1E,0DAAkD;AAClD,6CAA8C;AAG9C;8GAC8G;AAC9G,MAAsB,wBAMpB,SAAQ,yBAA2D;IAQnE,YACE,UAAgC,EAChC,IAIC;QAED,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAb1B,yFAAyF;QACjF,uBAAkB,GAAuB,IAAI,CAAC;QACtD,6IAA6I;QACrI,oBAAe,GAA+C,IAAI,CAAC;IAW3E,CAAC;IAED,IAAa,UAAU;QACrB,OAAO,KAAK,CAAC,UAAiC,CAAC;IACjD,CAAC;IAED,IAAa,UAAU,CAAC,KAA0B;QAChD,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,IAAa,MAAM;QACjB,OAAO,KAAK,CAAC,MAA4C,CAAC;IAC5D,CAAC;IAED,IAAa,MAAM,CAAC,KAAyC;QAC3D,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;IAC3C,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;IACxC,CAAC;IAEQ,aAAa,CAAC,IAAyC;QAC9D,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,iGAAiG;IACjG,mBAAmB;QACjB,IAAI,CAAC,kBAAkB,KAAK,IAAI,GAAG,CAAC,IAAI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,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACvF,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IA+BQ,QAAQ,CAAiB,IAGjC;QACC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEhC,IAAI,OAAO,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF;AAvXD,4DAuXC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ControllerTransports } from '../../../base/controllers/common/constants';
|
|
2
|
-
import type { IDataSource,
|
|
2
|
+
import type { IDataSource, TDataSourceDriverClass } from '../../../base/datasources';
|
|
3
3
|
import type { AbstractEntity } from '../../../base/models';
|
|
4
4
|
import type { IRepository, TFilter, TRepositoryOperationScope } from '../../../base/repositories';
|
|
5
5
|
import type { TAuthMode, TAuthStrategy } from '../../../components/auth/authenticate/common';
|
|
@@ -72,7 +72,7 @@ export type TModelClass<Model extends AbstractEntity = AbstractEntity> = TClass<
|
|
|
72
72
|
/** Decorator target for model classes (supports both strongly typed and ClassDecorator patterns). */
|
|
73
73
|
export type TDecoratorModelTarget<Model extends AbstractEntity = AbstractEntity> = TModelClass<Model> | (Function & IEntityStatics);
|
|
74
74
|
export interface IDataSourceMetadata {
|
|
75
|
-
driver
|
|
75
|
+
driver?: TDataSourceDriverClass;
|
|
76
76
|
autoDiscovery?: boolean;
|
|
77
77
|
}
|
|
78
78
|
export interface IRepositoryMetadata<Model extends AbstractEntity = AbstractEntity, DataSource extends IDataSource = IDataSource> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/helpers/inversion/common/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/helpers/inversion/common/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EACL,KAAK,eAAe,IAAI,gBAAgB,EACxC,KAAK,iBAAiB,IAAI,kBAAkB,EAC5C,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAElC,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACtE,SAAS,CAAC,EAAE,OAAO,oBAAoB,CAAC,IAAI,CAAC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ACtB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IACzC,cAAc,CAAC,EAAE,yBAAyB,CAAC;CAC5C;AAED,MAAM,WAAW,mBAAmB,CAAC,KAAK,SAAS,cAAc,GAAG,cAAc;IAChF,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAEhB,oFAAoF;IACpF,iBAAiB,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAErD,mDAAmD;IACnD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB,CACjC,KAAK,SAAS,cAAc,GAAG,cAAc,EAC7C,UAAU,SAAS,WAAW,GAAG,WAAW;IAE5C,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,UAAU,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5D,UAAU,EAAE,gBAAgB,CAAC,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC;CACrE"}
|
|
@@ -5,7 +5,7 @@ export declare const DatasourceMetadataMixin: <BaseClass extends TMixinTarget<_M
|
|
|
5
5
|
new (...args: any[]): {
|
|
6
6
|
setDataSourceMetadata<Target extends object = object>(opts: {
|
|
7
7
|
target: Target;
|
|
8
|
-
metadata
|
|
8
|
+
metadata?: IDataSourceMetadata;
|
|
9
9
|
}): void;
|
|
10
10
|
getDataSourceMetadata<Target extends object = object>(opts: {
|
|
11
11
|
target: Target;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasource.mixin.d.ts","sourceRoot":"","sources":["../../../../src/helpers/inversion/mixins/datasource.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAEtF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,eAAO,MAAM,uBAAuB,GAAI,SAAS,SAAS,YAAY,CAAC,iBAAiB,CAAC,EACvF,WAAW,SAAS;;8BAGI,MAAM,SAAS,MAAM,iBAAiB;YAC1D,MAAM,EAAE,MAAM,CAAC;YACf,QAAQ,EAAE,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"datasource.mixin.d.ts","sourceRoot":"","sources":["../../../../src/helpers/inversion/mixins/datasource.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAEtF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,eAAO,MAAM,uBAAuB,GAAI,SAAS,SAAS,YAAY,CAAC,iBAAiB,CAAC,EACvF,WAAW,SAAS;;8BAGI,MAAM,SAAS,MAAM,iBAAiB;YAC1D,MAAM,EAAE,MAAM,CAAC;YACf,QAAQ,CAAC,EAAE,mBAAmB,CAAC;SAChC,GAAG,IAAI;8BAUc,MAAM,SAAS,MAAM,iBAAiB;YAC1D,MAAM,EAAE,MAAM,CAAC;SAChB,GAAG,mBAAmB,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAKtC,CAAC"}
|
|
@@ -418,7 +418,7 @@ declare const BaseRegistry: {
|
|
|
418
418
|
new (...args: any[]): {
|
|
419
419
|
setDataSourceMetadata<Target extends object = object>(opts: {
|
|
420
420
|
target: Target;
|
|
421
|
-
metadata
|
|
421
|
+
metadata?: import("./common/types").IDataSourceMetadata;
|
|
422
422
|
}): void;
|
|
423
423
|
getDataSourceMetadata<Target extends object = object>(opts: {
|
|
424
424
|
target: Target;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ignis",
|
|
3
|
-
"version": "0.1.0",
|
|
3
|
+
"version": "0.1.1-0",
|
|
4
4
|
"description": "High-performance TypeScript server infrastructure combining LoopBack 4 enterprise architecture (decorator-based DI, repository pattern, component system) with Hono speed (~140k req/s). Features auto-generated OpenAPI docs, Drizzle ORM type-safe SQL, JWT/Basic authentication, Casbin authorization, convention-based bootstrapping, and pluggable components for health checks, Swagger UI, mail, Socket.IO, and static assets. Built for Bun and Node.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"access-control",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { TAnyDataSourceSchema } from '../../../base/datasources';
|
|
2
|
-
import type { IRelationalDriver } from './driver';
|
|
3
|
-
/**
|
|
4
|
-
* Picks the driver that matches the client the application built, and imports it dynamically so the
|
|
5
|
-
* losing driver's package is never loaded. This is the only reason `pg` and `postgres` can both be
|
|
6
|
-
* optional peers: a static `import` of either driver module would pull its package into every entry
|
|
7
|
-
* point that transitively reaches `connectors/postgres`, which is every entry point.
|
|
8
|
-
*
|
|
9
|
-
* Detection is structural rather than `instanceof`, because naming a constructor here would defeat
|
|
10
|
-
* the dynamic import it exists to enable.
|
|
11
|
-
*/
|
|
12
|
-
export declare const resolveDatabaseDriver: <Schema extends TAnyDataSourceSchema = TAnyDataSourceSchema>(opts: {
|
|
13
|
-
client: unknown;
|
|
14
|
-
}) => Promise<IRelationalDriver<Schema>>;
|
|
15
|
-
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAmBlD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAChC,MAAM,SAAS,oBAAoB,GAAG,oBAAoB,EAC1D,MAAM;IACN,MAAM,EAAE,OAAO,CAAC;CACjB,KAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAiBpC,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveDatabaseDriver = void 0;
|
|
4
|
-
const ignis_helpers_1 = require("@venizia/ignis-helpers");
|
|
5
|
-
/** postgres-js `Sql` - a tagged-template function carrying `reserve()` and `unsafe()`. */
|
|
6
|
-
const isPostgresJsClient = (opts) => {
|
|
7
|
-
const { client } = opts;
|
|
8
|
-
return typeof client?.reserve === 'function' && typeof client?.unsafe === 'function';
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* node-postgres `Pool` - keyed on `connect()`, the one verb `NodePostgresDriver` actually calls to
|
|
12
|
-
* check out a `PoolClient`. A postgres-js `Sql` has no `connect`, so the two never collide. A bare
|
|
13
|
-
* `pg.Client` also exposes `connect()` but is out of contract: the driver needs a pool to check
|
|
14
|
-
* connections out of.
|
|
15
|
-
*/
|
|
16
|
-
const isNodePostgresPool = (opts) => {
|
|
17
|
-
const { client } = opts;
|
|
18
|
-
return typeof client?.connect === 'function';
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Picks the driver that matches the client the application built, and imports it dynamically so the
|
|
22
|
-
* losing driver's package is never loaded. This is the only reason `pg` and `postgres` can both be
|
|
23
|
-
* optional peers: a static `import` of either driver module would pull its package into every entry
|
|
24
|
-
* point that transitively reaches `connectors/postgres`, which is every entry point.
|
|
25
|
-
*
|
|
26
|
-
* Detection is structural rather than `instanceof`, because naming a constructor here would defeat
|
|
27
|
-
* the dynamic import it exists to enable.
|
|
28
|
-
*/
|
|
29
|
-
const resolveDatabaseDriver = async (opts) => {
|
|
30
|
-
const client = opts.client;
|
|
31
|
-
if (isPostgresJsClient({ client })) {
|
|
32
|
-
const { PostgresJsDriver } = await import('./postgres-js.js');
|
|
33
|
-
return new PostgresJsDriver({ client });
|
|
34
|
-
}
|
|
35
|
-
if (isNodePostgresPool({ client })) {
|
|
36
|
-
const { NodePostgresDriver } = await import('./node-postgres.js');
|
|
37
|
-
return new NodePostgresDriver({ pool: client });
|
|
38
|
-
}
|
|
39
|
-
throw (0, ignis_helpers_1.getError)({
|
|
40
|
-
message: '[resolveDatabaseDriver] Unrecognized database client | Expected a `pg` Pool or a `postgres` Sql | Install one (`bun add pg` or `bun add postgres`), or assign `this.driver` explicitly in configure()',
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
exports.resolveDatabaseDriver = resolveDatabaseDriver;
|
|
44
|
-
//# sourceMappingURL=resolve.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../../src/connectors/postgres/drivers/resolve.ts"],"names":[],"mappings":";;;AAEA,0DAAkD;AAGlD,0FAA0F;AAC1F,MAAM,kBAAkB,GAAG,CAAC,IAAyB,EAAW,EAAE;IAChE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,OAAO,OAAO,MAAM,EAAE,OAAO,KAAK,UAAU,IAAI,OAAO,MAAM,EAAE,MAAM,KAAK,UAAU,CAAC;AACvF,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,CAAC,IAAyB,EAAW,EAAE;IAChE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,OAAO,OAAO,MAAM,EAAE,OAAO,KAAK,UAAU,CAAC;AAC/C,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACI,MAAM,qBAAqB,GAAG,KAAK,EAExC,IAED,EAAsC,EAAE;IACvC,MAAM,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