@databricks/sdk-uc-systemschemas 0.0.0-dev → 0.1.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,113 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+ import { execute } from '@databricks/sdk-core/ops';
3
+ import { ApiError } from '@databricks/sdk-core/apierror';
4
+ import JSONBig from 'json-bigint';
5
+ // JSON codec that preserves int64 precision. On the way in, large integer
6
+ // literals come back as bigint instead of being rounded to JS Number. On the
7
+ // way out, bigint values are emitted as raw JSON number digits.
8
+ const jsonBigint = JSONBig({ useNativeBigInt: true });
9
+ /**
10
+ * Translates public CallOptions to the internal Options shape accepted by
11
+ * execute(). Even though the shapes match today, this isolates the public
12
+ * API from the executor's internal type so they can diverge.
13
+ */
14
+ export async function executeCall(call, options) {
15
+ const opts = {
16
+ ...(options?.retrier !== undefined && { retrier: options.retrier }),
17
+ ...(options?.rateLimiter !== undefined && {
18
+ rateLimiter: options.rateLimiter,
19
+ }),
20
+ ...(options?.timeout !== undefined && { timeout: options.timeout }),
21
+ };
22
+ return execute(options?.signal, call, opts);
23
+ }
24
+ async function readAll(body) {
25
+ if (body === null) {
26
+ return new Uint8Array(0);
27
+ }
28
+ const reader = body.getReader();
29
+ const chunks = [];
30
+ for (;;) {
31
+ const { done, value } = await reader.read();
32
+ if (done) {
33
+ break;
34
+ }
35
+ chunks.push(value);
36
+ }
37
+ const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
38
+ const result = new Uint8Array(totalLength);
39
+ let offset = 0;
40
+ for (const chunk of chunks) {
41
+ result.set(chunk, offset);
42
+ offset += chunk.length;
43
+ }
44
+ return result;
45
+ }
46
+ export async function executeHttpCall(opts) {
47
+ opts.logger.debug('HTTP request', {
48
+ method: opts.request.method,
49
+ url: opts.request.url,
50
+ });
51
+ let resp;
52
+ try {
53
+ resp = await opts.httpClient.send(opts.request);
54
+ }
55
+ catch (e) {
56
+ opts.logger.debug('HTTP request failed');
57
+ throw e;
58
+ }
59
+ const body = await readAll(resp.body);
60
+ opts.logger.debug('HTTP response', {
61
+ statusCode: resp.statusCode,
62
+ body: new TextDecoder().decode(body),
63
+ });
64
+ const apiErr = ApiError.fromHttpError(resp.statusCode, resp.headers, body);
65
+ if (apiErr !== undefined) {
66
+ throw apiErr;
67
+ }
68
+ return body;
69
+ }
70
+ export function buildHttpRequest(method, url, headers, signal, body) {
71
+ const req = { url, method, headers };
72
+ if (body !== undefined) {
73
+ req.body = body;
74
+ }
75
+ if (signal !== undefined) {
76
+ req.signal = signal;
77
+ }
78
+ return req;
79
+ }
80
+ export function parseResponse(body, schema) {
81
+ const text = new TextDecoder().decode(body);
82
+ const parsed = jsonBigint.parse(text);
83
+ return schema.parse(parsed);
84
+ }
85
+ export function marshalRequest(data, schema) {
86
+ return jsonBigint.stringify(schema.parse(data));
87
+ }
88
+ export function flattenQueryParams(prefix, value, params) {
89
+ if (value === null || value === undefined) {
90
+ return;
91
+ }
92
+ if (Array.isArray(value)) {
93
+ // arrays of objects are not yet supported
94
+ for (const item of value) {
95
+ params.append(prefix, String(item));
96
+ }
97
+ }
98
+ else if (typeof value === 'object') {
99
+ for (const [key, val] of Object.entries(value)) {
100
+ flattenQueryParams(`${prefix}.${key}`, val, params);
101
+ }
102
+ }
103
+ else if (typeof value === 'string' ||
104
+ typeof value === 'number' ||
105
+ typeof value === 'boolean' ||
106
+ typeof value === 'bigint') {
107
+ params.append(prefix, String(value));
108
+ }
109
+ else {
110
+ throw new Error(`Unsupported query parameter type: ${typeof value}`);
111
+ }
112
+ }
113
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/v1/utils.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAG/E,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,+BAA+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,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YAC1E,kBAAkB,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;SAAM,IACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAO,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,41 @@
1
1
  {
2
2
  "name": "@databricks/sdk-uc-systemschemas",
3
- "version": "0.0.0-dev",
4
- "description": "Bootstrap placeholder; real contents in a later release.",
5
- "main": "index.js",
6
- "license": "Apache-2.0"
3
+ "version": "0.1.0-dev.2",
4
+ "description": "",
5
+ "type": "module",
6
+ "exports": {
7
+ "./v1": {
8
+ "types": "./dist/v1/index.d.ts",
9
+ "import": "./dist/v1/index.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "src",
15
+ "LICENSE"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc -b",
19
+ "lint": "eslint src --ext .ts",
20
+ "lint:fix": "eslint src --ext .ts --fix",
21
+ "format": "prettier --write \"src/**/*.ts\"",
22
+ "format:check": "prettier --check \"src/**/*.ts\"",
23
+ "typecheck": "tsc --noEmit",
24
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
25
+ "test": "echo 'no tests'",
26
+ "test:browser": "echo 'no tests'"
27
+ },
28
+ "author": "Databricks",
29
+ "license": "Apache-2.0",
30
+ "dependencies": {
31
+ "@databricks/sdk-auth": ">=0.1.0-dev.3 <1.0.0",
32
+ "@databricks/sdk-core": ">=0.1.0-dev.4 <1.0.0",
33
+ "@databricks/sdk-options": ">=0.1.0-dev.3 <1.0.0",
34
+ "@js-temporal/polyfill": "^0.5.0",
35
+ "json-bigint": "^1.0.0",
36
+ "zod": "^4.3.6"
37
+ },
38
+ "engines": {
39
+ "node": ">=22.0.0"
40
+ }
7
41
  }
@@ -0,0 +1,202 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import {VERSION as AUTH_VERSION} from '@databricks/sdk-auth';
4
+ import {createDefault} from '@databricks/sdk-core/clientinfo';
5
+ import type {Logger} from '@databricks/sdk-core/logger';
6
+ import {NoOpLogger} from '@databricks/sdk-core/logger';
7
+ import type {CallOptions} from '@databricks/sdk-options/call';
8
+ import type {ClientOptions} from '@databricks/sdk-options/client';
9
+ import type {HttpClient} from '@databricks/sdk-core/http';
10
+ import {newHttpClient} from './transport';
11
+ import {
12
+ buildHttpRequest,
13
+ executeCall,
14
+ executeHttpCall,
15
+ marshalRequest,
16
+ parseResponse,
17
+ } from './utils';
18
+ import pkgJson from '../../package.json' with {type: 'json'};
19
+ import type {
20
+ DisableSystemSchemaRequest,
21
+ DisableSystemSchemaRequest_Response,
22
+ EnableSystemSchemaRequest,
23
+ EnableSystemSchemaRequest_Response,
24
+ ListSystemSchemasRequest,
25
+ ListSystemSchemasRequest_Response,
26
+ SystemSchemaInfo,
27
+ } from './model';
28
+ import {
29
+ marshalEnableSystemSchemaRequestSchema,
30
+ unmarshalDisableSystemSchemaRequest_ResponseSchema,
31
+ unmarshalEnableSystemSchemaRequest_ResponseSchema,
32
+ unmarshalListSystemSchemasRequest_ResponseSchema,
33
+ } from './model';
34
+
35
+ // Package identity segment for this client to be used in the User-Agent header.
36
+ const PACKAGE_SEGMENT = {
37
+ key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
38
+ value: pkgJson.version,
39
+ };
40
+
41
+ export class SystemSchemasClient {
42
+ private readonly host: string;
43
+ // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
44
+ // When set, workspace-level methods send X-Databricks-Org-Id on every
45
+ // request.
46
+ private readonly workspaceId: string | undefined;
47
+ private readonly httpClient: HttpClient;
48
+ private readonly logger: Logger;
49
+ // User-Agent header value. Composed once at construction from
50
+ // createDefault() merged with this package's identity and the active
51
+ // credential's name.
52
+ private readonly userAgent: string;
53
+
54
+ constructor(options: ClientOptions) {
55
+ if (options.host === undefined) {
56
+ throw new Error('Host is required.');
57
+ }
58
+ this.host = options.host.replace(/\/$/, '');
59
+ this.workspaceId = options.workspaceId;
60
+ this.logger = options.logger ?? new NoOpLogger();
61
+ const info = createDefault()
62
+ .with(PACKAGE_SEGMENT)
63
+ .with({key: 'sdk-js-auth', value: AUTH_VERSION})
64
+ .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
65
+ this.userAgent = info.toString();
66
+ this.httpClient = newHttpClient(options);
67
+ }
68
+
69
+ /**
70
+ * Disables the system schema and removes it from the system catalog.
71
+ * The caller must be an account admin or a metastore admin.
72
+ */
73
+ async disableSystemSchema(
74
+ req: DisableSystemSchemaRequest,
75
+ options?: CallOptions
76
+ ): Promise<DisableSystemSchemaRequest_Response> {
77
+ const url = `${this.host}/api/2.1/unity-catalog/metastores/${req.metastoreId ?? ''}/systemschemas/${req.schema ?? ''}`;
78
+ let resp: DisableSystemSchemaRequest_Response | undefined;
79
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
80
+ const headers = new Headers();
81
+ if (this.workspaceId !== undefined) {
82
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
83
+ }
84
+ headers.set('User-Agent', this.userAgent);
85
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
86
+ const respBody = await executeHttpCall({
87
+ request: httpReq,
88
+ httpClient: this.httpClient,
89
+ logger: this.logger,
90
+ });
91
+ resp = parseResponse(
92
+ respBody,
93
+ unmarshalDisableSystemSchemaRequest_ResponseSchema
94
+ );
95
+ };
96
+ await executeCall(call, options);
97
+ if (resp === undefined) {
98
+ throw new Error('operation completed without a result.');
99
+ }
100
+ return resp;
101
+ }
102
+
103
+ /**
104
+ * Enables the system schema and adds it to the system catalog.
105
+ * The caller must be an account admin or a metastore admin.
106
+ */
107
+ async enableSystemSchema(
108
+ req: EnableSystemSchemaRequest,
109
+ options?: CallOptions
110
+ ): Promise<EnableSystemSchemaRequest_Response> {
111
+ const url = `${this.host}/api/2.1/unity-catalog/metastores/${req.metastoreId ?? ''}/systemschemas/${req.schema ?? ''}`;
112
+ const body = marshalRequest(req, marshalEnableSystemSchemaRequestSchema);
113
+ let resp: EnableSystemSchemaRequest_Response | undefined;
114
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
115
+ const headers = new Headers({'Content-Type': 'application/json'});
116
+ if (this.workspaceId !== undefined) {
117
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
118
+ }
119
+ headers.set('User-Agent', this.userAgent);
120
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
121
+ const respBody = await executeHttpCall({
122
+ request: httpReq,
123
+ httpClient: this.httpClient,
124
+ logger: this.logger,
125
+ });
126
+ resp = parseResponse(
127
+ respBody,
128
+ unmarshalEnableSystemSchemaRequest_ResponseSchema
129
+ );
130
+ };
131
+ await executeCall(call, options);
132
+ if (resp === undefined) {
133
+ throw new Error('operation completed without a result.');
134
+ }
135
+ return resp;
136
+ }
137
+
138
+ /**
139
+ * Gets an array of system schemas for a metastore.
140
+ * The caller must be an account admin or a metastore admin.
141
+ *
142
+ * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
143
+ *
144
+ * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
145
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
146
+ */
147
+ async listSystemSchemas(
148
+ req: ListSystemSchemasRequest,
149
+ options?: CallOptions
150
+ ): Promise<ListSystemSchemasRequest_Response> {
151
+ const url = `${this.host}/api/2.1/unity-catalog/metastores/${req.metastoreId ?? ''}/systemschemas`;
152
+ const params = new URLSearchParams();
153
+ if (req.maxResults !== undefined) {
154
+ params.append('max_results', String(req.maxResults));
155
+ }
156
+ if (req.pageToken !== undefined) {
157
+ params.append('page_token', req.pageToken);
158
+ }
159
+ const query = params.toString();
160
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
161
+ let resp: ListSystemSchemasRequest_Response | undefined;
162
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
163
+ const headers = new Headers();
164
+ if (this.workspaceId !== undefined) {
165
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
166
+ }
167
+ headers.set('User-Agent', this.userAgent);
168
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
169
+ const respBody = await executeHttpCall({
170
+ request: httpReq,
171
+ httpClient: this.httpClient,
172
+ logger: this.logger,
173
+ });
174
+ resp = parseResponse(
175
+ respBody,
176
+ unmarshalListSystemSchemasRequest_ResponseSchema
177
+ );
178
+ };
179
+ await executeCall(call, options);
180
+ if (resp === undefined) {
181
+ throw new Error('operation completed without a result.');
182
+ }
183
+ return resp;
184
+ }
185
+
186
+ async *listSystemSchemasIter(
187
+ req: ListSystemSchemasRequest,
188
+ options?: CallOptions
189
+ ): AsyncGenerator<SystemSchemaInfo> {
190
+ const pageReq: ListSystemSchemasRequest = {...req};
191
+ for (;;) {
192
+ const resp = await this.listSystemSchemas(pageReq, options);
193
+ for (const item of resp.schemas ?? []) {
194
+ yield item;
195
+ }
196
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
197
+ return;
198
+ }
199
+ pageReq.pageToken = resp.nextPageToken;
200
+ }
201
+ }
202
+ }
@@ -0,0 +1,13 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ export {SystemSchemasClient} from './client';
4
+
5
+ export type {
6
+ DisableSystemSchemaRequest,
7
+ DisableSystemSchemaRequest_Response,
8
+ EnableSystemSchemaRequest,
9
+ EnableSystemSchemaRequest_Response,
10
+ ListSystemSchemasRequest,
11
+ ListSystemSchemasRequest_Response,
12
+ SystemSchemaInfo,
13
+ } from './model';
@@ -0,0 +1,105 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import {z} from 'zod';
4
+
5
+ export interface DisableSystemSchemaRequest {
6
+ /** Full name of the system schema. */
7
+ schema?: string | undefined;
8
+ /** The metastore ID under which the system schema lives. */
9
+ metastoreId?: string | undefined;
10
+ }
11
+
12
+ // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
13
+ export interface DisableSystemSchemaRequest_Response {}
14
+
15
+ export interface EnableSystemSchemaRequest {
16
+ /** Full name of the system schema. */
17
+ schema?: string | undefined;
18
+ /** The metastore ID under which the system schema lives. */
19
+ metastoreId?: string | undefined;
20
+ /** the catalog for which the system schema is to enabled in */
21
+ catalogName?: string | undefined;
22
+ }
23
+
24
+ // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
25
+ export interface EnableSystemSchemaRequest_Response {}
26
+
27
+ export interface ListSystemSchemasRequest {
28
+ /** The ID for the metastore in which the system schema resides. */
29
+ metastoreId?: string | undefined;
30
+ /**
31
+ * Maximum number of schemas to return.
32
+ * - When set to 0, the page length is set to a server configured value (recommended);
33
+ * - When set to a value greater than 0, the page length is the minimum of this value and a server configured value;
34
+ * - When set to a value less than 0, an invalid parameter error is returned;
35
+ * - If not set, all the schemas are returned (not recommended).
36
+ */
37
+ maxResults?: number | undefined;
38
+ /** Opaque pagination token to go to next page based on previous query. */
39
+ pageToken?: string | undefined;
40
+ }
41
+
42
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
43
+ export interface ListSystemSchemasRequest_Response {
44
+ /** An array of system schema information objects. */
45
+ schemas?: SystemSchemaInfo[] | undefined;
46
+ /**
47
+ * Opaque token to retrieve the next page of results. Absent if there are no more pages.
48
+ * __page_token__ should be set to this value for the next request (for the next page of results).
49
+ */
50
+ nextPageToken?: string | undefined;
51
+ }
52
+
53
+ export interface SystemSchemaInfo {
54
+ /** Name of the system schema. */
55
+ schema: string;
56
+ /**
57
+ * The current state of enablement for the system schema. An empty string means the system schema is available and ready for opt-in.
58
+ * Possible values: AVAILABLE | ENABLE_INITIALIZED | ENABLE_COMPLETED | DISABLE_INITIALIZED | UNAVAILABLE | MANAGED
59
+ */
60
+ state: string;
61
+ }
62
+
63
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
64
+ export const unmarshalDisableSystemSchemaRequest_ResponseSchema: z.ZodType<DisableSystemSchemaRequest_Response> =
65
+ z.object({});
66
+
67
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
68
+ export const unmarshalEnableSystemSchemaRequest_ResponseSchema: z.ZodType<EnableSystemSchemaRequest_Response> =
69
+ z.object({});
70
+
71
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
72
+ export const unmarshalListSystemSchemasRequest_ResponseSchema: z.ZodType<ListSystemSchemasRequest_Response> =
73
+ z
74
+ .object({
75
+ schemas: z
76
+ .array(z.lazy(() => unmarshalSystemSchemaInfoSchema))
77
+ .optional(),
78
+ next_page_token: z.string().optional(),
79
+ })
80
+ .transform(d => ({
81
+ schemas: d.schemas,
82
+ nextPageToken: d.next_page_token,
83
+ }));
84
+
85
+ export const unmarshalSystemSchemaInfoSchema: z.ZodType<SystemSchemaInfo> = z
86
+ .object({
87
+ schema: z.string(),
88
+ state: z.string(),
89
+ })
90
+ .transform(d => ({
91
+ schema: d.schema,
92
+ state: d.state,
93
+ }));
94
+
95
+ export const marshalEnableSystemSchemaRequestSchema: z.ZodType = z
96
+ .object({
97
+ schema: z.string().optional(),
98
+ metastoreId: z.string().optional(),
99
+ catalogName: z.string().optional(),
100
+ })
101
+ .transform(d => ({
102
+ schema: d.schema,
103
+ metastore_id: d.metastoreId,
104
+ catalog_name: d.catalogName,
105
+ }));
@@ -0,0 +1,73 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import type {Credentials} from '@databricks/sdk-auth';
4
+ import {defaultCredentials} from '@databricks/sdk-auth/credentials';
5
+ import type {
6
+ HttpClient,
7
+ HttpRequest,
8
+ HttpResponse,
9
+ } from '@databricks/sdk-core/http';
10
+ import {newFetchHttpClient} from '@databricks/sdk-core/http';
11
+ import type {ClientOptions} from '@databricks/sdk-options/client';
12
+
13
+ /** Creates a new HTTP client with the given options. */
14
+ export function newHttpClient(options?: ClientOptions): HttpClient {
15
+ const opts = options ?? {};
16
+
17
+ // If an HTTP client is provided, use it as-is. Throw if other options are
18
+ // also set, since they would be silently ignored.
19
+ if (opts.httpClient !== undefined) {
20
+ if (opts.credentials !== undefined || opts.timeout !== undefined) {
21
+ throw new Error(
22
+ 'httpClient cannot be combined with credentials or timeout'
23
+ );
24
+ }
25
+ return opts.httpClient;
26
+ }
27
+
28
+ const credentials = opts.credentials ?? defaultCredentials();
29
+
30
+ const base = newFetchHttpClient();
31
+ let client: HttpClient = new AuthHttpClient(base, credentials);
32
+
33
+ if (opts.timeout !== undefined) {
34
+ client = new TimeoutHttpClient(client, opts.timeout);
35
+ }
36
+
37
+ return client;
38
+ }
39
+
40
+ /** Wraps an HttpClient and adds authentication headers to requests. */
41
+ class AuthHttpClient implements HttpClient {
42
+ constructor(
43
+ private readonly base: HttpClient,
44
+ private readonly credentials: Credentials
45
+ ) {}
46
+
47
+ async send(request: HttpRequest): Promise<HttpResponse> {
48
+ const authHeaders = await this.credentials.authHeaders();
49
+ // Do not modify the original request.
50
+ const headers = new Headers(request.headers);
51
+ for (const h of authHeaders) {
52
+ headers.set(h.key, h.value);
53
+ }
54
+ return this.base.send({...request, headers});
55
+ }
56
+ }
57
+
58
+ /** Wraps an HttpClient and applies a default timeout to requests. */
59
+ class TimeoutHttpClient implements HttpClient {
60
+ constructor(
61
+ private readonly base: HttpClient,
62
+ private readonly timeout: number
63
+ ) {}
64
+
65
+ async send(request: HttpRequest): Promise<HttpResponse> {
66
+ const timeoutSignal = AbortSignal.timeout(this.timeout);
67
+ const signal =
68
+ request.signal !== undefined
69
+ ? AbortSignal.any([request.signal, timeoutSignal])
70
+ : timeoutSignal;
71
+ return this.base.send({...request, signal});
72
+ }
73
+ }