@legenki/print2medusa 0.9.5 → 0.9.6

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.
@@ -195,12 +195,12 @@ const PrintfulSyncWidget = () => {
195
195
  void loadWebhook();
196
196
  }, []);
197
197
  react.useEffect(() => {
198
- if (!(status == null ? void 0 : status.running)) {
198
+ if (!status?.running) {
199
199
  return;
200
200
  }
201
201
  const t = setInterval(() => void loadStatus(), 3e3);
202
202
  return () => clearInterval(t);
203
- }, [status == null ? void 0 : status.running]);
203
+ }, [status?.running]);
204
204
  const onRegisterWebhook = async () => {
205
205
  setRegistering(true);
206
206
  try {
@@ -259,8 +259,8 @@ const PrintfulSyncWidget = () => {
259
259
  setSyncing(false);
260
260
  }
261
261
  };
262
- const latest = status == null ? void 0 : status.latest_sync;
263
- const running = (status == null ? void 0 : status.running) === true;
262
+ const latest = status?.latest_sync;
263
+ const running = status?.running === true;
264
264
  return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "divide-y p-0", children: [
265
265
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
266
266
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
@@ -317,7 +317,7 @@ const PrintfulSyncWidget = () => {
317
317
  variant: "secondary",
318
318
  onClick: () => void onRegisterWebhook(),
319
319
  isLoading: registering,
320
- disabled: webhookLoading || registering || !(webhook == null ? void 0 : webhook.secret_set),
320
+ disabled: webhookLoading || registering || !webhook?.secret_set,
321
321
  children: "Register webhook"
322
322
  }
323
323
  )
@@ -379,7 +379,6 @@ const minutesSince = (iso) => {
379
379
  return Math.floor((Date.now() - new Date(iso).getTime()) / 6e4);
380
380
  };
381
381
  const PrintfulPage = () => {
382
- var _a, _b, _c;
383
382
  const [syncs, setSyncs] = react.useState([]);
384
383
  const [health, setHealth] = react.useState(null);
385
384
  const [stats, setStats] = react.useState(null);
@@ -392,7 +391,6 @@ const PrintfulPage = () => {
392
391
  const [loading, setLoading] = react.useState(true);
393
392
  const [clearing, setClearing] = react.useState(false);
394
393
  const load = react.useCallback(async () => {
395
- var _a2;
396
394
  const [h, w, s, d, b] = await Promise.allSettled([
397
395
  fetch("/admin/printful/history", { credentials: "include" }),
398
396
  fetch("/admin/printful/health", { credentials: "include" }),
@@ -409,7 +407,7 @@ const PrintfulPage = () => {
409
407
  }
410
408
  if (s.status === "fulfilled" && s.value.ok) {
411
409
  const body = await s.value.json();
412
- setStats(((_a2 = body.statistics) == null ? void 0 : _a2[0]) ?? null);
410
+ setStats(body.statistics?.[0] ?? null);
413
411
  }
414
412
  if (d.status === "fulfilled" && d.value.ok) {
415
413
  const body = await d.value.json();
@@ -446,7 +444,7 @@ const PrintfulPage = () => {
446
444
  void loadPrompts();
447
445
  }, [loadPrompts]);
448
446
  const latest = syncs[0];
449
- const running = (latest == null ? void 0 : latest.status) === "running";
447
+ const running = latest?.status === "running";
450
448
  react.useEffect(() => {
451
449
  if (!running) {
452
450
  return;
@@ -484,8 +482,8 @@ const PrintfulPage = () => {
484
482
  setClearing(false);
485
483
  }
486
484
  };
487
- const stuck = looksStuck(latest, (health == null ? void 0 : health.window) ?? 60);
488
- const silentFor = minutesSince((latest == null ? void 0 : latest.heartbeat_at) ?? (latest == null ? void 0 : latest.started_at));
485
+ const stuck = looksStuck(latest, health?.window ?? 60);
486
+ const silentFor = minutesSince(latest?.heartbeat_at ?? latest?.started_at);
489
487
  return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "divide-y p-0", children: [
490
488
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
491
489
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Printful" }),
@@ -526,13 +524,13 @@ const PrintfulPage = () => {
526
524
  stats ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
527
525
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
528
526
  "Paid orders: ",
529
- ((_a = stats.total_paid_orders) == null ? void 0 : _a.value) ?? "—"
527
+ stats.total_paid_orders?.value ?? "—"
530
528
  ] }),
531
529
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
532
530
  "Profit: ",
533
- ((_b = stats.profit) == null ? void 0 : _b.value) ?? "—",
531
+ stats.profit?.value ?? "—",
534
532
  " ",
535
- ((_c = stats.currency) == null ? void 0 : _c.toUpperCase()) ?? ""
533
+ stats.currency?.toUpperCase() ?? ""
536
534
  ] })
537
535
  ] }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: loading ? "Loading…" : "Printful reported no statistics." })
538
536
  ] }),
@@ -194,12 +194,12 @@ const PrintfulSyncWidget = () => {
194
194
  void loadWebhook();
195
195
  }, []);
196
196
  useEffect(() => {
197
- if (!(status == null ? void 0 : status.running)) {
197
+ if (!status?.running) {
198
198
  return;
199
199
  }
200
200
  const t = setInterval(() => void loadStatus(), 3e3);
201
201
  return () => clearInterval(t);
202
- }, [status == null ? void 0 : status.running]);
202
+ }, [status?.running]);
203
203
  const onRegisterWebhook = async () => {
204
204
  setRegistering(true);
205
205
  try {
@@ -258,8 +258,8 @@ const PrintfulSyncWidget = () => {
258
258
  setSyncing(false);
259
259
  }
260
260
  };
261
- const latest = status == null ? void 0 : status.latest_sync;
262
- const running = (status == null ? void 0 : status.running) === true;
261
+ const latest = status?.latest_sync;
262
+ const running = status?.running === true;
263
263
  return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
264
264
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
265
265
  /* @__PURE__ */ jsxs("div", { children: [
@@ -316,7 +316,7 @@ const PrintfulSyncWidget = () => {
316
316
  variant: "secondary",
317
317
  onClick: () => void onRegisterWebhook(),
318
318
  isLoading: registering,
319
- disabled: webhookLoading || registering || !(webhook == null ? void 0 : webhook.secret_set),
319
+ disabled: webhookLoading || registering || !webhook?.secret_set,
320
320
  children: "Register webhook"
321
321
  }
322
322
  )
@@ -378,7 +378,6 @@ const minutesSince = (iso) => {
378
378
  return Math.floor((Date.now() - new Date(iso).getTime()) / 6e4);
379
379
  };
380
380
  const PrintfulPage = () => {
381
- var _a, _b, _c;
382
381
  const [syncs, setSyncs] = useState([]);
383
382
  const [health, setHealth] = useState(null);
384
383
  const [stats, setStats] = useState(null);
@@ -391,7 +390,6 @@ const PrintfulPage = () => {
391
390
  const [loading, setLoading] = useState(true);
392
391
  const [clearing, setClearing] = useState(false);
393
392
  const load = useCallback(async () => {
394
- var _a2;
395
393
  const [h, w, s, d, b] = await Promise.allSettled([
396
394
  fetch("/admin/printful/history", { credentials: "include" }),
397
395
  fetch("/admin/printful/health", { credentials: "include" }),
@@ -408,7 +406,7 @@ const PrintfulPage = () => {
408
406
  }
409
407
  if (s.status === "fulfilled" && s.value.ok) {
410
408
  const body = await s.value.json();
411
- setStats(((_a2 = body.statistics) == null ? void 0 : _a2[0]) ?? null);
409
+ setStats(body.statistics?.[0] ?? null);
412
410
  }
413
411
  if (d.status === "fulfilled" && d.value.ok) {
414
412
  const body = await d.value.json();
@@ -445,7 +443,7 @@ const PrintfulPage = () => {
445
443
  void loadPrompts();
446
444
  }, [loadPrompts]);
447
445
  const latest = syncs[0];
448
- const running = (latest == null ? void 0 : latest.status) === "running";
446
+ const running = latest?.status === "running";
449
447
  useEffect(() => {
450
448
  if (!running) {
451
449
  return;
@@ -483,8 +481,8 @@ const PrintfulPage = () => {
483
481
  setClearing(false);
484
482
  }
485
483
  };
486
- const stuck = looksStuck(latest, (health == null ? void 0 : health.window) ?? 60);
487
- const silentFor = minutesSince((latest == null ? void 0 : latest.heartbeat_at) ?? (latest == null ? void 0 : latest.started_at));
484
+ const stuck = looksStuck(latest, health?.window ?? 60);
485
+ const silentFor = minutesSince(latest?.heartbeat_at ?? latest?.started_at);
488
486
  return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
489
487
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
490
488
  /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Printful" }),
@@ -525,13 +523,13 @@ const PrintfulPage = () => {
525
523
  stats ? /* @__PURE__ */ jsxs(Fragment, { children: [
526
524
  /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
527
525
  "Paid orders: ",
528
- ((_a = stats.total_paid_orders) == null ? void 0 : _a.value) ?? "—"
526
+ stats.total_paid_orders?.value ?? "—"
529
527
  ] }),
530
528
  /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
531
529
  "Profit: ",
532
- ((_b = stats.profit) == null ? void 0 : _b.value) ?? "—",
530
+ stats.profit?.value ?? "—",
533
531
  " ",
534
- ((_c = stats.currency) == null ? void 0 : _c.toUpperCase()) ?? ""
532
+ stats.currency?.toUpperCase() ?? ""
535
533
  ] })
536
534
  ] }) : /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: loading ? "Loading…" : "Printful reported no statistics." })
537
535
  ] }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legenki/print2medusa",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "Printful → Medusa v2 plugin: product sync, auto fulfillment, and admin tools",
5
5
  "author": "Andy Legenki",
6
6
  "license": "MIT",
@@ -53,14 +53,14 @@
53
53
  "prepublishOnly": "medusa plugin:build"
54
54
  },
55
55
  "devDependencies": {
56
- "@medusajs/admin-sdk": "2.18.0",
57
- "@medusajs/cli": "2.18.0",
58
- "@medusajs/eslint-plugin": "2.18.0",
59
- "@medusajs/framework": "2.18.0",
60
- "@medusajs/icons": "2.18.0",
61
- "@medusajs/medusa": "2.18.0",
62
- "@medusajs/test-utils": "2.18.0",
63
- "@medusajs/ui": "4.2.0",
56
+ "@medusajs/admin-sdk": "2.19.0",
57
+ "@medusajs/cli": "2.19.0",
58
+ "@medusajs/eslint-plugin": "2.19.0",
59
+ "@medusajs/framework": "2.19.0",
60
+ "@medusajs/icons": "2.19.0",
61
+ "@medusajs/medusa": "2.19.0",
62
+ "@medusajs/test-utils": "2.19.0",
63
+ "@medusajs/ui": "4.2.1",
64
64
  "@swc/core": "^1.7.28",
65
65
  "@types/node": "^20.0.0",
66
66
  "@types/react": "^18.3.2",