punchout-simulator 0.1.4 → 0.1.5
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 +22 -10
- package/dist/server/cli.js.map +1 -1
- package/dist/web/assets/{cssMode-DLffFuN6.js → cssMode-WA7HerFP.js} +1 -1
- package/dist/web/assets/{freemarker2-zfr9jUGh.js → freemarker2-BTOdUHiQ.js} +1 -1
- package/dist/web/assets/{handlebars-M_QseyaG.js → handlebars-DdTiW10M.js} +1 -1
- package/dist/web/assets/{html-BRMBHmCq.js → html-CP7qpuUD.js} +1 -1
- package/dist/web/assets/{htmlMode-CicmEJMR.js → htmlMode-BG3HQ1Sh.js} +1 -1
- package/dist/web/assets/{index-sxaLM6ld.css → index-CRWJsM13.css} +1 -1
- package/dist/web/assets/{index-Cm4lvUlh.js → index-DQ_OSoxK.js} +166 -166
- package/dist/web/assets/{javascript-D6_vZEGx.js → javascript-IQKq-LZB.js} +1 -1
- package/dist/web/assets/{jsonMode-CTxq7vAq.js → jsonMode-B1p3z-UY.js} +1 -1
- package/dist/web/assets/{liquid-BUpPE-Wb.js → liquid-4Fxw7q97.js} +1 -1
- package/dist/web/assets/{mdx-ymOE7fzM.js → mdx-00dxYvhf.js} +1 -1
- package/dist/web/assets/{python-Db74sog5.js → python-BI6CPDlf.js} +1 -1
- package/dist/web/assets/{razor-BxQoOni_.js → razor-DGRBM6nC.js} +1 -1
- package/dist/web/assets/{tsMode-C9sm5xMG.js → tsMode-BVtwLDYC.js} +1 -1
- package/dist/web/assets/{typescript-Ctr2X0xG.js → typescript-Dgh1yWP4.js} +1 -1
- package/dist/web/assets/{xml-DGpUXjuk.js → xml-BOb15_Cq.js} +1 -1
- package/dist/web/assets/{yaml-6Dpo9WGU.js → yaml-Dv2aUhkS.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
package/dist/server/cli.js
CHANGED
|
@@ -1237,23 +1237,16 @@ flowRoute.post("/:id/setup", async (c) => {
|
|
|
1237
1237
|
response: respLog
|
|
1238
1238
|
});
|
|
1239
1239
|
});
|
|
1240
|
-
|
|
1241
|
-
const conn = getConnection(c.req.param("id"));
|
|
1242
|
-
const err = requireVirtualBuyer(conn);
|
|
1243
|
-
if (err) return c.json({ error: err }, 400);
|
|
1244
|
-
const body = await c.req.json().catch(() => ({}));
|
|
1245
|
-
const sessionId = body.sessionId || `pos-${nanoid5(16)}`;
|
|
1240
|
+
function buildOrderXml(conn, body) {
|
|
1246
1241
|
const items = body.items ?? [];
|
|
1247
1242
|
const currency = body.currency || items[0]?.currency || "USD";
|
|
1248
1243
|
const total = body.total ?? items.reduce((s, it) => s + (it.unitPriceAmount ?? 0) * it.quantity, 0);
|
|
1249
1244
|
const orderId = body.orderId || `PO-${nanoid5(8)}`;
|
|
1250
|
-
const
|
|
1251
|
-
const inputAtts = body.attachments ?? [];
|
|
1252
|
-
const attMeta = inputAtts.map((a) => ({
|
|
1245
|
+
const attMeta = (body.attachments ?? []).map((a) => ({
|
|
1253
1246
|
contentId: a.contentId,
|
|
1254
1247
|
scope: a.scope === "order" || a.scope == null ? "order" : { itemIndex: Number(a.scope) }
|
|
1255
1248
|
}));
|
|
1256
|
-
const xml =
|
|
1249
|
+
const xml = buildOrderRequest({
|
|
1257
1250
|
from: conn.from,
|
|
1258
1251
|
to: conn.to,
|
|
1259
1252
|
sender: conn.sender,
|
|
@@ -1270,6 +1263,25 @@ flowRoute.post("/:id/order", async (c) => {
|
|
|
1270
1263
|
billTo: body.billTo,
|
|
1271
1264
|
attachments: attMeta
|
|
1272
1265
|
});
|
|
1266
|
+
return { xml, orderId };
|
|
1267
|
+
}
|
|
1268
|
+
flowRoute.post("/:id/order/preview", async (c) => {
|
|
1269
|
+
const conn = getConnection(c.req.param("id"));
|
|
1270
|
+
const err = requireVirtualBuyer(conn);
|
|
1271
|
+
if (err) return c.json({ error: err }, 400);
|
|
1272
|
+
const body = await c.req.json().catch(() => ({}));
|
|
1273
|
+
const { xml, orderId } = buildOrderXml(conn, body);
|
|
1274
|
+
return c.json({ xml, orderId });
|
|
1275
|
+
});
|
|
1276
|
+
flowRoute.post("/:id/order", async (c) => {
|
|
1277
|
+
const conn = getConnection(c.req.param("id"));
|
|
1278
|
+
const err = requireVirtualBuyer(conn);
|
|
1279
|
+
if (err) return c.json({ error: err }, 400);
|
|
1280
|
+
const body = await c.req.json().catch(() => ({}));
|
|
1281
|
+
const sessionId = body.sessionId || `pos-${nanoid5(16)}`;
|
|
1282
|
+
const dangling = !!body.danglingCid;
|
|
1283
|
+
const inputAtts = body.attachments ?? [];
|
|
1284
|
+
const xml = body.xml || buildOrderXml(conn, body).xml;
|
|
1273
1285
|
let wireBody = xml;
|
|
1274
1286
|
let wireContentType = "text/xml; charset=UTF-8";
|
|
1275
1287
|
const availableContentIds = /* @__PURE__ */ new Set();
|