@epam/ai-dial-chat-hooks 1.2.0-dev.92 → 1.2.0-dev.98

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
@@ -94,6 +94,8 @@ import { MessageAttachment } from '@epam/ai-dial-chat-shared';
94
94
  import { MessageCustomContent } from '@epam/ai-dial-chat-shared';
95
95
  import { MessageRating } from '@epam/ai-dial-chat-shared';
96
96
  import { Middleware } from '@epam/ai-dial-chat-api-client';
97
+ import { ModelLimitPeriodStatuses } from '@epam/ai-dial-usage-dashboard';
98
+ import { ModelLimitRow } from '@epam/ai-dial-usage-dashboard';
97
99
  import { MoveFilesResponseDto } from '@epam/ai-dial-chat-api-client';
98
100
  import { MoveItemDto } from '@epam/ai-dial-chat-api-client';
99
101
  import { MutableRefObject } from 'react';
@@ -159,6 +161,7 @@ import { UpdatedScheduledTaskDto } from '@epam/ai-dial-chat-api-client';
159
161
  import { UpdateScheduledTaskBodyDto } from '@epam/ai-dial-chat-api-client';
160
162
  import { UploadArchiveResponseDto } from '@epam/ai-dial-chat-api-client';
161
163
  import { UploadedAttachmentResult } from '@epam/ai-dial-chat-shared';
164
+ import { UsageLimitCardData } from '@epam/ai-dial-usage-dashboard';
162
165
  import { useGridEditingScroll } from '@epam/ai-dial-chat-shared';
163
166
  import { UseGridEditingScrollOptions } from '@epam/ai-dial-chat-shared';
164
167
  import { UseGridEditingScrollResult } from '@epam/ai-dial-chat-shared';
@@ -1704,6 +1707,9 @@ export declare const formatOperationFolderName: (destinationFolder: string, root
1704
1707
  */
1705
1708
  export declare const formatQuotedNameList: (names: string[]) => string;
1706
1709
 
1710
+ /** Formats a raw `resetsAt` into display strings, or returns `undefined` when it cannot be formatted. */
1711
+ export declare type FormatResetTime = (resetsAt: string | undefined) => ResetTimeDisplay | undefined;
1712
+
1707
1713
  /**
1708
1714
  * Reported through `onError` when the backend rejects a completion because
1709
1715
  * another generation is already active on the same conversation — what a
@@ -2209,6 +2215,13 @@ export declare const mapFormValuesToCreateBody: (values: ScheduledTaskCreateForm
2209
2215
  */
2210
2216
  export declare const mapFormValuesToUpdateBody: (values: ScheduledTaskCreateFormValues) => UpdateScheduledTaskBodyDto;
2211
2217
 
2218
+ /**
2219
+ * Maps the same top-level Cost budgets used by the aggregate cards into table-header state.
2220
+ *
2221
+ * @param formatResetTime - Formats each period's top-level `resetsAt` into the header's reset trio. Omit it to produce statuses with no reset fields.
2222
+ */
2223
+ export declare const mapOverallCostLimitsToPeriodStatuses: (usage: UserLimitStatsResponseDto | undefined, activeLocale: string, t: Translate_2, formatResetTime?: FormatResetTime) => ModelLimitPeriodStatuses;
2224
+
2212
2225
  /**
2213
2226
  * Maps a prompt DTO into a catalog item.
2214
2227
  *
@@ -2298,6 +2311,24 @@ export declare interface MapToolsetToCatalogItemOptions {
2298
2311
  resolveIconUrl: (iconUrl: string | undefined) => string | undefined;
2299
2312
  }
2300
2313
 
2314
+ /**
2315
+ * Maps a `UserLimitStatsResponseDto` into `UsageLimitCardGroup`'s `cards` prop,
2316
+ * in Today / This week / This month order. A period is omitted entirely when
2317
+ * the response carries no usable stat for it. Each card's reset trio comes from
2318
+ * `formatResetTime`, and is absent when that callback returns `undefined`.
2319
+ */
2320
+ export declare const mapUsageDataToDashboard: (usage: UserLimitStatsResponseDto | undefined, t: Translate, formatResetTime: FormatResetTime) => UsageLimitCardData[];
2321
+
2322
+ /**
2323
+ * Maps `usage.deployments` into `ModelLimitsSection`'s `rows` prop, joined with model identity
2324
+ * from `deploymentItems`. Rows are included only when any displayed period stat has nonzero usage.
2325
+ * Order follows `Object.keys(deployments)` — `deploymentItems` is enrichment-only.
2326
+ *
2327
+ * @param resolveIconUrl - Resolves a deployment's raw `iconUrl` to the URL the avatar should load.
2328
+ * @param resolveDisplayName - Resolves a localized-text map or plain string to the display name for `activeLocale`.
2329
+ */
2330
+ export declare const mapUserUsageToModelLimits: (usage: UserLimitStatsResponseDto | undefined, deploymentItems: DeploymentItemDto[], activeLocale: string, t: Translate_2, resolveIconUrl: ResolveIconUrl, resolveDisplayName: ResolveDisplayName) => ModelLimitRow[];
2331
+
2301
2332
  /** Content payload for Markdown file attachments. */
2302
2333
  declare interface MarkdownCanvasContent {
2303
2334
  /** Discriminates the content type to select the correct renderer. */
@@ -3138,6 +3169,23 @@ export declare const referenceAttachmentToPdfCanvasContent: (attachment: Attachm
3138
3169
  /** Name reserved for the hidden marker file used to create empty folders. */
3139
3170
  export declare const RESERVED_MARKER_NAME = ".dial_folder";
3140
3171
 
3172
+ /**
3173
+ * One reset time, already parsed and formatted by the host. Declared
3174
+ * structurally here so this library never imports an application type; the
3175
+ * host passes a value that satisfies this shape (e.g. `apps/chat`'s own
3176
+ * `ResetTimeDisplay`).
3177
+ */
3178
+ export declare interface ResetTimeDisplay {
3179
+ /** Exclusive end of the period as an epoch ms value, for the host's boundary scheduling. */
3180
+ resetsAtMs: number;
3181
+ /** Machine-readable instant for a `<time dateTime>` attribute. */
3182
+ isoValue: string;
3183
+ /** Visible reset line. */
3184
+ label: string;
3185
+ /** Accessible expansion of the reset line. */
3186
+ ariaLabel: string;
3187
+ }
3188
+
3141
3189
  /**
3142
3190
  * Resolves the primary action for a catalog item.
3143
3191
  *
@@ -3176,6 +3224,9 @@ export declare const resolveDialFileBucketAndPath: (fileId: string) => {
3176
3224
  path: string;
3177
3225
  } | undefined;
3178
3226
 
3227
+ /** A callback that resolves a display name from a localized-text value. */
3228
+ declare type ResolveDisplayName = (name: string | Record<string, string> | undefined | null, locale: string) => string;
3229
+
3179
3230
  /** Resolves a DIAL Core file id to a downloadable URL. Host-owned — encodes the app's own file-download endpoint. */
3180
3231
  export declare type ResolveDownloadUrl = (fileId: string) => string | undefined;
3181
3232
 
@@ -3213,6 +3264,9 @@ export declare const resolveGroupedVisualizerCanvasContent: (attachments: Displa
3213
3264
  */
3214
3265
  export declare const resolveHtmlCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers) => Promise<HtmlCanvasContent | ErrorCanvasContent | null>;
3215
3266
 
3267
+ /** A callback that resolves an icon URL from a deployment's raw `iconUrl` field. */
3268
+ declare type ResolveIconUrl = (iconUrl: string | undefined) => string | undefined;
3269
+
3216
3270
  /**
3217
3271
  * Resolves an image canvas content payload from a DisplayAttachment without
3218
3272
  * fetching — returns a local blob URL or the BFF download URL directly so the
@@ -4171,6 +4225,12 @@ export declare interface TranscribeWithDeploymentParams {
4171
4225
  signal: AbortSignal;
4172
4226
  }
4173
4227
 
4228
+ /** A translate function compatible with i18next's `TFunction`. */
4229
+ declare type Translate = (key: string, options?: Record<string, unknown>) => string;
4230
+
4231
+ /** A translate function compatible with i18next's `TFunction`. */
4232
+ declare type Translate_2 = (key: string, options?: Record<string, unknown>) => string;
4233
+
4174
4234
  export declare const trimFileNameToByteLimit: (name: string, limit?: number) => string;
4175
4235
 
4176
4236
  /** An error thrown to indicate the caller is unauthenticated. */
@@ -4229,6 +4289,62 @@ export declare interface UploadFileWithProgressOptions {
4229
4289
  /** Upload mode passed to `FilesApi.uploadFile`: overwrite an existing file or fail if it already exists. */
4230
4290
  export declare type UploadMode = 'overwrite' | 'create-only';
4231
4291
 
4292
+ /**
4293
+ * i18n key strings that the consuming app's translation bundle must define for
4294
+ * `mapUsageDataToDashboard` to produce correctly translated strings. The
4295
+ * values are the default key paths used by AI DIAL Chat.
4296
+ */
4297
+ export declare const USAGE_DATA_I18N_KEYS: {
4298
+ /** Title for the current-UTC-day card (e.g. `'Today'`). */
4299
+ readonly todayTitle: "usage.todayTitle";
4300
+ /** Accessible period description for the current-UTC-day card. */
4301
+ readonly todayPeriodDescription: "usage.todayPeriodDescription";
4302
+ /** Title for the current-UTC-week card (e.g. `'This week'`). */
4303
+ readonly thisWeekTitle: "usage.thisWeekTitle";
4304
+ /** Accessible period description for the current-UTC-week card. */
4305
+ readonly thisWeekPeriodDescription: "usage.thisWeekPeriodDescription";
4306
+ /** Title for the current-UTC-month card (e.g. `'This month'`). */
4307
+ readonly thisMonthTitle: "usage.thisMonthTitle";
4308
+ /** Accessible period description for the current-UTC-month card. */
4309
+ readonly thisMonthPeriodDescription: "usage.thisMonthPeriodDescription";
4310
+ /** Aria label when there is no limit. Receives `{ used: string }`. */
4311
+ readonly unlimitedProgressAriaLabel: "usage.unlimitedProgressAriaLabel";
4312
+ /** Aria label for a progress bar with a finite limit. Receives `{ used: string, total: string, percent: number }`. */
4313
+ readonly progressAriaLabel: "usage.progressAriaLabel";
4314
+ };
4315
+
4316
+ /**
4317
+ * i18n key strings that the consuming app's translation bundle must define for
4318
+ * `mapUserUsageToModelLimits` and `mapOverallCostLimitsToPeriodStatuses` to produce
4319
+ * correctly translated strings. The values are the default key paths used by AI DIAL Chat.
4320
+ */
4321
+ export declare const USAGE_MODEL_LIMITS_I18N_KEYS: {
4322
+ /** Period label used in tooltip text. Receives no interpolation. */
4323
+ readonly todayPeriodDescription: "usage.todayPeriodDescription";
4324
+ /** Period label used in tooltip text. Receives no interpolation. */
4325
+ readonly thisWeekPeriodDescription: "usage.thisWeekPeriodDescription";
4326
+ /** Period label used in tooltip text. Receives no interpolation. */
4327
+ readonly thisMonthPeriodDescription: "usage.thisMonthPeriodDescription";
4328
+ /** Tooltip when the overall cost limit is running low. Receives `{ period: string }`. */
4329
+ readonly overallCostLimitRunningLowTooltip: "usage.overallCostLimitRunningLowTooltip";
4330
+ /** Tooltip when the overall cost limit is reached. Receives `{ period: string }`. */
4331
+ readonly overallCostLimitReachedTooltip: "usage.overallCostLimitReachedTooltip";
4332
+ /** Aria label for a metric cell with no data. */
4333
+ readonly unavailableLabel: "usage.unavailableLabel";
4334
+ /** Supporting label when a token limit follows the cost limit. */
4335
+ readonly followsCostLimitLabel: "usage.followsCostLimitLabel";
4336
+ /** Supporting label when there is no per-deployment token limit. */
4337
+ readonly noLimitLabel: "usage.noLimitLabel";
4338
+ /** Aria label when token usage has no limit but follows the cost limit. Receives `{ used: string }`. */
4339
+ readonly followsCostLimitAriaLabel: "usage.followsCostLimitAriaLabel";
4340
+ /** Aria label when there is no limit. Receives `{ used: string }`. */
4341
+ readonly unlimitedProgressAriaLabel: "usage.unlimitedProgressAriaLabel";
4342
+ /** Aria label for a progress bar with a finite limit. Receives `{ used: string, total: string, percent: number }`. */
4343
+ readonly progressAriaLabel: "usage.progressAriaLabel";
4344
+ /** Label for the spent-cost cell. Receives `{ amount: string }`. */
4345
+ readonly spentLabel: "usage.spentLabel";
4346
+ };
4347
+
4232
4348
  /**
4233
4349
  * Synchronises the active conversation with the conversation list and returns
4234
4350
  * the panel-space id of the active conversation, or `undefined` when none is active.
package/index.js CHANGED
@@ -136,11 +136,13 @@ import { useViewportWidth as fa } from "./useViewportWidth/useViewportWidth.js";
136
136
  import { usePanelMaxWidth as pa } from "./usePanelMaxWidth/usePanelMaxWidth.js";
137
137
  import { useShareLink as ma } from "./useShareLink/useShareLink.js";
138
138
  import { useToolsMenu as ha } from "./useToolsMenu/useToolsMenu.js";
139
- import { useUsageData as ga } from "./usage/useUsageData/useUsageData.js";
140
- import { McpAppResourceFetchError as _a, createMcpAppsApiClient as va } from "./mcp-apps/mcp-apps-api-client.js";
141
- import { useMcpAppTools as ya } from "./mcp-apps/useMcpAppTools/useMcpAppTools.js";
142
- import { useMcpAppHostContext as ba } from "./mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js";
143
- import { useMcpAppHostAdapter as xa } from "./mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js";
144
- import { useOpenMcpAppCanvas as Sa } from "./mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js";
145
- import { useGridEditingScroll as Ca } from "@epam/ai-dial-chat-shared";
146
- export { x as AttachmentValidationErrorReason, sr as AudioTranscriptionError, cr as AudioTranscriptionErrorReason, R as AuthenticationType, Fr as COLUMNS_WITHOUT_AUTHOR, Ir as COLUMNS_WITH_AUTHOR, Lr as CORE_PERMISSION_MAP, et as CatalogPrimaryActionType, T as ConversationExportMode, E as ConversationTransferErrorCode, D as ConversationTransferWarningCode, Rr as DATE_OPTIONS, zt as DEFAULT_GENERATION_CONFLICT_MESSAGE, ur as DEFAULT_MAX_ARCHIVE_BYTES, Hr as DialFileManagerActionProfile, Ur as DialFileManagerVariant, jr as DialFilesApiUploadMode, Gi as DownloadDestinationType, k as EXPORT_APP_NAME, O as ExportFileNameKind, jt as FavoriteEntityType, Mr as FileManagerNotificationReason, Nr as FileNameValidationErrorReason, Pr as FileOperationKind, Bt as GenerationConflictError, _a as McpAppResourceFetchError, ze as McpResourceKind, ot as OAuthResourceKind, zr as PATH_SEPARATOR_REGEXP, un as PROMPT_CONTENT_MAX_LENGTH, dn as PROMPT_COUNTER_ANNOUNCE_THRESHOLD, fn as PROMPT_DESCRIPTION_MAX_LENGTH, pn as PROMPT_NAME_MAX_LENGTH, Te as PUBLIC_SKILL_BUCKET, mn as PromptFieldError, ae as PromptSource, Br as RESERVED_MARKER_NAME, Jn as RecipientsCountStatus, ue as SKILL_FILE_UPLOAD_MAX_BYTES, Ee as SKILL_LISTING_MAX_PAGES, De as SKILL_LISTING_PAGE_SIZE, de as SKILL_MANIFEST_FILE, Oe as SKILL_MANIFEST_MAX_BYTES, fe as SKILL_UPLOAD_MAX_FILES, pe as SKILL_UPLOAD_MAX_TOTAL_BYTES, Sn as ScheduledTaskTriggerDescriptionKind, Un as SkillArchiveImportErrorKind, Wn as SkillArchiveImportStatus, Gn as SkillArchiveSelectionRejectionReason, In as SkillEditorLoadState, Bn as SkillPreviewErrorKind, ke as SkillSource, st as TOOLSET_REDIRECT_STATE_KEY, ct as ToolsetAuthStatus, lt as ToolsetAuthTypes, ut as ToolsetCredentialsLevel, Et as ToolsetLoginOutcomeType, dt as ToolsetOAuthCallbackQuery, ft as ToolsetOAuthChannelControlType, pt as ToolsetOAuthFailureReason, mt as ToolsetOAuthInitiationResultType, ht as ToolsetOAuthResultType, Vr as UPLOAD_CONCURRENCY, xn as UnsupportedTriggerReason, gt as WithLogin, zi as annotationToDisplayAttachment, xi as annotationToOoxmlCanvasContent, Si as annotationToPdfCanvasContent, wn as apSchedulerDayToJsDay, W as appendLocaleCode, Er as applyChunkToMessages, Bi as attachmentDtoToDisplayAttachment, Vi as attachmentDtosToDisplayAttachments, fr as attachmentToDto, pr as attachmentsToDtos, G as buildAdditionalLocaleOptions, Pt as buildAnnouncementSignature, Be as buildApplicationMcpUrl, N as buildChatCompletionsUrl, Ve as buildConnectApi, P as buildDeploymentConnectApi, sa as buildExternalServiceScopeId, li as buildFromCache, sn as buildPromptExportEnvelope, cn as buildPromptExportFileName, se as buildPromptOverview, hn as buildPromptPath, F as buildResponsesUrl, Gr as buildSharedItemVirtualPath, je as buildSkillContentTree, me as buildSkillFilesPayload, he as buildSkillManifest, ge as buildSkillManifestForSubmit, _e as buildSkillManifestFromFrontmatter, Me as buildSkillOverview, xt as buildToolsetAuthorizeUrl, He as buildToolsetMcpUrl, Kn as classifySkillArchiveImportError, Ci as clearAttachmentCache, K as composeLocalePayload, Vt as createChatStreamApi, i as createCsrfMiddleware, qt as createDeploymentChangedMessage, vi as createFilesApiClient, va as createMcpAppsApiClient, mr as createMessagePair, j as createPublishApiClient, jn as createScheduledTasksApiClient, a as createUnauthorizedMiddleware, yi as createUploadFileWithProgress, V as decodeToolsetId, q as decomposeLocalizedFields, Wr as deriveActionProfile, Ye as deriveAvailableTabIds, Xn as deriveConversationRowActionState, Xe as deriveFavoriteItems, Cn as describeScheduledTaskTrigger, Kr as dialCorePathToRelative, Hi as dialFileToAttachment, Ui as dialFilesToAttachments, Wi as dialFolderPathToAttachment, m as downloadAttachment, _t as emitToolsetLoginSuccess, I as encodeDeploymentId, H as encodeToolsetId, ui as fetchByTab, di as fetchForSearch, Ze as filterCatalogItemsBySelector, Qe as filterHiddenOwnedItems, L as findDeploymentByIdOrReference, qr as findDialFileByPath, fi as findFirstSuccessfulCopyMoveItem, Jr as findFolderByVirtualPath, Ut as formatAppVersion, X as formatCalendarDate, C as formatDateYM, w as formatDateYMD, Yr as formatOperationFolderName, A as formatQuotedNameList, e as getApiErrorDetails, t as getApiErrorMessage, n as getApiErrorStatus, ra as getBrowserTimezone, Sr as getConversationPath, er as getConversationSource, ca as getExternalServiceFallbackName, Jt as getLastDeploymentId, Yt as getLastUserMessageToolConfiguration, Gt as getModelIdFromConversationId, ii as getParentFolderPath, We as getPublicCatalogEntityFolderPath, en as getQuickAppConversationStarters, gn as getRemainingCharacters, yr as getStarterConversationText, br as getStarterDisplayText, rn as getStarterPopulateText, xr as getStarterSubmitText, an as getStartersFromSchema, Kt as getTimeOfDayGreeting, yt as getToolsetOAuthChannelName, St as getToolsetRedirectUri, Ii as getUrlFileName, Xr as getVirtualPathName, hr as hasActiveToolConfig, Ft as hasAnnouncementContent, wi as hasAttachmentTextSource, Zr as hasDialFileWritePermission, Qr as hasForbiddenNameSymbols, It as hasStructuredAnnouncement, o as includesIgnoreCase, Ct as initiateOAuthLogin, gr as isAnswerIncomplete, Or as isAwaitingGenerationResume, r as isConversationNotFoundError, $r as isCopyMoveDuplicateAllowed, ta as isCustomAppSchema, _ as isDialFileAcceptType, d as isDialFileId, h as isDownloadableAttachment, Li as isExternalSourcePreviewable, _r as isMessageChanged, Xt as isMessageStreaming, ce as isOrganisationPromptItem, Ge as isPublicCatalogEntityId, U as isPublicToolsetId, na as isQuickAppSchema, ei as isShareActionsAllowed, ia as isValidAbsoluteUrl, aa as isValidFeaturesData, ve as isValidSkillRelativePath, Tn as jsDayToApSchedulerDay, pi as mapCorePermissions, Q as mapDeploymentDetailsDtoToEntityDetails, z as mapDeploymentLimitsDtoToCatalogLimits, B as mapDeploymentLimitsToInput, te as mapDeploymentToCatalogItem, ne as mapDeploymentToolsetCredentials, $ as mapEntityDetailsToCatalogDetails, mi as mapFileMetadataToDialFile, En as mapFormValuesToCreateBody, Dn as mapFormValuesToUpdateBody, le as mapPromptToCatalogItem, Ke as mapPublishConversationResultDto, qe as mapPublishHistoryEntryDto, On as mapScheduledTaskDtoToFormValues, hi as mapSearchItem, Ne as mapSkillToCatalogItem, tn as mapStages, ee as mapToolsetCredentials, re as mapToolsetToCatalogItem, gi as mergeCreatedFolderIntoCache, Dr as mergeStages, Zt as messageHasStages, v as mimeTypesToAttachmentExtensionLabels, y as mimeTypesToDialFileAcceptTypes, b as mimeTypesToFileAccept, ye as nameFromPath, wt as navigateToolsetOAuthPopup, Qt as normalizeResponseFormat, be as normalizeSkillName, ti as normalizeVirtualPath, bi as openAnnotationAttachment, Tt as openToolsetOAuthPopup, Z as padTwoDigits, la as parseExternalServiceUrl, oa as parseFeaturesData, ni as parseNewFolderVirtualPath, oe as parsePromptResourceUrl, xe as parseSkillManifest, rt as parseSkillManifestDocument, Ae as parseSkillResourceUrl, si as prepareCopyItems, Ki as prepareDownloadDestination, ci as prepareMoveRenameItems, kn as prepareScheduledTaskCreateBody, An as prepareScheduledTaskUpdateBody, Pe as readSkillFileBytes, Fe as readSkillFilePreviewBytes, Ie as readSkillManifest, $e as reconcileFilterTopics, Ti as referenceAttachmentToPdfCanvasContent, tt as resolveCatalogPrimaryAction, Ei as resolveCodeCanvasContent, ie as resolveDeploymentFolder, ai as resolveDialFileApiPath, f as resolveDialFileBucketAndPath, Ri as resolveExternalSourceContentType, Di as resolveGroupedVisualizerCanvasContent, Oi as resolveHtmlCanvasContent, ki as resolveImageCanvasContent, Ai as resolveJsonCanvasContent, J as resolveLocalizedText, ji as resolveMarkdownCanvasContent, Ue as resolveMcpResourceKind, Mi as resolveOoxmlCanvasContent, ri as resolveOwnerCoords, Ni as resolvePdfCanvasContent, p as resolveRelativeDialFilePath, Le as resolveSkillFileDownloadPath, Re as resolveSkillManifestFileId, Pi as resolveTextCanvasContent, Fi as resolveVisualizerCanvasContent, s as safeDecodeURI, c as safeDecodeURIComponent, Lt as sanitizeAnnouncementHtml, Rt as sanitizeAnnouncementMessageHtml, rr as sanitizeFileName, Wt as sanitizeFooterHtml, ln as serializePromptExport, vr as shouldRerunGenerationOnEdit, Ht as shouldWatchForDisplayNameUpdate, Se as skillFileBytesToBlob, Fn as skillFileToAttachment, ir as splitFileNameExtension, Ce as startsWithFrontmatterBlock, l as stripSurroundingSlashes, u as stripTrailingSlashes, vt as subscribeToolsetLoginSuccess, Y as toBaseLocale, $t as toOverlayMessages, Je as toPublishEntityType, M as toPublishRuleDto, nn as toStage, ar as trimFileNameToByteLimit, we as unpackSkillArchive, _i as updateEntry, Zn as useActiveConversationSync, kt as useApplicationCredentials, Qn as useAsyncConfirmDialog, g as useAttachmentAction, or as useAttachmentUpload, S as useAttachmentValidation, nt as useCatalogEditNavigation, at as useCatalogItemDetails, Ot as useCatalogToolsetCredentials, ua as useChatSettingsFormConfig, dr as useConversationExport, Cr as useConversationHandlers, wr as useConversationImport, $n as useConversationLookupMaps, tr as useConversationPanelItems, Tr as useConversationScroll, Ar as useConversationSources, kr as useConversationStream, qi as useDialFileListing, Qi as useDialFileManager, $i as useDialFileManagerTabConfig, Ji as useDialFileMetadata, Yi as useDialFileMutations, Xi as useDialFileSharing, Zi as useDialFileUploadBatch, Mt as useFavoriteEntitiesState, ea as useFileAttachmentPicker, Ca as useGridEditingScroll, nr as useImportFilePicker, xa as useMcpAppHostAdapter, ba as useMcpAppHostContext, ya as useMcpAppTools, on as useOAuthCallbackCompletion, Sa as useOpenMcpAppCanvas, da as usePageFileDrag, pa as usePanelMaxWidth, bn as usePromptsState, Nt as usePublishFolders, Nn as useScheduledTaskRuns, Mn as useScheduledTasks, ma as useShareLink, Yn as useShareRecipientsCount, qn as useSkillArchiveImport, At as useSkillDetailsPanelData, Ln as useSkillEditorLoad, Rn as useSkillEditorSubmit, zn as useSkillFileActions, Vn as useSkillFilePreview, it as useSkillItemDetails, Hn as useSkillsState, ha as useToolsMenu, Dt as useToolsetLogin, lr as useTranscribeAudio, ga as useUsageData, fa as useViewportWidth, _n as validatePromptContent, vn as validatePromptDescription, yn as validatePromptName, Pn as validateSkillFileBatch, oi as virtualPathToApiPath, bt as waitForToolsetOAuthResult };
139
+ import { USAGE_DATA_I18N_KEYS as ga, mapUsageDataToDashboard as _a } from "./usage/map-usage-data-to-dashboard.js";
140
+ import { USAGE_MODEL_LIMITS_I18N_KEYS as va, mapOverallCostLimitsToPeriodStatuses as ya, mapUserUsageToModelLimits as ba } from "./usage/map-user-usage-to-model-limits.js";
141
+ import { useUsageData as xa } from "./usage/useUsageData/useUsageData.js";
142
+ import { McpAppResourceFetchError as Sa, createMcpAppsApiClient as Ca } from "./mcp-apps/mcp-apps-api-client.js";
143
+ import { useMcpAppTools as wa } from "./mcp-apps/useMcpAppTools/useMcpAppTools.js";
144
+ import { useMcpAppHostContext as Ta } from "./mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js";
145
+ import { useMcpAppHostAdapter as Ea } from "./mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js";
146
+ import { useOpenMcpAppCanvas as Da } from "./mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js";
147
+ import { useGridEditingScroll as Oa } from "@epam/ai-dial-chat-shared";
148
+ export { x as AttachmentValidationErrorReason, sr as AudioTranscriptionError, cr as AudioTranscriptionErrorReason, R as AuthenticationType, Fr as COLUMNS_WITHOUT_AUTHOR, Ir as COLUMNS_WITH_AUTHOR, Lr as CORE_PERMISSION_MAP, et as CatalogPrimaryActionType, T as ConversationExportMode, E as ConversationTransferErrorCode, D as ConversationTransferWarningCode, Rr as DATE_OPTIONS, zt as DEFAULT_GENERATION_CONFLICT_MESSAGE, ur as DEFAULT_MAX_ARCHIVE_BYTES, Hr as DialFileManagerActionProfile, Ur as DialFileManagerVariant, jr as DialFilesApiUploadMode, Gi as DownloadDestinationType, k as EXPORT_APP_NAME, O as ExportFileNameKind, jt as FavoriteEntityType, Mr as FileManagerNotificationReason, Nr as FileNameValidationErrorReason, Pr as FileOperationKind, Bt as GenerationConflictError, Sa as McpAppResourceFetchError, ze as McpResourceKind, ot as OAuthResourceKind, zr as PATH_SEPARATOR_REGEXP, un as PROMPT_CONTENT_MAX_LENGTH, dn as PROMPT_COUNTER_ANNOUNCE_THRESHOLD, fn as PROMPT_DESCRIPTION_MAX_LENGTH, pn as PROMPT_NAME_MAX_LENGTH, Te as PUBLIC_SKILL_BUCKET, mn as PromptFieldError, ae as PromptSource, Br as RESERVED_MARKER_NAME, Jn as RecipientsCountStatus, ue as SKILL_FILE_UPLOAD_MAX_BYTES, Ee as SKILL_LISTING_MAX_PAGES, De as SKILL_LISTING_PAGE_SIZE, de as SKILL_MANIFEST_FILE, Oe as SKILL_MANIFEST_MAX_BYTES, fe as SKILL_UPLOAD_MAX_FILES, pe as SKILL_UPLOAD_MAX_TOTAL_BYTES, Sn as ScheduledTaskTriggerDescriptionKind, Un as SkillArchiveImportErrorKind, Wn as SkillArchiveImportStatus, Gn as SkillArchiveSelectionRejectionReason, In as SkillEditorLoadState, Bn as SkillPreviewErrorKind, ke as SkillSource, st as TOOLSET_REDIRECT_STATE_KEY, ct as ToolsetAuthStatus, lt as ToolsetAuthTypes, ut as ToolsetCredentialsLevel, Et as ToolsetLoginOutcomeType, dt as ToolsetOAuthCallbackQuery, ft as ToolsetOAuthChannelControlType, pt as ToolsetOAuthFailureReason, mt as ToolsetOAuthInitiationResultType, ht as ToolsetOAuthResultType, Vr as UPLOAD_CONCURRENCY, ga as USAGE_DATA_I18N_KEYS, va as USAGE_MODEL_LIMITS_I18N_KEYS, xn as UnsupportedTriggerReason, gt as WithLogin, zi as annotationToDisplayAttachment, xi as annotationToOoxmlCanvasContent, Si as annotationToPdfCanvasContent, wn as apSchedulerDayToJsDay, W as appendLocaleCode, Er as applyChunkToMessages, Bi as attachmentDtoToDisplayAttachment, Vi as attachmentDtosToDisplayAttachments, fr as attachmentToDto, pr as attachmentsToDtos, G as buildAdditionalLocaleOptions, Pt as buildAnnouncementSignature, Be as buildApplicationMcpUrl, N as buildChatCompletionsUrl, Ve as buildConnectApi, P as buildDeploymentConnectApi, sa as buildExternalServiceScopeId, li as buildFromCache, sn as buildPromptExportEnvelope, cn as buildPromptExportFileName, se as buildPromptOverview, hn as buildPromptPath, F as buildResponsesUrl, Gr as buildSharedItemVirtualPath, je as buildSkillContentTree, me as buildSkillFilesPayload, he as buildSkillManifest, ge as buildSkillManifestForSubmit, _e as buildSkillManifestFromFrontmatter, Me as buildSkillOverview, xt as buildToolsetAuthorizeUrl, He as buildToolsetMcpUrl, Kn as classifySkillArchiveImportError, Ci as clearAttachmentCache, K as composeLocalePayload, Vt as createChatStreamApi, i as createCsrfMiddleware, qt as createDeploymentChangedMessage, vi as createFilesApiClient, Ca as createMcpAppsApiClient, mr as createMessagePair, j as createPublishApiClient, jn as createScheduledTasksApiClient, a as createUnauthorizedMiddleware, yi as createUploadFileWithProgress, V as decodeToolsetId, q as decomposeLocalizedFields, Wr as deriveActionProfile, Ye as deriveAvailableTabIds, Xn as deriveConversationRowActionState, Xe as deriveFavoriteItems, Cn as describeScheduledTaskTrigger, Kr as dialCorePathToRelative, Hi as dialFileToAttachment, Ui as dialFilesToAttachments, Wi as dialFolderPathToAttachment, m as downloadAttachment, _t as emitToolsetLoginSuccess, I as encodeDeploymentId, H as encodeToolsetId, ui as fetchByTab, di as fetchForSearch, Ze as filterCatalogItemsBySelector, Qe as filterHiddenOwnedItems, L as findDeploymentByIdOrReference, qr as findDialFileByPath, fi as findFirstSuccessfulCopyMoveItem, Jr as findFolderByVirtualPath, Ut as formatAppVersion, X as formatCalendarDate, C as formatDateYM, w as formatDateYMD, Yr as formatOperationFolderName, A as formatQuotedNameList, e as getApiErrorDetails, t as getApiErrorMessage, n as getApiErrorStatus, ra as getBrowserTimezone, Sr as getConversationPath, er as getConversationSource, ca as getExternalServiceFallbackName, Jt as getLastDeploymentId, Yt as getLastUserMessageToolConfiguration, Gt as getModelIdFromConversationId, ii as getParentFolderPath, We as getPublicCatalogEntityFolderPath, en as getQuickAppConversationStarters, gn as getRemainingCharacters, yr as getStarterConversationText, br as getStarterDisplayText, rn as getStarterPopulateText, xr as getStarterSubmitText, an as getStartersFromSchema, Kt as getTimeOfDayGreeting, yt as getToolsetOAuthChannelName, St as getToolsetRedirectUri, Ii as getUrlFileName, Xr as getVirtualPathName, hr as hasActiveToolConfig, Ft as hasAnnouncementContent, wi as hasAttachmentTextSource, Zr as hasDialFileWritePermission, Qr as hasForbiddenNameSymbols, It as hasStructuredAnnouncement, o as includesIgnoreCase, Ct as initiateOAuthLogin, gr as isAnswerIncomplete, Or as isAwaitingGenerationResume, r as isConversationNotFoundError, $r as isCopyMoveDuplicateAllowed, ta as isCustomAppSchema, _ as isDialFileAcceptType, d as isDialFileId, h as isDownloadableAttachment, Li as isExternalSourcePreviewable, _r as isMessageChanged, Xt as isMessageStreaming, ce as isOrganisationPromptItem, Ge as isPublicCatalogEntityId, U as isPublicToolsetId, na as isQuickAppSchema, ei as isShareActionsAllowed, ia as isValidAbsoluteUrl, aa as isValidFeaturesData, ve as isValidSkillRelativePath, Tn as jsDayToApSchedulerDay, pi as mapCorePermissions, Q as mapDeploymentDetailsDtoToEntityDetails, z as mapDeploymentLimitsDtoToCatalogLimits, B as mapDeploymentLimitsToInput, te as mapDeploymentToCatalogItem, ne as mapDeploymentToolsetCredentials, $ as mapEntityDetailsToCatalogDetails, mi as mapFileMetadataToDialFile, En as mapFormValuesToCreateBody, Dn as mapFormValuesToUpdateBody, ya as mapOverallCostLimitsToPeriodStatuses, le as mapPromptToCatalogItem, Ke as mapPublishConversationResultDto, qe as mapPublishHistoryEntryDto, On as mapScheduledTaskDtoToFormValues, hi as mapSearchItem, Ne as mapSkillToCatalogItem, tn as mapStages, ee as mapToolsetCredentials, re as mapToolsetToCatalogItem, _a as mapUsageDataToDashboard, ba as mapUserUsageToModelLimits, gi as mergeCreatedFolderIntoCache, Dr as mergeStages, Zt as messageHasStages, v as mimeTypesToAttachmentExtensionLabels, y as mimeTypesToDialFileAcceptTypes, b as mimeTypesToFileAccept, ye as nameFromPath, wt as navigateToolsetOAuthPopup, Qt as normalizeResponseFormat, be as normalizeSkillName, ti as normalizeVirtualPath, bi as openAnnotationAttachment, Tt as openToolsetOAuthPopup, Z as padTwoDigits, la as parseExternalServiceUrl, oa as parseFeaturesData, ni as parseNewFolderVirtualPath, oe as parsePromptResourceUrl, xe as parseSkillManifest, rt as parseSkillManifestDocument, Ae as parseSkillResourceUrl, si as prepareCopyItems, Ki as prepareDownloadDestination, ci as prepareMoveRenameItems, kn as prepareScheduledTaskCreateBody, An as prepareScheduledTaskUpdateBody, Pe as readSkillFileBytes, Fe as readSkillFilePreviewBytes, Ie as readSkillManifest, $e as reconcileFilterTopics, Ti as referenceAttachmentToPdfCanvasContent, tt as resolveCatalogPrimaryAction, Ei as resolveCodeCanvasContent, ie as resolveDeploymentFolder, ai as resolveDialFileApiPath, f as resolveDialFileBucketAndPath, Ri as resolveExternalSourceContentType, Di as resolveGroupedVisualizerCanvasContent, Oi as resolveHtmlCanvasContent, ki as resolveImageCanvasContent, Ai as resolveJsonCanvasContent, J as resolveLocalizedText, ji as resolveMarkdownCanvasContent, Ue as resolveMcpResourceKind, Mi as resolveOoxmlCanvasContent, ri as resolveOwnerCoords, Ni as resolvePdfCanvasContent, p as resolveRelativeDialFilePath, Le as resolveSkillFileDownloadPath, Re as resolveSkillManifestFileId, Pi as resolveTextCanvasContent, Fi as resolveVisualizerCanvasContent, s as safeDecodeURI, c as safeDecodeURIComponent, Lt as sanitizeAnnouncementHtml, Rt as sanitizeAnnouncementMessageHtml, rr as sanitizeFileName, Wt as sanitizeFooterHtml, ln as serializePromptExport, vr as shouldRerunGenerationOnEdit, Ht as shouldWatchForDisplayNameUpdate, Se as skillFileBytesToBlob, Fn as skillFileToAttachment, ir as splitFileNameExtension, Ce as startsWithFrontmatterBlock, l as stripSurroundingSlashes, u as stripTrailingSlashes, vt as subscribeToolsetLoginSuccess, Y as toBaseLocale, $t as toOverlayMessages, Je as toPublishEntityType, M as toPublishRuleDto, nn as toStage, ar as trimFileNameToByteLimit, we as unpackSkillArchive, _i as updateEntry, Zn as useActiveConversationSync, kt as useApplicationCredentials, Qn as useAsyncConfirmDialog, g as useAttachmentAction, or as useAttachmentUpload, S as useAttachmentValidation, nt as useCatalogEditNavigation, at as useCatalogItemDetails, Ot as useCatalogToolsetCredentials, ua as useChatSettingsFormConfig, dr as useConversationExport, Cr as useConversationHandlers, wr as useConversationImport, $n as useConversationLookupMaps, tr as useConversationPanelItems, Tr as useConversationScroll, Ar as useConversationSources, kr as useConversationStream, qi as useDialFileListing, Qi as useDialFileManager, $i as useDialFileManagerTabConfig, Ji as useDialFileMetadata, Yi as useDialFileMutations, Xi as useDialFileSharing, Zi as useDialFileUploadBatch, Mt as useFavoriteEntitiesState, ea as useFileAttachmentPicker, Oa as useGridEditingScroll, nr as useImportFilePicker, Ea as useMcpAppHostAdapter, Ta as useMcpAppHostContext, wa as useMcpAppTools, on as useOAuthCallbackCompletion, Da as useOpenMcpAppCanvas, da as usePageFileDrag, pa as usePanelMaxWidth, bn as usePromptsState, Nt as usePublishFolders, Nn as useScheduledTaskRuns, Mn as useScheduledTasks, ma as useShareLink, Yn as useShareRecipientsCount, qn as useSkillArchiveImport, At as useSkillDetailsPanelData, Ln as useSkillEditorLoad, Rn as useSkillEditorSubmit, zn as useSkillFileActions, Vn as useSkillFilePreview, it as useSkillItemDetails, Hn as useSkillsState, ha as useToolsMenu, Dt as useToolsetLogin, lr as useTranscribeAudio, xa as useUsageData, fa as useViewportWidth, _n as validatePromptContent, vn as validatePromptDescription, yn as validatePromptName, Pn as validateSkillFileBatch, oi as virtualPathToApiPath, bt as waitForToolsetOAuthResult };
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.2.0-dev.92",
4
+ "version": "1.2.0-dev.98",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -99,6 +99,11 @@
99
99
  "import": "./utils.js",
100
100
  "default": "./utils.js"
101
101
  },
102
+ "./usage": {
103
+ "types": "./usage.d.ts",
104
+ "import": "./usage.js",
105
+ "default": "./usage.js"
106
+ },
102
107
  "./mcp-apps": {
103
108
  "types": "./mcp-apps.d.ts",
104
109
  "import": "./mcp-apps.js",
@@ -106,7 +111,7 @@
106
111
  }
107
112
  },
108
113
  "dependencies": {
109
- "@epam/ai-dial-chat-api-client": "1.2.0-dev.92",
114
+ "@epam/ai-dial-chat-api-client": "1.2.0-dev.98",
110
115
  "dompurify": "3.4.15",
111
116
  "fflate": "^0.8.3",
112
117
  "lru-cache": "^10.4.3",
@@ -115,21 +120,22 @@
115
120
  },
116
121
  "peerDependencies": {
117
122
  "react": "^19.2.8",
118
- "@epam/ai-dial-attachment-canvas": "1.2.0-dev.92",
119
- "@epam/ai-dial-attachment-input": "1.2.0-dev.92",
120
- "@epam/ai-dial-builder-form": "1.2.0-dev.92",
121
- "@epam/ai-dial-catalog": "1.2.0-dev.92",
122
- "@epam/ai-dial-chat-overlay": "1.2.0-dev.92",
123
- "@epam/ai-dial-chat-shared": "1.2.0-dev.92",
124
- "@epam/ai-dial-mcp-apps": "1.2.0-dev.92",
125
- "@epam/ai-dial-publish-panel": "1.2.0-dev.92",
126
- "@epam/ai-dial-quotations": "1.2.0-dev.92",
123
+ "@epam/ai-dial-attachment-canvas": "1.2.0-dev.98",
124
+ "@epam/ai-dial-attachment-input": "1.2.0-dev.98",
125
+ "@epam/ai-dial-builder-form": "1.2.0-dev.98",
126
+ "@epam/ai-dial-catalog": "1.2.0-dev.98",
127
+ "@epam/ai-dial-chat-overlay": "1.2.0-dev.98",
128
+ "@epam/ai-dial-chat-shared": "1.2.0-dev.98",
129
+ "@epam/ai-dial-mcp-apps": "1.2.0-dev.98",
130
+ "@epam/ai-dial-publish-panel": "1.2.0-dev.98",
131
+ "@epam/ai-dial-quotations": "1.2.0-dev.98",
127
132
  "@epam/ai-dial-react-file-manager": "^0.3.0-dev.4",
128
- "@epam/ai-dial-scheduled-tasks": "1.2.0-dev.92",
129
- "@epam/ai-dial-share": "1.2.0-dev.92",
130
- "@epam/ai-dial-skill-editor": "1.2.0-dev.92",
131
- "@epam/ai-dial-source-panel": "1.2.0-dev.92",
133
+ "@epam/ai-dial-scheduled-tasks": "1.2.0-dev.98",
134
+ "@epam/ai-dial-share": "1.2.0-dev.98",
135
+ "@epam/ai-dial-skill-editor": "1.2.0-dev.98",
136
+ "@epam/ai-dial-source-panel": "1.2.0-dev.98",
132
137
  "@epam/ai-dial-ui-kit": "^0.15.0-dev.12",
138
+ "@epam/ai-dial-usage-dashboard": "1.2.0-dev.98",
133
139
  "@modelcontextprotocol/sdk": "^1.29.0",
134
140
  "@epam/pdf-highlighter-kit": "^0.0.19",
135
141
  "@mcp-ui/client": "^7.1.1"
@@ -180,6 +186,9 @@
180
186
  "@epam/ai-dial-ui-kit": {
181
187
  "optional": true
182
188
  },
189
+ "@epam/ai-dial-usage-dashboard": {
190
+ "optional": true
191
+ },
183
192
  "@mcp-ui/client": {
184
193
  "optional": true
185
194
  },
@@ -0,0 +1,66 @@
1
+ import { formatCost as e } from "@epam/ai-dial-chat-shared";
2
+ import { UsageLimitStatus as t } from "@epam/ai-dial-usage-dashboard";
3
+ //#region src/usage/map-usage-data-to-dashboard.ts
4
+ var n = {
5
+ todayTitle: "usage.todayTitle",
6
+ todayPeriodDescription: "usage.todayPeriodDescription",
7
+ thisWeekTitle: "usage.thisWeekTitle",
8
+ thisWeekPeriodDescription: "usage.thisWeekPeriodDescription",
9
+ thisMonthTitle: "usage.thisMonthTitle",
10
+ thisMonthPeriodDescription: "usage.thisMonthPeriodDescription",
11
+ unlimitedProgressAriaLabel: "usage.unlimitedProgressAriaLabel",
12
+ progressAriaLabel: "usage.progressAriaLabel"
13
+ }, r = 2 ** 53, i = 75, a = (e) => e != null && Number.isFinite(e.total) && Number.isFinite(e.used), o = (e) => e >= 100 ? t.LimitReached : e >= i ? t.RunningLow : t.Default, s = (e) => e ? {
14
+ resetLabel: e.label,
15
+ resetIsoValue: e.isoValue,
16
+ resetAriaLabel: e.ariaLabel
17
+ } : {}, c = (i, a, c, l, u) => {
18
+ let d = Math.max(0, i.used), f = e(d), p = s(u);
19
+ if (i.total >= r) return {
20
+ title: a,
21
+ periodDescription: c,
22
+ used: d,
23
+ total: i.total,
24
+ usedLabel: f,
25
+ isUnlimited: !0,
26
+ status: t.Default,
27
+ progressAriaLabel: l(n.unlimitedProgressAriaLabel, { used: f }),
28
+ ...p
29
+ };
30
+ let m = Math.max(i.total, 0), h = Math.max(m - d, 0), g = m > 0 ? d / m * 100 : 100, _ = e(m);
31
+ return {
32
+ title: a,
33
+ periodDescription: c,
34
+ used: d,
35
+ total: m,
36
+ usedLabel: f,
37
+ totalLabel: _,
38
+ remainingLabel: e(h),
39
+ usedPercent: g,
40
+ status: o(g),
41
+ progressAriaLabel: l(n.progressAriaLabel, {
42
+ used: f,
43
+ total: _,
44
+ percent: Math.round(g)
45
+ }),
46
+ ...p
47
+ };
48
+ }, l = (e, t, r) => [
49
+ {
50
+ stats: e?.dayCostStats,
51
+ titleKey: n.todayTitle,
52
+ periodDescriptionKey: n.todayPeriodDescription
53
+ },
54
+ {
55
+ stats: e?.weekCostStats,
56
+ titleKey: n.thisWeekTitle,
57
+ periodDescriptionKey: n.thisWeekPeriodDescription
58
+ },
59
+ {
60
+ stats: e?.monthCostStats,
61
+ titleKey: n.thisMonthTitle,
62
+ periodDescriptionKey: n.thisMonthPeriodDescription
63
+ }
64
+ ].flatMap(({ stats: e, titleKey: n, periodDescriptionKey: i }) => a(e) ? [c(e, t(n), t(i), t, r(e.resetsAt))] : []);
65
+ //#endregion
66
+ export { n as USAGE_DATA_I18N_KEYS, l as mapUsageDataToDashboard };
@@ -0,0 +1,160 @@
1
+ import { formatCost as e } from "@epam/ai-dial-chat-shared";
2
+ import { DeploymentItemDtoTypeEnum as t } from "@epam/ai-dial-chat-api-client";
3
+ import { ModelLimitMetricKind as n, ModelLimitStatus as r } from "@epam/ai-dial-usage-dashboard";
4
+ //#region src/usage/map-user-usage-to-model-limits.ts
5
+ var i = 2 ** 53, a = 75, o = new Intl.NumberFormat(void 0, {
6
+ notation: "compact",
7
+ maximumFractionDigits: 1
8
+ }), s = new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }), c = {
9
+ todayPeriodDescription: "usage.todayPeriodDescription",
10
+ thisWeekPeriodDescription: "usage.thisWeekPeriodDescription",
11
+ thisMonthPeriodDescription: "usage.thisMonthPeriodDescription",
12
+ overallCostLimitRunningLowTooltip: "usage.overallCostLimitRunningLowTooltip",
13
+ overallCostLimitReachedTooltip: "usage.overallCostLimitReachedTooltip",
14
+ unavailableLabel: "usage.unavailableLabel",
15
+ followsCostLimitLabel: "usage.followsCostLimitLabel",
16
+ noLimitLabel: "usage.noLimitLabel",
17
+ followsCostLimitAriaLabel: "usage.followsCostLimitAriaLabel",
18
+ unlimitedProgressAriaLabel: "usage.unlimitedProgressAriaLabel",
19
+ progressAriaLabel: "usage.progressAriaLabel",
20
+ spentLabel: "usage.spentLabel"
21
+ }, l = {
22
+ day: {
23
+ cost: "dayCostStats",
24
+ tokens: "dayTokenStats"
25
+ },
26
+ week: {
27
+ cost: "weekCostStats",
28
+ tokens: "weekTokenStats"
29
+ },
30
+ month: {
31
+ cost: "monthCostStats",
32
+ tokens: "monthTokenStats"
33
+ }
34
+ }, u = {
35
+ day: {
36
+ field: "dayCostStats",
37
+ labelKey: c.todayPeriodDescription
38
+ },
39
+ week: {
40
+ field: "weekCostStats",
41
+ labelKey: c.thisWeekPeriodDescription
42
+ },
43
+ month: {
44
+ field: "monthCostStats",
45
+ labelKey: c.thisMonthPeriodDescription
46
+ }
47
+ }, d = (e) => e != null && Number.isFinite(e.total) && Number.isFinite(e.used), f = (e) => e >= 100 ? r.LimitReached : e >= a ? r.RunningLow : r.WithinLimits, p = (e) => {
48
+ if (!d(e)) return r.Unavailable;
49
+ if (e.total >= i) return r.NoLimit;
50
+ let t = Math.max(0, e.used), n = Math.max(0, e.total);
51
+ return f(n > 0 ? t / n * 100 : 100);
52
+ }, m = (e) => e === r.WithinLimits || e === r.RunningLow || e === r.LimitReached, h = (e, t, n, i, a) => {
53
+ let o = e?.[t.field], s = p(o), l = a(o?.resetsAt), u = i(t.labelKey).toLocaleLowerCase(n);
54
+ return {
55
+ status: s,
56
+ tooltipLabel: s === r.LimitReached ? i(c.overallCostLimitReachedTooltip, { period: u }) : s === r.RunningLow ? i(c.overallCostLimitRunningLowTooltip, { period: u }) : void 0,
57
+ ...l ? {
58
+ resetLabel: l.label,
59
+ resetIsoValue: l.isoValue,
60
+ resetAriaLabel: l.ariaLabel
61
+ } : {}
62
+ };
63
+ }, g = () => void 0, _ = (e, t, n, r = g) => ({
64
+ day: h(e, u.day, t, n, r),
65
+ week: h(e, u.week, t, n, r),
66
+ month: h(e, u.month, t, n, r)
67
+ }), v = (e) => ({
68
+ kind: n.Unavailable,
69
+ ariaLabel: e(c.unavailableLabel)
70
+ }), y = (e, t, r) => {
71
+ if (!d(e)) return v(r);
72
+ let a = Math.max(0, e.used), l = o.format(a);
73
+ if (e.total >= i) {
74
+ let e = m(t);
75
+ return {
76
+ kind: n.Unlimited,
77
+ usedLabel: l,
78
+ supportingLabel: r(e ? c.followsCostLimitLabel : c.noLimitLabel),
79
+ ariaLabel: r(e ? c.followsCostLimitAriaLabel : c.unlimitedProgressAriaLabel, { used: s.format(a) })
80
+ };
81
+ }
82
+ let u = Math.max(e.total, 0), p = o.format(u), h = u > 0 ? a / u * 100 : 100, g = f(h);
83
+ return {
84
+ kind: n.Finite,
85
+ usedLabel: l,
86
+ totalLabel: p,
87
+ usedPercent: h,
88
+ status: g,
89
+ ariaLabel: r(c.progressAriaLabel, {
90
+ used: s.format(a),
91
+ total: s.format(u),
92
+ percent: Math.round(h)
93
+ })
94
+ };
95
+ }, b = (t, r) => {
96
+ if (!d(t)) return v(r);
97
+ let a = Math.max(0, t.used), o = r(c.spentLabel, { amount: e(a) });
98
+ if (t.total >= i) return {
99
+ kind: n.Unlimited,
100
+ usedLabel: o,
101
+ ariaLabel: o
102
+ };
103
+ let s = Math.max(t.total, 0), l = s > 0 ? a / s * 100 : 100;
104
+ return {
105
+ kind: n.Finite,
106
+ usedLabel: o,
107
+ totalLabel: e(s),
108
+ usedPercent: l,
109
+ status: f(l),
110
+ ariaLabel: r(c.progressAriaLabel, {
111
+ used: e(a),
112
+ total: e(s),
113
+ percent: Math.round(l)
114
+ })
115
+ };
116
+ }, x = (e, t, n, r) => ({
117
+ tokens: y(e[t.tokens], n, r),
118
+ cost: b(e[t.cost], r)
119
+ }), S = (e) => e.filter((e) => e.kind === n.Finite).map((e) => e.status), C = (e, t, i) => {
120
+ let a = [
121
+ ...S(e),
122
+ ...S(t),
123
+ ...i
124
+ ].filter((e) => e != null && m(e));
125
+ return a.includes(r.LimitReached) ? r.LimitReached : a.includes(r.RunningLow) ? r.RunningLow : a.includes(r.WithinLimits) ? r.WithinLimits : e.some((e) => e.kind === n.Unlimited) || i.includes(r.NoLimit) ? r.NoLimit : r.Unavailable;
126
+ }, w = (e) => e.some((e) => d(e) && e.used > 0), T = (e, n, r, i, a, o) => {
127
+ let s = e?.deployments;
128
+ if (s == null) return [];
129
+ let c = new Map(n.filter((e) => e.type === t.Model).map((e) => [e.id, e])), u = _(e, r, i);
130
+ return Object.keys(s).map((e) => {
131
+ let t = c.get(e), n = t == null ? e : o(t.displayName, r) || t.id, d = s[e], f = a(t?.iconUrl), p = x(d, l.day, u.day.status, i), m = x(d, l.week, u.week.status, i), h = x(d, l.month, u.month.status, i), g = Object.values(l).flatMap(({ cost: e, tokens: t }) => [d[e], d[t]]);
132
+ return {
133
+ row: {
134
+ id: e,
135
+ name: n,
136
+ version: t?.displayVersion,
137
+ avatarSrc: f,
138
+ day: p,
139
+ week: m,
140
+ month: h,
141
+ status: C([
142
+ p.tokens,
143
+ m.tokens,
144
+ h.tokens
145
+ ], [
146
+ p.cost,
147
+ m.cost,
148
+ h.cost
149
+ ], [
150
+ u.day.status,
151
+ u.week.status,
152
+ u.month.status
153
+ ])
154
+ },
155
+ hasUsage: w(g)
156
+ };
157
+ }).filter(({ hasUsage: e }) => e).map(({ row: e }) => e);
158
+ };
159
+ //#endregion
160
+ export { c as USAGE_MODEL_LIMITS_I18N_KEYS, _ as mapOverallCostLimitsToPeriodStatuses, T as mapUserUsageToModelLimits };
package/usage.d.ts ADDED
@@ -0,0 +1,120 @@
1
+ import { DeploymentItemDto } from '@epam/ai-dial-chat-api-client';
2
+ import { ModelLimitPeriodStatuses } from '@epam/ai-dial-usage-dashboard';
3
+ import { ModelLimitRow } from '@epam/ai-dial-usage-dashboard';
4
+ import { UsageLimitCardData } from '@epam/ai-dial-usage-dashboard';
5
+ import { UserLimitStatsResponseDto } from '@epam/ai-dial-chat-api-client';
6
+
7
+ /** Formats a raw `resetsAt` into display strings, or returns `undefined` when it cannot be formatted. */
8
+ export declare type FormatResetTime = (resetsAt: string | undefined) => ResetTimeDisplay | undefined;
9
+
10
+ /**
11
+ * Maps the same top-level Cost budgets used by the aggregate cards into table-header state.
12
+ *
13
+ * @param formatResetTime - Formats each period's top-level `resetsAt` into the header's reset trio. Omit it to produce statuses with no reset fields.
14
+ */
15
+ export declare const mapOverallCostLimitsToPeriodStatuses: (usage: UserLimitStatsResponseDto | undefined, activeLocale: string, t: Translate_2, formatResetTime?: FormatResetTime) => ModelLimitPeriodStatuses;
16
+
17
+ /**
18
+ * Maps a `UserLimitStatsResponseDto` into `UsageLimitCardGroup`'s `cards` prop,
19
+ * in Today / This week / This month order. A period is omitted entirely when
20
+ * the response carries no usable stat for it. Each card's reset trio comes from
21
+ * `formatResetTime`, and is absent when that callback returns `undefined`.
22
+ */
23
+ export declare const mapUsageDataToDashboard: (usage: UserLimitStatsResponseDto | undefined, t: Translate, formatResetTime: FormatResetTime) => UsageLimitCardData[];
24
+
25
+ /**
26
+ * Maps `usage.deployments` into `ModelLimitsSection`'s `rows` prop, joined with model identity
27
+ * from `deploymentItems`. Rows are included only when any displayed period stat has nonzero usage.
28
+ * Order follows `Object.keys(deployments)` — `deploymentItems` is enrichment-only.
29
+ *
30
+ * @param resolveIconUrl - Resolves a deployment's raw `iconUrl` to the URL the avatar should load.
31
+ * @param resolveDisplayName - Resolves a localized-text map or plain string to the display name for `activeLocale`.
32
+ */
33
+ export declare const mapUserUsageToModelLimits: (usage: UserLimitStatsResponseDto | undefined, deploymentItems: DeploymentItemDto[], activeLocale: string, t: Translate_2, resolveIconUrl: ResolveIconUrl, resolveDisplayName: ResolveDisplayName) => ModelLimitRow[];
34
+
35
+ /**
36
+ * One reset time, already parsed and formatted by the host. Declared
37
+ * structurally here so this library never imports an application type; the
38
+ * host passes a value that satisfies this shape (e.g. `apps/chat`'s own
39
+ * `ResetTimeDisplay`).
40
+ */
41
+ export declare interface ResetTimeDisplay {
42
+ /** Exclusive end of the period as an epoch ms value, for the host's boundary scheduling. */
43
+ resetsAtMs: number;
44
+ /** Machine-readable instant for a `<time dateTime>` attribute. */
45
+ isoValue: string;
46
+ /** Visible reset line. */
47
+ label: string;
48
+ /** Accessible expansion of the reset line. */
49
+ ariaLabel: string;
50
+ }
51
+
52
+ /** A callback that resolves a display name from a localized-text value. */
53
+ declare type ResolveDisplayName = (name: string | Record<string, string> | undefined | null, locale: string) => string;
54
+
55
+ /** A callback that resolves an icon URL from a deployment's raw `iconUrl` field. */
56
+ declare type ResolveIconUrl = (iconUrl: string | undefined) => string | undefined;
57
+
58
+ /** A translate function compatible with i18next's `TFunction`. */
59
+ declare type Translate = (key: string, options?: Record<string, unknown>) => string;
60
+
61
+ /** A translate function compatible with i18next's `TFunction`. */
62
+ declare type Translate_2 = (key: string, options?: Record<string, unknown>) => string;
63
+
64
+ /**
65
+ * i18n key strings that the consuming app's translation bundle must define for
66
+ * `mapUsageDataToDashboard` to produce correctly translated strings. The
67
+ * values are the default key paths used by AI DIAL Chat.
68
+ */
69
+ export declare const USAGE_DATA_I18N_KEYS: {
70
+ /** Title for the current-UTC-day card (e.g. `'Today'`). */
71
+ readonly todayTitle: "usage.todayTitle";
72
+ /** Accessible period description for the current-UTC-day card. */
73
+ readonly todayPeriodDescription: "usage.todayPeriodDescription";
74
+ /** Title for the current-UTC-week card (e.g. `'This week'`). */
75
+ readonly thisWeekTitle: "usage.thisWeekTitle";
76
+ /** Accessible period description for the current-UTC-week card. */
77
+ readonly thisWeekPeriodDescription: "usage.thisWeekPeriodDescription";
78
+ /** Title for the current-UTC-month card (e.g. `'This month'`). */
79
+ readonly thisMonthTitle: "usage.thisMonthTitle";
80
+ /** Accessible period description for the current-UTC-month card. */
81
+ readonly thisMonthPeriodDescription: "usage.thisMonthPeriodDescription";
82
+ /** Aria label when there is no limit. Receives `{ used: string }`. */
83
+ readonly unlimitedProgressAriaLabel: "usage.unlimitedProgressAriaLabel";
84
+ /** Aria label for a progress bar with a finite limit. Receives `{ used: string, total: string, percent: number }`. */
85
+ readonly progressAriaLabel: "usage.progressAriaLabel";
86
+ };
87
+
88
+ /**
89
+ * i18n key strings that the consuming app's translation bundle must define for
90
+ * `mapUserUsageToModelLimits` and `mapOverallCostLimitsToPeriodStatuses` to produce
91
+ * correctly translated strings. The values are the default key paths used by AI DIAL Chat.
92
+ */
93
+ export declare const USAGE_MODEL_LIMITS_I18N_KEYS: {
94
+ /** Period label used in tooltip text. Receives no interpolation. */
95
+ readonly todayPeriodDescription: "usage.todayPeriodDescription";
96
+ /** Period label used in tooltip text. Receives no interpolation. */
97
+ readonly thisWeekPeriodDescription: "usage.thisWeekPeriodDescription";
98
+ /** Period label used in tooltip text. Receives no interpolation. */
99
+ readonly thisMonthPeriodDescription: "usage.thisMonthPeriodDescription";
100
+ /** Tooltip when the overall cost limit is running low. Receives `{ period: string }`. */
101
+ readonly overallCostLimitRunningLowTooltip: "usage.overallCostLimitRunningLowTooltip";
102
+ /** Tooltip when the overall cost limit is reached. Receives `{ period: string }`. */
103
+ readonly overallCostLimitReachedTooltip: "usage.overallCostLimitReachedTooltip";
104
+ /** Aria label for a metric cell with no data. */
105
+ readonly unavailableLabel: "usage.unavailableLabel";
106
+ /** Supporting label when a token limit follows the cost limit. */
107
+ readonly followsCostLimitLabel: "usage.followsCostLimitLabel";
108
+ /** Supporting label when there is no per-deployment token limit. */
109
+ readonly noLimitLabel: "usage.noLimitLabel";
110
+ /** Aria label when token usage has no limit but follows the cost limit. Receives `{ used: string }`. */
111
+ readonly followsCostLimitAriaLabel: "usage.followsCostLimitAriaLabel";
112
+ /** Aria label when there is no limit. Receives `{ used: string }`. */
113
+ readonly unlimitedProgressAriaLabel: "usage.unlimitedProgressAriaLabel";
114
+ /** Aria label for a progress bar with a finite limit. Receives `{ used: string, total: string, percent: number }`. */
115
+ readonly progressAriaLabel: "usage.progressAriaLabel";
116
+ /** Label for the spent-cost cell. Receives `{ amount: string }`. */
117
+ readonly spentLabel: "usage.spentLabel";
118
+ };
119
+
120
+ export { }
package/usage.js ADDED
@@ -0,0 +1,3 @@
1
+ import { USAGE_DATA_I18N_KEYS as e, mapUsageDataToDashboard as t } from "./usage/map-usage-data-to-dashboard.js";
2
+ import { USAGE_MODEL_LIMITS_I18N_KEYS as n, mapOverallCostLimitsToPeriodStatuses as r, mapUserUsageToModelLimits as i } from "./usage/map-user-usage-to-model-limits.js";
3
+ export { e as USAGE_DATA_I18N_KEYS, n as USAGE_MODEL_LIMITS_I18N_KEYS, r as mapOverallCostLimitsToPeriodStatuses, t as mapUsageDataToDashboard, i as mapUserUsageToModelLimits };