foobara 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +5 -0
- data/.rubocop.yml +20 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +10 -0
- data/DECISION_LOG.md +220 -0
- data/Guardfile +9 -0
- data/LICENSE-AGPL.txt +666 -0
- data/LICENSE.txt +4 -0
- data/README.md +50 -0
- data/Rakefile +10 -0
- data/concepts.md +153 -0
- data/projects/builtin_types/lib/foobara/builtin_types.rb +67 -0
- data/projects/builtin_types/src/README.md +140 -0
- data/projects/builtin_types/src/array/casters/arrayable.rb +22 -0
- data/projects/builtin_types/src/array/supported_processors/element_type_declaration.rb +41 -0
- data/projects/builtin_types/src/array/supported_validators/size.rb +43 -0
- data/projects/builtin_types/src/associative_array/casters/array.rb +22 -0
- data/projects/builtin_types/src/associative_array/supported_processors/key_type_declaration.rb +44 -0
- data/projects/builtin_types/src/associative_array/supported_processors/value_type_declaration.rb +44 -0
- data/projects/builtin_types/src/atomic_duck.rb +6 -0
- data/projects/builtin_types/src/attributes/casters/array.rb +33 -0
- data/projects/builtin_types/src/attributes/casters/hash.rb +28 -0
- data/projects/builtin_types/src/attributes/supported_processors/element_type_declarations.rb +89 -0
- data/projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/desugarizers/move_defaults_from_element_types_to_root.rb +40 -0
- data/projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/desugarizers/symbolize_defaults.rb +31 -0
- data/projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/hash_with_symbolic_keys.rb +37 -0
- data/projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/valid_attribute_names.rb +60 -0
- data/projects/builtin_types/src/attributes/supported_transformers/defaults.rb +41 -0
- data/projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/desugarizers/move_required_from_element_types_to_root.rb +55 -0
- data/projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/array_of_symbols.rb +47 -0
- data/projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/array_with_valid_attribute_names.rb +54 -0
- data/projects/builtin_types/src/attributes/supported_validators/required.rb +51 -0
- data/projects/builtin_types/src/big_decimal/casters/integer.rb +21 -0
- data/projects/builtin_types/src/big_decimal/casters/string.rb +24 -0
- data/projects/builtin_types/src/boolean/casters/numeric.rb +21 -0
- data/projects/builtin_types/src/boolean/casters/string_or_symbol.rb +27 -0
- data/projects/builtin_types/src/builtin_types.rb +189 -0
- data/projects/builtin_types/src/date/casters/hash.rb +23 -0
- data/projects/builtin_types/src/date/casters/string.rb +40 -0
- data/projects/builtin_types/src/datetime/casters/date.rb +21 -0
- data/projects/builtin_types/src/datetime/casters/hash.rb +77 -0
- data/projects/builtin_types/src/datetime/casters/seconds_since_epoch.rb +21 -0
- data/projects/builtin_types/src/datetime/casters/string.rb +31 -0
- data/projects/builtin_types/src/duck/supported_casters/allow_nil.rb +38 -0
- data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/class_desugarizer.rb +29 -0
- data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/instance_of_class_desugarizer.rb +31 -0
- data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/instance_of_symbol_desugarizer.rb +31 -0
- data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/type_declaration_validators/is_valid_class.rb +43 -0
- data/projects/builtin_types/src/duck/supported_validators/instance_of.rb +42 -0
- data/projects/builtin_types/src/duck/supported_validators/one_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/cast_one_of.rb +37 -0
- data/projects/builtin_types/src/duck/supported_validators/one_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/module_desugarizer.rb +41 -0
- data/projects/builtin_types/src/duck/supported_validators/one_of.rb +41 -0
- data/projects/builtin_types/src/duck.rb +6 -0
- data/projects/builtin_types/src/duckture.rb +6 -0
- data/projects/builtin_types/src/email/transformers/downcase.rb +15 -0
- data/projects/builtin_types/src/email/validator_base.rb +94 -0
- data/projects/builtin_types/src/float/casters/integer.rb +21 -0
- data/projects/builtin_types/src/float/casters/string.rb +24 -0
- data/projects/builtin_types/src/integer/casters/string.rb +23 -0
- data/projects/builtin_types/src/number/supported_validators/max.rb +41 -0
- data/projects/builtin_types/src/number/supported_validators/min.rb +41 -0
- data/projects/builtin_types/src/string/casters/numeric.rb +21 -0
- data/projects/builtin_types/src/string/casters/symbol.rb +21 -0
- data/projects/builtin_types/src/string/supported_transformers/downcase.rb +11 -0
- data/projects/builtin_types/src/string/supported_validators/matches.rb +41 -0
- data/projects/builtin_types/src/string/supported_validators/max_length.rb +37 -0
- data/projects/builtin_types/src/symbol/casters/string.rb +21 -0
- data/projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/desugarizers/set_size.rb +32 -0
- data/projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb +50 -0
- data/projects/builtin_types/src/tuple/supported_processors/element_type_declarations.rb +59 -0
- data/projects/callback/lib/foobara/callback.rb +1 -0
- data/projects/callback/src/block/after.rb +10 -0
- data/projects/callback/src/block/around.rb +10 -0
- data/projects/callback/src/block/before.rb +10 -0
- data/projects/callback/src/block/concerns/block_parameter_not_allowed.rb +21 -0
- data/projects/callback/src/block/concerns/block_parameter_required.rb +21 -0
- data/projects/callback/src/block/concerns/keyword_argumentable_block.rb +31 -0
- data/projects/callback/src/block/concerns/single_argument_block.rb +22 -0
- data/projects/callback/src/block/concerns/type.rb +17 -0
- data/projects/callback/src/block/error.rb +10 -0
- data/projects/callback/src/block.rb +83 -0
- data/projects/callback/src/registry/base.rb +90 -0
- data/projects/callback/src/registry/chained_conditioned.rb +24 -0
- data/projects/callback/src/registry/chained_multiple_action.rb +24 -0
- data/projects/callback/src/registry/conditioned.rb +101 -0
- data/projects/callback/src/registry/multiple_action.rb +110 -0
- data/projects/callback/src/registry/single_action.rb +15 -0
- data/projects/callback/src/runner.rb +89 -0
- data/projects/callback/src/set.rb +56 -0
- data/projects/command/lib/foobara/command.rb +9 -0
- data/projects/command/src/command/entity_helpers.rb +145 -0
- data/projects/command/src/command.rb +36 -0
- data/projects/command/src/concerns/callbacks.rb +93 -0
- data/projects/command/src/concerns/description.rb +23 -0
- data/projects/command/src/concerns/domain_mappers.rb +35 -0
- data/projects/command/src/concerns/entities.rb +88 -0
- data/projects/command/src/concerns/errors.rb +181 -0
- data/projects/command/src/concerns/errors_type.rb +124 -0
- data/projects/command/src/concerns/inputs.rb +59 -0
- data/projects/command/src/concerns/inputs_type.rb +58 -0
- data/projects/command/src/concerns/namespace.rb +49 -0
- data/projects/command/src/concerns/reflection.rb +137 -0
- data/projects/command/src/concerns/result.rb +25 -0
- data/projects/command/src/concerns/result_type.rb +29 -0
- data/projects/command/src/concerns/runtime.rb +119 -0
- data/projects/command/src/concerns/state_machine.rb +12 -0
- data/projects/command/src/concerns/subcommands.rb +102 -0
- data/projects/command/src/concerns/transactions.rb +81 -0
- data/projects/command/src/state_machine.rb +57 -0
- data/projects/command/src/transformed_command.rb +459 -0
- data/projects/command_connectors/lib/foobara/command_connectors.rb +12 -0
- data/projects/command_connectors/src/command_connector.rb +401 -0
- data/projects/command_connectors/src/command_registry/allowed_rule.rb +29 -0
- data/projects/command_connectors/src/command_registry/exposed_command.rb +140 -0
- data/projects/command_connectors/src/command_registry/exposed_domain.rb +30 -0
- data/projects/command_connectors/src/command_registry/exposed_organization.rb +30 -0
- data/projects/command_connectors/src/command_registry.rb +257 -0
- data/projects/command_connectors/src/commands/describe.rb +36 -0
- data/projects/command_connectors/src/commands/list_commands.rb +51 -0
- data/projects/command_connectors/src/commands/ping.rb +21 -0
- data/projects/command_connectors/src/commands/query_git_commit_info.rb +81 -0
- data/projects/command_connectors/src/request.rb +99 -0
- data/projects/command_connectors/src/response.rb +17 -0
- data/projects/command_connectors/src/serializer.rb +25 -0
- data/projects/command_connectors/src/serializers/aggregate_serializer.rb +32 -0
- data/projects/command_connectors/src/serializers/atomic_serializer.rb +25 -0
- data/projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb +28 -0
- data/projects/command_connectors/src/serializers/errors_serializer.rb +18 -0
- data/projects/command_connectors/src/serializers/json_serializer.rb +20 -0
- data/projects/command_connectors/src/serializers/noop_serializer.rb +20 -0
- data/projects/command_connectors/src/serializers/record_store_serializer.rb +31 -0
- data/projects/command_connectors/src/serializers/success_serializer.rb +14 -0
- data/projects/command_connectors/src/serializers/yaml_serializer.rb +20 -0
- data/projects/command_connectors/src/transformers/auth_errors_transformer.rb +35 -0
- data/projects/command_connectors/src/transformers/load_aggregates_pre_commit_transformer.rb +36 -0
- data/projects/command_connectors_http/lib/foobara/command_connectors_http.rb +6 -0
- data/projects/command_connectors_http/src/http/commands/get_options.rb +16 -0
- data/projects/command_connectors_http/src/http/commands/help/presenter/command.rb +14 -0
- data/projects/command_connectors_http/src/http/commands/help/presenter/domain.rb +14 -0
- data/projects/command_connectors_http/src/http/commands/help/presenter/entity.rb +14 -0
- data/projects/command_connectors_http/src/http/commands/help/presenter/error.rb +14 -0
- data/projects/command_connectors_http/src/http/commands/help/presenter/model.rb +14 -0
- data/projects/command_connectors_http/src/http/commands/help/presenter/organization.rb +14 -0
- data/projects/command_connectors_http/src/http/commands/help/presenter/processor.rb +14 -0
- data/projects/command_connectors_http/src/http/commands/help/presenter/processor_class.rb +14 -0
- data/projects/command_connectors_http/src/http/commands/help/presenter/root.rb +14 -0
- data/projects/command_connectors_http/src/http/commands/help/presenter/type.rb +14 -0
- data/projects/command_connectors_http/src/http/commands/help/presenter.rb +162 -0
- data/projects/command_connectors_http/src/http/commands/help/templates/command.html.erb +11 -0
- data/projects/command_connectors_http/src/http/commands/help/templates/domain.html.erb +1 -0
- data/projects/command_connectors_http/src/http/commands/help/templates/entity.html.erb +1 -0
- data/projects/command_connectors_http/src/http/commands/help/templates/error.html.erb +1 -0
- data/projects/command_connectors_http/src/http/commands/help/templates/model.html.erb +1 -0
- data/projects/command_connectors_http/src/http/commands/help/templates/organization.html.erb +1 -0
- data/projects/command_connectors_http/src/http/commands/help/templates/processor.html.erb +1 -0
- data/projects/command_connectors_http/src/http/commands/help/templates/processor_class.html.erb +1 -0
- data/projects/command_connectors_http/src/http/commands/help/templates/root.html.erb +3 -0
- data/projects/command_connectors_http/src/http/commands/help/templates/type.html.erb +1 -0
- data/projects/command_connectors_http/src/http/commands/help.rb +98 -0
- data/projects/command_connectors_http/src/http/request.rb +98 -0
- data/projects/command_connectors_http/src/http/response.rb +14 -0
- data/projects/command_connectors_http/src/http.rb +84 -0
- data/projects/common/lib/foobara/common.rb +11 -0
- data/projects/common/src/data_path.rb +272 -0
- data/projects/common/src/error.rb +215 -0
- data/projects/common/src/error_collection.rb +97 -0
- data/projects/common/src/error_key.rb +168 -0
- data/projects/common/src/outcome.rb +101 -0
- data/projects/common/src/possible_error.rb +80 -0
- data/projects/common/src/runtime_error.rb +24 -0
- data/projects/concerns/lib/foobara/concerns.rb +1 -0
- data/projects/concerns/src/concern.rb +93 -0
- data/projects/delegate/lib/foobara/delegate.rb +1 -0
- data/projects/delegate/src/extensions/module.rb +12 -0
- data/projects/domain/lib/foobara/domain.rb +25 -0
- data/projects/domain/src/domain.rb +65 -0
- data/projects/domain/src/domain_mapper/registry.rb +47 -0
- data/projects/domain/src/domain_mapper.rb +162 -0
- data/projects/domain/src/domain_module_extension.rb +510 -0
- data/projects/domain/src/extensions/foobara.rb +69 -0
- data/projects/domain/src/global_domain.rb +14 -0
- data/projects/domain/src/global_organization.rb +12 -0
- data/projects/domain/src/is_manifestable.rb +68 -0
- data/projects/domain/src/manifestable.rb +12 -0
- data/projects/domain/src/module_extension.rb +122 -0
- data/projects/domain/src/organization.rb +52 -0
- data/projects/domain/src/organization_module_extension.rb +50 -0
- data/projects/entity/lib/foobara/entity.rb +27 -0
- data/projects/entity/src/concerns/associations.rb +241 -0
- data/projects/entity/src/concerns/attributes.rb +170 -0
- data/projects/entity/src/concerns/callbacks.rb +97 -0
- data/projects/entity/src/concerns/initialization.rb +127 -0
- data/projects/entity/src/concerns/persistence.rb +142 -0
- data/projects/entity/src/concerns/primary_key.rb +43 -0
- data/projects/entity/src/concerns/queries.rb +96 -0
- data/projects/entity/src/concerns/reflection.rb +51 -0
- data/projects/entity/src/concerns/transactions.rb +31 -0
- data/projects/entity/src/concerns/types.rb +31 -0
- data/projects/entity/src/entity.rb +61 -0
- data/projects/entity/src/extensions/builtin_types/entity/casters/hash.rb +33 -0
- data/projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb +32 -0
- data/projects/entity/src/extensions/builtin_types/entity.rb +6 -0
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/attributes_handler_desugarizer.rb +14 -0
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/hash_desugarizer.rb +43 -0
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/model_class_desugarizer.rb +21 -0
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/primary_key_desugarizer.rb +19 -0
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/to_type_transformer.rb +64 -0
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_is_symbol.rb +35 -0
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_present.rb +27 -0
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_references_attribute.rb +36 -0
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration.rb +11 -0
- data/projects/entity/src/new_prepend.rb +21 -0
- data/projects/entity/src/not_found_error.rb +72 -0
- data/projects/enumerated/lib/foobara/enumerated.rb +1 -0
- data/projects/enumerated/src/accessors.rb +61 -0
- data/projects/enumerated/src/values.rb +121 -0
- data/projects/foobara/lib/foobara/all.rb +44 -0
- data/projects/in_memory_crud_driver/lib/foobara/in_memory_crud_driver.rb +3 -0
- data/projects/in_memory_crud_driver/src/in_memory.rb +10 -0
- data/projects/in_memory_crud_driver_minimal/lib/foobara/in_memory_crud_driver_minimal.rb +1 -0
- data/projects/in_memory_crud_driver_minimal/src/in_memory_minimal.rb +113 -0
- data/projects/manifest/lib/foobara/manifest.rb +4 -0
- data/projects/manifest/src/foobara/manifest/array.rb +13 -0
- data/projects/manifest/src/foobara/manifest/attributes.rb +40 -0
- data/projects/manifest/src/foobara/manifest/base_manifest.rb +161 -0
- data/projects/manifest/src/foobara/manifest/command.rb +59 -0
- data/projects/manifest/src/foobara/manifest/domain.rb +43 -0
- data/projects/manifest/src/foobara/manifest/entity.rb +35 -0
- data/projects/manifest/src/foobara/manifest/error.rb +33 -0
- data/projects/manifest/src/foobara/manifest/model.rb +43 -0
- data/projects/manifest/src/foobara/manifest/organization.rb +45 -0
- data/projects/manifest/src/foobara/manifest/possible_error.rb +30 -0
- data/projects/manifest/src/foobara/manifest/processor.rb +11 -0
- data/projects/manifest/src/foobara/manifest/processor_class.rb +11 -0
- data/projects/manifest/src/foobara/manifest/root_manifest.rb +112 -0
- data/projects/manifest/src/foobara/manifest/type.rb +86 -0
- data/projects/manifest/src/foobara/manifest/type_declaration.rb +117 -0
- data/projects/model/lib/foobara/model.rb +23 -0
- data/projects/model/src/concerns/reflection.rb +22 -0
- data/projects/model/src/concerns/types.rb +104 -0
- data/projects/model/src/extensions/builtin_types/model/casters/hash.rb +23 -0
- data/projects/model/src/extensions/builtin_types/model/transformers/mutable.rb +26 -0
- data/projects/model/src/extensions/builtin_types/model/validators/attributes_declaration.rb +33 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/attributes_handler_desugarizer.rb +24 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/hash_desugarizer.rb +32 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/model_class_desugarizer.rb +119 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/to_type_transformer.rb +57 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration.rb +21 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb +37 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/model_class_type_desugarizer.rb +25 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/mutable_validator.rb +46 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb +28 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/to_type_transformer.rb +27 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb +31 -0
- data/projects/model/src/extensions/type_declarations/handlers/registered_type_declaration/model_class_desugarizer.rb +23 -0
- data/projects/model/src/model.rb +320 -0
- data/projects/monorepo/lib/foobara/monorepo/project.rb +52 -0
- data/projects/monorepo/lib/foobara/monorepo.rb +63 -0
- data/projects/namespace/lib/foobara/namespace.rb +4 -0
- data/projects/namespace/src/ambiguous_registry.rb +104 -0
- data/projects/namespace/src/base_registry.rb +66 -0
- data/projects/namespace/src/extensions/module.rb +5 -0
- data/projects/namespace/src/is_namespace.rb +352 -0
- data/projects/namespace/src/namespace/lookup_mode.rb +41 -0
- data/projects/namespace/src/namespace.rb +61 -0
- data/projects/namespace/src/namespace_helpers.rb +273 -0
- data/projects/namespace/src/prefixless_registry.rb +54 -0
- data/projects/namespace/src/scoped.rb +113 -0
- data/projects/namespace/src/unambiguous_registry.rb +65 -0
- data/projects/persistence/lib/foobara/persistence.rb +22 -0
- data/projects/persistence/src/entity_attributes_crud_driver.rb +241 -0
- data/projects/persistence/src/entity_base/table.rb +14 -0
- data/projects/persistence/src/entity_base/transaction/concerns/entity_callback_handling.rb +157 -0
- data/projects/persistence/src/entity_base/transaction/concerns/state_transitions.rb +83 -0
- data/projects/persistence/src/entity_base/transaction/concerns/transaction_tracking.rb +53 -0
- data/projects/persistence/src/entity_base/transaction/state_machine.rb +27 -0
- data/projects/persistence/src/entity_base/transaction.rb +163 -0
- data/projects/persistence/src/entity_base/transaction_table/concerns/queries.rb +42 -0
- data/projects/persistence/src/entity_base/transaction_table/concerns/record_tracking.rb +134 -0
- data/projects/persistence/src/entity_base/transaction_table.rb +620 -0
- data/projects/persistence/src/entity_base.rb +114 -0
- data/projects/persistence/src/persistence.rb +172 -0
- data/projects/state_machine/lib/foobara/state_machine.rb +1 -0
- data/projects/state_machine/src/callbacks.rb +158 -0
- data/projects/state_machine/src/log_entry.rb +13 -0
- data/projects/state_machine/src/state_machine.rb +91 -0
- data/projects/state_machine/src/sugar.rb +125 -0
- data/projects/state_machine/src/transition_log.rb +19 -0
- data/projects/state_machine/src/validations.rb +69 -0
- data/projects/thread_parent/lib/foobara/thread_parent.rb +1 -0
- data/projects/thread_parent/src/thread_parent.rb +38 -0
- data/projects/type_declarations/lib/foobara/type_declarations.rb +131 -0
- data/projects/type_declarations/src/attributes.rb +34 -0
- data/projects/type_declarations/src/caster.rb +7 -0
- data/projects/type_declarations/src/desugarizer.rb +25 -0
- data/projects/type_declarations/src/dsl/attributes.rb +199 -0
- data/projects/type_declarations/src/element_processor.rb +7 -0
- data/projects/type_declarations/src/error_extension.rb +73 -0
- data/projects/type_declarations/src/handlers/extend_array_type_declaration/array_desugarizer.rb +31 -0
- data/projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb +37 -0
- data/projects/type_declarations/src/handlers/extend_array_type_declaration/to_type_transformer.rb +22 -0
- data/projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb +36 -0
- data/projects/type_declarations/src/handlers/extend_array_type_declaration.rb +14 -0
- data/projects/type_declarations/src/handlers/extend_associative_array_type_declaration/to_type_transformer.rb +28 -0
- data/projects/type_declarations/src/handlers/extend_associative_array_type_declaration.rb +20 -0
- data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/dsl_desugarizer.rb +25 -0
- data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/element_type_declarations_desugarizer.rb +34 -0
- data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/hash_desugarizer.rb +60 -0
- data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/to_type_transformer.rb +21 -0
- data/projects/type_declarations/src/handlers/extend_attributes_type_declaration.rb +16 -0
- data/projects/type_declarations/src/handlers/extend_registered_type_declaration/to_type_transformer.rb +75 -0
- data/projects/type_declarations/src/handlers/extend_registered_type_declaration.rb +23 -0
- data/projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb +30 -0
- data/projects/type_declarations/src/handlers/extend_tuple_type_declaration/to_type_transformer.rb +24 -0
- data/projects/type_declarations/src/handlers/extend_tuple_type_declaration.rb +13 -0
- data/projects/type_declarations/src/handlers/registered_type_declaration/desugarizer_metadata_cleanup_desugarizer.rb +29 -0
- data/projects/type_declarations/src/handlers/registered_type_declaration/short_type_name_desugarizer.rb +65 -0
- data/projects/type_declarations/src/handlers/registered_type_declaration/strict_desugarizer.rb +32 -0
- data/projects/type_declarations/src/handlers/registered_type_declaration/strict_stringified_desugarizer.rb +39 -0
- data/projects/type_declarations/src/handlers/registered_type_declaration/symbol_desugarizer.rb +26 -0
- data/projects/type_declarations/src/handlers/registered_type_declaration/to_type_transformer.rb +28 -0
- data/projects/type_declarations/src/handlers/registered_type_declaration/type_desugarizer.rb +24 -0
- data/projects/type_declarations/src/handlers/registered_type_declaration.rb +26 -0
- data/projects/type_declarations/src/processor.rb +7 -0
- data/projects/type_declarations/src/to_type_transformer.rb +11 -0
- data/projects/type_declarations/src/transformer.rb +7 -0
- data/projects/type_declarations/src/type_builder.rb +112 -0
- data/projects/type_declarations/src/type_declaration_error.rb +9 -0
- data/projects/type_declarations/src/type_declaration_handler.rb +120 -0
- data/projects/type_declarations/src/type_declaration_handler_registry.rb +27 -0
- data/projects/type_declarations/src/type_declaration_validator.rb +19 -0
- data/projects/type_declarations/src/type_declarations.rb +128 -0
- data/projects/type_declarations/src/typed_transformer.rb +89 -0
- data/projects/type_declarations/src/validator.rb +7 -0
- data/projects/type_declarations/src/with_registries.rb +41 -0
- data/projects/types/lib/foobara/types.rb +11 -0
- data/projects/types/src/element_processor.rb +7 -0
- data/projects/types/src/extensions/error.rb +32 -0
- data/projects/types/src/type/concerns/reflection.rb +79 -0
- data/projects/types/src/type/concerns/supported_processor_registration.rb +56 -0
- data/projects/types/src/type.rb +375 -0
- data/projects/types/src/types.rb +4 -0
- data/projects/value/lib/foobara/value.rb +7 -0
- data/projects/value/src/caster.rb +84 -0
- data/projects/value/src/data_error.rb +27 -0
- data/projects/value/src/processor/casting.rb +123 -0
- data/projects/value/src/processor/multi.rb +63 -0
- data/projects/value/src/processor/pipeline.rb +27 -0
- data/projects/value/src/processor/runner.rb +38 -0
- data/projects/value/src/processor/selection.rb +90 -0
- data/projects/value/src/processor.rb +358 -0
- data/projects/value/src/transformer.rb +84 -0
- data/projects/value/src/validator.rb +53 -0
- data/projects/version/lib/foobara/version.rb +4 -0
- data/projects/version/src/version.rb +5 -0
- data/projects/weak_object_set/lib/foobara/weak_object_set.rb +3 -0
- data/projects/weak_object_set/src/weak_object_set.rb +163 -0
- metadata +445 -0
@@ -0,0 +1,401 @@
|
|
1
|
+
module Foobara
|
2
|
+
class CommandConnector
|
3
|
+
class CommandConnectorError < Foobara::RuntimeError
|
4
|
+
class << self
|
5
|
+
def context_type_declaration
|
6
|
+
{}
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(message, context: {})
|
11
|
+
super(message:, context:)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class UnknownError < CommandConnectorError
|
16
|
+
attr_accessor :error
|
17
|
+
|
18
|
+
def initialize(error)
|
19
|
+
# TODO: can we just use #cause for this?
|
20
|
+
self.error = error
|
21
|
+
|
22
|
+
super(error.message)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class NotFoundError < CommandConnectorError
|
27
|
+
class << self
|
28
|
+
def context_type_declaration
|
29
|
+
{ not_found: :string }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
attr_accessor :not_found
|
34
|
+
|
35
|
+
def initialize(not_found)
|
36
|
+
self.not_found = not_found
|
37
|
+
|
38
|
+
super(message, context: { not_found: })
|
39
|
+
end
|
40
|
+
|
41
|
+
def message
|
42
|
+
"Not found: #{not_found}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class UnauthenticatedError < CommandConnectorError
|
47
|
+
def initialize
|
48
|
+
super("Unauthenticated")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class NotAllowedError < CommandConnectorError
|
53
|
+
class << self
|
54
|
+
def context_type_declaration
|
55
|
+
{
|
56
|
+
rule_symbol: :symbol,
|
57
|
+
explanation: :string
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
attr_accessor :rule_symbol, :explanation
|
63
|
+
|
64
|
+
def initialize(rule_symbol:, explanation:)
|
65
|
+
self.rule_symbol = rule_symbol || :no_symbol_declared
|
66
|
+
self.explanation = explanation || "No explanation"
|
67
|
+
|
68
|
+
super("Not allowed: #{explanation}", context:)
|
69
|
+
end
|
70
|
+
|
71
|
+
def context
|
72
|
+
{ rule_symbol:, explanation: }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class InvalidContextError < CommandConnectorError; end
|
77
|
+
class NoCommandFoundError < NotFoundError; end
|
78
|
+
class NoTypeFoundError < NotFoundError; end
|
79
|
+
class NoCommandOrTypeFoundError < NotFoundError; end
|
80
|
+
|
81
|
+
foobara_delegate :add_default_inputs_transformer,
|
82
|
+
:add_default_result_transformer,
|
83
|
+
:add_default_errors_transformer,
|
84
|
+
:add_default_pre_commit_transformer,
|
85
|
+
:add_default_serializer,
|
86
|
+
:allowed_rule,
|
87
|
+
:allowed_rules,
|
88
|
+
:transform_command_class,
|
89
|
+
:transformed_command_from_name,
|
90
|
+
:each_transformed_command_class,
|
91
|
+
:all_transformed_command_classes,
|
92
|
+
to: :command_registry
|
93
|
+
|
94
|
+
attr_accessor :command_registry, :authenticator
|
95
|
+
|
96
|
+
def lookup_command(name)
|
97
|
+
command_registry.foobara_lookup_command(name)
|
98
|
+
end
|
99
|
+
|
100
|
+
# TODO: maybe instead connect commands with a shortcut_only: "describe" option
|
101
|
+
# in order to make this easier to extend and manage.
|
102
|
+
def request_to_command(request)
|
103
|
+
action = request.action
|
104
|
+
inputs = nil
|
105
|
+
full_command_name = request.full_command_name
|
106
|
+
|
107
|
+
case action
|
108
|
+
when "run"
|
109
|
+
transformed_command_class = transformed_command_from_name(full_command_name)
|
110
|
+
|
111
|
+
unless transformed_command_class
|
112
|
+
# :nocov:
|
113
|
+
raise NoCommandFoundError, "Could not find command registered for #{full_command_name}"
|
114
|
+
# :nocov:
|
115
|
+
end
|
116
|
+
|
117
|
+
request.command_class = transformed_command_class
|
118
|
+
|
119
|
+
inputs = request.inputs
|
120
|
+
when "describe"
|
121
|
+
manifestable = transformed_command_from_name(full_command_name) || type_from_name(full_command_name)
|
122
|
+
|
123
|
+
unless manifestable
|
124
|
+
# :nocov:
|
125
|
+
raise NoCommandOrTypeFoundError, "Could not find command or type registered for #{full_command_name}"
|
126
|
+
# :nocov:
|
127
|
+
end
|
128
|
+
|
129
|
+
command_class = Foobara::CommandConnectors::Commands::Describe
|
130
|
+
full_command_name = command_class.full_command_name
|
131
|
+
|
132
|
+
inputs = { manifestable:, request: }
|
133
|
+
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
134
|
+
transform_command_class(command_class)
|
135
|
+
when "describe_command"
|
136
|
+
transformed_command_class = transformed_command_from_name(full_command_name)
|
137
|
+
|
138
|
+
unless transformed_command_class
|
139
|
+
# :nocov:
|
140
|
+
raise NoCommandFoundError, "Could not find command registered for #{full_command_name}"
|
141
|
+
# :nocov:
|
142
|
+
end
|
143
|
+
|
144
|
+
command_class = Foobara::CommandConnectors::Commands::Describe
|
145
|
+
full_command_name = command_class.full_command_name
|
146
|
+
|
147
|
+
inputs = { manifestable: transformed_command_class, request: }
|
148
|
+
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
149
|
+
transform_command_class(command_class)
|
150
|
+
when "describe_type"
|
151
|
+
type = type_from_name(full_command_name)
|
152
|
+
|
153
|
+
unless type
|
154
|
+
# :nocov:
|
155
|
+
raise NoTypeFoundError, "Could not find type registered for #{full_command_name}"
|
156
|
+
# :nocov:
|
157
|
+
end
|
158
|
+
|
159
|
+
command_class = Foobara::CommandConnectors::Commands::Describe
|
160
|
+
full_command_name = command_class.full_command_name
|
161
|
+
|
162
|
+
inputs = { manifestable: type, request: }
|
163
|
+
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
164
|
+
transform_command_class(command_class)
|
165
|
+
when "manifest"
|
166
|
+
command_class = Foobara::CommandConnectors::Commands::Describe
|
167
|
+
full_command_name = command_class.full_command_name
|
168
|
+
|
169
|
+
inputs = { manifestable: self, request: }
|
170
|
+
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
171
|
+
transform_command_class(command_class)
|
172
|
+
when "ping"
|
173
|
+
command_class = Foobara::CommandConnectors::Commands::Ping
|
174
|
+
full_command_name = command_class.full_command_name
|
175
|
+
|
176
|
+
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
177
|
+
transform_command_class(command_class)
|
178
|
+
when "query_git_commit_info"
|
179
|
+
# TODO: this feels out of control... should just accomplish this through run I think instead. Same with ping.
|
180
|
+
command_class = Foobara::CommandConnectors::Commands::QueryGitCommitInfo
|
181
|
+
full_command_name = command_class.full_command_name
|
182
|
+
|
183
|
+
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
184
|
+
transform_command_class(command_class)
|
185
|
+
when "help"
|
186
|
+
command_class = self.class::Commands::Help
|
187
|
+
full_command_name = command_class.full_command_name
|
188
|
+
|
189
|
+
inputs = { request: }
|
190
|
+
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
191
|
+
transform_command_class(command_class)
|
192
|
+
when "list"
|
193
|
+
mod = self.class::Commands
|
194
|
+
command_class = if mod.const_defined?(:ListCommands)
|
195
|
+
# TODO: test this
|
196
|
+
# :nocov:
|
197
|
+
mod::ListCommands
|
198
|
+
# :nocov:
|
199
|
+
else
|
200
|
+
CommandConnectors::Commands::ListCommands
|
201
|
+
end
|
202
|
+
|
203
|
+
full_command_name = command_class.full_command_name
|
204
|
+
|
205
|
+
request.command_class = command_class
|
206
|
+
inputs = request.inputs.merge(request:)
|
207
|
+
|
208
|
+
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
209
|
+
transform_command_class(command_class)
|
210
|
+
else
|
211
|
+
# :nocov:
|
212
|
+
raise InvalidContextError, "Not sure what to do with #{action}"
|
213
|
+
# :nocov:
|
214
|
+
end
|
215
|
+
|
216
|
+
if inputs && !inputs.empty?
|
217
|
+
transformed_command_class.new(inputs)
|
218
|
+
else
|
219
|
+
transformed_command_class.new
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# Feels like we should just register these if we're going to make use of them via "actions"...
|
224
|
+
# TODO: figure out how to kill this
|
225
|
+
def transform_command_class(klass)
|
226
|
+
command_registry.create_exposed_command_without_domain(klass).transformed_command_class
|
227
|
+
end
|
228
|
+
|
229
|
+
def request_to_response(_command)
|
230
|
+
# :nocov:
|
231
|
+
raise "subclass responsibility"
|
232
|
+
# :nocov:
|
233
|
+
end
|
234
|
+
|
235
|
+
def initialize(authenticator: nil, default_serializers: nil)
|
236
|
+
self.command_registry = CommandRegistry.new(authenticator:)
|
237
|
+
self.authenticator = authenticator
|
238
|
+
|
239
|
+
Util.array(default_serializers).each do |serializer|
|
240
|
+
add_default_serializer(serializer)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def connect(registerable, *, **)
|
245
|
+
case registerable
|
246
|
+
when Class
|
247
|
+
unless registerable < Command
|
248
|
+
# :nocov:
|
249
|
+
raise "Don't know how to register #{registerable} (#{registerable.class})"
|
250
|
+
# :nocov:
|
251
|
+
end
|
252
|
+
|
253
|
+
command_registry.register(registerable, *, **)
|
254
|
+
when Module
|
255
|
+
if registerable.foobara_organization?
|
256
|
+
registerable.foobara_domains.map do |domain|
|
257
|
+
connect(domain, *, **)
|
258
|
+
end.flatten
|
259
|
+
elsif registerable.foobara_domain?
|
260
|
+
registerable.foobara_all_command(mode: Namespace::LookupMode::DIRECT).map do |command_class|
|
261
|
+
Util.array(connect(command_class, *, **))
|
262
|
+
end.flatten
|
263
|
+
else
|
264
|
+
# :nocov:
|
265
|
+
raise "Don't know how to register #{registerable} (#{registerable.class})"
|
266
|
+
# :nocov:
|
267
|
+
end
|
268
|
+
else
|
269
|
+
# :nocov:
|
270
|
+
raise "Don't know how to register #{registerable} (#{registerable.class})"
|
271
|
+
# :nocov:
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
def build_request(...)
|
276
|
+
self.class::Request.new(...)
|
277
|
+
end
|
278
|
+
|
279
|
+
# TODO: maybe introduce a Runner interface?
|
280
|
+
def run(*, **)
|
281
|
+
request, command = build_request_and_command(*, **)
|
282
|
+
|
283
|
+
# TODO: feels like a smell
|
284
|
+
request.command_connector = self
|
285
|
+
|
286
|
+
if command
|
287
|
+
command.run
|
288
|
+
# :nocov:
|
289
|
+
elsif !request.error
|
290
|
+
raise "No command returned from #request_to_command"
|
291
|
+
# :nocov:
|
292
|
+
end
|
293
|
+
|
294
|
+
build_response(request)
|
295
|
+
end
|
296
|
+
|
297
|
+
def build_request_and_command(...)
|
298
|
+
request = build_request(...)
|
299
|
+
|
300
|
+
unless request.error
|
301
|
+
command = request_to_command(request)
|
302
|
+
request.command = command
|
303
|
+
end
|
304
|
+
|
305
|
+
[request, command]
|
306
|
+
end
|
307
|
+
|
308
|
+
def build_response(request)
|
309
|
+
response = request_to_response(request)
|
310
|
+
response.request = request
|
311
|
+
response
|
312
|
+
end
|
313
|
+
|
314
|
+
def type_from_name(name)
|
315
|
+
Foobara.foobara_lookup_type(name, mode: Namespace::LookupMode::RELAXED)
|
316
|
+
end
|
317
|
+
|
318
|
+
def foobara_manifest
|
319
|
+
# Drive all of this off of the list of exposed commands...
|
320
|
+
to_include = Set.new
|
321
|
+
to_include << command_registry.exposed_global_organization
|
322
|
+
to_include << command_registry.exposed_global_domain
|
323
|
+
|
324
|
+
command_registry.foobara_each do |exposed_whatever|
|
325
|
+
to_include << exposed_whatever
|
326
|
+
end
|
327
|
+
|
328
|
+
included = Set.new
|
329
|
+
additional_to_include = Set.new
|
330
|
+
|
331
|
+
h = {
|
332
|
+
organization: {},
|
333
|
+
domain: {},
|
334
|
+
type: {},
|
335
|
+
command: {},
|
336
|
+
error: {},
|
337
|
+
processor: {},
|
338
|
+
processor_class: {}
|
339
|
+
}
|
340
|
+
|
341
|
+
until to_include.empty? && additional_to_include.empty?
|
342
|
+
object = nil
|
343
|
+
|
344
|
+
if to_include.empty?
|
345
|
+
until additional_to_include.empty?
|
346
|
+
o = additional_to_include.first
|
347
|
+
additional_to_include.delete(o)
|
348
|
+
|
349
|
+
if o.is_a?(::Module)
|
350
|
+
if o.foobara_domain? || o.foobara_organization? || (o.is_a?(::Class) && o < Foobara::Command)
|
351
|
+
next
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
object = o
|
356
|
+
break
|
357
|
+
end
|
358
|
+
else
|
359
|
+
object = to_include.first
|
360
|
+
to_include.delete(object)
|
361
|
+
end
|
362
|
+
|
363
|
+
break unless object
|
364
|
+
next if included.include?(object)
|
365
|
+
|
366
|
+
manifest_reference = object.foobara_manifest_reference.to_sym
|
367
|
+
|
368
|
+
category_symbol = command_registry.foobara_category_symbol_for(object)
|
369
|
+
|
370
|
+
raise "no category symbol for #{object}" unless category_symbol
|
371
|
+
|
372
|
+
namespace = if object.is_a?(Types::Type)
|
373
|
+
object.created_in_namespace
|
374
|
+
else
|
375
|
+
Foobara::Namespace.current
|
376
|
+
end
|
377
|
+
|
378
|
+
cat = h[category_symbol] ||= {}
|
379
|
+
# TODO: do we really need to enter the namespace here for this?
|
380
|
+
cat[manifest_reference] = Foobara::Namespace.use namespace do
|
381
|
+
object.foobara_manifest(to_include: additional_to_include)
|
382
|
+
end
|
383
|
+
|
384
|
+
included << object
|
385
|
+
end
|
386
|
+
|
387
|
+
h[:domain].each_value do |domain_manifest|
|
388
|
+
# TODO: hack, we need to trim types down to what is actually included in this manifest
|
389
|
+
domain_manifest[:types] = domain_manifest[:types].select do |type_name|
|
390
|
+
h[:type].key?(type_name.to_sym)
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
h.sort.to_h
|
395
|
+
end
|
396
|
+
|
397
|
+
def all_exposed_commands
|
398
|
+
command_registry.foobara_all_command
|
399
|
+
end
|
400
|
+
end
|
401
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Foobara
|
2
|
+
# TODO: move to foobara monorepo if this is generic...
|
3
|
+
class CommandRegistry
|
4
|
+
class AllowedRule
|
5
|
+
class << self
|
6
|
+
def allowed_rule_attributes_type
|
7
|
+
@allowed_rule_attributes_type ||= GlobalDomain.foobara_type_from_declaration(
|
8
|
+
symbol: :symbol,
|
9
|
+
# TODO: add a function type and a way to union two types so that we can string or function type checking
|
10
|
+
explanation: :duck,
|
11
|
+
logic: :duck
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_accessor :block, :explanation, :symbol
|
17
|
+
|
18
|
+
def initialize(symbol: nil, explanation: nil, &block)
|
19
|
+
self.symbol = symbol
|
20
|
+
self.block = block
|
21
|
+
self.explanation = explanation || symbol
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_proc
|
25
|
+
block
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
module Foobara
|
2
|
+
class CommandRegistry
|
3
|
+
class ExposedCommand
|
4
|
+
include Scoped
|
5
|
+
include IsManifestable
|
6
|
+
include TruncatedInspect
|
7
|
+
|
8
|
+
attr_accessor :command_class,
|
9
|
+
:capture_unknown_error,
|
10
|
+
:inputs_transformers,
|
11
|
+
:result_transformers,
|
12
|
+
:errors_transformers,
|
13
|
+
:pre_commit_transformers,
|
14
|
+
:serializers,
|
15
|
+
:allowed_rule,
|
16
|
+
:requires_authentication,
|
17
|
+
:authenticator,
|
18
|
+
:scoped_path,
|
19
|
+
:scoped_namespace
|
20
|
+
|
21
|
+
def initialize(
|
22
|
+
command_class,
|
23
|
+
scoped_path: nil,
|
24
|
+
suffix: nil,
|
25
|
+
capture_unknown_error: nil,
|
26
|
+
inputs_transformers: nil,
|
27
|
+
result_transformers: nil,
|
28
|
+
errors_transformers: nil,
|
29
|
+
pre_commit_transformers: nil,
|
30
|
+
serializers: nil,
|
31
|
+
allowed_rule: nil,
|
32
|
+
requires_authentication: nil,
|
33
|
+
authenticator: nil,
|
34
|
+
aggregate_entities: nil,
|
35
|
+
atomic_entities: nil
|
36
|
+
)
|
37
|
+
if requires_authentication || allowed_rule
|
38
|
+
errors_transformers = [
|
39
|
+
*errors_transformers,
|
40
|
+
Foobara::CommandConnectors::Transformers::AuthErrorsTransformer
|
41
|
+
].uniq
|
42
|
+
end
|
43
|
+
|
44
|
+
scoped_path ||= if suffix
|
45
|
+
*prefix, short = command_class.scoped_path
|
46
|
+
[*prefix, "#{short}#{suffix}"]
|
47
|
+
else
|
48
|
+
command_class.scoped_path
|
49
|
+
end
|
50
|
+
|
51
|
+
if aggregate_entities
|
52
|
+
pre_commit_transformers = [
|
53
|
+
*pre_commit_transformers,
|
54
|
+
Foobara::CommandConnectors::Transformers::LoadAggregatesPreCommitTransformer
|
55
|
+
].uniq
|
56
|
+
serializers = [
|
57
|
+
*serializers,
|
58
|
+
Foobara::CommandConnectors::Serializers::AggregateSerializer
|
59
|
+
].uniq
|
60
|
+
# TODO: either both should have special behavior for false or neither should
|
61
|
+
elsif aggregate_entities == false
|
62
|
+
pre_commit_transformers = pre_commit_transformers&.reject do |t|
|
63
|
+
t == Foobara::CommandConnectors::Transformers::LoadAggregatesPreCommitTransformer
|
64
|
+
end
|
65
|
+
serializers = serializers&.reject do |s|
|
66
|
+
s == Foobara::CommandConnectors::Serializers::AggregateSerializer
|
67
|
+
end
|
68
|
+
elsif atomic_entities
|
69
|
+
serializers = [*serializers, Foobara::CommandConnectors::Serializers::AtomicSerializer].uniq
|
70
|
+
end
|
71
|
+
|
72
|
+
self.command_class = command_class
|
73
|
+
self.scoped_path = scoped_path
|
74
|
+
self.capture_unknown_error = capture_unknown_error
|
75
|
+
self.inputs_transformers = inputs_transformers
|
76
|
+
self.result_transformers = result_transformers
|
77
|
+
self.errors_transformers = errors_transformers
|
78
|
+
self.pre_commit_transformers = pre_commit_transformers
|
79
|
+
self.serializers = serializers
|
80
|
+
self.allowed_rule = allowed_rule
|
81
|
+
self.requires_authentication = requires_authentication
|
82
|
+
self.authenticator = authenticator
|
83
|
+
end
|
84
|
+
|
85
|
+
def full_command_name
|
86
|
+
scoped_full_name
|
87
|
+
end
|
88
|
+
|
89
|
+
def command_name
|
90
|
+
@command_name ||= Util.non_full_name(full_command_name)
|
91
|
+
end
|
92
|
+
|
93
|
+
def full_command_symbol
|
94
|
+
@full_command_symbol ||= Util.underscore_sym(full_command_name)
|
95
|
+
end
|
96
|
+
|
97
|
+
def foobara_manifest(to_include:)
|
98
|
+
transformed_command_class.foobara_manifest(to_include:).merge(super).merge(
|
99
|
+
Util.remove_blank(
|
100
|
+
scoped_category: :command,
|
101
|
+
domain: command_class.domain.foobara_manifest_reference,
|
102
|
+
organization: command_class.organization.foobara_manifest_reference
|
103
|
+
)
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
def transformed_command_class
|
108
|
+
@transformed_command_class ||= if Util.all_blank_or_false?(
|
109
|
+
[
|
110
|
+
inputs_transformers,
|
111
|
+
result_transformers,
|
112
|
+
errors_transformers,
|
113
|
+
pre_commit_transformers,
|
114
|
+
serializers,
|
115
|
+
allowed_rule,
|
116
|
+
requires_authentication,
|
117
|
+
authenticator
|
118
|
+
]
|
119
|
+
) && scoped_path == command_class.scoped_path
|
120
|
+
command_class
|
121
|
+
else
|
122
|
+
Foobara::TransformedCommand.subclass(
|
123
|
+
command_class,
|
124
|
+
full_command_name:,
|
125
|
+
command_name:,
|
126
|
+
capture_unknown_error:,
|
127
|
+
inputs_transformers:,
|
128
|
+
result_transformers:,
|
129
|
+
errors_transformers:,
|
130
|
+
pre_commit_transformers:,
|
131
|
+
serializers:,
|
132
|
+
allowed_rule:,
|
133
|
+
requires_authentication:,
|
134
|
+
authenticator:
|
135
|
+
)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Foobara
|
2
|
+
class CommandRegistry
|
3
|
+
class ExposedDomain
|
4
|
+
foobara_instances_are_namespaces!
|
5
|
+
|
6
|
+
include TruncatedInspect
|
7
|
+
include IsManifestable
|
8
|
+
|
9
|
+
attr_accessor :domain_module
|
10
|
+
|
11
|
+
def initialize(domain_module)
|
12
|
+
self.domain_module = domain_module
|
13
|
+
self.scoped_path = domain_module.scoped_path
|
14
|
+
end
|
15
|
+
|
16
|
+
# TODO: unable to address types here so it is handled as a hack higher up...
|
17
|
+
def foobara_manifest(to_include:)
|
18
|
+
domain_manifest = domain_module.foobara_manifest(to_include: Set.new)
|
19
|
+
mode = Foobara::Namespace::LookupMode::DIRECT
|
20
|
+
commands = foobara_all_command(mode:).map(&:foobara_manifest_reference).sort
|
21
|
+
|
22
|
+
domain_manifest.merge(commands:)
|
23
|
+
end
|
24
|
+
|
25
|
+
def foobara_manifest_reference
|
26
|
+
domain_module.foobara_manifest_reference
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Foobara
|
2
|
+
class CommandRegistry
|
3
|
+
class ExposedOrganization
|
4
|
+
foobara_instances_are_namespaces!
|
5
|
+
|
6
|
+
include TruncatedInspect
|
7
|
+
include IsManifestable
|
8
|
+
|
9
|
+
attr_accessor :organization_module
|
10
|
+
|
11
|
+
def initialize(organization_module)
|
12
|
+
self.organization_module = organization_module
|
13
|
+
self.scoped_path = organization_module.scoped_path
|
14
|
+
end
|
15
|
+
|
16
|
+
# TODO: unable to address types here so it is handled as a hack higher up...
|
17
|
+
def foobara_manifest(to_include:)
|
18
|
+
organization_manifest = organization_module.foobara_manifest(to_include: Set.new)
|
19
|
+
mode = Foobara::Namespace::LookupMode::DIRECT
|
20
|
+
domains = foobara_all_domain(mode:).map(&:foobara_manifest_reference).sort
|
21
|
+
|
22
|
+
organization_manifest.merge(domains:)
|
23
|
+
end
|
24
|
+
|
25
|
+
def foobara_manifest_reference
|
26
|
+
organization_module.foobara_manifest_reference
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|