@cimplify/sdk 0.89.0 → 0.92.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.
- package/dist/advanced.d.mts +3 -3
- package/dist/advanced.d.ts +3 -3
- package/dist/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-JHJTXAPS.js → chunk-3MBMIEWT.js} +4 -4
- package/dist/{chunk-DENWOZEA.mjs → chunk-3XD2FVP4.mjs} +163 -43
- package/dist/{chunk-M4ALCELT.mjs → chunk-54H2YYIW.mjs} +2 -2
- package/dist/{chunk-T2CJ67QV.js → chunk-DCRN67NO.js} +201 -78
- package/dist/{chunk-T7Z25EY4.js → chunk-HKN3YG76.js} +84 -0
- package/dist/{chunk-GHFDYM5K.js → chunk-IVJEUGWF.js} +10 -1
- package/dist/{chunk-ROBTTS3Q.js → chunk-OAHSF542.js} +40 -1
- package/dist/{chunk-APBLFZ2I.mjs → chunk-PYBFTMHI.mjs} +40 -1
- package/dist/{chunk-OZDDHSIB.mjs → chunk-RRBY35TJ.mjs} +80 -1
- package/dist/{chunk-ZU4ZRYUR.mjs → chunk-T7LDBZZZ.mjs} +10 -1
- package/dist/chunk-U4MW6PYU.mjs +23 -0
- package/dist/chunk-XREIZ56K.js +26 -0
- package/dist/{client-CqZgdUtw.d.ts → client-BQbSKlHS.d.mts} +165 -11
- package/dist/{client-CAY2NbRG.d.mts → client-Bw4HtLP1.d.mts} +2 -2
- package/dist/{client-D8ZFs-sq.d.mts → client-CeW3acve.d.ts} +165 -11
- package/dist/{client-CUbwb6Om.d.ts → client-Otzv_rgP.d.ts} +2 -2
- package/dist/{index-CmWOz9bi.d.mts → index-CmIboQjl.d.mts} +3 -3
- package/dist/{index-Bc5qUxAt.d.ts → index-DgoRwz8l.d.ts} +3 -3
- package/dist/index.d.mts +49 -7
- package/dist/index.d.ts +49 -7
- package/dist/index.js +109 -82
- package/dist/index.mjs +11 -5
- package/dist/mock/cli.mjs +61 -1
- package/dist/mock/library.js +61 -1
- package/dist/mock/library.mjs +61 -1
- package/dist/mock/msw.js +61 -1
- package/dist/mock/msw.mjs +61 -1
- package/dist/{payment-Dcgb9n1n.d.mts → payment-BFtLqiG2.d.mts} +1 -1
- package/dist/{payment-Xq0WDZXh.d.ts → payment-Cq8FT1B6.d.ts} +1 -1
- package/dist/{price-DAAjKgAp.d.ts → price-DaFXT-Lr.d.ts} +1 -1
- package/dist/{price--Ma_WO5_.d.mts → price-DleDWk_s.d.mts} +1 -1
- package/dist/{product-BakHcsP2.d.ts → product-bZ8G5Z8D.d.mts} +95 -2
- package/dist/{product-BakHcsP2.d.mts → product-bZ8G5Z8D.d.ts} +95 -2
- package/dist/react.d.mts +471 -8
- package/dist/react.d.ts +471 -8
- package/dist/react.js +2787 -402
- package/dist/react.mjs +2699 -337
- package/dist/{server-Bk_hlefX.d.mts → server-D-iK-bNt.d.mts} +8 -1
- package/dist/{server-Bei5lBrc.d.ts → server-DwsY9hlX.d.ts} +8 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +7 -7
- package/dist/server.mjs +2 -2
- package/dist/styles.css +1 -1
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +3 -2
- package/dist/testing/msw.mjs +2 -1
- package/dist/testing/suite.d.mts +6 -6
- package/dist/testing/suite.d.ts +6 -6
- package/dist/testing/suite.js +24 -23
- package/dist/testing/suite.mjs +5 -4
- package/dist/testing.d.mts +5 -5
- package/dist/testing.d.ts +5 -5
- package/dist/testing.js +80 -79
- package/dist/testing.mjs +6 -5
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/package.json +4 -1
- package/registry/booking-page.json +1 -1
- package/registry/chat-widget.json +1 -1
- package/registry/customer-input-fields.json +1 -1
- package/registry/date-slot-picker.json +1 -1
- package/registry/product-customizer.json +1 -1
- package/registry/rental-service-card.json +1 -1
package/dist/mock/cli.mjs
CHANGED
|
@@ -3494,13 +3494,30 @@ function buildV1(deps) {
|
|
|
3494
3494
|
const body = await c.req.json().catch(() => ({}));
|
|
3495
3495
|
return tryRoute(
|
|
3496
3496
|
c,
|
|
3497
|
-
() => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type })
|
|
3497
|
+
() => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type, reply_to_message_id: body.reply_to_message_id })
|
|
3498
3498
|
);
|
|
3499
3499
|
});
|
|
3500
3500
|
app.get(
|
|
3501
3501
|
"/support/conversation/messages",
|
|
3502
3502
|
(c) => tryRoute(c, () => deps.support.listMessages(c.req.query("conversation_id") ?? "", { limit: getQueryNum(c, "limit") }))
|
|
3503
3503
|
);
|
|
3504
|
+
app.post("/support/conversation/messages/:messageId/reactions", async (c) => {
|
|
3505
|
+
const body = await c.req.json().catch(() => ({}));
|
|
3506
|
+
return tryRoute(c, () => deps.support.react(c.req.param("messageId"), body.emoji ?? ""));
|
|
3507
|
+
});
|
|
3508
|
+
app.post("/support/conversation/handoff", (c) => c.json({ data: { requested: true } }));
|
|
3509
|
+
app.post("/support/conversation/claim", async (c) => {
|
|
3510
|
+
const body = await c.req.json().catch(() => ({}));
|
|
3511
|
+
if (!body.access_token) return c.json({ error: "access_token is required" }, 400);
|
|
3512
|
+
const session = c.var.session;
|
|
3513
|
+
return c.json({
|
|
3514
|
+
data: {
|
|
3515
|
+
session_token: session.token,
|
|
3516
|
+
thread_id: null,
|
|
3517
|
+
customer_name: session.customer_name ?? "Test User"
|
|
3518
|
+
}
|
|
3519
|
+
});
|
|
3520
|
+
});
|
|
3504
3521
|
app.get(
|
|
3505
3522
|
"/support/conversation/ws",
|
|
3506
3523
|
(c) => c.json({ note: "WebSocket connection \u2014 connect via ws:// at the same path", supported: false }, 426)
|
|
@@ -6445,6 +6462,28 @@ function createActivityService(opts) {
|
|
|
6445
6462
|
};
|
|
6446
6463
|
}
|
|
6447
6464
|
|
|
6465
|
+
// src/genui/segments.ts
|
|
6466
|
+
var FENCE_PATTERN = /```genui\s*\n([\s\S]*?)(?:```|$)/g;
|
|
6467
|
+
function splitGenUIContent(content) {
|
|
6468
|
+
const segments = [];
|
|
6469
|
+
let cursor = 0;
|
|
6470
|
+
for (const match2 of content.matchAll(FENCE_PATTERN)) {
|
|
6471
|
+
const prose = content.slice(cursor, match2.index).trim();
|
|
6472
|
+
if (prose) segments.push({ kind: "prose", text: prose });
|
|
6473
|
+
const source = match2[1].trim();
|
|
6474
|
+
if (source) segments.push({ kind: "program", source });
|
|
6475
|
+
cursor = match2.index + match2[0].length;
|
|
6476
|
+
}
|
|
6477
|
+
const tail = content.slice(cursor).trim();
|
|
6478
|
+
if (tail) segments.push({ kind: "prose", text: tail });
|
|
6479
|
+
return segments;
|
|
6480
|
+
}
|
|
6481
|
+
function messagePreview(content, max = 90) {
|
|
6482
|
+
const prose = splitGenUIContent(content).filter((segment) => segment.kind === "prose").map((segment) => segment.text).join(" ").replace(/\s+/g, " ").trim();
|
|
6483
|
+
if (!prose) return "Structured answer";
|
|
6484
|
+
return prose.length > max ? `${prose.slice(0, max)}\u2026` : prose;
|
|
6485
|
+
}
|
|
6486
|
+
|
|
6448
6487
|
// src/mock/domain/support.ts
|
|
6449
6488
|
function createSupportService(opts) {
|
|
6450
6489
|
const { registry, clock, ids, bus } = opts;
|
|
@@ -6474,12 +6513,14 @@ function createSupportService(opts) {
|
|
|
6474
6513
|
sendMessage(conversationId, body) {
|
|
6475
6514
|
const conv = registry.conversations.get(conversationId);
|
|
6476
6515
|
if (!conv) throw notFound(`Conversation ${conversationId} not found`);
|
|
6516
|
+
const target = body.reply_to_message_id ? conv.messages.find((m) => m.id === body.reply_to_message_id) : void 0;
|
|
6477
6517
|
const msg = {
|
|
6478
6518
|
id: ids.message(),
|
|
6479
6519
|
conversation_id: conversationId,
|
|
6480
6520
|
sender_type: body.sender_type ?? "customer",
|
|
6481
6521
|
content_type: body.content_type ?? "text",
|
|
6482
6522
|
content: body.content,
|
|
6523
|
+
reply_to: target ? { id: target.id, sender_type: target.sender_type, preview: messagePreview(target.content) } : void 0,
|
|
6483
6524
|
created_at: clock.iso()
|
|
6484
6525
|
};
|
|
6485
6526
|
conv.messages.push(msg);
|
|
@@ -6501,6 +6542,25 @@ function createSupportService(opts) {
|
|
|
6501
6542
|
}
|
|
6502
6543
|
return msg;
|
|
6503
6544
|
},
|
|
6545
|
+
react(messageId, emoji) {
|
|
6546
|
+
for (const conv of registry.conversations.values()) {
|
|
6547
|
+
const target = conv.messages.find((m) => m.id === messageId);
|
|
6548
|
+
if (!target) continue;
|
|
6549
|
+
const reaction = {
|
|
6550
|
+
id: ids.message(),
|
|
6551
|
+
conversation_id: conv.id,
|
|
6552
|
+
sender_type: "customer",
|
|
6553
|
+
content_type: "text",
|
|
6554
|
+
content: emoji,
|
|
6555
|
+
reply_to: { id: target.id, sender_type: target.sender_type, preview: messagePreview(target.content) },
|
|
6556
|
+
created_at: clock.iso()
|
|
6557
|
+
};
|
|
6558
|
+
conv.messages.push(reaction);
|
|
6559
|
+
registry.conversations.put(conv.id, conv);
|
|
6560
|
+
return reaction;
|
|
6561
|
+
}
|
|
6562
|
+
throw notFound(`Message ${messageId} not found`);
|
|
6563
|
+
},
|
|
6504
6564
|
listMessages(conversationId, opts2) {
|
|
6505
6565
|
const conv = registry.conversations.get(conversationId);
|
|
6506
6566
|
if (!conv) throw notFound(`Conversation ${conversationId} not found`);
|
package/dist/mock/library.js
CHANGED
|
@@ -2556,13 +2556,30 @@ function buildV1(deps) {
|
|
|
2556
2556
|
const body = await c.req.json().catch(() => ({}));
|
|
2557
2557
|
return tryRoute(
|
|
2558
2558
|
c,
|
|
2559
|
-
() => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type })
|
|
2559
|
+
() => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type, reply_to_message_id: body.reply_to_message_id })
|
|
2560
2560
|
);
|
|
2561
2561
|
});
|
|
2562
2562
|
app.get(
|
|
2563
2563
|
"/support/conversation/messages",
|
|
2564
2564
|
(c) => tryRoute(c, () => deps.support.listMessages(c.req.query("conversation_id") ?? "", { limit: getQueryNum(c, "limit") }))
|
|
2565
2565
|
);
|
|
2566
|
+
app.post("/support/conversation/messages/:messageId/reactions", async (c) => {
|
|
2567
|
+
const body = await c.req.json().catch(() => ({}));
|
|
2568
|
+
return tryRoute(c, () => deps.support.react(c.req.param("messageId"), body.emoji ?? ""));
|
|
2569
|
+
});
|
|
2570
|
+
app.post("/support/conversation/handoff", (c) => c.json({ data: { requested: true } }));
|
|
2571
|
+
app.post("/support/conversation/claim", async (c) => {
|
|
2572
|
+
const body = await c.req.json().catch(() => ({}));
|
|
2573
|
+
if (!body.access_token) return c.json({ error: "access_token is required" }, 400);
|
|
2574
|
+
const session = c.var.session;
|
|
2575
|
+
return c.json({
|
|
2576
|
+
data: {
|
|
2577
|
+
session_token: session.token,
|
|
2578
|
+
thread_id: null,
|
|
2579
|
+
customer_name: session.customer_name ?? "Test User"
|
|
2580
|
+
}
|
|
2581
|
+
});
|
|
2582
|
+
});
|
|
2566
2583
|
app.get(
|
|
2567
2584
|
"/support/conversation/ws",
|
|
2568
2585
|
(c) => c.json({ note: "WebSocket connection \u2014 connect via ws:// at the same path", supported: false }, 426)
|
|
@@ -5507,6 +5524,28 @@ function createActivityService(opts) {
|
|
|
5507
5524
|
};
|
|
5508
5525
|
}
|
|
5509
5526
|
|
|
5527
|
+
// src/genui/segments.ts
|
|
5528
|
+
var FENCE_PATTERN = /```genui\s*\n([\s\S]*?)(?:```|$)/g;
|
|
5529
|
+
function splitGenUIContent(content) {
|
|
5530
|
+
const segments = [];
|
|
5531
|
+
let cursor = 0;
|
|
5532
|
+
for (const match2 of content.matchAll(FENCE_PATTERN)) {
|
|
5533
|
+
const prose = content.slice(cursor, match2.index).trim();
|
|
5534
|
+
if (prose) segments.push({ kind: "prose", text: prose });
|
|
5535
|
+
const source = match2[1].trim();
|
|
5536
|
+
if (source) segments.push({ kind: "program", source });
|
|
5537
|
+
cursor = match2.index + match2[0].length;
|
|
5538
|
+
}
|
|
5539
|
+
const tail = content.slice(cursor).trim();
|
|
5540
|
+
if (tail) segments.push({ kind: "prose", text: tail });
|
|
5541
|
+
return segments;
|
|
5542
|
+
}
|
|
5543
|
+
function messagePreview(content, max = 90) {
|
|
5544
|
+
const prose = splitGenUIContent(content).filter((segment) => segment.kind === "prose").map((segment) => segment.text).join(" ").replace(/\s+/g, " ").trim();
|
|
5545
|
+
if (!prose) return "Structured answer";
|
|
5546
|
+
return prose.length > max ? `${prose.slice(0, max)}\u2026` : prose;
|
|
5547
|
+
}
|
|
5548
|
+
|
|
5510
5549
|
// src/mock/domain/support.ts
|
|
5511
5550
|
function createSupportService(opts) {
|
|
5512
5551
|
const { registry, clock, ids, bus } = opts;
|
|
@@ -5536,12 +5575,14 @@ function createSupportService(opts) {
|
|
|
5536
5575
|
sendMessage(conversationId, body) {
|
|
5537
5576
|
const conv = registry.conversations.get(conversationId);
|
|
5538
5577
|
if (!conv) throw notFound(`Conversation ${conversationId} not found`);
|
|
5578
|
+
const target = body.reply_to_message_id ? conv.messages.find((m) => m.id === body.reply_to_message_id) : void 0;
|
|
5539
5579
|
const msg = {
|
|
5540
5580
|
id: ids.message(),
|
|
5541
5581
|
conversation_id: conversationId,
|
|
5542
5582
|
sender_type: body.sender_type ?? "customer",
|
|
5543
5583
|
content_type: body.content_type ?? "text",
|
|
5544
5584
|
content: body.content,
|
|
5585
|
+
reply_to: target ? { id: target.id, sender_type: target.sender_type, preview: messagePreview(target.content) } : void 0,
|
|
5545
5586
|
created_at: clock.iso()
|
|
5546
5587
|
};
|
|
5547
5588
|
conv.messages.push(msg);
|
|
@@ -5563,6 +5604,25 @@ function createSupportService(opts) {
|
|
|
5563
5604
|
}
|
|
5564
5605
|
return msg;
|
|
5565
5606
|
},
|
|
5607
|
+
react(messageId, emoji) {
|
|
5608
|
+
for (const conv of registry.conversations.values()) {
|
|
5609
|
+
const target = conv.messages.find((m) => m.id === messageId);
|
|
5610
|
+
if (!target) continue;
|
|
5611
|
+
const reaction = {
|
|
5612
|
+
id: ids.message(),
|
|
5613
|
+
conversation_id: conv.id,
|
|
5614
|
+
sender_type: "customer",
|
|
5615
|
+
content_type: "text",
|
|
5616
|
+
content: emoji,
|
|
5617
|
+
reply_to: { id: target.id, sender_type: target.sender_type, preview: messagePreview(target.content) },
|
|
5618
|
+
created_at: clock.iso()
|
|
5619
|
+
};
|
|
5620
|
+
conv.messages.push(reaction);
|
|
5621
|
+
registry.conversations.put(conv.id, conv);
|
|
5622
|
+
return reaction;
|
|
5623
|
+
}
|
|
5624
|
+
throw notFound(`Message ${messageId} not found`);
|
|
5625
|
+
},
|
|
5566
5626
|
listMessages(conversationId, opts2) {
|
|
5567
5627
|
const conv = registry.conversations.get(conversationId);
|
|
5568
5628
|
if (!conv) throw notFound(`Conversation ${conversationId} not found`);
|
package/dist/mock/library.mjs
CHANGED
|
@@ -2554,13 +2554,30 @@ function buildV1(deps) {
|
|
|
2554
2554
|
const body = await c.req.json().catch(() => ({}));
|
|
2555
2555
|
return tryRoute(
|
|
2556
2556
|
c,
|
|
2557
|
-
() => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type })
|
|
2557
|
+
() => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type, reply_to_message_id: body.reply_to_message_id })
|
|
2558
2558
|
);
|
|
2559
2559
|
});
|
|
2560
2560
|
app.get(
|
|
2561
2561
|
"/support/conversation/messages",
|
|
2562
2562
|
(c) => tryRoute(c, () => deps.support.listMessages(c.req.query("conversation_id") ?? "", { limit: getQueryNum(c, "limit") }))
|
|
2563
2563
|
);
|
|
2564
|
+
app.post("/support/conversation/messages/:messageId/reactions", async (c) => {
|
|
2565
|
+
const body = await c.req.json().catch(() => ({}));
|
|
2566
|
+
return tryRoute(c, () => deps.support.react(c.req.param("messageId"), body.emoji ?? ""));
|
|
2567
|
+
});
|
|
2568
|
+
app.post("/support/conversation/handoff", (c) => c.json({ data: { requested: true } }));
|
|
2569
|
+
app.post("/support/conversation/claim", async (c) => {
|
|
2570
|
+
const body = await c.req.json().catch(() => ({}));
|
|
2571
|
+
if (!body.access_token) return c.json({ error: "access_token is required" }, 400);
|
|
2572
|
+
const session = c.var.session;
|
|
2573
|
+
return c.json({
|
|
2574
|
+
data: {
|
|
2575
|
+
session_token: session.token,
|
|
2576
|
+
thread_id: null,
|
|
2577
|
+
customer_name: session.customer_name ?? "Test User"
|
|
2578
|
+
}
|
|
2579
|
+
});
|
|
2580
|
+
});
|
|
2564
2581
|
app.get(
|
|
2565
2582
|
"/support/conversation/ws",
|
|
2566
2583
|
(c) => c.json({ note: "WebSocket connection \u2014 connect via ws:// at the same path", supported: false }, 426)
|
|
@@ -5505,6 +5522,28 @@ function createActivityService(opts) {
|
|
|
5505
5522
|
};
|
|
5506
5523
|
}
|
|
5507
5524
|
|
|
5525
|
+
// src/genui/segments.ts
|
|
5526
|
+
var FENCE_PATTERN = /```genui\s*\n([\s\S]*?)(?:```|$)/g;
|
|
5527
|
+
function splitGenUIContent(content) {
|
|
5528
|
+
const segments = [];
|
|
5529
|
+
let cursor = 0;
|
|
5530
|
+
for (const match2 of content.matchAll(FENCE_PATTERN)) {
|
|
5531
|
+
const prose = content.slice(cursor, match2.index).trim();
|
|
5532
|
+
if (prose) segments.push({ kind: "prose", text: prose });
|
|
5533
|
+
const source = match2[1].trim();
|
|
5534
|
+
if (source) segments.push({ kind: "program", source });
|
|
5535
|
+
cursor = match2.index + match2[0].length;
|
|
5536
|
+
}
|
|
5537
|
+
const tail = content.slice(cursor).trim();
|
|
5538
|
+
if (tail) segments.push({ kind: "prose", text: tail });
|
|
5539
|
+
return segments;
|
|
5540
|
+
}
|
|
5541
|
+
function messagePreview(content, max = 90) {
|
|
5542
|
+
const prose = splitGenUIContent(content).filter((segment) => segment.kind === "prose").map((segment) => segment.text).join(" ").replace(/\s+/g, " ").trim();
|
|
5543
|
+
if (!prose) return "Structured answer";
|
|
5544
|
+
return prose.length > max ? `${prose.slice(0, max)}\u2026` : prose;
|
|
5545
|
+
}
|
|
5546
|
+
|
|
5508
5547
|
// src/mock/domain/support.ts
|
|
5509
5548
|
function createSupportService(opts) {
|
|
5510
5549
|
const { registry, clock, ids, bus } = opts;
|
|
@@ -5534,12 +5573,14 @@ function createSupportService(opts) {
|
|
|
5534
5573
|
sendMessage(conversationId, body) {
|
|
5535
5574
|
const conv = registry.conversations.get(conversationId);
|
|
5536
5575
|
if (!conv) throw notFound(`Conversation ${conversationId} not found`);
|
|
5576
|
+
const target = body.reply_to_message_id ? conv.messages.find((m) => m.id === body.reply_to_message_id) : void 0;
|
|
5537
5577
|
const msg = {
|
|
5538
5578
|
id: ids.message(),
|
|
5539
5579
|
conversation_id: conversationId,
|
|
5540
5580
|
sender_type: body.sender_type ?? "customer",
|
|
5541
5581
|
content_type: body.content_type ?? "text",
|
|
5542
5582
|
content: body.content,
|
|
5583
|
+
reply_to: target ? { id: target.id, sender_type: target.sender_type, preview: messagePreview(target.content) } : void 0,
|
|
5543
5584
|
created_at: clock.iso()
|
|
5544
5585
|
};
|
|
5545
5586
|
conv.messages.push(msg);
|
|
@@ -5561,6 +5602,25 @@ function createSupportService(opts) {
|
|
|
5561
5602
|
}
|
|
5562
5603
|
return msg;
|
|
5563
5604
|
},
|
|
5605
|
+
react(messageId, emoji) {
|
|
5606
|
+
for (const conv of registry.conversations.values()) {
|
|
5607
|
+
const target = conv.messages.find((m) => m.id === messageId);
|
|
5608
|
+
if (!target) continue;
|
|
5609
|
+
const reaction = {
|
|
5610
|
+
id: ids.message(),
|
|
5611
|
+
conversation_id: conv.id,
|
|
5612
|
+
sender_type: "customer",
|
|
5613
|
+
content_type: "text",
|
|
5614
|
+
content: emoji,
|
|
5615
|
+
reply_to: { id: target.id, sender_type: target.sender_type, preview: messagePreview(target.content) },
|
|
5616
|
+
created_at: clock.iso()
|
|
5617
|
+
};
|
|
5618
|
+
conv.messages.push(reaction);
|
|
5619
|
+
registry.conversations.put(conv.id, conv);
|
|
5620
|
+
return reaction;
|
|
5621
|
+
}
|
|
5622
|
+
throw notFound(`Message ${messageId} not found`);
|
|
5623
|
+
},
|
|
5564
5624
|
listMessages(conversationId, opts2) {
|
|
5565
5625
|
const conv = registry.conversations.get(conversationId);
|
|
5566
5626
|
if (!conv) throw notFound(`Conversation ${conversationId} not found`);
|
package/dist/mock/msw.js
CHANGED
|
@@ -2554,13 +2554,30 @@ function buildV1(deps) {
|
|
|
2554
2554
|
const body = await c.req.json().catch(() => ({}));
|
|
2555
2555
|
return tryRoute(
|
|
2556
2556
|
c,
|
|
2557
|
-
() => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type })
|
|
2557
|
+
() => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type, reply_to_message_id: body.reply_to_message_id })
|
|
2558
2558
|
);
|
|
2559
2559
|
});
|
|
2560
2560
|
app.get(
|
|
2561
2561
|
"/support/conversation/messages",
|
|
2562
2562
|
(c) => tryRoute(c, () => deps.support.listMessages(c.req.query("conversation_id") ?? "", { limit: getQueryNum(c, "limit") }))
|
|
2563
2563
|
);
|
|
2564
|
+
app.post("/support/conversation/messages/:messageId/reactions", async (c) => {
|
|
2565
|
+
const body = await c.req.json().catch(() => ({}));
|
|
2566
|
+
return tryRoute(c, () => deps.support.react(c.req.param("messageId"), body.emoji ?? ""));
|
|
2567
|
+
});
|
|
2568
|
+
app.post("/support/conversation/handoff", (c) => c.json({ data: { requested: true } }));
|
|
2569
|
+
app.post("/support/conversation/claim", async (c) => {
|
|
2570
|
+
const body = await c.req.json().catch(() => ({}));
|
|
2571
|
+
if (!body.access_token) return c.json({ error: "access_token is required" }, 400);
|
|
2572
|
+
const session = c.var.session;
|
|
2573
|
+
return c.json({
|
|
2574
|
+
data: {
|
|
2575
|
+
session_token: session.token,
|
|
2576
|
+
thread_id: null,
|
|
2577
|
+
customer_name: session.customer_name ?? "Test User"
|
|
2578
|
+
}
|
|
2579
|
+
});
|
|
2580
|
+
});
|
|
2564
2581
|
app.get(
|
|
2565
2582
|
"/support/conversation/ws",
|
|
2566
2583
|
(c) => c.json({ note: "WebSocket connection \u2014 connect via ws:// at the same path", supported: false }, 426)
|
|
@@ -5505,6 +5522,28 @@ function createActivityService(opts) {
|
|
|
5505
5522
|
};
|
|
5506
5523
|
}
|
|
5507
5524
|
|
|
5525
|
+
// src/genui/segments.ts
|
|
5526
|
+
var FENCE_PATTERN = /```genui\s*\n([\s\S]*?)(?:```|$)/g;
|
|
5527
|
+
function splitGenUIContent(content) {
|
|
5528
|
+
const segments = [];
|
|
5529
|
+
let cursor = 0;
|
|
5530
|
+
for (const match2 of content.matchAll(FENCE_PATTERN)) {
|
|
5531
|
+
const prose = content.slice(cursor, match2.index).trim();
|
|
5532
|
+
if (prose) segments.push({ kind: "prose", text: prose });
|
|
5533
|
+
const source = match2[1].trim();
|
|
5534
|
+
if (source) segments.push({ kind: "program", source });
|
|
5535
|
+
cursor = match2.index + match2[0].length;
|
|
5536
|
+
}
|
|
5537
|
+
const tail = content.slice(cursor).trim();
|
|
5538
|
+
if (tail) segments.push({ kind: "prose", text: tail });
|
|
5539
|
+
return segments;
|
|
5540
|
+
}
|
|
5541
|
+
function messagePreview(content, max = 90) {
|
|
5542
|
+
const prose = splitGenUIContent(content).filter((segment) => segment.kind === "prose").map((segment) => segment.text).join(" ").replace(/\s+/g, " ").trim();
|
|
5543
|
+
if (!prose) return "Structured answer";
|
|
5544
|
+
return prose.length > max ? `${prose.slice(0, max)}\u2026` : prose;
|
|
5545
|
+
}
|
|
5546
|
+
|
|
5508
5547
|
// src/mock/domain/support.ts
|
|
5509
5548
|
function createSupportService(opts) {
|
|
5510
5549
|
const { registry, clock, ids, bus } = opts;
|
|
@@ -5534,12 +5573,14 @@ function createSupportService(opts) {
|
|
|
5534
5573
|
sendMessage(conversationId, body) {
|
|
5535
5574
|
const conv = registry.conversations.get(conversationId);
|
|
5536
5575
|
if (!conv) throw notFound(`Conversation ${conversationId} not found`);
|
|
5576
|
+
const target = body.reply_to_message_id ? conv.messages.find((m) => m.id === body.reply_to_message_id) : void 0;
|
|
5537
5577
|
const msg = {
|
|
5538
5578
|
id: ids.message(),
|
|
5539
5579
|
conversation_id: conversationId,
|
|
5540
5580
|
sender_type: body.sender_type ?? "customer",
|
|
5541
5581
|
content_type: body.content_type ?? "text",
|
|
5542
5582
|
content: body.content,
|
|
5583
|
+
reply_to: target ? { id: target.id, sender_type: target.sender_type, preview: messagePreview(target.content) } : void 0,
|
|
5543
5584
|
created_at: clock.iso()
|
|
5544
5585
|
};
|
|
5545
5586
|
conv.messages.push(msg);
|
|
@@ -5561,6 +5602,25 @@ function createSupportService(opts) {
|
|
|
5561
5602
|
}
|
|
5562
5603
|
return msg;
|
|
5563
5604
|
},
|
|
5605
|
+
react(messageId, emoji) {
|
|
5606
|
+
for (const conv of registry.conversations.values()) {
|
|
5607
|
+
const target = conv.messages.find((m) => m.id === messageId);
|
|
5608
|
+
if (!target) continue;
|
|
5609
|
+
const reaction = {
|
|
5610
|
+
id: ids.message(),
|
|
5611
|
+
conversation_id: conv.id,
|
|
5612
|
+
sender_type: "customer",
|
|
5613
|
+
content_type: "text",
|
|
5614
|
+
content: emoji,
|
|
5615
|
+
reply_to: { id: target.id, sender_type: target.sender_type, preview: messagePreview(target.content) },
|
|
5616
|
+
created_at: clock.iso()
|
|
5617
|
+
};
|
|
5618
|
+
conv.messages.push(reaction);
|
|
5619
|
+
registry.conversations.put(conv.id, conv);
|
|
5620
|
+
return reaction;
|
|
5621
|
+
}
|
|
5622
|
+
throw notFound(`Message ${messageId} not found`);
|
|
5623
|
+
},
|
|
5564
5624
|
listMessages(conversationId, opts2) {
|
|
5565
5625
|
const conv = registry.conversations.get(conversationId);
|
|
5566
5626
|
if (!conv) throw notFound(`Conversation ${conversationId} not found`);
|
package/dist/mock/msw.mjs
CHANGED
|
@@ -2552,13 +2552,30 @@ function buildV1(deps) {
|
|
|
2552
2552
|
const body = await c.req.json().catch(() => ({}));
|
|
2553
2553
|
return tryRoute(
|
|
2554
2554
|
c,
|
|
2555
|
-
() => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type })
|
|
2555
|
+
() => deps.support.sendMessage(body.conversation_id ?? "", { content: body.content ?? "", content_type: body.content_type, sender_type: body.sender_type, reply_to_message_id: body.reply_to_message_id })
|
|
2556
2556
|
);
|
|
2557
2557
|
});
|
|
2558
2558
|
app.get(
|
|
2559
2559
|
"/support/conversation/messages",
|
|
2560
2560
|
(c) => tryRoute(c, () => deps.support.listMessages(c.req.query("conversation_id") ?? "", { limit: getQueryNum(c, "limit") }))
|
|
2561
2561
|
);
|
|
2562
|
+
app.post("/support/conversation/messages/:messageId/reactions", async (c) => {
|
|
2563
|
+
const body = await c.req.json().catch(() => ({}));
|
|
2564
|
+
return tryRoute(c, () => deps.support.react(c.req.param("messageId"), body.emoji ?? ""));
|
|
2565
|
+
});
|
|
2566
|
+
app.post("/support/conversation/handoff", (c) => c.json({ data: { requested: true } }));
|
|
2567
|
+
app.post("/support/conversation/claim", async (c) => {
|
|
2568
|
+
const body = await c.req.json().catch(() => ({}));
|
|
2569
|
+
if (!body.access_token) return c.json({ error: "access_token is required" }, 400);
|
|
2570
|
+
const session = c.var.session;
|
|
2571
|
+
return c.json({
|
|
2572
|
+
data: {
|
|
2573
|
+
session_token: session.token,
|
|
2574
|
+
thread_id: null,
|
|
2575
|
+
customer_name: session.customer_name ?? "Test User"
|
|
2576
|
+
}
|
|
2577
|
+
});
|
|
2578
|
+
});
|
|
2562
2579
|
app.get(
|
|
2563
2580
|
"/support/conversation/ws",
|
|
2564
2581
|
(c) => c.json({ note: "WebSocket connection \u2014 connect via ws:// at the same path", supported: false }, 426)
|
|
@@ -5503,6 +5520,28 @@ function createActivityService(opts) {
|
|
|
5503
5520
|
};
|
|
5504
5521
|
}
|
|
5505
5522
|
|
|
5523
|
+
// src/genui/segments.ts
|
|
5524
|
+
var FENCE_PATTERN = /```genui\s*\n([\s\S]*?)(?:```|$)/g;
|
|
5525
|
+
function splitGenUIContent(content) {
|
|
5526
|
+
const segments = [];
|
|
5527
|
+
let cursor = 0;
|
|
5528
|
+
for (const match2 of content.matchAll(FENCE_PATTERN)) {
|
|
5529
|
+
const prose = content.slice(cursor, match2.index).trim();
|
|
5530
|
+
if (prose) segments.push({ kind: "prose", text: prose });
|
|
5531
|
+
const source = match2[1].trim();
|
|
5532
|
+
if (source) segments.push({ kind: "program", source });
|
|
5533
|
+
cursor = match2.index + match2[0].length;
|
|
5534
|
+
}
|
|
5535
|
+
const tail = content.slice(cursor).trim();
|
|
5536
|
+
if (tail) segments.push({ kind: "prose", text: tail });
|
|
5537
|
+
return segments;
|
|
5538
|
+
}
|
|
5539
|
+
function messagePreview(content, max = 90) {
|
|
5540
|
+
const prose = splitGenUIContent(content).filter((segment) => segment.kind === "prose").map((segment) => segment.text).join(" ").replace(/\s+/g, " ").trim();
|
|
5541
|
+
if (!prose) return "Structured answer";
|
|
5542
|
+
return prose.length > max ? `${prose.slice(0, max)}\u2026` : prose;
|
|
5543
|
+
}
|
|
5544
|
+
|
|
5506
5545
|
// src/mock/domain/support.ts
|
|
5507
5546
|
function createSupportService(opts) {
|
|
5508
5547
|
const { registry, clock, ids, bus } = opts;
|
|
@@ -5532,12 +5571,14 @@ function createSupportService(opts) {
|
|
|
5532
5571
|
sendMessage(conversationId, body) {
|
|
5533
5572
|
const conv = registry.conversations.get(conversationId);
|
|
5534
5573
|
if (!conv) throw notFound(`Conversation ${conversationId} not found`);
|
|
5574
|
+
const target = body.reply_to_message_id ? conv.messages.find((m) => m.id === body.reply_to_message_id) : void 0;
|
|
5535
5575
|
const msg = {
|
|
5536
5576
|
id: ids.message(),
|
|
5537
5577
|
conversation_id: conversationId,
|
|
5538
5578
|
sender_type: body.sender_type ?? "customer",
|
|
5539
5579
|
content_type: body.content_type ?? "text",
|
|
5540
5580
|
content: body.content,
|
|
5581
|
+
reply_to: target ? { id: target.id, sender_type: target.sender_type, preview: messagePreview(target.content) } : void 0,
|
|
5541
5582
|
created_at: clock.iso()
|
|
5542
5583
|
};
|
|
5543
5584
|
conv.messages.push(msg);
|
|
@@ -5559,6 +5600,25 @@ function createSupportService(opts) {
|
|
|
5559
5600
|
}
|
|
5560
5601
|
return msg;
|
|
5561
5602
|
},
|
|
5603
|
+
react(messageId, emoji) {
|
|
5604
|
+
for (const conv of registry.conversations.values()) {
|
|
5605
|
+
const target = conv.messages.find((m) => m.id === messageId);
|
|
5606
|
+
if (!target) continue;
|
|
5607
|
+
const reaction = {
|
|
5608
|
+
id: ids.message(),
|
|
5609
|
+
conversation_id: conv.id,
|
|
5610
|
+
sender_type: "customer",
|
|
5611
|
+
content_type: "text",
|
|
5612
|
+
content: emoji,
|
|
5613
|
+
reply_to: { id: target.id, sender_type: target.sender_type, preview: messagePreview(target.content) },
|
|
5614
|
+
created_at: clock.iso()
|
|
5615
|
+
};
|
|
5616
|
+
conv.messages.push(reaction);
|
|
5617
|
+
registry.conversations.put(conv.id, conv);
|
|
5618
|
+
return reaction;
|
|
5619
|
+
}
|
|
5620
|
+
throw notFound(`Message ${messageId} not found`);
|
|
5621
|
+
},
|
|
5562
5622
|
listMessages(conversationId, opts2) {
|
|
5563
5623
|
const conv = registry.conversations.get(conversationId);
|
|
5564
5624
|
if (!conv) throw notFound(`Conversation ${conversationId} not found`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aO as Money, ad as CurrencyCode } from './product-
|
|
1
|
+
import { aO as Money, ad as CurrencyCode } from './product-bZ8G5Z8D.mjs';
|
|
2
2
|
|
|
3
3
|
type PaymentStatus = "initialized" | "pending" | "processing" | "authorized" | "captured" | "failed" | "cancelled" | "refunded" | "unknown" | "voided" | "requires_action" | "abandoned" | "reversed" | "disputed" | "refund_pending";
|
|
4
4
|
type PaymentProvider = "stripe" | "paystack" | "cellulant" | "mtn_momo" | "offline" | "mtn" | "vodafone" | "airtel" | "cash" | "manual";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aO as Money, ad as CurrencyCode } from './product-
|
|
1
|
+
import { aO as Money, ad as CurrencyCode } from './product-bZ8G5Z8D.js';
|
|
2
2
|
|
|
3
3
|
type PaymentStatus = "initialized" | "pending" | "processing" | "authorized" | "captured" | "failed" | "cancelled" | "refunded" | "unknown" | "voided" | "requires_action" | "abandoned" | "reversed" | "disputed" | "refund_pending";
|
|
4
4
|
type PaymentProvider = "stripe" | "paystack" | "cellulant" | "mtn_momo" | "offline" | "mtn" | "vodafone" | "airtel" | "cash" | "manual";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as CurrencyCode, U as ChosenPrice, bi as SaleInfo, bD as UpcomingSale } from './product-
|
|
1
|
+
import { ad as CurrencyCode, U as ChosenPrice, bi as SaleInfo, bD as UpcomingSale } from './product-bZ8G5Z8D.js';
|
|
2
2
|
|
|
3
3
|
interface ProductWithPrice {
|
|
4
4
|
price_info?: ChosenPrice;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as CurrencyCode, U as ChosenPrice, bi as SaleInfo, bD as UpcomingSale } from './product-
|
|
1
|
+
import { ad as CurrencyCode, U as ChosenPrice, bi as SaleInfo, bD as UpcomingSale } from './product-bZ8G5Z8D.mjs';
|
|
2
2
|
|
|
3
3
|
interface ProductWithPrice {
|
|
4
4
|
price_info?: ChosenPrice;
|