@epam/ai-dial-chat-hooks 1.3.1 → 1.3.2

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.
@@ -0,0 +1,9 @@
1
+ import { OrgUnit } from '@epam/ai-dial-chat-shared';
2
+ /** What the host's org-units read resolves to. */
3
+ export interface OrgUnitsListResult {
4
+ /** `false` when DIAL Core has org units turned off. */
5
+ enabled: boolean;
6
+ /** The units the current user may see. */
7
+ units: OrgUnit[];
8
+ }
9
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/org-units/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,OAAO,EAAE,OAAO,CAAC;IACjB,0CAA0C;IAC1C,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB"}
@@ -0,0 +1,14 @@
1
+ /** Load state of the org units read by `useOrgUnits`. */
2
+ export declare enum OrgUnitsStatus {
3
+ /** Nothing has asked for the units yet. */
4
+ Idle = "idle",
5
+ /** The read is in flight. */
6
+ Loading = "loading",
7
+ /** The units are loaded. */
8
+ Ready = "ready",
9
+ /** DIAL Core has org units turned off. */
10
+ Disabled = "disabled",
11
+ /** The read failed; no units are known. */
12
+ Error = "error"
13
+ }
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/org-units/types.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,oBAAY,cAAc;IACxB,2CAA2C;IAC3C,IAAI,SAAS;IACb,6BAA6B;IAC7B,OAAO,YAAY;IACnB,4BAA4B;IAC5B,KAAK,UAAU;IACf,0CAA0C;IAC1C,QAAQ,aAAa;IACrB,2CAA2C;IAC3C,KAAK,UAAU;CAChB"}
@@ -0,0 +1,6 @@
1
+ //#region src/org-units/types.ts
2
+ var e = /* @__PURE__ */ function(e) {
3
+ return e.Idle = "idle", e.Loading = "loading", e.Ready = "ready", e.Disabled = "disabled", e.Error = "error", e;
4
+ }({});
5
+ //#endregion
6
+ export { e as OrgUnitsStatus };
@@ -0,0 +1,19 @@
1
+ import { OrgUnitsListResult } from '../models';
2
+ import { OrgUnitsStatus } from '../types';
3
+ /** Options for {@link useOrgUnits}. */
4
+ export interface UseOrgUnitsOptions {
5
+ /** Reads the org units visible to the current user; supplied by the host. */
6
+ listOrgUnits: () => Promise<OrgUnitsListResult>;
7
+ }
8
+ /** State returned by {@link useOrgUnits}. */
9
+ export interface UseOrgUnitsResult {
10
+ /** Load state of the units. */
11
+ status: OrgUnitsStatus;
12
+ /** Starts the read on its first call, and again after a failed read; otherwise does nothing. */
13
+ ensureUnits: () => void;
14
+ /** Whether a public-bucket path is a unit's own folder; `false` until the units are loaded. */
15
+ isOrgUnitFolder: (publicPath: string) => boolean;
16
+ }
17
+ /** Loads the current user's org units once, on demand, and answers which public folders are units. */
18
+ export declare const useOrgUnits: ({ listOrgUnits, }: UseOrgUnitsOptions) => UseOrgUnitsResult;
19
+ //# sourceMappingURL=useOrgUnits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOrgUnits.d.ts","sourceRoot":"","sources":["../../../src/org-units/useOrgUnits/useOrgUnits.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,YAAY,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACjD;AAED,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,+BAA+B;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,gGAAgG;IAChG,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,+FAA+F;IAC/F,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;CAClD;AAED,sGAAsG;AACtG,eAAO,MAAM,WAAW,GAAI,mBAEzB,kBAAkB,KAAG,iBAoDvB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { OrgUnitsStatus as e } from "../types.js";
2
+ import { isOrgUnitFolder as t, toOrgUnitFolderSet as n } from "@epam/ai-dial-chat-shared";
3
+ import { useCallback as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
4
+ //#region src/org-units/useOrgUnits/useOrgUnits.ts
5
+ var c = ({ listOrgUnits: c }) => {
6
+ let [l, u] = s([]), [d, f] = s(e.Idle), p = o(!1), m = o(!0), h = o(c);
7
+ h.current = c, i(() => (m.current = !0, () => {
8
+ m.current = !1;
9
+ }), []);
10
+ let g = r(async () => {
11
+ f(e.Loading);
12
+ try {
13
+ let t = await h.current();
14
+ if (!m.current) return;
15
+ if (!t.enabled) {
16
+ u([]), f(e.Disabled);
17
+ return;
18
+ }
19
+ u(t.units), f(e.Ready);
20
+ } catch {
21
+ if (p.current = !1, !m.current) return;
22
+ u([]), f(e.Error);
23
+ }
24
+ }, []), _ = r(() => {
25
+ p.current || (p.current = !0, g());
26
+ }, [g]), v = a(() => n(l), [l]);
27
+ return {
28
+ status: d,
29
+ ensureUnits: _,
30
+ isOrgUnitFolder: r((n) => d === e.Ready && t(v, n), [d, v])
31
+ };
32
+ };
33
+ //#endregion
34
+ export { c as useOrgUnits };
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.3.1",
4
+ "version": "1.3.2",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -131,7 +131,7 @@
131
131
  }
132
132
  },
133
133
  "dependencies": {
134
- "@epam/ai-dial-chat-api-client": "1.3.1",
134
+ "@epam/ai-dial-chat-api-client": "1.3.2",
135
135
  "dompurify": "3.4.17",
136
136
  "fflate": "^0.8.3",
137
137
  "lru-cache": "^10.4.3",
@@ -140,23 +140,23 @@
140
140
  },
141
141
  "peerDependencies": {
142
142
  "react": "^19.2.8",
143
- "@epam/ai-dial-attachment-canvas": "1.3.1",
144
- "@epam/ai-dial-attachment-input": "1.3.1",
145
- "@epam/ai-dial-catalog": "1.3.1",
146
- "@epam/ai-dial-chat-overlay": "1.3.1",
147
- "@epam/ai-dial-chat-shared": "1.3.1",
148
- "@epam/ai-dial-conversation-input": "1.3.1",
149
- "@epam/ai-dial-mcp-apps": "1.3.1",
150
- "@epam/ai-dial-projects": "1.3.1",
151
- "@epam/ai-dial-publish-panel": "1.3.1",
152
- "@epam/ai-dial-quotations": "1.3.1",
143
+ "@epam/ai-dial-attachment-canvas": "1.3.2",
144
+ "@epam/ai-dial-attachment-input": "1.3.2",
145
+ "@epam/ai-dial-catalog": "1.3.2",
146
+ "@epam/ai-dial-chat-overlay": "1.3.2",
147
+ "@epam/ai-dial-chat-shared": "1.3.2",
148
+ "@epam/ai-dial-conversation-input": "1.3.2",
149
+ "@epam/ai-dial-mcp-apps": "1.3.2",
150
+ "@epam/ai-dial-projects": "1.3.2",
151
+ "@epam/ai-dial-publish-panel": "1.3.2",
152
+ "@epam/ai-dial-quotations": "1.3.2",
153
153
  "@epam/ai-dial-react-file-manager": "^0.4.1",
154
- "@epam/ai-dial-scheduled-tasks": "1.3.1",
155
- "@epam/ai-dial-share": "1.3.1",
156
- "@epam/ai-dial-skill-editor": "1.3.1",
157
- "@epam/ai-dial-source-panel": "1.3.1",
154
+ "@epam/ai-dial-scheduled-tasks": "1.3.2",
155
+ "@epam/ai-dial-share": "1.3.2",
156
+ "@epam/ai-dial-skill-editor": "1.3.2",
157
+ "@epam/ai-dial-source-panel": "1.3.2",
158
158
  "@epam/ai-dial-ui-kit": "^0.16.0",
159
- "@epam/ai-dial-usage-dashboard": "1.3.1",
159
+ "@epam/ai-dial-usage-dashboard": "1.3.2",
160
160
  "@modelcontextprotocol/sdk": "^1.32.2",
161
161
  "@epam/pdf-highlighter-kit": "^0.0.22"
162
162
  },
package/utils.js CHANGED
@@ -20,4 +20,6 @@ import { triggerBrowserDownload as ne } from "./files/browser-download.js";
20
20
  import { usePersistedState as re } from "./shared/usePersistedState/usePersistedState.js";
21
21
  import { useAppVersionCheck as ie } from "./shared/useAppVersionCheck/useAppVersionCheck.js";
22
22
  import { getCleanedLocationTarget as ae } from "./shared/url-cleanup.js";
23
- export { Q as ColorScheme, Y as EXTERNAL_SERVICE_SIGNIN_METHOD, j as PROMPT_CONTENT_MAX_LENGTH, M as PROMPT_COUNTER_ANNOUNCE_THRESHOLD, N as PROMPT_DESCRIPTION_MAX_LENGTH, P as PROMPT_FIELD_VALIDATORS, F as PROMPT_NAME_MAX_LENGTH, X as PendingSigninEventKind, I as PromptFieldError, b as PromptSource, Z as TOOLSET_SIGNIN_METHOD, U as apSchedulerDayToJsDay, f as appendLocaleCode, $ as applyThemeColors, p as buildAdditionalLocaleOptions, T as buildExternalServiceScopeId, O as buildPromptExportEnvelope, k as buildPromptExportFileName, L as buildPromptPath, m as composeLocalePayload, a as createCsrfMiddleware, o as createUnauthorizedMiddleware, h as decomposeLocalizedFields, v as formatCalendarDate, e as getAcceptInvitationErrorItemName, t as getApiErrorDetails, n as getApiErrorMessage, r as getApiErrorStatus, G as getBrowserTimezone, ae as getCleanedLocationTarget, E as getExternalServiceFallbackName, ee as getOsPreferredTheme, R as getRemainingCharacters, S as getRunnerSchemas, s as includesIgnoreCase, i as isConversationNotFoundError, C as isCustomAppSchema, w as isQuickAppSchema, K as isValidAbsoluteUrl, q as isValidFeaturesData, W as jsDayToApSchedulerDay, y as padTwoDigits, D as parseExternalServiceUrl, J as parseFeaturesData, x as parsePromptResourceUrl, g as resolveLocalizedText, c as safeDecodeURI, l as safeDecodeURIComponent, A as serializePromptExport, u as stripSurroundingSlashes, d as stripTrailingSlashes, _ as toBaseLocale, ne as triggerBrowserDownload, ie as useAppVersionCheck, re as usePersistedState, H as usePromptsState, te as useUsageData, z as validatePromptContent, B as validatePromptDescription, V as validatePromptName };
23
+ import { OrgUnitsStatus as oe } from "./org-units/types.js";
24
+ import { useOrgUnits as se } from "./org-units/useOrgUnits/useOrgUnits.js";
25
+ export { Q as ColorScheme, Y as EXTERNAL_SERVICE_SIGNIN_METHOD, oe as OrgUnitsStatus, j as PROMPT_CONTENT_MAX_LENGTH, M as PROMPT_COUNTER_ANNOUNCE_THRESHOLD, N as PROMPT_DESCRIPTION_MAX_LENGTH, P as PROMPT_FIELD_VALIDATORS, F as PROMPT_NAME_MAX_LENGTH, X as PendingSigninEventKind, I as PromptFieldError, b as PromptSource, Z as TOOLSET_SIGNIN_METHOD, U as apSchedulerDayToJsDay, f as appendLocaleCode, $ as applyThemeColors, p as buildAdditionalLocaleOptions, T as buildExternalServiceScopeId, O as buildPromptExportEnvelope, k as buildPromptExportFileName, L as buildPromptPath, m as composeLocalePayload, a as createCsrfMiddleware, o as createUnauthorizedMiddleware, h as decomposeLocalizedFields, v as formatCalendarDate, e as getAcceptInvitationErrorItemName, t as getApiErrorDetails, n as getApiErrorMessage, r as getApiErrorStatus, G as getBrowserTimezone, ae as getCleanedLocationTarget, E as getExternalServiceFallbackName, ee as getOsPreferredTheme, R as getRemainingCharacters, S as getRunnerSchemas, s as includesIgnoreCase, i as isConversationNotFoundError, C as isCustomAppSchema, w as isQuickAppSchema, K as isValidAbsoluteUrl, q as isValidFeaturesData, W as jsDayToApSchedulerDay, y as padTwoDigits, D as parseExternalServiceUrl, J as parseFeaturesData, x as parsePromptResourceUrl, g as resolveLocalizedText, c as safeDecodeURI, l as safeDecodeURIComponent, A as serializePromptExport, u as stripSurroundingSlashes, d as stripTrailingSlashes, _ as toBaseLocale, ne as triggerBrowserDownload, ie as useAppVersionCheck, se as useOrgUnits, re as usePersistedState, H as usePromptsState, te as useUsageData, z as validatePromptContent, B as validatePromptDescription, V as validatePromptName };