@uipath/conversational-tool 1.201.0-preview.131 → 1.201.0-preview.133

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,111 @@
1
+ import {
2
+ CLI_EXTERNAL_USER_ID,
3
+ addSdkUserAgentHeader,
4
+ getLoginStatusAsync,
5
+ getSdkUserAgentToken,
6
+ package_default
7
+ } from "./tool-23qdvt30.js";
8
+ import"./tool-9qecd4wb.js";
9
+ import"./tool-4pvh3k50.js";
10
+ import"./tool-5arsyj36.js";
11
+ import"./tool-wckvcay0.js";
12
+
13
+ // src/api/cas-client.ts
14
+ var SDK_USER_AGENT = getSdkUserAgentToken(package_default);
15
+ var SIP_TRUNK_PAGE_SIZE = 200;
16
+ var MAX_SIP_TRUNK_PAGES = 100;
17
+
18
+ class CasApiError extends Error {
19
+ status;
20
+ constructor(message, status) {
21
+ super(message);
22
+ this.status = status;
23
+ this.name = "CasApiError";
24
+ }
25
+ }
26
+ var getCasSession = async () => {
27
+ const status = await getLoginStatusAsync();
28
+ if (status.loginStatus !== "Logged in" || !status.accessToken || !status.baseUrl || !status.organizationId || !status.tenantId) {
29
+ throw new CasApiError(status.hint ?? "Not logged in. Run 'uip login' first.", 401);
30
+ }
31
+ return {
32
+ baseUrl: status.baseUrl,
33
+ organizationId: status.organizationId,
34
+ tenantId: status.tenantId,
35
+ accessToken: status.accessToken
36
+ };
37
+ };
38
+ var casFetch = async (session, path, init) => {
39
+ const response = await fetch(`${session.baseUrl}/${session.organizationId}/${session.tenantId}/autopilotforeveryone_${path}`, {
40
+ method: init?.method ?? "GET",
41
+ headers: addSdkUserAgentHeader({
42
+ Authorization: `Bearer ${session.accessToken}`,
43
+ "X-UiPath-TenantGlobalId": session.tenantId,
44
+ "x-uipath-external-user-id": CLI_EXTERNAL_USER_ID,
45
+ ...init?.body !== undefined ? { "Content-Type": "application/json" } : {}
46
+ }, SDK_USER_AGENT),
47
+ body: init?.body !== undefined ? JSON.stringify(init.body) : undefined
48
+ });
49
+ if (!response.ok) {
50
+ const body = await response.text().catch(() => "");
51
+ throw new CasApiError(`Conversational service request failed: HTTP ${response.status}${body ? ` — ${body.slice(0, 500)}` : ""}`, response.status);
52
+ }
53
+ return response.json();
54
+ };
55
+ var listSipTrunks = async (direction) => {
56
+ const session = await getCasSession();
57
+ const trunks = [];
58
+ const seen = new Set;
59
+ for (let page = 0;page < MAX_SIP_TRUNK_PAGES; page++) {
60
+ const params = new URLSearchParams({
61
+ pageSize: String(SIP_TRUNK_PAGE_SIZE),
62
+ page: String(page)
63
+ });
64
+ if (direction !== undefined)
65
+ params.set("direction", direction);
66
+ const data = await casFetch(session, `/api/v1/sip/trunk?${params.toString()}`);
67
+ const pageTrunks = data.trunks ?? [];
68
+ const fresh = pageTrunks.filter((t) => !seen.has(t.id));
69
+ for (const t of fresh)
70
+ seen.add(t.id);
71
+ trunks.push(...fresh);
72
+ if (fresh.length === 0 || pageTrunks.length < SIP_TRUNK_PAGE_SIZE) {
73
+ break;
74
+ }
75
+ }
76
+ return trunks;
77
+ };
78
+ var resolveSipTrunk = async (idOrNumber) => {
79
+ const trunks = await listSipTrunks();
80
+ const trunk = trunks.find((t) => idOrNumber.startsWith("+") ? t.phoneNumber === idOrNumber : t.id.toLowerCase() === idOrNumber.toLowerCase());
81
+ if (!trunk) {
82
+ throw new CasApiError(`No SIP trunk matches '${idOrNumber}'. Run 'uip conversational trunks list' to see the tenant's trunks.`, 404);
83
+ }
84
+ return trunk;
85
+ };
86
+ var listVoiceEntryPoints = async (processKey, folderKey) => {
87
+ const session = await getCasSession();
88
+ const params = new URLSearchParams({
89
+ folderKey,
90
+ triggerType: "core.trigger.voice"
91
+ });
92
+ const data = await casFetch(session, `/api/v1/maestro/${encodeURIComponent(processKey)}/entry-points?${params.toString()}`);
93
+ return data.entryPoints ?? [];
94
+ };
95
+ var updateSipTrunkBinding = async (trunkId, binding) => {
96
+ const session = await getCasSession();
97
+ const data = await casFetch(session, `/api/v1/sip/trunk/${encodeURIComponent(trunkId)}`, { method: "PATCH", body: binding });
98
+ if (!data.trunk) {
99
+ throw new Error("The conversational service accepted the update but returned no trunk.");
100
+ }
101
+ return data.trunk;
102
+ };
103
+ export {
104
+ updateSipTrunkBinding,
105
+ resolveSipTrunk,
106
+ listVoiceEntryPoints,
107
+ listSipTrunks,
108
+ CasApiError
109
+ };
110
+
111
+ //# debugId=4697A834F80404C064756E2164756E21
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  #!/usr/bin/env bun
2
2
  import {
3
- Command,
4
3
  metadata,
5
4
  registerCommands
6
- } from "./tool-yj26jyej.js";
5
+ } from "./tool-vw0n2t6n.js";
7
6
  import"./tool-a8ky4eng.js";
7
+ import {
8
+ Command
9
+ } from "./tool-23qdvt30.js";
8
10
  import"./tool-9qecd4wb.js";
9
11
  import"./tool-4pvh3k50.js";
10
12
  import"./tool-5arsyj36.js";
@@ -17,4 +19,4 @@ program.name(metadata.name).description(metadata.description).version(metadata.v
17
19
  await registerCommands(program);
18
20
  await program.parseAsync(process.argv);
19
21
 
20
- //# debugId=7267C715B48C49F364756E2164756E21
22
+ //# debugId=DB8E88539A42BF1264756E2164756E21