clarion-shared-types 1.0.132 → 1.0.133

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.
Files changed (33) hide show
  1. package/dist/cjs/index.js +1 -0
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/modules/analytics/analytics-country.js +83 -0
  4. package/dist/cjs/modules/analytics/analytics-country.js.map +1 -0
  5. package/dist/cjs/modules/analytics/index.js +18 -0
  6. package/dist/cjs/modules/analytics/index.js.map +1 -0
  7. package/dist/cjs/modules/incident-sla/interfaces/incident-sla.dto.js.map +1 -1
  8. package/dist/esm/index.js +1 -0
  9. package/dist/esm/index.js.map +1 -1
  10. package/dist/esm/modules/analytics/analytics-country.js +74 -0
  11. package/dist/esm/modules/analytics/analytics-country.js.map +1 -0
  12. package/dist/esm/modules/analytics/index.js +2 -0
  13. package/dist/esm/modules/analytics/index.js.map +1 -0
  14. package/dist/esm/modules/incident-sla/interfaces/incident-sla.dto.js.map +1 -1
  15. package/dist/types/index.d.ts +1 -0
  16. package/dist/types/modules/alert-intake/interfaces/alert-intake-analytics.d.ts +9 -0
  17. package/dist/types/modules/analytics/analytics-country.d.ts +61 -0
  18. package/dist/types/modules/analytics/index.d.ts +1 -0
  19. package/dist/types/modules/billing/interfaces/billing-analytics.d.ts +41 -1
  20. package/dist/types/modules/chat/interfaces/chat-analytics.d.ts +5 -0
  21. package/dist/types/modules/dispatch/interfaces/dispatch-analytics.d.ts +7 -0
  22. package/dist/types/modules/gis/interfaces/zone-analytics.d.ts +7 -0
  23. package/dist/types/modules/incident/intefaces/incident-dashboard-analytics.d.ts +9 -0
  24. package/dist/types/modules/incident-sla/interfaces/incident-sla.dto.d.ts +9 -0
  25. package/dist/types/modules/newsfeed/interfaces/newsfeed-analytics.d.ts +5 -0
  26. package/dist/types/modules/notification/interfaces/notification-analytics.d.ts +5 -0
  27. package/dist/types/modules/organization/interfaces/organization-analytics.d.ts +9 -0
  28. package/dist/types/modules/partner/interfaces/partner-analytics.d.ts +9 -0
  29. package/dist/types/modules/safety/interfaces/safety-analytics.d.ts +9 -0
  30. package/dist/types/modules/support/interfaces/support-analytics.d.ts +5 -0
  31. package/dist/types/modules/tracking/interfaces/tracking-analytics.d.ts +9 -0
  32. package/dist/types/modules/user/interfaces/account-analytics.d.ts +9 -0
  33. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -44,6 +44,7 @@ __exportStar(require("./modules/billing/index"), exports);
44
44
  __exportStar(require("./modules/newsfeed/index"), exports);
45
45
  __exportStar(require("./modules/dispatch/index"), exports);
46
46
  __exportStar(require("./modules/incident-sla/index"), exports);
47
+ __exportStar(require("./modules/analytics/index"), exports);
47
48
  __exportStar(require("./modules/responder/index"), exports);
48
49
  // Interfaces
49
50
  __exportStar(require("./modules/common/interfaces/server-message"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,uDAAqC;AACrC,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC;AACvC,mEAAiD;AACjD,+DAA6C;AAC7C,uDAAqC;AACrC,0DAAwC;AACxC,2DAAyC;AACzC,8DAA4C;AAC5C,iEAA+C;AAC/C,+DAA6C;AAC7C,0DAAwC;AACxC,0DAAwC;AACxC,yDAAuC;AACvC,0DAAwC;AACxC,2DAAyC;AACzC,2DAAyC;AACzC,+DAA6C;AAC7C,4DAA0C;AAE1C,aAAa;AACb,6EAA2D;AAC3D,yEAAuD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,uDAAqC;AACrC,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC;AACvC,mEAAiD;AACjD,+DAA6C;AAC7C,uDAAqC;AACrC,0DAAwC;AACxC,2DAAyC;AACzC,8DAA4C;AAC5C,iEAA+C;AAC/C,+DAA6C;AAC7C,0DAAwC;AACxC,0DAAwC;AACxC,yDAAuC;AACvC,0DAAwC;AACxC,2DAAyC;AACzC,2DAAyC;AACzC,+DAA6C;AAC7C,4DAA0C;AAC1C,4DAA0C;AAE1C,aAAa;AACb,6EAA2D;AAC3D,yEAAuD"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLATFORM_ANALYTICS_TIME_ZONE = exports.UNKNOWN_COUNTRY = void 0;
4
+ exports.analyticsCountryKey = analyticsCountryKey;
5
+ exports.analyticsCountryFilter = analyticsCountryFilter;
6
+ exports.analyticsTimeZone = analyticsTimeZone;
7
+ exports.analyticsLocalTimes = analyticsLocalTimes;
8
+ exports.analyticsCountryOrder = analyticsCountryOrder;
9
+ exports.analyticsCountryRows = analyticsCountryRows;
10
+ const country_defaults_const_1 = require("../country/constants/country-defaults.const");
11
+ const supported_countries_const_1 = require("../country/constants/supported-countries.const");
12
+ /**
13
+ * Analytics in every country, the rules every analytics family follows:
14
+ *
15
+ * - A `countryCode` narrows a read to the records OF that country: each record's own country
16
+ * (an incident's, an account's, a payment's), never the reader's.
17
+ * - A record with no country of its own is counted as `UNKNOWN` - never as Kenya.
18
+ * - With one country, days and hours are cut in that country's zone. With every country, the
19
+ * charts keep one zone (the one asked for, else the platform's), and the hour-of-week grids
20
+ * read each record in its own country's zone: 14:00 in Lusaka counts as 14:00.
21
+ * - `byCountry` splits the period's figures by country, the country filter left out, so a
22
+ * Super-Admin can compare countries side by side.
23
+ */
24
+ /** A record with no country of its own: counted apart, never as Kenya. */
25
+ exports.UNKNOWN_COUNTRY = 'UNKNOWN';
26
+ /** The platform's zone, for a read that names neither a country nor a zone. */
27
+ exports.PLATFORM_ANALYTICS_TIME_ZONE = country_defaults_const_1.DEFAULT_TIMEZONE;
28
+ /** A supported country's code, or `UNKNOWN` for anything else (null, blank, an unsupported code). */
29
+ function analyticsCountryKey(raw) {
30
+ const code = typeof raw === 'string' ? raw.trim().toUpperCase() : '';
31
+ return code in supported_countries_const_1.SUPPORTED_COUNTRIES_BY_CODE ? code : exports.UNKNOWN_COUNTRY;
32
+ }
33
+ /** A supported country's code, or null. */
34
+ function analyticsCountryFilter(raw) {
35
+ const key = analyticsCountryKey(raw);
36
+ return key === exports.UNKNOWN_COUNTRY ? null : key;
37
+ }
38
+ /**
39
+ * The zone a read cuts its days and hours in: the country's own when one is asked for (so a
40
+ * Zambian view reads CAT whoever looks at it), else the zone asked for, else the platform's.
41
+ */
42
+ function analyticsTimeZone(countryCode, asked, fallback = exports.PLATFORM_ANALYTICS_TIME_ZONE) {
43
+ const country = analyticsCountryFilter(countryCode);
44
+ if (country)
45
+ return supported_countries_const_1.SUPPORTED_COUNTRIES_BY_CODE[country].timezone;
46
+ return asked || fallback;
47
+ }
48
+ /** One country: its zone throughout. Every country: each record in its own. */
49
+ function analyticsLocalTimes(countryCode) {
50
+ return analyticsCountryFilter(countryCode) ? 'zone' : 'record';
51
+ }
52
+ /** The order countries are listed in: the platform's order (Kenya, Uganda, Tanzania, Zambia), Unknown last. */
53
+ function analyticsCountryOrder(key) {
54
+ const index = supported_countries_const_1.SUPPORTED_COUNTRIES.findIndex((country) => country.code === key);
55
+ return index >= 0 ? index : supported_countries_const_1.SUPPORTED_COUNTRIES.length;
56
+ }
57
+ /**
58
+ * Rows by country as a family returns them: shares filled in, the largest first, Unknown always
59
+ * last, ties in the platform's order. Rows with nothing at all are left out.
60
+ */
61
+ function analyticsCountryRows(rows) {
62
+ const total = rows.reduce((sum, row) => sum + (Number(row.count) || 0), 0);
63
+ return rows
64
+ .map((row) => {
65
+ var _a;
66
+ const count = Number(row.count) || 0;
67
+ const out = {
68
+ countryCode: analyticsCountryKey(row.countryCode),
69
+ count,
70
+ share: total > 0 ? Math.round((count * 1000) / total) / 10 : null,
71
+ figures: (_a = row.figures) !== null && _a !== void 0 ? _a : {},
72
+ };
73
+ if (row.currency !== undefined)
74
+ out.currency = row.currency;
75
+ return out;
76
+ })
77
+ .filter((row) => row.count > 0 || Object.values(row.figures).some((value) => value !== null && value !== 0))
78
+ .sort((a, b) => {
79
+ const unknown = Number(a.countryCode === exports.UNKNOWN_COUNTRY) - Number(b.countryCode === exports.UNKNOWN_COUNTRY);
80
+ return unknown || b.count - a.count || analyticsCountryOrder(a.countryCode) - analyticsCountryOrder(b.countryCode);
81
+ });
82
+ }
83
+ //# sourceMappingURL=analytics-country.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics-country.js","sourceRoot":"","sources":["../../../../src/modules/analytics/analytics-country.ts"],"names":[],"mappings":";;;AAgDA,kDAGC;AAGD,wDAGC;AAMD,8CAIC;AAGD,kDAEC;AAGD,sDAGC;AAMD,oDAqBC;AAxGD,wFAA+E;AAC/E,8FAAkH;AAElH;;;;;;;;;;;GAWG;AAEH,0EAA0E;AAC7D,QAAA,eAAe,GAAG,SAAS,CAAC;AAWzC,+EAA+E;AAClE,QAAA,4BAA4B,GAAG,yCAAgB,CAAC;AAiB7D,qGAAqG;AACrG,SAAgB,mBAAmB,CAAC,GAAY;IAC5C,MAAM,IAAI,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,OAAO,IAAI,IAAI,uDAA2B,CAAC,CAAC,CAAE,IAAoB,CAAC,CAAC,CAAC,uBAAe,CAAC;AACzF,CAAC;AAED,2CAA2C;AAC3C,SAAgB,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getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./analytics-country"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/analytics/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC"}
@@ -1 +1 @@
1
- {"version":3,"file":"incident-sla.dto.js","sourceRoot":"","sources":["../../../../../src/modules/incident-sla/interfaces/incident-sla.dto.ts"],"names":[],"mappings":";;;AA0rBA,8GAA8G;AACjG,QAAA,0BAA0B,GAAG;IACtC,gBAAgB,EAAE,CAAC;IACnB,gBAAgB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IAChC,mBAAmB,EAAE,EAAE;IACvB,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,EAAE,GAAG,EAAE;IACxB,eAAe,EAAE,EAAE;IACnB,iBAAiB,EAAE,CAAC;IACpB,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,CAAC,GAAG,IAAI;IACzB,mBAAmB,EAAE,EAAE;IACvB,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,GAAG;IAChB,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;IAChB,mBAAmB,EAAE,CAAC,GAAG,EAAE;IAC3B,mBAAmB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IACnC,yBAAyB,EAAE,EAAE,GAAG,IAAI;IACpC,kBAAkB,EAAE,EAAE;IACtB,qBAAqB,EAAE,EAAE;IACzB,mBAAmB,EAAE,GAAG;IACxB,0BAA0B,EAAE,IAAI;IAChC,gBAAgB,EAAE,EAAE;CACd,CAAC"}
1
+ {"version":3,"file":"incident-sla.dto.js","sourceRoot":"","sources":["../../../../../src/modules/incident-sla/interfaces/incident-sla.dto.ts"],"names":[],"mappings":";;;AAmsBA,8GAA8G;AACjG,QAAA,0BAA0B,GAAG;IACtC,gBAAgB,EAAE,CAAC;IACnB,gBAAgB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IAChC,mBAAmB,EAAE,EAAE;IACvB,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,EAAE,GAAG,EAAE;IACxB,eAAe,EAAE,EAAE;IACnB,iBAAiB,EAAE,CAAC;IACpB,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,CAAC,GAAG,IAAI;IACzB,mBAAmB,EAAE,EAAE;IACvB,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,GAAG;IAChB,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;IAChB,mBAAmB,EAAE,CAAC,GAAG,EAAE;IAC3B,mBAAmB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IACnC,yBAAyB,EAAE,EAAE,GAAG,IAAI;IACpC,kBAAkB,EAAE,EAAE;IACtB,qBAAqB,EAAE,EAAE;IACzB,mBAAmB,EAAE,GAAG;IACxB,0BAA0B,EAAE,IAAI;IAChC,gBAAgB,EAAE,EAAE;CACd,CAAC"}
package/dist/esm/index.js CHANGED
@@ -28,6 +28,7 @@ export * from './modules/billing/index';
28
28
  export * from './modules/newsfeed/index';
29
29
  export * from './modules/dispatch/index';
30
30
  export * from './modules/incident-sla/index';
31
+ export * from './modules/analytics/index';
31
32
  export * from './modules/responder/index';
32
33
  // Interfaces
33
34
  export * from './modules/common/interfaces/server-message';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAE1C,aAAa;AACb,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAE1C,aAAa;AACb,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { DEFAULT_TIMEZONE } from '../country/constants/country-defaults.const';
2
+ import { SUPPORTED_COUNTRIES, SUPPORTED_COUNTRIES_BY_CODE } from '../country/constants/supported-countries.const';
3
+ /**
4
+ * Analytics in every country, the rules every analytics family follows:
5
+ *
6
+ * - A `countryCode` narrows a read to the records OF that country: each record's own country
7
+ * (an incident's, an account's, a payment's), never the reader's.
8
+ * - A record with no country of its own is counted as `UNKNOWN` - never as Kenya.
9
+ * - With one country, days and hours are cut in that country's zone. With every country, the
10
+ * charts keep one zone (the one asked for, else the platform's), and the hour-of-week grids
11
+ * read each record in its own country's zone: 14:00 in Lusaka counts as 14:00.
12
+ * - `byCountry` splits the period's figures by country, the country filter left out, so a
13
+ * Super-Admin can compare countries side by side.
14
+ */
15
+ /** A record with no country of its own: counted apart, never as Kenya. */
16
+ export const UNKNOWN_COUNTRY = 'UNKNOWN';
17
+ /** The platform's zone, for a read that names neither a country nor a zone. */
18
+ export const PLATFORM_ANALYTICS_TIME_ZONE = DEFAULT_TIMEZONE;
19
+ /** A supported country's code, or `UNKNOWN` for anything else (null, blank, an unsupported code). */
20
+ export function analyticsCountryKey(raw) {
21
+ const code = typeof raw === 'string' ? raw.trim().toUpperCase() : '';
22
+ return code in SUPPORTED_COUNTRIES_BY_CODE ? code : UNKNOWN_COUNTRY;
23
+ }
24
+ /** A supported country's code, or null. */
25
+ export function analyticsCountryFilter(raw) {
26
+ const key = analyticsCountryKey(raw);
27
+ return key === UNKNOWN_COUNTRY ? null : key;
28
+ }
29
+ /**
30
+ * The zone a read cuts its days and hours in: the country's own when one is asked for (so a
31
+ * Zambian view reads CAT whoever looks at it), else the zone asked for, else the platform's.
32
+ */
33
+ export function analyticsTimeZone(countryCode, asked, fallback = PLATFORM_ANALYTICS_TIME_ZONE) {
34
+ const country = analyticsCountryFilter(countryCode);
35
+ if (country)
36
+ return SUPPORTED_COUNTRIES_BY_CODE[country].timezone;
37
+ return asked || fallback;
38
+ }
39
+ /** One country: its zone throughout. Every country: each record in its own. */
40
+ export function analyticsLocalTimes(countryCode) {
41
+ return analyticsCountryFilter(countryCode) ? 'zone' : 'record';
42
+ }
43
+ /** The order countries are listed in: the platform's order (Kenya, Uganda, Tanzania, Zambia), Unknown last. */
44
+ export function analyticsCountryOrder(key) {
45
+ const index = SUPPORTED_COUNTRIES.findIndex((country) => country.code === key);
46
+ return index >= 0 ? index : SUPPORTED_COUNTRIES.length;
47
+ }
48
+ /**
49
+ * Rows by country as a family returns them: shares filled in, the largest first, Unknown always
50
+ * last, ties in the platform's order. Rows with nothing at all are left out.
51
+ */
52
+ export function analyticsCountryRows(rows) {
53
+ const total = rows.reduce((sum, row) => sum + (Number(row.count) || 0), 0);
54
+ return rows
55
+ .map((row) => {
56
+ var _a;
57
+ const count = Number(row.count) || 0;
58
+ const out = {
59
+ countryCode: analyticsCountryKey(row.countryCode),
60
+ count,
61
+ share: total > 0 ? Math.round((count * 1000) / total) / 10 : null,
62
+ figures: (_a = row.figures) !== null && _a !== void 0 ? _a : {},
63
+ };
64
+ if (row.currency !== undefined)
65
+ out.currency = row.currency;
66
+ return out;
67
+ })
68
+ .filter((row) => row.count > 0 || Object.values(row.figures).some((value) => value !== null && value !== 0))
69
+ .sort((a, b) => {
70
+ const unknown = Number(a.countryCode === UNKNOWN_COUNTRY) - Number(b.countryCode === UNKNOWN_COUNTRY);
71
+ return unknown || b.count - a.count || analyticsCountryOrder(a.countryCode) - analyticsCountryOrder(b.countryCode);
72
+ });
73
+ }
74
+ //# sourceMappingURL=analytics-country.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics-country.js","sourceRoot":"","sources":["../../../../src/modules/analytics/analytics-country.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAElH;;;;;;;;;;;GAWG;AAEH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC;AAWzC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,4BAA4B,GAAG,gBAAgB,CAAC;AAiB7D,qGAAqG;AACrG,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC5C,MAAM,IAAI,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,OAAO,IAAI,IAAI,2BAA2B,CAAC,CAAC,CAAE,IAAoB,CAAC,CAAC,CAAC,eAAe,CAAC;AACzF,CAAC;AAED,2CAA2C;AAC3C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":"index.js","sourceRoot":"","sources":["../../../../src/modules/analytics/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"incident-sla.dto.js","sourceRoot":"","sources":["../../../../../src/modules/incident-sla/interfaces/incident-sla.dto.ts"],"names":[],"mappings":"AA0rBA,8GAA8G;AAC9G,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACtC,gBAAgB,EAAE,CAAC;IACnB,gBAAgB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IAChC,mBAAmB,EAAE,EAAE;IACvB,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,EAAE,GAAG,EAAE;IACxB,eAAe,EAAE,EAAE;IACnB,iBAAiB,EAAE,CAAC;IACpB,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,CAAC,GAAG,IAAI;IACzB,mBAAmB,EAAE,EAAE;IACvB,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,GAAG;IAChB,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;IAChB,mBAAmB,EAAE,CAAC,GAAG,EAAE;IAC3B,mBAAmB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IACnC,yBAAyB,EAAE,EAAE,GAAG,IAAI;IACpC,kBAAkB,EAAE,EAAE;IACtB,qBAAqB,EAAE,EAAE;IACzB,mBAAmB,EAAE,GAAG;IACxB,0BAA0B,EAAE,IAAI;IAChC,gBAAgB,EAAE,EAAE;CACd,CAAC"}
1
+ {"version":3,"file":"incident-sla.dto.js","sourceRoot":"","sources":["../../../../../src/modules/incident-sla/interfaces/incident-sla.dto.ts"],"names":[],"mappings":"AAmsBA,8GAA8G;AAC9G,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACtC,gBAAgB,EAAE,CAAC;IACnB,gBAAgB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IAChC,mBAAmB,EAAE,EAAE;IACvB,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,EAAE,GAAG,EAAE;IACxB,eAAe,EAAE,EAAE;IACnB,iBAAiB,EAAE,CAAC;IACpB,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,CAAC,GAAG,IAAI;IACzB,mBAAmB,EAAE,EAAE;IACvB,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,GAAG;IAChB,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;IAChB,mBAAmB,EAAE,CAAC,GAAG,EAAE;IAC3B,mBAAmB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IACnC,yBAAyB,EAAE,EAAE,GAAG,IAAI;IACpC,kBAAkB,EAAE,EAAE;IACtB,qBAAqB,EAAE,EAAE;IACzB,mBAAmB,EAAE,GAAG;IACxB,0BAA0B,EAAE,IAAI;IAChC,gBAAgB,EAAE,EAAE;CACd,CAAC"}
@@ -27,6 +27,7 @@ export * from './modules/billing/index';
27
27
  export * from './modules/newsfeed/index';
28
28
  export * from './modules/dispatch/index';
29
29
  export * from './modules/incident-sla/index';
30
+ export * from './modules/analytics/index';
30
31
  export * from './modules/responder/index';
31
32
  export * from './modules/common/interfaces/server-message';
32
33
  export * from './modules/common/interfaces/pagination';
@@ -1,4 +1,5 @@
1
1
  import { AlertIntakeChannel, AlertIntakeMessageState, AlertIntakeScreeningReason, AlertIntakeScreeningSource, AlertIntakeScreeningStatus } from '../enums/alert-intake.enum';
2
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
2
3
  /**
3
4
  * Alert intake analytics: what arrived on an organization's channels over a period, what
4
5
  * became of it, what the AI made of it and what that cost. One read, computed by
@@ -238,6 +239,12 @@ export interface AlertIntakeAnalytics {
238
239
  ai: AlertIntakeAnalyticsAi;
239
240
  /** Platform view only. */
240
241
  byOrganization?: AlertIntakeAnalyticsOrganizationRow[];
242
+ /** The country the figures are narrowed to (each record's own country); null for every country. */
243
+ countryCode: string | null;
244
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
245
+ localTimes: AnalyticsLocalTimes;
246
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
247
+ countryComparison: AnalyticsCountryRow[];
241
248
  }
242
249
  /**
243
250
  * The period an analytics read covers (query string). Both ends optional: no `from` is
@@ -247,6 +254,8 @@ export interface AlertIntakeAnalyticsQuery {
247
254
  from?: string;
248
255
  to?: string;
249
256
  timeZone?: string;
257
+ /** One country's records only; its days in that country's zone. */
258
+ countryCode?: string;
250
259
  }
251
260
  /** Platform operators: every organization's analytics, or one organization's. */
252
261
  export interface PlatformAlertIntakeAnalyticsQuery extends AlertIntakeAnalyticsQuery {
@@ -0,0 +1,61 @@
1
+ import { CountryCode } from '../country/enums/country-code.enum';
2
+ /**
3
+ * Analytics in every country, the rules every analytics family follows:
4
+ *
5
+ * - A `countryCode` narrows a read to the records OF that country: each record's own country
6
+ * (an incident's, an account's, a payment's), never the reader's.
7
+ * - A record with no country of its own is counted as `UNKNOWN` - never as Kenya.
8
+ * - With one country, days and hours are cut in that country's zone. With every country, the
9
+ * charts keep one zone (the one asked for, else the platform's), and the hour-of-week grids
10
+ * read each record in its own country's zone: 14:00 in Lusaka counts as 14:00.
11
+ * - `byCountry` splits the period's figures by country, the country filter left out, so a
12
+ * Super-Admin can compare countries side by side.
13
+ */
14
+ /** A record with no country of its own: counted apart, never as Kenya. */
15
+ export declare const UNKNOWN_COUNTRY = "UNKNOWN";
16
+ export type AnalyticsCountryKey = CountryCode | typeof UNKNOWN_COUNTRY;
17
+ /**
18
+ * How the hour-of-week (and hour-of-day) grids read a record's time:
19
+ * - `zone` in the read's `timeZone` (one country, or records without a country);
20
+ * - `record` each record in its own country's zone (every country).
21
+ */
22
+ export type AnalyticsLocalTimes = 'zone' | 'record';
23
+ /** The platform's zone, for a read that names neither a country nor a zone. */
24
+ export declare const PLATFORM_ANALYTICS_TIME_ZONE = "Africa/Nairobi";
25
+ /**
26
+ * One country's share of a family's figures. `count` is the family's headline count (incidents,
27
+ * accounts, messages, payments); `figures` the few that compare fairly across countries - rates,
28
+ * medians, per-1,000 ratios - keyed by names the family documents.
29
+ */
30
+ export interface AnalyticsCountryRow {
31
+ countryCode: AnalyticsCountryKey;
32
+ count: number;
33
+ /** `count` as a percentage of every country's, one decimal; null when there is nothing at all. */
34
+ share: number | null;
35
+ figures: Record<string, number | null>;
36
+ /** Money figures only: the currency they are in. A country with two currencies has two rows. */
37
+ currency?: string | null;
38
+ }
39
+ /** A supported country's code, or `UNKNOWN` for anything else (null, blank, an unsupported code). */
40
+ export declare function analyticsCountryKey(raw: unknown): AnalyticsCountryKey;
41
+ /** A supported country's code, or null. */
42
+ export declare function analyticsCountryFilter(raw: unknown): CountryCode | null;
43
+ /**
44
+ * The zone a read cuts its days and hours in: the country's own when one is asked for (so a
45
+ * Zambian view reads CAT whoever looks at it), else the zone asked for, else the platform's.
46
+ */
47
+ export declare function analyticsTimeZone(countryCode: unknown, asked?: string | null, fallback?: string): string;
48
+ /** One country: its zone throughout. Every country: each record in its own. */
49
+ export declare function analyticsLocalTimes(countryCode: unknown): AnalyticsLocalTimes;
50
+ /** The order countries are listed in: the platform's order (Kenya, Uganda, Tanzania, Zambia), Unknown last. */
51
+ export declare function analyticsCountryOrder(key: string): number;
52
+ /**
53
+ * Rows by country as a family returns them: shares filled in, the largest first, Unknown always
54
+ * last, ties in the platform's order. Rows with nothing at all are left out.
55
+ */
56
+ export declare function analyticsCountryRows(rows: Array<{
57
+ countryCode: unknown;
58
+ count: number;
59
+ figures?: Record<string, number | null>;
60
+ currency?: string | null;
61
+ }>): AnalyticsCountryRow[];
@@ -0,0 +1 @@
1
+ export * from './analytics-country';
@@ -12,6 +12,7 @@
12
12
  * client and a package appear by name - they are the organization's own customers and
13
13
  * products, already on its billing screens.
14
14
  */
15
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
15
16
  /** How the period is cut into points for the charts. Chosen by the service from the length of the period. */
16
17
  export type BillingAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
17
18
  export interface BillingAnalyticsRange {
@@ -34,13 +35,42 @@ export interface BillingAnalyticsAmount<K extends string = string> {
34
35
  count: number;
35
36
  amountMinor: number;
36
37
  }
37
- /** A currency the scope has done business in, so a dashboard can offer to switch to it. */
38
+ /**
39
+ * A currency the scope has done business in, with its headline figures, so a dashboard can show
40
+ * every currency side by side - never added together - and offer to switch to one.
41
+ */
38
42
  export interface BillingAnalyticsCurrency {
39
43
  currency: string;
40
44
  /** Money received in the period, in this currency. */
41
45
  collectedMinor: number;
42
46
  /** Subscriptions ever started in this currency. */
43
47
  subscriptions: number;
48
+ /** Recurring revenue of the subscriptions live at the end of the period, a month's worth. */
49
+ mrrMinor: number;
50
+ /** Invoiced and not yet paid, at the end of the period. */
51
+ outstandingMinor: number;
52
+ /** Subscriptions live at the end of the period. */
53
+ liveSubscriptions: number;
54
+ /** The countries the money came from (each record's own country), Unknown last. */
55
+ countryCodes: string[];
56
+ }
57
+ /**
58
+ * Every currency converted to one, at rates the platform operator configured - an INDICATIVE
59
+ * figure for a sense of scale, never for accounts: the rates are fixed, the money is not.
60
+ * Null when no rates are configured.
61
+ */
62
+ export interface BillingAnalyticsIndicativeTotal {
63
+ /** What the total is in, e.g. USD. */
64
+ currency: string;
65
+ collectedMinor: number;
66
+ mrrMinor: number;
67
+ outstandingMinor: number;
68
+ /** Units of `currency` per one unit of each currency converted. */
69
+ rates: Record<string, number>;
70
+ /** The day the rates were set, when configured: the total is only as good as they are. */
71
+ ratesAsOf: string | null;
72
+ /** Currencies with money in the period but no configured rate: left out of the total. */
73
+ missing: string[];
44
74
  }
45
75
  /**
46
76
  * What a payment was for:
@@ -405,6 +435,8 @@ export interface BillingAnalytics {
405
435
  currency: string;
406
436
  /** Every currency the scope has business in, busiest first. */
407
437
  currencies: BillingAnalyticsCurrency[];
438
+ /** Every currency converted at configured rates, for a sense of scale only; null without rates. */
439
+ indicativeTotal: BillingAnalyticsIndicativeTotal | null;
408
440
  previous: BillingAnalyticsPrevious | null;
409
441
  timeline: BillingAnalyticsTimelinePoint[];
410
442
  revenue: BillingAnalyticsRevenue;
@@ -421,6 +453,12 @@ export interface BillingAnalytics {
421
453
  clients: BillingAnalyticsClientRow[];
422
454
  /** A Super-Admin looking at every organization only. */
423
455
  byOrganization?: BillingAnalyticsOrganizationRow[];
456
+ /** The country the figures are narrowed to (each record's own country); null for every country. */
457
+ countryCode: string | null;
458
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
459
+ localTimes: AnalyticsLocalTimes;
460
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
461
+ countryComparison: AnalyticsCountryRow[];
424
462
  }
425
463
  /** What a dashboard asks: the period, and - for a Super-Admin - whose figures. */
426
464
  export interface BillingAnalyticsQuery {
@@ -429,4 +467,6 @@ export interface BillingAnalyticsQuery {
429
467
  timeZone?: string;
430
468
  currency?: string;
431
469
  organizationId?: number;
470
+ /** One country's records only; its days in that country's zone. */
471
+ countryCode?: string;
432
472
  }
@@ -30,6 +30,7 @@
30
30
  * the time between. Turns started in the period, answered whenever.
31
31
  * - System messages are counted on their own and never take part in a turn.
32
32
  */
33
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
33
34
  /** How the period is cut into points for the charts. Chosen by the service from the length of the period. */
34
35
  export type ChatAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
35
36
  /** What a conversation is for. */
@@ -264,6 +265,10 @@ export interface ChatAnalytics {
264
265
  heatmap: ChatAnalyticsHeatCell[];
265
266
  /** A Super-Admin looking at every organization only. */
266
267
  byOrganization?: ChatAnalyticsOrganizationRow[];
268
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
269
+ localTimes: AnalyticsLocalTimes;
270
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
271
+ countryComparison: AnalyticsCountryRow[];
267
272
  }
268
273
  /** What a dashboard asks: the period, one country - and, for a Super-Admin, whose figures. */
269
274
  export interface ChatAnalyticsQuery {
@@ -1,4 +1,5 @@
1
1
  import { UnitsAnalyticsCount, UnitsAnalyticsDuration, UnitsAnalyticsRange, UnitsAnalyticsScope } from '../../tracking/interfaces/tracking-analytics';
2
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
2
3
  /**
3
4
  * Units & Tracking analytics, the dispatch half: the response units sent to emergencies
4
5
  * and what became of each - computed by clarion-incident, for the same query as
@@ -155,4 +156,10 @@ export interface DispatchAnalytics {
155
156
  unitsTruncated: boolean;
156
157
  /** Platform view only; null otherwise. */
157
158
  byOrganization: DispatchAnalyticsOrganizationRow[] | null;
159
+ /** The country the figures are narrowed to (each record's own country); null for every country. */
160
+ countryCode: string | null;
161
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
162
+ localTimes: AnalyticsLocalTimes;
163
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
164
+ countryComparison: AnalyticsCountryRow[];
158
165
  }
@@ -1,4 +1,5 @@
1
1
  import { OrganizationAnalyticsCount, OrganizationAnalyticsRange, OrganizationAnalyticsScope } from '../../organization/interfaces/organization-analytics';
2
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
2
3
  /**
3
4
  * Organization analytics, the zone half: the areas the control centres cover - how
4
5
  * much ground, which counties, where zones overlap - computed by clarion-gis for the
@@ -140,4 +141,10 @@ export interface ZoneAnalytics {
140
141
  /** Platform view only; null otherwise. */
141
142
  byOrganization: ZoneAnalyticsOrganizationRow[] | null;
142
143
  timeline: ZoneAnalyticsTimelinePoint[];
144
+ /** The country the figures are narrowed to (each record's own country); null for every country. */
145
+ countryCode: string | null;
146
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
147
+ localTimes: AnalyticsLocalTimes;
148
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
149
+ countryComparison: AnalyticsCountryRow[];
143
150
  }
@@ -12,6 +12,7 @@
12
12
  * is never returned. Counts, rates and durations only - never a reporter, a description
13
13
  * or an address.
14
14
  */
15
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
15
16
  /** How the period is cut into points. Chosen by the service from the length of the period. */
16
17
  export type IncidentAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
17
18
  export interface IncidentAnalyticsRange {
@@ -303,6 +304,12 @@ export interface IncidentDashboardAnalytics {
303
304
  /** Platform view only; null otherwise. */
304
305
  byOrganization: IncidentAnalyticsOrganizationRow[] | null;
305
306
  geography: IncidentAnalyticsGeography;
307
+ /** The country the figures are narrowed to (each record's own country); null for every country. */
308
+ countryCode: string | null;
309
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
310
+ localTimes: AnalyticsLocalTimes;
311
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
312
+ countryComparison: AnalyticsCountryRow[];
306
313
  }
307
314
  /** The query the Dashboard's incident analytics answer (IncidentDashboardAnalyticsQueryDto in the services). */
308
315
  export interface IncidentDashboardAnalyticsQuery {
@@ -320,4 +327,6 @@ export interface IncidentDashboardAnalyticsQuery {
320
327
  channel?: string;
321
328
  typeId?: number;
322
329
  categoryId?: number;
330
+ /** One country's records only; its days in that country's zone. */
331
+ countryCode?: string;
323
332
  }
@@ -1,6 +1,7 @@
1
1
  import { IncidentEmergencyType } from '../../incident/enums/incident-emergency-type.enum';
2
2
  import { IncidentPriority } from '../../incident/enums/incident-priority.enum';
3
3
  import { EmergencyIncidentStage, EtaBasis, EtaStatus, IncidentActorType, IncidentArrivalSource, IncidentClosureReason, IncidentSlaEventSource, IncidentSlaEventType, IncidentSlaStage, IncidentSlaStatus, SlaEscalationLevel, SlaEscalationTrigger, SlaExceptionReason, SlaExceptionStatus, SlaOverallState, SlaPauseReason, SlaPauseStatus, SlaPolicyScope, SlaPriorityLevel } from '../enums/incident-sla-enums';
4
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
4
5
  export interface IncidentSlaExceptionDto {
5
6
  status: SlaExceptionStatus;
6
7
  reason: SlaExceptionReason | null;
@@ -517,6 +518,12 @@ export interface IncidentSlaAnalyticsDto {
517
518
  worstIncidents: IncidentSlaWorstIncidentDto[];
518
519
  byOrganization: IncidentSlaOrganizationRowDto[];
519
520
  generatedAt: string;
521
+ /** The country the figures are narrowed to (each record's own country); null for every country. */
522
+ countryCode: string | null;
523
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
524
+ localTimes: AnalyticsLocalTimes;
525
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
526
+ countryComparison: AnalyticsCountryRow[];
520
527
  }
521
528
  /** The query of `GET /api/incident-sla/analytics`. */
522
529
  export interface IncidentSlaAnalyticsQuery {
@@ -530,6 +537,8 @@ export interface IncidentSlaAnalyticsQuery {
530
537
  typeId?: number;
531
538
  categoryId?: number;
532
539
  responseUnitId?: number;
540
+ /** One country's records only; its days in that country's zone. */
541
+ countryCode?: string;
533
542
  }
534
543
  /** Policy settings beside the targets. On a stored policy every field is optional (absent = inherit). */
535
544
  export interface IncidentSlaPolicySettingsDto {
@@ -14,6 +14,7 @@
14
14
  * events the service emitted. Comments are every comment written, including any since
15
15
  * hidden by a moderator or removed.
16
16
  */
17
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
17
18
  /** How the period is cut into points for the charts. Chosen by the service from the length of the period. */
18
19
  export type NewsfeedAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
19
20
  export interface NewsfeedAnalyticsRange {
@@ -313,6 +314,10 @@ export interface NewsfeedAnalytics {
313
314
  byCountry: NewsfeedAnalyticsCountryRow[];
314
315
  /** A Super-Admin looking at every organization only. */
315
316
  byOrganization?: NewsfeedAnalyticsOrganizationRow[];
317
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
318
+ localTimes: AnalyticsLocalTimes;
319
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
320
+ countryComparison: AnalyticsCountryRow[];
316
321
  }
317
322
  /** What a dashboard asks: the period, one country - and, for a Super-Admin, whose figures. */
318
323
  export interface NewsfeedAnalyticsQuery {
@@ -22,6 +22,7 @@
22
22
  * - A country narrows push, in-app and devices by the recipient's country and SMS by
23
23
  * the number's; email has no country and is never narrowed.
24
24
  */
25
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
25
26
  /** How the period is cut into points for the charts. Chosen by the service from the length of the period. */
26
27
  export type NotificationAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
27
28
  /** The four ways Clarion tells somebody something. */
@@ -262,6 +263,10 @@ export interface NotificationAnalytics {
262
263
  byOrganization?: NotificationAnalyticsOrganizationRow[];
263
264
  /** A Super-Admin looking at every organization only. */
264
265
  unattributed?: NotificationAnalyticsUnattributed;
266
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
267
+ localTimes: AnalyticsLocalTimes;
268
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
269
+ countryComparison: AnalyticsCountryRow[];
265
270
  }
266
271
  /** What a dashboard asks: the period, one country - and, for a Super-Admin, whose figures. */
267
272
  export interface NotificationAnalyticsQuery {
@@ -10,6 +10,7 @@
10
10
  * Counts, rates and durations only - never a phone number, an address, a person or a
11
11
  * typed reason.
12
12
  */
13
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
13
14
  /** How the period is cut into points. Chosen by the service from the length of the period. */
14
15
  export type OrganizationAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
15
16
  export interface OrganizationAnalyticsRange {
@@ -186,6 +187,12 @@ export interface OrganizationAnalytics {
186
187
  controlCentreRowsTruncated: boolean;
187
188
  /** The organizations in scope: one row for an organization's own staff. */
188
189
  organizationRows: OrganizationAnalyticsOrganizationRow[];
190
+ /** The country the figures are narrowed to (each record's own country); null for every country. */
191
+ countryCode: string | null;
192
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
193
+ localTimes: AnalyticsLocalTimes;
194
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
195
+ countryComparison: AnalyticsCountryRow[];
189
196
  }
190
197
  /** The query both halves of the Organization analytics answer (OrganizationAnalyticsQueryDto in the services). */
191
198
  export interface OrganizationAnalyticsQuery {
@@ -197,4 +204,6 @@ export interface OrganizationAnalyticsQuery {
197
204
  /** Super-Admin only. */
198
205
  organizationId?: number;
199
206
  controlCentreId?: number;
207
+ /** One country's records only; its days in that country's zone. */
208
+ countryCode?: string;
200
209
  }
@@ -12,6 +12,7 @@
12
12
  * as they stand now: a dispatch raised in the period and delivered after it counts as
13
13
  * delivered. Partner calls and memberships are counted by when they happened.
14
14
  */
15
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
15
16
  /** How the period is cut into points for the charts. Chosen by the service from the length of the period. */
16
17
  export type PartnerAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
17
18
  export interface PartnerAnalyticsRange {
@@ -367,6 +368,12 @@ export interface PartnerAnalytics {
367
368
  incidentTypes: PartnerAnalyticsIncidentTypeRow[];
368
369
  /** A Super-Admin looking at every organization only. */
369
370
  byOrganization?: PartnerAnalyticsOrganizationRow[];
371
+ /** The country the figures are narrowed to (each record's own country); null for every country. */
372
+ countryCode: string | null;
373
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
374
+ localTimes: AnalyticsLocalTimes;
375
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
376
+ countryComparison: AnalyticsCountryRow[];
370
377
  }
371
378
  /** What a dashboard asks: the period, one partnership - and, for a Super-Admin, whose figures. */
372
379
  export interface PartnerAnalyticsQuery {
@@ -375,4 +382,6 @@ export interface PartnerAnalyticsQuery {
375
382
  timeZone?: string;
376
383
  organizationId?: number;
377
384
  integrationId?: number;
385
+ /** One country's records only; its days in that country's zone. */
386
+ countryCode?: string;
378
387
  }
@@ -7,6 +7,7 @@
7
7
  * Counts only: never a location, a destination, a phone number, a name or a reason a
8
8
  * user typed. A check or journey is counted by when it started, as it stands now.
9
9
  */
10
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
10
11
  /** How the period is cut into points for the charts. Chosen by the service from the length of the period. */
11
12
  export type SafetyAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
12
13
  export interface SafetyAnalyticsRange {
@@ -346,6 +347,12 @@ export interface SafetyAnalytics {
346
347
  followMe: FollowMeAnalytics;
347
348
  /** Super-Admin's view of every organization only. */
348
349
  byOrganization?: SafetyAnalyticsOrganizationRow[];
350
+ /** The country the figures are narrowed to (each record's own country); null for every country. */
351
+ countryCode: string | null;
352
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
353
+ localTimes: AnalyticsLocalTimes;
354
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
355
+ countryComparison: AnalyticsCountryRow[];
349
356
  }
350
357
  /**
351
358
  * The period a safety analytics read covers (query string). Both ends optional: no
@@ -357,4 +364,6 @@ export interface SafetyAnalyticsQuery {
357
364
  to?: string;
358
365
  timeZone?: string;
359
366
  organizationId?: number;
367
+ /** One country's records only; its days in that country's zone. */
368
+ countryCode?: string;
360
369
  }
@@ -25,6 +25,7 @@
25
25
  * whose deadline later moved (waiting on the customer, a reopen) can be breached
26
26
  * once and still end up met.
27
27
  */
28
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
28
29
  /** How the period is cut into points for the charts. Chosen by the service from the length of the period. */
29
30
  export type SupportAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
30
31
  export interface SupportAnalyticsRange {
@@ -379,6 +380,10 @@ export interface SupportAnalytics {
379
380
  heatmap: SupportAnalyticsHeatCell[];
380
381
  /** A Super-Admin looking at every organization only. */
381
382
  byOrganization?: SupportAnalyticsOrganizationRow[];
383
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
384
+ localTimes: AnalyticsLocalTimes;
385
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
386
+ countryComparison: AnalyticsCountryRow[];
382
387
  }
383
388
  /** What a dashboard asks: the period, one country - and, for a Super-Admin, whose figures. */
384
389
  export interface SupportAnalyticsQuery {
@@ -9,6 +9,7 @@
9
9
  * rollup of the position history, so a year costs no more to read than a day. Counts,
10
10
  * rates and durations only - never a position, a route or a device identifier.
11
11
  */
12
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
12
13
  /** How the period is cut into points for the charts. Chosen by the service from the length of the period. */
13
14
  export type UnitsAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
14
15
  export interface UnitsAnalyticsRange {
@@ -189,6 +190,12 @@ export interface TrackingAnalytics {
189
190
  rollupThrough: string | null;
190
191
  /** History older than this is still being rolled up (the first hours after release); null once complete. */
191
192
  backfillingBefore: string | null;
193
+ /** The country the figures are narrowed to (each record's own country); null for every country. */
194
+ countryCode: string | null;
195
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
196
+ localTimes: AnalyticsLocalTimes;
197
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
198
+ countryComparison: AnalyticsCountryRow[];
192
199
  }
193
200
  /** The query both halves answer (UnitsAnalyticsQueryDto in grm-shared-library). All optional. */
194
201
  export interface UnitsAnalyticsQuery {
@@ -202,4 +209,6 @@ export interface UnitsAnalyticsQuery {
202
209
  organizationId?: number;
203
210
  /** One control centre of the organization. */
204
211
  controlCentreId?: number;
212
+ /** One country's records only; its days in that country's zone. */
213
+ countryCode?: string;
205
214
  }
@@ -12,6 +12,7 @@
12
12
  * codes and password changes come from the service's activity log, which begins on
13
13
  * `activitySince`: before it, the only trace of a sign-in is each account's LAST one.
14
14
  */
15
+ import { AnalyticsCountryRow, AnalyticsLocalTimes } from '../../analytics/analytics-country';
15
16
  /** How the period is cut into points for the charts. Chosen by the service from the length of the period. */
16
17
  export type AccountAnalyticsBucket = 'hour' | 'day' | 'week' | 'month';
17
18
  export interface AccountAnalyticsRange {
@@ -444,6 +445,12 @@ export interface AccountAnalytics {
444
445
  signInOptions?: AccountAnalyticsSignInOptions;
445
446
  /** A Super-Admin looking at every organization only. */
446
447
  byOrganization?: AccountAnalyticsOrganizationRow[];
448
+ /** The country the figures are narrowed to (each record's own country); null for every country. */
449
+ countryCode: string | null;
450
+ /** How the hour-of-week grids read time: in `range.timeZone` ('zone'), or each record in its own country's zone ('record'). */
451
+ localTimes: AnalyticsLocalTimes;
452
+ /** Every country in scope side by side for the period, the country filter left out: largest first, Unknown last. */
453
+ countryComparison: AnalyticsCountryRow[];
447
454
  }
448
455
  /** What a dashboard asks: the period, and - for a Super-Admin - whose figures. */
449
456
  export interface AccountAnalyticsQuery {
@@ -451,4 +458,6 @@ export interface AccountAnalyticsQuery {
451
458
  to?: string;
452
459
  timeZone?: string;
453
460
  organizationId?: number;
461
+ /** One country's records only; its days in that country's zone. */
462
+ countryCode?: string;
454
463
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarion-shared-types",
3
- "version": "1.0.132",
3
+ "version": "1.0.133",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",