statelydb 0.12.2 → 0.13.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,952 @@
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
+ # TokenProvider is an abstract base class that should be extended
500
+ # for individual token provider implementations
501
+ class TokenProvider
502
+ # Get the current access token
503
+ #
504
+ # _@param_ `force` — Whether to force a refresh of the token
505
+ #
506
+ # _@return_ — The current access token
507
+ def get_token: (?force: bool) -> String
508
+
509
+ # Close the token provider and kill any background operations
510
+ def close: () -> untyped
511
+ end
512
+
513
+ # Auth0TokenProvider is an implementation of the TokenProvider abstract base class
514
+ # which vends tokens from auth0 with the given client_id and client_secret.
515
+ # It will default to using the values of `STATELY_CLIENT_ID` and `STATELY_CLIENT_SECRET` if
516
+ # no credentials are explicitly passed and will throw an error if none are found.
517
+ class Auth0TokenProvider < StatelyDB::Common::Auth::TokenProvider
518
+ # _@param_ `origin` — The origin of the OAuth server
519
+ #
520
+ # _@param_ `audience` — The OAuth Audience for the token
521
+ #
522
+ # _@param_ `client_secret` — The StatelyDB client secret credential
523
+ #
524
+ # _@param_ `client_id` — The StatelyDB client ID credential
525
+ def initialize: (
526
+ ?origin: String,
527
+ ?audience: String,
528
+ ?client_secret: String,
529
+ ?client_id: String
530
+ ) -> void
531
+
532
+ # Close the token provider and kill any background operations
533
+ # This just invokes the close method on the actor which should do the cleanup
534
+ def close: () -> untyped
535
+
536
+ # Get the current access token
537
+ #
538
+ # _@return_ — The current access token
539
+ def get_token: (?force: bool) -> String
540
+
541
+ # Actor for managing the token refresh
542
+ # This is designed to be used with Async::Actor and run on a dedicated thread.
543
+ class Actor
544
+ # _@param_ `origin` — The origin of the OAuth server
545
+ #
546
+ # _@param_ `audience` — The OAuth Audience for the token
547
+ #
548
+ # _@param_ `client_secret` — The StatelyDB client secret credential
549
+ #
550
+ # _@param_ `client_id` — The StatelyDB client ID credential
551
+ def initialize: (
552
+ origin: String,
553
+ audience: String,
554
+ client_secret: String,
555
+ client_id: String
556
+ ) -> void
557
+
558
+ # Initialize the actor. This runs on the actor thread which means
559
+ # we can dispatch async operations here.
560
+ def init: () -> untyped
561
+
562
+ # Close the token provider and kill any background operations
563
+ def close: () -> untyped
564
+
565
+ # Get the current access token
566
+ #
567
+ # _@param_ `force` — Whether to force a refresh of the token
568
+ #
569
+ # _@return_ — The current access token
570
+ def get_token: (?force: bool) -> String
571
+
572
+ # Get the current access token and whether it is valid
573
+ #
574
+ # _@return_ — The current access token and whether it is valid
575
+ def valid_access_token: () -> ::Array[untyped]
576
+
577
+ # Refresh the access token
578
+ #
579
+ # _@return_ — A task that will resolve to the new access token
580
+ def refresh_token: () -> Task
581
+
582
+ # Refresh the access token implementation
583
+ #
584
+ # _@return_ — The new access token
585
+ def refresh_token_impl: () -> String
586
+
587
+ def make_auth0_request: () -> untyped
588
+ end
589
+ end
590
+ end
591
+
592
+ # GRPC interceptor to convert errors to StatelyDB::Error
593
+ class ErrorInterceptor < GRPC::ClientInterceptor
594
+ # client unary interceptor
595
+ def request_response: (
596
+ request: untyped,
597
+ call: untyped,
598
+ method: untyped,
599
+ metadata: untyped
600
+ ) -> untyped
601
+
602
+ # client streaming interceptor
603
+ def client_streamer: (
604
+ requests: untyped,
605
+ call: untyped,
606
+ method: untyped,
607
+ metadata: untyped
608
+ ) -> untyped
609
+
610
+ # server streaming interceptor
611
+ def server_streamer: (
612
+ request: untyped,
613
+ call: untyped,
614
+ method: untyped,
615
+ metadata: untyped
616
+ ) -> untyped
617
+
618
+ # bidirectional streaming interceptor
619
+ def bidi_streamer: (
620
+ requests: untyped,
621
+ call: untyped,
622
+ method: untyped,
623
+ metadata: untyped
624
+ ) -> untyped
625
+ end
626
+ end
627
+
628
+ module Transaction
629
+ # TransactionQueue is a wrapper around Thread::Queue that implements Enumerable
630
+ class Queue < Thread::Queue
631
+ def initialize: () -> void
632
+
633
+ # next_message_id returns the next message ID, which is the current size of the queue + 1.
634
+ # This value is consumed by the StatelyDB transaction as a monotonically increasing MessageID.
635
+ def next_message_id: () -> Integer
636
+
637
+ # Iterates over each element in the queue, yielding each element to the given block.
638
+ def each: () -> void
639
+
640
+ # Iterates over each item in the queue, yielding each item to the given block.
641
+ def each_item: () -> void
642
+
643
+ # _@return_ — The ID of the last message, or nil if there is no message.
644
+ attr_reader last_message_id: Integer?
645
+ end
646
+
647
+ # Transaction coordinates sending requests and waiting for responses. Consumers should not need
648
+ # to interact with this class directly, but instead use the methods provided by the StatelyDB::CoreClient.
649
+ #
650
+ # The example below demonstrates using a transaction, which accepts a block. The lines in the block
651
+ # are executed within the context of the transaction. The transaction is committed when the block
652
+ # completes successfully, OR is aborted if an exception is raised.
653
+ #
654
+ # @example
655
+ # result = client.transaction do |tx|
656
+ # key_path = StatelyDB::KeyPath.with('movie', 'The Shining')
657
+ # movie = tx.get(key_path:)
658
+ # tx.put(item: movie)
659
+ # end
660
+ class Transaction
661
+ # Initialize a new Transaction
662
+ #
663
+ # _@param_ `stub` — a StatelyDB gRPC stub
664
+ #
665
+ # _@param_ `store_id` — the StatelyDB Store to transact against
666
+ #
667
+ # _@param_ `schema` — the schema to use for marshalling and unmarshalling Items
668
+ def initialize: (stub: Stately::Db::DatabaseService::Stub, store_id: Integer, schema: StatelyDB::Schema) -> void
669
+
670
+ # Send a request and wait for a response
671
+ #
672
+ # _@param_ `req` — the request to send
673
+ #
674
+ # _@return_ — the response
675
+ def request_response: (Stately::Db::TransactionRequest req) -> Stately::Db::TransactionResponse
676
+
677
+ # Send a request and don't wait for a response
678
+ #
679
+ # _@param_ `req` — the request to send
680
+ #
681
+ # _@return_ — nil
682
+ def request_only: (Stately::Db::TransactionRequest req) -> void
683
+
684
+ # Send a request and process all responses, until we receive a finished message. This is used for list operations.
685
+ # Each response is processed by the block passed to this method, and the response for this method is a token.
686
+ #
687
+ # _@param_ `req` — the request to send
688
+ #
689
+ # _@return_ — the token
690
+ #
691
+ # ```ruby
692
+ # request_list_responses(req) do |resp|
693
+ # resp.result.items.each do |result|
694
+ # puts result.item.key_path
695
+ # end
696
+ # ```
697
+ def request_list_responses: (Stately::Db::TransactionRequest req) ?{ (Stately::Db::TransactionListResponse resp) -> void } -> Stately::Db::ListToken
698
+
699
+ # Begin a transaction. Begin is called implicitly when the block passed to transaction is called.
700
+ #
701
+ # _@return_ — nil
702
+ def begin: () -> void
703
+
704
+ # Commit a transaction. Commit is called implicitly when the block passed to transaction completes.
705
+ def commit: () -> StatelyDB::Transaction::Transaction::Result
706
+
707
+ # Abort a transaction. Abort is called implicitly if an exception is raised within the block passed to transaction.
708
+ def abort: () -> Stately::Db::TransactionResponse
709
+
710
+ # Check if a transaction is open. A transaction is open if begin has been called and commit or abort has not been called.
711
+ #
712
+ # _@return_ — true if a transaction is open
713
+ def open?: () -> bool
714
+
715
+ # Fetch Items from a StatelyDB Store at the given key_path. Note that Items need to exist before being retrieved inside a
716
+ # transaction.
717
+ #
718
+ # _@param_ `key_path` — the path to the item
719
+ #
720
+ # _@return_ — the item or nil if not found
721
+ #
722
+ # ```ruby
723
+ # client.data.transaction do |txn|
724
+ # item = txn.get("/ItemType-identifier")
725
+ # end
726
+ # ```
727
+ def get: (String key_path) -> (StatelyDB::Item | NilClass)
728
+
729
+ # Fetch a batch of up to 100 Items from a StatelyDB Store at the given
730
+ # key_paths. Note that Items need to exist before being retrieved inside a
731
+ # transaction.
732
+ #
733
+ # key paths.
734
+ # Example:
735
+ # client.data.transaction do |txn|
736
+ # items = txn.get_batch("/foo", "/bar")
737
+ # end
738
+ #
739
+ # _@param_ `key_paths` — the paths to the items. Max 100
740
+ #
741
+ # _@return_ — the items
742
+ def get_batch: (*(String | ::Array[String]) key_paths) -> ::Array[StatelyDB::Item]
743
+
744
+ # Put a single Item into a StatelyDB store. Results are not returned until the transaction is
745
+ # committed and will be available in the Result object returned by commit. An identifier for
746
+ # the item will be returned while inside the transaction block.
747
+ #
748
+ # results.puts.each do |result|
749
+ # puts result.key_path
750
+ # end
751
+ #
752
+ # _@param_ `item` — the item to store
753
+ #
754
+ # _@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.
755
+ #
756
+ # _@return_ — the id of the item
757
+ #
758
+ # ```ruby
759
+ # results = client.data.transaction do |txn|
760
+ # txn.put(my_item)
761
+ # end
762
+ # ```
763
+ def put: (StatelyDB::Item item, ?must_not_exist: bool) -> (String | Integer)
764
+
765
+ # Put a batch of up to 50 Items into a StatelyDB Store. Results are not
766
+ # returned until the transaction is committed and will be available in the
767
+ # Result object returned by commit. A list of identifiers for the items
768
+ # will be returned while inside the transaction block.
769
+ #
770
+ # 50 items.
771
+ # results.puts.each do |result|
772
+ # puts result.key_path
773
+ # end
774
+ #
775
+ # _@param_ `items` — the items to store. Max
776
+ #
777
+ # _@return_ — the ids of the items
778
+ #
779
+ # ```ruby
780
+ # results = client.data.transaction do |txn|
781
+ # txn.put_batch(item1, item2)
782
+ # end
783
+ # ```
784
+ def put_batch: (*(StatelyDB::Item | ::Array[StatelyDB::Item]) items) -> ::Array[(StatelyDB::UUID | String | Integer | NilClass)]
785
+
786
+ # Delete up to 50 Items from a StatelyDB Store at the given key_paths. Results are not returned until the transaction is
787
+ # committed and will be available in the Result object returned by commit.
788
+ #
789
+ # Example:
790
+ # client.data.transaction do |txn|
791
+ # txn.delete("/ItemType-identifier", "/ItemType-identifier2")
792
+ # end
793
+ #
794
+ # _@param_ `key_paths` — the paths to the items. Max 50 key paths.
795
+ #
796
+ # _@return_ — nil
797
+ def delete: (*(String | ::Array[String]) key_paths) -> void
798
+
799
+ # Begin listing Items from a StatelyDB Store at the given prefix.
800
+ #
801
+ # Example:
802
+ # client.data.transaction do |txn|
803
+ # (items, token) = txn.begin_list("/ItemType-identifier")
804
+ # (items, token) = txn.continue_list(token)
805
+ # end
806
+ #
807
+ # _@param_ `prefix` — the prefix to list
808
+ #
809
+ # _@param_ `limit` — the maximum number of items to return
810
+ #
811
+ # _@param_ `sort_property` — the property to sort by
812
+ #
813
+ # _@param_ `sort_direction` — the direction to sort by (:ascending or :descending)
814
+ #
815
+ # _@return_ — the list of Items and the token
816
+ def begin_list: (
817
+ String prefix,
818
+ ?limit: Integer,
819
+ ?sort_property: String?,
820
+ ?sort_direction: Symbol
821
+ ) -> [::Array[StatelyDB::Item], Stately::Db::ListToken]
822
+
823
+ # Continue listing Items from a StatelyDB Store using a token.
824
+ #
825
+ # Example:
826
+ # client.data.transaction do |txn|
827
+ # (items, token) = txn.begin_list("/foo")
828
+ # (items, token) = txn.continue_list(token)
829
+ # end
830
+ #
831
+ # _@param_ `token` — the token to continue from
832
+ #
833
+ # _@param_ `continue_direction` — the direction to continue by (:forward or :backward)
834
+ #
835
+ # _@return_ — the list of Items and the token
836
+ def continue_list: (Stately::Db::ListToken token, ?continue_direction: Symbol) -> [::Array[StatelyDB::Item], Stately::Db::ListToken]
837
+
838
+ # Processes a list response from begin_list or continue_list
839
+ #
840
+ # _@param_ `req` — the request to send
841
+ #
842
+ # _@return_ — the list of Items and the token
843
+ def do_list_request_response: (Stately::Db::TransactionRequest req) -> [::Array[StatelyDB::Item], Stately::Db::ListToken]
844
+
845
+ # We are using a oneof inside the TransactionRequest to determine the type of request. The ruby
846
+ # generated code does not have a helper for the internal request type so we need to infer it.
847
+ #
848
+ # _@param_ `req` — the request
849
+ #
850
+ # _@return_ — the response type
851
+ def infer_response_type_from_request: (Stately::Db::TransactionRequest req) -> Class
852
+
853
+ # We are using a oneof inside the TransactionResponse to determine the type of response. The ruby
854
+ # generated code does not have a helper for the internal response type so we need to infer it.
855
+ #
856
+ # _@param_ `resp` — the response
857
+ #
858
+ # _@return_ — the response type
859
+ def infer_response_type_from_response: (Stately::Db::TransactionResponse resp) -> Class
860
+
861
+ # Result represents the results of a transaction
862
+ #
863
+ # @attr_reader puts [Array<StatelyDB::Item>] the items that were put
864
+ # @attr_reader deletes [Array<String>] the key paths that were deleted
865
+ class Result
866
+ # Initialize a new Result
867
+ #
868
+ # _@param_ `puts` — the items that were put
869
+ #
870
+ # _@param_ `deletes` — the key paths that were deleted
871
+ def initialize: (puts: ::Array[StatelyDB::Item], deletes: ::Array[String]) -> void
872
+
873
+ # puts is an array of StatelyDB::Items that were put
874
+ attr_reader puts: ::Array[StatelyDB::Item]
875
+
876
+ # deletes is an array of key paths that were deleted
877
+ attr_reader deletes: ::Array[String]
878
+ end
879
+ end
880
+ end
881
+ end
882
+
883
+ module Stately
884
+ module Db
885
+ GetRequest: untyped
886
+ GetItem: untyped
887
+ GetResponse: untyped
888
+ PutRequest: untyped
889
+ PutItem: untyped
890
+ PutResponse: untyped
891
+ Item: untyped
892
+ BeginListRequest: untyped
893
+ ListResponse: untyped
894
+ ListPartialResult: untyped
895
+ ListFinished: untyped
896
+ SortDirection: untyped
897
+ DeleteRequest: untyped
898
+ DeleteItem: untyped
899
+ DeleteResult: untyped
900
+ DeleteResponse: untyped
901
+ SyncListRequest: untyped
902
+ SyncListResponse: untyped
903
+ SyncListReset: untyped
904
+ SyncListPartialResponse: untyped
905
+ DeletedItem: untyped
906
+ ListToken: untyped
907
+ TransactionRequest: untyped
908
+ TransactionResponse: untyped
909
+ TransactionBegin: untyped
910
+ TransactionGet: untyped
911
+ TransactionBeginList: untyped
912
+ TransactionContinueList: untyped
913
+ TransactionPut: untyped
914
+ TransactionDelete: untyped
915
+ TransactionGetResponse: untyped
916
+ GeneratedID: untyped
917
+ TransactionPutAck: untyped
918
+ TransactionListResponse: untyped
919
+ TransactionFinished: untyped
920
+ ContinueListRequest: untyped
921
+ ContinueListDirection: untyped
922
+ SortableProperty: untyped
923
+ ScanRootPathsRequest: untyped
924
+ ScanRootPathsResponse: untyped
925
+ ScanRootPathResult: untyped
926
+
927
+ module DatabaseService
928
+ Stub: untyped
929
+
930
+ # DatabaseService is the service for creating, reading, updating and deleting data
931
+ # in a StatelyDB Store. Creating and modifying Stores is done by
932
+ # stately.dbmanagement.ManagementService.
933
+ class Service
934
+ include GRPC::GenericService
935
+ end
936
+ end
937
+ end
938
+
939
+ module Errors
940
+ StatelyErrorDetails: untyped
941
+ end
942
+ end
943
+
944
+ module StatelyCode
945
+ CACHED_SCHEMA_TOO_OLD: untyped
946
+ CONCURRENT_MODIFICATION: untyped
947
+ CONDITIONAL_CHECK_FAILED: untyped
948
+ NON_RECOVERABLE_TRANSACTION: untyped
949
+ STORE_IN_USE: untyped
950
+ STORE_REQUEST_LIMIT_EXCEEDED: untyped
951
+ STORE_THROUGHPUT_EXCEEDED: untyped
952
+ end