@databricks/sdk-postgres 0.1.0-dev.2 → 0.1.0-dev.4

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/src/v1/index.ts CHANGED
@@ -41,6 +41,7 @@ export {
41
41
  } from './model';
42
42
 
43
43
  export type {
44
+ ApiError,
44
45
  Branch,
45
46
  BranchOperationMetadata,
46
47
  BranchSpec,
@@ -61,7 +62,6 @@ export type {
61
62
  Database_DatabaseStatus,
62
63
  DatabaseCredential,
63
64
  DatabaseOperationMetadata,
64
- DatabricksServiceExceptionWithDetailsProto,
65
65
  DeleteBranchRequest,
66
66
  DeleteCatalogRequest,
67
67
  DeleteDatabaseRequest,
package/src/v1/model.ts CHANGED
@@ -685,6 +685,14 @@ export enum SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy {
685
685
  SNAPSHOT = 'SNAPSHOT',
686
686
  }
687
687
 
688
+ /** Databricks Error that is returned by all Databricks APIs. */
689
+ export interface ApiError {
690
+ errorCode?: ErrorCode | undefined;
691
+ message?: string | undefined;
692
+ stackTrace?: string | undefined;
693
+ details?: Record<string, unknown>[] | undefined;
694
+ }
695
+
688
696
  export interface Branch {
689
697
  /**
690
698
  * Output only. The full resource path of the branch.
@@ -1061,14 +1069,6 @@ export interface DatabaseCredential {
1061
1069
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
1062
1070
  export interface DatabaseOperationMetadata {}
1063
1071
 
1064
- /** Databricks Error that is returned by all Databricks APIs. */
1065
- export interface DatabricksServiceExceptionWithDetailsProto {
1066
- errorCode?: ErrorCode | undefined;
1067
- message?: string | undefined;
1068
- stackTrace?: string | undefined;
1069
- details?: Record<string, unknown>[] | undefined;
1070
- }
1071
-
1072
1072
  export interface DeleteBranchRequest {
1073
1073
  /**
1074
1074
  * The full resource path of the branch to delete.
@@ -1555,7 +1555,7 @@ export interface Operation {
1555
1555
  | {
1556
1556
  $case: 'error';
1557
1557
  /** The error result of the operation in case of failure or cancellation. */
1558
- error: DatabricksServiceExceptionWithDetailsProto;
1558
+ error: ApiError;
1559
1559
  }
1560
1560
  | {
1561
1561
  $case: 'response';
@@ -2058,6 +2058,20 @@ export interface UpdateRoleRequest {
2058
2058
  updateMask?: FieldMask<Role> | undefined;
2059
2059
  }
2060
2060
 
2061
+ export const unmarshalApiErrorSchema: z.ZodType<ApiError> = z
2062
+ .object({
2063
+ error_code: z.enum(ErrorCode).optional(),
2064
+ message: z.string().optional(),
2065
+ stack_trace: z.string().optional(),
2066
+ details: z.array(z.record(z.string(), z.unknown())).optional(),
2067
+ })
2068
+ .transform(d => ({
2069
+ errorCode: d.error_code,
2070
+ message: d.message,
2071
+ stackTrace: d.stack_trace,
2072
+ details: d.details,
2073
+ }));
2074
+
2061
2075
  export const unmarshalBranchSchema: z.ZodType<Branch> = z
2062
2076
  .object({
2063
2077
  name: z.string().optional(),
@@ -2293,21 +2307,6 @@ export const unmarshalDatabaseCredentialSchema: z.ZodType<DatabaseCredential> =
2293
2307
  export const unmarshalDatabaseOperationMetadataSchema: z.ZodType<DatabaseOperationMetadata> =
2294
2308
  z.object({});
2295
2309
 
2296
- export const unmarshalDatabricksServiceExceptionWithDetailsProtoSchema: z.ZodType<DatabricksServiceExceptionWithDetailsProto> =
2297
- z
2298
- .object({
2299
- error_code: z.enum(ErrorCode).optional(),
2300
- message: z.string().optional(),
2301
- stack_trace: z.string().optional(),
2302
- details: z.array(z.record(z.string(), z.unknown())).optional(),
2303
- })
2304
- .transform(d => ({
2305
- errorCode: d.error_code,
2306
- message: d.message,
2307
- stackTrace: d.stack_trace,
2308
- details: d.details,
2309
- }));
2310
-
2311
2310
  export const unmarshalDeltaTableSyncInfoSchema: z.ZodType<DeltaTableSyncInfo> =
2312
2311
  z
2313
2312
  .object({
@@ -2540,9 +2539,7 @@ export const unmarshalOperationSchema: z.ZodType<Operation> = z
2540
2539
  name: z.string().optional(),
2541
2540
  metadata: z.record(z.string(), z.unknown()).optional(),
2542
2541
  done: z.boolean().optional(),
2543
- error: z
2544
- .lazy(() => unmarshalDatabricksServiceExceptionWithDetailsProtoSchema)
2545
- .optional(),
2542
+ error: z.lazy(() => unmarshalApiErrorSchema).optional(),
2546
2543
  response: z.record(z.string(), z.unknown()).optional(),
2547
2544
  })
2548
2545
  .transform(d => ({
package/src/v1/utils.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
2
 
3
- import type {Call, Options} from '@databricks/sdk-core/api';
4
- import {execute} from '@databricks/sdk-core/api';
3
+ import type {Options} from '@databricks/sdk-core/ops';
4
+ import {execute, retryOn} from '@databricks/sdk-core/ops';
5
5
  import {ApiError} from '@databricks/sdk-core/apierror';
6
6
  import type {
7
7
  HttpClient,
@@ -10,6 +10,7 @@ import type {
10
10
  } from '@databricks/sdk-core/http';
11
11
  import type {Logger} from '@databricks/sdk-core/logger';
12
12
  import type {CallOptions} from '@databricks/sdk-options/call';
13
+ import type {LroOptions} from '@databricks/sdk-options/lro';
13
14
  import JSONBig from 'json-bigint';
14
15
  import type {z} from 'zod';
15
16
 
@@ -30,7 +31,7 @@ export interface HttpCallOptions {
30
31
  * API from the executor's internal type so they can diverge.
31
32
  */
32
33
  export async function executeCall(
33
- call: Call,
34
+ call: (signal?: AbortSignal) => Promise<void>,
34
35
  options?: CallOptions
35
36
  ): Promise<void> {
36
37
  const opts: Options = {
@@ -43,6 +44,29 @@ export async function executeCall(
43
44
  return execute(options?.signal, call, opts);
44
45
  }
45
46
 
47
+ /**
48
+ * Sentinel thrown by a polling call to signal that the operation has not
49
+ * yet reached a terminal state. {@link executeWait} treats this error as
50
+ * retriable; any other error aborts the wait.
51
+ */
52
+ export class StillRunningError extends Error {}
53
+
54
+ /**
55
+ * Polls until the call returns without throwing {@link StillRunningError}.
56
+ * Abort and overall-deadline behavior come from the supplied LroOptions.
57
+ */
58
+ export async function executeWait(
59
+ call: (signal?: AbortSignal) => Promise<void>,
60
+ options?: LroOptions
61
+ ): Promise<void> {
62
+ const opts: Options = {
63
+ ...(options?.timeout !== undefined && {timeout: options.timeout}),
64
+ retrier: () =>
65
+ retryOn({}, (err: Error) => err instanceof StillRunningError),
66
+ };
67
+ return execute(options?.signal, call, opts);
68
+ }
69
+
46
70
  async function readAll(
47
71
  body: ReadableStream<Uint8Array> | null
48
72
  ): Promise<Uint8Array> {