busroot-sdk 0.0.3 → 0.0.5

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.
@@ -1,5 +1,192 @@
1
1
  import { z } from 'zod';
2
2
 
3
+ declare enum RagStatus {
4
+ Red = "#cc3311",
5
+ Amber = "#ee7733",
6
+ Green = "#009988",
7
+ Blue = "#33bbee",
8
+ NA = "#CCCCCC",
9
+ }
10
+
11
+ declare const StationStatus = {
12
+ outOfShift: { label: "Out of Shift", colour: chroma("#DDDDDD") },
13
+ futureOutOfShift: { label: "Out of Shift (Future)", colour: chroma("#DDDDDD").darken(2) },
14
+ futureInShift: { label: "In Shift (Future)", colour: chroma("#DDDDDD").darken(1) },
15
+ noSchedule: { label: "No Schedule", colour: chroma("#ee7733") },
16
+ futureNoSchedule: { label: "Not Scheduled (Future)", colour: chroma("#ee7733").darken(1) },
17
+ nonProductionSchedule: { label: "Scheduled Non-Production", colour: chroma("#33bbee") },
18
+ futureNonProductionSchedule: { label: "Scheduled Non-Production (Future)", colour: chroma("#33bbee").darken(1) },
19
+ productionSchedule: { label: "Scheduled Production", colour: chroma("#009988") },
20
+ futureProductionSchedule: { label: "Scheduled Production (Future)", colour: chroma("#009988").darken(1) },
21
+ downtime: { label: "Unplanned Downtime", colour: chroma("#cc3311") },
22
+ disconnected: { label: "Connection Lost", colour: chroma("#8338ec") },
23
+ };
24
+
25
+ declare enum DowntimeType {
26
+ Stop = "stop",
27
+ Slow = "slow",
28
+ Manual = "manual",
29
+ StopUtilisation = "stop_utilisation",
30
+ }
31
+
32
+ declare enum DowntimeEventType {
33
+ Acknowledge = "acknowledge",
34
+ Estimate = "estimate",
35
+ Escalate = "escalate",
36
+ Cause = "cause",
37
+ Exclude = "exclude",
38
+ }
39
+
40
+ declare enum DowntimeFilterState {
41
+ Ongoing = "ongoing",
42
+ NotStartNotified = "not_start_notified",
43
+ NotEndNotified = "not_end_notified",
44
+ EscalatedOnly = "Escalated_only",
45
+ WithinADay = "day",
46
+ WithinAWeek = "week",
47
+ NoCause = "no_cause",
48
+ }
49
+
50
+ declare const GROUP_TAG_PREFIX = "group";
51
+
52
+ declare enum MessageType {
53
+ intouch = "intouch",
54
+ kepware = "iotgateway",
55
+ dau = "dau",
56
+ }
57
+
58
+ declare enum PRODUCTION_TYPE {
59
+ MANUAL = "manual",
60
+ TIMESERIES = "timeseries",
61
+ FROM_SPEED = "from-speed",
62
+ }
63
+
64
+ declare enum SCHEDULE_TYPE {
65
+ NON_PRODUCTION = "non_production",
66
+ PRODUCTION = "production",
67
+ }
68
+
69
+ declare enum UserRole {
70
+ customer = "customer",
71
+ oi = "oi",
72
+ blocked = "blocked",
73
+ partner = "partner",
74
+ }
75
+
76
+ declare enum AccountRole {
77
+ member = "member",
78
+ admin = "admin",
79
+ blocked = "blocked",
80
+ }
81
+
82
+ declare enum AuthType {
83
+ ui = "ui",
84
+ api = "api",
85
+ }
86
+
87
+ declare enum WeekDay {
88
+ Monday = "1",
89
+ Tuesday = "2",
90
+ Wednesday = "3",
91
+ Thursday = "4",
92
+ Friday = "5",
93
+ Saturday = "6",
94
+ Sunday = "7",
95
+ }
96
+
97
+ declare enum NOTIFICATION_PREFERENCE {
98
+ NONE = "none",
99
+ ALL = "all_issues",
100
+ DOWNTIME_SUMMARY = "downtime_summary",
101
+ }
102
+
103
+ declare enum DOWNTIME_DETECTION_MODE {
104
+ OFF = "off",
105
+ PRODUCTION_CYCLE_TIME = "production",
106
+ UTILISATION = "utilisation", // TODO: Rename this to PRODUCTIVE_STATUS
107
+ LINE_SPEED = "line_speed",
108
+ }
109
+
110
+ declare enum PRODUCTIVE_STATUS_MODE {
111
+ PRODUCTIVE_SIGNAL = "productive_signal",
112
+ ELECTRICAL_USAGE = "electrical_usage",
113
+ LINE_SPEED = "line_speed",
114
+ }
115
+
116
+ declare enum TIMESERIES_MESSAGE_TYPE {
117
+ BAD_PRODUCTION_COMPLETE = "BAD_PRODUCTION_COMPLETE",
118
+ BAD_PRODUCTION_COUNT = "BAD_PRODUCTION_COUNT",
119
+ PRODUCTION_COMPLETE = "PRODUCTION_COMPLETE",
120
+ PRODUCTION_COUNT = "PRODUCTION_COUNT",
121
+ PRODUCTIVE = "PRODUCTIVE",
122
+ LINE_SPEED = "LINE_SPEED",
123
+ SPEED = "SPEED",
124
+ ELECTRICAL_KWH = "ELECTRICAL_KWH",
125
+ ELECTRICAL_KWH_INTERVAL = "ELECTRICAL_KWH_INTERVAL",
126
+ ELECTRICAL_A = "ELECTRICAL_A",
127
+ ELECTRICAL_V = "ELECTRICAL_V",
128
+ ELECTRICAL_HZ = "ELECTRICAL_HZ",
129
+ ELECTRICAL_KW = "ELECTRICAL_KW",
130
+ ELECTRICAL_PF = "ELECTRICAL_PF",
131
+ STATUS_CODE = "STATUS_CODE",
132
+ RSSI = "RSSI",
133
+ }
134
+
135
+ declare enum CursorType {
136
+ production = "production",
137
+ stops = "stops",
138
+ slowLineSpeed = "slow_line_speed",
139
+ lastStatusCode = "last_status_code",
140
+ stationWindows = "station_windows",
141
+ }
142
+
143
+ declare enum ALERT_ISSUE_TYPE {
144
+ STOP = "stop",
145
+ RESOLVED = "resolved",
146
+ ESCALATED = "escalated",
147
+ }
148
+
149
+ declare enum STATION_MODULE_VISIBILITY {
150
+ UTILISATION = "utilisation",
151
+ ELECTRICAL = "electrical",
152
+ LINE_SPEED = "line_speed",
153
+ }
154
+
155
+ declare enum EMAIL_HARNESS_TYPE {
156
+ LOGIN = "login",
157
+ DOWNTIME_DETECTION = "downtime_detection",
158
+ DAILY_SUMMARY = "daily_summary",
159
+ DAILY_SUMMARY_REAL_ACCOUNT = "daily_summary_real_account",
160
+ }
161
+
162
+ declare const PERFORMANCE_MODE_TYPE = {
163
+ cycleTime: "cycle-time",
164
+ unitsPerMinute: "units-per-minute",
165
+ unitsPerHour: "units-per-hour",
166
+ lineSpeed: "line-speed",
167
+ none: "none",
168
+ } as const;
169
+
170
+ type PERFORMANCE_MODE_TYPE = (typeof PERFORMANCE_MODE_TYPE)[keyof typeof PERFORMANCE_MODE_TYPE];
171
+
172
+ declare const REASON_TYPE = {
173
+ downtime: "downtime",
174
+ non_production: "non-production",
175
+ } as const;
176
+
177
+ type REASON_TYPE = (typeof REASON_TYPE)[keyof typeof REASON_TYPE];
178
+
179
+ declare const MqttEventType = {
180
+ StationMetricNew: "STATION_METRIC_NEW", // When a new station window is created and saved to DB.
181
+ StationChanged: "STATION_CHANGED", // When a station is added or edited. NOT IMPLEMENTED.
182
+ ScheduleChanged: "SCHEDULE_CHANGED", // When a schedule is added or edited. NOT IMPLEMENTED.
183
+ ScheduleStarted: "SCHEDULE_STARTED", // When a schedule starts (actualStartAt). NOT IMPLEMENTED.
184
+ ScheduleEnded: "SCHEDULE_ENDED", // When a schedule ends (actualEndAt). NOT IMPLEMENTED.
185
+ ProductionNew: "PRODUCTION_NEW", // When new production is added. NOT IMPLEMENTED FOR MANUAL PRODUCTION YET.
186
+ };
187
+
188
+ type MqttEventType = keyof typeof MqttEventType;
189
+
3
190
  interface BusrootSignals {
4
191
  timestamp?: number;
5
192
  production_complete?: number;
@@ -37,38 +224,135 @@ interface PlantSchema {
37
224
  declare const StationSchema = z.object({
38
225
  // Basics
39
226
  accountId: z.string(),
40
- code: z.string(),
41
- name: z.string().trim().min(1).max(32),
42
- groupCode: z.string(),
43
- shiftPatternId: z.number().int().positive().nullish(),
227
+ code: z.string().describe("Code: Assign a Code to the Station, this cannot be changed once set."),
228
+ name: z.string().trim().min(1).max(32).describe("Name: Assign a Name to the Station."),
229
+ description: z.string().nullish(),
230
+ groupCode: z.string().describe("Group: Assign the station to a group of stations."),
231
+ shiftPatternId: z.number().int().positive().nullish().describe("Shift Pattern: Select which Shift Pattern the station will follow."),
44
232
  moduleVisibility: z.array(z.nativeEnum(STATION_MODULE_VISIBILITY)).nullish(),
45
- minimumCycleTime: z.number().int().gte(0).lte(TimeIntervals["12h"].ms).nullish(),
46
- speedScale: z.number().gte(-9999).lte(9999).nullish(),
47
- speedOffset: z.number().gte(-9999).lte(9999).nullish(),
48
- speedToProductionRatio: z.number().gte(0).lte(99999).nullish(),
49
- electricalPowerNominalKw: z.number().gte(0).nullish(),
233
+ minimumCycleTime: z
234
+ .number()
235
+ .int()
236
+ .gte(0)
237
+ .lte(TimeIntervals["12h"].ms)
238
+ .nullish()
239
+ .describe(
240
+ "Minimum Cycle Time (secs): Set a minimum cycle-time for the station. If more than one signal is received in this period, Busroot will only count one unit. This allows filtering of signals during setup process for example.",
241
+ ),
242
+ speedScale: z
243
+ .number()
244
+ .gte(-9999)
245
+ .lte(9999)
246
+ .nullish()
247
+ .describe(
248
+ "Speed scale: If the value on the Performance Chart doesn't reflect actual running speed, it can be calibrated by setting this value. For example current value = 20, but actual speed = 10, scale should be set to 0.5.",
249
+ ),
250
+ speedOffset: z
251
+ .number()
252
+ .gte(-9999)
253
+ .lte(9999)
254
+ .nullish()
255
+ .describe(
256
+ "Speed offset: This can be set to fine tune a Speed value. For example if a Stations speed is showing as 0.5 when stopped, set the value to -0.5.",
257
+ ),
258
+ speedToProductionRatio: z
259
+ .number()
260
+ .gte(0)
261
+ .lte(99999)
262
+ .nullish()
263
+ .describe(
264
+ "Speed to Production Ratio: A speed value can be converted into a production count. Set the conversion ratio, this can be a decimal if required. (if left blank no production units will be counted)",
265
+ ),
266
+ electricalPowerNominalKw: z
267
+ .number()
268
+ .gte(0)
269
+ .nullish()
270
+ .describe("Electrical Power Nominal (kW): The expected power usage in kW during normal operation."),
50
271
 
51
272
  // Defaults
52
- idleCostPerMinute: z.number().gte(0).lte(99999).nullish(),
273
+ idleCostPerMinute: z
274
+ .number()
275
+ .gte(0)
276
+ .lte(99999)
277
+ .nullish()
278
+ .describe(
279
+ "Idle Cost (£/min): Assign a cost per minute for any idle time. This will be used for scheduling losses, planned non-production losses and downtime losses where the SKU does not have a value set.",
280
+ ),
53
281
 
54
282
  // Downtime Settings
55
- downtimeDetectionMode: z.nativeEnum(DOWNTIME_DETECTION_MODE).default(DOWNTIME_DETECTION_MODE.UTILISATION).optional(),
56
- utilisationDowntimeThreshold: z.preprocess((val) => (val === null ? TimeIntervals["1h"].ms : val), z.number().int().gte(0).optional()),
283
+ downtimeDetectionMode: z
284
+ .nativeEnum(DOWNTIME_DETECTION_MODE)
285
+ .default(DOWNTIME_DETECTION_MODE.UTILISATION)
286
+ .optional()
287
+ .describe(
288
+ "Downtime Detection Mode: Busroot will report downtime for a station using either Utilisation, Production Cycle data or Line Speed Monitoring. (relevant signals must be connected)",
289
+ ),
290
+ utilisationDowntimeThreshold: z
291
+ .preprocess((val) => (val === null ? TimeIntervals["1h"].ms : val), z.number().int().gte(0).optional())
292
+ .describe(
293
+ "Utilisation Downtime Threshold (mins): This controls the minimum period before Busroot will register downtime. ie. with a threshold of 10mins, only stops of 10 mins or longer will be recorded.",
294
+ ),
57
295
 
58
296
  slowDurationThreshold: z.number().int().gte(0).nullish(),
59
297
  forceAllShiftTimeAsPlannedProduction: z.boolean().default(true),
60
298
 
61
299
  // Productive Settings
62
- productiveStatusMode: z.nativeEnum(PRODUCTIVE_STATUS_MODE).default(PRODUCTIVE_STATUS_MODE.PRODUCTIVE_SIGNAL).optional(),
63
- electricalUsageStoppedThresholdKw: z.number().gte(0).nullish(),
64
- lineSpeedStoppedThreshold: z.number().gte(0).nullish(),
65
- productiveHoldOnTime: z.number().int().gte(0).lte(TimeIntervals["1d"].ms).nullish(),
300
+ productiveStatusMode: z
301
+ .nativeEnum(PRODUCTIVE_STATUS_MODE)
302
+ .default(PRODUCTIVE_STATUS_MODE.PRODUCTIVE_SIGNAL)
303
+ .optional()
304
+ .describe("Productive Status Mode: Select one of the following to measure when the station is engaged in a value-adding-activity."),
305
+ electricalUsageStoppedThresholdKw: z
306
+ .number()
307
+ .gte(0)
308
+ .nullish()
309
+ .describe(
310
+ "Stopped Threshold (kW): Set the minimum kW consumption that indicates the station active, below this Busroot will regard as downtime.",
311
+ ),
312
+ lineSpeedStoppedThreshold: z
313
+ .number()
314
+ .gte(0)
315
+ .nullish()
316
+ .describe(
317
+ "Line Speed Stopped Threshold: Set the minimum speed that the indicates the station is running, below this Busroot will regard as downtime.",
318
+ ),
319
+ productiveHoldOnTime: z
320
+ .number()
321
+ .int()
322
+ .gte(0)
323
+ .lte(TimeIntervals["1d"].ms)
324
+ .nullish()
325
+ .describe(
326
+ "Productive Hold on Time (mins): This controls the length of time a station is considered active after a productive signal. Each time a new signal is received the hold on time will restart.",
327
+ ),
66
328
 
67
329
  // Flags
68
- allowInterruptionMode: z.boolean().default(false).optional(),
69
- allowManualProduction: z.boolean().default(false).optional(),
70
- allowQuickScheduleStart: z.boolean().default(false).optional(),
71
- allowScheduleCutShort: z.boolean().default(false).optional(),
330
+ allowInterruptionMode: z
331
+ .boolean()
332
+ .default(false)
333
+ .optional()
334
+ .describe(
335
+ "Allow Interruption Mode: Enable the Interruption tool. The tool provides an intuitive way to capture downtime from human-lead manufacturing processes where digital data capture is impossible.",
336
+ ),
337
+ allowManualProduction: z
338
+ .boolean()
339
+ .default(false)
340
+ .optional()
341
+ .describe(
342
+ "Allow Manual Production: This enables the production entry module on the tablet, allowing operators to count production manually.",
343
+ ),
344
+ allowQuickScheduleStart: z
345
+ .boolean()
346
+ .default(false)
347
+ .optional()
348
+ .describe("Allow Ad Hoc Schedules: This allows operators with tablets to start new schedules directly from the tablet."),
349
+ allowScheduleCutShort: z
350
+ .boolean()
351
+ .default(false)
352
+ .optional()
353
+ .describe(
354
+ "Allow Schedule Cut Short: This enables a button in Schedule Management, to allow a schedule to be ended early. The remaining quantity will be added to a new schedule with the same Work Order Ref.",
355
+ ),
72
356
 
73
357
  // Current State
74
358
  currentOperatorInitials: z.string().min(3).max(3).nullish(),
@@ -76,10 +360,16 @@ declare const StationSchema = z.object({
76
360
  statusCodeUpdatedAt: z.string().nullish(),
77
361
 
78
362
  // Performance Mode
79
- cycleTime: z.number().int().gt(0).lte(TimeIntervals["12h"].ms).nullish(),
80
- unitsPerMinute: z.number().int().gt(0).nullish(),
81
- unitsPerHour: z.number().int().gt(0).nullish(),
82
- lineSpeedTarget: z.number().gt(0).lte(99999).nullish(),
363
+ cycleTime: z
364
+ .number()
365
+ .int()
366
+ .gt(0)
367
+ .lte(TimeIntervals["12h"].ms)
368
+ .nullish()
369
+ .describe("Cycle Time (secs): Set a standard cycle-time for the station."),
370
+ unitsPerMinute: z.number().int().gt(0).nullish().describe("Units Per Minute: Set the expected production rate in units/min."),
371
+ unitsPerHour: z.number().int().gt(0).nullish().describe("Units Per Hour: Set the expected production rate in units/hr."),
372
+ lineSpeedTarget: z.number().gt(0).lte(99999).nullish().describe("Line Speed Target: Set a target speed for the station."),
83
373
 
84
374
  // System info
85
375
  createdAt: z.string().nullish(),
@@ -89,6 +379,111 @@ declare const StationSchema = z.object({
89
379
 
90
380
  type StationSchema = z.infer<typeof StationSchema>;
91
381
 
382
+ declare const AccountSchema = z.object({
383
+ id: z.string(),
384
+ domain: z.string(),
385
+ stationCountLimit: z.number().nullish(),
386
+ electricalPricePerKwh: z.number().nullish(),
387
+ electricalCo2PerKwh: z.number().nullish(),
388
+ currency: z.string().nullish(),
389
+ enableLostProductionCost: z.boolean().nullish(),
390
+ dashboardConfig: z.record(z.string(), z.any()).nullish(),
391
+ redshiftPassword: z.string().nullish(),
392
+ uploadTransforms: z.string().nullish(),
393
+ defaultAutoEndOnQuantityComplete: z.boolean().nullish(),
394
+ appUrls: z.string().nullish(),
395
+ createdAt: z.string().nullish(),
396
+ updatedAt: z.string().nullish(),
397
+ });
398
+
399
+ type AccountSchema = z.infer<typeof AccountSchema>;
400
+
401
+ // OEE Availability = (scheduledProductionMs - downtimeMs) / scheduledProductionMs
402
+ // OEE Performance = (productionTargetCount - (productionTargetCount - (productionGoodCount + productionBadCount)) / productionTargetCount
403
+ // OEE Quality = (productionGoodCount - productionBadCount) / productionGoodCount
404
+
405
+ declare const StationWindowSchema = z.object({
406
+ accountId: z.string().describe(""),
407
+ stationCode: z.string().describe("A code that uniquely identifies this station within this account."),
408
+ windowStartAt: z.string().describe("The start time of this window in ISO 8601 format."),
409
+ windowEndAt: z.string().describe("The end time of this window in ISO 8601 format."),
410
+ totalMs: z.number().describe("The total number milliseconds covered by this window. Shortcut for windowEndAt - windowStartAt."),
411
+ shiftMs: z.number().describe("The number of milliseconds that were in shift.").optional(),
412
+ shiftName: z.string().describe("The name of the shift at this time.").optional(),
413
+ scheduledProductionMs: z.number().describe("The number of milliseconds that were scheduled production.").optional(),
414
+ scheduledNonProductionMs: z.number().describe("The number of milliseconds that were scheduled non-production.").optional(),
415
+ productiveMs: z.number().describe("The number of milliseconds that the station was in a productive state.").optional(),
416
+ downtimeId: z.number().describe("The ID of the current downtime.").optional(),
417
+ downtimeMs: z.number().describe("The number of milliseconds that the station was in downtime.").optional(),
418
+ downtimeReasonCode: z.string().describe("The reason code assigned to the current downtime.").optional(),
419
+ downtimeSince: z.string().describe("The time this downtime started, in ISO 8601 format.").optional(),
420
+ rssiAvg: z
421
+ .number()
422
+ .optional()
423
+ .describe("The received signal strength of the wireless device. -70dBm to -80dBm is good. <-90dBm is bad.")
424
+ .optional(),
425
+ productionGoodCount: z.number().describe("The number of good quality units produced.").optional(),
426
+ productionBadCount: z.number().describe("The number of bad quality units produced.").optional(),
427
+ productionIdealCount: z
428
+ .number()
429
+ .optional()
430
+ .describe(
431
+ "The number of production units that should have been produced according to the SKU/part's cycle-time. WITH consideration for downtime.",
432
+ )
433
+ .optional(),
434
+ productionTargetCount: z
435
+ .number()
436
+ .describe(
437
+ "The number of production units that should have been produced according to the SKU/part's cycle-time. WITHOUT consideration for downtime.",
438
+ )
439
+ .optional(),
440
+ speed: z
441
+ .number()
442
+ .describe(
443
+ "The average line speed. Line speed is an arbitrary value that relates to this station's manufacturing process. i.e. Motor RPM.",
444
+ )
445
+ .optional(),
446
+ errorCode: z.string().describe("The error code that was flagged.").optional(),
447
+ scheduleId: z.number().describe("The ID of the current schedule.").optional(),
448
+ skuCode: z.string().describe("The SKU code taken from the current schedule.").optional(),
449
+ isAlive: z
450
+ .boolean()
451
+ .describe(
452
+ "A boolean value indicating if any signal was recieved from this station. Useful for detemining if the device has been disconnected from the network.",
453
+ )
454
+ .optional(),
455
+ electricalVoltsAvg: z.number().describe("The average voltage of the electrical supply.").optional(),
456
+ electricalAmpsAvg: z.number().describe("The average current draw.").optional(),
457
+ electricalHzAvg: z.number().describe("The average frequency of the electrical supply.").optional(),
458
+ electricalPfAvg: z.number().describe("The average Power Factor.").optional(),
459
+ electricalKwAvg: z.number().describe("The average power used.").optional(),
460
+ electricalKwh: z.number().describe("The total energy consumed.").optional(),
461
+ statusCode: z.string().describe("").optional(),
462
+ nonProductionReasonCode: z.string().describe("The non-production reason code for the current schedule.").optional(),
463
+ skuGroupCode: z.string().describe("").optional(),
464
+ electricalCost: z.number().describe("The cost of the electricity used.").optional(),
465
+ costCurrency: z.string().describe("The currency of any costs.").optional(),
466
+ electricalCo2: z.number().describe("The amount of CO2 associated with the electricity used.").optional(),
467
+ workOrderReference: z.string().describe("The work order reference of the current schedule.").optional(),
468
+
469
+ lostProductionCostNonProduction: z.number().describe("The cost of the time lost to scheduled non-production.").optional(),
470
+ lostProductionCostDowntime: z.number().describe("The cost of the time lost to downtime.").optional(),
471
+ lostProductionCostSpeed: z.number().describe("The cost of the shortfall units lost due to under performance.").optional(),
472
+ lostProductionCostQuality: z.number().describe("The cost of the bad quality units produced.").optional(),
473
+
474
+ // Performance Mode
475
+ performanceModeFrom: z.string().describe("").optional(),
476
+ performanceModeType: z.string().describe("").optional(),
477
+
478
+ productionGoodValue: z.number().describe("The value of the good quality units produced.").optional(),
479
+ productionBadValue: z.number().describe("The value of the bad quality units produced.").optional(),
480
+
481
+ createdAt: z.string().describe("").optional(),
482
+ updatedAt: z.string().describe("").optional(),
483
+ });
484
+
485
+ type StationWindowSchema = z.infer<typeof StationWindowSchema>;
486
+
92
487
  declare const ApiKeySchema = z.object({
93
488
  accountId: z.string(),
94
489
  key: z.string(),
@@ -99,6 +494,30 @@ declare const ApiKeySchema = z.object({
99
494
  });
100
495
  type ApiKeySchema = z.infer<typeof ApiKeySchema>;
101
496
 
497
+ declare const AccountViewModel = AccountSchema.merge(
498
+ z.object({
499
+ cursors: z
500
+ .array(
501
+ z.object({
502
+ type: z.string(),
503
+ timestamp: z.number(),
504
+ value: z.string(),
505
+ valueAgo: z.string(),
506
+ }),
507
+ )
508
+ .optional(),
509
+ redshiftConfig: z
510
+ .object({
511
+ host: z.string(),
512
+ port: z.number(),
513
+ username: z.string(),
514
+ })
515
+ .optional(),
516
+ }),
517
+ );
518
+
519
+ type AccountViewModel = z.infer<typeof AccountViewModel>;
520
+
102
521
  declare const PlantViewModel = z.object({
103
522
  code: z.string(),
104
523
  name: z.string(),
@@ -127,6 +546,37 @@ declare const SkuViewModel = z.object({
127
546
  });
128
547
  type SkuViewModel = z.infer<typeof SkuViewModel>;
129
548
 
549
+ declare const OeeViewModel = z.object({
550
+ scheduleMs: z.number().describe("The number of milliseconds spent on any schedule."), // production and non-production scheduled time combined.
551
+ scheduleLossMs: z.number().describe("The number of milliseconds lost to unscheduled time in shift."), // The amount of in shift time not schedule in either way.
552
+ schedulePerc: z.number().describe("The ratio of scheduled to unscheduled time."),
553
+
554
+ productionScheduleMs: z.number().describe("The number of milliseconds spent in a production schedule."), // In simplified OEE, this is shift time minus scheduled non-production time. In full OEE, this would be only scheduled production time.
555
+ productionScheduleLossMs: z.number().describe("The number of milliseconds lost to non-production schedules."),
556
+ productionSchedulePerc: z.number().describe("The ratio of production to non-production scheduled time."),
557
+
558
+ availabilityMs: z.number().describe("The number of milliseconds spent running."), // The planned production time minus stop time.
559
+ availabilityLossMs: z.number().describe("The number of milliseconds spend stopped."), // The amount of time the station is stopped during planned production time ()
560
+ availabilityPerc: z.number().describe("The ratio of running to stopped time aka OEE Availability."),
561
+
562
+ performanceMs: z
563
+ .number()
564
+ .describe("The number of milliseconds spend producing under ideal circumstances (production count * ideal cycle time)."),
565
+ performanceLossMs: z.number().describe("The number of milliseconds lost to under-production vs ideal cycle times."),
566
+ performancePerc: z.number().describe("OEE Performance."),
567
+
568
+ goodQualityCount: z.number().describe("The number of good quality units produced."),
569
+ goodQualityLossCount: z.number().describe("The number of bad quality units produced."),
570
+ goodQualityPerc: z.number().describe("The ratio of good units to bad units aka OEE Quality."),
571
+
572
+ scheduledNonProduction: z.array(OeeStop),
573
+ stops: z.array(OeeStop),
574
+
575
+ oee: z.number(),
576
+ });
577
+
578
+ type OeeViewModel = z.infer<typeof OeeViewModel>;
579
+
130
580
  type ApiKeyViewModel = ApiKeySchema;
131
581
 
132
582
  declare const ScheduleViewModel = z.object({
@@ -158,9 +608,17 @@ declare const ScheduleViewModel = z.object({
158
608
  effectiveUnitsPerMinute: z.number().optional(),
159
609
  effectiveUnitsPerHour: z.number().optional(),
160
610
  effectiveLineSpeedTarget: z.number().optional(),
611
+ normalisedCycleTime: z
612
+ .number()
613
+ .optional()
614
+ .describe("The effective performance mode, convered back into a cycle time (aka the time in millis required to make 1 unit."),
161
615
  effectiveBatchSize: z.number().optional(),
162
616
  effectiveMinimumCycleTime: z.number().optional(),
163
617
 
618
+ remainingTime: z.number().optional(),
619
+ quantityIdeal: z.number().optional(),
620
+ quantityIdealDelta: z.number().optional(),
621
+
164
622
  deletedAt: z.string().optional(),
165
623
  actualStartAt: z.string().optional(),
166
624
  actualStartAtTimestamp: z.number().optional(),
@@ -168,6 +626,7 @@ declare const ScheduleViewModel = z.object({
168
626
  actualEndAtTimestamp: z.number().optional(),
169
627
  idealEndAt: z.string().optional(),
170
628
  idealEndAtTimestamp: z.number().optional(),
629
+ idealDuration: z.number().optional(),
171
630
  quantityGood: z.number().optional(),
172
631
  quantityBad: z.number().optional(),
173
632
  quantityTotal: z.number().optional(),
@@ -179,7 +638,6 @@ declare const ScheduleViewModel = z.object({
179
638
  isEnded: z.boolean(),
180
639
  status: z.enum(["running", "planned", "deleted", "completed"]),
181
640
  allowScheduleCutShort: z.boolean().optional(),
182
- idealQuantity: z.number().optional(),
183
641
  performanceModeFrom: z.enum(["schedule", "sku", "station", "none"]).optional(),
184
642
  logs: z.array(z.string()).optional(),
185
643
  priorityAt: z.string().optional(),
@@ -187,9 +645,55 @@ declare const ScheduleViewModel = z.object({
187
645
 
188
646
  type ScheduleViewModel = z.infer<typeof ScheduleViewModel>;
189
647
 
648
+ declare const StationWindowViewModel = StationWindowSchema.omit({
649
+ skuCode: true,
650
+ skuGroupCode: true,
651
+ nonProductionReasonCode: true,
652
+ downtimeReasonCode: true,
653
+ downtimeId: true,
654
+ errorCode: true,
655
+ scheduleId: true,
656
+ workOrderReference: true,
657
+ shiftName: true,
658
+ })
659
+ .required({ isAlive: true })
660
+ .merge(
661
+ z.object({
662
+ stationName: z.string().describe("The name of the station."),
663
+ scheduleIds: z.array(z.number()).describe("The IDs of the schedules that ran.").optional(),
664
+ workOrderReferences: z.array(z.string()).describe("The WO refs of the schedules that ran.").optional(),
665
+ errorCodes: z.array(z.string()).describe("The error codes that were flagged.").optional(),
666
+ downtimeIds: z.array(z.number()).describe("The IDs of the downtimes that occured.").optional(),
667
+ downtimeReasonCodes: z.array(z.string()).describe("The reason codes of the downtimes that occured.").optional(),
668
+ nonProductionReasonCodes: z
669
+ .array(z.string())
670
+ .optional()
671
+ .describe("The reason codes for the non-production schedules that ran.")
672
+ .optional(),
673
+ windowStartAtTimestamp: z.number().describe("The start time of this window as a UNIX timestamp."),
674
+ windowEndAtTimestamp: z.number().describe("The end time of this window as a UNIX timestamp."),
675
+ isFuture: z.boolean().describe("A boolean value indicating if this is a placeholder station window for future time.").optional(),
676
+ skuName: z.string().describe("The name of the SKU from the current schedule.").optional(),
677
+ skuCodes: z.array(z.string()).describe("The code of the SKUs from the schedules that ran.").optional(),
678
+ shiftNames: z.array(z.string()).describe("The shift names during this time.").optional(),
679
+ skuGroupCodes: z.array(z.string()).describe("The code of the SKU Groups from the schedules that ran.").optional(),
680
+ lostProductionCostTotal: z.number().describe("The total cost of lost production output.").optional(),
681
+ productionTotalCount: z.number().describe("The total number of units produced, both good and bad.").optional(),
682
+ productionRatePerHour: z.number().describe("The average rate of production in units per hour.").optional(),
683
+ productionRatePerHourIdeal: z.number().describe("The ideal rate of production in units per hour.").optional(),
684
+ productionMs: z
685
+ .number()
686
+ .describe("The number of milliseconds of actual production achieved (production count * ideal cycle time).")
687
+ .optional(),
688
+ }),
689
+ );
690
+
691
+ type StationWindowViewModel = z.infer<typeof StationWindowViewModel>;
692
+
190
693
  declare const StationViewModel = z.object({
191
694
  code: z.string(), // from station table
192
695
  name: z.string(), // from station table
696
+ description: z.string().nullish(),
193
697
  groupCode: z.string().nullish(), // from station table
194
698
  groupName: z.string().nullish(), // from join with group table
195
699
  allowScheduleStationFlexibility: z.boolean().nullish(), // from join with group table
@@ -224,11 +728,6 @@ declare const StationViewModel = z.object({
224
728
 
225
729
  currentShift: ShiftSchema.optional(), // the shift calculated to be in now. Null if not in any shift.
226
730
 
227
- currentProductionSchedule: ProductionScheduleViewModel.nullish(), //The production schedule we are in for this station. null if no active production schedule.
228
- nextProductionSchedule: ProductionScheduleViewModel.nullish(), //The production schedule that is next. null if no active production schedule.
229
-
230
- currentNonProductionSchedule: NonProductionScheduleViewModel.nullish(), // The maintenance schedule we are in for this station. null if no active maintenance schedule.
231
-
232
731
  currentStopReasonCode: z.string().nullish(), // The reason code for the 'stop' type issue that is ongoing for this station. unknown if no reason given. null if no ongoing 'stop' type issue.
233
732
  stoppedSince: z.number().nullish(), // The startAt of the ongoing 'stop' type issue. null if no ongoing issue.
234
733
 
@@ -249,29 +748,69 @@ declare const StationViewModel = z.object({
249
748
 
250
749
  type StationViewModel = z.infer<typeof StationViewModel>;
251
750
 
252
- declare const AccountViewModel = AccountSchema.merge(
253
- z.object({
254
- cursors: z
255
- .array(
256
- z.object({
257
- type: z.string(),
258
- timestamp: z.number(),
259
- value: z.string(),
260
- valueAgo: z.string(),
261
- }),
262
- )
263
- .optional(),
264
- redshiftConfig: z
265
- .object({
266
- host: z.string(),
267
- port: z.number(),
268
- username: z.string(),
269
- })
270
- .optional(),
271
- }),
272
- );
751
+ declare const ReliabilityData = z.object({
752
+ runningsCount: z.number(),
753
+ stopsCount: z.number(),
754
+ totalRunningTime: z.number(),
755
+ totalStoppedTime: z.number(),
756
+ });
273
757
 
274
- type AccountViewModel = z.infer<typeof AccountViewModel>;
758
+ type ReliabilityData = z.infer<typeof ReliabilityData>;
759
+
760
+ declare const StationWindowViewModelTrimmed = StationWindowViewModel.omit({
761
+ accountId: true,
762
+ createdAt: true,
763
+ updatedAt: true,
764
+ })
765
+ .partial({ stationCode: true, stationName: true })
766
+ .merge(
767
+ z.object({
768
+ //TODO: Reasons don't have name, they have descriptions. This needs to be updated.
769
+ nonProductionReasonNames: z.array(z.string()).optional(),
770
+ }),
771
+ );
772
+
773
+ type StationWindowViewModelTrimmed = z.infer<typeof StationWindowViewModelTrimmed>;
774
+
775
+ declare const CycleTimeAnalysis = z.object({
776
+ avg: z.number(),
777
+ min: z.number(),
778
+ max: z.number(),
779
+ quantity: z.number(),
780
+ default: z.number().optional(),
781
+ stations: z
782
+ .object({
783
+ stationCode: z.string(),
784
+ stationName: z.string(),
785
+ avg: z.number(),
786
+ min: z.number(),
787
+ max: z.number(),
788
+ quantity: z.number(),
789
+ })
790
+ .array(),
791
+ });
792
+
793
+ type CycleTimeAnalysis = z.infer<typeof CycleTimeAnalysis>;
794
+
795
+ declare const NominalValue = z.object({
796
+ electricalPowerNominalKw: z.number(),
797
+ });
798
+
799
+ type NominalValue = z.infer<typeof NominalValue>;
800
+
801
+ declare const AggregatedStationWindowsByStation = z.object({
802
+ stationCode: z.string(),
803
+ stationName: z.string(),
804
+ stationGroupCode: z.string(),
805
+ stationGroupName: z.string(),
806
+ windows: z.array(StationWindowViewModelTrimmed),
807
+ reliabilityData: ReliabilityData,
808
+ cycleTimeAnalysis: CycleTimeAnalysis.optional(),
809
+ oee: OeeViewModel,
810
+ nominal: NominalValue,
811
+ });
812
+
813
+ type AggregatedStationWindowsByStation = z.infer<typeof AggregatedStationWindowsByStation>;
275
814
 
276
- export { AccountViewModel, PlantViewModel, ScheduleViewModel, SkuViewModel, StationSchema, StationViewModel };
815
+ export { ALERT_ISSUE_TYPE, AccountRole, AccountSchema, AccountViewModel, AggregatedStationWindowsByStation, AuthType, CursorType, CycleTimeAnalysis, DOWNTIME_DETECTION_MODE, DowntimeEventType, DowntimeFilterState, DowntimeType, EMAIL_HARNESS_TYPE, GROUP_TAG_PREFIX, MessageType, MqttEventType, NOTIFICATION_PREFERENCE, NominalValue, OeeViewModel, PERFORMANCE_MODE_TYPE, PRODUCTION_TYPE, PRODUCTIVE_STATUS_MODE, PlantViewModel, REASON_TYPE, RagStatus, ReliabilityData, SCHEDULE_TYPE, STATION_MODULE_VISIBILITY, ScheduleViewModel, SkuViewModel, StationSchema, StationStatus, StationViewModel, StationWindowSchema, StationWindowViewModel, StationWindowViewModelTrimmed, TIMESERIES_MESSAGE_TYPE, UserRole, WeekDay };
277
816
  export type { ApiKeyViewModel, BusrootSignals, PlantSchema };