punchout-simulator 0.5.0 → 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.
- package/dist/server/cli.js +46 -11
- package/dist/web/assets/{cssMode-BbEnQNgt.js → cssMode-BNnlXFNU.js} +1 -1
- package/dist/web/assets/{freemarker2-B66AqaBn.js → freemarker2-BuNAmJWP.js} +1 -1
- package/dist/web/assets/{handlebars-VHNJA3L3.js → handlebars-BJ-VFQ5X.js} +1 -1
- package/dist/web/assets/{html-DKhtq5mU.js → html-BkFoYEs4.js} +1 -1
- package/dist/web/assets/{htmlMode-DTvp4_of.js → htmlMode-DamCYXd_.js} +1 -1
- package/dist/web/assets/{index-WgWCySdd.css → index-BMoN8EG3.css} +1 -1
- package/dist/web/assets/{index-DRD_fRQi.js → index-CR8XUPcx.js} +161 -161
- package/dist/web/assets/{javascript-C7niBpqn.js → javascript-IrwRCTVa.js} +1 -1
- package/dist/web/assets/{jsonMode-mhDIEB_U.js → jsonMode-BGCKIu47.js} +1 -1
- package/dist/web/assets/{liquid-v92UUGTF.js → liquid-D5qP5QxV.js} +1 -1
- package/dist/web/assets/{mdx-upBohKLC.js → mdx-DPwh6PUj.js} +1 -1
- package/dist/web/assets/{python-BptHZKfu.js → python-DlzVHyu7.js} +1 -1
- package/dist/web/assets/{razor-D3-LbWWb.js → razor-D8NvtH9c.js} +1 -1
- package/dist/web/assets/{tsMode-0LcFoT79.js → tsMode-CJgtFdcK.js} +1 -1
- package/dist/web/assets/{typescript-ClLaLjem.js → typescript-BNSC8ixL.js} +1 -1
- package/dist/web/assets/{xml-BIefLbdX.js → xml-C_t3QDrI.js} +1 -1
- package/dist/web/assets/{yaml-D3udJL_a.js → yaml-BM1u2RtM.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
package/dist/server/cli.js
CHANGED
|
@@ -1650,7 +1650,7 @@ function credKnown(c, exp) {
|
|
|
1650
1650
|
if (!c) return false;
|
|
1651
1651
|
return [exp.from, exp.to, exp.sender].some((k) => credEq(c, k));
|
|
1652
1652
|
}
|
|
1653
|
-
function checkGeneral(doc, ctx, issues) {
|
|
1653
|
+
function checkGeneral(doc, ctx, issues, docType) {
|
|
1654
1654
|
const payloadId = getPayloadId(doc);
|
|
1655
1655
|
if (!payloadId) {
|
|
1656
1656
|
issues.error("missing-payloadID", "cXML/@payloadID is missing", "cXML/@payloadID");
|
|
@@ -1665,6 +1665,8 @@ function checkGeneral(doc, ctx, issues) {
|
|
|
1665
1665
|
issues.error("missing-timestamp", "cXML/@timestamp is missing", "cXML/@timestamp");
|
|
1666
1666
|
}
|
|
1667
1667
|
if (!ctx.expected) return;
|
|
1668
|
+
const carriesHeader = docType === "SetupRequest" || docType === "OrderRequest" || docType === "PunchOutOrderMessage";
|
|
1669
|
+
if (!carriesHeader) return;
|
|
1668
1670
|
const exp = ctx.expected;
|
|
1669
1671
|
const creds = getHeaderCredentials(doc);
|
|
1670
1672
|
for (const [name, c] of [
|
|
@@ -1967,7 +1969,7 @@ function validateDocument(raw, ctx = {}) {
|
|
|
1967
1969
|
return { docType: "Unknown", wellFormed: false, ok: false, issues: issues.list };
|
|
1968
1970
|
}
|
|
1969
1971
|
const docType = ctx.forceDocType ?? getDocType(doc);
|
|
1970
|
-
checkGeneral(doc, ctx, issues);
|
|
1972
|
+
checkGeneral(doc, ctx, issues, docType);
|
|
1971
1973
|
switch (docType) {
|
|
1972
1974
|
case "SetupRequest":
|
|
1973
1975
|
checkSharedSecret(doc, ctx, issues);
|
|
@@ -2130,6 +2132,21 @@ flowRoute.post("/:id/setup", async (c) => {
|
|
|
2130
2132
|
response: respLog
|
|
2131
2133
|
});
|
|
2132
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
|
+
});
|
|
2133
2150
|
function buildOrderXml(ctx, body) {
|
|
2134
2151
|
const items = body.items ?? [];
|
|
2135
2152
|
const currency = body.currency || items[0]?.currency || "USD";
|
|
@@ -2516,17 +2533,35 @@ simRoute.get("/:id/catalog", (c) => {
|
|
|
2516
2533
|
return c.html(`<!doctype html><html lang="en"><head><meta charset="utf-8">
|
|
2517
2534
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2518
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>
|
|
2519
2552
|
<style>
|
|
2520
|
-
|
|
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}
|
|
2521
2556
|
.wrap{max-width:720px;margin:0 auto}
|
|
2522
|
-
h1{font-size:1.4rem}.sub{color
|
|
2523
|
-
table{width:100%;border-collapse:collapse;background
|
|
2524
|
-
th,td{padding:.75rem 1rem;text-align:left;border-bottom:1px solid
|
|
2525
|
-
th{background
|
|
2526
|
-
.price{white-space:nowrap;color
|
|
2527
|
-
input[type=number]{width:5rem;background
|
|
2528
|
-
button{margin-top:1.5rem;background
|
|
2529
|
-
button:hover{background
|
|
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)}
|
|
2530
2565
|
</style></head><body><div class="wrap">
|
|
2531
2566
|
<h1>${escapeXml(supplier.name)} <small>(virtual supplier)</small></h1>
|
|
2532
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|