@powerhousedao/analytics-engine-pg 0.3.0 → 0.5.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.
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { IAnalyticsProfiler } from "@powerhousedao/analytics-engine-core";
|
|
2
2
|
import { KnexAnalyticsStore, SqlQueryLogger, SqlResultsLogger } from "@powerhousedao/analytics-engine-knex";
|
|
3
|
+
import { Knex } from "knex";
|
|
4
|
+
export type PostgresAnalyticsStoreOptions = {
|
|
5
|
+
connectionString?: string;
|
|
6
|
+
knex?: Knex;
|
|
7
|
+
queryLogger?: SqlQueryLogger;
|
|
8
|
+
resultsLogger?: SqlResultsLogger;
|
|
9
|
+
profiler?: IAnalyticsProfiler;
|
|
10
|
+
};
|
|
3
11
|
export declare class PostgresAnalyticsStore extends KnexAnalyticsStore {
|
|
4
12
|
private readonly _postgres;
|
|
5
13
|
private readonly _profiler;
|
|
6
|
-
constructor(connectionString
|
|
14
|
+
constructor({ connectionString, knex, queryLogger, resultsLogger, profiler, }: PostgresAnalyticsStoreOptions);
|
|
7
15
|
raw(sql: string): Promise<any>;
|
|
8
16
|
}
|
|
@@ -11,16 +11,24 @@ types.setTypeParser(types.builtins.JSON, (value) => {
|
|
|
11
11
|
export class PostgresAnalyticsStore extends KnexAnalyticsStore {
|
|
12
12
|
_postgres;
|
|
13
13
|
_profiler;
|
|
14
|
-
constructor(connectionString, queryLogger, resultsLogger, profiler) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
constructor({ connectionString, knex, queryLogger, resultsLogger, profiler, }) {
|
|
15
|
+
if (!knex) {
|
|
16
|
+
if (!connectionString) {
|
|
17
|
+
throw new Error("Either knex or connectionString parameters are required");
|
|
18
|
+
}
|
|
19
|
+
knex = knexFactory({
|
|
20
|
+
client: "pg",
|
|
21
|
+
connection: connectionString,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
19
24
|
if (!profiler) {
|
|
20
25
|
profiler = new PassthroughAnalyticsProfiler();
|
|
21
26
|
}
|
|
22
27
|
profiler.push("Pg");
|
|
23
|
-
super(
|
|
28
|
+
super({
|
|
29
|
+
executor: new KnexQueryExecutor(queryLogger, resultsLogger, profiler),
|
|
30
|
+
knex,
|
|
31
|
+
});
|
|
24
32
|
this._postgres = knex;
|
|
25
33
|
this._profiler = profiler;
|
|
26
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresAnalyticsStore.js","sourceRoot":"","sources":["../src/PostgresAnalyticsStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,4BAA4B,GAC7B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAGlB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,WAAqB,MAAM,MAAM,CAAC;AACzC,OAAO,GAAG,MAAM,IAAI,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;AACtB,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AACnE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAa,EAAE,EAAE;IACzD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"PostgresAnalyticsStore.js","sourceRoot":"","sources":["../src/PostgresAnalyticsStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,4BAA4B,GAC7B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAGlB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,WAAqB,MAAM,MAA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,GAAG,CAAC,GAAW;QACnB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,IAAI,EAAE;gBACxD,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/analytics-engine-pg",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,8 +17,6 @@
|
|
|
17
17
|
"test": "PG_CONNECTION_STRING=postgresql://postgres:password@localhost:5555/analytics vitest"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@powerhousedao/analytics-engine-core": "0.3.0",
|
|
21
|
-
"@powerhousedao/analytics-engine-knex": "0.3.0",
|
|
22
20
|
"date-fns": "^3.6.0",
|
|
23
21
|
"knex": "^3.1.0",
|
|
24
22
|
"luxon": "^3.5.0",
|
|
@@ -31,5 +29,9 @@
|
|
|
31
29
|
"tsc-watch": "^6.2.0",
|
|
32
30
|
"typescript": "^5.6.3",
|
|
33
31
|
"vitest": "^2.0.5"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@powerhousedao/analytics-engine-core": "0.4.0",
|
|
35
|
+
"@powerhousedao/analytics-engine-knex": "0.5.0"
|
|
34
36
|
}
|
|
35
37
|
}
|