@declarion/react 0.106.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 +9 -7
- package/dist-lib/api/audience.js +12 -0
- package/dist-lib/api/auth.js +1 -1
- package/dist-lib/api/client.js +101 -93
- package/dist-lib/api/schema.js +31 -31
- package/dist-lib/components/agents/AgentChatPanel.impl.js +362 -301
- package/dist-lib/components/agents/ChatAttachments.js +154 -0
- package/dist-lib/components/agents/transcript-runs.js +1 -1
- package/dist-lib/components/chrome/AssociationTabs.js +89 -75
- package/dist-lib/components/detail-layout/AssociatedBlock.js +243 -235
- package/dist-lib/components/detail-layout/ChildrenCards.js +57 -55
- package/dist-lib/components/detail-layout/ChildrenList.js +45 -43
- package/dist-lib/components/detail-layout/ChildrenTable.js +93 -91
- package/dist-lib/components/detail-layout/ChildrenTimeline.js +160 -155
- package/dist-lib/components/detail-layout/widgets/EntityScorecardWidget.js +127 -121
- package/dist-lib/components/fields/RefCombobox.js +53 -48
- package/dist-lib/components/fields/index.js +1 -0
- 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/components/file-widgets/useFileSelection.js +152 -0
- package/dist-lib/components/pages/SmartDetailPage.impl.js +506 -482
- package/dist-lib/components/pages/SmartRecordListPage.impl.js +335 -300
- package/dist-lib/components/pages/tenant-params/TenantParamsPage.impl.js +112 -109
- package/dist-lib/components/params/ParamsBlock.js +18 -15
- package/dist-lib/components/params/param-editors.js +60 -54
- package/dist-lib/components/primitives/RetryButton.js +14 -0
- package/dist-lib/components/primitives/StatTile.js +42 -34
- package/dist-lib/hooks/useAgentConversation.js +122 -109
- package/dist-lib/hooks/useAuth.js +4 -1
- package/dist-lib/hooks/useParams.js +54 -52
- package/dist-lib/hooks/useSchema.js +25 -30
- package/dist-lib/hooks/useTimelineData.js +26 -24
- package/dist-lib/index.d.ts +90 -6
- package/dist-lib/index.js +95 -93
- package/dist-lib/lib/read-display-state.js +19 -0
- package/dist-lib/stores/auth.js +35 -34
- package/dist-lib/test/seed-schema.js +4 -3
- package/dist-lib/testing.d.ts +1 -1
- package/dist-lib/types/fieldType.js +1 -1
- package/dist-lib/{useResponsiveMode-ECv1AEhv.d.ts → useResponsiveMode-C4MeAgoS.d.ts} +3 -1
- package/package.json +1 -1
|
@@ -2,14 +2,14 @@ import { ApiError as e } from "../types/api.js";
|
|
|
2
2
|
import { coerceDisplayString as t } from "../lib/display-value.js";
|
|
3
3
|
import { useAuthStore as n } from "../stores/auth.js";
|
|
4
4
|
import { AGENT_FRAME_EVENT as r, AGENT_MESSAGE_CHANGED_EVENT as i, agentBus as a } from "../api/events.js";
|
|
5
|
-
import { approveInvocation as o, cancelConversation as s, cancelInvocation as c, createConversation as l, listAvailableAgents as
|
|
5
|
+
import { approveInvocation as o, cancelConversation as s, cancelInvocation as c, createConversation as l, listAvailableAgents as u, listConversations as ee, loadConversationInvocations as d, loadConversationTurns as f, loadHistory as p, rejectInvocation as te, sendElicitResponse as ne, sendMessage as m } from "../api/agents.js";
|
|
6
6
|
import { useCallback as h, useEffect as g, useRef as _, useState as v } from "react";
|
|
7
7
|
//#region src/hooks/useAgentConversation.ts
|
|
8
8
|
var y = { streaming: !1 }, b = "declarion.agents.conversation_id";
|
|
9
9
|
function x(e) {
|
|
10
10
|
if (e) return `${b}:${e}`;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function re(e) {
|
|
13
13
|
if (typeof window > "u") return;
|
|
14
14
|
let t = x(e);
|
|
15
15
|
if (t) try {
|
|
@@ -18,17 +18,17 @@ function S(e) {
|
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function S(e, t) {
|
|
22
22
|
if (typeof window > "u") return;
|
|
23
23
|
let n = x(e);
|
|
24
24
|
if (n) try {
|
|
25
25
|
t ? window.localStorage.setItem(n, t) : window.localStorage.removeItem(n);
|
|
26
26
|
} catch {}
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function C(t) {
|
|
29
29
|
return !(t instanceof e) || t.code !== "entity.foreign_key_violation" ? !1 : t.ext("constraint") === "agent_messages_tenant_conv_fk";
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function w(e, t) {
|
|
32
32
|
return {
|
|
33
33
|
id: e,
|
|
34
34
|
conversation_id: t,
|
|
@@ -39,14 +39,14 @@ function T(e, t) {
|
|
|
39
39
|
streaming: !0
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function T(e, t) {
|
|
43
43
|
let n = !1, r = e.map((e) => e.role !== "assistant" || !e.streaming || e.id === t ? e : (n = !0, {
|
|
44
44
|
...e,
|
|
45
45
|
streaming: !1
|
|
46
46
|
}));
|
|
47
47
|
return n ? r : e;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function E(e, t) {
|
|
50
50
|
let n = !1, r = [];
|
|
51
51
|
for (let i of e) i.id !== t || i.role !== "assistant" ? r.push(i) : (n = !0, i.content.length !== 0 && (i.streaming ? r.push({
|
|
52
52
|
...i,
|
|
@@ -54,19 +54,19 @@ function D(e, t) {
|
|
|
54
54
|
}) : r.push(i)));
|
|
55
55
|
return n ? r : e;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function D(e) {
|
|
58
58
|
let t = e;
|
|
59
|
-
for (let n of e) n.role === "assistant" && n.streaming && (t =
|
|
59
|
+
for (let n of e) n.role === "assistant" && n.streaming && (t = E(t, n.id));
|
|
60
60
|
return t;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function O(e, t, n, r) {
|
|
63
63
|
let i = !1, a = e.map((e) => e.id === n ? (i = !0, r(e)) : e);
|
|
64
|
-
return i ? a : [...e, r(
|
|
64
|
+
return i ? a : [...e, r(w(n, t))];
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function k(e, t, n, r) {
|
|
67
67
|
if (!r) return e;
|
|
68
68
|
let i = e.find((e) => e.id === n);
|
|
69
|
-
return i && !i.streaming ? e :
|
|
69
|
+
return i && !i.streaming ? e : O(T(e, n), t, n, (e) => {
|
|
70
70
|
let t = [...e.content], n = t[t.length - 1];
|
|
71
71
|
return n?.type === "text" ? t[t.length - 1] = {
|
|
72
72
|
...n,
|
|
@@ -81,9 +81,9 @@ function A(e, t, n, r) {
|
|
|
81
81
|
};
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function A(e, t, n, r, i, a) {
|
|
85
85
|
let o = e.find((e) => e.id === n);
|
|
86
|
-
return o && !o.streaming ? e :
|
|
86
|
+
return o && !o.streaming ? e : O(T(e, n), t, n, (e) => r && e.content.some((e) => e.type === "tool_use" && e.id === r) ? e.streaming ? e : {
|
|
87
87
|
...e,
|
|
88
88
|
streaming: !0
|
|
89
89
|
} : {
|
|
@@ -97,7 +97,7 @@ function j(e, t, n, r, i, a) {
|
|
|
97
97
|
}]
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function ie(e, t) {
|
|
101
101
|
let n = e.map((e) => e.streaming ? {
|
|
102
102
|
...e,
|
|
103
103
|
streaming: !1
|
|
@@ -114,68 +114,71 @@ function re(e, t) {
|
|
|
114
114
|
}
|
|
115
115
|
return n;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function j(e) {
|
|
118
118
|
let t = e.payload?.message_id;
|
|
119
119
|
return typeof t == "string" && t ? t : void 0;
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
let b = n.getState().activeTenant?.id, [x,
|
|
123
|
-
|
|
124
|
-
}, [b]), [
|
|
121
|
+
function M(e) {
|
|
122
|
+
let b = n.getState().activeTenant?.id, [x, w] = v(e ?? re(b)), M = h((e) => {
|
|
123
|
+
S(b, e), w(e);
|
|
124
|
+
}, [b]), [ae, N] = v([]), [P, F] = v(y), [I, L] = v([]), [R, z] = v([]), [B, V] = v([]), [H, U] = v([]), [W, G] = v(), K = _(/* @__PURE__ */ new Set()), q = _(0), J = _(null), oe = (e) => (J.current?.fingerprint !== e && (J.current = {
|
|
125
|
+
key: crypto.randomUUID(),
|
|
126
|
+
fingerprint: e
|
|
127
|
+
}), J.current.key);
|
|
125
128
|
g(() => {
|
|
126
129
|
if (!x) {
|
|
127
|
-
|
|
130
|
+
N([]), F(y), L([]), z([]);
|
|
128
131
|
return;
|
|
129
132
|
}
|
|
130
|
-
if (
|
|
131
|
-
|
|
133
|
+
if (K.current.has(x)) {
|
|
134
|
+
K.current.delete(x);
|
|
132
135
|
return;
|
|
133
136
|
}
|
|
134
|
-
let e = !1;
|
|
137
|
+
let e = !1, t = ++q.current;
|
|
135
138
|
return Promise.all([
|
|
136
139
|
p(x),
|
|
137
140
|
f(x),
|
|
138
141
|
d(x)
|
|
139
|
-
]).then(([
|
|
140
|
-
if (e) return;
|
|
141
|
-
let
|
|
142
|
+
]).then(([n, r, i]) => {
|
|
143
|
+
if (e || t !== q.current) return;
|
|
144
|
+
let a = n.map((e) => e.streaming ? {
|
|
142
145
|
...e,
|
|
143
146
|
streaming: !1
|
|
144
147
|
} : e);
|
|
145
|
-
|
|
148
|
+
N(a), L(r), z(i);
|
|
146
149
|
}, (t) => {
|
|
147
|
-
e || t?.status === 404 && (
|
|
150
|
+
e || t?.status === 404 && (M(void 0), N([]));
|
|
148
151
|
}), () => {
|
|
149
152
|
e = !0;
|
|
150
153
|
};
|
|
151
|
-
}, [x,
|
|
152
|
-
let
|
|
154
|
+
}, [x, M]);
|
|
155
|
+
let Y = _(x);
|
|
153
156
|
g(() => {
|
|
154
|
-
|
|
157
|
+
Y.current = x;
|
|
155
158
|
}, [x]);
|
|
156
|
-
let
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
+
let X = _(!1), Z = _(null), Q = h((e) => {
|
|
160
|
+
if (X.current) {
|
|
161
|
+
Z.current = e;
|
|
159
162
|
return;
|
|
160
163
|
}
|
|
161
|
-
|
|
162
|
-
let t = ++
|
|
164
|
+
X.current = !0;
|
|
165
|
+
let t = ++q.current;
|
|
163
166
|
Promise.all([
|
|
164
167
|
p(e),
|
|
165
168
|
f(e),
|
|
166
169
|
d(e)
|
|
167
170
|
]).then(([n, r, i]) => {
|
|
168
|
-
e ===
|
|
171
|
+
e === Y.current && t === q.current && (N((e) => ie(n, e)), L(r), z(i));
|
|
169
172
|
}, () => {}).finally(() => {
|
|
170
|
-
|
|
171
|
-
let e =
|
|
172
|
-
|
|
173
|
+
X.current = !1;
|
|
174
|
+
let e = Z.current;
|
|
175
|
+
Z.current = null, e && Q(e);
|
|
173
176
|
});
|
|
174
177
|
}, []);
|
|
175
178
|
g(() => {
|
|
176
179
|
let e = (e) => {
|
|
177
180
|
let { convId: t, kind: r, turnId: i, payload: a } = e.detail;
|
|
178
|
-
t ===
|
|
181
|
+
t === Y.current && n(t, {
|
|
179
182
|
kind: r,
|
|
180
183
|
turnId: i,
|
|
181
184
|
payload: a
|
|
@@ -185,102 +188,112 @@ function N(e) {
|
|
|
185
188
|
let n = (e, n) => {
|
|
186
189
|
switch (n.kind) {
|
|
187
190
|
case "turn.started":
|
|
188
|
-
|
|
191
|
+
F((e) => ({
|
|
189
192
|
...e,
|
|
190
193
|
streaming: !0
|
|
191
|
-
})),
|
|
194
|
+
})), N((e) => T(e));
|
|
192
195
|
break;
|
|
193
196
|
case "assistant.message.created": {
|
|
194
197
|
let t = typeof n.payload?.message_id == "string" ? n.payload.message_id : "";
|
|
195
198
|
if (!t) break;
|
|
196
|
-
|
|
199
|
+
N((n) => O(T(n, t), e, t, (e) => ({
|
|
197
200
|
...e,
|
|
198
201
|
streaming: !0
|
|
199
202
|
})));
|
|
200
203
|
break;
|
|
201
204
|
}
|
|
202
205
|
case "text.delta": {
|
|
203
|
-
let r = t(n.payload?.text), i =
|
|
206
|
+
let r = t(n.payload?.text), i = j(n);
|
|
204
207
|
if (!i || !r) break;
|
|
205
|
-
|
|
208
|
+
N((t) => k(t, e, i, r));
|
|
206
209
|
break;
|
|
207
210
|
}
|
|
208
211
|
case "elicit.pending":
|
|
209
|
-
|
|
212
|
+
Q(e);
|
|
210
213
|
break;
|
|
211
214
|
case "tool.pending":
|
|
212
|
-
|
|
215
|
+
Q(e);
|
|
213
216
|
break;
|
|
214
217
|
case "tool.proposed": {
|
|
215
|
-
let t =
|
|
218
|
+
let t = j(n), r = typeof n.payload?.tool == "string" ? n.payload.tool : "", i = n.payload?.params ?? {}, a = typeof n.payload?.tool_use_id == "string" ? n.payload.tool_use_id : "";
|
|
216
219
|
if (!t || !r) break;
|
|
217
|
-
|
|
220
|
+
N((n) => A(n, e, t, a, r, i));
|
|
218
221
|
break;
|
|
219
222
|
}
|
|
220
223
|
case "tool.result":
|
|
221
224
|
case "tool.failed":
|
|
222
225
|
case "tool.canceled":
|
|
223
|
-
|
|
226
|
+
Q(e);
|
|
224
227
|
break;
|
|
225
228
|
case "turn.finished": {
|
|
226
|
-
|
|
227
|
-
let e =
|
|
228
|
-
e &&
|
|
229
|
+
F(y);
|
|
230
|
+
let e = j(n);
|
|
231
|
+
e && N((t) => E(t, e));
|
|
229
232
|
break;
|
|
230
233
|
}
|
|
231
|
-
case "error":
|
|
234
|
+
case "error": N((e) => D(e)), F((e) => ({
|
|
232
235
|
...e,
|
|
233
236
|
streaming: !1
|
|
234
237
|
}));
|
|
235
238
|
}
|
|
236
239
|
}, o = () => {
|
|
237
|
-
let e =
|
|
238
|
-
e &&
|
|
240
|
+
let e = Y.current;
|
|
241
|
+
e && Q(e);
|
|
239
242
|
};
|
|
240
243
|
return a.addEventListener(i, o), () => {
|
|
241
244
|
a.removeEventListener(r, e), a.removeEventListener(i, o);
|
|
242
245
|
};
|
|
243
|
-
}, [
|
|
244
|
-
let
|
|
245
|
-
let n = x;
|
|
246
|
-
|
|
247
|
-
let r
|
|
246
|
+
}, [Q]);
|
|
247
|
+
let $ = h(async (e, t, n = []) => {
|
|
248
|
+
let r = n.map((e) => e.id), i = x;
|
|
249
|
+
i || (i = (await l({ agent_id: W })).id, K.current.add(i), Y.current = i, M(i));
|
|
250
|
+
let a, o = (n) => m(e, n, t, r, oe(JSON.stringify([
|
|
251
|
+
n,
|
|
252
|
+
e,
|
|
253
|
+
t ?? null,
|
|
254
|
+
r
|
|
255
|
+
])));
|
|
248
256
|
try {
|
|
249
|
-
|
|
250
|
-
} catch (
|
|
251
|
-
if (!
|
|
252
|
-
|
|
257
|
+
a = await o(i);
|
|
258
|
+
} catch (e) {
|
|
259
|
+
if (!C(e)) throw e;
|
|
260
|
+
i = (await l({ agent_id: W })).id, K.current.add(i), Y.current = i, M(i), a = await o(i);
|
|
253
261
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
262
|
+
J.current = null, N((t) => {
|
|
263
|
+
if (t.some((e) => e.id === a.id)) return t;
|
|
264
|
+
let r = e ? [{
|
|
257
265
|
type: "text",
|
|
258
266
|
text: e
|
|
259
|
-
}]
|
|
260
|
-
|
|
267
|
+
}] : [];
|
|
268
|
+
return [...t, {
|
|
269
|
+
...a,
|
|
270
|
+
content: r,
|
|
271
|
+
attachments: n
|
|
272
|
+
}];
|
|
273
|
+
});
|
|
261
274
|
}, [
|
|
262
275
|
x,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
]),
|
|
266
|
-
await o(e, t), x &&
|
|
267
|
-
}, [x,
|
|
268
|
-
await te(e, t), x &&
|
|
269
|
-
}, [x,
|
|
270
|
-
x && (await ne(x, e, t),
|
|
271
|
-
}, [x,
|
|
272
|
-
x && (await c(e),
|
|
273
|
-
}, [x,
|
|
276
|
+
M,
|
|
277
|
+
W
|
|
278
|
+
]), se = h(async (e, t) => {
|
|
279
|
+
await o(e, t), x && Q(x);
|
|
280
|
+
}, [x, Q]), ce = h(async (e, t) => {
|
|
281
|
+
await te(e, t), x && Q(x);
|
|
282
|
+
}, [x, Q]), le = h(async (e, t) => {
|
|
283
|
+
x && (await ne(x, e, t), Q(x));
|
|
284
|
+
}, [x, Q]), ue = h(async (e) => {
|
|
285
|
+
x && (await c(e), Q(x));
|
|
286
|
+
}, [x, Q]), de = h(async () => {
|
|
274
287
|
x && await s(x);
|
|
275
|
-
}, [x]),
|
|
276
|
-
|
|
277
|
-
}, []),
|
|
278
|
-
|
|
279
|
-
}, [
|
|
288
|
+
}, [x]), fe = h(async () => {
|
|
289
|
+
V(await ee());
|
|
290
|
+
}, []), pe = h(() => {
|
|
291
|
+
M(void 0), N([]), F(y);
|
|
292
|
+
}, [M]);
|
|
280
293
|
return g(() => {
|
|
281
294
|
let e = !0;
|
|
282
|
-
return
|
|
283
|
-
e && (
|
|
295
|
+
return u().then((t) => {
|
|
296
|
+
e && (U(t), G((e) => e ?? t.find((e) => e.is_default)?.id));
|
|
284
297
|
}).catch((e) => {
|
|
285
298
|
console.warn("agents.list_available failed; the agent picker is unavailable", e);
|
|
286
299
|
}), () => {
|
|
@@ -288,24 +301,24 @@ function N(e) {
|
|
|
288
301
|
};
|
|
289
302
|
}, []), {
|
|
290
303
|
conversationId: x,
|
|
291
|
-
messages:
|
|
292
|
-
turn:
|
|
293
|
-
turns:
|
|
294
|
-
invocations:
|
|
295
|
-
conversations:
|
|
296
|
-
send:
|
|
297
|
-
approve:
|
|
298
|
-
reject:
|
|
299
|
-
submitInput:
|
|
300
|
-
cancelInput:
|
|
301
|
-
cancel:
|
|
302
|
-
refreshConversations:
|
|
303
|
-
startNew:
|
|
304
|
-
agents:
|
|
305
|
-
selectedAgentId:
|
|
306
|
-
selectAgent:
|
|
307
|
-
setConversationId:
|
|
304
|
+
messages: ae,
|
|
305
|
+
turn: P,
|
|
306
|
+
turns: I,
|
|
307
|
+
invocations: R,
|
|
308
|
+
conversations: B,
|
|
309
|
+
send: $,
|
|
310
|
+
approve: se,
|
|
311
|
+
reject: ce,
|
|
312
|
+
submitInput: le,
|
|
313
|
+
cancelInput: ue,
|
|
314
|
+
cancel: de,
|
|
315
|
+
refreshConversations: fe,
|
|
316
|
+
startNew: pe,
|
|
317
|
+
agents: H,
|
|
318
|
+
selectedAgentId: W,
|
|
319
|
+
selectAgent: G,
|
|
320
|
+
setConversationId: M
|
|
308
321
|
};
|
|
309
322
|
}
|
|
310
323
|
//#endregion
|
|
311
|
-
export {
|
|
324
|
+
export { M as useAgentConversation };
|
|
@@ -51,7 +51,10 @@ function g() {
|
|
|
51
51
|
confirmSignup: D.mutate,
|
|
52
52
|
switchTenant: O.mutate,
|
|
53
53
|
logout: async () => {
|
|
54
|
-
|
|
54
|
+
let e = x();
|
|
55
|
+
C.removeQueries({ predicate: (e) => !h.has(e.queryKey[0]) }), C.getMutationCache().clear(), d.getState().clear(), S("/login"), await e.catch((e) => {
|
|
56
|
+
c.error(o(w, e));
|
|
57
|
+
});
|
|
55
58
|
},
|
|
56
59
|
isLoginPending: T.isPending,
|
|
57
60
|
isSignupPending: E.isPending,
|
|
@@ -4,120 +4,122 @@ import { fetchAllParams as n, fetchParam as r, fetchPublicParams as i } from "..
|
|
|
4
4
|
import { executeAction as a, getEntity as o } from "../api/data.js";
|
|
5
5
|
import { failureTitle as s } from "../lib/failure.js";
|
|
6
6
|
import { useText as c } from "./useText.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { readDisplayState as l } from "../lib/read-display-state.js";
|
|
8
|
+
import { useCallback as u, useMemo as d, useState as f } from "react";
|
|
9
|
+
import { useQuery as p, useQueryClient as m } from "@tanstack/react-query";
|
|
9
10
|
//#region src/hooks/useParams.ts
|
|
10
|
-
var
|
|
11
|
-
function
|
|
11
|
+
var h = "$params";
|
|
12
|
+
function g(e, t) {
|
|
12
13
|
return [
|
|
13
14
|
"params-carrier-detail",
|
|
14
15
|
e,
|
|
15
16
|
t
|
|
16
17
|
];
|
|
17
18
|
}
|
|
18
|
-
async function
|
|
19
|
-
let s =
|
|
19
|
+
async function _(e, { carrierEntityCode: n, rowId: r }, i) {
|
|
20
|
+
let s = g(n, r), c = (await e.fetchQuery({
|
|
20
21
|
queryKey: s,
|
|
21
22
|
queryFn: () => o(n, r),
|
|
22
23
|
staleTime: 0
|
|
23
|
-
}))?.data?.[
|
|
24
|
-
if (!Array.isArray(c)) throw Error(`${n} ${r} carries no ${
|
|
24
|
+
}))?.data?.[h];
|
|
25
|
+
if (!Array.isArray(c)) throw Error(`${n} ${r} carries no ${h}`);
|
|
25
26
|
await a(`${n}.__update`, {
|
|
26
27
|
object_ids: [r],
|
|
27
28
|
entity: n,
|
|
28
|
-
fields: { [
|
|
29
|
+
fields: { [h]: i(c) }
|
|
29
30
|
}), await e.invalidateQueries({ queryKey: ["params-all"] }), await e.invalidateQueries({ queryKey: ["params"] }), await e.invalidateQueries({ queryKey: s }), await t(e);
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
-
let i =
|
|
33
|
-
queryKey:
|
|
32
|
+
function v({ carrierEntityCode: e, rowId: t, enabled: n = !0, writeOneByOne: r = !1 }) {
|
|
33
|
+
let i = m(), v = c("errors"), [y, b] = f(null), x = p({
|
|
34
|
+
queryKey: g(e, t),
|
|
34
35
|
queryFn: () => o(e, t),
|
|
35
36
|
enabled: n && !!t,
|
|
36
37
|
staleTime: 3e4
|
|
37
|
-
}),
|
|
38
|
-
|
|
38
|
+
}), S = x.data?.data, C = l(x), w = S ? !(h in S) : C.error !== null, T = d(() => Array.isArray(S?.$params) ? S[h] : [], [S]), E = d(() => new Map(T.map((e) => [e.param_code, e])), [T]), D = u(async (n) => {
|
|
39
|
+
b(null);
|
|
39
40
|
try {
|
|
40
|
-
return await
|
|
41
|
+
return await _(i, {
|
|
41
42
|
carrierEntityCode: e,
|
|
42
43
|
rowId: t
|
|
43
44
|
}, n), !0;
|
|
44
45
|
} catch (e) {
|
|
45
|
-
return
|
|
46
|
+
return b(s(v, e)), !1;
|
|
46
47
|
}
|
|
47
48
|
}, [
|
|
48
49
|
e,
|
|
49
50
|
t,
|
|
50
51
|
i,
|
|
51
|
-
|
|
52
|
-
]),
|
|
53
|
-
|
|
52
|
+
v
|
|
53
|
+
]), O = u(async (n, r) => {
|
|
54
|
+
b(null);
|
|
54
55
|
try {
|
|
55
56
|
return await a("params.set", {
|
|
56
57
|
code: n,
|
|
57
58
|
value: r,
|
|
58
59
|
entity: e,
|
|
59
60
|
object_id: t
|
|
60
|
-
}), await i.invalidateQueries({ queryKey: ["params-all"] }), await i.invalidateQueries({ queryKey: ["params"] }), await i.invalidateQueries({ queryKey:
|
|
61
|
+
}), await i.invalidateQueries({ queryKey: ["params-all"] }), await i.invalidateQueries({ queryKey: ["params"] }), await i.invalidateQueries({ queryKey: g(e, t) }), !0;
|
|
61
62
|
} catch (e) {
|
|
62
|
-
return
|
|
63
|
+
return b(s(v, e)), !1;
|
|
63
64
|
}
|
|
64
65
|
}, [
|
|
65
66
|
e,
|
|
66
67
|
t,
|
|
67
68
|
i,
|
|
68
|
-
|
|
69
|
-
]),
|
|
69
|
+
v
|
|
70
|
+
]), k = u((e, t) => r ? O(e.code, t) : D((n) => [...n.filter((t) => t.param_code !== e.code), {
|
|
70
71
|
param_code: e.code,
|
|
71
72
|
value: t
|
|
72
73
|
}]), [
|
|
73
74
|
r,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
]),
|
|
75
|
+
O,
|
|
76
|
+
D
|
|
77
|
+
]), A = u((e) => r ? O(e.code, null) : D((t) => t.filter((t) => t.param_code !== e.code)), [
|
|
77
78
|
r,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
]),
|
|
79
|
+
O,
|
|
80
|
+
D
|
|
81
|
+
]), j = u(() => b(null), []);
|
|
81
82
|
return {
|
|
82
|
-
overrides:
|
|
83
|
-
overrideByCode:
|
|
84
|
-
missingParams:
|
|
85
|
-
isLoading:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
overrides: T,
|
|
84
|
+
overrideByCode: E,
|
|
85
|
+
missingParams: w,
|
|
86
|
+
isLoading: C.loading,
|
|
87
|
+
retry: C.retry,
|
|
88
|
+
error: y,
|
|
89
|
+
clearError: j,
|
|
90
|
+
save: k,
|
|
91
|
+
reset: A
|
|
90
92
|
};
|
|
91
93
|
}
|
|
92
|
-
function
|
|
93
|
-
return
|
|
94
|
+
function y(e) {
|
|
95
|
+
return p({
|
|
94
96
|
queryKey: ["params-all", e ?? "full"],
|
|
95
97
|
queryFn: () => n(e),
|
|
96
98
|
staleTime: 3e4
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
|
-
var
|
|
100
|
-
function
|
|
101
|
-
return
|
|
102
|
-
queryKey:
|
|
101
|
+
var b = ["params-public"];
|
|
102
|
+
function x() {
|
|
103
|
+
return p({
|
|
104
|
+
queryKey: b,
|
|
103
105
|
queryFn: i,
|
|
104
106
|
staleTime: 3e5
|
|
105
107
|
});
|
|
106
108
|
}
|
|
107
|
-
function
|
|
109
|
+
function S(e, t = {}) {
|
|
108
110
|
let n = t.enabled ?? !0, i = t.isSessionProbe ?? !1;
|
|
109
|
-
return
|
|
111
|
+
return p({
|
|
110
112
|
queryKey: ["params", e],
|
|
111
113
|
queryFn: () => r(e, { isSessionProbe: i }),
|
|
112
114
|
enabled: !!e && n,
|
|
113
115
|
staleTime: 6e4
|
|
114
116
|
});
|
|
115
117
|
}
|
|
116
|
-
function
|
|
117
|
-
let n = e((e) => e.isAuthenticated), r = e((e) => e.sessionPresumed), i =
|
|
118
|
+
function C(t) {
|
|
119
|
+
let n = e((e) => e.isAuthenticated), r = e((e) => e.sessionPresumed), i = x(), a = S(t, {
|
|
118
120
|
enabled: n || r,
|
|
119
121
|
isSessionProbe: !n
|
|
120
|
-
}), o =
|
|
122
|
+
}), o = w(i.data?.parameters, t);
|
|
121
123
|
if (n && a.data?.found) return {
|
|
122
124
|
value: a.data.value,
|
|
123
125
|
found: !0,
|
|
@@ -134,11 +136,11 @@ function S(t) {
|
|
|
134
136
|
error: a.error ?? i.error ?? null
|
|
135
137
|
};
|
|
136
138
|
}
|
|
137
|
-
function
|
|
139
|
+
function w(e, t) {
|
|
138
140
|
return e?.find((e) => e.code === t);
|
|
139
141
|
}
|
|
140
|
-
function
|
|
141
|
-
let i = e((e) => e.isAuthenticated), a =
|
|
142
|
+
function T(t, n) {
|
|
143
|
+
let i = e((e) => e.isAuthenticated), a = p({
|
|
142
144
|
queryKey: ["params", t],
|
|
143
145
|
queryFn: () => r(t),
|
|
144
146
|
enabled: !!t && i,
|
|
@@ -153,4 +155,4 @@ function w(t, n) {
|
|
|
153
155
|
};
|
|
154
156
|
}
|
|
155
157
|
//#endregion
|
|
156
|
-
export {
|
|
158
|
+
export { h as PARAMS_KEY, b as PUBLIC_PARAMS_QUERY_KEY, y as useAllParams, v as useCarrierParamOverrides, C as useEffectiveParam, T as useParam, x as usePublicParams, S as useResolvedParam, _ as writeCarrierParams };
|