@seedtactics/insight-client 16.7.0 → 16.7.2

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,10 +1,20 @@
1
1
  import { IInProcessMaterial, ILogEntry, ILogMaterial, IMaterialDetails, IActiveWorkorder, IScannedPotentialNewMaterial } from "../network/api.js";
2
+ import { type Atom } from "jotai";
2
3
  export type MaterialToShowInfo = {
3
4
  readonly materialID: number;
4
5
  readonly partName: string;
5
6
  readonly serial?: string;
6
7
  readonly workorderId?: string;
7
8
  };
9
+ export type AsyncAtomState<T> = {
10
+ readonly state: "loading";
11
+ } | {
12
+ readonly state: "hasData";
13
+ readonly data: T;
14
+ } | {
15
+ readonly state: "hasError";
16
+ readonly error: unknown;
17
+ };
8
18
  export type MaterialToShow = {
9
19
  readonly type: "InProcMat";
10
20
  readonly inproc: Readonly<IInProcessMaterial>;
@@ -30,25 +40,27 @@ export type MaterialToShow = {
30
40
  readonly toQueue: string;
31
41
  };
32
42
  export declare const materialDialogOpen: import("jotai").WritableAtom<MaterialToShow | null, [mat: MaterialToShow | null], void>;
33
- export declare const barcodePotentialNewMaterial: import("jotai").Atom<Promise<Readonly<IScannedPotentialNewMaterial> | null>>;
34
- export declare const materialInDialogInfo: import("jotai").Atom<Promise<MaterialToShowInfo | null>>;
35
- export declare const materialInDialogInfoUnwrapped: import("jotai").Atom<MaterialToShowInfo | null>;
36
- export declare const inProcessMaterialInDialog: import("jotai").Atom<Promise<IInProcessMaterial | null>>;
37
- export declare const serialInMaterialDialog: import("jotai").Atom<Promise<string | null>>;
38
- export declare const serialInMaterialDialogUnwrapped: import("jotai").Atom<string | null>;
39
- export declare const workorderInMaterialDialog: import("jotai").Atom<Promise<string | null>>;
40
- export declare const materialInDialogEvents: import("jotai").Atom<readonly Readonly<ILogEntry>[]>;
43
+ export declare const barcodePotentialNewMaterial: Atom<Promise<Readonly<IScannedPotentialNewMaterial> | null>>;
44
+ export declare const materialInDialogInfo: Atom<Promise<MaterialToShowInfo | null>>;
45
+ export declare const materialInDialogInfoUnwrapped: Atom<MaterialToShowInfo | null>;
46
+ export declare const materialInDialogInfoState: Atom<AsyncAtomState<MaterialToShowInfo | null>>;
47
+ export declare const inProcessMaterialInDialog: Atom<Promise<IInProcessMaterial | null>>;
48
+ export declare const serialInMaterialDialog: Atom<Promise<string | null>>;
49
+ export declare const serialInMaterialDialogUnwrapped: Atom<string | null>;
50
+ export declare const serialInMaterialDialogState: Atom<AsyncAtomState<string | null>>;
51
+ export declare const workorderInMaterialDialog: Atom<Promise<string | null>>;
52
+ export declare const materialInDialogEvents: Atom<readonly Readonly<ILogEntry>[]>;
41
53
  export type LargestUsedProces = {
42
54
  readonly process: number;
43
55
  readonly totalNumProcesses: number;
44
56
  };
45
- export declare const materialInDialogLargestUsedProcess: import("jotai").Atom<Promise<LargestUsedProces | null>>;
57
+ export declare const materialInDialogLargestUsedProcess: Atom<Promise<LargestUsedProces | null>>;
46
58
  export interface MaterialToShowInspections {
47
59
  readonly signaledInspections: ReadonlyArray<string>;
48
60
  readonly completedInspections: ReadonlyArray<string>;
49
61
  }
50
- export declare const materialInDialogInspections: import("jotai").Atom<MaterialToShowInspections>;
51
- export declare const possibleWorkordersForMaterialInDialog: import("jotai").Atom<Promise<readonly IActiveWorkorder[]>>;
62
+ export declare const materialInDialogInspections: Atom<MaterialToShowInspections>;
63
+ export declare const possibleWorkordersForMaterialInDialog: Atom<Promise<readonly IActiveWorkorder[]>>;
52
64
  export interface ForceInspectionData {
53
65
  readonly mat: MaterialToShowInfo;
54
66
  readonly inspType: string;
@@ -112,6 +112,10 @@ export const materialInDialogInfo = atom(async (get) => {
112
112
  }
113
113
  });
114
114
  export const materialInDialogInfoUnwrapped = unwrap(materialInDialogInfo, (prev) => prev ?? null);
115
+ function asyncAtomState(source) {
116
+ return unwrap(atom((get) => get(source).then((data) => ({ state: "hasData", data }), (error) => ({ state: "hasError", error }))), () => ({ state: "loading" }));
117
+ }
118
+ export const materialInDialogInfoState = asyncAtomState(materialInDialogInfo);
115
119
  export const inProcessMaterialInDialog = atom(async (get) => {
116
120
  const status = get(currentStatus);
117
121
  const toShow = get(matToShow);
@@ -147,6 +151,7 @@ export const serialInMaterialDialog = atom(async (get) => {
147
151
  }
148
152
  });
149
153
  export const serialInMaterialDialogUnwrapped = unwrap(serialInMaterialDialog, (prev) => prev ?? null);
154
+ export const serialInMaterialDialogState = asyncAtomState(serialInMaterialDialog);
150
155
  export const workorderInMaterialDialog = atom(async (get) => {
151
156
  const toShow = get(matToShow);
152
157
  if (toShow === null)
@@ -439,9 +439,44 @@ export const MaterialDetailTitle = memo(function MaterialDetailTitle({ partName,
439
439
  }, children: [_jsx(Typography, { variant: "h6", children: title }), subtitle ? _jsx(Typography, { variant: "caption", children: subtitle }) : undefined] })] }));
440
440
  });
441
441
  function MaterialDialogTitle({ notes }) {
442
- const mat = useAtomValue(matDetails.materialInDialogInfoUnwrapped);
443
- const serial = useAtomValue(matDetails.serialInMaterialDialogUnwrapped);
444
- return _jsx(MaterialDetailTitle, { notes: notes, partName: mat?.partName ?? "", serial: mat?.serial ?? serial });
442
+ const toShow = useAtomValue(matDetails.materialDialogOpen);
443
+ const mat = useAtomValue(matDetails.materialInDialogInfoState);
444
+ const serial = useAtomValue(matDetails.serialInMaterialDialogState);
445
+ let partName = "";
446
+ let titleSerial = null;
447
+ switch (toShow?.type) {
448
+ case "InProcMat":
449
+ partName = toShow.inproc.partName;
450
+ titleSerial = toShow.inproc.serial;
451
+ break;
452
+ case "MatSummary":
453
+ partName = toShow.summary.partName;
454
+ titleSerial = toShow.summary.serial;
455
+ break;
456
+ case "MatDetails":
457
+ partName = toShow.details.partName;
458
+ titleSerial = toShow.details.serial;
459
+ break;
460
+ case "LogMat":
461
+ partName = toShow.logMat.part;
462
+ titleSerial = toShow.logMat.serial;
463
+ break;
464
+ case "Barcode":
465
+ titleSerial = toShow.barcode;
466
+ break;
467
+ case "ManuallyEnteredSerial":
468
+ case "AddMatWithEnteredSerial":
469
+ titleSerial = toShow.serial;
470
+ break;
471
+ }
472
+ if (mat.state === "hasData" && mat.data !== null) {
473
+ partName = mat.data.partName;
474
+ titleSerial = mat.data.serial ?? titleSerial;
475
+ }
476
+ if (serial.state === "hasData" && serial.data) {
477
+ titleSerial = serial.data;
478
+ }
479
+ return _jsx(MaterialDetailTitle, { notes: notes, partName: partName, serial: titleSerial });
445
480
  }
446
481
  function MaterialInspections() {
447
482
  const insps = useAtomValue(matDetails.materialInDialogInspections);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,199 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* Copyright (c) 2026, John Lenz
3
+
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright
10
+ notice, this list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above
13
+ copyright notice, this list of conditions and the following
14
+ disclaimer in the documentation and/or other materials provided
15
+ with the distribution.
16
+
17
+ * Neither the name of John Lenz, Black Maple Software, SeedTactics,
18
+ nor the names of other contributors may be used to endorse or
19
+ promote products derived from this software without specific
20
+ prior written permission.
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+ */
34
+ import { act } from "react";
35
+ import { Provider, createStore } from "jotai";
36
+ import { createRoot } from "react-dom/client";
37
+ import { afterEach, expect, it, vi } from "vitest";
38
+ import { MaterialDialog } from "./Material.js";
39
+ import { materialDialogOpen } from "../../cell-status/material-details.js";
40
+ import { ApiException } from "../../network/api.js";
41
+ import { registerBackend } from "../../network/backend.js";
42
+ const barcode = "1111222|SO100100|10000";
43
+ const barcodeError = "Serial 1111222 is assigned to sales order SO100100 line 10000 which is not currently scheduled";
44
+ function unexpectedCall(name) {
45
+ throw new Error(`Unexpected backend call in MaterialDialog test: ${name}`);
46
+ }
47
+ const logBackend = {
48
+ get() {
49
+ return unexpectedCall("LogAPI.get");
50
+ },
51
+ recent() {
52
+ return unexpectedCall("LogAPI.recent");
53
+ },
54
+ logForMaterial() {
55
+ return unexpectedCall("LogAPI.logForMaterial");
56
+ },
57
+ logForMaterials() {
58
+ return unexpectedCall("LogAPI.logForMaterials");
59
+ },
60
+ logForSerial() {
61
+ return unexpectedCall("LogAPI.logForSerial");
62
+ },
63
+ materialForSerial() {
64
+ return unexpectedCall("LogAPI.materialForSerial");
65
+ },
66
+ setInspectionDecision() {
67
+ return unexpectedCall("LogAPI.setInspectionDecision");
68
+ },
69
+ recordInspectionCompleted() {
70
+ return unexpectedCall("LogAPI.recordInspectionCompleted");
71
+ },
72
+ recordCloseoutCompleted() {
73
+ return unexpectedCall("LogAPI.recordCloseoutCompleted");
74
+ },
75
+ setWorkorder() {
76
+ return unexpectedCall("LogAPI.setWorkorder");
77
+ },
78
+ recordOperatorNotes() {
79
+ return unexpectedCall("LogAPI.recordOperatorNotes");
80
+ },
81
+ recordWorkorderComment() {
82
+ return unexpectedCall("LogAPI.recordWorkorderComment");
83
+ },
84
+ getActiveWorkorder() {
85
+ return unexpectedCall("LogAPI.getActiveWorkorder");
86
+ },
87
+ cancelRebooking() {
88
+ return unexpectedCall("LogAPI.cancelRebooking");
89
+ },
90
+ requestRebooking() {
91
+ return unexpectedCall("LogAPI.requestRebooking");
92
+ },
93
+ };
94
+ const jobBackend = {
95
+ history() {
96
+ return unexpectedCall("JobAPI.history");
97
+ },
98
+ recent() {
99
+ return unexpectedCall("JobAPI.recent");
100
+ },
101
+ currentStatus() {
102
+ return unexpectedCall("JobAPI.currentStatus");
103
+ },
104
+ setJobComment() {
105
+ return unexpectedCall("JobAPI.setJobComment");
106
+ },
107
+ removeMaterialFromAllQueues() {
108
+ return unexpectedCall("JobAPI.removeMaterialFromAllQueues");
109
+ },
110
+ bulkRemoveMaterialFromQueues() {
111
+ return unexpectedCall("JobAPI.bulkRemoveMaterialFromQueues");
112
+ },
113
+ setMaterialInQueue() {
114
+ return unexpectedCall("JobAPI.setMaterialInQueue");
115
+ },
116
+ addUnprocessedMaterialToQueue() {
117
+ return unexpectedCall("JobAPI.addUnprocessedMaterialToQueue");
118
+ },
119
+ addUnallocatedCastingToQueue() {
120
+ return unexpectedCall("JobAPI.addUnallocatedCastingToQueue");
121
+ },
122
+ signalMaterialForQuarantine() {
123
+ return unexpectedCall("JobAPI.signalMaterialForQuarantine");
124
+ },
125
+ swapMaterialOnPallet() {
126
+ return unexpectedCall("JobAPI.swapMaterialOnPallet");
127
+ },
128
+ invalidatePalletCycle() {
129
+ return unexpectedCall("JobAPI.invalidatePalletCycle");
130
+ },
131
+ unscheduledRebookings() {
132
+ return unexpectedCall("JobAPI.unscheduledRebookings");
133
+ },
134
+ };
135
+ const machineBackend = {
136
+ getToolsInMachines() {
137
+ return unexpectedCall("MachineAPI.getToolsInMachines");
138
+ },
139
+ getProgramsInCellController() {
140
+ return unexpectedCall("MachineAPI.getProgramsInCellController");
141
+ },
142
+ getProgramRevisionContent() {
143
+ return unexpectedCall("MachineAPI.getProgramRevisionContent");
144
+ },
145
+ getLatestProgramRevisionContent() {
146
+ return unexpectedCall("MachineAPI.getLatestProgramRevisionContent");
147
+ },
148
+ getProgramRevisionsInDescendingOrderOfRevision() {
149
+ return unexpectedCall("MachineAPI.getProgramRevisionsInDescendingOrderOfRevision");
150
+ },
151
+ };
152
+ const fmsBackend = {
153
+ fMSInformation() {
154
+ return unexpectedCall("FmsAPI.fMSInformation");
155
+ },
156
+ printLabel() {
157
+ return unexpectedCall("FmsAPI.printLabel");
158
+ },
159
+ parseBarcode() {
160
+ return Promise.reject(new ApiException("An unexpected server error occurred.", 400, barcodeError, {}, null));
161
+ },
162
+ enableVerboseLoggingForFiveMinutes() {
163
+ return unexpectedCall("FmsAPI.enableVerboseLoggingForFiveMinutes");
164
+ },
165
+ };
166
+ async function flushUi() {
167
+ for (let i = 0; i < 3; i += 1) {
168
+ await act(async () => {
169
+ await Promise.resolve();
170
+ });
171
+ }
172
+ }
173
+ afterEach(() => {
174
+ document.body.innerHTML = "";
175
+ });
176
+ it("shows barcode parse errors inside the material dialog", async () => {
177
+ const consoleError = vi.spyOn(console, "error").mockImplementation(() => { });
178
+ registerBackend(logBackend, jobBackend, fmsBackend, machineBackend);
179
+ const store = createStore();
180
+ store.set(materialDialogOpen, { type: "Barcode", barcode, toQueue: null });
181
+ const container = document.createElement("div");
182
+ document.body.append(container);
183
+ const root = createRoot(container);
184
+ try {
185
+ await act(async () => {
186
+ root.render(_jsx(Provider, { store: store, children: _jsx(MaterialDialog, {}) }));
187
+ });
188
+ await flushUi();
189
+ expect(document.body.textContent).toContain(barcode);
190
+ expect(document.body.textContent).toContain(barcodeError);
191
+ expect(document.body.textContent).not.toContain("An unexpected server error occurred.");
192
+ }
193
+ finally {
194
+ await act(async () => {
195
+ root.unmount();
196
+ });
197
+ consoleError.mockRestore();
198
+ }
199
+ });
@@ -157,14 +157,14 @@ export function selectQueueData(queuesToCheck, curSt, rawMatQueues, inProcQueues
157
157
  for (const queueName of queueNames) {
158
158
  const isRawMat = rawMatQueues.has(queueName);
159
159
  if (isRawMat) {
160
- const materialByPos = OrderedMap.empty();
160
+ let materialByPos = OrderedMap.empty();
161
161
  const matByPartThenUniq = new Map();
162
162
  for (const m of curSt.material) {
163
163
  if (m.location.type === api.LocType.InQueue &&
164
164
  m.location.currentQueue === queueName &&
165
165
  m.location.queuePosition !== undefined) {
166
166
  if ((m.serial && m.serial !== "") || m.action.type !== api.ActionType.Waiting) {
167
- materialByPos.set(m.location.queuePosition, m);
167
+ materialByPos = materialByPos.set(m.location.queuePosition, m);
168
168
  }
169
169
  else {
170
170
  let matsForPart = matByPartThenUniq.get(m.partName);
package/dist/index.html CHANGED
@@ -44,7 +44,7 @@
44
44
  }
45
45
  }
46
46
  </style>
47
- <script type="module" crossorigin src="/assets/index-bPAFn3jp.js"></script>
47
+ <script type="module" crossorigin src="/assets/index-BwbaiELK.js"></script>
48
48
  <link rel="stylesheet" crossorigin href="/assets/index-CbqW4-gR.css">
49
49
  </head>
50
50
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seedtactics/insight-client",
3
- "version": "16.7.0",
3
+ "version": "16.7.2",
4
4
  "license": "BSD-3-Clause",
5
5
  "type": "module",
6
6
  "repository": {
@@ -29,8 +29,8 @@
29
29
  "@fontsource/roboto": "^5.2.10",
30
30
  "@mui/icons-material": "^9.0.1",
31
31
  "@mui/material": "^9.0.1",
32
- "@react-spring/rafz": "^10.0.4",
33
- "@react-spring/web": "^10.0.4",
32
+ "@react-spring/rafz": "^10.1.0",
33
+ "@react-spring/web": "^10.1.0",
34
34
  "@seedtactics/immutable-collections": "^1.1.1",
35
35
  "@yudiel/react-qr-scanner": "^2.6.0",
36
36
  "copy-to-clipboard": "^4.0.2",
@@ -38,7 +38,7 @@
38
38
  "d3-sankey": "^0.12.3",
39
39
  "d3-scale": "^4.0.2",
40
40
  "d3-shape": "^3.2.0",
41
- "date-fns": "^4.2.1",
41
+ "date-fns": "^4.3.0",
42
42
  "highlight.js": "^11.11.1",
43
43
  "jdenticon": "^3.3.0",
44
44
  "jotai": "^2.20.0",
@@ -48,7 +48,7 @@
48
48
  "react": "^19.2.6",
49
49
  "react-calendar": "^6.0.1",
50
50
  "react-dom": "^19.2.6",
51
- "react-error-boundary": "^6.1.1",
51
+ "react-error-boundary": "^6.1.2",
52
52
  "react-resize-detector": "^12.3.0",
53
53
  "react-timeago": "^8.3.0",
54
54
  "react-to-print": "^3.3.0",