@epam/ai-dial-chat-hooks 1.1.0-dev.479 → 1.1.0-dev.487

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/index.d.ts CHANGED
@@ -5620,20 +5620,28 @@ export declare interface UseTranscribeAudioResult {
5620
5620
  }
5621
5621
 
5622
5622
  /**
5623
- * Fetches usage stats via the provided `getUserUsage` function on mount.
5623
+ * Fetches usage stats via the provided `getUserUsage` function on mount, and
5624
+ * again whenever `refreshToken` changes.
5624
5625
  *
5625
5626
  * `enabled` (default `true`) lets callers behind a feature flag skip the fetch
5626
5627
  * entirely. The hook accepts the fetch function as a parameter so the caller
5627
5628
  * supplies an already-configured API client — the hook never constructs or
5628
5629
  * imports one itself.
5630
+ *
5631
+ * `refreshToken` (default `0`) is a caller-driven re-fetch trigger, subject to
5632
+ * the same `enabled` gate. The hook owns no timer and reads no clock: the
5633
+ * caller decides when to change the token. A previously resolved `usage` value
5634
+ * is retained while a token-triggered re-fetch is in flight, so the consumer
5635
+ * can keep rendering the last known figures and suppress a full-page loading
5636
+ * state for a refresh.
5629
5637
  */
5630
- export declare const useUsageData: (getUserUsage: () => Promise<UserLimitStatsResponseDto>, enabled?: boolean) => UseUsageDataResult;
5638
+ export declare const useUsageData: (getUserUsage: () => Promise<UserLimitStatsResponseDto>, enabled?: boolean, refreshToken?: number) => UseUsageDataResult;
5631
5639
 
5632
5640
  /** Return shape of {@link useUsageData}. */
5633
5641
  export declare interface UseUsageDataResult {
5634
- /** Rolling usage and rate-limit stats for every deployment the caller has used in the trailing 30 days, plus the caller's global cost budget. */
5642
+ /** Calendar-period usage and rate-limit stats for every deployment the caller has used in the current UTC day, week, and month, plus the caller's global cost budget. Retained across a `refreshToken`-triggered re-fetch until the new response resolves. */
5635
5643
  usage: UserLimitStatsResponseDto | undefined;
5636
- /** `true` while the fetch is in flight. */
5644
+ /** `true` while a fetch is in flight, including a `refreshToken`-triggered re-fetch. */
5637
5645
  isLoading: boolean;
5638
5646
  /** Set when the `getUserUsage` call rejects. */
5639
5647
  usageError: Error | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-chat-hooks",
3
3
  "description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
4
- "version": "1.1.0-dev.479",
4
+ "version": "1.1.0-dev.487",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -96,7 +96,7 @@
96
96
  }
97
97
  },
98
98
  "dependencies": {
99
- "@epam/ai-dial-chat-api-client": "1.1.0-dev.479",
99
+ "@epam/ai-dial-chat-api-client": "1.1.0-dev.487",
100
100
  "dompurify": "3.4.15",
101
101
  "fflate": "^0.8.3",
102
102
  "lru-cache": "^10.4.3",
@@ -105,20 +105,20 @@
105
105
  },
106
106
  "peerDependencies": {
107
107
  "react": "^19.2.8",
108
- "@epam/ai-dial-attachment-canvas": "1.1.0-dev.479",
109
- "@epam/ai-dial-attachment-input": "1.1.0-dev.479",
110
- "@epam/ai-dial-builder-form": "1.1.0-dev.479",
111
- "@epam/ai-dial-catalog": "1.1.0-dev.479",
112
- "@epam/ai-dial-chat-overlay": "1.1.0-dev.479",
113
- "@epam/ai-dial-chat-shared": "1.1.0-dev.479",
114
- "@epam/ai-dial-mcp-apps": "1.1.0-dev.479",
115
- "@epam/ai-dial-publish-panel": "1.1.0-dev.479",
116
- "@epam/ai-dial-quotations": "1.1.0-dev.479",
108
+ "@epam/ai-dial-attachment-canvas": "1.1.0-dev.487",
109
+ "@epam/ai-dial-attachment-input": "1.1.0-dev.487",
110
+ "@epam/ai-dial-builder-form": "1.1.0-dev.487",
111
+ "@epam/ai-dial-catalog": "1.1.0-dev.487",
112
+ "@epam/ai-dial-chat-overlay": "1.1.0-dev.487",
113
+ "@epam/ai-dial-chat-shared": "1.1.0-dev.487",
114
+ "@epam/ai-dial-mcp-apps": "1.1.0-dev.487",
115
+ "@epam/ai-dial-publish-panel": "1.1.0-dev.487",
116
+ "@epam/ai-dial-quotations": "1.1.0-dev.487",
117
117
  "@epam/ai-dial-react-file-manager": "^0.2.0",
118
- "@epam/ai-dial-scheduled-tasks": "1.1.0-dev.479",
119
- "@epam/ai-dial-share": "1.1.0-dev.479",
120
- "@epam/ai-dial-skill-editor": "1.1.0-dev.479",
121
- "@epam/ai-dial-source-panel": "1.1.0-dev.479",
118
+ "@epam/ai-dial-scheduled-tasks": "1.1.0-dev.487",
119
+ "@epam/ai-dial-share": "1.1.0-dev.487",
120
+ "@epam/ai-dial-skill-editor": "1.1.0-dev.487",
121
+ "@epam/ai-dial-source-panel": "1.1.0-dev.487",
122
122
  "@epam/ai-dial-ui-kit": "^0.14.2",
123
123
  "@modelcontextprotocol/sdk": "^1.29.0",
124
124
  "@epam/pdf-highlighter-kit": "^0.0.19",
@@ -1,31 +1,35 @@
1
1
  import { useEffect as e, useState as t } from "react";
2
2
  //#region src/usage/useUsageData/useUsageData.ts
3
- var n = (e) => e instanceof Error ? e : Error(String(e)), r = (r, i = !0) => {
4
- let [a, o] = t(), [s, c] = t(i), [l, u] = t();
3
+ var n = (e) => e instanceof Error ? e : Error(String(e)), r = (r, i = !0, a = 0) => {
4
+ let [o, s] = t(), [c, l] = t(i), [u, d] = t();
5
5
  return e(() => {
6
6
  if (!i) {
7
- c(!1);
7
+ l(!1);
8
8
  return;
9
9
  }
10
10
  let e = !1;
11
- return c(!0), (async () => {
11
+ return l(!0), (async () => {
12
12
  try {
13
13
  let t = await r();
14
14
  if (e) return;
15
- o(t);
15
+ s(t);
16
16
  } catch (t) {
17
17
  if (e) return;
18
- u(n(t));
18
+ d(n(t));
19
19
  } finally {
20
- e || c(!1);
20
+ e || l(!1);
21
21
  }
22
22
  })(), () => {
23
23
  e = !0;
24
24
  };
25
- }, [i, r]), {
26
- usage: a,
27
- isLoading: s,
28
- usageError: l
25
+ }, [
26
+ i,
27
+ r,
28
+ a
29
+ ]), {
30
+ usage: o,
31
+ isLoading: c,
32
+ usageError: u
29
33
  };
30
34
  };
31
35
  //#endregion
package/utils.d.ts CHANGED
@@ -345,20 +345,28 @@ export declare interface UsePromptsStateResult {
345
345
  }
346
346
 
347
347
  /**
348
- * Fetches usage stats via the provided `getUserUsage` function on mount.
348
+ * Fetches usage stats via the provided `getUserUsage` function on mount, and
349
+ * again whenever `refreshToken` changes.
349
350
  *
350
351
  * `enabled` (default `true`) lets callers behind a feature flag skip the fetch
351
352
  * entirely. The hook accepts the fetch function as a parameter so the caller
352
353
  * supplies an already-configured API client — the hook never constructs or
353
354
  * imports one itself.
355
+ *
356
+ * `refreshToken` (default `0`) is a caller-driven re-fetch trigger, subject to
357
+ * the same `enabled` gate. The hook owns no timer and reads no clock: the
358
+ * caller decides when to change the token. A previously resolved `usage` value
359
+ * is retained while a token-triggered re-fetch is in flight, so the consumer
360
+ * can keep rendering the last known figures and suppress a full-page loading
361
+ * state for a refresh.
354
362
  */
355
- export declare const useUsageData: (getUserUsage: () => Promise<UserLimitStatsResponseDto>, enabled?: boolean) => UseUsageDataResult;
363
+ export declare const useUsageData: (getUserUsage: () => Promise<UserLimitStatsResponseDto>, enabled?: boolean, refreshToken?: number) => UseUsageDataResult;
356
364
 
357
365
  /** Return shape of {@link useUsageData}. */
358
366
  export declare interface UseUsageDataResult {
359
- /** Rolling usage and rate-limit stats for every deployment the caller has used in the trailing 30 days, plus the caller's global cost budget. */
367
+ /** Calendar-period usage and rate-limit stats for every deployment the caller has used in the current UTC day, week, and month, plus the caller's global cost budget. Retained across a `refreshToken`-triggered re-fetch until the new response resolves. */
360
368
  usage: UserLimitStatsResponseDto | undefined;
361
- /** `true` while the fetch is in flight. */
369
+ /** `true` while a fetch is in flight, including a `refreshToken`-triggered re-fetch. */
362
370
  isLoading: boolean;
363
371
  /** Set when the `getUserUsage` call rejects. */
364
372
  usageError: Error | undefined;