@nirvana-labs/nirvana 0.9.0 → 0.10.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 +18 -0
- package/README.md +108 -50
- 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/{_shims/auto/runtime.js → api-promise.js} +3 -5
- package/api-promise.js.map +1 -0
- package/api-promise.mjs +2 -0
- package/api-promise.mjs.map +1 -0
- package/client.d.mts +189 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +189 -0
- package/client.d.ts.map +1 -0
- package/client.js +481 -0
- package/client.js.map +1 -0
- package/client.mjs +454 -0
- package/client.mjs.map +1 -0
- package/core/api-promise.d.mts +47 -0
- package/core/api-promise.d.mts.map +1 -0
- package/core/api-promise.d.ts +47 -0
- package/core/api-promise.d.ts.map +1 -0
- package/core/api-promise.js +84 -0
- package/core/api-promise.js.map +1 -0
- package/core/api-promise.mjs +80 -0
- package/core/api-promise.mjs.map +1 -0
- package/core/error.d.mts +47 -0
- package/core/error.d.mts.map +1 -0
- package/core/error.d.ts +47 -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 +16 -110
- package/error.js.map +1 -1
- package/error.mjs +1 -96
- package/error.mjs.map +1 -1
- package/index.d.mts +6 -124
- package/index.d.mts.map +1 -0
- package/index.d.ts +5 -123
- package/index.d.ts.map +1 -1
- package/index.js +12 -116
- package/index.js.map +1 -1
- package/index.mjs +5 -89
- package/index.mjs.map +1 -1
- package/internal/builtin-types.d.mts +75 -0
- package/internal/builtin-types.d.mts.map +1 -0
- package/internal/builtin-types.d.ts +75 -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 +21 -0
- package/internal/headers.d.mts.map +1 -0
- package/internal/headers.d.ts +21 -0
- package/internal/headers.d.ts.map +1 -0
- package/internal/headers.js +77 -0
- package/internal/headers.js.map +1 -0
- package/internal/headers.mjs +72 -0
- package/internal/headers.mjs.map +1 -0
- package/internal/parse.d.mts +13 -0
- package/internal/parse.d.mts.map +1 -0
- package/internal/parse.d.ts +13 -0
- package/internal/parse.d.ts.map +1 -0
- package/internal/parse.js +36 -0
- package/internal/parse.js.map +1 -0
- package/internal/parse.mjs +32 -0
- package/internal/parse.mjs.map +1 -0
- package/internal/request-options.d.mts +33 -0
- package/internal/request-options.d.mts.map +1 -0
- package/internal/request-options.d.ts +33 -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 +28 -0
- package/internal/shim-types.d.ts +28 -0
- package/internal/shims/crypto.d.mts +13 -0
- package/internal/shims/crypto.d.mts.map +1 -0
- package/internal/shims/crypto.d.ts +13 -0
- package/internal/shims/crypto.d.ts.map +1 -0
- package/internal/shims/crypto.js +13 -0
- package/internal/shims/crypto.js.map +1 -0
- package/internal/shims/crypto.mjs +9 -0
- package/internal/shims/crypto.mjs.map +1 -0
- package/internal/shims/file.d.mts +23 -0
- package/internal/shims/file.d.mts.map +1 -0
- package/internal/shims/file.d.ts +23 -0
- package/internal/shims/file.d.ts.map +1 -0
- package/internal/shims/file.js +16 -0
- package/internal/shims/file.js.map +1 -0
- package/internal/shims/file.mjs +12 -0
- package/internal/shims/file.mjs.map +1 -0
- package/internal/shims/getBuiltinModule.d.mts +11 -0
- package/internal/shims/getBuiltinModule.d.mts.map +1 -0
- package/internal/shims/getBuiltinModule.d.ts +11 -0
- package/internal/shims/getBuiltinModule.d.ts.map +1 -0
- package/internal/shims/getBuiltinModule.js +71 -0
- package/internal/shims/getBuiltinModule.js.map +1 -0
- package/internal/shims/getBuiltinModule.mjs +67 -0
- package/internal/shims/getBuiltinModule.mjs.map +1 -0
- package/internal/shims/nullGetBuiltinModule.d.mts +2 -0
- package/internal/shims/nullGetBuiltinModule.d.mts.map +1 -0
- package/internal/shims/nullGetBuiltinModule.d.ts +2 -0
- package/internal/shims/nullGetBuiltinModule.d.ts.map +1 -0
- package/internal/shims/nullGetBuiltinModule.js +5 -0
- package/internal/shims/nullGetBuiltinModule.js.map +1 -0
- package/internal/shims/nullGetBuiltinModule.mjs +2 -0
- package/internal/shims/nullGetBuiltinModule.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 +93 -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 +46 -0
- package/internal/to-file.d.mts.map +1 -0
- package/internal/to-file.d.ts +46 -0
- package/internal/to-file.d.ts.map +1 -0
- package/internal/to-file.js +91 -0
- package/internal/to-file.js.map +1 -0
- package/internal/to-file.mjs +87 -0
- package/internal/to-file.mjs.map +1 -0
- package/internal/types.d.mts +68 -0
- package/internal/types.d.mts.map +1 -0
- package/internal/types.d.ts +68 -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 +44 -0
- package/internal/uploads.d.mts.map +1 -0
- package/internal/uploads.d.ts +44 -0
- package/internal/uploads.d.ts.map +1 -0
- package/internal/uploads.js +131 -0
- package/internal/uploads.js.map +1 -0
- package/internal/uploads.mjs +122 -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 +33 -0
- package/internal/utils/base64.js.map +1 -0
- package/internal/utils/base64.mjs +28 -0
- package/internal/utils/base64.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 +38 -0
- package/internal/utils/log.d.mts.map +1 -0
- package/internal/utils/log.d.ts +38 -0
- package/internal/utils/log.d.ts.map +1 -0
- package/internal/utils/log.js +85 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +79 -0
- package/internal/utils/log.mjs.map +1 -0
- package/internal/utils/path.d.mts +15 -0
- package/internal/utils/path.d.mts.map +1 -0
- package/internal/utils/path.d.ts +15 -0
- package/internal/utils/path.d.ts.map +1 -0
- package/internal/utils/path.js +58 -0
- package/internal/utils/path.js.map +1 -0
- package/internal/utils/path.mjs +53 -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 +20 -0
- package/internal/utils/uuid.js.map +1 -0
- package/internal/utils/uuid.mjs +16 -0
- package/internal/utils/uuid.mjs.map +1 -0
- package/internal/utils/values.d.mts +16 -0
- package/internal/utils/values.d.mts.map +1 -0
- package/internal/utils/values.d.ts +16 -0
- package/internal/utils/values.d.ts.map +1 -0
- package/internal/utils/values.js +109 -0
- package/internal/utils/values.js.map +1 -0
- package/internal/utils/values.mjs +92 -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/{_shims/auto/runtime-bun.js → internal/utils.js} +8 -5
- package/internal/utils.js.map +1 -0
- package/internal/utils.mjs +8 -0
- package/internal/utils.mjs.map +1 -0
- package/package.json +106 -63
- 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 +16 -8
- package/resource.js.map +1 -1
- package/resource.mjs +1 -6
- package/resource.mjs.map +1 -1
- package/resources/api-keys.d.mts +93 -0
- package/resources/api-keys.d.mts.map +1 -0
- package/resources/api-keys.d.ts +8 -7
- package/resources/api-keys.d.ts.map +1 -1
- package/resources/api-keys.js +10 -8
- package/resources/api-keys.js.map +1 -1
- package/resources/api-keys.mjs +10 -8
- package/resources/api-keys.mjs.map +1 -1
- package/resources/compute/compute.d.mts +14 -0
- package/resources/compute/compute.d.mts.map +1 -0
- package/resources/compute/compute.d.ts +1 -1
- package/resources/compute/compute.d.ts.map +1 -1
- package/resources/compute/compute.js +1 -1
- package/resources/compute/compute.js.map +1 -1
- package/resources/compute/compute.mjs +1 -1
- package/resources/compute/index.d.mts +4 -0
- package/resources/compute/index.d.mts.map +1 -0
- package/resources/compute/index.d.ts.map +1 -1
- package/resources/compute/vms/index.d.mts +4 -0
- package/resources/compute/vms/index.d.mts.map +1 -0
- package/resources/compute/vms/index.d.ts.map +1 -1
- package/resources/compute/vms/os-images.d.mts +15 -0
- package/resources/compute/vms/os-images.d.mts.map +1 -0
- package/resources/compute/vms/os-images.d.ts +4 -3
- package/resources/compute/vms/os-images.d.ts.map +1 -1
- package/resources/compute/vms/os-images.js +1 -1
- package/resources/compute/vms/os-images.js.map +1 -1
- package/resources/compute/vms/os-images.mjs +1 -1
- package/resources/compute/vms/os-images.mjs.map +1 -1
- package/resources/compute/vms/vms.d.mts +148 -0
- package/resources/compute/vms/vms.d.mts.map +1 -0
- package/resources/compute/vms/vms.d.ts +8 -7
- package/resources/compute/vms/vms.d.ts.map +1 -1
- package/resources/compute/vms/vms.js +8 -7
- package/resources/compute/vms/vms.js.map +1 -1
- package/resources/compute/vms/vms.mjs +8 -7
- package/resources/compute/vms/vms.mjs.map +1 -1
- package/resources/compute/vms/volumes.d.mts +11 -0
- package/resources/compute/vms/volumes.d.mts.map +1 -0
- package/resources/compute/vms/volumes.d.ts +4 -3
- package/resources/compute/vms/volumes.d.ts.map +1 -1
- package/resources/compute/vms/volumes.js +4 -3
- package/resources/compute/vms/volumes.js.map +1 -1
- package/resources/compute/vms/volumes.mjs +4 -3
- package/resources/compute/vms/volumes.mjs.map +1 -1
- package/resources/compute/vms.d.mts +2 -0
- package/resources/compute/vms.d.mts.map +1 -0
- package/resources/compute/vms.d.ts.map +1 -1
- package/resources/compute/volumes.d.mts +72 -0
- package/resources/compute/volumes.d.mts.map +1 -0
- package/resources/compute/volumes.d.ts +8 -7
- package/resources/compute/volumes.d.ts.map +1 -1
- package/resources/compute/volumes.js +8 -7
- package/resources/compute/volumes.js.map +1 -1
- package/resources/compute/volumes.mjs +8 -7
- package/resources/compute/volumes.mjs.map +1 -1
- package/resources/compute.d.mts +2 -0
- package/resources/compute.d.mts.map +1 -0
- package/resources/compute.d.ts.map +1 -1
- package/resources/index.d.mts +7 -0
- package/resources/index.d.mts.map +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/networking/firewall-rules.d.mts +100 -0
- package/resources/networking/firewall-rules.d.mts.map +1 -0
- package/resources/networking/firewall-rules.d.ts +38 -9
- package/resources/networking/firewall-rules.d.ts.map +1 -1
- package/resources/networking/firewall-rules.js +15 -11
- package/resources/networking/firewall-rules.js.map +1 -1
- package/resources/networking/firewall-rules.mjs +15 -11
- package/resources/networking/firewall-rules.mjs.map +1 -1
- package/resources/networking/index.d.mts +4 -0
- package/resources/networking/index.d.mts.map +1 -0
- package/resources/networking/index.d.ts +1 -1
- package/resources/networking/index.d.ts.map +1 -1
- package/resources/networking/index.js.map +1 -1
- package/resources/networking/index.mjs.map +1 -1
- package/resources/networking/networking.d.mts +14 -0
- package/resources/networking/networking.d.mts.map +1 -0
- package/resources/networking/networking.d.ts +3 -3
- package/resources/networking/networking.d.ts.map +1 -1
- package/resources/networking/networking.js +1 -1
- package/resources/networking/networking.js.map +1 -1
- package/resources/networking/networking.mjs +1 -1
- package/resources/networking/networking.mjs.map +1 -1
- package/resources/networking/vpcs.d.mts +69 -0
- package/resources/networking/vpcs.d.mts.map +1 -0
- package/resources/networking/vpcs.d.ts +8 -7
- package/resources/networking/vpcs.d.ts.map +1 -1
- package/resources/networking/vpcs.js +8 -7
- package/resources/networking/vpcs.js.map +1 -1
- package/resources/networking/vpcs.mjs +8 -7
- package/resources/networking/vpcs.mjs.map +1 -1
- package/resources/networking.d.mts +2 -0
- package/resources/networking.d.mts.map +1 -0
- package/resources/networking.d.ts.map +1 -1
- package/resources/operations.d.mts +35 -0
- package/resources/operations.d.mts.map +1 -0
- package/resources/operations.d.ts +5 -4
- package/resources/operations.d.ts.map +1 -1
- package/resources/operations.js +4 -3
- package/resources/operations.js.map +1 -1
- package/resources/operations.mjs +4 -3
- package/resources/operations.mjs.map +1 -1
- package/resources/shared.d.mts +3 -0
- package/resources/shared.d.mts.map +1 -0
- package/resources/user.d.mts +23 -0
- package/resources/user.d.mts.map +1 -0
- package/resources/user.d.ts +4 -3
- package/resources/user.d.ts.map +1 -1
- package/resources/user.js +1 -1
- package/resources/user.js.map +1 -1
- package/resources/user.mjs +1 -1
- package/resources/user.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/src/api-promise.ts +2 -0
- package/src/client.ts +707 -0
- package/src/core/README.md +3 -0
- package/src/core/api-promise.ts +92 -0
- package/src/core/error.ts +130 -0
- package/src/core/resource.ts +11 -0
- package/src/core/uploads.ts +2 -0
- package/src/error.ts +2 -130
- package/src/index.ts +5 -191
- 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 +96 -0
- package/src/internal/parse.ts +50 -0
- package/src/internal/request-options.ts +37 -0
- package/src/internal/shim-types.d.ts +28 -0
- package/src/internal/shims/crypto.ts +18 -0
- package/src/internal/shims/file.ts +32 -0
- package/src/internal/shims/getBuiltinModule.ts +66 -0
- package/src/internal/shims/nullGetBuiltinModule.ts +1 -0
- package/src/internal/shims.ts +107 -0
- package/src/internal/to-file.ts +152 -0
- package/src/internal/types.ts +92 -0
- package/src/internal/uploads.ts +175 -0
- package/src/internal/utils/base64.ts +37 -0
- package/src/internal/utils/env.ts +18 -0
- package/src/internal/utils/log.ts +126 -0
- package/src/internal/utils/path.ts +65 -0
- package/src/internal/utils/sleep.ts +3 -0
- package/src/internal/utils/uuid.ts +19 -0
- package/src/internal/utils/values.ts +102 -0
- package/src/internal/utils.ts +8 -0
- package/src/resource.ts +2 -11
- package/src/resources/api-keys.ts +14 -11
- package/src/resources/compute/compute.ts +1 -1
- package/src/resources/compute/vms/os-images.ts +4 -3
- package/src/resources/compute/vms/vms.ts +12 -14
- package/src/resources/compute/vms/volumes.ts +6 -4
- package/src/resources/compute/volumes.ts +14 -12
- package/src/resources/networking/firewall-rules.ts +63 -22
- package/src/resources/networking/index.ts +2 -0
- package/src/resources/networking/networking.ts +5 -1
- package/src/resources/networking/vpcs.ts +14 -12
- package/src/resources/operations.ts +7 -5
- package/src/resources/user.ts +4 -3
- package/src/tsconfig.json +2 -2
- package/src/uploads.ts +2 -255
- package/src/version.ts +1 -1
- package/uploads.d.mts +2 -0
- package/uploads.d.mts.map +1 -0
- package/uploads.d.ts +1 -74
- package/uploads.d.ts.map +1 -1
- package/uploads.js +16 -168
- package/uploads.js.map +1 -1
- package/uploads.mjs +1 -157
- package/uploads.mjs.map +1 -1
- package/version.d.mts +2 -0
- package/version.d.mts.map +1 -0
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/_shims/MultipartBody.d.ts +0 -9
- package/_shims/MultipartBody.d.ts.map +0 -1
- package/_shims/MultipartBody.js +0 -16
- package/_shims/MultipartBody.js.map +0 -1
- package/_shims/MultipartBody.mjs +0 -12
- package/_shims/MultipartBody.mjs.map +0 -1
- package/_shims/README.md +0 -46
- package/_shims/auto/runtime-bun.d.ts +0 -5
- package/_shims/auto/runtime-bun.d.ts.map +0 -1
- package/_shims/auto/runtime-bun.js.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.map +0 -1
- package/_shims/auto/runtime.mjs +0 -2
- package/_shims/auto/runtime.mjs.map +0 -1
- package/_shims/auto/types-node.d.ts +0 -5
- package/_shims/auto/types-node.d.ts.map +0 -1
- package/_shims/auto/types-node.js +0 -21
- package/_shims/auto/types-node.js.map +0 -1
- package/_shims/auto/types-node.mjs +0 -2
- package/_shims/auto/types-node.mjs.map +0 -1
- package/_shims/auto/types.d.ts +0 -101
- package/_shims/auto/types.js +0 -3
- package/_shims/auto/types.mjs +0 -3
- package/_shims/bun-runtime.d.ts +0 -6
- package/_shims/bun-runtime.d.ts.map +0 -1
- package/_shims/bun-runtime.js +0 -14
- package/_shims/bun-runtime.js.map +0 -1
- package/_shims/bun-runtime.mjs +0 -10
- package/_shims/bun-runtime.mjs.map +0 -1
- package/_shims/index.d.ts +0 -83
- package/_shims/index.js +0 -17
- package/_shims/index.mjs +0 -11
- package/_shims/manual-types.d.ts +0 -12
- package/_shims/manual-types.js +0 -3
- package/_shims/manual-types.mjs +0 -3
- package/_shims/node-runtime.d.ts +0 -3
- package/_shims/node-runtime.d.ts.map +0 -1
- package/_shims/node-runtime.js +0 -89
- package/_shims/node-runtime.js.map +0 -1
- package/_shims/node-runtime.mjs +0 -56
- package/_shims/node-runtime.mjs.map +0 -1
- package/_shims/node-types.d.ts +0 -42
- package/_shims/node-types.js +0 -3
- package/_shims/node-types.mjs +0 -3
- package/_shims/registry.d.ts +0 -37
- package/_shims/registry.d.ts.map +0 -1
- package/_shims/registry.js +0 -41
- package/_shims/registry.js.map +0 -1
- package/_shims/registry.mjs +0 -37
- package/_shims/registry.mjs.map +0 -1
- package/_shims/web-runtime.d.ts +0 -5
- package/_shims/web-runtime.d.ts.map +0 -1
- package/_shims/web-runtime.js +0 -78
- package/_shims/web-runtime.js.map +0 -1
- package/_shims/web-runtime.mjs +0 -71
- package/_shims/web-runtime.mjs.map +0 -1
- package/_shims/web-types.d.ts +0 -83
- package/_shims/web-types.js +0 -3
- package/_shims/web-types.mjs +0 -3
- package/core.d.ts +0 -252
- package/core.d.ts.map +0 -1
- package/core.js +0 -917
- package/core.js.map +0 -1
- package/core.mjs +0 -885
- package/core.mjs.map +0 -1
- package/shims/node.d.ts +0 -30
- package/shims/node.d.ts.map +0 -1
- package/shims/node.js +0 -31
- package/shims/node.js.map +0 -1
- package/shims/node.mjs +0 -5
- package/shims/node.mjs.map +0 -1
- package/shims/web.d.ts +0 -26
- package/shims/web.d.ts.map +0 -1
- package/shims/web.js +0 -31
- package/shims/web.js.map +0 -1
- package/shims/web.mjs +0 -5
- package/shims/web.mjs.map +0 -1
- package/src/_shims/MultipartBody.ts +0 -9
- package/src/_shims/README.md +0 -46
- package/src/_shims/auto/runtime-bun.ts +0 -4
- package/src/_shims/auto/runtime-node.ts +0 -4
- package/src/_shims/auto/runtime.ts +0 -4
- package/src/_shims/auto/types-node.ts +0 -4
- package/src/_shims/auto/types.d.ts +0 -101
- package/src/_shims/auto/types.js +0 -3
- package/src/_shims/auto/types.mjs +0 -3
- package/src/_shims/bun-runtime.ts +0 -14
- package/src/_shims/index.d.ts +0 -83
- package/src/_shims/index.js +0 -17
- package/src/_shims/index.mjs +0 -11
- package/src/_shims/manual-types.d.ts +0 -12
- package/src/_shims/manual-types.js +0 -3
- package/src/_shims/manual-types.mjs +0 -3
- package/src/_shims/node-runtime.ts +0 -81
- package/src/_shims/node-types.d.ts +0 -42
- package/src/_shims/node-types.js +0 -3
- package/src/_shims/node-types.mjs +0 -3
- package/src/_shims/registry.ts +0 -67
- package/src/_shims/web-runtime.ts +0 -103
- package/src/_shims/web-types.d.ts +0 -83
- package/src/_shims/web-types.js +0 -3
- package/src/_shims/web-types.mjs +0 -3
- package/src/core.ts +0 -1228
- package/src/shims/node.ts +0 -50
- package/src/shims/web.ts +0 -50
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { VERSION } from '../version';
|
|
4
|
+
|
|
5
|
+
export const isRunningInBrowser = () => {
|
|
6
|
+
return (
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
typeof window !== 'undefined' &&
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
typeof window.document !== 'undefined' &&
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
typeof navigator !== 'undefined'
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type DetectedPlatform = 'deno' | 'node' | 'edge' | 'unknown';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Note this does not detect 'browser'; for that, use getBrowserInfo().
|
|
20
|
+
*/
|
|
21
|
+
function getDetectedPlatform(): DetectedPlatform {
|
|
22
|
+
if (typeof Deno !== 'undefined' && Deno.build != null) {
|
|
23
|
+
return 'deno';
|
|
24
|
+
}
|
|
25
|
+
if (typeof EdgeRuntime !== 'undefined') {
|
|
26
|
+
return 'edge';
|
|
27
|
+
}
|
|
28
|
+
if (
|
|
29
|
+
Object.prototype.toString.call(
|
|
30
|
+
typeof (globalThis as any).process !== 'undefined' ? (globalThis as any).process : 0,
|
|
31
|
+
) === '[object process]'
|
|
32
|
+
) {
|
|
33
|
+
return 'node';
|
|
34
|
+
}
|
|
35
|
+
return 'unknown';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare const Deno: any;
|
|
39
|
+
declare const EdgeRuntime: any;
|
|
40
|
+
type Arch = 'x32' | 'x64' | 'arm' | 'arm64' | `other:${string}` | 'unknown';
|
|
41
|
+
type PlatformName =
|
|
42
|
+
| 'MacOS'
|
|
43
|
+
| 'Linux'
|
|
44
|
+
| 'Windows'
|
|
45
|
+
| 'FreeBSD'
|
|
46
|
+
| 'OpenBSD'
|
|
47
|
+
| 'iOS'
|
|
48
|
+
| 'Android'
|
|
49
|
+
| `Other:${string}`
|
|
50
|
+
| 'Unknown';
|
|
51
|
+
type Browser = 'ie' | 'edge' | 'chrome' | 'firefox' | 'safari';
|
|
52
|
+
type PlatformProperties = {
|
|
53
|
+
'X-Stainless-Lang': 'js';
|
|
54
|
+
'X-Stainless-Package-Version': string;
|
|
55
|
+
'X-Stainless-OS': PlatformName;
|
|
56
|
+
'X-Stainless-Arch': Arch;
|
|
57
|
+
'X-Stainless-Runtime': 'node' | 'deno' | 'edge' | `browser:${Browser}` | 'unknown';
|
|
58
|
+
'X-Stainless-Runtime-Version': string;
|
|
59
|
+
};
|
|
60
|
+
const getPlatformProperties = (): PlatformProperties => {
|
|
61
|
+
const detectedPlatform = getDetectedPlatform();
|
|
62
|
+
if (detectedPlatform === 'deno') {
|
|
63
|
+
return {
|
|
64
|
+
'X-Stainless-Lang': 'js',
|
|
65
|
+
'X-Stainless-Package-Version': VERSION,
|
|
66
|
+
'X-Stainless-OS': normalizePlatform(Deno.build.os),
|
|
67
|
+
'X-Stainless-Arch': normalizeArch(Deno.build.arch),
|
|
68
|
+
'X-Stainless-Runtime': 'deno',
|
|
69
|
+
'X-Stainless-Runtime-Version':
|
|
70
|
+
typeof Deno.version === 'string' ? Deno.version : Deno.version?.deno ?? 'unknown',
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (typeof EdgeRuntime !== 'undefined') {
|
|
74
|
+
return {
|
|
75
|
+
'X-Stainless-Lang': 'js',
|
|
76
|
+
'X-Stainless-Package-Version': VERSION,
|
|
77
|
+
'X-Stainless-OS': 'Unknown',
|
|
78
|
+
'X-Stainless-Arch': `other:${EdgeRuntime}`,
|
|
79
|
+
'X-Stainless-Runtime': 'edge',
|
|
80
|
+
'X-Stainless-Runtime-Version': (globalThis as any).process.version,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// Check if Node.js
|
|
84
|
+
if (detectedPlatform === 'node') {
|
|
85
|
+
return {
|
|
86
|
+
'X-Stainless-Lang': 'js',
|
|
87
|
+
'X-Stainless-Package-Version': VERSION,
|
|
88
|
+
'X-Stainless-OS': normalizePlatform((globalThis as any).process.platform),
|
|
89
|
+
'X-Stainless-Arch': normalizeArch((globalThis as any).process.arch),
|
|
90
|
+
'X-Stainless-Runtime': 'node',
|
|
91
|
+
'X-Stainless-Runtime-Version': (globalThis as any).process.version,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const browserInfo = getBrowserInfo();
|
|
96
|
+
if (browserInfo) {
|
|
97
|
+
return {
|
|
98
|
+
'X-Stainless-Lang': 'js',
|
|
99
|
+
'X-Stainless-Package-Version': VERSION,
|
|
100
|
+
'X-Stainless-OS': 'Unknown',
|
|
101
|
+
'X-Stainless-Arch': 'unknown',
|
|
102
|
+
'X-Stainless-Runtime': `browser:${browserInfo.browser}`,
|
|
103
|
+
'X-Stainless-Runtime-Version': browserInfo.version,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// TODO add support for Cloudflare workers, etc.
|
|
108
|
+
return {
|
|
109
|
+
'X-Stainless-Lang': 'js',
|
|
110
|
+
'X-Stainless-Package-Version': VERSION,
|
|
111
|
+
'X-Stainless-OS': 'Unknown',
|
|
112
|
+
'X-Stainless-Arch': 'unknown',
|
|
113
|
+
'X-Stainless-Runtime': 'unknown',
|
|
114
|
+
'X-Stainless-Runtime-Version': 'unknown',
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
type BrowserInfo = {
|
|
119
|
+
browser: Browser;
|
|
120
|
+
version: string;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
declare const navigator: { userAgent: string } | undefined;
|
|
124
|
+
|
|
125
|
+
// Note: modified from https://github.com/JS-DevTools/host-environment/blob/b1ab79ecde37db5d6e163c050e54fe7d287d7c92/src/isomorphic.browser.ts
|
|
126
|
+
function getBrowserInfo(): BrowserInfo | null {
|
|
127
|
+
if (typeof navigator === 'undefined' || !navigator) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// NOTE: The order matters here!
|
|
132
|
+
const browserPatterns = [
|
|
133
|
+
{ key: 'edge' as const, pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
134
|
+
{ key: 'ie' as const, pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
135
|
+
{ key: 'ie' as const, pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
136
|
+
{ key: 'chrome' as const, pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
137
|
+
{ key: 'firefox' as const, pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
138
|
+
{ key: 'safari' as const, pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ },
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
// Find the FIRST matching browser
|
|
142
|
+
for (const { key, pattern } of browserPatterns) {
|
|
143
|
+
const match = pattern.exec(navigator.userAgent);
|
|
144
|
+
if (match) {
|
|
145
|
+
const major = match[1] || 0;
|
|
146
|
+
const minor = match[2] || 0;
|
|
147
|
+
const patch = match[3] || 0;
|
|
148
|
+
|
|
149
|
+
return { browser: key, version: `${major}.${minor}.${patch}` };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const normalizeArch = (arch: string): Arch => {
|
|
157
|
+
// Node docs:
|
|
158
|
+
// - https://nodejs.org/api/process.html#processarch
|
|
159
|
+
// Deno docs:
|
|
160
|
+
// - https://doc.deno.land/deno/stable/~/Deno.build
|
|
161
|
+
if (arch === 'x32') return 'x32';
|
|
162
|
+
if (arch === 'x86_64' || arch === 'x64') return 'x64';
|
|
163
|
+
if (arch === 'arm') return 'arm';
|
|
164
|
+
if (arch === 'aarch64' || arch === 'arm64') return 'arm64';
|
|
165
|
+
if (arch) return `other:${arch}`;
|
|
166
|
+
return 'unknown';
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const normalizePlatform = (platform: string): PlatformName => {
|
|
170
|
+
// Node platforms:
|
|
171
|
+
// - https://nodejs.org/api/process.html#processplatform
|
|
172
|
+
// Deno platforms:
|
|
173
|
+
// - https://doc.deno.land/deno/stable/~/Deno.build
|
|
174
|
+
// - https://github.com/denoland/deno/issues/14799
|
|
175
|
+
|
|
176
|
+
platform = platform.toLowerCase();
|
|
177
|
+
|
|
178
|
+
// NOTE: this iOS check is untested and may not work
|
|
179
|
+
// Node does not work natively on IOS, there is a fork at
|
|
180
|
+
// https://github.com/nodejs-mobile/nodejs-mobile
|
|
181
|
+
// however it is unknown at the time of writing how to detect if it is running
|
|
182
|
+
if (platform.includes('ios')) return 'iOS';
|
|
183
|
+
if (platform === 'android') return 'Android';
|
|
184
|
+
if (platform === 'darwin') return 'MacOS';
|
|
185
|
+
if (platform === 'win32') return 'Windows';
|
|
186
|
+
if (platform === 'freebsd') return 'FreeBSD';
|
|
187
|
+
if (platform === 'openbsd') return 'OpenBSD';
|
|
188
|
+
if (platform === 'linux') return 'Linux';
|
|
189
|
+
if (platform) return `Other:${platform}`;
|
|
190
|
+
return 'Unknown';
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
let _platformHeaders: PlatformProperties;
|
|
194
|
+
export const getPlatformHeaders = () => {
|
|
195
|
+
return (_platformHeaders ??= getPlatformProperties());
|
|
196
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export function isAbortError(err: unknown) {
|
|
4
|
+
return (
|
|
5
|
+
typeof err === 'object' &&
|
|
6
|
+
err !== null &&
|
|
7
|
+
// Spec-compliant fetch implementations
|
|
8
|
+
(('name' in err && (err as any).name === 'AbortError') ||
|
|
9
|
+
// Expo fetch
|
|
10
|
+
('message' in err && String((err as any).message).includes('FetchRequestCanceledException')))
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const castToError = (err: any): Error => {
|
|
15
|
+
if (err instanceof Error) return err;
|
|
16
|
+
if (typeof err === 'object' && err !== null) {
|
|
17
|
+
try {
|
|
18
|
+
if (Object.prototype.toString.call(err) === '[object Error]') {
|
|
19
|
+
// @ts-ignore - not all envs have native support for cause yet
|
|
20
|
+
const error = new Error(err.message, err.cause ? { cause: err.cause } : {});
|
|
21
|
+
if (err.stack) error.stack = err.stack;
|
|
22
|
+
// @ts-ignore - not all envs have native support for cause yet
|
|
23
|
+
if (err.cause && !error.cause) error.cause = err.cause;
|
|
24
|
+
if (err.name) error.name = err.name;
|
|
25
|
+
return error;
|
|
26
|
+
}
|
|
27
|
+
} catch {}
|
|
28
|
+
try {
|
|
29
|
+
return new Error(JSON.stringify(err));
|
|
30
|
+
} catch {}
|
|
31
|
+
}
|
|
32
|
+
return new Error(err);
|
|
33
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
type HeaderValue = string | undefined | null;
|
|
4
|
+
export type HeadersLike =
|
|
5
|
+
| Headers
|
|
6
|
+
| readonly [string, HeaderValue][]
|
|
7
|
+
| Record<string, HeaderValue | readonly HeaderValue[]>
|
|
8
|
+
| undefined
|
|
9
|
+
| null
|
|
10
|
+
| NullableHeaders;
|
|
11
|
+
|
|
12
|
+
const brand_privateNullableHeaders = Symbol('brand.privateNullableHeaders');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
* Users can pass explicit nulls to unset default headers. When we parse them
|
|
17
|
+
* into a standard headers type we need to preserve that information.
|
|
18
|
+
*/
|
|
19
|
+
export type NullableHeaders = {
|
|
20
|
+
/** Brand check, prevent users from creating a NullableHeaders. */
|
|
21
|
+
[brand_privateNullableHeaders]: true;
|
|
22
|
+
/** Parsed headers. */
|
|
23
|
+
values: Headers;
|
|
24
|
+
/** Set of lowercase header names explicitly set to null. */
|
|
25
|
+
nulls: Set<string>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const isArray = Array.isArray as (val: unknown) => val is readonly unknown[];
|
|
29
|
+
|
|
30
|
+
function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [string, string | null]> {
|
|
31
|
+
if (!headers) return;
|
|
32
|
+
|
|
33
|
+
if (brand_privateNullableHeaders in headers) {
|
|
34
|
+
const { values, nulls } = headers;
|
|
35
|
+
yield* values.entries();
|
|
36
|
+
for (const name of nulls) {
|
|
37
|
+
yield [name, null];
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let shouldClear = false;
|
|
43
|
+
let iter: Iterable<readonly [string, HeaderValue | readonly HeaderValue[]]>;
|
|
44
|
+
if (headers instanceof Headers) {
|
|
45
|
+
iter = headers.entries();
|
|
46
|
+
} else if (isArray(headers)) {
|
|
47
|
+
iter = headers;
|
|
48
|
+
} else {
|
|
49
|
+
shouldClear = true;
|
|
50
|
+
iter = Object.entries(headers ?? {});
|
|
51
|
+
}
|
|
52
|
+
for (let row of iter) {
|
|
53
|
+
const name = row[0];
|
|
54
|
+
const values = isArray(row[1]) ? row[1] : [row[1]];
|
|
55
|
+
let didClear = false;
|
|
56
|
+
for (const value of values) {
|
|
57
|
+
if (value === undefined) continue;
|
|
58
|
+
|
|
59
|
+
// Objects keys always overwrite older headers, they never append.
|
|
60
|
+
// Yield a null to clear the header before adding the new values.
|
|
61
|
+
if (shouldClear && !didClear) {
|
|
62
|
+
didClear = true;
|
|
63
|
+
yield [name, null];
|
|
64
|
+
}
|
|
65
|
+
yield [name, value];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const buildHeaders = (newHeaders: HeadersLike[]): NullableHeaders => {
|
|
71
|
+
const targetHeaders = new Headers();
|
|
72
|
+
const nullHeaders = new Set<string>();
|
|
73
|
+
const seenHeaders = new Set<string>();
|
|
74
|
+
for (const headers of newHeaders) {
|
|
75
|
+
for (const [name, value] of iterateHeaders(headers)) {
|
|
76
|
+
const lowerName = name.toLowerCase();
|
|
77
|
+
if (!seenHeaders.has(lowerName)) {
|
|
78
|
+
targetHeaders.delete(name);
|
|
79
|
+
seenHeaders.add(lowerName);
|
|
80
|
+
}
|
|
81
|
+
if (value === null) {
|
|
82
|
+
targetHeaders.delete(name);
|
|
83
|
+
nullHeaders.add(lowerName);
|
|
84
|
+
} else {
|
|
85
|
+
targetHeaders.append(name, value);
|
|
86
|
+
nullHeaders.delete(lowerName);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const isEmptyHeaders = (headers: HeadersLike) => {
|
|
94
|
+
for (const _ of iterateHeaders(headers)) return false;
|
|
95
|
+
return true;
|
|
96
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import type { FinalRequestOptions } from './request-options';
|
|
4
|
+
import { type NirvanaLabs } from '../client';
|
|
5
|
+
import { formatRequestDetails, loggerFor } from './utils/log';
|
|
6
|
+
|
|
7
|
+
export type APIResponseProps = {
|
|
8
|
+
response: Response;
|
|
9
|
+
options: FinalRequestOptions;
|
|
10
|
+
controller: AbortController;
|
|
11
|
+
requestLogID: string;
|
|
12
|
+
retryOfRequestLogID: string | undefined;
|
|
13
|
+
startTime: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export async function defaultParseResponse<T>(client: NirvanaLabs, props: APIResponseProps): Promise<T> {
|
|
17
|
+
const { response, requestLogID, retryOfRequestLogID, startTime } = props;
|
|
18
|
+
const body = await (async () => {
|
|
19
|
+
// fetch refuses to read the body when the status code is 204.
|
|
20
|
+
if (response.status === 204) {
|
|
21
|
+
return null as T;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (props.options.__binaryResponse) {
|
|
25
|
+
return response as unknown as T;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const contentType = response.headers.get('content-type');
|
|
29
|
+
const mediaType = contentType?.split(';')[0]?.trim();
|
|
30
|
+
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
31
|
+
if (isJSON) {
|
|
32
|
+
const json = await response.json();
|
|
33
|
+
return json as T;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const text = await response.text();
|
|
37
|
+
return text as unknown as T;
|
|
38
|
+
})();
|
|
39
|
+
loggerFor(client).debug(
|
|
40
|
+
`[${requestLogID}] response parsed`,
|
|
41
|
+
formatRequestDetails({
|
|
42
|
+
retryOfRequestLogID,
|
|
43
|
+
url: response.url,
|
|
44
|
+
status: response.status,
|
|
45
|
+
body,
|
|
46
|
+
durationMs: Date.now() - startTime,
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
return body;
|
|
50
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { NullableHeaders } from './headers';
|
|
4
|
+
|
|
5
|
+
import type { BodyInit } from './builtin-types';
|
|
6
|
+
import type { HTTPMethod, MergedRequestInit } from './types';
|
|
7
|
+
import { type HeadersLike } from './headers';
|
|
8
|
+
|
|
9
|
+
export type FinalRequestOptions = RequestOptions & { method: HTTPMethod; path: string };
|
|
10
|
+
|
|
11
|
+
export type RequestOptions = {
|
|
12
|
+
method?: HTTPMethod;
|
|
13
|
+
path?: string;
|
|
14
|
+
query?: object | undefined | null;
|
|
15
|
+
body?: unknown;
|
|
16
|
+
headers?: HeadersLike;
|
|
17
|
+
maxRetries?: number;
|
|
18
|
+
stream?: boolean | undefined;
|
|
19
|
+
timeout?: number;
|
|
20
|
+
fetchOptions?: MergedRequestInit;
|
|
21
|
+
signal?: AbortSignal | undefined | null;
|
|
22
|
+
idempotencyKey?: string;
|
|
23
|
+
|
|
24
|
+
__binaryResponse?: boolean | undefined;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type EncodedContent = { bodyHeaders: HeadersLike; body: BodyInit };
|
|
28
|
+
export type RequestEncoder = (request: { headers: NullableHeaders; body: unknown }) => EncodedContent;
|
|
29
|
+
|
|
30
|
+
export const FallbackEncoder: RequestEncoder = ({ headers, body }) => {
|
|
31
|
+
return {
|
|
32
|
+
bodyHeaders: {
|
|
33
|
+
'content-type': 'application/json',
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(body),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shims for types that we can't always rely on being available globally.
|
|
5
|
+
*
|
|
6
|
+
* Note: these only exist at the type-level, there is no corresponding runtime
|
|
7
|
+
* version for any of these symbols.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* In order to properly access the global `NodeJS` type, if it's available, we
|
|
12
|
+
* need to make use of declaration shadowing. Without this, any checks for the
|
|
13
|
+
* presence of `NodeJS.ReadableStream` will fail.
|
|
14
|
+
*/
|
|
15
|
+
declare namespace NodeJS {
|
|
16
|
+
interface ReadableStream {}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type HasProperties<T> = keyof T extends never ? false : true;
|
|
20
|
+
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
type _ReadableStream<R = any> =
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
HasProperties<NodeJS.ReadableStream> extends true ? NodeJS.ReadableStream<R> : ReadableStream<R>;
|
|
25
|
+
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
declare const _ReadableStream: unknown extends typeof ReadableStream ? never : typeof ReadableStream;
|
|
28
|
+
export { _ReadableStream as ReadableStream };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getBuiltinModule } from './getBuiltinModule';
|
|
2
|
+
|
|
3
|
+
type Crypto = {
|
|
4
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) */
|
|
5
|
+
getRandomValues<T extends ArrayBufferView | null>(array: T): T;
|
|
6
|
+
/**
|
|
7
|
+
* Available only in secure contexts.
|
|
8
|
+
*
|
|
9
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
|
|
10
|
+
*/
|
|
11
|
+
randomUUID?: () => string;
|
|
12
|
+
};
|
|
13
|
+
export let getCrypto: () => Crypto | undefined = function lazyGetCrypto() {
|
|
14
|
+
if (getCrypto !== lazyGetCrypto) return getCrypto();
|
|
15
|
+
const crypto: Crypto = (globalThis as any).crypto || (getBuiltinModule?.('node:crypto') as any)?.webcrypto;
|
|
16
|
+
getCrypto = () => crypto;
|
|
17
|
+
return crypto;
|
|
18
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getBuiltinModule } from './getBuiltinModule';
|
|
2
|
+
|
|
3
|
+
export let getFile = function lazyGetFile(): FileConstructor {
|
|
4
|
+
if (getFile !== lazyGetFile) return getFile();
|
|
5
|
+
// We can drop getBuiltinModule once we no longer support Node < 20.0.0
|
|
6
|
+
const File = (globalThis as any).File ?? (getBuiltinModule?.('node:buffer') as any)?.File;
|
|
7
|
+
if (!File) throw new Error('`File` is not defined as a global, which is required for file uploads.');
|
|
8
|
+
getFile = () => File;
|
|
9
|
+
return File;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type FileConstructor =
|
|
13
|
+
typeof globalThis extends { File: infer fileConstructor } ? fileConstructor : typeof FallbackFile;
|
|
14
|
+
export type File = InstanceType<FileConstructor>;
|
|
15
|
+
|
|
16
|
+
// The infer is to make TS show it as a nice union type,
|
|
17
|
+
// instead of literally `ConstructorParameters<typeof Blob>[0]`
|
|
18
|
+
type FallbackBlobSource = ConstructorParameters<typeof Blob>[0] extends infer T ? T : never;
|
|
19
|
+
/**
|
|
20
|
+
* A [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) provides information about files.
|
|
21
|
+
*/
|
|
22
|
+
declare class FallbackFile extends Blob {
|
|
23
|
+
constructor(sources: FallbackBlobSource, fileName: string, options?: any);
|
|
24
|
+
/**
|
|
25
|
+
* The name of the `File`.
|
|
26
|
+
*/
|
|
27
|
+
readonly name: string;
|
|
28
|
+
/**
|
|
29
|
+
* The last modified date of the `File`.
|
|
30
|
+
*/
|
|
31
|
+
readonly lastModified: number;
|
|
32
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load a Node built-in module. ID may or may not be prefixed by `node:` and
|
|
3
|
+
* will be normalized. If we used static imports then our bundle size would be bloated by
|
|
4
|
+
* injected polyfills, and if we used dynamic require then in addition to bundlers logging warnings,
|
|
5
|
+
* our code would not work when bundled to ESM and run in Node 18.
|
|
6
|
+
* @param {string} id ID of the built-in to be loaded.
|
|
7
|
+
* @returns {object|undefined} exports of the built-in. Undefined if the built-in
|
|
8
|
+
* does not exist.
|
|
9
|
+
*/
|
|
10
|
+
export let getBuiltinModule: null | ((id: string) => object | undefined) = function getBuiltinModuleLazy(
|
|
11
|
+
id: string,
|
|
12
|
+
): object | undefined {
|
|
13
|
+
try {
|
|
14
|
+
if (getBuiltinModule !== getBuiltinModuleLazy) return getBuiltinModule!(id);
|
|
15
|
+
if ((process as any).getBuiltinModule) {
|
|
16
|
+
getBuiltinModule = (process as any).getBuiltinModule;
|
|
17
|
+
} else {
|
|
18
|
+
/* Fallback implementation for Node 18 */
|
|
19
|
+
function createFallbackGetBuiltinModule(BuiltinModule: any) {
|
|
20
|
+
return function getBuiltinModule(id: string): object | undefined {
|
|
21
|
+
id = BuiltinModule.normalizeRequirableId(String(id));
|
|
22
|
+
if (!BuiltinModule.canBeRequiredByUsers(id)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const mod = BuiltinModule.map.get(id);
|
|
26
|
+
mod.compileForPublicLoader();
|
|
27
|
+
return mod.exports;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const magicKey = Math.random() + '';
|
|
31
|
+
let module: { BuiltinModule: any } | undefined;
|
|
32
|
+
let ObjectPrototype: {} = Blob;
|
|
33
|
+
for (let next; (next = Reflect.getPrototypeOf(ObjectPrototype)); ObjectPrototype = next);
|
|
34
|
+
try {
|
|
35
|
+
const kClone = Object.getOwnPropertySymbols(Blob.prototype).find(
|
|
36
|
+
(e) => e.description?.includes('clone'),
|
|
37
|
+
)!;
|
|
38
|
+
Object.defineProperty(ObjectPrototype, magicKey, {
|
|
39
|
+
get() {
|
|
40
|
+
module = this;
|
|
41
|
+
throw null;
|
|
42
|
+
},
|
|
43
|
+
configurable: true,
|
|
44
|
+
});
|
|
45
|
+
structuredClone(
|
|
46
|
+
new (class extends Blob {
|
|
47
|
+
[kClone]() {
|
|
48
|
+
return {
|
|
49
|
+
deserializeInfo: 'internal/bootstrap/realm:' + magicKey,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
})([]),
|
|
53
|
+
);
|
|
54
|
+
} catch {}
|
|
55
|
+
delete (ObjectPrototype as any)[magicKey];
|
|
56
|
+
if (module) {
|
|
57
|
+
getBuiltinModule = createFallbackGetBuiltinModule(module.BuiltinModule);
|
|
58
|
+
} else {
|
|
59
|
+
getBuiltinModule = () => undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return getBuiltinModule!(id);
|
|
63
|
+
} catch {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const getBuiltinModule = null;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This module provides internal shims and utility functions for environments where certain Node.js or global types may not be available.
|
|
5
|
+
*
|
|
6
|
+
* These are used to ensure we can provide a consistent behaviour between different JavaScript environments and good error
|
|
7
|
+
* messages in cases where an environment isn't fully supported.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { type Fetch } from './builtin-types';
|
|
11
|
+
import { type ReadableStream } from './shim-types';
|
|
12
|
+
|
|
13
|
+
export function getDefaultFetch(): Fetch {
|
|
14
|
+
if (typeof fetch !== 'undefined') {
|
|
15
|
+
return fetch as any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
throw new Error(
|
|
19
|
+
'`fetch` is not defined as a global; Either pass `fetch` to the client, `new NirvanaLabs({ fetch })` or polyfill the global, `globalThis.fetch = fetch`',
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type ReadableStreamArgs = ConstructorParameters<typeof ReadableStream>;
|
|
24
|
+
|
|
25
|
+
export function makeReadableStream(...args: ReadableStreamArgs): ReadableStream {
|
|
26
|
+
const ReadableStream = (globalThis as any).ReadableStream;
|
|
27
|
+
if (typeof ReadableStream === 'undefined') {
|
|
28
|
+
// Note: All of the platforms / runtimes we officially support already define
|
|
29
|
+
// `ReadableStream` as a global, so this should only ever be hit on unsupported runtimes.
|
|
30
|
+
throw new Error(
|
|
31
|
+
'`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`',
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return new ReadableStream(...args);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function ReadableStreamFrom<T>(iterable: Iterable<T> | AsyncIterable<T>): ReadableStream<T> {
|
|
39
|
+
let iter: AsyncIterator<T> | Iterator<T> =
|
|
40
|
+
Symbol.asyncIterator in iterable ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
|
|
41
|
+
|
|
42
|
+
return makeReadableStream({
|
|
43
|
+
start() {},
|
|
44
|
+
async pull(controller: any) {
|
|
45
|
+
const { done, value } = await iter.next();
|
|
46
|
+
if (done) {
|
|
47
|
+
controller.close();
|
|
48
|
+
} else {
|
|
49
|
+
controller.enqueue(value);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
async cancel() {
|
|
53
|
+
await iter.return?.();
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Most browsers don't yet have async iterable support for ReadableStream,
|
|
60
|
+
* and Node has a very different way of reading bytes from its "ReadableStream".
|
|
61
|
+
*
|
|
62
|
+
* This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
63
|
+
*/
|
|
64
|
+
export function ReadableStreamToAsyncIterable<T>(stream: any): AsyncIterableIterator<T> {
|
|
65
|
+
if (stream[Symbol.asyncIterator]) return stream;
|
|
66
|
+
|
|
67
|
+
const reader = stream.getReader();
|
|
68
|
+
return {
|
|
69
|
+
async next() {
|
|
70
|
+
try {
|
|
71
|
+
const result = await reader.read();
|
|
72
|
+
if (result?.done) reader.releaseLock(); // release lock when stream becomes closed
|
|
73
|
+
return result;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
reader.releaseLock(); // release lock when stream becomes errored
|
|
76
|
+
throw e;
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
async return() {
|
|
80
|
+
const cancelPromise = reader.cancel();
|
|
81
|
+
reader.releaseLock();
|
|
82
|
+
await cancelPromise;
|
|
83
|
+
return { done: true, value: undefined };
|
|
84
|
+
},
|
|
85
|
+
[Symbol.asyncIterator]() {
|
|
86
|
+
return this;
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Cancels a ReadableStream we don't need to consume.
|
|
93
|
+
* See https://undici.nodejs.org/#/?id=garbage-collection
|
|
94
|
+
*/
|
|
95
|
+
export async function CancelReadableStream(stream: any): Promise<void> {
|
|
96
|
+
if (stream === null || typeof stream !== 'object') return;
|
|
97
|
+
|
|
98
|
+
if (stream[Symbol.asyncIterator]) {
|
|
99
|
+
await stream[Symbol.asyncIterator]().return?.();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const reader = stream.getReader();
|
|
104
|
+
const cancelPromise = reader.cancel();
|
|
105
|
+
reader.releaseLock();
|
|
106
|
+
await cancelPromise;
|
|
107
|
+
}
|