@zcatalyst/transport 0.0.2 → 0.0.3

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.
Files changed (39) hide show
  1. package/LICENCE +55 -1
  2. package/README.md +266 -0
  3. package/dist-cjs/fetch-handler.js +67 -64
  4. package/dist-cjs/http-handler.js +25 -23
  5. package/dist-cjs/index.browser.js +8 -3
  6. package/dist-cjs/index.js +9 -7
  7. package/dist-cjs/utils/clonable-stream.js +1 -1
  8. package/dist-cjs/utils/form-data.js +11 -5
  9. package/dist-cjs/utils/request-agent.js +1 -1
  10. package/dist-es/fetch-handler.js +64 -64
  11. package/dist-es/http-handler.js +25 -24
  12. package/dist-es/index.browser.js +3 -2
  13. package/dist-es/index.js +3 -5
  14. package/dist-es/utils/clonable-stream.js +0 -1
  15. package/dist-es/utils/form-data.js +10 -5
  16. package/dist-es/utils/request-agent.js +0 -1
  17. package/dist-types/fetch-handler.d.ts +115 -6
  18. package/dist-types/http-handler.d.ts +48 -8
  19. package/dist-types/index.browser.d.ts +17 -1
  20. package/dist-types/index.d.ts +22 -2
  21. package/dist-types/ts3.4/fetch-handler.d.ts +115 -6
  22. package/dist-types/ts3.4/http-handler.d.ts +48 -8
  23. package/dist-types/ts3.4/index.browser.d.ts +17 -1
  24. package/dist-types/ts3.4/index.d.ts +22 -2
  25. package/dist-types/ts3.4/utils/clonable-stream.d.ts +54 -0
  26. package/dist-types/ts3.4/utils/errors.d.ts +7 -0
  27. package/dist-types/ts3.4/utils/form-data.d.ts +242 -1
  28. package/dist-types/ts3.4/utils/helpers.d.ts +12 -0
  29. package/dist-types/ts3.4/utils/interfaces.d.ts +5 -1
  30. package/dist-types/ts3.4/utils/request-agent.d.ts +6 -0
  31. package/dist-types/ts3.4/utils/request-timeout.d.ts +12 -0
  32. package/dist-types/utils/clonable-stream.d.ts +54 -0
  33. package/dist-types/utils/errors.d.ts +7 -0
  34. package/dist-types/utils/form-data.d.ts +242 -1
  35. package/dist-types/utils/helpers.d.ts +12 -0
  36. package/dist-types/utils/interfaces.d.ts +5 -1
  37. package/dist-types/utils/request-agent.d.ts +6 -0
  38. package/dist-types/utils/request-timeout.d.ts +12 -0
  39. package/package.json +31 -6
@@ -1,4 +1,3 @@
1
- 'use strict';
2
1
  import { CONSTANTS } from '@zcatalyst/utils';
3
2
  import { Agent as httpAgent } from 'http';
4
3
  import { Agent as httpsAgent } from 'https';
@@ -1,8 +1,4 @@
1
- import { ConfigManager } from '@zcatalyst/auth-client';
2
1
  import { CoreType, IRequestConfig, jwtAccessTokenResponse, RequestHandlerOptions } from './utils/interfaces';
3
- export declare const keepAliveSupport: {
4
- supported: undefined | boolean;
5
- };
6
2
  type ICatalystDataRes = Record<string, string> | string | Blob | ArrayBuffer | ReadableStreamDefaultReader<Uint8Array> | FormData;
7
3
  export interface ICatalystClientRes {
8
4
  request: RequestInit;
@@ -19,22 +15,135 @@ export declare class DefaultHttpResponse {
19
15
  headers: HeadersInit;
20
16
  config: RequestHandlerOptions;
21
17
  resp: ICatalystClientRes;
18
+ /**
19
+ * Creates a DefaultHttpResponse instance.
20
+ * @param resp - The resp value.
21
+ */
22
22
  constructor(resp: ICatalystClientRes);
23
+ /**
24
+ * Returns the data value for this DefaultHttpResponse instance.
25
+ *
26
+ * @returns The response payload.
27
+ * @throws {CatalystAPIError} when the request or response cannot be processed.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { Handler } from '@zcatalyst/transport';
32
+ * const result = undefined;
33
+ * ```
34
+ */
23
35
  get data(): ICatalystDataRes;
24
36
  }
25
37
  export declare class ResponseHandler {
26
38
  #private;
27
- static configManager: ConfigManager;
39
+ static apiDomain: string;
40
+ /**
41
+ * Creates a ResponseHandler instance.
42
+ */
28
43
  constructor();
44
+ /**
45
+ * Sends a browser fetch request with SDK authentication, timeout and response handling.
46
+ *
47
+ * @param options - The initialization or request options.
48
+ * @param options.requestCore - The Fetch API request configuration.
49
+ * @param options.url - The URL to update or request.
50
+ * @param requestOptions - The request handling options.
51
+ * @returns The fire general request result.
52
+ * @throws {CatalystAPIError} when the request or response cannot be processed.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * import { Handler } from '@zcatalyst/transport';
57
+ * const response = await ResponseHandler.fireGeneralRequest({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
58
+ * ```
59
+ */
29
60
  static fireGeneralRequest({ requestCore, url }: {
30
61
  requestCore: RequestInit;
31
62
  url: string;
32
63
  }, requestOptions?: RequestHandlerOptions): Promise<DefaultHttpResponse | void>;
64
+ /**
65
+ * Wraps a Fetch API response in the SDK response object.
66
+ *
67
+ * @param response - The response to wrap.
68
+ * @param options - The initialization or request options.
69
+ * @returns The wrap response result.
70
+ * @throws {CatalystAPIError} when the request or response cannot be processed.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import { Handler } from '@zcatalyst/transport';
75
+ * const response = await ResponseHandler.wrapResponse({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
76
+ * ```
77
+ */
33
78
  static wrapResponse(response: Response, options?: RequestHandlerOptions): Promise<DefaultHttpResponse>;
79
+ /**
80
+ * Sends a browser fetch request without retry handling.
81
+ *
82
+ * @param requestCore - The Fetch API request configuration.
83
+ * @param reqOptions - The raw request handling options.
84
+ * @returns The fire raw request result.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * import { Handler } from '@zcatalyst/transport';
89
+ * const response = await ResponseHandler.fireRawRequest({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
90
+ * ```
91
+ */
34
92
  static fireRawRequest(requestCore: CoreType, reqOptions: RequestHandlerOptions): Promise<DefaultHttpResponse>;
93
+ /**
94
+ * Attaches browser authentication headers according to the configured auth protocol.
95
+ *
96
+ * @param headers - The headers object to mutate or extend.
97
+ * @returns The attach zcauth headers result.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * import { Handler } from '@zcatalyst/transport';
102
+ * const response = await ResponseHandler.attachZCAuthHeaders({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
103
+ * ```
104
+ */
35
105
  static attachZCAuthHeaders(headers: HeadersInit): Promise<HeadersInit>;
106
+ /**
107
+ * Builds the browser JWT authorization token from the configured cookie.
108
+ *
109
+ * @returns The get jwtzcauth token result.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * import { Handler } from '@zcatalyst/transport';
114
+ * const response = await ResponseHandler.getJWTZCAuthToken({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
115
+ * ```
116
+ */
36
117
  static getJWTZCAuthToken(): Promise<jwtAccessTokenResponse>;
118
+ /**
119
+ * Appends query parameters to a URL.
120
+ *
121
+ * @param url - The URL to update or request.
122
+ * @param qs - The query string values to append.
123
+ * @returns The URL with encoded query parameters.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * import { Handler } from '@zcatalyst/transport';
128
+ * const response = await ResponseHandler.appendQueryString({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
129
+ * ```
130
+ */
37
131
  static appendQueryString(url: string, qs?: Record<string, string | number | boolean | undefined>): string;
38
- static send(options: IRequestConfig): Promise<DefaultHttpResponse | void>;
132
+ /**
133
+ * Sends a Catalyst HTTP request and returns the wrapped response.
134
+ *
135
+ * @param options - The initialization or request options.
136
+ * @param componentName - The component name for user-agent metadata.
137
+ * @param componentVersion - The component version for user-agent metadata.
138
+ * @returns The send result.
139
+ * @throws {CatalystAPIError} when the request or response cannot be processed.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * import { Handler } from '@zcatalyst/transport';
144
+ * const response = await ResponseHandler.send({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
145
+ * ```
146
+ */
147
+ static send(options: IRequestConfig, componentName?: string, componentVersion?: string): Promise<DefaultHttpResponse | void>;
39
148
  }
40
149
  export {};
@@ -1,4 +1,4 @@
1
- import { CatalystApp } from '@zcatalyst/auth';
1
+ import { CatalystApp } from '@zcatalyst/auth-admin';
2
2
  import { ClientRequest, IncomingHttpHeaders, IncomingMessage } from 'http';
3
3
  import { Component, IRequestConfig } from './utils/interfaces';
4
4
  export interface IAPIResponse {
@@ -15,25 +15,65 @@ export declare class DefaultHttpResponse {
15
15
  headers: IncomingHttpHeaders;
16
16
  config: IRequestConfig;
17
17
  resp: IAPIResponse;
18
+ /**
19
+ * Creates a DefaultHttpResponse instance.
20
+ * @param resp - The resp value.
21
+ */
18
22
  constructor(resp: IAPIResponse);
23
+ /**
24
+ * Returns the parsed response payload.
25
+ *
26
+ * @returns The data result.
27
+ * @throws {CatalystAPIError} when the operation cannot be completed.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { Handler } from '@zcatalyst/transport';
32
+ * // Use DefaultHttpResponse.data while preparing or sending an SDK request.
33
+ * ```
34
+ */
19
35
  get data(): any;
20
36
  }
21
37
  export declare class HttpClient {
22
38
  app?: CatalystApp;
23
- private user;
39
+ /** * @param app - The app used to fetch access tokens to sign API requests. */
40
+ constructor(app?: CatalystApp);
24
41
  /**
25
- * @param {CatalystApp} app The app used to fetch access tokens to sign API requests.
26
- * @constructor
42
+ * Sends a Catalyst HTTP request and returns the wrapped response.
43
+ *
44
+ * @param req - The req value.
45
+ * @param apmTrackerName - The apmTrackerName value.
46
+ * @param componentVersion - The componentVersion value.
47
+ * @returns The send result.
48
+ * @throws {CatalystAPIError} when the operation cannot be completed.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * import { Handler } from '@zcatalyst/transport';
53
+ * // Use HttpClient.send while preparing or sending an SDK request.
54
+ * ```
27
55
  */
28
- constructor(app?: CatalystApp);
29
- send(req: IRequestConfig, apmTrackerName?: string): Promise<DefaultHttpResponse>;
56
+ send(req: IRequestConfig, apmTrackerName?: string, componentVersion?: string): Promise<DefaultHttpResponse>;
30
57
  }
31
58
  export declare class AuthorizedHttpClient extends HttpClient {
32
59
  readonly componentName?: string;
60
+ readonly componentVersion?: string;
33
61
  /**
34
- * @param {unknown} app The app used to fetch access tokens to sign API requests.
35
- * @constructor
62
+ * @param app - The app used to fetch access tokens to sign API requests.
63
+ * @param component - Optional component metadata used to attach version headers.
36
64
  */
37
65
  constructor(app?: CatalystApp, component?: Component);
66
+ /**
67
+ * Sends a Catalyst HTTP request and returns the wrapped response.
68
+ *
69
+ * @param request - The request value.
70
+ * @returns The send result.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import { Handler } from '@zcatalyst/transport';
75
+ * // Use AuthorizedHttpClient.send while preparing or sending an SDK request.
76
+ * ```
77
+ */
38
78
  send(request: IRequestConfig): Promise<DefaultHttpResponse>;
39
79
  }
@@ -1,11 +1,27 @@
1
1
  import { ICatalystClientRes } from './fetch-handler';
2
2
  import { Component, IRequestConfig } from './utils/interfaces';
3
+ export { CatalystService, Component, CONSTANTS } from '@zcatalyst/utils';
4
+ export { PrefixedCatalystError } from '@zcatalyst/utils';
3
5
  export declare class Handler {
4
6
  component?: Component;
5
7
  /**
6
- * @constructor
8
+ * Creates a Handler instance.
9
+ * @param app - The app value.
10
+ * @param component - The component value.
7
11
  */
8
12
  constructor(app?: unknown, component?: Component);
13
+ /**
14
+ * Sends a Catalyst HTTP request and returns the wrapped response.
15
+ *
16
+ * @param options - The initialization or request options.
17
+ * @returns The send result.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { Handler } from '@zcatalyst/transport';
22
+ * const result = undefined;
23
+ * ```
24
+ */
9
25
  send(options: IRequestConfig): Promise<ICatalystClientRes>;
10
26
  }
11
27
  export { RequestType, ResponseType } from './utils/enums';
@@ -1,14 +1,34 @@
1
+ /**
2
+ * Internal HTTP / fetch transport layer used by every Catalyst component package.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  import { DefaultHttpResponse } from './http-handler';
2
7
  import FormData from './utils/form-data';
3
8
  import { Component, IRequestConfig } from './utils/interfaces';
9
+ export { CatalystService, Component, CONSTANTS } from '@zcatalyst/utils';
10
+ export { PrefixedCatalystError } from '@zcatalyst/utils';
4
11
  export declare class Handler {
5
12
  component?: Component;
6
13
  app?: any;
7
14
  /**
8
- * @param {unknown} app The app used to fetch access tokens to sign API requests.
9
- * @constructor
15
+ * Creates a Handler instance.
16
+ * @param app - The app value.
17
+ * @param component - The component value.
10
18
  */
11
19
  constructor(app?: unknown, component?: Component);
20
+ /**
21
+ * Sends a Catalyst HTTP request through the Node transport handler.
22
+ *
23
+ * @param options - The request configuration to send.
24
+ * @returns The wrapped HTTP response.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { Handler } from '@zcatalyst/transport';
29
+ * const response = await new Handler(app).send({ method: 'GET', url: 'https://example.com' });
30
+ * ```
31
+ */
12
32
  send(options: IRequestConfig): Promise<DefaultHttpResponse>;
13
33
  }
14
34
  export { RequestType, ResponseType } from './utils/enums';
@@ -1,8 +1,4 @@
1
- import { ConfigManager } from '@zcatalyst/auth-client';
2
1
  import { CoreType, IRequestConfig, jwtAccessTokenResponse, RequestHandlerOptions } from './utils/interfaces';
3
- export declare const keepAliveSupport: {
4
- supported: undefined | boolean;
5
- };
6
2
  type ICatalystDataRes = Record<string, string> | string | Blob | ArrayBuffer | ReadableStreamDefaultReader<Uint8Array> | FormData;
7
3
  export interface ICatalystClientRes {
8
4
  request: RequestInit;
@@ -19,22 +15,135 @@ export declare class DefaultHttpResponse {
19
15
  headers: HeadersInit;
20
16
  config: RequestHandlerOptions;
21
17
  resp: ICatalystClientRes;
18
+ /**
19
+ * Creates a DefaultHttpResponse instance.
20
+ * @param resp - The resp value.
21
+ */
22
22
  constructor(resp: ICatalystClientRes);
23
+ /*
24
+ * Returns the data value for this DefaultHttpResponse instance.
25
+ *
26
+ * @returns The response payload.
27
+ * @throws {CatalystAPIError} when the request or response cannot be processed.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { Handler } from '@zcatalyst/transport';
32
+ * const result = undefined;
33
+ * ```
34
+ */
23
35
  readonly data: ICatalystDataRes;
24
36
  }
25
37
  export declare class ResponseHandler {
26
38
  private "ResponseHandler.#private";
27
- static configManager: ConfigManager;
39
+ static apiDomain: string;
40
+ /**
41
+ * Creates a ResponseHandler instance.
42
+ */
28
43
  constructor();
44
+ /**
45
+ * Sends a browser fetch request with SDK authentication, timeout and response handling.
46
+ *
47
+ * @param options - The initialization or request options.
48
+ * @param options.requestCore - The Fetch API request configuration.
49
+ * @param options.url - The URL to update or request.
50
+ * @param requestOptions - The request handling options.
51
+ * @returns The fire general request result.
52
+ * @throws {CatalystAPIError} when the request or response cannot be processed.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * import { Handler } from '@zcatalyst/transport';
57
+ * const response = await ResponseHandler.fireGeneralRequest({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
58
+ * ```
59
+ */
29
60
  static fireGeneralRequest({ requestCore, url }: {
30
61
  requestCore: RequestInit;
31
62
  url: string;
32
63
  }, requestOptions?: RequestHandlerOptions): Promise<DefaultHttpResponse | void>;
64
+ /**
65
+ * Wraps a Fetch API response in the SDK response object.
66
+ *
67
+ * @param response - The response to wrap.
68
+ * @param options - The initialization or request options.
69
+ * @returns The wrap response result.
70
+ * @throws {CatalystAPIError} when the request or response cannot be processed.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import { Handler } from '@zcatalyst/transport';
75
+ * const response = await ResponseHandler.wrapResponse({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
76
+ * ```
77
+ */
33
78
  static wrapResponse(response: Response, options?: RequestHandlerOptions): Promise<DefaultHttpResponse>;
79
+ /**
80
+ * Sends a browser fetch request without retry handling.
81
+ *
82
+ * @param requestCore - The Fetch API request configuration.
83
+ * @param reqOptions - The raw request handling options.
84
+ * @returns The fire raw request result.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * import { Handler } from '@zcatalyst/transport';
89
+ * const response = await ResponseHandler.fireRawRequest({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
90
+ * ```
91
+ */
34
92
  static fireRawRequest(requestCore: CoreType, reqOptions: RequestHandlerOptions): Promise<DefaultHttpResponse>;
93
+ /**
94
+ * Attaches browser authentication headers according to the configured auth protocol.
95
+ *
96
+ * @param headers - The headers object to mutate or extend.
97
+ * @returns The attach zcauth headers result.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * import { Handler } from '@zcatalyst/transport';
102
+ * const response = await ResponseHandler.attachZCAuthHeaders({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
103
+ * ```
104
+ */
35
105
  static attachZCAuthHeaders(headers: HeadersInit): Promise<HeadersInit>;
106
+ /**
107
+ * Builds the browser JWT authorization token from the configured cookie.
108
+ *
109
+ * @returns The get jwtzcauth token result.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * import { Handler } from '@zcatalyst/transport';
114
+ * const response = await ResponseHandler.getJWTZCAuthToken({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
115
+ * ```
116
+ */
36
117
  static getJWTZCAuthToken(): Promise<jwtAccessTokenResponse>;
118
+ /**
119
+ * Appends query parameters to a URL.
120
+ *
121
+ * @param url - The URL to update or request.
122
+ * @param qs - The query string values to append.
123
+ * @returns The URL with encoded query parameters.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * import { Handler } from '@zcatalyst/transport';
128
+ * const response = await ResponseHandler.appendQueryString({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
129
+ * ```
130
+ */
37
131
  static appendQueryString(url: string, qs?: Record<string, string | number | boolean | undefined>): string;
38
- static send(options: IRequestConfig): Promise<DefaultHttpResponse | void>;
132
+ /**
133
+ * Sends a Catalyst HTTP request and returns the wrapped response.
134
+ *
135
+ * @param options - The initialization or request options.
136
+ * @param componentName - The component name for user-agent metadata.
137
+ * @param componentVersion - The component version for user-agent metadata.
138
+ * @returns The send result.
139
+ * @throws {CatalystAPIError} when the request or response cannot be processed.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * import { Handler } from '@zcatalyst/transport';
144
+ * const response = await ResponseHandler.send({ url: '/baas/v1/project/123', method: 'GET', headers: {} });
145
+ * ```
146
+ */
147
+ static send(options: IRequestConfig, componentName?: string, componentVersion?: string): Promise<DefaultHttpResponse | void>;
39
148
  }
40
149
  export {};
@@ -1,4 +1,4 @@
1
- import { CatalystApp } from '@zcatalyst/auth';
1
+ import { CatalystApp } from '@zcatalyst/auth-admin';
2
2
  import { ClientRequest, IncomingHttpHeaders, IncomingMessage } from 'http';
3
3
  import { Component, IRequestConfig } from './utils/interfaces';
4
4
  export interface IAPIResponse {
@@ -15,25 +15,65 @@ export declare class DefaultHttpResponse {
15
15
  headers: IncomingHttpHeaders;
16
16
  config: IRequestConfig;
17
17
  resp: IAPIResponse;
18
+ /**
19
+ * Creates a DefaultHttpResponse instance.
20
+ * @param resp - The resp value.
21
+ */
18
22
  constructor(resp: IAPIResponse);
23
+ /*
24
+ * Returns the parsed response payload.
25
+ *
26
+ * @returns The data result.
27
+ * @throws {CatalystAPIError} when the operation cannot be completed.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { Handler } from '@zcatalyst/transport';
32
+ * // Use DefaultHttpResponse.data while preparing or sending an SDK request.
33
+ * ```
34
+ */
19
35
  readonly data: any;
20
36
  }
21
37
  export declare class HttpClient {
22
38
  app?: CatalystApp;
23
- private user;
39
+ /** * @param app - The app used to fetch access tokens to sign API requests. */
40
+ constructor(app?: CatalystApp);
24
41
  /**
25
- * @param {CatalystApp} app The app used to fetch access tokens to sign API requests.
26
- * @constructor
42
+ * Sends a Catalyst HTTP request and returns the wrapped response.
43
+ *
44
+ * @param req - The req value.
45
+ * @param apmTrackerName - The apmTrackerName value.
46
+ * @param componentVersion - The componentVersion value.
47
+ * @returns The send result.
48
+ * @throws {CatalystAPIError} when the operation cannot be completed.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * import { Handler } from '@zcatalyst/transport';
53
+ * // Use HttpClient.send while preparing or sending an SDK request.
54
+ * ```
27
55
  */
28
- constructor(app?: CatalystApp);
29
- send(req: IRequestConfig, apmTrackerName?: string): Promise<DefaultHttpResponse>;
56
+ send(req: IRequestConfig, apmTrackerName?: string, componentVersion?: string): Promise<DefaultHttpResponse>;
30
57
  }
31
58
  export declare class AuthorizedHttpClient extends HttpClient {
32
59
  readonly componentName?: string;
60
+ readonly componentVersion?: string;
33
61
  /**
34
- * @param {unknown} app The app used to fetch access tokens to sign API requests.
35
- * @constructor
62
+ * @param app - The app used to fetch access tokens to sign API requests.
63
+ * @param component - Optional component metadata used to attach version headers.
36
64
  */
37
65
  constructor(app?: CatalystApp, component?: Component);
66
+ /**
67
+ * Sends a Catalyst HTTP request and returns the wrapped response.
68
+ *
69
+ * @param request - The request value.
70
+ * @returns The send result.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import { Handler } from '@zcatalyst/transport';
75
+ * // Use AuthorizedHttpClient.send while preparing or sending an SDK request.
76
+ * ```
77
+ */
38
78
  send(request: IRequestConfig): Promise<DefaultHttpResponse>;
39
79
  }
@@ -1,11 +1,27 @@
1
1
  import { ICatalystClientRes } from './fetch-handler';
2
2
  import { Component, IRequestConfig } from './utils/interfaces';
3
+ export { CatalystService, Component, CONSTANTS } from '@zcatalyst/utils';
4
+ export { PrefixedCatalystError } from '@zcatalyst/utils';
3
5
  export declare class Handler {
4
6
  component?: Component;
5
7
  /**
6
- * @constructor
8
+ * Creates a Handler instance.
9
+ * @param app - The app value.
10
+ * @param component - The component value.
7
11
  */
8
12
  constructor(app?: unknown, component?: Component);
13
+ /**
14
+ * Sends a Catalyst HTTP request and returns the wrapped response.
15
+ *
16
+ * @param options - The initialization or request options.
17
+ * @returns The send result.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { Handler } from '@zcatalyst/transport';
22
+ * const result = undefined;
23
+ * ```
24
+ */
9
25
  send(options: IRequestConfig): Promise<ICatalystClientRes>;
10
26
  }
11
27
  export { RequestType, ResponseType } from './utils/enums';
@@ -1,14 +1,34 @@
1
+ /**
2
+ * Internal HTTP / fetch transport layer used by every Catalyst component package.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  import { DefaultHttpResponse } from './http-handler';
2
7
  import FormData from './utils/form-data';
3
8
  import { Component, IRequestConfig } from './utils/interfaces';
9
+ export { CatalystService, Component, CONSTANTS } from '@zcatalyst/utils';
10
+ export { PrefixedCatalystError } from '@zcatalyst/utils';
4
11
  export declare class Handler {
5
12
  component?: Component;
6
13
  app?: any;
7
14
  /**
8
- * @param {unknown} app The app used to fetch access tokens to sign API requests.
9
- * @constructor
15
+ * Creates a Handler instance.
16
+ * @param app - The app value.
17
+ * @param component - The component value.
10
18
  */
11
19
  constructor(app?: unknown, component?: Component);
20
+ /**
21
+ * Sends a Catalyst HTTP request through the Node transport handler.
22
+ *
23
+ * @param options - The request configuration to send.
24
+ * @returns The wrapped HTTP response.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { Handler } from '@zcatalyst/transport';
29
+ * const response = await new Handler(app).send({ method: 'GET', url: 'https://example.com' });
30
+ * ```
31
+ */
12
32
  send(options: IRequestConfig): Promise<DefaultHttpResponse>;
13
33
  }
14
34
  export { RequestType, ResponseType } from './utils/enums';
@@ -1,10 +1,37 @@
1
1
  import { PassThrough, Readable } from 'stream';
2
2
  declare class StreamClone extends PassThrough {
3
3
  parent: CloneableStream;
4
+ /**
5
+ * Creates a StreamClone instance.
6
+ * @param parent - The parent value.
7
+ */
4
8
  constructor(parent: CloneableStream);
5
9
  private onDataClone;
6
10
  private onResumeClone;
11
+ /**
12
+ * Performs clone for the transport package.
13
+ *
14
+ * @returns The clone result.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { Handler } from '@zcatalyst/transport';
19
+ * const result = undefined;
20
+ * ```
21
+ */
7
22
  clone(): StreamClone;
23
+ /**
24
+ * Performs is cloneable for the transport package.
25
+ *
26
+ * @param stream - The stream value.
27
+ * @returns The is cloneable result.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { Handler } from '@zcatalyst/transport';
32
+ * const result = undefined;
33
+ * ```
34
+ */
8
35
  isCloneable(stream: unknown): stream is CloneableStream | StreamClone;
9
36
  }
10
37
  export default class CloneableStream extends PassThrough {
@@ -12,10 +39,37 @@ export default class CloneableStream extends PassThrough {
12
39
  _clonesCount: number;
13
40
  _internalPipe: boolean;
14
41
  _hasListener: boolean;
42
+ /**
43
+ * Creates a CloneableStream instance.
44
+ * @param stream - The stream value.
45
+ */
15
46
  constructor(stream: Readable);
16
47
  private onData;
17
48
  private onResume;
49
+ /**
50
+ * Performs resume for the transport package.
51
+ *
52
+ * @returns The resume result.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * import { Handler } from '@zcatalyst/transport';
57
+ * const result = undefined;
58
+ * ```
59
+ */
18
60
  resume(): this;
61
+ /**
62
+ * Performs clone for the transport package.
63
+ *
64
+ * @returns The clone result.
65
+ * @throws {Error} when validation fails.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * import { Handler } from '@zcatalyst/transport';
70
+ * const result = undefined;
71
+ * ```
72
+ */
19
73
  clone(): StreamClone;
20
74
  }
21
75
  export {};
@@ -1,4 +1,11 @@
1
1
  import { PrefixedCatalystError } from '@zcatalyst/utils';
2
2
  export declare class CatalystAPIError extends PrefixedCatalystError {
3
+ /**
4
+ * Creates a CatalystAPIError instance.
5
+ * @param code - The code value.
6
+ * @param message - The message value.
7
+ * @param value - The value value.
8
+ * @param statusCode - The statusCode value.
9
+ */
3
10
  constructor(code: string, message: string, value?: unknown, statusCode?: number);
4
11
  }