dub 0.1.0 → 0.3.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.
- package/CHANGELOG.md +33 -0
- package/README.md +43 -23
- package/core.d.ts +3 -1
- package/core.d.ts.map +1 -1
- package/core.js +21 -11
- package/core.js.map +1 -1
- package/core.mjs +21 -11
- package/core.mjs.map +1 -1
- package/index.d.mts +9 -5
- package/index.d.ts +9 -5
- package/index.d.ts.map +1 -1
- package/index.js +11 -8
- package/index.js.map +1 -1
- package/index.mjs +11 -8
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/links/bulk.d.ts +1 -1
- package/resources/links/bulk.d.ts.map +1 -1
- package/resources/links/bulk.js +1 -1
- package/resources/links/bulk.js.map +1 -1
- package/resources/links/bulk.mjs +1 -1
- package/resources/links/bulk.mjs.map +1 -1
- package/resources/links/info.d.ts +2 -2
- package/resources/links/info.d.ts.map +1 -1
- package/resources/links/info.js +3 -2
- package/resources/links/info.js.map +1 -1
- package/resources/links/info.mjs +3 -2
- package/resources/links/info.mjs.map +1 -1
- package/resources/links/links.d.ts +5 -5
- package/resources/links/links.d.ts.map +1 -1
- package/resources/links/links.js +6 -5
- package/resources/links/links.js.map +1 -1
- package/resources/links/links.mjs +6 -5
- package/resources/links/links.mjs.map +1 -1
- package/resources/projects/index.d.ts +2 -2
- package/resources/projects/index.d.ts.map +1 -1
- package/resources/projects/index.js.map +1 -1
- package/resources/projects/index.mjs.map +1 -1
- package/resources/projects/projects.d.ts +10 -1
- package/resources/projects/projects.d.ts.map +1 -1
- package/resources/projects/projects.js +2 -1
- package/resources/projects/projects.js.map +1 -1
- package/resources/projects/projects.mjs +2 -1
- package/resources/projects/projects.mjs.map +1 -1
- package/resources/projects/tags.d.ts +16 -3
- package/resources/projects/tags.d.ts.map +1 -1
- package/resources/projects/tags.js +4 -2
- package/resources/projects/tags.js.map +1 -1
- package/resources/projects/tags.mjs +4 -2
- package/resources/projects/tags.mjs.map +1 -1
- package/src/core.ts +25 -15
- package/src/index.ts +19 -11
- package/src/resources/index.ts +7 -1
- package/src/resources/links/bulk.ts +2 -2
- package/src/resources/links/info.ts +4 -3
- package/src/resources/links/links.ts +10 -9
- package/src/resources/projects/index.ts +2 -2
- package/src/resources/projects/projects.ts +12 -1
- package/src/resources/projects/tags.ts +20 -3
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/resources/links/links.js
CHANGED
|
@@ -38,28 +38,29 @@ class Links extends resource_1.APIResource {
|
|
|
38
38
|
* Create a new link for the authenticated project.
|
|
39
39
|
*/
|
|
40
40
|
create(params, options) {
|
|
41
|
-
const { projectSlug, ...body } = params;
|
|
41
|
+
const { projectSlug = this._client.projectSlug, ...body } = params;
|
|
42
42
|
return this._client.post('/links', { query: { projectSlug }, body, ...options });
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Edit a link for the authenticated project.
|
|
46
46
|
*/
|
|
47
47
|
update(linkId, params, options) {
|
|
48
|
-
const { projectSlug, ...body } = params;
|
|
48
|
+
const { projectSlug = this._client.projectSlug, ...body } = params;
|
|
49
49
|
return this._client.put(`/links/${linkId}`, { query: { projectSlug }, body, ...options });
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Retrieve a list of links for the authenticated project. The list will be
|
|
53
53
|
* paginated and the provided query parameters allow filtering the returned links.
|
|
54
54
|
*/
|
|
55
|
-
list(
|
|
56
|
-
|
|
55
|
+
list(params, options) {
|
|
56
|
+
const { projectSlug = this._client.projectSlug, ...query } = params;
|
|
57
|
+
return this._client.get('/links', { query: { projectSlug, ...query }, ...options });
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
60
|
* Delete a link for the authenticated project.
|
|
60
61
|
*/
|
|
61
62
|
delete(linkId, params, options) {
|
|
62
|
-
const { projectSlug } = params;
|
|
63
|
+
const { projectSlug = this._client.projectSlug } = params;
|
|
63
64
|
return this._client.delete(`/links/${linkId}`, { query: { projectSlug }, ...options });
|
|
64
65
|
}
|
|
65
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../src/resources/links/links.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;AAGrD,2CAA2C;AAG3C,kEAAoD;AACpD,kEAAoD;AAEpD,MAAa,KAAM,SAAQ,sBAAW;IAAtC;;QACE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpD,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../src/resources/links/links.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;AAGrD,2CAA2C;AAG3C,kEAAoD;AACpD,kEAAoD;AAEpD,MAAa,KAAM,SAAQ,sBAAW;IAAtC;;QACE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpD,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IA0CtD,CAAC;IAxCC;;OAEG;IACH,MAAM,CAAC,MAAwB,EAAE,OAA6B;QAC5D,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QACnE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAA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13
|
*/
|
|
14
14
|
create(params, options) {
|
|
15
|
-
const { projectSlug, ...body } = params;
|
|
15
|
+
const { projectSlug = this._client.projectSlug, ...body } = params;
|
|
16
16
|
return this._client.post('/links', { query: { projectSlug }, body, ...options });
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Edit a link for the authenticated project.
|
|
20
20
|
*/
|
|
21
21
|
update(linkId, params, options) {
|
|
22
|
-
const { projectSlug, ...body } = params;
|
|
22
|
+
const { projectSlug = this._client.projectSlug, ...body } = params;
|
|
23
23
|
return this._client.put(`/links/${linkId}`, { query: { projectSlug }, body, ...options });
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Retrieve a list of links for the authenticated project. The list will be
|
|
27
27
|
* paginated and the provided query parameters allow filtering the returned links.
|
|
28
28
|
*/
|
|
29
|
-
list(
|
|
30
|
-
|
|
29
|
+
list(params, options) {
|
|
30
|
+
const { projectSlug = this._client.projectSlug, ...query } = params;
|
|
31
|
+
return this._client.get('/links', { query: { projectSlug, ...query }, ...options });
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Delete a link for the authenticated project.
|
|
34
35
|
*/
|
|
35
36
|
delete(linkId, params, options) {
|
|
36
|
-
const { projectSlug } = params;
|
|
37
|
+
const { projectSlug = this._client.projectSlug } = params;
|
|
37
38
|
return this._client.delete(`/links/${linkId}`, { query: { projectSlug }, ...options });
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.mjs","sourceRoot":"","sources":["../../src/resources/links/links.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAG9C,EAAE,WAAW,EAAE,MAAM,cAAc;OAGnC,KAAK,OAAO,MAAM,0BAA0B;OAC5C,KAAK,OAAO,MAAM,0BAA0B;AAEnD,MAAM,OAAO,KAAM,SAAQ,WAAW;IAAtC;;QACE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,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AG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QACpE,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtF,CAAC;IAED;;OAEG;IACH,MAAM,CACJ,MAAc,EACd,MAAwB,EACxB,OAA6B;QAE7B,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzF,CAAC;CACF;AAqQD,WAAiB,KAAK;IAMN,UAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAEpB,UAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAGpC,CAAC,EAXgB,KAAK,KAAL,KAAK,QAWrB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { Project, ProjectDetails, ProjectListResponse, Projects } from "./projects.js";
|
|
2
|
-
export { Tag, TagListResponse, TagCreateParams, Tags } from "./tags.js";
|
|
1
|
+
export { Project, ProjectDetails, ProjectListResponse, ProjectRetrieveParams, Projects } from "./projects.js";
|
|
2
|
+
export { Tag, TagListResponse, TagCreateParams, TagListParams, Tags } from "./tags.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/projects/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/projects/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3G,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/projects/index.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAErD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/projects/index.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAErD,0CAA2G;AAA7B,oGAAA,QAAQ,OAAA;AACtF,kCAAoF;AAArB,4FAAA,IAAI,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/resources/projects/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAE9C,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/resources/projects/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAE9C,EAAuE,QAAQ,EAAE;OACjF,EAAwD,IAAI,EAAE"}
|
|
@@ -7,7 +7,7 @@ export declare class Projects extends APIResource {
|
|
|
7
7
|
/**
|
|
8
8
|
* Retrieve a project for the authenticated user.
|
|
9
9
|
*/
|
|
10
|
-
retrieve(
|
|
10
|
+
retrieve(params: ProjectRetrieveParams, options?: Core.RequestOptions): Core.APIPromise<ProjectDetails>;
|
|
11
11
|
/**
|
|
12
12
|
* Retrieve a list of projects for the authenticated user.
|
|
13
13
|
*/
|
|
@@ -86,13 +86,22 @@ export declare namespace ProjectDetails {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
export type ProjectListResponse = Array<Project>;
|
|
89
|
+
export interface ProjectRetrieveParams {
|
|
90
|
+
/**
|
|
91
|
+
* The slug for the project to retrieve. E.g. for app.dub.co/acme, the projectSlug
|
|
92
|
+
* is 'acme'.
|
|
93
|
+
*/
|
|
94
|
+
projectSlug?: string;
|
|
95
|
+
}
|
|
89
96
|
export declare namespace Projects {
|
|
90
97
|
export import Project = ProjectsAPI.Project;
|
|
91
98
|
export import ProjectDetails = ProjectsAPI.ProjectDetails;
|
|
92
99
|
export import ProjectListResponse = ProjectsAPI.ProjectListResponse;
|
|
100
|
+
export import ProjectRetrieveParams = ProjectsAPI.ProjectRetrieveParams;
|
|
93
101
|
export import Tags = TagsAPI.Tags;
|
|
94
102
|
export import Tag = TagsAPI.Tag;
|
|
95
103
|
export import TagListResponse = TagsAPI.TagListResponse;
|
|
96
104
|
export import TagCreateParams = TagsAPI.TagCreateParams;
|
|
105
|
+
export import TagListParams = TagsAPI.TagListParams;
|
|
97
106
|
}
|
|
98
107
|
//# sourceMappingURL=projects.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../src/resources/projects/projects.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,WAAW,MAAM,iCAAiC,CAAC;AAC/D,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AAEvD,qBAAa,QAAS,SAAQ,WAAW;IACvC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAkC;IAEpD;;OAEG;IACH,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../src/resources/projects/projects.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,WAAW,MAAM,iCAAiC,CAAC;AAC/D,OAAO,KAAK,OAAO,M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H,UAAiB,IAAI;QACnB;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;CACF;AAED,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;AAEjD,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,yBAAiB,QAAQ,CAAC;IACxB,MAAM,QAAQ,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;IAC5C,MAAM,QAAQ,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;IAC1D,MAAM,QAAQ,mBAAmB,GAAG,WAAW,CAAC,mBAAmB,CAAC;IACpE,MAAM,QAAQ,qBAAqB,GAAG,WAAW,CAAC,qBAAqB,CAAC;IACxE,MAAM,QAAQ,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAClC,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAChC,MAAM,QAAQ,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IACxD,MAAM,QAAQ,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IACxD,MAAM,QAAQ,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;CACrD"}
|
|
@@ -35,7 +35,8 @@ class Projects extends resource_1.APIResource {
|
|
|
35
35
|
/**
|
|
36
36
|
* Retrieve a project for the authenticated user.
|
|
37
37
|
*/
|
|
38
|
-
retrieve(
|
|
38
|
+
retrieve(params, options) {
|
|
39
|
+
const { projectSlug = this._client.projectSlug } = params;
|
|
39
40
|
return this._client.get(`/projects/${projectSlug}`, options);
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../src/resources/projects/projects.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;AAGrD,2CAA2C;AAE3C,qEAAuD;AAEvD,MAAa,QAAS,SAAQ,sBAAW;IAAzC;;QACE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../src/resources/projects/projects.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;AAGrD,2CAA2C;AAE3C,qEAAuD;AAEvD,MAAa,QAAS,SAAQ,sBAAW;IAAzC;;QACE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAgBtD,CAAC;IAdC;;OAEG;IACH,QAAQ,CAAC,MAA6B,EAAE,OAA6B;QACnE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAA6B;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;CACF;AAjBD,4BAiBC;AAkGD,WAAiB,QAAQ;IAKT,aAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAKpC,CAAC,EAVgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUxB"}
|
|
@@ -9,7 +9,8 @@ export class Projects extends APIResource {
|
|
|
9
9
|
/**
|
|
10
10
|
* Retrieve a project for the authenticated user.
|
|
11
11
|
*/
|
|
12
|
-
retrieve(
|
|
12
|
+
retrieve(params, options) {
|
|
13
|
+
const { projectSlug = this._client.projectSlug } = params;
|
|
13
14
|
return this._client.get(`/projects/${projectSlug}`, options);
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projects.mjs","sourceRoot":"","sources":["../../src/resources/projects/projects.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAG9C,EAAE,WAAW,EAAE,MAAM,cAAc;OAEnC,KAAK,OAAO,MAAM,6BAA6B;AAEtD,MAAM,OAAO,QAAS,SAAQ,WAAW;IAAzC;;QACE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"projects.mjs","sourceRoot":"","sources":["../../src/resources/projects/projects.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAG9C,EAAE,WAAW,EAAE,MAAM,cAAc;OAEnC,KAAK,OAAO,MAAM,6BAA6B;AAEtD,MAAM,OAAO,QAAS,SAAQ,WAAW;IAAzC;;QACE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAgBtD,CAAC;IAdC;;OAEG;IACH,QAAQ,CAAC,MAA6B,EAAE,OAA6B;QACnE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAA6B;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;CACF;AAkGD,WAAiB,QAAQ;IAKT,aAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAKpC,CAAC,EAVgB,QAAQ,KAAR,QAAQ,QAUxB"}
|
|
@@ -5,11 +5,11 @@ export declare class Tags extends APIResource {
|
|
|
5
5
|
/**
|
|
6
6
|
* Create a new tag for the authenticated project.
|
|
7
7
|
*/
|
|
8
|
-
create(
|
|
8
|
+
create(params: TagCreateParams, options?: Core.RequestOptions): Core.APIPromise<Tag>;
|
|
9
9
|
/**
|
|
10
10
|
* Retrieve a list of tags for the authenticated project.
|
|
11
11
|
*/
|
|
12
|
-
list(
|
|
12
|
+
list(params: TagListParams, options?: Core.RequestOptions): Core.APIPromise<TagListResponse>;
|
|
13
13
|
}
|
|
14
14
|
export interface Tag {
|
|
15
15
|
/**
|
|
@@ -28,13 +28,26 @@ export interface Tag {
|
|
|
28
28
|
export type TagListResponse = Array<Tag>;
|
|
29
29
|
export interface TagCreateParams {
|
|
30
30
|
/**
|
|
31
|
-
* The
|
|
31
|
+
* Path param: The slug for the project to create tags for. E.g. for
|
|
32
|
+
* app.dub.co/acme, the projectSlug is 'acme'.
|
|
33
|
+
*/
|
|
34
|
+
projectSlug?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Body param: The name of the tag to create.
|
|
32
37
|
*/
|
|
33
38
|
tag?: string;
|
|
34
39
|
}
|
|
40
|
+
export interface TagListParams {
|
|
41
|
+
/**
|
|
42
|
+
* The slug for the project to retrieve tags for. E.g. for app.dub.co/acme, the
|
|
43
|
+
* projectSlug is 'acme'.
|
|
44
|
+
*/
|
|
45
|
+
projectSlug?: string;
|
|
46
|
+
}
|
|
35
47
|
export declare namespace Tags {
|
|
36
48
|
export import Tag = TagsAPI.Tag;
|
|
37
49
|
export import TagListResponse = TagsAPI.TagListResponse;
|
|
38
50
|
export import TagCreateParams = TagsAPI.TagCreateParams;
|
|
51
|
+
export import TagListParams = TagsAPI.TagListParams;
|
|
39
52
|
}
|
|
40
53
|
//# sourceMappingURL=tags.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../src/resources/projects/tags.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AAEvD,qBAAa,IAAK,SAAQ,WAAW;IACnC;;OAEG;IACH,MA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|
|
@@ -7,13 +7,15 @@ class Tags extends resource_1.APIResource {
|
|
|
7
7
|
/**
|
|
8
8
|
* Create a new tag for the authenticated project.
|
|
9
9
|
*/
|
|
10
|
-
create(
|
|
10
|
+
create(params, options) {
|
|
11
|
+
const { projectSlug = this._client.projectSlug, ...body } = params;
|
|
11
12
|
return this._client.post(`/projects/${projectSlug}/tags`, { body, ...options });
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* Retrieve a list of tags for the authenticated project.
|
|
15
16
|
*/
|
|
16
|
-
list(
|
|
17
|
+
list(params, options) {
|
|
18
|
+
const { projectSlug = this._client.projectSlug } = params;
|
|
17
19
|
return this._client.get(`/projects/${projectSlug}/tags`, options);
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../src/resources/projects/tags.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAGrD,2CAA2C;AAG3C,MAAa,IAAK,SAAQ,sBAAW;IACnC;;OAEG;IACH,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../src/resources/projects/tags.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAGrD,2CAA2C;AAG3C,MAAa,IAAK,SAAQ,sBAAW;IACnC;;OAEG;IACH,MAAM,CAAC,MAAuB,EAAE,OAA6B;QAC3D,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QACnE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,WAAW,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,MAAqB,EAAE,OAA6B;QACvD,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,WAAW,OAAO,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;CACF;AAhBD,oBAgBC;AA0CD,WAAiB,IAAI;AAKrB,CAAC,EALgB,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAKpB"}
|
|
@@ -4,13 +4,15 @@ export class Tags extends APIResource {
|
|
|
4
4
|
/**
|
|
5
5
|
* Create a new tag for the authenticated project.
|
|
6
6
|
*/
|
|
7
|
-
create(
|
|
7
|
+
create(params, options) {
|
|
8
|
+
const { projectSlug = this._client.projectSlug, ...body } = params;
|
|
8
9
|
return this._client.post(`/projects/${projectSlug}/tags`, { body, ...options });
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Retrieve a list of tags for the authenticated project.
|
|
12
13
|
*/
|
|
13
|
-
list(
|
|
14
|
+
list(params, options) {
|
|
15
|
+
const { projectSlug = this._client.projectSlug } = params;
|
|
14
16
|
return this._client.get(`/projects/${projectSlug}/tags`, options);
|
|
15
17
|
}
|
|
16
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.mjs","sourceRoot":"","sources":["../../src/resources/projects/tags.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAG9C,EAAE,WAAW,EAAE,MAAM,cAAc;AAG1C,MAAM,OAAO,IAAK,SAAQ,WAAW;IACnC;;OAEG;IACH,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"tags.mjs","sourceRoot":"","sources":["../../src/resources/projects/tags.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAG9C,EAAE,WAAW,EAAE,MAAM,cAAc;AAG1C,MAAM,OAAO,IAAK,SAAQ,WAAW;IACnC;;OAEG;IACH,MAAM,CAAC,MAAuB,EAAE,OAA6B;QAC3D,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QACnE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,WAAW,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,MAAqB,EAAE,OAA6B;QACvD,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,WAAW,OAAO,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;CACF;AA0CD,WAAiB,IAAI;AAKrB,CAAC,EALgB,IAAI,KAAJ,IAAI,QAKpB"}
|
package/src/core.ts
CHANGED
|
@@ -408,14 +408,17 @@ export abstract class APIClient {
|
|
|
408
408
|
|
|
409
409
|
if (!response.ok) {
|
|
410
410
|
if (retriesRemaining && this.shouldRetry(response)) {
|
|
411
|
+
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
412
|
+
debug(`response (error; ${retryMessage})`, response.status, url, responseHeaders);
|
|
411
413
|
return this.retryRequest(options, retriesRemaining, responseHeaders);
|
|
412
414
|
}
|
|
413
415
|
|
|
414
416
|
const errText = await response.text().catch((e) => castToError(e).message);
|
|
415
417
|
const errJSON = safeJSON(errText);
|
|
416
418
|
const errMessage = errJSON ? undefined : errText;
|
|
419
|
+
const retryMessage = retriesRemaining ? `(error; no more retries left)` : `(error; not retryable)`;
|
|
417
420
|
|
|
418
|
-
debug(
|
|
421
|
+
debug(`response (error; ${retryMessage})`, response.status, url, responseHeaders, errMessage);
|
|
419
422
|
|
|
420
423
|
const err = this.makeStatusError(response.status, errJSON, errMessage, responseHeaders);
|
|
421
424
|
throw err;
|
|
@@ -443,8 +446,8 @@ export abstract class APIClient {
|
|
|
443
446
|
query = { ...defaultQuery, ...query } as Req;
|
|
444
447
|
}
|
|
445
448
|
|
|
446
|
-
if (query) {
|
|
447
|
-
url.search = this.stringifyQuery(query);
|
|
449
|
+
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
450
|
+
url.search = this.stringifyQuery(query as Record<string, unknown>);
|
|
448
451
|
}
|
|
449
452
|
|
|
450
453
|
return url.toString();
|
|
@@ -520,11 +523,21 @@ export abstract class APIClient {
|
|
|
520
523
|
retriesRemaining: number,
|
|
521
524
|
responseHeaders?: Headers | undefined,
|
|
522
525
|
): Promise<APIResponseProps> {
|
|
523
|
-
// About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
524
526
|
let timeoutMillis: number | undefined;
|
|
527
|
+
|
|
528
|
+
// Note the `retry-after-ms` header may not be standard, but is a good idea and we'd like proactive support for it.
|
|
529
|
+
const retryAfterMillisHeader = responseHeaders?.['retry-after-ms'];
|
|
530
|
+
if (retryAfterMillisHeader) {
|
|
531
|
+
const timeoutMs = parseFloat(retryAfterMillisHeader);
|
|
532
|
+
if (!Number.isNaN(timeoutMs)) {
|
|
533
|
+
timeoutMillis = timeoutMs;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
525
538
|
const retryAfterHeader = responseHeaders?.['retry-after'];
|
|
526
|
-
if (retryAfterHeader) {
|
|
527
|
-
const timeoutSeconds =
|
|
539
|
+
if (retryAfterHeader && !timeoutMillis) {
|
|
540
|
+
const timeoutSeconds = parseFloat(retryAfterHeader);
|
|
528
541
|
if (!Number.isNaN(timeoutSeconds)) {
|
|
529
542
|
timeoutMillis = timeoutSeconds * 1000;
|
|
530
543
|
} else {
|
|
@@ -534,12 +547,7 @@ export abstract class APIClient {
|
|
|
534
547
|
|
|
535
548
|
// If the API asks us to wait a certain amount of time (and it's a reasonable amount),
|
|
536
549
|
// just do what it says, but otherwise calculate a default
|
|
537
|
-
if (
|
|
538
|
-
!timeoutMillis ||
|
|
539
|
-
!Number.isInteger(timeoutMillis) ||
|
|
540
|
-
timeoutMillis <= 0 ||
|
|
541
|
-
timeoutMillis > 60 * 1000
|
|
542
|
-
) {
|
|
550
|
+
if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
|
|
543
551
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
544
552
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
545
553
|
}
|
|
@@ -708,7 +716,7 @@ export type RequestOptions<Req = unknown | Record<string, unknown> | Readable> =
|
|
|
708
716
|
method?: HTTPMethod;
|
|
709
717
|
path?: string;
|
|
710
718
|
query?: Req | undefined;
|
|
711
|
-
body?: Req | undefined;
|
|
719
|
+
body?: Req | null | undefined;
|
|
712
720
|
headers?: Headers | undefined;
|
|
713
721
|
|
|
714
722
|
maxRetries?: number;
|
|
@@ -952,14 +960,16 @@ export const ensurePresent = <T>(value: T | null | undefined): T => {
|
|
|
952
960
|
/**
|
|
953
961
|
* Read an environment variable.
|
|
954
962
|
*
|
|
963
|
+
* Trims beginning and trailing whitespace.
|
|
964
|
+
*
|
|
955
965
|
* Will return undefined if the environment variable doesn't exist or cannot be accessed.
|
|
956
966
|
*/
|
|
957
967
|
export const readEnv = (env: string): string | undefined => {
|
|
958
968
|
if (typeof process !== 'undefined') {
|
|
959
|
-
return process.env?.[env] ?? undefined;
|
|
969
|
+
return process.env?.[env]?.trim() ?? undefined;
|
|
960
970
|
}
|
|
961
971
|
if (typeof Deno !== 'undefined') {
|
|
962
|
-
return Deno.env?.get?.(env);
|
|
972
|
+
return Deno.env?.get?.(env)?.trim();
|
|
963
973
|
}
|
|
964
974
|
return undefined;
|
|
965
975
|
};
|
package/src/index.ts
CHANGED
|
@@ -8,9 +8,11 @@ import * as API from "./resources/index";
|
|
|
8
8
|
|
|
9
9
|
export interface ClientOptions {
|
|
10
10
|
/**
|
|
11
|
-
* Defaults to process.env['
|
|
11
|
+
* Defaults to process.env['DUB_API_KEY'].
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
token?: string | undefined;
|
|
14
|
+
|
|
15
|
+
projectSlug?: string | null | undefined;
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
@@ -71,14 +73,16 @@ export interface ClientOptions {
|
|
|
71
73
|
|
|
72
74
|
/** API Client for interfacing with the Dub API. */
|
|
73
75
|
export class Dub extends Core.APIClient {
|
|
74
|
-
|
|
76
|
+
token: string;
|
|
77
|
+
projectSlug: string | null;
|
|
75
78
|
|
|
76
79
|
private _options: ClientOptions;
|
|
77
80
|
|
|
78
81
|
/**
|
|
79
82
|
* API Client for interfacing with the Dub API.
|
|
80
83
|
*
|
|
81
|
-
* @param {string} [opts.
|
|
84
|
+
* @param {string | undefined} [opts.token=process.env['DUB_API_KEY'] ?? undefined]
|
|
85
|
+
* @param {string | null | undefined} [opts.projectSlug]
|
|
82
86
|
* @param {string} [opts.baseURL=process.env['DUB_BASE_URL'] ?? https://api.dub.co] - Override the default base URL for the API.
|
|
83
87
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
84
88
|
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
@@ -89,19 +93,21 @@ export class Dub extends Core.APIClient {
|
|
|
89
93
|
*/
|
|
90
94
|
constructor({
|
|
91
95
|
baseURL = Core.readEnv('DUB_BASE_URL'),
|
|
92
|
-
|
|
96
|
+
token = Core.readEnv('DUB_API_KEY'),
|
|
97
|
+
projectSlug = null,
|
|
93
98
|
...opts
|
|
94
99
|
}: ClientOptions = {}) {
|
|
95
|
-
if (
|
|
100
|
+
if (token === undefined) {
|
|
96
101
|
throw new Errors.DubError(
|
|
97
|
-
"The
|
|
102
|
+
"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' }).",
|
|
98
103
|
);
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
const options: ClientOptions = {
|
|
102
|
-
|
|
107
|
+
token,
|
|
108
|
+
projectSlug,
|
|
103
109
|
...opts,
|
|
104
|
-
baseURL: baseURL
|
|
110
|
+
baseURL: baseURL || `https://api.dub.co`,
|
|
105
111
|
};
|
|
106
112
|
|
|
107
113
|
super({
|
|
@@ -113,7 +119,8 @@ export class Dub extends Core.APIClient {
|
|
|
113
119
|
});
|
|
114
120
|
this._options = options;
|
|
115
121
|
|
|
116
|
-
this.
|
|
122
|
+
this.token = token;
|
|
123
|
+
this.projectSlug = projectSlug;
|
|
117
124
|
}
|
|
118
125
|
|
|
119
126
|
links: API.Links = new API.Links(this);
|
|
@@ -131,7 +138,7 @@ export class Dub extends Core.APIClient {
|
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
134
|
-
return { Authorization: `Bearer ${this.
|
|
141
|
+
return { Authorization: `Bearer ${this.token}` };
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
static Dub = this;
|
|
@@ -188,6 +195,7 @@ export namespace Dub {
|
|
|
188
195
|
export import Project = API.Project;
|
|
189
196
|
export import ProjectDetails = API.ProjectDetails;
|
|
190
197
|
export import ProjectListResponse = API.ProjectListResponse;
|
|
198
|
+
export import ProjectRetrieveParams = API.ProjectRetrieveParams;
|
|
191
199
|
|
|
192
200
|
export import Link = API.Link;
|
|
193
201
|
}
|
package/src/resources/index.ts
CHANGED
|
@@ -9,4 +9,10 @@ export {
|
|
|
9
9
|
LinkDeleteParams,
|
|
10
10
|
Links,
|
|
11
11
|
} from './links/links';
|
|
12
|
-
export {
|
|
12
|
+
export {
|
|
13
|
+
Project,
|
|
14
|
+
ProjectDetails,
|
|
15
|
+
ProjectListResponse,
|
|
16
|
+
ProjectRetrieveParams,
|
|
17
|
+
Projects,
|
|
18
|
+
} from './projects/projects';
|
|
@@ -10,7 +10,7 @@ export class Bulk extends APIResource {
|
|
|
10
10
|
* Bulk create up to 100 links for the authenticated project.
|
|
11
11
|
*/
|
|
12
12
|
create(params: BulkCreateParams, options?: Core.RequestOptions): Core.APIPromise<BulkCreateResponse> {
|
|
13
|
-
const { projectSlug, ...body } = params;
|
|
13
|
+
const { projectSlug = this._client.projectSlug, ...body } = params;
|
|
14
14
|
return this._client.post('/links/bulk', { query: { projectSlug }, body, ...options });
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -22,7 +22,7 @@ export interface BulkCreateParams {
|
|
|
22
22
|
* Query param: The slug for the project to create links for. E.g. for
|
|
23
23
|
* app.dub.co/acme, the projectSlug is 'acme'.
|
|
24
24
|
*/
|
|
25
|
-
projectSlug
|
|
25
|
+
projectSlug?: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export namespace BulkCreateParams {
|
|
@@ -9,8 +9,9 @@ export class Info extends APIResource {
|
|
|
9
9
|
/**
|
|
10
10
|
* Retrieve the info for a link from their domain and key.
|
|
11
11
|
*/
|
|
12
|
-
retrieve(
|
|
13
|
-
|
|
12
|
+
retrieve(params: InfoRetrieveParams, options?: Core.RequestOptions): Core.APIPromise<Shared.Link> {
|
|
13
|
+
const { projectSlug = this._client.projectSlug, ...query } = params;
|
|
14
|
+
return this._client.get('/links/info', { query: { projectSlug, ...query }, ...options });
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -30,7 +31,7 @@ export interface InfoRetrieveParams {
|
|
|
30
31
|
* The slug for the project that the link belongs to. E.g. for app.dub.co/acme, the
|
|
31
32
|
* projectSlug is 'acme'.
|
|
32
33
|
*/
|
|
33
|
-
projectSlug
|
|
34
|
+
projectSlug?: string;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
export namespace Info {
|
|
@@ -15,7 +15,7 @@ export class Links extends APIResource {
|
|
|
15
15
|
* Create a new link for the authenticated project.
|
|
16
16
|
*/
|
|
17
17
|
create(params: LinkCreateParams, options?: Core.RequestOptions): Core.APIPromise<Shared.Link> {
|
|
18
|
-
const { projectSlug, ...body } = params;
|
|
18
|
+
const { projectSlug = this._client.projectSlug, ...body } = params;
|
|
19
19
|
return this._client.post('/links', { query: { projectSlug }, body, ...options });
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -27,7 +27,7 @@ export class Links extends APIResource {
|
|
|
27
27
|
params: LinkUpdateParams,
|
|
28
28
|
options?: Core.RequestOptions,
|
|
29
29
|
): Core.APIPromise<Shared.Link> {
|
|
30
|
-
const { projectSlug, ...body } = params;
|
|
30
|
+
const { projectSlug = this._client.projectSlug, ...body } = params;
|
|
31
31
|
return this._client.put(`/links/${linkId}`, { query: { projectSlug }, body, ...options });
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -35,8 +35,9 @@ export class Links extends APIResource {
|
|
|
35
35
|
* Retrieve a list of links for the authenticated project. The list will be
|
|
36
36
|
* paginated and the provided query parameters allow filtering the returned links.
|
|
37
37
|
*/
|
|
38
|
-
list(
|
|
39
|
-
|
|
38
|
+
list(params: LinkListParams, options?: Core.RequestOptions): Core.APIPromise<LinkListResponse> {
|
|
39
|
+
const { projectSlug = this._client.projectSlug, ...query } = params;
|
|
40
|
+
return this._client.get('/links', { query: { projectSlug, ...query }, ...options });
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
/**
|
|
@@ -47,7 +48,7 @@ export class Links extends APIResource {
|
|
|
47
48
|
params: LinkDeleteParams,
|
|
48
49
|
options?: Core.RequestOptions,
|
|
49
50
|
): Core.APIPromise<Shared.Link> {
|
|
50
|
-
const { projectSlug } = params;
|
|
51
|
+
const { projectSlug = this._client.projectSlug } = params;
|
|
51
52
|
return this._client.delete(`/links/${linkId}`, { query: { projectSlug }, ...options });
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -59,7 +60,7 @@ export interface LinkCreateParams {
|
|
|
59
60
|
* Query param: The slug for the project to create links for. E.g. for
|
|
60
61
|
* app.dub.co/acme, the projectSlug is 'acme'.
|
|
61
62
|
*/
|
|
62
|
-
projectSlug
|
|
63
|
+
projectSlug?: string;
|
|
63
64
|
|
|
64
65
|
/**
|
|
65
66
|
* Body param: The domain of the short link.
|
|
@@ -160,7 +161,7 @@ export interface LinkUpdateParams {
|
|
|
160
161
|
* Query param: The slug for the project that the link belongs to. E.g. for
|
|
161
162
|
* app.dub.co/acme, the projectSlug is 'acme'.
|
|
162
163
|
*/
|
|
163
|
-
projectSlug
|
|
164
|
+
projectSlug?: string;
|
|
164
165
|
|
|
165
166
|
/**
|
|
166
167
|
* Body param: The Android destination URL for the short link for Android device
|
|
@@ -261,7 +262,7 @@ export interface LinkListParams {
|
|
|
261
262
|
* The slug for the project to retrieve links for. E.g. for app.dub.co/acme, the
|
|
262
263
|
* projectSlug is 'acme'.
|
|
263
264
|
*/
|
|
264
|
-
projectSlug
|
|
265
|
+
projectSlug?: string;
|
|
265
266
|
|
|
266
267
|
/**
|
|
267
268
|
* The domain to filter the links by. E.g. 'ac.me'. If not provided, all links for
|
|
@@ -308,7 +309,7 @@ export interface LinkDeleteParams {
|
|
|
308
309
|
* The slug for the project that the link belongs to. E.g. for app.dub.co/acme, the
|
|
309
310
|
* projectSlug is 'acme'.
|
|
310
311
|
*/
|
|
311
|
-
projectSlug
|
|
312
|
+
projectSlug?: string;
|
|
312
313
|
}
|
|
313
314
|
|
|
314
315
|
export namespace Links {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
export { Project, ProjectDetails, ProjectListResponse, Projects } from './projects';
|
|
4
|
-
export { Tag, TagListResponse, TagCreateParams, Tags } from './tags';
|
|
3
|
+
export { Project, ProjectDetails, ProjectListResponse, ProjectRetrieveParams, Projects } from './projects';
|
|
4
|
+
export { Tag, TagListResponse, TagCreateParams, TagListParams, Tags } from './tags';
|