dub 0.0.0 → 0.0.1

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.
Files changed (221) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +241 -0
  3. package/_shims/MultipartBody.d.ts +9 -0
  4. package/_shims/MultipartBody.d.ts.map +1 -0
  5. package/_shims/MultipartBody.js +16 -0
  6. package/_shims/MultipartBody.js.map +1 -0
  7. package/_shims/MultipartBody.mjs +12 -0
  8. package/_shims/MultipartBody.mjs.map +1 -0
  9. package/_shims/README.md +46 -0
  10. package/_shims/auto/runtime-bun.d.ts +5 -0
  11. package/_shims/auto/runtime-bun.d.ts.map +1 -0
  12. package/_shims/auto/runtime-bun.js +21 -0
  13. package/_shims/auto/runtime-bun.js.map +1 -0
  14. package/_shims/auto/runtime-bun.mjs +2 -0
  15. package/_shims/auto/runtime-bun.mjs.map +1 -0
  16. package/_shims/auto/runtime-node.d.ts +5 -0
  17. package/_shims/auto/runtime-node.d.ts.map +1 -0
  18. package/_shims/auto/runtime-node.js +21 -0
  19. package/_shims/auto/runtime-node.js.map +1 -0
  20. package/_shims/auto/runtime-node.mjs +2 -0
  21. package/_shims/auto/runtime-node.mjs.map +1 -0
  22. package/_shims/auto/runtime.d.ts +5 -0
  23. package/_shims/auto/runtime.d.ts.map +1 -0
  24. package/_shims/auto/runtime.js +21 -0
  25. package/_shims/auto/runtime.js.map +1 -0
  26. package/_shims/auto/runtime.mjs +2 -0
  27. package/_shims/auto/runtime.mjs.map +1 -0
  28. package/_shims/auto/types-node.d.ts +5 -0
  29. package/_shims/auto/types-node.d.ts.map +1 -0
  30. package/_shims/auto/types-node.js +21 -0
  31. package/_shims/auto/types-node.js.map +1 -0
  32. package/_shims/auto/types-node.mjs +2 -0
  33. package/_shims/auto/types-node.mjs.map +1 -0
  34. package/_shims/auto/types.d.ts +101 -0
  35. package/_shims/auto/types.js +3 -0
  36. package/_shims/auto/types.mjs +3 -0
  37. package/_shims/bun-runtime.d.ts +6 -0
  38. package/_shims/bun-runtime.d.ts.map +1 -0
  39. package/_shims/bun-runtime.js +14 -0
  40. package/_shims/bun-runtime.js.map +1 -0
  41. package/_shims/bun-runtime.mjs +10 -0
  42. package/_shims/bun-runtime.mjs.map +1 -0
  43. package/_shims/index.d.ts +81 -0
  44. package/_shims/index.js +13 -0
  45. package/_shims/index.mjs +7 -0
  46. package/_shims/manual-types.d.ts +12 -0
  47. package/_shims/manual-types.js +3 -0
  48. package/_shims/manual-types.mjs +3 -0
  49. package/_shims/node-runtime.d.ts +3 -0
  50. package/_shims/node-runtime.d.ts.map +1 -0
  51. package/_shims/node-runtime.js +90 -0
  52. package/_shims/node-runtime.js.map +1 -0
  53. package/_shims/node-runtime.mjs +56 -0
  54. package/_shims/node-runtime.mjs.map +1 -0
  55. package/_shims/node-types.d.ts +42 -0
  56. package/_shims/node-types.js +3 -0
  57. package/_shims/node-types.mjs +3 -0
  58. package/_shims/registry.d.ts +37 -0
  59. package/_shims/registry.d.ts.map +1 -0
  60. package/_shims/registry.js +41 -0
  61. package/_shims/registry.js.map +1 -0
  62. package/_shims/registry.mjs +37 -0
  63. package/_shims/registry.mjs.map +1 -0
  64. package/_shims/web-runtime.d.ts +5 -0
  65. package/_shims/web-runtime.d.ts.map +1 -0
  66. package/_shims/web-runtime.js +78 -0
  67. package/_shims/web-runtime.js.map +1 -0
  68. package/_shims/web-runtime.mjs +71 -0
  69. package/_shims/web-runtime.mjs.map +1 -0
  70. package/_shims/web-types.d.ts +83 -0
  71. package/_shims/web-types.js +3 -0
  72. package/_shims/web-types.mjs +3 -0
  73. package/core.d.ts +230 -0
  74. package/core.d.ts.map +1 -0
  75. package/core.js +848 -0
  76. package/core.js.map +1 -0
  77. package/core.mjs +818 -0
  78. package/core.mjs.map +1 -0
  79. package/error.d.ts +53 -0
  80. package/error.d.ts.map +1 -0
  81. package/error.js +143 -0
  82. package/error.js.map +1 -0
  83. package/error.mjs +127 -0
  84. package/error.mjs.map +1 -0
  85. package/index.d.mts +118 -0
  86. package/index.d.ts +118 -0
  87. package/index.d.ts.map +1 -0
  88. package/index.js +109 -0
  89. package/index.js.map +1 -0
  90. package/index.mjs +81 -0
  91. package/index.mjs.map +1 -0
  92. package/package.json +100 -7
  93. package/resource.d.ts +6 -0
  94. package/resource.d.ts.map +1 -0
  95. package/resource.js +11 -0
  96. package/resource.js.map +1 -0
  97. package/resource.mjs +7 -0
  98. package/resource.mjs.map +1 -0
  99. package/resources/index.d.ts +4 -0
  100. package/resources/index.d.ts.map +1 -0
  101. package/resources/index.js +24 -0
  102. package/resources/index.js.map +1 -0
  103. package/resources/index.mjs +5 -0
  104. package/resources/index.mjs.map +1 -0
  105. package/resources/links/bulk.d.ts +101 -0
  106. package/resources/links/bulk.d.ts.map +1 -0
  107. package/resources/links/bulk.js +18 -0
  108. package/resources/links/bulk.js.map +1 -0
  109. package/resources/links/bulk.mjs +14 -0
  110. package/resources/links/bulk.mjs.map +1 -0
  111. package/resources/links/index.d.ts +4 -0
  112. package/resources/links/index.d.ts.map +1 -0
  113. package/resources/links/index.js +11 -0
  114. package/resources/links/index.js.map +1 -0
  115. package/resources/links/index.mjs +5 -0
  116. package/resources/links/index.mjs.map +1 -0
  117. package/resources/links/info.d.ts +30 -0
  118. package/resources/links/info.d.ts.map +1 -0
  119. package/resources/links/info.js +17 -0
  120. package/resources/links/info.js.map +1 -0
  121. package/resources/links/info.mjs +13 -0
  122. package/resources/links/info.mjs.map +1 -0
  123. package/resources/links/links.d.ts +253 -0
  124. package/resources/links/links.d.ts.map +1 -0
  125. package/resources/links/links.js +71 -0
  126. package/resources/links/links.js.map +1 -0
  127. package/resources/links/links.mjs +44 -0
  128. package/resources/links/links.mjs.map +1 -0
  129. package/resources/projects/index.d.ts +3 -0
  130. package/resources/projects/index.d.ts.map +1 -0
  131. package/resources/projects/index.js +9 -0
  132. package/resources/projects/index.js.map +1 -0
  133. package/resources/projects/index.mjs +4 -0
  134. package/resources/projects/index.mjs.map +1 -0
  135. package/resources/projects/projects.d.ts +98 -0
  136. package/resources/projects/projects.d.ts.map +1 -0
  137. package/resources/projects/projects.js +52 -0
  138. package/resources/projects/projects.js.map +1 -0
  139. package/resources/projects/projects.mjs +25 -0
  140. package/resources/projects/projects.mjs.map +1 -0
  141. package/resources/projects/tags.d.ts +40 -0
  142. package/resources/projects/tags.d.ts.map +1 -0
  143. package/resources/projects/tags.js +23 -0
  144. package/resources/projects/tags.js.map +1 -0
  145. package/resources/projects/tags.mjs +19 -0
  146. package/resources/projects/tags.mjs.map +1 -0
  147. package/resources/shared.d.ts +125 -0
  148. package/resources/shared.d.ts.map +1 -0
  149. package/resources/shared.js +4 -0
  150. package/resources/shared.js.map +1 -0
  151. package/resources/shared.mjs +3 -0
  152. package/resources/shared.mjs.map +1 -0
  153. package/shims/node.d.ts +29 -0
  154. package/shims/node.d.ts.map +1 -0
  155. package/shims/node.js +31 -0
  156. package/shims/node.js.map +1 -0
  157. package/shims/node.mjs +5 -0
  158. package/shims/node.mjs.map +1 -0
  159. package/shims/web.d.ts +26 -0
  160. package/shims/web.d.ts.map +1 -0
  161. package/shims/web.js +31 -0
  162. package/shims/web.js.map +1 -0
  163. package/shims/web.mjs +5 -0
  164. package/shims/web.mjs.map +1 -0
  165. package/src/_shims/MultipartBody.ts +9 -0
  166. package/src/_shims/README.md +46 -0
  167. package/src/_shims/auto/runtime-bun.ts +4 -0
  168. package/src/_shims/auto/runtime-node.ts +4 -0
  169. package/src/_shims/auto/runtime.ts +4 -0
  170. package/src/_shims/auto/types-node.ts +4 -0
  171. package/src/_shims/auto/types.d.ts +101 -0
  172. package/src/_shims/auto/types.js +3 -0
  173. package/src/_shims/auto/types.mjs +3 -0
  174. package/src/_shims/bun-runtime.ts +14 -0
  175. package/src/_shims/index.d.ts +81 -0
  176. package/src/_shims/index.js +13 -0
  177. package/src/_shims/index.mjs +7 -0
  178. package/src/_shims/manual-types.d.ts +12 -0
  179. package/src/_shims/manual-types.js +3 -0
  180. package/src/_shims/manual-types.mjs +3 -0
  181. package/src/_shims/node-runtime.ts +83 -0
  182. package/src/_shims/node-types.d.ts +42 -0
  183. package/src/_shims/node-types.js +3 -0
  184. package/src/_shims/node-types.mjs +3 -0
  185. package/src/_shims/registry.ts +63 -0
  186. package/src/_shims/web-runtime.ts +103 -0
  187. package/src/_shims/web-types.d.ts +83 -0
  188. package/src/_shims/web-types.js +3 -0
  189. package/src/_shims/web-types.mjs +3 -0
  190. package/src/core.ts +1122 -0
  191. package/src/error.ts +146 -0
  192. package/src/index.ts +195 -0
  193. package/src/lib/.keep +4 -0
  194. package/src/resource.ts +11 -0
  195. package/src/resources/index.ts +12 -0
  196. package/src/resources/links/bulk.ts +126 -0
  197. package/src/resources/links/index.ts +12 -0
  198. package/src/resources/links/info.ts +38 -0
  199. package/src/resources/links/links.ts +325 -0
  200. package/src/resources/projects/index.ts +4 -0
  201. package/src/resources/projects/projects.ts +122 -0
  202. package/src/resources/projects/tags.ts +53 -0
  203. package/src/resources/shared.ts +154 -0
  204. package/src/shims/node.ts +50 -0
  205. package/src/shims/web.ts +50 -0
  206. package/src/tsconfig.json +11 -0
  207. package/src/uploads.ts +245 -0
  208. package/src/version.ts +1 -0
  209. package/uploads.d.ts +75 -0
  210. package/uploads.d.ts.map +1 -0
  211. package/uploads.js +163 -0
  212. package/uploads.js.map +1 -0
  213. package/uploads.mjs +150 -0
  214. package/uploads.mjs.map +1 -0
  215. package/version.d.ts +2 -0
  216. package/version.d.ts.map +1 -0
  217. package/version.js +5 -0
  218. package/version.js.map +1 -0
  219. package/version.mjs +2 -0
  220. package/version.mjs.map +1 -0
  221. package/main.js +0 -8
package/src/error.ts ADDED
@@ -0,0 +1,146 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+
3
+ import { castToError, Headers } from './core';
4
+
5
+ export class DubError extends Error {}
6
+
7
+ export class APIError extends DubError {
8
+ readonly status: number | undefined;
9
+ readonly headers: Headers | undefined;
10
+ readonly error: Object | undefined;
11
+
12
+ constructor(
13
+ status: number | undefined,
14
+ error: Object | undefined,
15
+ message: string | undefined,
16
+ headers: Headers | undefined,
17
+ ) {
18
+ super(`${APIError.makeMessage(status, error, message)}`);
19
+ this.status = status;
20
+ this.headers = headers;
21
+ this.error = error;
22
+ }
23
+
24
+ private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
25
+ const msg =
26
+ error?.message ?
27
+ typeof error.message === 'string' ?
28
+ error.message
29
+ : JSON.stringify(error.message)
30
+ : error ? JSON.stringify(error)
31
+ : message;
32
+
33
+ if (status && msg) {
34
+ return `${status} ${msg}`;
35
+ }
36
+ if (status) {
37
+ return `${status} status code (no body)`;
38
+ }
39
+ if (msg) {
40
+ return msg;
41
+ }
42
+ return '(no status code or body)';
43
+ }
44
+
45
+ static generate(
46
+ status: number | undefined,
47
+ errorResponse: Object | undefined,
48
+ message: string | undefined,
49
+ headers: Headers | undefined,
50
+ ) {
51
+ if (!status) {
52
+ return new APIConnectionError({ cause: castToError(errorResponse) });
53
+ }
54
+
55
+ const error = errorResponse as Record<string, any>;
56
+
57
+ if (status === 400) {
58
+ return new BadRequestError(status, error, message, headers);
59
+ }
60
+
61
+ if (status === 401) {
62
+ return new AuthenticationError(status, error, message, headers);
63
+ }
64
+
65
+ if (status === 403) {
66
+ return new PermissionDeniedError(status, error, message, headers);
67
+ }
68
+
69
+ if (status === 404) {
70
+ return new NotFoundError(status, error, message, headers);
71
+ }
72
+
73
+ if (status === 409) {
74
+ return new ConflictError(status, error, message, headers);
75
+ }
76
+
77
+ if (status === 422) {
78
+ return new UnprocessableEntityError(status, error, message, headers);
79
+ }
80
+
81
+ if (status === 429) {
82
+ return new RateLimitError(status, error, message, headers);
83
+ }
84
+
85
+ if (status >= 500) {
86
+ return new InternalServerError(status, error, message, headers);
87
+ }
88
+
89
+ return new APIError(status, error, message, headers);
90
+ }
91
+ }
92
+
93
+ export class APIUserAbortError extends APIError {
94
+ override readonly status: undefined = undefined;
95
+
96
+ constructor({ message }: { message?: string } = {}) {
97
+ super(undefined, undefined, message || 'Request was aborted.', undefined);
98
+ }
99
+ }
100
+
101
+ export class APIConnectionError extends APIError {
102
+ override readonly status: undefined = undefined;
103
+
104
+ constructor({ message, cause }: { message?: string; cause?: Error | undefined }) {
105
+ super(undefined, undefined, message || 'Connection error.', undefined);
106
+ // in some environments the 'cause' property is already declared
107
+ // @ts-ignore
108
+ if (cause) this.cause = cause;
109
+ }
110
+ }
111
+
112
+ export class APIConnectionTimeoutError extends APIConnectionError {
113
+ constructor({ message }: { message?: string } = {}) {
114
+ super({ message: message ?? 'Request timed out.' });
115
+ }
116
+ }
117
+
118
+ export class BadRequestError extends APIError {
119
+ override readonly status: 400 = 400;
120
+ }
121
+
122
+ export class AuthenticationError extends APIError {
123
+ override readonly status: 401 = 401;
124
+ }
125
+
126
+ export class PermissionDeniedError extends APIError {
127
+ override readonly status: 403 = 403;
128
+ }
129
+
130
+ export class NotFoundError extends APIError {
131
+ override readonly status: 404 = 404;
132
+ }
133
+
134
+ export class ConflictError extends APIError {
135
+ override readonly status: 409 = 409;
136
+ }
137
+
138
+ export class UnprocessableEntityError extends APIError {
139
+ override readonly status: 422 = 422;
140
+ }
141
+
142
+ export class RateLimitError extends APIError {
143
+ override readonly status: 429 = 429;
144
+ }
145
+
146
+ export class InternalServerError extends APIError {}
package/src/index.ts ADDED
@@ -0,0 +1,195 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+
3
+ import * as Core from './core';
4
+ import * as Errors from './error';
5
+ import { type Agent } from './_shims/index';
6
+ import * as Uploads from './uploads';
7
+ import * as API from "./resources/index";
8
+
9
+ export interface ClientOptions {
10
+ /**
11
+ * Defaults to process.env['DUB_BEARER_TOKEN'].
12
+ */
13
+ bearerToken?: string;
14
+
15
+ /**
16
+ * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
17
+ *
18
+ * Defaults to process.env['DUB_BASE_URL'].
19
+ */
20
+ baseURL?: string | null | undefined;
21
+
22
+ /**
23
+ * The maximum amount of time (in milliseconds) that the client should wait for a response
24
+ * from the server before timing out a single request.
25
+ *
26
+ * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
27
+ * much longer than this timeout before the promise succeeds or fails.
28
+ */
29
+ timeout?: number;
30
+
31
+ /**
32
+ * An HTTP agent used to manage HTTP(S) connections.
33
+ *
34
+ * If not provided, an agent will be constructed by default in the Node.js environment,
35
+ * otherwise no agent is used.
36
+ */
37
+ httpAgent?: Agent;
38
+
39
+ /**
40
+ * Specify a custom `fetch` function implementation.
41
+ *
42
+ * If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
43
+ * defined globally.
44
+ */
45
+ fetch?: Core.Fetch | undefined;
46
+
47
+ /**
48
+ * The maximum number of times that the client will retry a request in case of a
49
+ * temporary failure, like a network error or a 5XX error from the server.
50
+ *
51
+ * @default 2
52
+ */
53
+ maxRetries?: number;
54
+
55
+ /**
56
+ * Default headers to include with every request to the API.
57
+ *
58
+ * These can be removed in individual requests by explicitly setting the
59
+ * header to `undefined` or `null` in request options.
60
+ */
61
+ defaultHeaders?: Core.Headers;
62
+
63
+ /**
64
+ * Default query parameters to include with every request to the API.
65
+ *
66
+ * These can be removed in individual requests by explicitly setting the
67
+ * param to `undefined` in request options.
68
+ */
69
+ defaultQuery?: Core.DefaultQuery;
70
+ }
71
+
72
+ /** API Client for interfacing with the Dub API. */
73
+ export class Dub extends Core.APIClient {
74
+ bearerToken: string;
75
+
76
+ private _options: ClientOptions;
77
+
78
+ /**
79
+ * API Client for interfacing with the Dub API.
80
+ *
81
+ * @param {string} [opts.bearerToken=process.env['DUB_BEARER_TOKEN'] ?? undefined]
82
+ * @param {string} [opts.baseURL=process.env['DUB_BASE_URL'] ?? https://api.dub.co] - Override the default base URL for the API.
83
+ * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
84
+ * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
85
+ * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
86
+ * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
87
+ * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
88
+ * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
89
+ */
90
+ constructor({
91
+ baseURL = Core.readEnv('DUB_BASE_URL'),
92
+ bearerToken = Core.readEnv('DUB_BEARER_TOKEN'),
93
+ ...opts
94
+ }: ClientOptions = {}) {
95
+ if (bearerToken === undefined) {
96
+ throw new Errors.DubError(
97
+ "The DUB_BEARER_TOKEN environment variable is missing or empty; either provide it, or instantiate the Dub client with an bearerToken option, like new Dub({ bearerToken: 'My Bearer Token' }).",
98
+ );
99
+ }
100
+
101
+ const options: ClientOptions = {
102
+ bearerToken,
103
+ ...opts,
104
+ baseURL: baseURL ?? `https://api.dub.co`,
105
+ };
106
+
107
+ super({
108
+ baseURL: options.baseURL!,
109
+ timeout: options.timeout ?? 60000 /* 1 minute */,
110
+ httpAgent: options.httpAgent,
111
+ maxRetries: options.maxRetries,
112
+ fetch: options.fetch,
113
+ });
114
+ this._options = options;
115
+
116
+ this.bearerToken = bearerToken;
117
+ }
118
+
119
+ links: API.Links = new API.Links(this);
120
+ projects: API.Projects = new API.Projects(this);
121
+
122
+ protected override defaultQuery(): Core.DefaultQuery | undefined {
123
+ return this._options.defaultQuery;
124
+ }
125
+
126
+ protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
127
+ return {
128
+ ...super.defaultHeaders(opts),
129
+ ...this._options.defaultHeaders,
130
+ };
131
+ }
132
+
133
+ protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
134
+ return { Authorization: `Bearer ${this.bearerToken}` };
135
+ }
136
+
137
+ static Dub = this;
138
+
139
+ static DubError = Errors.DubError;
140
+ static APIError = Errors.APIError;
141
+ static APIConnectionError = Errors.APIConnectionError;
142
+ static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
143
+ static APIUserAbortError = Errors.APIUserAbortError;
144
+ static NotFoundError = Errors.NotFoundError;
145
+ static ConflictError = Errors.ConflictError;
146
+ static RateLimitError = Errors.RateLimitError;
147
+ static BadRequestError = Errors.BadRequestError;
148
+ static AuthenticationError = Errors.AuthenticationError;
149
+ static InternalServerError = Errors.InternalServerError;
150
+ static PermissionDeniedError = Errors.PermissionDeniedError;
151
+ static UnprocessableEntityError = Errors.UnprocessableEntityError;
152
+ }
153
+
154
+ export const {
155
+ DubError,
156
+ APIError,
157
+ APIConnectionError,
158
+ APIConnectionTimeoutError,
159
+ APIUserAbortError,
160
+ NotFoundError,
161
+ ConflictError,
162
+ RateLimitError,
163
+ BadRequestError,
164
+ AuthenticationError,
165
+ InternalServerError,
166
+ PermissionDeniedError,
167
+ UnprocessableEntityError,
168
+ } = Errors;
169
+
170
+ export import toFile = Uploads.toFile;
171
+ export import fileFromPath = Uploads.fileFromPath;
172
+
173
+ export namespace Dub {
174
+ // Helper functions
175
+ export import toFile = Uploads.toFile;
176
+ export import fileFromPath = Uploads.fileFromPath;
177
+
178
+ export import RequestOptions = Core.RequestOptions;
179
+
180
+ export import Links = API.Links;
181
+ export import LinkListResponse = API.LinkListResponse;
182
+ export import LinkCreateParams = API.LinkCreateParams;
183
+ export import LinkUpdateParams = API.LinkUpdateParams;
184
+ export import LinkListParams = API.LinkListParams;
185
+ export import LinkDeleteParams = API.LinkDeleteParams;
186
+
187
+ export import Projects = API.Projects;
188
+ export import Project = API.Project;
189
+ export import ProjectDetails = API.ProjectDetails;
190
+ export import ProjectListResponse = API.ProjectListResponse;
191
+
192
+ export import Link = API.Link;
193
+ }
194
+
195
+ export default Dub;
package/src/lib/.keep ADDED
@@ -0,0 +1,4 @@
1
+ File generated from our OpenAPI spec by Stainless.
2
+
3
+ This directory can be used to store custom files to expand the SDK.
4
+ It is ignored by Stainless code generation and its content (other than this keep file) won't be touched.
@@ -0,0 +1,11 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+
3
+ import type { Dub } from './index';
4
+
5
+ export class APIResource {
6
+ protected _client: Dub;
7
+
8
+ constructor(client: Dub) {
9
+ this._client = client;
10
+ }
11
+ }
@@ -0,0 +1,12 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+
3
+ export * from './shared';
4
+ export {
5
+ LinkListResponse,
6
+ LinkCreateParams,
7
+ LinkUpdateParams,
8
+ LinkListParams,
9
+ LinkDeleteParams,
10
+ Links,
11
+ } from './links/links';
12
+ export { Project, ProjectDetails, ProjectListResponse, Projects } from './projects/projects';
@@ -0,0 +1,126 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+
3
+ import * as Core from "../../core";
4
+ import { APIResource } from "../../resource";
5
+ import * as BulkAPI from "./bulk";
6
+ import * as Shared from "../shared";
7
+
8
+ export class Bulk extends APIResource {
9
+ /**
10
+ * Bulk create up to 100 links for the authenticated project.
11
+ */
12
+ create(params: BulkCreateParams, options?: Core.RequestOptions): Core.APIPromise<BulkCreateResponse> {
13
+ const { projectSlug, ...body } = params;
14
+ return this._client.post('/links/bulk', { query: { projectSlug }, body, ...options });
15
+ }
16
+ }
17
+
18
+ export type BulkCreateResponse = Array<Shared.Link>;
19
+
20
+ export interface BulkCreateParams {
21
+ /**
22
+ * Query param: The slug for the project to create links for. E.g. for
23
+ * app.dub.co/acme, the projectSlug is 'acme'.
24
+ */
25
+ projectSlug: string;
26
+ }
27
+
28
+ export namespace BulkCreateParams {
29
+ export interface Body {
30
+ /**
31
+ * The Android destination URL for the short link for Android device targeting.
32
+ */
33
+ android?: string | null;
34
+
35
+ /**
36
+ * Whether the short link is archived.
37
+ */
38
+ archived?: boolean;
39
+
40
+ /**
41
+ * The comments for the short link.
42
+ */
43
+ comments?: string | null;
44
+
45
+ /**
46
+ * The description of the short link generated via api.dub.co/metatags. Will be
47
+ * used for Custom Social Media Cards if `proxy` is true.
48
+ */
49
+ description?: string | null;
50
+
51
+ /**
52
+ * The domain of the short link.
53
+ */
54
+ domain?: string;
55
+
56
+ /**
57
+ * The date and time when the short link will expire in ISO-8601 format. Must be in
58
+ * the future.
59
+ */
60
+ expiresAt?: string | null;
61
+
62
+ /**
63
+ * Geo targeting information for the short link in JSON format {[COUNTRY]:
64
+ * "https://example.com" }. Learn more: https://dub.sh/geo
65
+ */
66
+ geo?: Record<string, string> | null;
67
+
68
+ /**
69
+ * The image of the short link generated via api.dub.co/metatags. Will be used for
70
+ * Custom Social Media Cards if `proxy` is true.
71
+ */
72
+ image?: string | null;
73
+
74
+ /**
75
+ * The iOS destination URL for the short link for iOS device targeting.
76
+ */
77
+ ios?: string | null;
78
+
79
+ /**
80
+ * The short link slug. If not provided, a random 7-character slug will be
81
+ * generated.
82
+ */
83
+ key?: string;
84
+
85
+ /**
86
+ * The password required to access the destination URL of the short link.
87
+ */
88
+ password?: string | null;
89
+
90
+ /**
91
+ * Whether the short link uses Custom Social Media Cards feature.
92
+ */
93
+ proxy?: boolean;
94
+
95
+ /**
96
+ * Whether the short link's stats are publicly accessible.
97
+ */
98
+ publicStats?: boolean;
99
+
100
+ /**
101
+ * Whether the short link uses link cloaking.
102
+ */
103
+ rewrite?: boolean;
104
+
105
+ /**
106
+ * The unique id of the tag assigned to the short link.
107
+ */
108
+ tagId?: string | null;
109
+
110
+ /**
111
+ * The title of the short link generated via api.dub.co/metatags. Will be used for
112
+ * Custom Social Media Cards if `proxy` is true.
113
+ */
114
+ title?: string | null;
115
+
116
+ /**
117
+ * The destination URL of the short link.
118
+ */
119
+ url?: string;
120
+ }
121
+ }
122
+
123
+ export namespace Bulk {
124
+ export import BulkCreateResponse = BulkAPI.BulkCreateResponse;
125
+ export import BulkCreateParams = BulkAPI.BulkCreateParams;
126
+ }
@@ -0,0 +1,12 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+
3
+ export { BulkCreateResponse, BulkCreateParams, Bulk } from './bulk';
4
+ export { InfoRetrieveParams, Info } from './info';
5
+ export {
6
+ LinkListResponse,
7
+ LinkCreateParams,
8
+ LinkUpdateParams,
9
+ LinkListParams,
10
+ LinkDeleteParams,
11
+ Links,
12
+ } from './links';
@@ -0,0 +1,38 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+
3
+ import * as Core from "../../core";
4
+ import { APIResource } from "../../resource";
5
+ import * as InfoAPI from "./info";
6
+ import * as Shared from "../shared";
7
+
8
+ export class Info extends APIResource {
9
+ /**
10
+ * Retrieve the info for a link from their domain and key.
11
+ */
12
+ retrieve(query: InfoRetrieveParams, options?: Core.RequestOptions): Core.APIPromise<Shared.Link> {
13
+ return this._client.get('/links/info', { query, ...options });
14
+ }
15
+ }
16
+
17
+ export interface InfoRetrieveParams {
18
+ /**
19
+ * The domain of the link to retrieve. E.g. for dub.sh/github, the domain is
20
+ * 'dub.sh'.
21
+ */
22
+ domain: string;
23
+
24
+ /**
25
+ * The key of the link to retrieve. E.g. for dub.sh/github, the key is 'github'.
26
+ */
27
+ key: string;
28
+
29
+ /**
30
+ * The slug for the project that the link belongs to. E.g. for app.dub.co/acme, the
31
+ * projectSlug is 'acme'.
32
+ */
33
+ projectSlug: string;
34
+ }
35
+
36
+ export namespace Info {
37
+ export import InfoRetrieveParams = InfoAPI.InfoRetrieveParams;
38
+ }