@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.
Files changed (197) hide show
  1. package/README.md +196 -69
  2. package/dist/cjs/ApolloClientWrapper.d.ts +52 -24
  3. package/dist/cjs/ApolloClientWrapper.js +86 -58
  4. package/dist/cjs/BaseClient.d.ts +5 -0
  5. package/dist/cjs/Client.d.ts +4 -1
  6. package/dist/cjs/Client.js +24 -9
  7. package/dist/cjs/api/resources/agentVersions/client/Client.d.ts +26 -2
  8. package/dist/cjs/api/resources/agentVersions/client/Client.js +96 -43
  9. package/dist/cjs/api/resources/agentVersions/client/requests/AgentVersionPushRequest.d.ts +1 -1
  10. package/dist/cjs/api/resources/agents/client/Client.d.ts +22 -7
  11. package/dist/cjs/api/resources/agents/client/Client.js +80 -39
  12. package/dist/cjs/api/resources/agents/client/requests/{ExternalAgentCreateRequest.d.ts → AgentCreateRequest.d.ts} +1 -1
  13. package/dist/{esm/api/resources/agents/client/requests/ExternalAgentUpdateRequest.d.mts → cjs/api/resources/agents/client/requests/AgentUpdateRequest.d.ts} +1 -1
  14. package/dist/cjs/api/resources/agents/client/requests/ListAgentsRequest.d.ts +1 -1
  15. package/dist/cjs/api/resources/agents/client/requests/index.d.ts +2 -2
  16. package/dist/cjs/api/resources/auth/client/Client.d.ts +3 -2
  17. package/dist/cjs/api/resources/auth/client/Client.js +20 -8
  18. package/dist/cjs/api/resources/channels/client/Client.d.ts +7 -6
  19. package/dist/cjs/api/resources/channels/client/Client.js +24 -12
  20. package/dist/cjs/api/resources/channels/client/requests/InitiateThreadRequest.d.ts +3 -10
  21. package/dist/cjs/api/resources/messaging/client/Client.d.ts +51 -14
  22. package/dist/cjs/api/resources/messaging/client/Client.js +249 -50
  23. package/dist/cjs/api/resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.d.ts +9 -0
  24. package/dist/cjs/api/resources/messaging/client/requests/RerunMessageRequest.d.ts +2 -2
  25. package/dist/cjs/api/resources/messaging/client/requests/StreamMessageRequest.d.ts +0 -1
  26. package/dist/cjs/api/resources/messaging/client/requests/index.d.ts +1 -0
  27. package/dist/cjs/api/resources/projects/client/Client.d.ts +14 -2
  28. package/dist/cjs/api/resources/projects/client/Client.js +66 -31
  29. package/dist/cjs/api/resources/session/client/Client.d.ts +2 -1
  30. package/dist/cjs/api/resources/session/client/Client.js +12 -2
  31. package/dist/cjs/api/resources/threads/client/Client.d.ts +37 -2
  32. package/dist/cjs/api/resources/threads/client/Client.js +155 -31
  33. package/dist/cjs/api/resources/threads/client/requests/UpdateThreadRequest.d.ts +8 -0
  34. package/dist/cjs/api/resources/threads/client/requests/index.d.ts +1 -0
  35. package/dist/cjs/api/types/{ExternalAgent.d.ts → Agent.d.ts} +1 -1
  36. package/dist/cjs/api/types/{ExternalAgentCreateResponse.d.ts → AgentCreateResponse.d.ts} +1 -1
  37. package/dist/cjs/api/types/{ExternalAgentListFilters.d.ts → AgentListFilters.d.ts} +1 -1
  38. package/dist/{esm/api/types/ExternalAgentUpdateResponse.d.mts → cjs/api/types/AgentUpdateResponse.d.ts} +1 -1
  39. package/dist/cjs/api/types/AgentVariables.d.ts +12 -0
  40. package/dist/cjs/api/types/AgentVersionPullResponse.d.ts +2 -3
  41. package/dist/cjs/api/types/AgentVersionPushResponse.d.ts +1 -1
  42. package/dist/cjs/api/types/AgentVersionWelcomeMessageResponse.d.ts +6 -0
  43. package/dist/cjs/api/types/GenerateFollowupSuggestionsResponse.d.ts +4 -0
  44. package/dist/cjs/api/types/PageAgent.d.ts +6 -0
  45. package/dist/cjs/api/types/PageAgentVersion.d.ts +6 -0
  46. package/dist/cjs/api/types/PageAgentVersion.js +3 -0
  47. package/dist/cjs/api/types/{ExternalPageLinks.d.ts → PageLinks.d.ts} +1 -1
  48. package/dist/cjs/api/types/PageLinks.js +3 -0
  49. package/dist/cjs/api/types/{ExternalPageMeta.d.ts → PageMeta.d.ts} +1 -1
  50. package/dist/cjs/api/types/PageMeta.js +3 -0
  51. package/dist/cjs/api/types/PageProject.d.ts +6 -0
  52. package/dist/cjs/api/types/PageProject.js +3 -0
  53. package/dist/cjs/api/types/PageThreadListItem.d.ts +6 -0
  54. package/dist/cjs/api/types/PageThreadListItem.js +3 -0
  55. package/dist/cjs/api/types/Project.d.ts +1 -1
  56. package/dist/cjs/api/types/SendMessageRequest.d.ts +7 -5
  57. package/dist/cjs/api/types/ThreadListFilters.d.ts +2 -5
  58. package/dist/cjs/api/types/TokenResponse.d.ts +4 -8
  59. package/dist/cjs/api/types/TraceDecision.d.ts +1 -2
  60. package/dist/cjs/api/types/VersionStats.d.ts +1 -2
  61. package/dist/cjs/api/types/index.d.ts +13 -10
  62. package/dist/cjs/api/types/index.js +13 -10
  63. package/dist/cjs/core/auth/AuthProvider.d.ts +4 -0
  64. package/dist/cjs/core/auth/AuthProvider.js +2 -0
  65. package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
  66. package/dist/cjs/core/auth/AuthRequest.js +2 -0
  67. package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
  68. package/dist/cjs/core/auth/BasicAuth.js +27 -0
  69. package/dist/cjs/core/auth/BearerToken.d.ts +5 -0
  70. package/dist/cjs/core/auth/BearerToken.js +15 -0
  71. package/dist/cjs/core/auth/index.d.ts +4 -0
  72. package/dist/cjs/core/auth/index.js +7 -0
  73. package/dist/cjs/core/base64.d.ts +2 -0
  74. package/dist/cjs/core/base64.js +26 -0
  75. package/dist/cjs/core/index.d.ts +2 -0
  76. package/dist/cjs/core/index.js +2 -0
  77. package/dist/cjs/environments.d.ts +2 -2
  78. package/dist/cjs/environments.js +2 -2
  79. package/dist/cjs/index.d.ts +1 -1
  80. package/dist/cjs/index.js +3 -2
  81. package/dist/cjs/version.d.ts +1 -1
  82. package/dist/cjs/version.js +1 -1
  83. package/dist/esm/ApolloClientWrapper.d.mts +52 -24
  84. package/dist/esm/ApolloClientWrapper.mjs +83 -56
  85. package/dist/esm/BaseClient.d.mts +5 -0
  86. package/dist/esm/Client.d.mts +4 -1
  87. package/dist/esm/Client.mjs +25 -10
  88. package/dist/esm/api/resources/agentVersions/client/Client.d.mts +26 -2
  89. package/dist/esm/api/resources/agentVersions/client/Client.mjs +97 -44
  90. package/dist/esm/api/resources/agentVersions/client/requests/AgentVersionPushRequest.d.mts +1 -1
  91. package/dist/esm/api/resources/agents/client/Client.d.mts +22 -7
  92. package/dist/esm/api/resources/agents/client/Client.mjs +81 -40
  93. package/dist/esm/api/resources/agents/client/requests/{ExternalAgentCreateRequest.d.mts → AgentCreateRequest.d.mts} +1 -1
  94. package/dist/{cjs/api/resources/agents/client/requests/ExternalAgentUpdateRequest.d.ts → esm/api/resources/agents/client/requests/AgentUpdateRequest.d.mts} +1 -1
  95. package/dist/esm/api/resources/agents/client/requests/ListAgentsRequest.d.mts +1 -1
  96. package/dist/esm/api/resources/agents/client/requests/index.d.mts +2 -2
  97. package/dist/esm/api/resources/auth/client/Client.d.mts +3 -2
  98. package/dist/esm/api/resources/auth/client/Client.mjs +21 -9
  99. package/dist/esm/api/resources/channels/client/Client.d.mts +7 -6
  100. package/dist/esm/api/resources/channels/client/Client.mjs +25 -13
  101. package/dist/esm/api/resources/channels/client/requests/InitiateThreadRequest.d.mts +3 -10
  102. package/dist/esm/api/resources/messaging/client/Client.d.mts +51 -14
  103. package/dist/esm/api/resources/messaging/client/Client.mjs +249 -50
  104. package/dist/esm/api/resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.d.mts +9 -0
  105. package/dist/esm/api/resources/messaging/client/requests/RerunMessageRequest.d.mts +2 -2
  106. package/dist/esm/api/resources/messaging/client/requests/StreamMessageRequest.d.mts +0 -1
  107. package/dist/esm/api/resources/messaging/client/requests/index.d.mts +1 -0
  108. package/dist/esm/api/resources/projects/client/Client.d.mts +14 -2
  109. package/dist/esm/api/resources/projects/client/Client.mjs +67 -32
  110. package/dist/esm/api/resources/session/client/Client.d.mts +2 -1
  111. package/dist/esm/api/resources/session/client/Client.mjs +12 -2
  112. package/dist/esm/api/resources/threads/client/Client.d.mts +37 -2
  113. package/dist/esm/api/resources/threads/client/Client.mjs +156 -32
  114. package/dist/esm/api/resources/threads/client/requests/UpdateThreadRequest.d.mts +8 -0
  115. package/dist/esm/api/resources/threads/client/requests/index.d.mts +1 -0
  116. package/dist/esm/api/types/{ExternalAgent.d.mts → Agent.d.mts} +1 -1
  117. package/dist/esm/api/types/{ExternalAgentCreateResponse.d.mts → AgentCreateResponse.d.mts} +1 -1
  118. package/dist/esm/api/types/{ExternalAgentListFilters.d.mts → AgentListFilters.d.mts} +1 -1
  119. package/dist/{cjs/api/types/ExternalAgentUpdateResponse.d.ts → esm/api/types/AgentUpdateResponse.d.mts} +1 -1
  120. package/dist/esm/api/types/AgentVariables.d.mts +12 -0
  121. package/dist/esm/api/types/AgentVersionPullResponse.d.mts +2 -3
  122. package/dist/esm/api/types/AgentVersionPushResponse.d.mts +1 -1
  123. package/dist/esm/api/types/AgentVersionWelcomeMessageResponse.d.mts +6 -0
  124. package/dist/esm/api/types/GenerateFollowupSuggestionsResponse.d.mts +4 -0
  125. package/dist/esm/api/types/PageAgent.d.mts +6 -0
  126. package/dist/esm/api/types/PageAgentVersion.d.mts +6 -0
  127. package/dist/esm/api/types/PageAgentVersion.mjs +2 -0
  128. package/dist/esm/api/types/{ExternalPageLinks.d.mts → PageLinks.d.mts} +1 -1
  129. package/dist/esm/api/types/PageLinks.mjs +2 -0
  130. package/dist/esm/api/types/{ExternalPageMeta.d.mts → PageMeta.d.mts} +1 -1
  131. package/dist/esm/api/types/PageMeta.mjs +2 -0
  132. package/dist/esm/api/types/PageProject.d.mts +6 -0
  133. package/dist/esm/api/types/PageProject.mjs +2 -0
  134. package/dist/esm/api/types/PageThreadListItem.d.mts +6 -0
  135. package/dist/esm/api/types/PageThreadListItem.mjs +2 -0
  136. package/dist/esm/api/types/Project.d.mts +1 -1
  137. package/dist/esm/api/types/SendMessageRequest.d.mts +7 -5
  138. package/dist/esm/api/types/ThreadListFilters.d.mts +2 -5
  139. package/dist/esm/api/types/TokenResponse.d.mts +4 -8
  140. package/dist/esm/api/types/TraceDecision.d.mts +1 -2
  141. package/dist/esm/api/types/VersionStats.d.mts +1 -2
  142. package/dist/esm/api/types/index.d.mts +13 -10
  143. package/dist/esm/api/types/index.mjs +13 -10
  144. package/dist/esm/core/auth/AuthProvider.d.mts +4 -0
  145. package/dist/esm/core/auth/AuthProvider.mjs +1 -0
  146. package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
  147. package/dist/esm/core/auth/AuthRequest.mjs +1 -0
  148. package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
  149. package/dist/esm/core/auth/BasicAuth.mjs +24 -0
  150. package/dist/esm/core/auth/BearerToken.d.mts +5 -0
  151. package/dist/esm/core/auth/BearerToken.mjs +12 -0
  152. package/dist/esm/core/auth/index.d.mts +4 -0
  153. package/dist/esm/core/auth/index.mjs +2 -0
  154. package/dist/esm/core/base64.d.mts +2 -0
  155. package/dist/esm/core/base64.mjs +22 -0
  156. package/dist/esm/core/index.d.mts +2 -0
  157. package/dist/esm/core/index.mjs +2 -0
  158. package/dist/esm/environments.d.mts +2 -2
  159. package/dist/esm/environments.mjs +2 -2
  160. package/dist/esm/index.d.mts +1 -1
  161. package/dist/esm/index.mjs +1 -1
  162. package/dist/esm/version.d.mts +1 -1
  163. package/dist/esm/version.mjs +1 -1
  164. package/package.json +1 -1
  165. package/reference.md +568 -29
  166. package/dist/cjs/api/types/ExternalPageAgentVersion.d.ts +0 -6
  167. package/dist/cjs/api/types/ExternalPageExternalAgent.d.ts +0 -6
  168. package/dist/cjs/api/types/ExternalPageProject.d.ts +0 -6
  169. package/dist/cjs/api/types/ExternalPageThreadListItem.d.ts +0 -6
  170. package/dist/esm/api/types/ExternalPageAgentVersion.d.mts +0 -6
  171. package/dist/esm/api/types/ExternalPageExternalAgent.d.mts +0 -6
  172. package/dist/esm/api/types/ExternalPageProject.d.mts +0 -6
  173. package/dist/esm/api/types/ExternalPageThreadListItem.d.mts +0 -6
  174. /package/dist/cjs/api/resources/agents/client/requests/{ExternalAgentCreateRequest.js → AgentCreateRequest.js} +0 -0
  175. /package/dist/cjs/api/resources/agents/client/requests/{ExternalAgentUpdateRequest.js → AgentUpdateRequest.js} +0 -0
  176. /package/dist/cjs/api/{types/ExternalAgent.js → resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.js} +0 -0
  177. /package/dist/cjs/api/{types/ExternalAgentCreateResponse.js → resources/threads/client/requests/UpdateThreadRequest.js} +0 -0
  178. /package/dist/cjs/api/types/{ExternalAgentListFilters.js → Agent.js} +0 -0
  179. /package/dist/cjs/api/types/{ExternalAgentUpdateResponse.js → AgentCreateResponse.js} +0 -0
  180. /package/dist/cjs/api/types/{ExternalPageAgentVersion.js → AgentListFilters.js} +0 -0
  181. /package/dist/cjs/api/types/{ExternalPageExternalAgent.js → AgentUpdateResponse.js} +0 -0
  182. /package/dist/cjs/api/types/{ExternalPageLinks.js → AgentVariables.js} +0 -0
  183. /package/dist/cjs/api/types/{ExternalPageMeta.js → AgentVersionWelcomeMessageResponse.js} +0 -0
  184. /package/dist/cjs/api/types/{ExternalPageProject.js → GenerateFollowupSuggestionsResponse.js} +0 -0
  185. /package/dist/cjs/api/types/{ExternalPageThreadListItem.js → PageAgent.js} +0 -0
  186. /package/dist/esm/api/resources/agents/client/requests/{ExternalAgentCreateRequest.mjs → AgentCreateRequest.mjs} +0 -0
  187. /package/dist/esm/api/resources/agents/client/requests/{ExternalAgentUpdateRequest.mjs → AgentUpdateRequest.mjs} +0 -0
  188. /package/dist/esm/api/{types/ExternalAgent.mjs → resources/messaging/client/requests/GenerateFollowupSuggestionsRequest.mjs} +0 -0
  189. /package/dist/esm/api/{types/ExternalAgentCreateResponse.mjs → resources/threads/client/requests/UpdateThreadRequest.mjs} +0 -0
  190. /package/dist/esm/api/types/{ExternalAgentListFilters.mjs → Agent.mjs} +0 -0
  191. /package/dist/esm/api/types/{ExternalAgentUpdateResponse.mjs → AgentCreateResponse.mjs} +0 -0
  192. /package/dist/esm/api/types/{ExternalPageAgentVersion.mjs → AgentListFilters.mjs} +0 -0
  193. /package/dist/esm/api/types/{ExternalPageExternalAgent.mjs → AgentUpdateResponse.mjs} +0 -0
  194. /package/dist/esm/api/types/{ExternalPageLinks.mjs → AgentVariables.mjs} +0 -0
  195. /package/dist/esm/api/types/{ExternalPageMeta.mjs → AgentVersionWelcomeMessageResponse.mjs} +0 -0
  196. /package/dist/esm/api/types/{ExternalPageProject.mjs → GenerateFollowupSuggestionsResponse.mjs} +0 -0
  197. /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, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, `management/v1/projects/${core.url.encodePathParam(projectId)}/agents`),
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: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
69
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.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: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
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.ExternalAgentCreateRequest} request
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, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, `management/v1/projects/${core.url.encodePathParam(projectId)}/agents`),
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: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
152
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.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: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
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, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, `management/v1/agents/${core.url.encodePathParam(agentId)}`),
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: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
229
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.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: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
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, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, `management/v1/agents/${core.url.encodePathParam(agentId)}`),
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: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
306
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.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: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
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.ExternalAgentUpdateRequest} request
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, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, `management/v1/agents/${core.url.encodePathParam(agentId)}`),
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: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
387
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.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: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
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, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, `management/v1/agents/${core.url.encodePathParam(agentId)}/usage`),
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: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
476
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.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: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
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
  }
@@ -4,7 +4,7 @@
4
4
  * name: "name"
5
5
  * }
6
6
  */
7
- export interface ExternalAgentCreateRequest {
7
+ export interface AgentCreateRequest {
8
8
  /** Agent name */
9
9
  name: string;
10
10
  }
@@ -2,7 +2,7 @@
2
2
  * @example
3
3
  * {}
4
4
  */
5
- export interface ExternalAgentUpdateRequest {
5
+ export interface AgentUpdateRequest {
6
6
  /** New agent name */
7
7
  name?: string;
8
8
  }
@@ -6,7 +6,7 @@ import type * as Apollo from "../../../../index.mjs";
6
6
  * }
7
7
  */
8
8
  export interface ListAgentsRequest {
9
- filters: Apollo.ExternalAgentListFilters;
9
+ filters: Apollo.AgentListFilters;
10
10
  "page[size]"?: number;
11
11
  "page[after]"?: string;
12
12
  "page[before]"?: string;
@@ -1,4 +1,4 @@
1
- export type { ExternalAgentCreateRequest } from "./ExternalAgentCreateRequest.mjs";
2
- export type { ExternalAgentUpdateRequest } from "./ExternalAgentUpdateRequest.mjs";
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?: Auth.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, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, "management/v1/auth/token"),
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: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
52
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.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: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
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?: Channels.Options);
12
+ constructor(_options: Channels.Options);
13
13
  /**
14
- * Send the opener on ``channel`` and bind the recipient's phone to a thread.
15
- * Omit ``thread_id`` to start a new thread (its id is returned); pass it to
16
- * continue an existing one. Template fields apply to WhatsApp only.
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 opener on ``channel`` and bind the recipient's phone to a thread.
22
- * Omit ``thread_id`` to start a new thread (its id is returned); pass it to
23
- * continue an existing one. Template fields apply to WhatsApp only.
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, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ApolloEnvironment.Gcp).base, `messaging/v1/channels/${core.url.encodePathParam(channel)}/threads`),
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: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
59
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.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: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
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 ref id for a new thread; defaults to the phone's digits. */
16
- user_ref_id?: string;
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
  }