From 5b4edcbb227ac9c3719602376500f6e57d441d15 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 11:03:53 +0530 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.277.4 (#94) Co-authored-by: speakeasybot --- .speakeasy/gen.lock | 13 +- .speakeasy/gen.yaml | 2 +- .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 +- codeSamples.yaml | 559 +++++++++---------- docs/models/components/linkschema.md | 2 +- docs/models/operations/getlinkinforequest.md | 10 +- docs/sdks/links/README.md | 7 +- jsr.json | 2 +- package-lock.json | 4 +- package.json | 2 +- src/lib/config.ts | 6 +- src/lib/http.ts | 57 +- src/lib/security.ts | 2 +- src/models/components/linkschema.ts | 11 +- src/models/errors/sdkerror.ts | 5 +- src/models/operations/getlinkinfo.ts | 48 +- src/sdk/analytics.ts | 60 +- src/sdk/domains.ts | 36 +- src/sdk/links.ts | 49 +- src/sdk/metatags.ts | 6 +- src/sdk/qrcodes.ts | 20 +- src/sdk/tags.ts | 12 +- src/sdk/workspaces.ts | 18 +- 24 files changed, 559 insertions(+), 394 deletions(-) diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index b4d4305..13610fa 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,20 +1,19 @@ lockVersion: 2.0.0 id: f28179cc-ef59-426d-9e85-60cec22fc642 management: - docChecksum: 0008b3cde645369b98ab1f75381bb11a + docChecksum: 1504d2d6c3f4514d30a37a76c74a48a5 docVersion: 0.0.1 - speakeasyVersion: 1.276.0 - generationVersion: 2.314.0 - releaseVersion: 0.25.2 - configChecksum: a717018481b6fdc4d6146485565263e5 + speakeasyVersion: 1.277.4 + generationVersion: 2.318.3 + releaseVersion: 0.26.0 + configChecksum: 640563cb2897eac551ae0d2397065a1c repoURL: https://github.com/dubinc/dub-node.git installationURL: https://github.com/dubinc/dub-node published: true features: typescript: - acceptHeaders: 2.81.1 constsAndDefaults: 0.1.5 - core: 3.9.0 + core: 3.9.2 deprecations: 2.81.1 examples: 2.81.3 flattening: 2.81.1 diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index c6e3e50..3d2e271 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false typescript: - version: 0.25.2 + version: 0.26.0 additionalDependencies: dependencies: {} devDependencies: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 1d93469..f44e8be 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,17 +1,17 @@ -speakeasyVersion: 1.276.0 +speakeasyVersion: 1.277.4 sources: my-first-source: sourceNamespace: my-first-source - sourceRevisionDigest: sha256:365db128287dc83d36c7a0e2ce43b6abfe2e5108053a272988c8240fcafce541 - sourceBlobDigest: sha256:3b411021fd54342776cd1a1f631e53f2f51e7b299ba8ced635a3bdedaf86f225 + sourceRevisionDigest: sha256:55ec84ef7f4cfe2ce4c37f825adf9e34af493fc6bd28fc897643faea892381a4 + sourceBlobDigest: sha256:646aaaaf591cd2d029735da923e4ddf83e85d98d268353bb9c884cd77000c4b2 tags: - latest targets: my-first-target: source: my-first-source sourceNamespace: my-first-source - sourceRevisionDigest: sha256:365db128287dc83d36c7a0e2ce43b6abfe2e5108053a272988c8240fcafce541 - sourceBlobDigest: sha256:3b411021fd54342776cd1a1f631e53f2f51e7b299ba8ced635a3bdedaf86f225 + sourceRevisionDigest: sha256:55ec84ef7f4cfe2ce4c37f825adf9e34af493fc6bd28fc897643faea892381a4 + sourceBlobDigest: sha256:646aaaaf591cd2d029735da923e4ddf83e85d98d268353bb9c884cd77000c4b2 outLocation: /github/workspace/repo workflow: workflowVersion: 1.0.0 diff --git a/RELEASES.md b/RELEASES.md index 4c6dbfc..17c848a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -206,4 +206,14 @@ Based on: ### Generated - [typescript v0.25.2] . ### Releases -- [NPM v0.25.2] https://www.npmjs.com/package/dub/v/0.25.2 - . \ No newline at end of file +- [NPM v0.25.2] https://www.npmjs.com/package/dub/v/0.25.2 - . + +## 2024-05-01 01:17:50 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.277.4 (2.318.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.26.0] . +### Releases +- [NPM v0.26.0] https://www.npmjs.com/package/dub/v/0.26.0 - . \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index ccdd1fb..7c31650 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -24,11 +24,11 @@ actions: } run(); - - target: $["paths"]["/analytics/city"]["get"] + - target: $["paths"]["/analytics/timeseries"]["get"] update: "x-codeSamples": - "lang": "typescript" - "label": "getCityAnalytics" + "label": "getTimeseriesAnalytics" "source": |- import { Dub } from "dub"; @@ -38,7 +38,80 @@ actions: }); async function run() { - const result = await dub.cities({}); + const result = await dub.timeseries({}); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/analytics/device"]["get"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "getDeviceAnalytics" + "source": |- + import { Dub } from "dub"; + + const dub = new Dub({ + token: "DUB_API_KEY", + workspaceId: "", + }); + + async function run() { + const result = await dub.devices({}); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/analytics/referer"]["get"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "getRefererAnalytics" + "source": |- + import { Dub } from "dub"; + + const dub = new Dub({ + token: "DUB_API_KEY", + workspaceId: "", + }); + + async function run() { + const result = await dub.referers({}); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/domains/{slug}"]["patch"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "editDomain" + "source": "import { Dub } from \"dub\";\n\nconst dub = new Dub({\n token: \"DUB_API_KEY\",\n workspaceId: \"\",\n});\n\nasync function run() {\n const slug = \"acme.com\";\n const requestBody = {};\n \n const result = await dub.update(slug, requestBody);\n\n // Handle the result\n console.log(result)\n}\n\nrun();" + - target: $["paths"]["/links/bulk"]["post"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "bulkCreateLinks" + "source": |- + import { Dub } from "dub"; + + const dub = new Dub({ + token: "DUB_API_KEY", + workspaceId: "", + }); + + async function run() { + const result = await dub.createMany([ + { + url: "https://google/com", + }, + ]); // Handle the result console.log(result) @@ -86,168 +159,6 @@ actions: console.log(result) } - run(); - - target: $["paths"]["/links/{linkId}"]["put"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "editLink" - "source": "import { Dub } from \"dub\";\n\nconst dub = new Dub({\n token: \"DUB_API_KEY\",\n workspaceId: \"\",\n});\n\nasync function run() {\n const linkId = \"\";\n const requestBody = {\n url: \"https://google/com\",\n };\n \n const result = await dub.update(linkId, requestBody);\n\n // Handle the result\n console.log(result)\n}\n\nrun();" - - target: $["paths"]["/domains"]["get"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "listDomains" - "source": |- - import { Dub } from "dub"; - - const dub = new Dub({ - token: "DUB_API_KEY", - workspaceId: "", - }); - - async function run() { - const result = await dub.list({}); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/analytics/timeseries"]["get"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "getTimeseriesAnalytics" - "source": |- - import { Dub } from "dub"; - - const dub = new Dub({ - token: "DUB_API_KEY", - workspaceId: "", - }); - - async function run() { - const result = await dub.timeseries({}); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/domains"]["post"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "addDomain" - "source": |- - import { Dub } from "dub"; - - const dub = new Dub({ - token: "DUB_API_KEY", - workspaceId: "", - }); - - async function run() { - const result = await dub.add({ - slug: "acme.com", - }); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/links/info"]["get"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "getLinkInfo" - "source": |- - import { Dub } from "dub"; - - const dub = new Dub({ - token: "DUB_API_KEY", - workspaceId: "", - }); - - async function run() { - const result = await dub.get({ - domain: "ringed-blow.name", - key: "", - }); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/links/bulk"]["post"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "bulkCreateLinks" - "source": |- - import { Dub } from "dub"; - - const dub = new Dub({ - token: "DUB_API_KEY", - workspaceId: "", - }); - - async function run() { - const result = await dub.createMany([ - { - url: "https://google/com", - }, - ]); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/analytics/country"]["get"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "getCountryAnalytics" - "source": |- - import { Dub } from "dub"; - - const dub = new Dub({ - token: "DUB_API_KEY", - workspaceId: "", - }); - - async function run() { - const result = await dub.countries({}); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/analytics/device"]["get"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "getDeviceAnalytics" - "source": |- - import { Dub } from "dub"; - - const dub = new Dub({ - token: "DUB_API_KEY", - workspaceId: "", - }); - - async function run() { - const result = await dub.devices({}); - - // Handle the result - console.log(result) - } - run(); - target: $["paths"]["/workspaces/{idOrSlug}"]["get"] update: @@ -272,11 +183,11 @@ actions: } run(); - - target: $["paths"]["/tags"]["get"] + - target: $["paths"]["/analytics/top_links"]["get"] update: "x-codeSamples": - "lang": "typescript" - "label": "getTags" + "label": "getTopLinks" "source": |- import { Dub } from "dub"; @@ -286,49 +197,7 @@ actions: }); async function run() { - const result = await dub.list({}); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/links"]["get"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "getLinks" - "source": |- - import { Dub } from "dub"; - - const dub = new Dub({ - token: "DUB_API_KEY", - workspaceId: "", - }); - - async function run() { - const result = await dub.list({}); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/workspaces"]["get"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "getWorkspaces" - "source": |- - import { Dub } from "dub"; - - const dub = new Dub({ - token: "DUB_API_KEY", - workspaceId: "", - }); - - async function run() { - const result = await dub.list(); + const result = await dub.topLinks({}); // Handle the result console.log(result) @@ -341,17 +210,11 @@ actions: - "lang": "typescript" "label": "deleteDomain" "source": "import { Dub } from \"dub\";\n\nconst dub = new Dub({\n token: \"DUB_API_KEY\",\n workspaceId: \"\",\n});\n\nasync function run() {\n const slug = \"acme.com\";\n \n const result = await dub.delete(slug);\n\n // Handle the result\n console.log(result)\n}\n\nrun();" - - target: $["paths"]["/domains/{slug}/primary"]["post"] + - target: $["paths"]["/analytics/country"]["get"] update: "x-codeSamples": - "lang": "typescript" - "label": "setPrimaryDomain" - "source": "import { Dub } from \"dub\";\n\nconst dub = new Dub({\n token: \"DUB_API_KEY\",\n workspaceId: \"\",\n});\n\nasync function run() {\n const slug = \"acme.com\";\n \n const result = await dub.setPrimary(slug);\n\n // Handle the result\n console.log(result)\n}\n\nrun();" - - target: $["paths"]["/metatags"]["get"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "getMetatags" + "label": "getCountryAnalytics" "source": |- import { Dub } from "dub"; @@ -361,8 +224,29 @@ actions: }); async function run() { - const result = await dub.get({ - url: "https://dub.co", + const result = await dub.countries({}); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/tags"]["post"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "createTag" + "source": |- + import { Dub } from "dub"; + + const dub = new Dub({ + token: "DUB_API_KEY", + workspaceId: "", + }); + + async function run() { + const result = await dub.create({ + tag: "", }); // Handle the result @@ -370,12 +254,33 @@ actions: } run(); - - target: $["paths"]["/domains/{slug}"]["patch"] + - target: $["paths"]["/domains/{slug}/primary"]["post"] update: "x-codeSamples": - "lang": "typescript" - "label": "editDomain" - "source": "import { Dub } from \"dub\";\n\nconst dub = new Dub({\n token: \"DUB_API_KEY\",\n workspaceId: \"\",\n});\n\nasync function run() {\n const slug = \"acme.com\";\n const requestBody = {};\n \n const result = await dub.update(slug, requestBody);\n\n // Handle the result\n console.log(result)\n}\n\nrun();" + "label": "setPrimaryDomain" + "source": "import { Dub } from \"dub\";\n\nconst dub = new Dub({\n token: \"DUB_API_KEY\",\n workspaceId: \"\",\n});\n\nasync function run() {\n const slug = \"acme.com\";\n \n const result = await dub.setPrimary(slug);\n\n // Handle the result\n console.log(result)\n}\n\nrun();" + - target: $["paths"]["/qr"]["get"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "getQRCode" + "source": |- + import { Dub } from "dub"; + + const dub = new Dub({ + token: "DUB_API_KEY", + workspaceId: "", + }); + + async function run() { + const result = await dub.get({}); + + // Handle the result + console.log(result) + } + + run(); - target: $["paths"]["/links"]["post"] update: "x-codeSamples": @@ -398,6 +303,35 @@ actions: console.log(result) } + run(); + - target: $["paths"]["/links/{linkId}"]["put"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "editLink" + "source": "import { Dub } from \"dub\";\n\nconst dub = new Dub({\n token: \"DUB_API_KEY\",\n workspaceId: \"\",\n});\n\nasync function run() {\n const linkId = \"\";\n const requestBody = {\n url: \"https://google/com\",\n };\n \n const result = await dub.update(linkId, requestBody);\n\n // Handle the result\n console.log(result)\n}\n\nrun();" + - target: $["paths"]["/domains"]["post"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "addDomain" + "source": |- + import { Dub } from "dub"; + + const dub = new Dub({ + token: "DUB_API_KEY", + workspaceId: "", + }); + + async function run() { + const result = await dub.add({ + slug: "acme.com", + }); + + // Handle the result + console.log(result) + } + run(); - target: $["paths"]["/links/count"]["get"] update: @@ -420,17 +354,11 @@ actions: } run(); - - target: $["paths"]["/links/{linkId}"]["delete"] + - target: $["paths"]["/links/info"]["get"] update: "x-codeSamples": - "lang": "typescript" - "label": "deleteLink" - "source": "import { Dub } from \"dub\";\n\nconst dub = new Dub({\n token: \"DUB_API_KEY\",\n workspaceId: \"\",\n});\n\nasync function run() {\n const linkId = \"\";\n \n const result = await dub.delete(linkId);\n\n // Handle the result\n console.log(result)\n}\n\nrun();" - - target: $["paths"]["/qr"]["get"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "getQRCode" + "label": "getLinkInfo" "source": |- import { Dub } from "dub"; @@ -447,11 +375,11 @@ actions: } run(); - - target: $["paths"]["/analytics/referer"]["get"] + - target: $["paths"]["/analytics/os"]["get"] update: "x-codeSamples": - "lang": "typescript" - "label": "getRefererAnalytics" + "label": "getOSAnalytics" "source": |- import { Dub } from "dub"; @@ -461,51 +389,7 @@ actions: }); async function run() { - const result = await dub.referers({}); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/analytics/top_links"]["get"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "getTopLinks" - "source": |- - import { Dub } from "dub"; - - const dub = new Dub({ - token: "DUB_API_KEY", - workspaceId: "", - }); - - async function run() { - const result = await dub.topLinks({}); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/tags"]["post"] - update: - "x-codeSamples": - - "lang": "typescript" - "label": "createTag" - "source": |- - import { Dub } from "dub"; - - const dub = new Dub({ - token: "DUB_API_KEY", - workspaceId: "", - }); - - async function run() { - const result = await dub.create({ - tag: "", - }); + const result = await dub.os({}); // Handle the result console.log(result) @@ -536,11 +420,11 @@ actions: } run(); - - target: $["paths"]["/analytics/os"]["get"] + - target: $["paths"]["/tags"]["get"] update: "x-codeSamples": - "lang": "typescript" - "label": "getOSAnalytics" + "label": "getTags" "source": |- import { Dub } from "dub"; @@ -550,7 +434,7 @@ actions: }); async function run() { - const result = await dub.os({}); + const result = await dub.list({}); // Handle the result console.log(result) @@ -563,3 +447,116 @@ actions: - "lang": "typescript" "label": "transferDomain" "source": "import { Dub } from \"dub\";\n\nconst dub = new Dub({\n token: \"DUB_API_KEY\",\n workspaceId: \"\",\n});\n\nasync function run() {\n const slug = \"acme.com\";\n const requestBody = {\n newWorkspaceId: \"\",\n };\n \n const result = await dub.transfer(slug, requestBody);\n\n // Handle the result\n console.log(result)\n}\n\nrun();" + - target: $["paths"]["/links"]["get"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "getLinks" + "source": |- + import { Dub } from "dub"; + + const dub = new Dub({ + token: "DUB_API_KEY", + workspaceId: "", + }); + + async function run() { + const result = await dub.list({}); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/links/{linkId}"]["delete"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "deleteLink" + "source": "import { Dub } from \"dub\";\n\nconst dub = new Dub({\n token: \"DUB_API_KEY\",\n workspaceId: \"\",\n});\n\nasync function run() {\n const linkId = \"\";\n \n const result = await dub.delete(linkId);\n\n // Handle the result\n console.log(result)\n}\n\nrun();" + - target: $["paths"]["/analytics/city"]["get"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "getCityAnalytics" + "source": |- + import { Dub } from "dub"; + + const dub = new Dub({ + token: "DUB_API_KEY", + workspaceId: "", + }); + + async function run() { + const result = await dub.cities({}); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/workspaces"]["get"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "getWorkspaces" + "source": |- + import { Dub } from "dub"; + + const dub = new Dub({ + token: "DUB_API_KEY", + workspaceId: "", + }); + + async function run() { + const result = await dub.list(); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/domains"]["get"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "listDomains" + "source": |- + import { Dub } from "dub"; + + const dub = new Dub({ + token: "DUB_API_KEY", + workspaceId: "", + }); + + async function run() { + const result = await dub.list({}); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/metatags"]["get"] + update: + "x-codeSamples": + - "lang": "typescript" + "label": "getMetatags" + "source": |- + import { Dub } from "dub"; + + const dub = new Dub({ + token: "DUB_API_KEY", + workspaceId: "", + }); + + async function run() { + const result = await dub.get({ + url: "https://dub.co", + }); + + // Handle the result + console.log(result) + } + + run(); diff --git a/docs/models/components/linkschema.md b/docs/models/components/linkschema.md index 4f808d2..57f5656 100644 --- a/docs/models/components/linkschema.md +++ b/docs/models/components/linkschema.md @@ -11,7 +11,7 @@ | `externalId` | *string* | :heavy_check_mark: | This is the ID of the link in your database. If set, it can be used to identify the link in the future. Must be prefixed with 'ext_' when passed as a query parameter. | | `url` | *string* | :heavy_check_mark: | The destination URL of the short link. | | `archived` | *boolean* | :heavy_minus_sign: | Whether the short link is archived. | -| `expiresAt` | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) | :heavy_check_mark: | The date and time when the short link will expire in ISO-8601 format. | +| `expiresAt` | *string* | :heavy_check_mark: | The date and time when the short link will expire in ISO-8601 format. | | `expiredUrl` | *string* | :heavy_check_mark: | The URL to redirect to when the short link has expired. | | `password` | *string* | :heavy_check_mark: | The password required to access the destination URL of the short link. | | `proxy` | *boolean* | :heavy_minus_sign: | Whether the short link uses Custom Social Media Cards feature. | diff --git a/docs/models/operations/getlinkinforequest.md b/docs/models/operations/getlinkinforequest.md index 07c56e4..dc8c7c7 100644 --- a/docs/models/operations/getlinkinforequest.md +++ b/docs/models/operations/getlinkinforequest.md @@ -3,7 +3,9 @@ ## Fields -| Field | Type | Required | Description | -| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | -| `domain` | *string* | :heavy_check_mark: | N/A | -| `key` | *string* | :heavy_check_mark: | The key of the link to retrieve. E.g. for `d.to/github`, the key is `github`. | \ No newline at end of file +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | +| `domain` | *string* | :heavy_minus_sign: | N/A | | +| `key` | *string* | :heavy_minus_sign: | The key of the link to retrieve. E.g. for `d.to/github`, the key is `github`. | | +| `linkId` | *string* | :heavy_minus_sign: | The unique ID of the short link. | clux0rgak00011... | +| `externalId` | *string* | :heavy_minus_sign: | This is the ID of the link in the your database. Must be prefixed with `ext_`. when provided. | ext_123456 | \ No newline at end of file diff --git a/docs/sdks/links/README.md b/docs/sdks/links/README.md index a015d4a..539bbcc 100644 --- a/docs/sdks/links/README.md +++ b/docs/sdks/links/README.md @@ -168,7 +168,7 @@ run(); ## get -Retrieve the info for a link from their domain and key. +Retrieve the info for a link. ### Example Usage @@ -181,10 +181,7 @@ const dub = new Dub({ }); async function run() { - const result = await dub.links.get({ - domain: "ringed-blow.name", - key: "", - }); + const result = await dub.links.get({}); // Handle the result console.log(result) diff --git a/jsr.json b/jsr.json index 7d6330d..09e70a3 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "dub", - "version": "0.25.2", + "version": "0.26.0", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index aacd685..800e9b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dub", - "version": "0.25.2", + "version": "0.26.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dub", - "version": "0.25.2", + "version": "0.26.0", "devDependencies": { "@types/jsonpath": "^0.2.4", "@types/node": "^20.12.7", diff --git a/package.json b/package.json index ab290e5..496c2f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dub", - "version": "0.25.2", + "version": "0.26.0", "author": "Dub", "main": "./index.js", "sideEffects": false, diff --git a/src/lib/config.ts b/src/lib/config.ts index 3ef3661..7071cf5 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -64,7 +64,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "0.0.1", - sdkVersion: "0.25.2", - genVersion: "2.314.0", - userAgent: "speakeasy-sdk/typescript 0.25.2 2.314.0 0.0.1 dub", + sdkVersion: "0.26.0", + genVersion: "2.318.3", + userAgent: "speakeasy-sdk/typescript 0.26.0 2.318.3 0.0.1 dub", } as const; diff --git a/src/lib/http.ts b/src/lib/http.ts index cc00dc1..b4e519c 100644 --- a/src/lib/http.ts +++ b/src/lib/http.ts @@ -141,29 +141,56 @@ export class HTTPClient { } } -export function matchContentType(response: Response, pattern: string): boolean { - if (pattern === "*" || pattern === "*/*") { +// A semicolon surrounded by optional whitespace characters is used to separate +// segments in a media type string. +const mediaParamSeparator = /\s*;\s*/g; + +function matchContentType(response: Response, pattern: string): boolean { + // `*` is a special case which means anything is acceptable. + if (pattern === "*") { return true; } - const contentType = - response.headers.get("content-type") ?? "application/octet-stream"; + let contentType = + response.headers.get("content-type")?.trim() || "application/octet-stream"; + contentType = contentType.toLowerCase(); - const idx = contentType.split(";").findIndex((raw) => { - const ctype = raw.trim(); - if (ctype === pattern) { - return true; - } + const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator); + const [wantType = "", ...wantParams] = wantParts; - const parts = ctype.split("/"); - if (parts.length !== 2) { + if (wantType.split("/").length !== 2) { + return false; + } + + const gotParts = contentType.split(mediaParamSeparator); + const [gotType = "", ...gotParams] = gotParts; + + const [type = "", subtype = ""] = gotType.split("/"); + if (!type || !subtype) { + return false; + } + + if ( + wantType !== "*/*" && + gotType !== wantType && + `${type}/*` !== wantType && + `*/${subtype}` !== wantType + ) { + return false; + } + + if (gotParams.length < wantParams.length) { + return false; + } + + const params = new Set(gotParams); + for (const wantParam of wantParams) { + if (!params.has(wantParam)) { return false; } + } - return `${parts[0]}/*` === pattern || `*/${parts[1]}` === pattern; - }); - - return idx >= 0; + return true; } const codeRangeRE = new RegExp("^[0-9]xx$", "i"); diff --git a/src/lib/security.ts b/src/lib/security.ts index ae2bdc6..c63efac 100644 --- a/src/lib/security.ts +++ b/src/lib/security.ts @@ -68,7 +68,7 @@ type SecurityInputOAuth2 = { type SecurityInputOAuth2ClientCredentials = { type: "oauth2:client_credentials"; value: string | null | undefined; - fieldName: "clientID" | "clientSecret"; + fieldName: string; }; export type SecurityInput = diff --git a/src/models/components/linkschema.ts b/src/models/components/linkschema.ts index 17869eb..580f6fd 100644 --- a/src/models/components/linkschema.ts +++ b/src/models/components/linkschema.ts @@ -289,7 +289,7 @@ export type LinkSchema = { /** * The date and time when the short link will expire in ISO-8601 format. */ - expiresAt: Date | null; + expiresAt: string | null; /** * The URL to redirect to when the short link has expired. */ @@ -1981,12 +1981,7 @@ export namespace LinkSchema$ { externalId: z.nullable(z.string()), url: z.string(), archived: z.boolean().default(false), - expiresAt: z.nullable( - z - .string() - .datetime({ offset: true }) - .transform((v) => new Date(v)) - ), + expiresAt: z.nullable(z.string()), expiredUrl: z.nullable(z.string()), password: z.nullable(z.string()), proxy: z.boolean().default(false), @@ -2102,7 +2097,7 @@ export namespace LinkSchema$ { externalId: z.nullable(z.string()), url: z.string(), archived: z.boolean().default(false), - expiresAt: z.nullable(z.date().transform((v) => v.toISOString())), + expiresAt: z.nullable(z.string()), expiredUrl: z.nullable(z.string()), password: z.nullable(z.string()), proxy: z.boolean().default(false), diff --git a/src/models/errors/sdkerror.ts b/src/models/errors/sdkerror.ts index 1f66915..5a94e84 100644 --- a/src/models/errors/sdkerror.ts +++ b/src/models/errors/sdkerror.ts @@ -4,6 +4,7 @@ export class SDKError extends Error { public readonly statusCode: number; + public readonly contentType: string; constructor( message: string, @@ -11,11 +12,13 @@ export class SDKError extends Error { public readonly body: string = "" ) { const statusCode = rawResponse.status; + const contentType = rawResponse.headers.get("content-type") || ""; const bodyString = body.length > 0 ? `\n${body}` : ""; - super(`${message}: Status ${statusCode}${bodyString}`); + super(`${message}: Status ${statusCode} Content-Type ${contentType} Body ${bodyString}`); this.statusCode = statusCode; + this.contentType = contentType; this.name = "SDKError"; } diff --git a/src/models/operations/getlinkinfo.ts b/src/models/operations/getlinkinfo.ts index f924394..6c39813 100644 --- a/src/models/operations/getlinkinfo.ts +++ b/src/models/operations/getlinkinfo.ts @@ -5,46 +5,66 @@ import * as z from "zod"; export type GetLinkInfoRequest = { - domain: string; + domain?: string | undefined; /** * The key of the link to retrieve. E.g. for `d.to/github`, the key is `github`. */ - key: string; + key?: string | undefined; + /** + * The unique ID of the short link. + */ + linkId?: string | undefined; + /** + * This is the ID of the link in the your database. Must be prefixed with `ext_`. when provided. + */ + externalId?: string | undefined; }; /** @internal */ export namespace GetLinkInfoRequest$ { export type Inbound = { - domain: string; - key: string; + domain?: string | undefined; + key?: string | undefined; + linkId?: string | undefined; + externalId?: string | undefined; }; export const inboundSchema: z.ZodType = z .object({ - domain: z.string(), - key: z.string(), + domain: z.string().optional(), + key: z.string().optional(), + linkId: z.string().optional(), + externalId: z.string().optional(), }) .transform((v) => { return { - domain: v.domain, - key: v.key, + ...(v.domain === undefined ? null : { domain: v.domain }), + ...(v.key === undefined ? null : { key: v.key }), + ...(v.linkId === undefined ? null : { linkId: v.linkId }), + ...(v.externalId === undefined ? null : { externalId: v.externalId }), }; }); export type Outbound = { - domain: string; - key: string; + domain?: string | undefined; + key?: string | undefined; + linkId?: string | undefined; + externalId?: string | undefined; }; export const outboundSchema: z.ZodType = z .object({ - domain: z.string(), - key: z.string(), + domain: z.string().optional(), + key: z.string().optional(), + linkId: z.string().optional(), + externalId: z.string().optional(), }) .transform((v) => { return { - domain: v.domain, - key: v.key, + ...(v.domain === undefined ? null : { domain: v.domain }), + ...(v.key === undefined ? null : { key: v.key }), + ...(v.linkId === undefined ? null : { linkId: v.linkId }), + ...(v.externalId === undefined ? null : { externalId: v.externalId }), }; }); } diff --git a/src/sdk/analytics.ts b/src/sdk/analytics.ts index 2290709..9243413 100644 --- a/src/sdk/analytics.ts +++ b/src/sdk/analytics.ts @@ -287,7 +287,11 @@ export class Analytics extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -539,7 +543,11 @@ export class Analytics extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -793,7 +801,11 @@ export class Analytics extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -1047,7 +1059,11 @@ export class Analytics extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -1301,7 +1317,11 @@ export class Analytics extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -1555,7 +1575,11 @@ export class Analytics extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -1809,7 +1833,11 @@ export class Analytics extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -2063,7 +2091,11 @@ export class Analytics extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -2315,7 +2347,11 @@ export class Analytics extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -2567,7 +2603,11 @@ export class Analytics extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } } diff --git a/src/sdk/domains.ts b/src/sdk/domains.ts index 1d30340..a49ab0b 100644 --- a/src/sdk/domains.ts +++ b/src/sdk/domains.ts @@ -250,7 +250,11 @@ export class Domains extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -474,7 +478,11 @@ export class Domains extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -705,7 +713,11 @@ export class Domains extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -939,7 +951,11 @@ export class Domains extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -1167,7 +1183,11 @@ export class Domains extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -1401,7 +1421,11 @@ export class Domains extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } } diff --git a/src/sdk/links.ts b/src/sdk/links.ts index 16366ce..183df1b 100644 --- a/src/sdk/links.ts +++ b/src/sdk/links.ts @@ -277,7 +277,11 @@ export class Links extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -501,7 +505,11 @@ export class Links extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -741,7 +749,11 @@ export class Links extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -749,7 +761,7 @@ export class Links extends ClientSDK { * Retrieve a link * * @remarks - * Retrieve the info for a link from their domain and key. + * Retrieve the info for a link. */ async get( input: operations.GetLinkInfoRequest, @@ -770,7 +782,12 @@ export class Links extends ClientSDK { const query$ = [ enc$.encodeForm("domain", payload$.domain, { explode: true, charEncoding: "percent" }), + enc$.encodeForm("externalId", payload$.externalId, { + explode: true, + charEncoding: "percent", + }), enc$.encodeForm("key", payload$.key, { explode: true, charEncoding: "percent" }), + enc$.encodeForm("linkId", payload$.linkId, { explode: true, charEncoding: "percent" }), enc$.encodeForm("projectSlug", this.options$.projectSlug, { explode: true, charEncoding: "percent", @@ -965,7 +982,11 @@ export class Links extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -1199,7 +1220,11 @@ export class Links extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -1430,7 +1455,11 @@ export class Links extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -1654,7 +1683,11 @@ export class Links extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } } diff --git a/src/sdk/metatags.ts b/src/sdk/metatags.ts index 379ec43..0844ec1 100644 --- a/src/sdk/metatags.ts +++ b/src/sdk/metatags.ts @@ -110,7 +110,11 @@ export class Metatags extends ClientSDK { return result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } } diff --git a/src/sdk/qrcodes.ts b/src/sdk/qrcodes.ts index da6cecc..278c4d0 100644 --- a/src/sdk/qrcodes.ts +++ b/src/sdk/qrcodes.ts @@ -12,11 +12,6 @@ import * as errors from "../models/errors"; import * as operations from "../models/operations"; import * as z from "zod"; -export enum GetAcceptEnum { - applicationJson = "application/json", - imagePng = "image/png", -} - export class QRCodes extends ClientSDK { private readonly options$: SDKOptions & { hooks?: SDKHooks }; @@ -50,15 +45,10 @@ export class QRCodes extends ClientSDK { * @remarks * Retrieve a QR code for a link. */ - async get( - input: operations.GetQRCodeRequest, - options?: RequestOptions & { acceptHeaderOverride?: GetAcceptEnum } - ): Promise { + async get(input: operations.GetQRCodeRequest, options?: RequestOptions): Promise { const headers$ = new Headers(); headers$.set("user-agent", SDK_METADATA.userAgent); - - const accept = options?.acceptHeaderOverride || "application/json;q=1, image/png;q=0"; - headers$.set("Accept", accept); + headers$.set("Accept", "image/png"); const payload$ = schemas$.parse( input, @@ -271,7 +261,11 @@ export class QRCodes extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } } diff --git a/src/sdk/tags.ts b/src/sdk/tags.ts index 0b31aa4..894f665 100644 --- a/src/sdk/tags.ts +++ b/src/sdk/tags.ts @@ -250,7 +250,11 @@ export class Tags extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -474,7 +478,11 @@ export class Tags extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } } diff --git a/src/sdk/workspaces.ts b/src/sdk/workspaces.ts index d30595a..21a672c 100644 --- a/src/sdk/workspaces.ts +++ b/src/sdk/workspaces.ts @@ -236,7 +236,11 @@ export class Workspaces extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -450,7 +454,11 @@ export class Workspaces extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } @@ -667,7 +675,11 @@ export class Workspaces extends ClientSDK { throw result; } else { const responseBody = await response.text(); - throw new errors.SDKError("Unexpected API response", response, responseBody); + throw new errors.SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ); } } }