-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodel.ts
More file actions
267 lines (239 loc) · 7.35 KB
/
Copy pathmodel.ts
File metadata and controls
267 lines (239 loc) · 7.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
import type {JsonValue, JsonObject} from '@databricks/sdk-core/wkt';
import {z} from 'zod';
const jsonValueSchema: z.ZodType<JsonValue> = z.lazy(() =>
z.union([
z.null(),
z.number(),
z.string(),
z.boolean(),
z.record(z.string(), jsonValueSchema),
z.array(jsonValueSchema),
])
);
const jsonObjectSchema: z.ZodType<JsonObject> = z.record(
z.string(),
jsonValueSchema
);
// eslint-disable-next-line @typescript-eslint/naming-convention -- Enum-style const object.
export const CommandStatus = {
COMMAND_STATUS_UNSPECIFIED: '',
COMMAND_CANCELLED: 'Cancelled',
COMMAND_CANCELLING: 'Cancelling',
COMMAND_ERROR: 'Error',
COMMAND_FINISHED: 'Finished',
COMMAND_QUEUED: 'Queued',
COMMAND_RUNNING: 'Running',
} as const;
export type CommandStatus =
| (typeof CommandStatus)[keyof typeof CommandStatus]
| (string & {});
// eslint-disable-next-line @typescript-eslint/naming-convention -- Enum-style const object.
export const ContextStatus = {
CONTEXT_STATUS_UNSPECIFIED: '',
CONTEXT_RUNNING: 'Running',
CONTEXT_PENDING: 'Pending',
CONTEXT_ERROR: 'Error',
} as const;
export type ContextStatus =
| (typeof ContextStatus)[keyof typeof ContextStatus]
| (string & {});
// eslint-disable-next-line @typescript-eslint/naming-convention -- Enum-style const object.
export const Language = {
LANGUAGE_UNSPECIFIED: '',
PYTHON: 'python',
SCALA: 'scala',
SQL: 'sql',
R: 'r',
} as const;
export type Language = (typeof Language)[keyof typeof Language] | (string & {});
// eslint-disable-next-line @typescript-eslint/naming-convention -- Enum-style const object.
export const ResultType = {
RESULT_TYPE_UNSPECIFIED: '',
ERROR_RESULT: 'error',
IMAGE_RESULT: 'image',
IMAGES_RESULT: 'images',
TABLE_RESULT: 'table',
TEXT_RESULT: 'text',
} as const;
export type ResultType =
| (typeof ResultType)[keyof typeof ResultType]
| (string & {});
export interface CancelCommandRequest {
clusterId?: string | undefined;
commandId?: string | undefined;
contextId?: string | undefined;
}
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface CancelResponse {}
export interface CreateContextRequest {
/** Running cluster id */
clusterId?: string | undefined;
language?: Language | undefined;
}
export interface CreateResponse {
id?: string | undefined;
}
export interface DestroyContextRequest {
clusterId?: string | undefined;
contextId?: string | undefined;
}
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface DestroyResponse {}
export interface ExecuteCommandRequest {
/** Running cluster id */
clusterId?: string | undefined;
/** Running context id */
contextId?: string | undefined;
language?: Language | undefined;
/** Executable code */
command?: string | undefined;
}
/** Request to get the status of a previously submitted command. */
export interface GetCommandStatusRequest {
clusterId?: string | undefined;
contextId?: string | undefined;
commandId?: string | undefined;
}
export interface GetCommandStatusResponse {
id?: string | undefined;
status?: CommandStatus | undefined;
results?: Results | undefined;
}
/** Request to retrieve the status of an execution context. */
export interface GetContextStatusRequest {
clusterId?: string | undefined;
contextId?: string | undefined;
}
export interface GetContextStatusResponse {
id?: string | undefined;
status?: ContextStatus | undefined;
}
export interface Results {
/** The cause of the error */
cause?: string | undefined;
data?: JsonValue | undefined;
/**
* The image data in one of the following formats:
*
* 1. A Data URL with base64-encoded image data: `data:image/{type};base64,{base64-data}`.
* Example: `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...`
*
* 2. A FileStore file path for large images: `/plots/{filename}.png`.
* Example: `/plots/b6a7ad70-fb2c-4353-8aed-3f1e015174a4.png`
*/
fileName?: string | undefined;
/** List of image data for multiple images. Each element follows the same format as file_name. */
fileNames?: string[] | undefined;
/** true if a JSON schema is returned instead of a string representation of the Hive type. */
isJsonSchema?: boolean | undefined;
/** internal field used by SDK */
pos?: number | undefined;
resultType?: ResultType | undefined;
/** The table schema */
schema?: JsonObject[] | undefined;
/** The summary of the error */
summary?: string | undefined;
/** true if partial results are returned. */
truncated?: boolean | undefined;
}
export const unmarshalCancelResponseSchema: z.ZodType<CancelResponse> =
z.object({});
export const unmarshalCreateResponseSchema: z.ZodType<CreateResponse> = z
.object({
id: z.string().optional(),
})
.transform(d => ({
id: d.id,
}));
export const unmarshalDestroyResponseSchema: z.ZodType<DestroyResponse> =
z.object({});
export const unmarshalGetCommandStatusResponseSchema: z.ZodType<GetCommandStatusResponse> =
z
.object({
id: z.string().optional(),
status: z.string().optional(),
results: z.lazy(() => unmarshalResultsSchema).optional(),
})
.transform(d => ({
id: d.id,
status: d.status,
results: d.results,
}));
export const unmarshalGetContextStatusResponseSchema: z.ZodType<GetContextStatusResponse> =
z
.object({
id: z.string().optional(),
status: z.string().optional(),
})
.transform(d => ({
id: d.id,
status: d.status,
}));
export const unmarshalResultsSchema: z.ZodType<Results> = z
.object({
cause: z.string().optional(),
data: jsonValueSchema.optional(),
fileName: z.string().optional(),
fileNames: z.array(z.string()).optional(),
isJsonSchema: z.boolean().optional(),
pos: z.number().optional(),
resultType: z.string().optional(),
schema: z.array(jsonObjectSchema).optional(),
summary: z.string().optional(),
truncated: z.boolean().optional(),
})
.transform(d => ({
cause: d.cause,
data: d.data,
fileName: d.fileName,
fileNames: d.fileNames,
isJsonSchema: d.isJsonSchema,
pos: d.pos,
resultType: d.resultType,
schema: d.schema,
summary: d.summary,
truncated: d.truncated,
}));
export const marshalCancelCommandRequestSchema: z.ZodType = z
.object({
clusterId: z.string().optional(),
commandId: z.string().optional(),
contextId: z.string().optional(),
})
.transform(d => ({
clusterId: d.clusterId,
commandId: d.commandId,
contextId: d.contextId,
}));
export const marshalCreateContextRequestSchema: z.ZodType = z
.object({
clusterId: z.string().optional(),
language: z.string().optional(),
})
.transform(d => ({
clusterId: d.clusterId,
language: d.language,
}));
export const marshalDestroyContextRequestSchema: z.ZodType = z
.object({
clusterId: z.string().optional(),
contextId: z.string().optional(),
})
.transform(d => ({
clusterId: d.clusterId,
contextId: d.contextId,
}));
export const marshalExecuteCommandRequestSchema: z.ZodType = z
.object({
clusterId: z.string().optional(),
contextId: z.string().optional(),
language: z.string().optional(),
command: z.string().optional(),
})
.transform(d => ({
clusterId: d.clusterId,
contextId: d.contextId,
language: d.language,
command: d.command,
}));