foobara 0.5.10 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of foobara might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +13 -0
- data/lib/foobara/all.rb +4 -2
- data/projects/command/src/command_pattern_implementation/concerns/command_data.rb +3 -3
- data/projects/command/src/command_pattern_implementation/concerns/domain_mappers.rb +2 -2
- data/projects/command/src/command_pattern_implementation/concerns/errors.rb +27 -27
- data/projects/command/src/command_pattern_implementation/concerns/errors_type.rb +7 -11
- data/projects/command/src/command_pattern_implementation/concerns/inputs.rb +4 -24
- data/projects/command/src/command_pattern_implementation/concerns/inputs_type.rb +9 -14
- data/projects/command/src/command_pattern_implementation/concerns/reflection.rb +7 -20
- data/projects/command/src/command_pattern_implementation/concerns/runtime.rb +3 -48
- data/projects/command/src/command_pattern_implementation/concerns/subcommands.rb +5 -5
- data/projects/command/src/command_pattern_implementation.rb +0 -1
- data/projects/command_connectors/lib/foobara/command_connectors.rb +1 -1
- data/projects/command_connectors/spec/command_connector_spec.rb +63 -4
- data/projects/command_connectors/spec/spec_helper.rb +1 -1
- data/projects/command_connectors/src/command_connector/concerns/desugarizers.rb +5 -5
- data/projects/command_connectors/src/command_connector/concerns/reflection.rb +4 -4
- data/projects/command_connectors/src/command_connector/request.rb +26 -10
- data/projects/command_connectors/src/command_connector/response.rb +2 -0
- data/projects/command_connectors/src/command_connector.rb +62 -58
- data/projects/command_connectors/src/command_registry/exposed_command.rb +7 -2
- data/projects/command_connectors/src/command_registry.rb +15 -15
- data/projects/command_connectors/src/desugarizer.rb +2 -2
- data/projects/command_connectors/src/desugarizers/attributes.rb +8 -8
- data/projects/command_connectors/src/desugarizers/auth.rb +1 -1
- data/projects/command_connectors/src/desugarizers/set_inputs.rb +3 -3
- data/projects/command_connectors/src/desugarizers/symbols_to_true.rb +2 -2
- data/projects/command_connectors/src/request_mutator.rb +6 -6
- data/projects/command_connectors/src/response_mutator.rb +6 -6
- data/projects/command_connectors/src/transformed_command.rb +39 -36
- data/projects/command_connectors/src/transformers/auth_errors_transformer.rb +2 -2
- data/projects/command_connectors/src/transformers/entity_to_primary_key_inputs_transformer.rb +2 -2
- data/projects/command_connectors/src/transformers/load_delegated_attributes_entities_pre_commit_transformer.rb +1 -1
- data/projects/domain_mapper/src/domain_mapper.rb +4 -4
- data/projects/domain_mapper/src/domain_mapper_lookups.rb +3 -3
- data/projects/entities/projects/detached_entity/lib/foobara/detached_entity.rb +1 -1
- data/projects/entities/projects/detached_entity/src/concerns/associations.rb +18 -18
- data/projects/entities/projects/detached_entity/src/concerns/initialization.rb +2 -2
- data/projects/entities/projects/detached_entity/src/concerns/primary_key.rb +4 -4
- data/projects/entities/projects/detached_entity/src/concerns/types.rb +2 -2
- data/projects/entities/projects/detached_entity/src/detached_entity_type.rb +4 -4
- data/projects/entities/projects/detached_entity/src/extensions/builtin_types/detached_entity/casters/primary_key.rb +1 -1
- data/projects/entities/projects/detached_entity/src/extensions/builtin_types/detached_entity/validators/model_instance_is_valid.rb +2 -2
- data/projects/entities/projects/detached_entity/src/extensions/type_declarations/handlers/registered_type_declaration/validate_primary_key_present.rb +30 -0
- data/projects/entities/projects/detached_entity/src/remove_sensitive_values_transformer_extensions.rb +2 -2
- data/projects/entities/projects/entity/lib/foobara/entity.rb +1 -1
- data/projects/entities/projects/entity/src/concerns/attributes.rb +6 -6
- data/projects/entities/projects/entity/src/concerns/callbacks.rb +1 -1
- data/projects/entities/projects/entity/src/concerns/initialization.rb +8 -8
- data/projects/entities/projects/entity/src/concerns/mutations.rb +4 -4
- data/projects/entities/projects/entity/src/concerns/persistence.rb +3 -3
- data/projects/entities/projects/entity/src/concerns/queries.rb +7 -7
- data/projects/entities/projects/entity/src/extensions/domain/domain_module_extension.rb +4 -4
- data/projects/entities/projects/entity/src/new_prepend.rb +2 -2
- data/projects/entities/projects/entity/src/not_found_error.rb +8 -8
- data/projects/entities/projects/entity/src/sensitive_value_removers/entity.rb +8 -5
- data/projects/entities/projects/in_memory_crud_driver_minimal/src/in_memory_minimal.rb +4 -4
- data/projects/entities/projects/model_attribute_helpers/lib/foobara/model_attribute_helpers.rb +0 -2
- data/projects/entities/projects/model_attribute_helpers/src/attribute_helper_aliases.rb +1 -1
- data/projects/entities/projects/model_attribute_helpers/src/attribute_helpers.rb +2 -2
- data/projects/entities/projects/nested_transactionable/lib/foobara/nested_transactionable.rb +5 -5
- data/projects/entities/projects/persistence/lib/foobara/persistence.rb +1 -1
- data/projects/entities/projects/persistence/src/entity_attributes_crud_driver.rb +35 -37
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/entity_callback_handling.rb +25 -25
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/state_transitions.rb +8 -8
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/transaction_tracking.rb +1 -1
- data/projects/entities/projects/persistence/src/entity_base/transaction.rb +9 -9
- data/projects/entities/projects/persistence/src/entity_base/transaction_table/concerns/record_tracking.rb +4 -4
- data/projects/entities/projects/persistence/src/entity_base/transaction_table.rb +52 -52
- data/projects/entities/projects/persistence/src/entity_base.rb +7 -7
- data/projects/entities/projects/persistence/src/persistence.rb +23 -23
- data/projects/entities/projects/weak_object_set/src/weak_object_set.rb +16 -16
- data/projects/entities/spec/builtin_types/detached_entity_spec.rb +1 -1
- data/projects/entities/spec/builtin_types/entity_spec.rb +1 -1
- data/projects/entities/spec/builtin_types/model_spec.rb +1 -1
- data/projects/entities/spec/entity/extending_existing_spec.rb +1 -1
- data/projects/entities/spec/entity/from_type_declaration_spec.rb +1 -1
- data/projects/entities/spec/model/model_spec.rb +2 -2
- data/projects/entities/spec/spec_helper.rb +1 -1
- data/projects/entities_plumbing/lib/foobara/entities_plumbing.rb +6 -2
- data/projects/entities_plumbing/spec/inputs_spec.rb +54 -0
- data/projects/entities_plumbing/spec/spec_helper.rb +1 -1
- data/projects/entities_plumbing/spec/transaction_spec.rb +2 -2
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entities.rb +21 -5
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_errors_type.rb +23 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_inputs.rb +33 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_reflection.rb +39 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/runtime.rb +39 -0
- data/projects/manifest/spec/spec_helper.rb +1 -1
- data/projects/manifest/src/base_manifest.rb +9 -9
- data/projects/manifest/src/model.rb +4 -4
- data/projects/manifest/src/type.rb +3 -3
- data/projects/manifest/src/type_declaration.rb +4 -4
- data/projects/model_plumbing/lib/foobara/model_plumbing.rb +2 -0
- data/projects/model_plumbing/src/extensions/command_pattern_implementation/concerns/model_inputs_type.rb +35 -0
- data/projects/typesystem/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_asc.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_asc_disabled.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_both.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_desc.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_desc_disabled.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/application.css +1 -0
- data/projects/typesystem/coverage/assets/0.13.2/application.js +7 -0
- data/projects/typesystem/coverage/assets/0.13.2/colorbox/border.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/colorbox/controls.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/colorbox/loading.gif +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/colorbox/loading_background.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/favicon_green.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/favicon_red.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/favicon_yellow.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-icons_222222_256x240.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-icons_2e83ff_256x240.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-icons_454545_256x240.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-icons_888888_256x240.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/loading.gif +0 -0
- data/projects/typesystem/coverage/assets/0.13.2/magnify.png +0 -0
- data/projects/typesystem/coverage/index.html +215756 -0
- data/projects/typesystem/projects/builtin_types/lib/foobara/builtin_types.rb +1 -1
- data/projects/typesystem/projects/builtin_types/src/builtin_types.rb +8 -8
- data/projects/typesystem/projects/builtin_types/src/duck/supported_validators/one_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/module_desugarizer.rb +2 -2
- data/projects/typesystem/projects/builtin_types/src/email/validator_base.rb +4 -4
- data/projects/typesystem/projects/callback/src/block/concerns/block_parameter_required.rb +2 -2
- data/projects/typesystem/projects/callback/src/block/concerns/keyword_argumentable_block.rb +2 -2
- data/projects/typesystem/projects/callback/src/block/concerns/single_argument_block.rb +2 -2
- data/projects/typesystem/projects/callback/src/block.rb +4 -4
- data/projects/typesystem/projects/callback/src/registry/base.rb +10 -10
- data/projects/typesystem/projects/callback/src/registry/conditioned.rb +2 -2
- data/projects/typesystem/projects/callback/src/registry/multiple_action.rb +6 -6
- data/projects/typesystem/projects/callback/src/runner.rb +4 -4
- data/projects/typesystem/projects/callback/src/set.rb +4 -4
- data/projects/typesystem/projects/common/src/data_path.rb +14 -14
- data/projects/typesystem/projects/common/src/error.rb +11 -11
- data/projects/typesystem/projects/common/src/error_collection.rb +14 -14
- data/projects/typesystem/projects/common/src/error_key.rb +5 -3
- data/projects/typesystem/projects/common/src/outcome.rb +5 -5
- data/projects/typesystem/projects/common/src/possible_error.rb +2 -2
- data/projects/typesystem/projects/concerns/src/concern.rb +3 -3
- data/projects/typesystem/projects/delegate/src/extensions/module.rb +4 -4
- data/projects/typesystem/projects/domain/lib/foobara/domain.rb +2 -2
- data/projects/typesystem/projects/domain/src/domain.rb +5 -5
- data/projects/typesystem/projects/domain/src/domain_module_extension.rb +22 -22
- data/projects/typesystem/projects/domain/src/extensions/foobara.rb +6 -6
- data/projects/typesystem/projects/domain/src/module_extension.rb +4 -4
- data/projects/typesystem/projects/domain/src/organization.rb +6 -6
- data/projects/typesystem/projects/enumerated/src/accessors.rb +4 -4
- data/projects/typesystem/projects/enumerated/src/values.rb +14 -14
- data/projects/{entities → typesystem}/projects/model/lib/foobara/model.rb +1 -1
- data/projects/{entities → typesystem}/projects/model/src/concerns/classes.rb +4 -4
- data/projects/{entities → typesystem}/projects/model/src/concerns/types.rb +5 -5
- data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/casters/hash.rb +1 -1
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/attributes_handler_desugarizer.rb +2 -2
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/model_class_desugarizer.rb +6 -6
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/to_type_transformer.rb +4 -4
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb +2 -2
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/registered_type_declaration/model_class_desugarizer.rb +6 -10
- data/projects/{entities → typesystem}/projects/model/src/model.rb +13 -13
- data/projects/{entities → typesystem}/projects/model/src/sensitive_value_removers/model.rb +1 -1
- data/projects/typesystem/projects/namespace/src/ambiguous_registry.rb +5 -5
- data/projects/typesystem/projects/namespace/src/base_registry.rb +8 -8
- data/projects/typesystem/projects/namespace/src/is_namespace.rb +19 -19
- data/projects/typesystem/projects/namespace/src/namespace/lookup_mode.rb +2 -2
- data/projects/typesystem/projects/namespace/src/namespace.rb +5 -5
- data/projects/typesystem/projects/namespace/src/namespace_helpers.rb +4 -4
- data/projects/typesystem/projects/namespace/src/prefixless_registry.rb +3 -3
- data/projects/typesystem/projects/namespace/src/scoped.rb +7 -7
- data/projects/typesystem/projects/project/src/foobara.rb +13 -7
- data/projects/typesystem/projects/project/src/project.rb +1 -1
- data/projects/typesystem/projects/state_machine/src/callbacks.rb +14 -14
- data/projects/typesystem/projects/state_machine/src/state_machine.rb +2 -2
- data/projects/typesystem/projects/state_machine/src/sugar.rb +3 -3
- data/projects/typesystem/projects/type_declarations/lib/foobara/type_declarations.rb +1 -1
- data/projects/typesystem/projects/type_declarations/src/attributes.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/from_yaml.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/reject.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/set.rb +4 -4
- data/projects/typesystem/projects/type_declarations/src/desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/dsl/attributes.rb +9 -9
- data/projects/typesystem/projects/type_declarations/src/error_extension.rb +6 -6
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/array_desugarizer.rb +3 -3
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_attributes_type_declaration/element_type_declarations_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_registered_type_declaration/to_type_transformer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_registered_type_declaration.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/registered_type_declaration.rb +4 -3
- data/projects/typesystem/projects/type_declarations/src/remove_sensitive_values_transformer.rb +3 -3
- data/projects/typesystem/projects/type_declarations/src/type_builder.rb +5 -5
- data/projects/typesystem/projects/type_declarations/src/type_declaration.rb +7 -1
- data/projects/typesystem/projects/type_declarations/src/type_declaration_handler.rb +13 -13
- data/projects/typesystem/projects/type_declarations/src/type_declaration_handler_registry.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/type_declaration_validator.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/type_declarations.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/with_registries.rb +2 -2
- data/projects/typesystem/projects/types/src/extensions/error.rb +5 -5
- data/projects/typesystem/projects/types/src/type/concerns/reflection.rb +22 -22
- data/projects/typesystem/projects/types/src/type/concerns/supported_processor_registration.rb +4 -4
- data/projects/typesystem/projects/types/src/type.rb +25 -25
- data/projects/typesystem/projects/value/src/caster.rb +11 -11
- data/projects/typesystem/projects/value/src/data_error.rb +1 -1
- data/projects/typesystem/projects/value/src/mutator.rb +3 -3
- data/projects/typesystem/projects/value/src/processor/casting.rb +6 -6
- data/projects/typesystem/projects/value/src/processor/pipeline.rb +2 -2
- data/projects/typesystem/projects/value/src/processor/runner.rb +1 -1
- data/projects/typesystem/projects/value/src/processor/selection.rb +3 -3
- data/projects/typesystem/projects/value/src/processor.rb +23 -23
- data/projects/typesystem/projects/value/src/transformer.rb +5 -5
- data/projects/typesystem/projects/value/src/validator.rb +3 -3
- data/projects/typesystem/spec/builtin_types/custom_type_spec.rb +2 -2
- data/projects/typesystem/spec/builtin_types/instance_of_spec.rb +1 -1
- data/projects/typesystem/spec/foobara/foobara_spec.rb +18 -8
- data/projects/typesystem/spec/namespace/foobara_simulation_spec.rb +1 -1
- data/projects/typesystem/spec/spec_helper.rb +1 -1
- data/projects/typesystem/spec/state_machine/callbacks_spec.rb +1 -1
- data/projects/typesystem/spec/value/caster_spec.rb +1 -1
- data/version.rb +2 -2
- metadata +75 -35
- /data/projects/{command/src → entities_plumbing/src/extensions}/command_pattern_implementation/concerns/transactions.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/concerns/aliases.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/concerns/reflection.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/supported_transformers/mutable.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/validators/model_instance_is_valid.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/array_with_symbolic_elements.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_validator.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/hash_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/move_private_from_element_types_to_root.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/symbolize_private.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/valid_attribute_names.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/model_class_type_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/mutable_validator.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/to_type_transformer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/lazy_element_types/model.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/sensitive_type_removers/extended_model.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/sensitive_type_removers/model.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7e94765634a72f087a3a71aeebdde58025a8a7d605658c9f16389a423a6792cb
|
|
4
|
+
data.tar.gz: 208864692b0d7fff0f40a2b5cfdf10aa45ea0af67ca1f60876fb9f4455ab66cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9496fc386e0b3c0bc170dfb57a60728f28c936e79b2da5dcd91ff89c719f6986d787e4da7b1fb085d85b16402812d2788ff7e519435ae0bce1e351361ee05159
|
|
7
|
+
data.tar.gz: e5f1911f7cca2da95ebd8d48c2367e67bee640cbee9c27e5666d34afdbe50d1284701238e5a47d1e600fae0188cb894dcd647a6cf45f2d6dd84af24f3c5efbe7
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4.0.6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# [0.6.0] - 2026-08-06
|
|
2
|
+
|
|
3
|
+
- Give a way to authenticate if possible without requiring it (:authentication_optional)
|
|
4
|
+
- Convert NotFoundError into a data error
|
|
5
|
+
- Progress on getting closer to decoupling persistence
|
|
6
|
+
- Raise an error if non-attributes-like type is used for inputs
|
|
7
|
+
- Improve error message when using an entity that has no primary key as a type
|
|
8
|
+
- Support concept of a type declaration being claimed but errored
|
|
9
|
+
- Combine some entities cache-busting code
|
|
10
|
+
- Move model project out of entities project and into typesystem
|
|
11
|
+
- Raise with NotImplementedError where applicable instead of StandardError
|
|
12
|
+
- Simplify raise_if_production! interface
|
|
13
|
+
|
|
1
14
|
# [0.5.10] - 2026-04-17
|
|
2
15
|
|
|
3
16
|
- Add a ignore_unexpected_attributes transformer to builtin attributes type
|
data/lib/foobara/all.rb
CHANGED
|
@@ -16,14 +16,16 @@ module Foobara
|
|
|
16
16
|
require "foobara/builtin_types"
|
|
17
17
|
require "foobara/domain"
|
|
18
18
|
require "foobara/command"
|
|
19
|
+
require "foobara/domain_mapper"
|
|
20
|
+
require "foobara/manifest"
|
|
21
|
+
|
|
19
22
|
# TODO: make it so these are fully decoupled, optional, and not required here
|
|
20
23
|
require "foobara/model_attribute_helpers"
|
|
21
24
|
require "foobara/model_plumbing"
|
|
25
|
+
|
|
22
26
|
require "foobara/entities_plumbing"
|
|
23
27
|
# Shouldn't this be optional? Maybe use autoload feature somehow?
|
|
24
28
|
require "foobara/in_memory_crud_driver"
|
|
25
|
-
require "foobara/domain_mapper"
|
|
26
|
-
require "foobara/manifest"
|
|
27
29
|
|
|
28
30
|
install!
|
|
29
31
|
end
|
|
@@ -9,11 +9,11 @@ module Foobara
|
|
|
9
9
|
if args.empty?
|
|
10
10
|
@description
|
|
11
11
|
elsif args.size == 1
|
|
12
|
-
@description = args
|
|
12
|
+
@description = args[0]
|
|
13
13
|
else
|
|
14
|
-
# :
|
|
14
|
+
# simplecov:disable
|
|
15
15
|
raise ArgumentError, "wrong number of arguments (#{args.size} for 0 or 1)"
|
|
16
|
-
# :
|
|
16
|
+
# simplecov:enable
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -63,9 +63,9 @@ module Foobara
|
|
|
63
63
|
|
|
64
64
|
def run_mapped_subcommand!(subcommand_class, unmapped_inputs = {}, to = nil)
|
|
65
65
|
unless subcommand_class
|
|
66
|
-
# :
|
|
66
|
+
# simplecov:disable
|
|
67
67
|
raise ArgumentError, "subcommand_class is required"
|
|
68
|
-
# :
|
|
68
|
+
# simplecov:enable
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
mapped_something = false
|
|
@@ -10,9 +10,9 @@ module Foobara
|
|
|
10
10
|
key = key.to_s_type
|
|
11
11
|
|
|
12
12
|
unless error_context_type_map.key?(key)
|
|
13
|
-
# :
|
|
13
|
+
# simplecov:disable
|
|
14
14
|
raise "No error class was registered for #{key}"
|
|
15
|
-
# :
|
|
15
|
+
# simplecov:enable
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
error_context_type_map[key].error_class
|
|
@@ -23,9 +23,9 @@ module Foobara
|
|
|
23
23
|
key = key.to_s_type
|
|
24
24
|
|
|
25
25
|
unless error_context_type_map.key?(key)
|
|
26
|
-
# :
|
|
26
|
+
# simplecov:disable
|
|
27
27
|
raise "No error class was registered for #{key}"
|
|
28
|
-
# :
|
|
28
|
+
# simplecov:enable
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
error_context_type_map[key].error_class
|
|
@@ -37,9 +37,9 @@ module Foobara
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
unless error_context_type_map.key?(key)
|
|
40
|
-
# :
|
|
40
|
+
# simplecov:disable
|
|
41
41
|
raise "No error class was registered for #{key}"
|
|
42
|
-
# :
|
|
42
|
+
# simplecov:enable
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
error_context_type_map[key].error_class
|
|
@@ -66,32 +66,32 @@ module Foobara
|
|
|
66
66
|
|
|
67
67
|
def add_input_error(*args, **opts)
|
|
68
68
|
error = if args.size == 1 && opts.empty?
|
|
69
|
-
error = args
|
|
69
|
+
error = args[0]
|
|
70
70
|
|
|
71
71
|
unless error.is_a?(Value::DataError)
|
|
72
|
-
# :
|
|
72
|
+
# simplecov:disable
|
|
73
73
|
raise ArgumentError, "expected an DataError or keyword arguments to construct one"
|
|
74
|
-
# :
|
|
74
|
+
# simplecov:enable
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
error
|
|
78
|
-
elsif args.empty? || (args.size == 1 && args.
|
|
79
|
-
error_args = opts.merge(args
|
|
78
|
+
elsif args.empty? || (args.size == 1 && args[0].is_a?(Hash))
|
|
79
|
+
error_args = opts.merge(args[0] || {})
|
|
80
80
|
symbol = error_args[:symbol]
|
|
81
81
|
path = error_args[:input] || error_args[:path]
|
|
82
82
|
|
|
83
83
|
error_args = error_args.except(:input)
|
|
84
84
|
|
|
85
85
|
unless symbol
|
|
86
|
-
# :
|
|
86
|
+
# simplecov:disable
|
|
87
87
|
raise ArgumentError, "missing error symbol"
|
|
88
|
-
# :
|
|
88
|
+
# simplecov:enable
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
unless path
|
|
92
|
-
# :
|
|
92
|
+
# simplecov:disable
|
|
93
93
|
raise ArgumentError, "missing input"
|
|
94
|
-
# :
|
|
94
|
+
# simplecov:enable
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
error_class = self.class.lookup_input_error_class(symbol, path)
|
|
@@ -109,10 +109,10 @@ module Foobara
|
|
|
109
109
|
|
|
110
110
|
error_class.new(path: input, symbol:, context:, message:)
|
|
111
111
|
else
|
|
112
|
-
# :
|
|
112
|
+
# simplecov:disable
|
|
113
113
|
raise ArgumentError,
|
|
114
114
|
"Invalid arguments given. Expected an error or args for an error"
|
|
115
|
-
# :
|
|
115
|
+
# simplecov:enable
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
add_error(error)
|
|
@@ -126,30 +126,30 @@ module Foobara
|
|
|
126
126
|
|
|
127
127
|
def add_runtime_error(*args, halt: true, **opts)
|
|
128
128
|
error = if args.size == 1 && opts.empty? && (
|
|
129
|
-
args.
|
|
129
|
+
args[0].is_a?(::Class) || args[0].is_a?(Foobara::RuntimeError)
|
|
130
130
|
)
|
|
131
|
-
error = args
|
|
131
|
+
error = args[0]
|
|
132
132
|
|
|
133
133
|
if error.is_a?(::Class) && error < Foobara::RuntimeError
|
|
134
134
|
error = error.new
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
unless error.is_a?(Foobara::RuntimeError)
|
|
138
|
-
# :
|
|
138
|
+
# simplecov:disable
|
|
139
139
|
raise ArgumentError,
|
|
140
140
|
"expected a Foobara::RuntimeError or keyword arguments to construct one"
|
|
141
|
-
# :
|
|
141
|
+
# simplecov:enable
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
error
|
|
145
|
-
elsif args.empty? || (args.size == 1 && args.
|
|
146
|
-
error_args = opts.merge(args
|
|
145
|
+
elsif args.empty? || (args.size == 1 && args[0].is_a?(Hash))
|
|
146
|
+
error_args = opts.merge(args[0] || {})
|
|
147
147
|
symbol = error_args[:symbol]
|
|
148
148
|
|
|
149
149
|
unless symbol
|
|
150
|
-
# :
|
|
150
|
+
# simplecov:disable
|
|
151
151
|
raise ArgumentError, "missing error symbol"
|
|
152
|
-
# :
|
|
152
|
+
# simplecov:enable
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
error_class = self.class.lookup_runtime_error_class(symbol)
|
|
@@ -161,9 +161,9 @@ module Foobara
|
|
|
161
161
|
error_class = self.class.lookup_runtime_error_class(symbol)
|
|
162
162
|
error_class.new(symbol:, context:, message:)
|
|
163
163
|
else
|
|
164
|
-
# :
|
|
164
|
+
# simplecov:disable
|
|
165
165
|
raise ArgumentError, "Invalid arguments given. Expected an error or args/opts to build error"
|
|
166
|
-
# :
|
|
166
|
+
# simplecov:enable
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
add_error(error)
|
|
@@ -26,22 +26,22 @@ module Foobara
|
|
|
26
26
|
def possible_error(*args)
|
|
27
27
|
possible_error = case args.size
|
|
28
28
|
when 1
|
|
29
|
-
arg = args
|
|
29
|
+
arg = args[0]
|
|
30
30
|
|
|
31
31
|
if arg.is_a?(PossibleError)
|
|
32
32
|
# TODO: test this code path
|
|
33
|
-
# :
|
|
33
|
+
# simplecov:disable
|
|
34
34
|
arg
|
|
35
|
-
# :
|
|
35
|
+
# simplecov:enable
|
|
36
36
|
elsif arg.is_a?(::Class) && arg < Foobara::Error
|
|
37
37
|
PossibleError.new(arg)
|
|
38
38
|
elsif arg.is_a?(::Symbol)
|
|
39
39
|
error_class = Foobara::RuntimeError.subclass(mod: self, symbol: arg)
|
|
40
40
|
PossibleError.new(error_class, symbol: arg)
|
|
41
41
|
else
|
|
42
|
-
# :
|
|
42
|
+
# simplecov:disable
|
|
43
43
|
raise ArgumentError, "Expected a PossibleError or an Error but got #{arg}"
|
|
44
|
-
# :
|
|
44
|
+
# simplecov:enable
|
|
45
45
|
end
|
|
46
46
|
when 2
|
|
47
47
|
symbol, subclass_parameters, data = args
|
|
@@ -54,9 +54,9 @@ module Foobara
|
|
|
54
54
|
|
|
55
55
|
PossibleError.new(error_class, symbol:, data:)
|
|
56
56
|
else
|
|
57
|
-
# :
|
|
57
|
+
# simplecov:disable
|
|
58
58
|
raise ArgumentError, "Expected an error or a symbol and error context type declaration"
|
|
59
|
-
# :
|
|
59
|
+
# simplecov:enable
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
register_possible_error_class(possible_error)
|
|
@@ -111,10 +111,6 @@ module Foobara
|
|
|
111
111
|
map
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
inputs_association_paths&.each do |data_path|
|
|
115
|
-
possible_input_error(data_path.to_sym, CommandPatternImplementation::NotFoundError)
|
|
116
|
-
end
|
|
117
|
-
|
|
118
114
|
@error_context_type_map
|
|
119
115
|
end
|
|
120
116
|
|
|
@@ -6,26 +6,6 @@ module Foobara
|
|
|
6
6
|
|
|
7
7
|
include Concern
|
|
8
8
|
|
|
9
|
-
module ClassMethods
|
|
10
|
-
def inputs_association_paths
|
|
11
|
-
return @inputs_association_paths if defined?(@inputs_association_paths)
|
|
12
|
-
|
|
13
|
-
@inputs_association_paths = if inputs_type.nil?
|
|
14
|
-
nil
|
|
15
|
-
else
|
|
16
|
-
keys = Entity.construct_associations(inputs_type).keys
|
|
17
|
-
|
|
18
|
-
if keys.empty?
|
|
19
|
-
nil
|
|
20
|
-
else
|
|
21
|
-
keys.map do |key|
|
|
22
|
-
DataPath.new(key)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
9
|
attr_reader :inputs, :raw_inputs
|
|
30
10
|
|
|
31
11
|
def initialize(inputs = {})
|
|
@@ -37,9 +17,9 @@ module Foobara
|
|
|
37
17
|
if respond_to_missing_for_inputs?(method_name)
|
|
38
18
|
inputs[method_name]
|
|
39
19
|
else
|
|
40
|
-
# :
|
|
20
|
+
# simplecov:disable
|
|
41
21
|
super
|
|
42
|
-
# :
|
|
22
|
+
# simplecov:enable
|
|
43
23
|
end
|
|
44
24
|
end
|
|
45
25
|
|
|
@@ -66,9 +46,9 @@ module Foobara
|
|
|
66
46
|
if error.is_a?(Value::DataError)
|
|
67
47
|
add_input_error(error)
|
|
68
48
|
else
|
|
69
|
-
# :
|
|
49
|
+
# simplecov:disable
|
|
70
50
|
raise UnexpectedInputValidationError, "Unexpected input validation error: #{error}"
|
|
71
|
-
# :
|
|
51
|
+
# simplecov:enable
|
|
72
52
|
end
|
|
73
53
|
end
|
|
74
54
|
end
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
module Foobara
|
|
2
2
|
module CommandPatternImplementation
|
|
3
|
+
class BadCommandInputsError < StandardError; end
|
|
4
|
+
|
|
3
5
|
module Concerns
|
|
4
6
|
module InputsType
|
|
5
7
|
include Concern
|
|
6
8
|
|
|
7
9
|
module ClassMethods
|
|
8
10
|
def inputs(...)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
old_inputs_type&.possible_errors&.each do |possible_error|
|
|
12
|
-
unregister_possible_error_if_registered(possible_error)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
if defined?(@inputs_association_paths)
|
|
16
|
-
remove_instance_variable(:@inputs_association_paths)
|
|
17
|
-
end
|
|
11
|
+
type = type_for_declaration(...)
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
unless type.extends?(BuiltinTypes[:attributes])
|
|
14
|
+
raise BadCommandInputsError, "Expected attributes or something unambiguously convertable to attributes " \
|
|
15
|
+
"but got #{type}"
|
|
21
16
|
end
|
|
22
17
|
|
|
23
|
-
|
|
18
|
+
old_inputs_type = inputs_type
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
old_inputs_type&.possible_errors&.each do |possible_error|
|
|
21
|
+
unregister_possible_error_if_registered(possible_error)
|
|
27
22
|
end
|
|
28
23
|
|
|
29
24
|
@inputs_type = type
|
|
@@ -88,28 +88,15 @@ module Foobara
|
|
|
88
88
|
remove_sensitive = TypeDeclarations.foobara_manifest_context_remove_sensitive?
|
|
89
89
|
|
|
90
90
|
if defined?(@types_depended_on) && @types_depended_on.key?(remove_sensitive)
|
|
91
|
+
# simplecov:disable
|
|
91
92
|
return @types_depended_on[remove_sensitive]
|
|
93
|
+
# simplecov:enable
|
|
92
94
|
end
|
|
93
95
|
|
|
94
96
|
@types_depended_on ||= {}
|
|
95
|
-
@types_depended_on[remove_sensitive] =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
errors_types_depended_on
|
|
99
|
-
|
|
100
|
-
unless depends_on_entities.empty?
|
|
101
|
-
entity_types = depends_on_entities.map(&:entity_type)
|
|
102
|
-
|
|
103
|
-
if remove_sensitive
|
|
104
|
-
entity_types = entity_types.reject(&:sensitive?)
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
types |= entity_types
|
|
108
|
-
types |= entity_types.map(&:types_depended_on).inject(:|)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
types
|
|
112
|
-
end
|
|
97
|
+
@types_depended_on[remove_sensitive] = inputs_types_depended_on |
|
|
98
|
+
result_types_depended_on |
|
|
99
|
+
errors_types_depended_on
|
|
113
100
|
end
|
|
114
101
|
|
|
115
102
|
def inputs_types_depended_on
|
|
@@ -124,13 +111,13 @@ module Foobara
|
|
|
124
111
|
if inputs_type.registered?
|
|
125
112
|
# TODO: if we ever change from attributes-only inputs type
|
|
126
113
|
# then this will be handy
|
|
127
|
-
# :
|
|
114
|
+
# simplecov:disable
|
|
128
115
|
if !remove_sensitive || !inputs_type.sensitive?
|
|
129
116
|
Set[inputs_type]
|
|
130
117
|
else
|
|
131
118
|
Set.new
|
|
132
119
|
end
|
|
133
|
-
# :
|
|
120
|
+
# simplecov:enable
|
|
134
121
|
else
|
|
135
122
|
inputs_type.types_depended_on
|
|
136
123
|
end
|
|
@@ -7,13 +7,6 @@ module Foobara
|
|
|
7
7
|
class CannotHaltWithoutAddingErrors < StandardError; end
|
|
8
8
|
class Halt < StandardError; end
|
|
9
9
|
|
|
10
|
-
class NotFoundError < Foobara::DataError
|
|
11
|
-
context do
|
|
12
|
-
entity_class :string, :required
|
|
13
|
-
criteria :duck
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
10
|
module ClassMethods
|
|
18
11
|
def run(...)
|
|
19
12
|
new(...).run
|
|
@@ -54,10 +47,10 @@ module Foobara
|
|
|
54
47
|
return outcome if state_machine.currently_errored?
|
|
55
48
|
|
|
56
49
|
if error_collection.empty?
|
|
57
|
-
# :
|
|
50
|
+
# simplecov:disable
|
|
58
51
|
raise CannotHaltWithoutAddingErrors, "Cannot halt without adding errors first. " \
|
|
59
52
|
"Either add errors or use error! transition instead."
|
|
60
|
-
# :
|
|
53
|
+
# simplecov:enable
|
|
61
54
|
end
|
|
62
55
|
|
|
63
56
|
state_machine.fail!
|
|
@@ -93,44 +86,6 @@ module Foobara
|
|
|
93
86
|
# noop but for now helpful for carrying out state transition
|
|
94
87
|
end
|
|
95
88
|
|
|
96
|
-
def validate_records
|
|
97
|
-
self.class.inputs_association_paths&.each do |data_path|
|
|
98
|
-
if data_path.last == :"#"
|
|
99
|
-
records = data_path.values_at(@inputs)
|
|
100
|
-
|
|
101
|
-
records.each.with_index do |record, index|
|
|
102
|
-
if record&.persisted? && !record.loaded?
|
|
103
|
-
begin
|
|
104
|
-
record.class.load(record)
|
|
105
|
-
rescue Foobara::Entity::NotFoundError => e
|
|
106
|
-
add_input_error(
|
|
107
|
-
[*data_path.path[..-2], index],
|
|
108
|
-
CommandPatternImplementation::NotFoundError,
|
|
109
|
-
criteria: e.criteria,
|
|
110
|
-
entity_class: record.class.model_type.scoped_full_name
|
|
111
|
-
)
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
else
|
|
116
|
-
record = data_path.value_at(@inputs)
|
|
117
|
-
|
|
118
|
-
if record&.persisted? && !record.loaded?
|
|
119
|
-
begin
|
|
120
|
-
record.class.load(record)
|
|
121
|
-
rescue Foobara::Entity::NotFoundError => e
|
|
122
|
-
add_input_error(
|
|
123
|
-
data_path.to_s,
|
|
124
|
-
CommandPatternImplementation::NotFoundError,
|
|
125
|
-
criteria: e.criteria,
|
|
126
|
-
entity_class: record.class.model_type.scoped_full_name
|
|
127
|
-
)
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
89
|
def validate
|
|
135
90
|
# can override if desired, default is a no-op
|
|
136
91
|
end
|
|
@@ -152,7 +107,7 @@ module Foobara
|
|
|
152
107
|
transition = transition_or_transitions
|
|
153
108
|
|
|
154
109
|
state_machine.perform_transition!(transition) do
|
|
155
|
-
result =
|
|
110
|
+
result = __send__(transition)
|
|
156
111
|
halt! if has_errors?
|
|
157
112
|
end
|
|
158
113
|
end
|
|
@@ -74,17 +74,17 @@ module Foobara
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
if subcommand_classes.length == 1
|
|
77
|
-
subcommand_classes = Util.array(subcommand_classes
|
|
77
|
+
subcommand_classes = Util.array(subcommand_classes[0])
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
subcommand_classes.each do |subcommand_class|
|
|
81
81
|
subcommand_name = subcommand_class.scoped_full_name.to_sym
|
|
82
82
|
|
|
83
83
|
if depends_on.include?(subcommand_name)
|
|
84
|
-
# :
|
|
84
|
+
# simplecov:disable
|
|
85
85
|
raise AlreadyRegisteredSubcommand,
|
|
86
86
|
"Already registered #{subcommand_class} as a dependency of #{self}"
|
|
87
|
-
# :
|
|
87
|
+
# simplecov:enable
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
depends_on << subcommand_name
|
|
@@ -99,9 +99,9 @@ module Foobara
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
unless depends_on?(subcommand_class)
|
|
102
|
-
# :
|
|
102
|
+
# simplecov:disable
|
|
103
103
|
raise SubcommandNotRegistered, "Need to declare #{subcommand_class} on #{self} with .depends_on"
|
|
104
|
-
# :
|
|
104
|
+
# simplecov:enable
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
|
@@ -29,7 +29,6 @@ module Foobara
|
|
|
29
29
|
include CommandPatternImplementation::Concerns::Runtime
|
|
30
30
|
include CommandPatternImplementation::Concerns::Callbacks
|
|
31
31
|
include CommandPatternImplementation::Concerns::StateMachine
|
|
32
|
-
include CommandPatternImplementation::Concerns::Transactions
|
|
33
32
|
include CommandPatternImplementation::Concerns::Subcommands
|
|
34
33
|
include CommandPatternImplementation::Concerns::DomainMappers
|
|
35
34
|
include CommandPatternImplementation::Concerns::Reflection
|
|
@@ -25,7 +25,7 @@ module Foobara
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def reset_all
|
|
28
|
-
Foobara.raise_if_production!
|
|
28
|
+
Foobara.raise_if_production!
|
|
29
29
|
remove_instance_variable("@desugarizer") if defined?(@desugarizer)
|
|
30
30
|
remove_instance_variable("@desugarizers") if defined?(@desugarizers)
|
|
31
31
|
end
|
|
@@ -83,6 +83,7 @@ RSpec.describe Foobara::CommandConnector do
|
|
|
83
83
|
let(:allowed_rule) { nil }
|
|
84
84
|
let(:allowed_rules) { nil }
|
|
85
85
|
let(:requires_authentication) { nil }
|
|
86
|
+
let(:authentication_optional) { nil }
|
|
86
87
|
let(:capture_unknown_error) { false }
|
|
87
88
|
let(:aggregate_entities) { nil }
|
|
88
89
|
let(:atomic_entities) { nil }
|
|
@@ -473,6 +474,7 @@ RSpec.describe Foobara::CommandConnector do
|
|
|
473
474
|
request: request_mutators,
|
|
474
475
|
allowed_rule:,
|
|
475
476
|
requires_authentication:,
|
|
477
|
+
authentication_optional:,
|
|
476
478
|
pre_commit_transformers:,
|
|
477
479
|
capture_unknown_error:,
|
|
478
480
|
aggregate_entities:,
|
|
@@ -1066,6 +1068,63 @@ RSpec.describe Foobara::CommandConnector do
|
|
|
1066
1068
|
end
|
|
1067
1069
|
end
|
|
1068
1070
|
|
|
1071
|
+
context "when authentication is optional" do
|
|
1072
|
+
let(:requires_authentication) { nil }
|
|
1073
|
+
let(:authentication_optional) { true }
|
|
1074
|
+
let(:authenticator) { proc { "some-user" } }
|
|
1075
|
+
|
|
1076
|
+
it "authenticates, so the command can tell who is calling" do
|
|
1077
|
+
expect(response.status).to be(0)
|
|
1078
|
+
expect(response.authenticated_user).to eq("some-user")
|
|
1079
|
+
end
|
|
1080
|
+
|
|
1081
|
+
context "when the authenticator finds nobody" do
|
|
1082
|
+
let(:authenticator) { proc {} }
|
|
1083
|
+
|
|
1084
|
+
it "is not an error" do
|
|
1085
|
+
expect(response.status).to be(0)
|
|
1086
|
+
expect(response.authenticated_user).to be_nil
|
|
1087
|
+
end
|
|
1088
|
+
end
|
|
1089
|
+
end
|
|
1090
|
+
|
|
1091
|
+
context "when authentication is asked for but no authenticator is configured" do
|
|
1092
|
+
let(:authenticator) { nil }
|
|
1093
|
+
|
|
1094
|
+
context "when it is required" do
|
|
1095
|
+
let(:requires_authentication) { true }
|
|
1096
|
+
let(:authentication_optional) { nil }
|
|
1097
|
+
|
|
1098
|
+
it "blows up rather than running the command unauthenticated" do
|
|
1099
|
+
expect {
|
|
1100
|
+
response
|
|
1101
|
+
}.to raise_error(Foobara::CommandConnector::NoAuthenticatorGivenError)
|
|
1102
|
+
end
|
|
1103
|
+
end
|
|
1104
|
+
|
|
1105
|
+
context "when it is optional" do
|
|
1106
|
+
let(:requires_authentication) { nil }
|
|
1107
|
+
let(:authentication_optional) { true }
|
|
1108
|
+
|
|
1109
|
+
it "blows up rather than running the command anonymously" do
|
|
1110
|
+
expect {
|
|
1111
|
+
response
|
|
1112
|
+
}.to raise_error(Foobara::CommandConnector::NoAuthenticatorGivenError)
|
|
1113
|
+
end
|
|
1114
|
+
end
|
|
1115
|
+
end
|
|
1116
|
+
|
|
1117
|
+
context "when neither is asked for" do
|
|
1118
|
+
let(:requires_authentication) { nil }
|
|
1119
|
+
let(:authentication_optional) { nil }
|
|
1120
|
+
let(:authenticator) { proc { "some-user" } }
|
|
1121
|
+
|
|
1122
|
+
it "does not authenticate at all" do
|
|
1123
|
+
expect(response.status).to be(0)
|
|
1124
|
+
expect(response.authenticated_user).to be_nil
|
|
1125
|
+
end
|
|
1126
|
+
end
|
|
1127
|
+
|
|
1069
1128
|
context "with an entity input" do
|
|
1070
1129
|
before do
|
|
1071
1130
|
Foobara::Persistence.default_crud_driver = Foobara::Persistence::CrudDrivers::InMemory.new
|
|
@@ -1129,7 +1188,7 @@ RSpec.describe Foobara::CommandConnector do
|
|
|
1129
1188
|
errors = JSON.parse(response.body)
|
|
1130
1189
|
|
|
1131
1190
|
expect(errors.size).to eq(1)
|
|
1132
|
-
expect(errors.map { |e| e["key"] }).to include("
|
|
1191
|
+
expect(errors.map { |e| e["key"] }).to include("data.user.not_found")
|
|
1133
1192
|
end
|
|
1134
1193
|
end
|
|
1135
1194
|
|
|
@@ -1576,7 +1635,7 @@ RSpec.describe Foobara::CommandConnector do
|
|
|
1576
1635
|
|
|
1577
1636
|
it "gives some help" do
|
|
1578
1637
|
expect(response.status).to be(0)
|
|
1579
|
-
expect(response.body).to
|
|
1638
|
+
expect(response.body).to include('HELP!!!')
|
|
1580
1639
|
end
|
|
1581
1640
|
|
|
1582
1641
|
context "when asking for help with a specific element" do
|
|
@@ -1585,7 +1644,7 @@ RSpec.describe Foobara::CommandConnector do
|
|
|
1585
1644
|
|
|
1586
1645
|
it "gives some help" do
|
|
1587
1646
|
expect(response.status).to be(0)
|
|
1588
|
-
expect(response.body).to
|
|
1647
|
+
expect(response.body).to include('HELP!!!')
|
|
1589
1648
|
end
|
|
1590
1649
|
end
|
|
1591
1650
|
|
|
@@ -2039,7 +2098,7 @@ RSpec.describe Foobara::CommandConnector do
|
|
|
2039
2098
|
|
|
2040
2099
|
# TODO: figure out how to set up this situation instead of directly passing a manifest
|
|
2041
2100
|
# hash to a private method
|
|
2042
|
-
patched_up_manifest = command_connector.
|
|
2101
|
+
patched_up_manifest = command_connector.__send__(
|
|
2043
2102
|
:patch_up_broken_parents_for_errors_with_missing_command_parents,
|
|
2044
2103
|
manifest_hash
|
|
2045
2104
|
)
|