@databricks/sdk-queries 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/model.ts DELETED
@@ -1,995 +0,0 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
-
3
- import {Temporal} from '@js-temporal/polyfill';
4
- import {FieldMask} from '@databricks/sdk-core/wkt';
5
- import type {FieldMaskSchema} from '@databricks/sdk-core/wkt';
6
- import {z} from 'zod';
7
-
8
- export enum DatePrecision {
9
- DAY_PRECISION = 'DAY_PRECISION',
10
- MINUTE_PRECISION = 'MINUTE_PRECISION',
11
- SECOND_PRECISION = 'SECOND_PRECISION',
12
- }
13
-
14
- export enum LifecycleState {
15
- ACTIVE = 'ACTIVE',
16
- TRASHED = 'TRASHED',
17
- }
18
-
19
- export enum RunAsMode {
20
- OWNER = 'OWNER',
21
- VIEWER = 'VIEWER',
22
- }
23
-
24
- // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested enum name.
25
- export enum DateRangeValue_DynamicDateRange {
26
- TODAY = 'TODAY',
27
- YESTERDAY = 'YESTERDAY',
28
- THIS_WEEK = 'THIS_WEEK',
29
- THIS_MONTH = 'THIS_MONTH',
30
- THIS_YEAR = 'THIS_YEAR',
31
- LAST_WEEK = 'LAST_WEEK',
32
- LAST_MONTH = 'LAST_MONTH',
33
- LAST_YEAR = 'LAST_YEAR',
34
- LAST_HOUR = 'LAST_HOUR',
35
- LAST_8_HOURS = 'LAST_8_HOURS',
36
- LAST_24_HOURS = 'LAST_24_HOURS',
37
- LAST_7_DAYS = 'LAST_7_DAYS',
38
- LAST_14_DAYS = 'LAST_14_DAYS',
39
- LAST_30_DAYS = 'LAST_30_DAYS',
40
- LAST_60_DAYS = 'LAST_60_DAYS',
41
- LAST_90_DAYS = 'LAST_90_DAYS',
42
- LAST_12_MONTHS = 'LAST_12_MONTHS',
43
- }
44
-
45
- // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested enum name.
46
- export enum DateValue_DynamicDate {
47
- NOW = 'NOW',
48
- YESTERDAY = 'YESTERDAY',
49
- }
50
-
51
- export interface CreateQueryRequest {
52
- query?: CreateQueryRequestQuery | undefined;
53
- /** If true, automatically resolve query display name conflicts. Otherwise, fail the request if the query's display name conflicts with an existing query's display name. */
54
- autoResolveDisplayName?: boolean | undefined;
55
- }
56
-
57
- export interface CreateQueryRequestQuery {
58
- /** UUID identifying the query. */
59
- id?: string | undefined;
60
- /** Display name of the query that appears in list views, widget headings, and on the query page. */
61
- displayName?: string | undefined;
62
- /** General description that conveys additional information about this query such as usage notes. */
63
- description?: string | undefined;
64
- /** Username of the user that owns the query. */
65
- ownerUserName?: string | undefined;
66
- /** ID of the SQL warehouse attached to the query. */
67
- warehouseId?: string | undefined;
68
- /** Text of the query to be run. */
69
- queryText?: string | undefined;
70
- /** Sets the "Run as" role for the object. */
71
- runAsMode?: RunAsMode | undefined;
72
- /** Indicates whether the query is trashed. */
73
- lifecycleState?: LifecycleState | undefined;
74
- /** Username of the user who last saved changes to this query. */
75
- lastModifierUserName?: string | undefined;
76
- /** Workspace path of the workspace folder containing the object. */
77
- parentPath?: string | undefined;
78
- tags?: string[] | undefined;
79
- /** Timestamp when this query was created. */
80
- createTime?: Temporal.Instant | undefined;
81
- /** Timestamp when this query was last updated. */
82
- updateTime?: Temporal.Instant | undefined;
83
- /** List of query parameter definitions. */
84
- parameters?: QueryParameter[] | undefined;
85
- /** Whether to apply a 1000 row limit to the query result. */
86
- applyAutoLimit?: boolean | undefined;
87
- /** Name of the catalog where this query will be executed. */
88
- catalog?: string | undefined;
89
- /** Name of the schema where this query will be executed. */
90
- schema?: string | undefined;
91
- }
92
-
93
- export interface DateRange {
94
- start?: string | undefined;
95
- end?: string | undefined;
96
- }
97
-
98
- export interface DateRangeValue {
99
- value?:
100
- | {
101
- $case: 'dynamicDateRangeValue';
102
- /** Dynamic date-time range value based on current date-time. */
103
- dynamicDateRangeValue: DateRangeValue_DynamicDateRange;
104
- }
105
- | {
106
- $case: 'dateRangeValue';
107
- /** Manually specified date-time range value. */
108
- dateRangeValue: DateRange;
109
- }
110
- | undefined;
111
- /** Date-time precision to format the value into when the query is run. Defaults to DAY_PRECISION (YYYY-MM-DD). */
112
- precision?: DatePrecision | undefined;
113
- startDayOfWeek?: number | undefined;
114
- }
115
-
116
- export interface DateValue {
117
- value?:
118
- | {
119
- $case: 'dynamicDateValue';
120
- /** Dynamic date-time value based on current date-time. */
121
- dynamicDateValue: DateValue_DynamicDate;
122
- }
123
- | {
124
- $case: 'dateValue';
125
- /** Manually specified date-time value. */
126
- dateValue: string;
127
- }
128
- | undefined;
129
- /** Date-time precision to format the value into when the query is run. Defaults to DAY_PRECISION (YYYY-MM-DD). */
130
- precision?: DatePrecision | undefined;
131
- }
132
-
133
- /**
134
- * Represents an empty message, similar to google.protobuf.Empty, which is not available in the firm
135
- * right now.
136
- */
137
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
138
- export interface Empty {}
139
-
140
- export interface EnumValue {
141
- /** List of selected query parameter values. */
142
- values?: string[] | undefined;
143
- /** List of valid query parameter values, newline delimited. */
144
- enumOptions?: string | undefined;
145
- /** If specified, allows multiple values to be selected for this parameter. */
146
- multiValuesOptions?: MultiValuesOptions | undefined;
147
- }
148
-
149
- export interface GetQueryRequest {
150
- id?: string | undefined;
151
- }
152
-
153
- export interface ListQueriesRequest {
154
- pageToken?: string | undefined;
155
- pageSize?: number | undefined;
156
- }
157
-
158
- export interface ListQueriesResponse {
159
- results?: ListQueryObjectsResponseQuery[] | undefined;
160
- nextPageToken?: string | undefined;
161
- }
162
-
163
- export interface ListQueryObjectsResponseQuery {
164
- /** UUID identifying the query. */
165
- id?: string | undefined;
166
- /** Display name of the query that appears in list views, widget headings, and on the query page. */
167
- displayName?: string | undefined;
168
- /** General description that conveys additional information about this query such as usage notes. */
169
- description?: string | undefined;
170
- /** Username of the user that owns the query. */
171
- ownerUserName?: string | undefined;
172
- /** ID of the SQL warehouse attached to the query. */
173
- warehouseId?: string | undefined;
174
- /** Text of the query to be run. */
175
- queryText?: string | undefined;
176
- /** Sets the "Run as" role for the object. */
177
- runAsMode?: RunAsMode | undefined;
178
- /** Indicates whether the query is trashed. */
179
- lifecycleState?: LifecycleState | undefined;
180
- /** Username of the user who last saved changes to this query. */
181
- lastModifierUserName?: string | undefined;
182
- /** Workspace path of the workspace folder containing the object. */
183
- parentPath?: string | undefined;
184
- tags?: string[] | undefined;
185
- /** Timestamp when this query was created. */
186
- createTime?: Temporal.Instant | undefined;
187
- /** Timestamp when this query was last updated. */
188
- updateTime?: Temporal.Instant | undefined;
189
- /** List of query parameter definitions. */
190
- parameters?: QueryParameter[] | undefined;
191
- /** Whether to apply a 1000 row limit to the query result. */
192
- applyAutoLimit?: boolean | undefined;
193
- /** Name of the catalog where this query will be executed. */
194
- catalog?: string | undefined;
195
- /** Name of the schema where this query will be executed. */
196
- schema?: string | undefined;
197
- }
198
-
199
- export interface ListVisualizationsForQueryRequest {
200
- id?: string | undefined;
201
- pageToken?: string | undefined;
202
- pageSize?: number | undefined;
203
- }
204
-
205
- export interface ListVisualizationsForQueryResponse {
206
- results?: Visualization[] | undefined;
207
- nextPageToken?: string | undefined;
208
- }
209
-
210
- export interface MultiValuesOptions {
211
- /** Character that prefixes each selected parameter value. */
212
- prefix?: string | undefined;
213
- /** Character that separates each selected parameter value. Defaults to a comma. */
214
- separator?: string | undefined;
215
- /** Character that suffixes each selected parameter value. */
216
- suffix?: string | undefined;
217
- }
218
-
219
- export interface NumericValue {
220
- value?: number | undefined;
221
- }
222
-
223
- export interface Query {
224
- /** UUID identifying the query. */
225
- id?: string | undefined;
226
- /** Display name of the query that appears in list views, widget headings, and on the query page. */
227
- displayName?: string | undefined;
228
- /** General description that conveys additional information about this query such as usage notes. */
229
- description?: string | undefined;
230
- /** Username of the user that owns the query. */
231
- ownerUserName?: string | undefined;
232
- /** ID of the SQL warehouse attached to the query. */
233
- warehouseId?: string | undefined;
234
- /** Text of the query to be run. */
235
- queryText?: string | undefined;
236
- /** Sets the "Run as" role for the object. */
237
- runAsMode?: RunAsMode | undefined;
238
- /** Indicates whether the query is trashed. */
239
- lifecycleState?: LifecycleState | undefined;
240
- /** Username of the user who last saved changes to this query. */
241
- lastModifierUserName?: string | undefined;
242
- /** Workspace path of the workspace folder containing the object. */
243
- parentPath?: string | undefined;
244
- tags?: string[] | undefined;
245
- /** Timestamp when this query was created. */
246
- createTime?: Temporal.Instant | undefined;
247
- /** Timestamp when this query was last updated. */
248
- updateTime?: Temporal.Instant | undefined;
249
- /** List of query parameter definitions. */
250
- parameters?: QueryParameter[] | undefined;
251
- /** Whether to apply a 1000 row limit to the query result. */
252
- applyAutoLimit?: boolean | undefined;
253
- /** Name of the catalog where this query will be executed. */
254
- catalog?: string | undefined;
255
- /** Name of the schema where this query will be executed. */
256
- schema?: string | undefined;
257
- }
258
-
259
- export interface QueryBackedValue {
260
- /** List of selected query parameter values. */
261
- values?: string[] | undefined;
262
- /** UUID of the query that provides the parameter values. */
263
- queryId?: string | undefined;
264
- /** If specified, allows multiple values to be selected for this parameter. */
265
- multiValuesOptions?: MultiValuesOptions | undefined;
266
- }
267
-
268
- export interface QueryParameter {
269
- /** Text displayed in the user-facing parameter widget in the UI. */
270
- title?: string | undefined;
271
- /** Literal parameter marker that appears between double curly braces in the query text. */
272
- name?: string | undefined;
273
- /** Only one of the following fields may be set, depending on the type of parameter. */
274
- parameterValue?:
275
- | {
276
- $case: 'textValue';
277
- /** Text query parameter value. */
278
- textValue: TextValue;
279
- }
280
- | {
281
- $case: 'numericValue';
282
- /** Numeric query parameter value. */
283
- numericValue: NumericValue;
284
- }
285
- | {
286
- $case: 'enumValue';
287
- /** Dropdown query parameter value. */
288
- enumValue: EnumValue;
289
- }
290
- | {
291
- $case: 'dateValue';
292
- /** Date query parameter value. Can only specify one of `dynamic_date_value` or `date_value`. */
293
- dateValue: DateValue;
294
- }
295
- | {
296
- $case: 'dateRangeValue';
297
- /** Date-range query parameter value. Can only specify one of `dynamic_date_range_value` or `date_range_value`. */
298
- dateRangeValue: DateRangeValue;
299
- }
300
- | {
301
- $case: 'queryBackedValue';
302
- /** Query-based dropdown query parameter value. */
303
- queryBackedValue: QueryBackedValue;
304
- }
305
- | undefined;
306
- }
307
-
308
- export interface TextValue {
309
- value?: string | undefined;
310
- }
311
-
312
- export interface TrashQueryRequest {
313
- id?: string | undefined;
314
- }
315
-
316
- export interface UpdateQueryRequest {
317
- query?: UpdateQueryRequestQuery | undefined;
318
- updateMask?: FieldMask<UpdateQueryRequestQuery> | undefined;
319
- id?: string | undefined;
320
- /** If true, automatically resolve alert display name conflicts. Otherwise, fail the request if the alert's display name conflicts with an existing alert's display name. */
321
- autoResolveDisplayName?: boolean | undefined;
322
- }
323
-
324
- export interface UpdateQueryRequestQuery {
325
- /** UUID identifying the query. */
326
- id?: string | undefined;
327
- /** Display name of the query that appears in list views, widget headings, and on the query page. */
328
- displayName?: string | undefined;
329
- /** General description that conveys additional information about this query such as usage notes. */
330
- description?: string | undefined;
331
- /** Username of the user that owns the query. */
332
- ownerUserName?: string | undefined;
333
- /** ID of the SQL warehouse attached to the query. */
334
- warehouseId?: string | undefined;
335
- /** Text of the query to be run. */
336
- queryText?: string | undefined;
337
- /** Sets the "Run as" role for the object. */
338
- runAsMode?: RunAsMode | undefined;
339
- /** Indicates whether the query is trashed. */
340
- lifecycleState?: LifecycleState | undefined;
341
- /** Username of the user who last saved changes to this query. */
342
- lastModifierUserName?: string | undefined;
343
- /** Workspace path of the workspace folder containing the object. */
344
- parentPath?: string | undefined;
345
- tags?: string[] | undefined;
346
- /** Timestamp when this query was created. */
347
- createTime?: Temporal.Instant | undefined;
348
- /** Timestamp when this query was last updated. */
349
- updateTime?: Temporal.Instant | undefined;
350
- /** List of query parameter definitions. */
351
- parameters?: QueryParameter[] | undefined;
352
- /** Whether to apply a 1000 row limit to the query result. */
353
- applyAutoLimit?: boolean | undefined;
354
- /** Name of the catalog where this query will be executed. */
355
- catalog?: string | undefined;
356
- /** Name of the schema where this query will be executed. */
357
- schema?: string | undefined;
358
- }
359
-
360
- export interface Visualization {
361
- /** UUID identifying the visualization. */
362
- id?: string | undefined;
363
- /** The display name of the visualization. */
364
- displayName?: string | undefined;
365
- /** The type of visualization: counter, table, funnel, and so on. */
366
- type?: string | undefined;
367
- /** The timestamp indicating when the visualization was created. */
368
- createTime?: Temporal.Instant | undefined;
369
- /** The timestamp indicating when the visualization was updated. */
370
- updateTime?: Temporal.Instant | undefined;
371
- /** The visualization query plan varies widely from one visualization type to the next and is unsupported. Databricks does not recommend modifying the visualization query plan directly. */
372
- serializedQueryPlan?: string | undefined;
373
- /** The visualization options varies widely from one visualization type to the next and is unsupported. Databricks does not recommend modifying visualization options directly. */
374
- serializedOptions?: string | undefined;
375
- /** UUID of the query that the visualization is attached to. */
376
- queryId?: string | undefined;
377
- }
378
-
379
- export const unmarshalDateRangeSchema: z.ZodType<DateRange> = z
380
- .object({
381
- start: z.string().optional(),
382
- end: z.string().optional(),
383
- })
384
- .transform(d => ({
385
- start: d.start,
386
- end: d.end,
387
- }));
388
-
389
- export const unmarshalDateRangeValueSchema: z.ZodType<DateRangeValue> = z
390
- .object({
391
- dynamic_date_range_value: z
392
- .enum(DateRangeValue_DynamicDateRange)
393
- .optional(),
394
- date_range_value: z.lazy(() => unmarshalDateRangeSchema).optional(),
395
- precision: z.enum(DatePrecision).optional(),
396
- start_day_of_week: z.number().optional(),
397
- })
398
- .transform(d => ({
399
- value:
400
- d.dynamic_date_range_value !== undefined
401
- ? {
402
- $case: 'dynamicDateRangeValue' as const,
403
- dynamicDateRangeValue: d.dynamic_date_range_value,
404
- }
405
- : d.date_range_value !== undefined
406
- ? {
407
- $case: 'dateRangeValue' as const,
408
- dateRangeValue: d.date_range_value,
409
- }
410
- : undefined,
411
- precision: d.precision,
412
- startDayOfWeek: d.start_day_of_week,
413
- }));
414
-
415
- export const unmarshalDateValueSchema: z.ZodType<DateValue> = z
416
- .object({
417
- dynamic_date_value: z.enum(DateValue_DynamicDate).optional(),
418
- date_value: z.string().optional(),
419
- precision: z.enum(DatePrecision).optional(),
420
- })
421
- .transform(d => ({
422
- value:
423
- d.dynamic_date_value !== undefined
424
- ? {
425
- $case: 'dynamicDateValue' as const,
426
- dynamicDateValue: d.dynamic_date_value,
427
- }
428
- : d.date_value !== undefined
429
- ? {$case: 'dateValue' as const, dateValue: d.date_value}
430
- : undefined,
431
- precision: d.precision,
432
- }));
433
-
434
- export const unmarshalEmptySchema: z.ZodType<Empty> = z.object({});
435
-
436
- export const unmarshalEnumValueSchema: z.ZodType<EnumValue> = z
437
- .object({
438
- values: z.array(z.string()).optional(),
439
- enum_options: z.string().optional(),
440
- multi_values_options: z
441
- .lazy(() => unmarshalMultiValuesOptionsSchema)
442
- .optional(),
443
- })
444
- .transform(d => ({
445
- values: d.values,
446
- enumOptions: d.enum_options,
447
- multiValuesOptions: d.multi_values_options,
448
- }));
449
-
450
- export const unmarshalListQueriesResponseSchema: z.ZodType<ListQueriesResponse> =
451
- z
452
- .object({
453
- results: z
454
- .array(z.lazy(() => unmarshalListQueryObjectsResponseQuerySchema))
455
- .optional(),
456
- next_page_token: z.string().optional(),
457
- })
458
- .transform(d => ({
459
- results: d.results,
460
- nextPageToken: d.next_page_token,
461
- }));
462
-
463
- export const unmarshalListQueryObjectsResponseQuerySchema: z.ZodType<ListQueryObjectsResponseQuery> =
464
- z
465
- .object({
466
- id: z.string().optional(),
467
- display_name: z.string().optional(),
468
- description: z.string().optional(),
469
- owner_user_name: z.string().optional(),
470
- warehouse_id: z.string().optional(),
471
- query_text: z.string().optional(),
472
- run_as_mode: z.enum(RunAsMode).optional(),
473
- lifecycle_state: z.enum(LifecycleState).optional(),
474
- last_modifier_user_name: z.string().optional(),
475
- parent_path: z.string().optional(),
476
- tags: z.array(z.string()).optional(),
477
- create_time: z
478
- .string()
479
- .transform(s => Temporal.Instant.from(s))
480
- .optional(),
481
- update_time: z
482
- .string()
483
- .transform(s => Temporal.Instant.from(s))
484
- .optional(),
485
- parameters: z
486
- .array(z.lazy(() => unmarshalQueryParameterSchema))
487
- .optional(),
488
- apply_auto_limit: z.boolean().optional(),
489
- catalog: z.string().optional(),
490
- schema: z.string().optional(),
491
- })
492
- .transform(d => ({
493
- id: d.id,
494
- displayName: d.display_name,
495
- description: d.description,
496
- ownerUserName: d.owner_user_name,
497
- warehouseId: d.warehouse_id,
498
- queryText: d.query_text,
499
- runAsMode: d.run_as_mode,
500
- lifecycleState: d.lifecycle_state,
501
- lastModifierUserName: d.last_modifier_user_name,
502
- parentPath: d.parent_path,
503
- tags: d.tags,
504
- createTime: d.create_time,
505
- updateTime: d.update_time,
506
- parameters: d.parameters,
507
- applyAutoLimit: d.apply_auto_limit,
508
- catalog: d.catalog,
509
- schema: d.schema,
510
- }));
511
-
512
- export const unmarshalListVisualizationsForQueryResponseSchema: z.ZodType<ListVisualizationsForQueryResponse> =
513
- z
514
- .object({
515
- results: z.array(z.lazy(() => unmarshalVisualizationSchema)).optional(),
516
- next_page_token: z.string().optional(),
517
- })
518
- .transform(d => ({
519
- results: d.results,
520
- nextPageToken: d.next_page_token,
521
- }));
522
-
523
- export const unmarshalMultiValuesOptionsSchema: z.ZodType<MultiValuesOptions> =
524
- z
525
- .object({
526
- prefix: z.string().optional(),
527
- separator: z.string().optional(),
528
- suffix: z.string().optional(),
529
- })
530
- .transform(d => ({
531
- prefix: d.prefix,
532
- separator: d.separator,
533
- suffix: d.suffix,
534
- }));
535
-
536
- export const unmarshalNumericValueSchema: z.ZodType<NumericValue> = z
537
- .object({
538
- value: z.number().optional(),
539
- })
540
- .transform(d => ({
541
- value: d.value,
542
- }));
543
-
544
- export const unmarshalQuerySchema: z.ZodType<Query> = z
545
- .object({
546
- id: z.string().optional(),
547
- display_name: z.string().optional(),
548
- description: z.string().optional(),
549
- owner_user_name: z.string().optional(),
550
- warehouse_id: z.string().optional(),
551
- query_text: z.string().optional(),
552
- run_as_mode: z.enum(RunAsMode).optional(),
553
- lifecycle_state: z.enum(LifecycleState).optional(),
554
- last_modifier_user_name: z.string().optional(),
555
- parent_path: z.string().optional(),
556
- tags: z.array(z.string()).optional(),
557
- create_time: z
558
- .string()
559
- .transform(s => Temporal.Instant.from(s))
560
- .optional(),
561
- update_time: z
562
- .string()
563
- .transform(s => Temporal.Instant.from(s))
564
- .optional(),
565
- parameters: z.array(z.lazy(() => unmarshalQueryParameterSchema)).optional(),
566
- apply_auto_limit: z.boolean().optional(),
567
- catalog: z.string().optional(),
568
- schema: z.string().optional(),
569
- })
570
- .transform(d => ({
571
- id: d.id,
572
- displayName: d.display_name,
573
- description: d.description,
574
- ownerUserName: d.owner_user_name,
575
- warehouseId: d.warehouse_id,
576
- queryText: d.query_text,
577
- runAsMode: d.run_as_mode,
578
- lifecycleState: d.lifecycle_state,
579
- lastModifierUserName: d.last_modifier_user_name,
580
- parentPath: d.parent_path,
581
- tags: d.tags,
582
- createTime: d.create_time,
583
- updateTime: d.update_time,
584
- parameters: d.parameters,
585
- applyAutoLimit: d.apply_auto_limit,
586
- catalog: d.catalog,
587
- schema: d.schema,
588
- }));
589
-
590
- export const unmarshalQueryBackedValueSchema: z.ZodType<QueryBackedValue> = z
591
- .object({
592
- values: z.array(z.string()).optional(),
593
- query_id: z.string().optional(),
594
- multi_values_options: z
595
- .lazy(() => unmarshalMultiValuesOptionsSchema)
596
- .optional(),
597
- })
598
- .transform(d => ({
599
- values: d.values,
600
- queryId: d.query_id,
601
- multiValuesOptions: d.multi_values_options,
602
- }));
603
-
604
- export const unmarshalQueryParameterSchema: z.ZodType<QueryParameter> = z
605
- .object({
606
- title: z.string().optional(),
607
- name: z.string().optional(),
608
- text_value: z.lazy(() => unmarshalTextValueSchema).optional(),
609
- numeric_value: z.lazy(() => unmarshalNumericValueSchema).optional(),
610
- enum_value: z.lazy(() => unmarshalEnumValueSchema).optional(),
611
- date_value: z.lazy(() => unmarshalDateValueSchema).optional(),
612
- date_range_value: z.lazy(() => unmarshalDateRangeValueSchema).optional(),
613
- query_backed_value: z
614
- .lazy(() => unmarshalQueryBackedValueSchema)
615
- .optional(),
616
- })
617
- .transform(d => ({
618
- title: d.title,
619
- name: d.name,
620
- parameterValue:
621
- d.text_value !== undefined
622
- ? {$case: 'textValue' as const, textValue: d.text_value}
623
- : d.numeric_value !== undefined
624
- ? {$case: 'numericValue' as const, numericValue: d.numeric_value}
625
- : d.enum_value !== undefined
626
- ? {$case: 'enumValue' as const, enumValue: d.enum_value}
627
- : d.date_value !== undefined
628
- ? {$case: 'dateValue' as const, dateValue: d.date_value}
629
- : d.date_range_value !== undefined
630
- ? {
631
- $case: 'dateRangeValue' as const,
632
- dateRangeValue: d.date_range_value,
633
- }
634
- : d.query_backed_value !== undefined
635
- ? {
636
- $case: 'queryBackedValue' as const,
637
- queryBackedValue: d.query_backed_value,
638
- }
639
- : undefined,
640
- }));
641
-
642
- export const unmarshalTextValueSchema: z.ZodType<TextValue> = z
643
- .object({
644
- value: z.string().optional(),
645
- })
646
- .transform(d => ({
647
- value: d.value,
648
- }));
649
-
650
- export const unmarshalVisualizationSchema: z.ZodType<Visualization> = z
651
- .object({
652
- id: z.string().optional(),
653
- display_name: z.string().optional(),
654
- type: z.string().optional(),
655
- create_time: z
656
- .string()
657
- .transform(s => Temporal.Instant.from(s))
658
- .optional(),
659
- update_time: z
660
- .string()
661
- .transform(s => Temporal.Instant.from(s))
662
- .optional(),
663
- serialized_query_plan: z.string().optional(),
664
- serialized_options: z.string().optional(),
665
- query_id: z.string().optional(),
666
- })
667
- .transform(d => ({
668
- id: d.id,
669
- displayName: d.display_name,
670
- type: d.type,
671
- createTime: d.create_time,
672
- updateTime: d.update_time,
673
- serializedQueryPlan: d.serialized_query_plan,
674
- serializedOptions: d.serialized_options,
675
- queryId: d.query_id,
676
- }));
677
-
678
- export const marshalCreateQueryRequestSchema: z.ZodType = z
679
- .object({
680
- query: z.lazy(() => marshalCreateQueryRequestQuerySchema).optional(),
681
- autoResolveDisplayName: z.boolean().optional(),
682
- })
683
- .transform(d => ({
684
- query: d.query,
685
- auto_resolve_display_name: d.autoResolveDisplayName,
686
- }));
687
-
688
- export const marshalCreateQueryRequestQuerySchema: z.ZodType = z
689
- .object({
690
- id: z.string().optional(),
691
- displayName: z.string().optional(),
692
- description: z.string().optional(),
693
- ownerUserName: z.string().optional(),
694
- warehouseId: z.string().optional(),
695
- queryText: z.string().optional(),
696
- runAsMode: z.enum(RunAsMode).optional(),
697
- lifecycleState: z.enum(LifecycleState).optional(),
698
- lastModifierUserName: z.string().optional(),
699
- parentPath: z.string().optional(),
700
- tags: z.array(z.string()).optional(),
701
- createTime: z
702
- .any()
703
- .transform((d: Temporal.Instant) => d.toString())
704
- .optional(),
705
- updateTime: z
706
- .any()
707
- .transform((d: Temporal.Instant) => d.toString())
708
- .optional(),
709
- parameters: z.array(z.lazy(() => marshalQueryParameterSchema)).optional(),
710
- applyAutoLimit: z.boolean().optional(),
711
- catalog: z.string().optional(),
712
- schema: z.string().optional(),
713
- })
714
- .transform(d => ({
715
- id: d.id,
716
- display_name: d.displayName,
717
- description: d.description,
718
- owner_user_name: d.ownerUserName,
719
- warehouse_id: d.warehouseId,
720
- query_text: d.queryText,
721
- run_as_mode: d.runAsMode,
722
- lifecycle_state: d.lifecycleState,
723
- last_modifier_user_name: d.lastModifierUserName,
724
- parent_path: d.parentPath,
725
- tags: d.tags,
726
- create_time: d.createTime,
727
- update_time: d.updateTime,
728
- parameters: d.parameters,
729
- apply_auto_limit: d.applyAutoLimit,
730
- catalog: d.catalog,
731
- schema: d.schema,
732
- }));
733
-
734
- export const marshalDateRangeSchema: z.ZodType = z
735
- .object({
736
- start: z.string().optional(),
737
- end: z.string().optional(),
738
- })
739
- .transform(d => ({
740
- start: d.start,
741
- end: d.end,
742
- }));
743
-
744
- export const marshalDateRangeValueSchema: z.ZodType = z
745
- .object({
746
- value: z
747
- .discriminatedUnion('$case', [
748
- z.object({
749
- $case: z.literal('dynamicDateRangeValue'),
750
- dynamicDateRangeValue: z.enum(DateRangeValue_DynamicDateRange),
751
- }),
752
- z.object({
753
- $case: z.literal('dateRangeValue'),
754
- dateRangeValue: z.lazy(() => marshalDateRangeSchema),
755
- }),
756
- ])
757
- .optional(),
758
- precision: z.enum(DatePrecision).optional(),
759
- startDayOfWeek: z.number().optional(),
760
- })
761
- .transform(d => ({
762
- ...(d.value?.$case === 'dynamicDateRangeValue' && {
763
- dynamic_date_range_value: d.value.dynamicDateRangeValue,
764
- }),
765
- ...(d.value?.$case === 'dateRangeValue' && {
766
- date_range_value: d.value.dateRangeValue,
767
- }),
768
- precision: d.precision,
769
- start_day_of_week: d.startDayOfWeek,
770
- }));
771
-
772
- export const marshalDateValueSchema: z.ZodType = z
773
- .object({
774
- value: z
775
- .discriminatedUnion('$case', [
776
- z.object({
777
- $case: z.literal('dynamicDateValue'),
778
- dynamicDateValue: z.enum(DateValue_DynamicDate),
779
- }),
780
- z.object({$case: z.literal('dateValue'), dateValue: z.string()}),
781
- ])
782
- .optional(),
783
- precision: z.enum(DatePrecision).optional(),
784
- })
785
- .transform(d => ({
786
- ...(d.value?.$case === 'dynamicDateValue' && {
787
- dynamic_date_value: d.value.dynamicDateValue,
788
- }),
789
- ...(d.value?.$case === 'dateValue' && {date_value: d.value.dateValue}),
790
- precision: d.precision,
791
- }));
792
-
793
- export const marshalEnumValueSchema: z.ZodType = z
794
- .object({
795
- values: z.array(z.string()).optional(),
796
- enumOptions: z.string().optional(),
797
- multiValuesOptions: z
798
- .lazy(() => marshalMultiValuesOptionsSchema)
799
- .optional(),
800
- })
801
- .transform(d => ({
802
- values: d.values,
803
- enum_options: d.enumOptions,
804
- multi_values_options: d.multiValuesOptions,
805
- }));
806
-
807
- export const marshalMultiValuesOptionsSchema: z.ZodType = z
808
- .object({
809
- prefix: z.string().optional(),
810
- separator: z.string().optional(),
811
- suffix: z.string().optional(),
812
- })
813
- .transform(d => ({
814
- prefix: d.prefix,
815
- separator: d.separator,
816
- suffix: d.suffix,
817
- }));
818
-
819
- export const marshalNumericValueSchema: z.ZodType = z
820
- .object({
821
- value: z.number().optional(),
822
- })
823
- .transform(d => ({
824
- value: d.value,
825
- }));
826
-
827
- export const marshalQueryBackedValueSchema: z.ZodType = z
828
- .object({
829
- values: z.array(z.string()).optional(),
830
- queryId: z.string().optional(),
831
- multiValuesOptions: z
832
- .lazy(() => marshalMultiValuesOptionsSchema)
833
- .optional(),
834
- })
835
- .transform(d => ({
836
- values: d.values,
837
- query_id: d.queryId,
838
- multi_values_options: d.multiValuesOptions,
839
- }));
840
-
841
- export const marshalQueryParameterSchema: z.ZodType = z
842
- .object({
843
- title: z.string().optional(),
844
- name: z.string().optional(),
845
- parameterValue: z
846
- .discriminatedUnion('$case', [
847
- z.object({
848
- $case: z.literal('textValue'),
849
- textValue: z.lazy(() => marshalTextValueSchema),
850
- }),
851
- z.object({
852
- $case: z.literal('numericValue'),
853
- numericValue: z.lazy(() => marshalNumericValueSchema),
854
- }),
855
- z.object({
856
- $case: z.literal('enumValue'),
857
- enumValue: z.lazy(() => marshalEnumValueSchema),
858
- }),
859
- z.object({
860
- $case: z.literal('dateValue'),
861
- dateValue: z.lazy(() => marshalDateValueSchema),
862
- }),
863
- z.object({
864
- $case: z.literal('dateRangeValue'),
865
- dateRangeValue: z.lazy(() => marshalDateRangeValueSchema),
866
- }),
867
- z.object({
868
- $case: z.literal('queryBackedValue'),
869
- queryBackedValue: z.lazy(() => marshalQueryBackedValueSchema),
870
- }),
871
- ])
872
- .optional(),
873
- })
874
- .transform(d => ({
875
- title: d.title,
876
- name: d.name,
877
- ...(d.parameterValue?.$case === 'textValue' && {
878
- text_value: d.parameterValue.textValue,
879
- }),
880
- ...(d.parameterValue?.$case === 'numericValue' && {
881
- numeric_value: d.parameterValue.numericValue,
882
- }),
883
- ...(d.parameterValue?.$case === 'enumValue' && {
884
- enum_value: d.parameterValue.enumValue,
885
- }),
886
- ...(d.parameterValue?.$case === 'dateValue' && {
887
- date_value: d.parameterValue.dateValue,
888
- }),
889
- ...(d.parameterValue?.$case === 'dateRangeValue' && {
890
- date_range_value: d.parameterValue.dateRangeValue,
891
- }),
892
- ...(d.parameterValue?.$case === 'queryBackedValue' && {
893
- query_backed_value: d.parameterValue.queryBackedValue,
894
- }),
895
- }));
896
-
897
- export const marshalTextValueSchema: z.ZodType = z
898
- .object({
899
- value: z.string().optional(),
900
- })
901
- .transform(d => ({
902
- value: d.value,
903
- }));
904
-
905
- export const marshalUpdateQueryRequestSchema: z.ZodType = z
906
- .object({
907
- query: z.lazy(() => marshalUpdateQueryRequestQuerySchema).optional(),
908
- updateMask: z
909
- .any()
910
- .transform((m: FieldMask) => m.toString())
911
- .optional(),
912
- id: z.string().optional(),
913
- autoResolveDisplayName: z.boolean().optional(),
914
- })
915
- .transform(d => ({
916
- query: d.query,
917
- update_mask: d.updateMask,
918
- id: d.id,
919
- auto_resolve_display_name: d.autoResolveDisplayName,
920
- }));
921
-
922
- export const marshalUpdateQueryRequestQuerySchema: z.ZodType = z
923
- .object({
924
- id: z.string().optional(),
925
- displayName: z.string().optional(),
926
- description: z.string().optional(),
927
- ownerUserName: z.string().optional(),
928
- warehouseId: z.string().optional(),
929
- queryText: z.string().optional(),
930
- runAsMode: z.enum(RunAsMode).optional(),
931
- lifecycleState: z.enum(LifecycleState).optional(),
932
- lastModifierUserName: z.string().optional(),
933
- parentPath: z.string().optional(),
934
- tags: z.array(z.string()).optional(),
935
- createTime: z
936
- .any()
937
- .transform((d: Temporal.Instant) => d.toString())
938
- .optional(),
939
- updateTime: z
940
- .any()
941
- .transform((d: Temporal.Instant) => d.toString())
942
- .optional(),
943
- parameters: z.array(z.lazy(() => marshalQueryParameterSchema)).optional(),
944
- applyAutoLimit: z.boolean().optional(),
945
- catalog: z.string().optional(),
946
- schema: z.string().optional(),
947
- })
948
- .transform(d => ({
949
- id: d.id,
950
- display_name: d.displayName,
951
- description: d.description,
952
- owner_user_name: d.ownerUserName,
953
- warehouse_id: d.warehouseId,
954
- query_text: d.queryText,
955
- run_as_mode: d.runAsMode,
956
- lifecycle_state: d.lifecycleState,
957
- last_modifier_user_name: d.lastModifierUserName,
958
- parent_path: d.parentPath,
959
- tags: d.tags,
960
- create_time: d.createTime,
961
- update_time: d.updateTime,
962
- parameters: d.parameters,
963
- apply_auto_limit: d.applyAutoLimit,
964
- catalog: d.catalog,
965
- schema: d.schema,
966
- }));
967
-
968
- const updateQueryRequestQueryFieldMaskSchema: FieldMaskSchema = {
969
- applyAutoLimit: {wire: 'apply_auto_limit'},
970
- catalog: {wire: 'catalog'},
971
- createTime: {wire: 'create_time'},
972
- description: {wire: 'description'},
973
- displayName: {wire: 'display_name'},
974
- id: {wire: 'id'},
975
- lastModifierUserName: {wire: 'last_modifier_user_name'},
976
- lifecycleState: {wire: 'lifecycle_state'},
977
- ownerUserName: {wire: 'owner_user_name'},
978
- parameters: {wire: 'parameters'},
979
- parentPath: {wire: 'parent_path'},
980
- queryText: {wire: 'query_text'},
981
- runAsMode: {wire: 'run_as_mode'},
982
- schema: {wire: 'schema'},
983
- tags: {wire: 'tags'},
984
- updateTime: {wire: 'update_time'},
985
- warehouseId: {wire: 'warehouse_id'},
986
- };
987
-
988
- export function updateQueryRequestQueryFieldMask(
989
- ...paths: string[]
990
- ): FieldMask<UpdateQueryRequestQuery> {
991
- return FieldMask.build<UpdateQueryRequestQuery>(
992
- paths,
993
- updateQueryRequestQueryFieldMaskSchema
994
- );
995
- }