@aui.io/aui-client 3.1.2 → 3.2.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/README.md +196 -69
- package/dist/cjs/ApolloClientWrapper.d.ts +52 -24
- package/dist/cjs/ApolloClientWrapper.js +86 -58
- package/dist/cjs/BaseClient.d.ts +5 -0
- package/dist/cjs/Client.d.ts +4 -1
- package/dist/cjs/Client.js +24 -9
- package/dist/cjs/api/resources/agentVersions/client/Client.d.ts +26 -2
- package/dist/cjs/api/resources/agentVersions/client/Client.js +96 -43
- package/dist/cjs/api/resources/agentVersions/client/requests/AgentVersionPushRequest.d.ts +1 -1
- package/dist/cjs/api/resources/agents/client/Client.d.ts +22 -7
- package/dist/cjs/api/resources/agents/client/Client.js +80 -39
- package/dist/cjs/api/resources/agents/client/requests/{ExternalAgentCreateRequest.d.ts → AgentCreateRequest.d.ts} +1 -1
- package/dist/{esm/api/resources/agents/client/requests/ExternalAgentUpdateRequest.d.mts → cjs/api/resources/agents/client/requests/AgentUpdateRequest.d.ts} +1 -1
- package/dist/cjs/api/resources/agents/client/requests/ListAgentsRequest.d.ts +1 -1
- package/dist/cjs/api/resources/agents/client/requests/index.d.ts +2 -2
- package/dist/cjs/api/resources/auth/client/Client.d.ts +3 -2
- package/dist/cjs/api/resources/auth/client/Client.js +20 -8
- package/dist/cjs/api/resources/channels/client/Client.d.ts +7 -6
- package/dist/cjs/api/resources/channels/client/Client.js +24 -12
- package/dist/cjs/api/resources/channels/client/requests/InitiateThreadRequest.d.ts +3 -10
- package/dist/cjs/api/resources/messaging/client/Client.d.ts +51 -14
- package/dist/cjs/api/resources/messaging/client/Client.js +249 -50
- package/dist/cjs/api/resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.d.ts +9 -0
- package/dist/cjs/api/resources/messaging/client/requests/RerunMessageRequest.d.ts +2 -2
- package/dist/cjs/api/resources/messaging/client/requests/StreamMessageRequest.d.ts +0 -1
- package/dist/cjs/api/resources/messaging/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/projects/client/Client.d.ts +14 -2
- package/dist/cjs/api/resources/projects/client/Client.js +66 -31
- package/dist/cjs/api/resources/session/client/Client.d.ts +2 -1
- package/dist/cjs/api/resources/session/client/Client.js +12 -2
- package/dist/cjs/api/resources/threads/client/Client.d.ts +37 -2
- package/dist/cjs/api/resources/threads/client/Client.js +155 -31
- package/dist/cjs/api/resources/threads/client/requests/UpdateThreadRequest.d.ts +8 -0
- package/dist/cjs/api/resources/threads/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/types/{ExternalAgent.d.ts → Agent.d.ts} +1 -1
- package/dist/cjs/api/types/{ExternalAgentCreateResponse.d.ts → AgentCreateResponse.d.ts} +1 -1
- package/dist/cjs/api/types/{ExternalAgentListFilters.d.ts → AgentListFilters.d.ts} +1 -1
- package/dist/{esm/api/types/ExternalAgentUpdateResponse.d.mts → cjs/api/types/AgentUpdateResponse.d.ts} +1 -1
- package/dist/cjs/api/types/AgentVariables.d.ts +12 -0
- package/dist/cjs/api/types/AgentVersionPullResponse.d.ts +2 -3
- package/dist/cjs/api/types/AgentVersionPushResponse.d.ts +1 -1
- package/dist/cjs/api/types/AgentVersionWelcomeMessageResponse.d.ts +6 -0
- package/dist/cjs/api/types/GenerateFollowupSuggestionsResponse.d.ts +4 -0
- package/dist/cjs/api/types/PageAgent.d.ts +6 -0
- package/dist/cjs/api/types/PageAgentVersion.d.ts +6 -0
- package/dist/cjs/api/types/PageAgentVersion.js +3 -0
- package/dist/cjs/api/types/{ExternalPageLinks.d.ts → PageLinks.d.ts} +1 -1
- package/dist/cjs/api/types/PageLinks.js +3 -0
- package/dist/cjs/api/types/{ExternalPageMeta.d.ts → PageMeta.d.ts} +1 -1
- package/dist/cjs/api/types/PageMeta.js +3 -0
- package/dist/cjs/api/types/PageProject.d.ts +6 -0
- package/dist/cjs/api/types/PageProject.js +3 -0
- package/dist/cjs/api/types/PageThreadListItem.d.ts +6 -0
- package/dist/cjs/api/types/PageThreadListItem.js +3 -0
- package/dist/cjs/api/types/Project.d.ts +1 -1
- package/dist/cjs/api/types/SendMessageRequest.d.ts +7 -5
- package/dist/cjs/api/types/ThreadListFilters.d.ts +2 -5
- package/dist/cjs/api/types/TokenResponse.d.ts +4 -8
- package/dist/cjs/api/types/TraceDecision.d.ts +1 -2
- package/dist/cjs/api/types/VersionStats.d.ts +1 -2
- package/dist/cjs/api/types/index.d.ts +13 -10
- package/dist/cjs/api/types/index.js +13 -10
- package/dist/cjs/core/auth/AuthProvider.d.ts +4 -0
- package/dist/cjs/core/auth/AuthProvider.js +2 -0
- package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
- package/dist/cjs/core/auth/AuthRequest.js +2 -0
- package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
- package/dist/cjs/core/auth/BasicAuth.js +27 -0
- package/dist/cjs/core/auth/BearerToken.d.ts +5 -0
- package/dist/cjs/core/auth/BearerToken.js +15 -0
- package/dist/cjs/core/auth/index.d.ts +4 -0
- package/dist/cjs/core/auth/index.js +7 -0
- package/dist/cjs/core/base64.d.ts +2 -0
- package/dist/cjs/core/base64.js +26 -0
- package/dist/cjs/core/index.d.ts +2 -0
- package/dist/cjs/core/index.js +2 -0
- package/dist/cjs/environments.d.ts +2 -2
- package/dist/cjs/environments.js +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/ApolloClientWrapper.d.mts +52 -24
- package/dist/esm/ApolloClientWrapper.mjs +83 -56
- package/dist/esm/BaseClient.d.mts +5 -0
- package/dist/esm/Client.d.mts +4 -1
- package/dist/esm/Client.mjs +25 -10
- package/dist/esm/api/resources/agentVersions/client/Client.d.mts +26 -2
- package/dist/esm/api/resources/agentVersions/client/Client.mjs +97 -44
- package/dist/esm/api/resources/agentVersions/client/requests/AgentVersionPushRequest.d.mts +1 -1
- package/dist/esm/api/resources/agents/client/Client.d.mts +22 -7
- package/dist/esm/api/resources/agents/client/Client.mjs +81 -40
- package/dist/esm/api/resources/agents/client/requests/{ExternalAgentCreateRequest.d.mts → AgentCreateRequest.d.mts} +1 -1
- package/dist/{cjs/api/resources/agents/client/requests/ExternalAgentUpdateRequest.d.ts → esm/api/resources/agents/client/requests/AgentUpdateRequest.d.mts} +1 -1
- package/dist/esm/api/resources/agents/client/requests/ListAgentsRequest.d.mts +1 -1
- package/dist/esm/api/resources/agents/client/requests/index.d.mts +2 -2
- package/dist/esm/api/resources/auth/client/Client.d.mts +3 -2
- package/dist/esm/api/resources/auth/client/Client.mjs +21 -9
- package/dist/esm/api/resources/channels/client/Client.d.mts +7 -6
- package/dist/esm/api/resources/channels/client/Client.mjs +25 -13
- package/dist/esm/api/resources/channels/client/requests/InitiateThreadRequest.d.mts +3 -10
- package/dist/esm/api/resources/messaging/client/Client.d.mts +51 -14
- package/dist/esm/api/resources/messaging/client/Client.mjs +249 -50
- package/dist/esm/api/resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.d.mts +9 -0
- package/dist/esm/api/resources/messaging/client/requests/RerunMessageRequest.d.mts +2 -2
- package/dist/esm/api/resources/messaging/client/requests/StreamMessageRequest.d.mts +0 -1
- package/dist/esm/api/resources/messaging/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/projects/client/Client.d.mts +14 -2
- package/dist/esm/api/resources/projects/client/Client.mjs +67 -32
- package/dist/esm/api/resources/session/client/Client.d.mts +2 -1
- package/dist/esm/api/resources/session/client/Client.mjs +12 -2
- package/dist/esm/api/resources/threads/client/Client.d.mts +37 -2
- package/dist/esm/api/resources/threads/client/Client.mjs +156 -32
- package/dist/esm/api/resources/threads/client/requests/UpdateThreadRequest.d.mts +8 -0
- package/dist/esm/api/resources/threads/client/requests/index.d.mts +1 -0
- package/dist/esm/api/types/{ExternalAgent.d.mts → Agent.d.mts} +1 -1
- package/dist/esm/api/types/{ExternalAgentCreateResponse.d.mts → AgentCreateResponse.d.mts} +1 -1
- package/dist/esm/api/types/{ExternalAgentListFilters.d.mts → AgentListFilters.d.mts} +1 -1
- package/dist/{cjs/api/types/ExternalAgentUpdateResponse.d.ts → esm/api/types/AgentUpdateResponse.d.mts} +1 -1
- package/dist/esm/api/types/AgentVariables.d.mts +12 -0
- package/dist/esm/api/types/AgentVersionPullResponse.d.mts +2 -3
- package/dist/esm/api/types/AgentVersionPushResponse.d.mts +1 -1
- package/dist/esm/api/types/AgentVersionWelcomeMessageResponse.d.mts +6 -0
- package/dist/esm/api/types/GenerateFollowupSuggestionsResponse.d.mts +4 -0
- package/dist/esm/api/types/PageAgent.d.mts +6 -0
- package/dist/esm/api/types/PageAgentVersion.d.mts +6 -0
- package/dist/esm/api/types/PageAgentVersion.mjs +2 -0
- package/dist/esm/api/types/{ExternalPageLinks.d.mts → PageLinks.d.mts} +1 -1
- package/dist/esm/api/types/PageLinks.mjs +2 -0
- package/dist/esm/api/types/{ExternalPageMeta.d.mts → PageMeta.d.mts} +1 -1
- package/dist/esm/api/types/PageMeta.mjs +2 -0
- package/dist/esm/api/types/PageProject.d.mts +6 -0
- package/dist/esm/api/types/PageProject.mjs +2 -0
- package/dist/esm/api/types/PageThreadListItem.d.mts +6 -0
- package/dist/esm/api/types/PageThreadListItem.mjs +2 -0
- package/dist/esm/api/types/Project.d.mts +1 -1
- package/dist/esm/api/types/SendMessageRequest.d.mts +7 -5
- package/dist/esm/api/types/ThreadListFilters.d.mts +2 -5
- package/dist/esm/api/types/TokenResponse.d.mts +4 -8
- package/dist/esm/api/types/TraceDecision.d.mts +1 -2
- package/dist/esm/api/types/VersionStats.d.mts +1 -2
- package/dist/esm/api/types/index.d.mts +13 -10
- package/dist/esm/api/types/index.mjs +13 -10
- package/dist/esm/core/auth/AuthProvider.d.mts +4 -0
- package/dist/esm/core/auth/AuthProvider.mjs +1 -0
- package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
- package/dist/esm/core/auth/AuthRequest.mjs +1 -0
- package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
- package/dist/esm/core/auth/BasicAuth.mjs +24 -0
- package/dist/esm/core/auth/BearerToken.d.mts +5 -0
- package/dist/esm/core/auth/BearerToken.mjs +12 -0
- package/dist/esm/core/auth/index.d.mts +4 -0
- package/dist/esm/core/auth/index.mjs +2 -0
- package/dist/esm/core/base64.d.mts +2 -0
- package/dist/esm/core/base64.mjs +22 -0
- package/dist/esm/core/index.d.mts +2 -0
- package/dist/esm/core/index.mjs +2 -0
- package/dist/esm/environments.d.mts +2 -2
- package/dist/esm/environments.mjs +2 -2
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +568 -29
- package/dist/cjs/api/types/ExternalPageAgentVersion.d.ts +0 -6
- package/dist/cjs/api/types/ExternalPageExternalAgent.d.ts +0 -6
- package/dist/cjs/api/types/ExternalPageProject.d.ts +0 -6
- package/dist/cjs/api/types/ExternalPageThreadListItem.d.ts +0 -6
- package/dist/esm/api/types/ExternalPageAgentVersion.d.mts +0 -6
- package/dist/esm/api/types/ExternalPageExternalAgent.d.mts +0 -6
- package/dist/esm/api/types/ExternalPageProject.d.mts +0 -6
- package/dist/esm/api/types/ExternalPageThreadListItem.d.mts +0 -6
- /package/dist/cjs/api/resources/agents/client/requests/{ExternalAgentCreateRequest.js → AgentCreateRequest.js} +0 -0
- /package/dist/cjs/api/resources/agents/client/requests/{ExternalAgentUpdateRequest.js → AgentUpdateRequest.js} +0 -0
- /package/dist/cjs/api/{types/ExternalAgent.js → resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.js} +0 -0
- /package/dist/cjs/api/{types/ExternalAgentCreateResponse.js → resources/threads/client/requests/UpdateThreadRequest.js} +0 -0
- /package/dist/cjs/api/types/{ExternalAgentListFilters.js → Agent.js} +0 -0
- /package/dist/cjs/api/types/{ExternalAgentUpdateResponse.js → AgentCreateResponse.js} +0 -0
- /package/dist/cjs/api/types/{ExternalPageAgentVersion.js → AgentListFilters.js} +0 -0
- /package/dist/cjs/api/types/{ExternalPageExternalAgent.js → AgentUpdateResponse.js} +0 -0
- /package/dist/cjs/api/types/{ExternalPageLinks.js → AgentVariables.js} +0 -0
- /package/dist/cjs/api/types/{ExternalPageMeta.js → AgentVersionWelcomeMessageResponse.js} +0 -0
- /package/dist/cjs/api/types/{ExternalPageProject.js → GenerateFollowupSuggestionsResponse.js} +0 -0
- /package/dist/cjs/api/types/{ExternalPageThreadListItem.js → PageAgent.js} +0 -0
- /package/dist/esm/api/resources/agents/client/requests/{ExternalAgentCreateRequest.mjs → AgentCreateRequest.mjs} +0 -0
- /package/dist/esm/api/resources/agents/client/requests/{ExternalAgentUpdateRequest.mjs → AgentUpdateRequest.mjs} +0 -0
- /package/dist/esm/api/{types/ExternalAgent.mjs → resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.mjs} +0 -0
- /package/dist/esm/api/{types/ExternalAgentCreateResponse.mjs → resources/threads/client/requests/UpdateThreadRequest.mjs} +0 -0
- /package/dist/esm/api/types/{ExternalAgentListFilters.mjs → Agent.mjs} +0 -0
- /package/dist/esm/api/types/{ExternalAgentUpdateResponse.mjs → AgentCreateResponse.mjs} +0 -0
- /package/dist/esm/api/types/{ExternalPageAgentVersion.mjs → AgentListFilters.mjs} +0 -0
- /package/dist/esm/api/types/{ExternalPageExternalAgent.mjs → AgentUpdateResponse.mjs} +0 -0
- /package/dist/esm/api/types/{ExternalPageLinks.mjs → AgentVariables.mjs} +0 -0
- /package/dist/esm/api/types/{ExternalPageMeta.mjs → AgentVersionWelcomeMessageResponse.mjs} +0 -0
- /package/dist/esm/api/types/{ExternalPageProject.mjs → GenerateFollowupSuggestionsResponse.mjs} +0 -0
- /package/dist/esm/api/types/{ExternalPageThreadListItem.mjs → PageAgent.mjs} +0 -0
|
@@ -8,16 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
11
|
+
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
|
|
12
12
|
import * as core from "../../../../core/index.mjs";
|
|
13
13
|
import * as environments from "../../../../environments.mjs";
|
|
14
14
|
import * as errors from "../../../../errors/index.mjs";
|
|
15
15
|
import * as Apollo from "../../../index.mjs";
|
|
16
16
|
export class Agents {
|
|
17
|
-
constructor(_options
|
|
17
|
+
constructor(_options) {
|
|
18
18
|
this._options = _options;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
+
* List the project's agents, optionally filtered by name.
|
|
22
|
+
*
|
|
21
23
|
* @param {string} projectId
|
|
22
24
|
* @param {Apollo.ListAgentsRequest} request
|
|
23
25
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -40,7 +42,7 @@ export class Agents {
|
|
|
40
42
|
}
|
|
41
43
|
__listAgents(projectId, request, requestOptions) {
|
|
42
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
45
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
44
46
|
const { filters, "page[size]": pageSize, "page[after]": pageAfter, "page[before]": pageBefore, sort_by: sortBy, sort_order: sortOrder, } = request;
|
|
45
47
|
const _queryParams = {};
|
|
46
48
|
_queryParams.filters = filters;
|
|
@@ -59,16 +61,19 @@ export class Agents {
|
|
|
59
61
|
if (sortOrder != null) {
|
|
60
62
|
_queryParams.sort_order = sortOrder;
|
|
61
63
|
}
|
|
62
|
-
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
64
|
+
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
|
|
65
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
66
|
+
"x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
|
|
67
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
63
68
|
const _response = yield core.fetcher({
|
|
64
|
-
url: core.url.join((
|
|
69
|
+
url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `management/v1/projects/${core.url.encodePathParam(projectId)}/agents`),
|
|
65
70
|
method: "GET",
|
|
66
71
|
headers: _headers,
|
|
67
72
|
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
68
|
-
timeoutMs: ((
|
|
69
|
-
maxRetries: (
|
|
73
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
74
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
70
75
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
71
|
-
fetchFn: (
|
|
76
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
72
77
|
logging: this._options.logging,
|
|
73
78
|
});
|
|
74
79
|
if (_response.ok) {
|
|
@@ -116,8 +121,11 @@ export class Agents {
|
|
|
116
121
|
});
|
|
117
122
|
}
|
|
118
123
|
/**
|
|
124
|
+
* Create an agent in the project. New agents start without a live version
|
|
125
|
+
* — create and publish a version to make the agent answer.
|
|
126
|
+
*
|
|
119
127
|
* @param {string} projectId
|
|
120
|
-
* @param {Apollo.
|
|
128
|
+
* @param {Apollo.AgentCreateRequest} request
|
|
121
129
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
122
130
|
*
|
|
123
131
|
* @throws {@link Apollo.BadRequestError}
|
|
@@ -138,20 +146,23 @@ export class Agents {
|
|
|
138
146
|
}
|
|
139
147
|
__createAgent(projectId, request, requestOptions) {
|
|
140
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
142
|
-
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
149
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
150
|
+
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
|
|
151
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
152
|
+
"x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
|
|
153
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
143
154
|
const _response = yield core.fetcher({
|
|
144
|
-
url: core.url.join((
|
|
155
|
+
url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `management/v1/projects/${core.url.encodePathParam(projectId)}/agents`),
|
|
145
156
|
method: "POST",
|
|
146
157
|
headers: _headers,
|
|
147
158
|
contentType: "application/json",
|
|
148
159
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
149
160
|
requestType: "json",
|
|
150
161
|
body: request,
|
|
151
|
-
timeoutMs: ((
|
|
152
|
-
maxRetries: (
|
|
162
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
163
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
153
164
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
154
|
-
fetchFn: (
|
|
165
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
155
166
|
logging: this._options.logging,
|
|
156
167
|
});
|
|
157
168
|
if (_response.ok) {
|
|
@@ -199,6 +210,8 @@ export class Agents {
|
|
|
199
210
|
});
|
|
200
211
|
}
|
|
201
212
|
/**
|
|
213
|
+
* Fetch one agent, including which version is currently live.
|
|
214
|
+
*
|
|
202
215
|
* @param {string} agentId
|
|
203
216
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
204
217
|
*
|
|
@@ -218,17 +231,20 @@ export class Agents {
|
|
|
218
231
|
}
|
|
219
232
|
__getAgent(agentId, requestOptions) {
|
|
220
233
|
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
222
|
-
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
234
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
235
|
+
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
|
|
236
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
237
|
+
"x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
|
|
238
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
223
239
|
const _response = yield core.fetcher({
|
|
224
|
-
url: core.url.join((
|
|
240
|
+
url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `management/v1/agents/${core.url.encodePathParam(agentId)}`),
|
|
225
241
|
method: "GET",
|
|
226
242
|
headers: _headers,
|
|
227
243
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
228
|
-
timeoutMs: ((
|
|
229
|
-
maxRetries: (
|
|
244
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
245
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
230
246
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
231
|
-
fetchFn: (
|
|
247
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
232
248
|
logging: this._options.logging,
|
|
233
249
|
});
|
|
234
250
|
if (_response.ok) {
|
|
@@ -276,6 +292,8 @@ export class Agents {
|
|
|
276
292
|
});
|
|
277
293
|
}
|
|
278
294
|
/**
|
|
295
|
+
* Delete an agent and all of its versions. This cannot be undone.
|
|
296
|
+
*
|
|
279
297
|
* @param {string} agentId
|
|
280
298
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
281
299
|
*
|
|
@@ -295,17 +313,20 @@ export class Agents {
|
|
|
295
313
|
}
|
|
296
314
|
__deleteAgent(agentId, requestOptions) {
|
|
297
315
|
return __awaiter(this, void 0, void 0, function* () {
|
|
298
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
299
|
-
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
316
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
317
|
+
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
|
|
318
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
319
|
+
"x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
|
|
320
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
300
321
|
const _response = yield core.fetcher({
|
|
301
|
-
url: core.url.join((
|
|
322
|
+
url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `management/v1/agents/${core.url.encodePathParam(agentId)}`),
|
|
302
323
|
method: "DELETE",
|
|
303
324
|
headers: _headers,
|
|
304
325
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
305
|
-
timeoutMs: ((
|
|
306
|
-
maxRetries: (
|
|
326
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
327
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
307
328
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
308
|
-
fetchFn: (
|
|
329
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
309
330
|
logging: this._options.logging,
|
|
310
331
|
});
|
|
311
332
|
if (_response.ok) {
|
|
@@ -353,8 +374,11 @@ export class Agents {
|
|
|
353
374
|
});
|
|
354
375
|
}
|
|
355
376
|
/**
|
|
377
|
+
* Rename an agent. To change which version is live, publish a version
|
|
378
|
+
* instead.
|
|
379
|
+
*
|
|
356
380
|
* @param {string} agentId
|
|
357
|
-
* @param {Apollo.
|
|
381
|
+
* @param {Apollo.AgentUpdateRequest} request
|
|
358
382
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
359
383
|
*
|
|
360
384
|
* @throws {@link Apollo.BadRequestError}
|
|
@@ -373,20 +397,23 @@ export class Agents {
|
|
|
373
397
|
}
|
|
374
398
|
__updateAgent(agentId_1) {
|
|
375
399
|
return __awaiter(this, arguments, void 0, function* (agentId, request = {}, requestOptions) {
|
|
376
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
377
|
-
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
400
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
401
|
+
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
|
|
402
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
403
|
+
"x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
|
|
404
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
378
405
|
const _response = yield core.fetcher({
|
|
379
|
-
url: core.url.join((
|
|
406
|
+
url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `management/v1/agents/${core.url.encodePathParam(agentId)}`),
|
|
380
407
|
method: "PATCH",
|
|
381
408
|
headers: _headers,
|
|
382
409
|
contentType: "application/json",
|
|
383
410
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
384
411
|
requestType: "json",
|
|
385
412
|
body: request,
|
|
386
|
-
timeoutMs: ((
|
|
387
|
-
maxRetries: (
|
|
413
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
414
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
388
415
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
389
|
-
fetchFn: (
|
|
416
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
390
417
|
logging: this._options.logging,
|
|
391
418
|
});
|
|
392
419
|
if (_response.ok) {
|
|
@@ -434,6 +461,8 @@ export class Agents {
|
|
|
434
461
|
});
|
|
435
462
|
}
|
|
436
463
|
/**
|
|
464
|
+
* Usage metrics for one agent, optionally bounded by a date range.
|
|
465
|
+
*
|
|
437
466
|
* @param {string} agentId
|
|
438
467
|
* @param {Apollo.GetAgentUsageRequest} request
|
|
439
468
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -457,7 +486,7 @@ export class Agents {
|
|
|
457
486
|
}
|
|
458
487
|
__getAgentUsage(agentId_1) {
|
|
459
488
|
return __awaiter(this, arguments, void 0, function* (agentId, request = {}, requestOptions) {
|
|
460
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
489
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
461
490
|
const { created_from: createdFrom, created_to: createdTo } = request;
|
|
462
491
|
const _queryParams = {};
|
|
463
492
|
if (createdFrom != null) {
|
|
@@ -466,16 +495,19 @@ export class Agents {
|
|
|
466
495
|
if (createdTo != null) {
|
|
467
496
|
_queryParams.created_to = createdTo;
|
|
468
497
|
}
|
|
469
|
-
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
498
|
+
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
|
|
499
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
500
|
+
"x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
|
|
501
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
470
502
|
const _response = yield core.fetcher({
|
|
471
|
-
url: core.url.join((
|
|
503
|
+
url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `management/v1/agents/${core.url.encodePathParam(agentId)}/usage`),
|
|
472
504
|
method: "GET",
|
|
473
505
|
headers: _headers,
|
|
474
506
|
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
475
|
-
timeoutMs: ((
|
|
476
|
-
maxRetries: (
|
|
507
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
508
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
477
509
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
478
|
-
fetchFn: (
|
|
510
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
479
511
|
logging: this._options.logging,
|
|
480
512
|
});
|
|
481
513
|
if (_response.ok) {
|
|
@@ -522,4 +554,13 @@ export class Agents {
|
|
|
522
554
|
}
|
|
523
555
|
});
|
|
524
556
|
}
|
|
557
|
+
_getAuthorizationHeader() {
|
|
558
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
559
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
560
|
+
if (bearer != null) {
|
|
561
|
+
return `Bearer ${bearer}`;
|
|
562
|
+
}
|
|
563
|
+
return undefined;
|
|
564
|
+
});
|
|
565
|
+
}
|
|
525
566
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export type {
|
|
1
|
+
export type { AgentCreateRequest } from "./AgentCreateRequest.mjs";
|
|
2
|
+
export type { AgentUpdateRequest } from "./AgentUpdateRequest.mjs";
|
|
3
3
|
export type { GetAgentUsageRequest } from "./GetAgentUsageRequest.mjs";
|
|
4
4
|
export type { ListAgentsRequest } from "./ListAgentsRequest.mjs";
|
|
@@ -9,9 +9,9 @@ export declare namespace Auth {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class Auth {
|
|
11
11
|
protected readonly _options: Auth.Options;
|
|
12
|
-
constructor(_options
|
|
12
|
+
constructor(_options: Auth.Options);
|
|
13
13
|
/**
|
|
14
|
-
* Exchange a credential for a short-lived access token. Supported grant types: `publishable_key`. Refresh and other grants will be added on the same endpoint.
|
|
14
|
+
* Exchange a credential for a short-lived access token (OAuth 2.0, RFC 6749). Supported grant types: `publishable_key`. Refresh and other grants will be added on the same endpoint.
|
|
15
15
|
*
|
|
16
16
|
* @param {Record<string, unknown>} request
|
|
17
17
|
* @param {Auth.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -28,4 +28,5 @@ export declare class Auth {
|
|
|
28
28
|
*/
|
|
29
29
|
issueToken(request: Record<string, unknown>, requestOptions?: Auth.RequestOptions): core.HttpResponsePromise<Apollo.TokenResponse>;
|
|
30
30
|
private __issueToken;
|
|
31
|
+
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
31
32
|
}
|
|
@@ -8,17 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
11
|
+
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
|
|
12
12
|
import * as core from "../../../../core/index.mjs";
|
|
13
13
|
import * as environments from "../../../../environments.mjs";
|
|
14
14
|
import * as errors from "../../../../errors/index.mjs";
|
|
15
15
|
import * as Apollo from "../../../index.mjs";
|
|
16
16
|
export class Auth {
|
|
17
|
-
constructor(_options
|
|
17
|
+
constructor(_options) {
|
|
18
18
|
this._options = _options;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Exchange a credential for a short-lived access token. Supported grant types: `publishable_key`. Refresh and other grants will be added on the same endpoint.
|
|
21
|
+
* Exchange a credential for a short-lived access token (OAuth 2.0, RFC 6749). Supported grant types: `publishable_key`. Refresh and other grants will be added on the same endpoint.
|
|
22
22
|
*
|
|
23
23
|
* @param {Record<string, unknown>} request
|
|
24
24
|
* @param {Auth.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -38,20 +38,23 @@ export class Auth {
|
|
|
38
38
|
}
|
|
39
39
|
__issueToken(request, requestOptions) {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
42
|
-
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
42
|
+
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
|
|
43
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
44
|
+
"x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
|
|
45
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
43
46
|
const _response = yield core.fetcher({
|
|
44
|
-
url: core.url.join((
|
|
47
|
+
url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "management/v1/auth/token"),
|
|
45
48
|
method: "POST",
|
|
46
49
|
headers: _headers,
|
|
47
50
|
contentType: "application/json",
|
|
48
51
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
49
52
|
requestType: "json",
|
|
50
53
|
body: request,
|
|
51
|
-
timeoutMs: ((
|
|
52
|
-
maxRetries: (
|
|
54
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
55
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
53
56
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
54
|
-
fetchFn: (
|
|
57
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
55
58
|
logging: this._options.logging,
|
|
56
59
|
});
|
|
57
60
|
if (_response.ok) {
|
|
@@ -90,4 +93,13 @@ export class Auth {
|
|
|
90
93
|
}
|
|
91
94
|
});
|
|
92
95
|
}
|
|
96
|
+
_getAuthorizationHeader() {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
99
|
+
if (bearer != null) {
|
|
100
|
+
return `Bearer ${bearer}`;
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
93
105
|
}
|
|
@@ -9,11 +9,12 @@ export declare namespace Channels {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class Channels {
|
|
11
11
|
protected readonly _options: Channels.Options;
|
|
12
|
-
constructor(_options
|
|
12
|
+
constructor(_options: Channels.Options);
|
|
13
13
|
/**
|
|
14
|
-
* Send the
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Send the opening message on ``channel`` and bind the recipient's phone
|
|
15
|
+
* number to a conversation thread. The agent is identified by your access
|
|
16
|
+
* token. Omit ``thread_id`` to start a new thread (its id is returned); pass
|
|
17
|
+
* it to continue an existing one. Template fields apply to WhatsApp only.
|
|
17
18
|
*
|
|
18
19
|
* @param {string} channel - Channel id: 'whatsapp' or 'sms'.
|
|
19
20
|
* @param {Apollo.InitiateThreadRequest} request
|
|
@@ -29,10 +30,10 @@ export declare class Channels {
|
|
|
29
30
|
*
|
|
30
31
|
* @example
|
|
31
32
|
* await client.channels.initiateThread("channel", {
|
|
32
|
-
* phone_number: "phone_number"
|
|
33
|
-
* agent_id: "agent_id"
|
|
33
|
+
* phone_number: "phone_number"
|
|
34
34
|
* })
|
|
35
35
|
*/
|
|
36
36
|
initiateThread(channel: string, request: Apollo.InitiateThreadRequest, requestOptions?: Channels.RequestOptions): core.HttpResponsePromise<Apollo.InitiateThreadResponse>;
|
|
37
37
|
private __initiateThread;
|
|
38
|
+
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
38
39
|
}
|
|
@@ -8,19 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
11
|
+
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
|
|
12
12
|
import * as core from "../../../../core/index.mjs";
|
|
13
13
|
import * as environments from "../../../../environments.mjs";
|
|
14
14
|
import * as errors from "../../../../errors/index.mjs";
|
|
15
15
|
import * as Apollo from "../../../index.mjs";
|
|
16
16
|
export class Channels {
|
|
17
|
-
constructor(_options
|
|
17
|
+
constructor(_options) {
|
|
18
18
|
this._options = _options;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Send the
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* Send the opening message on ``channel`` and bind the recipient's phone
|
|
22
|
+
* number to a conversation thread. The agent is identified by your access
|
|
23
|
+
* token. Omit ``thread_id`` to start a new thread (its id is returned); pass
|
|
24
|
+
* it to continue an existing one. Template fields apply to WhatsApp only.
|
|
24
25
|
*
|
|
25
26
|
* @param {string} channel - Channel id: 'whatsapp' or 'sms'.
|
|
26
27
|
* @param {Apollo.InitiateThreadRequest} request
|
|
@@ -36,8 +37,7 @@ export class Channels {
|
|
|
36
37
|
*
|
|
37
38
|
* @example
|
|
38
39
|
* await client.channels.initiateThread("channel", {
|
|
39
|
-
* phone_number: "phone_number"
|
|
40
|
-
* agent_id: "agent_id"
|
|
40
|
+
* phone_number: "phone_number"
|
|
41
41
|
* })
|
|
42
42
|
*/
|
|
43
43
|
initiateThread(channel, request, requestOptions) {
|
|
@@ -45,20 +45,23 @@ export class Channels {
|
|
|
45
45
|
}
|
|
46
46
|
__initiateThread(channel, request, requestOptions) {
|
|
47
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
49
|
-
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
49
|
+
const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
|
|
50
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
51
|
+
"x-organization-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.organizationApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.organizationApiKey,
|
|
52
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
50
53
|
const _response = yield core.fetcher({
|
|
51
|
-
url: core.url.join((
|
|
54
|
+
url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `messaging/v1/channels/${core.url.encodePathParam(channel)}/threads`),
|
|
52
55
|
method: "POST",
|
|
53
56
|
headers: _headers,
|
|
54
57
|
contentType: "application/json",
|
|
55
58
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
56
59
|
requestType: "json",
|
|
57
60
|
body: request,
|
|
58
|
-
timeoutMs: ((
|
|
59
|
-
maxRetries: (
|
|
61
|
+
timeoutMs: ((_h = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _f !== void 0 ? _f : (_g = this._options) === null || _g === void 0 ? void 0 : _g.timeoutInSeconds) !== null && _h !== void 0 ? _h : 60) * 1000,
|
|
62
|
+
maxRetries: (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _j !== void 0 ? _j : (_k = this._options) === null || _k === void 0 ? void 0 : _k.maxRetries,
|
|
60
63
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
61
|
-
fetchFn: (
|
|
64
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
62
65
|
logging: this._options.logging,
|
|
63
66
|
});
|
|
64
67
|
if (_response.ok) {
|
|
@@ -105,4 +108,13 @@ export class Channels {
|
|
|
105
108
|
}
|
|
106
109
|
});
|
|
107
110
|
}
|
|
111
|
+
_getAuthorizationHeader() {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
114
|
+
if (bearer != null) {
|
|
115
|
+
return `Bearer ${bearer}`;
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
108
120
|
}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @example
|
|
3
3
|
* {
|
|
4
|
-
* phone_number: "phone_number"
|
|
5
|
-
* agent_id: "agent_id"
|
|
4
|
+
* phone_number: "phone_number"
|
|
6
5
|
* }
|
|
7
6
|
*/
|
|
8
7
|
export interface InitiateThreadRequest {
|
|
9
8
|
/** Recipient phone number in E.164 (e.g. +14155551234). */
|
|
10
9
|
phone_number: string;
|
|
11
|
-
/** Agent the thread targets. */
|
|
12
|
-
agent_id: string;
|
|
13
10
|
/** When set, continue this thread instead of creating a new one. */
|
|
14
11
|
thread_id?: string;
|
|
15
|
-
/** User
|
|
16
|
-
|
|
12
|
+
/** User id for a new thread; defaults to the phone's digits. */
|
|
13
|
+
user_id?: string;
|
|
17
14
|
/** Opener body for non-template channels (SMS). Ignored by WhatsApp (uses templates). */
|
|
18
15
|
text?: string;
|
|
19
|
-
/** WhatsApp only: Twilio Content template SID override. */
|
|
20
|
-
template_id?: string;
|
|
21
16
|
/** WhatsApp only: bound to template variable {{1}}. */
|
|
22
17
|
agent_display_name?: string;
|
|
23
|
-
/** WhatsApp only: additional template variable overrides ({{2}}, {{3}}, …). */
|
|
24
|
-
content_variables?: Record<string, string | undefined>;
|
|
25
18
|
}
|