diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 8231e419..3aee01f9 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -5,8 +5,10 @@ management: docVersion: 0.0.0 speakeasyVersion: 1.469.10 generationVersion: 2.493.31 - releaseVersion: 0.1.1 - configChecksum: e5e857e20b1a8ded6ae8e626c09aa97d + releaseVersion: 0.1.2 + configChecksum: b9cc53548e6012078ebb6189b18868ed + repoURL: https://github.com/documenso/sdk-typescript.git + installationURL: https://github.com/documenso/sdk-typescript published: true features: typescript: @@ -14,7 +16,6 @@ features: constsAndDefaults: 0.1.11 core: 3.18.16 defaultEnabledRetries: 0.1.0 - devContainers: 2.90.0 enumUnions: 0.1.0 envVarSecurityUsage: 0.1.2 globalSecurity: 2.82.12 @@ -29,9 +30,6 @@ features: sdkHooks: 0.2.0 unions: 2.85.8 generatedFiles: - - .devcontainer/README.md - - .devcontainer/devcontainer.json - - .devcontainer/setup.sh - .eslintrc.cjs - .gitattributes - .npmignore diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 03e789b2..349e6c14 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -13,7 +13,7 @@ generation: oAuth2ClientCredentialsEnabled: true oAuth2PasswordEnabled: true typescript: - version: 0.1.1 + version: 0.1.2 additionalDependencies: dependencies: {} devDependencies: {} @@ -41,7 +41,7 @@ typescript: methodArguments: require-security-and-request moduleFormat: commonjs outputModelSuffix: output - packageName: "@documenso/sdk-typescript" + packageName: '@documenso/sdk-typescript' responseFormat: flat templateVersion: v2 useIndexModules: true diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index a9ed8e06..69cc3300 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,19 +2,20 @@ speakeasyVersion: 1.469.10 sources: Documenso v2 beta API: sourceNamespace: documenso-v-2-beta-api - sourceRevisionDigest: sha256:95ffeb1aa479735642965b97f50f53ca294a5fa116f6a7ae22d62695b0f54460 + sourceRevisionDigest: sha256:93ee78e094f9f5de4c126c6a06c363e22412c11a874255e545a8cb610b3bf047 sourceBlobDigest: sha256:b54d7f793fedc532b07ad3a417aa86f4af3d1b4f9e7496550ce6cf5a455187fb tags: - latest + - speakeasy-sdk-regen-1737368101 - 0.0.0 targets: documenso: source: Documenso v2 beta API sourceNamespace: documenso-v-2-beta-api - sourceRevisionDigest: sha256:95ffeb1aa479735642965b97f50f53ca294a5fa116f6a7ae22d62695b0f54460 + sourceRevisionDigest: sha256:93ee78e094f9f5de4c126c6a06c363e22412c11a874255e545a8cb610b3bf047 sourceBlobDigest: sha256:b54d7f793fedc532b07ad3a417aa86f4af3d1b4f9e7496550ce6cf5a455187fb codeSamplesNamespace: documenso-v-2-beta-api-typescript-code-samples - codeSamplesRevisionDigest: sha256:3cfbd3ec88e22ee235f505b444abaf45460dc42ec037be02119b4c3ae8db798d + codeSamplesRevisionDigest: sha256:88d3d249a42c45220d4b668f0fe65b78cc17890da031e29c7211419a2442e992 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index 4a85143c..9dd974c4 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ Documenso v2 beta API: Subject to breaking changes until v2 is fully released. * [Standalone functions](#standalone-functions) * [Retries](#retries) * [Error Handling](#error-handling) + * [Server Selection](#server-selection) + * [Custom HTTP Client](#custom-http-client) * [Debugging](#debugging) * [Development](#development) * [Maturity](#maturity) @@ -424,6 +426,83 @@ In some rare cases, the SDK can fail to get a response from the server or even m + +## Server Selection + +### Override Server URL Per-Client + +The default server can also be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example: +```typescript +import { Documenso } from "@documenso/sdk-typescript"; + +const documenso = new Documenso({ + serverURL: "https://app.documenso.com/api/v2-beta", + apiKey: process.env["DOCUMENSO_API_KEY"] ?? "", +}); + +async function run() { + const result = await documenso.documents.find({ + orderByDirection: "desc", + }); + + // Handle the result + console.log(result); +} + +run(); + +``` + + + +## Custom HTTP Client + +The TypeScript SDK makes API calls using an `HTTPClient` that wraps the native +[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This +client is a thin wrapper around `fetch` and provides the ability to attach hooks +around the request lifecycle that can be used to modify the request or handle +errors and response. + +The `HTTPClient` constructor takes an optional `fetcher` argument that can be +used to integrate a third-party HTTP client or when writing tests to mock out +the HTTP client and feed in fixtures. + +The following example shows how to use the `"beforeRequest"` hook to to add a +custom header and a timeout to requests and how to use the `"requestError"` hook +to log errors: + +```typescript +import { Documenso } from "@documenso/sdk-typescript"; +import { HTTPClient } from "@documenso/sdk-typescript/lib/http"; + +const httpClient = new HTTPClient({ + // fetcher takes a function that has the same signature as native `fetch`. + fetcher: (request) => { + return fetch(request); + } +}); + +httpClient.addHook("beforeRequest", (request) => { + const nextRequest = new Request(request, { + signal: request.signal || AbortSignal.timeout(5000) + }); + + nextRequest.headers.set("x-custom-header", "custom value"); + + return nextRequest; +}); + +httpClient.addHook("requestError", (error, request) => { + console.group("Request Error"); + console.log("Reason:", `${error}`); + console.log("Endpoint:", `${request.method} ${request.url}`); + console.groupEnd(); +}); + +const sdk = new Documenso({ httpClient }); +``` + + ## Debugging diff --git a/RELEASES.md b/RELEASES.md new file mode 100644 index 00000000..bf211b63 --- /dev/null +++ b/RELEASES.md @@ -0,0 +1,11 @@ + + +## 2025-01-20 10:23:14 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.469.10 (2.493.31) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.1.2] . +### Releases +- [NPM v0.1.2] https://www.npmjs.com/package/@documenso/sdk-typescript/v/0.1.2 - . \ No newline at end of file diff --git a/docs/models/operations/directlink.md b/docs/models/operations/directlink.md index 011023d0..b5b5dcd5 100644 --- a/docs/models/operations/directlink.md +++ b/docs/models/operations/directlink.md @@ -9,7 +9,7 @@ let value: DirectLink = { id: "", templateId: 514767, token: "", - createdAt: "1710260121777", + createdAt: "1710261542647", enabled: false, directTemplateRecipientId: 712893, }; diff --git a/docs/models/operations/document.md b/docs/models/operations/document.md index 4d33c313..82a57491 100644 --- a/docs/models/operations/document.md +++ b/docs/models/operations/document.md @@ -21,8 +21,8 @@ let value: Document = { }, title: "", documentDataId: "", - createdAt: "1718997069708", - updatedAt: "1737292163076", + createdAt: "1718998489873", + updatedAt: "1737293583241", completedAt: "", deletedAt: "", teamId: 604118, diff --git a/docs/models/operations/documentcreatedocumenttemporaryresponsebody.md b/docs/models/operations/documentcreatedocumenttemporaryresponsebody.md index 0374db47..c5a788cf 100644 --- a/docs/models/operations/documentcreatedocumenttemporaryresponsebody.md +++ b/docs/models/operations/documentcreatedocumenttemporaryresponsebody.md @@ -24,8 +24,8 @@ let value: DocumentCreateDocumentTemporaryResponseBody = { }, title: "", documentDataId: "", - createdAt: "1727795489058", - updatedAt: "1737351120842", + createdAt: "1727796909232", + updatedAt: "1737352541016", completedAt: "", deletedAt: "", teamId: 509807, diff --git a/docs/models/operations/documentfinddocumentsdata.md b/docs/models/operations/documentfinddocumentsdata.md index af4d8e71..f0fdbfe3 100644 --- a/docs/models/operations/documentfinddocumentsdata.md +++ b/docs/models/operations/documentfinddocumentsdata.md @@ -21,8 +21,8 @@ let value: DocumentFindDocumentsData = { }, title: "", documentDataId: "", - createdAt: "1719662956408", - updatedAt: "1737366214030", + createdAt: "1719664376312", + updatedAt: "1737367633934", completedAt: "", deletedAt: "", teamId: 102044, diff --git a/docs/models/operations/documentfinddocumentsresponsebody.md b/docs/models/operations/documentfinddocumentsresponsebody.md index c277c97c..a44bed4c 100644 --- a/docs/models/operations/documentfinddocumentsresponsebody.md +++ b/docs/models/operations/documentfinddocumentsresponsebody.md @@ -25,8 +25,8 @@ let value: DocumentFindDocumentsResponseBody = { }, title: "", documentDataId: "", - createdAt: "1728421313518", - updatedAt: "1737305823922", + createdAt: "1728422733427", + updatedAt: "1737307243831", completedAt: "", deletedAt: "", teamId: 183191, diff --git a/docs/models/operations/documentgetdocumentwithdetailsbyidresponsebody.md b/docs/models/operations/documentgetdocumentwithdetailsbyidresponsebody.md index e90b08c8..bceef398 100644 --- a/docs/models/operations/documentgetdocumentwithdetailsbyidresponsebody.md +++ b/docs/models/operations/documentgetdocumentwithdetailsbyidresponsebody.md @@ -23,8 +23,8 @@ let value: DocumentGetDocumentWithDetailsByIdResponseBody = { }, title: "", documentDataId: "", - createdAt: "1712671282693", - updatedAt: "1737338108904", + createdAt: "1712672702673", + updatedAt: "1737339528884", completedAt: "", deletedAt: "", teamId: 263322, diff --git a/docs/models/operations/documentmovedocumenttoteamresponsebody.md b/docs/models/operations/documentmovedocumenttoteamresponsebody.md index 05d95ce0..941706d5 100644 --- a/docs/models/operations/documentmovedocumenttoteamresponsebody.md +++ b/docs/models/operations/documentmovedocumenttoteamresponsebody.md @@ -23,8 +23,8 @@ let value: DocumentMoveDocumentToTeamResponseBody = { }, title: "", documentDataId: "", - createdAt: "1721529111949", - updatedAt: "1737331024780", + createdAt: "1721530532201", + updatedAt: "1737332445032", completedAt: "", deletedAt: "", teamId: 241557, diff --git a/docs/models/operations/documentsenddocumentresponsebody.md b/docs/models/operations/documentsenddocumentresponsebody.md index ae28f0e8..c3d3802c 100644 --- a/docs/models/operations/documentsenddocumentresponsebody.md +++ b/docs/models/operations/documentsenddocumentresponsebody.md @@ -23,8 +23,8 @@ let value: DocumentSendDocumentResponseBody = { }, title: "", documentDataId: "", - createdAt: "1719447206859", - updatedAt: "1737333914484", + createdAt: "1719448627130", + updatedAt: "1737335334755", completedAt: "", deletedAt: "", teamId: 70042, diff --git a/docs/models/operations/documentsetsettingsfordocumentresponsebody.md b/docs/models/operations/documentsetsettingsfordocumentresponsebody.md index 20930766..ba1327d9 100644 --- a/docs/models/operations/documentsetsettingsfordocumentresponsebody.md +++ b/docs/models/operations/documentsetsettingsfordocumentresponsebody.md @@ -23,8 +23,8 @@ let value: DocumentSetSettingsForDocumentResponseBody = { }, title: "", documentDataId: "", - createdAt: "1707806508794", - updatedAt: "1737301719930", + createdAt: "1707807929024", + updatedAt: "1737303140161", completedAt: "", deletedAt: "", teamId: 432281, diff --git a/docs/models/operations/templatecreatedocumentfromtemplateresponsebody.md b/docs/models/operations/templatecreatedocumentfromtemplateresponsebody.md index bcc240cd..e863c6e7 100644 --- a/docs/models/operations/templatecreatedocumentfromtemplateresponsebody.md +++ b/docs/models/operations/templatecreatedocumentfromtemplateresponsebody.md @@ -23,8 +23,8 @@ let value: TemplateCreateDocumentFromTemplateResponseBody = { }, title: "", documentDataId: "", - createdAt: "1715613546296", - updatedAt: "1737325354277", + createdAt: "1715614967366", + updatedAt: "1737326775348", completedAt: "", deletedAt: "", teamId: 415953, diff --git a/docs/models/operations/templatecreatetemplatedirectlinkresponsebody.md b/docs/models/operations/templatecreatetemplatedirectlinkresponsebody.md index 64a99536..7fb1b118 100644 --- a/docs/models/operations/templatecreatetemplatedirectlinkresponsebody.md +++ b/docs/models/operations/templatecreatetemplatedirectlinkresponsebody.md @@ -11,7 +11,7 @@ let value: TemplateCreateTemplateDirectLinkResponseBody = { id: "", templateId: 933847, token: "", - createdAt: "1730235478042", + createdAt: "1730236899675", enabled: false, directTemplateRecipientId: 358861, }; diff --git a/docs/models/operations/templateduplicatetemplateresponsebody.md b/docs/models/operations/templateduplicatetemplateresponsebody.md index 2c7943f3..bbc253d9 100644 --- a/docs/models/operations/templateduplicatetemplateresponsebody.md +++ b/docs/models/operations/templateduplicatetemplateresponsebody.md @@ -20,8 +20,8 @@ let value: TemplateDuplicateTemplateResponseBody = { globalActionAuth: "TWO_FACTOR_AUTH", }, templateDocumentDataId: "", - createdAt: "1718812272893", - updatedAt: "1737307196042", + createdAt: "1718813693866", + updatedAt: "1737308617015", publicTitle: "", publicDescription: "", }; diff --git a/docs/models/operations/templatefindtemplatesdata.md b/docs/models/operations/templatefindtemplatesdata.md index 51542a59..145347a2 100644 --- a/docs/models/operations/templatefindtemplatesdata.md +++ b/docs/models/operations/templatefindtemplatesdata.md @@ -18,8 +18,8 @@ let value: TemplateFindTemplatesData = { globalActionAuth: "PASSKEY", }, templateDocumentDataId: "", - createdAt: "1722862173160", - updatedAt: "1737336595499", + createdAt: "1722863594003", + updatedAt: "1737338016343", publicTitle: "", publicDescription: "", team: { diff --git a/docs/models/operations/templatefindtemplatesresponsebody.md b/docs/models/operations/templatefindtemplatesresponsebody.md index 855b7a64..7960b2dc 100644 --- a/docs/models/operations/templatefindtemplatesresponsebody.md +++ b/docs/models/operations/templatefindtemplatesresponsebody.md @@ -22,8 +22,8 @@ let value: TemplateFindTemplatesResponseBody = { globalActionAuth: "ACCOUNT", }, templateDocumentDataId: "", - createdAt: "1715813661601", - updatedAt: "1737306632855", + createdAt: "1715815082451", + updatedAt: "1737308053705", publicTitle: "", publicDescription: "", team: { diff --git a/docs/models/operations/templategettemplatebyidresponsebody.md b/docs/models/operations/templategettemplatebyidresponsebody.md index ad6978f4..bbdf1688 100644 --- a/docs/models/operations/templategettemplatebyidresponsebody.md +++ b/docs/models/operations/templategettemplatebyidresponsebody.md @@ -20,8 +20,8 @@ let value: TemplateGetTemplateByIdResponseBody = { globalActionAuth: "TWO_FACTOR_AUTH", }, templateDocumentDataId: "", - createdAt: "1734473741211", - updatedAt: "1737293811299", + createdAt: "1734475162147", + updatedAt: "1737295232235", publicTitle: "", publicDescription: "", templateDocumentData: { @@ -48,7 +48,7 @@ let value: TemplateGetTemplateByIdResponseBody = { id: "", templateId: 738152, token: "", - createdAt: "1734418419060", + createdAt: "1734419839998", enabled: false, directTemplateRecipientId: 799866, }, diff --git a/docs/models/operations/templatemovetemplatetoteamresponsebody.md b/docs/models/operations/templatemovetemplatetoteamresponsebody.md index d53159ff..da7efb93 100644 --- a/docs/models/operations/templatemovetemplatetoteamresponsebody.md +++ b/docs/models/operations/templatemovetemplatetoteamresponsebody.md @@ -20,8 +20,8 @@ let value: TemplateMoveTemplateToTeamResponseBody = { globalActionAuth: "PASSKEY", }, templateDocumentDataId: "", - createdAt: "1729781243761", - updatedAt: "1737296217774", + createdAt: "1729782664846", + updatedAt: "1737297638859", publicTitle: "", publicDescription: "", }; diff --git a/docs/models/operations/templatetoggletemplatedirectlinkresponsebody.md b/docs/models/operations/templatetoggletemplatedirectlinkresponsebody.md index 4f52931a..ae45f046 100644 --- a/docs/models/operations/templatetoggletemplatedirectlinkresponsebody.md +++ b/docs/models/operations/templatetoggletemplatedirectlinkresponsebody.md @@ -11,7 +11,7 @@ let value: TemplateToggleTemplateDirectLinkResponseBody = { id: "", templateId: 409295, token: "", - createdAt: "1708881108768", + createdAt: "1708882530406", enabled: false, directTemplateRecipientId: 656939, }; diff --git a/docs/models/operations/templateupdatetemplateresponsebody.md b/docs/models/operations/templateupdatetemplateresponsebody.md index 94a27485..146527b9 100644 --- a/docs/models/operations/templateupdatetemplateresponsebody.md +++ b/docs/models/operations/templateupdatetemplateresponsebody.md @@ -20,8 +20,8 @@ let value: TemplateUpdateTemplateResponseBody = { globalActionAuth: "ACCOUNT", }, templateDocumentDataId: "", - createdAt: "1737320754424", - updatedAt: "1737292189301", + createdAt: "1737322175387", + updatedAt: "1737293610264", publicTitle: "", publicDescription: "", }; diff --git a/jsr.json b/jsr.json index f63e0cfd..307d9ea4 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@documenso/sdk-typescript", - "version": "0.1.1", + "version": "0.1.2", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index 03ef8e69..ec8a3f4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@documenso/sdk-typescript", - "version": "0.1.1", + "version": "0.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@documenso/sdk-typescript", - "version": "0.1.1", + "version": "0.1.2", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", diff --git a/package.json b/package.json index 8f1ddab2..0008a88f 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,13 @@ { "name": "@documenso/sdk-typescript", - "version": "0.1.1", + "version": "0.1.2", "author": "Speakeasy", "main": "./index.js", "sideEffects": false, + "repository": { + "type": "git", + "url": "https://github.com/documenso/sdk-typescript.git" + }, "scripts": { "lint": "eslint --max-warnings=0 src", "build": "tsc", diff --git a/src/lib/config.ts b/src/lib/config.ts index 1dbc8d1e..f0fda5ed 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -54,8 +54,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "0.0.0", - sdkVersion: "0.1.1", + sdkVersion: "0.1.2", genVersion: "2.493.31", userAgent: - "speakeasy-sdk/typescript 0.1.1 2.493.31 0.0.0 @documenso/sdk-typescript", + "speakeasy-sdk/typescript 0.1.2 2.493.31 0.0.0 @documenso/sdk-typescript", } as const;