├── .github ├── CODEOWNERS ├── dependabot.yaml └── workflows │ ├── ci.yaml │ ├── docs.yaml │ ├── grafana-foundation-sdk-diff-preview.yaml │ └── release.yaml ├── .gitignore ├── .gitmodules ├── .golangci.yaml ├── .goreleaser.yaml ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── catalog-info.yaml ├── cmd ├── cli │ ├── generate │ │ └── command.go │ ├── inspect │ │ └── command.go │ └── main.go ├── cog-config-schemas │ └── main.go └── compiler-passes-docs │ └── main.go ├── config ├── ci │ └── php │ │ └── phpstan.neon ├── foundation_sdk.dev.yaml └── foundation_sdk.tests.yaml ├── devbox.d └── php │ ├── php-fpm.conf │ └── php.ini ├── devbox.json ├── devbox.lock ├── docs ├── assets │ ├── custom.css │ └── logo.svg ├── index.md ├── pipelines │ ├── builder_transformations.md │ ├── creating_pipeline.md │ ├── index.md │ └── schema_transformations.md └── reference │ ├── builders_transformations.md │ ├── glossary.md │ ├── index.md │ ├── schema_transformations.md │ └── template_blocks.md ├── examples ├── _as_library │ └── main.go ├── _go │ ├── common.go │ ├── cpu.go │ ├── disk.go │ ├── logs.go │ ├── main.go │ ├── memory.go │ └── network.go ├── _go_alerting │ └── main.go ├── java │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── test │ │ ├── CPU.java │ │ ├── Common.java │ │ ├── Disk.java │ │ ├── Logs.java │ │ ├── Main.java │ │ ├── Memory.java │ │ └── Network.java ├── php │ ├── composer.json │ ├── composer.lock │ ├── index.php │ └── src │ │ └── Monitoring │ │ ├── CPU.php │ │ ├── Common.php │ │ ├── Disk.php │ │ ├── Logs.php │ │ ├── Memory.php │ │ └── Network.php ├── python │ ├── main.py │ └── raspberry │ │ ├── .gitignore │ │ ├── __init__.py │ │ ├── common.py │ │ ├── cpu.py │ │ ├── disk.py │ │ ├── logs.py │ │ ├── memory.py │ │ └── network.py └── typescript │ ├── common.ts │ ├── cpu.ts │ ├── disk.ts │ ├── index.ts │ ├── logs.ts │ ├── memory.ts │ └── network.ts ├── examples_test.go ├── go.mod ├── go.sum ├── helpers.go ├── helpers_test.go ├── internal ├── ast │ ├── builder.go │ ├── builder_factories.go │ ├── buildervisitor.go │ ├── compiler │ │ ├── add_fields.go │ │ ├── add_fields_test.go │ │ ├── add_object.go │ │ ├── anonymous_enum.go │ │ ├── anonymous_enum_test.go │ │ ├── anonymous_structs_to_named.go │ │ ├── append_comment_objects.go │ │ ├── append_comment_objects_test.go │ │ ├── compiler.go │ │ ├── constant_to_enum.go │ │ ├── constant_to_enum_test.go │ │ ├── dataquery_identification.go │ │ ├── disjunction_of_constants_to_enum.go │ │ ├── disjunction_of_constants_to_enum_test.go │ │ ├── disjunction_with_constant_to_default.go │ │ ├── disjunction_with_constant_to_default_test.go │ │ ├── disjunctions.go │ │ ├── disjunctions_infer_mapping.go │ │ ├── disjunctions_infer_mapping_test.go │ │ ├── disjunctions_of_anonymous_to_explicit.go │ │ ├── disjunctions_of_anonymous_to_explicit_test.go │ │ ├── disjunctions_test.go │ │ ├── disjunctions_with_null_to_optional.go │ │ ├── disjunctions_with_null_to_optional_test.go │ │ ├── duplicate_object.go │ │ ├── fields_set_default.go │ │ ├── fields_set_default_test.go │ │ ├── fields_set_not_required.go │ │ ├── fields_set_required.go │ │ ├── fields_set_required_test.go │ │ ├── filter_schemas.go │ │ ├── filter_schemas_test.go │ │ ├── flatten_disjunctions.go │ │ ├── flatten_disjunctions_test.go │ │ ├── hint_object.go │ │ ├── hint_object_test.go │ │ ├── infer_entrypoint.go │ │ ├── inline_objects_with_types.go │ │ ├── inline_objects_with_types_test.go │ │ ├── name_anonymous_struct.go │ │ ├── name_anonymous_struct_test.go │ │ ├── not_required_as_nullable.go │ │ ├── not_required_as_nullable_test.go │ │ ├── omit.go │ │ ├── omit_fields.go │ │ ├── omit_fields_test.go │ │ ├── omit_test.go │ │ ├── prefix_enum_values.go │ │ ├── prefix_enum_values_test.go │ │ ├── prefix_object_names_test.go │ │ ├── prefix_objects_names.go │ │ ├── remove_intersections.go │ │ ├── rename_numeric_enum_values.go │ │ ├── rename_numeric_enum_values_test.go │ │ ├── rename_object.go │ │ ├── rename_object_test.go │ │ ├── replace_reference.go │ │ ├── replace_reference_test.go │ │ ├── retype_field.go │ │ ├── retype_field_test.go │ │ ├── retype_object.go │ │ ├── retype_object_test.go │ │ ├── sanitize_enum_member_names.go │ │ ├── schema_set_entrypoint.go │ │ ├── schema_set_identifier.go │ │ ├── trim_enum_values.go │ │ ├── trim_enum_values_test.go │ │ ├── types.go │ │ ├── undiscriminated_disjunctions_to_any.go │ │ ├── undiscriminated_disjunctions_to_any_test.go │ │ ├── unspec.go │ │ ├── unspec_test.go │ │ ├── utils_test.go │ │ └── visitor.go │ ├── hints.go │ ├── schema.go │ ├── tools.go │ ├── types.go │ └── types_test.go ├── codegen │ ├── cue.go │ ├── input.go │ ├── jsonschema.go │ ├── kindregistry.go │ ├── kindsyscomposable.go │ ├── kindsyscore.go │ ├── openapi.go │ ├── options.go │ ├── output.go │ ├── pipeline.go │ ├── run.go │ ├── tools.go │ └── transforms.go ├── envvars │ └── env.go ├── jennies │ ├── common │ │ ├── apireference.go │ │ ├── codejen.go │ │ ├── codejen_test.go │ │ ├── customtemplate.go │ │ ├── dynamicfilestemplate.go │ │ ├── importmap.go │ │ ├── repotemplate.go │ │ └── templatehelpers.go │ ├── golang │ │ ├── apiref.go │ │ ├── builder.go │ │ ├── builder_test.go │ │ ├── converter.go │ │ ├── converter_test.go │ │ ├── equality.go │ │ ├── equality_test.go │ │ ├── imports.go │ │ ├── jennies.go │ │ ├── jsonmarshalling.go │ │ ├── postprocessor.go │ │ ├── rawtypes.go │ │ ├── rawtypes_test.go │ │ ├── runtime.go │ │ ├── strictjson.go │ │ ├── templates │ │ │ ├── builders │ │ │ │ ├── args.tmpl │ │ │ │ ├── assignment.tmpl │ │ │ │ ├── builder.tmpl │ │ │ │ ├── factory.tmpl │ │ │ │ ├── nilcheck.tmpl │ │ │ │ └── options.tmpl │ │ │ ├── converters │ │ │ │ └── converter.tmpl │ │ │ ├── runtime │ │ │ │ └── tools.tmpl │ │ │ └── types │ │ │ │ ├── dataquery_equality_method.tmpl │ │ │ │ ├── disjunction_of_refs.json_marshal.tmpl │ │ │ │ ├── disjunction_of_refs.json_unmarshal.tmpl │ │ │ │ ├── disjunction_of_refs.strict.json_unmarshal.tmpl │ │ │ │ ├── disjunction_of_scalars.json_marshal.tmpl │ │ │ │ ├── disjunction_of_scalars.json_unmarshal.tmpl │ │ │ │ ├── disjunction_of_scalars.strict.json_unmarshal.tmpl │ │ │ │ ├── struct.strict.json_unmarshal.tmpl │ │ │ │ ├── struct_equality_method.tmpl │ │ │ │ └── struct_validation_method.tmpl │ │ ├── tmpl.go │ │ ├── tools.go │ │ ├── types.go │ │ ├── validation.go │ │ └── validation_test.go │ ├── java │ │ ├── apiref.go │ │ ├── builder.go │ │ ├── builder_test.go │ │ ├── converter.go │ │ ├── deserializers.go │ │ ├── factory.go │ │ ├── imports.go │ │ ├── jennies.go │ │ ├── jsonmarshalling.go │ │ ├── rawtypes.go │ │ ├── rawtypes_test.go │ │ ├── runtime.go │ │ ├── serializers.go │ │ ├── templates │ │ │ ├── builders │ │ │ │ ├── args.tmpl │ │ │ │ ├── assigments.tmpl │ │ │ │ ├── builder.tmpl │ │ │ │ ├── constraints.tmpl │ │ │ │ ├── factories.tmpl │ │ │ │ ├── nilcheck.tmpl │ │ │ │ └── panel_builder.tmpl │ │ │ ├── converters │ │ │ │ ├── converter.tmpl │ │ │ │ ├── converter_runtime.tmpl │ │ │ │ └── dataquery_converter.tmpl │ │ │ ├── marshalling │ │ │ │ ├── disjunctions.json_marshall.tmpl │ │ │ │ ├── disjunctions_of_refs.json_unmarshall.tmpl │ │ │ │ ├── disjunctions_of_scalars.json_marshall.tmpl │ │ │ │ ├── disjunctions_of_scalars.json_unmarshall.tmpl │ │ │ │ ├── marshalling.tmpl │ │ │ │ └── unmarshalling.tmpl │ │ │ ├── runtime │ │ │ │ ├── builder.tmpl │ │ │ │ ├── converter_interface.tmpl │ │ │ │ └── variants.tmpl │ │ │ └── types │ │ │ │ ├── class.tmpl │ │ │ │ ├── constants.tmpl │ │ │ │ └── enum.tmpl │ │ ├── tmpl.go │ │ ├── tools.go │ │ └── types.go │ ├── jsonschema │ │ ├── jennies.go │ │ ├── schema.go │ │ └── schema_test.go │ ├── openapi │ │ ├── jennies.go │ │ ├── schema.go │ │ └── schema_test.go │ ├── php │ │ ├── add_typehints_comments.go │ │ ├── apiref.go │ │ ├── builder.go │ │ ├── builder_test.go │ │ ├── converter.go │ │ ├── converter_test.go │ │ ├── factory.go │ │ ├── jennies.go │ │ ├── rawtypes.go │ │ ├── rawtypes_test.go │ │ ├── runtime.go │ │ ├── shape.go │ │ ├── templates │ │ │ ├── builders │ │ │ │ ├── args.tmpl │ │ │ │ ├── assignment.tmpl │ │ │ │ ├── builder.tmpl │ │ │ │ ├── constraints.tmpl │ │ │ │ ├── factories.tmpl │ │ │ │ ├── factory.tmpl │ │ │ │ ├── nilcheck.tmpl │ │ │ │ └── option.tmpl │ │ │ ├── converters │ │ │ │ └── converter.tmpl │ │ │ ├── runtime │ │ │ │ └── builder.tmpl │ │ │ └── types │ │ │ │ └── enum.tmpl │ │ ├── tmpl.go │ │ ├── tools.go │ │ ├── typehints.go │ │ └── types.go │ ├── python │ │ ├── apiref.go │ │ ├── builder.go │ │ ├── builder_test.go │ │ ├── imports.go │ │ ├── jennies.go │ │ ├── module_init.go │ │ ├── rawtypes.go │ │ ├── rawtypes_test.go │ │ ├── runtime.go │ │ ├── templates │ │ │ ├── builders │ │ │ │ ├── args.tmpl │ │ │ │ ├── assignment.tmpl │ │ │ │ ├── builder.tmpl │ │ │ │ ├── comments.tmpl │ │ │ │ ├── constraints.tmpl │ │ │ │ ├── factories.tmpl │ │ │ │ ├── factory.tmpl │ │ │ │ ├── nilcheck.tmpl │ │ │ │ └── options.tmpl │ │ │ └── runtime │ │ │ │ ├── builder.tmpl │ │ │ │ └── encoder.tmpl │ │ ├── tmpl.go │ │ ├── tools.go │ │ └── types.go │ ├── template │ │ ├── blocks.go │ │ └── template.go │ └── typescript │ │ ├── apiref.go │ │ ├── builder.go │ │ ├── builder_test.go │ │ ├── imports.go │ │ ├── index.go │ │ ├── jennies.go │ │ ├── rawtypes.go │ │ ├── rawtypes_test.go │ │ ├── runtime.go │ │ ├── runtime_test.go │ │ ├── templates │ │ ├── args.tmpl │ │ ├── builder.tmpl │ │ ├── constraints.tmpl │ │ ├── factory.tmpl │ │ ├── nilcheck.tmpl │ │ └── options.tmpl │ │ ├── tmpl.go │ │ ├── tools.go │ │ └── types.go ├── jsonschema │ ├── generator.go │ ├── generator_test.go │ └── utils.go ├── languages │ ├── config.go │ ├── context.go │ ├── context_test.go │ ├── converter.go │ ├── language.go │ └── nilchecks.go ├── openapi │ ├── generator.go │ ├── generator_test.go │ └── utils.go ├── orderedmap │ ├── map.go │ └── map_test.go ├── semver │ └── semver.go ├── simplecue │ ├── generator.go │ ├── generator_test.go │ ├── referenceresolver.go │ └── utils.go ├── testutils │ ├── constants.go │ ├── jennytestsuite.go │ └── orderedmap.go ├── tools │ ├── arrays.go │ ├── maps.go │ ├── regexp.go │ ├── strings.go │ └── types.go ├── veneers │ ├── builder │ │ ├── rules.go │ │ ├── rules_test.go │ │ ├── selectors.go │ │ └── selectors_test.go │ ├── option │ │ ├── actions.go │ │ ├── actions_test.go │ │ ├── rules.go │ │ ├── selectors.go │ │ └── selectors_test.go │ ├── rewrite │ │ ├── rewrite.go │ │ └── rewrite_test.go │ └── types.go └── yaml │ ├── builder.go │ ├── compiler.go │ ├── compilerpasses.go │ ├── option.go │ ├── veneers.go │ └── veneers_test.go ├── mkdocs-github.yml ├── mkdocs.yml ├── requirements.txt ├── schemas ├── compiler_passes.json ├── pipeline.json └── veneers.json ├── scripts └── ci │ ├── build-go.sh │ ├── build-java.sh │ ├── build-php.sh │ ├── build-python.sh │ └── build-ts.sh ├── testdata ├── generated │ ├── cog │ │ ├── errors.go │ │ ├── plugins │ │ │ └── variants.go │ │ ├── runtime.go │ │ └── variants │ │ │ └── variants.go │ ├── defaults │ │ └── types_gen.go │ ├── equality │ │ └── types_gen.go │ └── validation │ │ └── types_gen.go ├── jennies │ ├── builders │ │ ├── anonymous_struct │ │ │ ├── GoBuilder │ │ │ │ └── anonymous_struct │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── anonymous_struct │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── AnonymousStruct │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── anonymousStruct │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── array_append │ │ │ ├── GoBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── sandbox │ │ │ │ │ └── somestruct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── SomeStructConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── sandbox.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── sandbox │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── basic_struct │ │ │ ├── GoBuilder │ │ │ │ └── basic_struct │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── basic_struct │ │ │ │ │ └── somestruct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── basic_struct │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── BasicStruct │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── BasicStruct │ │ │ │ │ └── SomeStructConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── basic_struct.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── basicStruct │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ ├── builders_context.json │ │ │ └── schema.cue │ │ ├── basic_struct_defaults │ │ │ ├── GoBuilder │ │ │ │ └── basic_struct_defaults │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── basic_struct_defaults │ │ │ │ │ └── somestruct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── basic_struct_defaults │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── BasicStructDefaults │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── BasicStructDefaults │ │ │ │ │ └── SomeStructConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── basic_struct_defaults.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── basicStructDefaults │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ ├── builders_context.json │ │ │ └── schema.cue │ │ ├── builder_delegation │ │ │ ├── GoBuilder │ │ │ │ └── builder_delegation │ │ │ │ │ ├── dashboard_builder_gen.go │ │ │ │ │ └── dashboardlink_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── builder_delegation │ │ │ │ │ ├── dashboard_converter_gen.go │ │ │ │ │ └── dashboardlink_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── builder_delegation │ │ │ │ │ ├── DashboardBuilder.java │ │ │ │ │ └── DashboardLinkBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── BuilderDelegation │ │ │ │ │ ├── DashboardBuilder.php │ │ │ │ │ └── DashboardLinkBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── BuilderDelegation │ │ │ │ │ ├── DashboardConverter.php │ │ │ │ │ └── DashboardLinkConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── builder_delegation.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── builderDelegation │ │ │ │ │ ├── dashboardBuilder.gen.ts │ │ │ │ │ └── dashboardLinkBuilder.gen.ts │ │ │ ├── builders_context.json │ │ │ └── schema.cue │ │ ├── builder_delegation_in_disjunction │ │ │ ├── JavaBuilder │ │ │ │ └── builder_delegation_in_disjunction │ │ │ │ │ ├── DashboardBuilder.java │ │ │ │ │ ├── DashboardLinkBuilder.java │ │ │ │ │ └── ExternalLinkBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── BuilderDelegationInDisjunction │ │ │ │ │ ├── DashboardBuilder.php │ │ │ │ │ ├── DashboardLinkBuilder.php │ │ │ │ │ └── ExternalLinkBuilder.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── builder_delegation_in_disjunction.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── builderDelegationInDisjunction │ │ │ │ │ ├── dashboardBuilder.gen.ts │ │ │ │ │ ├── dashboardLinkBuilder.gen.ts │ │ │ │ │ └── externalLinkBuilder.gen.ts │ │ │ ├── builders_context.json │ │ │ └── schema.cue │ │ ├── composable_slot │ │ │ ├── GoBuilder │ │ │ │ └── composable_slot │ │ │ │ │ └── lokibuilder_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── composable_slot │ │ │ │ │ └── lokibuilder_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── composable_slot │ │ │ │ │ └── LokiBuilderBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── ComposableSlot │ │ │ │ │ └── LokiBuilderBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── ComposableSlot │ │ │ │ │ └── LokiBuilderConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── composable_slot.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── composableSlot │ │ │ │ │ └── lokiBuilderBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── constant_assignment │ │ │ ├── GoBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── sandbox │ │ │ │ │ └── somestruct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── SomeStructConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── sandbox.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── sandbox │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── constraints │ │ │ ├── GoBuilder │ │ │ │ └── constraints │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── constraints │ │ │ │ │ └── somestruct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── constraints │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── Constraints │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── Constraints │ │ │ │ │ └── SomeStructConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── constraints.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── constraints │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ ├── builders_context.json │ │ │ └── schema.cue │ │ ├── constructor_argument │ │ │ ├── GoBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── sandbox │ │ │ │ │ └── somestruct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── SomeStructConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── sandbox.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── sandbox │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── constructor_initializations │ │ │ ├── GoBuilder │ │ │ │ └── constructor_initializations │ │ │ │ │ └── somepanel_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── constructor_initializations │ │ │ │ │ └── somepanel_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── constructor_initializations │ │ │ │ │ └── SomePanelBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── ConstructorInitializations │ │ │ │ │ └── SomePanelBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── ConstructorInitializations │ │ │ │ │ └── SomePanelConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── constructor_initializations.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── constructorInitializations │ │ │ │ │ └── somePanelBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── dashboard_panel │ │ │ ├── JavaBuilder │ │ │ │ └── dashboard │ │ │ │ │ └── PanelBuilder.java │ │ │ └── builders_context.json │ │ ├── dataquery_variant_builder │ │ │ ├── GoBuilder │ │ │ │ └── dataquery_variant_builder │ │ │ │ │ └── lokibuilder_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── dataquery_variant_builder │ │ │ │ │ └── lokibuilder_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── dataquery_variant_builder │ │ │ │ │ └── LokiBuilderBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── DataqueryVariantBuilder │ │ │ │ │ └── LokiBuilderBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── DataqueryVariantBuilder │ │ │ │ │ └── LokiBuilderConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── dataquery_variant_builder.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── dataqueryVariantBuilder │ │ │ │ │ └── lokiBuilderBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── envelope_assignment │ │ │ ├── GoBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── dashboard_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── sandbox │ │ │ │ │ └── dashboard_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── DashboardBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── DashboardBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── DashboardConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── sandbox.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── sandbox │ │ │ │ │ └── dashboardBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── factories │ │ │ ├── GoBuilder │ │ │ │ └── promql │ │ │ │ │ └── funccallexpr_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── promql │ │ │ │ │ └── funccallexpr_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── promql │ │ │ │ │ └── FuncCallExprBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── Promql │ │ │ │ │ └── FuncCallExprBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── Promql │ │ │ │ │ └── FuncCallExprConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── promql.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── promql │ │ │ │ │ └── funcCallExprBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── foreign_builder │ │ │ ├── GoBuilder │ │ │ │ └── builder_pkg │ │ │ │ │ └── somenicebuilder_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── builder_pkg │ │ │ │ │ └── somenicebuilder_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── builder_pkg │ │ │ │ │ └── SomeNiceBuilderBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── BuilderPkg │ │ │ │ │ └── SomeNiceBuilderBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── BuilderPkg │ │ │ │ │ └── SomeNiceBuilderConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── builder_pkg.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── builderPkg │ │ │ │ │ └── someNiceBuilderBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── initialization_safeguards │ │ │ ├── GoBuilder │ │ │ │ └── initialization_safeguards │ │ │ │ │ └── somepanel_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── initialization_safeguards │ │ │ │ │ └── somepanel_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── initialization_safeguards │ │ │ │ │ └── SomePanelBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── InitializationSafeguards │ │ │ │ │ └── SomePanelBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── InitializationSafeguards │ │ │ │ │ └── SomePanelConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── initialization_safeguards.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── initializationSafeguards │ │ │ │ │ └── somePanelBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── known_any │ │ │ ├── GoBuilder │ │ │ │ └── known_any │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── known_any │ │ │ │ │ └── somestruct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── known_any │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── KnownAny │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── KnownAny │ │ │ │ │ └── SomeStructConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── known_any.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── knownAny │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── map_index_assignment │ │ │ ├── GoBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── sandbox │ │ │ │ │ └── somestruct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── SomeStructConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── sandbox.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── sandbox │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── map_of_builders │ │ │ ├── GoBuilder │ │ │ │ └── map_of_builders │ │ │ │ │ ├── dashboard_builder_gen.go │ │ │ │ │ └── panel_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── map_of_builders │ │ │ │ │ ├── dashboard_converter_gen.go │ │ │ │ │ └── panel_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── map_of_builders │ │ │ │ │ ├── DashboardBuilder.java │ │ │ │ │ └── PanelBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── MapOfBuilders │ │ │ │ │ ├── DashboardBuilder.php │ │ │ │ │ └── PanelBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── MapOfBuilders │ │ │ │ │ ├── DashboardConverter.php │ │ │ │ │ └── PanelConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── map_of_builders.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── mapOfBuilders │ │ │ │ │ ├── dashboardBuilder.gen.ts │ │ │ │ │ └── panelBuilder.gen.ts │ │ │ ├── builders_context.json │ │ │ └── schema.cue │ │ ├── nullable_map_assignment │ │ │ ├── GoBuilder │ │ │ │ └── nullable_map_assignment │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── nullable_map_assignment │ │ │ │ │ └── somestruct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── nullable_map_assignment │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── NullableMapAssignment │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── NullableMapAssignment │ │ │ │ │ └── SomeStructConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── nullable_map_assignment.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── nullableMapAssignment │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── package-with-dashes │ │ │ ├── GoBuilder │ │ │ │ └── builderpkg │ │ │ │ │ └── somenicebuilder_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── builderpkg │ │ │ │ │ └── somenicebuilder_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── builderpkg │ │ │ │ │ └── SomeNiceBuilderBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── Builderpkg │ │ │ │ │ └── SomeNiceBuilderBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── Builderpkg │ │ │ │ │ └── SomeNiceBuilderConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── builder-pkg.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── builderPkg │ │ │ │ │ └── someNiceBuilderBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── panel_builders │ │ │ ├── GoBuilder │ │ │ │ └── panelbuilder │ │ │ │ │ └── panel_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── panelbuilder │ │ │ │ │ └── panel_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── panelbuilder │ │ │ │ │ └── PanelBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── Panelbuilder │ │ │ │ │ └── PanelBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── Panelbuilder │ │ │ │ │ └── PanelConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── panelbuilder.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── panelbuilder │ │ │ │ │ └── panelBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── properties │ │ │ ├── GoBuilder │ │ │ │ └── properties │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── properties │ │ │ │ │ └── somestruct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── properties │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── Properties │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── Properties │ │ │ │ │ └── SomeStructConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── properties.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── properties │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── references │ │ │ ├── GoBuilder │ │ │ │ └── some_pkg │ │ │ │ │ └── person_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── some_pkg │ │ │ │ │ └── person_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── some_pkg │ │ │ │ │ └── PersonBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── SomePkg │ │ │ │ │ └── PersonBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── SomePkg │ │ │ │ │ └── PersonConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── some_pkg.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── somePkg │ │ │ │ │ └── personBuilder.gen.ts │ │ │ └── builders_context.json │ │ ├── struct_fields_as_args_assignment │ │ │ ├── GoBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── somestruct_builder_gen.go │ │ │ ├── GoConverter │ │ │ │ └── sandbox │ │ │ │ │ └── somestruct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ │ └── sandbox │ │ │ │ │ └── SomeStructBuilder.java │ │ │ ├── PHPBuilder │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── SomeStructBuilder.php │ │ │ ├── PHPConverter │ │ │ │ └── src │ │ │ │ │ └── Sandbox │ │ │ │ │ └── SomeStructConverter.php │ │ │ ├── PythonBuilder │ │ │ │ └── builders │ │ │ │ │ └── sandbox.py │ │ │ ├── TypescriptBuilder │ │ │ │ └── src │ │ │ │ │ └── sandbox │ │ │ │ │ └── someStructBuilder.gen.ts │ │ │ └── builders_context.json │ │ └── struct_with_defaults │ │ │ ├── GoBuilder │ │ │ └── struct_with_defaults │ │ │ │ ├── nestedstruct_builder_gen.go │ │ │ │ └── struct_builder_gen.go │ │ │ ├── GoConverter │ │ │ └── struct_with_defaults │ │ │ │ ├── nestedstruct_converter_gen.go │ │ │ │ └── struct_converter_gen.go │ │ │ ├── JavaBuilder │ │ │ └── struct_with_defaults │ │ │ │ ├── NestedStructBuilder.java │ │ │ │ └── StructBuilder.java │ │ │ ├── PHPBuilder │ │ │ └── src │ │ │ │ └── StructWithDefaults │ │ │ │ ├── NestedStructBuilder.php │ │ │ │ └── StructBuilder.php │ │ │ ├── PHPConverter │ │ │ └── src │ │ │ │ └── StructWithDefaults │ │ │ │ ├── NestedStructConverter.php │ │ │ │ └── StructConverter.php │ │ │ ├── PythonBuilder │ │ │ └── builders │ │ │ │ └── struct_with_defaults.py │ │ │ ├── TypescriptBuilder │ │ │ └── src │ │ │ │ └── structWithDefaults │ │ │ │ ├── nestedStructBuilder.gen.ts │ │ │ │ └── structBuilder.gen.ts │ │ │ ├── builders_context.json │ │ │ └── schema.cue │ └── rawtypes │ │ ├── arrays │ │ ├── GoRawTypes │ │ │ └── arrays │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── arrays.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── arrays │ │ │ │ └── SomeStruct.java │ │ ├── OpenAPI │ │ │ └── arrays.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Arrays │ │ │ │ └── SomeStruct.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── arrays.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── arrays │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── constant_reference_discriminator │ │ ├── GoRawTypes │ │ │ └── constant_reference_discriminator │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── constant_reference_discriminator.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── constant_reference_discriminator │ │ │ │ ├── Constants.java │ │ │ │ ├── GridLayoutUsingValue.java │ │ │ │ ├── GridLayoutWithoutValue.java │ │ │ │ ├── LayoutWithValue.java │ │ │ │ ├── LayoutWithoutValue.java │ │ │ │ ├── RowsLayoutUsingValue.java │ │ │ │ └── RowsLayoutWithoutValue.java │ │ ├── OpenAPI │ │ │ └── constant_reference_discriminator.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── ConstantReferenceDiscriminator │ │ │ │ ├── Constants.php │ │ │ │ ├── GridLayoutUsingValue.php │ │ │ │ ├── GridLayoutWithoutValue.php │ │ │ │ ├── RowsLayoutUsingValue.php │ │ │ │ └── RowsLayoutWithoutValue.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── constant_reference_discriminator.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── constantReferenceDiscriminator │ │ │ │ └── types.gen.ts │ │ ├── ir.json │ │ └── schema.cue │ │ ├── constant_references │ │ ├── GoRawTypes │ │ │ └── constant_references │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── constant_references.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── constant_references │ │ │ │ ├── Enum.java │ │ │ │ ├── ParentStruct.java │ │ │ │ ├── Struct.java │ │ │ │ ├── StructA.java │ │ │ │ └── StructB.java │ │ ├── OpenAPI │ │ │ └── constant_references.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── ConstantReferences │ │ │ │ ├── Enum.php │ │ │ │ ├── ParentStruct.php │ │ │ │ ├── Struct.php │ │ │ │ ├── StructA.php │ │ │ │ └── StructB.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── constant_references.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── constantReferences │ │ │ │ └── types.gen.ts │ │ ├── ir.json │ │ └── schema.cue │ │ ├── constraints │ │ ├── GoRawTypes │ │ │ └── constraints │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── constraints.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── constraints │ │ │ │ ├── RefStruct.java │ │ │ │ └── SomeStruct.java │ │ ├── OpenAPI │ │ │ └── constraints.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Constraints │ │ │ │ ├── RefStruct.php │ │ │ │ └── SomeStruct.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── constraints.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── constraints │ │ │ │ └── types.gen.ts │ │ ├── ir.json │ │ └── schema.cue │ │ ├── dashboard │ │ ├── GoRawTypes │ │ │ └── dashboard │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── dashboard.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── dashboard │ │ │ │ ├── Dashboard.java │ │ │ │ ├── DataSourceRef.java │ │ │ │ ├── FieldConfig.java │ │ │ │ ├── FieldConfigSource.java │ │ │ │ └── Panel.java │ │ ├── OpenAPI │ │ │ └── dashboard.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Dashboard │ │ │ │ ├── Dashboard.php │ │ │ │ ├── DataSourceRef.php │ │ │ │ ├── FieldConfig.php │ │ │ │ ├── FieldConfigSource.php │ │ │ │ └── Panel.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── dashboard.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── dashboard │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── disjunctions │ │ ├── GoRawTypes │ │ │ └── disjunctions │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── disjunctions.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── disjunctions │ │ │ │ ├── BoolOrRef.java │ │ │ │ ├── RefreshRate.java │ │ │ │ ├── SeveralRefs.java │ │ │ │ ├── SomeOtherStruct.java │ │ │ │ ├── SomeStruct.java │ │ │ │ └── YetAnotherStruct.java │ │ ├── OpenAPI │ │ │ └── disjunctions.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Disjunctions │ │ │ │ ├── SomeOtherStruct.php │ │ │ │ ├── SomeStruct.php │ │ │ │ └── YetAnotherStruct.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── disjunctions.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── disjunctions │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── enums │ │ ├── GoRawTypes │ │ │ └── enums │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── enums.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── enums │ │ │ │ ├── DashboardCursorSync.java │ │ │ │ ├── LogsSortOrder.java │ │ │ │ ├── Operator.java │ │ │ │ └── TableSortOrder.java │ │ ├── OpenAPI │ │ │ └── enums.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Enums │ │ │ │ ├── DashboardCursorSync.php │ │ │ │ ├── LogsSortOrder.php │ │ │ │ ├── Operator.php │ │ │ │ └── TableSortOrder.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── enums.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── enums │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── field_with_struct_with_defaults │ │ ├── GoRawTypes │ │ │ └── defaults │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── defaults.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── defaults │ │ │ │ ├── DefaultsStructComplexField.java │ │ │ │ ├── DefaultsStructComplexFieldNested.java │ │ │ │ ├── DefaultsStructPartialComplexField.java │ │ │ │ ├── NestedStruct.java │ │ │ │ └── Struct.java │ │ ├── OpenAPI │ │ │ └── defaults.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Defaults │ │ │ │ ├── DefaultsStructComplexField.php │ │ │ │ ├── DefaultsStructComplexFieldNested.php │ │ │ │ ├── DefaultsStructPartialComplexField.php │ │ │ │ ├── NestedStruct.php │ │ │ │ └── Struct.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── defaults.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── defaults │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── intersections │ │ ├── GoRawTypes │ │ │ └── intersections │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── intersections.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── intersections │ │ │ │ ├── Intersections.java │ │ │ │ └── SomeStruct.java │ │ ├── OpenAPI │ │ │ └── intersections.openapi.json │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── intersections │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── maps │ │ ├── GoRawTypes │ │ │ └── maps │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── maps.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── maps │ │ │ │ └── SomeStruct.java │ │ ├── OpenAPI │ │ │ └── maps.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Maps │ │ │ │ └── SomeStruct.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── maps.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── maps │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── package-with-dashes │ │ ├── GoRawTypes │ │ │ └── withdashes │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── with-dashes.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── withdashes │ │ │ │ ├── RefreshRate.java │ │ │ │ └── SomeStruct.java │ │ ├── OpenAPI │ │ │ └── with-dashes.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Withdashes │ │ │ │ └── SomeStruct.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── with-dashes.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── withDashes │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── refs │ │ ├── GoRawTypes │ │ │ └── refs │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── refs.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── refs │ │ │ │ ├── RefToSomeStruct.java │ │ │ │ └── RefToSomeStructFromOtherPackage.java │ │ ├── OpenAPI │ │ │ └── refs.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Refs │ │ │ │ ├── RefToSomeStruct.php │ │ │ │ ├── RefToSomeStructFromOtherPackage.php │ │ │ │ └── SomeStruct.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── refs.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── refs │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── scalars │ │ ├── GoRawTypes │ │ │ └── scalars │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── scalars.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── scalars │ │ │ │ └── Constants.java │ │ ├── OpenAPI │ │ │ └── scalars.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Scalars │ │ │ │ └── Constants.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── scalars.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── scalars │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── struct_with_complex_fields │ │ ├── GoRawTypes │ │ │ └── struct_complex_fields │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── struct_complex_fields.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── struct_complex_fields │ │ │ │ ├── Constants.java │ │ │ │ ├── SomeOtherStruct.java │ │ │ │ ├── SomeStruct.java │ │ │ │ ├── SomeStructOperator.java │ │ │ │ ├── StringOrBool.java │ │ │ │ ├── StringOrSomeOtherStruct.java │ │ │ │ └── StructComplexFieldsSomeStructFieldAnonymousStruct.java │ │ ├── OpenAPI │ │ │ └── struct_complex_fields.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── StructComplexFields │ │ │ │ ├── Constants.php │ │ │ │ ├── SomeOtherStruct.php │ │ │ │ ├── SomeStruct.php │ │ │ │ ├── SomeStructOperator.php │ │ │ │ └── StructComplexFieldsSomeStructFieldAnonymousStruct.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── struct_complex_fields.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── structComplexFields │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── struct_with_defaults │ │ ├── GoRawTypes │ │ │ └── defaults │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── defaults.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── defaults │ │ │ │ └── SomeStruct.java │ │ ├── OpenAPI │ │ │ └── defaults.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Defaults │ │ │ │ └── SomeStruct.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── defaults.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── defaults │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── struct_with_optional_fields │ │ ├── GoRawTypes │ │ │ └── struct_optional_fields │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── struct_optional_fields.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── struct_optional_fields │ │ │ │ ├── SomeOtherStruct.java │ │ │ │ ├── SomeStruct.java │ │ │ │ ├── SomeStructOperator.java │ │ │ │ └── StructOptionalFieldsSomeStructFieldAnonymousStruct.java │ │ ├── OpenAPI │ │ │ └── struct_optional_fields.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── StructOptionalFields │ │ │ │ ├── SomeOtherStruct.php │ │ │ │ ├── SomeStruct.php │ │ │ │ ├── SomeStructOperator.php │ │ │ │ └── StructOptionalFieldsSomeStructFieldAnonymousStruct.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── struct_optional_fields.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── structOptionalFields │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── struct_with_scalar_fields │ │ ├── GoRawTypes │ │ │ └── basic │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── basic.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── basic │ │ │ │ └── SomeStruct.java │ │ ├── OpenAPI │ │ │ └── basic.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── Basic │ │ │ │ └── SomeStruct.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── basic.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── basic │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── time_hint │ │ ├── GoRawTypes │ │ │ └── time_hint │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── time_hint.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── time_hint │ │ │ │ └── ObjWithTimeField.java │ │ ├── OpenAPI │ │ │ └── time_hint.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── TimeHint │ │ │ │ └── ObjWithTimeField.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── time_hint.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── timeHint │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── variant_dataquery │ │ ├── GoRawTypes │ │ │ └── variant_dataquery │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── variant_dataquery.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── variant_dataquery │ │ │ │ └── Query.java │ │ ├── OpenAPI │ │ │ └── variant_dataquery.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── VariantDataquery │ │ │ │ └── Query.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── variant_dataquery.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── variantDataquery │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ ├── variant_panelcfg_full │ │ ├── GoRawTypes │ │ │ └── variant_panelcfg_full │ │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ │ └── variant_panelcfg_full.jsonschema.json │ │ ├── JavaRawTypes │ │ │ └── variant_panelcfg_full │ │ │ │ ├── FieldConfig.java │ │ │ │ └── Options.java │ │ ├── OpenAPI │ │ │ └── variant_panelcfg_full.openapi.json │ │ ├── PHPRawTypes │ │ │ └── src │ │ │ │ └── VariantPanelcfgFull │ │ │ │ ├── FieldConfig.php │ │ │ │ └── Options.php │ │ ├── PythonRawTypes │ │ │ └── models │ │ │ │ └── variant_panelcfg_full.py │ │ ├── TypescriptRawTypes │ │ │ └── src │ │ │ │ └── variantPanelcfgFull │ │ │ │ └── types.gen.ts │ │ └── ir.json │ │ └── variant_panelcfg_only_options │ │ ├── GoRawTypes │ │ └── variant_panelcfg_only_options │ │ │ └── types_gen.go │ │ ├── JSONSchema │ │ └── variant_panelcfg_only_options.jsonschema.json │ │ ├── JavaRawTypes │ │ └── variant_panelcfg_only_options │ │ │ └── Options.java │ │ ├── OpenAPI │ │ └── variant_panelcfg_only_options.openapi.json │ │ ├── PHPRawTypes │ │ └── src │ │ │ └── VariantPanelcfgOnlyOptions │ │ │ └── Options.php │ │ ├── PythonRawTypes │ │ └── models │ │ │ └── variant_panelcfg_only_options.py │ │ ├── TypescriptRawTypes │ │ └── src │ │ │ └── variantPanelcfgOnlyOptions │ │ │ └── types.gen.ts │ │ └── ir.json ├── jsonschema │ ├── allof_object │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── anyof_object │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── anyof_struct_field │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── array_any │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── basic_object │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── consts │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── defaults │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── enum │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── influxdbquery │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── number_constraints │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── object_no_properties │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── oneof_object │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── oneof_struct_field │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── recursive │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── ref_struct_field │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── string_length_constraints │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ └── time │ │ ├── GenerateAST │ │ └── ir.json │ │ └── schema.json ├── openapi │ ├── arrays │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── consts │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── datatypes │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── defaults │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── discriminator │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── enums │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── external_refs │ │ ├── GenerateAST │ │ │ └── ir.json │ │ ├── refs │ │ │ └── refs.json │ │ └── schema.json │ ├── intersections │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── nested_structs │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── object_no_properties │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── refs │ │ ├── GenerateAST │ │ │ └── ir.json │ │ └── schema.json │ ├── split_schema │ │ ├── GenerateAST │ │ │ └── ir.json │ │ ├── refs │ │ │ ├── partial.json │ │ │ ├── partial2.json │ │ │ └── refs.json │ │ └── schema.json │ └── time │ │ ├── GenerateAST │ │ └── ir.json │ │ └── schema.json ├── schemas │ ├── defaults │ │ └── defaults.cue │ ├── equality │ │ └── equality.cue │ └── validation │ │ └── validation.cue └── simplecue │ ├── arrays │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── common_timezone_disjunction │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── defaults │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── defaults_on_struct │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── disjunctions │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── enums │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── maps │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── nested_disjunctions │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── numbers_constraints │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── refs │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── scalars │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── strings_constraints │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ ├── time │ ├── GenerateAST │ │ └── ir.json │ └── schema.cue │ └── unifications │ ├── GenerateAST │ └── ir.json │ └── schema.cue └── tsconfig.json /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @grafana/platform-monitoring 2 | -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | groups: 8 | github-actions: 9 | patterns: 10 | - "*" 11 | 12 | - package-ecosystem: "gomod" 13 | directory: "/" 14 | schedule: 15 | interval: "weekly" 16 | groups: 17 | go: 18 | exclude-patterns: 19 | - "cuelang.org/*" 20 | cue: 21 | patterns: 22 | - "cuelang.org/*" 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /generated 2 | /schemas/kind-registry 3 | /examples/php/vendor 4 | /.devbox 5 | /gradle.properties 6 | /vendor 7 | /cog 8 | /docs-site 9 | 10 | # Java building folders 11 | .gradle/ 12 | build/ 13 | 14 | .idea 15 | 16 | dist/ 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "config/foundation-sdk"] 2 | path = config/foundation-sdk 3 | url = https://github.com/grafana/grafana-foundation-sdk.git 4 | -------------------------------------------------------------------------------- /catalog-info.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: backstage.io/v1alpha1 2 | kind: Component 3 | metadata: 4 | name: cog 5 | title: cog 6 | annotations: 7 | backstage.io/techdocs-ref: dir:. 8 | github.com/project-slug: grafana/cog 9 | links: 10 | - title: Slack Channel 11 | url: https://raintank-corp.slack.com/archives/C018SLDD5MW 12 | description: | 13 | Code generation with a human touch 14 | spec: 15 | type: tool 16 | owner: group:default/platform-monitoring 17 | lifecycle: production 18 | -------------------------------------------------------------------------------- /cmd/cli/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/grafana/cog/cmd/cli/generate" 7 | "github.com/grafana/cog/cmd/cli/inspect" 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | var version = "SNAPSHOT" 12 | 13 | func main() { 14 | rootCmd := &cobra.Command{ 15 | Use: "cog ", 16 | Short: "A tool for working with Grafana objects from code", 17 | SilenceUsage: true, 18 | Version: version, 19 | } 20 | 21 | rootCmd.AddCommand(generate.Command()) 22 | rootCmd.AddCommand(inspect.Command()) 23 | 24 | if err := rootCmd.Execute(); err != nil { 25 | os.Exit(1) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /config/ci/php/phpstan.neon: -------------------------------------------------------------------------------- 1 | parameters: 2 | level: 9 # https://phpstan.org/user-guide/rule-levels 3 | paths: 4 | - ../../../generated/php/src 5 | 6 | ignoreErrors: 7 | - identifier: identical.alwaysFalse # not a big deal, duplicated enum values come from the schema 8 | paths: 9 | - ../../../generated/php/src/Common/ScaleDirection.php 10 | - identifier: offsetAccess.nonOffsetAccessible 11 | paths: 12 | - ../../../generated/php/src/Cog/Runtime.php 13 | 14 | # cog being very defensive isn't a bad thing 15 | - identifier: isset.variable 16 | - identifier: instanceof.alwaysTrue 17 | - identifier: function.alreadyNarrowedType 18 | - identifier: arrayFilter.same 19 | -------------------------------------------------------------------------------- /config/foundation_sdk.tests.yaml: -------------------------------------------------------------------------------- 1 | # yaml-language-server: $schema=https://raw.githubusercontent.com/grafana/cog/main/schemas/pipeline.json 2 | 3 | debug: true 4 | 5 | parameters: 6 | output_dir: './testdata/generated' 7 | go_package_root: 'github.com/grafana/cog/testdata/generated' 8 | php_namespace_root: 'Grafana\Foundation' 9 | java_package_path: 'com.grafana.foundation' 10 | 11 | inputs: 12 | - cue: 13 | entrypoint: '%__config_dir%/../testdata/schemas/defaults' 14 | - cue: 15 | entrypoint: '%__config_dir%/../testdata/schemas/equality' 16 | - cue: 17 | entrypoint: '%__config_dir%/../testdata/schemas/validation' 18 | 19 | output: 20 | directory: '%output_dir%' 21 | 22 | types: true 23 | 24 | languages: 25 | - go: 26 | package_root: '%go_package_root%' 27 | generate_json_marshaller: true 28 | generate_strict_unmarshaller: true 29 | generate_equal: true 30 | generate_validate: true 31 | -------------------------------------------------------------------------------- /devbox.d/php/php-fpm.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | pid = ${PHPFPM_PID_FILE} 3 | error_log = ${PHPFPM_ERROR_LOG_FILE} 4 | daemonize = yes 5 | 6 | [www] 7 | ; user = www-data 8 | ; group = www-data 9 | listen = 127.0.0.1:${PHPFPM_PORT} 10 | ; listen.owner = www-data 11 | ; listen.group = www-data 12 | pm = dynamic 13 | pm.max_children = 5 14 | pm.start_servers = 2 15 | pm.min_spare_servers = 1 16 | pm.max_spare_servers = 3 17 | chdir = / 18 | -------------------------------------------------------------------------------- /devbox.d/php/php.ini: -------------------------------------------------------------------------------- 1 | [php] 2 | 3 | opcache.enable_cli=1 4 | 5 | ; Put your php.ini directives here. For the latest default php.ini file, see https://github.com/php/php-src/blob/master/php.ini-production 6 | 7 | ; memory_limit = 128M 8 | ; expose_php = Off 9 | -------------------------------------------------------------------------------- /devbox.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/main/.schema/devbox.schema.json", 3 | "packages": [ 4 | "go@1.23", 5 | "php@8.3", 6 | "php83Packages.composer@2.7", 7 | "php83Packages.phpstan@2.1.1", 8 | "python@3.12", 9 | "golangci-lint@1.61", 10 | "nodejs-slim_18@18.20", 11 | "nodePackages.ts-node@10.9.2", 12 | "gradle@8.10", 13 | "goreleaser@2.2" 14 | ], 15 | "shell": { 16 | "init_hook": [ 17 | "echo 'Entering Python venv' && . $VENV_DIR/bin/activate", 18 | "echo 'Installing dependencies...' && make deps", 19 | "export PYTHONPATH=$PYTHONPATH:$(pwd)/generated/python" 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /docs/reference/builders_transformations.md: -------------------------------------------------------------------------------- 1 | --- 2 | weight: 10 3 | --- 4 | 5 | # Builder transformations 6 | 7 | TBD 8 | -------------------------------------------------------------------------------- /docs/reference/index.md: -------------------------------------------------------------------------------- 1 | # Reference 2 | 3 | -------------------------------------------------------------------------------- /examples/java/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'application' 4 | } 5 | 6 | java { 7 | sourceCompatibility = JavaVersion.VERSION_17 8 | targetCompatibility = JavaVersion.VERSION_17 9 | 10 | withJavadocJar() 11 | withSourcesJar() 12 | } 13 | 14 | application { 15 | mainClass = "test.Main" 16 | } 17 | 18 | allprojects { 19 | version = rootProject.version 20 | apply plugin: "java" 21 | 22 | repositories { 23 | mavenCentral() 24 | mavenLocal() 25 | } 26 | } 27 | 28 | dependencies { 29 | implementation 'com.grafana:grafana-foundation-sdk:0.0' 30 | } 31 | 32 | tasks.withType(Javadoc).configureEach { 33 | options.addStringOption('Xdoclint:-missing', '-quiet') 34 | } 35 | -------------------------------------------------------------------------------- /examples/php/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grafana/cog-example", 3 | "type": "project", 4 | "autoload": { 5 | "psr-4": { 6 | "App\\": "./src", 7 | "Grafana\\Foundation\\": "../../generated/php/src" 8 | } 9 | }, 10 | "require": {} 11 | } 12 | -------------------------------------------------------------------------------- /examples/php/composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "a5fdcb7e077d2cdcfda2fe298318d7b0", 8 | "packages": [], 9 | "packages-dev": [], 10 | "aliases": [], 11 | "minimum-stability": "stable", 12 | "stability-flags": [], 13 | "prefer-stable": false, 14 | "prefer-lowest": false, 15 | "platform": [], 16 | "platform-dev": [], 17 | "plugin-api-version": "2.6.0" 18 | } 19 | -------------------------------------------------------------------------------- /examples/python/raspberry/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | -------------------------------------------------------------------------------- /examples/python/raspberry/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grafana/cog/289fe1abb0b0d3068125de42302f76732b50ed39/examples/python/raspberry/__init__.py -------------------------------------------------------------------------------- /internal/ast/compiler/append_comment_objects.go: -------------------------------------------------------------------------------- 1 | package compiler 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/grafana/cog/internal/ast" 7 | ) 8 | 9 | var _ Pass = (*AppendCommentObjects)(nil) 10 | 11 | // AppendCommentObjects appends the given comment to every object definition. 12 | type AppendCommentObjects struct { 13 | Comment string 14 | } 15 | 16 | func (pass *AppendCommentObjects) Process(schemas []*ast.Schema) ([]*ast.Schema, error) { 17 | visitor := &Visitor{ 18 | OnObject: pass.processObject, 19 | } 20 | 21 | return visitor.VisitSchemas(schemas) 22 | } 23 | 24 | func (pass *AppendCommentObjects) processObject(_ *Visitor, _ *ast.Schema, object ast.Object) (ast.Object, error) { 25 | object.Comments = append(object.Comments, pass.Comment) 26 | object.AddToPassesTrail(fmt.Sprintf("AppendCommentObjects[%s]", pass.Comment)) 27 | 28 | return object, nil 29 | } 30 | -------------------------------------------------------------------------------- /internal/ast/compiler/compiler.go: -------------------------------------------------------------------------------- 1 | package compiler 2 | 3 | import ( 4 | "github.com/grafana/cog/internal/ast" 5 | ) 6 | 7 | type Passes []Pass 8 | 9 | func (passes Passes) Concat(other Passes) Passes { 10 | concat := make([]Pass, 0, len(passes)+len(other)) 11 | 12 | concat = append(concat, passes...) 13 | concat = append(concat, other...) 14 | 15 | return concat 16 | } 17 | 18 | func (passes Passes) Process(schemas ast.Schemas) (ast.Schemas, error) { 19 | var err error 20 | processedSchemas := schemas.DeepCopy() 21 | 22 | for _, compilerPass := range passes { 23 | processedSchemas, err = compilerPass.Process(processedSchemas) 24 | if err != nil { 25 | return nil, err 26 | } 27 | } 28 | 29 | return processedSchemas, nil 30 | } 31 | 32 | type Pass interface { 33 | Process(schemas []*ast.Schema) ([]*ast.Schema, error) 34 | } 35 | -------------------------------------------------------------------------------- /internal/ast/compiler/infer_entrypoint.go: -------------------------------------------------------------------------------- 1 | package compiler 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/grafana/cog/internal/ast" 7 | ) 8 | 9 | var _ Pass = (*InferEntrypoint)(nil) 10 | 11 | type InferEntrypoint struct { 12 | } 13 | 14 | func (pass *InferEntrypoint) Process(schemas []*ast.Schema) ([]*ast.Schema, error) { 15 | for _, schema := range schemas { 16 | if schema.EntryPoint != "" { 17 | continue 18 | } 19 | 20 | schema.EntryPoint = pass.inferEntrypoint(schema) 21 | if schema.EntryPoint != "" { 22 | schema.EntryPointType = schema.Objects.Get(schema.EntryPoint).SelfRef.AsType() 23 | } 24 | } 25 | 26 | return schemas, nil 27 | } 28 | 29 | func (pass *InferEntrypoint) inferEntrypoint(schema *ast.Schema) string { 30 | entrypoint := "" 31 | 32 | schema.Objects.Iterate(func(_ string, object ast.Object) { 33 | if strings.EqualFold(schema.Package, object.Name) { 34 | entrypoint = object.Name 35 | } 36 | }) 37 | 38 | return entrypoint 39 | } 40 | -------------------------------------------------------------------------------- /internal/ast/compiler/omit.go: -------------------------------------------------------------------------------- 1 | package compiler 2 | 3 | import ( 4 | "github.com/grafana/cog/internal/ast" 5 | ) 6 | 7 | var _ Pass = (*Omit)(nil) 8 | 9 | // Omit rewrites schemas to omit the configured objects. 10 | type Omit struct { 11 | Objects []ObjectReference 12 | } 13 | 14 | func (pass *Omit) Process(schemas []*ast.Schema) ([]*ast.Schema, error) { 15 | for i, schema := range schemas { 16 | schemas[i] = pass.processSchema(schema) 17 | } 18 | 19 | return schemas, nil 20 | } 21 | 22 | func (pass *Omit) processSchema(schema *ast.Schema) *ast.Schema { 23 | schema.Objects = schema.Objects.Filter(func(_ string, object ast.Object) bool { 24 | // if any reference matches the current object, we filter it out 25 | for _, objectRef := range pass.Objects { 26 | if objectRef.Matches(object) { 27 | return false 28 | } 29 | } 30 | 31 | return true 32 | }) 33 | 34 | return schema 35 | } 36 | -------------------------------------------------------------------------------- /internal/ast/compiler/replace_reference.go: -------------------------------------------------------------------------------- 1 | package compiler 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/grafana/cog/internal/ast" 7 | ) 8 | 9 | // ReplaceReference replaces any usage of the `From` reference by the one given in `To`. 10 | type ReplaceReference struct { 11 | From ObjectReference 12 | To ObjectReference 13 | } 14 | 15 | func (pass *ReplaceReference) Process(schemas []*ast.Schema) ([]*ast.Schema, error) { 16 | visitor := Visitor{ 17 | OnRef: pass.processRef, 18 | } 19 | 20 | return visitor.VisitSchemas(schemas) 21 | } 22 | 23 | func (pass *ReplaceReference) processRef(_ *Visitor, _ *ast.Schema, def ast.Type) (ast.Type, error) { 24 | if !pass.From.MatchesRef(def.AsRef()) { 25 | return def, nil 26 | } 27 | 28 | return ast.NewRef(pass.To.Package, pass.To.Object, ast.Trail(fmt.Sprintf("ReplaceReference[%s → %s]", def.Ref, pass.To))), nil 29 | } 30 | -------------------------------------------------------------------------------- /internal/ast/compiler/retype_object_test.go: -------------------------------------------------------------------------------- 1 | package compiler 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/grafana/cog/internal/ast" 7 | "github.com/grafana/cog/internal/testutils" 8 | ) 9 | 10 | func TestRetypeObject(t *testing.T) { 11 | // Prepare test input 12 | schema := &ast.Schema{ 13 | Package: "retype_object", 14 | Objects: testutils.ObjectsMap( 15 | ast.NewObject("retype_object", "SomeObject", ast.NewStruct( 16 | ast.NewStructField("AString", ast.String()), 17 | )), 18 | ), 19 | } 20 | expected := &ast.Schema{ 21 | Package: "retype_object", 22 | Objects: testutils.ObjectsMap( 23 | ast.NewObject("retype_object", "SomeObject", ast.Bool(), "RetypeObject[Struct → Bool]"), 24 | ), 25 | } 26 | 27 | pass := &RetypeObject{ 28 | Object: ObjectReference{Package: schema.Package, Object: "SomeObject"}, 29 | As: ast.Bool(), 30 | } 31 | 32 | // Run the compiler pass 33 | runPassOnSchema(t, pass, schema, expected) 34 | } 35 | -------------------------------------------------------------------------------- /internal/ast/compiler/schema_set_entrypoint.go: -------------------------------------------------------------------------------- 1 | package compiler 2 | 3 | import ( 4 | "github.com/grafana/cog/internal/ast" 5 | ) 6 | 7 | var _ Pass = (*SchemaSetEntrypoint)(nil) 8 | 9 | type SchemaSetEntrypoint struct { 10 | Package string // we don't have a "clear" identifier, so we use the package to identify a schema. 11 | EntryPoint string 12 | } 13 | 14 | func (pass *SchemaSetEntrypoint) Process(schemas []*ast.Schema) ([]*ast.Schema, error) { 15 | for _, schema := range schemas { 16 | if schema.Package != pass.Package { 17 | continue 18 | } 19 | 20 | schema.EntryPoint = pass.EntryPoint 21 | schema.EntryPointType = ast.NewRef(schema.Package, pass.EntryPoint) 22 | } 23 | 24 | return schemas, nil 25 | } 26 | -------------------------------------------------------------------------------- /internal/ast/compiler/schema_set_identifier.go: -------------------------------------------------------------------------------- 1 | package compiler 2 | 3 | import ( 4 | "github.com/grafana/cog/internal/ast" 5 | ) 6 | 7 | var _ Pass = (*SchemaSetIdentifier)(nil) 8 | 9 | // SchemaSetIdentifier overwrites the Metadata.Identifier field of a schema. 10 | type SchemaSetIdentifier struct { 11 | Package string // we don't have a "clear" identifier, so we use the package to identify a schema. 12 | Identifier string 13 | } 14 | 15 | func (pass *SchemaSetIdentifier) Process(schemas []*ast.Schema) ([]*ast.Schema, error) { 16 | for _, schema := range schemas { 17 | if schema.Package != pass.Package { 18 | continue 19 | } 20 | 21 | schema.Metadata.Identifier = pass.Identifier 22 | } 23 | 24 | return schemas, nil 25 | } 26 | -------------------------------------------------------------------------------- /internal/ast/compiler/trim_enum_values.go: -------------------------------------------------------------------------------- 1 | package compiler 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/grafana/cog/internal/ast" 7 | ) 8 | 9 | var _ Pass = (*TrimEnumValues)(nil) 10 | 11 | // TrimEnumValues removes leading and trailing spaces from string values. 12 | // It could happen when they add them by mistake in jsonschema/openapi when they define the enums 13 | type TrimEnumValues struct { 14 | } 15 | 16 | func (t TrimEnumValues) Process(schemas []*ast.Schema) ([]*ast.Schema, error) { 17 | visitor := Visitor{ 18 | OnEnum: t.processEnum, 19 | } 20 | 21 | return visitor.VisitSchemas(schemas) 22 | } 23 | 24 | func (t TrimEnumValues) processEnum(_ *Visitor, _ *ast.Schema, def ast.Type) (ast.Type, error) { 25 | for i, value := range def.AsEnum().Values { 26 | if stringType, ok := value.Value.(string); ok { 27 | def.AsEnum().Values[i].Value = strings.TrimSpace(stringType) 28 | } 29 | } 30 | 31 | return def, nil 32 | } 33 | -------------------------------------------------------------------------------- /internal/ast/tools.go: -------------------------------------------------------------------------------- 1 | package ast 2 | 3 | import ( 4 | "github.com/grafana/cog/internal/tools" 5 | ) 6 | 7 | func TypeName(typeDef Type) string { 8 | if typeDef.IsRef() { 9 | return tools.UpperCamelCase(typeDef.AsRef().ReferredType) 10 | } 11 | if typeDef.IsScalar() { 12 | return tools.UpperCamelCase(string(typeDef.AsScalar().ScalarKind)) 13 | } 14 | if typeDef.IsArray() { 15 | return "ArrayOf" + TypeName(typeDef.AsArray().ValueType) 16 | } 17 | 18 | return tools.UpperCamelCase(string(typeDef.Kind)) 19 | } 20 | -------------------------------------------------------------------------------- /internal/codegen/options.go: -------------------------------------------------------------------------------- 1 | package codegen 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func StdoutReporter(msg string) { 8 | fmt.Println(msg) 9 | } 10 | 11 | func Parameters(extraParameters map[string]string) PipelineOption { 12 | return func(pipeline *Pipeline) { 13 | for key, value := range extraParameters { 14 | pipeline.Parameters[key] = value 15 | } 16 | 17 | pipeline.interpolateParameters() 18 | } 19 | } 20 | 21 | func Reporter(reporter ProgressReporter) PipelineOption { 22 | return func(pipeline *Pipeline) { 23 | pipeline.reporter = reporter 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /internal/envvars/env.go: -------------------------------------------------------------------------------- 1 | package envvars 2 | 3 | import "os" 4 | 5 | // VarUpdateGolden is the name of the env var to trigger updating golden test files. 6 | const VarUpdateGolden = "COG_UPDATE_GOLDEN" 7 | 8 | // UpdateGoldenFiles determines whether tests should update txtar 9 | // archives on failures. 10 | // It is controlled by setting COG_UPDATE_GOLDEN to a non-empty string like "true". 11 | var UpdateGoldenFiles = os.Getenv(VarUpdateGolden) != "" //nolint: gochecknoglobals 12 | -------------------------------------------------------------------------------- /internal/jennies/golang/postprocessor.go: -------------------------------------------------------------------------------- 1 | package golang 2 | 3 | import ( 4 | "fmt" 5 | "path/filepath" 6 | "strings" 7 | 8 | "github.com/grafana/codejen" 9 | "golang.org/x/tools/imports" 10 | ) 11 | 12 | func formatGoFiles(file codejen.File) (codejen.File, error) { 13 | if !strings.HasSuffix(file.RelativePath, ".go") { 14 | return file, nil 15 | } 16 | 17 | output, err := imports.Process(filepath.Base(file.RelativePath), file.Data, &imports.Options{ 18 | FormatOnly: true, 19 | Comments: true, 20 | }) 21 | if err != nil { 22 | return codejen.File{}, fmt.Errorf("goimports processing of generated file failed: %w", err) 23 | } 24 | 25 | return codejen.File{ 26 | RelativePath: file.RelativePath, 27 | Data: output, 28 | From: file.From, 29 | }, nil 30 | } 31 | -------------------------------------------------------------------------------- /internal/jennies/golang/templates/builders/args.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "args" }} 2 | {{- range $i, $arg := . }} 3 | {{- if gt $i 0 }}, {{- end }} 4 | {{- $arg.Name | formatArgName }} {{ $arg.Type | formatType | trimPrefix "*"}} 5 | {{- end }} 6 | {{- end }} 7 | -------------------------------------------------------------------------------- /internal/jennies/golang/templates/builders/nilcheck.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "nil_check" }} 2 | if builder.internal.{{ .Path|formatPath }} == nil { 3 | builder.internal.{{ .Path|formatPath }} = {{ .|emptyValueForGuard }} 4 | } 5 | {{- end }} 6 | -------------------------------------------------------------------------------- /internal/jennies/golang/templates/builders/options.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "options" }} 2 | {{- $builder := .Builder }} 3 | {{ range $builder.Options }} 4 | {{- $option := . }} 5 | {{- range .Comments }} 6 | // {{ . }} 7 | {{- end }} 8 | func (builder *{{ $builder.Name|formatObjectName }}Builder) {{ .Name|formatFunctionName }}({{- template "args" .Args }}) *{{ $builder.Name|formatObjectName }}Builder { 9 | {{- range .Assignments }} 10 | {{- template "assignment" (dict "Assignment" . "Builder" $builder "Option" $option) }} 11 | {{- end }} 12 | 13 | return builder 14 | } 15 | {{ end }} 16 | {{- end }} 17 | -------------------------------------------------------------------------------- /internal/jennies/golang/templates/types/dataquery_equality_method.tmpl: -------------------------------------------------------------------------------- 1 | // Equals tests the equality of two dataqueries. 2 | func (resource {{ .def.Name|formatObjectName }}) Equals(otherCandidate variants.Dataquery) bool { 3 | if otherCandidate == nil { 4 | return false 5 | } 6 | 7 | other, ok := otherCandidate.({{ .def.Name|formatObjectName }}) 8 | if !ok { 9 | return false 10 | } 11 | 12 | {{- template "type_equality_check" (dict "Type" .def.Type "Nullable" .def.Type.Nullable "Dereference" false "SelfName" "resource" "OtherName" "other" "Depth" 0) }} 13 | 14 | return true 15 | } 16 | -------------------------------------------------------------------------------- /internal/jennies/golang/templates/types/disjunction_of_refs.json_marshal.tmpl: -------------------------------------------------------------------------------- 1 | // MarshalJSON implements a custom JSON marshalling logic to encode `{{ .def.Name|formatObjectName }}` as JSON. 2 | func (resource {{ .def.Name|formatObjectName }}) MarshalJSON() ([]byte, error) { 3 | {{- $json := importStdPkg "encoding/json" -}} 4 | {{- $fmt := importStdPkg "fmt" -}} 5 | {{- range .def.Type.Struct.Fields }} 6 | if resource.{{ .Name|formatFieldName }} != nil { 7 | return json.Marshal(resource.{{ .Name|formatFieldName }}) 8 | } 9 | {{- end }} 10 | 11 | return []byte("null"), nil 12 | } 13 | -------------------------------------------------------------------------------- /internal/jennies/golang/templates/types/disjunction_of_scalars.json_marshal.tmpl: -------------------------------------------------------------------------------- 1 | {{- $json := importStdPkg "encoding/json" -}} 2 | {{- $fmt := importStdPkg "fmt" -}} 3 | // MarshalJSON implements a custom JSON marshalling logic to encode `{{ .def.Name|formatObjectName }}` as JSON. 4 | func (resource {{ .def.Name|formatObjectName }}) MarshalJSON() ([]byte, error) { 5 | {{- range .def.Type.Struct.Fields }} 6 | if resource.{{ .Name|formatFieldName }} != nil { 7 | return json.Marshal(resource.{{ .Name|formatFieldName }}) 8 | } 9 | {{ end }} 10 | 11 | return []byte("null"), nil 12 | } 13 | -------------------------------------------------------------------------------- /internal/jennies/golang/templates/types/disjunction_of_scalars.json_unmarshal.tmpl: -------------------------------------------------------------------------------- 1 | {{- $json := importStdPkg "encoding/json" -}} 2 | {{- $errors := importStdPkg "errors" -}} 3 | // UnmarshalJSON implements a custom JSON unmarshalling logic to decode `{{ .def.Name|formatObjectName }}` from JSON. 4 | func (resource *{{ .def.Name|formatObjectName }}) UnmarshalJSON(raw []byte) error { 5 | if raw == nil { 6 | return nil 7 | } 8 | 9 | var errList []error 10 | {{ range .def.Type.Struct.Fields }} 11 | // {{ .Name|upperCamelCase }} 12 | var {{ .Name }} {{ trimPrefix "*" (.Type | formatType) }} 13 | if err := json.Unmarshal(raw, &{{ .Name }}); err != nil { 14 | errList = append(errList, err) 15 | resource.{{ .Name|formatFieldName }} = nil 16 | } else { 17 | resource.{{ .Name|formatFieldName }} = {{ if and (ne .Type.Kind "array") (ne .Type.Kind "map") }}&{{ end }}{{ .Name }} 18 | return nil 19 | } 20 | {{ end }} 21 | return errors.Join(errList...) 22 | } 23 | 24 | -------------------------------------------------------------------------------- /internal/jennies/java/templates/builders/args.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "args" }} 2 | {{- range $i, $arg := .Arguments }} 3 | {{- if gt $i 0 }}, {{- end }} 4 | {{- if $.IsBuilder }}{{- $arg.Type | formatBuilderFieldType }}{{ else }}{{ $arg.Type | formatType }}{{ end }} {{ $arg.Name | escapeVar | lowerCamelCase }} 5 | {{- end }} 6 | {{- end }} 7 | -------------------------------------------------------------------------------- /internal/jennies/java/templates/builders/constraints.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "constraints" }} 2 | {{- range . }} 3 | {{- $leftOperand := .Argument.Name | escapeVar | lowerCamelCase }} 4 | {{- $operator := .Op }} 5 | {{- if eq .Op "minLength" }} 6 | {{- $leftOperand = print $leftOperand ".length()" }} 7 | {{- $operator = ">=" }} 8 | {{- end }} 9 | {{- if eq .Op "maxLength" }} 10 | {{- $leftOperand = print $leftOperand ".length()" }} 11 | {{- $operator = "<=" }} 12 | {{- end }} 13 | if (!({{ $leftOperand }} {{ $operator }} {{ .Parameter }})) { 14 | throw new IllegalArgumentException("{{ $leftOperand }} must be {{ $operator }} {{ .Parameter }}"); 15 | } 16 | {{- end }} 17 | {{- end }} 18 | -------------------------------------------------------------------------------- /internal/jennies/java/templates/builders/nilcheck.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "nil_check" }} 2 | {{- $path := formatAssignmentPath "this.internal" .Path }} 3 | if ({{ $path }} == null) { 4 | {{ $path }} = {{ .EmptyValueType|emptyValueForType }}; 5 | } 6 | {{- end }} 7 | -------------------------------------------------------------------------------- /internal/jennies/java/templates/marshalling/disjunctions.json_marshall.tmpl: -------------------------------------------------------------------------------- 1 | 2 | public String toJSON() throws JsonProcessingException { 3 | {{- range .Fields }} 4 | if ({{ .Name|lowerCamelCase }} != null) { 5 | ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); 6 | return ow.writeValueAsString({{ .Name|lowerCamelCase }}); 7 | } 8 | {{- end }} 9 | 10 | return null; 11 | } 12 | -------------------------------------------------------------------------------- /internal/jennies/java/templates/marshalling/disjunctions_of_scalars.json_marshall.tmpl: -------------------------------------------------------------------------------- 1 | package {{ .Package }}; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | 7 | import java.io.IOException; 8 | 9 | public class {{ .Name }}Serializer extends JsonSerializer<{{ .Name }}> { 10 | 11 | @Override 12 | public void serialize({{ .Name }} value, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException { 13 | {{- range $i, $val := .Fields }} 14 | {{ if gt $i 0 }} else {{ end }} if (value.{{ .Name | lowerCamelCase | escapeVar }} != null) { 15 | gen.writeObject(value.{{ .Name | lowerCamelCase | escapeVar }}); 16 | } 17 | {{- end }} 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /internal/jennies/java/templates/marshalling/marshalling.tmpl: -------------------------------------------------------------------------------- 1 | 2 | public String toJSON() throws JsonProcessingException { 3 | ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); 4 | return ow.writeValueAsString(this); 5 | } 6 | -------------------------------------------------------------------------------- /internal/jennies/java/templates/runtime/builder.tmpl: -------------------------------------------------------------------------------- 1 | package {{ .Package }}; 2 | 3 | public interface Builder { 4 | public T build(); 5 | } 6 | -------------------------------------------------------------------------------- /internal/jennies/java/templates/runtime/converter_interface.tmpl: -------------------------------------------------------------------------------- 1 | package {{ .Package }}; 2 | 3 | public interface Converter { 4 | String convert(T input); 5 | } 6 | -------------------------------------------------------------------------------- /internal/jennies/java/templates/runtime/variants.tmpl: -------------------------------------------------------------------------------- 1 | package {{ .Package }}; 2 | 3 | public interface {{ .Variant }} { 4 | String dataqueryName(); 5 | } 6 | -------------------------------------------------------------------------------- /internal/jennies/java/templates/types/constants.tmpl: -------------------------------------------------------------------------------- 1 | package {{ .Package }}; 2 | 3 | public class {{ .Name }} { 4 | {{- range .Constants }} 5 | public static final {{ .Type }} {{ .Name | escapeVar }} = {{ printf "%#v" .Value }}; 6 | {{- end }} 7 | } 8 | -------------------------------------------------------------------------------- /internal/jennies/java/templates/types/enum.tmpl: -------------------------------------------------------------------------------- 1 | package {{ .Package }}; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | {{ range .Comments }} 7 | // {{ . }} 8 | {{- end }} 9 | @JsonFormat(shape = JsonFormat.Shape.OBJECT) 10 | public enum {{ .Name }} { 11 | {{- range $i, $val := .Values }} 12 | {{- if gt $i 0 }}, {{- end }} 13 | {{ $val.Name }}({{ printf "%#v" $val.Value }}) 14 | {{- if lastItem $i $.Values }}; {{- end }} 15 | {{- end }} 16 | 17 | private final {{ .Type }} value; 18 | 19 | private {{ .Name }}({{ .Type }} value) { 20 | this.value = value; 21 | } 22 | 23 | @JsonValue 24 | public {{ .Type }} Value() { 25 | return value; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /internal/jennies/php/templates/builders/args.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "args" }} 2 | {{- range $i, $arg := . }}{{- if gt $i 0 }}, {{ end -}} 3 | {{ $arg.Type | formatType }} ${{- $arg.Name | formatArgName }} 4 | {{- end }} 5 | {{- end }} 6 | -------------------------------------------------------------------------------- /internal/jennies/php/templates/builders/constraints.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "constraints" }} 2 | {{- range . }} 3 | {{- $argName := .Argument.Name|formatArgName }} 4 | {{- $leftOperand := print "$" $argName }} 5 | {{- $operator := .Op }} 6 | {{- if eq .Op "minLength" }} 7 | {{- $leftOperand = print "strlen(" $leftOperand ")" }} 8 | {{- $operator = ">=" }} 9 | {{- end }} 10 | {{- if eq .Op "maxLength" }} 11 | {{- $leftOperand = print "strlen(" $leftOperand ")" }} 12 | {{- $operator = "<=" }} 13 | {{- end }} 14 | if (!({{ $leftOperand }} {{ $operator }} {{ .Parameter }})) { 15 | throw new \ValueError('{{ $leftOperand }} must be {{ $operator }} {{ .Parameter }}'); 16 | } 17 | {{- end }} 18 | {{- end }} 19 | -------------------------------------------------------------------------------- /internal/jennies/php/templates/builders/factories.tmpl: -------------------------------------------------------------------------------- 1 | internal->{{ .Path|formatPath }} === null) { 3 | $this->internal->{{ .Path|formatPath }} = {{ .EmptyValueType|defaultForType }}; 4 | } 5 | {{ if .EmptyValueType.IsRef }}assert($this->internal->{{ .Path|formatPath }} instanceof {{ .EmptyValueType|formatRawTypeNotNullable }});{{ end }} 6 | {{- end }} 7 | -------------------------------------------------------------------------------- /internal/jennies/php/templates/builders/option.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "option" }} 2 | {{- .Option.Comments|formatDocsBlock -}} 3 | public function {{ .Option.Name|formatOptionName }}({{- template "args" .Option.Args }}): static 4 | { 5 | {{- range .Option.Assignments }} 6 | {{- template "assignment" (dict "Assignment" . "Builder" $.Builder "Option" $.Option) }} 7 | {{- end }} 8 | 9 | return $this; 10 | } 11 | {{- end }} 12 | -------------------------------------------------------------------------------- /internal/jennies/php/templates/runtime/builder.tmpl: -------------------------------------------------------------------------------- 1 | =" }} 8 | {{- end }} 9 | {{- if eq .Op "maxLength" }} 10 | {{- $leftOperand = print "len(" $leftOperand ")" }} 11 | {{- $operator = "<=" }} 12 | {{- end }} 13 | if not {{ $leftOperand }} {{ $operator }} {{ .Parameter }}: 14 | raise ValueError("{{ $leftOperand }} must be {{ $operator }} {{ .Parameter }}") 15 | {{- end }} 16 | {{- end }} 17 | -------------------------------------------------------------------------------- /internal/jennies/python/templates/builders/factories.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "factories" }} 2 | {{- $builder := .Builder }} 3 | {{ range $builder.Factories }} 4 | {{- template "factory" (dict "Builder" $builder "Factory" .) }} 5 | {{- end }} 6 | {{- end -}} 7 | -------------------------------------------------------------------------------- /internal/jennies/python/templates/builders/nilcheck.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "nil_check" -}} 2 | if self._internal.{{ .Path|formatPath }} is None: 3 | self._internal.{{ .Path|formatPath }} = {{ .EmptyValueType|defaultForType }} 4 | {{ if not (or .EmptyValueType.IsArray .EmptyValueType.IsMap) }}assert isinstance(self._internal.{{ .Path|formatPath }}, {{.EmptyValueType|formatRawTypeNotNullable}}){{ end }} 5 | {{- end }} 6 | -------------------------------------------------------------------------------- /internal/jennies/python/templates/builders/options.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "options" }} 2 | {{- $builder := .Builder }} 3 | {{ range $builder.Options }} 4 | {{- $option := . }} 5 | def {{ .Name|formatFunctionName }}(self{{- template "args" .Args }}) -> typing.Self: 6 | {{- include "comments" . | indent 4 }} 7 | {{- range .Assignments }} 8 | {{- include "assignment" (dict "Assignment" . "Builder" $builder "Option" $option) | indent 4 }} 9 | {{- end }} 10 | 11 | return self 12 | {{ end }} 13 | {{- end -}} 14 | -------------------------------------------------------------------------------- /internal/jennies/python/templates/runtime/builder.tmpl: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | from typing import Generic, TypeVar 3 | 4 | T = TypeVar("T", covariant=True) 5 | 6 | 7 | class Builder(Generic[T], ABC): 8 | @abstractmethod 9 | def build(self) -> T: 10 | pass 11 | -------------------------------------------------------------------------------- /internal/jennies/python/templates/runtime/encoder.tmpl: -------------------------------------------------------------------------------- 1 | from json import JSONEncoder as BaseJSONEncoder 2 | 3 | 4 | class JSONEncoder(BaseJSONEncoder): 5 | def default(self, obj): 6 | obj_to_json = getattr(obj, "to_json", None) 7 | if callable(obj_to_json): 8 | return obj_to_json() 9 | 10 | return BaseJSONEncoder.default(self, obj) 11 | -------------------------------------------------------------------------------- /internal/jennies/typescript/runtime_test.go: -------------------------------------------------------------------------------- 1 | package typescript 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/grafana/cog/internal/languages" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestRuntime(t *testing.T) { 11 | req := require.New(t) 12 | 13 | config := Config{} 14 | config.applyDefaults() 15 | jenny := Runtime{config: config} 16 | 17 | files, err := jenny.Generate(languages.Context{}) 18 | req.NoError(err) 19 | 20 | req.Len(files, 3) 21 | } 22 | -------------------------------------------------------------------------------- /internal/jennies/typescript/templates/args.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "args" }} 2 | {{- range $i, $arg := . }} 3 | {{- if gt $i 0 }}, {{- end }} 4 | {{- $arg.Name|formatIdentifier }}: {{ $arg.Type | formatType }} 5 | {{- end }} 6 | {{- end }} 7 | -------------------------------------------------------------------------------- /internal/jennies/typescript/templates/constraints.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "constraints" }} 2 | {{- range $c := . }} 3 | {{- $leftOperand := .Argument.Name|formatIdentifier }} 4 | {{- $operator := .Op }} 5 | 6 | {{- if eq .Op "minLength" }} 7 | {{- $leftOperand = print $leftOperand ".length" }} 8 | {{- $operator = ">=" }} 9 | {{- end }} 10 | {{- if eq .Op "maxLength" }} 11 | {{- $leftOperand = print $leftOperand ".length" }} 12 | {{- $operator = "<=" }} 13 | {{- end }} 14 | if (!({{ $leftOperand }} {{ $operator }} {{ .Parameter }})) { 15 | throw new Error("{{ $leftOperand }} must be {{ $operator }} {{ .Parameter }}"); 16 | } 17 | {{- end }} 18 | {{- end }} 19 | -------------------------------------------------------------------------------- /internal/jennies/typescript/templates/nilcheck.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "nil_check" }} 2 | if (!this.internal.{{ .Path|formatPath }}) { 3 | this.internal.{{ .Path|formatPath }} = {{ .|emptyValueForGuard }}; 4 | } 5 | {{- end }} 6 | -------------------------------------------------------------------------------- /internal/jennies/typescript/templates/options.tmpl: -------------------------------------------------------------------------------- 1 | {{- define "options" }} 2 | {{- $builder := .Builder }} 3 | {{ range .Builder.Options }} 4 | {{- $option := . }} 5 | {{- range .Comments}} 6 | // {{ . }} 7 | {{- end }} 8 | {{ .Name|formatIdentifier }}({{ template "args" .Args }}): this { 9 | {{- range .Assignments }} 10 | {{- template "assignment" (dict "Assignment" . "Builder" $builder "Option" $option) }} 11 | {{- end }} 12 | return this; 13 | } 14 | {{ end -}} 15 | {{- end }} 16 | -------------------------------------------------------------------------------- /internal/jsonschema/utils.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | 7 | schemaparser "github.com/santhosh-tekuri/jsonschema/v5" 8 | ) 9 | 10 | func schemaComments(schema *schemaparser.Schema) []string { 11 | comment := schema.Description 12 | 13 | lines := strings.Split(comment, "\n") 14 | filtered := make([]string, 0, len(lines)) 15 | 16 | for _, line := range lines { 17 | if line == "" { 18 | continue 19 | } 20 | 21 | filtered = append(filtered, line) 22 | } 23 | 24 | return filtered 25 | } 26 | 27 | func unwrapJSONNumber(input any) any { 28 | if val, ok := input.(json.Number); ok { 29 | asInt, err := val.Int64() 30 | if err == nil { 31 | return asInt 32 | } 33 | 34 | asFloat, err := val.Float64() 35 | if err == nil { 36 | return asFloat 37 | } 38 | 39 | return val.String() 40 | } 41 | 42 | return input 43 | } 44 | -------------------------------------------------------------------------------- /internal/languages/config.go: -------------------------------------------------------------------------------- 1 | package languages 2 | 3 | // Config represents global configuration options, to be used by all jennies. 4 | type Config struct { 5 | // Debug turns on or off the debugging mode. 6 | Debug bool 7 | 8 | // Types indicates whether types should be generated or not. 9 | Types bool 10 | 11 | // Builders indicates whether builders should be generated or not. 12 | Builders bool 13 | 14 | // Converters indicates whether converters should be generated or not. 15 | Converters bool 16 | 17 | // APIReference indicates whether an API reference should be generated or not. 18 | APIReference bool 19 | } 20 | -------------------------------------------------------------------------------- /internal/testutils/constants.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | const RawTypesIRInputFile = "ir.json" 4 | const BuildersContextInputFile = "builders_context.json" 5 | 6 | const GeneratorOutputFile = "ir.json" 7 | -------------------------------------------------------------------------------- /internal/testutils/orderedmap.go: -------------------------------------------------------------------------------- 1 | package testutils 2 | 3 | import ( 4 | "github.com/grafana/cog/internal/ast" 5 | "github.com/grafana/cog/internal/orderedmap" 6 | ) 7 | 8 | func ObjectsMap(objects ...ast.Object) *orderedmap.Map[string, ast.Object] { 9 | ordered := orderedmap.New[string, ast.Object]() 10 | for _, object := range objects { 11 | ordered.Set(object.Name, object) 12 | } 13 | return ordered 14 | } 15 | -------------------------------------------------------------------------------- /internal/tools/maps.go: -------------------------------------------------------------------------------- 1 | package tools 2 | 3 | func Keys[K comparable, V any](inputMap map[K]V) []K { 4 | keys := make([]K, 0, len(inputMap)) 5 | 6 | for k := range inputMap { 7 | keys = append(keys, k) 8 | } 9 | 10 | return keys 11 | } 12 | -------------------------------------------------------------------------------- /internal/tools/regexp.go: -------------------------------------------------------------------------------- 1 | package tools 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | // naive way of checking if the input regex describes a constant string, or something else. 8 | // ex: `^math$` or `^reduce$` would return true, while `^foo[0-9]+$` wouldn't 9 | func RegexMatchesConstantString(regex string) bool { 10 | if regex == "" { 11 | return false 12 | } 13 | 14 | if regex[0] != '^' || regex[len(regex)-1] != '$' { 15 | return false 16 | } 17 | 18 | return !strings.ContainsAny(regex, ".+*?()|[]{}") 19 | } 20 | 21 | func ConstantStringFromRegex(regex string) string { 22 | return regex[1 : len(regex)-1] 23 | } 24 | -------------------------------------------------------------------------------- /internal/tools/types.go: -------------------------------------------------------------------------------- 1 | package tools 2 | 3 | func AnyToInt64(value any) int64 { 4 | switch v := value.(type) { 5 | case int: 6 | return int64(v) 7 | case int8: 8 | return int64(v) 9 | case int16: 10 | return int64(v) 11 | case int32: 12 | return int64(v) 13 | case int64: 14 | return v 15 | 16 | case float32: 17 | return int64(v) 18 | case float64: 19 | return int64(v) 20 | } 21 | 22 | return value.(int64) 23 | } 24 | 25 | func ToPtr[T any](v T) *T { 26 | return &v 27 | } 28 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | # To run locally: 2 | # npx @techdocs/cli serve -v -c ./mkdocs.yml 3 | 4 | site_name: 'Cog Internal Documentation' 5 | repo_url: https://github.com/grafana/cog 6 | edit_uri: edit/main/docs 7 | 8 | theme: 9 | name: material 10 | features: 11 | - navigation.sections 12 | 13 | plugins: 14 | - techdocs-core 15 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Babel==2.15.0 2 | brotlicffi==1.1.0.0 3 | certifi==2024.7.4 4 | cffi==1.17.1 5 | charset-normalizer==3.3.2 6 | click==8.1.7 7 | colorama==0.4.6 8 | ghp-import==2.1.0 9 | idna==3.7 10 | importlib_metadata==7.1.0 11 | Jinja2==3.1.6 12 | Markdown==3.7 13 | MarkupSafe==2.1.5 14 | mergedeep==1.3.4 15 | mkdocs==1.6.1 16 | mkdocs-get-deps==0.2.0 17 | mkdocs-material==9.5.39 18 | mkdocs-material-extensions==1.3.1 19 | mkdocs-nav-weight==0.2.0 20 | mypy==1.10.0 21 | mypy-extensions==1.0.0 22 | packaging==24.1 23 | paginate==0.5.7 24 | pathspec==0.12.1 25 | platformdirs==4.2.2 26 | pycparser==2.22 27 | Pygments==2.18.0 28 | pymdown-extensions==10.11.2 29 | python-dateutil==2.9.0.post0 30 | PyYAML==6.0.2 31 | pyyaml_env_tag==0.1 32 | regex==2024.5.15 33 | requests==2.32.3 34 | six==1.16.0 35 | toml==0.10.2 36 | typing_extensions==4.12.2 37 | urllib3==2.2.2 38 | watchdog==4.0.1 39 | zipp==3.19.2 40 | -------------------------------------------------------------------------------- /scripts/ci/build-go.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Exit on error. Append "|| true" if you expect an error. 4 | set -o errexit 5 | # Exit on error inside any functions or subshells. 6 | set -o errtrace 7 | # Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR 8 | set -o nounset 9 | # Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip` 10 | set -o pipefail 11 | 12 | for d in generated/go/*/ ; do 13 | [[ "$d" != "generated/go/docs/" ]] && (echo "Building $d"; go build "./$d") 14 | done 15 | -------------------------------------------------------------------------------- /scripts/ci/build-java.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Exit on error. Append "|| true" if you expect an error. 4 | set -o errexit 5 | # Exit on error inside any functions or subshells. 6 | set -o errtrace 7 | # Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR 8 | set -o nounset 9 | # Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip` 10 | set -o pipefail 11 | 12 | gradle build --build-cache -p generated/java 13 | -------------------------------------------------------------------------------- /scripts/ci/build-php.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Exit on error. Append "|| true" if you expect an error. 4 | set -o errexit 5 | # Exit on error inside any functions or subshells. 6 | set -o errtrace 7 | # Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR 8 | set -o nounset 9 | # Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip` 10 | set -o pipefail 11 | 12 | phpstan analyze --memory-limit 512M -c config/ci/php/phpstan.neon 13 | -------------------------------------------------------------------------------- /scripts/ci/build-python.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Exit on error. Append "|| true" if you expect an error. 4 | set -o errexit 5 | # Exit on error inside any functions or subshells. 6 | set -o errtrace 7 | # Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR 8 | set -o nounset 9 | # Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip` 10 | set -o pipefail 11 | 12 | mypy generated/python/ 13 | -------------------------------------------------------------------------------- /scripts/ci/build-ts.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Exit on error. Append "|| true" if you expect an error. 4 | set -o errexit 5 | # Exit on error inside any functions or subshells. 6 | set -o errtrace 7 | # Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR 8 | set -o nounset 9 | # Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip` 10 | set -o pipefail 11 | 12 | tsc generated/typescript/src/*/*.ts 13 | -------------------------------------------------------------------------------- /testdata/generated/cog/plugins/variants.go: -------------------------------------------------------------------------------- 1 | // Code generated - EDITING IS FUTILE. DO NOT EDIT. 2 | // 3 | // Using jennies: 4 | // GoVariantsPlugins 5 | 6 | package plugins 7 | 8 | func RegisterDefaultPlugins() { 9 | 10 | // Panelcfg variants 11 | 12 | // Dataquery variants 13 | } 14 | -------------------------------------------------------------------------------- /testdata/jennies/builders/anonymous_struct/JavaBuilder/anonymous_struct/SomeStructBuilder.java: -------------------------------------------------------------------------------- 1 | package anonymous_struct; 2 | 3 | 4 | public class SomeStructBuilder implements cog.Builder { 5 | protected final SomeStruct internal; 6 | 7 | public SomeStructBuilder() { 8 | this.internal = new SomeStruct(); 9 | } 10 | public SomeStructBuilder time(Object time) { 11 | this.internal.time = time; 12 | return this; 13 | } 14 | public SomeStruct build() { 15 | return this.internal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/jennies/builders/anonymous_struct/PHPBuilder/src/AnonymousStruct/SomeStructBuilder.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class SomeStructBuilder implements \Grafana\Foundation\Cog\Builder 9 | { 10 | protected \Grafana\Foundation\AnonymousStruct\SomeStruct $internal; 11 | 12 | public function __construct() 13 | { 14 | $this->internal = new \Grafana\Foundation\AnonymousStruct\SomeStruct(); 15 | } 16 | 17 | /** 18 | * Builds the object. 19 | * @return \Grafana\Foundation\AnonymousStruct\SomeStruct 20 | */ 21 | public function build() 22 | { 23 | return $this->internal; 24 | } 25 | 26 | public function time(unknown $time): static 27 | { 28 | $this->internal->time = $time; 29 | 30 | return $this; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /testdata/jennies/builders/anonymous_struct/TypescriptBuilder/src/anonymousStruct/someStructBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as anonymousStruct from '../anonymousStruct'; 3 | 4 | export class SomeStructBuilder implements cog.Builder { 5 | protected readonly internal: anonymousStruct.SomeStruct; 6 | 7 | constructor() { 8 | this.internal = anonymousStruct.defaultSomeStruct(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): anonymousStruct.SomeStruct { 15 | return this.internal; 16 | } 17 | 18 | time(time: { 19 | from: string; 20 | to: string; 21 | }): this { 22 | this.internal.time = time; 23 | return this; 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /testdata/jennies/builders/array_append/GoConverter/sandbox/somestruct_converter_gen.go: -------------------------------------------------------------------------------- 1 | package sandbox 2 | 3 | 4 | 5 | import ( 6 | "strings" 7 | "fmt" 8 | ) 9 | 10 | // SomeStructConverter accepts a `SomeStruct` object and generates the Go code to build this object using builders. 11 | func SomeStructConverter(input SomeStruct) string { 12 | calls := []string{ 13 | `sandbox.NewSomeStructBuilder()`, 14 | } 15 | var buffer strings.Builder 16 | if input.Tags != nil && len(input.Tags) >= 1 {for _, item := range input.Tags { 17 | 18 | buffer.WriteString(`Tags(`) 19 | arg0 :=fmt.Sprintf("%#v", item) 20 | buffer.WriteString(arg0) 21 | 22 | buffer.WriteString(")") 23 | 24 | calls = append(calls, buffer.String()) 25 | buffer.Reset() 26 | 27 | }} 28 | 29 | return strings.Join(calls, ".\t\n") 30 | } 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/array_append/JavaBuilder/sandbox/SomeStructBuilder.java: -------------------------------------------------------------------------------- 1 | package sandbox; 2 | 3 | import java.util.LinkedList; 4 | 5 | public class SomeStructBuilder implements cog.Builder { 6 | protected final SomeStruct internal; 7 | 8 | public SomeStructBuilder() { 9 | this.internal = new SomeStruct(); 10 | } 11 | public SomeStructBuilder tags(String tags) { 12 | if (this.internal.tags == null) { 13 | this.internal.tags = new LinkedList<>(); 14 | } 15 | this.internal.tags.add(tags); 16 | return this; 17 | } 18 | public SomeStruct build() { 19 | return this.internal; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testdata/jennies/builders/array_append/PHPBuilder/src/Sandbox/SomeStructBuilder.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class SomeStructBuilder implements \Grafana\Foundation\Cog\Builder 9 | { 10 | protected \Grafana\Foundation\Sandbox\SomeStruct $internal; 11 | 12 | public function __construct() 13 | { 14 | $this->internal = new \Grafana\Foundation\Sandbox\SomeStruct(); 15 | } 16 | 17 | /** 18 | * Builds the object. 19 | * @return \Grafana\Foundation\Sandbox\SomeStruct 20 | */ 21 | public function build() 22 | { 23 | return $this->internal; 24 | } 25 | 26 | public function tags(string $tags): static 27 | { 28 | $this->internal->tags[] = $tags; 29 | 30 | return $this; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /testdata/jennies/builders/array_append/PHPConverter/src/Sandbox/SomeStructConverter.php: -------------------------------------------------------------------------------- 1 | tags) >= 1) { 14 | foreach ($input->tags as $item) { 15 | 16 | $buffer = 'tags('; 17 | $arg0 =\var_export($item, true); 18 | $buffer .= $arg0; 19 | 20 | $buffer .= ')'; 21 | 22 | $calls[] = $buffer; 23 | 24 | } 25 | } 26 | 27 | return \implode("\n\t->", $calls); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/array_append/PythonBuilder/builders/sandbox.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import sandbox 4 | 5 | 6 | class SomeStruct(cogbuilder.Builder[sandbox.SomeStruct]): 7 | _internal: sandbox.SomeStruct 8 | 9 | def __init__(self): 10 | self._internal = sandbox.SomeStruct() 11 | 12 | def build(self) -> sandbox.SomeStruct: 13 | """ 14 | Builds the object. 15 | """ 16 | return self._internal 17 | 18 | def tags(self, tags: str) -> typing.Self: 19 | if self._internal.tags is None: 20 | self._internal.tags = [] 21 | 22 | self._internal.tags.append(tags) 23 | 24 | return self 25 | 26 | -------------------------------------------------------------------------------- /testdata/jennies/builders/array_append/TypescriptBuilder/src/sandbox/someStructBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as sandbox from '../sandbox'; 3 | 4 | export class SomeStructBuilder implements cog.Builder { 5 | protected readonly internal: sandbox.SomeStruct; 6 | 7 | constructor() { 8 | this.internal = sandbox.defaultSomeStruct(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): sandbox.SomeStruct { 15 | return this.internal; 16 | } 17 | 18 | tags(tags: string): this { 19 | if (!this.internal.tags) { 20 | this.internal.tags = []; 21 | } 22 | this.internal.tags.push(tags); 23 | return this; 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /testdata/jennies/builders/basic_struct/schema.cue: -------------------------------------------------------------------------------- 1 | package basic_struct 2 | 3 | // SomeStruct, to hold data. 4 | SomeStruct: { 5 | // id identifies something. Weird, right? 6 | id: int64 7 | uid: string 8 | tags: [...string] 9 | // This thing could be live. 10 | // Or maybe not. 11 | liveNow: bool 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/builders/basic_struct_defaults/schema.cue: -------------------------------------------------------------------------------- 1 | package sandbox 2 | 3 | SomeStruct: { 4 | id: int64 | *42 5 | uid: string | *"default-uid" 6 | tags: [...string] | *["generated", "cog"] 7 | liveNow: bool | *true 8 | } 9 | -------------------------------------------------------------------------------- /testdata/jennies/builders/builder_delegation/JavaBuilder/builder_delegation/DashboardLinkBuilder.java: -------------------------------------------------------------------------------- 1 | package builder_delegation; 2 | 3 | 4 | public class DashboardLinkBuilder implements cog.Builder { 5 | protected final DashboardLink internal; 6 | 7 | public DashboardLinkBuilder() { 8 | this.internal = new DashboardLink(); 9 | } 10 | public DashboardLinkBuilder title(String title) { 11 | this.internal.title = title; 12 | return this; 13 | } 14 | 15 | public DashboardLinkBuilder url(String url) { 16 | this.internal.url = url; 17 | return this; 18 | } 19 | public DashboardLink build() { 20 | return this.internal; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/jennies/builders/builder_delegation/TypescriptBuilder/src/builderDelegation/dashboardLinkBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as builderDelegation from '../builderDelegation'; 3 | 4 | export class DashboardLinkBuilder implements cog.Builder { 5 | protected readonly internal: builderDelegation.DashboardLink; 6 | 7 | constructor() { 8 | this.internal = builderDelegation.defaultDashboardLink(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): builderDelegation.DashboardLink { 15 | return this.internal; 16 | } 17 | 18 | title(title: string): this { 19 | this.internal.title = title; 20 | return this; 21 | } 22 | 23 | url(url: string): this { 24 | this.internal.url = url; 25 | return this; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /testdata/jennies/builders/builder_delegation/schema.cue: -------------------------------------------------------------------------------- 1 | package builder_delegation 2 | 3 | #DashboardLink: { 4 | title: string 5 | url: string 6 | } 7 | 8 | Dashboard: { 9 | id: int64 10 | title: string 11 | links: [...#DashboardLink] // will be expanded to []cog.Builder 12 | linksOfLinks: [...[...#DashboardLink]] // will be expanded to [][]cog.Builder 13 | singleLink: #DashboardLink // will be expanded to cog.Builder 14 | } 15 | -------------------------------------------------------------------------------- /testdata/jennies/builders/builder_delegation_in_disjunction/JavaBuilder/builder_delegation_in_disjunction/DashboardLinkBuilder.java: -------------------------------------------------------------------------------- 1 | package builder_delegation_in_disjunction; 2 | 3 | 4 | public class DashboardLinkBuilder implements cog.Builder { 5 | protected final DashboardLink internal; 6 | 7 | public DashboardLinkBuilder() { 8 | this.internal = new DashboardLink(); 9 | } 10 | public DashboardLinkBuilder title(String title) { 11 | this.internal.title = title; 12 | return this; 13 | } 14 | 15 | public DashboardLinkBuilder url(String url) { 16 | this.internal.url = url; 17 | return this; 18 | } 19 | public DashboardLink build() { 20 | return this.internal; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/jennies/builders/builder_delegation_in_disjunction/JavaBuilder/builder_delegation_in_disjunction/ExternalLinkBuilder.java: -------------------------------------------------------------------------------- 1 | package builder_delegation_in_disjunction; 2 | 3 | 4 | public class ExternalLinkBuilder implements cog.Builder { 5 | protected final ExternalLink internal; 6 | 7 | public ExternalLinkBuilder() { 8 | this.internal = new ExternalLink(); 9 | } 10 | public ExternalLinkBuilder url(String url) { 11 | this.internal.url = url; 12 | return this; 13 | } 14 | public ExternalLink build() { 15 | return this.internal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/jennies/builders/builder_delegation_in_disjunction/TypescriptBuilder/src/builderDelegationInDisjunction/dashboardLinkBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as builderDelegationInDisjunction from '../builderDelegationInDisjunction'; 3 | 4 | export class DashboardLinkBuilder implements cog.Builder { 5 | protected readonly internal: builderDelegationInDisjunction.DashboardLink; 6 | 7 | constructor() { 8 | this.internal = builderDelegationInDisjunction.defaultDashboardLink(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): builderDelegationInDisjunction.DashboardLink { 15 | return this.internal; 16 | } 17 | 18 | title(title: string): this { 19 | this.internal.title = title; 20 | return this; 21 | } 22 | 23 | url(url: string): this { 24 | this.internal.url = url; 25 | return this; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /testdata/jennies/builders/builder_delegation_in_disjunction/TypescriptBuilder/src/builderDelegationInDisjunction/externalLinkBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as builderDelegationInDisjunction from '../builderDelegationInDisjunction'; 3 | 4 | export class ExternalLinkBuilder implements cog.Builder { 5 | protected readonly internal: builderDelegationInDisjunction.ExternalLink; 6 | 7 | constructor() { 8 | this.internal = builderDelegationInDisjunction.defaultExternalLink(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): builderDelegationInDisjunction.ExternalLink { 15 | return this.internal; 16 | } 17 | 18 | url(url: string): this { 19 | this.internal.url = url; 20 | return this; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /testdata/jennies/builders/builder_delegation_in_disjunction/schema.cue: -------------------------------------------------------------------------------- 1 | package builder_delegation_in_disjunction 2 | 3 | #DashboardLink: { 4 | title: string 5 | url: string 6 | } 7 | 8 | #ExternalLink: { 9 | url: string 10 | } 11 | 12 | Dashboard: { 13 | singleLinkOrString: #DashboardLink | string // will be expanded to cog.Builder | string 14 | linksOrStrings: [...(#DashboardLink | string)] // will be expanded to [](cog.Builder | string) 15 | disjunctionOfBuilders: #DashboardLink | #ExternalLink 16 | } 17 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constant_assignment/JavaBuilder/sandbox/SomeStructBuilder.java: -------------------------------------------------------------------------------- 1 | package sandbox; 2 | 3 | 4 | public class SomeStructBuilder implements cog.Builder { 5 | protected final SomeStruct internal; 6 | 7 | public SomeStructBuilder() { 8 | this.internal = new SomeStruct(); 9 | } 10 | public SomeStructBuilder editable() { 11 | this.internal.editable = true; 12 | return this; 13 | } 14 | 15 | public SomeStructBuilder readonly() { 16 | this.internal.editable = false; 17 | return this; 18 | } 19 | 20 | public SomeStructBuilder autoRefresh() { 21 | this.internal.autoRefresh = true; 22 | return this; 23 | } 24 | 25 | public SomeStructBuilder noAutoRefresh() { 26 | this.internal.autoRefresh = false; 27 | return this; 28 | } 29 | public SomeStruct build() { 30 | return this.internal; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constraints/schema.cue: -------------------------------------------------------------------------------- 1 | package constraints 2 | 3 | import "strings" 4 | 5 | SomeStruct: { 6 | id: int64 & >= 5 & <10 7 | title: strings.MinRunes(1) & { 8 | string 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constructor_argument/GoConverter/sandbox/somestruct_converter_gen.go: -------------------------------------------------------------------------------- 1 | package sandbox 2 | 3 | 4 | 5 | import ( 6 | "strings" 7 | "fmt" 8 | ) 9 | 10 | // SomeStructConverter accepts a `SomeStruct` object and generates the Go code to build this object using builders. 11 | func SomeStructConverter(input SomeStruct) string { 12 | calls := []string{ 13 | `sandbox.NewSomeStructBuilder(`+fmt.Sprintf("%#v", input.Title)+`)`, 14 | } 15 | var buffer strings.Builder 16 | if input.Title != "" { 17 | 18 | buffer.WriteString(`Title(`) 19 | arg0 :=fmt.Sprintf("%#v", input.Title) 20 | buffer.WriteString(arg0) 21 | 22 | buffer.WriteString(")") 23 | 24 | calls = append(calls, buffer.String()) 25 | buffer.Reset() 26 | 27 | } 28 | 29 | return strings.Join(calls, ".\t\n") 30 | } 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constructor_argument/JavaBuilder/sandbox/SomeStructBuilder.java: -------------------------------------------------------------------------------- 1 | package sandbox; 2 | 3 | 4 | public class SomeStructBuilder implements cog.Builder { 5 | protected final SomeStruct internal; 6 | 7 | public SomeStructBuilder(String title) { 8 | this.internal = new SomeStruct(); 9 | this.internal.title = title; 10 | } 11 | public SomeStructBuilder title(String title) { 12 | this.internal.title = title; 13 | return this; 14 | } 15 | public SomeStruct build() { 16 | return this.internal; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constructor_argument/PHPBuilder/src/Sandbox/SomeStructBuilder.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class SomeStructBuilder implements \Grafana\Foundation\Cog\Builder 9 | { 10 | protected \Grafana\Foundation\Sandbox\SomeStruct $internal; 11 | 12 | public function __construct(string $title) 13 | { 14 | $this->internal = new \Grafana\Foundation\Sandbox\SomeStruct(); 15 | $this->internal->title = $title; 16 | } 17 | 18 | /** 19 | * Builds the object. 20 | * @return \Grafana\Foundation\Sandbox\SomeStruct 21 | */ 22 | public function build() 23 | { 24 | return $this->internal; 25 | } 26 | 27 | public function title(string $title): static 28 | { 29 | $this->internal->title = $title; 30 | 31 | return $this; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constructor_argument/PHPConverter/src/Sandbox/SomeStructConverter.php: -------------------------------------------------------------------------------- 1 | title, true).'))', 12 | ]; 13 | if ($input->title !== "") { 14 | 15 | 16 | $buffer = 'title('; 17 | $arg0 =\var_export($input->title, true); 18 | $buffer .= $arg0; 19 | 20 | $buffer .= ')'; 21 | 22 | $calls[] = $buffer; 23 | 24 | 25 | } 26 | 27 | return \implode("\n\t->", $calls); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constructor_argument/PythonBuilder/builders/sandbox.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import sandbox 4 | 5 | 6 | class SomeStruct(cogbuilder.Builder[sandbox.SomeStruct]): 7 | _internal: sandbox.SomeStruct 8 | 9 | def __init__(self, title: str): 10 | self._internal = sandbox.SomeStruct() 11 | self._internal.title = title 12 | 13 | def build(self) -> sandbox.SomeStruct: 14 | """ 15 | Builds the object. 16 | """ 17 | return self._internal 18 | 19 | def title(self, title: str) -> typing.Self: 20 | self._internal.title = title 21 | 22 | return self 23 | 24 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constructor_argument/TypescriptBuilder/src/sandbox/someStructBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as sandbox from '../sandbox'; 3 | 4 | export class SomeStructBuilder implements cog.Builder { 5 | protected readonly internal: sandbox.SomeStruct; 6 | 7 | constructor(title: string) { 8 | this.internal = sandbox.defaultSomeStruct(); 9 | this.internal.title = title; 10 | } 11 | 12 | /** 13 | * Builds the object. 14 | */ 15 | build(): sandbox.SomeStruct { 16 | return this.internal; 17 | } 18 | 19 | title(title: string): this { 20 | this.internal.title = title; 21 | return this; 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constructor_initializations/GoConverter/constructor_initializations/somepanel_converter_gen.go: -------------------------------------------------------------------------------- 1 | package constructor_initializations 2 | 3 | 4 | 5 | import ( 6 | "strings" 7 | "fmt" 8 | ) 9 | 10 | // SomePanelConverter accepts a `SomePanel` object and generates the Go code to build this object using builders. 11 | func SomePanelConverter(input SomePanel) string { 12 | calls := []string{ 13 | `constructor_initializations.NewSomePanelBuilder()`, 14 | } 15 | var buffer strings.Builder 16 | if input.Title != "" { 17 | 18 | buffer.WriteString(`Title(`) 19 | arg0 :=fmt.Sprintf("%#v", input.Title) 20 | buffer.WriteString(arg0) 21 | 22 | buffer.WriteString(")") 23 | 24 | calls = append(calls, buffer.String()) 25 | buffer.Reset() 26 | 27 | } 28 | 29 | return strings.Join(calls, ".\t\n") 30 | } 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constructor_initializations/JavaBuilder/constructor_initializations/SomePanelBuilder.java: -------------------------------------------------------------------------------- 1 | package constructor_initializations; 2 | 3 | 4 | public class SomePanelBuilder implements cog.Builder { 5 | protected final SomePanel internal; 6 | 7 | public SomePanelBuilder() { 8 | this.internal = new SomePanel(); 9 | this.internal.type = "panel_type"; 10 | this.internal.cursor = CursorMode.TOOLTIP; 11 | } 12 | public SomePanelBuilder title(String title) { 13 | this.internal.title = title; 14 | return this; 15 | } 16 | public SomePanel build() { 17 | return this.internal; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constructor_initializations/PHPConverter/src/ConstructorInitializations/SomePanelConverter.php: -------------------------------------------------------------------------------- 1 | title !== "") { 14 | 15 | 16 | $buffer = 'title('; 17 | $arg0 =\var_export($input->title, true); 18 | $buffer .= $arg0; 19 | 20 | $buffer .= ')'; 21 | 22 | $calls[] = $buffer; 23 | 24 | 25 | } 26 | 27 | return \implode("\n\t->", $calls); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constructor_initializations/PythonBuilder/builders/constructor_initializations.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import constructor_initializations 4 | 5 | 6 | class SomePanel(cogbuilder.Builder[constructor_initializations.SomePanel]): 7 | _internal: constructor_initializations.SomePanel 8 | 9 | def __init__(self): 10 | self._internal = constructor_initializations.SomePanel() 11 | self._internal.type_val = "panel_type" 12 | self._internal.cursor = constructor_initializations.CursorMode.TOOLTIP 13 | 14 | def build(self) -> constructor_initializations.SomePanel: 15 | """ 16 | Builds the object. 17 | """ 18 | return self._internal 19 | 20 | def title(self, title: str) -> typing.Self: 21 | self._internal.title = title 22 | 23 | return self 24 | 25 | -------------------------------------------------------------------------------- /testdata/jennies/builders/constructor_initializations/TypescriptBuilder/src/constructorInitializations/somePanelBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as constructorInitializations from '../constructorInitializations'; 3 | 4 | export class SomePanelBuilder implements cog.Builder { 5 | protected readonly internal: constructorInitializations.SomePanel; 6 | 7 | constructor() { 8 | this.internal = constructorInitializations.defaultSomePanel(); 9 | this.internal.type = "panel_type"; 10 | this.internal.cursor = constructorInitializations.CursorMode.Tooltip; 11 | } 12 | 13 | /** 14 | * Builds the object. 15 | */ 16 | build(): constructorInitializations.SomePanel { 17 | return this.internal; 18 | } 19 | 20 | title(title: string): this { 21 | this.internal.title = title; 22 | return this; 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /testdata/jennies/builders/dashboard_panel/JavaBuilder/dashboard/PanelBuilder.java: -------------------------------------------------------------------------------- 1 | package dashboard; 2 | 3 | 4 | public class PanelBuilder> implements cog.Builder { 5 | protected final Panel internal; 6 | 7 | public PanelBuilder() { 8 | this.internal = new Panel(); 9 | } 10 | public T onlyFromThisDashboard(Boolean onlyFromThisDashboard) { 11 | this.internal.onlyFromThisDashboard = onlyFromThisDashboard; 12 | return (T) this; 13 | } 14 | public Panel build() { 15 | return this.internal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/jennies/builders/dataquery_variant_builder/GoConverter/dataquery_variant_builder/lokibuilder_converter_gen.go: -------------------------------------------------------------------------------- 1 | package dataquery_variant_builder 2 | 3 | 4 | 5 | import ( 6 | "strings" 7 | "fmt" 8 | ) 9 | 10 | // LokiBuilderConverter accepts a `LokiBuilder` object and generates the Go code to build this object using builders. 11 | func LokiBuilderConverter(input Loki) string { 12 | calls := []string{ 13 | `dataquery_variant_builder.NewLokiBuilderBuilder()`, 14 | } 15 | var buffer strings.Builder 16 | if input.Expr != "" { 17 | 18 | buffer.WriteString(`Expr(`) 19 | arg0 :=fmt.Sprintf("%#v", input.Expr) 20 | buffer.WriteString(arg0) 21 | 22 | buffer.WriteString(")") 23 | 24 | calls = append(calls, buffer.String()) 25 | buffer.Reset() 26 | 27 | } 28 | 29 | return strings.Join(calls, ".\t\n") 30 | } 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/dataquery_variant_builder/JavaBuilder/dataquery_variant_builder/LokiBuilderBuilder.java: -------------------------------------------------------------------------------- 1 | package dataquery_variant_builder; 2 | 3 | 4 | public class LokiBuilderBuilder implements cog.Builder { 5 | protected final Loki internal; 6 | 7 | public LokiBuilderBuilder() { 8 | this.internal = new Loki(); 9 | } 10 | public LokiBuilderBuilder expr(String expr) { 11 | this.internal.expr = expr; 12 | return this; 13 | } 14 | public Loki build() { 15 | return this.internal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/jennies/builders/dataquery_variant_builder/PHPConverter/src/DataqueryVariantBuilder/LokiBuilderConverter.php: -------------------------------------------------------------------------------- 1 | expr !== "") { 14 | 15 | 16 | $buffer = 'expr('; 17 | $arg0 =\var_export($input->expr, true); 18 | $buffer .= $arg0; 19 | 20 | $buffer .= ')'; 21 | 22 | $calls[] = $buffer; 23 | 24 | 25 | } 26 | 27 | return \implode("\n\t->", $calls); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/dataquery_variant_builder/PythonBuilder/builders/dataquery_variant_builder.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import dataquery_variant_builder 4 | 5 | 6 | class LokiBuilder(cogbuilder.Builder[dataquery_variant_builder.Loki]): 7 | _internal: dataquery_variant_builder.Loki 8 | 9 | def __init__(self): 10 | self._internal = dataquery_variant_builder.Loki() 11 | 12 | def build(self) -> dataquery_variant_builder.Loki: 13 | """ 14 | Builds the object. 15 | """ 16 | return self._internal 17 | 18 | def expr(self, expr: str) -> typing.Self: 19 | self._internal.expr = expr 20 | 21 | return self 22 | 23 | -------------------------------------------------------------------------------- /testdata/jennies/builders/dataquery_variant_builder/TypescriptBuilder/src/dataqueryVariantBuilder/lokiBuilderBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as dataqueryVariantBuilder from '../dataqueryVariantBuilder'; 3 | 4 | export class LokiBuilderBuilder implements cog.Builder { 5 | protected readonly internal: dataqueryVariantBuilder.Loki; 6 | 7 | constructor() { 8 | this.internal = dataqueryVariantBuilder.defaultLoki(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): dataqueryVariantBuilder.Loki { 15 | return this.internal; 16 | } 17 | 18 | expr(expr: string): this { 19 | this.internal.expr = expr; 20 | return this; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /testdata/jennies/builders/envelope_assignment/JavaBuilder/sandbox/DashboardBuilder.java: -------------------------------------------------------------------------------- 1 | package sandbox; 2 | 3 | import java.util.LinkedList; 4 | 5 | public class DashboardBuilder implements cog.Builder { 6 | protected final Dashboard internal; 7 | 8 | public DashboardBuilder() { 9 | this.internal = new Dashboard(); 10 | } 11 | public DashboardBuilder withVariable(String name,String value) { 12 | if (this.internal.variables == null) { 13 | this.internal.variables = new LinkedList<>(); 14 | } 15 | Variable variable = new Variable(); 16 | variable.name = name; 17 | variable.value = value; 18 | this.internal.variables.add(variable); 19 | return this; 20 | } 21 | public Dashboard build() { 22 | return this.internal; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/jennies/builders/envelope_assignment/PHPConverter/src/Sandbox/DashboardConverter.php: -------------------------------------------------------------------------------- 1 | variables) >= 1) { 14 | foreach ($input->variables as $item) { 15 | 16 | $buffer = 'withVariable('; 17 | $arg0 =\var_export($item->name, true); 18 | $buffer .= $arg0; 19 | $buffer .= ', '; 20 | $arg1 =\var_export($item->value, true); 21 | $buffer .= $arg1; 22 | 23 | $buffer .= ')'; 24 | 25 | $calls[] = $buffer; 26 | 27 | } 28 | } 29 | 30 | return \implode("\n\t->", $calls); 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /testdata/jennies/builders/envelope_assignment/PythonBuilder/builders/sandbox.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import sandbox 4 | 5 | 6 | class Dashboard(cogbuilder.Builder[sandbox.Dashboard]): 7 | _internal: sandbox.Dashboard 8 | 9 | def __init__(self): 10 | self._internal = sandbox.Dashboard() 11 | 12 | def build(self) -> sandbox.Dashboard: 13 | """ 14 | Builds the object. 15 | """ 16 | return self._internal 17 | 18 | def with_variable(self, name: str, value: str) -> typing.Self: 19 | if self._internal.variables is None: 20 | self._internal.variables = [] 21 | 22 | self._internal.variables.append(sandbox.Variable( 23 | name=name, 24 | value=value, 25 | )) 26 | 27 | return self 28 | 29 | -------------------------------------------------------------------------------- /testdata/jennies/builders/envelope_assignment/TypescriptBuilder/src/sandbox/dashboardBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as sandbox from '../sandbox'; 3 | 4 | export class DashboardBuilder implements cog.Builder { 5 | protected readonly internal: sandbox.Dashboard; 6 | 7 | constructor() { 8 | this.internal = sandbox.defaultDashboard(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): sandbox.Dashboard { 15 | return this.internal; 16 | } 17 | 18 | withVariable(name: string,value: string): this { 19 | if (!this.internal.variables) { 20 | this.internal.variables = []; 21 | } 22 | this.internal.variables.push({ 23 | name: name, 24 | value: value, 25 | }); 26 | return this; 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /testdata/jennies/builders/foreign_builder/GoConverter/builder_pkg/somenicebuilder_converter_gen.go: -------------------------------------------------------------------------------- 1 | package builder_pkg 2 | 3 | 4 | 5 | import ( 6 | some_pkg "github.com/grafana/cog/generated/some_pkg" 7 | "strings" 8 | "fmt" 9 | ) 10 | 11 | // SomeNiceBuilderConverter accepts a `SomeNiceBuilder` object and generates the Go code to build this object using builders. 12 | func SomeNiceBuilderConverter(input some_pkg.SomeStruct) string { 13 | calls := []string{ 14 | `builder_pkg.NewSomeNiceBuilderBuilder()`, 15 | } 16 | var buffer strings.Builder 17 | if input.Title != "" { 18 | 19 | buffer.WriteString(`Title(`) 20 | arg0 :=fmt.Sprintf("%#v", input.Title) 21 | buffer.WriteString(arg0) 22 | 23 | buffer.WriteString(")") 24 | 25 | calls = append(calls, buffer.String()) 26 | buffer.Reset() 27 | 28 | } 29 | 30 | return strings.Join(calls, ".\t\n") 31 | } 32 | -------------------------------------------------------------------------------- /testdata/jennies/builders/foreign_builder/JavaBuilder/builder_pkg/SomeNiceBuilderBuilder.java: -------------------------------------------------------------------------------- 1 | package builder_pkg; 2 | 3 | import some_pkg.SomeStruct; 4 | 5 | public class SomeNiceBuilderBuilder implements cog.Builder { 6 | protected final SomeStruct internal; 7 | 8 | public SomeNiceBuilderBuilder() { 9 | this.internal = new SomeStruct(); 10 | } 11 | public SomeNiceBuilderBuilder title(String title) { 12 | this.internal.title = title; 13 | return this; 14 | } 15 | public SomeStruct build() { 16 | return this.internal; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/jennies/builders/foreign_builder/PHPBuilder/src/BuilderPkg/SomeNiceBuilderBuilder.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class SomeNiceBuilderBuilder implements \Grafana\Foundation\Cog\Builder 9 | { 10 | protected \Grafana\Foundation\SomePkg\SomeStruct $internal; 11 | 12 | public function __construct() 13 | { 14 | $this->internal = new \Grafana\Foundation\SomePkg\SomeStruct(); 15 | } 16 | 17 | /** 18 | * Builds the object. 19 | * @return \Grafana\Foundation\SomePkg\SomeStruct 20 | */ 21 | public function build() 22 | { 23 | return $this->internal; 24 | } 25 | 26 | public function title(string $title): static 27 | { 28 | $this->internal->title = $title; 29 | 30 | return $this; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /testdata/jennies/builders/foreign_builder/PHPConverter/src/BuilderPkg/SomeNiceBuilderConverter.php: -------------------------------------------------------------------------------- 1 | title !== "") { 14 | 15 | 16 | $buffer = 'title('; 17 | $arg0 =\var_export($input->title, true); 18 | $buffer .= $arg0; 19 | 20 | $buffer .= ')'; 21 | 22 | $calls[] = $buffer; 23 | 24 | 25 | } 26 | 27 | return \implode("\n\t->", $calls); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/foreign_builder/PythonBuilder/builders/builder_pkg.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import some_pkg 4 | 5 | 6 | class SomeNiceBuilder(cogbuilder.Builder[some_pkg.SomeStruct]): 7 | _internal: some_pkg.SomeStruct 8 | 9 | def __init__(self): 10 | self._internal = some_pkg.SomeStruct() 11 | 12 | def build(self) -> some_pkg.SomeStruct: 13 | """ 14 | Builds the object. 15 | """ 16 | return self._internal 17 | 18 | def title(self, title: str) -> typing.Self: 19 | self._internal.title = title 20 | 21 | return self 22 | 23 | -------------------------------------------------------------------------------- /testdata/jennies/builders/foreign_builder/TypescriptBuilder/src/builderPkg/someNiceBuilderBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as somePkg from '../somePkg'; 3 | 4 | export class SomeNiceBuilderBuilder implements cog.Builder { 5 | protected readonly internal: somePkg.SomeStruct; 6 | 7 | constructor() { 8 | this.internal = somePkg.defaultSomeStruct(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): somePkg.SomeStruct { 15 | return this.internal; 16 | } 17 | 18 | title(title: string): this { 19 | this.internal.title = title; 20 | return this; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /testdata/jennies/builders/known_any/GoConverter/known_any/somestruct_converter_gen.go: -------------------------------------------------------------------------------- 1 | package known_any 2 | 3 | 4 | 5 | import ( 6 | "strings" 7 | "fmt" 8 | ) 9 | 10 | // SomeStructConverter accepts a `SomeStruct` object and generates the Go code to build this object using builders. 11 | func SomeStructConverter(input SomeStruct) string { 12 | calls := []string{ 13 | `known_any.NewSomeStructBuilder()`, 14 | } 15 | var buffer strings.Builder 16 | if input.Config != nil && input.Config.(*Config).Title != "" { 17 | 18 | buffer.WriteString(`Title(`) 19 | arg0 :=fmt.Sprintf("%#v", input.Config.(*Config).Title) 20 | buffer.WriteString(arg0) 21 | 22 | buffer.WriteString(")") 23 | 24 | calls = append(calls, buffer.String()) 25 | buffer.Reset() 26 | 27 | } 28 | 29 | return strings.Join(calls, ".\t\n") 30 | } 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/known_any/JavaBuilder/known_any/SomeStructBuilder.java: -------------------------------------------------------------------------------- 1 | package known_any; 2 | 3 | 4 | public class SomeStructBuilder implements cog.Builder { 5 | protected final SomeStruct internal; 6 | 7 | public SomeStructBuilder() { 8 | this.internal = new SomeStruct(); 9 | } 10 | public SomeStructBuilder title(String title) { 11 | if (this.internal.config == null) { 12 | this.internal.config = new known_any.Config(); 13 | } 14 | ((Config) this.internal.config).title = title; 15 | return this; 16 | } 17 | public SomeStruct build() { 18 | return this.internal; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/jennies/builders/known_any/PHPConverter/src/KnownAny/SomeStructConverter.php: -------------------------------------------------------------------------------- 1 | config !== null && $input->config instanceof \Grafana\Foundation\KnownAny\Config && $input->config->title !== "") { 14 | 15 | 16 | $buffer = 'title('; 17 | $arg0 =\var_export($input->config->title, true); 18 | $buffer .= $arg0; 19 | 20 | $buffer .= ')'; 21 | 22 | $calls[] = $buffer; 23 | 24 | 25 | } 26 | 27 | return \implode("\n\t->", $calls); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/known_any/PythonBuilder/builders/known_any.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import known_any 4 | 5 | 6 | class SomeStruct(cogbuilder.Builder[known_any.SomeStruct]): 7 | _internal: known_any.SomeStruct 8 | 9 | def __init__(self): 10 | self._internal = known_any.SomeStruct() 11 | 12 | def build(self) -> known_any.SomeStruct: 13 | """ 14 | Builds the object. 15 | """ 16 | return self._internal 17 | 18 | def title(self, title: str) -> typing.Self: 19 | if self._internal.config is None: 20 | self._internal.config = known_any.Config() 21 | assert isinstance(self._internal.config, known_any.Config) 22 | self._internal.config.title = title 23 | 24 | return self 25 | 26 | -------------------------------------------------------------------------------- /testdata/jennies/builders/known_any/TypescriptBuilder/src/knownAny/someStructBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as knownAny from '../knownAny'; 3 | 4 | export class SomeStructBuilder implements cog.Builder { 5 | protected readonly internal: knownAny.SomeStruct; 6 | 7 | constructor() { 8 | this.internal = knownAny.defaultSomeStruct(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): knownAny.SomeStruct { 15 | return this.internal; 16 | } 17 | 18 | title(title: string): this { 19 | if (!this.internal.config) { 20 | this.internal.config = knownAny.defaultConfig(); 21 | } 22 | this.internal.config.title = title; 23 | return this; 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_index_assignment/JavaBuilder/sandbox/SomeStructBuilder.java: -------------------------------------------------------------------------------- 1 | package sandbox; 2 | 3 | import java.util.HashMap; 4 | 5 | public class SomeStructBuilder implements cog.Builder { 6 | protected final SomeStruct internal; 7 | 8 | public SomeStructBuilder() { 9 | this.internal = new SomeStruct(); 10 | } 11 | public SomeStructBuilder annotations(String key,String value) { 12 | if (this.internal.annotations == null) { 13 | this.internal.annotations = new HashMap<>(); 14 | } 15 | this.internal.annotations.put(key, value); 16 | return this; 17 | } 18 | public SomeStruct build() { 19 | return this.internal; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_index_assignment/PHPBuilder/src/Sandbox/SomeStructBuilder.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class SomeStructBuilder implements \Grafana\Foundation\Cog\Builder 9 | { 10 | protected \Grafana\Foundation\Sandbox\SomeStruct $internal; 11 | 12 | public function __construct() 13 | { 14 | $this->internal = new \Grafana\Foundation\Sandbox\SomeStruct(); 15 | } 16 | 17 | /** 18 | * Builds the object. 19 | * @return \Grafana\Foundation\Sandbox\SomeStruct 20 | */ 21 | public function build() 22 | { 23 | return $this->internal; 24 | } 25 | 26 | public function annotations(string $key, string $value): static 27 | { 28 | $this->internal->annotations[$key] = $value; 29 | 30 | return $this; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_index_assignment/PHPConverter/src/Sandbox/SomeStructConverter.php: -------------------------------------------------------------------------------- 1 | annotations as $key => $value) { 15 | { 16 | $buffer = 'annotations('; 17 | $arg0 =\var_export($key, true); 18 | $buffer .= $arg0; 19 | $buffer .= ', '; 20 | $arg1 =\var_export($value, true); 21 | $buffer .= $arg1; 22 | 23 | $buffer .= ')'; 24 | 25 | $calls[] = $buffer; 26 | } 27 | } 28 | 29 | 30 | return \implode("\n\t->", $calls); 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_index_assignment/PythonBuilder/builders/sandbox.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import sandbox 4 | 5 | 6 | class SomeStruct(cogbuilder.Builder[sandbox.SomeStruct]): 7 | _internal: sandbox.SomeStruct 8 | 9 | def __init__(self): 10 | self._internal = sandbox.SomeStruct() 11 | 12 | def build(self) -> sandbox.SomeStruct: 13 | """ 14 | Builds the object. 15 | """ 16 | return self._internal 17 | 18 | def annotations(self, key: str, value: str) -> typing.Self: 19 | if self._internal.annotations is None: 20 | self._internal.annotations = {} 21 | 22 | self._internal.annotations[key] = value 23 | 24 | return self 25 | 26 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_index_assignment/TypescriptBuilder/src/sandbox/someStructBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as sandbox from '../sandbox'; 3 | 4 | export class SomeStructBuilder implements cog.Builder { 5 | protected readonly internal: sandbox.SomeStruct; 6 | 7 | constructor() { 8 | this.internal = sandbox.defaultSomeStruct(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): sandbox.SomeStruct { 15 | return this.internal; 16 | } 17 | 18 | annotations(key: string,value: string): this { 19 | if (!this.internal.annotations) { 20 | this.internal.annotations = {}; 21 | } 22 | this.internal.annotations[key] = value; 23 | return this; 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_of_builders/GoConverter/map_of_builders/panel_converter_gen.go: -------------------------------------------------------------------------------- 1 | package map_of_builders 2 | 3 | 4 | 5 | import ( 6 | "strings" 7 | "fmt" 8 | ) 9 | 10 | // PanelConverter accepts a `Panel` object and generates the Go code to build this object using builders. 11 | func PanelConverter(input Panel) string { 12 | calls := []string{ 13 | `map_of_builders.NewPanelBuilder()`, 14 | } 15 | var buffer strings.Builder 16 | if input.Title != "" { 17 | 18 | buffer.WriteString(`Title(`) 19 | arg0 :=fmt.Sprintf("%#v", input.Title) 20 | buffer.WriteString(arg0) 21 | 22 | buffer.WriteString(")") 23 | 24 | calls = append(calls, buffer.String()) 25 | buffer.Reset() 26 | 27 | } 28 | 29 | return strings.Join(calls, ".\t\n") 30 | } 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_of_builders/JavaBuilder/map_of_builders/DashboardBuilder.java: -------------------------------------------------------------------------------- 1 | package map_of_builders; 2 | 3 | import java.util.Map; 4 | import java.util.HashMap; 5 | 6 | public class DashboardBuilder implements cog.Builder { 7 | protected final Dashboard internal; 8 | 9 | public DashboardBuilder() { 10 | this.internal = new Dashboard(); 11 | } 12 | public DashboardBuilder panels(Map> panels) { 13 | Map panelsResources = new HashMap<>(); 14 | for (var entry1 : panels.entrySet()) { 15 | panelsDepth1 = entry1.getValue().build(); 16 | panelsResources.put(entry1.getKey(), panelsDepth1); 17 | } 18 | this.internal.panels = panelsResources; 19 | return this; 20 | } 21 | public Dashboard build() { 22 | return this.internal; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_of_builders/JavaBuilder/map_of_builders/PanelBuilder.java: -------------------------------------------------------------------------------- 1 | package map_of_builders; 2 | 3 | 4 | public class PanelBuilder> implements cog.Builder { 5 | protected final Panel internal; 6 | 7 | public PanelBuilder() { 8 | this.internal = new Panel(); 9 | } 10 | public T title(String title) { 11 | this.internal.title = title; 12 | return (T) this; 13 | } 14 | public Panel build() { 15 | return this.internal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_of_builders/PHPBuilder/src/MapOfBuilders/PanelBuilder.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class PanelBuilder implements \Grafana\Foundation\Cog\Builder 9 | { 10 | protected \Grafana\Foundation\MapOfBuilders\Panel $internal; 11 | 12 | public function __construct() 13 | { 14 | $this->internal = new \Grafana\Foundation\MapOfBuilders\Panel(); 15 | } 16 | 17 | /** 18 | * Builds the object. 19 | * @return \Grafana\Foundation\MapOfBuilders\Panel 20 | */ 21 | public function build() 22 | { 23 | return $this->internal; 24 | } 25 | 26 | public function title(string $title): static 27 | { 28 | $this->internal->title = $title; 29 | 30 | return $this; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_of_builders/PHPConverter/src/MapOfBuilders/PanelConverter.php: -------------------------------------------------------------------------------- 1 | title !== "") { 14 | 15 | 16 | $buffer = 'title('; 17 | $arg0 =\var_export($input->title, true); 18 | $buffer .= $arg0; 19 | 20 | $buffer .= ')'; 21 | 22 | $calls[] = $buffer; 23 | 24 | 25 | } 26 | 27 | return \implode("\n\t->", $calls); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_of_builders/TypescriptBuilder/src/mapOfBuilders/panelBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as mapOfBuilders from '../mapOfBuilders'; 3 | 4 | export class PanelBuilder implements cog.Builder { 5 | protected readonly internal: mapOfBuilders.Panel; 6 | 7 | constructor() { 8 | this.internal = mapOfBuilders.defaultPanel(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): mapOfBuilders.Panel { 15 | return this.internal; 16 | } 17 | 18 | title(title: string): this { 19 | this.internal.title = title; 20 | return this; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /testdata/jennies/builders/map_of_builders/schema.cue: -------------------------------------------------------------------------------- 1 | package map_of_builders 2 | 3 | Panel: { 4 | title: string 5 | } 6 | 7 | Dashboard: { 8 | panels: { 9 | [string]: Panel 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/jennies/builders/nullable_map_assignment/JavaBuilder/nullable_map_assignment/SomeStructBuilder.java: -------------------------------------------------------------------------------- 1 | package nullable_map_assignment; 2 | 3 | import java.util.Map; 4 | 5 | public class SomeStructBuilder implements cog.Builder { 6 | protected final SomeStruct internal; 7 | 8 | public SomeStructBuilder() { 9 | this.internal = new SomeStruct(); 10 | } 11 | public SomeStructBuilder config(Map config) { 12 | this.internal.config = config; 13 | return this; 14 | } 15 | public SomeStruct build() { 16 | return this.internal; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/jennies/builders/nullable_map_assignment/PythonBuilder/builders/nullable_map_assignment.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import nullable_map_assignment 4 | 5 | 6 | class SomeStruct(cogbuilder.Builder[nullable_map_assignment.SomeStruct]): 7 | _internal: nullable_map_assignment.SomeStruct 8 | 9 | def __init__(self): 10 | self._internal = nullable_map_assignment.SomeStruct() 11 | 12 | def build(self) -> nullable_map_assignment.SomeStruct: 13 | """ 14 | Builds the object. 15 | """ 16 | return self._internal 17 | 18 | def config(self, config: dict[str, str]) -> typing.Self: 19 | self._internal.config = config 20 | 21 | return self 22 | 23 | -------------------------------------------------------------------------------- /testdata/jennies/builders/nullable_map_assignment/TypescriptBuilder/src/nullableMapAssignment/someStructBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as nullableMapAssignment from '../nullableMapAssignment'; 3 | 4 | export class SomeStructBuilder implements cog.Builder { 5 | protected readonly internal: nullableMapAssignment.SomeStruct; 6 | 7 | constructor() { 8 | this.internal = nullableMapAssignment.defaultSomeStruct(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): nullableMapAssignment.SomeStruct { 15 | return this.internal; 16 | } 17 | 18 | config(config: Record): this { 19 | this.internal.config = config; 20 | return this; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /testdata/jennies/builders/package-with-dashes/GoConverter/builderpkg/somenicebuilder_converter_gen.go: -------------------------------------------------------------------------------- 1 | package builderpkg 2 | 3 | 4 | 5 | import ( 6 | withdashes "github.com/grafana/cog/generated/with-dashes" 7 | "strings" 8 | "fmt" 9 | ) 10 | 11 | // SomeNiceBuilderConverter accepts a `SomeNiceBuilder` object and generates the Go code to build this object using builders. 12 | func SomeNiceBuilderConverter(input withdashes.SomeStruct) string { 13 | calls := []string{ 14 | `builderpkg.NewSomeNiceBuilderBuilder()`, 15 | } 16 | var buffer strings.Builder 17 | if input.Title != "" { 18 | 19 | buffer.WriteString(`Title(`) 20 | arg0 :=fmt.Sprintf("%#v", input.Title) 21 | buffer.WriteString(arg0) 22 | 23 | buffer.WriteString(")") 24 | 25 | calls = append(calls, buffer.String()) 26 | buffer.Reset() 27 | 28 | } 29 | 30 | return strings.Join(calls, ".\t\n") 31 | } 32 | -------------------------------------------------------------------------------- /testdata/jennies/builders/package-with-dashes/JavaBuilder/builderpkg/SomeNiceBuilderBuilder.java: -------------------------------------------------------------------------------- 1 | package builder-pkg; 2 | 3 | import with-dashes.SomeStruct; 4 | 5 | public class SomeNiceBuilderBuilder implements cog.Builder { 6 | protected final SomeStruct internal; 7 | 8 | public SomeNiceBuilderBuilder() { 9 | this.internal = new SomeStruct(); 10 | } 11 | public SomeNiceBuilderBuilder title(String title) { 12 | this.internal.title = title; 13 | return this; 14 | } 15 | public SomeStruct build() { 16 | return this.internal; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/jennies/builders/package-with-dashes/PHPBuilder/src/Builderpkg/SomeNiceBuilderBuilder.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class SomeNiceBuilderBuilder implements \Grafana\Foundation\Cog\Builder 9 | { 10 | protected \Grafana\Foundation\Withdashes\SomeStruct $internal; 11 | 12 | public function __construct() 13 | { 14 | $this->internal = new \Grafana\Foundation\Withdashes\SomeStruct(); 15 | } 16 | 17 | /** 18 | * Builds the object. 19 | * @return \Grafana\Foundation\Withdashes\SomeStruct 20 | */ 21 | public function build() 22 | { 23 | return $this->internal; 24 | } 25 | 26 | public function title(string $title): static 27 | { 28 | $this->internal->title = $title; 29 | 30 | return $this; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /testdata/jennies/builders/package-with-dashes/PHPConverter/src/Builderpkg/SomeNiceBuilderConverter.php: -------------------------------------------------------------------------------- 1 | title !== "") { 14 | 15 | 16 | $buffer = 'title('; 17 | $arg0 =\var_export($input->title, true); 18 | $buffer .= $arg0; 19 | 20 | $buffer .= ')'; 21 | 22 | $calls[] = $buffer; 23 | 24 | 25 | } 26 | 27 | return \implode("\n\t->", $calls); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/package-with-dashes/PythonBuilder/builders/builder-pkg.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import with-dashes 4 | 5 | 6 | class SomeNiceBuilder(cogbuilder.Builder[with-dashes.SomeStruct]): 7 | _internal: with-dashes.SomeStruct 8 | 9 | def __init__(self): 10 | self._internal = with-dashes.SomeStruct() 11 | 12 | def build(self) -> with-dashes.SomeStruct: 13 | """ 14 | Builds the object. 15 | """ 16 | return self._internal 17 | 18 | def title(self, title: str) -> typing.Self: 19 | self._internal.title = title 20 | 21 | return self 22 | 23 | -------------------------------------------------------------------------------- /testdata/jennies/builders/package-with-dashes/TypescriptBuilder/src/builderPkg/someNiceBuilderBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as withDashes from '../withDashes'; 3 | 4 | export class SomeNiceBuilderBuilder implements cog.Builder { 5 | protected readonly internal: withDashes.SomeStruct; 6 | 7 | constructor() { 8 | this.internal = withDashes.defaultSomeStruct(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): withDashes.SomeStruct { 15 | return this.internal; 16 | } 17 | 18 | title(title: string): this { 19 | this.internal.title = title; 20 | return this; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /testdata/jennies/builders/properties/GoConverter/properties/somestruct_converter_gen.go: -------------------------------------------------------------------------------- 1 | package properties 2 | 3 | 4 | 5 | import ( 6 | "strings" 7 | "fmt" 8 | ) 9 | 10 | // SomeStructConverter accepts a `SomeStruct` object and generates the Go code to build this object using builders. 11 | func SomeStructConverter(input SomeStruct) string { 12 | calls := []string{ 13 | `properties.NewSomeStructBuilder()`, 14 | } 15 | var buffer strings.Builder 16 | 17 | { 18 | buffer.WriteString(`Id(`) 19 | arg0 :=fmt.Sprintf("%#v", input.Id) 20 | buffer.WriteString(arg0) 21 | 22 | buffer.WriteString(")") 23 | 24 | calls = append(calls, buffer.String()) 25 | buffer.Reset() 26 | } 27 | 28 | 29 | return strings.Join(calls, ".\t\n") 30 | } 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/properties/JavaBuilder/properties/SomeStructBuilder.java: -------------------------------------------------------------------------------- 1 | package properties; 2 | 3 | 4 | public class SomeStructBuilder implements cog.Builder { 5 | protected final SomeStruct internal; 6 | private String someBuilderProperty; 7 | 8 | public SomeStructBuilder() { 9 | this.internal = new SomeStruct(); 10 | this.someBuilderProperty = ""; 11 | } 12 | public SomeStructBuilder id(Long id) { 13 | this.internal.id = id; 14 | return this; 15 | } 16 | public SomeStruct build() { 17 | return this.internal; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/jennies/builders/properties/PHPConverter/src/Properties/SomeStructConverter.php: -------------------------------------------------------------------------------- 1 | id, true); 18 | $buffer .= $arg0; 19 | 20 | $buffer .= ')'; 21 | 22 | $calls[] = $buffer; 23 | } 24 | 25 | 26 | 27 | return \implode("\n\t->", $calls); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/properties/PythonBuilder/builders/properties.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import properties 4 | 5 | 6 | class SomeStruct(cogbuilder.Builder[properties.SomeStruct]): 7 | _internal: properties.SomeStruct 8 | __some_builder_property: str = "" 9 | 10 | def __init__(self): 11 | self._internal = properties.SomeStruct() 12 | 13 | def build(self) -> properties.SomeStruct: 14 | """ 15 | Builds the object. 16 | """ 17 | return self._internal 18 | 19 | def id(self, id_val: int) -> typing.Self: 20 | self._internal.id_val = id_val 21 | 22 | return self 23 | 24 | -------------------------------------------------------------------------------- /testdata/jennies/builders/properties/TypescriptBuilder/src/properties/someStructBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as properties from '../properties'; 3 | 4 | export class SomeStructBuilder implements cog.Builder { 5 | protected readonly internal: properties.SomeStruct; 6 | private someBuilderProperty: string = ""; 7 | 8 | constructor() { 9 | this.internal = properties.defaultSomeStruct(); 10 | } 11 | 12 | /** 13 | * Builds the object. 14 | */ 15 | build(): properties.SomeStruct { 16 | return this.internal; 17 | } 18 | 19 | id(id: number): this { 20 | this.internal.id = id; 21 | return this; 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /testdata/jennies/builders/references/GoConverter/some_pkg/person_converter_gen.go: -------------------------------------------------------------------------------- 1 | package some_pkg 2 | 3 | 4 | 5 | import ( 6 | "strings" 7 | cog "github.com/grafana/cog/generated/cog" 8 | ) 9 | 10 | // PersonConverter accepts a `Person` object and generates the Go code to build this object using builders. 11 | func PersonConverter(input Person) string { 12 | calls := []string{ 13 | `some_pkg.NewPersonBuilder()`, 14 | } 15 | var buffer strings.Builder 16 | 17 | { 18 | buffer.WriteString(`Name(`) 19 | arg0 :=cog.Dump(input.Name) 20 | buffer.WriteString(arg0) 21 | 22 | buffer.WriteString(")") 23 | 24 | calls = append(calls, buffer.String()) 25 | buffer.Reset() 26 | } 27 | 28 | 29 | return strings.Join(calls, ".\t\n") 30 | } 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/references/JavaBuilder/some_pkg/PersonBuilder.java: -------------------------------------------------------------------------------- 1 | package some_pkg; 2 | 3 | import other_pkg.Name; 4 | 5 | public class PersonBuilder implements cog.Builder { 6 | protected final Person internal; 7 | 8 | public PersonBuilder() { 9 | this.internal = new Person(); 10 | } 11 | public PersonBuilder name(Name name) { 12 | this.internal.name = name; 13 | return this; 14 | } 15 | public Person build() { 16 | return this.internal; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/jennies/builders/references/PHPBuilder/src/SomePkg/PersonBuilder.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class PersonBuilder implements \Grafana\Foundation\Cog\Builder 9 | { 10 | protected \Grafana\Foundation\SomePkg\Person $internal; 11 | 12 | public function __construct() 13 | { 14 | $this->internal = new \Grafana\Foundation\SomePkg\Person(); 15 | } 16 | 17 | /** 18 | * Builds the object. 19 | * @return \Grafana\Foundation\SomePkg\Person 20 | */ 21 | public function build() 22 | { 23 | return $this->internal; 24 | } 25 | 26 | public function name(\Grafana\Foundation\OtherPkg\Name $name): static 27 | { 28 | $this->internal->name = $name; 29 | 30 | return $this; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /testdata/jennies/builders/references/PHPConverter/src/SomePkg/PersonConverter.php: -------------------------------------------------------------------------------- 1 | name, true); 18 | $buffer .= $arg0; 19 | 20 | $buffer .= ')'; 21 | 22 | $calls[] = $buffer; 23 | } 24 | 25 | 26 | 27 | return \implode("\n\t->", $calls); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/references/PythonBuilder/builders/some_pkg.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import some_pkg 4 | from ..models import other_pkg 5 | 6 | 7 | class Person(cogbuilder.Builder[some_pkg.Person]): 8 | _internal: some_pkg.Person 9 | 10 | def __init__(self): 11 | self._internal = some_pkg.Person() 12 | 13 | def build(self) -> some_pkg.Person: 14 | """ 15 | Builds the object. 16 | """ 17 | return self._internal 18 | 19 | def name(self, name: other_pkg.Name) -> typing.Self: 20 | self._internal.name = name 21 | 22 | return self 23 | 24 | -------------------------------------------------------------------------------- /testdata/jennies/builders/references/TypescriptBuilder/src/somePkg/personBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as somePkg from '../somePkg'; 3 | import * as otherPkg from '../otherPkg'; 4 | 5 | export class PersonBuilder implements cog.Builder { 6 | protected readonly internal: somePkg.Person; 7 | 8 | constructor() { 9 | this.internal = somePkg.defaultPerson(); 10 | } 11 | 12 | /** 13 | * Builds the object. 14 | */ 15 | build(): somePkg.Person { 16 | return this.internal; 17 | } 18 | 19 | name(name: otherPkg.Name): this { 20 | this.internal.name = name; 21 | return this; 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /testdata/jennies/builders/struct_fields_as_args_assignment/JavaBuilder/sandbox/SomeStructBuilder.java: -------------------------------------------------------------------------------- 1 | package sandbox; 2 | 3 | 4 | public class SomeStructBuilder implements cog.Builder { 5 | protected final SomeStruct internal; 6 | 7 | public SomeStructBuilder() { 8 | this.internal = new SomeStruct(); 9 | } 10 | public SomeStructBuilder time(String from,String to) { 11 | if (this.internal.time == null) { 12 | this.internal.time = new Object(); 13 | } 14 | this.internal.time.from = from; 15 | this.internal.time.to = to; 16 | return this; 17 | } 18 | public SomeStruct build() { 19 | return this.internal; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testdata/jennies/builders/struct_fields_as_args_assignment/PythonBuilder/builders/sandbox.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from ..cog import builder as cogbuilder 3 | from ..models import sandbox 4 | 5 | 6 | class SomeStruct(cogbuilder.Builder[sandbox.SomeStruct]): 7 | _internal: sandbox.SomeStruct 8 | 9 | def __init__(self): 10 | self._internal = sandbox.SomeStruct() 11 | 12 | def build(self) -> sandbox.SomeStruct: 13 | """ 14 | Builds the object. 15 | """ 16 | return self._internal 17 | 18 | def time(self, from_val: str, to: str) -> typing.Self: 19 | if self._internal.time is None: 20 | self._internal.time = "unknown" 21 | assert isinstance(self._internal.time, unknown) 22 | self._internal.time.from_val = from_val 23 | self._internal.time.to = to 24 | 25 | return self 26 | 27 | -------------------------------------------------------------------------------- /testdata/jennies/builders/struct_fields_as_args_assignment/TypescriptBuilder/src/sandbox/someStructBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as sandbox from '../sandbox'; 3 | 4 | export class SomeStructBuilder implements cog.Builder { 5 | protected readonly internal: sandbox.SomeStruct; 6 | 7 | constructor() { 8 | this.internal = sandbox.defaultSomeStruct(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): sandbox.SomeStruct { 15 | return this.internal; 16 | } 17 | 18 | time(from: string,to: string): this { 19 | if (!this.internal.time) { 20 | this.internal.time = { 21 | from: "now-6h", 22 | to: "now", 23 | }; 24 | } 25 | this.internal.time.from = from; 26 | this.internal.time.to = to; 27 | return this; 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/builders/struct_with_defaults/JavaBuilder/struct_with_defaults/NestedStructBuilder.java: -------------------------------------------------------------------------------- 1 | package struct_with_defaults; 2 | 3 | 4 | public class NestedStructBuilder implements cog.Builder { 5 | protected final NestedStruct internal; 6 | 7 | public NestedStructBuilder() { 8 | this.internal = new NestedStruct(); 9 | } 10 | public NestedStructBuilder stringVal(String stringVal) { 11 | this.internal.stringVal = stringVal; 12 | return this; 13 | } 14 | 15 | public NestedStructBuilder intVal(Long intVal) { 16 | this.internal.intVal = intVal; 17 | return this; 18 | } 19 | public NestedStruct build() { 20 | return this.internal; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/jennies/builders/struct_with_defaults/TypescriptBuilder/src/structWithDefaults/nestedStructBuilder.gen.ts: -------------------------------------------------------------------------------- 1 | import * as cog from '../cog'; 2 | import * as structWithDefaults from '../structWithDefaults'; 3 | 4 | export class NestedStructBuilder implements cog.Builder { 5 | protected readonly internal: structWithDefaults.NestedStruct; 6 | 7 | constructor() { 8 | this.internal = structWithDefaults.defaultNestedStruct(); 9 | } 10 | 11 | /** 12 | * Builds the object. 13 | */ 14 | build(): structWithDefaults.NestedStruct { 15 | return this.internal; 16 | } 17 | 18 | stringVal(stringVal: string): this { 19 | this.internal.stringVal = stringVal; 20 | return this; 21 | } 22 | 23 | intVal(intVal: number): this { 24 | this.internal.intVal = intVal; 25 | return this; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /testdata/jennies/builders/struct_with_defaults/schema.cue: -------------------------------------------------------------------------------- 1 | package struct_with_defaults 2 | 3 | #NestedStruct: { 4 | stringVal: string 5 | intVal: int64 6 | } 7 | 8 | #Struct: { 9 | allFields: #NestedStruct | *{ 10 | stringVal: "hello" 11 | intVal: 3 12 | } 13 | partialFields: #NestedStruct | *{ 14 | intVal: 4 15 | } 16 | emptyFields: #NestedStruct | *{} 17 | 18 | complexField: { 19 | uid: string 20 | nested: { 21 | nestedVal: string 22 | } 23 | array: [...string] 24 | } | *{ uid: "myUID", nested: { nestedVal: "nested"}, array: ["hello"]} 25 | 26 | partialComplexField: { 27 | uid: string 28 | aVal: int64 29 | } | *{ uid: "myUID" } 30 | } 31 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/arrays/JavaRawTypes/arrays/SomeStruct.java: -------------------------------------------------------------------------------- 1 | package arrays; 2 | 3 | 4 | public class SomeStruct { 5 | public Object fieldAny; 6 | public SomeStruct() { 7 | this.fieldAny = new Object(); 8 | } 9 | public SomeStruct(Object fieldAny) { 10 | this.fieldAny = fieldAny; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/arrays/PythonRawTypes/models/arrays.py: -------------------------------------------------------------------------------- 1 | import typing 2 | 3 | 4 | # List of tags, maybe? 5 | ArrayOfStrings: typing.TypeAlias = list[str] 6 | 7 | 8 | class SomeStruct: 9 | field_any: object 10 | 11 | def __init__(self, field_any: object = None): 12 | self.field_any = field_any 13 | 14 | def to_json(self) -> dict[str, object]: 15 | payload: dict[str, object] = { 16 | "FieldAny": self.field_any, 17 | } 18 | return payload 19 | 20 | @classmethod 21 | def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: 22 | args: dict[str, typing.Any] = {} 23 | 24 | if "FieldAny" in data: 25 | args["field_any"] = data["FieldAny"] 26 | 27 | return cls(**args) 28 | 29 | 30 | ArrayOfRefs: typing.TypeAlias = list['SomeStruct'] 31 | 32 | 33 | ArrayOfArrayOfNumbers: typing.TypeAlias = list[list[int]] 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/arrays/TypescriptRawTypes/src/arrays/types.gen.ts: -------------------------------------------------------------------------------- 1 | // List of tags, maybe? 2 | export type ArrayOfStrings = string[]; 3 | 4 | export const defaultArrayOfStrings = (): ArrayOfStrings => ([]); 5 | 6 | export interface someStruct { 7 | FieldAny: any; 8 | } 9 | 10 | export const defaultSomeStruct = (): someStruct => ({ 11 | FieldAny: {}, 12 | }); 13 | 14 | export type ArrayOfRefs = someStruct[]; 15 | 16 | export const defaultArrayOfRefs = (): ArrayOfRefs => ([]); 17 | 18 | export type ArrayOfArrayOfNumbers = number[][]; 19 | 20 | export const defaultArrayOfArrayOfNumbers = (): ArrayOfArrayOfNumbers => ([]); 21 | 22 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constant_reference_discriminator/JavaRawTypes/constant_reference_discriminator/Constants.java: -------------------------------------------------------------------------------- 1 | package constant_reference_discriminator; 2 | 3 | public class Constants { 4 | public static final String GridLayoutKindType = "GridLayout"; 5 | public static final String RowsLayoutKindType = "RowsLayout"; 6 | } 7 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constant_reference_discriminator/JavaRawTypes/constant_reference_discriminator/GridLayoutUsingValue.java: -------------------------------------------------------------------------------- 1 | package constant_reference_discriminator; 2 | 3 | 4 | public class GridLayoutUsingValue { 5 | public String kind; 6 | public String gridLayoutProperty; 7 | public GridLayoutUsingValue() { 8 | this.kind = GridLayoutKindType; 9 | this.gridLayoutProperty = ""; 10 | } 11 | public GridLayoutUsingValue(String gridLayoutProperty) { 12 | this.kind = GridLayoutKindType; 13 | this.gridLayoutProperty = gridLayoutProperty; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constant_reference_discriminator/JavaRawTypes/constant_reference_discriminator/GridLayoutWithoutValue.java: -------------------------------------------------------------------------------- 1 | package constant_reference_discriminator; 2 | 3 | 4 | public class GridLayoutWithoutValue { 5 | public String kind; 6 | public String gridLayoutProperty; 7 | public GridLayoutWithoutValue() { 8 | this.kind = GridLayoutKindType; 9 | this.gridLayoutProperty = ""; 10 | } 11 | public GridLayoutWithoutValue(String gridLayoutProperty) { 12 | this.kind = GridLayoutKindType; 13 | this.gridLayoutProperty = gridLayoutProperty; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constant_reference_discriminator/JavaRawTypes/constant_reference_discriminator/LayoutWithValue.java: -------------------------------------------------------------------------------- 1 | package constant_reference_discriminator; 2 | 3 | 4 | public class LayoutWithValue { 5 | protected GridLayoutUsingValue gridLayoutUsingValue; 6 | protected RowsLayoutUsingValue rowsLayoutUsingValue; 7 | protected LayoutWithValue() {} 8 | public static LayoutWithValue createGridLayoutUsingValue(GridLayoutUsingValue gridLayoutUsingValue) { 9 | LayoutWithValue layoutWithValue = new LayoutWithValue(); 10 | layoutWithValue.gridLayoutUsingValue = gridLayoutUsingValue; 11 | return layoutWithValue; 12 | } 13 | public static LayoutWithValue createRowsLayoutUsingValue(RowsLayoutUsingValue rowsLayoutUsingValue) { 14 | LayoutWithValue layoutWithValue = new LayoutWithValue(); 15 | layoutWithValue.rowsLayoutUsingValue = rowsLayoutUsingValue; 16 | return layoutWithValue; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constant_reference_discriminator/JavaRawTypes/constant_reference_discriminator/RowsLayoutUsingValue.java: -------------------------------------------------------------------------------- 1 | package constant_reference_discriminator; 2 | 3 | 4 | public class RowsLayoutUsingValue { 5 | public String kind; 6 | public String rowsLayoutProperty; 7 | public RowsLayoutUsingValue() { 8 | this.kind = RowsLayoutKindType; 9 | this.rowsLayoutProperty = ""; 10 | } 11 | public RowsLayoutUsingValue(String rowsLayoutProperty) { 12 | this.kind = RowsLayoutKindType; 13 | this.rowsLayoutProperty = rowsLayoutProperty; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constant_reference_discriminator/JavaRawTypes/constant_reference_discriminator/RowsLayoutWithoutValue.java: -------------------------------------------------------------------------------- 1 | package constant_reference_discriminator; 2 | 3 | 4 | public class RowsLayoutWithoutValue { 5 | public String kind; 6 | public String rowsLayoutProperty; 7 | public RowsLayoutWithoutValue() { 8 | this.kind = RowsLayoutKindType; 9 | this.rowsLayoutProperty = ""; 10 | } 11 | public RowsLayoutWithoutValue(String rowsLayoutProperty) { 12 | this.kind = RowsLayoutKindType; 13 | this.rowsLayoutProperty = rowsLayoutProperty; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constant_reference_discriminator/PHPRawTypes/src/ConstantReferenceDiscriminator/Constants.php: -------------------------------------------------------------------------------- 1 | myEnum = \Grafana\Foundation\ConstantReferences\Enum::valueA(); 12 | } 13 | 14 | /** 15 | * @param array $inputData 16 | */ 17 | public static function fromArray(array $inputData): self 18 | { 19 | return new self( 20 | ); 21 | } 22 | 23 | /** 24 | * @return mixed 25 | */ 26 | public function jsonSerialize(): mixed 27 | { 28 | $data = new \stdClass; 29 | $data->myEnum = $this->myEnum; 30 | return $data; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constant_references/schema.cue: -------------------------------------------------------------------------------- 1 | package constant_references 2 | 3 | Enum: "ValueA" | "ValueB" | "ValueC" 4 | 5 | ParentStruct: { 6 | myEnum: Enum 7 | } 8 | 9 | Struct: { 10 | ParentStruct 11 | myValue: string 12 | } 13 | 14 | StructA: { 15 | ParentStruct 16 | myEnum: Enum & "ValueA" 17 | } 18 | 19 | StructB: { 20 | Struct 21 | myEnum: Enum & "ValueB" 22 | } 23 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constraints/JavaRawTypes/constraints/RefStruct.java: -------------------------------------------------------------------------------- 1 | package constraints; 2 | 3 | import java.util.HashMap; 4 | import java.util.LinkedList; 5 | import java.util.Map; 6 | import java.util.List; 7 | 8 | public class RefStruct { 9 | public Map labels; 10 | public List tags; 11 | public RefStruct() { 12 | this.labels = new HashMap<>(); 13 | this.tags = new LinkedList<>(); 14 | } 15 | public RefStruct(Map labels,List tags) { 16 | this.labels = labels; 17 | this.tags = tags; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constraints/JavaRawTypes/constraints/SomeStruct.java: -------------------------------------------------------------------------------- 1 | package constraints; 2 | 3 | 4 | public class SomeStruct { 5 | public Long id; 6 | public Long maybeId; 7 | public String title; 8 | public RefStruct refStruct; 9 | public SomeStruct() { 10 | this.id = 0L; 11 | this.title = ""; 12 | } 13 | public SomeStruct(Long id,Long maybeId,String title,RefStruct refStruct) { 14 | this.id = id; 15 | this.maybeId = maybeId; 16 | this.title = title; 17 | this.refStruct = refStruct; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constraints/TypescriptRawTypes/src/constraints/types.gen.ts: -------------------------------------------------------------------------------- 1 | export interface SomeStruct { 2 | id: number; 3 | maybeId?: number; 4 | title: string; 5 | refStruct?: refStruct; 6 | } 7 | 8 | export const defaultSomeStruct = (): SomeStruct => ({ 9 | id: 0, 10 | title: "", 11 | }); 12 | 13 | export interface refStruct { 14 | labels: Record; 15 | tags: string[]; 16 | } 17 | 18 | export const defaultRefStruct = (): refStruct => ({ 19 | labels: {}, 20 | tags: [], 21 | }); 22 | 23 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/constraints/schema.cue: -------------------------------------------------------------------------------- 1 | package constraints 2 | 3 | import "strings" 4 | 5 | SomeStruct: { 6 | id: int64 & >= 5 & <10 7 | maybeId?: int64 & >= 5 & <10 8 | title: strings.MinRunes(1) & { 9 | string 10 | } 11 | refStruct?: refStruct 12 | } 13 | 14 | 15 | refStruct: { 16 | labels: [string]: (string & strings.MinRunes(1)) 17 | tags: [...(string & strings.MinRunes(1))] 18 | } 19 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/dashboard/JavaRawTypes/dashboard/Dashboard.java: -------------------------------------------------------------------------------- 1 | package dashboard; 2 | 3 | import java.util.List; 4 | 5 | public class Dashboard { 6 | public String title; 7 | public List panels; 8 | public Dashboard() { 9 | this.title = ""; 10 | } 11 | public Dashboard(String title,List panels) { 12 | this.title = title; 13 | this.panels = panels; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/dashboard/JavaRawTypes/dashboard/DataSourceRef.java: -------------------------------------------------------------------------------- 1 | package dashboard; 2 | 3 | 4 | public class DataSourceRef { 5 | public String type; 6 | public String uid; 7 | public DataSourceRef() { 8 | } 9 | public DataSourceRef(String type,String uid) { 10 | this.type = type; 11 | this.uid = uid; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/dashboard/JavaRawTypes/dashboard/FieldConfig.java: -------------------------------------------------------------------------------- 1 | package dashboard; 2 | 3 | 4 | public class FieldConfig { 5 | public String unit; 6 | public Object custom; 7 | public FieldConfig() { 8 | } 9 | public FieldConfig(String unit,Object custom) { 10 | this.unit = unit; 11 | this.custom = custom; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/dashboard/JavaRawTypes/dashboard/FieldConfigSource.java: -------------------------------------------------------------------------------- 1 | package dashboard; 2 | 3 | 4 | public class FieldConfigSource { 5 | public FieldConfig defaults; 6 | public FieldConfigSource() { 7 | } 8 | public FieldConfigSource(FieldConfig defaults) { 9 | this.defaults = defaults; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/dashboard/JavaRawTypes/dashboard/Panel.java: -------------------------------------------------------------------------------- 1 | package dashboard; 2 | 3 | import java.util.List; 4 | import cog.variants.Dataquery; 5 | 6 | public class Panel { 7 | public String title; 8 | public String type; 9 | public DataSourceRef datasource; 10 | public Object options; 11 | public List targets; 12 | public FieldConfigSource fieldConfig; 13 | public Panel() { 14 | this.title = ""; 15 | this.type = ""; 16 | } 17 | public Panel(String title,String type,DataSourceRef datasource,Object options,List targets,FieldConfigSource fieldConfig) { 18 | this.title = title; 19 | this.type = type; 20 | this.datasource = datasource; 21 | this.options = options; 22 | this.targets = targets; 23 | this.fieldConfig = fieldConfig; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/disjunctions/JavaRawTypes/disjunctions/BoolOrRef.java: -------------------------------------------------------------------------------- 1 | package disjunctions; 2 | 3 | 4 | public class BoolOrRef { 5 | public Boolean bool; 6 | public SomeStruct someStruct; 7 | public BoolOrRef() { 8 | } 9 | public BoolOrRef(Boolean bool,SomeStruct someStruct) { 10 | this.bool = bool; 11 | this.someStruct = someStruct; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/disjunctions/JavaRawTypes/disjunctions/RefreshRate.java: -------------------------------------------------------------------------------- 1 | package disjunctions; 2 | 3 | 4 | // Refresh rate or disabled. 5 | public class RefreshRate { 6 | protected String string; 7 | protected Boolean bool; 8 | protected RefreshRate() {} 9 | public static RefreshRate createString(String string) { 10 | RefreshRate refreshRate = new RefreshRate(); 11 | refreshRate.string = string; 12 | return refreshRate; 13 | } 14 | public static RefreshRate createBool(Boolean bool) { 15 | RefreshRate refreshRate = new RefreshRate(); 16 | refreshRate.bool = bool; 17 | return refreshRate; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/disjunctions/JavaRawTypes/disjunctions/SomeOtherStruct.java: -------------------------------------------------------------------------------- 1 | package disjunctions; 2 | 3 | 4 | public class SomeOtherStruct { 5 | public String type; 6 | public Byte foo; 7 | public SomeOtherStruct() { 8 | this.type = ""; 9 | this.foo = (byte) 0; 10 | } 11 | public SomeOtherStruct(String type,Byte foo) { 12 | this.type = type; 13 | this.foo = foo; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/disjunctions/JavaRawTypes/disjunctions/SomeStruct.java: -------------------------------------------------------------------------------- 1 | package disjunctions; 2 | 3 | 4 | public class SomeStruct { 5 | public String type; 6 | public Object fieldAny; 7 | public SomeStruct() { 8 | this.type = ""; 9 | this.fieldAny = new Object(); 10 | } 11 | public SomeStruct(String type,Object fieldAny) { 12 | this.type = type; 13 | this.fieldAny = fieldAny; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/disjunctions/JavaRawTypes/disjunctions/YetAnotherStruct.java: -------------------------------------------------------------------------------- 1 | package disjunctions; 2 | 3 | 4 | public class YetAnotherStruct { 5 | public String type; 6 | public Integer bar; 7 | public YetAnotherStruct() { 8 | this.type = ""; 9 | this.bar = 0; 10 | } 11 | public YetAnotherStruct(String type,Integer bar) { 12 | this.type = type; 13 | this.bar = bar; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/enums/GoRawTypes/enums/types_gen.go: -------------------------------------------------------------------------------- 1 | package enums 2 | 3 | // This is a very interesting string enum. 4 | type Operator string 5 | const ( 6 | OperatorGreaterThan Operator = ">" 7 | OperatorLessThan Operator = "<" 8 | ) 9 | 10 | 11 | type TableSortOrder string 12 | const ( 13 | TableSortOrderAsc TableSortOrder = "asc" 14 | TableSortOrderDesc TableSortOrder = "desc" 15 | ) 16 | 17 | 18 | type LogsSortOrder string 19 | const ( 20 | LogsSortOrderAsc LogsSortOrder = "time_asc" 21 | LogsSortOrderDesc LogsSortOrder = "time_desc" 22 | ) 23 | 24 | 25 | // 0 for no shared crosshair or tooltip (default). 26 | // 1 for shared crosshair. 27 | // 2 for shared crosshair AND shared tooltip. 28 | type DashboardCursorSync int8 29 | const ( 30 | DashboardCursorSyncOff DashboardCursorSync = 0 31 | DashboardCursorSyncCrosshair DashboardCursorSync = 1 32 | DashboardCursorSyncTooltip DashboardCursorSync = 2 33 | ) 34 | 35 | 36 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/enums/JSONSchema/enums.jsonschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "definitions": { 4 | "Operator": { 5 | "enum": [ 6 | "\u003e", 7 | "\u003c" 8 | ], 9 | "description": "This is a very interesting string enum." 10 | }, 11 | "TableSortOrder": { 12 | "enum": [ 13 | "asc", 14 | "desc" 15 | ] 16 | }, 17 | "LogsSortOrder": { 18 | "enum": [ 19 | "time_asc", 20 | "time_desc" 21 | ] 22 | }, 23 | "DashboardCursorSync": { 24 | "enum": [ 25 | 0, 26 | 1, 27 | 2 28 | ], 29 | "description": "0 for no shared crosshair or tooltip (default).\n1 for shared crosshair.\n2 for shared crosshair AND shared tooltip." 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/enums/JavaRawTypes/enums/DashboardCursorSync.java: -------------------------------------------------------------------------------- 1 | package enums; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | 7 | // 0 for no shared crosshair or tooltip (default). 8 | // 1 for shared crosshair. 9 | // 2 for shared crosshair AND shared tooltip. 10 | @JsonFormat(shape = JsonFormat.Shape.OBJECT) 11 | public enum DashboardCursorSync { 12 | OFF(0), 13 | CROSSHAIR(1), 14 | TOOLTIP(2); 15 | 16 | private final Integer value; 17 | 18 | private DashboardCursorSync(Integer value) { 19 | this.value = value; 20 | } 21 | 22 | @JsonValue 23 | public Integer Value() { 24 | return value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/enums/JavaRawTypes/enums/LogsSortOrder.java: -------------------------------------------------------------------------------- 1 | package enums; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | 7 | @JsonFormat(shape = JsonFormat.Shape.OBJECT) 8 | public enum LogsSortOrder { 9 | ASC("time_asc"), 10 | DESC("time_desc"), 11 | _EMPTY(""); 12 | 13 | private final String value; 14 | 15 | private LogsSortOrder(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | public String Value() { 21 | return value; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/enums/JavaRawTypes/enums/Operator.java: -------------------------------------------------------------------------------- 1 | package enums; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | 7 | // This is a very interesting string enum. 8 | @JsonFormat(shape = JsonFormat.Shape.OBJECT) 9 | public enum Operator { 10 | GREATER_THAN(">"), 11 | LESS_THAN("<"), 12 | _EMPTY(""); 13 | 14 | private final String value; 15 | 16 | private Operator(String value) { 17 | this.value = value; 18 | } 19 | 20 | @JsonValue 21 | public String Value() { 22 | return value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/enums/JavaRawTypes/enums/TableSortOrder.java: -------------------------------------------------------------------------------- 1 | package enums; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | 7 | @JsonFormat(shape = JsonFormat.Shape.OBJECT) 8 | public enum TableSortOrder { 9 | ASC("asc"), 10 | DESC("desc"), 11 | _EMPTY(""); 12 | 13 | private final String value; 14 | 15 | private TableSortOrder(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | public String Value() { 21 | return value; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/enums/PythonRawTypes/models/enums.py: -------------------------------------------------------------------------------- 1 | import enum 2 | 3 | 4 | class Operator(enum.StrEnum): 5 | """ 6 | This is a very interesting string enum. 7 | """ 8 | 9 | GREATER_THAN = ">" 10 | LESS_THAN = "<" 11 | 12 | 13 | class TableSortOrder(enum.StrEnum): 14 | ASC = "asc" 15 | DESC = "desc" 16 | 17 | 18 | class LogsSortOrder(enum.StrEnum): 19 | ASC = "time_asc" 20 | DESC = "time_desc" 21 | 22 | 23 | class DashboardCursorSync(enum.IntEnum): 24 | """ 25 | 0 for no shared crosshair or tooltip (default). 26 | 1 for shared crosshair. 27 | 2 for shared crosshair AND shared tooltip. 28 | """ 29 | 30 | OFF = 0 31 | CROSSHAIR = 1 32 | TOOLTIP = 2 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/enums/TypescriptRawTypes/src/enums/types.gen.ts: -------------------------------------------------------------------------------- 1 | // This is a very interesting string enum. 2 | export enum Operator { 3 | GreaterThan = ">", 4 | LessThan = "<", 5 | } 6 | 7 | export const defaultOperator = (): Operator => (Operator.GreaterThan); 8 | 9 | export enum TableSortOrder { 10 | Asc = "asc", 11 | Desc = "desc", 12 | } 13 | 14 | export const defaultTableSortOrder = (): TableSortOrder => (TableSortOrder.Asc); 15 | 16 | export enum LogsSortOrder { 17 | Asc = "time_asc", 18 | Desc = "time_desc", 19 | } 20 | 21 | export const defaultLogsSortOrder = (): LogsSortOrder => (LogsSortOrder.Asc); 22 | 23 | // 0 for no shared crosshair or tooltip (default). 24 | // 1 for shared crosshair. 25 | // 2 for shared crosshair AND shared tooltip. 26 | export enum DashboardCursorSync { 27 | Off = 0, 28 | Crosshair = 1, 29 | Tooltip = 2, 30 | } 31 | 32 | export const defaultDashboardCursorSync = (): DashboardCursorSync => (DashboardCursorSync.Off); 33 | 34 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/field_with_struct_with_defaults/JavaRawTypes/defaults/DefaultsStructComplexField.java: -------------------------------------------------------------------------------- 1 | package defaults; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | public class DefaultsStructComplexField { 7 | public String uid; 8 | public DefaultsStructComplexFieldNested nested; 9 | public List array; 10 | public DefaultsStructComplexField() { 11 | this.uid = ""; 12 | this.nested = new defaults.DefaultsStructComplexFieldNested(); 13 | this.array = new LinkedList<>(); 14 | } 15 | public DefaultsStructComplexField(String uid,DefaultsStructComplexFieldNested nested,List array) { 16 | this.uid = uid; 17 | this.nested = nested; 18 | this.array = array; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/field_with_struct_with_defaults/JavaRawTypes/defaults/DefaultsStructComplexFieldNested.java: -------------------------------------------------------------------------------- 1 | package defaults; 2 | 3 | 4 | public class DefaultsStructComplexFieldNested { 5 | public String nestedVal; 6 | public DefaultsStructComplexFieldNested() { 7 | this.nestedVal = ""; 8 | } 9 | public DefaultsStructComplexFieldNested(String nestedVal) { 10 | this.nestedVal = nestedVal; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/field_with_struct_with_defaults/JavaRawTypes/defaults/DefaultsStructPartialComplexField.java: -------------------------------------------------------------------------------- 1 | package defaults; 2 | 3 | 4 | public class DefaultsStructPartialComplexField { 5 | public String uid; 6 | public Long intVal; 7 | public DefaultsStructPartialComplexField() { 8 | this.uid = ""; 9 | this.intVal = 0L; 10 | } 11 | public DefaultsStructPartialComplexField(String uid,Long intVal) { 12 | this.uid = uid; 13 | this.intVal = intVal; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/field_with_struct_with_defaults/JavaRawTypes/defaults/NestedStruct.java: -------------------------------------------------------------------------------- 1 | package defaults; 2 | 3 | 4 | public class NestedStruct { 5 | public String stringVal; 6 | public Long intVal; 7 | public NestedStruct() { 8 | this.stringVal = ""; 9 | this.intVal = 0L; 10 | } 11 | public NestedStruct(String stringVal,Long intVal) { 12 | this.stringVal = stringVal; 13 | this.intVal = intVal; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/intersections/JSONSchema/intersections.jsonschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$ref": "#/definitions/Intersections", 4 | "definitions": { 5 | "Intersections": {}, 6 | "SomeStruct": { 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": [ 10 | "fieldBool" 11 | ], 12 | "properties": { 13 | "fieldBool": { 14 | "type": "boolean", 15 | "default": true 16 | } 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/intersections/JavaRawTypes/intersections/Intersections.java: -------------------------------------------------------------------------------- 1 | package intersections; 2 | 3 | import externalPkg.AnotherStruct; 4 | 5 | public class Intersections extends SomeStruct, AnotherStruct { 6 | public String fieldString; 7 | public Integer fieldInteger; 8 | } 9 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/intersections/JavaRawTypes/intersections/SomeStruct.java: -------------------------------------------------------------------------------- 1 | package intersections; 2 | 3 | 4 | public class SomeStruct { 5 | public Boolean fieldBool; 6 | public SomeStruct() { 7 | this.fieldBool = true; 8 | } 9 | public SomeStruct(Boolean fieldBool) { 10 | this.fieldBool = fieldBool; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/intersections/OpenAPI/intersections.openapi.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "intersections", 5 | "version": "0.0.0", 6 | "x-schema-identifier": "", 7 | "x-schema-kind": "" 8 | }, 9 | "paths": {}, 10 | "components": { 11 | "schemas": { 12 | "Intersections": {}, 13 | "SomeStruct": { 14 | "type": "object", 15 | "additionalProperties": false, 16 | "required": [ 17 | "fieldBool" 18 | ], 19 | "properties": { 20 | "fieldBool": { 21 | "type": "boolean", 22 | "default": true 23 | } 24 | } 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/intersections/TypescriptRawTypes/src/intersections/types.gen.ts: -------------------------------------------------------------------------------- 1 | import * as externalPkg from '../externalPkg'; 2 | 3 | 4 | export interface Intersections extends SomeStruct, externalPkg.AnotherStruct { 5 | fieldString: string; 6 | fieldInteger: number; 7 | } 8 | 9 | export const defaultIntersections = (): Intersections => ({ 10 | fieldString: "hello", 11 | fieldInteger: 32, 12 | }); 13 | 14 | export interface SomeStruct { 15 | fieldBool: boolean; 16 | } 17 | 18 | export const defaultSomeStruct = (): SomeStruct => ({ 19 | fieldBool: true, 20 | }); 21 | 22 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/maps/JavaRawTypes/maps/SomeStruct.java: -------------------------------------------------------------------------------- 1 | package maps; 2 | 3 | 4 | public class SomeStruct { 5 | public Object fieldAny; 6 | public SomeStruct() { 7 | this.fieldAny = new Object(); 8 | } 9 | public SomeStruct(Object fieldAny) { 10 | this.fieldAny = fieldAny; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/maps/TypescriptRawTypes/src/maps/types.gen.ts: -------------------------------------------------------------------------------- 1 | // String to... something. 2 | export type MapOfStringToAny = Record; 3 | 4 | export const defaultMapOfStringToAny = (): MapOfStringToAny => ({}); 5 | 6 | export type MapOfStringToString = Record; 7 | 8 | export const defaultMapOfStringToString = (): MapOfStringToString => ({}); 9 | 10 | export interface SomeStruct { 11 | FieldAny: any; 12 | } 13 | 14 | export const defaultSomeStruct = (): SomeStruct => ({ 15 | FieldAny: {}, 16 | }); 17 | 18 | export type MapOfStringToRef = Record; 19 | 20 | export const defaultMapOfStringToRef = (): MapOfStringToRef => ({}); 21 | 22 | export type MapOfStringToMapOfStringToBool = Record>; 23 | 24 | export const defaultMapOfStringToMapOfStringToBool = (): MapOfStringToMapOfStringToBool => ({}); 25 | 26 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/package-with-dashes/JSONSchema/with-dashes.jsonschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "definitions": { 4 | "someStruct": { 5 | "type": "object", 6 | "additionalProperties": false, 7 | "required": [ 8 | "FieldAny" 9 | ], 10 | "properties": { 11 | "FieldAny": { 12 | "type": "object", 13 | "additionalProperties": {} 14 | } 15 | } 16 | }, 17 | "RefreshRate": { 18 | "anyOf": [ 19 | { 20 | "type": "string" 21 | }, 22 | { 23 | "type": "boolean" 24 | } 25 | ], 26 | "description": "Refresh rate or disabled." 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/package-with-dashes/JavaRawTypes/withdashes/RefreshRate.java: -------------------------------------------------------------------------------- 1 | package withdashes; 2 | 3 | 4 | // Refresh rate or disabled. 5 | public class RefreshRate { 6 | protected String string; 7 | protected Boolean bool; 8 | protected RefreshRate() {} 9 | public static RefreshRate createString(String string) { 10 | RefreshRate refreshRate = new RefreshRate(); 11 | refreshRate.string = string; 12 | return refreshRate; 13 | } 14 | public static RefreshRate createBool(Boolean bool) { 15 | RefreshRate refreshRate = new RefreshRate(); 16 | refreshRate.bool = bool; 17 | return refreshRate; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/package-with-dashes/JavaRawTypes/withdashes/SomeStruct.java: -------------------------------------------------------------------------------- 1 | package withdashes; 2 | 3 | 4 | public class SomeStruct { 5 | public Object fieldAny; 6 | public SomeStruct() { 7 | this.fieldAny = new Object(); 8 | } 9 | public SomeStruct(Object fieldAny) { 10 | this.fieldAny = fieldAny; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/package-with-dashes/OpenAPI/with-dashes.openapi.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "with-dashes", 5 | "version": "0.0.0", 6 | "x-schema-identifier": "", 7 | "x-schema-kind": "" 8 | }, 9 | "paths": {}, 10 | "components": { 11 | "schemas": { 12 | "someStruct": { 13 | "type": "object", 14 | "additionalProperties": false, 15 | "required": [ 16 | "FieldAny" 17 | ], 18 | "properties": { 19 | "FieldAny": { 20 | "type": "object", 21 | "additionalProperties": {} 22 | } 23 | } 24 | }, 25 | "RefreshRate": { 26 | "anyOf": [ 27 | { 28 | "type": "string" 29 | }, 30 | { 31 | "type": "boolean" 32 | } 33 | ], 34 | "description": "Refresh rate or disabled." 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/package-with-dashes/PythonRawTypes/models/with-dashes.py: -------------------------------------------------------------------------------- 1 | import typing 2 | 3 | 4 | class SomeStruct: 5 | field_any: object 6 | 7 | def __init__(self, field_any: object = None): 8 | self.field_any = field_any 9 | 10 | def to_json(self) -> dict[str, object]: 11 | payload: dict[str, object] = { 12 | "FieldAny": self.field_any, 13 | } 14 | return payload 15 | 16 | @classmethod 17 | def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: 18 | args: dict[str, typing.Any] = {} 19 | 20 | if "FieldAny" in data: 21 | args["field_any"] = data["FieldAny"] 22 | 23 | return cls(**args) 24 | 25 | 26 | # Refresh rate or disabled. 27 | RefreshRate: typing.TypeAlias = typing.Union[str, bool] 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/package-with-dashes/TypescriptRawTypes/src/withDashes/types.gen.ts: -------------------------------------------------------------------------------- 1 | export interface someStruct { 2 | FieldAny: any; 3 | } 4 | 5 | export const defaultSomeStruct = (): someStruct => ({ 6 | FieldAny: {}, 7 | }); 8 | 9 | // Refresh rate or disabled. 10 | export type RefreshRate = string | boolean; 11 | 12 | export const defaultRefreshRate = (): RefreshRate => (""); 13 | 14 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/refs/JSONSchema/refs.jsonschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "definitions": { 4 | "SomeStruct": { 5 | "type": "object", 6 | "additionalProperties": false, 7 | "required": [ 8 | "FieldAny" 9 | ], 10 | "properties": { 11 | "FieldAny": { 12 | "type": "object", 13 | "additionalProperties": {} 14 | } 15 | } 16 | }, 17 | "RefToSomeStruct": { 18 | "$ref": "#/definitions/SomeStruct" 19 | }, 20 | "RefToSomeStructFromOtherPackage": { 21 | "$ref": "#/definitions/SomeDistantStruct" 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/refs/JavaRawTypes/refs/RefToSomeStruct.java: -------------------------------------------------------------------------------- 1 | package refs; 2 | 3 | 4 | public class RefToSomeStruct { 5 | public Object fieldAny; 6 | public RefToSomeStruct() { 7 | this.fieldAny = new Object(); 8 | } 9 | public RefToSomeStruct(Object fieldAny) { 10 | this.fieldAny = fieldAny; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/refs/JavaRawTypes/refs/RefToSomeStructFromOtherPackage.java: -------------------------------------------------------------------------------- 1 | package refs; 2 | 3 | 4 | public class RefToSomeStructFromOtherPackage extends otherpkg.SomeDistantStruct { 5 | } 6 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/refs/OpenAPI/refs.openapi.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "refs", 5 | "version": "0.0.0", 6 | "x-schema-identifier": "", 7 | "x-schema-kind": "" 8 | }, 9 | "paths": {}, 10 | "components": { 11 | "schemas": { 12 | "SomeStruct": { 13 | "type": "object", 14 | "additionalProperties": false, 15 | "required": [ 16 | "FieldAny" 17 | ], 18 | "properties": { 19 | "FieldAny": { 20 | "type": "object", 21 | "additionalProperties": {} 22 | } 23 | } 24 | }, 25 | "RefToSomeStruct": { 26 | "$ref": "#/components/schemas/SomeStruct" 27 | }, 28 | "RefToSomeStructFromOtherPackage": { 29 | "$ref": "#/components/schemas/SomeDistantStruct" 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/refs/PHPRawTypes/src/Refs/RefToSomeStruct.php: -------------------------------------------------------------------------------- 1 | dict[str, object]: 12 | payload: dict[str, object] = { 13 | "FieldAny": self.field_any, 14 | } 15 | return payload 16 | 17 | @classmethod 18 | def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: 19 | args: dict[str, typing.Any] = {} 20 | 21 | if "FieldAny" in data: 22 | args["field_any"] = data["FieldAny"] 23 | 24 | return cls(**args) 25 | 26 | 27 | RefToSomeStruct: typing.TypeAlias = 'SomeStruct' 28 | 29 | 30 | RefToSomeStructFromOtherPackage: typing.TypeAlias = otherpkg.SomeDistantStruct 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/refs/TypescriptRawTypes/src/refs/types.gen.ts: -------------------------------------------------------------------------------- 1 | import * as otherpkg from '../otherpkg'; 2 | 3 | 4 | export interface SomeStruct { 5 | FieldAny: any; 6 | } 7 | 8 | export const defaultSomeStruct = (): SomeStruct => ({ 9 | FieldAny: {}, 10 | }); 11 | 12 | export type RefToSomeStruct = SomeStruct; 13 | 14 | export const defaultRefToSomeStruct = (): RefToSomeStruct => (defaultSomeStruct()); 15 | 16 | export type RefToSomeStructFromOtherPackage = otherpkg.SomeDistantStruct; 17 | 18 | export const defaultRefToSomeStructFromOtherPackage = (): RefToSomeStructFromOtherPackage => (otherpkg.default()); 19 | 20 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/scalars/GoRawTypes/scalars/types_gen.go: -------------------------------------------------------------------------------- 1 | package scalars 2 | 3 | const ConstTypeString = "foo" 4 | 5 | type ScalarTypeAny any 6 | 7 | type ScalarTypeBool bool 8 | 9 | type ScalarTypeBytes []byte 10 | 11 | type ScalarTypeString string 12 | 13 | type ScalarTypeFloat32 float32 14 | 15 | type ScalarTypeFloat64 float64 16 | 17 | type ScalarTypeUint8 uint8 18 | 19 | type ScalarTypeUint16 uint16 20 | 21 | type ScalarTypeUint32 uint32 22 | 23 | type ScalarTypeUint64 uint64 24 | 25 | type ScalarTypeInt8 int8 26 | 27 | type ScalarTypeInt16 int16 28 | 29 | type ScalarTypeInt32 int32 30 | 31 | type ScalarTypeInt64 int64 32 | 33 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/scalars/JavaRawTypes/scalars/Constants.java: -------------------------------------------------------------------------------- 1 | package scalars; 2 | 3 | public class Constants { 4 | public static final String constTypeString = "foo"; 5 | } 6 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/scalars/PHPRawTypes/src/Scalars/Constants.php: -------------------------------------------------------------------------------- 1 | "), 10 | LESS_THAN("<"), 11 | _EMPTY(""); 12 | 13 | private final String value; 14 | 15 | private SomeStructOperator(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | public String Value() { 21 | return value; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/struct_with_complex_fields/JavaRawTypes/struct_complex_fields/StringOrBool.java: -------------------------------------------------------------------------------- 1 | package struct_complex_fields; 2 | 3 | 4 | public class StringOrBool { 5 | protected String string; 6 | protected Boolean bool; 7 | protected StringOrBool() {} 8 | public static StringOrBool createString(String string) { 9 | StringOrBool stringOrBool = new StringOrBool(); 10 | stringOrBool.string = string; 11 | return stringOrBool; 12 | } 13 | public static StringOrBool createBool(Boolean bool) { 14 | StringOrBool stringOrBool = new StringOrBool(); 15 | stringOrBool.bool = bool; 16 | return stringOrBool; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/struct_with_complex_fields/JavaRawTypes/struct_complex_fields/StringOrSomeOtherStruct.java: -------------------------------------------------------------------------------- 1 | package struct_complex_fields; 2 | 3 | 4 | public class StringOrSomeOtherStruct { 5 | public String string; 6 | public SomeOtherStruct someOtherStruct; 7 | public StringOrSomeOtherStruct() { 8 | } 9 | public StringOrSomeOtherStruct(String string,SomeOtherStruct someOtherStruct) { 10 | this.string = string; 11 | this.someOtherStruct = someOtherStruct; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/struct_with_complex_fields/JavaRawTypes/struct_complex_fields/StructComplexFieldsSomeStructFieldAnonymousStruct.java: -------------------------------------------------------------------------------- 1 | package struct_complex_fields; 2 | 3 | 4 | public class StructComplexFieldsSomeStructFieldAnonymousStruct { 5 | public Object fieldAny; 6 | public StructComplexFieldsSomeStructFieldAnonymousStruct() { 7 | this.fieldAny = new Object(); 8 | } 9 | public StructComplexFieldsSomeStructFieldAnonymousStruct(Object fieldAny) { 10 | this.fieldAny = fieldAny; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/struct_with_complex_fields/PHPRawTypes/src/StructComplexFields/Constants.php: -------------------------------------------------------------------------------- 1 | ({ 10 | fieldBool: true, 11 | fieldString: "foo", 12 | FieldStringWithConstantValue: "auto", 13 | FieldFloat32: 42.42, 14 | FieldInt32: 42, 15 | }); 16 | 17 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/struct_with_optional_fields/JavaRawTypes/struct_optional_fields/SomeOtherStruct.java: -------------------------------------------------------------------------------- 1 | package struct_optional_fields; 2 | 3 | 4 | public class SomeOtherStruct { 5 | public Object fieldAny; 6 | public SomeOtherStruct() { 7 | this.fieldAny = new Object(); 8 | } 9 | public SomeOtherStruct(Object fieldAny) { 10 | this.fieldAny = fieldAny; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/struct_with_optional_fields/JavaRawTypes/struct_optional_fields/SomeStruct.java: -------------------------------------------------------------------------------- 1 | package struct_optional_fields; 2 | 3 | import java.util.List; 4 | 5 | public class SomeStruct { 6 | public SomeOtherStruct fieldRef; 7 | public String fieldString; 8 | public SomeStructOperator operator; 9 | public List fieldArrayOfStrings; 10 | public StructOptionalFieldsSomeStructFieldAnonymousStruct fieldAnonymousStruct; 11 | public SomeStruct() { 12 | } 13 | public SomeStruct(SomeOtherStruct fieldRef,String fieldString,SomeStructOperator operator,List fieldArrayOfStrings,StructOptionalFieldsSomeStructFieldAnonymousStruct fieldAnonymousStruct) { 14 | this.fieldRef = fieldRef; 15 | this.fieldString = fieldString; 16 | this.operator = operator; 17 | this.fieldArrayOfStrings = fieldArrayOfStrings; 18 | this.fieldAnonymousStruct = fieldAnonymousStruct; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/struct_with_optional_fields/JavaRawTypes/struct_optional_fields/SomeStructOperator.java: -------------------------------------------------------------------------------- 1 | package struct_optional_fields; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | 7 | @JsonFormat(shape = JsonFormat.Shape.OBJECT) 8 | public enum SomeStructOperator { 9 | GREATER_THAN(">"), 10 | LESS_THAN("<"), 11 | _EMPTY(""); 12 | 13 | private final String value; 14 | 15 | private SomeStructOperator(String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | public String Value() { 21 | return value; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/struct_with_optional_fields/JavaRawTypes/struct_optional_fields/StructOptionalFieldsSomeStructFieldAnonymousStruct.java: -------------------------------------------------------------------------------- 1 | package struct_optional_fields; 2 | 3 | 4 | public class StructOptionalFieldsSomeStructFieldAnonymousStruct { 5 | public Object fieldAny; 6 | public StructOptionalFieldsSomeStructFieldAnonymousStruct() { 7 | this.fieldAny = new Object(); 8 | } 9 | public StructOptionalFieldsSomeStructFieldAnonymousStruct(Object fieldAny) { 10 | this.fieldAny = fieldAny; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/struct_with_optional_fields/TypescriptRawTypes/src/structOptionalFields/types.gen.ts: -------------------------------------------------------------------------------- 1 | export interface SomeStruct { 2 | FieldRef?: SomeOtherStruct; 3 | FieldString?: string; 4 | Operator?: ">" | "<"; 5 | FieldArrayOfStrings?: string[]; 6 | FieldAnonymousStruct?: { 7 | FieldAny: any; 8 | }; 9 | } 10 | 11 | export const defaultSomeStruct = (): SomeStruct => ({ 12 | }); 13 | 14 | export interface SomeOtherStruct { 15 | FieldAny: any; 16 | } 17 | 18 | export const defaultSomeOtherStruct = (): SomeOtherStruct => ({ 19 | FieldAny: {}, 20 | }); 21 | 22 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/time_hint/JSONSchema/time_hint.jsonschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "definitions": { 4 | "objTime": { 5 | "type": "string", 6 | "format": "date-time" 7 | }, 8 | "objWithTimeField": { 9 | "type": "object", 10 | "additionalProperties": false, 11 | "required": [ 12 | "registeredAt" 13 | ], 14 | "properties": { 15 | "registeredAt": { 16 | "type": "string", 17 | "format": "date-time" 18 | } 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/time_hint/JavaRawTypes/time_hint/ObjWithTimeField.java: -------------------------------------------------------------------------------- 1 | package time_hint; 2 | 3 | 4 | public class ObjWithTimeField { 5 | public String registeredAt; 6 | public ObjWithTimeField() { 7 | this.registeredAt = ""; 8 | } 9 | public ObjWithTimeField(String registeredAt) { 10 | this.registeredAt = registeredAt; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/time_hint/OpenAPI/time_hint.openapi.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "time_hint", 5 | "version": "0.0.0", 6 | "x-schema-identifier": "", 7 | "x-schema-kind": "" 8 | }, 9 | "paths": {}, 10 | "components": { 11 | "schemas": { 12 | "objTime": { 13 | "type": "string", 14 | "format": "date-time" 15 | }, 16 | "objWithTimeField": { 17 | "type": "object", 18 | "additionalProperties": false, 19 | "required": [ 20 | "registeredAt" 21 | ], 22 | "properties": { 23 | "registeredAt": { 24 | "type": "string", 25 | "format": "date-time" 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/time_hint/PythonRawTypes/models/time_hint.py: -------------------------------------------------------------------------------- 1 | import typing 2 | 3 | 4 | ObjTime: typing.TypeAlias = str 5 | 6 | 7 | class ObjWithTimeField: 8 | registered_at: str 9 | 10 | def __init__(self, registered_at: str = ""): 11 | self.registered_at = registered_at 12 | 13 | def to_json(self) -> dict[str, object]: 14 | payload: dict[str, object] = { 15 | "registeredAt": self.registered_at, 16 | } 17 | return payload 18 | 19 | @classmethod 20 | def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: 21 | args: dict[str, typing.Any] = {} 22 | 23 | if "registeredAt" in data: 24 | args["registered_at"] = data["registeredAt"] 25 | 26 | return cls(**args) 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/time_hint/TypescriptRawTypes/src/timeHint/types.gen.ts: -------------------------------------------------------------------------------- 1 | export type objTime = string; 2 | 3 | export const defaultObjTime = (): objTime => (""); 4 | 5 | export interface objWithTimeField { 6 | registeredAt: string; 7 | } 8 | 9 | export const defaultObjWithTimeField = (): objWithTimeField => ({ 10 | registeredAt: "", 11 | }); 12 | 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_dataquery/JSONSchema/variant_dataquery.jsonschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "definitions": { 4 | "Query": { 5 | "type": "object", 6 | "additionalProperties": false, 7 | "required": [ 8 | "expr" 9 | ], 10 | "properties": { 11 | "expr": { 12 | "type": "string" 13 | }, 14 | "instant": { 15 | "type": "boolean" 16 | } 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_dataquery/JavaRawTypes/variant_dataquery/Query.java: -------------------------------------------------------------------------------- 1 | package variant_dataquery; 2 | 3 | 4 | public class Query implements cog.variants.Dataquery { 5 | public String expr; 6 | public Boolean instant; 7 | public Query() { 8 | this.expr = ""; 9 | } 10 | public Query(String expr,Boolean instant) { 11 | this.expr = expr; 12 | this.instant = instant; 13 | } 14 | public String dataqueryName() { 15 | return "prometheus"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_dataquery/OpenAPI/variant_dataquery.openapi.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "variant_dataquery", 5 | "version": "0.0.0", 6 | "x-schema-identifier": "prometheus", 7 | "x-schema-kind": "composable", 8 | "x-schema-variant": "dataquery" 9 | }, 10 | "paths": {}, 11 | "components": { 12 | "schemas": { 13 | "Query": { 14 | "type": "object", 15 | "additionalProperties": false, 16 | "required": [ 17 | "expr" 18 | ], 19 | "properties": { 20 | "expr": { 21 | "type": "string" 22 | }, 23 | "instant": { 24 | "type": "boolean" 25 | } 26 | } 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_dataquery/TypescriptRawTypes/src/variantDataquery/types.gen.ts: -------------------------------------------------------------------------------- 1 | export interface Query { 2 | expr: string; 3 | instant?: boolean; 4 | _implementsDataqueryVariant(): void; 5 | } 6 | 7 | export const defaultQuery = (): Query => ({ 8 | expr: "", 9 | _implementsDataqueryVariant: () => {}, 10 | }); 11 | 12 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_panelcfg_full/JSONSchema/variant_panelcfg_full.jsonschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "definitions": { 4 | "Options": { 5 | "type": "object", 6 | "additionalProperties": false, 7 | "required": [ 8 | "timeseries_option" 9 | ], 10 | "properties": { 11 | "timeseries_option": { 12 | "type": "string" 13 | } 14 | } 15 | }, 16 | "FieldConfig": { 17 | "type": "object", 18 | "additionalProperties": false, 19 | "required": [ 20 | "timeseries_field_config_option" 21 | ], 22 | "properties": { 23 | "timeseries_field_config_option": { 24 | "type": "string" 25 | } 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_panelcfg_full/JavaRawTypes/variant_panelcfg_full/FieldConfig.java: -------------------------------------------------------------------------------- 1 | package variant_panelcfg_full; 2 | 3 | 4 | public class FieldConfig { 5 | public String timeseriesFieldConfigOption; 6 | public FieldConfig() { 7 | this.timeseriesFieldConfigOption = ""; 8 | } 9 | public FieldConfig(String timeseriesFieldConfigOption) { 10 | this.timeseriesFieldConfigOption = timeseriesFieldConfigOption; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_panelcfg_full/JavaRawTypes/variant_panelcfg_full/Options.java: -------------------------------------------------------------------------------- 1 | package variant_panelcfg_full; 2 | 3 | 4 | public class Options { 5 | public String timeseriesOption; 6 | public Options() { 7 | this.timeseriesOption = ""; 8 | } 9 | public Options(String timeseriesOption) { 10 | this.timeseriesOption = timeseriesOption; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_panelcfg_full/TypescriptRawTypes/src/variantPanelcfgFull/types.gen.ts: -------------------------------------------------------------------------------- 1 | export interface Options { 2 | timeseries_option: string; 3 | } 4 | 5 | export const defaultOptions = (): Options => ({ 6 | timeseries_option: "", 7 | }); 8 | 9 | export interface FieldConfig { 10 | timeseries_field_config_option: string; 11 | } 12 | 13 | export const defaultFieldConfig = (): FieldConfig => ({ 14 | timeseries_field_config_option: "", 15 | }); 16 | 17 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_panelcfg_only_options/JSONSchema/variant_panelcfg_only_options.jsonschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "definitions": { 4 | "Options": { 5 | "type": "object", 6 | "additionalProperties": false, 7 | "required": [ 8 | "content" 9 | ], 10 | "properties": { 11 | "content": { 12 | "type": "string" 13 | } 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_panelcfg_only_options/JavaRawTypes/variant_panelcfg_only_options/Options.java: -------------------------------------------------------------------------------- 1 | package variant_panelcfg_only_options; 2 | 3 | 4 | public class Options { 5 | public String content; 6 | public Options() { 7 | this.content = ""; 8 | } 9 | public Options(String content) { 10 | this.content = content; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_panelcfg_only_options/OpenAPI/variant_panelcfg_only_options.openapi.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "variant_panelcfg_only_options", 5 | "version": "0.0.0", 6 | "x-schema-identifier": "text", 7 | "x-schema-kind": "composable", 8 | "x-schema-variant": "panelcfg" 9 | }, 10 | "paths": {}, 11 | "components": { 12 | "schemas": { 13 | "Options": { 14 | "type": "object", 15 | "additionalProperties": false, 16 | "required": [ 17 | "content" 18 | ], 19 | "properties": { 20 | "content": { 21 | "type": "string" 22 | } 23 | } 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_panelcfg_only_options/PythonRawTypes/models/variant_panelcfg_only_options.py: -------------------------------------------------------------------------------- 1 | import typing 2 | 3 | 4 | class Options: 5 | content: str 6 | 7 | def __init__(self, content: str = ""): 8 | self.content = content 9 | 10 | def to_json(self) -> dict[str, object]: 11 | payload: dict[str, object] = { 12 | "content": self.content, 13 | } 14 | return payload 15 | 16 | @classmethod 17 | def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: 18 | args: dict[str, typing.Any] = {} 19 | 20 | if "content" in data: 21 | args["content"] = data["content"] 22 | 23 | return cls(**args) 24 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_panelcfg_only_options/TypescriptRawTypes/src/variantPanelcfgOnlyOptions/types.gen.ts: -------------------------------------------------------------------------------- 1 | export interface Options { 2 | content: string; 3 | } 4 | 5 | export const defaultOptions = (): Options => ({ 6 | content: "", 7 | }); 8 | 9 | -------------------------------------------------------------------------------- /testdata/jennies/rawtypes/variant_panelcfg_only_options/ir.json: -------------------------------------------------------------------------------- 1 | { 2 | "Package": "variant_panelcfg_only_options", 3 | "Metadata": { 4 | "Kind": "composable", 5 | "Variant": "panelcfg", 6 | "Identifier": "text" 7 | }, 8 | "Objects": { 9 | "Options": { 10 | "Name": "Options", 11 | "Type": { 12 | "Kind": "struct", 13 | "Struct": { 14 | "Fields": [ 15 | { 16 | "Name": "content", 17 | "Required": true, 18 | "Type": { 19 | "Kind": "scalar", 20 | "Scalar": { 21 | "ScalarKind": "string" 22 | } 23 | } 24 | } 25 | ] 26 | } 27 | }, 28 | "SelfRef": { 29 | "ReferredPkg": "variant_panelcfg_only_options", 30 | "ReferredType": "Options" 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /testdata/jsonschema/anyof_object/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/AnyOf", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "AnyOf": { 6 | "anyOf": [ 7 | { 8 | "type": "integer" 9 | }, 10 | { 11 | "type": "string" 12 | } 13 | ] 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/jsonschema/anyof_struct_field/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/AnyOfField", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "AnyOfField": { 6 | "properties": { 7 | "foo": { 8 | "anyOf": [ 9 | { 10 | "type": "integer" 11 | }, 12 | { 13 | "type": "string" 14 | } 15 | ] 16 | } 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/jsonschema/array_any/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/SomeObject", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "SomeObject": { 6 | "properties": { 7 | "array": { 8 | "type": "array" 9 | } 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testdata/jsonschema/enum/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/SomeObject", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "SomeObject": { 6 | "properties": { 7 | "sort": { 8 | "enum": [ 9 | "asc", 10 | "desc" 11 | ] 12 | }, 13 | "loglevel": { 14 | "enum": [ 15 | 1, 16 | 2, 17 | 3 18 | ] 19 | } 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/jsonschema/number_constraints/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/SomeObject", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "SomeObject": { 6 | "properties": { 7 | "minute": { 8 | "type": "number", 9 | "minimum": 0, 10 | "maximum": 59 11 | }, 12 | "seconds": { 13 | "type": "number", 14 | "exclusiveMinimum": -1, 15 | "exclusiveMaximum": 60 16 | } 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/jsonschema/object_no_properties/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/Entrypoint", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "Entrypoint": { 6 | "type": "object", 7 | "properties": { 8 | "ObjectNoProperties": { 9 | "$ref": "#/definitions/ObjectNoProperties" 10 | }, 11 | "ObjectNoAdditionalProperties": { 12 | "$ref": "#/definitions/ObjectNoAdditionalProperties" 13 | }, 14 | "ObjectAdditionalPropertiesWithSchema": { 15 | "$ref": "#/definitions/ObjectAdditionalPropertiesWithSchema" 16 | } 17 | } 18 | }, 19 | "ObjectNoProperties": { 20 | "type": "object" 21 | }, 22 | "ObjectNoAdditionalProperties": { 23 | "additionalProperties": false 24 | }, 25 | "ObjectAdditionalPropertiesWithSchema": { 26 | "additionalProperties": { 27 | "type": "string" 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/jsonschema/oneof_struct_field/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/OneOfField", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "OneOfField": { 6 | "properties": { 7 | "foo": { 8 | "oneOf": [ 9 | { 10 | "type": "integer" 11 | }, 12 | { 13 | "type": "string" 14 | } 15 | ] 16 | } 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/jsonschema/recursive/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/Node", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "Node": { 6 | "properties": { 7 | "value": { 8 | "type": "string" 9 | }, 10 | "edges": { 11 | "items": { 12 | "$ref": "#/definitions/Node" 13 | }, 14 | "type": "array" 15 | } 16 | }, 17 | "type": "object" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/jsonschema/ref_struct_field/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "title": { 4 | "$ref": "#/definitions/is-string" 5 | } 6 | }, 7 | "definitions": { 8 | "is-string": { 9 | "type": "string" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/jsonschema/string_length_constraints/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/SomeObject", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "SomeObject": { 6 | "properties": { 7 | "title": { 8 | "type": "string", 9 | "minLength": 1, 10 | "maxLength": 20 11 | } 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/jsonschema/time/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/SomeObject", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "SomeObject": { 6 | "properties": { 7 | "registeredAt": { 8 | "type": "string", 9 | "format": "date-time" 10 | } 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/openapi/consts/GenerateAST/ir.json: -------------------------------------------------------------------------------- 1 | { 2 | "Package": "grafanatest", 3 | "Metadata": {}, 4 | "EntryPointType": { 5 | "Kind": "", 6 | "Nullable": false 7 | }, 8 | "Objects": { 9 | "Constants": { 10 | "Name": "Constants", 11 | "Type": { 12 | "Kind": "struct", 13 | "Nullable": false, 14 | "Struct": { 15 | "Fields": [ 16 | { 17 | "Name": "const_disguised_as_regex", 18 | "Type": { 19 | "Kind": "scalar", 20 | "Nullable": false, 21 | "Scalar": { 22 | "ScalarKind": "string", 23 | "Value": "surprise" 24 | } 25 | }, 26 | "Required": false 27 | } 28 | ] 29 | } 30 | }, 31 | "SelfRef": { 32 | "ReferredPkg": "grafanatest", 33 | "ReferredType": "Constants" 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /testdata/openapi/consts/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "consts", 5 | "version": "0.0" 6 | }, 7 | "paths": {}, 8 | "components": { 9 | "schemas": { 10 | "Constants": { 11 | "type": "object", 12 | "properties": { 13 | "const_disguised_as_regex": { 14 | "type": "string", 15 | "pattern": "^surprise$" 16 | } 17 | } 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testdata/openapi/enums/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "enums", 5 | "version": "0.0" 6 | }, 7 | "paths": {}, 8 | "components": { 9 | "schemas": { 10 | "Enums": { 11 | "type": "object", 12 | "required": [ 13 | "enumString" 14 | ], 15 | "properties": { 16 | "enumString": { 17 | "type": "string", 18 | "enum": [ 19 | "a", 20 | "b" 21 | ] 22 | }, 23 | "enumInt": { 24 | "type": "integer", 25 | "enum": [ 26 | 3, 27 | 4 28 | ] 29 | }, 30 | "enumWithDefault": { 31 | "type": "string", 32 | "enum": [ 33 | "a", 34 | "b" 35 | ], 36 | "default": "a" 37 | } 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /testdata/openapi/external_refs/refs/refs.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "DataQuery", 5 | "version": "0.0" 6 | }, 7 | "paths": {}, 8 | "components": { 9 | "schemas": { 10 | "ReferenceA": { 11 | "type": "object", 12 | "properties": { 13 | "id": { 14 | "description": "An identifier", 15 | "type": "string" 16 | } 17 | } 18 | }, 19 | "ReferenceB": { 20 | "type": "object", 21 | "properties": { 22 | "value": { 23 | "description": "A value", 24 | "type": "string" 25 | } 26 | } 27 | } 28 | } 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /testdata/openapi/nested_structs/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "nested_structs", 5 | "version": "0.0" 6 | }, 7 | "paths": {}, 8 | "components": { 9 | "schemas": { 10 | "Nested": { 11 | "type": "object", 12 | "properties": { 13 | "nested": { 14 | "type": "object", 15 | "properties": { 16 | "nested": { 17 | "type": "object", 18 | "properties": { 19 | "value": { 20 | "type": "string" 21 | } 22 | } 23 | } 24 | } 25 | } 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /testdata/openapi/object_no_properties/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "object_no_properties", 5 | "version": "0.0" 6 | }, 7 | "paths": {}, 8 | "components": { 9 | "schemas": { 10 | "ObjectNoProperties": { 11 | "type": "object" 12 | }, 13 | "ObjectNoAdditionalProperties": { 14 | "additionalProperties": false 15 | }, 16 | "ObjectAdditionalPropertiesWithSchema": { 17 | "additionalProperties": { 18 | "type": "string" 19 | }, 20 | "type": "object" 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/openapi/refs/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "refs", 5 | "version": "0.0" 6 | }, 7 | "paths": {}, 8 | "components": { 9 | "schemas": { 10 | "Refs": { 11 | "type": "object", 12 | "required": [ 13 | "ref" 14 | ], 15 | "properties": { 16 | "ref": { 17 | "$ref": "#/components/schemas/Test" 18 | } 19 | } 20 | }, 21 | "Test": { 22 | "type": "object", 23 | "properties": { 24 | "a": { 25 | "type": "string" 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/openapi/split_schema/refs/partial.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "id": { 5 | "description": "An identifier", 6 | "type": "string" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /testdata/openapi/split_schema/refs/partial2.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "array", 3 | "items": { 4 | "$ref": "./refs.json/#/components/schemas/ReferenceA" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /testdata/openapi/split_schema/refs/refs.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "DataQuery", 5 | "version": "0.0" 6 | }, 7 | "paths": {}, 8 | "components": { 9 | "schemas": { 10 | "ReferenceA": { 11 | "type": "object", 12 | "properties": { 13 | "id": { 14 | "description": "An identifier", 15 | "type": "string" 16 | } 17 | } 18 | }, 19 | "ReferenceB": { 20 | "type": "object", 21 | "properties": { 22 | "value": { 23 | "description": "A value", 24 | "type": "string" 25 | } 26 | } 27 | } 28 | } 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /testdata/openapi/split_schema/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "external_schema", 5 | "version": "0.0" 6 | }, 7 | "paths": {}, 8 | "components": { 9 | "schemas": { 10 | "Partial": { 11 | "$ref": "./refs/partial.json" 12 | }, 13 | "Array": { 14 | "$ref": "./refs/partial2.json" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/openapi/time/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "time", 5 | "version": "0.0" 6 | }, 7 | "paths": {}, 8 | "components": { 9 | "schemas": { 10 | "SomeObject": { 11 | "type": "object", 12 | "properties": { 13 | "registeredAt": { 14 | "type": "string", 15 | "format": "date-time" 16 | } 17 | } 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testdata/schemas/defaults/defaults.cue: -------------------------------------------------------------------------------- 1 | package defaults 2 | 3 | VariableOption: { 4 | selected?: bool | string 5 | text: string | [...string] 6 | value: string | [...string] 7 | } 8 | 9 | TextVariable: { 10 | name: string | *"" 11 | current: VariableOption | *{ 12 | text: "" 13 | value: ["val"] 14 | selected: "maybe" 15 | } 16 | skipUrlSync: bool | *false 17 | } 18 | -------------------------------------------------------------------------------- /testdata/schemas/equality/equality.cue: -------------------------------------------------------------------------------- 1 | package equality 2 | 3 | #Direction: "top" | "bottom" | "left" | "right" 4 | 5 | #Variable: { 6 | name: string 7 | } 8 | 9 | container: { 10 | stringField: string 11 | intField: int 12 | enumField: #Direction 13 | refField: #Variable 14 | } 15 | 16 | optionals: { 17 | stringField?: string 18 | enumField?: #Direction 19 | refField?: #Variable 20 | } 21 | 22 | arrays: { 23 | ints: [...int] 24 | strings: [...string] 25 | arrayOfArray: [...[...string]] 26 | refs: [...#Variable] 27 | anonymousStructs: [...{ 28 | inner: string 29 | }] 30 | arrayOfAny: [...] 31 | } 32 | 33 | maps: { 34 | ints: [string]: int 35 | strings: [string]: string 36 | refs: [string]: #Variable 37 | anonymousStructs: [string]: { 38 | inner: string 39 | } 40 | stringToAny: { 41 | [string]: _ 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /testdata/schemas/validation/validation.cue: -------------------------------------------------------------------------------- 1 | package validation 2 | 3 | import "strings" 4 | 5 | Dashboard: { 6 | uid?: string & strings.MinRunes(1) 7 | id?: int & >0 8 | title: string & strings.MinRunes(1) 9 | tags: [...(string & strings.MinRunes(1))] 10 | labels: [string]: (string & strings.MinRunes(1)) 11 | panels: [...#Panel] 12 | } 13 | 14 | #Panel: { 15 | title: string & strings.MinRunes(1) 16 | } 17 | -------------------------------------------------------------------------------- /testdata/simplecue/arrays/schema.cue: -------------------------------------------------------------------------------- 1 | #refStruct: { 2 | things: string 3 | } 4 | 5 | struct: { 6 | things: string 7 | } 8 | 9 | container: { 10 | ints: [...int] 11 | strings: [...string] 12 | refs: [...#refStruct] 13 | structs: [...struct] 14 | arrayOfAnything: [...] 15 | } 16 | -------------------------------------------------------------------------------- /testdata/simplecue/common_timezone_disjunction/schema.cue: -------------------------------------------------------------------------------- 1 | package grafanatest 2 | 3 | // Use UTC/GMT timezone 4 | TimeZoneUtc: "utc" @cuetsy(kind="type") 5 | 6 | // Use the timezone defined by end user web browser 7 | TimeZoneBrowser: "browser" @cuetsy(kind="type") 8 | 9 | // A specific timezone from https://en.wikipedia.org/wiki/Tz_database 10 | TimeZone: TimeZoneUtc | TimeZoneBrowser | string | *"browser" @cuetsy(kind="type") 11 | 12 | // This should become an enum 13 | DisjunctionWithOnlyConcreteValues: "foo" | "bar" | "baz" 14 | -------------------------------------------------------------------------------- /testdata/simplecue/defaults/schema.cue: -------------------------------------------------------------------------------- 1 | StringEnum: "a" | "b" | "c" 2 | IntEnum: 1 | 2 | 3 @cog(kind="enum", memberNames="one|two|three") 3 | 4 | container: { 5 | from: string | *"now-6h" 6 | editable: bool | *true 7 | IntEnum: 0 | 1 | *2 @cog(kind="enum",memberNames="firstValue|secondValue|thirdValue") 8 | Number: int64 | *5 9 | repeatDirection: *"h" | "v" 10 | tags: [...string] | *["default", "tags"] 11 | stringEnum: StringEnum & (*"c" | _) 12 | intEnum: IntEnum & (*2 | _) 13 | } 14 | -------------------------------------------------------------------------------- /testdata/simplecue/defaults_on_struct/schema.cue: -------------------------------------------------------------------------------- 1 | Enum: "a" | "b" | "c" 2 | 3 | HeatmapColorOptions: { 4 | scheme: string 5 | fill: string 6 | exponent: float32 7 | min?: float32 8 | max?: float32 9 | enum: Enum 10 | } 11 | container: { 12 | color: HeatmapColorOptions | *{ 13 | scheme: "Oranges" 14 | fill: "dark-orange" 15 | enum: Enum & (*"b" | _) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/simplecue/disjunctions/schema.cue: -------------------------------------------------------------------------------- 1 | container: { 2 | text: string | [...string] 3 | listWithDifferentTypes: [...bool] | [...string] 4 | stringOrBool: string | false 5 | stringOrNull: string | null 6 | } 7 | -------------------------------------------------------------------------------- /testdata/simplecue/enums/schema.cue: -------------------------------------------------------------------------------- 1 | IntEnum: 0 | 1 | 2 @cog(kind="enum",memberNames="firstValue|secondValue|thirdValue") 2 | StringEnum: "foo" | "bar" | "baz" 3 | Operator: "<" | ">" 4 | -------------------------------------------------------------------------------- /testdata/simplecue/maps/schema.cue: -------------------------------------------------------------------------------- 1 | intStringMap: { 2 | [string]: int 3 | } 4 | stringStringMap: { 5 | [string]: string 6 | } 7 | #foo: { 8 | bar: string 9 | stringToAny: { 10 | [string]: _ 11 | } 12 | } 13 | stringRefMap: [string]: #foo 14 | stringToMapOfMap: [string]: {[string]: bool} 15 | 16 | incompleteObjectIsNotAMap: { 17 | foo: string 18 | ... 19 | } 20 | -------------------------------------------------------------------------------- /testdata/simplecue/nested_disjunctions/schema.cue: -------------------------------------------------------------------------------- 1 | HelloMsg: { 2 | type: "hello" 3 | salutation: string 4 | } 5 | 6 | ByeMsg: { 7 | type: "bye" 8 | reason: string 9 | } 10 | 11 | QuestionMsg: { 12 | type: "question" 13 | question: string 14 | } 15 | 16 | AnswerMsg: { 17 | type: "answer" 18 | content: string 19 | } 20 | 21 | ChitChat: HelloMsg | ByeMsg 22 | Message: ChitChat | QuestionMsg | AnswerMsg 23 | -------------------------------------------------------------------------------- /testdata/simplecue/numbers_constraints/schema.cue: -------------------------------------------------------------------------------- 1 | container: { 2 | constantInt: 42 3 | constantFloat: 42.24 4 | rowHeight: float & >=0 & <=1 5 | colWidth: float64 & <=1 6 | fiscalYearStartMonth: uint8 & <12 | *0 7 | } 8 | -------------------------------------------------------------------------------- /testdata/simplecue/refs/schema.cue: -------------------------------------------------------------------------------- 1 | #IntEnum: 0 | 1 | *2 @cog(kind="enum",memberNames="firstValue|secondValue|thirdValue") 2 | 3 | container: { 4 | StringEnum: "foo" | "bar" | "baz" 5 | TheIntEnum: #IntEnum 6 | 7 | #SomeInlineDefinition: { 8 | field: string 9 | } 10 | 11 | inline: #SomeInlineDefinition 12 | } 13 | -------------------------------------------------------------------------------- /testdata/simplecue/scalars/schema.cue: -------------------------------------------------------------------------------- 1 | container: { 2 | str: string 3 | trueOrFalse: bool 4 | anything: _ 5 | data: bytes 6 | 7 | num_unit8: uint8 8 | num_int8: int8 9 | num_uint16: uint16 10 | num_int16: int16 11 | num_uint32: uint32 12 | num_int32: int32 13 | num_uint64: uint64 14 | num_int64: int64 15 | } 16 | -------------------------------------------------------------------------------- /testdata/simplecue/strings_constraints/schema.cue: -------------------------------------------------------------------------------- 1 | import "strings" 2 | 3 | container: { 4 | minLengthConstraints: string & strings.MinRunes(1) 5 | maxLengthConstraints: string & strings.MaxRunes(64) 6 | minMaxLengthConstraints: string & strings.MinRunes(2) & strings.MaxRunes(8) 7 | } 8 | -------------------------------------------------------------------------------- /testdata/simplecue/time/schema.cue: -------------------------------------------------------------------------------- 1 | import "time" 2 | 3 | User: { 4 | registeredAt: string & time.Time 5 | subscribedAt: time.Time 6 | } 7 | -------------------------------------------------------------------------------- /testdata/simplecue/unifications/schema.cue: -------------------------------------------------------------------------------- 1 | #InlineScript: string | { 2 | inline?: string 3 | } 4 | 5 | #MetricAggregationWithInlineScript: { 6 | settings?: { 7 | script?: #InlineScript 8 | } 9 | } 10 | 11 | #Average: { 12 | #MetricAggregationWithInlineScript 13 | type: "avg" 14 | settings?: { 15 | script?: #InlineScript 16 | missing?: string 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "ts-node": { 3 | "compilerOptions": { 4 | "module": "commonjs" 5 | } 6 | } 7 | } 8 | --------------------------------------------------------------------------------