@epam/ai-dial-chat-hooks 1.1.0-dev.479 → 1.1.0-dev.481
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 +12 -4
- package/package.json +15 -15
- package/usage/useUsageData/useUsageData.js +15 -11
- package/utils.d.ts +12 -4
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
|
-
/**
|
|
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
|
|
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.
|
|
4
|
+
"version": "1.1.0-dev.481",
|
|
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.
|
|
99
|
+
"@epam/ai-dial-chat-api-client": "1.1.0-dev.481",
|
|
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.
|
|
109
|
-
"@epam/ai-dial-attachment-input": "1.1.0-dev.
|
|
110
|
-
"@epam/ai-dial-builder-form": "1.1.0-dev.
|
|
111
|
-
"@epam/ai-dial-catalog": "1.1.0-dev.
|
|
112
|
-
"@epam/ai-dial-chat-overlay": "1.1.0-dev.
|
|
113
|
-
"@epam/ai-dial-chat-shared": "1.1.0-dev.
|
|
114
|
-
"@epam/ai-dial-mcp-apps": "1.1.0-dev.
|
|
115
|
-
"@epam/ai-dial-publish-panel": "1.1.0-dev.
|
|
116
|
-
"@epam/ai-dial-quotations": "1.1.0-dev.
|
|
108
|
+
"@epam/ai-dial-attachment-canvas": "1.1.0-dev.481",
|
|
109
|
+
"@epam/ai-dial-attachment-input": "1.1.0-dev.481",
|
|
110
|
+
"@epam/ai-dial-builder-form": "1.1.0-dev.481",
|
|
111
|
+
"@epam/ai-dial-catalog": "1.1.0-dev.481",
|
|
112
|
+
"@epam/ai-dial-chat-overlay": "1.1.0-dev.481",
|
|
113
|
+
"@epam/ai-dial-chat-shared": "1.1.0-dev.481",
|
|
114
|
+
"@epam/ai-dial-mcp-apps": "1.1.0-dev.481",
|
|
115
|
+
"@epam/ai-dial-publish-panel": "1.1.0-dev.481",
|
|
116
|
+
"@epam/ai-dial-quotations": "1.1.0-dev.481",
|
|
117
117
|
"@epam/ai-dial-react-file-manager": "^0.2.0",
|
|
118
|
-
"@epam/ai-dial-scheduled-tasks": "1.1.0-dev.
|
|
119
|
-
"@epam/ai-dial-share": "1.1.0-dev.
|
|
120
|
-
"@epam/ai-dial-skill-editor": "1.1.0-dev.
|
|
121
|
-
"@epam/ai-dial-source-panel": "1.1.0-dev.
|
|
118
|
+
"@epam/ai-dial-scheduled-tasks": "1.1.0-dev.481",
|
|
119
|
+
"@epam/ai-dial-share": "1.1.0-dev.481",
|
|
120
|
+
"@epam/ai-dial-skill-editor": "1.1.0-dev.481",
|
|
121
|
+
"@epam/ai-dial-source-panel": "1.1.0-dev.481",
|
|
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 [
|
|
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
|
-
|
|
7
|
+
l(!1);
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
let e = !1;
|
|
11
|
-
return
|
|
11
|
+
return l(!0), (async () => {
|
|
12
12
|
try {
|
|
13
13
|
let t = await r();
|
|
14
14
|
if (e) return;
|
|
15
|
-
|
|
15
|
+
s(t);
|
|
16
16
|
} catch (t) {
|
|
17
17
|
if (e) return;
|
|
18
|
-
|
|
18
|
+
d(n(t));
|
|
19
19
|
} finally {
|
|
20
|
-
e ||
|
|
20
|
+
e || l(!1);
|
|
21
21
|
}
|
|
22
22
|
})(), () => {
|
|
23
23
|
e = !0;
|
|
24
24
|
};
|
|
25
|
-
}, [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
/**
|
|
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
|
|
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;
|