@apicity/dropbox 0.6.6
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/LICENSE +21 -0
- package/README.md +227 -0
- package/dist/src/dropbox.d.ts +3 -0
- package/dist/src/dropbox.d.ts.map +1 -0
- package/dist/src/dropbox.js +253 -0
- package/dist/src/dropbox.js.map +1 -0
- package/dist/src/example.d.ts +8 -0
- package/dist/src/example.d.ts.map +1 -0
- package/dist/src/example.js +85 -0
- package/dist/src/example.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +237 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +15 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/zod.d.ts +286 -0
- package/dist/src/zod.d.ts.map +1 -0
- package/dist/src/zod.js +208 -0
- package/dist/src/zod.js.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Justin Tanner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# @apicity/dropbox
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@apicity/dropbox)
|
|
4
|
+
[](package.json)
|
|
5
|
+
[](tsconfig.json)
|
|
6
|
+
[](https://www.dropbox.com/developers/documentation/http/documentation)
|
|
7
|
+
|
|
8
|
+
Dropbox HTTP API provider for users, files, content upload/download, and sharing endpoints.
|
|
9
|
+
|
|
10
|
+
Runtime dependencies:
|
|
11
|
+
|
|
12
|
+
- `zod@^4.4.3` — request schemas attached to Dropbox endpoint methods as `.schema`
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @apicity/dropbox
|
|
18
|
+
# or
|
|
19
|
+
pnpm add @apicity/dropbox
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { createDropbox } from "@apicity/dropbox";
|
|
26
|
+
|
|
27
|
+
const dropbox = createDropbox({ oauthToken: process.env.DROPBOX_OAUTH_TOKEN! });
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
If `oauthToken` is omitted, the provider reads `DROPBOX_OAUTH_TOKEN` at request time.
|
|
31
|
+
Tokens are only sent in the `Authorization: Bearer ...` header.
|
|
32
|
+
|
|
33
|
+
## API Reference
|
|
34
|
+
|
|
35
|
+
12 endpoints across 3 groups. Each method mirrors an upstream URL path.
|
|
36
|
+
|
|
37
|
+
### files
|
|
38
|
+
|
|
39
|
+
<details>
|
|
40
|
+
<summary><code>POST</code> <b><code>dropbox.files.copyV2</code></b></summary>
|
|
41
|
+
|
|
42
|
+
<code>POST https://api.dropboxapi.com/2/files/copy_v2</code>
|
|
43
|
+
|
|
44
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#files-copy_v2)
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
const res = await dropbox.files.copyV2({ /* ... */ });
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
51
|
+
|
|
52
|
+
</details>
|
|
53
|
+
|
|
54
|
+
<details>
|
|
55
|
+
<summary><code>POST</code> <b><code>dropbox.files.createFolderV2</code></b></summary>
|
|
56
|
+
|
|
57
|
+
<code>POST https://api.dropboxapi.com/2/files/create_folder_v2</code>
|
|
58
|
+
|
|
59
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder_v2)
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const res = await dropbox.files.createFolderV2({ /* ... */ });
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
66
|
+
|
|
67
|
+
</details>
|
|
68
|
+
|
|
69
|
+
<details>
|
|
70
|
+
<summary><code>POST</code> <b><code>dropbox.files.deleteV2</code></b></summary>
|
|
71
|
+
|
|
72
|
+
<code>POST https://api.dropboxapi.com/2/files/delete_v2</code>
|
|
73
|
+
|
|
74
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#files-delete_v2)
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
const res = await dropbox.files.deleteV2({ /* ... */ });
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
81
|
+
|
|
82
|
+
</details>
|
|
83
|
+
|
|
84
|
+
<details>
|
|
85
|
+
<summary><code>POST</code> <b><code>dropbox.files.download</code></b></summary>
|
|
86
|
+
|
|
87
|
+
<code>POST https://content.dropboxapi.com/2/files/download</code>
|
|
88
|
+
|
|
89
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#files-download)
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
const res = await dropbox.files.download({ /* ... */ });
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
96
|
+
|
|
97
|
+
</details>
|
|
98
|
+
|
|
99
|
+
<details>
|
|
100
|
+
<summary><code>POST</code> <b><code>dropbox.files.getMetadata</code></b></summary>
|
|
101
|
+
|
|
102
|
+
<code>POST https://api.dropboxapi.com/2/files/get_metadata</code>
|
|
103
|
+
|
|
104
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata)
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
const res = await dropbox.files.getMetadata({ /* ... */ });
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
111
|
+
|
|
112
|
+
</details>
|
|
113
|
+
|
|
114
|
+
<details>
|
|
115
|
+
<summary><code>POST</code> <b><code>dropbox.files.listFolder</code></b></summary>
|
|
116
|
+
|
|
117
|
+
<code>POST https://api.dropboxapi.com/2/files/list_folder</code>
|
|
118
|
+
|
|
119
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder)
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
const res = await dropbox.files.listFolder({ /* ... */ });
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
126
|
+
|
|
127
|
+
</details>
|
|
128
|
+
|
|
129
|
+
<details>
|
|
130
|
+
<summary><code>POST</code> <b><code>dropbox.files.listFolderContinue</code></b></summary>
|
|
131
|
+
|
|
132
|
+
<code>POST https://api.dropboxapi.com/2/files/list_folder/continue</code>
|
|
133
|
+
|
|
134
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-continue)
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
const res = await dropbox.files.listFolderContinue({ /* ... */ });
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
141
|
+
|
|
142
|
+
</details>
|
|
143
|
+
|
|
144
|
+
<details>
|
|
145
|
+
<summary><code>POST</code> <b><code>dropbox.files.moveV2</code></b></summary>
|
|
146
|
+
|
|
147
|
+
<code>POST https://api.dropboxapi.com/2/files/move_v2</code>
|
|
148
|
+
|
|
149
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#files-move_v2)
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
const res = await dropbox.files.moveV2({ /* ... */ });
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
156
|
+
|
|
157
|
+
</details>
|
|
158
|
+
|
|
159
|
+
<details>
|
|
160
|
+
<summary><code>POST</code> <b><code>dropbox.files.upload</code></b></summary>
|
|
161
|
+
|
|
162
|
+
<code>POST https://content.dropboxapi.com/2/files/upload</code>
|
|
163
|
+
|
|
164
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#files-upload)
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
const res = await dropbox.files.upload({ /* ... */ });
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
171
|
+
|
|
172
|
+
</details>
|
|
173
|
+
|
|
174
|
+
### sharing
|
|
175
|
+
|
|
176
|
+
<details>
|
|
177
|
+
<summary><code>POST</code> <b><code>dropbox.sharing.createSharedLinkWithSettings</code></b></summary>
|
|
178
|
+
|
|
179
|
+
<code>POST https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings</code>
|
|
180
|
+
|
|
181
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#sharing-create_shared_link_with_settings)
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
const res = await dropbox.sharing.createSharedLinkWithSettings({ /* ... */ });
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
188
|
+
|
|
189
|
+
</details>
|
|
190
|
+
|
|
191
|
+
<details>
|
|
192
|
+
<summary><code>POST</code> <b><code>dropbox.sharing.listSharedLinks</code></b></summary>
|
|
193
|
+
|
|
194
|
+
<code>POST https://api.dropboxapi.com/2/sharing/list_shared_links</code>
|
|
195
|
+
|
|
196
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_shared_links)
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
const res = await dropbox.sharing.listSharedLinks({ /* ... */ });
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
203
|
+
|
|
204
|
+
</details>
|
|
205
|
+
|
|
206
|
+
### users
|
|
207
|
+
|
|
208
|
+
<details>
|
|
209
|
+
<summary><code>POST</code> <b><code>dropbox.users.getCurrentAccount</code></b></summary>
|
|
210
|
+
|
|
211
|
+
<code>POST https://api.dropboxapi.com/2/users/get_current_account</code>
|
|
212
|
+
|
|
213
|
+
[Upstream docs ↗](https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account)
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
const res = await dropbox.users.getCurrentAccount({ /* ... */ });
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Source: [`packages/provider/dropbox/src/dropbox.ts`](src/dropbox.ts)
|
|
220
|
+
|
|
221
|
+
</details>
|
|
222
|
+
|
|
223
|
+
Part of the [apicity](https://github.com/justintanner/apicity) monorepo.
|
|
224
|
+
|
|
225
|
+
## License
|
|
226
|
+
|
|
227
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropbox.d.ts","sourceRoot":"","sources":["../../src/dropbox.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAgBV,cAAc,EACd,eAAe,EAMhB,MAAM,SAAS,CAAC;AAqBjB,wBAAgB,aAAa,CAAC,IAAI,GAAE,cAAmB,GAAG,eAAe,CA4axE"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { attachExamples } from "./example.js";
|
|
2
|
+
import { DropboxError } from "./types.js";
|
|
3
|
+
import { DropboxFilesCreateFolderV2RequestSchema, DropboxFilesDeleteV2RequestSchema, DropboxFilesDownloadRequestSchema, DropboxFilesGetMetadataRequestSchema, DropboxFilesListFolderContinueRequestSchema, DropboxFilesListFolderRequestSchema, DropboxFilesRelocationRequestSchema, DropboxFilesUploadRequestSchema, DropboxSharingCreateSharedLinkWithSettingsRequestSchema, DropboxSharingListSharedLinksRequestSchema, } from "./zod.js";
|
|
4
|
+
export function createDropbox(opts = {}) {
|
|
5
|
+
const baseURL = (opts.apiBaseURL ?? "https://api.dropboxapi.com/2").replace(/\/+$/, "");
|
|
6
|
+
const uploadBaseURL = (opts.contentBaseURL ?? "https://content.dropboxapi.com/2").replace(/\/+$/, "");
|
|
7
|
+
const doFetch = opts.fetch ?? fetch;
|
|
8
|
+
const timeout = opts.timeout ?? 30000;
|
|
9
|
+
function attachAbortHandler(signal, controller) {
|
|
10
|
+
if (signal.aborted) {
|
|
11
|
+
controller.abort();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
15
|
+
}
|
|
16
|
+
function oauthToken() {
|
|
17
|
+
const token = opts.oauthToken ?? process.env.DROPBOX_OAUTH_TOKEN;
|
|
18
|
+
if (!token) {
|
|
19
|
+
throw new DropboxError("Dropbox OAuth token is required. Pass oauthToken or set DROPBOX_OAUTH_TOKEN.", 401);
|
|
20
|
+
}
|
|
21
|
+
return token;
|
|
22
|
+
}
|
|
23
|
+
function authHeaders() {
|
|
24
|
+
return {
|
|
25
|
+
Authorization: `Bearer ${oauthToken()}`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function errorDetails(body) {
|
|
29
|
+
if (body === null || typeof body !== "object")
|
|
30
|
+
return {};
|
|
31
|
+
const record = body;
|
|
32
|
+
return {
|
|
33
|
+
errorSummary: typeof record.error_summary === "string"
|
|
34
|
+
? record.error_summary
|
|
35
|
+
: undefined,
|
|
36
|
+
error: record.error,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function errorMessage(status, body) {
|
|
40
|
+
const { errorSummary } = errorDetails(body);
|
|
41
|
+
if (errorSummary)
|
|
42
|
+
return `Dropbox API error ${status}: ${errorSummary}`;
|
|
43
|
+
if (typeof body === "string" && body.length > 0) {
|
|
44
|
+
return `Dropbox API error ${status}: ${body}`;
|
|
45
|
+
}
|
|
46
|
+
return `Dropbox API error: ${status}`;
|
|
47
|
+
}
|
|
48
|
+
async function parseBody(res) {
|
|
49
|
+
const text = await res.text();
|
|
50
|
+
if (text.length === 0)
|
|
51
|
+
return null;
|
|
52
|
+
try {
|
|
53
|
+
return JSON.parse(text);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return text;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function throwDropboxError(res) {
|
|
60
|
+
const body = await parseBody(res);
|
|
61
|
+
const { errorSummary, error } = errorDetails(body);
|
|
62
|
+
throw new DropboxError(errorMessage(res.status, body), res.status, body, errorSummary, error);
|
|
63
|
+
}
|
|
64
|
+
async function makeJsonRequest(method, path, body, signal) {
|
|
65
|
+
const controller = new AbortController();
|
|
66
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
67
|
+
if (signal)
|
|
68
|
+
attachAbortHandler(signal, controller);
|
|
69
|
+
try {
|
|
70
|
+
const res = await doFetch(`${baseURL}${path}`, {
|
|
71
|
+
method,
|
|
72
|
+
headers: {
|
|
73
|
+
...authHeaders(),
|
|
74
|
+
"Content-Type": "application/json",
|
|
75
|
+
},
|
|
76
|
+
body: JSON.stringify(body),
|
|
77
|
+
signal: controller.signal,
|
|
78
|
+
});
|
|
79
|
+
if (!res.ok)
|
|
80
|
+
await throwDropboxError(res);
|
|
81
|
+
return (await parseBody(res));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (error instanceof DropboxError)
|
|
85
|
+
throw error;
|
|
86
|
+
throw new DropboxError(`Dropbox request failed: ${error}`, 500);
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
clearTimeout(timeoutId);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async function makeUploadRequest(path, req, signal, options = { baseOverride: uploadBaseURL }) {
|
|
93
|
+
const { contents, ...arg } = req;
|
|
94
|
+
const controller = new AbortController();
|
|
95
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
96
|
+
if (signal)
|
|
97
|
+
attachAbortHandler(signal, controller);
|
|
98
|
+
try {
|
|
99
|
+
const res = await doFetch(`${options.baseOverride}${path}`, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
headers: {
|
|
102
|
+
...authHeaders(),
|
|
103
|
+
"Content-Type": "application/octet-stream",
|
|
104
|
+
"Dropbox-API-Arg": JSON.stringify(arg),
|
|
105
|
+
},
|
|
106
|
+
body: contents,
|
|
107
|
+
signal: controller.signal,
|
|
108
|
+
});
|
|
109
|
+
if (!res.ok)
|
|
110
|
+
await throwDropboxError(res);
|
|
111
|
+
return (await parseBody(res));
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (error instanceof DropboxError)
|
|
115
|
+
throw error;
|
|
116
|
+
throw new DropboxError(`Dropbox request failed: ${error}`, 500);
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
clearTimeout(timeoutId);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function parseDropboxApiResult(header) {
|
|
123
|
+
if (!header) {
|
|
124
|
+
throw new DropboxError("Dropbox download response is missing Dropbox-API-Result.", 500);
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
return JSON.parse(header);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
throw new DropboxError(`Dropbox download metadata parse failed: ${error}`, 500, header);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async function makeBinaryRequest(path, req, signal, options = { baseOverride: uploadBaseURL }) {
|
|
134
|
+
const controller = new AbortController();
|
|
135
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
136
|
+
if (signal)
|
|
137
|
+
attachAbortHandler(signal, controller);
|
|
138
|
+
try {
|
|
139
|
+
const res = await doFetch(`${options.baseOverride}${path}`, {
|
|
140
|
+
method: "POST",
|
|
141
|
+
headers: {
|
|
142
|
+
...authHeaders(),
|
|
143
|
+
"Dropbox-API-Arg": JSON.stringify(req),
|
|
144
|
+
},
|
|
145
|
+
signal: controller.signal,
|
|
146
|
+
});
|
|
147
|
+
if (!res.ok)
|
|
148
|
+
await throwDropboxError(res);
|
|
149
|
+
const metadata = parseDropboxApiResult(res.headers.get("Dropbox-API-Result"));
|
|
150
|
+
const content = await res.arrayBuffer();
|
|
151
|
+
const contentType = res.headers.get("Content-Type") ?? undefined;
|
|
152
|
+
return {
|
|
153
|
+
metadata,
|
|
154
|
+
content,
|
|
155
|
+
contentType,
|
|
156
|
+
headers: res.headers,
|
|
157
|
+
text: () => new TextDecoder().decode(content),
|
|
158
|
+
bytes: () => new Uint8Array(content.slice(0)),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
if (error instanceof DropboxError)
|
|
163
|
+
throw error;
|
|
164
|
+
throw new DropboxError(`Dropbox request failed: ${error}`, 500);
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
clearTimeout(timeoutId);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// POST https://api.dropboxapi.com/2/users/get_current_account
|
|
171
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account
|
|
172
|
+
const getCurrentAccount = Object.assign(async (signal) => {
|
|
173
|
+
return makeJsonRequest("POST", "/users/get_current_account", null, signal);
|
|
174
|
+
}, { schema: undefined });
|
|
175
|
+
// POST https://api.dropboxapi.com/2/files/list_folder
|
|
176
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder
|
|
177
|
+
const listFolder = Object.assign(async (req, signal) => {
|
|
178
|
+
return makeJsonRequest("POST", "/files/list_folder", req, signal);
|
|
179
|
+
}, { schema: DropboxFilesListFolderRequestSchema });
|
|
180
|
+
// POST https://api.dropboxapi.com/2/files/list_folder/continue
|
|
181
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-continue
|
|
182
|
+
const listFolderContinue = Object.assign(async (req, signal) => {
|
|
183
|
+
return makeJsonRequest("POST", "/files/list_folder/continue", req, signal);
|
|
184
|
+
}, { schema: DropboxFilesListFolderContinueRequestSchema });
|
|
185
|
+
// POST https://api.dropboxapi.com/2/files/get_metadata
|
|
186
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata
|
|
187
|
+
const getMetadata = Object.assign(async (req, signal) => {
|
|
188
|
+
return makeJsonRequest("POST", "/files/get_metadata", req, signal);
|
|
189
|
+
}, { schema: DropboxFilesGetMetadataRequestSchema });
|
|
190
|
+
// POST https://api.dropboxapi.com/2/files/create_folder_v2
|
|
191
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder_v2
|
|
192
|
+
const createFolderV2 = Object.assign(async (req, signal) => {
|
|
193
|
+
return makeJsonRequest("POST", "/files/create_folder_v2", req, signal);
|
|
194
|
+
}, { schema: DropboxFilesCreateFolderV2RequestSchema });
|
|
195
|
+
// POST https://api.dropboxapi.com/2/files/delete_v2
|
|
196
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#files-delete_v2
|
|
197
|
+
const deleteV2 = Object.assign(async (req, signal) => {
|
|
198
|
+
return makeJsonRequest("POST", "/files/delete_v2", req, signal);
|
|
199
|
+
}, { schema: DropboxFilesDeleteV2RequestSchema });
|
|
200
|
+
// POST https://api.dropboxapi.com/2/files/copy_v2
|
|
201
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#files-copy_v2
|
|
202
|
+
const copyV2 = Object.assign(async (req, signal) => {
|
|
203
|
+
return makeJsonRequest("POST", "/files/copy_v2", req, signal);
|
|
204
|
+
}, { schema: DropboxFilesRelocationRequestSchema });
|
|
205
|
+
// POST https://api.dropboxapi.com/2/files/move_v2
|
|
206
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#files-move_v2
|
|
207
|
+
const moveV2 = Object.assign(async (req, signal) => {
|
|
208
|
+
return makeJsonRequest("POST", "/files/move_v2", req, signal);
|
|
209
|
+
}, { schema: DropboxFilesRelocationRequestSchema });
|
|
210
|
+
// POST https://content.dropboxapi.com/2/files/upload
|
|
211
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#files-upload
|
|
212
|
+
const upload = Object.assign(async (req, signal) => {
|
|
213
|
+
return makeUploadRequest("/files/upload", req, signal, { baseOverride: uploadBaseURL });
|
|
214
|
+
}, { schema: DropboxFilesUploadRequestSchema });
|
|
215
|
+
// POST https://content.dropboxapi.com/2/files/download
|
|
216
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#files-download
|
|
217
|
+
const download = Object.assign(async (req, signal) => {
|
|
218
|
+
return makeBinaryRequest("/files/download", req, signal, {
|
|
219
|
+
baseOverride: uploadBaseURL,
|
|
220
|
+
});
|
|
221
|
+
}, { schema: DropboxFilesDownloadRequestSchema });
|
|
222
|
+
// POST https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings
|
|
223
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#sharing-create_shared_link_with_settings
|
|
224
|
+
const createSharedLinkWithSettings = Object.assign(async (req, signal) => {
|
|
225
|
+
return makeJsonRequest("POST", "/sharing/create_shared_link_with_settings", req, signal);
|
|
226
|
+
}, { schema: DropboxSharingCreateSharedLinkWithSettingsRequestSchema });
|
|
227
|
+
// POST https://api.dropboxapi.com/2/sharing/list_shared_links
|
|
228
|
+
// Docs: https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_shared_links
|
|
229
|
+
const listSharedLinks = Object.assign(async (req = {}, signal) => {
|
|
230
|
+
return makeJsonRequest("POST", "/sharing/list_shared_links", req, signal);
|
|
231
|
+
}, { schema: DropboxSharingListSharedLinksRequestSchema });
|
|
232
|
+
return attachExamples({
|
|
233
|
+
users: {
|
|
234
|
+
getCurrentAccount,
|
|
235
|
+
},
|
|
236
|
+
files: {
|
|
237
|
+
listFolder,
|
|
238
|
+
listFolderContinue,
|
|
239
|
+
getMetadata,
|
|
240
|
+
createFolderV2,
|
|
241
|
+
deleteV2,
|
|
242
|
+
copyV2,
|
|
243
|
+
moveV2,
|
|
244
|
+
upload,
|
|
245
|
+
download,
|
|
246
|
+
},
|
|
247
|
+
sharing: {
|
|
248
|
+
createSharedLinkWithSettings,
|
|
249
|
+
listSharedLinks,
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=dropbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropbox.js","sourceRoot":"","sources":["../../src/dropbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAA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ACD,KAAK,EAAE;YACL,UAAU;YACV,kBAAkB;YAClB,WAAW;YACX,cAAc;YACd,QAAQ;YACR,MAAM;YACN,MAAM;YACN,MAAM;YACN,QAAQ;SACT;QACD,OAAO,EAAE;YACP,4BAA4B;YAC5B,eAAe;SAChB;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/example.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,QAAA,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAM,CAAC;AAErD,eAAe,QAAQ,CAAC;AAOxB,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CA6ChD"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Auto-generated by `pnpm run gen:examples` — do not edit by hand.
|
|
2
|
+
// Source: tests/recordings/<provider>_*/<test>_*/recording.har
|
|
3
|
+
//
|
|
4
|
+
// Each entry is the green-path payload for one endpoint, mined from a real
|
|
5
|
+
// integration-test recording. `attachExamples` walks the provider tree and
|
|
6
|
+
// hangs the matching entry off each endpoint function as `.example`.
|
|
7
|
+
const EXAMPLES = {};
|
|
8
|
+
export default EXAMPLES;
|
|
9
|
+
// Walks each "<METHOD> <dotPath>" key onto the provider's tree. Tries the
|
|
10
|
+
// standard `provider.<method>.<dotPath>` shape first, then a few fallbacks
|
|
11
|
+
// to cover providers with non-standard layouts (fal's `.run.` namespace,
|
|
12
|
+
// kie's sub-providers, `free`'s flat root). Returns the same provider for
|
|
13
|
+
// drop-in use as `return attachExamples({ ... });`.
|
|
14
|
+
export function attachExamples(provider) {
|
|
15
|
+
const root = provider;
|
|
16
|
+
const HTTP_KEYS = new Set(["post", "get", "put", "delete", "patch", "head"]);
|
|
17
|
+
for (const [key, example] of Object.entries(EXAMPLES)) {
|
|
18
|
+
const sp = key.indexOf(" ");
|
|
19
|
+
if (sp < 0)
|
|
20
|
+
continue;
|
|
21
|
+
const method = key.slice(0, sp).toLowerCase();
|
|
22
|
+
const segs = key.slice(sp + 1).split(".");
|
|
23
|
+
const candidates = [
|
|
24
|
+
root[method],
|
|
25
|
+
root[method]?.run,
|
|
26
|
+
root,
|
|
27
|
+
];
|
|
28
|
+
if (segs.length > 1) {
|
|
29
|
+
const sub = root[segs[0]];
|
|
30
|
+
if (sub && typeof sub === "object") {
|
|
31
|
+
const subMethod = sub[method];
|
|
32
|
+
if (subMethod)
|
|
33
|
+
candidates.push({ __nested: subMethod, __segs: segs.slice(1) });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
let attached = false;
|
|
37
|
+
for (const c of candidates) {
|
|
38
|
+
const fn = walkToFn(c, segs);
|
|
39
|
+
if (fn) {
|
|
40
|
+
Object.assign(fn, { example });
|
|
41
|
+
attached = true;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (attached)
|
|
46
|
+
continue;
|
|
47
|
+
for (const k of Object.keys(root)) {
|
|
48
|
+
if (HTTP_KEYS.has(k))
|
|
49
|
+
continue;
|
|
50
|
+
if (!segs.includes(k))
|
|
51
|
+
continue;
|
|
52
|
+
const sub = root[k];
|
|
53
|
+
if (!sub || typeof sub !== "object")
|
|
54
|
+
continue;
|
|
55
|
+
const subMethod = sub[method];
|
|
56
|
+
if (!subMethod)
|
|
57
|
+
continue;
|
|
58
|
+
const fn = walkToFn(subMethod, segs);
|
|
59
|
+
if (fn) {
|
|
60
|
+
Object.assign(fn, { example });
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return provider;
|
|
66
|
+
}
|
|
67
|
+
function walkToFn(start, segs) {
|
|
68
|
+
if (start && typeof start === "object" && "__nested" in start) {
|
|
69
|
+
const wrapper = start;
|
|
70
|
+
return walkToFn(wrapper.__nested, wrapper.__segs);
|
|
71
|
+
}
|
|
72
|
+
let cur = start;
|
|
73
|
+
for (const seg of segs) {
|
|
74
|
+
if (cur === null || cur === undefined)
|
|
75
|
+
return null;
|
|
76
|
+
const t = typeof cur;
|
|
77
|
+
if (t !== "object" && t !== "function")
|
|
78
|
+
return null;
|
|
79
|
+
cur = cur[seg];
|
|
80
|
+
}
|
|
81
|
+
return typeof cur === "function"
|
|
82
|
+
? cur
|
|
83
|
+
: null;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","sourceRoot":"","sources":["../../src/example.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,+DAA+D;AAC/D,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,qEAAqE;AAOrE,MAAM,QAAQ,GAAoC,EAAE,CAAC;AAErD,eAAe,QAAQ,CAAC;AAExB,0EAA0E;AAC1E,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,oDAAoD;AACpD,MAAM,UAAU,cAAc,CAAI,QAAW;IAC3C,MAAM,IAAI,GAAG,QAAmC,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7E,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtD,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,EAAE,GAAG,CAAC;YAAE,SAAS;QACrB,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,GAA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3
|
+
export type { DropboxDeletedMetadata, DropboxFileMetadata, DropboxFilesCreateFolderV2Request, DropboxFilesCreateFolderV2Response, DropboxFilesDeleteV2Request, DropboxFilesDeleteV2Response, DropboxFilesDownloadRequest, DropboxFilesDownloadResponse, DropboxFilesGetMetadataRequest, DropboxFilesListFolderContinueRequest, DropboxFilesListFolderRequest, DropboxFilesListFolderResponse, DropboxFilesNamespace, DropboxFilesRelocationRequest, DropboxFilesRelocationResponse, DropboxFilesUploadRequest, DropboxFolderMetadata, DropboxMetadata, DropboxMetadataBase, DropboxMethod, DropboxName, DropboxNoRequestMethod, DropboxOptionalMethod, DropboxOptions, DropboxProvider, DropboxRequestedVisibility, DropboxSharingCreateSharedLinkWithSettingsRequest, DropboxSharingListSharedLinksRequest, DropboxSharingListSharedLinksResponse, DropboxSharingNamespace, DropboxSharingSharedLinkMetadata, DropboxSharingSharedLinkSettings, DropboxSharedLink, DropboxTagged, DropboxUsersGetCurrentAccountResponse, DropboxUsersNamespace, DropboxWriteMode, } from "./types.js";
|
|
4
|
+
export { DropboxBodyInitSchema, DropboxDeletedMetadataSchema, DropboxFileMetadataSchema, DropboxFilesCreateFolderV2RequestSchema, DropboxFilesCreateFolderV2ResponseSchema, DropboxFilesDeleteV2RequestSchema, DropboxFilesDeleteV2ResponseSchema, DropboxFilesDownloadRequestSchema, DropboxFilesDownloadResponseSchema, DropboxFilesGetMetadataRequestSchema, DropboxFilesListFolderContinueRequestSchema, DropboxFilesListFolderRequestSchema, DropboxFilesListFolderResponseSchema, DropboxFilesRelocationRequestSchema, DropboxFilesRelocationResponseSchema, DropboxFilesUploadRequestSchema, DropboxFolderMetadataSchema, DropboxMetadataSchema, DropboxNameSchema, DropboxOptionsSchema, DropboxRequestedVisibilitySchema, DropboxSharedLinkSchema, DropboxSharingCreateSharedLinkWithSettingsRequestSchema, DropboxSharingListSharedLinksRequestSchema, DropboxSharingListSharedLinksResponseSchema, DropboxSharingSharedLinkMetadataSchema, DropboxSharingSharedLinkSettingsSchema, DropboxTaggedSchema, DropboxUsersGetCurrentAccountResponseSchema, DropboxWriteModeSchema, } from "./zod.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,iCAAiC,EACjC,kCAAkC,EAClC,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,EAC3B,4BAA4B,EAC5B,8BAA8B,EAC9B,qCAAqC,EACrC,6BAA6B,EAC7B,8BAA8B,EAC9B,qBAAqB,EACrB,6BAA6B,EAC7B,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,0BAA0B,EAC1B,iDAAiD,EACjD,oCAAoC,EACpC,qCAAqC,EACrC,uBAAuB,EACvB,gCAAgC,EAChC,gCAAgC,EAChC,iBAAiB,EACjB,aAAa,EACb,qCAAqC,EACrC,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,yBAAyB,EACzB,uCAAuC,EACvC,wCAAwC,EACxC,iCAAiC,EACjC,kCAAkC,EAClC,iCAAiC,EACjC,kCAAkC,EAClC,oCAAoC,EACpC,2CAA2C,EAC3C,mCAAmC,EACnC,oCAAoC,EACpC,mCAAmC,EACnC,oCAAoC,EACpC,+BAA+B,EAC/B,2BAA2B,EAC3B,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,gCAAgC,EAChC,uBAAuB,EACvB,uDAAuD,EACvD,0CAA0C,EAC1C,2CAA2C,EAC3C,sCAAsC,EACtC,sCAAsC,EACtC,mBAAmB,EACnB,2CAA2C,EAC3C,sBAAsB,GACvB,MAAM,OAAO,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createDropbox } from "./dropbox.js";
|
|
2
|
+
export { DropboxError } from "./types.js";
|
|
3
|
+
export { DropboxBodyInitSchema, DropboxDeletedMetadataSchema, DropboxFileMetadataSchema, DropboxFilesCreateFolderV2RequestSchema, DropboxFilesCreateFolderV2ResponseSchema, DropboxFilesDeleteV2RequestSchema, DropboxFilesDeleteV2ResponseSchema, DropboxFilesDownloadRequestSchema, DropboxFilesDownloadResponseSchema, DropboxFilesGetMetadataRequestSchema, DropboxFilesListFolderContinueRequestSchema, DropboxFilesListFolderRequestSchema, DropboxFilesListFolderResponseSchema, DropboxFilesRelocationRequestSchema, DropboxFilesRelocationResponseSchema, DropboxFilesUploadRequestSchema, DropboxFolderMetadataSchema, DropboxMetadataSchema, DropboxNameSchema, DropboxOptionsSchema, DropboxRequestedVisibilitySchema, DropboxSharedLinkSchema, DropboxSharingCreateSharedLinkWithSettingsRequestSchema, DropboxSharingListSharedLinksRequestSchema, DropboxSharingListSharedLinksResponseSchema, DropboxSharingSharedLinkMetadataSchema, DropboxSharingSharedLinkSettingsSchema, DropboxTaggedSchema, DropboxUsersGetCurrentAccountResponseSchema, DropboxWriteModeSchema, } from "./zod.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AA0CvC,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,yBAAyB,EACzB,uCAAuC,EACvC,wCAAwC,EACxC,iCAAiC,EACjC,kCAAkC,EAClC,iCAAiC,EACjC,kCAAkC,EAClC,oCAAoC,EACpC,2CAA2C,EAC3C,mCAAmC,EACnC,oCAAoC,EACpC,mCAAmC,EACnC,oCAAoC,EACpC,+BAA+B,EAC/B,2BAA2B,EAC3B,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,gCAAgC,EAChC,uBAAuB,EACvB,uDAAuD,EACvD,0CAA0C,EAC1C,2CAA2C,EAC3C,sCAAsC,EACtC,sCAAsC,EACtC,mBAAmB,EACnB,2CAA2C,EAC3C,sBAAsB,GACvB,MAAM,OAAO,CAAC"}
|