@lorikeetai/node-sdk 1.8.1 → 2.1.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 +43 -782
- 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 +123 -73
- package/resource.d.mts +2 -0
- package/resource.d.mts.map +1 -0
- package/resource.d.ts +1 -5
- package/resource.d.ts.map +1 -1
- package/resource.js +3 -8
- package/resource.js.map +1 -1
- package/resource.mjs +1 -6
- package/resource.mjs.map +1 -1
- package/resources/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
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { type Lorikeet } from '../client';
|
|
4
|
+
|
|
5
|
+
import { type PromiseOrValue } from '../internal/types';
|
|
6
|
+
import { APIResponseProps, defaultParseResponse } from '../internal/parse';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A subclass of `Promise` providing additional helper methods
|
|
10
|
+
* for interacting with the SDK.
|
|
11
|
+
*/
|
|
12
|
+
export class APIPromise<T> extends Promise<T> {
|
|
13
|
+
private parsedPromise: Promise<T> | undefined;
|
|
14
|
+
#client: Lorikeet;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
client: Lorikeet,
|
|
18
|
+
private responsePromise: Promise<APIResponseProps>,
|
|
19
|
+
private parseResponse: (
|
|
20
|
+
client: Lorikeet,
|
|
21
|
+
props: APIResponseProps,
|
|
22
|
+
) => PromiseOrValue<T> = defaultParseResponse,
|
|
23
|
+
) {
|
|
24
|
+
super((resolve) => {
|
|
25
|
+
// this is maybe a bit weird but this has to be a no-op to not implicitly
|
|
26
|
+
// parse the response body; instead .then, .catch, .finally are overridden
|
|
27
|
+
// to parse the response
|
|
28
|
+
resolve(null as any);
|
|
29
|
+
});
|
|
30
|
+
this.#client = client;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U> {
|
|
34
|
+
return new APIPromise(this.#client, this.responsePromise, async (client, props) =>
|
|
35
|
+
transform(await this.parseResponse(client, props), props),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Gets the raw `Response` instance instead of parsing the response
|
|
41
|
+
* data.
|
|
42
|
+
*
|
|
43
|
+
* If you want to parse the response body but still get the `Response`
|
|
44
|
+
* instance, you can use {@link withResponse()}.
|
|
45
|
+
*
|
|
46
|
+
* 👋 Getting the wrong TypeScript type for `Response`?
|
|
47
|
+
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
|
|
48
|
+
* to your `tsconfig.json`.
|
|
49
|
+
*/
|
|
50
|
+
asResponse(): Promise<Response> {
|
|
51
|
+
return this.responsePromise.then((p) => p.response);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Gets the parsed response data and the raw `Response` instance.
|
|
56
|
+
*
|
|
57
|
+
* If you just want to get the raw `Response` instance without parsing it,
|
|
58
|
+
* you can use {@link asResponse()}.
|
|
59
|
+
*
|
|
60
|
+
* 👋 Getting the wrong TypeScript type for `Response`?
|
|
61
|
+
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
|
|
62
|
+
* to your `tsconfig.json`.
|
|
63
|
+
*/
|
|
64
|
+
async withResponse(): Promise<{ data: T; response: Response }> {
|
|
65
|
+
const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
|
|
66
|
+
return { data, response };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private parse(): Promise<T> {
|
|
70
|
+
if (!this.parsedPromise) {
|
|
71
|
+
this.parsedPromise = this.responsePromise.then((data) => this.parseResponse(this.#client, data));
|
|
72
|
+
}
|
|
73
|
+
return this.parsedPromise;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
override then<TResult1 = T, TResult2 = never>(
|
|
77
|
+
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
|
|
78
|
+
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,
|
|
79
|
+
): Promise<TResult1 | TResult2> {
|
|
80
|
+
return this.parse().then(onfulfilled, onrejected);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
override catch<TResult = never>(
|
|
84
|
+
onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null,
|
|
85
|
+
): Promise<T | TResult> {
|
|
86
|
+
return this.parse().catch(onrejected);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
override finally(onfinally?: (() => void) | undefined | null): Promise<T> {
|
|
90
|
+
return this.parse().finally(onfinally);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { castToError } from '../internal/errors';
|
|
4
|
+
|
|
5
|
+
export class LorikeetError extends Error {}
|
|
6
|
+
|
|
7
|
+
export class APIError<
|
|
8
|
+
TStatus extends number | undefined = number | undefined,
|
|
9
|
+
THeaders extends Headers | undefined = Headers | undefined,
|
|
10
|
+
TError extends Object | undefined = Object | undefined,
|
|
11
|
+
> extends LorikeetError {
|
|
12
|
+
/** HTTP status for the response that caused the error */
|
|
13
|
+
readonly status: TStatus;
|
|
14
|
+
/** HTTP headers for the response that caused the error */
|
|
15
|
+
readonly headers: THeaders;
|
|
16
|
+
/** JSON body of the response that caused the error */
|
|
17
|
+
readonly error: TError;
|
|
18
|
+
|
|
19
|
+
constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
|
|
20
|
+
super(`${APIError.makeMessage(status, error, message)}`);
|
|
21
|
+
this.status = status;
|
|
22
|
+
this.headers = headers;
|
|
23
|
+
this.error = error;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
|
|
27
|
+
const msg =
|
|
28
|
+
error?.message ?
|
|
29
|
+
typeof error.message === 'string' ?
|
|
30
|
+
error.message
|
|
31
|
+
: JSON.stringify(error.message)
|
|
32
|
+
: error ? JSON.stringify(error)
|
|
33
|
+
: message;
|
|
34
|
+
|
|
35
|
+
if (status && msg) {
|
|
36
|
+
return `${status} ${msg}`;
|
|
37
|
+
}
|
|
38
|
+
if (status) {
|
|
39
|
+
return `${status} status code (no body)`;
|
|
40
|
+
}
|
|
41
|
+
if (msg) {
|
|
42
|
+
return msg;
|
|
43
|
+
}
|
|
44
|
+
return '(no status code or body)';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static generate(
|
|
48
|
+
status: number | undefined,
|
|
49
|
+
errorResponse: Object | undefined,
|
|
50
|
+
message: string | undefined,
|
|
51
|
+
headers: Headers | undefined,
|
|
52
|
+
): APIError {
|
|
53
|
+
if (!status || !headers) {
|
|
54
|
+
return new APIConnectionError({ message, cause: castToError(errorResponse) });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const error = errorResponse as Record<string, any>;
|
|
58
|
+
|
|
59
|
+
if (status === 400) {
|
|
60
|
+
return new BadRequestError(status, error, message, headers);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (status === 401) {
|
|
64
|
+
return new AuthenticationError(status, error, message, headers);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (status === 403) {
|
|
68
|
+
return new PermissionDeniedError(status, error, message, headers);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (status === 404) {
|
|
72
|
+
return new NotFoundError(status, error, message, headers);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (status === 409) {
|
|
76
|
+
return new ConflictError(status, error, message, headers);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (status === 422) {
|
|
80
|
+
return new UnprocessableEntityError(status, error, message, headers);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (status === 429) {
|
|
84
|
+
return new RateLimitError(status, error, message, headers);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (status >= 500) {
|
|
88
|
+
return new InternalServerError(status, error, message, headers);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return new APIError(status, error, message, headers);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export class APIUserAbortError extends APIError<undefined, undefined, undefined> {
|
|
96
|
+
constructor({ message }: { message?: string } = {}) {
|
|
97
|
+
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class APIConnectionError extends APIError<undefined, undefined, undefined> {
|
|
102
|
+
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
|
|
103
|
+
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
104
|
+
// in some environments the 'cause' property is already declared
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
if (cause) this.cause = cause;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
111
|
+
constructor({ message }: { message?: string } = {}) {
|
|
112
|
+
super({ message: message ?? 'Request timed out.' });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export class BadRequestError extends APIError<400, Headers> {}
|
|
117
|
+
|
|
118
|
+
export class AuthenticationError extends APIError<401, Headers> {}
|
|
119
|
+
|
|
120
|
+
export class PermissionDeniedError extends APIError<403, Headers> {}
|
|
121
|
+
|
|
122
|
+
export class NotFoundError extends APIError<404, Headers> {}
|
|
123
|
+
|
|
124
|
+
export class ConflictError extends APIError<409, Headers> {}
|
|
125
|
+
|
|
126
|
+
export class UnprocessableEntityError extends APIError<422, Headers> {}
|
|
127
|
+
|
|
128
|
+
export class RateLimitError extends APIError<429, Headers> {}
|
|
129
|
+
|
|
130
|
+
export class InternalServerError extends APIError<number, Headers> {}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import type { Lorikeet } from '../client';
|
|
4
|
+
|
|
5
|
+
export abstract class APIResource {
|
|
6
|
+
protected _client: Lorikeet;
|
|
7
|
+
|
|
8
|
+
constructor(client: Lorikeet) {
|
|
9
|
+
this._client = client;
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/error.ts
CHANGED
|
@@ -1,130 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { castToError, Headers } from './core';
|
|
4
|
-
|
|
5
|
-
export class LorikeetError extends Error {}
|
|
6
|
-
|
|
7
|
-
export class APIError<
|
|
8
|
-
TStatus extends number | undefined = number | undefined,
|
|
9
|
-
THeaders extends Headers | undefined = Headers | undefined,
|
|
10
|
-
TError extends Object | undefined = Object | undefined,
|
|
11
|
-
> extends LorikeetError {
|
|
12
|
-
/** HTTP status for the response that caused the error */
|
|
13
|
-
readonly status: TStatus;
|
|
14
|
-
/** HTTP headers for the response that caused the error */
|
|
15
|
-
readonly headers: THeaders;
|
|
16
|
-
/** JSON body of the response that caused the error */
|
|
17
|
-
readonly error: TError;
|
|
18
|
-
|
|
19
|
-
constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
|
|
20
|
-
super(`${APIError.makeMessage(status, error, message)}`);
|
|
21
|
-
this.status = status;
|
|
22
|
-
this.headers = headers;
|
|
23
|
-
this.error = error;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
|
|
27
|
-
const msg =
|
|
28
|
-
error?.message ?
|
|
29
|
-
typeof error.message === 'string' ?
|
|
30
|
-
error.message
|
|
31
|
-
: JSON.stringify(error.message)
|
|
32
|
-
: error ? JSON.stringify(error)
|
|
33
|
-
: message;
|
|
34
|
-
|
|
35
|
-
if (status && msg) {
|
|
36
|
-
return `${status} ${msg}`;
|
|
37
|
-
}
|
|
38
|
-
if (status) {
|
|
39
|
-
return `${status} status code (no body)`;
|
|
40
|
-
}
|
|
41
|
-
if (msg) {
|
|
42
|
-
return msg;
|
|
43
|
-
}
|
|
44
|
-
return '(no status code or body)';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static generate(
|
|
48
|
-
status: number | undefined,
|
|
49
|
-
errorResponse: Object | undefined,
|
|
50
|
-
message: string | undefined,
|
|
51
|
-
headers: Headers | undefined,
|
|
52
|
-
): APIError {
|
|
53
|
-
if (!status || !headers) {
|
|
54
|
-
return new APIConnectionError({ message, cause: castToError(errorResponse) });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const error = errorResponse as Record<string, any>;
|
|
58
|
-
|
|
59
|
-
if (status === 400) {
|
|
60
|
-
return new BadRequestError(status, error, message, headers);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (status === 401) {
|
|
64
|
-
return new AuthenticationError(status, error, message, headers);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (status === 403) {
|
|
68
|
-
return new PermissionDeniedError(status, error, message, headers);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (status === 404) {
|
|
72
|
-
return new NotFoundError(status, error, message, headers);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (status === 409) {
|
|
76
|
-
return new ConflictError(status, error, message, headers);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (status === 422) {
|
|
80
|
-
return new UnprocessableEntityError(status, error, message, headers);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (status === 429) {
|
|
84
|
-
return new RateLimitError(status, error, message, headers);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (status >= 500) {
|
|
88
|
-
return new InternalServerError(status, error, message, headers);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return new APIError(status, error, message, headers);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export class APIUserAbortError extends APIError<undefined, undefined, undefined> {
|
|
96
|
-
constructor({ message }: { message?: string } = {}) {
|
|
97
|
-
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export class APIConnectionError extends APIError<undefined, undefined, undefined> {
|
|
102
|
-
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
|
|
103
|
-
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
104
|
-
// in some environments the 'cause' property is already declared
|
|
105
|
-
// @ts-ignore
|
|
106
|
-
if (cause) this.cause = cause;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
111
|
-
constructor({ message }: { message?: string } = {}) {
|
|
112
|
-
super({ message: message ?? 'Request timed out.' });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export class BadRequestError extends APIError<400, Headers> {}
|
|
117
|
-
|
|
118
|
-
export class AuthenticationError extends APIError<401, Headers> {}
|
|
119
|
-
|
|
120
|
-
export class PermissionDeniedError extends APIError<403, Headers> {}
|
|
121
|
-
|
|
122
|
-
export class NotFoundError extends APIError<404, Headers> {}
|
|
123
|
-
|
|
124
|
-
export class ConflictError extends APIError<409, Headers> {}
|
|
125
|
-
|
|
126
|
-
export class UnprocessableEntityError extends APIError<422, Headers> {}
|
|
127
|
-
|
|
128
|
-
export class RateLimitError extends APIError<429, Headers> {}
|
|
129
|
-
|
|
130
|
-
export class InternalServerError extends APIError<number, Headers> {}
|
|
1
|
+
/** @deprecated Import from ./core/error instead */
|
|
2
|
+
export * from './core/error';
|
package/src/index.ts
CHANGED
|
@@ -1,276 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import * as Core from './core';
|
|
5
|
-
import * as Errors from './error';
|
|
6
|
-
import * as Uploads from './uploads';
|
|
7
|
-
import * as API from './resources/index';
|
|
8
|
-
import {
|
|
9
|
-
APIKeyCreateParams,
|
|
10
|
-
APIKeyCreateResponse,
|
|
11
|
-
APIKeyGetResponse,
|
|
12
|
-
APIKeyListResponse,
|
|
13
|
-
APIKeys,
|
|
14
|
-
} from './resources/api-keys';
|
|
15
|
-
import { Ingest, IngestTestParams } from './resources/ingest';
|
|
16
|
-
import {
|
|
17
|
-
AttachmentDto,
|
|
18
|
-
Conversation,
|
|
19
|
-
TicketEvent,
|
|
20
|
-
TicketMessageDto,
|
|
21
|
-
} from './resources/conversation/conversation';
|
|
22
|
-
import { generateSignature } from './lib/generate-signature';
|
|
23
|
-
import {
|
|
24
|
-
Customer,
|
|
25
|
-
CustomerCreateParams,
|
|
26
|
-
CustomerCreateResponse,
|
|
27
|
-
CustomerGetParams,
|
|
28
|
-
CustomerGetResponse,
|
|
29
|
-
CustomerTokenParams,
|
|
30
|
-
CustomerTokenResponse,
|
|
31
|
-
CustomerUpdateParams,
|
|
32
|
-
CustomerUpdateResponse,
|
|
33
|
-
} from './resources/customer/customer';
|
|
3
|
+
export { Lorikeet as default } from './client';
|
|
34
4
|
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*/
|
|
39
|
-
clientId?: string | undefined;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Secret key pulled from the Lorikeet App
|
|
43
|
-
*/
|
|
44
|
-
clientSecret?: string | undefined;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
48
|
-
*
|
|
49
|
-
* Defaults to process.env['LORIKEET_BASE_URL'].
|
|
50
|
-
*/
|
|
51
|
-
baseURL?: string | null | undefined;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
55
|
-
* from the server before timing out a single request.
|
|
56
|
-
*
|
|
57
|
-
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
58
|
-
* much longer than this timeout before the promise succeeds or fails.
|
|
59
|
-
*
|
|
60
|
-
* @unit milliseconds
|
|
61
|
-
*/
|
|
62
|
-
timeout?: number | undefined;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* An HTTP agent used to manage HTTP(S) connections.
|
|
66
|
-
*
|
|
67
|
-
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
68
|
-
* otherwise no agent is used.
|
|
69
|
-
*/
|
|
70
|
-
httpAgent?: Agent | undefined;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Specify a custom `fetch` function implementation.
|
|
74
|
-
*
|
|
75
|
-
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
76
|
-
* defined globally.
|
|
77
|
-
*/
|
|
78
|
-
fetch?: Core.Fetch | undefined;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* The maximum number of times that the client will retry a request in case of a
|
|
82
|
-
* temporary failure, like a network error or a 5XX error from the server.
|
|
83
|
-
*
|
|
84
|
-
* @default 2
|
|
85
|
-
*/
|
|
86
|
-
maxRetries?: number | undefined;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Default headers to include with every request to the API.
|
|
90
|
-
*
|
|
91
|
-
* These can be removed in individual requests by explicitly setting the
|
|
92
|
-
* header to `undefined` or `null` in request options.
|
|
93
|
-
*/
|
|
94
|
-
defaultHeaders?: Core.Headers | undefined;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Default query parameters to include with every request to the API.
|
|
98
|
-
*
|
|
99
|
-
* These can be removed in individual requests by explicitly setting the
|
|
100
|
-
* param to `undefined` in request options.
|
|
101
|
-
*/
|
|
102
|
-
defaultQuery?: Core.DefaultQuery | undefined;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* API Client for interfacing with the Lorikeet API.
|
|
107
|
-
*/
|
|
108
|
-
export class Lorikeet extends Core.APIClient {
|
|
109
|
-
clientId: string;
|
|
110
|
-
clientSecret: string;
|
|
111
|
-
|
|
112
|
-
private _options: ClientOptions;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* API Client for interfacing with the Lorikeet API.
|
|
116
|
-
*
|
|
117
|
-
* @param {string | undefined} [opts.clientId=process.env['LORIKEET_CLIENT_ID'] ?? undefined]
|
|
118
|
-
* @param {string | undefined} [opts.clientSecret=process.env['LORIKEET_CLIENT_SECRET'] ?? undefined]
|
|
119
|
-
* @param {string} [opts.baseURL=process.env['LORIKEET_BASE_URL'] ?? https://api.lorikeetcx.ai] - Override the default base URL for the API.
|
|
120
|
-
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
121
|
-
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
122
|
-
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
123
|
-
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
124
|
-
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
125
|
-
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
126
|
-
*/
|
|
127
|
-
constructor({
|
|
128
|
-
baseURL = Core.readEnv('LORIKEET_BASE_URL'),
|
|
129
|
-
clientId = Core.readEnv('LORIKEET_CLIENT_ID'),
|
|
130
|
-
clientSecret = Core.readEnv('LORIKEET_CLIENT_SECRET'),
|
|
131
|
-
...opts
|
|
132
|
-
}: ClientOptions = {}) {
|
|
133
|
-
if (clientId === undefined) {
|
|
134
|
-
throw new Errors.LorikeetError(
|
|
135
|
-
"The LORIKEET_CLIENT_ID environment variable is missing or empty; either provide it, or instantiate the Lorikeet client with an clientId option, like new Lorikeet({ clientId: 'My Client ID' }).",
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
if (clientSecret === undefined) {
|
|
139
|
-
throw new Errors.LorikeetError(
|
|
140
|
-
"The LORIKEET_CLIENT_SECRET environment variable is missing or empty; either provide it, or instantiate the Lorikeet client with an clientSecret option, like new Lorikeet({ clientSecret: 'My Client Secret' }).",
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const options: ClientOptions = {
|
|
145
|
-
clientId,
|
|
146
|
-
clientSecret,
|
|
147
|
-
...opts,
|
|
148
|
-
baseURL: baseURL || `https://api.lorikeetcx.ai`,
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
super({
|
|
152
|
-
baseURL: options.baseURL!,
|
|
153
|
-
baseURLOverridden: baseURL ? baseURL !== 'https://api.lorikeetcx.ai' : false,
|
|
154
|
-
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
155
|
-
httpAgent: options.httpAgent,
|
|
156
|
-
maxRetries: options.maxRetries,
|
|
157
|
-
fetch: options.fetch,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
this._options = options;
|
|
161
|
-
|
|
162
|
-
this.clientId = clientId;
|
|
163
|
-
this.clientSecret = clientSecret;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
conversation: API.Conversation = new API.Conversation(this);
|
|
167
|
-
customer: API.Customer = new API.Customer(this);
|
|
168
|
-
ingest: API.Ingest = new API.Ingest(this);
|
|
169
|
-
apiKeys: API.APIKeys = new API.APIKeys(this);
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Check whether the base URL is set to its default.
|
|
173
|
-
*/
|
|
174
|
-
#baseURLOverridden(): boolean {
|
|
175
|
-
return this.baseURL !== 'https://api.lorikeetcx.ai';
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
179
|
-
return this._options.defaultQuery;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
183
|
-
return {
|
|
184
|
-
...super.defaultHeaders(opts),
|
|
185
|
-
...this._options.defaultHeaders,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
190
|
-
return {
|
|
191
|
-
...this.lorikeetClientIdAuth(opts),
|
|
192
|
-
...this.lorikeetSignatureAuthV1Auth(opts),
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
protected lorikeetClientIdAuth(opts: Core.FinalRequestOptions): Core.Headers {
|
|
197
|
-
return { authorization: `Bearer ${this.clientId}` };
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
protected lorikeetSignatureAuthV1Auth(opts: Core.FinalRequestOptions): Core.Headers {
|
|
201
|
-
const signature = generateSignature(
|
|
202
|
-
opts.body ?
|
|
203
|
-
typeof opts.body === 'string' ?
|
|
204
|
-
opts.body
|
|
205
|
-
: JSON.stringify(opts.body, null, 2)
|
|
206
|
-
: '',
|
|
207
|
-
this.clientSecret,
|
|
208
|
-
);
|
|
209
|
-
return {
|
|
210
|
-
'x-lorikeet-signature': signature,
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
static Lorikeet = this;
|
|
215
|
-
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
216
|
-
|
|
217
|
-
static LorikeetError = Errors.LorikeetError;
|
|
218
|
-
static APIError = Errors.APIError;
|
|
219
|
-
static APIConnectionError = Errors.APIConnectionError;
|
|
220
|
-
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
221
|
-
static APIUserAbortError = Errors.APIUserAbortError;
|
|
222
|
-
static NotFoundError = Errors.NotFoundError;
|
|
223
|
-
static ConflictError = Errors.ConflictError;
|
|
224
|
-
static RateLimitError = Errors.RateLimitError;
|
|
225
|
-
static BadRequestError = Errors.BadRequestError;
|
|
226
|
-
static AuthenticationError = Errors.AuthenticationError;
|
|
227
|
-
static InternalServerError = Errors.InternalServerError;
|
|
228
|
-
static PermissionDeniedError = Errors.PermissionDeniedError;
|
|
229
|
-
static UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
230
|
-
|
|
231
|
-
static toFile = Uploads.toFile;
|
|
232
|
-
static fileFromPath = Uploads.fileFromPath;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
Lorikeet.Conversation = Conversation;
|
|
236
|
-
Lorikeet.Customer = Customer;
|
|
237
|
-
Lorikeet.Ingest = Ingest;
|
|
238
|
-
Lorikeet.APIKeys = APIKeys;
|
|
239
|
-
|
|
240
|
-
export declare namespace Lorikeet {
|
|
241
|
-
export type RequestOptions = Core.RequestOptions;
|
|
242
|
-
|
|
243
|
-
export {
|
|
244
|
-
Conversation as Conversation,
|
|
245
|
-
type AttachmentDto as AttachmentDto,
|
|
246
|
-
type TicketEvent as TicketEvent,
|
|
247
|
-
type TicketMessageDto as TicketMessageDto,
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
export {
|
|
251
|
-
Customer as Customer,
|
|
252
|
-
type CustomerCreateResponse as CustomerCreateResponse,
|
|
253
|
-
type CustomerUpdateResponse as CustomerUpdateResponse,
|
|
254
|
-
type CustomerGetResponse as CustomerGetResponse,
|
|
255
|
-
type CustomerTokenResponse as CustomerTokenResponse,
|
|
256
|
-
type CustomerCreateParams as CustomerCreateParams,
|
|
257
|
-
type CustomerUpdateParams as CustomerUpdateParams,
|
|
258
|
-
type CustomerGetParams as CustomerGetParams,
|
|
259
|
-
type CustomerTokenParams as CustomerTokenParams,
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
export { Ingest as Ingest, type IngestTestParams as IngestTestParams };
|
|
263
|
-
|
|
264
|
-
export {
|
|
265
|
-
APIKeys as APIKeys,
|
|
266
|
-
type APIKeyCreateResponse as APIKeyCreateResponse,
|
|
267
|
-
type APIKeyListResponse as APIKeyListResponse,
|
|
268
|
-
type APIKeyGetResponse as APIKeyGetResponse,
|
|
269
|
-
type APIKeyCreateParams as APIKeyCreateParams,
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export { toFile, fileFromPath } from './uploads';
|
|
5
|
+
export { type Uploadable, toFile } from './core/uploads';
|
|
6
|
+
export { APIPromise } from './core/api-promise';
|
|
7
|
+
export { Lorikeet, type ClientOptions } from './client';
|
|
274
8
|
export {
|
|
275
9
|
LorikeetError,
|
|
276
10
|
APIError,
|
|
@@ -285,8 +19,5 @@ export {
|
|
|
285
19
|
InternalServerError,
|
|
286
20
|
PermissionDeniedError,
|
|
287
21
|
UnprocessableEntityError,
|
|
288
|
-
} from './error';
|
|
289
|
-
|
|
290
|
-
export { generateSignature } from "./lib/generate-signature";
|
|
291
|
-
|
|
292
|
-
export default Lorikeet;
|
|
22
|
+
} from './core/error';
|
|
23
|
+
export { generateSignature } from './lib/generate-signature';
|