@roarkanalytics/sdk 2.21.0 → 2.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +112 -51
- package/api-promise.d.mts +2 -0
- package/api-promise.d.mts.map +1 -0
- package/api-promise.d.ts +2 -0
- package/api-promise.d.ts.map +1 -0
- package/api-promise.js +6 -0
- package/api-promise.js.map +1 -0
- package/api-promise.mjs +2 -0
- package/api-promise.mjs.map +1 -0
- package/client.d.mts +196 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +196 -0
- package/client.d.ts.map +1 -0
- package/client.js +472 -0
- package/client.js.map +1 -0
- package/client.mjs +468 -0
- package/client.mjs.map +1 -0
- 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 +2 -0
- package/error.d.mts.map +1 -0
- 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 -132
- package/index.d.mts.map +1 -0
- package/index.d.ts +5 -131
- package/index.d.ts.map +1 -1
- package/index.js +12 -130
- package/index.js.map +1 -1
- package/index.mjs +5 -103
- package/index.mjs.map +1 -1
- package/internal/builtin-types.d.mts +73 -0
- package/internal/builtin-types.d.mts.map +1 -0
- package/internal/builtin-types.d.ts +73 -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 +41 -0
- package/internal/errors.js.map +1 -0
- package/internal/errors.mjs +36 -0
- package/internal/errors.mjs.map +1 -0
- package/internal/headers.d.mts +20 -0
- package/internal/headers.d.mts.map +1 -0
- package/internal/headers.d.ts +20 -0
- package/internal/headers.d.ts.map +1 -0
- package/internal/headers.js +79 -0
- package/internal/headers.js.map +1 -0
- package/internal/headers.mjs +74 -0
- package/internal/headers.mjs.map +1 -0
- package/internal/parse.d.mts +12 -0
- package/internal/parse.d.mts.map +1 -0
- package/internal/parse.d.ts +12 -0
- package/internal/parse.d.ts.map +1 -0
- package/internal/parse.js +40 -0
- package/internal/parse.js.map +1 -0
- package/internal/parse.mjs +37 -0
- package/internal/parse.mjs.map +1 -0
- package/internal/qs/formats.d.mts +7 -0
- package/internal/qs/formats.d.mts.map +1 -0
- 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/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/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/types.d.mts +57 -0
- package/internal/qs/types.d.mts.map +1 -0
- package/internal/qs/utils.d.mts +15 -0
- package/internal/qs/utils.d.mts.map +1 -0
- 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 +75 -0
- package/internal/request-options.d.mts.map +1 -0
- package/internal/request-options.d.ts +75 -0
- package/internal/request-options.d.ts.map +1 -0
- package/internal/request-options.js +14 -0
- package/internal/request-options.js.map +1 -0
- package/internal/request-options.mjs +10 -0
- package/internal/request-options.mjs.map +1 -0
- package/internal/shim-types.d.mts +17 -0
- package/internal/shim-types.d.mts.map +1 -0
- package/internal/shim-types.d.ts +17 -0
- 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 +20 -0
- package/internal/shims.d.mts.map +1 -0
- package/internal/shims.d.ts +20 -0
- package/internal/shims.d.ts.map +1 -0
- package/internal/shims.js +92 -0
- package/internal/shims.js.map +1 -0
- package/internal/shims.mjs +85 -0
- package/internal/shims.mjs.map +1 -0
- 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 +69 -0
- package/internal/types.d.mts.map +1 -0
- package/internal/types.d.ts +69 -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 +42 -0
- package/internal/uploads.d.mts.map +1 -0
- package/internal/uploads.d.ts +42 -0
- package/internal/uploads.d.ts.map +1 -0
- package/internal/uploads.js +141 -0
- package/internal/uploads.js.map +1 -0
- package/internal/uploads.mjs +131 -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 +38 -0
- package/internal/utils/base64.js.map +1 -0
- package/internal/utils/base64.mjs +33 -0
- package/internal/utils/base64.mjs.map +1 -0
- 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 +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 +37 -0
- package/internal/utils/log.d.mts.map +1 -0
- package/internal/utils/log.d.ts +37 -0
- package/internal/utils/log.d.ts.map +1 -0
- package/internal/utils/log.js +85 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +79 -0
- package/internal/utils/log.mjs.map +1 -0
- 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 +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 +19 -0
- package/internal/utils/uuid.js.map +1 -0
- package/internal/utils/uuid.mjs +15 -0
- package/internal/utils/uuid.mjs.map +1 -0
- package/internal/utils/values.d.mts +18 -0
- package/internal/utils/values.d.mts.map +1 -0
- package/internal/utils/values.d.ts +18 -0
- package/internal/utils/values.d.ts.map +1 -0
- package/internal/utils/values.js +112 -0
- package/internal/utils/values.js.map +1 -0
- package/internal/utils/values.mjs +94 -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/internal/utils.js +11 -0
- package/internal/utils.js.map +1 -0
- package/internal/utils.mjs +8 -0
- package/internal/utils.mjs.map +1 -0
- package/package.json +108 -73
- package/resource.d.mts +2 -0
- package/resource.d.mts.map +1 -0
- 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 +1207 -0
- package/resources/call.d.mts.map +1 -0
- package/resources/call.d.ts +9 -10
- package/resources/call.d.ts.map +1 -1
- package/resources/call.js +17 -16
- package/resources/call.js.map +1 -1
- package/resources/call.mjs +17 -16
- package/resources/call.mjs.map +1 -1
- package/resources/evaluation.d.mts +1307 -0
- package/resources/evaluation.d.mts.map +1 -0
- package/resources/evaluation.d.ts +8 -9
- package/resources/evaluation.d.ts.map +1 -1
- package/resources/evaluation.js +15 -14
- package/resources/evaluation.js.map +1 -1
- package/resources/evaluation.mjs +15 -14
- 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 +4 -3
- package/resources/health.d.ts.map +1 -1
- package/resources/health.js +1 -1
- package/resources/health.js.map +1 -1
- package/resources/health.mjs +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 +114 -0
- package/resources/integrations.d.mts.map +1 -0
- package/resources/integrations.d.ts +5 -4
- package/resources/integrations.d.ts.map +1 -1
- package/resources/integrations.js +1 -1
- package/resources/integrations.js.map +1 -1
- package/resources/integrations.mjs +1 -1
- 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 +4 -3
- package/resources/metric.d.ts.map +1 -1
- package/resources/metric.js +1 -1
- package/resources/metric.js.map +1 -1
- package/resources/metric.mjs +1 -1
- package/resources/metric.mjs.map +1 -1
- package/resources/persona.d.mts +528 -0
- package/resources/persona.d.mts.map +1 -0
- package/resources/persona.d.ts +8 -9
- package/resources/persona.d.ts.map +1 -1
- package/resources/persona.js +23 -13
- package/resources/persona.js.map +1 -1
- package/resources/persona.mjs +23 -13
- package/resources/persona.mjs.map +1 -1
- package/resources/simulation.d.mts +802 -0
- package/resources/simulation.d.mts.map +1 -0
- package/resources/simulation.d.ts +10 -11
- package/resources/simulation.d.ts.map +1 -1
- package/resources/simulation.js +26 -15
- package/resources/simulation.js.map +1 -1
- package/resources/simulation.mjs +26 -15
- package/resources/simulation.mjs.map +1 -1
- package/resources.d.mts +2 -0
- package/resources.d.mts.map +1 -0
- package/resources.d.ts.map +1 -1
- package/resources.js +2 -15
- package/resources.js.map +1 -1
- package/src/api-promise.ts +2 -0
- package/src/client.ts +842 -0
- 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 +5 -308
- package/src/internal/README.md +3 -0
- package/src/internal/builtin-types.ts +93 -0
- package/src/internal/detect-platform.ts +196 -0
- package/src/internal/errors.ts +33 -0
- package/src/internal/headers.ts +97 -0
- package/src/internal/parse.ts +56 -0
- 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 +91 -0
- package/src/internal/shim-types.ts +26 -0
- package/src/internal/shims.ts +107 -0
- package/src/internal/to-file.ts +154 -0
- package/src/internal/types.ts +95 -0
- package/src/internal/uploads.ts +187 -0
- package/src/internal/utils/base64.ts +40 -0
- package/src/internal/utils/bytes.ts +32 -0
- package/src/internal/utils/env.ts +18 -0
- package/src/internal/utils/log.ts +126 -0
- package/src/internal/utils/path.ts +88 -0
- package/src/internal/utils/sleep.ts +3 -0
- package/src/internal/utils/uuid.ts +17 -0
- package/src/internal/utils/values.ts +105 -0
- package/src/internal/utils.ts +8 -0
- package/src/resource.ts +2 -11
- package/src/resources/call.ts +19 -38
- package/src/resources/evaluation.ts +21 -37
- package/src/resources/health.ts +4 -3
- package/src/resources/integrations.ts +7 -6
- package/src/resources/metric.ts +4 -3
- package/src/resources/persona.ts +16 -29
- package/src/resources/simulation.ts +22 -43
- package/src/tsconfig.json +2 -2
- package/src/uploads.ts +2 -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 +0 -21
- 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/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/shims/node.ts +0 -50
- package/src/shims/web.ts +0 -50
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { type Roark } from '../client';
|
|
4
|
+
|
|
5
|
+
import { type PromiseOrValue } from '../internal/types';
|
|
6
|
+
import { APIResponseProps, defaultParseResponse } from '../internal/parse';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A subclass of `Promise` providing additional helper methods
|
|
10
|
+
* for interacting with the SDK.
|
|
11
|
+
*/
|
|
12
|
+
export class APIPromise<T> extends Promise<T> {
|
|
13
|
+
private parsedPromise: Promise<T> | undefined;
|
|
14
|
+
#client: Roark;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
client: Roark,
|
|
18
|
+
private responsePromise: Promise<APIResponseProps>,
|
|
19
|
+
private parseResponse: (
|
|
20
|
+
client: Roark,
|
|
21
|
+
props: APIResponseProps,
|
|
22
|
+
) => PromiseOrValue<T> = defaultParseResponse,
|
|
23
|
+
) {
|
|
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 as any);
|
|
29
|
+
});
|
|
30
|
+
this.#client = client;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U> {
|
|
34
|
+
return new APIPromise(this.#client, this.responsePromise, async (client, props) =>
|
|
35
|
+
transform(await this.parseResponse(client, props), props),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Gets the raw `Response` instance instead of parsing the response
|
|
41
|
+
* data.
|
|
42
|
+
*
|
|
43
|
+
* If you want to parse the response body but still get the `Response`
|
|
44
|
+
* instance, you can use {@link withResponse()}.
|
|
45
|
+
*
|
|
46
|
+
* 👋 Getting the wrong TypeScript type for `Response`?
|
|
47
|
+
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
|
|
48
|
+
* to your `tsconfig.json`.
|
|
49
|
+
*/
|
|
50
|
+
asResponse(): Promise<Response> {
|
|
51
|
+
return this.responsePromise.then((p) => p.response);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Gets the parsed response data and the raw `Response` instance.
|
|
56
|
+
*
|
|
57
|
+
* If you just want to get the raw `Response` instance without parsing it,
|
|
58
|
+
* you can use {@link asResponse()}.
|
|
59
|
+
*
|
|
60
|
+
* 👋 Getting the wrong TypeScript type for `Response`?
|
|
61
|
+
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
|
|
62
|
+
* to your `tsconfig.json`.
|
|
63
|
+
*/
|
|
64
|
+
async withResponse(): Promise<{ data: T; response: Response }> {
|
|
65
|
+
const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
|
|
66
|
+
return { data, response };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private parse(): Promise<T> {
|
|
70
|
+
if (!this.parsedPromise) {
|
|
71
|
+
this.parsedPromise = this.responsePromise.then((data) => this.parseResponse(this.#client, data));
|
|
72
|
+
}
|
|
73
|
+
return this.parsedPromise;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
override then<TResult1 = T, TResult2 = never>(
|
|
77
|
+
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
|
|
78
|
+
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,
|
|
79
|
+
): Promise<TResult1 | TResult2> {
|
|
80
|
+
return this.parse().then(onfulfilled, onrejected);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
override catch<TResult = never>(
|
|
84
|
+
onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null,
|
|
85
|
+
): Promise<T | TResult> {
|
|
86
|
+
return this.parse().catch(onrejected);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
override finally(onfinally?: (() => void) | undefined | null): Promise<T> {
|
|
90
|
+
return this.parse().finally(onfinally);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { castToError } from '../internal/errors';
|
|
4
|
+
|
|
5
|
+
export class RoarkError extends Error {}
|
|
6
|
+
|
|
7
|
+
export class APIError<
|
|
8
|
+
TStatus extends number | undefined = number | undefined,
|
|
9
|
+
THeaders extends Headers | undefined = Headers | undefined,
|
|
10
|
+
TError extends Object | undefined = Object | undefined,
|
|
11
|
+
> extends RoarkError {
|
|
12
|
+
/** HTTP status for the response that caused the error */
|
|
13
|
+
readonly status: TStatus;
|
|
14
|
+
/** HTTP headers for the response that caused the error */
|
|
15
|
+
readonly headers: THeaders;
|
|
16
|
+
/** JSON body of the response that caused the error */
|
|
17
|
+
readonly error: TError;
|
|
18
|
+
|
|
19
|
+
constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
|
|
20
|
+
super(`${APIError.makeMessage(status, error, message)}`);
|
|
21
|
+
this.status = status;
|
|
22
|
+
this.headers = headers;
|
|
23
|
+
this.error = error;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
|
|
27
|
+
const msg =
|
|
28
|
+
error?.message ?
|
|
29
|
+
typeof error.message === 'string' ?
|
|
30
|
+
error.message
|
|
31
|
+
: JSON.stringify(error.message)
|
|
32
|
+
: error ? JSON.stringify(error)
|
|
33
|
+
: message;
|
|
34
|
+
|
|
35
|
+
if (status && msg) {
|
|
36
|
+
return `${status} ${msg}`;
|
|
37
|
+
}
|
|
38
|
+
if (status) {
|
|
39
|
+
return `${status} status code (no body)`;
|
|
40
|
+
}
|
|
41
|
+
if (msg) {
|
|
42
|
+
return msg;
|
|
43
|
+
}
|
|
44
|
+
return '(no status code or body)';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static generate(
|
|
48
|
+
status: number | undefined,
|
|
49
|
+
errorResponse: Object | undefined,
|
|
50
|
+
message: string | undefined,
|
|
51
|
+
headers: Headers | undefined,
|
|
52
|
+
): APIError {
|
|
53
|
+
if (!status || !headers) {
|
|
54
|
+
return new APIConnectionError({ message, cause: castToError(errorResponse) });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const error = errorResponse as Record<string, any>;
|
|
58
|
+
|
|
59
|
+
if (status === 400) {
|
|
60
|
+
return new BadRequestError(status, error, message, headers);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (status === 401) {
|
|
64
|
+
return new AuthenticationError(status, error, message, headers);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (status === 403) {
|
|
68
|
+
return new PermissionDeniedError(status, error, message, headers);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (status === 404) {
|
|
72
|
+
return new NotFoundError(status, error, message, headers);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (status === 409) {
|
|
76
|
+
return new ConflictError(status, error, message, headers);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (status === 422) {
|
|
80
|
+
return new UnprocessableEntityError(status, error, message, headers);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (status === 429) {
|
|
84
|
+
return new RateLimitError(status, error, message, headers);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (status >= 500) {
|
|
88
|
+
return new InternalServerError(status, error, message, headers);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return new APIError(status, error, message, headers);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export class APIUserAbortError extends APIError<undefined, undefined, undefined> {
|
|
96
|
+
constructor({ message }: { message?: string } = {}) {
|
|
97
|
+
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class APIConnectionError extends APIError<undefined, undefined, undefined> {
|
|
102
|
+
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
|
|
103
|
+
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
104
|
+
// in some environments the 'cause' property is already declared
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
if (cause) this.cause = cause;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
111
|
+
constructor({ message }: { message?: string } = {}) {
|
|
112
|
+
super({ message: message ?? 'Request timed out.' });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export class BadRequestError extends APIError<400, Headers> {}
|
|
117
|
+
|
|
118
|
+
export class AuthenticationError extends APIError<401, Headers> {}
|
|
119
|
+
|
|
120
|
+
export class PermissionDeniedError extends APIError<403, Headers> {}
|
|
121
|
+
|
|
122
|
+
export class NotFoundError extends APIError<404, Headers> {}
|
|
123
|
+
|
|
124
|
+
export class ConflictError extends APIError<409, Headers> {}
|
|
125
|
+
|
|
126
|
+
export class UnprocessableEntityError extends APIError<422, Headers> {}
|
|
127
|
+
|
|
128
|
+
export class RateLimitError extends APIError<429, Headers> {}
|
|
129
|
+
|
|
130
|
+
export class InternalServerError extends APIError<number, Headers> {}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import type { Roark } from '../client';
|
|
4
|
+
|
|
5
|
+
export abstract class APIResource {
|
|
6
|
+
protected _client: Roark;
|
|
7
|
+
|
|
8
|
+
constructor(client: Roark) {
|
|
9
|
+
this._client = client;
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/error.ts
CHANGED
|
@@ -1,130 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { castToError, Headers } from './core';
|
|
4
|
-
|
|
5
|
-
export class RoarkError extends Error {}
|
|
6
|
-
|
|
7
|
-
export class APIError<
|
|
8
|
-
TStatus extends number | undefined = number | undefined,
|
|
9
|
-
THeaders extends Headers | undefined = Headers | undefined,
|
|
10
|
-
TError extends Object | undefined = Object | undefined,
|
|
11
|
-
> extends RoarkError {
|
|
12
|
-
/** HTTP status for the response that caused the error */
|
|
13
|
-
readonly status: TStatus;
|
|
14
|
-
/** HTTP headers for the response that caused the error */
|
|
15
|
-
readonly headers: THeaders;
|
|
16
|
-
/** JSON body of the response that caused the error */
|
|
17
|
-
readonly error: TError;
|
|
18
|
-
|
|
19
|
-
constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
|
|
20
|
-
super(`${APIError.makeMessage(status, error, message)}`);
|
|
21
|
-
this.status = status;
|
|
22
|
-
this.headers = headers;
|
|
23
|
-
this.error = error;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
|
|
27
|
-
const msg =
|
|
28
|
-
error?.message ?
|
|
29
|
-
typeof error.message === 'string' ?
|
|
30
|
-
error.message
|
|
31
|
-
: JSON.stringify(error.message)
|
|
32
|
-
: error ? JSON.stringify(error)
|
|
33
|
-
: message;
|
|
34
|
-
|
|
35
|
-
if (status && msg) {
|
|
36
|
-
return `${status} ${msg}`;
|
|
37
|
-
}
|
|
38
|
-
if (status) {
|
|
39
|
-
return `${status} status code (no body)`;
|
|
40
|
-
}
|
|
41
|
-
if (msg) {
|
|
42
|
-
return msg;
|
|
43
|
-
}
|
|
44
|
-
return '(no status code or body)';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static generate(
|
|
48
|
-
status: number | undefined,
|
|
49
|
-
errorResponse: Object | undefined,
|
|
50
|
-
message: string | undefined,
|
|
51
|
-
headers: Headers | undefined,
|
|
52
|
-
): APIError {
|
|
53
|
-
if (!status || !headers) {
|
|
54
|
-
return new APIConnectionError({ message, cause: castToError(errorResponse) });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const error = errorResponse as Record<string, any>;
|
|
58
|
-
|
|
59
|
-
if (status === 400) {
|
|
60
|
-
return new BadRequestError(status, error, message, headers);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (status === 401) {
|
|
64
|
-
return new AuthenticationError(status, error, message, headers);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (status === 403) {
|
|
68
|
-
return new PermissionDeniedError(status, error, message, headers);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (status === 404) {
|
|
72
|
-
return new NotFoundError(status, error, message, headers);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (status === 409) {
|
|
76
|
-
return new ConflictError(status, error, message, headers);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (status === 422) {
|
|
80
|
-
return new UnprocessableEntityError(status, error, message, headers);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (status === 429) {
|
|
84
|
-
return new RateLimitError(status, error, message, headers);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (status >= 500) {
|
|
88
|
-
return new InternalServerError(status, error, message, headers);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return new APIError(status, error, message, headers);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export class APIUserAbortError extends APIError<undefined, undefined, undefined> {
|
|
96
|
-
constructor({ message }: { message?: string } = {}) {
|
|
97
|
-
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export class APIConnectionError extends APIError<undefined, undefined, undefined> {
|
|
102
|
-
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
|
|
103
|
-
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
104
|
-
// in some environments the 'cause' property is already declared
|
|
105
|
-
// @ts-ignore
|
|
106
|
-
if (cause) this.cause = cause;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
111
|
-
constructor({ message }: { message?: string } = {}) {
|
|
112
|
-
super({ message: message ?? 'Request timed out.' });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export class BadRequestError extends APIError<400, Headers> {}
|
|
117
|
-
|
|
118
|
-
export class AuthenticationError extends APIError<401, Headers> {}
|
|
119
|
-
|
|
120
|
-
export class PermissionDeniedError extends APIError<403, Headers> {}
|
|
121
|
-
|
|
122
|
-
export class NotFoundError extends APIError<404, Headers> {}
|
|
123
|
-
|
|
124
|
-
export class ConflictError extends APIError<409, Headers> {}
|
|
125
|
-
|
|
126
|
-
export class UnprocessableEntityError extends APIError<422, Headers> {}
|
|
127
|
-
|
|
128
|
-
export class RateLimitError extends APIError<429, Headers> {}
|
|
129
|
-
|
|
130
|
-
export class InternalServerError extends APIError<number, Headers> {}
|
|
1
|
+
/** @deprecated Import from ./core/error instead */
|
|
2
|
+
export * from './core/error';
|
package/src/index.ts
CHANGED
|
@@ -1,311 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import * as qs from './internal/qs';
|
|
5
|
-
import * as Core from './core';
|
|
6
|
-
import * as Errors from './error';
|
|
7
|
-
import * as Uploads from './uploads';
|
|
8
|
-
import * as API from './resources/index';
|
|
9
|
-
import {
|
|
10
|
-
Call,
|
|
11
|
-
CallCreateParams,
|
|
12
|
-
CallCreateResponse,
|
|
13
|
-
CallGetByIDResponse,
|
|
14
|
-
CallListEvaluationRunsResponse,
|
|
15
|
-
CallListMetricsParams,
|
|
16
|
-
CallListMetricsResponse,
|
|
17
|
-
CallListParams,
|
|
18
|
-
CallListResponse,
|
|
19
|
-
CallListSentimentRunsResponse,
|
|
20
|
-
} from './resources/call';
|
|
21
|
-
import {
|
|
22
|
-
Evaluation,
|
|
23
|
-
EvaluationCreateJobParams,
|
|
24
|
-
EvaluationCreateJobResponse,
|
|
25
|
-
EvaluationGetEvaluatorByIDResponse,
|
|
26
|
-
EvaluationGetJobResponse,
|
|
27
|
-
EvaluationListEvaluatorsParams,
|
|
28
|
-
EvaluationListEvaluatorsResponse,
|
|
29
|
-
EvaluationListJobRunsParams,
|
|
30
|
-
EvaluationListJobRunsResponse,
|
|
31
|
-
} from './resources/evaluation';
|
|
32
|
-
import { Health, HealthGetResponse } from './resources/health';
|
|
33
|
-
import {
|
|
34
|
-
IntegrationCreateRetellCallParams,
|
|
35
|
-
IntegrationCreateRetellCallResponse,
|
|
36
|
-
IntegrationCreateVapiCallParams,
|
|
37
|
-
IntegrationCreateVapiCallResponse,
|
|
38
|
-
Integrations,
|
|
39
|
-
} from './resources/integrations';
|
|
40
|
-
import { Metric, MetricListDefinitionsResponse } from './resources/metric';
|
|
41
|
-
import {
|
|
42
|
-
Persona,
|
|
43
|
-
PersonaCreateParams,
|
|
44
|
-
PersonaCreateResponse,
|
|
45
|
-
PersonaGetByIDResponse,
|
|
46
|
-
PersonaListParams,
|
|
47
|
-
PersonaListResponse,
|
|
48
|
-
PersonaUpdateParams,
|
|
49
|
-
PersonaUpdateResponse,
|
|
50
|
-
} from './resources/persona';
|
|
51
|
-
import {
|
|
52
|
-
Simulation,
|
|
53
|
-
SimulationGetRunPlanJobResponse,
|
|
54
|
-
SimulationGetSimulationJobByIDResponse,
|
|
55
|
-
SimulationListRunPlanJobsParams,
|
|
56
|
-
SimulationListRunPlanJobsResponse,
|
|
57
|
-
SimulationListScenariosParams,
|
|
58
|
-
SimulationListScenariosResponse,
|
|
59
|
-
SimulationLookupSimulationJobParams,
|
|
60
|
-
SimulationLookupSimulationJobResponse,
|
|
61
|
-
SimulationStartRunPlanJobResponse,
|
|
62
|
-
} from './resources/simulation';
|
|
3
|
+
export { Roark as default } from './client';
|
|
63
4
|
|
|
64
|
-
export
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*/
|
|
68
|
-
bearerToken?: string | undefined;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
72
|
-
*
|
|
73
|
-
* Defaults to process.env['ROARK_BASE_URL'].
|
|
74
|
-
*/
|
|
75
|
-
baseURL?: string | null | undefined;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
79
|
-
* from the server before timing out a single request.
|
|
80
|
-
*
|
|
81
|
-
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
82
|
-
* much longer than this timeout before the promise succeeds or fails.
|
|
83
|
-
*
|
|
84
|
-
* @unit milliseconds
|
|
85
|
-
*/
|
|
86
|
-
timeout?: number | undefined;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* An HTTP agent used to manage HTTP(S) connections.
|
|
90
|
-
*
|
|
91
|
-
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
92
|
-
* otherwise no agent is used.
|
|
93
|
-
*/
|
|
94
|
-
httpAgent?: Agent | undefined;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Specify a custom `fetch` function implementation.
|
|
98
|
-
*
|
|
99
|
-
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
100
|
-
* defined globally.
|
|
101
|
-
*/
|
|
102
|
-
fetch?: Core.Fetch | undefined;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* The maximum number of times that the client will retry a request in case of a
|
|
106
|
-
* temporary failure, like a network error or a 5XX error from the server.
|
|
107
|
-
*
|
|
108
|
-
* @default 2
|
|
109
|
-
*/
|
|
110
|
-
maxRetries?: number | undefined;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Default headers to include with every request to the API.
|
|
114
|
-
*
|
|
115
|
-
* These can be removed in individual requests by explicitly setting the
|
|
116
|
-
* header to `undefined` or `null` in request options.
|
|
117
|
-
*/
|
|
118
|
-
defaultHeaders?: Core.Headers | undefined;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Default query parameters to include with every request to the API.
|
|
122
|
-
*
|
|
123
|
-
* These can be removed in individual requests by explicitly setting the
|
|
124
|
-
* param to `undefined` in request options.
|
|
125
|
-
*/
|
|
126
|
-
defaultQuery?: Core.DefaultQuery | undefined;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* API Client for interfacing with the Roark API.
|
|
131
|
-
*/
|
|
132
|
-
export class Roark extends Core.APIClient {
|
|
133
|
-
bearerToken: string;
|
|
134
|
-
|
|
135
|
-
private _options: ClientOptions;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* API Client for interfacing with the Roark API.
|
|
139
|
-
*
|
|
140
|
-
* @param {string | undefined} [opts.bearerToken=process.env['ROARK_API_BEARER_TOKEN'] ?? undefined]
|
|
141
|
-
* @param {string} [opts.baseURL=process.env['ROARK_BASE_URL'] ?? https://api.roark.ai] - Override the default base URL for the API.
|
|
142
|
-
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
143
|
-
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
144
|
-
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
145
|
-
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
146
|
-
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
147
|
-
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
148
|
-
*/
|
|
149
|
-
constructor({
|
|
150
|
-
baseURL = Core.readEnv('ROARK_BASE_URL'),
|
|
151
|
-
bearerToken = Core.readEnv('ROARK_API_BEARER_TOKEN'),
|
|
152
|
-
...opts
|
|
153
|
-
}: ClientOptions = {}) {
|
|
154
|
-
if (bearerToken === undefined) {
|
|
155
|
-
throw new Errors.RoarkError(
|
|
156
|
-
"The ROARK_API_BEARER_TOKEN environment variable is missing or empty; either provide it, or instantiate the Roark client with an bearerToken option, like new Roark({ bearerToken: 'My Bearer Token' }).",
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const options: ClientOptions = {
|
|
161
|
-
bearerToken,
|
|
162
|
-
...opts,
|
|
163
|
-
baseURL: baseURL || `https://api.roark.ai`,
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
super({
|
|
167
|
-
baseURL: options.baseURL!,
|
|
168
|
-
baseURLOverridden: baseURL ? baseURL !== 'https://api.roark.ai' : false,
|
|
169
|
-
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
170
|
-
httpAgent: options.httpAgent,
|
|
171
|
-
maxRetries: options.maxRetries,
|
|
172
|
-
fetch: options.fetch,
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
this._options = options;
|
|
176
|
-
|
|
177
|
-
this.bearerToken = bearerToken;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
health: API.Health = new API.Health(this);
|
|
181
|
-
evaluation: API.Evaluation = new API.Evaluation(this);
|
|
182
|
-
call: API.Call = new API.Call(this);
|
|
183
|
-
metric: API.Metric = new API.Metric(this);
|
|
184
|
-
integrations: API.Integrations = new API.Integrations(this);
|
|
185
|
-
simulation: API.Simulation = new API.Simulation(this);
|
|
186
|
-
persona: API.Persona = new API.Persona(this);
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Check whether the base URL is set to its default.
|
|
190
|
-
*/
|
|
191
|
-
#baseURLOverridden(): boolean {
|
|
192
|
-
return this.baseURL !== 'https://api.roark.ai';
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
196
|
-
return this._options.defaultQuery;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
200
|
-
return {
|
|
201
|
-
...super.defaultHeaders(opts),
|
|
202
|
-
...this._options.defaultHeaders,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
207
|
-
return { Authorization: `Bearer ${this.bearerToken}` };
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
protected override stringifyQuery(query: Record<string, unknown>): string {
|
|
211
|
-
return qs.stringify(query, { arrayFormat: 'comma' });
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
static Roark = this;
|
|
215
|
-
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
216
|
-
|
|
217
|
-
static RoarkError = Errors.RoarkError;
|
|
218
|
-
static APIError = Errors.APIError;
|
|
219
|
-
static APIConnectionError = Errors.APIConnectionError;
|
|
220
|
-
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
221
|
-
static APIUserAbortError = Errors.APIUserAbortError;
|
|
222
|
-
static NotFoundError = Errors.NotFoundError;
|
|
223
|
-
static ConflictError = Errors.ConflictError;
|
|
224
|
-
static RateLimitError = Errors.RateLimitError;
|
|
225
|
-
static BadRequestError = Errors.BadRequestError;
|
|
226
|
-
static AuthenticationError = Errors.AuthenticationError;
|
|
227
|
-
static InternalServerError = Errors.InternalServerError;
|
|
228
|
-
static PermissionDeniedError = Errors.PermissionDeniedError;
|
|
229
|
-
static UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
230
|
-
|
|
231
|
-
static toFile = Uploads.toFile;
|
|
232
|
-
static fileFromPath = Uploads.fileFromPath;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
Roark.Health = Health;
|
|
236
|
-
Roark.Evaluation = Evaluation;
|
|
237
|
-
Roark.Call = Call;
|
|
238
|
-
Roark.Metric = Metric;
|
|
239
|
-
Roark.Integrations = Integrations;
|
|
240
|
-
Roark.Simulation = Simulation;
|
|
241
|
-
Roark.Persona = Persona;
|
|
242
|
-
|
|
243
|
-
export declare namespace Roark {
|
|
244
|
-
export type RequestOptions = Core.RequestOptions;
|
|
245
|
-
|
|
246
|
-
export { Health as Health, type HealthGetResponse as HealthGetResponse };
|
|
247
|
-
|
|
248
|
-
export {
|
|
249
|
-
Evaluation as Evaluation,
|
|
250
|
-
type EvaluationCreateJobResponse as EvaluationCreateJobResponse,
|
|
251
|
-
type EvaluationGetEvaluatorByIDResponse as EvaluationGetEvaluatorByIDResponse,
|
|
252
|
-
type EvaluationGetJobResponse as EvaluationGetJobResponse,
|
|
253
|
-
type EvaluationListEvaluatorsResponse as EvaluationListEvaluatorsResponse,
|
|
254
|
-
type EvaluationListJobRunsResponse as EvaluationListJobRunsResponse,
|
|
255
|
-
type EvaluationCreateJobParams as EvaluationCreateJobParams,
|
|
256
|
-
type EvaluationListEvaluatorsParams as EvaluationListEvaluatorsParams,
|
|
257
|
-
type EvaluationListJobRunsParams as EvaluationListJobRunsParams,
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
export {
|
|
261
|
-
Call as Call,
|
|
262
|
-
type CallCreateResponse as CallCreateResponse,
|
|
263
|
-
type CallListResponse as CallListResponse,
|
|
264
|
-
type CallGetByIDResponse as CallGetByIDResponse,
|
|
265
|
-
type CallListEvaluationRunsResponse as CallListEvaluationRunsResponse,
|
|
266
|
-
type CallListMetricsResponse as CallListMetricsResponse,
|
|
267
|
-
type CallListSentimentRunsResponse as CallListSentimentRunsResponse,
|
|
268
|
-
type CallCreateParams as CallCreateParams,
|
|
269
|
-
type CallListParams as CallListParams,
|
|
270
|
-
type CallListMetricsParams as CallListMetricsParams,
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
export { Metric as Metric, type MetricListDefinitionsResponse as MetricListDefinitionsResponse };
|
|
274
|
-
|
|
275
|
-
export {
|
|
276
|
-
Integrations as Integrations,
|
|
277
|
-
type IntegrationCreateRetellCallResponse as IntegrationCreateRetellCallResponse,
|
|
278
|
-
type IntegrationCreateVapiCallResponse as IntegrationCreateVapiCallResponse,
|
|
279
|
-
type IntegrationCreateRetellCallParams as IntegrationCreateRetellCallParams,
|
|
280
|
-
type IntegrationCreateVapiCallParams as IntegrationCreateVapiCallParams,
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
export {
|
|
284
|
-
Simulation as Simulation,
|
|
285
|
-
type SimulationGetRunPlanJobResponse as SimulationGetRunPlanJobResponse,
|
|
286
|
-
type SimulationGetSimulationJobByIDResponse as SimulationGetSimulationJobByIDResponse,
|
|
287
|
-
type SimulationListRunPlanJobsResponse as SimulationListRunPlanJobsResponse,
|
|
288
|
-
type SimulationListScenariosResponse as SimulationListScenariosResponse,
|
|
289
|
-
type SimulationLookupSimulationJobResponse as SimulationLookupSimulationJobResponse,
|
|
290
|
-
type SimulationStartRunPlanJobResponse as SimulationStartRunPlanJobResponse,
|
|
291
|
-
type SimulationListRunPlanJobsParams as SimulationListRunPlanJobsParams,
|
|
292
|
-
type SimulationListScenariosParams as SimulationListScenariosParams,
|
|
293
|
-
type SimulationLookupSimulationJobParams as SimulationLookupSimulationJobParams,
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
export {
|
|
297
|
-
Persona as Persona,
|
|
298
|
-
type PersonaCreateResponse as PersonaCreateResponse,
|
|
299
|
-
type PersonaUpdateResponse as PersonaUpdateResponse,
|
|
300
|
-
type PersonaListResponse as PersonaListResponse,
|
|
301
|
-
type PersonaGetByIDResponse as PersonaGetByIDResponse,
|
|
302
|
-
type PersonaCreateParams as PersonaCreateParams,
|
|
303
|
-
type PersonaUpdateParams as PersonaUpdateParams,
|
|
304
|
-
type PersonaListParams as PersonaListParams,
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export { toFile, fileFromPath } from './uploads';
|
|
5
|
+
export { type Uploadable, toFile } from './core/uploads';
|
|
6
|
+
export { APIPromise } from './core/api-promise';
|
|
7
|
+
export { Roark, type ClientOptions } from './client';
|
|
309
8
|
export {
|
|
310
9
|
RoarkError,
|
|
311
10
|
APIError,
|
|
@@ -320,6 +19,4 @@ export {
|
|
|
320
19
|
InternalServerError,
|
|
321
20
|
PermissionDeniedError,
|
|
322
21
|
UnprocessableEntityError,
|
|
323
|
-
} from './error';
|
|
324
|
-
|
|
325
|
-
export default Roark;
|
|
22
|
+
} from './core/error';
|