@lorikeetai/node-sdk 1.8.1 → 2.0.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 +38 -787
- package/README.md +114 -44
- 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/bin/cli +53 -0
- package/bin/migration-config.json +50 -0
- package/client.d.mts +197 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +197 -0
- package/client.d.ts.map +1 -0
- package/client.js +504 -0
- package/client.js.map +1 -0
- package/client.mjs +500 -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 +7 -131
- package/index.d.mts.map +1 -0
- package/index.d.ts +6 -130
- package/index.d.ts.map +1 -1
- package/index.js +14 -142
- package/index.js.map +1 -1
- package/index.mjs +6 -114
- 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/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 +92 -0
- package/internal/to-file.js.map +1 -0
- package/internal/to-file.mjs +89 -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 +86 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +80 -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/lib/generate-signature.d.mts +7 -0
- package/lib/generate-signature.d.mts.map +1 -0
- package/lib/generate-signature.d.ts +1 -1
- package/lib/generate-signature.d.ts.map +1 -1
- package/lib/generate-signature.js +3 -3
- package/lib/generate-signature.js.map +1 -1
- package/lib/generate-signature.mjs +1 -1
- package/lib/generate-signature.mjs.map +1 -1
- package/lib/poll-until.d.mts +20 -0
- package/lib/poll-until.d.mts.map +1 -0
- package/lib/poll-until.d.ts.map +1 -1
- package/lib/promise.d.mts +55 -0
- package/lib/promise.d.mts.map +1 -0
- package/package.json +125 -74
- 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/api-keys.d.mts +130 -0
- package/resources/api-keys.d.mts.map +1 -0
- package/resources/api-keys.d.ts +7 -6
- package/resources/api-keys.d.ts.map +1 -1
- package/resources/api-keys.js +6 -4
- package/resources/api-keys.js.map +1 -1
- package/resources/api-keys.mjs +6 -4
- package/resources/api-keys.mjs.map +1 -1
- package/resources/conversation/chat.d.mts +312 -0
- package/resources/conversation/chat.d.mts.map +1 -0
- package/resources/conversation/chat.d.ts +45 -77
- package/resources/conversation/chat.d.ts.map +1 -1
- package/resources/conversation/chat.js +14 -48
- package/resources/conversation/chat.js.map +1 -1
- package/resources/conversation/chat.mjs +14 -48
- package/resources/conversation/chat.mjs.map +1 -1
- package/resources/conversation/conversation.d.mts +77 -0
- package/resources/conversation/conversation.d.mts.map +1 -0
- package/resources/conversation/conversation.d.ts +1 -1
- package/resources/conversation/conversation.d.ts.map +1 -1
- package/resources/conversation/conversation.js +5 -27
- package/resources/conversation/conversation.js.map +1 -1
- package/resources/conversation/conversation.mjs +1 -1
- package/resources/conversation/email.d.mts +257 -0
- package/resources/conversation/email.d.mts.map +1 -0
- package/resources/conversation/email.d.ts +10 -8
- package/resources/conversation/email.d.ts.map +1 -1
- package/resources/conversation/email.js +6 -6
- package/resources/conversation/email.js.map +1 -1
- package/resources/conversation/email.mjs +6 -6
- package/resources/conversation/email.mjs.map +1 -1
- package/resources/conversation/index.d.mts +5 -0
- package/resources/conversation/index.d.mts.map +1 -0
- package/resources/conversation/index.d.ts +1 -1
- package/resources/conversation/index.d.ts.map +1 -1
- package/resources/conversation/index.js.map +1 -1
- package/resources/conversation/index.mjs.map +1 -1
- package/resources/conversation/voice.d.mts +45 -0
- package/resources/conversation/voice.d.mts.map +1 -0
- package/resources/conversation/voice.d.ts +4 -3
- package/resources/conversation/voice.d.ts.map +1 -1
- package/resources/conversation/voice.js +3 -2
- package/resources/conversation/voice.js.map +1 -1
- package/resources/conversation/voice.mjs +3 -2
- package/resources/conversation/voice.mjs.map +1 -1
- package/resources/conversation.d.mts +2 -0
- package/resources/conversation.d.mts.map +1 -0
- package/resources/conversation.d.ts.map +1 -1
- package/resources/conversation.js +2 -15
- package/resources/conversation.js.map +1 -1
- package/resources/customer/customer.d.mts +333 -0
- package/resources/customer/customer.d.mts.map +1 -0
- package/resources/customer/customer.d.ts +7 -7
- package/resources/customer/customer.d.ts.map +1 -1
- package/resources/customer/customer.js +12 -31
- package/resources/customer/customer.js.map +1 -1
- package/resources/customer/customer.mjs +9 -6
- package/resources/customer/customer.mjs.map +1 -1
- package/resources/customer/index.d.mts +4 -0
- package/resources/customer/index.d.mts.map +1 -0
- package/resources/customer/index.d.ts.map +1 -1
- package/resources/customer/profile.d.mts +30 -0
- package/resources/customer/profile.d.mts.map +1 -0
- package/resources/customer/profile.d.ts +4 -3
- package/resources/customer/profile.d.ts.map +1 -1
- package/resources/customer/profile.js +3 -2
- package/resources/customer/profile.js.map +1 -1
- package/resources/customer/profile.mjs +3 -2
- package/resources/customer/profile.mjs.map +1 -1
- package/resources/customer/remote.d.mts +164 -0
- package/resources/customer/remote.d.mts.map +1 -0
- package/resources/customer/remote.d.ts +5 -4
- package/resources/customer/remote.d.ts.map +1 -1
- package/resources/customer/remote.js +6 -5
- package/resources/customer/remote.js.map +1 -1
- package/resources/customer/remote.mjs +6 -5
- package/resources/customer/remote.mjs.map +1 -1
- package/resources/customer.d.mts +2 -0
- package/resources/customer.d.mts.map +1 -0
- package/resources/customer.d.ts.map +1 -1
- package/resources/customer.js +2 -15
- package/resources/customer.js.map +1 -1
- package/resources/index.d.mts +5 -0
- package/resources/index.d.mts.map +1 -0
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/ingest.d.mts +27 -0
- package/resources/ingest.d.mts.map +1 -0
- package/resources/ingest.d.ts +12 -6
- package/resources/ingest.d.ts.map +1 -1
- package/resources/ingest.js +11 -8
- package/resources/ingest.js.map +1 -1
- package/resources/ingest.mjs +11 -8
- package/resources/ingest.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 +835 -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 +6 -275
- 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/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 +156 -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 +127 -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/lib/generate-signature.ts +2 -2
- package/src/resource.ts +2 -11
- package/src/resources/api-keys.ts +12 -9
- package/src/resources/conversation/chat.ts +60 -95
- package/src/resources/conversation/conversation.ts +1 -1
- package/src/resources/conversation/email.ts +13 -12
- package/src/resources/conversation/index.ts +5 -0
- package/src/resources/conversation/voice.ts +6 -4
- package/src/resources/customer/customer.ts +12 -16
- package/src/resources/customer/profile.ts +6 -8
- package/src/resources/customer/remote.ts +10 -8
- package/src/resources/index.ts +1 -1
- package/src/resources/ingest.ts +23 -17
- package/src/tsconfig.json +2 -2
- package/src/uploads.ts +2 -256
- 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 -167
- package/uploads.js.map +1 -1
- package/uploads.mjs +1 -156
- 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 -13
- 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 -88
- 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 -77
- 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 -253
- 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/internal/qs/formats.d.ts +0 -6
- package/internal/qs/formats.d.ts.map +0 -1
- package/internal/qs/formats.js +0 -11
- package/internal/qs/formats.js.map +0 -1
- package/internal/qs/formats.mjs +0 -8
- package/internal/qs/formats.mjs.map +0 -1
- package/internal/qs/index.d.ts +0 -10
- package/internal/qs/index.d.ts.map +0 -1
- package/internal/qs/index.js +0 -14
- package/internal/qs/index.js.map +0 -1
- package/internal/qs/index.mjs +0 -10
- package/internal/qs/index.mjs.map +0 -1
- package/internal/qs/stringify.d.ts +0 -3
- package/internal/qs/stringify.d.ts.map +0 -1
- package/internal/qs/stringify.js +0 -279
- package/internal/qs/stringify.js.map +0 -1
- package/internal/qs/stringify.mjs +0 -276
- package/internal/qs/stringify.mjs.map +0 -1
- package/internal/qs/types.d.ts +0 -57
- package/internal/qs/types.d.ts.map +0 -1
- package/internal/qs/types.js +0 -3
- package/internal/qs/types.js.map +0 -1
- package/internal/qs/types.mjs +0 -2
- package/internal/qs/types.mjs.map +0 -1
- package/internal/qs/utils.d.ts +0 -14
- package/internal/qs/utils.d.ts.map +0 -1
- package/internal/qs/utils.js +0 -229
- package/internal/qs/utils.js.map +0 -1
- package/internal/qs/utils.mjs +0 -217
- package/internal/qs/utils.mjs.map +0 -1
- package/resources/ticket.d.ts +0 -14
- package/resources/ticket.d.ts.map +0 -1
- package/resources/ticket.js +0 -16
- package/resources/ticket.js.map +0 -1
- package/resources/ticket.mjs +0 -12
- package/resources/ticket.mjs.map +0 -1
- package/shims/node.d.ts +0 -26
- package/shims/node.d.ts.map +0 -1
- package/shims/node.js +0 -6
- package/shims/node.js.map +0 -1
- package/shims/node.mjs +0 -4
- 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 -6
- package/shims/web.js.map +0 -1
- package/shims/web.mjs +0 -4
- 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/internal/qs/LICENSE.md +0 -13
- package/src/internal/qs/README.md +0 -3
- package/src/internal/qs/formats.ts +0 -9
- package/src/internal/qs/index.ts +0 -13
- package/src/internal/qs/stringify.ts +0 -388
- package/src/internal/qs/types.ts +0 -71
- package/src/internal/qs/utils.ts +0 -265
- package/src/resources/ticket.ts +0 -30
- package/src/shims/node.ts +0 -50
- package/src/shims/web.ts +0 -50
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from '../../resource';
|
|
4
|
-
import * as Core from '../../core';
|
|
5
|
-
import { pollUntil } from "../../lib/poll-until";
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
6
4
|
import * as ConversationAPI from './conversation';
|
|
5
|
+
import { APIPromise } from '../../core/api-promise';
|
|
6
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
7
|
+
import { pollUntil } from '../../lib/poll-until';
|
|
7
8
|
|
|
8
9
|
export class Email extends APIResource {
|
|
9
10
|
/**
|
|
@@ -22,7 +23,7 @@ export class Email extends APIResource {
|
|
|
22
23
|
* });
|
|
23
24
|
* ```
|
|
24
25
|
*/
|
|
25
|
-
generate(body: EmailGenerateParams, options?:
|
|
26
|
+
generate(body: EmailGenerateParams, options?: RequestOptions): APIPromise<EmailGenerateResponse> {
|
|
26
27
|
return this._client.post('/v1/conversation/email/message', { body, ...options });
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -34,7 +35,7 @@ export class Email extends APIResource {
|
|
|
34
35
|
* });
|
|
35
36
|
* ```
|
|
36
37
|
*/
|
|
37
|
-
get(query: EmailGetParams, options?:
|
|
38
|
+
get(query: EmailGetParams, options?: RequestOptions): APIPromise<EmailGetResponse> {
|
|
38
39
|
return this._client.get('/v1/conversation/email/message', { query, ...options });
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -47,23 +48,23 @@ export class Email extends APIResource {
|
|
|
47
48
|
* });
|
|
48
49
|
* ```
|
|
49
50
|
*/
|
|
50
|
-
start(body: EmailStartParams, options?:
|
|
51
|
+
start(body: EmailStartParams, options?: RequestOptions): APIPromise<EmailStartResponse> {
|
|
51
52
|
return this._client.post('/v1/conversation/email/create', { body, ...options });
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
|
-
*
|
|
56
|
+
* Poll until the conversation has a bot response ready.
|
|
56
57
|
*
|
|
57
|
-
*
|
|
58
|
+
* Stops when `latestMessageType` is `BOT_RESPONSE` or `PENDING_RESPONSE`,
|
|
59
|
+
* or when `status` is `Escalated` or `Error`.
|
|
58
60
|
*/
|
|
59
|
-
poll(query: EmailGetParams, options?:
|
|
61
|
+
poll(query: EmailGetParams, options?: RequestOptions): APIPromise<EmailGetResponse> {
|
|
60
62
|
return pollUntil<EmailGetResponse>(
|
|
61
|
-
() => this._client.get('/v1/conversation/
|
|
63
|
+
() => this._client.get('/v1/conversation/email/message', { query, ...options }),
|
|
62
64
|
{
|
|
63
65
|
timeout: options?.timeout || 180_000,
|
|
64
66
|
interval: 2_000,
|
|
65
67
|
condition: (conversation) => {
|
|
66
|
-
// Don't poll if the conversation is escalated or in error
|
|
67
68
|
if (conversation.status === 'Escalated' || conversation.status === 'Error') {
|
|
68
69
|
return true;
|
|
69
70
|
}
|
|
@@ -78,7 +79,7 @@ export class Email extends APIResource {
|
|
|
78
79
|
return false;
|
|
79
80
|
},
|
|
80
81
|
},
|
|
81
|
-
) as
|
|
82
|
+
) as APIPromise<EmailGetResponse>;
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
|
|
@@ -8,6 +8,11 @@ export {
|
|
|
8
8
|
type ChatGenerateParams,
|
|
9
9
|
type ChatGetParams,
|
|
10
10
|
type ChatStartParams,
|
|
11
|
+
type ChatStreamParams,
|
|
12
|
+
type ChatStreamEvent,
|
|
13
|
+
type ChatStreamNewMessageEvent,
|
|
14
|
+
type ChatStreamMessageChunkEvent,
|
|
15
|
+
type ChatStreamMessageCompleteEvent,
|
|
11
16
|
} from './chat';
|
|
12
17
|
export { Conversation, type AttachmentDto, type TicketEvent, type TicketMessageDto } from './conversation';
|
|
13
18
|
export {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from '../../resource';
|
|
4
|
-
import
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import { APIPromise } from '../../core/api-promise';
|
|
5
|
+
import { buildHeaders } from '../../internal/headers';
|
|
6
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
5
7
|
|
|
6
8
|
export class Voice extends APIResource {
|
|
7
9
|
/**
|
|
@@ -12,11 +14,11 @@ export class Voice extends APIResource {
|
|
|
12
14
|
* });
|
|
13
15
|
* ```
|
|
14
16
|
*/
|
|
15
|
-
outbound(body: VoiceOutboundParams, options?:
|
|
17
|
+
outbound(body: VoiceOutboundParams, options?: RequestOptions): APIPromise<void> {
|
|
16
18
|
return this._client.post('/v1/conversation/voice/outbound', {
|
|
17
19
|
body,
|
|
18
20
|
...options,
|
|
19
|
-
headers: { Accept: '*/*',
|
|
21
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from '../../resource';
|
|
4
|
-
import { isRequestOptions } from '../../core';
|
|
5
|
-
import * as Core from '../../core';
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
6
4
|
import * as ProfileAPI from './profile';
|
|
7
5
|
import { Profile, ProfileSyncParams, ProfileSyncResponse } from './profile';
|
|
8
6
|
import * as RemoteAPI from './remote';
|
|
9
7
|
import { Remote, RemoteGetResponse, RemoteUpdateParams, RemoteUpdateResponse } from './remote';
|
|
8
|
+
import { APIPromise } from '../../core/api-promise';
|
|
9
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
10
|
+
import { path } from '../../internal/utils/path';
|
|
10
11
|
|
|
11
12
|
export class Customer extends APIResource {
|
|
12
13
|
remote: RemoteAPI.Remote = new RemoteAPI.Remote(this._client);
|
|
@@ -18,7 +19,7 @@ export class Customer extends APIResource {
|
|
|
18
19
|
* const customer = await client.customer.create();
|
|
19
20
|
* ```
|
|
20
21
|
*/
|
|
21
|
-
create(body: CustomerCreateParams, options?:
|
|
22
|
+
create(body: CustomerCreateParams, options?: RequestOptions): APIPromise<CustomerCreateResponse> {
|
|
22
23
|
return this._client.post('/v1/customer', { body, ...options });
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -33,9 +34,9 @@ export class Customer extends APIResource {
|
|
|
33
34
|
update(
|
|
34
35
|
id: string,
|
|
35
36
|
body: CustomerUpdateParams,
|
|
36
|
-
options?:
|
|
37
|
-
):
|
|
38
|
-
return this._client.put(`/v1/customer/${id}`, { body, ...options });
|
|
37
|
+
options?: RequestOptions,
|
|
38
|
+
): APIPromise<CustomerUpdateResponse> {
|
|
39
|
+
return this._client.put(path`/v1/customer/${id}`, { body, ...options });
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/**
|
|
@@ -44,15 +45,10 @@ export class Customer extends APIResource {
|
|
|
44
45
|
* const customer = await client.customer.get();
|
|
45
46
|
* ```
|
|
46
47
|
*/
|
|
47
|
-
get(query?: CustomerGetParams, options?: Core.RequestOptions): Core.APIPromise<CustomerGetResponse>;
|
|
48
|
-
get(options?: Core.RequestOptions): Core.APIPromise<CustomerGetResponse>;
|
|
49
48
|
get(
|
|
50
|
-
query: CustomerGetParams |
|
|
51
|
-
options?:
|
|
52
|
-
):
|
|
53
|
-
if (isRequestOptions(query)) {
|
|
54
|
-
return this.get({}, query);
|
|
55
|
-
}
|
|
49
|
+
query: CustomerGetParams | null | undefined = {},
|
|
50
|
+
options?: RequestOptions,
|
|
51
|
+
): APIPromise<CustomerGetResponse> {
|
|
56
52
|
return this._client.get('/v1/customer', { query, ...options });
|
|
57
53
|
}
|
|
58
54
|
|
|
@@ -62,7 +58,7 @@ export class Customer extends APIResource {
|
|
|
62
58
|
* const response = await client.customer.token();
|
|
63
59
|
* ```
|
|
64
60
|
*/
|
|
65
|
-
token(body: CustomerTokenParams, options?:
|
|
61
|
+
token(body: CustomerTokenParams, options?: RequestOptions): APIPromise<string> {
|
|
66
62
|
return this._client.post('/v1/customer/token', { body, ...options });
|
|
67
63
|
}
|
|
68
64
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from '../../resource';
|
|
4
|
-
import
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import { APIPromise } from '../../core/api-promise';
|
|
5
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
6
|
+
import { path } from '../../internal/utils/path';
|
|
5
7
|
|
|
6
8
|
export class Profile extends APIResource {
|
|
7
9
|
/**
|
|
@@ -13,12 +15,8 @@ export class Profile extends APIResource {
|
|
|
13
15
|
* );
|
|
14
16
|
* ```
|
|
15
17
|
*/
|
|
16
|
-
sync(
|
|
17
|
-
id
|
|
18
|
-
body: ProfileSyncParams,
|
|
19
|
-
options?: Core.RequestOptions,
|
|
20
|
-
): Core.APIPromise<ProfileSyncResponse> {
|
|
21
|
-
return this._client.put(`/v1/customer/profile/${id}`, { body, ...options });
|
|
18
|
+
sync(id: string, body: ProfileSyncParams, options?: RequestOptions): APIPromise<ProfileSyncResponse> {
|
|
19
|
+
return this._client.put(path`/v1/customer/profile/${id}`, { body, ...options });
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
22
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from '../../resource';
|
|
4
|
-
import
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import { APIPromise } from '../../core/api-promise';
|
|
5
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
6
|
+
import { path } from '../../internal/utils/path';
|
|
5
7
|
|
|
6
8
|
export class Remote extends APIResource {
|
|
7
9
|
/**
|
|
@@ -13,11 +15,11 @@ export class Remote extends APIResource {
|
|
|
13
15
|
* ```
|
|
14
16
|
*/
|
|
15
17
|
update(
|
|
16
|
-
|
|
18
|
+
remoteID: string,
|
|
17
19
|
body: RemoteUpdateParams,
|
|
18
|
-
options?:
|
|
19
|
-
):
|
|
20
|
-
return this._client.patch(`/v1/customer/remote/${
|
|
20
|
+
options?: RequestOptions,
|
|
21
|
+
): APIPromise<RemoteUpdateResponse> {
|
|
22
|
+
return this._client.patch(path`/v1/customer/remote/${remoteID}`, { body, ...options });
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/**
|
|
@@ -26,8 +28,8 @@ export class Remote extends APIResource {
|
|
|
26
28
|
* const remote = await client.customer.remote.get('remoteId');
|
|
27
29
|
* ```
|
|
28
30
|
*/
|
|
29
|
-
get(
|
|
30
|
-
return this._client.get(`/v1/customer/remote/${
|
|
31
|
+
get(remoteID: string, options?: RequestOptions): APIPromise<RemoteGetResponse> {
|
|
32
|
+
return this._client.get(path`/v1/customer/remote/${remoteID}`, options);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
package/src/resources/index.ts
CHANGED
package/src/resources/ingest.ts
CHANGED
|
@@ -1,38 +1,44 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from '../resource';
|
|
4
|
-
import
|
|
3
|
+
import { APIResource } from '../core/resource';
|
|
4
|
+
import { APIPromise } from '../core/api-promise';
|
|
5
|
+
import { buildHeaders } from '../internal/headers';
|
|
6
|
+
import { RequestOptions } from '../internal/request-options';
|
|
7
|
+
import { path } from '../internal/utils/path';
|
|
5
8
|
|
|
6
9
|
export class Ingest extends APIResource {
|
|
7
|
-
submit(
|
|
8
|
-
toolId
|
|
9
|
-
ticketId
|
|
10
|
-
inputHash: string,
|
|
11
|
-
workflowId: string,
|
|
12
|
-
options?: Core.RequestOptions,
|
|
13
|
-
): Core.APIPromise<void> {
|
|
14
|
-
return this._client.post(`/ingest/${toolId}/${ticketId}/${inputHash}/${workflowId}`, {
|
|
10
|
+
submit(workflowID: string, params: IngestSubmitParams, options?: RequestOptions): APIPromise<void> {
|
|
11
|
+
const { toolId, ticketId, inputHash } = params;
|
|
12
|
+
return this._client.post(path`/ingest/${toolId}/${ticketId}/${inputHash}/${workflowID}`, {
|
|
15
13
|
...options,
|
|
16
|
-
headers: { Accept: '*/*',
|
|
14
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
17
15
|
});
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
test(
|
|
21
|
-
return this._client.post(`/ingest/test/${
|
|
18
|
+
test(toolID: string, body: IngestTestParams, options?: RequestOptions): APIPromise<void> {
|
|
19
|
+
return this._client.post(path`/ingest/test/${toolID}`, {
|
|
22
20
|
body,
|
|
23
21
|
...options,
|
|
24
|
-
headers: { Accept: '*/*',
|
|
22
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
25
23
|
});
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
validate(options?:
|
|
26
|
+
validate(options?: RequestOptions): APIPromise<void> {
|
|
29
27
|
return this._client.post('/ingest/validate', {
|
|
30
28
|
...options,
|
|
31
|
-
headers: { Accept: '*/*',
|
|
29
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
32
30
|
});
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
|
|
34
|
+
export interface IngestSubmitParams {
|
|
35
|
+
toolId: string;
|
|
36
|
+
|
|
37
|
+
ticketId: string;
|
|
38
|
+
|
|
39
|
+
inputHash: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
36
42
|
export interface IngestTestParams {
|
|
37
43
|
/**
|
|
38
44
|
* The input data to simulate a test response for.
|
|
@@ -46,5 +52,5 @@ export interface IngestTestParams {
|
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
export declare namespace Ingest {
|
|
49
|
-
export { type IngestTestParams as IngestTestParams };
|
|
55
|
+
export { type IngestSubmitParams as IngestSubmitParams, type IngestTestParams as IngestTestParams };
|
|
50
56
|
}
|
package/src/tsconfig.json
CHANGED
package/src/uploads.ts
CHANGED
|
@@ -1,256 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
FormData,
|
|
4
|
-
File,
|
|
5
|
-
type Blob,
|
|
6
|
-
type FilePropertyBag,
|
|
7
|
-
getMultipartRequestOptions,
|
|
8
|
-
type FsReadStream,
|
|
9
|
-
isFsReadStream,
|
|
10
|
-
} from './_shims/index';
|
|
11
|
-
import { MultipartBody } from './_shims/MultipartBody';
|
|
12
|
-
export { fileFromPath } from './_shims/index';
|
|
13
|
-
|
|
14
|
-
type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView;
|
|
15
|
-
export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | Uint8Array | DataView;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Typically, this is a native "File" class.
|
|
19
|
-
*
|
|
20
|
-
* We provide the {@link toFile} utility to convert a variety of objects
|
|
21
|
-
* into the File class.
|
|
22
|
-
*
|
|
23
|
-
* For convenience, you can also pass a fetch Response, or in Node,
|
|
24
|
-
* the result of fs.createReadStream().
|
|
25
|
-
*/
|
|
26
|
-
export type Uploadable = FileLike | ResponseLike | FsReadStream;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Intended to match web.Blob, node.Blob, node-fetch.Blob, etc.
|
|
30
|
-
*/
|
|
31
|
-
export interface BlobLike {
|
|
32
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
|
|
33
|
-
readonly size: number;
|
|
34
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
|
|
35
|
-
readonly type: string;
|
|
36
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
|
|
37
|
-
text(): Promise<string>;
|
|
38
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
|
|
39
|
-
slice(start?: number, end?: number): BlobLike;
|
|
40
|
-
// unfortunately @types/node-fetch@^2.6.4 doesn't type the arrayBuffer method
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Intended to match web.File, node.File, node-fetch.File, etc.
|
|
45
|
-
*/
|
|
46
|
-
export interface FileLike extends BlobLike {
|
|
47
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
|
|
48
|
-
readonly lastModified: number;
|
|
49
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
|
|
50
|
-
readonly name: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Intended to match web.Response, node.Response, node-fetch.Response, etc.
|
|
55
|
-
*/
|
|
56
|
-
export interface ResponseLike {
|
|
57
|
-
url: string;
|
|
58
|
-
blob(): Promise<BlobLike>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const isResponseLike = (value: any): value is ResponseLike =>
|
|
62
|
-
value != null &&
|
|
63
|
-
typeof value === 'object' &&
|
|
64
|
-
typeof value.url === 'string' &&
|
|
65
|
-
typeof value.blob === 'function';
|
|
66
|
-
|
|
67
|
-
export const isFileLike = (value: any): value is FileLike =>
|
|
68
|
-
value != null &&
|
|
69
|
-
typeof value === 'object' &&
|
|
70
|
-
typeof value.name === 'string' &&
|
|
71
|
-
typeof value.lastModified === 'number' &&
|
|
72
|
-
isBlobLike(value);
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check
|
|
76
|
-
* adds the arrayBuffer() method type because it is available and used at runtime
|
|
77
|
-
*/
|
|
78
|
-
export const isBlobLike = (value: any): value is BlobLike & { arrayBuffer(): Promise<ArrayBuffer> } =>
|
|
79
|
-
value != null &&
|
|
80
|
-
typeof value === 'object' &&
|
|
81
|
-
typeof value.size === 'number' &&
|
|
82
|
-
typeof value.type === 'string' &&
|
|
83
|
-
typeof value.text === 'function' &&
|
|
84
|
-
typeof value.slice === 'function' &&
|
|
85
|
-
typeof value.arrayBuffer === 'function';
|
|
86
|
-
|
|
87
|
-
export const isUploadable = (value: any): value is Uploadable => {
|
|
88
|
-
return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export type ToFileInput = Uploadable | Exclude<BlobLikePart, string> | AsyncIterable<BlobLikePart>;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
|
|
95
|
-
* @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
|
|
96
|
-
* @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
|
|
97
|
-
* @param {Object=} options additional properties
|
|
98
|
-
* @param {string=} options.type the MIME type of the content
|
|
99
|
-
* @param {number=} options.lastModified the last modified timestamp
|
|
100
|
-
* @returns a {@link File} with the given properties
|
|
101
|
-
*/
|
|
102
|
-
export async function toFile(
|
|
103
|
-
value: ToFileInput | PromiseLike<ToFileInput>,
|
|
104
|
-
name?: string | null | undefined,
|
|
105
|
-
options?: FilePropertyBag | undefined,
|
|
106
|
-
): Promise<FileLike> {
|
|
107
|
-
// If it's a promise, resolve it.
|
|
108
|
-
value = await value;
|
|
109
|
-
|
|
110
|
-
// If we've been given a `File` we don't need to do anything
|
|
111
|
-
if (isFileLike(value)) {
|
|
112
|
-
return value;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (isResponseLike(value)) {
|
|
116
|
-
const blob = await value.blob();
|
|
117
|
-
name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file';
|
|
118
|
-
|
|
119
|
-
// we need to convert the `Blob` into an array buffer because the `Blob` class
|
|
120
|
-
// that `node-fetch` defines is incompatible with the web standard which results
|
|
121
|
-
// in `new File` interpreting it as a string instead of binary data.
|
|
122
|
-
const data = isBlobLike(blob) ? [(await blob.arrayBuffer()) as any] : [blob];
|
|
123
|
-
|
|
124
|
-
return new File(data, name, options);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const bits = await getBytes(value);
|
|
128
|
-
|
|
129
|
-
name ||= getName(value) ?? 'unknown_file';
|
|
130
|
-
|
|
131
|
-
if (!options?.type) {
|
|
132
|
-
const type = (bits[0] as any)?.type;
|
|
133
|
-
if (typeof type === 'string') {
|
|
134
|
-
options = { ...options, type };
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return new File(bits, name, options);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async function getBytes(value: ToFileInput): Promise<Array<BlobPart>> {
|
|
142
|
-
let parts: Array<BlobPart> = [];
|
|
143
|
-
if (
|
|
144
|
-
typeof value === 'string' ||
|
|
145
|
-
ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
|
|
146
|
-
value instanceof ArrayBuffer
|
|
147
|
-
) {
|
|
148
|
-
parts.push(value);
|
|
149
|
-
} else if (isBlobLike(value)) {
|
|
150
|
-
parts.push(await value.arrayBuffer());
|
|
151
|
-
} else if (
|
|
152
|
-
isAsyncIterableIterator(value) // includes Readable, ReadableStream, etc.
|
|
153
|
-
) {
|
|
154
|
-
for await (const chunk of value) {
|
|
155
|
-
parts.push(chunk as BlobPart); // TODO, consider validating?
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
throw new Error(
|
|
159
|
-
`Unexpected data type: ${typeof value}; constructor: ${
|
|
160
|
-
value?.constructor?.name
|
|
161
|
-
}; props: ${propsForError(value)}`,
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return parts;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function propsForError(value: any): string {
|
|
169
|
-
const props = Object.getOwnPropertyNames(value);
|
|
170
|
-
return `[${props.map((p) => `"${p}"`).join(', ')}]`;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function getName(value: any): string | undefined {
|
|
174
|
-
return (
|
|
175
|
-
getStringFromMaybeBuffer(value.name) ||
|
|
176
|
-
getStringFromMaybeBuffer(value.filename) ||
|
|
177
|
-
// For fs.ReadStream
|
|
178
|
-
getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop()
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const getStringFromMaybeBuffer = (x: string | Buffer | unknown): string | undefined => {
|
|
183
|
-
if (typeof x === 'string') return x;
|
|
184
|
-
if (typeof Buffer !== 'undefined' && x instanceof Buffer) return String(x);
|
|
185
|
-
return undefined;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const isAsyncIterableIterator = (value: any): value is AsyncIterableIterator<unknown> =>
|
|
189
|
-
value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function';
|
|
190
|
-
|
|
191
|
-
export const isMultipartBody = (body: any): body is MultipartBody =>
|
|
192
|
-
body && typeof body === 'object' && body.body && body[Symbol.toStringTag] === 'MultipartBody';
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
|
|
196
|
-
* Otherwise returns the request as is.
|
|
197
|
-
*/
|
|
198
|
-
export const maybeMultipartFormRequestOptions = async <T = Record<string, unknown>>(
|
|
199
|
-
opts: RequestOptions<T>,
|
|
200
|
-
): Promise<RequestOptions<T | MultipartBody>> => {
|
|
201
|
-
if (!hasUploadableValue(opts.body)) return opts;
|
|
202
|
-
|
|
203
|
-
const form = await createForm(opts.body);
|
|
204
|
-
return getMultipartRequestOptions(form, opts);
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
export const multipartFormRequestOptions = async <T = Record<string, unknown>>(
|
|
208
|
-
opts: RequestOptions<T>,
|
|
209
|
-
): Promise<RequestOptions<T | MultipartBody>> => {
|
|
210
|
-
const form = await createForm(opts.body);
|
|
211
|
-
return getMultipartRequestOptions(form, opts);
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export const createForm = async <T = Record<string, unknown>>(body: T | undefined): Promise<FormData> => {
|
|
215
|
-
const form = new FormData();
|
|
216
|
-
await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
|
|
217
|
-
return form;
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const hasUploadableValue = (value: unknown): boolean => {
|
|
221
|
-
if (isUploadable(value)) return true;
|
|
222
|
-
if (Array.isArray(value)) return value.some(hasUploadableValue);
|
|
223
|
-
if (value && typeof value === 'object') {
|
|
224
|
-
for (const k in value) {
|
|
225
|
-
if (hasUploadableValue((value as any)[k])) return true;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return false;
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
const addFormValue = async (form: FormData, key: string, value: unknown): Promise<void> => {
|
|
232
|
-
if (value === undefined) return;
|
|
233
|
-
if (value == null) {
|
|
234
|
-
throw new TypeError(
|
|
235
|
-
`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`,
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// TODO: make nested formats configurable
|
|
240
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
241
|
-
form.append(key, String(value));
|
|
242
|
-
} else if (isUploadable(value)) {
|
|
243
|
-
const file = await toFile(value);
|
|
244
|
-
form.append(key, file as File);
|
|
245
|
-
} else if (Array.isArray(value)) {
|
|
246
|
-
await Promise.all(value.map((entry) => addFormValue(form, key + '[]', entry)));
|
|
247
|
-
} else if (typeof value === 'object') {
|
|
248
|
-
await Promise.all(
|
|
249
|
-
Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)),
|
|
250
|
-
);
|
|
251
|
-
} else {
|
|
252
|
-
throw new TypeError(
|
|
253
|
-
`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`,
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
};
|
|
1
|
+
/** @deprecated Import from ./core/uploads instead */
|
|
2
|
+
export * from './core/uploads';
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '1.
|
|
1
|
+
export const VERSION = '0.1.0'; // x-release-please-version
|
package/uploads.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploads.d.mts","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":""}
|