@composio/client 0.1.0-alpha.1 → 0.1.0-alpha.10
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 +137 -0
- package/LICENSE +1 -1
- package/README.md +31 -31
- package/api-promise.js +2 -15
- package/api-promise.js.map +1 -1
- package/client.d.mts +28 -25
- package/client.d.mts.map +1 -1
- package/client.d.ts +28 -25
- package/client.d.ts.map +1 -1
- package/client.js +95 -113
- package/client.js.map +1 -1
- package/client.mjs +88 -83
- package/client.mjs.map +1 -1
- package/core/api-promise.d.mts +2 -3
- package/core/api-promise.d.mts.map +1 -1
- package/core/api-promise.d.ts +2 -3
- package/core/api-promise.d.ts.map +1 -1
- package/core/api-promise.js +4 -14
- package/core/api-promise.js.map +1 -1
- package/core/api-promise.mjs +1 -11
- package/core/api-promise.mjs.map +1 -1
- package/core/error.d.mts +2 -3
- package/core/error.d.mts.map +1 -1
- package/core/error.d.ts +2 -3
- package/core/error.d.ts.map +1 -1
- package/core/error.js +4 -4
- package/core/error.js.map +1 -1
- package/core/error.mjs +2 -2
- package/core/error.mjs.map +1 -1
- package/core/resource.d.mts +3 -3
- package/core/resource.d.mts.map +1 -1
- package/core/resource.d.ts +3 -3
- package/core/resource.d.ts.map +1 -1
- package/core/resource.js.map +1 -1
- package/core/resource.mjs.map +1 -1
- package/error.js +2 -15
- package/error.js.map +1 -1
- package/index.d.mts +3 -3
- package/index.d.mts.map +1 -1
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +4 -4
- package/index.js.map +1 -1
- package/index.mjs +3 -3
- package/index.mjs.map +1 -1
- package/internal/builtin-types.d.mts +0 -2
- package/internal/builtin-types.d.mts.map +1 -1
- package/internal/builtin-types.d.ts +0 -2
- package/internal/builtin-types.d.ts.map +1 -1
- package/internal/detect-platform.js.map +1 -1
- package/internal/detect-platform.mjs.map +1 -1
- package/internal/errors.d.mts.map +1 -1
- package/internal/errors.d.ts.map +1 -1
- package/internal/errors.js +2 -2
- package/internal/errors.js.map +1 -1
- package/internal/errors.mjs.map +1 -1
- package/internal/headers.d.mts +1 -2
- package/internal/headers.d.mts.map +1 -1
- package/internal/headers.d.ts +1 -2
- package/internal/headers.d.ts.map +1 -1
- package/internal/headers.js +3 -1
- package/internal/headers.js.map +1 -1
- package/internal/headers.mjs +3 -1
- package/internal/headers.mjs.map +1 -1
- package/internal/parse.d.mts +2 -3
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts +2 -3
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +1 -2
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs.map +1 -1
- package/internal/qs/formats.d.mts +6 -0
- package/internal/qs/formats.d.mts.map +1 -0
- package/internal/qs/formats.d.ts +6 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +11 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +8 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.mts +10 -0
- package/internal/qs/index.d.mts.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.mts +3 -0
- package/internal/qs/stringify.d.mts.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +279 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +276 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.mts +57 -0
- package/internal/qs/types.d.mts.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.mts +14 -0
- package/internal/qs/utils.d.mts.map +1 -0
- package/internal/qs/utils.d.ts +14 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +229 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/internal/request-options.d.mts +0 -1
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +0 -1
- package/internal/request-options.d.ts.map +1 -1
- package/internal/shims.js +6 -7
- package/internal/shims.js.map +1 -1
- package/internal/shims.mjs +1 -1
- package/internal/shims.mjs.map +1 -1
- package/internal/to-file.d.mts +0 -1
- package/internal/to-file.d.mts.map +1 -1
- package/internal/to-file.d.ts +0 -1
- package/internal/to-file.d.ts.map +1 -1
- package/internal/to-file.js +4 -4
- package/internal/to-file.js.map +1 -1
- package/internal/to-file.mjs +3 -2
- package/internal/to-file.mjs.map +1 -1
- package/internal/tslib.js +81 -0
- package/internal/tslib.mjs +17 -0
- package/internal/types.d.mts +0 -1
- package/internal/types.d.mts.map +1 -1
- package/internal/types.d.ts +0 -1
- package/internal/types.d.ts.map +1 -1
- package/internal/uploads.d.mts +5 -7
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +5 -7
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js +16 -6
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +12 -3
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/base64.d.mts.map +1 -1
- package/internal/utils/base64.d.ts.map +1 -1
- package/internal/utils/base64.js +14 -9
- package/internal/utils/base64.js.map +1 -1
- package/internal/utils/base64.mjs +15 -10
- package/internal/utils/base64.mjs.map +1 -1
- package/internal/utils/bytes.d.mts +4 -0
- package/internal/utils/bytes.d.mts.map +1 -0
- package/internal/utils/bytes.d.ts +4 -0
- package/internal/utils/bytes.d.ts.map +1 -0
- package/internal/utils/bytes.js +31 -0
- package/internal/utils/bytes.js.map +1 -0
- package/internal/utils/bytes.mjs +26 -0
- package/internal/utils/bytes.mjs.map +1 -0
- package/internal/utils/env.d.mts.map +1 -1
- package/internal/utils/env.d.ts.map +1 -1
- package/internal/utils/env.js.map +1 -1
- package/internal/utils/env.mjs.map +1 -1
- package/internal/utils/log.d.mts +3 -4
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts +3 -4
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js +2 -2
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.d.mts.map +1 -1
- package/internal/utils/path.d.ts.map +1 -1
- package/internal/utils/path.js +3 -3
- package/internal/utils/path.js.map +1 -1
- package/internal/utils/path.mjs +2 -2
- package/internal/utils/path.mjs.map +1 -1
- package/internal/utils/sleep.d.mts.map +1 -1
- package/internal/utils/sleep.d.ts.map +1 -1
- package/internal/utils/uuid.d.mts +1 -1
- package/internal/utils/uuid.d.mts.map +1 -1
- package/internal/utils/uuid.d.ts +1 -1
- package/internal/utils/uuid.d.ts.map +1 -1
- package/internal/utils/uuid.js +1 -2
- package/internal/utils/uuid.js.map +1 -1
- package/internal/utils/uuid.mjs +1 -2
- package/internal/utils/uuid.mjs.map +1 -1
- package/internal/utils/values.d.mts.map +1 -1
- package/internal/utils/values.d.ts.map +1 -1
- package/internal/utils/values.js +10 -10
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +6 -6
- package/internal/utils/values.mjs.map +1 -1
- package/internal/utils.js +7 -20
- package/internal/utils.js.map +1 -1
- package/package.json +5 -9
- package/resource.js +2 -15
- package/resource.js.map +1 -1
- package/resources/auth-configs.d.mts +75 -23
- package/resources/auth-configs.d.mts.map +1 -1
- package/resources/auth-configs.d.ts +75 -23
- package/resources/auth-configs.d.ts.map +1 -1
- package/resources/auth-configs.js +18 -0
- package/resources/auth-configs.js.map +1 -1
- package/resources/auth-configs.mjs +18 -0
- package/resources/auth-configs.mjs.map +1 -1
- package/resources/connected-accounts.d.mts +106 -209
- package/resources/connected-accounts.d.mts.map +1 -1
- package/resources/connected-accounts.d.ts +106 -209
- package/resources/connected-accounts.d.ts.map +1 -1
- package/resources/connected-accounts.js +18 -0
- package/resources/connected-accounts.js.map +1 -1
- package/resources/connected-accounts.mjs +18 -0
- package/resources/connected-accounts.mjs.map +1 -1
- package/resources/files.d.mts +126 -0
- package/resources/files.d.mts.map +1 -0
- package/resources/files.d.ts +126 -0
- package/resources/files.d.ts.map +1 -0
- package/resources/files.js +21 -0
- package/resources/files.js.map +1 -0
- package/resources/files.mjs +17 -0
- package/resources/files.mjs.map +1 -0
- package/resources/index.d.mts +3 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +3 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +7 -5
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +3 -2
- package/resources/index.mjs.map +1 -1
- package/resources/mcp/command.d.mts +37 -0
- package/resources/mcp/command.d.mts.map +1 -0
- package/resources/mcp/command.d.ts +37 -0
- package/resources/mcp/command.d.ts.map +1 -0
- package/resources/mcp/command.js +15 -0
- package/resources/mcp/command.js.map +1 -0
- package/resources/mcp/command.mjs +11 -0
- package/resources/mcp/command.mjs.map +1 -0
- package/resources/mcp/index.d.mts +3 -0
- package/resources/mcp/index.d.mts.map +1 -0
- package/resources/mcp/index.d.ts +3 -0
- package/resources/mcp/index.d.ts.map +1 -0
- package/resources/mcp/index.js +9 -0
- package/resources/mcp/index.js.map +1 -0
- package/resources/mcp/index.mjs +4 -0
- package/resources/mcp/index.mjs.map +1 -0
- package/resources/mcp/mcp.d.mts +414 -0
- package/resources/mcp/mcp.d.mts.map +1 -0
- package/resources/mcp/mcp.d.ts +414 -0
- package/resources/mcp/mcp.d.ts.map +1 -0
- package/resources/mcp/mcp.js +65 -0
- package/resources/mcp/mcp.js.map +1 -0
- package/resources/mcp/mcp.mjs +60 -0
- package/resources/mcp/mcp.mjs.map +1 -0
- package/resources/mcp.d.mts +2 -0
- package/resources/mcp.d.mts.map +1 -0
- package/resources/mcp.d.ts +2 -0
- package/resources/mcp.d.ts.map +1 -0
- package/resources/mcp.js +6 -0
- package/resources/mcp.js.map +1 -0
- package/resources/mcp.mjs +3 -0
- package/resources/mcp.mjs.map +1 -0
- package/resources/migration.d.mts +23 -0
- package/resources/migration.d.mts.map +1 -0
- package/resources/migration.d.ts +23 -0
- package/resources/migration.d.ts.map +1 -0
- package/resources/migration.js +15 -0
- package/resources/migration.js.map +1 -0
- package/resources/migration.mjs +11 -0
- package/resources/migration.mjs.map +1 -0
- package/resources/org/api-key.d.mts +7 -0
- package/resources/org/api-key.d.mts.map +1 -1
- package/resources/org/api-key.d.ts +7 -0
- package/resources/org/api-key.d.ts.map +1 -1
- package/resources/org/api-key.js +7 -0
- package/resources/org/api-key.js.map +1 -1
- package/resources/org/api-key.mjs +7 -0
- package/resources/org/api-key.mjs.map +1 -1
- package/resources/org/org.js +3 -25
- package/resources/org/org.js.map +1 -1
- package/resources/org/project/project.d.mts +9 -6
- package/resources/org/project/project.d.mts.map +1 -1
- package/resources/org/project/project.d.ts +9 -6
- package/resources/org/project/project.d.ts.map +1 -1
- package/resources/org/project/project.js +13 -26
- package/resources/org/project/project.js.map +1 -1
- package/resources/org/project/project.mjs +9 -0
- package/resources/org/project/project.mjs.map +1 -1
- package/resources/org/project/trigger.d.mts +0 -4
- package/resources/org/project/trigger.d.mts.map +1 -1
- package/resources/org/project/trigger.d.ts +0 -4
- package/resources/org/project/trigger.d.ts.map +1 -1
- package/resources/org/project/webhook.d.mts +3 -0
- package/resources/org/project/webhook.d.mts.map +1 -1
- package/resources/org/project/webhook.d.ts +3 -0
- package/resources/org/project/webhook.d.ts.map +1 -1
- package/resources/org/project/webhook.js +3 -0
- package/resources/org/project/webhook.js.map +1 -1
- package/resources/org/project/webhook.mjs +3 -0
- package/resources/org/project/webhook.mjs.map +1 -1
- package/resources/org/project.js +2 -15
- package/resources/org/project.js.map +1 -1
- package/resources/org.js +2 -15
- package/resources/org.js.map +1 -1
- package/resources/team-members.d.mts +12 -0
- package/resources/team-members.d.mts.map +1 -1
- package/resources/team-members.d.ts +12 -0
- package/resources/team-members.d.ts.map +1 -1
- package/resources/team-members.js +12 -0
- package/resources/team-members.js.map +1 -1
- package/resources/team-members.mjs +12 -0
- package/resources/team-members.mjs.map +1 -1
- package/resources/toolkits.d.mts +25 -2
- package/resources/toolkits.d.mts.map +1 -1
- package/resources/toolkits.d.ts +25 -2
- package/resources/toolkits.d.ts.map +1 -1
- package/resources/toolkits.js +10 -0
- package/resources/toolkits.js.map +1 -1
- package/resources/toolkits.mjs +10 -0
- package/resources/toolkits.mjs.map +1 -1
- package/resources/tools.d.mts +107 -0
- package/resources/tools.d.mts.map +1 -1
- package/resources/tools.d.ts +107 -0
- package/resources/tools.d.ts.map +1 -1
- package/resources/tools.js +14 -0
- package/resources/tools.js.map +1 -1
- package/resources/tools.mjs +14 -0
- package/resources/tools.mjs.map +1 -1
- package/resources/trigger-instances/handle.d.mts +2 -2
- package/resources/trigger-instances/handle.d.mts.map +1 -1
- package/resources/trigger-instances/handle.d.ts +2 -2
- package/resources/trigger-instances/handle.d.ts.map +1 -1
- package/resources/trigger-instances/handle.js.map +1 -1
- package/resources/trigger-instances/handle.mjs.map +1 -1
- package/resources/trigger-instances/trigger-instances.d.mts +32 -9
- package/resources/trigger-instances/trigger-instances.d.mts.map +1 -1
- package/resources/trigger-instances/trigger-instances.d.ts +32 -9
- package/resources/trigger-instances/trigger-instances.d.ts.map +1 -1
- package/resources/trigger-instances/trigger-instances.js +2 -24
- package/resources/trigger-instances/trigger-instances.js.map +1 -1
- package/resources/trigger-instances/trigger-instances.mjs.map +1 -1
- package/resources/trigger-instances.js +2 -15
- package/resources/trigger-instances.js.map +1 -1
- package/resources/triggers-types.d.mts +11 -4
- package/resources/triggers-types.d.mts.map +1 -1
- package/resources/triggers-types.d.ts +11 -4
- package/resources/triggers-types.d.ts.map +1 -1
- package/resources/triggers-types.js +7 -0
- package/resources/triggers-types.js.map +1 -1
- package/resources/triggers-types.mjs +7 -0
- package/resources/triggers-types.mjs.map +1 -1
- package/resources.js +2 -15
- package/resources.js.map +1 -1
- package/src/client.ts +132 -88
- package/src/core/api-promise.ts +4 -4
- package/src/core/error.ts +2 -2
- package/src/core/resource.ts +3 -3
- package/src/index.ts +3 -3
- package/src/internal/headers.ts +4 -3
- package/src/internal/parse.ts +2 -2
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +9 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +388 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/internal/shims.ts +1 -1
- package/src/internal/to-file.ts +4 -2
- package/src/internal/uploads.ts +21 -9
- package/src/internal/utils/base64.ts +16 -13
- package/src/internal/utils/bytes.ts +32 -0
- package/src/internal/utils/log.ts +3 -3
- package/src/internal/utils/path.ts +2 -4
- package/src/internal/utils/uuid.ts +1 -3
- package/src/internal/utils/values.ts +6 -6
- package/src/resources/auth-configs.ts +100 -31
- package/src/resources/connected-accounts.ts +122 -295
- package/src/resources/files.ts +176 -0
- package/src/resources/index.ts +26 -8
- package/src/resources/mcp/command.ts +50 -0
- package/src/resources/mcp/index.ts +17 -0
- package/src/resources/mcp/mcp.ts +562 -0
- package/src/resources/mcp.ts +3 -0
- package/src/resources/migration.ts +37 -0
- package/src/resources/org/api-key.ts +7 -0
- package/src/resources/org/project/project.ts +9 -12
- package/src/resources/org/project/trigger.ts +0 -8
- package/src/resources/org/project/webhook.ts +3 -0
- package/src/resources/team-members.ts +12 -0
- package/src/resources/toolkits.ts +35 -2
- package/src/resources/tools.ts +128 -0
- package/src/resources/trigger-instances/handle.ts +10 -2
- package/src/resources/trigger-instances/trigger-instances.ts +36 -9
- package/src/resources/triggers-types.ts +13 -6
- package/src/version.ts +1 -1
- package/uploads.js +2 -15
- package/uploads.js.map +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- 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/internal/shims/crypto.d.mts +0 -13
- package/internal/shims/crypto.d.mts.map +0 -1
- package/internal/shims/crypto.d.ts +0 -13
- package/internal/shims/crypto.d.ts.map +0 -1
- package/internal/shims/crypto.js +0 -13
- package/internal/shims/crypto.js.map +0 -1
- package/internal/shims/crypto.mjs +0 -9
- package/internal/shims/crypto.mjs.map +0 -1
- package/internal/shims/file.d.mts +0 -23
- package/internal/shims/file.d.mts.map +0 -1
- package/internal/shims/file.d.ts +0 -23
- package/internal/shims/file.d.ts.map +0 -1
- package/internal/shims/file.js +0 -16
- package/internal/shims/file.js.map +0 -1
- package/internal/shims/file.mjs +0 -12
- package/internal/shims/file.mjs.map +0 -1
- package/internal/shims/getBuiltinModule.d.mts +0 -11
- package/internal/shims/getBuiltinModule.d.mts.map +0 -1
- package/internal/shims/getBuiltinModule.d.ts +0 -11
- package/internal/shims/getBuiltinModule.d.ts.map +0 -1
- package/internal/shims/getBuiltinModule.js +0 -68
- package/internal/shims/getBuiltinModule.js.map +0 -1
- package/internal/shims/getBuiltinModule.mjs +0 -64
- package/internal/shims/getBuiltinModule.mjs.map +0 -1
- package/internal/shims/nullGetBuiltinModule.d.mts +0 -2
- package/internal/shims/nullGetBuiltinModule.d.mts.map +0 -1
- package/internal/shims/nullGetBuiltinModule.d.ts +0 -2
- package/internal/shims/nullGetBuiltinModule.d.ts.map +0 -1
- package/internal/shims/nullGetBuiltinModule.js +0 -5
- package/internal/shims/nullGetBuiltinModule.js.map +0 -1
- package/internal/shims/nullGetBuiltinModule.mjs +0 -2
- package/internal/shims/nullGetBuiltinModule.mjs.map +0 -1
- package/resources/action-execution.d.mts +0 -155
- package/resources/action-execution.d.mts.map +0 -1
- package/resources/action-execution.d.ts +0 -155
- package/resources/action-execution.d.ts.map +0 -1
- package/resources/action-execution.js +0 -19
- package/resources/action-execution.js.map +0 -1
- package/resources/action-execution.mjs +0 -15
- package/resources/action-execution.mjs.map +0 -1
- package/resources/trigger.d.mts +0 -73
- package/resources/trigger.d.mts.map +0 -1
- package/resources/trigger.d.ts +0 -73
- package/resources/trigger.d.ts.map +0 -1
- package/resources/trigger.js +0 -12
- package/resources/trigger.js.map +0 -1
- package/resources/trigger.mjs +0 -8
- package/resources/trigger.mjs.map +0 -1
- package/src/internal/shims/crypto.ts +0 -18
- package/src/internal/shims/file.ts +0 -32
- package/src/internal/shims/getBuiltinModule.ts +0 -64
- package/src/internal/shims/nullGetBuiltinModule.ts +0 -1
- package/src/resources/action-execution.ts +0 -244
- package/src/resources/trigger.ts +0 -108
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { RFC1738 } from './formats';
|
|
2
|
+
import type { DefaultEncoder, Format } from './types';
|
|
3
|
+
|
|
4
|
+
const has = Object.prototype.hasOwnProperty;
|
|
5
|
+
const is_array = Array.isArray;
|
|
6
|
+
|
|
7
|
+
const hex_table = (() => {
|
|
8
|
+
const array = [];
|
|
9
|
+
for (let i = 0; i < 256; ++i) {
|
|
10
|
+
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return array;
|
|
14
|
+
})();
|
|
15
|
+
|
|
16
|
+
function compact_queue<T extends Record<string, any>>(queue: Array<{ obj: T; prop: string }>) {
|
|
17
|
+
while (queue.length > 1) {
|
|
18
|
+
const item = queue.pop();
|
|
19
|
+
if (!item) continue;
|
|
20
|
+
|
|
21
|
+
const obj = item.obj[item.prop];
|
|
22
|
+
|
|
23
|
+
if (is_array(obj)) {
|
|
24
|
+
const compacted: unknown[] = [];
|
|
25
|
+
|
|
26
|
+
for (let j = 0; j < obj.length; ++j) {
|
|
27
|
+
if (typeof obj[j] !== 'undefined') {
|
|
28
|
+
compacted.push(obj[j]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
item.obj[item.prop] = compacted;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function array_to_object(source: any[], options: { plainObjects: boolean }) {
|
|
39
|
+
const obj = options && options.plainObjects ? Object.create(null) : {};
|
|
40
|
+
for (let i = 0; i < source.length; ++i) {
|
|
41
|
+
if (typeof source[i] !== 'undefined') {
|
|
42
|
+
obj[i] = source[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return obj;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function merge(
|
|
50
|
+
target: any,
|
|
51
|
+
source: any,
|
|
52
|
+
options: { plainObjects?: boolean; allowPrototypes?: boolean } = {},
|
|
53
|
+
) {
|
|
54
|
+
if (!source) {
|
|
55
|
+
return target;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (typeof source !== 'object') {
|
|
59
|
+
if (is_array(target)) {
|
|
60
|
+
target.push(source);
|
|
61
|
+
} else if (target && typeof target === 'object') {
|
|
62
|
+
if (
|
|
63
|
+
(options && (options.plainObjects || options.allowPrototypes)) ||
|
|
64
|
+
!has.call(Object.prototype, source)
|
|
65
|
+
) {
|
|
66
|
+
target[source] = true;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
return [target, source];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!target || typeof target !== 'object') {
|
|
76
|
+
return [target].concat(source);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let mergeTarget = target;
|
|
80
|
+
if (is_array(target) && !is_array(source)) {
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
mergeTarget = array_to_object(target, options);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (is_array(target) && is_array(source)) {
|
|
86
|
+
source.forEach(function (item, i) {
|
|
87
|
+
if (has.call(target, i)) {
|
|
88
|
+
const targetItem = target[i];
|
|
89
|
+
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
90
|
+
target[i] = merge(targetItem, item, options);
|
|
91
|
+
} else {
|
|
92
|
+
target.push(item);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
target[i] = item;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
102
|
+
const value = source[key];
|
|
103
|
+
|
|
104
|
+
if (has.call(acc, key)) {
|
|
105
|
+
acc[key] = merge(acc[key], value, options);
|
|
106
|
+
} else {
|
|
107
|
+
acc[key] = value;
|
|
108
|
+
}
|
|
109
|
+
return acc;
|
|
110
|
+
}, mergeTarget);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function assign_single_source(target: any, source: any) {
|
|
114
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
115
|
+
acc[key] = source[key];
|
|
116
|
+
return acc;
|
|
117
|
+
}, target);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function decode(str: string, _: any, charset: string) {
|
|
121
|
+
const strWithoutPlus = str.replace(/\+/g, ' ');
|
|
122
|
+
if (charset === 'iso-8859-1') {
|
|
123
|
+
// unescape never throws, no try...catch needed:
|
|
124
|
+
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
|
125
|
+
}
|
|
126
|
+
// utf-8
|
|
127
|
+
try {
|
|
128
|
+
return decodeURIComponent(strWithoutPlus);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return strWithoutPlus;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const limit = 1024;
|
|
135
|
+
|
|
136
|
+
export const encode: (
|
|
137
|
+
str: any,
|
|
138
|
+
defaultEncoder: DefaultEncoder,
|
|
139
|
+
charset: string,
|
|
140
|
+
type: 'key' | 'value',
|
|
141
|
+
format: Format,
|
|
142
|
+
) => string = (str, _defaultEncoder, charset, _kind, format: Format) => {
|
|
143
|
+
// This code was originally written by Brian White for the io.js core querystring library.
|
|
144
|
+
// It has been adapted here for stricter adherence to RFC 3986
|
|
145
|
+
if (str.length === 0) {
|
|
146
|
+
return str;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let string = str;
|
|
150
|
+
if (typeof str === 'symbol') {
|
|
151
|
+
string = Symbol.prototype.toString.call(str);
|
|
152
|
+
} else if (typeof str !== 'string') {
|
|
153
|
+
string = String(str);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (charset === 'iso-8859-1') {
|
|
157
|
+
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
|
158
|
+
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let out = '';
|
|
163
|
+
for (let j = 0; j < string.length; j += limit) {
|
|
164
|
+
const segment = string.length >= limit ? string.slice(j, j + limit) : string;
|
|
165
|
+
const arr = [];
|
|
166
|
+
|
|
167
|
+
for (let i = 0; i < segment.length; ++i) {
|
|
168
|
+
let c = segment.charCodeAt(i);
|
|
169
|
+
if (
|
|
170
|
+
c === 0x2d || // -
|
|
171
|
+
c === 0x2e || // .
|
|
172
|
+
c === 0x5f || // _
|
|
173
|
+
c === 0x7e || // ~
|
|
174
|
+
(c >= 0x30 && c <= 0x39) || // 0-9
|
|
175
|
+
(c >= 0x41 && c <= 0x5a) || // a-z
|
|
176
|
+
(c >= 0x61 && c <= 0x7a) || // A-Z
|
|
177
|
+
(format === RFC1738 && (c === 0x28 || c === 0x29)) // ( )
|
|
178
|
+
) {
|
|
179
|
+
arr[arr.length] = segment.charAt(i);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (c < 0x80) {
|
|
184
|
+
arr[arr.length] = hex_table[c];
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (c < 0x800) {
|
|
189
|
+
arr[arr.length] = hex_table[0xc0 | (c >> 6)]! + hex_table[0x80 | (c & 0x3f)];
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (c < 0xd800 || c >= 0xe000) {
|
|
194
|
+
arr[arr.length] =
|
|
195
|
+
hex_table[0xe0 | (c >> 12)]! + hex_table[0x80 | ((c >> 6) & 0x3f)] + hex_table[0x80 | (c & 0x3f)];
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
i += 1;
|
|
200
|
+
c = 0x10000 + (((c & 0x3ff) << 10) | (segment.charCodeAt(i) & 0x3ff));
|
|
201
|
+
|
|
202
|
+
arr[arr.length] =
|
|
203
|
+
hex_table[0xf0 | (c >> 18)]! +
|
|
204
|
+
hex_table[0x80 | ((c >> 12) & 0x3f)] +
|
|
205
|
+
hex_table[0x80 | ((c >> 6) & 0x3f)] +
|
|
206
|
+
hex_table[0x80 | (c & 0x3f)];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
out += arr.join('');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return out;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export function compact(value: any) {
|
|
216
|
+
const queue = [{ obj: { o: value }, prop: 'o' }];
|
|
217
|
+
const refs = [];
|
|
218
|
+
|
|
219
|
+
for (let i = 0; i < queue.length; ++i) {
|
|
220
|
+
const item = queue[i];
|
|
221
|
+
// @ts-ignore
|
|
222
|
+
const obj = item.obj[item.prop];
|
|
223
|
+
|
|
224
|
+
const keys = Object.keys(obj);
|
|
225
|
+
for (let j = 0; j < keys.length; ++j) {
|
|
226
|
+
const key = keys[j]!;
|
|
227
|
+
const val = obj[key];
|
|
228
|
+
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
229
|
+
queue.push({ obj: obj, prop: key });
|
|
230
|
+
refs.push(val);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
compact_queue(queue);
|
|
236
|
+
|
|
237
|
+
return value;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function is_regexp(obj: any) {
|
|
241
|
+
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function is_buffer(obj: any) {
|
|
245
|
+
if (!obj || typeof obj !== 'object') {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function combine(a: any, b: any) {
|
|
253
|
+
return [].concat(a, b);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function maybe_map<T>(val: T[], fn: (v: T) => T) {
|
|
257
|
+
if (is_array(val)) {
|
|
258
|
+
const mapped = [];
|
|
259
|
+
for (let i = 0; i < val.length; i += 1) {
|
|
260
|
+
mapped.push(fn(val[i]!));
|
|
261
|
+
}
|
|
262
|
+
return mapped;
|
|
263
|
+
}
|
|
264
|
+
return fn(val);
|
|
265
|
+
}
|
package/src/internal/shims.ts
CHANGED
|
@@ -16,7 +16,7 @@ export function getDefaultFetch(): Fetch {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
throw new Error(
|
|
19
|
-
'`fetch` is not defined as a global; Either pass `fetch` to the client, `new
|
|
19
|
+
'`fetch` is not defined as a global; Either pass `fetch` to the client, `new Composio({ fetch })` or polyfill the global, `globalThis.fetch = fetch`',
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
|
package/src/internal/to-file.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type File, getFile } from './shims/file';
|
|
2
1
|
import { BlobPart, getName, makeFile, isAsyncIterable } from './uploads';
|
|
3
2
|
import type { FilePropertyBag } from './builtin-types';
|
|
3
|
+
import { checkFileSupport } from './uploads';
|
|
4
4
|
|
|
5
5
|
type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | DataView;
|
|
6
6
|
|
|
@@ -85,12 +85,14 @@ export async function toFile(
|
|
|
85
85
|
name?: string | null | undefined,
|
|
86
86
|
options?: FilePropertyBag | undefined,
|
|
87
87
|
): Promise<File> {
|
|
88
|
+
checkFileSupport();
|
|
89
|
+
|
|
88
90
|
// If it's a promise, resolve it.
|
|
89
91
|
value = await value;
|
|
90
92
|
|
|
91
93
|
// If we've been given a `File` we don't need to do anything
|
|
92
94
|
if (isFileLike(value)) {
|
|
93
|
-
if (value instanceof
|
|
95
|
+
if (value instanceof File) {
|
|
94
96
|
return value;
|
|
95
97
|
}
|
|
96
98
|
return makeFile([await value.arrayBuffer()], value.name);
|
package/src/internal/uploads.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type RequestOptions } from './request-options';
|
|
2
2
|
import type { FilePropertyBag, Fetch } from './builtin-types';
|
|
3
|
-
import type {
|
|
4
|
-
import { type File, getFile } from './shims/file';
|
|
3
|
+
import type { Composio } from '../client';
|
|
5
4
|
import { ReadableStreamFrom } from './shims';
|
|
6
5
|
|
|
7
6
|
export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | DataView;
|
|
@@ -12,6 +11,20 @@ interface BunFile extends Blob {
|
|
|
12
11
|
readonly name?: string | undefined;
|
|
13
12
|
}
|
|
14
13
|
|
|
14
|
+
export const checkFileSupport = () => {
|
|
15
|
+
if (typeof File === 'undefined') {
|
|
16
|
+
const { process } = globalThis as any;
|
|
17
|
+
const isOldNode =
|
|
18
|
+
typeof process?.versions?.node === 'string' && parseInt(process.versions.node.split('.')) < 20;
|
|
19
|
+
throw new Error(
|
|
20
|
+
'`File` is not defined as a global, which is required for file uploads.' +
|
|
21
|
+
(isOldNode ?
|
|
22
|
+
" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`."
|
|
23
|
+
: ''),
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
15
28
|
/**
|
|
16
29
|
* Typically, this is a native "File" class.
|
|
17
30
|
*
|
|
@@ -32,7 +45,7 @@ export function makeFile(
|
|
|
32
45
|
fileName: string | undefined,
|
|
33
46
|
options?: FilePropertyBag,
|
|
34
47
|
): File {
|
|
35
|
-
|
|
48
|
+
checkFileSupport();
|
|
36
49
|
return new File(fileBits as any, fileName ?? 'unknown_file', options);
|
|
37
50
|
}
|
|
38
51
|
|
|
@@ -61,7 +74,7 @@ export const isAsyncIterable = (value: any): value is AsyncIterable<any> =>
|
|
|
61
74
|
*/
|
|
62
75
|
export const maybeMultipartFormRequestOptions = async (
|
|
63
76
|
opts: RequestOptions,
|
|
64
|
-
fetch:
|
|
77
|
+
fetch: Composio | Fetch,
|
|
65
78
|
): Promise<RequestOptions> => {
|
|
66
79
|
if (!hasUploadableValue(opts.body)) return opts;
|
|
67
80
|
|
|
@@ -72,7 +85,7 @@ type MultipartFormRequestOptions = Omit<RequestOptions, 'body'> & { body: unknow
|
|
|
72
85
|
|
|
73
86
|
export const multipartFormRequestOptions = async (
|
|
74
87
|
opts: MultipartFormRequestOptions,
|
|
75
|
-
fetch:
|
|
88
|
+
fetch: Composio | Fetch,
|
|
76
89
|
): Promise<RequestOptions> => {
|
|
77
90
|
return { ...opts, body: await createForm(opts.body, fetch) };
|
|
78
91
|
};
|
|
@@ -85,7 +98,7 @@ const supportsFormDataMap = new WeakMap<Fetch, Promise<boolean>>();
|
|
|
85
98
|
* This function detects if the fetch function provided supports the global FormData object to avoid
|
|
86
99
|
* confusing error messages later on.
|
|
87
100
|
*/
|
|
88
|
-
function supportsFormData(fetchObject:
|
|
101
|
+
function supportsFormData(fetchObject: Composio | Fetch): Promise<boolean> {
|
|
89
102
|
const fetch: Fetch = typeof fetchObject === 'function' ? fetchObject : (fetchObject as any).fetch;
|
|
90
103
|
const cached = supportsFormDataMap.get(fetch);
|
|
91
104
|
if (cached) return cached;
|
|
@@ -111,7 +124,7 @@ function supportsFormData(fetchObject: ComposioSDK | Fetch): Promise<boolean> {
|
|
|
111
124
|
|
|
112
125
|
export const createForm = async <T = Record<string, unknown>>(
|
|
113
126
|
body: T | undefined,
|
|
114
|
-
fetch:
|
|
127
|
+
fetch: Composio | Fetch,
|
|
115
128
|
): Promise<FormData> => {
|
|
116
129
|
if (!(await supportsFormData(fetch))) {
|
|
117
130
|
throw new TypeError(
|
|
@@ -125,8 +138,7 @@ export const createForm = async <T = Record<string, unknown>>(
|
|
|
125
138
|
|
|
126
139
|
// We check for Blob not File because Bun.File doesn't inherit from File,
|
|
127
140
|
// but they both inherit from Blob and have a `name` property at runtime.
|
|
128
|
-
const isNamedBlob = (value: object) =>
|
|
129
|
-
value instanceof getFile() || (value instanceof Blob && 'name' in value);
|
|
141
|
+
const isNamedBlob = (value: object) => value instanceof Blob && 'name' in value;
|
|
130
142
|
|
|
131
143
|
const isUploadable = (value: unknown) =>
|
|
132
144
|
typeof value === 'object' &&
|
|
@@ -1,37 +1,40 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ComposioError } from '../../core/error';
|
|
4
|
+
import { encodeUTF8 } from './bytes';
|
|
4
5
|
|
|
5
6
|
export const toBase64 = (data: string | Uint8Array | null | undefined): string => {
|
|
6
7
|
if (!data) return '';
|
|
7
8
|
|
|
8
|
-
if (typeof data === 'string') {
|
|
9
|
-
data = new (globalThis as any).TextEncoder().encode(data);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
9
|
if (typeof (globalThis as any).Buffer !== 'undefined') {
|
|
13
10
|
return (globalThis as any).Buffer.from(data).toString('base64');
|
|
14
11
|
}
|
|
15
12
|
|
|
13
|
+
if (typeof data === 'string') {
|
|
14
|
+
data = encodeUTF8(data);
|
|
15
|
+
}
|
|
16
|
+
|
|
16
17
|
if (typeof btoa !== 'undefined') {
|
|
17
18
|
return btoa(String.fromCharCode.apply(null, data as any));
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
throw new
|
|
21
|
+
throw new ComposioError('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
export const fromBase64 = (str: string): Uint8Array => {
|
|
24
25
|
if (typeof (globalThis as any).Buffer !== 'undefined') {
|
|
25
|
-
|
|
26
|
+
const buf = (globalThis as any).Buffer.from(str, 'base64');
|
|
27
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
if (typeof atob !== 'undefined') {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const bstr = atob(str);
|
|
32
|
+
const buf = new Uint8Array(bstr.length);
|
|
33
|
+
for (let i = 0; i < bstr.length; i++) {
|
|
34
|
+
buf[i] = bstr.charCodeAt(i);
|
|
35
|
+
}
|
|
36
|
+
return buf;
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
throw new
|
|
39
|
+
throw new ComposioError('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
|
|
37
40
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function concatBytes(buffers: Uint8Array[]): Uint8Array {
|
|
2
|
+
let length = 0;
|
|
3
|
+
for (const buffer of buffers) {
|
|
4
|
+
length += buffer.length;
|
|
5
|
+
}
|
|
6
|
+
const output = new Uint8Array(length);
|
|
7
|
+
let index = 0;
|
|
8
|
+
for (const buffer of buffers) {
|
|
9
|
+
output.set(buffer, index);
|
|
10
|
+
index += buffer.length;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return output;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let encodeUTF8_: (str: string) => Uint8Array;
|
|
17
|
+
export function encodeUTF8(str: string) {
|
|
18
|
+
let encoder;
|
|
19
|
+
return (
|
|
20
|
+
encodeUTF8_ ??
|
|
21
|
+
((encoder = new (globalThis as any).TextEncoder()), (encodeUTF8_ = encoder.encode.bind(encoder)))
|
|
22
|
+
)(str);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let decodeUTF8_: (bytes: Uint8Array) => string;
|
|
26
|
+
export function decodeUTF8(bytes: Uint8Array) {
|
|
27
|
+
let decoder;
|
|
28
|
+
return (
|
|
29
|
+
decodeUTF8_ ??
|
|
30
|
+
((decoder = new (globalThis as any).TextDecoder()), (decodeUTF8_ = decoder.decode.bind(decoder)))
|
|
31
|
+
)(bytes);
|
|
32
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import { hasOwn } from './values';
|
|
4
|
-
import { type
|
|
4
|
+
import { type Composio } from '../../client';
|
|
5
5
|
import { RequestOptions } from '../request-options';
|
|
6
6
|
|
|
7
7
|
type LogFn = (message: string, ...rest: unknown[]) => void;
|
|
@@ -24,7 +24,7 @@ const levelNumbers = {
|
|
|
24
24
|
export const parseLogLevel = (
|
|
25
25
|
maybeLevel: string | undefined,
|
|
26
26
|
sourceName: string,
|
|
27
|
-
client:
|
|
27
|
+
client: Composio,
|
|
28
28
|
): LogLevel | undefined => {
|
|
29
29
|
if (!maybeLevel) {
|
|
30
30
|
return undefined;
|
|
@@ -60,7 +60,7 @@ const noopLogger = {
|
|
|
60
60
|
|
|
61
61
|
let cachedLoggers = new WeakMap<Logger, [LogLevel, Logger]>();
|
|
62
62
|
|
|
63
|
-
export function loggerFor(client:
|
|
63
|
+
export function loggerFor(client: Composio): Logger {
|
|
64
64
|
const logger = client.logger;
|
|
65
65
|
const logLevel = client.logLevel ?? 'off';
|
|
66
66
|
if (!logger) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComposioError } from '../../core/error';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Percent-encode everything that isn't safe to have in a path without encoding safe chars.
|
|
@@ -51,9 +51,7 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
|
|
|
51
51
|
return acc + spaces + arrows;
|
|
52
52
|
}, '');
|
|
53
53
|
|
|
54
|
-
throw new
|
|
55
|
-
`Path parameters result in path with invalid segments:\n${path}\n${underline}`,
|
|
56
|
-
);
|
|
54
|
+
throw new ComposioError(`Path parameters result in path with invalid segments:\n${path}\n${underline}`);
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
return path;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { getCrypto } from '../shims/crypto';
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* https://stackoverflow.com/a/2117523
|
|
7
5
|
*/
|
|
8
6
|
export let uuid4 = function () {
|
|
9
|
-
const crypto =
|
|
7
|
+
const { crypto } = globalThis as any;
|
|
10
8
|
if (crypto?.randomUUID) {
|
|
11
9
|
uuid4 = crypto.randomUUID.bind(crypto);
|
|
12
10
|
return crypto.randomUUID();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ComposioError } from '../../core/error';
|
|
4
4
|
|
|
5
5
|
// https://url.spec.whatwg.org/#url-scheme-string
|
|
6
6
|
const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
|
|
@@ -36,7 +36,7 @@ export function isObj(obj: unknown): obj is Record<string, unknown> {
|
|
|
36
36
|
|
|
37
37
|
export const ensurePresent = <T>(value: T | null | undefined): T => {
|
|
38
38
|
if (value == null) {
|
|
39
|
-
throw new
|
|
39
|
+
throw new ComposioError(`Expected a value to be given but received ${value} instead.`);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
return value;
|
|
@@ -44,10 +44,10 @@ export const ensurePresent = <T>(value: T | null | undefined): T => {
|
|
|
44
44
|
|
|
45
45
|
export const validatePositiveInteger = (name: string, n: unknown): number => {
|
|
46
46
|
if (typeof n !== 'number' || !Number.isInteger(n)) {
|
|
47
|
-
throw new
|
|
47
|
+
throw new ComposioError(`${name} must be an integer`);
|
|
48
48
|
}
|
|
49
49
|
if (n < 0) {
|
|
50
|
-
throw new
|
|
50
|
+
throw new ComposioError(`${name} must be a positive integer`);
|
|
51
51
|
}
|
|
52
52
|
return n;
|
|
53
53
|
};
|
|
@@ -56,14 +56,14 @@ export const coerceInteger = (value: unknown): number => {
|
|
|
56
56
|
if (typeof value === 'number') return Math.round(value);
|
|
57
57
|
if (typeof value === 'string') return parseInt(value, 10);
|
|
58
58
|
|
|
59
|
-
throw new
|
|
59
|
+
throw new ComposioError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
export const coerceFloat = (value: unknown): number => {
|
|
63
63
|
if (typeof value === 'number') return value;
|
|
64
64
|
if (typeof value === 'string') return parseFloat(value);
|
|
65
65
|
|
|
66
|
-
throw new
|
|
66
|
+
throw new ComposioError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
export const coerceBoolean = (value: unknown): boolean => {
|