elasticgraph-support 0.19.1.1 → 0.19.2.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/LICENSE.txt +1 -1
- data/lib/elastic_graph/constants.rb +1 -1
- data/lib/elastic_graph/errors.rb +4 -1
- data/lib/elastic_graph/support/faraday_middleware/msearch_using_get_instead_of_post.rb +1 -1
- data/lib/elastic_graph/support/faraday_middleware/support_timeouts.rb +1 -1
- data/lib/elastic_graph/support/from_yaml_file.rb +1 -1
- data/lib/elastic_graph/support/graphql_formatter.rb +1 -1
- data/lib/elastic_graph/support/hash_util.rb +60 -29
- data/lib/elastic_graph/support/logger.rb +1 -1
- data/lib/elastic_graph/support/memoizable_data.rb +1 -1
- data/lib/elastic_graph/support/monotonic_clock.rb +1 -1
- data/lib/elastic_graph/support/threading.rb +1 -1
- data/lib/elastic_graph/support/time_set.rb +1 -1
- data/lib/elastic_graph/support/time_util.rb +1 -1
- data/lib/elastic_graph/support/untyped_encoder.rb +1 -1
- data/lib/elastic_graph/version.rb +2 -2
- metadata +20 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a14d36c34bf951d94568e37cf2a8152d264214b13e23e4fd0bd718dbf95ca4fa
|
4
|
+
data.tar.gz: 61845392dc210469ccf00672d91d683094a1cdbe9abf5db98c26ee8cb25629c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c31b4a29ba0c9d7db0ebd0e150f4a6bde49edb721329fd1669bf1cb9b3b88bfbc5672b3e2e2fbd1f9b6ee4bbc9e1957edd4d2bd7622dc3e1ac99ececba2761c6
|
7
|
+
data.tar.gz: 929da040de365779c80cd0d04e7a9f4c5c6d6e7833f399193e4045b671c66895cf5261f99e9d6ec76233c18ec3911d65d9f8b4cb7034f24afa5bb1a0e04d2403
|
data/LICENSE.txt
CHANGED
data/lib/elastic_graph/errors.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2024 Block, Inc.
|
1
|
+
# Copyright 2024 - 2025 Block, Inc.
|
2
2
|
#
|
3
3
|
# Use of this source code is governed by an MIT-style
|
4
4
|
# license that can be found in the LICENSE file or at
|
@@ -27,6 +27,9 @@ module ElasticGraph
|
|
27
27
|
class CountUnavailableError < Error
|
28
28
|
end
|
29
29
|
|
30
|
+
class AggregationsUnavailableError < Error
|
31
|
+
end
|
32
|
+
|
30
33
|
class InvalidArgumentValueError < Error
|
31
34
|
end
|
32
35
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2024 Block, Inc.
|
1
|
+
# Copyright 2024 - 2025 Block, Inc.
|
2
2
|
#
|
3
3
|
# Use of this source code is governed by an MIT-style
|
4
4
|
# license that can be found in the LICENSE file or at
|
@@ -50,9 +50,7 @@ module ElasticGraph
|
|
50
50
|
# Recursively transforms any hash keys in the given object to string keys, without
|
51
51
|
# mutating the provided argument.
|
52
52
|
def self.stringify_keys(object)
|
53
|
-
|
54
|
-
hash[key.to_s] = value
|
55
|
-
end
|
53
|
+
transform_keys(object, :to_s)
|
56
54
|
end
|
57
55
|
|
58
56
|
# Recursively transforms any hash keys in the given object to symbol keys, without
|
@@ -61,9 +59,7 @@ module ElasticGraph
|
|
61
59
|
# Important note: this should never be used on untrusted input. Symbols are not GCd in
|
62
60
|
# Ruby in the same way as strings.
|
63
61
|
def self.symbolize_keys(object)
|
64
|
-
|
65
|
-
hash[key.to_sym] = value
|
66
|
-
end
|
62
|
+
transform_keys(object, :to_sym)
|
67
63
|
end
|
68
64
|
|
69
65
|
# Recursively prunes nil values from the hash, at any level of its structure, without
|
@@ -114,37 +110,72 @@ module ElasticGraph
|
|
114
110
|
end
|
115
111
|
|
116
112
|
# Fetches a list of (potentially) nested value from a hash. The `key_path` is expected
|
117
|
-
# to be
|
118
|
-
#
|
119
|
-
# at any level is an array.
|
113
|
+
# to be an array of path parts. Returns `[]` if the value at any parent key is `nil`.
|
114
|
+
# Returns a flat array of values if the structure at any level is an array.
|
120
115
|
#
|
121
116
|
# Raises an error if the key is not found unless a default block is provided.
|
122
117
|
# Raises an error if any parent value is not a hash as expected.
|
123
118
|
# Raises an error if the provided path is not a full path to a leaf in the nested structure.
|
124
119
|
def self.fetch_leaf_values_at_path(hash, key_path, &default)
|
125
|
-
do_fetch_leaf_values_at_path(hash, key_path
|
120
|
+
do_fetch_leaf_values_at_path(hash, key_path, 0, &default)
|
126
121
|
end
|
127
122
|
|
128
|
-
# Fetches a single value from the hash at the given path. The `
|
129
|
-
# to be a string with dots between the nesting levels (e.g. `foo.bar`).
|
123
|
+
# Fetches a single value from the hash at the given path. The `path_parts` is expected to be an array.
|
130
124
|
#
|
131
125
|
# If any parent value is not a hash as expected, raises an error.
|
132
126
|
# If the key at any level is not found, yields to the provided block (which can provide a default value)
|
133
127
|
# or raises an error if no block is provided.
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
128
|
+
#
|
129
|
+
# Note: this is a somewhat lengthy implementation, but it was chosen based on benchmarking. This method
|
130
|
+
# needs to be fast because it gets used repeatedly when resolving GraphQL queries at all levels of the
|
131
|
+
# response structure.
|
132
|
+
def self.fetch_value_at_path(hash, path_parts)
|
133
|
+
# We expect the most common case to be a single path part. Benchmarks have shown that special casing it
|
134
|
+
# is quite worthwhile, as it is much faster than the general purpose implementation further below.
|
135
|
+
if path_parts.size == 1
|
136
|
+
return hash.fetch(path_parts.first) do
|
137
|
+
return yield path_parts if block_given?
|
138
|
+
raise KeyError, "Key not found: #{path_parts.inspect}"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
current = hash
|
143
|
+
i = 0
|
144
|
+
|
145
|
+
while i < path_parts.length
|
146
|
+
key = path_parts[i]
|
147
|
+
|
148
|
+
unless current.is_a?(Hash)
|
149
|
+
raise KeyError, "Value at key #{path_parts.first(i).inspect} is not a `Hash` as expected; " \
|
150
|
+
"instead, was a `#{current.class}`"
|
151
|
+
end
|
152
|
+
|
153
|
+
current = current.fetch(key) do
|
154
|
+
missing_path = path_parts.first(i + 1)
|
155
|
+
return yield missing_path if block_given?
|
156
|
+
raise KeyError, "Key not found: #{missing_path.inspect}"
|
157
|
+
end
|
158
|
+
|
159
|
+
i += 1
|
160
|
+
end
|
161
|
+
|
162
|
+
current
|
163
|
+
end
|
164
|
+
|
165
|
+
# Note: this implementation was chosen based off of a benchmark in
|
166
|
+
# `benchmarks/hash_util/key_transformations.rb`.
|
167
|
+
private_class_method def self.transform_keys(object, method)
|
168
|
+
case object
|
169
|
+
when ::Hash
|
170
|
+
result = {} # : ::Hash[untyped, untyped]
|
171
|
+
object.each do |key, value|
|
172
|
+
result[key.send(method)] = transform_keys(value, method)
|
147
173
|
end
|
174
|
+
result
|
175
|
+
when ::Array
|
176
|
+
object.map { |item| transform_keys(item, method) }
|
177
|
+
else
|
178
|
+
object
|
148
179
|
end
|
149
180
|
end
|
150
181
|
|
@@ -192,7 +223,7 @@ module ElasticGraph
|
|
192
223
|
private_class_method def self.do_fetch_leaf_values_at_path(object, path_parts, level_index, &default)
|
193
224
|
if level_index == path_parts.size
|
194
225
|
if object.is_a?(::Hash)
|
195
|
-
raise KeyError, "Key was not a path to a leaf field: #{path_parts.
|
226
|
+
raise KeyError, "Key was not a path to a leaf field: #{path_parts.inspect}"
|
196
227
|
else
|
197
228
|
return Array(object)
|
198
229
|
end
|
@@ -206,7 +237,7 @@ module ElasticGraph
|
|
206
237
|
if object.key?(key)
|
207
238
|
do_fetch_leaf_values_at_path(object.fetch(key), path_parts, level_index + 1, &default)
|
208
239
|
else
|
209
|
-
missing_path = path_parts.first(level_index + 1)
|
240
|
+
missing_path = path_parts.first(level_index + 1)
|
210
241
|
if default
|
211
242
|
Array(default.call(missing_path))
|
212
243
|
else
|
@@ -220,7 +251,7 @@ module ElasticGraph
|
|
220
251
|
else
|
221
252
|
# Note: we intentionally do not put the value (`current_level_hash`) in the
|
222
253
|
# error message, as that would risk leaking PII. But the class of the value should be OK.
|
223
|
-
raise KeyError, "Value at key #{path_parts.first(level_index).
|
254
|
+
raise KeyError, "Value at key #{path_parts.first(level_index).inspect} is not a `Hash` as expected; " \
|
224
255
|
"instead, was a `#{object.class}`"
|
225
256
|
end
|
226
257
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2024 Block, Inc.
|
1
|
+
# Copyright 2024 - 2025 Block, Inc.
|
2
2
|
#
|
3
3
|
# Use of this source code is governed by an MIT-style
|
4
4
|
# license that can be found in the LICENSE file or at
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
module ElasticGraph
|
10
10
|
# The version of all ElasticGraph gems.
|
11
|
-
VERSION = "0.19.
|
11
|
+
VERSION = "0.19.2.0"
|
12
12
|
|
13
13
|
# Steep weirdly expects this here...
|
14
14
|
# @dynamic self.define_schema
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticgraph-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.19.
|
4
|
+
version: 0.19.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myron Marston
|
8
8
|
- Ben VandenBos
|
9
9
|
- Block Engineering
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2025-
|
12
|
+
date: 2025-04-09 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: logger
|
@@ -18,20 +17,14 @@ dependencies:
|
|
18
17
|
requirements:
|
19
18
|
- - "~>"
|
20
19
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
22
|
-
- - ">="
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 1.6.2
|
20
|
+
version: '1.7'
|
25
21
|
type: :runtime
|
26
22
|
prerelease: false
|
27
23
|
version_requirements: !ruby/object:Gem::Requirement
|
28
24
|
requirements:
|
29
25
|
- - "~>"
|
30
26
|
- !ruby/object:Gem::Version
|
31
|
-
version: '1.
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: 1.6.2
|
27
|
+
version: '1.7'
|
35
28
|
- !ruby/object:Gem::Dependency
|
36
29
|
name: faraday
|
37
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,6 +32,9 @@ dependencies:
|
|
39
32
|
- - "~>"
|
40
33
|
- !ruby/object:Gem::Version
|
41
34
|
version: '2.12'
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.12.2
|
42
38
|
type: :development
|
43
39
|
prerelease: false
|
44
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -46,6 +42,9 @@ dependencies:
|
|
46
42
|
- - "~>"
|
47
43
|
- !ruby/object:Gem::Version
|
48
44
|
version: '2.12'
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.12.2
|
49
48
|
- !ruby/object:Gem::Dependency
|
50
49
|
name: rake
|
51
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,6 +52,9 @@ dependencies:
|
|
53
52
|
- - "~>"
|
54
53
|
- !ruby/object:Gem::Version
|
55
54
|
version: '13.2'
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 13.2.1
|
56
58
|
type: :development
|
57
59
|
prerelease: false
|
58
60
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -60,7 +62,9 @@ dependencies:
|
|
60
62
|
- - "~>"
|
61
63
|
- !ruby/object:Gem::Version
|
62
64
|
version: '13.2'
|
63
|
-
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 13.2.1
|
64
68
|
email:
|
65
69
|
- myron@squareup.com
|
66
70
|
executables: []
|
@@ -89,12 +93,11 @@ licenses:
|
|
89
93
|
- MIT
|
90
94
|
metadata:
|
91
95
|
bug_tracker_uri: https://github.com/block/elasticgraph/issues
|
92
|
-
changelog_uri: https://github.com/block/elasticgraph/releases/tag/v0.19.
|
93
|
-
documentation_uri: https://block.github.io/elasticgraph/docs/
|
96
|
+
changelog_uri: https://github.com/block/elasticgraph/releases/tag/v0.19.2.0
|
97
|
+
documentation_uri: https://block.github.io/elasticgraph/api-docs/v0.19.2.0/
|
94
98
|
homepage_uri: https://block.github.io/elasticgraph/
|
95
|
-
source_code_uri: https://github.com/block/elasticgraph/tree/v0.19.
|
99
|
+
source_code_uri: https://github.com/block/elasticgraph/tree/v0.19.2.0/elasticgraph-support
|
96
100
|
gem_category: core
|
97
|
-
post_install_message:
|
98
101
|
rdoc_options: []
|
99
102
|
require_paths:
|
100
103
|
- lib
|
@@ -112,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
115
|
- !ruby/object:Gem::Version
|
113
116
|
version: '0'
|
114
117
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
116
|
-
signing_key:
|
118
|
+
rubygems_version: 3.6.2
|
117
119
|
specification_version: 4
|
118
120
|
summary: ElasticGraph gem providing support utilities to the other ElasticGraph gems.
|
119
121
|
test_files: []
|