dub 0.20.3 → 0.22.0

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.
@@ -1,12 +1,12 @@
1
1
  lockVersion: 2.0.0
2
2
  id: f28179cc-ef59-426d-9e85-60cec22fc642
3
3
  management:
4
- docChecksum: 3ef41873dee5fcca0b0407f423aa20bf
4
+ docChecksum: f694a42b01f2e867afec56e4fb1fd88d
5
5
  docVersion: 0.0.1
6
6
  speakeasyVersion: 1.246.1
7
7
  generationVersion: 2.302.1
8
- releaseVersion: 0.20.3
9
- configChecksum: d59a77a56a626d3c17af15170f4a04da
8
+ releaseVersion: 0.22.0
9
+ configChecksum: 2bcec32c8da56b5b716a7aa5ae49cfdb
10
10
  repoURL: https://github.com/dubinc/dub-node.git
11
11
  installationURL: https://github.com/dubinc/dub-node
12
12
  published: true
@@ -12,10 +12,11 @@ generation:
12
12
  auth:
13
13
  oAuth2ClientCredentialsEnabled: false
14
14
  typescript:
15
- version: 0.20.3
15
+ version: 0.22.0
16
16
  additionalDependencies:
17
17
  dependencies: {}
18
18
  devDependencies:
19
+ '@types/node': ^20.12.7
19
20
  vitest: 1.4.0
20
21
  peerDependencies: {}
21
22
  author: Dub
@@ -0,0 +1,3 @@
1
+ import { BeforeRequestHook } from "./types";
2
+ export declare const injectAPIKey: BeforeRequestHook;
3
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/hooks/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,YAAY,EAAE,iBAoB1B,CAAC"}
package/hooks/auth.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.injectAPIKey = void 0;
4
+ exports.injectAPIKey = {
5
+ beforeRequest: async (_, request) => {
6
+ var _a;
7
+ const authz = request.headers.get("Authorization");
8
+ if (authz) {
9
+ return request;
10
+ }
11
+ let token = "";
12
+ if (typeof process !== "undefined") {
13
+ token = (_a = process.env["DUB_API_KEY"]) !== null && _a !== void 0 ? _a : "";
14
+ }
15
+ if (!token) {
16
+ throw new Error("The DUB_API_KEY environment variable is missing or empty; either provide it, or instantiate the Dub client with an token option, like new Dub({ token: 'My Token' }).");
17
+ }
18
+ request.headers.set("Authorization", `Bearer ${token}`);
19
+ return request;
20
+ },
21
+ };
22
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/hooks/auth.ts"],"names":[],"mappings":";;;AAEa,QAAA,YAAY,GAAsB;IAC3C,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE;;QAChC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACnD,IAAI,KAAK,EAAE,CAAC;YACR,OAAO,OAAO,CAAC;QACnB,CAAC;QAED,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACjC,KAAK,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,mCAAI,EAAE,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,uKAAuK,CAAC,CAAC;QAC7L,CAAC;QAED,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;QAExD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { BeforeRequestHook } from "./types";
2
+ export declare const overrideBaseURL: BeforeRequestHook;
3
+ //# sourceMappingURL=base-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-url.d.ts","sourceRoot":"","sources":["../src/hooks/base-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,eAAe,EAAE,iBAqB7B,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.overrideBaseURL = void 0;
4
+ exports.overrideBaseURL = {
5
+ beforeRequest: async (_, request) => {
6
+ var _a;
7
+ let baseURL = "";
8
+ if (typeof process !== "undefined") {
9
+ baseURL = (_a = process.env["DUB_BASE_URL"]) !== null && _a !== void 0 ? _a : "";
10
+ }
11
+ if (!baseURL) {
12
+ return request;
13
+ }
14
+ const clone = new URL(request.url);
15
+ const base = new URL(baseURL);
16
+ clone.protocol = base.protocol;
17
+ clone.host = base.host;
18
+ clone.port = base.port;
19
+ clone.username = base.username;
20
+ clone.password = base.password;
21
+ return new Request(clone.toString(), request);
22
+ },
23
+ };
24
+ //# sourceMappingURL=base-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-url.js","sourceRoot":"","sources":["../src/hooks/base-url.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAsB;IAC9C,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE;;QAChC,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACjC,OAAO,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,mCAAI,EAAE,CAAC;QAChD,CAAC;QACD,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,OAAO,CAAC;QACnB,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAE9B,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE/B,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;CACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../src/hooks/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAShC,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAIrC"}
1
+ {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../src/hooks/registration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAQhC,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAOrC"}
@@ -1,16 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initHooks = void 0;
4
+ const auth_1 = require("./auth");
5
+ const base_url_1 = require("./base-url");
4
6
  /*
5
7
  * This file is only ever generated once on the first generation and then is free to be modified.
6
8
  * Any hooks you wish to add should be registered in the initHooks function. Feel free to define them
7
9
  * in this file or in separate files in the hooks folder.
8
10
  */
9
- // @ts-expect-error remove this line when you add your first hook and hooks is used
10
11
  function initHooks(hooks) {
11
12
  // Add hooks by calling hooks.register{ClientInit/BeforeRequest/AfterSuccess/AfterError}Hook
12
13
  // with an instance of a hook that implements that specific Hook interface
13
14
  // Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
15
+ hooks.registerBeforeRequestHook(auth_1.injectAPIKey);
16
+ hooks.registerBeforeRequestHook(base_url_1.overrideBaseURL);
14
17
  }
15
18
  exports.initHooks = initHooks;
16
19
  //# sourceMappingURL=registration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registration.js","sourceRoot":"","sources":["../src/hooks/registration.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AAEH,mFAAmF;AACnF,SAAgB,SAAS,CAAC,KAAY;IAClC,4FAA4F;IAC5F,0EAA0E;IAC1E,4FAA4F;AAChG,CAAC;AAJD,8BAIC"}
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../src/hooks/registration.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AACtC,yCAA6C;AAG7C;;;;GAIG;AAEH,SAAgB,SAAS,CAAC,KAAY;IAClC,4FAA4F;IAC5F,0EAA0E;IAC1E,4FAA4F;IAE5F,KAAK,CAAC,yBAAyB,CAAC,mBAAY,CAAC,CAAC;IAC9C,KAAK,CAAC,yBAAyB,CAAC,0BAAe,CAAC,CAAC;AACrD,CAAC;AAPD,8BAOC"}
package/lib/config.d.ts CHANGED
@@ -32,8 +32,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
32
32
  export declare const SDK_METADATA: Readonly<{
33
33
  language: "typescript";
34
34
  openapiDocVersion: "0.0.1";
35
- sdkVersion: "0.20.3";
35
+ sdkVersion: "0.22.0";
36
36
  genVersion: "2.302.1";
37
- userAgent: "speakeasy-sdk/typescript 0.20.3 2.302.1 0.0.1 dub";
37
+ userAgent: "speakeasy-sdk/typescript 0.22.0 2.302.1 0.0.1 dub";
38
38
  }>;
39
39
  //# sourceMappingURL=config.d.ts.map
package/lib/config.js CHANGED
@@ -32,8 +32,8 @@ exports.serverURLFromOptions = serverURLFromOptions;
32
32
  exports.SDK_METADATA = Object.freeze({
33
33
  language: "typescript",
34
34
  openapiDocVersion: "0.0.1",
35
- sdkVersion: "0.20.3",
35
+ sdkVersion: "0.22.0",
36
36
  genVersion: "2.302.1",
37
- userAgent: "speakeasy-sdk/typescript 0.20.3 2.302.1 0.0.1 dub",
37
+ userAgent: "speakeasy-sdk/typescript 0.22.0 2.302.1 0.0.1 dub",
38
38
  });
39
39
  //# sourceMappingURL=config.js.map
@@ -1,8 +1,5 @@
1
1
  import * as z from "zod";
2
2
  export type GetLinkInfoRequest = {
3
- /**
4
- * The domain of the link to retrieve. E.g. for `d.to/github`, the domain is `d.to`.
5
- */
6
3
  domain: string;
7
4
  /**
8
5
  * The key of the link to retrieve. E.g. for `d.to/github`, the key is `github`.
@@ -1 +1 @@
1
- {"version":3,"file":"getlinkinfo.d.ts","sourceRoot":"","sources":["../../src/models/operations/getlinkinfo.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,MAAM,MAAM,kBAAkB,GAAG;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,gBAAgB;AAChB,yBAAiB,mBAAmB,CAAC;IACjC,KAAY,OAAO,GAAG;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;KACf,CAAC;IAEK,MAAM,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,UAAU,EAAE,OAAO,CAUzE,CAAC;IAEP,KAAY,QAAQ,GAAG;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;KACf,CAAC;IAEK,MAAM,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE,kBAAkB,CAU3E,CAAC;CACV"}
1
+ {"version":3,"file":"getlinkinfo.d.ts","sourceRoot":"","sources":["../../src/models/operations/getlinkinfo.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,MAAM,MAAM,kBAAkB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACf,CA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C,GAAG;SACb,CAAC;IACN,CAAC,CAAC,CAAC;AACX,CAAC,EAlCgB,mBAAmB,mCAAnB,mBAAmB,QAkCnC"}
1
+ {"version":3,"file":"getlinkinfo.js","sourceRoot":"","sources":["../../src/models/operations/getlinkinfo.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAUzB,gBAAgB;AAChB,IAAiB,mBAAmB,CAkCnC;AAlCD,WAAiB,mBAAmB;IAMnB,iCAAa,GAAyD,CAAC;SAC/E,MAAM,CAAC;QACJ,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;QAClB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;KAClB,CAAC;SACD,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;QACb,OAAO;YACH,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,GAAG,EAAE,CAAC,CAAC,GAAG;SACb,CAAC;IACN,CAAC,CAAC,CAAC;IAOM,kCAAc,GAA0D,CAAC;SACjF,MAAM,CAAC;QACJ,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;QAClB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;KAClB,CAAC;SACD,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;QACb,OAAO;YACH,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,GAAG,EAAE,CAAC,CAAC,GAAG;SACb,CAAC;IACN,CAAC,CAAC,CAAC;AACX,CAAC,EAlCgB,mBAAmB,mCAAnB,mBAAmB,QAkCnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dub",
3
- "version": "0.20.3",
3
+ "version": "0.22.0",
4
4
  "author": "Dub",
5
5
  "main": "./index.js",
6
6
  "sideEffects": false,
@@ -19,6 +19,7 @@
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/jsonpath": "^0.2.4",
22
+ "@types/node": "^20.12.7",
22
23
  "@typescript-eslint/eslint-plugin": "^6.13.2",
23
24
  "@typescript-eslint/parser": "^6.13.2",
24
25
  "eslint": "^8.55.0",
@@ -0,0 +1,23 @@
1
+ import { BeforeRequestHook } from "./types";
2
+
3
+ export const injectAPIKey: BeforeRequestHook = {
4
+ beforeRequest: async (_, request) => {
5
+ const authz = request.headers.get("Authorization");
6
+ if (authz) {
7
+ return request;
8
+ }
9
+
10
+ let token = "";
11
+ if (typeof process !== "undefined") {
12
+ token = process.env["DUB_API_KEY"] ?? "";
13
+ }
14
+
15
+ if (!token) {
16
+ throw new Error("The DUB_API_KEY environment variable is missing or empty; either provide it, or instantiate the Dub client with an token option, like new Dub({ token: 'My Token' }).");
17
+ }
18
+
19
+ request.headers.set("Authorization", `Bearer ${token}`);
20
+
21
+ return request;
22
+ },
23
+ };
@@ -0,0 +1,24 @@
1
+ import { BeforeRequestHook } from "./types";
2
+
3
+ export const overrideBaseURL: BeforeRequestHook = {
4
+ beforeRequest: async (_, request) => {
5
+ let baseURL = "";
6
+ if (typeof process !== "undefined") {
7
+ baseURL = process.env["DUB_BASE_URL"] ?? "";
8
+ }
9
+ if (!baseURL) {
10
+ return request;
11
+ }
12
+
13
+ const clone = new URL(request.url);
14
+ const base = new URL(baseURL);
15
+
16
+ clone.protocol = base.protocol;
17
+ clone.host = base.host;
18
+ clone.port = base.port;
19
+ clone.username = base.username;
20
+ clone.password = base.password;
21
+
22
+ return new Request(clone.toString(), request);
23
+ },
24
+ };
@@ -1,3 +1,5 @@
1
+ import { injectAPIKey } from "./auth";
2
+ import { overrideBaseURL } from "./base-url";
1
3
  import { Hooks } from "./types";
2
4
 
3
5
  /*
@@ -6,9 +8,11 @@ import { Hooks } from "./types";
6
8
  * in this file or in separate files in the hooks folder.
7
9
  */
8
10
 
9
- // @ts-expect-error remove this line when you add your first hook and hooks is used
10
11
  export function initHooks(hooks: Hooks) {
11
12
  // Add hooks by calling hooks.register{ClientInit/BeforeRequest/AfterSuccess/AfterError}Hook
12
13
  // with an instance of a hook that implements that specific Hook interface
13
14
  // Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
15
+
16
+ hooks.registerBeforeRequestHook(injectAPIKey);
17
+ hooks.registerBeforeRequestHook(overrideBaseURL);
14
18
  }
package/src/lib/config.ts CHANGED
@@ -64,7 +64,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
64
64
  export const SDK_METADATA = Object.freeze({
65
65
  language: "typescript",
66
66
  openapiDocVersion: "0.0.1",
67
- sdkVersion: "0.20.3",
67
+ sdkVersion: "0.22.0",
68
68
  genVersion: "2.302.1",
69
- userAgent: "speakeasy-sdk/typescript 0.20.3 2.302.1 0.0.1 dub",
69
+ userAgent: "speakeasy-sdk/typescript 0.22.0 2.302.1 0.0.1 dub",
70
70
  });
@@ -5,9 +5,6 @@
5
5
  import * as z from "zod";
6
6
 
7
7
  export type GetLinkInfoRequest = {
8
- /**
9
- * The domain of the link to retrieve. E.g. for `d.to/github`, the domain is `d.to`.
10
- */
11
8
  domain: string;
12
9
  /**
13
10
  * The key of the link to retrieve. E.g. for `d.to/github`, the key is `github`.