diff --git a/AGENTS.md b/AGENTS.md index ea25d3bfd..7b0c4d782 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -85,9 +85,10 @@ All gems follow the pattern: `elasticgraph-[name]/` containing: - `elasticgraph-elasticsearch`: Elasticsearch client wrapper - `elasticgraph-opensearch`: OpenSearch client wrapper -**Extensions** (5 gems): Optional functionality +**Extensions** (6 gems): Optional functionality plus the default JSON Schema ingestion serializer - `elasticgraph-apollo`: Apollo Federation support - `elasticgraph-health_check`: Health checks +- `elasticgraph-json_ingestion`: JSON Schema ingestion serializer - `elasticgraph-query_interceptor`: Query interception - `elasticgraph-query_registry`: Source-controlled query registry - `elasticgraph-warehouse`: Data warehouse ingestion diff --git a/elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb b/elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb index 5b2db4351..0a25d6cc5 100644 --- a/elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb +++ b/elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb @@ -35,7 +35,7 @@ module ElasticGraph # local_config_yaml: "config/settings/local.yaml", # path_to_schema: "config/schema.rb" # ) do |tasks| - # tasks.schema_definition_extension_modules = [ElasticGraph::Apollo::SchemaDefinition::APIExtension] + # tasks.schema_definition_extension_modules += [ElasticGraph::Apollo::SchemaDefinition::APIExtension] # end module Apollo # Namespace for all Apollo schema definition support. @@ -55,7 +55,7 @@ module SchemaDefinition # local_config_yaml: "config/settings/local.yaml", # path_to_schema: "config/schema.rb" # ) do |tasks| - # tasks.schema_definition_extension_modules = [ElasticGraph::Apollo::SchemaDefinition::APIExtension] + # tasks.schema_definition_extension_modules += [ElasticGraph::Apollo::SchemaDefinition::APIExtension] # end module APIExtension # Applies an apollo tag to built-in types so that they are included in the Apollo contract schema. diff --git a/elasticgraph-json_ingestion/README.md b/elasticgraph-json_ingestion/README.md index db1eb3988..7f5091166 100644 --- a/elasticgraph-json_ingestion/README.md +++ b/elasticgraph-json_ingestion/README.md @@ -1,9 +1,98 @@ # ElasticGraph::JSONIngestion -JSON Schema ingestion support for ElasticGraph. +Default JSON Schema ingestion support for ElasticGraph. This gem provides the schema-definition extension that generates JSON Schema artifacts for indexing -events and validates JSON-ingestion-specific schema options. +events and validates JSON-ingestion-specific schema options. Generated ElasticGraph projects install +and enable it by default. Applications that wire schema-definition tasks manually enable it by adding +`ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension` to their schema-definition extension modules. + +## Schema Definition APIs + +Use `schema.json_schema_version` to identify the current JSON schema artifact. Every change that affects +the JSON schema should increment this version so publishers and indexers can safely evolve independently. + +```diff +diff --git a/config/schema.rb b/config/schema.rb +index 015c5fa..b8eeaef 100644 +--- a/config/schema.rb ++++ b/config/schema.rb +@@ -1,5 +1,5 @@ + ElasticGraph.define_schema do |schema| + # ElasticGraph will tell you when you need to bump this. +- schema.json_schema_version 1 ++ schema.json_schema_version 2 +- ++ + # Set this to true once you're beyond the prototyping stage. +``` + +Use `schema.json_schema_strictness` to configure whether indexing events may omit nullable fields or include +extra fields. We recommend enabling at most one of these options, because enabling both can hide misspelled +event fields. + +```ruby +# in config/schema/json_schema_strictness.rb + +ElasticGraph.define_schema do |schema| + schema.json_schema_strictness allow_omitted_fields: true, allow_extra_fields: false +end +``` + +Custom scalar types must declare how they are represented in JSON Schema: + +```ruby +# in config/schema/url.rb + +ElasticGraph.define_schema do |schema| + schema.scalar_type "URL" do |t| + t.mapping type: "keyword" + t.json_schema type: "string", format: "uri" + end +end +``` + +Fields and object/interface types can add JSON Schema validations. Use field-level validations sparingly: +they run while indexing events, so violations can send otherwise valid source-system data to the dead letter +queue. They are best reserved for constraints that ElasticGraph needs in order to index correctly. + +```ruby +# in config/schema/card.rb + +ElasticGraph.define_schema do |schema| + schema.object_type "Card" do |t| + t.field "id", "ID!" + + t.field "expYear", "Int" do |f| + f.json_schema minimum: 2000, maximum: 2099 + end + + t.field "expMonth", "Int" do |f| + f.json_schema minimum: 1, maximum: 12 + end + + t.index "cards" + end +end +``` + +On fields, `nullable: false` disallows `null` in indexing events while keeping the GraphQL field nullable: + +```ruby +# in config/schema/widget.rb + +ElasticGraph.define_schema do |schema| + schema.object_type "Widget" do |t| + t.field "id", "ID!" + + t.field "name", "String" do |f| + f.json_schema nullable: false + end + + t.index "widgets" + end +end +``` ## Dependency Diagram diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/api_extension.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/api_extension.rb index 912b6b97e..80bcb71fb 100644 --- a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/api_extension.rb +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/api_extension.rb @@ -9,15 +9,7 @@ require "elastic_graph/constants" require "elastic_graph/graphql/scalar_coercion_adapters/valid_time_zones" require "elastic_graph/json_ingestion/schema_definition/factory_extension" -require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum_extension" -require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/object_extension" -require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar_extension" -require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/union_extension" require "elastic_graph/json_ingestion/schema_definition/state_extension" -require "elastic_graph/schema_definition/indexing/field_type/enum" -require "elastic_graph/schema_definition/indexing/field_type/object" -require "elastic_graph/schema_definition/indexing/field_type/scalar" -require "elastic_graph/schema_definition/indexing/field_type/union" module ElasticGraph module JSONIngestion @@ -47,20 +39,12 @@ module APIExtension "LongString" => {type: "integer", minimum: LONG_STRING_MIN, maximum: LONG_STRING_MAX} }.freeze - # Wires up the factory extension when this module is extended onto an API instance. + # Wires up the JSON ingestion extensions when this module is extended onto an API instance. # # @param api [ElasticGraph::SchemaDefinition::API] the API instance to extend # @return [void] # @api private def self.extended(api) - # Prepend our indexing-field-type extensions onto the core classes so they participate in - # `to_json_schema` / `format_field_json_schema_customizations` / `json_schema_field_metadata_by_field_name`. - # Guarded so re-extending an already-extended API instance is a no-op. - ElasticGraph::SchemaDefinition::Indexing::FieldType::Enum.prepend(Indexing::FieldType::EnumExtension) unless ElasticGraph::SchemaDefinition::Indexing::FieldType::Enum < Indexing::FieldType::EnumExtension - ElasticGraph::SchemaDefinition::Indexing::FieldType::Object.prepend(Indexing::FieldType::ObjectExtension) unless ElasticGraph::SchemaDefinition::Indexing::FieldType::Object < Indexing::FieldType::ObjectExtension - ElasticGraph::SchemaDefinition::Indexing::FieldType::Scalar.prepend(Indexing::FieldType::ScalarExtension) unless ElasticGraph::SchemaDefinition::Indexing::FieldType::Scalar < Indexing::FieldType::ScalarExtension - ElasticGraph::SchemaDefinition::Indexing::FieldType::Union.prepend(Indexing::FieldType::UnionExtension) unless ElasticGraph::SchemaDefinition::Indexing::FieldType::Union < Indexing::FieldType::UnionExtension - state = api.state.extend(StateExtension) # : ElasticGraph::SchemaDefinition::State & StateExtension state.reserved_type_names << EVENT_ENVELOPE_JSON_SCHEMA_NAME api.factory.extend FactoryExtension diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/factory_extension.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/factory_extension.rb index 0bae2715b..67970d395 100644 --- a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/factory_extension.rb +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/factory_extension.rb @@ -14,6 +14,7 @@ require "elastic_graph/json_ingestion/schema_definition/schema_elements/object_interface_extension" require "elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension" require "elastic_graph/json_ingestion/schema_definition/schema_elements/type_reference_extension" +require "elastic_graph/json_ingestion/schema_definition/schema_elements/union_type_extension" module ElasticGraph module JSONIngestion @@ -78,6 +79,14 @@ def new_type_reference(name) super(name).extend(SchemaElements::TypeReferenceExtension) end + # @private + def new_union_type(name) + super(name) do |type| + type.extend SchemaElements::UnionTypeExtension + yield type if block_given? + end + end + # Creates a new Results instance with JSON Schema extensions. # # @return [ElasticGraph::SchemaDefinition::Results] the created results instance diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum.rb new file mode 100644 index 000000000..c34e092bb --- /dev/null +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum.rb @@ -0,0 +1,43 @@ +# Copyright 2024 - 2026 Block, Inc. +# +# Use of this source code is governed by an MIT-style +# license that can be found in the LICENSE file or at +# https://opensource.org/licenses/MIT. +# +# frozen_string_literal: true + +require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum_extension" +require "elastic_graph/schema_definition/indexing/field_type/enum" + +module ElasticGraph + module JSONIngestion + module SchemaDefinition + module Indexing + module FieldType + # JSON-ingestion indexing field type wrapper for enums. + # + # @private + class Enum + include EnumExtension + + def self.wrap(field_type) + new(field_type) + end + + def initialize(field_type) + @field_type = field_type + end + + def enum_value_names + @field_type.enum_value_names + end + + def to_mapping + @field_type.to_mapping + end + end + end + end + end + end +end diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/object.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/object.rb new file mode 100644 index 000000000..37d9dca40 --- /dev/null +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/object.rb @@ -0,0 +1,59 @@ +# Copyright 2024 - 2026 Block, Inc. +# +# Use of this source code is governed by an MIT-style +# license that can be found in the LICENSE file or at +# https://opensource.org/licenses/MIT. +# +# frozen_string_literal: true + +require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/object_extension" +require "elastic_graph/schema_definition/indexing/field_type/object" + +module ElasticGraph + module JSONIngestion + module SchemaDefinition + module Indexing + module FieldType + # JSON-ingestion indexing field type wrapper for objects. + # + # @private + class Object + include ObjectExtension + + def self.wrap(field_type, json_schema_options:) + new(field_type).with_json_schema_options(json_schema_options) + end + + def initialize(field_type) + @field_type = field_type + end + + def schema_def_state + @field_type.schema_def_state + end + + def type_name + @field_type.type_name + end + + def subfields + @field_type.subfields + end + + def mapping_options + @field_type.mapping_options + end + + def doc_comment + @field_type.doc_comment + end + + def to_mapping + @field_type.to_mapping + end + end + end + end + end + end +end diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar.rb new file mode 100644 index 000000000..a97e53fcf --- /dev/null +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar.rb @@ -0,0 +1,43 @@ +# Copyright 2024 - 2026 Block, Inc. +# +# Use of this source code is governed by an MIT-style +# license that can be found in the LICENSE file or at +# https://opensource.org/licenses/MIT. +# +# frozen_string_literal: true + +require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar_extension" +require "elastic_graph/schema_definition/indexing/field_type/scalar" + +module ElasticGraph + module JSONIngestion + module SchemaDefinition + module Indexing + module FieldType + # JSON-ingestion indexing field type wrapper for scalars. + # + # @private + class Scalar + include ScalarExtension + + def self.wrap(field_type) + new(field_type) + end + + def initialize(field_type) + @field_type = field_type + end + + def scalar_type + @field_type.scalar_type + end + + def to_mapping + @field_type.to_mapping + end + end + end + end + end + end +end diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/union.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/union.rb new file mode 100644 index 000000000..bb7331ae8 --- /dev/null +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/indexing/field_type/union.rb @@ -0,0 +1,43 @@ +# Copyright 2024 - 2026 Block, Inc. +# +# Use of this source code is governed by an MIT-style +# license that can be found in the LICENSE file or at +# https://opensource.org/licenses/MIT. +# +# frozen_string_literal: true + +require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/union_extension" +require "elastic_graph/schema_definition/indexing/field_type/union" + +module ElasticGraph + module JSONIngestion + module SchemaDefinition + module Indexing + module FieldType + # JSON-ingestion indexing field type wrapper for unions. + # + # @private + class Union + include UnionExtension + + def self.wrap(field_type) + new(field_type) + end + + def initialize(field_type) + @field_type = field_type + end + + def subtypes_by_name + @field_type.subtypes_by_name + end + + def to_mapping + @field_type.to_mapping + end + end + end + end + end + end +end diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_artifact_manager_extension.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_artifact_manager_extension.rb index 85e5e150d..c4c0f6ef4 100644 --- a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_artifact_manager_extension.rb +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_artifact_manager_extension.rb @@ -21,7 +21,7 @@ module SchemaArtifactManagerExtension # Overrides `dump_artifacts` to add JSON schema version bump checking before dumping. def dump_artifacts schema_results = json_ingestion_schema_definition_results - state = schema_results.state # : ElasticGraph::SchemaDefinition::State & StateExtension + state = json_ingestion_state check_if_needs_json_schema_version_bump do |recommended_json_schema_version| if state.enforce_json_schema_version @@ -57,6 +57,10 @@ def json_ingestion_schema_definition_results schema_definition_results # : ElasticGraph::SchemaDefinition::Results & ResultsExtension end + def json_ingestion_state + json_ingestion_schema_definition_results.state # : ElasticGraph::SchemaDefinition::State & StateExtension + end + # Overrides the base `artifacts_from_schema_def` method to add JSON schema artifacts. def artifacts_from_schema_def base_artifacts = super @@ -200,7 +204,7 @@ def missing_type_error_for(type, json_schema_versions) To continue, do one of the following: 1. If the `#{type}` type has been renamed, indicate this by calling `type.renamed_from "#{type}"` on the renamed type. - 2. If the `#{type}` field has been dropped, indicate this by calling `schema.deleted_type "#{type}"` on the schema. + 2. If the `#{type}` type has been dropped, indicate this by calling `schema.deleted_type "#{type}"` on the schema. 3. Alternately, if no publishers or in-flight events use #{describe_json_schema_versions(json_schema_versions, "or")}, delete #{files_noun_phrase(json_schema_versions)} from `#{JSON_SCHEMAS_BY_VERSION_DIRECTORY}`, and no further changes are required. EOS end @@ -223,15 +227,14 @@ def missing_necessary_field_error_for(field, json_schema_versions) def describe_json_schema_versions(json_schema_versions, conjunction) json_schema_versions = json_schema_versions.sort - # Steep doesn't support pattern matching yet, so have to skip type checking here. - __skip__ = case json_schema_versions - in [single_version] - "JSON schema version #{single_version}" - in [version1, version2] - "JSON schema versions #{version1} #{conjunction} #{version2}" + case json_schema_versions.size + when 1 + "JSON schema version #{json_schema_versions.first}" + when 2 + "JSON schema versions #{json_schema_versions.first} #{conjunction} #{json_schema_versions.last}" else - *versions, last_version = json_schema_versions - "JSON schema versions #{versions.join(", ")}, #{conjunction} #{last_version}" + versions = json_schema_versions.take(json_schema_versions.size - 1) + "JSON schema versions #{versions.join(", ")}, #{conjunction} #{json_schema_versions.last}" end end diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/enum_type_extension.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/enum_type_extension.rb index 68eb12abd..c0f8f3871 100644 --- a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/enum_type_extension.rb +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/enum_type_extension.rb @@ -6,12 +6,20 @@ # # frozen_string_literal: true +require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum" + module ElasticGraph module JSONIngestion module SchemaDefinition module SchemaElements # Extends enum types with JSON schema behavior. module EnumTypeExtension + # @private + def to_indexing_field_type + field_type = super # : ElasticGraph::SchemaDefinition::Indexing::FieldType::Enum + Indexing::FieldType::Enum.wrap(field_type) + end + # @private def configure_derived_scalar_type(scalar_type) super diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/field_extension.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/field_extension.rb index 6cef4b048..a75ca8a1c 100644 --- a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/field_extension.rb +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/field_extension.rb @@ -22,7 +22,7 @@ def json_schema_options end # @return [Boolean] whether this field has been marked as non-nullable in the JSON schema - def non_nullable_in_json_schema + def non_nullable_in_json_schema? @non_nullable_in_json_schema || false end @@ -30,11 +30,32 @@ def non_nullable_in_json_schema # @param value [Boolean] true to make the field non-nullable attr_writer :non_nullable_in_json_schema - # Configures JSON schema options for this field. + # Defines JSON Schema validations for this field. Validations defined here will be included in the + # generated `json_schemas.yaml` artifact, which ElasticGraph uses to validate events before indexing. + # Publishers may also use the artifact for code generation and validation before publishing events. + # + # Can be called multiple times; each call merges options into the existing set. + # + # Use these validations sparingly. Events that violate JSON Schema validation fail to index, so we + # recommend limiting them to constraints that ElasticGraph needs in order to operate correctly. + # `nullable: false` is also supported to disallow `null` values in indexed data while keeping the + # GraphQL field nullable. # # @param nullable [Boolean, nil] set to `false` to make this field non-nullable in the JSON schema # @param options [Hash] additional JSON schema options # @return [void] + # + # @example Define additional validations on a field + # ElasticGraph.define_schema do |schema| + # schema.object_type "Card" do |t| + # t.field "id", "ID!" + # t.field "expYear", "Int" do |f| + # f.json_schema minimum: 2000, maximum: 2099 + # end + # + # t.index "cards" + # end + # end def json_schema(nullable: nil, **options) if options.key?(:type) raise Errors::SchemaError, "Cannot override JSON schema type of field `#{name}` with `#{options.fetch(:type)}`" @@ -56,7 +77,7 @@ def to_indexing_field_reference reference = super return nil unless reference - type_for_json_schema = (non_nullable_in_json_schema ? type.wrap_non_null : type) # : ElasticGraph::SchemaDefinition::SchemaElements::TypeReference & TypeReferenceExtension + type_for_json_schema = (non_nullable_in_json_schema? ? type.wrap_non_null : type) # : ElasticGraph::SchemaDefinition::SchemaElements::TypeReference & TypeReferenceExtension Indexing::FieldReference.new( field_reference: reference.with(type: type_for_json_schema), diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/object_interface_extension.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/object_interface_extension.rb index 8a207e273..6ef275677 100644 --- a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/object_interface_extension.rb +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/object_interface_extension.rb @@ -6,6 +6,8 @@ # # frozen_string_literal: true +require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/object" +require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/union" require "elastic_graph/json_ingestion/schema_definition/json_schema_option_validator" module ElasticGraph @@ -19,7 +21,10 @@ def json_schema_options @json_schema_options ||= {} end - # Configures JSON schema options for this object or interface type. + # Configures JSON Schema options for this object or interface type. + # + # Can be called multiple times; each call merges options into the existing set. When options are present, + # they replace ElasticGraph's generated object schema for this type. # # @param options [Hash] JSON schema options # @return [void] @@ -30,12 +35,14 @@ def json_schema(**options) # @private def to_indexing_field_type - # @type var field_type: (ElasticGraph::SchemaDefinition::Indexing::FieldType::Object & Indexing::FieldType::ObjectExtension) | ElasticGraph::SchemaDefinition::Indexing::FieldType::Union + # @type var field_type: ElasticGraph::SchemaDefinition::Indexing::FieldType::Object | ElasticGraph::SchemaDefinition::Indexing::FieldType::Union field_type = _ = super - return field_type if field_type.is_a?(ElasticGraph::SchemaDefinition::Indexing::FieldType::Union) + if field_type.is_a?(ElasticGraph::SchemaDefinition::Indexing::FieldType::Union) + return Indexing::FieldType::Union.wrap(field_type) + end - field_type.with_json_schema_options(json_schema_options) + Indexing::FieldType::Object.wrap(field_type, json_schema_options: json_schema_options) end end end diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension.rb index 29d02c2b9..2f0e56a1b 100644 --- a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension.rb +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension.rb @@ -6,6 +6,7 @@ # # frozen_string_literal: true +require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar" require "elastic_graph/json_ingestion/schema_definition/json_schema_option_validator" module ElasticGraph @@ -19,16 +20,33 @@ def json_schema_options @json_schema_options ||= {} end - # Configures JSON schema options for this scalar type. + # Defines the JSON Schema representation of this scalar type. This is required for custom scalar types + # because ElasticGraph cannot infer how arbitrary scalars are represented in indexing events. + # + # Can be called multiple times; each call merges options into the existing set. # # @param options [Hash] JSON schema options # @return [void] + # + # @example Define the JSON Schema representation of a custom scalar type + # ElasticGraph.define_schema do |schema| + # schema.scalar_type "URL" do |t| + # t.mapping type: "keyword" + # t.json_schema type: "string", format: "uri" + # end + # end def json_schema(**options) JSONSchemaOptionValidator.validate!(self, options) json_schema_options.update(options) self.runtime_metadata = runtime_metadata.with(grouping_missing_value_placeholder: inferred_grouping_missing_value_placeholder) unless grouping_missing_value_placeholder_overridden end + # @private + def to_indexing_field_type + field_type = super # : ElasticGraph::SchemaDefinition::Indexing::FieldType::Scalar + Indexing::FieldType::Scalar.wrap(field_type) + end + # Validates that json_schema has been configured on this scalar type. # # @raise [Errors::SchemaError] if json_schema has not been configured diff --git a/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/union_type_extension.rb b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/union_type_extension.rb new file mode 100644 index 000000000..5e4b913d9 --- /dev/null +++ b/elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/union_type_extension.rb @@ -0,0 +1,26 @@ +# Copyright 2024 - 2026 Block, Inc. +# +# Use of this source code is governed by an MIT-style +# license that can be found in the LICENSE file or at +# https://opensource.org/licenses/MIT. +# +# frozen_string_literal: true + +require "elastic_graph/json_ingestion/schema_definition/indexing/field_type/union" + +module ElasticGraph + module JSONIngestion + module SchemaDefinition + module SchemaElements + # Extends union types with JSON schema behavior. + module UnionTypeExtension + # @private + def to_indexing_field_type + field_type = super # : ElasticGraph::SchemaDefinition::Indexing::FieldType::Union + Indexing::FieldType::Union.wrap(field_type) + end + end + end + end + end +end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/factory_extension.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/factory_extension.rbs index 0eb4732df..c9ef38279 100644 --- a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/factory_extension.rbs +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/factory_extension.rbs @@ -11,6 +11,7 @@ module ElasticGraph def new_type_reference: (::String) -> ::ElasticGraph::SchemaDefinition::SchemaElements::TypeReference def new_results: () -> ::ElasticGraph::SchemaDefinition::Results def new_schema_artifact_manager: (**untyped) -> ::ElasticGraph::SchemaDefinition::SchemaArtifactManager + def new_union_type: (::String) ?{ (::ElasticGraph::SchemaDefinition::SchemaElements::UnionType & SchemaElements::UnionTypeExtension) -> void } -> (::ElasticGraph::SchemaDefinition::SchemaElements::UnionType & SchemaElements::UnionTypeExtension) end end end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type.rbs index 96995e7fc..f3c0cb648 100644 --- a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type.rbs +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type.rbs @@ -2,11 +2,31 @@ module ElasticGraph module JSONIngestion module SchemaDefinition module Indexing + interface _EnumFieldType + def enum_value_names: () -> ::Array[::String] + end + interface _JSONFieldType def json_schema_field_metadata_by_field_name: () -> ::Hash[::String, JSONSchemaFieldMetadata] def format_field_json_schema_customizations: (::Hash[::String, untyped]) -> ::Hash[::String, untyped] def to_json_schema: () -> ::Hash[::String, untyped] end + + interface _ObjectFieldType + def schema_def_state: () -> ::ElasticGraph::SchemaDefinition::State + def type_name: () -> ::String + def subfields: () -> ::Array[::ElasticGraph::SchemaDefinition::Indexing::Field] + def mapping_options: () -> ::ElasticGraph::SchemaDefinition::Mixins::HasTypeInfo::optionsHash + def doc_comment: () -> ::String? + end + + interface _ScalarFieldType + def scalar_type: () -> ::ElasticGraph::SchemaDefinition::SchemaElements::ScalarType + end + + interface _UnionFieldType + def subtypes_by_name: () -> ::Hash[::String, ::Object] + end end end end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum.rbs new file mode 100644 index 000000000..fbaec0f21 --- /dev/null +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum.rbs @@ -0,0 +1,20 @@ +module ElasticGraph + module JSONIngestion + module SchemaDefinition + module Indexing + module FieldType + class Enum + include ::ElasticGraph::SchemaDefinition::Indexing::_FieldType + include _EnumFieldType + include EnumExtension + + @field_type: ::ElasticGraph::SchemaDefinition::Indexing::FieldType::Enum + + def self.wrap: (::ElasticGraph::SchemaDefinition::Indexing::FieldType::Enum) -> Enum + def initialize: (::ElasticGraph::SchemaDefinition::Indexing::FieldType::Enum) -> void + end + end + end + end + end +end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum_extension.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum_extension.rbs index 88147e1d0..1d72b1dc8 100644 --- a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum_extension.rbs +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/enum_extension.rbs @@ -3,7 +3,7 @@ module ElasticGraph module SchemaDefinition module Indexing module FieldType - module EnumExtension: ::ElasticGraph::SchemaDefinition::Indexing::FieldType::Enum + module EnumExtension: _EnumFieldType include _JSONFieldType end end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/object.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/object.rbs new file mode 100644 index 000000000..86404ae6b --- /dev/null +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/object.rbs @@ -0,0 +1,24 @@ +module ElasticGraph + module JSONIngestion + module SchemaDefinition + module Indexing + module FieldType + class Object + include ::ElasticGraph::SchemaDefinition::Indexing::_FieldType + include _ObjectFieldType + include ObjectExtension + + @field_type: ::ElasticGraph::SchemaDefinition::Indexing::FieldType::Object + + def self.wrap: ( + ::ElasticGraph::SchemaDefinition::Indexing::FieldType::Object, + json_schema_options: ::Hash[::Symbol, untyped] + ) -> Object + + def initialize: (::ElasticGraph::SchemaDefinition::Indexing::FieldType::Object) -> void + end + end + end + end + end +end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/object_extension.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/object_extension.rbs index ea21f0f48..5da75c442 100644 --- a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/object_extension.rbs +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/object_extension.rbs @@ -3,14 +3,14 @@ module ElasticGraph module SchemaDefinition module Indexing module FieldType - module ObjectExtension: ::ElasticGraph::SchemaDefinition::Indexing::FieldType::Object + module ObjectExtension: _ObjectFieldType include _JSONFieldType @json_schema_options: ::Hash[::Symbol, untyped] @to_json_schema: ::Hash[::String, untyped]? def json_schema_options: () -> ::Hash[::Symbol, untyped] - def with_json_schema_options: (::Hash[::Symbol, untyped]) -> (::ElasticGraph::SchemaDefinition::Indexing::FieldType::Object & ObjectExtension) + def with_json_schema_options: (::Hash[::Symbol, untyped]) -> self private diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar.rbs new file mode 100644 index 000000000..6b80e6a0d --- /dev/null +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar.rbs @@ -0,0 +1,20 @@ +module ElasticGraph + module JSONIngestion + module SchemaDefinition + module Indexing + module FieldType + class Scalar + include ::ElasticGraph::SchemaDefinition::Indexing::_FieldType + include _ScalarFieldType + include ScalarExtension + + @field_type: ::ElasticGraph::SchemaDefinition::Indexing::FieldType::Scalar + + def self.wrap: (::ElasticGraph::SchemaDefinition::Indexing::FieldType::Scalar) -> Scalar + def initialize: (::ElasticGraph::SchemaDefinition::Indexing::FieldType::Scalar) -> void + end + end + end + end + end +end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar_extension.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar_extension.rbs index 139241fbb..db66862eb 100644 --- a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar_extension.rbs +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/scalar_extension.rbs @@ -3,7 +3,7 @@ module ElasticGraph module SchemaDefinition module Indexing module FieldType - module ScalarExtension: ::ElasticGraph::SchemaDefinition::Indexing::FieldType::Scalar + module ScalarExtension: _ScalarFieldType include _JSONFieldType end end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/union.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/union.rbs new file mode 100644 index 000000000..1da0f0bc2 --- /dev/null +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/union.rbs @@ -0,0 +1,20 @@ +module ElasticGraph + module JSONIngestion + module SchemaDefinition + module Indexing + module FieldType + class Union + include ::ElasticGraph::SchemaDefinition::Indexing::_FieldType + include _UnionFieldType + include UnionExtension + + @field_type: ::ElasticGraph::SchemaDefinition::Indexing::FieldType::Union + + def self.wrap: (::ElasticGraph::SchemaDefinition::Indexing::FieldType::Union) -> Union + def initialize: (::ElasticGraph::SchemaDefinition::Indexing::FieldType::Union) -> void + end + end + end + end + end +end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/union_extension.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/union_extension.rbs index 9817d218b..b92244088 100644 --- a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/union_extension.rbs +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/indexing/field_type/union_extension.rbs @@ -3,7 +3,7 @@ module ElasticGraph module SchemaDefinition module Indexing module FieldType - module UnionExtension: ::ElasticGraph::SchemaDefinition::Indexing::FieldType::Union + module UnionExtension: _UnionFieldType include _JSONFieldType end end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_artifact_manager_extension.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_artifact_manager_extension.rbs index b03bd3001..107769d01 100644 --- a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_artifact_manager_extension.rbs +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_artifact_manager_extension.rbs @@ -1,12 +1,13 @@ module ElasticGraph module JSONIngestion - module SchemaDefinition + module SchemaDefinition module SchemaArtifactManagerExtension : ::ElasticGraph::SchemaDefinition::SchemaArtifactManager private @json_schemas_artifact: ::ElasticGraph::SchemaDefinition::SchemaArtifact[untyped]? def json_ingestion_schema_definition_results: () -> (::ElasticGraph::SchemaDefinition::Results & ResultsExtension) + def json_ingestion_state: () -> (::ElasticGraph::SchemaDefinition::State & StateExtension) def artifacts_from_schema_def: () -> ::Array[::ElasticGraph::SchemaDefinition::SchemaArtifact[untyped]] def json_schemas_artifact: () -> ::ElasticGraph::SchemaDefinition::SchemaArtifact[::Hash[::String, untyped]] def check_if_needs_json_schema_version_bump: () { (::Integer) -> void } -> void diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/enum_type_extension.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/enum_type_extension.rbs index 12d81c14b..df48b35e5 100644 --- a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/enum_type_extension.rbs +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/enum_type_extension.rbs @@ -3,6 +3,8 @@ module ElasticGraph module SchemaDefinition module SchemaElements module EnumTypeExtension: ::ElasticGraph::SchemaDefinition::SchemaElements::EnumType + def to_indexing_field_type: () -> Indexing::FieldType::Enum + private def configure_derived_scalar_type: (::ElasticGraph::SchemaDefinition::SchemaElements::ScalarType & ScalarTypeExtension) -> void diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/field_extension.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/field_extension.rbs index 0236ddb92..bedec735d 100644 --- a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/field_extension.rbs +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/field_extension.rbs @@ -7,7 +7,7 @@ module ElasticGraph @non_nullable_in_json_schema: bool def json_schema_options: () -> ::Hash[::Symbol, untyped] - def non_nullable_in_json_schema: () -> bool + def non_nullable_in_json_schema?: () -> bool def json_schema: (?nullable: bool?, **untyped) -> void def to_indexing_field_reference: () -> Indexing::FieldReference? end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/object_interface_extension.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/object_interface_extension.rbs index 5fcf3774f..161725cac 100644 --- a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/object_interface_extension.rbs +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/object_interface_extension.rbs @@ -7,7 +7,7 @@ module ElasticGraph def json_schema_options: () -> ::Hash[::Symbol, untyped] def json_schema: (**untyped) -> void - def to_indexing_field_type: () -> ((::ElasticGraph::SchemaDefinition::Indexing::FieldType::Object & Indexing::FieldType::ObjectExtension) | ::ElasticGraph::SchemaDefinition::Indexing::FieldType::Union) + def to_indexing_field_type: () -> (Indexing::FieldType::Object | Indexing::FieldType::Union) end end end diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension.rbs index c659b4ec8..b4c358560 100644 --- a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension.rbs +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension.rbs @@ -7,6 +7,7 @@ module ElasticGraph def json_schema_options: () -> ::Hash[::Symbol, untyped] def json_schema: (**untyped) -> void + def to_indexing_field_type: () -> Indexing::FieldType::Scalar def validate_json_schema_configuration!: () -> void private diff --git a/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/union_type_extension.rbs b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/union_type_extension.rbs new file mode 100644 index 000000000..b50259a96 --- /dev/null +++ b/elasticgraph-json_ingestion/sig/elastic_graph/json_ingestion/schema_definition/schema_elements/union_type_extension.rbs @@ -0,0 +1,11 @@ +module ElasticGraph + module JSONIngestion + module SchemaDefinition + module SchemaElements + module UnionTypeExtension: ::ElasticGraph::SchemaDefinition::SchemaElements::UnionType + def to_indexing_field_type: () -> Indexing::FieldType::Union + end + end + end + end +end diff --git a/elasticgraph-local/lib/elastic_graph/local/rake_tasks.rb b/elasticgraph-local/lib/elastic_graph/local/rake_tasks.rb index a8b55e1b5..c23887280 100644 --- a/elasticgraph-local/lib/elastic_graph/local/rake_tasks.rb +++ b/elasticgraph-local/lib/elastic_graph/local/rake_tasks.rb @@ -168,7 +168,7 @@ class RakeTasks < ::Rake::TaskLib # local_config_yaml: "config/settings/local.yaml", # path_to_schema: "config/schema.rb" # ) do |tasks| - # tasks.schema_definition_extension_modules = [ElasticGraph::Apollo::SchemaDefinition::APIExtension] + # tasks.schema_definition_extension_modules += [ElasticGraph::Apollo::SchemaDefinition::APIExtension] # end # # @example Extension that defines a `@since` directive and offers a `since` API on fields @@ -207,7 +207,7 @@ class RakeTasks < ::Rake::TaskLib # local_config_yaml: "config/settings/local.yaml", # path_to_schema: "config/schema.rb" # ) do |tasks| - # tasks.schema_definition_extension_modules = [SinceExtension] + # tasks.schema_definition_extension_modules += [SinceExtension] # end # # @dynamic schema_definition_extension_modules, schema_definition_extension_modules= diff --git a/elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_type_info.rb b/elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_type_info.rb index d805b964b..577ef1b27 100644 --- a/elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_type_info.rb +++ b/elasticgraph-schema_definition/lib/elastic_graph/schema_definition/mixins/has_type_info.rb @@ -40,7 +40,8 @@ def json_schema_options # Records JSON schema options for this element. # # The default implementation is a no-op; an ingestion-serializer extension overrides this on the - # elements it extends to apply real validation and storage. + # elements it extends to apply real validation and storage. The default JSON ingestion extension + # provides the user-facing behavior and documentation for this API. # # @param options [Hash] JSON schema options # @return [void] diff --git a/elasticgraph-schema_definition/spec/integration/elastic_graph/schema_definition/rake_tasks_spec.rb b/elasticgraph-schema_definition/spec/integration/elastic_graph/schema_definition/rake_tasks_spec.rb index 8770feb53..cf465bbe4 100644 --- a/elasticgraph-schema_definition/spec/integration/elastic_graph/schema_definition/rake_tasks_spec.rb +++ b/elasticgraph-schema_definition/spec/integration/elastic_graph/schema_definition/rake_tasks_spec.rb @@ -595,7 +595,7 @@ module SchemaDefinition To continue, do one of the following: 1. If the `Component` type has been renamed, indicate this by calling `type.renamed_from "Component"` on the renamed type. - 2. If the `Component` field has been dropped, indicate this by calling `schema.deleted_type "Component"` on the schema. + 2. If the `Component` type has been dropped, indicate this by calling `schema.deleted_type "Component"` on the schema. 3. Alternately, if no publishers or in-flight events use JSON schema version 1, delete its file from `json_schemas_by_version`, and no further changes are required. EOS @@ -610,7 +610,7 @@ module SchemaDefinition To continue, do one of the following: 1. If the `Component` type has been renamed, indicate this by calling `type.renamed_from "Component"` on the renamed type. - 2. If the `Component` field has been dropped, indicate this by calling `schema.deleted_type "Component"` on the schema. + 2. If the `Component` type has been dropped, indicate this by calling `schema.deleted_type "Component"` on the schema. 3. Alternately, if no publishers or in-flight events use JSON schema versions 1 or 2, delete their files from `json_schemas_by_version`, and no further changes are required. EOS @@ -625,7 +625,7 @@ module SchemaDefinition To continue, do one of the following: 1. If the `Component` type has been renamed, indicate this by calling `type.renamed_from "Component"` on the renamed type. - 2. If the `Component` field has been dropped, indicate this by calling `schema.deleted_type "Component"` on the schema. + 2. If the `Component` type has been dropped, indicate this by calling `schema.deleted_type "Component"` on the schema. 3. Alternately, if no publishers or in-flight events use JSON schema versions 1, 2, or 3, delete their files from `json_schemas_by_version`, and no further changes are required. EOS diff --git a/elasticgraph-schema_definition/spec/unit/elastic_graph/schema_definition/json_schema_field_metadata_spec.rb b/elasticgraph-schema_definition/spec/unit/elastic_graph/schema_definition/json_schema_field_metadata_spec.rb index 664e1c041..450ae447d 100644 --- a/elasticgraph-schema_definition/spec/unit/elastic_graph/schema_definition/json_schema_field_metadata_spec.rb +++ b/elasticgraph-schema_definition/spec/unit/elastic_graph/schema_definition/json_schema_field_metadata_spec.rb @@ -85,7 +85,7 @@ module SchemaDefinition expect(json_schema_field_metadata).to all eq({}) end - it "generates no field metadata for user-defined union or interface types since the JSON schema" do + it "generates no field metadata for user-defined union or interface types since they have no direct JSON fields" do metadata_by_type_and_field_name = dump_metadata do |schema| schema.interface_type "Named" do |t| t.field "name", "String" diff --git a/elasticgraph-warehouse/lib/elastic_graph/warehouse.rb b/elasticgraph-warehouse/lib/elastic_graph/warehouse.rb index 6d079dc6c..c2bee2343 100644 --- a/elasticgraph-warehouse/lib/elastic_graph/warehouse.rb +++ b/elasticgraph-warehouse/lib/elastic_graph/warehouse.rb @@ -19,7 +19,7 @@ module ElasticGraph # local_config_yaml: "config/settings/local.yaml", # path_to_schema: "config/schema.rb" # ) do |tasks| - # tasks.schema_definition_extension_modules = [ + # tasks.schema_definition_extension_modules += [ # ElasticGraph::Warehouse::SchemaDefinition::APIExtension # ] # end diff --git a/elasticgraph-warehouse/lib/elastic_graph/warehouse/schema_definition/api_extension.rb b/elasticgraph-warehouse/lib/elastic_graph/warehouse/schema_definition/api_extension.rb index 8a0f50ce4..9ef1e5210 100644 --- a/elasticgraph-warehouse/lib/elastic_graph/warehouse/schema_definition/api_extension.rb +++ b/elasticgraph-warehouse/lib/elastic_graph/warehouse/schema_definition/api_extension.rb @@ -29,7 +29,7 @@ module SchemaDefinition # local_config_yaml: "config/settings/local.yaml", # path_to_schema: "config/schema.rb" # ) do |tasks| - # tasks.schema_definition_extension_modules = [ + # tasks.schema_definition_extension_modules += [ # ElasticGraph::Warehouse::SchemaDefinition::APIExtension # ] # end