@powerhousedao/analytics-engine-core 0.5.0 → 0.6.2
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 +661 -0
- package/build/index.js +5556 -0
- package/build/index.js.map +18 -0
- package/package.json +25 -18
- package/dist/AnalyticsDiscretizer.d.ts +0 -58
- package/dist/AnalyticsDiscretizer.js +0 -236
- package/dist/AnalyticsDiscretizer.js.map +0 -1
- package/dist/AnalyticsPath.d.ts +0 -35
- package/dist/AnalyticsPath.js +0 -166
- package/dist/AnalyticsPath.js.map +0 -1
- package/dist/AnalyticsPeriod.d.ts +0 -48
- package/dist/AnalyticsPeriod.js +0 -214
- package/dist/AnalyticsPeriod.js.map +0 -1
- package/dist/AnalyticsProfiler.d.ts +0 -30
- package/dist/AnalyticsProfiler.js +0 -76
- package/dist/AnalyticsProfiler.js.map +0 -1
- package/dist/AnalyticsQuery.d.ts +0 -85
- package/dist/AnalyticsQuery.js +0 -28
- package/dist/AnalyticsQuery.js.map +0 -1
- package/dist/AnalyticsQueryEngine.d.ts +0 -19
- package/dist/AnalyticsQueryEngine.js +0 -173
- package/dist/AnalyticsQueryEngine.js.map +0 -1
- package/dist/AnalyticsQueryResult.d.ts +0 -9
- package/dist/AnalyticsQueryResult.js +0 -2
- package/dist/AnalyticsQueryResult.js.map +0 -1
- package/dist/AnalyticsSubscriptionManager.d.ts +0 -47
- package/dist/AnalyticsSubscriptionManager.js +0 -161
- package/dist/AnalyticsSubscriptionManager.js.map +0 -1
- package/dist/AnalyticsTimeSlicer.d.ts +0 -28
- package/dist/AnalyticsTimeSlicer.js +0 -212
- package/dist/AnalyticsTimeSlicer.js.map +0 -1
- package/dist/IAnalyticsCache.d.ts +0 -6
- package/dist/IAnalyticsCache.js +0 -2
- package/dist/IAnalyticsCache.js.map +0 -1
- package/dist/IAnalyticsStore.d.ts +0 -25
- package/dist/IAnalyticsStore.js +0 -2
- package/dist/IAnalyticsStore.js.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AnalyticsPath } from "./AnalyticsPath.js";
|
|
2
|
-
import { AnalyticsPeriod } from "./AnalyticsPeriod.js";
|
|
3
|
-
export type AnalyticsQueryResultRow = {
|
|
4
|
-
period: AnalyticsPeriod;
|
|
5
|
-
dimensions: Record<string, AnalyticsPath>;
|
|
6
|
-
currency: string;
|
|
7
|
-
value: number;
|
|
8
|
-
};
|
|
9
|
-
export type AnalyticsQueryResult = Array<AnalyticsQueryResultRow>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsQueryResult.js","sourceRoot":"","sources":["../src/AnalyticsQueryResult.ts"],"names":[],"mappings":""}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { AnalyticsPath } from "./AnalyticsPath.js";
|
|
2
|
-
import { AnalyticsUpdateCallback } from "./IAnalyticsStore.js";
|
|
3
|
-
export declare class NotificationError extends Error {
|
|
4
|
-
readonly innerErrors: Error[];
|
|
5
|
-
constructor(errors: Error[]);
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Manages subscriptions for analytics paths.
|
|
9
|
-
*/
|
|
10
|
-
export declare class AnalyticsSubscriptionManager {
|
|
11
|
-
private _subscriptions;
|
|
12
|
-
/**
|
|
13
|
-
* Subscribe to updates for an analytics path. A subscribed function will be
|
|
14
|
-
* called for:
|
|
15
|
-
*
|
|
16
|
-
* - exact path matches
|
|
17
|
-
* - matching child paths (i.e. an update to /a/b/c will trigger a callback
|
|
18
|
-
* for /a/b/c, /a/b, and /a)
|
|
19
|
-
* - wildcard matches
|
|
20
|
-
*
|
|
21
|
-
* @param path The analytics path to subscribe to.
|
|
22
|
-
* @param callback Function to be called when the path is updated.
|
|
23
|
-
*
|
|
24
|
-
* @returns A function that, when called, unsubscribes from the updates.
|
|
25
|
-
*/
|
|
26
|
-
subscribeToPath(path: AnalyticsPath, callback: AnalyticsUpdateCallback): () => void;
|
|
27
|
-
/**
|
|
28
|
-
* Notifies subscribers about updates to paths.
|
|
29
|
-
*
|
|
30
|
-
* @param paths The paths that were updated.
|
|
31
|
-
*/
|
|
32
|
-
notifySubscribers(paths: AnalyticsPath[]): void;
|
|
33
|
-
/**
|
|
34
|
-
* Normalizes a path string to ensure consistent comparison.
|
|
35
|
-
*/
|
|
36
|
-
private normalizePath;
|
|
37
|
-
/**
|
|
38
|
-
* Checks if a path matches a subscription pattern that may contain wildcards.
|
|
39
|
-
*/
|
|
40
|
-
private pathMatchesWildcardPattern;
|
|
41
|
-
/**
|
|
42
|
-
* Gets all path prefixes for a given path.
|
|
43
|
-
*
|
|
44
|
-
* For example, for '/a/b/c' it returns ['/a', '/a/b', '/a/b/c'].
|
|
45
|
-
*/
|
|
46
|
-
private getPathPrefixes;
|
|
47
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
export class NotificationError extends Error {
|
|
2
|
-
innerErrors;
|
|
3
|
-
constructor(errors) {
|
|
4
|
-
super(errors.map((e) => e.message).join("\n"));
|
|
5
|
-
this.name = "NotificationError";
|
|
6
|
-
this.innerErrors = errors;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Manages subscriptions for analytics paths.
|
|
11
|
-
*/
|
|
12
|
-
export class AnalyticsSubscriptionManager {
|
|
13
|
-
_subscriptions = new Map();
|
|
14
|
-
/**
|
|
15
|
-
* Subscribe to updates for an analytics path. A subscribed function will be
|
|
16
|
-
* called for:
|
|
17
|
-
*
|
|
18
|
-
* - exact path matches
|
|
19
|
-
* - matching child paths (i.e. an update to /a/b/c will trigger a callback
|
|
20
|
-
* for /a/b/c, /a/b, and /a)
|
|
21
|
-
* - wildcard matches
|
|
22
|
-
*
|
|
23
|
-
* @param path The analytics path to subscribe to.
|
|
24
|
-
* @param callback Function to be called when the path is updated.
|
|
25
|
-
*
|
|
26
|
-
* @returns A function that, when called, unsubscribes from the updates.
|
|
27
|
-
*/
|
|
28
|
-
subscribeToPath(path, callback) {
|
|
29
|
-
const pathString = this.normalizePath(path.toString("/"));
|
|
30
|
-
if (!this._subscriptions.has(pathString)) {
|
|
31
|
-
this._subscriptions.set(pathString, new Set());
|
|
32
|
-
}
|
|
33
|
-
this._subscriptions.get(pathString).add(callback);
|
|
34
|
-
return () => {
|
|
35
|
-
const callbacks = this._subscriptions.get(pathString);
|
|
36
|
-
if (callbacks) {
|
|
37
|
-
callbacks.delete(callback);
|
|
38
|
-
// only remove the path entry if there are no more callbacks
|
|
39
|
-
if (callbacks.size === 0) {
|
|
40
|
-
this._subscriptions.delete(pathString);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Notifies subscribers about updates to paths.
|
|
47
|
-
*
|
|
48
|
-
* @param paths The paths that were updated.
|
|
49
|
-
*/
|
|
50
|
-
notifySubscribers(paths) {
|
|
51
|
-
if (paths.length === 0 || this._subscriptions.size === 0) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const errors = [];
|
|
55
|
-
for (const path of paths) {
|
|
56
|
-
const pathString = this.normalizePath(path.toString("/"));
|
|
57
|
-
const pathPrefixes = this.getPathPrefixes(pathString);
|
|
58
|
-
const matchingSubscriptions = [];
|
|
59
|
-
// add the exact prefix matches
|
|
60
|
-
pathPrefixes
|
|
61
|
-
.filter((prefix) => this._subscriptions.has(prefix))
|
|
62
|
-
.forEach((prefix) => {
|
|
63
|
-
matchingSubscriptions.push({
|
|
64
|
-
prefix,
|
|
65
|
-
callbacks: this._subscriptions.get(prefix),
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
// check all wildcard patterns
|
|
69
|
-
for (const [subscriptionPath, callbacks,] of this._subscriptions.entries()) {
|
|
70
|
-
// skip if it's already in the exact matches
|
|
71
|
-
if (pathPrefixes.includes(subscriptionPath)) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
// hceck if this subscription path (which might have wildcards) matches the update path
|
|
75
|
-
if (this.pathMatchesWildcardPattern(pathString, subscriptionPath)) {
|
|
76
|
-
matchingSubscriptions.push({
|
|
77
|
-
prefix: subscriptionPath,
|
|
78
|
-
callbacks,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (matchingSubscriptions.length === 0)
|
|
83
|
-
continue;
|
|
84
|
-
// guarantee delivery to all subscribers
|
|
85
|
-
for (const { callbacks } of matchingSubscriptions) {
|
|
86
|
-
for (const callback of callbacks) {
|
|
87
|
-
try {
|
|
88
|
-
callback(path);
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
errors.push(e);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (errors.length > 0) {
|
|
97
|
-
throw new NotificationError(errors);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Normalizes a path string to ensure consistent comparison.
|
|
102
|
-
*/
|
|
103
|
-
normalizePath(path) {
|
|
104
|
-
// Handle potential double slashes by first splitting on slashes and rejoining
|
|
105
|
-
const parts = path.split("/").filter((p) => p.length > 0);
|
|
106
|
-
let normalized = "/" + parts.join("/");
|
|
107
|
-
return normalized;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Checks if a path matches a subscription pattern that may contain wildcards.
|
|
111
|
-
*/
|
|
112
|
-
pathMatchesWildcardPattern(updatePath, subscriptionPath) {
|
|
113
|
-
// Handle the wildcard segment case
|
|
114
|
-
if (subscriptionPath.includes("*")) {
|
|
115
|
-
const updateSegments = updatePath.split("/").filter((s) => s.length > 0);
|
|
116
|
-
const subscriptionSegments = subscriptionPath
|
|
117
|
-
.split("/")
|
|
118
|
-
.filter((s) => s.length > 0);
|
|
119
|
-
// If subscription is longer than the update path, it can't match
|
|
120
|
-
if (subscriptionSegments.length > updateSegments.length) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
// Compare each segment
|
|
124
|
-
for (let i = 0; i < subscriptionSegments.length; i++) {
|
|
125
|
-
const subSegment = subscriptionSegments[i];
|
|
126
|
-
const updateSegment = updateSegments[i];
|
|
127
|
-
// If segment is * or starts with * (wildcard), it matches anything
|
|
128
|
-
if (subSegment === "*" || subSegment.startsWith("*:")) {
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
// Otherwise, segments should match exactly
|
|
132
|
-
if (subSegment !== updateSegment) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
// If no wildcards, check if subscription is a prefix of the update path
|
|
139
|
-
return (updatePath === subscriptionPath ||
|
|
140
|
-
updatePath.startsWith(subscriptionPath + "/"));
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Gets all path prefixes for a given path.
|
|
144
|
-
*
|
|
145
|
-
* For example, for '/a/b/c' it returns ['/a', '/a/b', '/a/b/c'].
|
|
146
|
-
*/
|
|
147
|
-
getPathPrefixes(path) {
|
|
148
|
-
const segments = path.split("/").filter((s) => s.length > 0);
|
|
149
|
-
const prefixes = [];
|
|
150
|
-
let currentPath = "";
|
|
151
|
-
for (const segment of segments) {
|
|
152
|
-
currentPath = currentPath ? `${currentPath}/${segment}` : `/${segment}`;
|
|
153
|
-
prefixes.push(currentPath);
|
|
154
|
-
}
|
|
155
|
-
if (prefixes.length === 0 && path === "/") {
|
|
156
|
-
prefixes.push("/");
|
|
157
|
-
}
|
|
158
|
-
return prefixes;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
//# sourceMappingURL=AnalyticsSubscriptionManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsSubscriptionManager.js","sourceRoot":"","sources":["../src/AnalyticsSubscriptionManager.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,iBAAkB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C,MAAM,KAAK,CAAC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAC1C,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { DateTime } from "luxon";
|
|
2
|
-
import { AnalyticsGranularity } from "./AnalyticsQuery.js";
|
|
3
|
-
export type AnalyticsRange = {
|
|
4
|
-
start: DateTime;
|
|
5
|
-
end: DateTime;
|
|
6
|
-
granularity: AnalyticsGranularity;
|
|
7
|
-
};
|
|
8
|
-
export type AnalyticsPeriod = {
|
|
9
|
-
period: string;
|
|
10
|
-
start: DateTime;
|
|
11
|
-
end: DateTime;
|
|
12
|
-
};
|
|
13
|
-
interface AnalyticsPeriodSeries {
|
|
14
|
-
start: DateTime;
|
|
15
|
-
end: DateTime;
|
|
16
|
-
granularity: AnalyticsGranularity;
|
|
17
|
-
next(): AnalyticsPeriod | null;
|
|
18
|
-
}
|
|
19
|
-
export declare const getPeriodSeriesArray: (range: AnalyticsRange) => AnalyticsPeriod[];
|
|
20
|
-
export declare const getPeriodSeries: (range: AnalyticsRange) => AnalyticsPeriodSeries;
|
|
21
|
-
export declare const _nextAnnualPeriod: (nextStart: DateTime, seriesEnd: DateTime) => AnalyticsPeriod | null;
|
|
22
|
-
export declare const _nextSemiAnnualPeriod: (nextStart: DateTime, seriesEnd: DateTime) => AnalyticsPeriod | null;
|
|
23
|
-
export declare const _nextQuarterlyPeriod: (nextStart: DateTime, seriesEnd: DateTime) => AnalyticsPeriod | null;
|
|
24
|
-
export declare const _nextMonthlyPeriod: (nextStart: DateTime, seriesEnd: DateTime) => AnalyticsPeriod | null;
|
|
25
|
-
export declare const _nextWeeklyPeriod: (nextStart: DateTime, seriesEnd: DateTime) => AnalyticsPeriod | null;
|
|
26
|
-
export declare const _nextDailyPeriod: (nextStart: DateTime, seriesEnd: DateTime) => AnalyticsPeriod | null;
|
|
27
|
-
export declare const _nextHourlyPeriod: (nextStart: DateTime, seriesEnd: DateTime) => AnalyticsPeriod | null;
|
|
28
|
-
export {};
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { DateTime } from "luxon";
|
|
2
|
-
import { AnalyticsGranularity } from "./AnalyticsQuery.js";
|
|
3
|
-
export const getPeriodSeriesArray = (range) => {
|
|
4
|
-
const result = [];
|
|
5
|
-
const series = getPeriodSeries(range);
|
|
6
|
-
let next = series.next();
|
|
7
|
-
while (next) {
|
|
8
|
-
result.push(next);
|
|
9
|
-
next = series.next();
|
|
10
|
-
}
|
|
11
|
-
return result;
|
|
12
|
-
};
|
|
13
|
-
export const getPeriodSeries = (range) => {
|
|
14
|
-
return {
|
|
15
|
-
...range,
|
|
16
|
-
next: _createFactoryFn(range),
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
const _createFactoryFn = (range) => {
|
|
20
|
-
let current = range.start;
|
|
21
|
-
return () => {
|
|
22
|
-
if (current == null) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
let result = null;
|
|
26
|
-
switch (range.granularity) {
|
|
27
|
-
case AnalyticsGranularity.Total:
|
|
28
|
-
result = _nextTotalPeriod(current, range.end);
|
|
29
|
-
break;
|
|
30
|
-
case AnalyticsGranularity.Annual:
|
|
31
|
-
result = _nextAnnualPeriod(current, range.end);
|
|
32
|
-
break;
|
|
33
|
-
case AnalyticsGranularity.SemiAnnual:
|
|
34
|
-
result = _nextSemiAnnualPeriod(current, range.end);
|
|
35
|
-
break;
|
|
36
|
-
case AnalyticsGranularity.Quarterly:
|
|
37
|
-
result = _nextQuarterlyPeriod(current, range.end);
|
|
38
|
-
break;
|
|
39
|
-
case AnalyticsGranularity.Monthly:
|
|
40
|
-
result = _nextMonthlyPeriod(current, range.end);
|
|
41
|
-
break;
|
|
42
|
-
case AnalyticsGranularity.Weekly:
|
|
43
|
-
result = _nextWeeklyPeriod(current, range.end);
|
|
44
|
-
break;
|
|
45
|
-
case AnalyticsGranularity.Daily:
|
|
46
|
-
result = _nextDailyPeriod(current, range.end);
|
|
47
|
-
break;
|
|
48
|
-
case AnalyticsGranularity.Hourly:
|
|
49
|
-
result = _nextHourlyPeriod(current, range.end);
|
|
50
|
-
}
|
|
51
|
-
// Update current to start of next period
|
|
52
|
-
if (result === null) {
|
|
53
|
-
current = null;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
current = result.end.plus({ milliseconds: 1 });
|
|
57
|
-
}
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
const _nextTotalPeriod = (nextStart, seriesEnd) => {
|
|
62
|
-
if (seriesEnd <= nextStart) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
period: "total",
|
|
67
|
-
start: nextStart,
|
|
68
|
-
end: seriesEnd,
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
export const _nextAnnualPeriod = (nextStart, seriesEnd) => {
|
|
72
|
-
if (seriesEnd <= nextStart) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const inputUtc = nextStart.toUTC();
|
|
76
|
-
const oneYearLater = DateTime.utc(inputUtc.year, inputUtc.month, inputUtc.day).plus({ years: 1 });
|
|
77
|
-
return {
|
|
78
|
-
period: "annual",
|
|
79
|
-
start: nextStart,
|
|
80
|
-
end: oneYearLater,
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
export const _nextSemiAnnualPeriod = (nextStart, seriesEnd) => {
|
|
84
|
-
if (seriesEnd <= nextStart) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
const midYear = DateTime.utc(nextStart.year, 7, 1);
|
|
88
|
-
const endYear = DateTime.utc(nextStart.year, 12, 31, 23, 59, 59, 999);
|
|
89
|
-
let endDate;
|
|
90
|
-
if (midYear > nextStart) {
|
|
91
|
-
endDate = midYear;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
endDate = endYear;
|
|
95
|
-
}
|
|
96
|
-
if (endDate > seriesEnd) {
|
|
97
|
-
endDate = seriesEnd;
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
period: "semiAnnual",
|
|
101
|
-
start: nextStart,
|
|
102
|
-
end: endDate,
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
export const _nextQuarterlyPeriod = (nextStart, seriesEnd) => {
|
|
106
|
-
if (seriesEnd <= nextStart) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
let endDate;
|
|
110
|
-
const nextStartUtc = nextStart.toUTC();
|
|
111
|
-
const startMonth = nextStartUtc.month;
|
|
112
|
-
if (startMonth < 3) {
|
|
113
|
-
endDate = DateTime.utc(nextStartUtc.year, 4, 1);
|
|
114
|
-
}
|
|
115
|
-
else if (startMonth < 6) {
|
|
116
|
-
endDate = DateTime.utc(nextStartUtc.year, 7, 1);
|
|
117
|
-
}
|
|
118
|
-
else if (startMonth < 9) {
|
|
119
|
-
endDate = DateTime.utc(nextStartUtc.year, 10, 1);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
endDate = DateTime.utc(nextStartUtc.year, 12, 31, 23, 59, 59, 999);
|
|
123
|
-
}
|
|
124
|
-
if (endDate > seriesEnd) {
|
|
125
|
-
endDate = seriesEnd;
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
period: "quarterly",
|
|
129
|
-
start: nextStart,
|
|
130
|
-
end: endDate,
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
export const _nextMonthlyPeriod = (nextStart, seriesEnd) => {
|
|
134
|
-
if (seriesEnd <= nextStart) {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
// Get the first day of the next month
|
|
138
|
-
const nextStartUtc = nextStart.toUTC();
|
|
139
|
-
let endDate = DateTime.utc(nextStartUtc.year, nextStartUtc.month, nextStartUtc.day)
|
|
140
|
-
.plus({ months: 1 })
|
|
141
|
-
.startOf("month");
|
|
142
|
-
// If the end date is after the series end, then use the series end as the end date
|
|
143
|
-
if (endDate > seriesEnd) {
|
|
144
|
-
if (!nextStart.hasSame(seriesEnd, "month")) {
|
|
145
|
-
endDate = seriesEnd;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// Otherwise, return the end date as the first day of the next month
|
|
149
|
-
return {
|
|
150
|
-
period: "monthly",
|
|
151
|
-
start: nextStart,
|
|
152
|
-
end: endDate,
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
export const _nextWeeklyPeriod = (nextStart, seriesEnd) => {
|
|
156
|
-
if (seriesEnd <= nextStart) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
// Calculate the start of the next week (Monday)
|
|
160
|
-
const nextStartUtc = nextStart.toUTC();
|
|
161
|
-
const nextWeekStartUTC = DateTime.utc(nextStartUtc.year, nextStartUtc.month, nextStartUtc.day)
|
|
162
|
-
.plus({ weeks: 1 })
|
|
163
|
-
.startOf("week");
|
|
164
|
-
// If the calculated next week start is later or equal to the series end date, return the series end
|
|
165
|
-
if (nextWeekStartUTC > seriesEnd)
|
|
166
|
-
if (!nextWeekStartUTC.hasSame(seriesEnd, "day")) {
|
|
167
|
-
return {
|
|
168
|
-
period: "weekly",
|
|
169
|
-
start: nextStart,
|
|
170
|
-
end: seriesEnd,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
return {
|
|
174
|
-
period: "weekly",
|
|
175
|
-
start: nextStart,
|
|
176
|
-
end: nextWeekStartUTC,
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
export const _nextDailyPeriod = (nextStart, seriesEnd) => {
|
|
180
|
-
if (seriesEnd <= nextStart) {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
// Set the end date to the start of the next day
|
|
184
|
-
const nextStartUtc = nextStart.toUTC();
|
|
185
|
-
let endDate = nextStartUtc.plus({ days: 1 }).startOf("day");
|
|
186
|
-
if (endDate > seriesEnd || endDate.hasSame(seriesEnd, "day")) {
|
|
187
|
-
endDate = seriesEnd;
|
|
188
|
-
}
|
|
189
|
-
return {
|
|
190
|
-
period: "daily",
|
|
191
|
-
start: nextStart,
|
|
192
|
-
end: endDate,
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
export const _nextHourlyPeriod = (nextStart, seriesEnd) => {
|
|
196
|
-
if (seriesEnd <= nextStart) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
const startDate = nextStart.toUTC();
|
|
200
|
-
let endDate = startDate.plus({ hours: 1 });
|
|
201
|
-
if (endDate > seriesEnd) {
|
|
202
|
-
if (nextStart.hour !== seriesEnd.hour) {
|
|
203
|
-
endDate = seriesEnd.toUTC();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
period: "hourly",
|
|
208
|
-
start: nextStart,
|
|
209
|
-
end: endDate,
|
|
210
|
-
};
|
|
211
|
-
};
|
|
212
|
-
//# sourceMappingURL=AnalyticsTimeSlicer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsTimeSlicer.js","sourceRoot":"","sources":["../src/AnalyticsTimeSlicer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAqB3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,KAAqB,EACF,EAAE;IACrB,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAEtC,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IACzB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,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AAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5D,IAAI,OAAO,GAAG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QAC7D,OAAO,GAAG,SAAS,CAAC;IACtB,CAAC;IAED,OAAO;QACL,MAAM,EAAE,OAAO;QACf,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,OAAO;KACb,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,SAAmB,EACnB,SAAmB,EACK,EAAE;IAC1B,IAAI,SAAS,IAAI,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC;IACpC,IAAI,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAE3C,IAAI,OAAO,GAAG,SAAS,EAAE,CAAC;QACxB,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC;YACtC,OAAO,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,OAAO;KACb,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { GroupedPeriodResults } from "./AnalyticsDiscretizer";
|
|
2
|
-
import { AnalyticsQuery } from "./AnalyticsQuery";
|
|
3
|
-
export interface IAnalyticsCache {
|
|
4
|
-
get(query: AnalyticsQuery): Promise<GroupedPeriodResults | null>;
|
|
5
|
-
set(query: AnalyticsQuery, expirySecs?: number): void;
|
|
6
|
-
}
|
package/dist/IAnalyticsCache.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAnalyticsCache.js","sourceRoot":"","sources":["../src/IAnalyticsCache.ts"],"names":[],"mappings":""}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DateTime } from "luxon";
|
|
2
|
-
import { AnalyticsPath } from "./AnalyticsPath.js";
|
|
3
|
-
import { 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
|
-
}
|
package/dist/IAnalyticsStore.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAnalyticsStore.js","sourceRoot":"","sources":["../src/IAnalyticsStore.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type { IAnalyticsProfiler } from "./AnalyticsProfiler.js";
|
|
2
|
-
export { AnalyticsProfiler, PassthroughAnalyticsProfiler, } from "./AnalyticsProfiler.js";
|
|
3
|
-
export type { IAnalyticsStore, AnalyticsSeriesInput, AnalyticsUpdateCallback, } from "./IAnalyticsStore.js";
|
|
4
|
-
export { AnalyticsPath, AnalyticsPathSegment } from "./AnalyticsPath.js";
|
|
5
|
-
export type { AnalyticsQuery, AnalyticsSeriesQuery, AnalyticsSeries, AnalyticsDimension, } from "./AnalyticsQuery.js";
|
|
6
|
-
export { AnalyticsGranularity } from "./AnalyticsQuery.js";
|
|
7
|
-
export { AnalyticsQueryEngine } from "./AnalyticsQueryEngine.js";
|
|
8
|
-
export type { GroupedPeriodResult, GroupedPeriodResults, } from "./AnalyticsDiscretizer.js";
|
|
9
|
-
export { AnalyticsSerializerTypes, AnalyticsPeriod, } from "./AnalyticsPeriod.js";
|
|
10
|
-
export * from "./AnalyticsSubscriptionManager.js";
|
package/dist/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { AnalyticsProfiler, PassthroughAnalyticsProfiler, } from "./AnalyticsProfiler.js";
|
|
2
|
-
export { AnalyticsPath, AnalyticsPathSegment } from "./AnalyticsPath.js";
|
|
3
|
-
export { AnalyticsGranularity } from "./AnalyticsQuery.js";
|
|
4
|
-
export { AnalyticsQueryEngine } from "./AnalyticsQueryEngine.js";
|
|
5
|
-
export { AnalyticsSerializerTypes, AnalyticsPeriod, } from "./AnalyticsPeriod.js";
|
|
6
|
-
export * from "./AnalyticsSubscriptionManager.js";
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAOzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAKjE,OAAO,EACL,wBAAwB,EACxB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,cAAc,mCAAmC,CAAC"}
|