typia 13.0.0-dev.20260430 → 13.0.0-dev.20260502-2
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.
- package/lib/executable/TypiaGenerateWizard.js +55 -8
- package/lib/executable/TypiaGenerateWizard.js.map +1 -1
- package/lib/executable/TypiaGenerateWizard2.mjs +55 -8
- package/lib/executable/TypiaGenerateWizard2.mjs.map +1 -1
- package/lib/executable/generate/ttsc.js.map +1 -1
- package/lib/executable/setup/PluginConfigurator.js.map +1 -1
- package/lib/internal/_randomInteger.js.map +1 -1
- package/lib/internal/_validateReport.js.map +1 -1
- package/lib/transform.d.ts +2 -13
- package/lib/transform.js +4 -11
- package/lib/transform.js.map +1 -1
- package/lib/transform2.mjs +6 -14
- package/lib/transform2.mjs.map +1 -1
- package/native/adapter/adapter.go +128 -128
- package/native/adapter/cleanup.go +155 -172
- package/native/adapter/imports.go +80 -80
- package/native/adapter/visit.go +142 -142
- package/native/cmd/ttsc-typia/build.go +223 -223
- package/native/cmd/ttsc-typia/main.go +57 -57
- package/native/cmd/ttsc-typia/transform.go +421 -254
- package/native/cmd/ttsc-typia/transform_test.go +40 -0
- package/native/core/context/IProgrammerProps.go +7 -7
- package/native/core/context/ITransformOptions.go +5 -5
- package/native/core/context/ITypiaContext.go +13 -13
- package/native/core/context/TransformerError.go +81 -81
- package/native/core/factories/CommentFactory.go +9 -9
- package/native/core/factories/ExpressionFactory.go +254 -254
- package/native/core/factories/FormatCheatSheet.go +23 -23
- package/native/core/factories/IdentifierFactory.go +130 -130
- package/native/core/factories/JsonMetadataFactory.go +129 -129
- package/native/core/factories/LiteralFactory.go +195 -182
- package/native/core/factories/MetadataCommentTagFactory.go +379 -379
- package/native/core/factories/MetadataFactory.go +462 -462
- package/native/core/factories/MetadataTypeTagFactory.go +498 -498
- package/native/core/factories/MetadataTypeTagSchemaFactory.go +102 -102
- package/native/core/factories/NumericRangeFactory.go +84 -84
- package/native/core/factories/ProtobufFactory.go +933 -933
- package/native/core/factories/StatementFactory.go +72 -72
- package/native/core/factories/TemplateFactory.go +57 -57
- package/native/core/factories/TypeFactory.go +125 -125
- package/native/core/factories/ValueFactory.go +12 -12
- package/native/core/factories/internal/metadata/IMetadataIteratorProps.go +35 -35
- package/native/core/factories/internal/metadata/MetadataHelper.go +176 -176
- package/native/core/factories/internal/metadata/emend_metadata_atomics.go +69 -69
- package/native/core/factories/internal/metadata/emplace_metadata_alias.go +27 -27
- package/native/core/factories/internal/metadata/emplace_metadata_array_type.go +33 -33
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +209 -209
- package/native/core/factories/internal/metadata/emplace_metadata_tuple.go +50 -50
- package/native/core/factories/internal/metadata/explore_metadata.go +29 -29
- package/native/core/factories/internal/metadata/iterate_metadata.go +46 -46
- package/native/core/factories/internal/metadata/iterate_metadata_alias.go +25 -25
- package/native/core/factories/internal/metadata/iterate_metadata_array.go +65 -65
- package/native/core/factories/internal/metadata/iterate_metadata_atomic.go +49 -49
- package/native/core/factories/internal/metadata/iterate_metadata_coalesce.go +22 -22
- package/native/core/factories/internal/metadata/iterate_metadata_collection.go +228 -228
- package/native/core/factories/internal/metadata/iterate_metadata_comment_tags.go +12 -12
- package/native/core/factories/internal/metadata/iterate_metadata_constant.go +71 -71
- package/native/core/factories/internal/metadata/iterate_metadata_escape.go +48 -48
- package/native/core/factories/internal/metadata/iterate_metadata_function.go +82 -82
- package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +319 -319
- package/native/core/factories/internal/metadata/iterate_metadata_map.go +51 -51
- package/native/core/factories/internal/metadata/iterate_metadata_native.go +85 -85
- package/native/core/factories/internal/metadata/iterate_metadata_object.go +27 -27
- package/native/core/factories/internal/metadata/iterate_metadata_set.go +37 -37
- package/native/core/factories/internal/metadata/iterate_metadata_sort.go +137 -137
- package/native/core/factories/internal/metadata/iterate_metadata_template.go +33 -33
- package/native/core/factories/internal/metadata/iterate_metadata_tuple.go +16 -16
- package/native/core/factories/internal/metadata/iterate_metadata_union.go +18 -18
- package/native/core/programmers/AssertProgrammer.go +389 -389
- package/native/core/programmers/ImportProgrammer.go +196 -196
- package/native/core/programmers/IsProgrammer.go +293 -293
- package/native/core/programmers/RandomProgrammer.go +1094 -1094
- package/native/core/programmers/ValidateProgrammer.go +369 -369
- package/native/core/programmers/functional/FunctionalAssertFunctionProgrammer.go +133 -133
- package/native/core/programmers/functional/FunctionalAssertParametersProgrammer.go +104 -104
- package/native/core/programmers/functional/FunctionalAssertReturnProgrammer.go +100 -100
- package/native/core/programmers/functional/FunctionalIsFunctionProgrammer.go +79 -79
- package/native/core/programmers/functional/FunctionalIsParametersProgrammer.go +159 -159
- package/native/core/programmers/functional/FunctionalIsReturnProgrammer.go +99 -99
- package/native/core/programmers/functional/FunctionalValidateFunctionProgrammer.go +138 -138
- package/native/core/programmers/functional/FunctionalValidateParametersProgrammer.go +222 -222
- package/native/core/programmers/functional/FunctionalValidateReturnProgrammer.go +116 -116
- package/native/core/programmers/functional/internal/FunctionalGeneralProgrammer.go +36 -36
- package/native/core/programmers/helpers/AtomicPredicator.go +35 -35
- package/native/core/programmers/helpers/CloneJoiner.go +217 -217
- package/native/core/programmers/helpers/FunctionProgrammer.go +79 -79
- package/native/core/programmers/helpers/HttpMetadataUtil.go +17 -17
- package/native/core/programmers/helpers/ICheckEntry.go +5 -5
- package/native/core/programmers/helpers/IExpressionEntry.go +6 -6
- package/native/core/programmers/helpers/NotationJoiner.go +159 -159
- package/native/core/programmers/helpers/OptionPredicator.go +4 -4
- package/native/core/programmers/helpers/ProtobufUtil.go +231 -231
- package/native/core/programmers/helpers/ProtobufWire.go +6 -6
- package/native/core/programmers/helpers/PruneJoiner.go +227 -227
- package/native/core/programmers/helpers/RandomJoiner.go +155 -155
- package/native/core/programmers/helpers/StringifyJoinder.go +331 -331
- package/native/core/programmers/helpers/StringifyPredicator.go +10 -10
- package/native/core/programmers/helpers/UnionExplorer.go +835 -835
- package/native/core/programmers/helpers/UnionPredicator.go +78 -78
- package/native/core/programmers/helpers/disable_function_programmer_declare.go +6 -6
- package/native/core/programmers/http/HttpAssertFormDataProgrammer.go +93 -93
- package/native/core/programmers/http/HttpAssertHeadersProgrammer.go +42 -42
- package/native/core/programmers/http/HttpAssertQueryProgrammer.go +51 -51
- package/native/core/programmers/http/HttpFormDataProgrammer.go +351 -351
- package/native/core/programmers/http/HttpHeadersProgrammer.go +370 -370
- package/native/core/programmers/http/HttpIsFormDataProgrammer.go +109 -109
- package/native/core/programmers/http/HttpIsHeadersProgrammer.go +36 -36
- package/native/core/programmers/http/HttpIsQueryProgrammer.go +45 -45
- package/native/core/programmers/http/HttpParameterProgrammer.go +158 -158
- package/native/core/programmers/http/HttpQueryProgrammer.go +422 -422
- package/native/core/programmers/http/HttpValidateFormDataProgrammer.go +87 -87
- package/native/core/programmers/http/HttpValidateHeadersProgrammer.go +39 -39
- package/native/core/programmers/http/HttpValidateQueryProgrammer.go +48 -48
- package/native/core/programmers/internal/CheckerProgrammer.go +1490 -1490
- package/native/core/programmers/internal/FeatureProgrammer.go +589 -589
- package/native/core/programmers/iterate/check_array_length.go +46 -46
- package/native/core/programmers/iterate/check_bigint.go +52 -52
- package/native/core/programmers/iterate/check_dynamic_key.go +220 -220
- package/native/core/programmers/iterate/check_dynamic_properties.go +245 -245
- package/native/core/programmers/iterate/check_everything.go +21 -21
- package/native/core/programmers/iterate/check_native.go +25 -25
- package/native/core/programmers/iterate/check_number.go +135 -135
- package/native/core/programmers/iterate/check_object.go +66 -66
- package/native/core/programmers/iterate/check_string.go +52 -52
- package/native/core/programmers/iterate/check_template.go +57 -57
- package/native/core/programmers/iterate/check_union_array_like.go +372 -372
- package/native/core/programmers/iterate/decode_union_object.go +118 -118
- package/native/core/programmers/iterate/feature_object_entries.go +134 -134
- package/native/core/programmers/iterate/json_schema_alias.go +52 -52
- package/native/core/programmers/iterate/json_schema_array.go +52 -52
- package/native/core/programmers/iterate/json_schema_bigint.go +8 -8
- package/native/core/programmers/iterate/json_schema_boolean.go +8 -8
- package/native/core/programmers/iterate/json_schema_constant.go +38 -38
- package/native/core/programmers/iterate/json_schema_description.go +12 -12
- package/native/core/programmers/iterate/json_schema_discriminator.go +47 -47
- package/native/core/programmers/iterate/json_schema_escaped.go +58 -58
- package/native/core/programmers/iterate/json_schema_jsDocTags.go +34 -34
- package/native/core/programmers/iterate/json_schema_native.go +43 -43
- package/native/core/programmers/iterate/json_schema_number.go +8 -8
- package/native/core/programmers/iterate/json_schema_object.go +149 -149
- package/native/core/programmers/iterate/json_schema_plugin.go +35 -35
- package/native/core/programmers/iterate/json_schema_station.go +211 -211
- package/native/core/programmers/iterate/json_schema_string.go +8 -8
- package/native/core/programmers/iterate/json_schema_template.go +53 -53
- package/native/core/programmers/iterate/json_schema_title.go +16 -16
- package/native/core/programmers/iterate/json_schema_tuple.go +34 -34
- package/native/core/programmers/iterate/metadata_to_pattern.go +53 -53
- package/native/core/programmers/iterate/postfix_of_tuple.go +5 -5
- package/native/core/programmers/iterate/prune_object_properties.go +85 -85
- package/native/core/programmers/iterate/stringify_dynamic_properties.go +193 -193
- package/native/core/programmers/iterate/stringify_native.go +1 -1
- package/native/core/programmers/iterate/stringify_regular_properties.go +84 -84
- package/native/core/programmers/iterate/template_to_pattern.go +20 -20
- package/native/core/programmers/iterate/wrap_metadata_rest_tuple.go +13 -13
- package/native/core/programmers/json/JsonApplicationProgrammer.go +323 -323
- package/native/core/programmers/json/JsonAssertParseProgrammer.go +100 -100
- package/native/core/programmers/json/JsonAssertStringifyProgrammer.go +88 -88
- package/native/core/programmers/json/JsonIsParseProgrammer.go +130 -130
- package/native/core/programmers/json/JsonIsStringifyProgrammer.go +92 -92
- package/native/core/programmers/json/JsonSchemaProgrammer.go +65 -65
- package/native/core/programmers/json/JsonSchemasProgrammer.go +116 -116
- package/native/core/programmers/json/JsonStringifyProgrammer.go +1245 -1245
- package/native/core/programmers/json/JsonValidateParseProgrammer.go +89 -89
- package/native/core/programmers/json/JsonValidateStringifyProgrammer.go +106 -106
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +449 -437
- package/native/core/programmers/llm/LlmCoerceProgrammer.go +79 -79
- package/native/core/programmers/llm/LlmControllerProgrammer.go +35 -35
- package/native/core/programmers/llm/LlmMetadataFactory.go +74 -74
- package/native/core/programmers/llm/LlmParametersProgrammer.go +105 -132
- package/native/core/programmers/llm/LlmParseProgrammer.go +88 -88
- package/native/core/programmers/llm/LlmSchemaProgrammer.go +780 -423
- package/native/core/programmers/llm/LlmStructuredOutputProgrammer.go +123 -123
- package/native/core/programmers/misc/MiscAssertCloneProgrammer.go +82 -82
- package/native/core/programmers/misc/MiscAssertPruneProgrammer.go +97 -97
- package/native/core/programmers/misc/MiscCloneProgrammer.go +1056 -1056
- package/native/core/programmers/misc/MiscIsCloneProgrammer.go +94 -94
- package/native/core/programmers/misc/MiscIsPruneProgrammer.go +86 -86
- package/native/core/programmers/misc/MiscLiteralsProgrammer.go +99 -99
- package/native/core/programmers/misc/MiscPruneProgrammer.go +700 -700
- package/native/core/programmers/misc/MiscValidateCloneProgrammer.go +103 -103
- package/native/core/programmers/misc/MiscValidatePruneProgrammer.go +94 -94
- package/native/core/programmers/notations/NotationAssertGeneralProgrammer.go +85 -85
- package/native/core/programmers/notations/NotationGeneralProgrammer.go +1188 -1188
- package/native/core/programmers/notations/NotationIsGeneralProgrammer.go +90 -90
- package/native/core/programmers/notations/NotationValidateGeneralProgrammer.go +109 -109
- package/native/core/programmers/protobuf/ProtobufAssertDecodeProgrammer.go +99 -99
- package/native/core/programmers/protobuf/ProtobufAssertEncodeProgrammer.go +114 -114
- package/native/core/programmers/protobuf/ProtobufDecodeProgrammer.go +697 -697
- package/native/core/programmers/protobuf/ProtobufEncodeProgrammer.go +1039 -1039
- package/native/core/programmers/protobuf/ProtobufIsDecodeProgrammer.go +99 -99
- package/native/core/programmers/protobuf/ProtobufIsEncodeProgrammer.go +93 -93
- package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +228 -228
- package/native/core/programmers/protobuf/ProtobufValidateDecodeProgrammer.go +88 -88
- package/native/core/programmers/protobuf/ProtobufValidateEncodeProgrammer.go +120 -120
- package/native/core/schemas/metadata/IMetadataDictionary.go +4 -4
- package/native/core/schemas/metadata/MetadataAlias.go +15 -15
- package/native/core/schemas/metadata/MetadataAliasType.go +36 -36
- package/native/core/schemas/metadata/MetadataApplication.go +25 -25
- package/native/core/schemas/metadata/MetadataArray.go +15 -15
- package/native/core/schemas/metadata/MetadataArrayType.go +31 -31
- package/native/core/schemas/metadata/MetadataAtomic.go +45 -45
- package/native/core/schemas/metadata/MetadataCollection.go +380 -380
- package/native/core/schemas/metadata/MetadataComponents.go +95 -95
- package/native/core/schemas/metadata/MetadataConstant.go +31 -31
- package/native/core/schemas/metadata/MetadataConstantValue.go +63 -63
- package/native/core/schemas/metadata/MetadataEscaped.go +17 -17
- package/native/core/schemas/metadata/MetadataFunction.go +30 -30
- package/native/core/schemas/metadata/MetadataMap.go +21 -21
- package/native/core/schemas/metadata/MetadataNative.go +48 -48
- package/native/core/schemas/metadata/MetadataObject.go +15 -15
- package/native/core/schemas/metadata/MetadataObjectType.go +116 -116
- package/native/core/schemas/metadata/MetadataParameter.go +28 -28
- package/native/core/schemas/metadata/MetadataProperty.go +32 -32
- package/native/core/schemas/metadata/MetadataSchema.go +766 -766
- package/native/core/schemas/metadata/MetadataSet.go +17 -17
- package/native/core/schemas/metadata/MetadataTemplate.go +43 -43
- package/native/core/schemas/metadata/MetadataTuple.go +10 -10
- package/native/core/schemas/metadata/MetadataTupleType.go +38 -38
- package/native/core/schemas/protobuf/IProtobufProperty.go +2 -2
- package/native/core/schemas/protobuf/IProtobufPropertyType.go +18 -18
- package/native/core/schemas/protobuf/IProtobufSchema.go +17 -17
- package/native/core/typings/Writable.go +1 -1
- package/native/core/utils/PatternUtil.go +38 -38
- package/native/core/utils/ProtobufNameEncoder.go +28 -28
- package/native/shim/printer/shim.go +213 -213
- package/native/third_party/ttsc/driver/host.go +7 -7
- package/native/third_party/ttsc/driver/program.go +275 -275
- package/native/third_party/ttsc/driver/rewrite.go +219 -219
- package/native/third_party/ttsc/shim/ast/lint.go +171 -171
- package/native/third_party/ttsc/shim/ast/shim.go +83 -83
- package/native/third_party/ttsc/shim/bundled/shim.go +5 -1
- package/native/third_party/ttsc/shim/checker/shim.go +79 -79
- package/native/third_party/ttsc/shim/compiler/shim.go +16 -1
- package/native/third_party/ttsc/shim/core/shim.go +10 -10
- package/native/third_party/ttsc/shim/diagnosticwriter/lint.go +79 -79
- package/native/third_party/ttsc/shim/diagnosticwriter/shim.go +19 -19
- package/native/third_party/ttsc/shim/parser/shim.go +7 -1
- package/native/third_party/ttsc/shim/scanner/shim.go +39 -1
- package/native/third_party/ttsc/shim/tsoptions/shim.go +51 -1
- package/native/third_party/ttsc/shim/tspath/shim.go +72 -1
- package/native/third_party/ttsc/shim/vfs/cachedvfs/shim.go +1 -1
- package/native/third_party/ttsc/shim/vfs/osvfs/shim.go +1 -1
- package/native/third_party/ttsc/shim/vfs/shim.go +4 -1
- package/native/transform/CallExpressionTransformer.go +556 -556
- package/native/transform/FileTransformer.go +123 -123
- package/native/transform/ImportTransformer.go +224 -224
- package/native/transform/NodeTransformer.go +11 -11
- package/native/transform/TypiaGenerator.go +136 -136
- package/native/transform/features/AssertTransformer.go +28 -28
- package/native/transform/features/CreateAssertTransformer.go +28 -28
- package/native/transform/features/CreateIsTransformer.go +24 -24
- package/native/transform/features/CreateRandomTransformer.go +35 -35
- package/native/transform/features/CreateValidateTransformer.go +24 -24
- package/native/transform/features/IsTransformer.go +24 -24
- package/native/transform/features/RandomTransformer.go +37 -37
- package/native/transform/features/ValidateTransformer.go +24 -24
- package/native/transform/features/functional/FunctionalGenericTransformer.go +48 -48
- package/native/transform/features/http/CreateHttpAssertFormDataTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpAssertHeadersTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpAssertQueryTransformer.go +17 -17
- package/native/transform/features/http/CreateHttpFormDataTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpHeadersTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpIsFormDataTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpIsHeadersTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpIsQueryTransformer.go +17 -17
- package/native/transform/features/http/CreateHttpParameterTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpQueryTransformer.go +17 -17
- package/native/transform/features/http/CreateHttpValidateFormDataTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpValidateHeadersTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpValidateQueryTransformer.go +17 -17
- package/native/transform/features/http/HttpAssertFormDataTransformer.go +11 -11
- package/native/transform/features/http/HttpAssertHeadersTransformer.go +11 -11
- package/native/transform/features/http/HttpAssertQueryTransformer.go +17 -17
- package/native/transform/features/http/HttpFormDataTransformer.go +11 -11
- package/native/transform/features/http/HttpHeadersTransformer.go +11 -11
- package/native/transform/features/http/HttpIsFormDataTransformer.go +11 -11
- package/native/transform/features/http/HttpIsHeadersTransformer.go +11 -11
- package/native/transform/features/http/HttpIsQueryTransformer.go +17 -17
- package/native/transform/features/http/HttpParameterTransformer.go +11 -11
- package/native/transform/features/http/HttpQueryTransformer.go +17 -17
- package/native/transform/features/http/HttpValidateFormDataTransformer.go +11 -11
- package/native/transform/features/http/HttpValidateHeadersTransformer.go +11 -11
- package/native/transform/features/http/HttpValidateQueryTransformer.go +17 -17
- package/native/transform/features/json/JsonApplicationTransformer.go +61 -61
- package/native/transform/features/json/JsonAssertParseTransformer.go +11 -11
- package/native/transform/features/json/JsonAssertStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateAssertParseTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateAssertStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateIsParseTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateIsStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateValidateParseTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateValidateStringifyProgrammer.go +11 -11
- package/native/transform/features/json/JsonIsParseTransformer.go +11 -11
- package/native/transform/features/json/JsonIsStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonSchemaTransformer.go +148 -148
- package/native/transform/features/json/JsonSchemasTransformer.go +94 -94
- package/native/transform/features/json/JsonStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonValidateParseTransformer.go +11 -11
- package/native/transform/features/json/JsonValidateStringifyTransformer.go +11 -11
- package/native/transform/features/llm/LlmApplicationTransformer.go +43 -43
- package/native/transform/features/llm/LlmCoerceTransformer.go +50 -50
- package/native/transform/features/llm/LlmControllerTransformer.go +48 -48
- package/native/transform/features/llm/LlmCreateCoerceTransformer.go +43 -43
- package/native/transform/features/llm/LlmCreateParseTransformer.go +43 -43
- package/native/transform/features/llm/LlmParametersTransformer.go +38 -38
- package/native/transform/features/llm/LlmParseTransformer.go +50 -50
- package/native/transform/features/llm/LlmSchemaTransformer.go +129 -129
- package/native/transform/features/llm/LlmStructuredOutputTransformer.go +44 -44
- package/native/transform/features/misc/MiscAssertCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscAssertPruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateAssertCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateAssertPruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateIsCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateIsPruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreatePruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateValidateCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateValidatePruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscIsCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscIsPruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscLiteralsTransformer.go +21 -21
- package/native/transform/features/misc/MiscPruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscValidateCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscValidatePruneTransformer.go +11 -11
- package/native/transform/features/notations/NotationAssertGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationCreateAssertGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationCreateGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationCreateIsGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationCreateValidateGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationGeneralTransformer.go +21 -21
- package/native/transform/features/notations/NotationIsGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationValidateGeneralTransformer.go +16 -16
- package/native/transform/features/protobuf/ProtobufAssertDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufAssertEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateAssertDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateAssertEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateIsDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateIsEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateValidateDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateValidateEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufIsDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufIsEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufMessageTransformer.go +20 -20
- package/native/transform/features/protobuf/ProtobufValidateDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufValidateEncodeTransformer.go +11 -11
- package/native/transform/features/reflect/ReflectMetadataTransformer.go +59 -59
- package/native/transform/features/reflect/ReflectNameTransformer.go +78 -78
- package/native/transform/features/reflect/ReflectSchemaTransformer.go +121 -121
- package/native/transform/features/reflect/ReflectSchemasTransformer.go +55 -55
- package/native/transform/internal/GenericTransformer.go +173 -173
- package/native/transform/transform.go +32 -32
- package/package.json +4 -4
- package/src/executable/TypiaGenerateWizard.ts +78 -9
- package/src/executable/generate/ttsc.ts +2 -3
- package/src/executable/setup/PluginConfigurator.ts +2 -3
- package/src/internal/_randomInteger.ts +5 -5
- package/src/internal/_validateReport.ts +1 -2
- package/src/transform.ts +6 -11
|
@@ -1,863 +1,863 @@
|
|
|
1
1
|
package metadata
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
"fmt"
|
|
5
|
+
"reflect"
|
|
6
|
+
"sort"
|
|
7
|
+
"strings"
|
|
8
8
|
)
|
|
9
9
|
|
|
10
10
|
type IMetadataSchema struct {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
Any bool
|
|
12
|
+
Required bool
|
|
13
|
+
Optional bool
|
|
14
|
+
Nullable bool
|
|
15
|
+
Functions []*IMetadataSchema_IFunction
|
|
16
|
+
|
|
17
|
+
Atomics []IMetadataSchema_IAtomic
|
|
18
|
+
Constants []IMetadataSchema_IConstant
|
|
19
|
+
Templates []IMetadataSchema_ITemplate
|
|
20
|
+
Escaped *IMetadataSchema_IEscaped
|
|
21
|
+
|
|
22
|
+
Rest *IMetadataSchema
|
|
23
|
+
Arrays []IMetadataSchema_IReference
|
|
24
|
+
Tuples []IMetadataSchema_IReference
|
|
25
|
+
Objects []IMetadataSchema_IReference
|
|
26
|
+
Aliases []IMetadataSchema_IReference
|
|
27
|
+
|
|
28
|
+
Natives []IMetadataSchema_IReference
|
|
29
|
+
Sets []IMetadataSchema_ISet
|
|
30
|
+
Maps []IMetadataSchema_IMap
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
type MetadataSchema struct {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
34
|
+
Any bool
|
|
35
|
+
Required bool
|
|
36
|
+
Optional bool
|
|
37
|
+
Nullable bool
|
|
38
|
+
|
|
39
|
+
Escaped *MetadataEscaped
|
|
40
|
+
Atomics []*MetadataAtomic
|
|
41
|
+
Constants []*MetadataConstant
|
|
42
|
+
Templates []*MetadataTemplate
|
|
43
|
+
|
|
44
|
+
Rest *MetadataSchema
|
|
45
|
+
Aliases []*MetadataAlias
|
|
46
|
+
Arrays []*MetadataArray
|
|
47
|
+
Tuples []*MetadataTuple
|
|
48
|
+
Objects []*MetadataObject
|
|
49
|
+
Functions []*MetadataFunction
|
|
50
|
+
|
|
51
|
+
Natives []*MetadataNative
|
|
52
|
+
Sets []*MetadataSet
|
|
53
|
+
Maps []*MetadataMap
|
|
54
|
+
|
|
55
|
+
name_ string
|
|
56
|
+
parent_resolved_ bool
|
|
57
|
+
Union_index *int
|
|
58
|
+
Fixed_ *int
|
|
59
|
+
Boolean_literal_intersected_ *bool
|
|
60
|
+
is_sequence_ *bool
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
func MetadataSchema_create(props MetadataSchema) *MetadataSchema {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
64
|
+
return &MetadataSchema{
|
|
65
|
+
Any: props.Any,
|
|
66
|
+
Required: props.Required,
|
|
67
|
+
Optional: props.Optional,
|
|
68
|
+
Nullable: props.Nullable,
|
|
69
|
+
Functions: props.Functions,
|
|
70
|
+
|
|
71
|
+
Escaped: props.Escaped,
|
|
72
|
+
Atomics: props.Atomics,
|
|
73
|
+
Constants: props.Constants,
|
|
74
|
+
Templates: props.Templates,
|
|
75
|
+
|
|
76
|
+
Rest: props.Rest,
|
|
77
|
+
Arrays: props.Arrays,
|
|
78
|
+
Tuples: props.Tuples,
|
|
79
|
+
Objects: props.Objects,
|
|
80
|
+
Aliases: props.Aliases,
|
|
81
|
+
|
|
82
|
+
Natives: props.Natives,
|
|
83
|
+
Sets: props.Sets,
|
|
84
|
+
Maps: props.Maps,
|
|
85
|
+
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
func MetadataSchema_initialize(parentResolved ...bool) *MetadataSchema {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
89
|
+
resolved := false
|
|
90
|
+
if len(parentResolved) > 0 {
|
|
91
|
+
resolved = parentResolved[0]
|
|
92
|
+
}
|
|
93
|
+
meta := MetadataSchema_create(MetadataSchema{
|
|
94
|
+
Any: false,
|
|
95
|
+
Nullable: false,
|
|
96
|
+
Required: true,
|
|
97
|
+
Optional: false,
|
|
98
|
+
Escaped: nil,
|
|
99
|
+
Constants: []*MetadataConstant{},
|
|
100
|
+
Atomics: []*MetadataAtomic{},
|
|
101
|
+
Templates: []*MetadataTemplate{},
|
|
102
|
+
Arrays: []*MetadataArray{},
|
|
103
|
+
Tuples: []*MetadataTuple{},
|
|
104
|
+
Objects: []*MetadataObject{},
|
|
105
|
+
Aliases: []*MetadataAlias{},
|
|
106
|
+
Functions: []*MetadataFunction{},
|
|
107
|
+
Rest: nil,
|
|
108
|
+
Natives: []*MetadataNative{},
|
|
109
|
+
Sets: []*MetadataSet{},
|
|
110
|
+
Maps: []*MetadataMap{},
|
|
111
|
+
})
|
|
112
|
+
meta.parent_resolved_ = resolved
|
|
113
|
+
return meta
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
func (obj *MetadataSchema) ToJSON() *IMetadataSchema {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
117
|
+
output := &IMetadataSchema{
|
|
118
|
+
Any: obj.Any,
|
|
119
|
+
Required: obj.Required,
|
|
120
|
+
Optional: obj.Optional,
|
|
121
|
+
Nullable: obj.Nullable,
|
|
122
|
+
}
|
|
123
|
+
for _, f := range obj.Functions {
|
|
124
|
+
json := f.ToJSON()
|
|
125
|
+
output.Functions = append(output.Functions, &json)
|
|
126
|
+
}
|
|
127
|
+
for _, a := range obj.Atomics {
|
|
128
|
+
output.Atomics = append(output.Atomics, a.ToJSON())
|
|
129
|
+
}
|
|
130
|
+
for _, c := range obj.Constants {
|
|
131
|
+
output.Constants = append(output.Constants, c.ToJSON())
|
|
132
|
+
}
|
|
133
|
+
for _, tpl := range obj.Templates {
|
|
134
|
+
output.Templates = append(output.Templates, tpl.ToJSON())
|
|
135
|
+
}
|
|
136
|
+
if obj.Escaped != nil {
|
|
137
|
+
escaped := obj.Escaped.ToJSON()
|
|
138
|
+
output.Escaped = &escaped
|
|
139
|
+
}
|
|
140
|
+
if obj.Rest != nil {
|
|
141
|
+
output.Rest = obj.Rest.ToJSON()
|
|
142
|
+
}
|
|
143
|
+
for _, array := range obj.Arrays {
|
|
144
|
+
output.Arrays = append(output.Arrays, array.ToJSON())
|
|
145
|
+
}
|
|
146
|
+
for _, tuple := range obj.Tuples {
|
|
147
|
+
output.Tuples = append(output.Tuples, tuple.ToJSON())
|
|
148
|
+
}
|
|
149
|
+
for _, object := range obj.Objects {
|
|
150
|
+
output.Objects = append(output.Objects, object.ToJSON())
|
|
151
|
+
}
|
|
152
|
+
for _, alias := range obj.Aliases {
|
|
153
|
+
output.Aliases = append(output.Aliases, alias.ToJSON())
|
|
154
|
+
}
|
|
155
|
+
for _, native := range obj.Natives {
|
|
156
|
+
output.Natives = append(output.Natives, native.ToJSON())
|
|
157
|
+
}
|
|
158
|
+
for _, set := range obj.Sets {
|
|
159
|
+
output.Sets = append(output.Sets, set.ToJSON())
|
|
160
|
+
}
|
|
161
|
+
for _, m := range obj.Maps {
|
|
162
|
+
output.Maps = append(output.Maps, m.ToJSON())
|
|
163
|
+
}
|
|
164
|
+
return output
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
func MetadataSchema_from(meta *IMetadataSchema, dict IMetadataDictionary) *MetadataSchema {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
168
|
+
functions := make([]*MetadataFunction, 0, len(meta.Functions))
|
|
169
|
+
for _, f := range meta.Functions {
|
|
170
|
+
functions = append(functions, MetadataFunction_from(*f, dict))
|
|
171
|
+
}
|
|
172
|
+
constants := make([]*MetadataConstant, 0, len(meta.Constants))
|
|
173
|
+
for _, c := range meta.Constants {
|
|
174
|
+
constants = append(constants, MetadataConstant_from(c))
|
|
175
|
+
}
|
|
176
|
+
atomics := make([]*MetadataAtomic, 0, len(meta.Atomics))
|
|
177
|
+
for _, a := range meta.Atomics {
|
|
178
|
+
atomics = append(atomics, MetadataAtomic_from(a))
|
|
179
|
+
}
|
|
180
|
+
templates := make([]*MetadataTemplate, 0, len(meta.Templates))
|
|
181
|
+
for _, tpl := range meta.Templates {
|
|
182
|
+
templates = append(templates, MetadataTemplate_from(tpl, dict))
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
var escaped *MetadataEscaped
|
|
186
|
+
if meta.Escaped != nil {
|
|
187
|
+
escaped = MetadataEscaped_from(*meta.Escaped, dict)
|
|
188
|
+
}
|
|
189
|
+
var rest *MetadataSchema
|
|
190
|
+
if meta.Rest != nil {
|
|
191
|
+
rest = MetadataSchema_from(meta.Rest, dict)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
arrays := make([]*MetadataArray, 0, len(meta.Arrays))
|
|
195
|
+
for _, ref := range meta.Arrays {
|
|
196
|
+
typ := dict.Arrays[ref.Name]
|
|
197
|
+
if typ == nil {
|
|
198
|
+
panic(fmt.Sprintf("Error on Metadata.from(): failed to find array %q.", ref.Name))
|
|
199
|
+
}
|
|
200
|
+
arrays = append(arrays, MetadataArray_create(MetadataArray{Type: typ, Tags: cloneTagMatrix(ref.Tags)}))
|
|
201
|
+
}
|
|
202
|
+
tuples := make([]*MetadataTuple, 0, len(meta.Tuples))
|
|
203
|
+
for _, ref := range meta.Tuples {
|
|
204
|
+
typ := dict.Tuples[ref.Name]
|
|
205
|
+
if typ == nil {
|
|
206
|
+
panic(fmt.Sprintf("Error on Metadata.from(): failed to find tuple %q.", ref.Name))
|
|
207
|
+
}
|
|
208
|
+
tuples = append(tuples, MetadataTuple_create(MetadataTuple{Type: typ, Tags: cloneTagMatrix(ref.Tags)}))
|
|
209
|
+
}
|
|
210
|
+
objects := make([]*MetadataObject, 0, len(meta.Objects))
|
|
211
|
+
for _, ref := range meta.Objects {
|
|
212
|
+
found := dict.Objects[ref.Name]
|
|
213
|
+
if found == nil {
|
|
214
|
+
panic(fmt.Sprintf("Error on Metadata.from(): failed to find object %q.", ref.Name))
|
|
215
|
+
}
|
|
216
|
+
objects = append(objects, MetadataObject_create(MetadataObject{Type: found, Tags: cloneTagMatrix(ref.Tags)}))
|
|
217
|
+
}
|
|
218
|
+
aliases := make([]*MetadataAlias, 0, len(meta.Aliases))
|
|
219
|
+
for _, ref := range meta.Aliases {
|
|
220
|
+
typ := dict.Aliases[ref.Name]
|
|
221
|
+
if typ == nil {
|
|
222
|
+
panic(fmt.Sprintf("Error on Metadata.from(): failed to find alias %q.", ref.Name))
|
|
223
|
+
}
|
|
224
|
+
aliases = append(aliases, MetadataAlias_create(MetadataAlias{Type: typ, Tags: cloneTagMatrix(ref.Tags)}))
|
|
225
|
+
}
|
|
226
|
+
natives := make([]*MetadataNative, 0, len(meta.Natives))
|
|
227
|
+
for _, native := range meta.Natives {
|
|
228
|
+
natives = append(natives, MetadataNative_create(MetadataNative{Name: native.Name, Tags: cloneTagMatrix(native.Tags)}))
|
|
229
|
+
}
|
|
230
|
+
sets := make([]*MetadataSet, 0, len(meta.Sets))
|
|
231
|
+
for _, set := range meta.Sets {
|
|
232
|
+
sets = append(sets, MetadataSet_create(MetadataSet{
|
|
233
|
+
Value: MetadataSchema_from(set.Value, dict),
|
|
234
|
+
Tags: cloneTagMatrix(set.Tags),
|
|
235
|
+
}))
|
|
236
|
+
}
|
|
237
|
+
maps := make([]*MetadataMap, 0, len(meta.Maps))
|
|
238
|
+
for _, m := range meta.Maps {
|
|
239
|
+
maps = append(maps, MetadataMap_create(MetadataMap{
|
|
240
|
+
Key: MetadataSchema_from(m.Key, dict),
|
|
241
|
+
Value: MetadataSchema_from(m.Value, dict),
|
|
242
|
+
Tags: cloneTagMatrix(m.Tags),
|
|
243
|
+
}))
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return MetadataSchema_create(MetadataSchema{
|
|
247
|
+
Any: meta.Any,
|
|
248
|
+
Required: meta.Required,
|
|
249
|
+
Optional: meta.Optional,
|
|
250
|
+
Nullable: meta.Nullable,
|
|
251
|
+
Functions: functions,
|
|
252
|
+
Constants: constants,
|
|
253
|
+
Atomics: atomics,
|
|
254
|
+
Templates: templates,
|
|
255
|
+
Escaped: escaped,
|
|
256
|
+
Rest: rest,
|
|
257
|
+
Arrays: arrays,
|
|
258
|
+
Tuples: tuples,
|
|
259
|
+
Objects: objects,
|
|
260
|
+
Aliases: aliases,
|
|
261
|
+
Natives: natives,
|
|
262
|
+
Sets: sets,
|
|
263
|
+
Maps: maps,
|
|
264
|
+
})
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
func (obj *MetadataSchema) GetName() string {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
if obj.name_ == "" {
|
|
269
|
+
obj.name_ = metadataSchema_getName(obj)
|
|
270
|
+
}
|
|
271
|
+
return obj.name_
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
func (obj *MetadataSchema) Empty() bool {
|
|
275
|
-
|
|
275
|
+
return obj.Bucket() == 0 || obj.Size() == 0
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
func (obj *MetadataSchema) Size() int {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
279
|
+
size := 0
|
|
280
|
+
if obj.Any {
|
|
281
|
+
size++
|
|
282
|
+
}
|
|
283
|
+
if obj.Escaped != nil {
|
|
284
|
+
size++
|
|
285
|
+
}
|
|
286
|
+
if obj.Rest != nil {
|
|
287
|
+
size += obj.Rest.Size()
|
|
288
|
+
}
|
|
289
|
+
size += len(obj.Templates)
|
|
290
|
+
size += len(obj.Atomics)
|
|
291
|
+
for _, c := range obj.Constants {
|
|
292
|
+
size += len(c.Values)
|
|
293
|
+
}
|
|
294
|
+
size += len(obj.Arrays) + len(obj.Tuples) + len(obj.Natives) + len(obj.Maps) + len(obj.Sets)
|
|
295
|
+
size += len(obj.Objects) + len(obj.Functions) + len(obj.Aliases)
|
|
296
|
+
return size
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
func (obj *MetadataSchema) Bucket() int {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
300
|
+
size := 0
|
|
301
|
+
if obj.Any {
|
|
302
|
+
size++
|
|
303
|
+
}
|
|
304
|
+
if obj.Escaped != nil {
|
|
305
|
+
size++
|
|
306
|
+
}
|
|
307
|
+
if len(obj.Templates) != 0 {
|
|
308
|
+
size++
|
|
309
|
+
}
|
|
310
|
+
if len(obj.Atomics) != 0 {
|
|
311
|
+
size++
|
|
312
|
+
}
|
|
313
|
+
if len(obj.Constants) != 0 {
|
|
314
|
+
size++
|
|
315
|
+
}
|
|
316
|
+
if obj.Rest != nil {
|
|
317
|
+
size += obj.Rest.Size()
|
|
318
|
+
}
|
|
319
|
+
if len(obj.Arrays) != 0 {
|
|
320
|
+
size++
|
|
321
|
+
}
|
|
322
|
+
if len(obj.Tuples) != 0 {
|
|
323
|
+
size++
|
|
324
|
+
}
|
|
325
|
+
if len(obj.Natives) != 0 {
|
|
326
|
+
size++
|
|
327
|
+
}
|
|
328
|
+
if len(obj.Sets) != 0 {
|
|
329
|
+
size++
|
|
330
|
+
}
|
|
331
|
+
if len(obj.Maps) != 0 {
|
|
332
|
+
size++
|
|
333
|
+
}
|
|
334
|
+
if len(obj.Objects) != 0 {
|
|
335
|
+
size++
|
|
336
|
+
}
|
|
337
|
+
if len(obj.Functions) != 0 {
|
|
338
|
+
size++
|
|
339
|
+
}
|
|
340
|
+
if len(obj.Aliases) != 0 {
|
|
341
|
+
size++
|
|
342
|
+
}
|
|
343
|
+
return size
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
func (obj *MetadataSchema) IsSequence() bool {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
347
|
+
if obj.is_sequence_ != nil {
|
|
348
|
+
return *obj.is_sequence_
|
|
349
|
+
}
|
|
350
|
+
exists := func(tags [][]IMetadataTypeTag) bool {
|
|
351
|
+
for _, row := range tags {
|
|
352
|
+
for _, t := range row {
|
|
353
|
+
if t.Kind != "sequence" {
|
|
354
|
+
continue
|
|
355
|
+
}
|
|
356
|
+
schema, ok := t.Schema.(map[string]any)
|
|
357
|
+
if ok == false {
|
|
358
|
+
continue
|
|
359
|
+
}
|
|
360
|
+
if _, ok := schema["x-protobuf-sequence"].(float64); ok {
|
|
361
|
+
return true
|
|
362
|
+
}
|
|
363
|
+
if _, ok := schema["x-protobuf-sequence"].(int); ok {
|
|
364
|
+
return true
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return false
|
|
369
|
+
}
|
|
370
|
+
value := anyOf(obj.Atomics, func(atomic *MetadataAtomic) bool { return exists(atomic.Tags) }) &&
|
|
371
|
+
anyOf(obj.Constants, func(c *MetadataConstant) bool {
|
|
372
|
+
return anyOf(c.Values, func(v *MetadataConstantValue) bool { return exists(v.Tags) })
|
|
373
|
+
}) &&
|
|
374
|
+
anyOf(obj.Templates, func(tpl *MetadataTemplate) bool { return exists(tpl.Tags) }) &&
|
|
375
|
+
anyOf(obj.Arrays, func(array *MetadataArray) bool { return exists(array.Tags) }) &&
|
|
376
|
+
anyOf(obj.Objects, func(object *MetadataObject) bool { return exists(object.Tags) }) &&
|
|
377
|
+
anyOf(obj.Natives, func(native *MetadataNative) bool { return native.Name == "Uint8Array" && exists(native.Tags) })
|
|
378
|
+
obj.is_sequence_ = &value
|
|
379
|
+
return value
|
|
380
380
|
}
|
|
381
381
|
|
|
382
382
|
func (obj *MetadataSchema) IsConstant() bool {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
383
|
+
count := 0
|
|
384
|
+
if len(obj.Constants) != 0 {
|
|
385
|
+
count = 1
|
|
386
|
+
}
|
|
387
|
+
return obj.Bucket() == count
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
func (obj *MetadataSchema) IsRequired() bool {
|
|
391
|
-
|
|
391
|
+
return obj.Required == true && obj.Optional == false
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
func (obj *MetadataSchema) IsUnionBucket() bool {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
395
|
+
size := obj.Bucket()
|
|
396
|
+
emended := size
|
|
397
|
+
if len(obj.Atomics) != 0 && len(obj.Constants) != 0 {
|
|
398
|
+
emended = size - 1
|
|
399
|
+
}
|
|
400
|
+
return emended > 1
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
func (obj *MetadataSchema) GetSoleLiteral() *string {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
404
|
+
if obj.Size() == 1 &&
|
|
405
|
+
len(obj.Constants) == 1 &&
|
|
406
|
+
obj.Constants[0].Type == "string" &&
|
|
407
|
+
len(obj.Constants[0].Values) == 1 {
|
|
408
|
+
if value, ok := obj.Constants[0].Values[0].Value.(string); ok {
|
|
409
|
+
return &value
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return nil
|
|
413
413
|
}
|
|
414
414
|
|
|
415
415
|
func (obj *MetadataSchema) IsSoleLiteral() bool {
|
|
416
|
-
|
|
416
|
+
return obj.GetSoleLiteral() != nil
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
func (obj *MetadataSchema) IsParentResolved() bool {
|
|
420
|
-
|
|
420
|
+
return obj.parent_resolved_
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
func MetadataSchema_intersects(x *MetadataSchema, y *MetadataSchema) bool {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
424
|
+
if x.Any || y.Any {
|
|
425
|
+
return true
|
|
426
|
+
}
|
|
427
|
+
if x.IsRequired() == false && y.IsRequired() == false {
|
|
428
|
+
return true
|
|
429
|
+
}
|
|
430
|
+
if x.Nullable && y.Nullable {
|
|
431
|
+
return true
|
|
432
|
+
}
|
|
433
|
+
if len(x.Functions) != 0 && len(y.Functions) != 0 {
|
|
434
|
+
return true
|
|
435
|
+
}
|
|
436
|
+
if len(x.Arrays) != 0 && len(y.Arrays) != 0 {
|
|
437
|
+
return true
|
|
438
|
+
}
|
|
439
|
+
if len(x.Tuples) != 0 && len(y.Tuples) != 0 {
|
|
440
|
+
return true
|
|
441
|
+
}
|
|
442
|
+
if len(x.Objects) != 0 && len(y.Objects) != 0 {
|
|
443
|
+
return true
|
|
444
|
+
}
|
|
445
|
+
if len(x.Aliases) != 0 && len(y.Aliases) != 0 {
|
|
446
|
+
return true
|
|
447
|
+
}
|
|
448
|
+
if anyOf(x.Natives, func(xn *MetadataNative) bool {
|
|
449
|
+
return anyOf(y.Natives, func(yn *MetadataNative) bool { return xn == yn })
|
|
450
|
+
}) {
|
|
451
|
+
return true
|
|
452
|
+
}
|
|
453
|
+
if x.Escaped != nil && y.Escaped != nil {
|
|
454
|
+
return MetadataSchema_intersects(x.Escaped.Original, y.Escaped.Original) ||
|
|
455
|
+
MetadataSchema_intersects(x.Escaped.Returns, y.Escaped.Returns)
|
|
456
|
+
}
|
|
457
|
+
for _, atomic := range x.Atomics {
|
|
458
|
+
if anyOf(y.Atomics, func(ya *MetadataAtomic) bool { return atomic.Type == ya.Type }) {
|
|
459
|
+
return true
|
|
460
|
+
}
|
|
461
|
+
if anyOf(y.Constants, func(yc *MetadataConstant) bool { return atomic.Type == yc.Type }) {
|
|
462
|
+
return true
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
for _, constant := range x.Constants {
|
|
466
|
+
if anyOf(y.Atomics, func(elem *MetadataAtomic) bool { return elem.Type == constant.Type }) {
|
|
467
|
+
return true
|
|
468
|
+
}
|
|
469
|
+
var opposite *MetadataConstant
|
|
470
|
+
for _, elem := range y.Constants {
|
|
471
|
+
if elem.Type == constant.Type {
|
|
472
|
+
opposite = elem
|
|
473
|
+
break
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if opposite == nil {
|
|
477
|
+
continue
|
|
478
|
+
}
|
|
479
|
+
values := map[string]struct{}{}
|
|
480
|
+
for _, v := range constant.Values {
|
|
481
|
+
values[fmt.Sprint(v.Value)] = struct{}{}
|
|
482
|
+
}
|
|
483
|
+
for _, v := range opposite.Values {
|
|
484
|
+
values[fmt.Sprint(v.Value)] = struct{}{}
|
|
485
|
+
}
|
|
486
|
+
if len(values) != len(constant.Values)+len(opposite.Values) {
|
|
487
|
+
return true
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if len(x.Templates) != 0 && anyOf(y.Atomics, func(ya *MetadataAtomic) bool { return ya.Type == "string" }) {
|
|
491
|
+
return true
|
|
492
|
+
}
|
|
493
|
+
if len(y.Templates) != 0 && anyOf(x.Atomics, func(xa *MetadataAtomic) bool { return xa.Type == "string" }) {
|
|
494
|
+
return true
|
|
495
|
+
}
|
|
496
|
+
return false
|
|
497
497
|
}
|
|
498
498
|
|
|
499
499
|
func MetadataSchema_covers(x *MetadataSchema, y *MetadataSchema, levelAndEscaped ...any) bool {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
500
|
+
level := 0
|
|
501
|
+
escaped := false
|
|
502
|
+
if len(levelAndEscaped) > 0 {
|
|
503
|
+
if v, ok := levelAndEscaped[0].(int); ok {
|
|
504
|
+
level = v
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
if len(levelAndEscaped) > 1 {
|
|
508
|
+
if v, ok := levelAndEscaped[1].(bool); ok {
|
|
509
|
+
escaped = v
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if x == y {
|
|
513
|
+
return false
|
|
514
|
+
}
|
|
515
|
+
if x.Any {
|
|
516
|
+
return true
|
|
517
|
+
}
|
|
518
|
+
if y.Any {
|
|
519
|
+
return false
|
|
520
|
+
}
|
|
521
|
+
if escaped == false {
|
|
522
|
+
if x.Escaped == nil && y.Escaped != nil {
|
|
523
|
+
return false
|
|
524
|
+
}
|
|
525
|
+
if x.Escaped != nil && y.Escaped != nil &&
|
|
526
|
+
(MetadataSchema_covers(x.Escaped.Original, y.Escaped.Original, level, true) == false ||
|
|
527
|
+
MetadataSchema_covers(x.Escaped.Returns, y.Escaped.Returns, level, true) == false) {
|
|
528
|
+
return false
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
if level == 0 {
|
|
532
|
+
for _, ya := range y.Arrays {
|
|
533
|
+
if anyOf(x.Arrays, func(xa *MetadataArray) bool {
|
|
534
|
+
return MetadataSchema_covers(xa.Type.Value, ya.Type.Value, level+1)
|
|
535
|
+
}) == false {
|
|
536
|
+
return false
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
for _, yt := range y.Tuples {
|
|
540
|
+
if len(yt.Type.Elements) != 0 && anyOf(x.Tuples, func(xt *MetadataTuple) bool {
|
|
541
|
+
if len(xt.Type.Elements) < len(yt.Type.Elements) {
|
|
542
|
+
return false
|
|
543
|
+
}
|
|
544
|
+
for i := len(yt.Type.Elements); i < len(xt.Type.Elements); i++ {
|
|
545
|
+
if MetadataSchema_covers(xt.Type.Elements[i], yt.Type.Elements[i-len(yt.Type.Elements)], level+1) == false {
|
|
546
|
+
return false
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return true
|
|
550
|
+
}) == false {
|
|
551
|
+
return false
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
for _, yo := range y.Objects {
|
|
556
|
+
if anyOf(x.Objects, func(xo *MetadataObject) bool {
|
|
557
|
+
return MetadataObjectType_covers(xo.Type, yo.Type)
|
|
558
|
+
}) == false {
|
|
559
|
+
return false
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
for _, yd := range y.Aliases {
|
|
563
|
+
if anyOf(x.Aliases, func(xd *MetadataAlias) bool { return xd.Type.Name == yd.Type.Name }) == false {
|
|
564
|
+
return false
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
for _, yn := range y.Natives {
|
|
568
|
+
if anyOf(x.Natives, func(xn *MetadataNative) bool { return xn == yn }) == false {
|
|
569
|
+
return false
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
for _, ys := range y.Sets {
|
|
573
|
+
if anyOf(x.Sets, func(xs *MetadataSet) bool { return MetadataSchema_covers(xs.Value, ys.Value) }) == false {
|
|
574
|
+
return false
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
if anyOf(y.Atomics, func(ya *MetadataAtomic) bool {
|
|
578
|
+
return anyOf(x.Atomics, func(xa *MetadataAtomic) bool { return xa.Type == ya.Type }) == false
|
|
579
|
+
}) {
|
|
580
|
+
return false
|
|
581
|
+
}
|
|
582
|
+
for _, yc := range y.Constants {
|
|
583
|
+
if anyOf(x.Atomics, func(atom *MetadataAtomic) bool { return yc.Type == atom.Type }) {
|
|
584
|
+
continue
|
|
585
|
+
}
|
|
586
|
+
var xc *MetadataConstant
|
|
587
|
+
for _, elem := range x.Constants {
|
|
588
|
+
if elem.Type == yc.Type {
|
|
589
|
+
xc = elem
|
|
590
|
+
break
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
if xc == nil {
|
|
594
|
+
return false
|
|
595
|
+
}
|
|
596
|
+
for _, yv := range yc.Values {
|
|
597
|
+
if anyOf(xc.Values, func(xv *MetadataConstantValue) bool { return reflect.DeepEqual(xv.Value, yv.Value) }) == false {
|
|
598
|
+
return false
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
if len(x.Functions) == 0 && len(y.Functions) != 0 {
|
|
603
|
+
return false
|
|
604
|
+
}
|
|
605
|
+
return true
|
|
606
606
|
}
|
|
607
607
|
|
|
608
608
|
func MetadataSchema_merge(x *MetadataSchema, y *MetadataSchema) *MetadataSchema {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
609
|
+
output := MetadataSchema_create(MetadataSchema{
|
|
610
|
+
Any: x.Any || y.Any,
|
|
611
|
+
Nullable: x.Nullable || y.Nullable,
|
|
612
|
+
Required: x.Required && y.Required,
|
|
613
|
+
Optional: x.Optional || y.Optional,
|
|
614
|
+
Functions: firstNonEmpty(x.Functions, y.Functions),
|
|
615
|
+
Escaped: mergeEscaped(x.Escaped, y.Escaped),
|
|
616
|
+
Atomics: append([]*MetadataAtomic{}, x.Atomics...),
|
|
617
|
+
Constants: append([]*MetadataConstant{}, x.Constants...),
|
|
618
|
+
Templates: append([]*MetadataTemplate{}, x.Templates...),
|
|
619
|
+
Rest: mergeRest(x.Rest, y.Rest),
|
|
620
|
+
Arrays: append([]*MetadataArray{}, x.Arrays...),
|
|
621
|
+
Tuples: append([]*MetadataTuple{}, x.Tuples...),
|
|
622
|
+
Objects: append([]*MetadataObject{}, x.Objects...),
|
|
623
|
+
Aliases: append([]*MetadataAlias{}, x.Aliases...),
|
|
624
|
+
Natives: append([]*MetadataNative{}, x.Natives...),
|
|
625
|
+
Sets: append([]*MetadataSet{}, x.Sets...),
|
|
626
|
+
Maps: append([]*MetadataMap{}, x.Maps...),
|
|
627
|
+
})
|
|
628
|
+
mergeTagged(&output.Atomics, y.Atomics, func(a, b *MetadataAtomic) bool { return a.Type == b.Type }, func(v *MetadataAtomic) *[][]IMetadataTypeTag { return &v.Tags })
|
|
629
|
+
mergeTagged(&output.Arrays, y.Arrays, func(a, b *MetadataArray) bool { return a.Type.Name == b.Type.Name }, func(v *MetadataArray) *[][]IMetadataTypeTag { return &v.Tags })
|
|
630
|
+
mergeTagged(&output.Tuples, y.Tuples, func(a, b *MetadataTuple) bool { return a.Type.Name == b.Type.Name }, func(v *MetadataTuple) *[][]IMetadataTypeTag { return &v.Tags })
|
|
631
|
+
mergeTagged(&output.Objects, y.Objects, func(a, b *MetadataObject) bool { return a.Type.Name == b.Type.Name }, func(v *MetadataObject) *[][]IMetadataTypeTag { return &v.Tags })
|
|
632
|
+
mergeTagged(&output.Aliases, y.Aliases, func(a, b *MetadataAlias) bool { return a.Type.Name == b.Type.Name }, func(v *MetadataAlias) *[][]IMetadataTypeTag { return &v.Tags })
|
|
633
|
+
mergeTagged(&output.Natives, y.Natives, func(a, b *MetadataNative) bool { return a.Name == b.Name }, func(v *MetadataNative) *[][]IMetadataTypeTag { return &v.Tags })
|
|
634
|
+
mergeTagged(&output.Sets, y.Sets, func(a, b *MetadataSet) bool { return a.Value.GetName() == b.Value.GetName() }, func(v *MetadataSet) *[][]IMetadataTypeTag { return &v.Tags })
|
|
635
|
+
mergeTagged(&output.Maps, y.Maps, func(a, b *MetadataMap) bool {
|
|
636
|
+
return a.Key.GetName() == b.Key.GetName() && a.Value.GetName() == b.Value.GetName()
|
|
637
|
+
}, func(v *MetadataMap) *[][]IMetadataTypeTag { return &v.Tags })
|
|
638
|
+
for _, constant := range y.Constants {
|
|
639
|
+
var target *MetadataConstant
|
|
640
|
+
for _, elem := range output.Constants {
|
|
641
|
+
if elem.Type == constant.Type {
|
|
642
|
+
target = elem
|
|
643
|
+
break
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
if target == nil {
|
|
647
|
+
target = MetadataConstant_create(MetadataConstant{Type: constant.Type, Values: []*MetadataConstantValue{}})
|
|
648
|
+
output.Constants = append(output.Constants, target)
|
|
649
|
+
}
|
|
650
|
+
for _, value := range constant.Values {
|
|
651
|
+
if anyOf(target.Values, func(elem *MetadataConstantValue) bool { return reflect.DeepEqual(elem.Value, value.Value) }) == false {
|
|
652
|
+
target.Values = append(target.Values, value)
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
return output
|
|
657
657
|
}
|
|
658
658
|
|
|
659
659
|
func MetadataSchema_unalias(w *MetadataSchema) *MetadataSchema {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
660
|
+
visited := map[*MetadataSchema]struct{}{}
|
|
661
|
+
for w.Size() == 1 && w.Nullable == false && w.IsRequired() && len(w.Aliases) == 1 {
|
|
662
|
+
if _, ok := visited[w]; ok {
|
|
663
|
+
break
|
|
664
|
+
}
|
|
665
|
+
visited[w] = struct{}{}
|
|
666
|
+
w = w.Aliases[0].Type.Value
|
|
667
|
+
}
|
|
668
|
+
return w
|
|
669
669
|
}
|
|
670
670
|
|
|
671
671
|
func metadataSchema_getName(metadata *MetadataSchema) string {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
672
|
+
if metadata.Any {
|
|
673
|
+
return "any"
|
|
674
|
+
}
|
|
675
|
+
elements := []string{}
|
|
676
|
+
if metadata.Nullable {
|
|
677
|
+
elements = append(elements, "null")
|
|
678
|
+
}
|
|
679
|
+
if metadata.IsRequired() == false {
|
|
680
|
+
elements = append(elements, "undefined")
|
|
681
|
+
}
|
|
682
|
+
for _, atom := range metadata.Atomics {
|
|
683
|
+
elements = append(elements, atom.GetName())
|
|
684
|
+
}
|
|
685
|
+
for _, constant := range metadata.Constants {
|
|
686
|
+
for _, value := range constant.Values {
|
|
687
|
+
elements = append(elements, value.GetName())
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
for _, template := range metadata.Templates {
|
|
691
|
+
elements = append(elements, template.GetName())
|
|
692
|
+
}
|
|
693
|
+
for _, native := range metadata.Natives {
|
|
694
|
+
elements = append(elements, native.GetName())
|
|
695
|
+
}
|
|
696
|
+
for _, set := range metadata.Sets {
|
|
697
|
+
elements = append(elements, set.GetName())
|
|
698
|
+
}
|
|
699
|
+
for _, m := range metadata.Maps {
|
|
700
|
+
elements = append(elements, m.GetName())
|
|
701
|
+
}
|
|
702
|
+
if metadata.Rest != nil {
|
|
703
|
+
elements = append(elements, "..."+metadata.Rest.GetName())
|
|
704
|
+
}
|
|
705
|
+
for _, tuple := range metadata.Tuples {
|
|
706
|
+
elements = append(elements, tuple.Type.Name)
|
|
707
|
+
}
|
|
708
|
+
for _, array := range metadata.Arrays {
|
|
709
|
+
elements = append(elements, array.GetName())
|
|
710
|
+
}
|
|
711
|
+
for _, object := range metadata.Objects {
|
|
712
|
+
elements = append(elements, object.GetName())
|
|
713
|
+
}
|
|
714
|
+
for _, alias := range metadata.Aliases {
|
|
715
|
+
elements = append(elements, alias.GetName())
|
|
716
|
+
}
|
|
717
|
+
if metadata.Escaped != nil {
|
|
718
|
+
elements = append(elements, metadata.Escaped.GetName())
|
|
719
|
+
}
|
|
720
|
+
if len(elements) == 0 {
|
|
721
|
+
return "unknown"
|
|
722
|
+
}
|
|
723
|
+
if len(elements) == 1 {
|
|
724
|
+
return elements[0]
|
|
725
|
+
}
|
|
726
|
+
sort.Strings(elements)
|
|
727
|
+
return "(" + strings.Join(elements, " | ") + ")"
|
|
728
728
|
}
|
|
729
729
|
|
|
730
730
|
func cloneTagMatrix(input [][]IMetadataTypeTag) [][]IMetadataTypeTag {
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
731
|
+
if input == nil {
|
|
732
|
+
return nil
|
|
733
|
+
}
|
|
734
|
+
output := make([][]IMetadataTypeTag, len(input))
|
|
735
|
+
for i, row := range input {
|
|
736
|
+
output[i] = append([]IMetadataTypeTag{}, row...)
|
|
737
|
+
}
|
|
738
|
+
return output
|
|
739
739
|
}
|
|
740
740
|
|
|
741
741
|
func taggedName(base string, tags [][]IMetadataTypeTag) string {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
742
|
+
if len(tags) == 0 {
|
|
743
|
+
return base
|
|
744
|
+
}
|
|
745
|
+
if len(tags) == 1 {
|
|
746
|
+
row := []string{base}
|
|
747
|
+
for _, tag := range tags[0] {
|
|
748
|
+
row = append(row, tag.Name)
|
|
749
|
+
}
|
|
750
|
+
return "(" + strings.Join(row, " & ") + ")"
|
|
751
|
+
}
|
|
752
|
+
rows := make([]string, 0, len(tags))
|
|
753
|
+
for _, row := range tags {
|
|
754
|
+
names := make([]string, 0, len(row))
|
|
755
|
+
for _, tag := range row {
|
|
756
|
+
names = append(names, tag.Name)
|
|
757
|
+
}
|
|
758
|
+
str := strings.Join(names, " & ")
|
|
759
|
+
if len(row) == 1 {
|
|
760
|
+
rows = append(rows, str)
|
|
761
|
+
} else {
|
|
762
|
+
rows = append(rows, "("+str+")")
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return "(" + base + " & (" + strings.Join(rows, " | ") + "))"
|
|
766
766
|
}
|
|
767
767
|
|
|
768
768
|
func safeMetadataName(meta *MetadataSchema) string {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
769
|
+
if meta == nil {
|
|
770
|
+
return "unknown"
|
|
771
|
+
}
|
|
772
|
+
return meta.GetName()
|
|
773
773
|
}
|
|
774
774
|
|
|
775
775
|
func anyOf[T any](input []T, pred func(T) bool) bool {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
776
|
+
for _, elem := range input {
|
|
777
|
+
if pred(elem) {
|
|
778
|
+
return true
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
return false
|
|
782
782
|
}
|
|
783
783
|
|
|
784
784
|
func firstNonEmpty[T any](x []T, y []T) []T {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
785
|
+
if len(x) != 0 {
|
|
786
|
+
return x
|
|
787
|
+
}
|
|
788
|
+
return y
|
|
789
789
|
}
|
|
790
790
|
|
|
791
791
|
func mergeEscaped(x *MetadataEscaped, y *MetadataEscaped) *MetadataEscaped {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
792
|
+
if x != nil && y != nil {
|
|
793
|
+
return MetadataEscaped_create(MetadataEscaped{
|
|
794
|
+
Original: MetadataSchema_merge(x.Original, y.Original),
|
|
795
|
+
Returns: MetadataSchema_merge(x.Returns, y.Returns),
|
|
796
|
+
})
|
|
797
|
+
}
|
|
798
|
+
if x != nil {
|
|
799
|
+
return x
|
|
800
|
+
}
|
|
801
|
+
return y
|
|
802
802
|
}
|
|
803
803
|
|
|
804
804
|
func mergeRest(x *MetadataSchema, y *MetadataSchema) *MetadataSchema {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
805
|
+
if x != nil && y != nil {
|
|
806
|
+
return MetadataSchema_merge(x, y)
|
|
807
|
+
}
|
|
808
|
+
if x != nil {
|
|
809
|
+
return x
|
|
810
|
+
}
|
|
811
|
+
return y
|
|
812
812
|
}
|
|
813
813
|
|
|
814
814
|
func mergeTagged[T any](container *[]T, opposite []T, equals func(T, T) bool, getter func(T) *[][]IMetadataTypeTag) {
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
815
|
+
for _, elem := range opposite {
|
|
816
|
+
var equal T
|
|
817
|
+
found := false
|
|
818
|
+
for _, x := range *container {
|
|
819
|
+
if equals(x, elem) {
|
|
820
|
+
equal = x
|
|
821
|
+
found = true
|
|
822
|
+
break
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
if found == false {
|
|
826
|
+
*container = append(*container, elem)
|
|
827
|
+
continue
|
|
828
|
+
}
|
|
829
|
+
matrix := make([][]string, 0)
|
|
830
|
+
for _, tags := range *getter(equal) {
|
|
831
|
+
names := make([]string, 0, len(tags))
|
|
832
|
+
for _, tag := range tags {
|
|
833
|
+
names = append(names, tag.Name)
|
|
834
|
+
}
|
|
835
|
+
sort.Strings(names)
|
|
836
|
+
matrix = append(matrix, names)
|
|
837
|
+
}
|
|
838
|
+
for _, tags := range *getter(elem) {
|
|
839
|
+
names := make([]string, 0, len(tags))
|
|
840
|
+
for _, tag := range tags {
|
|
841
|
+
names = append(names, tag.Name)
|
|
842
|
+
}
|
|
843
|
+
sort.Strings(names)
|
|
844
|
+
if anyOf(matrix, func(row []string) bool { return stringSliceEqual(row, names) }) {
|
|
845
|
+
continue
|
|
846
|
+
}
|
|
847
|
+
target := getter(equal)
|
|
848
|
+
*target = append(*target, tags)
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
851
|
}
|
|
852
852
|
|
|
853
853
|
func stringSliceEqual(x []string, y []string) bool {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
854
|
+
if len(x) != len(y) {
|
|
855
|
+
return false
|
|
856
|
+
}
|
|
857
|
+
for i := range x {
|
|
858
|
+
if x[i] != y[i] {
|
|
859
|
+
return false
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return true
|
|
863
863
|
}
|