@roarkanalytics/sdk 2.21.1 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +78 -46
- package/api-promise.d.mts +1 -46
- package/api-promise.d.mts.map +1 -1
- package/api-promise.d.ts +1 -46
- package/api-promise.d.ts.map +1 -1
- package/api-promise.js +3 -81
- package/api-promise.js.map +1 -1
- package/api-promise.mjs +1 -79
- package/api-promise.mjs.map +1 -1
- package/client.d.mts +25 -30
- package/client.d.mts.map +1 -1
- package/client.d.ts +25 -30
- package/client.d.ts.map +1 -1
- package/client.js +150 -132
- package/client.js.map +1 -1
- package/client.mjs +145 -104
- package/client.mjs.map +1 -1
- package/core/api-promise.d.mts +46 -0
- package/core/api-promise.d.mts.map +1 -0
- package/core/api-promise.d.ts +46 -0
- package/core/api-promise.d.ts.map +1 -0
- package/core/api-promise.js +74 -0
- package/core/api-promise.js.map +1 -0
- package/core/api-promise.mjs +70 -0
- package/core/api-promise.mjs.map +1 -0
- package/core/error.d.mts +46 -0
- package/core/error.d.mts.map +1 -0
- package/core/error.d.ts +46 -0
- package/core/error.d.ts.map +1 -0
- package/core/error.js +113 -0
- package/core/error.js.map +1 -0
- package/core/error.mjs +97 -0
- package/core/error.mjs.map +1 -0
- package/core/resource.d.mts +6 -0
- package/core/resource.d.mts.map +1 -0
- package/core/resource.d.ts +6 -0
- package/core/resource.d.ts.map +1 -0
- package/core/resource.js +11 -0
- package/core/resource.js.map +1 -0
- package/core/resource.mjs +7 -0
- package/core/resource.mjs.map +1 -0
- package/core/uploads.d.mts +3 -0
- package/core/uploads.d.mts.map +1 -0
- package/core/uploads.d.ts +3 -0
- package/core/uploads.d.ts.map +1 -0
- package/core/uploads.js +6 -0
- package/core/uploads.js.map +1 -0
- package/core/uploads.mjs +2 -0
- package/core/uploads.mjs.map +1 -0
- package/error.d.mts +1 -46
- package/error.d.mts.map +1 -1
- package/error.d.ts +1 -46
- package/error.d.ts.map +1 -1
- package/error.js +3 -110
- package/error.js.map +1 -1
- package/error.mjs +1 -96
- package/error.mjs.map +1 -1
- package/index.d.mts +6 -6
- package/index.d.ts +3 -3
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/index.mjs +3 -3
- package/internal/builtin-types.d.mts +11 -3
- package/internal/builtin-types.d.mts.map +1 -1
- package/internal/builtin-types.d.ts +11 -3
- package/internal/builtin-types.d.ts.map +1 -1
- package/internal/detect-platform.js +3 -3
- package/internal/detect-platform.js.map +1 -1
- package/internal/detect-platform.mjs +3 -3
- package/internal/detect-platform.mjs.map +1 -1
- package/internal/errors.d.mts.map +1 -1
- package/internal/errors.d.ts.map +1 -1
- package/internal/errors.js +17 -2
- package/internal/errors.js.map +1 -1
- package/internal/errors.mjs +15 -0
- package/internal/errors.mjs.map +1 -1
- package/internal/headers.d.mts +1 -2
- package/internal/headers.d.mts.map +1 -1
- package/internal/headers.d.ts +1 -2
- package/internal/headers.d.ts.map +1 -1
- package/internal/headers.js +7 -5
- package/internal/headers.js.map +1 -1
- package/internal/headers.mjs +7 -5
- package/internal/headers.mjs.map +1 -1
- package/internal/parse.d.mts +3 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts +3 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +33 -21
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +33 -20
- package/internal/parse.mjs.map +1 -1
- package/internal/qs/formats.d.mts +1 -0
- package/internal/qs/formats.d.mts.map +1 -1
- package/internal/qs/formats.d.ts +1 -0
- package/internal/qs/formats.d.ts.map +1 -1
- package/internal/qs/formats.js +4 -2
- package/internal/qs/formats.js.map +1 -1
- package/internal/qs/formats.mjs +2 -1
- package/internal/qs/formats.mjs.map +1 -1
- package/internal/qs/stringify.d.mts.map +1 -1
- package/internal/qs/stringify.d.ts.map +1 -1
- package/internal/qs/stringify.js +16 -19
- package/internal/qs/stringify.js.map +1 -1
- package/internal/qs/stringify.mjs +17 -19
- package/internal/qs/stringify.mjs.map +1 -1
- package/internal/qs/utils.d.mts +1 -0
- package/internal/qs/utils.d.mts.map +1 -1
- package/internal/qs/utils.d.ts +1 -0
- package/internal/qs/utils.d.ts.map +1 -1
- package/internal/qs/utils.js +22 -21
- package/internal/qs/utils.js.map +1 -1
- package/internal/qs/utils.mjs +12 -12
- package/internal/qs/utils.mjs.map +1 -1
- package/internal/request-options.d.mts +43 -2
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +43 -2
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js +1 -26
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs +0 -24
- package/internal/request-options.mjs.map +1 -1
- package/internal/shim-types.d.mts +11 -22
- package/internal/shim-types.d.mts.map +1 -0
- package/internal/shim-types.d.ts +11 -22
- package/internal/shim-types.d.ts.map +1 -0
- package/internal/shim-types.js +4 -0
- package/internal/shim-types.js.map +1 -0
- package/internal/shim-types.mjs +3 -0
- package/internal/shim-types.mjs.map +1 -0
- package/internal/shims.d.mts +7 -48
- package/internal/shims.d.mts.map +1 -1
- package/internal/shims.d.ts +7 -48
- package/internal/shims.d.ts.map +1 -1
- package/internal/shims.js +21 -30
- package/internal/shims.js.map +1 -1
- package/internal/shims.mjs +16 -23
- package/internal/shims.mjs.map +1 -1
- package/internal/to-file.d.mts +45 -0
- package/internal/to-file.d.mts.map +1 -0
- package/internal/to-file.d.ts +45 -0
- package/internal/to-file.d.ts.map +1 -0
- package/internal/to-file.js +91 -0
- package/internal/to-file.js.map +1 -0
- package/internal/to-file.mjs +88 -0
- package/internal/to-file.mjs.map +1 -0
- package/internal/tslib.js +81 -0
- package/internal/tslib.mjs +17 -0
- package/internal/types.d.mts +14 -13
- package/internal/types.d.mts.map +1 -1
- package/internal/types.d.ts +14 -13
- package/internal/types.d.ts.map +1 -1
- package/internal/uploads.d.mts +16 -47
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +16 -47
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js +41 -108
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +39 -108
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/base64.d.mts.map +1 -1
- package/internal/utils/base64.d.ts.map +1 -1
- package/internal/utils/base64.js +13 -8
- package/internal/utils/base64.js.map +1 -1
- package/internal/utils/base64.mjs +13 -8
- package/internal/utils/base64.mjs.map +1 -1
- package/internal/utils/bytes.d.mts +4 -0
- package/internal/utils/bytes.d.mts.map +1 -0
- package/internal/utils/bytes.d.ts +4 -0
- package/internal/utils/bytes.d.ts.map +1 -0
- package/internal/utils/bytes.js +31 -0
- package/internal/utils/bytes.js.map +1 -0
- package/internal/utils/bytes.mjs +26 -0
- package/internal/utils/bytes.mjs.map +1 -0
- package/internal/utils/env.d.mts.map +1 -1
- package/internal/utils/env.d.ts.map +1 -1
- package/internal/utils/env.js.map +1 -1
- package/internal/utils/env.mjs.map +1 -1
- package/internal/utils/log.d.mts +35 -2
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts +35 -2
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js +62 -24
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +58 -22
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.d.mts +15 -0
- package/internal/utils/path.d.mts.map +1 -0
- package/internal/utils/path.d.ts +15 -0
- package/internal/utils/path.d.ts.map +1 -0
- package/internal/utils/path.js +79 -0
- package/internal/utils/path.js.map +1 -0
- package/internal/utils/path.mjs +74 -0
- package/internal/utils/path.mjs.map +1 -0
- package/internal/utils/sleep.d.mts.map +1 -1
- package/internal/utils/sleep.d.ts.map +1 -1
- package/internal/utils/uuid.d.mts +1 -1
- package/internal/utils/uuid.d.mts.map +1 -1
- package/internal/utils/uuid.d.ts +1 -1
- package/internal/utils/uuid.d.ts.map +1 -1
- package/internal/utils/uuid.js +10 -6
- package/internal/utils/uuid.js.map +1 -1
- package/internal/utils/uuid.mjs +9 -5
- package/internal/utils/uuid.mjs.map +1 -1
- package/internal/utils/values.d.mts +4 -1
- package/internal/utils/values.d.mts.map +1 -1
- package/internal/utils/values.d.ts +4 -1
- package/internal/utils/values.d.ts.map +1 -1
- package/internal/utils/values.js +21 -9
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +14 -4
- package/internal/utils/values.mjs.map +1 -1
- package/internal/utils.js +7 -20
- package/internal/utils.js.map +1 -1
- package/package.json +31 -13
- package/resource.d.mts +1 -5
- package/resource.d.mts.map +1 -1
- package/resource.d.ts +1 -5
- package/resource.d.ts.map +1 -1
- package/resource.js +3 -8
- package/resource.js.map +1 -1
- package/resource.mjs +1 -6
- package/resource.mjs.map +1 -1
- package/resources/call.d.mts +17 -7
- package/resources/call.d.mts.map +1 -1
- package/resources/call.d.ts +17 -7
- package/resources/call.d.ts.map +1 -1
- package/resources/call.js +6 -5
- package/resources/call.js.map +1 -1
- package/resources/call.mjs +6 -5
- package/resources/call.mjs.map +1 -1
- package/resources/evaluation.d.mts +20 -8
- package/resources/evaluation.d.mts.map +1 -1
- package/resources/evaluation.d.ts +20 -8
- package/resources/evaluation.d.ts.map +1 -1
- package/resources/evaluation.js +5 -4
- package/resources/evaluation.js.map +1 -1
- package/resources/evaluation.mjs +5 -4
- package/resources/evaluation.mjs.map +1 -1
- package/resources/health.d.mts +2 -2
- package/resources/health.d.ts +2 -2
- package/resources/health.js +1 -1
- package/resources/health.js.map +1 -1
- package/resources/health.mjs +1 -1
- package/resources/integrations.d.mts +39 -6
- package/resources/integrations.d.mts.map +1 -1
- package/resources/integrations.d.ts +39 -6
- package/resources/integrations.d.ts.map +1 -1
- package/resources/integrations.js +26 -1
- package/resources/integrations.js.map +1 -1
- package/resources/integrations.mjs +26 -1
- package/resources/integrations.mjs.map +1 -1
- package/resources/metric.d.mts +2 -2
- package/resources/metric.d.ts +2 -2
- package/resources/metric.js +1 -1
- package/resources/metric.js.map +1 -1
- package/resources/metric.mjs +1 -1
- package/resources/persona.d.mts +45 -8
- package/resources/persona.d.mts.map +1 -1
- package/resources/persona.d.ts +45 -8
- package/resources/persona.d.ts.map +1 -1
- package/resources/persona.js +29 -3
- package/resources/persona.js.map +1 -1
- package/resources/persona.mjs +29 -3
- package/resources/persona.mjs.map +1 -1
- package/resources/simulation.d.mts +51 -5
- package/resources/simulation.d.mts.map +1 -1
- package/resources/simulation.d.ts +51 -5
- package/resources/simulation.d.ts.map +1 -1
- package/resources/simulation.js +45 -4
- package/resources/simulation.js.map +1 -1
- package/resources/simulation.mjs +45 -4
- package/resources/simulation.mjs.map +1 -1
- package/resources.d.mts +2 -0
- package/resources.d.mts.map +1 -0
- package/resources.d.ts +2 -0
- package/resources.d.ts.map +1 -0
- package/resources.js +5 -0
- package/resources.js.map +1 -0
- package/resources.mjs +2 -0
- package/resources.mjs.map +1 -0
- package/src/api-promise.ts +2 -92
- package/src/client.ts +207 -116
- package/src/core/README.md +3 -0
- package/src/core/api-promise.ts +92 -0
- package/src/core/error.ts +130 -0
- package/src/core/resource.ts +11 -0
- package/src/core/uploads.ts +2 -0
- package/src/error.ts +2 -130
- package/src/index.ts +3 -3
- package/src/internal/README.md +3 -0
- package/src/internal/builtin-types.ts +14 -0
- package/src/internal/detect-platform.ts +3 -3
- package/src/internal/errors.ts +11 -0
- package/src/internal/headers.ts +9 -8
- package/src/internal/parse.ts +43 -28
- package/src/internal/qs/formats.ts +2 -1
- package/src/internal/qs/stringify.ts +17 -20
- package/src/internal/qs/utils.ts +14 -14
- package/src/internal/request-options.ts +55 -31
- package/src/internal/shim-types.ts +26 -0
- package/src/internal/shims.ts +20 -58
- package/src/internal/to-file.ts +154 -0
- package/src/internal/types.ts +14 -17
- package/src/internal/uploads.ts +60 -180
- package/src/internal/utils/base64.ts +14 -11
- package/src/internal/utils/bytes.ts +32 -0
- package/src/internal/utils/log.ts +100 -23
- package/src/internal/utils/path.ts +88 -0
- package/src/internal/utils/uuid.ts +10 -6
- package/src/internal/utils/values.ts +16 -5
- package/src/resource.ts +2 -11
- package/src/resources/call.ts +12 -11
- package/src/resources/evaluation.ts +12 -11
- package/src/resources/health.ts +2 -2
- package/src/resources/integrations.ts +31 -6
- package/src/resources/metric.ts +2 -2
- package/src/resources/persona.ts +36 -10
- package/src/resources/simulation.ts +49 -8
- package/src/resources.ts +1 -0
- package/src/uploads.ts +2 -1
- package/src/version.ts +1 -1
- package/uploads.d.mts +1 -1
- package/uploads.d.mts.map +1 -1
- package/uploads.d.ts +1 -1
- package/uploads.d.ts.map +1 -1
- package/uploads.js +3 -3
- package/uploads.js.map +1 -1
- package/uploads.mjs +1 -1
- package/uploads.mjs.map +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/internal/polyfill/crypto.node.d.ts +0 -10
- package/internal/polyfill/crypto.node.js +0 -11
- package/internal/polyfill/crypto.node.mjs +0 -2
- package/internal/polyfill/file.node.d.ts +0 -9
- package/internal/polyfill/file.node.js +0 -17
- package/internal/polyfill/file.node.mjs +0 -9
- package/src/internal/polyfill/crypto.node.d.ts +0 -10
- package/src/internal/polyfill/crypto.node.js +0 -11
- package/src/internal/polyfill/crypto.node.mjs +0 -2
- package/src/internal/polyfill/file.node.d.ts +0 -9
- package/src/internal/polyfill/file.node.js +0 -17
- package/src/internal/polyfill/file.node.mjs +0 -9
- package/src/internal/shim-types.d.ts +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.22.0 (2026-02-11)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v2.21.2...v2.22.0](https://github.com/roarkhq/sdk-roark-analytics-node/compare/v2.21.2...v2.22.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** api update ([68c529c](https://github.com/roarkhq/sdk-roark-analytics-node/commit/68c529c4a0c33510a9f988e4c5d76834394fcc97))
|
|
10
|
+
|
|
11
|
+
## 2.21.2 (2026-02-11)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v2.21.1...v2.21.2](https://github.com/roarkhq/sdk-roark-analytics-node/compare/v2.21.1...v2.21.2)
|
|
14
|
+
|
|
15
|
+
### Chores
|
|
16
|
+
|
|
17
|
+
* **internal:** codegen related update ([6fb1d9f](https://github.com/roarkhq/sdk-roark-analytics-node/commit/6fb1d9fa50d1a5ca32c64b6a6f48e295eccbbaa9))
|
|
18
|
+
|
|
3
19
|
## 2.21.1 (2026-02-10)
|
|
4
20
|
|
|
5
21
|
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,21 @@
|
|
|
1
1
|
# Roark TypeScript API Library
|
|
2
2
|
|
|
3
|
-
[](https://npmjs.org/package/@roarkanalytics/sdk) 
|
|
3
|
+
[>)](https://npmjs.org/package/@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.
|
|
9
|
+
It is generated with [Stainless](https://www.stainless.com/).
|
|
10
|
+
|
|
11
|
+
## MCP Server
|
|
12
|
+
|
|
13
|
+
Use the Roark MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.
|
|
14
|
+
|
|
15
|
+
[](https://cursor.com/en-US/install-mcp?name=%40roarkanalytics%2Fsdk-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkByb2Fya2FuYWx5dGljcy9zZGstbWNwIl0sImVudiI6eyJST0FSS19BUElfQkVBUkVSX1RPS0VOIjoiTXkgQmVhcmVyIFRva2VuIn19)
|
|
16
|
+
[](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40roarkanalytics%2Fsdk-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40roarkanalytics%2Fsdk-mcp%22%5D%2C%22env%22%3A%7B%22ROARK_API_BEARER_TOKEN%22%3A%22My%20Bearer%20Token%22%7D%7D)
|
|
17
|
+
|
|
18
|
+
> Note: You may need to set environment variables in your MCP client.
|
|
10
19
|
|
|
11
20
|
## Installation
|
|
12
21
|
|
|
@@ -26,13 +35,9 @@ const client = new Roark({
|
|
|
26
35
|
bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
|
|
27
36
|
});
|
|
28
37
|
|
|
29
|
-
|
|
30
|
-
const response = await client.evaluation.createJob({ evaluators: ['string'] });
|
|
31
|
-
|
|
32
|
-
console.log(response.data);
|
|
33
|
-
}
|
|
38
|
+
const response = await client.evaluation.createJob({ evaluators: ['string'] });
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
console.log(response.data);
|
|
36
41
|
```
|
|
37
42
|
|
|
38
43
|
### Request & Response types
|
|
@@ -47,12 +52,8 @@ const client = new Roark({
|
|
|
47
52
|
bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
|
|
48
53
|
});
|
|
49
54
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const response: Roark.EvaluationCreateJobResponse = await client.evaluation.createJob(params);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
main();
|
|
55
|
+
const params: Roark.EvaluationCreateJobParams = { evaluators: ['string'] };
|
|
56
|
+
const response: Roark.EvaluationCreateJobResponse = await client.evaluation.createJob(params);
|
|
56
57
|
```
|
|
57
58
|
|
|
58
59
|
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
|
|
@@ -65,8 +66,9 @@ a subclass of `APIError` will be thrown:
|
|
|
65
66
|
|
|
66
67
|
<!-- prettier-ignore -->
|
|
67
68
|
```ts
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
const response = await client.evaluation
|
|
70
|
+
.createJob({ evaluators: ['string'] })
|
|
71
|
+
.catch(async (err) => {
|
|
70
72
|
if (err instanceof Roark.APIError) {
|
|
71
73
|
console.log(err.status); // 400
|
|
72
74
|
console.log(err.name); // BadRequestError
|
|
@@ -75,12 +77,9 @@ async function main() {
|
|
|
75
77
|
throw err;
|
|
76
78
|
}
|
|
77
79
|
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
main();
|
|
81
80
|
```
|
|
82
81
|
|
|
83
|
-
Error codes are as
|
|
82
|
+
Error codes are as follows:
|
|
84
83
|
|
|
85
84
|
| Status Code | Error Type |
|
|
86
85
|
| ----------- | -------------------------- |
|
|
@@ -140,8 +139,10 @@ Note that requests which time out will be [retried twice by default](#retries).
|
|
|
140
139
|
### Accessing raw Response data (e.g., headers)
|
|
141
140
|
|
|
142
141
|
The "raw" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.
|
|
142
|
+
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
143
|
|
|
144
144
|
You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.
|
|
145
|
+
Unlike `.asResponse()` this method consumes the body, returning once it is parsed.
|
|
145
146
|
|
|
146
147
|
<!-- prettier-ignore -->
|
|
147
148
|
```ts
|
|
@@ -158,6 +159,59 @@ console.log(raw.headers.get('X-My-Header'));
|
|
|
158
159
|
console.log(response.data);
|
|
159
160
|
```
|
|
160
161
|
|
|
162
|
+
### Logging
|
|
163
|
+
|
|
164
|
+
> [!IMPORTANT]
|
|
165
|
+
> All log messages are intended for debugging only. The format and content of log messages
|
|
166
|
+
> may change between releases.
|
|
167
|
+
|
|
168
|
+
#### Log levels
|
|
169
|
+
|
|
170
|
+
The log level can be configured in two ways:
|
|
171
|
+
|
|
172
|
+
1. Via the `ROARK_LOG` environment variable
|
|
173
|
+
2. Using the `logLevel` client option (overrides the environment variable if set)
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
import Roark from '@roarkanalytics/sdk';
|
|
177
|
+
|
|
178
|
+
const client = new Roark({
|
|
179
|
+
logLevel: 'debug', // Show all log messages
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Available log levels, from most to least verbose:
|
|
184
|
+
|
|
185
|
+
- `'debug'` - Show debug messages, info, warnings, and errors
|
|
186
|
+
- `'info'` - Show info messages, warnings, and errors
|
|
187
|
+
- `'warn'` - Show warnings and errors (default)
|
|
188
|
+
- `'error'` - Show only errors
|
|
189
|
+
- `'off'` - Disable all logging
|
|
190
|
+
|
|
191
|
+
At the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.
|
|
192
|
+
Some authentication-related headers are redacted, but sensitive data in request and response bodies
|
|
193
|
+
may still be visible.
|
|
194
|
+
|
|
195
|
+
#### Custom logger
|
|
196
|
+
|
|
197
|
+
By default, this library logs to `globalThis.console`. You can also provide a custom logger.
|
|
198
|
+
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.
|
|
199
|
+
|
|
200
|
+
When providing a custom logger, the `logLevel` option still controls which messages are emitted, messages
|
|
201
|
+
below the configured level will not be sent to your logger.
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
import Roark from '@roarkanalytics/sdk';
|
|
205
|
+
import pino from 'pino';
|
|
206
|
+
|
|
207
|
+
const logger = pino();
|
|
208
|
+
|
|
209
|
+
const client = new Roark({
|
|
210
|
+
logger: logger.child({ name: 'Roark' }),
|
|
211
|
+
logLevel: 'debug', // Send all messages to pino, allowing it to filter
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
161
215
|
### Making custom/undocumented requests
|
|
162
216
|
|
|
163
217
|
This library is typed for convenient access to the documented API. If you need to access undocumented
|
|
@@ -182,9 +236,8 @@ parameter. This library doesn't validate at runtime that the request matches the
|
|
|
182
236
|
send will be sent as-is.
|
|
183
237
|
|
|
184
238
|
```ts
|
|
185
|
-
client.
|
|
186
|
-
|
|
187
|
-
bar: 12,
|
|
239
|
+
client.evaluation.createJob({
|
|
240
|
+
// ...
|
|
188
241
|
// @ts-expect-error baz is not yet public
|
|
189
242
|
baz: 'undocumented option',
|
|
190
243
|
});
|
|
@@ -217,33 +270,12 @@ globalThis.fetch = fetch;
|
|
|
217
270
|
Or pass it to the client:
|
|
218
271
|
|
|
219
272
|
```ts
|
|
273
|
+
import Roark from '@roarkanalytics/sdk';
|
|
220
274
|
import fetch from 'my-fetch';
|
|
221
275
|
|
|
222
276
|
const client = new Roark({ fetch });
|
|
223
277
|
```
|
|
224
278
|
|
|
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
279
|
### Fetch options
|
|
248
280
|
|
|
249
281
|
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 +355,7 @@ TypeScript >= 4.9 is supported.
|
|
|
323
355
|
The following runtimes are supported:
|
|
324
356
|
|
|
325
357
|
- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
|
|
326
|
-
- Node.js
|
|
358
|
+
- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
|
|
327
359
|
- Deno v1.28.0 or higher.
|
|
328
360
|
- Bun 1.0 or later.
|
|
329
361
|
- 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
|
package/api-promise.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-promise.d.mts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":"
|
|
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
|
package/api-promise.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-promise.d.ts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-promise.d.ts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
|
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
|
-
|
|
17
|
-
|
|
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
|
package/api-promise.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-promise.js","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":"
|
|
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
|
-
|
|
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-promise.mjs.map
|
package/api-promise.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-promise.mjs","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":"
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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
|
|
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
|
|
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):
|
|
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(
|
|
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
|