codeforge-main-middesk-api-sdk 1.0.0 → 1.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 (225) hide show
  1. package/README.md +106 -2
  2. package/dist/channels/http_client.d.ts +382 -4
  3. package/dist/channels/http_client.d.ts.map +1 -1
  4. package/dist/channels/http_client.js +1322 -336
  5. package/dist/channels/http_client.js.map +1 -1
  6. package/dist/client/MiddeskClient.d.ts +156 -0
  7. package/dist/client/MiddeskClient.d.ts.map +1 -1
  8. package/dist/client/MiddeskClient.js +153 -4
  9. package/dist/client/MiddeskClient.js.map +1 -1
  10. package/dist/headers/CreateSubAccountApiKeyHeaders.d.ts +10 -0
  11. package/dist/headers/CreateSubAccountApiKeyHeaders.d.ts.map +1 -0
  12. package/dist/headers/CreateSubAccountApiKeyHeaders.js +35 -0
  13. package/dist/headers/CreateSubAccountApiKeyHeaders.js.map +1 -0
  14. package/dist/headers/CreateSubAccountHeaders.d.ts +10 -0
  15. package/dist/headers/CreateSubAccountHeaders.d.ts.map +1 -0
  16. package/dist/headers/CreateSubAccountHeaders.js +35 -0
  17. package/dist/headers/CreateSubAccountHeaders.js.map +1 -0
  18. package/dist/headers/DeleteSubAccountApiKeyHeaders.d.ts +10 -0
  19. package/dist/headers/DeleteSubAccountApiKeyHeaders.d.ts.map +1 -0
  20. package/dist/headers/DeleteSubAccountApiKeyHeaders.js +35 -0
  21. package/dist/headers/DeleteSubAccountApiKeyHeaders.js.map +1 -0
  22. package/dist/headers/GetSubAccountHeaders.d.ts +10 -0
  23. package/dist/headers/GetSubAccountHeaders.d.ts.map +1 -0
  24. package/dist/headers/GetSubAccountHeaders.js +35 -0
  25. package/dist/headers/GetSubAccountHeaders.js.map +1 -0
  26. package/dist/headers/ListSubAccountApiKeysHeaders.d.ts +10 -0
  27. package/dist/headers/ListSubAccountApiKeysHeaders.d.ts.map +1 -0
  28. package/dist/headers/ListSubAccountApiKeysHeaders.js +35 -0
  29. package/dist/headers/ListSubAccountApiKeysHeaders.js.map +1 -0
  30. package/dist/headers/ListSubAccountsHeaders.d.ts +10 -0
  31. package/dist/headers/ListSubAccountsHeaders.d.ts.map +1 -0
  32. package/dist/headers/ListSubAccountsHeaders.js +35 -0
  33. package/dist/headers/ListSubAccountsHeaders.js.map +1 -0
  34. package/dist/headers/UpdateSubAccountHeaders.d.ts +10 -0
  35. package/dist/headers/UpdateSubAccountHeaders.d.ts.map +1 -0
  36. package/dist/headers/UpdateSubAccountHeaders.js +35 -0
  37. package/dist/headers/UpdateSubAccountHeaders.js.map +1 -0
  38. package/dist/index.d.ts +53 -1
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +61 -6
  41. package/dist/index.js.map +1 -1
  42. package/dist/parameters/CreateSubAccountApiKeyParameters.d.ts +47 -0
  43. package/dist/parameters/CreateSubAccountApiKeyParameters.d.ts.map +1 -0
  44. package/dist/parameters/CreateSubAccountApiKeyParameters.js +105 -0
  45. package/dist/parameters/CreateSubAccountApiKeyParameters.js.map +1 -0
  46. package/dist/parameters/DeleteSubAccountApiKeyParameters.d.ts +54 -0
  47. package/dist/parameters/DeleteSubAccountApiKeyParameters.d.ts.map +1 -0
  48. package/dist/parameters/DeleteSubAccountApiKeyParameters.js +127 -0
  49. package/dist/parameters/DeleteSubAccountApiKeyParameters.js.map +1 -0
  50. package/dist/parameters/GetDocumentDownloadUrlParameters.d.ts +18 -0
  51. package/dist/parameters/GetDocumentDownloadUrlParameters.d.ts.map +1 -1
  52. package/dist/parameters/GetDocumentDownloadUrlParameters.js +60 -0
  53. package/dist/parameters/GetDocumentDownloadUrlParameters.js.map +1 -1
  54. package/dist/parameters/GetDocumentDownloadUrlRequestDisposition.d.ts +6 -0
  55. package/dist/parameters/GetDocumentDownloadUrlRequestDisposition.d.ts.map +1 -0
  56. package/dist/parameters/GetDocumentDownloadUrlRequestDisposition.js +3 -0
  57. package/dist/parameters/GetDocumentDownloadUrlRequestDisposition.js.map +1 -0
  58. package/dist/parameters/GetSubAccountParameters.d.ts +47 -0
  59. package/dist/parameters/GetSubAccountParameters.d.ts.map +1 -0
  60. package/dist/parameters/GetSubAccountParameters.js +105 -0
  61. package/dist/parameters/GetSubAccountParameters.js.map +1 -0
  62. package/dist/parameters/ListSubAccountApiKeysParameters.d.ts +71 -0
  63. package/dist/parameters/ListSubAccountApiKeysParameters.d.ts.map +1 -0
  64. package/dist/parameters/ListSubAccountApiKeysParameters.js +198 -0
  65. package/dist/parameters/ListSubAccountApiKeysParameters.js.map +1 -0
  66. package/dist/parameters/ListSubAccountsParameters.d.ts +83 -0
  67. package/dist/parameters/ListSubAccountsParameters.d.ts.map +1 -0
  68. package/dist/parameters/ListSubAccountsParameters.js +240 -0
  69. package/dist/parameters/ListSubAccountsParameters.js.map +1 -0
  70. package/dist/parameters/ListSubAccountsRequestEnabled.d.ts +6 -0
  71. package/dist/parameters/ListSubAccountsRequestEnabled.d.ts.map +1 -0
  72. package/dist/parameters/ListSubAccountsRequestEnabled.js +3 -0
  73. package/dist/parameters/ListSubAccountsRequestEnabled.js.map +1 -0
  74. package/dist/parameters/ListSubAccountsRequestSortBy.d.ts +6 -0
  75. package/dist/parameters/ListSubAccountsRequestSortBy.d.ts.map +1 -0
  76. package/dist/parameters/ListSubAccountsRequestSortBy.js +3 -0
  77. package/dist/parameters/ListSubAccountsRequestSortBy.js.map +1 -0
  78. package/dist/parameters/ListSubAccountsRequestSortOrder.d.ts +6 -0
  79. package/dist/parameters/ListSubAccountsRequestSortOrder.d.ts.map +1 -0
  80. package/dist/parameters/ListSubAccountsRequestSortOrder.js +3 -0
  81. package/dist/parameters/ListSubAccountsRequestSortOrder.js.map +1 -0
  82. package/dist/parameters/SearchJurisdictionsParameters.d.ts +0 -7
  83. package/dist/parameters/SearchJurisdictionsParameters.d.ts.map +1 -1
  84. package/dist/parameters/SearchJurisdictionsParameters.js +0 -27
  85. package/dist/parameters/SearchJurisdictionsParameters.js.map +1 -1
  86. package/dist/parameters/UpdateSubAccountParameters.d.ts +47 -0
  87. package/dist/parameters/UpdateSubAccountParameters.d.ts.map +1 -0
  88. package/dist/parameters/UpdateSubAccountParameters.js +105 -0
  89. package/dist/parameters/UpdateSubAccountParameters.js.map +1 -0
  90. package/dist/payloads/AgentsRun.d.ts +4 -0
  91. package/dist/payloads/AgentsRun.d.ts.map +1 -1
  92. package/dist/payloads/ApiKey.d.ts +17 -0
  93. package/dist/payloads/ApiKey.d.ts.map +1 -0
  94. package/dist/payloads/ApiKey.js +3 -0
  95. package/dist/payloads/ApiKey.js.map +1 -0
  96. package/dist/payloads/ApiKeyApiVersion.d.ts +6 -0
  97. package/dist/payloads/ApiKeyApiVersion.d.ts.map +1 -0
  98. package/dist/payloads/ApiKeyApiVersion.js +9 -0
  99. package/dist/payloads/ApiKeyApiVersion.js.map +1 -0
  100. package/dist/payloads/ApiKeyObject.d.ts +5 -0
  101. package/dist/payloads/ApiKeyObject.d.ts.map +1 -0
  102. package/dist/payloads/ApiKeyObject.js +8 -0
  103. package/dist/payloads/ApiKeyObject.js.map +1 -0
  104. package/dist/payloads/BusinessRequest.d.ts +1 -1
  105. package/dist/payloads/CreateSubAccountApiKeyRequest.d.ts +7 -0
  106. package/dist/payloads/CreateSubAccountApiKeyRequest.d.ts.map +1 -0
  107. package/dist/payloads/CreateSubAccountApiKeyRequest.js +3 -0
  108. package/dist/payloads/CreateSubAccountApiKeyRequest.js.map +1 -0
  109. package/dist/payloads/CreateSubAccountApiKeyResponse.d.ts +5 -0
  110. package/dist/payloads/CreateSubAccountApiKeyResponse.d.ts.map +1 -0
  111. package/dist/payloads/CreateSubAccountApiKeyResponse.js +3 -0
  112. package/dist/payloads/CreateSubAccountApiKeyResponse.js.map +1 -0
  113. package/dist/payloads/CreateSubAccountRequest.d.ts +51 -0
  114. package/dist/payloads/CreateSubAccountRequest.d.ts.map +1 -0
  115. package/dist/payloads/CreateSubAccountRequest.js +3 -0
  116. package/dist/payloads/CreateSubAccountRequest.js.map +1 -0
  117. package/dist/payloads/CreateSubAccountResponse.d.ts +5 -0
  118. package/dist/payloads/CreateSubAccountResponse.d.ts.map +1 -0
  119. package/dist/payloads/CreateSubAccountResponse.js +3 -0
  120. package/dist/payloads/CreateSubAccountResponse.js.map +1 -0
  121. package/dist/payloads/DeleteSubAccountApiKeyResponse.d.ts +3 -0
  122. package/dist/payloads/DeleteSubAccountApiKeyResponse.d.ts.map +1 -0
  123. package/dist/payloads/DeleteSubAccountApiKeyResponse.js +3 -0
  124. package/dist/payloads/DeleteSubAccountApiKeyResponse.js.map +1 -0
  125. package/dist/payloads/ErrorResponseErrorsItem.d.ts +4 -0
  126. package/dist/payloads/ErrorResponseErrorsItem.d.ts.map +1 -1
  127. package/dist/payloads/GetDocumentDownloadUrlRequestDisposition.d.ts +5 -0
  128. package/dist/payloads/GetDocumentDownloadUrlRequestDisposition.d.ts.map +1 -0
  129. package/dist/payloads/GetDocumentDownloadUrlRequestDisposition.js +8 -0
  130. package/dist/payloads/GetDocumentDownloadUrlRequestDisposition.js.map +1 -0
  131. package/dist/payloads/GetSubAccountResponse.d.ts +5 -0
  132. package/dist/payloads/GetSubAccountResponse.d.ts.map +1 -0
  133. package/dist/payloads/GetSubAccountResponse.js +3 -0
  134. package/dist/payloads/GetSubAccountResponse.js.map +1 -0
  135. package/dist/payloads/LienStatus.d.ts +2 -1
  136. package/dist/payloads/LienStatus.d.ts.map +1 -1
  137. package/dist/payloads/LienStatus.js +1 -0
  138. package/dist/payloads/LienStatus.js.map +1 -1
  139. package/dist/payloads/LienStatusCategory.d.ts +2 -1
  140. package/dist/payloads/LienStatusCategory.d.ts.map +1 -1
  141. package/dist/payloads/LienStatusCategory.js +1 -0
  142. package/dist/payloads/LienStatusCategory.js.map +1 -1
  143. package/dist/payloads/ListSubAccountApiKeysResponse.d.ts +5 -0
  144. package/dist/payloads/ListSubAccountApiKeysResponse.d.ts.map +1 -0
  145. package/dist/payloads/ListSubAccountApiKeysResponse.js +3 -0
  146. package/dist/payloads/ListSubAccountApiKeysResponse.js.map +1 -0
  147. package/dist/payloads/ListSubAccountApiKeysResponse1.d.ts +9 -0
  148. package/dist/payloads/ListSubAccountApiKeysResponse1.d.ts.map +1 -0
  149. package/dist/payloads/ListSubAccountApiKeysResponse1.js +3 -0
  150. package/dist/payloads/ListSubAccountApiKeysResponse1.js.map +1 -0
  151. package/dist/payloads/ListSubAccountApiKeysResponse2.d.ts +9 -0
  152. package/dist/payloads/ListSubAccountApiKeysResponse2.d.ts.map +1 -0
  153. package/dist/payloads/ListSubAccountApiKeysResponse2.js +3 -0
  154. package/dist/payloads/ListSubAccountApiKeysResponse2.js.map +1 -0
  155. package/dist/payloads/ListSubAccountsRequestEnabled.d.ts +6 -0
  156. package/dist/payloads/ListSubAccountsRequestEnabled.d.ts.map +1 -0
  157. package/dist/payloads/ListSubAccountsRequestEnabled.js +9 -0
  158. package/dist/payloads/ListSubAccountsRequestEnabled.js.map +1 -0
  159. package/dist/payloads/ListSubAccountsRequestSortBy.d.ts +5 -0
  160. package/dist/payloads/ListSubAccountsRequestSortBy.d.ts.map +1 -0
  161. package/dist/payloads/ListSubAccountsRequestSortBy.js +8 -0
  162. package/dist/payloads/ListSubAccountsRequestSortBy.js.map +1 -0
  163. package/dist/payloads/ListSubAccountsRequestSortOrder.d.ts +6 -0
  164. package/dist/payloads/ListSubAccountsRequestSortOrder.d.ts.map +1 -0
  165. package/dist/payloads/ListSubAccountsRequestSortOrder.js +9 -0
  166. package/dist/payloads/ListSubAccountsRequestSortOrder.js.map +1 -0
  167. package/dist/payloads/ListSubAccountsResponse.d.ts +5 -0
  168. package/dist/payloads/ListSubAccountsResponse.d.ts.map +1 -0
  169. package/dist/payloads/ListSubAccountsResponse.js +3 -0
  170. package/dist/payloads/ListSubAccountsResponse.js.map +1 -0
  171. package/dist/payloads/ListSubAccountsResponse1.d.ts +9 -0
  172. package/dist/payloads/ListSubAccountsResponse1.d.ts.map +1 -0
  173. package/dist/payloads/ListSubAccountsResponse1.js +3 -0
  174. package/dist/payloads/ListSubAccountsResponse1.js.map +1 -0
  175. package/dist/payloads/ListSubAccountsResponse2.d.ts +9 -0
  176. package/dist/payloads/ListSubAccountsResponse2.d.ts.map +1 -0
  177. package/dist/payloads/ListSubAccountsResponse2.js +3 -0
  178. package/dist/payloads/ListSubAccountsResponse2.js.map +1 -0
  179. package/dist/payloads/SubAccount.d.ts +18 -0
  180. package/dist/payloads/SubAccount.d.ts.map +1 -0
  181. package/dist/payloads/SubAccount.js +3 -0
  182. package/dist/payloads/SubAccount.js.map +1 -0
  183. package/dist/payloads/SubAccountApiKeyCreateParamEnvironment.d.ts +6 -0
  184. package/dist/payloads/SubAccountApiKeyCreateParamEnvironment.d.ts.map +1 -0
  185. package/dist/payloads/SubAccountApiKeyCreateParamEnvironment.js +9 -0
  186. package/dist/payloads/SubAccountApiKeyCreateParamEnvironment.js.map +1 -0
  187. package/dist/payloads/SubAccountCreateParamContact.d.ts +11 -0
  188. package/dist/payloads/SubAccountCreateParamContact.d.ts.map +1 -0
  189. package/dist/payloads/SubAccountCreateParamContact.js +3 -0
  190. package/dist/payloads/SubAccountCreateParamContact.js.map +1 -0
  191. package/dist/payloads/SubAccountCreateParamProductsItem.d.ts +30 -0
  192. package/dist/payloads/SubAccountCreateParamProductsItem.d.ts.map +1 -0
  193. package/dist/payloads/SubAccountCreateParamProductsItem.js +33 -0
  194. package/dist/payloads/SubAccountCreateParamProductsItem.js.map +1 -0
  195. package/dist/payloads/SubAccountCreateParamSubVertical.d.ts +32 -0
  196. package/dist/payloads/SubAccountCreateParamSubVertical.d.ts.map +1 -0
  197. package/dist/payloads/SubAccountCreateParamSubVertical.js +35 -0
  198. package/dist/payloads/SubAccountCreateParamSubVertical.js.map +1 -0
  199. package/dist/payloads/SubAccountCreateParamUseCase.d.ts +43 -0
  200. package/dist/payloads/SubAccountCreateParamUseCase.d.ts.map +1 -0
  201. package/dist/payloads/SubAccountCreateParamUseCase.js +46 -0
  202. package/dist/payloads/SubAccountCreateParamUseCase.js.map +1 -0
  203. package/dist/payloads/SubAccountCreateParamVertical.d.ts +14 -0
  204. package/dist/payloads/SubAccountCreateParamVertical.d.ts.map +1 -0
  205. package/dist/payloads/SubAccountCreateParamVertical.js +17 -0
  206. package/dist/payloads/SubAccountCreateParamVertical.js.map +1 -0
  207. package/dist/payloads/SubAccountObject.d.ts +5 -0
  208. package/dist/payloads/SubAccountObject.d.ts.map +1 -0
  209. package/dist/payloads/SubAccountObject.js +8 -0
  210. package/dist/payloads/SubAccountObject.js.map +1 -0
  211. package/dist/payloads/SubmittedAddressComponent.d.ts +2 -2
  212. package/dist/payloads/SubmittedAddressComponent.d.ts.map +1 -1
  213. package/dist/payloads/UpdateSubAccountRequest.d.ts +5 -0
  214. package/dist/payloads/UpdateSubAccountRequest.d.ts.map +1 -0
  215. package/dist/payloads/UpdateSubAccountRequest.js +3 -0
  216. package/dist/payloads/UpdateSubAccountRequest.js.map +1 -0
  217. package/dist/payloads/UpdateSubAccountResponse.d.ts +5 -0
  218. package/dist/payloads/UpdateSubAccountResponse.d.ts.map +1 -0
  219. package/dist/payloads/UpdateSubAccountResponse.js +3 -0
  220. package/dist/payloads/UpdateSubAccountResponse.js.map +1 -0
  221. package/dist/types/Types.d.ts +2 -2
  222. package/dist/types/Types.d.ts.map +1 -1
  223. package/dist/types/Types.js +30 -1
  224. package/dist/types/Types.js.map +1 -1
  225. package/package.json +4 -1
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpHookCapabilityError = exports.HttpError = void 0;
3
+ exports.HttpHookCapabilityError = exports.TimeoutError = exports.InternalServerError = exports.RateLimitError = exports.UnprocessableEntityError = exports.ConflictError = exports.NotFoundError = exports.PermissionDeniedError = exports.AuthenticationError = exports.BadRequestError = exports.HttpError = void 0;
4
+ exports.request = request;
4
5
  exports.listBusinesses = listBusinesses;
5
6
  exports.createBusiness = createBusiness;
6
7
  exports.getBusiness = getBusiness;
@@ -80,6 +81,13 @@ exports.getDocumentDownloadUrl = getDocumentDownloadUrl;
80
81
  exports.getRiskAssessments = getRiskAssessments;
81
82
  exports.getLatestRiskAssessment = getLatestRiskAssessment;
82
83
  exports.getRiskAssessment = getRiskAssessment;
84
+ exports.listSubAccounts = listSubAccounts;
85
+ exports.createSubAccount = createSubAccount;
86
+ exports.getSubAccount = getSubAccount;
87
+ exports.updateSubAccount = updateSubAccount;
88
+ exports.listSubAccountApiKeys = listSubAccountApiKeys;
89
+ exports.createSubAccountApiKey = createSubAccountApiKey;
90
+ exports.deleteSubAccountApiKey = deleteSubAccountApiKey;
83
91
  const GetBusinessParameters_js_1 = require("./../parameters/GetBusinessParameters.js");
84
92
  const UpdateBusinessParameters_js_1 = require("./../parameters/UpdateBusinessParameters.js");
85
93
  const GetBusinessPdfParameters_js_1 = require("./../parameters/GetBusinessPdfParameters.js");
@@ -142,6 +150,12 @@ const GetDocumentDownloadUrlParameters_js_1 = require("./../parameters/GetDocume
142
150
  const GetRiskAssessmentsParameters_js_1 = require("./../parameters/GetRiskAssessmentsParameters.js");
143
151
  const GetLatestRiskAssessmentParameters_js_1 = require("./../parameters/GetLatestRiskAssessmentParameters.js");
144
152
  const GetRiskAssessmentParameters_js_1 = require("./../parameters/GetRiskAssessmentParameters.js");
153
+ const ListSubAccountsParameters_js_1 = require("./../parameters/ListSubAccountsParameters.js");
154
+ const GetSubAccountParameters_js_1 = require("./../parameters/GetSubAccountParameters.js");
155
+ const UpdateSubAccountParameters_js_1 = require("./../parameters/UpdateSubAccountParameters.js");
156
+ const ListSubAccountApiKeysParameters_js_1 = require("./../parameters/ListSubAccountApiKeysParameters.js");
157
+ const CreateSubAccountApiKeyParameters_js_1 = require("./../parameters/CreateSubAccountApiKeyParameters.js");
158
+ const DeleteSubAccountApiKeyParameters_js_1 = require("./../parameters/DeleteSubAccountApiKeyParameters.js");
145
159
  const ListBusinessesHeaders_js_1 = require("./../headers/ListBusinessesHeaders.js");
146
160
  const CreateBusinessHeaders_js_1 = require("./../headers/CreateBusinessHeaders.js");
147
161
  const GetBusinessHeaders_js_1 = require("./../headers/GetBusinessHeaders.js");
@@ -220,6 +234,13 @@ const GetDocumentDownloadUrlHeaders_js_1 = require("./../headers/GetDocumentDown
220
234
  const GetRiskAssessmentsHeaders_js_1 = require("./../headers/GetRiskAssessmentsHeaders.js");
221
235
  const GetLatestRiskAssessmentHeaders_js_1 = require("./../headers/GetLatestRiskAssessmentHeaders.js");
222
236
  const GetRiskAssessmentHeaders_js_1 = require("./../headers/GetRiskAssessmentHeaders.js");
237
+ const ListSubAccountsHeaders_js_1 = require("./../headers/ListSubAccountsHeaders.js");
238
+ const CreateSubAccountHeaders_js_1 = require("./../headers/CreateSubAccountHeaders.js");
239
+ const GetSubAccountHeaders_js_1 = require("./../headers/GetSubAccountHeaders.js");
240
+ const UpdateSubAccountHeaders_js_1 = require("./../headers/UpdateSubAccountHeaders.js");
241
+ const ListSubAccountApiKeysHeaders_js_1 = require("./../headers/ListSubAccountApiKeysHeaders.js");
242
+ const CreateSubAccountApiKeyHeaders_js_1 = require("./../headers/CreateSubAccountApiKeyHeaders.js");
243
+ const DeleteSubAccountApiKeyHeaders_js_1 = require("./../headers/DeleteSubAccountApiKeyHeaders.js");
223
244
  // ============================================================================
224
245
  // Common Types - Shared across all HTTP client functions
225
246
  // ============================================================================
@@ -249,6 +270,105 @@ class HttpError extends HttpGlobalError {
249
270
  }
250
271
  }
251
272
  exports.HttpError = HttpError;
273
+ /**
274
+ * Thrown for a 400 Bad Request response.
275
+ */
276
+ class BadRequestError extends HttpError {
277
+ constructor(message, statusText, body) {
278
+ super(message, 400, statusText, body);
279
+ this.name = 'BadRequestError';
280
+ }
281
+ }
282
+ exports.BadRequestError = BadRequestError;
283
+ /**
284
+ * Thrown for a 401 Unauthorized response.
285
+ */
286
+ class AuthenticationError extends HttpError {
287
+ constructor(message, statusText, body) {
288
+ super(message, 401, statusText, body);
289
+ this.name = 'AuthenticationError';
290
+ }
291
+ }
292
+ exports.AuthenticationError = AuthenticationError;
293
+ /**
294
+ * Thrown for a 403 Forbidden response.
295
+ */
296
+ class PermissionDeniedError extends HttpError {
297
+ constructor(message, statusText, body) {
298
+ super(message, 403, statusText, body);
299
+ this.name = 'PermissionDeniedError';
300
+ }
301
+ }
302
+ exports.PermissionDeniedError = PermissionDeniedError;
303
+ /**
304
+ * Thrown for a 404 Not Found response.
305
+ */
306
+ class NotFoundError extends HttpError {
307
+ constructor(message, statusText, body) {
308
+ super(message, 404, statusText, body);
309
+ this.name = 'NotFoundError';
310
+ }
311
+ }
312
+ exports.NotFoundError = NotFoundError;
313
+ /**
314
+ * Thrown for a 409 Conflict response.
315
+ */
316
+ class ConflictError extends HttpError {
317
+ constructor(message, statusText, body) {
318
+ super(message, 409, statusText, body);
319
+ this.name = 'ConflictError';
320
+ }
321
+ }
322
+ exports.ConflictError = ConflictError;
323
+ /**
324
+ * Thrown for a 422 Unprocessable Entity response.
325
+ */
326
+ class UnprocessableEntityError extends HttpError {
327
+ constructor(message, statusText, body) {
328
+ super(message, 422, statusText, body);
329
+ this.name = 'UnprocessableEntityError';
330
+ }
331
+ }
332
+ exports.UnprocessableEntityError = UnprocessableEntityError;
333
+ /**
334
+ * Thrown for a 429 Too Many Requests response.
335
+ */
336
+ class RateLimitError extends HttpError {
337
+ constructor(message, statusText, body) {
338
+ super(message, 429, statusText, body);
339
+ this.name = 'RateLimitError';
340
+ }
341
+ }
342
+ exports.RateLimitError = RateLimitError;
343
+ /**
344
+ * Thrown for any response with a status of 500 or higher. `status` stays
345
+ * `number` since the range spans many codes - check it to tell a 500 from a
346
+ * 503.
347
+ */
348
+ class InternalServerError extends HttpError {
349
+ constructor(message, status, statusText, body) {
350
+ super(message, status, statusText, body);
351
+ this.name = 'InternalServerError';
352
+ }
353
+ }
354
+ exports.InternalServerError = InternalServerError;
355
+ /**
356
+ * Thrown when a single request attempt does not complete within `timeoutMs`.
357
+ *
358
+ * The timer is per attempt, not per call: a request that times out and then
359
+ * retries gets a fresh `timeoutMs` on the next attempt. Retryable under the
360
+ * same rule as a network error - unlike a caller-triggered `AbortSignal`,
361
+ * which is never retried.
362
+ */
363
+ class TimeoutError extends HttpGlobalError {
364
+ constructor(url, timeoutMs) {
365
+ super(`Request to ${url} timed out after ${timeoutMs}ms`);
366
+ this.name = 'TimeoutError';
367
+ this.url = url;
368
+ this.timeoutMs = timeoutMs;
369
+ }
370
+ }
371
+ exports.TimeoutError = TimeoutError;
252
372
  // ============================================================================
253
373
  // Helper Functions - Shared logic extracted for reuse
254
374
  // ============================================================================
@@ -265,9 +385,16 @@ const DEFAULT_RETRY_CONFIG = {
265
385
  onRetry: () => { },
266
386
  };
267
387
  /**
268
- * Default request hook implementation using the global fetch (Node.js 18+)
388
+ * The `timeoutMs` every request uses unless the client config or an
389
+ * individual call overrides it.
390
+ */
391
+ const DEFAULT_TIMEOUT_MS = 60000;
392
+ /**
393
+ * Default request hook implementation using the global fetch (Node.js 20+),
394
+ * or the client's `fetch` config field when set - the narrow transport seam
395
+ * `hooks.makeRequest` bypasses entirely.
269
396
  */
270
- const defaultMakeRequest = async (params) => {
397
+ const defaultMakeRequest = async (params, customFetch) => {
271
398
  // Build a Headers object so multi-value headers (string[]) are preserved -
272
399
  // the global fetch's HeadersInit only accepts string values in a plain object.
273
400
  const headers = new Headers();
@@ -281,10 +408,12 @@ const defaultMakeRequest = async (params) => {
281
408
  headers.set(name, value);
282
409
  }
283
410
  }
284
- return fetch(params.url, {
411
+ const runFetch = customFetch ?? fetch;
412
+ return runFetch(params.url, {
285
413
  body: params.body,
286
414
  method: params.method,
287
- headers
415
+ headers,
416
+ signal: params.signal
288
417
  });
289
418
  };
290
419
  /**
@@ -337,6 +466,11 @@ function calculateBackoffDelay(attempt, config) {
337
466
  function shouldRetry(error, response, config, attempt) {
338
467
  if (attempt >= config.maxRetries)
339
468
  return false;
469
+ // An aborted request is a caller-initiated cancellation, not a transient
470
+ // network failure - retrying it just re-attempts against an already-aborted
471
+ // signal and delays the caller's rejection by the backoff schedule.
472
+ if (error && error.name === 'AbortError')
473
+ return false;
340
474
  if (error && config.retryOnNetworkError)
341
475
  return true;
342
476
  if (response && config.retryableStatusCodes.includes(response.status))
@@ -344,20 +478,36 @@ function shouldRetry(error, response, config, attempt) {
344
478
  return false;
345
479
  }
346
480
  /**
347
- * Execute request with retry logic
481
+ * Execute request with retry logic.
482
+ *
483
+ * Composes a fresh per-attempt `AbortSignal` from the caller's own `signal`
484
+ * (unchanged across attempts) and a fresh `AbortSignal.timeout(timeoutMs)`
485
+ * (one per attempt, so a request that times out and retries gets a new timer
486
+ * on the next attempt). `timeoutMs` is `undefined` for a streaming operation,
487
+ * which skips this function entirely and keeps caller-only cancellation.
488
+ *
489
+ * When both signals fire near-simultaneously, the caller's own `signal` - not
490
+ * the composed one - decides the classification: a caller abort always
491
+ * rethrows `AbortError` and is never retried, even if the timeout also
492
+ * expired in the same instant. A timeout throws `TimeoutError`, retryable
493
+ * under the same rule as a network error.
348
494
  */
349
- async function executeWithRetry(params, makeRequest, retryConfig) {
495
+ async function executeWithRetry(params, makeRequest, retryConfig, timeoutMs) {
350
496
  const config = { ...DEFAULT_RETRY_CONFIG, ...retryConfig };
351
497
  let lastError = null;
352
498
  let lastResponse = null;
353
499
  for (let attempt = 0; attempt <= config.maxRetries; attempt++) {
500
+ let timeoutSignal;
354
501
  try {
355
502
  if (attempt > 0) {
356
503
  const delay = calculateBackoffDelay(attempt, config);
357
504
  config.onRetry(attempt, delay, lastError ?? new HttpGlobalError('Retry attempt'));
358
505
  await sleep(delay);
359
506
  }
360
- const response = await makeRequest(params);
507
+ timeoutSignal = timeoutMs === undefined ? undefined : AbortSignal.timeout(timeoutMs);
508
+ const attemptSignals = [params.signal, timeoutSignal].filter((signal) => signal !== undefined);
509
+ const attemptParams = attemptSignals.length > 0 ? { ...params, signal: AbortSignal.any(attemptSignals) } : params;
510
+ const response = await makeRequest(attemptParams);
361
511
  // Check if we should retry this response
362
512
  if (!shouldRetry(null, response, config, attempt + 1)) {
363
513
  return response;
@@ -366,7 +516,21 @@ async function executeWithRetry(params, makeRequest, retryConfig) {
366
516
  lastError = new HttpGlobalError(`HTTP Error: ${response.status} ${response.statusText}`);
367
517
  }
368
518
  catch (error) {
369
- lastError = error instanceof HttpGlobalError ? error : new HttpGlobalError(String(error));
519
+ // Checked directly against the caller's own signal (rather than
520
+ // through the error's `name`) because an aborted fetch can throw an
521
+ // `AbortError` from a realm whose `Error` differs from this module's,
522
+ // which would otherwise wrap it and lose that identity before
523
+ // `shouldRetry` ever saw it.
524
+ if (params.signal?.aborted) {
525
+ lastError = error instanceof HttpGlobalError ? error : new HttpGlobalError(String(error));
526
+ throw lastError;
527
+ }
528
+ lastError =
529
+ timeoutSignal?.aborted && timeoutMs !== undefined
530
+ ? new TimeoutError(params.url, timeoutMs)
531
+ : error instanceof HttpGlobalError
532
+ ? error
533
+ : new HttpGlobalError(String(error));
370
534
  if (!shouldRetry(lastError, null, config, attempt + 1)) {
371
535
  throw lastError;
372
536
  }
@@ -379,28 +543,57 @@ async function executeWithRetry(params, makeRequest, retryConfig) {
379
543
  throw lastError ?? new HttpGlobalError('Request failed after retries');
380
544
  }
381
545
  /**
382
- * Handle HTTP error status codes by throwing a typed HttpError.
383
- * Explicit cases are generated from the error status codes declared by the
384
- * input document; undeclared codes fall through to the default handler.
546
+ * Picks the `HttpError` subclass for a status: an exact match against the
547
+ * fixed per-status set, then the >= 500 range as `InternalServerError`,
548
+ * then plain `HttpError`.
549
+ */
550
+ function errorForStatus(status, message, statusText, body) {
551
+ switch (status) {
552
+ case 400:
553
+ return new BadRequestError(message, statusText, body);
554
+ case 401:
555
+ return new AuthenticationError(message, statusText, body);
556
+ case 403:
557
+ return new PermissionDeniedError(message, statusText, body);
558
+ case 404:
559
+ return new NotFoundError(message, statusText, body);
560
+ case 409:
561
+ return new ConflictError(message, statusText, body);
562
+ case 422:
563
+ return new UnprocessableEntityError(message, statusText, body);
564
+ case 429:
565
+ return new RateLimitError(message, statusText, body);
566
+ default:
567
+ return status >= 500
568
+ ? new InternalServerError(message, status, statusText, body)
569
+ : new HttpError(message, status, statusText, body);
570
+ }
571
+ }
572
+ /**
573
+ * Handle HTTP error status codes by throwing the matching `HttpError`
574
+ * subclass. Explicit cases are generated from the error status codes declared
575
+ * by the input document, and only ever pick the message; undeclared codes
576
+ * fall through to the default handler with a generic message. Either way,
577
+ * `errorForStatus` alone decides which subclass gets thrown.
385
578
  */
386
579
  function handleHttpError(status, statusText, body) {
387
580
  switch (status) {
388
581
  case 400:
389
- throw new HttpError("Bad Request", status, statusText, body);
582
+ throw errorForStatus(status, "Bad Request", statusText, body);
390
583
  case 403:
391
- throw new HttpError("Forbidden", status, statusText, body);
584
+ throw errorForStatus(status, "Forbidden", statusText, body);
392
585
  case 404:
393
- throw new HttpError("Not Found", status, statusText, body);
586
+ throw errorForStatus(status, "Not Found", statusText, body);
394
587
  case 409:
395
- throw new HttpError("Conflict", status, statusText, body);
588
+ throw errorForStatus(status, "Conflict", statusText, body);
396
589
  case 422:
397
- throw new HttpError("Unprocessable Entity", status, statusText, body);
590
+ throw errorForStatus(status, "Unprocessable Entity", statusText, body);
398
591
  case 429:
399
- throw new HttpError("Too Many Requests", status, statusText, body);
592
+ throw errorForStatus(status, "Too Many Requests", statusText, body);
400
593
  case 503:
401
- throw new HttpError("Service Unavailable", status, statusText, body);
594
+ throw errorForStatus(status, "Service Unavailable", statusText, body);
402
595
  default:
403
- throw new HttpError(`HTTP Error: ${status} ${statusText}`, status, statusText, body);
596
+ throw errorForStatus(status, `HTTP Error: ${status} ${statusText}`, statusText, body);
404
597
  }
405
598
  }
406
599
  /**
@@ -521,6 +714,148 @@ async function readErrorBody(response) {
521
714
  return undefined;
522
715
  }
523
716
  }
717
+ /**
718
+ * Read the `Content-Type` response header ahead of choosing how to parse the
719
+ * body. A `Headers` instance and a plain header object disagree on casing -
720
+ * the same disagreement `extractHeaders` resolves after the body is already
721
+ * read, which is too late for this decision.
722
+ */
723
+ function getContentTypeHeader(response) {
724
+ if (!response.headers) {
725
+ return undefined;
726
+ }
727
+ if (typeof response.headers.get === 'function') {
728
+ return response.headers.get('content-type') ?? undefined;
729
+ }
730
+ for (const [key, value] of Object.entries(response.headers)) {
731
+ if (key.toLowerCase() === 'content-type') {
732
+ return value;
733
+ }
734
+ }
735
+ return undefined;
736
+ }
737
+ /**
738
+ * Classify a runtime `Content-Type` header the same way a declared response
739
+ * media type is classified at generation time: an exact JSON media type or a
740
+ * `+json` suffix reads as JSON, anything under `text/` reads as text, and
741
+ * everything else reads as binary - so a server sending an undeclared content
742
+ * type is still read as sensibly as possible, rather than by whichever
743
+ * variant happened to be declared. Returns `undefined` only when the response
744
+ * carries no `Content-Type` header at all, which the caller resolves by
745
+ * falling back to its highest-priority declared variant.
746
+ */
747
+ function classifyRuntimeContentType(contentType) {
748
+ if (!contentType) {
749
+ return undefined;
750
+ }
751
+ const normalized = contentType.toLowerCase().split(';')[0].trim();
752
+ if (normalized === 'application/json' || normalized === 'text/json' || normalized.endsWith('+json')) {
753
+ return 'json';
754
+ }
755
+ if (normalized.startsWith('text/')) {
756
+ return 'text';
757
+ }
758
+ return 'binary';
759
+ }
760
+ /** Whether `body` is already wire-ready and must be sent as-is rather than JSON-serialized. */
761
+ function isEncodedRequestBody(value) {
762
+ return (typeof value === 'string' ||
763
+ value instanceof FormData ||
764
+ value instanceof Blob ||
765
+ value instanceof URLSearchParams ||
766
+ value instanceof ArrayBuffer ||
767
+ ArrayBuffer.isView(value) ||
768
+ value instanceof ReadableStream);
769
+ }
770
+ /**
771
+ * Read the body of a raw request's error response without assuming it is
772
+ * JSON - the endpoint is unmodeled, so unlike a generated operation's error
773
+ * path there is no declared content type to fall back on either way.
774
+ */
775
+ async function readRawRequestErrorBody(response) {
776
+ try {
777
+ return await response.json();
778
+ }
779
+ catch {
780
+ // fall through to text
781
+ }
782
+ try {
783
+ return typeof response.text === 'function' ? await response.text() : undefined;
784
+ }
785
+ catch {
786
+ return undefined;
787
+ }
788
+ }
789
+ /**
790
+ * Escape hatch for a request none of the generated operations model. Goes
791
+ * through the same pipeline every operation does - baseUrl joining through
792
+ * the `URL` constructor, `applyAuth`, `additionalHeaders`,
793
+ * `additionalQueryParams`, retries, the per-attempt `timeoutMs`, and hooks -
794
+ * and throws through the same `handleHttpError` on a non-OK response.
795
+ *
796
+ * `data` parses by the response's own `Content-Type` header: a JSON type via
797
+ * `response.json()`, a textual type via `response.text()`, and anything else
798
+ * as a `Blob`. A response with no `Content-Type` header is read as JSON.
799
+ */
800
+ async function request(options) {
801
+ const config = {
802
+ baseUrl: 'https://api.middesk.com',
803
+ ...options
804
+ };
805
+ const bodyIsEncoded = config.body === undefined || isEncodedRequestBody(config.body);
806
+ const body = bodyIsEncoded ? config.body : JSON.stringify(config.body);
807
+ let headers = {
808
+ ...(bodyIsEncoded ? {} : { 'Content-Type': 'application/json' }),
809
+ ...config.additionalHeaders,
810
+ ...config.headers
811
+ };
812
+ let url = new URL(config.path, config.baseUrl).toString();
813
+ url = applyQueryParams(config.additionalQueryParams, url);
814
+ url = applyQueryParams(config.query, url);
815
+ const authResult = applyAuth(config.auth, headers, url);
816
+ headers = authResult.headers;
817
+ url = authResult.url;
818
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
819
+ let requestParams = {
820
+ url,
821
+ method: config.method,
822
+ headers,
823
+ body,
824
+ signal: config.signal
825
+ };
826
+ if (config.hooks?.beforeRequest) {
827
+ requestParams = await config.hooks.beforeRequest(requestParams);
828
+ }
829
+ try {
830
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
831
+ if (config.hooks?.afterResponse) {
832
+ response = await config.hooks.afterResponse(response, requestParams);
833
+ }
834
+ if (!response.ok) {
835
+ const errorBody = await readRawRequestErrorBody(response);
836
+ handleHttpError(response.status, response.statusText, errorBody);
837
+ }
838
+ const contentType = getContentTypeHeader(response);
839
+ const classification = classifyRuntimeContentType(contentType) ?? 'json';
840
+ let data;
841
+ if (classification === 'json') {
842
+ data = await response.json();
843
+ }
844
+ else if (classification === 'text') {
845
+ data = typeof response.text === 'function' ? await response.text() : undefined;
846
+ }
847
+ else {
848
+ data = typeof response.blob === 'function' ? await response.blob() : undefined;
849
+ }
850
+ return { data, response };
851
+ }
852
+ catch (error) {
853
+ if (config.hooks?.onError && error instanceof HttpGlobalError) {
854
+ throw await config.hooks.onError(error, requestParams);
855
+ }
856
+ throw error;
857
+ }
858
+ }
524
859
  /**
525
860
  * List businesses
526
861
  */
@@ -541,14 +876,16 @@ async function listBusinesses(context = {}) {
541
876
  url = authResult.url;
542
877
  // Prepare body
543
878
  const body = undefined;
544
- // Determine request function
545
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
879
+ // Determine request function - a custom fetch is read only by the built-in
880
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
881
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
546
882
  // Build request params
547
883
  let requestParams = {
548
884
  url,
549
885
  method: 'GET',
550
886
  headers,
551
- body
887
+ body,
888
+ signal: context.signal
552
889
  };
553
890
  // Apply beforeRequest hook
554
891
  if (config.hooks?.beforeRequest) {
@@ -556,7 +893,7 @@ async function listBusinesses(context = {}) {
556
893
  }
557
894
  try {
558
895
  // Execute request with retry logic
559
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
896
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
560
897
  // Apply afterResponse hook
561
898
  if (config.hooks?.afterResponse) {
562
899
  response = await config.hooks.afterResponse(response, requestParams);
@@ -609,14 +946,16 @@ async function createBusiness(context) {
609
946
  // Prepare body
610
947
  const payload = context.payload;
611
948
  const body = JSON.stringify(payload);
612
- // Determine request function
613
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
949
+ // Determine request function - a custom fetch is read only by the built-in
950
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
951
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
614
952
  // Build request params
615
953
  let requestParams = {
616
954
  url,
617
955
  method: 'POST',
618
956
  headers,
619
- body
957
+ body,
958
+ signal: context.signal
620
959
  };
621
960
  // Apply beforeRequest hook
622
961
  if (config.hooks?.beforeRequest) {
@@ -624,7 +963,7 @@ async function createBusiness(context) {
624
963
  }
625
964
  try {
626
965
  // Execute request with retry logic
627
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
966
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
628
967
  // Apply afterResponse hook
629
968
  if (config.hooks?.afterResponse) {
630
969
  response = await config.hooks.afterResponse(response, requestParams);
@@ -677,14 +1016,16 @@ async function getBusiness(context) {
677
1016
  url = authResult.url;
678
1017
  // Prepare body
679
1018
  const body = undefined;
680
- // Determine request function
681
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1019
+ // Determine request function - a custom fetch is read only by the built-in
1020
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1021
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
682
1022
  // Build request params
683
1023
  let requestParams = {
684
1024
  url,
685
1025
  method: 'GET',
686
1026
  headers,
687
- body
1027
+ body,
1028
+ signal: context.signal
688
1029
  };
689
1030
  // Apply beforeRequest hook
690
1031
  if (config.hooks?.beforeRequest) {
@@ -692,7 +1033,7 @@ async function getBusiness(context) {
692
1033
  }
693
1034
  try {
694
1035
  // Execute request with retry logic
695
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1036
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
696
1037
  // Apply afterResponse hook
697
1038
  if (config.hooks?.afterResponse) {
698
1039
  response = await config.hooks.afterResponse(response, requestParams);
@@ -746,14 +1087,16 @@ async function updateBusiness(context) {
746
1087
  // Prepare body
747
1088
  const payload = context.payload;
748
1089
  const body = JSON.stringify(payload);
749
- // Determine request function
750
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1090
+ // Determine request function - a custom fetch is read only by the built-in
1091
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1092
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
751
1093
  // Build request params
752
1094
  let requestParams = {
753
1095
  url,
754
1096
  method: 'PATCH',
755
1097
  headers,
756
- body
1098
+ body,
1099
+ signal: context.signal
757
1100
  };
758
1101
  // Apply beforeRequest hook
759
1102
  if (config.hooks?.beforeRequest) {
@@ -761,7 +1104,7 @@ async function updateBusiness(context) {
761
1104
  }
762
1105
  try {
763
1106
  // Execute request with retry logic
764
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1107
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
765
1108
  // Apply afterResponse hook
766
1109
  if (config.hooks?.afterResponse) {
767
1110
  response = await config.hooks.afterResponse(response, requestParams);
@@ -814,14 +1157,16 @@ async function getBusinessPdf(context) {
814
1157
  url = authResult.url;
815
1158
  // Prepare body
816
1159
  const body = undefined;
817
- // Determine request function
818
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1160
+ // Determine request function - a custom fetch is read only by the built-in
1161
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1162
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
819
1163
  // Build request params
820
1164
  let requestParams = {
821
1165
  url,
822
1166
  method: 'GET',
823
1167
  headers,
824
- body
1168
+ body,
1169
+ signal: context.signal
825
1170
  };
826
1171
  // Apply beforeRequest hook
827
1172
  if (config.hooks?.beforeRequest) {
@@ -829,7 +1174,7 @@ async function getBusinessPdf(context) {
829
1174
  }
830
1175
  try {
831
1176
  // Execute request with retry logic
832
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1177
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
833
1178
  // Apply afterResponse hook
834
1179
  if (config.hooks?.afterResponse) {
835
1180
  response = await config.hooks.afterResponse(response, requestParams);
@@ -883,14 +1228,16 @@ async function listOrders(context) {
883
1228
  url = authResult.url;
884
1229
  // Prepare body
885
1230
  const body = undefined;
886
- // Determine request function
887
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1231
+ // Determine request function - a custom fetch is read only by the built-in
1232
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1233
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
888
1234
  // Build request params
889
1235
  let requestParams = {
890
1236
  url,
891
1237
  method: 'GET',
892
1238
  headers,
893
- body
1239
+ body,
1240
+ signal: context.signal
894
1241
  };
895
1242
  // Apply beforeRequest hook
896
1243
  if (config.hooks?.beforeRequest) {
@@ -898,7 +1245,7 @@ async function listOrders(context) {
898
1245
  }
899
1246
  try {
900
1247
  // Execute request with retry logic
901
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1248
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
902
1249
  // Apply afterResponse hook
903
1250
  if (config.hooks?.afterResponse) {
904
1251
  response = await config.hooks.afterResponse(response, requestParams);
@@ -952,14 +1299,16 @@ async function createOrder(context) {
952
1299
  // Prepare body
953
1300
  const payload = context.payload;
954
1301
  const body = JSON.stringify(payload);
955
- // Determine request function
956
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1302
+ // Determine request function - a custom fetch is read only by the built-in
1303
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1304
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
957
1305
  // Build request params
958
1306
  let requestParams = {
959
1307
  url,
960
1308
  method: 'POST',
961
1309
  headers,
962
- body
1310
+ body,
1311
+ signal: context.signal
963
1312
  };
964
1313
  // Apply beforeRequest hook
965
1314
  if (config.hooks?.beforeRequest) {
@@ -967,7 +1316,7 @@ async function createOrder(context) {
967
1316
  }
968
1317
  try {
969
1318
  // Execute request with retry logic
970
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1319
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
971
1320
  // Apply afterResponse hook
972
1321
  if (config.hooks?.afterResponse) {
973
1322
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1020,14 +1369,16 @@ async function getOrder(context) {
1020
1369
  url = authResult.url;
1021
1370
  // Prepare body
1022
1371
  const body = undefined;
1023
- // Determine request function
1024
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1372
+ // Determine request function - a custom fetch is read only by the built-in
1373
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1374
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1025
1375
  // Build request params
1026
1376
  let requestParams = {
1027
1377
  url,
1028
1378
  method: 'GET',
1029
1379
  headers,
1030
- body
1380
+ body,
1381
+ signal: context.signal
1031
1382
  };
1032
1383
  // Apply beforeRequest hook
1033
1384
  if (config.hooks?.beforeRequest) {
@@ -1035,7 +1386,7 @@ async function getOrder(context) {
1035
1386
  }
1036
1387
  try {
1037
1388
  // Execute request with retry logic
1038
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1389
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1039
1390
  // Apply afterResponse hook
1040
1391
  if (config.hooks?.afterResponse) {
1041
1392
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1088,14 +1439,16 @@ async function getOrderById(context) {
1088
1439
  url = authResult.url;
1089
1440
  // Prepare body
1090
1441
  const body = undefined;
1091
- // Determine request function
1092
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1442
+ // Determine request function - a custom fetch is read only by the built-in
1443
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1444
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1093
1445
  // Build request params
1094
1446
  let requestParams = {
1095
1447
  url,
1096
1448
  method: 'GET',
1097
1449
  headers,
1098
- body
1450
+ body,
1451
+ signal: context.signal
1099
1452
  };
1100
1453
  // Apply beforeRequest hook
1101
1454
  if (config.hooks?.beforeRequest) {
@@ -1103,7 +1456,7 @@ async function getOrderById(context) {
1103
1456
  }
1104
1457
  try {
1105
1458
  // Execute request with retry logic
1106
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1459
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1107
1460
  // Apply afterResponse hook
1108
1461
  if (config.hooks?.afterResponse) {
1109
1462
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1157,14 +1510,16 @@ async function updateOrder(context) {
1157
1510
  // Prepare body
1158
1511
  const payload = context.payload;
1159
1512
  const body = JSON.stringify(payload);
1160
- // Determine request function
1161
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1513
+ // Determine request function - a custom fetch is read only by the built-in
1514
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1515
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1162
1516
  // Build request params
1163
1517
  let requestParams = {
1164
1518
  url,
1165
1519
  method: 'PUT',
1166
1520
  headers,
1167
- body
1521
+ body,
1522
+ signal: context.signal
1168
1523
  };
1169
1524
  // Apply beforeRequest hook
1170
1525
  if (config.hooks?.beforeRequest) {
@@ -1172,7 +1527,7 @@ async function updateOrder(context) {
1172
1527
  }
1173
1528
  try {
1174
1529
  // Execute request with retry logic
1175
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1530
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1176
1531
  // Apply afterResponse hook
1177
1532
  if (config.hooks?.afterResponse) {
1178
1533
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1225,14 +1580,16 @@ async function listBusinessBatches(context) {
1225
1580
  url = authResult.url;
1226
1581
  // Prepare body
1227
1582
  const body = undefined;
1228
- // Determine request function
1229
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1583
+ // Determine request function - a custom fetch is read only by the built-in
1584
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1585
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1230
1586
  // Build request params
1231
1587
  let requestParams = {
1232
1588
  url,
1233
1589
  method: 'GET',
1234
1590
  headers,
1235
- body
1591
+ body,
1592
+ signal: context.signal
1236
1593
  };
1237
1594
  // Apply beforeRequest hook
1238
1595
  if (config.hooks?.beforeRequest) {
@@ -1240,7 +1597,7 @@ async function listBusinessBatches(context) {
1240
1597
  }
1241
1598
  try {
1242
1599
  // Execute request with retry logic
1243
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1600
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1244
1601
  // Apply afterResponse hook
1245
1602
  if (config.hooks?.afterResponse) {
1246
1603
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1293,14 +1650,16 @@ async function createBusinessBatch(context) {
1293
1650
  // Prepare body
1294
1651
  const payload = context.payload;
1295
1652
  const body = JSON.stringify(payload);
1296
- // Determine request function
1297
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1653
+ // Determine request function - a custom fetch is read only by the built-in
1654
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1655
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1298
1656
  // Build request params
1299
1657
  let requestParams = {
1300
1658
  url,
1301
1659
  method: 'POST',
1302
1660
  headers,
1303
- body
1661
+ body,
1662
+ signal: context.signal
1304
1663
  };
1305
1664
  // Apply beforeRequest hook
1306
1665
  if (config.hooks?.beforeRequest) {
@@ -1308,7 +1667,7 @@ async function createBusinessBatch(context) {
1308
1667
  }
1309
1668
  try {
1310
1669
  // Execute request with retry logic
1311
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1670
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1312
1671
  // Apply afterResponse hook
1313
1672
  if (config.hooks?.afterResponse) {
1314
1673
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1361,14 +1720,16 @@ async function getBusinessBatch(context) {
1361
1720
  url = authResult.url;
1362
1721
  // Prepare body
1363
1722
  const body = undefined;
1364
- // Determine request function
1365
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1723
+ // Determine request function - a custom fetch is read only by the built-in
1724
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1725
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1366
1726
  // Build request params
1367
1727
  let requestParams = {
1368
1728
  url,
1369
1729
  method: 'GET',
1370
1730
  headers,
1371
- body
1731
+ body,
1732
+ signal: context.signal
1372
1733
  };
1373
1734
  // Apply beforeRequest hook
1374
1735
  if (config.hooks?.beforeRequest) {
@@ -1376,7 +1737,7 @@ async function getBusinessBatch(context) {
1376
1737
  }
1377
1738
  try {
1378
1739
  // Execute request with retry logic
1379
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1740
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1380
1741
  // Apply afterResponse hook
1381
1742
  if (config.hooks?.afterResponse) {
1382
1743
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1429,14 +1790,16 @@ async function getBusinessBatchCsv(context) {
1429
1790
  url = authResult.url;
1430
1791
  // Prepare body
1431
1792
  const body = undefined;
1432
- // Determine request function
1433
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1793
+ // Determine request function - a custom fetch is read only by the built-in
1794
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1795
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1434
1796
  // Build request params
1435
1797
  let requestParams = {
1436
1798
  url,
1437
1799
  method: 'GET',
1438
1800
  headers,
1439
- body
1801
+ body,
1802
+ signal: context.signal
1440
1803
  };
1441
1804
  // Apply beforeRequest hook
1442
1805
  if (config.hooks?.beforeRequest) {
@@ -1444,7 +1807,7 @@ async function getBusinessBatchCsv(context) {
1444
1807
  }
1445
1808
  try {
1446
1809
  // Execute request with retry logic
1447
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1810
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1448
1811
  // Apply afterResponse hook
1449
1812
  if (config.hooks?.afterResponse) {
1450
1813
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1497,14 +1860,16 @@ async function listSignals(context) {
1497
1860
  url = authResult.url;
1498
1861
  // Prepare body
1499
1862
  const body = undefined;
1500
- // Determine request function
1501
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1863
+ // Determine request function - a custom fetch is read only by the built-in
1864
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1865
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1502
1866
  // Build request params
1503
1867
  let requestParams = {
1504
1868
  url,
1505
1869
  method: 'GET',
1506
1870
  headers,
1507
- body
1871
+ body,
1872
+ signal: context.signal
1508
1873
  };
1509
1874
  // Apply beforeRequest hook
1510
1875
  if (config.hooks?.beforeRequest) {
@@ -1512,7 +1877,7 @@ async function listSignals(context) {
1512
1877
  }
1513
1878
  try {
1514
1879
  // Execute request with retry logic
1515
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1880
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1516
1881
  // Apply afterResponse hook
1517
1882
  if (config.hooks?.afterResponse) {
1518
1883
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1565,14 +1930,16 @@ async function createSignal(context) {
1565
1930
  // Prepare body
1566
1931
  const payload = context.payload;
1567
1932
  const body = JSON.stringify(payload);
1568
- // Determine request function
1569
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
1933
+ // Determine request function - a custom fetch is read only by the built-in
1934
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
1935
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1570
1936
  // Build request params
1571
1937
  let requestParams = {
1572
1938
  url,
1573
1939
  method: 'POST',
1574
1940
  headers,
1575
- body
1941
+ body,
1942
+ signal: context.signal
1576
1943
  };
1577
1944
  // Apply beforeRequest hook
1578
1945
  if (config.hooks?.beforeRequest) {
@@ -1580,7 +1947,7 @@ async function createSignal(context) {
1580
1947
  }
1581
1948
  try {
1582
1949
  // Execute request with retry logic
1583
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
1950
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1584
1951
  // Apply afterResponse hook
1585
1952
  if (config.hooks?.afterResponse) {
1586
1953
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1633,14 +2000,16 @@ async function getSignal(context) {
1633
2000
  url = authResult.url;
1634
2001
  // Prepare body
1635
2002
  const body = undefined;
1636
- // Determine request function
1637
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2003
+ // Determine request function - a custom fetch is read only by the built-in
2004
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2005
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1638
2006
  // Build request params
1639
2007
  let requestParams = {
1640
2008
  url,
1641
2009
  method: 'GET',
1642
2010
  headers,
1643
- body
2011
+ body,
2012
+ signal: context.signal
1644
2013
  };
1645
2014
  // Apply beforeRequest hook
1646
2015
  if (config.hooks?.beforeRequest) {
@@ -1648,7 +2017,7 @@ async function getSignal(context) {
1648
2017
  }
1649
2018
  try {
1650
2019
  // Execute request with retry logic
1651
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2020
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1652
2021
  // Apply afterResponse hook
1653
2022
  if (config.hooks?.afterResponse) {
1654
2023
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1701,14 +2070,16 @@ async function getBusinessMonitor(context) {
1701
2070
  url = authResult.url;
1702
2071
  // Prepare body
1703
2072
  const body = undefined;
1704
- // Determine request function
1705
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2073
+ // Determine request function - a custom fetch is read only by the built-in
2074
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2075
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1706
2076
  // Build request params
1707
2077
  let requestParams = {
1708
2078
  url,
1709
2079
  method: 'GET',
1710
2080
  headers,
1711
- body
2081
+ body,
2082
+ signal: context.signal
1712
2083
  };
1713
2084
  // Apply beforeRequest hook
1714
2085
  if (config.hooks?.beforeRequest) {
@@ -1716,7 +2087,7 @@ async function getBusinessMonitor(context) {
1716
2087
  }
1717
2088
  try {
1718
2089
  // Execute request with retry logic
1719
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2090
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1720
2091
  // Apply afterResponse hook
1721
2092
  if (config.hooks?.afterResponse) {
1722
2093
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1770,14 +2141,16 @@ async function createBusinessMonitor(context) {
1770
2141
  // Prepare body
1771
2142
  const payload = context.payload;
1772
2143
  const body = JSON.stringify(payload);
1773
- // Determine request function
1774
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2144
+ // Determine request function - a custom fetch is read only by the built-in
2145
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2146
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1775
2147
  // Build request params
1776
2148
  let requestParams = {
1777
2149
  url,
1778
2150
  method: 'POST',
1779
2151
  headers,
1780
- body
2152
+ body,
2153
+ signal: context.signal
1781
2154
  };
1782
2155
  // Apply beforeRequest hook
1783
2156
  if (config.hooks?.beforeRequest) {
@@ -1785,7 +2158,7 @@ async function createBusinessMonitor(context) {
1785
2158
  }
1786
2159
  try {
1787
2160
  // Execute request with retry logic
1788
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2161
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1789
2162
  // Apply afterResponse hook
1790
2163
  if (config.hooks?.afterResponse) {
1791
2164
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1839,14 +2212,16 @@ async function updateBusinessMonitor(context) {
1839
2212
  // Prepare body
1840
2213
  const payload = context.payload;
1841
2214
  const body = JSON.stringify(payload);
1842
- // Determine request function
1843
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2215
+ // Determine request function - a custom fetch is read only by the built-in
2216
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2217
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1844
2218
  // Build request params
1845
2219
  let requestParams = {
1846
2220
  url,
1847
2221
  method: 'PUT',
1848
2222
  headers,
1849
- body
2223
+ body,
2224
+ signal: context.signal
1850
2225
  };
1851
2226
  // Apply beforeRequest hook
1852
2227
  if (config.hooks?.beforeRequest) {
@@ -1854,7 +2229,7 @@ async function updateBusinessMonitor(context) {
1854
2229
  }
1855
2230
  try {
1856
2231
  // Execute request with retry logic
1857
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2232
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1858
2233
  // Apply afterResponse hook
1859
2234
  if (config.hooks?.afterResponse) {
1860
2235
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1907,14 +2282,16 @@ async function deleteBusinessMonitor(context) {
1907
2282
  url = authResult.url;
1908
2283
  // Prepare body
1909
2284
  const body = undefined;
1910
- // Determine request function
1911
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2285
+ // Determine request function - a custom fetch is read only by the built-in
2286
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2287
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1912
2288
  // Build request params
1913
2289
  let requestParams = {
1914
2290
  url,
1915
2291
  method: 'DELETE',
1916
2292
  headers,
1917
- body
2293
+ body,
2294
+ signal: context.signal
1918
2295
  };
1919
2296
  // Apply beforeRequest hook
1920
2297
  if (config.hooks?.beforeRequest) {
@@ -1922,7 +2299,7 @@ async function deleteBusinessMonitor(context) {
1922
2299
  }
1923
2300
  try {
1924
2301
  // Execute request with retry logic
1925
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2302
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1926
2303
  // Apply afterResponse hook
1927
2304
  if (config.hooks?.afterResponse) {
1928
2305
  response = await config.hooks.afterResponse(response, requestParams);
@@ -1976,14 +2353,16 @@ async function bulkDisableMonitors(context) {
1976
2353
  // Prepare body
1977
2354
  const payload = context.payload;
1978
2355
  const body = JSON.stringify(payload);
1979
- // Determine request function
1980
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2356
+ // Determine request function - a custom fetch is read only by the built-in
2357
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2358
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
1981
2359
  // Build request params
1982
2360
  let requestParams = {
1983
2361
  url,
1984
2362
  method: 'POST',
1985
2363
  headers,
1986
- body
2364
+ body,
2365
+ signal: context.signal
1987
2366
  };
1988
2367
  // Apply beforeRequest hook
1989
2368
  if (config.hooks?.beforeRequest) {
@@ -1991,7 +2370,7 @@ async function bulkDisableMonitors(context) {
1991
2370
  }
1992
2371
  try {
1993
2372
  // Execute request with retry logic
1994
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2373
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
1995
2374
  // Apply afterResponse hook
1996
2375
  if (config.hooks?.afterResponse) {
1997
2376
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2045,14 +2424,16 @@ async function listLiens(context) {
2045
2424
  url = authResult.url;
2046
2425
  // Prepare body
2047
2426
  const body = undefined;
2048
- // Determine request function
2049
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2427
+ // Determine request function - a custom fetch is read only by the built-in
2428
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2429
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2050
2430
  // Build request params
2051
2431
  let requestParams = {
2052
2432
  url,
2053
2433
  method: 'GET',
2054
2434
  headers,
2055
- body
2435
+ body,
2436
+ signal: context.signal
2056
2437
  };
2057
2438
  // Apply beforeRequest hook
2058
2439
  if (config.hooks?.beforeRequest) {
@@ -2060,7 +2441,7 @@ async function listLiens(context) {
2060
2441
  }
2061
2442
  try {
2062
2443
  // Execute request with retry logic
2063
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2444
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2064
2445
  // Apply afterResponse hook
2065
2446
  if (config.hooks?.afterResponse) {
2066
2447
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2114,14 +2495,16 @@ async function createLien(context) {
2114
2495
  // Prepare body
2115
2496
  const payload = context.payload;
2116
2497
  const body = JSON.stringify(payload);
2117
- // Determine request function
2118
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2498
+ // Determine request function - a custom fetch is read only by the built-in
2499
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2500
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2119
2501
  // Build request params
2120
2502
  let requestParams = {
2121
2503
  url,
2122
2504
  method: 'POST',
2123
2505
  headers,
2124
- body
2506
+ body,
2507
+ signal: context.signal
2125
2508
  };
2126
2509
  // Apply beforeRequest hook
2127
2510
  if (config.hooks?.beforeRequest) {
@@ -2129,7 +2512,7 @@ async function createLien(context) {
2129
2512
  }
2130
2513
  try {
2131
2514
  // Execute request with retry logic
2132
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2515
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2133
2516
  // Apply afterResponse hook
2134
2517
  if (config.hooks?.afterResponse) {
2135
2518
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2183,14 +2566,16 @@ async function createLienFilingsInBatch(context) {
2183
2566
  // Prepare body
2184
2567
  const payload = context.payload;
2185
2568
  const body = JSON.stringify(payload);
2186
- // Determine request function
2187
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2569
+ // Determine request function - a custom fetch is read only by the built-in
2570
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2571
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2188
2572
  // Build request params
2189
2573
  let requestParams = {
2190
2574
  url,
2191
2575
  method: 'POST',
2192
2576
  headers,
2193
- body
2577
+ body,
2578
+ signal: context.signal
2194
2579
  };
2195
2580
  // Apply beforeRequest hook
2196
2581
  if (config.hooks?.beforeRequest) {
@@ -2198,7 +2583,7 @@ async function createLienFilingsInBatch(context) {
2198
2583
  }
2199
2584
  try {
2200
2585
  // Execute request with retry logic
2201
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2586
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2202
2587
  // Apply afterResponse hook
2203
2588
  if (config.hooks?.afterResponse) {
2204
2589
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2252,14 +2637,16 @@ async function createRegistration(context) {
2252
2637
  // Prepare body
2253
2638
  const payload = context.payload;
2254
2639
  const body = JSON.stringify(payload);
2255
- // Determine request function
2256
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2640
+ // Determine request function - a custom fetch is read only by the built-in
2641
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2642
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2257
2643
  // Build request params
2258
2644
  let requestParams = {
2259
2645
  url,
2260
2646
  method: 'POST',
2261
2647
  headers,
2262
- body
2648
+ body,
2649
+ signal: context.signal
2263
2650
  };
2264
2651
  // Apply beforeRequest hook
2265
2652
  if (config.hooks?.beforeRequest) {
@@ -2267,7 +2654,7 @@ async function createRegistration(context) {
2267
2654
  }
2268
2655
  try {
2269
2656
  // Execute request with retry logic
2270
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2657
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2271
2658
  // Apply afterResponse hook
2272
2659
  if (config.hooks?.afterResponse) {
2273
2660
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2321,14 +2708,16 @@ async function createLienTermination(context) {
2321
2708
  // Prepare body
2322
2709
  const payload = context.payload;
2323
2710
  const body = JSON.stringify(payload);
2324
- // Determine request function
2325
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2711
+ // Determine request function - a custom fetch is read only by the built-in
2712
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2713
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2326
2714
  // Build request params
2327
2715
  let requestParams = {
2328
2716
  url,
2329
2717
  method: 'POST',
2330
2718
  headers,
2331
- body
2719
+ body,
2720
+ signal: context.signal
2332
2721
  };
2333
2722
  // Apply beforeRequest hook
2334
2723
  if (config.hooks?.beforeRequest) {
@@ -2336,7 +2725,7 @@ async function createLienTermination(context) {
2336
2725
  }
2337
2726
  try {
2338
2727
  // Execute request with retry logic
2339
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2728
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2340
2729
  // Apply afterResponse hook
2341
2730
  if (config.hooks?.afterResponse) {
2342
2731
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2389,14 +2778,16 @@ async function listBusinessPolicyResults(context) {
2389
2778
  url = authResult.url;
2390
2779
  // Prepare body
2391
2780
  const body = undefined;
2392
- // Determine request function
2393
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2781
+ // Determine request function - a custom fetch is read only by the built-in
2782
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2783
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2394
2784
  // Build request params
2395
2785
  let requestParams = {
2396
2786
  url,
2397
2787
  method: 'GET',
2398
2788
  headers,
2399
- body
2789
+ body,
2790
+ signal: context.signal
2400
2791
  };
2401
2792
  // Apply beforeRequest hook
2402
2793
  if (config.hooks?.beforeRequest) {
@@ -2404,7 +2795,7 @@ async function listBusinessPolicyResults(context) {
2404
2795
  }
2405
2796
  try {
2406
2797
  // Execute request with retry logic
2407
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2798
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2408
2799
  // Apply afterResponse hook
2409
2800
  if (config.hooks?.afterResponse) {
2410
2801
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2457,14 +2848,16 @@ async function getBusinessReview(context) {
2457
2848
  url = authResult.url;
2458
2849
  // Prepare body
2459
2850
  const body = undefined;
2460
- // Determine request function
2461
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2851
+ // Determine request function - a custom fetch is read only by the built-in
2852
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2853
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2462
2854
  // Build request params
2463
2855
  let requestParams = {
2464
2856
  url,
2465
2857
  method: 'GET',
2466
2858
  headers,
2467
- body
2859
+ body,
2860
+ signal: context.signal
2468
2861
  };
2469
2862
  // Apply beforeRequest hook
2470
2863
  if (config.hooks?.beforeRequest) {
@@ -2472,7 +2865,7 @@ async function getBusinessReview(context) {
2472
2865
  }
2473
2866
  try {
2474
2867
  // Execute request with retry logic
2475
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2868
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2476
2869
  // Apply afterResponse hook
2477
2870
  if (config.hooks?.afterResponse) {
2478
2871
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2525,14 +2918,16 @@ async function listActions(context) {
2525
2918
  url = authResult.url;
2526
2919
  // Prepare body
2527
2920
  const body = undefined;
2528
- // Determine request function
2529
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2921
+ // Determine request function - a custom fetch is read only by the built-in
2922
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2923
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2530
2924
  // Build request params
2531
2925
  let requestParams = {
2532
2926
  url,
2533
2927
  method: 'GET',
2534
2928
  headers,
2535
- body
2929
+ body,
2930
+ signal: context.signal
2536
2931
  };
2537
2932
  // Apply beforeRequest hook
2538
2933
  if (config.hooks?.beforeRequest) {
@@ -2540,7 +2935,7 @@ async function listActions(context) {
2540
2935
  }
2541
2936
  try {
2542
2937
  // Execute request with retry logic
2543
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
2938
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2544
2939
  // Apply afterResponse hook
2545
2940
  if (config.hooks?.afterResponse) {
2546
2941
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2593,14 +2988,16 @@ async function createAction(context) {
2593
2988
  // Prepare body
2594
2989
  const payload = context.payload;
2595
2990
  const body = JSON.stringify(payload);
2596
- // Determine request function
2597
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
2991
+ // Determine request function - a custom fetch is read only by the built-in
2992
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
2993
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2598
2994
  // Build request params
2599
2995
  let requestParams = {
2600
2996
  url,
2601
2997
  method: 'POST',
2602
2998
  headers,
2603
- body
2999
+ body,
3000
+ signal: context.signal
2604
3001
  };
2605
3002
  // Apply beforeRequest hook
2606
3003
  if (config.hooks?.beforeRequest) {
@@ -2608,7 +3005,7 @@ async function createAction(context) {
2608
3005
  }
2609
3006
  try {
2610
3007
  // Execute request with retry logic
2611
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3008
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2612
3009
  // Apply afterResponse hook
2613
3010
  if (config.hooks?.afterResponse) {
2614
3011
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2661,14 +3058,16 @@ async function getAction(context) {
2661
3058
  url = authResult.url;
2662
3059
  // Prepare body
2663
3060
  const body = undefined;
2664
- // Determine request function
2665
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3061
+ // Determine request function - a custom fetch is read only by the built-in
3062
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3063
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2666
3064
  // Build request params
2667
3065
  let requestParams = {
2668
3066
  url,
2669
3067
  method: 'GET',
2670
3068
  headers,
2671
- body
3069
+ body,
3070
+ signal: context.signal
2672
3071
  };
2673
3072
  // Apply beforeRequest hook
2674
3073
  if (config.hooks?.beforeRequest) {
@@ -2676,7 +3075,7 @@ async function getAction(context) {
2676
3075
  }
2677
3076
  try {
2678
3077
  // Execute request with retry logic
2679
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3078
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2680
3079
  // Apply afterResponse hook
2681
3080
  if (config.hooks?.afterResponse) {
2682
3081
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2728,14 +3127,16 @@ async function getTinMatchAvailability(context = {}) {
2728
3127
  url = authResult.url;
2729
3128
  // Prepare body
2730
3129
  const body = undefined;
2731
- // Determine request function
2732
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3130
+ // Determine request function - a custom fetch is read only by the built-in
3131
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3132
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2733
3133
  // Build request params
2734
3134
  let requestParams = {
2735
3135
  url,
2736
3136
  method: 'GET',
2737
3137
  headers,
2738
- body
3138
+ body,
3139
+ signal: context.signal
2739
3140
  };
2740
3141
  // Apply beforeRequest hook
2741
3142
  if (config.hooks?.beforeRequest) {
@@ -2743,7 +3144,7 @@ async function getTinMatchAvailability(context = {}) {
2743
3144
  }
2744
3145
  try {
2745
3146
  // Execute request with retry logic
2746
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3147
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2747
3148
  // Apply afterResponse hook
2748
3149
  if (config.hooks?.afterResponse) {
2749
3150
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2796,14 +3197,16 @@ async function getBusinessWebsite(context) {
2796
3197
  url = authResult.url;
2797
3198
  // Prepare body
2798
3199
  const body = undefined;
2799
- // Determine request function
2800
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3200
+ // Determine request function - a custom fetch is read only by the built-in
3201
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3202
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2801
3203
  // Build request params
2802
3204
  let requestParams = {
2803
3205
  url,
2804
3206
  method: 'GET',
2805
3207
  headers,
2806
- body
3208
+ body,
3209
+ signal: context.signal
2807
3210
  };
2808
3211
  // Apply beforeRequest hook
2809
3212
  if (config.hooks?.beforeRequest) {
@@ -2811,7 +3214,7 @@ async function getBusinessWebsite(context) {
2811
3214
  }
2812
3215
  try {
2813
3216
  // Execute request with retry logic
2814
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3217
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2815
3218
  // Apply afterResponse hook
2816
3219
  if (config.hooks?.afterResponse) {
2817
3220
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2864,14 +3267,16 @@ async function listConnections(context) {
2864
3267
  url = authResult.url;
2865
3268
  // Prepare body
2866
3269
  const body = undefined;
2867
- // Determine request function
2868
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3270
+ // Determine request function - a custom fetch is read only by the built-in
3271
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3272
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2869
3273
  // Build request params
2870
3274
  let requestParams = {
2871
3275
  url,
2872
3276
  method: 'GET',
2873
3277
  headers,
2874
- body
3278
+ body,
3279
+ signal: context.signal
2875
3280
  };
2876
3281
  // Apply beforeRequest hook
2877
3282
  if (config.hooks?.beforeRequest) {
@@ -2879,7 +3284,7 @@ async function listConnections(context) {
2879
3284
  }
2880
3285
  try {
2881
3286
  // Execute request with retry logic
2882
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3287
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2883
3288
  // Apply afterResponse hook
2884
3289
  if (config.hooks?.afterResponse) {
2885
3290
  response = await config.hooks.afterResponse(response, requestParams);
@@ -2934,14 +3339,16 @@ async function getBusinessTimeline(context) {
2934
3339
  url = authResult.url;
2935
3340
  // Prepare body
2936
3341
  const body = undefined;
2937
- // Determine request function
2938
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3342
+ // Determine request function - a custom fetch is read only by the built-in
3343
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3344
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
2939
3345
  // Build request params
2940
3346
  let requestParams = {
2941
3347
  url,
2942
3348
  method: 'GET',
2943
3349
  headers,
2944
- body
3350
+ body,
3351
+ signal: context.signal
2945
3352
  };
2946
3353
  // Apply beforeRequest hook
2947
3354
  if (config.hooks?.beforeRequest) {
@@ -2949,7 +3356,7 @@ async function getBusinessTimeline(context) {
2949
3356
  }
2950
3357
  try {
2951
3358
  // Execute request with retry logic
2952
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3359
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
2953
3360
  // Apply afterResponse hook
2954
3361
  if (config.hooks?.afterResponse) {
2955
3362
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3002,14 +3409,16 @@ async function listRegistrationRequests(context) {
3002
3409
  url = authResult.url;
3003
3410
  // Prepare body
3004
3411
  const body = undefined;
3005
- // Determine request function
3006
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3412
+ // Determine request function - a custom fetch is read only by the built-in
3413
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3414
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3007
3415
  // Build request params
3008
3416
  let requestParams = {
3009
3417
  url,
3010
3418
  method: 'GET',
3011
3419
  headers,
3012
- body
3420
+ body,
3421
+ signal: context.signal
3013
3422
  };
3014
3423
  // Apply beforeRequest hook
3015
3424
  if (config.hooks?.beforeRequest) {
@@ -3017,7 +3426,7 @@ async function listRegistrationRequests(context) {
3017
3426
  }
3018
3427
  try {
3019
3428
  // Execute request with retry logic
3020
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3429
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3021
3430
  // Apply afterResponse hook
3022
3431
  if (config.hooks?.afterResponse) {
3023
3432
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3070,14 +3479,16 @@ async function createRegistrationRequest(context) {
3070
3479
  // Prepare body
3071
3480
  const payload = context.payload;
3072
3481
  const body = JSON.stringify(payload);
3073
- // Determine request function
3074
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3482
+ // Determine request function - a custom fetch is read only by the built-in
3483
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3484
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3075
3485
  // Build request params
3076
3486
  let requestParams = {
3077
3487
  url,
3078
3488
  method: 'POST',
3079
3489
  headers,
3080
- body
3490
+ body,
3491
+ signal: context.signal
3081
3492
  };
3082
3493
  // Apply beforeRequest hook
3083
3494
  if (config.hooks?.beforeRequest) {
@@ -3085,7 +3496,7 @@ async function createRegistrationRequest(context) {
3085
3496
  }
3086
3497
  try {
3087
3498
  // Execute request with retry logic
3088
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3499
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3089
3500
  // Apply afterResponse hook
3090
3501
  if (config.hooks?.afterResponse) {
3091
3502
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3138,14 +3549,16 @@ async function getRegistrationRequest(context) {
3138
3549
  url = authResult.url;
3139
3550
  // Prepare body
3140
3551
  const body = undefined;
3141
- // Determine request function
3142
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3552
+ // Determine request function - a custom fetch is read only by the built-in
3553
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3554
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3143
3555
  // Build request params
3144
3556
  let requestParams = {
3145
3557
  url,
3146
3558
  method: 'GET',
3147
3559
  headers,
3148
- body
3560
+ body,
3561
+ signal: context.signal
3149
3562
  };
3150
3563
  // Apply beforeRequest hook
3151
3564
  if (config.hooks?.beforeRequest) {
@@ -3153,7 +3566,7 @@ async function getRegistrationRequest(context) {
3153
3566
  }
3154
3567
  try {
3155
3568
  // Execute request with retry logic
3156
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3569
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3157
3570
  // Apply afterResponse hook
3158
3571
  if (config.hooks?.afterResponse) {
3159
3572
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3206,14 +3619,16 @@ async function deleteRegistrationRequest(context) {
3206
3619
  url = authResult.url;
3207
3620
  // Prepare body
3208
3621
  const body = undefined;
3209
- // Determine request function
3210
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3622
+ // Determine request function - a custom fetch is read only by the built-in
3623
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3624
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3211
3625
  // Build request params
3212
3626
  let requestParams = {
3213
3627
  url,
3214
3628
  method: 'DELETE',
3215
3629
  headers,
3216
- body
3630
+ body,
3631
+ signal: context.signal
3217
3632
  };
3218
3633
  // Apply beforeRequest hook
3219
3634
  if (config.hooks?.beforeRequest) {
@@ -3221,7 +3636,7 @@ async function deleteRegistrationRequest(context) {
3221
3636
  }
3222
3637
  try {
3223
3638
  // Execute request with retry logic
3224
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3639
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3225
3640
  // Apply afterResponse hook
3226
3641
  if (config.hooks?.afterResponse) {
3227
3642
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3275,14 +3690,16 @@ async function getRegistrationRequestGuestDashboard(context) {
3275
3690
  url = authResult.url;
3276
3691
  // Prepare body
3277
3692
  const body = undefined;
3278
- // Determine request function
3279
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3693
+ // Determine request function - a custom fetch is read only by the built-in
3694
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3695
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3280
3696
  // Build request params
3281
3697
  let requestParams = {
3282
3698
  url,
3283
3699
  method: 'GET',
3284
3700
  headers,
3285
- body
3701
+ body,
3702
+ signal: context.signal
3286
3703
  };
3287
3704
  // Apply beforeRequest hook
3288
3705
  if (config.hooks?.beforeRequest) {
@@ -3290,7 +3707,7 @@ async function getRegistrationRequestGuestDashboard(context) {
3290
3707
  }
3291
3708
  try {
3292
3709
  // Execute request with retry logic
3293
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3710
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3294
3711
  // Apply afterResponse hook
3295
3712
  if (config.hooks?.afterResponse) {
3296
3713
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3343,14 +3760,16 @@ async function listInformationRequests(context) {
3343
3760
  url = authResult.url;
3344
3761
  // Prepare body
3345
3762
  const body = undefined;
3346
- // Determine request function
3347
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3763
+ // Determine request function - a custom fetch is read only by the built-in
3764
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3765
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3348
3766
  // Build request params
3349
3767
  let requestParams = {
3350
3768
  url,
3351
3769
  method: 'GET',
3352
3770
  headers,
3353
- body
3771
+ body,
3772
+ signal: context.signal
3354
3773
  };
3355
3774
  // Apply beforeRequest hook
3356
3775
  if (config.hooks?.beforeRequest) {
@@ -3358,7 +3777,7 @@ async function listInformationRequests(context) {
3358
3777
  }
3359
3778
  try {
3360
3779
  // Execute request with retry logic
3361
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3780
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3362
3781
  // Apply afterResponse hook
3363
3782
  if (config.hooks?.afterResponse) {
3364
3783
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3411,14 +3830,16 @@ async function createApplication(context) {
3411
3830
  // Prepare body
3412
3831
  const payload = context.payload;
3413
3832
  const body = JSON.stringify(payload);
3414
- // Determine request function
3415
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3833
+ // Determine request function - a custom fetch is read only by the built-in
3834
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3835
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3416
3836
  // Build request params
3417
3837
  let requestParams = {
3418
3838
  url,
3419
3839
  method: 'POST',
3420
3840
  headers,
3421
- body
3841
+ body,
3842
+ signal: context.signal
3422
3843
  };
3423
3844
  // Apply beforeRequest hook
3424
3845
  if (config.hooks?.beforeRequest) {
@@ -3426,7 +3847,7 @@ async function createApplication(context) {
3426
3847
  }
3427
3848
  try {
3428
3849
  // Execute request with retry logic
3429
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3850
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3430
3851
  // Apply afterResponse hook
3431
3852
  if (config.hooks?.afterResponse) {
3432
3853
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3479,14 +3900,16 @@ async function createCompany(context) {
3479
3900
  // Prepare body
3480
3901
  const payload = context.payload;
3481
3902
  const body = JSON.stringify(payload);
3482
- // Determine request function
3483
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3903
+ // Determine request function - a custom fetch is read only by the built-in
3904
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3905
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3484
3906
  // Build request params
3485
3907
  let requestParams = {
3486
3908
  url,
3487
3909
  method: 'POST',
3488
3910
  headers,
3489
- body
3911
+ body,
3912
+ signal: context.signal
3490
3913
  };
3491
3914
  // Apply beforeRequest hook
3492
3915
  if (config.hooks?.beforeRequest) {
@@ -3494,7 +3917,7 @@ async function createCompany(context) {
3494
3917
  }
3495
3918
  try {
3496
3919
  // Execute request with retry logic
3497
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3920
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3498
3921
  // Apply afterResponse hook
3499
3922
  if (config.hooks?.afterResponse) {
3500
3923
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3547,14 +3970,16 @@ async function searchJurisdictions(context) {
3547
3970
  url = authResult.url;
3548
3971
  // Prepare body
3549
3972
  const body = undefined;
3550
- // Determine request function
3551
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
3973
+ // Determine request function - a custom fetch is read only by the built-in
3974
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
3975
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3552
3976
  // Build request params
3553
3977
  let requestParams = {
3554
3978
  url,
3555
3979
  method: 'GET',
3556
3980
  headers,
3557
- body
3981
+ body,
3982
+ signal: context.signal
3558
3983
  };
3559
3984
  // Apply beforeRequest hook
3560
3985
  if (config.hooks?.beforeRequest) {
@@ -3562,7 +3987,7 @@ async function searchJurisdictions(context) {
3562
3987
  }
3563
3988
  try {
3564
3989
  // Execute request with retry logic
3565
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
3990
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3566
3991
  // Apply afterResponse hook
3567
3992
  if (config.hooks?.afterResponse) {
3568
3993
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3615,14 +4040,16 @@ async function listJurisdictions(context) {
3615
4040
  url = authResult.url;
3616
4041
  // Prepare body
3617
4042
  const body = undefined;
3618
- // Determine request function
3619
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4043
+ // Determine request function - a custom fetch is read only by the built-in
4044
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4045
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3620
4046
  // Build request params
3621
4047
  let requestParams = {
3622
4048
  url,
3623
4049
  method: 'GET',
3624
4050
  headers,
3625
- body
4051
+ body,
4052
+ signal: context.signal
3626
4053
  };
3627
4054
  // Apply beforeRequest hook
3628
4055
  if (config.hooks?.beforeRequest) {
@@ -3630,7 +4057,7 @@ async function listJurisdictions(context) {
3630
4057
  }
3631
4058
  try {
3632
4059
  // Execute request with retry logic
3633
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4060
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3634
4061
  // Apply afterResponse hook
3635
4062
  if (config.hooks?.afterResponse) {
3636
4063
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3683,14 +4110,16 @@ async function listQuestions(context) {
3683
4110
  url = authResult.url;
3684
4111
  // Prepare body
3685
4112
  const body = undefined;
3686
- // Determine request function
3687
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4113
+ // Determine request function - a custom fetch is read only by the built-in
4114
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4115
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3688
4116
  // Build request params
3689
4117
  let requestParams = {
3690
4118
  url,
3691
4119
  method: 'GET',
3692
4120
  headers,
3693
- body
4121
+ body,
4122
+ signal: context.signal
3694
4123
  };
3695
4124
  // Apply beforeRequest hook
3696
4125
  if (config.hooks?.beforeRequest) {
@@ -3698,7 +4127,7 @@ async function listQuestions(context) {
3698
4127
  }
3699
4128
  try {
3700
4129
  // Execute request with retry logic
3701
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4130
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3702
4131
  // Apply afterResponse hook
3703
4132
  if (config.hooks?.afterResponse) {
3704
4133
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3751,14 +4180,16 @@ async function listMailItems(context) {
3751
4180
  url = authResult.url;
3752
4181
  // Prepare body
3753
4182
  const body = undefined;
3754
- // Determine request function
3755
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4183
+ // Determine request function - a custom fetch is read only by the built-in
4184
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4185
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3756
4186
  // Build request params
3757
4187
  let requestParams = {
3758
4188
  url,
3759
4189
  method: 'GET',
3760
4190
  headers,
3761
- body
4191
+ body,
4192
+ signal: context.signal
3762
4193
  };
3763
4194
  // Apply beforeRequest hook
3764
4195
  if (config.hooks?.beforeRequest) {
@@ -3766,7 +4197,7 @@ async function listMailItems(context) {
3766
4197
  }
3767
4198
  try {
3768
4199
  // Execute request with retry logic
3769
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4200
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3770
4201
  // Apply afterResponse hook
3771
4202
  if (config.hooks?.afterResponse) {
3772
4203
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3819,14 +4250,16 @@ async function getMailItem(context) {
3819
4250
  url = authResult.url;
3820
4251
  // Prepare body
3821
4252
  const body = undefined;
3822
- // Determine request function
3823
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4253
+ // Determine request function - a custom fetch is read only by the built-in
4254
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4255
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3824
4256
  // Build request params
3825
4257
  let requestParams = {
3826
4258
  url,
3827
4259
  method: 'GET',
3828
4260
  headers,
3829
- body
4261
+ body,
4262
+ signal: context.signal
3830
4263
  };
3831
4264
  // Apply beforeRequest hook
3832
4265
  if (config.hooks?.beforeRequest) {
@@ -3834,7 +4267,7 @@ async function getMailItem(context) {
3834
4267
  }
3835
4268
  try {
3836
4269
  // Execute request with retry logic
3837
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4270
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3838
4271
  // Apply afterResponse hook
3839
4272
  if (config.hooks?.afterResponse) {
3840
4273
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3889,14 +4322,16 @@ async function updateMailItem(context) {
3889
4322
  // Prepare body
3890
4323
  const payload = context.payload;
3891
4324
  const body = JSON.stringify(payload);
3892
- // Determine request function
3893
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4325
+ // Determine request function - a custom fetch is read only by the built-in
4326
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4327
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3894
4328
  // Build request params
3895
4329
  let requestParams = {
3896
4330
  url,
3897
4331
  method: 'PATCH',
3898
4332
  headers,
3899
- body
4333
+ body,
4334
+ signal: context.signal
3900
4335
  };
3901
4336
  // Apply beforeRequest hook
3902
4337
  if (config.hooks?.beforeRequest) {
@@ -3904,7 +4339,7 @@ async function updateMailItem(context) {
3904
4339
  }
3905
4340
  try {
3906
4341
  // Execute request with retry logic
3907
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4342
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3908
4343
  // Apply afterResponse hook
3909
4344
  if (config.hooks?.afterResponse) {
3910
4345
  response = await config.hooks.afterResponse(response, requestParams);
@@ -3957,14 +4392,16 @@ async function listAgents(context = {}) {
3957
4392
  url = authResult.url;
3958
4393
  // Prepare body
3959
4394
  const body = undefined;
3960
- // Determine request function
3961
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4395
+ // Determine request function - a custom fetch is read only by the built-in
4396
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4397
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
3962
4398
  // Build request params
3963
4399
  let requestParams = {
3964
4400
  url,
3965
4401
  method: 'GET',
3966
4402
  headers,
3967
- body
4403
+ body,
4404
+ signal: context.signal
3968
4405
  };
3969
4406
  // Apply beforeRequest hook
3970
4407
  if (config.hooks?.beforeRequest) {
@@ -3972,7 +4409,7 @@ async function listAgents(context = {}) {
3972
4409
  }
3973
4410
  try {
3974
4411
  // Execute request with retry logic
3975
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4412
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
3976
4413
  // Apply afterResponse hook
3977
4414
  if (config.hooks?.afterResponse) {
3978
4415
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4025,14 +4462,16 @@ async function getAgent(context) {
4025
4462
  url = authResult.url;
4026
4463
  // Prepare body
4027
4464
  const body = undefined;
4028
- // Determine request function
4029
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4465
+ // Determine request function - a custom fetch is read only by the built-in
4466
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4467
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4030
4468
  // Build request params
4031
4469
  let requestParams = {
4032
4470
  url,
4033
4471
  method: 'GET',
4034
4472
  headers,
4035
- body
4473
+ body,
4474
+ signal: context.signal
4036
4475
  };
4037
4476
  // Apply beforeRequest hook
4038
4477
  if (config.hooks?.beforeRequest) {
@@ -4040,7 +4479,7 @@ async function getAgent(context) {
4040
4479
  }
4041
4480
  try {
4042
4481
  // Execute request with retry logic
4043
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4482
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4044
4483
  // Apply afterResponse hook
4045
4484
  if (config.hooks?.afterResponse) {
4046
4485
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4093,14 +4532,16 @@ async function listAgentThreads(context) {
4093
4532
  url = authResult.url;
4094
4533
  // Prepare body
4095
4534
  const body = undefined;
4096
- // Determine request function
4097
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4535
+ // Determine request function - a custom fetch is read only by the built-in
4536
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4537
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4098
4538
  // Build request params
4099
4539
  let requestParams = {
4100
4540
  url,
4101
4541
  method: 'GET',
4102
4542
  headers,
4103
- body
4543
+ body,
4544
+ signal: context.signal
4104
4545
  };
4105
4546
  // Apply beforeRequest hook
4106
4547
  if (config.hooks?.beforeRequest) {
@@ -4108,7 +4549,7 @@ async function listAgentThreads(context) {
4108
4549
  }
4109
4550
  try {
4110
4551
  // Execute request with retry logic
4111
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4552
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4112
4553
  // Apply afterResponse hook
4113
4554
  if (config.hooks?.afterResponse) {
4114
4555
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4161,14 +4602,16 @@ async function createAgentThread(context) {
4161
4602
  // Prepare body
4162
4603
  const payload = context.payload;
4163
4604
  const body = JSON.stringify(payload);
4164
- // Determine request function
4165
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4605
+ // Determine request function - a custom fetch is read only by the built-in
4606
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4607
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4166
4608
  // Build request params
4167
4609
  let requestParams = {
4168
4610
  url,
4169
4611
  method: 'POST',
4170
4612
  headers,
4171
- body
4613
+ body,
4614
+ signal: context.signal
4172
4615
  };
4173
4616
  // Apply beforeRequest hook
4174
4617
  if (config.hooks?.beforeRequest) {
@@ -4176,7 +4619,7 @@ async function createAgentThread(context) {
4176
4619
  }
4177
4620
  try {
4178
4621
  // Execute request with retry logic
4179
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4622
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4180
4623
  // Apply afterResponse hook
4181
4624
  if (config.hooks?.afterResponse) {
4182
4625
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4229,14 +4672,16 @@ async function getAgentThread(context) {
4229
4672
  url = authResult.url;
4230
4673
  // Prepare body
4231
4674
  const body = undefined;
4232
- // Determine request function
4233
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4675
+ // Determine request function - a custom fetch is read only by the built-in
4676
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4677
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4234
4678
  // Build request params
4235
4679
  let requestParams = {
4236
4680
  url,
4237
4681
  method: 'GET',
4238
4682
  headers,
4239
- body
4683
+ body,
4684
+ signal: context.signal
4240
4685
  };
4241
4686
  // Apply beforeRequest hook
4242
4687
  if (config.hooks?.beforeRequest) {
@@ -4244,7 +4689,7 @@ async function getAgentThread(context) {
4244
4689
  }
4245
4690
  try {
4246
4691
  // Execute request with retry logic
4247
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4692
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4248
4693
  // Apply afterResponse hook
4249
4694
  if (config.hooks?.afterResponse) {
4250
4695
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4297,14 +4742,16 @@ async function listAgentRuns(context) {
4297
4742
  url = authResult.url;
4298
4743
  // Prepare body
4299
4744
  const body = undefined;
4300
- // Determine request function
4301
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4745
+ // Determine request function - a custom fetch is read only by the built-in
4746
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4747
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4302
4748
  // Build request params
4303
4749
  let requestParams = {
4304
4750
  url,
4305
4751
  method: 'GET',
4306
4752
  headers,
4307
- body
4753
+ body,
4754
+ signal: context.signal
4308
4755
  };
4309
4756
  // Apply beforeRequest hook
4310
4757
  if (config.hooks?.beforeRequest) {
@@ -4312,7 +4759,7 @@ async function listAgentRuns(context) {
4312
4759
  }
4313
4760
  try {
4314
4761
  // Execute request with retry logic
4315
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4762
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4316
4763
  // Apply afterResponse hook
4317
4764
  if (config.hooks?.afterResponse) {
4318
4765
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4365,14 +4812,16 @@ async function createAgentRun(context) {
4365
4812
  // Prepare body
4366
4813
  const payload = context.payload;
4367
4814
  const body = JSON.stringify(payload);
4368
- // Determine request function
4369
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4815
+ // Determine request function - a custom fetch is read only by the built-in
4816
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4817
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4370
4818
  // Build request params
4371
4819
  let requestParams = {
4372
4820
  url,
4373
4821
  method: 'POST',
4374
4822
  headers,
4375
- body
4823
+ body,
4824
+ signal: context.signal
4376
4825
  };
4377
4826
  // Apply beforeRequest hook
4378
4827
  if (config.hooks?.beforeRequest) {
@@ -4380,7 +4829,7 @@ async function createAgentRun(context) {
4380
4829
  }
4381
4830
  try {
4382
4831
  // Execute request with retry logic
4383
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4832
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4384
4833
  // Apply afterResponse hook
4385
4834
  if (config.hooks?.afterResponse) {
4386
4835
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4433,14 +4882,16 @@ async function getAgentRun(context) {
4433
4882
  url = authResult.url;
4434
4883
  // Prepare body
4435
4884
  const body = undefined;
4436
- // Determine request function
4437
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4885
+ // Determine request function - a custom fetch is read only by the built-in
4886
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4887
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4438
4888
  // Build request params
4439
4889
  let requestParams = {
4440
4890
  url,
4441
4891
  method: 'GET',
4442
4892
  headers,
4443
- body
4893
+ body,
4894
+ signal: context.signal
4444
4895
  };
4445
4896
  // Apply beforeRequest hook
4446
4897
  if (config.hooks?.beforeRequest) {
@@ -4448,7 +4899,7 @@ async function getAgentRun(context) {
4448
4899
  }
4449
4900
  try {
4450
4901
  // Execute request with retry logic
4451
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4902
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4452
4903
  // Apply afterResponse hook
4453
4904
  if (config.hooks?.afterResponse) {
4454
4905
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4502,14 +4953,16 @@ async function submitAgentRunFeedback(context) {
4502
4953
  // Prepare body
4503
4954
  const payload = context.payload;
4504
4955
  const body = JSON.stringify(payload);
4505
- // Determine request function
4506
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
4956
+ // Determine request function - a custom fetch is read only by the built-in
4957
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
4958
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4507
4959
  // Build request params
4508
4960
  let requestParams = {
4509
4961
  url,
4510
4962
  method: 'POST',
4511
4963
  headers,
4512
- body
4964
+ body,
4965
+ signal: context.signal
4513
4966
  };
4514
4967
  // Apply beforeRequest hook
4515
4968
  if (config.hooks?.beforeRequest) {
@@ -4517,7 +4970,7 @@ async function submitAgentRunFeedback(context) {
4517
4970
  }
4518
4971
  try {
4519
4972
  // Execute request with retry logic
4520
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
4973
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4521
4974
  // Apply afterResponse hook
4522
4975
  if (config.hooks?.afterResponse) {
4523
4976
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4570,14 +5023,16 @@ async function streamAgentRunEvents(context) {
4570
5023
  url = authResult.url;
4571
5024
  // Prepare body
4572
5025
  const body = undefined;
4573
- // Determine request function
4574
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5026
+ // Determine request function - a custom fetch is read only by the built-in
5027
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5028
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4575
5029
  // Build request params
4576
5030
  let requestParams = {
4577
5031
  url,
4578
5032
  method: 'GET',
4579
5033
  headers,
4580
- body
5034
+ body,
5035
+ signal: context.signal
4581
5036
  };
4582
5037
  // Apply beforeRequest hook
4583
5038
  if (config.hooks?.beforeRequest) {
@@ -4585,7 +5040,7 @@ async function streamAgentRunEvents(context) {
4585
5040
  }
4586
5041
  try {
4587
5042
  // Execute request with retry logic
4588
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5043
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4589
5044
  // Apply afterResponse hook
4590
5045
  if (config.hooks?.afterResponse) {
4591
5046
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4638,14 +5093,16 @@ async function autocompleteBusinessIdentities(context) {
4638
5093
  // Prepare body
4639
5094
  const payload = context.payload;
4640
5095
  const body = JSON.stringify(payload);
4641
- // Determine request function
4642
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5096
+ // Determine request function - a custom fetch is read only by the built-in
5097
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5098
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4643
5099
  // Build request params
4644
5100
  let requestParams = {
4645
5101
  url,
4646
5102
  method: 'POST',
4647
5103
  headers,
4648
- body
5104
+ body,
5105
+ signal: context.signal
4649
5106
  };
4650
5107
  // Apply beforeRequest hook
4651
5108
  if (config.hooks?.beforeRequest) {
@@ -4653,7 +5110,7 @@ async function autocompleteBusinessIdentities(context) {
4653
5110
  }
4654
5111
  try {
4655
5112
  // Execute request with retry logic
4656
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5113
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4657
5114
  // Apply afterResponse hook
4658
5115
  if (config.hooks?.afterResponse) {
4659
5116
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4706,14 +5163,16 @@ async function business(context) {
4706
5163
  // Prepare body
4707
5164
  const payload = context.payload;
4708
5165
  const body = JSON.stringify(payload);
4709
- // Determine request function
4710
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5166
+ // Determine request function - a custom fetch is read only by the built-in
5167
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5168
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4711
5169
  // Build request params
4712
5170
  let requestParams = {
4713
5171
  url,
4714
5172
  method: 'POST',
4715
5173
  headers,
4716
- body
5174
+ body,
5175
+ signal: context.signal
4717
5176
  };
4718
5177
  // Apply beforeRequest hook
4719
5178
  if (config.hooks?.beforeRequest) {
@@ -4721,7 +5180,7 @@ async function business(context) {
4721
5180
  }
4722
5181
  try {
4723
5182
  // Execute request with retry logic
4724
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5183
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4725
5184
  // Apply afterResponse hook
4726
5185
  if (config.hooks?.afterResponse) {
4727
5186
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4774,14 +5233,16 @@ async function listWebhooks(context) {
4774
5233
  url = authResult.url;
4775
5234
  // Prepare body
4776
5235
  const body = undefined;
4777
- // Determine request function
4778
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5236
+ // Determine request function - a custom fetch is read only by the built-in
5237
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5238
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4779
5239
  // Build request params
4780
5240
  let requestParams = {
4781
5241
  url,
4782
5242
  method: 'GET',
4783
5243
  headers,
4784
- body
5244
+ body,
5245
+ signal: context.signal
4785
5246
  };
4786
5247
  // Apply beforeRequest hook
4787
5248
  if (config.hooks?.beforeRequest) {
@@ -4789,7 +5250,7 @@ async function listWebhooks(context) {
4789
5250
  }
4790
5251
  try {
4791
5252
  // Execute request with retry logic
4792
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5253
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4793
5254
  // Apply afterResponse hook
4794
5255
  if (config.hooks?.afterResponse) {
4795
5256
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4842,14 +5303,16 @@ async function createWebhook(context) {
4842
5303
  // Prepare body
4843
5304
  const payload = context.payload;
4844
5305
  const body = JSON.stringify(payload);
4845
- // Determine request function
4846
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5306
+ // Determine request function - a custom fetch is read only by the built-in
5307
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5308
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4847
5309
  // Build request params
4848
5310
  let requestParams = {
4849
5311
  url,
4850
5312
  method: 'POST',
4851
5313
  headers,
4852
- body
5314
+ body,
5315
+ signal: context.signal
4853
5316
  };
4854
5317
  // Apply beforeRequest hook
4855
5318
  if (config.hooks?.beforeRequest) {
@@ -4857,7 +5320,7 @@ async function createWebhook(context) {
4857
5320
  }
4858
5321
  try {
4859
5322
  // Execute request with retry logic
4860
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5323
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4861
5324
  // Apply afterResponse hook
4862
5325
  if (config.hooks?.afterResponse) {
4863
5326
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4910,14 +5373,16 @@ async function getWebhook(context) {
4910
5373
  url = authResult.url;
4911
5374
  // Prepare body
4912
5375
  const body = undefined;
4913
- // Determine request function
4914
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5376
+ // Determine request function - a custom fetch is read only by the built-in
5377
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5378
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4915
5379
  // Build request params
4916
5380
  let requestParams = {
4917
5381
  url,
4918
5382
  method: 'GET',
4919
5383
  headers,
4920
- body
5384
+ body,
5385
+ signal: context.signal
4921
5386
  };
4922
5387
  // Apply beforeRequest hook
4923
5388
  if (config.hooks?.beforeRequest) {
@@ -4925,7 +5390,7 @@ async function getWebhook(context) {
4925
5390
  }
4926
5391
  try {
4927
5392
  // Execute request with retry logic
4928
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5393
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4929
5394
  // Apply afterResponse hook
4930
5395
  if (config.hooks?.afterResponse) {
4931
5396
  response = await config.hooks.afterResponse(response, requestParams);
@@ -4979,14 +5444,16 @@ async function updateWebhook(context) {
4979
5444
  // Prepare body
4980
5445
  const payload = context.payload;
4981
5446
  const body = JSON.stringify(payload);
4982
- // Determine request function
4983
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5447
+ // Determine request function - a custom fetch is read only by the built-in
5448
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5449
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
4984
5450
  // Build request params
4985
5451
  let requestParams = {
4986
5452
  url,
4987
5453
  method: 'PUT',
4988
5454
  headers,
4989
- body
5455
+ body,
5456
+ signal: context.signal
4990
5457
  };
4991
5458
  // Apply beforeRequest hook
4992
5459
  if (config.hooks?.beforeRequest) {
@@ -4994,7 +5461,7 @@ async function updateWebhook(context) {
4994
5461
  }
4995
5462
  try {
4996
5463
  // Execute request with retry logic
4997
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5464
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
4998
5465
  // Apply afterResponse hook
4999
5466
  if (config.hooks?.afterResponse) {
5000
5467
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5047,14 +5514,16 @@ async function deleteWebhook(context) {
5047
5514
  url = authResult.url;
5048
5515
  // Prepare body
5049
5516
  const body = undefined;
5050
- // Determine request function
5051
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5517
+ // Determine request function - a custom fetch is read only by the built-in
5518
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5519
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5052
5520
  // Build request params
5053
5521
  let requestParams = {
5054
5522
  url,
5055
5523
  method: 'DELETE',
5056
5524
  headers,
5057
- body
5525
+ body,
5526
+ signal: context.signal
5058
5527
  };
5059
5528
  // Apply beforeRequest hook
5060
5529
  if (config.hooks?.beforeRequest) {
@@ -5062,7 +5531,7 @@ async function deleteWebhook(context) {
5062
5531
  }
5063
5532
  try {
5064
5533
  // Execute request with retry logic
5065
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5534
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5066
5535
  // Apply afterResponse hook
5067
5536
  if (config.hooks?.afterResponse) {
5068
5537
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5116,14 +5585,16 @@ async function listWebhookEventSchemas(context) {
5116
5585
  url = authResult.url;
5117
5586
  // Prepare body
5118
5587
  const body = undefined;
5119
- // Determine request function
5120
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5588
+ // Determine request function - a custom fetch is read only by the built-in
5589
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5590
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5121
5591
  // Build request params
5122
5592
  let requestParams = {
5123
5593
  url,
5124
5594
  method: 'GET',
5125
5595
  headers,
5126
- body
5596
+ body,
5597
+ signal: context.signal
5127
5598
  };
5128
5599
  // Apply beforeRequest hook
5129
5600
  if (config.hooks?.beforeRequest) {
@@ -5131,7 +5602,7 @@ async function listWebhookEventSchemas(context) {
5131
5602
  }
5132
5603
  try {
5133
5604
  // Execute request with retry logic
5134
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5605
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5135
5606
  // Apply afterResponse hook
5136
5607
  if (config.hooks?.afterResponse) {
5137
5608
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5185,14 +5656,16 @@ async function createWebhookEventSchema(context) {
5185
5656
  // Prepare body
5186
5657
  const payload = context.payload;
5187
5658
  const body = JSON.stringify(payload);
5188
- // Determine request function
5189
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5659
+ // Determine request function - a custom fetch is read only by the built-in
5660
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5661
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5190
5662
  // Build request params
5191
5663
  let requestParams = {
5192
5664
  url,
5193
5665
  method: 'POST',
5194
5666
  headers,
5195
- body
5667
+ body,
5668
+ signal: context.signal
5196
5669
  };
5197
5670
  // Apply beforeRequest hook
5198
5671
  if (config.hooks?.beforeRequest) {
@@ -5200,7 +5673,7 @@ async function createWebhookEventSchema(context) {
5200
5673
  }
5201
5674
  try {
5202
5675
  // Execute request with retry logic
5203
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5676
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5204
5677
  // Apply afterResponse hook
5205
5678
  if (config.hooks?.afterResponse) {
5206
5679
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5253,14 +5726,16 @@ async function getWebhookEventSchema(context) {
5253
5726
  url = authResult.url;
5254
5727
  // Prepare body
5255
5728
  const body = undefined;
5256
- // Determine request function
5257
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5729
+ // Determine request function - a custom fetch is read only by the built-in
5730
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5731
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5258
5732
  // Build request params
5259
5733
  let requestParams = {
5260
5734
  url,
5261
5735
  method: 'GET',
5262
5736
  headers,
5263
- body
5737
+ body,
5738
+ signal: context.signal
5264
5739
  };
5265
5740
  // Apply beforeRequest hook
5266
5741
  if (config.hooks?.beforeRequest) {
@@ -5268,7 +5743,7 @@ async function getWebhookEventSchema(context) {
5268
5743
  }
5269
5744
  try {
5270
5745
  // Execute request with retry logic
5271
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5746
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5272
5747
  // Apply afterResponse hook
5273
5748
  if (config.hooks?.afterResponse) {
5274
5749
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5322,14 +5797,16 @@ async function updateWebhookEventSchema(context) {
5322
5797
  // Prepare body
5323
5798
  const payload = context.payload;
5324
5799
  const body = JSON.stringify(payload);
5325
- // Determine request function
5326
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5800
+ // Determine request function - a custom fetch is read only by the built-in
5801
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5802
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5327
5803
  // Build request params
5328
5804
  let requestParams = {
5329
5805
  url,
5330
5806
  method: 'PATCH',
5331
5807
  headers,
5332
- body
5808
+ body,
5809
+ signal: context.signal
5333
5810
  };
5334
5811
  // Apply beforeRequest hook
5335
5812
  if (config.hooks?.beforeRequest) {
@@ -5337,7 +5814,7 @@ async function updateWebhookEventSchema(context) {
5337
5814
  }
5338
5815
  try {
5339
5816
  // Execute request with retry logic
5340
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5817
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5341
5818
  // Apply afterResponse hook
5342
5819
  if (config.hooks?.afterResponse) {
5343
5820
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5390,14 +5867,16 @@ async function deleteWebhookEventSchema(context) {
5390
5867
  url = authResult.url;
5391
5868
  // Prepare body
5392
5869
  const body = undefined;
5393
- // Determine request function
5394
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5870
+ // Determine request function - a custom fetch is read only by the built-in
5871
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5872
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5395
5873
  // Build request params
5396
5874
  let requestParams = {
5397
5875
  url,
5398
5876
  method: 'DELETE',
5399
5877
  headers,
5400
- body
5878
+ body,
5879
+ signal: context.signal
5401
5880
  };
5402
5881
  // Apply beforeRequest hook
5403
5882
  if (config.hooks?.beforeRequest) {
@@ -5405,7 +5884,7 @@ async function deleteWebhookEventSchema(context) {
5405
5884
  }
5406
5885
  try {
5407
5886
  // Execute request with retry logic
5408
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5887
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5409
5888
  // Apply afterResponse hook
5410
5889
  if (config.hooks?.afterResponse) {
5411
5890
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5458,14 +5937,16 @@ async function getOidcKeys(context = {}) {
5458
5937
  url = authResult.url;
5459
5938
  // Prepare body
5460
5939
  const body = undefined;
5461
- // Determine request function
5462
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
5940
+ // Determine request function - a custom fetch is read only by the built-in
5941
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
5942
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5463
5943
  // Build request params
5464
5944
  let requestParams = {
5465
5945
  url,
5466
5946
  method: 'GET',
5467
5947
  headers,
5468
- body
5948
+ body,
5949
+ signal: context.signal
5469
5950
  };
5470
5951
  // Apply beforeRequest hook
5471
5952
  if (config.hooks?.beforeRequest) {
@@ -5473,7 +5954,7 @@ async function getOidcKeys(context = {}) {
5473
5954
  }
5474
5955
  try {
5475
5956
  // Execute request with retry logic
5476
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
5957
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5477
5958
  // Apply afterResponse hook
5478
5959
  if (config.hooks?.afterResponse) {
5479
5960
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5526,14 +6007,16 @@ async function listDocuments(context) {
5526
6007
  url = authResult.url;
5527
6008
  // Prepare body
5528
6009
  const body = undefined;
5529
- // Determine request function
5530
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
6010
+ // Determine request function - a custom fetch is read only by the built-in
6011
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6012
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5531
6013
  // Build request params
5532
6014
  let requestParams = {
5533
6015
  url,
5534
6016
  method: 'GET',
5535
6017
  headers,
5536
- body
6018
+ body,
6019
+ signal: context.signal
5537
6020
  };
5538
6021
  // Apply beforeRequest hook
5539
6022
  if (config.hooks?.beforeRequest) {
@@ -5541,7 +6024,7 @@ async function listDocuments(context) {
5541
6024
  }
5542
6025
  try {
5543
6026
  // Execute request with retry logic
5544
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
6027
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5545
6028
  // Apply afterResponse hook
5546
6029
  if (config.hooks?.afterResponse) {
5547
6030
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5594,14 +6077,16 @@ async function getDocument(context) {
5594
6077
  url = authResult.url;
5595
6078
  // Prepare body
5596
6079
  const body = undefined;
5597
- // Determine request function
5598
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
6080
+ // Determine request function - a custom fetch is read only by the built-in
6081
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6082
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5599
6083
  // Build request params
5600
6084
  let requestParams = {
5601
6085
  url,
5602
6086
  method: 'GET',
5603
6087
  headers,
5604
- body
6088
+ body,
6089
+ signal: context.signal
5605
6090
  };
5606
6091
  // Apply beforeRequest hook
5607
6092
  if (config.hooks?.beforeRequest) {
@@ -5609,7 +6094,7 @@ async function getDocument(context) {
5609
6094
  }
5610
6095
  try {
5611
6096
  // Execute request with retry logic
5612
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
6097
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5613
6098
  // Apply afterResponse hook
5614
6099
  if (config.hooks?.afterResponse) {
5615
6100
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5662,14 +6147,16 @@ async function getDocumentDownloadUrl(context) {
5662
6147
  url = authResult.url;
5663
6148
  // Prepare body
5664
6149
  const body = undefined;
5665
- // Determine request function
5666
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
6150
+ // Determine request function - a custom fetch is read only by the built-in
6151
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6152
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5667
6153
  // Build request params
5668
6154
  let requestParams = {
5669
6155
  url,
5670
6156
  method: 'GET',
5671
6157
  headers,
5672
- body
6158
+ body,
6159
+ signal: context.signal
5673
6160
  };
5674
6161
  // Apply beforeRequest hook
5675
6162
  if (config.hooks?.beforeRequest) {
@@ -5677,7 +6164,7 @@ async function getDocumentDownloadUrl(context) {
5677
6164
  }
5678
6165
  try {
5679
6166
  // Execute request with retry logic
5680
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
6167
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5681
6168
  // Apply afterResponse hook
5682
6169
  if (config.hooks?.afterResponse) {
5683
6170
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5730,14 +6217,16 @@ async function getRiskAssessments(context) {
5730
6217
  url = authResult.url;
5731
6218
  // Prepare body
5732
6219
  const body = undefined;
5733
- // Determine request function
5734
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
6220
+ // Determine request function - a custom fetch is read only by the built-in
6221
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6222
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5735
6223
  // Build request params
5736
6224
  let requestParams = {
5737
6225
  url,
5738
6226
  method: 'GET',
5739
6227
  headers,
5740
- body
6228
+ body,
6229
+ signal: context.signal
5741
6230
  };
5742
6231
  // Apply beforeRequest hook
5743
6232
  if (config.hooks?.beforeRequest) {
@@ -5745,7 +6234,7 @@ async function getRiskAssessments(context) {
5745
6234
  }
5746
6235
  try {
5747
6236
  // Execute request with retry logic
5748
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
6237
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5749
6238
  // Apply afterResponse hook
5750
6239
  if (config.hooks?.afterResponse) {
5751
6240
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5798,14 +6287,16 @@ async function getLatestRiskAssessment(context) {
5798
6287
  url = authResult.url;
5799
6288
  // Prepare body
5800
6289
  const body = undefined;
5801
- // Determine request function
5802
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
6290
+ // Determine request function - a custom fetch is read only by the built-in
6291
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6292
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5803
6293
  // Build request params
5804
6294
  let requestParams = {
5805
6295
  url,
5806
6296
  method: 'GET',
5807
6297
  headers,
5808
- body
6298
+ body,
6299
+ signal: context.signal
5809
6300
  };
5810
6301
  // Apply beforeRequest hook
5811
6302
  if (config.hooks?.beforeRequest) {
@@ -5813,7 +6304,7 @@ async function getLatestRiskAssessment(context) {
5813
6304
  }
5814
6305
  try {
5815
6306
  // Execute request with retry logic
5816
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
6307
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5817
6308
  // Apply afterResponse hook
5818
6309
  if (config.hooks?.afterResponse) {
5819
6310
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5866,14 +6357,156 @@ async function getRiskAssessment(context) {
5866
6357
  url = authResult.url;
5867
6358
  // Prepare body
5868
6359
  const body = undefined;
5869
- // Determine request function
5870
- const makeRequest = config.hooks?.makeRequest ?? defaultMakeRequest;
6360
+ // Determine request function - a custom fetch is read only by the built-in
6361
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6362
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
6363
+ // Build request params
6364
+ let requestParams = {
6365
+ url,
6366
+ method: 'GET',
6367
+ headers,
6368
+ body,
6369
+ signal: context.signal
6370
+ };
6371
+ // Apply beforeRequest hook
6372
+ if (config.hooks?.beforeRequest) {
6373
+ requestParams = await config.hooks.beforeRequest(requestParams);
6374
+ }
6375
+ try {
6376
+ // Execute request with retry logic
6377
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
6378
+ // Apply afterResponse hook
6379
+ if (config.hooks?.afterResponse) {
6380
+ response = await config.hooks.afterResponse(response, requestParams);
6381
+ }
6382
+ // Handle error responses
6383
+ if (!response.ok) {
6384
+ const errorBody = await response.json().catch(() => undefined);
6385
+ handleHttpError(response.status, response.statusText, errorBody);
6386
+ }
6387
+ // Parse response
6388
+ const rawData = await response.json();
6389
+ const responseData = rawData;
6390
+ // Extract response metadata
6391
+ const responseHeaders = extractHeaders(response);
6392
+ const result = {
6393
+ data: responseData,
6394
+ status: response.status,
6395
+ statusText: response.statusText,
6396
+ headers: responseHeaders,
6397
+ rawData: rawData ?? {},
6398
+ };
6399
+ return result;
6400
+ }
6401
+ catch (error) {
6402
+ // Apply onError hook if present
6403
+ if (config.hooks?.onError && error instanceof HttpGlobalError) {
6404
+ throw await config.hooks.onError(error, requestParams);
6405
+ }
6406
+ throw error;
6407
+ }
6408
+ }
6409
+ /**
6410
+ * Lists sub-accounts owned by the caller, newest first. q performs a case-insensitive substring search on name only; percent and underscore characters are treated literally.
6411
+ */
6412
+ async function listSubAccounts(context) {
6413
+ // Apply defaults
6414
+ const config = {
6415
+ baseUrl: 'https://api.middesk.com',
6416
+ ...context,
6417
+ };
6418
+ const parameters = context.parameters instanceof ListSubAccountsParameters_js_1.ListSubAccountsParameters ? context.parameters : new ListSubAccountsParameters_js_1.ListSubAccountsParameters(context.parameters);
6419
+ // Build headers
6420
+ let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders, ...(context.requestHeaders ? (0, ListSubAccountsHeaders_js_1.serializeListSubAccountsHeadersHeaders)(context.requestHeaders) : {}) };
6421
+ // Build URL
6422
+ let url = buildUrlWithParameters(config.baseUrl, '/v1/sub_accounts', parameters);
6423
+ url = applyQueryParams(config.additionalQueryParams, url);
6424
+ // Apply authentication
6425
+ const authResult = applyAuth(config.auth, headers, url);
6426
+ headers = authResult.headers;
6427
+ url = authResult.url;
6428
+ // Prepare body
6429
+ const body = undefined;
6430
+ // Determine request function - a custom fetch is read only by the built-in
6431
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6432
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
5871
6433
  // Build request params
5872
6434
  let requestParams = {
5873
6435
  url,
5874
6436
  method: 'GET',
5875
6437
  headers,
5876
- body
6438
+ body,
6439
+ signal: context.signal
6440
+ };
6441
+ // Apply beforeRequest hook
6442
+ if (config.hooks?.beforeRequest) {
6443
+ requestParams = await config.hooks.beforeRequest(requestParams);
6444
+ }
6445
+ try {
6446
+ // Execute request with retry logic
6447
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
6448
+ // Apply afterResponse hook
6449
+ if (config.hooks?.afterResponse) {
6450
+ response = await config.hooks.afterResponse(response, requestParams);
6451
+ }
6452
+ // Handle error responses
6453
+ if (!response.ok) {
6454
+ const errorBody = await response.json().catch(() => undefined);
6455
+ handleHttpError(response.status, response.statusText, errorBody);
6456
+ }
6457
+ // Parse response
6458
+ const rawData = await response.json();
6459
+ const responseData = rawData;
6460
+ // Extract response metadata
6461
+ const responseHeaders = extractHeaders(response);
6462
+ const result = {
6463
+ data: responseData,
6464
+ status: response.status,
6465
+ statusText: response.statusText,
6466
+ headers: responseHeaders,
6467
+ rawData: rawData ?? {},
6468
+ };
6469
+ return result;
6470
+ }
6471
+ catch (error) {
6472
+ // Apply onError hook if present
6473
+ if (config.hooks?.onError && error instanceof HttpGlobalError) {
6474
+ throw await config.hooks.onError(error, requestParams);
6475
+ }
6476
+ throw error;
6477
+ }
6478
+ }
6479
+ /**
6480
+ * Creates a sub-account and provisions an initial sandbox API key. external_id is an idempotency key unique within the parent account: repeating a request with the same external_id returns the existing sub-account with 200 and no api_keys field. With inherit_products_from_parent enabled (the default), parent product changes cascade to the sub-account. When disabled, products is required and the sub-account is independent.
6481
+ */
6482
+ async function createSubAccount(context) {
6483
+ // Apply defaults
6484
+ const config = {
6485
+ baseUrl: 'https://api.middesk.com',
6486
+ ...context,
6487
+ };
6488
+ // Build headers
6489
+ let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders, ...(context.requestHeaders ? (0, CreateSubAccountHeaders_js_1.serializeCreateSubAccountHeadersHeaders)(context.requestHeaders) : {}) };
6490
+ // Build URL
6491
+ let url = `${config.baseUrl}/v1/sub_accounts`;
6492
+ url = applyQueryParams(config.additionalQueryParams, url);
6493
+ // Apply authentication
6494
+ const authResult = applyAuth(config.auth, headers, url);
6495
+ headers = authResult.headers;
6496
+ url = authResult.url;
6497
+ // Prepare body
6498
+ const payload = context.payload;
6499
+ const body = JSON.stringify(payload);
6500
+ // Determine request function - a custom fetch is read only by the built-in
6501
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6502
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
6503
+ // Build request params
6504
+ let requestParams = {
6505
+ url,
6506
+ method: 'POST',
6507
+ headers,
6508
+ body,
6509
+ signal: context.signal
5877
6510
  };
5878
6511
  // Apply beforeRequest hook
5879
6512
  if (config.hooks?.beforeRequest) {
@@ -5881,7 +6514,7 @@ async function getRiskAssessment(context) {
5881
6514
  }
5882
6515
  try {
5883
6516
  // Execute request with retry logic
5884
- let response = await executeWithRetry(requestParams, makeRequest, config.retry);
6517
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
5885
6518
  // Apply afterResponse hook
5886
6519
  if (config.hooks?.afterResponse) {
5887
6520
  response = await config.hooks.afterResponse(response, requestParams);
@@ -5913,4 +6546,357 @@ async function getRiskAssessment(context) {
5913
6546
  throw error;
5914
6547
  }
5915
6548
  }
6549
+ /**
6550
+ * Returns a sub-account owned by the caller. IDs belonging to another parent return 404.
6551
+ */
6552
+ async function getSubAccount(context) {
6553
+ // Apply defaults
6554
+ const config = {
6555
+ baseUrl: 'https://api.middesk.com',
6556
+ ...context,
6557
+ };
6558
+ const parameters = context.parameters instanceof GetSubAccountParameters_js_1.GetSubAccountParameters ? context.parameters : new GetSubAccountParameters_js_1.GetSubAccountParameters(context.parameters);
6559
+ // Build headers
6560
+ let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders, ...(context.requestHeaders ? (0, GetSubAccountHeaders_js_1.serializeGetSubAccountHeadersHeaders)(context.requestHeaders) : {}) };
6561
+ // Build URL
6562
+ let url = buildUrlWithParameters(config.baseUrl, '/v1/sub_accounts/{id}', parameters);
6563
+ url = applyQueryParams(config.additionalQueryParams, url);
6564
+ // Apply authentication
6565
+ const authResult = applyAuth(config.auth, headers, url);
6566
+ headers = authResult.headers;
6567
+ url = authResult.url;
6568
+ // Prepare body
6569
+ const body = undefined;
6570
+ // Determine request function - a custom fetch is read only by the built-in
6571
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6572
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
6573
+ // Build request params
6574
+ let requestParams = {
6575
+ url,
6576
+ method: 'GET',
6577
+ headers,
6578
+ body,
6579
+ signal: context.signal
6580
+ };
6581
+ // Apply beforeRequest hook
6582
+ if (config.hooks?.beforeRequest) {
6583
+ requestParams = await config.hooks.beforeRequest(requestParams);
6584
+ }
6585
+ try {
6586
+ // Execute request with retry logic
6587
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
6588
+ // Apply afterResponse hook
6589
+ if (config.hooks?.afterResponse) {
6590
+ response = await config.hooks.afterResponse(response, requestParams);
6591
+ }
6592
+ // Handle error responses
6593
+ if (!response.ok) {
6594
+ const errorBody = await response.json().catch(() => undefined);
6595
+ handleHttpError(response.status, response.statusText, errorBody);
6596
+ }
6597
+ // Parse response
6598
+ const rawData = await response.json();
6599
+ const responseData = rawData;
6600
+ // Extract response metadata
6601
+ const responseHeaders = extractHeaders(response);
6602
+ const result = {
6603
+ data: responseData,
6604
+ status: response.status,
6605
+ statusText: response.statusText,
6606
+ headers: responseHeaders,
6607
+ rawData: rawData ?? {},
6608
+ };
6609
+ return result;
6610
+ }
6611
+ catch (error) {
6612
+ // Apply onError hook if present
6613
+ if (config.hooks?.onError && error instanceof HttpGlobalError) {
6614
+ throw await config.hooks.onError(error, requestParams);
6615
+ }
6616
+ throw error;
6617
+ }
6618
+ }
6619
+ /**
6620
+ * Activates or deactivates a sub-account. Deactivation causes every API key belonging to the sub-account to return 401, while retaining its data and keys. Re-enabling restores access.
6621
+ */
6622
+ async function updateSubAccount(context) {
6623
+ // Apply defaults
6624
+ const config = {
6625
+ baseUrl: 'https://api.middesk.com',
6626
+ ...context,
6627
+ };
6628
+ const parameters = context.parameters instanceof UpdateSubAccountParameters_js_1.UpdateSubAccountParameters ? context.parameters : new UpdateSubAccountParameters_js_1.UpdateSubAccountParameters(context.parameters);
6629
+ // Build headers
6630
+ let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders, ...(context.requestHeaders ? (0, UpdateSubAccountHeaders_js_1.serializeUpdateSubAccountHeadersHeaders)(context.requestHeaders) : {}) };
6631
+ // Build URL
6632
+ let url = buildUrlWithParameters(config.baseUrl, '/v1/sub_accounts/{id}', parameters);
6633
+ url = applyQueryParams(config.additionalQueryParams, url);
6634
+ // Apply authentication
6635
+ const authResult = applyAuth(config.auth, headers, url);
6636
+ headers = authResult.headers;
6637
+ url = authResult.url;
6638
+ // Prepare body
6639
+ const payload = context.payload;
6640
+ const body = JSON.stringify(payload);
6641
+ // Determine request function - a custom fetch is read only by the built-in
6642
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6643
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
6644
+ // Build request params
6645
+ let requestParams = {
6646
+ url,
6647
+ method: 'PATCH',
6648
+ headers,
6649
+ body,
6650
+ signal: context.signal
6651
+ };
6652
+ // Apply beforeRequest hook
6653
+ if (config.hooks?.beforeRequest) {
6654
+ requestParams = await config.hooks.beforeRequest(requestParams);
6655
+ }
6656
+ try {
6657
+ // Execute request with retry logic
6658
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
6659
+ // Apply afterResponse hook
6660
+ if (config.hooks?.afterResponse) {
6661
+ response = await config.hooks.afterResponse(response, requestParams);
6662
+ }
6663
+ // Handle error responses
6664
+ if (!response.ok) {
6665
+ const errorBody = await response.json().catch(() => undefined);
6666
+ handleHttpError(response.status, response.statusText, errorBody);
6667
+ }
6668
+ // Parse response
6669
+ const rawData = await response.json();
6670
+ const responseData = rawData;
6671
+ // Extract response metadata
6672
+ const responseHeaders = extractHeaders(response);
6673
+ const result = {
6674
+ data: responseData,
6675
+ status: response.status,
6676
+ statusText: response.statusText,
6677
+ headers: responseHeaders,
6678
+ rawData: rawData ?? {},
6679
+ };
6680
+ return result;
6681
+ }
6682
+ catch (error) {
6683
+ // Apply onError hook if present
6684
+ if (config.hooks?.onError && error instanceof HttpGlobalError) {
6685
+ throw await config.hooks.onError(error, requestParams);
6686
+ }
6687
+ throw error;
6688
+ }
6689
+ }
6690
+ /**
6691
+ * Lists active API keys for a sub-account owned by the caller. The response includes each key value; store and handle the response as a secret.
6692
+ */
6693
+ async function listSubAccountApiKeys(context) {
6694
+ // Apply defaults
6695
+ const config = {
6696
+ baseUrl: 'https://api.middesk.com',
6697
+ ...context,
6698
+ };
6699
+ const parameters = context.parameters instanceof ListSubAccountApiKeysParameters_js_1.ListSubAccountApiKeysParameters ? context.parameters : new ListSubAccountApiKeysParameters_js_1.ListSubAccountApiKeysParameters(context.parameters);
6700
+ // Build headers
6701
+ let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders, ...(context.requestHeaders ? (0, ListSubAccountApiKeysHeaders_js_1.serializeListSubAccountApiKeysHeadersHeaders)(context.requestHeaders) : {}) };
6702
+ // Build URL
6703
+ let url = buildUrlWithParameters(config.baseUrl, '/v1/sub_accounts/{sub_account_id}/api_keys', parameters);
6704
+ url = applyQueryParams(config.additionalQueryParams, url);
6705
+ // Apply authentication
6706
+ const authResult = applyAuth(config.auth, headers, url);
6707
+ headers = authResult.headers;
6708
+ url = authResult.url;
6709
+ // Prepare body
6710
+ const body = undefined;
6711
+ // Determine request function - a custom fetch is read only by the built-in
6712
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6713
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
6714
+ // Build request params
6715
+ let requestParams = {
6716
+ url,
6717
+ method: 'GET',
6718
+ headers,
6719
+ body,
6720
+ signal: context.signal
6721
+ };
6722
+ // Apply beforeRequest hook
6723
+ if (config.hooks?.beforeRequest) {
6724
+ requestParams = await config.hooks.beforeRequest(requestParams);
6725
+ }
6726
+ try {
6727
+ // Execute request with retry logic
6728
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
6729
+ // Apply afterResponse hook
6730
+ if (config.hooks?.afterResponse) {
6731
+ response = await config.hooks.afterResponse(response, requestParams);
6732
+ }
6733
+ // Handle error responses
6734
+ if (!response.ok) {
6735
+ const errorBody = await response.json().catch(() => undefined);
6736
+ handleHttpError(response.status, response.statusText, errorBody);
6737
+ }
6738
+ // Parse response
6739
+ const rawData = await response.json();
6740
+ const responseData = rawData;
6741
+ // Extract response metadata
6742
+ const responseHeaders = extractHeaders(response);
6743
+ const result = {
6744
+ data: responseData,
6745
+ status: response.status,
6746
+ statusText: response.statusText,
6747
+ headers: responseHeaders,
6748
+ rawData: rawData ?? {},
6749
+ };
6750
+ return result;
6751
+ }
6752
+ catch (error) {
6753
+ // Apply onError hook if present
6754
+ if (config.hooks?.onError && error instanceof HttpGlobalError) {
6755
+ throw await config.hooks.onError(error, requestParams);
6756
+ }
6757
+ throw error;
6758
+ }
6759
+ }
6760
+ /**
6761
+ * Creates a sandbox or production API key for a sub-account. Treat the returned key value as a secret. For rotation, create a replacement, cut traffic over, then revoke the old key.
6762
+ */
6763
+ async function createSubAccountApiKey(context) {
6764
+ // Apply defaults
6765
+ const config = {
6766
+ baseUrl: 'https://api.middesk.com',
6767
+ ...context,
6768
+ };
6769
+ const parameters = context.parameters instanceof CreateSubAccountApiKeyParameters_js_1.CreateSubAccountApiKeyParameters ? context.parameters : new CreateSubAccountApiKeyParameters_js_1.CreateSubAccountApiKeyParameters(context.parameters);
6770
+ // Build headers
6771
+ let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders, ...(context.requestHeaders ? (0, CreateSubAccountApiKeyHeaders_js_1.serializeCreateSubAccountApiKeyHeadersHeaders)(context.requestHeaders) : {}) };
6772
+ // Build URL
6773
+ let url = buildUrlWithParameters(config.baseUrl, '/v1/sub_accounts/{sub_account_id}/api_keys', parameters);
6774
+ url = applyQueryParams(config.additionalQueryParams, url);
6775
+ // Apply authentication
6776
+ const authResult = applyAuth(config.auth, headers, url);
6777
+ headers = authResult.headers;
6778
+ url = authResult.url;
6779
+ // Prepare body
6780
+ const payload = context.payload;
6781
+ const body = JSON.stringify(payload);
6782
+ // Determine request function - a custom fetch is read only by the built-in
6783
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6784
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
6785
+ // Build request params
6786
+ let requestParams = {
6787
+ url,
6788
+ method: 'POST',
6789
+ headers,
6790
+ body,
6791
+ signal: context.signal
6792
+ };
6793
+ // Apply beforeRequest hook
6794
+ if (config.hooks?.beforeRequest) {
6795
+ requestParams = await config.hooks.beforeRequest(requestParams);
6796
+ }
6797
+ try {
6798
+ // Execute request with retry logic
6799
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
6800
+ // Apply afterResponse hook
6801
+ if (config.hooks?.afterResponse) {
6802
+ response = await config.hooks.afterResponse(response, requestParams);
6803
+ }
6804
+ // Handle error responses
6805
+ if (!response.ok) {
6806
+ const errorBody = await response.json().catch(() => undefined);
6807
+ handleHttpError(response.status, response.statusText, errorBody);
6808
+ }
6809
+ // Parse response
6810
+ const rawData = await response.json();
6811
+ const responseData = rawData;
6812
+ // Extract response metadata
6813
+ const responseHeaders = extractHeaders(response);
6814
+ const result = {
6815
+ data: responseData,
6816
+ status: response.status,
6817
+ statusText: response.statusText,
6818
+ headers: responseHeaders,
6819
+ rawData: rawData ?? {},
6820
+ };
6821
+ return result;
6822
+ }
6823
+ catch (error) {
6824
+ // Apply onError hook if present
6825
+ if (config.hooks?.onError && error instanceof HttpGlobalError) {
6826
+ throw await config.hooks.onError(error, requestParams);
6827
+ }
6828
+ throw error;
6829
+ }
6830
+ }
6831
+ /**
6832
+ * Revokes an API key belonging to a sub-account. The key must belong to the specified sub-account, and the sub-account must belong to the caller.
6833
+ */
6834
+ async function deleteSubAccountApiKey(context) {
6835
+ // Apply defaults
6836
+ const config = {
6837
+ baseUrl: 'https://api.middesk.com',
6838
+ ...context,
6839
+ };
6840
+ const parameters = context.parameters instanceof DeleteSubAccountApiKeyParameters_js_1.DeleteSubAccountApiKeyParameters ? context.parameters : new DeleteSubAccountApiKeyParameters_js_1.DeleteSubAccountApiKeyParameters(context.parameters);
6841
+ // Build headers
6842
+ let headers = { 'Content-Type': 'application/json', ...config.additionalHeaders, ...(context.requestHeaders ? (0, DeleteSubAccountApiKeyHeaders_js_1.serializeDeleteSubAccountApiKeyHeadersHeaders)(context.requestHeaders) : {}) };
6843
+ // Build URL
6844
+ let url = buildUrlWithParameters(config.baseUrl, '/v1/sub_accounts/{sub_account_id}/api_keys/{id}', parameters);
6845
+ url = applyQueryParams(config.additionalQueryParams, url);
6846
+ // Apply authentication
6847
+ const authResult = applyAuth(config.auth, headers, url);
6848
+ headers = authResult.headers;
6849
+ url = authResult.url;
6850
+ // Prepare body
6851
+ const body = undefined;
6852
+ // Determine request function - a custom fetch is read only by the built-in
6853
+ // makeRequest, so it is bound in here rather than passed to executeWithRetry.
6854
+ const makeRequest = config.hooks?.makeRequest ?? ((requestParams) => defaultMakeRequest(requestParams, config.fetch));
6855
+ // Build request params
6856
+ let requestParams = {
6857
+ url,
6858
+ method: 'DELETE',
6859
+ headers,
6860
+ body,
6861
+ signal: context.signal
6862
+ };
6863
+ // Apply beforeRequest hook
6864
+ if (config.hooks?.beforeRequest) {
6865
+ requestParams = await config.hooks.beforeRequest(requestParams);
6866
+ }
6867
+ try {
6868
+ // Execute request with retry logic
6869
+ let response = await executeWithRetry(requestParams, makeRequest, config.retry, config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
6870
+ // Apply afterResponse hook
6871
+ if (config.hooks?.afterResponse) {
6872
+ response = await config.hooks.afterResponse(response, requestParams);
6873
+ }
6874
+ // Handle error responses
6875
+ if (!response.ok) {
6876
+ const errorBody = await response.json().catch(() => undefined);
6877
+ handleHttpError(response.status, response.statusText, errorBody);
6878
+ }
6879
+ // Parse response
6880
+ // This operation declares no response body.
6881
+ const rawData = await readOptionalJsonBody(response);
6882
+ const responseData = undefined;
6883
+ // Extract response metadata
6884
+ const responseHeaders = extractHeaders(response);
6885
+ const result = {
6886
+ data: responseData,
6887
+ status: response.status,
6888
+ statusText: response.statusText,
6889
+ headers: responseHeaders,
6890
+ rawData: rawData ?? {},
6891
+ };
6892
+ return result;
6893
+ }
6894
+ catch (error) {
6895
+ // Apply onError hook if present
6896
+ if (config.hooks?.onError && error instanceof HttpGlobalError) {
6897
+ throw await config.hooks.onError(error, requestParams);
6898
+ }
6899
+ throw error;
6900
+ }
6901
+ }
5916
6902
  //# sourceMappingURL=http_client.js.map