@athoscommerce/snap-store-mobx 1.2.3-beta.1 → 1.3.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.
Files changed (43) hide show
  1. package/dist/cjs/Autocomplete/AutocompleteStore.js +2 -2
  2. package/dist/cjs/Search/Stores/index.d.ts +1 -1
  3. package/dist/cjs/Search/Stores/index.d.ts.map +1 -1
  4. package/dist/cjs/Search/Stores/index.js +1 -2
  5. package/dist/cjs/index.d.ts +0 -4
  6. package/dist/cjs/index.d.ts.map +1 -1
  7. package/dist/cjs/index.js +1 -5
  8. package/dist/cjs/types.d.ts +2 -13
  9. package/dist/cjs/types.d.ts.map +1 -1
  10. package/dist/esm/Autocomplete/AutocompleteStore.js +1 -1
  11. package/dist/esm/Search/Stores/index.d.ts +1 -1
  12. package/dist/esm/Search/Stores/index.d.ts.map +1 -1
  13. package/dist/esm/Search/Stores/index.js +1 -1
  14. package/dist/esm/index.d.ts +0 -4
  15. package/dist/esm/index.d.ts.map +1 -1
  16. package/dist/esm/index.js +0 -2
  17. package/dist/esm/types.d.ts +2 -13
  18. package/dist/esm/types.d.ts.map +1 -1
  19. package/package.json +5 -5
  20. package/dist/cjs/Chat/ChatStore.d.ts +0 -55
  21. package/dist/cjs/Chat/ChatStore.d.ts.map +0 -1
  22. package/dist/cjs/Chat/ChatStore.js +0 -368
  23. package/dist/cjs/Chat/Stores/ChatAttachmentStore.d.ts +0 -98
  24. package/dist/cjs/Chat/Stores/ChatAttachmentStore.d.ts.map +0 -1
  25. package/dist/cjs/Chat/Stores/ChatAttachmentStore.js +0 -312
  26. package/dist/cjs/Chat/Stores/ChatCompareStore.d.ts +0 -14
  27. package/dist/cjs/Chat/Stores/ChatCompareStore.d.ts.map +0 -1
  28. package/dist/cjs/Chat/Stores/ChatCompareStore.js +0 -63
  29. package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts +0 -103
  30. package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts.map +0 -1
  31. package/dist/cjs/Chat/Stores/ChatSessionStore.js +0 -612
  32. package/dist/esm/Chat/ChatStore.d.ts +0 -55
  33. package/dist/esm/Chat/ChatStore.d.ts.map +0 -1
  34. package/dist/esm/Chat/ChatStore.js +0 -309
  35. package/dist/esm/Chat/Stores/ChatAttachmentStore.d.ts +0 -98
  36. package/dist/esm/Chat/Stores/ChatAttachmentStore.d.ts.map +0 -1
  37. package/dist/esm/Chat/Stores/ChatAttachmentStore.js +0 -220
  38. package/dist/esm/Chat/Stores/ChatCompareStore.d.ts +0 -14
  39. package/dist/esm/Chat/Stores/ChatCompareStore.d.ts.map +0 -1
  40. package/dist/esm/Chat/Stores/ChatCompareStore.js +0 -49
  41. package/dist/esm/Chat/Stores/ChatSessionStore.d.ts +0 -103
  42. package/dist/esm/Chat/Stores/ChatSessionStore.d.ts.map +0 -1
  43. package/dist/esm/Chat/Stores/ChatSessionStore.js +0 -581
@@ -1,49 +0,0 @@
1
- import { computed, makeObservable, observable } from 'mobx';
2
- export class ChatCompareStore {
3
- constructor() {
4
- this.items = [];
5
- this.committedItems = [];
6
- this.maxItems = 4;
7
- makeObservable(this, {
8
- items: observable,
9
- committedItems: observable,
10
- maxItems: observable,
11
- compared: computed,
12
- committed: computed,
13
- });
14
- }
15
- // add, remove, reset methods
16
- add(item) {
17
- // prevent adding the same product to the comparison twice
18
- if (item.result?.id && this.items.some((existing) => existing.result?.id === item.result.id)) {
19
- return;
20
- }
21
- if (this.items.length >= this.maxItems) {
22
- // handle max items reached, e.g. remove the oldest item
23
- this.items.shift();
24
- }
25
- this.items.push(item);
26
- }
27
- remove(itemId) {
28
- this.items = this.items.filter((item) => item.result?.id !== itemId);
29
- }
30
- reset() {
31
- this.items = [];
32
- }
33
- resetCommitted() {
34
- this.committedItems = [];
35
- }
36
- // move the current items to the committed list and clear items
37
- commit() {
38
- if (this.items.length > 0) {
39
- this.committedItems = this.items.slice();
40
- this.items = [];
41
- }
42
- }
43
- get compared() {
44
- return this.items;
45
- }
46
- get committed() {
47
- return this.committedItems;
48
- }
49
- }
@@ -1,103 +0,0 @@
1
- import type { ChatResponseModel, ChatRequestModel, ChatResponseTextData, ChatResponseProductSearchResultData, ChatResponseInspirationResultData, ChatResponseContentData, ChatResponseProductAnswerData, ChatResponseProductComparisonData, ChatResponseProductRecommendationData, ChatResponseErrorData, ChatResponseTopicDriftData } from '@athoscommerce/snap-client';
2
- import { ChatAttachmentAddAttachment, ChatAttachmentStore } from '../Stores/ChatAttachmentStore';
3
- import type { StorageStore } from '../../Storage/StorageStore';
4
- import { MetaResponseModel } from '@athoscommerce/snapi-types';
5
- import { ChatCompareStore } from './ChatCompareStore';
6
- export type ChatFeedbacks = {
7
- messageId: string;
8
- rating: 'UP' | 'DOWN';
9
- };
10
- export type ChatSessionFeedback = {
11
- rating: 'UP' | 'DOWN';
12
- };
13
- export type ChatUserMessage = {
14
- id: string;
15
- messageType: 'user';
16
- text: string;
17
- attachments?: string[];
18
- requestType?: string;
19
- };
20
- export type ChatProductQueryMessageData = {
21
- id: string;
22
- messageType: 'productQuery';
23
- sourceProduct: any;
24
- sourceMessageId?: string;
25
- };
26
- export type ChatSystemMessage = ChatResponseTextData | ChatResponseContentData | ChatResponseProductSearchResultData | ChatResponseInspirationResultData | ChatResponseProductAnswerData | ChatResponseProductComparisonData | ChatResponseProductRecommendationData | ChatResponseErrorData | ChatResponseTopicDriftData | ChatProductQueryMessageData;
27
- export type ChatMessage = ChatUserMessage | ChatSystemMessage;
28
- type ChatSessionStoreConfig = {
29
- data?: {
30
- id?: string;
31
- sessionId?: string;
32
- chat?: ChatMessage[];
33
- attachments?: ChatAttachmentAddAttachment[];
34
- actions?: ChatActions;
35
- feedbacks?: ChatFeedbacks[];
36
- sessionFeedback?: ChatSessionFeedback | null;
37
- feedbackDismissed?: boolean;
38
- createdAt?: Date;
39
- committedComparisons?: any[];
40
- };
41
- stores: {
42
- storage: StorageStore;
43
- };
44
- };
45
- export type FacetsData = {
46
- type: 'facets';
47
- data: any;
48
- };
49
- export type ActionsData = {
50
- type: 'actions';
51
- data: any;
52
- };
53
- export type ChatActions = (FacetsData | ActionsData)[];
54
- export declare class ChatSessionStore {
55
- chat: ChatMessage[];
56
- actions: ChatActions;
57
- id: string;
58
- sessionId?: string;
59
- attachments: ChatAttachmentStore;
60
- comparisons: ChatCompareStore;
61
- storage: StorageStore;
62
- feedbacks: ChatFeedbacks[];
63
- sessionFeedback: ChatSessionFeedback | null;
64
- feedbackDismissed: boolean;
65
- feedbackJustGiven: boolean;
66
- createdAt: Date;
67
- requestType: string;
68
- dismissedSideChatMessageId: string | null;
69
- activeMessageId: string | null;
70
- sessionLimitReached: boolean;
71
- /** Whether raw stored results have been hydrated into Product/SearchResultStore instances. */
72
- hydrated: boolean;
73
- constructor(params: ChatSessionStoreConfig);
74
- dismissSideChat(): void;
75
- setActiveMessage(id: string): void;
76
- pushProductQueryMessage(result: any): void;
77
- popProductQueryMessage(restoreActiveMessageId?: string): void;
78
- get isExpired(): boolean;
79
- get topicDrift(): ChatResponseTopicDriftData | null;
80
- get activeMessage(): ChatMessage | null;
81
- dismissTopicDrift(): void;
82
- handleTopicDrift(): string | undefined;
83
- reset(): void;
84
- private saveTimerId;
85
- /** Persist the session to storage immediately (synchronous). */
86
- saveImmediate(): void;
87
- /**
88
- * Schedule a save — multiple calls within the debounce window are coalesced
89
- * into a single localStorage write.
90
- */
91
- save(): void;
92
- /** Remove oldest stored sessions when exceeding the limit. */
93
- static pruneStoredSessions(storage: StorageStore, maxSessions?: number): void;
94
- /** Re-wrap raw stored results as Product / SearchResultStore instances. */
95
- hydrateResults(meta: MetaResponseModel): void;
96
- request(request: ChatRequestModel): void;
97
- update(data: {
98
- chat: ChatResponseModel;
99
- meta: MetaResponseModel;
100
- }): void;
101
- }
102
- export {};
103
- //# sourceMappingURL=ChatSessionStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatSessionStore.d.ts","sourceRoot":"","sources":["../../../../src/Chat/Stores/Chat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