@epam/ai-dial-chat-hooks 1.1.7 → 1.1.8

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.
@@ -1,5 +1,5 @@
1
1
  //#region src/catalog/catalog-derivations.ts
2
- var e = (e, t) => e.filter((e) => t.has(e.type)), t = (e, t) => t ? e.filter((e) => !e.isMyApp) : [...e], n = (e) => e.filter((e) => e.isUserFavorite), r = (e, t) => {
2
+ var e = (e, t) => e.filter((e) => t.has(e.type)), t = (e, t) => t ? e.filter((e) => !e.isMyApp) : [...e], n = (e) => e.filter((e) => e.isUserFavorite && !e.isHidden), r = (e, t) => {
3
3
  let n = new Set(e.map((e) => e.type));
4
4
  return t.filter((e) => n.has(e));
5
5
  }, i = (e, t) => {
@@ -1,6 +1,12 @@
1
1
  //#region src/catalog/deployment-id.ts
2
- var e = (e) => e.split("/").map((e) => encodeURIComponent(e)).join("/"), t = (e, t) => {
2
+ var e = (e) => e.split("/").map((e) => encodeURIComponent(e)).join("/"), t = (e) => e.split("/").map((e) => {
3
+ try {
4
+ return decodeURIComponent(e);
5
+ } catch {
6
+ return e;
7
+ }
8
+ }).join("/"), n = (n) => e(t(n)), r = (e, t) => {
3
9
  if (t) return e.find((e) => e.id === t) ?? e.find((e) => e.reference === t);
4
10
  };
5
11
  //#endregion
6
- export { e as encodeDeploymentId, t as findDeploymentByIdOrReference };
12
+ export { t as decodeDeploymentId, e as encodeDeploymentId, r as findDeploymentByIdOrReference, n as normalizeDeploymentId };
@@ -1,14 +1,86 @@
1
+ import { formatCost as e } from "@epam/ai-dial-chat-shared";
2
+ import { CatalogLimitStatus as t } from "@epam/ai-dial-catalog";
1
3
  //#region src/catalog/map-deployment-limits-to-input.ts
2
- var e = (e) => {
3
- let t = e?.monthTokenStats;
4
- if (t == null || !Number.isFinite(t.total) || !Number.isFinite(t.used) || t.total <= 0 || t.total >= 2 ** 53 - 1) return;
5
- let n = Math.max(0, t.used);
4
+ var n = [
5
+ {
6
+ key: "dayTokenStats",
7
+ labelField: "periodDay"
8
+ },
9
+ {
10
+ key: "weekTokenStats",
11
+ labelField: "periodWeek"
12
+ },
13
+ {
14
+ key: "monthTokenStats",
15
+ labelField: "periodMonth"
16
+ }
17
+ ], r = [
18
+ {
19
+ key: "dayCostStats",
20
+ labelField: "periodDay"
21
+ },
22
+ {
23
+ key: "weekCostStats",
24
+ labelField: "periodWeek"
25
+ },
26
+ {
27
+ key: "monthCostStats",
28
+ labelField: "periodMonth"
29
+ }
30
+ ], i = 2 ** 53 - 1, a = .75, o = [1e6, 1e3], s = new Intl.NumberFormat(void 0, {
31
+ notation: "compact",
32
+ maximumFractionDigits: 1
33
+ }), c = new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }), l = (e) => {
34
+ let t = o.find((t) => Math.abs(e) >= t);
35
+ return t == null ? e : Math.trunc(e / t * 10) / 10 * t;
36
+ }, u = (e) => e != null && Number.isFinite(e.total) && Number.isFinite(e.used) && e.total > 0, d = (e) => e >= i, f = (e, t) => {
37
+ let n = t?.(e.resetsAt);
38
+ return n ? {
39
+ resetLabel: n.label,
40
+ resetIsoValue: n.isoValue,
41
+ resetAriaLabel: n.ariaLabel
42
+ } : {};
43
+ }, p = (e, t, n, r, i) => {
44
+ let a = Math.max(0, e.used), o = e.total, s = r.format(a), c = r.format(o);
6
45
  return {
7
- used: n,
8
- total: t.total,
9
- remaining: Math.max(0, t.total - n),
10
- usedPercent: Math.min(100, Math.round(n / t.total * 100))
46
+ label: t,
47
+ used: a,
48
+ total: o,
49
+ ...f(e, i),
50
+ usedLabel: s,
51
+ totalLabel: c,
52
+ valueLabel: n.formatValueLabel(s, c),
53
+ ariaLabel: n.formatProgressAriaLabel({
54
+ label: t,
55
+ used: r.formatFull(a),
56
+ total: r.formatFull(o)
57
+ })
11
58
  };
59
+ }, m = (e) => d(e.total) ? 0 : Math.max(e.used, 0) / e.total, h = (e) => m(e) >= a, g = (e) => e.reduce((e, n) => {
60
+ let r = m(n);
61
+ return r >= 1 ? t.LimitReached : r >= a && e !== t.LimitReached ? t.RunningLow : e;
62
+ }, void 0), _ = (e, t, n, r, i, a, o) => {
63
+ let s = t.flatMap((t) => {
64
+ let n = e[t.key];
65
+ return !u(n) || !h(n) ? [] : (o.push(n), [p(n, r[t.labelField], r, i, a)]);
66
+ });
67
+ return s.length > 0 ? {
68
+ label: n,
69
+ rows: s
70
+ } : void 0;
71
+ }, v = (t, i, a) => {
72
+ if (t == null) return;
73
+ let o = [], u = [_(t, n, i.tokenGroup, i, {
74
+ format: (e) => s.format(l(e)),
75
+ formatFull: (e) => c.format(e)
76
+ }, a, o), _(t, r, i.costGroup, i, {
77
+ format: e,
78
+ formatFull: e
79
+ }, a, o)].filter((e) => e != null);
80
+ return u.length > 0 ? {
81
+ groups: u,
82
+ status: g(o)
83
+ } : void 0;
12
84
  };
13
85
  //#endregion
14
- export { e as mapDeploymentLimitsToInput };
86
+ export { v as mapDeploymentLimitsToInput };
package/catalog.d.ts CHANGED
@@ -244,6 +244,28 @@ export declare enum CatalogPrimaryActionType {
244
244
  */
245
245
  export declare type CatalogPublishEntityType = 'model' | 'toolset' | 'application' | 'prompt' | 'skill';
246
246
 
247
+ /** Labels and formatter callbacks for the conversation-input limits mapping utility. */
248
+ export declare interface ConversationInputLimitsLabels {
249
+ /** Heading of the group listing the selected deployment's token limits. */
250
+ tokenGroup: string;
251
+ /** Heading of the group listing the caller's cost budget and spend against it. */
252
+ costGroup: string;
253
+ /** Label for the current-UTC-day row, used by both groups. */
254
+ periodDay: string;
255
+ /** Label for the current-UTC-week row, used by both groups. */
256
+ periodWeek: string;
257
+ /** Label for the current-UTC-month row, used by both groups. */
258
+ periodMonth: string;
259
+ /** Formats the combined used/total display value for a capped row. */
260
+ formatValueLabel: (used: string, total: string) => string;
261
+ /** Formats the ARIA label for a capped progress row. */
262
+ formatProgressAriaLabel: (params: {
263
+ label: string;
264
+ used: string;
265
+ total: string;
266
+ }) => string;
267
+ }
268
+
247
269
  /**
248
270
  * Wraps the generated `PublishApi` in the positional-argument surface the
249
271
  * catalog and conversation publish flows call, so each host app re-exports one
@@ -252,6 +274,15 @@ export declare type CatalogPublishEntityType = 'model' | 'toolset' | 'applicatio
252
274
  */
253
275
  export declare const createPublishApiClient: (publishApi: PublishApi) => PublishApiClient;
254
276
 
277
+ /**
278
+ * Inverse of `encodeDeploymentId` — decodes each `/`-separated segment back
279
+ * to its raw, human-readable form. A segment that isn't valid
280
+ * percent-encoding is passed through unchanged rather than throwing, since
281
+ * this decodes externally-sourced ids (the settings iframe's postMessage
282
+ * protocol).
283
+ */
284
+ export declare const decodeDeploymentId: (id: string) => string;
285
+
255
286
  /** Translated folder-path labels for the Personal/Shared/Public deployment groupings. */
256
287
  export declare interface DeploymentFolderLabels {
257
288
  personal: string;
@@ -301,7 +332,7 @@ export declare interface DeploymentLimitsLabels {
301
332
  export declare const deriveAvailableTabIds: <T extends CatalogEntityType>(items: readonly CatalogItem[], tabOrder: readonly T[]) => T[];
302
333
 
303
334
  /**
304
- * Returns items marked as a user favorite, in original order.
335
+ * Returns items marked as a user favorite that are not hidden, in original order.
305
336
  */
306
337
  export declare const deriveFavoriteItems: (items: readonly CatalogItem[]) => CatalogItem[];
307
338
 
@@ -366,6 +397,9 @@ export declare const filterHiddenOwnedItems: (items: readonly CatalogItem[], hid
366
397
  */
367
398
  export declare const findDeploymentByIdOrReference: (deployments: DeploymentItemDto[], idOrReference: string | null | undefined) => DeploymentItemDto | undefined;
368
399
 
400
+ /** Formats a raw `resetsAt` into display strings, or returns `undefined` when it cannot be formatted. */
401
+ declare type FormatResetTime = (resetsAt: string | undefined) => ResetTimeDisplay | undefined;
402
+
369
403
  /**
370
404
  * The publish folder a public catalog entity id sits in: the segments between
371
405
  * the `public` bucket and the entity name, decoded to the plain text the
@@ -403,8 +437,8 @@ export declare const mapDeploymentDetailsDtoToEntityDetails: (dto: DeploymentDet
403
437
  /** Maps a deployment limits DTO to display-ready catalog limits, or `undefined` when no qualifying stats exist. */
404
438
  export declare const mapDeploymentLimitsDtoToCatalogLimits: (dto: DeploymentLimitsResponseDto | undefined, labels: DeploymentLimitsLabels) => CatalogItemLimits | undefined;
405
439
 
406
- /** Maps the monthly deployment token limit to a display-ready value. */
407
- export declare const mapDeploymentLimitsToInput: (dto: DeploymentLimitsResponseDto | undefined) => MonthlyUsageLimit | undefined;
440
+ /** Maps a deployment's day, week, and month token limits and the caller's cost budget to display-ready rows, or `undefined` when none qualify. */
441
+ export declare const mapDeploymentLimitsToInput: (dto: DeploymentLimitsResponseDto | undefined, labels: ConversationInputLimitsLabels, formatResetTime?: FormatResetTime) => CatalogItemLimits | undefined;
408
442
 
409
443
  /** Maps a deployment listing row into the catalog UI's `CatalogItem` shape. */
410
444
  export declare const mapDeploymentToCatalogItem: (deployment: DeploymentItemDto, { favoriteIds, entityDetails, folderLabels, editableSchemaIds, isCustomAppsEditable, activeLocale, primaryLocale, resolveIconUrl, }: MapDeploymentToCatalogItemOptions) => CatalogItem;
@@ -586,17 +620,19 @@ export declare interface ModelSpecification {
586
620
  createdAt?: number;
587
621
  }
588
622
 
589
- /** Normalized monthly token usage consumed by the conversation input control. */
590
- export declare interface MonthlyUsageLimit {
591
- /** Normalized used-token count. */
592
- used: number;
593
- /** Configured monthly token limit. */
594
- total: number;
595
- /** Remaining monthly tokens, clamped to zero. */
596
- remaining: number;
597
- /** Monthly utilization percentage, clamped to 0–100. */
598
- usedPercent: number;
599
- }
623
+ /**
624
+ * Encodes a deployment/application id to its single-encoded form regardless
625
+ * of whether the value it received was already percent-encoded or the raw,
626
+ * human-readable form — decoding first then re-encoding once is idempotent
627
+ * either way, since `decodeDeploymentId` on a raw (unencoded) id is a no-op.
628
+ * Use this instead of `encodeDeploymentId` at a boundary that cannot
629
+ * guarantee which form it receives, such as a `postMessage` payload from the
630
+ * settings iframe: calling `encodeDeploymentId` directly on a value the
631
+ * sender already encoded escapes the existing `%` characters a second time
632
+ * (`%20` becomes `%2520`), which the backend only ever undoes once and so
633
+ * 404s on.
634
+ */
635
+ export declare const normalizeDeploymentId: (id: string) => string;
600
636
 
601
637
  /** A skill resource URL split into the bucket and the path within it. */
602
638
  export declare interface ParsedSkillResourceUrl {
@@ -690,6 +726,23 @@ export declare const readSkillManifest: (response: Response) => Promise<string |
690
726
  */
691
727
  export declare const reconcileFilterTopics: (persistedTopics: ReadonlySet<string>, items: readonly CatalogItem[]) => Set<string>;
692
728
 
729
+ /**
730
+ * One reset time, already parsed and formatted by the host. Declared
731
+ * structurally here so this library never imports an application type; the
732
+ * host passes a value that satisfies this shape (e.g. `apps/chat`'s own
733
+ * `ResetTimeDisplay`).
734
+ */
735
+ declare interface ResetTimeDisplay {
736
+ /** Exclusive end of the period as an epoch ms value, for the host's boundary scheduling. */
737
+ resetsAtMs: number;
738
+ /** Machine-readable instant for a `<time dateTime>` attribute. */
739
+ isoValue: string;
740
+ /** Visible reset line. */
741
+ label: string;
742
+ /** Accessible expansion of the reset line. */
743
+ ariaLabel: string;
744
+ }
745
+
693
746
  /**
694
747
  * Resolves the primary action for a catalog item.
695
748
  *
package/catalog.js CHANGED
@@ -1,24 +1,24 @@
1
1
  import { createPublishApiClient as e, toPublishRuleDto as t } from "./catalog/create-publish-api.js";
2
2
  import { buildChatCompletionsUrl as n, buildDeploymentConnectApi as r, buildResponsesUrl as i } from "./catalog/deployment-endpoint-url.js";
3
- import { encodeDeploymentId as a, findDeploymentByIdOrReference as o } from "./catalog/deployment-id.js";
4
- import { AuthenticationType as s } from "./catalog/entity-details.js";
5
- import { mapDeploymentLimitsDtoToCatalogLimits as c } from "./catalog/map-deployment-limits-to-catalog.js";
6
- import { mapDeploymentLimitsToInput as l } from "./catalog/map-deployment-limits-to-input.js";
7
- import { mapDeploymentDetailsDtoToEntityDetails as u, mapEntityDetailsToCatalogDetails as d, mapToolsetCredentials as f } from "./catalog/map-entity-details-to-catalog.js";
8
- import { mapDeploymentToCatalogItem as p, mapDeploymentToolsetCredentials as m, mapToolsetToCatalogItem as h, resolveDeploymentFolder as g } from "./catalog/map-deployment-to-catalog-item.js";
9
- import { buildPromptOverview as _, isOrganisationPromptItem as v, mapPromptToCatalogItem as y } from "./catalog/map-prompt-to-catalog-item.js";
10
- import { PUBLIC_SKILL_BUCKET as b, SKILL_LISTING_MAX_PAGES as x, SKILL_LISTING_PAGE_SIZE as S, SKILL_MANIFEST_MAX_BYTES as C, SkillSource as w, parseSkillResourceUrl as T } from "./skill/skill-types.js";
11
- import { buildSkillContentTree as E, buildSkillOverview as D, mapSkillToCatalogItem as O, readSkillFileBytes as k, readSkillFilePreviewBytes as A, readSkillManifest as j, resolveSkillFileDownloadPath as M, resolveSkillManifestFileId as N } from "./catalog/map-skill-to-catalog-item.js";
12
- import { McpResourceKind as P, buildApplicationMcpUrl as F, buildConnectApi as I, buildToolsetMcpUrl as L, resolveMcpResourceKind as R } from "./catalog/mcp-endpoint-url.js";
13
- import { getPublicCatalogEntityFolderPath as z, isPublicCatalogEntityId as B, mapPublishConversationResultDto as V, mapPublishHistoryEntryDto as H, toPublishEntityType as U } from "./catalog/publish.js";
14
- import { deriveAvailableTabIds as W, deriveFavoriteItems as G, filterCatalogItemsBySelector as K, filterHiddenOwnedItems as q, reconcileFilterTopics as J } from "./catalog/catalog-derivations.js";
15
- import { CatalogPrimaryActionType as Y, resolveCatalogPrimaryAction as X } from "./catalog/catalog-primary-action.js";
16
- import { useCatalogEditNavigation as Z } from "./catalog/useCatalogEditNavigation/useCatalogEditNavigation.js";
17
- import { useSkillItemDetails as Q } from "./catalog/useSkillItemDetails.js";
18
- import { useCatalogItemDetails as $ } from "./catalog/useCatalogItemDetails.js";
19
- import { useCatalogToolsetCredentials as ee } from "./catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js";
20
- import { useSkillDetailsPanelData as te } from "./catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js";
21
- import { FavoriteEntityType as ne, useFavoriteEntitiesState as re } from "./catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js";
22
- import { usePublishFolders as ie } from "./catalog/usePublishFolders/usePublishFolders.js";
23
- import { SkillPreviewErrorKind as ae, useSkillFilePreview as oe } from "./skill/useSkillFilePreview.js";
24
- export { s as AuthenticationType, Y as CatalogPrimaryActionType, ne as FavoriteEntityType, P as McpResourceKind, b as PUBLIC_SKILL_BUCKET, x as SKILL_LISTING_MAX_PAGES, S as SKILL_LISTING_PAGE_SIZE, C as SKILL_MANIFEST_MAX_BYTES, ae as SkillPreviewErrorKind, w as SkillSource, F as buildApplicationMcpUrl, n as buildChatCompletionsUrl, I as buildConnectApi, r as buildDeploymentConnectApi, _ as buildPromptOverview, i as buildResponsesUrl, E as buildSkillContentTree, D as buildSkillOverview, L as buildToolsetMcpUrl, e as createPublishApiClient, W as deriveAvailableTabIds, G as deriveFavoriteItems, a as encodeDeploymentId, K as filterCatalogItemsBySelector, q as filterHiddenOwnedItems, o as findDeploymentByIdOrReference, z as getPublicCatalogEntityFolderPath, v as isOrganisationPromptItem, B as isPublicCatalogEntityId, u as mapDeploymentDetailsDtoToEntityDetails, c as mapDeploymentLimitsDtoToCatalogLimits, l as mapDeploymentLimitsToInput, p as mapDeploymentToCatalogItem, m as mapDeploymentToolsetCredentials, d as mapEntityDetailsToCatalogDetails, y as mapPromptToCatalogItem, V as mapPublishConversationResultDto, H as mapPublishHistoryEntryDto, O as mapSkillToCatalogItem, f as mapToolsetCredentials, h as mapToolsetToCatalogItem, T as parseSkillResourceUrl, k as readSkillFileBytes, A as readSkillFilePreviewBytes, j as readSkillManifest, J as reconcileFilterTopics, X as resolveCatalogPrimaryAction, g as resolveDeploymentFolder, R as resolveMcpResourceKind, M as resolveSkillFileDownloadPath, N as resolveSkillManifestFileId, U as toPublishEntityType, t as toPublishRuleDto, Z as useCatalogEditNavigation, $ as useCatalogItemDetails, ee as useCatalogToolsetCredentials, re as useFavoriteEntitiesState, ie as usePublishFolders, te as useSkillDetailsPanelData, oe as useSkillFilePreview, Q as useSkillItemDetails };
3
+ import { decodeDeploymentId as a, encodeDeploymentId as o, findDeploymentByIdOrReference as s, normalizeDeploymentId as c } from "./catalog/deployment-id.js";
4
+ import { AuthenticationType as l } from "./catalog/entity-details.js";
5
+ import { mapDeploymentLimitsDtoToCatalogLimits as u } from "./catalog/map-deployment-limits-to-catalog.js";
6
+ import { mapDeploymentLimitsToInput as d } from "./catalog/map-deployment-limits-to-input.js";
7
+ import { mapDeploymentDetailsDtoToEntityDetails as f, mapEntityDetailsToCatalogDetails as p, mapToolsetCredentials as m } from "./catalog/map-entity-details-to-catalog.js";
8
+ import { mapDeploymentToCatalogItem as h, mapDeploymentToolsetCredentials as g, mapToolsetToCatalogItem as _, resolveDeploymentFolder as v } from "./catalog/map-deployment-to-catalog-item.js";
9
+ import { buildPromptOverview as y, isOrganisationPromptItem as b, mapPromptToCatalogItem as x } from "./catalog/map-prompt-to-catalog-item.js";
10
+ import { PUBLIC_SKILL_BUCKET as S, SKILL_LISTING_MAX_PAGES as C, SKILL_LISTING_PAGE_SIZE as w, SKILL_MANIFEST_MAX_BYTES as T, SkillSource as E, parseSkillResourceUrl as D } from "./skill/skill-types.js";
11
+ import { buildSkillContentTree as O, buildSkillOverview as k, mapSkillToCatalogItem as A, readSkillFileBytes as j, readSkillFilePreviewBytes as M, readSkillManifest as N, resolveSkillFileDownloadPath as P, resolveSkillManifestFileId as F } from "./catalog/map-skill-to-catalog-item.js";
12
+ import { McpResourceKind as I, buildApplicationMcpUrl as L, buildConnectApi as R, buildToolsetMcpUrl as z, resolveMcpResourceKind as B } from "./catalog/mcp-endpoint-url.js";
13
+ import { getPublicCatalogEntityFolderPath as V, isPublicCatalogEntityId as H, mapPublishConversationResultDto as U, mapPublishHistoryEntryDto as W, toPublishEntityType as G } from "./catalog/publish.js";
14
+ import { deriveAvailableTabIds as K, deriveFavoriteItems as q, filterCatalogItemsBySelector as J, filterHiddenOwnedItems as Y, reconcileFilterTopics as X } from "./catalog/catalog-derivations.js";
15
+ import { CatalogPrimaryActionType as Z, resolveCatalogPrimaryAction as Q } from "./catalog/catalog-primary-action.js";
16
+ import { useCatalogEditNavigation as $ } from "./catalog/useCatalogEditNavigation/useCatalogEditNavigation.js";
17
+ import { useSkillItemDetails as ee } from "./catalog/useSkillItemDetails.js";
18
+ import { useCatalogItemDetails as te } from "./catalog/useCatalogItemDetails.js";
19
+ import { useCatalogToolsetCredentials as ne } from "./catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js";
20
+ import { useSkillDetailsPanelData as re } from "./catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js";
21
+ import { FavoriteEntityType as ie, useFavoriteEntitiesState as ae } from "./catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js";
22
+ import { usePublishFolders as oe } from "./catalog/usePublishFolders/usePublishFolders.js";
23
+ import { SkillPreviewErrorKind as se, useSkillFilePreview as ce } from "./skill/useSkillFilePreview.js";
24
+ export { l as AuthenticationType, Z as CatalogPrimaryActionType, ie as FavoriteEntityType, I as McpResourceKind, S as PUBLIC_SKILL_BUCKET, C as SKILL_LISTING_MAX_PAGES, w as SKILL_LISTING_PAGE_SIZE, T as SKILL_MANIFEST_MAX_BYTES, se as SkillPreviewErrorKind, E as SkillSource, L as buildApplicationMcpUrl, n as buildChatCompletionsUrl, R as buildConnectApi, r as buildDeploymentConnectApi, y as buildPromptOverview, i as buildResponsesUrl, O as buildSkillContentTree, k as buildSkillOverview, z as buildToolsetMcpUrl, e as createPublishApiClient, a as decodeDeploymentId, K as deriveAvailableTabIds, q as deriveFavoriteItems, o as encodeDeploymentId, J as filterCatalogItemsBySelector, Y as filterHiddenOwnedItems, s as findDeploymentByIdOrReference, V as getPublicCatalogEntityFolderPath, b as isOrganisationPromptItem, H as isPublicCatalogEntityId, f as mapDeploymentDetailsDtoToEntityDetails, u as mapDeploymentLimitsDtoToCatalogLimits, d as mapDeploymentLimitsToInput, h as mapDeploymentToCatalogItem, g as mapDeploymentToolsetCredentials, p as mapEntityDetailsToCatalogDetails, x as mapPromptToCatalogItem, U as mapPublishConversationResultDto, W as mapPublishHistoryEntryDto, A as mapSkillToCatalogItem, m as mapToolsetCredentials, _ as mapToolsetToCatalogItem, c as normalizeDeploymentId, D as parseSkillResourceUrl, j as readSkillFileBytes, M as readSkillFilePreviewBytes, N as readSkillManifest, X as reconcileFilterTopics, Q as resolveCatalogPrimaryAction, v as resolveDeploymentFolder, B as resolveMcpResourceKind, P as resolveSkillFileDownloadPath, F as resolveSkillManifestFileId, G as toPublishEntityType, t as toPublishRuleDto, $ as useCatalogEditNavigation, te as useCatalogItemDetails, ne as useCatalogToolsetCredentials, ae as useFavoriteEntitiesState, oe as usePublishFolders, re as useSkillDetailsPanelData, ce as useSkillFilePreview, ee as useSkillItemDetails };
package/index.d.ts CHANGED
@@ -84,6 +84,8 @@ import { MessageAttachment } from '@epam/ai-dial-chat-shared';
84
84
  import { MessageCustomContent } from '@epam/ai-dial-chat-shared';
85
85
  import { MessageRating } from '@epam/ai-dial-chat-shared';
86
86
  import { Middleware } from '@epam/ai-dial-chat-api-client';
87
+ import { ModelLimitPeriodStatuses } from '@epam/ai-dial-usage-dashboard';
88
+ import { ModelLimitRow } from '@epam/ai-dial-usage-dashboard';
87
89
  import { MoveFilesResponseDto } from '@epam/ai-dial-chat-api-client';
88
90
  import { MoveItemDto } from '@epam/ai-dial-chat-api-client';
89
91
  import { MutableRefObject } from 'react';
@@ -144,6 +146,7 @@ import { UnpublishResultDto } from '@epam/ai-dial-chat-api-client';
144
146
  import { UpdateScheduledTaskBodyDto } from '@epam/ai-dial-chat-api-client';
145
147
  import { UploadArchiveResponseDto } from '@epam/ai-dial-chat-api-client';
146
148
  import { UploadedAttachmentResult } from '@epam/ai-dial-chat-shared';
149
+ import { UsageLimitCardData } from '@epam/ai-dial-usage-dashboard';
147
150
  import { useGridEditingScroll } from '@epam/ai-dial-chat-shared';
148
151
  import { UseGridEditingScrollOptions } from '@epam/ai-dial-chat-shared';
149
152
  import { UseGridEditingScrollResult } from '@epam/ai-dial-chat-shared';
@@ -769,6 +772,28 @@ export declare interface ConversationGenerationLifecycle {
769
772
  completeGeneration: (path: string, generationId: string) => void;
770
773
  }
771
774
 
775
+ /** Labels and formatter callbacks for the conversation-input limits mapping utility. */
776
+ export declare interface ConversationInputLimitsLabels {
777
+ /** Heading of the group listing the selected deployment's token limits. */
778
+ tokenGroup: string;
779
+ /** Heading of the group listing the caller's cost budget and spend against it. */
780
+ costGroup: string;
781
+ /** Label for the current-UTC-day row, used by both groups. */
782
+ periodDay: string;
783
+ /** Label for the current-UTC-week row, used by both groups. */
784
+ periodWeek: string;
785
+ /** Label for the current-UTC-month row, used by both groups. */
786
+ periodMonth: string;
787
+ /** Formats the combined used/total display value for a capped row. */
788
+ formatValueLabel: (used: string, total: string) => string;
789
+ /** Formats the ARIA label for a capped progress row. */
790
+ formatProgressAriaLabel: (params: {
791
+ label: string;
792
+ used: string;
793
+ total: string;
794
+ }) => string;
795
+ }
796
+
772
797
  /** Stable reverse-lookup maps returned by `useConversationLookupMaps`. */
773
798
  export declare interface ConversationLookupMaps {
774
799
  /** Returns the raw context id for a panel-space conversation id, or `undefined` when not found. */
@@ -1036,6 +1061,15 @@ export declare type CsrfRefreshOutcome = {
1036
1061
 
1037
1062
  export declare const DATE_OPTIONS: Intl.DateTimeFormatOptions;
1038
1063
 
1064
+ /**
1065
+ * Inverse of `encodeDeploymentId` — decodes each `/`-separated segment back
1066
+ * to its raw, human-readable form. A segment that isn't valid
1067
+ * percent-encoding is passed through unchanged rather than throwing, since
1068
+ * this decodes externally-sourced ids (the settings iframe's postMessage
1069
+ * protocol).
1070
+ */
1071
+ export declare const decodeDeploymentId: (id: string) => string;
1072
+
1039
1073
  /**
1040
1074
  * Inverse of `encodeToolsetId` — decodes each `/`-separated segment back to
1041
1075
  * its raw, human-readable form. A segment that isn't valid percent-encoding
@@ -1141,7 +1175,7 @@ export declare const deriveAvailableTabIds: <T extends CatalogEntityType>(items:
1141
1175
  export declare const deriveConversationRowActionState: (item: Pick<ConversationListItemDto, "sharedWithMe" | "publishedWithMe" | "isReadonly">, publishHistory: PublishHistoryEntry[] | undefined, recipients: RecipientsCountEntry) => ConversationRowActionState;
1142
1176
 
1143
1177
  /**
1144
- * Returns items marked as a user favorite, in original order.
1178
+ * Returns items marked as a user favorite that are not hidden, in original order.
1145
1179
  */
1146
1180
  export declare const deriveFavoriteItems: (items: readonly CatalogItem[]) => CatalogItem[];
1147
1181
 
@@ -1656,6 +1690,9 @@ export declare const formatOperationFolderName: (destinationFolder: string, root
1656
1690
  */
1657
1691
  export declare const formatQuotedNameList: (names: string[]) => string;
1658
1692
 
1693
+ /** Formats a raw `resetsAt` into display strings, or returns `undefined` when it cannot be formatted. */
1694
+ export declare type FormatResetTime = (resetsAt: string | undefined) => ResetTimeDisplay | undefined;
1695
+
1659
1696
  /**
1660
1697
  * Reported through `onError` when the backend rejects a completion because
1661
1698
  * another generation is already active on the same conversation — what a
@@ -2127,8 +2164,8 @@ export declare const mapDeploymentDetailsDtoToEntityDetails: (dto: DeploymentDet
2127
2164
  /** Maps a deployment limits DTO to display-ready catalog limits, or `undefined` when no qualifying stats exist. */
2128
2165
  export declare const mapDeploymentLimitsDtoToCatalogLimits: (dto: DeploymentLimitsResponseDto | undefined, labels: DeploymentLimitsLabels) => CatalogItemLimits | undefined;
2129
2166
 
2130
- /** Maps the monthly deployment token limit to a display-ready value. */
2131
- export declare const mapDeploymentLimitsToInput: (dto: DeploymentLimitsResponseDto | undefined) => MonthlyUsageLimit | undefined;
2167
+ /** Maps a deployment's day, week, and month token limits and the caller's cost budget to display-ready rows, or `undefined` when none qualify. */
2168
+ export declare const mapDeploymentLimitsToInput: (dto: DeploymentLimitsResponseDto | undefined, labels: ConversationInputLimitsLabels, formatResetTime?: FormatResetTime) => CatalogItemLimits | undefined;
2132
2169
 
2133
2170
  /** Maps a deployment listing row into the catalog UI's `CatalogItem` shape. */
2134
2171
  export declare const mapDeploymentToCatalogItem: (deployment: DeploymentItemDto, { favoriteIds, entityDetails, folderLabels, editableSchemaIds, isCustomAppsEditable, activeLocale, primaryLocale, resolveIconUrl, }: MapDeploymentToCatalogItemOptions) => CatalogItem;
@@ -2200,6 +2237,13 @@ export declare const mapFormValuesToCreateBody: (values: ScheduledTaskCreateForm
2200
2237
  */
2201
2238
  export declare const mapFormValuesToUpdateBody: (values: ScheduledTaskCreateFormValues) => UpdateScheduledTaskBodyDto;
2202
2239
 
2240
+ /**
2241
+ * Maps the same top-level Cost budgets used by the aggregate cards into table-header state.
2242
+ *
2243
+ * @param formatResetTime - Formats each period's top-level `resetsAt` into the header's reset trio. Omit it to produce statuses with no reset fields.
2244
+ */
2245
+ export declare const mapOverallCostLimitsToPeriodStatuses: (usage: UserLimitStatsResponseDto | undefined, activeLocale: string, t: Translate_2, formatResetTime?: FormatResetTime) => ModelLimitPeriodStatuses;
2246
+
2203
2247
  /**
2204
2248
  * Maps a prompt DTO into a catalog item.
2205
2249
  *
@@ -2282,6 +2326,25 @@ export declare interface MapToolsetToCatalogItemOptions {
2282
2326
  resolveIconUrl: (iconUrl: string | undefined) => string | undefined;
2283
2327
  }
2284
2328
 
2329
+ /**
2330
+ * Maps a `UserLimitStatsResponseDto` into `UsageLimitCardGroup`'s `cards` prop,
2331
+ * in Today / This week / This month order. A period is omitted entirely when
2332
+ * the response carries no usable stat for it. Each card's reset trio comes from
2333
+ * `formatResetTime`, and is absent when that callback returns `undefined`.
2334
+ */
2335
+ export declare const mapUsageDataToDashboard: (usage: UserLimitStatsResponseDto | undefined, t: Translate, formatResetTime: FormatResetTime) => UsageLimitCardData[];
2336
+
2337
+ /**
2338
+ * Maps `usage.deployments` into `ModelLimitsSection`'s `rows` prop, joined with model or application
2339
+ * identity from `deploymentItems`. Rows are included only when any displayed period stat has nonzero
2340
+ * usage (Cost stats only, for an application). Order follows `Object.keys(deployments)` —
2341
+ * `deploymentItems` is enrichment-only.
2342
+ *
2343
+ * @param resolveIconUrl - Resolves a deployment's raw `iconUrl` to the URL the avatar should load.
2344
+ * @param resolveDisplayName - Resolves a localized-text map or plain string to the display name for `activeLocale`.
2345
+ */
2346
+ export declare const mapUserUsageToModelLimits: (usage: UserLimitStatsResponseDto | undefined, deploymentItems: DeploymentItemDto[], activeLocale: string, t: Translate_2, resolveIconUrl: ResolveIconUrl, resolveDisplayName: ResolveDisplayName) => ModelLimitRow[];
2347
+
2285
2348
  /** Content payload for Markdown file attachments. */
2286
2349
  declare interface MarkdownCanvasContent {
2287
2350
  /** Discriminates the content type to select the correct renderer. */
@@ -2519,18 +2582,6 @@ export declare interface ModelSpecification {
2519
2582
  createdAt?: number;
2520
2583
  }
2521
2584
 
2522
- /** Normalized monthly token usage consumed by the conversation input control. */
2523
- export declare interface MonthlyUsageLimit {
2524
- /** Normalized used-token count. */
2525
- used: number;
2526
- /** Configured monthly token limit. */
2527
- total: number;
2528
- /** Remaining monthly tokens, clamped to zero. */
2529
- remaining: number;
2530
- /** Monthly utilization percentage, clamped to 0–100. */
2531
- usedPercent: number;
2532
- }
2533
-
2534
2585
  /** Returns a skill relative path's final segment (its display name in the file tree). */
2535
2586
  export declare const nameFromPath: (path: string) => string;
2536
2587
 
@@ -2542,6 +2593,20 @@ export declare const nameFromPath: (path: string) => string;
2542
2593
  */
2543
2594
  export declare const navigateToolsetOAuthPopup: (popup: Window, auth: ToolsetOAuthSettings, toolsetId: string, callbackPath: string, credentialsLevel?: ToolsetCredentialsLevel, resourceKind?: OAuthResourceKind, offlineUsageConsent?: boolean) => ToolsetOAuthInitiationResult;
2544
2595
 
2596
+ /**
2597
+ * Encodes a deployment/application id to its single-encoded form regardless
2598
+ * of whether the value it received was already percent-encoded or the raw,
2599
+ * human-readable form — decoding first then re-encoding once is idempotent
2600
+ * either way, since `decodeDeploymentId` on a raw (unencoded) id is a no-op.
2601
+ * Use this instead of `encodeDeploymentId` at a boundary that cannot
2602
+ * guarantee which form it receives, such as a `postMessage` payload from the
2603
+ * settings iframe: calling `encodeDeploymentId` directly on a value the
2604
+ * sender already encoded escapes the existing `%` characters a second time
2605
+ * (`%20` becomes `%2520`), which the backend only ever undoes once and so
2606
+ * 404s on.
2607
+ */
2608
+ export declare const normalizeDeploymentId: (id: string) => string;
2609
+
2545
2610
  /**
2546
2611
  * Normalises a stored response-format string to the current enum. Legacy data
2547
2612
  * may contain `'Markdown'` or `'PlainText'` (capital-first) instead of the
@@ -3031,6 +3096,23 @@ export declare const referenceAttachmentToPdfCanvasContent: (attachment: Attachm
3031
3096
  /** Name reserved for the hidden marker file used to create empty folders. */
3032
3097
  export declare const RESERVED_MARKER_NAME = ".dial_folder";
3033
3098
 
3099
+ /**
3100
+ * One reset time, already parsed and formatted by the host. Declared
3101
+ * structurally here so this library never imports an application type; the
3102
+ * host passes a value that satisfies this shape (e.g. `apps/chat`'s own
3103
+ * `ResetTimeDisplay`).
3104
+ */
3105
+ export declare interface ResetTimeDisplay {
3106
+ /** Exclusive end of the period as an epoch ms value, for the host's boundary scheduling. */
3107
+ resetsAtMs: number;
3108
+ /** Machine-readable instant for a `<time dateTime>` attribute. */
3109
+ isoValue: string;
3110
+ /** Visible reset line. */
3111
+ label: string;
3112
+ /** Accessible expansion of the reset line. */
3113
+ ariaLabel: string;
3114
+ }
3115
+
3034
3116
  /**
3035
3117
  * Resolves the primary action for a catalog item.
3036
3118
  *
@@ -3069,6 +3151,9 @@ export declare const resolveDialFileBucketAndPath: (fileId: string) => {
3069
3151
  path: string;
3070
3152
  } | undefined;
3071
3153
 
3154
+ /** A callback that resolves a display name from a localized-text value. */
3155
+ declare type ResolveDisplayName = (name: string | Record<string, string> | undefined | null, locale: string) => string;
3156
+
3072
3157
  /** Resolves a DIAL Core file id to a downloadable URL. Host-owned — encodes the app's own file-download endpoint. */
3073
3158
  export declare type ResolveDownloadUrl = (fileId: string) => string | undefined;
3074
3159
 
@@ -3106,6 +3191,9 @@ export declare const resolveGroupedVisualizerCanvasContent: (attachments: Displa
3106
3191
  */
3107
3192
  export declare const resolveHtmlCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers) => Promise<HtmlCanvasContent | ErrorCanvasContent | null>;
3108
3193
 
3194
+ /** A callback that resolves an icon URL from a deployment's raw `iconUrl` field. */
3195
+ declare type ResolveIconUrl = (iconUrl: string | undefined) => string | undefined;
3196
+
3109
3197
  /**
3110
3198
  * Resolves an image canvas content payload from a DisplayAttachment without
3111
3199
  * fetching — returns a local blob URL or the BFF download URL directly so the
@@ -3930,6 +4018,12 @@ export declare interface TranscribeWithDeploymentParams {
3930
4018
  signal: AbortSignal;
3931
4019
  }
3932
4020
 
4021
+ /** A translate function compatible with i18next's `TFunction`. */
4022
+ declare type Translate = (key: string, options?: Record<string, unknown>) => string;
4023
+
4024
+ /** A translate function compatible with i18next's `TFunction`. */
4025
+ declare type Translate_2 = (key: string, options?: Record<string, unknown>) => string;
4026
+
3933
4027
  export declare const trimFileNameToByteLimit: (name: string, limit?: number) => string;
3934
4028
 
3935
4029
  /** An error thrown to indicate the caller is unauthenticated. */
@@ -3988,6 +4082,66 @@ export declare interface UploadFileWithProgressOptions {
3988
4082
  /** Upload mode passed to `FilesApi.uploadFile`: overwrite an existing file or fail if it already exists. */
3989
4083
  export declare type UploadMode = 'overwrite' | 'create-only';
3990
4084
 
4085
+ /**
4086
+ * i18n key strings that the consuming app's translation bundle must define for
4087
+ * `mapUsageDataToDashboard` to produce correctly translated strings. The
4088
+ * values are the default key paths used by AI DIAL Chat.
4089
+ */
4090
+ export declare const USAGE_DATA_I18N_KEYS: {
4091
+ /** Title for the current-UTC-day card (e.g. `'Today'`). */
4092
+ readonly todayTitle: "usage.todayTitle";
4093
+ /** Accessible period description for the current-UTC-day card. */
4094
+ readonly todayPeriodDescription: "usage.todayPeriodDescription";
4095
+ /** Title for the current-UTC-week card (e.g. `'This week'`). */
4096
+ readonly thisWeekTitle: "usage.thisWeekTitle";
4097
+ /** Accessible period description for the current-UTC-week card. */
4098
+ readonly thisWeekPeriodDescription: "usage.thisWeekPeriodDescription";
4099
+ /** Title for the current-UTC-month card (e.g. `'This month'`). */
4100
+ readonly thisMonthTitle: "usage.thisMonthTitle";
4101
+ /** Accessible period description for the current-UTC-month card. */
4102
+ readonly thisMonthPeriodDescription: "usage.thisMonthPeriodDescription";
4103
+ /** Aria label when there is no limit. Receives `{ used: string }`. */
4104
+ readonly unlimitedProgressAriaLabel: "usage.unlimitedProgressAriaLabel";
4105
+ /** Aria label for a progress bar with a finite limit. Receives `{ used: string, total: string, percent: number }`. */
4106
+ readonly progressAriaLabel: "usage.progressAriaLabel";
4107
+ };
4108
+
4109
+ /**
4110
+ * i18n key strings that the consuming app's translation bundle must define for
4111
+ * `mapUserUsageToModelLimits` and `mapOverallCostLimitsToPeriodStatuses` to produce
4112
+ * correctly translated strings. The values are the default key paths used by AI DIAL Chat.
4113
+ */
4114
+ export declare const USAGE_MODEL_LIMITS_I18N_KEYS: {
4115
+ /** Period label used in tooltip text. Receives no interpolation. */
4116
+ readonly todayPeriodDescription: "usage.todayPeriodDescription";
4117
+ /** Period label used in tooltip text. Receives no interpolation. */
4118
+ readonly thisWeekPeriodDescription: "usage.thisWeekPeriodDescription";
4119
+ /** Period label used in tooltip text. Receives no interpolation. */
4120
+ readonly thisMonthPeriodDescription: "usage.thisMonthPeriodDescription";
4121
+ /** Tooltip when the overall cost limit is running low. Receives `{ period: string }`. */
4122
+ readonly overallCostLimitRunningLowTooltip: "usage.overallCostLimitRunningLowTooltip";
4123
+ /** Tooltip when the overall cost limit is reached. Receives `{ period: string }`. */
4124
+ readonly overallCostLimitReachedTooltip: "usage.overallCostLimitReachedTooltip";
4125
+ /** Aria label for a metric cell with no data. */
4126
+ readonly unavailableLabel: "usage.unavailableLabel";
4127
+ /** Supporting label when a token limit follows the cost limit. */
4128
+ readonly followsCostLimitLabel: "usage.followsCostLimitLabel";
4129
+ /** Supporting label when there is no per-deployment token limit. */
4130
+ readonly noLimitLabel: "usage.noLimitLabel";
4131
+ /** Aria label when token usage has no limit but follows the cost limit. Receives `{ used: string }`. */
4132
+ readonly followsCostLimitAriaLabel: "usage.followsCostLimitAriaLabel";
4133
+ /** Aria label when there is no limit. Receives `{ used: string }`. */
4134
+ readonly unlimitedProgressAriaLabel: "usage.unlimitedProgressAriaLabel";
4135
+ /** Aria label for a progress bar with a finite limit. Receives `{ used: string, total: string, percent: number }`. */
4136
+ readonly progressAriaLabel: "usage.progressAriaLabel";
4137
+ /** Label for the spent-cost cell. Receives `{ amount: string }`. */
4138
+ readonly spentLabel: "usage.spentLabel";
4139
+ /** Type caption for an application (agent) row. Receives no interpolation. */
4140
+ readonly applicationTypeLabel: "usage.applicationTypeLabel";
4141
+ /** Supporting label on an application row's spent cost. Receives no interpolation. */
4142
+ readonly includesCalledModelsLabel: "usage.includesCalledModelsLabel";
4143
+ };
4144
+
3991
4145
  /**
3992
4146
  * Synchronises the active conversation with the conversation list and returns
3993
4147
  * the panel-space id of the active conversation, or `undefined` when none is active.