statelydb 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1d7563d7f40d84bdc1ef3dacff41707ed1d915b638223d33b488ca4c7de531f
4
- data.tar.gz: dd682b92fbc100505e15820c5415acadc9defc6bc2f2d0dad5b5797deddbf24b
3
+ metadata.gz: acc7d4cbc70b66408fc0723cb627b291114ea531eabf57491d668bd4be9c6dc6
4
+ data.tar.gz: 4758fd8040faca40481b98aa713c12f711c353cbdfc2141e604227276da59e9c
5
5
  SHA512:
6
- metadata.gz: c0f27aa770fdf0c7b3386ac37862226cb4b5215766d265e47c82323b2157966e6ce0d87b5e4081d8d9dcd549f45cd0f6527203b0025b0e6c62ce0780c81dae74
7
- data.tar.gz: de86db0a2a0227e6bec231d11c378bffff42fa7911ccc0874bd3ed97fae7f73d0ac29ce55b31817f75bfa82c0b63daa79dabd28276a66e17e2748770450f6243
6
+ metadata.gz: 9338ba66b860a68ba965534743dc9f119c19d7db3196432f003db98d056a2ac33f4ce600064200b44e61d355750bc1c2ff1ac1fe378ac0618c5716aea19de8f0
7
+ data.tar.gz: 44c1c821cde2adc873cb223b3459744959dbe4ab625ddf9da76a9f47e7662cdcd028a6a471f0243fdefea30c419e1e8c8c28c251c776b66b8c8168675dbc27c9
data/lib/api/db/put_pb.rb CHANGED
@@ -7,7 +7,7 @@ require 'google/protobuf'
7
7
  require 'api/db/item_pb'
8
8
 
9
9
 
10
- descriptor_data = "\n\x0c\x64\x62/put.proto\x12\nstately.db\x1a\rdb/item.proto\"|\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\"U\n\x07PutItem\x12$\n\x04item\x18\x01 \x01(\x0b\x32\x10.stately.db.ItemR\x04item\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"
10
+ descriptor_data = "\n\x0c\x64\x62/put.proto\x12\nstately.db\x1a\rdb/item.proto\"|\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\"\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
12
  pool = Google::Protobuf::DescriptorPool.generated_pool
13
13
  pool.add_serialized_file(descriptor_data)
@@ -13,35 +13,27 @@ require_relative "../../error"
13
13
 
14
14
  LOGGER = Logger.new($stdout)
15
15
  LOGGER.level = Logger::WARN
16
- DEFAULT_GRANT_TYPE = "client_credentials"
17
16
 
18
17
  # A module for Stately Cloud auth code
19
18
  module StatelyDB
20
19
  module Common
21
20
  # A module for Stately Cloud auth code
22
21
  module Auth
23
- # Auth0TokenProvider is an implementation of the TokenProvider abstract base class
24
- # which vends tokens from auth0 with the given client_id and client_secret.
25
- # It will default to using the values of `STATELY_CLIENT_ID` and `STATELY_CLIENT_SECRET` if
26
- # no credentials are explicitly passed and will throw an error if none are found.
22
+ # AuthTokenProvider is an implementation of the TokenProvider abstract base class
23
+ # which vends tokens from the StatelyDB auth API.
24
+ # It will default to using the value of `STATELY_ACCESS_KEY` if
25
+ # no credentials are explicitly passed and will throw an error if no credentials are found.
27
26
  class AuthTokenProvider < TokenProvider
28
- # @param [String] origin The origin of the OAuth server
29
- # @param [String] audience The OAuth Audience for the token
30
- # @param [String] client_secret The StatelyDB client secret credential
31
- # @param [String] client_id The StatelyDB client ID credential
27
+ # @param [String] origin The origin of the auth server
32
28
  # @param [String] access_key The StatelyDB access key credential
33
29
  # @param [Float] base_retry_backoff_secs The base retry backoff in seconds
34
30
  def initialize(
35
- origin: "https://oauth.stately.cloud",
36
- audience: "api.stately.cloud",
37
- client_secret: ENV.fetch("STATELY_CLIENT_SECRET", nil),
38
- client_id: ENV.fetch("STATELY_CLIENT_ID", nil),
31
+ origin: "https://api.stately.cloud",
39
32
  access_key: ENV.fetch("STATELY_ACCESS_KEY", nil),
40
33
  base_retry_backoff_secs: 1
41
34
  )
42
35
  super()
43
- @actor = Async::Actor.new(Actor.new(origin: origin, audience: audience,
44
- client_secret: client_secret, client_id: client_id, access_key: access_key,
36
+ @actor = Async::Actor.new(Actor.new(origin: origin, access_key: access_key,
45
37
  base_retry_backoff_secs: base_retry_backoff_secs))
46
38
  # this initialization cannot happen in the constructor because it is async and must run on the event loop
47
39
  # which is not available in the constructor
@@ -64,37 +56,26 @@ module StatelyDB
64
56
  # This is designed to be used with Async::Actor and run on a dedicated thread.
65
57
  class Actor
66
58
  # @param [String] origin The origin of the OAuth server
67
- # @param [String] audience The OAuth Audience for the token
68
- # @param [String] client_secret The StatelyDB client secret credential
69
- # @param [String] client_id The StatelyDB client ID credential
70
59
  # @param [String] access_key The StatelyDB access key credential
71
60
  # @param [Float] base_retry_backoff_secs The base retry backoff in seconds
72
- def initialize(
73
- origin:,
74
- audience:,
75
- client_secret:,
76
- client_id:,
77
- access_key:,
78
- base_retry_backoff_secs:
79
- )
61
+ def initialize(origin:, access_key:, base_retry_backoff_secs:)
80
62
  super()
81
63
 
82
- @token_fetcher = nil
83
- if !access_key.nil?
84
- @token_fetcher = StatelyDB::Common::Auth::StatelyAccessTokenFetcher.new(
85
- origin: origin, access_key: access_key, base_retry_backoff_secs: base_retry_backoff_secs
64
+ if access_key.nil?
65
+ raise StatelyDB::Error.new(
66
+ "Unable to find an access key in the STATELY_ACCESS_KEY " \
67
+ "environment variable. Either pass your credentials in " \
68
+ "the options when creating a client or set this environment variable.",
69
+ code: GRPC::Core::StatusCodes::UNAUTHENTICATED,
70
+ stately_code: "Unauthenticated"
86
71
  )
87
- elsif !client_secret.nil? && !client_id.nil?
88
- @token_fetcher = StatelyDB::Common::Auth::Auth0TokenFetcher.new(origin: origin, audience: audience,
89
- client_secret: client_secret, client_id: client_id)
90
- else
91
- raise StatelyDB::Error.new("unable to find client credentials in STATELY_ACCESS_KEY or STATELY_CLIENT_ID and " \
92
- "STATELY_CLIENT_SECRET environment variables. Either pass your credentials in " \
93
- "explicitly or set these environment variables",
94
- code: GRPC::Core::StatusCodes::UNAUTHENTICATED,
95
- stately_code: "Unauthenticated")
96
72
  end
97
73
 
74
+ @token_fetcher = StatelyDB::Common::Auth::StatelyAccessTokenFetcher.new(
75
+ origin: origin,
76
+ access_key: access_key,
77
+ base_retry_backoff_secs: base_retry_backoff_secs
78
+ )
98
79
  @token_state = nil
99
80
  @pending_refresh = nil
100
81
  end
@@ -37,42 +37,6 @@ module StatelyDB
37
37
  end
38
38
  end
39
39
 
40
- # Auth0TokenFetcher is a TokenFetcher that fetches tokens from an Auth0 server
41
- class Auth0TokenFetcher < TokenFetcher
42
- # @param [String] origin The origin of the OAuth server
43
- # @param [String] audience The OAuth Audience for the token
44
- # @param [String] client_secret The StatelyDB client secret credential
45
- # @param [String] client_id The StatelyDB client ID credential
46
- def initialize(origin:, audience:, client_secret:, client_id:)
47
- super()
48
- @client = Async::HTTP::Client.new(Async::HTTP::Endpoint.parse(origin))
49
- @audience = audience
50
- @client_secret = client_secret
51
- @client_id = client_id
52
- end
53
-
54
- # Fetch a new token from auth0
55
- # @return [TokenResult] The fetched TokenResult
56
- def fetch
57
- headers = [["content-type", "application/json"]]
58
- body = JSON.dump({ "client_id" => @client_id, client_secret: @client_secret, audience: @audience,
59
- grant_type: DEFAULT_GRANT_TYPE })
60
- Sync do
61
- response = @client.post("/oauth/token", headers, body)
62
- raise "Auth request failed" if response.status != 200
63
-
64
- resp_data = JSON.parse(response.read)
65
- TokenResult.new(token: resp_data["access_token"], expires_in_secs: resp_data["expires_in"])
66
- ensure
67
- response&.close
68
- end
69
- end
70
-
71
- def close
72
- @client&.close
73
- end
74
- end
75
-
76
40
  # StatelyAccessTokenFetcher is a TokenFetcher that fetches tokens from the StatelyDB API
77
41
  class StatelyAccessTokenFetcher < TokenFetcher
78
42
  NON_RETRYABLE_ERRORS = [
data/lib/error.rb CHANGED
@@ -41,9 +41,12 @@ module StatelyDB
41
41
  raw_detail = status.details[0]
42
42
  if raw_detail.type_url == "type.googleapis.com/stately.errors.StatelyErrorDetails"
43
43
  error_details = Stately::Errors::StatelyErrorDetails.decode(raw_detail.value)
44
+ message = error_details.message
45
+ rid = error.metadata["st-rid"]
46
+ message = "#{message} (Request ID: #{rid})" unless rid.nil?
44
47
  upstream_cause = error_details.upstream_cause.empty? ? nil : StandardError.new(error_details.upstream_cause) # rubocop:disable Metrics/BlockNesting
45
- return new(error_details.message, code: error.code, stately_code: error_details.stately_code,
46
- cause: upstream_cause)
48
+ return new(message, code: error.code, stately_code: error_details.stately_code,
49
+ cause: upstream_cause)
47
50
  end
48
51
  end
49
52
  end
data/lib/statelydb.rb CHANGED
@@ -188,12 +188,20 @@ module StatelyDB
188
188
  # `initialValue` field in its key, that initial value will automatically
189
189
  # be chosen not to conflict with existing items, so this condition only
190
190
  # applies to key paths that do not contain the `initialValue` field.
191
+ # @param overwrite_metadata_timestamps [Boolean] If set to true, the server will
192
+ # set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the
193
+ # current values in this item (assuming you've mapped them to a field using
194
+ # `fromMetadata`). Without this, those fields are always ignored and the
195
+ # server sets them to the appropriate times. This option can be useful when
196
+ # migrating data from another system.
191
197
  # @return [StatelyDB::Item] the item that was stored
192
198
  #
193
199
  # @example client.data.put(my_item)
194
200
  # @example client.data.put(my_item, must_not_exist: true)
195
- def put(item, must_not_exist: false)
196
- resp = put_batch({ item:, must_not_exist: })
201
+ def put(item,
202
+ must_not_exist: false,
203
+ overwrite_metadata_timestamps: false)
204
+ resp = put_batch({ item:, must_not_exist:, overwrite_metadata_timestamps: })
197
205
 
198
206
  # Always return a single Item.
199
207
  resp.first
@@ -215,6 +223,7 @@ module StatelyDB
215
223
  item = input[:item]
216
224
  Stately::Db::PutItem.new(
217
225
  item: item.send("marshal_stately"),
226
+ overwrite_metadata_timestamps: input[:overwrite_metadata_timestamps],
218
227
  must_not_exist: input[:must_not_exist]
219
228
  )
220
229
  else
@@ -233,6 +233,12 @@ module StatelyDB
233
233
  # `initialValue` field in its key, that initial value will automatically
234
234
  # be chosen not to conflict with existing items, so this condition only
235
235
  # applies to key paths that do not contain the `initialValue` field.
236
+ # @param overwrite_metadata_timestamps [Boolean] If set to true, the server will
237
+ # set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the
238
+ # current values in this item (assuming you've mapped them to a field using
239
+ # `fromMetadata`). Without this, those fields are always ignored and the
240
+ # server sets them to the appropriate times. This option can be useful when
241
+ # migrating data from another system.
236
242
  # @return [String, Integer] the id of the item
237
243
  #
238
244
  # @example
@@ -242,8 +248,10 @@ module StatelyDB
242
248
  # results.puts.each do |result|
243
249
  # puts result.key_path
244
250
  # end
245
- def put(item, must_not_exist: false)
246
- resp = put_batch({ item:, must_not_exist: })
251
+ def put(item,
252
+ must_not_exist: false,
253
+ overwrite_metadata_timestamps: false)
254
+ resp = put_batch({ item:, must_not_exist:, overwrite_metadata_timestamps: })
247
255
  resp.first
248
256
  end
249
257
 
@@ -269,6 +277,7 @@ module StatelyDB
269
277
  item = input[:item]
270
278
  Stately::Db::PutItem.new(
271
279
  item: item.send("marshal_stately"),
280
+ overwrite_metadata_timestamps: input[:overwrite_metadata_timestamps],
272
281
  must_not_exist: input[:must_not_exist]
273
282
  )
274
283
  else
data/sig/statelydb.rbi CHANGED
@@ -313,6 +313,8 @@ module StatelyDB
313
313
  #
314
314
  # _@param_ `must_not_exist` — A condition that indicates this item must not already exist at any of its key paths. If there is already an item at one of those paths, the Put operation will fail with a "ConditionalCheckFailed" error. Note that if the item has an `initialValue` field in its key, that initial value will automatically be chosen not to conflict with existing items, so this condition only applies to key paths that do not contain the `initialValue` field.
315
315
  #
316
+ # _@param_ `overwrite_metadata_timestamps` — If set to true, the server will set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the current values in this item (assuming you've mapped them to a field using `fromMetadata`). Without this, those fields are always ignored and the server sets them to the appropriate times. This option can be useful when migrating data from another system.
317
+ #
316
318
  # _@return_ — the item that was stored
317
319
  #
318
320
  # client.data.put(my_item)
@@ -322,8 +324,8 @@ module StatelyDB
322
324
  # client.data.put(my_item, must_not_exist: true)
323
325
  # ```ruby
324
326
  # ```
325
- sig { params(item: StatelyDB::Item, must_not_exist: T::Boolean).returns(StatelyDB::Item) }
326
- def put(item, must_not_exist: false); end
327
+ sig { params(item: StatelyDB::Item, must_not_exist: T::Boolean, overwrite_metadata_timestamps: T::Boolean).returns(StatelyDB::Item) }
328
+ def put(item, must_not_exist: false, overwrite_metadata_timestamps: false); end
327
329
 
328
330
  # Put a batch of up to 50 Items into a StatelyDB Store.
329
331
  #
@@ -605,35 +607,6 @@ module StatelyDB
605
607
  def close; end
606
608
  end
607
609
 
608
- # Auth0TokenFetcher is a TokenFetcher that fetches tokens from an Auth0 server
609
- class Auth0TokenFetcher < StatelyDB::Common::Auth::TokenFetcher
610
- # _@param_ `origin` — The origin of the OAuth server
611
- #
612
- # _@param_ `audience` — The OAuth Audience for the token
613
- #
614
- # _@param_ `client_secret` — The StatelyDB client secret credential
615
- #
616
- # _@param_ `client_id` — The StatelyDB client ID credential
617
- sig do
618
- params(
619
- origin: String,
620
- audience: String,
621
- client_secret: String,
622
- client_id: String
623
- ).void
624
- end
625
- def initialize(origin:, audience:, client_secret:, client_id:); end
626
-
627
- # Fetch a new token from auth0
628
- #
629
- # _@return_ — The fetched TokenResult
630
- sig { returns(TokenResult) }
631
- def fetch; end
632
-
633
- sig { returns(T.untyped) }
634
- def close; end
635
- end
636
-
637
610
  # StatelyAccessTokenFetcher is a TokenFetcher that fetches tokens from the StatelyDB API
638
611
  class StatelyAccessTokenFetcher < StatelyDB::Common::Auth::TokenFetcher
639
612
  NON_RETRYABLE_ERRORS = T.let([
@@ -687,33 +660,18 @@ module StatelyDB
687
660
  def close; end
688
661
  end
689
662
 
690
- # Auth0TokenProvider is an implementation of the TokenProvider abstract base class
691
- # which vends tokens from auth0 with the given client_id and client_secret.
692
- # It will default to using the values of `STATELY_CLIENT_ID` and `STATELY_CLIENT_SECRET` if
693
- # no credentials are explicitly passed and will throw an error if none are found.
663
+ # AuthTokenProvider is an implementation of the TokenProvider abstract base class
664
+ # which vends tokens from the StatelyDB auth API.
665
+ # It will default to using the value of `STATELY_ACCESS_KEY` if
666
+ # no credentials are explicitly passed and will throw an error if no credentials are found.
694
667
  class AuthTokenProvider < StatelyDB::Common::Auth::TokenProvider
695
- # _@param_ `origin` — The origin of the OAuth server
696
- #
697
- # _@param_ `audience` — The OAuth Audience for the token
698
- #
699
- # _@param_ `client_secret` — The StatelyDB client secret credential
700
- #
701
- # _@param_ `client_id` — The StatelyDB client ID credential
668
+ # _@param_ `origin` — The origin of the auth server
702
669
  #
703
670
  # _@param_ `access_key` — The StatelyDB access key credential
704
671
  #
705
672
  # _@param_ `base_retry_backoff_secs` — The base retry backoff in seconds
706
- sig do
707
- params(
708
- origin: String,
709
- audience: String,
710
- client_secret: String,
711
- client_id: String,
712
- access_key: String,
713
- base_retry_backoff_secs: Float
714
- ).void
715
- end
716
- def initialize(origin: "https://oauth.stately.cloud", audience: "api.stately.cloud", client_secret: ENV.fetch("STATELY_CLIENT_SECRET", nil), client_id: ENV.fetch("STATELY_CLIENT_ID", nil), access_key: ENV.fetch("STATELY_ACCESS_KEY", nil), base_retry_backoff_secs: 1); end
673
+ sig { params(origin: String, access_key: String, base_retry_backoff_secs: Float).void }
674
+ def initialize(origin: "https://api.stately.cloud", access_key: ENV.fetch("STATELY_ACCESS_KEY", nil), base_retry_backoff_secs: 1); end
717
675
 
718
676
  # Close the token provider and kill any background operations
719
677
  # This just invokes the close method on the actor which should do the cleanup
@@ -731,26 +689,11 @@ module StatelyDB
731
689
  class Actor
732
690
  # _@param_ `origin` — The origin of the OAuth server
733
691
  #
734
- # _@param_ `audience` — The OAuth Audience for the token
735
- #
736
- # _@param_ `client_secret` — The StatelyDB client secret credential
737
- #
738
- # _@param_ `client_id` — The StatelyDB client ID credential
739
- #
740
692
  # _@param_ `access_key` — The StatelyDB access key credential
741
693
  #
742
694
  # _@param_ `base_retry_backoff_secs` — The base retry backoff in seconds
743
- sig do
744
- params(
745
- origin: String,
746
- audience: String,
747
- client_secret: String,
748
- client_id: String,
749
- access_key: String,
750
- base_retry_backoff_secs: Float
751
- ).void
752
- end
753
- def initialize(origin:, audience:, client_secret:, client_id:, access_key:, base_retry_backoff_secs:); end
695
+ sig { params(origin: String, access_key: String, base_retry_backoff_secs: Float).void }
696
+ def initialize(origin:, access_key:, base_retry_backoff_secs:); end
754
697
 
755
698
  # Initialize the actor. This runs on the actor thread which means
756
699
  # we can dispatch async operations here.
@@ -1000,6 +943,8 @@ module StatelyDB
1000
943
  #
1001
944
  # _@param_ `must_not_exist` — A condition that indicates this item must not already exist at any of its key paths. If there is already an item at one of those paths, the Put operation will fail with a "ConditionalCheckFailed" error. Note that if the item has an `initialValue` field in its key, that initial value will automatically be chosen not to conflict with existing items, so this condition only applies to key paths that do not contain the `initialValue` field.
1002
945
  #
946
+ # _@param_ `overwrite_metadata_timestamps` — If set to true, the server will set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the current values in this item (assuming you've mapped them to a field using `fromMetadata`). Without this, those fields are always ignored and the server sets them to the appropriate times. This option can be useful when migrating data from another system.
947
+ #
1003
948
  # _@return_ — the id of the item
1004
949
  #
1005
950
  # ```ruby
@@ -1007,8 +952,8 @@ module StatelyDB
1007
952
  # txn.put(my_item)
1008
953
  # end
1009
954
  # ```
1010
- sig { params(item: StatelyDB::Item, must_not_exist: T::Boolean).returns(T.any(String, Integer)) }
1011
- def put(item, must_not_exist: false); end
955
+ sig { params(item: StatelyDB::Item, must_not_exist: T::Boolean, overwrite_metadata_timestamps: T::Boolean).returns(T.any(String, Integer)) }
956
+ def put(item, must_not_exist: false, overwrite_metadata_timestamps: false); end
1012
957
 
1013
958
  # Put a batch of up to 50 Items into a StatelyDB Store. Results are not
1014
959
  # returned until the transaction is committed and will be available in the
data/sig/statelydb.rbs CHANGED
@@ -267,6 +267,8 @@ module StatelyDB
267
267
  #
268
268
  # _@param_ `must_not_exist` — A condition that indicates this item must not already exist at any of its key paths. If there is already an item at one of those paths, the Put operation will fail with a "ConditionalCheckFailed" error. Note that if the item has an `initialValue` field in its key, that initial value will automatically be chosen not to conflict with existing items, so this condition only applies to key paths that do not contain the `initialValue` field.
269
269
  #
270
+ # _@param_ `overwrite_metadata_timestamps` — If set to true, the server will set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the current values in this item (assuming you've mapped them to a field using `fromMetadata`). Without this, those fields are always ignored and the server sets them to the appropriate times. This option can be useful when migrating data from another system.
271
+ #
270
272
  # _@return_ — the item that was stored
271
273
  #
272
274
  # client.data.put(my_item)
@@ -276,7 +278,7 @@ module StatelyDB
276
278
  # client.data.put(my_item, must_not_exist: true)
277
279
  # ```ruby
278
280
  # ```
279
- def put: (StatelyDB::Item item, ?must_not_exist: bool) -> StatelyDB::Item
281
+ def put: (StatelyDB::Item item, ?must_not_exist: bool, ?overwrite_metadata_timestamps: bool) -> StatelyDB::Item
280
282
 
281
283
  # Put a batch of up to 50 Items into a StatelyDB Store.
282
284
  #
@@ -524,30 +526,6 @@ module StatelyDB
524
526
  def close: () -> untyped
525
527
  end
526
528
 
527
- # Auth0TokenFetcher is a TokenFetcher that fetches tokens from an Auth0 server
528
- class Auth0TokenFetcher < StatelyDB::Common::Auth::TokenFetcher
529
- # _@param_ `origin` — The origin of the OAuth server
530
- #
531
- # _@param_ `audience` — The OAuth Audience for the token
532
- #
533
- # _@param_ `client_secret` — The StatelyDB client secret credential
534
- #
535
- # _@param_ `client_id` — The StatelyDB client ID credential
536
- def initialize: (
537
- origin: String,
538
- audience: String,
539
- client_secret: String,
540
- client_id: String
541
- ) -> void
542
-
543
- # Fetch a new token from auth0
544
- #
545
- # _@return_ — The fetched TokenResult
546
- def fetch: () -> TokenResult
547
-
548
- def close: () -> untyped
549
- end
550
-
551
529
  # StatelyAccessTokenFetcher is a TokenFetcher that fetches tokens from the StatelyDB API
552
530
  class StatelyAccessTokenFetcher < StatelyDB::Common::Auth::TokenFetcher
553
531
  NON_RETRYABLE_ERRORS: untyped
@@ -589,30 +567,17 @@ module StatelyDB
589
567
  def close: () -> untyped
590
568
  end
591
569
 
592
- # Auth0TokenProvider is an implementation of the TokenProvider abstract base class
593
- # which vends tokens from auth0 with the given client_id and client_secret.
594
- # It will default to using the values of `STATELY_CLIENT_ID` and `STATELY_CLIENT_SECRET` if
595
- # no credentials are explicitly passed and will throw an error if none are found.
570
+ # AuthTokenProvider is an implementation of the TokenProvider abstract base class
571
+ # which vends tokens from the StatelyDB auth API.
572
+ # It will default to using the value of `STATELY_ACCESS_KEY` if
573
+ # no credentials are explicitly passed and will throw an error if no credentials are found.
596
574
  class AuthTokenProvider < StatelyDB::Common::Auth::TokenProvider
597
- # _@param_ `origin` — The origin of the OAuth server
598
- #
599
- # _@param_ `audience` — The OAuth Audience for the token
600
- #
601
- # _@param_ `client_secret` — The StatelyDB client secret credential
602
- #
603
- # _@param_ `client_id` — The StatelyDB client ID credential
575
+ # _@param_ `origin` — The origin of the auth server
604
576
  #
605
577
  # _@param_ `access_key` — The StatelyDB access key credential
606
578
  #
607
579
  # _@param_ `base_retry_backoff_secs` — The base retry backoff in seconds
608
- def initialize: (
609
- ?origin: String,
610
- ?audience: String,
611
- ?client_secret: String,
612
- ?client_id: String,
613
- ?access_key: String,
614
- ?base_retry_backoff_secs: Float
615
- ) -> void
580
+ def initialize: (?origin: String, ?access_key: String, ?base_retry_backoff_secs: Float) -> void
616
581
 
617
582
  # Close the token provider and kill any background operations
618
583
  # This just invokes the close method on the actor which should do the cleanup
@@ -628,23 +593,10 @@ module StatelyDB
628
593
  class Actor
629
594
  # _@param_ `origin` — The origin of the OAuth server
630
595
  #
631
- # _@param_ `audience` — The OAuth Audience for the token
632
- #
633
- # _@param_ `client_secret` — The StatelyDB client secret credential
634
- #
635
- # _@param_ `client_id` — The StatelyDB client ID credential
636
- #
637
596
  # _@param_ `access_key` — The StatelyDB access key credential
638
597
  #
639
598
  # _@param_ `base_retry_backoff_secs` — The base retry backoff in seconds
640
- def initialize: (
641
- origin: String,
642
- audience: String,
643
- client_secret: String,
644
- client_id: String,
645
- access_key: String,
646
- base_retry_backoff_secs: Float
647
- ) -> void
599
+ def initialize: (origin: String, access_key: String, base_retry_backoff_secs: Float) -> void
648
600
 
649
601
  # Initialize the actor. This runs on the actor thread which means
650
602
  # we can dispatch async operations here.
@@ -858,6 +810,8 @@ module StatelyDB
858
810
  #
859
811
  # _@param_ `must_not_exist` — A condition that indicates this item must not already exist at any of its key paths. If there is already an item at one of those paths, the Put operation will fail with a "ConditionalCheckFailed" error. Note that if the item has an `initialValue` field in its key, that initial value will automatically be chosen not to conflict with existing items, so this condition only applies to key paths that do not contain the `initialValue` field.
860
812
  #
813
+ # _@param_ `overwrite_metadata_timestamps` — If set to true, the server will set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the current values in this item (assuming you've mapped them to a field using `fromMetadata`). Without this, those fields are always ignored and the server sets them to the appropriate times. This option can be useful when migrating data from another system.
814
+ #
861
815
  # _@return_ — the id of the item
862
816
  #
863
817
  # ```ruby
@@ -865,7 +819,7 @@ module StatelyDB
865
819
  # txn.put(my_item)
866
820
  # end
867
821
  # ```
868
- def put: (StatelyDB::Item item, ?must_not_exist: bool) -> (String | Integer)
822
+ def put: (StatelyDB::Item item, ?must_not_exist: bool, ?overwrite_metadata_timestamps: bool) -> (String | Integer)
869
823
 
870
824
  # Put a batch of up to 50 Items into a StatelyDB Store. Results are not
871
825
  # returned until the transaction is committed and will be available in the
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.15.0
4
+ version: 0.16.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: 2024-12-13 00:00:00.000000000 Z
11
+ date: 2024-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async