contree-client 0.1.0

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.
@@ -0,0 +1,30 @@
1
+ export declare class ContreeError extends Error {}
2
+
3
+ export declare class SSEStreamError extends ContreeError {
4
+ lastEventId: number | null;
5
+ constructor(message: string, options?: { lastEventId?: number | null });
6
+ }
7
+
8
+ export declare class ContreeAPIError extends ContreeError {
9
+ status: number;
10
+ error: unknown;
11
+ traceback: string[] | null;
12
+ retryAfter: number | null;
13
+ constructor(
14
+ status: number,
15
+ error: unknown,
16
+ options?: { traceback?: string[] | null; retryAfter?: number | null },
17
+ );
18
+ }
19
+
20
+ export declare class BadRequestError extends ContreeAPIError {}
21
+ export declare class UnauthorizedError extends ContreeAPIError {}
22
+ export declare class ForbiddenError extends ContreeAPIError {}
23
+ export declare class NotFoundError extends ContreeAPIError {}
24
+ export declare class ConflictError extends ContreeAPIError {}
25
+ export declare class GoneError extends ContreeAPIError {}
26
+ export declare class UnprocessableEntityError extends ContreeAPIError {}
27
+ export declare class TooEarlyError extends ContreeAPIError {}
28
+ export declare class ServerError extends ContreeAPIError {}
29
+
30
+ export declare const ERROR_CLASSES: Map<number, typeof ContreeAPIError>;
package/lib/errors.js ADDED
@@ -0,0 +1,46 @@
1
+ /** Exception hierarchy for the Contree API client. */
2
+
3
+ export class ContreeError extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = new.target.name;
7
+ }
8
+ }
9
+
10
+ export class SSEStreamError extends ContreeError {
11
+ constructor(message, { lastEventId = null } = {}) {
12
+ super(message);
13
+ this.lastEventId = lastEventId;
14
+ }
15
+ }
16
+
17
+ export class ContreeAPIError extends ContreeError {
18
+ constructor(status, error, { traceback = null, retryAfter = null } = {}) {
19
+ super(`HTTP ${status}: ${error}`);
20
+ this.status = status;
21
+ this.error = error;
22
+ this.traceback = traceback;
23
+ this.retryAfter = retryAfter;
24
+ }
25
+ }
26
+
27
+ export class BadRequestError extends ContreeAPIError {}
28
+ export class UnauthorizedError extends ContreeAPIError {}
29
+ export class ForbiddenError extends ContreeAPIError {}
30
+ export class NotFoundError extends ContreeAPIError {}
31
+ export class ConflictError extends ContreeAPIError {}
32
+ export class GoneError extends ContreeAPIError {}
33
+ export class UnprocessableEntityError extends ContreeAPIError {}
34
+ export class TooEarlyError extends ContreeAPIError {}
35
+ export class ServerError extends ContreeAPIError {}
36
+
37
+ export const ERROR_CLASSES = new Map([
38
+ [400, BadRequestError],
39
+ [401, UnauthorizedError],
40
+ [403, ForbiddenError],
41
+ [404, NotFoundError],
42
+ [409, ConflictError],
43
+ [410, GoneError],
44
+ [422, UnprocessableEntityError],
45
+ [425, TooEarlyError],
46
+ ]);
package/lib/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ // Generated by codegen from the OpenAPI spec - do not edit.
2
+ export * from "./errors.js";
3
+ export * from "./specInfo.js";
4
+ export * from "./models.js";
5
+ export {
6
+ CHUNK_SIZE,
7
+ PACKAGE_VERSION,
8
+ RETRY_DELAYS,
9
+ RetryPolicy,
10
+ SSEParser,
11
+ parseDatetime,
12
+ parseRetryAfter,
13
+ sha256,
14
+ } from "./runtime.js";
15
+ export type { RequestSpec, ResponseData, RequestBody } from "./runtime.js";
16
+ export { ContreeClient, ContreeClientOptions } from "./client.js";
17
+ export * as operations from "./operations.js";
18
+ export * as profiles from "./profiles.js";
19
+ export * as testing from "./testing.js";
package/lib/index.js ADDED
@@ -0,0 +1,18 @@
1
+ // Generated by codegen from the OpenAPI spec - do not edit.
2
+ export * from "./errors.js";
3
+ export * from "./specInfo.js";
4
+ export * from "./models.js";
5
+ export {
6
+ CHUNK_SIZE,
7
+ PACKAGE_VERSION,
8
+ RETRY_DELAYS,
9
+ RetryPolicy,
10
+ SSEParser,
11
+ parseDatetime,
12
+ parseRetryAfter,
13
+ sha256,
14
+ } from "./runtime.js";
15
+ export { ContreeClient } from "./client.js";
16
+ export * as operations from "./operations.js";
17
+ export * as profiles from "./profiles.js";
18
+ export * as testing from "./testing.js";