@stapel/chat-react 0.1.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/CHANGELOG.md +1 -0
- package/MODULE.md +118 -0
- package/README.md +126 -0
- package/dist/api/chatApi.d.ts +49 -0
- package/dist/api/chatApi.d.ts.map +1 -0
- package/dist/api/chatApi.js +46 -0
- package/dist/api/chatApi.js.map +1 -0
- package/dist/api/extensions.d.ts +19 -0
- package/dist/api/extensions.d.ts.map +1 -0
- package/dist/api/extensions.js +19 -0
- package/dist/api/extensions.js.map +1 -0
- package/dist/api/generated/schema.d.ts +547 -0
- package/dist/api/generated/schema.d.ts.map +1 -0
- package/dist/api/generated/schema.js +2 -0
- package/dist/api/generated/schema.js.map +1 -0
- package/dist/api/types.d.ts +75 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/default/ConversationListPanel.d.ts +22 -0
- package/dist/default/ConversationListPanel.d.ts.map +1 -0
- package/dist/default/ConversationListPanel.js +49 -0
- package/dist/default/ConversationListPanel.js.map +1 -0
- package/dist/default/ConversationThreadPanel.d.ts +21 -0
- package/dist/default/ConversationThreadPanel.d.ts.map +1 -0
- package/dist/default/ConversationThreadPanel.js +51 -0
- package/dist/default/ConversationThreadPanel.js.map +1 -0
- package/dist/default/ErrorAlert.d.ts +8 -0
- package/dist/default/ErrorAlert.d.ts.map +1 -0
- package/dist/default/ErrorAlert.js +26 -0
- package/dist/default/ErrorAlert.js.map +1 -0
- package/dist/default/StartChatButton.d.ts +17 -0
- package/dist/default/StartChatButton.d.ts.map +1 -0
- package/dist/default/StartChatButton.js +18 -0
- package/dist/default/StartChatButton.js.map +1 -0
- package/dist/default/index.d.ts +21 -0
- package/dist/default/index.d.ts.map +1 -0
- package/dist/default/index.js +18 -0
- package/dist/default/index.js.map +1 -0
- package/dist/flows/errors.d.ts +12 -0
- package/dist/flows/errors.d.ts.map +1 -0
- package/dist/flows/errors.js +13 -0
- package/dist/flows/errors.js.map +1 -0
- package/dist/flows/freshness.d.ts +69 -0
- package/dist/flows/freshness.d.ts.map +1 -0
- package/dist/flows/freshness.js +227 -0
- package/dist/flows/freshness.js.map +1 -0
- package/dist/flows/registry.d.ts +26 -0
- package/dist/flows/registry.d.ts.map +1 -0
- package/dist/flows/registry.js +24 -0
- package/dist/flows/registry.js.map +1 -0
- package/dist/headless/ChatProvider.d.ts +22 -0
- package/dist/headless/ChatProvider.d.ts.map +1 -0
- package/dist/headless/ChatProvider.js +18 -0
- package/dist/headless/ChatProvider.js.map +1 -0
- package/dist/headless/ConversationList.d.ts +51 -0
- package/dist/headless/ConversationList.d.ts.map +1 -0
- package/dist/headless/ConversationList.js +47 -0
- package/dist/headless/ConversationList.js.map +1 -0
- package/dist/headless/ConversationThread.d.ts +50 -0
- package/dist/headless/ConversationThread.d.ts.map +1 -0
- package/dist/headless/ConversationThread.js +64 -0
- package/dist/headless/ConversationThread.js.map +1 -0
- package/dist/headless/MessageComposer.d.ts +39 -0
- package/dist/headless/MessageComposer.d.ts.map +1 -0
- package/dist/headless/MessageComposer.js +45 -0
- package/dist/headless/MessageComposer.js.map +1 -0
- package/dist/headless/StartDirectChat.d.ts +40 -0
- package/dist/headless/StartDirectChat.d.ts.map +1 -0
- package/dist/headless/StartDirectChat.js +46 -0
- package/dist/headless/StartDirectChat.js.map +1 -0
- package/dist/i18n/errorsMap.d.ts +10 -0
- package/dist/i18n/errorsMap.d.ts.map +1 -0
- package/dist/i18n/errorsMap.js +20 -0
- package/dist/i18n/errorsMap.js.map +1 -0
- package/dist/i18n/es.d.ts +23 -0
- package/dist/i18n/es.d.ts.map +1 -0
- package/dist/i18n/es.js +75 -0
- package/dist/i18n/es.js.map +1 -0
- package/dist/i18n/generated/errors.es.gen.d.ts +16 -0
- package/dist/i18n/generated/errors.es.gen.d.ts.map +1 -0
- package/dist/i18n/generated/errors.es.gen.js +58 -0
- package/dist/i18n/generated/errors.es.gen.js.map +1 -0
- package/dist/i18n/generated/errors.gen.d.ts +359 -0
- package/dist/i18n/generated/errors.gen.d.ts.map +1 -0
- package/dist/i18n/generated/errors.gen.js +183 -0
- package/dist/i18n/generated/errors.gen.js.map +1 -0
- package/dist/i18n/generated/errors.ru.gen.d.ts +16 -0
- package/dist/i18n/generated/errors.ru.gen.d.ts.map +1 -0
- package/dist/i18n/generated/errors.ru.gen.js +58 -0
- package/dist/i18n/generated/errors.ru.gen.js.map +1 -0
- package/dist/i18n/keys.d.ts +78 -0
- package/dist/i18n/keys.d.ts.map +1 -0
- package/dist/i18n/keys.js +130 -0
- package/dist/i18n/keys.js.map +1 -0
- package/dist/i18n/ru.d.ts +28 -0
- package/dist/i18n/ru.d.ts.map +1 -0
- package/dist/i18n/ru.js +80 -0
- package/dist/i18n/ru.js.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/model/context.d.ts +11 -0
- package/dist/model/context.d.ts.map +1 -0
- package/dist/model/context.js +16 -0
- package/dist/model/context.js.map +1 -0
- package/dist/model/limits.d.ts +12 -0
- package/dist/model/limits.d.ts.map +1 -0
- package/dist/model/limits.js +12 -0
- package/dist/model/limits.js.map +1 -0
- package/dist/model/mutations.d.ts +66 -0
- package/dist/model/mutations.d.ts.map +1 -0
- package/dist/model/mutations.js +156 -0
- package/dist/model/mutations.js.map +1 -0
- package/dist/model/queries.d.ts +33 -0
- package/dist/model/queries.d.ts.map +1 -0
- package/dist/model/queries.js +93 -0
- package/dist/model/queries.js.map +1 -0
- package/dist/model/queryKeys.d.ts +8 -0
- package/dist/model/queryKeys.d.ts.map +1 -0
- package/dist/model/queryKeys.js +26 -0
- package/dist/model/queryKeys.js.map +1 -0
- package/dist/model/readMarker.d.ts +25 -0
- package/dist/model/readMarker.d.ts.map +1 -0
- package/dist/model/readMarker.js +31 -0
- package/dist/model/readMarker.js.map +1 -0
- package/dist/model/runtime.d.ts +50 -0
- package/dist/model/runtime.d.ts.map +1 -0
- package/dist/model/runtime.js +27 -0
- package/dist/model/runtime.js.map +1 -0
- package/dist/model/threadWindow.d.ts +95 -0
- package/dist/model/threadWindow.d.ts.map +1 -0
- package/dist/model/threadWindow.js +100 -0
- package/dist/model/threadWindow.js.map +1 -0
- package/dist/nav/manifest.d.ts +23 -0
- package/dist/nav/manifest.d.ts.map +1 -0
- package/dist/nav/manifest.js +15 -0
- package/dist/nav/manifest.js.map +1 -0
- package/dist/realtime/chatSocket.d.ts +93 -0
- package/dist/realtime/chatSocket.d.ts.map +1 -0
- package/dist/realtime/chatSocket.js +199 -0
- package/dist/realtime/chatSocket.js.map +1 -0
- package/dist/realtime/frames.d.ts +123 -0
- package/dist/realtime/frames.d.ts.map +1 -0
- package/dist/realtime/frames.js +123 -0
- package/dist/realtime/frames.js.map +1 -0
- package/dist/realtime/streams.d.ts +49 -0
- package/dist/realtime/streams.d.ts.map +1 -0
- package/dist/realtime/streams.js +52 -0
- package/dist/realtime/streams.js.map +1 -0
- package/llms.txt +89 -0
- package/manifest.json +733 -0
- package/nav-manifest.json +25 -0
- package/package.json +114 -0
- package/src/analytics/generated/events.json +7 -0
- package/src/api/chatApi.ts +142 -0
- package/src/api/extensions.ts +18 -0
- package/src/api/generated/schema.ts +549 -0
- package/src/api/types.ts +87 -0
- package/src/default/ConversationListPanel.tsx +163 -0
- package/src/default/ConversationThreadPanel.tsx +245 -0
- package/src/default/ErrorAlert.tsx +43 -0
- package/src/default/StartChatButton.tsx +78 -0
- package/src/default/index.ts +20 -0
- package/src/flows/errors.ts +16 -0
- package/src/flows/freshness.ts +315 -0
- package/src/flows/registry.ts +36 -0
- package/src/headless/ChatProvider.tsx +23 -0
- package/src/headless/ConversationList.tsx +92 -0
- package/src/headless/ConversationThread.tsx +107 -0
- package/src/headless/MessageComposer.tsx +86 -0
- package/src/headless/StartDirectChat.tsx +75 -0
- package/src/i18n/errorsMap.ts +31 -0
- package/src/i18n/es.ts +95 -0
- package/src/i18n/generated/errors.es.gen.ts +64 -0
- package/src/i18n/generated/errors.gen.ts +214 -0
- package/src/i18n/generated/errors.json +408 -0
- package/src/i18n/generated/errors.ru.gen.ts +64 -0
- package/src/i18n/keys.ts +152 -0
- package/src/i18n/ru.ts +98 -0
- package/src/index.ts +189 -0
- package/src/model/context.tsx +25 -0
- package/src/model/limits.ts +11 -0
- package/src/model/mutations.ts +208 -0
- package/src/model/queries.ts +120 -0
- package/src/model/queryKeys.ts +32 -0
- package/src/model/readMarker.ts +32 -0
- package/src/model/runtime.ts +90 -0
- package/src/model/threadWindow.ts +173 -0
- package/src/nav/manifest.ts +36 -0
- package/src/realtime/chatSocket.ts +304 -0
- package/src/realtime/frames.ts +229 -0
- package/src/realtime/streams.ts +85 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.ru.gen.js","sourceRoot":"","sources":["../../../src/i18n/generated/errors.ru.gen.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA2C;IACvE,uBAAuB,EAAE,qBAAqB;IAC9C,2BAA2B,EAAE,6DAA6D;IAC1F,4BAA4B,EAAE,wBAAwB;IACtD,yBAAyB,EAAE,2BAA2B;IACtD,uBAAuB,EAAE,qCAAqC;IAC9D,gCAAgC,EAAE,yBAAyB;IAC3D,yBAAyB,EAAE,+CAA+C;IAC1E,gCAAgC,EAAE,yCAAyC;IAC3E,4BAA4B,EAAE,gEAAgE;IAC9F,2BAA2B,EAAE,2DAA2D;IACxF,4BAA4B,EAAE,gEAAgE;IAC9F,2BAA2B,EAAE,2DAA2D;IACxF,sBAAsB,EAAE,mCAAmC;IAC3D,0BAA0B,EAAE,4BAA4B;IACxD,wBAAwB,EAAE,gDAAgD;IAC1E,yBAAyB,EAAE,uCAAuC;IAClE,4BAA4B,EAAE,kBAAkB;IAChD,+BAA+B,EAAE,sBAAsB;IACvD,uCAAuC,EAAE,sCAAsC;IAC/E,wBAAwB,EAAE,0BAA0B;IACpD,4BAA4B,EAAE,kBAAkB;IAChD,qBAAqB,EAAE,8CAA8C;IACrE,2BAA2B,EAAE,oCAAoC;IACjE,4CAA4C,EAAE,8CAA8C;IAC5F,iCAAiC,EAAE,mCAAmC;IACtE,wBAAwB,EAAE,uBAAuB;IACjD,qBAAqB,EAAE,8BAA8B;IACrD,4CAA4C,EAAE,6CAA6C;IAC3F,8BAA8B,EAAE,mBAAmB;IACnD,0BAA0B,EAAE,4BAA4B;IACxD,2BAA2B,EAAE,gCAAgC;IAC7D,oBAAoB,EAAE,uBAAuB;IAC7C,gBAAgB,EAAE,gCAAgC;IAClD,6BAA6B,EAAE,8BAA8B;IAC7D,kCAAkC,EAAE,6BAA6B;IACjE,gCAAgC,EAAE,sCAAsC;IACxE,kBAAkB,EAAE,qBAAqB;IACzC,+BAA+B,EAAE,+DAA+D;IAChG,sBAAsB,EAAE,2EAA2E;IACnG,6BAA6B,EAAE,8DAA8D;IAC7F,oBAAoB,EAAE,qBAAqB;IAC3C,+BAA+B,EAAE,qDAAqD;CACvF,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { I18nDictionary, I18nEngine } from "@stapel/core";
|
|
2
|
+
/**
|
|
3
|
+
* chat-react's own translation KEYS (frontend-standard §4.2): headless
|
|
4
|
+
* components never render literal strings — hosts resolve these via core's
|
|
5
|
+
* i18n engine (`useT`). Backend error codes flow through the SAME contour: a
|
|
6
|
+
* `StapelApiError.code` is already a key, so the default bundle below ships
|
|
7
|
+
* English fallbacks for both the backend error codes (generated) and the
|
|
8
|
+
* pair's own UI keys.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CHAT_I18N_KEYS: {
|
|
11
|
+
readonly unknownError: "chat.error.unknown";
|
|
12
|
+
readonly listTitle: "chat.list.title";
|
|
13
|
+
readonly listEmpty: "chat.list.empty";
|
|
14
|
+
readonly listLoading: "chat.list.loading";
|
|
15
|
+
readonly listLoadMore: "chat.list.load_more";
|
|
16
|
+
readonly listEnd: "chat.list.end";
|
|
17
|
+
readonly listRetry: "chat.list.retry";
|
|
18
|
+
readonly listUnread: "chat.list.unread";
|
|
19
|
+
readonly listOpen: "chat.list.open";
|
|
20
|
+
readonly kindDirect: "chat.kind.direct";
|
|
21
|
+
readonly kindGroup: "chat.kind.group";
|
|
22
|
+
readonly kindSupport: "chat.kind.support";
|
|
23
|
+
readonly threadLoading: "chat.thread.loading";
|
|
24
|
+
readonly threadEmpty: "chat.thread.empty";
|
|
25
|
+
readonly threadRetry: "chat.thread.retry";
|
|
26
|
+
readonly threadLoadOlder: "chat.thread.load_older";
|
|
27
|
+
readonly threadBeginning: "chat.thread.beginning";
|
|
28
|
+
readonly threadSystem: "chat.thread.system";
|
|
29
|
+
readonly composerPlaceholder: "chat.composer.placeholder";
|
|
30
|
+
readonly composerSend: "chat.composer.send";
|
|
31
|
+
readonly composerSending: "chat.composer.sending";
|
|
32
|
+
readonly composerBlockedEmpty: "chat.composer.blocked.empty";
|
|
33
|
+
readonly composerBlockedTooLong: "chat.composer.blocked.too_long";
|
|
34
|
+
readonly startButton: "chat.start.button";
|
|
35
|
+
readonly startStarting: "chat.start.starting";
|
|
36
|
+
readonly startBlockedSelf: "chat.start.blocked.self";
|
|
37
|
+
readonly startBlockedUnknownSeller: "chat.start.blocked.unknown_seller";
|
|
38
|
+
readonly transportLive: "chat.transport.live";
|
|
39
|
+
readonly transportPolling: "chat.transport.polling";
|
|
40
|
+
readonly transportIdle: "chat.transport.idle";
|
|
41
|
+
readonly errorEmptyMessage: "error.400.chat_empty_message";
|
|
42
|
+
readonly errorBodyTooLong: "error.400.chat_body_too_long";
|
|
43
|
+
readonly errorAttachmentsDisabled: "error.400.chat_attachments_disabled";
|
|
44
|
+
readonly errorInvalidDirect: "error.400.chat_invalid_direct";
|
|
45
|
+
readonly errorInvalidKind: "error.400.chat_invalid_kind";
|
|
46
|
+
readonly errorKindDisabled: "error.400.chat_kind_disabled";
|
|
47
|
+
readonly errorInvalidReply: "error.400.chat_invalid_reply";
|
|
48
|
+
readonly errorNotSupport: "error.400.chat_not_support";
|
|
49
|
+
readonly errorNotOperator: "error.403.chat_not_operator";
|
|
50
|
+
readonly errorNotParticipant: "error.403.chat_not_participant";
|
|
51
|
+
readonly errorConversationNotFound: "error.404.chat_conversation_not_found";
|
|
52
|
+
readonly errorAlreadyAssigned: "error.409.chat_already_assigned";
|
|
53
|
+
readonly navConversations: "chat.nav.conversations";
|
|
54
|
+
};
|
|
55
|
+
export type ChatI18nKey = (typeof CHAT_I18N_KEYS)[keyof typeof CHAT_I18N_KEYS];
|
|
56
|
+
/**
|
|
57
|
+
* English fallback bundle for chat-react UI keys + backend error codes. The
|
|
58
|
+
* generated `chatErrorBundleEn` (from stapel-chat's error registry, `pnpm
|
|
59
|
+
* gen:errors`) is spread FIRST so every backend `error.*` key has a fallback —
|
|
60
|
+
* a `StapelApiError.code` never renders as a raw key. Hand-polished copy below
|
|
61
|
+
* then OVERRIDES the generated English for the keys users see most.
|
|
62
|
+
*/
|
|
63
|
+
export declare const chatI18nBundleEn: I18nDictionary;
|
|
64
|
+
/**
|
|
65
|
+
* Register chat-react's key bundle into a core i18n engine (call once at
|
|
66
|
+
* startup). Registers under the given locale (default `"en"`).
|
|
67
|
+
*
|
|
68
|
+
* MERGE-PRIORITY CONVENTION (i18n-shipping.md §3 — every `@stapel/*-react`
|
|
69
|
+
* pair follows it): registration order IS override priority, later wins per
|
|
70
|
+
* key. Within a locale, layers register bottom-up:
|
|
71
|
+
*
|
|
72
|
+
* 1. generated en floor (`chatErrorBundleEn` — coverage by construction),
|
|
73
|
+
* 2. the pair's polish / UI copy (this bundle spreads 1 then overrides),
|
|
74
|
+
* 3. the pair's locale bundle from the `./i18n/<locale>` subpath,
|
|
75
|
+
* 4. the HOST's own bundle — always registered LAST.
|
|
76
|
+
*/
|
|
77
|
+
export declare function registerChatI18n(engine: I18nEngine, locale?: string): void;
|
|
78
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/i18n/keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/D;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoEjB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAE/E;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,cA4C9B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,SAAO,GAAG,IAAI,CAExE"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { chatErrorBundleEn } from "./generated/errors.gen.js";
|
|
2
|
+
/**
|
|
3
|
+
* chat-react's own translation KEYS (frontend-standard §4.2): headless
|
|
4
|
+
* components never render literal strings — hosts resolve these via core's
|
|
5
|
+
* i18n engine (`useT`). Backend error codes flow through the SAME contour: a
|
|
6
|
+
* `StapelApiError.code` is already a key, so the default bundle below ships
|
|
7
|
+
* English fallbacks for both the backend error codes (generated) and the
|
|
8
|
+
* pair's own UI keys.
|
|
9
|
+
*/
|
|
10
|
+
export const CHAT_I18N_KEYS = {
|
|
11
|
+
unknownError: "chat.error.unknown",
|
|
12
|
+
// Conversation list
|
|
13
|
+
listTitle: "chat.list.title",
|
|
14
|
+
listEmpty: "chat.list.empty",
|
|
15
|
+
listLoading: "chat.list.loading",
|
|
16
|
+
listLoadMore: "chat.list.load_more",
|
|
17
|
+
listEnd: "chat.list.end",
|
|
18
|
+
listRetry: "chat.list.retry",
|
|
19
|
+
listUnread: "chat.list.unread",
|
|
20
|
+
listOpen: "chat.list.open",
|
|
21
|
+
// Conversation kinds (the response carries no title — the kind and the
|
|
22
|
+
// participants are all a row can honestly say)
|
|
23
|
+
kindDirect: "chat.kind.direct",
|
|
24
|
+
kindGroup: "chat.kind.group",
|
|
25
|
+
kindSupport: "chat.kind.support",
|
|
26
|
+
// Thread
|
|
27
|
+
threadLoading: "chat.thread.loading",
|
|
28
|
+
threadEmpty: "chat.thread.empty",
|
|
29
|
+
threadRetry: "chat.thread.retry",
|
|
30
|
+
threadLoadOlder: "chat.thread.load_older",
|
|
31
|
+
threadBeginning: "chat.thread.beginning",
|
|
32
|
+
threadSystem: "chat.thread.system",
|
|
33
|
+
// Composer
|
|
34
|
+
composerPlaceholder: "chat.composer.placeholder",
|
|
35
|
+
composerSend: "chat.composer.send",
|
|
36
|
+
composerSending: "chat.composer.sending",
|
|
37
|
+
composerBlockedEmpty: "chat.composer.blocked.empty",
|
|
38
|
+
composerBlockedTooLong: "chat.composer.blocked.too_long",
|
|
39
|
+
// "Message the seller"
|
|
40
|
+
startButton: "chat.start.button",
|
|
41
|
+
startStarting: "chat.start.starting",
|
|
42
|
+
startBlockedSelf: "chat.start.blocked.self",
|
|
43
|
+
startBlockedUnknownSeller: "chat.start.blocked.unknown_seller",
|
|
44
|
+
// Transport (the seam is invisible to the UI's BEHAVIOUR, but a person may
|
|
45
|
+
// still be told whether the thread is live or on a timer)
|
|
46
|
+
transportLive: "chat.transport.live",
|
|
47
|
+
transportPolling: "chat.transport.polling",
|
|
48
|
+
transportIdle: "chat.transport.idle",
|
|
49
|
+
// Backend error keys the pair OWNS the localization of. stapel-chat ships
|
|
50
|
+
// English only (it has no `translations/` directory), so its 12 keys are
|
|
51
|
+
// absent from the generated ru/es bundles and are authored here instead —
|
|
52
|
+
// the stapel-forms/stapel_attributes precedent. Listed as keys so the
|
|
53
|
+
// i18n-key-exists lint knows them and `test/i18n.test.ts` can prove all
|
|
54
|
+
// three locales carry them.
|
|
55
|
+
errorEmptyMessage: "error.400.chat_empty_message",
|
|
56
|
+
errorBodyTooLong: "error.400.chat_body_too_long",
|
|
57
|
+
errorAttachmentsDisabled: "error.400.chat_attachments_disabled",
|
|
58
|
+
errorInvalidDirect: "error.400.chat_invalid_direct",
|
|
59
|
+
errorInvalidKind: "error.400.chat_invalid_kind",
|
|
60
|
+
errorKindDisabled: "error.400.chat_kind_disabled",
|
|
61
|
+
errorInvalidReply: "error.400.chat_invalid_reply",
|
|
62
|
+
errorNotSupport: "error.400.chat_not_support",
|
|
63
|
+
errorNotOperator: "error.403.chat_not_operator",
|
|
64
|
+
errorNotParticipant: "error.403.chat_not_participant",
|
|
65
|
+
errorConversationNotFound: "error.404.chat_conversation_not_found",
|
|
66
|
+
errorAlreadyAssigned: "error.409.chat_already_assigned",
|
|
67
|
+
// Nav-manifest label (`../nav/manifest.ts`) — read by a shell via
|
|
68
|
+
// `t(entry.labelKey)`.
|
|
69
|
+
navConversations: "chat.nav.conversations",
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* English fallback bundle for chat-react UI keys + backend error codes. The
|
|
73
|
+
* generated `chatErrorBundleEn` (from stapel-chat's error registry, `pnpm
|
|
74
|
+
* gen:errors`) is spread FIRST so every backend `error.*` key has a fallback —
|
|
75
|
+
* a `StapelApiError.code` never renders as a raw key. Hand-polished copy below
|
|
76
|
+
* then OVERRIDES the generated English for the keys users see most.
|
|
77
|
+
*/
|
|
78
|
+
export const chatI18nBundleEn = {
|
|
79
|
+
// Backend error codes — generated en fallbacks (coverage by construction).
|
|
80
|
+
...chatErrorBundleEn,
|
|
81
|
+
// chat-react UI
|
|
82
|
+
"chat.error.unknown": "Something went wrong. Please try again.",
|
|
83
|
+
"chat.list.title": "Messages",
|
|
84
|
+
"chat.list.empty": "No conversations yet.",
|
|
85
|
+
"chat.list.loading": "Loading conversations…",
|
|
86
|
+
"chat.list.load_more": "Load more",
|
|
87
|
+
"chat.list.end": "That's everything.",
|
|
88
|
+
"chat.list.retry": "Try again",
|
|
89
|
+
"chat.list.unread": "{count} unread",
|
|
90
|
+
"chat.list.open": "Open",
|
|
91
|
+
"chat.kind.direct": "Direct message",
|
|
92
|
+
"chat.kind.group": "Group",
|
|
93
|
+
"chat.kind.support": "Support",
|
|
94
|
+
"chat.thread.loading": "Loading messages…",
|
|
95
|
+
"chat.thread.empty": "No messages yet. Say hello.",
|
|
96
|
+
"chat.thread.retry": "Try again",
|
|
97
|
+
"chat.thread.load_older": "Show earlier messages",
|
|
98
|
+
"chat.thread.beginning": "This is the beginning of the conversation.",
|
|
99
|
+
"chat.thread.system": "System",
|
|
100
|
+
"chat.composer.placeholder": "Write a message…",
|
|
101
|
+
"chat.composer.send": "Send",
|
|
102
|
+
"chat.composer.sending": "Sending…",
|
|
103
|
+
"chat.composer.blocked.empty": "Write something first.",
|
|
104
|
+
"chat.composer.blocked.too_long": "That is longer than {max} characters — shorten it a little.",
|
|
105
|
+
"chat.start.button": "Message the seller",
|
|
106
|
+
"chat.start.starting": "Opening…",
|
|
107
|
+
"chat.start.blocked.self": "This is your own listing.",
|
|
108
|
+
"chat.start.blocked.unknown_seller": "This listing has no seller to write to.",
|
|
109
|
+
"chat.transport.live": "Live",
|
|
110
|
+
"chat.transport.polling": "Refreshing every few seconds",
|
|
111
|
+
"chat.transport.idle": "Paused",
|
|
112
|
+
"chat.nav.conversations": "Messages",
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Register chat-react's key bundle into a core i18n engine (call once at
|
|
116
|
+
* startup). Registers under the given locale (default `"en"`).
|
|
117
|
+
*
|
|
118
|
+
* MERGE-PRIORITY CONVENTION (i18n-shipping.md §3 — every `@stapel/*-react`
|
|
119
|
+
* pair follows it): registration order IS override priority, later wins per
|
|
120
|
+
* key. Within a locale, layers register bottom-up:
|
|
121
|
+
*
|
|
122
|
+
* 1. generated en floor (`chatErrorBundleEn` — coverage by construction),
|
|
123
|
+
* 2. the pair's polish / UI copy (this bundle spreads 1 then overrides),
|
|
124
|
+
* 3. the pair's locale bundle from the `./i18n/<locale>` subpath,
|
|
125
|
+
* 4. the HOST's own bundle — always registered LAST.
|
|
126
|
+
*/
|
|
127
|
+
export function registerChatI18n(engine, locale = "en") {
|
|
128
|
+
engine.registerBundle(locale, chatI18nBundleEn);
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/i18n/keys.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY,EAAE,oBAAoB;IAElC,oBAAoB;IACpB,SAAS,EAAE,iBAAiB;IAC5B,SAAS,EAAE,iBAAiB;IAC5B,WAAW,EAAE,mBAAmB;IAChC,YAAY,EAAE,qBAAqB;IACnC,OAAO,EAAE,eAAe;IACxB,SAAS,EAAE,iBAAiB;IAC5B,UAAU,EAAE,kBAAkB;IAC9B,QAAQ,EAAE,gBAAgB;IAE1B,uEAAuE;IACvE,+CAA+C;IAC/C,UAAU,EAAE,kBAAkB;IAC9B,SAAS,EAAE,iBAAiB;IAC5B,WAAW,EAAE,mBAAmB;IAEhC,SAAS;IACT,aAAa,EAAE,qBAAqB;IACpC,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,mBAAmB;IAChC,eAAe,EAAE,wBAAwB;IACzC,eAAe,EAAE,uBAAuB;IACxC,YAAY,EAAE,oBAAoB;IAElC,WAAW;IACX,mBAAmB,EAAE,2BAA2B;IAChD,YAAY,EAAE,oBAAoB;IAClC,eAAe,EAAE,uBAAuB;IACxC,oBAAoB,EAAE,6BAA6B;IACnD,sBAAsB,EAAE,gCAAgC;IAExD,uBAAuB;IACvB,WAAW,EAAE,mBAAmB;IAChC,aAAa,EAAE,qBAAqB;IACpC,gBAAgB,EAAE,yBAAyB;IAC3C,yBAAyB,EAAE,mCAAmC;IAE9D,2EAA2E;IAC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,2BAA2B,EAAE,kBAAkB;IAC/C,oBAAoB,EAAE,MAAM;IAC5B,uBAAuB,EAAE,UAAU;IACnC,6BAA6B,EAAE,wBAAwB;IACvD,gCAAgC,EAC9B,6DAA6D;IAE/D,mBAAmB,EAAE,oBAAoB;IACzC,qBAAqB,EAAE,UAAU;IACjC,yBAAyB,EAAE,2BAA2B;IACtD,mCAAmC,EAAE,yCAAyC;IAE9E,qBAAqB,EAAE,MAAM;IAC7B,wBAAwB,EAAE,8BAA8B;IACxD,qBAAqB,EAAE,QAAQ;IAE/B,wBAAwB,EAAE,UAAU;CACrC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAkB,EAAE,MAAM,GAAG,IAAI;IAChE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { I18nDictionary, I18nEngine } from "@stapel/core";
|
|
2
|
+
export { chatErrorBundleRu } from "./generated/errors.ru.gen.js";
|
|
3
|
+
/**
|
|
4
|
+
* Russian bundle for chat-react — the pair's `ru` locale, shipped as the
|
|
5
|
+
* `@stapel/chat-react/i18n/ru` subpath (i18n-shipping.md §2) so the locale is
|
|
6
|
+
* opt-in: hosts that don't register it never carry these strings (the main
|
|
7
|
+
* entry does not import this module — gated by size-limit + the bundle-purity
|
|
8
|
+
* test).
|
|
9
|
+
*
|
|
10
|
+
* TWO SOURCES, ON PURPOSE. The generated `chatErrorBundleRu` covers the 42
|
|
11
|
+
* cross-cutting keys stapel-core owns and localizes. The 12 keys stapel-chat
|
|
12
|
+
* owns are NOT in it, and cannot be: the module ships no `translations/`
|
|
13
|
+
* directory at all, so the generator emits a `Partial` bundle and says so in
|
|
14
|
+
* its own header (`ERRORS_LOCALE_EXEMPT_OWNERS`, the stapel-forms precedent).
|
|
15
|
+
* They are authored below, beside the UI copy. When upstream ships
|
|
16
|
+
* `translations/errors.ru.json`, these twelve lines are deleted and the
|
|
17
|
+
* generated bundle covers them — the keys and the texts do not move.
|
|
18
|
+
*/
|
|
19
|
+
export declare const chatI18nBundleRu: I18nDictionary;
|
|
20
|
+
/**
|
|
21
|
+
* Register the pair's `ru` locale into a core i18n engine (call once at
|
|
22
|
+
* startup, after {@link registerChatI18n}). Layers per the merge-priority
|
|
23
|
+
* convention (i18n-shipping.md §3): the en floor is registered UNDER the ru
|
|
24
|
+
* texts inside the `ru` locale, so a key the ru bundle ever misses degrades to
|
|
25
|
+
* its English text — never to a raw key.
|
|
26
|
+
*/
|
|
27
|
+
export declare function registerChatI18nRu(engine: I18nEngine): void;
|
|
28
|
+
//# sourceMappingURL=ru.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ru.d.ts","sourceRoot":"","sources":["../../src/i18n/ru.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,EAAE,cA+D9B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAG3D"}
|
package/dist/i18n/ru.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { chatI18nBundleEn } from "./keys.js";
|
|
2
|
+
import { chatErrorBundleRu } from "./generated/errors.ru.gen.js";
|
|
3
|
+
export { chatErrorBundleRu } from "./generated/errors.ru.gen.js";
|
|
4
|
+
/**
|
|
5
|
+
* Russian bundle for chat-react — the pair's `ru` locale, shipped as the
|
|
6
|
+
* `@stapel/chat-react/i18n/ru` subpath (i18n-shipping.md §2) so the locale is
|
|
7
|
+
* opt-in: hosts that don't register it never carry these strings (the main
|
|
8
|
+
* entry does not import this module — gated by size-limit + the bundle-purity
|
|
9
|
+
* test).
|
|
10
|
+
*
|
|
11
|
+
* TWO SOURCES, ON PURPOSE. The generated `chatErrorBundleRu` covers the 42
|
|
12
|
+
* cross-cutting keys stapel-core owns and localizes. The 12 keys stapel-chat
|
|
13
|
+
* owns are NOT in it, and cannot be: the module ships no `translations/`
|
|
14
|
+
* directory at all, so the generator emits a `Partial` bundle and says so in
|
|
15
|
+
* its own header (`ERRORS_LOCALE_EXEMPT_OWNERS`, the stapel-forms precedent).
|
|
16
|
+
* They are authored below, beside the UI copy. When upstream ships
|
|
17
|
+
* `translations/errors.ru.json`, these twelve lines are deleted and the
|
|
18
|
+
* generated bundle covers them — the keys and the texts do not move.
|
|
19
|
+
*/
|
|
20
|
+
export const chatI18nBundleRu = {
|
|
21
|
+
// Backend error codes — generated ru texts for every key core owns.
|
|
22
|
+
...chatErrorBundleRu,
|
|
23
|
+
// Backend error codes stapel-chat owns — authored here (see the note above).
|
|
24
|
+
"error.400.chat_attachments_disabled": "Вложения отключены в этой установке",
|
|
25
|
+
"error.400.chat_body_too_long": "Сообщение длиннее допустимого предела",
|
|
26
|
+
"error.400.chat_empty_message": "В сообщении должен быть текст или хотя бы одно вложение",
|
|
27
|
+
"error.400.chat_invalid_direct": "В личной переписке должен быть ровно один собеседник",
|
|
28
|
+
"error.400.chat_invalid_kind": "Неизвестный тип диалога",
|
|
29
|
+
"error.400.chat_invalid_reply": "Сообщение, на которое вы отвечаете, не из этого диалога",
|
|
30
|
+
"error.400.chat_kind_disabled": "Этот тип диалога отключён в этой установке",
|
|
31
|
+
"error.400.chat_not_support": "Это действие применимо только к обращениям в поддержку",
|
|
32
|
+
"error.403.chat_not_operator": "Это действие доступно только оператору поддержки",
|
|
33
|
+
"error.403.chat_not_participant": "Вы не участник этого диалога",
|
|
34
|
+
"error.404.chat_conversation_not_found": "Диалог не найден",
|
|
35
|
+
"error.409.chat_already_assigned": "Это обращение уже взято в работу",
|
|
36
|
+
// chat-react UI (hand-written ru mirror of the en copy in keys.ts)
|
|
37
|
+
"chat.error.unknown": "Что-то пошло не так. Попробуйте ещё раз.",
|
|
38
|
+
"chat.list.title": "Сообщения",
|
|
39
|
+
"chat.list.empty": "Диалогов пока нет.",
|
|
40
|
+
"chat.list.loading": "Загрузка диалогов…",
|
|
41
|
+
"chat.list.load_more": "Показать ещё",
|
|
42
|
+
"chat.list.end": "Это все диалоги.",
|
|
43
|
+
"chat.list.retry": "Повторить",
|
|
44
|
+
"chat.list.unread": "Непрочитанных: {count}",
|
|
45
|
+
"chat.list.open": "Открыть",
|
|
46
|
+
"chat.kind.direct": "Личная переписка",
|
|
47
|
+
"chat.kind.group": "Групповой диалог",
|
|
48
|
+
"chat.kind.support": "Поддержка",
|
|
49
|
+
"chat.thread.loading": "Загрузка сообщений…",
|
|
50
|
+
"chat.thread.empty": "Сообщений пока нет. Напишите первым.",
|
|
51
|
+
"chat.thread.retry": "Повторить",
|
|
52
|
+
"chat.thread.load_older": "Показать более ранние",
|
|
53
|
+
"chat.thread.beginning": "Это начало переписки.",
|
|
54
|
+
"chat.thread.system": "Системное сообщение",
|
|
55
|
+
"chat.composer.placeholder": "Напишите сообщение…",
|
|
56
|
+
"chat.composer.send": "Отправить",
|
|
57
|
+
"chat.composer.sending": "Отправка…",
|
|
58
|
+
"chat.composer.blocked.empty": "Сначала напишите текст.",
|
|
59
|
+
"chat.composer.blocked.too_long": "Это длиннее {max} символов — немного сократите.",
|
|
60
|
+
"chat.start.button": "Написать продавцу",
|
|
61
|
+
"chat.start.starting": "Открываем…",
|
|
62
|
+
"chat.start.blocked.self": "Это ваше собственное объявление.",
|
|
63
|
+
"chat.start.blocked.unknown_seller": "У этого объявления не указан продавец.",
|
|
64
|
+
"chat.transport.live": "На связи",
|
|
65
|
+
"chat.transport.polling": "Обновляется каждые несколько секунд",
|
|
66
|
+
"chat.transport.idle": "Приостановлено",
|
|
67
|
+
"chat.nav.conversations": "Сообщения",
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Register the pair's `ru` locale into a core i18n engine (call once at
|
|
71
|
+
* startup, after {@link registerChatI18n}). Layers per the merge-priority
|
|
72
|
+
* convention (i18n-shipping.md §3): the en floor is registered UNDER the ru
|
|
73
|
+
* texts inside the `ru` locale, so a key the ru bundle ever misses degrades to
|
|
74
|
+
* its English text — never to a raw key.
|
|
75
|
+
*/
|
|
76
|
+
export function registerChatI18nRu(engine) {
|
|
77
|
+
engine.registerBundle("ru", chatI18nBundleEn);
|
|
78
|
+
engine.registerBundle("ru", chatI18nBundleRu);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=ru.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ru.js","sourceRoot":"","sources":["../../src/i18n/ru.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAmB;IAC9C,oEAAoE;IACpE,GAAG,iBAAiB;IAEpB,6EAA6E;IAC7E,qCAAqC,EAAE,qCAAqC;IAC5E,8BAA8B,EAAE,uCAAuC;IACvE,8BAA8B,EAC5B,yDAAyD;IAC3D,+BAA+B,EAC7B,sDAAsD;IACxD,6BAA6B,EAAE,yBAAyB;IACxD,8BAA8B,EAC5B,yDAAyD;IAC3D,8BAA8B,EAAE,4CAA4C;IAC5E,4BAA4B,EAC1B,wDAAwD;IAC1D,6BAA6B,EAC3B,kDAAkD;IACpD,gCAAgC,EAAE,8BAA8B;IAChE,uCAAuC,EAAE,kBAAkB;IAC3D,iCAAiC,EAAE,kCAAkC;IAErE,mEAAmE;IACnE,oBAAoB,EAAE,0CAA0C;IAEhE,iBAAiB,EAAE,WAAW;IAC9B,iBAAiB,EAAE,oBAAoB;IACvC,mBAAmB,EAAE,oBAAoB;IACzC,qBAAqB,EAAE,cAAc;IACrC,eAAe,EAAE,kBAAkB;IACnC,iBAAiB,EAAE,WAAW;IAC9B,kBAAkB,EAAE,wBAAwB;IAC5C,gBAAgB,EAAE,SAAS;IAE3B,kBAAkB,EAAE,kBAAkB;IACtC,iBAAiB,EAAE,kBAAkB;IACrC,mBAAmB,EAAE,WAAW;IAEhC,qBAAqB,EAAE,qBAAqB;IAC5C,mBAAmB,EAAE,sCAAsC;IAC3D,mBAAmB,EAAE,WAAW;IAChC,wBAAwB,EAAE,uBAAuB;IACjD,uBAAuB,EAAE,uBAAuB;IAChD,oBAAoB,EAAE,qBAAqB;IAE3C,2BAA2B,EAAE,qBAAqB;IAClD,oBAAoB,EAAE,WAAW;IACjC,uBAAuB,EAAE,WAAW;IACpC,6BAA6B,EAAE,yBAAyB;IACxD,gCAAgC,EAC9B,iDAAiD;IAEnD,mBAAmB,EAAE,mBAAmB;IACxC,qBAAqB,EAAE,YAAY;IACnC,yBAAyB,EAAE,kCAAkC;IAC7D,mCAAmC,EAAE,wCAAwC;IAE7E,qBAAqB,EAAE,UAAU;IACjC,wBAAwB,EAAE,qCAAqC;IAC/D,qBAAqB,EAAE,gBAAgB;IAEvC,wBAAwB,EAAE,WAAW;CACtC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAkB;IACnD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC9C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;AAChD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@stapel/chat-react` — the headless React pair for stapel-chat
|
|
3
|
+
* (frontend-standard §2). Business + state only, zero visual opinion. Built on
|
|
4
|
+
* `@stapel/core`'s StapelClient (verification-403 interception, token refresh,
|
|
5
|
+
* i18n, analytics, query layer).
|
|
6
|
+
*
|
|
7
|
+
* WHAT IS DIFFERENT ABOUT THIS PAIR. Its backend has two ways to deliver the
|
|
8
|
+
* same journal: the REST history, and its own resumable WebSocket protocol
|
|
9
|
+
* (`ws/chat/<conversation_id>` — hello{last_seq} → welcome → replay →
|
|
10
|
+
* replay_done → live). Both are wired here, behind ONE seam
|
|
11
|
+
* (`useChatFreshness`), and no component above that seam can tell which is
|
|
12
|
+
* running. Writes go over REST in either case. See `flows/freshness.ts` for
|
|
13
|
+
* the seam and the criterion under which `@stapel/realtime` replaces its
|
|
14
|
+
* insides.
|
|
15
|
+
*
|
|
16
|
+
* Layers: api → model → realtime → flows → headless → i18n. Generated
|
|
17
|
+
* surfaces (error map, manifest, llms.txt) are produced by the monorepo
|
|
18
|
+
* `gen:*` drivers and stand under drift gates.
|
|
19
|
+
*/
|
|
20
|
+
export { createChatApi } from "./api/chatApi.js";
|
|
21
|
+
export type { ChatApi } from "./api/chatApi.js";
|
|
22
|
+
export type { Schemas, AnchorDirection, ChatMessage, Conversation, ConversationKind, ConversationListParams, ConversationPage, CreateConversationRequest, MarkReadRequest, MessageHistoryParams, MessageKind, MessagePage, Participant, ParticipantRole, SendMessageRequest, SupportStatus, } from "./api/types.js";
|
|
23
|
+
export { CHAT_WS_CLOSE_NOT_PARTICIPANT, CHAT_WS_CLOSE_UNAUTHENTICATED, CHAT_WS_REPLAY_LIMIT, CHAT_WS_RESYNC, decodeServerFrame, parseServerFrame, } from "./realtime/frames.js";
|
|
24
|
+
export type { ChatAckFrame, ChatClientFrame, ChatErrorFrame, ChatHelloFrame, ChatMessageFrame, ChatPingFrame, ChatPongFrame, ChatReplayDoneFrame, ChatSendFrame, ChatServerFrame, ChatWelcomeFrame, } from "./realtime/frames.js";
|
|
25
|
+
export { browserWebSocketFactory, canOpenWebSocket, createChatSocket, } from "./realtime/chatSocket.js";
|
|
26
|
+
export type { ChatConnectionState, ChatReconnectOptions, ChatSocket, ChatSocketConnection, ChatSocketHandlers, ChatSocketOptions, ChatSocketRefusal, ChatSocketStatus, ChatWebSocketFactory, } from "./realtime/chatSocket.js";
|
|
27
|
+
export { chatConversationStream, chatInboxStream, chatSocketUrl, chatStreamId, deriveChatSocketBase, } from "./realtime/streams.js";
|
|
28
|
+
export type { ChatConversationStream, ChatInboxStream, ChatStreamKey, } from "./realtime/streams.js";
|
|
29
|
+
export { createFlowMachine, useFlow, isErrorCode } from "@stapel/core";
|
|
30
|
+
export type { FlowMachine, FlowMachineOptions, FlowStateBase, FlowError, } from "@stapel/core";
|
|
31
|
+
export { toFlowError } from "./flows/errors.js";
|
|
32
|
+
export { CHAT_FLOWS, flowEndpoints } from "./flows/registry.js";
|
|
33
|
+
export type { ChatFlowId, ChatFlowSpec, FlowEndpoint } from "./flows/registry.js";
|
|
34
|
+
export { CONVERSATION_LIST_INTERVAL_MS, THREAD_INTERVAL_MS, useChatFreshness, } from "./flows/freshness.js";
|
|
35
|
+
export type { ChatFreshness, ChatFreshnessOptions, ChatSignal, ChatSignalKeyMap, ChatTransport, } from "./flows/freshness.js";
|
|
36
|
+
export { createChatRuntime } from "./model/runtime.js";
|
|
37
|
+
export type { ChatRealtimeConfig, ChatRealtimeOptions, ChatRuntime, CreateChatRuntimeOptions, } from "./model/runtime.js";
|
|
38
|
+
export { ChatRuntimeContext, useChatRuntime, useChatApi, useChatAnalytics, } from "./model/context.js";
|
|
39
|
+
export { chatQueryKeys } from "./model/queryKeys.js";
|
|
40
|
+
export { THREAD_PAGE, useConversation, useConversations, useThread } from "./model/queries.js";
|
|
41
|
+
export { useLoadOlderMessages, useMarkRead, useSendMessage, useStartDirectChat, } from "./model/mutations.js";
|
|
42
|
+
export type { SendMessageVariables, StartDirectChatVariables, } from "./model/mutations.js";
|
|
43
|
+
export { CHAT_DEFAULT_MAX_BODY_LENGTH } from "./model/limits.js";
|
|
44
|
+
export { nextReadMarker } from "./model/readMarker.js";
|
|
45
|
+
export { EMPTY_THREAD_WINDOW, mergeMessage, mergeNewerPage, mergeOlderPage, threadFirstSeq, threadLastSeq, threadWindowFromPage, } from "./model/threadWindow.js";
|
|
46
|
+
export type { ChatThreadWindow, ThreadMergeResult } from "./model/threadWindow.js";
|
|
47
|
+
export { ChatProvider } from "./headless/ChatProvider.js";
|
|
48
|
+
export { ConversationList } from "./headless/ConversationList.js";
|
|
49
|
+
export type { ConversationListBag } from "./headless/ConversationList.js";
|
|
50
|
+
export { ConversationThread } from "./headless/ConversationThread.js";
|
|
51
|
+
export type { ConversationThreadBag } from "./headless/ConversationThread.js";
|
|
52
|
+
export { MessageComposer } from "./headless/MessageComposer.js";
|
|
53
|
+
export type { MessageComposerBag } from "./headless/MessageComposer.js";
|
|
54
|
+
export { StartDirectChat } from "./headless/StartDirectChat.js";
|
|
55
|
+
export type { StartDirectChatBag } from "./headless/StartDirectChat.js";
|
|
56
|
+
export { navEntries } from "./nav/manifest.js";
|
|
57
|
+
export { CHAT_I18N_KEYS, chatI18nBundleEn, registerChatI18n } from "./i18n/keys.js";
|
|
58
|
+
export type { ChatI18nKey } from "./i18n/keys.js";
|
|
59
|
+
export { CHAT_ERRORS, CHAT_ERROR_CODES, chatErrorBundleEn, explainChatError, } from "./i18n/errorsMap.js";
|
|
60
|
+
export type { ChatErrorCode, ChatErrorSpec, Remediation, } from "./i18n/errorsMap.js";
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EACV,OAAO,EACP,eAAe,EACf,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,WAAW,EACX,eAAe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AE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGxE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACpF,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,aAAa,EACb,aAAa,EACb,WAAW,GACZ,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@stapel/chat-react` — the headless React pair for stapel-chat
|
|
3
|
+
* (frontend-standard §2). Business + state only, zero visual opinion. Built on
|
|
4
|
+
* `@stapel/core`'s StapelClient (verification-403 interception, token refresh,
|
|
5
|
+
* i18n, analytics, query layer).
|
|
6
|
+
*
|
|
7
|
+
* WHAT IS DIFFERENT ABOUT THIS PAIR. Its backend has two ways to deliver the
|
|
8
|
+
* same journal: the REST history, and its own resumable WebSocket protocol
|
|
9
|
+
* (`ws/chat/<conversation_id>` — hello{last_seq} → welcome → replay →
|
|
10
|
+
* replay_done → live). Both are wired here, behind ONE seam
|
|
11
|
+
* (`useChatFreshness`), and no component above that seam can tell which is
|
|
12
|
+
* running. Writes go over REST in either case. See `flows/freshness.ts` for
|
|
13
|
+
* the seam and the criterion under which `@stapel/realtime` replaces its
|
|
14
|
+
* insides.
|
|
15
|
+
*
|
|
16
|
+
* Layers: api → model → realtime → flows → headless → i18n. Generated
|
|
17
|
+
* surfaces (error map, manifest, llms.txt) are produced by the monorepo
|
|
18
|
+
* `gen:*` drivers and stand under drift gates.
|
|
19
|
+
*/
|
|
20
|
+
// ── api ──────────────────────────────────────────────────────────────────────
|
|
21
|
+
export { createChatApi } from "./api/chatApi.js";
|
|
22
|
+
// ── realtime (the module's own socket protocol, typed) ───────────────────────
|
|
23
|
+
// Exported because a host may want to render the connection state or inject a
|
|
24
|
+
// transport; NOTHING above `flows/freshness.ts` inside this package uses it,
|
|
25
|
+
// which is what keeps the substrate migration to one file.
|
|
26
|
+
export { CHAT_WS_CLOSE_NOT_PARTICIPANT, CHAT_WS_CLOSE_UNAUTHENTICATED, CHAT_WS_REPLAY_LIMIT, CHAT_WS_RESYNC, decodeServerFrame, parseServerFrame, } from "./realtime/frames.js";
|
|
27
|
+
export { browserWebSocketFactory, canOpenWebSocket, createChatSocket, } from "./realtime/chatSocket.js";
|
|
28
|
+
export { chatConversationStream, chatInboxStream, chatSocketUrl, chatStreamId, deriveChatSocketBase, } from "./realtime/streams.js";
|
|
29
|
+
// ── flows (the transport seam + the error fold) ──────────────────────────────
|
|
30
|
+
export { createFlowMachine, useFlow, isErrorCode } from "@stapel/core";
|
|
31
|
+
export { toFlowError } from "./flows/errors.js";
|
|
32
|
+
export { CHAT_FLOWS, flowEndpoints } from "./flows/registry.js";
|
|
33
|
+
export { CONVERSATION_LIST_INTERVAL_MS, THREAD_INTERVAL_MS, useChatFreshness, } from "./flows/freshness.js";
|
|
34
|
+
// ── model (runtime wiring, query keys, context, the thread store) ────────────
|
|
35
|
+
export { createChatRuntime } from "./model/runtime.js";
|
|
36
|
+
export { ChatRuntimeContext, useChatRuntime, useChatApi, useChatAnalytics, } from "./model/context.js";
|
|
37
|
+
export { chatQueryKeys } from "./model/queryKeys.js";
|
|
38
|
+
export { THREAD_PAGE, useConversation, useConversations, useThread } from "./model/queries.js";
|
|
39
|
+
export { useLoadOlderMessages, useMarkRead, useSendMessage, useStartDirectChat, } from "./model/mutations.js";
|
|
40
|
+
export { CHAT_DEFAULT_MAX_BODY_LENGTH } from "./model/limits.js";
|
|
41
|
+
export { nextReadMarker } from "./model/readMarker.js";
|
|
42
|
+
export { EMPTY_THREAD_WINDOW, mergeMessage, mergeNewerPage, mergeOlderPage, threadFirstSeq, threadLastSeq, threadWindowFromPage, } from "./model/threadWindow.js";
|
|
43
|
+
// ── headless (renderless components) ─────────────────────────────────────────
|
|
44
|
+
export { ChatProvider } from "./headless/ChatProvider.js";
|
|
45
|
+
export { ConversationList } from "./headless/ConversationList.js";
|
|
46
|
+
export { ConversationThread } from "./headless/ConversationThread.js";
|
|
47
|
+
export { MessageComposer } from "./headless/MessageComposer.js";
|
|
48
|
+
export { StartDirectChat } from "./headless/StartDirectChat.js";
|
|
49
|
+
// ── nav ──────────────────────────────────────────────────────────────────────
|
|
50
|
+
export { navEntries } from "./nav/manifest.js";
|
|
51
|
+
// ── i18n ─────────────────────────────────────────────────────────────────────
|
|
52
|
+
export { CHAT_I18N_KEYS, chatI18nBundleEn, registerChatI18n } from "./i18n/keys.js";
|
|
53
|
+
// ── errors map (code → status/params/remediation/en; generated) ──────────────
|
|
54
|
+
export { CHAT_ERRORS, CHAT_ERROR_CODES, chatErrorBundleEn, explainChatError, } from "./i18n/errorsMap.js";
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,gFAAgF;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAqBjD,gFAAgF;AAChF,8EAA8E;AAC9E,6EAA6E;AAC7E,2DAA2D;AAC3D,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAc9B,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAYlC,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,aAAa,E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hE,gFAAgF;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,gFAAgF;AAChF,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGpF,gFAAgF;AAChF,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from "react";
|
|
2
|
+
import type { Analytics, ModuleContextKit } from "@stapel/core";
|
|
3
|
+
import type { ChatApi } from "../api/chatApi.js";
|
|
4
|
+
import type { ChatRuntime } from "./runtime.js";
|
|
5
|
+
export declare const ChatRuntimeContext: Context<ChatRuntime | null>;
|
|
6
|
+
export declare const useChatRuntime: () => ChatRuntime;
|
|
7
|
+
export declare const useChatApi: () => ChatApi;
|
|
8
|
+
export declare const useChatAnalytics: () => Analytics | null;
|
|
9
|
+
/** @internal Re-exported as `<ChatProvider>` from `headless/`. */
|
|
10
|
+
export declare const ModuleProvider: ModuleContextKit<ChatRuntime>["Provider"];
|
|
11
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/model/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAWhD,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,WAAW,GAAG,IAAI,CAAsB,CAAC;AAElF,eAAO,MAAM,cAAc,EAAE,MAAM,WAA4B,CAAC;AAEhE,eAAO,MAAM,UAAU,EAAE,MAAM,OAAoB,CAAC;AAEpD,eAAO,MAAM,gBAAgB,EAAE,MAAM,SAAS,GAAG,IAAuB,CAAC;AAEzE,kEAAkE;AAClE,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC,UAAU,CAAgB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createModuleContext } from "@stapel/core";
|
|
2
|
+
/**
|
|
3
|
+
* The wired ChatRuntime shared through React context by `<ChatProvider>`.
|
|
4
|
+
* Hooks in `model/`, `flows/` and `headless/` read the singletons from here.
|
|
5
|
+
* One reviewed copy of this plumbing lives in `@stapel/core`
|
|
6
|
+
* (`createModuleContext`, slim wave §21/S2); this module binds it under the
|
|
7
|
+
* pair's public names.
|
|
8
|
+
*/
|
|
9
|
+
const kit = createModuleContext("Chat");
|
|
10
|
+
export const ChatRuntimeContext = kit.RuntimeContext;
|
|
11
|
+
export const useChatRuntime = kit.useRuntime;
|
|
12
|
+
export const useChatApi = kit.useApi;
|
|
13
|
+
export const useChatAnalytics = kit.useAnalytics;
|
|
14
|
+
/** @internal Re-exported as `<ChatProvider>` from `headless/`. */
|
|
15
|
+
export const ModuleProvider = kit.Provider;
|
|
16
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/model/context.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAKnD;;;;;;GAMG;AACH,MAAM,GAAG,GAAkC,mBAAmB,CAAc,MAAM,CAAC,CAAC;AAEpF,MAAM,CAAC,MAAM,kBAAkB,GAAgC,GAAG,CAAC,cAAc,CAAC;AAElF,MAAM,CAAC,MAAM,cAAc,GAAsB,GAAG,CAAC,UAAU,CAAC;AAEhE,MAAM,CAAC,MAAM,UAAU,GAAkB,GAAG,CAAC,MAAM,CAAC;AAEpD,MAAM,CAAC,MAAM,gBAAgB,GAA2B,GAAG,CAAC,YAAY,CAAC;AAEzE,kEAAkE;AAClE,MAAM,CAAC,MAAM,cAAc,GAA8C,GAAG,CAAC,QAAQ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mirrors of the backend's CONFIGURABLE limits — axes, not constants.
|
|
3
|
+
*
|
|
4
|
+
* `STAPEL_CHAT.MAX_BODY_LENGTH` (`stapel_chat/conf.py`, surfaced in
|
|
5
|
+
* `docs/capabilities.json`) defaults to 4000 characters and a deployment may
|
|
6
|
+
* narrow it. The server stays authoritative and answers
|
|
7
|
+
* `error.400.chat_body_too_long`; the mirror exists so a person is told before
|
|
8
|
+
* they lose what they typed, not after. A host that changed the axis passes
|
|
9
|
+
* its own value to `<MessageComposer maxLength=…>`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CHAT_DEFAULT_MAX_BODY_LENGTH = 4000;
|
|
12
|
+
//# sourceMappingURL=limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/model/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,OAAO,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mirrors of the backend's CONFIGURABLE limits — axes, not constants.
|
|
3
|
+
*
|
|
4
|
+
* `STAPEL_CHAT.MAX_BODY_LENGTH` (`stapel_chat/conf.py`, surfaced in
|
|
5
|
+
* `docs/capabilities.json`) defaults to 4000 characters and a deployment may
|
|
6
|
+
* narrow it. The server stays authoritative and answers
|
|
7
|
+
* `error.400.chat_body_too_long`; the mirror exists so a person is told before
|
|
8
|
+
* they lose what they typed, not after. A host that changed the axis passes
|
|
9
|
+
* its own value to `<MessageComposer maxLength=…>`.
|
|
10
|
+
*/
|
|
11
|
+
export const CHAT_DEFAULT_MAX_BODY_LENGTH = 4000;
|
|
12
|
+
//# sourceMappingURL=limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/model/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { StapelApiError } from "@stapel/core";
|
|
3
|
+
import type { ChatMessage, Conversation } from "../api/types.js";
|
|
4
|
+
import type { ChatThreadWindow } from "./threadWindow.js";
|
|
5
|
+
/** Variables for {@link useSendMessage}. */
|
|
6
|
+
export interface SendMessageVariables {
|
|
7
|
+
readonly body: string;
|
|
8
|
+
/** Quoted message id; must belong to this conversation. */
|
|
9
|
+
readonly replyTo?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Append a message to a thread. On success the persisted row (with its `seq`)
|
|
13
|
+
* is folded straight into the window, so the sender sees their own line
|
|
14
|
+
* without waiting for a poll — and the socket's fan-out copy of the same row
|
|
15
|
+
* is then a duplicate that `mergeMessage` drops.
|
|
16
|
+
*
|
|
17
|
+
* Attachments are NOT wired in this version (spec §4.5): the field exists on
|
|
18
|
+
* the wire, but shipping it would mean shipping CDN upload rights into chat,
|
|
19
|
+
* and a control that is visible but does nothing is worse than one that is
|
|
20
|
+
* absent.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useSendMessage(conversationId: string): UseMutationResult<ChatMessage, StapelApiError, SendMessageVariables>;
|
|
23
|
+
/**
|
|
24
|
+
* Advance the caller's read marker to `upto_seq`.
|
|
25
|
+
*
|
|
26
|
+
* Monotonic on the client as well as on the server: a candidate at or below
|
|
27
|
+
* what this client already reported resolves without a request
|
|
28
|
+
* (`nextReadMarker`). The reported value is remembered in the query cache —
|
|
29
|
+
* see `readMarker.ts` for why it cannot be read back off the wire.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useMarkRead(conversationId: string): UseMutationResult<number | null, StapelApiError, number>;
|
|
32
|
+
/** Variables for {@link useStartDirectChat}. */
|
|
33
|
+
export interface StartDirectChatVariables {
|
|
34
|
+
/** The other person — the seller, on a listing page. */
|
|
35
|
+
readonly userId: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Open the direct thread with someone, creating it only if it does not exist.
|
|
39
|
+
*
|
|
40
|
+
* The idempotency is the module's, not ours: a direct thread is keyed by an
|
|
41
|
+
* order-independent `direct_key` over the participant pair (namespaced by
|
|
42
|
+
* scope) under a unique constraint, and the create race is resolved by the
|
|
43
|
+
* constraint — the loser gets the winner's row (`MODULE.md`, "Direct
|
|
44
|
+
* idempotency"). So "message the seller" is safe to press twice, from two
|
|
45
|
+
* tabs, on two listings.
|
|
46
|
+
*
|
|
47
|
+
* TWO PEOPLE, ONE THREAD — INCLUDING ACROSS LISTINGS. The key is the pair,
|
|
48
|
+
* not the listing: a buyer who writes to the same seller about a second item
|
|
49
|
+
* lands in the same conversation. `CreateConversationRequest.scope_key` does
|
|
50
|
+
* not change that (the server ignores the field and resolves the scope
|
|
51
|
+
* itself — `api/extensions.ts`), so a host that wants the listing named must
|
|
52
|
+
* name it in the first message.
|
|
53
|
+
*/
|
|
54
|
+
export declare function useStartDirectChat(): UseMutationResult<Conversation, StapelApiError, StartDirectChatVariables>;
|
|
55
|
+
/**
|
|
56
|
+
* Backfill one page of older history onto the front of the window
|
|
57
|
+
* (`direction=next` from the window's oldest seq — "next" is OLDER here,
|
|
58
|
+
* because the history is ordered `-seq`).
|
|
59
|
+
*
|
|
60
|
+
* A mutation rather than a second query: it is an action a person takes
|
|
61
|
+
* ("show me more"), it must not re-run on focus, and its result belongs in
|
|
62
|
+
* the ONE thread cache entry rather than in a second one that would then have
|
|
63
|
+
* to be reconciled with it.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useLoadOlderMessages(conversationId: string, limit?: number): UseMutationResult<ChatThreadWindow | null, StapelApiError, void>;
|
|
66
|
+
//# sourceMappingURL=mutations.d.ts.map
|