google-cloud-firestore 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/README.md +8 -8
  4. data/lib/google-cloud-firestore.rb +1 -1
  5. data/lib/google/cloud/firestore.rb +46 -0
  6. data/lib/google/cloud/firestore/batch.rb +1 -1
  7. data/lib/google/cloud/firestore/client.rb +18 -13
  8. data/lib/google/cloud/firestore/convert.rb +78 -35
  9. data/lib/google/cloud/firestore/credentials.rb +2 -12
  10. data/lib/google/cloud/firestore/document_change.rb +124 -0
  11. data/lib/google/cloud/firestore/document_listener.rb +125 -0
  12. data/lib/google/cloud/firestore/document_reference.rb +35 -0
  13. data/lib/google/cloud/firestore/document_snapshot.rb +91 -9
  14. data/lib/google/cloud/firestore/field_path.rb +23 -13
  15. data/lib/google/cloud/firestore/query.rb +513 -69
  16. data/lib/google/cloud/firestore/query_listener.rb +118 -0
  17. data/lib/google/cloud/firestore/query_snapshot.rb +121 -0
  18. data/lib/google/cloud/firestore/service.rb +8 -0
  19. data/lib/google/cloud/firestore/transaction.rb +2 -2
  20. data/lib/google/cloud/firestore/v1beta1.rb +62 -37
  21. data/lib/google/cloud/firestore/v1beta1/credentials.rb +41 -0
  22. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/common.rb +1 -1
  23. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/document.rb +5 -4
  24. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/firestore.rb +1 -12
  25. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/query.rb +4 -1
  26. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/write.rb +37 -8
  27. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/any.rb +1 -1
  28. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/empty.rb +28 -0
  29. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/timestamp.rb +1 -1
  30. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/wrappers.rb +1 -1
  31. data/lib/google/cloud/firestore/v1beta1/doc/google/rpc/status.rb +1 -1
  32. data/lib/google/cloud/firestore/v1beta1/firestore_client.rb +124 -56
  33. data/lib/google/cloud/firestore/v1beta1/firestore_client_config.json +2 -2
  34. data/lib/google/cloud/firestore/version.rb +1 -1
  35. data/lib/google/cloud/firestore/watch/enumerator_queue.rb +47 -0
  36. data/lib/google/cloud/firestore/watch/inventory.rb +280 -0
  37. data/lib/google/cloud/firestore/watch/listener.rb +298 -0
  38. data/lib/google/cloud/firestore/watch/order.rb +98 -0
  39. data/lib/google/firestore/v1beta1/firestore_services_pb.rb +2 -4
  40. data/lib/google/firestore/v1beta1/query_pb.rb +1 -0
  41. data/lib/google/firestore/v1beta1/write_pb.rb +2 -0
  42. metadata +40 -3
  43. data/lib/google/cloud/firestore/v1beta1/doc/overview.rb +0 -53
@@ -0,0 +1,98 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ require "google/cloud/firestore/v1beta1"
17
+ require "google/cloud/firestore/convert"
18
+ require "google/cloud/firestore/document_reference"
19
+ require "google/cloud/firestore/document_snapshot"
20
+ require "google/cloud/firestore/document_change"
21
+ require "google/cloud/firestore/query_snapshot"
22
+ require "rbtree"
23
+
24
+ module Google
25
+ module Cloud
26
+ module Firestore
27
+ ##
28
+ # @private
29
+ module Watch
30
+ # @private
31
+ module Order
32
+ module ClassMethods
33
+ def compare_field_values a_value, b_value
34
+ field_comparison(a_value) <=> field_comparison(b_value)
35
+ end
36
+
37
+ def field_comparison value
38
+ [field_type(value), field_value(value)]
39
+ end
40
+
41
+ def field_type value
42
+ return 0 if value.nil?
43
+ return 1 if value == false
44
+ return 1 if value == true
45
+ # The backend ordering semantics treats NaN and Numbers as the
46
+ # same type, and then internally orders NaNs before Numbers.
47
+ # Ruby's Float::NAN cannot be compared, similar to nil, so we need
48
+ # to use a stand in value instead. Therefore the desired sorting
49
+ # is achieved by separating NaN and Number types. This is an
50
+ # intentional divergence from type order that is used in the
51
+ # backend and in the other SDKs.
52
+ # (And because Ruby has to be special.)
53
+ return 2 if value.respond_to?(:nan?) && value.nan?
54
+ return 3 if value.is_a? Numeric
55
+ return 4 if value.is_a? Time
56
+ return 5 if value.is_a? String
57
+ return 6 if value.is_a? StringIO
58
+ return 7 if value.is_a? DocumentReference
59
+ return 9 if value.is_a? Array
60
+ if value.is_a? Hash
61
+ return 8 if Convert.hash_is_geo_point? value
62
+ return 10
63
+ end
64
+
65
+ raise "Can't determine field type for #{value.class}"
66
+ end
67
+
68
+ def field_value value
69
+ # nil can't be compared, so use 0 as a stand in.
70
+ return 0 if value.nil?
71
+ return 0 if value == false
72
+ return 1 if value == true
73
+ # NaN can't be compared, so use 0 as a stand in.
74
+ return 0 if value.respond_to?(:nan?) && value.nan?
75
+ return value if value.is_a? Numeric
76
+ return value if value.is_a? Time
77
+ return value if value.is_a? String
78
+ return value.string if value.is_a? StringIO
79
+ if value.is_a? DocumentReference
80
+ return value.path.split("/".freeze)
81
+ end
82
+ return value.map { |v| field_comparison(v) } if value.is_a? Array
83
+ if value.is_a? Hash
84
+ geo_pairs = Convert.hash_is_geo_point? value
85
+ return geo_pairs.map(&:last) if geo_pairs
86
+ return value.sort.map { |k, v| [k, field_comparison(v)] }
87
+ end
88
+
89
+ raise "Can't determine field value for #{value}"
90
+ end
91
+ end
92
+
93
+ extend ClassMethods
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -1,13 +1,13 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # Source: google/firestore/v1beta1/firestore.proto for package 'google.firestore.v1beta1'
3
3
  # Original file comments:
4
- # Copyright 2017 Google Inc.
4
+ # Copyright 2018 Google LLC
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # https://www.apache.org/licenses/LICENSE-2.0
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -23,8 +23,6 @@ module Google
23
23
  module Firestore
24
24
  module V1beta1
25
25
  module Firestore
26
- # Specification of the Firestore API.
27
- #
28
26
  # The Cloud Firestore service.
29
27
  #
30
28
  # This service exposes several types of comparable timestamps:
@@ -48,6 +48,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
48
48
  value :GREATER_THAN, 3
49
49
  value :GREATER_THAN_OR_EQUAL, 4
50
50
  value :EQUAL, 5
51
+ value :ARRAY_CONTAINS, 7
51
52
  end
52
53
  add_message "google.firestore.v1beta1.StructuredQuery.UnaryFilter" do
53
54
  optional :op, :enum, 1, "google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator"
@@ -25,6 +25,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
25
25
  optional :field_path, :string, 1
26
26
  oneof :transform_type do
27
27
  optional :set_to_server_value, :enum, 2, "google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue"
28
+ optional :append_missing_elements, :message, 6, "google.firestore.v1beta1.ArrayValue"
29
+ optional :remove_all_from_array, :message, 7, "google.firestore.v1beta1.ArrayValue"
28
30
  end
29
31
  end
30
32
  add_enum "google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-firestore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-05 00:00:00.000000000 Z
11
+ date: 2018-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-core
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rbtree
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.4.2
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: minitest
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: '1.1'
139
+ - !ruby/object:Gem::Dependency
140
+ name: redcarpet
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.0'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: rubocop
127
155
  requirement: !ruby/object:Gem::Requirement
@@ -196,28 +224,37 @@ files:
196
224
  - lib/google/cloud/firestore/commit_response.rb
197
225
  - lib/google/cloud/firestore/convert.rb
198
226
  - lib/google/cloud/firestore/credentials.rb
227
+ - lib/google/cloud/firestore/document_change.rb
228
+ - lib/google/cloud/firestore/document_listener.rb
199
229
  - lib/google/cloud/firestore/document_reference.rb
200
230
  - lib/google/cloud/firestore/document_snapshot.rb
201
231
  - lib/google/cloud/firestore/field_path.rb
202
232
  - lib/google/cloud/firestore/field_value.rb
203
233
  - lib/google/cloud/firestore/generate.rb
204
234
  - lib/google/cloud/firestore/query.rb
235
+ - lib/google/cloud/firestore/query_listener.rb
236
+ - lib/google/cloud/firestore/query_snapshot.rb
205
237
  - lib/google/cloud/firestore/service.rb
206
238
  - lib/google/cloud/firestore/transaction.rb
207
239
  - lib/google/cloud/firestore/v1beta1.rb
240
+ - lib/google/cloud/firestore/v1beta1/credentials.rb
208
241
  - lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/common.rb
209
242
  - lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/document.rb
210
243
  - lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/firestore.rb
211
244
  - lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/query.rb
212
245
  - lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/write.rb
213
246
  - lib/google/cloud/firestore/v1beta1/doc/google/protobuf/any.rb
247
+ - lib/google/cloud/firestore/v1beta1/doc/google/protobuf/empty.rb
214
248
  - lib/google/cloud/firestore/v1beta1/doc/google/protobuf/timestamp.rb
215
249
  - lib/google/cloud/firestore/v1beta1/doc/google/protobuf/wrappers.rb
216
250
  - lib/google/cloud/firestore/v1beta1/doc/google/rpc/status.rb
217
- - lib/google/cloud/firestore/v1beta1/doc/overview.rb
218
251
  - lib/google/cloud/firestore/v1beta1/firestore_client.rb
219
252
  - lib/google/cloud/firestore/v1beta1/firestore_client_config.json
220
253
  - lib/google/cloud/firestore/version.rb
254
+ - lib/google/cloud/firestore/watch/enumerator_queue.rb
255
+ - lib/google/cloud/firestore/watch/inventory.rb
256
+ - lib/google/cloud/firestore/watch/listener.rb
257
+ - lib/google/cloud/firestore/watch/order.rb
221
258
  - lib/google/firestore/v1beta1/common_pb.rb
222
259
  - lib/google/firestore/v1beta1/document_pb.rb
223
260
  - lib/google/firestore/v1beta1/firestore_pb.rb
@@ -1,53 +0,0 @@
1
- # Copyright 2017 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- module Google
16
- module Cloud
17
- # rubocop:disable LineLength
18
-
19
- ##
20
- # # Ruby Client for Google Cloud Firestore API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
- #
22
- # [Google Cloud Firestore API][Product Documentation]:
23
- #
24
- # - [Product Documentation][]
25
- #
26
- # ## Quick Start
27
- # In order to use this library, you first need to go through the following
28
- # steps:
29
- #
30
- # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
31
- # 2. [Enable the Google Cloud Firestore API.](https://console.cloud.google.com/apis/api/firestore)
32
- # 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
33
- #
34
- # ### Installation
35
- # ```
36
- # $ gem install google-cloud-firestore
37
- # ```
38
- #
39
- # ### Next Steps
40
- # - Read the [Google Cloud Firestore API Product documentation][Product Documentation]
41
- # to learn more about the product and see How-to Guides.
42
- # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
43
- # to see the full list of Cloud APIs that we cover.
44
- #
45
- # [Product Documentation]: https://cloud.google.com/firestore
46
- #
47
- #
48
- module Firestore
49
- module V1beta1
50
- end
51
- end
52
- end
53
- end