spitch 0.1.0-alpha.1 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -8
- package/LICENSE +1 -1
- package/README.md +170 -71
- 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 +183 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +183 -0
- package/client.d.ts.map +1 -0
- package/client.js +464 -0
- package/client.js.map +1 -0
- package/client.mjs +460 -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 -52
- package/error.d.ts.map +1 -1
- package/error.js +3 -140
- package/error.js.map +1 -1
- package/error.mjs +1 -126
- package/error.mjs.map +1 -1
- package/index.d.mts +6 -118
- package/index.d.mts.map +1 -0
- package/index.d.ts +5 -117
- package/index.d.ts.map +1 -1
- package/index.js +26 -107
- package/index.js.map +1 -1
- package/index.mjs +5 -81
- 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 +35 -0
- package/internal/parse.js.map +1 -0
- package/internal/parse.mjs +32 -0
- package/internal/parse.mjs.map +1 -0
- 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 +104 -72
- 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/index.d.mts +3 -0
- package/resources/index.d.mts.map +1 -0
- package/resources/index.d.ts +2 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/speech.d.mts +44 -0
- package/resources/speech.d.mts.map +1 -0
- package/resources/speech.d.ts +28 -29
- package/resources/speech.d.ts.map +1 -1
- package/resources/speech.js +15 -32
- package/resources/speech.js.map +1 -1
- package/resources/speech.mjs +15 -9
- package/resources/speech.mjs.map +1 -1
- package/resources/text.d.mts +34 -0
- package/resources/text.d.mts.map +1 -0
- package/resources/text.d.ts +23 -8
- package/resources/text.d.ts.map +1 -1
- package/resources/text.js +7 -3
- package/resources/text.js.map +1 -1
- package/resources/text.mjs +7 -3
- package/resources/text.mjs.map +1 -1
- package/resources.d.mts +2 -0
- package/resources.d.mts.map +1 -0
- package/resources.d.ts +2 -0
- package/resources.d.ts.map +1 -0
- package/resources.js +5 -0
- package/resources.js.map +1 -0
- package/resources.mjs +2 -0
- package/resources.mjs.map +1 -0
- package/src/api-promise.ts +2 -0
- package/src/client.ts +751 -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 -146
- package/src/index.ts +6 -178
- 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 +50 -0
- 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/index.ts +10 -5
- package/src/resources/speech.ts +74 -33
- package/src/resources/text.ts +38 -9
- package/src/resources.ts +1 -0
- 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.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +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 -81
- package/_shims/index.js +0 -13
- package/_shims/index.mjs +0 -7
- 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 -242
- package/core.d.ts.map +0 -1
- package/core.js +0 -901
- package/core.js.map +0 -1
- package/core.mjs +0 -869
- 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 -81
- package/src/_shims/index.js +0 -13
- package/src/_shims/index.mjs +0 -7
- 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 -65
- 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 -1190
- package/src/shims/node.ts +0 -50
- package/src/shims/web.ts +0 -50
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 1.18.0 (2025-08-02)
|
|
4
4
|
|
|
5
|
-
Full Changelog: [
|
|
5
|
+
Full Changelog: [v1.17.0...v1.18.0](https://github.com/spi-tch/spitch-typescript/compare/v1.17.0...v1.18.0)
|
|
6
6
|
|
|
7
7
|
### Features
|
|
8
8
|
|
|
9
|
-
* **api:** update via SDK Studio ([
|
|
9
|
+
* **api:** update via SDK Studio ([7a1064a](https://github.com/spi-tch/spitch-typescript/commit/7a1064a21ff0f29a22de6f366d83cbeba0737154))
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## 1.17.0 (2025-08-02)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v0.1.0-alpha.1...v1.17.0](https://github.com/spi-tch/spitch-typescript/compare/v0.1.0-alpha.1...v1.17.0)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **api:** update via SDK Studio ([f73d00e](https://github.com/spi-tch/spitch-typescript/commit/f73d00ee3d5701d1f1904402353ef7f70c70f93d))
|
|
18
|
+
|
|
19
|
+
## 0.1.0-alpha.1 (2025-08-01)
|
|
20
|
+
|
|
21
|
+
Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/spi-tch/spitch-typescript/compare/v0.0.1-alpha.0...v0.1.0-alpha.1)
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* **api:** update via SDK Studio ([a34386f](https://github.com/spi-tch/spitch-typescript/commit/a34386f023f82cb9cea023b634fd2bc422845015))
|
|
26
|
+
* **api:** update via SDK Studio ([034dd1d](https://github.com/spi-tch/spitch-typescript/commit/034dd1df081f1590dfeaeef4e57baf849bbc6e9e))
|
|
12
27
|
|
|
13
|
-
Full Changelog: [v0.0.1-alpha.0...v0.0.1-alpha.1](https://github.com/spi-tch/spitch-node/compare/v0.0.1-alpha.0...v0.0.1-alpha.1)
|
|
14
28
|
|
|
15
29
|
### Chores
|
|
16
30
|
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* go live ([#1](https://github.com/spi-tch/spitch-node/issues/1)) ([0ef989d](https://github.com/spi-tch/spitch-node/commit/0ef989d934571aca2926db0b1c1d0c4ff11497b1))
|
|
31
|
+
* update SDK settings ([62b07a3](https://github.com/spi-tch/spitch-typescript/commit/62b07a379a86104a2ed9fd8fbeb459f352b13071))
|
|
32
|
+
* update SDK settings ([fa5033d](https://github.com/spi-tch/spitch-typescript/commit/fa5033d84fcf7235a201072b965b65fcf771b492))
|
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
|
|
189
|
+
Copyright 2025 Spitch
|
|
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,12 +1,12 @@
|
|
|
1
|
-
# Spitch
|
|
1
|
+
# Spitch TypeScript API Library
|
|
2
2
|
|
|
3
|
-
[](https://npmjs.org/package/spitch) 
|
|
3
|
+
[>)](https://npmjs.org/package/spitch) 
|
|
4
4
|
|
|
5
5
|
This library provides convenient access to the Spitch REST API from server-side TypeScript or JavaScript.
|
|
6
6
|
|
|
7
|
-
The REST API documentation can be found on [docs.
|
|
7
|
+
The REST API documentation can be found on [docs.spitch.app](https://docs.spitch.app). The full API of this library can be found in [api.md](api.md).
|
|
8
8
|
|
|
9
|
-
It is generated with [Stainless](https://www.
|
|
9
|
+
It is generated with [Stainless](https://www.stainless.com/).
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
@@ -22,15 +22,12 @@ The full API of this library can be found in [api.md](api.md).
|
|
|
22
22
|
```js
|
|
23
23
|
import Spitch from 'spitch';
|
|
24
24
|
|
|
25
|
-
const client = new Spitch(
|
|
26
|
-
apiKey: process.env['SPITCH_API_KEY'], // This is the default and can be omitted
|
|
27
|
-
});
|
|
25
|
+
const client = new Spitch();
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
const response = await client.speech.transcibe({ language: 'yo' });
|
|
31
|
-
}
|
|
27
|
+
const response = await client.speech.generate({ language: 'yo', text: 'text', voice: 'sade' });
|
|
32
28
|
|
|
33
|
-
|
|
29
|
+
const content = await response.blob();
|
|
30
|
+
console.log(content);
|
|
34
31
|
```
|
|
35
32
|
|
|
36
33
|
### Request & Response types
|
|
@@ -41,20 +38,43 @@ This library includes TypeScript definitions for all request params and response
|
|
|
41
38
|
```ts
|
|
42
39
|
import Spitch from 'spitch';
|
|
43
40
|
|
|
44
|
-
const client = new Spitch(
|
|
45
|
-
apiKey: process.env['SPITCH_API_KEY'], // This is the default and can be omitted
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
async function main() {
|
|
49
|
-
const params: Spitch.SpeechTranscibeParams = { language: 'yo' };
|
|
50
|
-
const response: unknown = await client.speech.transcibe(params);
|
|
51
|
-
}
|
|
41
|
+
const client = new Spitch();
|
|
52
42
|
|
|
53
|
-
|
|
43
|
+
const params: Spitch.SpeechGenerateParams = { language: 'yo', text: 'text', voice: 'sade' };
|
|
44
|
+
const response: Response = await client.speech.generate(params);
|
|
54
45
|
```
|
|
55
46
|
|
|
56
47
|
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
|
|
57
48
|
|
|
49
|
+
## File uploads
|
|
50
|
+
|
|
51
|
+
Request parameters that correspond to file uploads can be passed in many different forms:
|
|
52
|
+
|
|
53
|
+
- `File` (or an object with the same structure)
|
|
54
|
+
- a `fetch` `Response` (or an object with the same structure)
|
|
55
|
+
- an `fs.ReadStream`
|
|
56
|
+
- the return value of our `toFile` helper
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import fs from 'fs';
|
|
60
|
+
import Spitch, { toFile } from 'spitch';
|
|
61
|
+
|
|
62
|
+
const client = new Spitch();
|
|
63
|
+
|
|
64
|
+
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
|
|
65
|
+
await client.speech.transcribe({ language: 'yo', content: fs.createReadStream('/path/to/file') });
|
|
66
|
+
|
|
67
|
+
// Or if you have the web `File` API you can pass a `File` instance:
|
|
68
|
+
await client.speech.transcribe({ language: 'yo', content: new File(['my bytes'], 'file') });
|
|
69
|
+
|
|
70
|
+
// You can also pass a `fetch` `Response`:
|
|
71
|
+
await client.speech.transcribe({ language: 'yo', content: await fetch('https://somesite/file') });
|
|
72
|
+
|
|
73
|
+
// Finally, if none of the above are convenient, you can use our `toFile` helper:
|
|
74
|
+
await client.speech.transcribe({ language: 'yo', content: await toFile(Buffer.from('my bytes'), 'file') });
|
|
75
|
+
await client.speech.transcribe({ language: 'yo', content: await toFile(new Uint8Array([0, 1, 2]), 'file') });
|
|
76
|
+
```
|
|
77
|
+
|
|
58
78
|
## Handling errors
|
|
59
79
|
|
|
60
80
|
When the library is unable to connect to the API,
|
|
@@ -63,8 +83,9 @@ a subclass of `APIError` will be thrown:
|
|
|
63
83
|
|
|
64
84
|
<!-- prettier-ignore -->
|
|
65
85
|
```ts
|
|
66
|
-
|
|
67
|
-
|
|
86
|
+
const response = await client.speech
|
|
87
|
+
.generate({ language: 'yo', text: 'text', voice: 'sade' })
|
|
88
|
+
.catch(async (err) => {
|
|
68
89
|
if (err instanceof Spitch.APIError) {
|
|
69
90
|
console.log(err.status); // 400
|
|
70
91
|
console.log(err.name); // BadRequestError
|
|
@@ -73,12 +94,9 @@ async function main() {
|
|
|
73
94
|
throw err;
|
|
74
95
|
}
|
|
75
96
|
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
main();
|
|
79
97
|
```
|
|
80
98
|
|
|
81
|
-
Error codes are as
|
|
99
|
+
Error codes are as follows:
|
|
82
100
|
|
|
83
101
|
| Status Code | Error Type |
|
|
84
102
|
| ----------- | -------------------------- |
|
|
@@ -107,7 +125,7 @@ const client = new Spitch({
|
|
|
107
125
|
});
|
|
108
126
|
|
|
109
127
|
// Or, configure per-request:
|
|
110
|
-
await client.speech.
|
|
128
|
+
await client.speech.generate({ language: 'yo', text: 'text', voice: 'sade' }, {
|
|
111
129
|
maxRetries: 5,
|
|
112
130
|
});
|
|
113
131
|
```
|
|
@@ -124,7 +142,7 @@ const client = new Spitch({
|
|
|
124
142
|
});
|
|
125
143
|
|
|
126
144
|
// Override per-request:
|
|
127
|
-
await client.speech.
|
|
145
|
+
await client.speech.generate({ language: 'yo', text: 'text', voice: 'sade' }, {
|
|
128
146
|
timeout: 5 * 1000,
|
|
129
147
|
});
|
|
130
148
|
```
|
|
@@ -138,22 +156,79 @@ Note that requests which time out will be [retried twice by default](#retries).
|
|
|
138
156
|
### Accessing raw Response data (e.g., headers)
|
|
139
157
|
|
|
140
158
|
The "raw" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.
|
|
159
|
+
This method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.
|
|
141
160
|
|
|
142
161
|
You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.
|
|
162
|
+
Unlike `.asResponse()` this method consumes the body, returning once it is parsed.
|
|
143
163
|
|
|
144
164
|
<!-- prettier-ignore -->
|
|
145
165
|
```ts
|
|
146
166
|
const client = new Spitch();
|
|
147
167
|
|
|
148
|
-
const response = await client.speech.
|
|
168
|
+
const response = await client.speech.generate({ language: 'yo', text: 'text', voice: 'sade' }).asResponse();
|
|
149
169
|
console.log(response.headers.get('X-My-Header'));
|
|
150
170
|
console.log(response.statusText); // access the underlying Response object
|
|
151
171
|
|
|
152
|
-
const { data: response, response: raw } = await client.speech
|
|
172
|
+
const { data: response, response: raw } = await client.speech
|
|
173
|
+
.generate({ language: 'yo', text: 'text', voice: 'sade' })
|
|
174
|
+
.withResponse();
|
|
153
175
|
console.log(raw.headers.get('X-My-Header'));
|
|
154
176
|
console.log(response);
|
|
155
177
|
```
|
|
156
178
|
|
|
179
|
+
### Logging
|
|
180
|
+
|
|
181
|
+
> [!IMPORTANT]
|
|
182
|
+
> All log messages are intended for debugging only. The format and content of log messages
|
|
183
|
+
> may change between releases.
|
|
184
|
+
|
|
185
|
+
#### Log levels
|
|
186
|
+
|
|
187
|
+
The log level can be configured in two ways:
|
|
188
|
+
|
|
189
|
+
1. Via the `SPITCH_LOG` environment variable
|
|
190
|
+
2. Using the `logLevel` client option (overrides the environment variable if set)
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
import Spitch from 'spitch';
|
|
194
|
+
|
|
195
|
+
const client = new Spitch({
|
|
196
|
+
logLevel: 'debug', // Show all log messages
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Available log levels, from most to least verbose:
|
|
201
|
+
|
|
202
|
+
- `'debug'` - Show debug messages, info, warnings, and errors
|
|
203
|
+
- `'info'` - Show info messages, warnings, and errors
|
|
204
|
+
- `'warn'` - Show warnings and errors (default)
|
|
205
|
+
- `'error'` - Show only errors
|
|
206
|
+
- `'off'` - Disable all logging
|
|
207
|
+
|
|
208
|
+
At the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.
|
|
209
|
+
Some authentication-related headers are redacted, but sensitive data in request and response bodies
|
|
210
|
+
may still be visible.
|
|
211
|
+
|
|
212
|
+
#### Custom logger
|
|
213
|
+
|
|
214
|
+
By default, this library logs to `globalThis.console`. You can also provide a custom logger.
|
|
215
|
+
Most logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.
|
|
216
|
+
|
|
217
|
+
When providing a custom logger, the `logLevel` option still controls which messages are emitted, messages
|
|
218
|
+
below the configured level will not be sent to your logger.
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
import Spitch from 'spitch';
|
|
222
|
+
import pino from 'pino';
|
|
223
|
+
|
|
224
|
+
const logger = pino();
|
|
225
|
+
|
|
226
|
+
const client = new Spitch({
|
|
227
|
+
logger: logger.child({ name: 'Spitch' }),
|
|
228
|
+
logLevel: 'debug', // Send all messages to pino, allowing it to filter
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
157
232
|
### Making custom/undocumented requests
|
|
158
233
|
|
|
159
234
|
This library is typed for convenient access to the documented API. If you need to access undocumented
|
|
@@ -178,9 +253,8 @@ parameter. This library doesn't validate at runtime that the request matches the
|
|
|
178
253
|
send will be sent as-is.
|
|
179
254
|
|
|
180
255
|
```ts
|
|
181
|
-
client.
|
|
182
|
-
|
|
183
|
-
bar: 12,
|
|
256
|
+
client.speech.generate({
|
|
257
|
+
// ...
|
|
184
258
|
// @ts-expect-error baz is not yet public
|
|
185
259
|
baz: 'undocumented option',
|
|
186
260
|
});
|
|
@@ -200,87 +274,112 @@ validate or strip extra properties from the response from the API.
|
|
|
200
274
|
|
|
201
275
|
### Customizing the fetch client
|
|
202
276
|
|
|
203
|
-
By default, this library
|
|
277
|
+
By default, this library expects a global `fetch` function is defined.
|
|
204
278
|
|
|
205
|
-
If you
|
|
206
|
-
(for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`),
|
|
207
|
-
add the following import before your first import `from "Spitch"`:
|
|
279
|
+
If you want to use a different `fetch` function, you can either polyfill the global:
|
|
208
280
|
|
|
209
281
|
```ts
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
import Spitch from 'spitch';
|
|
282
|
+
import fetch from 'my-fetch';
|
|
283
|
+
|
|
284
|
+
globalThis.fetch = fetch;
|
|
214
285
|
```
|
|
215
286
|
|
|
216
|
-
|
|
217
|
-
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/spi-tch/spitch-node/tree/main/src/_shims#readme)).
|
|
287
|
+
Or pass it to the client:
|
|
218
288
|
|
|
219
|
-
|
|
289
|
+
```ts
|
|
290
|
+
import Spitch from 'spitch';
|
|
291
|
+
import fetch from 'my-fetch';
|
|
292
|
+
|
|
293
|
+
const client = new Spitch({ fetch });
|
|
294
|
+
```
|
|
220
295
|
|
|
221
|
-
|
|
222
|
-
|
|
296
|
+
### Fetch options
|
|
297
|
+
|
|
298
|
+
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.)
|
|
223
299
|
|
|
224
300
|
```ts
|
|
225
|
-
import { fetch } from 'undici'; // as one example
|
|
226
301
|
import Spitch from 'spitch';
|
|
227
302
|
|
|
228
303
|
const client = new Spitch({
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const response = await fetch(url, init);
|
|
232
|
-
console.log('Got response', response);
|
|
233
|
-
return response;
|
|
304
|
+
fetchOptions: {
|
|
305
|
+
// `RequestInit` options
|
|
234
306
|
},
|
|
235
307
|
});
|
|
236
308
|
```
|
|
237
309
|
|
|
238
|
-
|
|
239
|
-
This is intended for debugging purposes only and may change in the future without notice.
|
|
310
|
+
#### Configuring proxies
|
|
240
311
|
|
|
241
|
-
|
|
312
|
+
To modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy
|
|
313
|
+
options to requests:
|
|
242
314
|
|
|
243
|
-
|
|
315
|
+
<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>
|
|
244
316
|
|
|
245
|
-
|
|
317
|
+
```ts
|
|
318
|
+
import Spitch from 'spitch';
|
|
319
|
+
import * as undici from 'undici';
|
|
320
|
+
|
|
321
|
+
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
|
|
322
|
+
const client = new Spitch({
|
|
323
|
+
fetchOptions: {
|
|
324
|
+
dispatcher: proxyAgent,
|
|
325
|
+
},
|
|
326
|
+
});
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
<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>
|
|
246
330
|
|
|
247
|
-
<!-- prettier-ignore -->
|
|
248
331
|
```ts
|
|
249
|
-
import
|
|
250
|
-
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
332
|
+
import Spitch from 'spitch';
|
|
251
333
|
|
|
252
|
-
// Configure the default for all requests:
|
|
253
334
|
const client = new Spitch({
|
|
254
|
-
|
|
335
|
+
fetchOptions: {
|
|
336
|
+
proxy: 'http://localhost:8888',
|
|
337
|
+
},
|
|
255
338
|
});
|
|
339
|
+
```
|
|
256
340
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
341
|
+
<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>
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
import Spitch from 'npm:spitch';
|
|
345
|
+
|
|
346
|
+
const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
|
|
347
|
+
const client = new Spitch({
|
|
348
|
+
fetchOptions: {
|
|
349
|
+
client: httpClient,
|
|
262
350
|
},
|
|
263
|
-
);
|
|
351
|
+
});
|
|
264
352
|
```
|
|
265
353
|
|
|
354
|
+
## Frequently Asked Questions
|
|
355
|
+
|
|
266
356
|
## Semantic versioning
|
|
267
357
|
|
|
268
358
|
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:
|
|
269
359
|
|
|
270
360
|
1. Changes that only affect static types, without breaking runtime behavior.
|
|
271
|
-
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_
|
|
361
|
+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
|
272
362
|
3. Changes that we do not expect to impact the vast majority of users in practice.
|
|
273
363
|
|
|
274
364
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
275
365
|
|
|
276
|
-
We are keen for your feedback; please open an [issue](https://www.github.com/spi-tch/spitch-
|
|
366
|
+
We are keen for your feedback; please open an [issue](https://www.github.com/spi-tch/spitch-typescript/issues) with questions, bugs, or suggestions.
|
|
277
367
|
|
|
278
368
|
## Requirements
|
|
279
369
|
|
|
280
|
-
TypeScript >= 4.
|
|
370
|
+
TypeScript >= 4.9 is supported.
|
|
281
371
|
|
|
282
372
|
The following runtimes are supported:
|
|
283
373
|
|
|
374
|
+
- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
|
|
375
|
+
- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
|
|
376
|
+
- Deno v1.28.0 or higher.
|
|
377
|
+
- Bun 1.0 or later.
|
|
378
|
+
- Cloudflare Workers.
|
|
379
|
+
- Vercel Edge Runtime.
|
|
380
|
+
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
|
|
381
|
+
- Nitro v2.6 or greater.
|
|
382
|
+
|
|
284
383
|
Note that React Native is not supported at this time.
|
|
285
384
|
|
|
286
385
|
If you are interested in other runtime environments, please open or upvote an issue on GitHub.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-promise.d.mts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
|
package/api-promise.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-promise.d.ts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
|
package/api-promise.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("./internal/tslib.js");
|
|
4
|
+
/** @deprecated Import from ./core/api-promise instead */
|
|
5
|
+
tslib_1.__exportStar(require("./core/api-promise.js"), exports);
|
|
6
|
+
//# sourceMappingURL=api-promise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-promise.js","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,gEAAmC"}
|
package/api-promise.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-promise.mjs","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
|
package/client.d.mts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { RequestInit, RequestInfo } from "./internal/builtin-types.mjs";
|
|
2
|
+
import type { PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from "./internal/types.mjs";
|
|
3
|
+
export type { Logger, LogLevel } from "./internal/utils/log.mjs";
|
|
4
|
+
import * as Opts from "./internal/request-options.mjs";
|
|
5
|
+
import * as Errors from "./core/error.mjs";
|
|
6
|
+
import * as Uploads from "./core/uploads.mjs";
|
|
7
|
+
import * as API from "./resources/index.mjs";
|
|
8
|
+
import { APIPromise } from "./core/api-promise.mjs";
|
|
9
|
+
import { Speech, SpeechGenerateParams, SpeechTranscribeParams, SpeechTranscribeResponse } from "./resources/speech.mjs";
|
|
10
|
+
import { Text, TextToneMarkParams, TextToneMarkResponse, TextTranslateParams, TextTranslateResponse } from "./resources/text.mjs";
|
|
11
|
+
import { type Fetch } from "./internal/builtin-types.mjs";
|
|
12
|
+
import { HeadersLike, NullableHeaders } from "./internal/headers.mjs";
|
|
13
|
+
import { FinalRequestOptions, RequestOptions } from "./internal/request-options.mjs";
|
|
14
|
+
import { type LogLevel, type Logger } from "./internal/utils/log.mjs";
|
|
15
|
+
export interface ClientOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Defaults to process.env['SPITCH_API_KEY'].
|
|
18
|
+
*/
|
|
19
|
+
apiKey?: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
22
|
+
*
|
|
23
|
+
* Defaults to process.env['SPITCH_BASE_URL'].
|
|
24
|
+
*/
|
|
25
|
+
baseURL?: string | null | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
28
|
+
* from the server before timing out a single request.
|
|
29
|
+
*
|
|
30
|
+
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
31
|
+
* much longer than this timeout before the promise succeeds or fails.
|
|
32
|
+
*
|
|
33
|
+
* @unit milliseconds
|
|
34
|
+
*/
|
|
35
|
+
timeout?: number | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Additional `RequestInit` options to be passed to `fetch` calls.
|
|
38
|
+
* Properties will be overridden by per-request `fetchOptions`.
|
|
39
|
+
*/
|
|
40
|
+
fetchOptions?: MergedRequestInit | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Specify a custom `fetch` function implementation.
|
|
43
|
+
*
|
|
44
|
+
* If not provided, we expect that `fetch` is defined globally.
|
|
45
|
+
*/
|
|
46
|
+
fetch?: Fetch | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* The maximum number of times that the client will retry a request in case of a
|
|
49
|
+
* temporary failure, like a network error or a 5XX error from the server.
|
|
50
|
+
*
|
|
51
|
+
* @default 2
|
|
52
|
+
*/
|
|
53
|
+
maxRetries?: number | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Default headers to include with every request to the API.
|
|
56
|
+
*
|
|
57
|
+
* These can be removed in individual requests by explicitly setting the
|
|
58
|
+
* header to `null` in request options.
|
|
59
|
+
*/
|
|
60
|
+
defaultHeaders?: HeadersLike | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Default query parameters to include with every request to the API.
|
|
63
|
+
*
|
|
64
|
+
* These can be removed in individual requests by explicitly setting the
|
|
65
|
+
* param to `undefined` in request options.
|
|
66
|
+
*/
|
|
67
|
+
defaultQuery?: Record<string, string | undefined> | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Set the log level.
|
|
70
|
+
*
|
|
71
|
+
* Defaults to process.env['SPITCH_LOG'] or 'warn' if it isn't set.
|
|
72
|
+
*/
|
|
73
|
+
logLevel?: LogLevel | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Set the logger.
|
|
76
|
+
*
|
|
77
|
+
* Defaults to globalThis.console.
|
|
78
|
+
*/
|
|
79
|
+
logger?: Logger | undefined;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* API Client for interfacing with the Spitch API.
|
|
83
|
+
*/
|
|
84
|
+
export declare class Spitch {
|
|
85
|
+
#private;
|
|
86
|
+
apiKey: string;
|
|
87
|
+
baseURL: string;
|
|
88
|
+
maxRetries: number;
|
|
89
|
+
timeout: number;
|
|
90
|
+
logger: Logger | undefined;
|
|
91
|
+
logLevel: LogLevel | undefined;
|
|
92
|
+
fetchOptions: MergedRequestInit | undefined;
|
|
93
|
+
private fetch;
|
|
94
|
+
protected idempotencyHeader?: string;
|
|
95
|
+
private _options;
|
|
96
|
+
/**
|
|
97
|
+
* API Client for interfacing with the Spitch API.
|
|
98
|
+
*
|
|
99
|
+
* @param {string | undefined} [opts.apiKey=process.env['SPITCH_API_KEY'] ?? undefined]
|
|
100
|
+
* @param {string} [opts.baseURL=process.env['SPITCH_BASE_URL'] ?? https://api.spi-tch.com] - Override the default base URL for the API.
|
|
101
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
102
|
+
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
103
|
+
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
104
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
105
|
+
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
106
|
+
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
107
|
+
*/
|
|
108
|
+
constructor({ baseURL, apiKey, ...opts }?: ClientOptions);
|
|
109
|
+
/**
|
|
110
|
+
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
111
|
+
*/
|
|
112
|
+
withOptions(options: Partial<ClientOptions>): this;
|
|
113
|
+
protected defaultQuery(): Record<string, string | undefined> | undefined;
|
|
114
|
+
protected validateHeaders({ values, nulls }: NullableHeaders): void;
|
|
115
|
+
protected authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined>;
|
|
116
|
+
/**
|
|
117
|
+
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
118
|
+
*/
|
|
119
|
+
protected stringifyQuery(query: Record<string, unknown>): string;
|
|
120
|
+
private getUserAgent;
|
|
121
|
+
protected defaultIdempotencyKey(): string;
|
|
122
|
+
protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError;
|
|
123
|
+
buildURL(path: string, query: Record<string, unknown> | null | undefined, defaultBaseURL?: string | undefined): string;
|
|
124
|
+
/**
|
|
125
|
+
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
126
|
+
*/
|
|
127
|
+
protected prepareOptions(options: FinalRequestOptions): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Used as a callback for mutating the given `RequestInit` object.
|
|
130
|
+
*
|
|
131
|
+
* This is useful for cases where you want to add certain headers based off of
|
|
132
|
+
* the request properties, e.g. `method` or `url`.
|
|
133
|
+
*/
|
|
134
|
+
protected prepareRequest(request: RequestInit, { url, options }: {
|
|
135
|
+
url: string;
|
|
136
|
+
options: FinalRequestOptions;
|
|
137
|
+
}): Promise<void>;
|
|
138
|
+
get<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
139
|
+
post<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
140
|
+
patch<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
141
|
+
put<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
142
|
+
delete<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
143
|
+
private methodRequest;
|
|
144
|
+
request<Rsp>(options: PromiseOrValue<FinalRequestOptions>, remainingRetries?: number | null): APIPromise<Rsp>;
|
|
145
|
+
private makeRequest;
|
|
146
|
+
fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
|
|
147
|
+
private shouldRetry;
|
|
148
|
+
private retryRequest;
|
|
149
|
+
private calculateDefaultRetryTimeoutMillis;
|
|
150
|
+
buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: {
|
|
151
|
+
retryCount?: number;
|
|
152
|
+
}): Promise<{
|
|
153
|
+
req: FinalizedRequestInit;
|
|
154
|
+
url: string;
|
|
155
|
+
timeout: number;
|
|
156
|
+
}>;
|
|
157
|
+
private buildHeaders;
|
|
158
|
+
private buildBody;
|
|
159
|
+
static Spitch: typeof Spitch;
|
|
160
|
+
static DEFAULT_TIMEOUT: number;
|
|
161
|
+
static SpitchError: typeof Errors.SpitchError;
|
|
162
|
+
static APIError: typeof Errors.APIError;
|
|
163
|
+
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
164
|
+
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
165
|
+
static APIUserAbortError: typeof Errors.APIUserAbortError;
|
|
166
|
+
static NotFoundError: typeof Errors.NotFoundError;
|
|
167
|
+
static ConflictError: typeof Errors.ConflictError;
|
|
168
|
+
static RateLimitError: typeof Errors.RateLimitError;
|
|
169
|
+
static BadRequestError: typeof Errors.BadRequestError;
|
|
170
|
+
static AuthenticationError: typeof Errors.AuthenticationError;
|
|
171
|
+
static InternalServerError: typeof Errors.InternalServerError;
|
|
172
|
+
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
173
|
+
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
174
|
+
static toFile: typeof Uploads.toFile;
|
|
175
|
+
speech: API.Speech;
|
|
176
|
+
text: API.Text;
|
|
177
|
+
}
|
|
178
|
+
export declare namespace Spitch {
|
|
179
|
+
export type RequestOptions = Opts.RequestOptions;
|
|
180
|
+
export { Speech as Speech, type SpeechTranscribeResponse as SpeechTranscribeResponse, type SpeechGenerateParams as SpeechGenerateParams, type SpeechTranscribeParams as SpeechTranscribeParams, };
|
|
181
|
+
export { Text as Text, type TextToneMarkResponse as TextToneMarkResponse, type TextTranslateResponse as TextTranslateResponse, type TextToneMarkParams as TextToneMarkParams, type TextTranslateParams as TextTranslateParams, };
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=client.d.mts.map
|
package/client.d.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