@alienplatform/manager-api 3.3.1 → 3.3.3
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/.devcontainer/devcontainer.json +45 -0
- package/FUNCTIONS.md +2 -2
- package/README.md +29 -28
- package/esm/funcs/bindingsResolveBinding.d.ts +12 -0
- package/esm/funcs/bindingsResolveBinding.d.ts.map +1 -0
- package/esm/funcs/bindingsResolveBinding.js +76 -0
- package/esm/funcs/bindingsResolveBinding.js.map +1 -0
- package/esm/funcs/commandsCreateCommand.d.ts.map +1 -1
- package/esm/funcs/commandsCreateCommand.js +1 -2
- package/esm/funcs/commandsCreateCommand.js.map +1 -1
- package/esm/funcs/commandsGetCommandPayload.d.ts.map +1 -1
- package/esm/funcs/commandsGetCommandPayload.js +1 -2
- package/esm/funcs/commandsGetCommandPayload.js.map +1 -1
- package/esm/funcs/commandsGetCommandStatus.d.ts.map +1 -1
- package/esm/funcs/commandsGetCommandStatus.js +1 -2
- package/esm/funcs/commandsGetCommandStatus.js.map +1 -1
- package/esm/funcs/commandsStoreCommandPayload.d.ts.map +1 -1
- package/esm/funcs/commandsStoreCommandPayload.js +1 -2
- package/esm/funcs/commandsStoreCommandPayload.js.map +1 -1
- package/esm/funcs/commandsSubmitResponse.d.ts.map +1 -1
- package/esm/funcs/commandsSubmitResponse.js +1 -2
- package/esm/funcs/commandsSubmitResponse.js.map +1 -1
- package/esm/funcs/commandsUploadComplete.d.ts.map +1 -1
- package/esm/funcs/commandsUploadComplete.js +1 -2
- package/esm/funcs/commandsUploadComplete.js.map +1 -1
- package/esm/funcs/credentialsMintCredentials.d.ts.map +1 -1
- package/esm/funcs/credentialsMintCredentials.js +1 -2
- package/esm/funcs/credentialsMintCredentials.js.map +1 -1
- package/esm/funcs/deploymentGroupsCreateDeploymentGroup.d.ts.map +1 -1
- package/esm/funcs/deploymentGroupsCreateDeploymentGroup.js +1 -2
- package/esm/funcs/deploymentGroupsCreateDeploymentGroup.js.map +1 -1
- package/esm/funcs/deploymentGroupsCreateDeploymentGroupToken.d.ts.map +1 -1
- package/esm/funcs/deploymentGroupsCreateDeploymentGroupToken.js +1 -2
- package/esm/funcs/deploymentGroupsCreateDeploymentGroupToken.js.map +1 -1
- package/esm/funcs/deploymentGroupsGetDeploymentGroup.d.ts.map +1 -1
- package/esm/funcs/deploymentGroupsGetDeploymentGroup.js +1 -2
- package/esm/funcs/deploymentGroupsGetDeploymentGroup.js.map +1 -1
- package/esm/funcs/deploymentGroupsListDeploymentGroups.d.ts.map +1 -1
- package/esm/funcs/deploymentGroupsListDeploymentGroups.js +1 -2
- package/esm/funcs/deploymentGroupsListDeploymentGroups.js.map +1 -1
- package/esm/funcs/deploymentsCreateDeployment.d.ts.map +1 -1
- package/esm/funcs/deploymentsCreateDeployment.js +1 -2
- package/esm/funcs/deploymentsCreateDeployment.js.map +1 -1
- package/esm/funcs/deploymentsDeleteDeployment.d.ts.map +1 -1
- package/esm/funcs/deploymentsDeleteDeployment.js +1 -2
- package/esm/funcs/deploymentsDeleteDeployment.js.map +1 -1
- package/esm/funcs/deploymentsGetDeployment.d.ts.map +1 -1
- package/esm/funcs/deploymentsGetDeployment.js +1 -2
- package/esm/funcs/deploymentsGetDeployment.js.map +1 -1
- package/esm/funcs/deploymentsGetDeploymentInfo.d.ts.map +1 -1
- package/esm/funcs/deploymentsGetDeploymentInfo.js +1 -2
- package/esm/funcs/deploymentsGetDeploymentInfo.js.map +1 -1
- package/esm/funcs/deploymentsListDeployments.d.ts.map +1 -1
- package/esm/funcs/deploymentsListDeployments.js +1 -2
- package/esm/funcs/deploymentsListDeployments.js.map +1 -1
- package/esm/funcs/deploymentsRedeploy.d.ts.map +1 -1
- package/esm/funcs/deploymentsRedeploy.js +1 -2
- package/esm/funcs/deploymentsRedeploy.js.map +1 -1
- package/esm/funcs/deploymentsRetryDeployment.d.ts.map +1 -1
- package/esm/funcs/deploymentsRetryDeployment.js +1 -2
- package/esm/funcs/deploymentsRetryDeployment.js.map +1 -1
- package/esm/funcs/healthHealth.d.ts.map +1 -1
- package/esm/funcs/healthHealth.js +1 -2
- package/esm/funcs/healthHealth.js.map +1 -1
- package/esm/funcs/leasesAcquireLeases.d.ts.map +1 -1
- package/esm/funcs/leasesAcquireLeases.js +1 -2
- package/esm/funcs/leasesAcquireLeases.js.map +1 -1
- package/esm/funcs/leasesReleaseLease.d.ts.map +1 -1
- package/esm/funcs/leasesReleaseLease.js +1 -2
- package/esm/funcs/leasesReleaseLease.js.map +1 -1
- package/esm/funcs/releasesCreateRelease.d.ts.map +1 -1
- package/esm/funcs/releasesCreateRelease.js +1 -2
- package/esm/funcs/releasesCreateRelease.js.map +1 -1
- package/esm/funcs/releasesGetLatestRelease.d.ts.map +1 -1
- package/esm/funcs/releasesGetLatestRelease.js +1 -2
- package/esm/funcs/releasesGetLatestRelease.js.map +1 -1
- package/esm/funcs/releasesGetRelease.d.ts.map +1 -1
- package/esm/funcs/releasesGetRelease.js +1 -2
- package/esm/funcs/releasesGetRelease.js.map +1 -1
- package/esm/funcs/releasesListReleases.d.ts.map +1 -1
- package/esm/funcs/releasesListReleases.js +1 -2
- package/esm/funcs/releasesListReleases.js.map +1 -1
- package/esm/funcs/stackImportStackImport.d.ts.map +1 -1
- package/esm/funcs/stackImportStackImport.js +1 -2
- package/esm/funcs/stackImportStackImport.js.map +1 -1
- package/esm/funcs/syncAcquire.d.ts.map +1 -1
- package/esm/funcs/syncAcquire.js +1 -2
- package/esm/funcs/syncAcquire.js.map +1 -1
- package/esm/funcs/syncAgentSync.d.ts.map +1 -1
- package/esm/funcs/syncAgentSync.js +1 -2
- package/esm/funcs/syncAgentSync.js.map +1 -1
- package/esm/funcs/syncInitialize.d.ts.map +1 -1
- package/esm/funcs/syncInitialize.js +1 -2
- package/esm/funcs/syncInitialize.js.map +1 -1
- package/esm/funcs/syncReconcile.d.ts.map +1 -1
- package/esm/funcs/syncReconcile.js +1 -2
- package/esm/funcs/syncReconcile.js.map +1 -1
- package/esm/funcs/syncRelease.d.ts.map +1 -1
- package/esm/funcs/syncRelease.js +1 -2
- package/esm/funcs/syncRelease.js.map +1 -1
- package/esm/funcs/{credentialsResolveCredentials.d.ts → syncRenew.d.ts} +5 -2
- package/esm/funcs/syncRenew.d.ts.map +1 -0
- package/esm/funcs/{credentialsResolveCredentials.js → syncRenew.js} +12 -9
- package/esm/funcs/syncRenew.js.map +1 -0
- package/esm/funcs/whoamiWhoami.d.ts.map +1 -1
- package/esm/funcs/whoamiWhoami.js +1 -2
- package/esm/funcs/whoamiWhoami.js.map +1 -1
- package/esm/hooks/types.d.ts +0 -1
- package/esm/hooks/types.d.ts.map +1 -1
- package/esm/lib/config.d.ts +11 -3
- package/esm/lib/config.d.ts.map +1 -1
- package/esm/lib/config.js +16 -6
- package/esm/lib/config.js.map +1 -1
- package/esm/lib/dlv.d.ts +14 -0
- package/esm/lib/dlv.d.ts.map +1 -0
- package/esm/lib/dlv.js +46 -0
- package/esm/lib/dlv.js.map +1 -0
- package/esm/lib/encodings.d.ts +0 -1
- package/esm/lib/encodings.d.ts.map +1 -1
- package/esm/lib/encodings.js +6 -27
- package/esm/lib/encodings.js.map +1 -1
- package/esm/lib/env.d.ts.map +1 -1
- package/esm/lib/env.js +3 -3
- package/esm/lib/env.js.map +1 -1
- package/esm/lib/files.d.ts +0 -13
- package/esm/lib/files.d.ts.map +1 -1
- package/esm/lib/files.js +0 -18
- package/esm/lib/files.js.map +1 -1
- package/esm/lib/http.d.ts +1 -1
- package/esm/lib/http.d.ts.map +1 -1
- package/esm/lib/http.js +1 -1
- package/esm/lib/http.js.map +1 -1
- package/esm/lib/is-plain-object.d.ts +2 -0
- package/esm/lib/is-plain-object.d.ts.map +1 -0
- package/esm/lib/is-plain-object.js +38 -0
- package/esm/lib/is-plain-object.js.map +1 -0
- package/esm/lib/matchers.d.ts.map +1 -1
- package/esm/lib/matchers.js +2 -1
- package/esm/lib/matchers.js.map +1 -1
- package/esm/lib/primitives.d.ts +0 -1
- package/esm/lib/primitives.d.ts.map +1 -1
- package/esm/lib/primitives.js +0 -17
- package/esm/lib/primitives.js.map +1 -1
- package/esm/lib/retries.js +0 -7
- package/esm/lib/retries.js.map +1 -1
- package/esm/lib/sdks.d.ts +1 -1
- package/esm/lib/sdks.d.ts.map +1 -1
- package/esm/lib/sdks.js +26 -62
- package/esm/lib/sdks.js.map +1 -1
- package/esm/lib/security.d.ts +5 -6
- package/esm/lib/security.d.ts.map +1 -1
- package/esm/lib/security.js +15 -24
- package/esm/lib/security.js.map +1 -1
- package/esm/lib/url.d.ts.map +1 -1
- package/esm/lib/url.js +2 -4
- package/esm/lib/url.js.map +1 -1
- package/esm/models/aiheartbeatdata.d.ts +79 -0
- package/esm/models/aiheartbeatdata.d.ts.map +1 -0
- package/esm/models/aiheartbeatdata.js +56 -0
- package/esm/models/aiheartbeatdata.js.map +1 -0
- package/esm/models/aiheartbeatstatus.d.ts +25 -0
- package/esm/models/aiheartbeatstatus.d.ts.map +1 -0
- package/esm/models/aiheartbeatstatus.js +20 -0
- package/esm/models/aiheartbeatstatus.js.map +1 -0
- package/esm/models/computepoolselection.d.ts +5 -0
- package/esm/models/computepoolselection.d.ts.map +1 -1
- package/esm/models/computepoolselection.js +22 -0
- package/esm/models/computepoolselection.js.map +1 -1
- package/esm/models/errors/alienerror.d.ts +173 -0
- package/esm/models/errors/alienerror.d.ts.map +1 -0
- package/esm/models/errors/alienerror.js +59 -0
- package/esm/models/errors/alienerror.js.map +1 -0
- package/esm/models/errors/index.d.ts +1 -0
- package/esm/models/errors/index.d.ts.map +1 -1
- package/esm/models/errors/index.js +1 -0
- package/esm/models/errors/index.js.map +1 -1
- package/esm/models/exposeprotocol.d.ts +16 -0
- package/esm/models/exposeprotocol.d.ts.map +1 -0
- package/esm/models/exposeprotocol.js +15 -0
- package/esm/models/exposeprotocol.js.map +1 -0
- package/esm/models/failuredomainselection.d.ts +31 -0
- package/esm/models/failuredomainselection.d.ts.map +1 -0
- package/esm/models/failuredomainselection.js +22 -0
- package/esm/models/failuredomainselection.js.map +1 -0
- package/esm/models/index.d.ts +18 -2
- package/esm/models/index.d.ts.map +1 -1
- package/esm/models/index.js +18 -2
- package/esm/models/index.js.map +1 -1
- package/esm/models/loadbalancerendpoint.d.ts +23 -0
- package/esm/models/loadbalancerendpoint.d.ts.map +1 -0
- package/esm/models/loadbalancerendpoint.js +14 -0
- package/esm/models/loadbalancerendpoint.js.map +1 -0
- package/esm/models/publicendpointoutput.d.ts +35 -0
- package/esm/models/publicendpointoutput.d.ts.map +1 -0
- package/esm/models/publicendpointoutput.js +21 -0
- package/esm/models/publicendpointoutput.js.map +1 -0
- package/esm/models/remoteawsclientconfig.d.ts +28 -0
- package/esm/models/remoteawsclientconfig.d.ts.map +1 -0
- package/esm/models/remoteawsclientconfig.js +16 -0
- package/esm/models/remoteawsclientconfig.js.map +1 -0
- package/esm/models/remoteawscredentials.d.ts +43 -0
- package/esm/models/remoteawscredentials.d.ts.map +1 -0
- package/esm/models/remoteawscredentials.js +27 -0
- package/esm/models/remoteawscredentials.js.map +1 -0
- package/esm/models/remoteazureclientconfig.d.ts +32 -0
- package/esm/models/remoteazureclientconfig.d.ts.map +1 -0
- package/esm/models/remoteazureclientconfig.js +17 -0
- package/esm/models/remoteazureclientconfig.js.map +1 -0
- package/esm/models/remoteazurecredentials.d.ts +28 -0
- package/esm/models/remoteazurecredentials.d.ts.map +1 -0
- package/esm/models/remoteazurecredentials.js +24 -0
- package/esm/models/remoteazurecredentials.js.map +1 -0
- package/esm/models/remoteblobstoragebinding.d.ts +20 -0
- package/esm/models/remoteblobstoragebinding.d.ts.map +1 -0
- package/esm/models/remoteblobstoragebinding.js +14 -0
- package/esm/models/remoteblobstoragebinding.js.map +1 -0
- package/esm/models/remotegcpclientconfig.d.ts +32 -0
- package/esm/models/remotegcpclientconfig.d.ts.map +1 -0
- package/esm/models/remotegcpclientconfig.js +17 -0
- package/esm/models/remotegcpclientconfig.js.map +1 -0
- package/esm/models/remotegcpcredentials.d.ts +31 -0
- package/esm/models/remotegcpcredentials.d.ts.map +1 -0
- package/esm/models/remotegcpcredentials.js +24 -0
- package/esm/models/remotegcpcredentials.js.map +1 -0
- package/esm/models/remotegcsstoragebinding.d.ts +16 -0
- package/esm/models/remotegcsstoragebinding.d.ts.map +1 -0
- package/esm/models/remotegcsstoragebinding.js +13 -0
- package/esm/models/remotegcsstoragebinding.js.map +1 -0
- package/esm/models/remotes3storagebinding.d.ts +16 -0
- package/esm/models/remotes3storagebinding.d.ts.map +1 -0
- package/esm/models/remotes3storagebinding.js +13 -0
- package/esm/models/remotes3storagebinding.js.map +1 -0
- package/esm/models/renewrequest.d.ts +14 -0
- package/esm/models/renewrequest.d.ts.map +1 -0
- package/esm/models/renewrequest.js +13 -0
- package/esm/models/renewrequest.js.map +1 -0
- package/esm/models/resolvebindingrequest.d.ts +23 -0
- package/esm/models/resolvebindingrequest.d.ts.map +1 -0
- package/esm/models/resolvebindingrequest.js +13 -0
- package/esm/models/resolvebindingrequest.js.map +1 -0
- package/esm/models/resolvebindingresponse.d.ts +83 -0
- package/esm/models/resolvebindingresponse.d.ts.map +1 -0
- package/esm/models/resolvebindingresponse.js +51 -0
- package/esm/models/resolvebindingresponse.js.map +1 -0
- package/esm/models/resourceentry.d.ts +4 -0
- package/esm/models/resourceentry.d.ts.map +1 -1
- package/esm/models/resourceentry.js +3 -0
- package/esm/models/resourceentry.js.map +1 -1
- package/esm/models/resourceheartbeatdata.d.ts +15 -2
- package/esm/models/resourceheartbeatdata.d.ts.map +1 -1
- package/esm/models/resourceheartbeatdata.js +10 -0
- package/esm/models/resourceheartbeatdata.js.map +1 -1
- package/esm/sdk/bindings.d.ts +6 -0
- package/esm/sdk/bindings.d.ts.map +1 -0
- package/esm/sdk/bindings.js +12 -0
- package/esm/sdk/bindings.js.map +1 -0
- package/esm/sdk/credentials.d.ts +0 -1
- package/esm/sdk/credentials.d.ts.map +1 -1
- package/esm/sdk/credentials.js +0 -4
- package/esm/sdk/credentials.js.map +1 -1
- package/esm/sdk/sdk.d.ts +3 -0
- package/esm/sdk/sdk.d.ts.map +1 -1
- package/esm/sdk/sdk.js +4 -0
- package/esm/sdk/sdk.js.map +1 -1
- package/esm/sdk/sync.d.ts +4 -0
- package/esm/sdk/sync.d.ts.map +1 -1
- package/esm/sdk/sync.js +7 -0
- package/esm/sdk/sync.js.map +1 -1
- package/esm/types/async.d.ts.map +1 -1
- package/esm/types/async.js +7 -8
- package/esm/types/async.js.map +1 -1
- package/examples/package.json +18 -0
- package/jsr.json +1 -1
- package/package.json +3 -3
- package/src/funcs/bindingsResolveBinding.ts +163 -0
- package/src/funcs/commandsCreateCommand.ts +1 -3
- package/src/funcs/commandsGetCommandPayload.ts +2 -3
- package/src/funcs/commandsGetCommandStatus.ts +2 -3
- package/src/funcs/commandsStoreCommandPayload.ts +2 -3
- package/src/funcs/commandsSubmitResponse.ts +2 -3
- package/src/funcs/commandsUploadComplete.ts +2 -3
- package/src/funcs/credentialsMintCredentials.ts +1 -3
- package/src/funcs/deploymentGroupsCreateDeploymentGroup.ts +1 -3
- package/src/funcs/deploymentGroupsCreateDeploymentGroupToken.ts +2 -3
- package/src/funcs/deploymentGroupsGetDeploymentGroup.ts +2 -3
- package/src/funcs/deploymentGroupsListDeploymentGroups.ts +1 -3
- package/src/funcs/deploymentsCreateDeployment.ts +1 -3
- package/src/funcs/deploymentsDeleteDeployment.ts +2 -3
- package/src/funcs/deploymentsGetDeployment.ts +2 -3
- package/src/funcs/deploymentsGetDeploymentInfo.ts +2 -3
- package/src/funcs/deploymentsListDeployments.ts +1 -3
- package/src/funcs/deploymentsRedeploy.ts +2 -3
- package/src/funcs/deploymentsRetryDeployment.ts +2 -3
- package/src/funcs/healthHealth.ts +1 -3
- package/src/funcs/leasesAcquireLeases.ts +1 -3
- package/src/funcs/leasesReleaseLease.ts +2 -3
- package/src/funcs/releasesCreateRelease.ts +1 -3
- package/src/funcs/releasesGetLatestRelease.ts +1 -3
- package/src/funcs/releasesGetRelease.ts +2 -3
- package/src/funcs/releasesListReleases.ts +1 -3
- package/src/funcs/stackImportStackImport.ts +1 -3
- package/src/funcs/syncAcquire.ts +1 -3
- package/src/funcs/syncAgentSync.ts +1 -3
- package/src/funcs/syncInitialize.ts +1 -3
- package/src/funcs/syncReconcile.ts +1 -3
- package/src/funcs/syncRelease.ts +1 -3
- package/src/funcs/{credentialsResolveCredentials.ts → syncRenew.ts} +16 -14
- package/src/funcs/whoamiWhoami.ts +1 -3
- package/src/hooks/types.ts +0 -1
- package/src/lib/config.ts +23 -8
- package/src/lib/dlv.ts +53 -0
- package/src/lib/encodings.ts +5 -33
- package/src/lib/env.ts +3 -7
- package/src/lib/files.ts +0 -22
- package/src/lib/http.ts +1 -3
- package/src/lib/is-plain-object.ts +43 -0
- package/src/lib/matchers.ts +3 -4
- package/src/lib/primitives.ts +0 -16
- package/src/lib/retries.ts +0 -8
- package/src/lib/sdks.ts +30 -66
- package/src/lib/security.ts +10 -26
- package/src/lib/url.ts +14 -16
- package/src/models/aiheartbeatdata.ts +184 -0
- package/src/models/aiheartbeatstatus.ts +58 -0
- package/src/models/computepoolselection.ts +31 -0
- package/src/models/errors/alienerror.ts +213 -0
- package/src/models/errors/index.ts +1 -0
- package/src/models/exposeprotocol.ts +22 -0
- package/src/models/failuredomainselection.ts +65 -0
- package/src/models/index.ts +18 -2
- package/src/models/loadbalancerendpoint.ts +44 -0
- package/src/models/publicendpointoutput.ts +67 -0
- package/src/models/remoteawsclientconfig.ts +53 -0
- package/src/models/remoteawscredentials.ts +88 -0
- package/src/models/remoteazureclientconfig.ts +58 -0
- package/src/models/remoteazurecredentials.ts +69 -0
- package/src/models/remoteblobstoragebinding.ts +41 -0
- package/src/models/remotegcpclientconfig.ts +58 -0
- package/src/models/remotegcpcredentials.ts +72 -0
- package/src/models/remotegcsstoragebinding.ts +36 -0
- package/src/models/remotes3storagebinding.ts +36 -0
- package/src/models/renewrequest.ts +29 -0
- package/src/models/resolvebindingrequest.ts +42 -0
- package/src/models/resolvebindingresponse.ts +183 -0
- package/src/models/resourceentry.ts +7 -0
- package/src/models/resourceheartbeatdata.ts +38 -2
- package/src/sdk/bindings.ts +21 -0
- package/src/sdk/credentials.ts +0 -12
- package/src/sdk/sdk.ts +6 -0
- package/src/sdk/sync.ts +15 -0
- package/src/types/async.ts +7 -8
- package/tsconfig.json +40 -0
- package/esm/funcs/credentialsResolveCredentials.d.ts.map +0 -1
- package/esm/funcs/credentialsResolveCredentials.js.map +0 -1
- package/esm/models/resolvecredentialsrequest.d.ts +0 -12
- package/esm/models/resolvecredentialsrequest.d.ts.map +0 -1
- package/esm/models/resolvecredentialsrequest.js +0 -12
- package/esm/models/resolvecredentialsrequest.js.map +0 -1
- package/esm/models/resolvecredentialsresponse.d.ts +0 -14
- package/esm/models/resolvecredentialsresponse.d.ts.map +0 -1
- package/esm/models/resolvecredentialsresponse.js +0 -14
- package/esm/models/resolvecredentialsresponse.js.map +0 -1
- package/src/models/resolvecredentialsrequest.ts +0 -30
- package/src/models/resolvecredentialsresponse.ts +0 -37
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import * as z from "zod/v4";
|
|
5
6
|
import { AlienManagerCore } from "../core.js";
|
|
6
7
|
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
-
import { matchStatusCode } from "../lib/http.js";
|
|
8
8
|
import * as M from "../lib/matchers.js";
|
|
9
9
|
import { compactMap } from "../lib/primitives.js";
|
|
10
10
|
import { safeParse } from "../lib/schemas.js";
|
|
@@ -25,13 +25,16 @@ import * as models from "../models/index.js";
|
|
|
25
25
|
import { APICall, APIPromise } from "../types/async.js";
|
|
26
26
|
import { Result } from "../types/fp.js";
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Renew an acquired deployment lease without writing deployment state.
|
|
30
|
+
*/
|
|
31
|
+
export function syncRenew(
|
|
29
32
|
client: AlienManagerCore,
|
|
30
|
-
request: models.
|
|
33
|
+
request: models.RenewRequest,
|
|
31
34
|
options?: RequestOptions,
|
|
32
35
|
): APIPromise<
|
|
33
36
|
Result<
|
|
34
|
-
|
|
37
|
+
void,
|
|
35
38
|
| AlienManagerError
|
|
36
39
|
| ResponseValidationError
|
|
37
40
|
| ConnectionError
|
|
@@ -51,12 +54,12 @@ export function credentialsResolveCredentials(
|
|
|
51
54
|
|
|
52
55
|
async function $do(
|
|
53
56
|
client: AlienManagerCore,
|
|
54
|
-
request: models.
|
|
57
|
+
request: models.RenewRequest,
|
|
55
58
|
options?: RequestOptions,
|
|
56
59
|
): Promise<
|
|
57
60
|
[
|
|
58
61
|
Result<
|
|
59
|
-
|
|
62
|
+
void,
|
|
60
63
|
| AlienManagerError
|
|
61
64
|
| ResponseValidationError
|
|
62
65
|
| ConnectionError
|
|
@@ -71,7 +74,7 @@ async function $do(
|
|
|
71
74
|
> {
|
|
72
75
|
const parsed = safeParse(
|
|
73
76
|
request,
|
|
74
|
-
(value) => models.
|
|
77
|
+
(value) => models.RenewRequest$outboundSchema.parse(value),
|
|
75
78
|
"Input validation failed",
|
|
76
79
|
);
|
|
77
80
|
if (!parsed.ok) {
|
|
@@ -80,11 +83,11 @@ async function $do(
|
|
|
80
83
|
const payload = parsed.value;
|
|
81
84
|
const body = encodeJSON("body", payload, { explode: true });
|
|
82
85
|
|
|
83
|
-
const path = pathToFunc("/v1/
|
|
86
|
+
const path = pathToFunc("/v1/sync/renew")();
|
|
84
87
|
|
|
85
88
|
const headers = new Headers(compactMap({
|
|
86
89
|
"Content-Type": "application/json",
|
|
87
|
-
Accept: "
|
|
90
|
+
Accept: "*/*",
|
|
88
91
|
}));
|
|
89
92
|
|
|
90
93
|
const secConfig = await extractSecurity(client._options.bearer);
|
|
@@ -94,7 +97,7 @@ async function $do(
|
|
|
94
97
|
const context = {
|
|
95
98
|
options: client._options,
|
|
96
99
|
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
97
|
-
operationID: "
|
|
100
|
+
operationID: "renew",
|
|
98
101
|
oAuth2Scopes: null,
|
|
99
102
|
|
|
100
103
|
resolvedSecurity: requestSecurity,
|
|
@@ -123,8 +126,7 @@ async function $do(
|
|
|
123
126
|
|
|
124
127
|
const doResult = await client._do(req, {
|
|
125
128
|
context,
|
|
126
|
-
|
|
127
|
-
matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
|
|
129
|
+
errorCodes: ["4XX", "5XX"],
|
|
128
130
|
retryConfig: context.retryConfig,
|
|
129
131
|
retryCodes: context.retryCodes,
|
|
130
132
|
});
|
|
@@ -134,7 +136,7 @@ async function $do(
|
|
|
134
136
|
const response = doResult.value;
|
|
135
137
|
|
|
136
138
|
const [result] = await M.match<
|
|
137
|
-
|
|
139
|
+
void,
|
|
138
140
|
| AlienManagerError
|
|
139
141
|
| ResponseValidationError
|
|
140
142
|
| ConnectionError
|
|
@@ -144,7 +146,7 @@ async function $do(
|
|
|
144
146
|
| UnexpectedClientError
|
|
145
147
|
| SDKValidationError
|
|
146
148
|
>(
|
|
147
|
-
M.
|
|
149
|
+
M.nil(200, z.void()),
|
|
148
150
|
M.fail("4XX"),
|
|
149
151
|
M.fail("5XX"),
|
|
150
152
|
)(response, req);
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { AlienManagerCore } from "../core.js";
|
|
6
|
-
import { matchStatusCode } from "../lib/http.js";
|
|
7
6
|
import * as M from "../lib/matchers.js";
|
|
8
7
|
import { compactMap } from "../lib/primitives.js";
|
|
9
8
|
import { RequestOptions } from "../lib/sdks.js";
|
|
@@ -105,8 +104,7 @@ async function $do(
|
|
|
105
104
|
|
|
106
105
|
const doResult = await client._do(req, {
|
|
107
106
|
context,
|
|
108
|
-
|
|
109
|
-
matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
|
|
107
|
+
errorCodes: ["4XX", "5XX"],
|
|
110
108
|
retryConfig: context.retryConfig,
|
|
111
109
|
retryCodes: context.retryCodes,
|
|
112
110
|
});
|
package/src/hooks/types.ts
CHANGED
package/src/lib/config.ts
CHANGED
|
@@ -5,12 +5,23 @@
|
|
|
5
5
|
import { HTTPClient } from "./http.js";
|
|
6
6
|
import { Logger } from "./logger.js";
|
|
7
7
|
import { RetryConfig } from "./retries.js";
|
|
8
|
-
import { pathToFunc } from "./url.js";
|
|
8
|
+
import { Params, pathToFunc } from "./url.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Contains the list of servers available to the SDK
|
|
12
|
+
*/
|
|
13
|
+
export const ServerList = [
|
|
14
|
+
"/",
|
|
15
|
+
] as const;
|
|
9
16
|
|
|
10
17
|
export type SDKOptions = {
|
|
11
18
|
bearer?: string | (() => Promise<string>) | undefined;
|
|
12
19
|
|
|
13
20
|
httpClient?: HTTPClient;
|
|
21
|
+
/**
|
|
22
|
+
* Allows overriding the default server used by the SDK
|
|
23
|
+
*/
|
|
24
|
+
serverIdx?: number | undefined;
|
|
14
25
|
/**
|
|
15
26
|
* Specifies the server URL to be used by the SDK
|
|
16
27
|
*/
|
|
@@ -28,14 +39,18 @@ export type SDKOptions = {
|
|
|
28
39
|
};
|
|
29
40
|
|
|
30
41
|
export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
31
|
-
|
|
42
|
+
let serverURL = options.serverURL;
|
|
43
|
+
|
|
44
|
+
const params: Params = {};
|
|
32
45
|
|
|
33
46
|
if (!serverURL) {
|
|
34
|
-
|
|
47
|
+
const serverIdx = options.serverIdx ?? 0;
|
|
48
|
+
if (serverIdx < 0 || serverIdx >= ServerList.length) {
|
|
49
|
+
throw new Error(`Invalid server index ${serverIdx}`);
|
|
50
|
+
}
|
|
51
|
+
serverURL = ServerList[serverIdx] || "";
|
|
35
52
|
}
|
|
36
53
|
|
|
37
|
-
const params: Record<string, string | undefined> = {};
|
|
38
|
-
|
|
39
54
|
const u = pathToFunc(serverURL)(params);
|
|
40
55
|
return new URL(u);
|
|
41
56
|
}
|
|
@@ -43,8 +58,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
43
58
|
export const SDK_METADATA = {
|
|
44
59
|
language: "typescript",
|
|
45
60
|
openapiDocVersion: "1.0.0",
|
|
46
|
-
sdkVersion: "
|
|
47
|
-
genVersion: "2.
|
|
61
|
+
sdkVersion: "3.3.2",
|
|
62
|
+
genVersion: "2.788.15",
|
|
48
63
|
userAgent:
|
|
49
|
-
"speakeasy-sdk/typescript
|
|
64
|
+
"speakeasy-sdk/typescript 3.3.2 2.788.15 1.0.0 @alienplatform/manager-api",
|
|
50
65
|
} as const;
|
package/src/lib/dlv.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 Jason Miller <jason@developit.ca> (http://jasonformat.com)
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
11
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
12
|
+
the Software without restriction, including without limitation the rights to
|
|
13
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
14
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
15
|
+
subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
22
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
23
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
24
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
25
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param obj The object to walk
|
|
30
|
+
* @param key The key path to walk the object with
|
|
31
|
+
* @param def A default value to return if the result is undefined
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* dlv(obj, "a.b.c.d")
|
|
35
|
+
* @example
|
|
36
|
+
* dlv(object, ["a", "b", "c", "d"])
|
|
37
|
+
* @example
|
|
38
|
+
* dlv(object, "foo.bar.baz", "Hello, default value!")
|
|
39
|
+
*/
|
|
40
|
+
export function dlv<T = any>(
|
|
41
|
+
obj: any,
|
|
42
|
+
key: string | string[],
|
|
43
|
+
def?: T,
|
|
44
|
+
p?: number,
|
|
45
|
+
undef?: never,
|
|
46
|
+
): T | undefined {
|
|
47
|
+
key = Array.isArray(key) ? key : key.split(".");
|
|
48
|
+
for (p = 0; p < key.length; p++) {
|
|
49
|
+
const k = key[p];
|
|
50
|
+
obj = k != null && obj ? obj[k] : undef;
|
|
51
|
+
}
|
|
52
|
+
return obj === undef ? def : obj;
|
|
53
|
+
}
|
package/src/lib/encodings.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { bytesToBase64 } from "./base64.js";
|
|
6
|
-
import { isPlainObject } from "./
|
|
6
|
+
import { isPlainObject } from "./is-plain-object.js";
|
|
7
7
|
|
|
8
8
|
export class EncodingError extends Error {
|
|
9
9
|
constructor(message: string) {
|
|
@@ -479,23 +479,6 @@ export const encodeSpaceDelimitedQuery = queryEncoder(encodeSpaceDelimited);
|
|
|
479
479
|
export const encodePipeDelimitedQuery = queryEncoder(encodePipeDelimited);
|
|
480
480
|
export const encodeDeepObjectQuery = queryEncoder(encodeDeepObject);
|
|
481
481
|
|
|
482
|
-
function isBlobLike(val: unknown): val is Blob {
|
|
483
|
-
if (val instanceof Blob) {
|
|
484
|
-
return true;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
if (typeof val !== "object" || val == null || !(Symbol.toStringTag in val)) {
|
|
488
|
-
return false;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
const tag = val[Symbol.toStringTag];
|
|
492
|
-
if (tag !== "Blob" && tag !== "File") {
|
|
493
|
-
return false;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
return "stream" in val && typeof val.stream === "function";
|
|
497
|
-
}
|
|
498
|
-
|
|
499
482
|
export function appendForm(
|
|
500
483
|
fd: FormData,
|
|
501
484
|
key: string,
|
|
@@ -504,22 +487,11 @@ export function appendForm(
|
|
|
504
487
|
): void {
|
|
505
488
|
if (value == null) {
|
|
506
489
|
return;
|
|
507
|
-
} else if (
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
fd.append(key, value as Blob);
|
|
512
|
-
}
|
|
490
|
+
} else if (value instanceof Blob && fileName) {
|
|
491
|
+
fd.append(key, value, fileName);
|
|
492
|
+
} else if (value instanceof Blob) {
|
|
493
|
+
fd.append(key, value);
|
|
513
494
|
} else {
|
|
514
495
|
fd.append(key, String(value));
|
|
515
496
|
}
|
|
516
497
|
}
|
|
517
|
-
|
|
518
|
-
export async function normalizeBlob(
|
|
519
|
-
value: Pick<Blob, "arrayBuffer" | "type">,
|
|
520
|
-
): Promise<Blob> {
|
|
521
|
-
if (value instanceof Blob) {
|
|
522
|
-
return value;
|
|
523
|
-
}
|
|
524
|
-
return new Blob([await value.arrayBuffer()], { type: value.type });
|
|
525
|
-
}
|
package/src/lib/env.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v4";
|
|
6
|
+
import { dlv } from "./dlv.js";
|
|
6
7
|
|
|
7
8
|
export interface Env {
|
|
8
9
|
ALIEN_MANAGER_BEARER?: string | undefined;
|
|
@@ -37,16 +38,11 @@ export function env(): Env {
|
|
|
37
38
|
return envMemo;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
const globals = globalThis as {
|
|
41
|
-
Deno?: { env?: { toObject?: () => Record<string, string | undefined> } };
|
|
42
|
-
process?: { env?: Record<string, string | undefined> };
|
|
43
|
-
};
|
|
44
|
-
|
|
45
41
|
let envObject: Record<string, unknown> = {};
|
|
46
42
|
if (isDeno()) {
|
|
47
|
-
envObject =
|
|
43
|
+
envObject = (globalThis as any).Deno?.env?.toObject?.() ?? {};
|
|
48
44
|
} else {
|
|
49
|
-
envObject =
|
|
45
|
+
envObject = dlv(globalThis, "process.env") ?? {};
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
envMemo = envSchema.parse(envObject);
|
package/src/lib/files.ts
CHANGED
|
@@ -80,25 +80,3 @@ export function getContentTypeFromFileName(fileName: string): string | null {
|
|
|
80
80
|
|
|
81
81
|
return mimeTypes[ext] || null;
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Creates a Blob from file content with the given MIME type.
|
|
86
|
-
*
|
|
87
|
-
* Node.js Buffers are Uint8Array subclasses that may share a pooled
|
|
88
|
-
* ArrayBuffer (byteOffset > 0, byteLength < buffer.byteLength). Passing
|
|
89
|
-
* such a Buffer directly to `new Blob([buf])` can include the entire
|
|
90
|
-
* underlying pool on some runtimes, producing a Blob with extra bytes
|
|
91
|
-
* that corrupts multipart uploads.
|
|
92
|
-
*
|
|
93
|
-
* Copying into a standalone Uint8Array ensures the Blob receives only the
|
|
94
|
-
* intended bytes regardless of runtime behaviour.
|
|
95
|
-
*/
|
|
96
|
-
export function bytesToBlob(
|
|
97
|
-
content: Uint8Array<ArrayBufferLike> | ArrayBuffer | Blob | string,
|
|
98
|
-
contentType: string,
|
|
99
|
-
): Blob {
|
|
100
|
-
if (content instanceof Uint8Array) {
|
|
101
|
-
return new Blob([new Uint8Array(content)], { type: contentType });
|
|
102
|
-
}
|
|
103
|
-
return new Blob([content as BlobPart], { type: contentType });
|
|
104
|
-
}
|
package/src/lib/http.ts
CHANGED
|
@@ -45,10 +45,8 @@ export class HTTPClient {
|
|
|
45
45
|
private requestHooks: BeforeRequestHook[] = [];
|
|
46
46
|
private requestErrorHooks: RequestErrorHook[] = [];
|
|
47
47
|
private responseHooks: ResponseHook[] = [];
|
|
48
|
-
private options: HTTPClientOptions;
|
|
49
48
|
|
|
50
|
-
constructor(options: HTTPClientOptions = {}) {
|
|
51
|
-
this.options = options;
|
|
49
|
+
constructor(private options: HTTPClientOptions = {}) {
|
|
52
50
|
this.fetcher = options.fetcher || DEFAULT_FETCHER;
|
|
53
51
|
}
|
|
54
52
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
11
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
12
|
+
the Software without restriction, including without limitation the rights to
|
|
13
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
14
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
15
|
+
subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
22
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
23
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
24
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
25
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
// Taken from https://github.com/sindresorhus/is-plain-obj/blob/97f38e8836f86a642cce98fc6ab3058bc36df181/index.js
|
|
29
|
+
|
|
30
|
+
export function isPlainObject(value: unknown): value is object {
|
|
31
|
+
if (typeof value !== "object" || value === null) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const prototype = Object.getPrototypeOf(value);
|
|
36
|
+
return (
|
|
37
|
+
(prototype === null ||
|
|
38
|
+
prototype === Object.prototype ||
|
|
39
|
+
Object.getPrototypeOf(prototype) === null) &&
|
|
40
|
+
!(Symbol.toStringTag in value) &&
|
|
41
|
+
!(Symbol.iterator in value)
|
|
42
|
+
);
|
|
43
|
+
}
|
package/src/lib/matchers.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { AlienManagerDefaultError } from "../models/errors/alienmanagerdefaulter
|
|
|
6
6
|
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
7
7
|
import { ERR, OK, Result } from "../types/fp.js";
|
|
8
8
|
import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js";
|
|
9
|
-
import { isPlainObject } from "./
|
|
9
|
+
import { isPlainObject } from "./is-plain-object.js";
|
|
10
10
|
|
|
11
11
|
export type Encoding =
|
|
12
12
|
| "jsonl"
|
|
@@ -254,9 +254,8 @@ export function match<T, E>(
|
|
|
254
254
|
raw = body;
|
|
255
255
|
break;
|
|
256
256
|
default:
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
);
|
|
257
|
+
encoding satisfies never;
|
|
258
|
+
throw new Error(`Unsupported response type: ${encoding}`);
|
|
260
259
|
}
|
|
261
260
|
|
|
262
261
|
if (matcher.enc === "fail") {
|
package/src/lib/primitives.ts
CHANGED
|
@@ -148,19 +148,3 @@ export function allRequired<V extends Record<string, unknown>>(
|
|
|
148
148
|
|
|
149
149
|
return v as ReturnType<typeof allRequired<V>>;
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
export function isPlainObject(
|
|
153
|
-
value: unknown,
|
|
154
|
-
): value is Record<string, unknown> {
|
|
155
|
-
if (value === null || typeof value !== "object") return false;
|
|
156
|
-
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
|
157
|
-
const proto = Object.getPrototypeOf(value);
|
|
158
|
-
if (proto === null || proto === Object.prototype) return true;
|
|
159
|
-
// cross-realm plain objects (vm contexts, iframes) inherit from a
|
|
160
|
-
// different realm's Object.prototype, which itself has a null prototype
|
|
161
|
-
try {
|
|
162
|
-
return Object.getPrototypeOf(proto) === null;
|
|
163
|
-
} catch {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
}
|
package/src/lib/retries.ts
CHANGED
|
@@ -194,14 +194,6 @@ async function retryBackoff(
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
function retryIntervalFromResponse(res: Response): number {
|
|
197
|
-
const retryAfterMsVal = res.headers.get("retry-after-ms");
|
|
198
|
-
if (retryAfterMsVal) {
|
|
199
|
-
const parsedMs = Number(retryAfterMsVal);
|
|
200
|
-
if (Number.isFinite(parsedMs) && parsedMs >= 0) {
|
|
201
|
-
return parsedMs;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
197
|
const retryVal = res.headers.get("retry-after") || "";
|
|
206
198
|
if (!retryVal) {
|
|
207
199
|
return 0;
|
package/src/lib/sdks.ts
CHANGED
|
@@ -22,9 +22,9 @@ import {
|
|
|
22
22
|
isConnectionError,
|
|
23
23
|
isTimeoutError,
|
|
24
24
|
matchContentType,
|
|
25
|
+
matchStatusCode,
|
|
25
26
|
} from "./http.js";
|
|
26
27
|
import { Logger } from "./logger.js";
|
|
27
|
-
import { combineSignals } from "./primitives.js";
|
|
28
28
|
import { retry, RetryConfig } from "./retries.js";
|
|
29
29
|
import { SecurityState } from "./security.js";
|
|
30
30
|
|
|
@@ -127,60 +127,30 @@ export class ClientSDK {
|
|
|
127
127
|
if (!base) {
|
|
128
128
|
return ERR(new InvalidRequestError("No base URL provided for operation"));
|
|
129
129
|
}
|
|
130
|
-
const
|
|
131
|
-
|
|
130
|
+
const reqURL = new URL(base);
|
|
131
|
+
const inputURL = new URL(path, reqURL);
|
|
132
|
+
|
|
132
133
|
if (path) {
|
|
133
|
-
|
|
134
|
-
reqURL
|
|
135
|
-
if (!reqURL.search && baseURL.search) {
|
|
136
|
-
reqURL.search = baseURL.search;
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
reqURL = baseURL;
|
|
134
|
+
reqURL.pathname += reqURL.pathname.endsWith("/") ? "" : "/";
|
|
135
|
+
reqURL.pathname += inputURL.pathname.replace(/^\/+/, "");
|
|
140
136
|
}
|
|
141
|
-
reqURL.hash = "";
|
|
142
|
-
|
|
143
|
-
// Appends already-encoded query pairs to a query string, replacing any
|
|
144
|
-
// existing pairs with the same key so later sources take precedence.
|
|
145
|
-
const mergeQuery = (current: string, additions: string): string => {
|
|
146
|
-
if (!additions) {
|
|
147
|
-
return current;
|
|
148
|
-
}
|
|
149
|
-
const additionKeys = new Set(
|
|
150
|
-
additions
|
|
151
|
-
.split("&")
|
|
152
|
-
.filter((pair) => pair !== "")
|
|
153
|
-
.map((pair) => pair.split("=")[0] ?? ""),
|
|
154
|
-
);
|
|
155
|
-
const kept = current.split("&").filter((pair) => {
|
|
156
|
-
return pair !== "" && !additionKeys.has(pair.split("=")[0] ?? "");
|
|
157
|
-
});
|
|
158
|
-
return [...kept, additions].join("&");
|
|
159
|
-
};
|
|
160
137
|
|
|
161
|
-
|
|
162
|
-
return Object.entries(record)
|
|
163
|
-
.map(([k, v]) => {
|
|
164
|
-
if (v == null) {
|
|
165
|
-
return undefined;
|
|
166
|
-
}
|
|
167
|
-
const value = v;
|
|
168
|
-
return encodeForm(k, value, {
|
|
169
|
-
explode: Array.isArray(value),
|
|
170
|
-
charEncoding: "percent",
|
|
171
|
-
});
|
|
172
|
-
})
|
|
173
|
-
.filter((pair): pair is string => typeof pair !== "undefined")
|
|
174
|
-
.join("&");
|
|
175
|
-
};
|
|
138
|
+
let finalQuery = query || "";
|
|
176
139
|
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
140
|
+
const secQuery: string[] = [];
|
|
141
|
+
for (const [k, v] of Object.entries(security?.queryParams || {})) {
|
|
142
|
+
const q = encodeForm(k, v, { charEncoding: "percent" });
|
|
143
|
+
if (typeof q !== "undefined") {
|
|
144
|
+
secQuery.push(q);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (secQuery.length) {
|
|
148
|
+
finalQuery += `&${secQuery.join("&")}`;
|
|
149
|
+
}
|
|
181
150
|
|
|
182
151
|
if (finalQuery) {
|
|
183
|
-
|
|
152
|
+
const q = finalQuery.startsWith("&") ? finalQuery.slice(1) : finalQuery;
|
|
153
|
+
reqURL.search = `?${q}`;
|
|
184
154
|
}
|
|
185
155
|
|
|
186
156
|
const headers = new Headers(opHeaders);
|
|
@@ -226,8 +196,9 @@ export class ClientSDK {
|
|
|
226
196
|
...options?.fetchOptions,
|
|
227
197
|
...options,
|
|
228
198
|
};
|
|
229
|
-
if (!fetchOptions?.signal && conf.timeoutMs
|
|
230
|
-
|
|
199
|
+
if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) {
|
|
200
|
+
const timeoutSignal = AbortSignal.timeout(conf.timeoutMs);
|
|
201
|
+
fetchOptions.signal = timeoutSignal;
|
|
231
202
|
}
|
|
232
203
|
|
|
233
204
|
if (conf.body instanceof ReadableStream) {
|
|
@@ -260,7 +231,7 @@ export class ClientSDK {
|
|
|
260
231
|
request: Request,
|
|
261
232
|
options: {
|
|
262
233
|
context: HookContext;
|
|
263
|
-
|
|
234
|
+
errorCodes: number | string | (number | string)[];
|
|
264
235
|
retryConfig: RetryConfig;
|
|
265
236
|
retryCodes: string[];
|
|
266
237
|
},
|
|
@@ -273,20 +244,11 @@ export class ClientSDK {
|
|
|
273
244
|
| UnexpectedClientError
|
|
274
245
|
>
|
|
275
246
|
> {
|
|
276
|
-
const { context,
|
|
277
|
-
const timeoutMs = context.timeoutMs;
|
|
247
|
+
const { context, errorCodes } = options;
|
|
278
248
|
|
|
279
249
|
return retry(
|
|
280
250
|
async () => {
|
|
281
|
-
const
|
|
282
|
-
let attempt = cloned;
|
|
283
|
-
if (timeoutMs != null && timeoutMs > 0) {
|
|
284
|
-
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
285
|
-
const combined = combineSignals(cloned.signal, timeoutSignal)
|
|
286
|
-
?? timeoutSignal;
|
|
287
|
-
attempt = new Request(cloned, { signal: combined });
|
|
288
|
-
}
|
|
289
|
-
const req = await this.#hooks.beforeRequest(context, attempt);
|
|
251
|
+
const req = await this.#hooks.beforeRequest(context, request.clone());
|
|
290
252
|
await logRequest(this.#logger, req).catch((e) =>
|
|
291
253
|
this.#logger?.log("Failed to log request:", e)
|
|
292
254
|
);
|
|
@@ -294,7 +256,7 @@ export class ClientSDK {
|
|
|
294
256
|
let response = await this.#httpClient.request(req);
|
|
295
257
|
|
|
296
258
|
try {
|
|
297
|
-
if (
|
|
259
|
+
if (matchStatusCode(response, errorCodes)) {
|
|
298
260
|
const result = await this.#hooks.afterError(
|
|
299
261
|
context,
|
|
300
262
|
response,
|
|
@@ -345,9 +307,9 @@ export class ClientSDK {
|
|
|
345
307
|
}
|
|
346
308
|
}
|
|
347
309
|
|
|
348
|
-
const jsonLikeContentTypeRE =
|
|
310
|
+
const jsonLikeContentTypeRE = /(application|text)\/.*?\+*json.*/;
|
|
349
311
|
const jsonlLikeContentTypeRE =
|
|
350
|
-
|
|
312
|
+
/(application|text)\/(.*?\+*\bjsonl\b.*|.*?\+*\bx-ndjson\b.*)/;
|
|
351
313
|
async function logRequest(logger: Logger | undefined, req: Request) {
|
|
352
314
|
if (!logger) {
|
|
353
315
|
return;
|
|
@@ -418,6 +380,8 @@ async function logResponse(
|
|
|
418
380
|
break;
|
|
419
381
|
case matchContentType(res, "application/jsonl")
|
|
420
382
|
|| jsonlLikeContentTypeRE.test(ct):
|
|
383
|
+
logger.log(await res.clone().text());
|
|
384
|
+
break;
|
|
421
385
|
case matchContentType(res, "text/event-stream"):
|
|
422
386
|
logger.log(`<${contentType}>`);
|
|
423
387
|
break;
|