busroot-sdk 0.0.8-dev.2929555090 → 0.0.8-dev.2936968167
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/build/index.d.ts +2 -1
- package/build/index.js +41 -15
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Reason, UserRole, AuthType, AccountRole, DOWNTIME_DETECTION_MODE as DOWNTIME_DETECTION_MODE$1, PRODUCTIVE_STATUS_MODE as PRODUCTIVE_STATUS_MODE$1, PRODUCTION_TYPE, DowntimeType, SCHEDULE_TYPE } from './utils/times';
|
|
1
|
+
import { Reason, UserRole, AuthType, AccountRole, LoginMethod, DOWNTIME_DETECTION_MODE as DOWNTIME_DETECTION_MODE$1, PRODUCTIVE_STATUS_MODE as PRODUCTIVE_STATUS_MODE$1, PRODUCTION_TYPE, DowntimeType, SCHEDULE_TYPE } from './utils/times';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { IClientOptions, MqttClient } from 'mqtt';
|
|
4
4
|
import * as __ from '..';
|
|
@@ -2774,6 +2774,7 @@ declare class BusrootClient {
|
|
|
2774
2774
|
durationFormat?: "months" | "days" | "hours" | "minutes" | null | undefined;
|
|
2775
2775
|
appUrls?: string | null | undefined;
|
|
2776
2776
|
} | undefined;
|
|
2777
|
+
loginMethod?: LoginMethod | undefined;
|
|
2777
2778
|
accounts?: {
|
|
2778
2779
|
accountId: string;
|
|
2779
2780
|
role: AccountRole;
|
package/build/index.js
CHANGED
|
@@ -567,6 +567,8 @@ var require_times = __commonJS({
|
|
|
567
567
|
exports2.fromSpecificHourString = fromSpecificHourString;
|
|
568
568
|
exports2.plantWeekNumber = plantWeekNumber;
|
|
569
569
|
exports2.plantWeekStart = plantWeekStart;
|
|
570
|
+
exports2.plantDayStart = plantDayStart;
|
|
571
|
+
exports2.plantProductionDate = plantProductionDate;
|
|
570
572
|
exports2.addPlantDays = addPlantDays;
|
|
571
573
|
exports2.getTimeRangeFromRangeCode = getTimeRangeFromRangeCode;
|
|
572
574
|
exports2.getCoverage = getCoverage;
|
|
@@ -995,9 +997,24 @@ var require_times = __commonJS({
|
|
|
995
997
|
return start;
|
|
996
998
|
}
|
|
997
999
|
var DAYS_PER_WEEK = 7;
|
|
1000
|
+
function plantDayStart(date, dayStartHour) {
|
|
1001
|
+
const start = date.clone().hour(dayStartHour);
|
|
1002
|
+
const timezone = date.tz();
|
|
1003
|
+
if (timezone && (0, moment_timezone_1.default)(start.valueOf()).tz(timezone).hour() !== dayStartHour) {
|
|
1004
|
+
return (0, moment_timezone_1.default)(start.valueOf()).tz(timezone).add(1, "hour");
|
|
1005
|
+
}
|
|
1006
|
+
return start;
|
|
1007
|
+
}
|
|
1008
|
+
function plantProductionDate(instant, plant) {
|
|
1009
|
+
const date = (0, moment_timezone_1.default)(instant).tz(plant.timezone).startOf("day");
|
|
1010
|
+
if (instant < plantDayStart(date, plant.dayStartHour).valueOf()) {
|
|
1011
|
+
date.subtract(1, "day");
|
|
1012
|
+
}
|
|
1013
|
+
return date;
|
|
1014
|
+
}
|
|
998
1015
|
function plantDayRange(date, days, dayStartHour) {
|
|
999
|
-
const from = date
|
|
1000
|
-
const to = date.clone().add(days, "days")
|
|
1016
|
+
const from = plantDayStart(date, dayStartHour).valueOf();
|
|
1017
|
+
const to = plantDayStart(date.clone().add(days, "days"), dayStartHour).valueOf();
|
|
1001
1018
|
return timestampsToTimeRange({ from, to });
|
|
1002
1019
|
}
|
|
1003
1020
|
function addPlantDays(instant, days, timezone) {
|
|
@@ -1005,10 +1022,11 @@ var require_times = __commonJS({
|
|
|
1005
1022
|
}
|
|
1006
1023
|
function floorToPlantWeekStart(instant, plant) {
|
|
1007
1024
|
const weekStartDay = plant.weekStartDay ?? 0;
|
|
1008
|
-
|
|
1025
|
+
const weekStart = plantProductionDate(instant, plant).subtract(weekStartDay, "days").startOf("isoWeek").add(weekStartDay, "days");
|
|
1026
|
+
return plantDayStart(weekStart, plant.dayStartHour).valueOf();
|
|
1009
1027
|
}
|
|
1010
1028
|
function floorToPlantDayStart(instant, plant) {
|
|
1011
|
-
return (
|
|
1029
|
+
return plantDayStart(plantProductionDate(instant, plant), plant.dayStartHour).valueOf();
|
|
1012
1030
|
}
|
|
1013
1031
|
var CUSTOM_RANGE_MINUTE_STEPS = {
|
|
1014
1032
|
"5m": 5,
|
|
@@ -1063,19 +1081,18 @@ var require_times = __commonJS({
|
|
|
1063
1081
|
return timestampsToTimeRange({ from: day.valueOf(), to: day.add(1, "hours").valueOf() });
|
|
1064
1082
|
},
|
|
1065
1083
|
// Every range below ends where the next one of its kind starts, built on the plant's local calendar
|
|
1066
|
-
// (add whole days/months, then dayStartHour) and only then read as UTC. Adding a fixed
|
|
1067
|
-
// would make a range that contains a daylight-saving change an hour too long or short,
|
|
1068
|
-
// and overlaps between consecutive ranges.
|
|
1084
|
+
// (add whole days/months, then set the hour to dayStartHour) and only then read as UTC. Adding a fixed
|
|
1085
|
+
// n×24h instead would make a range that contains a daylight-saving change an hour too long or short,
|
|
1086
|
+
// leaving gaps and overlaps between consecutive ranges.
|
|
1069
1087
|
//
|
|
1070
|
-
// TODAY/YESTERDAY:
|
|
1071
|
-
//
|
|
1072
|
-
// e.g. it's 02:00 but the production day started at 06:00 the previous calendar day.
|
|
1088
|
+
// TODAY/YESTERDAY: the production date containing `now` - e.g. at 02:00 with a 06:00 day start,
|
|
1089
|
+
// the production day that started the previous calendar day.
|
|
1073
1090
|
today: () => {
|
|
1074
|
-
const date = (
|
|
1091
|
+
const date = plantProductionDate(now ?? Date.now(), plant);
|
|
1075
1092
|
return plantDayRange(date, 1, plant.dayStartHour);
|
|
1076
1093
|
},
|
|
1077
1094
|
yesterday: () => {
|
|
1078
|
-
const date = (
|
|
1095
|
+
const date = plantProductionDate(now ?? Date.now(), plant).subtract(1, "day");
|
|
1079
1096
|
return plantDayRange(date, 1, plant.dayStartHour);
|
|
1080
1097
|
},
|
|
1081
1098
|
day: () => {
|
|
@@ -1087,7 +1104,7 @@ var require_times = __commonJS({
|
|
|
1087
1104
|
return plantDayRange(week, DAYS_PER_WEEK, plant.dayStartHour);
|
|
1088
1105
|
},
|
|
1089
1106
|
month: () => {
|
|
1090
|
-
const month = moment_timezone_1.default.tz(`${parseInt(parts[1])}_${parseInt(parts[2])}
|
|
1107
|
+
const month = moment_timezone_1.default.tz(`${parseInt(parts[1])}_${parseInt(parts[2])}`, "YYYY_MM", plant.timezone).startOf("month");
|
|
1091
1108
|
return plantDayRange(month, month.daysInMonth(), plant.dayStartHour);
|
|
1092
1109
|
},
|
|
1093
1110
|
// QUARTER: 13 ISO weeks (14 for Q4 in 53-week years). Start at the first ISO week of the quarter,
|
|
@@ -1853,7 +1870,7 @@ var require_enums = __commonJS({
|
|
|
1853
1870
|
"../../packages/common/build/enums.js"(exports2) {
|
|
1854
1871
|
"use strict";
|
|
1855
1872
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1856
|
-
exports2.MqttEventType = exports2.REASON_TYPE = exports2.PERFORMANCE_MODE_TYPE = exports2.EMAIL_HARNESS_TYPE = exports2.ALERT_ISSUE_TYPE = exports2.CursorType = exports2.TIMESERIES_MESSAGE_TYPE = exports2.PRODUCTIVE_STATUS_MODE = exports2.DOWNTIME_DETECTION_MODE = exports2.NOTIFICATION_PREFERENCE = exports2.WeekDay = exports2.AuthType = exports2.AccountRole = exports2.UserRole = exports2.SCHEDULE_TYPE = exports2.PRODUCTION_TYPE = exports2.MessageType = exports2.GROUP_TAG_PREFIX = exports2.DowntimeFilterState = exports2.DowntimeEventType = exports2.DowntimeType = exports2.StationStatus = exports2.RagStatus = void 0;
|
|
1873
|
+
exports2.MqttEventType = exports2.REASON_TYPE = exports2.PERFORMANCE_MODE_TYPE = exports2.EMAIL_HARNESS_TYPE = exports2.ALERT_ISSUE_TYPE = exports2.CursorType = exports2.TIMESERIES_MESSAGE_TYPE = exports2.PRODUCTIVE_STATUS_MODE = exports2.DOWNTIME_DETECTION_MODE = exports2.NOTIFICATION_PREFERENCE = exports2.WeekDay = exports2.LoginMethod = exports2.AuthType = exports2.AccountRole = exports2.UserRole = exports2.SCHEDULE_TYPE = exports2.PRODUCTION_TYPE = exports2.MessageType = exports2.GROUP_TAG_PREFIX = exports2.DowntimeFilterState = exports2.DowntimeEventType = exports2.DowntimeType = exports2.StationStatus = exports2.RagStatus = void 0;
|
|
1857
1874
|
var colours_1 = require_colours();
|
|
1858
1875
|
var RagStatus;
|
|
1859
1876
|
(function(RagStatus2) {
|
|
@@ -1941,6 +1958,13 @@ var require_enums = __commonJS({
|
|
|
1941
1958
|
AuthType2["ui"] = "ui";
|
|
1942
1959
|
AuthType2["api"] = "api";
|
|
1943
1960
|
})(AuthType || (exports2.AuthType = AuthType = {}));
|
|
1961
|
+
var LoginMethod;
|
|
1962
|
+
(function(LoginMethod2) {
|
|
1963
|
+
LoginMethod2["accessCode"] = "access_code";
|
|
1964
|
+
LoginMethod2["magicLink"] = "magic_link";
|
|
1965
|
+
LoginMethod2["microsoft"] = "microsoft";
|
|
1966
|
+
LoginMethod2["bypass"] = "bypass";
|
|
1967
|
+
})(LoginMethod || (exports2.LoginMethod = LoginMethod = {}));
|
|
1944
1968
|
var WeekDay;
|
|
1945
1969
|
(function(WeekDay2) {
|
|
1946
1970
|
WeekDay2["Monday"] = "1";
|
|
@@ -11210,7 +11234,9 @@ var require_auth2 = __commonJS({
|
|
|
11210
11234
|
userRole: zod_1.z.nativeEnum(enums_1.UserRole),
|
|
11211
11235
|
accountId: zod_1.z.string(),
|
|
11212
11236
|
role: zod_1.z.nativeEnum(enums_1.AccountRole).optional(),
|
|
11213
|
-
type: zod_1.z.nativeEnum(enums_1.AuthType).optional()
|
|
11237
|
+
type: zod_1.z.nativeEnum(enums_1.AuthType).optional(),
|
|
11238
|
+
// Absent on sessions signed in before it was added; see resolveLoginMethod.
|
|
11239
|
+
loginMethod: zod_1.z.nativeEnum(enums_1.LoginMethod).optional()
|
|
11214
11240
|
});
|
|
11215
11241
|
}
|
|
11216
11242
|
});
|
package/package.json
CHANGED