@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
package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts
CHANGED
|
@@ -1656,6 +1656,12 @@ export interface MediaFieldProps {
|
|
|
1656
1656
|
uploadService: string;
|
|
1657
1657
|
/** Empty-well copy (a message key or literal). Default "Add a photo". */
|
|
1658
1658
|
label?: string;
|
|
1659
|
+
/** Set to "avatar" for a circular picker row; omitted preserves the 160pt image well. */
|
|
1660
|
+
presentation?: string;
|
|
1661
|
+
/** `$service:<svc>.<path>` → initials shown in avatar mode when no photo is set. */
|
|
1662
|
+
fallbackTextPath?: string;
|
|
1663
|
+
/** Optional visible heading in avatar mode; label remains the action caption. */
|
|
1664
|
+
heading?: string;
|
|
1659
1665
|
}
|
|
1660
1666
|
/**
|
|
1661
1667
|
* A formatted, multiline editor that writes HTML into an enclosing Form under `id`.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WixCallOptions, WixStreamMessagesRequest } from "./index.js";
|
|
2
|
+
/** Submits a visitor message (for example a visitor-option selection) to the widget's
|
|
3
|
+
* `messages/stream` endpoint. This is a BUFFERED call, not a stream: the endpoint
|
|
4
|
+
* answers with an SSE body, but the Wix bridge reads the whole body before it resolves,
|
|
5
|
+
* so the promise settles only once the response has ended and the events are not
|
|
6
|
+
* delivered as they arrive. The payload is returned opaque, as the bridge hands it
|
|
7
|
+
* over. Native clients expose the same buffered call as `streamMessages`. The request
|
|
8
|
+
* is sent as the visitor or member session the host supplies; a gateway error rejects.
|
|
9
|
+
* @scope visitor — an anonymous visitor session is enough. */
|
|
10
|
+
export declare function streamMessages(req: WixStreamMessagesRequest, opts?: WixCallOptions): Promise<unknown>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
var himalaya: {
|
|
3
|
+
wixApi?: {
|
|
4
|
+
call: (method: string, path: string, body?: unknown, headers?: Record<string, string>) => Promise<unknown>;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
/** Per-call options. `site` addresses ONE call at a business other than the app's
|
|
9
|
+
* active one, so a cross-site rollup can read several businesses concurrently without
|
|
10
|
+
* `setActiveSite` moving the whole process between them. Omitted ⇒ the active business,
|
|
11
|
+
* byte-identical to a call that never passed options.
|
|
12
|
+
*
|
|
13
|
+
* `site.forSite(msid)` from `@himalaya/wix-platform` returns a value of this shape, so
|
|
14
|
+
* it can be passed straight through: `someMethod(req, site.forSite(msid))`. */
|
|
15
|
+
export interface WixCallOptions {
|
|
16
|
+
site?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function wixCall<T>(method: string, path: string, body?: unknown, opts?: WixCallOptions): Promise<T>;
|
|
19
|
+
/** `path` with `req` appended as the query string Wix's RPC gateway reads a GET or
|
|
20
|
+
* DELETE request from. A nested object flattens to dotted field paths
|
|
21
|
+
* (`{ sort: { order: "ASC" } }` → `sort.order=ASC`), an array repeats its key
|
|
22
|
+
* (`{ id: ["a", "b"] }` → `id=a&id=b`), and an absent field contributes nothing —
|
|
23
|
+
* so an empty request yields the bare path. A field whose value is an array of
|
|
24
|
+
* objects has no query-string spelling and is omitted, exactly as Wix's own client
|
|
25
|
+
* omits it; such a field has to be sent through a POST sibling endpoint instead.
|
|
26
|
+
*
|
|
27
|
+
* Built from template literals and `encodeURIComponent`, never `URLSearchParams`:
|
|
28
|
+
* that is a host global the bare Tier-5 worker runtimes (JSCore / Hermes /
|
|
29
|
+
* QuickJS-ng) do not provide, so reaching for it would throw a ReferenceError
|
|
30
|
+
* before the request went out rather than degrade.
|
|
31
|
+
*
|
|
32
|
+
* Exported so the hand-written ./extensions sidecar can build the same URLs. */
|
|
33
|
+
export declare function wixQueryPath(path: string, req: unknown): string;
|
|
34
|
+
export interface WixMessage {
|
|
35
|
+
id?: string;
|
|
36
|
+
createdDate?: string;
|
|
37
|
+
sender?: string;
|
|
38
|
+
conversationId?: string;
|
|
39
|
+
answerTo?: string;
|
|
40
|
+
messageType?: string;
|
|
41
|
+
body?: WixBody;
|
|
42
|
+
inboxId?: string;
|
|
43
|
+
visitorOptions?: string[];
|
|
44
|
+
assistantActions?: string[];
|
|
45
|
+
visitorOptionsFields?: Record<string, unknown>[];
|
|
46
|
+
engineStatus?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface WixBody {
|
|
49
|
+
mainText?: string;
|
|
50
|
+
footerText?: string;
|
|
51
|
+
additionalData?: Record<string, unknown>[];
|
|
52
|
+
}
|
|
53
|
+
export interface WixListMessagesRequest {
|
|
54
|
+
cursorPaging?: WixCursorPaging;
|
|
55
|
+
}
|
|
56
|
+
export interface WixCursorPaging {
|
|
57
|
+
limit?: number;
|
|
58
|
+
cursor?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface WixListMessagesResponse {
|
|
61
|
+
messages?: WixMessage[];
|
|
62
|
+
pagingMetadata?: WixPagingMetadataV2;
|
|
63
|
+
}
|
|
64
|
+
export interface WixPagingMetadataV2 {
|
|
65
|
+
count?: number;
|
|
66
|
+
offset?: number;
|
|
67
|
+
total?: number;
|
|
68
|
+
tooManyToCount?: boolean;
|
|
69
|
+
cursors?: WixCursors;
|
|
70
|
+
hasNext?: boolean;
|
|
71
|
+
}
|
|
72
|
+
export interface WixCursors {
|
|
73
|
+
next?: string;
|
|
74
|
+
prev?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface WixStreamMessagesRequest {
|
|
77
|
+
message: WixStreamMessage;
|
|
78
|
+
}
|
|
79
|
+
export interface WixStreamMessage {
|
|
80
|
+
sender: "SITE_VISITOR";
|
|
81
|
+
messageType: "VISITOR_OPTION_SELECTED";
|
|
82
|
+
answerTo: string;
|
|
83
|
+
body: WixStreamMessageBody;
|
|
84
|
+
}
|
|
85
|
+
export interface WixStreamMessageBody {
|
|
86
|
+
mainText: string;
|
|
87
|
+
additionalData: WixStreamMessageAdditionalData[];
|
|
88
|
+
}
|
|
89
|
+
export interface WixStreamMessageAdditionalData {
|
|
90
|
+
id: string;
|
|
91
|
+
type: "select_option";
|
|
92
|
+
action: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Lists the messages of the AI Site Chat (Wix Smart Chat) conversation for the active site, paged by cursor via `cursorPaging`. Runs as the site visitor or member session the host supplies; an empty `messages` array means the conversation has no messages yet, and a 4xx/5xx rejects with the gateway error.
|
|
96
|
+
*
|
|
97
|
+
* @scope visitor — an anonymous visitor session is enough.
|
|
98
|
+
*
|
|
99
|
+
* GET /wix-assistant-widget/v1/messages/list
|
|
100
|
+
*/
|
|
101
|
+
export declare function listMessages(req?: WixListMessagesRequest, opts?: WixCallOptions): Promise<WixListMessagesResponse>;
|
|
102
|
+
export * from "./extensions.js";
|
|
@@ -5,8 +5,33 @@ declare global {
|
|
|
5
5
|
};
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
+
export type ChatWebErrorCode = "token_empty" | "token_mint_failed" | "invalid_argument" | "invalid_response";
|
|
9
|
+
/** Typed failure so callers can tell "no token / bad input / bad response" from
|
|
10
|
+
* an empty inbox.
|
|
11
|
+
*
|
|
12
|
+
* A tagged Error, NOT a subclass (same pattern as `genieChatError`): Tier-5
|
|
13
|
+
* bundles are built for a target that refuses `class` syntax, so this module
|
|
14
|
+
* stays class-free. Test with `isChatWebError`, not `instanceof`. */
|
|
15
|
+
export interface ChatWebError extends Error {
|
|
16
|
+
code: ChatWebErrorCode;
|
|
17
|
+
cause?: unknown;
|
|
18
|
+
}
|
|
19
|
+
/** Creates a typed error for token, validation, and malformed-response failures. */
|
|
20
|
+
export declare function chatWebError(code: ChatWebErrorCode, message: string, cause?: unknown): ChatWebError;
|
|
21
|
+
/** Returns whether a value is a typed Wix chat SDK error. */
|
|
22
|
+
export declare function isChatWebError(e: unknown): e is ChatWebError;
|
|
23
|
+
export type ChatRole = "owner" | "member";
|
|
24
|
+
export interface ChatOptions {
|
|
25
|
+
/** `owner` (default) mints with isForUnifiedList=true; `member` with false. */
|
|
26
|
+
role?: ChatRole;
|
|
27
|
+
/** A caller-supplied chatToken; skips the mint. Never stored by this module. */
|
|
28
|
+
chatToken?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Opaque server cursor. `0` is a valid cursor, so test for null/undefined only. */
|
|
31
|
+
export type ChatCursor = number | string;
|
|
8
32
|
export interface ChatMessage {
|
|
9
33
|
id: string;
|
|
34
|
+
sequence?: number;
|
|
10
35
|
summary?: string;
|
|
11
36
|
createdAt?: number;
|
|
12
37
|
sender?: {
|
|
@@ -29,18 +54,44 @@ export interface ChatMessage {
|
|
|
29
54
|
};
|
|
30
55
|
}>;
|
|
31
56
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
57
|
+
export interface ChatMessagesPage {
|
|
58
|
+
items: ChatMessage[];
|
|
59
|
+
/** Raw server cursors: `before` pages Desc (older), `since` pages Asc (newer). */
|
|
60
|
+
next?: {
|
|
61
|
+
before?: ChatCursor | null;
|
|
62
|
+
since?: ChatCursor | null;
|
|
63
|
+
};
|
|
64
|
+
/** The cursor for the next page in the requested ordering; undefined = end. */
|
|
65
|
+
nextPointer?: ChatCursor;
|
|
66
|
+
}
|
|
67
|
+
export interface GetMessagesPageParams extends ChatOptions {
|
|
68
|
+
pageSize?: number;
|
|
69
|
+
/** Omitted = server default (what the array helper has always sent). */
|
|
70
|
+
ordering?: "Asc" | "Desc";
|
|
71
|
+
nextPointer?: ChatCursor;
|
|
72
|
+
}
|
|
73
|
+
/** One page of history. Verified live (200) for the plain form: chat-web **v1**,
|
|
74
|
+
* chatToken in the QUERY, `pageSize` required. Contract (chat-sdk 24.0.40
|
|
75
|
+
* `server-api.ts:128-139`): optional `ordering=Asc|Desc` and `nextPointer`,
|
|
76
|
+
* response `{items, next:{before,since}}`. */
|
|
77
|
+
export declare function getMessagesPage(chatroomId: string, params?: GetMessagesPageParams): Promise<ChatMessagesPage>;
|
|
78
|
+
/** Fetch the recent messages for a chatroom (first page of `getMessagesPage`). */
|
|
79
|
+
export declare function getMessages(chatroomId: string, pageSize?: number, options?: ChatOptions): Promise<ChatMessage[]>;
|
|
80
|
+
export interface SendChatMessageOptions extends ChatOptions {
|
|
81
|
+
/** Caller-owned message id: the same id on a user retry is the same send
|
|
82
|
+
* intent. Generated when omitted. */
|
|
83
|
+
messageId?: string;
|
|
84
|
+
}
|
|
36
85
|
/** Send a plain-text message to a chatroom. Verified live (200): the body is
|
|
37
86
|
* SendMessageRequest{sendMessageBody:{...,data:[{mimeType:"text/plain",data:{text}}]}}
|
|
38
|
-
* with the chatToken in the `ChatToken` HEADER (query param is rejected).
|
|
39
|
-
|
|
87
|
+
* with the chatToken in the `ChatToken` HEADER (query param is rejected).
|
|
88
|
+
* The send is issued exactly once — this module never retries it; a caller
|
|
89
|
+
* that retries should pass the same `messageId`. */
|
|
90
|
+
export declare function sendChatMessage(chatroomId: string, text: string, options?: SendChatMessageOptions): Promise<void>;
|
|
40
91
|
/** Archive (or unarchive) a chatroom. Verified live (200): chat-web **v1**,
|
|
41
92
|
* `PUT .../chatrooms/{id}/archive|unarchive` with the chatToken in the QUERY.
|
|
42
93
|
* Used by the inbox swipe action. */
|
|
43
|
-
export declare function archiveChatroom(chatroomId: string, archived?: boolean): Promise<void>;
|
|
94
|
+
export declare function archiveChatroom(chatroomId: string, archived?: boolean, options?: ChatOptions): Promise<void>;
|
|
44
95
|
export interface ChatMessagePreview {
|
|
45
96
|
summary?: string;
|
|
46
97
|
createdAt?: number;
|
|
@@ -58,6 +109,7 @@ export interface Chatroom {
|
|
|
58
109
|
isArchived?: boolean;
|
|
59
110
|
createdAt?: number;
|
|
60
111
|
participantId?: string;
|
|
112
|
+
lastReadMessageSequence?: number;
|
|
61
113
|
displayData?: {
|
|
62
114
|
name?: string;
|
|
63
115
|
image?: {
|
|
@@ -66,26 +118,68 @@ export interface Chatroom {
|
|
|
66
118
|
};
|
|
67
119
|
lastMessage?: ChatMessagePreview;
|
|
68
120
|
}
|
|
69
|
-
/** Mint a chatToken (required by every chat-web call).
|
|
70
|
-
*
|
|
71
|
-
* empty body on a cold worker
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
121
|
+
/** Mint a chatToken (required by every chat-web call). Tries the mint exactly
|
|
122
|
+
* `TOKEN_MINT_ATTEMPTS` times: the token endpoint occasionally returns a
|
|
123
|
+
* transient 5xx / empty body on a cold worker. If every attempt throws or
|
|
124
|
+
* returns no token this THROWS a typed `chatWebError` (`token_mint_failed` with
|
|
125
|
+
* the last thrown cause if any attempt threw, else `token_empty`) — it never returns an empty
|
|
126
|
+
* token, so callers cannot render a false "No messages yet". A caller-supplied
|
|
127
|
+
* `options.chatToken` is returned as is (no network). */
|
|
128
|
+
export declare function getChatToken(options?: ChatOptions): Promise<{
|
|
75
129
|
chatToken: string;
|
|
76
130
|
}>;
|
|
77
|
-
/** List the site's inbox chatrooms (conversations). Mints a chatToken first.
|
|
78
|
-
|
|
79
|
-
|
|
131
|
+
/** List the site's inbox chatrooms (conversations). Mints a chatToken first.
|
|
132
|
+
* The v2 GET below is the owner (unified-list) endpoint; a member list is the v1
|
|
133
|
+
* list view, so `role: "member"` is served by `listChatroomsPage` (first page). */
|
|
134
|
+
export declare function listChatrooms(pageSize?: number, options?: ChatOptions): Promise<Chatroom[]>;
|
|
135
|
+
export type ParticipantType = "business" | "siteMember";
|
|
136
|
+
export interface ChatroomsPage {
|
|
137
|
+
items: Chatroom[];
|
|
138
|
+
/** Cursor for the next page (`chatrooms.next.before`); undefined = end. */
|
|
139
|
+
nextPointer?: ChatCursor;
|
|
140
|
+
unreadChatroomCount?: number;
|
|
141
|
+
unreadChatroomIds?: string[];
|
|
142
|
+
}
|
|
143
|
+
export interface ListChatroomsPageParams extends ChatOptions {
|
|
144
|
+
/** Optional participant filter; default and `[]` = no filter (the reference
|
|
145
|
+
* allows it: with an `isForUnifiedList=false` chatToken the server scopes the
|
|
146
|
+
* list itself). Elements, when present, must be non-empty strings. */
|
|
147
|
+
participantIds?: string[];
|
|
148
|
+
participantType?: ParticipantType;
|
|
149
|
+
pageSize?: number;
|
|
150
|
+
nextPointer?: ChatCursor;
|
|
151
|
+
archived?: boolean;
|
|
152
|
+
onlyUnread?: boolean;
|
|
153
|
+
unreadChatroomLimit?: number;
|
|
154
|
+
}
|
|
155
|
+
/** One page of the v1 list view (the member list). Contract (chat-sdk 24.0.40
|
|
156
|
+
* `server-api.ts:107-125`): `POST v1/chatrooms-for-list-view[/{participantType}]`,
|
|
157
|
+
* chatToken + paging in the query, body `{participantIds, labelIds}` (`participantIds` may be `[]`), response
|
|
158
|
+
* `{chatrooms:{items,next:{before}}, unreadChatroomCount, unreadChatroomIds}`.
|
|
159
|
+
* Not yet live-verified for a member session. */
|
|
160
|
+
export declare function listChatroomsPage(params?: ListChatroomsPageParams): Promise<ChatroomsPage>;
|
|
161
|
+
/** Mark ONE chatroom read up to a message sequence. Contract (chat-sdk 24.0.40
|
|
162
|
+
* `server-api.ts:268-281`): `PUT v1/chatrooms/{id}/users` body
|
|
163
|
+
* `{lastReadMessageSequence, readMethod?}` → `{lastReadMessageSequence}`
|
|
164
|
+
* (the old `/read` variants 404 — that is a different path). `readMethod` names
|
|
165
|
+
* the channel, e.g. `WixMembersMobileApp` in the member reference apps.
|
|
166
|
+
* Not yet live-verified. */
|
|
167
|
+
export declare function markChatroomRead(chatroomId: string, lastReadMessageSequence: number, options?: ChatOptions & {
|
|
168
|
+
readMethod?: string;
|
|
169
|
+
}): Promise<{
|
|
170
|
+
lastReadMessageSequence?: number;
|
|
171
|
+
}>;
|
|
172
|
+
/** Mark a chatroom UNREAD. Verified live (200) with an empty body: chat-web **v1**,
|
|
80
173
|
* `PUT .../chatrooms/{id}/unread?chatToken=<t>` → `{hasRead, unreadChatroomCount}`.
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
|
|
174
|
+
* The reference sends `{lastReadMessageSequence}` = newest unreadable message
|
|
175
|
+
* sequence − 1 (`server-api.ts:283-287`); pass it as `lastReadMessageSequence`.
|
|
176
|
+
* Omitted = the legacy empty body, so existing callers are unchanged. Used by the
|
|
177
|
+
* inbox "Mark as unread" swipe. */
|
|
178
|
+
export declare function markChatroomUnread(chatroomId: string, lastReadMessageSequence?: number, options?: ChatOptions): Promise<void>;
|
|
85
179
|
/** Delete a chatroom entirely. Verified live (200): chat-web **v1**,
|
|
86
180
|
* `DELETE .../chatrooms/{id}?chatToken=<t>`. Used by the inbox "Delete" swipe
|
|
87
181
|
* (distinct from Archive, which is reversible). */
|
|
88
|
-
export declare function deleteChatroom(chatroomId: string): Promise<void>;
|
|
182
|
+
export declare function deleteChatroom(chatroomId: string, options?: ChatOptions): Promise<void>;
|
|
89
183
|
export interface SocialChatroom {
|
|
90
184
|
id: string;
|
|
91
185
|
name?: string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// ../../stdlib/wix-sdk/ai-site-chat/src/extensions.ts
|
|
2
|
+
function streamMessages(req, opts) {
|
|
3
|
+
return wixCall("POST", "/wix-assistant-widget/v1/messages/stream", req, opts);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// ../../stdlib/wix-sdk/ai-site-chat/src/index.ts
|
|
7
|
+
function wixCallHeaders(opts) {
|
|
8
|
+
const site = opts?.site?.trim();
|
|
9
|
+
return site ? { "wix-site-id": site } : void 0;
|
|
10
|
+
}
|
|
11
|
+
function wixCall(method, path, body, opts) {
|
|
12
|
+
if (!globalThis.himalaya?.wixApi) {
|
|
13
|
+
return Promise.reject(
|
|
14
|
+
new Error(
|
|
15
|
+
"@himalaya/wix-ai-site-chat: host did not install the wixApi bridge"
|
|
16
|
+
)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return globalThis.himalaya.wixApi.call(
|
|
20
|
+
method,
|
|
21
|
+
path,
|
|
22
|
+
body,
|
|
23
|
+
wixCallHeaders(opts)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
function wixQueryPath(path, req) {
|
|
27
|
+
const parts = [];
|
|
28
|
+
const pair = (key, value) => {
|
|
29
|
+
parts.push(
|
|
30
|
+
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
const add = (key, value) => {
|
|
34
|
+
if (value === void 0 || value === null) return;
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
for (const item of value) {
|
|
37
|
+
if (item === void 0 || item === null || typeof item === "object")
|
|
38
|
+
continue;
|
|
39
|
+
pair(key, item);
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (typeof value === "object") {
|
|
44
|
+
for (const [k, v] of Object.entries(value))
|
|
45
|
+
add(`${key}.${k}`, v);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
pair(key, value);
|
|
49
|
+
};
|
|
50
|
+
for (const [key, value] of Object.entries(
|
|
51
|
+
req ?? {}
|
|
52
|
+
))
|
|
53
|
+
add(key, value);
|
|
54
|
+
return parts.length > 0 ? `${path}?${parts.join("&")}` : path;
|
|
55
|
+
}
|
|
56
|
+
function listMessages(req = {}, opts) {
|
|
57
|
+
return wixCall(
|
|
58
|
+
"GET",
|
|
59
|
+
wixQueryPath("/wix-assistant-widget/v1/messages/list", req),
|
|
60
|
+
void 0,
|
|
61
|
+
opts
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
listMessages,
|
|
66
|
+
streamMessages,
|
|
67
|
+
wixCall,
|
|
68
|
+
wixQueryPath
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=wix-ai-site-chat.mjs.map
|