@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
|
@@ -50,10 +50,12 @@ const environments = __importStar(require("../../../../environments.js"));
|
|
|
50
50
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
51
51
|
const Apollo = __importStar(require("../../../index.js"));
|
|
52
52
|
class Agents {
|
|
53
|
-
constructor(_options
|
|
53
|
+
constructor(_options) {
|
|
54
54
|
this._options = _options;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
+
* List the project's agents, optionally filtered by name.
|
|
58
|
+
*
|
|
57
59
|
* @param {string} projectId
|
|
58
60
|
* @param {Apollo.ListAgentsRequest} request
|
|
59
61
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -76,7 +78,7 @@ class Agents {
|
|
|
76
78
|
}
|
|
77
79
|
__listAgents(projectId, request, requestOptions) {
|
|
78
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
81
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
80
82
|
const { filters, "page[size]": pageSize, "page[after]": pageAfter, "page[before]": pageBefore, sort_by: sortBy, sort_order: sortOrder, } = request;
|
|
81
83
|
const _queryParams = {};
|
|
82
84
|
_queryParams.filters = filters;
|
|
@@ -95,16 +97,19 @@ class Agents {
|
|
|
95
97
|
if (sortOrder != null) {
|
|
96
98
|
_queryParams.sort_order = sortOrder;
|
|
97
99
|
}
|
|
98
|
-
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
100
|
+
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
|
|
101
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
102
|
+
"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,
|
|
103
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
99
104
|
const _response = yield core.fetcher({
|
|
100
|
-
url: core.url.join((
|
|
105
|
+
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`),
|
|
101
106
|
method: "GET",
|
|
102
107
|
headers: _headers,
|
|
103
108
|
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
104
|
-
timeoutMs: ((
|
|
105
|
-
maxRetries: (
|
|
109
|
+
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,
|
|
110
|
+
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,
|
|
106
111
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
107
|
-
fetchFn: (
|
|
112
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
108
113
|
logging: this._options.logging,
|
|
109
114
|
});
|
|
110
115
|
if (_response.ok) {
|
|
@@ -152,8 +157,11 @@ class Agents {
|
|
|
152
157
|
});
|
|
153
158
|
}
|
|
154
159
|
/**
|
|
160
|
+
* Create an agent in the project. New agents start without a live version
|
|
161
|
+
* — create and publish a version to make the agent answer.
|
|
162
|
+
*
|
|
155
163
|
* @param {string} projectId
|
|
156
|
-
* @param {Apollo.
|
|
164
|
+
* @param {Apollo.AgentCreateRequest} request
|
|
157
165
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
158
166
|
*
|
|
159
167
|
* @throws {@link Apollo.BadRequestError}
|
|
@@ -174,20 +182,23 @@ class Agents {
|
|
|
174
182
|
}
|
|
175
183
|
__createAgent(projectId, request, requestOptions) {
|
|
176
184
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
178
|
-
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
185
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
186
|
+
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
|
|
187
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
188
|
+
"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,
|
|
189
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
179
190
|
const _response = yield core.fetcher({
|
|
180
|
-
url: core.url.join((
|
|
191
|
+
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`),
|
|
181
192
|
method: "POST",
|
|
182
193
|
headers: _headers,
|
|
183
194
|
contentType: "application/json",
|
|
184
195
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
185
196
|
requestType: "json",
|
|
186
197
|
body: request,
|
|
187
|
-
timeoutMs: ((
|
|
188
|
-
maxRetries: (
|
|
198
|
+
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,
|
|
199
|
+
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,
|
|
189
200
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
190
|
-
fetchFn: (
|
|
201
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
191
202
|
logging: this._options.logging,
|
|
192
203
|
});
|
|
193
204
|
if (_response.ok) {
|
|
@@ -235,6 +246,8 @@ class Agents {
|
|
|
235
246
|
});
|
|
236
247
|
}
|
|
237
248
|
/**
|
|
249
|
+
* Fetch one agent, including which version is currently live.
|
|
250
|
+
*
|
|
238
251
|
* @param {string} agentId
|
|
239
252
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
240
253
|
*
|
|
@@ -254,17 +267,20 @@ class Agents {
|
|
|
254
267
|
}
|
|
255
268
|
__getAgent(agentId, requestOptions) {
|
|
256
269
|
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
258
|
-
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
270
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
271
|
+
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
|
|
272
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
273
|
+
"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,
|
|
274
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
259
275
|
const _response = yield core.fetcher({
|
|
260
|
-
url: core.url.join((
|
|
276
|
+
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)}`),
|
|
261
277
|
method: "GET",
|
|
262
278
|
headers: _headers,
|
|
263
279
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
264
|
-
timeoutMs: ((
|
|
265
|
-
maxRetries: (
|
|
280
|
+
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,
|
|
281
|
+
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,
|
|
266
282
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
267
|
-
fetchFn: (
|
|
283
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
268
284
|
logging: this._options.logging,
|
|
269
285
|
});
|
|
270
286
|
if (_response.ok) {
|
|
@@ -312,6 +328,8 @@ class Agents {
|
|
|
312
328
|
});
|
|
313
329
|
}
|
|
314
330
|
/**
|
|
331
|
+
* Delete an agent and all of its versions. This cannot be undone.
|
|
332
|
+
*
|
|
315
333
|
* @param {string} agentId
|
|
316
334
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
317
335
|
*
|
|
@@ -331,17 +349,20 @@ class Agents {
|
|
|
331
349
|
}
|
|
332
350
|
__deleteAgent(agentId, requestOptions) {
|
|
333
351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
334
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
335
|
-
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
352
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
353
|
+
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
|
|
354
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
355
|
+
"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,
|
|
356
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
336
357
|
const _response = yield core.fetcher({
|
|
337
|
-
url: core.url.join((
|
|
358
|
+
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)}`),
|
|
338
359
|
method: "DELETE",
|
|
339
360
|
headers: _headers,
|
|
340
361
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
341
|
-
timeoutMs: ((
|
|
342
|
-
maxRetries: (
|
|
362
|
+
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,
|
|
363
|
+
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,
|
|
343
364
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
344
|
-
fetchFn: (
|
|
365
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
345
366
|
logging: this._options.logging,
|
|
346
367
|
});
|
|
347
368
|
if (_response.ok) {
|
|
@@ -389,8 +410,11 @@ class Agents {
|
|
|
389
410
|
});
|
|
390
411
|
}
|
|
391
412
|
/**
|
|
413
|
+
* Rename an agent. To change which version is live, publish a version
|
|
414
|
+
* instead.
|
|
415
|
+
*
|
|
392
416
|
* @param {string} agentId
|
|
393
|
-
* @param {Apollo.
|
|
417
|
+
* @param {Apollo.AgentUpdateRequest} request
|
|
394
418
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
395
419
|
*
|
|
396
420
|
* @throws {@link Apollo.BadRequestError}
|
|
@@ -409,20 +433,23 @@ class Agents {
|
|
|
409
433
|
}
|
|
410
434
|
__updateAgent(agentId_1) {
|
|
411
435
|
return __awaiter(this, arguments, void 0, function* (agentId, request = {}, requestOptions) {
|
|
412
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
413
|
-
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
436
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
437
|
+
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
|
|
438
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
439
|
+
"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,
|
|
440
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
414
441
|
const _response = yield core.fetcher({
|
|
415
|
-
url: core.url.join((
|
|
442
|
+
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)}`),
|
|
416
443
|
method: "PATCH",
|
|
417
444
|
headers: _headers,
|
|
418
445
|
contentType: "application/json",
|
|
419
446
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
420
447
|
requestType: "json",
|
|
421
448
|
body: request,
|
|
422
|
-
timeoutMs: ((
|
|
423
|
-
maxRetries: (
|
|
449
|
+
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,
|
|
450
|
+
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,
|
|
424
451
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
425
|
-
fetchFn: (
|
|
452
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
426
453
|
logging: this._options.logging,
|
|
427
454
|
});
|
|
428
455
|
if (_response.ok) {
|
|
@@ -470,6 +497,8 @@ class Agents {
|
|
|
470
497
|
});
|
|
471
498
|
}
|
|
472
499
|
/**
|
|
500
|
+
* Usage metrics for one agent, optionally bounded by a date range.
|
|
501
|
+
*
|
|
473
502
|
* @param {string} agentId
|
|
474
503
|
* @param {Apollo.GetAgentUsageRequest} request
|
|
475
504
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -493,7 +522,7 @@ class Agents {
|
|
|
493
522
|
}
|
|
494
523
|
__getAgentUsage(agentId_1) {
|
|
495
524
|
return __awaiter(this, arguments, void 0, function* (agentId, request = {}, requestOptions) {
|
|
496
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
525
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
497
526
|
const { created_from: createdFrom, created_to: createdTo } = request;
|
|
498
527
|
const _queryParams = {};
|
|
499
528
|
if (createdFrom != null) {
|
|
@@ -502,16 +531,19 @@ class Agents {
|
|
|
502
531
|
if (createdTo != null) {
|
|
503
532
|
_queryParams.created_to = createdTo;
|
|
504
533
|
}
|
|
505
|
-
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
534
|
+
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
|
|
535
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
536
|
+
"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,
|
|
537
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
506
538
|
const _response = yield core.fetcher({
|
|
507
|
-
url: core.url.join((
|
|
539
|
+
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`),
|
|
508
540
|
method: "GET",
|
|
509
541
|
headers: _headers,
|
|
510
542
|
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
511
|
-
timeoutMs: ((
|
|
512
|
-
maxRetries: (
|
|
543
|
+
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,
|
|
544
|
+
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,
|
|
513
545
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
514
|
-
fetchFn: (
|
|
546
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
515
547
|
logging: this._options.logging,
|
|
516
548
|
});
|
|
517
549
|
if (_response.ok) {
|
|
@@ -558,5 +590,14 @@ class Agents {
|
|
|
558
590
|
}
|
|
559
591
|
});
|
|
560
592
|
}
|
|
593
|
+
_getAuthorizationHeader() {
|
|
594
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
595
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
596
|
+
if (bearer != null) {
|
|
597
|
+
return `Bearer ${bearer}`;
|
|
598
|
+
}
|
|
599
|
+
return undefined;
|
|
600
|
+
});
|
|
601
|
+
}
|
|
561
602
|
}
|
|
562
603
|
exports.Agents = Agents;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export type {
|
|
1
|
+
export type { AgentCreateRequest } from "./AgentCreateRequest.js";
|
|
2
|
+
export type { AgentUpdateRequest } from "./AgentUpdateRequest.js";
|
|
3
3
|
export type { GetAgentUsageRequest } from "./GetAgentUsageRequest.js";
|
|
4
4
|
export type { ListAgentsRequest } from "./ListAgentsRequest.js";
|
|
@@ -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
|
}
|
|
@@ -50,11 +50,11 @@ const environments = __importStar(require("../../../../environments.js"));
|
|
|
50
50
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
51
51
|
const Apollo = __importStar(require("../../../index.js"));
|
|
52
52
|
class Auth {
|
|
53
|
-
constructor(_options
|
|
53
|
+
constructor(_options) {
|
|
54
54
|
this._options = _options;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* 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.
|
|
57
|
+
* 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.
|
|
58
58
|
*
|
|
59
59
|
* @param {Record<string, unknown>} request
|
|
60
60
|
* @param {Auth.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -74,20 +74,23 @@ class Auth {
|
|
|
74
74
|
}
|
|
75
75
|
__issueToken(request, requestOptions) {
|
|
76
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
78
|
-
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
77
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
78
|
+
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
|
|
79
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
80
|
+
"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,
|
|
81
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
79
82
|
const _response = yield core.fetcher({
|
|
80
|
-
url: core.url.join((
|
|
83
|
+
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"),
|
|
81
84
|
method: "POST",
|
|
82
85
|
headers: _headers,
|
|
83
86
|
contentType: "application/json",
|
|
84
87
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
85
88
|
requestType: "json",
|
|
86
89
|
body: request,
|
|
87
|
-
timeoutMs: ((
|
|
88
|
-
maxRetries: (
|
|
90
|
+
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,
|
|
91
|
+
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,
|
|
89
92
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
90
|
-
fetchFn: (
|
|
93
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
91
94
|
logging: this._options.logging,
|
|
92
95
|
});
|
|
93
96
|
if (_response.ok) {
|
|
@@ -126,5 +129,14 @@ class Auth {
|
|
|
126
129
|
}
|
|
127
130
|
});
|
|
128
131
|
}
|
|
132
|
+
_getAuthorizationHeader() {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
135
|
+
if (bearer != null) {
|
|
136
|
+
return `Bearer ${bearer}`;
|
|
137
|
+
}
|
|
138
|
+
return undefined;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
129
141
|
}
|
|
130
142
|
exports.Auth = Auth;
|
|
@@ -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
|
}
|
|
@@ -50,13 +50,14 @@ const environments = __importStar(require("../../../../environments.js"));
|
|
|
50
50
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
51
51
|
const Apollo = __importStar(require("../../../index.js"));
|
|
52
52
|
class Channels {
|
|
53
|
-
constructor(_options
|
|
53
|
+
constructor(_options) {
|
|
54
54
|
this._options = _options;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* Send the
|
|
58
|
-
*
|
|
59
|
-
*
|
|
57
|
+
* Send the opening message on ``channel`` and bind the recipient's phone
|
|
58
|
+
* number to a conversation thread. The agent is identified by your access
|
|
59
|
+
* token. Omit ``thread_id`` to start a new thread (its id is returned); pass
|
|
60
|
+
* it to continue an existing one. Template fields apply to WhatsApp only.
|
|
60
61
|
*
|
|
61
62
|
* @param {string} channel - Channel id: 'whatsapp' or 'sms'.
|
|
62
63
|
* @param {Apollo.InitiateThreadRequest} request
|
|
@@ -72,8 +73,7 @@ class Channels {
|
|
|
72
73
|
*
|
|
73
74
|
* @example
|
|
74
75
|
* await client.channels.initiateThread("channel", {
|
|
75
|
-
* phone_number: "phone_number"
|
|
76
|
-
* agent_id: "agent_id"
|
|
76
|
+
* phone_number: "phone_number"
|
|
77
77
|
* })
|
|
78
78
|
*/
|
|
79
79
|
initiateThread(channel, request, requestOptions) {
|
|
@@ -81,20 +81,23 @@ class Channels {
|
|
|
81
81
|
}
|
|
82
82
|
__initiateThread(channel, request, requestOptions) {
|
|
83
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
85
|
-
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers,
|
|
84
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
85
|
+
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
|
|
86
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
87
|
+
"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,
|
|
88
|
+
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
86
89
|
const _response = yield core.fetcher({
|
|
87
|
-
url: core.url.join((
|
|
90
|
+
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`),
|
|
88
91
|
method: "POST",
|
|
89
92
|
headers: _headers,
|
|
90
93
|
contentType: "application/json",
|
|
91
94
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
92
95
|
requestType: "json",
|
|
93
96
|
body: request,
|
|
94
|
-
timeoutMs: ((
|
|
95
|
-
maxRetries: (
|
|
97
|
+
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,
|
|
98
|
+
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,
|
|
96
99
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
97
|
-
fetchFn: (
|
|
100
|
+
fetchFn: (_l = this._options) === null || _l === void 0 ? void 0 : _l.fetch,
|
|
98
101
|
logging: this._options.logging,
|
|
99
102
|
});
|
|
100
103
|
if (_response.ok) {
|
|
@@ -141,5 +144,14 @@ class Channels {
|
|
|
141
144
|
}
|
|
142
145
|
});
|
|
143
146
|
}
|
|
147
|
+
_getAuthorizationHeader() {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
150
|
+
if (bearer != null) {
|
|
151
|
+
return `Bearer ${bearer}`;
|
|
152
|
+
}
|
|
153
|
+
return undefined;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
144
156
|
}
|
|
145
157
|
exports.Channels = Channels;
|
|
@@ -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
|
}
|