@optifye/dashboard-core 6.4.0 → 6.4.1

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/dist/index.js CHANGED
@@ -3859,7 +3859,12 @@ var S3ClipsService = class {
3859
3859
  */
3860
3860
  async listS3Clips(params) {
3861
3861
  const { workspaceId, date, shiftId, maxKeys } = params;
3862
+ if (!isValidShiftId(shiftId)) {
3863
+ console.error(`[S3ClipsService] Invalid shift ID: ${shiftId}. Must be 0 (day) or 1 (night)`);
3864
+ return [];
3865
+ }
3862
3866
  const prefix = `sop_violations/${workspaceId}/${date}/${shiftId}/`;
3867
+ console.log(`[S3ClipsService] Listing clips for workspace: ${workspaceId}, date: ${date}, shift: ${shiftId}`);
3863
3868
  const deduplicationKey = `list-s3-clips:${prefix}:${maxKeys || "all"}`;
3864
3869
  return this.requestCache.deduplicate(
3865
3870
  deduplicationKey,
@@ -4040,6 +4045,10 @@ var S3ClipsService = class {
4040
4045
  return sopConfig.default;
4041
4046
  }
4042
4047
  async getClipCounts(workspaceId, date, shiftId, buildIndex) {
4048
+ if (!isValidShiftId(shiftId)) {
4049
+ console.error(`[S3ClipsService] getClipCounts - Invalid shift ID: ${shiftId}. Must be 0 (day) or 1 (night)`);
4050
+ return buildIndex ? { counts: {}, videoIndex: { byCategory: /* @__PURE__ */ new Map(), allVideos: [], counts: {}, workspaceId, date, shiftId: "0", lastUpdated: /* @__PURE__ */ new Date() } } : {};
4051
+ }
4043
4052
  const deduplicationKey = `clip-counts:${workspaceId}:${date}:${shiftId}:${buildIndex ? "with-index" : "counts-only"}`;
4044
4053
  return this.requestCache.deduplicate(
4045
4054
  deduplicationKey,
@@ -4069,7 +4078,8 @@ var S3ClipsService = class {
4069
4078
  "cycle_completion",
4070
4079
  "bottleneck"
4071
4080
  ];
4072
- console.log(`[S3ClipsService] ${buildIndex ? "Building video index and counting" : "Fast counting"} clips for ${workspaceId} on ${date}, shift ${shiftId}`);
4081
+ const shiftName = shiftId === 0 || shiftId === "0" ? "Day" : "Night";
4082
+ console.log(`[S3ClipsService] ${buildIndex ? "Building video index and counting" : "Fast counting"} clips for ${workspaceId} on ${date}, shift ${shiftId} (${shiftName} Shift)`);
4073
4083
  const startTime = performance.now();
4074
4084
  const videoIndex = buildIndex ? {
4075
4085
  byCategory: /* @__PURE__ */ new Map(),
@@ -4216,6 +4226,10 @@ var S3ClipsService = class {
4216
4226
  * Get first clip for a specific category with deduplication
4217
4227
  */
4218
4228
  async getFirstClipForCategory(workspaceId, date, shiftId, category) {
4229
+ if (!isValidShiftId(shiftId)) {
4230
+ console.error(`[S3ClipsService] getFirstClipForCategory - Invalid shift ID: ${shiftId}. Must be 0 (day) or 1 (night)`);
4231
+ return null;
4232
+ }
4219
4233
  const deduplicationKey = `first-clip:${workspaceId}:${date}:${shiftId}:${category}`;
4220
4234
  return this.requestCache.deduplicate(
4221
4235
  deduplicationKey,
@@ -11623,7 +11637,18 @@ var usePrefetchClipCounts = ({
11623
11637
  }, [subscriberId]);
11624
11638
  const prefetchParams = React19.useMemo(() => {
11625
11639
  const operationalDate = date || getOperationalDate();
11626
- const shiftStr = shift?.toString() || "0";
11640
+ let shiftStr;
11641
+ if (shift !== void 0 && shift !== null) {
11642
+ shiftStr = shift.toString();
11643
+ console.log(`[usePrefetchClipCounts] Using provided shift: ${shiftStr} for date: ${operationalDate}`);
11644
+ } else if (date) {
11645
+ shiftStr = "0";
11646
+ console.log(`[usePrefetchClipCounts] No shift provided for historical date ${date}, defaulting to day shift (0)`);
11647
+ } else {
11648
+ const currentShift = getCurrentShift2();
11649
+ shiftStr = currentShift.shiftId.toString();
11650
+ console.log(`[usePrefetchClipCounts] Using current operational shift: ${shiftStr} (${currentShift.shiftName})`);
11651
+ }
11627
11652
  return {
11628
11653
  workspaceId: workspaceId || "",
11629
11654
  date: operationalDate,
@@ -26290,6 +26315,21 @@ var BottlenecksContent = ({
26290
26315
  }
26291
26316
  return videoPrefetchManager.getS3Service(dashboardConfig);
26292
26317
  }, [dashboardConfig]);
26318
+ const effectiveShift = React19.useMemo(() => {
26319
+ if (shift !== void 0 && shift !== null) {
26320
+ const shiftStr = shift.toString();
26321
+ console.log(`[BottlenecksContent] Using provided shift: ${shiftStr} for date: ${date}`);
26322
+ return shiftStr;
26323
+ }
26324
+ if (date) {
26325
+ console.log(`[BottlenecksContent] No shift provided for historical date ${date}, defaulting to day shift (0)`);
26326
+ return "0";
26327
+ } else {
26328
+ const currentShift = getCurrentShift2();
26329
+ console.log(`[BottlenecksContent] Using current operational shift: ${currentShift.shiftId} (${currentShift.shiftName})`);
26330
+ return currentShift.shiftId.toString();
26331
+ }
26332
+ }, [shift, date]);
26293
26333
  const {
26294
26334
  data: prefetchData,
26295
26335
  isFullyIndexed,
@@ -26298,7 +26338,7 @@ var BottlenecksContent = ({
26298
26338
  } = usePrefetchClipCounts({
26299
26339
  workspaceId,
26300
26340
  date: date || getOperationalDate(),
26301
- shift: shift?.toString() || "0",
26341
+ shift: effectiveShift,
26302
26342
  enabled: !!workspaceId && !!s3ClipsService,
26303
26343
  buildIndex: true
26304
26344
  });
@@ -26312,7 +26352,7 @@ var BottlenecksContent = ({
26312
26352
  fetchInProgressRef.current.add(operationKey);
26313
26353
  try {
26314
26354
  const operationalDate = date || getOperationalDate();
26315
- const shiftStr = shift?.toString() || "0";
26355
+ const shiftStr = effectiveShift;
26316
26356
  console.log(`[BottlenecksContent] Fetching clip counts directly for ${workspaceId}`);
26317
26357
  const cacheKey = `clip-counts:${workspaceId}:${operationalDate}:${shiftStr}`;
26318
26358
  const cachedResult = await smartVideoCache.getClipCounts(cacheKey);
@@ -26353,7 +26393,7 @@ var BottlenecksContent = ({
26353
26393
  } finally {
26354
26394
  fetchInProgressRef.current.delete(operationKey);
26355
26395
  }
26356
- }, [workspaceId, date, s3ClipsService, shift, dashboardConfig, updateClipCounts, updateVideoIndex]);
26396
+ }, [workspaceId, date, s3ClipsService, effectiveShift, dashboardConfig, updateClipCounts, updateVideoIndex]);
26357
26397
  const loadingCategoryRef = React19.useRef(null);
26358
26398
  const videoRetryCountRef = React19.useRef(0);
26359
26399
  const loadingVideosRef = React19.useRef(/* @__PURE__ */ new Set());
@@ -26401,7 +26441,7 @@ var BottlenecksContent = ({
26401
26441
  }
26402
26442
  if (!video) {
26403
26443
  const operationalDate = date || getOperationalDate();
26404
- const shiftStr = shift?.toString() || "0";
26444
+ const shiftStr = effectiveShift;
26405
26445
  video = await s3ClipsService.getClipByIndex(
26406
26446
  workspaceId,
26407
26447
  operationalDate,
@@ -26434,7 +26474,7 @@ var BottlenecksContent = ({
26434
26474
  Promise.all(loadPromises).catch((err) => {
26435
26475
  console.warn("[ensureVideosLoaded] Some videos failed to preload:", err);
26436
26476
  });
26437
- }, [s3ClipsService, workspaceId, clipCounts, sopCategories, date, shift]);
26477
+ }, [s3ClipsService, workspaceId, clipCounts, sopCategories, date, effectiveShift]);
26438
26478
  const loadFirstVideoForCategory = React19.useCallback(async (category) => {
26439
26479
  if (!workspaceId || !s3ClipsService || !isMountedRef.current) return;
26440
26480
  const targetCategory = category || activeFilterRef.current;
@@ -26450,7 +26490,7 @@ var BottlenecksContent = ({
26450
26490
  }
26451
26491
  try {
26452
26492
  const operationalDate = date || getOperationalDate();
26453
- const shiftStr = shift?.toString() || "0";
26493
+ const shiftStr = effectiveShift;
26454
26494
  if (!clipCounts[targetCategory] && !videoIndex) {
26455
26495
  const cacheKey = `clip-counts:${workspaceId}:${operationalDate}:${shiftStr}`;
26456
26496
  const cachedResult = await smartVideoCache.getClipCounts(cacheKey);
@@ -26532,12 +26572,12 @@ var BottlenecksContent = ({
26532
26572
  loadingCategoryRef.current = null;
26533
26573
  fetchInProgressRef.current.delete(operationKey);
26534
26574
  }
26535
- }, [workspaceId, date, s3ClipsService, clipCounts, videoIndex, shift, updateClipCounts, updateVideoIndex]);
26575
+ }, [workspaceId, date, s3ClipsService, clipCounts, videoIndex, effectiveShift, updateClipCounts, updateVideoIndex]);
26536
26576
  React19.useEffect(() => {
26537
26577
  if (s3ClipsService && !prefetchData) {
26538
26578
  fetchClipCounts();
26539
26579
  }
26540
- }, [workspaceId, date, shift, s3ClipsService, fetchClipCounts, updateClipCounts, updateVideoIndex, prefetchData]);
26580
+ }, [workspaceId, date, effectiveShift, s3ClipsService, fetchClipCounts, updateClipCounts, updateVideoIndex, prefetchData]);
26541
26581
  React19.useEffect(() => {
26542
26582
  if (prefetchData) {
26543
26583
  console.log(`[BottlenecksContent] Received prefetch update - status: ${prefetchStatus}, videos: ${prefetchData.videoIndex.allVideos.length}, ID: ${prefetchData.videoIndex._debugId || "NO_ID"}`);
@@ -26724,7 +26764,7 @@ var BottlenecksContent = ({
26724
26764
  }
26725
26765
  if (!video && s3ClipsService) {
26726
26766
  const operationalDate = date || getOperationalDate();
26727
- const shiftStr = shift?.toString() || "0";
26767
+ const shiftStr = effectiveShift;
26728
26768
  video = await s3ClipsService.getClipByIndex(
26729
26769
  workspaceId,
26730
26770
  operationalDate,
@@ -26760,7 +26800,7 @@ var BottlenecksContent = ({
26760
26800
  }
26761
26801
  }
26762
26802
  }
26763
- }, [clipCounts, filteredVideos.length, s3ClipsService, workspaceId, date, shift]);
26803
+ }, [clipCounts, filteredVideos.length, s3ClipsService, workspaceId, date, effectiveShift]);
26764
26804
  const handlePrevious = React19.useCallback(() => {
26765
26805
  if (!isMountedRef.current) return;
26766
26806
  const currentIdx = currentIndexRef.current;
package/dist/index.mjs CHANGED
@@ -3829,7 +3829,12 @@ var S3ClipsService = class {
3829
3829
  */
3830
3830
  async listS3Clips(params) {
3831
3831
  const { workspaceId, date, shiftId, maxKeys } = params;
3832
+ if (!isValidShiftId(shiftId)) {
3833
+ console.error(`[S3ClipsService] Invalid shift ID: ${shiftId}. Must be 0 (day) or 1 (night)`);
3834
+ return [];
3835
+ }
3832
3836
  const prefix = `sop_violations/${workspaceId}/${date}/${shiftId}/`;
3837
+ console.log(`[S3ClipsService] Listing clips for workspace: ${workspaceId}, date: ${date}, shift: ${shiftId}`);
3833
3838
  const deduplicationKey = `list-s3-clips:${prefix}:${maxKeys || "all"}`;
3834
3839
  return this.requestCache.deduplicate(
3835
3840
  deduplicationKey,
@@ -4010,6 +4015,10 @@ var S3ClipsService = class {
4010
4015
  return sopConfig.default;
4011
4016
  }
4012
4017
  async getClipCounts(workspaceId, date, shiftId, buildIndex) {
4018
+ if (!isValidShiftId(shiftId)) {
4019
+ console.error(`[S3ClipsService] getClipCounts - Invalid shift ID: ${shiftId}. Must be 0 (day) or 1 (night)`);
4020
+ return buildIndex ? { counts: {}, videoIndex: { byCategory: /* @__PURE__ */ new Map(), allVideos: [], counts: {}, workspaceId, date, shiftId: "0", lastUpdated: /* @__PURE__ */ new Date() } } : {};
4021
+ }
4013
4022
  const deduplicationKey = `clip-counts:${workspaceId}:${date}:${shiftId}:${buildIndex ? "with-index" : "counts-only"}`;
4014
4023
  return this.requestCache.deduplicate(
4015
4024
  deduplicationKey,
@@ -4039,7 +4048,8 @@ var S3ClipsService = class {
4039
4048
  "cycle_completion",
4040
4049
  "bottleneck"
4041
4050
  ];
4042
- console.log(`[S3ClipsService] ${buildIndex ? "Building video index and counting" : "Fast counting"} clips for ${workspaceId} on ${date}, shift ${shiftId}`);
4051
+ const shiftName = shiftId === 0 || shiftId === "0" ? "Day" : "Night";
4052
+ console.log(`[S3ClipsService] ${buildIndex ? "Building video index and counting" : "Fast counting"} clips for ${workspaceId} on ${date}, shift ${shiftId} (${shiftName} Shift)`);
4043
4053
  const startTime = performance.now();
4044
4054
  const videoIndex = buildIndex ? {
4045
4055
  byCategory: /* @__PURE__ */ new Map(),
@@ -4186,6 +4196,10 @@ var S3ClipsService = class {
4186
4196
  * Get first clip for a specific category with deduplication
4187
4197
  */
4188
4198
  async getFirstClipForCategory(workspaceId, date, shiftId, category) {
4199
+ if (!isValidShiftId(shiftId)) {
4200
+ console.error(`[S3ClipsService] getFirstClipForCategory - Invalid shift ID: ${shiftId}. Must be 0 (day) or 1 (night)`);
4201
+ return null;
4202
+ }
4189
4203
  const deduplicationKey = `first-clip:${workspaceId}:${date}:${shiftId}:${category}`;
4190
4204
  return this.requestCache.deduplicate(
4191
4205
  deduplicationKey,
@@ -11593,7 +11607,18 @@ var usePrefetchClipCounts = ({
11593
11607
  }, [subscriberId]);
11594
11608
  const prefetchParams = useMemo(() => {
11595
11609
  const operationalDate = date || getOperationalDate();
11596
- const shiftStr = shift?.toString() || "0";
11610
+ let shiftStr;
11611
+ if (shift !== void 0 && shift !== null) {
11612
+ shiftStr = shift.toString();
11613
+ console.log(`[usePrefetchClipCounts] Using provided shift: ${shiftStr} for date: ${operationalDate}`);
11614
+ } else if (date) {
11615
+ shiftStr = "0";
11616
+ console.log(`[usePrefetchClipCounts] No shift provided for historical date ${date}, defaulting to day shift (0)`);
11617
+ } else {
11618
+ const currentShift = getCurrentShift2();
11619
+ shiftStr = currentShift.shiftId.toString();
11620
+ console.log(`[usePrefetchClipCounts] Using current operational shift: ${shiftStr} (${currentShift.shiftName})`);
11621
+ }
11597
11622
  return {
11598
11623
  workspaceId: workspaceId || "",
11599
11624
  date: operationalDate,
@@ -26260,6 +26285,21 @@ var BottlenecksContent = ({
26260
26285
  }
26261
26286
  return videoPrefetchManager.getS3Service(dashboardConfig);
26262
26287
  }, [dashboardConfig]);
26288
+ const effectiveShift = useMemo(() => {
26289
+ if (shift !== void 0 && shift !== null) {
26290
+ const shiftStr = shift.toString();
26291
+ console.log(`[BottlenecksContent] Using provided shift: ${shiftStr} for date: ${date}`);
26292
+ return shiftStr;
26293
+ }
26294
+ if (date) {
26295
+ console.log(`[BottlenecksContent] No shift provided for historical date ${date}, defaulting to day shift (0)`);
26296
+ return "0";
26297
+ } else {
26298
+ const currentShift = getCurrentShift2();
26299
+ console.log(`[BottlenecksContent] Using current operational shift: ${currentShift.shiftId} (${currentShift.shiftName})`);
26300
+ return currentShift.shiftId.toString();
26301
+ }
26302
+ }, [shift, date]);
26263
26303
  const {
26264
26304
  data: prefetchData,
26265
26305
  isFullyIndexed,
@@ -26268,7 +26308,7 @@ var BottlenecksContent = ({
26268
26308
  } = usePrefetchClipCounts({
26269
26309
  workspaceId,
26270
26310
  date: date || getOperationalDate(),
26271
- shift: shift?.toString() || "0",
26311
+ shift: effectiveShift,
26272
26312
  enabled: !!workspaceId && !!s3ClipsService,
26273
26313
  buildIndex: true
26274
26314
  });
@@ -26282,7 +26322,7 @@ var BottlenecksContent = ({
26282
26322
  fetchInProgressRef.current.add(operationKey);
26283
26323
  try {
26284
26324
  const operationalDate = date || getOperationalDate();
26285
- const shiftStr = shift?.toString() || "0";
26325
+ const shiftStr = effectiveShift;
26286
26326
  console.log(`[BottlenecksContent] Fetching clip counts directly for ${workspaceId}`);
26287
26327
  const cacheKey = `clip-counts:${workspaceId}:${operationalDate}:${shiftStr}`;
26288
26328
  const cachedResult = await smartVideoCache.getClipCounts(cacheKey);
@@ -26323,7 +26363,7 @@ var BottlenecksContent = ({
26323
26363
  } finally {
26324
26364
  fetchInProgressRef.current.delete(operationKey);
26325
26365
  }
26326
- }, [workspaceId, date, s3ClipsService, shift, dashboardConfig, updateClipCounts, updateVideoIndex]);
26366
+ }, [workspaceId, date, s3ClipsService, effectiveShift, dashboardConfig, updateClipCounts, updateVideoIndex]);
26327
26367
  const loadingCategoryRef = useRef(null);
26328
26368
  const videoRetryCountRef = useRef(0);
26329
26369
  const loadingVideosRef = useRef(/* @__PURE__ */ new Set());
@@ -26371,7 +26411,7 @@ var BottlenecksContent = ({
26371
26411
  }
26372
26412
  if (!video) {
26373
26413
  const operationalDate = date || getOperationalDate();
26374
- const shiftStr = shift?.toString() || "0";
26414
+ const shiftStr = effectiveShift;
26375
26415
  video = await s3ClipsService.getClipByIndex(
26376
26416
  workspaceId,
26377
26417
  operationalDate,
@@ -26404,7 +26444,7 @@ var BottlenecksContent = ({
26404
26444
  Promise.all(loadPromises).catch((err) => {
26405
26445
  console.warn("[ensureVideosLoaded] Some videos failed to preload:", err);
26406
26446
  });
26407
- }, [s3ClipsService, workspaceId, clipCounts, sopCategories, date, shift]);
26447
+ }, [s3ClipsService, workspaceId, clipCounts, sopCategories, date, effectiveShift]);
26408
26448
  const loadFirstVideoForCategory = useCallback(async (category) => {
26409
26449
  if (!workspaceId || !s3ClipsService || !isMountedRef.current) return;
26410
26450
  const targetCategory = category || activeFilterRef.current;
@@ -26420,7 +26460,7 @@ var BottlenecksContent = ({
26420
26460
  }
26421
26461
  try {
26422
26462
  const operationalDate = date || getOperationalDate();
26423
- const shiftStr = shift?.toString() || "0";
26463
+ const shiftStr = effectiveShift;
26424
26464
  if (!clipCounts[targetCategory] && !videoIndex) {
26425
26465
  const cacheKey = `clip-counts:${workspaceId}:${operationalDate}:${shiftStr}`;
26426
26466
  const cachedResult = await smartVideoCache.getClipCounts(cacheKey);
@@ -26502,12 +26542,12 @@ var BottlenecksContent = ({
26502
26542
  loadingCategoryRef.current = null;
26503
26543
  fetchInProgressRef.current.delete(operationKey);
26504
26544
  }
26505
- }, [workspaceId, date, s3ClipsService, clipCounts, videoIndex, shift, updateClipCounts, updateVideoIndex]);
26545
+ }, [workspaceId, date, s3ClipsService, clipCounts, videoIndex, effectiveShift, updateClipCounts, updateVideoIndex]);
26506
26546
  useEffect(() => {
26507
26547
  if (s3ClipsService && !prefetchData) {
26508
26548
  fetchClipCounts();
26509
26549
  }
26510
- }, [workspaceId, date, shift, s3ClipsService, fetchClipCounts, updateClipCounts, updateVideoIndex, prefetchData]);
26550
+ }, [workspaceId, date, effectiveShift, s3ClipsService, fetchClipCounts, updateClipCounts, updateVideoIndex, prefetchData]);
26511
26551
  useEffect(() => {
26512
26552
  if (prefetchData) {
26513
26553
  console.log(`[BottlenecksContent] Received prefetch update - status: ${prefetchStatus}, videos: ${prefetchData.videoIndex.allVideos.length}, ID: ${prefetchData.videoIndex._debugId || "NO_ID"}`);
@@ -26694,7 +26734,7 @@ var BottlenecksContent = ({
26694
26734
  }
26695
26735
  if (!video && s3ClipsService) {
26696
26736
  const operationalDate = date || getOperationalDate();
26697
- const shiftStr = shift?.toString() || "0";
26737
+ const shiftStr = effectiveShift;
26698
26738
  video = await s3ClipsService.getClipByIndex(
26699
26739
  workspaceId,
26700
26740
  operationalDate,
@@ -26730,7 +26770,7 @@ var BottlenecksContent = ({
26730
26770
  }
26731
26771
  }
26732
26772
  }
26733
- }, [clipCounts, filteredVideos.length, s3ClipsService, workspaceId, date, shift]);
26773
+ }, [clipCounts, filteredVideos.length, s3ClipsService, workspaceId, date, effectiveShift]);
26734
26774
  const handlePrevious = useCallback(() => {
26735
26775
  if (!isMountedRef.current) return;
26736
26776
  const currentIdx = currentIndexRef.current;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "6.4.0",
3
+ "version": "6.4.1",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",