@deeptable/deeptable 0.1.0-alpha.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.
- package/CHANGELOG.md +16 -0
- package/LICENSE +7 -0
- package/README.md +430 -0
- package/api-promise.d.mts +2 -0
- package/api-promise.d.mts.map +1 -0
- package/api-promise.d.ts +2 -0
- package/api-promise.d.ts.map +1 -0
- package/api-promise.js +6 -0
- package/api-promise.js.map +1 -0
- package/api-promise.mjs +2 -0
- package/api-promise.mjs.map +1 -0
- package/client.d.mts +189 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +189 -0
- package/client.d.ts.map +1 -0
- package/client.js +472 -0
- package/client.js.map +1 -0
- package/client.mjs +468 -0
- package/client.mjs.map +1 -0
- package/core/api-promise.d.mts +46 -0
- package/core/api-promise.d.mts.map +1 -0
- package/core/api-promise.d.ts +46 -0
- package/core/api-promise.d.ts.map +1 -0
- package/core/api-promise.js +74 -0
- package/core/api-promise.js.map +1 -0
- package/core/api-promise.mjs +70 -0
- package/core/api-promise.mjs.map +1 -0
- package/core/error.d.mts +46 -0
- package/core/error.d.mts.map +1 -0
- package/core/error.d.ts +46 -0
- package/core/error.d.ts.map +1 -0
- package/core/error.js +113 -0
- package/core/error.js.map +1 -0
- package/core/error.mjs +97 -0
- package/core/error.mjs.map +1 -0
- package/core/pagination.d.mts +54 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +54 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +101 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +95 -0
- package/core/pagination.mjs.map +1 -0
- package/core/resource.d.mts +6 -0
- package/core/resource.d.mts.map +1 -0
- package/core/resource.d.ts +6 -0
- package/core/resource.d.ts.map +1 -0
- package/core/resource.js +11 -0
- package/core/resource.js.map +1 -0
- package/core/resource.mjs +7 -0
- package/core/resource.mjs.map +1 -0
- package/core/uploads.d.mts +3 -0
- package/core/uploads.d.mts.map +1 -0
- package/core/uploads.d.ts +3 -0
- package/core/uploads.d.ts.map +1 -0
- package/core/uploads.js +6 -0
- package/core/uploads.js.map +1 -0
- package/core/uploads.mjs +2 -0
- package/core/uploads.mjs.map +1 -0
- package/error.d.mts +2 -0
- package/error.d.mts.map +1 -0
- package/error.d.ts +2 -0
- package/error.d.ts.map +1 -0
- package/error.js +6 -0
- package/error.js.map +1 -0
- package/error.mjs +2 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +7 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +7 -0
- package/index.d.ts.map +1 -0
- package/index.js +32 -0
- package/index.js.map +1 -0
- package/index.mjs +8 -0
- package/index.mjs.map +1 -0
- package/internal/builtin-types.d.mts +73 -0
- package/internal/builtin-types.d.mts.map +1 -0
- package/internal/builtin-types.d.ts +73 -0
- package/internal/builtin-types.d.ts.map +1 -0
- package/internal/builtin-types.js +4 -0
- package/internal/builtin-types.js.map +1 -0
- package/internal/builtin-types.mjs +3 -0
- package/internal/builtin-types.mjs.map +1 -0
- package/internal/detect-platform.d.mts +15 -0
- package/internal/detect-platform.d.mts.map +1 -0
- package/internal/detect-platform.d.ts +15 -0
- package/internal/detect-platform.d.ts.map +1 -0
- package/internal/detect-platform.js +162 -0
- package/internal/detect-platform.js.map +1 -0
- package/internal/detect-platform.mjs +157 -0
- package/internal/detect-platform.mjs.map +1 -0
- package/internal/errors.d.mts +3 -0
- package/internal/errors.d.mts.map +1 -0
- package/internal/errors.d.ts +3 -0
- package/internal/errors.d.ts.map +1 -0
- package/internal/errors.js +41 -0
- package/internal/errors.js.map +1 -0
- package/internal/errors.mjs +36 -0
- package/internal/errors.mjs.map +1 -0
- package/internal/headers.d.mts +20 -0
- package/internal/headers.d.mts.map +1 -0
- package/internal/headers.d.ts +20 -0
- package/internal/headers.d.ts.map +1 -0
- package/internal/headers.js +79 -0
- package/internal/headers.js.map +1 -0
- package/internal/headers.mjs +74 -0
- package/internal/headers.mjs.map +1 -0
- package/internal/parse.d.mts +12 -0
- package/internal/parse.d.mts.map +1 -0
- package/internal/parse.d.ts +12 -0
- package/internal/parse.d.ts.map +1 -0
- package/internal/parse.js +35 -0
- package/internal/parse.js.map +1 -0
- package/internal/parse.mjs +32 -0
- package/internal/parse.mjs.map +1 -0
- package/internal/request-options.d.mts +75 -0
- package/internal/request-options.d.mts.map +1 -0
- package/internal/request-options.d.ts +75 -0
- package/internal/request-options.d.ts.map +1 -0
- package/internal/request-options.js +14 -0
- package/internal/request-options.js.map +1 -0
- package/internal/request-options.mjs +10 -0
- package/internal/request-options.mjs.map +1 -0
- package/internal/shim-types.d.mts +17 -0
- package/internal/shim-types.d.mts.map +1 -0
- package/internal/shim-types.d.ts +17 -0
- package/internal/shim-types.d.ts.map +1 -0
- package/internal/shim-types.js +4 -0
- package/internal/shim-types.js.map +1 -0
- package/internal/shim-types.mjs +3 -0
- package/internal/shim-types.mjs.map +1 -0
- package/internal/shims.d.mts +20 -0
- package/internal/shims.d.mts.map +1 -0
- package/internal/shims.d.ts +20 -0
- package/internal/shims.d.ts.map +1 -0
- package/internal/shims.js +92 -0
- package/internal/shims.js.map +1 -0
- package/internal/shims.mjs +85 -0
- package/internal/shims.mjs.map +1 -0
- package/internal/to-file.d.mts +45 -0
- package/internal/to-file.d.mts.map +1 -0
- package/internal/to-file.d.ts +45 -0
- package/internal/to-file.d.ts.map +1 -0
- package/internal/to-file.js +91 -0
- package/internal/to-file.js.map +1 -0
- package/internal/to-file.mjs +88 -0
- package/internal/to-file.mjs.map +1 -0
- package/internal/tslib.js +81 -0
- package/internal/tslib.mjs +17 -0
- package/internal/types.d.mts +69 -0
- package/internal/types.d.mts.map +1 -0
- package/internal/types.d.ts +69 -0
- package/internal/types.d.ts.map +1 -0
- package/internal/types.js +4 -0
- package/internal/types.js.map +1 -0
- package/internal/types.mjs +3 -0
- package/internal/types.mjs.map +1 -0
- package/internal/uploads.d.mts +42 -0
- package/internal/uploads.d.mts.map +1 -0
- package/internal/uploads.d.ts +42 -0
- package/internal/uploads.d.ts.map +1 -0
- package/internal/uploads.js +141 -0
- package/internal/uploads.js.map +1 -0
- package/internal/uploads.mjs +131 -0
- package/internal/uploads.mjs.map +1 -0
- package/internal/utils/base64.d.mts +3 -0
- package/internal/utils/base64.d.mts.map +1 -0
- package/internal/utils/base64.d.ts +3 -0
- package/internal/utils/base64.d.ts.map +1 -0
- package/internal/utils/base64.js +38 -0
- package/internal/utils/base64.js.map +1 -0
- package/internal/utils/base64.mjs +33 -0
- package/internal/utils/base64.mjs.map +1 -0
- package/internal/utils/bytes.d.mts +4 -0
- package/internal/utils/bytes.d.mts.map +1 -0
- package/internal/utils/bytes.d.ts +4 -0
- package/internal/utils/bytes.d.ts.map +1 -0
- package/internal/utils/bytes.js +31 -0
- package/internal/utils/bytes.js.map +1 -0
- package/internal/utils/bytes.mjs +26 -0
- package/internal/utils/bytes.mjs.map +1 -0
- package/internal/utils/env.d.mts +9 -0
- package/internal/utils/env.d.mts.map +1 -0
- package/internal/utils/env.d.ts +9 -0
- package/internal/utils/env.d.ts.map +1 -0
- package/internal/utils/env.js +22 -0
- package/internal/utils/env.js.map +1 -0
- package/internal/utils/env.mjs +18 -0
- package/internal/utils/env.mjs.map +1 -0
- package/internal/utils/log.d.mts +37 -0
- package/internal/utils/log.d.mts.map +1 -0
- package/internal/utils/log.d.ts +37 -0
- package/internal/utils/log.d.ts.map +1 -0
- package/internal/utils/log.js +85 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +79 -0
- package/internal/utils/log.mjs.map +1 -0
- package/internal/utils/path.d.mts +15 -0
- package/internal/utils/path.d.mts.map +1 -0
- package/internal/utils/path.d.ts +15 -0
- package/internal/utils/path.d.ts.map +1 -0
- package/internal/utils/path.js +79 -0
- package/internal/utils/path.js.map +1 -0
- package/internal/utils/path.mjs +74 -0
- package/internal/utils/path.mjs.map +1 -0
- package/internal/utils/sleep.d.mts +2 -0
- package/internal/utils/sleep.d.mts.map +1 -0
- package/internal/utils/sleep.d.ts +2 -0
- package/internal/utils/sleep.d.ts.map +1 -0
- package/internal/utils/sleep.js +7 -0
- package/internal/utils/sleep.js.map +1 -0
- package/internal/utils/sleep.mjs +3 -0
- package/internal/utils/sleep.mjs.map +1 -0
- package/internal/utils/uuid.d.mts +5 -0
- package/internal/utils/uuid.d.mts.map +1 -0
- package/internal/utils/uuid.d.ts +5 -0
- package/internal/utils/uuid.d.ts.map +1 -0
- package/internal/utils/uuid.js +19 -0
- package/internal/utils/uuid.js.map +1 -0
- package/internal/utils/uuid.mjs +15 -0
- package/internal/utils/uuid.mjs.map +1 -0
- package/internal/utils/values.d.mts +18 -0
- package/internal/utils/values.d.mts.map +1 -0
- package/internal/utils/values.d.ts +18 -0
- package/internal/utils/values.d.ts.map +1 -0
- package/internal/utils/values.js +112 -0
- package/internal/utils/values.js.map +1 -0
- package/internal/utils/values.mjs +94 -0
- package/internal/utils/values.mjs.map +1 -0
- package/internal/utils.d.mts +7 -0
- package/internal/utils.d.mts.map +1 -0
- package/internal/utils.d.ts +7 -0
- package/internal/utils.d.ts.map +1 -0
- package/internal/utils.js +11 -0
- package/internal/utils.js.map +1 -0
- package/internal/utils.mjs +8 -0
- package/internal/utils.mjs.map +1 -0
- package/package.json +147 -0
- package/pagination.d.mts +2 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +2 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +2 -0
- package/pagination.mjs.map +1 -0
- package/resource.d.mts +2 -0
- package/resource.d.mts.map +1 -0
- package/resource.d.ts +2 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +6 -0
- package/resource.js.map +1 -0
- package/resource.mjs +2 -0
- package/resource.mjs.map +1 -0
- package/resources/files.d.mts +102 -0
- package/resources/files.d.mts.map +1 -0
- package/resources/files.d.ts +102 -0
- package/resources/files.d.ts.map +1 -0
- package/resources/files.js +75 -0
- package/resources/files.js.map +1 -0
- package/resources/files.mjs +71 -0
- package/resources/files.mjs.map +1 -0
- package/resources/index.d.mts +3 -0
- package/resources/index.d.mts.map +1 -0
- package/resources/index.d.ts +3 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +9 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +4 -0
- package/resources/index.mjs.map +1 -0
- package/resources/structured-sheets/exports.d.mts +22 -0
- package/resources/structured-sheets/exports.d.mts.map +1 -0
- package/resources/structured-sheets/exports.d.ts +22 -0
- package/resources/structured-sheets/exports.d.ts.map +1 -0
- package/resources/structured-sheets/exports.js +33 -0
- package/resources/structured-sheets/exports.js.map +1 -0
- package/resources/structured-sheets/exports.mjs +29 -0
- package/resources/structured-sheets/exports.mjs.map +1 -0
- package/resources/structured-sheets/index.d.mts +3 -0
- package/resources/structured-sheets/index.d.mts.map +1 -0
- package/resources/structured-sheets/index.d.ts +3 -0
- package/resources/structured-sheets/index.d.ts.map +1 -0
- package/resources/structured-sheets/index.js +9 -0
- package/resources/structured-sheets/index.js.map +1 -0
- package/resources/structured-sheets/index.mjs +4 -0
- package/resources/structured-sheets/index.mjs.map +1 -0
- package/resources/structured-sheets/structured-sheets.d.mts +136 -0
- package/resources/structured-sheets/structured-sheets.d.mts.map +1 -0
- package/resources/structured-sheets/structured-sheets.d.ts +136 -0
- package/resources/structured-sheets/structured-sheets.d.ts.map +1 -0
- package/resources/structured-sheets/structured-sheets.js +85 -0
- package/resources/structured-sheets/structured-sheets.js.map +1 -0
- package/resources/structured-sheets/structured-sheets.mjs +80 -0
- package/resources/structured-sheets/structured-sheets.mjs.map +1 -0
- package/resources/structured-sheets.d.mts +2 -0
- package/resources/structured-sheets.d.mts.map +1 -0
- package/resources/structured-sheets.d.ts +2 -0
- package/resources/structured-sheets.d.ts.map +1 -0
- package/resources/structured-sheets.js +6 -0
- package/resources/structured-sheets.js.map +1 -0
- package/resources/structured-sheets.mjs +3 -0
- package/resources/structured-sheets.mjs.map +1 -0
- package/resources.d.mts +2 -0
- package/resources.d.mts.map +1 -0
- package/resources.d.ts +2 -0
- package/resources.d.ts.map +1 -0
- package/resources.js +5 -0
- package/resources.js.map +1 -0
- package/resources.mjs +2 -0
- package/resources.mjs.map +1 -0
- package/src/api-promise.ts +2 -0
- package/src/client.ts +773 -0
- package/src/core/README.md +3 -0
- package/src/core/api-promise.ts +92 -0
- package/src/core/error.ts +130 -0
- package/src/core/pagination.ts +156 -0
- package/src/core/resource.ts +11 -0
- package/src/core/uploads.ts +2 -0
- package/src/error.ts +2 -0
- package/src/index.ts +23 -0
- package/src/internal/README.md +3 -0
- package/src/internal/builtin-types.ts +93 -0
- package/src/internal/detect-platform.ts +196 -0
- package/src/internal/errors.ts +33 -0
- package/src/internal/headers.ts +97 -0
- package/src/internal/parse.ts +50 -0
- package/src/internal/request-options.ts +91 -0
- package/src/internal/shim-types.ts +26 -0
- package/src/internal/shims.ts +107 -0
- package/src/internal/to-file.ts +154 -0
- package/src/internal/types.ts +95 -0
- package/src/internal/uploads.ts +187 -0
- package/src/internal/utils/base64.ts +40 -0
- package/src/internal/utils/bytes.ts +32 -0
- package/src/internal/utils/env.ts +18 -0
- package/src/internal/utils/log.ts +126 -0
- package/src/internal/utils/path.ts +88 -0
- package/src/internal/utils/sleep.ts +3 -0
- package/src/internal/utils/uuid.ts +17 -0
- package/src/internal/utils/values.ts +105 -0
- package/src/internal/utils.ts +8 -0
- package/src/lib/.keep +4 -0
- package/src/pagination.ts +2 -0
- package/src/resource.ts +2 -0
- package/src/resources/files.ts +138 -0
- package/src/resources/index.ts +16 -0
- package/src/resources/structured-sheets/exports.ts +32 -0
- package/src/resources/structured-sheets/index.ts +10 -0
- package/src/resources/structured-sheets/structured-sheets.ts +184 -0
- package/src/resources/structured-sheets.ts +3 -0
- package/src/resources.ts +1 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +2 -0
- package/src/version.ts +1 -0
- package/uploads.d.mts +2 -0
- package/uploads.d.mts.map +1 -0
- package/uploads.d.ts +2 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +6 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +2 -0
- package/uploads.mjs.map +1 -0
- package/version.d.mts +2 -0
- package/version.d.mts.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0-alpha.1 (2026-01-23)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.0.1...v0.1.0-alpha.1](https://github.com/deeptable-com/deeptable-typescript/compare/v0.0.1...v0.1.0-alpha.1)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** change casing for DeepTable class ([7b707a0](https://github.com/deeptable-com/deeptable-typescript/commit/7b707a0f3bffa65282fa952416174f6736826e4f))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Chores
|
|
13
|
+
|
|
14
|
+
* configure new SDK language ([b2904f1](https://github.com/deeptable-com/deeptable-typescript/commit/b2904f1c9a84ea840cadb7e187be58b18bdc347a))
|
|
15
|
+
* update SDK settings ([427a5c6](https://github.com/deeptable-com/deeptable-typescript/commit/427a5c6156151c393c9332a2db7f34a68005ae29))
|
|
16
|
+
* update SDK settings ([40caac4](https://github.com/deeptable-com/deeptable-typescript/commit/40caac4eef86f2a367564f9085d89770e8ab7040))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2026 deeptable
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
# DeepTable TypeScript API Library
|
|
2
|
+
|
|
3
|
+
[>)](https://npmjs.org/package/@deeptable/deeptable) 
|
|
4
|
+
|
|
5
|
+
This library provides convenient access to the DeepTable REST API from server-side TypeScript or JavaScript.
|
|
6
|
+
|
|
7
|
+
The REST API documentation can be found on [docs.deeptable.com](https://docs.deeptable.com). The full API of this library can be found in [api.md](api.md).
|
|
8
|
+
|
|
9
|
+
It is generated with [Stainless](https://www.stainless.com/).
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @deeptable/deeptable
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
The full API of this library can be found in [api.md](api.md).
|
|
20
|
+
|
|
21
|
+
<!-- prettier-ignore -->
|
|
22
|
+
```js
|
|
23
|
+
import DeepTable from '@deeptable/deeptable';
|
|
24
|
+
|
|
25
|
+
const client = new DeepTable({
|
|
26
|
+
apiKey: process.env['DEEPTABLE_API_KEY'], // This is the default and can be omitted
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const structuredSheetResponse = await client.structuredSheets.create({
|
|
30
|
+
file_id: 'file_01h45ytscbebyvny4gc8cr8ma2',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
console.log(structuredSheetResponse.id);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Request & Response types
|
|
37
|
+
|
|
38
|
+
This library includes TypeScript definitions for all request params and response fields. You may import and use them like so:
|
|
39
|
+
|
|
40
|
+
<!-- prettier-ignore -->
|
|
41
|
+
```ts
|
|
42
|
+
import DeepTable from '@deeptable/deeptable';
|
|
43
|
+
|
|
44
|
+
const client = new DeepTable({
|
|
45
|
+
apiKey: process.env['DEEPTABLE_API_KEY'], // This is the default and can be omitted
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const params: DeepTable.StructuredSheetCreateParams = {
|
|
49
|
+
file_id: 'file_01h45ytscbebyvny4gc8cr8ma2',
|
|
50
|
+
};
|
|
51
|
+
const structuredSheetResponse: DeepTable.StructuredSheetResponse =
|
|
52
|
+
await client.structuredSheets.create(params);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
|
|
56
|
+
|
|
57
|
+
## File uploads
|
|
58
|
+
|
|
59
|
+
Request parameters that correspond to file uploads can be passed in many different forms:
|
|
60
|
+
|
|
61
|
+
- `File` (or an object with the same structure)
|
|
62
|
+
- a `fetch` `Response` (or an object with the same structure)
|
|
63
|
+
- an `fs.ReadStream`
|
|
64
|
+
- the return value of our `toFile` helper
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import fs from 'fs';
|
|
68
|
+
import DeepTable, { toFile } from '@deeptable/deeptable';
|
|
69
|
+
|
|
70
|
+
const client = new DeepTable();
|
|
71
|
+
|
|
72
|
+
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
|
|
73
|
+
await client.files.upload({ file: fs.createReadStream('/path/to/file') });
|
|
74
|
+
|
|
75
|
+
// Or if you have the web `File` API you can pass a `File` instance:
|
|
76
|
+
await client.files.upload({ file: new File(['my bytes'], 'file') });
|
|
77
|
+
|
|
78
|
+
// You can also pass a `fetch` `Response`:
|
|
79
|
+
await client.files.upload({ file: await fetch('https://somesite/file') });
|
|
80
|
+
|
|
81
|
+
// Finally, if none of the above are convenient, you can use our `toFile` helper:
|
|
82
|
+
await client.files.upload({ file: await toFile(Buffer.from('my bytes'), 'file') });
|
|
83
|
+
await client.files.upload({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') });
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Handling errors
|
|
87
|
+
|
|
88
|
+
When the library is unable to connect to the API,
|
|
89
|
+
or if the API returns a non-success status code (i.e., 4xx or 5xx response),
|
|
90
|
+
a subclass of `APIError` will be thrown:
|
|
91
|
+
|
|
92
|
+
<!-- prettier-ignore -->
|
|
93
|
+
```ts
|
|
94
|
+
const structuredSheetResponse = await client.structuredSheets
|
|
95
|
+
.create({ file_id: 'file_01h45ytscbebyvny4gc8cr8ma2' })
|
|
96
|
+
.catch(async (err) => {
|
|
97
|
+
if (err instanceof DeepTable.APIError) {
|
|
98
|
+
console.log(err.status); // 400
|
|
99
|
+
console.log(err.name); // BadRequestError
|
|
100
|
+
console.log(err.headers); // {server: 'nginx', ...}
|
|
101
|
+
} else {
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Error codes are as follows:
|
|
108
|
+
|
|
109
|
+
| Status Code | Error Type |
|
|
110
|
+
| ----------- | -------------------------- |
|
|
111
|
+
| 400 | `BadRequestError` |
|
|
112
|
+
| 401 | `AuthenticationError` |
|
|
113
|
+
| 403 | `PermissionDeniedError` |
|
|
114
|
+
| 404 | `NotFoundError` |
|
|
115
|
+
| 422 | `UnprocessableEntityError` |
|
|
116
|
+
| 429 | `RateLimitError` |
|
|
117
|
+
| >=500 | `InternalServerError` |
|
|
118
|
+
| N/A | `APIConnectionError` |
|
|
119
|
+
|
|
120
|
+
### Retries
|
|
121
|
+
|
|
122
|
+
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
|
|
123
|
+
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
|
|
124
|
+
429 Rate Limit, and >=500 Internal errors will all be retried by default.
|
|
125
|
+
|
|
126
|
+
You can use the `maxRetries` option to configure or disable this:
|
|
127
|
+
|
|
128
|
+
<!-- prettier-ignore -->
|
|
129
|
+
```js
|
|
130
|
+
// Configure the default for all requests:
|
|
131
|
+
const client = new DeepTable({
|
|
132
|
+
maxRetries: 0, // default is 2
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Or, configure per-request:
|
|
136
|
+
await client.structuredSheets.create({ file_id: 'file_01h45ytscbebyvny4gc8cr8ma2' }, {
|
|
137
|
+
maxRetries: 5,
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Timeouts
|
|
142
|
+
|
|
143
|
+
Requests time out after 1 minute by default. You can configure this with a `timeout` option:
|
|
144
|
+
|
|
145
|
+
<!-- prettier-ignore -->
|
|
146
|
+
```ts
|
|
147
|
+
// Configure the default for all requests:
|
|
148
|
+
const client = new DeepTable({
|
|
149
|
+
timeout: 20 * 1000, // 20 seconds (default is 1 minute)
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// Override per-request:
|
|
153
|
+
await client.structuredSheets.create({ file_id: 'file_01h45ytscbebyvny4gc8cr8ma2' }, {
|
|
154
|
+
timeout: 5 * 1000,
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
On timeout, an `APIConnectionTimeoutError` is thrown.
|
|
159
|
+
|
|
160
|
+
Note that requests which time out will be [retried twice by default](#retries).
|
|
161
|
+
|
|
162
|
+
## Auto-pagination
|
|
163
|
+
|
|
164
|
+
List methods in the DeepTable API are paginated.
|
|
165
|
+
You can use the `for await … of` syntax to iterate through items across all pages:
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
async function fetchAllFiles(params) {
|
|
169
|
+
const allFiles = [];
|
|
170
|
+
// Automatically fetches more pages as needed.
|
|
171
|
+
for await (const file of client.files.list()) {
|
|
172
|
+
allFiles.push(file);
|
|
173
|
+
}
|
|
174
|
+
return allFiles;
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Alternatively, you can request a single page at a time:
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
let page = await client.files.list();
|
|
182
|
+
for (const file of page.data) {
|
|
183
|
+
console.log(file);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Convenience methods are provided for manually paginating:
|
|
187
|
+
while (page.hasNextPage()) {
|
|
188
|
+
page = await page.getNextPage();
|
|
189
|
+
// ...
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Advanced Usage
|
|
194
|
+
|
|
195
|
+
### Accessing raw Response data (e.g., headers)
|
|
196
|
+
|
|
197
|
+
The "raw" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.
|
|
198
|
+
This method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.
|
|
199
|
+
|
|
200
|
+
You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.
|
|
201
|
+
Unlike `.asResponse()` this method consumes the body, returning once it is parsed.
|
|
202
|
+
|
|
203
|
+
<!-- prettier-ignore -->
|
|
204
|
+
```ts
|
|
205
|
+
const client = new DeepTable();
|
|
206
|
+
|
|
207
|
+
const response = await client.structuredSheets
|
|
208
|
+
.create({ file_id: 'file_01h45ytscbebyvny4gc8cr8ma2' })
|
|
209
|
+
.asResponse();
|
|
210
|
+
console.log(response.headers.get('X-My-Header'));
|
|
211
|
+
console.log(response.statusText); // access the underlying Response object
|
|
212
|
+
|
|
213
|
+
const { data: structuredSheetResponse, response: raw } = await client.structuredSheets
|
|
214
|
+
.create({ file_id: 'file_01h45ytscbebyvny4gc8cr8ma2' })
|
|
215
|
+
.withResponse();
|
|
216
|
+
console.log(raw.headers.get('X-My-Header'));
|
|
217
|
+
console.log(structuredSheetResponse.id);
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Logging
|
|
221
|
+
|
|
222
|
+
> [!IMPORTANT]
|
|
223
|
+
> All log messages are intended for debugging only. The format and content of log messages
|
|
224
|
+
> may change between releases.
|
|
225
|
+
|
|
226
|
+
#### Log levels
|
|
227
|
+
|
|
228
|
+
The log level can be configured in two ways:
|
|
229
|
+
|
|
230
|
+
1. Via the `DEEPTABLE_LOG` environment variable
|
|
231
|
+
2. Using the `logLevel` client option (overrides the environment variable if set)
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
import DeepTable from '@deeptable/deeptable';
|
|
235
|
+
|
|
236
|
+
const client = new DeepTable({
|
|
237
|
+
logLevel: 'debug', // Show all log messages
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Available log levels, from most to least verbose:
|
|
242
|
+
|
|
243
|
+
- `'debug'` - Show debug messages, info, warnings, and errors
|
|
244
|
+
- `'info'` - Show info messages, warnings, and errors
|
|
245
|
+
- `'warn'` - Show warnings and errors (default)
|
|
246
|
+
- `'error'` - Show only errors
|
|
247
|
+
- `'off'` - Disable all logging
|
|
248
|
+
|
|
249
|
+
At the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.
|
|
250
|
+
Some authentication-related headers are redacted, but sensitive data in request and response bodies
|
|
251
|
+
may still be visible.
|
|
252
|
+
|
|
253
|
+
#### Custom logger
|
|
254
|
+
|
|
255
|
+
By default, this library logs to `globalThis.console`. You can also provide a custom logger.
|
|
256
|
+
Most logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.
|
|
257
|
+
|
|
258
|
+
When providing a custom logger, the `logLevel` option still controls which messages are emitted, messages
|
|
259
|
+
below the configured level will not be sent to your logger.
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
import DeepTable from '@deeptable/deeptable';
|
|
263
|
+
import pino from 'pino';
|
|
264
|
+
|
|
265
|
+
const logger = pino();
|
|
266
|
+
|
|
267
|
+
const client = new DeepTable({
|
|
268
|
+
logger: logger.child({ name: 'DeepTable' }),
|
|
269
|
+
logLevel: 'debug', // Send all messages to pino, allowing it to filter
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Making custom/undocumented requests
|
|
274
|
+
|
|
275
|
+
This library is typed for convenient access to the documented API. If you need to access undocumented
|
|
276
|
+
endpoints, params, or response properties, the library can still be used.
|
|
277
|
+
|
|
278
|
+
#### Undocumented endpoints
|
|
279
|
+
|
|
280
|
+
To make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.
|
|
281
|
+
Options on the client, such as retries, will be respected when making these requests.
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
await client.post('/some/path', {
|
|
285
|
+
body: { some_prop: 'foo' },
|
|
286
|
+
query: { some_query_arg: 'bar' },
|
|
287
|
+
});
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
#### Undocumented request params
|
|
291
|
+
|
|
292
|
+
To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented
|
|
293
|
+
parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you
|
|
294
|
+
send will be sent as-is.
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
client.structuredSheets.create({
|
|
298
|
+
// ...
|
|
299
|
+
// @ts-expect-error baz is not yet public
|
|
300
|
+
baz: 'undocumented option',
|
|
301
|
+
});
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
For requests with the `GET` verb, any extra params will be in the query, all other requests will send the
|
|
305
|
+
extra param in the body.
|
|
306
|
+
|
|
307
|
+
If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request
|
|
308
|
+
options.
|
|
309
|
+
|
|
310
|
+
#### Undocumented response properties
|
|
311
|
+
|
|
312
|
+
To access undocumented response properties, you may access the response object with `// @ts-expect-error` on
|
|
313
|
+
the response object, or cast the response object to the requisite type. Like the request params, we do not
|
|
314
|
+
validate or strip extra properties from the response from the API.
|
|
315
|
+
|
|
316
|
+
### Customizing the fetch client
|
|
317
|
+
|
|
318
|
+
By default, this library expects a global `fetch` function is defined.
|
|
319
|
+
|
|
320
|
+
If you want to use a different `fetch` function, you can either polyfill the global:
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
import fetch from 'my-fetch';
|
|
324
|
+
|
|
325
|
+
globalThis.fetch = fetch;
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Or pass it to the client:
|
|
329
|
+
|
|
330
|
+
```ts
|
|
331
|
+
import DeepTable from '@deeptable/deeptable';
|
|
332
|
+
import fetch from 'my-fetch';
|
|
333
|
+
|
|
334
|
+
const client = new DeepTable({ fetch });
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Fetch options
|
|
338
|
+
|
|
339
|
+
If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
import DeepTable from '@deeptable/deeptable';
|
|
343
|
+
|
|
344
|
+
const client = new DeepTable({
|
|
345
|
+
fetchOptions: {
|
|
346
|
+
// `RequestInit` options
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
#### Configuring proxies
|
|
352
|
+
|
|
353
|
+
To modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy
|
|
354
|
+
options to requests:
|
|
355
|
+
|
|
356
|
+
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg" align="top" width="18" height="21"> **Node** <sup>[[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]</sup>
|
|
357
|
+
|
|
358
|
+
```ts
|
|
359
|
+
import DeepTable from '@deeptable/deeptable';
|
|
360
|
+
import * as undici from 'undici';
|
|
361
|
+
|
|
362
|
+
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
|
|
363
|
+
const client = new DeepTable({
|
|
364
|
+
fetchOptions: {
|
|
365
|
+
dispatcher: proxyAgent,
|
|
366
|
+
},
|
|
367
|
+
});
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg" align="top" width="18" height="21"> **Bun** <sup>[[docs](https://bun.sh/guides/http/proxy)]</sup>
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
import DeepTable from '@deeptable/deeptable';
|
|
374
|
+
|
|
375
|
+
const client = new DeepTable({
|
|
376
|
+
fetchOptions: {
|
|
377
|
+
proxy: 'http://localhost:8888',
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg" align="top" width="18" height="21"> **Deno** <sup>[[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]</sup>
|
|
383
|
+
|
|
384
|
+
```ts
|
|
385
|
+
import DeepTable from 'npm:@deeptable/deeptable';
|
|
386
|
+
|
|
387
|
+
const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
|
|
388
|
+
const client = new DeepTable({
|
|
389
|
+
fetchOptions: {
|
|
390
|
+
client: httpClient,
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
## Frequently Asked Questions
|
|
396
|
+
|
|
397
|
+
## Semantic versioning
|
|
398
|
+
|
|
399
|
+
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
|
400
|
+
|
|
401
|
+
1. Changes that only affect static types, without breaking runtime behavior.
|
|
402
|
+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
|
403
|
+
3. Changes that we do not expect to impact the vast majority of users in practice.
|
|
404
|
+
|
|
405
|
+
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
406
|
+
|
|
407
|
+
We are keen for your feedback; please open an [issue](https://www.github.com/deeptable-com/deeptable-typescript/issues) with questions, bugs, or suggestions.
|
|
408
|
+
|
|
409
|
+
## Requirements
|
|
410
|
+
|
|
411
|
+
TypeScript >= 4.9 is supported.
|
|
412
|
+
|
|
413
|
+
The following runtimes are supported:
|
|
414
|
+
|
|
415
|
+
- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
|
|
416
|
+
- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
|
|
417
|
+
- Deno v1.28.0 or higher.
|
|
418
|
+
- Bun 1.0 or later.
|
|
419
|
+
- Cloudflare Workers.
|
|
420
|
+
- Vercel Edge Runtime.
|
|
421
|
+
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
|
|
422
|
+
- Nitro v2.6 or greater.
|
|
423
|
+
|
|
424
|
+
Note that React Native is not supported at this time.
|
|
425
|
+
|
|
426
|
+
If you are interested in other runtime environments, please open or upvote an issue on GitHub.
|
|
427
|
+
|
|
428
|
+
## Contributing
|
|
429
|
+
|
|
430
|
+
See [the contributing documentation](./CONTRIBUTING.md).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-promise.d.mts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
|
package/api-promise.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-promise.d.ts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
|
package/api-promise.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("./internal/tslib.js");
|
|
4
|
+
/** @deprecated Import from ./core/api-promise instead */
|
|
5
|
+
tslib_1.__exportStar(require("./core/api-promise.js"), exports);
|
|
6
|
+
//# sourceMappingURL=api-promise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-promise.js","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,gEAAmC"}
|
package/api-promise.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-promise.mjs","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
|
package/client.d.mts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { RequestInit, RequestInfo } from "./internal/builtin-types.mjs";
|
|
2
|
+
import type { PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from "./internal/types.mjs";
|
|
3
|
+
export type { Logger, LogLevel } from "./internal/utils/log.mjs";
|
|
4
|
+
import * as Opts from "./internal/request-options.mjs";
|
|
5
|
+
import * as Errors from "./core/error.mjs";
|
|
6
|
+
import * as Pagination from "./core/pagination.mjs";
|
|
7
|
+
import { type CursorIDPageParams, CursorIDPageResponse } from "./core/pagination.mjs";
|
|
8
|
+
import * as Uploads from "./core/uploads.mjs";
|
|
9
|
+
import * as API from "./resources/index.mjs";
|
|
10
|
+
import { APIPromise } from "./core/api-promise.mjs";
|
|
11
|
+
import { File, FileListParams, FileUploadParams, Files, FilesCursorIDPage } from "./resources/files.mjs";
|
|
12
|
+
import { StructuredSheetCreateParams, StructuredSheetListParams, StructuredSheetResponse, StructuredSheetResponsesCursorIDPage, StructuredSheets } from "./resources/structured-sheets/structured-sheets.mjs";
|
|
13
|
+
import { type Fetch } from "./internal/builtin-types.mjs";
|
|
14
|
+
import { HeadersLike, NullableHeaders } from "./internal/headers.mjs";
|
|
15
|
+
import { FinalRequestOptions, RequestOptions } from "./internal/request-options.mjs";
|
|
16
|
+
import { type LogLevel, type Logger } from "./internal/utils/log.mjs";
|
|
17
|
+
export interface ClientOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Defaults to process.env['DEEPTABLE_API_KEY'].
|
|
20
|
+
*/
|
|
21
|
+
apiKey?: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
24
|
+
*
|
|
25
|
+
* Defaults to process.env['DEEPTABLE_BASE_URL'].
|
|
26
|
+
*/
|
|
27
|
+
baseURL?: string | null | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
30
|
+
* from the server before timing out a single request.
|
|
31
|
+
*
|
|
32
|
+
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
33
|
+
* much longer than this timeout before the promise succeeds or fails.
|
|
34
|
+
*
|
|
35
|
+
* @unit milliseconds
|
|
36
|
+
*/
|
|
37
|
+
timeout?: number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Additional `RequestInit` options to be passed to `fetch` calls.
|
|
40
|
+
* Properties will be overridden by per-request `fetchOptions`.
|
|
41
|
+
*/
|
|
42
|
+
fetchOptions?: MergedRequestInit | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Specify a custom `fetch` function implementation.
|
|
45
|
+
*
|
|
46
|
+
* If not provided, we expect that `fetch` is defined globally.
|
|
47
|
+
*/
|
|
48
|
+
fetch?: Fetch | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* The maximum number of times that the client will retry a request in case of a
|
|
51
|
+
* temporary failure, like a network error or a 5XX error from the server.
|
|
52
|
+
*
|
|
53
|
+
* @default 2
|
|
54
|
+
*/
|
|
55
|
+
maxRetries?: number | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Default headers to include with every request to the API.
|
|
58
|
+
*
|
|
59
|
+
* These can be removed in individual requests by explicitly setting the
|
|
60
|
+
* header to `null` in request options.
|
|
61
|
+
*/
|
|
62
|
+
defaultHeaders?: HeadersLike | undefined;
|
|
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?: Record<string, string | undefined> | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Set the log level.
|
|
72
|
+
*
|
|
73
|
+
* Defaults to process.env['DEEPTABLE_LOG'] or 'warn' if it isn't set.
|
|
74
|
+
*/
|
|
75
|
+
logLevel?: LogLevel | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Set the logger.
|
|
78
|
+
*
|
|
79
|
+
* Defaults to globalThis.console.
|
|
80
|
+
*/
|
|
81
|
+
logger?: Logger | undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* API Client for interfacing with the DeepTable API.
|
|
85
|
+
*/
|
|
86
|
+
export declare class DeepTable {
|
|
87
|
+
#private;
|
|
88
|
+
apiKey: string;
|
|
89
|
+
baseURL: string;
|
|
90
|
+
maxRetries: number;
|
|
91
|
+
timeout: number;
|
|
92
|
+
logger: Logger;
|
|
93
|
+
logLevel: LogLevel | undefined;
|
|
94
|
+
fetchOptions: MergedRequestInit | undefined;
|
|
95
|
+
private fetch;
|
|
96
|
+
protected idempotencyHeader?: string;
|
|
97
|
+
private _options;
|
|
98
|
+
/**
|
|
99
|
+
* API Client for interfacing with the DeepTable API.
|
|
100
|
+
*
|
|
101
|
+
* @param {string | undefined} [opts.apiKey=process.env['DEEPTABLE_API_KEY'] ?? undefined]
|
|
102
|
+
* @param {string} [opts.baseURL=process.env['DEEPTABLE_BASE_URL'] ?? https://api.deeptable.com] - Override the default base URL for the API.
|
|
103
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
104
|
+
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
105
|
+
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
106
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
107
|
+
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
108
|
+
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
109
|
+
*/
|
|
110
|
+
constructor({ baseURL, apiKey, ...opts }?: ClientOptions);
|
|
111
|
+
/**
|
|
112
|
+
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
113
|
+
*/
|
|
114
|
+
withOptions(options: Partial<ClientOptions>): this;
|
|
115
|
+
protected defaultQuery(): Record<string, string | undefined> | undefined;
|
|
116
|
+
protected validateHeaders({ values, nulls }: NullableHeaders): void;
|
|
117
|
+
protected authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined>;
|
|
118
|
+
/**
|
|
119
|
+
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
120
|
+
*/
|
|
121
|
+
protected stringifyQuery(query: Record<string, unknown>): string;
|
|
122
|
+
private getUserAgent;
|
|
123
|
+
protected defaultIdempotencyKey(): string;
|
|
124
|
+
protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError;
|
|
125
|
+
buildURL(path: string, query: Record<string, unknown> | null | undefined, defaultBaseURL?: string | undefined): string;
|
|
126
|
+
/**
|
|
127
|
+
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
128
|
+
*/
|
|
129
|
+
protected prepareOptions(options: FinalRequestOptions): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Used as a callback for mutating the given `RequestInit` object.
|
|
132
|
+
*
|
|
133
|
+
* This is useful for cases where you want to add certain headers based off of
|
|
134
|
+
* the request properties, e.g. `method` or `url`.
|
|
135
|
+
*/
|
|
136
|
+
protected prepareRequest(request: RequestInit, { url, options }: {
|
|
137
|
+
url: string;
|
|
138
|
+
options: FinalRequestOptions;
|
|
139
|
+
}): Promise<void>;
|
|
140
|
+
get<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
141
|
+
post<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
142
|
+
patch<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
143
|
+
put<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
144
|
+
delete<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
145
|
+
private methodRequest;
|
|
146
|
+
request<Rsp>(options: PromiseOrValue<FinalRequestOptions>, remainingRetries?: number | null): APIPromise<Rsp>;
|
|
147
|
+
private makeRequest;
|
|
148
|
+
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(path: string, Page: new (...args: any[]) => PageClass, opts?: RequestOptions): Pagination.PagePromise<PageClass, Item>;
|
|
149
|
+
requestAPIList<Item = unknown, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass, options: FinalRequestOptions): Pagination.PagePromise<PageClass, Item>;
|
|
150
|
+
fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
|
|
151
|
+
private shouldRetry;
|
|
152
|
+
private retryRequest;
|
|
153
|
+
private calculateDefaultRetryTimeoutMillis;
|
|
154
|
+
buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: {
|
|
155
|
+
retryCount?: number;
|
|
156
|
+
}): Promise<{
|
|
157
|
+
req: FinalizedRequestInit;
|
|
158
|
+
url: string;
|
|
159
|
+
timeout: number;
|
|
160
|
+
}>;
|
|
161
|
+
private buildHeaders;
|
|
162
|
+
private buildBody;
|
|
163
|
+
static DeepTable: typeof DeepTable;
|
|
164
|
+
static DEFAULT_TIMEOUT: number;
|
|
165
|
+
static DeepTableError: typeof Errors.DeepTableError;
|
|
166
|
+
static APIError: typeof Errors.APIError;
|
|
167
|
+
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
168
|
+
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
169
|
+
static APIUserAbortError: typeof Errors.APIUserAbortError;
|
|
170
|
+
static NotFoundError: typeof Errors.NotFoundError;
|
|
171
|
+
static ConflictError: typeof Errors.ConflictError;
|
|
172
|
+
static RateLimitError: typeof Errors.RateLimitError;
|
|
173
|
+
static BadRequestError: typeof Errors.BadRequestError;
|
|
174
|
+
static AuthenticationError: typeof Errors.AuthenticationError;
|
|
175
|
+
static InternalServerError: typeof Errors.InternalServerError;
|
|
176
|
+
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
177
|
+
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
178
|
+
static toFile: typeof Uploads.toFile;
|
|
179
|
+
files: API.Files;
|
|
180
|
+
structuredSheets: API.StructuredSheets;
|
|
181
|
+
}
|
|
182
|
+
export declare namespace DeepTable {
|
|
183
|
+
export type RequestOptions = Opts.RequestOptions;
|
|
184
|
+
export import CursorIDPage = Pagination.CursorIDPage;
|
|
185
|
+
export { type CursorIDPageParams as CursorIDPageParams, type CursorIDPageResponse as CursorIDPageResponse };
|
|
186
|
+
export { Files as Files, type File as File, type FilesCursorIDPage as FilesCursorIDPage, type FileListParams as FileListParams, type FileUploadParams as FileUploadParams, };
|
|
187
|
+
export { StructuredSheets as StructuredSheets, type StructuredSheetResponse as StructuredSheetResponse, type StructuredSheetResponsesCursorIDPage as StructuredSheetResponsesCursorIDPage, type StructuredSheetCreateParams as StructuredSheetCreateParams, type StructuredSheetListParams as StructuredSheetListParams, };
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=client.d.mts.map
|