@cimplify/sdk 0.94.0 → 0.94.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/{chunk-X36FZZT6.mjs → chunk-7TEMLVDT.mjs} +19 -8
- package/dist/{chunk-6Y7KC5YZ.js → chunk-FECGCIVV.js} +19 -8
- package/dist/{chunk-AWNWP5J3.js → chunk-RQMCRU4C.js} +2 -2
- package/dist/{chunk-QXWX7CD2.mjs → chunk-VZWK2FJM.mjs} +1 -1
- package/dist/{client-Bhe2TnFW.d.mts → client-BycFj07D.d.mts} +1 -1
- package/dist/{client-DrkuEK_I.d.ts → client-DqYNEMce.d.ts} +1 -1
- package/dist/mock/cli.mjs +19 -8
- package/dist/mock/library.js +19 -8
- package/dist/mock/library.mjs +19 -8
- package/dist/mock/msw.js +19 -8
- package/dist/mock/msw.mjs +19 -8
- package/dist/react.js +20 -17
- package/dist/react.mjs +20 -17
- package/dist/{server-BN9ZCAKT.d.mts → server-HVDbbqR9.d.mts} +6 -0
- package/dist/{server-DDGbfW_S.d.ts → server-JBuTPY-j.d.ts} +6 -0
- package/dist/testing/msw.d.mts +1 -1
- package/dist/testing/msw.d.ts +1 -1
- package/dist/testing/msw.js +2 -2
- package/dist/testing/msw.mjs +1 -1
- package/dist/testing/suite.d.mts +3 -3
- package/dist/testing/suite.d.ts +3 -3
- package/dist/testing/suite.js +21 -21
- package/dist/testing/suite.mjs +2 -2
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +77 -77
- package/dist/testing.mjs +3 -3
- package/package.json +1 -1
- package/registry/chat-widget.json +1 -1
|
@@ -2486,10 +2486,15 @@ function buildV1(deps) {
|
|
|
2486
2486
|
);
|
|
2487
2487
|
app.post("/support/conversation/messages", async (c) => {
|
|
2488
2488
|
const body = await c.req.json().catch(() => ({}));
|
|
2489
|
-
return tryRoute(
|
|
2490
|
-
c
|
|
2491
|
-
|
|
2492
|
-
|
|
2489
|
+
return tryRoute(c, () => {
|
|
2490
|
+
const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
|
|
2491
|
+
return deps.support.sendMessage(conversationId, {
|
|
2492
|
+
content: body.content ?? "",
|
|
2493
|
+
content_type: body.content_type,
|
|
2494
|
+
sender_type: body.sender_type,
|
|
2495
|
+
reply_to_message_id: body.reply_to_message_id
|
|
2496
|
+
});
|
|
2497
|
+
});
|
|
2493
2498
|
});
|
|
2494
2499
|
app.get(
|
|
2495
2500
|
"/support/conversation/messages",
|
|
@@ -3575,8 +3580,8 @@ function createBus(opts) {
|
|
|
3575
3580
|
var SESSION_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
3576
3581
|
function createAuthService(opts) {
|
|
3577
3582
|
const { registry, clock, ids, options } = opts;
|
|
3578
|
-
const newSession = (authenticated, profile) => {
|
|
3579
|
-
const id = ids.session();
|
|
3583
|
+
const newSession = (authenticated, profile, token) => {
|
|
3584
|
+
const id = token || ids.session();
|
|
3580
3585
|
const session = {
|
|
3581
3586
|
id,
|
|
3582
3587
|
token: id,
|
|
@@ -3607,9 +3612,9 @@ function createAuthService(opts) {
|
|
|
3607
3612
|
const existing = this.resolveSession(token);
|
|
3608
3613
|
if (existing) return existing;
|
|
3609
3614
|
if (options.mode === "strict") {
|
|
3610
|
-
return newSession(false);
|
|
3615
|
+
return newSession(false, void 0, token);
|
|
3611
3616
|
}
|
|
3612
|
-
return newSession(true, { name: "Guest" });
|
|
3617
|
+
return newSession(true, { name: "Guest" }, token);
|
|
3613
3618
|
},
|
|
3614
3619
|
requestOtp(contact) {
|
|
3615
3620
|
const otp_id = ids.raw("otp");
|
|
@@ -5482,6 +5487,12 @@ function createSupportService(opts) {
|
|
|
5482
5487
|
registry.conversations.put(id, conv);
|
|
5483
5488
|
return conv;
|
|
5484
5489
|
},
|
|
5490
|
+
ensureConversation(businessId, customerId) {
|
|
5491
|
+
const existing = registry.conversations.list(
|
|
5492
|
+
(c) => c.business_id === businessId && c.customer_id === customerId
|
|
5493
|
+
);
|
|
5494
|
+
return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
|
|
5495
|
+
},
|
|
5485
5496
|
peekConversation(businessId, customerId) {
|
|
5486
5497
|
const matches = registry.conversations.list(
|
|
5487
5498
|
(c) => c.business_id === businessId && c.customer_id === customerId
|
|
@@ -2488,10 +2488,15 @@ function buildV1(deps) {
|
|
|
2488
2488
|
);
|
|
2489
2489
|
app.post("/support/conversation/messages", async (c) => {
|
|
2490
2490
|
const body = await c.req.json().catch(() => ({}));
|
|
2491
|
-
return tryRoute(
|
|
2492
|
-
c
|
|
2493
|
-
|
|
2494
|
-
|
|
2491
|
+
return tryRoute(c, () => {
|
|
2492
|
+
const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
|
|
2493
|
+
return deps.support.sendMessage(conversationId, {
|
|
2494
|
+
content: body.content ?? "",
|
|
2495
|
+
content_type: body.content_type,
|
|
2496
|
+
sender_type: body.sender_type,
|
|
2497
|
+
reply_to_message_id: body.reply_to_message_id
|
|
2498
|
+
});
|
|
2499
|
+
});
|
|
2495
2500
|
});
|
|
2496
2501
|
app.get(
|
|
2497
2502
|
"/support/conversation/messages",
|
|
@@ -3577,8 +3582,8 @@ function createBus(opts) {
|
|
|
3577
3582
|
var SESSION_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
3578
3583
|
function createAuthService(opts) {
|
|
3579
3584
|
const { registry, clock, ids, options } = opts;
|
|
3580
|
-
const newSession = (authenticated, profile) => {
|
|
3581
|
-
const id = ids.session();
|
|
3585
|
+
const newSession = (authenticated, profile, token) => {
|
|
3586
|
+
const id = token || ids.session();
|
|
3582
3587
|
const session = {
|
|
3583
3588
|
id,
|
|
3584
3589
|
token: id,
|
|
@@ -3609,9 +3614,9 @@ function createAuthService(opts) {
|
|
|
3609
3614
|
const existing = this.resolveSession(token);
|
|
3610
3615
|
if (existing) return existing;
|
|
3611
3616
|
if (options.mode === "strict") {
|
|
3612
|
-
return newSession(false);
|
|
3617
|
+
return newSession(false, void 0, token);
|
|
3613
3618
|
}
|
|
3614
|
-
return newSession(true, { name: "Guest" });
|
|
3619
|
+
return newSession(true, { name: "Guest" }, token);
|
|
3615
3620
|
},
|
|
3616
3621
|
requestOtp(contact) {
|
|
3617
3622
|
const otp_id = ids.raw("otp");
|
|
@@ -5484,6 +5489,12 @@ function createSupportService(opts) {
|
|
|
5484
5489
|
registry.conversations.put(id, conv);
|
|
5485
5490
|
return conv;
|
|
5486
5491
|
},
|
|
5492
|
+
ensureConversation(businessId, customerId) {
|
|
5493
|
+
const existing = registry.conversations.list(
|
|
5494
|
+
(c) => c.business_id === businessId && c.customer_id === customerId
|
|
5495
|
+
);
|
|
5496
|
+
return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
|
|
5497
|
+
},
|
|
5487
5498
|
peekConversation(businessId, customerId) {
|
|
5488
5499
|
const matches = registry.conversations.list(
|
|
5489
5500
|
(c) => c.business_id === businessId && c.customer_id === customerId
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkFECGCIVV_js = require('./chunk-FECGCIVV.js');
|
|
4
4
|
var chunkQLGZIBRO_js = require('./chunk-QLGZIBRO.js');
|
|
5
5
|
var zod = require('zod');
|
|
6
6
|
|
|
@@ -600,7 +600,7 @@ async function toForwardedRequest(input, init) {
|
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
602
|
function createTestClient(options = {}) {
|
|
603
|
-
const mock =
|
|
603
|
+
const mock = chunkFECGCIVV_js.createMockApp(options);
|
|
604
604
|
let sessionToken;
|
|
605
605
|
const fetchImpl = async (input, init) => {
|
|
606
606
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
package/dist/mock/cli.mjs
CHANGED
|
@@ -3496,10 +3496,15 @@ function buildV1(deps) {
|
|
|
3496
3496
|
);
|
|
3497
3497
|
app.post("/support/conversation/messages", async (c) => {
|
|
3498
3498
|
const body = await c.req.json().catch(() => ({}));
|
|
3499
|
-
return tryRoute(
|
|
3500
|
-
c
|
|
3501
|
-
|
|
3502
|
-
|
|
3499
|
+
return tryRoute(c, () => {
|
|
3500
|
+
const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
|
|
3501
|
+
return deps.support.sendMessage(conversationId, {
|
|
3502
|
+
content: body.content ?? "",
|
|
3503
|
+
content_type: body.content_type,
|
|
3504
|
+
sender_type: body.sender_type,
|
|
3505
|
+
reply_to_message_id: body.reply_to_message_id
|
|
3506
|
+
});
|
|
3507
|
+
});
|
|
3503
3508
|
});
|
|
3504
3509
|
app.get(
|
|
3505
3510
|
"/support/conversation/messages",
|
|
@@ -4585,8 +4590,8 @@ function createBus(opts) {
|
|
|
4585
4590
|
var SESSION_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
4586
4591
|
function createAuthService(opts) {
|
|
4587
4592
|
const { registry, clock, ids, options } = opts;
|
|
4588
|
-
const newSession = (authenticated, profile) => {
|
|
4589
|
-
const id = ids.session();
|
|
4593
|
+
const newSession = (authenticated, profile, token) => {
|
|
4594
|
+
const id = token || ids.session();
|
|
4590
4595
|
const session = {
|
|
4591
4596
|
id,
|
|
4592
4597
|
token: id,
|
|
@@ -4617,9 +4622,9 @@ function createAuthService(opts) {
|
|
|
4617
4622
|
const existing = this.resolveSession(token);
|
|
4618
4623
|
if (existing) return existing;
|
|
4619
4624
|
if (options.mode === "strict") {
|
|
4620
|
-
return newSession(false);
|
|
4625
|
+
return newSession(false, void 0, token);
|
|
4621
4626
|
}
|
|
4622
|
-
return newSession(true, { name: "Guest" });
|
|
4627
|
+
return newSession(true, { name: "Guest" }, token);
|
|
4623
4628
|
},
|
|
4624
4629
|
requestOtp(contact) {
|
|
4625
4630
|
const otp_id = ids.raw("otp");
|
|
@@ -6514,6 +6519,12 @@ function createSupportService(opts) {
|
|
|
6514
6519
|
registry.conversations.put(id, conv);
|
|
6515
6520
|
return conv;
|
|
6516
6521
|
},
|
|
6522
|
+
ensureConversation(businessId, customerId) {
|
|
6523
|
+
const existing = registry.conversations.list(
|
|
6524
|
+
(c) => c.business_id === businessId && c.customer_id === customerId
|
|
6525
|
+
);
|
|
6526
|
+
return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
|
|
6527
|
+
},
|
|
6517
6528
|
peekConversation(businessId, customerId) {
|
|
6518
6529
|
const matches = registry.conversations.list(
|
|
6519
6530
|
(c) => c.business_id === businessId && c.customer_id === customerId
|
package/dist/mock/library.js
CHANGED
|
@@ -2558,10 +2558,15 @@ function buildV1(deps) {
|
|
|
2558
2558
|
);
|
|
2559
2559
|
app.post("/support/conversation/messages", async (c) => {
|
|
2560
2560
|
const body = await c.req.json().catch(() => ({}));
|
|
2561
|
-
return tryRoute(
|
|
2562
|
-
c
|
|
2563
|
-
|
|
2564
|
-
|
|
2561
|
+
return tryRoute(c, () => {
|
|
2562
|
+
const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
|
|
2563
|
+
return deps.support.sendMessage(conversationId, {
|
|
2564
|
+
content: body.content ?? "",
|
|
2565
|
+
content_type: body.content_type,
|
|
2566
|
+
sender_type: body.sender_type,
|
|
2567
|
+
reply_to_message_id: body.reply_to_message_id
|
|
2568
|
+
});
|
|
2569
|
+
});
|
|
2565
2570
|
});
|
|
2566
2571
|
app.get(
|
|
2567
2572
|
"/support/conversation/messages",
|
|
@@ -3647,8 +3652,8 @@ function createBus(opts) {
|
|
|
3647
3652
|
var SESSION_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
3648
3653
|
function createAuthService(opts) {
|
|
3649
3654
|
const { registry, clock, ids, options } = opts;
|
|
3650
|
-
const newSession = (authenticated, profile) => {
|
|
3651
|
-
const id = ids.session();
|
|
3655
|
+
const newSession = (authenticated, profile, token) => {
|
|
3656
|
+
const id = token || ids.session();
|
|
3652
3657
|
const session = {
|
|
3653
3658
|
id,
|
|
3654
3659
|
token: id,
|
|
@@ -3679,9 +3684,9 @@ function createAuthService(opts) {
|
|
|
3679
3684
|
const existing = this.resolveSession(token);
|
|
3680
3685
|
if (existing) return existing;
|
|
3681
3686
|
if (options.mode === "strict") {
|
|
3682
|
-
return newSession(false);
|
|
3687
|
+
return newSession(false, void 0, token);
|
|
3683
3688
|
}
|
|
3684
|
-
return newSession(true, { name: "Guest" });
|
|
3689
|
+
return newSession(true, { name: "Guest" }, token);
|
|
3685
3690
|
},
|
|
3686
3691
|
requestOtp(contact) {
|
|
3687
3692
|
const otp_id = ids.raw("otp");
|
|
@@ -5576,6 +5581,12 @@ function createSupportService(opts) {
|
|
|
5576
5581
|
registry.conversations.put(id, conv);
|
|
5577
5582
|
return conv;
|
|
5578
5583
|
},
|
|
5584
|
+
ensureConversation(businessId, customerId) {
|
|
5585
|
+
const existing = registry.conversations.list(
|
|
5586
|
+
(c) => c.business_id === businessId && c.customer_id === customerId
|
|
5587
|
+
);
|
|
5588
|
+
return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
|
|
5589
|
+
},
|
|
5579
5590
|
peekConversation(businessId, customerId) {
|
|
5580
5591
|
const matches = registry.conversations.list(
|
|
5581
5592
|
(c) => c.business_id === businessId && c.customer_id === customerId
|
package/dist/mock/library.mjs
CHANGED
|
@@ -2556,10 +2556,15 @@ function buildV1(deps) {
|
|
|
2556
2556
|
);
|
|
2557
2557
|
app.post("/support/conversation/messages", async (c) => {
|
|
2558
2558
|
const body = await c.req.json().catch(() => ({}));
|
|
2559
|
-
return tryRoute(
|
|
2560
|
-
c
|
|
2561
|
-
|
|
2562
|
-
|
|
2559
|
+
return tryRoute(c, () => {
|
|
2560
|
+
const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
|
|
2561
|
+
return deps.support.sendMessage(conversationId, {
|
|
2562
|
+
content: body.content ?? "",
|
|
2563
|
+
content_type: body.content_type,
|
|
2564
|
+
sender_type: body.sender_type,
|
|
2565
|
+
reply_to_message_id: body.reply_to_message_id
|
|
2566
|
+
});
|
|
2567
|
+
});
|
|
2563
2568
|
});
|
|
2564
2569
|
app.get(
|
|
2565
2570
|
"/support/conversation/messages",
|
|
@@ -3645,8 +3650,8 @@ function createBus(opts) {
|
|
|
3645
3650
|
var SESSION_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
3646
3651
|
function createAuthService(opts) {
|
|
3647
3652
|
const { registry, clock, ids, options } = opts;
|
|
3648
|
-
const newSession = (authenticated, profile) => {
|
|
3649
|
-
const id = ids.session();
|
|
3653
|
+
const newSession = (authenticated, profile, token) => {
|
|
3654
|
+
const id = token || ids.session();
|
|
3650
3655
|
const session = {
|
|
3651
3656
|
id,
|
|
3652
3657
|
token: id,
|
|
@@ -3677,9 +3682,9 @@ function createAuthService(opts) {
|
|
|
3677
3682
|
const existing = this.resolveSession(token);
|
|
3678
3683
|
if (existing) return existing;
|
|
3679
3684
|
if (options.mode === "strict") {
|
|
3680
|
-
return newSession(false);
|
|
3685
|
+
return newSession(false, void 0, token);
|
|
3681
3686
|
}
|
|
3682
|
-
return newSession(true, { name: "Guest" });
|
|
3687
|
+
return newSession(true, { name: "Guest" }, token);
|
|
3683
3688
|
},
|
|
3684
3689
|
requestOtp(contact) {
|
|
3685
3690
|
const otp_id = ids.raw("otp");
|
|
@@ -5574,6 +5579,12 @@ function createSupportService(opts) {
|
|
|
5574
5579
|
registry.conversations.put(id, conv);
|
|
5575
5580
|
return conv;
|
|
5576
5581
|
},
|
|
5582
|
+
ensureConversation(businessId, customerId) {
|
|
5583
|
+
const existing = registry.conversations.list(
|
|
5584
|
+
(c) => c.business_id === businessId && c.customer_id === customerId
|
|
5585
|
+
);
|
|
5586
|
+
return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
|
|
5587
|
+
},
|
|
5577
5588
|
peekConversation(businessId, customerId) {
|
|
5578
5589
|
const matches = registry.conversations.list(
|
|
5579
5590
|
(c) => c.business_id === businessId && c.customer_id === customerId
|
package/dist/mock/msw.js
CHANGED
|
@@ -2556,10 +2556,15 @@ function buildV1(deps) {
|
|
|
2556
2556
|
);
|
|
2557
2557
|
app.post("/support/conversation/messages", async (c) => {
|
|
2558
2558
|
const body = await c.req.json().catch(() => ({}));
|
|
2559
|
-
return tryRoute(
|
|
2560
|
-
c
|
|
2561
|
-
|
|
2562
|
-
|
|
2559
|
+
return tryRoute(c, () => {
|
|
2560
|
+
const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
|
|
2561
|
+
return deps.support.sendMessage(conversationId, {
|
|
2562
|
+
content: body.content ?? "",
|
|
2563
|
+
content_type: body.content_type,
|
|
2564
|
+
sender_type: body.sender_type,
|
|
2565
|
+
reply_to_message_id: body.reply_to_message_id
|
|
2566
|
+
});
|
|
2567
|
+
});
|
|
2563
2568
|
});
|
|
2564
2569
|
app.get(
|
|
2565
2570
|
"/support/conversation/messages",
|
|
@@ -3645,8 +3650,8 @@ function createBus(opts) {
|
|
|
3645
3650
|
var SESSION_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
3646
3651
|
function createAuthService(opts) {
|
|
3647
3652
|
const { registry, clock, ids, options } = opts;
|
|
3648
|
-
const newSession = (authenticated, profile) => {
|
|
3649
|
-
const id = ids.session();
|
|
3653
|
+
const newSession = (authenticated, profile, token) => {
|
|
3654
|
+
const id = token || ids.session();
|
|
3650
3655
|
const session = {
|
|
3651
3656
|
id,
|
|
3652
3657
|
token: id,
|
|
@@ -3677,9 +3682,9 @@ function createAuthService(opts) {
|
|
|
3677
3682
|
const existing = this.resolveSession(token);
|
|
3678
3683
|
if (existing) return existing;
|
|
3679
3684
|
if (options.mode === "strict") {
|
|
3680
|
-
return newSession(false);
|
|
3685
|
+
return newSession(false, void 0, token);
|
|
3681
3686
|
}
|
|
3682
|
-
return newSession(true, { name: "Guest" });
|
|
3687
|
+
return newSession(true, { name: "Guest" }, token);
|
|
3683
3688
|
},
|
|
3684
3689
|
requestOtp(contact) {
|
|
3685
3690
|
const otp_id = ids.raw("otp");
|
|
@@ -5574,6 +5579,12 @@ function createSupportService(opts) {
|
|
|
5574
5579
|
registry.conversations.put(id, conv);
|
|
5575
5580
|
return conv;
|
|
5576
5581
|
},
|
|
5582
|
+
ensureConversation(businessId, customerId) {
|
|
5583
|
+
const existing = registry.conversations.list(
|
|
5584
|
+
(c) => c.business_id === businessId && c.customer_id === customerId
|
|
5585
|
+
);
|
|
5586
|
+
return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
|
|
5587
|
+
},
|
|
5577
5588
|
peekConversation(businessId, customerId) {
|
|
5578
5589
|
const matches = registry.conversations.list(
|
|
5579
5590
|
(c) => c.business_id === businessId && c.customer_id === customerId
|
package/dist/mock/msw.mjs
CHANGED
|
@@ -2554,10 +2554,15 @@ function buildV1(deps) {
|
|
|
2554
2554
|
);
|
|
2555
2555
|
app.post("/support/conversation/messages", async (c) => {
|
|
2556
2556
|
const body = await c.req.json().catch(() => ({}));
|
|
2557
|
-
return tryRoute(
|
|
2558
|
-
c
|
|
2559
|
-
|
|
2560
|
-
|
|
2557
|
+
return tryRoute(c, () => {
|
|
2558
|
+
const conversationId = body.conversation_id || deps.support.ensureConversation(deps.defaultBusinessId, c.var.session.customer_id).id;
|
|
2559
|
+
return deps.support.sendMessage(conversationId, {
|
|
2560
|
+
content: body.content ?? "",
|
|
2561
|
+
content_type: body.content_type,
|
|
2562
|
+
sender_type: body.sender_type,
|
|
2563
|
+
reply_to_message_id: body.reply_to_message_id
|
|
2564
|
+
});
|
|
2565
|
+
});
|
|
2561
2566
|
});
|
|
2562
2567
|
app.get(
|
|
2563
2568
|
"/support/conversation/messages",
|
|
@@ -3643,8 +3648,8 @@ function createBus(opts) {
|
|
|
3643
3648
|
var SESSION_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
3644
3649
|
function createAuthService(opts) {
|
|
3645
3650
|
const { registry, clock, ids, options } = opts;
|
|
3646
|
-
const newSession = (authenticated, profile) => {
|
|
3647
|
-
const id = ids.session();
|
|
3651
|
+
const newSession = (authenticated, profile, token) => {
|
|
3652
|
+
const id = token || ids.session();
|
|
3648
3653
|
const session = {
|
|
3649
3654
|
id,
|
|
3650
3655
|
token: id,
|
|
@@ -3675,9 +3680,9 @@ function createAuthService(opts) {
|
|
|
3675
3680
|
const existing = this.resolveSession(token);
|
|
3676
3681
|
if (existing) return existing;
|
|
3677
3682
|
if (options.mode === "strict") {
|
|
3678
|
-
return newSession(false);
|
|
3683
|
+
return newSession(false, void 0, token);
|
|
3679
3684
|
}
|
|
3680
|
-
return newSession(true, { name: "Guest" });
|
|
3685
|
+
return newSession(true, { name: "Guest" }, token);
|
|
3681
3686
|
},
|
|
3682
3687
|
requestOtp(contact) {
|
|
3683
3688
|
const otp_id = ids.raw("otp");
|
|
@@ -5572,6 +5577,12 @@ function createSupportService(opts) {
|
|
|
5572
5577
|
registry.conversations.put(id, conv);
|
|
5573
5578
|
return conv;
|
|
5574
5579
|
},
|
|
5580
|
+
ensureConversation(businessId, customerId) {
|
|
5581
|
+
const existing = registry.conversations.list(
|
|
5582
|
+
(c) => c.business_id === businessId && c.customer_id === customerId
|
|
5583
|
+
);
|
|
5584
|
+
return existing[existing.length - 1] ?? this.openConversation(businessId, customerId);
|
|
5585
|
+
},
|
|
5575
5586
|
peekConversation(businessId, customerId) {
|
|
5576
5587
|
const matches = registry.conversations.list(
|
|
5577
5588
|
(c) => c.business_id === businessId && c.customer_id === customerId
|
package/dist/react.js
CHANGED
|
@@ -1137,6 +1137,23 @@ function preconnectOrigin(url, crossOrigin) {
|
|
|
1137
1137
|
if (crossOrigin) link.crossOrigin = crossOrigin;
|
|
1138
1138
|
document.head.appendChild(link);
|
|
1139
1139
|
}
|
|
1140
|
+
function subscribeToPathChanges(onChange) {
|
|
1141
|
+
const { pushState, replaceState } = window.history;
|
|
1142
|
+
window.history.pushState = function(...args) {
|
|
1143
|
+
pushState.apply(this, args);
|
|
1144
|
+
onChange();
|
|
1145
|
+
};
|
|
1146
|
+
window.history.replaceState = function(...args) {
|
|
1147
|
+
replaceState.apply(this, args);
|
|
1148
|
+
onChange();
|
|
1149
|
+
};
|
|
1150
|
+
window.addEventListener("popstate", onChange);
|
|
1151
|
+
return () => {
|
|
1152
|
+
window.history.pushState = pushState;
|
|
1153
|
+
window.history.replaceState = replaceState;
|
|
1154
|
+
window.removeEventListener("popstate", onChange);
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1140
1157
|
function usePageViewTracking(client, enabled) {
|
|
1141
1158
|
React14.useEffect(() => {
|
|
1142
1159
|
if (!enabled || typeof window === "undefined") return;
|
|
@@ -1151,21 +1168,7 @@ function usePageViewTracking(client, enabled) {
|
|
|
1151
1168
|
}
|
|
1152
1169
|
};
|
|
1153
1170
|
record();
|
|
1154
|
-
|
|
1155
|
-
window.history.pushState = function(...args) {
|
|
1156
|
-
pushState.apply(this, args);
|
|
1157
|
-
record();
|
|
1158
|
-
};
|
|
1159
|
-
window.history.replaceState = function(...args) {
|
|
1160
|
-
replaceState.apply(this, args);
|
|
1161
|
-
record();
|
|
1162
|
-
};
|
|
1163
|
-
window.addEventListener("popstate", record);
|
|
1164
|
-
return () => {
|
|
1165
|
-
window.history.pushState = pushState;
|
|
1166
|
-
window.history.replaceState = replaceState;
|
|
1167
|
-
window.removeEventListener("popstate", record);
|
|
1168
|
-
};
|
|
1171
|
+
return subscribeToPathChanges(record);
|
|
1169
1172
|
}, [client, enabled]);
|
|
1170
1173
|
}
|
|
1171
1174
|
var LOCATION_STORAGE_KEY = "cimplify_location_id";
|
|
@@ -17419,12 +17422,12 @@ function Panel({
|
|
|
17419
17422
|
}
|
|
17420
17423
|
),
|
|
17421
17424
|
error != null && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-red-200 bg-red-50 px-4 py-2 text-xs text-red-600", children: error.userMessage || "Something went wrong. Please try again." }),
|
|
17422
|
-
|
|
17425
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17423
17426
|
ChatInput,
|
|
17424
17427
|
{
|
|
17425
17428
|
placeholder,
|
|
17426
17429
|
isSending,
|
|
17427
|
-
onSend,
|
|
17430
|
+
onSend: isActive ? onSend : onStartConversation,
|
|
17428
17431
|
onAttach,
|
|
17429
17432
|
className: classNames?.input
|
|
17430
17433
|
}
|
package/dist/react.mjs
CHANGED
|
@@ -1113,6 +1113,23 @@ function preconnectOrigin(url, crossOrigin) {
|
|
|
1113
1113
|
if (crossOrigin) link.crossOrigin = crossOrigin;
|
|
1114
1114
|
document.head.appendChild(link);
|
|
1115
1115
|
}
|
|
1116
|
+
function subscribeToPathChanges(onChange) {
|
|
1117
|
+
const { pushState, replaceState } = window.history;
|
|
1118
|
+
window.history.pushState = function(...args) {
|
|
1119
|
+
pushState.apply(this, args);
|
|
1120
|
+
onChange();
|
|
1121
|
+
};
|
|
1122
|
+
window.history.replaceState = function(...args) {
|
|
1123
|
+
replaceState.apply(this, args);
|
|
1124
|
+
onChange();
|
|
1125
|
+
};
|
|
1126
|
+
window.addEventListener("popstate", onChange);
|
|
1127
|
+
return () => {
|
|
1128
|
+
window.history.pushState = pushState;
|
|
1129
|
+
window.history.replaceState = replaceState;
|
|
1130
|
+
window.removeEventListener("popstate", onChange);
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1116
1133
|
function usePageViewTracking(client, enabled) {
|
|
1117
1134
|
useEffect(() => {
|
|
1118
1135
|
if (!enabled || typeof window === "undefined") return;
|
|
@@ -1127,21 +1144,7 @@ function usePageViewTracking(client, enabled) {
|
|
|
1127
1144
|
}
|
|
1128
1145
|
};
|
|
1129
1146
|
record();
|
|
1130
|
-
|
|
1131
|
-
window.history.pushState = function(...args) {
|
|
1132
|
-
pushState.apply(this, args);
|
|
1133
|
-
record();
|
|
1134
|
-
};
|
|
1135
|
-
window.history.replaceState = function(...args) {
|
|
1136
|
-
replaceState.apply(this, args);
|
|
1137
|
-
record();
|
|
1138
|
-
};
|
|
1139
|
-
window.addEventListener("popstate", record);
|
|
1140
|
-
return () => {
|
|
1141
|
-
window.history.pushState = pushState;
|
|
1142
|
-
window.history.replaceState = replaceState;
|
|
1143
|
-
window.removeEventListener("popstate", record);
|
|
1144
|
-
};
|
|
1147
|
+
return subscribeToPathChanges(record);
|
|
1145
1148
|
}, [client, enabled]);
|
|
1146
1149
|
}
|
|
1147
1150
|
var LOCATION_STORAGE_KEY = "cimplify_location_id";
|
|
@@ -17395,12 +17398,12 @@ function Panel({
|
|
|
17395
17398
|
}
|
|
17396
17399
|
),
|
|
17397
17400
|
error != null && /* @__PURE__ */ jsx("div", { className: "border-t border-red-200 bg-red-50 px-4 py-2 text-xs text-red-600", children: error.userMessage || "Something went wrong. Please try again." }),
|
|
17398
|
-
|
|
17401
|
+
/* @__PURE__ */ jsx(
|
|
17399
17402
|
ChatInput,
|
|
17400
17403
|
{
|
|
17401
17404
|
placeholder,
|
|
17402
17405
|
isSending,
|
|
17403
|
-
onSend,
|
|
17406
|
+
onSend: isActive ? onSend : onStartConversation,
|
|
17404
17407
|
onAttach,
|
|
17405
17408
|
className: classNames?.input
|
|
17406
17409
|
}
|
|
@@ -952,6 +952,12 @@ interface ActivityService {
|
|
|
952
952
|
|
|
953
953
|
interface SupportService {
|
|
954
954
|
openConversation(businessId: string, customerId?: string): MockConversation;
|
|
955
|
+
/**
|
|
956
|
+
* The conversation for this visitor, opening one if none exists. Mirrors the
|
|
957
|
+
* lens, whose `send_message` takes no conversation id at all and resolves the
|
|
958
|
+
* thread from the widget identity — so a first message must not 404.
|
|
959
|
+
*/
|
|
960
|
+
ensureConversation(businessId: string, customerId?: string): MockConversation;
|
|
955
961
|
peekConversation(businessId: string, customerId?: string): {
|
|
956
962
|
conversation: MockConversation | null;
|
|
957
963
|
messages: MockChatMessage[];
|
|
@@ -952,6 +952,12 @@ interface ActivityService {
|
|
|
952
952
|
|
|
953
953
|
interface SupportService {
|
|
954
954
|
openConversation(businessId: string, customerId?: string): MockConversation;
|
|
955
|
+
/**
|
|
956
|
+
* The conversation for this visitor, opening one if none exists. Mirrors the
|
|
957
|
+
* lens, whose `send_message` takes no conversation id at all and resolves the
|
|
958
|
+
* thread from the widget identity — so a first message must not 404.
|
|
959
|
+
*/
|
|
960
|
+
ensureConversation(businessId: string, customerId?: string): MockConversation;
|
|
955
961
|
peekConversation(businessId: string, customerId?: string): {
|
|
956
962
|
conversation: MockConversation | null;
|
|
957
963
|
messages: MockChatMessage[];
|
package/dist/testing/msw.d.mts
CHANGED
package/dist/testing/msw.d.ts
CHANGED
package/dist/testing/msw.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkFECGCIVV_js = require('../chunk-FECGCIVV.js');
|
|
4
4
|
require('../chunk-XREIZ56K.js');
|
|
5
5
|
require('../chunk-AETVRBKI.js');
|
|
6
6
|
require('../chunk-OWW5GUSB.js');
|
|
@@ -8,7 +8,7 @@ require('../chunk-OWW5GUSB.js');
|
|
|
8
8
|
// src/mock/msw.ts
|
|
9
9
|
async function createMswHandlers(options = {}) {
|
|
10
10
|
const baseUrl = options.baseUrl ?? "http://localhost:8787";
|
|
11
|
-
const handle =
|
|
11
|
+
const handle = chunkFECGCIVV_js.createMockApp(options);
|
|
12
12
|
const msw = await import('msw').catch(() => {
|
|
13
13
|
throw new Error("msw is required to use @cimplify/sdk/mock/msw \u2014 install it as a peer dependency");
|
|
14
14
|
});
|
package/dist/testing/msw.mjs
CHANGED
package/dist/testing/suite.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TestAPI } from 'vitest';
|
|
2
|
-
import { T as TestClientHandle } from '../client-
|
|
3
|
-
import { C as CreateAppOptions } from '../server-
|
|
4
|
-
export { S as SeedName } from '../server-
|
|
2
|
+
import { T as TestClientHandle } from '../client-BycFj07D.mjs';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-HVDbbqR9.mjs';
|
|
4
|
+
export { S as SeedName } from '../server-HVDbbqR9.mjs';
|
|
5
5
|
import '../client-BTL9d_nN.mjs';
|
|
6
6
|
import '../product-O8-wcHSe.mjs';
|
|
7
7
|
import '../payment-pKPpaORI.mjs';
|
package/dist/testing/suite.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TestAPI } from 'vitest';
|
|
2
|
-
import { T as TestClientHandle } from '../client-
|
|
3
|
-
import { C as CreateAppOptions } from '../server-
|
|
4
|
-
export { S as SeedName } from '../server-
|
|
2
|
+
import { T as TestClientHandle } from '../client-DqYNEMce.js';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-JBuTPY-j.js';
|
|
4
|
+
export { S as SeedName } from '../server-JBuTPY-j.js';
|
|
5
5
|
import '../client-BX30FAWZ.js';
|
|
6
6
|
import '../product-O8-wcHSe.js';
|
|
7
7
|
import '../payment-By0JidTe.js';
|