statelydb 0.29.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/api/db/list_filters_pb.rb +2 -1
- data/lib/common/build_filters.rb +18 -0
- data/lib/statelydb.rb +46 -12
- data/lib/transaction/transaction.rb +25 -10
- data/lib/version.rb +1 -1
- data/rbi/db/list_filters_pb.rbi +128 -5
- data/rbi/statelydb.rbi +15 -10
- data/sig/statelydb.rbs +13 -7
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27ff426cc92aa94367beb63a0c568cec999cdf69c1e77385742e589b933f1162
|
4
|
+
data.tar.gz: 9244139c26ba6f3000f70966e11fba71b3188300b30632f84c31df2a5760effb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a806985ceb7c1a5a186343a155f2e8536823a371b8c3aea4bd682f3fe7b2a0ca4197a16117bb0d0ca42656946b7c6b3de77f243adcc02bfd8a2edc6e620eb8dc
|
7
|
+
data.tar.gz: 6f35612802f0189f14356515132277cfa7d3825fed0a5b6ff70c5dfa9071040a4e01d025d944fb5618c6171c604774e68821c24e3f76fb86ea5edab33248d16c
|
@@ -5,7 +5,7 @@
|
|
5
5
|
require 'google/protobuf'
|
6
6
|
|
7
7
|
|
8
|
-
descriptor_data = "\n\x15\x64\x62/list_filters.proto\x12\nstately.db\"
|
8
|
+
descriptor_data = "\n\x15\x64\x62/list_filters.proto\x12\nstately.db\"}\n\x0f\x46ilterCondition\x12\x1d\n\titem_type\x18\x01 \x01(\tH\x00R\x08itemType\x12\x42\n\x0e\x63\x65l_expression\x18\x02 \x01(\x0b\x32\x19.stately.db.CelExpressionH\x00R\rcelExpressionB\x07\n\x05value\"L\n\rCelExpression\x12\x1b\n\titem_type\x18\x01 \x01(\tR\x08itemType\x12\x1e\n\nexpression\x18\x02 \x01(\tR\nexpressionBk\n\x0e\x63om.stately.dbB\x10ListFiltersProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
9
9
|
|
10
10
|
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
11
11
|
pool.add_serialized_file(descriptor_data)
|
@@ -13,5 +13,6 @@ pool.add_serialized_file(descriptor_data)
|
|
13
13
|
module Stately
|
14
14
|
module Db
|
15
15
|
FilterCondition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.FilterCondition").msgclass
|
16
|
+
CelExpression = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.CelExpression").msgclass
|
16
17
|
end
|
17
18
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "api/db/service_services_pb"
|
4
|
+
|
5
|
+
def build_filters(item_types: [], cel_filters: [])
|
6
|
+
filters = item_types.map do |item_type|
|
7
|
+
Stately::Db::FilterCondition.new(item_type: item_type.respond_to?(:name) ? item_type.name.split("::").last : item_type)
|
8
|
+
end
|
9
|
+
filters += cel_filters.map do |filter|
|
10
|
+
Stately::Db::FilterCondition.new(
|
11
|
+
cel_expression: {
|
12
|
+
item_type: filter[0].respond_to?(:name) ? filter[0].name.split("::").last : filter[0],
|
13
|
+
expression: filter[1]
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
filters
|
18
|
+
end
|
data/lib/statelydb.rb
CHANGED
@@ -4,6 +4,7 @@ require "api/db/service_services_pb"
|
|
4
4
|
require "common/auth/auth_token_provider"
|
5
5
|
require "common/auth/interceptor"
|
6
6
|
require "common/net/conn"
|
7
|
+
require "common/build_filters"
|
7
8
|
require "common/error_interceptor"
|
8
9
|
require "grpc"
|
9
10
|
require "json"
|
@@ -16,6 +17,7 @@ require "key_path"
|
|
16
17
|
require "token"
|
17
18
|
require "uuid"
|
18
19
|
|
20
|
+
# StatelyDB -- the home of all StatelyDB Ruby SDK classes and modules.
|
19
21
|
module StatelyDB
|
20
22
|
# CoreClient is a low level client for interacting with the Stately Cloud API.
|
21
23
|
# This client shouldn't be used directly in most cases. Instead, use the generated
|
@@ -84,7 +86,7 @@ module StatelyDB
|
|
84
86
|
|
85
87
|
# Fetch a single Item from a StatelyDB Store at the given key_path.
|
86
88
|
#
|
87
|
-
# @param key_path [String] the path to the item
|
89
|
+
# @param key_path [StatelyDB::KeyPath, String] the path to the item
|
88
90
|
# @return [StatelyDB::Item, NilClass] the Item or nil if not found
|
89
91
|
# @raise [StatelyDB::Error] if the parameters are invalid or if the item is not found
|
90
92
|
#
|
@@ -99,7 +101,8 @@ module StatelyDB
|
|
99
101
|
|
100
102
|
# Fetch a batch of up to 100 Items from a StatelyDB Store at the given key_paths.
|
101
103
|
#
|
102
|
-
# @param key_paths [String, Array<String>] the paths
|
104
|
+
# @param key_paths [StatelyDB::KeyPath, String, Array<StatelyDB::KeyPath, String>] the paths
|
105
|
+
# to the items. Max 100 key paths.
|
103
106
|
# @return [Array<StatelyDB::Item>, NilClass] the items or nil if not found
|
104
107
|
# @raise [StatelyDB::Error] if the parameters are invalid or if the item is not found
|
105
108
|
#
|
@@ -124,12 +127,27 @@ module StatelyDB
|
|
124
127
|
|
125
128
|
# Begin listing Items from a StatelyDB Store at the given prefix.
|
126
129
|
#
|
127
|
-
# @param prefix [String] the prefix to list
|
130
|
+
# @param prefix [StatelyDB::KeyPath, String] the prefix to list
|
128
131
|
# @param limit [Integer] the maximum number of items to return
|
129
132
|
# @param sort_property [String] the property to sort by
|
130
133
|
# @param sort_direction [Symbol, String, Integer] the direction to sort by (:ascending or :descending)
|
131
|
-
# @param item_types [Array<Class
|
134
|
+
# @param item_types [Array<Class<StatelyDB::Item>, String>] the item types to filter by. The returned
|
132
135
|
# items will be instances of one of these types.
|
136
|
+
# @param cel_filters [Array<Array<Class, String>, String>>] An optional list of
|
137
|
+
# item_type, cel_expression tuples that represent CEL expressions to filter the
|
138
|
+
# results set by. Use the cel_filter helper function to build these expressions.
|
139
|
+
# CEL expressions are only evaluated for the item type they are defined for, and
|
140
|
+
# do not affect other item types in the result set. This means if an item type has
|
141
|
+
# no CEL filter and there are no item_type filters constraints, it will be included
|
142
|
+
# in the result set.
|
143
|
+
# In the context of a CEL expression, the key-word `this` refers to the item being
|
144
|
+
# evaluated, and property properties should be accessed by the names as they appear
|
145
|
+
# in schema -- not necessarily as they appear in the generated code for a particular
|
146
|
+
# language. For example, if you have a `Movie` item type with the property `rating`,
|
147
|
+
# you could write a CEL expression like `this.rating == 'R'` to return only movies
|
148
|
+
# that are rated `R`.
|
149
|
+
# Find the full CEL language definition here:
|
150
|
+
# https://github.com/google/cel-spec/blob/master/doc/langdef.md
|
133
151
|
# @param gt [StatelyDB::KeyPath | String] filters results to only include items with a key greater than the
|
134
152
|
# specified value based on lexicographic ordering.
|
135
153
|
# @param gte [StatelyDB::KeyPath | String] filters results to only include items with a key greater than or equal to the
|
@@ -148,6 +166,7 @@ module StatelyDB
|
|
148
166
|
sort_property: nil,
|
149
167
|
sort_direction: :ascending,
|
150
168
|
item_types: [],
|
169
|
+
cel_filters: [],
|
151
170
|
gt: nil,
|
152
171
|
gte: nil,
|
153
172
|
lt: nil,
|
@@ -162,15 +181,14 @@ module StatelyDB
|
|
162
181
|
key_conditions = key_condition_params
|
163
182
|
.reject { |(_, value)| value.nil? }
|
164
183
|
.map { |(operator, key_path)| Stately::Db::KeyCondition.new(operator: operator, key_path: key_path) }
|
184
|
+
|
165
185
|
req = Stately::Db::BeginListRequest.new(
|
166
186
|
store_id: @store_id,
|
167
187
|
key_path_prefix: String(prefix),
|
168
188
|
limit:,
|
169
189
|
sort_property:,
|
170
190
|
sort_direction:,
|
171
|
-
filter_conditions: item_types
|
172
|
-
Stately::Db::FilterCondition.new(item_type: item_type.respond_to?(:name) ? item_type.name.split("::").last : item_type)
|
173
|
-
end,
|
191
|
+
filter_conditions: build_filters(item_types: item_types, cel_filters: cel_filters),
|
174
192
|
key_conditions: key_conditions,
|
175
193
|
allow_stale: @allow_stale,
|
176
194
|
schema_id: @schema::SCHEMA_ID,
|
@@ -210,8 +228,23 @@ module StatelyDB
|
|
210
228
|
# then the first page of results will be returned which may empty because it
|
211
229
|
# does not contain items of your selected item types. Be sure to check
|
212
230
|
# token.can_continue to see if there are more results to fetch.
|
213
|
-
# @param item_types [Array<
|
231
|
+
# @param item_types [Array<StatelyDB::Item, String>] the item types to filter by. The returned
|
214
232
|
# items will be instances of one of these types.
|
233
|
+
# @param cel_filters [Array<Array<Class, String>, String>>] An optional list of
|
234
|
+
# item_type, cel_expression tuples that represent CEL expressions to filter the
|
235
|
+
# results set by. Use the cel_filter helper function to build these expressions.
|
236
|
+
# CEL expressions are only evaluated for the item type they are defined for, and
|
237
|
+
# do not affect other item types in the result set. This means if an item type has
|
238
|
+
# no CEL filter and there are no item_type filters constraints, it will be included
|
239
|
+
# in the result set.
|
240
|
+
# In the context of a CEL expression, the key-word `this` refers to the item being
|
241
|
+
# evaluated, and property properties should be accessed by the names as they appear
|
242
|
+
# in schema -- not necessarily as they appear in the generated code for a particular
|
243
|
+
# language. For example, if you have a `Movie` item type with the property `rating`,
|
244
|
+
# you could write a CEL expression like `this.rating == 'R'` to return only movies
|
245
|
+
# that are rated `R`.
|
246
|
+
# Find the full CEL language definition here:
|
247
|
+
# https://github.com/google/cel-spec/blob/master/doc/langdef.md
|
215
248
|
# @param total_segments [Integer] the total number of segments to divide the
|
216
249
|
# scan into. Use this when you want to parallelize your operation.
|
217
250
|
# @param segment_index [Integer] the index of the segment to scan.
|
@@ -222,6 +255,7 @@ module StatelyDB
|
|
222
255
|
# client.data.begin_scan(limit: 10, item_types: [MyItem])
|
223
256
|
def begin_scan(limit: 0,
|
224
257
|
item_types: [],
|
258
|
+
cel_filters: [],
|
225
259
|
total_segments: nil,
|
226
260
|
segment_index: nil)
|
227
261
|
if total_segments.nil? != segment_index.nil?
|
@@ -229,12 +263,11 @@ module StatelyDB
|
|
229
263
|
code: GRPC::Core::StatusCodes::INVALID_ARGUMENT,
|
230
264
|
stately_code: "InvalidArgument")
|
231
265
|
end
|
266
|
+
|
232
267
|
req = Stately::Db::BeginScanRequest.new(
|
233
268
|
store_id: @store_id,
|
234
269
|
limit:,
|
235
|
-
filter_condition: item_types
|
236
|
-
Stately::Db::FilterCondition.new(item_type: item_type.respond_to?(:name) ? item_type.name.split("::").last : item_type)
|
237
|
-
end,
|
270
|
+
filter_condition: build_filters(item_types: item_types, cel_filters: cel_filters),
|
238
271
|
schema_id: @schema::SCHEMA_ID,
|
239
272
|
schema_version_id: @schema::SCHEMA_VERSION_ID
|
240
273
|
)
|
@@ -350,7 +383,8 @@ module StatelyDB
|
|
350
383
|
|
351
384
|
# Delete up to 50 Items from a StatelyDB Store at the given key_paths.
|
352
385
|
#
|
353
|
-
# @param key_paths [String, Array<String>] the paths
|
386
|
+
# @param key_paths [StatelyDB::KeyPath, String, Array<StatelyDB::KeyPath, String>] the paths
|
387
|
+
# to the items. Max 50 key paths.
|
354
388
|
# @raise [StatelyDB::Error] if the parameters are invalid
|
355
389
|
# @raise [StatelyDB::Error] if the item is not found
|
356
390
|
# @return [void] nil
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "common/build_filters"
|
4
|
+
|
3
5
|
module StatelyDB
|
4
6
|
module Transaction
|
5
7
|
# Transaction coordinates sending requests and waiting for responses. Consumers should not need
|
@@ -178,7 +180,7 @@ module StatelyDB
|
|
178
180
|
# Fetch Items from a StatelyDB Store at the given key_path. Note that Items need to exist before being retrieved inside a
|
179
181
|
# transaction.
|
180
182
|
#
|
181
|
-
# @param key_path [String] the path to the item
|
183
|
+
# @param key_path [StatelyDB::KeyPath, String] the path to the item
|
182
184
|
# @return [StatelyDB::Item, NilClass] the item or nil if not found
|
183
185
|
# @raise [StatelyDB::Error::InvalidParameters] if the parameters are invalid
|
184
186
|
# @raise [StatelyDB::Error::NotFound] if the item is not found
|
@@ -198,7 +200,7 @@ module StatelyDB
|
|
198
200
|
# key_paths. Note that Items need to exist before being retrieved inside a
|
199
201
|
# transaction.
|
200
202
|
#
|
201
|
-
# @param key_paths [String, Array<String>] the paths to the items. Max 100
|
203
|
+
# @param key_paths [StatelyDB::KeyPath, String, Array<StatelyDB::KeyPath, String>] the paths to the items. Max 100
|
202
204
|
# key paths.
|
203
205
|
# @return [Array<StatelyDB::Item>] the items
|
204
206
|
# @raise [StatelyDB::Error::InvalidParameters] if the parameters are invalid
|
@@ -310,7 +312,8 @@ module StatelyDB
|
|
310
312
|
# Delete up to 50 Items from a StatelyDB Store at the given key_paths. Results are not returned until the transaction is
|
311
313
|
# committed and will be available in the Result object returned by commit.
|
312
314
|
#
|
313
|
-
# @param key_paths [String, Array<String>] the paths
|
315
|
+
# @param key_paths [StatelyDB::KeyPath, String, Array<StatelyDB::KeyPath, String>] the paths
|
316
|
+
# to the items. Max 50 key paths.
|
314
317
|
# @return [void] nil
|
315
318
|
#
|
316
319
|
# Example:
|
@@ -330,12 +333,27 @@ module StatelyDB
|
|
330
333
|
|
331
334
|
# Begin listing Items from a StatelyDB Store at the given prefix.
|
332
335
|
#
|
333
|
-
# @param prefix [String] the prefix to list
|
336
|
+
# @param prefix [StatelyDB::KeyPath, String] the prefix to list
|
334
337
|
# @param limit [Integer] the maximum number of items to return
|
335
338
|
# @param sort_property [String] the property to sort by
|
336
339
|
# @param sort_direction [Symbol] the direction to sort by (:ascending or :descending)
|
337
|
-
# @param item_types [Array<
|
340
|
+
# @param item_types [Array<StatelyDB::Item, String>] the item types to filter by. The returned
|
338
341
|
# items will be instances of one of these types.
|
342
|
+
# @param cel_filters [Array<Array<Class, String>, String>>] An optional list of
|
343
|
+
# item_type, cel_expression tuples that represent CEL expressions to filter the
|
344
|
+
# results set by. Use the cel_filter helper function to build these expressions.
|
345
|
+
# CEL expressions are only evaluated for the item type they are defined for, and
|
346
|
+
# do not affect other item types in the result set. This means if an item type has
|
347
|
+
# no CEL filter and there are no item_type filters constraints, it will be included
|
348
|
+
# in the result set.
|
349
|
+
# In the context of a CEL expression, the key-word `this` refers to the item being
|
350
|
+
# evaluated, and property properties should be accessed by the names as they appear
|
351
|
+
# in schema -- not necessarily as they appear in the generated code for a particular
|
352
|
+
# language. For example, if you have a `Movie` item type with the property `rating`,
|
353
|
+
# you could write a CEL expression like `this.rating == 'R'` to return only movies
|
354
|
+
# that are rated `R`.
|
355
|
+
# Find the full CEL language definition here:
|
356
|
+
# https://github.com/google/cel-spec/blob/master/doc/langdef.md
|
339
357
|
# @param gt [StatelyDB::KeyPath | String] filters results to only include items with a key greater than the
|
340
358
|
# specified value based on lexicographic ordering.
|
341
359
|
# @param gte [StatelyDB::KeyPath | String] filters results to only include items with a key greater than or equal to the
|
@@ -357,6 +375,7 @@ module StatelyDB
|
|
357
375
|
sort_property: nil,
|
358
376
|
sort_direction: :ascending,
|
359
377
|
item_types: [],
|
378
|
+
cel_filters: [],
|
360
379
|
gt: nil,
|
361
380
|
gte: nil,
|
362
381
|
lt: nil,
|
@@ -385,11 +404,7 @@ module StatelyDB
|
|
385
404
|
limit:,
|
386
405
|
sort_property:,
|
387
406
|
sort_direction:,
|
388
|
-
filter_conditions: item_types
|
389
|
-
Stately::Db::FilterCondition.new(
|
390
|
-
item_type: item_type.respond_to?(:name) ? item_type.name.split("::").last : item_type
|
391
|
-
)
|
392
|
-
end,
|
407
|
+
filter_conditions: build_filters(item_types: item_types, cel_filters: cel_filters),
|
393
408
|
key_conditions: key_conditions
|
394
409
|
)
|
395
410
|
)
|
data/lib/version.rb
CHANGED
data/rbi/db/list_filters_pb.rbi
CHANGED
@@ -8,29 +8,55 @@ class Stately::Db::FilterCondition
|
|
8
8
|
|
9
9
|
sig do
|
10
10
|
params(
|
11
|
-
item_type: T.nilable(String)
|
11
|
+
item_type: T.nilable(String),
|
12
|
+
cel_expression: T.nilable(Stately::Db::CelExpression)
|
12
13
|
).void
|
13
14
|
end
|
14
15
|
def initialize(
|
15
|
-
item_type: ""
|
16
|
+
item_type: "",
|
17
|
+
cel_expression: nil
|
16
18
|
)
|
17
19
|
end
|
18
20
|
|
19
|
-
# item_type is the type of item to
|
21
|
+
# item_type is the type of item to include in a query response.
|
20
22
|
sig { returns(String) }
|
21
23
|
def item_type
|
22
24
|
end
|
23
25
|
|
24
|
-
# item_type is the type of item to
|
26
|
+
# item_type is the type of item to include in a query response.
|
25
27
|
sig { params(value: String).void }
|
26
28
|
def item_type=(value)
|
27
29
|
end
|
28
30
|
|
29
|
-
# item_type is the type of item to
|
31
|
+
# item_type is the type of item to include in a query response.
|
30
32
|
sig { void }
|
31
33
|
def clear_item_type
|
32
34
|
end
|
33
35
|
|
36
|
+
# cel_expression is a CEL expression to evaluate against a specific item type.
|
37
|
+
# If an expression evaluates to true, the item is included in the results.
|
38
|
+
# This expression *only* applies to the item type specified in the
|
39
|
+
# CelExpression.item_type field, and is not applied to other item types in the query.
|
40
|
+
sig { returns(T.nilable(Stately::Db::CelExpression)) }
|
41
|
+
def cel_expression
|
42
|
+
end
|
43
|
+
|
44
|
+
# cel_expression is a CEL expression to evaluate against a specific item type.
|
45
|
+
# If an expression evaluates to true, the item is included in the results.
|
46
|
+
# This expression *only* applies to the item type specified in the
|
47
|
+
# CelExpression.item_type field, and is not applied to other item types in the query.
|
48
|
+
sig { params(value: T.nilable(Stately::Db::CelExpression)).void }
|
49
|
+
def cel_expression=(value)
|
50
|
+
end
|
51
|
+
|
52
|
+
# cel_expression is a CEL expression to evaluate against a specific item type.
|
53
|
+
# If an expression evaluates to true, the item is included in the results.
|
54
|
+
# This expression *only* applies to the item type specified in the
|
55
|
+
# CelExpression.item_type field, and is not applied to other item types in the query.
|
56
|
+
sig { void }
|
57
|
+
def clear_cel_expression
|
58
|
+
end
|
59
|
+
|
34
60
|
sig { returns(T.nilable(Symbol)) }
|
35
61
|
def value
|
36
62
|
end
|
@@ -67,3 +93,100 @@ class Stately::Db::FilterCondition
|
|
67
93
|
def self.descriptor
|
68
94
|
end
|
69
95
|
end
|
96
|
+
|
97
|
+
class Stately::Db::CelExpression
|
98
|
+
include ::Google::Protobuf::MessageExts
|
99
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
100
|
+
|
101
|
+
sig do
|
102
|
+
params(
|
103
|
+
item_type: T.nilable(String),
|
104
|
+
expression: T.nilable(String)
|
105
|
+
).void
|
106
|
+
end
|
107
|
+
def initialize(
|
108
|
+
item_type: "",
|
109
|
+
expression: ""
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
# item_type is the itemType to evaluate the expression against.
|
114
|
+
sig { returns(String) }
|
115
|
+
def item_type
|
116
|
+
end
|
117
|
+
|
118
|
+
# item_type is the itemType to evaluate the expression against.
|
119
|
+
sig { params(value: String).void }
|
120
|
+
def item_type=(value)
|
121
|
+
end
|
122
|
+
|
123
|
+
# item_type is the itemType to evaluate the expression against.
|
124
|
+
sig { void }
|
125
|
+
def clear_item_type
|
126
|
+
end
|
127
|
+
|
128
|
+
# expression is the CEL expression to evaluate.
|
129
|
+
# If the expression evaluates to true, the item is included in the results,
|
130
|
+
# otherwise it is excluded.
|
131
|
+
#
|
132
|
+
# In the context of the CEL expression, 'this' refers to the item being evaluated.
|
133
|
+
# For example, the expression is "this.foo == 'bar'" means that the item
|
134
|
+
# must have a property 'foo' with the value 'bar' to be included in the results.
|
135
|
+
sig { returns(String) }
|
136
|
+
def expression
|
137
|
+
end
|
138
|
+
|
139
|
+
# expression is the CEL expression to evaluate.
|
140
|
+
# If the expression evaluates to true, the item is included in the results,
|
141
|
+
# otherwise it is excluded.
|
142
|
+
#
|
143
|
+
# In the context of the CEL expression, 'this' refers to the item being evaluated.
|
144
|
+
# For example, the expression is "this.foo == 'bar'" means that the item
|
145
|
+
# must have a property 'foo' with the value 'bar' to be included in the results.
|
146
|
+
sig { params(value: String).void }
|
147
|
+
def expression=(value)
|
148
|
+
end
|
149
|
+
|
150
|
+
# expression is the CEL expression to evaluate.
|
151
|
+
# If the expression evaluates to true, the item is included in the results,
|
152
|
+
# otherwise it is excluded.
|
153
|
+
#
|
154
|
+
# In the context of the CEL expression, 'this' refers to the item being evaluated.
|
155
|
+
# For example, the expression is "this.foo == 'bar'" means that the item
|
156
|
+
# must have a property 'foo' with the value 'bar' to be included in the results.
|
157
|
+
sig { void }
|
158
|
+
def clear_expression
|
159
|
+
end
|
160
|
+
|
161
|
+
sig { params(field: String).returns(T.untyped) }
|
162
|
+
def [](field)
|
163
|
+
end
|
164
|
+
|
165
|
+
sig { params(field: String, value: T.untyped).void }
|
166
|
+
def []=(field, value)
|
167
|
+
end
|
168
|
+
|
169
|
+
sig { returns(T::Hash[Symbol, T.untyped]) }
|
170
|
+
def to_h
|
171
|
+
end
|
172
|
+
|
173
|
+
sig { params(str: String).returns(Stately::Db::CelExpression) }
|
174
|
+
def self.decode(str)
|
175
|
+
end
|
176
|
+
|
177
|
+
sig { params(msg: Stately::Db::CelExpression).returns(String) }
|
178
|
+
def self.encode(msg)
|
179
|
+
end
|
180
|
+
|
181
|
+
sig { params(str: String, kw: T.untyped).returns(Stately::Db::CelExpression) }
|
182
|
+
def self.decode_json(str, **kw)
|
183
|
+
end
|
184
|
+
|
185
|
+
sig { params(msg: Stately::Db::CelExpression, kw: T.untyped).returns(String) }
|
186
|
+
def self.encode_json(msg, **kw)
|
187
|
+
end
|
188
|
+
|
189
|
+
sig { returns(::Google::Protobuf::Descriptor) }
|
190
|
+
def self.descriptor
|
191
|
+
end
|
192
|
+
end
|
data/rbi/statelydb.rbi
CHANGED
@@ -245,7 +245,7 @@ module StatelyDB
|
|
245
245
|
# ```ruby
|
246
246
|
# client.get("/ItemType-identifier")
|
247
247
|
# ```
|
248
|
-
sig { params(key_path: String).returns(T.any(StatelyDB::Item, NilClass)) }
|
248
|
+
sig { params(key_path: T.any(StatelyDB::KeyPath, String)).returns(T.any(StatelyDB::Item, NilClass)) }
|
249
249
|
def get(key_path); end
|
250
250
|
|
251
251
|
# Fetch a batch of up to 100 Items from a StatelyDB Store at the given key_paths.
|
@@ -257,7 +257,7 @@ module StatelyDB
|
|
257
257
|
# ```ruby
|
258
258
|
# client.data.get_batch("/ItemType-identifier", "/ItemType-identifier2")
|
259
259
|
# ```
|
260
|
-
sig { params(key_paths: T.any(String, T::Array[String])).returns(T.any(T::Array[StatelyDB::Item], NilClass)) }
|
260
|
+
sig { params(key_paths: T.any(StatelyDB::KeyPath, String, T::Array[T.any(StatelyDB::KeyPath, String)])).returns(T.any(T::Array[StatelyDB::Item], NilClass)) }
|
261
261
|
def get_batch(*key_paths); end
|
262
262
|
|
263
263
|
# _@return_ — the list of Items and the token
|
@@ -272,13 +272,14 @@ module StatelyDB
|
|
272
272
|
sort_property: T.untyped,
|
273
273
|
sort_direction: T.untyped,
|
274
274
|
item_types: T.untyped,
|
275
|
+
cel_filters: T.untyped,
|
275
276
|
gt: T.untyped,
|
276
277
|
gte: T.untyped,
|
277
278
|
lt: T.untyped,
|
278
279
|
lte: T.untyped
|
279
280
|
).returns(T.any(T::Array[StatelyDB::Item], StatelyDB::Token))
|
280
281
|
end
|
281
|
-
def begin_list(prefix, limit: 100, sort_property: nil, sort_direction: :ascending, item_types: [], gt: nil, gte: nil, lt: nil, lte: nil); end
|
282
|
+
def begin_list(prefix, limit: 100, sort_property: nil, sort_direction: :ascending, item_types: [], cel_filters: [], gt: nil, gte: nil, lt: nil, lte: nil); end
|
282
283
|
|
283
284
|
# Continue listing Items from a StatelyDB Store using a token.
|
284
285
|
#
|
@@ -305,6 +306,8 @@ module StatelyDB
|
|
305
306
|
#
|
306
307
|
# _@param_ `item_types` — the item types to filter by. The returned items will be instances of one of these types.
|
307
308
|
#
|
309
|
+
# _@param_ `cel_filters` — ] An optional list of item_type, cel_expression tuples that represent CEL expressions to filter the results set by. Use the cel_filter helper function to build these expressions. CEL expressions are only evaluated for the item type they are defined for, and do not affect other item types in the result set. This means if an item type has no CEL filter and there are no item_type filters constraints, it will be included in the result set. In the context of a CEL expression, the key-word `this` refers to the item being evaluated, and property properties should be accessed by the names as they appear in schema -- not necessarily as they appear in the generated code for a particular language. For example, if you have a `Movie` item type with the property `rating`, you could write a CEL expression like `this.rating == 'R'` to return only movies that are rated `R`. Find the full CEL language definition here: https://github.com/google/cel-spec/blob/master/doc/langdef.md
|
310
|
+
#
|
308
311
|
# _@param_ `total_segments` — the total number of segments to divide the scan into. Use this when you want to parallelize your operation.
|
309
312
|
#
|
310
313
|
# _@param_ `segment_index` — the index of the segment to scan. Use this when you want to parallelize your operation.
|
@@ -317,12 +320,13 @@ module StatelyDB
|
|
317
320
|
sig do
|
318
321
|
params(
|
319
322
|
limit: Integer,
|
320
|
-
item_types: T::Array[T.any(
|
323
|
+
item_types: T::Array[T.any(StatelyDB::Item, String)],
|
324
|
+
cel_filters: T::Array[T.any(T::Array[T.any(T::Class[T.anything], String)], String)],
|
321
325
|
total_segments: T.nilable(Integer),
|
322
326
|
segment_index: T.nilable(Integer)
|
323
327
|
).returns(T.any(T::Array[StatelyDB::Item], StatelyDB::Token))
|
324
328
|
end
|
325
|
-
def begin_scan(limit: 0, item_types: [], total_segments: nil, segment_index: nil); end
|
329
|
+
def begin_scan(limit: 0, item_types: [], cel_filters: [], total_segments: nil, segment_index: nil); end
|
326
330
|
|
327
331
|
# continue_scan takes the token from a begin_scan call and returns more results
|
328
332
|
# based on the original request parameters and pagination options.
|
@@ -400,7 +404,7 @@ module StatelyDB
|
|
400
404
|
# ```ruby
|
401
405
|
# client.data.delete("/ItemType-identifier", "/ItemType-identifier2")
|
402
406
|
# ```
|
403
|
-
sig { params(key_paths: T.any(String, T::Array[String])).void }
|
407
|
+
sig { params(key_paths: T.any(StatelyDB::KeyPath, String, T::Array[T.any(StatelyDB::KeyPath, String)])).void }
|
404
408
|
def delete(*key_paths); end
|
405
409
|
|
406
410
|
# Transaction takes a block and executes the block within a transaction.
|
@@ -927,7 +931,7 @@ module StatelyDB
|
|
927
931
|
# item = txn.get("/ItemType-identifier")
|
928
932
|
# end
|
929
933
|
# ```
|
930
|
-
sig { params(key_path: String).returns(T.any(StatelyDB::Item, NilClass)) }
|
934
|
+
sig { params(key_path: T.any(StatelyDB::KeyPath, String)).returns(T.any(StatelyDB::Item, NilClass)) }
|
931
935
|
def get(key_path); end
|
932
936
|
|
933
937
|
# Fetch a batch of up to 100 Items from a StatelyDB Store at the given
|
@@ -943,7 +947,7 @@ module StatelyDB
|
|
943
947
|
# _@param_ `key_paths` — the paths to the items. Max 100
|
944
948
|
#
|
945
949
|
# _@return_ — the items
|
946
|
-
sig { params(key_paths: T.any(String, T::Array[String])).returns(T::Array[StatelyDB::Item]) }
|
950
|
+
sig { params(key_paths: T.any(StatelyDB::KeyPath, String, T::Array[T.any(StatelyDB::KeyPath, String)])).returns(T::Array[StatelyDB::Item]) }
|
947
951
|
def get_batch(*key_paths); end
|
948
952
|
|
949
953
|
# Put a single Item into a StatelyDB store. Results are not returned until the transaction is
|
@@ -1003,7 +1007,7 @@ module StatelyDB
|
|
1003
1007
|
# _@param_ `key_paths` — the paths to the items. Max 50 key paths.
|
1004
1008
|
#
|
1005
1009
|
# _@return_ — nil
|
1006
|
-
sig { params(key_paths: T.any(String, T::Array[String])).void }
|
1010
|
+
sig { params(key_paths: T.any(StatelyDB::KeyPath, String, T::Array[T.any(StatelyDB::KeyPath, String)])).void }
|
1007
1011
|
def delete(*key_paths); end
|
1008
1012
|
|
1009
1013
|
# Example:
|
@@ -1020,13 +1024,14 @@ module StatelyDB
|
|
1020
1024
|
sort_property: T.untyped,
|
1021
1025
|
sort_direction: T.untyped,
|
1022
1026
|
item_types: T.untyped,
|
1027
|
+
cel_filters: T.untyped,
|
1023
1028
|
gt: T.untyped,
|
1024
1029
|
gte: T.untyped,
|
1025
1030
|
lt: T.untyped,
|
1026
1031
|
lte: T.untyped
|
1027
1032
|
).returns([T::Array[StatelyDB::Item], ::Stately::Db::ListToken])
|
1028
1033
|
end
|
1029
|
-
def begin_list(prefix, limit: 100, sort_property: nil, sort_direction: :ascending, item_types: [], gt: nil, gte: nil, lt: nil, lte: nil); end
|
1034
|
+
def begin_list(prefix, limit: 100, sort_property: nil, sort_direction: :ascending, item_types: [], cel_filters: [], gt: nil, gte: nil, lt: nil, lte: nil); end
|
1030
1035
|
|
1031
1036
|
# Continue listing Items from a StatelyDB Store using a token.
|
1032
1037
|
#
|
data/sig/statelydb.rbs
CHANGED
@@ -208,7 +208,7 @@ module StatelyDB
|
|
208
208
|
# ```ruby
|
209
209
|
# client.get("/ItemType-identifier")
|
210
210
|
# ```
|
211
|
-
def get: (String key_path) -> (StatelyDB::Item | NilClass)
|
211
|
+
def get: ((StatelyDB::KeyPath | String) key_path) -> (StatelyDB::Item | NilClass)
|
212
212
|
|
213
213
|
# Fetch a batch of up to 100 Items from a StatelyDB Store at the given key_paths.
|
214
214
|
#
|
@@ -219,7 +219,7 @@ module StatelyDB
|
|
219
219
|
# ```ruby
|
220
220
|
# client.data.get_batch("/ItemType-identifier", "/ItemType-identifier2")
|
221
221
|
# ```
|
222
|
-
def get_batch: (*(String | ::Array[String]) key_paths) -> (::Array[StatelyDB::Item] | NilClass)
|
222
|
+
def get_batch: (*(StatelyDB::KeyPath | String | ::Array[(StatelyDB::KeyPath | String)]) key_paths) -> (::Array[StatelyDB::Item] | NilClass)
|
223
223
|
|
224
224
|
# _@return_ — the list of Items and the token
|
225
225
|
#
|
@@ -232,6 +232,7 @@ module StatelyDB
|
|
232
232
|
?sort_property: untyped,
|
233
233
|
?sort_direction: untyped,
|
234
234
|
?item_types: untyped,
|
235
|
+
?cel_filters: untyped,
|
235
236
|
?gt: untyped,
|
236
237
|
?gte: untyped,
|
237
238
|
?lt: untyped,
|
@@ -262,6 +263,8 @@ module StatelyDB
|
|
262
263
|
#
|
263
264
|
# _@param_ `item_types` — the item types to filter by. The returned items will be instances of one of these types.
|
264
265
|
#
|
266
|
+
# _@param_ `cel_filters` — ] An optional list of item_type, cel_expression tuples that represent CEL expressions to filter the results set by. Use the cel_filter helper function to build these expressions. CEL expressions are only evaluated for the item type they are defined for, and do not affect other item types in the result set. This means if an item type has no CEL filter and there are no item_type filters constraints, it will be included in the result set. In the context of a CEL expression, the key-word `this` refers to the item being evaluated, and property properties should be accessed by the names as they appear in schema -- not necessarily as they appear in the generated code for a particular language. For example, if you have a `Movie` item type with the property `rating`, you could write a CEL expression like `this.rating == 'R'` to return only movies that are rated `R`. Find the full CEL language definition here: https://github.com/google/cel-spec/blob/master/doc/langdef.md
|
267
|
+
#
|
265
268
|
# _@param_ `total_segments` — the total number of segments to divide the scan into. Use this when you want to parallelize your operation.
|
266
269
|
#
|
267
270
|
# _@param_ `segment_index` — the index of the segment to scan. Use this when you want to parallelize your operation.
|
@@ -273,7 +276,8 @@ module StatelyDB
|
|
273
276
|
# ```
|
274
277
|
def begin_scan: (
|
275
278
|
?limit: Integer,
|
276
|
-
?item_types: ::Array[(
|
279
|
+
?item_types: ::Array[(StatelyDB::Item | String)],
|
280
|
+
?cel_filters: ::Array[(::Array[(Class | String)] | String)],
|
277
281
|
?total_segments: Integer?,
|
278
282
|
?segment_index: Integer?
|
279
283
|
) -> (::Array[StatelyDB::Item] | StatelyDB::Token)
|
@@ -350,7 +354,7 @@ module StatelyDB
|
|
350
354
|
# ```ruby
|
351
355
|
# client.data.delete("/ItemType-identifier", "/ItemType-identifier2")
|
352
356
|
# ```
|
353
|
-
def delete: (*(String | ::Array[String]) key_paths) -> void
|
357
|
+
def delete: (*(StatelyDB::KeyPath | String | ::Array[(StatelyDB::KeyPath | String)]) key_paths) -> void
|
354
358
|
|
355
359
|
# Transaction takes a block and executes the block within a transaction.
|
356
360
|
# If the block raises an exception, the transaction is rolled back.
|
@@ -813,7 +817,7 @@ module StatelyDB
|
|
813
817
|
# item = txn.get("/ItemType-identifier")
|
814
818
|
# end
|
815
819
|
# ```
|
816
|
-
def get: (String key_path) -> (StatelyDB::Item | NilClass)
|
820
|
+
def get: ((StatelyDB::KeyPath | String) key_path) -> (StatelyDB::Item | NilClass)
|
817
821
|
|
818
822
|
# Fetch a batch of up to 100 Items from a StatelyDB Store at the given
|
819
823
|
# key_paths. Note that Items need to exist before being retrieved inside a
|
@@ -828,7 +832,7 @@ module StatelyDB
|
|
828
832
|
# _@param_ `key_paths` — the paths to the items. Max 100
|
829
833
|
#
|
830
834
|
# _@return_ — the items
|
831
|
-
def get_batch: (*(String | ::Array[String]) key_paths) -> ::Array[StatelyDB::Item]
|
835
|
+
def get_batch: (*(StatelyDB::KeyPath | String | ::Array[(StatelyDB::KeyPath | String)]) key_paths) -> ::Array[StatelyDB::Item]
|
832
836
|
|
833
837
|
# Put a single Item into a StatelyDB store. Results are not returned until the transaction is
|
834
838
|
# committed and will be available in the Result object returned by commit. An identifier for
|
@@ -885,7 +889,7 @@ module StatelyDB
|
|
885
889
|
# _@param_ `key_paths` — the paths to the items. Max 50 key paths.
|
886
890
|
#
|
887
891
|
# _@return_ — nil
|
888
|
-
def delete: (*(String | ::Array[String]) key_paths) -> void
|
892
|
+
def delete: (*(StatelyDB::KeyPath | String | ::Array[(StatelyDB::KeyPath | String)]) key_paths) -> void
|
889
893
|
|
890
894
|
# Example:
|
891
895
|
# client.data.transaction do |txn|
|
@@ -900,6 +904,7 @@ module StatelyDB
|
|
900
904
|
?sort_property: untyped,
|
901
905
|
?sort_direction: untyped,
|
902
906
|
?item_types: untyped,
|
907
|
+
?cel_filters: untyped,
|
903
908
|
?gt: untyped,
|
904
909
|
?gte: untyped,
|
905
910
|
?lt: untyped,
|
@@ -1008,6 +1013,7 @@ module Stately
|
|
1008
1013
|
TransactionListResponse: untyped
|
1009
1014
|
TransactionFinished: untyped
|
1010
1015
|
FilterCondition: untyped
|
1016
|
+
CelExpression: untyped
|
1011
1017
|
ContinueListRequest: untyped
|
1012
1018
|
ContinueListDirection: untyped
|
1013
1019
|
ContinueScanRequest: untyped
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statelydb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stately Cloud, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-06-
|
11
|
+
date: 2025-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/common/auth/interceptor.rb
|
100
100
|
- lib/common/auth/token_fetcher.rb
|
101
101
|
- lib/common/auth/token_provider.rb
|
102
|
+
- lib/common/build_filters.rb
|
102
103
|
- lib/common/error_interceptor.rb
|
103
104
|
- lib/common/net/conn.rb
|
104
105
|
- lib/error.rb
|