@uipath/apollo-react 5.1.1 → 6.0.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/canvas/locales/de.cjs +1 -1
- package/dist/canvas/locales/de.d.ts.map +1 -1
- package/dist/canvas/locales/de.js +1 -1
- package/dist/canvas/locales/es-MX.cjs +1 -1
- package/dist/canvas/locales/es-MX.d.ts.map +1 -1
- package/dist/canvas/locales/es-MX.js +1 -1
- package/dist/canvas/locales/es.cjs +1 -1
- package/dist/canvas/locales/es.d.ts.map +1 -1
- package/dist/canvas/locales/es.js +1 -1
- package/dist/canvas/locales/fr.cjs +1 -1
- package/dist/canvas/locales/fr.d.ts.map +1 -1
- package/dist/canvas/locales/fr.js +1 -1
- package/dist/canvas/locales/ko.cjs +1 -1
- package/dist/canvas/locales/ko.d.ts.map +1 -1
- package/dist/canvas/locales/ko.js +1 -1
- package/dist/canvas/locales/tr.cjs +1 -1
- package/dist/canvas/locales/tr.d.ts.map +1 -1
- package/dist/canvas/locales/tr.js +1 -1
- package/dist/canvas/locales/zh-CN.cjs +1 -1
- package/dist/canvas/locales/zh-CN.d.ts.map +1 -1
- package/dist/canvas/locales/zh-CN.js +1 -1
- package/dist/canvas/locales/zh-TW.cjs +1 -1
- package/dist/canvas/locales/zh-TW.d.ts.map +1 -1
- package/dist/canvas/locales/zh-TW.js +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/material/components/ap-model-picker/ModelPicker.cjs +76 -23
- package/dist/material/components/ap-model-picker/ModelPicker.d.ts +6 -1
- package/dist/material/components/ap-model-picker/ModelPicker.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/ModelPicker.js +77 -24
- package/dist/material/components/ap-model-picker/i18n.cjs +3 -0
- package/dist/material/components/ap-model-picker/i18n.d.ts +1 -0
- package/dist/material/components/ap-model-picker/i18n.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/i18n.js +3 -0
- package/dist/material/components/ap-model-picker/index.cjs +7 -1
- package/dist/material/components/ap-model-picker/index.d.ts +2 -2
- package/dist/material/components/ap-model-picker/index.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/index.js +2 -2
- package/dist/material/components/ap-model-picker/locales/en.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/en.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/en.js +1 -1
- package/dist/material/components/ap-model-picker/primitives/ModelOptionRow.cjs +56 -17
- package/dist/material/components/ap-model-picker/primitives/ModelOptionRow.d.ts +1 -0
- package/dist/material/components/ap-model-picker/primitives/ModelOptionRow.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/primitives/ModelOptionRow.js +56 -18
- package/dist/material/components/ap-model-picker/primitives/PickerPopup.cjs +3 -1
- package/dist/material/components/ap-model-picker/primitives/PickerPopup.d.ts +3 -0
- package/dist/material/components/ap-model-picker/primitives/PickerPopup.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/primitives/PickerPopup.js +3 -1
- package/dist/material/components/ap-model-picker/types.d.ts +2 -1
- package/dist/material/components/ap-model-picker/types.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/useDiscoveryModels.cjs +6 -3
- package/dist/material/components/ap-model-picker/useDiscoveryModels.d.ts +1 -0
- package/dist/material/components/ap-model-picker/useDiscoveryModels.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/useDiscoveryModels.js +3 -3
- package/dist/material/components/ap-model-picker/usePlatformAccess.cjs +148 -13
- package/dist/material/components/ap-model-picker/usePlatformAccess.d.ts +20 -2
- package/dist/material/components/ap-model-picker/usePlatformAccess.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/usePlatformAccess.js +142 -13
- package/dist/material/components/ap-model-picker/utils.cjs +7 -1
- package/dist/material/components/ap-model-picker/utils.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/utils.js +7 -1
- package/package.json +1 -1
|
@@ -25,11 +25,15 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
buildLlmConfigurationsUrl: ()=>buildLlmConfigurationsUrl,
|
|
28
|
-
platformNavigation: ()=>platformNavigation,
|
|
29
28
|
useUserFolders: ()=>useUserFolders,
|
|
29
|
+
platformNavigation: ()=>platformNavigation,
|
|
30
|
+
usePlatformDiscoveryModels: ()=>usePlatformDiscoveryModels,
|
|
31
|
+
useByoConnectionNames: ()=>useByoConnectionNames,
|
|
30
32
|
useCanManageByo: ()=>useCanManageByo
|
|
31
33
|
});
|
|
32
34
|
const external_react_namespaceObject = require("react");
|
|
35
|
+
const external_useDiscoveryModels_cjs_namespaceObject = require("./useDiscoveryModels.cjs");
|
|
36
|
+
const resolveToken = async (token)=>'function' == typeof token ? token() : token;
|
|
33
37
|
const FOLDERS_PAGE_SIZE = 100;
|
|
34
38
|
function useUserFolders(ctx) {
|
|
35
39
|
const [folders, setFolders] = (0, external_react_namespaceObject.useState)([]);
|
|
@@ -46,16 +50,18 @@ function useUserFolders(ctx) {
|
|
|
46
50
|
const base = (ctx.baseUrl ?? '').replace(/\/$/, '');
|
|
47
51
|
const url = `${base}/${ctx.tenantName}/orchestrator_/api/FoldersNavigation/GetFoldersForCurrentUser?take=${FOLDERS_PAGE_SIZE}`;
|
|
48
52
|
try {
|
|
53
|
+
const bearer = await resolveToken(ctx.token);
|
|
49
54
|
const res = await fetch(url, {
|
|
50
55
|
headers: {
|
|
51
|
-
Authorization: `Bearer ${
|
|
52
|
-
Accept: 'application/json'
|
|
56
|
+
Authorization: `Bearer ${bearer}`,
|
|
57
|
+
Accept: 'application/json',
|
|
58
|
+
'Content-Type': 'application/json'
|
|
53
59
|
},
|
|
54
60
|
signal: ctrl.signal
|
|
55
61
|
});
|
|
56
62
|
if (!res.ok) throw new Error(`FoldersNavigation API ${res.status} ${res.statusText}`);
|
|
57
63
|
const data = await res.json();
|
|
58
|
-
if (!ctrl.signal.aborted) setFolders((data.PageItems ?? []).map((f)=>({
|
|
64
|
+
if (!ctrl.signal.aborted) setFolders((data.PageItems ?? []).filter((f)=>'Personal' !== f.FolderType).map((f)=>({
|
|
59
65
|
id: f.Key,
|
|
60
66
|
label: f.DisplayName,
|
|
61
67
|
numericId: f.Id
|
|
@@ -90,6 +96,130 @@ function useUserFolders(ctx) {
|
|
|
90
96
|
refetch: fetchFolders
|
|
91
97
|
};
|
|
92
98
|
}
|
|
99
|
+
function usePlatformDiscoveryModels(ctx, folderKey) {
|
|
100
|
+
const [models, setModels] = (0, external_react_namespaceObject.useState)(void 0);
|
|
101
|
+
const [loading, setLoading] = (0, external_react_namespaceObject.useState)(false);
|
|
102
|
+
const [error, setError] = (0, external_react_namespaceObject.useState)(null);
|
|
103
|
+
const abortRef = (0, external_react_namespaceObject.useRef)(null);
|
|
104
|
+
const fetchModels = (0, external_react_namespaceObject.useCallback)(async ()=>{
|
|
105
|
+
if (!ctx) return;
|
|
106
|
+
abortRef.current?.abort();
|
|
107
|
+
const ctrl = new AbortController();
|
|
108
|
+
abortRef.current = ctrl;
|
|
109
|
+
setLoading(true);
|
|
110
|
+
setError(null);
|
|
111
|
+
const base = (ctx.baseUrl ?? '').replace(/\/$/, '');
|
|
112
|
+
let url;
|
|
113
|
+
if (ctx.organizationId && ctx.tenantId) {
|
|
114
|
+
let origin = '';
|
|
115
|
+
try {
|
|
116
|
+
origin = base ? new URL(base).origin : '';
|
|
117
|
+
} catch {
|
|
118
|
+
origin = '';
|
|
119
|
+
}
|
|
120
|
+
url = `${origin}/${ctx.organizationId}/${ctx.tenantId}/llmgateway_/api/discovery`;
|
|
121
|
+
} else url = `${base}/${ctx.tenantName}/llmgateway_/api/discovery`;
|
|
122
|
+
try {
|
|
123
|
+
const bearer = await resolveToken(ctx.token);
|
|
124
|
+
const headers = {
|
|
125
|
+
Authorization: `Bearer ${bearer}`,
|
|
126
|
+
Accept: 'application/json',
|
|
127
|
+
'Content-Type': 'application/json'
|
|
128
|
+
};
|
|
129
|
+
if (ctx.requestingProduct) headers['X-UiPath-LlmGateway-RequestingProduct'] = ctx.requestingProduct;
|
|
130
|
+
if (ctx.requestingFeature) headers['X-UiPath-LlmGateway-RequestingFeature'] = ctx.requestingFeature;
|
|
131
|
+
if (ctx.userId) headers['X-UiPath-LlmGateway-UserId'] = ctx.userId;
|
|
132
|
+
if (ctx.operationCode) headers['X-UiPath-LlmGateway-OperationCode'] = ctx.operationCode;
|
|
133
|
+
if (folderKey) headers['X-UiPath-FolderKey'] = folderKey;
|
|
134
|
+
const res = await fetch(url, {
|
|
135
|
+
headers,
|
|
136
|
+
signal: ctrl.signal
|
|
137
|
+
});
|
|
138
|
+
if (!res.ok) throw new Error(`Discovery API ${res.status} ${res.statusText}`);
|
|
139
|
+
const data = await res.json();
|
|
140
|
+
if (!ctrl.signal.aborted) setModels((0, external_useDiscoveryModels_cjs_namespaceObject.normalizeDiscoveryModels)(Array.isArray(data) ? data : []));
|
|
141
|
+
} catch (err) {
|
|
142
|
+
if (err?.name === 'AbortError') return;
|
|
143
|
+
if (!ctrl.signal.aborted) setError(err instanceof Error ? err : new Error(String(err)));
|
|
144
|
+
} finally{
|
|
145
|
+
if (!ctrl.signal.aborted) setLoading(false);
|
|
146
|
+
}
|
|
147
|
+
}, [
|
|
148
|
+
ctx,
|
|
149
|
+
folderKey
|
|
150
|
+
]);
|
|
151
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
152
|
+
if (!ctx) {
|
|
153
|
+
abortRef.current?.abort();
|
|
154
|
+
setModels(void 0);
|
|
155
|
+
setLoading(false);
|
|
156
|
+
setError(null);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
fetchModels();
|
|
160
|
+
return ()=>abortRef.current?.abort();
|
|
161
|
+
}, [
|
|
162
|
+
ctx,
|
|
163
|
+
fetchModels
|
|
164
|
+
]);
|
|
165
|
+
return {
|
|
166
|
+
models,
|
|
167
|
+
loading,
|
|
168
|
+
error,
|
|
169
|
+
refetch: fetchModels
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const EMPTY_GUID = '00000000-0000-0000-0000-000000000000';
|
|
173
|
+
function useByoConnectionNames(models, ctx) {
|
|
174
|
+
const [names, setNames] = (0, external_react_namespaceObject.useState)(new Map());
|
|
175
|
+
const requestedRef = (0, external_react_namespaceObject.useRef)(new Set());
|
|
176
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
177
|
+
if (!ctx) return;
|
|
178
|
+
const pending = [
|
|
179
|
+
...new Set(models.filter((m)=>!m.byoConnectionLabel).map((m)=>m.byomDetails?.integrationServiceConnectionId).filter((id)=>!!id && id !== EMPTY_GUID))
|
|
180
|
+
].filter((id)=>!requestedRef.current.has(id));
|
|
181
|
+
if (0 === pending.length) return;
|
|
182
|
+
pending.forEach((id)=>requestedRef.current.add(id));
|
|
183
|
+
const ctrl = new AbortController();
|
|
184
|
+
const base = (ctx.baseUrl ?? '').replace(/\/$/, '');
|
|
185
|
+
(async ()=>{
|
|
186
|
+
const bearer = await resolveToken(ctx.token);
|
|
187
|
+
const resolved = await Promise.all(pending.map(async (id)=>{
|
|
188
|
+
try {
|
|
189
|
+
const res = await fetch(`${base}/${ctx.tenantName}/connections_/api/v1/Connections/${encodeURIComponent(id)}`, {
|
|
190
|
+
headers: {
|
|
191
|
+
Authorization: `Bearer ${bearer}`,
|
|
192
|
+
Accept: 'application/json',
|
|
193
|
+
'Content-Type': 'application/json'
|
|
194
|
+
},
|
|
195
|
+
signal: ctrl.signal
|
|
196
|
+
});
|
|
197
|
+
if (!res.ok) return null;
|
|
198
|
+
const data = await res.json();
|
|
199
|
+
return data.name ? [
|
|
200
|
+
id,
|
|
201
|
+
data.name
|
|
202
|
+
] : null;
|
|
203
|
+
} catch {
|
|
204
|
+
if (ctrl.signal.aborted) requestedRef.current.delete(id);
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}));
|
|
208
|
+
const found = resolved.filter((entry)=>null !== entry);
|
|
209
|
+
if (!ctrl.signal.aborted && found.length > 0) setNames((prev)=>new Map([
|
|
210
|
+
...prev,
|
|
211
|
+
...found
|
|
212
|
+
]));
|
|
213
|
+
})().catch(()=>{
|
|
214
|
+
pending.forEach((id)=>requestedRef.current.delete(id));
|
|
215
|
+
});
|
|
216
|
+
return ()=>ctrl.abort();
|
|
217
|
+
}, [
|
|
218
|
+
ctx,
|
|
219
|
+
models
|
|
220
|
+
]);
|
|
221
|
+
return names;
|
|
222
|
+
}
|
|
93
223
|
const ORG_ADMIN_ROLES = [
|
|
94
224
|
'ACCOUNT_ADMIN',
|
|
95
225
|
'ACCOUNT_OWNER'
|
|
@@ -115,13 +245,14 @@ function useCanManageByo(ctx) {
|
|
|
115
245
|
setError(null);
|
|
116
246
|
const base = (ctx.baseUrl ?? '').replace(/\/$/, '');
|
|
117
247
|
const url = `${base}/portal_/api/organization/UserOrganizationInfo`;
|
|
118
|
-
fetch(url, {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
248
|
+
resolveToken(ctx.token).then((bearer)=>fetch(url, {
|
|
249
|
+
headers: {
|
|
250
|
+
Authorization: `Bearer ${bearer}`,
|
|
251
|
+
Accept: 'application/json',
|
|
252
|
+
'Content-Type': 'application/json'
|
|
253
|
+
},
|
|
254
|
+
signal: ctrl.signal
|
|
255
|
+
})).then(async (res)=>{
|
|
125
256
|
if (!res.ok) throw new Error(`UserOrganizationInfo API ${res.status} ${res.statusText}`);
|
|
126
257
|
const data = await res.json();
|
|
127
258
|
if (!ctrl.signal.aborted) setCanManage(ORG_ADMIN_ROLES.includes(data.accountRoleType ?? ''));
|
|
@@ -165,18 +296,22 @@ function buildLlmConfigurationsUrl(ctx, options) {
|
|
|
165
296
|
return `${root}${qs ? `?${qs}` : ''}`;
|
|
166
297
|
}
|
|
167
298
|
const platformNavigation = {
|
|
168
|
-
|
|
169
|
-
globalThis.
|
|
299
|
+
openInNewTab (url) {
|
|
300
|
+
globalThis.open?.(url, '_blank', 'noopener,noreferrer');
|
|
170
301
|
}
|
|
171
302
|
};
|
|
172
303
|
exports.buildLlmConfigurationsUrl = __webpack_exports__.buildLlmConfigurationsUrl;
|
|
173
304
|
exports.platformNavigation = __webpack_exports__.platformNavigation;
|
|
305
|
+
exports.useByoConnectionNames = __webpack_exports__.useByoConnectionNames;
|
|
174
306
|
exports.useCanManageByo = __webpack_exports__.useCanManageByo;
|
|
307
|
+
exports.usePlatformDiscoveryModels = __webpack_exports__.usePlatformDiscoveryModels;
|
|
175
308
|
exports.useUserFolders = __webpack_exports__.useUserFolders;
|
|
176
309
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
177
310
|
"buildLlmConfigurationsUrl",
|
|
178
311
|
"platformNavigation",
|
|
312
|
+
"useByoConnectionNames",
|
|
179
313
|
"useCanManageByo",
|
|
314
|
+
"usePlatformDiscoveryModels",
|
|
180
315
|
"useUserFolders"
|
|
181
316
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
182
317
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { FolderSwitcherFolder } from './primitives/FolderSwitcher';
|
|
2
|
+
import type { DiscoveryModel } from './types';
|
|
3
|
+
export type PlatformToken = string | (() => string | Promise<string>);
|
|
2
4
|
export interface PlatformRequestContext {
|
|
3
|
-
token:
|
|
5
|
+
token: PlatformToken;
|
|
4
6
|
baseUrl?: string;
|
|
5
7
|
tenantName: string;
|
|
8
|
+
organizationId?: string;
|
|
6
9
|
tenantId?: string;
|
|
7
10
|
requestingProduct?: string;
|
|
8
11
|
requestingFeature?: string;
|
|
12
|
+
operationCode?: string;
|
|
13
|
+
userId?: string;
|
|
9
14
|
}
|
|
10
15
|
export interface UseUserFoldersResult {
|
|
11
16
|
folders: FolderSwitcherFolder[];
|
|
@@ -14,6 +19,19 @@ export interface UseUserFoldersResult {
|
|
|
14
19
|
refetch: () => void;
|
|
15
20
|
}
|
|
16
21
|
export declare function useUserFolders(ctx: PlatformRequestContext | null): UseUserFoldersResult;
|
|
22
|
+
export interface UsePlatformDiscoveryModelsResult {
|
|
23
|
+
models: DiscoveryModel[] | undefined;
|
|
24
|
+
loading: boolean;
|
|
25
|
+
error: Error | null;
|
|
26
|
+
refetch: () => void;
|
|
27
|
+
}
|
|
28
|
+
export declare function usePlatformDiscoveryModels(ctx: PlatformRequestContext | null, folderKey: string | null): UsePlatformDiscoveryModelsResult;
|
|
29
|
+
export declare function useByoConnectionNames(models: readonly {
|
|
30
|
+
byoConnectionLabel?: string;
|
|
31
|
+
byomDetails?: {
|
|
32
|
+
integrationServiceConnectionId?: string;
|
|
33
|
+
} | null;
|
|
34
|
+
}[], ctx: PlatformRequestContext | null): ReadonlyMap<string, string>;
|
|
17
35
|
export interface UseCanManageByoResult {
|
|
18
36
|
canManage: boolean | undefined;
|
|
19
37
|
loading: boolean;
|
|
@@ -27,6 +45,6 @@ export interface LlmConfigurationsLinkOptions {
|
|
|
27
45
|
}
|
|
28
46
|
export declare function buildLlmConfigurationsUrl(ctx: PlatformRequestContext, options: LlmConfigurationsLinkOptions): string;
|
|
29
47
|
export declare const platformNavigation: {
|
|
30
|
-
|
|
48
|
+
openInNewTab(url: string): void;
|
|
31
49
|
};
|
|
32
50
|
//# sourceMappingURL=usePlatformAccess.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePlatformAccess.d.ts","sourceRoot":"","sources":["../../../../src/material/components/ap-model-picker/usePlatformAccess.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"usePlatformAccess.d.ts","sourceRoot":"","sources":["../../../../src/material/components/ap-model-picker/usePlatformAccess.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAA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AAC;CAClE,EAAE,EACH,GAAG,EAAE,sBAAsB,GAAG,IAAI,GACjC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CA6D7B;AAeD,MAAM,WAAW,qBAAqB;IAMpC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAiBD,wBAAgB,eAAe,CAAC,GAAG,EAAE,sBAAsB,GAAG,IAAI,GAAG,qBAAqB,CAoEzF;AAMD,MAAM,WAAW,4BAA4B;IAE3C,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IAEvB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAcD,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,4BAA4B,GACpC,MAAM,CAuBR;AAaD,eAAO,MAAM,kBAAkB;sBACX,MAAM,GAAG,IAAI;CAGhC,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { normalizeDiscoveryModels } from "./useDiscoveryModels.js";
|
|
3
|
+
const resolveToken = async (token)=>'function' == typeof token ? token() : token;
|
|
2
4
|
const FOLDERS_PAGE_SIZE = 100;
|
|
3
5
|
function useUserFolders(ctx) {
|
|
4
6
|
const [folders, setFolders] = useState([]);
|
|
@@ -15,16 +17,18 @@ function useUserFolders(ctx) {
|
|
|
15
17
|
const base = (ctx.baseUrl ?? '').replace(/\/$/, '');
|
|
16
18
|
const url = `${base}/${ctx.tenantName}/orchestrator_/api/FoldersNavigation/GetFoldersForCurrentUser?take=${FOLDERS_PAGE_SIZE}`;
|
|
17
19
|
try {
|
|
20
|
+
const bearer = await resolveToken(ctx.token);
|
|
18
21
|
const res = await fetch(url, {
|
|
19
22
|
headers: {
|
|
20
|
-
Authorization: `Bearer ${
|
|
21
|
-
Accept: 'application/json'
|
|
23
|
+
Authorization: `Bearer ${bearer}`,
|
|
24
|
+
Accept: 'application/json',
|
|
25
|
+
'Content-Type': 'application/json'
|
|
22
26
|
},
|
|
23
27
|
signal: ctrl.signal
|
|
24
28
|
});
|
|
25
29
|
if (!res.ok) throw new Error(`FoldersNavigation API ${res.status} ${res.statusText}`);
|
|
26
30
|
const data = await res.json();
|
|
27
|
-
if (!ctrl.signal.aborted) setFolders((data.PageItems ?? []).map((f)=>({
|
|
31
|
+
if (!ctrl.signal.aborted) setFolders((data.PageItems ?? []).filter((f)=>'Personal' !== f.FolderType).map((f)=>({
|
|
28
32
|
id: f.Key,
|
|
29
33
|
label: f.DisplayName,
|
|
30
34
|
numericId: f.Id
|
|
@@ -59,6 +63,130 @@ function useUserFolders(ctx) {
|
|
|
59
63
|
refetch: fetchFolders
|
|
60
64
|
};
|
|
61
65
|
}
|
|
66
|
+
function usePlatformDiscoveryModels(ctx, folderKey) {
|
|
67
|
+
const [models, setModels] = useState(void 0);
|
|
68
|
+
const [loading, setLoading] = useState(false);
|
|
69
|
+
const [error, setError] = useState(null);
|
|
70
|
+
const abortRef = useRef(null);
|
|
71
|
+
const fetchModels = useCallback(async ()=>{
|
|
72
|
+
if (!ctx) return;
|
|
73
|
+
abortRef.current?.abort();
|
|
74
|
+
const ctrl = new AbortController();
|
|
75
|
+
abortRef.current = ctrl;
|
|
76
|
+
setLoading(true);
|
|
77
|
+
setError(null);
|
|
78
|
+
const base = (ctx.baseUrl ?? '').replace(/\/$/, '');
|
|
79
|
+
let url;
|
|
80
|
+
if (ctx.organizationId && ctx.tenantId) {
|
|
81
|
+
let origin = '';
|
|
82
|
+
try {
|
|
83
|
+
origin = base ? new URL(base).origin : '';
|
|
84
|
+
} catch {
|
|
85
|
+
origin = '';
|
|
86
|
+
}
|
|
87
|
+
url = `${origin}/${ctx.organizationId}/${ctx.tenantId}/llmgateway_/api/discovery`;
|
|
88
|
+
} else url = `${base}/${ctx.tenantName}/llmgateway_/api/discovery`;
|
|
89
|
+
try {
|
|
90
|
+
const bearer = await resolveToken(ctx.token);
|
|
91
|
+
const headers = {
|
|
92
|
+
Authorization: `Bearer ${bearer}`,
|
|
93
|
+
Accept: 'application/json',
|
|
94
|
+
'Content-Type': 'application/json'
|
|
95
|
+
};
|
|
96
|
+
if (ctx.requestingProduct) headers['X-UiPath-LlmGateway-RequestingProduct'] = ctx.requestingProduct;
|
|
97
|
+
if (ctx.requestingFeature) headers['X-UiPath-LlmGateway-RequestingFeature'] = ctx.requestingFeature;
|
|
98
|
+
if (ctx.userId) headers['X-UiPath-LlmGateway-UserId'] = ctx.userId;
|
|
99
|
+
if (ctx.operationCode) headers['X-UiPath-LlmGateway-OperationCode'] = ctx.operationCode;
|
|
100
|
+
if (folderKey) headers['X-UiPath-FolderKey'] = folderKey;
|
|
101
|
+
const res = await fetch(url, {
|
|
102
|
+
headers,
|
|
103
|
+
signal: ctrl.signal
|
|
104
|
+
});
|
|
105
|
+
if (!res.ok) throw new Error(`Discovery API ${res.status} ${res.statusText}`);
|
|
106
|
+
const data = await res.json();
|
|
107
|
+
if (!ctrl.signal.aborted) setModels(normalizeDiscoveryModels(Array.isArray(data) ? data : []));
|
|
108
|
+
} catch (err) {
|
|
109
|
+
if (err?.name === 'AbortError') return;
|
|
110
|
+
if (!ctrl.signal.aborted) setError(err instanceof Error ? err : new Error(String(err)));
|
|
111
|
+
} finally{
|
|
112
|
+
if (!ctrl.signal.aborted) setLoading(false);
|
|
113
|
+
}
|
|
114
|
+
}, [
|
|
115
|
+
ctx,
|
|
116
|
+
folderKey
|
|
117
|
+
]);
|
|
118
|
+
useEffect(()=>{
|
|
119
|
+
if (!ctx) {
|
|
120
|
+
abortRef.current?.abort();
|
|
121
|
+
setModels(void 0);
|
|
122
|
+
setLoading(false);
|
|
123
|
+
setError(null);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
fetchModels();
|
|
127
|
+
return ()=>abortRef.current?.abort();
|
|
128
|
+
}, [
|
|
129
|
+
ctx,
|
|
130
|
+
fetchModels
|
|
131
|
+
]);
|
|
132
|
+
return {
|
|
133
|
+
models,
|
|
134
|
+
loading,
|
|
135
|
+
error,
|
|
136
|
+
refetch: fetchModels
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const EMPTY_GUID = '00000000-0000-0000-0000-000000000000';
|
|
140
|
+
function useByoConnectionNames(models, ctx) {
|
|
141
|
+
const [names, setNames] = useState(new Map());
|
|
142
|
+
const requestedRef = useRef(new Set());
|
|
143
|
+
useEffect(()=>{
|
|
144
|
+
if (!ctx) return;
|
|
145
|
+
const pending = [
|
|
146
|
+
...new Set(models.filter((m)=>!m.byoConnectionLabel).map((m)=>m.byomDetails?.integrationServiceConnectionId).filter((id)=>!!id && id !== EMPTY_GUID))
|
|
147
|
+
].filter((id)=>!requestedRef.current.has(id));
|
|
148
|
+
if (0 === pending.length) return;
|
|
149
|
+
pending.forEach((id)=>requestedRef.current.add(id));
|
|
150
|
+
const ctrl = new AbortController();
|
|
151
|
+
const base = (ctx.baseUrl ?? '').replace(/\/$/, '');
|
|
152
|
+
(async ()=>{
|
|
153
|
+
const bearer = await resolveToken(ctx.token);
|
|
154
|
+
const resolved = await Promise.all(pending.map(async (id)=>{
|
|
155
|
+
try {
|
|
156
|
+
const res = await fetch(`${base}/${ctx.tenantName}/connections_/api/v1/Connections/${encodeURIComponent(id)}`, {
|
|
157
|
+
headers: {
|
|
158
|
+
Authorization: `Bearer ${bearer}`,
|
|
159
|
+
Accept: 'application/json',
|
|
160
|
+
'Content-Type': 'application/json'
|
|
161
|
+
},
|
|
162
|
+
signal: ctrl.signal
|
|
163
|
+
});
|
|
164
|
+
if (!res.ok) return null;
|
|
165
|
+
const data = await res.json();
|
|
166
|
+
return data.name ? [
|
|
167
|
+
id,
|
|
168
|
+
data.name
|
|
169
|
+
] : null;
|
|
170
|
+
} catch {
|
|
171
|
+
if (ctrl.signal.aborted) requestedRef.current.delete(id);
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}));
|
|
175
|
+
const found = resolved.filter((entry)=>null !== entry);
|
|
176
|
+
if (!ctrl.signal.aborted && found.length > 0) setNames((prev)=>new Map([
|
|
177
|
+
...prev,
|
|
178
|
+
...found
|
|
179
|
+
]));
|
|
180
|
+
})().catch(()=>{
|
|
181
|
+
pending.forEach((id)=>requestedRef.current.delete(id));
|
|
182
|
+
});
|
|
183
|
+
return ()=>ctrl.abort();
|
|
184
|
+
}, [
|
|
185
|
+
ctx,
|
|
186
|
+
models
|
|
187
|
+
]);
|
|
188
|
+
return names;
|
|
189
|
+
}
|
|
62
190
|
const ORG_ADMIN_ROLES = [
|
|
63
191
|
'ACCOUNT_ADMIN',
|
|
64
192
|
'ACCOUNT_OWNER'
|
|
@@ -84,13 +212,14 @@ function useCanManageByo(ctx) {
|
|
|
84
212
|
setError(null);
|
|
85
213
|
const base = (ctx.baseUrl ?? '').replace(/\/$/, '');
|
|
86
214
|
const url = `${base}/portal_/api/organization/UserOrganizationInfo`;
|
|
87
|
-
fetch(url, {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
215
|
+
resolveToken(ctx.token).then((bearer)=>fetch(url, {
|
|
216
|
+
headers: {
|
|
217
|
+
Authorization: `Bearer ${bearer}`,
|
|
218
|
+
Accept: 'application/json',
|
|
219
|
+
'Content-Type': 'application/json'
|
|
220
|
+
},
|
|
221
|
+
signal: ctrl.signal
|
|
222
|
+
})).then(async (res)=>{
|
|
94
223
|
if (!res.ok) throw new Error(`UserOrganizationInfo API ${res.status} ${res.statusText}`);
|
|
95
224
|
const data = await res.json();
|
|
96
225
|
if (!ctrl.signal.aborted) setCanManage(ORG_ADMIN_ROLES.includes(data.accountRoleType ?? ''));
|
|
@@ -134,8 +263,8 @@ function buildLlmConfigurationsUrl(ctx, options) {
|
|
|
134
263
|
return `${root}${qs ? `?${qs}` : ''}`;
|
|
135
264
|
}
|
|
136
265
|
const platformNavigation = {
|
|
137
|
-
|
|
138
|
-
globalThis.
|
|
266
|
+
openInNewTab (url) {
|
|
267
|
+
globalThis.open?.(url, '_blank', 'noopener,noreferrer');
|
|
139
268
|
}
|
|
140
269
|
};
|
|
141
|
-
export { buildLlmConfigurationsUrl, platformNavigation, useCanManageByo, useUserFolders };
|
|
270
|
+
export { buildLlmConfigurationsUrl, platformNavigation, useByoConnectionNames, useCanManageByo, usePlatformDiscoveryModels, useUserFolders };
|
|
@@ -114,7 +114,13 @@ function deriveModelTags(model, context = {}) {
|
|
|
114
114
|
}) : `Routes traffic outside ${context.homeRegion}`
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
const poolBadges = context.badgesFor?.(model) ?? (()=>{
|
|
118
|
+
const tier = defaultCostTier(model);
|
|
119
|
+
return tier ? [
|
|
120
|
+
`cost-${tier}`
|
|
121
|
+
] : [];
|
|
122
|
+
})();
|
|
123
|
+
for (const kind of poolBadges){
|
|
118
124
|
const def = external_badges_cjs_namespaceObject.MODEL_BADGES[kind];
|
|
119
125
|
if (def) tags.push({
|
|
120
126
|
kind,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/material/components/ap-model-picker/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG/C,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAS9E,MAAM,WAAW,sBAAsB;IAOrC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IAExB,UAAU,CAAC,EAAE,MAAM,CAAC;IASpB,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAKxC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC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,QAAQ,GAAG,MAAM,CAAC;AAQ/D,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAMpC,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAwED,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,EAAE,EACxB,QAAQ,GAAE,aAA8B,EACxC,OAAO,GAAE,kBAAuB,GAC/B,UAAU,EAAE,CA6Ed;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAkBtF"}
|
|
@@ -82,7 +82,13 @@ function deriveModelTags(model, context = {}) {
|
|
|
82
82
|
}) : `Routes traffic outside ${context.homeRegion}`
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
const poolBadges = context.badgesFor?.(model) ?? (()=>{
|
|
86
|
+
const tier = defaultCostTier(model);
|
|
87
|
+
return tier ? [
|
|
88
|
+
`cost-${tier}`
|
|
89
|
+
] : [];
|
|
90
|
+
})();
|
|
91
|
+
for (const kind of poolBadges){
|
|
86
92
|
const def = MODEL_BADGES[kind];
|
|
87
93
|
if (def) tags.push({
|
|
88
94
|
kind,
|