-
Notifications
You must be signed in to change notification settings - Fork 0
/
workflowslib.d.ts
731 lines (709 loc) · 20.3 KB
/
workflowslib.d.ts
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
// Type annotations for GCP Workflows expression helpers, standard library
// functions and (some) connectors
// An opaque bytes type.
// This should really be defined in the transpiler, not here.
declare const tag: unique symbol
export interface bytes {
readonly [tag]: 'bytes'
}
// GCP Workflows expression helpers
export declare function double(x: string | number): number
export declare function int(x: string | number): number
export declare function string(x: string | number | boolean): string
export declare function keys(map: Record<string, unknown>): string[]
export declare function len(
value: unknown[] | Record<string, unknown> | string,
): number
export declare function get_type(
value:
| boolean
| number
| string
| unknown[]
| Record<string, unknown>
| null
| bytes
| undefined,
): string
// GCP Workflows standard library functions
export declare namespace base64 {
function decode(data: bytes, padding?: boolean): string
function encode(data: string, padding?: boolean): bytes
}
export declare namespace events {
function await_callback(
callback: {
url: string
},
timeout?: number,
): object
function create_callback_endpoint(http_callback_method: string): {
url: string
}
}
export declare namespace http {
export function default_retry(errormap: Record<string, any>): void
export function default_retry_non_idempotent(
errormap: Record<string, any>,
): void
export function default_retry_predicate(
errormap: Record<string, any>,
): boolean
export function default_retry_predicate_non_idempotent(
errormap: Record<string, any>,
): boolean
function _delete(
url: string,
timeout?: number,
body?: unknown,
headers?: Record<string, string>,
query?: Record<
string,
string | number | boolean | (string | number | boolean)[]
>,
auth?: Record<string, string>,
private_service_name?: string,
ca_certificate?: string,
): {
body: unknown
code: number
headers: Record<string, string>
}
export function get(
url: string,
timeout?: number,
headers?: Record<string, string>,
query?: Record<
string,
string | number | boolean | (string | number | boolean)[]
>,
auth?: Record<string, string>,
private_service_name?: string,
ca_certificate?: string,
): {
body: unknown
code: number
headers: Record<string, string>
}
export function patch(
url: string,
timeout?: number,
body?: unknown,
headers?: Record<string, string>,
query?: Record<
string,
string | number | boolean | (string | number | boolean)[]
>,
auth?: Record<string, string>,
private_service_name?: string,
ca_certificate?: string,
): {
body: unknown
code: number
headers: Record<string, string>
}
export function post(
url: string,
timeout?: number,
body?: unknown,
headers?: Record<string, string>,
query?: Record<
string,
string | number | boolean | (string | number | boolean)[]
>,
auth?: Record<string, string>,
private_service_name?: string,
ca_certificate?: string,
): {
body: unknown
code: number
headers: Record<string, string>
}
export function put(
url: string,
timeout?: number,
body?: unknown,
headers?: Record<string, string>,
query?: Record<
string,
string | number | boolean | (string | number | boolean)[]
>,
auth?: Record<string, string>,
private_service_name?: string,
ca_certificate?: string,
): {
body: unknown
code: number
headers: Record<string, string>
}
export function request(
method: string,
url: string,
timeout?: number,
body?: unknown,
headers?: Record<string, string>,
query?: Record<
string,
string | number | boolean | (string | number | boolean)[]
>,
auth?: Record<string, string>,
private_service_name?: string,
ca_certificate?: string,
): {
body: unknown
code: number
headers: Record<string, string>
}
export { _delete as delete }
}
export declare namespace json {
function decode(data: bytes | string): unknown
function encode(
data:
| string
| number
| boolean
| unknown[]
| Record<string, unknown>
| null,
indent?:
| boolean
| {
prefix?: string
indent?: string
},
): bytes
function encode_to_string(
data:
| string
| number
| boolean
| unknown[]
| Record<string, unknown>
| null,
indent?:
| boolean
| {
prefix?: string
indent?: string
},
): string
}
export declare namespace list {
function concat<T, U>(objs: T[], val: U): (T | U)[]
function prepend<T, U>(objs: T[], val: U): (T | U)[]
}
export declare namespace map {
function _delete<T>(map: Record<string, T>, key: string): Record<string, T>
export function get<T, K extends string | string[]>(
map: Record<string, T>,
keys: K,
): K extends string ? T | null : unknown
export function merge<T, U>(
first: Record<string, T>,
second: Record<string, U>,
): Record<string, T | U>
export function merge_nested<T, U>(
first: Record<string, T>,
second: Record<string, U>,
): Record<string, T | U>
export { _delete as delete }
}
export declare namespace math {
function abs(x: number): number
function max(x: number, y: number): number
function min(x: number, y: number): number
}
export declare namespace retry {
function always(exception: unknown): void
const default_backoff: {
initial_delay: number
max_delay: number
multiplier: number
}
function never(exception: unknown): void
}
export declare namespace sys {
function get_env(name: string, default_value?: string): string | undefined
function log(
data?: number | boolean | string | unknown[] | object,
severity?: string,
text?: number | boolean | string | unknown[] | object,
json?: object,
timeout?: number,
): void
function now(): number
function sleep(seconds: number): void
function sleep_until(time: string): void
}
export declare namespace text {
function decode(data: bytes, charset?: string): string
function encode(text: string, charset?: string): bytes
function find_all(source: string, substr: string): number[]
function find_all_regex(
source: string,
regexp: string,
): {
index: number
match: string
}[]
function match_regex(source: string, regexp: string): boolean
function replace_all(source: string, substr: string, repl: string): string
function replace_all_regex(
source: string,
substr: string,
repl: string,
): string
function split(source: string, separator: string): string[]
function substring(source: string, start: number, end: number): string
function to_lower(source: string): string
function to_upper(source: string): string
function url_decode(source: string): string
function url_encode(source: string): string
function url_encode_plus(source: string): string
}
export declare namespace time {
function format(seconds: number, timezone?: string): string
function parse(value: string): number
}
export declare namespace uuid {
function generate(): string
}
// Connectors
// Cloud Firestore API Connector
// https://cloud.google.com/workflows/docs/reference/googleapis/firestore/Overview
export declare namespace googleapis {
namespace firestore {
namespace v1 {
interface ArrayValue {
values: Value[]
}
interface BatchGetDocumentsRequest {
documents: string[]
mask?: DocumentMask
newTransaction?: TransactionOptions
readTime?: string
transaction?: string
}
interface BatchGetDocumentsResponse {
found?: Document
missing?: string
readTime: string
transaction?: string
}
interface BatchWriteRequest {
labels: Record<string, string>
writes: Write[]
}
interface BatchWriteResponse {
status: Status[]
writeResults: WriteResult[]
}
interface BeginTransactionRequest {
options?: TransactionOptions
}
interface BeginTransactionResponse {
transaction: string
}
interface CollectionSelector {
allDescendants: boolean
collectionId?: string
}
interface CommitRequest {
transaction: string
writes: Write[]
}
interface CommitResponse {
commitTime: string
writeResults: WriteResult[]
}
interface CompositeFilter {
filters: Filter[]
op: 'OPERATOR_UNSPECIFIED' | 'AND'
}
interface Cursor {
before: boolean
values: Value[]
}
interface Document {
createTime: string
fields: Record<string, Value>
name?: string
updateTime: string
}
interface DocumentMask {
fieldPaths: string[]
}
interface DocumentTransform {
document: string
fieldTransforms: FieldTransform[]
}
interface FieldReference {
fieldPath: string
}
interface Filter {
compositeFilter?: CompositeFilter
fieldFilter?: FieldFilter
unaryFilter?: UnaryFilter
}
interface FieldFilter {
field: FieldReference
op:
| 'OPERATOR_UNSPECIFIED'
| 'LESS_THAN'
| 'LESS_THAN_OR_EQUAL'
| 'GREATER_THAN'
| 'GREATER_THAN_OR_EQUAL'
| 'EQUAL'
| 'NOT_EQUAL'
| 'ARRAY_CONTAINS'
| 'IN'
| 'ARRAY_CONTAINS_ANY'
| 'NOT_IN'
value: Value
}
interface FieldTransform {
appendMissingElements?: ArrayValue[]
fieldPath: string
increment?: Value
maximum?: Value
minimum?: Value
removeAllFromArray?: ArrayValue
setToServerValue?: 'SERVER_VALUE_UNSPECIFIED' | 'REQUEST_TIME'
}
interface GoogleFirestoreAdminV1ExportDocumentsRequest {
collectionIds?: string[]
outputUriPrefix: string
}
interface GoogleFirestoreAdminV1Field {
indexConfig: GoogleFirestoreAdminV1IndexConfig
name: string
}
interface GoogleFirestoreAdminV1ImportDocumentsRequest {
collectionIds?: string[]
inputUriPrefix: string
}
interface GoogleFirestoreAdminV1Index {
fields: GoogleFirestoreAdminV1IndexField[]
name?: string
queryScope:
| 'QUERY_SCOPE_UNSPECIFIED'
| 'COLLECTION'
| 'COLLECTION_GROUP'
state?: 'STATE_UNSPECIFIED' | 'CREATING' | 'READY' | 'NEEDS_REPAIR'
}
interface GoogleFirestoreAdminV1IndexConfig {
ancestorField?: string
indexes: GoogleFirestoreAdminV1Index[]
reverting?: boolean
usesAncestorConfig?: boolean
}
interface GoogleFirestoreAdminV1IndexField {
arrayConfig: 'ARRAY_CONFIG_UNSPECIFIED' | 'CONTAINS'
fieldPath: string
order: 'ORDER_UNSPECIFIED' | 'ASCENDING' | 'DESCENDING'
}
interface GoogleFirestoreAdminV1ListFieldsResponse {
fields: GoogleFirestoreAdminV1Field[]
nextPageToken?: string
}
interface GoogleFirestoreAdminV1ListIndexesResponse {
indexes: GoogleFirestoreAdminV1Index[]
nextPageToken?: string
}
interface GoogleLongrunningOperation {
done: boolean
error?: Status
metadata?: Record<string, unknown>
name: string
response: Record<string, unknown>
}
interface GoogleLongrunningListOperationsResponse {
nextPageToken?: string
operations: GoogleLongrunningOperation[]
}
interface LatLng {
latitude: number
longitude: number
}
interface ListLocationsResponse {
locations: Location[]
nextPageToken: string
}
interface Location {
displayName: string
labels: Record<string, string>
locationId: string
metadata?: Record<string, unknown>
name: string
}
interface ListCollectionIdsRequest {
pageSize: number
pageToken: string
}
interface ListCollectionIdsResponse {
collectionIds: string[]
nextPageToken: string
}
interface ListDocumentsResponse {
documents: Document[]
nextPageToken: string
}
interface MapValue {
fields: Record<string, Value>
}
interface Order {
direction: 'DIRECTION_UNSPECIFIED' | 'ASCENDING' | 'DESCENDING'
field: FieldReference
}
interface PartitionQueryRequest {
pageSize: number
pageToken: string
partitionCount: string
structuredQuery: StructuredQuery
}
interface PartitionQueryResponse {
nextPageToken: string
partitions: Cursor[]
}
interface Precondition {
exists: boolean
updateTime?: string
}
interface Projection {
fields: FieldReference[]
}
interface ReadOnly {
readTime: string
}
interface ReadWrite {
retryTransaction: string
}
interface RollbackRequest {
transaction: string
}
interface RunQueryRequest {
newTransaction?: TransactionOptions
readTime?: string
structuredQuery: StructuredQuery
transaction?: string
}
interface RunQueryResponse {
document: Document
readTime: string
skippedResults: number
transaction?: string
}
interface Status {
code: number
details: Record<string, unknown>[]
message: string
}
interface StructuredQuery {
endAt?: Cursor
from?: CollectionSelector[]
limit?: number
offset?: number
orderBy?: Order[]
select?: Projection
startAt?: Cursor
where?: Filter
}
interface TransactionOptions {
readOnly?: ReadOnly
readWrite?: ReadWrite
}
interface UnaryFilter {
field: FieldReference
op:
| 'OPERATOR_UNSPECIFIED'
| 'IS_NAN'
| 'IS_NULL'
| 'IS_NOT_NAN'
| 'IS_NOT_NULL'
}
interface Value {
arrayValue?: ArrayValue
booleanValue?: boolean
bytesValue?: string
doubleValue?: number
geoPointValue?: LatLng
integerValue?: string
mapValue?: MapValue
nullValue?: 'NULL_VALUE'
referenceValue?: string
stringValue?: string
timestampValue?: string
}
interface Write {
currentDocument?: Precondition
delete?: string
transform?: DocumentTransform
update?: Pick<Document, 'fields' | 'name'>
updateMask?: DocumentMask
updateTransforms?: FieldTransform[]
}
interface WriteResult {
transformResults?: Value[]
updateTime: string
}
namespace projects {
namespace databases {
export function exportDocuments(
name: string,
body: GoogleFirestoreAdminV1ExportDocumentsRequest,
): GoogleLongrunningOperation
export function importDocuments(
name: string,
body: GoogleFirestoreAdminV1ImportDocumentsRequest,
): GoogleLongrunningOperation
namespace collectionGroups {
namespace fields {
export function get(name: string): GoogleFirestoreAdminV1Field
export function list(
parent: string,
filter?: string,
pageSize?: number,
pageToken?: string,
): GoogleFirestoreAdminV1ListFieldsResponse
export function patch(
name: string,
updateMask: string,
body: GoogleFirestoreAdminV1Field,
): GoogleLongrunningOperation
}
namespace indexes {
export function create(
parent: string,
body: GoogleFirestoreAdminV1Index,
): GoogleLongrunningOperation
function _delete(name: string): void
export function get(name: string): GoogleFirestoreAdminV1Index
export function list(
parent: string,
filter?: string,
pageSize?: number,
pageToken?: string,
): GoogleFirestoreAdminV1ListIndexesResponse
export { _delete as delete }
}
}
namespace documents {
export function batchGet(
database: string,
body: BatchGetDocumentsRequest,
): BatchGetDocumentsResponse
export function batchWrite(
database: string,
body: BatchWriteRequest,
): BatchWriteResponse
export function beginTransaction(
database: string,
body: BeginTransactionRequest,
): BeginTransactionResponse
export function commit(
database: string,
body: CommitRequest,
): CommitResponse
export function createDocument(
collectionId: string,
parent: string,
body: Pick<Document, 'fields' | 'name'>,
documentId?: string,
mask?: DocumentMask,
): Document
function _delete(name: string, currentDocument?: Precondition): void
export function get(
name: string,
mask?: DocumentMask,
readTime?: string,
transaction?: string,
): Document
export function list(
collectionId: string,
parent: string,
mask?: DocumentMask,
orderBy?: string,
pageSize?: number,
pageToken?: string,
readTime?: string,
showMissing?: boolean,
transaction?: string,
): ListDocumentsResponse
export function listCollectionIds(
parent: string,
body: ListCollectionIdsRequest,
): ListCollectionIdsResponse
export function partitionQuery(
parent: string,
body: PartitionQueryRequest,
): PartitionQueryResponse
export function patch(
name: string,
currentDocument: Precondition,
mask: DocumentMask,
updateMask: DocumentMask,
body: Pick<Document, 'fields' | 'name'>,
): Document
export function rollback(
database: string,
body: RollbackRequest,
): void
export function runQuery(
parent: string,
body: RunQueryRequest,
): RunQueryResponse
export { _delete as delete }
}
namespace operations {
export function cancel(name: string): void
function _delete(name: string): void
export function get(name: string): GoogleLongrunningOperation
export function list(
name: string,
filter?: string,
pageSize?: number,
pageToken?: string,
): GoogleLongrunningListOperationsResponse
export { _delete as delete }
}
}
namespace locations {
export function get(name: string): Location
export function list(
name: string,
filter: string,
pageSize?: number,
pageToken?: string,
): ListLocationsResponse
}
}
}
}
}
// Functionality that is not implemented by Typescript keywords
export declare function parallel(
branches: (() => void)[] | (() => void),
options?: {
shared?: string[]
concurrency_limit?: number
exception_policy?: string
},
): void
export declare function retry_policy(
params:
| ((errormap: Record<string, any>) => void)
| {
predicate?: (errormap: Record<string, any>) => boolean
max_retries: number | string | null
backoff: {
initial_delay?: number | string | null
max_delay?: number | string | null
multiplier?: number | string | null
}
},
): void
export declare function call_step<T, A extends any[]>(
func: (...args: A) => T,
arguments: Record<string, unknown>,
): T