statelydb 0.25.1 → 0.29.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/README.md +1 -6
- data/lib/api/auth/get_auth_token_pb.rb +1 -1
- data/lib/api/auth/service_pb.rb +1 -1
- data/lib/api/db/continue_list_pb.rb +1 -1
- data/lib/api/db/continue_scan_pb.rb +1 -1
- data/lib/api/db/delete_pb.rb +1 -1
- data/lib/api/db/get_pb.rb +1 -1
- data/lib/api/db/item_pb.rb +1 -1
- data/lib/api/db/item_property_pb.rb +1 -1
- data/lib/api/db/list_filters_pb.rb +17 -0
- data/lib/api/db/list_pb.rb +5 -2
- data/lib/api/db/list_token_pb.rb +1 -1
- data/lib/api/db/put_pb.rb +1 -1
- data/lib/api/db/scan_pb.rb +4 -3
- data/lib/api/db/service_pb.rb +1 -1
- data/lib/api/db/sync_list_pb.rb +1 -1
- data/lib/api/db/transaction_pb.rb +3 -2
- data/lib/api/errors/error_details_pb.rb +1 -1
- data/lib/common/auth/auth_token_provider.rb +25 -7
- data/lib/common/auth/interceptor.rb +3 -2
- data/lib/common/auth/token_provider.rb +7 -0
- data/lib/key_path.rb +2 -1
- data/lib/statelydb.rb +37 -7
- data/lib/transaction/transaction.rb +36 -2
- data/lib/version.rb +5 -0
- data/rbi/db/delete_pb.rbi +3 -3
- data/rbi/db/get_pb.rbi +3 -3
- data/rbi/db/list_filters_pb.rbi +69 -0
- data/rbi/db/list_pb.rbi +263 -2
- data/rbi/db/put_pb.rbi +3 -3
- data/rbi/db/scan_pb.rbi +0 -66
- data/rbi/db/transaction_pb.rbi +132 -11
- data/rbi/statelydb.rbi +40 -39
- data/sig/statelydb.rbs +40 -37
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d5953d075d48d8ca4449644bb88fe0792587f00da52e29d0937b02416b0c0a0
|
4
|
+
data.tar.gz: 424e94dd43130382ec000b986d701581dd3a76a7e404ae7c4d2f0b3f3d8927b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f4c26cdb3399124ee45110ad92611551a64d14df7548d92a537797eef804191d538c267bfc82d9c6c20f9e2f3812fd13f9f4fcfb3b60339df743b265b05e1e9
|
7
|
+
data.tar.gz: 4661408175189b2ef7320a145bee131404eb0b6a542b00e846dfb8fee0a4d3fdbdfb660d43a675b7362d5b7b94d6e17c3fd0a63cda284e624e4d13419ab7b3be
|
data/README.md
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
# StatelyDB SDK for Ruby
|
2
2
|
|
3
|
-
This is the Ruby SDK for [StatelyDB](https://stately.cloud).
|
3
|
+
This is the Ruby SDK for [StatelyDB](https://stately.cloud). StatelyDB is a document database built on top of DynamoDB. It uses Elastic Schema to allow you to update your data model at any time, with automatic backwards and forwards compatibility.
|
4
4
|
|
5
5
|
### Getting started:
|
6
6
|
|
7
|
-
##### Disclaimer:
|
8
|
-
|
9
|
-
We're still in an invite-only preview mode - if you're interested, please reach out to [preview@stately.cloud](mailto:preview@stately.cloud?subject=Early%20Access%20Program).
|
10
|
-
|
11
7
|
Begin by following our [Getting Started Guide] which will help you define, generate, and publish a DB schema so that it can be used.
|
12
8
|
|
13
9
|
##### Install the SDK
|
@@ -16,7 +12,6 @@ Begin by following our [Getting Started Guide] which will help you define, gener
|
|
16
12
|
gem install statelydb
|
17
13
|
```
|
18
14
|
|
19
|
-
|
20
15
|
### Usage:
|
21
16
|
|
22
17
|
Create an authenticated client, then import your item types from your generated schema module and use the client!
|
@@ -7,7 +7,7 @@ require 'google/protobuf'
|
|
7
7
|
|
8
8
|
descriptor_data = "\n\x19\x61uth/get_auth_token.proto\x12\x0cstately.auth\"B\n\x13GetAuthTokenRequest\x12\x1f\n\naccess_key\x18\x01 \x01(\tH\x00R\taccessKeyB\n\n\x08identity\"W\n\x14GetAuthTokenResponse\x12\x1d\n\nauth_token\x18\x01 \x01(\tR\tauthToken\x12 \n\x0c\x65xpires_in_s\x18\x02 \x01(\x04R\nexpiresInSBv\n\x10\x63om.stately.authB\x11GetAuthTokenProtoP\x01\xa2\x02\x03SAX\xaa\x02\x0cStately.Auth\xca\x02\x0cStately\\Auth\xe2\x02\x18Stately\\Auth\\GPBMetadata\xea\x02\rStately::Authb\x06proto3"
|
9
9
|
|
10
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
10
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
11
11
|
pool.add_serialized_file(descriptor_data)
|
12
12
|
|
13
13
|
module Stately
|
data/lib/api/auth/service_pb.rb
CHANGED
@@ -9,7 +9,7 @@ require 'api/auth/get_auth_token_pb'
|
|
9
9
|
|
10
10
|
descriptor_data = "\n\x12\x61uth/service.proto\x12\x0cstately.auth\x1a\x19\x61uth/get_auth_token.proto2i\n\x0b\x41uthService\x12Z\n\x0cGetAuthToken\x12!.stately.auth.GetAuthTokenRequest\x1a\".stately.auth.GetAuthTokenResponse\"\x03\x90\x02\x01\x42q\n\x10\x63om.stately.authB\x0cServiceProtoP\x01\xa2\x02\x03SAX\xaa\x02\x0cStately.Auth\xca\x02\x0cStately\\Auth\xe2\x02\x18Stately\\Auth\\GPBMetadata\xea\x02\rStately::Authb\x06proto3"
|
11
11
|
|
12
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
12
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
13
13
|
pool.add_serialized_file(descriptor_data)
|
14
14
|
|
15
15
|
module Stately
|
@@ -7,7 +7,7 @@ require 'google/protobuf'
|
|
7
7
|
|
8
8
|
descriptor_data = "\n\x16\x64\x62/continue_list.proto\x12\nstately.db\"\xbe\x01\n\x13\x43ontinueListRequest\x12\x1d\n\ntoken_data\x18\x01 \x01(\x0cR\ttokenData\x12?\n\tdirection\x18\x02 \x01(\x0e\x32!.stately.db.ContinueListDirectionR\tdirection\x12*\n\x11schema_version_id\x18\x05 \x01(\rR\x0fschemaVersionId\x12\x1b\n\tschema_id\x18\x06 \x01(\x04R\x08schemaId*N\n\x15\x43ontinueListDirection\x12\x19\n\x15\x43ONTINUE_LIST_FORWARD\x10\x00\x12\x1a\n\x16\x43ONTINUE_LIST_BACKWARD\x10\x01\x42l\n\x0e\x63om.stately.dbB\x11\x43ontinueListProtoP\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
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
10
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
11
11
|
pool.add_serialized_file(descriptor_data)
|
12
12
|
|
13
13
|
module Stately
|
@@ -7,7 +7,7 @@ require 'google/protobuf'
|
|
7
7
|
|
8
8
|
descriptor_data = "\n\x16\x64\x62/continue_scan.proto\x12\nstately.db\"}\n\x13\x43ontinueScanRequest\x12\x1d\n\ntoken_data\x18\x01 \x01(\x0cR\ttokenData\x12*\n\x11schema_version_id\x18\x02 \x01(\rR\x0fschemaVersionId\x12\x1b\n\tschema_id\x18\x03 \x01(\x04R\x08schemaIdBl\n\x0e\x63om.stately.dbB\x11\x43ontinueScanProtoP\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
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
10
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
11
11
|
pool.add_serialized_file(descriptor_data)
|
12
12
|
|
13
13
|
module Stately
|
data/lib/api/db/delete_pb.rb
CHANGED
@@ -7,7 +7,7 @@ require 'google/protobuf'
|
|
7
7
|
|
8
8
|
descriptor_data = "\n\x0f\x64\x62/delete.proto\x12\nstately.db\"\xab\x01\n\rDeleteRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12\x30\n\x07\x64\x65letes\x18\x03 \x03(\x0b\x32\x16.stately.db.DeleteItemR\x07\x64\x65letes\x12*\n\x11schema_version_id\x18\x05 \x01(\rR\x0fschemaVersionId\x12\x1b\n\tschema_id\x18\x06 \x01(\x04R\x08schemaIdJ\x04\x08\x04\x10\x05\"\'\n\nDeleteItem\x12\x19\n\x08key_path\x18\x01 \x01(\tR\x07keyPath\"/\n\x0c\x44\x65leteResult\x12\x19\n\x08key_path\x18\x01 \x01(\tR\x07keyPathJ\x04\x08\x02\x10\x03\"D\n\x0e\x44\x65leteResponse\x12\x32\n\x07results\x18\x01 \x03(\x0b\x32\x18.stately.db.DeleteResultR\x07resultsBf\n\x0e\x63om.stately.dbB\x0b\x44\x65leteProtoP\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
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
10
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
11
11
|
pool.add_serialized_file(descriptor_data)
|
12
12
|
|
13
13
|
module Stately
|
data/lib/api/db/get_pb.rb
CHANGED
@@ -9,7 +9,7 @@ require 'api/db/item_pb'
|
|
9
9
|
|
10
10
|
descriptor_data = "\n\x0c\x64\x62/get.proto\x12\nstately.db\x1a\rdb/item.proto\"\xc0\x01\n\nGetRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12\'\n\x04gets\x18\x02 \x03(\x0b\x32\x13.stately.db.GetItemR\x04gets\x12\x1f\n\x0b\x61llow_stale\x18\x03 \x01(\x08R\nallowStale\x12*\n\x11schema_version_id\x18\x05 \x01(\rR\x0fschemaVersionId\x12\x1b\n\tschema_id\x18\x06 \x01(\x04R\x08schemaIdJ\x04\x08\x04\x10\x05\"$\n\x07GetItem\x12\x19\n\x08key_path\x18\x01 \x01(\tR\x07keyPath\"5\n\x0bGetResponse\x12&\n\x05items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x05itemsBc\n\x0e\x63om.stately.dbB\x08GetProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
11
11
|
|
12
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
12
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
13
13
|
pool.add_serialized_file(descriptor_data)
|
14
14
|
|
15
15
|
module Stately
|
data/lib/api/db/item_pb.rb
CHANGED
@@ -9,7 +9,7 @@ require 'google/protobuf/struct_pb'
|
|
9
9
|
|
10
10
|
descriptor_data = "\n\rdb/item.proto\x12\nstately.db\x1a\x1cgoogle/protobuf/struct.proto\"u\n\x04Item\x12\x1b\n\titem_type\x18\x01 \x01(\tR\x08itemType\x12\x16\n\x05proto\x18\x02 \x01(\x0cH\x00R\x05proto\x12-\n\x04json\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructH\x00R\x04jsonB\t\n\x07payloadBd\n\x0e\x63om.stately.dbB\tItemProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
11
11
|
|
12
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
12
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
13
13
|
pool.add_serialized_file(descriptor_data)
|
14
14
|
|
15
15
|
module Stately
|
@@ -7,7 +7,7 @@ require 'google/protobuf'
|
|
7
7
|
|
8
8
|
descriptor_data = "\n\x16\x64\x62/item_property.proto\x12\nstately.db*\x8b\x02\n\x10SortableProperty\x12\x1e\n\x1aSORTABLE_PROPERTY_KEY_PATH\x10\x00\x12+\n\'SORTABLE_PROPERTY_LAST_MODIFIED_VERSION\x10\x01\x12)\n%SORTABLE_PROPERTY_GROUP_LOCAL_INDEX_1\x10\x08\x12)\n%SORTABLE_PROPERTY_GROUP_LOCAL_INDEX_2\x10\t\x12)\n%SORTABLE_PROPERTY_GROUP_LOCAL_INDEX_3\x10\n\x12)\n%SORTABLE_PROPERTY_GROUP_LOCAL_INDEX_4\x10\x0b\x42l\n\x0e\x63om.stately.dbB\x11ItemPropertyProtoP\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
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
10
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
11
11
|
pool.add_serialized_file(descriptor_data)
|
12
12
|
|
13
13
|
module Stately
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
|
+
# source: db/list_filters.proto
|
4
|
+
|
5
|
+
require 'google/protobuf'
|
6
|
+
|
7
|
+
|
8
|
+
descriptor_data = "\n\x15\x64\x62/list_filters.proto\x12\nstately.db\"9\n\x0f\x46ilterCondition\x12\x1d\n\titem_type\x18\x01 \x01(\tH\x00R\x08itemTypeB\x07\n\x05valueBk\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
|
+
|
10
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
11
|
+
pool.add_serialized_file(descriptor_data)
|
12
|
+
|
13
|
+
module Stately
|
14
|
+
module Db
|
15
|
+
FilterCondition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.FilterCondition").msgclass
|
16
|
+
end
|
17
|
+
end
|
data/lib/api/db/list_pb.rb
CHANGED
@@ -6,12 +6,13 @@ require 'google/protobuf'
|
|
6
6
|
|
7
7
|
require 'api/db/item_pb'
|
8
8
|
require 'api/db/item_property_pb'
|
9
|
+
require 'api/db/list_filters_pb'
|
9
10
|
require 'api/db/list_token_pb'
|
10
11
|
|
11
12
|
|
12
|
-
descriptor_data = "\n\rdb/list.proto\x12\nstately.db\x1a\rdb/item.proto\x1a\x16\x64\x62/item_property.proto\x1a\x13\x64\x62/list_token.proto\"\
|
13
|
+
descriptor_data = "\n\rdb/list.proto\x12\nstately.db\x1a\rdb/item.proto\x1a\x16\x64\x62/item_property.proto\x1a\x15\x64\x62/list_filters.proto\x1a\x13\x64\x62/list_token.proto\"\xe5\x03\n\x10\x42\x65ginListRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12&\n\x0fkey_path_prefix\x18\x02 \x01(\tR\rkeyPathPrefix\x12\x14\n\x05limit\x18\x03 \x01(\rR\x05limit\x12\x1f\n\x0b\x61llow_stale\x18\x04 \x01(\x08R\nallowStale\x12\x41\n\rsort_property\x18\x05 \x01(\x0e\x32\x1c.stately.db.SortablePropertyR\x0csortProperty\x12@\n\x0esort_direction\x18\x06 \x01(\x0e\x32\x19.stately.db.SortDirectionR\rsortDirection\x12*\n\x11schema_version_id\x18\x07 \x01(\rR\x0fschemaVersionId\x12\x1b\n\tschema_id\x18\x08 \x01(\x04R\x08schemaId\x12H\n\x11\x66ilter_conditions\x18\t \x03(\x0b\x32\x1b.stately.db.FilterConditionR\x10\x66ilterConditions\x12?\n\x0ekey_conditions\x18\n \x03(\x0b\x32\x18.stately.db.KeyConditionR\rkeyConditions\"\x8b\x01\n\x0cListResponse\x12\x37\n\x06result\x18\x01 \x01(\x0b\x32\x1d.stately.db.ListPartialResultH\x00R\x06result\x12\x36\n\x08\x66inished\x18\x02 \x01(\x0b\x32\x18.stately.db.ListFinishedH\x00R\x08\x66inishedB\n\n\x08response\";\n\x11ListPartialResult\x12&\n\x05items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x05items\";\n\x0cListFinished\x12+\n\x05token\x18\x01 \x01(\x0b\x32\x15.stately.db.ListTokenR\x05token\"[\n\x0cKeyCondition\x12\x19\n\x08key_path\x18\x01 \x01(\tR\x07keyPath\x12\x30\n\x08operator\x18\x02 \x01(\x0e\x32\x14.stately.db.OperatorR\x08operator*8\n\rSortDirection\x12\x12\n\x0eSORT_ASCENDING\x10\x00\x12\x13\n\x0fSORT_DESCENDING\x10\x01*\x9c\x01\n\x08Operator\x12\x18\n\x14OPERATOR_UNSPECIFIED\x10\x00\x12\x19\n\x15OPERATOR_GREATER_THAN\x10\x04\x12\"\n\x1eOPERATOR_GREATER_THAN_OR_EQUAL\x10\x05\x12\x16\n\x12OPERATOR_LESS_THAN\x10\x06\x12\x1f\n\x1bOPERATOR_LESS_THAN_OR_EQUAL\x10\x07\x42\x64\n\x0e\x63om.stately.dbB\tListProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
13
14
|
|
14
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
15
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
15
16
|
pool.add_serialized_file(descriptor_data)
|
16
17
|
|
17
18
|
module Stately
|
@@ -20,6 +21,8 @@ module Stately
|
|
20
21
|
ListResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.ListResponse").msgclass
|
21
22
|
ListPartialResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.ListPartialResult").msgclass
|
22
23
|
ListFinished = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.ListFinished").msgclass
|
24
|
+
KeyCondition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.KeyCondition").msgclass
|
23
25
|
SortDirection = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.SortDirection").enummodule
|
26
|
+
Operator = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.Operator").enummodule
|
24
27
|
end
|
25
28
|
end
|
data/lib/api/db/list_token_pb.rb
CHANGED
@@ -7,7 +7,7 @@ require 'google/protobuf'
|
|
7
7
|
|
8
8
|
descriptor_data = "\n\x13\x64\x62/list_token.proto\x12\nstately.db\"\x94\x01\n\tListToken\x12\x1d\n\ntoken_data\x18\x01 \x01(\x0cR\ttokenData\x12!\n\x0c\x63\x61n_continue\x18\x02 \x01(\x08R\x0b\x63\x61nContinue\x12\x19\n\x08\x63\x61n_sync\x18\x03 \x01(\x08R\x07\x63\x61nSync\x12*\n\x11schema_version_id\x18\x04 \x01(\rR\x0fschemaVersionIdBi\n\x0e\x63om.stately.dbB\x0eListTokenProtoP\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
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
10
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
11
11
|
pool.add_serialized_file(descriptor_data)
|
12
12
|
|
13
13
|
module Stately
|
data/lib/api/db/put_pb.rb
CHANGED
@@ -9,7 +9,7 @@ require 'api/db/item_pb'
|
|
9
9
|
|
10
10
|
descriptor_data = "\n\x0c\x64\x62/put.proto\x12\nstately.db\x1a\rdb/item.proto\"\x99\x01\n\nPutRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12\'\n\x04puts\x18\x02 \x03(\x0b\x32\x13.stately.db.PutItemR\x04puts\x12*\n\x11schema_version_id\x18\x03 \x01(\rR\x0fschemaVersionId\x12\x1b\n\tschema_id\x18\x04 \x01(\x04R\x08schemaId\"\x99\x01\n\x07PutItem\x12$\n\x04item\x18\x01 \x01(\x0b\x32\x10.stately.db.ItemR\x04item\x12\x42\n\x1doverwrite_metadata_timestamps\x18\x02 \x01(\x08R\x1boverwriteMetadataTimestamps\x12$\n\x0emust_not_exist\x18\x03 \x01(\x08R\x0cmustNotExist\"5\n\x0bPutResponse\x12&\n\x05items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x05itemsBc\n\x0e\x63om.stately.dbB\x08PutProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
11
11
|
|
12
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
12
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
13
13
|
pool.add_serialized_file(descriptor_data)
|
14
14
|
|
15
15
|
module Stately
|
data/lib/api/db/scan_pb.rb
CHANGED
@@ -4,15 +4,16 @@
|
|
4
4
|
|
5
5
|
require 'google/protobuf'
|
6
6
|
|
7
|
+
require 'api/db/list_filters_pb'
|
7
8
|
|
8
|
-
descriptor_data = "\n\rdb/scan.proto\x12\nstately.db\"9\n\x0f\x46ilterCondition\x12\x1d\n\titem_type\x18\x01 \x01(\tH\x00R\x08itemTypeB\x07\n\x05value\"\xa5\x02\n\x10\x42\x65ginScanRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12\x46\n\x10\x66ilter_condition\x18\x02 \x03(\x0b\x32\x1b.stately.db.FilterConditionR\x0f\x66ilterCondition\x12\x14\n\x05limit\x18\x03 \x01(\rR\x05limit\x12O\n\x13segmentation_params\x18\x04 \x01(\x0b\x32\x1e.stately.db.SegmentationParamsR\x12segmentationParams\x12*\n\x11schema_version_id\x18\x05 \x01(\rR\x0fschemaVersionId\x12\x1b\n\tschema_id\x18\x06 \x01(\x04R\x08schemaId\"`\n\x12SegmentationParams\x12%\n\x0etotal_segments\x18\x05 \x01(\rR\rtotalSegments\x12#\n\rsegment_index\x18\x06 \x01(\rR\x0csegmentIndexBd\n\x0e\x63om.stately.dbB\tScanProtoP\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
|
+
descriptor_data = "\n\rdb/scan.proto\x12\nstately.db\x1a\x15\x64\x62/list_filters.proto\"\xa5\x02\n\x10\x42\x65ginScanRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12\x46\n\x10\x66ilter_condition\x18\x02 \x03(\x0b\x32\x1b.stately.db.FilterConditionR\x0f\x66ilterCondition\x12\x14\n\x05limit\x18\x03 \x01(\rR\x05limit\x12O\n\x13segmentation_params\x18\x04 \x01(\x0b\x32\x1e.stately.db.SegmentationParamsR\x12segmentationParams\x12*\n\x11schema_version_id\x18\x05 \x01(\rR\x0fschemaVersionId\x12\x1b\n\tschema_id\x18\x06 \x01(\x04R\x08schemaId\"`\n\x12SegmentationParams\x12%\n\x0etotal_segments\x18\x05 \x01(\rR\rtotalSegments\x12#\n\rsegment_index\x18\x06 \x01(\rR\x0csegmentIndexBd\n\x0e\x63om.stately.dbB\tScanProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
11
|
+
|
12
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
11
13
|
pool.add_serialized_file(descriptor_data)
|
12
14
|
|
13
15
|
module Stately
|
14
16
|
module Db
|
15
|
-
FilterCondition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.FilterCondition").msgclass
|
16
17
|
BeginScanRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.BeginScanRequest").msgclass
|
17
18
|
SegmentationParams = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("stately.db.SegmentationParams").msgclass
|
18
19
|
end
|
data/lib/api/db/service_pb.rb
CHANGED
@@ -17,7 +17,7 @@ require 'api/db/transaction_pb'
|
|
17
17
|
|
18
18
|
descriptor_data = "\n\x10\x64\x62/service.proto\x12\nstately.db\x1a\x16\x64\x62/continue_list.proto\x1a\x16\x64\x62/continue_scan.proto\x1a\x0f\x64\x62/delete.proto\x1a\x0c\x64\x62/get.proto\x1a\rdb/list.proto\x1a\x0c\x64\x62/put.proto\x1a\rdb/scan.proto\x1a\x12\x64\x62/sync_list.proto\x1a\x14\x64\x62/transaction.proto2\xb1\x05\n\x0f\x44\x61tabaseService\x12;\n\x03Put\x12\x16.stately.db.PutRequest\x1a\x17.stately.db.PutResponse\"\x03\x90\x02\x02\x12;\n\x03Get\x12\x16.stately.db.GetRequest\x1a\x17.stately.db.GetResponse\"\x03\x90\x02\x01\x12\x44\n\x06\x44\x65lete\x12\x19.stately.db.DeleteRequest\x1a\x1a.stately.db.DeleteResponse\"\x03\x90\x02\x02\x12J\n\tBeginList\x12\x1c.stately.db.BeginListRequest\x1a\x18.stately.db.ListResponse\"\x03\x90\x02\x01\x30\x01\x12P\n\x0c\x43ontinueList\x12\x1f.stately.db.ContinueListRequest\x1a\x18.stately.db.ListResponse\"\x03\x90\x02\x01\x30\x01\x12J\n\tBeginScan\x12\x1c.stately.db.BeginScanRequest\x1a\x18.stately.db.ListResponse\"\x03\x90\x02\x01\x30\x01\x12P\n\x0c\x43ontinueScan\x12\x1f.stately.db.ContinueScanRequest\x1a\x18.stately.db.ListResponse\"\x03\x90\x02\x01\x30\x01\x12L\n\x08SyncList\x12\x1b.stately.db.SyncListRequest\x1a\x1c.stately.db.SyncListResponse\"\x03\x90\x02\x01\x30\x01\x12T\n\x0bTransaction\x12\x1e.stately.db.TransactionRequest\x1a\x1f.stately.db.TransactionResponse\"\x00(\x01\x30\x01\x42g\n\x0e\x63om.stately.dbB\x0cServiceProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
19
19
|
|
20
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
20
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
21
21
|
pool.add_serialized_file(descriptor_data)
|
22
22
|
|
23
23
|
module Stately
|
data/lib/api/db/sync_list_pb.rb
CHANGED
@@ -10,7 +10,7 @@ require 'api/db/list_pb'
|
|
10
10
|
|
11
11
|
descriptor_data = "\n\x12\x64\x62/sync_list.proto\x12\nstately.db\x1a\rdb/item.proto\x1a\rdb/list.proto\"y\n\x0fSyncListRequest\x12\x1d\n\ntoken_data\x18\x01 \x01(\x0cR\ttokenData\x12*\n\x11schema_version_id\x18\x05 \x01(\rR\x0fschemaVersionId\x12\x1b\n\tschema_id\x18\x06 \x01(\x04R\x08schemaId\"\xc8\x01\n\x10SyncListResponse\x12\x31\n\x05reset\x18\x01 \x01(\x0b\x32\x19.stately.db.SyncListResetH\x00R\x05reset\x12=\n\x06result\x18\x02 \x01(\x0b\x32#.stately.db.SyncListPartialResponseH\x00R\x06result\x12\x36\n\x08\x66inished\x18\x03 \x01(\x0b\x32\x18.stately.db.ListFinishedH\x00R\x08\x66inishedB\n\n\x08response\"\x0f\n\rSyncListReset\"\xdf\x01\n\x17SyncListPartialResponse\x12\x35\n\rchanged_items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x0c\x63hangedItems\x12<\n\rdeleted_items\x18\x02 \x03(\x0b\x32\x17.stately.db.DeletedItemR\x0c\x64\x65letedItems\x12O\n%updated_item_keys_outside_list_window\x18\x03 \x03(\tR updatedItemKeysOutsideListWindow\"(\n\x0b\x44\x65letedItem\x12\x19\n\x08key_path\x18\x01 \x01(\tR\x07keyPathBh\n\x0e\x63om.stately.dbB\rSyncListProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
12
12
|
|
13
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
13
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
14
14
|
pool.add_serialized_file(descriptor_data)
|
15
15
|
|
16
16
|
module Stately
|
@@ -10,13 +10,14 @@ require 'api/db/get_pb'
|
|
10
10
|
require 'api/db/item_pb'
|
11
11
|
require 'api/db/item_property_pb'
|
12
12
|
require 'api/db/list_pb'
|
13
|
+
require 'api/db/list_filters_pb'
|
13
14
|
require 'api/db/put_pb'
|
14
15
|
require 'google/protobuf/empty_pb'
|
15
16
|
|
16
17
|
|
17
|
-
descriptor_data = "\n\x14\x64\x62/transaction.proto\x12\nstately.db\x1a\x16\x64\x62/continue_list.proto\x1a\x0f\x64\x62/delete.proto\x1a\x0c\x64\x62/get.proto\x1a\rdb/item.proto\x1a\x16\x64\x62/item_property.proto\x1a\rdb/list.proto\x1a\x0c\x64\x62/put.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x9f\x04\n\x12TransactionRequest\x12\x1d\n\nmessage_id\x18\x01 \x01(\rR\tmessageId\x12\x34\n\x05\x62\x65gin\x18\x02 \x01(\x0b\x32\x1c.stately.db.TransactionBeginH\x00R\x05\x62\x65gin\x12\x39\n\tget_items\x18\x03 \x01(\x0b\x32\x1a.stately.db.TransactionGetH\x00R\x08getItems\x12\x41\n\nbegin_list\x18\x04 \x01(\x0b\x32 .stately.db.TransactionBeginListH\x00R\tbeginList\x12J\n\rcontinue_list\x18\x05 \x01(\x0b\x32#.stately.db.TransactionContinueListH\x00R\x0c\x63ontinueList\x12\x39\n\tput_items\x18\x06 \x01(\x0b\x32\x1a.stately.db.TransactionPutH\x00R\x08putItems\x12\x42\n\x0c\x64\x65lete_items\x18\x07 \x01(\x0b\x32\x1d.stately.db.TransactionDeleteH\x00R\x0b\x64\x65leteItems\x12\x30\n\x06\x63ommit\x18\x08 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00R\x06\x63ommit\x12.\n\x05\x61\x62ort\x18\t \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00R\x05\x61\x62ortB\t\n\x07\x63ommand\"\xc8\x02\n\x13TransactionResponse\x12\x1d\n\nmessage_id\x18\x01 \x01(\rR\tmessageId\x12\x45\n\x0bget_results\x18\x02 \x01(\x0b\x32\".stately.db.TransactionGetResponseH\x00R\ngetResults\x12\x38\n\x07put_ack\x18\x03 \x01(\x0b\x32\x1d.stately.db.TransactionPutAckH\x00R\x06putAck\x12H\n\x0clist_results\x18\x04 \x01(\x0b\x32#.stately.db.TransactionListResponseH\x00R\x0blistResults\x12=\n\x08\x66inished\x18\x05 \x01(\x0b\x32\x1f.stately.db.TransactionFinishedH\x00R\x08\x66inishedB\x08\n\x06result\"v\n\x10TransactionBegin\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12*\n\x11schema_version_id\x18\x02 \x01(\rR\x0fschemaVersionId\x12\x1b\n\tschema_id\x18\x03 \x01(\x04R\x08schemaId\"9\n\x0eTransactionGet\x12\'\n\x04gets\x18\x01 \x03(\x0b\x32\x13.stately.db.GetItemR\x04gets\"\
|
18
|
+
descriptor_data = "\n\x14\x64\x62/transaction.proto\x12\nstately.db\x1a\x16\x64\x62/continue_list.proto\x1a\x0f\x64\x62/delete.proto\x1a\x0c\x64\x62/get.proto\x1a\rdb/item.proto\x1a\x16\x64\x62/item_property.proto\x1a\rdb/list.proto\x1a\x15\x64\x62/list_filters.proto\x1a\x0c\x64\x62/put.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x9f\x04\n\x12TransactionRequest\x12\x1d\n\nmessage_id\x18\x01 \x01(\rR\tmessageId\x12\x34\n\x05\x62\x65gin\x18\x02 \x01(\x0b\x32\x1c.stately.db.TransactionBeginH\x00R\x05\x62\x65gin\x12\x39\n\tget_items\x18\x03 \x01(\x0b\x32\x1a.stately.db.TransactionGetH\x00R\x08getItems\x12\x41\n\nbegin_list\x18\x04 \x01(\x0b\x32 .stately.db.TransactionBeginListH\x00R\tbeginList\x12J\n\rcontinue_list\x18\x05 \x01(\x0b\x32#.stately.db.TransactionContinueListH\x00R\x0c\x63ontinueList\x12\x39\n\tput_items\x18\x06 \x01(\x0b\x32\x1a.stately.db.TransactionPutH\x00R\x08putItems\x12\x42\n\x0c\x64\x65lete_items\x18\x07 \x01(\x0b\x32\x1d.stately.db.TransactionDeleteH\x00R\x0b\x64\x65leteItems\x12\x30\n\x06\x63ommit\x18\x08 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00R\x06\x63ommit\x12.\n\x05\x61\x62ort\x18\t \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00R\x05\x61\x62ortB\t\n\x07\x63ommand\"\xc8\x02\n\x13TransactionResponse\x12\x1d\n\nmessage_id\x18\x01 \x01(\rR\tmessageId\x12\x45\n\x0bget_results\x18\x02 \x01(\x0b\x32\".stately.db.TransactionGetResponseH\x00R\ngetResults\x12\x38\n\x07put_ack\x18\x03 \x01(\x0b\x32\x1d.stately.db.TransactionPutAckH\x00R\x06putAck\x12H\n\x0clist_results\x18\x04 \x01(\x0b\x32#.stately.db.TransactionListResponseH\x00R\x0blistResults\x12=\n\x08\x66inished\x18\x05 \x01(\x0b\x32\x1f.stately.db.TransactionFinishedH\x00R\x08\x66inishedB\x08\n\x06result\"v\n\x10TransactionBegin\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12*\n\x11schema_version_id\x18\x02 \x01(\rR\x0fschemaVersionId\x12\x1b\n\tschema_id\x18\x03 \x01(\x04R\x08schemaId\"9\n\x0eTransactionGet\x12\'\n\x04gets\x18\x01 \x03(\x0b\x32\x13.stately.db.GetItemR\x04gets\"\xe4\x02\n\x14TransactionBeginList\x12&\n\x0fkey_path_prefix\x18\x01 \x01(\tR\rkeyPathPrefix\x12\x14\n\x05limit\x18\x02 \x01(\rR\x05limit\x12\x41\n\rsort_property\x18\x03 \x01(\x0e\x32\x1c.stately.db.SortablePropertyR\x0csortProperty\x12@\n\x0esort_direction\x18\x04 \x01(\x0e\x32\x19.stately.db.SortDirectionR\rsortDirection\x12H\n\x11\x66ilter_conditions\x18\t \x03(\x0b\x32\x1b.stately.db.FilterConditionR\x10\x66ilterConditions\x12?\n\x0ekey_conditions\x18\n \x03(\x0b\x32\x18.stately.db.KeyConditionR\rkeyConditions\"y\n\x17TransactionContinueList\x12\x1d\n\ntoken_data\x18\x01 \x01(\x0cR\ttokenData\x12?\n\tdirection\x18\x04 \x01(\x0e\x32!.stately.db.ContinueListDirectionR\tdirection\"9\n\x0eTransactionPut\x12\'\n\x04puts\x18\x01 \x03(\x0b\x32\x13.stately.db.PutItemR\x04puts\"E\n\x11TransactionDelete\x12\x30\n\x07\x64\x65letes\x18\x01 \x03(\x0b\x32\x16.stately.db.DeleteItemR\x07\x64\x65letes\"@\n\x16TransactionGetResponse\x12&\n\x05items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x05items\"D\n\x0bGeneratedID\x12\x14\n\x04uint\x18\x01 \x01(\x04H\x00R\x04uint\x12\x16\n\x05\x62ytes\x18\x02 \x01(\x0cH\x00R\x05\x62ytesB\x07\n\x05value\"Q\n\x11TransactionPutAck\x12<\n\rgenerated_ids\x18\x01 \x03(\x0b\x32\x17.stately.db.GeneratedIDR\x0cgeneratedIds\"\x96\x01\n\x17TransactionListResponse\x12\x37\n\x06result\x18\x01 \x01(\x0b\x32\x1d.stately.db.ListPartialResultH\x00R\x06result\x12\x36\n\x08\x66inished\x18\x02 \x01(\x0b\x32\x18.stately.db.ListFinishedH\x00R\x08\x66inishedB\n\n\x08response\"\xa7\x01\n\x13TransactionFinished\x12\x1c\n\tcommitted\x18\x01 \x01(\x08R\tcommitted\x12\x31\n\x0bput_results\x18\x02 \x03(\x0b\x32\x10.stately.db.ItemR\nputResults\x12?\n\x0e\x64\x65lete_results\x18\x03 \x03(\x0b\x32\x18.stately.db.DeleteResultR\rdeleteResultsBk\n\x0e\x63om.stately.dbB\x10TransactionProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
18
19
|
|
19
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
20
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
20
21
|
pool.add_serialized_file(descriptor_data)
|
21
22
|
|
22
23
|
module Stately
|
@@ -7,7 +7,7 @@ require 'google/protobuf'
|
|
7
7
|
|
8
8
|
descriptor_data = "\n\x1a\x65rrors/error_details.proto\x12\x0estately.errors\"\x8d\x01\n\x13StatelyErrorDetails\x12!\n\x0cstately_code\x18\x01 \x01(\tR\x0bstatelyCode\x12\x18\n\x07message\x18\x02 \x01(\tR\x07message\x12%\n\x0eupstream_cause\x18\x03 \x01(\tR\rupstreamCause\x12\x12\n\x04\x63ode\x18\x04 \x01(\rR\x04\x63odeB\x80\x01\n\x12\x63om.stately.errorsB\x11\x45rrorDetailsProtoP\x01\xa2\x02\x03SEX\xaa\x02\x0eStately.Errors\xca\x02\x0eStately\\Errors\xe2\x02\x1aStately\\Errors\\GPBMetadata\xea\x02\x0fStately::Errorsb\x06proto3"
|
9
9
|
|
10
|
-
pool = Google::Protobuf::DescriptorPool.generated_pool
|
10
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
11
11
|
pool.add_serialized_file(descriptor_data)
|
12
12
|
|
13
13
|
module Stately
|
@@ -24,31 +24,49 @@ module StatelyDB
|
|
24
24
|
# It will default to using the value of `STATELY_ACCESS_KEY` if
|
25
25
|
# no credentials are explicitly passed and will throw an error if no credentials are found.
|
26
26
|
class AuthTokenProvider < TokenProvider
|
27
|
-
# @param [String] endpoint The endpoint of the auth server
|
28
27
|
# @param [String] access_key The StatelyDB access key credential
|
29
28
|
# @param [Float] base_retry_backoff_secs The base retry backoff in seconds
|
30
29
|
def initialize(
|
31
|
-
endpoint: "https://api.stately.cloud",
|
32
30
|
access_key: ENV.fetch("STATELY_ACCESS_KEY", nil),
|
33
31
|
base_retry_backoff_secs: 1
|
34
32
|
)
|
35
33
|
super()
|
36
|
-
@
|
34
|
+
@access_key = access_key
|
35
|
+
@base_retry_backoff_secs = base_retry_backoff_secs
|
36
|
+
end
|
37
|
+
|
38
|
+
# Start the token provider. Starting multiple times is a no-op.
|
39
|
+
def start(
|
40
|
+
endpoint: "https://api.stately.cloud"
|
41
|
+
)
|
42
|
+
# If the actor is already started, do nothing
|
43
|
+
return unless @actor.nil?
|
44
|
+
|
45
|
+
@actor = Async::Actor.new(Actor.new(endpoint:, access_key: @access_key,
|
46
|
+
base_retry_backoff_secs: @base_retry_backoff_secs))
|
37
47
|
# this initialization cannot happen in the constructor because it is async and must run on the event loop
|
38
48
|
# which is not available in the constructor
|
39
|
-
@actor.
|
49
|
+
@actor.start
|
40
50
|
end
|
41
51
|
|
42
52
|
# Close the token provider and kill any background operations
|
43
53
|
# This just invokes the close method on the actor which should do the cleanup
|
44
54
|
# @return [void]
|
45
55
|
def close
|
46
|
-
@actor.close
|
56
|
+
@actor.close unless @actor.nil?
|
57
|
+
@actor = nil
|
47
58
|
end
|
48
59
|
|
49
60
|
# Get the current access token
|
50
61
|
# @return [String] The current access token
|
51
62
|
def get_token(force: false)
|
63
|
+
if @actor.nil?
|
64
|
+
raise StatelyDB::Error.new(
|
65
|
+
"Token provider has not been started. Call start() before get_token().",
|
66
|
+
code: GRPC::Core::StatusCodes::FAILED_PRECONDITION,
|
67
|
+
stately_code: "FailedPrecondition"
|
68
|
+
)
|
69
|
+
end
|
52
70
|
@actor.get_token(force: force)
|
53
71
|
end
|
54
72
|
|
@@ -80,10 +98,10 @@ module StatelyDB
|
|
80
98
|
@pending_refresh = nil
|
81
99
|
end
|
82
100
|
|
83
|
-
#
|
101
|
+
# Start the actor. This runs on the actor thread which means
|
84
102
|
# we can dispatch async operations here.
|
85
103
|
# @return [void]
|
86
|
-
def
|
104
|
+
def start
|
87
105
|
# disable the async lib logger. We do our own error handling and propagation
|
88
106
|
Console.logger.disable(Async::Task)
|
89
107
|
refresh_token
|
@@ -9,9 +9,10 @@ module StatelyDB
|
|
9
9
|
module Auth
|
10
10
|
# GRPC interceptor to authenticate against Stately and append bearer tokens to outgoing requests
|
11
11
|
class Interceptor < GRPC::ClientInterceptor
|
12
|
-
# @param [StatelyDB::Common::Auth::TokenProvider] token_provider The token provider to use for authentication
|
12
|
+
# @param [StatelyDB::Common::Auth::TokenProvider] token_provider The token provider to use for authentication.
|
13
|
+
# This must have been started already.
|
13
14
|
def initialize(
|
14
|
-
token_provider:
|
15
|
+
token_provider:
|
15
16
|
)
|
16
17
|
super()
|
17
18
|
@token_provider = token_provider
|
@@ -7,6 +7,13 @@ module StatelyDB
|
|
7
7
|
# TokenProvider is an abstract base class that should be extended
|
8
8
|
# for individual token provider implementations
|
9
9
|
class TokenProvider
|
10
|
+
# Start the token provider. Starting multiple times should be a no-op.
|
11
|
+
# @param [String] endpoint The endpoint to connect to
|
12
|
+
# @return [void]
|
13
|
+
def start(endpoint: "https://api.stately.cloud") # rubocop:disable Lint/UnusedMethodArgument
|
14
|
+
raise "Not Implemented"
|
15
|
+
end
|
16
|
+
|
10
17
|
# Get the current access token
|
11
18
|
# @param [Boolean] force Whether to force a refresh of the token
|
12
19
|
# @return [String] The current access token
|
data/lib/key_path.rb
CHANGED
@@ -47,7 +47,8 @@ module StatelyDB
|
|
47
47
|
new.with(namespace, identifier)
|
48
48
|
end
|
49
49
|
|
50
|
-
# If the value is a binary string, encode it as a url-safe
|
50
|
+
# If the value is a binary string, encode it as a url-safe
|
51
|
+
# base64 string with padding removed.
|
51
52
|
#
|
52
53
|
# @param value [String, StatelyDB::UUID, #to_s] The value to convert to a key id.
|
53
54
|
# @return [String]
|
data/lib/statelydb.rb
CHANGED
@@ -49,11 +49,13 @@ module StatelyDB
|
|
49
49
|
|
50
50
|
endpoint = self.class.make_endpoint(endpoint:, region:)
|
51
51
|
@channel = Common::Net.new_channel(endpoint:)
|
52
|
-
# Make sure to use the correct endpoint for the default token provider
|
53
|
-
@token_provider = token_provider || Common::Auth::AuthTokenProvider.new(endpoint:)
|
54
|
-
|
55
52
|
interceptors = [Common::ErrorInterceptor.new]
|
56
|
-
|
53
|
+
# Make sure to use the correct endpoint for the default token provider
|
54
|
+
unless no_auth
|
55
|
+
@token_provider = token_provider || Common::Auth::AuthTokenProvider.new
|
56
|
+
@token_provider.start(endpoint: endpoint)
|
57
|
+
interceptors << Common::Auth::Interceptor.new(token_provider: @token_provider)
|
58
|
+
end
|
57
59
|
|
58
60
|
@stub = Stately::Db::DatabaseService::Stub.new(nil, nil,
|
59
61
|
channel_override: @channel, interceptors:)
|
@@ -125,7 +127,18 @@ module StatelyDB
|
|
125
127
|
# @param prefix [String] the prefix to list
|
126
128
|
# @param limit [Integer] the maximum number of items to return
|
127
129
|
# @param sort_property [String] the property to sort by
|
128
|
-
# @param sort_direction [Symbol] the direction to sort by (:ascending or :descending)
|
130
|
+
# @param sort_direction [Symbol, String, Integer] the direction to sort by (:ascending or :descending)
|
131
|
+
# @param item_types [Array<Class, String>] the item types to filter by. The returned
|
132
|
+
# items will be instances of one of these types.
|
133
|
+
# @param gt [StatelyDB::KeyPath | String] filters results to only include items with a key greater than the
|
134
|
+
# specified value based on lexicographic ordering.
|
135
|
+
# @param gte [StatelyDB::KeyPath | String] filters results to only include items with a key greater than or equal to the
|
136
|
+
# specified value based on lexicographic ordering.
|
137
|
+
# @param lt [StatelyDB::KeyPath | String] filters results to only include items with a key less than the
|
138
|
+
# specified value based on lexicographic ordering.
|
139
|
+
# @param lte [StatelyDB::KeyPath | String] filters results to only include items with a key less than or equal to the
|
140
|
+
# specified value based on lexicographic ordering.
|
141
|
+
|
129
142
|
# @return [Array<StatelyDB::Item>, StatelyDB::Token] the list of Items and the token
|
130
143
|
#
|
131
144
|
# @example
|
@@ -133,15 +146,32 @@ module StatelyDB
|
|
133
146
|
def begin_list(prefix,
|
134
147
|
limit: 100,
|
135
148
|
sort_property: nil,
|
136
|
-
sort_direction: :ascending
|
149
|
+
sort_direction: :ascending,
|
150
|
+
item_types: [],
|
151
|
+
gt: nil,
|
152
|
+
gte: nil,
|
153
|
+
lt: nil,
|
154
|
+
lte: nil)
|
137
155
|
sort_direction = sort_direction == :ascending ? 0 : 1
|
138
|
-
|
156
|
+
key_condition_params = [
|
157
|
+
[Stately::Db::Operator::OPERATOR_GREATER_THAN, gt.is_a?(String) ? gt : gt&.to_s],
|
158
|
+
[Stately::Db::Operator::OPERATOR_GREATER_THAN_OR_EQUAL, gte.is_a?(String) ? gte : gte&.to_s],
|
159
|
+
[Stately::Db::Operator::OPERATOR_LESS_THAN, lt.is_a?(String) ? lt : lt&.to_s],
|
160
|
+
[Stately::Db::Operator::OPERATOR_LESS_THAN_OR_EQUAL, lte.is_a?(String) ? lte : lte&.to_s]
|
161
|
+
]
|
162
|
+
key_conditions = key_condition_params
|
163
|
+
.reject { |(_, value)| value.nil? }
|
164
|
+
.map { |(operator, key_path)| Stately::Db::KeyCondition.new(operator: operator, key_path: key_path) }
|
139
165
|
req = Stately::Db::BeginListRequest.new(
|
140
166
|
store_id: @store_id,
|
141
167
|
key_path_prefix: String(prefix),
|
142
168
|
limit:,
|
143
169
|
sort_property:,
|
144
170
|
sort_direction:,
|
171
|
+
filter_conditions: item_types.map do |item_type|
|
172
|
+
Stately::Db::FilterCondition.new(item_type: item_type.respond_to?(:name) ? item_type.name.split("::").last : item_type)
|
173
|
+
end,
|
174
|
+
key_conditions: key_conditions,
|
145
175
|
allow_stale: @allow_stale,
|
146
176
|
schema_id: @schema::SCHEMA_ID,
|
147
177
|
schema_version_id: @schema::SCHEMA_VERSION_ID
|
@@ -334,6 +334,17 @@ module StatelyDB
|
|
334
334
|
# @param limit [Integer] the maximum number of items to return
|
335
335
|
# @param sort_property [String] the property to sort by
|
336
336
|
# @param sort_direction [Symbol] the direction to sort by (:ascending or :descending)
|
337
|
+
# @param item_types [Array<Class, String>] the item types to filter by. The returned
|
338
|
+
# items will be instances of one of these types.
|
339
|
+
# @param gt [StatelyDB::KeyPath | String] filters results to only include items with a key greater than the
|
340
|
+
# specified value based on lexicographic ordering.
|
341
|
+
# @param gte [StatelyDB::KeyPath | String] filters results to only include items with a key greater than or equal to the
|
342
|
+
# specified value based on lexicographic ordering.
|
343
|
+
# @param lt [StatelyDB::KeyPath | String] filters results to only include items with a key less than the
|
344
|
+
# specified value based on lexicographic ordering.
|
345
|
+
# @param lte [StatelyDB::KeyPath | String] filters results to only include items with a key less than or equal to the
|
346
|
+
# specified value based on lexicographic ordering.
|
347
|
+
|
337
348
|
# @return [Array(Array<StatelyDB::Item>, ::Stately::Db::ListToken)] the list of Items and the token
|
338
349
|
#
|
339
350
|
# Example:
|
@@ -344,19 +355,42 @@ module StatelyDB
|
|
344
355
|
def begin_list(prefix,
|
345
356
|
limit: 100,
|
346
357
|
sort_property: nil,
|
347
|
-
sort_direction: :ascending
|
358
|
+
sort_direction: :ascending,
|
359
|
+
item_types: [],
|
360
|
+
gt: nil,
|
361
|
+
gte: nil,
|
362
|
+
lt: nil,
|
363
|
+
lte: nil)
|
348
364
|
sort_direction = case sort_direction
|
349
365
|
when :ascending
|
350
366
|
0
|
351
367
|
else
|
352
368
|
1
|
353
369
|
end
|
370
|
+
key_condition_params = [
|
371
|
+
[Stately::Db::Operator::OPERATOR_GREATER_THAN, gt.is_a?(String) ? gt : gt&.to_s],
|
372
|
+
[Stately::Db::Operator::OPERATOR_GREATER_THAN_OR_EQUAL, gte.is_a?(String) ? gte : gte&.to_s],
|
373
|
+
[Stately::Db::Operator::OPERATOR_LESS_THAN, lt.is_a?(String) ? lt : lt&.to_s],
|
374
|
+
[Stately::Db::Operator::OPERATOR_LESS_THAN_OR_EQUAL, lte.is_a?(String) ? lte : lte&.to_s]
|
375
|
+
]
|
376
|
+
key_conditions = key_condition_params
|
377
|
+
.reject { |(_, value)| value.nil? }
|
378
|
+
.map do |(operator, key_path)|
|
379
|
+
Stately::Db::KeyCondition.new(operator: operator,
|
380
|
+
key_path: key_path)
|
381
|
+
end
|
354
382
|
req = Stately::Db::TransactionRequest.new(
|
355
383
|
begin_list: Stately::Db::TransactionBeginList.new(
|
356
384
|
key_path_prefix: String(prefix),
|
357
385
|
limit:,
|
358
386
|
sort_property:,
|
359
|
-
sort_direction
|
387
|
+
sort_direction:,
|
388
|
+
filter_conditions: item_types.map do |item_type|
|
389
|
+
Stately::Db::FilterCondition.new(
|
390
|
+
item_type: item_type.respond_to?(:name) ? item_type.name.split("::").last : item_type
|
391
|
+
)
|
392
|
+
end,
|
393
|
+
key_conditions: key_conditions
|
360
394
|
)
|
361
395
|
)
|
362
396
|
do_list_request_response(req)
|
data/lib/version.rb
ADDED
data/rbi/db/delete_pb.rbi
CHANGED
@@ -40,17 +40,17 @@ class Stately::Db::DeleteRequest
|
|
40
40
|
def clear_store_id
|
41
41
|
end
|
42
42
|
|
43
|
-
#
|
43
|
+
# key paths of items to delete.
|
44
44
|
sig { returns(T::Array[T.nilable(Stately::Db::DeleteItem)]) }
|
45
45
|
def deletes
|
46
46
|
end
|
47
47
|
|
48
|
-
#
|
48
|
+
# key paths of items to delete.
|
49
49
|
sig { params(value: ::Google::Protobuf::RepeatedField).void }
|
50
50
|
def deletes=(value)
|
51
51
|
end
|
52
52
|
|
53
|
-
#
|
53
|
+
# key paths of items to delete.
|
54
54
|
sig { void }
|
55
55
|
def clear_deletes
|
56
56
|
end
|
data/rbi/db/get_pb.rbi
CHANGED
@@ -42,17 +42,17 @@ class Stately::Db::GetRequest
|
|
42
42
|
def clear_store_id
|
43
43
|
end
|
44
44
|
|
45
|
-
#
|
45
|
+
# key paths to of each item to get.
|
46
46
|
sig { returns(T::Array[T.nilable(Stately::Db::GetItem)]) }
|
47
47
|
def gets
|
48
48
|
end
|
49
49
|
|
50
|
-
#
|
50
|
+
# key paths to of each item to get.
|
51
51
|
sig { params(value: ::Google::Protobuf::RepeatedField).void }
|
52
52
|
def gets=(value)
|
53
53
|
end
|
54
54
|
|
55
|
-
#
|
55
|
+
# key paths to of each item to get.
|
56
56
|
sig { void }
|
57
57
|
def clear_gets
|
58
58
|
end
|