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,61 @@
|
|
1
|
+
module Foobara
|
2
|
+
module Enumerated
|
3
|
+
module Accessors
|
4
|
+
class ValueNotAllowed < StandardError; end
|
5
|
+
class CannotDetermineModuleAutomatically; end
|
6
|
+
|
7
|
+
include Concern
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def enumerated(attribute_name, values_source = nil)
|
11
|
+
original_values_source = values_source
|
12
|
+
|
13
|
+
if values_source.nil?
|
14
|
+
module_name = Util.classify(attribute_name)
|
15
|
+
|
16
|
+
values_source = begin
|
17
|
+
Util.const_get_up_hierarchy(self, module_name)
|
18
|
+
rescue NameError
|
19
|
+
# :nocov:
|
20
|
+
raise CannotDetermineModuleAutomatically,
|
21
|
+
"could not find a module for #{module_name}. Maybe consider passing it in explicitly."
|
22
|
+
# :nocov:
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
values = Values.new(values_source)
|
27
|
+
|
28
|
+
attribute_name = attribute_name.to_sym
|
29
|
+
|
30
|
+
# :nocov:
|
31
|
+
unless respond_to?(:enumerated_type_metadata)
|
32
|
+
# :nocov:
|
33
|
+
class << self
|
34
|
+
attr_accessor :enumerated_type_metadata
|
35
|
+
end
|
36
|
+
|
37
|
+
self.enumerated_type_metadata = {}
|
38
|
+
end
|
39
|
+
|
40
|
+
attr_reader attribute_name
|
41
|
+
|
42
|
+
define_method "#{attribute_name}=" do |value|
|
43
|
+
value = Values.normalize_value(value)
|
44
|
+
|
45
|
+
if !value.nil? && !values.all_values.include?(value)
|
46
|
+
raise ValueNotAllowed, "Received #{value} for #{attribute_name} but expected one of #{values.all_values}"
|
47
|
+
end
|
48
|
+
|
49
|
+
instance_variable_set("@#{attribute_name}", value)
|
50
|
+
end
|
51
|
+
|
52
|
+
enumerated_type_metadata[attribute_name] = {
|
53
|
+
original_values_source:,
|
54
|
+
values_source:,
|
55
|
+
values:
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module Foobara
|
2
|
+
module Enumerated
|
3
|
+
class Values
|
4
|
+
class BadNameType < ::StandardError; end
|
5
|
+
class BadValueType < ::StandardError; end
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def valid_value_type?(value)
|
9
|
+
value.is_a?(String) || value.is_a?(Symbol) || value.nil?
|
10
|
+
end
|
11
|
+
|
12
|
+
def valid_name_type?(value)
|
13
|
+
value.is_a?(String) || value.is_a?(Symbol)
|
14
|
+
end
|
15
|
+
|
16
|
+
def normalize_value(value)
|
17
|
+
unless Values.valid_value_type?(value)
|
18
|
+
# :nocov:
|
19
|
+
raise BadValueType, "Expected nil, String, or Symbol, but got #{value} which is a #{value.class}"
|
20
|
+
# :nocov:
|
21
|
+
end
|
22
|
+
|
23
|
+
value&.to_sym
|
24
|
+
end
|
25
|
+
|
26
|
+
def module_to_symbol_map(constants_module)
|
27
|
+
symbol_map = {}
|
28
|
+
|
29
|
+
constants_module.constants.each do |constant_name|
|
30
|
+
constant_value = constants_module.const_get(constant_name)
|
31
|
+
|
32
|
+
symbol_map[constant_name] = constant_value
|
33
|
+
end
|
34
|
+
|
35
|
+
symbol_map
|
36
|
+
end
|
37
|
+
|
38
|
+
def validate_symbol_map_types(symbol_map)
|
39
|
+
symbol_map.each_pair do |name, value|
|
40
|
+
unless valid_name_type?(name)
|
41
|
+
# :nocov:
|
42
|
+
raise BadNameType, "name is #{name} which is a #{name.class} but expected String, or Symbol"
|
43
|
+
# :nocov:
|
44
|
+
end
|
45
|
+
|
46
|
+
unless valid_value_type?(value)
|
47
|
+
# :nocov:
|
48
|
+
raise BadValueType, "#{
|
49
|
+
name
|
50
|
+
} is #{value} which is a #{value.class} but expected nil, String, or Symbol"
|
51
|
+
# :nocov:
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def normalize_symbol_map(symbol_map)
|
57
|
+
normalized = {}
|
58
|
+
|
59
|
+
symbol_map.each_pair do |name, value|
|
60
|
+
normalized[Util.constantify_sym(name)] = value&.to_sym
|
61
|
+
end
|
62
|
+
|
63
|
+
normalized.freeze
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def initialize(*args)
|
68
|
+
if args.empty?
|
69
|
+
# :nocov:
|
70
|
+
raise ArgumentError, "Expected Module, Hash, or Array"
|
71
|
+
# :nocov:
|
72
|
+
elsif args.size > 1
|
73
|
+
initialize(args)
|
74
|
+
else
|
75
|
+
symbol_map = args.first
|
76
|
+
|
77
|
+
case symbol_map
|
78
|
+
when ::Hash
|
79
|
+
Values.validate_symbol_map_types(symbol_map)
|
80
|
+
|
81
|
+
@symbol_map = Values.normalize_symbol_map(symbol_map)
|
82
|
+
when ::Module
|
83
|
+
initialize(Values.module_to_symbol_map(symbol_map))
|
84
|
+
when ::Array
|
85
|
+
initialize(symbol_map.to_h { |name| [name, name] })
|
86
|
+
else
|
87
|
+
# :nocov:
|
88
|
+
raise ArgumentError, "Expected Module, Hash, or Array"
|
89
|
+
# :nocov:
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def all
|
95
|
+
@symbol_map
|
96
|
+
end
|
97
|
+
|
98
|
+
def all_names
|
99
|
+
@symbol_map.keys
|
100
|
+
end
|
101
|
+
|
102
|
+
def all_values
|
103
|
+
@symbol_map.values
|
104
|
+
end
|
105
|
+
|
106
|
+
def method_missing(name)
|
107
|
+
unless respond_to_missing?(name)
|
108
|
+
# :nocov:
|
109
|
+
super
|
110
|
+
# :nocov:
|
111
|
+
end
|
112
|
+
|
113
|
+
@symbol_map[name]
|
114
|
+
end
|
115
|
+
|
116
|
+
def respond_to_missing?(name, _include_private = false)
|
117
|
+
@symbol_map.key?(name)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "foobara/util"
|
2
|
+
require "foobara/monorepo"
|
3
|
+
|
4
|
+
module Foobara
|
5
|
+
module All
|
6
|
+
# just makes Rubocop happy
|
7
|
+
# TODO: delete this and make Rubocop exception in .rubocop.yml
|
8
|
+
end
|
9
|
+
|
10
|
+
module Monorepo
|
11
|
+
# universal
|
12
|
+
project "version"
|
13
|
+
|
14
|
+
# could be independent projects
|
15
|
+
projects "delegate",
|
16
|
+
"concerns",
|
17
|
+
"thread_parent",
|
18
|
+
"weak_object_set",
|
19
|
+
"enumerated",
|
20
|
+
"callback",
|
21
|
+
"state_machine",
|
22
|
+
"namespace"
|
23
|
+
|
24
|
+
project "domain"
|
25
|
+
|
26
|
+
# various components of the foobara framework that have some level of coupling.
|
27
|
+
# for example, Error in common knows about (or could be implemented to know about)
|
28
|
+
# type declarations to expose its context type.
|
29
|
+
projects "common",
|
30
|
+
"value",
|
31
|
+
"types",
|
32
|
+
"type_declarations",
|
33
|
+
"builtin_types",
|
34
|
+
"model",
|
35
|
+
"entity",
|
36
|
+
"command",
|
37
|
+
"persistence",
|
38
|
+
"in_memory_crud_driver_minimal",
|
39
|
+
"in_memory_crud_driver",
|
40
|
+
"manifest"
|
41
|
+
|
42
|
+
install!
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
module Foobara::InMemoryCrudDriverMinimal; end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module Foobara
|
2
|
+
module Persistence
|
3
|
+
module CrudDrivers
|
4
|
+
class InMemoryMinimal < EntityAttributesCrudDriver
|
5
|
+
# TODO: delete
|
6
|
+
def open_connection(_connection_or_credentials)
|
7
|
+
# TODO: figure out what we expect here when there is no connection necessary
|
8
|
+
Object.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def open_transaction
|
12
|
+
# TODO: figure out what we expect here when there is no native transaction support
|
13
|
+
Object.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def close_transaction(_raw_tx)
|
17
|
+
# can't fail since there's no native transaction support...
|
18
|
+
end
|
19
|
+
|
20
|
+
def rollback_transaction(_raw_tx)
|
21
|
+
# nothing to do... except maybe enter a state where we don't flush anything else
|
22
|
+
# but can just rely on higher-up plumbing for that
|
23
|
+
end
|
24
|
+
|
25
|
+
class Table < EntityAttributesCrudDriver::Table
|
26
|
+
attr_accessor :records
|
27
|
+
|
28
|
+
def initialize(...)
|
29
|
+
@last_id = 0
|
30
|
+
self.records = {}
|
31
|
+
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_id
|
36
|
+
@last_id += 1
|
37
|
+
end
|
38
|
+
|
39
|
+
# CRUD
|
40
|
+
# TODO: all multiple record methods should return enumerators and code further up should only use
|
41
|
+
# the lazy enumerator interface... to encourage that/catch bugs we will return lazy enumerators in these
|
42
|
+
# built-in crud drivers
|
43
|
+
def all
|
44
|
+
records.each_value.lazy
|
45
|
+
end
|
46
|
+
|
47
|
+
def count
|
48
|
+
records.count
|
49
|
+
end
|
50
|
+
|
51
|
+
def find(record_id)
|
52
|
+
Util.deep_dup(records[record_id])
|
53
|
+
end
|
54
|
+
|
55
|
+
def find!(record_id)
|
56
|
+
attributes = find(record_id)
|
57
|
+
|
58
|
+
unless attributes
|
59
|
+
raise CannotFindError.new(record_id, "does not exist")
|
60
|
+
end
|
61
|
+
|
62
|
+
attributes
|
63
|
+
end
|
64
|
+
|
65
|
+
def insert(attributes)
|
66
|
+
attributes = Util.deep_dup(attributes)
|
67
|
+
|
68
|
+
record_id = record_id_for(attributes)
|
69
|
+
|
70
|
+
if record_id
|
71
|
+
if exists?(record_id)
|
72
|
+
raise CannotInsertError.new(record_id, "already exists")
|
73
|
+
end
|
74
|
+
else
|
75
|
+
record_id = get_id
|
76
|
+
attributes.merge!(primary_key_attribute => record_id)
|
77
|
+
end
|
78
|
+
|
79
|
+
records[record_id] = attributes
|
80
|
+
find(record_id)
|
81
|
+
end
|
82
|
+
|
83
|
+
def update(attributes)
|
84
|
+
record_id = record_id_for(attributes)
|
85
|
+
|
86
|
+
unless exists?(record_id)
|
87
|
+
# :nocov:
|
88
|
+
raise CannotUpdateError.new(record_id, "does not exist")
|
89
|
+
# :nocov:
|
90
|
+
end
|
91
|
+
|
92
|
+
records[record_id] = Util.deep_dup(attributes)
|
93
|
+
find(record_id)
|
94
|
+
end
|
95
|
+
|
96
|
+
def hard_delete(record_id)
|
97
|
+
unless exists?(record_id)
|
98
|
+
# :nocov:
|
99
|
+
raise CannotUpdateError.new(record_id, "does not exist")
|
100
|
+
# :nocov:
|
101
|
+
end
|
102
|
+
|
103
|
+
records.delete(record_id)
|
104
|
+
end
|
105
|
+
|
106
|
+
def hard_delete_all
|
107
|
+
self.records = {}
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative "type_declaration"
|
2
|
+
|
3
|
+
module Foobara
|
4
|
+
module Manifest
|
5
|
+
class Array < TypeDeclaration
|
6
|
+
alias array_manifest relevant_manifest
|
7
|
+
|
8
|
+
def element_type
|
9
|
+
@element_type ||= TypeDeclaration.new(root_manifest, [*path, :element_type_declaration])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative "type_declaration"
|
2
|
+
|
3
|
+
module Foobara
|
4
|
+
module Manifest
|
5
|
+
class Attributes < TypeDeclaration
|
6
|
+
optional_keys :required, :defaults
|
7
|
+
|
8
|
+
alias attributes_manifest relevant_manifest
|
9
|
+
|
10
|
+
def required?(attribute_name)
|
11
|
+
required = DataPath.value_at(:required, attributes_manifest)
|
12
|
+
|
13
|
+
if required
|
14
|
+
required.include?(attribute_name.to_sym) || required.include?(attribute_name.to_s)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_for(attribute_name)
|
19
|
+
DataPath.value_at([:defaults, attribute_name], attributes_manifest)
|
20
|
+
end
|
21
|
+
|
22
|
+
def attribute_declarations
|
23
|
+
element_type_declarations.keys.to_h do |attribute_name|
|
24
|
+
[
|
25
|
+
attribute_name.to_sym,
|
26
|
+
TypeDeclaration.new(root_manifest, [*path, :element_type_declarations, attribute_name])
|
27
|
+
]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def empty?
|
32
|
+
attribute_declarations.empty?
|
33
|
+
end
|
34
|
+
|
35
|
+
def attribute_names
|
36
|
+
attribute_declarations.keys.map(&:to_s)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
module Foobara
|
2
|
+
module Manifest
|
3
|
+
class InvalidPath < StandardError; end
|
4
|
+
|
5
|
+
class BaseManifest
|
6
|
+
include TruncatedInspect
|
7
|
+
|
8
|
+
attr_accessor :root_manifest, :path
|
9
|
+
|
10
|
+
class << self
|
11
|
+
attr_accessor :category_symbol
|
12
|
+
|
13
|
+
def optional_keys(*values, default: nil)
|
14
|
+
if values.empty?
|
15
|
+
@optional_keys ||= if superclass == Object
|
16
|
+
Set.new
|
17
|
+
else
|
18
|
+
superclass.optional_keys.dup
|
19
|
+
end
|
20
|
+
else
|
21
|
+
if default
|
22
|
+
default = default.freeze
|
23
|
+
end
|
24
|
+
|
25
|
+
values.each do |value|
|
26
|
+
value = value.to_sym
|
27
|
+
optional_keys << value
|
28
|
+
if default
|
29
|
+
optional_key_defaults[value] = default
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def optional_key_defaults
|
36
|
+
@optional_key_defaults ||= {}
|
37
|
+
end
|
38
|
+
|
39
|
+
def optional_key(value, default: nil)
|
40
|
+
optional_keys(value, default:)
|
41
|
+
end
|
42
|
+
|
43
|
+
def category_to_manifest_class(category_symbol)
|
44
|
+
category_symbol = category_symbol.to_sym
|
45
|
+
|
46
|
+
Util.descendants(BaseManifest).find do |manifest_class|
|
47
|
+
manifest_class.category_symbol == category_symbol
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def initialize(root_manifest, path)
|
53
|
+
self.root_manifest = root_manifest
|
54
|
+
self.path = path
|
55
|
+
|
56
|
+
if relevant_manifest.nil?
|
57
|
+
# :nocov:
|
58
|
+
raise InvalidPath, "invalid path #{path}"
|
59
|
+
# :nocov:
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def domain
|
64
|
+
domain_reference = self[:domain]
|
65
|
+
|
66
|
+
Domain.new(root_manifest, [:domain, domain_reference])
|
67
|
+
end
|
68
|
+
|
69
|
+
def organization
|
70
|
+
organization_reference = self[:organization]
|
71
|
+
|
72
|
+
Organization.new(root_manifest, [:organization, organization_reference])
|
73
|
+
end
|
74
|
+
|
75
|
+
def parent
|
76
|
+
if parent_category
|
77
|
+
parent_class = self.class.category_to_manifest_class(parent_category)
|
78
|
+
|
79
|
+
parent_class&.new(root_manifest, self[:parent])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def parent_category
|
84
|
+
self[:parent]&.first
|
85
|
+
end
|
86
|
+
|
87
|
+
def parent_name
|
88
|
+
self[:parent]&.last
|
89
|
+
end
|
90
|
+
|
91
|
+
def scoped_category
|
92
|
+
self[:scoped_category]
|
93
|
+
end
|
94
|
+
|
95
|
+
def relevant_manifest
|
96
|
+
@relevant_manifest ||= Foobara::DataPath.values_at(path, root_manifest).first
|
97
|
+
end
|
98
|
+
|
99
|
+
def find_type(type_declaration)
|
100
|
+
type_symbol = type_declaration.type
|
101
|
+
|
102
|
+
Type.new(root_manifest, [:type, type_symbol])
|
103
|
+
end
|
104
|
+
|
105
|
+
def global_domain
|
106
|
+
Domain.new(root_manifest, %i[domain global_organization::global_domain])
|
107
|
+
end
|
108
|
+
|
109
|
+
def global_organization
|
110
|
+
Organization.new(root_manifest, %i[organization global_organization])
|
111
|
+
end
|
112
|
+
|
113
|
+
def method_missing(method_name, *, &)
|
114
|
+
if key?(method_name)
|
115
|
+
self[method_name]
|
116
|
+
elsif optional_key?(method_name)
|
117
|
+
self.class.optional_key_defaults[method_name.to_sym]
|
118
|
+
else
|
119
|
+
# :nocov:
|
120
|
+
super
|
121
|
+
# :nocov:
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def [](method_name)
|
126
|
+
if relevant_manifest.key?(method_name.to_sym)
|
127
|
+
relevant_manifest[method_name.to_sym]
|
128
|
+
elsif relevant_manifest.key?(method_name.to_s)
|
129
|
+
relevant_manifest[method_name.to_s]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def key?(method_name)
|
134
|
+
relevant_manifest.key?(method_name.to_sym) || relevant_manifest.key?(method_name.to_s)
|
135
|
+
end
|
136
|
+
|
137
|
+
def optional_key?(key)
|
138
|
+
if key.is_a?(::Symbol) || key.is_a?(::String)
|
139
|
+
self.class.optional_keys.include?(key.to_sym)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def respond_to_missing?(method_name, include_private = false)
|
144
|
+
relevant_manifest.key?(method_name.to_sym) || relevant_manifest.key?(method_name.to_s) ||
|
145
|
+
optional_key?(method_name) || super
|
146
|
+
end
|
147
|
+
|
148
|
+
def ==(other)
|
149
|
+
other.class == self.class && other.path.map(&:to_sym) == path.map(&:to_sym)
|
150
|
+
end
|
151
|
+
|
152
|
+
def eql?(other)
|
153
|
+
self == other
|
154
|
+
end
|
155
|
+
|
156
|
+
def hash
|
157
|
+
[root_manifest, path.map(&:to_sym)].hash
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Foobara
|
2
|
+
module Manifest
|
3
|
+
class Command < BaseManifest
|
4
|
+
self.category_symbol = :command
|
5
|
+
|
6
|
+
def command_manifest
|
7
|
+
relevant_manifest
|
8
|
+
end
|
9
|
+
|
10
|
+
def command_name
|
11
|
+
scoped_short_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def full_command_name
|
15
|
+
scoped_full_name
|
16
|
+
end
|
17
|
+
|
18
|
+
def inputs_type
|
19
|
+
Attributes.new(root_manifest, [*path, :inputs_type])
|
20
|
+
end
|
21
|
+
|
22
|
+
def result_type
|
23
|
+
TypeDeclaration.new(root_manifest, [*path, :result_type])
|
24
|
+
rescue Foobara::Manifest::InvalidPath
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def possible_errors
|
29
|
+
super.keys.to_h do |key|
|
30
|
+
[key, PossibleError.new(root_manifest, [*path, :possible_errors, key])]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def types_depended_on
|
35
|
+
@types_depended_on ||= self[:types_depended_on].map do |type_reference|
|
36
|
+
Type.new(root_manifest, [:type, type_reference])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def inputs_types_depended_on
|
41
|
+
@inputs_types_depended_on ||= self[:inputs_types_depended_on].map do |type_reference|
|
42
|
+
Type.new(root_manifest, [:type, type_reference])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def result_types_depended_on
|
47
|
+
@result_types_depended_on ||= self[:result_types_depended_on].to_set do |type_reference|
|
48
|
+
Type.new(root_manifest, [:type, type_reference])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def errors_types_depended_on
|
53
|
+
@errors_types_depended_on ||= self[:errors_types_depended_on].to_set do |type_reference|
|
54
|
+
Type.new(root_manifest, [:type, type_reference])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Foobara
|
2
|
+
module Manifest
|
3
|
+
class Domain < BaseManifest
|
4
|
+
self.category_symbol = :domain
|
5
|
+
|
6
|
+
def domain_manifest
|
7
|
+
relevant_manifest
|
8
|
+
end
|
9
|
+
|
10
|
+
def commands
|
11
|
+
@commands ||= DataPath.value_at(:commands, domain_manifest).map do |key|
|
12
|
+
Command.new(root_manifest, [:command, key])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def types
|
17
|
+
@types ||= DataPath.value_at(:types, domain_manifest).map do |key|
|
18
|
+
Type.new(root_manifest, [:type, key])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def entities
|
23
|
+
@entities ||= types.select(&:entity?)
|
24
|
+
end
|
25
|
+
|
26
|
+
def models
|
27
|
+
@models ||= types.select(&:model?)
|
28
|
+
end
|
29
|
+
|
30
|
+
def global?
|
31
|
+
reference == "global_organization::global_domain"
|
32
|
+
end
|
33
|
+
|
34
|
+
def domain_name
|
35
|
+
scoped_name
|
36
|
+
end
|
37
|
+
|
38
|
+
def full_domain_name
|
39
|
+
scoped_full_name
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|