busroot-sdk 0.0.8-dev.2916117361 → 0.0.8-dev.2920350130
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.js +48 -6
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -536,6 +536,8 @@ var require_times = __commonJS({
|
|
|
536
536
|
})();
|
|
537
537
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
538
538
|
exports2.getDurationAsHumanize = exports2.getDuration = exports2.hourToMoment = exports2.convertToUniversal = exports2.AcceptedDateTimeFormats = exports2.getOverlappedTimeRange = exports2.intersectTimeWindowsIso = exports2.intersectTimeWindows = exports2.intersectTimeRanges = exports2.getCoverageRanges = exports2.convertNumberToMomentTime = exports2.getTimesBetweenRangeTimes = exports2.formattedDurationShort = exports2.formattedDuration = exports2.RelativeRanges = exports2.SUPPORTED_DURATION = exports2.RangeType = void 0;
|
|
539
|
+
exports2.isoWeeksInIsoWeekYear = isoWeeksInIsoWeekYear;
|
|
540
|
+
exports2.isValidRangeCode = isValidRangeCode;
|
|
539
541
|
exports2.getAllowedAggregationWindowsForDuration = getAllowedAggregationWindowsForDuration;
|
|
540
542
|
exports2.getTimestampFromString = getTimestampFromString;
|
|
541
543
|
exports2.getTimestampInSecond = getTimestampInSecond;
|
|
@@ -651,6 +653,49 @@ var require_times = __commonJS({
|
|
|
651
653
|
months: 12
|
|
652
654
|
}
|
|
653
655
|
];
|
|
656
|
+
var RANGE_CODE_MIN_YEAR = 2020;
|
|
657
|
+
var RANGE_CODE_MAX_YEAR = 2100;
|
|
658
|
+
function isoWeeksInIsoWeekYear(year) {
|
|
659
|
+
return moment_timezone_1.default.utc({ year }).isoWeeksInYear();
|
|
660
|
+
}
|
|
661
|
+
var DATED_RANGE_CODE_FORMATS = [
|
|
662
|
+
{ pattern: /^DAY_(\d{4})_\d{2}_\d{2}$/, momentFormat: "YYYY_MM_DD" },
|
|
663
|
+
{ pattern: /^MONTH_(\d{4})_\d{2}$/, momentFormat: "YYYY_MM" },
|
|
664
|
+
{ pattern: /^HOUR_(\d{4})_\d{2}_\d{2}_\d{2}$/, momentFormat: "YYYY_MM_DD_HH" },
|
|
665
|
+
{ pattern: /^MINUTE_(\d{4})_\d{2}_\d{2}_\d{2}_\d{2}$/, momentFormat: "YYYY_MM_DD_HH_mm" },
|
|
666
|
+
{ pattern: /^QUARTER_(\d{4})_[1-4]$/ },
|
|
667
|
+
{ pattern: /^YEAR_(\d{4})$/ }
|
|
668
|
+
];
|
|
669
|
+
var WEEK_RANGE_CODE_PATTERN = /^WEEK_(\d{4})_(\d{1,2})$/;
|
|
670
|
+
var CUSTOM_RANGE_CODE_PATTERN = /^CUSTOM_\d+_\d+$/;
|
|
671
|
+
function isValidRangeCode(code) {
|
|
672
|
+
if (code === "TODAY" || code === "YESTERDAY") {
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
675
|
+
if (code.startsWith("RELATIVE_")) {
|
|
676
|
+
return exports2.RelativeRanges.some((relativeRange) => relativeRange.rangeCode === code);
|
|
677
|
+
}
|
|
678
|
+
if (CUSTOM_RANGE_CODE_PATTERN.test(code)) {
|
|
679
|
+
return true;
|
|
680
|
+
}
|
|
681
|
+
const isYearInBounds = (year) => year >= RANGE_CODE_MIN_YEAR && year <= RANGE_CODE_MAX_YEAR;
|
|
682
|
+
const weekMatch = WEEK_RANGE_CODE_PATTERN.exec(code);
|
|
683
|
+
if (weekMatch) {
|
|
684
|
+
const year = Number(weekMatch[1]);
|
|
685
|
+
const week = Number(weekMatch[2]);
|
|
686
|
+
return isYearInBounds(year) && week >= 1 && week <= isoWeeksInIsoWeekYear(year);
|
|
687
|
+
}
|
|
688
|
+
for (const { pattern, momentFormat } of DATED_RANGE_CODE_FORMATS) {
|
|
689
|
+
const match = pattern.exec(code);
|
|
690
|
+
if (match) {
|
|
691
|
+
const components = code.slice(code.indexOf("_") + 1);
|
|
692
|
+
const parsed = momentFormat == null ? null : moment_timezone_1.default.utc(components, momentFormat, true);
|
|
693
|
+
const isRealPeriod = parsed == null || parsed.isValid() && parsed.format(momentFormat) === components;
|
|
694
|
+
return isYearInBounds(Number(match[1])) && isRealPeriod;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
return false;
|
|
698
|
+
}
|
|
654
699
|
var AllowedAggregationWindows = [
|
|
655
700
|
// 1 Hour
|
|
656
701
|
{
|
|
@@ -1038,7 +1083,7 @@ var require_times = __commonJS({
|
|
|
1038
1083
|
// YEAR: full ISO week year (52 or 53 weeks). Start at ISO week 1, apply plant offsets like the week handler.
|
|
1039
1084
|
year: () => {
|
|
1040
1085
|
const year = parseInt(parts[1]);
|
|
1041
|
-
const weeksInYear = (
|
|
1086
|
+
const weeksInYear = isoWeeksInIsoWeekYear(year);
|
|
1042
1087
|
const start = plantWeekStart(year, 1, plant.weekStartDay ?? 0, plant.timezone);
|
|
1043
1088
|
start.add(plant.dayStartHour, "hour");
|
|
1044
1089
|
start.utc();
|
|
@@ -1151,7 +1196,7 @@ var require_times = __commonJS({
|
|
|
1151
1196
|
};
|
|
1152
1197
|
exports2.intersectTimeWindowsIso = intersectTimeWindowsIso;
|
|
1153
1198
|
function getWeeksInQuarter(year, quarter) {
|
|
1154
|
-
const weeksInYear = (
|
|
1199
|
+
const weeksInYear = isoWeeksInIsoWeekYear(year);
|
|
1155
1200
|
if (quarter === 1) {
|
|
1156
1201
|
return new Array(13).fill("").map((v, i) => i + 1);
|
|
1157
1202
|
}
|
|
@@ -3511,10 +3556,7 @@ var require_common = __commonJS({
|
|
|
3511
3556
|
var times_1 = require_times();
|
|
3512
3557
|
var time_1 = require_time();
|
|
3513
3558
|
exports2.UNKNOWN_CODE = "unknown";
|
|
3514
|
-
exports2.RangeCodeSchema = zod_1.z.string().trim().refine((
|
|
3515
|
-
const rangeType = value.split("_")[0].toLowerCase();
|
|
3516
|
-
return zod_1.z.nativeEnum(times_1.RangeType).safeParse(rangeType).success;
|
|
3517
|
-
}).optional().describe("Time range code (e.g. TODAY, YESTERDAY, DAY_2026_02_24, WEEK_2026_09, MONTH_2026_02, QUARTER_2026_2, YEAR_2026, HOUR_2026_02_24_14, MINUTE_2026_02_24_14_30, RELATIVE_HOURS_1, RELATIVE_HOURS_24, RELATIVE_DAYS_7, RELATIVE_DAYS_28).");
|
|
3559
|
+
exports2.RangeCodeSchema = zod_1.z.string().trim().refine(times_1.isValidRangeCode).optional().describe("Time range code (e.g. TODAY, YESTERDAY, DAY_2026_02_24, WEEK_2026_09, MONTH_2026_02, QUARTER_2026_2, YEAR_2026, HOUR_2026_02_24_14, MINUTE_2026_02_24_14_30, RELATIVE_HOURS_1, RELATIVE_HOURS_24, RELATIVE_DAYS_7, RELATIVE_DAYS_28).");
|
|
3518
3560
|
exports2.StandardRequestParams = zod_1.z.object({
|
|
3519
3561
|
plantcode: zod_1.z.string().trim().min(1).optional(),
|
|
3520
3562
|
rangecode: exports2.RangeCodeSchema,
|
package/package.json
CHANGED