@roarkanalytics/sdk 2.21.1 → 2.21.2

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 (348) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +69 -46
  3. package/api-promise.d.mts +1 -46
  4. package/api-promise.d.mts.map +1 -1
  5. package/api-promise.d.ts +1 -46
  6. package/api-promise.d.ts.map +1 -1
  7. package/api-promise.js +3 -81
  8. package/api-promise.js.map +1 -1
  9. package/api-promise.mjs +1 -79
  10. package/api-promise.mjs.map +1 -1
  11. package/client.d.mts +25 -30
  12. package/client.d.mts.map +1 -1
  13. package/client.d.ts +25 -30
  14. package/client.d.ts.map +1 -1
  15. package/client.js +150 -132
  16. package/client.js.map +1 -1
  17. package/client.mjs +145 -104
  18. package/client.mjs.map +1 -1
  19. package/core/api-promise.d.mts +46 -0
  20. package/core/api-promise.d.mts.map +1 -0
  21. package/core/api-promise.d.ts +46 -0
  22. package/core/api-promise.d.ts.map +1 -0
  23. package/core/api-promise.js +74 -0
  24. package/core/api-promise.js.map +1 -0
  25. package/core/api-promise.mjs +70 -0
  26. package/core/api-promise.mjs.map +1 -0
  27. package/core/error.d.mts +46 -0
  28. package/core/error.d.mts.map +1 -0
  29. package/core/error.d.ts +46 -0
  30. package/core/error.d.ts.map +1 -0
  31. package/core/error.js +113 -0
  32. package/core/error.js.map +1 -0
  33. package/core/error.mjs +97 -0
  34. package/core/error.mjs.map +1 -0
  35. package/core/resource.d.mts +6 -0
  36. package/core/resource.d.mts.map +1 -0
  37. package/core/resource.d.ts +6 -0
  38. package/core/resource.d.ts.map +1 -0
  39. package/core/resource.js +11 -0
  40. package/core/resource.js.map +1 -0
  41. package/core/resource.mjs +7 -0
  42. package/core/resource.mjs.map +1 -0
  43. package/core/uploads.d.mts +3 -0
  44. package/core/uploads.d.mts.map +1 -0
  45. package/core/uploads.d.ts +3 -0
  46. package/core/uploads.d.ts.map +1 -0
  47. package/core/uploads.js +6 -0
  48. package/core/uploads.js.map +1 -0
  49. package/core/uploads.mjs +2 -0
  50. package/core/uploads.mjs.map +1 -0
  51. package/error.d.mts +1 -46
  52. package/error.d.mts.map +1 -1
  53. package/error.d.ts +1 -46
  54. package/error.d.ts.map +1 -1
  55. package/error.js +3 -110
  56. package/error.js.map +1 -1
  57. package/error.mjs +1 -96
  58. package/error.mjs.map +1 -1
  59. package/index.d.mts +6 -6
  60. package/index.d.ts +3 -3
  61. package/index.js +3 -3
  62. package/index.js.map +1 -1
  63. package/index.mjs +3 -3
  64. package/internal/builtin-types.d.mts +11 -3
  65. package/internal/builtin-types.d.mts.map +1 -1
  66. package/internal/builtin-types.d.ts +11 -3
  67. package/internal/builtin-types.d.ts.map +1 -1
  68. package/internal/detect-platform.js +3 -3
  69. package/internal/detect-platform.js.map +1 -1
  70. package/internal/detect-platform.mjs +3 -3
  71. package/internal/detect-platform.mjs.map +1 -1
  72. package/internal/errors.d.mts.map +1 -1
  73. package/internal/errors.d.ts.map +1 -1
  74. package/internal/errors.js +17 -2
  75. package/internal/errors.js.map +1 -1
  76. package/internal/errors.mjs +15 -0
  77. package/internal/errors.mjs.map +1 -1
  78. package/internal/headers.d.mts +1 -2
  79. package/internal/headers.d.mts.map +1 -1
  80. package/internal/headers.d.ts +1 -2
  81. package/internal/headers.d.ts.map +1 -1
  82. package/internal/headers.js +7 -5
  83. package/internal/headers.js.map +1 -1
  84. package/internal/headers.mjs +7 -5
  85. package/internal/headers.mjs.map +1 -1
  86. package/internal/parse.d.mts +3 -1
  87. package/internal/parse.d.mts.map +1 -1
  88. package/internal/parse.d.ts +3 -1
  89. package/internal/parse.d.ts.map +1 -1
  90. package/internal/parse.js +33 -21
  91. package/internal/parse.js.map +1 -1
  92. package/internal/parse.mjs +33 -20
  93. package/internal/parse.mjs.map +1 -1
  94. package/internal/qs/formats.d.mts +1 -0
  95. package/internal/qs/formats.d.mts.map +1 -1
  96. package/internal/qs/formats.d.ts +1 -0
  97. package/internal/qs/formats.d.ts.map +1 -1
  98. package/internal/qs/formats.js +4 -2
  99. package/internal/qs/formats.js.map +1 -1
  100. package/internal/qs/formats.mjs +2 -1
  101. package/internal/qs/formats.mjs.map +1 -1
  102. package/internal/qs/stringify.d.mts.map +1 -1
  103. package/internal/qs/stringify.d.ts.map +1 -1
  104. package/internal/qs/stringify.js +16 -19
  105. package/internal/qs/stringify.js.map +1 -1
  106. package/internal/qs/stringify.mjs +17 -19
  107. package/internal/qs/stringify.mjs.map +1 -1
  108. package/internal/qs/utils.d.mts +1 -0
  109. package/internal/qs/utils.d.mts.map +1 -1
  110. package/internal/qs/utils.d.ts +1 -0
  111. package/internal/qs/utils.d.ts.map +1 -1
  112. package/internal/qs/utils.js +22 -21
  113. package/internal/qs/utils.js.map +1 -1
  114. package/internal/qs/utils.mjs +12 -12
  115. package/internal/qs/utils.mjs.map +1 -1
  116. package/internal/request-options.d.mts +43 -2
  117. package/internal/request-options.d.mts.map +1 -1
  118. package/internal/request-options.d.ts +43 -2
  119. package/internal/request-options.d.ts.map +1 -1
  120. package/internal/request-options.js +1 -26
  121. package/internal/request-options.js.map +1 -1
  122. package/internal/request-options.mjs +0 -24
  123. package/internal/request-options.mjs.map +1 -1
  124. package/internal/shim-types.d.mts +11 -22
  125. package/internal/shim-types.d.mts.map +1 -0
  126. package/internal/shim-types.d.ts +11 -22
  127. package/internal/shim-types.d.ts.map +1 -0
  128. package/internal/shim-types.js +4 -0
  129. package/internal/shim-types.js.map +1 -0
  130. package/internal/shim-types.mjs +3 -0
  131. package/internal/shim-types.mjs.map +1 -0
  132. package/internal/shims.d.mts +7 -48
  133. package/internal/shims.d.mts.map +1 -1
  134. package/internal/shims.d.ts +7 -48
  135. package/internal/shims.d.ts.map +1 -1
  136. package/internal/shims.js +21 -30
  137. package/internal/shims.js.map +1 -1
  138. package/internal/shims.mjs +16 -23
  139. package/internal/shims.mjs.map +1 -1
  140. package/internal/to-file.d.mts +45 -0
  141. package/internal/to-file.d.mts.map +1 -0
  142. package/internal/to-file.d.ts +45 -0
  143. package/internal/to-file.d.ts.map +1 -0
  144. package/internal/to-file.js +91 -0
  145. package/internal/to-file.js.map +1 -0
  146. package/internal/to-file.mjs +88 -0
  147. package/internal/to-file.mjs.map +1 -0
  148. package/internal/tslib.js +81 -0
  149. package/internal/tslib.mjs +17 -0
  150. package/internal/types.d.mts +14 -13
  151. package/internal/types.d.mts.map +1 -1
  152. package/internal/types.d.ts +14 -13
  153. package/internal/types.d.ts.map +1 -1
  154. package/internal/uploads.d.mts +16 -47
  155. package/internal/uploads.d.mts.map +1 -1
  156. package/internal/uploads.d.ts +16 -47
  157. package/internal/uploads.d.ts.map +1 -1
  158. package/internal/uploads.js +41 -108
  159. package/internal/uploads.js.map +1 -1
  160. package/internal/uploads.mjs +39 -108
  161. package/internal/uploads.mjs.map +1 -1
  162. package/internal/utils/base64.d.mts.map +1 -1
  163. package/internal/utils/base64.d.ts.map +1 -1
  164. package/internal/utils/base64.js +13 -8
  165. package/internal/utils/base64.js.map +1 -1
  166. package/internal/utils/base64.mjs +13 -8
  167. package/internal/utils/base64.mjs.map +1 -1
  168. package/internal/utils/bytes.d.mts +4 -0
  169. package/internal/utils/bytes.d.mts.map +1 -0
  170. package/internal/utils/bytes.d.ts +4 -0
  171. package/internal/utils/bytes.d.ts.map +1 -0
  172. package/internal/utils/bytes.js +31 -0
  173. package/internal/utils/bytes.js.map +1 -0
  174. package/internal/utils/bytes.mjs +26 -0
  175. package/internal/utils/bytes.mjs.map +1 -0
  176. package/internal/utils/env.d.mts.map +1 -1
  177. package/internal/utils/env.d.ts.map +1 -1
  178. package/internal/utils/env.js.map +1 -1
  179. package/internal/utils/env.mjs.map +1 -1
  180. package/internal/utils/log.d.mts +35 -2
  181. package/internal/utils/log.d.mts.map +1 -1
  182. package/internal/utils/log.d.ts +35 -2
  183. package/internal/utils/log.d.ts.map +1 -1
  184. package/internal/utils/log.js +62 -24
  185. package/internal/utils/log.js.map +1 -1
  186. package/internal/utils/log.mjs +58 -22
  187. package/internal/utils/log.mjs.map +1 -1
  188. package/internal/utils/path.d.mts +15 -0
  189. package/internal/utils/path.d.mts.map +1 -0
  190. package/internal/utils/path.d.ts +15 -0
  191. package/internal/utils/path.d.ts.map +1 -0
  192. package/internal/utils/path.js +79 -0
  193. package/internal/utils/path.js.map +1 -0
  194. package/internal/utils/path.mjs +74 -0
  195. package/internal/utils/path.mjs.map +1 -0
  196. package/internal/utils/sleep.d.mts.map +1 -1
  197. package/internal/utils/sleep.d.ts.map +1 -1
  198. package/internal/utils/uuid.d.mts +1 -1
  199. package/internal/utils/uuid.d.mts.map +1 -1
  200. package/internal/utils/uuid.d.ts +1 -1
  201. package/internal/utils/uuid.d.ts.map +1 -1
  202. package/internal/utils/uuid.js +10 -6
  203. package/internal/utils/uuid.js.map +1 -1
  204. package/internal/utils/uuid.mjs +9 -5
  205. package/internal/utils/uuid.mjs.map +1 -1
  206. package/internal/utils/values.d.mts +4 -1
  207. package/internal/utils/values.d.mts.map +1 -1
  208. package/internal/utils/values.d.ts +4 -1
  209. package/internal/utils/values.d.ts.map +1 -1
  210. package/internal/utils/values.js +21 -9
  211. package/internal/utils/values.js.map +1 -1
  212. package/internal/utils/values.mjs +14 -4
  213. package/internal/utils/values.mjs.map +1 -1
  214. package/internal/utils.js +7 -20
  215. package/internal/utils.js.map +1 -1
  216. package/package.json +31 -13
  217. package/resource.d.mts +1 -5
  218. package/resource.d.mts.map +1 -1
  219. package/resource.d.ts +1 -5
  220. package/resource.d.ts.map +1 -1
  221. package/resource.js +3 -8
  222. package/resource.js.map +1 -1
  223. package/resource.mjs +1 -6
  224. package/resource.mjs.map +1 -1
  225. package/resources/call.d.mts +17 -7
  226. package/resources/call.d.mts.map +1 -1
  227. package/resources/call.d.ts +17 -7
  228. package/resources/call.d.ts.map +1 -1
  229. package/resources/call.js +6 -5
  230. package/resources/call.js.map +1 -1
  231. package/resources/call.mjs +6 -5
  232. package/resources/call.mjs.map +1 -1
  233. package/resources/evaluation.d.mts +20 -8
  234. package/resources/evaluation.d.mts.map +1 -1
  235. package/resources/evaluation.d.ts +20 -8
  236. package/resources/evaluation.d.ts.map +1 -1
  237. package/resources/evaluation.js +5 -4
  238. package/resources/evaluation.js.map +1 -1
  239. package/resources/evaluation.mjs +5 -4
  240. package/resources/evaluation.mjs.map +1 -1
  241. package/resources/health.d.mts +2 -2
  242. package/resources/health.d.ts +2 -2
  243. package/resources/health.js +1 -1
  244. package/resources/health.js.map +1 -1
  245. package/resources/health.mjs +1 -1
  246. package/resources/integrations.d.mts +39 -6
  247. package/resources/integrations.d.mts.map +1 -1
  248. package/resources/integrations.d.ts +39 -6
  249. package/resources/integrations.d.ts.map +1 -1
  250. package/resources/integrations.js +26 -1
  251. package/resources/integrations.js.map +1 -1
  252. package/resources/integrations.mjs +26 -1
  253. package/resources/integrations.mjs.map +1 -1
  254. package/resources/metric.d.mts +2 -2
  255. package/resources/metric.d.ts +2 -2
  256. package/resources/metric.js +1 -1
  257. package/resources/metric.js.map +1 -1
  258. package/resources/metric.mjs +1 -1
  259. package/resources/persona.d.mts +45 -8
  260. package/resources/persona.d.mts.map +1 -1
  261. package/resources/persona.d.ts +45 -8
  262. package/resources/persona.d.ts.map +1 -1
  263. package/resources/persona.js +29 -3
  264. package/resources/persona.js.map +1 -1
  265. package/resources/persona.mjs +29 -3
  266. package/resources/persona.mjs.map +1 -1
  267. package/resources/simulation.d.mts +51 -5
  268. package/resources/simulation.d.mts.map +1 -1
  269. package/resources/simulation.d.ts +51 -5
  270. package/resources/simulation.d.ts.map +1 -1
  271. package/resources/simulation.js +45 -4
  272. package/resources/simulation.js.map +1 -1
  273. package/resources/simulation.mjs +45 -4
  274. package/resources/simulation.mjs.map +1 -1
  275. package/resources.d.mts +2 -0
  276. package/resources.d.mts.map +1 -0
  277. package/resources.d.ts +2 -0
  278. package/resources.d.ts.map +1 -0
  279. package/resources.js +5 -0
  280. package/resources.js.map +1 -0
  281. package/resources.mjs +2 -0
  282. package/resources.mjs.map +1 -0
  283. package/src/api-promise.ts +2 -92
  284. package/src/client.ts +207 -116
  285. package/src/core/README.md +3 -0
  286. package/src/core/api-promise.ts +92 -0
  287. package/src/core/error.ts +130 -0
  288. package/src/core/resource.ts +11 -0
  289. package/src/core/uploads.ts +2 -0
  290. package/src/error.ts +2 -130
  291. package/src/index.ts +3 -3
  292. package/src/internal/README.md +3 -0
  293. package/src/internal/builtin-types.ts +14 -0
  294. package/src/internal/detect-platform.ts +3 -3
  295. package/src/internal/errors.ts +11 -0
  296. package/src/internal/headers.ts +9 -8
  297. package/src/internal/parse.ts +43 -28
  298. package/src/internal/qs/formats.ts +2 -1
  299. package/src/internal/qs/stringify.ts +17 -20
  300. package/src/internal/qs/utils.ts +14 -14
  301. package/src/internal/request-options.ts +55 -31
  302. package/src/internal/shim-types.ts +26 -0
  303. package/src/internal/shims.ts +20 -58
  304. package/src/internal/to-file.ts +154 -0
  305. package/src/internal/types.ts +14 -17
  306. package/src/internal/uploads.ts +60 -180
  307. package/src/internal/utils/base64.ts +14 -11
  308. package/src/internal/utils/bytes.ts +32 -0
  309. package/src/internal/utils/log.ts +100 -23
  310. package/src/internal/utils/path.ts +88 -0
  311. package/src/internal/utils/uuid.ts +10 -6
  312. package/src/internal/utils/values.ts +16 -5
  313. package/src/resource.ts +2 -11
  314. package/src/resources/call.ts +12 -11
  315. package/src/resources/evaluation.ts +12 -11
  316. package/src/resources/health.ts +2 -2
  317. package/src/resources/integrations.ts +31 -6
  318. package/src/resources/metric.ts +2 -2
  319. package/src/resources/persona.ts +36 -10
  320. package/src/resources/simulation.ts +49 -8
  321. package/src/resources.ts +1 -0
  322. package/src/uploads.ts +2 -1
  323. package/src/version.ts +1 -1
  324. package/uploads.d.mts +1 -1
  325. package/uploads.d.mts.map +1 -1
  326. package/uploads.d.ts +1 -1
  327. package/uploads.d.ts.map +1 -1
  328. package/uploads.js +3 -3
  329. package/uploads.js.map +1 -1
  330. package/uploads.mjs +1 -1
  331. package/uploads.mjs.map +1 -1
  332. package/version.d.mts +1 -1
  333. package/version.d.ts +1 -1
  334. package/version.js +1 -1
  335. package/version.mjs +1 -1
  336. package/internal/polyfill/crypto.node.d.ts +0 -10
  337. package/internal/polyfill/crypto.node.js +0 -11
  338. package/internal/polyfill/crypto.node.mjs +0 -2
  339. package/internal/polyfill/file.node.d.ts +0 -9
  340. package/internal/polyfill/file.node.js +0 -17
  341. package/internal/polyfill/file.node.mjs +0 -9
  342. package/src/internal/polyfill/crypto.node.d.ts +0 -10
  343. package/src/internal/polyfill/crypto.node.js +0 -11
  344. package/src/internal/polyfill/crypto.node.mjs +0 -2
  345. package/src/internal/polyfill/file.node.d.ts +0 -9
  346. package/src/internal/polyfill/file.node.js +0 -17
  347. package/src/internal/polyfill/file.node.mjs +0 -9
  348. package/src/internal/shim-types.d.ts +0 -28
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.21.2 (2026-02-11)
4
+
5
+ Full Changelog: [v2.21.1...v2.21.2](https://github.com/roarkhq/sdk-roark-analytics-node/compare/v2.21.1...v2.21.2)
6
+
7
+ ### Chores
8
+
9
+ * **internal:** codegen related update ([6fb1d9f](https://github.com/roarkhq/sdk-roark-analytics-node/commit/6fb1d9fa50d1a5ca32c64b6a6f48e295eccbbaa9))
10
+
3
11
  ## 2.21.1 (2026-02-10)
4
12
 
5
13
  Full Changelog: [v2.21.0...v2.21.1](https://github.com/roarkhq/sdk-roark-analytics-node/compare/v2.21.0...v2.21.1)
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Roark TypeScript API Library
2
2
 
3
- [![NPM version](https://img.shields.io/npm/v/@roarkanalytics/sdk.svg)](https://npmjs.org/package/@roarkanalytics/sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@roarkanalytics/sdk)
3
+ [![NPM version](<https://img.shields.io/npm/v/@roarkanalytics/sdk.svg?label=npm%20(stable)>)](https://npmjs.org/package/@roarkanalytics/sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@roarkanalytics/sdk)
4
4
 
5
5
  This library provides convenient access to the Roark REST API from server-side TypeScript or JavaScript.
6
6
 
7
7
  The REST API documentation can be found on [docs.roark.ai](https://docs.roark.ai). The full API of this library can be found in [api.md](api.md).
8
8
 
9
- It is generated with [Stainless](https://www.stainlessapi.com/).
9
+ It is generated with [Stainless](https://www.stainless.com/).
10
10
 
11
11
  ## Installation
12
12
 
@@ -26,13 +26,9 @@ const client = new Roark({
26
26
  bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
27
27
  });
28
28
 
29
- async function main() {
30
- const response = await client.evaluation.createJob({ evaluators: ['string'] });
29
+ const response = await client.evaluation.createJob({ evaluators: ['string'] });
31
30
 
32
- console.log(response.data);
33
- }
34
-
35
- main();
31
+ console.log(response.data);
36
32
  ```
37
33
 
38
34
  ### Request & Response types
@@ -47,12 +43,8 @@ const client = new Roark({
47
43
  bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
48
44
  });
49
45
 
50
- async function main() {
51
- const params: Roark.EvaluationCreateJobParams = { evaluators: ['string'] };
52
- const response: Roark.EvaluationCreateJobResponse = await client.evaluation.createJob(params);
53
- }
54
-
55
- main();
46
+ const params: Roark.EvaluationCreateJobParams = { evaluators: ['string'] };
47
+ const response: Roark.EvaluationCreateJobResponse = await client.evaluation.createJob(params);
56
48
  ```
57
49
 
58
50
  Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -65,8 +57,9 @@ a subclass of `APIError` will be thrown:
65
57
 
66
58
  <!-- prettier-ignore -->
67
59
  ```ts
68
- async function main() {
69
- const response = await client.evaluation.createJob({ evaluators: ['string'] }).catch(async (err) => {
60
+ const response = await client.evaluation
61
+ .createJob({ evaluators: ['string'] })
62
+ .catch(async (err) => {
70
63
  if (err instanceof Roark.APIError) {
71
64
  console.log(err.status); // 400
72
65
  console.log(err.name); // BadRequestError
@@ -75,12 +68,9 @@ async function main() {
75
68
  throw err;
76
69
  }
77
70
  });
78
- }
79
-
80
- main();
81
71
  ```
82
72
 
83
- Error codes are as followed:
73
+ Error codes are as follows:
84
74
 
85
75
  | Status Code | Error Type |
86
76
  | ----------- | -------------------------- |
@@ -140,8 +130,10 @@ Note that requests which time out will be [retried twice by default](#retries).
140
130
  ### Accessing raw Response data (e.g., headers)
141
131
 
142
132
  The "raw" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.
133
+ This method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.
143
134
 
144
135
  You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.
136
+ Unlike `.asResponse()` this method consumes the body, returning once it is parsed.
145
137
 
146
138
  <!-- prettier-ignore -->
147
139
  ```ts
@@ -158,6 +150,59 @@ console.log(raw.headers.get('X-My-Header'));
158
150
  console.log(response.data);
159
151
  ```
160
152
 
153
+ ### Logging
154
+
155
+ > [!IMPORTANT]
156
+ > All log messages are intended for debugging only. The format and content of log messages
157
+ > may change between releases.
158
+
159
+ #### Log levels
160
+
161
+ The log level can be configured in two ways:
162
+
163
+ 1. Via the `ROARK_LOG` environment variable
164
+ 2. Using the `logLevel` client option (overrides the environment variable if set)
165
+
166
+ ```ts
167
+ import Roark from '@roarkanalytics/sdk';
168
+
169
+ const client = new Roark({
170
+ logLevel: 'debug', // Show all log messages
171
+ });
172
+ ```
173
+
174
+ Available log levels, from most to least verbose:
175
+
176
+ - `'debug'` - Show debug messages, info, warnings, and errors
177
+ - `'info'` - Show info messages, warnings, and errors
178
+ - `'warn'` - Show warnings and errors (default)
179
+ - `'error'` - Show only errors
180
+ - `'off'` - Disable all logging
181
+
182
+ At the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.
183
+ Some authentication-related headers are redacted, but sensitive data in request and response bodies
184
+ may still be visible.
185
+
186
+ #### Custom logger
187
+
188
+ By default, this library logs to `globalThis.console`. You can also provide a custom logger.
189
+ Most logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.
190
+
191
+ When providing a custom logger, the `logLevel` option still controls which messages are emitted, messages
192
+ below the configured level will not be sent to your logger.
193
+
194
+ ```ts
195
+ import Roark from '@roarkanalytics/sdk';
196
+ import pino from 'pino';
197
+
198
+ const logger = pino();
199
+
200
+ const client = new Roark({
201
+ logger: logger.child({ name: 'Roark' }),
202
+ logLevel: 'debug', // Send all messages to pino, allowing it to filter
203
+ });
204
+ ```
205
+
161
206
  ### Making custom/undocumented requests
162
207
 
163
208
  This library is typed for convenient access to the documented API. If you need to access undocumented
@@ -182,9 +227,8 @@ parameter. This library doesn't validate at runtime that the request matches the
182
227
  send will be sent as-is.
183
228
 
184
229
  ```ts
185
- client.foo.create({
186
- foo: 'my_param',
187
- bar: 12,
230
+ client.evaluation.createJob({
231
+ // ...
188
232
  // @ts-expect-error baz is not yet public
189
233
  baz: 'undocumented option',
190
234
  });
@@ -217,33 +261,12 @@ globalThis.fetch = fetch;
217
261
  Or pass it to the client:
218
262
 
219
263
  ```ts
264
+ import Roark from '@roarkanalytics/sdk';
220
265
  import fetch from 'my-fetch';
221
266
 
222
267
  const client = new Roark({ fetch });
223
268
  ```
224
269
 
225
- ### Logging and middleware
226
-
227
- You may also provide a custom `fetch` function when instantiating the client,
228
- which can be used to inspect or alter the `Request` or `Response` before/after each request:
229
-
230
- ```ts
231
- import { fetch } from 'undici'; // as one example
232
- import Roark from '@roarkanalytics/sdk';
233
-
234
- const client = new Roark({
235
- fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
236
- console.log('About to make a request', url, init);
237
- const response = await fetch(url, init);
238
- console.log('Got response', response);
239
- return response;
240
- },
241
- });
242
- ```
243
-
244
- Note that if given a `ROARK_LOG=debug` environment variable, this library will log all requests and responses automatically.
245
- This is intended for debugging purposes only and may change in the future without notice.
246
-
247
270
  ### Fetch options
248
271
 
249
272
  If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
@@ -323,7 +346,7 @@ TypeScript >= 4.9 is supported.
323
346
  The following runtimes are supported:
324
347
 
325
348
  - Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
326
- - Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
349
+ - Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
327
350
  - Deno v1.28.0 or higher.
328
351
  - Bun 1.0 or later.
329
352
  - Cloudflare Workers.
package/api-promise.d.mts CHANGED
@@ -1,47 +1,2 @@
1
-
2
- import { type Roark } from "./client.mjs";
3
- import { type PromiseOrValue } from "./internal/types.mjs";
4
- import { APIResponseProps } from "./internal/parse.mjs";
5
- /**
6
- * A subclass of `Promise` providing additional helper methods
7
- * for interacting with the SDK.
8
- */
9
- export declare class APIPromise<T> extends Promise<T> {
10
- #private;
11
- private responsePromise;
12
- private parseResponse;
13
- private parsedPromise;
14
- constructor(client: Roark, responsePromise: Promise<APIResponseProps>, parseResponse?: (client: Roark, props: APIResponseProps) => PromiseOrValue<T>);
15
- _thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
16
- /**
17
- * Gets the raw `Response` instance instead of parsing the response
18
- * data.
19
- *
20
- * If you want to parse the response body but still get the `Response`
21
- * instance, you can use {@link withResponse()}.
22
- *
23
- * 👋 Getting the wrong TypeScript type for `Response`?
24
- * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
25
- * to your `tsconfig.json`.
26
- */
27
- asResponse(): Promise<Response>;
28
- /**
29
- * Gets the parsed response data and the raw `Response` instance.
30
- *
31
- * If you just want to get the raw `Response` instance without parsing it,
32
- * you can use {@link asResponse()}.
33
- *
34
- * 👋 Getting the wrong TypeScript type for `Response`?
35
- * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
36
- * to your `tsconfig.json`.
37
- */
38
- withResponse(): Promise<{
39
- data: T;
40
- response: Response;
41
- }>;
42
- private parse;
43
- then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
44
- catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
45
- finally(onfinally?: (() => void) | undefined | null): Promise<T>;
46
- }
1
+ export * from "./core/api-promise.mjs";
47
2
  //# sourceMappingURL=api-promise.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-promise.d.mts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":";OAEO,EAAE,KAAK,KAAK,EAAE;OAEd,EAAE,KAAK,cAAc,EAAE;OACvB,EAAE,gBAAgB,EAAwB;AAEjD;;;GAGG;AACH,qBAAa,UAAU,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;;IAMzC,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,aAAa;IANvB,OAAO,CAAC,aAAa,CAAyB;gBAI5C,MAAM,EAAE,KAAK,EACL,eAAe,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAC1C,aAAa,GAAE,CACrB,MAAM,EAAE,KAAK,EACb,KAAK,EAAE,gBAAgB,KACpB,cAAc,CAAC,CAAC,CAAwB;IAW/C,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,KAAK,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAMjF;;;;;;;;;;OAUG;IACH,UAAU,IAAI,OAAO,CAAC,QAAQ,CAAC;IAI/B;;;;;;;;;OASG;IACG,YAAY,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC;IAK9D,OAAO,CAAC,KAAK;IAOJ,IAAI,CAAC,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,EAC1C,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,EACjF,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAClF,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAItB,KAAK,CAAC,OAAO,GAAG,KAAK,EAC5B,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAChF,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;IAId,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;CAG1E"}
1
+ {"version":3,"file":"api-promise.d.mts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
package/api-promise.d.ts CHANGED
@@ -1,47 +1,2 @@
1
-
2
- import { type Roark } from "./client.js";
3
- import { type PromiseOrValue } from "./internal/types.js";
4
- import { APIResponseProps } from "./internal/parse.js";
5
- /**
6
- * A subclass of `Promise` providing additional helper methods
7
- * for interacting with the SDK.
8
- */
9
- export declare class APIPromise<T> extends Promise<T> {
10
- #private;
11
- private responsePromise;
12
- private parseResponse;
13
- private parsedPromise;
14
- constructor(client: Roark, responsePromise: Promise<APIResponseProps>, parseResponse?: (client: Roark, props: APIResponseProps) => PromiseOrValue<T>);
15
- _thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
16
- /**
17
- * Gets the raw `Response` instance instead of parsing the response
18
- * data.
19
- *
20
- * If you want to parse the response body but still get the `Response`
21
- * instance, you can use {@link withResponse()}.
22
- *
23
- * 👋 Getting the wrong TypeScript type for `Response`?
24
- * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
25
- * to your `tsconfig.json`.
26
- */
27
- asResponse(): Promise<Response>;
28
- /**
29
- * Gets the parsed response data and the raw `Response` instance.
30
- *
31
- * If you just want to get the raw `Response` instance without parsing it,
32
- * you can use {@link asResponse()}.
33
- *
34
- * 👋 Getting the wrong TypeScript type for `Response`?
35
- * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
36
- * to your `tsconfig.json`.
37
- */
38
- withResponse(): Promise<{
39
- data: T;
40
- response: Response;
41
- }>;
42
- private parse;
43
- then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
44
- catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
45
- finally(onfinally?: (() => void) | undefined | null): Promise<T>;
46
- }
1
+ export * from "./core/api-promise.js";
47
2
  //# sourceMappingURL=api-promise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-promise.d.ts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":";OAEO,EAAE,KAAK,KAAK,EAAE;OAEd,EAAE,KAAK,cAAc,EAAE;OACvB,EAAE,gBAAgB,EAAwB;AAEjD;;;GAGG;AACH,qBAAa,UAAU,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;;IAMzC,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,aAAa;IANvB,OAAO,CAAC,aAAa,CAAyB;gBAI5C,MAAM,EAAE,KAAK,EACL,eAAe,EAAE,OAAO,CAAC,gB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
package/api-promise.js CHANGED
@@ -1,84 +1,6 @@
1
1
  "use strict";
2
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
4
- if (kind === "m") throw new TypeError("Private method is not writable");
5
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
7
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
8
- };
9
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
12
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13
- };
14
- var _APIPromise_client;
15
2
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.APIPromise = void 0;
17
- const parse_1 = require("./internal/parse.js");
18
- /**
19
- * A subclass of `Promise` providing additional helper methods
20
- * for interacting with the SDK.
21
- */
22
- class APIPromise extends Promise {
23
- constructor(client, responsePromise, parseResponse = parse_1.defaultParseResponse) {
24
- super((resolve) => {
25
- // this is maybe a bit weird but this has to be a no-op to not implicitly
26
- // parse the response body; instead .then, .catch, .finally are overridden
27
- // to parse the response
28
- resolve(null);
29
- });
30
- this.responsePromise = responsePromise;
31
- this.parseResponse = parseResponse;
32
- _APIPromise_client.set(this, void 0);
33
- __classPrivateFieldSet(this, _APIPromise_client, client, "f");
34
- }
35
- _thenUnwrap(transform) {
36
- return new APIPromise(__classPrivateFieldGet(this, _APIPromise_client, "f"), this.responsePromise, async (client, props) => transform(await this.parseResponse(client, props), props));
37
- }
38
- /**
39
- * Gets the raw `Response` instance instead of parsing the response
40
- * data.
41
- *
42
- * If you want to parse the response body but still get the `Response`
43
- * instance, you can use {@link withResponse()}.
44
- *
45
- * 👋 Getting the wrong TypeScript type for `Response`?
46
- * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
47
- * to your `tsconfig.json`.
48
- */
49
- asResponse() {
50
- return this.responsePromise.then((p) => p.response);
51
- }
52
- /**
53
- * Gets the parsed response data and the raw `Response` instance.
54
- *
55
- * If you just want to get the raw `Response` instance without parsing it,
56
- * you can use {@link asResponse()}.
57
- *
58
- * 👋 Getting the wrong TypeScript type for `Response`?
59
- * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
60
- * to your `tsconfig.json`.
61
- */
62
- async withResponse() {
63
- const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
64
- return { data, response };
65
- }
66
- parse() {
67
- if (!this.parsedPromise) {
68
- this.parsedPromise = this.responsePromise.then((data) => this.parseResponse(__classPrivateFieldGet(this, _APIPromise_client, "f"), data));
69
- }
70
- return this.parsedPromise;
71
- }
72
- then(onfulfilled, onrejected) {
73
- return this.parse().then(onfulfilled, onrejected);
74
- }
75
- catch(onrejected) {
76
- return this.parse().catch(onrejected);
77
- }
78
- finally(onfinally) {
79
- return this.parse().finally(onfinally);
80
- }
81
- }
82
- exports.APIPromise = APIPromise;
83
- _APIPromise_client = new WeakMap();
3
+ const tslib_1 = require("./internal/tslib.js");
4
+ /** @deprecated Import from ./core/api-promise instead */
5
+ tslib_1.__exportStar(require("./core/api-promise.js"), exports);
84
6
  //# sourceMappingURL=api-promise.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-promise.js","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;AAKtF,+CAA0E;AAE1E;;;GAGG;AACH,MAAa,UAAc,SAAQ,OAAU;IAI3C,YACE,MAAa,EACL,eAA0C,EAC1C,gBAGiB,4BAAoB;QAE7C,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE;YAChB,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mF;QAEnF,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpD,CAAC;IAEQ,KAAK,CACZ,UAAiF;QAEjF,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAEQ,OAAO,CAAC,SAA2C;QAC1D,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;CACF;AAhFD,gCAgFC"}
1
+ {"version":3,"file":"api-promise.js","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,gEAAmC"}
package/api-promise.mjs CHANGED
@@ -1,80 +1,2 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _APIPromise_client;
14
- import { defaultParseResponse } from "./internal/parse.mjs";
15
- /**
16
- * A subclass of `Promise` providing additional helper methods
17
- * for interacting with the SDK.
18
- */
19
- export class APIPromise extends Promise {
20
- constructor(client, responsePromise, parseResponse = defaultParseResponse) {
21
- super((resolve) => {
22
- // this is maybe a bit weird but this has to be a no-op to not implicitly
23
- // parse the response body; instead .then, .catch, .finally are overridden
24
- // to parse the response
25
- resolve(null);
26
- });
27
- this.responsePromise = responsePromise;
28
- this.parseResponse = parseResponse;
29
- _APIPromise_client.set(this, void 0);
30
- __classPrivateFieldSet(this, _APIPromise_client, client, "f");
31
- }
32
- _thenUnwrap(transform) {
33
- return new APIPromise(__classPrivateFieldGet(this, _APIPromise_client, "f"), this.responsePromise, async (client, props) => transform(await this.parseResponse(client, props), props));
34
- }
35
- /**
36
- * Gets the raw `Response` instance instead of parsing the response
37
- * data.
38
- *
39
- * If you want to parse the response body but still get the `Response`
40
- * instance, you can use {@link withResponse()}.
41
- *
42
- * 👋 Getting the wrong TypeScript type for `Response`?
43
- * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
44
- * to your `tsconfig.json`.
45
- */
46
- asResponse() {
47
- return this.responsePromise.then((p) => p.response);
48
- }
49
- /**
50
- * Gets the parsed response data and the raw `Response` instance.
51
- *
52
- * If you just want to get the raw `Response` instance without parsing it,
53
- * you can use {@link asResponse()}.
54
- *
55
- * 👋 Getting the wrong TypeScript type for `Response`?
56
- * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
57
- * to your `tsconfig.json`.
58
- */
59
- async withResponse() {
60
- const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
61
- return { data, response };
62
- }
63
- parse() {
64
- if (!this.parsedPromise) {
65
- this.parsedPromise = this.responsePromise.then((data) => this.parseResponse(__classPrivateFieldGet(this, _APIPromise_client, "f"), data));
66
- }
67
- return this.parsedPromise;
68
- }
69
- then(onfulfilled, onrejected) {
70
- return this.parse().then(onfulfilled, onrejected);
71
- }
72
- catch(onrejected) {
73
- return this.parse().catch(onrejected);
74
- }
75
- finally(onfinally) {
76
- return this.parse().finally(onfinally);
77
- }
78
- }
79
- _APIPromise_client = new WeakMap();
1
+ export * from "./core/api-promise.mjs";
80
2
  //# sourceMappingURL=api-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AAK;QACX,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,uBAAA,IAAI,0BAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;SAClG;QACD,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAEQ,IAAI,CACX,WAAiF,EACjF,UAAmF;QAEnF,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpD,CAAC;IAEQ,KAAK,CACZ,UAAiF;QAEjF,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAEQ,OAAO,CAAC,SAA2C;QAC1D,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;CACF"}
1
+ {"version":3,"file":"api-promise.mjs","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
package/client.d.mts CHANGED
@@ -1,14 +1,11 @@
1
-
2
1
  import type { RequestInit, RequestInfo } from "./internal/builtin-types.mjs";
3
- import type { PromiseOrValue, MergedRequestInit } from "./internal/types.mjs";
2
+ import type { PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from "./internal/types.mjs";
3
+ export type { Logger, LogLevel } from "./internal/utils/log.mjs";
4
4
  import * as Opts from "./internal/request-options.mjs";
5
- import * as Errors from "./error.mjs";
6
- import * as Uploads from "./uploads.mjs";
5
+ import * as Errors from "./core/error.mjs";
6
+ import * as Uploads from "./core/uploads.mjs";
7
7
  import * as API from "./resources/index.mjs";
8
- import { APIPromise } from "./api-promise.mjs";
9
- import { type Fetch } from "./internal/builtin-types.mjs";
10
- import { HeadersLike, NullableHeaders } from "./internal/headers.mjs";
11
- import { FinalRequestOptions, RequestOptions } from "./internal/request-options.mjs";
8
+ import { APIPromise } from "./core/api-promise.mjs";
12
9
  import { Call, CallCreateParams, CallCreateResponse, CallGetByIDResponse, CallListEvaluationRunsResponse, CallListMetricsParams, CallListMetricsResponse, CallListParams, CallListResponse, CallListSentimentRunsResponse } from "./resources/call.mjs";
13
10
  import { Evaluation, EvaluationCreateJobParams, EvaluationCreateJobResponse, EvaluationGetEvaluatorByIDResponse, EvaluationGetJobResponse, EvaluationListEvaluatorsParams, EvaluationListEvaluatorsResponse, EvaluationListJobRunsParams, EvaluationListJobRunsResponse } from "./resources/evaluation.mjs";
14
11
  import { Health, HealthGetResponse } from "./resources/health.mjs";
@@ -16,14 +13,10 @@ import { IntegrationCreateRetellCallParams, IntegrationCreateRetellCallResponse,
16
13
  import { Metric, MetricListDefinitionsResponse } from "./resources/metric.mjs";
17
14
  import { Persona, PersonaCreateParams, PersonaCreateResponse, PersonaGetByIDResponse, PersonaListParams, PersonaListResponse, PersonaUpdateParams, PersonaUpdateResponse } from "./resources/persona.mjs";
18
15
  import { Simulation, SimulationGetRunPlanJobResponse, SimulationGetSimulationJobByIDResponse, SimulationListRunPlanJobsParams, SimulationListRunPlanJobsResponse, SimulationListScenariosParams, SimulationListScenariosResponse, SimulationLookupSimulationJobParams, SimulationLookupSimulationJobResponse, SimulationStartRunPlanJobResponse } from "./resources/simulation.mjs";
19
- type LogFn = (message: string, ...rest: unknown[]) => void;
20
- export type Logger = {
21
- error: LogFn;
22
- warn: LogFn;
23
- info: LogFn;
24
- debug: LogFn;
25
- };
26
- export type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug';
16
+ import { type Fetch } from "./internal/builtin-types.mjs";
17
+ import { HeadersLike, NullableHeaders } from "./internal/headers.mjs";
18
+ import { FinalRequestOptions, RequestOptions } from "./internal/request-options.mjs";
19
+ import { type LogLevel, type Logger } from "./internal/utils/log.mjs";
27
20
  export interface ClientOptions {
28
21
  /**
29
22
  * JWT token for authentication
@@ -41,6 +34,8 @@ export interface ClientOptions {
41
34
  *
42
35
  * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
43
36
  * much longer than this timeout before the promise succeeds or fails.
37
+ *
38
+ * @unit milliseconds
44
39
  */
45
40
  timeout?: number | undefined;
46
41
  /**
@@ -78,19 +73,16 @@ export interface ClientOptions {
78
73
  /**
79
74
  * Set the log level.
80
75
  *
81
- * Defaults to process.env['ROARK_LOG'].
76
+ * Defaults to process.env['ROARK_LOG'] or 'warn' if it isn't set.
82
77
  */
83
- logLevel?: LogLevel | undefined | null;
78
+ logLevel?: LogLevel | undefined;
84
79
  /**
85
80
  * Set the logger.
86
81
  *
87
82
  * Defaults to globalThis.console.
88
83
  */
89
- logger?: Logger | undefined | null;
84
+ logger?: Logger | undefined;
90
85
  }
91
- type FinalizedRequestInit = RequestInit & {
92
- headers: Headers;
93
- };
94
86
  /**
95
87
  * API Client for interfacing with the Roark API.
96
88
  */
@@ -100,7 +92,7 @@ export declare class Roark {
100
92
  baseURL: string;
101
93
  maxRetries: number;
102
94
  timeout: number;
103
- logger: Logger | undefined;
95
+ logger: Logger;
104
96
  logLevel: LogLevel | undefined;
105
97
  fetchOptions: MergedRequestInit | undefined;
106
98
  private fetch;
@@ -119,15 +111,18 @@ export declare class Roark {
119
111
  * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
120
112
  */
121
113
  constructor({ baseURL, bearerToken, ...opts }?: ClientOptions);
114
+ /**
115
+ * Create a new client instance re-using the same options given to the current client with optional overriding.
116
+ */
117
+ withOptions(options: Partial<ClientOptions>): this;
122
118
  protected defaultQuery(): Record<string, string | undefined> | undefined;
123
119
  protected validateHeaders({ values, nulls }: NullableHeaders): void;
124
- protected authHeaders(opts: FinalRequestOptions): Headers | undefined;
120
+ protected authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined>;
125
121
  protected stringifyQuery(query: Record<string, unknown>): string;
126
122
  private getUserAgent;
127
123
  protected defaultIdempotencyKey(): string;
128
124
  protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError;
129
- buildURL(path: string, query: Record<string, unknown> | null | undefined): string;
130
- private calculateContentLength;
125
+ buildURL(path: string, query: Record<string, unknown> | null | undefined, defaultBaseURL?: string | undefined): string;
131
126
  /**
132
127
  * Used as a callback for mutating the given `FinalRequestOptions` object.
133
128
  */
@@ -154,14 +149,15 @@ export declare class Roark {
154
149
  private shouldRetry;
155
150
  private retryRequest;
156
151
  private calculateDefaultRetryTimeoutMillis;
157
- buildRequest(options: FinalRequestOptions, { retryCount }?: {
152
+ buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: {
158
153
  retryCount?: number;
159
- }): {
154
+ }): Promise<{
160
155
  req: FinalizedRequestInit;
161
156
  url: string;
162
157
  timeout: number;
163
- };
158
+ }>;
164
159
  private buildHeaders;
160
+ private _makeAbort;
165
161
  private buildBody;
166
162
  static Roark: typeof Roark;
167
163
  static DEFAULT_TIMEOUT: number;
@@ -197,5 +193,4 @@ export declare namespace Roark {
197
193
  export { Simulation as Simulation, type SimulationGetRunPlanJobResponse as SimulationGetRunPlanJobResponse, type SimulationGetSimulationJobByIDResponse as SimulationGetSimulationJobByIDResponse, type SimulationListRunPlanJobsResponse as SimulationListRunPlanJobsResponse, type SimulationListScenariosResponse as SimulationListScenariosResponse, type SimulationLookupSimulationJobResponse as SimulationLookupSimulationJobResponse, type SimulationStartRunPlanJobResponse as SimulationStartRunPlanJobResponse, type SimulationListRunPlanJobsParams as SimulationListRunPlanJobsParams, type SimulationListScenariosParams as SimulationListScenariosParams, type SimulationLookupSimulationJobParams as SimulationLookupSimulationJobParams, };
198
194
  export { Persona as Persona, type PersonaCreateResponse as PersonaCreateResponse, type PersonaUpdateResponse as PersonaUpdateResponse, type PersonaListResponse as PersonaListResponse, type PersonaGetByIDResponse as PersonaGetByIDResponse, type PersonaCreateParams as PersonaCreateParams, type PersonaUpdateParams as PersonaUpdateParams, type PersonaListParams as PersonaListParams, };
199
195
  }
200
- export {};
201
196
  //# sourceMappingURL=client.d.mts.map