@powerhousedao/analytics-engine-knex 0.6.2 → 0.6.4

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.
@@ -0,0 +1,52 @@
1
+ import type { Knex } from "knex";
2
+ import { AnalyticsPath, type AnalyticsSeries, type AnalyticsSeriesInput, type AnalyticsSeriesQuery, type IAnalyticsStore, type AnalyticsUpdateCallback } from "@powerhousedao/analytics-engine-core";
3
+ export type AnalyticsSeriesRecord = {
4
+ id: number;
5
+ source: string;
6
+ start: Date;
7
+ end: Date | null;
8
+ metric: string;
9
+ value: number;
10
+ unit: string | null;
11
+ fn: string;
12
+ params: Record<string, any> | null;
13
+ [dimension: `dim_${string}`]: string;
14
+ dimensionMetadata?: Record<string, string>;
15
+ };
16
+ /**
17
+ * Using an interface here, so that a null implementation can be used in production,
18
+ * without the added overhead of calling toString().
19
+ */
20
+ export interface IQuery {
21
+ toString(): string;
22
+ }
23
+ export interface IKnexQueryExecutor {
24
+ execute<T extends {}, U>(query: Knex.QueryBuilder<T, U>): Promise<any>;
25
+ }
26
+ export type KnexAnalyticsStoreOptions = {
27
+ executor: IKnexQueryExecutor;
28
+ knex: Knex;
29
+ };
30
+ export declare class KnexAnalyticsStore implements IAnalyticsStore {
31
+ protected readonly _executor: IKnexQueryExecutor;
32
+ protected readonly _knex: Knex;
33
+ private readonly _subscriptionManager;
34
+ constructor({ executor, knex }: KnexAnalyticsStoreOptions);
35
+ destroy(): void;
36
+ clearSeriesBySource(source: AnalyticsPath, cleanUpDimensions?: boolean): Promise<number>;
37
+ clearEmptyAnalyticsDimensions(): Promise<any>;
38
+ getMatchingSeries(query: AnalyticsSeriesQuery): Promise<AnalyticsSeries[]>;
39
+ addSeriesValue(input: AnalyticsSeriesInput): Promise<void>;
40
+ addSeriesValues(inputs: AnalyticsSeriesInput[]): Promise<void>;
41
+ private _formatQueryRecords;
42
+ private _buildViewQuery;
43
+ private _buildDimensionQuery;
44
+ private _linkDimensions;
45
+ private _createDimensionPath;
46
+ private addDimensionMetadata;
47
+ getDimensions(): Promise<any>;
48
+ getMetrics(): Promise<any>;
49
+ getCurrencies(): Promise<any>;
50
+ subscribeToSource(path: AnalyticsPath, callback: AnalyticsUpdateCallback): () => void;
51
+ }
52
+ //# sourceMappingURL=KnexAnalyticsStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnexAnalyticsStore.d.ts","sourceRoot":"","sources":["../../src/KnexAnalyticsStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EACL,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAEzB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE7B,MAAM,sCAAsC,CAAC;AAK9C,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IACnC,CAAC,SAAS,EAAE,OAAO,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,IAAI,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACxE;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,qBAAa,kBAAmB,YAAW,eAAe;IACxD,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACjD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IAC/B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CACA;gBAElB,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,yBAAyB;IAKzD,OAAO;IAID,mBAAmB,CAC9B,MAAM,EAAE,aAAa,EACrB,iBAAiB,GAAE,OAAe,GACjC,OAAO,CAAC,MAAM,CAAC;IAgBL,6BAA6B;IAa7B,iBAAiB,CAC5B,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,eAAe,EAAE,CAAC;IAuChB,cAAc,CAAC,KAAK,EAAE,oBAAoB;IAI1C,eAAe,CAAC,MAAM,EAAE,oBAAoB,EAAE;IAyD3D,OAAO,CAAC,mBAAmB;IAoC3B,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,oBAAoB;YAWd,eAAe;YA8Bf,oBAAoB;YAUpB,oBAAoB;IAoBrB,aAAa;IAqCb,UAAU;IAuBV,aAAa;IAUnB,iBAAiB,CACtB,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,uBAAuB,GAChC,MAAM,IAAI;CAGd"}
@@ -0,0 +1,12 @@
1
+ import { type IAnalyticsProfiler } from "@powerhousedao/analytics-engine-core";
2
+ import type { Knex } from "knex";
3
+ import { type IKnexQueryExecutor } from "./KnexAnalyticsStore.js";
4
+ export declare class KnexQueryExecutor implements IKnexQueryExecutor {
5
+ private readonly _queryLogger?;
6
+ private readonly _resultsLogger?;
7
+ private readonly _profiler?;
8
+ private _index;
9
+ constructor(_queryLogger?: ((index: number, query: string) => void) | undefined, _resultsLogger?: ((index: number, results: any) => void) | undefined, _profiler?: IAnalyticsProfiler | undefined);
10
+ execute<T extends {}, U>(query: Knex.QueryBuilder<T, U>): Promise<any>;
11
+ }
12
+ //# sourceMappingURL=KnexQueryExecutor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnexQueryExecutor.d.ts","sourceRoot":"","sources":["../../src/KnexQueryExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,qBAAa,iBAAkB,YAAW,kBAAkB;IAIxD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC9B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;IAL7B,OAAO,CAAC,MAAM,CAAa;gBAGR,YAAY,CAAC,GAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,aAAA,EACrD,cAAc,CAAC,GAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,aAAA,EACtD,SAAS,CAAC,EAAE,kBAAkB,YAAA;IAO3C,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;CAqB7E"}
@@ -0,0 +1,6 @@
1
+ export * from "./KnexAnalyticsStore.js";
2
+ export { KnexQueryExecutor } from "./KnexQueryExecutor.js";
3
+ export type { IKnexQueryExecutor, KnexAnalyticsStoreOptions, } from "./KnexAnalyticsStore.js";
4
+ export type { SqlQueryLogger, SqlResultsLogger } from "./util.js";
5
+ export { defaultQueryLogger, defaultResultsLogger } from "./util.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EACV,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
@@ -4444,7 +4444,7 @@ function friendlyDateTime(dateTimeish) {
4444
4444
  }
4445
4445
  }
4446
4446
 
4447
- // ../core/build/index.js
4447
+ // ../core/dist/src/index.js
4448
4448
  var AnalyticsSerializerTypes;
4449
4449
  ((AnalyticsSerializerTypes2) => {
4450
4450
  AnalyticsSerializerTypes2[AnalyticsSerializerTypes2["AnalyticsPath"] = 0] = "AnalyticsPath";
@@ -9409,6 +9409,3 @@ export {
9409
9409
  KnexQueryExecutor,
9410
9410
  KnexAnalyticsStore
9411
9411
  };
9412
-
9413
- //# debugId=23B59978D43E742764756E2164756E21
9414
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ export type SqlQueryLogger = (index: number, query: string) => void;
2
+ export type SqlResultsLogger = (index: number, results: any) => void;
3
+ export declare const defaultQueryLogger: (tag: string) => SqlQueryLogger;
4
+ export declare const defaultResultsLogger: (tag: string) => SqlResultsLogger;
5
+ export declare function toPascalCase(str: string): string;
6
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AACpE,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;AAErE,eAAO,MAAM,kBAAkB,GAC5B,KAAK,MAAM,KAAG,cAGd,CAAC;AAEJ,eAAO,MAAM,oBAAoB,GAC9B,KAAK,MAAM,KAAG,gBAOd,CAAC;AAEJ,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,UAMvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/analytics-engine-knex",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "license": "AGPL-3.0-only",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,20 +13,18 @@
13
13
  "exports": {
14
14
  ".": {
15
15
  "types": "./dist/src/index.d.ts",
16
- "default": "./build/index.js"
16
+ "default": "./dist/src/index.js"
17
17
  }
18
18
  },
19
19
  "files": [
20
- "./build/index.js",
21
- "./build/index.js.map",
22
- "./dist/index.d.ts"
20
+ "dist/src"
23
21
  ],
24
22
  "dependencies": {
25
23
  "date-fns": "4.1.0",
26
24
  "knex": "3.1.0",
27
25
  "luxon": "3.7.2",
28
26
  "pg": "8.18.0",
29
- "@powerhousedao/analytics-engine-core": "0.6.2"
27
+ "@powerhousedao/analytics-engine-core": "0.6.4"
30
28
  },
31
29
  "devDependencies": {
32
30
  "@types/pg": "8.16.0",