@uipath/apollo-react 5.2.0 → 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/material/components/ap-model-picker/ModelPicker.cjs +65 -21
- package/dist/material/components/ap-model-picker/ModelPicker.d.ts +3 -3
- package/dist/material/components/ap-model-picker/ModelPicker.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/ModelPicker.js +66 -22
- package/dist/material/components/ap-model-picker/index.cjs +7 -1
- package/dist/material/components/ap-model-picker/index.d.ts +1 -1
- 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/types.d.ts +1 -0
- 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 +132 -4
- package/dist/material/components/ap-model-picker/usePlatformAccess.d.ts +17 -1
- package/dist/material/components/ap-model-picker/usePlatformAccess.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/usePlatformAccess.js +126 -4
- 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,14 @@ 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");
|
|
33
36
|
const resolveToken = async (token)=>'function' == typeof token ? token() : token;
|
|
34
37
|
const FOLDERS_PAGE_SIZE = 100;
|
|
35
38
|
function useUserFolders(ctx) {
|
|
@@ -93,6 +96,130 @@ function useUserFolders(ctx) {
|
|
|
93
96
|
refetch: fetchFolders
|
|
94
97
|
};
|
|
95
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
|
+
}
|
|
96
223
|
const ORG_ADMIN_ROLES = [
|
|
97
224
|
'ACCOUNT_ADMIN',
|
|
98
225
|
'ACCOUNT_OWNER'
|
|
@@ -169,21 +296,22 @@ function buildLlmConfigurationsUrl(ctx, options) {
|
|
|
169
296
|
return `${root}${qs ? `?${qs}` : ''}`;
|
|
170
297
|
}
|
|
171
298
|
const platformNavigation = {
|
|
172
|
-
assign (url) {
|
|
173
|
-
globalThis.location?.assign(url);
|
|
174
|
-
},
|
|
175
299
|
openInNewTab (url) {
|
|
176
300
|
globalThis.open?.(url, '_blank', 'noopener,noreferrer');
|
|
177
301
|
}
|
|
178
302
|
};
|
|
179
303
|
exports.buildLlmConfigurationsUrl = __webpack_exports__.buildLlmConfigurationsUrl;
|
|
180
304
|
exports.platformNavigation = __webpack_exports__.platformNavigation;
|
|
305
|
+
exports.useByoConnectionNames = __webpack_exports__.useByoConnectionNames;
|
|
181
306
|
exports.useCanManageByo = __webpack_exports__.useCanManageByo;
|
|
307
|
+
exports.usePlatformDiscoveryModels = __webpack_exports__.usePlatformDiscoveryModels;
|
|
182
308
|
exports.useUserFolders = __webpack_exports__.useUserFolders;
|
|
183
309
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
184
310
|
"buildLlmConfigurationsUrl",
|
|
185
311
|
"platformNavigation",
|
|
312
|
+
"useByoConnectionNames",
|
|
186
313
|
"useCanManageByo",
|
|
314
|
+
"usePlatformDiscoveryModels",
|
|
187
315
|
"useUserFolders"
|
|
188
316
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
189
317
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { FolderSwitcherFolder } from './primitives/FolderSwitcher';
|
|
2
|
+
import type { DiscoveryModel } from './types';
|
|
2
3
|
export type PlatformToken = string | (() => string | Promise<string>);
|
|
3
4
|
export interface PlatformRequestContext {
|
|
4
5
|
token: PlatformToken;
|
|
5
6
|
baseUrl?: string;
|
|
6
7
|
tenantName: string;
|
|
8
|
+
organizationId?: string;
|
|
7
9
|
tenantId?: string;
|
|
8
10
|
requestingProduct?: string;
|
|
9
11
|
requestingFeature?: string;
|
|
12
|
+
operationCode?: string;
|
|
13
|
+
userId?: string;
|
|
10
14
|
}
|
|
11
15
|
export interface UseUserFoldersResult {
|
|
12
16
|
folders: FolderSwitcherFolder[];
|
|
@@ -15,6 +19,19 @@ export interface UseUserFoldersResult {
|
|
|
15
19
|
refetch: () => void;
|
|
16
20
|
}
|
|
17
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>;
|
|
18
35
|
export interface UseCanManageByoResult {
|
|
19
36
|
canManage: boolean | undefined;
|
|
20
37
|
loading: boolean;
|
|
@@ -28,7 +45,6 @@ export interface LlmConfigurationsLinkOptions {
|
|
|
28
45
|
}
|
|
29
46
|
export declare function buildLlmConfigurationsUrl(ctx: PlatformRequestContext, options: LlmConfigurationsLinkOptions): string;
|
|
30
47
|
export declare const platformNavigation: {
|
|
31
|
-
assign(url: string): void;
|
|
32
48
|
openInNewTab(url: string): void;
|
|
33
49
|
};
|
|
34
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,EAAE,MAAM,SAAS,CAAC;AAgB9C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAKtE,MAAM,WAAW,sBAAsB;IAErC,KAAK,EAAE,aAAa,CAAC;IAWrB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,UAAU,EAAE,MAAM,CAAC;IAOnB,cAAc,CAAC,EAAE,MAAM,CAAC;IAQxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAMlB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAO3B,aAAa,CAAC,EAAE,MAAM,CAAC;IAOvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAqBD,MAAM,WAAW,oBAAoB;IAMnC,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AA2BD,wBAAgB,cAAc,CAAC,GAAG,EAAE,sBAAsB,GAAG,IAAI,GAAG,oBAAoB,CAyEvF;AAMD,MAAM,WAAW,gCAAgC;IAE/C,MAAM,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAgBD,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,sBAAsB,GAAG,IAAI,EAClC,SAAS,EAAE,MAAM,GAAG,IAAI,GACvB,gCAAgC,CA8ElC;AA4BD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE;QAAE,8BAA8B,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;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,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { normalizeDiscoveryModels } from "./useDiscoveryModels.js";
|
|
2
3
|
const resolveToken = async (token)=>'function' == typeof token ? token() : token;
|
|
3
4
|
const FOLDERS_PAGE_SIZE = 100;
|
|
4
5
|
function useUserFolders(ctx) {
|
|
@@ -62,6 +63,130 @@ function useUserFolders(ctx) {
|
|
|
62
63
|
refetch: fetchFolders
|
|
63
64
|
};
|
|
64
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
|
+
}
|
|
65
190
|
const ORG_ADMIN_ROLES = [
|
|
66
191
|
'ACCOUNT_ADMIN',
|
|
67
192
|
'ACCOUNT_OWNER'
|
|
@@ -138,11 +263,8 @@ function buildLlmConfigurationsUrl(ctx, options) {
|
|
|
138
263
|
return `${root}${qs ? `?${qs}` : ''}`;
|
|
139
264
|
}
|
|
140
265
|
const platformNavigation = {
|
|
141
|
-
assign (url) {
|
|
142
|
-
globalThis.location?.assign(url);
|
|
143
|
-
},
|
|
144
266
|
openInNewTab (url) {
|
|
145
267
|
globalThis.open?.(url, '_blank', 'noopener,noreferrer');
|
|
146
268
|
}
|
|
147
269
|
};
|
|
148
|
-
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;IAUpC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,cAAc,EAAE,CAAC;IAQjE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,QAAQ,EAAE,CAAC;CAChE;AAiBD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,EACrB,OAAO,GAAE,sBAA2B,GACnC,QAAQ,EAAE,
|
|
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;IAUpC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,cAAc,EAAE,CAAC;IAQjE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,QAAQ,EAAE,CAAC;CAChE;AAiBD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,EACrB,OAAO,GAAE,sBAA2B,GACnC,QAAQ,EAAE,CAqKZ;AAmBD,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI,CAMtE;AAoBD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAa1E;AA8BD,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,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,
|