@koredev/kore-web-sdk 11.18.0-rc.f92a18a → 11.19.0-rc.57e454c

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.
@@ -24,16 +24,18 @@ declare class ProactiveWebCampaignPlugin {
24
24
  static readonly MAX_FLATTEN_DEPTH = 10;
25
25
  private static readonly ACTIVE_CAMPAIGN_SELECTOR;
26
26
  private static readonly CHAT_CONTAINER_SELECTOR;
27
+ private static readonly MAX_API_RETRIES;
28
+ private static readonly RETRY_DELAY_MS;
29
+ private static readonly TEMPLATE_PERSIST_DURATION;
27
30
  isPendingSendAPIEvent: boolean;
31
+ private currentPersistedTemplate;
32
+ private isTemplateRestored;
28
33
  coolDownTime: number;
29
34
  cooldownState: {
30
35
  isActive: boolean;
31
36
  startTime: number;
32
37
  expiryTime: number;
33
38
  };
34
- isVisitorAlreadyChatting: boolean;
35
- private chatSessionInfo;
36
- private static readonly CHAT_SESSION_STORAGE_KEY;
37
39
  constructor(config: any);
38
40
  /**
39
41
  * Generates a unique browser session ID for the campaign trigger session
@@ -42,6 +44,11 @@ declare class ProactiveWebCampaignPlugin {
42
44
  generateBrowserSessionId(): string;
43
45
  onHostCreate(): void;
44
46
  onInit(): void;
47
+ /**
48
+ * Called when view is initialized (DOM ready)
49
+ * Attempts template restoration for chat templates that need DOM access
50
+ */
51
+ onViewInit(): void;
45
52
  onUrlChange(callback: () => void): void;
46
53
  onTitleChange(callback: (newTitle: string) => void): void;
47
54
  /**
@@ -132,7 +139,6 @@ declare class ProactiveWebCampaignPlugin {
132
139
  * @param campaigns - Array of campaign data
133
140
  */
134
141
  extractCustomColumns(campaigns: any[]): void;
135
- sendPWCStartEvent(): void;
136
142
  installPWCTemplates(): void;
137
143
  /**
138
144
  * Creates targeted timers for timeSpent conditions instead of polling every second
@@ -237,7 +243,12 @@ declare class ProactiveWebCampaignPlugin {
237
243
  * @returns true if the recent journey matches the required sequence, false otherwise
238
244
  */
239
245
  isJourneyValid(pageVisitArray: any, websiteArray: any): boolean;
240
- checkEngagementHours(engHours: any): boolean;
246
+ /**
247
+ * Checks if the current time is within the engagement hours specified in engStrategy
248
+ * @param engStrategy - Engagement strategy object with engagement hours settings
249
+ * @returns {boolean} - Returns true if current time is within engagement hours, false otherwise
250
+ */
251
+ checkEngagementHours(engStrategy: any): boolean;
241
252
  createTimeSpentObjs(): void;
242
253
  getLocationDetails(): void;
243
254
  /**
@@ -281,11 +292,74 @@ declare class ProactiveWebCampaignPlugin {
281
292
  * @returns Location name or null if not found
282
293
  */
283
294
  findLocationByType(response: any[], targetType: string): string | null;
284
- sendApiEvent(payload: string, route: string, campInstanceId?: string): Promise<void>;
295
+ /**
296
+ * Sends API event with retry logic
297
+ * @param payload - Event payload
298
+ * @param route - API route
299
+ * @param retryCount - Number of retries remaining (default: MAX_API_RETRIES)
300
+ * @returns Promise with API response
301
+ */
302
+ sendApiEvent(payload: any, route: string, retryCount?: number): Promise<any>;
303
+ /**
304
+ * Determines if an HTTP status code should trigger a retry
305
+ * Retries: 429 (Rate Limit), 5xx (Server Errors)
306
+ * Does NOT retry: 4xx (Client Errors, except 429)
307
+ * @param statusCode - HTTP status code
308
+ * @returns Boolean indicating if retry should happen
309
+ */
310
+ private shouldRetryStatusCode;
311
+ /**
312
+ * Initializes PWC campaigns by calling the pwe_verify API
313
+ */
314
+ initializePWCCampaigns(): Promise<void>;
315
+ /**
316
+ * Restores PWC state from sessionStorage for multi-page apps
317
+ * Called when pwe_data exists but in-memory state is lost (page navigation)
318
+ * Reconstructs campInfo from stored data to avoid redundant API calls
319
+ * @returns Boolean indicating if restoration was successful
320
+ */
321
+ restorePWCStateFromStorage(): boolean;
322
+ /**
323
+ * Handles the pwe_verify API response
324
+ * Processes campaign configuration and initializes PWC system
325
+ * @param responseData - API response data
326
+ */
327
+ handlePweVerifyResponse(responseData: any): Promise<void>;
328
+ /**
329
+ * Handles the pwe_event API response and renders campaign templates
330
+ * @param responseData - API response data
331
+ */
332
+ handlePweEventResponse(responseData: any): void;
333
+ /**
334
+ * Persists template data to sessionStorage for multi-page persistence
335
+ * @param templateData - Template data to persist
336
+ */
337
+ private persistTemplate;
338
+ /**
339
+ * Public method for templates to call when closing
340
+ * Clears persisted template from both memory and sessionStorage
341
+ */
342
+ clearPersistedTemplateFromStorage(): void;
343
+ /**
344
+ * Checks if a persisted template has expired
345
+ * @param template - Persisted template to check
346
+ * @returns Boolean indicating if template has expired
347
+ */
348
+ private isTemplateExpired;
349
+ /**
350
+ * Restores persisted template from sessionStorage if valid
351
+ * Called during onInit after PWC state restoration
352
+ */
353
+ private restorePersistedTemplate;
354
+ /**
355
+ * Re-renders a persisted template in the DOM
356
+ * @param template - Persisted template to render
357
+ */
358
+ private renderPersistedTemplate;
285
359
  /**
286
360
  * Constructs the pwe_data object based on the new campaign structure
287
361
  * Extracts custom column configurations and initializes custom data
288
- * @param campaignData - Campaign data received from socket
362
+ * @param campaignData - Campaign data received from API
289
363
  * @returns Constructed pwe_data object
290
364
  */
291
365
  constructPweData(campaignData: any): any;
@@ -331,7 +405,7 @@ declare class ProactiveWebCampaignPlugin {
331
405
  setupHoverListenerForCondition(condition: any, campInstanceId: string, group: any, groupIndex: number, conditionIndex: number, type: string): void;
332
406
  /**
333
407
  * Constructs rules/exclusions structure with proper grouping and condition tracking
334
- * Reads 'globalType' from socket message but stores as 'groupType' internally
408
+ * Reads 'globalType' from API response but stores as 'groupType' internally
335
409
  * @param rulesConfig - Rules or exclusions configuration
336
410
  * @returns Structured rules object
337
411
  */
@@ -342,6 +416,12 @@ declare class ProactiveWebCampaignPlugin {
342
416
  * @returns Object with conditions grouped by column
343
417
  */
344
418
  groupConditionsByColumn(conditions: any[]): any;
419
+ /**
420
+ * Reconstructs RAW rules format from PROCESSED format stored in pwe_data
421
+ * @param processedRules - Processed rules structure from pwe_data.expected
422
+ * @returns RAW rules structure matching original API format
423
+ */
424
+ reconstructRawRulesFromProcessed(processedRules: any): any;
345
425
  /**
346
426
  * Checks if a campaign has a specific condition type configured in RULES
347
427
  * @param campaign - Campaign object
@@ -580,11 +660,11 @@ declare class ProactiveWebCampaignPlugin {
580
660
  */
581
661
  updateSatisfactionFlags(campInstanceId: string): void;
582
662
  /**
583
- * Triggers campaign event using existing API logic
663
+ * Triggers campaign event using API and handles response
584
664
  * @param campInstanceId - Campaign instance ID
585
665
  * @param campId - Campaign ID
586
666
  */
587
- triggerCampaignEvent(campInstanceId: string, campId: string): void;
667
+ triggerCampaignEvent(campInstanceId: string, campId: string, campaignData: any): Promise<void>;
588
668
  /**
589
669
  * Checks if any campaign template is active
590
670
  * @returns Boolean indicating if any campaign template is active
@@ -621,22 +701,11 @@ declare class ProactiveWebCampaignPlugin {
621
701
  * Only called during page load/refresh - has error handling fallback
622
702
  */
623
703
  restoreCooldownState(): void;
624
- /**
625
- * Initialize chat session state from sessionStorage
626
- */
627
- initializeChatSessionState(): void;
628
704
  /**
629
705
  * Check if chat window is currently open
630
706
  * Note: When minimize class is present, chat window is actually OPEN
631
707
  * @returns true if chat window is open, false if closed/minimized
632
708
  */
633
709
  isChatWindowOpen(): boolean;
634
- /**
635
- * Update chat session state based on received events
636
- * Handles Session_Start, Session_End, and Bot_Active events
637
- * @param eventType - Type of event received
638
- * @param data - Event data
639
- */
640
- updateChatSessionState(eventType: 'Session_Start' | 'Session_End' | 'Bot_Active', data: any): void;
641
710
  }
642
711
  export default ProactiveWebCampaignPlugin;
@@ -1,6 +1,7 @@
1
1
  import BaseChatTemplate from '../baseChatTemplate';
2
2
  import './clockPicker.scss';
3
3
  import { h } from 'preact';
4
+ export declare function ClockPickerInline(props: any): h.JSX.Element;
4
5
  export declare function ClockPicker(props: any): h.JSX.Element | undefined;
5
6
  declare class TemplateClockPicker extends BaseChatTemplate {
6
7
  hostInstance: any;
@@ -2,6 +2,7 @@ import BaseChatTemplate from '../baseChatTemplate';
2
2
  import './datePicker.scss';
3
3
  import { h } from 'preact';
4
4
  export declare function DatePickerExt(props: any): h.JSX.Element;
5
+ export declare function DatePickerInline(props: any): h.JSX.Element;
5
6
  export declare function DatePicker(props: any): h.JSX.Element | undefined;
6
7
  declare class TemplateDatePicker extends BaseChatTemplate {
7
8
  hostInstance: any;
@@ -2,6 +2,7 @@ import BaseChatTemplate from '../baseChatTemplate';
2
2
  import './dateRange.scss';
3
3
  import { h } from 'preact';
4
4
  export declare function DateRangeExt(props: any): h.JSX.Element;
5
+ export declare function DateRangeInline(props: any): h.JSX.Element;
5
6
  export declare function DateRange(props: any): h.JSX.Element | undefined;
6
7
  declare class TemplateDatePicker extends BaseChatTemplate {
7
8
  hostInstance: any;