@optifye/dashboard-core 6.12.14 → 6.12.16

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.
@@ -0,0 +1 @@
1
+ export * from './dist/automation';
package/automation.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/automation.js');
@@ -0,0 +1,444 @@
1
+ import React__default from 'react';
2
+
3
+ type VideoGridMetricMode = 'efficiency' | 'recent_flow' | 'recent_flow_wip_gated';
4
+ declare const normalizeVideoGridMetricMode: (value: unknown, assemblyEnabled?: boolean) => VideoGridMetricMode;
5
+ declare const isRecentFlowVideoGridMetricMode: (value: unknown, assemblyEnabled?: boolean) => boolean;
6
+ declare const isWipGatedVideoGridMetricMode: (value: unknown, assemblyEnabled?: boolean) => boolean;
7
+
8
+ /** One row of per-SKU workspace metrics. Backend computes; frontend renders. */
9
+ interface SkuBreakdownItem {
10
+ /** UUID — `skus.id`. Stable identifier for selectors and threshold writes. */
11
+ sku_id: string;
12
+ /** Technical code — `skus.sku_id` (e.g. `IMT_BIG`). */
13
+ sku_code: string;
14
+ /** User-facing label — `skus.display_name`, falling back to `sku_code`. */
15
+ sku_display_name?: string | null;
16
+ sku_definition: string;
17
+ is_dummy: boolean;
18
+ total_output: number;
19
+ target_output: number;
20
+ avg_pph: number;
21
+ pph_threshold: number;
22
+ avg_cycle_time: number;
23
+ ideal_cycle_time: number;
24
+ efficiency: number;
25
+ /** Active minutes the SKU was present in this shift; used for ranking. */
26
+ active_minutes: number;
27
+ intervals: Array<{
28
+ start_time: string;
29
+ end_time: string | null;
30
+ }>;
31
+ }
32
+ /** Hourly-chart divider segment. Dummy excluded by backend. */
33
+ interface SkuSegmentItem {
34
+ sku_id: string;
35
+ sku_code: string;
36
+ sku_display_name?: string | null;
37
+ start_time: string;
38
+ end_time: string | null;
39
+ pph_threshold: number;
40
+ }
41
+ /** Per-SKU line-level breakdown (subset of workspace breakdown). */
42
+ interface LineSkuBreakdownItem {
43
+ sku_id: string;
44
+ sku_code: string;
45
+ sku_display_name?: string | null;
46
+ is_dummy: boolean;
47
+ current_output: number;
48
+ ideal_output: number;
49
+ avg_efficiency: number;
50
+ /**
51
+ * Raw per-SKU target from `line_thresholds` (or the dummy-SKU fallback
52
+ * via `update_line_metrics`'s LATERAL lookup when no per-SKU row exists).
53
+ */
54
+ line_threshold: number | null;
55
+ /**
56
+ * Active-time-weighted projection per-SKU (line-scope lift of
57
+ * `pm.total_day_output_recalculated`, added by db migration v1_20).
58
+ * Semantics:
59
+ * * Active SKU mid-shift: projected full-day output if it continues.
60
+ * * Finalized SKU: raw_target × active_fraction (realized share).
61
+ * Per-SKU UIs should prefer this field for the displayed target so
62
+ * efficiency reflects real SKU activity rather than the shared line
63
+ * target. Null on rows written before v1_20 (not yet backfilled) and
64
+ * on Nahar rows (quality_metrics path doesn't populate it).
65
+ */
66
+ line_threshold_recalculated?: number | null;
67
+ /** Summed real-SKU `performance_metrics.total_day_output_recalculated`. */
68
+ output_target_recalculated?: number | null;
69
+ total_workspaces?: number;
70
+ underperforming_workspaces?: number;
71
+ underperforming_workspace_names?: string[];
72
+ underperforming_workspace_uuids?: string[];
73
+ output_array?: number[];
74
+ output_hourly?: Record<string, any>;
75
+ idle_time_hourly?: Record<string, any>;
76
+ /**
77
+ * Poorest-performing workspaces for THIS SKU specifically (sorted by
78
+ * efficiency ascending, top 5). Excludes rows where the SKU had no
79
+ * activity. Backend builds this from `workspace_metrics_by_sku[sku_id]`.
80
+ * Absent on payloads from pre-Step-3 backends.
81
+ */
82
+ poorest_performing_workspaces?: PoorPerformingWorkspace[];
83
+ }
84
+ /** Currently-active SKU on a workspace (sourced from sku_presence end_time IS NULL). */
85
+ interface CurrentWorkspaceSKU {
86
+ sku_uuid: string;
87
+ sku_code: string;
88
+ sku_display_name?: string | null;
89
+ sku_definition: string;
90
+ start_time: string;
91
+ is_dummy: boolean;
92
+ }
93
+ interface LineInfo {
94
+ line_id: string;
95
+ line_name: string;
96
+ company_id: string;
97
+ company_name: string;
98
+ factory_id: string;
99
+ factory_name: string;
100
+ shift_id: number;
101
+ date: string;
102
+ monitoring_mode?: 'output' | 'uptime';
103
+ assembly?: boolean | null;
104
+ recent_flow_window_minutes?: number;
105
+ metrics: LineDetailedMetrics;
106
+ }
107
+ /**
108
+ * Aggregated line metrics (legacy fields plus optional multi-SKU additions).
109
+ *
110
+ * The five SKU fields are populated only when `enable_sku_detection=true` AND
111
+ * at least one real SKU row exists (decision #12). When absent, consumers
112
+ * must fall back to the legacy aggregate fields.
113
+ */
114
+ interface LineDetailedMetrics {
115
+ avg_efficiency: number;
116
+ avg_cycle_time: number;
117
+ current_output: number;
118
+ ideal_output: number;
119
+ total_workspaces: number;
120
+ underperforming_workspaces: number;
121
+ underperforming_workspace_names: string[];
122
+ underperforming_workspace_uuids: string[];
123
+ output_array: number[];
124
+ output_hourly?: Record<string, number[]>;
125
+ hourly_target_output?: Array<number | null> | null;
126
+ hourly_target_output_by_sku?: Record<string, Array<number | null> | null>;
127
+ line_threshold: number;
128
+ /** Summed real-SKU `performance_metrics.total_day_output_recalculated`. */
129
+ output_target_recalculated?: number | null;
130
+ threshold_pph?: number;
131
+ shift_start?: string;
132
+ shift_end?: string;
133
+ last_updated?: string;
134
+ poorest_performing_workspaces?: PoorPerformingWorkspace[];
135
+ avg_idle_time_seconds?: number;
136
+ idle_time_hourly?: Record<string, any> | null;
137
+ /** True iff `enable_sku_detection=true` AND `real_sku_count >= 1`. */
138
+ sku_aware?: boolean;
139
+ /** Distinct count of non-dummy SKU rows for this (line, date, shift). */
140
+ real_sku_count?: number;
141
+ /** Per-SKU breakdown for the Line Detail selector. Includes dummy with `is_dummy=true`. */
142
+ sku_breakdown?: LineSkuBreakdownItem[];
143
+ /** Hourly-chart divider segments (dummy excluded). */
144
+ sku_segments?: SkuSegmentItem[];
145
+ }
146
+ interface PoorPerformingWorkspace {
147
+ workspace_name: string;
148
+ efficiency: number;
149
+ action_count: number;
150
+ action_threshold: number;
151
+ }
152
+ interface WorkspaceMetrics {
153
+ company_id: string;
154
+ line_id: string;
155
+ shift_id: number;
156
+ date: string;
157
+ workspace_uuid: string | null;
158
+ workspace_name: string;
159
+ action_count: number;
160
+ pph: number;
161
+ pph_threshold?: number;
162
+ performance_score: 0 | 1 | 2;
163
+ avg_cycle_time: number;
164
+ ideal_cycle_time?: number;
165
+ trend: 0 | 1 | 2;
166
+ predicted_output: number;
167
+ efficiency: number;
168
+ action_threshold: number;
169
+ displayName?: string;
170
+ monitoring_mode?: 'output' | 'uptime';
171
+ idle_time?: number;
172
+ idle_time_hourly?: Record<string, any> | null;
173
+ shift_start?: string;
174
+ shift_end?: string;
175
+ assembly_enabled?: boolean;
176
+ video_grid_metric_mode?: VideoGridMetricMode;
177
+ action_type?: 'assembly' | 'output' | null;
178
+ action_family?: 'assembly' | 'output' | 'other' | null;
179
+ action_display_name?: string | null;
180
+ leaderboard_metric_kind?: 'efficiency' | 'recent_flow_shift_average';
181
+ leaderboard_value?: number | null;
182
+ avg_recent_flow?: number | null;
183
+ recent_flow_mode?: 'computed' | 'hold' | 'unavailable';
184
+ recent_flow_percent?: number | null;
185
+ recent_flow_actual_rate_pph?: number | null;
186
+ recent_flow_healthy_rate_pph?: number | null;
187
+ recent_flow_window_minutes?: number | null;
188
+ recent_flow_effective_end_at?: string | null;
189
+ recent_flow_computed_at?: string | null;
190
+ recent_flow_forced_zero_after_shift?: boolean | null;
191
+ scheduled_break_active?: boolean;
192
+ incoming_wip_current?: number | null;
193
+ incoming_wip_effective_at?: string | null;
194
+ incoming_wip_buffer_name?: string | null;
195
+ /**
196
+ * When present, controls whether the UI should show the exclamation indicator for this workstation.
197
+ * - Flow-configured lines: true only when a WIP alert is active for a buffer that outputs to this workstation.
198
+ * - Non-flow lines: true when efficiency is critically low (legacy behavior).
199
+ */
200
+ show_exclamation?: boolean;
201
+ }
202
+ interface WorkspaceDetailedMetrics {
203
+ line_id: string;
204
+ line_name: string;
205
+ line_assembly_enabled?: boolean;
206
+ workspace_name: string;
207
+ workspace_display_name?: string | null;
208
+ workspace_id: string;
209
+ company_id: string;
210
+ company_name: string;
211
+ date: string;
212
+ shift_id: number;
213
+ action_name: string;
214
+ action_type?: 'assembly' | 'output' | null;
215
+ action_family?: 'assembly' | 'output' | 'other' | null;
216
+ action_display_name?: string | null;
217
+ monitoring_mode?: 'output' | 'uptime';
218
+ shift_start: string;
219
+ shift_end: string;
220
+ shift_type: string;
221
+ pph_threshold: number;
222
+ target_output: number;
223
+ avg_pph: number;
224
+ avg_cycle_time: number;
225
+ ideal_cycle_time: number;
226
+ avg_efficiency: number;
227
+ total_actions: number;
228
+ hourly_action_counts: number[];
229
+ hourly_target_output?: Array<number | null> | null;
230
+ hourly_cycle_times?: number[];
231
+ cycle_completion_clip_count?: number | null;
232
+ cycle_time_data_status?: 'available' | 'missing_clips' | null;
233
+ cycle_time_timezone?: string | null;
234
+ workspace_rank: number;
235
+ total_workspaces: number;
236
+ ideal_output_until_now: number;
237
+ output_difference: number;
238
+ idle_time?: number;
239
+ idle_time_hourly?: Record<string, string[]>;
240
+ compliance_efficiency?: number;
241
+ sop_check?: Record<string, number>;
242
+ /** True iff `enable_sku_detection=true` AND `real_sku_count >= 1`. */
243
+ sku_aware?: boolean;
244
+ /**
245
+ * True when only dummy rows exist for this workspace/shift. Default `true`
246
+ * for legacy lines so the SKU UI is hidden by default. Backend authoritative.
247
+ */
248
+ is_dummy_only?: boolean;
249
+ /** Distinct count of non-dummy SKU rows for this (workspace, date, shift). */
250
+ real_sku_count?: number;
251
+ /** Per-SKU workspace breakdown ordered by `active_minutes desc, total_output desc`. */
252
+ sku_breakdown?: SkuBreakdownItem[];
253
+ /** Hourly-chart divider segments (dummy excluded). */
254
+ sku_segments?: SkuSegmentItem[];
255
+ }
256
+ interface DashboardKPIs {
257
+ underperformingWorkers: {
258
+ current: number;
259
+ total: number;
260
+ change: number;
261
+ };
262
+ efficiency: {
263
+ value: number;
264
+ change: number;
265
+ };
266
+ outputProgress: {
267
+ current: number;
268
+ target: number;
269
+ change: number;
270
+ idealOutput: number;
271
+ };
272
+ qualityCompliance: {
273
+ value: number;
274
+ change: number;
275
+ };
276
+ avgCycleTime: {
277
+ value: number;
278
+ change: number;
279
+ };
280
+ }
281
+ interface LineIssueResolutionSummary {
282
+ mean_resolution_seconds: number | null;
283
+ median_resolution_seconds: number | null;
284
+ resolved_issue_count: number;
285
+ open_issue_count: number;
286
+ oldest_open_issue_age_seconds: number | null;
287
+ total_issue_seconds: number;
288
+ }
289
+ interface ValueDelta {
290
+ current: number | null;
291
+ previous: number | null;
292
+ }
293
+ interface PercentageDelta extends ValueDelta {
294
+ delta_pp: number | null;
295
+ }
296
+ interface CountDelta extends ValueDelta {
297
+ delta_count: number | null;
298
+ }
299
+ interface DurationDelta extends ValueDelta {
300
+ delta_seconds: number | null;
301
+ }
302
+ interface KpiTrend {
303
+ efficiency: PercentageDelta;
304
+ outputProgress: PercentageDelta;
305
+ underperformingWorkers: CountDelta;
306
+ avgCycleTime: DurationDelta;
307
+ }
308
+ interface MonthlyTrendSummary {
309
+ avg_efficiency?: PercentageDelta;
310
+ avg_daily_output?: PercentageDelta;
311
+ avg_cycle_time?: DurationDelta;
312
+ avg_idle_time?: DurationDelta;
313
+ avg_daily_stoppages?: CountDelta;
314
+ }
315
+
316
+ interface Workspace {
317
+ id: string;
318
+ line_id: string;
319
+ workspace_id: string;
320
+ action_id: string;
321
+ action_type?: 'assembly' | 'output';
322
+ action_display_name?: string | null;
323
+ action_pph_threshold: number | null;
324
+ action_cycle_time: number | null;
325
+ action_total_day_output: number | null;
326
+ enable: boolean;
327
+ }
328
+ interface WorkspaceCropRect {
329
+ x: number;
330
+ y: number;
331
+ width: number;
332
+ height: number;
333
+ }
334
+ interface WorkspaceVideoStream {
335
+ workspace_id: string;
336
+ camera_uuid: string;
337
+ stream_camera_uuid: string;
338
+ hls_url: string;
339
+ crop?: WorkspaceCropRect | null;
340
+ }
341
+ interface WorkspaceCameraIpInfo {
342
+ workspace_id: string;
343
+ camera_ip: string | null;
344
+ source_camera_uuid: string | null;
345
+ effective_camera_uuid: string | null;
346
+ resolution_mode: 'direct' | 'redirect' | null;
347
+ }
348
+ interface ActionThreshold {
349
+ line_id: string;
350
+ shift_id: number;
351
+ action_id: string;
352
+ workspace_id: string;
353
+ date: string;
354
+ pph_threshold: number;
355
+ ideal_cycle_time: number;
356
+ total_day_output: number;
357
+ action_name: string | null;
358
+ action_family?: 'assembly' | 'output' | 'other' | null;
359
+ display_name?: string | null;
360
+ updated_by: string;
361
+ sku_id?: string;
362
+ created_at?: string;
363
+ last_updated?: string;
364
+ }
365
+ interface WorkspaceActionUpdate {
366
+ id: string;
367
+ action_id: string;
368
+ }
369
+ interface LineThreshold {
370
+ factory_id: string;
371
+ line_id: string;
372
+ date: string;
373
+ shift_id: number;
374
+ product_code: string;
375
+ threshold_day_output: number;
376
+ threshold_pph: number;
377
+ sku_id?: string;
378
+ }
379
+ interface ShiftConfiguration {
380
+ id?: string;
381
+ lineId: string;
382
+ dayShift: {
383
+ startTime: string;
384
+ endTime: string;
385
+ breaks: {
386
+ startTime: string;
387
+ endTime: string;
388
+ duration: number;
389
+ }[];
390
+ };
391
+ nightShift: {
392
+ startTime: string;
393
+ endTime: string;
394
+ breaks: {
395
+ startTime: string;
396
+ endTime: string;
397
+ duration: number;
398
+ }[];
399
+ };
400
+ date: string;
401
+ updatedBy: string;
402
+ }
403
+ interface ShiftConfigurationRecord {
404
+ id: string;
405
+ line_id: string;
406
+ day_shift: object;
407
+ night_shift: object;
408
+ date: string;
409
+ updated_by: string;
410
+ created_at: string;
411
+ last_updated: string;
412
+ }
413
+
414
+ interface EfficiencyLegendUpdate {
415
+ green_min: number;
416
+ green_max: number;
417
+ yellow_min: number;
418
+ yellow_max: number;
419
+ red_min: number;
420
+ red_max: number;
421
+ critical_threshold: number;
422
+ }
423
+
424
+ type SnapshotVideoStatus = {
425
+ expectedVideoCount: number;
426
+ readyVideoCount: number;
427
+ status: 'loading' | 'ready' | 'no_videos';
428
+ updatedAt: string;
429
+ };
430
+ declare global {
431
+ interface Window {
432
+ __OPTIFYE_SNAPSHOT_READY__?: boolean;
433
+ __OPTIFYE_SNAPSHOT_VIDEO_STATUS__?: SnapshotVideoStatus;
434
+ }
435
+ }
436
+ interface RecentFlowSnapshotGridProps {
437
+ workspaces: WorkspaceMetrics[];
438
+ videoStreamsByWorkspaceId: Record<string, WorkspaceVideoStream>;
439
+ legend?: EfficiencyLegendUpdate | null;
440
+ className?: string;
441
+ }
442
+ declare const RecentFlowSnapshotGrid: React__default.FC<RecentFlowSnapshotGridProps>;
443
+
444
+ export { type ActionThreshold as A, type CurrentWorkspaceSKU as C, type DashboardKPIs as D, type EfficiencyLegendUpdate as E, type KpiTrend as K, type LineInfo as L, type MonthlyTrendSummary as M, type PoorPerformingWorkspace as P, type RecentFlowSnapshotGridProps as R, type SkuBreakdownItem as S, type VideoGridMetricMode as V, type WorkspaceMetrics as W, type WorkspaceDetailedMetrics as a, type SkuSegmentItem as b, type LineSkuBreakdownItem as c, type WorkspaceVideoStream as d, type Workspace as e, type WorkspaceCameraIpInfo as f, type WorkspaceActionUpdate as g, type ShiftConfiguration as h, type LineIssueResolutionSummary as i, type LineDetailedMetrics as j, type ValueDelta as k, type PercentageDelta as l, type CountDelta as m, type DurationDelta as n, type WorkspaceCropRect as o, type LineThreshold as p, type ShiftConfigurationRecord as q, normalizeVideoGridMetricMode as r, isRecentFlowVideoGridMetricMode as s, isWipGatedVideoGridMetricMode as t, RecentFlowSnapshotGrid as u };