phonic 0.32.2 → 0.32.3

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 (212) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/Client.d.ts +3 -0
  3. package/dist/cjs/Client.js +23 -18
  4. package/dist/cjs/api/errors/TooManyRequestsError.d.ts +6 -0
  5. package/dist/cjs/api/errors/TooManyRequestsError.js +54 -0
  6. package/dist/cjs/api/errors/index.d.ts +1 -0
  7. package/dist/cjs/api/errors/index.js +1 -0
  8. package/dist/cjs/api/resources/agents/client/requests/AgentsCreateRequest.d.ts +8 -0
  9. package/dist/cjs/api/resources/agents/client/requests/UpdateAgentRequest.d.ts +14 -0
  10. package/dist/cjs/api/resources/agents/client/requests/UpsertAgentRequest.d.ts +6 -0
  11. package/dist/cjs/api/resources/agents/types/AgentsUpdateResponse.d.ts +5 -0
  12. package/dist/cjs/api/resources/apiKeys/client/Client.d.ts +79 -0
  13. package/dist/cjs/api/resources/apiKeys/client/Client.js +293 -0
  14. package/dist/cjs/api/resources/apiKeys/client/index.d.ts +1 -0
  15. package/dist/cjs/api/resources/apiKeys/client/index.js +17 -0
  16. package/dist/cjs/api/resources/apiKeys/client/requests/CreateApiKeyRequest.d.ts +10 -0
  17. package/dist/cjs/api/resources/apiKeys/client/requests/CreateApiKeyRequest.js +3 -0
  18. package/dist/cjs/api/resources/apiKeys/client/requests/UpdateApiKeyRequest.d.ts +10 -0
  19. package/dist/cjs/api/resources/apiKeys/client/requests/UpdateApiKeyRequest.js +3 -0
  20. package/dist/cjs/api/resources/apiKeys/client/requests/index.d.ts +2 -0
  21. package/dist/cjs/api/resources/apiKeys/client/requests/index.js +2 -0
  22. package/dist/cjs/api/resources/apiKeys/exports.d.ts +2 -0
  23. package/dist/cjs/api/resources/apiKeys/exports.js +21 -0
  24. package/dist/cjs/api/resources/apiKeys/index.d.ts +2 -0
  25. package/dist/cjs/api/resources/apiKeys/index.js +18 -0
  26. package/dist/cjs/api/resources/apiKeys/types/ApiKeysDeleteResponse.d.ts +3 -0
  27. package/dist/cjs/api/resources/apiKeys/types/ApiKeysDeleteResponse.js +3 -0
  28. package/dist/cjs/api/resources/apiKeys/types/ApiKeysUpdateResponse.d.ts +3 -0
  29. package/dist/cjs/api/resources/apiKeys/types/ApiKeysUpdateResponse.js +3 -0
  30. package/dist/cjs/api/resources/apiKeys/types/index.d.ts +2 -0
  31. package/dist/cjs/api/resources/apiKeys/types/index.js +18 -0
  32. package/dist/cjs/api/resources/auth/client/Client.d.ts +20 -0
  33. package/dist/cjs/api/resources/auth/client/Client.js +70 -0
  34. package/dist/cjs/api/resources/auth/client/requests/CreateConversationTokenRequest.d.ts +13 -0
  35. package/dist/cjs/api/resources/auth/client/requests/CreateConversationTokenRequest.js +3 -0
  36. package/dist/cjs/api/resources/auth/client/requests/index.d.ts +1 -0
  37. package/dist/cjs/api/resources/auth/types/AuthCreateConversationTokenResponse.d.ts +6 -0
  38. package/dist/cjs/api/resources/auth/types/AuthCreateConversationTokenResponse.js +3 -0
  39. package/dist/cjs/api/resources/auth/types/index.d.ts +1 -0
  40. package/dist/cjs/api/resources/auth/types/index.js +1 -0
  41. package/dist/cjs/api/resources/conversations/client/Client.d.ts +26 -1
  42. package/dist/cjs/api/resources/conversations/client/Client.js +78 -0
  43. package/dist/cjs/api/resources/conversations/client/requests/ReplayConversationRequest.d.ts +10 -0
  44. package/dist/cjs/api/resources/conversations/client/requests/ReplayConversationRequest.js +3 -0
  45. package/dist/cjs/api/resources/conversations/client/requests/index.d.ts +1 -0
  46. package/dist/cjs/api/resources/conversations/types/ConversationsEvaluateResponse.d.ts +19 -0
  47. package/dist/cjs/api/resources/conversations/types/ConversationsEvaluateResponse.js +17 -0
  48. package/dist/cjs/api/resources/conversations/types/ConversationsReplayResponse.d.ts +4 -0
  49. package/dist/cjs/api/resources/conversations/types/ConversationsReplayResponse.js +3 -0
  50. package/dist/cjs/api/resources/conversations/types/index.d.ts +2 -0
  51. package/dist/cjs/api/resources/conversations/types/index.js +2 -0
  52. package/dist/cjs/api/resources/index.d.ts +4 -0
  53. package/dist/cjs/api/resources/index.js +5 -1
  54. package/dist/cjs/api/resources/projects/client/Client.d.ts +16 -0
  55. package/dist/cjs/api/resources/projects/client/Client.js +58 -0
  56. package/dist/cjs/api/resources/projects/types/ProjectsListEvalsResponse.d.ts +4 -0
  57. package/dist/cjs/api/resources/projects/types/ProjectsListEvalsResponse.js +3 -0
  58. package/dist/cjs/api/resources/projects/types/index.d.ts +1 -0
  59. package/dist/cjs/api/resources/projects/types/index.js +1 -0
  60. package/dist/cjs/api/resources/tools/client/Client.d.ts +2 -1
  61. package/dist/cjs/api/resources/tools/client/Client.js +2 -1
  62. package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.d.ts +4 -1
  63. package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.d.ts +5 -13
  64. package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.js +0 -8
  65. package/dist/cjs/api/resources/workspace/client/Client.d.ts +20 -0
  66. package/dist/cjs/api/resources/workspace/client/Client.js +65 -0
  67. package/dist/cjs/api/resources/workspace/client/index.d.ts +1 -1
  68. package/dist/cjs/api/resources/workspace/client/index.js +15 -0
  69. package/dist/cjs/api/resources/workspace/client/requests/UpdateWorkspaceRequest.d.ts +16 -0
  70. package/dist/cjs/api/resources/workspace/client/requests/UpdateWorkspaceRequest.js +3 -0
  71. package/dist/cjs/api/resources/workspace/client/requests/index.d.ts +1 -0
  72. package/dist/cjs/api/resources/workspace/client/requests/index.js +2 -0
  73. package/dist/cjs/api/resources/workspace/types/WorkspaceGetResponse.d.ts +6 -0
  74. package/dist/cjs/api/resources/workspace/types/WorkspaceUpdateResponse.d.ts +3 -0
  75. package/dist/cjs/api/resources/workspace/types/WorkspaceUpdateResponse.js +3 -0
  76. package/dist/cjs/api/resources/workspace/types/index.d.ts +1 -0
  77. package/dist/cjs/api/resources/workspace/types/index.js +1 -0
  78. package/dist/cjs/api/types/Agent.d.ts +9 -0
  79. package/dist/cjs/api/types/AgentIntegration.d.ts +13 -0
  80. package/dist/cjs/api/types/AgentIntegration.js +3 -0
  81. package/dist/cjs/api/types/ApiKeyWithSecret.d.ts +8 -0
  82. package/dist/cjs/api/types/ApiKeyWithSecret.js +3 -0
  83. package/dist/cjs/api/types/AudioChunkResponsePayload.d.ts +2 -0
  84. package/dist/cjs/api/types/ConfigOptions.d.ts +67 -0
  85. package/dist/cjs/api/types/Conversation.d.ts +23 -0
  86. package/dist/cjs/api/types/ConversationEval.d.ts +22 -1
  87. package/dist/cjs/api/types/ConversationEval.js +11 -0
  88. package/dist/cjs/api/types/ConversationEvalPromptInfo.d.ts +7 -0
  89. package/dist/cjs/api/types/ConversationEvalPromptInfo.js +3 -0
  90. package/dist/cjs/api/types/ConversationExtraction.d.ts +2 -4
  91. package/dist/cjs/api/types/ConversationItem.d.ts +4 -2
  92. package/dist/cjs/api/types/CreateAgentRequest.d.ts +8 -0
  93. package/dist/cjs/api/types/DataRetentionPolicy.d.ts +21 -0
  94. package/dist/cjs/api/types/DataRetentionPolicy.js +3 -0
  95. package/dist/cjs/api/types/DtmfPayload.d.ts +2 -0
  96. package/dist/cjs/api/types/ExtractionField.d.ts +2 -2
  97. package/dist/cjs/api/types/OutboundCallConfig.d.ts +40 -0
  98. package/dist/cjs/api/types/OutboundCallConfig.js +6 -0
  99. package/dist/cjs/api/types/OutboundNumberPool.d.ts +9 -0
  100. package/dist/cjs/api/types/OutboundNumberPool.js +3 -0
  101. package/dist/cjs/api/types/Tool.d.ts +3 -1
  102. package/dist/cjs/api/types/index.d.ts +5 -0
  103. package/dist/cjs/api/types/index.js +5 -0
  104. package/dist/cjs/version.d.ts +1 -1
  105. package/dist/cjs/version.js +1 -1
  106. package/dist/esm/BaseClient.mjs +2 -2
  107. package/dist/esm/Client.d.mts +3 -0
  108. package/dist/esm/Client.mjs +5 -0
  109. package/dist/esm/api/errors/TooManyRequestsError.d.mts +6 -0
  110. package/dist/esm/api/errors/TooManyRequestsError.mjs +17 -0
  111. package/dist/esm/api/errors/index.d.mts +1 -0
  112. package/dist/esm/api/errors/index.mjs +1 -0
  113. package/dist/esm/api/resources/agents/client/requests/AgentsCreateRequest.d.mts +8 -0
  114. package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.d.mts +14 -0
  115. package/dist/esm/api/resources/agents/client/requests/UpsertAgentRequest.d.mts +6 -0
  116. package/dist/esm/api/resources/agents/types/AgentsUpdateResponse.d.mts +5 -0
  117. package/dist/esm/api/resources/apiKeys/client/Client.d.mts +79 -0
  118. package/dist/esm/api/resources/apiKeys/client/Client.mjs +256 -0
  119. package/dist/esm/api/resources/apiKeys/client/index.d.mts +1 -0
  120. package/dist/esm/api/resources/apiKeys/client/index.mjs +1 -0
  121. package/dist/esm/api/resources/apiKeys/client/requests/CreateApiKeyRequest.d.mts +10 -0
  122. package/dist/esm/api/resources/apiKeys/client/requests/CreateApiKeyRequest.mjs +2 -0
  123. package/dist/esm/api/resources/apiKeys/client/requests/UpdateApiKeyRequest.d.mts +10 -0
  124. package/dist/esm/api/resources/apiKeys/client/requests/UpdateApiKeyRequest.mjs +2 -0
  125. package/dist/esm/api/resources/apiKeys/client/requests/index.d.mts +2 -0
  126. package/dist/esm/api/resources/apiKeys/client/requests/index.mjs +1 -0
  127. package/dist/esm/api/resources/apiKeys/exports.d.mts +2 -0
  128. package/dist/esm/api/resources/apiKeys/exports.mjs +3 -0
  129. package/dist/esm/api/resources/apiKeys/index.d.mts +2 -0
  130. package/dist/esm/api/resources/apiKeys/index.mjs +2 -0
  131. package/dist/esm/api/resources/apiKeys/types/ApiKeysDeleteResponse.d.mts +3 -0
  132. package/dist/esm/api/resources/apiKeys/types/ApiKeysDeleteResponse.mjs +2 -0
  133. package/dist/esm/api/resources/apiKeys/types/ApiKeysUpdateResponse.d.mts +3 -0
  134. package/dist/esm/api/resources/apiKeys/types/ApiKeysUpdateResponse.mjs +2 -0
  135. package/dist/esm/api/resources/apiKeys/types/index.d.mts +2 -0
  136. package/dist/esm/api/resources/apiKeys/types/index.mjs +2 -0
  137. package/dist/esm/api/resources/auth/client/Client.d.mts +20 -0
  138. package/dist/esm/api/resources/auth/client/Client.mjs +70 -0
  139. package/dist/esm/api/resources/auth/client/requests/CreateConversationTokenRequest.d.mts +13 -0
  140. package/dist/esm/api/resources/auth/client/requests/CreateConversationTokenRequest.mjs +2 -0
  141. package/dist/esm/api/resources/auth/client/requests/index.d.mts +1 -0
  142. package/dist/esm/api/resources/auth/types/AuthCreateConversationTokenResponse.d.mts +6 -0
  143. package/dist/esm/api/resources/auth/types/AuthCreateConversationTokenResponse.mjs +2 -0
  144. package/dist/esm/api/resources/auth/types/index.d.mts +1 -0
  145. package/dist/esm/api/resources/auth/types/index.mjs +1 -0
  146. package/dist/esm/api/resources/conversations/client/Client.d.mts +26 -1
  147. package/dist/esm/api/resources/conversations/client/Client.mjs +78 -0
  148. package/dist/esm/api/resources/conversations/client/requests/ReplayConversationRequest.d.mts +10 -0
  149. package/dist/esm/api/resources/conversations/client/requests/ReplayConversationRequest.mjs +2 -0
  150. package/dist/esm/api/resources/conversations/client/requests/index.d.mts +1 -0
  151. package/dist/esm/api/resources/conversations/types/ConversationsEvaluateResponse.d.mts +19 -0
  152. package/dist/esm/api/resources/conversations/types/ConversationsEvaluateResponse.mjs +14 -0
  153. package/dist/esm/api/resources/conversations/types/ConversationsReplayResponse.d.mts +4 -0
  154. package/dist/esm/api/resources/conversations/types/ConversationsReplayResponse.mjs +2 -0
  155. package/dist/esm/api/resources/conversations/types/index.d.mts +2 -0
  156. package/dist/esm/api/resources/conversations/types/index.mjs +2 -0
  157. package/dist/esm/api/resources/index.d.mts +4 -0
  158. package/dist/esm/api/resources/index.mjs +4 -0
  159. package/dist/esm/api/resources/projects/client/Client.d.mts +16 -0
  160. package/dist/esm/api/resources/projects/client/Client.mjs +58 -0
  161. package/dist/esm/api/resources/projects/types/ProjectsListEvalsResponse.d.mts +4 -0
  162. package/dist/esm/api/resources/projects/types/ProjectsListEvalsResponse.mjs +2 -0
  163. package/dist/esm/api/resources/projects/types/index.d.mts +1 -0
  164. package/dist/esm/api/resources/projects/types/index.mjs +1 -0
  165. package/dist/esm/api/resources/tools/client/Client.d.mts +2 -1
  166. package/dist/esm/api/resources/tools/client/Client.mjs +2 -1
  167. package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.d.mts +4 -1
  168. package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.d.mts +5 -13
  169. package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.mjs +0 -8
  170. package/dist/esm/api/resources/workspace/client/Client.d.mts +20 -0
  171. package/dist/esm/api/resources/workspace/client/Client.mjs +65 -0
  172. package/dist/esm/api/resources/workspace/client/index.d.mts +1 -1
  173. package/dist/esm/api/resources/workspace/client/index.mjs +1 -1
  174. package/dist/esm/api/resources/workspace/client/requests/UpdateWorkspaceRequest.d.mts +16 -0
  175. package/dist/esm/api/resources/workspace/client/requests/UpdateWorkspaceRequest.mjs +2 -0
  176. package/dist/esm/api/resources/workspace/client/requests/index.d.mts +1 -0
  177. package/dist/esm/api/resources/workspace/client/requests/index.mjs +1 -0
  178. package/dist/esm/api/resources/workspace/types/WorkspaceGetResponse.d.mts +6 -0
  179. package/dist/esm/api/resources/workspace/types/WorkspaceUpdateResponse.d.mts +3 -0
  180. package/dist/esm/api/resources/workspace/types/WorkspaceUpdateResponse.mjs +2 -0
  181. package/dist/esm/api/resources/workspace/types/index.d.mts +1 -0
  182. package/dist/esm/api/resources/workspace/types/index.mjs +1 -0
  183. package/dist/esm/api/types/Agent.d.mts +9 -0
  184. package/dist/esm/api/types/AgentIntegration.d.mts +13 -0
  185. package/dist/esm/api/types/AgentIntegration.mjs +2 -0
  186. package/dist/esm/api/types/ApiKeyWithSecret.d.mts +8 -0
  187. package/dist/esm/api/types/ApiKeyWithSecret.mjs +2 -0
  188. package/dist/esm/api/types/AudioChunkResponsePayload.d.mts +2 -0
  189. package/dist/esm/api/types/ConfigOptions.d.mts +67 -0
  190. package/dist/esm/api/types/Conversation.d.mts +23 -0
  191. package/dist/esm/api/types/ConversationEval.d.mts +22 -1
  192. package/dist/esm/api/types/ConversationEval.mjs +10 -1
  193. package/dist/esm/api/types/ConversationEvalPromptInfo.d.mts +7 -0
  194. package/dist/esm/api/types/ConversationEvalPromptInfo.mjs +2 -0
  195. package/dist/esm/api/types/ConversationExtraction.d.mts +2 -4
  196. package/dist/esm/api/types/ConversationItem.d.mts +4 -2
  197. package/dist/esm/api/types/CreateAgentRequest.d.mts +8 -0
  198. package/dist/esm/api/types/DataRetentionPolicy.d.mts +21 -0
  199. package/dist/esm/api/types/DataRetentionPolicy.mjs +2 -0
  200. package/dist/esm/api/types/DtmfPayload.d.mts +2 -0
  201. package/dist/esm/api/types/ExtractionField.d.mts +2 -2
  202. package/dist/esm/api/types/OutboundCallConfig.d.mts +40 -0
  203. package/dist/esm/api/types/OutboundCallConfig.mjs +6 -0
  204. package/dist/esm/api/types/OutboundNumberPool.d.mts +9 -0
  205. package/dist/esm/api/types/OutboundNumberPool.mjs +2 -0
  206. package/dist/esm/api/types/Tool.d.mts +3 -1
  207. package/dist/esm/api/types/index.d.mts +5 -0
  208. package/dist/esm/api/types/index.mjs +5 -0
  209. package/dist/esm/version.d.mts +1 -1
  210. package/dist/esm/version.mjs +1 -1
  211. package/package.json +12 -1
  212. package/reference.md +540 -2
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "phonic",
46
- "X-Fern-SDK-Version": "0.32.2",
47
- "User-Agent": "phonic/0.32.2",
46
+ "X-Fern-SDK-Version": "0.32.3",
47
+ "User-Agent": "phonic/0.32.3",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -1,4 +1,5 @@
1
1
  import { AgentsClient } from "./api/resources/agents/client/Client.js";
2
+ import { ApiKeysClient } from "./api/resources/apiKeys/client/Client.js";
2
3
  import { AuthClient } from "./api/resources/auth/client/Client.js";
3
4
  import { ConversationItemsClient } from "./api/resources/conversationItems/client/Client.js";
4
5
  import { ConversationsClient } from "./api/resources/conversations/client/Client.js";
@@ -27,6 +28,7 @@ export declare namespace PhonicClient {
27
28
  export declare class PhonicClient {
28
29
  protected readonly _options: NormalizedClientOptionsWithAuth<PhonicClient.Options>;
29
30
  protected _agents: AgentsClient | undefined;
31
+ protected _apiKeys: ApiKeysClient | undefined;
30
32
  protected _tools: ToolsClient | undefined;
31
33
  protected _extractionSchemas: ExtractionSchemasClient | undefined;
32
34
  protected _tts: TtsClient | undefined;
@@ -38,6 +40,7 @@ export declare class PhonicClient {
38
40
  protected _workspace: WorkspaceClient | undefined;
39
41
  constructor(options?: PhonicClient.Options);
40
42
  get agents(): AgentsClient;
43
+ get apiKeys(): ApiKeysClient;
41
44
  get tools(): ToolsClient;
42
45
  get extractionSchemas(): ExtractionSchemasClient;
43
46
  get tts(): TtsClient;
@@ -45,15 +45,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.PhonicClient = void 0;
47
47
  const Client_js_1 = require("./api/resources/agents/client/Client.js");
48
- const Client_js_2 = require("./api/resources/auth/client/Client.js");
49
- const Client_js_3 = require("./api/resources/conversationItems/client/Client.js");
50
- const Client_js_4 = require("./api/resources/conversations/client/Client.js");
51
- const Client_js_5 = require("./api/resources/extractionSchemas/client/Client.js");
52
- const Client_js_6 = require("./api/resources/projects/client/Client.js");
53
- const Client_js_7 = require("./api/resources/tools/client/Client.js");
54
- const Client_js_8 = require("./api/resources/tts/client/Client.js");
55
- const Client_js_9 = require("./api/resources/voices/client/Client.js");
56
- const Client_js_10 = require("./api/resources/workspace/client/Client.js");
48
+ const Client_js_2 = require("./api/resources/apiKeys/client/Client.js");
49
+ const Client_js_3 = require("./api/resources/auth/client/Client.js");
50
+ const Client_js_4 = require("./api/resources/conversationItems/client/Client.js");
51
+ const Client_js_5 = require("./api/resources/conversations/client/Client.js");
52
+ const Client_js_6 = require("./api/resources/extractionSchemas/client/Client.js");
53
+ const Client_js_7 = require("./api/resources/projects/client/Client.js");
54
+ const Client_js_8 = require("./api/resources/tools/client/Client.js");
55
+ const Client_js_9 = require("./api/resources/tts/client/Client.js");
56
+ const Client_js_10 = require("./api/resources/voices/client/Client.js");
57
+ const Client_js_11 = require("./api/resources/workspace/client/Client.js");
57
58
  const BaseClient_js_1 = require("./BaseClient.js");
58
59
  const core = __importStar(require("./core/index.js"));
59
60
  const environments = __importStar(require("./environments.js"));
@@ -65,41 +66,45 @@ class PhonicClient {
65
66
  var _a;
66
67
  return ((_a = this._agents) !== null && _a !== void 0 ? _a : (this._agents = new Client_js_1.AgentsClient(this._options)));
67
68
  }
69
+ get apiKeys() {
70
+ var _a;
71
+ return ((_a = this._apiKeys) !== null && _a !== void 0 ? _a : (this._apiKeys = new Client_js_2.ApiKeysClient(this._options)));
72
+ }
68
73
  get tools() {
69
74
  var _a;
70
- return ((_a = this._tools) !== null && _a !== void 0 ? _a : (this._tools = new Client_js_7.ToolsClient(this._options)));
75
+ return ((_a = this._tools) !== null && _a !== void 0 ? _a : (this._tools = new Client_js_8.ToolsClient(this._options)));
71
76
  }
72
77
  get extractionSchemas() {
73
78
  var _a;
74
- return ((_a = this._extractionSchemas) !== null && _a !== void 0 ? _a : (this._extractionSchemas = new Client_js_5.ExtractionSchemasClient(this._options)));
79
+ return ((_a = this._extractionSchemas) !== null && _a !== void 0 ? _a : (this._extractionSchemas = new Client_js_6.ExtractionSchemasClient(this._options)));
75
80
  }
76
81
  get tts() {
77
82
  var _a;
78
- return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new Client_js_8.TtsClient(this._options)));
83
+ return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new Client_js_9.TtsClient(this._options)));
79
84
  }
80
85
  get voices() {
81
86
  var _a;
82
- return ((_a = this._voices) !== null && _a !== void 0 ? _a : (this._voices = new Client_js_9.VoicesClient(this._options)));
87
+ return ((_a = this._voices) !== null && _a !== void 0 ? _a : (this._voices = new Client_js_10.VoicesClient(this._options)));
83
88
  }
84
89
  get conversations() {
85
90
  var _a;
86
- return ((_a = this._conversations) !== null && _a !== void 0 ? _a : (this._conversations = new Client_js_4.ConversationsClient(this._options)));
91
+ return ((_a = this._conversations) !== null && _a !== void 0 ? _a : (this._conversations = new Client_js_5.ConversationsClient(this._options)));
87
92
  }
88
93
  get conversationItems() {
89
94
  var _a;
90
- return ((_a = this._conversationItems) !== null && _a !== void 0 ? _a : (this._conversationItems = new Client_js_3.ConversationItemsClient(this._options)));
95
+ return ((_a = this._conversationItems) !== null && _a !== void 0 ? _a : (this._conversationItems = new Client_js_4.ConversationItemsClient(this._options)));
91
96
  }
92
97
  get auth() {
93
98
  var _a;
94
- return ((_a = this._auth) !== null && _a !== void 0 ? _a : (this._auth = new Client_js_2.AuthClient(this._options)));
99
+ return ((_a = this._auth) !== null && _a !== void 0 ? _a : (this._auth = new Client_js_3.AuthClient(this._options)));
95
100
  }
96
101
  get projects() {
97
102
  var _a;
98
- return ((_a = this._projects) !== null && _a !== void 0 ? _a : (this._projects = new Client_js_6.ProjectsClient(this._options)));
103
+ return ((_a = this._projects) !== null && _a !== void 0 ? _a : (this._projects = new Client_js_7.ProjectsClient(this._options)));
99
104
  }
100
105
  get workspace() {
101
106
  var _a;
102
- return ((_a = this._workspace) !== null && _a !== void 0 ? _a : (this._workspace = new Client_js_10.WorkspaceClient(this._options)));
107
+ return ((_a = this._workspace) !== null && _a !== void 0 ? _a : (this._workspace = new Client_js_11.WorkspaceClient(this._options)));
103
108
  }
104
109
  /**
105
110
  * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
@@ -0,0 +1,6 @@
1
+ import type * as core from "../../core/index.js";
2
+ import * as errors from "../../errors/index.js";
3
+ import type * as Phonic from "../index.js";
4
+ export declare class TooManyRequestsError extends errors.PhonicError {
5
+ constructor(body: Phonic.BasicError, rawResponse?: core.RawResponse);
6
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.TooManyRequestsError = void 0;
38
+ const errors = __importStar(require("../../errors/index.js"));
39
+ class TooManyRequestsError extends errors.PhonicError {
40
+ constructor(body, rawResponse) {
41
+ super({
42
+ message: "TooManyRequestsError",
43
+ statusCode: 429,
44
+ body: body,
45
+ rawResponse: rawResponse,
46
+ });
47
+ Object.setPrototypeOf(this, new.target.prototype);
48
+ if (Error.captureStackTrace) {
49
+ Error.captureStackTrace(this, this.constructor);
50
+ }
51
+ this.name = this.constructor.name;
52
+ }
53
+ }
54
+ exports.TooManyRequestsError = TooManyRequestsError;
@@ -4,5 +4,6 @@ export * from "./ForbiddenError.js";
4
4
  export * from "./GatewayTimeoutError.js";
5
5
  export * from "./InternalServerError.js";
6
6
  export * from "./NotFoundError.js";
7
+ export * from "./TooManyRequestsError.js";
7
8
  export * from "./UnauthorizedError.js";
8
9
  export * from "./UnprocessableEntityError.js";
@@ -20,5 +20,6 @@ __exportStar(require("./ForbiddenError.js"), exports);
20
20
  __exportStar(require("./GatewayTimeoutError.js"), exports);
21
21
  __exportStar(require("./InternalServerError.js"), exports);
22
22
  __exportStar(require("./NotFoundError.js"), exports);
23
+ __exportStar(require("./TooManyRequestsError.js"), exports);
23
24
  __exportStar(require("./UnauthorizedError.js"), exports);
24
25
  __exportStar(require("./UnprocessableEntityError.js"), exports);
@@ -49,6 +49,8 @@ export interface AgentsCreateRequest {
49
49
  project?: string;
50
50
  /** The name of the agent. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
51
51
  name: string;
52
+ /** URL-friendly agent slug. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
53
+ slug?: string;
52
54
  /** When set to `null`, the agent will not be associated with a phone number. When set to `"assign-automatically"`, the agent will be assigned a random phone number. When set to `"custom"`, you must provide `custom_phone_numbers`. */
53
55
  phone_number?: Phonic.CreateAgentRequest.PhoneNumber | null;
54
56
  /** The custom phone number to use for the agent in E.164 format (e.g., +1234567890). This field is deprecated. Use `custom_phone_numbers` instead. */
@@ -89,6 +91,12 @@ export interface AgentsCreateRequest {
89
91
  no_input_poke_text?: string;
90
92
  /** Seconds of silence before ending the conversation. */
91
93
  no_input_end_conversation_sec?: number;
94
+ /** When `true`, the assistant will produce backchannel responses (e.g. "mm-hmm") while the user is speaking. */
95
+ enable_assistant_backchannel?: boolean;
96
+ /** How aggressively the assistant produces backchannel responses. Only relevant when `enable_assistant_backchannel` is `true`. */
97
+ assistant_backchannel_aggressiveness?: number;
98
+ /** Controls how long transcripts and audio recordings are retained before deletion. */
99
+ data_retention_policy?: Phonic.DataRetentionPolicy;
92
100
  /** ISO 639-1 language code that sets the agent's default language to recognize and speak. Welcome message and no input poke text should be in this language. */
93
101
  default_language?: Phonic.LanguageCode;
94
102
  /** Array of additional ISO 639-1 language codes that the agent should be able to recognize and speak. Should not include `default_language`. */
@@ -49,6 +49,8 @@ export interface UpdateAgentRequest {
49
49
  project?: string;
50
50
  /** The name of the agent. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
51
51
  name?: string;
52
+ /** URL-friendly agent slug. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
53
+ slug?: string;
52
54
  /** When set to `null`, the agent will not be associated with a phone number anymore. When set to `"assign-automatically"`, the agent will be assigned a random phone number if it doesn't have one yet. If the agent already has a phone number, `"assign-automatically"` has no effect. When set to `"custom"`, you must provide `custom_phone_numbers`. */
53
55
  phone_number?: UpdateAgentRequest.PhoneNumber | null;
54
56
  /** The custom phone number to use for the agent in E.164 format (e.g., +1234567890). This field is deprecated. Use `custom_phone_numbers` instead. */
@@ -89,6 +91,18 @@ export interface UpdateAgentRequest {
89
91
  no_input_poke_text?: string;
90
92
  /** Seconds of silence before ending the conversation. */
91
93
  no_input_end_conversation_sec?: number;
94
+ /** When `true`, the assistant will produce backchannel responses (e.g. "mm-hmm") while the user is speaking. */
95
+ enable_assistant_backchannel?: boolean;
96
+ /** How aggressively the assistant produces backchannel responses. Only relevant when `enable_assistant_backchannel` is `true`. */
97
+ assistant_backchannel_aggressiveness?: number;
98
+ /** Controls how long transcripts and audio recordings are retained before deletion. */
99
+ data_retention_policy?: Phonic.DataRetentionPolicy;
100
+ /** Pool of phone numbers used for outbound calls. Set to `null` to remove the pool. */
101
+ outbound_number_pool?: Phonic.OutboundNumberPool | null;
102
+ /** Array of procedure IDs associated with the agent. */
103
+ procedure_ids?: string[];
104
+ /** Array of third-party integrations enabled for the agent. */
105
+ integrations?: Phonic.AgentIntegration[];
92
106
  /** ISO 639-1 language code that sets the agent's default language to recognize and speak. Welcome message and no input poke text should be in this language. */
93
107
  default_language?: Phonic.LanguageCode;
94
108
  /** Array of additional ISO 639-1 language codes that the agent should be able to recognize and speak. Should not include `default_language`. */
@@ -47,4 +47,10 @@ import type * as Phonic from "../../../../index.js";
47
47
  export interface UpsertAgentRequest extends Phonic.CreateAgentRequest {
48
48
  /** The name of the project containing the agent. */
49
49
  project?: string;
50
+ /** Pool of phone numbers used for outbound calls. Set to `null` to remove the pool. */
51
+ outbound_number_pool?: Phonic.OutboundNumberPool | null;
52
+ /** Array of procedure IDs associated with the agent. */
53
+ procedure_ids?: string[];
54
+ /** Array of third-party integrations enabled for the agent. */
55
+ integrations?: Phonic.AgentIntegration[];
50
56
  }
@@ -1,4 +1,9 @@
1
+ import type * as Phonic from "../../../index.js";
1
2
  export interface AgentsUpdateResponse {
2
3
  /** Whether the agent was updated successfully. */
3
4
  success: boolean;
5
+ /** The version number of the agent after the update. */
6
+ version_number: number;
7
+ /** The updated agent. */
8
+ agent: Phonic.Agent;
4
9
  }
@@ -0,0 +1,79 @@
1
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
3
+ import * as core from "../../../../core/index.js";
4
+ import * as Phonic from "../../../index.js";
5
+ export declare namespace ApiKeysClient {
6
+ type Options = BaseClientOptions;
7
+ interface RequestOptions extends BaseRequestOptions {
8
+ }
9
+ }
10
+ export declare class ApiKeysClient {
11
+ protected readonly _options: NormalizedClientOptionsWithAuth<ApiKeysClient.Options>;
12
+ constructor(options?: ApiKeysClient.Options);
13
+ /**
14
+ * Creates a new API key in the workspace.
15
+ *
16
+ * @param {Phonic.CreateApiKeyRequest} request
17
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
18
+ *
19
+ * @throws {@link Phonic.BadRequestError}
20
+ * @throws {@link Phonic.UnauthorizedError}
21
+ * @throws {@link Phonic.InternalServerError}
22
+ *
23
+ * @example
24
+ * await client.apiKeys.create({
25
+ * name: "production-key"
26
+ * })
27
+ */
28
+ create(request: Phonic.CreateApiKeyRequest, requestOptions?: ApiKeysClient.RequestOptions): core.HttpResponsePromise<Phonic.ApiKeyWithSecret>;
29
+ private __create;
30
+ /**
31
+ * Deletes an API key.
32
+ *
33
+ * @param {string} id - The ID of the API key to delete.
34
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
35
+ *
36
+ * @throws {@link Phonic.UnauthorizedError}
37
+ * @throws {@link Phonic.NotFoundError}
38
+ * @throws {@link Phonic.InternalServerError}
39
+ *
40
+ * @example
41
+ * await client.apiKeys.delete("id")
42
+ */
43
+ delete(id: string, requestOptions?: ApiKeysClient.RequestOptions): core.HttpResponsePromise<Phonic.ApiKeysDeleteResponse>;
44
+ private __delete;
45
+ /**
46
+ * Updates an API key.
47
+ *
48
+ * @param {string} id - The ID of the API key to update.
49
+ * @param {Phonic.UpdateApiKeyRequest} request
50
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
51
+ *
52
+ * @throws {@link Phonic.BadRequestError}
53
+ * @throws {@link Phonic.UnauthorizedError}
54
+ * @throws {@link Phonic.NotFoundError}
55
+ * @throws {@link Phonic.InternalServerError}
56
+ *
57
+ * @example
58
+ * await client.apiKeys.update("id", {
59
+ * name: "renamed-key"
60
+ * })
61
+ */
62
+ update(id: string, request: Phonic.UpdateApiKeyRequest, requestOptions?: ApiKeysClient.RequestOptions): core.HttpResponsePromise<Phonic.ApiKeysUpdateResponse>;
63
+ private __update;
64
+ /**
65
+ * Rotates an API key, generating a new secret and invalidating the old one.
66
+ *
67
+ * @param {string} id - The ID of the API key to rotate.
68
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
69
+ *
70
+ * @throws {@link Phonic.UnauthorizedError}
71
+ * @throws {@link Phonic.NotFoundError}
72
+ * @throws {@link Phonic.InternalServerError}
73
+ *
74
+ * @example
75
+ * await client.apiKeys.rotate("id")
76
+ */
77
+ rotate(id: string, requestOptions?: ApiKeysClient.RequestOptions): core.HttpResponsePromise<Phonic.ApiKeyWithSecret>;
78
+ private __rotate;
79
+ }
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.ApiKeysClient = void 0;
47
+ const BaseClient_js_1 = require("../../../../BaseClient.js");
48
+ const headers_js_1 = require("../../../../core/headers.js");
49
+ const core = __importStar(require("../../../../core/index.js"));
50
+ const environments = __importStar(require("../../../../environments.js"));
51
+ const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
52
+ const errors = __importStar(require("../../../../errors/index.js"));
53
+ const Phonic = __importStar(require("../../../index.js"));
54
+ class ApiKeysClient {
55
+ constructor(options = {}) {
56
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
57
+ }
58
+ /**
59
+ * Creates a new API key in the workspace.
60
+ *
61
+ * @param {Phonic.CreateApiKeyRequest} request
62
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
63
+ *
64
+ * @throws {@link Phonic.BadRequestError}
65
+ * @throws {@link Phonic.UnauthorizedError}
66
+ * @throws {@link Phonic.InternalServerError}
67
+ *
68
+ * @example
69
+ * await client.apiKeys.create({
70
+ * name: "production-key"
71
+ * })
72
+ */
73
+ create(request, requestOptions) {
74
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
75
+ }
76
+ __create(request, requestOptions) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
79
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
80
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
81
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
82
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
83
+ .base, "api_keys"),
84
+ method: "POST",
85
+ headers: _headers,
86
+ contentType: "application/json",
87
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
88
+ requestType: "json",
89
+ body: request,
90
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
91
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
92
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
93
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
94
+ logging: this._options.logging,
95
+ });
96
+ if (_response.ok) {
97
+ return { data: _response.body, rawResponse: _response.rawResponse };
98
+ }
99
+ if (_response.error.reason === "status-code") {
100
+ switch (_response.error.statusCode) {
101
+ case 400:
102
+ throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
103
+ case 401:
104
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
105
+ case 500:
106
+ throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
107
+ default:
108
+ throw new errors.PhonicError({
109
+ statusCode: _response.error.statusCode,
110
+ body: _response.error.body,
111
+ rawResponse: _response.rawResponse,
112
+ });
113
+ }
114
+ }
115
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/api_keys");
116
+ });
117
+ }
118
+ /**
119
+ * Deletes an API key.
120
+ *
121
+ * @param {string} id - The ID of the API key to delete.
122
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
123
+ *
124
+ * @throws {@link Phonic.UnauthorizedError}
125
+ * @throws {@link Phonic.NotFoundError}
126
+ * @throws {@link Phonic.InternalServerError}
127
+ *
128
+ * @example
129
+ * await client.apiKeys.delete("id")
130
+ */
131
+ delete(id, requestOptions) {
132
+ return core.HttpResponsePromise.fromPromise(this.__delete(id, requestOptions));
133
+ }
134
+ __delete(id, requestOptions) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
137
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
138
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
139
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
140
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
141
+ .base, `api_keys/${core.url.encodePathParam(id)}`),
142
+ method: "DELETE",
143
+ headers: _headers,
144
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
145
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
146
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
147
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
148
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
149
+ logging: this._options.logging,
150
+ });
151
+ if (_response.ok) {
152
+ return { data: _response.body, rawResponse: _response.rawResponse };
153
+ }
154
+ if (_response.error.reason === "status-code") {
155
+ switch (_response.error.statusCode) {
156
+ case 401:
157
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
158
+ case 404:
159
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
160
+ case 500:
161
+ throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
162
+ default:
163
+ throw new errors.PhonicError({
164
+ statusCode: _response.error.statusCode,
165
+ body: _response.error.body,
166
+ rawResponse: _response.rawResponse,
167
+ });
168
+ }
169
+ }
170
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "DELETE", "/api_keys/{id}");
171
+ });
172
+ }
173
+ /**
174
+ * Updates an API key.
175
+ *
176
+ * @param {string} id - The ID of the API key to update.
177
+ * @param {Phonic.UpdateApiKeyRequest} request
178
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
179
+ *
180
+ * @throws {@link Phonic.BadRequestError}
181
+ * @throws {@link Phonic.UnauthorizedError}
182
+ * @throws {@link Phonic.NotFoundError}
183
+ * @throws {@link Phonic.InternalServerError}
184
+ *
185
+ * @example
186
+ * await client.apiKeys.update("id", {
187
+ * name: "renamed-key"
188
+ * })
189
+ */
190
+ update(id, request, requestOptions) {
191
+ return core.HttpResponsePromise.fromPromise(this.__update(id, request, requestOptions));
192
+ }
193
+ __update(id, request, requestOptions) {
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
196
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
197
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
198
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
199
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
200
+ .base, `api_keys/${core.url.encodePathParam(id)}`),
201
+ method: "PATCH",
202
+ headers: _headers,
203
+ contentType: "application/json",
204
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
205
+ requestType: "json",
206
+ body: request,
207
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
208
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
209
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
210
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
211
+ logging: this._options.logging,
212
+ });
213
+ if (_response.ok) {
214
+ return { data: _response.body, rawResponse: _response.rawResponse };
215
+ }
216
+ if (_response.error.reason === "status-code") {
217
+ switch (_response.error.statusCode) {
218
+ case 400:
219
+ throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
220
+ case 401:
221
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
222
+ case 404:
223
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
224
+ case 500:
225
+ throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
226
+ default:
227
+ throw new errors.PhonicError({
228
+ statusCode: _response.error.statusCode,
229
+ body: _response.error.body,
230
+ rawResponse: _response.rawResponse,
231
+ });
232
+ }
233
+ }
234
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PATCH", "/api_keys/{id}");
235
+ });
236
+ }
237
+ /**
238
+ * Rotates an API key, generating a new secret and invalidating the old one.
239
+ *
240
+ * @param {string} id - The ID of the API key to rotate.
241
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
242
+ *
243
+ * @throws {@link Phonic.UnauthorizedError}
244
+ * @throws {@link Phonic.NotFoundError}
245
+ * @throws {@link Phonic.InternalServerError}
246
+ *
247
+ * @example
248
+ * await client.apiKeys.rotate("id")
249
+ */
250
+ rotate(id, requestOptions) {
251
+ return core.HttpResponsePromise.fromPromise(this.__rotate(id, requestOptions));
252
+ }
253
+ __rotate(id, requestOptions) {
254
+ return __awaiter(this, void 0, void 0, function* () {
255
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
256
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
257
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
258
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
259
+ url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
260
+ .base, `api_keys/${core.url.encodePathParam(id)}/rotate`),
261
+ method: "POST",
262
+ headers: _headers,
263
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
264
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
265
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
266
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
267
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
268
+ logging: this._options.logging,
269
+ });
270
+ if (_response.ok) {
271
+ return { data: _response.body, rawResponse: _response.rawResponse };
272
+ }
273
+ if (_response.error.reason === "status-code") {
274
+ switch (_response.error.statusCode) {
275
+ case 401:
276
+ throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
277
+ case 404:
278
+ throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
279
+ case 500:
280
+ throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
281
+ default:
282
+ throw new errors.PhonicError({
283
+ statusCode: _response.error.statusCode,
284
+ body: _response.error.body,
285
+ rawResponse: _response.rawResponse,
286
+ });
287
+ }
288
+ }
289
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/api_keys/{id}/rotate");
290
+ });
291
+ }
292
+ }
293
+ exports.ApiKeysClient = ApiKeysClient;
@@ -0,0 +1 @@
1
+ export * from "./requests/index.js";