elasticgraph-schema_artifacts 0.19.2.2 → 1.0.0.rc1
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/lib/elastic_graph/schema_artifacts/artifacts_helper_methods.rb +17 -2
- data/lib/elastic_graph/schema_artifacts/from_disk.rb +80 -1
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/computation_detail.rb +2 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/enum.rb +5 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/extension.rb +2 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/extension_loader.rb +2 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_extension.rb +1 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_field.rb +1 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_resolver.rb +3 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/hash_dumper.rb +1 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/index_definition.rb +3 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/index_field.rb +2 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/interface_verifier.rb +2 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/object_type.rb +2 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/params.rb +4 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/relation.rb +1 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/scalar_type.rb +4 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/schema.rb +16 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/schema_element_names.rb +9 -4
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/sort_field.rb +1 -0
- data/lib/elastic_graph/schema_artifacts/runtime_metadata/update_target.rb +2 -0
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee87ed29ac7ce2c46f8c4a3f104e716d98cea3cdefb3e81df3523b729c465cb5
|
4
|
+
data.tar.gz: 2efaeedcfbec47cb7cdf9e3d3649d09863498f12f7ed1fe25db63ad15035afca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65a0168084e7499b240f628093c9ff1b9d86a67c273fdba7ae62e086e3dd6e62f6ad5b4ccd5894566cb5365b99ba35ec91ba8bf3bf873018b53b0a33c92ff7a1
|
7
|
+
data.tar.gz: 10528ae4b46b65f32ccc17a0f7f5e2c5fde9573d4d00661ecd9184850552b099c4f15b0187065de13fab1c04a099528149da1aeb6d39fd286def6a51f43c3663
|
@@ -9,21 +9,36 @@
|
|
9
9
|
module ElasticGraph
|
10
10
|
module SchemaArtifacts
|
11
11
|
# Mixin that offers convenient helper methods on top of the basic schema artifacts.
|
12
|
-
# Intended to be mixed into
|
12
|
+
# Intended to be mixed into {FromDisk} and other implementations of the same interface
|
13
|
+
# (such as {SchemaDefinition::Results}.
|
13
14
|
module ArtifactsHelperMethods
|
15
|
+
# Provides accesses to the datastore scripts, typically written using the [painless scripting
|
16
|
+
# language](https://www.elastic.co/docs/explore-analyze/scripting/modules-scripting-painless).
|
17
|
+
#
|
18
|
+
# @return [Hash<String, Hash<String, Object>>]
|
14
19
|
def datastore_scripts
|
15
20
|
datastore_config.fetch("scripts")
|
16
21
|
end
|
17
22
|
|
23
|
+
# Provides accesses to the datastore index templates, which are used for a rollover index defined using
|
24
|
+
# {SchemaDefinition::Indexing::Index#rollover}.
|
25
|
+
#
|
26
|
+
# @return [Hash<String, Hash<String, Object>>]
|
18
27
|
def index_templates
|
19
28
|
datastore_config.fetch("index_templates")
|
20
29
|
end
|
21
30
|
|
31
|
+
# Provides accesses to the datastore indices, used for an index that does not rollover.
|
32
|
+
#
|
33
|
+
# @return [Hash<String, Hash<String, Object>>]
|
22
34
|
def indices
|
23
35
|
datastore_config.fetch("indices")
|
24
36
|
end
|
25
37
|
|
26
|
-
#
|
38
|
+
# Provides access to the [mappings](https://www.elastic.co/docs/manage-data/data-store/mapping) of both the
|
39
|
+
# {#index_templates} and {#indices}.
|
40
|
+
#
|
41
|
+
# @return [Hash<String, Hash<String, Object>>]
|
27
42
|
def index_mappings_by_index_def_name
|
28
43
|
@index_mappings_by_index_def_name ||= index_templates
|
29
44
|
.transform_values { |config| config.fetch("template").fetch("mappings") }
|
@@ -15,8 +15,14 @@ require "elastic_graph/support/memoizable_data"
|
|
15
15
|
require "yaml"
|
16
16
|
|
17
17
|
module ElasticGraph
|
18
|
+
# Namespace for all code related to ElasticGraph schema artifacts.
|
19
|
+
# Schema artifacts are generated by {SchemaDefinition} and dumped to disk.
|
20
|
+
# Later, they are used to power ElasticGraph.
|
18
21
|
module SchemaArtifacts
|
19
22
|
# Builds a `SchemaArtifacts::FromDisk` instance using the provided YAML settings.
|
23
|
+
#
|
24
|
+
# @param parsed_yaml [Hash<String, Object>] hash parsed from a settings YAML file
|
25
|
+
# @return [FromDisk]
|
20
26
|
def self.from_parsed_yaml(parsed_yaml)
|
21
27
|
schema_artifacts = parsed_yaml.fetch("schema_artifacts") do
|
22
28
|
raise Errors::ConfigError, "Config is missing required key `schema_artifacts`."
|
@@ -33,14 +39,54 @@ module ElasticGraph
|
|
33
39
|
FromDisk.new(directory)
|
34
40
|
end
|
35
41
|
|
36
|
-
# Responsible for loading schema artifacts from disk.
|
42
|
+
# Responsible for loading schema artifacts from disk and providing access to each artifact.
|
43
|
+
#
|
44
|
+
# @!attribute [r] artifacts_dir
|
45
|
+
# @return [String] directory from which the schema artifacts are loaded
|
46
|
+
#
|
47
|
+
# @!method initialize(artifacts_dir)
|
48
|
+
# Builds an instance using the given artifacts directory.
|
49
|
+
# @param artifacts_dir [String] directory from which the schema artifacts are loaded
|
50
|
+
# @return [void]
|
37
51
|
class FromDisk < Support::MemoizableData.define(:artifacts_dir)
|
38
52
|
include ArtifactsHelperMethods
|
39
53
|
|
54
|
+
# Provides the GraphQL SDL schema string. This defines the contract between an ElasticGraph project and its GraphQL clients,
|
55
|
+
# and can be freely given to GraphQL clients for code generation or query validation purposes.
|
56
|
+
#
|
57
|
+
# In addition, it is used by `elasticgraph-graphql` to power an ElasticGraph GraphQL endpoint.
|
58
|
+
#
|
59
|
+
# @return [String]
|
60
|
+
# @raise [Errors::MissingSchemaArtifactError] when the `graphql.schema` file does not exist in the `artifacts_dir`.
|
61
|
+
#
|
62
|
+
# @example Print the GraphQL schema string
|
63
|
+
# artifacts = ElasticGraph::SchemaArtifacts::FromDisk.new(schema_artifacts_dir)
|
64
|
+
# puts artifacts.graphql_schema_string
|
65
|
+
#
|
40
66
|
def graphql_schema_string
|
41
67
|
@graphql_schema_string ||= read_artifact(GRAPHQL_SCHEMA_FILE)
|
42
68
|
end
|
43
69
|
|
70
|
+
# Provides the JSON schemas of all types at a specific version. The JSON schemas define the contract between
|
71
|
+
# data publishers and an ElasticGraph project, and can be freely given to data publishers for code generation
|
72
|
+
# or query validation purposes.
|
73
|
+
#
|
74
|
+
# In addition, they are used by `elasticgraph-indexer` to validate data before indexing it.
|
75
|
+
#
|
76
|
+
# @note ElasticGraph supports multiple JSON schema versions in order to support safe, seamless schema evolution.
|
77
|
+
# Each event will be validated using the version specified in the event itself, allowing data publishers to be
|
78
|
+
# updated to the latest JSON schema at a later time after `elasticgraph-indexer` is deployed with a new JSON
|
79
|
+
# schema version.
|
80
|
+
#
|
81
|
+
# @param version [Integer] the desired JSON schema version
|
82
|
+
# @return [Hash<String, Object>]
|
83
|
+
# @raise [Errors::MissingSchemaArtifactError] when the provided version does not exist within the `artifacts_dir`.
|
84
|
+
# @see #available_json_schema_versions
|
85
|
+
# @see #latest_json_schema_version
|
86
|
+
#
|
87
|
+
# @example Get the JSON schema for a `Widget` type at version 1
|
88
|
+
# artifacts = ElasticGraph::SchemaArtifacts::FromDisk.new(schema_artifacts_dir)
|
89
|
+
# widget_v1_json_schema = artifacts.json_schemas_for(1).fetch("$defs").fetch("Widget")
|
44
90
|
def json_schemas_for(version)
|
45
91
|
unless available_json_schema_versions.include?(version)
|
46
92
|
raise Errors::MissingSchemaArtifactError, "The requested json schema version (#{version}) is not available. " \
|
@@ -50,6 +96,15 @@ module ElasticGraph
|
|
50
96
|
json_schemas_by_version[version] # : ::Hash[::String, untyped]
|
51
97
|
end
|
52
98
|
|
99
|
+
# Provides the set of available JSON schema versions.
|
100
|
+
#
|
101
|
+
# @return [Set<Integer>]
|
102
|
+
# @see #json_schemas_for
|
103
|
+
# @see #latest_json_schema_version
|
104
|
+
#
|
105
|
+
# @example Print the list of available JSON schema versions
|
106
|
+
# artifacts = ElasticGraph::SchemaArtifacts::FromDisk.new(schema_artifacts_dir)
|
107
|
+
# puts artifacts.available_json_schema_versions.sort.join(", ")
|
53
108
|
def available_json_schema_versions
|
54
109
|
@available_json_schema_versions ||= begin
|
55
110
|
versioned_json_schemas_dir = ::File.join(artifacts_dir, JSON_SCHEMAS_BY_VERSION_DIRECTORY)
|
@@ -61,6 +116,16 @@ module ElasticGraph
|
|
61
116
|
end
|
62
117
|
end
|
63
118
|
|
119
|
+
# Provides the latest JSON schema version.
|
120
|
+
#
|
121
|
+
# @return [Integer]
|
122
|
+
# @raise [Errors::MissingSchemaArtifactError] when no JSON schemas files exist within the `artifacts_dir`.
|
123
|
+
# @see #available_json_schema_versions
|
124
|
+
# @see #json_schemas_for
|
125
|
+
#
|
126
|
+
# @example Print the latest JSON schema version
|
127
|
+
# artifacts = ElasticGraph::SchemaArtifacts::FromDisk.new(schema_artifacts_dir)
|
128
|
+
# puts artifacts.latest_json_schema_version
|
64
129
|
def latest_json_schema_version
|
65
130
|
@latest_json_schema_version ||= available_json_schema_versions.max || raise(
|
66
131
|
Errors::MissingSchemaArtifactError,
|
@@ -69,10 +134,24 @@ module ElasticGraph
|
|
69
134
|
)
|
70
135
|
end
|
71
136
|
|
137
|
+
# Provides the datastore configuration. The datastore configuration defines the full configuration--including indices, templates,
|
138
|
+
# and scripts--required in the datastore (Elasticsearch or OpenSearch) by ElasticGraph for the current schema.
|
139
|
+
#
|
140
|
+
# `elasticgraph-admin` uses this artifact to administer the datastore.
|
141
|
+
#
|
142
|
+
# @return [Hash<String, Object>]
|
143
|
+
# @raise [Errors::MissingSchemaArtifactError] when `datastore_config.yaml` does not exist within the `artifacts_dir`.
|
144
|
+
#
|
145
|
+
# @example Print the current list of indices
|
146
|
+
# artifacts = ElasticGraph::SchemaArtifacts::FromDisk.new(schema_artifacts_dir)
|
147
|
+
# puts artifacts.datastore_config.fetch("indices").keys.sort.join(", ")
|
72
148
|
def datastore_config
|
73
149
|
@datastore_config ||= _ = parsed_yaml_from(DATASTORE_CONFIG_FILE)
|
74
150
|
end
|
75
151
|
|
152
|
+
# Provides the runtime metadata. This runtime metadata is used at runtime by `elasticgraph-graphql` and `elasticgraph-indexer`.
|
153
|
+
#
|
154
|
+
# @return [RuntimeMetadata::Schema]
|
76
155
|
def runtime_metadata
|
77
156
|
@runtime_metadata ||= RuntimeMetadata::Schema.from_hash(parsed_yaml_from(RUNTIME_METADATA_FILE))
|
78
157
|
end
|
@@ -10,6 +10,8 @@ module ElasticGraph
|
|
10
10
|
module SchemaArtifacts
|
11
11
|
module RuntimeMetadata
|
12
12
|
# Details about our aggregation functions.
|
13
|
+
#
|
14
|
+
# @private
|
13
15
|
class ComputationDetail < ::Data.define(:empty_bucket_value, :function)
|
14
16
|
FUNCTION = "function"
|
15
17
|
EMPTY_BUCKET_VALUE = "empty_bucket_value"
|
@@ -12,8 +12,11 @@ require "elastic_graph/schema_artifacts/runtime_metadata/sort_field"
|
|
12
12
|
module ElasticGraph
|
13
13
|
module SchemaArtifacts
|
14
14
|
module RuntimeMetadata
|
15
|
+
# @private
|
15
16
|
module Enum
|
16
17
|
# Runtime metadata related to an ElasticGraph enum type.
|
18
|
+
#
|
19
|
+
# @private
|
17
20
|
class Type < ::Data.define(:values_by_name)
|
18
21
|
VALUES_BY_NAME = "values_by_name"
|
19
22
|
|
@@ -34,6 +37,8 @@ module ElasticGraph
|
|
34
37
|
end
|
35
38
|
|
36
39
|
# Runtime metadata related to an ElasticGraph enum value.
|
40
|
+
#
|
41
|
+
# @private
|
37
42
|
class Value < ::Data.define(:sort_field, :datastore_value, :datastore_abbreviation, :alternate_original_name)
|
38
43
|
DATASTORE_VALUE = "datastore_value"
|
39
44
|
DATASTORE_ABBREVIATION = "datastore_abbreviation"
|
@@ -23,6 +23,8 @@ module ElasticGraph
|
|
23
23
|
# We eagerly load extensions (and validate them in the `ExtensionLoader`) in
|
24
24
|
# order to surface any issues with the extension as soon as possible. We don't
|
25
25
|
# want to defer errors if we can detect any issues with the extension at boot time.
|
26
|
+
#
|
27
|
+
# @private
|
26
28
|
Extension = ::Data.define(:extension_class, :require_path, :config, :name) do
|
27
29
|
# @implements Extension
|
28
30
|
def initialize(extension_class:, require_path:, config:, name: extension_class.name.to_s)
|
@@ -22,6 +22,8 @@ module ElasticGraph
|
|
22
22
|
# Note, however, that this does not guarantee no runtime exceptions from the use of the
|
23
23
|
# extension: the extension may return invalid return values, or throw exceptions when
|
24
24
|
# called. But this verifies the interface to the extent that we can.
|
25
|
+
#
|
26
|
+
# @private
|
25
27
|
class ExtensionLoader
|
26
28
|
def initialize(interface_def)
|
27
29
|
@interface_def = interface_def
|
@@ -11,6 +11,7 @@ require "elastic_graph/schema_artifacts/runtime_metadata/extension_loader"
|
|
11
11
|
module ElasticGraph
|
12
12
|
module SchemaArtifacts
|
13
13
|
module RuntimeMetadata
|
14
|
+
# @private
|
14
15
|
class GraphQLExtension < ::Data.define(:extension_ref)
|
15
16
|
def self.loader
|
16
17
|
@loader ||= ExtensionLoader.new(Module.new)
|
@@ -12,6 +12,7 @@ require "elastic_graph/schema_artifacts/runtime_metadata/relation"
|
|
12
12
|
module ElasticGraph
|
13
13
|
module SchemaArtifacts
|
14
14
|
module RuntimeMetadata
|
15
|
+
# @private
|
15
16
|
class GraphQLField < ::Data.define(:name_in_index, :relation, :computation_detail, :resolver)
|
16
17
|
EMPTY = new(nil, nil, nil, nil)
|
17
18
|
NAME_IN_INDEX = "name_in_index"
|
@@ -11,6 +11,7 @@ require "elastic_graph/schema_artifacts/runtime_metadata/extension_loader"
|
|
11
11
|
module ElasticGraph
|
12
12
|
module SchemaArtifacts
|
13
13
|
module RuntimeMetadata
|
14
|
+
# @private
|
14
15
|
class GraphQLResolver < ::Data.define(:needs_lookahead, :resolver_ref)
|
15
16
|
def self.with_lookahead_loader
|
16
17
|
@with_lookahead_loader ||= ExtensionLoader.new(InterfaceWithLookahead)
|
@@ -43,6 +44,7 @@ module ElasticGraph
|
|
43
44
|
}
|
44
45
|
end
|
45
46
|
|
47
|
+
# @private
|
46
48
|
class InterfaceWithLookahead
|
47
49
|
def initialize(elasticgraph_graphql:, config:)
|
48
50
|
# must be defined, but nothing to do
|
@@ -52,6 +54,7 @@ module ElasticGraph
|
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
57
|
+
# @private
|
55
58
|
class InterfaceWithoutLookahead
|
56
59
|
def initialize(elasticgraph_graphql:, config:)
|
57
60
|
# must be defined, but nothing to do
|
@@ -14,6 +14,8 @@ module ElasticGraph
|
|
14
14
|
module SchemaArtifacts
|
15
15
|
module RuntimeMetadata
|
16
16
|
# Runtime metadata related to a datastore index definition.
|
17
|
+
#
|
18
|
+
# @private
|
17
19
|
class IndexDefinition < ::Data.define(:route_with, :rollover, :default_sort_fields, :current_sources, :fields_by_path)
|
18
20
|
ROUTE_WITH = "route_with"
|
19
21
|
ROLLOVER = "rollover"
|
@@ -52,6 +54,7 @@ module ElasticGraph
|
|
52
54
|
}
|
53
55
|
end
|
54
56
|
|
57
|
+
# @private
|
55
58
|
class Rollover < ::Data.define(:frequency, :timestamp_field_path)
|
56
59
|
FREQUENCY = "frequency"
|
57
60
|
TIMESTAMP_FIELD_PATH = "timestamp_field_path"
|
@@ -20,6 +20,8 @@ module ElasticGraph
|
|
20
20
|
# Note, however, that this does not guarantee no runtime exceptions from the use of the
|
21
21
|
# extension: the extension may return invalid return values, or throw exceptions when
|
22
22
|
# called. But this verifies the interface to the extent that we can.
|
23
|
+
#
|
24
|
+
# @private
|
23
25
|
module InterfaceVerifier
|
24
26
|
class << self
|
25
27
|
def verify!(extension, against:, constant_name:)
|
@@ -12,6 +12,7 @@ require "elastic_graph/support/hash_util"
|
|
12
12
|
module ElasticGraph
|
13
13
|
module SchemaArtifacts
|
14
14
|
module RuntimeMetadata
|
15
|
+
# @private
|
15
16
|
module Param
|
16
17
|
def self.dump_params_hash(hash_of_params)
|
17
18
|
hash_of_params.sort_by(&:first).to_h { |name, param| [name, param.to_dumpable_hash(name)] }
|
@@ -31,6 +32,8 @@ module ElasticGraph
|
|
31
32
|
end
|
32
33
|
|
33
34
|
# Represents metadata about dynamic params we pass to our update scripts.
|
35
|
+
#
|
36
|
+
# @private
|
34
37
|
class DynamicParam < ::Data.define(:source_path, :cardinality)
|
35
38
|
SOURCE_PATH = "source_path"
|
36
39
|
CARDINALITY = "cardinality"
|
@@ -58,6 +61,7 @@ module ElasticGraph
|
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
64
|
+
# @private
|
61
65
|
class StaticParam < ::Data.define(:value)
|
62
66
|
VALUE = "value"
|
63
67
|
|
@@ -12,6 +12,8 @@ module ElasticGraph
|
|
12
12
|
module SchemaArtifacts
|
13
13
|
module RuntimeMetadata
|
14
14
|
# Provides runtime metadata related to scalar types.
|
15
|
+
#
|
16
|
+
# @private
|
15
17
|
class ScalarType < ::Data.define(:coercion_adapter_ref, :indexing_preparer_ref)
|
16
18
|
def self.coercion_adapter_extension_loader
|
17
19
|
@coercion_adapter_extension_loader ||= ExtensionLoader.new(ScalarCoercionAdapterInterface)
|
@@ -77,6 +79,7 @@ module ElasticGraph
|
|
77
79
|
private :to_h
|
78
80
|
end
|
79
81
|
|
82
|
+
# @private
|
80
83
|
class ScalarCoercionAdapterInterface
|
81
84
|
def self.coerce_input(value, ctx)
|
82
85
|
end
|
@@ -85,6 +88,7 @@ module ElasticGraph
|
|
85
88
|
end
|
86
89
|
end
|
87
90
|
|
91
|
+
# @private
|
88
92
|
class ScalarIndexingPreparerInterface
|
89
93
|
def self.prepare_for_indexing(value)
|
90
94
|
end
|
@@ -20,6 +20,7 @@ require "elastic_graph/support/hash_util"
|
|
20
20
|
|
21
21
|
module ElasticGraph
|
22
22
|
module SchemaArtifacts
|
23
|
+
# Namespace containing class definitions for runtime metadata.
|
23
24
|
module RuntimeMetadata
|
24
25
|
# Entry point for runtime metadata for an entire schema.
|
25
26
|
class Schema < ::Data.define(
|
@@ -32,15 +33,27 @@ module ElasticGraph
|
|
32
33
|
:graphql_resolvers_by_name,
|
33
34
|
:static_script_ids_by_scoped_name
|
34
35
|
)
|
36
|
+
# @private
|
35
37
|
OBJECT_TYPES_BY_NAME = "object_types_by_name"
|
38
|
+
# @private
|
36
39
|
SCALAR_TYPES_BY_NAME = "scalar_types_by_name"
|
40
|
+
# @private
|
37
41
|
ENUM_TYPES_BY_NAME = "enum_types_by_name"
|
42
|
+
# @private
|
38
43
|
INDEX_DEFINITIONS_BY_NAME = "index_definitions_by_name"
|
44
|
+
# @private
|
39
45
|
SCHEMA_ELEMENT_NAMES = "schema_element_names"
|
46
|
+
# @private
|
40
47
|
GRAPHQL_EXTENSION_MODULES = "graphql_extension_modules"
|
48
|
+
# @private
|
41
49
|
GRAPHQL_RESOLVERS_BY_NAME = "graphql_resolvers_by_name"
|
50
|
+
# @private
|
42
51
|
STATIC_SCRIPT_IDS_BY_NAME = "static_script_ids_by_scoped_name"
|
43
52
|
|
53
|
+
# Loads a {RuntimeMetadata::Schema} from the given hash.
|
54
|
+
#
|
55
|
+
# @param hash [Hash<String, Hash<String, Object>>] runtime metadata hash loaded from YAML
|
56
|
+
# @return [Schema] the runtime metadata schema instance
|
44
57
|
def self.from_hash(hash)
|
45
58
|
object_types_by_name = hash[OBJECT_TYPES_BY_NAME]&.transform_values do |type_hash|
|
46
59
|
ObjectType.from_hash(type_hash)
|
@@ -83,6 +96,9 @@ module ElasticGraph
|
|
83
96
|
)
|
84
97
|
end
|
85
98
|
|
99
|
+
# Converts to a hash that is suitable for dumping to disk as YAML.
|
100
|
+
#
|
101
|
+
# @return [Hash<String, Hash<String, Object>>] runtime metadata hash ready to dump to YAML
|
86
102
|
def to_dumpable_hash
|
87
103
|
Support::HashUtil.recursively_prune_nils_and_empties_from({
|
88
104
|
# Keys here are ordered alphabetically; please keep them that way.
|
@@ -13,6 +13,8 @@ module ElasticGraph
|
|
13
13
|
module SchemaArtifacts
|
14
14
|
module RuntimeMetadata
|
15
15
|
# Defines a generic schema element names API. Defined as a separate class to facilitate easy testing.
|
16
|
+
#
|
17
|
+
# @private
|
16
18
|
class SchemaElementNamesDefinition
|
17
19
|
def self.new(*element_names)
|
18
20
|
::Data.define(:form, :overrides, :exposed_name_by_canonical_name, :canonical_name_by_exposed_name) do
|
@@ -107,6 +109,7 @@ module ElasticGraph
|
|
107
109
|
FORM = "form"
|
108
110
|
OVERRIDES = "overrides"
|
109
111
|
|
112
|
+
# @private
|
110
113
|
module SnakeCaseConverter
|
111
114
|
extend self
|
112
115
|
|
@@ -115,6 +118,7 @@ module ElasticGraph
|
|
115
118
|
end
|
116
119
|
end
|
117
120
|
|
121
|
+
# @private
|
118
122
|
module CamelCaseConverter
|
119
123
|
extend self
|
120
124
|
|
@@ -129,23 +133,24 @@ module ElasticGraph
|
|
129
133
|
}
|
130
134
|
end
|
131
135
|
|
136
|
+
# @private
|
132
137
|
SchemaElementNames = SchemaElementNamesDefinition.new(
|
133
138
|
# Filter arg and operation names:
|
134
139
|
:filter,
|
135
|
-
:equal_to_any_of, :gt, :gte, :lt, :lte, :
|
136
|
-
:time_of_day, :any_satisfy,
|
140
|
+
:equal_to_any_of, :gt, :gte, :lt, :lte, :matches_phrase, :matches_query, :any_of, :all_of, :not,
|
141
|
+
:time_of_day, :any_satisfy, :contains, :starts_with, :all_substrings_of, :any_substring_of, :ignore_case, :any_prefix_of,
|
137
142
|
# Directives
|
138
143
|
:eg_latency_slo, :ms,
|
139
144
|
# For sorting.
|
140
145
|
:order_by,
|
146
|
+
# For search highlighting,
|
147
|
+
:highlights, :all_highlights, :path, :snippets,
|
141
148
|
# For aggregation
|
142
149
|
:grouped_by, :count, :count_detail, :aggregated_values, :sub_aggregations,
|
143
150
|
# Date/time grouping aggregation fields
|
144
151
|
:as_date_time, :as_date, :as_time_of_day, :as_day_of_week,
|
145
152
|
# Date/time grouping aggregation arguments
|
146
153
|
:offset, :amount, :unit, :time_zone, :truncation_unit,
|
147
|
-
# TODO: Drop support for legacy grouping schema that uses `granularity` and `offset_days`
|
148
|
-
:granularity, :offset_days,
|
149
154
|
# For aggregation counts.
|
150
155
|
:approximate_value, :exact_value, :upper_bound,
|
151
156
|
# For pagination.
|
@@ -11,6 +11,7 @@ require "elastic_graph/errors"
|
|
11
11
|
module ElasticGraph
|
12
12
|
module SchemaArtifacts
|
13
13
|
module RuntimeMetadata
|
14
|
+
# @private
|
14
15
|
class SortField < ::Data.define(:field_path, :direction)
|
15
16
|
def initialize(field_path:, direction:)
|
16
17
|
unless direction == :asc || direction == :desc
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticgraph-schema_artifacts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myron Marston
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
- Block Engineering
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: elasticgraph-support
|
@@ -17,42 +17,42 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
20
|
+
version: 1.0.0.rc1
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
27
|
+
version: 1.0.0.rc1
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: elasticgraph-graphql
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.
|
34
|
+
version: 1.0.0.rc1
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - '='
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.
|
41
|
+
version: 1.0.0.rc1
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: elasticgraph-indexer
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - '='
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0.
|
48
|
+
version: 1.0.0.rc1
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - '='
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
55
|
+
version: 1.0.0.rc1
|
56
56
|
email:
|
57
57
|
- myron@squareup.com
|
58
58
|
executables: []
|
@@ -87,10 +87,10 @@ licenses:
|
|
87
87
|
- MIT
|
88
88
|
metadata:
|
89
89
|
bug_tracker_uri: https://github.com/block/elasticgraph/issues
|
90
|
-
changelog_uri: https://github.com/block/elasticgraph/releases/tag/
|
91
|
-
documentation_uri: https://block.github.io/elasticgraph/api-docs/
|
90
|
+
changelog_uri: https://github.com/block/elasticgraph/releases/tag/v1.0.0.rc1
|
91
|
+
documentation_uri: https://block.github.io/elasticgraph/api-docs/v1.0.0.rc1/
|
92
92
|
homepage_uri: https://block.github.io/elasticgraph/
|
93
|
-
source_code_uri: https://github.com/block/elasticgraph/tree/
|
93
|
+
source_code_uri: https://github.com/block/elasticgraph/tree/v1.0.0.rc1/elasticgraph-schema_artifacts
|
94
94
|
gem_category: core
|
95
95
|
rdoc_options: []
|
96
96
|
require_paths:
|
@@ -99,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '3.
|
102
|
+
version: '3.4'
|
103
103
|
- - "<"
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '3.5'
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
rubygems_version: 3.6.
|
112
|
+
rubygems_version: 3.6.7
|
113
113
|
specification_version: 4
|
114
114
|
summary: ElasticGraph gem containing code related to generated schema artifacts.
|
115
115
|
test_files: []
|