@expandai/sdk 0.17.0 → 0.17.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/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 +364 -0
- package/build/dts/FetchJson.d.ts.map +1 -0
- package/build/dts/Generated.d.ts +1863 -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 +277 -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 +646 -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 +53 -136
- package/src/Client.ts +128 -0
- package/src/Error.ts +105 -0
- package/src/FetchJson.ts +109 -0
- package/src/Generated.ts +949 -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/package.json
CHANGED
|
@@ -1,137 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"import": "./core/*.mjs",
|
|
56
|
-
"require": "./core/*.js"
|
|
57
|
-
},
|
|
58
|
-
"./error": {
|
|
59
|
-
"import": "./error.mjs",
|
|
60
|
-
"require": "./error.js"
|
|
61
|
-
},
|
|
62
|
-
"./error.js": {
|
|
63
|
-
"default": "./error.js"
|
|
64
|
-
},
|
|
65
|
-
"./error.mjs": {
|
|
66
|
-
"default": "./error.mjs"
|
|
67
|
-
},
|
|
68
|
-
"./index": {
|
|
69
|
-
"import": "./index.mjs",
|
|
70
|
-
"require": "./index.js"
|
|
71
|
-
},
|
|
72
|
-
"./index.js": {
|
|
73
|
-
"default": "./index.js"
|
|
74
|
-
},
|
|
75
|
-
"./index.mjs": {
|
|
76
|
-
"default": "./index.mjs"
|
|
77
|
-
},
|
|
78
|
-
"./resource": {
|
|
79
|
-
"import": "./resource.mjs",
|
|
80
|
-
"require": "./resource.js"
|
|
81
|
-
},
|
|
82
|
-
"./resource.js": {
|
|
83
|
-
"default": "./resource.js"
|
|
84
|
-
},
|
|
85
|
-
"./resource.mjs": {
|
|
86
|
-
"default": "./resource.mjs"
|
|
87
|
-
},
|
|
88
|
-
"./resources/*.mjs": {
|
|
89
|
-
"default": "./resources/*.mjs"
|
|
90
|
-
},
|
|
91
|
-
"./resources/*.js": {
|
|
92
|
-
"default": "./resources/*.js"
|
|
93
|
-
},
|
|
94
|
-
"./resources/*": {
|
|
95
|
-
"import": "./resources/*.mjs",
|
|
96
|
-
"require": "./resources/*.js"
|
|
97
|
-
},
|
|
98
|
-
"./resources": {
|
|
99
|
-
"import": "./resources.mjs",
|
|
100
|
-
"require": "./resources.js"
|
|
101
|
-
},
|
|
102
|
-
"./resources.js": {
|
|
103
|
-
"default": "./resources.js"
|
|
104
|
-
},
|
|
105
|
-
"./resources.mjs": {
|
|
106
|
-
"default": "./resources.mjs"
|
|
107
|
-
},
|
|
108
|
-
"./uploads": {
|
|
109
|
-
"import": "./uploads.mjs",
|
|
110
|
-
"require": "./uploads.js"
|
|
111
|
-
},
|
|
112
|
-
"./uploads.js": {
|
|
113
|
-
"default": "./uploads.js"
|
|
114
|
-
},
|
|
115
|
-
"./uploads.mjs": {
|
|
116
|
-
"default": "./uploads.mjs"
|
|
117
|
-
},
|
|
118
|
-
"./version": {
|
|
119
|
-
"import": "./version.mjs",
|
|
120
|
-
"require": "./version.js"
|
|
121
|
-
},
|
|
122
|
-
"./version.js": {
|
|
123
|
-
"default": "./version.js"
|
|
124
|
-
},
|
|
125
|
-
"./version.mjs": {
|
|
126
|
-
"default": "./version.mjs"
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
"scripts": {
|
|
130
|
-
"test": "./scripts/test",
|
|
131
|
-
"build": "./scripts/build",
|
|
132
|
-
"format": "./scripts/format",
|
|
133
|
-
"tsn": "ts-node -r tsconfig-paths/register",
|
|
134
|
-
"lint": "./scripts/lint",
|
|
135
|
-
"fix": "./scripts/format"
|
|
136
|
-
}
|
|
137
|
-
}
|
|
2
|
+
"name": "@expandai/sdk",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.17.1",
|
|
5
|
+
"private": false,
|
|
6
|
+
"description": "TypeScript SDK for ExpandAI",
|
|
7
|
+
"author": "ExpandAI",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/expandai/expandai-node.git"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"build/dts",
|
|
18
|
+
"build/esm",
|
|
19
|
+
"src",
|
|
20
|
+
"!**/*.tsbuildinfo"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
"./package.json": "./package.json",
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./build/dts/index.d.ts",
|
|
26
|
+
"import": "./build/esm/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./*": "./src/*.ts"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"generate": "tsx scripts/generate-client.ts",
|
|
32
|
+
"build": "tsc -b tsconfig.build.json",
|
|
33
|
+
"check": "tsc -b tsconfig.json",
|
|
34
|
+
"check:test": "tsc -b tsconfig.test.json",
|
|
35
|
+
"lint": "biome check --write --no-errors-on-unmatched",
|
|
36
|
+
"lint:check": "biome check",
|
|
37
|
+
"format": "biome format --write",
|
|
38
|
+
"format:check": "biome format",
|
|
39
|
+
"test": "vitest run --exclude 'test/**/*.integration.test.ts'",
|
|
40
|
+
"test:integration": "vitest run integration"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@effect/platform": "0.96.1",
|
|
44
|
+
"@effect/platform-node": "0.106.0",
|
|
45
|
+
"effect": "3.21.2"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@biomejs/biome": "^2.4.14",
|
|
49
|
+
"@effect/vitest": "0.29.0",
|
|
50
|
+
"@tim-smart/openapi-gen": "0.3.12",
|
|
51
|
+
"@types/node": "^25.5.2",
|
|
52
|
+
"vitest": "4.1.4"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/Client.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Effect, Either, Exit, Layer } from 'effect'
|
|
2
|
+
import { InternalClient } from './Internal.js'
|
|
3
|
+
import {
|
|
4
|
+
type BatchedParams,
|
|
5
|
+
type BatchedResponse,
|
|
6
|
+
buildServiceConfig,
|
|
7
|
+
type ExpandServiceOptions,
|
|
8
|
+
type FetchJsonParams,
|
|
9
|
+
type FetchJsonRequestOptions,
|
|
10
|
+
type FetchJsonResponse,
|
|
11
|
+
type FetchParams,
|
|
12
|
+
type FetchRequestOptions,
|
|
13
|
+
type FetchResponse,
|
|
14
|
+
type FetchSearchParams,
|
|
15
|
+
type FetchSearchResponse,
|
|
16
|
+
type GetBatchedParams,
|
|
17
|
+
type GetBatchedResponse,
|
|
18
|
+
type RequestOptions,
|
|
19
|
+
} from './Service.js'
|
|
20
|
+
|
|
21
|
+
export type {
|
|
22
|
+
BatchedParams,
|
|
23
|
+
BatchedResponse,
|
|
24
|
+
FetchJsonParams,
|
|
25
|
+
FetchJsonRequestOptions,
|
|
26
|
+
FetchJsonResponse,
|
|
27
|
+
FetchParams,
|
|
28
|
+
FetchRequestOptions,
|
|
29
|
+
FetchResponse,
|
|
30
|
+
FetchSearchParams,
|
|
31
|
+
FetchSearchResponse,
|
|
32
|
+
GetBatchedParams,
|
|
33
|
+
GetBatchedResponse,
|
|
34
|
+
} from './Service.js'
|
|
35
|
+
|
|
36
|
+
/** Options for constructing an {@link ExpandClient}. Same shape as `ExpandServiceOptions`. */
|
|
37
|
+
export type ExpandClientOptions = ExpandServiceOptions
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Promise-based client for the Expand API. Holds an {@link InternalClient} layer and runs Effects
|
|
41
|
+
* against it, translating typed failures into the `ExpandClient*Error` hierarchy that async/await
|
|
42
|
+
* consumers expect.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const client = new ExpandClient({ apiKey: 'sk_...' })
|
|
47
|
+
* const result = await client.fetch({ url: 'https://example.com' })
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export class ExpandClient {
|
|
51
|
+
private readonly layer: Layer.Layer<InternalClient>
|
|
52
|
+
|
|
53
|
+
constructor(options: ExpandClientOptions = {}) {
|
|
54
|
+
// Eagerly validate so the Promise constructor matches the documented sync-throw contract.
|
|
55
|
+
// `buildServiceConfig` is a pure-sync Effect (env-var read + Schema.decode), so runSync is safe.
|
|
56
|
+
const result = Effect.runSync(buildServiceConfig(options).pipe(Effect.either))
|
|
57
|
+
if (Either.isLeft(result)) {
|
|
58
|
+
throw result.left.toPublicError()
|
|
59
|
+
}
|
|
60
|
+
// Validation passed; the layer's acquisition Effect re-runs the same logic, so it cannot fail.
|
|
61
|
+
// Layer.orDie narrows the error channel to `never` while keeping a die fallback as a defensive
|
|
62
|
+
// net (translateCause picks up dies via Cause.dieOption and converts via toPublicError).
|
|
63
|
+
this.layer = InternalClient.layer(options).pipe(Layer.orDie)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Fetch a URL through the Expand API.
|
|
68
|
+
*
|
|
69
|
+
* @throws {ExpandClientApiError} on 4xx/5xx responses
|
|
70
|
+
* @throws {ExpandClientTimeoutError} when the request exceeds `timeoutMs`
|
|
71
|
+
* @throws {ExpandClientConnectionError} on network failures
|
|
72
|
+
* @throws {ExpandClientError} for any other failure
|
|
73
|
+
*/
|
|
74
|
+
async fetch(params: FetchParams, options: FetchRequestOptions = {}): Promise<FetchResponse> {
|
|
75
|
+
return this.run((client) => client.fetch(params, options))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Fetch a URL through the object-mode endpoint.
|
|
80
|
+
*
|
|
81
|
+
* Returns `{ meta, markdown, json }`; use {@link fetch} for the raw markdown document.
|
|
82
|
+
*/
|
|
83
|
+
async fetchJson(params: FetchJsonParams, options: FetchJsonRequestOptions = {}): Promise<FetchJsonResponse> {
|
|
84
|
+
return this.run((client) => client.fetchJson(params, options))
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Search a previous Fetch response by `snapshotId` without starting a new capture.
|
|
89
|
+
*/
|
|
90
|
+
async fetchSearch(params: FetchSearchParams, options: RequestOptions = {}): Promise<FetchSearchResponse> {
|
|
91
|
+
return this.run((client) => client.fetchSearch(params, options))
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Kick off an asynchronous batched fetch over one or more URLs. Returns a batched-run ID that can
|
|
96
|
+
* be polled via {@link getBatched}.
|
|
97
|
+
*
|
|
98
|
+
* Retries are disabled by default. Pass `{ maxRetries: N }` to opt in.
|
|
99
|
+
*
|
|
100
|
+
* @throws {ExpandClientApiError} on 4xx/5xx responses
|
|
101
|
+
* @throws {ExpandClientTimeoutError} when the request exceeds `timeoutMs`
|
|
102
|
+
* @throws {ExpandClientConnectionError} on network failures
|
|
103
|
+
* @throws {ExpandClientError} for any other failure
|
|
104
|
+
*/
|
|
105
|
+
async batched(params: BatchedParams, options: RequestOptions = {}): Promise<BatchedResponse> {
|
|
106
|
+
return this.run((client) => client.batched(params, options))
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Fetch the status and accumulated results for a batched run previously started by {@link batched}.
|
|
111
|
+
*
|
|
112
|
+
* @throws {ExpandClientApiError} on 4xx/5xx responses
|
|
113
|
+
* @throws {ExpandClientTimeoutError} when the request exceeds `timeoutMs`
|
|
114
|
+
* @throws {ExpandClientConnectionError} on network failures
|
|
115
|
+
* @throws {ExpandClientError} for any other failure
|
|
116
|
+
*/
|
|
117
|
+
async getBatched(id: string, options: GetBatchedParams & RequestOptions = {}): Promise<GetBatchedResponse> {
|
|
118
|
+
return this.run((client) => client.getBatched(id, options))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private async run<A>(body: (ic: InternalClient) => Effect.Effect<A, Error>): Promise<A> {
|
|
122
|
+
const exit = await Effect.runPromiseExit(InternalClient.use(body).pipe(Effect.provide(this.layer)))
|
|
123
|
+
if (Exit.isSuccess(exit)) {
|
|
124
|
+
return exit.value
|
|
125
|
+
}
|
|
126
|
+
throw InternalClient.translateCause(exit.cause)
|
|
127
|
+
}
|
|
128
|
+
}
|
package/src/Error.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Schema } from 'effect'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Effect-side base error. Schema.TaggedError; Effect consumers receive these in the error channel.
|
|
5
|
+
*/
|
|
6
|
+
export class ExpandSdkError extends Schema.TaggedError<ExpandSdkError>()('ExpandSdkError', {
|
|
7
|
+
message: Schema.String,
|
|
8
|
+
cause: Schema.optional(Schema.Defect),
|
|
9
|
+
}) {
|
|
10
|
+
toPublicError() {
|
|
11
|
+
return new ExpandClientError(this.message, { cause: this.cause })
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Effect-side error for non-2xx API responses. Inspect `status` and `body` for details.
|
|
17
|
+
*/
|
|
18
|
+
export class ExpandApiError extends Schema.TaggedError<ExpandApiError>()('ExpandApiError', {
|
|
19
|
+
message: Schema.String,
|
|
20
|
+
status: Schema.Number,
|
|
21
|
+
body: Schema.optional(Schema.Unknown),
|
|
22
|
+
cause: Schema.optional(Schema.Defect),
|
|
23
|
+
}) {
|
|
24
|
+
toPublicError() {
|
|
25
|
+
return new ExpandClientApiError(this.message, { status: this.status, body: this.body, cause: this.cause })
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Effect-side error when the SDK cannot reach the API (DNS, connection refused, socket reset, etc.).
|
|
31
|
+
*/
|
|
32
|
+
export class ExpandConnectionError extends Schema.TaggedError<ExpandConnectionError>()('ExpandConnectionError', {
|
|
33
|
+
message: Schema.String,
|
|
34
|
+
cause: Schema.optional(Schema.Defect),
|
|
35
|
+
}) {
|
|
36
|
+
toPublicError() {
|
|
37
|
+
return new ExpandClientConnectionError(this.message, { cause: this.cause })
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Effect-side error when a request exceeds its configured `timeoutMs`.
|
|
43
|
+
*/
|
|
44
|
+
export class ExpandTimeoutError extends Schema.TaggedError<ExpandTimeoutError>()('ExpandTimeoutError', {
|
|
45
|
+
message: Schema.String,
|
|
46
|
+
timeoutMs: Schema.Number,
|
|
47
|
+
cause: Schema.optional(Schema.Defect),
|
|
48
|
+
}) {
|
|
49
|
+
toPublicError() {
|
|
50
|
+
return new ExpandClientTimeoutError(this.message, { timeoutMs: this.timeoutMs, cause: this.cause })
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Union of every error the Effect-side `ExpandService` can fail with.
|
|
56
|
+
*/
|
|
57
|
+
export type ExpandError = ExpandSdkError | ExpandApiError | ExpandConnectionError | ExpandTimeoutError
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Promise-side base class. Catch this to handle any failure thrown by `ExpandClient`.
|
|
61
|
+
*/
|
|
62
|
+
export class ExpandClientError extends Error {
|
|
63
|
+
constructor(message: string, options: ErrorOptions = {}) {
|
|
64
|
+
super(message, options)
|
|
65
|
+
this.name = 'ExpandClientError'
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Promise-side error for non-2xx API responses. Inspect `status` and `body` for details.
|
|
71
|
+
*/
|
|
72
|
+
export class ExpandClientApiError extends ExpandClientError {
|
|
73
|
+
readonly status: number
|
|
74
|
+
readonly body: unknown
|
|
75
|
+
|
|
76
|
+
constructor(message: string, options: ErrorOptions & { readonly status: number; readonly body?: unknown }) {
|
|
77
|
+
super(message, options)
|
|
78
|
+
this.name = 'ExpandClientApiError'
|
|
79
|
+
this.status = options.status
|
|
80
|
+
this.body = options.body
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Promise-side error when the SDK cannot reach the API (DNS, connection refused, socket reset, etc.).
|
|
86
|
+
*/
|
|
87
|
+
export class ExpandClientConnectionError extends ExpandClientError {
|
|
88
|
+
constructor(message: string, options: ErrorOptions = {}) {
|
|
89
|
+
super(message, options)
|
|
90
|
+
this.name = 'ExpandClientConnectionError'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Promise-side error when a request exceeds its configured `timeoutMs`.
|
|
96
|
+
*/
|
|
97
|
+
export class ExpandClientTimeoutError extends ExpandClientConnectionError {
|
|
98
|
+
readonly timeoutMs: number
|
|
99
|
+
|
|
100
|
+
constructor(message: string, options: ErrorOptions & { readonly timeoutMs: number }) {
|
|
101
|
+
super(message, options)
|
|
102
|
+
this.name = 'ExpandClientTimeoutError'
|
|
103
|
+
this.timeoutMs = options.timeoutMs
|
|
104
|
+
}
|
|
105
|
+
}
|
package/src/FetchJson.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// `json`-recovering decode for the fetch JSON-mode and snapshot-search endpoints.
|
|
2
|
+
//
|
|
3
|
+
// The OpenAPI spec declares `json` on each search snippet (the extracted State JSON value), but
|
|
4
|
+
// the code generator drops the bare `unknown`-typed field, so `Generated.FetchObjectModeResult`
|
|
5
|
+
// / `Generated.FetchSnapshotSearchResult` decode it away. These hand-written schemas re-add
|
|
6
|
+
// `json`, and the request functions mirror the generated client but decode the 200 body with
|
|
7
|
+
// them — so callers that need to surface the cited JSON get it. Kept out of `Generated.ts` so the
|
|
8
|
+
// OpenAPI conformance test (which checks the generated schemas) is unaffected.
|
|
9
|
+
|
|
10
|
+
import { HttpClient, HttpClientRequest, HttpClientResponse } from '@effect/platform'
|
|
11
|
+
import * as Generated from '@expandai/sdk/Generated'
|
|
12
|
+
import { decodeError, unexpectedStatus } from '@expandai/sdk/HttpClientHelpers'
|
|
13
|
+
import { Effect, Schema as S } from 'effect'
|
|
14
|
+
|
|
15
|
+
/** Search snippet with the extracted `json` value preserved (statejson snippets only). */
|
|
16
|
+
export const FetchSearchSnippetWithJson = S.Struct({
|
|
17
|
+
type: S.optionalWith(S.Literal('text'), { nullable: true, default: () => 'text' as const }),
|
|
18
|
+
source: S.Literal('markdown', 'appendix', 'statejson'),
|
|
19
|
+
text: S.String,
|
|
20
|
+
json: S.optionalWith(S.Unknown, { nullable: true }),
|
|
21
|
+
score: S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)),
|
|
22
|
+
location: S.optionalWith(Generated.FetchSearchSnippetLocation, { nullable: true }),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
export const FetchSearchResultWithJson = S.Struct({
|
|
26
|
+
query: S.String,
|
|
27
|
+
snippets: S.Array(FetchSearchSnippetWithJson),
|
|
28
|
+
meta: S.optionalWith(Generated.FetchSearchMeta, { nullable: true }),
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
export class FetchObjectModeResultWithJson extends S.Class<FetchObjectModeResultWithJson>(
|
|
32
|
+
'FetchObjectModeResultWithJson',
|
|
33
|
+
)({
|
|
34
|
+
meta: Generated.FetchObjectModeMeta,
|
|
35
|
+
markdown: S.String,
|
|
36
|
+
json: S.Array(Generated.FetchObjectModeEvidence),
|
|
37
|
+
data: S.optionalWith(
|
|
38
|
+
S.Struct({
|
|
39
|
+
assets: S.optionalWith(S.Array(Generated.FetchAssetReference), { nullable: true }),
|
|
40
|
+
captureTelemetry: S.optionalWith(Generated.CaptureTelemetryInfo, { nullable: true }),
|
|
41
|
+
search: S.optionalWith(FetchSearchResultWithJson, { nullable: true }),
|
|
42
|
+
}),
|
|
43
|
+
{ nullable: true },
|
|
44
|
+
),
|
|
45
|
+
}) {}
|
|
46
|
+
|
|
47
|
+
export class FetchSnapshotSearchResultWithJson extends S.Class<FetchSnapshotSearchResultWithJson>(
|
|
48
|
+
'FetchSnapshotSearchResultWithJson',
|
|
49
|
+
)({
|
|
50
|
+
snapshotId: S.String.pipe(S.minLength(1)),
|
|
51
|
+
response: Generated.ResponseInfo,
|
|
52
|
+
search: FetchSearchResultWithJson,
|
|
53
|
+
durationMs: S.Number.pipe(S.greaterThanOrEqualTo(0)),
|
|
54
|
+
}) {}
|
|
55
|
+
|
|
56
|
+
/** Mirrors `Generated.Client['fetchFetchJson']` but decodes the 200 body with `json` preserved. */
|
|
57
|
+
export const fetchObjectModeJson = (
|
|
58
|
+
httpClient: HttpClient.HttpClient,
|
|
59
|
+
options: {
|
|
60
|
+
readonly params: typeof Generated.FetchFetchJsonParams.Encoded
|
|
61
|
+
readonly payload: typeof Generated.FetchFetchJsonRequest.Encoded
|
|
62
|
+
},
|
|
63
|
+
) =>
|
|
64
|
+
HttpClientRequest.make('POST')('/v1/fetch/json').pipe(
|
|
65
|
+
HttpClientRequest.setUrlParams(options.params.include !== undefined ? { include: options.params.include } : {}),
|
|
66
|
+
(request) => Effect.orDie(HttpClientRequest.bodyJson(request, options.payload)),
|
|
67
|
+
Effect.flatMap((request) =>
|
|
68
|
+
Effect.flatMap(
|
|
69
|
+
httpClient.execute(request),
|
|
70
|
+
HttpClientResponse.matchStatus({
|
|
71
|
+
'200': (response) => HttpClientResponse.schemaBodyJson(FetchObjectModeResultWithJson)(response),
|
|
72
|
+
'400': (response) => decodeError(response, Generated.FetchFetchJson400),
|
|
73
|
+
'401': (response) => decodeError(response, Generated.AuthFailed),
|
|
74
|
+
'403': (response) => decodeError(response, Generated.FetchFetchJson403),
|
|
75
|
+
'413': (response) => decodeError(response, Generated.PayloadTooLarge),
|
|
76
|
+
'429': (response) => decodeError(response, Generated.TooManyRequests),
|
|
77
|
+
'500': (response) => decodeError(response, Generated.InternalError),
|
|
78
|
+
'503': (response) => decodeError(response, Generated.ServiceUnavailable),
|
|
79
|
+
orElse: (response) => unexpectedStatus(request, response),
|
|
80
|
+
}),
|
|
81
|
+
),
|
|
82
|
+
),
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
/** Mirrors `Generated.Client['fetchFetchSearch']` but decodes the 200 body with `json` preserved. */
|
|
86
|
+
export const fetchSnapshotSearch = (
|
|
87
|
+
httpClient: HttpClient.HttpClient,
|
|
88
|
+
options: typeof Generated.FetchFetchSearchRequest.Encoded,
|
|
89
|
+
) =>
|
|
90
|
+
HttpClientRequest.make('POST')('/v1/fetch/search').pipe(
|
|
91
|
+
(request) => Effect.orDie(HttpClientRequest.bodyJson(request, options)),
|
|
92
|
+
Effect.flatMap((request) =>
|
|
93
|
+
Effect.flatMap(
|
|
94
|
+
httpClient.execute(request),
|
|
95
|
+
HttpClientResponse.matchStatus({
|
|
96
|
+
'200': (response) => HttpClientResponse.schemaBodyJson(FetchSnapshotSearchResultWithJson)(response),
|
|
97
|
+
'400': (response) => decodeError(response, Generated.FetchFetchSearch400),
|
|
98
|
+
'401': (response) => decodeError(response, Generated.AuthFailed),
|
|
99
|
+
'403': (response) => decodeError(response, Generated.FetchFetchSearch403),
|
|
100
|
+
'404': (response) => decodeError(response, Generated.FetchSnapshotSearchNotFound),
|
|
101
|
+
'413': (response) => decodeError(response, Generated.PayloadTooLarge),
|
|
102
|
+
'429': (response) => decodeError(response, Generated.TooManyRequests),
|
|
103
|
+
'500': (response) => decodeError(response, Generated.InternalError),
|
|
104
|
+
'503': (response) => decodeError(response, Generated.ServiceUnavailable),
|
|
105
|
+
orElse: (response) => unexpectedStatus(request, response),
|
|
106
|
+
}),
|
|
107
|
+
),
|
|
108
|
+
),
|
|
109
|
+
)
|