@declarion/react 0.109.0 → 0.110.0
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/dist-lib/api/agents.js +2 -1
- package/dist-lib/api/audience.js +12 -0
- package/dist-lib/api/auth.js +1 -1
- package/dist-lib/api/client.js +100 -91
- package/dist-lib/api/schema.js +31 -31
- package/dist-lib/components/agents/ChatAttachments.js +20 -10
- package/dist-lib/components/file-widgets/DocumentCard.js +1 -1
- package/dist-lib/components/file-widgets/FileList.js +1 -1
- package/dist-lib/components/file-widgets/Grid.js +1 -1
- package/dist-lib/components/file-widgets/upload.js +64 -61
- package/dist-lib/hooks/useAgentConversation.js +112 -104
- package/dist-lib/hooks/useAuth.js +4 -1
- package/dist-lib/hooks/useSchema.js +21 -29
- package/dist-lib/index.d.ts +3 -3
- package/dist-lib/stores/auth.js +35 -35
- package/dist-lib/test/seed-schema.js +4 -3
- package/dist-lib/testing.d.ts +1 -1
- package/dist-lib/{useResponsiveMode-DODbtSrY.d.ts → useResponsiveMode-C4MeAgoS.d.ts} +0 -1
- package/package.json +1 -1
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { sameAudience as e, sessionCaller as t } from "../api/audience.js";
|
|
2
|
+
import { fetchSchema as n } from "../api/schema.js";
|
|
3
|
+
import { useEmbed as r } from "../embed/EmbedContext.js";
|
|
4
|
+
import { useAuthStore as i } from "../stores/auth.js";
|
|
5
|
+
import { useEffect as a } from "react";
|
|
6
|
+
import { useQuery as o, useQueryClient as s } from "@tanstack/react-query";
|
|
6
7
|
//#region src/hooks/useSchema.ts
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
if (
|
|
10
|
-
user_id: e.user.id,
|
|
11
|
-
tenant_id: e.activeTenant?.id ?? ""
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function c(e, t) {
|
|
15
|
-
return e === t || e !== null && t !== null && e.user_id === t.user_id && e.tenant_id === t.tenant_id;
|
|
16
|
-
}
|
|
17
|
-
function l(e, t) {
|
|
18
|
-
if (e && t !== void 0 && c(e.audience, t)) return e.schema;
|
|
8
|
+
var c = ["schema"];
|
|
9
|
+
function l(t, n) {
|
|
10
|
+
if (t && n !== void 0 && e(t.audience, n)) return t.schema;
|
|
19
11
|
}
|
|
20
12
|
function u(e) {
|
|
21
|
-
return l(e.getQueryData(
|
|
13
|
+
return l(e.getQueryData(c), t(i.getState()));
|
|
22
14
|
}
|
|
23
15
|
function d(e, t) {
|
|
24
16
|
return {
|
|
@@ -35,24 +27,24 @@ function p(e) {
|
|
|
35
27
|
function m(e) {
|
|
36
28
|
if (e.rereading) return;
|
|
37
29
|
e.rereading = !0;
|
|
38
|
-
let t =
|
|
30
|
+
let t = i.getState();
|
|
39
31
|
(t.isAuthenticated ? t.reloadSession : t.recheckSession)().finally(() => {
|
|
40
|
-
e.rereadFor =
|
|
32
|
+
e.rereadFor = i.getState().identitySince, e.rereading = !1;
|
|
41
33
|
});
|
|
42
34
|
}
|
|
43
35
|
function h() {
|
|
44
|
-
let
|
|
45
|
-
isLoading:
|
|
36
|
+
let e = i((e) => e.isLoading), u = i((e) => e.isAuthenticated), d = i((e) => e.user), f = i((e) => e.activeTenant), h = i((e) => e.identitySince), g = t({
|
|
37
|
+
isLoading: e,
|
|
46
38
|
isAuthenticated: u,
|
|
47
39
|
user: d,
|
|
48
40
|
activeTenant: f
|
|
49
|
-
}), _ =
|
|
50
|
-
queryKey:
|
|
51
|
-
queryFn:
|
|
41
|
+
}), _ = i((e) => e.sessionPresumed), v = r().enabled, y = p(s()), b = o({
|
|
42
|
+
queryKey: c,
|
|
43
|
+
queryFn: n,
|
|
52
44
|
staleTime: Infinity,
|
|
53
|
-
enabled: v ? u : _ || !
|
|
45
|
+
enabled: v ? u : _ || !e
|
|
54
46
|
}), x = b.data, S = l(x, g), C = x !== void 0 && g !== void 0 && S === void 0, w = C && x.requestedAt <= h, { refetch: T, isFetching: E } = b, D = C && !w, O = y.rereadFor === h;
|
|
55
|
-
return
|
|
47
|
+
return a(() => {
|
|
56
48
|
w && !E && y.refetchedFor !== h && (y.refetchedFor = h, T({ cancelRefetch: !1 }));
|
|
57
49
|
}, [
|
|
58
50
|
w,
|
|
@@ -60,7 +52,7 @@ function h() {
|
|
|
60
52
|
T,
|
|
61
53
|
y,
|
|
62
54
|
h
|
|
63
|
-
]),
|
|
55
|
+
]), a(() => {
|
|
64
56
|
D && !O && m(y);
|
|
65
57
|
}, [
|
|
66
58
|
D,
|
|
@@ -73,4 +65,4 @@ function h() {
|
|
|
73
65
|
};
|
|
74
66
|
}
|
|
75
67
|
//#endregion
|
|
76
|
-
export {
|
|
68
|
+
export { c as SCHEMA_QUERY_KEY, u as cachedSchema, d as schemaAnswerFor, l as schemaFor, t as sessionCaller, h as useSchema };
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as DynamicIcon, n as IconName, r as IconProps, t as Icon } from "./Icons-Dzl-AkD_.js";
|
|
2
2
|
import { i as setIconRegistry, n as getIcon, t as IconDef } from "./icon-registry-CUT4eF63.js";
|
|
3
|
-
import { $ as AreaDef, $t as HydratedFile, A as EnrichedRow, At as MANDATORY_LANGUAGE, B as Refs, Bt as FilterValueResolver, C as ApiErrorBody, Ct as fieldDisplayName, D as CURSOR_SEMANTICS_MISMATCH, Dt as pkValuesToDetailId, E as CURSOR_LANGUAGE_CHANGED, Et as pkValuesFromId, F as LoginResponse, Ft as pluralText, G as V2ListParams, Gt as parseFilterURLState, H as StatusInfo, Ht as OP_LABELS, I as ParamLookup, It as textWithNodes, J as V2ParamInstance, Jt as FileAddress, K as V2ListResponse, Kt as parseFiltersFromURL, L as PropertyValue, Lt as FilterNode, M as ListMeta, Mt as TextVars, N as ListParams, Nt as makeTextFn, O as CheckSetupResponse, Ot as pkValuesToId, P as ListResponse, Pt as pickLocalized, Q as Action, Qt as FileFieldValue, R as PublicParam, Rt as FilterOp, S as ApiError, St as extractPkValues, T as BrandingIdentity, Tt as pkValuePartsToId, U as Tenant, Ut as countActiveFilters, V as SignupResponse, Vt as NO_VALUE_OPS, W as TenantEnv, Wt as hasOrGroups, X as V2StatusInstance, Xt as FileFieldDisplay, Y as V2PropertyInstance, Yt as FileFieldDef, Z as isCursorStaleError, Zt as FileFieldMode, _ as executeAction$1, _t as StatusGroupDef, a as ResponsiveMode, at as FieldAccessInfo, b as AggregateParams, bt as buildEntityDetailHref, c as resolveViewportCategory, ct as NavNode, d as ActionExecuteResponse, dt as PropertyDef, en as UploadProgress, et as ChildRelation, f as ActionItemError, ft as RefConfig, g as deleteObject, gt as StatusDef, h as buildActionBody, ht as SpecialValue, i as ResponsiveBreakpoints, it as EnumDef, j as ImpersonationInfo, jt as TextFn, k as DataResponse, kt as resolveDetailRoute, l as ActionBatchError, lt as ParameterDef, m as GetEntityOptions, mt as Screen, n as useResponsiveMode, nn as OrderedMap, nt as Entity, o as ResponsiveViewport, ot as LanguageDef, p as ActionItemSkip, pt as Schema, q as V2Meta, qt as setFiltersInURL, r as DEFAULT_RESPONSIVE_BREAKPOINTS, rt as EntityField, s as ViewportCategory, st as LocalizedString, t as ResponsiveModeProvider, tn as UploadedFile, tt as ClassificationTierDef, u as ActionExecuteRequest, ut as PkValues, v as restoreObject, vt as StructureDef, w as AuthUser, wt as getPrimaryKeyFields, x as AggregateResponse, xt as buildRowDetailHref, y as AggregateGroup, yt as buildDetailHrefFromId, z as PublicParamsResponse, zt as FilterURLState } from "./useResponsiveMode-
|
|
3
|
+
import { $ as AreaDef, $t as HydratedFile, A as EnrichedRow, At as MANDATORY_LANGUAGE, B as Refs, Bt as FilterValueResolver, C as ApiErrorBody, Ct as fieldDisplayName, D as CURSOR_SEMANTICS_MISMATCH, Dt as pkValuesToDetailId, E as CURSOR_LANGUAGE_CHANGED, Et as pkValuesFromId, F as LoginResponse, Ft as pluralText, G as V2ListParams, Gt as parseFilterURLState, H as StatusInfo, Ht as OP_LABELS, I as ParamLookup, It as textWithNodes, J as V2ParamInstance, Jt as FileAddress, K as V2ListResponse, Kt as parseFiltersFromURL, L as PropertyValue, Lt as FilterNode, M as ListMeta, Mt as TextVars, N as ListParams, Nt as makeTextFn, O as CheckSetupResponse, Ot as pkValuesToId, P as ListResponse, Pt as pickLocalized, Q as Action, Qt as FileFieldValue, R as PublicParam, Rt as FilterOp, S as ApiError, St as extractPkValues, T as BrandingIdentity, Tt as pkValuePartsToId, U as Tenant, Ut as countActiveFilters, V as SignupResponse, Vt as NO_VALUE_OPS, W as TenantEnv, Wt as hasOrGroups, X as V2StatusInstance, Xt as FileFieldDisplay, Y as V2PropertyInstance, Yt as FileFieldDef, Z as isCursorStaleError, Zt as FileFieldMode, _ as executeAction$1, _t as StatusGroupDef, a as ResponsiveMode, at as FieldAccessInfo, b as AggregateParams, bt as buildEntityDetailHref, c as resolveViewportCategory, ct as NavNode, d as ActionExecuteResponse, dt as PropertyDef, en as UploadProgress, et as ChildRelation, f as ActionItemError, ft as RefConfig, g as deleteObject, gt as StatusDef, h as buildActionBody, ht as SpecialValue, i as ResponsiveBreakpoints, it as EnumDef, j as ImpersonationInfo, jt as TextFn, k as DataResponse, kt as resolveDetailRoute, l as ActionBatchError, lt as ParameterDef, m as GetEntityOptions, mt as Screen, n as useResponsiveMode, nn as OrderedMap, nt as Entity, o as ResponsiveViewport, ot as LanguageDef, p as ActionItemSkip, pt as Schema, q as V2Meta, qt as setFiltersInURL, r as DEFAULT_RESPONSIVE_BREAKPOINTS, rt as EntityField, s as ViewportCategory, st as LocalizedString, t as ResponsiveModeProvider, tn as UploadedFile, tt as ClassificationTierDef, u as ActionExecuteRequest, ut as PkValues, v as restoreObject, vt as StructureDef, w as AuthUser, wt as getPrimaryKeyFields, x as AggregateResponse, xt as buildRowDetailHref, y as AggregateGroup, yt as buildDetailHrefFromId, z as PublicParamsResponse, zt as FilterURLState } from "./useResponsiveMode-C4MeAgoS.js";
|
|
4
4
|
import { ButtonHTMLAttributes, CSSProperties, ComponentType, InputHTMLAttributes, MouseEvent, ReactNode, RefObject } from "react";
|
|
5
5
|
import { QueryClient, QueryKey, UseQueryResult } from "@tanstack/react-query";
|
|
6
6
|
import { useLocation, useNavigate, useParams, useSearchParams } from "react-router";
|
|
@@ -1923,7 +1923,7 @@ type UploadCheck = {
|
|
|
1923
1923
|
type: string;
|
|
1924
1924
|
};
|
|
1925
1925
|
export declare function validateClientSide(file: File, accepts: string[] | undefined, maxBytes: number | undefined): UploadCheck | null;
|
|
1926
|
-
export declare function formatBytes(n: number): string;
|
|
1926
|
+
export declare function formatBytes(n: number, language: string): string;
|
|
1927
1927
|
//#endregion
|
|
1928
1928
|
//#region src/components/file-widgets/useFileSelection.d.ts
|
|
1929
1929
|
type FileSelectionState = "uploading" | "failed" | "cancelled" | "ready";
|
|
@@ -2377,7 +2377,7 @@ interface AgentMessageContext {
|
|
|
2377
2377
|
screen: string;
|
|
2378
2378
|
record?: string;
|
|
2379
2379
|
}
|
|
2380
|
-
export declare function sendMessage(text: string, conversationId: string, context
|
|
2380
|
+
export declare function sendMessage(text: string, conversationId: string, context: AgentMessageContext | undefined, attachments: string[] | undefined, idempotencyKey: string): Promise<AgentMessage>;
|
|
2381
2381
|
export declare function answerQuestion(invocationId: string, answer: Record<string, unknown>): Promise<void>;
|
|
2382
2382
|
export declare function sendElicitResponse(_conversationId: string, invocationId: string, data: Record<string, unknown>): Promise<void>;
|
|
2383
2383
|
/** What a person permitted: this call alone, or the action for the rest of
|
package/dist-lib/stores/auth.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { isEmbedTokenMode as e } from "../embed/token.js";
|
|
2
|
+
import { startOrderNow as t } from "../api/access-expiry.js";
|
|
3
|
+
import { sessionCaller as n } from "../api/audience.js";
|
|
4
|
+
import { cancelProactiveRefresh as r, ensureRefresh as i, scheduleProactiveRefresh as a, setLanguageReader as o } from "../api/client.js";
|
|
5
|
+
import { getMe as s, listTenants as c, logout as l, probeSession as u } from "../api/auth.js";
|
|
6
|
+
import { warmRoutePages as d } from "../lib/capabilityPrefetch.js";
|
|
7
|
+
import { usePreferencesStore as f } from "./preferences.js";
|
|
8
|
+
import { create as p } from "zustand";
|
|
7
9
|
//#region src/stores/auth.ts
|
|
8
|
-
async function
|
|
10
|
+
async function m(e, t, n) {
|
|
9
11
|
try {
|
|
10
12
|
let r = await n();
|
|
11
|
-
|
|
13
|
+
a(r.access_expires_at), e({
|
|
12
14
|
user: r,
|
|
13
15
|
isAuthenticated: !0,
|
|
14
16
|
isLoading: !1,
|
|
@@ -25,7 +27,7 @@ async function f(e, t, n) {
|
|
|
25
27
|
});
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
|
-
var
|
|
30
|
+
var h = p((e, n) => ({
|
|
29
31
|
user: null,
|
|
30
32
|
isAuthenticated: !1,
|
|
31
33
|
isLoading: !0,
|
|
@@ -34,53 +36,51 @@ var p = d((r, i) => ({
|
|
|
34
36
|
sessionPresumed: !1,
|
|
35
37
|
identitySince: 0,
|
|
36
38
|
initialize: async () => {
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
+
let r = t();
|
|
40
|
+
r === "refresh-first" && (r = await i().then(() => "first-wave", () => "probe-first")), e({ sessionPresumed: r === "first-wave" }), r === "first-wave" && d(), await m(e, n, u), r === "probe-first" && n().isAuthenticated && d();
|
|
39
41
|
},
|
|
40
|
-
reloadSession: () =>
|
|
41
|
-
recheckSession: () =>
|
|
42
|
+
reloadSession: () => m(e, n, s),
|
|
43
|
+
recheckSession: () => m(e, n, u),
|
|
42
44
|
refreshMe: async () => {
|
|
43
45
|
try {
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
user:
|
|
47
|
-
activeTenant:
|
|
48
|
-
...
|
|
46
|
+
let t = await s(), r = n(), i = r.user?.id !== t.id || r.activeTenant?.id !== t.tenant?.id;
|
|
47
|
+
e({
|
|
48
|
+
user: t,
|
|
49
|
+
activeTenant: t.tenant ?? null,
|
|
50
|
+
...i ? { identitySince: performance.now() } : {}
|
|
49
51
|
});
|
|
50
52
|
} catch {}
|
|
51
53
|
},
|
|
52
|
-
setUser: (
|
|
53
|
-
|
|
54
|
-
user:
|
|
54
|
+
setUser: (t, n) => {
|
|
55
|
+
e({
|
|
56
|
+
user: t,
|
|
55
57
|
isAuthenticated: !0,
|
|
56
58
|
isLoading: !1,
|
|
57
|
-
activeTenant:
|
|
59
|
+
activeTenant: n ?? null,
|
|
58
60
|
identitySince: performance.now()
|
|
59
61
|
});
|
|
60
62
|
},
|
|
61
63
|
loadTenants: () => {
|
|
62
|
-
|
|
64
|
+
c().then((t) => e({ tenants: t }), () => void 0);
|
|
63
65
|
},
|
|
64
|
-
setActiveTenant: (
|
|
65
|
-
|
|
66
|
+
setActiveTenant: (t) => {
|
|
67
|
+
e({ activeTenant: t });
|
|
66
68
|
},
|
|
67
69
|
logout: async () => {
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
await s();
|
|
71
|
-
} catch {}
|
|
72
|
-
r({
|
|
70
|
+
r(), e({
|
|
73
71
|
user: null,
|
|
74
72
|
isAuthenticated: !1,
|
|
75
73
|
activeTenant: null,
|
|
76
74
|
tenants: [],
|
|
77
75
|
sessionPresumed: !1,
|
|
78
76
|
identitySince: performance.now()
|
|
79
|
-
});
|
|
77
|
+
}), await l(), _?.postMessage(g);
|
|
80
78
|
}
|
|
81
|
-
}));
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
})), g = "signed-out", _ = typeof BroadcastChannel == "function" ? new BroadcastChannel("declarion.auth") : null;
|
|
80
|
+
_?.addEventListener("message", (t) => {
|
|
81
|
+
t.data === g && !e() && h.getState().isAuthenticated && (r(), window.location.assign("/login"));
|
|
82
|
+
}), h.subscribe((e, t) => {
|
|
83
|
+
o(n(e)), e.user?.id !== t.user?.id && f.getState().startIdentity();
|
|
84
84
|
});
|
|
85
85
|
//#endregion
|
|
86
|
-
export {
|
|
86
|
+
export { h as useAuthStore };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { sessionCaller as e } from "../api/audience.js";
|
|
2
|
+
import { useAuthStore as t } from "../stores/auth.js";
|
|
3
|
+
import { SCHEMA_QUERY_KEY as n, schemaAnswerFor as r } from "../hooks/useSchema.js";
|
|
3
4
|
//#region src/test/seed-schema.ts
|
|
4
5
|
function i(i, a) {
|
|
5
|
-
|
|
6
|
+
t.getState().isLoading && t.setState({ isLoading: !1 }), i.setQueryData(n, r(a, e(t.getState()) ?? null));
|
|
6
7
|
}
|
|
7
8
|
//#endregion
|
|
8
9
|
export { i as seedSchemaCache };
|
package/dist-lib/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as Refs, M as ListMeta, P as ListResponse, d as ActionExecuteResponse, jt as TextFn, k as DataResponse, o as ResponsiveViewport, pt as Schema, st as LocalizedString, u as ActionExecuteRequest } from "./useResponsiveMode-
|
|
1
|
+
import { B as Refs, M as ListMeta, P as ListResponse, d as ActionExecuteResponse, jt as TextFn, k as DataResponse, o as ResponsiveViewport, pt as Schema, st as LocalizedString, u as ActionExecuteRequest } from "./useResponsiveMode-C4MeAgoS.js";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
3
|
import { QueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { RenderResult } from "@testing-library/react";
|