@roarkanalytics/sdk 2.20.0 → 2.21.1
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 +83 -45
- package/api-promise.d.mts +47 -0
- package/api-promise.d.mts.map +1 -0
- package/api-promise.d.ts +47 -0
- package/api-promise.d.ts.map +1 -0
- package/api-promise.js +84 -0
- package/api-promise.js.map +1 -0
- package/api-promise.mjs +80 -0
- package/api-promise.mjs.map +1 -0
- package/client.d.mts +201 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +201 -0
- package/client.d.ts.map +1 -0
- package/client.js +454 -0
- package/client.js.map +1 -0
- package/client.mjs +427 -0
- package/client.mjs.map +1 -0
- package/error.d.mts +47 -0
- package/error.d.mts.map +1 -0
- package/error.d.ts +1 -1
- package/error.d.ts.map +1 -1
- package/error.js +2 -2
- package/error.js.map +1 -1
- package/error.mjs +1 -1
- package/error.mjs.map +1 -1
- package/index.d.mts +4 -130
- package/index.d.mts.map +1 -0
- package/index.d.ts +4 -130
- package/index.d.ts.map +1 -1
- package/index.js +10 -128
- package/index.js.map +1 -1
- package/index.mjs +4 -102
- package/index.mjs.map +1 -1
- package/internal/builtin-types.d.mts +65 -0
- package/internal/builtin-types.d.mts.map +1 -0
- package/internal/builtin-types.d.ts +65 -0
- package/internal/builtin-types.d.ts.map +1 -0
- package/internal/builtin-types.js +4 -0
- package/internal/builtin-types.js.map +1 -0
- package/internal/builtin-types.mjs +3 -0
- package/internal/builtin-types.mjs.map +1 -0
- package/internal/detect-platform.d.mts +15 -0
- package/internal/detect-platform.d.mts.map +1 -0
- package/internal/detect-platform.d.ts +15 -0
- package/internal/detect-platform.d.ts.map +1 -0
- package/internal/detect-platform.js +162 -0
- package/internal/detect-platform.js.map +1 -0
- package/internal/detect-platform.mjs +157 -0
- package/internal/detect-platform.mjs.map +1 -0
- package/internal/errors.d.mts +3 -0
- package/internal/errors.d.mts.map +1 -0
- package/internal/errors.d.ts +3 -0
- package/internal/errors.d.ts.map +1 -0
- package/internal/errors.js +26 -0
- package/internal/errors.js.map +1 -0
- package/internal/errors.mjs +21 -0
- package/internal/errors.mjs.map +1 -0
- package/internal/headers.d.mts +21 -0
- package/internal/headers.d.mts.map +1 -0
- package/internal/headers.d.ts +21 -0
- package/internal/headers.d.ts.map +1 -0
- package/internal/headers.js +77 -0
- package/internal/headers.js.map +1 -0
- package/internal/headers.mjs +72 -0
- package/internal/headers.mjs.map +1 -0
- package/internal/parse.d.mts +10 -0
- package/internal/parse.d.mts.map +1 -0
- package/internal/parse.d.ts +10 -0
- package/internal/parse.d.ts.map +1 -0
- package/internal/parse.js +28 -0
- package/internal/parse.js.map +1 -0
- package/internal/parse.mjs +24 -0
- package/internal/parse.mjs.map +1 -0
- package/internal/polyfill/crypto.node.d.ts +10 -0
- package/internal/polyfill/crypto.node.js +11 -0
- package/internal/polyfill/crypto.node.mjs +2 -0
- package/internal/polyfill/file.node.d.ts +9 -0
- package/internal/polyfill/file.node.js +17 -0
- package/internal/polyfill/file.node.mjs +9 -0
- package/internal/qs/formats.d.mts +6 -0
- package/internal/qs/formats.d.mts.map +1 -0
- package/internal/qs/formats.d.ts.map +1 -1
- package/internal/qs/index.d.mts +10 -0
- package/internal/qs/index.d.mts.map +1 -0
- package/internal/qs/index.d.ts.map +1 -1
- package/internal/qs/stringify.d.mts +3 -0
- package/internal/qs/stringify.d.mts.map +1 -0
- package/internal/qs/stringify.d.ts.map +1 -1
- package/internal/qs/types.d.mts +57 -0
- package/internal/qs/types.d.mts.map +1 -0
- package/internal/qs/utils.d.mts +14 -0
- package/internal/qs/utils.d.mts.map +1 -0
- package/internal/qs/utils.d.ts.map +1 -1
- package/internal/request-options.d.mts +34 -0
- package/internal/request-options.d.mts.map +1 -0
- package/internal/request-options.d.ts +34 -0
- package/internal/request-options.d.ts.map +1 -0
- package/internal/request-options.js +39 -0
- package/internal/request-options.js.map +1 -0
- package/internal/request-options.mjs +34 -0
- package/internal/request-options.mjs.map +1 -0
- package/internal/shim-types.d.mts +28 -0
- package/internal/shim-types.d.ts +28 -0
- package/internal/shims.d.mts +61 -0
- package/internal/shims.d.mts.map +1 -0
- package/internal/shims.d.ts +61 -0
- package/internal/shims.d.ts.map +1 -0
- package/internal/shims.js +101 -0
- package/internal/shims.js.map +1 -0
- package/internal/shims.mjs +92 -0
- package/internal/shims.mjs.map +1 -0
- package/internal/types.d.mts +68 -0
- package/internal/types.d.mts.map +1 -0
- package/internal/types.d.ts +68 -0
- package/internal/types.d.ts.map +1 -0
- package/internal/types.js +4 -0
- package/internal/types.js.map +1 -0
- package/internal/types.mjs +3 -0
- package/internal/types.mjs.map +1 -0
- package/internal/uploads.d.mts +73 -0
- package/internal/uploads.d.mts.map +1 -0
- package/internal/uploads.d.ts +73 -0
- package/internal/uploads.d.ts.map +1 -0
- package/internal/uploads.js +208 -0
- package/internal/uploads.js.map +1 -0
- package/internal/uploads.mjs +200 -0
- package/internal/uploads.mjs.map +1 -0
- package/internal/utils/base64.d.mts +3 -0
- package/internal/utils/base64.d.mts.map +1 -0
- package/internal/utils/base64.d.ts +3 -0
- package/internal/utils/base64.d.ts.map +1 -0
- package/internal/utils/base64.js +33 -0
- package/internal/utils/base64.js.map +1 -0
- package/internal/utils/base64.mjs +28 -0
- package/internal/utils/base64.mjs.map +1 -0
- package/internal/utils/env.d.mts +9 -0
- package/internal/utils/env.d.mts.map +1 -0
- package/internal/utils/env.d.ts +9 -0
- package/internal/utils/env.d.ts.map +1 -0
- package/internal/utils/env.js +22 -0
- package/internal/utils/env.js.map +1 -0
- package/internal/utils/env.mjs +18 -0
- package/internal/utils/env.mjs.map +1 -0
- package/internal/utils/log.d.mts +4 -0
- package/internal/utils/log.d.mts.map +1 -0
- package/internal/utils/log.d.ts +4 -0
- package/internal/utils/log.d.ts.map +1 -0
- package/internal/utils/log.js +47 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +43 -0
- package/internal/utils/log.mjs.map +1 -0
- package/internal/utils/sleep.d.mts +2 -0
- package/internal/utils/sleep.d.mts.map +1 -0
- package/internal/utils/sleep.d.ts +2 -0
- package/internal/utils/sleep.d.ts.map +1 -0
- package/internal/utils/sleep.js +7 -0
- package/internal/utils/sleep.js.map +1 -0
- package/internal/utils/sleep.mjs +3 -0
- package/internal/utils/sleep.mjs.map +1 -0
- package/internal/utils/uuid.d.mts +5 -0
- package/internal/utils/uuid.d.mts.map +1 -0
- package/internal/utils/uuid.d.ts +5 -0
- package/internal/utils/uuid.d.ts.map +1 -0
- package/internal/utils/uuid.js +15 -0
- package/internal/utils/uuid.js.map +1 -0
- package/internal/utils/uuid.mjs +11 -0
- package/internal/utils/uuid.mjs.map +1 -0
- package/internal/utils/values.d.mts +15 -0
- package/internal/utils/values.d.mts.map +1 -0
- package/internal/utils/values.d.ts +15 -0
- package/internal/utils/values.d.ts.map +1 -0
- package/internal/utils/values.js +100 -0
- package/internal/utils/values.js.map +1 -0
- package/internal/utils/values.mjs +84 -0
- package/internal/utils/values.mjs.map +1 -0
- package/internal/utils.d.mts +7 -0
- package/internal/utils.d.mts.map +1 -0
- package/internal/utils.d.ts +7 -0
- package/internal/utils.d.ts.map +1 -0
- package/{_shims/auto/runtime-bun.js → internal/utils.js} +8 -5
- package/internal/utils.js.map +1 -0
- package/internal/utils.mjs +8 -0
- package/internal/utils.mjs.map +1 -0
- package/package.json +83 -66
- package/resource.d.mts +6 -0
- package/resource.d.mts.map +1 -0
- package/resource.d.ts +2 -2
- package/resource.d.ts.map +1 -1
- package/resource.js.map +1 -1
- package/resource.mjs.map +1 -1
- package/resources/call.d.mts +1197 -0
- package/resources/call.d.mts.map +1 -0
- package/resources/call.d.ts +13 -24
- package/resources/call.d.ts.map +1 -1
- package/resources/call.js +15 -15
- package/resources/call.js.map +1 -1
- package/resources/call.mjs +15 -15
- package/resources/call.mjs.map +1 -1
- package/resources/evaluation.d.mts +1295 -0
- package/resources/evaluation.d.mts.map +1 -0
- package/resources/evaluation.d.ts +13 -26
- package/resources/evaluation.d.ts.map +1 -1
- package/resources/evaluation.js +13 -13
- package/resources/evaluation.js.map +1 -1
- package/resources/evaluation.mjs +13 -13
- package/resources/evaluation.mjs.map +1 -1
- package/resources/health.d.mts +29 -0
- package/resources/health.d.mts.map +1 -0
- package/resources/health.d.ts +3 -2
- package/resources/health.d.ts.map +1 -1
- package/resources/health.js.map +1 -1
- package/resources/health.mjs.map +1 -1
- package/resources/index.d.mts +8 -0
- package/resources/index.d.mts.map +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/integrations.d.mts +81 -0
- package/resources/integrations.d.mts.map +1 -0
- package/resources/integrations.d.ts +8 -40
- package/resources/integrations.d.ts.map +1 -1
- package/resources/integrations.js +0 -25
- package/resources/integrations.js.map +1 -1
- package/resources/integrations.mjs +0 -25
- package/resources/integrations.mjs.map +1 -1
- package/resources/metric.d.mts +75 -0
- package/resources/metric.d.mts.map +1 -0
- package/resources/metric.d.ts +3 -2
- package/resources/metric.d.ts.map +1 -1
- package/resources/metric.js.map +1 -1
- package/resources/metric.mjs.map +1 -1
- package/resources/persona.d.mts +491 -0
- package/resources/persona.d.mts.map +1 -0
- package/resources/persona.d.ts +13 -51
- package/resources/persona.d.ts.map +1 -1
- package/resources/persona.js +10 -26
- package/resources/persona.js.map +1 -1
- package/resources/persona.mjs +10 -26
- package/resources/persona.mjs.map +1 -1
- package/resources/simulation.d.mts +756 -0
- package/resources/simulation.d.mts.map +1 -0
- package/resources/simulation.d.ts +11 -58
- package/resources/simulation.d.ts.map +1 -1
- package/resources/simulation.js +13 -43
- package/resources/simulation.js.map +1 -1
- package/resources/simulation.mjs +13 -43
- package/resources/simulation.mjs.map +1 -1
- package/src/api-promise.ts +92 -0
- package/src/client.ts +751 -0
- package/src/error.ts +1 -1
- package/src/index.ts +4 -307
- package/src/internal/builtin-types.ts +79 -0
- package/src/internal/detect-platform.ts +196 -0
- package/src/internal/errors.ts +22 -0
- package/src/internal/headers.ts +96 -0
- package/src/internal/parse.ts +41 -0
- package/src/internal/polyfill/crypto.node.d.ts +10 -0
- package/src/internal/polyfill/crypto.node.js +11 -0
- package/src/internal/polyfill/crypto.node.mjs +2 -0
- package/src/internal/polyfill/file.node.d.ts +9 -0
- package/src/internal/polyfill/file.node.js +17 -0
- package/src/internal/polyfill/file.node.mjs +9 -0
- package/src/internal/request-options.ts +67 -0
- package/src/internal/shim-types.d.ts +28 -0
- package/src/internal/shims.ts +145 -0
- package/src/internal/types.ts +98 -0
- package/src/internal/uploads.ts +307 -0
- package/src/internal/utils/base64.ts +37 -0
- package/src/internal/utils/env.ts +18 -0
- package/src/internal/utils/log.ts +49 -0
- package/src/internal/utils/sleep.ts +3 -0
- package/src/internal/utils/uuid.ts +13 -0
- package/src/internal/utils/values.ts +94 -0
- package/src/internal/utils.ts +8 -0
- package/src/resource.ts +2 -2
- package/src/resources/call.ts +22 -42
- package/src/resources/evaluation.ts +25 -42
- package/src/resources/health.ts +3 -2
- package/src/resources/integrations.ts +10 -34
- package/src/resources/metric.ts +3 -2
- package/src/resources/persona.ts +22 -61
- package/src/resources/simulation.ts +22 -84
- package/src/tsconfig.json +2 -2
- package/src/uploads.ts +1 -255
- package/src/version.ts +1 -1
- package/uploads.d.mts +2 -0
- package/uploads.d.mts.map +1 -0
- package/uploads.d.ts +1 -74
- package/uploads.d.ts.map +1 -1
- package/uploads.js +3 -168
- package/uploads.js.map +1 -1
- package/uploads.mjs +1 -157
- package/uploads.mjs.map +1 -1
- package/version.d.mts +2 -0
- package/version.d.mts.map +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/_shims/MultipartBody.d.ts +0 -9
- package/_shims/MultipartBody.d.ts.map +0 -1
- package/_shims/MultipartBody.js +0 -16
- package/_shims/MultipartBody.js.map +0 -1
- package/_shims/MultipartBody.mjs +0 -12
- package/_shims/MultipartBody.mjs.map +0 -1
- package/_shims/README.md +0 -46
- package/_shims/auto/runtime-bun.d.ts +0 -5
- package/_shims/auto/runtime-bun.d.ts.map +0 -1
- package/_shims/auto/runtime-bun.js.map +0 -1
- package/_shims/auto/runtime-bun.mjs +0 -2
- package/_shims/auto/runtime-bun.mjs.map +0 -1
- package/_shims/auto/runtime-node.d.ts +0 -5
- package/_shims/auto/runtime-node.d.ts.map +0 -1
- package/_shims/auto/runtime-node.js +0 -21
- package/_shims/auto/runtime-node.js.map +0 -1
- package/_shims/auto/runtime-node.mjs +0 -2
- package/_shims/auto/runtime-node.mjs.map +0 -1
- package/_shims/auto/runtime.d.ts +0 -5
- package/_shims/auto/runtime.d.ts.map +0 -1
- package/_shims/auto/runtime.js +0 -21
- package/_shims/auto/runtime.js.map +0 -1
- package/_shims/auto/runtime.mjs +0 -2
- package/_shims/auto/runtime.mjs.map +0 -1
- package/_shims/auto/types-node.d.ts +0 -5
- package/_shims/auto/types-node.d.ts.map +0 -1
- package/_shims/auto/types-node.js +0 -21
- package/_shims/auto/types-node.js.map +0 -1
- package/_shims/auto/types-node.mjs +0 -2
- package/_shims/auto/types-node.mjs.map +0 -1
- package/_shims/auto/types.d.ts +0 -101
- package/_shims/auto/types.js +0 -3
- package/_shims/auto/types.mjs +0 -3
- package/_shims/bun-runtime.d.ts +0 -6
- package/_shims/bun-runtime.d.ts.map +0 -1
- package/_shims/bun-runtime.js +0 -14
- package/_shims/bun-runtime.js.map +0 -1
- package/_shims/bun-runtime.mjs +0 -10
- package/_shims/bun-runtime.mjs.map +0 -1
- package/_shims/index.d.ts +0 -83
- package/_shims/index.js +0 -17
- package/_shims/index.mjs +0 -11
- package/_shims/manual-types.d.ts +0 -12
- package/_shims/manual-types.js +0 -3
- package/_shims/manual-types.mjs +0 -3
- package/_shims/node-runtime.d.ts +0 -3
- package/_shims/node-runtime.d.ts.map +0 -1
- package/_shims/node-runtime.js +0 -89
- package/_shims/node-runtime.js.map +0 -1
- package/_shims/node-runtime.mjs +0 -56
- package/_shims/node-runtime.mjs.map +0 -1
- package/_shims/node-types.d.ts +0 -42
- package/_shims/node-types.js +0 -3
- package/_shims/node-types.mjs +0 -3
- package/_shims/registry.d.ts +0 -37
- package/_shims/registry.d.ts.map +0 -1
- package/_shims/registry.js +0 -41
- package/_shims/registry.js.map +0 -1
- package/_shims/registry.mjs +0 -37
- package/_shims/registry.mjs.map +0 -1
- package/_shims/web-runtime.d.ts +0 -5
- package/_shims/web-runtime.d.ts.map +0 -1
- package/_shims/web-runtime.js +0 -78
- package/_shims/web-runtime.js.map +0 -1
- package/_shims/web-runtime.mjs +0 -71
- package/_shims/web-runtime.mjs.map +0 -1
- package/_shims/web-types.d.ts +0 -83
- package/_shims/web-types.js +0 -3
- package/_shims/web-types.mjs +0 -3
- package/core.d.ts +0 -255
- package/core.d.ts.map +0 -1
- package/core.js +0 -929
- package/core.js.map +0 -1
- package/core.mjs +0 -897
- package/core.mjs.map +0 -1
- package/resources.d.ts +0 -2
- package/resources.d.ts.map +0 -1
- package/resources.js +0 -18
- package/resources.js.map +0 -1
- package/resources.mjs +0 -2
- package/resources.mjs.map +0 -1
- package/shims/node.d.ts +0 -30
- package/shims/node.d.ts.map +0 -1
- package/shims/node.js +0 -31
- package/shims/node.js.map +0 -1
- package/shims/node.mjs +0 -5
- package/shims/node.mjs.map +0 -1
- package/shims/web.d.ts +0 -26
- package/shims/web.d.ts.map +0 -1
- package/shims/web.js +0 -31
- package/shims/web.js.map +0 -1
- package/shims/web.mjs +0 -5
- package/shims/web.mjs.map +0 -1
- package/src/_shims/MultipartBody.ts +0 -9
- package/src/_shims/README.md +0 -46
- package/src/_shims/auto/runtime-bun.ts +0 -4
- package/src/_shims/auto/runtime-node.ts +0 -4
- package/src/_shims/auto/runtime.ts +0 -4
- package/src/_shims/auto/types-node.ts +0 -4
- package/src/_shims/auto/types.d.ts +0 -101
- package/src/_shims/auto/types.js +0 -3
- package/src/_shims/auto/types.mjs +0 -3
- package/src/_shims/bun-runtime.ts +0 -14
- package/src/_shims/index.d.ts +0 -83
- package/src/_shims/index.js +0 -17
- package/src/_shims/index.mjs +0 -11
- package/src/_shims/manual-types.d.ts +0 -12
- package/src/_shims/manual-types.js +0 -3
- package/src/_shims/manual-types.mjs +0 -3
- package/src/_shims/node-runtime.ts +0 -81
- package/src/_shims/node-types.d.ts +0 -42
- package/src/_shims/node-types.js +0 -3
- package/src/_shims/node-types.mjs +0 -3
- package/src/_shims/registry.ts +0 -67
- package/src/_shims/web-runtime.ts +0 -103
- package/src/_shims/web-types.d.ts +0 -83
- package/src/_shims/web-types.js +0 -3
- package/src/_shims/web-types.mjs +0 -3
- package/src/core.ts +0 -1242
- package/src/resources.ts +0 -1
- package/src/shims/node.ts +0 -50
- package/src/shims/web.ts +0 -50
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.21.1 (2026-02-10)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v2.21.0...v2.21.1](https://github.com/roarkhq/sdk-roark-analytics-node/compare/v2.21.0...v2.21.1)
|
|
6
|
+
|
|
7
|
+
### Chores
|
|
8
|
+
|
|
9
|
+
* remove custom code ([ffba344](https://github.com/roarkhq/sdk-roark-analytics-node/commit/ffba3447da35dfe5e64906bda1b6290164981c4b))
|
|
10
|
+
|
|
11
|
+
## 2.21.0 (2026-02-10)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v2.20.0...v2.21.0](https://github.com/roarkhq/sdk-roark-analytics-node/compare/v2.20.0...v2.21.0)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **api:** api update ([337193e](https://github.com/roarkhq/sdk-roark-analytics-node/commit/337193e95b52e4054516340367a7cb6e9cb55516))
|
|
18
|
+
|
|
3
19
|
## 2.20.0 (2026-02-10)
|
|
4
20
|
|
|
5
21
|
Full Changelog: [v2.19.1...v2.20.0](https://github.com/roarkhq/sdk-roark-analytics-node/compare/v2.19.1...v2.20.0)
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Roark
|
|
1
|
+
# Roark TypeScript API Library
|
|
2
2
|
|
|
3
3
|
[](https://npmjs.org/package/@roarkanalytics/sdk) 
|
|
4
4
|
|
|
@@ -6,16 +6,7 @@ This library provides convenient access to the Roark REST API from server-side T
|
|
|
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.
|
|
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.
|
|
9
|
+
It is generated with [Stainless](https://www.stainlessapi.com/).
|
|
19
10
|
|
|
20
11
|
## Installation
|
|
21
12
|
|
|
@@ -35,9 +26,13 @@ const client = new Roark({
|
|
|
35
26
|
bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
|
|
36
27
|
});
|
|
37
28
|
|
|
38
|
-
|
|
29
|
+
async function main() {
|
|
30
|
+
const response = await client.evaluation.createJob({ evaluators: ['string'] });
|
|
39
31
|
|
|
40
|
-
console.log(response.data);
|
|
32
|
+
console.log(response.data);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
main();
|
|
41
36
|
```
|
|
42
37
|
|
|
43
38
|
### Request & Response types
|
|
@@ -52,8 +47,12 @@ const client = new Roark({
|
|
|
52
47
|
bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
|
|
53
48
|
});
|
|
54
49
|
|
|
55
|
-
|
|
56
|
-
const
|
|
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();
|
|
57
56
|
```
|
|
58
57
|
|
|
59
58
|
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
|
|
@@ -66,9 +65,8 @@ a subclass of `APIError` will be thrown:
|
|
|
66
65
|
|
|
67
66
|
<!-- prettier-ignore -->
|
|
68
67
|
```ts
|
|
69
|
-
|
|
70
|
-
.createJob({ evaluators: ['string'] })
|
|
71
|
-
.catch(async (err) => {
|
|
68
|
+
async function main() {
|
|
69
|
+
const response = await client.evaluation.createJob({ evaluators: ['string'] }).catch(async (err) => {
|
|
72
70
|
if (err instanceof Roark.APIError) {
|
|
73
71
|
console.log(err.status); // 400
|
|
74
72
|
console.log(err.name); // BadRequestError
|
|
@@ -77,9 +75,12 @@ const response = await client.evaluation
|
|
|
77
75
|
throw err;
|
|
78
76
|
}
|
|
79
77
|
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
main();
|
|
80
81
|
```
|
|
81
82
|
|
|
82
|
-
Error codes are as
|
|
83
|
+
Error codes are as followed:
|
|
83
84
|
|
|
84
85
|
| Status Code | Error Type |
|
|
85
86
|
| ----------- | -------------------------- |
|
|
@@ -203,21 +204,23 @@ validate or strip extra properties from the response from the API.
|
|
|
203
204
|
|
|
204
205
|
### Customizing the fetch client
|
|
205
206
|
|
|
206
|
-
By default, this library
|
|
207
|
+
By default, this library expects a global `fetch` function is defined.
|
|
207
208
|
|
|
208
|
-
If you
|
|
209
|
-
(for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`),
|
|
210
|
-
add the following import before your first import `from "Roark"`:
|
|
209
|
+
If you want to use a different `fetch` function, you can either polyfill the global:
|
|
211
210
|
|
|
212
211
|
```ts
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
import Roark from '@roarkanalytics/sdk';
|
|
212
|
+
import fetch from 'my-fetch';
|
|
213
|
+
|
|
214
|
+
globalThis.fetch = fetch;
|
|
217
215
|
```
|
|
218
216
|
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
Or pass it to the client:
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
import fetch from 'my-fetch';
|
|
221
|
+
|
|
222
|
+
const client = new Roark({ fetch });
|
|
223
|
+
```
|
|
221
224
|
|
|
222
225
|
### Logging and middleware
|
|
223
226
|
|
|
@@ -238,34 +241,69 @@ const client = new Roark({
|
|
|
238
241
|
});
|
|
239
242
|
```
|
|
240
243
|
|
|
241
|
-
Note that if given a `
|
|
244
|
+
Note that if given a `ROARK_LOG=debug` environment variable, this library will log all requests and responses automatically.
|
|
242
245
|
This is intended for debugging purposes only and may change in the future without notice.
|
|
243
246
|
|
|
244
|
-
###
|
|
247
|
+
### Fetch options
|
|
245
248
|
|
|
246
|
-
|
|
249
|
+
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.)
|
|
247
250
|
|
|
248
|
-
|
|
251
|
+
```ts
|
|
252
|
+
import Roark from '@roarkanalytics/sdk';
|
|
253
|
+
|
|
254
|
+
const client = new Roark({
|
|
255
|
+
fetchOptions: {
|
|
256
|
+
// `RequestInit` options
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
#### Configuring proxies
|
|
262
|
+
|
|
263
|
+
To modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy
|
|
264
|
+
options to requests:
|
|
265
|
+
|
|
266
|
+
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg" align="top" width="18" height="21"> **Node** <sup>[[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]</sup>
|
|
249
267
|
|
|
250
|
-
<!-- prettier-ignore -->
|
|
251
268
|
```ts
|
|
252
|
-
import
|
|
253
|
-
import
|
|
269
|
+
import Roark from '@roarkanalytics/sdk';
|
|
270
|
+
import * as undici from 'undici';
|
|
254
271
|
|
|
255
|
-
|
|
272
|
+
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
|
|
256
273
|
const client = new Roark({
|
|
257
|
-
|
|
274
|
+
fetchOptions: {
|
|
275
|
+
dispatcher: proxyAgent,
|
|
276
|
+
},
|
|
258
277
|
});
|
|
278
|
+
```
|
|
259
279
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
280
|
+
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg" align="top" width="18" height="21"> **Bun** <sup>[[docs](https://bun.sh/guides/http/proxy)]</sup>
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
import Roark from '@roarkanalytics/sdk';
|
|
284
|
+
|
|
285
|
+
const client = new Roark({
|
|
286
|
+
fetchOptions: {
|
|
287
|
+
proxy: 'http://localhost:8888',
|
|
265
288
|
},
|
|
266
|
-
);
|
|
289
|
+
});
|
|
267
290
|
```
|
|
268
291
|
|
|
292
|
+
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg" align="top" width="18" height="21"> **Deno** <sup>[[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]</sup>
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
import Roark from 'npm:@roarkanalytics/sdk';
|
|
296
|
+
|
|
297
|
+
const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
|
|
298
|
+
const client = new Roark({
|
|
299
|
+
fetchOptions: {
|
|
300
|
+
client: httpClient,
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Frequently Asked Questions
|
|
306
|
+
|
|
269
307
|
## Semantic versioning
|
|
270
308
|
|
|
271
309
|
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
|
@@ -280,7 +318,7 @@ We are keen for your feedback; please open an [issue](https://www.github.com/roa
|
|
|
280
318
|
|
|
281
319
|
## Requirements
|
|
282
320
|
|
|
283
|
-
TypeScript >= 4.
|
|
321
|
+
TypeScript >= 4.9 is supported.
|
|
284
322
|
|
|
285
323
|
The following runtimes are supported:
|
|
286
324
|
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
}
|
|
47
|
+
//# sourceMappingURL=api-promise.d.mts.map
|
|
@@ -0,0 +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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G,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;CAG1E"}
|
package/api-promise.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
}
|
|
47
|
+
//# sourceMappingURL=api-promise.d.ts.map
|
|
@@ -0,0 +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,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"}
|
package/api-promise.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
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();
|
|
84
|
+
//# sourceMappingURL=api-promise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-promise.js","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;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,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;AAhFD,gCAgFC"}
|
package/api-promise.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
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();
|
|
80
|
+
//# sourceMappingURL=api-promise.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-promise.mjs","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":"AAAA,sFAAsF;;;;;;;;;;;;;OAK/E,EAAoB,oBAAoB,EAAE;AAEjD;;;GAGG;AACH,MAAM,OAAO,UAAc,SAAQ,OAAU;IAI3C,YACE,MAAa,EACL,eAA0C,EAC1C,gBAGiB,oBAAoB;QAE7C,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE;YAChB,yEAAyE;YACzE,0EAA0E;YAC1E,wBAAwB;YACxB,OAAO,CAAC,IAAW,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAXK,oBAAe,GAAf,eAAe,CAA2B;QAC1C,kBAAa,GAAb,aAAa,CAGwB;QAR/C,q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