statelydb 0.12.2 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
data/sig/statelydb.rbs ADDED
@@ -0,0 +1,1053 @@
1
+ # A module for Stately Cloud auth code
2
+ module StatelyDB
3
+ # UUID is a helper class for working with UUIDs in StatelyDB. The ruby version of a StatelyDB is a binary string,
4
+ # and this class provides convenience methods for converting to the base16 representation specified in RFC 9562.
5
+ # Internally this class uses the byte_string attribute to store the UUID as a string with the Encoding::ASCII_8BIT
6
+ # encoding.
7
+ class UUID
8
+ # _@param_ `byte_string` — A binary-encoded string (eg: Encoding::ASCII_8BIT encoding)
9
+ def initialize: (String byte_string) -> void
10
+
11
+ # to_s returns the UUID as a base16 string (eg: "f4a8a24a-129d-411f-91d2-6d19d0eaa096")
12
+ def to_s: () -> String
13
+
14
+ # to_str returns the UUID as a base16 string (eg: "f4a8a24a-129d-411f-91d2-6d19d0eaa096")
15
+ #
16
+ # Note: to_str is a type coercion method that is called by Ruby when an object is coerced to a string.
17
+ def to_str: () -> String
18
+
19
+ # Encodes the byte string as a url-safe base64 string with padding removed.
20
+ def to_base64: () -> String
21
+
22
+ # UUIDs are equal if their byte_strings are equal.
23
+ #
24
+ # _@param_ `other`
25
+ def ==: (StatelyDB::UUID other) -> bool
26
+
27
+ # UUIDs are sorted lexigraphically by their base16 representation.
28
+ #
29
+ # _@param_ `other`
30
+ def <=>: (StatelyDB::UUID other) -> Integer
31
+
32
+ # Returns true if the UUID is empty.
33
+ def empty?: () -> bool
34
+
35
+ # Parses a base16 string (eg: "f4a8a24a-129d-411f-91d2-6d19d0eaa096") into a UUID object.
36
+ # The string can be the following:
37
+ # 1. Encoded as Encoding::ASCII_8BIT (also aliased as Encoding::BINARY) and be 16 bytes long.
38
+ # 2. A string of the form "f4a8a24a-129d-411f-91d2-6d19d0eaa096"
39
+ #
40
+ # _@param_ `byte_string` — A binary-encoded string (eg: Encoding::ASCII_8BIT encoding) that is 16 bytes in length, or a base16-formatted UUID string.
41
+ def self.parse: (String byte_string) -> StatelyDB::UUID
42
+
43
+ # Not all bytes values in StatelyDB are UUIDs. This method checks if a byte string is a valid UUID.
44
+ #
45
+ # _@param_ `byte_string` — A binary-encoded string (eg: Encoding::ASCII_8BIT encoding)
46
+ def self.valid_uuid?: (String byte_string) -> bool
47
+
48
+ # Returns the value of attribute byte_string.
49
+ attr_accessor byte_string: untyped
50
+ end
51
+
52
+ # The Error class contains common StatelyDB error types.
53
+ class Error < StandardError
54
+ # _@param_ `message`
55
+ #
56
+ # _@param_ `code`
57
+ #
58
+ # _@param_ `stately_code`
59
+ #
60
+ # _@param_ `cause`
61
+ def initialize: (
62
+ String message,
63
+ ?code: Integer?,
64
+ ?stately_code: String?,
65
+ ?cause: Exception?
66
+ ) -> void
67
+
68
+ # Convert any exception into a StatelyDB::Error.
69
+ #
70
+ # _@param_ `error`
71
+ def self.from: (Exception error) -> StatelyDB::Error
72
+
73
+ # Turn this error's gRPC status code into a human-readable string. e.g. 3 -> "InvalidArgument"
74
+ def code_string: () -> String
75
+
76
+ # Turn a gRPC status code into a human-readable string. e.g. 3 -> "InvalidArgument"
77
+ #
78
+ # _@param_ `code`
79
+ def self.grpc_code_to_string: (Integer code) -> String
80
+
81
+ # The gRPC/Connect Code for this error.
82
+ attr_reader code: Integer
83
+
84
+ # The more fine-grained Stately error code, which is a human-readable string.
85
+ attr_reader stately_code: String
86
+
87
+ # The upstream cause of the error, if available.
88
+ attr_reader cause: Exception
89
+ end
90
+
91
+ # The Token type contains a continuation token for list and sync operations along with metadata about the ability
92
+ # to sync or continue listing based on the last operation performed.
93
+ #
94
+ # Ths StatelyDB SDK vends this Token type for list and sync operations.
95
+ # Consumers should not need to construct this type directly.
96
+ class Token
97
+ # _@param_ `token_data`
98
+ #
99
+ # _@param_ `can_continue`
100
+ #
101
+ # _@param_ `can_sync`
102
+ #
103
+ # _@param_ `schema_version_id`
104
+ def initialize: (
105
+ token_data: String,
106
+ can_continue: bool,
107
+ can_sync: bool,
108
+ schema_version_id: Integer
109
+ ) -> void
110
+
111
+ # Returns true if the list operation can be continued, otherwise false.
112
+ def can_continue?: () -> bool
113
+
114
+ # Returns true if the sync operation can be continued, otherwise false.
115
+ def can_sync?: () -> bool
116
+
117
+ # Returns the value of attribute token_data.
118
+ attr_accessor token_data: untyped
119
+
120
+ # Returns the schema version ID associated with the token.
121
+ attr_reader schema_version_id: Integer
122
+ end
123
+
124
+ # KeyPath is a helper class for constructing key paths.
125
+ class KeyPath
126
+ def initialize: () -> void
127
+
128
+ # Appends a new path segment.
129
+ #
130
+ # _@param_ `namespace`
131
+ #
132
+ # _@param_ `identifier`
133
+ def with: (String namespace, ?(String | StatelyDB::UUID | _ToS)? identifier) -> KeyPath
134
+
135
+ def to_str: () -> String
136
+
137
+ def inspect: () -> String
138
+
139
+ def to_s: () -> String
140
+
141
+ # Appends a new path segment.
142
+ #
143
+ # _@param_ `namespace`
144
+ #
145
+ # _@param_ `identifier`
146
+ #
147
+ # ```ruby
148
+ # keypath = KeyPath.with("genres", "rock").with("artists", "the-beatles")
149
+ # ```
150
+ def self.with: (String namespace, ?(String | StatelyDB::UUID | _ToS)? identifier) -> KeyPath
151
+
152
+ # If the value is a binary string, encode it as a url-safe base64 string with padding removed.
153
+ #
154
+ # _@param_ `value` — The value to convert to a key id.
155
+ def self.to_key_id: ((String | StatelyDB::UUID | _ToS) value) -> String
156
+ end
157
+
158
+ # CoreClient is a low level client for interacting with the Stately Cloud API.
159
+ # This client shouldn't be used directly in most cases. Instead, use the generated
160
+ # client for your schema.
161
+ class CoreClient
162
+ # Initialize a new StatelyDB CoreClient
163
+ #
164
+ # _@param_ `store_id` — the StatelyDB to use for all operations with this client.
165
+ #
166
+ # _@param_ `schema` — the generated Schema module to use for mapping StatelyDB Items.
167
+ #
168
+ # _@param_ `token_provider` — the token provider to use for authentication.
169
+ #
170
+ # _@param_ `endpoint` — the endpoint to connect to.
171
+ #
172
+ # _@param_ `region` — the region to connect to.
173
+ def initialize: (
174
+ store_id: Integer,
175
+ schema: Module,
176
+ ?token_provider: Common::Auth::TokenProvider,
177
+ ?endpoint: String?,
178
+ ?region: String?
179
+ ) -> void
180
+
181
+ # _@return_ — nil
182
+ def close: () -> void
183
+
184
+ # Set whether to allow stale results for all operations with this client. This produces a new client
185
+ # with the allow_stale flag set.
186
+ #
187
+ # _@param_ `allow_stale` — whether to allow stale results
188
+ #
189
+ # _@return_ — a new client with the allow_stale flag set
190
+ #
191
+ # ```ruby
192
+ # client.with_allow_stale(true).get("/ItemType-identifier")
193
+ # ```
194
+ def with_allow_stale: (bool allow_stale) -> self
195
+
196
+ # Fetch a single Item from a StatelyDB Store at the given key_path.
197
+ #
198
+ # _@param_ `key_path` — the path to the item
199
+ #
200
+ # _@return_ — the Item or nil if not found
201
+ #
202
+ # ```ruby
203
+ # client.get("/ItemType-identifier")
204
+ # ```
205
+ def get: (String key_path) -> (StatelyDB::Item | NilClass)
206
+
207
+ # Fetch a batch of up to 100 Items from a StatelyDB Store at the given key_paths.
208
+ #
209
+ # _@param_ `key_paths` — the paths to the items. Max 100 key paths.
210
+ #
211
+ # _@return_ — the items or nil if not found
212
+ #
213
+ # ```ruby
214
+ # client.data.get_batch("/ItemType-identifier", "/ItemType-identifier2")
215
+ # ```
216
+ def get_batch: (*(String | ::Array[String]) key_paths) -> (::Array[StatelyDB::Item] | NilClass)
217
+
218
+ # Begin listing Items from a StatelyDB Store at the given prefix.
219
+ #
220
+ # _@param_ `prefix` — the prefix to list
221
+ #
222
+ # _@param_ `limit` — the maximum number of items to return
223
+ #
224
+ # _@param_ `sort_property` — the property to sort by
225
+ #
226
+ # _@param_ `sort_direction` — the direction to sort by (:ascending or :descending)
227
+ #
228
+ # _@return_ — the list of Items and the token
229
+ #
230
+ # ```ruby
231
+ # client.data.begin_list("/ItemType-identifier", limit: 10, sort_direction: :ascending)
232
+ # ```
233
+ def begin_list: (
234
+ String prefix,
235
+ ?limit: Integer,
236
+ ?sort_property: String?,
237
+ ?sort_direction: Symbol
238
+ ) -> (::Array[StatelyDB::Item] | StatelyDB::Token)
239
+
240
+ # Continue listing Items from a StatelyDB Store using a token.
241
+ #
242
+ # _@param_ `token` — the token to continue from
243
+ #
244
+ # _@return_ — the list of Items and the token
245
+ #
246
+ # ```ruby
247
+ # (items, token) = client.data.begin_list("/ItemType-identifier")
248
+ # client.data.continue_list(token)
249
+ # ```
250
+ def continue_list: (StatelyDB::Token token) -> (::Array[StatelyDB::Item] | StatelyDB::Token)
251
+
252
+ # Sync a list of Items from a StatelyDB Store.
253
+ #
254
+ # _@param_ `token` — the token to sync from
255
+ #
256
+ # _@return_ — the result of the sync operation
257
+ #
258
+ # ```ruby
259
+ # (items, token) = client.data.begin_list("/ItemType-identifier")
260
+ # client.data.sync_list(token)
261
+ # ```
262
+ def sync_list: (StatelyDB::Token token) -> StatelyDB::SyncResult
263
+
264
+ # Put an Item into a StatelyDB Store at the given key_path.
265
+ #
266
+ # _@param_ `item` — a StatelyDB Item
267
+ #
268
+ # _@param_ `must_not_exist` — A condition that indicates this item must not already exist at any of its key paths. If there is already an item at one of those paths, the Put operation will fail with a "ConditionalCheckFailed" error. Note that if the item has an `initialValue` field in its key, that initial value will automatically be chosen not to conflict with existing items, so this condition only applies to key paths that do not contain the `initialValue` field.
269
+ #
270
+ # _@return_ — the item that was stored
271
+ #
272
+ # client.data.put(my_item)
273
+ # ```ruby
274
+ # ```
275
+ #
276
+ # client.data.put(my_item, must_not_exist: true)
277
+ # ```ruby
278
+ # ```
279
+ def put: (StatelyDB::Item item, ?must_not_exist: bool) -> StatelyDB::Item
280
+
281
+ # Put a batch of up to 50 Items into a StatelyDB Store.
282
+ #
283
+ # Max 50 items.
284
+ #
285
+ # _@param_ `items` — the items to store.
286
+ #
287
+ # _@return_ — the items that were stored
288
+ #
289
+ # ```ruby
290
+ # client.data.put_batch(item1, item2)
291
+ # ```
292
+ #
293
+ # ```ruby
294
+ # client.data.put_batch({ item: item1, must_not_exist: true }, item2)
295
+ # ```
296
+ def put_batch: (*(StatelyDB::Item | ::Array[StatelyDB::Item]) items) -> ::Array[StatelyDB::Item]
297
+
298
+ # Delete up to 50 Items from a StatelyDB Store at the given key_paths.
299
+ #
300
+ # _@param_ `key_paths` — the paths to the items. Max 50 key paths.
301
+ #
302
+ # _@return_ — nil
303
+ #
304
+ # ```ruby
305
+ # client.data.delete("/ItemType-identifier", "/ItemType-identifier2")
306
+ # ```
307
+ def delete: (*(String | ::Array[String]) key_paths) -> void
308
+
309
+ # Transaction takes a block and executes the block within a transaction.
310
+ # If the block raises an exception, the transaction is rolled back.
311
+ # If the block completes successfully, the transaction is committed.
312
+ #
313
+ # _@return_ — the result of the transaction
314
+ #
315
+ # ```ruby
316
+ # client.data.transaction do |txn|
317
+ # txn.put(item: my_item)
318
+ # txn.put(item: another_item)
319
+ # end
320
+ # ```
321
+ def transaction: () -> StatelyDB::Transaction::Transaction::Result
322
+
323
+ # Construct the API endpoint from the region and endpoint.
324
+ # If the endpoint is provided, it will be returned as-is.
325
+ # If the region is provided and the endpoint is not,
326
+ # then the region-specific endpoint will be returned.
327
+ # If neither the region nor the endpoint is provided,
328
+ # then the default endpoint will be returned.
329
+ #
330
+ # _@param_ `endpoint` — the endpoint to connect to
331
+ #
332
+ # _@param_ `region` — the region to connect to
333
+ #
334
+ # _@return_ — the constructed endpoint
335
+ def self.make_endpoint: (?endpoint: String?, ?region: Region?) -> String
336
+
337
+ # Process a list response from begin_list or continue_list
338
+ #
339
+ # _@param_ `resp` — the response to process
340
+ #
341
+ # _@return_ — the list of Items and the token
342
+ def process_list_response: (Stately::Db::ListResponse resp) -> [::Array[StatelyDB::Item], StatelyDB::Token]
343
+
344
+ # Process a sync response from sync_list
345
+ #
346
+ # _@param_ `resp` — the response to process
347
+ #
348
+ # _@return_ — the result of the sync operation
349
+ def process_sync_response: (Stately::Db::SyncResponse resp) -> StatelyDB::SyncResult
350
+ end
351
+
352
+ # SyncResult represents the results of a sync operation.
353
+ #
354
+ # @attr_reader changed_items [Array<StatelyDB::Item>] the items that were changed
355
+ # @attr_reader deleted_item_paths [Array<String>] the key paths that were deleted
356
+ # @attr_reader updated_outside_list_window_paths [Array<String>] the key paths of
357
+ # items that were updated but Stately cannot tell if they were in the sync window.
358
+ # Treat these as deleted in most cases.
359
+ # @attr_reader is_reset [Boolean] whether the sync operation reset the token
360
+ # @attr_reader token [StatelyDB::Token] the token to continue from
361
+ class SyncResult
362
+ # _@param_ `changed_items` — the items that were changed
363
+ #
364
+ # _@param_ `deleted_item_paths` — the key paths that were deleted
365
+ #
366
+ # _@param_ `updated_outside_list_window_paths` — key paths for items that were updated but do not currently use the sort property that the list window is based on
367
+ #
368
+ # _@param_ `is_reset` — whether the sync operation reset the token
369
+ #
370
+ # _@param_ `token` — the token to continue from
371
+ def initialize: (
372
+ changed_items: ::Array[StatelyDB::Item],
373
+ deleted_item_paths: ::Array[String],
374
+ updated_outside_list_window_paths: ::Array[String],
375
+ is_reset: bool,
376
+ token: StatelyDB::Token
377
+ ) -> void
378
+
379
+ # the items that were changed
380
+ attr_reader changed_items: ::Array[StatelyDB::Item]
381
+
382
+ # the key paths that were deleted
383
+ attr_reader deleted_item_paths: ::Array[String]
384
+
385
+ # the key paths of
386
+ # items that were updated but Stately cannot tell if they were in the sync window.
387
+ # Treat these as deleted in most cases.
388
+ attr_reader updated_outside_list_window_paths: ::Array[String]
389
+
390
+ # whether the sync operation reset the token
391
+ attr_reader is_reset: bool
392
+
393
+ # the token to continue from
394
+ attr_reader token: StatelyDB::Token
395
+ end
396
+
397
+ # StatelyDB::Item is a base class for all StatelyDB Items. This class is provided in documentation
398
+ # to show the expected interface for a StatelyDB Item, but in practice the SDK will return a subclass
399
+ # of this class that is generated from the schema.
400
+ class Item
401
+ end
402
+
403
+ module Common
404
+ # A module for Stately Cloud networking code
405
+ module Net
406
+ # Create a new gRPC channel
407
+ #
408
+ # _@param_ `endpoint` — The endpoint to connect to
409
+ #
410
+ # _@return_ — The new channel
411
+ def self.new_channel: (endpoint: String) -> GRPC::Core::Channel
412
+ end
413
+
414
+ # A module for Stately Cloud auth code
415
+ module Auth
416
+ # GRPC interceptor to authenticate against Stately and append bearer tokens to outgoing requests
417
+ class Interceptor < GRPC::ClientInterceptor
418
+ # _@param_ `token_provider` — The token provider to use for authentication
419
+ def initialize: (?token_provider: TokenProvider) -> void
420
+
421
+ # gRPC client unary interceptor
422
+ #
423
+ # _@param_ `request` — The request object
424
+ #
425
+ # _@param_ `call` — The active call object
426
+ #
427
+ # _@param_ `method` — The method being called
428
+ #
429
+ # _@param_ `metadata` — The metadata hash
430
+ #
431
+ # _@return_ — The response object
432
+ def request_response: (
433
+ request: Object,
434
+ call: GRPC::ActiveCall,
435
+ method: Symbol,
436
+ metadata: ::Hash[untyped, untyped]
437
+ ) -> Object
438
+
439
+ # gRPC client streaming interceptor
440
+ #
441
+ # _@param_ `requests` — The list of requests
442
+ #
443
+ # _@param_ `call` — The active call object
444
+ #
445
+ # _@param_ `method` — The method being called
446
+ #
447
+ # _@param_ `metadata` — The metadata hash
448
+ #
449
+ # _@return_ — The response enumerator
450
+ def client_streamer: (
451
+ requests: ::Enumerable[untyped],
452
+ call: GRPC::ActiveCall,
453
+ method: Symbol,
454
+ metadata: ::Hash[untyped, untyped]
455
+ ) -> ::Enumerator[untyped]
456
+
457
+ # gRPC server streaming interceptor
458
+ #
459
+ # _@param_ `request` — The request object
460
+ #
461
+ # _@param_ `call` — The active call object
462
+ #
463
+ # _@param_ `method` — The method being called
464
+ #
465
+ # _@param_ `metadata` — The metadata hash
466
+ #
467
+ # _@return_ — The response enumerator
468
+ def server_streamer: (
469
+ request: Object,
470
+ call: GRPC::ActiveCall,
471
+ method: Symbol,
472
+ metadata: ::Hash[untyped, untyped]
473
+ ) -> ::Enumerator[untyped]
474
+
475
+ # gRPC bidirectional streaming interceptor
476
+ #
477
+ # _@param_ `requests` — The list of requests
478
+ #
479
+ # _@param_ `call` — The active call object
480
+ #
481
+ # _@param_ `method` — The method being called
482
+ #
483
+ # _@param_ `metadata` — The metadata hash
484
+ #
485
+ # _@return_ — The response enumerator
486
+ def bidi_streamer: (
487
+ requests: ::Enumerable[untyped],
488
+ call: GRPC::ActiveCall,
489
+ method: Symbol,
490
+ metadata: ::Hash[untyped, untyped]
491
+ ) -> ::Enumerator[untyped]
492
+
493
+ # Adds a JWT to the metadata hash
494
+ #
495
+ # _@param_ `metadata` — The metadata hash
496
+ def add_jwt_to_grpc_request: (metadata: ::Hash[untyped, untyped]) -> void
497
+ end
498
+
499
+ # Result from a token fetch operation
500
+ class TokenResult
501
+ # Create a new TokenResult
502
+ #
503
+ # _@param_ `token` — The access token
504
+ #
505
+ # _@param_ `expires_in_secs` — The number of seconds until the token expires
506
+ def initialize: (token: String, expires_in_secs: Integer) -> void
507
+
508
+ # Returns the value of attribute token.
509
+ attr_reader token: untyped
510
+
511
+ # Returns the value of attribute expires_in_secs.
512
+ attr_reader expires_in_secs: untyped
513
+ end
514
+
515
+ # TokenFetcher is an abstract base class that should be extended
516
+ # for individual token fetcher implementations
517
+ class TokenFetcher
518
+ # Get the current access token
519
+ #
520
+ # _@return_ — The fetched TokenResult
521
+ def fetch: () -> TokenResult
522
+
523
+ # Close the token provider and kill any background operations
524
+ def close: () -> untyped
525
+ end
526
+
527
+ # Auth0TokenFetcher is a TokenFetcher that fetches tokens from an Auth0 server
528
+ class Auth0TokenFetcher < StatelyDB::Common::Auth::TokenFetcher
529
+ # _@param_ `origin` — The origin of the OAuth server
530
+ #
531
+ # _@param_ `audience` — The OAuth Audience for the token
532
+ #
533
+ # _@param_ `client_secret` — The StatelyDB client secret credential
534
+ #
535
+ # _@param_ `client_id` — The StatelyDB client ID credential
536
+ def initialize: (
537
+ origin: String,
538
+ audience: String,
539
+ client_secret: String,
540
+ client_id: String
541
+ ) -> void
542
+
543
+ # Fetch a new token from auth0
544
+ #
545
+ # _@return_ — The fetched TokenResult
546
+ def fetch: () -> TokenResult
547
+
548
+ def close: () -> untyped
549
+ end
550
+
551
+ # StatelyAccessTokenFetcher is a TokenFetcher that fetches tokens from the StatelyDB API
552
+ class StatelyAccessTokenFetcher < StatelyDB::Common::Auth::TokenFetcher
553
+ # _@param_ `origin` — The origin of the OAuth server
554
+ #
555
+ # _@param_ `access_key` — The StatelyDB access key credential
556
+ def initialize: (origin: String, access_key: String) -> void
557
+
558
+ # Fetch a new token from the StatelyDB API
559
+ #
560
+ # _@return_ — The fetched TokenResult
561
+ def fetch: () -> TokenResult
562
+
563
+ def close: () -> untyped
564
+ end
565
+
566
+ # TokenProvider is an abstract base class that should be extended
567
+ # for individual token provider implementations
568
+ class TokenProvider
569
+ # Get the current access token
570
+ #
571
+ # _@param_ `force` — Whether to force a refresh of the token
572
+ #
573
+ # _@return_ — The current access token
574
+ def get_token: (?force: bool) -> String
575
+
576
+ # Close the token provider and kill any background operations
577
+ def close: () -> untyped
578
+ end
579
+
580
+ # Auth0TokenProvider is an implementation of the TokenProvider abstract base class
581
+ # which vends tokens from auth0 with the given client_id and client_secret.
582
+ # It will default to using the values of `STATELY_CLIENT_ID` and `STATELY_CLIENT_SECRET` if
583
+ # no credentials are explicitly passed and will throw an error if none are found.
584
+ class AuthTokenProvider < StatelyDB::Common::Auth::TokenProvider
585
+ # _@param_ `origin` — The origin of the OAuth server
586
+ #
587
+ # _@param_ `audience` — The OAuth Audience for the token
588
+ #
589
+ # _@param_ `client_secret` — The StatelyDB client secret credential
590
+ #
591
+ # _@param_ `client_id` — The StatelyDB client ID credential
592
+ #
593
+ # _@param_ `access_key` — The StatelyDB access key credential
594
+ def initialize: (
595
+ ?origin: String,
596
+ ?audience: String,
597
+ ?client_secret: String,
598
+ ?client_id: String,
599
+ ?access_key: String
600
+ ) -> void
601
+
602
+ # Close the token provider and kill any background operations
603
+ # This just invokes the close method on the actor which should do the cleanup
604
+ def close: () -> untyped
605
+
606
+ # Get the current access token
607
+ #
608
+ # _@return_ — The current access token
609
+ def get_token: (?force: bool) -> String
610
+
611
+ # Actor for managing the token refresh
612
+ # This is designed to be used with Async::Actor and run on a dedicated thread.
613
+ class Actor
614
+ # _@param_ `origin` — The origin of the OAuth server
615
+ #
616
+ # _@param_ `audience` — The OAuth Audience for the token
617
+ #
618
+ # _@param_ `client_secret` — The StatelyDB client secret credential
619
+ #
620
+ # _@param_ `client_id` — The StatelyDB client ID credential
621
+ def initialize: (
622
+ origin: String,
623
+ audience: String,
624
+ client_secret: String,
625
+ client_id: String,
626
+ access_key: untyped
627
+ ) -> void
628
+
629
+ # Initialize the actor. This runs on the actor thread which means
630
+ # we can dispatch async operations here.
631
+ def init: () -> untyped
632
+
633
+ # Close the token provider and kill any background operations
634
+ def close: () -> untyped
635
+
636
+ # Get the current access token
637
+ #
638
+ # _@param_ `force` — Whether to force a refresh of the token
639
+ #
640
+ # _@return_ — The current access token
641
+ def get_token: (?force: bool) -> String
642
+
643
+ # Get the current access token and whether it is valid
644
+ #
645
+ # _@return_ — The current access token and whether it is valid
646
+ def valid_access_token: () -> ::Array[untyped]
647
+
648
+ # Refresh the access token
649
+ #
650
+ # _@return_ — A task that will resolve to the new access token
651
+ def refresh_token: () -> Task
652
+
653
+ # Refresh the access token implementation
654
+ #
655
+ # _@return_ — The new access token
656
+ def refresh_token_impl: () -> String
657
+ end
658
+
659
+ # Persistent state for the token provider
660
+ class TokenState
661
+ # Create a new TokenState
662
+ #
663
+ # _@param_ `token` — The access token
664
+ #
665
+ # _@param_ `expires_at_unix_secs` — The unix timestamp when the token expires
666
+ def initialize: (token: String, expires_at_unix_secs: Integer) -> void
667
+
668
+ # Returns the value of attribute token.
669
+ attr_reader token: untyped
670
+
671
+ # Returns the value of attribute expires_at_unix_secs.
672
+ attr_reader expires_at_unix_secs: untyped
673
+ end
674
+ end
675
+ end
676
+
677
+ # GRPC interceptor to convert errors to StatelyDB::Error
678
+ class ErrorInterceptor < GRPC::ClientInterceptor
679
+ # client unary interceptor
680
+ def request_response: (
681
+ request: untyped,
682
+ call: untyped,
683
+ method: untyped,
684
+ metadata: untyped
685
+ ) -> untyped
686
+
687
+ # client streaming interceptor
688
+ def client_streamer: (
689
+ requests: untyped,
690
+ call: untyped,
691
+ method: untyped,
692
+ metadata: untyped
693
+ ) -> untyped
694
+
695
+ # server streaming interceptor
696
+ def server_streamer: (
697
+ request: untyped,
698
+ call: untyped,
699
+ method: untyped,
700
+ metadata: untyped
701
+ ) -> untyped
702
+
703
+ # bidirectional streaming interceptor
704
+ def bidi_streamer: (
705
+ requests: untyped,
706
+ call: untyped,
707
+ method: untyped,
708
+ metadata: untyped
709
+ ) -> untyped
710
+ end
711
+ end
712
+
713
+ module Transaction
714
+ # TransactionQueue is a wrapper around Thread::Queue that implements Enumerable
715
+ class Queue < Thread::Queue
716
+ def initialize: () -> void
717
+
718
+ # next_message_id returns the next message ID, which is the current size of the queue + 1.
719
+ # This value is consumed by the StatelyDB transaction as a monotonically increasing MessageID.
720
+ def next_message_id: () -> Integer
721
+
722
+ # Iterates over each element in the queue, yielding each element to the given block.
723
+ def each: () -> void
724
+
725
+ # Iterates over each item in the queue, yielding each item to the given block.
726
+ def each_item: () -> void
727
+
728
+ # _@return_ — The ID of the last message, or nil if there is no message.
729
+ attr_reader last_message_id: Integer?
730
+ end
731
+
732
+ # Transaction coordinates sending requests and waiting for responses. Consumers should not need
733
+ # to interact with this class directly, but instead use the methods provided by the StatelyDB::CoreClient.
734
+ #
735
+ # The example below demonstrates using a transaction, which accepts a block. The lines in the block
736
+ # are executed within the context of the transaction. The transaction is committed when the block
737
+ # completes successfully, OR is aborted if an exception is raised.
738
+ #
739
+ # @example
740
+ # result = client.transaction do |tx|
741
+ # key_path = StatelyDB::KeyPath.with('movie', 'The Shining')
742
+ # movie = tx.get(key_path:)
743
+ # tx.put(item: movie)
744
+ # end
745
+ class Transaction
746
+ # Initialize a new Transaction
747
+ #
748
+ # _@param_ `stub` — a StatelyDB gRPC stub
749
+ #
750
+ # _@param_ `store_id` — the StatelyDB Store to transact against
751
+ #
752
+ # _@param_ `schema` — the schema to use for marshalling and unmarshalling Items
753
+ def initialize: (stub: Stately::Db::DatabaseService::Stub, store_id: Integer, schema: StatelyDB::Schema) -> void
754
+
755
+ # Send a request and wait for a response
756
+ #
757
+ # _@param_ `req` — the request to send
758
+ #
759
+ # _@return_ — the response
760
+ def request_response: (Stately::Db::TransactionRequest req) -> Stately::Db::TransactionResponse
761
+
762
+ # Send a request and don't wait for a response
763
+ #
764
+ # _@param_ `req` — the request to send
765
+ #
766
+ # _@return_ — nil
767
+ def request_only: (Stately::Db::TransactionRequest req) -> void
768
+
769
+ # Send a request and process all responses, until we receive a finished message. This is used for list operations.
770
+ # Each response is processed by the block passed to this method, and the response for this method is a token.
771
+ #
772
+ # _@param_ `req` — the request to send
773
+ #
774
+ # _@return_ — the token
775
+ #
776
+ # ```ruby
777
+ # request_list_responses(req) do |resp|
778
+ # resp.result.items.each do |result|
779
+ # puts result.item.key_path
780
+ # end
781
+ # ```
782
+ def request_list_responses: (Stately::Db::TransactionRequest req) ?{ (Stately::Db::TransactionListResponse resp) -> void } -> Stately::Db::ListToken
783
+
784
+ # Begin a transaction. Begin is called implicitly when the block passed to transaction is called.
785
+ #
786
+ # _@return_ — nil
787
+ def begin: () -> void
788
+
789
+ # Commit a transaction. Commit is called implicitly when the block passed to transaction completes.
790
+ def commit: () -> StatelyDB::Transaction::Transaction::Result
791
+
792
+ # Abort a transaction. Abort is called implicitly if an exception is raised within the block passed to transaction.
793
+ def abort: () -> Stately::Db::TransactionResponse
794
+
795
+ # Check if a transaction is open. A transaction is open if begin has been called and commit or abort has not been called.
796
+ #
797
+ # _@return_ — true if a transaction is open
798
+ def open?: () -> bool
799
+
800
+ # Fetch Items from a StatelyDB Store at the given key_path. Note that Items need to exist before being retrieved inside a
801
+ # transaction.
802
+ #
803
+ # _@param_ `key_path` — the path to the item
804
+ #
805
+ # _@return_ — the item or nil if not found
806
+ #
807
+ # ```ruby
808
+ # client.data.transaction do |txn|
809
+ # item = txn.get("/ItemType-identifier")
810
+ # end
811
+ # ```
812
+ def get: (String key_path) -> (StatelyDB::Item | NilClass)
813
+
814
+ # Fetch a batch of up to 100 Items from a StatelyDB Store at the given
815
+ # key_paths. Note that Items need to exist before being retrieved inside a
816
+ # transaction.
817
+ #
818
+ # key paths.
819
+ # Example:
820
+ # client.data.transaction do |txn|
821
+ # items = txn.get_batch("/foo", "/bar")
822
+ # end
823
+ #
824
+ # _@param_ `key_paths` — the paths to the items. Max 100
825
+ #
826
+ # _@return_ — the items
827
+ def get_batch: (*(String | ::Array[String]) key_paths) -> ::Array[StatelyDB::Item]
828
+
829
+ # Put a single Item into a StatelyDB store. Results are not returned until the transaction is
830
+ # committed and will be available in the Result object returned by commit. An identifier for
831
+ # the item will be returned while inside the transaction block.
832
+ #
833
+ # results.puts.each do |result|
834
+ # puts result.key_path
835
+ # end
836
+ #
837
+ # _@param_ `item` — the item to store
838
+ #
839
+ # _@param_ `must_not_exist` — A condition that indicates this item must not already exist at any of its key paths. If there is already an item at one of those paths, the Put operation will fail with a "ConditionalCheckFailed" error. Note that if the item has an `initialValue` field in its key, that initial value will automatically be chosen not to conflict with existing items, so this condition only applies to key paths that do not contain the `initialValue` field.
840
+ #
841
+ # _@return_ — the id of the item
842
+ #
843
+ # ```ruby
844
+ # results = client.data.transaction do |txn|
845
+ # txn.put(my_item)
846
+ # end
847
+ # ```
848
+ def put: (StatelyDB::Item item, ?must_not_exist: bool) -> (String | Integer)
849
+
850
+ # Put a batch of up to 50 Items into a StatelyDB Store. Results are not
851
+ # returned until the transaction is committed and will be available in the
852
+ # Result object returned by commit. A list of identifiers for the items
853
+ # will be returned while inside the transaction block.
854
+ #
855
+ # 50 items.
856
+ # results.puts.each do |result|
857
+ # puts result.key_path
858
+ # end
859
+ #
860
+ # _@param_ `items` — the items to store. Max
861
+ #
862
+ # _@return_ — the ids of the items
863
+ #
864
+ # ```ruby
865
+ # results = client.data.transaction do |txn|
866
+ # txn.put_batch(item1, item2)
867
+ # end
868
+ # ```
869
+ def put_batch: (*(StatelyDB::Item | ::Array[StatelyDB::Item]) items) -> ::Array[(StatelyDB::UUID | String | Integer | NilClass)]
870
+
871
+ # Delete up to 50 Items from a StatelyDB Store at the given key_paths. Results are not returned until the transaction is
872
+ # committed and will be available in the Result object returned by commit.
873
+ #
874
+ # Example:
875
+ # client.data.transaction do |txn|
876
+ # txn.delete("/ItemType-identifier", "/ItemType-identifier2")
877
+ # end
878
+ #
879
+ # _@param_ `key_paths` — the paths to the items. Max 50 key paths.
880
+ #
881
+ # _@return_ — nil
882
+ def delete: (*(String | ::Array[String]) key_paths) -> void
883
+
884
+ # Begin listing Items from a StatelyDB Store at the given prefix.
885
+ #
886
+ # Example:
887
+ # client.data.transaction do |txn|
888
+ # (items, token) = txn.begin_list("/ItemType-identifier")
889
+ # (items, token) = txn.continue_list(token)
890
+ # end
891
+ #
892
+ # _@param_ `prefix` — the prefix to list
893
+ #
894
+ # _@param_ `limit` — the maximum number of items to return
895
+ #
896
+ # _@param_ `sort_property` — the property to sort by
897
+ #
898
+ # _@param_ `sort_direction` — the direction to sort by (:ascending or :descending)
899
+ #
900
+ # _@return_ — the list of Items and the token
901
+ def begin_list: (
902
+ String prefix,
903
+ ?limit: Integer,
904
+ ?sort_property: String?,
905
+ ?sort_direction: Symbol
906
+ ) -> [::Array[StatelyDB::Item], Stately::Db::ListToken]
907
+
908
+ # Continue listing Items from a StatelyDB Store using a token.
909
+ #
910
+ # Example:
911
+ # client.data.transaction do |txn|
912
+ # (items, token) = txn.begin_list("/foo")
913
+ # (items, token) = txn.continue_list(token)
914
+ # end
915
+ #
916
+ # _@param_ `token` — the token to continue from
917
+ #
918
+ # _@param_ `continue_direction` — the direction to continue by (:forward or :backward)
919
+ #
920
+ # _@return_ — the list of Items and the token
921
+ def continue_list: (Stately::Db::ListToken token, ?continue_direction: Symbol) -> [::Array[StatelyDB::Item], Stately::Db::ListToken]
922
+
923
+ # Processes a list response from begin_list or continue_list
924
+ #
925
+ # _@param_ `req` — the request to send
926
+ #
927
+ # _@return_ — the list of Items and the token
928
+ def do_list_request_response: (Stately::Db::TransactionRequest req) -> [::Array[StatelyDB::Item], Stately::Db::ListToken]
929
+
930
+ # We are using a oneof inside the TransactionRequest to determine the type of request. The ruby
931
+ # generated code does not have a helper for the internal request type so we need to infer it.
932
+ #
933
+ # _@param_ `req` — the request
934
+ #
935
+ # _@return_ — the response type
936
+ def infer_response_type_from_request: (Stately::Db::TransactionRequest req) -> Class
937
+
938
+ # We are using a oneof inside the TransactionResponse to determine the type of response. The ruby
939
+ # generated code does not have a helper for the internal response type so we need to infer it.
940
+ #
941
+ # _@param_ `resp` — the response
942
+ #
943
+ # _@return_ — the response type
944
+ def infer_response_type_from_response: (Stately::Db::TransactionResponse resp) -> Class
945
+
946
+ # Result represents the results of a transaction
947
+ #
948
+ # @attr_reader puts [Array<StatelyDB::Item>] the items that were put
949
+ # @attr_reader deletes [Array<String>] the key paths that were deleted
950
+ class Result
951
+ # Initialize a new Result
952
+ #
953
+ # _@param_ `puts` — the items that were put
954
+ #
955
+ # _@param_ `deletes` — the key paths that were deleted
956
+ def initialize: (puts: ::Array[StatelyDB::Item], deletes: ::Array[String]) -> void
957
+
958
+ # puts is an array of StatelyDB::Items that were put
959
+ attr_reader puts: ::Array[StatelyDB::Item]
960
+
961
+ # deletes is an array of key paths that were deleted
962
+ attr_reader deletes: ::Array[String]
963
+ end
964
+ end
965
+ end
966
+ end
967
+
968
+ module Stately
969
+ module Db
970
+ GetRequest: untyped
971
+ GetItem: untyped
972
+ GetResponse: untyped
973
+ PutRequest: untyped
974
+ PutItem: untyped
975
+ PutResponse: untyped
976
+ Item: untyped
977
+ BeginListRequest: untyped
978
+ ListResponse: untyped
979
+ ListPartialResult: untyped
980
+ ListFinished: untyped
981
+ SortDirection: untyped
982
+ DeleteRequest: untyped
983
+ DeleteItem: untyped
984
+ DeleteResult: untyped
985
+ DeleteResponse: untyped
986
+ SyncListRequest: untyped
987
+ SyncListResponse: untyped
988
+ SyncListReset: untyped
989
+ SyncListPartialResponse: untyped
990
+ DeletedItem: untyped
991
+ ListToken: untyped
992
+ TransactionRequest: untyped
993
+ TransactionResponse: untyped
994
+ TransactionBegin: untyped
995
+ TransactionGet: untyped
996
+ TransactionBeginList: untyped
997
+ TransactionContinueList: untyped
998
+ TransactionPut: untyped
999
+ TransactionDelete: untyped
1000
+ TransactionGetResponse: untyped
1001
+ GeneratedID: untyped
1002
+ TransactionPutAck: untyped
1003
+ TransactionListResponse: untyped
1004
+ TransactionFinished: untyped
1005
+ ContinueListRequest: untyped
1006
+ ContinueListDirection: untyped
1007
+ SortableProperty: untyped
1008
+ ScanRootPathsRequest: untyped
1009
+ ScanRootPathsResponse: untyped
1010
+ ScanRootPathResult: untyped
1011
+
1012
+ module DatabaseService
1013
+ Stub: untyped
1014
+
1015
+ # DatabaseService is the service for creating, reading, updating and deleting data
1016
+ # in a StatelyDB Store. Creating and modifying Stores is done by
1017
+ # stately.dbmanagement.ManagementService.
1018
+ class Service
1019
+ include GRPC::GenericService
1020
+ end
1021
+ end
1022
+ end
1023
+
1024
+ module Auth
1025
+ GetAuthTokenRequest: untyped
1026
+ GetAuthTokenResponse: untyped
1027
+
1028
+ module AuthService
1029
+ Stub: untyped
1030
+
1031
+ # AuthService is the service for vending access tokens used to connect to
1032
+ # StatelyDB. This API is meant to be used from SDKs. Access Keys are created
1033
+ # and managed from the stately.dbmanagement.UserService.
1034
+ class Service
1035
+ include GRPC::GenericService
1036
+ end
1037
+ end
1038
+ end
1039
+
1040
+ module Errors
1041
+ StatelyErrorDetails: untyped
1042
+ end
1043
+ end
1044
+
1045
+ module StatelyCode
1046
+ CACHED_SCHEMA_TOO_OLD: untyped
1047
+ CONCURRENT_MODIFICATION: untyped
1048
+ CONDITIONAL_CHECK_FAILED: untyped
1049
+ NON_RECOVERABLE_TRANSACTION: untyped
1050
+ STORE_IN_USE: untyped
1051
+ STORE_REQUEST_LIMIT_EXCEEDED: untyped
1052
+ STORE_THROUGHPUT_EXCEEDED: untyped
1053
+ end