@wix/himalaya-cli 0.1403.0 → 0.1405.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/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +6 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/ai-site-chat/src/extensions.d.ts +10 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/ai-site-chat/src/index.d.ts +102 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/chat-web/src/index.d.ts +115 -21
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-ai-site-chat.mjs +70 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-chat-web.mjs +207 -38
- package/dist/authoring-runtime/node_modules/@wix/himalaya/package.json +4 -0
- package/dist/cli.mjs +95 -38
- package/dist/preview-assets.generated.bin +0 -0
- package/fixtures/wix-canned.json +3 -0
- package/guides/component-reference.json +3 -2
- package/guides/component-reference.md +7 -1
- package/guides/importable-sdks.md +1 -0
- package/guides/sdk-reference.json +217 -14
- package/package.json +2 -2
- package/templates/beauty-salon/config.ts +7 -0
- package/templates/beauty-salon/dev/index.ts +1750 -0
- package/templates/beauty-salon/himalaya.content.json +3 -0
- package/templates/beauty-salon/site-functions/README.md +37 -0
- package/templates/beauty-salon/site-functions/himiMemberPhotoUploadUrl.js +90 -0
- package/templates/beauty-salon/tier5-src/_shared/member-account-routes.ts +11 -3
- package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
- package/templates/beauty-salon/tier5-src/himi-branded-lite-account-settings/index.ts +1091 -0
- package/templates/branded-lite/config.ts +7 -0
- package/templates/branded-lite/dev/index.ts +1750 -0
- package/templates/branded-lite/himalaya.content.json +3 -0
- package/templates/branded-lite/site-functions/README.md +37 -0
- package/templates/branded-lite/site-functions/himiMemberPhotoUploadUrl.js +90 -0
- package/templates/branded-lite/tier5-src/_shared/member-account-routes.ts +11 -3
- package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-account-settings/index.ts +1091 -0
- package/templates/branded-lite/tier5-src/wix-spaces-chat-thread/index.ts +2 -2
- package/templates/community-club/config.ts +7 -0
- package/templates/community-club/dev/index.ts +1750 -0
- package/templates/community-club/himalaya.content.json +3 -0
- package/templates/community-club/site-functions/README.md +37 -0
- package/templates/community-club/site-functions/himiMemberPhotoUploadUrl.js +90 -0
- package/templates/community-club/tier5-src/_shared/member-account-routes.ts +11 -3
- package/templates/community-club/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
- package/templates/community-club/tier5-src/himi-branded-lite-account-settings/index.ts +1091 -0
- package/templates/events-meetups/config.ts +7 -0
- package/templates/events-meetups/dev/index.ts +1750 -0
- package/templates/events-meetups/himalaya.content.json +3 -0
- package/templates/events-meetups/site-functions/README.md +37 -0
- package/templates/events-meetups/site-functions/himiMemberPhotoUploadUrl.js +90 -0
- package/templates/events-meetups/tier5-src/_shared/member-account-routes.ts +11 -3
- package/templates/events-meetups/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
- package/templates/events-meetups/tier5-src/himi-branded-lite-account-settings/index.ts +1091 -0
- package/templates/gym-fitness/config.ts +7 -0
- package/templates/gym-fitness/dev/index.ts +1750 -0
- package/templates/gym-fitness/himalaya.content.json +3 -0
- package/templates/gym-fitness/site-functions/README.md +37 -0
- package/templates/gym-fitness/site-functions/himiMemberPhotoUploadUrl.js +90 -0
- package/templates/gym-fitness/tier5-src/_shared/member-account-routes.ts +11 -3
- package/templates/gym-fitness/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
- package/templates/gym-fitness/tier5-src/himi-branded-lite-account-settings/index.ts +1091 -0
- package/templates/nonprofit-cause/config.ts +7 -0
- package/templates/nonprofit-cause/dev/index.ts +1750 -0
- package/templates/nonprofit-cause/himalaya.content.json +3 -0
- package/templates/nonprofit-cause/site-functions/README.md +37 -0
- package/templates/nonprofit-cause/site-functions/himiMemberPhotoUploadUrl.js +90 -0
- package/templates/nonprofit-cause/tier5-src/_shared/member-account-routes.ts +11 -3
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-account-settings/index.ts +1091 -0
- package/templates/podcast-creator/config.ts +7 -0
- package/templates/podcast-creator/dev/index.ts +1750 -0
- package/templates/podcast-creator/himalaya.content.json +3 -0
- package/templates/podcast-creator/site-functions/README.md +37 -0
- package/templates/podcast-creator/site-functions/himiMemberPhotoUploadUrl.js +90 -0
- package/templates/podcast-creator/tier5-src/_shared/member-account-routes.ts +11 -3
- package/templates/podcast-creator/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
- package/templates/podcast-creator/tier5-src/himi-branded-lite-account-settings/index.ts +1091 -0
- package/templates/portfolio-creative/config.ts +7 -0
- package/templates/portfolio-creative/dev/index.ts +1750 -0
- package/templates/portfolio-creative/himalaya.content.json +3 -0
- package/templates/portfolio-creative/site-functions/README.md +37 -0
- package/templates/portfolio-creative/site-functions/himiMemberPhotoUploadUrl.js +90 -0
- package/templates/portfolio-creative/tier5-src/_shared/member-account-routes.ts +11 -3
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-account-settings/index.ts +1091 -0
- package/templates/restaurant/config.ts +7 -0
- package/templates/restaurant/dev/index.ts +1750 -0
- package/templates/restaurant/himalaya.content.json +3 -0
- package/templates/restaurant/site-functions/README.md +37 -0
- package/templates/restaurant/site-functions/himiMemberPhotoUploadUrl.js +90 -0
- package/templates/restaurant/tier5-src/_shared/member-account-routes.ts +11 -3
- package/templates/restaurant/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
- package/templates/restaurant/tier5-src/himi-branded-lite-account-settings/index.ts +1091 -0
- package/templates/retail-store/config.ts +7 -0
- package/templates/retail-store/dev/index.ts +1750 -0
- package/templates/retail-store/himalaya.content.json +3 -0
- package/templates/retail-store/site-functions/README.md +37 -0
- package/templates/retail-store/site-functions/himiMemberPhotoUploadUrl.js +90 -0
- package/templates/retail-store/tier5-src/_shared/member-account-routes.ts +11 -3
- package/templates/retail-store/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
- package/templates/retail-store/tier5-src/himi-branded-lite-account-settings/index.ts +1091 -0
- package/templates/yoga-studio/config.ts +7 -0
- package/templates/yoga-studio/dev/index.ts +1750 -0
- package/templates/yoga-studio/himalaya.content.json +3 -0
- package/templates/yoga-studio/site-functions/README.md +37 -0
- package/templates/yoga-studio/site-functions/himiMemberPhotoUploadUrl.js +90 -0
- package/templates/yoga-studio/tier5-src/_shared/member-account-routes.ts +11 -3
- package/templates/yoga-studio/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
- package/templates/yoga-studio/tier5-src/himi-branded-lite-account-settings/index.ts +1091 -0
|
@@ -12,73 +12,237 @@ function uuid() {
|
|
|
12
12
|
return v.toString(16);
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
15
|
+
function chatWebError(code, message, cause) {
|
|
16
|
+
const e = new Error(`@himalaya/wix-chat-web: ${message}`);
|
|
17
|
+
e.name = "ChatWebError";
|
|
18
|
+
e.code = code;
|
|
19
|
+
if (cause !== void 0) e.cause = cause;
|
|
20
|
+
return e;
|
|
21
|
+
}
|
|
22
|
+
function isChatWebError(e) {
|
|
23
|
+
return !!e && typeof e === "object" && e.name === "ChatWebError";
|
|
24
|
+
}
|
|
25
|
+
var BASE = "https://manage.wix.com";
|
|
26
|
+
var TOKEN_MINT_ATTEMPTS = 2;
|
|
27
|
+
function pathSegment(value, what) {
|
|
28
|
+
if (typeof value !== "string" || !/^[^\s/\\%?#\u0000-\u001f]+$/.test(value) || value === "." || value === "..") {
|
|
29
|
+
throw chatWebError("invalid_argument", `invalid ${what}`);
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return encodeURIComponent(value);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
throw chatWebError("invalid_argument", `invalid ${what}`, e);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function sequence(value, what) {
|
|
38
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
39
|
+
throw chatWebError("invalid_argument", `invalid ${what}`);
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
var MAX_PAGE_SIZE = 100;
|
|
44
|
+
function pageSizeOf(value) {
|
|
45
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > MAX_PAGE_SIZE) {
|
|
46
|
+
throw chatWebError("invalid_argument", `pageSize must be an integer 1..${MAX_PAGE_SIZE}`);
|
|
47
|
+
}
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
function isCursor(v) {
|
|
51
|
+
if (typeof v === "number") return Number.isSafeInteger(v) && v >= 0;
|
|
52
|
+
if (typeof v !== "string" || v.length === 0 || v.length > 2048) return false;
|
|
53
|
+
try {
|
|
54
|
+
encodeURIComponent(v);
|
|
55
|
+
return true;
|
|
56
|
+
} catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function cursorOf(value) {
|
|
61
|
+
if (value !== void 0 && !isCursor(value)) throw chatWebError("invalid_argument", "invalid nextPointer");
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
function responseCursor(value) {
|
|
65
|
+
if (value === void 0 || value === null) return void 0;
|
|
66
|
+
if (!isCursor(value)) throw chatWebError("invalid_response", "malformed cursor in response");
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
function requiredArray(value, what) {
|
|
70
|
+
if (!Array.isArray(value)) throw chatWebError("invalid_response", `${what} is missing or not an array`);
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
function nextOf(value) {
|
|
74
|
+
if (value === void 0 || value === null) return void 0;
|
|
75
|
+
if (typeof value !== "object" || Array.isArray(value)) throw chatWebError("invalid_response", "next is not an object");
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
function responseArray(value, what) {
|
|
79
|
+
if (value === void 0 || value === null) return void 0;
|
|
80
|
+
if (!Array.isArray(value)) throw chatWebError("invalid_response", `${what} is not an array`);
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
function queryString(params) {
|
|
84
|
+
return Object.keys(params).filter((k) => params[k] !== void 0 && params[k] !== null).map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(String(params[k]))}`).join("&");
|
|
85
|
+
}
|
|
86
|
+
async function getMessagesPage(chatroomId, params = {}) {
|
|
87
|
+
const room = pathSegment(chatroomId, "chatroomId");
|
|
88
|
+
const size = pageSizeOf(params.pageSize === void 0 ? 30 : params.pageSize);
|
|
89
|
+
const { ordering } = params;
|
|
90
|
+
const nextPointer = cursorOf(params.nextPointer);
|
|
91
|
+
if (ordering !== void 0 && ordering !== "Asc" && ordering !== "Desc") {
|
|
92
|
+
throw chatWebError("invalid_argument", "invalid ordering");
|
|
93
|
+
}
|
|
94
|
+
const { chatToken } = await getChatToken(params);
|
|
95
|
+
const query = queryString({ chatToken, pageSize: size, ordering, nextPointer });
|
|
18
96
|
const res = await wixCall(
|
|
19
97
|
"GET",
|
|
20
|
-
`${BASE}/_api/chat-web/v1/chatrooms/${
|
|
98
|
+
`${BASE}/_api/chat-web/v1/chatrooms/${room}/messages?${query}`
|
|
21
99
|
);
|
|
22
|
-
|
|
100
|
+
if (!res || typeof res !== "object") throw chatWebError("invalid_response", "history response is not an object");
|
|
101
|
+
const items = requiredArray(res.items, "items");
|
|
102
|
+
const next = nextOf(res.next);
|
|
103
|
+
const before = responseCursor(next?.before);
|
|
104
|
+
const since = responseCursor(next?.since);
|
|
105
|
+
return { items, next, nextPointer: ordering === "Asc" ? since : before };
|
|
106
|
+
}
|
|
107
|
+
async function getMessages(chatroomId, pageSize = 30, options = {}) {
|
|
108
|
+
return (await getMessagesPage(chatroomId, { ...options, pageSize })).items;
|
|
23
109
|
}
|
|
24
|
-
async function sendChatMessage(chatroomId, text) {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
110
|
+
async function sendChatMessage(chatroomId, text, options = {}) {
|
|
111
|
+
const room = pathSegment(chatroomId, "chatroomId");
|
|
112
|
+
if (options.messageId !== void 0 && (typeof options.messageId !== "string" || !options.messageId)) {
|
|
113
|
+
throw chatWebError("invalid_argument", "invalid messageId");
|
|
114
|
+
}
|
|
115
|
+
const id = options.messageId ?? uuid();
|
|
116
|
+
const { chatToken } = await getChatToken(options);
|
|
27
117
|
await wixCall(
|
|
28
118
|
"POST",
|
|
29
|
-
`${BASE}/_api/chat-web/v2/chatrooms/${
|
|
30
|
-
{ sendMessageBody: { id
|
|
119
|
+
`${BASE}/_api/chat-web/v2/chatrooms/${room}/messages`,
|
|
120
|
+
{ sendMessageBody: { id, messageType: "message", messageTypeVersion: 1, summary: text, data: [{ mimeType: "text/plain", data: { text } }] } },
|
|
31
121
|
{ ChatToken: chatToken }
|
|
32
122
|
);
|
|
33
123
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const { chatToken } = await getChatToken();
|
|
37
|
-
if (!chatToken) throw new Error("chat-web: no chatToken");
|
|
124
|
+
async function archiveChatroom(chatroomId, archived = true, options = {}) {
|
|
125
|
+
const room = pathSegment(chatroomId, "chatroomId");
|
|
126
|
+
const { chatToken } = await getChatToken(options);
|
|
38
127
|
const verb = archived ? "archive" : "unarchive";
|
|
39
128
|
await wixCall(
|
|
40
129
|
"PUT",
|
|
41
|
-
`${BASE}/_api/chat-web/v1/chatrooms/${
|
|
130
|
+
`${BASE}/_api/chat-web/v1/chatrooms/${room}/${verb}?chatToken=${encodeURIComponent(chatToken)}`,
|
|
42
131
|
{}
|
|
43
132
|
);
|
|
44
133
|
}
|
|
45
|
-
async function getChatToken() {
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
134
|
+
async function getChatToken(options = {}) {
|
|
135
|
+
if (options.chatToken !== void 0) {
|
|
136
|
+
if (typeof options.chatToken !== "string" || !options.chatToken) {
|
|
137
|
+
throw chatWebError("invalid_argument", "empty chatToken option");
|
|
138
|
+
}
|
|
139
|
+
return { chatToken: options.chatToken };
|
|
140
|
+
}
|
|
141
|
+
const role = options.role ?? "owner";
|
|
142
|
+
if (role !== "owner" && role !== "member") {
|
|
143
|
+
throw chatWebError("invalid_argument", "invalid role");
|
|
144
|
+
}
|
|
145
|
+
const unified = role === "owner";
|
|
146
|
+
let failure;
|
|
147
|
+
for (let attempt = 0; attempt < TOKEN_MINT_ATTEMPTS; attempt++) {
|
|
148
|
+
try {
|
|
149
|
+
const r = await wixCall(
|
|
150
|
+
"POST",
|
|
151
|
+
`${BASE}/_api/wix-chat-tokens-server/v1/chat-tokens?isForUnifiedList=${unified}`,
|
|
152
|
+
{}
|
|
153
|
+
);
|
|
154
|
+
if (typeof r?.chatToken === "string" && r.chatToken) return { chatToken: r.chatToken };
|
|
155
|
+
} catch (e) {
|
|
156
|
+
failure = e;
|
|
157
|
+
}
|
|
55
158
|
}
|
|
56
|
-
|
|
159
|
+
throw failure === void 0 ? chatWebError("token_empty", `chat token mint returned no token after ${TOKEN_MINT_ATTEMPTS} attempts`) : chatWebError("token_mint_failed", `chat token mint failed after ${TOKEN_MINT_ATTEMPTS} attempts`, failure);
|
|
57
160
|
}
|
|
58
|
-
async function listChatrooms(pageSize = 20) {
|
|
59
|
-
|
|
60
|
-
|
|
161
|
+
async function listChatrooms(pageSize = 20, options = {}) {
|
|
162
|
+
if (options.role === "member") return (await listChatroomsPage({ ...options, pageSize })).items;
|
|
163
|
+
const { chatToken } = await getChatToken(options);
|
|
61
164
|
const res = await wixCall(
|
|
62
165
|
"GET",
|
|
63
166
|
`${BASE}/_api/chat-web/v2/chatrooms?chatToken=${encodeURIComponent(chatToken)}&pageSize=${pageSize}`
|
|
64
167
|
);
|
|
65
168
|
return res.chatrooms?.items ?? [];
|
|
66
169
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
170
|
+
var LAST_MESSAGE_LIMIT = 10;
|
|
171
|
+
var UNREAD_CHATROOM_LIMIT = 100;
|
|
172
|
+
function unreadChatroomLimitOf(value) {
|
|
173
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > UNREAD_CHATROOM_LIMIT) {
|
|
174
|
+
throw chatWebError("invalid_argument", `unreadChatroomLimit must be an integer 1..${UNREAD_CHATROOM_LIMIT}`);
|
|
175
|
+
}
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
async function listChatroomsPage(params = {}) {
|
|
179
|
+
const { participantIds = [], participantType, archived, onlyUnread, unreadChatroomLimit } = params;
|
|
180
|
+
const size = pageSizeOf(params.pageSize === void 0 ? 20 : params.pageSize);
|
|
181
|
+
const nextPointer = cursorOf(params.nextPointer);
|
|
182
|
+
const unreadLimit = unreadChatroomLimit === void 0 ? UNREAD_CHATROOM_LIMIT : unreadChatroomLimitOf(unreadChatroomLimit);
|
|
183
|
+
if (!Array.isArray(participantIds) || participantIds.some((p) => typeof p !== "string" || !p)) {
|
|
184
|
+
throw chatWebError("invalid_argument", "participantIds must be an array of non-empty strings");
|
|
185
|
+
}
|
|
186
|
+
if (participantType !== void 0 && participantType !== "business" && participantType !== "siteMember") {
|
|
187
|
+
throw chatWebError("invalid_argument", "participantType must be business or siteMember");
|
|
188
|
+
}
|
|
189
|
+
const type = participantType === void 0 ? "" : `/${participantType}`;
|
|
190
|
+
const { chatToken } = await getChatToken(params);
|
|
191
|
+
const query = queryString({
|
|
192
|
+
chatToken,
|
|
193
|
+
nextPointer,
|
|
194
|
+
pageSize: size,
|
|
195
|
+
archived,
|
|
196
|
+
onlyUnread,
|
|
197
|
+
lastMessageLimit: LAST_MESSAGE_LIMIT,
|
|
198
|
+
unreadChatroomLimit: unreadLimit
|
|
199
|
+
});
|
|
200
|
+
const res = await wixCall("POST", `${BASE}/_api/chat-web/v1/chatrooms-for-list-view${type}?${query}`, { participantIds, labelIds: [] });
|
|
201
|
+
if (!res || typeof res !== "object" || !res.chatrooms || typeof res.chatrooms !== "object") {
|
|
202
|
+
throw chatWebError("invalid_response", "list response has no chatrooms");
|
|
203
|
+
}
|
|
204
|
+
const items = requiredArray(res.chatrooms.items, "chatrooms.items");
|
|
205
|
+
const next = nextOf(res.chatrooms.next);
|
|
206
|
+
const unreadChatroomIds = responseArray(res.unreadChatroomIds, "unreadChatroomIds");
|
|
207
|
+
if (res.unreadChatroomCount !== void 0 && typeof res.unreadChatroomCount !== "number") {
|
|
208
|
+
throw chatWebError("invalid_response", "unreadChatroomCount is not a number");
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
items,
|
|
212
|
+
nextPointer: responseCursor(next?.before),
|
|
213
|
+
unreadChatroomCount: res.unreadChatroomCount,
|
|
214
|
+
unreadChatroomIds
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
async function markChatroomRead(chatroomId, lastReadMessageSequence, options = {}) {
|
|
218
|
+
const room = pathSegment(chatroomId, "chatroomId");
|
|
219
|
+
const seq = sequence(lastReadMessageSequence, "lastReadMessageSequence");
|
|
220
|
+
const body = { lastReadMessageSequence: seq };
|
|
221
|
+
if (options.readMethod !== void 0) body.readMethod = options.readMethod;
|
|
222
|
+
const { chatToken } = await getChatToken(options);
|
|
223
|
+
const res = await wixCall(
|
|
224
|
+
"PUT",
|
|
225
|
+
`${BASE}/_api/chat-web/v1/chatrooms/${room}/users?chatToken=${encodeURIComponent(chatToken)}`,
|
|
226
|
+
body
|
|
227
|
+
);
|
|
228
|
+
return { lastReadMessageSequence: res?.lastReadMessageSequence };
|
|
229
|
+
}
|
|
230
|
+
async function markChatroomUnread(chatroomId, lastReadMessageSequence, options = {}) {
|
|
231
|
+
const room = pathSegment(chatroomId, "chatroomId");
|
|
232
|
+
const body = lastReadMessageSequence === void 0 ? {} : { lastReadMessageSequence: sequence(lastReadMessageSequence, "lastReadMessageSequence") };
|
|
233
|
+
const { chatToken } = await getChatToken(options);
|
|
70
234
|
await wixCall(
|
|
71
235
|
"PUT",
|
|
72
|
-
`${BASE}/_api/chat-web/v1/chatrooms/${
|
|
73
|
-
|
|
236
|
+
`${BASE}/_api/chat-web/v1/chatrooms/${room}/unread?chatToken=${encodeURIComponent(chatToken)}`,
|
|
237
|
+
body
|
|
74
238
|
);
|
|
75
239
|
}
|
|
76
|
-
async function deleteChatroom(chatroomId) {
|
|
77
|
-
const
|
|
78
|
-
|
|
240
|
+
async function deleteChatroom(chatroomId, options = {}) {
|
|
241
|
+
const room = pathSegment(chatroomId, "chatroomId");
|
|
242
|
+
const { chatToken } = await getChatToken(options);
|
|
79
243
|
await wixCall(
|
|
80
244
|
"DELETE",
|
|
81
|
-
`${BASE}/_api/chat-web/v1/chatrooms/${
|
|
245
|
+
`${BASE}/_api/chat-web/v1/chatrooms/${room}?chatToken=${encodeURIComponent(chatToken)}`
|
|
82
246
|
);
|
|
83
247
|
}
|
|
84
248
|
async function getOrCreateDirectChatroom(memberId) {
|
|
@@ -99,11 +263,16 @@ async function getOrCreateDirectChatroom(memberId) {
|
|
|
99
263
|
}
|
|
100
264
|
export {
|
|
101
265
|
archiveChatroom,
|
|
266
|
+
chatWebError,
|
|
102
267
|
deleteChatroom,
|
|
103
268
|
getChatToken,
|
|
104
269
|
getMessages,
|
|
270
|
+
getMessagesPage,
|
|
105
271
|
getOrCreateDirectChatroom,
|
|
272
|
+
isChatWebError,
|
|
106
273
|
listChatrooms,
|
|
274
|
+
listChatroomsPage,
|
|
275
|
+
markChatroomRead,
|
|
107
276
|
markChatroomUnread,
|
|
108
277
|
sendChatMessage
|
|
109
278
|
};
|
|
@@ -266,6 +266,10 @@
|
|
|
266
266
|
"types": "./dist/_types/stdlib/wix-sdk/activity-counters-v1/src/index.d.ts",
|
|
267
267
|
"import": "./dist/wix-activity-counters.mjs"
|
|
268
268
|
},
|
|
269
|
+
"./wix-ai-site-chat": {
|
|
270
|
+
"types": "./dist/_types/stdlib/wix-sdk/ai-site-chat/src/index.d.ts",
|
|
271
|
+
"import": "./dist/wix-ai-site-chat.mjs"
|
|
272
|
+
},
|
|
269
273
|
"./wix-analytics": {
|
|
270
274
|
"types": "./dist/_types/stdlib/wix-sdk/analytics/src/index.d.ts",
|
|
271
275
|
"import": "./dist/wix-analytics.mjs"
|