@databricks/sdk-uc-volumes 0.0.0-dev → 0.1.0-dev.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.
@@ -0,0 +1,404 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import {z} from 'zod';
4
+
5
+ export enum SseEncryptionAlgorithm {
6
+ SSE_ENCRYPTION_ALGORITHM_UNSPECIFIED = 'SSE_ENCRYPTION_ALGORITHM_UNSPECIFIED',
7
+ AWS_SSE_S3 = 'AWS_SSE_S3',
8
+ AWS_SSE_KMS = 'AWS_SSE_KMS',
9
+ }
10
+
11
+ export enum VolumeType {
12
+ MANAGED = 'MANAGED',
13
+ EXTERNAL = 'EXTERNAL',
14
+ }
15
+
16
+ export interface CreateVolumeRequest {
17
+ /** The name of the volume */
18
+ name?: string | undefined;
19
+ /** The name of the catalog where the schema and the volume are */
20
+ catalogName?: string | undefined;
21
+ /** The name of the schema where the volume is */
22
+ schemaName?: string | undefined;
23
+ /**
24
+ * The type of the volume. An external volume is located in the specified external location.
25
+ * A managed volume is located in the default location which is specified by the parent schema, or the parent catalog, or the Metastore.
26
+ * [Learn more](https://docs.databricks.com/aws/en/volumes/managed-vs-external)
27
+ */
28
+ volumeType?: VolumeType | undefined;
29
+ /** The storage location on the cloud */
30
+ storageLocation?: string | undefined;
31
+ /** The identifier of the user who owns the volume */
32
+ owner?: string | undefined;
33
+ /** The comment attached to the volume */
34
+ comment?: string | undefined;
35
+ /** The three-level (fully qualified) name of the volume */
36
+ fullName?: string | undefined;
37
+ /** The unique identifier of the volume */
38
+ volumeId?: string | undefined;
39
+ /** The unique identifier of the metastore */
40
+ metastoreId?: string | undefined;
41
+ createdAt?: bigint | undefined;
42
+ /** The identifier of the user who created the volume */
43
+ createdBy?: string | undefined;
44
+ updatedAt?: bigint | undefined;
45
+ /** The identifier of the user who updated the volume last time */
46
+ updatedBy?: string | undefined;
47
+ /** The AWS access point to use when accesing s3 for this external location. */
48
+ accessPoint?: string | undefined;
49
+ encryptionDetails?: EncryptionDetails | undefined;
50
+ /** Indicates whether the principal is limited to retrieving metadata for the associated object through the BROWSE privilege when include_browse is enabled in the request. */
51
+ browseOnly?: boolean | undefined;
52
+ }
53
+
54
+ export interface DeleteVolumeRequest {
55
+ /** The three-level (fully qualified) name of the volume */
56
+ fullNameArg?: string | undefined;
57
+ }
58
+
59
+ // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
60
+ export interface DeleteVolumeRequest_Response {}
61
+
62
+ /** Encryption options that apply to clients connecting to cloud storage. */
63
+ export interface EncryptionDetails {
64
+ encryptionDetailsType?:
65
+ | {
66
+ $case: 'sseEncryptionDetails';
67
+ /** Server-Side Encryption properties for clients communicating with AWS s3. */
68
+ sseEncryptionDetails: SseEncryptionDetails;
69
+ }
70
+ | undefined;
71
+ }
72
+
73
+ export interface GetVolumeRequest {
74
+ /** The three-level (fully qualified) name of the volume */
75
+ fullNameArg?: string | undefined;
76
+ /** Whether to include volumes in the response for which the principal can only access selective metadata for */
77
+ includeBrowse?: boolean | undefined;
78
+ }
79
+
80
+ export interface ListVolumesRequest {
81
+ /** The identifier of the catalog */
82
+ catalogName?: string | undefined;
83
+ /** The identifier of the schema */
84
+ schemaName?: string | undefined;
85
+ /** Whether to include volumes in the response for which the principal can only access selective metadata for */
86
+ includeBrowse?: boolean | undefined;
87
+ /**
88
+ * Maximum number of volumes to return (page length).
89
+ *
90
+ * If not set, the page length is set to a server configured value (10000, as of 1/29/2024).
91
+ * - when set to a value greater than 0, the page length is the minimum of this value and a server configured value (10000, as of 1/29/2024);
92
+ * - when set to 0, the page length is set to a server configured value (10000, as of 1/29/2024) (recommended);
93
+ * - when set to a value less than 0, an invalid parameter error is returned;
94
+ *
95
+ * Note: this parameter controls only the maximum number of volumes to return. The actual number of volumes returned in a page
96
+ * may be smaller than this value, including 0, even if there are more pages.
97
+ */
98
+ maxResults?: number | undefined;
99
+ /** Opaque token returned by a previous request. It must be included in the request to retrieve the next page of results (pagination). */
100
+ pageToken?: string | undefined;
101
+ }
102
+
103
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
104
+ export interface ListVolumesRequest_Response {
105
+ volumes?: VolumeInfo[] | undefined;
106
+ /**
107
+ * Opaque token to retrieve the next page of results. Absent if there are no more pages.
108
+ * __page_token__ should be set to this value for the next request to retrieve the next page of results.
109
+ */
110
+ nextPageToken?: string | undefined;
111
+ }
112
+
113
+ /** Server-Side Encryption properties for clients communicating with AWS s3. */
114
+ export interface SseEncryptionDetails {
115
+ /** Sets the value of the 'x-amz-server-side-encryption' header in S3 request. */
116
+ algorithm?: SseEncryptionAlgorithm | undefined;
117
+ /**
118
+ * Optional. The ARN of the SSE-KMS key used with the S3 location, when algorithm = "SSE-KMS".
119
+ * Sets the value of the 'x-amz-server-side-encryption-aws-kms-key-id' header.
120
+ */
121
+ awsKmsKeyArn?: string | undefined;
122
+ }
123
+
124
+ export interface UpdateVolumeRequest {
125
+ /** The three-level (fully qualified) name of the volume */
126
+ fullNameArg?: string | undefined;
127
+ /** New name for the volume. */
128
+ newName?: string | undefined;
129
+ /** The name of the volume */
130
+ name?: string | undefined;
131
+ /** The name of the catalog where the schema and the volume are */
132
+ catalogName?: string | undefined;
133
+ /** The name of the schema where the volume is */
134
+ schemaName?: string | undefined;
135
+ /**
136
+ * The type of the volume. An external volume is located in the specified external location.
137
+ * A managed volume is located in the default location which is specified by the parent schema, or the parent catalog, or the Metastore.
138
+ * [Learn more](https://docs.databricks.com/aws/en/volumes/managed-vs-external)
139
+ */
140
+ volumeType?: VolumeType | undefined;
141
+ /** The storage location on the cloud */
142
+ storageLocation?: string | undefined;
143
+ /** The identifier of the user who owns the volume */
144
+ owner?: string | undefined;
145
+ /** The comment attached to the volume */
146
+ comment?: string | undefined;
147
+ /** The three-level (fully qualified) name of the volume */
148
+ fullName?: string | undefined;
149
+ /** The unique identifier of the volume */
150
+ volumeId?: string | undefined;
151
+ /** The unique identifier of the metastore */
152
+ metastoreId?: string | undefined;
153
+ createdAt?: bigint | undefined;
154
+ /** The identifier of the user who created the volume */
155
+ createdBy?: string | undefined;
156
+ updatedAt?: bigint | undefined;
157
+ /** The identifier of the user who updated the volume last time */
158
+ updatedBy?: string | undefined;
159
+ /** The AWS access point to use when accesing s3 for this external location. */
160
+ accessPoint?: string | undefined;
161
+ encryptionDetails?: EncryptionDetails | undefined;
162
+ /** Indicates whether the principal is limited to retrieving metadata for the associated object through the BROWSE privilege when include_browse is enabled in the request. */
163
+ browseOnly?: boolean | undefined;
164
+ }
165
+
166
+ export interface VolumeInfo {
167
+ /** The name of the volume */
168
+ name?: string | undefined;
169
+ /** The name of the catalog where the schema and the volume are */
170
+ catalogName?: string | undefined;
171
+ /** The name of the schema where the volume is */
172
+ schemaName?: string | undefined;
173
+ /**
174
+ * The type of the volume. An external volume is located in the specified external location.
175
+ * A managed volume is located in the default location which is specified by the parent schema, or the parent catalog, or the Metastore.
176
+ * [Learn more](https://docs.databricks.com/aws/en/volumes/managed-vs-external)
177
+ */
178
+ volumeType?: VolumeType | undefined;
179
+ /** The storage location on the cloud */
180
+ storageLocation?: string | undefined;
181
+ /** The identifier of the user who owns the volume */
182
+ owner?: string | undefined;
183
+ /** The comment attached to the volume */
184
+ comment?: string | undefined;
185
+ /** The three-level (fully qualified) name of the volume */
186
+ fullName?: string | undefined;
187
+ /** The unique identifier of the volume */
188
+ volumeId?: string | undefined;
189
+ /** The unique identifier of the metastore */
190
+ metastoreId?: string | undefined;
191
+ createdAt?: bigint | undefined;
192
+ /** The identifier of the user who created the volume */
193
+ createdBy?: string | undefined;
194
+ updatedAt?: bigint | undefined;
195
+ /** The identifier of the user who updated the volume last time */
196
+ updatedBy?: string | undefined;
197
+ /** The AWS access point to use when accesing s3 for this external location. */
198
+ accessPoint?: string | undefined;
199
+ encryptionDetails?: EncryptionDetails | undefined;
200
+ /** Indicates whether the principal is limited to retrieving metadata for the associated object through the BROWSE privilege when include_browse is enabled in the request. */
201
+ browseOnly?: boolean | undefined;
202
+ }
203
+
204
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
205
+ export const unmarshalDeleteVolumeRequest_ResponseSchema: z.ZodType<DeleteVolumeRequest_Response> =
206
+ z.object({});
207
+
208
+ export const unmarshalEncryptionDetailsSchema: z.ZodType<EncryptionDetails> = z
209
+ .object({
210
+ sse_encryption_details: z
211
+ .lazy(() => unmarshalSseEncryptionDetailsSchema)
212
+ .optional(),
213
+ })
214
+ .transform(d => ({
215
+ encryptionDetailsType:
216
+ d.sse_encryption_details !== undefined
217
+ ? {
218
+ $case: 'sseEncryptionDetails' as const,
219
+ sseEncryptionDetails: d.sse_encryption_details,
220
+ }
221
+ : undefined,
222
+ }));
223
+
224
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
225
+ export const unmarshalListVolumesRequest_ResponseSchema: z.ZodType<ListVolumesRequest_Response> =
226
+ z
227
+ .object({
228
+ volumes: z.array(z.lazy(() => unmarshalVolumeInfoSchema)).optional(),
229
+ next_page_token: z.string().optional(),
230
+ })
231
+ .transform(d => ({
232
+ volumes: d.volumes,
233
+ nextPageToken: d.next_page_token,
234
+ }));
235
+
236
+ export const unmarshalSseEncryptionDetailsSchema: z.ZodType<SseEncryptionDetails> =
237
+ z
238
+ .object({
239
+ algorithm: z.enum(SseEncryptionAlgorithm).optional(),
240
+ aws_kms_key_arn: z.string().optional(),
241
+ })
242
+ .transform(d => ({
243
+ algorithm: d.algorithm,
244
+ awsKmsKeyArn: d.aws_kms_key_arn,
245
+ }));
246
+
247
+ export const unmarshalVolumeInfoSchema: z.ZodType<VolumeInfo> = z
248
+ .object({
249
+ name: z.string().optional(),
250
+ catalog_name: z.string().optional(),
251
+ schema_name: z.string().optional(),
252
+ volume_type: z.enum(VolumeType).optional(),
253
+ storage_location: z.string().optional(),
254
+ owner: z.string().optional(),
255
+ comment: z.string().optional(),
256
+ full_name: z.string().optional(),
257
+ volume_id: z.string().optional(),
258
+ metastore_id: z.string().optional(),
259
+ created_at: z
260
+ .union([z.number(), z.bigint()])
261
+ .transform(v => BigInt(v))
262
+ .optional(),
263
+ created_by: z.string().optional(),
264
+ updated_at: z
265
+ .union([z.number(), z.bigint()])
266
+ .transform(v => BigInt(v))
267
+ .optional(),
268
+ updated_by: z.string().optional(),
269
+ access_point: z.string().optional(),
270
+ encryption_details: z
271
+ .lazy(() => unmarshalEncryptionDetailsSchema)
272
+ .optional(),
273
+ browse_only: z.boolean().optional(),
274
+ })
275
+ .transform(d => ({
276
+ name: d.name,
277
+ catalogName: d.catalog_name,
278
+ schemaName: d.schema_name,
279
+ volumeType: d.volume_type,
280
+ storageLocation: d.storage_location,
281
+ owner: d.owner,
282
+ comment: d.comment,
283
+ fullName: d.full_name,
284
+ volumeId: d.volume_id,
285
+ metastoreId: d.metastore_id,
286
+ createdAt: d.created_at,
287
+ createdBy: d.created_by,
288
+ updatedAt: d.updated_at,
289
+ updatedBy: d.updated_by,
290
+ accessPoint: d.access_point,
291
+ encryptionDetails: d.encryption_details,
292
+ browseOnly: d.browse_only,
293
+ }));
294
+
295
+ export const marshalCreateVolumeRequestSchema: z.ZodType = z
296
+ .object({
297
+ name: z.string().optional(),
298
+ catalogName: z.string().optional(),
299
+ schemaName: z.string().optional(),
300
+ volumeType: z.enum(VolumeType).optional(),
301
+ storageLocation: z.string().optional(),
302
+ owner: z.string().optional(),
303
+ comment: z.string().optional(),
304
+ fullName: z.string().optional(),
305
+ volumeId: z.string().optional(),
306
+ metastoreId: z.string().optional(),
307
+ createdAt: z.bigint().optional(),
308
+ createdBy: z.string().optional(),
309
+ updatedAt: z.bigint().optional(),
310
+ updatedBy: z.string().optional(),
311
+ accessPoint: z.string().optional(),
312
+ encryptionDetails: z.lazy(() => marshalEncryptionDetailsSchema).optional(),
313
+ browseOnly: z.boolean().optional(),
314
+ })
315
+ .transform(d => ({
316
+ name: d.name,
317
+ catalog_name: d.catalogName,
318
+ schema_name: d.schemaName,
319
+ volume_type: d.volumeType,
320
+ storage_location: d.storageLocation,
321
+ owner: d.owner,
322
+ comment: d.comment,
323
+ full_name: d.fullName,
324
+ volume_id: d.volumeId,
325
+ metastore_id: d.metastoreId,
326
+ created_at: d.createdAt,
327
+ created_by: d.createdBy,
328
+ updated_at: d.updatedAt,
329
+ updated_by: d.updatedBy,
330
+ access_point: d.accessPoint,
331
+ encryption_details: d.encryptionDetails,
332
+ browse_only: d.browseOnly,
333
+ }));
334
+
335
+ export const marshalEncryptionDetailsSchema: z.ZodType = z
336
+ .object({
337
+ encryptionDetailsType: z
338
+ .discriminatedUnion('$case', [
339
+ z.object({
340
+ $case: z.literal('sseEncryptionDetails'),
341
+ sseEncryptionDetails: z.lazy(() => marshalSseEncryptionDetailsSchema),
342
+ }),
343
+ ])
344
+ .optional(),
345
+ })
346
+ .transform(d => ({
347
+ ...(d.encryptionDetailsType?.$case === 'sseEncryptionDetails' && {
348
+ sse_encryption_details: d.encryptionDetailsType.sseEncryptionDetails,
349
+ }),
350
+ }));
351
+
352
+ export const marshalSseEncryptionDetailsSchema: z.ZodType = z
353
+ .object({
354
+ algorithm: z.enum(SseEncryptionAlgorithm).optional(),
355
+ awsKmsKeyArn: z.string().optional(),
356
+ })
357
+ .transform(d => ({
358
+ algorithm: d.algorithm,
359
+ aws_kms_key_arn: d.awsKmsKeyArn,
360
+ }));
361
+
362
+ export const marshalUpdateVolumeRequestSchema: z.ZodType = z
363
+ .object({
364
+ fullNameArg: z.string().optional(),
365
+ newName: z.string().optional(),
366
+ name: z.string().optional(),
367
+ catalogName: z.string().optional(),
368
+ schemaName: z.string().optional(),
369
+ volumeType: z.enum(VolumeType).optional(),
370
+ storageLocation: z.string().optional(),
371
+ owner: z.string().optional(),
372
+ comment: z.string().optional(),
373
+ fullName: z.string().optional(),
374
+ volumeId: z.string().optional(),
375
+ metastoreId: z.string().optional(),
376
+ createdAt: z.bigint().optional(),
377
+ createdBy: z.string().optional(),
378
+ updatedAt: z.bigint().optional(),
379
+ updatedBy: z.string().optional(),
380
+ accessPoint: z.string().optional(),
381
+ encryptionDetails: z.lazy(() => marshalEncryptionDetailsSchema).optional(),
382
+ browseOnly: z.boolean().optional(),
383
+ })
384
+ .transform(d => ({
385
+ full_name_arg: d.fullNameArg,
386
+ new_name: d.newName,
387
+ name: d.name,
388
+ catalog_name: d.catalogName,
389
+ schema_name: d.schemaName,
390
+ volume_type: d.volumeType,
391
+ storage_location: d.storageLocation,
392
+ owner: d.owner,
393
+ comment: d.comment,
394
+ full_name: d.fullName,
395
+ volume_id: d.volumeId,
396
+ metastore_id: d.metastoreId,
397
+ created_at: d.createdAt,
398
+ created_by: d.createdBy,
399
+ updated_at: d.updatedAt,
400
+ updated_by: d.updatedBy,
401
+ access_point: d.accessPoint,
402
+ encryption_details: d.encryptionDetails,
403
+ browse_only: d.browseOnly,
404
+ }));
@@ -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
+ }
@@ -0,0 +1,156 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import type {Call, Options} from '@databricks/sdk-core/api';
4
+ import {execute} from '@databricks/sdk-core/api';
5
+ import {ApiError} from '@databricks/sdk-core/apierror';
6
+ import type {
7
+ HttpClient,
8
+ HttpRequest,
9
+ HttpResponse,
10
+ } from '@databricks/sdk-core/http';
11
+ import type {Logger} from '@databricks/sdk-core/logger';
12
+ import type {CallOptions} from '@databricks/sdk-options/call';
13
+ import JSONBig from 'json-bigint';
14
+ import type {z} from 'zod';
15
+
16
+ // JSON codec that preserves int64 precision. On the way in, large integer
17
+ // literals come back as bigint instead of being rounded to JS Number. On the
18
+ // way out, bigint values are emitted as raw JSON number digits.
19
+ const jsonBigint = JSONBig({useNativeBigInt: true});
20
+
21
+ export interface HttpCallOptions {
22
+ readonly request: HttpRequest;
23
+ readonly httpClient: HttpClient;
24
+ readonly logger: Logger;
25
+ }
26
+
27
+ /**
28
+ * Translates public CallOptions to the internal Options shape accepted by
29
+ * execute(). Even though the shapes match today, this isolates the public
30
+ * API from the executor's internal type so they can diverge.
31
+ */
32
+ export async function executeCall(
33
+ call: Call,
34
+ options?: CallOptions
35
+ ): Promise<void> {
36
+ const opts: Options = {
37
+ ...(options?.retrier !== undefined && {retrier: options.retrier}),
38
+ ...(options?.rateLimiter !== undefined && {
39
+ rateLimiter: options.rateLimiter,
40
+ }),
41
+ ...(options?.timeout !== undefined && {timeout: options.timeout}),
42
+ };
43
+ return execute(options?.signal, call, opts);
44
+ }
45
+
46
+ async function readAll(
47
+ body: ReadableStream<Uint8Array> | null
48
+ ): Promise<Uint8Array> {
49
+ if (body === null) {
50
+ return new Uint8Array(0);
51
+ }
52
+ const reader = body.getReader();
53
+ const chunks: Uint8Array[] = [];
54
+ for (;;) {
55
+ const {done, value} = await reader.read();
56
+ if (done) {
57
+ break;
58
+ }
59
+ chunks.push(value);
60
+ }
61
+ const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
62
+ const result = new Uint8Array(totalLength);
63
+ let offset = 0;
64
+ for (const chunk of chunks) {
65
+ result.set(chunk, offset);
66
+ offset += chunk.length;
67
+ }
68
+ return result;
69
+ }
70
+
71
+ export async function executeHttpCall(
72
+ opts: HttpCallOptions
73
+ ): Promise<Uint8Array> {
74
+ opts.logger.debug('HTTP request', {
75
+ method: opts.request.method,
76
+ url: opts.request.url,
77
+ });
78
+
79
+ let resp: HttpResponse;
80
+ try {
81
+ resp = await opts.httpClient.send(opts.request);
82
+ } catch (e: unknown) {
83
+ opts.logger.debug('HTTP request failed');
84
+ throw e;
85
+ }
86
+
87
+ const body = await readAll(resp.body);
88
+
89
+ opts.logger.debug('HTTP response', {
90
+ statusCode: resp.statusCode,
91
+ body: new TextDecoder().decode(body),
92
+ });
93
+
94
+ const apiErr = ApiError.fromHttpError(resp.statusCode, resp.headers, body);
95
+ if (apiErr !== undefined) {
96
+ throw apiErr;
97
+ }
98
+
99
+ return body;
100
+ }
101
+
102
+ export function buildHttpRequest(
103
+ method: string,
104
+ url: string,
105
+ headers: Headers,
106
+ signal?: AbortSignal,
107
+ body?: string | ReadableStream<Uint8Array>
108
+ ): HttpRequest {
109
+ const req: HttpRequest = {url, method, headers};
110
+ if (body !== undefined) {
111
+ req.body = body;
112
+ }
113
+ if (signal !== undefined) {
114
+ req.signal = signal;
115
+ }
116
+ return req;
117
+ }
118
+
119
+ export function parseResponse<T>(body: Uint8Array, schema: z.ZodType<T>): T {
120
+ const text = new TextDecoder().decode(body);
121
+ const parsed: unknown = jsonBigint.parse(text);
122
+ return schema.parse(parsed);
123
+ }
124
+
125
+ export function marshalRequest(data: unknown, schema: z.ZodType): string {
126
+ return jsonBigint.stringify(schema.parse(data));
127
+ }
128
+
129
+ export function flattenQueryParams(
130
+ prefix: string,
131
+ value: unknown,
132
+ params: URLSearchParams
133
+ ): void {
134
+ if (value === null || value === undefined) {
135
+ return;
136
+ }
137
+ if (Array.isArray(value)) {
138
+ // arrays of objects are not yet supported
139
+ for (const item of value) {
140
+ params.append(prefix, String(item));
141
+ }
142
+ } else if (typeof value === 'object') {
143
+ for (const [key, val] of Object.entries(value as Record<string, unknown>)) {
144
+ flattenQueryParams(`${prefix}.${key}`, val, params);
145
+ }
146
+ } else if (
147
+ typeof value === 'string' ||
148
+ typeof value === 'number' ||
149
+ typeof value === 'boolean' ||
150
+ typeof value === 'bigint'
151
+ ) {
152
+ params.append(prefix, String(value));
153
+ } else {
154
+ throw new Error(`Unsupported query parameter type: ${typeof value}`);
155
+ }
156
+ }
package/README.md DELETED
@@ -1 +0,0 @@
1
- This is a placeholder release used to enable OIDC trusted publishing. Real code lands in a later version.
package/index.js DELETED
@@ -1 +0,0 @@
1
- module.exports = {};