@roarkanalytics/sdk 0.1.0-alpha.1 → 0.1.0-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/LICENSE +1 -1
- package/README.md +48 -85
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +16 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +12 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/_shims/auto/runtime-bun.d.ts +5 -0
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/{internal/utils.js → _shims/auto/runtime-bun.js} +5 -8
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +2 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +21 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +2 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +21 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +2 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +21 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +2 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +101 -0
- package/_shims/auto/types.js +3 -0
- package/_shims/auto/types.mjs +3 -0
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +14 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +10 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +81 -0
- package/_shims/index.js +13 -0
- package/_shims/index.mjs +7 -0
- package/_shims/manual-types.d.ts +12 -0
- package/_shims/manual-types.js +3 -0
- package/_shims/manual-types.mjs +3 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +89 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +56 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +42 -0
- package/_shims/node-types.js +3 -0
- package/_shims/node-types.mjs +3 -0
- package/_shims/registry.d.ts +37 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +41 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +37 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +78 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +71 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +83 -0
- package/_shims/web-types.js +3 -0
- package/_shims/web-types.mjs +3 -0
- package/core.d.ts +241 -0
- package/core.d.ts.map +1 -0
- package/core.js +908 -0
- package/core.js.map +1 -0
- package/core.mjs +876 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +3 -3
- package/error.d.ts.map +1 -1
- package/error.js +6 -6
- package/error.js.map +1 -1
- package/error.mjs +3 -3
- package/error.mjs.map +1 -1
- package/index.d.mts +109 -5
- package/index.d.ts +109 -5
- package/index.d.ts.map +1 -1
- package/index.js +103 -11
- package/index.js.map +1 -1
- package/index.mjs +77 -5
- package/index.mjs.map +1 -1
- package/package.json +66 -82
- package/resource.d.ts +3 -3
- package/resource.d.ts.map +1 -1
- package/resource.js.map +1 -1
- package/resource.mjs.map +1 -1
- package/resources/calls.d.ts +2 -3
- package/resources/calls.d.ts.map +1 -1
- package/resources/calls.js.map +1 -1
- package/resources/calls.mjs.map +1 -1
- package/resources/index.d.ts.map +1 -1
- package/shims/node.d.ts +30 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +31 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +5 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +31 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +5 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +9 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +4 -0
- package/src/_shims/auto/runtime-node.ts +4 -0
- package/src/_shims/auto/runtime.ts +4 -0
- package/src/_shims/auto/types-node.ts +4 -0
- package/src/_shims/auto/types.d.ts +101 -0
- package/src/_shims/auto/types.js +3 -0
- package/src/_shims/auto/types.mjs +3 -0
- package/src/_shims/bun-runtime.ts +14 -0
- package/src/_shims/index.d.ts +81 -0
- package/src/_shims/index.js +13 -0
- package/src/_shims/index.mjs +7 -0
- package/src/_shims/manual-types.d.ts +12 -0
- package/src/_shims/manual-types.js +3 -0
- package/src/_shims/manual-types.mjs +3 -0
- package/src/_shims/node-runtime.ts +81 -0
- package/src/_shims/node-types.d.ts +42 -0
- package/src/_shims/node-types.js +3 -0
- package/src/_shims/node-types.mjs +3 -0
- package/src/_shims/registry.ts +67 -0
- package/src/_shims/web-runtime.ts +103 -0
- package/src/_shims/web-types.d.ts +83 -0
- package/src/_shims/web-types.js +3 -0
- package/src/_shims/web-types.mjs +3 -0
- package/src/core.ts +1200 -0
- package/src/error.ts +3 -3
- package/src/index.ts +172 -5
- package/src/resource.ts +3 -3
- package/src/resources/calls.ts +2 -3
- package/src/shims/node.ts +50 -0
- package/src/shims/web.ts +50 -0
- package/src/tsconfig.json +2 -2
- package/src/uploads.ts +255 -1
- package/src/version.ts +1 -1
- package/uploads.d.ts +74 -1
- package/uploads.d.ts.map +1 -1
- package/uploads.js +168 -3
- package/uploads.js.map +1 -1
- package/uploads.mjs +157 -1
- package/uploads.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/api-promise.d.mts +0 -47
- package/api-promise.d.mts.map +0 -1
- package/api-promise.d.ts +0 -47
- package/api-promise.d.ts.map +0 -1
- package/api-promise.js +0 -84
- package/api-promise.js.map +0 -1
- package/api-promise.mjs +0 -80
- package/api-promise.mjs.map +0 -1
- package/client.d.mts +0 -186
- package/client.d.mts.map +0 -1
- package/client.d.ts +0 -186
- package/client.d.ts.map +0 -1
- package/client.js +0 -449
- package/client.js.map +0 -1
- package/client.mjs +0 -422
- package/client.mjs.map +0 -1
- package/error.d.mts +0 -47
- package/error.d.mts.map +0 -1
- package/index.d.mts.map +0 -1
- package/internal/builtin-types.d.mts +0 -65
- package/internal/builtin-types.d.mts.map +0 -1
- package/internal/builtin-types.d.ts +0 -65
- package/internal/builtin-types.d.ts.map +0 -1
- package/internal/builtin-types.js +0 -4
- package/internal/builtin-types.js.map +0 -1
- package/internal/builtin-types.mjs +0 -3
- package/internal/builtin-types.mjs.map +0 -1
- package/internal/detect-platform.d.mts +0 -15
- package/internal/detect-platform.d.mts.map +0 -1
- package/internal/detect-platform.d.ts +0 -15
- package/internal/detect-platform.d.ts.map +0 -1
- package/internal/detect-platform.js +0 -162
- package/internal/detect-platform.js.map +0 -1
- package/internal/detect-platform.mjs +0 -157
- package/internal/detect-platform.mjs.map +0 -1
- package/internal/errors.d.mts +0 -3
- package/internal/errors.d.mts.map +0 -1
- package/internal/errors.d.ts +0 -3
- package/internal/errors.d.ts.map +0 -1
- package/internal/errors.js +0 -26
- package/internal/errors.js.map +0 -1
- package/internal/errors.mjs +0 -21
- package/internal/errors.mjs.map +0 -1
- package/internal/headers.d.mts +0 -21
- package/internal/headers.d.mts.map +0 -1
- package/internal/headers.d.ts +0 -21
- package/internal/headers.d.ts.map +0 -1
- package/internal/headers.js +0 -77
- package/internal/headers.js.map +0 -1
- package/internal/headers.mjs +0 -72
- package/internal/headers.mjs.map +0 -1
- package/internal/parse.d.mts +0 -10
- package/internal/parse.d.mts.map +0 -1
- package/internal/parse.d.ts +0 -10
- package/internal/parse.d.ts.map +0 -1
- package/internal/parse.js +0 -28
- package/internal/parse.js.map +0 -1
- package/internal/parse.mjs +0 -24
- package/internal/parse.mjs.map +0 -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/internal/request-options.d.mts +0 -34
- package/internal/request-options.d.mts.map +0 -1
- package/internal/request-options.d.ts +0 -34
- package/internal/request-options.d.ts.map +0 -1
- package/internal/request-options.js +0 -39
- package/internal/request-options.js.map +0 -1
- package/internal/request-options.mjs +0 -34
- package/internal/request-options.mjs.map +0 -1
- package/internal/shim-types.d.mts +0 -28
- package/internal/shim-types.d.ts +0 -28
- package/internal/shims.d.mts +0 -61
- package/internal/shims.d.mts.map +0 -1
- package/internal/shims.d.ts +0 -61
- package/internal/shims.d.ts.map +0 -1
- package/internal/shims.js +0 -101
- package/internal/shims.js.map +0 -1
- package/internal/shims.mjs +0 -92
- package/internal/shims.mjs.map +0 -1
- package/internal/types.d.mts +0 -68
- package/internal/types.d.mts.map +0 -1
- package/internal/types.d.ts +0 -68
- package/internal/types.d.ts.map +0 -1
- package/internal/types.js +0 -4
- package/internal/types.js.map +0 -1
- package/internal/types.mjs +0 -3
- package/internal/types.mjs.map +0 -1
- package/internal/uploads.d.mts +0 -73
- package/internal/uploads.d.mts.map +0 -1
- package/internal/uploads.d.ts +0 -73
- package/internal/uploads.d.ts.map +0 -1
- package/internal/uploads.js +0 -208
- package/internal/uploads.js.map +0 -1
- package/internal/uploads.mjs +0 -200
- package/internal/uploads.mjs.map +0 -1
- package/internal/utils/base64.d.mts +0 -3
- package/internal/utils/base64.d.mts.map +0 -1
- package/internal/utils/base64.d.ts +0 -3
- package/internal/utils/base64.d.ts.map +0 -1
- package/internal/utils/base64.js +0 -33
- package/internal/utils/base64.js.map +0 -1
- package/internal/utils/base64.mjs +0 -28
- package/internal/utils/base64.mjs.map +0 -1
- package/internal/utils/env.d.mts +0 -9
- package/internal/utils/env.d.mts.map +0 -1
- package/internal/utils/env.d.ts +0 -9
- package/internal/utils/env.d.ts.map +0 -1
- package/internal/utils/env.js +0 -22
- package/internal/utils/env.js.map +0 -1
- package/internal/utils/env.mjs +0 -18
- package/internal/utils/env.mjs.map +0 -1
- package/internal/utils/log.d.mts +0 -4
- package/internal/utils/log.d.mts.map +0 -1
- package/internal/utils/log.d.ts +0 -4
- package/internal/utils/log.d.ts.map +0 -1
- package/internal/utils/log.js +0 -47
- package/internal/utils/log.js.map +0 -1
- package/internal/utils/log.mjs +0 -43
- package/internal/utils/log.mjs.map +0 -1
- package/internal/utils/sleep.d.mts +0 -2
- package/internal/utils/sleep.d.mts.map +0 -1
- package/internal/utils/sleep.d.ts +0 -2
- package/internal/utils/sleep.d.ts.map +0 -1
- package/internal/utils/sleep.js +0 -7
- package/internal/utils/sleep.js.map +0 -1
- package/internal/utils/sleep.mjs +0 -3
- package/internal/utils/sleep.mjs.map +0 -1
- package/internal/utils/uuid.d.mts +0 -5
- package/internal/utils/uuid.d.mts.map +0 -1
- package/internal/utils/uuid.d.ts +0 -5
- package/internal/utils/uuid.d.ts.map +0 -1
- package/internal/utils/uuid.js +0 -15
- package/internal/utils/uuid.js.map +0 -1
- package/internal/utils/uuid.mjs +0 -11
- package/internal/utils/uuid.mjs.map +0 -1
- package/internal/utils/values.d.mts +0 -15
- package/internal/utils/values.d.mts.map +0 -1
- package/internal/utils/values.d.ts +0 -15
- package/internal/utils/values.d.ts.map +0 -1
- package/internal/utils/values.js +0 -100
- package/internal/utils/values.js.map +0 -1
- package/internal/utils/values.mjs +0 -84
- package/internal/utils/values.mjs.map +0 -1
- package/internal/utils.d.mts +0 -7
- package/internal/utils.d.mts.map +0 -1
- package/internal/utils.d.ts +0 -7
- package/internal/utils.d.ts.map +0 -1
- package/internal/utils.js.map +0 -1
- package/internal/utils.mjs +0 -8
- package/internal/utils.mjs.map +0 -1
- package/resource.d.mts +0 -6
- package/resource.d.mts.map +0 -1
- package/resources/calls.d.mts +0 -85
- package/resources/calls.d.mts.map +0 -1
- package/resources/index.d.mts +0 -2
- package/resources/index.d.mts.map +0 -1
- package/src/api-promise.ts +0 -92
- package/src/client.ts +0 -646
- package/src/internal/builtin-types.ts +0 -79
- package/src/internal/detect-platform.ts +0 -196
- package/src/internal/errors.ts +0 -22
- package/src/internal/headers.ts +0 -96
- package/src/internal/parse.ts +0 -41
- 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/request-options.ts +0 -67
- package/src/internal/shim-types.d.ts +0 -28
- package/src/internal/shims.ts +0 -145
- package/src/internal/types.ts +0 -98
- package/src/internal/uploads.ts +0 -307
- package/src/internal/utils/base64.ts +0 -37
- package/src/internal/utils/env.ts +0 -18
- package/src/internal/utils/log.ts +0 -49
- package/src/internal/utils/sleep.ts +0 -3
- package/src/internal/utils/uuid.ts +0 -13
- package/src/internal/utils/values.ts +0 -94
- package/src/internal/utils.ts +0 -8
- package/uploads.d.mts +0 -2
- package/uploads.d.mts.map +0 -1
- package/version.d.mts +0 -2
- package/version.d.mts.map +0 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.1.0-alpha.2 (2025-02-04)
|
4
|
+
|
5
|
+
Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/roarkhq/sdk-roark-analytics-node/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
9
|
+
* **api:** manual updates ([#6](https://github.com/roarkhq/sdk-roark-analytics-node/issues/6)) ([d0eb21e](https://github.com/roarkhq/sdk-roark-analytics-node/commit/d0eb21e5116a9ce99f7198ac430eec2ed68cf0ed))
|
10
|
+
|
3
11
|
## 0.1.0-alpha.1 (2025-02-04)
|
4
12
|
|
5
13
|
Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/roarkhq/sdk-roark-analytics-node/compare/v0.0.1-alpha.0...v0.1.0-alpha.1)
|
package/LICENSE
CHANGED
@@ -186,7 +186,7 @@
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
187
187
|
identification within third-party archives.
|
188
188
|
|
189
|
-
Copyright 2025
|
189
|
+
Copyright 2025 Roark
|
190
190
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
192
192
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# Roark Node API Library
|
2
2
|
|
3
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)
|
4
4
|
|
5
|
-
This library provides convenient access to the
|
5
|
+
This library provides convenient access to the Roark REST API from server-side TypeScript or JavaScript.
|
6
6
|
|
7
|
-
The REST API documentation can be found on [
|
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
9
|
It is generated with [Stainless](https://www.stainlessapi.com/).
|
10
10
|
|
@@ -20,14 +20,14 @@ The full API of this library can be found in [api.md](api.md).
|
|
20
20
|
|
21
21
|
<!-- prettier-ignore -->
|
22
22
|
```js
|
23
|
-
import
|
23
|
+
import Roark from '@roarkanalytics/sdk';
|
24
24
|
|
25
|
-
const client = new
|
25
|
+
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
29
|
async function main() {
|
30
|
-
const call = await client.calls.create({ direction: 'INBOUND', startedAt: '2025-02-
|
30
|
+
const call = await client.calls.create({ direction: 'INBOUND', startedAt: '2025-02-04T06:23:19.633Z' });
|
31
31
|
|
32
32
|
console.log(call.data);
|
33
33
|
}
|
@@ -41,15 +41,15 @@ This library includes TypeScript definitions for all request params and response
|
|
41
41
|
|
42
42
|
<!-- prettier-ignore -->
|
43
43
|
```ts
|
44
|
-
import
|
44
|
+
import Roark from '@roarkanalytics/sdk';
|
45
45
|
|
46
|
-
const client = new
|
46
|
+
const client = new Roark({
|
47
47
|
bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
|
48
48
|
});
|
49
49
|
|
50
50
|
async function main() {
|
51
|
-
const params:
|
52
|
-
const call:
|
51
|
+
const params: Roark.CallCreateParams = { direction: 'INBOUND', startedAt: '2025-02-04T06:23:19.633Z' };
|
52
|
+
const call: Roark.CallCreateResponse = await client.calls.create(params);
|
53
53
|
}
|
54
54
|
|
55
55
|
main();
|
@@ -67,9 +67,9 @@ a subclass of `APIError` will be thrown:
|
|
67
67
|
```ts
|
68
68
|
async function main() {
|
69
69
|
const call = await client.calls
|
70
|
-
.create({ direction: 'INBOUND', startedAt: '2025-02-
|
70
|
+
.create({ direction: 'INBOUND', startedAt: '2025-02-04T06:23:19.633Z' })
|
71
71
|
.catch(async (err) => {
|
72
|
-
if (err instanceof
|
72
|
+
if (err instanceof Roark.APIError) {
|
73
73
|
console.log(err.status); // 400
|
74
74
|
console.log(err.name); // BadRequestError
|
75
75
|
console.log(err.headers); // {server: 'nginx', ...}
|
@@ -106,12 +106,12 @@ You can use the `maxRetries` option to configure or disable this:
|
|
106
106
|
<!-- prettier-ignore -->
|
107
107
|
```js
|
108
108
|
// Configure the default for all requests:
|
109
|
-
const client = new
|
109
|
+
const client = new Roark({
|
110
110
|
maxRetries: 0, // default is 2
|
111
111
|
});
|
112
112
|
|
113
113
|
// Or, configure per-request:
|
114
|
-
await client.calls.create({ direction: 'INBOUND', startedAt: '2025-02-
|
114
|
+
await client.calls.create({ direction: 'INBOUND', startedAt: '2025-02-04T06:23:19.633Z' }, {
|
115
115
|
maxRetries: 5,
|
116
116
|
});
|
117
117
|
```
|
@@ -123,12 +123,12 @@ Requests time out after 1 minute by default. You can configure this with a `time
|
|
123
123
|
<!-- prettier-ignore -->
|
124
124
|
```ts
|
125
125
|
// Configure the default for all requests:
|
126
|
-
const client = new
|
126
|
+
const client = new Roark({
|
127
127
|
timeout: 20 * 1000, // 20 seconds (default is 1 minute)
|
128
128
|
});
|
129
129
|
|
130
130
|
// Override per-request:
|
131
|
-
await client.calls.create({ direction: 'INBOUND', startedAt: '2025-02-
|
131
|
+
await client.calls.create({ direction: 'INBOUND', startedAt: '2025-02-04T06:23:19.633Z' }, {
|
132
132
|
timeout: 5 * 1000,
|
133
133
|
});
|
134
134
|
```
|
@@ -147,16 +147,16 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
|
|
147
147
|
|
148
148
|
<!-- prettier-ignore -->
|
149
149
|
```ts
|
150
|
-
const client = new
|
150
|
+
const client = new Roark();
|
151
151
|
|
152
152
|
const response = await client.calls
|
153
|
-
.create({ direction: 'INBOUND', startedAt: '2025-02-
|
153
|
+
.create({ direction: 'INBOUND', startedAt: '2025-02-04T06:23:19.633Z' })
|
154
154
|
.asResponse();
|
155
155
|
console.log(response.headers.get('X-My-Header'));
|
156
156
|
console.log(response.statusText); // access the underlying Response object
|
157
157
|
|
158
158
|
const { data: call, response: raw } = await client.calls
|
159
|
-
.create({ direction: 'INBOUND', startedAt: '2025-02-
|
159
|
+
.create({ direction: 'INBOUND', startedAt: '2025-02-04T06:23:19.633Z' })
|
160
160
|
.withResponse();
|
161
161
|
console.log(raw.headers.get('X-My-Header'));
|
162
162
|
console.log(call.data);
|
@@ -208,23 +208,21 @@ validate or strip extra properties from the response from the API.
|
|
208
208
|
|
209
209
|
### Customizing the fetch client
|
210
210
|
|
211
|
-
By default, this library expects a global `fetch` function
|
211
|
+
By default, this library uses `node-fetch` in Node, and expects a global `fetch` function in other environments.
|
212
212
|
|
213
|
-
If you
|
213
|
+
If you would prefer to use a global, web-standards-compliant `fetch` function even in a Node environment,
|
214
|
+
(for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`),
|
215
|
+
add the following import before your first import `from "Roark"`:
|
214
216
|
|
215
217
|
```ts
|
216
|
-
|
217
|
-
|
218
|
-
|
218
|
+
// Tell TypeScript and the package to use the global web fetch instead of node-fetch.
|
219
|
+
// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.
|
220
|
+
import '@roarkanalytics/sdk/shims/web';
|
221
|
+
import Roark from '@roarkanalytics/sdk';
|
219
222
|
```
|
220
223
|
|
221
|
-
|
222
|
-
|
223
|
-
```ts
|
224
|
-
import fetch from 'my-fetch';
|
225
|
-
|
226
|
-
const client = new Petstore({ fetch });
|
227
|
-
```
|
224
|
+
To do the inverse, add `import "@roarkanalytics/sdk/shims/node"` (which does import polyfills).
|
225
|
+
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/roarkhq/sdk-roark-analytics-node/tree/main/src/_shims#readme)).
|
228
226
|
|
229
227
|
### Logging and middleware
|
230
228
|
|
@@ -233,9 +231,9 @@ which can be used to inspect or alter the `Request` or `Response` before/after e
|
|
233
231
|
|
234
232
|
```ts
|
235
233
|
import { fetch } from 'undici'; // as one example
|
236
|
-
import
|
234
|
+
import Roark from '@roarkanalytics/sdk';
|
237
235
|
|
238
|
-
const client = new
|
236
|
+
const client = new Roark({
|
239
237
|
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
|
240
238
|
console.log('About to make a request', url, init);
|
241
239
|
const response = await fetch(url, init);
|
@@ -245,69 +243,34 @@ const client = new Petstore({
|
|
245
243
|
});
|
246
244
|
```
|
247
245
|
|
248
|
-
Note that if given a `
|
246
|
+
Note that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically.
|
249
247
|
This is intended for debugging purposes only and may change in the future without notice.
|
250
248
|
|
251
|
-
###
|
252
|
-
|
253
|
-
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.)
|
254
|
-
|
255
|
-
```ts
|
256
|
-
import Petstore from '@roarkanalytics/sdk';
|
257
|
-
|
258
|
-
const client = new Petstore({
|
259
|
-
fetchOptions: {
|
260
|
-
// `RequestInit` options
|
261
|
-
},
|
262
|
-
});
|
263
|
-
```
|
264
|
-
|
265
|
-
#### Configuring proxies
|
266
|
-
|
267
|
-
To modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy
|
268
|
-
options to requests:
|
269
|
-
|
270
|
-
<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
|
+
### Configuring an HTTP(S) Agent (e.g., for proxies)
|
271
250
|
|
272
|
-
|
273
|
-
import Petstore from '@roarkanalytics/sdk';
|
274
|
-
import * as undici from 'undici';
|
275
|
-
|
276
|
-
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
|
277
|
-
const client = new Petstore({
|
278
|
-
fetchOptions: {
|
279
|
-
dispatcher: proxyAgent,
|
280
|
-
},
|
281
|
-
});
|
282
|
-
```
|
251
|
+
By default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP & TLS handshakes and shaving around 100ms off most requests.
|
283
252
|
|
284
|
-
|
253
|
+
If you would like to disable or customize this behavior, for example to use the API behind a proxy, you can pass an `httpAgent` which is used for all requests (be they http or https), for example:
|
285
254
|
|
255
|
+
<!-- prettier-ignore -->
|
286
256
|
```ts
|
287
|
-
import
|
257
|
+
import http from 'http';
|
258
|
+
import { HttpsProxyAgent } from 'https-proxy-agent';
|
288
259
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
},
|
260
|
+
// Configure the default for all requests:
|
261
|
+
const client = new Roark({
|
262
|
+
httpAgent: new HttpsProxyAgent(process.env.PROXY_URL),
|
293
263
|
});
|
294
|
-
```
|
295
|
-
|
296
|
-
<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>
|
297
|
-
|
298
|
-
```ts
|
299
|
-
import Petstore from 'npm:@roarkanalytics/sdk';
|
300
264
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
265
|
+
// Override per-request:
|
266
|
+
await client.calls.create(
|
267
|
+
{ direction: 'INBOUND', startedAt: '2025-02-04T06:23:19.633Z' },
|
268
|
+
{
|
269
|
+
httpAgent: new http.Agent({ keepAlive: false }),
|
305
270
|
},
|
306
|
-
|
271
|
+
);
|
307
272
|
```
|
308
273
|
|
309
|
-
## Frequently Asked Questions
|
310
|
-
|
311
274
|
## Semantic versioning
|
312
275
|
|
313
276
|
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:
|
@@ -322,7 +285,7 @@ We are keen for your feedback; please open an [issue](https://www.github.com/roa
|
|
322
285
|
|
323
286
|
## Requirements
|
324
287
|
|
325
|
-
TypeScript >= 4.
|
288
|
+
TypeScript >= 4.5 is supported.
|
326
289
|
|
327
290
|
The following runtimes are supported:
|
328
291
|
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MultipartBody.d.ts","sourceRoot":"","sources":["../src/_shims/MultipartBody.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,aAAa;IACL,IAAI,EAAE,GAAG;gBAAT,IAAI,EAAE,GAAG;IAC5B,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;CACF"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MultipartBody = void 0;
|
4
|
+
/**
|
5
|
+
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
6
|
+
*/
|
7
|
+
class MultipartBody {
|
8
|
+
constructor(body) {
|
9
|
+
this.body = body;
|
10
|
+
}
|
11
|
+
get [Symbol.toStringTag]() {
|
12
|
+
return 'MultipartBody';
|
13
|
+
}
|
14
|
+
}
|
15
|
+
exports.MultipartBody = MultipartBody;
|
16
|
+
//# sourceMappingURL=MultipartBody.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MultipartBody.js","sourceRoot":"","sources":["../src/_shims/MultipartBody.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,aAAa;IACxB,YAAmB,IAAS;QAAT,SAAI,GAAJ,IAAI,CAAK;IAAG,CAAC;IAChC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AALD,sCAKC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
3
|
+
*/
|
4
|
+
export class MultipartBody {
|
5
|
+
constructor(body) {
|
6
|
+
this.body = body;
|
7
|
+
}
|
8
|
+
get [Symbol.toStringTag]() {
|
9
|
+
return 'MultipartBody';
|
10
|
+
}
|
11
|
+
}
|
12
|
+
//# sourceMappingURL=MultipartBody.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MultipartBody.mjs","sourceRoot":"","sources":["../src/_shims/MultipartBody.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,aAAa;IACxB,YAAmB,IAAS;QAAT,SAAI,GAAJ,IAAI,CAAK;IAAG,CAAC;IAChC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF"}
|
package/_shims/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# 👋 Wondering what everything in here does?
|
2
|
+
|
3
|
+
`@roarkanalytics/sdk` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various
|
4
|
+
edge runtimes, as well as both CommonJS (CJS) and EcmaScript Modules (ESM).
|
5
|
+
|
6
|
+
To do this, `@roarkanalytics/sdk` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node.
|
7
|
+
|
8
|
+
It uses [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) to
|
9
|
+
automatically select the correct shims for each environment. However, conditional exports are a fairly new
|
10
|
+
feature and not supported everywhere. For instance, the TypeScript `"moduleResolution": "node"`
|
11
|
+
|
12
|
+
setting doesn't consult the `exports` map, compared to `"moduleResolution": "nodeNext"`, which does.
|
13
|
+
Unfortunately that's still the default setting, and it can result in errors like
|
14
|
+
getting the wrong raw `Response` type from `.asResponse()`, for example.
|
15
|
+
|
16
|
+
The user can work around these issues by manually importing one of:
|
17
|
+
|
18
|
+
- `import '@roarkanalytics/sdk/shims/node'`
|
19
|
+
- `import '@roarkanalytics/sdk/shims/web'`
|
20
|
+
|
21
|
+
All of the code here in `_shims` handles selecting the automatic default shims or manual overrides.
|
22
|
+
|
23
|
+
### How it works - Runtime
|
24
|
+
|
25
|
+
Runtime shims get installed by calling `setShims` exported by `@roarkanalytics/sdk/_shims/registry`.
|
26
|
+
|
27
|
+
Manually importing `@roarkanalytics/sdk/shims/node` or `@roarkanalytics/sdk/shims/web`, calls `setShims` with the respective runtime shims.
|
28
|
+
|
29
|
+
All client code imports shims from `@roarkanalytics/sdk/_shims/index`, which:
|
30
|
+
|
31
|
+
- checks if shims have been set manually
|
32
|
+
- if not, calls `setShims` with the shims from `@roarkanalytics/sdk/_shims/auto/runtime`
|
33
|
+
- re-exports the installed shims from `@roarkanalytics/sdk/_shims/registry`.
|
34
|
+
|
35
|
+
`@roarkanalytics/sdk/_shims/auto/runtime` exports web runtime shims.
|
36
|
+
If the `node` export condition is set, the export map replaces it with `@roarkanalytics/sdk/_shims/auto/runtime-node`.
|
37
|
+
|
38
|
+
### How it works - Type time
|
39
|
+
|
40
|
+
All client code imports shim types from `@roarkanalytics/sdk/_shims/index`, which selects the manual types from `@roarkanalytics/sdk/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `@roarkanalytics/sdk/_shims/auto/types`.
|
41
|
+
|
42
|
+
`@roarkanalytics/sdk/_shims/manual-types` exports an empty namespace.
|
43
|
+
Manually importing `@roarkanalytics/sdk/shims/node` or `@roarkanalytics/sdk/shims/web` merges declarations into this empty namespace, so they get picked up by `@roarkanalytics/sdk/_shims/index`.
|
44
|
+
|
45
|
+
`@roarkanalytics/sdk/_shims/auto/types` exports web type definitions.
|
46
|
+
If the `node` export condition is set, the export map replaces it with `@roarkanalytics/sdk/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`.
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtime-bun.d.ts","sourceRoot":"","sources":["../../src/_shims/auto/runtime-bun.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC"}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
3
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
4
3
|
if (k2 === undefined) k2 = k;
|
5
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
@@ -15,10 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
16
15
|
};
|
17
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
__exportStar(require("
|
22
|
-
|
23
|
-
__exportStar(require("./utils/sleep.js"), exports);
|
24
|
-
//# sourceMappingURL=utils.js.map
|
17
|
+
/**
|
18
|
+
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
19
|
+
*/
|
20
|
+
__exportStar(require("../bun-runtime.js"), exports);
|
21
|
+
//# sourceMappingURL=runtime-bun.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtime-bun.js","sourceRoot":"","sources":["../../src/_shims/auto/runtime-bun.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,oDAA+B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtime-bun.mjs","sourceRoot":"","sources":["../../src/_shims/auto/runtime-bun.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtime-node.d.ts","sourceRoot":"","sources":["../../src/_shims/auto/runtime-node.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,iBAAiB,CAAC"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
/**
|
18
|
+
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
19
|
+
*/
|
20
|
+
__exportStar(require("../node-runtime.js"), exports);
|
21
|
+
//# sourceMappingURL=runtime-node.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtime-node.js","sourceRoot":"","sources":["../../src/_shims/auto/runtime-node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,qDAAgC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtime-node.mjs","sourceRoot":"","sources":["../../src/_shims/auto/runtime-node.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/_shims/auto/runtime.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
/**
|
18
|
+
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
19
|
+
*/
|
20
|
+
__exportStar(require("../web-runtime.js"), exports);
|
21
|
+
//# sourceMappingURL=runtime.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/_shims/auto/runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,oDAA+B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runtime.mjs","sourceRoot":"","sources":["../../src/_shims/auto/runtime.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types-node.d.ts","sourceRoot":"","sources":["../../src/_shims/auto/types-node.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,eAAe,CAAC"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
/**
|
18
|
+
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
19
|
+
*/
|
20
|
+
__exportStar(require("../node-types.js"), exports);
|
21
|
+
//# sourceMappingURL=types-node.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types-node.js","sourceRoot":"","sources":["../../src/_shims/auto/types-node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,mDAA8B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types-node.mjs","sourceRoot":"","sources":["../../src/_shims/auto/types-node.ts"],"names":[],"mappings":""}
|