@openrouter/sdk 0.0.1-beta.6 → 0.0.1-beta.8
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/esm/core.d.ts +10 -0
- package/esm/core.js +13 -0
- package/esm/funcs/analyticsGetUserActivity.d.ts +18 -0
- package/esm/funcs/analyticsGetUserActivity.js +85 -0
- package/esm/funcs/apiKeysCreate.d.ts +15 -0
- package/esm/funcs/apiKeysCreate.js +79 -0
- package/esm/funcs/apiKeysDelete.d.ts +15 -0
- package/esm/funcs/apiKeysDelete.js +84 -0
- package/esm/funcs/apiKeysGet.d.ts +15 -0
- package/esm/funcs/apiKeysGet.js +84 -0
- package/esm/funcs/apiKeysGetCurrentKeyMetadata.d.ts +18 -0
- package/esm/funcs/apiKeysGetCurrentKeyMetadata.js +72 -0
- package/esm/funcs/apiKeysList.d.ts +15 -0
- package/esm/funcs/apiKeysList.js +83 -0
- package/esm/funcs/apiKeysUpdate.d.ts +15 -0
- package/esm/funcs/apiKeysUpdate.js +85 -0
- package/esm/funcs/betaResponsesSend.d.ts +18 -0
- package/esm/funcs/betaResponsesSend.js +69 -0
- package/esm/funcs/chatSend.d.ts +19 -0
- package/esm/funcs/chatSend.js +83 -0
- package/esm/funcs/completionsGenerate.d.ts +18 -0
- package/esm/funcs/completionsGenerate.js +82 -0
- package/esm/funcs/creditsCreateCoinbaseCharge.d.ts +19 -0
- package/esm/funcs/creditsCreateCoinbaseCharge.js +77 -0
- package/esm/funcs/creditsGetCredits.d.ts +18 -0
- package/esm/funcs/creditsGetCredits.js +72 -0
- package/esm/funcs/endpointsList.d.ts +15 -0
- package/esm/funcs/endpointsList.js +88 -0
- package/esm/funcs/endpointsListZdrEndpoints.d.ts +14 -0
- package/esm/funcs/endpointsListZdrEndpoints.js +65 -0
- package/esm/funcs/generationsGetGeneration.d.ts +15 -0
- package/esm/funcs/generationsGetGeneration.js +82 -0
- package/esm/funcs/modelsCount.d.ts +14 -0
- package/esm/funcs/modelsCount.js +65 -0
- package/esm/funcs/modelsList.d.ts +14 -0
- package/esm/funcs/modelsList.js +83 -0
- package/esm/funcs/modelsListForUser.d.ts +14 -0
- package/esm/funcs/modelsListForUser.js +69 -0
- package/esm/funcs/oAuthCreateAuthorizationUrl.d.ts +43 -0
- package/esm/funcs/oAuthCreateAuthorizationUrl.js +44 -0
- package/esm/funcs/oAuthCreateSHA256CodeChallenge.d.ts +35 -0
- package/esm/funcs/oAuthCreateSHA256CodeChallenge.js +69 -0
- package/esm/funcs/parametersGetParameters.d.ts +15 -0
- package/esm/funcs/parametersGetParameters.js +96 -0
- package/esm/funcs/providersList.d.ts +15 -0
- package/esm/funcs/providersList.js +69 -0
- package/esm/hooks/hooks.d.ts +25 -0
- package/esm/hooks/hooks.js +82 -0
- package/esm/hooks/index.d.ts +3 -0
- package/esm/hooks/index.js +6 -0
- package/esm/hooks/registration.d.ts +3 -0
- package/esm/hooks/registration.js +12 -0
- package/esm/hooks/types.d.ts +76 -0
- package/esm/hooks/types.js +5 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.js +8 -0
- package/esm/lib/base64.d.ts +10 -0
- package/esm/lib/base64.js +29 -0
- package/esm/lib/config.d.ts +44 -0
- package/esm/lib/config.js +32 -0
- package/esm/lib/dlv.d.ts +14 -0
- package/esm/lib/dlv.js +46 -0
- package/esm/lib/encodings.d.ts +52 -0
- package/esm/lib/encodings.js +354 -0
- package/esm/lib/env.d.ts +15 -0
- package/esm/lib/env.js +44 -0
- package/esm/lib/event-streams.d.ts +11 -0
- package/esm/lib/event-streams.js +125 -0
- package/esm/lib/files.d.ts +13 -0
- package/esm/lib/files.js +73 -0
- package/esm/lib/http.d.ts +67 -0
- package/esm/lib/http.js +207 -0
- package/esm/lib/is-plain-object.d.ts +2 -0
- package/esm/lib/is-plain-object.js +38 -0
- package/esm/lib/logger.d.ts +6 -0
- package/esm/lib/logger.js +5 -0
- package/esm/lib/matchers.d.ts +59 -0
- package/esm/lib/matchers.js +203 -0
- package/esm/lib/primitives.d.ts +26 -0
- package/esm/lib/primitives.js +103 -0
- package/esm/lib/retries.d.ts +38 -0
- package/esm/lib/retries.js +147 -0
- package/esm/lib/schemas.d.ts +21 -0
- package/esm/lib/schemas.js +57 -0
- package/esm/lib/sdks.d.ts +63 -0
- package/esm/lib/sdks.js +269 -0
- package/esm/lib/security.d.ts +83 -0
- package/esm/lib/security.js +137 -0
- package/esm/lib/url.d.ts +5 -0
- package/esm/lib/url.js +22 -0
- package/esm/models/activityitem.d.ts +82 -0
- package/esm/models/activityitem.js +73 -0
- package/esm/models/assistantmessage.d.ts +62 -0
- package/esm/models/assistantmessage.js +73 -0
- package/esm/models/chatcompletionfinishreason.d.ts +25 -0
- package/esm/models/chatcompletionfinishreason.js +35 -0
- package/esm/models/chaterror.d.ts +56 -0
- package/esm/models/chaterror.js +64 -0
- package/esm/models/chatgenerationparams.d.ts +249 -0
- package/esm/models/chatgenerationparams.js +301 -0
- package/esm/models/chatgenerationtokenusage.d.ts +95 -0
- package/esm/models/chatgenerationtokenusage.js +142 -0
- package/esm/models/chatmessagecontentitem.d.ts +40 -0
- package/esm/models/chatmessagecontentitem.js +46 -0
- package/esm/models/chatmessagecontentitemaudio.d.ts +83 -0
- package/esm/models/chatmessagecontentitemaudio.js +102 -0
- package/esm/models/chatmessagecontentitemimage.d.ts +79 -0
- package/esm/models/chatmessagecontentitemimage.js +98 -0
- package/esm/models/chatmessagecontentitemtext.d.ts +31 -0
- package/esm/models/chatmessagecontentitemtext.js +33 -0
- package/esm/models/chatmessagetokenlogprob.d.ts +64 -0
- package/esm/models/chatmessagetokenlogprob.js +75 -0
- package/esm/models/chatmessagetokenlogprobs.d.ts +32 -0
- package/esm/models/chatmessagetokenlogprobs.js +34 -0
- package/esm/models/chatmessagetoolcall.d.ts +60 -0
- package/esm/models/chatmessagetoolcall.js +62 -0
- package/esm/models/chatresponse.d.ts +43 -0
- package/esm/models/chatresponse.js +55 -0
- package/esm/models/chatresponsechoice.d.ts +38 -0
- package/esm/models/chatresponsechoice.js +49 -0
- package/esm/models/chatstreamingchoice.d.ts +38 -0
- package/esm/models/chatstreamingchoice.js +49 -0
- package/esm/models/chatstreamingmessagechunk.d.ts +61 -0
- package/esm/models/chatstreamingmessagechunk.js +67 -0
- package/esm/models/chatstreamingmessagetoolcall.d.ts +62 -0
- package/esm/models/chatstreamingmessagetoolcall.js +66 -0
- package/esm/models/chatstreamingresponsechunk.d.ts +97 -0
- package/esm/models/chatstreamingresponsechunk.js +120 -0
- package/esm/models/chatstreamoptions.d.ts +29 -0
- package/esm/models/chatstreamoptions.js +40 -0
- package/esm/models/completionchoice.d.ts +57 -0
- package/esm/models/completionchoice.js +75 -0
- package/esm/models/completioncreateparams.d.ts +240 -0
- package/esm/models/completioncreateparams.js +313 -0
- package/esm/models/completionlogprobs.d.ts +39 -0
- package/esm/models/completionlogprobs.js +50 -0
- package/esm/models/completionresponse.d.ts +43 -0
- package/esm/models/completionresponse.js +54 -0
- package/esm/models/completionusage.d.ts +33 -0
- package/esm/models/completionusage.js +48 -0
- package/esm/models/createchargerequest.d.ts +28 -0
- package/esm/models/createchargerequest.js +27 -0
- package/esm/models/errorresponse.d.ts +155 -0
- package/esm/models/errorresponse.js +167 -0
- package/esm/models/errors/chaterror.d.ts +37 -0
- package/esm/models/errors/chaterror.js +48 -0
- package/esm/models/errors/errorresponse.d.ts +46 -0
- package/esm/models/errors/errorresponse.js +64 -0
- package/esm/models/errors/httpclienterrors.d.ts +44 -0
- package/esm/models/errors/httpclienterrors.js +69 -0
- package/esm/models/errors/index.d.ts +9 -0
- package/esm/models/errors/index.js +12 -0
- package/esm/models/errors/listproviders.d.ts +49 -0
- package/esm/models/errors/listproviders.js +51 -0
- package/esm/models/errors/openrouterdefaulterror.d.ts +10 -0
- package/esm/models/errors/openrouterdefaulterror.js +30 -0
- package/esm/models/errors/openroutererror.d.ts +19 -0
- package/esm/models/errors/openroutererror.js +16 -0
- package/esm/models/errors/responsevalidationerror.d.ts +26 -0
- package/esm/models/errors/responsevalidationerror.js +29 -0
- package/esm/models/errors/sdkvalidationerror.d.ts +21 -0
- package/esm/models/errors/sdkvalidationerror.js +44 -0
- package/esm/models/filecitationannotation.d.ts +58 -0
- package/esm/models/filecitationannotation.js +64 -0
- package/esm/models/filepathannotation.d.ts +56 -0
- package/esm/models/filepathannotation.js +62 -0
- package/esm/models/imagegenerationstatus.d.ts +24 -0
- package/esm/models/imagegenerationstatus.js +34 -0
- package/esm/models/index.d.ts +96 -0
- package/esm/models/index.js +99 -0
- package/esm/models/jsonschemaconfig.d.ts +39 -0
- package/esm/models/jsonschemaconfig.js +37 -0
- package/esm/models/listendpointsresponse.d.ts +28 -0
- package/esm/models/listendpointsresponse.js +27 -0
- package/esm/models/message.d.ts +80 -0
- package/esm/models/message.js +101 -0
- package/esm/models/modelscountresponse.d.ts +28 -0
- package/esm/models/modelscountresponse.js +27 -0
- package/esm/models/modelslistresponse.d.ts +28 -0
- package/esm/models/modelslistresponse.js +27 -0
- package/esm/models/namedtoolchoice.d.ts +56 -0
- package/esm/models/namedtoolchoice.js +58 -0
- package/esm/models/openresponseseasyinputmessage.d.ts +190 -0
- package/esm/models/openresponseseasyinputmessage.js +194 -0
- package/esm/models/openresponsesformatjsonobject.d.ts +55 -0
- package/esm/models/openresponsesformatjsonobject.js +49 -0
- package/esm/models/openresponsesformatjsonschema.d.ts +67 -0
- package/esm/models/openresponsesformatjsonschema.js +57 -0
- package/esm/models/openresponsesformattext.d.ts +55 -0
- package/esm/models/openresponsesformattext.js +49 -0
- package/esm/models/openresponsesformattextconfig.d.ts +31 -0
- package/esm/models/openresponsesformattextconfig.js +38 -0
- package/esm/models/openresponsesfunctioncalloutput.d.ts +64 -0
- package/esm/models/openresponsesfunctioncalloutput.js +67 -0
- package/esm/models/openresponsesfunctiontoolcall.d.ts +66 -0
- package/esm/models/openresponsesfunctiontoolcall.js +69 -0
- package/esm/models/openresponsesinput.d.ts +29 -0
- package/esm/models/openresponsesinput.js +36 -0
- package/esm/models/openresponsesinputcontent.d.ts +43 -0
- package/esm/models/openresponsesinputcontent.js +50 -0
- package/esm/models/openresponsesinputfile.d.ts +63 -0
- package/esm/models/openresponsesinputfile.js +70 -0
- package/esm/models/openresponsesinputimage.d.ts +79 -0
- package/esm/models/openresponsesinputimage.js +90 -0
- package/esm/models/openresponsesinputitem.d.ts +39 -0
- package/esm/models/openresponsesinputitem.js +62 -0
- package/esm/models/openresponsesinputmessageitem.d.ts +149 -0
- package/esm/models/openresponsesinputmessageitem.js +147 -0
- package/esm/models/openresponsesinputtext.d.ts +57 -0
- package/esm/models/openresponsesinputtext.js +51 -0
- package/esm/models/openresponseslogprobs.d.ts +66 -0
- package/esm/models/openresponseslogprobs.js +71 -0
- package/esm/models/openresponsesnonstreamingresponse.d.ts +260 -0
- package/esm/models/openresponsesnonstreamingresponse.js +290 -0
- package/esm/models/openresponsesoutputtext.d.ts +80 -0
- package/esm/models/openresponsesoutputtext.js +93 -0
- package/esm/models/openresponsesprompt.d.ts +39 -0
- package/esm/models/openresponsesprompt.js +34 -0
- package/esm/models/openresponsesreasoning.d.ts +90 -0
- package/esm/models/openresponsesreasoning.js +101 -0
- package/esm/models/openresponsesreasoningconfig.d.ts +61 -0
- package/esm/models/openresponsesreasoningconfig.js +78 -0
- package/esm/models/openresponsesrefusalcontent.d.ts +54 -0
- package/esm/models/openresponsesrefusalcontent.js +51 -0
- package/esm/models/openresponsesrequest.d.ts +28 -0
- package/esm/models/openresponsesrequest.js +27 -0
- package/esm/models/openresponsesstreamevent.d.ts +1683 -0
- package/esm/models/openresponsesstreamevent.js +1944 -0
- package/esm/models/openresponsestextconfig.d.ts +59 -0
- package/esm/models/openresponsestextconfig.js +63 -0
- package/esm/models/openresponsestoolchoice.d.ts +148 -0
- package/esm/models/openresponsestoolchoice.js +139 -0
- package/esm/models/openresponsestoolunion.d.ts +95 -0
- package/esm/models/openresponsestoolunion.js +94 -0
- package/esm/models/openresponseswebsearch20250826tool.d.ts +94 -0
- package/esm/models/openresponseswebsearch20250826tool.js +103 -0
- package/esm/models/openresponseswebsearchpreview20250311tool.d.ts +64 -0
- package/esm/models/openresponseswebsearchpreview20250311tool.js +68 -0
- package/esm/models/openresponseswebsearchpreviewtool.d.ts +64 -0
- package/esm/models/openresponseswebsearchpreviewtool.js +68 -0
- package/esm/models/openresponseswebsearchtool.d.ts +94 -0
- package/esm/models/openresponseswebsearchtool.js +103 -0
- package/esm/models/operations/createapialpharesponses.d.ts +58 -0
- package/esm/models/operations/createapialpharesponses.js +83 -0
- package/esm/models/operations/createcoinbasecharge.d.ts +212 -0
- package/esm/models/operations/createcoinbasecharge.js +267 -0
- package/esm/models/operations/createkeys.d.ts +226 -0
- package/esm/models/operations/createkeys.js +195 -0
- package/esm/models/operations/deletekeys.d.ts +63 -0
- package/esm/models/operations/deletekeys.js +56 -0
- package/esm/models/operations/getcredits.d.ts +28 -0
- package/esm/models/operations/getcredits.js +27 -0
- package/esm/models/operations/getcurrentkey.d.ts +186 -0
- package/esm/models/operations/getcurrentkey.js +148 -0
- package/esm/models/operations/getgeneration.d.ts +272 -0
- package/esm/models/operations/getgeneration.js +230 -0
- package/esm/models/operations/getkey.d.ts +179 -0
- package/esm/models/operations/getkey.js +148 -0
- package/esm/models/operations/getmodels.d.ts +57 -0
- package/esm/models/operations/getmodels.js +80 -0
- package/esm/models/operations/getparameters.d.ts +250 -0
- package/esm/models/operations/getparameters.js +260 -0
- package/esm/models/operations/getuseractivity.d.ts +64 -0
- package/esm/models/operations/getuseractivity.js +57 -0
- package/esm/models/operations/index.d.ts +20 -0
- package/esm/models/operations/index.js +23 -0
- package/esm/models/operations/list.d.ts +181 -0
- package/esm/models/operations/list.js +159 -0
- package/esm/models/operations/listendpoints.d.ts +63 -0
- package/esm/models/operations/listendpoints.js +59 -0
- package/esm/models/operations/listendpointszdr.d.ts +54 -0
- package/esm/models/operations/listendpointszdr.js +59 -0
- package/esm/models/operations/listmodelscount.d.ts +26 -0
- package/esm/models/operations/listmodelscount.js +34 -0
- package/esm/models/operations/listmodelsuser.d.ts +51 -0
- package/esm/models/operations/listmodelsuser.js +59 -0
- package/esm/models/operations/listproviders.d.ts +116 -0
- package/esm/models/operations/listproviders.js +105 -0
- package/esm/models/operations/sendchatcompletionrequest.d.ts +27 -0
- package/esm/models/operations/sendchatcompletionrequest.js +41 -0
- package/esm/models/operations/updatekeys.d.ts +256 -0
- package/esm/models/operations/updatekeys.js +230 -0
- package/esm/models/outputtextcontent.d.ts +80 -0
- package/esm/models/outputtextcontent.js +93 -0
- package/esm/models/publicendpoint.d.ts +28 -0
- package/esm/models/publicendpoint.js +27 -0
- package/esm/models/reasoningsummarytext.d.ts +54 -0
- package/esm/models/reasoningsummarytext.js +51 -0
- package/esm/models/reasoningsummaryverbosity.d.ts +23 -0
- package/esm/models/reasoningsummaryverbosity.js +33 -0
- package/esm/models/reasoningtextcontent.d.ts +54 -0
- package/esm/models/reasoningtextcontent.js +51 -0
- package/esm/models/refusalcontent.d.ts +54 -0
- package/esm/models/refusalcontent.js +51 -0
- package/esm/models/responseformatjsonschema.d.ts +32 -0
- package/esm/models/responseformatjsonschema.js +43 -0
- package/esm/models/responseformattextgrammar.d.ts +31 -0
- package/esm/models/responseformattextgrammar.js +33 -0
- package/esm/models/responseserrorfield.d.ts +55 -0
- package/esm/models/responseserrorfield.js +61 -0
- package/esm/models/responsesimagegenerationcall.d.ts +59 -0
- package/esm/models/responsesimagegenerationcall.js +56 -0
- package/esm/models/responsesoutputitem.d.ts +34 -0
- package/esm/models/responsesoutputitem.js +47 -0
- package/esm/models/responsesoutputitemfilesearchcall.d.ts +59 -0
- package/esm/models/responsesoutputitemfilesearchcall.js +56 -0
- package/esm/models/responsesoutputitemfunctioncall.d.ts +60 -0
- package/esm/models/responsesoutputitemfunctioncall.js +66 -0
- package/esm/models/responsesoutputitemreasoning.d.ts +62 -0
- package/esm/models/responsesoutputitemreasoning.js +68 -0
- package/esm/models/responsesoutputmessage.d.ts +192 -0
- package/esm/models/responsesoutputmessage.js +190 -0
- package/esm/models/responsessearchcontextsize.d.ts +29 -0
- package/esm/models/responsessearchcontextsize.js +36 -0
- package/esm/models/responsesusage.d.ts +131 -0
- package/esm/models/responsesusage.js +174 -0
- package/esm/models/responseswebsearchcalloutput.d.ts +57 -0
- package/esm/models/responseswebsearchcalloutput.js +54 -0
- package/esm/models/responseswebsearchuserlocation.d.ts +63 -0
- package/esm/models/responseswebsearchuserlocation.js +57 -0
- package/esm/models/security.d.ts +29 -0
- package/esm/models/security.js +32 -0
- package/esm/models/systemmessage.d.ts +55 -0
- package/esm/models/systemmessage.js +64 -0
- package/esm/models/tool.d.ts +66 -0
- package/esm/models/tool.js +65 -0
- package/esm/models/toolcallstatus.d.ts +23 -0
- package/esm/models/toolcallstatus.js +33 -0
- package/esm/models/toolchoicetypes.d.ts +164 -0
- package/esm/models/toolchoicetypes.js +167 -0
- package/esm/models/toolresponsemessage.d.ts +55 -0
- package/esm/models/toolresponsemessage.js +69 -0
- package/esm/models/urlcitationannotation.d.ts +60 -0
- package/esm/models/urlcitationannotation.js +68 -0
- package/esm/models/usermessage.d.ts +55 -0
- package/esm/models/usermessage.js +64 -0
- package/esm/models/websearchpreviewtooluserlocation.d.ts +60 -0
- package/esm/models/websearchpreviewtooluserlocation.js +57 -0
- package/esm/models/websearchstatus.d.ts +24 -0
- package/esm/models/websearchstatus.js +34 -0
- package/esm/react-query/_context.d.ts +8 -0
- package/esm/react-query/_context.js +14 -0
- package/esm/react-query/_types.d.ts +27 -0
- package/esm/react-query/_types.js +5 -0
- package/esm/react-query/analyticsGetUserActivity.d.ts +36 -0
- package/esm/react-query/analyticsGetUserActivity.js +77 -0
- package/esm/react-query/apiKeysCreate.d.ts +20 -0
- package/esm/react-query/apiKeysCreate.js +39 -0
- package/esm/react-query/apiKeysDelete.d.ts +20 -0
- package/esm/react-query/apiKeysDelete.js +39 -0
- package/esm/react-query/apiKeysGet.d.ts +24 -0
- package/esm/react-query/apiKeysGet.js +66 -0
- package/esm/react-query/apiKeysGetCurrentKeyMetadata.d.ts +29 -0
- package/esm/react-query/apiKeysGetCurrentKeyMetadata.js +66 -0
- package/esm/react-query/apiKeysList.d.ts +37 -0
- package/esm/react-query/apiKeysList.js +69 -0
- package/esm/react-query/apiKeysUpdate.d.ts +20 -0
- package/esm/react-query/apiKeysUpdate.js +39 -0
- package/esm/react-query/betaResponsesSend.d.ts +24 -0
- package/esm/react-query/betaResponsesSend.js +42 -0
- package/esm/react-query/chatSend.d.ts +24 -0
- package/esm/react-query/chatSend.js +42 -0
- package/esm/react-query/completionsGenerate.d.ts +23 -0
- package/esm/react-query/completionsGenerate.js +42 -0
- package/esm/react-query/creditsCreateCoinbaseCharge.d.ts +25 -0
- package/esm/react-query/creditsCreateCoinbaseCharge.js +42 -0
- package/esm/react-query/creditsGetCredits.d.ts +29 -0
- package/esm/react-query/creditsGetCredits.js +66 -0
- package/esm/react-query/endpointsList.d.ts +24 -0
- package/esm/react-query/endpointsList.js +66 -0
- package/esm/react-query/endpointsListZdrEndpoints.d.ts +23 -0
- package/esm/react-query/endpointsListZdrEndpoints.js +60 -0
- package/esm/react-query/generationsGetGeneration.d.ts +30 -0
- package/esm/react-query/generationsGetGeneration.js +71 -0
- package/esm/react-query/index.d.ts +23 -0
- package/esm/react-query/index.js +26 -0
- package/esm/react-query/modelsCount.d.ts +23 -0
- package/esm/react-query/modelsCount.js +60 -0
- package/esm/react-query/modelsList.d.ts +43 -0
- package/esm/react-query/modelsList.js +71 -0
- package/esm/react-query/modelsListForUser.d.ts +23 -0
- package/esm/react-query/modelsListForUser.js +60 -0
- package/esm/react-query/parametersGetParameters.d.ts +38 -0
- package/esm/react-query/parametersGetParameters.js +80 -0
- package/esm/react-query/providersList.d.ts +23 -0
- package/esm/react-query/providersList.js +60 -0
- package/esm/sdk/analytics.d.ts +12 -0
- package/esm/sdk/analytics.js +18 -0
- package/esm/sdk/apikeys.d.ts +32 -0
- package/esm/sdk/apikeys.js +53 -0
- package/esm/sdk/beta.d.ts +7 -0
- package/esm/sdk/beta.js +11 -0
- package/esm/sdk/chat.d.ts +13 -0
- package/esm/sdk/chat.js +18 -0
- package/esm/sdk/completions.d.ts +12 -0
- package/esm/sdk/completions.js +18 -0
- package/esm/sdk/credits.d.ts +20 -0
- package/esm/sdk/credits.js +28 -0
- package/esm/sdk/endpoints.d.ts +13 -0
- package/esm/sdk/endpoints.js +22 -0
- package/esm/sdk/generations.d.ts +9 -0
- package/esm/sdk/generations.js +15 -0
- package/esm/sdk/index.d.ts +2 -0
- package/esm/sdk/index.js +5 -0
- package/esm/sdk/models.d.ts +17 -0
- package/esm/sdk/models.js +29 -0
- package/esm/sdk/parameters.d.ts +9 -0
- package/esm/sdk/parameters.js +15 -0
- package/esm/sdk/providers.d.ts +9 -0
- package/esm/sdk/providers.js +15 -0
- package/esm/sdk/responses.d.ts +13 -0
- package/esm/sdk/responses.js +18 -0
- package/esm/sdk/sdk.d.ts +37 -0
- package/esm/sdk/sdk.js +51 -0
- package/esm/types/async.d.ts +23 -0
- package/esm/types/async.js +40 -0
- package/esm/types/blobs.d.ts +4 -0
- package/esm/types/blobs.js +25 -0
- package/esm/types/constdatetime.d.ts +3 -0
- package/esm/types/constdatetime.js +10 -0
- package/esm/types/enums.d.ts +12 -0
- package/esm/types/enums.js +7 -0
- package/esm/types/fp.d.ts +31 -0
- package/esm/types/fp.js +31 -0
- package/esm/types/index.d.ts +8 -0
- package/esm/types/index.js +8 -0
- package/esm/types/operations.d.ts +27 -0
- package/esm/types/operations.js +77 -0
- package/esm/types/rfcdate.d.ts +21 -0
- package/esm/types/rfcdate.js +42 -0
- package/esm/types/streams.d.ts +2 -0
- package/esm/types/streams.js +15 -0
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/tsconfig.json +3 -3
- package/core.d.ts +0 -9
- package/core.js +0 -12
- package/funcs/analyticsGetUserActivity.d.ts +0 -17
- package/funcs/analyticsGetUserActivity.js +0 -84
- package/funcs/apiKeysCreate.d.ts +0 -14
- package/funcs/apiKeysCreate.js +0 -78
- package/funcs/apiKeysDelete.d.ts +0 -14
- package/funcs/apiKeysDelete.js +0 -83
- package/funcs/apiKeysGet.d.ts +0 -14
- package/funcs/apiKeysGet.js +0 -83
- package/funcs/apiKeysGetCurrentKeyMetadata.d.ts +0 -17
- package/funcs/apiKeysGetCurrentKeyMetadata.js +0 -71
- package/funcs/apiKeysList.d.ts +0 -14
- package/funcs/apiKeysList.js +0 -82
- package/funcs/apiKeysUpdate.d.ts +0 -14
- package/funcs/apiKeysUpdate.js +0 -84
- package/funcs/betaResponsesSend.d.ts +0 -17
- package/funcs/betaResponsesSend.js +0 -68
- package/funcs/chatSend.d.ts +0 -18
- package/funcs/chatSend.js +0 -82
- package/funcs/completionsGenerate.d.ts +0 -17
- package/funcs/completionsGenerate.js +0 -81
- package/funcs/creditsCreateCoinbaseCharge.d.ts +0 -18
- package/funcs/creditsCreateCoinbaseCharge.js +0 -76
- package/funcs/creditsGetCredits.d.ts +0 -17
- package/funcs/creditsGetCredits.js +0 -71
- package/funcs/endpointsList.d.ts +0 -14
- package/funcs/endpointsList.js +0 -87
- package/funcs/endpointsListZdrEndpoints.d.ts +0 -13
- package/funcs/endpointsListZdrEndpoints.js +0 -64
- package/funcs/generationsGetGeneration.d.ts +0 -14
- package/funcs/generationsGetGeneration.js +0 -81
- package/funcs/modelsCount.d.ts +0 -13
- package/funcs/modelsCount.js +0 -64
- package/funcs/modelsList.d.ts +0 -13
- package/funcs/modelsList.js +0 -82
- package/funcs/modelsListForUser.d.ts +0 -13
- package/funcs/modelsListForUser.js +0 -68
- package/funcs/oAuthCreateAuthorizationUrl.d.ts +0 -42
- package/funcs/oAuthCreateAuthorizationUrl.js +0 -43
- package/funcs/oAuthCreateSHA256CodeChallenge.d.ts +0 -34
- package/funcs/oAuthCreateSHA256CodeChallenge.js +0 -68
- package/funcs/parametersGetParameters.d.ts +0 -14
- package/funcs/parametersGetParameters.js +0 -95
- package/funcs/providersList.d.ts +0 -14
- package/funcs/providersList.js +0 -68
- package/hooks/hooks.d.ts +0 -24
- package/hooks/hooks.js +0 -81
- package/hooks/index.d.ts +0 -2
- package/hooks/index.js +0 -5
- package/hooks/registration.d.ts +0 -2
- package/hooks/registration.js +0 -11
- package/hooks/types.d.ts +0 -75
- package/hooks/types.js +0 -4
- package/index.d.ts +0 -5
- package/index.js +0 -7
- package/lib/base64.d.ts +0 -9
- package/lib/base64.js +0 -28
- package/lib/config.d.ts +0 -43
- package/lib/config.js +0 -31
- package/lib/dlv.d.ts +0 -13
- package/lib/dlv.js +0 -45
- package/lib/encodings.d.ts +0 -51
- package/lib/encodings.js +0 -353
- package/lib/env.d.ts +0 -14
- package/lib/env.js +0 -43
- package/lib/event-streams.d.ts +0 -10
- package/lib/event-streams.js +0 -124
- package/lib/files.d.ts +0 -12
- package/lib/files.js +0 -72
- package/lib/http.d.ts +0 -66
- package/lib/http.js +0 -206
- package/lib/is-plain-object.d.ts +0 -1
- package/lib/is-plain-object.js +0 -37
- package/lib/logger.d.ts +0 -5
- package/lib/logger.js +0 -4
- package/lib/matchers.d.ts +0 -58
- package/lib/matchers.js +0 -202
- package/lib/primitives.d.ts +0 -25
- package/lib/primitives.js +0 -102
- package/lib/retries.d.ts +0 -37
- package/lib/retries.js +0 -146
- package/lib/schemas.d.ts +0 -18
- package/lib/schemas.js +0 -56
- package/lib/sdks.d.ts +0 -62
- package/lib/sdks.js +0 -268
- package/lib/security.d.ts +0 -82
- package/lib/security.js +0 -136
- package/lib/url.d.ts +0 -4
- package/lib/url.js +0 -21
- package/models/activityitem.d.ts +0 -81
- package/models/activityitem.js +0 -71
- package/models/assistantmessage.d.ts +0 -61
- package/models/assistantmessage.js +0 -72
- package/models/chatcompletionfinishreason.d.ts +0 -24
- package/models/chatcompletionfinishreason.js +0 -34
- package/models/chaterror.d.ts +0 -55
- package/models/chaterror.js +0 -58
- package/models/chatgenerationparams.d.ts +0 -248
- package/models/chatgenerationparams.js +0 -300
- package/models/chatgenerationtokenusage.d.ts +0 -94
- package/models/chatgenerationtokenusage.js +0 -141
- package/models/chatmessagecontentitem.d.ts +0 -39
- package/models/chatmessagecontentitem.js +0 -45
- package/models/chatmessagecontentitemaudio.d.ts +0 -82
- package/models/chatmessagecontentitemaudio.js +0 -100
- package/models/chatmessagecontentitemimage.d.ts +0 -78
- package/models/chatmessagecontentitemimage.js +0 -96
- package/models/chatmessagecontentitemtext.d.ts +0 -30
- package/models/chatmessagecontentitemtext.js +0 -32
- package/models/chatmessagetokenlogprob.d.ts +0 -63
- package/models/chatmessagetokenlogprob.js +0 -74
- package/models/chatmessagetokenlogprobs.d.ts +0 -31
- package/models/chatmessagetokenlogprobs.js +0 -33
- package/models/chatmessagetoolcall.d.ts +0 -59
- package/models/chatmessagetoolcall.js +0 -61
- package/models/chatresponse.d.ts +0 -42
- package/models/chatresponse.js +0 -53
- package/models/chatresponsechoice.d.ts +0 -37
- package/models/chatresponsechoice.js +0 -48
- package/models/chatstreamingchoice.d.ts +0 -37
- package/models/chatstreamingchoice.js +0 -48
- package/models/chatstreamingmessagechunk.d.ts +0 -60
- package/models/chatstreamingmessagechunk.js +0 -66
- package/models/chatstreamingmessagetoolcall.d.ts +0 -61
- package/models/chatstreamingmessagetoolcall.js +0 -65
- package/models/chatstreamingresponsechunk.d.ts +0 -96
- package/models/chatstreamingresponsechunk.js +0 -121
- package/models/chatstreamoptions.d.ts +0 -28
- package/models/chatstreamoptions.js +0 -39
- package/models/completionchoice.d.ts +0 -56
- package/models/completionchoice.js +0 -74
- package/models/completioncreateparams.d.ts +0 -239
- package/models/completioncreateparams.js +0 -311
- package/models/completionlogprobs.d.ts +0 -38
- package/models/completionlogprobs.js +0 -49
- package/models/completionresponse.d.ts +0 -42
- package/models/completionresponse.js +0 -53
- package/models/completionusage.d.ts +0 -32
- package/models/completionusage.js +0 -47
- package/models/createchargerequest.d.ts +0 -27
- package/models/createchargerequest.js +0 -26
- package/models/errorresponse.d.ts +0 -154
- package/models/errorresponse.js +0 -165
- package/models/errors/chaterror.d.ts +0 -36
- package/models/errors/chaterror.js +0 -47
- package/models/errors/errorresponse.d.ts +0 -45
- package/models/errors/errorresponse.js +0 -62
- package/models/errors/httpclienterrors.d.ts +0 -43
- package/models/errors/httpclienterrors.js +0 -68
- package/models/errors/index.d.ts +0 -8
- package/models/errors/index.js +0 -11
- package/models/errors/listproviders.d.ts +0 -48
- package/models/errors/listproviders.js +0 -50
- package/models/errors/openrouterdefaulterror.d.ts +0 -9
- package/models/errors/openrouterdefaulterror.js +0 -29
- package/models/errors/openroutererror.d.ts +0 -18
- package/models/errors/openroutererror.js +0 -15
- package/models/errors/responsevalidationerror.d.ts +0 -25
- package/models/errors/responsevalidationerror.js +0 -28
- package/models/errors/sdkvalidationerror.d.ts +0 -20
- package/models/errors/sdkvalidationerror.js +0 -90
- package/models/filecitationannotation.d.ts +0 -57
- package/models/filecitationannotation.js +0 -63
- package/models/filepathannotation.d.ts +0 -55
- package/models/filepathannotation.js +0 -61
- package/models/imagegenerationstatus.d.ts +0 -23
- package/models/imagegenerationstatus.js +0 -33
- package/models/index.d.ts +0 -95
- package/models/index.js +0 -98
- package/models/jsonschemaconfig.d.ts +0 -38
- package/models/jsonschemaconfig.js +0 -36
- package/models/listendpointsresponse.d.ts +0 -27
- package/models/listendpointsresponse.js +0 -26
- package/models/message.d.ts +0 -79
- package/models/message.js +0 -99
- package/models/modelscountresponse.d.ts +0 -27
- package/models/modelscountresponse.js +0 -26
- package/models/modelslistresponse.d.ts +0 -27
- package/models/modelslistresponse.js +0 -26
- package/models/namedtoolchoice.d.ts +0 -55
- package/models/namedtoolchoice.js +0 -57
- package/models/openresponseseasyinputmessage.d.ts +0 -189
- package/models/openresponseseasyinputmessage.js +0 -196
- package/models/openresponsesformatjsonobject.d.ts +0 -54
- package/models/openresponsesformatjsonobject.js +0 -48
- package/models/openresponsesformatjsonschema.d.ts +0 -66
- package/models/openresponsesformatjsonschema.js +0 -56
- package/models/openresponsesformattext.d.ts +0 -54
- package/models/openresponsesformattext.js +0 -48
- package/models/openresponsesformattextconfig.d.ts +0 -30
- package/models/openresponsesformattextconfig.js +0 -37
- package/models/openresponsesfunctioncalloutput.d.ts +0 -63
- package/models/openresponsesfunctioncalloutput.js +0 -66
- package/models/openresponsesfunctiontoolcall.d.ts +0 -65
- package/models/openresponsesfunctiontoolcall.js +0 -68
- package/models/openresponsesinput.d.ts +0 -28
- package/models/openresponsesinput.js +0 -35
- package/models/openresponsesinputcontent.d.ts +0 -42
- package/models/openresponsesinputcontent.js +0 -49
- package/models/openresponsesinputfile.d.ts +0 -62
- package/models/openresponsesinputfile.js +0 -69
- package/models/openresponsesinputimage.d.ts +0 -78
- package/models/openresponsesinputimage.js +0 -89
- package/models/openresponsesinputitem.d.ts +0 -38
- package/models/openresponsesinputitem.js +0 -61
- package/models/openresponsesinputmessageitem.d.ts +0 -148
- package/models/openresponsesinputmessageitem.js +0 -148
- package/models/openresponsesinputtext.d.ts +0 -56
- package/models/openresponsesinputtext.js +0 -50
- package/models/openresponseslogprobs.d.ts +0 -65
- package/models/openresponseslogprobs.js +0 -70
- package/models/openresponsesnonstreamingresponse.d.ts +0 -259
- package/models/openresponsesnonstreamingresponse.js +0 -289
- package/models/openresponsesoutputtext.d.ts +0 -79
- package/models/openresponsesoutputtext.js +0 -92
- package/models/openresponsesprompt.d.ts +0 -38
- package/models/openresponsesprompt.js +0 -35
- package/models/openresponsesreasoning.d.ts +0 -89
- package/models/openresponsesreasoning.js +0 -100
- package/models/openresponsesreasoningconfig.d.ts +0 -60
- package/models/openresponsesreasoningconfig.js +0 -77
- package/models/openresponsesrefusalcontent.d.ts +0 -53
- package/models/openresponsesrefusalcontent.js +0 -50
- package/models/openresponsesrequest.d.ts +0 -27
- package/models/openresponsesrequest.js +0 -26
- package/models/openresponsesstreamevent.d.ts +0 -1682
- package/models/openresponsesstreamevent.js +0 -1944
- package/models/openresponsestextconfig.d.ts +0 -58
- package/models/openresponsestextconfig.js +0 -61
- package/models/openresponsestoolchoice.d.ts +0 -147
- package/models/openresponsestoolchoice.js +0 -138
- package/models/openresponsestoolunion.d.ts +0 -94
- package/models/openresponsestoolunion.js +0 -93
- package/models/openresponseswebsearch20250826tool.d.ts +0 -93
- package/models/openresponseswebsearch20250826tool.js +0 -102
- package/models/openresponseswebsearchpreview20250311tool.d.ts +0 -63
- package/models/openresponseswebsearchpreview20250311tool.js +0 -68
- package/models/openresponseswebsearchpreviewtool.d.ts +0 -63
- package/models/openresponseswebsearchpreviewtool.js +0 -67
- package/models/openresponseswebsearchtool.d.ts +0 -93
- package/models/openresponseswebsearchtool.js +0 -102
- package/models/operations/createapialpharesponses.d.ts +0 -57
- package/models/operations/createapialpharesponses.js +0 -83
- package/models/operations/createcoinbasecharge.d.ts +0 -211
- package/models/operations/createcoinbasecharge.js +0 -263
- package/models/operations/createkeys.d.ts +0 -225
- package/models/operations/createkeys.js +0 -194
- package/models/operations/deletekeys.d.ts +0 -62
- package/models/operations/deletekeys.js +0 -55
- package/models/operations/getcredits.d.ts +0 -27
- package/models/operations/getcredits.js +0 -26
- package/models/operations/getcurrentkey.d.ts +0 -185
- package/models/operations/getcurrentkey.js +0 -147
- package/models/operations/getgeneration.d.ts +0 -271
- package/models/operations/getgeneration.js +0 -229
- package/models/operations/getkey.d.ts +0 -178
- package/models/operations/getkey.js +0 -145
- package/models/operations/getmodels.d.ts +0 -56
- package/models/operations/getmodels.js +0 -79
- package/models/operations/getparameters.d.ts +0 -249
- package/models/operations/getparameters.js +0 -259
- package/models/operations/getuseractivity.d.ts +0 -63
- package/models/operations/getuseractivity.js +0 -56
- package/models/operations/index.d.ts +0 -19
- package/models/operations/index.js +0 -22
- package/models/operations/list.d.ts +0 -180
- package/models/operations/list.js +0 -155
- package/models/operations/listendpoints.d.ts +0 -62
- package/models/operations/listendpoints.js +0 -58
- package/models/operations/listendpointszdr.d.ts +0 -53
- package/models/operations/listendpointszdr.js +0 -58
- package/models/operations/listmodelscount.d.ts +0 -25
- package/models/operations/listmodelscount.js +0 -33
- package/models/operations/listmodelsuser.d.ts +0 -50
- package/models/operations/listmodelsuser.js +0 -58
- package/models/operations/listproviders.d.ts +0 -115
- package/models/operations/listproviders.js +0 -104
- package/models/operations/sendchatcompletionrequest.d.ts +0 -26
- package/models/operations/sendchatcompletionrequest.js +0 -41
- package/models/operations/updatekeys.d.ts +0 -255
- package/models/operations/updatekeys.js +0 -229
- package/models/outputtextcontent.d.ts +0 -79
- package/models/outputtextcontent.js +0 -92
- package/models/publicendpoint.d.ts +0 -27
- package/models/publicendpoint.js +0 -26
- package/models/reasoningsummarytext.d.ts +0 -53
- package/models/reasoningsummarytext.js +0 -50
- package/models/reasoningsummaryverbosity.d.ts +0 -22
- package/models/reasoningsummaryverbosity.js +0 -32
- package/models/reasoningtextcontent.d.ts +0 -53
- package/models/reasoningtextcontent.js +0 -50
- package/models/refusalcontent.d.ts +0 -53
- package/models/refusalcontent.js +0 -50
- package/models/responseformatjsonschema.d.ts +0 -31
- package/models/responseformatjsonschema.js +0 -42
- package/models/responseformattextgrammar.d.ts +0 -30
- package/models/responseformattextgrammar.js +0 -32
- package/models/responseserrorfield.d.ts +0 -54
- package/models/responseserrorfield.js +0 -60
- package/models/responsesimagegenerationcall.d.ts +0 -58
- package/models/responsesimagegenerationcall.js +0 -55
- package/models/responsesoutputitem.d.ts +0 -33
- package/models/responsesoutputitem.js +0 -46
- package/models/responsesoutputitemfilesearchcall.d.ts +0 -58
- package/models/responsesoutputitemfilesearchcall.js +0 -55
- package/models/responsesoutputitemfunctioncall.d.ts +0 -59
- package/models/responsesoutputitemfunctioncall.js +0 -65
- package/models/responsesoutputitemreasoning.d.ts +0 -61
- package/models/responsesoutputitemreasoning.js +0 -67
- package/models/responsesoutputmessage.d.ts +0 -191
- package/models/responsesoutputmessage.js +0 -189
- package/models/responsessearchcontextsize.d.ts +0 -28
- package/models/responsessearchcontextsize.js +0 -35
- package/models/responsesusage.d.ts +0 -130
- package/models/responsesusage.js +0 -172
- package/models/responseswebsearchcalloutput.d.ts +0 -56
- package/models/responseswebsearchcalloutput.js +0 -53
- package/models/responseswebsearchuserlocation.d.ts +0 -62
- package/models/responseswebsearchuserlocation.js +0 -56
- package/models/security.d.ts +0 -28
- package/models/security.js +0 -30
- package/models/systemmessage.d.ts +0 -54
- package/models/systemmessage.js +0 -62
- package/models/tool.d.ts +0 -65
- package/models/tool.js +0 -64
- package/models/toolcallstatus.d.ts +0 -22
- package/models/toolcallstatus.js +0 -32
- package/models/toolchoicetypes.d.ts +0 -163
- package/models/toolchoicetypes.js +0 -167
- package/models/toolresponsemessage.d.ts +0 -54
- package/models/toolresponsemessage.js +0 -68
- package/models/urlcitationannotation.d.ts +0 -59
- package/models/urlcitationannotation.js +0 -67
- package/models/usermessage.d.ts +0 -54
- package/models/usermessage.js +0 -59
- package/models/websearchpreviewtooluserlocation.d.ts +0 -59
- package/models/websearchpreviewtooluserlocation.js +0 -56
- package/models/websearchstatus.d.ts +0 -23
- package/models/websearchstatus.js +0 -33
- package/react-query/_context.d.ts +0 -7
- package/react-query/_context.js +0 -13
- package/react-query/_types.d.ts +0 -26
- package/react-query/_types.js +0 -4
- package/react-query/analyticsGetUserActivity.d.ts +0 -35
- package/react-query/analyticsGetUserActivity.js +0 -76
- package/react-query/apiKeysCreate.d.ts +0 -19
- package/react-query/apiKeysCreate.js +0 -38
- package/react-query/apiKeysDelete.d.ts +0 -19
- package/react-query/apiKeysDelete.js +0 -38
- package/react-query/apiKeysGet.d.ts +0 -23
- package/react-query/apiKeysGet.js +0 -65
- package/react-query/apiKeysGetCurrentKeyMetadata.d.ts +0 -28
- package/react-query/apiKeysGetCurrentKeyMetadata.js +0 -65
- package/react-query/apiKeysList.d.ts +0 -36
- package/react-query/apiKeysList.js +0 -68
- package/react-query/apiKeysUpdate.d.ts +0 -19
- package/react-query/apiKeysUpdate.js +0 -38
- package/react-query/betaResponsesSend.d.ts +0 -23
- package/react-query/betaResponsesSend.js +0 -41
- package/react-query/chatSend.d.ts +0 -23
- package/react-query/chatSend.js +0 -41
- package/react-query/completionsGenerate.d.ts +0 -22
- package/react-query/completionsGenerate.js +0 -41
- package/react-query/creditsCreateCoinbaseCharge.d.ts +0 -24
- package/react-query/creditsCreateCoinbaseCharge.js +0 -41
- package/react-query/creditsGetCredits.d.ts +0 -28
- package/react-query/creditsGetCredits.js +0 -65
- package/react-query/endpointsList.d.ts +0 -23
- package/react-query/endpointsList.js +0 -65
- package/react-query/endpointsListZdrEndpoints.d.ts +0 -22
- package/react-query/endpointsListZdrEndpoints.js +0 -59
- package/react-query/generationsGetGeneration.d.ts +0 -29
- package/react-query/generationsGetGeneration.js +0 -70
- package/react-query/index.d.ts +0 -22
- package/react-query/index.js +0 -25
- package/react-query/modelsCount.d.ts +0 -22
- package/react-query/modelsCount.js +0 -59
- package/react-query/modelsList.d.ts +0 -42
- package/react-query/modelsList.js +0 -70
- package/react-query/modelsListForUser.d.ts +0 -22
- package/react-query/modelsListForUser.js +0 -59
- package/react-query/parametersGetParameters.d.ts +0 -37
- package/react-query/parametersGetParameters.js +0 -79
- package/react-query/providersList.d.ts +0 -22
- package/react-query/providersList.js +0 -59
- package/sdk/analytics.d.ts +0 -11
- package/sdk/analytics.js +0 -17
- package/sdk/apikeys.d.ts +0 -31
- package/sdk/apikeys.js +0 -52
- package/sdk/beta.d.ts +0 -6
- package/sdk/beta.js +0 -10
- package/sdk/chat.d.ts +0 -12
- package/sdk/chat.js +0 -17
- package/sdk/completions.d.ts +0 -11
- package/sdk/completions.js +0 -17
- package/sdk/credits.d.ts +0 -19
- package/sdk/credits.js +0 -27
- package/sdk/endpoints.d.ts +0 -12
- package/sdk/endpoints.js +0 -21
- package/sdk/generations.d.ts +0 -8
- package/sdk/generations.js +0 -14
- package/sdk/index.d.ts +0 -1
- package/sdk/index.js +0 -4
- package/sdk/models.d.ts +0 -16
- package/sdk/models.js +0 -28
- package/sdk/parameters.d.ts +0 -8
- package/sdk/parameters.js +0 -14
- package/sdk/providers.d.ts +0 -8
- package/sdk/providers.js +0 -14
- package/sdk/responses.d.ts +0 -12
- package/sdk/responses.js +0 -17
- package/sdk/sdk.d.ts +0 -36
- package/sdk/sdk.js +0 -50
- package/types/async.d.ts +0 -22
- package/types/async.js +0 -39
- package/types/blobs.d.ts +0 -3
- package/types/blobs.js +0 -24
- package/types/constdatetime.d.ts +0 -2
- package/types/constdatetime.js +0 -9
- package/types/enums.d.ts +0 -11
- package/types/enums.js +0 -6
- package/types/fp.d.ts +0 -30
- package/types/fp.js +0 -30
- package/types/index.d.ts +0 -7
- package/types/index.js +0 -7
- package/types/operations.d.ts +0 -26
- package/types/operations.js +0 -76
- package/types/rfcdate.d.ts +0 -20
- package/types/rfcdate.js +0 -41
- package/types/streams.d.ts +0 -1
- package/types/streams.js +0 -14
package/lib/matchers.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
import { OpenRouterDefaultError } from "../models/errors/openrouterdefaulterror.js";
|
|
5
|
-
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
6
|
-
import { ERR, OK } from "../types/fp.js";
|
|
7
|
-
import { matchResponse, matchStatusCode } from "./http.js";
|
|
8
|
-
import { isPlainObject } from "./is-plain-object.js";
|
|
9
|
-
const DEFAULT_CONTENT_TYPES = {
|
|
10
|
-
jsonl: "application/jsonl",
|
|
11
|
-
json: "application/json",
|
|
12
|
-
text: "text/plain",
|
|
13
|
-
bytes: "application/octet-stream",
|
|
14
|
-
stream: "application/octet-stream",
|
|
15
|
-
sse: "text/event-stream",
|
|
16
|
-
nil: "*",
|
|
17
|
-
fail: "*",
|
|
18
|
-
};
|
|
19
|
-
export function jsonErr(codes, schema, options) {
|
|
20
|
-
return { ...options, err: true, enc: "json", codes, schema };
|
|
21
|
-
}
|
|
22
|
-
export function json(codes, schema, options) {
|
|
23
|
-
return { ...options, enc: "json", codes, schema };
|
|
24
|
-
}
|
|
25
|
-
export function jsonl(codes, schema, options) {
|
|
26
|
-
return { ...options, enc: "jsonl", codes, schema };
|
|
27
|
-
}
|
|
28
|
-
export function jsonlErr(codes, schema, options) {
|
|
29
|
-
return { ...options, err: true, enc: "jsonl", codes, schema };
|
|
30
|
-
}
|
|
31
|
-
export function textErr(codes, schema, options) {
|
|
32
|
-
return { ...options, err: true, enc: "text", codes, schema };
|
|
33
|
-
}
|
|
34
|
-
export function text(codes, schema, options) {
|
|
35
|
-
return { ...options, enc: "text", codes, schema };
|
|
36
|
-
}
|
|
37
|
-
export function bytesErr(codes, schema, options) {
|
|
38
|
-
return { ...options, err: true, enc: "bytes", codes, schema };
|
|
39
|
-
}
|
|
40
|
-
export function bytes(codes, schema, options) {
|
|
41
|
-
return { ...options, enc: "bytes", codes, schema };
|
|
42
|
-
}
|
|
43
|
-
export function streamErr(codes, schema, options) {
|
|
44
|
-
return { ...options, err: true, enc: "stream", codes, schema };
|
|
45
|
-
}
|
|
46
|
-
export function stream(codes, schema, options) {
|
|
47
|
-
return { ...options, enc: "stream", codes, schema };
|
|
48
|
-
}
|
|
49
|
-
export function sseErr(codes, schema, options) {
|
|
50
|
-
return { ...options, err: true, enc: "sse", codes, schema };
|
|
51
|
-
}
|
|
52
|
-
export function sse(codes, schema, options) {
|
|
53
|
-
return { ...options, enc: "sse", codes, schema };
|
|
54
|
-
}
|
|
55
|
-
export function nilErr(codes, schema, options) {
|
|
56
|
-
return { ...options, err: true, enc: "nil", codes, schema };
|
|
57
|
-
}
|
|
58
|
-
export function nil(codes, schema, options) {
|
|
59
|
-
return { ...options, enc: "nil", codes, schema };
|
|
60
|
-
}
|
|
61
|
-
export function fail(codes) {
|
|
62
|
-
return { enc: "fail", codes };
|
|
63
|
-
}
|
|
64
|
-
export function match(...matchers) {
|
|
65
|
-
return async function matchFunc(response, request, options) {
|
|
66
|
-
let raw;
|
|
67
|
-
let matcher;
|
|
68
|
-
for (const match of matchers) {
|
|
69
|
-
const { codes } = match;
|
|
70
|
-
const ctpattern = "ctype" in match
|
|
71
|
-
? match.ctype
|
|
72
|
-
: DEFAULT_CONTENT_TYPES[match.enc];
|
|
73
|
-
if (ctpattern && matchResponse(response, codes, ctpattern)) {
|
|
74
|
-
matcher = match;
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
else if (!ctpattern && matchStatusCode(response, codes)) {
|
|
78
|
-
matcher = match;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (!matcher) {
|
|
83
|
-
return [{
|
|
84
|
-
ok: false,
|
|
85
|
-
error: new OpenRouterDefaultError("Unexpected Status or Content-Type", {
|
|
86
|
-
response,
|
|
87
|
-
request,
|
|
88
|
-
body: await response.text().catch(() => ""),
|
|
89
|
-
}),
|
|
90
|
-
}, raw];
|
|
91
|
-
}
|
|
92
|
-
const encoding = matcher.enc;
|
|
93
|
-
let body = "";
|
|
94
|
-
switch (encoding) {
|
|
95
|
-
case "json":
|
|
96
|
-
body = await response.text();
|
|
97
|
-
raw = JSON.parse(body);
|
|
98
|
-
break;
|
|
99
|
-
case "jsonl":
|
|
100
|
-
raw = response.body;
|
|
101
|
-
break;
|
|
102
|
-
case "bytes":
|
|
103
|
-
raw = new Uint8Array(await response.arrayBuffer());
|
|
104
|
-
break;
|
|
105
|
-
case "stream":
|
|
106
|
-
raw = response.body;
|
|
107
|
-
break;
|
|
108
|
-
case "text":
|
|
109
|
-
body = await response.text();
|
|
110
|
-
raw = body;
|
|
111
|
-
break;
|
|
112
|
-
case "sse":
|
|
113
|
-
raw = response.body;
|
|
114
|
-
break;
|
|
115
|
-
case "nil":
|
|
116
|
-
body = await response.text();
|
|
117
|
-
raw = undefined;
|
|
118
|
-
break;
|
|
119
|
-
case "fail":
|
|
120
|
-
body = await response.text();
|
|
121
|
-
raw = body;
|
|
122
|
-
break;
|
|
123
|
-
default:
|
|
124
|
-
encoding;
|
|
125
|
-
throw new Error(`Unsupported response type: ${encoding}`);
|
|
126
|
-
}
|
|
127
|
-
if (matcher.enc === "fail") {
|
|
128
|
-
return [{
|
|
129
|
-
ok: false,
|
|
130
|
-
error: new OpenRouterDefaultError("API error occurred", {
|
|
131
|
-
request,
|
|
132
|
-
response,
|
|
133
|
-
body,
|
|
134
|
-
}),
|
|
135
|
-
}, raw];
|
|
136
|
-
}
|
|
137
|
-
const resultKey = matcher.key || options?.resultKey;
|
|
138
|
-
let data;
|
|
139
|
-
if ("err" in matcher) {
|
|
140
|
-
data = {
|
|
141
|
-
...options?.extraFields,
|
|
142
|
-
...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null),
|
|
143
|
-
...(isPlainObject(raw) ? raw : null),
|
|
144
|
-
request$: request,
|
|
145
|
-
response$: response,
|
|
146
|
-
body$: body,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
else if (resultKey) {
|
|
150
|
-
data = {
|
|
151
|
-
...options?.extraFields,
|
|
152
|
-
...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null),
|
|
153
|
-
[resultKey]: raw,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
else if (matcher.hdrs) {
|
|
157
|
-
data = {
|
|
158
|
-
...options?.extraFields,
|
|
159
|
-
...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null),
|
|
160
|
-
...(isPlainObject(raw) ? raw : null),
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
data = raw;
|
|
165
|
-
}
|
|
166
|
-
if ("err" in matcher) {
|
|
167
|
-
const result = safeParseResponse(data, (v) => matcher.schema.parse(v), "Response validation failed", { request, response, body });
|
|
168
|
-
return [result.ok ? { ok: false, error: result.value } : result, raw];
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
return [
|
|
172
|
-
safeParseResponse(data, (v) => matcher.schema.parse(v), "Response validation failed", { request, response, body }),
|
|
173
|
-
raw,
|
|
174
|
-
];
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
const headerValRE = /, */;
|
|
179
|
-
/**
|
|
180
|
-
* Iterates over a Headers object and returns an object with all the header
|
|
181
|
-
* entries. Values are represented as an array to account for repeated headers.
|
|
182
|
-
*/
|
|
183
|
-
export function unpackHeaders(headers) {
|
|
184
|
-
const out = {};
|
|
185
|
-
for (const [k, v] of headers.entries()) {
|
|
186
|
-
out[k] = v.split(headerValRE);
|
|
187
|
-
}
|
|
188
|
-
return out;
|
|
189
|
-
}
|
|
190
|
-
function safeParseResponse(rawValue, fn, errorMessage, httpMeta) {
|
|
191
|
-
try {
|
|
192
|
-
return OK(fn(rawValue));
|
|
193
|
-
}
|
|
194
|
-
catch (err) {
|
|
195
|
-
return ERR(new ResponseValidationError(errorMessage, {
|
|
196
|
-
cause: err,
|
|
197
|
-
rawValue,
|
|
198
|
-
rawMessage: errorMessage,
|
|
199
|
-
...httpMeta,
|
|
200
|
-
}));
|
|
201
|
-
}
|
|
202
|
-
}
|
package/lib/primitives.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export declare function invariant(condition: unknown, message: string): asserts condition;
|
|
2
|
-
export type ExactPartial<T> = {
|
|
3
|
-
[P in keyof T]?: T[P] | undefined;
|
|
4
|
-
};
|
|
5
|
-
export type Remap<Inp, Mapping extends {
|
|
6
|
-
[k in keyof Inp]?: string | null;
|
|
7
|
-
}> = {
|
|
8
|
-
[k in keyof Inp as Mapping[k] extends string ? Mapping[k] : Mapping[k] extends null ? never : k]: Inp[k];
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Converts or omits an object's keys according to a mapping.
|
|
12
|
-
*
|
|
13
|
-
* @param inp An object whose keys will be remapped
|
|
14
|
-
* @param mappings A mapping of original keys to new keys. If a key is not present in the mapping, it will be left as is. If a key is mapped to `null`, it will be removed in the resulting object.
|
|
15
|
-
* @returns A new object with keys remapped or omitted according to the mappings
|
|
16
|
-
*/
|
|
17
|
-
export declare function remap<Inp extends Record<string, unknown>, const Mapping extends {
|
|
18
|
-
[k in keyof Inp]?: string | null;
|
|
19
|
-
}>(inp: Inp, mappings: Mapping): Remap<Inp, Mapping>;
|
|
20
|
-
export declare function combineSignals(...signals: Array<AbortSignal | null | undefined>): AbortSignal | null;
|
|
21
|
-
export declare function abortSignalAny(signals: AbortSignal[]): AbortSignal;
|
|
22
|
-
export declare function compactMap<T>(values: Record<string, T | undefined>): Record<string, T>;
|
|
23
|
-
export declare function allRequired<V extends Record<string, unknown>>(v: V): {
|
|
24
|
-
[K in keyof V]: NonNullable<V[K]>;
|
|
25
|
-
} | undefined;
|
package/lib/primitives.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
class InvariantError extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = "InvariantError";
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export function invariant(condition, message) {
|
|
11
|
-
if (!condition) {
|
|
12
|
-
throw new InvariantError(message);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Converts or omits an object's keys according to a mapping.
|
|
17
|
-
*
|
|
18
|
-
* @param inp An object whose keys will be remapped
|
|
19
|
-
* @param mappings A mapping of original keys to new keys. If a key is not present in the mapping, it will be left as is. If a key is mapped to `null`, it will be removed in the resulting object.
|
|
20
|
-
* @returns A new object with keys remapped or omitted according to the mappings
|
|
21
|
-
*/
|
|
22
|
-
export function remap(inp, mappings) {
|
|
23
|
-
let out = {};
|
|
24
|
-
if (!Object.keys(mappings).length) {
|
|
25
|
-
out = inp;
|
|
26
|
-
return out;
|
|
27
|
-
}
|
|
28
|
-
for (const [k, v] of Object.entries(inp)) {
|
|
29
|
-
const j = mappings[k];
|
|
30
|
-
if (j === null) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
out[j ?? k] = v;
|
|
34
|
-
}
|
|
35
|
-
return out;
|
|
36
|
-
}
|
|
37
|
-
export function combineSignals(...signals) {
|
|
38
|
-
const filtered = [];
|
|
39
|
-
for (const signal of signals) {
|
|
40
|
-
if (signal) {
|
|
41
|
-
filtered.push(signal);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
switch (filtered.length) {
|
|
45
|
-
case 0:
|
|
46
|
-
case 1:
|
|
47
|
-
return filtered[0] || null;
|
|
48
|
-
default:
|
|
49
|
-
if ("any" in AbortSignal && typeof AbortSignal.any === "function") {
|
|
50
|
-
return AbortSignal.any(filtered);
|
|
51
|
-
}
|
|
52
|
-
return abortSignalAny(filtered);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
export function abortSignalAny(signals) {
|
|
56
|
-
const controller = new AbortController();
|
|
57
|
-
const result = controller.signal;
|
|
58
|
-
if (!signals.length) {
|
|
59
|
-
return controller.signal;
|
|
60
|
-
}
|
|
61
|
-
if (signals.length === 1) {
|
|
62
|
-
return signals[0] || controller.signal;
|
|
63
|
-
}
|
|
64
|
-
for (const signal of signals) {
|
|
65
|
-
if (signal.aborted) {
|
|
66
|
-
return signal;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function abort() {
|
|
70
|
-
controller.abort(this.reason);
|
|
71
|
-
clean();
|
|
72
|
-
}
|
|
73
|
-
const signalRefs = [];
|
|
74
|
-
function clean() {
|
|
75
|
-
for (const signalRef of signalRefs) {
|
|
76
|
-
const signal = signalRef.deref();
|
|
77
|
-
if (signal) {
|
|
78
|
-
signal.removeEventListener("abort", abort);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
for (const signal of signals) {
|
|
83
|
-
signalRefs.push(new WeakRef(signal));
|
|
84
|
-
signal.addEventListener("abort", abort);
|
|
85
|
-
}
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
export function compactMap(values) {
|
|
89
|
-
const out = {};
|
|
90
|
-
for (const [k, v] of Object.entries(values)) {
|
|
91
|
-
if (typeof v !== "undefined") {
|
|
92
|
-
out[k] = v;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return out;
|
|
96
|
-
}
|
|
97
|
-
export function allRequired(v) {
|
|
98
|
-
if (Object.values(v).every((x) => x == null)) {
|
|
99
|
-
return void 0;
|
|
100
|
-
}
|
|
101
|
-
return v;
|
|
102
|
-
}
|
package/lib/retries.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export type BackoffStrategy = {
|
|
2
|
-
initialInterval: number;
|
|
3
|
-
maxInterval: number;
|
|
4
|
-
exponent: number;
|
|
5
|
-
maxElapsedTime: number;
|
|
6
|
-
};
|
|
7
|
-
export type RetryConfig = {
|
|
8
|
-
strategy: "none";
|
|
9
|
-
} | {
|
|
10
|
-
strategy: "backoff";
|
|
11
|
-
backoff?: BackoffStrategy;
|
|
12
|
-
retryConnectionErrors?: boolean;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* PermanentError is an error that is not recoverable. Throwing this error will
|
|
16
|
-
* cause a retry loop to terminate.
|
|
17
|
-
*/
|
|
18
|
-
export declare class PermanentError extends Error {
|
|
19
|
-
/** The underlying cause of the error. */
|
|
20
|
-
readonly cause: unknown;
|
|
21
|
-
constructor(message: string, options?: {
|
|
22
|
-
cause?: unknown;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* TemporaryError is an error is used to signal that an HTTP request can be
|
|
27
|
-
* retried as part of a retry loop. If retry attempts are exhausted and this
|
|
28
|
-
* error is thrown, the response will be returned to the caller.
|
|
29
|
-
*/
|
|
30
|
-
export declare class TemporaryError extends Error {
|
|
31
|
-
response: Response;
|
|
32
|
-
constructor(message: string, response: Response);
|
|
33
|
-
}
|
|
34
|
-
export declare function retry(fetchFn: () => Promise<Response>, options: {
|
|
35
|
-
config: RetryConfig;
|
|
36
|
-
statusCodes: string[];
|
|
37
|
-
}): Promise<Response>;
|
package/lib/retries.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
import { isConnectionError, isTimeoutError } from "./http.js";
|
|
5
|
-
const defaultBackoff = {
|
|
6
|
-
initialInterval: 500,
|
|
7
|
-
maxInterval: 60000,
|
|
8
|
-
exponent: 1.5,
|
|
9
|
-
maxElapsedTime: 3600000,
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* PermanentError is an error that is not recoverable. Throwing this error will
|
|
13
|
-
* cause a retry loop to terminate.
|
|
14
|
-
*/
|
|
15
|
-
export class PermanentError extends Error {
|
|
16
|
-
constructor(message, options) {
|
|
17
|
-
let msg = message;
|
|
18
|
-
if (options?.cause) {
|
|
19
|
-
msg += `: ${options.cause}`;
|
|
20
|
-
}
|
|
21
|
-
super(msg, options);
|
|
22
|
-
this.name = "PermanentError";
|
|
23
|
-
// In older runtimes, the cause field would not have been assigned through
|
|
24
|
-
// the super() call.
|
|
25
|
-
if (typeof this.cause === "undefined") {
|
|
26
|
-
this.cause = options?.cause;
|
|
27
|
-
}
|
|
28
|
-
Object.setPrototypeOf(this, PermanentError.prototype);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* TemporaryError is an error is used to signal that an HTTP request can be
|
|
33
|
-
* retried as part of a retry loop. If retry attempts are exhausted and this
|
|
34
|
-
* error is thrown, the response will be returned to the caller.
|
|
35
|
-
*/
|
|
36
|
-
export class TemporaryError extends Error {
|
|
37
|
-
constructor(message, response) {
|
|
38
|
-
super(message);
|
|
39
|
-
this.response = response;
|
|
40
|
-
this.name = "TemporaryError";
|
|
41
|
-
Object.setPrototypeOf(this, TemporaryError.prototype);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
export async function retry(fetchFn, options) {
|
|
45
|
-
switch (options.config.strategy) {
|
|
46
|
-
case "backoff":
|
|
47
|
-
return retryBackoff(wrapFetcher(fetchFn, {
|
|
48
|
-
statusCodes: options.statusCodes,
|
|
49
|
-
retryConnectionErrors: !!options.config.retryConnectionErrors,
|
|
50
|
-
}), options.config.backoff ?? defaultBackoff);
|
|
51
|
-
default:
|
|
52
|
-
return await fetchFn();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function wrapFetcher(fn, options) {
|
|
56
|
-
return async () => {
|
|
57
|
-
try {
|
|
58
|
-
const res = await fn();
|
|
59
|
-
if (isRetryableResponse(res, options.statusCodes)) {
|
|
60
|
-
throw new TemporaryError("Response failed with retryable status code", res);
|
|
61
|
-
}
|
|
62
|
-
return res;
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
if (err instanceof TemporaryError) {
|
|
66
|
-
throw err;
|
|
67
|
-
}
|
|
68
|
-
if (options.retryConnectionErrors &&
|
|
69
|
-
(isTimeoutError(err) || isConnectionError(err))) {
|
|
70
|
-
throw err;
|
|
71
|
-
}
|
|
72
|
-
throw new PermanentError("Permanent error", { cause: err });
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const codeRangeRE = new RegExp("^[0-9]xx$", "i");
|
|
77
|
-
function isRetryableResponse(res, statusCodes) {
|
|
78
|
-
const actual = `${res.status}`;
|
|
79
|
-
return statusCodes.some((code) => {
|
|
80
|
-
if (!codeRangeRE.test(code)) {
|
|
81
|
-
return code === actual;
|
|
82
|
-
}
|
|
83
|
-
const expectFamily = code.charAt(0);
|
|
84
|
-
if (!expectFamily) {
|
|
85
|
-
throw new Error("Invalid status code range");
|
|
86
|
-
}
|
|
87
|
-
const actualFamily = actual.charAt(0);
|
|
88
|
-
if (!actualFamily) {
|
|
89
|
-
throw new Error(`Invalid response status code: ${actual}`);
|
|
90
|
-
}
|
|
91
|
-
return actualFamily === expectFamily;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
async function retryBackoff(fn, strategy) {
|
|
95
|
-
const { maxElapsedTime, initialInterval, exponent, maxInterval } = strategy;
|
|
96
|
-
const start = Date.now();
|
|
97
|
-
let x = 0;
|
|
98
|
-
while (true) {
|
|
99
|
-
try {
|
|
100
|
-
const res = await fn();
|
|
101
|
-
return res;
|
|
102
|
-
}
|
|
103
|
-
catch (err) {
|
|
104
|
-
if (err instanceof PermanentError) {
|
|
105
|
-
throw err.cause;
|
|
106
|
-
}
|
|
107
|
-
const elapsed = Date.now() - start;
|
|
108
|
-
if (elapsed > maxElapsedTime) {
|
|
109
|
-
if (err instanceof TemporaryError) {
|
|
110
|
-
return err.response;
|
|
111
|
-
}
|
|
112
|
-
throw err;
|
|
113
|
-
}
|
|
114
|
-
let retryInterval = 0;
|
|
115
|
-
if (err instanceof TemporaryError) {
|
|
116
|
-
retryInterval = retryIntervalFromResponse(err.response);
|
|
117
|
-
}
|
|
118
|
-
if (retryInterval <= 0) {
|
|
119
|
-
retryInterval =
|
|
120
|
-
initialInterval * Math.pow(x, exponent) + Math.random() * 1000;
|
|
121
|
-
}
|
|
122
|
-
const d = Math.min(retryInterval, maxInterval);
|
|
123
|
-
await delay(d);
|
|
124
|
-
x++;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function retryIntervalFromResponse(res) {
|
|
129
|
-
const retryVal = res.headers.get("retry-after") || "";
|
|
130
|
-
if (!retryVal) {
|
|
131
|
-
return 0;
|
|
132
|
-
}
|
|
133
|
-
const parsedNumber = Number(retryVal);
|
|
134
|
-
if (Number.isInteger(parsedNumber)) {
|
|
135
|
-
return parsedNumber * 1000;
|
|
136
|
-
}
|
|
137
|
-
const parsedDate = Date.parse(retryVal);
|
|
138
|
-
if (Number.isInteger(parsedDate)) {
|
|
139
|
-
const deltaMS = parsedDate - Date.now();
|
|
140
|
-
return deltaMS > 0 ? Math.ceil(deltaMS) : 0;
|
|
141
|
-
}
|
|
142
|
-
return 0;
|
|
143
|
-
}
|
|
144
|
-
async function delay(delay) {
|
|
145
|
-
return new Promise((resolve) => setTimeout(resolve, delay));
|
|
146
|
-
}
|
package/lib/schemas.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { output, ZodEffects, ZodObject, ZodRawShape, ZodTypeAny } from "zod/v3";
|
|
2
|
-
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
3
|
-
import { Result } from "../types/fp.js";
|
|
4
|
-
/**
|
|
5
|
-
* Utility function that executes some code which may throw a ZodError. It
|
|
6
|
-
* intercepts this error and converts it to an SDKValidationError so as to not
|
|
7
|
-
* leak Zod implementation details to user code.
|
|
8
|
-
*/
|
|
9
|
-
export declare function parse<Inp, Out>(rawValue: Inp, fn: (value: Inp) => Out, errorMessage: string): Out;
|
|
10
|
-
/**
|
|
11
|
-
* Utility function that executes some code which may result in a ZodError. It
|
|
12
|
-
* intercepts this error and converts it to an SDKValidationError so as to not
|
|
13
|
-
* leak Zod implementation details to user code.
|
|
14
|
-
*/
|
|
15
|
-
export declare function safeParse<Inp, Out>(rawValue: Inp, fn: (value: Inp) => Out, errorMessage: string): Result<Out, SDKValidationError>;
|
|
16
|
-
export declare function collectExtraKeys<Shape extends ZodRawShape, Catchall extends ZodTypeAny, K extends string>(obj: ZodObject<Shape, "strip", Catchall>, extrasKey: K, optional: boolean): ZodEffects<typeof obj, output<ZodObject<Shape, "strict">> & {
|
|
17
|
-
[k in K]: Record<string, output<Catchall>>;
|
|
18
|
-
}>;
|
package/lib/schemas.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
import { ZodError, } from "zod/v3";
|
|
5
|
-
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
6
|
-
import { ERR, OK } from "../types/fp.js";
|
|
7
|
-
/**
|
|
8
|
-
* Utility function that executes some code which may throw a ZodError. It
|
|
9
|
-
* intercepts this error and converts it to an SDKValidationError so as to not
|
|
10
|
-
* leak Zod implementation details to user code.
|
|
11
|
-
*/
|
|
12
|
-
export function parse(rawValue, fn, errorMessage) {
|
|
13
|
-
try {
|
|
14
|
-
return fn(rawValue);
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
if (err instanceof ZodError) {
|
|
18
|
-
throw new SDKValidationError(errorMessage, err, rawValue);
|
|
19
|
-
}
|
|
20
|
-
throw err;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Utility function that executes some code which may result in a ZodError. It
|
|
25
|
-
* intercepts this error and converts it to an SDKValidationError so as to not
|
|
26
|
-
* leak Zod implementation details to user code.
|
|
27
|
-
*/
|
|
28
|
-
export function safeParse(rawValue, fn, errorMessage) {
|
|
29
|
-
try {
|
|
30
|
-
return OK(fn(rawValue));
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
return ERR(new SDKValidationError(errorMessage, err, rawValue));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export function collectExtraKeys(obj, extrasKey, optional) {
|
|
37
|
-
return obj.transform((val) => {
|
|
38
|
-
const extras = {};
|
|
39
|
-
const { shape } = obj;
|
|
40
|
-
for (const [key] of Object.entries(val)) {
|
|
41
|
-
if (key in shape) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
const v = val[key];
|
|
45
|
-
if (typeof v === "undefined") {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
extras[key] = v;
|
|
49
|
-
delete val[key];
|
|
50
|
-
}
|
|
51
|
-
if (optional && Object.keys(extras).length === 0) {
|
|
52
|
-
return val;
|
|
53
|
-
}
|
|
54
|
-
return { ...val, [extrasKey]: extras };
|
|
55
|
-
});
|
|
56
|
-
}
|
package/lib/sdks.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { SDKHooks } from "../hooks/hooks.js";
|
|
2
|
-
import { HookContext } from "../hooks/types.js";
|
|
3
|
-
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
|
|
4
|
-
import { Result } from "../types/fp.js";
|
|
5
|
-
import { SDKOptions } from "./config.js";
|
|
6
|
-
import { RetryConfig } from "./retries.js";
|
|
7
|
-
import { SecurityState } from "./security.js";
|
|
8
|
-
export type RequestOptions = {
|
|
9
|
-
/**
|
|
10
|
-
* Sets a timeout, in milliseconds, on HTTP requests made by an SDK method. If
|
|
11
|
-
* `fetchOptions.signal` is set then it will take precedence over this option.
|
|
12
|
-
*/
|
|
13
|
-
timeoutMs?: number;
|
|
14
|
-
/**
|
|
15
|
-
* Set or override a retry policy on HTTP calls.
|
|
16
|
-
*/
|
|
17
|
-
retries?: RetryConfig;
|
|
18
|
-
/**
|
|
19
|
-
* Specifies the status codes which should be retried using the given retry policy.
|
|
20
|
-
*/
|
|
21
|
-
retryCodes?: string[];
|
|
22
|
-
/**
|
|
23
|
-
* Overrides the base server URL that will be used by an operation.
|
|
24
|
-
*/
|
|
25
|
-
serverURL?: string | URL;
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated `fetchOptions` has been flattened into `RequestOptions`.
|
|
28
|
-
*
|
|
29
|
-
* Sets various request options on the `fetch` call made by an SDK method.
|
|
30
|
-
*
|
|
31
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options|Request}
|
|
32
|
-
*/
|
|
33
|
-
fetchOptions?: Omit<RequestInit, "method" | "body">;
|
|
34
|
-
} & Omit<RequestInit, "method" | "body">;
|
|
35
|
-
type RequestConfig = {
|
|
36
|
-
method: string;
|
|
37
|
-
path: string;
|
|
38
|
-
baseURL?: string | URL | undefined;
|
|
39
|
-
query?: string;
|
|
40
|
-
body?: RequestInit["body"];
|
|
41
|
-
headers?: HeadersInit;
|
|
42
|
-
security?: SecurityState | null;
|
|
43
|
-
uaHeader?: string;
|
|
44
|
-
userAgent?: string | undefined;
|
|
45
|
-
timeoutMs?: number;
|
|
46
|
-
};
|
|
47
|
-
export declare class ClientSDK {
|
|
48
|
-
#private;
|
|
49
|
-
readonly _baseURL: URL | null;
|
|
50
|
-
readonly _options: SDKOptions & {
|
|
51
|
-
hooks?: SDKHooks;
|
|
52
|
-
};
|
|
53
|
-
constructor(options?: SDKOptions);
|
|
54
|
-
_createRequest(context: HookContext, conf: RequestConfig, options?: RequestOptions): Result<Request, InvalidRequestError | UnexpectedClientError>;
|
|
55
|
-
_do(request: Request, options: {
|
|
56
|
-
context: HookContext;
|
|
57
|
-
errorCodes: number | string | (number | string)[];
|
|
58
|
-
retryConfig: RetryConfig;
|
|
59
|
-
retryCodes: string[];
|
|
60
|
-
}): Promise<Result<Response, RequestAbortedError | RequestTimeoutError | ConnectionError | UnexpectedClientError>>;
|
|
61
|
-
}
|
|
62
|
-
export {};
|