From aad17db04ca6225c387b38cd98cacf43af650510 Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Fri, 29 Sep 2023 23:14:17 -0500 Subject: [PATCH 1/3] new frontmatter schema definitions --- xml_converter/generators/code_generator.py | 258 +-------------------- xml_converter/generators/schema.py | 191 +++++++++++++++ 2 files changed, 194 insertions(+), 255 deletions(-) create mode 100644 xml_converter/generators/schema.py diff --git a/xml_converter/generators/code_generator.py b/xml_converter/generators/code_generator.py index dbd5c683..ef193af6 100644 --- a/xml_converter/generators/code_generator.py +++ b/xml_converter/generators/code_generator.py @@ -9,264 +9,12 @@ from jinja2 import Template, FileSystemLoader, Environment from jinja_helpers import UnindentBlocks -SchemaType = Dict[str, Any] -schema = """ -type: object -properties: - type: - type: string - enum: [Int32, Fixed32, Float32, String, Boolean, MultiflagValue, Enum, CompoundValue, Custom, CompoundCustomClass] -allOf: - ############################# - # Int32 Type - ############################# - - if: - properties: - type: - const: Int32 - then: - additionalProperties: false - required: [{shared_fields}] - properties: - {shared_field_properties} - - ############################# - # Fixed32 Type - ############################# - - if: - properties: - type: - const: Fixed32 - then: - additionalProperties: false - required: [{shared_fields}] - properties: - {shared_field_properties} - - ############################# - # Float32 Type - ############################# - - if: - properties: - type: - const: Float32 - then: - additionalProperties: false - required: [{shared_fields}] - properties: - {shared_field_properties} - - ############################# - # String Type - ############################# - - if: - properties: - type: - const: String - then: - additionalProperties: false - required: [{shared_fields}] - properties: - {shared_field_properties} - - ############################# - # Boolean Type - ############################# - - if: - properties: - type: - const: Boolean - then: - additionalProperties: false - required: [{shared_fields}] - properties: - {shared_field_properties} - - ############################# - # MultiflagValue Type - ############################# - - if: - properties: - type: - const: MultiflagValue - then: - additionalProperties: false - required: [{shared_fields}, flags] - properties: - {shared_field_properties} - flags: - type: object - patternProperties: - "^[a-z_]+$": - type: array - items: - type: string - - ############################# - # Enum Type - ############################# - - if: - properties: - type: - const: Enum - then: - additionalProperties: false - required: [{shared_fields}, values] - properties: - {shared_field_properties} - values: - type: object - patternProperties: - "^[a-z_]+$": - type: array - items: - type: string - - ############################# - # CompoundValue Type - ############################# - - if: - properties: - type: - const: CompoundValue - then: - additionalProperties: false - required: [{shared_fields}, xml_bundled_components, xml_separate_components, components] - properties: - {shared_field_properties} - xml_bundled_components: - type: array - items: - type: string - xml_separate_components: - type: array - items: - type: string - components: - type: array - items: - type: object - additionalProperties: false - required: [name, type, xml_fields, protobuf_field, compatability] - properties: - name: - type: string - type: - type: string - enum: [Int32, Fixed32, Float32] - xml_fields: - type: array - items: - type: string - pattern: "^[A-Za-z]+$" - protobuf_field: - type: string - pattern: "^[a-z_.]+$" - compatability: - type: array - items: - type: string - enum: [BlishHUD, Burrito, TacO] - ############################# - # CompoundCustomClass Type - ############################# - - if: - properties: - type: - const: CompoundCustomClass - then: - additionalProperties: false - required: [{shared_fields}, xml_bundled_components, xml_separate_components, class] - properties: - {shared_field_properties} - class: - type: string - xml_bundled_components: - type: array - items: - type: string - xml_separate_components: - type: array - items: - type: string - components: - type: array - items: - type: object - additionalProperties: false - required: [name, type, xml_fields, protobuf_field, compatability] - properties: - name: - type: string - type: - type: string - enum: [Int32, Fixed32, Float32] - xml_fields: - type: array - items: - type: string - pattern: "^[A-Za-z]+$" - protobuf_field: - type: string - pattern: "^[a-z_.]+$" - compatability: - type: array - items: - type: string - enum: [BlishHUD, Burrito, TacO] - - ############################# - # Custom Type - ############################# - - if: - properties: - type: - const: Custom - then: - additionalProperties: false - required: [{shared_fields}, class] - properties: - {shared_field_properties} - class: - type: string - side_effects: - type: array - items: - type: string - uses_file_path: - type: boolean - -""".format( - shared_field_properties="""type: - type: string - name: - type: string - applies_to: - type: array - items: - type: string - enum: [Icon, Trail, Category] - compatability: - type: array - items: - type: string - enum: [BlishHUD, Burrito, TacO] - xml_fields: - type: array - items: - type: string - pattern: "^[A-Za-z]+$" - protobuf_field: - type: string - pattern: "^[a-z_.]+$" - """, - shared_fields="type, name, applies_to, compatability, xml_fields, protobuf_field" -) - +from schema import schema +SchemaType = Dict[str, Any] def validate_front_matter_schema(front_matter: Any) -> str: try: - validate(front_matter, yaml.safe_load(schema)) + validate(front_matter, schema) except ValidationError as e: return "Error Message: {} (Path: {}".format(e.message, e.json_path) return "" diff --git a/xml_converter/generators/schema.py b/xml_converter/generators/schema.py new file mode 100644 index 00000000..8a75dd5f --- /dev/null +++ b/xml_converter/generators/schema.py @@ -0,0 +1,191 @@ +from jsonschema import validate # type:ignore +from jsonschema.exceptions import ValidationError # type:ignore +from typing import Any, Optional, List, Dict, Iterable, TypedDict, Literal, Union, Tuple +import yaml + + +################################################################################ +# A union type of all of the different type helpers found below +################################################################################ +DefType = Union[ + "StringDef", + "BooleanDef", + "EnumDef", + "ArrayDef", + "ObjectDef", + "PatternDictionaryDef" +]; + + +################################################################################ +# String Definition Helpers +# +# +################################################################################ +class BaseStringDef(TypedDict): + type: Literal["string"] +class StringDef(BaseStringDef, total=False): + pattern: Optional[str] +def string_t(pattern: Optional[str] = None) -> StringDef: + if pattern is None: + return { + "type": "string" + } + else: + return { + "type": "string", + "pattern": pattern, + } + +class BooleanDef(TypedDict): + type: Literal["boolean"] +def boolean_t() -> BooleanDef: + return { + "type": "boolean" + } + +class EnumDef(TypedDict): + type: Literal["string"] + enum: List[str] +def enum_t(options: Iterable[str]) -> EnumDef: + return { + "type": "string", + "enum": list(options) + } + +class ArrayDef(TypedDict): + type: Literal["array"] + items: DefType +def array_t(element_type: DefType) -> ArrayDef: + return { + "type": "array", + "items": element_type + } + +class ObjectDef(TypedDict): + type: Literal["object"] + additionalProperties: Literal[False] + required: List[str] + properties: Dict[str, DefType] +def object_t(fields: Dict[str, DefType], optional_fields: Dict[str, DefType] = {}) -> ObjectDef: + return { + "type": "object", + "additionalProperties": False, + "required": list(fields.keys()), + "properties": {**fields, **optional_fields} + } + +class PatternDictionaryDef(TypedDict): + type: Literal["object"] + patternProperties: Dict[str, DefType] +def pattern_dictionary_t(pattern_properties: Dict[str, DefType]) -> PatternDictionaryDef: + return { + "type": "object", + "patternProperties": pattern_properties + } + + +# Helper function for the union types +def union_partial_t(*, required: Dict[str, DefType]={}, optional: Dict[str, DefType]={}) ->Tuple[Dict[str, DefType], Dict[str, DefType]]: + return (required, optional) +upt=union_partial_t + + + +def union_t(options: Dict[str, Tuple[Dict[str, DefType], Dict[str, DefType]]]): + union_type = { + "type": "object", + "properties": { + "type": enum_t(options.keys()) + }, + "allOf": [ + { + "if": { + "properties": { + "type": { + "const": key + } + } + }, + "then": { + "additionalProperties": False, + "required": list(value[0].keys()), + "properties": {**value[0], **value[1]} + } + } + for key, value in options.items()] + } + + return union_type + + +shared_field_properties: Dict[str, DefType] = { + "type": string_t(), + "name": string_t(), + "applies_to": array_t(enum_t(["Icon", "Trail", "Category"])), + # To Be Depricated + "compatability": array_t(enum_t(["BlishHUD", "Burrito", "TacO"])), + "xml_fields": array_t(string_t(pattern="^[A-Za-z]+$")), + "protobuf_field": string_t(pattern="^[a-z_.]+$"), +} + +schema = union_t({ + "Int32": union_partial_t(required=shared_field_properties), + "Fixed32": union_partial_t(required=shared_field_properties), + "Float32": union_partial_t(required=shared_field_properties), + "String": union_partial_t(required=shared_field_properties), + "Boolean": union_partial_t(required=shared_field_properties), + "MultiflagValue": union_partial_t( + required = {**shared_field_properties, **{ + "flags": pattern_dictionary_t({"^[a-z_]+$": array_t(string_t())}), + }}, + ), + "Enum": union_partial_t( + required={**shared_field_properties, **{ + "values": pattern_dictionary_t({"^[a-z_]+$": array_t(string_t())}) + }} + ), + "CompoundValue": union_partial_t( + required={**shared_field_properties, **{ + "xml_bundled_components": array_t(string_t()), + "xml_separate_components": array_t(string_t()), + "components": array_t(object_t({ + "name": string_t(), + "type": enum_t(["Int32", "Fixed32", "Float32"]), + "xml_fields": array_t(string_t("^[A-Za-z]+$")), + "protobuf_field": string_t("^[a-z_.]+$"), + # To Be Depricated + "compatability": array_t(enum_t(["BlishHUD", "Burrito", "TacO"])) + })), + }} + ), + + "CompoundCustomClass": union_partial_t( + required={**shared_field_properties, **{ + "class": string_t(), + "xml_bundled_components": array_t(string_t()), + "xml_separate_components": array_t(string_t()), + "components": array_t(object_t({ + "name": string_t(), + "type": enum_t(["Int32", "Fixed32", "Float32"]), + "xml_fields": array_t(string_t("^[A-Za-z]+$")), + "protobuf_field": string_t("^[a-z_.]+$"), + # To Be Depricated + "compatability": array_t(enum_t(["BlishHUD", "Burrito", "TacO"])) + })), + }} + ), + + "Custom": union_partial_t( + required={**shared_field_properties, **{"class": string_t()}}, + optional={ + "side_effects": array_t(string_t()), + "uses_file_path": boolean_t(), + } + ), +}) + + + + + From ec70b0539a3f5a103435506a176decb6699e1ec2 Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Sat, 30 Sep 2023 03:01:19 -0500 Subject: [PATCH 2/3] linter file cleanups, and upgrading mypy --- xml_converter/generators/code_generator.py | 5 +- xml_converter/generators/requirements.txt | 3 +- xml_converter/generators/schema.py | 66 ++++++++++++++++------ 3 files changed, 53 insertions(+), 21 deletions(-) diff --git a/xml_converter/generators/code_generator.py b/xml_converter/generators/code_generator.py index ef193af6..9d47b4cc 100644 --- a/xml_converter/generators/code_generator.py +++ b/xml_converter/generators/code_generator.py @@ -1,6 +1,5 @@ from jsonschema import validate # type:ignore from jsonschema.exceptions import ValidationError # type:ignore -import yaml import frontmatter # type:ignore from typing import Any, Dict, List, Tuple, Set, Optional, Final import os @@ -8,10 +7,12 @@ from dataclasses import dataclass, field from jinja2 import Template, FileSystemLoader, Environment from jinja_helpers import UnindentBlocks - from schema import schema + SchemaType = Dict[str, Any] + + def validate_front_matter_schema(front_matter: Any) -> str: try: validate(front_matter, schema) diff --git a/xml_converter/generators/requirements.txt b/xml_converter/generators/requirements.txt index 01586b2e..3a17b260 100644 --- a/xml_converter/generators/requirements.txt +++ b/xml_converter/generators/requirements.txt @@ -5,8 +5,7 @@ jsonschema==4.7.2 Markdown==3.4.1 MarkupSafe==2.1.1 mccabe==0.6.1 -mypy==0.971 -mypy-extensions==0.4.3 +mypy==1.5.1 pyaml==21.10.1 pycodestyle==2.8.0 pyflakes==2.4.0 diff --git a/xml_converter/generators/schema.py b/xml_converter/generators/schema.py index 8a75dd5f..335cc2a1 100644 --- a/xml_converter/generators/schema.py +++ b/xml_converter/generators/schema.py @@ -1,7 +1,4 @@ -from jsonschema import validate # type:ignore -from jsonschema.exceptions import ValidationError # type:ignore -from typing import Any, Optional, List, Dict, Iterable, TypedDict, Literal, Union, Tuple -import yaml +from typing import Optional, List, Dict, Iterable, TypedDict, Literal, Union, Tuple ################################################################################ @@ -14,18 +11,22 @@ "ArrayDef", "ObjectDef", "PatternDictionaryDef" -]; +] ################################################################################ # String Definition Helpers # -# +# ################################################################################ class BaseStringDef(TypedDict): type: Literal["string"] + + class StringDef(BaseStringDef, total=False): pattern: Optional[str] + + def string_t(pattern: Optional[str] = None) -> StringDef: if pattern is None: return { @@ -37,36 +38,48 @@ def string_t(pattern: Optional[str] = None) -> StringDef: "pattern": pattern, } + class BooleanDef(TypedDict): type: Literal["boolean"] + + def boolean_t() -> BooleanDef: return { "type": "boolean" } + class EnumDef(TypedDict): type: Literal["string"] enum: List[str] + + def enum_t(options: Iterable[str]) -> EnumDef: return { "type": "string", "enum": list(options) } + class ArrayDef(TypedDict): type: Literal["array"] items: DefType + + def array_t(element_type: DefType) -> ArrayDef: return { "type": "array", "items": element_type } + class ObjectDef(TypedDict): type: Literal["object"] additionalProperties: Literal[False] required: List[str] properties: Dict[str, DefType] + + def object_t(fields: Dict[str, DefType], optional_fields: Dict[str, DefType] = {}) -> ObjectDef: return { "type": "object", @@ -75,9 +88,12 @@ def object_t(fields: Dict[str, DefType], optional_fields: Dict[str, DefType] = { "properties": {**fields, **optional_fields} } + class PatternDictionaryDef(TypedDict): type: Literal["object"] patternProperties: Dict[str, DefType] + + def pattern_dictionary_t(pattern_properties: Dict[str, DefType]) -> PatternDictionaryDef: return { "type": "object", @@ -86,14 +102,34 @@ def pattern_dictionary_t(pattern_properties: Dict[str, DefType]) -> PatternDicti # Helper function for the union types -def union_partial_t(*, required: Dict[str, DefType]={}, optional: Dict[str, DefType]={}) ->Tuple[Dict[str, DefType], Dict[str, DefType]]: +def union_partial_t( + *, + required: Dict[str, DefType] = {}, + optional: Dict[str, DefType] = {} +) -> Tuple[Dict[str, DefType], Dict[str, DefType]]: return (required, optional) -upt=union_partial_t +class UnionBranchThenDef(TypedDict): + additionalProperties: Literal[False] + required: List[str] + properties: Dict[str, DefType] + + +UnionBranchDef = TypedDict('UnionBranchDef', { + 'if': Dict[Literal["properties"], Dict[Literal["type"], Dict[Literal["const"], str]]], + 'then': UnionBranchThenDef, +}) + -def union_t(options: Dict[str, Tuple[Dict[str, DefType], Dict[str, DefType]]]): - union_type = { +class UnionDef(TypedDict): + type: Literal["object"] + properties: Dict[Literal["type"], EnumDef] + allOf: List[UnionBranchDef] + + +def union_t(options: Dict[str, Tuple[Dict[str, DefType], Dict[str, DefType]]]) -> UnionDef: + union_type: UnionDef = { "type": "object", "properties": { "type": enum_t(options.keys()) @@ -113,7 +149,8 @@ def union_t(options: Dict[str, Tuple[Dict[str, DefType], Dict[str, DefType]]]): "properties": {**value[0], **value[1]} } } - for key, value in options.items()] + for key, value in options.items() + ] } return union_type @@ -136,7 +173,7 @@ def union_t(options: Dict[str, Tuple[Dict[str, DefType], Dict[str, DefType]]]): "String": union_partial_t(required=shared_field_properties), "Boolean": union_partial_t(required=shared_field_properties), "MultiflagValue": union_partial_t( - required = {**shared_field_properties, **{ + required={**shared_field_properties, **{ "flags": pattern_dictionary_t({"^[a-z_]+$": array_t(string_t())}), }}, ), @@ -184,8 +221,3 @@ def union_t(options: Dict[str, Tuple[Dict[str, DefType], Dict[str, DefType]]]): } ), }) - - - - - From c68bb42eb0215bebad1a4ea5b06a7eb07f3785ee Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Sat, 30 Sep 2023 03:47:27 -0500 Subject: [PATCH 3/3] moving the schema itself back into the main file and adding more comments to the utility functions --- xml_converter/generators/code_generator.py | 67 +++++++++++- xml_converter/generators/schema.py | 117 +++++++++------------ 2 files changed, 114 insertions(+), 70 deletions(-) diff --git a/xml_converter/generators/code_generator.py b/xml_converter/generators/code_generator.py index 9d47b4cc..b34c6051 100644 --- a/xml_converter/generators/code_generator.py +++ b/xml_converter/generators/code_generator.py @@ -7,12 +7,77 @@ from dataclasses import dataclass, field from jinja2 import Template, FileSystemLoader, Environment from jinja_helpers import UnindentBlocks -from schema import schema +from schema import string_t, array_t, enum_t, union_t, union_partial_t, pattern_dictionary_t, object_t, boolean_t, DefType SchemaType = Dict[str, Any] +shared_field_properties: Dict[str, DefType] = { + "type": string_t(), + "name": string_t(), + "applies_to": array_t(enum_t(["Icon", "Trail", "Category"])), + # To Be Depricated + "compatability": array_t(enum_t(["BlishHUD", "Burrito", "TacO"])), + "xml_fields": array_t(string_t(pattern="^[A-Za-z]+$")), + "protobuf_field": string_t(pattern="^[a-z_.]+$"), +} + +schema = union_t({ + "Int32": union_partial_t(required=shared_field_properties), + "Fixed32": union_partial_t(required=shared_field_properties), + "Float32": union_partial_t(required=shared_field_properties), + "String": union_partial_t(required=shared_field_properties), + "Boolean": union_partial_t(required=shared_field_properties), + "MultiflagValue": union_partial_t( + required={**shared_field_properties, **{ + "flags": pattern_dictionary_t({"^[a-z_]+$": array_t(string_t())}), + }}, + ), + "Enum": union_partial_t( + required={**shared_field_properties, **{ + "values": pattern_dictionary_t({"^[a-z_]+$": array_t(string_t())}) + }} + ), + "CompoundValue": union_partial_t( + required={**shared_field_properties, **{ + "xml_bundled_components": array_t(string_t()), + "xml_separate_components": array_t(string_t()), + "components": array_t(object_t({ + "name": string_t(), + "type": enum_t(["Int32", "Fixed32", "Float32"]), + "xml_fields": array_t(string_t("^[A-Za-z]+$")), + "protobuf_field": string_t("^[a-z_.]+$"), + # To Be Depricated + "compatability": array_t(enum_t(["BlishHUD", "Burrito", "TacO"])) + })), + }} + ), + "CompoundCustomClass": union_partial_t( + required={**shared_field_properties, **{ + "class": string_t(), + "xml_bundled_components": array_t(string_t()), + "xml_separate_components": array_t(string_t()), + "components": array_t(object_t({ + "name": string_t(), + "type": enum_t(["Int32", "Fixed32", "Float32"]), + "xml_fields": array_t(string_t("^[A-Za-z]+$")), + "protobuf_field": string_t("^[a-z_.]+$"), + # To Be Depricated + "compatability": array_t(enum_t(["BlishHUD", "Burrito", "TacO"])) + })), + }} + ), + "Custom": union_partial_t( + required={**shared_field_properties, **{"class": string_t()}}, + optional={ + "side_effects": array_t(string_t()), + "uses_file_path": boolean_t(), + } + ), +}) + + def validate_front_matter_schema(front_matter: Any) -> str: try: validate(front_matter, schema) diff --git a/xml_converter/generators/schema.py b/xml_converter/generators/schema.py index 335cc2a1..d2e9784b 100644 --- a/xml_converter/generators/schema.py +++ b/xml_converter/generators/schema.py @@ -17,7 +17,9 @@ ################################################################################ # String Definition Helpers # -# +# These are used as helpers for string_t() which is a helper for creating a +# "string" jsonschema definition object. Optionally string_t() can be called +# with a regex pattern that will be applied to the json schema. ################################################################################ class BaseStringDef(TypedDict): type: Literal["string"] @@ -39,6 +41,12 @@ def string_t(pattern: Optional[str] = None) -> StringDef: } +################################################################################ +# Boolean Definition Helpers +# +# These are helpers for creating a "boolean" jsonschema definition object. +# boolean_t() does not take any arguments and will always return the same value +################################################################################ class BooleanDef(TypedDict): type: Literal["boolean"] @@ -49,6 +57,13 @@ def boolean_t() -> BooleanDef: } +################################################################################ +# Enumeration Definition Helpers +# +# These are helpers for creating "enum" jsonschema definition objects. These +# are string values that can only be one of a set number of values. The values +# that are allowed are passed into the enum_t() function. +################################################################################ class EnumDef(TypedDict): type: Literal["string"] enum: List[str] @@ -61,6 +76,12 @@ def enum_t(options: Iterable[str]) -> EnumDef: } +################################################################################ +# Array Definition Helpers +# +# Theses are helpers for creating "array" jsonschema definition objects. Arrays +# Take in a subtype that represents the type of their elements. +################################################################################ class ArrayDef(TypedDict): type: Literal["array"] items: DefType @@ -73,6 +94,15 @@ def array_t(element_type: DefType) -> ArrayDef: } +################################################################################ +# Object Definition Helpers +# +# These are helpers for creating object jsonschema definitions. Objects contain +# both required and optional fields. Objects in jsonschema normally just +# denote fields that might exist, but dont force them to exist or prevent other +# fields from existing by default. This helper automatically forces all of the +# required fields to exist, and restricts any non-required non-optional field. +################################################################################ class ObjectDef(TypedDict): type: Literal["object"] additionalProperties: Literal[False] @@ -89,6 +119,13 @@ def object_t(fields: Dict[str, DefType], optional_fields: Dict[str, DefType] = { } +################################################################################ +# Pattern Dictionary Definition Helpers +# +# These are helpers for creating dictionary types that have pattern +# requirements on their keys. This is a special type for jsonschema and it +# may be replaced in the future with something else given its uniqueness. +################################################################################ class PatternDictionaryDef(TypedDict): type: Literal["object"] patternProperties: Dict[str, DefType] @@ -101,7 +138,16 @@ def pattern_dictionary_t(pattern_properties: Dict[str, DefType]) -> PatternDicti } -# Helper function for the union types +################################################################################ +# Union Definition Type +# +# These are helpers for creating union types in jsonschema. Unions seem to be +# very difficult to accomplish in jsonschema but union_t() will abstract all +# of the complexities away, only requiring a map of strings to required and +# optional fields, similar to an object. +################################################################################ +# Helper function for the union types to more easily write required/optional +# tuples inline. def union_partial_t( *, required: Dict[str, DefType] = {}, @@ -154,70 +200,3 @@ def union_t(options: Dict[str, Tuple[Dict[str, DefType], Dict[str, DefType]]]) - } return union_type - - -shared_field_properties: Dict[str, DefType] = { - "type": string_t(), - "name": string_t(), - "applies_to": array_t(enum_t(["Icon", "Trail", "Category"])), - # To Be Depricated - "compatability": array_t(enum_t(["BlishHUD", "Burrito", "TacO"])), - "xml_fields": array_t(string_t(pattern="^[A-Za-z]+$")), - "protobuf_field": string_t(pattern="^[a-z_.]+$"), -} - -schema = union_t({ - "Int32": union_partial_t(required=shared_field_properties), - "Fixed32": union_partial_t(required=shared_field_properties), - "Float32": union_partial_t(required=shared_field_properties), - "String": union_partial_t(required=shared_field_properties), - "Boolean": union_partial_t(required=shared_field_properties), - "MultiflagValue": union_partial_t( - required={**shared_field_properties, **{ - "flags": pattern_dictionary_t({"^[a-z_]+$": array_t(string_t())}), - }}, - ), - "Enum": union_partial_t( - required={**shared_field_properties, **{ - "values": pattern_dictionary_t({"^[a-z_]+$": array_t(string_t())}) - }} - ), - "CompoundValue": union_partial_t( - required={**shared_field_properties, **{ - "xml_bundled_components": array_t(string_t()), - "xml_separate_components": array_t(string_t()), - "components": array_t(object_t({ - "name": string_t(), - "type": enum_t(["Int32", "Fixed32", "Float32"]), - "xml_fields": array_t(string_t("^[A-Za-z]+$")), - "protobuf_field": string_t("^[a-z_.]+$"), - # To Be Depricated - "compatability": array_t(enum_t(["BlishHUD", "Burrito", "TacO"])) - })), - }} - ), - - "CompoundCustomClass": union_partial_t( - required={**shared_field_properties, **{ - "class": string_t(), - "xml_bundled_components": array_t(string_t()), - "xml_separate_components": array_t(string_t()), - "components": array_t(object_t({ - "name": string_t(), - "type": enum_t(["Int32", "Fixed32", "Float32"]), - "xml_fields": array_t(string_t("^[A-Za-z]+$")), - "protobuf_field": string_t("^[a-z_.]+$"), - # To Be Depricated - "compatability": array_t(enum_t(["BlishHUD", "Burrito", "TacO"])) - })), - }} - ), - - "Custom": union_partial_t( - required={**shared_field_properties, **{"class": string_t()}}, - optional={ - "side_effects": array_t(string_t()), - "uses_file_path": boolean_t(), - } - ), -})