dedalus-cli 0.0.0-stage → 0.8.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/LICENSE +201 -0
- package/README.md +306 -2
- package/SKILL.md +73 -0
- package/api.md +340 -0
- package/dist/cjs/bin.d.ts +3 -0
- package/dist/cjs/bin.d.ts.map +1 -0
- package/dist/cjs/bin.js +7 -0
- package/dist/cjs/bin.js.map +1 -0
- package/dist/cjs/cli/completions.d.ts +6 -0
- package/dist/cjs/cli/completions.d.ts.map +1 -0
- package/dist/cjs/cli/completions.js +11 -0
- package/dist/cjs/cli/completions.js.map +1 -0
- package/dist/cjs/cli/credentials.d.ts +169 -0
- package/dist/cjs/cli/credentials.d.ts.map +1 -0
- package/dist/cjs/cli/credentials.js +630 -0
- package/dist/cjs/cli/credentials.js.map +1 -0
- package/dist/cjs/cli/keychain.d.ts +34 -0
- package/dist/cjs/cli/keychain.d.ts.map +1 -0
- package/dist/cjs/cli/keychain.js +246 -0
- package/dist/cjs/cli/keychain.js.map +1 -0
- package/dist/cjs/cli/list.d.ts +23 -0
- package/dist/cjs/cli/list.d.ts.map +1 -0
- package/dist/cjs/cli/list.js +32 -0
- package/dist/cjs/cli/list.js.map +1 -0
- package/dist/cjs/cli/login.d.ts +137 -0
- package/dist/cjs/cli/login.d.ts.map +1 -0
- package/dist/cjs/cli/login.js +2060 -0
- package/dist/cjs/cli/login.js.map +1 -0
- package/dist/cjs/cli/runtime.d.ts +98 -0
- package/dist/cjs/cli/runtime.d.ts.map +1 -0
- package/dist/cjs/cli/runtime.js +1356 -0
- package/dist/cjs/cli/runtime.js.map +1 -0
- package/dist/cjs/cli/toon.d.ts +6 -0
- package/dist/cjs/cli/toon.d.ts.map +1 -0
- package/dist/cjs/cli/toon.js +165 -0
- package/dist/cjs/cli/toon.js.map +1 -0
- package/dist/cjs/cli/upgrade.d.ts +28 -0
- package/dist/cjs/cli/upgrade.d.ts.map +1 -0
- package/dist/cjs/cli/upgrade.js +1191 -0
- package/dist/cjs/cli/upgrade.js.map +1 -0
- package/dist/cjs/commands/index.d.ts +47 -0
- package/dist/cjs/commands/index.d.ts.map +1 -0
- package/dist/cjs/commands/index.js +1202 -0
- package/dist/cjs/commands/index.js.map +1 -0
- package/dist/cjs/custom/browser-routing.d.ts +4 -0
- package/dist/cjs/custom/browser-routing.d.ts.map +1 -0
- package/dist/cjs/custom/browser-routing.js +51 -0
- package/dist/cjs/custom/browser-routing.js.map +1 -0
- package/dist/cjs/custom/images.d.ts +6 -0
- package/dist/cjs/custom/images.d.ts.map +1 -0
- package/dist/cjs/custom/images.js +74 -0
- package/dist/cjs/custom/images.js.map +1 -0
- package/dist/cjs/custom/machines.d.ts +20 -0
- package/dist/cjs/custom/machines.d.ts.map +1 -0
- package/dist/cjs/custom/machines.js +84 -0
- package/dist/cjs/custom/machines.js.map +1 -0
- package/dist/cjs/custom/ssh-picker.d.ts +19 -0
- package/dist/cjs/custom/ssh-picker.d.ts.map +1 -0
- package/dist/cjs/custom/ssh-picker.js +157 -0
- package/dist/cjs/custom/ssh-picker.js.map +1 -0
- package/dist/cjs/custom/ssh.d.ts +18 -0
- package/dist/cjs/custom/ssh.d.ts.map +1 -0
- package/dist/cjs/custom/ssh.js +152 -0
- package/dist/cjs/custom/ssh.js.map +1 -0
- package/dist/cjs/feedback/bundle.d.ts +41 -0
- package/dist/cjs/feedback/bundle.d.ts.map +1 -0
- package/dist/cjs/feedback/bundle.js +88 -0
- package/dist/cjs/feedback/bundle.js.map +1 -0
- package/dist/cjs/feedback/command.d.ts +6 -0
- package/dist/cjs/feedback/command.d.ts.map +1 -0
- package/dist/cjs/feedback/command.js +100 -0
- package/dist/cjs/feedback/command.js.map +1 -0
- package/dist/cjs/feedback/diagnostics.d.ts +30 -0
- package/dist/cjs/feedback/diagnostics.d.ts.map +1 -0
- package/dist/cjs/feedback/diagnostics.js +278 -0
- package/dist/cjs/feedback/diagnostics.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/sdk/api-promise.d.ts +31 -0
- package/dist/cjs/sdk/api-promise.d.ts.map +1 -0
- package/dist/cjs/sdk/api-promise.js +73 -0
- package/dist/cjs/sdk/api-promise.js.map +1 -0
- package/dist/cjs/sdk/client.d.ts +267 -0
- package/dist/cjs/sdk/client.d.ts.map +1 -0
- package/dist/cjs/sdk/client.js +962 -0
- package/dist/cjs/sdk/client.js.map +1 -0
- package/dist/cjs/sdk/core/api-promise.d.ts +3 -0
- package/dist/cjs/sdk/core/api-promise.d.ts.map +1 -0
- package/dist/cjs/sdk/core/api-promise.js +8 -0
- package/dist/cjs/sdk/core/api-promise.js.map +1 -0
- package/dist/cjs/sdk/core/error.d.ts +46 -0
- package/dist/cjs/sdk/core/error.d.ts.map +1 -0
- package/dist/cjs/sdk/core/error.js +135 -0
- package/dist/cjs/sdk/core/error.js.map +1 -0
- package/dist/cjs/sdk/core/pagination.d.ts +38 -0
- package/dist/cjs/sdk/core/pagination.d.ts.map +1 -0
- package/dist/cjs/sdk/core/pagination.js +98 -0
- package/dist/cjs/sdk/core/pagination.js.map +1 -0
- package/dist/cjs/sdk/core/resource.d.ts +2 -0
- package/dist/cjs/sdk/core/resource.d.ts.map +1 -0
- package/dist/cjs/sdk/core/resource.js +7 -0
- package/dist/cjs/sdk/core/resource.js.map +1 -0
- package/dist/cjs/sdk/core/uploads.d.ts +3 -0
- package/dist/cjs/sdk/core/uploads.d.ts.map +1 -0
- package/dist/cjs/sdk/core/uploads.js +7 -0
- package/dist/cjs/sdk/core/uploads.js.map +1 -0
- package/dist/cjs/sdk/error.d.ts +3 -0
- package/dist/cjs/sdk/error.d.ts.map +1 -0
- package/dist/cjs/sdk/error.js +20 -0
- package/dist/cjs/sdk/error.js.map +1 -0
- package/dist/cjs/sdk/helpers/images.d.ts +31 -0
- package/dist/cjs/sdk/helpers/images.d.ts.map +1 -0
- package/dist/cjs/sdk/helpers/images.js +195 -0
- package/dist/cjs/sdk/helpers/images.js.map +1 -0
- package/dist/cjs/sdk/index.d.ts +7 -0
- package/dist/cjs/sdk/index.d.ts.map +1 -0
- package/dist/cjs/sdk/index.js +29 -0
- package/dist/cjs/sdk/index.js.map +1 -0
- package/dist/cjs/sdk/internal/builtin-types.d.ts +73 -0
- package/dist/cjs/sdk/internal/builtin-types.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/builtin-types.js +4 -0
- package/dist/cjs/sdk/internal/builtin-types.js.map +1 -0
- package/dist/cjs/sdk/internal/detect-platform.d.ts +15 -0
- package/dist/cjs/sdk/internal/detect-platform.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/detect-platform.js +185 -0
- package/dist/cjs/sdk/internal/detect-platform.js.map +1 -0
- package/dist/cjs/sdk/internal/errors.d.ts +3 -0
- package/dist/cjs/sdk/internal/errors.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/errors.js +41 -0
- package/dist/cjs/sdk/internal/errors.js.map +1 -0
- package/dist/cjs/sdk/internal/headers.d.ts +43 -0
- package/dist/cjs/sdk/internal/headers.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/headers.js +142 -0
- package/dist/cjs/sdk/internal/headers.js.map +1 -0
- package/dist/cjs/sdk/internal/parse.d.ts +3 -0
- package/dist/cjs/sdk/internal/parse.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/parse.js +7 -0
- package/dist/cjs/sdk/internal/parse.js.map +1 -0
- package/dist/cjs/sdk/internal/qs/formats.d.ts +7 -0
- package/dist/cjs/sdk/internal/qs/formats.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/qs/formats.js +13 -0
- package/dist/cjs/sdk/internal/qs/formats.js.map +1 -0
- package/dist/cjs/sdk/internal/qs/index.d.ts +10 -0
- package/dist/cjs/sdk/internal/qs/index.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/qs/index.js +14 -0
- package/dist/cjs/sdk/internal/qs/index.js.map +1 -0
- package/dist/cjs/sdk/internal/qs/stringify.d.ts +3 -0
- package/dist/cjs/sdk/internal/qs/stringify.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/qs/stringify.js +278 -0
- package/dist/cjs/sdk/internal/qs/stringify.js.map +1 -0
- package/dist/cjs/sdk/internal/qs/types.d.ts +57 -0
- package/dist/cjs/sdk/internal/qs/types.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/qs/types.js +3 -0
- package/dist/cjs/sdk/internal/qs/types.js.map +1 -0
- package/dist/cjs/sdk/internal/qs/utils.d.ts +15 -0
- package/dist/cjs/sdk/internal/qs/utils.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/qs/utils.js +230 -0
- package/dist/cjs/sdk/internal/qs/utils.js.map +1 -0
- package/dist/cjs/sdk/internal/request-options.d.ts +33 -0
- package/dist/cjs/sdk/internal/request-options.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/request-options.js +15 -0
- package/dist/cjs/sdk/internal/request-options.js.map +1 -0
- package/dist/cjs/sdk/internal/shim-types.d.ts +17 -0
- package/dist/cjs/sdk/internal/shim-types.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/shim-types.js +4 -0
- package/dist/cjs/sdk/internal/shim-types.js.map +1 -0
- package/dist/cjs/sdk/internal/shims.d.ts +26 -0
- package/dist/cjs/sdk/internal/shims.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/shims.js +92 -0
- package/dist/cjs/sdk/internal/shims.js.map +1 -0
- package/dist/cjs/sdk/internal/to-file.d.ts +45 -0
- package/dist/cjs/sdk/internal/to-file.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/to-file.js +91 -0
- package/dist/cjs/sdk/internal/to-file.js.map +1 -0
- package/dist/cjs/sdk/internal/types.d.ts +63 -0
- package/dist/cjs/sdk/internal/types.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/types.js +4 -0
- package/dist/cjs/sdk/internal/types.js.map +1 -0
- package/dist/cjs/sdk/internal/uploads.d.ts +42 -0
- package/dist/cjs/sdk/internal/uploads.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/uploads.js +158 -0
- package/dist/cjs/sdk/internal/uploads.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/base64.d.ts +3 -0
- package/dist/cjs/sdk/internal/utils/base64.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/base64.js +38 -0
- package/dist/cjs/sdk/internal/utils/base64.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/body.d.ts +40 -0
- package/dist/cjs/sdk/internal/utils/body.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/body.js +148 -0
- package/dist/cjs/sdk/internal/utils/body.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/bytes.d.ts +4 -0
- package/dist/cjs/sdk/internal/utils/bytes.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/bytes.js +31 -0
- package/dist/cjs/sdk/internal/utils/bytes.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/env.d.ts +9 -0
- package/dist/cjs/sdk/internal/utils/env.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/env.js +22 -0
- package/dist/cjs/sdk/internal/utils/env.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/log.d.ts +52 -0
- package/dist/cjs/sdk/internal/utils/log.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/log.js +413 -0
- package/dist/cjs/sdk/internal/utils/log.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/path.d.ts +41 -0
- package/dist/cjs/sdk/internal/utils/path.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/path.js +115 -0
- package/dist/cjs/sdk/internal/utils/path.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/query-string.d.ts +21 -0
- package/dist/cjs/sdk/internal/utils/query-string.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/query-string.js +128 -0
- package/dist/cjs/sdk/internal/utils/query-string.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/query.d.ts +2 -0
- package/dist/cjs/sdk/internal/utils/query.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/query.js +12 -0
- package/dist/cjs/sdk/internal/utils/query.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/sleep.d.ts +2 -0
- package/dist/cjs/sdk/internal/utils/sleep.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/sleep.js +7 -0
- package/dist/cjs/sdk/internal/utils/sleep.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/uuid.d.ts +5 -0
- package/dist/cjs/sdk/internal/utils/uuid.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/uuid.js +19 -0
- package/dist/cjs/sdk/internal/utils/uuid.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/uuid7.d.ts +6 -0
- package/dist/cjs/sdk/internal/utils/uuid7.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/uuid7.js +35 -0
- package/dist/cjs/sdk/internal/utils/uuid7.js.map +1 -0
- package/dist/cjs/sdk/internal/utils/values.d.ts +18 -0
- package/dist/cjs/sdk/internal/utils/values.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils/values.js +112 -0
- package/dist/cjs/sdk/internal/utils/values.js.map +1 -0
- package/dist/cjs/sdk/internal/utils.d.ts +8 -0
- package/dist/cjs/sdk/internal/utils.d.ts.map +1 -0
- package/dist/cjs/sdk/internal/utils.js +25 -0
- package/dist/cjs/sdk/internal/utils.js.map +1 -0
- package/dist/cjs/sdk/pagination.d.ts +3 -0
- package/dist/cjs/sdk/pagination.d.ts.map +1 -0
- package/dist/cjs/sdk/pagination.js +20 -0
- package/dist/cjs/sdk/pagination.js.map +1 -0
- package/dist/cjs/sdk/resource.d.ts +6 -0
- package/dist/cjs/sdk/resource.d.ts.map +1 -0
- package/dist/cjs/sdk/resource.js +12 -0
- package/dist/cjs/sdk/resource.js.map +1 -0
- package/dist/cjs/sdk/resources/images/images.d.ts +202 -0
- package/dist/cjs/sdk/resources/images/images.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/images/images.js +139 -0
- package/dist/cjs/sdk/resources/images/images.js.map +1 -0
- package/dist/cjs/sdk/resources/images/index.d.ts +5 -0
- package/dist/cjs/sdk/resources/images/index.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/images/index.js +9 -0
- package/dist/cjs/sdk/resources/images/index.js.map +1 -0
- package/dist/cjs/sdk/resources/images/uploads.d.ts +50 -0
- package/dist/cjs/sdk/resources/images/uploads.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/images/uploads.js +28 -0
- package/dist/cjs/sdk/resources/images/uploads.js.map +1 -0
- package/dist/cjs/sdk/resources/images.d.ts +2 -0
- package/dist/cjs/sdk/resources/images.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/images.js +19 -0
- package/dist/cjs/sdk/resources/images.js.map +1 -0
- package/dist/cjs/sdk/resources/index.d.ts +6 -0
- package/dist/cjs/sdk/resources/index.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/index.js +11 -0
- package/dist/cjs/sdk/resources/index.js.map +1 -0
- package/dist/cjs/sdk/resources/machines/autoresizing.d.ts +116 -0
- package/dist/cjs/sdk/resources/machines/autoresizing.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/machines/autoresizing.js +46 -0
- package/dist/cjs/sdk/resources/machines/autoresizing.js.map +1 -0
- package/dist/cjs/sdk/resources/machines/executions/executions.d.ts +341 -0
- package/dist/cjs/sdk/resources/machines/executions/executions.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/machines/executions/executions.js +161 -0
- package/dist/cjs/sdk/resources/machines/executions/executions.js.map +1 -0
- package/dist/cjs/sdk/resources/machines/executions/index.d.ts +5 -0
- package/dist/cjs/sdk/resources/machines/executions/index.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/machines/executions/index.js +9 -0
- package/dist/cjs/sdk/resources/machines/executions/index.js.map +1 -0
- package/dist/cjs/sdk/resources/machines/executions/logs.d.ts +103 -0
- package/dist/cjs/sdk/resources/machines/executions/logs.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/machines/executions/logs.js +48 -0
- package/dist/cjs/sdk/resources/machines/executions/logs.js.map +1 -0
- package/dist/cjs/sdk/resources/machines/executions.d.ts +2 -0
- package/dist/cjs/sdk/resources/machines/executions.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/machines/executions.js +19 -0
- package/dist/cjs/sdk/resources/machines/executions.js.map +1 -0
- package/dist/cjs/sdk/resources/machines/index.d.ts +9 -0
- package/dist/cjs/sdk/resources/machines/index.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/machines/index.js +13 -0
- package/dist/cjs/sdk/resources/machines/index.js.map +1 -0
- package/dist/cjs/sdk/resources/machines/machines.d.ts +497 -0
- package/dist/cjs/sdk/resources/machines/machines.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/machines/machines.js +220 -0
- package/dist/cjs/sdk/resources/machines/machines.js.map +1 -0
- package/dist/cjs/sdk/resources/machines/ssh.d.ts +175 -0
- package/dist/cjs/sdk/resources/machines/ssh.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/machines/ssh.js +89 -0
- package/dist/cjs/sdk/resources/machines/ssh.js.map +1 -0
- package/dist/cjs/sdk/resources/machines.d.ts +2 -0
- package/dist/cjs/sdk/resources/machines.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/machines.js +19 -0
- package/dist/cjs/sdk/resources/machines.js.map +1 -0
- package/dist/cjs/sdk/resources/organization/autoresizing.d.ts +87 -0
- package/dist/cjs/sdk/resources/organization/autoresizing.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/organization/autoresizing.js +38 -0
- package/dist/cjs/sdk/resources/organization/autoresizing.js.map +1 -0
- package/dist/cjs/sdk/resources/organization/index.d.ts +4 -0
- package/dist/cjs/sdk/resources/organization/index.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/organization/index.js +9 -0
- package/dist/cjs/sdk/resources/organization/index.js.map +1 -0
- package/dist/cjs/sdk/resources/organization/organization.d.ts +10 -0
- package/dist/cjs/sdk/resources/organization/organization.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/organization/organization.js +46 -0
- package/dist/cjs/sdk/resources/organization/organization.js.map +1 -0
- package/dist/cjs/sdk/resources/organization.d.ts +2 -0
- package/dist/cjs/sdk/resources/organization.d.ts.map +1 -0
- package/dist/cjs/sdk/resources/organization.js +19 -0
- package/dist/cjs/sdk/resources/organization.js.map +1 -0
- package/dist/cjs/sdk/resources.d.ts +3 -0
- package/dist/cjs/sdk/resources.d.ts.map +1 -0
- package/dist/cjs/sdk/resources.js +9 -0
- package/dist/cjs/sdk/resources.js.map +1 -0
- package/dist/cjs/sdk/uploads.d.ts +2 -0
- package/dist/cjs/sdk/uploads.d.ts.map +1 -0
- package/dist/cjs/sdk/uploads.js +7 -0
- package/dist/cjs/sdk/uploads.js.map +1 -0
- package/dist/cjs/sdk/version.d.ts +2 -0
- package/dist/cjs/sdk/version.d.ts.map +1 -0
- package/dist/cjs/sdk/version.js +6 -0
- package/dist/cjs/sdk/version.js.map +1 -0
- package/dist/esm/bin.d.ts +3 -0
- package/dist/esm/bin.d.ts.map +1 -0
- package/dist/esm/bin.js +5 -0
- package/dist/esm/bin.js.map +1 -0
- package/dist/esm/cli/completions.d.ts +6 -0
- package/dist/esm/cli/completions.d.ts.map +1 -0
- package/dist/esm/cli/completions.js +8 -0
- package/dist/esm/cli/completions.js.map +1 -0
- package/dist/esm/cli/credentials.d.ts +169 -0
- package/dist/esm/cli/credentials.d.ts.map +1 -0
- package/dist/esm/cli/credentials.js +614 -0
- package/dist/esm/cli/credentials.js.map +1 -0
- package/dist/esm/cli/keychain.d.ts +34 -0
- package/dist/esm/cli/keychain.d.ts.map +1 -0
- package/dist/esm/cli/keychain.js +237 -0
- package/dist/esm/cli/keychain.js.map +1 -0
- package/dist/esm/cli/list.d.ts +23 -0
- package/dist/esm/cli/list.d.ts.map +1 -0
- package/dist/esm/cli/list.js +27 -0
- package/dist/esm/cli/list.js.map +1 -0
- package/dist/esm/cli/login.d.ts +137 -0
- package/dist/esm/cli/login.d.ts.map +1 -0
- package/dist/esm/cli/login.js +2053 -0
- package/dist/esm/cli/login.js.map +1 -0
- package/dist/esm/cli/runtime.d.ts +98 -0
- package/dist/esm/cli/runtime.d.ts.map +1 -0
- package/dist/esm/cli/runtime.js +1345 -0
- package/dist/esm/cli/runtime.js.map +1 -0
- package/dist/esm/cli/toon.d.ts +6 -0
- package/dist/esm/cli/toon.d.ts.map +1 -0
- package/dist/esm/cli/toon.js +161 -0
- package/dist/esm/cli/toon.js.map +1 -0
- package/dist/esm/cli/upgrade.d.ts +28 -0
- package/dist/esm/cli/upgrade.d.ts.map +1 -0
- package/dist/esm/cli/upgrade.js +1186 -0
- package/dist/esm/cli/upgrade.js.map +1 -0
- package/dist/esm/commands/index.d.ts +47 -0
- package/dist/esm/commands/index.d.ts.map +1 -0
- package/dist/esm/commands/index.js +1195 -0
- package/dist/esm/commands/index.js.map +1 -0
- package/dist/esm/custom/browser-routing.d.ts +4 -0
- package/dist/esm/custom/browser-routing.d.ts.map +1 -0
- package/dist/esm/custom/browser-routing.js +47 -0
- package/dist/esm/custom/browser-routing.js.map +1 -0
- package/dist/esm/custom/images.d.ts +6 -0
- package/dist/esm/custom/images.d.ts.map +1 -0
- package/dist/esm/custom/images.js +68 -0
- package/dist/esm/custom/images.js.map +1 -0
- package/dist/esm/custom/machines.d.ts +20 -0
- package/dist/esm/custom/machines.d.ts.map +1 -0
- package/dist/esm/custom/machines.js +76 -0
- package/dist/esm/custom/machines.js.map +1 -0
- package/dist/esm/custom/ssh-picker.d.ts +19 -0
- package/dist/esm/custom/ssh-picker.d.ts.map +1 -0
- package/dist/esm/custom/ssh-picker.js +149 -0
- package/dist/esm/custom/ssh-picker.js.map +1 -0
- package/dist/esm/custom/ssh.d.ts +18 -0
- package/dist/esm/custom/ssh.d.ts.map +1 -0
- package/dist/esm/custom/ssh.js +147 -0
- package/dist/esm/custom/ssh.js.map +1 -0
- package/dist/esm/feedback/bundle.d.ts +41 -0
- package/dist/esm/feedback/bundle.d.ts.map +1 -0
- package/dist/esm/feedback/bundle.js +83 -0
- package/dist/esm/feedback/bundle.js.map +1 -0
- package/dist/esm/feedback/command.d.ts +6 -0
- package/dist/esm/feedback/command.d.ts.map +1 -0
- package/dist/esm/feedback/command.js +92 -0
- package/dist/esm/feedback/command.js.map +1 -0
- package/dist/esm/feedback/diagnostics.d.ts +30 -0
- package/dist/esm/feedback/diagnostics.d.ts.map +1 -0
- package/dist/esm/feedback/diagnostics.js +270 -0
- package/dist/esm/feedback/diagnostics.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/sdk/api-promise.d.ts +31 -0
- package/dist/esm/sdk/api-promise.d.ts.map +1 -0
- package/dist/esm/sdk/api-promise.js +68 -0
- package/dist/esm/sdk/api-promise.js.map +1 -0
- package/dist/esm/sdk/client.d.ts +267 -0
- package/dist/esm/sdk/client.d.ts.map +1 -0
- package/dist/esm/sdk/client.js +925 -0
- package/dist/esm/sdk/client.js.map +1 -0
- package/dist/esm/sdk/core/api-promise.d.ts +3 -0
- package/dist/esm/sdk/core/api-promise.d.ts.map +1 -0
- package/dist/esm/sdk/core/api-promise.js +3 -0
- package/dist/esm/sdk/core/api-promise.js.map +1 -0
- package/dist/esm/sdk/core/error.d.ts +46 -0
- package/dist/esm/sdk/core/error.d.ts.map +1 -0
- package/dist/esm/sdk/core/error.js +119 -0
- package/dist/esm/sdk/core/error.js.map +1 -0
- package/dist/esm/sdk/core/pagination.d.ts +38 -0
- package/dist/esm/sdk/core/pagination.d.ts.map +1 -0
- package/dist/esm/sdk/core/pagination.js +92 -0
- package/dist/esm/sdk/core/pagination.js.map +1 -0
- package/dist/esm/sdk/core/resource.d.ts +2 -0
- package/dist/esm/sdk/core/resource.d.ts.map +1 -0
- package/dist/esm/sdk/core/resource.js +3 -0
- package/dist/esm/sdk/core/resource.js.map +1 -0
- package/dist/esm/sdk/core/uploads.d.ts +3 -0
- package/dist/esm/sdk/core/uploads.d.ts.map +1 -0
- package/dist/esm/sdk/core/uploads.js +3 -0
- package/dist/esm/sdk/core/uploads.js.map +1 -0
- package/dist/esm/sdk/error.d.ts +3 -0
- package/dist/esm/sdk/error.d.ts.map +1 -0
- package/dist/esm/sdk/error.js +4 -0
- package/dist/esm/sdk/error.js.map +1 -0
- package/dist/esm/sdk/helpers/images.d.ts +31 -0
- package/dist/esm/sdk/helpers/images.d.ts.map +1 -0
- package/dist/esm/sdk/helpers/images.js +189 -0
- package/dist/esm/sdk/helpers/images.js.map +1 -0
- package/dist/esm/sdk/index.d.ts +7 -0
- package/dist/esm/sdk/index.d.ts.map +1 -0
- package/dist/esm/sdk/index.js +8 -0
- package/dist/esm/sdk/index.js.map +1 -0
- package/dist/esm/sdk/internal/builtin-types.d.ts +73 -0
- package/dist/esm/sdk/internal/builtin-types.d.ts.map +1 -0
- package/dist/esm/sdk/internal/builtin-types.js +3 -0
- package/dist/esm/sdk/internal/builtin-types.js.map +1 -0
- package/dist/esm/sdk/internal/detect-platform.d.ts +15 -0
- package/dist/esm/sdk/internal/detect-platform.d.ts.map +1 -0
- package/dist/esm/sdk/internal/detect-platform.js +180 -0
- package/dist/esm/sdk/internal/detect-platform.js.map +1 -0
- package/dist/esm/sdk/internal/errors.d.ts +3 -0
- package/dist/esm/sdk/internal/errors.d.ts.map +1 -0
- package/dist/esm/sdk/internal/errors.js +36 -0
- package/dist/esm/sdk/internal/errors.js.map +1 -0
- package/dist/esm/sdk/internal/headers.d.ts +43 -0
- package/dist/esm/sdk/internal/headers.d.ts.map +1 -0
- package/dist/esm/sdk/internal/headers.js +133 -0
- package/dist/esm/sdk/internal/headers.js.map +1 -0
- package/dist/esm/sdk/internal/parse.d.ts +3 -0
- package/dist/esm/sdk/internal/parse.d.ts.map +1 -0
- package/dist/esm/sdk/internal/parse.js +3 -0
- package/dist/esm/sdk/internal/parse.js.map +1 -0
- package/dist/esm/sdk/internal/qs/formats.d.ts +7 -0
- package/dist/esm/sdk/internal/qs/formats.d.ts.map +1 -0
- package/dist/esm/sdk/internal/qs/formats.js +9 -0
- package/dist/esm/sdk/internal/qs/formats.js.map +1 -0
- package/dist/esm/sdk/internal/qs/index.d.ts +10 -0
- package/dist/esm/sdk/internal/qs/index.d.ts.map +1 -0
- package/dist/esm/sdk/internal/qs/index.js +10 -0
- package/dist/esm/sdk/internal/qs/index.js.map +1 -0
- package/dist/esm/sdk/internal/qs/stringify.d.ts +3 -0
- package/dist/esm/sdk/internal/qs/stringify.d.ts.map +1 -0
- package/dist/esm/sdk/internal/qs/stringify.js +275 -0
- package/dist/esm/sdk/internal/qs/stringify.js.map +1 -0
- package/dist/esm/sdk/internal/qs/types.d.ts +57 -0
- package/dist/esm/sdk/internal/qs/types.d.ts.map +1 -0
- package/dist/esm/sdk/internal/qs/types.js +2 -0
- package/dist/esm/sdk/internal/qs/types.js.map +1 -0
- package/dist/esm/sdk/internal/qs/utils.d.ts +15 -0
- package/dist/esm/sdk/internal/qs/utils.d.ts.map +1 -0
- package/dist/esm/sdk/internal/qs/utils.js +217 -0
- package/dist/esm/sdk/internal/qs/utils.js.map +1 -0
- package/dist/esm/sdk/internal/request-options.d.ts +33 -0
- package/dist/esm/sdk/internal/request-options.d.ts.map +1 -0
- package/dist/esm/sdk/internal/request-options.js +11 -0
- package/dist/esm/sdk/internal/request-options.js.map +1 -0
- package/dist/esm/sdk/internal/shim-types.d.ts +17 -0
- package/dist/esm/sdk/internal/shim-types.d.ts.map +1 -0
- package/dist/esm/sdk/internal/shim-types.js +3 -0
- package/dist/esm/sdk/internal/shim-types.js.map +1 -0
- package/dist/esm/sdk/internal/shims.d.ts +26 -0
- package/dist/esm/sdk/internal/shims.d.ts.map +1 -0
- package/dist/esm/sdk/internal/shims.js +85 -0
- package/dist/esm/sdk/internal/shims.js.map +1 -0
- package/dist/esm/sdk/internal/to-file.d.ts +45 -0
- package/dist/esm/sdk/internal/to-file.d.ts.map +1 -0
- package/dist/esm/sdk/internal/to-file.js +88 -0
- package/dist/esm/sdk/internal/to-file.js.map +1 -0
- package/dist/esm/sdk/internal/types.d.ts +63 -0
- package/dist/esm/sdk/internal/types.d.ts.map +1 -0
- package/dist/esm/sdk/internal/types.js +3 -0
- package/dist/esm/sdk/internal/types.js.map +1 -0
- package/dist/esm/sdk/internal/uploads.d.ts +42 -0
- package/dist/esm/sdk/internal/uploads.d.ts.map +1 -0
- package/dist/esm/sdk/internal/uploads.js +148 -0
- package/dist/esm/sdk/internal/uploads.js.map +1 -0
- package/dist/esm/sdk/internal/utils/base64.d.ts +3 -0
- package/dist/esm/sdk/internal/utils/base64.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/base64.js +33 -0
- package/dist/esm/sdk/internal/utils/base64.js.map +1 -0
- package/dist/esm/sdk/internal/utils/body.d.ts +40 -0
- package/dist/esm/sdk/internal/utils/body.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/body.js +140 -0
- package/dist/esm/sdk/internal/utils/body.js.map +1 -0
- package/dist/esm/sdk/internal/utils/bytes.d.ts +4 -0
- package/dist/esm/sdk/internal/utils/bytes.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/bytes.js +26 -0
- package/dist/esm/sdk/internal/utils/bytes.js.map +1 -0
- package/dist/esm/sdk/internal/utils/env.d.ts +9 -0
- package/dist/esm/sdk/internal/utils/env.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/env.js +18 -0
- package/dist/esm/sdk/internal/utils/env.js.map +1 -0
- package/dist/esm/sdk/internal/utils/log.d.ts +52 -0
- package/dist/esm/sdk/internal/utils/log.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/log.js +405 -0
- package/dist/esm/sdk/internal/utils/log.js.map +1 -0
- package/dist/esm/sdk/internal/utils/path.d.ts +41 -0
- package/dist/esm/sdk/internal/utils/path.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/path.js +108 -0
- package/dist/esm/sdk/internal/utils/path.js.map +1 -0
- package/dist/esm/sdk/internal/utils/query-string.d.ts +21 -0
- package/dist/esm/sdk/internal/utils/query-string.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/query-string.js +125 -0
- package/dist/esm/sdk/internal/utils/query-string.js.map +1 -0
- package/dist/esm/sdk/internal/utils/query.d.ts +2 -0
- package/dist/esm/sdk/internal/utils/query.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/query.js +9 -0
- package/dist/esm/sdk/internal/utils/query.js.map +1 -0
- package/dist/esm/sdk/internal/utils/sleep.d.ts +2 -0
- package/dist/esm/sdk/internal/utils/sleep.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/sleep.js +3 -0
- package/dist/esm/sdk/internal/utils/sleep.js.map +1 -0
- package/dist/esm/sdk/internal/utils/uuid.d.ts +5 -0
- package/dist/esm/sdk/internal/utils/uuid.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/uuid.js +15 -0
- package/dist/esm/sdk/internal/utils/uuid.js.map +1 -0
- package/dist/esm/sdk/internal/utils/uuid7.d.ts +6 -0
- package/dist/esm/sdk/internal/utils/uuid7.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/uuid7.js +31 -0
- package/dist/esm/sdk/internal/utils/uuid7.js.map +1 -0
- package/dist/esm/sdk/internal/utils/values.d.ts +18 -0
- package/dist/esm/sdk/internal/utils/values.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils/values.js +94 -0
- package/dist/esm/sdk/internal/utils/values.js.map +1 -0
- package/dist/esm/sdk/internal/utils.d.ts +8 -0
- package/dist/esm/sdk/internal/utils.d.ts.map +1 -0
- package/dist/esm/sdk/internal/utils.js +9 -0
- package/dist/esm/sdk/internal/utils.js.map +1 -0
- package/dist/esm/sdk/pagination.d.ts +3 -0
- package/dist/esm/sdk/pagination.d.ts.map +1 -0
- package/dist/esm/sdk/pagination.js +4 -0
- package/dist/esm/sdk/pagination.js.map +1 -0
- package/dist/esm/sdk/resource.d.ts +6 -0
- package/dist/esm/sdk/resource.d.ts.map +1 -0
- package/dist/esm/sdk/resource.js +8 -0
- package/dist/esm/sdk/resource.js.map +1 -0
- package/dist/esm/sdk/resources/images/images.d.ts +202 -0
- package/dist/esm/sdk/resources/images/images.d.ts.map +1 -0
- package/dist/esm/sdk/resources/images/images.js +102 -0
- package/dist/esm/sdk/resources/images/images.js.map +1 -0
- package/dist/esm/sdk/resources/images/index.d.ts +5 -0
- package/dist/esm/sdk/resources/images/index.d.ts.map +1 -0
- package/dist/esm/sdk/resources/images/index.js +4 -0
- package/dist/esm/sdk/resources/images/index.js.map +1 -0
- package/dist/esm/sdk/resources/images/uploads.d.ts +50 -0
- package/dist/esm/sdk/resources/images/uploads.d.ts.map +1 -0
- package/dist/esm/sdk/resources/images/uploads.js +24 -0
- package/dist/esm/sdk/resources/images/uploads.js.map +1 -0
- package/dist/esm/sdk/resources/images.d.ts +2 -0
- package/dist/esm/sdk/resources/images.d.ts.map +1 -0
- package/dist/esm/sdk/resources/images.js +3 -0
- package/dist/esm/sdk/resources/images.js.map +1 -0
- package/dist/esm/sdk/resources/index.d.ts +6 -0
- package/dist/esm/sdk/resources/index.d.ts.map +1 -0
- package/dist/esm/sdk/resources/index.js +5 -0
- package/dist/esm/sdk/resources/index.js.map +1 -0
- package/dist/esm/sdk/resources/machines/autoresizing.d.ts +116 -0
- package/dist/esm/sdk/resources/machines/autoresizing.d.ts.map +1 -0
- package/dist/esm/sdk/resources/machines/autoresizing.js +42 -0
- package/dist/esm/sdk/resources/machines/autoresizing.js.map +1 -0
- package/dist/esm/sdk/resources/machines/executions/executions.d.ts +341 -0
- package/dist/esm/sdk/resources/machines/executions/executions.d.ts.map +1 -0
- package/dist/esm/sdk/resources/machines/executions/executions.js +124 -0
- package/dist/esm/sdk/resources/machines/executions/executions.js.map +1 -0
- package/dist/esm/sdk/resources/machines/executions/index.d.ts +5 -0
- package/dist/esm/sdk/resources/machines/executions/index.d.ts.map +1 -0
- package/dist/esm/sdk/resources/machines/executions/index.js +4 -0
- package/dist/esm/sdk/resources/machines/executions/index.js.map +1 -0
- package/dist/esm/sdk/resources/machines/executions/logs.d.ts +103 -0
- package/dist/esm/sdk/resources/machines/executions/logs.d.ts.map +1 -0
- package/dist/esm/sdk/resources/machines/executions/logs.js +44 -0
- package/dist/esm/sdk/resources/machines/executions/logs.js.map +1 -0
- package/dist/esm/sdk/resources/machines/executions.d.ts +2 -0
- package/dist/esm/sdk/resources/machines/executions.d.ts.map +1 -0
- package/dist/esm/sdk/resources/machines/executions.js +3 -0
- package/dist/esm/sdk/resources/machines/executions.js.map +1 -0
- package/dist/esm/sdk/resources/machines/index.d.ts +9 -0
- package/dist/esm/sdk/resources/machines/index.d.ts.map +1 -0
- package/dist/esm/sdk/resources/machines/index.js +6 -0
- package/dist/esm/sdk/resources/machines/index.js.map +1 -0
- package/dist/esm/sdk/resources/machines/machines.d.ts +497 -0
- package/dist/esm/sdk/resources/machines/machines.d.ts.map +1 -0
- package/dist/esm/sdk/resources/machines/machines.js +183 -0
- package/dist/esm/sdk/resources/machines/machines.js.map +1 -0
- package/dist/esm/sdk/resources/machines/ssh.d.ts +175 -0
- package/dist/esm/sdk/resources/machines/ssh.d.ts.map +1 -0
- package/dist/esm/sdk/resources/machines/ssh.js +85 -0
- package/dist/esm/sdk/resources/machines/ssh.js.map +1 -0
- package/dist/esm/sdk/resources/machines.d.ts +2 -0
- package/dist/esm/sdk/resources/machines.d.ts.map +1 -0
- package/dist/esm/sdk/resources/machines.js +3 -0
- package/dist/esm/sdk/resources/machines.js.map +1 -0
- package/dist/esm/sdk/resources/organization/autoresizing.d.ts +87 -0
- package/dist/esm/sdk/resources/organization/autoresizing.d.ts.map +1 -0
- package/dist/esm/sdk/resources/organization/autoresizing.js +34 -0
- package/dist/esm/sdk/resources/organization/autoresizing.js.map +1 -0
- package/dist/esm/sdk/resources/organization/index.d.ts +4 -0
- package/dist/esm/sdk/resources/organization/index.d.ts.map +1 -0
- package/dist/esm/sdk/resources/organization/index.js +4 -0
- package/dist/esm/sdk/resources/organization/index.js.map +1 -0
- package/dist/esm/sdk/resources/organization/organization.d.ts +10 -0
- package/dist/esm/sdk/resources/organization/organization.d.ts.map +1 -0
- package/dist/esm/sdk/resources/organization/organization.js +9 -0
- package/dist/esm/sdk/resources/organization/organization.js.map +1 -0
- package/dist/esm/sdk/resources/organization.d.ts +2 -0
- package/dist/esm/sdk/resources/organization.d.ts.map +1 -0
- package/dist/esm/sdk/resources/organization.js +3 -0
- package/dist/esm/sdk/resources/organization.js.map +1 -0
- package/dist/esm/sdk/resources.d.ts +3 -0
- package/dist/esm/sdk/resources.d.ts.map +1 -0
- package/dist/esm/sdk/resources.js +3 -0
- package/dist/esm/sdk/resources.js.map +1 -0
- package/dist/esm/sdk/uploads.d.ts +2 -0
- package/dist/esm/sdk/uploads.d.ts.map +1 -0
- package/dist/esm/sdk/uploads.js +3 -0
- package/dist/esm/sdk/uploads.js.map +1 -0
- package/dist/esm/sdk/version.d.ts +2 -0
- package/dist/esm/sdk/version.d.ts.map +1 -0
- package/dist/esm/sdk/version.js +3 -0
- package/dist/esm/sdk/version.js.map +1 -0
- package/man/dedalus-completion.1 +35 -0
- package/man/dedalus-images-create.1 +126 -0
- package/man/dedalus-images-delete.1 +102 -0
- package/man/dedalus-images-import.1 +34 -0
- package/man/dedalus-images-list.1 +105 -0
- package/man/dedalus-images-retrieve.1 +102 -0
- package/man/dedalus-images-update.1 +108 -0
- package/man/dedalus-images-uploads-create.1 +112 -0
- package/man/dedalus-login.1 +47 -0
- package/man/dedalus-logout.1 +28 -0
- package/man/dedalus-machines-autoresizing-retrieve.1 +104 -0
- package/man/dedalus-machines-autoresizing-update.1 +116 -0
- package/man/dedalus-machines-create.1 +119 -0
- package/man/dedalus-machines-delete.1 +107 -0
- package/man/dedalus-machines-executions-create.1 +120 -0
- package/man/dedalus-machines-executions-delete.1 +108 -0
- package/man/dedalus-machines-executions-events.1 +118 -0
- package/man/dedalus-machines-executions-list.1 +114 -0
- package/man/dedalus-machines-executions-logs-create-token.1 +108 -0
- package/man/dedalus-machines-executions-logs-retrieve.1 +108 -0
- package/man/dedalus-machines-executions-output.1 +108 -0
- package/man/dedalus-machines-executions-retrieve.1 +108 -0
- package/man/dedalus-machines-list.1 +108 -0
- package/man/dedalus-machines-reboot.1 +107 -0
- package/man/dedalus-machines-resize.1 +110 -0
- package/man/dedalus-machines-retrieve.1 +104 -0
- package/man/dedalus-machines-sleep.1 +104 -0
- package/man/dedalus-machines-ssh-create.1 +108 -0
- package/man/dedalus-machines-ssh-delete.1 +108 -0
- package/man/dedalus-machines-ssh-list.1 +114 -0
- package/man/dedalus-machines-ssh-retrieve.1 +108 -0
- package/man/dedalus-machines-update.1 +110 -0
- package/man/dedalus-machines-wake.1 +104 -0
- package/man/dedalus-organization-autoresizing-retrieve.1 +99 -0
- package/man/dedalus-organization-autoresizing-update.1 +111 -0
- package/man/dedalus-uninstall.1 +23 -0
- package/man/dedalus-upgrade.1 +32 -0
- package/man/dedalus.1 +222 -0
- package/package.json +88 -4
|
@@ -0,0 +1,962 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Scalar. See README.md for details.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.Dedalus = void 0;
|
|
38
|
+
const api_promise_1 = require("./api-promise");
|
|
39
|
+
const pagination_1 = require("./core/pagination");
|
|
40
|
+
const Errors = __importStar(require("./error"));
|
|
41
|
+
const uuid7_1 = require("./internal/utils/uuid7");
|
|
42
|
+
const values_1 = require("./internal/utils/values");
|
|
43
|
+
const sleep_1 = require("./internal/utils/sleep");
|
|
44
|
+
const errors_1 = require("./internal/errors");
|
|
45
|
+
const body_1 = require("./internal/utils/body");
|
|
46
|
+
const detect_platform_1 = require("./internal/detect-platform");
|
|
47
|
+
const Shims = __importStar(require("./internal/shims"));
|
|
48
|
+
const Opts = __importStar(require("./internal/request-options"));
|
|
49
|
+
const env_1 = require("./internal/utils/env");
|
|
50
|
+
const log_1 = require("./internal/utils/log");
|
|
51
|
+
const headers_1 = require("./internal/headers");
|
|
52
|
+
const query_1 = require("./internal/utils/query");
|
|
53
|
+
const uploads_1 = require("./core/uploads");
|
|
54
|
+
const version_1 = require("./version");
|
|
55
|
+
const machines_1 = require("./resources/machines/machines");
|
|
56
|
+
const organization_1 = require("./resources/organization/organization");
|
|
57
|
+
const images_1 = require("./resources/images/images");
|
|
58
|
+
/**
|
|
59
|
+
* API Client for interfacing with the Dedalus API.
|
|
60
|
+
*/
|
|
61
|
+
class Dedalus {
|
|
62
|
+
apiKey;
|
|
63
|
+
xAPIKey;
|
|
64
|
+
browserToken;
|
|
65
|
+
dedalusOrgID;
|
|
66
|
+
asBaseURL;
|
|
67
|
+
baseURL;
|
|
68
|
+
maxRetries;
|
|
69
|
+
timeout;
|
|
70
|
+
logger;
|
|
71
|
+
logLevel;
|
|
72
|
+
fetchOptions;
|
|
73
|
+
/**
|
|
74
|
+
* The `fetch` implementation every request is sent through: the `fetch` client option, or the
|
|
75
|
+
* platform default. A replacement must honor the same contract as that option.
|
|
76
|
+
*/
|
|
77
|
+
fetch;
|
|
78
|
+
#encoder;
|
|
79
|
+
idempotencyHeader;
|
|
80
|
+
_baseURLOverridden;
|
|
81
|
+
_defaultBaseURL;
|
|
82
|
+
_options;
|
|
83
|
+
/**
|
|
84
|
+
* API Client for interfacing with the Dedalus API.
|
|
85
|
+
*
|
|
86
|
+
* @param {string | AuthTokenProvider | null | undefined} [opts.apiKey=process.env["DEDALUS_API_KEY"] ?? null]
|
|
87
|
+
* @param {string | AuthTokenProvider | null | undefined} [opts.xAPIKey=process.env["DEDALUS_X_API_KEY"] ?? null]
|
|
88
|
+
* @param {string | AuthTokenProvider | null | undefined} [opts.browserToken=process.env["DEDALUS_BROWSER_TOKEN"] ?? null]
|
|
89
|
+
* @param {string | null | undefined} [opts.dedalusOrgID=process.env["DEDALUS_ORG_ID"] ?? null]
|
|
90
|
+
* @param {string | null | undefined} [opts.asBaseURL=process.env["DEDALUS_AS_URL"] ?? "https://as.dedaluslabs.ai"]
|
|
91
|
+
* @param {string} [opts.baseURL=process.env["DEDALUS_BASE_URL"] ?? https://dcs.dedaluslabs.ai] - Override the default base URL for the API.
|
|
92
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
93
|
+
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
94
|
+
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
95
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
96
|
+
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
97
|
+
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
98
|
+
*/
|
|
99
|
+
constructor({ baseURL = (0, env_1.readEnv)('DEDALUS_BASE_URL'), apiKey = (0, env_1.readEnv)('DEDALUS_API_KEY') ?? null, xAPIKey = (0, env_1.readEnv)('DEDALUS_X_API_KEY') ?? null, browserToken = (0, env_1.readEnv)('DEDALUS_BROWSER_TOKEN') ?? null, dedalusOrgID = (0, env_1.readEnv)('DEDALUS_ORG_ID') ?? null, asBaseURL = (0, env_1.readEnv)('DEDALUS_AS_URL') ?? 'https://as.dedaluslabs.ai', ...opts } = {}) {
|
|
100
|
+
const options = {
|
|
101
|
+
apiKey,
|
|
102
|
+
xAPIKey,
|
|
103
|
+
browserToken,
|
|
104
|
+
dedalusOrgID,
|
|
105
|
+
asBaseURL,
|
|
106
|
+
...opts,
|
|
107
|
+
baseURL: baseURL || 'https://dcs.dedaluslabs.ai',
|
|
108
|
+
};
|
|
109
|
+
const baseURLOverridden = baseURL !== null && baseURL !== undefined && baseURL !== '';
|
|
110
|
+
const defaultBaseURL = 'https://dcs.dedaluslabs.ai';
|
|
111
|
+
this.baseURL = options.baseURL || defaultBaseURL;
|
|
112
|
+
this.timeout = options.timeout ?? Dedalus.DEFAULT_TIMEOUT /* 1 minute */;
|
|
113
|
+
this.logger = options.logger ?? console;
|
|
114
|
+
const defaultLogLevel = 'warn';
|
|
115
|
+
// Set default logLevel early so that we can log a warning in parseLogLevel.
|
|
116
|
+
this.logLevel = defaultLogLevel;
|
|
117
|
+
this.logLevel =
|
|
118
|
+
(0, log_1.parseLogLevel)(options.logLevel, 'ClientOptions.logLevel', this) ??
|
|
119
|
+
(0, log_1.parseLogLevel)((0, env_1.readEnv)('DEDALUS_LOG'), 'process.env["DEDALUS_LOG"]', this) ??
|
|
120
|
+
defaultLogLevel;
|
|
121
|
+
this.fetchOptions = options.fetchOptions;
|
|
122
|
+
this.maxRetries = options.maxRetries ?? 2;
|
|
123
|
+
this.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
124
|
+
this.#encoder = Opts.FallbackEncoder;
|
|
125
|
+
const customHeadersEnv = (0, env_1.readEnv)('DEDALUS_CUSTOM_HEADERS');
|
|
126
|
+
if (customHeadersEnv) {
|
|
127
|
+
const parsed = {};
|
|
128
|
+
for (const line of customHeadersEnv.split('\n')) {
|
|
129
|
+
const colon = line.indexOf(':');
|
|
130
|
+
if (colon >= 0) {
|
|
131
|
+
parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
options.defaultHeaders = { ...parsed, ...options.defaultHeaders };
|
|
135
|
+
}
|
|
136
|
+
this._options = { ...options, baseURL: baseURLOverridden ? this.baseURL : undefined };
|
|
137
|
+
this._baseURLOverridden = baseURLOverridden;
|
|
138
|
+
this._defaultBaseURL = defaultBaseURL;
|
|
139
|
+
this.idempotencyHeader = 'Idempotency-Key';
|
|
140
|
+
this.apiKey = apiKey;
|
|
141
|
+
this.xAPIKey = xAPIKey;
|
|
142
|
+
this.browserToken = browserToken;
|
|
143
|
+
this.dedalusOrgID = dedalusOrgID;
|
|
144
|
+
this.asBaseURL = asBaseURL;
|
|
145
|
+
}
|
|
146
|
+
withOptions(options) {
|
|
147
|
+
const client = new this.constructor({
|
|
148
|
+
...this._options,
|
|
149
|
+
...(this.#baseURLOverridden() ? { baseURL: this.baseURL } : {}),
|
|
150
|
+
maxRetries: this.maxRetries,
|
|
151
|
+
timeout: this.timeout,
|
|
152
|
+
logger: this.logger,
|
|
153
|
+
logLevel: this.logLevel,
|
|
154
|
+
fetch: this.fetch,
|
|
155
|
+
fetchOptions: this.fetchOptions,
|
|
156
|
+
apiKey: this.apiKey,
|
|
157
|
+
xAPIKey: this.xAPIKey,
|
|
158
|
+
browserToken: this.browserToken,
|
|
159
|
+
dedalusOrgID: this.dedalusOrgID,
|
|
160
|
+
asBaseURL: this.asBaseURL,
|
|
161
|
+
...options,
|
|
162
|
+
});
|
|
163
|
+
return client;
|
|
164
|
+
}
|
|
165
|
+
#baseURLOverridden() {
|
|
166
|
+
// A named environment selects a default URL; only explicit overrides should bypass per-request defaults.
|
|
167
|
+
return this._baseURLOverridden || this.baseURL !== this._defaultBaseURL;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The client as `JSON.stringify` sees it: every credential masked, and the resource accessors,
|
|
171
|
+
* which point back at the client, left out.
|
|
172
|
+
*/
|
|
173
|
+
toJSON() {
|
|
174
|
+
const view = {};
|
|
175
|
+
for (const [key, value] of Object.entries(this)) {
|
|
176
|
+
if (typeof value === 'object' && value !== null && value._client === this)
|
|
177
|
+
continue;
|
|
178
|
+
view[key] = redactClientField(key, value);
|
|
179
|
+
}
|
|
180
|
+
return view;
|
|
181
|
+
}
|
|
182
|
+
/** What `console.log` and `util.inspect` print for the client: the masked view `toJSON` builds. */
|
|
183
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
184
|
+
return this.toJSON();
|
|
185
|
+
}
|
|
186
|
+
defaultQuery() {
|
|
187
|
+
return this._options.defaultQuery;
|
|
188
|
+
}
|
|
189
|
+
stringifyQuery(query) {
|
|
190
|
+
return (0, query_1.stringifyQuery)(query);
|
|
191
|
+
}
|
|
192
|
+
getUserAgent() {
|
|
193
|
+
return `Dedalus/JS ${version_1.VERSION}`;
|
|
194
|
+
}
|
|
195
|
+
defaultIdempotencyKey() {
|
|
196
|
+
return (0, uuid7_1.uuid7)().replace(/-/g, '');
|
|
197
|
+
}
|
|
198
|
+
makeStatusError(status, error, message, headers) {
|
|
199
|
+
return Errors.APIError.generate(status, error, message, headers);
|
|
200
|
+
}
|
|
201
|
+
buildURL(path, query, defaultBaseURL) {
|
|
202
|
+
const baseURL = (!this.#baseURLOverridden() && defaultBaseURL) || this.baseURL;
|
|
203
|
+
// Guarantee exactly one "/" between baseURL and path so that bases without a trailing slash
|
|
204
|
+
// and paths without a leading slash do not fuse into a malformed URL (e.g. ".../v1" + "widgets").
|
|
205
|
+
const url = (0, values_1.isAbsoluteURL)(path)
|
|
206
|
+
? new URL(path)
|
|
207
|
+
: new URL((baseURL.endsWith('/') ? baseURL : baseURL + '/') + (path.startsWith('/') ? path.slice(1) : path));
|
|
208
|
+
const defaultQuery = this.defaultQuery();
|
|
209
|
+
const pathQuery = Object.fromEntries(url.searchParams);
|
|
210
|
+
if (!(0, values_1.isEmptyObj)(defaultQuery) || !(0, values_1.isEmptyObj)(pathQuery)) {
|
|
211
|
+
query = { ...pathQuery, ...defaultQuery, ...query };
|
|
212
|
+
}
|
|
213
|
+
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
214
|
+
url.search = this.stringifyQuery(query);
|
|
215
|
+
}
|
|
216
|
+
return url.toString();
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
220
|
+
*/
|
|
221
|
+
async prepareOptions(options) { }
|
|
222
|
+
/**
|
|
223
|
+
* Used as a callback for mutating the given `RequestInit` object.
|
|
224
|
+
*
|
|
225
|
+
* This is useful for cases where you want to add certain headers based off of
|
|
226
|
+
* the request properties, e.g. `method` or `url`.
|
|
227
|
+
*/
|
|
228
|
+
async prepareRequest(request, { url, options }) { }
|
|
229
|
+
get(path, opts) {
|
|
230
|
+
return this.methodRequest('get', path, opts);
|
|
231
|
+
}
|
|
232
|
+
post(path, opts) {
|
|
233
|
+
return this.methodRequest('post', path, opts);
|
|
234
|
+
}
|
|
235
|
+
patch(path, opts) {
|
|
236
|
+
return this.methodRequest('patch', path, opts);
|
|
237
|
+
}
|
|
238
|
+
put(path, opts) {
|
|
239
|
+
return this.methodRequest('put', path, opts);
|
|
240
|
+
}
|
|
241
|
+
delete(path, opts) {
|
|
242
|
+
return this.methodRequest('delete', path, opts);
|
|
243
|
+
}
|
|
244
|
+
methodRequest(method, path, opts) {
|
|
245
|
+
return this.request(Promise.resolve(opts).then((opts) => {
|
|
246
|
+
return { method, path, ...opts };
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
request(options, remainingRetries = null) {
|
|
250
|
+
return new api_promise_1.APIPromise(this, this.makeRequest(options, remainingRetries, undefined));
|
|
251
|
+
}
|
|
252
|
+
async makeRequest(optionsInput, retriesRemaining, retryOfRequestLogID) {
|
|
253
|
+
const options = await optionsInput;
|
|
254
|
+
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
255
|
+
if (retriesRemaining == null) {
|
|
256
|
+
retriesRemaining = maxRetries;
|
|
257
|
+
}
|
|
258
|
+
await this.prepareOptions(options);
|
|
259
|
+
const { req, url, timeout } = await this.buildRequest(options, {
|
|
260
|
+
retryCount: maxRetries - retriesRemaining,
|
|
261
|
+
});
|
|
262
|
+
await this.prepareRequest(req, { url, options });
|
|
263
|
+
/** Not an API request ID, just for correlating local log entries. */
|
|
264
|
+
const requestLogID = 'log_' + ((Math.random() * (1 << 24)) | 0).toString(16).padStart(6, '0');
|
|
265
|
+
const retryLogStr = retryOfRequestLogID === undefined ? '' : `, retryOf: ${retryOfRequestLogID}`;
|
|
266
|
+
const startTime = Date.now();
|
|
267
|
+
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] sending request`, (0, log_1.formatRequestDetails)({
|
|
268
|
+
retryOfRequestLogID,
|
|
269
|
+
method: options.method,
|
|
270
|
+
url,
|
|
271
|
+
options,
|
|
272
|
+
headers: req.headers,
|
|
273
|
+
}));
|
|
274
|
+
if (options.signal?.aborted) {
|
|
275
|
+
throw new Errors.APIUserAbortError();
|
|
276
|
+
}
|
|
277
|
+
const controller = new AbortController();
|
|
278
|
+
// The deadline stays armed until the body is read, not just until headers arrive, so a server
|
|
279
|
+
// that answers quickly and then trickles its body is still cut off at `timeout`.
|
|
280
|
+
const { release: releaseDeadline, unref: unrefDeadline } = this.#armDeadline(req.signal, timeout, controller);
|
|
281
|
+
// A subclass's own `fetchWithTimeout` sends the request; the deadline above still covers the body.
|
|
282
|
+
const viaOverride = this.fetchWithTimeout !== Dedalus.prototype.fetchWithTimeout;
|
|
283
|
+
const response = await (viaOverride
|
|
284
|
+
? Promise.resolve().then(() => this.fetchWithTimeout(url, req, timeout, controller))
|
|
285
|
+
: this.#fetchFollowingRedirects(url, req, controller)).catch(errors_1.castToError);
|
|
286
|
+
const headersTime = Date.now();
|
|
287
|
+
if (response instanceof globalThis.Error) {
|
|
288
|
+
releaseDeadline();
|
|
289
|
+
// A redirect the SDK refused to follow fails the same way on every attempt, so it is not retried.
|
|
290
|
+
if (isRefusedRedirect(response))
|
|
291
|
+
throw response;
|
|
292
|
+
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
293
|
+
if (options.signal?.aborted) {
|
|
294
|
+
throw new Errors.APIUserAbortError();
|
|
295
|
+
}
|
|
296
|
+
// detect native connection timeout errors
|
|
297
|
+
// deno throws "TypeError: error sending request for url (https://example/): client error (Connect): tcp connect error: Operation timed out (os error 60): Operation timed out (os error 60)"
|
|
298
|
+
// undici throws "TypeError: fetch failed" with cause "ConnectTimeoutError: Connect Timeout Error (attempted address: example:443, timeout: 1ms)"
|
|
299
|
+
// others do not provide enough information to distinguish timeouts from other connection errors
|
|
300
|
+
const isTimeout = (0, errors_1.isAbortError)(response) ||
|
|
301
|
+
/timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : ''));
|
|
302
|
+
if (retriesRemaining) {
|
|
303
|
+
(0, log_1.loggerFor)(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`);
|
|
304
|
+
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, (0, log_1.formatRequestDetails)({
|
|
305
|
+
retryOfRequestLogID,
|
|
306
|
+
url,
|
|
307
|
+
durationMs: headersTime - startTime,
|
|
308
|
+
message: response.message,
|
|
309
|
+
}));
|
|
310
|
+
return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID);
|
|
311
|
+
}
|
|
312
|
+
(0, log_1.loggerFor)(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`);
|
|
313
|
+
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, (0, log_1.formatRequestDetails)({
|
|
314
|
+
retryOfRequestLogID,
|
|
315
|
+
url,
|
|
316
|
+
durationMs: headersTime - startTime,
|
|
317
|
+
message: response.message,
|
|
318
|
+
}));
|
|
319
|
+
if (isTimeout) {
|
|
320
|
+
throw new Errors.APIConnectionTimeoutError();
|
|
321
|
+
}
|
|
322
|
+
throw new Errors.APIConnectionError({ cause: response });
|
|
323
|
+
}
|
|
324
|
+
const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${(0, log_1.redactUrl)(url)} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
325
|
+
if (!response.ok) {
|
|
326
|
+
const shouldRetry = await this.shouldRetry(response);
|
|
327
|
+
if (retriesRemaining && shouldRetry) {
|
|
328
|
+
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
329
|
+
// We don't need the body of this response.
|
|
330
|
+
releaseDeadline();
|
|
331
|
+
await Shims.CancelReadableStream(response.body);
|
|
332
|
+
(0, log_1.loggerFor)(this).info(`${responseInfo} - ${retryMessage}`);
|
|
333
|
+
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] response error (${retryMessage})`, (0, log_1.formatRequestDetails)({
|
|
334
|
+
retryOfRequestLogID,
|
|
335
|
+
url: response.url,
|
|
336
|
+
status: response.status,
|
|
337
|
+
headers: response.headers,
|
|
338
|
+
durationMs: headersTime - startTime,
|
|
339
|
+
}));
|
|
340
|
+
return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, response.headers);
|
|
341
|
+
}
|
|
342
|
+
const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`;
|
|
343
|
+
(0, log_1.loggerFor)(this).info(`${responseInfo} - ${retryMessage}`);
|
|
344
|
+
// Only the first 64 KiB of an error body is read: enough for any message, and a hostile or
|
|
345
|
+
// broken server cannot make the client buffer more. The read still runs under the deadline.
|
|
346
|
+
const errText = await (0, body_1.readBodyText)(response, body_1.MAX_ERROR_BODY_BYTES, 'truncate').catch((err) => (0, errors_1.castToError)(err).message);
|
|
347
|
+
releaseDeadline();
|
|
348
|
+
const errJSON = (0, values_1.safeJSON)(errText);
|
|
349
|
+
const errMessage = errJSON ? undefined : errText;
|
|
350
|
+
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] response error (${retryMessage})`, (0, log_1.formatRequestDetails)({
|
|
351
|
+
retryOfRequestLogID,
|
|
352
|
+
url: response.url,
|
|
353
|
+
status: response.status,
|
|
354
|
+
headers: response.headers,
|
|
355
|
+
message: errMessage,
|
|
356
|
+
durationMs: Date.now() - startTime,
|
|
357
|
+
}));
|
|
358
|
+
const err = this.makeStatusError(response.status, errJSON, errMessage, response.headers);
|
|
359
|
+
throw err;
|
|
360
|
+
}
|
|
361
|
+
(0, log_1.loggerFor)(this).info(responseInfo);
|
|
362
|
+
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] response start`, (0, log_1.formatRequestDetails)({
|
|
363
|
+
retryOfRequestLogID,
|
|
364
|
+
url: response.url,
|
|
365
|
+
status: response.status,
|
|
366
|
+
headers: response.headers,
|
|
367
|
+
durationMs: headersTime - startTime,
|
|
368
|
+
}));
|
|
369
|
+
// A streamed or binary body is the caller's to read at its own pace, so the deadline ends with
|
|
370
|
+
// the headers there; a buffered body keeps it until `defaultParseResponse` has read it.
|
|
371
|
+
if (options.stream || options.__binaryResponse)
|
|
372
|
+
releaseDeadline();
|
|
373
|
+
else {
|
|
374
|
+
// Unreferenced so a response nobody parses (a call never awaited) cannot hold the process
|
|
375
|
+
// open until the deadline; a body being read keeps it alive through its own socket.
|
|
376
|
+
unrefDeadline();
|
|
377
|
+
(0, body_1.holdDeadline)(controller, releaseDeadline);
|
|
378
|
+
}
|
|
379
|
+
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
380
|
+
}
|
|
381
|
+
// Public escape hatch for list endpoints the spec does not describe: the page type parameter
|
|
382
|
+
// defaults so `getAPIList<Item>(path, MyPage)` needs only the item type, and the page argument
|
|
383
|
+
// is a bare constructor so a hand-rolled page class need not restate the runtime page
|
|
384
|
+
// constructor's parameter types.
|
|
385
|
+
getAPIList(path, Page, options, method = 'get') {
|
|
386
|
+
// List endpoints are usually GET, but a body-located cursor scheme rides a POST body, so the
|
|
387
|
+
// caller passes the operation's actual verb. The method is preserved across auto-advanced
|
|
388
|
+
// pages because `nextPageRequestOptions` spreads the stored request options (incl. `method`).
|
|
389
|
+
const requestOptions = Promise.resolve(options).then((opts) => ({ ...opts, method, path }));
|
|
390
|
+
return this.requestAPIList(Page, requestOptions);
|
|
391
|
+
}
|
|
392
|
+
requestAPIList(Page, options) {
|
|
393
|
+
// `Item` is passed explicitly because the page constructor carries no slot to infer it from.
|
|
394
|
+
return new pagination_1.PagePromise(this, this.makeRequest(options, null, undefined), Page);
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Sends one request with a deadline on its response headers, following redirects as the client
|
|
398
|
+
* does.
|
|
399
|
+
*
|
|
400
|
+
* Override it in a subclass to wrap every HTTP request this client sends to its API, retries included;
|
|
401
|
+
* call `super.fetchWithTimeout` to send, which keeps the client's redirect handling. When a redirect
|
|
402
|
+
* leaves the origin that drops the client's own credential headers, but a header an override adds
|
|
403
|
+
* goes on to the redirect target, so a secret belongs in a client option rather than added here.
|
|
404
|
+
* A client that does not override it skips this method and sends directly.
|
|
405
|
+
*
|
|
406
|
+
* The SDK's own deadline aborts `controller` and stays armed until a buffered body is read, so it
|
|
407
|
+
* cuts off an override that sends through `super` or passes `controller.signal` on; a larger `ms`
|
|
408
|
+
* passed to `super` cannot extend it, so set the `timeout` option instead.
|
|
409
|
+
*/
|
|
410
|
+
async fetchWithTimeout(url, init, ms, controller) {
|
|
411
|
+
const deadline = this.#armDeadline(init?.signal, ms, controller);
|
|
412
|
+
try {
|
|
413
|
+
return await this.#fetchFollowingRedirects(url, init, controller);
|
|
414
|
+
}
|
|
415
|
+
finally {
|
|
416
|
+
deadline.release();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Starts the request deadline on `controller` and forwards the caller's abort signal to it.
|
|
421
|
+
*
|
|
422
|
+
* `release` disarms the deadline. `unref` stops it alone from keeping a Node process alive, for
|
|
423
|
+
* the stretch where it waits on a body nobody may ever read.
|
|
424
|
+
*/
|
|
425
|
+
#armDeadline(signal, ms, controller) {
|
|
426
|
+
const abort = this._makeAbort(controller);
|
|
427
|
+
if (signal?.aborted)
|
|
428
|
+
abort();
|
|
429
|
+
else if (signal)
|
|
430
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
431
|
+
const timeout = setTimeout(abort, ms);
|
|
432
|
+
return {
|
|
433
|
+
release: () => clearTimeout(timeout),
|
|
434
|
+
unref: () => timeout?.unref?.(),
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Sends one request, following its redirects here rather than in `fetch`.
|
|
439
|
+
*
|
|
440
|
+
* Platform `fetch` strips only `Authorization` when a redirect leaves the origin, so it would hand
|
|
441
|
+
* a header API key, cookies and a 307 body to whatever host the API names. Following here, where
|
|
442
|
+
* the client knows which headers carry credentials, keeps them on the API's own origin.
|
|
443
|
+
*/
|
|
444
|
+
async #fetchFollowingRedirects(url, init, controller) {
|
|
445
|
+
const { signal, method, ...options } = init || {};
|
|
446
|
+
const isReadableBody = isOneShotBody(options.body);
|
|
447
|
+
const request = typeof url === 'string' || url instanceof URL ? undefined : url;
|
|
448
|
+
const carriesUnguardedCredential = [...new Headers(options.headers ?? request?.headers).keys()].some((name) => CREDENTIAL_HEADERS.includes(name) && !BROWSER_GUARDED_HEADERS.includes(name));
|
|
449
|
+
const browserFollows = hidesRedirectTargets() && !carriesUnguardedCredential;
|
|
450
|
+
const callerRedirect = options.redirect === 'error' || options.redirect === 'manual' ? options.redirect : undefined;
|
|
451
|
+
const fetchOptions = {
|
|
452
|
+
signal: controller.signal,
|
|
453
|
+
...(isReadableBody ? { duplex: 'half' } : {}),
|
|
454
|
+
method: 'GET',
|
|
455
|
+
...options,
|
|
456
|
+
redirect: callerRedirect ?? (browserFollows ? 'follow' : 'manual'),
|
|
457
|
+
};
|
|
458
|
+
if (method) {
|
|
459
|
+
// Custom methods like 'patch' need to be uppercased
|
|
460
|
+
// See https://github.com/nodejs/undici/issues/2294
|
|
461
|
+
fetchOptions.method = method.toUpperCase();
|
|
462
|
+
}
|
|
463
|
+
// use undefined this binding; fetch errors if bound to something else in browsers and edge runtimes / workers
|
|
464
|
+
let response = await this.fetch.call(undefined, url, fetchOptions);
|
|
465
|
+
let current = request ? request.url : String(url);
|
|
466
|
+
let hop = {
|
|
467
|
+
...fetchOptions,
|
|
468
|
+
headers: new Headers(fetchOptions.headers ?? request?.headers),
|
|
469
|
+
};
|
|
470
|
+
// Once a hop leaves the origin, credentials stay dropped for the rest of the chain, even if a
|
|
471
|
+
// later hop comes back: the foreign host chose where that hop goes.
|
|
472
|
+
let leftOrigin = false;
|
|
473
|
+
for (let redirects = 0;; redirects++) {
|
|
474
|
+
if (callerRedirect)
|
|
475
|
+
return response;
|
|
476
|
+
if (hop.redirect === 'manual' && response.redirected) {
|
|
477
|
+
throw refuseRedirect("The fetch implementation followed a redirect itself although the client asked it not to, so its response was not used. A custom fetch must honor redirect: 'manual'.");
|
|
478
|
+
}
|
|
479
|
+
if (response.type === 'opaqueredirect') {
|
|
480
|
+
// Browsers answer a manual redirect with an opaque response that hides its target, so there
|
|
481
|
+
// is nothing safe to follow; it is refused rather than mistaken for the API's answer.
|
|
482
|
+
throw refuseRedirect(carriesUnguardedCredential
|
|
483
|
+
? 'The server answered with a redirect, which this request does not follow: the platform hides the target from the SDK, and the request carries an API key header that could reach another host. Call the redirect target directly, or send the request from a server.'
|
|
484
|
+
: 'The server answered with a redirect whose target this platform hides from the SDK, so it was not followed. Call the redirect target directly, or send the request from a server.');
|
|
485
|
+
}
|
|
486
|
+
const location = REDIRECT_STATUSES.includes(response.status)
|
|
487
|
+
? response.headers.get('location')?.trim()
|
|
488
|
+
: undefined;
|
|
489
|
+
if (!location)
|
|
490
|
+
return response;
|
|
491
|
+
await Shims.CancelReadableStream(response.body);
|
|
492
|
+
if (redirects >= MAX_REDIRECTS)
|
|
493
|
+
throw refuseRedirect(`Maximum redirects exceeded (${MAX_REDIRECTS}).`);
|
|
494
|
+
const from = new URL(current);
|
|
495
|
+
let target;
|
|
496
|
+
try {
|
|
497
|
+
target = new URL(location, from);
|
|
498
|
+
}
|
|
499
|
+
catch {
|
|
500
|
+
throw refuseRedirect('The server redirected to a URL that cannot be parsed.');
|
|
501
|
+
}
|
|
502
|
+
if (target.protocol !== 'https:' && target.protocol !== 'http:') {
|
|
503
|
+
throw refuseRedirect(`Refusing to follow a redirect to a ${target.protocol} URL.`);
|
|
504
|
+
}
|
|
505
|
+
if (from.protocol === 'https:' && target.protocol === 'http:') {
|
|
506
|
+
throw refuseRedirect('Refusing to follow a redirect from https to http.');
|
|
507
|
+
}
|
|
508
|
+
const headers = new Headers(hop.headers);
|
|
509
|
+
let nextMethod = hop.method ?? 'GET';
|
|
510
|
+
let body = hop.body ?? request?.body ?? undefined;
|
|
511
|
+
// A 303 (but for HEAD), and a 301 or 302 answering a POST, re-ask with a bodiless GET, as
|
|
512
|
+
// browsers do. Every other redirect repeats the request, so its body has to be sent again.
|
|
513
|
+
if ((response.status === 303 && nextMethod !== 'HEAD') ||
|
|
514
|
+
((response.status === 301 || response.status === 302) && nextMethod === 'POST')) {
|
|
515
|
+
nextMethod = 'GET';
|
|
516
|
+
body = undefined;
|
|
517
|
+
for (const name of [...headers.keys()])
|
|
518
|
+
if (name.startsWith('content-'))
|
|
519
|
+
headers.delete(name);
|
|
520
|
+
}
|
|
521
|
+
else if (body != null && isOneShotBody(body)) {
|
|
522
|
+
throw refuseRedirect(`Refusing to follow a ${response.status} redirect: the request body was a stream, which cannot be sent again.`);
|
|
523
|
+
}
|
|
524
|
+
if (target.origin !== from.origin)
|
|
525
|
+
leftOrigin = true;
|
|
526
|
+
if (leftOrigin) {
|
|
527
|
+
for (const name of CREDENTIAL_HEADERS)
|
|
528
|
+
headers.delete(name);
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
// A `Location` the server spelled does not repeat our query credentials, so a same-origin
|
|
532
|
+
// hop carries them over; appended rather than set so the target's own query keeps its bytes.
|
|
533
|
+
for (const name of CREDENTIAL_QUERY) {
|
|
534
|
+
const value = from.searchParams.get(name);
|
|
535
|
+
if (value === null || target.searchParams.has(name))
|
|
536
|
+
continue;
|
|
537
|
+
target.search =
|
|
538
|
+
(target.search ? target.search + '&' : '?') +
|
|
539
|
+
encodeURIComponent(name) +
|
|
540
|
+
'=' +
|
|
541
|
+
encodeURIComponent(value);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
hop = { ...hop, method: nextMethod, headers };
|
|
545
|
+
if (body == null) {
|
|
546
|
+
delete hop.body;
|
|
547
|
+
delete hop.duplex;
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
hop.body = body;
|
|
551
|
+
}
|
|
552
|
+
current = target.href;
|
|
553
|
+
response = await this.fetch.call(undefined, current, hop);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
async shouldRetry(response) {
|
|
557
|
+
// Note this is not a standard header.
|
|
558
|
+
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
559
|
+
// If the server explicitly says whether or not to retry, obey.
|
|
560
|
+
if (shouldRetryHeader === 'true')
|
|
561
|
+
return true;
|
|
562
|
+
if (shouldRetryHeader === 'false')
|
|
563
|
+
return false;
|
|
564
|
+
// Retry on request timeouts.
|
|
565
|
+
if (response.status === 408)
|
|
566
|
+
return true;
|
|
567
|
+
// Retry on lock timeouts.
|
|
568
|
+
if (response.status === 409)
|
|
569
|
+
return true;
|
|
570
|
+
// Retry on rate limits.
|
|
571
|
+
if (response.status === 429)
|
|
572
|
+
return true;
|
|
573
|
+
// Retry internal errors.
|
|
574
|
+
if (response.status >= 500)
|
|
575
|
+
return true;
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
async retryRequest(options, retriesRemaining, requestLogID, responseHeaders) {
|
|
579
|
+
let timeoutMillis;
|
|
580
|
+
// Note the `retry-after-ms` header may not be standard, but is a good idea and we'd like proactive support for it.
|
|
581
|
+
const retryAfterMillisHeader = responseHeaders?.get('retry-after-ms');
|
|
582
|
+
if (retryAfterMillisHeader) {
|
|
583
|
+
const timeoutMs = parseFloat(retryAfterMillisHeader);
|
|
584
|
+
if (!Number.isNaN(timeoutMs)) {
|
|
585
|
+
timeoutMillis = timeoutMs;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
// About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
589
|
+
const retryAfterHeader = responseHeaders?.get('retry-after');
|
|
590
|
+
if (retryAfterHeader && !timeoutMillis) {
|
|
591
|
+
const timeoutSeconds = parseFloat(retryAfterHeader);
|
|
592
|
+
if (!Number.isNaN(timeoutSeconds)) {
|
|
593
|
+
timeoutMillis = timeoutSeconds * 1000;
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
// If the API asks us to wait a certain amount of time, just do what it says,
|
|
600
|
+
// but cap server-provided delays at 60s so an oversized or malformed Retry-After
|
|
601
|
+
// (e.g. `retry-after-ms: 999999999`, a past HTTP-date, or a value that Date.parse
|
|
602
|
+
// failed on) cannot block retries for an unbounded amount of time. Otherwise fall
|
|
603
|
+
// back to the default exponential-backoff calculation.
|
|
604
|
+
const maxRetryAfterMillis = 60 * 1000;
|
|
605
|
+
if (timeoutMillis === undefined ||
|
|
606
|
+
!Number.isFinite(timeoutMillis) ||
|
|
607
|
+
timeoutMillis <= 0 ||
|
|
608
|
+
timeoutMillis > maxRetryAfterMillis) {
|
|
609
|
+
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
610
|
+
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
611
|
+
}
|
|
612
|
+
await (0, sleep_1.sleep)(timeoutMillis);
|
|
613
|
+
return this.makeRequest(options, retriesRemaining - 1, requestLogID);
|
|
614
|
+
}
|
|
615
|
+
calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries) {
|
|
616
|
+
const initialRetryDelay = 0.5;
|
|
617
|
+
const maxRetryDelay = 8.0;
|
|
618
|
+
const numRetries = maxRetries - retriesRemaining;
|
|
619
|
+
// Apply exponential backoff, but not more than the max.
|
|
620
|
+
const sleepSeconds = Math.min(initialRetryDelay * Math.pow(2, numRetries), maxRetryDelay);
|
|
621
|
+
// Apply some jitter, take up to at most 25 percent of the retry time.
|
|
622
|
+
const jitter = 1 - Math.random() * 0.25;
|
|
623
|
+
return sleepSeconds * jitter * 1000;
|
|
624
|
+
}
|
|
625
|
+
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
626
|
+
const options = { ...inputOptions };
|
|
627
|
+
const { method, path, query, defaultBaseURL } = options;
|
|
628
|
+
const url = this.buildURL(path, query, defaultBaseURL);
|
|
629
|
+
if ('timeout' in options)
|
|
630
|
+
(0, values_1.validatePositiveInteger)('timeout', options.timeout);
|
|
631
|
+
options.timeout = options.timeout ?? this.timeout;
|
|
632
|
+
const { bodyHeaders, body } = this.buildBody({ options });
|
|
633
|
+
// Headers read the caller's own options, not the copy defaulted above: `X-Scalar-Timeout`
|
|
634
|
+
// reports an explicit per-request timeout, and the idempotency key written back here has to
|
|
635
|
+
// land where the retry can see it.
|
|
636
|
+
const reqHeaders = await this.buildHeaders({
|
|
637
|
+
options: inputOptions,
|
|
638
|
+
method,
|
|
639
|
+
bodyHeaders,
|
|
640
|
+
retryCount,
|
|
641
|
+
url,
|
|
642
|
+
});
|
|
643
|
+
const req = {
|
|
644
|
+
method,
|
|
645
|
+
headers: reqHeaders,
|
|
646
|
+
...(options.signal && { signal: options.signal }),
|
|
647
|
+
...(globalThis.ReadableStream &&
|
|
648
|
+
body instanceof globalThis.ReadableStream && { duplex: 'half' }),
|
|
649
|
+
// `buildBody` already collapses no-body into `undefined`; here we only need to drop that
|
|
650
|
+
// sentinel. A truthiness spread would also strip an intentional empty-string body.
|
|
651
|
+
...(body !== undefined && { body }),
|
|
652
|
+
...(this.fetchOptions ?? {}),
|
|
653
|
+
...(options.fetchOptions ?? {}),
|
|
654
|
+
};
|
|
655
|
+
return { req, url, timeout: options.timeout };
|
|
656
|
+
}
|
|
657
|
+
async buildHeaders({ options, method, bodyHeaders, retryCount, url, }) {
|
|
658
|
+
let idempotencyHeaders = {};
|
|
659
|
+
if (this.idempotencyHeader && method !== 'get') {
|
|
660
|
+
if (!options.idempotencyKey)
|
|
661
|
+
options.idempotencyKey = this.defaultIdempotencyKey();
|
|
662
|
+
idempotencyHeaders[this.idempotencyHeader] = options.idempotencyKey;
|
|
663
|
+
}
|
|
664
|
+
const headers = (0, headers_1.buildHeaders)([
|
|
665
|
+
idempotencyHeaders,
|
|
666
|
+
{
|
|
667
|
+
Accept: 'application/json',
|
|
668
|
+
'User-Agent': this.getUserAgent(),
|
|
669
|
+
'X-Scalar-Retry-Count': String(retryCount),
|
|
670
|
+
...(options.timeout ? { 'X-Scalar-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}),
|
|
671
|
+
...(0, detect_platform_1.getPlatformHeaders)(),
|
|
672
|
+
...{ 'X-SDK-Version': '1.0.0' },
|
|
673
|
+
'X-Dedalus-Org-Id': this.dedalusOrgID,
|
|
674
|
+
},
|
|
675
|
+
await this.authHeaders(options),
|
|
676
|
+
this._options.defaultHeaders,
|
|
677
|
+
bodyHeaders,
|
|
678
|
+
options.headers,
|
|
679
|
+
]);
|
|
680
|
+
appendAuthCookies(headers.values, await this.authCookiesAsync());
|
|
681
|
+
this.validateAuth(url, headers.values, options);
|
|
682
|
+
// Last, so a subclass sees the headers as they leave here, after the SDK has checked the auth.
|
|
683
|
+
await this.validateHeaders(headers);
|
|
684
|
+
return headers.values;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Runs once for every HTTP request built from the client's headers, at the end of header building,
|
|
688
|
+
* with the headers it will be sent with: `values` holds them and `nulls` the names the call removed
|
|
689
|
+
* with a `null`.
|
|
690
|
+
* Throwing, or rejecting from an `async` override, which is awaited, rejects the request before it
|
|
691
|
+
* is sent. Does nothing unless a subclass overrides it.
|
|
692
|
+
* `fetchOptions.headers` and `prepareRequest` are applied afterwards, so the hook does not see them.
|
|
693
|
+
*/
|
|
694
|
+
validateHeaders({ values, nulls }) { }
|
|
695
|
+
_makeAbort(controller) {
|
|
696
|
+
// note: we can't just inline this method inside `#armDeadline()` because then the closure
|
|
697
|
+
// would capture all request options, and cause a memory leak.
|
|
698
|
+
return () => controller.abort();
|
|
699
|
+
}
|
|
700
|
+
buildBody({ options: { body, headers: rawHeaders } }) {
|
|
701
|
+
// Skip only `null`/`undefined` so an intentional empty-string (or 0/false) payload still
|
|
702
|
+
// reaches the encoder. A plain `!body` check would silently drop those falsy-but-valid bodies,
|
|
703
|
+
// and `null` must be excluded here too because the iterator check below uses `in`, which
|
|
704
|
+
// throws on null.
|
|
705
|
+
if (body == null) {
|
|
706
|
+
return { bodyHeaders: undefined, body: undefined };
|
|
707
|
+
}
|
|
708
|
+
// A `content-type` from either header bag says how the body is already encoded; the request's
|
|
709
|
+
// own wins over the client-wide default, as it does on the wire.
|
|
710
|
+
const headers = (0, headers_1.buildHeaders)([this._options.defaultHeaders, rawHeaders]);
|
|
711
|
+
if (
|
|
712
|
+
// Pass raw type verbatim
|
|
713
|
+
ArrayBuffer.isView(body) ||
|
|
714
|
+
body instanceof ArrayBuffer ||
|
|
715
|
+
body instanceof DataView ||
|
|
716
|
+
// A string is only already-encoded when something has said what it is encoded as.
|
|
717
|
+
// Generated call sites state the declared request media type, so a `text/plain` or
|
|
718
|
+
// ndjson payload reaches the wire byte-for-byte. A string with no `content-type` came
|
|
719
|
+
// from a body the document declared as JSON — `{ "type": "string" }` — and encoding it
|
|
720
|
+
// below is what puts the quotes the server parses for around it.
|
|
721
|
+
(typeof body === 'string' && headers.values.has('content-type')) ||
|
|
722
|
+
// `Blob` is superset of `File`
|
|
723
|
+
(globalThis.Blob && body instanceof globalThis.Blob) ||
|
|
724
|
+
// `FormData` -> `multipart/form-data`
|
|
725
|
+
body instanceof FormData ||
|
|
726
|
+
// `URLSearchParams` -> `application/x-www-form-urlencoded`
|
|
727
|
+
body instanceof URLSearchParams ||
|
|
728
|
+
// Send chunked stream (each chunk has own `length`)
|
|
729
|
+
(globalThis.ReadableStream && body instanceof globalThis.ReadableStream)) {
|
|
730
|
+
return { bodyHeaders: undefined, body: body };
|
|
731
|
+
}
|
|
732
|
+
else if (typeof body === 'object' &&
|
|
733
|
+
(Symbol.asyncIterator in body ||
|
|
734
|
+
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
735
|
+
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body) };
|
|
736
|
+
}
|
|
737
|
+
else if (typeof body === 'object' &&
|
|
738
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
739
|
+
return {
|
|
740
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
741
|
+
body: this.stringifyQuery(body),
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
else {
|
|
745
|
+
return this.#encoder({ body, headers });
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
validateAuth(url, headers, options) {
|
|
749
|
+
if (headers.has('Authorization'))
|
|
750
|
+
return;
|
|
751
|
+
if (headerExplicitlyOmitted(options.headers, 'Authorization'))
|
|
752
|
+
return;
|
|
753
|
+
if (headers.has('x-api-key'))
|
|
754
|
+
return;
|
|
755
|
+
if (headerExplicitlyOmitted(options.headers, 'x-api-key'))
|
|
756
|
+
return;
|
|
757
|
+
throw new Errors.AuthenticationError(401, undefined, 'Could not resolve authentication method. Expected either apiKey, browserToken or xAPIKey to be set. Or for one of the "Authorization" or "x-api-key" headers to be explicitly omitted', headers);
|
|
758
|
+
}
|
|
759
|
+
authHeadersSync() {
|
|
760
|
+
const headers = {};
|
|
761
|
+
const apiKey = this.resolveAuthOptionSync('apiKey', this.apiKey);
|
|
762
|
+
if (apiKey)
|
|
763
|
+
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
764
|
+
const xAPIKey = this.resolveAuthOptionSync('xAPIKey', this.xAPIKey);
|
|
765
|
+
if (xAPIKey)
|
|
766
|
+
headers['x-api-key'] = xAPIKey;
|
|
767
|
+
const browserToken = this.resolveAuthOptionSync('browserToken', this.browserToken);
|
|
768
|
+
if (browserToken)
|
|
769
|
+
headers['Authorization'] = `Bearer ${browserToken}`;
|
|
770
|
+
return headers;
|
|
771
|
+
}
|
|
772
|
+
webSocketAuthHeaders() {
|
|
773
|
+
const apiKey = this.resolveAuthOptionSync('apiKey', this.apiKey);
|
|
774
|
+
if (apiKey)
|
|
775
|
+
return { Authorization: `Bearer ${apiKey}` };
|
|
776
|
+
const xAPIKey = this.resolveAuthOptionSync('xAPIKey', this.xAPIKey);
|
|
777
|
+
if (xAPIKey)
|
|
778
|
+
return { 'x-api-key': xAPIKey };
|
|
779
|
+
return {};
|
|
780
|
+
}
|
|
781
|
+
async authHeaders(opts) {
|
|
782
|
+
return (0, headers_1.buildHeaders)([
|
|
783
|
+
await this.bearerAuth(opts),
|
|
784
|
+
await this.apiKeyAuth(opts),
|
|
785
|
+
await this.browserAuth(opts),
|
|
786
|
+
]);
|
|
787
|
+
}
|
|
788
|
+
async bearerAuth(opts) {
|
|
789
|
+
const apiKey = await this.resolveAuthOption('apiKey', this.apiKey);
|
|
790
|
+
if (apiKey == null) {
|
|
791
|
+
return undefined;
|
|
792
|
+
}
|
|
793
|
+
return (0, headers_1.buildHeaders)([{ Authorization: `Bearer ${apiKey}` }]);
|
|
794
|
+
}
|
|
795
|
+
async apiKeyAuth(opts) {
|
|
796
|
+
const xAPIKey = await this.resolveAuthOption('xAPIKey', this.xAPIKey);
|
|
797
|
+
if (xAPIKey == null) {
|
|
798
|
+
return undefined;
|
|
799
|
+
}
|
|
800
|
+
return (0, headers_1.buildHeaders)([{ 'x-api-key': xAPIKey }]);
|
|
801
|
+
}
|
|
802
|
+
async browserAuth(opts) {
|
|
803
|
+
const browserToken = await this.resolveAuthOption('browserToken', this.browserToken);
|
|
804
|
+
if (browserToken == null) {
|
|
805
|
+
return undefined;
|
|
806
|
+
}
|
|
807
|
+
return (0, headers_1.buildHeaders)([{ Authorization: `Bearer ${browserToken}` }]);
|
|
808
|
+
}
|
|
809
|
+
async authQueryAsync() {
|
|
810
|
+
const query = {};
|
|
811
|
+
return query;
|
|
812
|
+
}
|
|
813
|
+
async authCookiesAsync() {
|
|
814
|
+
const cookies = {};
|
|
815
|
+
return cookies;
|
|
816
|
+
}
|
|
817
|
+
async resolveAuthOption(optionName, value) {
|
|
818
|
+
if (value == null)
|
|
819
|
+
return undefined;
|
|
820
|
+
const token = typeof value === 'function' ? await value() : value;
|
|
821
|
+
if (!token)
|
|
822
|
+
throw new Errors.DedalusError(`Expected '${optionName}' to resolve to a non-empty string.`);
|
|
823
|
+
return token;
|
|
824
|
+
}
|
|
825
|
+
resolveAuthOptionSync(optionName, value) {
|
|
826
|
+
if (value == null)
|
|
827
|
+
return undefined;
|
|
828
|
+
const token = typeof value === 'function' ? value() : value;
|
|
829
|
+
if (typeof token !== 'string' || !token)
|
|
830
|
+
throw new Errors.DedalusError(`Expected '${optionName}' to resolve to a non-empty string.`);
|
|
831
|
+
return token;
|
|
832
|
+
}
|
|
833
|
+
static Dedalus = this;
|
|
834
|
+
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
835
|
+
static DedalusError = Errors.DedalusError;
|
|
836
|
+
static APIError = Errors.APIError;
|
|
837
|
+
static APIConnectionError = Errors.APIConnectionError;
|
|
838
|
+
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
839
|
+
static APIUserAbortError = Errors.APIUserAbortError;
|
|
840
|
+
static NotFoundError = Errors.NotFoundError;
|
|
841
|
+
static ConflictError = Errors.ConflictError;
|
|
842
|
+
static RateLimitError = Errors.RateLimitError;
|
|
843
|
+
static BadRequestError = Errors.BadRequestError;
|
|
844
|
+
static AuthenticationError = Errors.AuthenticationError;
|
|
845
|
+
static InternalServerError = Errors.InternalServerError;
|
|
846
|
+
static PermissionDeniedError = Errors.PermissionDeniedError;
|
|
847
|
+
static UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
848
|
+
static toFile = uploads_1.toFile;
|
|
849
|
+
machines = new machines_1.Machines(this);
|
|
850
|
+
organization = new organization_1.Organization(this);
|
|
851
|
+
images = new images_1.Images(this);
|
|
852
|
+
}
|
|
853
|
+
exports.Dedalus = Dedalus;
|
|
854
|
+
Dedalus.Machines = machines_1.Machines;
|
|
855
|
+
Dedalus.Organization = organization_1.Organization;
|
|
856
|
+
Dedalus.Images = images_1.Images;
|
|
857
|
+
const headerExplicitlyOmitted = (source, name) => {
|
|
858
|
+
if (!source || Array.isArray(source) || source instanceof Headers)
|
|
859
|
+
return false;
|
|
860
|
+
const target = name.toLowerCase();
|
|
861
|
+
return Object.entries(source).some(([key, value]) => key.toLowerCase() === target && value === null);
|
|
862
|
+
};
|
|
863
|
+
const appendAuthCookies = (headers, cookies) => {
|
|
864
|
+
for (const [name, value] of Object.entries(cookies)) {
|
|
865
|
+
if (cookieHeaderHas(headers.get('Cookie'), name))
|
|
866
|
+
continue;
|
|
867
|
+
const cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
|
|
868
|
+
const existing = headers.get('Cookie');
|
|
869
|
+
headers.set('Cookie', existing ? existing + '; ' + cookie : cookie);
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
const cookieHeaderHas = (value, name) => {
|
|
873
|
+
if (!value)
|
|
874
|
+
return false;
|
|
875
|
+
const target = encodeURIComponent(name) + '=';
|
|
876
|
+
return value.split(';').some((cookie) => cookie.trim().startsWith(target));
|
|
877
|
+
};
|
|
878
|
+
/** Client fields holding a secret, masked whenever the client is printed or serialized. */
|
|
879
|
+
const SECRET_CLIENT_FIELDS = ['apiKey', 'xAPIKey', 'browserToken'];
|
|
880
|
+
/**
|
|
881
|
+
* One field of the client (or of its stored options) as a printed client shows it. Credentials are
|
|
882
|
+
* masked outright; header bags go through the log redaction, which knows every header this SDK
|
|
883
|
+
* authenticates with; a base URL loses any userinfo or query credential it carries.
|
|
884
|
+
*/
|
|
885
|
+
const redactClientField = (key, value) => {
|
|
886
|
+
if (value === null || value === undefined)
|
|
887
|
+
return value;
|
|
888
|
+
if (SECRET_CLIENT_FIELDS.includes(key))
|
|
889
|
+
return '***';
|
|
890
|
+
if (key === 'baseURL' && typeof value === 'string')
|
|
891
|
+
return (0, log_1.redactUrl)(value);
|
|
892
|
+
if (key === 'defaultHeaders') {
|
|
893
|
+
if (value instanceof Headers)
|
|
894
|
+
return (0, log_1.redactHeaders)(value);
|
|
895
|
+
if (typeof value !== 'object' || Array.isArray(value))
|
|
896
|
+
return '***';
|
|
897
|
+
const redactValue = (name, field) => {
|
|
898
|
+
if (typeof field === 'string')
|
|
899
|
+
return (0, log_1.redactHeaders)({ [name]: field })[name];
|
|
900
|
+
if (Array.isArray(field))
|
|
901
|
+
return field.map((entry) => redactValue(name, entry));
|
|
902
|
+
return field === null || field === undefined ? field : '***';
|
|
903
|
+
};
|
|
904
|
+
return Object.fromEntries(Object.entries(value).map(([name, field]) => [name, redactValue(name, field)]));
|
|
905
|
+
}
|
|
906
|
+
if (typeof value !== 'object')
|
|
907
|
+
return value;
|
|
908
|
+
if (key === 'fetchOptions') {
|
|
909
|
+
const { headers: _headers, ...rest } = value;
|
|
910
|
+
return _headers === undefined ? rest : { ...rest, headers: '***' };
|
|
911
|
+
}
|
|
912
|
+
if (key === '_options') {
|
|
913
|
+
return Object.fromEntries(Object.entries(value).map(([name, field]) => [name, redactClientField(name, field)]));
|
|
914
|
+
}
|
|
915
|
+
return value;
|
|
916
|
+
};
|
|
917
|
+
/** Statuses the client follows when they carry a `Location`; any other 3xx is the server's answer. */
|
|
918
|
+
const REDIRECT_STATUSES = [301, 302, 303, 307, 308];
|
|
919
|
+
/** The most redirects one request follows, the same cap the platform `fetch` uses. */
|
|
920
|
+
const MAX_REDIRECTS = 20;
|
|
921
|
+
/**
|
|
922
|
+
* Headers that carry a credential: the platform's own and every header this API's security schemes
|
|
923
|
+
* place. A redirect that leaves the origin drops each of them, wherever it was set.
|
|
924
|
+
*/
|
|
925
|
+
const CREDENTIAL_HEADERS = ['authorization', 'cookie', 'proxy-authorization', 'x-api-key'];
|
|
926
|
+
/** Query parameters this API's security schemes place, carried only to a same-origin redirect target. */
|
|
927
|
+
const CREDENTIAL_QUERY = [];
|
|
928
|
+
/**
|
|
929
|
+
* Credential headers a browser keeps on the origin itself: it drops `Authorization` from a
|
|
930
|
+
* cross-origin redirect and never lets script set the other two.
|
|
931
|
+
*/
|
|
932
|
+
const BROWSER_GUARDED_HEADERS = ['authorization', 'cookie', 'proxy-authorization'];
|
|
933
|
+
/**
|
|
934
|
+
* Whether this runtime's fetch answers a manual redirect opaquely, hiding its target: a browser
|
|
935
|
+
* page, or a dedicated, shared or service worker in one. A worker scope alone is not enough,
|
|
936
|
+
* since edge runtimes model theirs on it while returning the real 3xx; a browser user agent is.
|
|
937
|
+
*/
|
|
938
|
+
const hidesRedirectTargets = () => {
|
|
939
|
+
if ((0, detect_platform_1.isRunningInBrowser)())
|
|
940
|
+
return true;
|
|
941
|
+
if (typeof globalThis.WorkerGlobalScope === 'undefined')
|
|
942
|
+
return false;
|
|
943
|
+
const agent = globalThis.navigator?.userAgent;
|
|
944
|
+
return typeof agent === 'string' && agent.startsWith('Mozilla/');
|
|
945
|
+
};
|
|
946
|
+
/** Marks the error for a redirect the client refused to follow, which `makeRequest` does not retry. */
|
|
947
|
+
const REFUSED_REDIRECT = Symbol('refusedRedirect');
|
|
948
|
+
/** Marks `error` as a redirect refusal, which no retry layer repeats. */
|
|
949
|
+
const markRefusedRedirect = (error) => {
|
|
950
|
+
error[REFUSED_REDIRECT] = true;
|
|
951
|
+
return error;
|
|
952
|
+
};
|
|
953
|
+
/** A connection error for a redirect the client will not follow. */
|
|
954
|
+
const refuseRedirect = (message) => markRefusedRedirect(new Errors.APIConnectionError({ message }));
|
|
955
|
+
/** Whether `error` is a redirect refusal from {@link refuseRedirect}. */
|
|
956
|
+
const isRefusedRedirect = (error) => typeof error === 'object' &&
|
|
957
|
+
error !== null &&
|
|
958
|
+
error[REFUSED_REDIRECT] === true;
|
|
959
|
+
/** Whether a request body can be read only once, so a redirect that repeats the request cannot resend it. */
|
|
960
|
+
const isOneShotBody = (body) => !!((globalThis.ReadableStream && body instanceof globalThis.ReadableStream) ||
|
|
961
|
+
(typeof body === 'object' && body !== null && Symbol.asyncIterator in body));
|
|
962
|
+
//# sourceMappingURL=client.js.map
|