busroot-sdk 0.0.8-dev.2804160550 → 0.0.8-dev.2804783613

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 (2) hide show
  1. package/build/index.js +33 -4
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -8518,6 +8518,7 @@ var require_schedules = __commonJS({
8518
8518
  };
8519
8519
  Object.defineProperty(exports2, "__esModule", { value: true });
8520
8520
  exports2.getActiveSchedulesForTimestamp = getActiveSchedulesForTimestamp;
8521
+ exports2.getActiveSchedulesForWindow = getActiveSchedulesForWindow;
8521
8522
  exports2.calculateScheduleProgress = calculateScheduleProgress;
8522
8523
  exports2.calculateEffectivePerformance = calculateEffectivePerformance;
8523
8524
  exports2.calculateIdealEnd = calculateIdealEnd;
@@ -8541,6 +8542,27 @@ var require_schedules = __commonJS({
8541
8542
  nextSchedule
8542
8543
  };
8543
8544
  }
8545
+ function getActiveSchedulesForWindow(schedules, windowStartTimestamp, windowEndTimestamp, now) {
8546
+ const overlapMs = (schedule) => {
8547
+ if (schedule.actualStartAtTimestamp == null) {
8548
+ return 0;
8549
+ }
8550
+ const start = Math.max(schedule.actualStartAtTimestamp, windowStartTimestamp);
8551
+ const end = Math.min(schedule.actualEndAtTimestamp || now + 1, windowEndTimestamp);
8552
+ return Math.max(0, end - start);
8553
+ };
8554
+ const activeSchedules = schedules.filter((schedule) => overlapMs(schedule) > 0).sort((a, b) => overlapMs(b) - overlapMs(a) || (b.actualStartAtTimestamp || 0) - (a.actualStartAtTimestamp || 0));
8555
+ const activeProductionSchedules = activeSchedules.filter((schedule) => schedule.skuCode != void 0);
8556
+ const activeNonProductionSchedules = activeSchedules.filter((schedule) => schedule.nonProductionReasonCode != void 0);
8557
+ const activeSchedule = activeNonProductionSchedules[0] || activeProductionSchedules[0];
8558
+ const nextSchedule = schedules.sort((a, b) => (a.plannedStartAtTimestamp || 0) - (b.plannedStartAtTimestamp || 0)).filter((a) => activeSchedule == null || a.id !== activeSchedule.id)[0];
8559
+ return {
8560
+ activeProductionSchedule: activeProductionSchedules[0],
8561
+ activeNonProductionSchedule: activeNonProductionSchedules[0],
8562
+ activeSchedule,
8563
+ nextSchedule
8564
+ };
8565
+ }
8544
8566
  function calculateScheduleProgress(now, stations, schedules) {
8545
8567
  return schedules.map((schedule) => {
8546
8568
  const station = stations.find((station2) => station2.code === schedule.stationCode);
@@ -8666,7 +8688,7 @@ var require_schedules = __commonJS({
8666
8688
  if (window2.shiftMs == null) {
8667
8689
  throw new Error("Shift time must be already populated.");
8668
8690
  }
8669
- const { activeNonProductionSchedule, activeProductionSchedule } = getActiveSchedulesForTimestamp(schedules, window2.windowStartAtTimestamp, now || (0, moment_timezone_1.default)().valueOf());
8691
+ const { activeNonProductionSchedule, activeProductionSchedule } = getActiveSchedulesForWindow(schedules, window2.windowStartAtTimestamp, window2.windowEndAtTimestamp, now || (0, moment_timezone_1.default)().valueOf());
8670
8692
  const isInShift = window2.shiftMs > 0;
8671
8693
  if (isInShift) {
8672
8694
  const productionGoodCount = window2.productionGoodCount || 0;
@@ -8725,7 +8747,7 @@ var require_schedules = __commonJS({
8725
8747
  unitsPerHour: station.unitsPerHour,
8726
8748
  unitsPerMinute: station.unitsPerMinute
8727
8749
  });
8728
- window2.skuCode = isAnyProduction ? "unknown" : void 0;
8750
+ window2.skuCode = isAnyProduction ? window2.skuCode ?? "unknown" : void 0;
8729
8751
  window2.workOrderReference = void 0;
8730
8752
  window2.productionIdealCount = 0;
8731
8753
  window2.productionTargetCount = 0;
@@ -9367,8 +9389,9 @@ var require_station_windows = __commonJS({
9367
9389
  return mod && mod.__esModule ? mod : { "default": mod };
9368
9390
  };
9369
9391
  Object.defineProperty(exports2, "__esModule", { value: true });
9370
- exports2.AggregatedProduction = void 0;
9392
+ exports2.AggregatedProduction = exports2.OPERATOR_INITIALS_SEPARATOR = void 0;
9371
9393
  exports2.generateMockStationWindows = generateMockStationWindows;
9394
+ exports2.joinOperatorInitials = joinOperatorInitials;
9372
9395
  exports2.combineStationWindows = combineStationWindows;
9373
9396
  exports2.combineStationWindowsByTime = combineStationWindowsByTime;
9374
9397
  exports2.aggregateStationWindows = aggregateStationWindows;
@@ -9417,6 +9440,12 @@ var require_station_windows = __commonJS({
9417
9440
  ...extraFields
9418
9441
  };
9419
9442
  }
9443
+ exports2.OPERATOR_INITIALS_SEPARATOR = ", ";
9444
+ function joinOperatorInitials(existing, next) {
9445
+ const values = [existing, next].flatMap((value) => (value || "").split(exports2.OPERATOR_INITIALS_SEPARATOR.trim())).map((value) => value.trim()).filter((value) => value.length > 0);
9446
+ const unique = [...new Set(values)];
9447
+ return unique.length > 0 ? unique.join(exports2.OPERATOR_INITIALS_SEPARATOR) : void 0;
9448
+ }
9420
9449
  function combineStationWindows(windows, inShiftAverages = false, skipConsecutiveCheck = false) {
9421
9450
  if (windows.length === 0) {
9422
9451
  throw new Error("Must be at least 1 window.");
@@ -9525,7 +9554,7 @@ var require_station_windows = __commonJS({
9525
9554
  a.nonProductionReasonCodesDetail = nonProductionReasonCodesDetail;
9526
9555
  }
9527
9556
  if (b.operatorInitials) {
9528
- a.operatorInitials = b.operatorInitials;
9557
+ a.operatorInitials = joinOperatorInitials(a.operatorInitials, b.operatorInitials);
9529
9558
  }
9530
9559
  a.performanceModeFrom = b.performanceModeFrom;
9531
9560
  a.performanceModeType = b.performanceModeType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "busroot-sdk",
3
- "version": "0.0.8-dev.2804160550",
3
+ "version": "0.0.8-dev.2804783613",
4
4
  "description": "An SDK for accessing Busroot from output.industries",
5
5
  "homepage": "https://www.output.industries",
6
6
  "main": "./build/index.js",