@powerhousedao/analytics-engine-core 0.6.4 → 6.0.0-dev.65
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/LICENSE +1 -1
- package/dist/src/AnalyticsDiscretizer.d.ts +3 -2
- package/dist/src/AnalyticsDiscretizer.d.ts.map +1 -1
- package/dist/src/AnalyticsPath.d.ts +1 -35
- package/dist/src/AnalyticsPath.d.ts.map +1 -1
- package/dist/src/AnalyticsPeriod.d.ts +1 -48
- package/dist/src/AnalyticsPeriod.d.ts.map +1 -1
- package/dist/src/AnalyticsQuery.d.ts +2 -85
- package/dist/src/AnalyticsQuery.d.ts.map +1 -1
- package/dist/src/AnalyticsQueryEngine.d.ts.map +1 -1
- package/dist/src/AnalyticsQueryResult.d.ts +2 -2
- package/dist/src/AnalyticsQueryResult.d.ts.map +1 -1
- package/dist/src/AnalyticsSubscriptionManager.d.ts +1 -1
- package/dist/src/AnalyticsSubscriptionManager.d.ts.map +1 -1
- package/dist/src/IAnalyticsStore.d.ts +1 -25
- package/dist/src/IAnalyticsStore.d.ts.map +1 -1
- package/dist/src/index.js +192 -169
- package/package.json +5 -6
package/LICENSE
CHANGED
|
@@ -658,4 +658,4 @@ specific requirements.
|
|
|
658
658
|
You should also get your employer (if you work as a programmer) or school,
|
|
659
659
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
660
660
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
|
661
|
-
<https://www.gnu.org/licenses/>.
|
|
661
|
+
<https://www.gnu.org/licenses/>.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type AnalyticsDimension, AnalyticsGranularity, type AnalyticsSeries } from "./AnalyticsQuery.js";
|
|
2
|
-
import { type AnalyticsPeriod } from "./AnalyticsTimeSlicer.js";
|
|
3
1
|
import { DateTime } from "luxon";
|
|
2
|
+
import type { AnalyticsGranularity } from "./AnalyticsQuery.js";
|
|
3
|
+
import { type AnalyticsDimension, type AnalyticsSeries } from "./AnalyticsQuery.js";
|
|
4
|
+
import { type AnalyticsPeriod } from "./AnalyticsTimeSlicer.js";
|
|
4
5
|
export declare const getQuarter: (date: DateTime) => number;
|
|
5
6
|
export type GroupedPeriodResult = {
|
|
6
7
|
period: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsDiscretizer.d.ts","sourceRoot":"","sources":["../../src/AnalyticsDiscretizer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AnalyticsDiscretizer.d.ts","sourceRoot":"","sources":["../../src/AnalyticsDiscretizer.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare class AnalyticsPath {
|
|
3
|
-
get segments(): AnalyticsPathSegment[];
|
|
4
|
-
private _segments;
|
|
5
|
-
static fromString(path: string): AnalyticsPath;
|
|
6
|
-
static fromStringArray(segments: string[]): AnalyticsPath;
|
|
7
|
-
static fromArray(segments: AnalyticsPathSegment[]): AnalyticsPath;
|
|
8
|
-
static fromJSON(json: any): AnalyticsPath;
|
|
9
|
-
constructor(segments: AnalyticsPathSegment[]);
|
|
10
|
-
toJSON(): {
|
|
11
|
-
_t: AnalyticsSerializerTypes;
|
|
12
|
-
_v: string;
|
|
13
|
-
};
|
|
14
|
-
toString(tail?: string): string;
|
|
15
|
-
firstSegment(): AnalyticsPathSegment;
|
|
16
|
-
reduce(): AnalyticsPath;
|
|
17
|
-
applyLod(levelOfDetail: number): AnalyticsPath;
|
|
18
|
-
}
|
|
19
|
-
export declare class AnalyticsPathSegment {
|
|
20
|
-
get filters(): NullableStrings;
|
|
21
|
-
get groups(): NullableStrings;
|
|
22
|
-
private _filters;
|
|
23
|
-
private _groups;
|
|
24
|
-
static fromString(segment: string): AnalyticsPathSegment;
|
|
25
|
-
static escape(segment: string): string;
|
|
26
|
-
static unescape(segment: string): string;
|
|
27
|
-
constructor(filters?: NullableStrings, groups?: NullableStrings);
|
|
28
|
-
toJSON(): {
|
|
29
|
-
_t: AnalyticsSerializerTypes;
|
|
30
|
-
_v: string;
|
|
31
|
-
};
|
|
32
|
-
toString(): string;
|
|
33
|
-
}
|
|
34
|
-
type NullableStrings = string[] | null;
|
|
35
|
-
export {};
|
|
1
|
+
export { AnalyticsPath, AnalyticsPathSegment, } from "@powerhousedao/shared/analytics";
|
|
36
2
|
//# sourceMappingURL=AnalyticsPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsPath.d.ts","sourceRoot":"","sources":["../../src/AnalyticsPath.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AnalyticsPath.d.ts","sourceRoot":"","sources":["../../src/AnalyticsPath.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,GACrB,MAAM,iCAAiC,CAAC"}
|
|
@@ -1,49 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
AnalyticsPath = 0,
|
|
3
|
-
AnalyticsPathSegment = 1,
|
|
4
|
-
AnalyticsPeriod = 2
|
|
5
|
-
}
|
|
6
|
-
export declare enum AnalyticsPeriodType {
|
|
7
|
-
Year = 0,
|
|
8
|
-
Quarter = 1,
|
|
9
|
-
Month = 2
|
|
10
|
-
}
|
|
11
|
-
export declare class AnalyticsPeriod {
|
|
12
|
-
get type(): AnalyticsPeriodType;
|
|
13
|
-
get year(): number;
|
|
14
|
-
get quarter(): number | null;
|
|
15
|
-
get month(): number | null;
|
|
16
|
-
private _type;
|
|
17
|
-
private _year;
|
|
18
|
-
private _quarter;
|
|
19
|
-
private _month;
|
|
20
|
-
toJSON(): {
|
|
21
|
-
_t: AnalyticsSerializerTypes;
|
|
22
|
-
_v: string;
|
|
23
|
-
};
|
|
24
|
-
static fromString(period: string): AnalyticsPeriod;
|
|
25
|
-
static fillRange(p1: AnalyticsPeriod | string, p2: AnalyticsPeriod | string): AnalyticsPeriod[];
|
|
26
|
-
static normalizeQuarters(year: number, quarter: number): PeriodTriple;
|
|
27
|
-
static normalizeMonths(year: number, month: number): PeriodTriple;
|
|
28
|
-
constructor(year: number, quarter?: number, month?: number);
|
|
29
|
-
equals(period: AnalyticsPeriod | string): boolean;
|
|
30
|
-
toString(): string;
|
|
31
|
-
startAsSqlDate(): string;
|
|
32
|
-
comesAfter(period: AnalyticsPeriod): boolean;
|
|
33
|
-
comesBefore(period: AnalyticsPeriod): boolean;
|
|
34
|
-
contains(period: AnalyticsPeriod): boolean;
|
|
35
|
-
firstMonth(): AnalyticsPeriod;
|
|
36
|
-
lastMonth(): AnalyticsPeriod;
|
|
37
|
-
nextPeriod(n?: number): AnalyticsPeriod;
|
|
38
|
-
previousPeriod(n?: number): AnalyticsPeriod;
|
|
39
|
-
private _start;
|
|
40
|
-
private _end;
|
|
41
|
-
private _getNumericComparator;
|
|
42
|
-
private _addPeriods;
|
|
43
|
-
private _initAsYear;
|
|
44
|
-
private _initAsQuarter;
|
|
45
|
-
private _initAsMonth;
|
|
46
|
-
}
|
|
47
|
-
type PeriodTriple = [number, number | undefined, number | undefined];
|
|
48
|
-
export {};
|
|
1
|
+
export { AnalyticsPeriod, AnalyticsSerializerTypes, } from "@powerhousedao/shared/analytics";
|
|
49
2
|
//# sourceMappingURL=AnalyticsPeriod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsPeriod.d.ts","sourceRoot":"","sources":["../../src/AnalyticsPeriod.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"AnalyticsPeriod.d.ts","sourceRoot":"","sources":["../../src/AnalyticsPeriod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,wBAAwB,GACzB,MAAM,iCAAiC,CAAC"}
|
|
@@ -1,86 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type AnalyticsSeriesQuery = {
|
|
4
|
-
start: DateTime | null;
|
|
5
|
-
end: DateTime | null;
|
|
6
|
-
metrics: string[];
|
|
7
|
-
currency?: AnalyticsPath;
|
|
8
|
-
select: Record<string, AnalyticsPath[]>;
|
|
9
|
-
};
|
|
10
|
-
export type AnalyticsQuery = AnalyticsSeriesQuery & {
|
|
11
|
-
granularity: AnalyticsGranularity;
|
|
12
|
-
lod: Record<string, number | null>;
|
|
13
|
-
};
|
|
14
|
-
export type AnalyticsSeries<D = string | AnalyticsDimension> = {
|
|
15
|
-
source: AnalyticsPath;
|
|
16
|
-
start: DateTime;
|
|
17
|
-
end: DateTime | null;
|
|
18
|
-
metric: string;
|
|
19
|
-
value: number;
|
|
20
|
-
unit: string | null;
|
|
21
|
-
fn: string;
|
|
22
|
-
params: Record<string, any> | null;
|
|
23
|
-
dimensions: Record<string, D>;
|
|
24
|
-
};
|
|
25
|
-
export type AnalyticsDimension = {
|
|
26
|
-
path: AnalyticsPath;
|
|
27
|
-
icon: string;
|
|
28
|
-
label: string;
|
|
29
|
-
description: string;
|
|
30
|
-
};
|
|
31
|
-
export declare enum AnalyticsMetric {
|
|
32
|
-
Budget = 0,
|
|
33
|
-
Forecast = 1,
|
|
34
|
-
Actuals = 2,
|
|
35
|
-
PaymentsOnChain = 3,
|
|
36
|
-
PaymentsOffChainIncluded = 4,
|
|
37
|
-
FTEs = 5
|
|
38
|
-
}
|
|
39
|
-
export type CompoundAnalyticsQuery = {
|
|
40
|
-
start: DateTime | null;
|
|
41
|
-
end: DateTime | null;
|
|
42
|
-
granularity: AnalyticsGranularity;
|
|
43
|
-
lod: Record<string, number | null>;
|
|
44
|
-
select: Record<string, AnalyticsPath[]>;
|
|
45
|
-
expression: CompoundAnalyticsExpression;
|
|
46
|
-
};
|
|
47
|
-
export type CompoundAnalyticsExpression = {
|
|
48
|
-
inputs: CompoundAnalyticsInputs;
|
|
49
|
-
operator: CompoundOperator;
|
|
50
|
-
operand: AnalyticsOperand;
|
|
51
|
-
resultCurrency?: AnalyticsPath;
|
|
52
|
-
};
|
|
53
|
-
export type CompoundAnalyticsInputs = {
|
|
54
|
-
metrics: string[];
|
|
55
|
-
currency?: AnalyticsPath;
|
|
56
|
-
};
|
|
57
|
-
export type AnalyticsOperand = {
|
|
58
|
-
metric: string;
|
|
59
|
-
currency?: AnalyticsPath;
|
|
60
|
-
useSum: boolean;
|
|
61
|
-
};
|
|
62
|
-
export declare enum CompoundOperator {
|
|
63
|
-
VectorAdd = 0,
|
|
64
|
-
VectorSubtract = 1,
|
|
65
|
-
ScalarMultiply = 2,
|
|
66
|
-
ScalarDivide = 3
|
|
67
|
-
}
|
|
68
|
-
export type MultiCurrencyConversion = {
|
|
69
|
-
targetCurrency?: AnalyticsPath;
|
|
70
|
-
conversions: ConversionMetric[];
|
|
71
|
-
};
|
|
72
|
-
export type ConversionMetric = {
|
|
73
|
-
metric: string;
|
|
74
|
-
currency?: AnalyticsPath;
|
|
75
|
-
};
|
|
76
|
-
export declare enum AnalyticsGranularity {
|
|
77
|
-
Total = 0,
|
|
78
|
-
Annual = 1,
|
|
79
|
-
SemiAnnual = 2,
|
|
80
|
-
Quarterly = 3,
|
|
81
|
-
Monthly = 4,
|
|
82
|
-
Weekly = 5,
|
|
83
|
-
Daily = 6,
|
|
84
|
-
Hourly = 7
|
|
85
|
-
}
|
|
1
|
+
export { AnalyticsGranularity, AnalyticsMetric, CompoundOperator, } from "@powerhousedao/shared/analytics";
|
|
2
|
+
export type { AnalyticsDimension, AnalyticsOperand, AnalyticsQuery, AnalyticsSeries, AnalyticsSeriesQuery, CompoundAnalyticsExpression, CompoundAnalyticsInputs, CompoundAnalyticsQuery, ConversionMetric, MultiCurrencyConversion, } from "@powerhousedao/shared/analytics";
|
|
86
3
|
//# sourceMappingURL=AnalyticsQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsQuery.d.ts","sourceRoot":"","sources":["../../src/AnalyticsQuery.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AnalyticsQuery.d.ts","sourceRoot":"","sources":["../../src/AnalyticsQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,gBAAgB,GACjB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,iCAAiC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsQueryEngine.d.ts","sourceRoot":"","sources":["../../src/AnalyticsQueryEngine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AnalyticsQueryEngine.d.ts","sourceRoot":"","sources":["../../src/AnalyticsQueryEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,oBAAoB,EAE1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAE7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,qBAAa,oBAAoB;IAI7B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAHlC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;gBAG5B,eAAe,EAAE,eAAe,EACjD,QAAQ,CAAC,EAAE,kBAAkB;IAKlB,eAAe,CAC1B,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,oBAAoB,CAAC;IA0DnB,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAsB7D,oBAAoB,CAC/B,KAAK,EAAE,cAAc,EACrB,GAAG,EAAE,uBAAuB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;YAwClB,oBAAoB;YAgBpB,oBAAoB;IAoDlC,OAAO,CAAC,qBAAqB;YAiBf,mBAAmB;IAcjC,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,oBAAoB;IAmBf,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC;CAW3C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnalyticsPath } from "./AnalyticsPath.js";
|
|
2
|
-
import { AnalyticsPeriod } from "./AnalyticsPeriod.js";
|
|
1
|
+
import type { AnalyticsPath } from "./AnalyticsPath.js";
|
|
2
|
+
import type { AnalyticsPeriod } from "./AnalyticsPeriod.js";
|
|
3
3
|
export type AnalyticsQueryResultRow = {
|
|
4
4
|
period: AnalyticsPeriod;
|
|
5
5
|
dimensions: Record<string, AnalyticsPath>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsQueryResult.d.ts","sourceRoot":"","sources":["../../src/AnalyticsQueryResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"AnalyticsQueryResult.d.ts","sourceRoot":"","sources":["../../src/AnalyticsQueryResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,uBAAuB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsSubscriptionManager.d.ts","sourceRoot":"","sources":["../../src/AnalyticsSubscriptionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"AnalyticsSubscriptionManager.d.ts","sourceRoot":"","sources":["../../src/AnalyticsSubscriptionManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,SAAgB,WAAW,EAAE,KAAK,EAAE,CAAC;gBAEzB,MAAM,EAAE,KAAK,EAAE;CAM5B;AAED;;GAEG;AACH,qBAAa,4BAA4B;IACvC,OAAO,CAAC,cAAc,CAAwD;IAE9E;;;;;;;;;;;;;OAaG;IACI,eAAe,CACpB,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,uBAAuB,GAChC,MAAM,IAAI;IAsBb;;;;OAIG;IACI,iBAAiB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,IAAI;IA+DtD;;OAEG;IACH,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACH,OAAO,CAAC,0BAA0B;IA0ClC;;;;OAIG;IACH,OAAO,CAAC,eAAe;CAgBxB"}
|
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { AnalyticsPath } from "./AnalyticsPath.js";
|
|
3
|
-
import type { AnalyticsSeries, AnalyticsSeriesQuery } from "./AnalyticsQuery.js";
|
|
4
|
-
export type AnalyticsSeriesInput = {
|
|
5
|
-
start: DateTime;
|
|
6
|
-
end?: DateTime | null;
|
|
7
|
-
source: AnalyticsPath;
|
|
8
|
-
metric: string;
|
|
9
|
-
value: number;
|
|
10
|
-
unit?: string | null;
|
|
11
|
-
fn?: string | null;
|
|
12
|
-
params?: Record<string, any> | null;
|
|
13
|
-
dimensions: Record<string, AnalyticsPath>;
|
|
14
|
-
dimensionMetadata?: Record<string, string>;
|
|
15
|
-
};
|
|
16
|
-
export type AnalyticsUpdateCallback = (source: AnalyticsPath) => void;
|
|
17
|
-
export interface IAnalyticsStore {
|
|
18
|
-
clearSeriesBySource: (source: AnalyticsPath, cleanUpDimensions?: boolean) => Promise<number>;
|
|
19
|
-
clearEmptyAnalyticsDimensions: () => Promise<number>;
|
|
20
|
-
getMatchingSeries: (query: AnalyticsSeriesQuery) => Promise<AnalyticsSeries[]>;
|
|
21
|
-
addSeriesValue: (input: AnalyticsSeriesInput) => Promise<void>;
|
|
22
|
-
addSeriesValues: (inputs: AnalyticsSeriesInput[]) => Promise<void>;
|
|
23
|
-
getDimensions: () => Promise<any>;
|
|
24
|
-
subscribeToSource: (source: AnalyticsPath, callback: AnalyticsUpdateCallback) => () => void;
|
|
25
|
-
}
|
|
1
|
+
export type { AnalyticsSeriesInput, AnalyticsUpdateCallback, IAnalyticsStore, } from "@powerhousedao/shared/analytics";
|
|
26
2
|
//# sourceMappingURL=IAnalyticsStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IAnalyticsStore.d.ts","sourceRoot":"","sources":["../../src/IAnalyticsStore.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"IAnalyticsStore.d.ts","sourceRoot":"","sources":["../../src/IAnalyticsStore.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,GAChB,MAAM,iCAAiC,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -68,13 +68,169 @@ class PassthroughAnalyticsProfiler {
|
|
|
68
68
|
return fn();
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
//
|
|
71
|
+
// ../../shared/dist/analytics/constants.js
|
|
72
72
|
var AnalyticsSerializerTypes;
|
|
73
|
-
((AnalyticsSerializerTypes2)
|
|
73
|
+
(function(AnalyticsSerializerTypes2) {
|
|
74
74
|
AnalyticsSerializerTypes2[AnalyticsSerializerTypes2["AnalyticsPath"] = 0] = "AnalyticsPath";
|
|
75
75
|
AnalyticsSerializerTypes2[AnalyticsSerializerTypes2["AnalyticsPathSegment"] = 1] = "AnalyticsPathSegment";
|
|
76
76
|
AnalyticsSerializerTypes2[AnalyticsSerializerTypes2["AnalyticsPeriod"] = 2] = "AnalyticsPeriod";
|
|
77
|
-
})(AnalyticsSerializerTypes
|
|
77
|
+
})(AnalyticsSerializerTypes || (AnalyticsSerializerTypes = {}));
|
|
78
|
+
var AnalyticsPeriodType;
|
|
79
|
+
(function(AnalyticsPeriodType2) {
|
|
80
|
+
AnalyticsPeriodType2[AnalyticsPeriodType2["Year"] = 0] = "Year";
|
|
81
|
+
AnalyticsPeriodType2[AnalyticsPeriodType2["Quarter"] = 1] = "Quarter";
|
|
82
|
+
AnalyticsPeriodType2[AnalyticsPeriodType2["Month"] = 2] = "Month";
|
|
83
|
+
})(AnalyticsPeriodType || (AnalyticsPeriodType = {}));
|
|
84
|
+
var AnalyticsMetric;
|
|
85
|
+
(function(AnalyticsMetric2) {
|
|
86
|
+
AnalyticsMetric2[AnalyticsMetric2["Budget"] = 0] = "Budget";
|
|
87
|
+
AnalyticsMetric2[AnalyticsMetric2["Forecast"] = 1] = "Forecast";
|
|
88
|
+
AnalyticsMetric2[AnalyticsMetric2["Actuals"] = 2] = "Actuals";
|
|
89
|
+
AnalyticsMetric2[AnalyticsMetric2["PaymentsOnChain"] = 3] = "PaymentsOnChain";
|
|
90
|
+
AnalyticsMetric2[AnalyticsMetric2["PaymentsOffChainIncluded"] = 4] = "PaymentsOffChainIncluded";
|
|
91
|
+
AnalyticsMetric2[AnalyticsMetric2["FTEs"] = 5] = "FTEs";
|
|
92
|
+
})(AnalyticsMetric || (AnalyticsMetric = {}));
|
|
93
|
+
var CompoundOperator;
|
|
94
|
+
(function(CompoundOperator2) {
|
|
95
|
+
CompoundOperator2[CompoundOperator2["VectorAdd"] = 0] = "VectorAdd";
|
|
96
|
+
CompoundOperator2[CompoundOperator2["VectorSubtract"] = 1] = "VectorSubtract";
|
|
97
|
+
CompoundOperator2[CompoundOperator2["ScalarMultiply"] = 2] = "ScalarMultiply";
|
|
98
|
+
CompoundOperator2[CompoundOperator2["ScalarDivide"] = 3] = "ScalarDivide";
|
|
99
|
+
})(CompoundOperator || (CompoundOperator = {}));
|
|
100
|
+
var AnalyticsGranularity;
|
|
101
|
+
(function(AnalyticsGranularity2) {
|
|
102
|
+
AnalyticsGranularity2[AnalyticsGranularity2["Total"] = 0] = "Total";
|
|
103
|
+
AnalyticsGranularity2[AnalyticsGranularity2["Annual"] = 1] = "Annual";
|
|
104
|
+
AnalyticsGranularity2[AnalyticsGranularity2["SemiAnnual"] = 2] = "SemiAnnual";
|
|
105
|
+
AnalyticsGranularity2[AnalyticsGranularity2["Quarterly"] = 3] = "Quarterly";
|
|
106
|
+
AnalyticsGranularity2[AnalyticsGranularity2["Monthly"] = 4] = "Monthly";
|
|
107
|
+
AnalyticsGranularity2[AnalyticsGranularity2["Weekly"] = 5] = "Weekly";
|
|
108
|
+
AnalyticsGranularity2[AnalyticsGranularity2["Daily"] = 6] = "Daily";
|
|
109
|
+
AnalyticsGranularity2[AnalyticsGranularity2["Hourly"] = 7] = "Hourly";
|
|
110
|
+
})(AnalyticsGranularity || (AnalyticsGranularity = {}));
|
|
111
|
+
|
|
112
|
+
// ../../shared/dist/analytics/analytics-path.js
|
|
113
|
+
class AnalyticsPath {
|
|
114
|
+
get segments() {
|
|
115
|
+
return this._segments;
|
|
116
|
+
}
|
|
117
|
+
_segments;
|
|
118
|
+
static fromString(path) {
|
|
119
|
+
const segments = parseSeparatedList(path, "/").map((segment) => AnalyticsPathSegment.fromString(segment));
|
|
120
|
+
return new AnalyticsPath(segments);
|
|
121
|
+
}
|
|
122
|
+
static fromStringArray(segments) {
|
|
123
|
+
return new AnalyticsPath(segments.map((segment) => AnalyticsPathSegment.fromString(segment)));
|
|
124
|
+
}
|
|
125
|
+
static fromArray(segments) {
|
|
126
|
+
return new AnalyticsPath(segments);
|
|
127
|
+
}
|
|
128
|
+
static fromJSON(json) {
|
|
129
|
+
const segments = json._v.split("/").map((segment) => AnalyticsPathSegment.fromString(segment));
|
|
130
|
+
return new AnalyticsPath(segments);
|
|
131
|
+
}
|
|
132
|
+
constructor(segments) {
|
|
133
|
+
this._segments = segments;
|
|
134
|
+
}
|
|
135
|
+
toJSON() {
|
|
136
|
+
return {
|
|
137
|
+
_t: AnalyticsSerializerTypes.AnalyticsPath,
|
|
138
|
+
_v: this.toString()
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
toString(tail = "") {
|
|
142
|
+
return this._segments.map((s) => s.toString()).join("/") + tail;
|
|
143
|
+
}
|
|
144
|
+
firstSegment() {
|
|
145
|
+
return this._segments.length > 0 ? this._segments[0] : new AnalyticsPathSegment;
|
|
146
|
+
}
|
|
147
|
+
reduce() {
|
|
148
|
+
const result = this._segments.slice(1);
|
|
149
|
+
if (result.length < 1) {
|
|
150
|
+
result.push(new AnalyticsPathSegment);
|
|
151
|
+
}
|
|
152
|
+
return new AnalyticsPath(result);
|
|
153
|
+
}
|
|
154
|
+
applyLod(levelOfDetail) {
|
|
155
|
+
const segments = [...this._segments];
|
|
156
|
+
while (segments.length < levelOfDetail) {
|
|
157
|
+
segments.push(new AnalyticsPathSegment);
|
|
158
|
+
}
|
|
159
|
+
return new AnalyticsPath(segments.slice(0, levelOfDetail));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
class AnalyticsPathSegment {
|
|
164
|
+
get filters() {
|
|
165
|
+
return this._filters;
|
|
166
|
+
}
|
|
167
|
+
get groups() {
|
|
168
|
+
return this._groups;
|
|
169
|
+
}
|
|
170
|
+
_filters = null;
|
|
171
|
+
_groups = null;
|
|
172
|
+
static fromString(segment) {
|
|
173
|
+
const elements = parseSeparatedList(segment, ":");
|
|
174
|
+
let filtersArg;
|
|
175
|
+
if (elements[0] === "*") {
|
|
176
|
+
filtersArg = null;
|
|
177
|
+
} else {
|
|
178
|
+
filtersArg = parseSeparatedList(elements[0], ",").map((f) => AnalyticsPathSegment.unescape(f));
|
|
179
|
+
}
|
|
180
|
+
let groupsArg;
|
|
181
|
+
if (elements[1] === undefined || elements[1].length < 1) {
|
|
182
|
+
groupsArg = [];
|
|
183
|
+
} else if (elements[1] === "*") {
|
|
184
|
+
groupsArg = null;
|
|
185
|
+
} else {
|
|
186
|
+
groupsArg = parseSeparatedList(elements[1], ",").map((g) => AnalyticsPathSegment.unescape(g));
|
|
187
|
+
}
|
|
188
|
+
return new AnalyticsPathSegment(filtersArg, groupsArg);
|
|
189
|
+
}
|
|
190
|
+
static escape(segment) {
|
|
191
|
+
return segment.replace(/(\\|:|\/|,)/gi, "\\$1");
|
|
192
|
+
}
|
|
193
|
+
static unescape(segment) {
|
|
194
|
+
return segment.replace(/\\(.)/gi, "$1");
|
|
195
|
+
}
|
|
196
|
+
constructor(filters = null, groups = []) {
|
|
197
|
+
this._filters = filters;
|
|
198
|
+
this._groups = groups;
|
|
199
|
+
}
|
|
200
|
+
toJSON() {
|
|
201
|
+
return {
|
|
202
|
+
_t: AnalyticsSerializerTypes.AnalyticsPathSegment,
|
|
203
|
+
_v: this.toString()
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
toString() {
|
|
207
|
+
let result = "";
|
|
208
|
+
if (this._filters === null) {
|
|
209
|
+
result += "*";
|
|
210
|
+
} else {
|
|
211
|
+
result += this._filters.map((f) => AnalyticsPathSegment.escape(f)).join(",");
|
|
212
|
+
}
|
|
213
|
+
if (this._groups === null) {
|
|
214
|
+
result += ":*";
|
|
215
|
+
} else if (this._groups.length > 0) {
|
|
216
|
+
result += ":" + this._groups.map((g) => AnalyticsPathSegment.escape(g)).join(",");
|
|
217
|
+
}
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
var unescapedSeparatorPattern = {
|
|
222
|
+
":": /(?<!\\):/,
|
|
223
|
+
",": /(?<!\\),/,
|
|
224
|
+
"/": /(?<!\\)\//
|
|
225
|
+
};
|
|
226
|
+
function parseSeparatedList(list, separator) {
|
|
227
|
+
let substituteString = "@@";
|
|
228
|
+
while (list.indexOf(substituteString) > -1) {
|
|
229
|
+
substituteString += "@";
|
|
230
|
+
}
|
|
231
|
+
return list.replaceAll("\\\\", substituteString).split(unescapedSeparatorPattern[separator]).map((e) => e.replaceAll(substituteString, "\\\\"));
|
|
232
|
+
}
|
|
233
|
+
// ../../shared/dist/analytics/analytics-period.js
|
|
78
234
|
class AnalyticsPeriod {
|
|
79
235
|
get type() {
|
|
80
236
|
return this._type;
|
|
@@ -88,13 +244,13 @@ class AnalyticsPeriod {
|
|
|
88
244
|
get month() {
|
|
89
245
|
return this._month;
|
|
90
246
|
}
|
|
91
|
-
_type =
|
|
247
|
+
_type = AnalyticsPeriodType.Year;
|
|
92
248
|
_year = 1970;
|
|
93
249
|
_quarter = null;
|
|
94
250
|
_month = null;
|
|
95
251
|
toJSON() {
|
|
96
252
|
return {
|
|
97
|
-
_t:
|
|
253
|
+
_t: AnalyticsSerializerTypes.AnalyticsPeriod,
|
|
98
254
|
_v: this.toString()
|
|
99
255
|
};
|
|
100
256
|
}
|
|
@@ -156,10 +312,10 @@ class AnalyticsPeriod {
|
|
|
156
312
|
return this.toString() === (typeof period === "string" ? period : period.toString());
|
|
157
313
|
}
|
|
158
314
|
toString() {
|
|
159
|
-
let result = this._year + (this._type ===
|
|
160
|
-
if (this._type ===
|
|
315
|
+
let result = this._year + (this._type === AnalyticsPeriodType.Year ? "" : "/");
|
|
316
|
+
if (this._type === AnalyticsPeriodType.Quarter) {
|
|
161
317
|
result += "Q" + this._quarter;
|
|
162
|
-
} else if (this._type ===
|
|
318
|
+
} else if (this._type === AnalyticsPeriodType.Month) {
|
|
163
319
|
if (this._month < 10) {
|
|
164
320
|
result += "0";
|
|
165
321
|
}
|
|
@@ -170,14 +326,15 @@ class AnalyticsPeriod {
|
|
|
170
326
|
startAsSqlDate() {
|
|
171
327
|
let result = this._year + "-";
|
|
172
328
|
switch (this._type) {
|
|
173
|
-
case
|
|
329
|
+
case AnalyticsPeriodType.Month:
|
|
174
330
|
result += (this._month < 10 ? "0" : "") + this.month;
|
|
175
331
|
break;
|
|
176
|
-
case
|
|
332
|
+
case AnalyticsPeriodType.Quarter: {
|
|
177
333
|
const firstMonth = (this._quarter - 1) * 3 + 1;
|
|
178
334
|
result += (firstMonth < 10 ? "0" : "") + firstMonth;
|
|
179
335
|
break;
|
|
180
|
-
|
|
336
|
+
}
|
|
337
|
+
case AnalyticsPeriodType.Year:
|
|
181
338
|
result += "01";
|
|
182
339
|
break;
|
|
183
340
|
}
|
|
@@ -194,14 +351,14 @@ class AnalyticsPeriod {
|
|
|
194
351
|
}
|
|
195
352
|
firstMonth() {
|
|
196
353
|
let month = this._month || 1;
|
|
197
|
-
if (this._type ===
|
|
354
|
+
if (this._type === AnalyticsPeriodType.Quarter) {
|
|
198
355
|
month = (this._quarter - 1) * 3 + 1;
|
|
199
356
|
}
|
|
200
357
|
return new AnalyticsPeriod(this._year, undefined, month);
|
|
201
358
|
}
|
|
202
359
|
lastMonth() {
|
|
203
360
|
let month = this._month || 12;
|
|
204
|
-
if (this._type ===
|
|
361
|
+
if (this._type === AnalyticsPeriodType.Quarter) {
|
|
205
362
|
month = this._quarter * 3;
|
|
206
363
|
}
|
|
207
364
|
return new AnalyticsPeriod(this._year, undefined, month);
|
|
@@ -224,9 +381,9 @@ class AnalyticsPeriod {
|
|
|
224
381
|
}
|
|
225
382
|
_addPeriods(periods) {
|
|
226
383
|
let result;
|
|
227
|
-
if (this._type ===
|
|
384
|
+
if (this._type === AnalyticsPeriodType.Year) {
|
|
228
385
|
result = new AnalyticsPeriod(this._year + periods);
|
|
229
|
-
} else if (this._type ===
|
|
386
|
+
} else if (this._type === AnalyticsPeriodType.Quarter) {
|
|
230
387
|
const [y, q] = AnalyticsPeriod.normalizeQuarters(this._year, this._quarter + periods);
|
|
231
388
|
result = new AnalyticsPeriod(y, q);
|
|
232
389
|
} else {
|
|
@@ -246,7 +403,7 @@ class AnalyticsPeriod {
|
|
|
246
403
|
throw new Error(`Invalid period quarter: ${quarter}`);
|
|
247
404
|
}
|
|
248
405
|
this._quarter = quarter;
|
|
249
|
-
this._type =
|
|
406
|
+
this._type = AnalyticsPeriodType.Quarter;
|
|
250
407
|
}
|
|
251
408
|
_initAsMonth(month) {
|
|
252
409
|
if (month < 1 || month > 12) {
|
|
@@ -258,147 +415,13 @@ class AnalyticsPeriod {
|
|
|
258
415
|
throw new Error(`Period month ${month} outside of quarter ${this.quarter}`);
|
|
259
416
|
}
|
|
260
417
|
this._month = month;
|
|
261
|
-
this._type =
|
|
418
|
+
this._type = AnalyticsPeriodType.Month;
|
|
262
419
|
}
|
|
263
420
|
}
|
|
264
421
|
function moduloButWithoutBugs(base, n) {
|
|
265
422
|
return (base % n + n) % n;
|
|
266
423
|
}
|
|
267
|
-
|
|
268
|
-
// src/AnalyticsPath.ts
|
|
269
|
-
class AnalyticsPath {
|
|
270
|
-
get segments() {
|
|
271
|
-
return this._segments;
|
|
272
|
-
}
|
|
273
|
-
_segments;
|
|
274
|
-
static fromString(path) {
|
|
275
|
-
const segments = parseSeparatedList(path, "/").map((segment) => AnalyticsPathSegment.fromString(segment));
|
|
276
|
-
return new AnalyticsPath(segments);
|
|
277
|
-
}
|
|
278
|
-
static fromStringArray(segments) {
|
|
279
|
-
return new AnalyticsPath(segments.map((segment) => AnalyticsPathSegment.fromString(segment)));
|
|
280
|
-
}
|
|
281
|
-
static fromArray(segments) {
|
|
282
|
-
return new AnalyticsPath(segments);
|
|
283
|
-
}
|
|
284
|
-
static fromJSON(json) {
|
|
285
|
-
const segments = json._v.split("/").map((segment) => AnalyticsPathSegment.fromString(segment));
|
|
286
|
-
return new AnalyticsPath(segments);
|
|
287
|
-
}
|
|
288
|
-
constructor(segments) {
|
|
289
|
-
this._segments = segments;
|
|
290
|
-
}
|
|
291
|
-
toJSON() {
|
|
292
|
-
return {
|
|
293
|
-
_t: 0 /* AnalyticsPath */,
|
|
294
|
-
_v: this.toString()
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
toString(tail = "") {
|
|
298
|
-
return this._segments.map((s) => s.toString()).join("/") + tail;
|
|
299
|
-
}
|
|
300
|
-
firstSegment() {
|
|
301
|
-
return this._segments.length > 0 ? this._segments[0] : new AnalyticsPathSegment;
|
|
302
|
-
}
|
|
303
|
-
reduce() {
|
|
304
|
-
const result = this._segments.slice(1);
|
|
305
|
-
if (result.length < 1) {
|
|
306
|
-
result.push(new AnalyticsPathSegment);
|
|
307
|
-
}
|
|
308
|
-
return new AnalyticsPath(result);
|
|
309
|
-
}
|
|
310
|
-
applyLod(levelOfDetail) {
|
|
311
|
-
const segments = [...this._segments];
|
|
312
|
-
while (segments.length < levelOfDetail) {
|
|
313
|
-
segments.push(new AnalyticsPathSegment);
|
|
314
|
-
}
|
|
315
|
-
return new AnalyticsPath(segments.slice(0, levelOfDetail));
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
class AnalyticsPathSegment {
|
|
320
|
-
get filters() {
|
|
321
|
-
return this._filters;
|
|
322
|
-
}
|
|
323
|
-
get groups() {
|
|
324
|
-
return this._groups;
|
|
325
|
-
}
|
|
326
|
-
_filters = null;
|
|
327
|
-
_groups = null;
|
|
328
|
-
static fromString(segment) {
|
|
329
|
-
const elements = parseSeparatedList(segment, ":");
|
|
330
|
-
let filtersArg;
|
|
331
|
-
if (elements[0] === "*") {
|
|
332
|
-
filtersArg = null;
|
|
333
|
-
} else {
|
|
334
|
-
filtersArg = parseSeparatedList(elements[0], ",").map((f) => AnalyticsPathSegment.unescape(f));
|
|
335
|
-
}
|
|
336
|
-
let groupsArg;
|
|
337
|
-
if (elements[1] === undefined || elements[1].length < 1) {
|
|
338
|
-
groupsArg = [];
|
|
339
|
-
} else if (elements[1] === "*") {
|
|
340
|
-
groupsArg = null;
|
|
341
|
-
} else {
|
|
342
|
-
groupsArg = parseSeparatedList(elements[1], ",").map((g) => AnalyticsPathSegment.unescape(g));
|
|
343
|
-
}
|
|
344
|
-
return new AnalyticsPathSegment(filtersArg, groupsArg);
|
|
345
|
-
}
|
|
346
|
-
static escape(segment) {
|
|
347
|
-
return segment.replace(/(\\|:|\/|,)/gi, "\\$1");
|
|
348
|
-
}
|
|
349
|
-
static unescape(segment) {
|
|
350
|
-
return segment.replace(/\\(.)/gi, "$1");
|
|
351
|
-
}
|
|
352
|
-
constructor(filters = null, groups = []) {
|
|
353
|
-
this._filters = filters;
|
|
354
|
-
this._groups = groups;
|
|
355
|
-
}
|
|
356
|
-
toJSON() {
|
|
357
|
-
return {
|
|
358
|
-
_t: 1 /* AnalyticsPathSegment */,
|
|
359
|
-
_v: this.toString()
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
toString() {
|
|
363
|
-
let result = "";
|
|
364
|
-
if (this._filters === null) {
|
|
365
|
-
result += "*";
|
|
366
|
-
} else {
|
|
367
|
-
result += this._filters.map((f) => AnalyticsPathSegment.escape(f)).join(",");
|
|
368
|
-
}
|
|
369
|
-
if (this._groups === null) {
|
|
370
|
-
result += ":*";
|
|
371
|
-
} else if (this._groups.length > 0) {
|
|
372
|
-
result += ":" + this._groups.map((g) => AnalyticsPathSegment.escape(g)).join(",");
|
|
373
|
-
}
|
|
374
|
-
return result;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
var unescapedSeparatorPattern = {
|
|
378
|
-
":": /(?<!\\):/,
|
|
379
|
-
",": /(?<!\\),/,
|
|
380
|
-
"/": /(?<!\\)\//
|
|
381
|
-
};
|
|
382
|
-
function parseSeparatedList(list, separator) {
|
|
383
|
-
let substituteString = "@@";
|
|
384
|
-
while (list.indexOf(substituteString) > -1) {
|
|
385
|
-
substituteString += "@";
|
|
386
|
-
}
|
|
387
|
-
return list.replaceAll("\\\\", substituteString).split(unescapedSeparatorPattern[separator]).map((e) => e.replaceAll(substituteString, "\\\\"));
|
|
388
|
-
}
|
|
389
|
-
// src/AnalyticsQuery.ts
|
|
390
|
-
var AnalyticsGranularity;
|
|
391
|
-
((AnalyticsGranularity2) => {
|
|
392
|
-
AnalyticsGranularity2[AnalyticsGranularity2["Total"] = 0] = "Total";
|
|
393
|
-
AnalyticsGranularity2[AnalyticsGranularity2["Annual"] = 1] = "Annual";
|
|
394
|
-
AnalyticsGranularity2[AnalyticsGranularity2["SemiAnnual"] = 2] = "SemiAnnual";
|
|
395
|
-
AnalyticsGranularity2[AnalyticsGranularity2["Quarterly"] = 3] = "Quarterly";
|
|
396
|
-
AnalyticsGranularity2[AnalyticsGranularity2["Monthly"] = 4] = "Monthly";
|
|
397
|
-
AnalyticsGranularity2[AnalyticsGranularity2["Weekly"] = 5] = "Weekly";
|
|
398
|
-
AnalyticsGranularity2[AnalyticsGranularity2["Daily"] = 6] = "Daily";
|
|
399
|
-
AnalyticsGranularity2[AnalyticsGranularity2["Hourly"] = 7] = "Hourly";
|
|
400
|
-
})(AnalyticsGranularity ||= {});
|
|
401
|
-
// ../node_modules/.pnpm/luxon@3.7.2/node_modules/luxon/build/es6/luxon.mjs
|
|
424
|
+
// ../../../node_modules/.pnpm/luxon@3.7.2/node_modules/luxon/build/es6/luxon.mjs
|
|
402
425
|
class LuxonError extends Error {
|
|
403
426
|
}
|
|
404
427
|
|
|
@@ -4869,28 +4892,28 @@ var _createFactoryFn = (range) => {
|
|
|
4869
4892
|
}
|
|
4870
4893
|
let result = null;
|
|
4871
4894
|
switch (range.granularity) {
|
|
4872
|
-
case
|
|
4895
|
+
case AnalyticsGranularity.Total:
|
|
4873
4896
|
result = _nextTotalPeriod(current, range.end);
|
|
4874
4897
|
break;
|
|
4875
|
-
case
|
|
4898
|
+
case AnalyticsGranularity.Annual:
|
|
4876
4899
|
result = _nextAnnualPeriod(current, range.end);
|
|
4877
4900
|
break;
|
|
4878
|
-
case
|
|
4901
|
+
case AnalyticsGranularity.SemiAnnual:
|
|
4879
4902
|
result = _nextSemiAnnualPeriod(current, range.end);
|
|
4880
4903
|
break;
|
|
4881
|
-
case
|
|
4904
|
+
case AnalyticsGranularity.Quarterly:
|
|
4882
4905
|
result = _nextQuarterlyPeriod(current, range.end);
|
|
4883
4906
|
break;
|
|
4884
|
-
case
|
|
4907
|
+
case AnalyticsGranularity.Monthly:
|
|
4885
4908
|
result = _nextMonthlyPeriod(current, range.end);
|
|
4886
4909
|
break;
|
|
4887
|
-
case
|
|
4910
|
+
case AnalyticsGranularity.Weekly:
|
|
4888
4911
|
result = _nextWeeklyPeriod(current, range.end);
|
|
4889
4912
|
break;
|
|
4890
|
-
case
|
|
4913
|
+
case AnalyticsGranularity.Daily:
|
|
4891
4914
|
result = _nextDailyPeriod(current, range.end);
|
|
4892
4915
|
break;
|
|
4893
|
-
case
|
|
4916
|
+
case AnalyticsGranularity.Hourly:
|
|
4894
4917
|
result = _nextHourlyPeriod(current, range.end);
|
|
4895
4918
|
}
|
|
4896
4919
|
if (result === null) {
|
|
@@ -5297,7 +5320,7 @@ class AnalyticsQueryEngine {
|
|
|
5297
5320
|
};
|
|
5298
5321
|
const inputExecute = await this.execute(inputsQuery);
|
|
5299
5322
|
const operandExecute = await this.execute(operandQuery);
|
|
5300
|
-
if ([
|
|
5323
|
+
if ([CompoundOperator.VectorAdd, CompoundOperator.VectorSubtract].includes(query.expression.operator)) {
|
|
5301
5324
|
result = await this._profiler.record("ApplyVectorOperator", async () => await this._applyVectorOperator(inputExecute, operandExecute, query.expression.operator, query.expression.resultCurrency));
|
|
5302
5325
|
} else {
|
|
5303
5326
|
result = await this._profiler.record("ApplyScalarOperator", async () => await this._applyScalarOperator(inputExecute, operandExecute, query.expression.operator, query.expression.operand.useSum, query.expression.resultCurrency));
|
|
@@ -5329,7 +5352,7 @@ class AnalyticsQueryEngine {
|
|
|
5329
5352
|
metrics: baseQuery.metrics,
|
|
5330
5353
|
currency: conversion.currency
|
|
5331
5354
|
},
|
|
5332
|
-
operator:
|
|
5355
|
+
operator: CompoundOperator.ScalarMultiply,
|
|
5333
5356
|
operand: {
|
|
5334
5357
|
metric: conversion.metric,
|
|
5335
5358
|
currency: mcc.targetCurrency,
|
|
@@ -5339,18 +5362,18 @@ class AnalyticsQueryEngine {
|
|
|
5339
5362
|
}
|
|
5340
5363
|
};
|
|
5341
5364
|
const executedCompound = await this.executeCompound(nextQuery);
|
|
5342
|
-
result = await this._applyVectorOperator(result, executedCompound,
|
|
5365
|
+
result = await this._applyVectorOperator(result, executedCompound, CompoundOperator.VectorAdd, mcc.targetCurrency);
|
|
5343
5366
|
}
|
|
5344
5367
|
return result;
|
|
5345
5368
|
}
|
|
5346
5369
|
async _applyVectorOperator(inputsA, inputsB, operator, resultCurrency) {
|
|
5347
|
-
if ([
|
|
5370
|
+
if ([CompoundOperator.ScalarMultiply, CompoundOperator.ScalarDivide].includes(operator)) {
|
|
5348
5371
|
throw new Error("Invalid operator for vector operation");
|
|
5349
5372
|
}
|
|
5350
5373
|
return inputsB;
|
|
5351
5374
|
}
|
|
5352
5375
|
async _applyScalarOperator(inputs, operand, operator, useOperandSum, resultCurrency) {
|
|
5353
|
-
if ([
|
|
5376
|
+
if ([CompoundOperator.VectorAdd, CompoundOperator.VectorSubtract].includes(operator)) {
|
|
5354
5377
|
throw new Error("Invalid operator for scalar operation");
|
|
5355
5378
|
}
|
|
5356
5379
|
const result = [];
|
|
@@ -5383,13 +5406,13 @@ class AnalyticsQueryEngine {
|
|
|
5383
5406
|
}
|
|
5384
5407
|
_calculateOutputValue(input, operator, operand) {
|
|
5385
5408
|
switch (operator) {
|
|
5386
|
-
case
|
|
5409
|
+
case CompoundOperator.VectorAdd:
|
|
5387
5410
|
return input + operand;
|
|
5388
|
-
case
|
|
5411
|
+
case CompoundOperator.VectorSubtract:
|
|
5389
5412
|
return input - operand;
|
|
5390
|
-
case
|
|
5413
|
+
case CompoundOperator.ScalarMultiply:
|
|
5391
5414
|
return input * operand;
|
|
5392
|
-
case
|
|
5415
|
+
case CompoundOperator.ScalarDivide:
|
|
5393
5416
|
return input / operand;
|
|
5394
5417
|
}
|
|
5395
5418
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/analytics-engine-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "6.0.0-dev.65",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/powerhouse-inc/
|
|
7
|
+
"url": "https://github.com/powerhouse-inc/powerhouse"
|
|
8
8
|
},
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/src/index.d.ts",
|
|
16
|
-
"
|
|
16
|
+
"import": "./dist/src/index.js"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
@@ -25,11 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/luxon": "3.7.1",
|
|
28
|
-
"vitest": "
|
|
28
|
+
"vitest": "3.2.4"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"
|
|
32
|
-
"bundle": "bun run ./bundle.ts",
|
|
31
|
+
"build:bundle": "bun run ./bundle.ts",
|
|
33
32
|
"test": "vitest --run ./**/*.test.ts"
|
|
34
33
|
}
|
|
35
34
|
}
|