statelydb 0.30.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/common/build_filters.rb +18 -0
- data/lib/statelydb.rb +40 -8
- data/lib/transaction/transaction.rb +20 -6
- data/lib/version.rb +1 -1
- data/rbi/statelydb.rbi +9 -4
- data/sig/statelydb.rbs +6 -1
- 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
|
@@ -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
|
@@ -129,8 +131,23 @@ module StatelyDB
|
|
129
131
|
# @param limit [Integer] the maximum number of items to return
|
130
132
|
# @param sort_property [String] the property to sort by
|
131
133
|
# @param sort_direction [Symbol, String, Integer] the direction to sort by (:ascending or :descending)
|
132
|
-
# @param item_types [Array<Class
|
134
|
+
# @param item_types [Array<Class<StatelyDB::Item>, String>] the item types to filter by. The returned
|
133
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
|
134
151
|
# @param gt [StatelyDB::KeyPath | String] filters results to only include items with a key greater than the
|
135
152
|
# specified value based on lexicographic ordering.
|
136
153
|
# @param gte [StatelyDB::KeyPath | String] filters results to only include items with a key greater than or equal to the
|
@@ -149,6 +166,7 @@ module StatelyDB
|
|
149
166
|
sort_property: nil,
|
150
167
|
sort_direction: :ascending,
|
151
168
|
item_types: [],
|
169
|
+
cel_filters: [],
|
152
170
|
gt: nil,
|
153
171
|
gte: nil,
|
154
172
|
lt: nil,
|
@@ -163,15 +181,14 @@ module StatelyDB
|
|
163
181
|
key_conditions = key_condition_params
|
164
182
|
.reject { |(_, value)| value.nil? }
|
165
183
|
.map { |(operator, key_path)| Stately::Db::KeyCondition.new(operator: operator, key_path: key_path) }
|
184
|
+
|
166
185
|
req = Stately::Db::BeginListRequest.new(
|
167
186
|
store_id: @store_id,
|
168
187
|
key_path_prefix: String(prefix),
|
169
188
|
limit:,
|
170
189
|
sort_property:,
|
171
190
|
sort_direction:,
|
172
|
-
filter_conditions: item_types
|
173
|
-
Stately::Db::FilterCondition.new(item_type: item_type.respond_to?(:name) ? item_type.name.split("::").last : item_type)
|
174
|
-
end,
|
191
|
+
filter_conditions: build_filters(item_types: item_types, cel_filters: cel_filters),
|
175
192
|
key_conditions: key_conditions,
|
176
193
|
allow_stale: @allow_stale,
|
177
194
|
schema_id: @schema::SCHEMA_ID,
|
@@ -211,8 +228,23 @@ module StatelyDB
|
|
211
228
|
# then the first page of results will be returned which may empty because it
|
212
229
|
# does not contain items of your selected item types. Be sure to check
|
213
230
|
# token.can_continue to see if there are more results to fetch.
|
214
|
-
# @param item_types [Array<
|
231
|
+
# @param item_types [Array<StatelyDB::Item, String>] the item types to filter by. The returned
|
215
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
|
216
248
|
# @param total_segments [Integer] the total number of segments to divide the
|
217
249
|
# scan into. Use this when you want to parallelize your operation.
|
218
250
|
# @param segment_index [Integer] the index of the segment to scan.
|
@@ -223,6 +255,7 @@ module StatelyDB
|
|
223
255
|
# client.data.begin_scan(limit: 10, item_types: [MyItem])
|
224
256
|
def begin_scan(limit: 0,
|
225
257
|
item_types: [],
|
258
|
+
cel_filters: [],
|
226
259
|
total_segments: nil,
|
227
260
|
segment_index: nil)
|
228
261
|
if total_segments.nil? != segment_index.nil?
|
@@ -230,12 +263,11 @@ module StatelyDB
|
|
230
263
|
code: GRPC::Core::StatusCodes::INVALID_ARGUMENT,
|
231
264
|
stately_code: "InvalidArgument")
|
232
265
|
end
|
266
|
+
|
233
267
|
req = Stately::Db::BeginScanRequest.new(
|
234
268
|
store_id: @store_id,
|
235
269
|
limit:,
|
236
|
-
filter_condition: item_types
|
237
|
-
Stately::Db::FilterCondition.new(item_type: item_type.respond_to?(:name) ? item_type.name.split("::").last : item_type)
|
238
|
-
end,
|
270
|
+
filter_condition: build_filters(item_types: item_types, cel_filters: cel_filters),
|
239
271
|
schema_id: @schema::SCHEMA_ID,
|
240
272
|
schema_version_id: @schema::SCHEMA_VERSION_ID
|
241
273
|
)
|
@@ -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
|
@@ -335,8 +337,23 @@ module StatelyDB
|
|
335
337
|
# @param limit [Integer] the maximum number of items to return
|
336
338
|
# @param sort_property [String] the property to sort by
|
337
339
|
# @param sort_direction [Symbol] the direction to sort by (:ascending or :descending)
|
338
|
-
# @param item_types [Array<
|
340
|
+
# @param item_types [Array<StatelyDB::Item, String>] the item types to filter by. The returned
|
339
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
|
340
357
|
# @param gt [StatelyDB::KeyPath | String] filters results to only include items with a key greater than the
|
341
358
|
# specified value based on lexicographic ordering.
|
342
359
|
# @param gte [StatelyDB::KeyPath | String] filters results to only include items with a key greater than or equal to the
|
@@ -358,6 +375,7 @@ module StatelyDB
|
|
358
375
|
sort_property: nil,
|
359
376
|
sort_direction: :ascending,
|
360
377
|
item_types: [],
|
378
|
+
cel_filters: [],
|
361
379
|
gt: nil,
|
362
380
|
gte: nil,
|
363
381
|
lt: nil,
|
@@ -386,11 +404,7 @@ module StatelyDB
|
|
386
404
|
limit:,
|
387
405
|
sort_property:,
|
388
406
|
sort_direction:,
|
389
|
-
filter_conditions: item_types
|
390
|
-
Stately::Db::FilterCondition.new(
|
391
|
-
item_type: item_type.respond_to?(:name) ? item_type.name.split("::").last : item_type
|
392
|
-
)
|
393
|
-
end,
|
407
|
+
filter_conditions: build_filters(item_types: item_types, cel_filters: cel_filters),
|
394
408
|
key_conditions: key_conditions
|
395
409
|
)
|
396
410
|
)
|
data/lib/version.rb
CHANGED
data/rbi/statelydb.rbi
CHANGED
@@ -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.
|
@@ -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
@@ -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)
|
@@ -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,
|
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
|