@credal/sdk 0.1.13 → 0.1.16
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/dist/cjs/BaseClient.d.ts +7 -7
- package/dist/cjs/BaseClient.js +7 -3
- package/dist/cjs/Client.d.ts +1 -2
- package/dist/cjs/api/resources/copilots/client/Client.d.ts +21 -2
- package/dist/cjs/api/resources/copilots/client/Client.js +62 -134
- package/dist/cjs/api/resources/copilots/client/requests/ExportCopilotsRequest.d.ts +21 -0
- package/dist/cjs/api/resources/copilots/client/requests/ExportCopilotsRequest.js +3 -0
- package/dist/cjs/api/resources/copilots/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/copilots/types/ExportCopilotsResponse.d.ts +9 -0
- package/dist/cjs/api/resources/copilots/types/ExportCopilotsResponse.js +3 -0
- package/dist/cjs/api/resources/copilots/types/ExportedCopilot.d.ts +24 -0
- package/dist/cjs/api/resources/copilots/types/ExportedCopilot.js +3 -0
- package/dist/cjs/api/resources/copilots/types/index.d.ts +2 -0
- package/dist/cjs/api/resources/copilots/types/index.js +2 -0
- package/dist/cjs/api/resources/documentCatalog/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/documentCatalog/client/Client.js +5 -60
- package/dist/cjs/api/resources/documentCollections/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/documentCollections/client/Client.js +8 -105
- package/dist/cjs/api/resources/search/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/search/client/Client.js +2 -15
- package/dist/cjs/api/resources/users/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/users/client/Client.js +2 -15
- package/dist/cjs/auth/BearerAuthProvider.d.ts +4 -2
- package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
- package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
- package/dist/cjs/core/auth/index.d.ts +1 -0
- package/dist/cjs/core/auth/index.js +3 -1
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +6 -7
- package/dist/cjs/core/fetcher/Fetcher.d.ts +5 -1
- package/dist/cjs/core/fetcher/Fetcher.js +2 -1
- package/dist/cjs/core/fetcher/getResponseBody.js +18 -4
- package/dist/cjs/core/fetcher/signals.d.ts +1 -1
- package/dist/cjs/core/runtime/runtime.js +11 -10
- package/dist/cjs/errors/CredalError.js +5 -1
- package/dist/cjs/errors/CredalTimeoutError.js +5 -1
- package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
- package/dist/cjs/errors/handleNonStatusCodeError.js +65 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +7 -7
- package/dist/esm/BaseClient.mjs +7 -3
- package/dist/esm/Client.d.mts +1 -2
- package/dist/esm/api/resources/copilots/client/Client.d.mts +21 -2
- package/dist/esm/api/resources/copilots/client/Client.mjs +62 -134
- package/dist/esm/api/resources/copilots/client/requests/ExportCopilotsRequest.d.mts +21 -0
- package/dist/esm/api/resources/copilots/client/requests/ExportCopilotsRequest.mjs +2 -0
- package/dist/esm/api/resources/copilots/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/copilots/types/ExportCopilotsResponse.d.mts +9 -0
- package/dist/esm/api/resources/copilots/types/ExportCopilotsResponse.mjs +2 -0
- package/dist/esm/api/resources/copilots/types/ExportedCopilot.d.mts +24 -0
- package/dist/esm/api/resources/copilots/types/ExportedCopilot.mjs +2 -0
- package/dist/esm/api/resources/copilots/types/index.d.mts +2 -0
- package/dist/esm/api/resources/copilots/types/index.mjs +2 -0
- package/dist/esm/api/resources/documentCatalog/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/documentCatalog/client/Client.mjs +5 -60
- package/dist/esm/api/resources/documentCollections/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/documentCollections/client/Client.mjs +8 -105
- package/dist/esm/api/resources/search/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/search/client/Client.mjs +2 -15
- package/dist/esm/api/resources/users/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/users/client/Client.mjs +2 -15
- package/dist/esm/auth/BearerAuthProvider.d.mts +4 -2
- package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
- package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
- package/dist/esm/core/auth/index.d.mts +1 -0
- package/dist/esm/core/auth/index.mjs +1 -0
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +6 -7
- package/dist/esm/core/fetcher/Fetcher.d.mts +5 -1
- package/dist/esm/core/fetcher/Fetcher.mjs +2 -1
- package/dist/esm/core/fetcher/getResponseBody.mjs +18 -4
- package/dist/esm/core/fetcher/signals.d.mts +1 -1
- package/dist/esm/core/runtime/runtime.mjs +11 -10
- package/dist/esm/errors/CredalError.mjs +5 -1
- package/dist/esm/errors/CredalTimeoutError.mjs +5 -1
- package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
- package/dist/esm/errors/handleNonStatusCodeError.mjs +29 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +5 -2
- package/reference.md +72 -0
- package/dist/cjs/core/fetcher/ResponseWithBody.d.ts +0 -4
- package/dist/cjs/core/fetcher/ResponseWithBody.js +0 -6
- package/dist/esm/core/fetcher/ResponseWithBody.d.mts +0 -4
- package/dist/esm/core/fetcher/ResponseWithBody.mjs +0 -3
|
@@ -12,6 +12,7 @@ import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
|
12
12
|
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
13
13
|
import * as core from "../../../../core/index.mjs";
|
|
14
14
|
import * as environments from "../../../../environments.mjs";
|
|
15
|
+
import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
|
|
15
16
|
import * as errors from "../../../../errors/index.mjs";
|
|
16
17
|
export class DocumentCollectionsClient {
|
|
17
18
|
constructor(options = {}) {
|
|
@@ -69,21 +70,7 @@ export class DocumentCollectionsClient {
|
|
|
69
70
|
rawResponse: _response.rawResponse,
|
|
70
71
|
});
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
case "non-json":
|
|
74
|
-
throw new errors.CredalError({
|
|
75
|
-
statusCode: _response.error.statusCode,
|
|
76
|
-
body: _response.error.rawBody,
|
|
77
|
-
rawResponse: _response.rawResponse,
|
|
78
|
-
});
|
|
79
|
-
case "timeout":
|
|
80
|
-
throw new errors.CredalTimeoutError("Timeout exceeded when calling POST /v0/documentCollections/addDocumentsToCollection.");
|
|
81
|
-
case "unknown":
|
|
82
|
-
throw new errors.CredalError({
|
|
83
|
-
message: _response.error.errorMessage,
|
|
84
|
-
rawResponse: _response.rawResponse,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
73
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v0/documentCollections/addDocumentsToCollection");
|
|
87
74
|
});
|
|
88
75
|
}
|
|
89
76
|
/**
|
|
@@ -138,21 +125,7 @@ export class DocumentCollectionsClient {
|
|
|
138
125
|
rawResponse: _response.rawResponse,
|
|
139
126
|
});
|
|
140
127
|
}
|
|
141
|
-
|
|
142
|
-
case "non-json":
|
|
143
|
-
throw new errors.CredalError({
|
|
144
|
-
statusCode: _response.error.statusCode,
|
|
145
|
-
body: _response.error.rawBody,
|
|
146
|
-
rawResponse: _response.rawResponse,
|
|
147
|
-
});
|
|
148
|
-
case "timeout":
|
|
149
|
-
throw new errors.CredalTimeoutError("Timeout exceeded when calling DELETE /v0/documentCollections/removeDocumentsFromCollection.");
|
|
150
|
-
case "unknown":
|
|
151
|
-
throw new errors.CredalError({
|
|
152
|
-
message: _response.error.errorMessage,
|
|
153
|
-
rawResponse: _response.rawResponse,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
128
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v0/documentCollections/removeDocumentsFromCollection");
|
|
156
129
|
});
|
|
157
130
|
}
|
|
158
131
|
/**
|
|
@@ -201,21 +174,7 @@ export class DocumentCollectionsClient {
|
|
|
201
174
|
rawResponse: _response.rawResponse,
|
|
202
175
|
});
|
|
203
176
|
}
|
|
204
|
-
|
|
205
|
-
case "non-json":
|
|
206
|
-
throw new errors.CredalError({
|
|
207
|
-
statusCode: _response.error.statusCode,
|
|
208
|
-
body: _response.error.rawBody,
|
|
209
|
-
rawResponse: _response.rawResponse,
|
|
210
|
-
});
|
|
211
|
-
case "timeout":
|
|
212
|
-
throw new errors.CredalTimeoutError("Timeout exceeded when calling GET /v0/documentCollections/listDocumentsInCollection.");
|
|
213
|
-
case "unknown":
|
|
214
|
-
throw new errors.CredalError({
|
|
215
|
-
message: _response.error.errorMessage,
|
|
216
|
-
rawResponse: _response.rawResponse,
|
|
217
|
-
});
|
|
218
|
-
}
|
|
177
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v0/documentCollections/listDocumentsInCollection");
|
|
219
178
|
});
|
|
220
179
|
}
|
|
221
180
|
/**
|
|
@@ -266,21 +225,7 @@ export class DocumentCollectionsClient {
|
|
|
266
225
|
rawResponse: _response.rawResponse,
|
|
267
226
|
});
|
|
268
227
|
}
|
|
269
|
-
|
|
270
|
-
case "non-json":
|
|
271
|
-
throw new errors.CredalError({
|
|
272
|
-
statusCode: _response.error.statusCode,
|
|
273
|
-
body: _response.error.rawBody,
|
|
274
|
-
rawResponse: _response.rawResponse,
|
|
275
|
-
});
|
|
276
|
-
case "timeout":
|
|
277
|
-
throw new errors.CredalTimeoutError("Timeout exceeded when calling POST /v0/documentCollections/createCollection.");
|
|
278
|
-
case "unknown":
|
|
279
|
-
throw new errors.CredalError({
|
|
280
|
-
message: _response.error.errorMessage,
|
|
281
|
-
rawResponse: _response.rawResponse,
|
|
282
|
-
});
|
|
283
|
-
}
|
|
228
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v0/documentCollections/createCollection");
|
|
284
229
|
});
|
|
285
230
|
}
|
|
286
231
|
/**
|
|
@@ -326,21 +271,7 @@ export class DocumentCollectionsClient {
|
|
|
326
271
|
rawResponse: _response.rawResponse,
|
|
327
272
|
});
|
|
328
273
|
}
|
|
329
|
-
|
|
330
|
-
case "non-json":
|
|
331
|
-
throw new errors.CredalError({
|
|
332
|
-
statusCode: _response.error.statusCode,
|
|
333
|
-
body: _response.error.rawBody,
|
|
334
|
-
rawResponse: _response.rawResponse,
|
|
335
|
-
});
|
|
336
|
-
case "timeout":
|
|
337
|
-
throw new errors.CredalTimeoutError("Timeout exceeded when calling DELETE /v0/documentCollections/deleteCollection.");
|
|
338
|
-
case "unknown":
|
|
339
|
-
throw new errors.CredalError({
|
|
340
|
-
message: _response.error.errorMessage,
|
|
341
|
-
rawResponse: _response.rawResponse,
|
|
342
|
-
});
|
|
343
|
-
}
|
|
274
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v0/documentCollections/deleteCollection");
|
|
344
275
|
});
|
|
345
276
|
}
|
|
346
277
|
/**
|
|
@@ -402,21 +333,7 @@ export class DocumentCollectionsClient {
|
|
|
402
333
|
rawResponse: _response.rawResponse,
|
|
403
334
|
});
|
|
404
335
|
}
|
|
405
|
-
|
|
406
|
-
case "non-json":
|
|
407
|
-
throw new errors.CredalError({
|
|
408
|
-
statusCode: _response.error.statusCode,
|
|
409
|
-
body: _response.error.rawBody,
|
|
410
|
-
rawResponse: _response.rawResponse,
|
|
411
|
-
});
|
|
412
|
-
case "timeout":
|
|
413
|
-
throw new errors.CredalTimeoutError("Timeout exceeded when calling POST /v0/documentCollections/mongodb/createMongoSync.");
|
|
414
|
-
case "unknown":
|
|
415
|
-
throw new errors.CredalError({
|
|
416
|
-
message: _response.error.errorMessage,
|
|
417
|
-
rawResponse: _response.rawResponse,
|
|
418
|
-
});
|
|
419
|
-
}
|
|
336
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v0/documentCollections/mongodb/createMongoSync");
|
|
420
337
|
});
|
|
421
338
|
}
|
|
422
339
|
/**
|
|
@@ -478,21 +395,7 @@ export class DocumentCollectionsClient {
|
|
|
478
395
|
rawResponse: _response.rawResponse,
|
|
479
396
|
});
|
|
480
397
|
}
|
|
481
|
-
|
|
482
|
-
case "non-json":
|
|
483
|
-
throw new errors.CredalError({
|
|
484
|
-
statusCode: _response.error.statusCode,
|
|
485
|
-
body: _response.error.rawBody,
|
|
486
|
-
rawResponse: _response.rawResponse,
|
|
487
|
-
});
|
|
488
|
-
case "timeout":
|
|
489
|
-
throw new errors.CredalTimeoutError("Timeout exceeded when calling POST /v0/documentCollections/mongodb/updateMongoSync.");
|
|
490
|
-
case "unknown":
|
|
491
|
-
throw new errors.CredalError({
|
|
492
|
-
message: _response.error.errorMessage,
|
|
493
|
-
rawResponse: _response.rawResponse,
|
|
494
|
-
});
|
|
495
|
-
}
|
|
398
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v0/documentCollections/mongodb/updateMongoSync");
|
|
496
399
|
});
|
|
497
400
|
}
|
|
498
401
|
}
|
|
@@ -3,8 +3,7 @@ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs
|
|
|
3
3
|
import * as core from "../../../../core/index.mjs";
|
|
4
4
|
import type * as Credal from "../../../index.mjs";
|
|
5
5
|
export declare namespace SearchClient {
|
|
6
|
-
|
|
7
|
-
}
|
|
6
|
+
type Options = BaseClientOptions;
|
|
8
7
|
interface RequestOptions extends BaseRequestOptions {
|
|
9
8
|
}
|
|
10
9
|
}
|
|
@@ -12,6 +12,7 @@ import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
|
12
12
|
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
13
13
|
import * as core from "../../../../core/index.mjs";
|
|
14
14
|
import * as environments from "../../../../environments.mjs";
|
|
15
|
+
import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
|
|
15
16
|
import * as errors from "../../../../errors/index.mjs";
|
|
16
17
|
export class SearchClient {
|
|
17
18
|
constructor(options = {}) {
|
|
@@ -78,21 +79,7 @@ export class SearchClient {
|
|
|
78
79
|
rawResponse: _response.rawResponse,
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
-
case "non-json":
|
|
83
|
-
throw new errors.CredalError({
|
|
84
|
-
statusCode: _response.error.statusCode,
|
|
85
|
-
body: _response.error.rawBody,
|
|
86
|
-
rawResponse: _response.rawResponse,
|
|
87
|
-
});
|
|
88
|
-
case "timeout":
|
|
89
|
-
throw new errors.CredalTimeoutError("Timeout exceeded when calling POST /v0/search/searchDocumentCollection.");
|
|
90
|
-
case "unknown":
|
|
91
|
-
throw new errors.CredalError({
|
|
92
|
-
message: _response.error.errorMessage,
|
|
93
|
-
rawResponse: _response.rawResponse,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
82
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v0/search/searchDocumentCollection");
|
|
96
83
|
});
|
|
97
84
|
}
|
|
98
85
|
}
|
|
@@ -3,8 +3,7 @@ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs
|
|
|
3
3
|
import * as core from "../../../../core/index.mjs";
|
|
4
4
|
import type * as Credal from "../../../index.mjs";
|
|
5
5
|
export declare namespace UsersClient {
|
|
6
|
-
|
|
7
|
-
}
|
|
6
|
+
type Options = BaseClientOptions;
|
|
8
7
|
interface RequestOptions extends BaseRequestOptions {
|
|
9
8
|
}
|
|
10
9
|
}
|
|
@@ -12,6 +12,7 @@ import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
|
12
12
|
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
13
13
|
import * as core from "../../../../core/index.mjs";
|
|
14
14
|
import * as environments from "../../../../environments.mjs";
|
|
15
|
+
import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
|
|
15
16
|
import * as errors from "../../../../errors/index.mjs";
|
|
16
17
|
export class UsersClient {
|
|
17
18
|
constructor(options = {}) {
|
|
@@ -70,21 +71,7 @@ export class UsersClient {
|
|
|
70
71
|
rawResponse: _response.rawResponse,
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
case "non-json":
|
|
75
|
-
throw new errors.CredalError({
|
|
76
|
-
statusCode: _response.error.statusCode,
|
|
77
|
-
body: _response.error.rawBody,
|
|
78
|
-
rawResponse: _response.rawResponse,
|
|
79
|
-
});
|
|
80
|
-
case "timeout":
|
|
81
|
-
throw new errors.CredalTimeoutError("Timeout exceeded when calling PATCH /v0/users/metadata.");
|
|
82
|
-
case "unknown":
|
|
83
|
-
throw new errors.CredalError({
|
|
84
|
-
message: _response.error.errorMessage,
|
|
85
|
-
rawResponse: _response.rawResponse,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
74
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/v0/users/metadata");
|
|
88
75
|
});
|
|
89
76
|
}
|
|
90
77
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as core from "../core/index.mjs";
|
|
2
2
|
export declare namespace BearerAuthProvider {
|
|
3
|
-
interface
|
|
4
|
-
apiKey?: core.Supplier<core.BearerToken | undefined
|
|
3
|
+
interface AuthOptions {
|
|
4
|
+
apiKey?: core.Supplier<core.BearerToken> | undefined;
|
|
5
|
+
}
|
|
6
|
+
interface Options extends AuthOptions {
|
|
5
7
|
}
|
|
6
8
|
}
|
|
7
9
|
export declare class BearerAuthProvider implements core.AuthProvider {
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import type { ResponseWithBody } from "./ResponseWithBody.mjs";
|
|
2
1
|
export type BinaryResponse = {
|
|
3
2
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
|
|
4
|
-
bodyUsed:
|
|
3
|
+
bodyUsed: Response["bodyUsed"];
|
|
5
4
|
/**
|
|
6
5
|
* Returns a ReadableStream of the response body.
|
|
7
6
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body)
|
|
8
7
|
*/
|
|
9
|
-
stream: () =>
|
|
8
|
+
stream: () => Response["body"];
|
|
10
9
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
|
|
11
|
-
arrayBuffer: () =>
|
|
10
|
+
arrayBuffer: () => ReturnType<Response["arrayBuffer"]>;
|
|
12
11
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
|
|
13
|
-
blob: () =>
|
|
12
|
+
blob: () => ReturnType<Response["blob"]>;
|
|
14
13
|
/**
|
|
15
14
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
|
|
16
15
|
* Some versions of the Fetch API may not support this method.
|
|
17
16
|
*/
|
|
18
|
-
bytes?():
|
|
17
|
+
bytes?(): ReturnType<Response["bytes"]>;
|
|
19
18
|
};
|
|
20
|
-
export declare function getBinaryResponse(response:
|
|
19
|
+
export declare function getBinaryResponse(response: Response): BinaryResponse;
|
|
@@ -22,7 +22,7 @@ export declare namespace Fetcher {
|
|
|
22
22
|
fetchFn?: typeof fetch;
|
|
23
23
|
logging?: LogConfig | Logger;
|
|
24
24
|
}
|
|
25
|
-
type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
|
|
25
|
+
type Error = FailedStatusCodeError | NonJsonError | BodyIsNullError | TimeoutError | UnknownError;
|
|
26
26
|
interface FailedStatusCodeError {
|
|
27
27
|
reason: "status-code";
|
|
28
28
|
statusCode: number;
|
|
@@ -33,6 +33,10 @@ export declare namespace Fetcher {
|
|
|
33
33
|
statusCode: number;
|
|
34
34
|
rawBody: string;
|
|
35
35
|
}
|
|
36
|
+
interface BodyIsNullError {
|
|
37
|
+
reason: "body-is-null";
|
|
38
|
+
statusCode: number;
|
|
39
|
+
}
|
|
36
40
|
interface TimeoutError {
|
|
37
41
|
reason: "timeout";
|
|
38
42
|
}
|
|
@@ -208,9 +208,10 @@ export function fetcherImpl(args) {
|
|
|
208
208
|
};
|
|
209
209
|
logger.debug("HTTP request succeeded", metadata);
|
|
210
210
|
}
|
|
211
|
+
const body = yield getResponseBody(response, args.responseType);
|
|
211
212
|
return {
|
|
212
213
|
ok: true,
|
|
213
|
-
body:
|
|
214
|
+
body: body,
|
|
214
215
|
headers: response.headers,
|
|
215
216
|
rawResponse: toRawResponse(response),
|
|
216
217
|
};
|
|
@@ -9,12 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { fromJson } from "../json.mjs";
|
|
11
11
|
import { getBinaryResponse } from "./BinaryResponse.mjs";
|
|
12
|
-
import { isResponseWithBody } from "./ResponseWithBody.mjs";
|
|
13
12
|
export function getResponseBody(response, responseType) {
|
|
14
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
if (!isResponseWithBody(response)) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
14
|
switch (responseType) {
|
|
19
15
|
case "binary-response":
|
|
20
16
|
return getBinaryResponse(response);
|
|
@@ -23,8 +19,26 @@ export function getResponseBody(response, responseType) {
|
|
|
23
19
|
case "arrayBuffer":
|
|
24
20
|
return yield response.arrayBuffer();
|
|
25
21
|
case "sse":
|
|
22
|
+
if (response.body == null) {
|
|
23
|
+
return {
|
|
24
|
+
ok: false,
|
|
25
|
+
error: {
|
|
26
|
+
reason: "body-is-null",
|
|
27
|
+
statusCode: response.status,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
26
31
|
return response.body;
|
|
27
32
|
case "streaming":
|
|
33
|
+
if (response.body == null) {
|
|
34
|
+
return {
|
|
35
|
+
ok: false,
|
|
36
|
+
error: {
|
|
37
|
+
reason: "body-is-null",
|
|
38
|
+
statusCode: response.status,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
28
42
|
return response.body;
|
|
29
43
|
case "text":
|
|
30
44
|
return yield response.text();
|
|
@@ -68,6 +68,17 @@ function evaluateRuntime() {
|
|
|
68
68
|
version: Bun.version,
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* A constant that indicates whether the environment the code is running is in React-Native.
|
|
73
|
+
* This check should come before Node.js detection since React Native may have a process polyfill.
|
|
74
|
+
* https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
|
|
75
|
+
*/
|
|
76
|
+
const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
|
|
77
|
+
if (isReactNative) {
|
|
78
|
+
return {
|
|
79
|
+
type: "react-native",
|
|
80
|
+
};
|
|
81
|
+
}
|
|
71
82
|
/**
|
|
72
83
|
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
73
84
|
*/
|
|
@@ -83,16 +94,6 @@ function evaluateRuntime() {
|
|
|
83
94
|
parsedVersion: Number(process.versions.node.split(".")[0]),
|
|
84
95
|
};
|
|
85
96
|
}
|
|
86
|
-
/**
|
|
87
|
-
* A constant that indicates whether the environment the code is running is in React-Native.
|
|
88
|
-
* https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
|
|
89
|
-
*/
|
|
90
|
-
const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
|
|
91
|
-
if (isReactNative) {
|
|
92
|
-
return {
|
|
93
|
-
type: "react-native",
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
97
|
return {
|
|
97
98
|
type: "unknown",
|
|
98
99
|
};
|
|
@@ -3,7 +3,11 @@ import { toJson } from "../core/json.mjs";
|
|
|
3
3
|
export class CredalError extends Error {
|
|
4
4
|
constructor({ message, statusCode, body, rawResponse, }) {
|
|
5
5
|
super(buildMessage({ message, statusCode, body }));
|
|
6
|
-
Object.setPrototypeOf(this,
|
|
6
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
7
|
+
if (Error.captureStackTrace) {
|
|
8
|
+
Error.captureStackTrace(this, this.constructor);
|
|
9
|
+
}
|
|
10
|
+
this.name = this.constructor.name;
|
|
7
11
|
this.statusCode = statusCode;
|
|
8
12
|
this.body = body;
|
|
9
13
|
this.rawResponse = rawResponse;
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
export class CredalTimeoutError extends Error {
|
|
3
3
|
constructor(message) {
|
|
4
4
|
super(message);
|
|
5
|
-
Object.setPrototypeOf(this,
|
|
5
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
6
|
+
if (Error.captureStackTrace) {
|
|
7
|
+
Error.captureStackTrace(this, this.constructor);
|
|
8
|
+
}
|
|
9
|
+
this.name = this.constructor.name;
|
|
6
10
|
}
|
|
7
11
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import * as errors from "./index.mjs";
|
|
3
|
+
export function handleNonStatusCodeError(error, rawResponse, method, path) {
|
|
4
|
+
switch (error.reason) {
|
|
5
|
+
case "non-json":
|
|
6
|
+
throw new errors.CredalError({
|
|
7
|
+
statusCode: error.statusCode,
|
|
8
|
+
body: error.rawBody,
|
|
9
|
+
rawResponse: rawResponse,
|
|
10
|
+
});
|
|
11
|
+
case "body-is-null":
|
|
12
|
+
throw new errors.CredalError({
|
|
13
|
+
statusCode: error.statusCode,
|
|
14
|
+
rawResponse: rawResponse,
|
|
15
|
+
});
|
|
16
|
+
case "timeout":
|
|
17
|
+
throw new errors.CredalTimeoutError(`Timeout exceeded when calling ${method} ${path}.`);
|
|
18
|
+
case "unknown":
|
|
19
|
+
throw new errors.CredalError({
|
|
20
|
+
message: error.errorMessage,
|
|
21
|
+
rawResponse: rawResponse,
|
|
22
|
+
});
|
|
23
|
+
default:
|
|
24
|
+
throw new errors.CredalError({
|
|
25
|
+
message: "Unknown error",
|
|
26
|
+
rawResponse: rawResponse,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.1.
|
|
1
|
+
export declare const SDK_VERSION = "0.1.16";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.1.
|
|
1
|
+
export const SDK_VERSION = "0.1.16";
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@credal/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"private": false,
|
|
5
|
-
"repository":
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Credal-ai/credal-typescript-sdk.git"
|
|
8
|
+
},
|
|
6
9
|
"type": "commonjs",
|
|
7
10
|
"main": "./dist/cjs/index.js",
|
|
8
11
|
"module": "./dist/esm/index.mjs",
|
package/reference.md
CHANGED
|
@@ -584,6 +584,78 @@ await client.copilots.deleteCopilot({
|
|
|
584
584
|
</dl>
|
|
585
585
|
|
|
586
586
|
|
|
587
|
+
</dd>
|
|
588
|
+
</dl>
|
|
589
|
+
</details>
|
|
590
|
+
|
|
591
|
+
<details><summary><code>client.copilots.<a href="/src/api/resources/copilots/client/Client.ts">export</a>({ ...params }) -> Credal.ExportCopilotsResponse</code></summary>
|
|
592
|
+
<dl>
|
|
593
|
+
<dd>
|
|
594
|
+
|
|
595
|
+
#### 📝 Description
|
|
596
|
+
|
|
597
|
+
<dl>
|
|
598
|
+
<dd>
|
|
599
|
+
|
|
600
|
+
<dl>
|
|
601
|
+
<dd>
|
|
602
|
+
|
|
603
|
+
Export copilot configurations for backup or migration purposes.
|
|
604
|
+
|
|
605
|
+
**IMPORTANT**: This endpoint requires:
|
|
606
|
+
- Admin privileges
|
|
607
|
+
- The 'ai-usage-analytics-log.export' scope on the API key
|
|
608
|
+
|
|
609
|
+
Returns all deployed copilots with their full configuration including model settings, tools, and deployment details. Optional date filters can be applied to narrow down results.
|
|
610
|
+
</dd>
|
|
611
|
+
</dl>
|
|
612
|
+
</dd>
|
|
613
|
+
</dl>
|
|
614
|
+
|
|
615
|
+
#### 🔌 Usage
|
|
616
|
+
|
|
617
|
+
<dl>
|
|
618
|
+
<dd>
|
|
619
|
+
|
|
620
|
+
<dl>
|
|
621
|
+
<dd>
|
|
622
|
+
|
|
623
|
+
```typescript
|
|
624
|
+
await client.copilots.export({
|
|
625
|
+
agentCreatedFrom: "2024-01-01T00:00:00Z",
|
|
626
|
+
agentCreatedTo: "2024-12-31T23:59:59Z"
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
```
|
|
630
|
+
</dd>
|
|
631
|
+
</dl>
|
|
632
|
+
</dd>
|
|
633
|
+
</dl>
|
|
634
|
+
|
|
635
|
+
#### ⚙️ Parameters
|
|
636
|
+
|
|
637
|
+
<dl>
|
|
638
|
+
<dd>
|
|
639
|
+
|
|
640
|
+
<dl>
|
|
641
|
+
<dd>
|
|
642
|
+
|
|
643
|
+
**request:** `Credal.ExportCopilotsRequest`
|
|
644
|
+
|
|
645
|
+
</dd>
|
|
646
|
+
</dl>
|
|
647
|
+
|
|
648
|
+
<dl>
|
|
649
|
+
<dd>
|
|
650
|
+
|
|
651
|
+
**requestOptions:** `CopilotsClient.RequestOptions`
|
|
652
|
+
|
|
653
|
+
</dd>
|
|
654
|
+
</dl>
|
|
655
|
+
</dd>
|
|
656
|
+
</dl>
|
|
657
|
+
|
|
658
|
+
|
|
587
659
|
</dd>
|
|
588
660
|
</dl>
|
|
589
661
|
</details>
|