@questwork/q-inventory 0.1.0

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 (67) hide show
  1. package/.storybook/main.js +23 -0
  2. package/.storybook/preview.js +17 -0
  3. package/README.md +16 -0
  4. package/app/qInventory/App.vue +164 -0
  5. package/app/qInventory/index.html +12 -0
  6. package/app/qInventory/main.ts +4 -0
  7. package/app/qInventory/styles.scss +59 -0
  8. package/dist/components/InventoryAssetDetail.vue.d.ts +8 -0
  9. package/dist/components/InventoryAssetDetail.vue.d.ts.map +1 -0
  10. package/dist/components/InventoryLocationAdmin.vue.d.ts +10 -0
  11. package/dist/components/InventoryLocationAdmin.vue.d.ts.map +1 -0
  12. package/dist/components/InventoryLocationDetail.vue.d.ts +8 -0
  13. package/dist/components/InventoryLocationDetail.vue.d.ts.map +1 -0
  14. package/dist/components/InventoryOverview.vue.d.ts +15 -0
  15. package/dist/components/InventoryOverview.vue.d.ts.map +1 -0
  16. package/dist/components/InventoryScanner.vue.d.ts +21 -0
  17. package/dist/components/InventoryScanner.vue.d.ts.map +1 -0
  18. package/dist/components/QInventory.vue.d.ts +24 -0
  19. package/dist/components/QInventory.vue.d.ts.map +1 -0
  20. package/dist/index.d.ts +16 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/mixins/CSSMixin.d.ts +7 -0
  23. package/dist/mixins/CSSMixin.d.ts.map +1 -0
  24. package/dist/models/index.d.ts +62 -0
  25. package/dist/models/index.d.ts.map +1 -0
  26. package/dist/models/inventoryAssetRepoAxios.d.ts +18 -0
  27. package/dist/models/inventoryAssetRepoAxios.d.ts.map +1 -0
  28. package/dist/models/inventoryAuthRepoAxios.d.ts +26 -0
  29. package/dist/models/inventoryAuthRepoAxios.d.ts.map +1 -0
  30. package/dist/models/inventoryAxiosBase.d.ts +41 -0
  31. package/dist/models/inventoryAxiosBase.d.ts.map +1 -0
  32. package/dist/models/inventoryLocationRepoAxios.d.ts +13 -0
  33. package/dist/models/inventoryLocationRepoAxios.d.ts.map +1 -0
  34. package/dist/models/inventoryMovementRepoAxios.d.ts +13 -0
  35. package/dist/models/inventoryMovementRepoAxios.d.ts.map +1 -0
  36. package/dist/q-inventory.esm.js +961 -0
  37. package/dist/q-inventory.esm.js.map +1 -0
  38. package/dist/q-inventory.min.cjs +2 -0
  39. package/dist/q-inventory.min.cjs.map +1 -0
  40. package/dist/q-inventory.min.css +1 -0
  41. package/dist/q-inventory.min.js +2 -0
  42. package/dist/q-inventory.min.js.map +1 -0
  43. package/dist-app/qInventory/assets/q-inventory-app.css +1 -0
  44. package/dist-app/qInventory/assets/q-inventory-app.js +18 -0
  45. package/dist-app/qInventory/index.html +13 -0
  46. package/package.json +58 -0
  47. package/src/components/InventoryAssetDetail.vue +55 -0
  48. package/src/components/InventoryLocationAdmin.vue +56 -0
  49. package/src/components/InventoryLocationDetail.vue +51 -0
  50. package/src/components/InventoryOverview.vue +81 -0
  51. package/src/components/InventoryScanner.vue +315 -0
  52. package/src/components/QInventory.vue +117 -0
  53. package/src/index.ts +36 -0
  54. package/src/mixins/CSSMixin.ts +14 -0
  55. package/src/models/index.ts +114 -0
  56. package/src/models/inventoryAssetRepoAxios.ts +38 -0
  57. package/src/models/inventoryAuthRepoAxios.ts +48 -0
  58. package/src/models/inventoryAxiosBase.ts +149 -0
  59. package/src/models/inventoryLocationRepoAxios.ts +25 -0
  60. package/src/models/inventoryMovementRepoAxios.ts +24 -0
  61. package/src/styles/index.scss +148 -0
  62. package/stories/stories.scss +9 -0
  63. package/stories/stories.ts +362 -0
  64. package/tsconfig.json +29 -0
  65. package/vite.app.config.js +37 -0
  66. package/vite.config.js +68 -0
  67. package/vitest.config.js +11 -0
@@ -0,0 +1,961 @@
1
+ import { defineComponent as k, ref as A, computed as U, watch as ie, openBlock as u, createElementBlock as f, createElementVNode as r, normalizeClass as D, toDisplayString as m, withDirectives as E, withKeys as ce, vModelText as P, createCommentVNode as w, Fragment as b, renderList as T, withModifiers as Z, reactive as le, createVNode as de, vShow as ue, createBlock as x } from "vue";
2
+ import { INVENTORY_MOVEMENT_TYPE as I, getVirtualUserLocationCode as ve, parseInventoryQr as ye, isLocationQr as fe, INVENTORY_LOCATION_KIND as N, isVirtualInventoryLocation as me, isVirtualUserLocationCode as _e, getVirtualUserCode as ge } from "@questwork/q-inventory-model";
3
+ export * from "@questwork/q-inventory-model";
4
+ const pe = /* @__PURE__ */ k({
5
+ name: "inventory-scanner",
6
+ __name: "InventoryScanner",
7
+ props: {
8
+ assetApiClient: { type: Object, required: !1 },
9
+ assets: { type: Array, required: !1 },
10
+ currentUserCode: { type: String, required: !1 }
11
+ },
12
+ emits: ["moved", "scan"],
13
+ setup(s, { expose: e, emit: n }) {
14
+ e();
15
+ const t = s, a = n, l = A(""), o = A([]), v = A(""), _ = A(I.PICKUP), d = A([]), c = U(() => ve(t.currentUserCode || "currentUser")), g = U(() => _.value === I.PICKUP ? "Source" : "Destination");
16
+ ie(
17
+ () => [t.assets, c.value],
18
+ B,
19
+ { deep: !0, immediate: !0 }
20
+ );
21
+ function O(i) {
22
+ _.value = i, l.value = "", L({
23
+ message: `Mode changed to ${i}`,
24
+ status: "INFO",
25
+ title: "Mode"
26
+ });
27
+ }
28
+ async function R() {
29
+ const i = v.value.trim();
30
+ i && (v.value = "", await C(i));
31
+ }
32
+ async function C(i) {
33
+ const y = ye(i);
34
+ if (a("scan", { raw: i, parsed: y }), fe(i)) {
35
+ l.value = y.code, L({
36
+ message: `${g.value} set to ${y.code}`,
37
+ status: "INFO",
38
+ title: "Location"
39
+ });
40
+ return;
41
+ }
42
+ if (!l.value) {
43
+ L({
44
+ message: `Scan ${g.value.toLowerCase()} location first`,
45
+ status: "FAILED",
46
+ title: y.code
47
+ });
48
+ return;
49
+ }
50
+ const h = p(y.code);
51
+ try {
52
+ if (t.assetApiClient?.move) {
53
+ const K = await t.assetApiClient.move(h), W = H(K);
54
+ if (a("moved", h), V(h), W.length) {
55
+ L({
56
+ message: J(W),
57
+ status: "WARNING",
58
+ title: y.code
59
+ });
60
+ return;
61
+ }
62
+ } else
63
+ a("moved", h), V(h);
64
+ L({
65
+ message: `${h.fromLocationCode || "-"} -> ${h.toLocationCode}`,
66
+ status: "OK",
67
+ title: y.code
68
+ });
69
+ } catch (K) {
70
+ L({
71
+ message: Y(K),
72
+ status: "FAILED",
73
+ title: y.code
74
+ });
75
+ }
76
+ }
77
+ function p(i) {
78
+ return _.value === I.PICKUP ? {
79
+ assetTag: i,
80
+ fromLocationCode: l.value,
81
+ fromLocationKind: N.REGISTERED,
82
+ movementType: I.PICKUP,
83
+ toLocationCode: c.value,
84
+ toLocationKind: N.VIRTUAL
85
+ } : {
86
+ assetTag: i,
87
+ fromLocationCode: c.value,
88
+ fromLocationKind: N.VIRTUAL,
89
+ movementType: I.DROPOFF,
90
+ toLocationCode: l.value,
91
+ toLocationKind: N.REGISTERED
92
+ };
93
+ }
94
+ function V(i) {
95
+ if (i.toLocationCode === c.value) {
96
+ Q({
97
+ assetTag: i.assetTag,
98
+ currentLocationCode: c.value
99
+ });
100
+ return;
101
+ }
102
+ o.value = o.value.filter((y) => y.assetTag !== i.assetTag);
103
+ }
104
+ function Q(i) {
105
+ const y = o.value.findIndex((h) => h.assetTag === i.assetTag);
106
+ if (y >= 0) {
107
+ o.value[y] = {
108
+ ...o.value[y],
109
+ ...i
110
+ };
111
+ return;
112
+ }
113
+ o.value.unshift(i);
114
+ }
115
+ function B() {
116
+ o.value = (t.assets || []).map(F).filter((i) => !!i && i.currentLocationCode === c.value);
117
+ }
118
+ function F(i) {
119
+ const y = i, h = q(y.assetTag);
120
+ return h ? {
121
+ assetTag: h,
122
+ category: q(y.category),
123
+ currentLocationCode: q(y.currentLocationCode),
124
+ name: q(y.name)
125
+ } : null;
126
+ }
127
+ function L({ message: i, status: y, title: h }) {
128
+ d.value.unshift({
129
+ key: `${Date.now()}-${Math.random()}`,
130
+ message: i,
131
+ status: y,
132
+ title: h
133
+ }), d.value = d.value.slice(0, 30);
134
+ }
135
+ function q(i) {
136
+ return typeof i == "string" ? i : "";
137
+ }
138
+ function Y(i) {
139
+ return i instanceof Error ? i.message : String(i);
140
+ }
141
+ function H(i) {
142
+ return i?.data?.[0]?.warnings || [];
143
+ }
144
+ function J(i) {
145
+ return i.map((y) => `${y.code}: ${y.message}`).join("; ");
146
+ }
147
+ function re() {
148
+ d.value = [];
149
+ }
150
+ const G = { props: t, emit: a, activeLocationCode: l, basketItems: o, manualQr: v, mode: _, scanLog: d, holderLocationCode: c, locationLabel: g, setMode: O, submitManualQr: R, handleQr: C, getMovePayload: p, applyBasketMove: V, upsertBasketItem: Q, syncBasketFromAssets: B, toBasketItem: F, addLog: L, getString: q, getErrorMessage: Y, getMoveWarnings: H, formatWarnings: J, clearScanLog: re, get INVENTORY_MOVEMENT_TYPE() {
151
+ return I;
152
+ } };
153
+ return Object.defineProperty(G, "__isScriptSetup", { enumerable: !1, value: !0 }), G;
154
+ }
155
+ }), S = (s, e) => {
156
+ const n = s.__vccOpts || s;
157
+ for (const [t, a] of e)
158
+ n[t] = a;
159
+ return n;
160
+ }, he = { class: "inventory-scanner" }, Ae = { class: "inventory-scanner__mode" }, Ce = { class: "inventory-scanner__state" }, Le = { class: "inventory-scanner__manual" }, be = { class: "inventory-scanner__basket-header" }, Te = ["disabled"], Ie = { class: "inventory-scanner__basket" }, we = {
161
+ key: 0,
162
+ class: "inventory-scanner__empty"
163
+ }, ke = { class: "inventory-scanner__log" }, Se = {
164
+ key: 0,
165
+ class: "inventory-scanner__log-empty"
166
+ };
167
+ function Oe(s, e, n, t, a, l) {
168
+ return u(), f("div", he, [
169
+ r("div", Ae, [
170
+ r(
171
+ "button",
172
+ {
173
+ class: D(["inventory-scanner__mode-button", { "inventory-scanner__mode-button--active": t.mode === t.INVENTORY_MOVEMENT_TYPE.PICKUP }]),
174
+ type: "button",
175
+ onClick: e[0] || (e[0] = (o) => t.setMode(t.INVENTORY_MOVEMENT_TYPE.PICKUP))
176
+ },
177
+ " Pickup ",
178
+ 2
179
+ /* CLASS */
180
+ ),
181
+ r(
182
+ "button",
183
+ {
184
+ class: D(["inventory-scanner__mode-button", { "inventory-scanner__mode-button--active": t.mode === t.INVENTORY_MOVEMENT_TYPE.DROPOFF }]),
185
+ type: "button",
186
+ onClick: e[1] || (e[1] = (o) => t.setMode(t.INVENTORY_MOVEMENT_TYPE.DROPOFF))
187
+ },
188
+ " Drop-off ",
189
+ 2
190
+ /* CLASS */
191
+ )
192
+ ]),
193
+ r("div", Ce, [
194
+ r(
195
+ "div",
196
+ null,
197
+ "Mode: " + m(t.mode),
198
+ 1
199
+ /* TEXT */
200
+ ),
201
+ r(
202
+ "div",
203
+ null,
204
+ m(t.locationLabel) + ": " + m(t.activeLocationCode || "-"),
205
+ 1
206
+ /* TEXT */
207
+ ),
208
+ r(
209
+ "div",
210
+ null,
211
+ "Holder: " + m(t.holderLocationCode || "-"),
212
+ 1
213
+ /* TEXT */
214
+ )
215
+ ]),
216
+ r("div", Le, [
217
+ E(r(
218
+ "input",
219
+ {
220
+ "onUpdate:modelValue": e[2] || (e[2] = (o) => t.manualQr = o),
221
+ class: "inventory-scanner__input",
222
+ placeholder: "Scan or enter QR text",
223
+ onKeyup: ce(t.submitManualQr, ["enter"])
224
+ },
225
+ null,
226
+ 544
227
+ /* NEED_HYDRATION, NEED_PATCH */
228
+ ), [
229
+ [P, t.manualQr]
230
+ ]),
231
+ r("button", {
232
+ type: "button",
233
+ onClick: t.submitManualQr
234
+ }, "Submit")
235
+ ]),
236
+ r("div", be, [
237
+ r("div", null, [
238
+ e[3] || (e[3] = r(
239
+ "strong",
240
+ null,
241
+ "My Basket",
242
+ -1
243
+ /* CACHED */
244
+ )),
245
+ r(
246
+ "span",
247
+ null,
248
+ m(t.basketItems.length) + " on hand",
249
+ 1
250
+ /* TEXT */
251
+ )
252
+ ]),
253
+ r("button", {
254
+ type: "button",
255
+ disabled: t.scanLog.length === 0,
256
+ onClick: t.clearScanLog
257
+ }, " Clear log ", 8, Te)
258
+ ]),
259
+ r("div", Ie, [
260
+ t.basketItems.length === 0 ? (u(), f("div", we, " No items on hand ")) : w("v-if", !0),
261
+ (u(!0), f(
262
+ b,
263
+ null,
264
+ T(t.basketItems, (o) => (u(), f("div", {
265
+ key: o.assetTag,
266
+ class: "inventory-scanner__basket-item"
267
+ }, [
268
+ r(
269
+ "strong",
270
+ null,
271
+ m(o.assetTag),
272
+ 1
273
+ /* TEXT */
274
+ ),
275
+ r(
276
+ "small",
277
+ null,
278
+ m(o.name || o.category || o.currentLocationCode),
279
+ 1
280
+ /* TEXT */
281
+ )
282
+ ]))),
283
+ 128
284
+ /* KEYED_FRAGMENT */
285
+ ))
286
+ ]),
287
+ r("div", ke, [
288
+ (u(!0), f(
289
+ b,
290
+ null,
291
+ T(t.scanLog, (o) => (u(), f(
292
+ "div",
293
+ {
294
+ key: o.key,
295
+ class: D(["inventory-scanner__log-item", {
296
+ "inventory-scanner__log-item--failed": o.status === "FAILED",
297
+ "inventory-scanner__log-item--warning": o.status === "WARNING"
298
+ }])
299
+ },
300
+ [
301
+ r("div", null, [
302
+ r(
303
+ "strong",
304
+ null,
305
+ m(o.title),
306
+ 1
307
+ /* TEXT */
308
+ ),
309
+ r(
310
+ "span",
311
+ null,
312
+ m(o.status),
313
+ 1
314
+ /* TEXT */
315
+ )
316
+ ]),
317
+ r(
318
+ "small",
319
+ null,
320
+ m(o.message),
321
+ 1
322
+ /* TEXT */
323
+ )
324
+ ],
325
+ 2
326
+ /* CLASS */
327
+ ))),
328
+ 128
329
+ /* KEYED_FRAGMENT */
330
+ ))
331
+ ]),
332
+ t.scanLog.length === 0 ? (u(), f("div", Se, " Scan log will appear here ")) : w("v-if", !0)
333
+ ]);
334
+ }
335
+ const $ = /* @__PURE__ */ S(pe, [["render", Oe], ["__file", "/Users/donlee/Developer/qw.q.inventory/src/components/InventoryScanner.vue"]]), Re = /* @__PURE__ */ k({
336
+ name: "inventory-overview",
337
+ __name: "InventoryOverview",
338
+ props: {
339
+ assetApiClient: { type: Object, required: !1 },
340
+ assets: { type: Array, required: !1 },
341
+ locations: { type: Array, required: !1 }
342
+ },
343
+ emits: ["selectAsset", "selectLocation"],
344
+ setup(s, { expose: e }) {
345
+ e();
346
+ const n = s, t = A([]), a = U(() => t.value.length > 0 ? t.value : n.assets || []);
347
+ async function l() {
348
+ n.assetApiClient?.findAll && (t.value = await n.assetApiClient.findAll());
349
+ }
350
+ function o(c) {
351
+ return v(c, "id") || v(c, "assetTag") || JSON.stringify(c);
352
+ }
353
+ function v(c, g) {
354
+ return String(c?.[g] || "");
355
+ }
356
+ function _(c) {
357
+ const g = v(c, "currentLocationCode"), O = v(c, "currentLocationKind");
358
+ if (!g) return "Never scanned";
359
+ if (me({ locationCode: g, locationKind: O }) || _e(g))
360
+ return `In transit - ${ge(g)}`;
361
+ const R = (n.locations || []).find((C) => C.locationCode === g);
362
+ return String(R?.name || g);
363
+ }
364
+ const d = { props: n, loadedAssets: t, displayAssets: a, reload: l, getAssetKey: o, getAssetText: v, getDisplayLocation: _ };
365
+ return Object.defineProperty(d, "__isScriptSetup", { enumerable: !1, value: !0 }), d;
366
+ }
367
+ }), qe = { class: "inventory-overview" }, Ee = { class: "inventory-overview__rows" }, Ue = ["onClick"], xe = ["onClick"];
368
+ function Ne(s, e, n, t, a, l) {
369
+ return u(), f("div", qe, [
370
+ r("div", { class: "inventory-overview__header" }, [
371
+ e[0] || (e[0] = r(
372
+ "div",
373
+ null,
374
+ "Assets",
375
+ -1
376
+ /* CACHED */
377
+ )),
378
+ r("button", {
379
+ type: "button",
380
+ onClick: t.reload
381
+ }, "Reload")
382
+ ]),
383
+ r("div", Ee, [
384
+ (u(!0), f(
385
+ b,
386
+ null,
387
+ T(t.displayAssets, (o) => (u(), f("button", {
388
+ key: t.getAssetKey(o),
389
+ class: "inventory-overview__row",
390
+ type: "button",
391
+ onClick: (v) => s.$emit("selectAsset", o)
392
+ }, [
393
+ r(
394
+ "span",
395
+ null,
396
+ m(t.getAssetText(o, "assetTag")),
397
+ 1
398
+ /* TEXT */
399
+ ),
400
+ r(
401
+ "span",
402
+ null,
403
+ m(t.getAssetText(o, "name")),
404
+ 1
405
+ /* TEXT */
406
+ ),
407
+ r("span", {
408
+ class: "inventory-overview__location",
409
+ onClick: Z((v) => s.$emit("selectLocation", t.getAssetText(o, "currentLocationCode")), ["stop"])
410
+ }, m(t.getDisplayLocation(o)), 9, xe)
411
+ ], 8, Ue))),
412
+ 128
413
+ /* KEYED_FRAGMENT */
414
+ ))
415
+ ])
416
+ ]);
417
+ }
418
+ const ee = /* @__PURE__ */ S(Re, [["render", Ne], ["__file", "/Users/donlee/Developer/qw.q.inventory/src/components/InventoryOverview.vue"]]), De = /* @__PURE__ */ k({
419
+ name: "inventory-asset-detail",
420
+ __name: "InventoryAssetDetail",
421
+ props: {
422
+ movementApiClient: { type: Object, required: !1 },
423
+ asset: { type: null, required: !1 }
424
+ },
425
+ setup(s, { expose: e }) {
426
+ e();
427
+ const n = s, t = A([]);
428
+ async function a() {
429
+ const d = l("assetTag");
430
+ d && n.movementApiClient?.findAll && (t.value = await n.movementApiClient.findAll({ assetTag: d }));
431
+ }
432
+ function l(d) {
433
+ return String(n.asset?.[d] || "");
434
+ }
435
+ function o(d) {
436
+ const c = d;
437
+ return String(c.id || c.inventoryMovementCode || c.movedAt || JSON.stringify(d));
438
+ }
439
+ function v(d) {
440
+ const c = d;
441
+ return `${c.fromLocationCode || "-"} -> ${c.toLocationCode || "-"}`;
442
+ }
443
+ const _ = { props: n, history: t, loadHistory: a, getValue: l, getHistoryKey: o, getHistoryText: v };
444
+ return Object.defineProperty(_, "__isScriptSetup", { enumerable: !1, value: !0 }), _;
445
+ }
446
+ }), Pe = { class: "inventory-asset-detail" }, Me = {
447
+ key: 0,
448
+ class: "inventory-asset-detail__body"
449
+ }, Ve = {
450
+ key: 1,
451
+ class: "inventory-asset-detail__empty"
452
+ };
453
+ function Ke(s, e, n, t, a, l) {
454
+ return u(), f("div", Pe, [
455
+ n.asset ? (u(), f("div", Me, [
456
+ r(
457
+ "h3",
458
+ null,
459
+ m(t.getValue("assetTag")),
460
+ 1
461
+ /* TEXT */
462
+ ),
463
+ r(
464
+ "div",
465
+ null,
466
+ m(t.getValue("name")),
467
+ 1
468
+ /* TEXT */
469
+ ),
470
+ r(
471
+ "div",
472
+ null,
473
+ m(t.getValue("currentLocationCode")),
474
+ 1
475
+ /* TEXT */
476
+ ),
477
+ r("button", {
478
+ type: "button",
479
+ onClick: t.loadHistory
480
+ }, "Load History"),
481
+ (u(!0), f(
482
+ b,
483
+ null,
484
+ T(t.history, (o) => (u(), f(
485
+ "div",
486
+ {
487
+ key: t.getHistoryKey(o),
488
+ class: "inventory-asset-detail__history"
489
+ },
490
+ m(t.getHistoryText(o)),
491
+ 1
492
+ /* TEXT */
493
+ ))),
494
+ 128
495
+ /* KEYED_FRAGMENT */
496
+ ))
497
+ ])) : (u(), f("div", Ve, "No asset selected"))
498
+ ]);
499
+ }
500
+ const te = /* @__PURE__ */ S(De, [["render", Ke], ["__file", "/Users/donlee/Developer/qw.q.inventory/src/components/InventoryAssetDetail.vue"]]), je = /* @__PURE__ */ k({
501
+ name: "inventory-location-detail",
502
+ __name: "InventoryLocationDetail",
503
+ props: {
504
+ assetApiClient: { type: Object, required: !1 },
505
+ location: { type: null, required: !1 }
506
+ },
507
+ setup(s, { expose: e }) {
508
+ e();
509
+ const n = s, t = A([]), a = U(() => typeof n.location == "string" ? n.location : String(n.location?.locationCode || ""));
510
+ async function l() {
511
+ a.value && n.assetApiClient?.findAll && (t.value = await n.assetApiClient.findAll({ currentLocationCode: a.value }));
512
+ }
513
+ function o(d) {
514
+ const c = d;
515
+ return String(c.id || c.assetTag || JSON.stringify(d));
516
+ }
517
+ function v(d) {
518
+ const c = d;
519
+ return `${c.assetTag || ""} ${c.name || ""}`.trim();
520
+ }
521
+ const _ = { props: n, assets: t, locationCode: a, loadAssets: l, getAssetKey: o, getAssetText: v };
522
+ return Object.defineProperty(_, "__isScriptSetup", { enumerable: !1, value: !0 }), _;
523
+ }
524
+ }), Qe = { class: "inventory-location-detail" }, Be = { class: "inventory-location-detail__header" }, Fe = ["disabled"];
525
+ function Ye(s, e, n, t, a, l) {
526
+ return u(), f("div", Qe, [
527
+ r("div", Be, [
528
+ r(
529
+ "div",
530
+ null,
531
+ m(t.locationCode || "No location selected"),
532
+ 1
533
+ /* TEXT */
534
+ ),
535
+ r("button", {
536
+ type: "button",
537
+ disabled: !t.locationCode,
538
+ onClick: t.loadAssets
539
+ }, "Load Assets", 8, Fe)
540
+ ]),
541
+ (u(!0), f(
542
+ b,
543
+ null,
544
+ T(t.assets, (o) => (u(), f(
545
+ "div",
546
+ {
547
+ key: t.getAssetKey(o),
548
+ class: "inventory-location-detail__asset"
549
+ },
550
+ m(t.getAssetText(o)),
551
+ 1
552
+ /* TEXT */
553
+ ))),
554
+ 128
555
+ /* KEYED_FRAGMENT */
556
+ ))
557
+ ]);
558
+ }
559
+ const ne = /* @__PURE__ */ S(je, [["render", Ye], ["__file", "/Users/donlee/Developer/qw.q.inventory/src/components/InventoryLocationDetail.vue"]]), He = /* @__PURE__ */ k({
560
+ name: "inventory-location-admin",
561
+ __name: "InventoryLocationAdmin",
562
+ props: {
563
+ locations: { type: Array, required: !1 }
564
+ },
565
+ emits: ["saveLocation"],
566
+ setup(s, { expose: e, emit: n }) {
567
+ e();
568
+ const t = n, a = le({
569
+ locationCode: "",
570
+ locationType: "",
571
+ name: ""
572
+ });
573
+ function l() {
574
+ t("saveLocation", { ...a }), a.locationCode = "", a.locationType = "", a.name = "";
575
+ }
576
+ function o(d) {
577
+ const c = d;
578
+ return String(c.id || c.locationCode || JSON.stringify(d));
579
+ }
580
+ function v(d) {
581
+ const c = d;
582
+ return `${c.locationCode || ""} ${c.name || ""}`.trim();
583
+ }
584
+ const _ = { emit: t, form: a, submit: l, getLocationKey: o, getLocationText: v };
585
+ return Object.defineProperty(_, "__isScriptSetup", { enumerable: !1, value: !0 }), _;
586
+ }
587
+ }), Je = { class: "inventory-location-admin" };
588
+ function Ge(s, e, n, t, a, l) {
589
+ return u(), f("div", Je, [
590
+ r(
591
+ "form",
592
+ {
593
+ class: "inventory-location-admin__form",
594
+ onSubmit: Z(t.submit, ["prevent"])
595
+ },
596
+ [
597
+ E(r(
598
+ "input",
599
+ {
600
+ "onUpdate:modelValue": e[0] || (e[0] = (o) => t.form.locationCode = o),
601
+ placeholder: "Location code"
602
+ },
603
+ null,
604
+ 512
605
+ /* NEED_PATCH */
606
+ ), [
607
+ [P, t.form.locationCode]
608
+ ]),
609
+ E(r(
610
+ "input",
611
+ {
612
+ "onUpdate:modelValue": e[1] || (e[1] = (o) => t.form.name = o),
613
+ placeholder: "Name"
614
+ },
615
+ null,
616
+ 512
617
+ /* NEED_PATCH */
618
+ ), [
619
+ [P, t.form.name]
620
+ ]),
621
+ E(r(
622
+ "input",
623
+ {
624
+ "onUpdate:modelValue": e[2] || (e[2] = (o) => t.form.locationType = o),
625
+ placeholder: "Type"
626
+ },
627
+ null,
628
+ 512
629
+ /* NEED_PATCH */
630
+ ), [
631
+ [P, t.form.locationType]
632
+ ]),
633
+ e[3] || (e[3] = r(
634
+ "button",
635
+ { type: "submit" },
636
+ "Save",
637
+ -1
638
+ /* CACHED */
639
+ ))
640
+ ],
641
+ 32
642
+ /* NEED_HYDRATION */
643
+ ),
644
+ (u(!0), f(
645
+ b,
646
+ null,
647
+ T(n.locations, (o) => (u(), f(
648
+ "div",
649
+ {
650
+ key: t.getLocationKey(o),
651
+ class: "inventory-location-admin__row"
652
+ },
653
+ m(t.getLocationText(o)),
654
+ 1
655
+ /* TEXT */
656
+ ))),
657
+ 128
658
+ /* KEYED_FRAGMENT */
659
+ ))
660
+ ]);
661
+ }
662
+ const oe = /* @__PURE__ */ S(He, [["render", Ge], ["__file", "/Users/donlee/Developer/qw.q.inventory/src/components/InventoryLocationAdmin.vue"]]), We = /* @__PURE__ */ k({
663
+ name: "q-inventory",
664
+ __name: "QInventory",
665
+ props: {
666
+ assetApiClient: { type: Object, required: !1 },
667
+ locationApiClient: { type: Object, required: !1 },
668
+ movementApiClient: { type: Object, required: !1 },
669
+ assets: { type: Array, required: !1 },
670
+ currentUserCode: { type: String, required: !1 },
671
+ locations: { type: Array, required: !1 }
672
+ },
673
+ emits: ["moved", "saveLocation", "scan", "selectAsset", "selectLocation"],
674
+ setup(s, { expose: e, emit: n }) {
675
+ e();
676
+ const t = s, a = n, l = A("scanner"), o = A(null), v = A(null), _ = U(() => [
677
+ { key: "scanner", label: "Scan" },
678
+ { key: "overview", label: "Overview" },
679
+ { key: "asset", label: "Asset" },
680
+ { key: "location", label: "Location" },
681
+ { key: "locations", label: "Locations" }
682
+ ]);
683
+ function d(p) {
684
+ a("moved", p);
685
+ }
686
+ function c(p) {
687
+ a("scan", p);
688
+ }
689
+ function g(p) {
690
+ a("saveLocation", p);
691
+ }
692
+ function O(p) {
693
+ o.value = p, l.value = "asset", a("selectAsset", p);
694
+ }
695
+ function R(p) {
696
+ v.value = p, l.value = "location", a("selectLocation", p);
697
+ }
698
+ const C = { props: t, emit: a, activeTab: l, selectedAsset: o, selectedLocation: v, tabs: _, onMoved: d, onScan: c, onSaveLocation: g, onSelectAsset: O, onSelectLocation: R, InventoryScanner: $, InventoryOverview: ee, InventoryAssetDetail: te, InventoryLocationDetail: ne, InventoryLocationAdmin: oe };
699
+ return Object.defineProperty(C, "__isScriptSetup", { enumerable: !1, value: !0 }), C;
700
+ }
701
+ }), Xe = { class: "q-inventory" }, ze = { class: "q-inventory__toolbar" }, Ze = ["onClick"];
702
+ function $e(s, e, n, t, a, l) {
703
+ return u(), f("div", Xe, [
704
+ r("div", ze, [
705
+ (u(!0), f(
706
+ b,
707
+ null,
708
+ T(t.tabs, (o) => (u(), f("button", {
709
+ key: o.key,
710
+ class: D(["q-inventory__tab", { "q-inventory__tab--active": t.activeTab === o.key }]),
711
+ type: "button",
712
+ onClick: (v) => t.activeTab = o.key
713
+ }, m(o.label), 11, Ze))),
714
+ 128
715
+ /* KEYED_FRAGMENT */
716
+ ))
717
+ ]),
718
+ E(de(t.InventoryScanner, {
719
+ "asset-api-client": n.assetApiClient,
720
+ assets: n.assets,
721
+ "current-user-code": n.currentUserCode,
722
+ onMoved: t.onMoved,
723
+ onScan: t.onScan
724
+ }, null, 8, ["asset-api-client", "assets", "current-user-code"]), [
725
+ [ue, t.activeTab === "scanner"]
726
+ ]),
727
+ t.activeTab === "overview" ? (u(), x(t.InventoryOverview, {
728
+ key: 0,
729
+ "asset-api-client": n.assetApiClient,
730
+ assets: n.assets,
731
+ locations: n.locations,
732
+ onSelectAsset: t.onSelectAsset,
733
+ onSelectLocation: t.onSelectLocation
734
+ }, null, 8, ["asset-api-client", "assets", "locations"])) : w("v-if", !0),
735
+ t.activeTab === "asset" ? (u(), x(t.InventoryAssetDetail, {
736
+ key: 1,
737
+ "movement-api-client": n.movementApiClient,
738
+ asset: t.selectedAsset
739
+ }, null, 8, ["movement-api-client", "asset"])) : w("v-if", !0),
740
+ t.activeTab === "location" ? (u(), x(t.InventoryLocationDetail, {
741
+ key: 2,
742
+ "asset-api-client": n.assetApiClient,
743
+ location: t.selectedLocation
744
+ }, null, 8, ["asset-api-client", "location"])) : w("v-if", !0),
745
+ t.activeTab === "locations" ? (u(), x(t.InventoryLocationAdmin, {
746
+ key: 3,
747
+ locations: n.locations,
748
+ onSaveLocation: t.onSaveLocation
749
+ }, null, 8, ["locations"])) : w("v-if", !0)
750
+ ]);
751
+ }
752
+ const se = /* @__PURE__ */ S(We, [["render", $e], ["__file", "/Users/donlee/Developer/qw.q.inventory/src/components/QInventory.vue"]]);
753
+ class M {
754
+ constructor(e = {}) {
755
+ this.axios = e.axios, this.authenticatorTokenProvider = e.authenticatorTokenProvider, this.baseURL = (e.baseURL || "").replace(/\/$/, ""), this.movedBy = e.movedBy || "currentUser", this.qRepo = e.qRepo, this.tenantCode = e.tenantCode || "tenantCode", this.userTokenProvider = e.userTokenProvider;
756
+ }
757
+ async get(e, n = {}) {
758
+ const t = await this.getAuthHeaders();
759
+ if (this.axios) {
760
+ const o = await this.axios.get(this.getUrl(e), { headers: t, params: n });
761
+ return z(o.data);
762
+ }
763
+ const a = new URL(this.getUrl(e), et());
764
+ Object.entries(n).forEach(([o, v]) => {
765
+ typeof v < "u" && v !== null && v !== "" && a.searchParams.set(o, String(v));
766
+ });
767
+ const l = await fetch(this.getFetchUrl(a), { headers: t });
768
+ return z(await l.json(), l);
769
+ }
770
+ async post(e, n = {}) {
771
+ const t = {
772
+ "Content-Type": "application/json",
773
+ ...await this.getAuthHeaders()
774
+ };
775
+ if (this.axios) {
776
+ const l = await this.axios.post(this.getUrl(e), n, { headers: t });
777
+ return j(l.data);
778
+ }
779
+ const a = await fetch(this.getUrl(e), {
780
+ body: JSON.stringify(n),
781
+ headers: t,
782
+ method: "POST"
783
+ });
784
+ return j(await a.json(), a);
785
+ }
786
+ getUrl(e) {
787
+ return `${this.baseURL}/api/v1${e}`;
788
+ }
789
+ getFetchUrl(e) {
790
+ return this.baseURL ? e.toString() : `${e.pathname}${e.search}`;
791
+ }
792
+ withDefaults(e = {}) {
793
+ return ot({
794
+ ...e,
795
+ qRepo: e.qRepo || this.qRepo,
796
+ tenantCode: e.tenantCode || this.tenantCode
797
+ });
798
+ }
799
+ async getAuthHeaders() {
800
+ const e = {}, n = await X(this.authenticatorTokenProvider), t = await X(this.userTokenProvider);
801
+ return n && (e["X-Q-Authenticator"] = n), t && (e["X-Q-Inventory-User-Token"] = t), e;
802
+ }
803
+ }
804
+ async function X(s) {
805
+ return s ? s() : "";
806
+ }
807
+ function j(s, e) {
808
+ const n = s, t = n?.err, a = n?.errors;
809
+ if (e && !e.ok || t?.hasError || a)
810
+ throw new Error(tt({ data: n, err: t, errors: a, response: e }));
811
+ return n;
812
+ }
813
+ function z(s, e) {
814
+ const n = j(s, e);
815
+ return Array.isArray(n?.data) ? n.data : [];
816
+ }
817
+ function et() {
818
+ return typeof window < "u" ? window.location.origin : "http://localhost";
819
+ }
820
+ function tt({ data: s, err: e, errors: n, response: t }) {
821
+ const a = String(t?.status || e?.statusCode || e?.code || n?.name || s?.code || "REQUEST_ERROR"), l = nt(e?.message || n?.message || s?.message || "QInventory request failed");
822
+ return `${a}: ${l}`;
823
+ }
824
+ function nt(s) {
825
+ return Array.isArray(s) ? s.join("; ") : String(s);
826
+ }
827
+ function ot(s) {
828
+ return Object.fromEntries(
829
+ Object.entries(s).filter(([, e]) => typeof e < "u" && e !== null && e !== "")
830
+ );
831
+ }
832
+ class st extends M {
833
+ constructor(e = {}) {
834
+ super(e);
835
+ }
836
+ async findAll(e = {}) {
837
+ return this.get("/qInventoryAsset", this.withDefaults(e));
838
+ }
839
+ async findOne(e) {
840
+ return this.get(`/qInventoryAsset/${encodeURIComponent(e)}`, this.withDefaults());
841
+ }
842
+ async saveOne(e) {
843
+ return this.post("/qInventoryAsset", this.withDefaults(e));
844
+ }
845
+ async move(e) {
846
+ const n = String(e.assetTag || ""), t = e.movedBy || this.movedBy;
847
+ return this.post(`/qInventoryAsset/${encodeURIComponent(n)}/move`, this.withDefaults({
848
+ ...e,
849
+ movedBy: t
850
+ }));
851
+ }
852
+ }
853
+ class at extends M {
854
+ constructor(e = {}) {
855
+ super(e);
856
+ }
857
+ async findAll(e = {}) {
858
+ return this.get("/qInventoryLocation", this.withDefaults(e));
859
+ }
860
+ async findOne(e) {
861
+ return this.get(`/qInventoryLocation/${encodeURIComponent(e)}`, this.withDefaults());
862
+ }
863
+ async saveOne(e) {
864
+ return this.post("/qInventoryLocation", this.withDefaults(e));
865
+ }
866
+ }
867
+ class rt extends M {
868
+ constructor(e = {}) {
869
+ super(e);
870
+ }
871
+ async findAll(e = {}) {
872
+ const n = String(e.assetTag || "");
873
+ if (!n)
874
+ throw new Error("assetTag is required for movement findAll");
875
+ const { assetTag: t, ...a } = e;
876
+ return this.get(`/qInventoryAsset/${encodeURIComponent(n)}/movements`, this.withDefaults(a));
877
+ }
878
+ }
879
+ class lt extends M {
880
+ constructor(e = {}) {
881
+ super(e);
882
+ }
883
+ async getBrowserToken() {
884
+ return (await this.post("/qInventory/token", {
885
+ clientAppId: "qInventoryBrowser",
886
+ clientAppName: "qInventoryBrowser"
887
+ })).data?.[0];
888
+ }
889
+ async requestLoginLink({ email: e, tenantCode: n = this.tenantCode }) {
890
+ return (await this.post("/qInventory/login-link", {
891
+ email: e,
892
+ tenantCode: n
893
+ })).data?.[0];
894
+ }
895
+ async verifyLoginToken(e) {
896
+ return (await this.post("/qInventory/login-token/verify", {
897
+ loginToken: e
898
+ })).data?.[0];
899
+ }
900
+ }
901
+ class dt {
902
+ constructor(e = {}) {
903
+ this.assetRepo = new st(e), this.locationRepo = new at(e), this.movementRepo = new rt(e);
904
+ }
905
+ async findAll(e) {
906
+ return this.assetRepo.findAll(e);
907
+ }
908
+ async findOne(e) {
909
+ return this.assetRepo.findOne(e);
910
+ }
911
+ async saveOne(e) {
912
+ return this.assetRepo.saveOne(e);
913
+ }
914
+ async move(e) {
915
+ return this.assetRepo.move(e);
916
+ }
917
+ // Legacy alias for asset findAll
918
+ async findAssets(e) {
919
+ return this.assetRepo.findAll(e);
920
+ }
921
+ // Legacy alias for location findAll
922
+ async findLocations(e) {
923
+ return this.locationRepo.findAll(e);
924
+ }
925
+ // Legacy alias — location assets are just assets filtered by currentLocationCode
926
+ async findLocationAssets(e) {
927
+ return this.assetRepo.findAll({ currentLocationCode: e });
928
+ }
929
+ // Legacy alias for movement history
930
+ async findAssetHistory(e) {
931
+ return this.movementRepo.findAll({ assetTag: e });
932
+ }
933
+ // Legacy alias for move
934
+ async moveAsset(e) {
935
+ return this.assetRepo.move(e);
936
+ }
937
+ }
938
+ function ae(s) {
939
+ s.component("q-inventory", se), s.component("inventory-scanner", $), s.component("inventory-overview", ee), s.component("inventory-asset-detail", te), s.component("inventory-location-detail", ne), s.component("inventory-location-admin", oe);
940
+ }
941
+ se.install = ae;
942
+ const ut = {
943
+ install: ae
944
+ };
945
+ export {
946
+ te as InventoryAssetDetail,
947
+ st as InventoryAssetRepoAxios,
948
+ lt as InventoryAuthRepoAxios,
949
+ oe as InventoryLocationAdmin,
950
+ ne as InventoryLocationDetail,
951
+ at as InventoryLocationRepoAxios,
952
+ rt as InventoryMovementRepoAxios,
953
+ ee as InventoryOverview,
954
+ dt as InventoryRepoAxios,
955
+ M as InventoryRepoAxiosBase,
956
+ $ as InventoryScanner,
957
+ se as QInventory,
958
+ ut as default,
959
+ ae as install
960
+ };
961
+ //# sourceMappingURL=q-inventory.esm.js.map