elasticgraph-support 0.19.1.1 → 0.19.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5011690a4632f61ad8385954fdd40dc642910f857639c0ecd9b18ab92cd3ac5
4
- data.tar.gz: 74ff3c94eb4c6b4d118a9894e62d8c901cead6eda46468d34e453db5a4bd5b21
3
+ metadata.gz: 319d6a49ad00e0f14902145d626c347f15a02d2a3796c3f68905da7974580513
4
+ data.tar.gz: dfcb39b4e9a116a36981414c473b2537d1591e617a0a716823badfead5106bc4
5
5
  SHA512:
6
- metadata.gz: 0c31e5517580458e1ce45a410f865e11c79e2105dc36e4d1b76579c4b401f6a0b95a5f9e6ffc39dadfc4b60c38b24e43f9d98bf84f215d6dfdd14d76b5295104
7
- data.tar.gz: 2985360c094becc9b0c5984b2974273f876e09ecc65656e54e32cbac761a9d2d3326bb28d43ec0653491969ca7cef144f51be3a067307ec53f51e160c7ce9f71
6
+ metadata.gz: ae40ab372733d3106d385d198fcc1cc7e4c9d95dba3205e0717392ea3e718f8fe8dc5b3909d4bd97f6066feed564db361853d4110b7972d000e26d15d7cbc9c4
7
+ data.tar.gz: 1417f16e24819a3060e6c7de32bbc07091e78b262f5d8476043d091273194e54a464a94fa6f942a27eea510230b860677f9caf1c6e011c34655015f9514f44b5
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 Block, Inc.
3
+ Copyright (c) 2024 - 2025 Block, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -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
@@ -253,6 +253,10 @@ module ElasticGraph
253
253
  # @private
254
254
  GRAPHQL_LAMBDA_AWS_ARN_HEADER = "X-AWS-LAMBDA-CALLER-ARN"
255
255
 
256
+ # The name of the visibility profile we use with the GraphQL gem.
257
+ # @private
258
+ VISIBILITY_PROFILE = :main
259
+
256
260
  # TODO(steep): it complains about `define_schema` not being defined but it is defined
257
261
  # in another file; I shouldn't have to say it's dynamic here. For now this works though.
258
262
  # @dynamic self.define_schema
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
- recursively_transform(object) do |key, value, hash|
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
- recursively_transform(object) do |key, value, hash|
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 a string with dots between the nesting levels (e.g. `foo.bar`). Returns `[]` if
118
- # the value at any parent key is `nil`. Returns a flat array of values if the structure
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.split("."), 0, &default)
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 `key_path` is expected
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
- def self.fetch_value_at_path(hash, key_path)
135
- path_parts = key_path.split(".")
136
-
137
- path_parts.each.with_index(1).reduce(hash) do |inner_hash, (key, num_parts)|
138
- if inner_hash.is_a?(::Hash)
139
- inner_hash.fetch(key) do
140
- missing_path = path_parts.first(num_parts).join(".")
141
- return yield missing_path if block_given?
142
- raise KeyError, "Key not found: #{missing_path.inspect}"
143
- end
144
- else
145
- raise KeyError, "Value at key #{path_parts.first(num_parts - 1).join(".").inspect} is not a `Hash` as expected; " \
146
- "instead, was a `#{(_ = inner_hash).class}`"
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.join(".").inspect}"
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).join(".")
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).join(".").inspect} is not a `Hash` as expected; " \
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.1.1"
11
+ VERSION = "0.19.2.1"
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.1.1
4
+ version: 0.19.2.1
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-02-07 00:00:00.000000000 Z
12
+ date: 2025-04-24 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: logger
@@ -18,34 +17,28 @@ dependencies:
18
17
  requirements:
19
18
  - - "~>"
20
19
  - !ruby/object:Gem::Version
21
- version: '1.6'
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.6'
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
38
31
  requirements:
39
32
  - - "~>"
40
33
  - !ruby/object:Gem::Version
41
- version: '2.12'
34
+ version: '2.13'
42
35
  type: :development
43
36
  prerelease: false
44
37
  version_requirements: !ruby/object:Gem::Requirement
45
38
  requirements:
46
39
  - - "~>"
47
40
  - !ruby/object:Gem::Version
48
- version: '2.12'
41
+ version: '2.13'
49
42
  - !ruby/object:Gem::Dependency
50
43
  name: rake
51
44
  requirement: !ruby/object:Gem::Requirement
@@ -53,6 +46,9 @@ dependencies:
53
46
  - - "~>"
54
47
  - !ruby/object:Gem::Version
55
48
  version: '13.2'
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 13.2.1
56
52
  type: :development
57
53
  prerelease: false
58
54
  version_requirements: !ruby/object:Gem::Requirement
@@ -60,7 +56,9 @@ dependencies:
60
56
  - - "~>"
61
57
  - !ruby/object:Gem::Version
62
58
  version: '13.2'
63
- description:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 13.2.1
64
62
  email:
65
63
  - myron@squareup.com
66
64
  executables: []
@@ -89,12 +87,11 @@ licenses:
89
87
  - MIT
90
88
  metadata:
91
89
  bug_tracker_uri: https://github.com/block/elasticgraph/issues
92
- changelog_uri: https://github.com/block/elasticgraph/releases/tag/v0.19.1.1
93
- documentation_uri: https://block.github.io/elasticgraph/docs/main/
90
+ changelog_uri: https://github.com/block/elasticgraph/releases/tag/v0.19.2.1
91
+ documentation_uri: https://block.github.io/elasticgraph/api-docs/v0.19.2.1/
94
92
  homepage_uri: https://block.github.io/elasticgraph/
95
- source_code_uri: https://github.com/block/elasticgraph/tree/v0.19.1.1/elasticgraph-support
93
+ source_code_uri: https://github.com/block/elasticgraph/tree/v0.19.2.1/elasticgraph-support
96
94
  gem_category: core
97
- post_install_message:
98
95
  rdoc_options: []
99
96
  require_paths:
100
97
  - lib
@@ -112,8 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
109
  - !ruby/object:Gem::Version
113
110
  version: '0'
114
111
  requirements: []
115
- rubygems_version: 3.5.22
116
- signing_key:
112
+ rubygems_version: 3.6.2
117
113
  specification_version: 4
118
114
  summary: ElasticGraph gem providing support utilities to the other ElasticGraph gems.
119
115
  test_files: []