punchout-simulator 0.5.1 → 0.5.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.
@@ -2132,6 +2132,21 @@ flowRoute.post("/:id/setup", async (c) => {
2132
2132
  response: respLog
2133
2133
  });
2134
2134
  });
2135
+ flowRoute.post("/:id/validate", async (c) => {
2136
+ const r = resolveVirtualBuyer(c.req.param("id"));
2137
+ if ("error" in r) return c.json({ error: r.error }, 400);
2138
+ const { ctx } = r;
2139
+ const body = await c.req.json().catch(() => ({}));
2140
+ const xml = String(body.xml ?? "");
2141
+ const docType = body.docType ?? "Unknown";
2142
+ return c.json(
2143
+ validateDocument(xml, {
2144
+ expected: ctx.expected,
2145
+ forceDocType: docType,
2146
+ allowMixedCurrency: ctx.allowMixedCurrency
2147
+ })
2148
+ );
2149
+ });
2135
2150
  function buildOrderXml(ctx, body) {
2136
2151
  const items = body.items ?? [];
2137
2152
  const currency = body.currency || items[0]?.currency || "USD";
@@ -2518,17 +2533,35 @@ simRoute.get("/:id/catalog", (c) => {
2518
2533
  return c.html(`<!doctype html><html lang="en"><head><meta charset="utf-8">
2519
2534
  <meta name="viewport" content="width=device-width, initial-scale=1">
2520
2535
  <title>${escapeXml(supplier.name)} \u2014 mock catalog</title>
2536
+ <script>
2537
+ // Match the main app's theme. The app appends ?theme= to the catalog link
2538
+ // (works even when the SPA is on a different origin, e.g. the Vite dev server);
2539
+ // otherwise fall back to a same-origin 'pos-theme' in localStorage, then the OS
2540
+ // preference. Set before paint to avoid a flash.
2541
+ (function () {
2542
+ try {
2543
+ var q = new URLSearchParams(location.search).get("theme");
2544
+ var t = (q === "light" || q === "dark") ? q : localStorage.getItem("pos-theme");
2545
+ if (t !== "light" && t !== "dark") {
2546
+ t = (window.matchMedia && matchMedia("(prefers-color-scheme: light)").matches) ? "light" : "dark";
2547
+ }
2548
+ document.documentElement.dataset.theme = t;
2549
+ } catch (e) {}
2550
+ })();
2551
+ </script>
2521
2552
  <style>
2522
- body{font-family:system-ui,sans-serif;background:#0f172a;color:#e2e8f0;margin:0;padding:2rem}
2553
+ :root{--bg:#0f172a;--text:#e2e8f0;--muted:#94a3b8;--panel:#1e293b;--th:#0b1220;--border:#334155;--field:#0b1220;--price:#fbbf24;--accent:#6366f1;--accent-hover:#4f46e5}
2554
+ :root[data-theme="light"]{--bg:#f5f7fb;--text:#1e293b;--muted:#4b5a73;--panel:#ffffff;--th:#eef1f7;--border:#d4dae8;--field:#ffffff;--price:#b45309;--accent:#6366f1;--accent-hover:#4f46e5}
2555
+ body{font-family:system-ui,sans-serif;background:var(--bg);color:var(--text);margin:0;padding:2rem}
2523
2556
  .wrap{max-width:720px;margin:0 auto}
2524
- h1{font-size:1.4rem}.sub{color:#94a3b8;margin-bottom:1.5rem}
2525
- table{width:100%;border-collapse:collapse;background:#1e293b;border-radius:12px;overflow:hidden}
2526
- th,td{padding:.75rem 1rem;text-align:left;border-bottom:1px solid #334155}
2527
- th{background:#0b1220;font-size:.8rem;text-transform:uppercase;letter-spacing:.05em;color:#94a3b8}
2528
- .price{white-space:nowrap;color:#fbbf24}
2529
- input[type=number]{width:5rem;background:#0b1220;border:1px solid #334155;color:#e2e8f0;border-radius:6px;padding:.35rem .5rem}
2530
- button{margin-top:1.5rem;background:#6366f1;color:#fff;border:0;border-radius:8px;padding:.7rem 1.4rem;font-size:1rem;cursor:pointer}
2531
- button:hover{background:#4f46e5}
2557
+ h1{font-size:1.4rem}.sub{color:var(--muted);margin-bottom:1.5rem}
2558
+ table{width:100%;border-collapse:collapse;background:var(--panel);border-radius:12px;overflow:hidden}
2559
+ th,td{padding:.75rem 1rem;text-align:left;border-bottom:1px solid var(--border)}
2560
+ th{background:var(--th);font-size:.8rem;text-transform:uppercase;letter-spacing:.05em;color:var(--muted)}
2561
+ .price{white-space:nowrap;color:var(--price)}
2562
+ input[type=number]{width:5rem;background:var(--field);border:1px solid var(--border);color:var(--text);border-radius:6px;padding:.35rem .5rem}
2563
+ button{margin-top:1.5rem;background:var(--accent);color:#fff;border:0;border-radius:8px;padding:.7rem 1.4rem;font-size:1rem;cursor:pointer}
2564
+ button:hover{background:var(--accent-hover)}
2532
2565
  </style></head><body><div class="wrap">
2533
2566
  <h1>${escapeXml(supplier.name)} <small>(virtual supplier)</small></h1>
2534
2567
  <div class="sub">Mock catalog served by punchout-simulator. Set quantities and return the cart.</div>
@@ -1,4 +1,4 @@
1
- import{m as et}from"./index-DRD_fRQi.js";/*!-----------------------------------------------------------------------------
1
+ import{m as et}from"./index-CR8XUPcx.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -1,4 +1,4 @@
1
- import{m as f}from"./index-DRD_fRQi.js";/*!-----------------------------------------------------------------------------
1
+ import{m as f}from"./index-CR8XUPcx.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -1,4 +1,4 @@
1
- import{m as l}from"./index-DRD_fRQi.js";/*!-----------------------------------------------------------------------------
1
+ import{m as l}from"./index-CR8XUPcx.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -1,4 +1,4 @@
1
- import{m as s}from"./index-DRD_fRQi.js";/*!-----------------------------------------------------------------------------
1
+ import{m as s}from"./index-CR8XUPcx.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -1,4 +1,4 @@
1
- import{m as lt}from"./index-DRD_fRQi.js";/*!-----------------------------------------------------------------------------
1
+ import{m as lt}from"./index-CR8XUPcx.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license