@expandai/sdk 0.17.0 → 0.17.2
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 +2 -1
- package/README.md +83 -307
- package/build/dts/Client.d.ts +61 -0
- package/build/dts/Client.d.ts.map +1 -0
- package/build/dts/Error.d.ts +90 -0
- package/build/dts/Error.d.ts.map +1 -0
- package/build/dts/FetchJson.d.ts +363 -0
- package/build/dts/FetchJson.d.ts.map +1 -0
- package/build/dts/Generated.d.ts +1896 -0
- package/build/dts/Generated.d.ts.map +1 -0
- package/build/dts/HttpClientHelpers.d.ts +5 -0
- package/build/dts/HttpClientHelpers.d.ts.map +1 -0
- package/build/dts/Internal.d.ts +49 -0
- package/build/dts/Internal.d.ts.map +1 -0
- package/build/dts/Playground.d.ts +24 -0
- package/build/dts/Playground.d.ts.map +1 -0
- package/build/dts/Service.d.ts +283 -0
- package/build/dts/Service.d.ts.map +1 -0
- package/build/dts/index.d.ts +6 -0
- package/build/dts/index.d.ts.map +1 -0
- package/build/esm/Client.js +87 -0
- package/build/esm/Client.js.map +1 -0
- package/build/esm/Error.js +91 -0
- package/build/esm/Error.js.map +1 -0
- package/build/esm/FetchJson.js +70 -0
- package/build/esm/FetchJson.js.map +1 -0
- package/build/esm/Generated.js +651 -0
- package/build/esm/Generated.js.map +1 -0
- package/build/esm/HttpClientHelpers.js +14 -0
- package/build/esm/HttpClientHelpers.js.map +1 -0
- package/build/esm/Internal.js +95 -0
- package/build/esm/Internal.js.map +1 -0
- package/build/esm/Playground.js +55 -0
- package/build/esm/Playground.js.map +1 -0
- package/build/esm/Service.js +174 -0
- package/build/esm/Service.js.map +1 -0
- package/build/esm/index.js +4 -0
- package/build/esm/index.js.map +1 -0
- package/package.json +72 -136
- package/src/Client.ts +128 -0
- package/src/Error.ts +105 -0
- package/src/FetchJson.ts +109 -0
- package/src/Generated.ts +960 -0
- package/src/HttpClientHelpers.ts +24 -0
- package/src/Internal.ts +246 -0
- package/src/Playground.ts +76 -0
- package/src/Service.ts +264 -0
- package/src/index.ts +27 -21
- package/CHANGELOG.md +0 -238
- package/api-promise.d.mts +0 -2
- package/api-promise.d.mts.map +0 -1
- package/api-promise.d.ts +0 -2
- package/api-promise.d.ts.map +0 -1
- package/api-promise.js +0 -6
- package/api-promise.js.map +0 -1
- package/api-promise.mjs +0 -2
- package/api-promise.mjs.map +0 -1
- package/client.d.mts +0 -184
- package/client.d.mts.map +0 -1
- package/client.d.ts +0 -184
- package/client.d.ts.map +0 -1
- package/client.js +0 -476
- package/client.js.map +0 -1
- package/client.mjs +0 -472
- package/client.mjs.map +0 -1
- package/core/api-promise.d.mts +0 -46
- package/core/api-promise.d.mts.map +0 -1
- package/core/api-promise.d.ts +0 -46
- package/core/api-promise.d.ts.map +0 -1
- package/core/api-promise.js +0 -74
- package/core/api-promise.js.map +0 -1
- package/core/api-promise.mjs +0 -70
- package/core/api-promise.mjs.map +0 -1
- package/core/error.d.mts +0 -46
- package/core/error.d.mts.map +0 -1
- package/core/error.d.ts +0 -46
- package/core/error.d.ts.map +0 -1
- package/core/error.js +0 -113
- package/core/error.js.map +0 -1
- package/core/error.mjs +0 -97
- package/core/error.mjs.map +0 -1
- package/core/resource.d.mts +0 -6
- package/core/resource.d.mts.map +0 -1
- package/core/resource.d.ts +0 -6
- package/core/resource.d.ts.map +0 -1
- package/core/resource.js +0 -11
- package/core/resource.js.map +0 -1
- package/core/resource.mjs +0 -7
- package/core/resource.mjs.map +0 -1
- package/core/uploads.d.mts +0 -3
- package/core/uploads.d.mts.map +0 -1
- package/core/uploads.d.ts +0 -3
- package/core/uploads.d.ts.map +0 -1
- package/core/uploads.js +0 -6
- package/core/uploads.js.map +0 -1
- package/core/uploads.mjs +0 -2
- package/core/uploads.mjs.map +0 -1
- package/error.d.mts +0 -2
- package/error.d.mts.map +0 -1
- package/error.d.ts +0 -2
- package/error.d.ts.map +0 -1
- package/error.js +0 -6
- package/error.js.map +0 -1
- package/error.mjs +0 -2
- package/error.mjs.map +0 -1
- package/index.d.mts +0 -6
- package/index.d.mts.map +0 -1
- package/index.d.ts +0 -6
- package/index.d.ts.map +0 -1
- package/index.js +0 -30
- package/index.js.map +0 -1
- package/index.mjs +0 -7
- package/index.mjs.map +0 -1
- package/internal/builtin-types.d.mts +0 -73
- package/internal/builtin-types.d.mts.map +0 -1
- package/internal/builtin-types.d.ts +0 -73
- package/internal/builtin-types.d.ts.map +0 -1
- package/internal/builtin-types.js +0 -4
- package/internal/builtin-types.js.map +0 -1
- package/internal/builtin-types.mjs +0 -3
- package/internal/builtin-types.mjs.map +0 -1
- package/internal/detect-platform.d.mts +0 -15
- package/internal/detect-platform.d.mts.map +0 -1
- package/internal/detect-platform.d.ts +0 -15
- package/internal/detect-platform.d.ts.map +0 -1
- package/internal/detect-platform.js +0 -162
- package/internal/detect-platform.js.map +0 -1
- package/internal/detect-platform.mjs +0 -157
- package/internal/detect-platform.mjs.map +0 -1
- package/internal/errors.d.mts +0 -3
- package/internal/errors.d.mts.map +0 -1
- package/internal/errors.d.ts +0 -3
- package/internal/errors.d.ts.map +0 -1
- package/internal/errors.js +0 -41
- package/internal/errors.js.map +0 -1
- package/internal/errors.mjs +0 -36
- package/internal/errors.mjs.map +0 -1
- package/internal/headers.d.mts +0 -20
- package/internal/headers.d.mts.map +0 -1
- package/internal/headers.d.ts +0 -20
- package/internal/headers.d.ts.map +0 -1
- package/internal/headers.js +0 -79
- package/internal/headers.js.map +0 -1
- package/internal/headers.mjs +0 -74
- package/internal/headers.mjs.map +0 -1
- package/internal/parse.d.mts +0 -12
- package/internal/parse.d.mts.map +0 -1
- package/internal/parse.d.ts +0 -12
- package/internal/parse.d.ts.map +0 -1
- package/internal/parse.js +0 -40
- package/internal/parse.js.map +0 -1
- package/internal/parse.mjs +0 -37
- package/internal/parse.mjs.map +0 -1
- package/internal/request-options.d.mts +0 -75
- package/internal/request-options.d.mts.map +0 -1
- package/internal/request-options.d.ts +0 -75
- package/internal/request-options.d.ts.map +0 -1
- package/internal/request-options.js +0 -14
- package/internal/request-options.js.map +0 -1
- package/internal/request-options.mjs +0 -10
- package/internal/request-options.mjs.map +0 -1
- package/internal/shim-types.d.mts +0 -17
- package/internal/shim-types.d.mts.map +0 -1
- package/internal/shim-types.d.ts +0 -17
- package/internal/shim-types.d.ts.map +0 -1
- package/internal/shim-types.js +0 -4
- package/internal/shim-types.js.map +0 -1
- package/internal/shim-types.mjs +0 -3
- package/internal/shim-types.mjs.map +0 -1
- package/internal/shims.d.mts +0 -20
- package/internal/shims.d.mts.map +0 -1
- package/internal/shims.d.ts +0 -20
- package/internal/shims.d.ts.map +0 -1
- package/internal/shims.js +0 -92
- package/internal/shims.js.map +0 -1
- package/internal/shims.mjs +0 -85
- package/internal/shims.mjs.map +0 -1
- package/internal/to-file.d.mts +0 -45
- package/internal/to-file.d.mts.map +0 -1
- package/internal/to-file.d.ts +0 -45
- package/internal/to-file.d.ts.map +0 -1
- package/internal/to-file.js +0 -91
- package/internal/to-file.js.map +0 -1
- package/internal/to-file.mjs +0 -88
- package/internal/to-file.mjs.map +0 -1
- package/internal/tslib.js +0 -81
- package/internal/tslib.mjs +0 -17
- package/internal/types.d.mts +0 -69
- package/internal/types.d.mts.map +0 -1
- package/internal/types.d.ts +0 -69
- package/internal/types.d.ts.map +0 -1
- package/internal/types.js +0 -4
- package/internal/types.js.map +0 -1
- package/internal/types.mjs +0 -3
- package/internal/types.mjs.map +0 -1
- package/internal/uploads.d.mts +0 -42
- package/internal/uploads.d.mts.map +0 -1
- package/internal/uploads.d.ts +0 -42
- package/internal/uploads.d.ts.map +0 -1
- package/internal/uploads.js +0 -141
- package/internal/uploads.js.map +0 -1
- package/internal/uploads.mjs +0 -131
- package/internal/uploads.mjs.map +0 -1
- package/internal/utils/base64.d.mts +0 -3
- package/internal/utils/base64.d.mts.map +0 -1
- package/internal/utils/base64.d.ts +0 -3
- package/internal/utils/base64.d.ts.map +0 -1
- package/internal/utils/base64.js +0 -38
- package/internal/utils/base64.js.map +0 -1
- package/internal/utils/base64.mjs +0 -33
- package/internal/utils/base64.mjs.map +0 -1
- package/internal/utils/bytes.d.mts +0 -4
- package/internal/utils/bytes.d.mts.map +0 -1
- package/internal/utils/bytes.d.ts +0 -4
- package/internal/utils/bytes.d.ts.map +0 -1
- package/internal/utils/bytes.js +0 -31
- package/internal/utils/bytes.js.map +0 -1
- package/internal/utils/bytes.mjs +0 -26
- package/internal/utils/bytes.mjs.map +0 -1
- package/internal/utils/env.d.mts +0 -9
- package/internal/utils/env.d.mts.map +0 -1
- package/internal/utils/env.d.ts +0 -9
- package/internal/utils/env.d.ts.map +0 -1
- package/internal/utils/env.js +0 -22
- package/internal/utils/env.js.map +0 -1
- package/internal/utils/env.mjs +0 -18
- package/internal/utils/env.mjs.map +0 -1
- package/internal/utils/log.d.mts +0 -37
- package/internal/utils/log.d.mts.map +0 -1
- package/internal/utils/log.d.ts +0 -37
- package/internal/utils/log.d.ts.map +0 -1
- package/internal/utils/log.js +0 -86
- package/internal/utils/log.js.map +0 -1
- package/internal/utils/log.mjs +0 -80
- package/internal/utils/log.mjs.map +0 -1
- package/internal/utils/path.d.mts +0 -15
- package/internal/utils/path.d.mts.map +0 -1
- package/internal/utils/path.d.ts +0 -15
- package/internal/utils/path.d.ts.map +0 -1
- package/internal/utils/path.js +0 -79
- package/internal/utils/path.js.map +0 -1
- package/internal/utils/path.mjs +0 -74
- package/internal/utils/path.mjs.map +0 -1
- package/internal/utils/sleep.d.mts +0 -2
- package/internal/utils/sleep.d.mts.map +0 -1
- package/internal/utils/sleep.d.ts +0 -2
- package/internal/utils/sleep.d.ts.map +0 -1
- package/internal/utils/sleep.js +0 -7
- package/internal/utils/sleep.js.map +0 -1
- package/internal/utils/sleep.mjs +0 -3
- package/internal/utils/sleep.mjs.map +0 -1
- package/internal/utils/uuid.d.mts +0 -5
- package/internal/utils/uuid.d.mts.map +0 -1
- package/internal/utils/uuid.d.ts +0 -5
- package/internal/utils/uuid.d.ts.map +0 -1
- package/internal/utils/uuid.js +0 -19
- package/internal/utils/uuid.js.map +0 -1
- package/internal/utils/uuid.mjs +0 -15
- package/internal/utils/uuid.mjs.map +0 -1
- package/internal/utils/values.d.mts +0 -18
- package/internal/utils/values.d.mts.map +0 -1
- package/internal/utils/values.d.ts +0 -18
- package/internal/utils/values.d.ts.map +0 -1
- package/internal/utils/values.js +0 -112
- package/internal/utils/values.js.map +0 -1
- package/internal/utils/values.mjs +0 -94
- package/internal/utils/values.mjs.map +0 -1
- package/internal/utils.d.mts +0 -7
- package/internal/utils.d.mts.map +0 -1
- package/internal/utils.d.ts +0 -7
- package/internal/utils.d.ts.map +0 -1
- package/internal/utils.js +0 -11
- package/internal/utils.js.map +0 -1
- package/internal/utils.mjs +0 -8
- package/internal/utils.mjs.map +0 -1
- package/resource.d.mts +0 -2
- package/resource.d.mts.map +0 -1
- package/resource.d.ts +0 -2
- package/resource.d.ts.map +0 -1
- package/resource.js +0 -6
- package/resource.js.map +0 -1
- package/resource.mjs +0 -2
- package/resource.mjs.map +0 -1
- package/resources/index.d.mts +0 -2
- package/resources/index.d.mts.map +0 -1
- package/resources/index.d.ts +0 -2
- package/resources/index.d.ts.map +0 -1
- package/resources/index.js +0 -4
- package/resources/index.js.map +0 -1
- package/resources/index.mjs +0 -3
- package/resources/index.mjs.map +0 -1
- package/resources/top-level.d.mts +0 -469
- package/resources/top-level.d.mts.map +0 -1
- package/resources/top-level.d.ts +0 -469
- package/resources/top-level.d.ts.map +0 -1
- package/resources/top-level.js +0 -4
- package/resources/top-level.js.map +0 -1
- package/resources/top-level.mjs +0 -3
- package/resources/top-level.mjs.map +0 -1
- package/resources.d.mts +0 -2
- package/resources.d.mts.map +0 -1
- package/resources.d.ts +0 -2
- package/resources.d.ts.map +0 -1
- package/resources.js +0 -5
- package/resources.js.map +0 -1
- package/resources.mjs +0 -2
- package/resources.mjs.map +0 -1
- package/src/api-promise.ts +0 -2
- package/src/client.ts +0 -744
- package/src/core/README.md +0 -3
- package/src/core/api-promise.ts +0 -92
- package/src/core/error.ts +0 -130
- package/src/core/resource.ts +0 -11
- package/src/core/uploads.ts +0 -2
- package/src/error.ts +0 -2
- package/src/internal/README.md +0 -3
- package/src/internal/builtin-types.ts +0 -93
- package/src/internal/detect-platform.ts +0 -196
- package/src/internal/errors.ts +0 -33
- package/src/internal/headers.ts +0 -97
- package/src/internal/parse.ts +0 -56
- package/src/internal/request-options.ts +0 -91
- package/src/internal/shim-types.ts +0 -26
- package/src/internal/shims.ts +0 -107
- package/src/internal/to-file.ts +0 -154
- package/src/internal/types.ts +0 -95
- package/src/internal/uploads.ts +0 -187
- package/src/internal/utils/base64.ts +0 -40
- package/src/internal/utils/bytes.ts +0 -32
- package/src/internal/utils/env.ts +0 -18
- package/src/internal/utils/log.ts +0 -127
- package/src/internal/utils/path.ts +0 -88
- package/src/internal/utils/sleep.ts +0 -3
- package/src/internal/utils/uuid.ts +0 -17
- package/src/internal/utils/values.ts +0 -105
- package/src/internal/utils.ts +0 -8
- package/src/lib/.keep +0 -4
- package/src/resource.ts +0 -2
- package/src/resources/index.ts +0 -3
- package/src/resources/top-level.ts +0 -552
- package/src/resources.ts +0 -1
- package/src/tsconfig.json +0 -11
- package/src/uploads.ts +0 -2
- package/src/version.ts +0 -1
- package/uploads.d.mts +0 -2
- package/uploads.d.mts.map +0 -1
- package/uploads.d.ts +0 -2
- package/uploads.d.ts.map +0 -1
- package/uploads.js +0 -6
- package/uploads.js.map +0 -1
- package/uploads.mjs +0 -2
- package/uploads.mjs.map +0 -1
- package/version.d.mts +0 -2
- package/version.d.mts.map +0 -1
- package/version.d.ts +0 -2
- package/version.d.ts.map +0 -1
- package/version.js +0 -5
- package/version.js.map +0 -1
- package/version.mjs +0 -2
- package/version.mjs.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
Apache License
|
|
2
3
|
Version 2.0, January 2004
|
|
3
4
|
http://www.apache.org/licenses/
|
|
@@ -186,7 +187,7 @@
|
|
|
186
187
|
same "printed page" as the copyright notice for easier
|
|
187
188
|
identification within third-party archives.
|
|
188
189
|
|
|
189
|
-
Copyright
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
191
|
|
|
191
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
193
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -1,361 +1,137 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @expandai/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official TypeScript SDK for the [ExpandAI](https://expand.ai) API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Built on [Effect](https://effect.website), with both a class-based client for promise-style usage and an `Effect.Service` for full Effect integration.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
It is generated with [Stainless](https://www.stainless.com/).
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
7
|
+
## Install
|
|
12
8
|
|
|
13
9
|
```sh
|
|
14
10
|
npm install @expandai/sdk
|
|
11
|
+
# or
|
|
12
|
+
bun add @expandai/sdk
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @expandai/sdk
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
The full API of this library can be found in [api.md](api.md).
|
|
20
|
-
|
|
21
|
-
<!-- prettier-ignore -->
|
|
22
|
-
```js
|
|
23
|
-
import Expand from '@expandai/sdk';
|
|
24
|
-
|
|
25
|
-
const client = new Expand({
|
|
26
|
-
apiKey: process.env['EXPAND_API_KEY'], // This is the default and can be omitted
|
|
27
|
-
});
|
|
17
|
+
## Authentication
|
|
28
18
|
|
|
29
|
-
|
|
19
|
+
Set `EXPAND_API_KEY` in your environment, or pass `apiKey` explicitly when constructing the client.
|
|
30
20
|
|
|
31
|
-
|
|
21
|
+
```sh
|
|
22
|
+
export EXPAND_API_KEY=sk_...
|
|
32
23
|
```
|
|
33
24
|
|
|
34
|
-
|
|
25
|
+
## Quick start
|
|
35
26
|
|
|
36
|
-
|
|
27
|
+
### Promise API
|
|
37
28
|
|
|
38
|
-
<!-- prettier-ignore -->
|
|
39
29
|
```ts
|
|
40
|
-
import
|
|
41
|
-
|
|
42
|
-
const client = new Expand({
|
|
43
|
-
apiKey: process.env['EXPAND_API_KEY'], // This is the default and can be omitted
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const params: Expand.FetchParams = { url: 'https://news.ycombinator.com' };
|
|
47
|
-
const response: Expand.FetchResponse = await client.fetch(params);
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
|
|
30
|
+
import { ExpandClient } from '@expandai/sdk'
|
|
51
31
|
|
|
52
|
-
|
|
32
|
+
const expand = new ExpandClient()
|
|
53
33
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
a subclass of `APIError` will be thrown:
|
|
57
|
-
|
|
58
|
-
<!-- prettier-ignore -->
|
|
59
|
-
```ts
|
|
60
|
-
const response = await client.fetch({ url: 'https://news.ycombinator.com' }).catch(async (err) => {
|
|
61
|
-
if (err instanceof Expand.APIError) {
|
|
62
|
-
console.log(err.status); // 400
|
|
63
|
-
console.log(err.name); // BadRequestError
|
|
64
|
-
console.log(err.headers); // {server: 'nginx', ...}
|
|
65
|
-
} else {
|
|
66
|
-
throw err;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
34
|
+
const result = await expand.fetch({ url: 'https://example.com' })
|
|
35
|
+
console.log(result)
|
|
69
36
|
```
|
|
70
37
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
| Status Code | Error Type |
|
|
74
|
-
| ----------- | -------------------------- |
|
|
75
|
-
| 400 | `BadRequestError` |
|
|
76
|
-
| 401 | `AuthenticationError` |
|
|
77
|
-
| 403 | `PermissionDeniedError` |
|
|
78
|
-
| 404 | `NotFoundError` |
|
|
79
|
-
| 422 | `UnprocessableEntityError` |
|
|
80
|
-
| 429 | `RateLimitError` |
|
|
81
|
-
| >=500 | `InternalServerError` |
|
|
82
|
-
| N/A | `APIConnectionError` |
|
|
83
|
-
|
|
84
|
-
### Retries
|
|
85
|
-
|
|
86
|
-
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
|
|
87
|
-
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
|
|
88
|
-
429 Rate Limit, and >=500 Internal errors will all be retried by default.
|
|
89
|
-
|
|
90
|
-
You can use the `maxRetries` option to configure or disable this:
|
|
91
|
-
|
|
92
|
-
<!-- prettier-ignore -->
|
|
93
|
-
```js
|
|
94
|
-
// Configure the default for all requests:
|
|
95
|
-
const client = new Expand({
|
|
96
|
-
maxRetries: 0, // default is 2
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// Or, configure per-request:
|
|
100
|
-
await client.fetch({ url: 'https://news.ycombinator.com' }, {
|
|
101
|
-
maxRetries: 5,
|
|
102
|
-
});
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Timeouts
|
|
106
|
-
|
|
107
|
-
Requests time out after 1 minute by default. You can configure this with a `timeout` option:
|
|
38
|
+
Constructor options:
|
|
108
39
|
|
|
109
|
-
<!-- prettier-ignore -->
|
|
110
40
|
```ts
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
await client.fetch({ url: 'https://news.ycombinator.com' }, {
|
|
118
|
-
timeout: 5 * 1000,
|
|
119
|
-
});
|
|
41
|
+
new ExpandClient({
|
|
42
|
+
apiKey: 'xpnd_...', // defaults to process.env.EXPAND_API_KEY
|
|
43
|
+
baseUrl: 'https://api...', // defaults to https://api.expand.ai
|
|
44
|
+
timeoutMs: 60_000, // total wall-clock budget incl. retries
|
|
45
|
+
maxRetries: 2, // retries on timeout / connection / 408,409,429,5xx
|
|
46
|
+
})
|
|
120
47
|
```
|
|
121
48
|
|
|
122
|
-
|
|
49
|
+
Errors thrown:
|
|
123
50
|
|
|
124
|
-
|
|
51
|
+
- `ExpandClientError` — invalid options (missing API key, empty `baseUrl`)
|
|
52
|
+
- `ExpandClientApiError` — non-2xx HTTP response
|
|
53
|
+
- `ExpandClientConnectionError` — network failure
|
|
54
|
+
- `ExpandClientTimeoutError` — request timed out
|
|
125
55
|
|
|
126
|
-
|
|
56
|
+
### Effect service
|
|
127
57
|
|
|
128
|
-
### Accessing raw Response data (e.g., headers)
|
|
129
|
-
|
|
130
|
-
The "raw" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.
|
|
131
|
-
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.
|
|
132
|
-
|
|
133
|
-
You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.
|
|
134
|
-
Unlike `.asResponse()` this method consumes the body, returning once it is parsed.
|
|
135
|
-
|
|
136
|
-
<!-- prettier-ignore -->
|
|
137
58
|
```ts
|
|
138
|
-
|
|
59
|
+
import { NodeRuntime } from '@effect/platform-node'
|
|
60
|
+
import { Effect } from 'effect'
|
|
61
|
+
import { ExpandService } from '@expandai/sdk'
|
|
139
62
|
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
63
|
+
const program = Effect.gen(function* () {
|
|
64
|
+
const expand = yield* ExpandService
|
|
65
|
+
const result = yield* expand.fetch({ url: 'https://example.com' })
|
|
66
|
+
yield* Effect.log(result)
|
|
67
|
+
})
|
|
143
68
|
|
|
144
|
-
|
|
145
|
-
.fetch({ url: 'https://news.ycombinator.com' })
|
|
146
|
-
.withResponse();
|
|
147
|
-
console.log(raw.headers.get('X-My-Header'));
|
|
148
|
-
console.log(response.data);
|
|
69
|
+
NodeRuntime.runMain(program.pipe(Effect.provide(ExpandService.layer({ apiKey: process.env.EXPAND_API_KEY }))))
|
|
149
70
|
```
|
|
150
71
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
> [!IMPORTANT]
|
|
154
|
-
> All log messages are intended for debugging only. The format and content of log messages
|
|
155
|
-
> may change between releases.
|
|
156
|
-
|
|
157
|
-
#### Log levels
|
|
158
|
-
|
|
159
|
-
The log level can be configured in two ways:
|
|
160
|
-
|
|
161
|
-
1. Via the `EXPAND_LOG` environment variable
|
|
162
|
-
2. Using the `logLevel` client option (overrides the environment variable if set)
|
|
72
|
+
Layer options (same shape as `ExpandClientOptions`):
|
|
163
73
|
|
|
164
74
|
```ts
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
75
|
+
ExpandService.layer({
|
|
76
|
+
apiKey: 'xpnd_...', // defaults to process.env.EXPAND_API_KEY
|
|
77
|
+
baseUrl: 'https://api...', // defaults to https://api.expand.ai
|
|
78
|
+
timeoutMs: 60_000, // total wall-clock budget incl. retries
|
|
79
|
+
maxRetries: 2, // retries on timeout / connection / 408,409,429,5xx
|
|
80
|
+
})
|
|
170
81
|
```
|
|
171
82
|
|
|
172
|
-
|
|
83
|
+
Typed errors in the `Effect` channel:
|
|
173
84
|
|
|
174
|
-
- `
|
|
175
|
-
- `
|
|
176
|
-
- `
|
|
177
|
-
- `
|
|
178
|
-
- `'off'` - Disable all logging
|
|
85
|
+
- `ExpandSdkError` — invalid options (missing API key, empty `baseUrl`)
|
|
86
|
+
- `ExpandApiError` — non-2xx HTTP response
|
|
87
|
+
- `ExpandConnectionError` — network failure
|
|
88
|
+
- `ExpandTimeoutError` — request timed out
|
|
179
89
|
|
|
180
|
-
|
|
181
|
-
Some authentication-related headers are redacted, but sensitive data in request and response bodies
|
|
182
|
-
may still be visible.
|
|
90
|
+
## Batched fetches
|
|
183
91
|
|
|
184
|
-
|
|
92
|
+
`batched` kicks off a job and returns immediately with an `id`. Poll `getBatched(id)` until `batchedStatus` is no longer `RUNNING` or `QUEUED`.
|
|
185
93
|
|
|
186
|
-
|
|
187
|
-
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.
|
|
188
|
-
|
|
189
|
-
When providing a custom logger, the `logLevel` option still controls which messages are emitted, messages
|
|
190
|
-
below the configured level will not be sent to your logger.
|
|
94
|
+
### Promise API
|
|
191
95
|
|
|
192
96
|
```ts
|
|
193
|
-
import
|
|
194
|
-
import pino from 'pino';
|
|
195
|
-
|
|
196
|
-
const logger = pino();
|
|
97
|
+
import { ExpandClient } from '@expandai/sdk'
|
|
197
98
|
|
|
198
|
-
const
|
|
199
|
-
logger: logger.child({ name: 'Expand' }),
|
|
200
|
-
logLevel: 'debug', // Send all messages to pino, allowing it to filter
|
|
201
|
-
});
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### Making custom/undocumented requests
|
|
205
|
-
|
|
206
|
-
This library is typed for convenient access to the documented API. If you need to access undocumented
|
|
207
|
-
endpoints, params, or response properties, the library can still be used.
|
|
99
|
+
const expand = new ExpandClient()
|
|
208
100
|
|
|
209
|
-
|
|
101
|
+
const run = await expand.batched({ urls: ['https://example.com'] })
|
|
210
102
|
|
|
211
|
-
|
|
212
|
-
|
|
103
|
+
let status = await expand.getBatched(run.id)
|
|
104
|
+
while (status.batchedStatus === 'RUNNING' || status.batchedStatus === 'QUEUED') {
|
|
105
|
+
await new Promise((resolve) => setTimeout(resolve, 1000))
|
|
106
|
+
status = await expand.getBatched(run.id)
|
|
107
|
+
}
|
|
213
108
|
|
|
214
|
-
|
|
215
|
-
await client.post('/some/path', {
|
|
216
|
-
body: { some_prop: 'foo' },
|
|
217
|
-
query: { some_query_arg: 'bar' },
|
|
218
|
-
});
|
|
109
|
+
console.log(status.results)
|
|
219
110
|
```
|
|
220
111
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented
|
|
224
|
-
parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you
|
|
225
|
-
send will be sent as-is.
|
|
112
|
+
### Effect service
|
|
226
113
|
|
|
227
114
|
```ts
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
baz: 'undocumented option',
|
|
232
|
-
});
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
For requests with the `GET` verb, any extra params will be in the query, all other requests will send the
|
|
236
|
-
extra param in the body.
|
|
237
|
-
|
|
238
|
-
If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request
|
|
239
|
-
options.
|
|
240
|
-
|
|
241
|
-
#### Undocumented response properties
|
|
242
|
-
|
|
243
|
-
To access undocumented response properties, you may access the response object with `// @ts-expect-error` on
|
|
244
|
-
the response object, or cast the response object to the requisite type. Like the request params, we do not
|
|
245
|
-
validate or strip extra properties from the response from the API.
|
|
115
|
+
import { NodeRuntime } from '@effect/platform-node'
|
|
116
|
+
import { Duration, Effect, Schedule } from 'effect'
|
|
117
|
+
import { ExpandService, type GetBatchedResponse } from '@expandai/sdk'
|
|
246
118
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
119
|
+
const program = Effect.gen(function* () {
|
|
120
|
+
const expand = yield* ExpandService
|
|
121
|
+
const run = yield* expand.batched({ urls: ['https://example.com'] })
|
|
122
|
+
const final = yield* expand.getBatched(run.id).pipe(
|
|
123
|
+
Effect.repeat(
|
|
124
|
+
Schedule.recurUntil(
|
|
125
|
+
(status: GetBatchedResponse) => status.batchedStatus !== 'RUNNING' && status.batchedStatus !== 'QUEUED',
|
|
126
|
+
).pipe(Schedule.addDelay(() => Duration.seconds(1))),
|
|
127
|
+
),
|
|
128
|
+
)
|
|
129
|
+
yield* Effect.log(final.results)
|
|
130
|
+
})
|
|
255
131
|
|
|
256
|
-
|
|
132
|
+
NodeRuntime.runMain(program.pipe(Effect.provide(ExpandService.layer({ apiKey: process.env.EXPAND_API_KEY }))))
|
|
257
133
|
```
|
|
258
134
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
```ts
|
|
262
|
-
import Expand from '@expandai/sdk';
|
|
263
|
-
import fetch from 'my-fetch';
|
|
264
|
-
|
|
265
|
-
const client = new Expand({ customFetch: fetch });
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
### Fetch options
|
|
269
|
-
|
|
270
|
-
If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `customFetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
|
|
271
|
-
|
|
272
|
-
```ts
|
|
273
|
-
import Expand from '@expandai/sdk';
|
|
274
|
-
|
|
275
|
-
const client = new Expand({
|
|
276
|
-
customFetchOptions: {
|
|
277
|
-
// `RequestInit` options
|
|
278
|
-
},
|
|
279
|
-
});
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
#### Configuring proxies
|
|
283
|
-
|
|
284
|
-
To modify proxy behavior, you can provide custom `customFetchOptions` that add runtime-specific proxy
|
|
285
|
-
options to requests:
|
|
286
|
-
|
|
287
|
-
<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>
|
|
288
|
-
|
|
289
|
-
```ts
|
|
290
|
-
import Expand from '@expandai/sdk';
|
|
291
|
-
import * as undici from 'undici';
|
|
292
|
-
|
|
293
|
-
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
|
|
294
|
-
const client = new Expand({
|
|
295
|
-
customFetchOptions: {
|
|
296
|
-
dispatcher: proxyAgent,
|
|
297
|
-
},
|
|
298
|
-
});
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
<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>
|
|
302
|
-
|
|
303
|
-
```ts
|
|
304
|
-
import Expand from '@expandai/sdk';
|
|
305
|
-
|
|
306
|
-
const client = new Expand({
|
|
307
|
-
customFetchOptions: {
|
|
308
|
-
proxy: 'http://localhost:8888',
|
|
309
|
-
},
|
|
310
|
-
});
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
<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>
|
|
314
|
-
|
|
315
|
-
```ts
|
|
316
|
-
import Expand from 'npm:@expandai/sdk';
|
|
317
|
-
|
|
318
|
-
const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
|
|
319
|
-
const client = new Expand({
|
|
320
|
-
customFetchOptions: {
|
|
321
|
-
client: httpClient,
|
|
322
|
-
},
|
|
323
|
-
});
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
## Frequently Asked Questions
|
|
327
|
-
|
|
328
|
-
## Semantic versioning
|
|
329
|
-
|
|
330
|
-
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:
|
|
331
|
-
|
|
332
|
-
1. Changes that only affect static types, without breaking runtime behavior.
|
|
333
|
-
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.)_
|
|
334
|
-
3. Changes that we do not expect to impact the vast majority of users in practice.
|
|
335
|
-
|
|
336
|
-
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
337
|
-
|
|
338
|
-
We are keen for your feedback; please open an [issue](https://www.github.com/expandai/expandai-node/issues) with questions, bugs, or suggestions.
|
|
339
|
-
|
|
340
|
-
## Requirements
|
|
341
|
-
|
|
342
|
-
TypeScript >= 4.9 is supported.
|
|
343
|
-
|
|
344
|
-
The following runtimes are supported:
|
|
345
|
-
|
|
346
|
-
- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
|
|
347
|
-
- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
|
|
348
|
-
- Deno v1.28.0 or higher.
|
|
349
|
-
- Bun 1.0 or later.
|
|
350
|
-
- Cloudflare Workers.
|
|
351
|
-
- Vercel Edge Runtime.
|
|
352
|
-
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
|
|
353
|
-
- Nitro v2.6 or greater.
|
|
354
|
-
|
|
355
|
-
Note that React Native is not supported at this time.
|
|
356
|
-
|
|
357
|
-
If you are interested in other runtime environments, please open or upvote an issue on GitHub.
|
|
358
|
-
|
|
359
|
-
## Contributing
|
|
135
|
+
## License
|
|
360
136
|
|
|
361
|
-
|
|
137
|
+
[Apache 2.0](./LICENSE)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type BatchedParams, type BatchedResponse, type ExpandServiceOptions, type FetchJsonParams, type FetchJsonRequestOptions, type FetchJsonResponse, type FetchParams, type FetchRequestOptions, type FetchResponse, type FetchSearchParams, type FetchSearchResponse, type GetBatchedParams, type GetBatchedResponse, type RequestOptions } from './Service.js';
|
|
2
|
+
export type { BatchedParams, BatchedResponse, FetchJsonParams, FetchJsonRequestOptions, FetchJsonResponse, FetchParams, FetchRequestOptions, FetchResponse, FetchSearchParams, FetchSearchResponse, GetBatchedParams, GetBatchedResponse, } from './Service.js';
|
|
3
|
+
/** Options for constructing an {@link ExpandClient}. Same shape as `ExpandServiceOptions`. */
|
|
4
|
+
export type ExpandClientOptions = ExpandServiceOptions;
|
|
5
|
+
/**
|
|
6
|
+
* Promise-based client for the Expand API. Holds an {@link InternalClient} layer and runs Effects
|
|
7
|
+
* against it, translating typed failures into the `ExpandClient*Error` hierarchy that async/await
|
|
8
|
+
* consumers expect.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const client = new ExpandClient({ apiKey: 'sk_...' })
|
|
13
|
+
* const result = await client.fetch({ url: 'https://example.com' })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class ExpandClient {
|
|
17
|
+
private readonly layer;
|
|
18
|
+
constructor(options?: ExpandClientOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Fetch a URL through the Expand API.
|
|
21
|
+
*
|
|
22
|
+
* @throws {ExpandClientApiError} on 4xx/5xx responses
|
|
23
|
+
* @throws {ExpandClientTimeoutError} when the request exceeds `timeoutMs`
|
|
24
|
+
* @throws {ExpandClientConnectionError} on network failures
|
|
25
|
+
* @throws {ExpandClientError} for any other failure
|
|
26
|
+
*/
|
|
27
|
+
fetch(params: FetchParams, options?: FetchRequestOptions): Promise<FetchResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Fetch a URL through the object-mode endpoint.
|
|
30
|
+
*
|
|
31
|
+
* Returns `{ meta, markdown, json }`; use {@link fetch} for the raw markdown document.
|
|
32
|
+
*/
|
|
33
|
+
fetchJson(params: FetchJsonParams, options?: FetchJsonRequestOptions): Promise<FetchJsonResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Search a previous Fetch response by `snapshotId` without starting a new capture.
|
|
36
|
+
*/
|
|
37
|
+
fetchSearch(params: FetchSearchParams, options?: RequestOptions): Promise<FetchSearchResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Kick off an asynchronous batched fetch over one or more URLs. Returns a batched-run ID that can
|
|
40
|
+
* be polled via {@link getBatched}.
|
|
41
|
+
*
|
|
42
|
+
* Retries are disabled by default. Pass `{ maxRetries: N }` to opt in.
|
|
43
|
+
*
|
|
44
|
+
* @throws {ExpandClientApiError} on 4xx/5xx responses
|
|
45
|
+
* @throws {ExpandClientTimeoutError} when the request exceeds `timeoutMs`
|
|
46
|
+
* @throws {ExpandClientConnectionError} on network failures
|
|
47
|
+
* @throws {ExpandClientError} for any other failure
|
|
48
|
+
*/
|
|
49
|
+
batched(params: BatchedParams, options?: RequestOptions): Promise<BatchedResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Fetch the status and accumulated results for a batched run previously started by {@link batched}.
|
|
52
|
+
*
|
|
53
|
+
* @throws {ExpandClientApiError} on 4xx/5xx responses
|
|
54
|
+
* @throws {ExpandClientTimeoutError} when the request exceeds `timeoutMs`
|
|
55
|
+
* @throws {ExpandClientConnectionError} on network failures
|
|
56
|
+
* @throws {ExpandClientError} for any other failure
|
|
57
|
+
*/
|
|
58
|
+
getBatched(id: string, options?: GetBatchedParams & RequestOptions): Promise<GetBatchedResponse>;
|
|
59
|
+
private run;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=Client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/Client.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,eAAe,EAEpB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,MAAM,cAAc,CAAA;AAErB,YAAY,EACX,aAAa,EACb,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,cAAc,CAAA;AAErB,8FAA8F;AAC9F,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6B;gBAEvC,OAAO,GAAE,mBAAwB;IAa7C;;;;;;;OAOG;IACG,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC;IAI3F;;;;OAIG;IACG,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI3G;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAIxG;;;;;;;;;;OAUG;IACG,OAAO,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IAI5F;;;;;;;OAOG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAgB,GAAG,cAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAI5F,GAAG;CAOjB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
declare const ExpandSdkError_base: Schema.TaggedErrorClass<ExpandSdkError, "ExpandSdkError", {
|
|
3
|
+
readonly _tag: Schema.tag<"ExpandSdkError">;
|
|
4
|
+
} & {
|
|
5
|
+
message: typeof Schema.String;
|
|
6
|
+
cause: Schema.optional<typeof Schema.Defect>;
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* Effect-side base error. Schema.TaggedError; Effect consumers receive these in the error channel.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ExpandSdkError extends ExpandSdkError_base {
|
|
12
|
+
toPublicError(): ExpandClientError;
|
|
13
|
+
}
|
|
14
|
+
declare const ExpandApiError_base: Schema.TaggedErrorClass<ExpandApiError, "ExpandApiError", {
|
|
15
|
+
readonly _tag: Schema.tag<"ExpandApiError">;
|
|
16
|
+
} & {
|
|
17
|
+
message: typeof Schema.String;
|
|
18
|
+
status: typeof Schema.Number;
|
|
19
|
+
body: Schema.optional<typeof Schema.Unknown>;
|
|
20
|
+
cause: Schema.optional<typeof Schema.Defect>;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Effect-side error for non-2xx API responses. Inspect `status` and `body` for details.
|
|
24
|
+
*/
|
|
25
|
+
export declare class ExpandApiError extends ExpandApiError_base {
|
|
26
|
+
toPublicError(): ExpandClientApiError;
|
|
27
|
+
}
|
|
28
|
+
declare const ExpandConnectionError_base: Schema.TaggedErrorClass<ExpandConnectionError, "ExpandConnectionError", {
|
|
29
|
+
readonly _tag: Schema.tag<"ExpandConnectionError">;
|
|
30
|
+
} & {
|
|
31
|
+
message: typeof Schema.String;
|
|
32
|
+
cause: Schema.optional<typeof Schema.Defect>;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Effect-side error when the SDK cannot reach the API (DNS, connection refused, socket reset, etc.).
|
|
36
|
+
*/
|
|
37
|
+
export declare class ExpandConnectionError extends ExpandConnectionError_base {
|
|
38
|
+
toPublicError(): ExpandClientConnectionError;
|
|
39
|
+
}
|
|
40
|
+
declare const ExpandTimeoutError_base: Schema.TaggedErrorClass<ExpandTimeoutError, "ExpandTimeoutError", {
|
|
41
|
+
readonly _tag: Schema.tag<"ExpandTimeoutError">;
|
|
42
|
+
} & {
|
|
43
|
+
message: typeof Schema.String;
|
|
44
|
+
timeoutMs: typeof Schema.Number;
|
|
45
|
+
cause: Schema.optional<typeof Schema.Defect>;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Effect-side error when a request exceeds its configured `timeoutMs`.
|
|
49
|
+
*/
|
|
50
|
+
export declare class ExpandTimeoutError extends ExpandTimeoutError_base {
|
|
51
|
+
toPublicError(): ExpandClientTimeoutError;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Union of every error the Effect-side `ExpandService` can fail with.
|
|
55
|
+
*/
|
|
56
|
+
export type ExpandError = ExpandSdkError | ExpandApiError | ExpandConnectionError | ExpandTimeoutError;
|
|
57
|
+
/**
|
|
58
|
+
* Promise-side base class. Catch this to handle any failure thrown by `ExpandClient`.
|
|
59
|
+
*/
|
|
60
|
+
export declare class ExpandClientError extends Error {
|
|
61
|
+
constructor(message: string, options?: ErrorOptions);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Promise-side error for non-2xx API responses. Inspect `status` and `body` for details.
|
|
65
|
+
*/
|
|
66
|
+
export declare class ExpandClientApiError extends ExpandClientError {
|
|
67
|
+
readonly status: number;
|
|
68
|
+
readonly body: unknown;
|
|
69
|
+
constructor(message: string, options: ErrorOptions & {
|
|
70
|
+
readonly status: number;
|
|
71
|
+
readonly body?: unknown;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Promise-side error when the SDK cannot reach the API (DNS, connection refused, socket reset, etc.).
|
|
76
|
+
*/
|
|
77
|
+
export declare class ExpandClientConnectionError extends ExpandClientError {
|
|
78
|
+
constructor(message: string, options?: ErrorOptions);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Promise-side error when a request exceeds its configured `timeoutMs`.
|
|
82
|
+
*/
|
|
83
|
+
export declare class ExpandClientTimeoutError extends ExpandClientConnectionError {
|
|
84
|
+
readonly timeoutMs: number;
|
|
85
|
+
constructor(message: string, options: ErrorOptions & {
|
|
86
|
+
readonly timeoutMs: number;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export {};
|
|
90
|
+
//# sourceMappingURL=Error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;;;;;;;AAE/B;;GAEG;AACH,qBAAa,cAAe,SAAQ,mBAGlC;IACD,aAAa;CAGb;;;;;;;;;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,mBAKlC;IACD,aAAa;CAGb;;;;;;;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,0BAGzC;IACD,aAAa;CAGb;;;;;;;;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,uBAItC;IACD,aAAa;CAGb;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,cAAc,GAAG,qBAAqB,GAAG,kBAAkB,CAAA;AAEtG;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB;CAIvD;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB;IAC1D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;gBAEV,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE;CAMzG;AAED;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,iBAAiB;gBACrD,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB;CAIvD;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,2BAA2B;IACxE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;gBAEd,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;KAAE;CAKnF"}
|