ecoportal-api-graphql 1.3.16 → 2.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +746 -6
- data/LICENSE +21 -21
- data/README.md +24 -24
- data/lib/ecoportal/api/common/graphql/auth_service.rb +115 -115
- data/lib/ecoportal/api/common/graphql/class_helpers.rb +46 -46
- data/lib/ecoportal/api/common/graphql/client.rb +69 -69
- data/lib/ecoportal/api/common/graphql/hash_helpers.rb +105 -105
- data/lib/ecoportal/api/common/graphql/http_client.rb +85 -2
- data/lib/ecoportal/api/common/graphql/model/as_input.rb +54 -54
- data/lib/ecoportal/api/common/graphql/model/diffable/classic_diff_service.rb +49 -49
- data/lib/ecoportal/api/common/graphql/model/diffable/diff_service.rb +188 -188
- data/lib/ecoportal/api/common/graphql/model/diffable/hash_diff.rb +55 -55
- data/lib/ecoportal/api/common/graphql/model/diffable/hash_diff_nesting.rb +295 -295
- data/lib/ecoportal/api/common/graphql/model/diffable/leaf_diff_service.rb +97 -0
- data/lib/ecoportal/api/common/graphql/model/diffable.rb +1 -0
- data/lib/ecoportal/api/common/graphql/model.rb +17 -17
- data/lib/ecoportal/api/common/graphql/patches.rb +1 -1
- data/lib/ecoportal/api/common/graphql/query_integration.rb +45 -45
- data/lib/ecoportal/api/common/graphql.rb +16 -16
- data/lib/ecoportal/api/common.graphql.rb +8 -8
- data/lib/ecoportal/api/graphql/base/action.rb +1 -1
- data/lib/ecoportal/api/graphql/base/action_category.rb +15 -15
- data/lib/ecoportal/api/graphql/base/action_event.rb +23 -0
- data/lib/ecoportal/api/graphql/base/action_event_page.rb +16 -0
- data/lib/ecoportal/api/graphql/base/activity.rb +38 -0
- data/lib/ecoportal/api/graphql/base/activity_log.rb +38 -0
- data/lib/ecoportal/api/graphql/base/ai_summary_version.rb +13 -8
- data/lib/ecoportal/api/graphql/base/auth_log.rb +24 -0
- data/lib/ecoportal/api/graphql/base/authorization_result.rb +20 -0
- data/lib/ecoportal/api/graphql/base/contractor_entity/member_changes.rb +17 -5
- data/lib/ecoportal/api/graphql/base/contractor_entity.rb +24 -24
- data/lib/ecoportal/api/graphql/base/date_time.rb +12 -12
- data/lib/ecoportal/api/graphql/base/delta_result.rb +16 -16
- data/lib/ecoportal/api/graphql/base/field.rb +12 -12
- data/lib/ecoportal/api/graphql/base/file_attachment.rb +15 -15
- data/lib/ecoportal/api/graphql/base/file_container.rb +12 -4
- data/lib/ecoportal/api/graphql/base/location_classification_type.rb +2 -0
- data/lib/ecoportal/api/graphql/base/location_node.rb +14 -14
- data/lib/ecoportal/api/graphql/base/location_structure/draft/structure.rb +37 -37
- data/lib/ecoportal/api/graphql/base/location_structure/draft.rb +93 -93
- data/lib/ecoportal/api/graphql/base/location_structure.rb +3 -0
- data/lib/ecoportal/api/graphql/base/minimal_dashboard.rb +25 -0
- data/lib/ecoportal/api/graphql/base/organization.rb +2 -0
- data/lib/ecoportal/api/graphql/base/page/data_field/actions_list.rb +9 -9
- data/lib/ecoportal/api/graphql/base/page/data_field/ai_summary.rb +18 -18
- data/lib/ecoportal/api/graphql/base/page/data_field/checklist.rb +29 -29
- data/lib/ecoportal/api/graphql/base/page/data_field/contractor_entities.rb +26 -3
- data/lib/ecoportal/api/graphql/base/page/data_field/cross_reference.rb +1 -1
- data/lib/ecoportal/api/graphql/base/page/data_field/date_field.rb +23 -23
- data/lib/ecoportal/api/graphql/base/page/data_field/file_field.rb +47 -8
- data/lib/ecoportal/api/graphql/base/page/data_field/geo.rb +24 -24
- data/lib/ecoportal/api/graphql/base/page/data_field/image_gallery.rb +6 -3
- data/lib/ecoportal/api/graphql/base/page/data_field/law.rb +8 -8
- data/lib/ecoportal/api/graphql/base/page/data_field/mailbox.rb +9 -9
- data/lib/ecoportal/api/graphql/base/page/data_field/people.rb +50 -12
- data/lib/ecoportal/api/graphql/base/page/data_field/plain_text.rb +17 -17
- data/lib/ecoportal/api/graphql/base/page/data_field/rich_text.rb +26 -26
- data/lib/ecoportal/api/graphql/base/page/data_field/signature.rb +9 -9
- data/lib/ecoportal/api/graphql/base/page/data_field/smart_fill.rb +17 -17
- data/lib/ecoportal/api/graphql/base/page/data_field/table.rb +9 -9
- data/lib/ecoportal/api/graphql/base/page/data_field/tag_field.rb +21 -21
- data/lib/ecoportal/api/graphql/base/page/data_field.rb +12 -18
- data/lib/ecoportal/api/graphql/base/page/phased/stage.rb +51 -0
- data/lib/ecoportal/api/graphql/base/page/phased.rb +15 -15
- data/lib/ecoportal/api/graphql/base/page/section.rb +48 -48
- data/lib/ecoportal/api/graphql/base/page_info.rb +12 -12
- data/lib/ecoportal/api/graphql/base/pages_workflow/operation_interface.rb +39 -39
- data/lib/ecoportal/api/graphql/base/pages_workflow/operations/assign_to.rb +27 -27
- data/lib/ecoportal/api/graphql/base/pages_workflow/operations/send_notification.rb +30 -30
- data/lib/ecoportal/api/graphql/base/pages_workflow/recipient_config.rb +34 -34
- data/lib/ecoportal/api/graphql/base/pages_workflow.rb +35 -35
- data/lib/ecoportal/api/graphql/base/permissions.rb +15 -0
- data/lib/ecoportal/api/graphql/base/person_member.rb +22 -22
- data/lib/ecoportal/api/graphql/base/person_member_changelog.rb +23 -0
- data/lib/ecoportal/api/graphql/base/preset_view.rb +136 -1
- data/lib/ecoportal/api/graphql/base/preview_page.rb +23 -23
- data/lib/ecoportal/api/graphql/base/register.rb +6 -1
- data/lib/ecoportal/api/graphql/base/resource.rb +13 -13
- data/lib/ecoportal/api/graphql/base/template/change_log_entry.rb +118 -0
- data/lib/ecoportal/api/graphql/base/template.rb +2 -0
- data/lib/ecoportal/api/graphql/base.rb +9 -0
- data/lib/ecoportal/api/graphql/builder/action.rb +41 -41
- data/lib/ecoportal/api/graphql/builder/contractor_entity.rb +10 -0
- data/lib/ecoportal/api/graphql/builder/location_structure/draft.rb +64 -64
- data/lib/ecoportal/api/graphql/builder/location_structure.rb +40 -40
- data/lib/ecoportal/api/graphql/builder/page.rb +0 -16
- data/lib/ecoportal/api/graphql/builder/register/preset_view.rb +84 -84
- data/lib/ecoportal/api/graphql/builder/register.rb +49 -49
- data/lib/ecoportal/api/graphql/builder/template.rb +46 -0
- data/lib/ecoportal/api/graphql/builder/template_builder.rb +21 -2
- data/lib/ecoportal/api/graphql/compat/page_reference.rb +23 -23
- data/lib/ecoportal/api/graphql/compat/pages.rb +7 -2
- data/lib/ecoportal/api/graphql/compat/registers.rb +84 -84
- data/lib/ecoportal/api/graphql/compat/response.rb +14 -0
- data/lib/ecoportal/api/graphql/compat/search_results.rb +33 -33
- data/lib/ecoportal/api/graphql/compat.rb +17 -17
- data/lib/ecoportal/api/graphql/concerns/data_field_access.rb +71 -71
- data/lib/ecoportal/api/graphql/concerns/fragment_definitions.rb +68 -68
- data/lib/ecoportal/api/graphql/concerns/snake_camel_access.rb +60 -60
- data/lib/ecoportal/api/graphql/concerns/threadable.rb +58 -0
- data/lib/ecoportal/api/graphql/concerns.rb +1 -0
- data/lib/ecoportal/api/graphql/connection/action.rb +1 -1
- data/lib/ecoportal/api/graphql/connection/action_category.rb +1 -1
- data/lib/ecoportal/api/graphql/connection/activity.rb +11 -0
- data/lib/ecoportal/api/graphql/connection/activity_log.rb +11 -0
- data/lib/ecoportal/api/graphql/connection/auth_log.rb +11 -0
- data/lib/ecoportal/api/graphql/connection/contractor_entity.rb +1 -1
- data/lib/ecoportal/api/graphql/connection/minimal_dashboard.rb +11 -0
- data/lib/ecoportal/api/graphql/connection/page.rb +1 -1
- data/lib/ecoportal/api/graphql/connection/pages_workflow_command.rb +1 -1
- data/lib/ecoportal/api/graphql/connection/person_member.rb +1 -1
- data/lib/ecoportal/api/graphql/connection/person_member_changelog.rb +11 -0
- data/lib/ecoportal/api/graphql/connection/preset_view.rb +11 -11
- data/lib/ecoportal/api/graphql/connection/preview_page.rb +1 -1
- data/lib/ecoportal/api/graphql/connection/template_change_log.rb +19 -0
- data/lib/ecoportal/api/graphql/connection.rb +6 -0
- data/lib/ecoportal/api/graphql/diff/change.rb +7 -2
- data/lib/ecoportal/api/graphql/diff/command_synthesizer.rb +19 -1
- data/lib/ecoportal/api/graphql/diff/pairing/signals.rb +21 -1
- data/lib/ecoportal/api/graphql/diff/version_diff.rb +13 -6
- data/lib/ecoportal/api/graphql/error/locations_error/fetch_nested.rb +51 -51
- data/lib/ecoportal/api/graphql/error/locations_error.rb +28 -28
- data/lib/ecoportal/api/graphql/error/locations_validation_error.rb +20 -20
- data/lib/ecoportal/api/graphql/error/validation_errors.rb +28 -28
- data/lib/ecoportal/api/graphql/error.rb +12 -12
- data/lib/ecoportal/api/graphql/file_upload/client.rb +199 -140
- data/lib/ecoportal/api/graphql/file_upload.rb +10 -10
- data/lib/ecoportal/api/graphql/fragment/action.rb +65 -65
- data/lib/ecoportal/api/graphql/fragment/action_category.rb +17 -17
- data/lib/ecoportal/api/graphql/fragment/activity.rb +84 -0
- data/lib/ecoportal/api/graphql/fragment/activity_log.rb +75 -0
- data/lib/ecoportal/api/graphql/fragment/auth_log.rb +29 -0
- data/lib/ecoportal/api/graphql/fragment/authorization_result.rb +14 -0
- data/lib/ecoportal/api/graphql/fragment/contractor_entity.rb +20 -20
- data/lib/ecoportal/api/graphql/fragment/location_node.rb +1 -0
- data/lib/ecoportal/api/graphql/fragment/locations_error.rb +19 -19
- data/lib/ecoportal/api/graphql/fragment/minimal_dashboard.rb +31 -0
- data/lib/ecoportal/api/graphql/fragment/page.rb +1 -0
- data/lib/ecoportal/api/graphql/fragment/pages/common_page_union.rb +23 -0
- data/lib/ecoportal/api/graphql/fragment/pages.rb +15 -15
- data/lib/ecoportal/api/graphql/fragment/pagination.rb +17 -17
- data/lib/ecoportal/api/graphql/fragment/permissions.rb +98 -0
- data/lib/ecoportal/api/graphql/fragment/person_member_changelog.rb +33 -0
- data/lib/ecoportal/api/graphql/fragment/template_change_log.rb +102 -0
- data/lib/ecoportal/api/graphql/fragment.rb +8 -0
- data/lib/ecoportal/api/graphql/helpers/locations_tree.rb +41 -41
- data/lib/ecoportal/api/graphql/helpers.rb +10 -10
- data/lib/ecoportal/api/graphql/input/action/archive.rb +14 -14
- data/lib/ecoportal/api/graphql/input/action/create.rb +13 -13
- data/lib/ecoportal/api/graphql/input/action/update.rb +12 -0
- data/lib/ecoportal/api/graphql/input/action.rb +14 -14
- data/lib/ecoportal/api/graphql/input/contractor_entity/create.rb +14 -14
- data/lib/ecoportal/api/graphql/input/contractor_entity/destroy.rb +13 -13
- data/lib/ecoportal/api/graphql/input/contractor_entity/manager_settings.rb +20 -0
- data/lib/ecoportal/api/graphql/input/contractor_entity/update.rb +6 -27
- data/lib/ecoportal/api/graphql/input/contractor_entity.rb +1 -0
- data/lib/ecoportal/api/graphql/input/date_range.rb +16 -0
- data/lib/ecoportal/api/graphql/input/delta_input.rb +16 -16
- data/lib/ecoportal/api/graphql/input/id_diff.rb +11 -11
- data/lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb +2 -2
- data/lib/ecoportal/api/graphql/input/location_structure/archive_command.rb +13 -13
- data/lib/ecoportal/api/graphql/input/location_structure/delete_command.rb +13 -13
- data/lib/ecoportal/api/graphql/input/location_structure/draft/add_commands.rb +2 -2
- data/lib/ecoportal/api/graphql/input/location_structure/draft/create.rb +15 -15
- data/lib/ecoportal/api/graphql/input/location_structure/draft/delete.rb +15 -15
- data/lib/ecoportal/api/graphql/input/location_structure/draft/drop_bad_commands.rb +16 -16
- data/lib/ecoportal/api/graphql/input/location_structure/draft/publish.rb +16 -16
- data/lib/ecoportal/api/graphql/input/location_structure/draft.rb +19 -19
- data/lib/ecoportal/api/graphql/input/location_structure/insert_command.rb +21 -13
- data/lib/ecoportal/api/graphql/input/location_structure/move_command.rb +14 -14
- data/lib/ecoportal/api/graphql/input/location_structure/reorder_command.rb +13 -13
- data/lib/ecoportal/api/graphql/input/location_structure/unarchive_command.rb +13 -13
- data/lib/ecoportal/api/graphql/input/location_structure/update_command.rb +6 -2
- data/lib/ecoportal/api/graphql/input/location_structure.rb +20 -20
- data/lib/ecoportal/api/graphql/input/page/archive.rb +14 -14
- data/lib/ecoportal/api/graphql/input/page/build_from_template.rb +13 -13
- data/lib/ecoportal/api/graphql/input/page/create_draft.rb +13 -13
- data/lib/ecoportal/api/graphql/input/page/create_from_template.rb +18 -18
- data/lib/ecoportal/api/graphql/input/page/delete_draft.rb +13 -13
- data/lib/ecoportal/api/graphql/input/page/publish_draft.rb +13 -13
- data/lib/ecoportal/api/graphql/input/page/review_task.rb +27 -14
- data/lib/ecoportal/api/graphql/input/page/unarchive.rb +14 -14
- data/lib/ecoportal/api/graphql/input/page.rb +26 -26
- data/lib/ecoportal/api/graphql/input/preset_view/create.rb +18 -18
- data/lib/ecoportal/api/graphql/input/preset_view/permission.rb +16 -16
- data/lib/ecoportal/api/graphql/input/preset_view/update.rb +17 -2
- data/lib/ecoportal/api/graphql/input/preset_view.rb +14 -14
- data/lib/ecoportal/api/graphql/input/register/create.rb +18 -18
- data/lib/ecoportal/api/graphql/input/register/update.rb +15 -15
- data/lib/ecoportal/api/graphql/input/register.rb +13 -13
- data/lib/ecoportal/api/graphql/input/search.rb +13 -13
- data/lib/ecoportal/api/graphql/input/search_conf/ai_generator.rb +234 -234
- data/lib/ecoportal/api/graphql/input/search_filter.rb +12 -12
- data/lib/ecoportal/api/graphql/input/search_sorter.rb +11 -11
- data/lib/ecoportal/api/graphql/input/workflow_command/add_action_tag.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_binding.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_checklist_field_item.rb +19 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/add_comment_tagging_user_group.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_default_direct_strategy_user.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_default_strategy.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_direct_strategy_user.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_field.rb +10 -9
- data/lib/ecoportal/api/graphql/input/workflow_command/add_force.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_linked_field_config.rb +23 -23
- data/lib/ecoportal/api/graphql/input/workflow_command/add_linked_helper.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_operation.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_operation_direct_strategy_user.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_operation_strategy.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_recipient_action_type.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_recipient_filter.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_recipient_people_field.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_recipient_task_config.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_recipient_user.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_scheduled_callback.rb +23 -23
- data/lib/ecoportal/api/graphql/input/workflow_command/add_scheduled_callback_action.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_section.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_select_field_option.rb +25 -19
- data/lib/ecoportal/api/graphql/input/workflow_command/add_smart_fill_config.rb +23 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/add_stage.rb +3 -2
- data/lib/ecoportal/api/graphql/input/workflow_command/add_stage_section.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_stage_tag.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_strategy.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_task.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_task_assignment_user_group.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/add_viewable_field.rb +45 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/add_workflow_callback.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/archive_public_config.rb +19 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/collapse_section.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/create_public_config.rb +19 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_binding.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_checklist_field_item.rb +19 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_creator_permissions.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_default_strategy.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_field_configuration.rb +17 -2
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_force.rb +21 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_gauge_field_stop.rb +19 -19
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_linked_field_config.rb +19 -19
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_linked_helper.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_operation.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_operation_strategy.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_public_config.rb +19 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_reminder.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_required_sign_offs.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_restrict_comment_tagging.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_restrict_task_assignment.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_scheduled_callback.rb +22 -22
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_section_header.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_select_field_option.rb +23 -19
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_smart_fill_config.rb +21 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_stage.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_strategy.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_task_due.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_template_advanced_settings.rb +19 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_template_basic_settings.rb +32 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_template_container_uid.rb +45 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/{edit_page_creator_permissions.rb → edit_template_creator_permissions.rb} +3 -2
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_template_descriptions.rb +19 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_trigger.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/expand_section.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/action_list.rb +31 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/contractor_entities.rb +28 -24
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/cross_reference.rb +9 -1
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/date.rb +15 -2
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/file.rb +21 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/gauge.rb +20 -20
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/image_gallery.rb +3 -2
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/location_field.rb +24 -24
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/people.rb +27 -3
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/plain_text.rb +9 -2
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/rich_text.rb +3 -2
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/select.rb +3 -2
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/signature.rb +20 -20
- data/lib/ecoportal/api/graphql/input/workflow_command/field_config/table.rb +25 -25
- data/lib/ecoportal/api/graphql/input/workflow_command/manage_copy_page_configuration.rb +47 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/move_field.rb +3 -2
- data/lib/ecoportal/api/graphql/input/workflow_command/move_stage.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/move_viewable_field.rb +33 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_action_tag.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_binding.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_callback.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_checklist_field_item.rb +19 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_comment_tagging_user_group.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_default_direct_strategy_user.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_default_strategy.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_direct_strategy_user.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_field.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_force.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_linked_helper.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_operation.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_operation_direct_strategy_user.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_operation_strategy.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_recipient_action_type.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_recipient_filter.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_recipient_people_field.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_recipient_task_config.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_recipient_user.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_scheduled_callback.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_section.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_smart_fill_config.rb +19 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_stage.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_stage_section.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_stage_tag.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_strategy.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_task.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_task_assignment_user_group.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_task_due.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_task_priority_level.rb +18 -18
- data/lib/ecoportal/api/graphql/input/workflow_command/remove_viewable_field.rb +21 -0
- data/lib/ecoportal/api/graphql/input/workflow_command/reorder_forces.rb +3 -2
- data/lib/ecoportal/api/graphql/input/workflow_command/reorder_section.rb +3 -2
- data/lib/ecoportal/api/graphql/input/workflow_command.rb +46 -5
- data/lib/ecoportal/api/graphql/input.rb +1 -0
- data/lib/ecoportal/api/graphql/interface/base_page.rb +50 -3
- data/lib/ecoportal/api/graphql/interface/location_structure/command.rb +2 -1
- data/lib/ecoportal/api/graphql/interface/location_structure/node.rb +43 -43
- data/lib/ecoportal/api/graphql/interface/location_structure.rb +14 -14
- data/lib/ecoportal/api/graphql/interface.rb +11 -11
- data/lib/ecoportal/api/graphql/logic/base_model.rb +15 -15
- data/lib/ecoportal/api/graphql/logic/base_query.rb +260 -193
- data/lib/ecoportal/api/graphql/logic/connection.rb +17 -0
- data/lib/ecoportal/api/graphql/logic/input.rb +127 -0
- data/lib/ecoportal/api/graphql/logic/mutation.rb +59 -59
- data/lib/ecoportal/api/graphql/logic/payload.rb +42 -42
- data/lib/ecoportal/api/graphql/logic/query.rb +23 -23
- data/lib/ecoportal/api/graphql/logic/query_array.rb +30 -30
- data/lib/ecoportal/api/graphql/logic/query_connection.rb +48 -48
- data/lib/ecoportal/api/graphql/logic.rb +18 -18
- data/lib/ecoportal/api/graphql/model/account.rb +15 -15
- data/lib/ecoportal/api/graphql/model/action.rb +22 -22
- data/lib/ecoportal/api/graphql/model/action_event.rb +14 -0
- data/lib/ecoportal/api/graphql/model/action_event_page.rb +10 -0
- data/lib/ecoportal/api/graphql/model/activity.rb +14 -0
- data/lib/ecoportal/api/graphql/model/activity_log.rb +31 -0
- data/lib/ecoportal/api/graphql/model/ai_summary_version.rb +10 -10
- data/lib/ecoportal/api/graphql/model/auth_log.rb +11 -0
- data/lib/ecoportal/api/graphql/model/authorization_result.rb +12 -0
- data/lib/ecoportal/api/graphql/model/contractor_entity.rb +12 -12
- data/lib/ecoportal/api/graphql/model/field.rb +10 -10
- data/lib/ecoportal/api/graphql/model/file_attachment.rb +10 -10
- data/lib/ecoportal/api/graphql/model/file_container.rb +11 -11
- data/lib/ecoportal/api/graphql/model/location_node.rb +14 -14
- data/lib/ecoportal/api/graphql/model/location_structure/draft/structure.rb +15 -15
- data/lib/ecoportal/api/graphql/model/location_structure/draft.rb +15 -15
- data/lib/ecoportal/api/graphql/model/location_structure.rb +16 -16
- data/lib/ecoportal/api/graphql/model/minimal_dashboard.rb +14 -0
- data/lib/ecoportal/api/graphql/model/organization.rb +36 -0
- data/lib/ecoportal/api/graphql/model/page/basic.rb +14 -14
- data/lib/ecoportal/api/graphql/model/page/data_field.rb +12 -12
- data/lib/ecoportal/api/graphql/model/page/phased/stage.rb +14 -14
- data/lib/ecoportal/api/graphql/model/page/phased.rb +17 -0
- data/lib/ecoportal/api/graphql/model/page/section.rb +12 -12
- data/lib/ecoportal/api/graphql/model/page_union.rb +21 -21
- data/lib/ecoportal/api/graphql/model/pages_workflow.rb +20 -20
- data/lib/ecoportal/api/graphql/model/permissions.rb +179 -0
- data/lib/ecoportal/api/graphql/model/person_member.rb +7 -0
- data/lib/ecoportal/api/graphql/model/person_member_changelog.rb +15 -0
- data/lib/ecoportal/api/graphql/model/preset_view.rb +10 -10
- data/lib/ecoportal/api/graphql/model/preview_page.rb +10 -10
- data/lib/ecoportal/api/graphql/model/register.rb +10 -10
- data/lib/ecoportal/api/graphql/model/resource.rb +13 -13
- data/lib/ecoportal/api/graphql/model/template/change_log_entry.rb +19 -0
- data/lib/ecoportal/api/graphql/model/template.rb +4 -1
- data/lib/ecoportal/api/graphql/model/user.rb +14 -14
- data/lib/ecoportal/api/graphql/model.rb +9 -0
- data/lib/ecoportal/api/graphql/mutation/action/archive.rb +41 -41
- data/lib/ecoportal/api/graphql/mutation/action/create.rb +40 -40
- data/lib/ecoportal/api/graphql/mutation/action/update.rb +40 -40
- data/lib/ecoportal/api/graphql/mutation/action.rb +14 -14
- data/lib/ecoportal/api/graphql/mutation/ai_summary/generate.rb +21 -11
- data/lib/ecoportal/api/graphql/mutation/ai_summary/submit_feedback.rb +26 -11
- data/lib/ecoportal/api/graphql/mutation/ai_summary.rb +13 -13
- data/lib/ecoportal/api/graphql/mutation/contractor_entity/create.rb +40 -40
- data/lib/ecoportal/api/graphql/mutation/contractor_entity/destroy.rb +40 -40
- data/lib/ecoportal/api/graphql/mutation/contractor_entity/update.rb +40 -40
- data/lib/ecoportal/api/graphql/mutation/contractor_entity/update_manager_settings.rb +37 -0
- data/lib/ecoportal/api/graphql/mutation/contractor_entity.rb +1 -0
- data/lib/ecoportal/api/graphql/mutation/file_container/upload.rb +78 -0
- data/lib/ecoportal/api/graphql/mutation/file_container.rb +15 -0
- data/lib/ecoportal/api/graphql/mutation/location_structure/apply_commands.rb +54 -54
- data/lib/ecoportal/api/graphql/mutation/location_structure/draft/add_commands.rb +55 -55
- data/lib/ecoportal/api/graphql/mutation/location_structure/draft/create.rb +54 -54
- data/lib/ecoportal/api/graphql/mutation/location_structure/draft/delete.rb +43 -43
- data/lib/ecoportal/api/graphql/mutation/location_structure/draft/drop_bad_commands.rb +56 -56
- data/lib/ecoportal/api/graphql/mutation/location_structure/draft/publish.rb +66 -66
- data/lib/ecoportal/api/graphql/mutation/location_structure/draft.rb +18 -18
- data/lib/ecoportal/api/graphql/mutation/location_structure.rb +13 -13
- data/lib/ecoportal/api/graphql/mutation/page/approve_review_task.rb +1 -1
- data/lib/ecoportal/api/graphql/mutation/page/archive.rb +40 -40
- data/lib/ecoportal/api/graphql/mutation/page/batch_update_review_task.rb +1 -1
- data/lib/ecoportal/api/graphql/mutation/page/build_from_template.rb +50 -50
- data/lib/ecoportal/api/graphql/mutation/page/create_draft.rb +1 -1
- data/lib/ecoportal/api/graphql/mutation/page/create_from_template.rb +43 -43
- data/lib/ecoportal/api/graphql/mutation/page/delete_draft.rb +1 -1
- data/lib/ecoportal/api/graphql/mutation/page/publish_draft.rb +1 -1
- data/lib/ecoportal/api/graphql/mutation/page/reject_review_task.rb +1 -1
- data/lib/ecoportal/api/graphql/mutation/page/restart_review_task.rb +1 -1
- data/lib/ecoportal/api/graphql/mutation/page/unarchive.rb +40 -40
- data/lib/ecoportal/api/graphql/mutation/page/undo_review_task.rb +1 -1
- data/lib/ecoportal/api/graphql/mutation/page/update.rb +40 -40
- data/lib/ecoportal/api/graphql/mutation/page.rb +28 -28
- data/lib/ecoportal/api/graphql/mutation/preset_view/create.rb +35 -35
- data/lib/ecoportal/api/graphql/mutation/preset_view/destroy.rb +1 -1
- data/lib/ecoportal/api/graphql/mutation/preset_view/permission.rb +37 -37
- data/lib/ecoportal/api/graphql/mutation/preset_view/update.rb +35 -35
- data/lib/ecoportal/api/graphql/mutation/preset_view.rb +15 -15
- data/lib/ecoportal/api/graphql/mutation/register/create.rb +35 -35
- data/lib/ecoportal/api/graphql/mutation/register/destroy.rb +1 -1
- data/lib/ecoportal/api/graphql/mutation/register/update.rb +35 -35
- data/lib/ecoportal/api/graphql/mutation/register.rb +14 -14
- data/lib/ecoportal/api/graphql/mutation/template/update_related_page.rb +79 -0
- data/lib/ecoportal/api/graphql/mutation/template.rb +1 -0
- data/lib/ecoportal/api/graphql/mutation.rb +1 -1
- data/lib/ecoportal/api/graphql/payload/action/archive.rb +13 -13
- data/lib/ecoportal/api/graphql/payload/action/create.rb +13 -13
- data/lib/ecoportal/api/graphql/payload/action/update.rb +13 -13
- data/lib/ecoportal/api/graphql/payload/action.rb +14 -14
- data/lib/ecoportal/api/graphql/payload/ai_summary_generate.rb +12 -12
- data/lib/ecoportal/api/graphql/payload/contractor_entity/create.rb +13 -13
- data/lib/ecoportal/api/graphql/payload/contractor_entity/destroy.rb +12 -12
- data/lib/ecoportal/api/graphql/payload/contractor_entity/manager_settings.rb +20 -0
- data/lib/ecoportal/api/graphql/payload/contractor_entity/update.rb +12 -12
- data/lib/ecoportal/api/graphql/payload/contractor_entity.rb +1 -0
- data/lib/ecoportal/api/graphql/payload/kickstand/bulk_update_jobs.rb +2 -2
- data/lib/ecoportal/api/graphql/payload/kickstand/bulk_update_workflows.rb +2 -2
- data/lib/ecoportal/api/graphql/payload/location_structure/apply_commands.rb +51 -51
- data/lib/ecoportal/api/graphql/payload/location_structure/command_execution_result.rb +50 -50
- data/lib/ecoportal/api/graphql/payload/location_structure/draft/add_commands.rb +30 -30
- data/lib/ecoportal/api/graphql/payload/location_structure/draft/delete.rb +30 -30
- data/lib/ecoportal/api/graphql/payload/location_structure/draft/drop_bad_commands.rb +43 -43
- data/lib/ecoportal/api/graphql/payload/location_structure/draft/publish.rb +63 -63
- data/lib/ecoportal/api/graphql/payload/location_structure/draft.rb +18 -18
- data/lib/ecoportal/api/graphql/payload/location_structure.rb +14 -14
- data/lib/ecoportal/api/graphql/payload/ok_payload.rb +1 -1
- data/lib/ecoportal/api/graphql/payload/page/archive.rb +13 -13
- data/lib/ecoportal/api/graphql/payload/page/build_from_template.rb +13 -13
- data/lib/ecoportal/api/graphql/payload/page/create_from_template.rb +13 -13
- data/lib/ecoportal/api/graphql/payload/page/draft.rb +1 -1
- data/lib/ecoportal/api/graphql/payload/page/review_task.rb +1 -1
- data/lib/ecoportal/api/graphql/payload/page/unarchive.rb +13 -13
- data/lib/ecoportal/api/graphql/payload/page/update.rb +13 -13
- data/lib/ecoportal/api/graphql/payload/preset_view.rb +1 -1
- data/lib/ecoportal/api/graphql/payload/register.rb +1 -1
- data/lib/ecoportal/api/graphql/payload/template/update_related_page.rb +15 -0
- data/lib/ecoportal/api/graphql/payload/template.rb +1 -0
- data/lib/ecoportal/api/graphql/payload/upload.rb +12 -0
- data/lib/ecoportal/api/graphql/payload.rb +1 -0
- data/lib/ecoportal/api/graphql/query/action.rb +33 -33
- data/lib/ecoportal/api/graphql/query/action_categories.rb +53 -53
- data/lib/ecoportal/api/graphql/query/actions.rb +43 -43
- data/lib/ecoportal/api/graphql/query/activity_logs.rb +78 -0
- data/lib/ecoportal/api/graphql/query/auth_logs.rb +51 -0
- data/lib/ecoportal/api/graphql/query/contractor_entities.rb +53 -53
- data/lib/ecoportal/api/graphql/query/dashboard_search.rb +57 -0
- data/lib/ecoportal/api/graphql/query/file_upload_signature.rb +76 -76
- data/lib/ecoportal/api/graphql/query/location_classifications.rb +39 -39
- data/lib/ecoportal/api/graphql/query/location_structure.rb +2 -0
- data/lib/ecoportal/api/graphql/query/location_structures.rb +2 -0
- data/lib/ecoportal/api/graphql/query/page.rb +6 -1
- data/lib/ecoportal/api/graphql/query/page_activities.rb +56 -0
- data/lib/ecoportal/api/graphql/query/page_delta.rb +47 -47
- data/lib/ecoportal/api/graphql/query/pages.rb +59 -59
- data/lib/ecoportal/api/graphql/query/permissions.rb +35 -0
- data/lib/ecoportal/api/graphql/query/person_member_changelogs.rb +53 -0
- data/lib/ecoportal/api/graphql/query/person_members.rb +76 -0
- data/lib/ecoportal/api/graphql/query/register_preset_views.rb +1 -1
- data/lib/ecoportal/api/graphql/query/register_preview_pages.rb +83 -83
- data/lib/ecoportal/api/graphql/query/template_change_log.rb +118 -0
- data/lib/ecoportal/api/graphql/query/templates.rb +53 -53
- data/lib/ecoportal/api/graphql/query.rb +8 -0
- data/lib/ecoportal/api/graphql_version.rb +1 -1
- data/lib/ecoportal/api-graphql.rb +10 -10
- metadata +82 -19
- data/lib/ecoportal/api/common/graphql/CLAUDE.md +0 -36
- data/lib/ecoportal/api/common/graphql/model/CLAUDE.md +0 -28
- data/lib/ecoportal/api/graphql/CLAUDE.md +0 -37
- data/lib/ecoportal/api/graphql/base/CLAUDE.md +0 -50
- data/lib/ecoportal/api/graphql/builder/CLAUDE.md +0 -65
- data/lib/ecoportal/api/graphql/input/workflow_command/edit_page.rb +0 -28
- data/lib/ecoportal/api/graphql/mutation/smart_fill/generate.rb +0 -36
- data/lib/ecoportal/api/graphql/mutation/smart_fill/submit_feedback.rb +0 -40
- data/lib/ecoportal/api/graphql/mutation/smart_fill.rb +0 -13
|
@@ -1,295 +1,295 @@
|
|
|
1
|
-
# rubocop:disable Naming/MethodParameterName
|
|
2
|
-
module Ecoportal::API::Common::GraphQL::Model::Diffable
|
|
3
|
-
# @note this is a literal copy of ecoportal-api-v2 gem `has_diff` function.
|
|
4
|
-
# @todo the aim is to adapt it by:
|
|
5
|
-
# 1. Removing the `patch_ver` model ✅
|
|
6
|
-
# 2. Using symbol keys ✅
|
|
7
|
-
module HashDiffNesting
|
|
8
|
-
class << self
|
|
9
|
-
def included(base)
|
|
10
|
-
super
|
|
11
|
-
|
|
12
|
-
base.send :include, InstanceMethods
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
META_KEYS = %i[id].freeze
|
|
17
|
-
NO_CHANGES = "%not-changed!%".freeze
|
|
18
|
-
|
|
19
|
-
module InstanceMethods
|
|
20
|
-
# The `change data` is built as follows:
|
|
21
|
-
# 1. detect changes that have occurred translate into one `api_operation` of `OP_TYPE`:
|
|
22
|
-
# * `:update`: meaning that the object has changed (existed and has not been removed)
|
|
23
|
-
# * `:delete`: the object has been removed
|
|
24
|
-
# * `:create`: the object is new
|
|
25
|
-
# 2. at the level of the target object of the model, the object is opened for change
|
|
26
|
-
# with `id` and `api_operation` as follows:
|
|
27
|
-
#
|
|
28
|
-
# ```json
|
|
29
|
-
# {
|
|
30
|
-
# "id": "objectID",
|
|
31
|
-
# "api_operation": "OP_TYPE",
|
|
32
|
-
# "change_data" {
|
|
33
|
-
# "property": "value",
|
|
34
|
-
# "...": "..."
|
|
35
|
-
# }
|
|
36
|
-
# }
|
|
37
|
-
# ```
|
|
38
|
-
# 3. the `change_data` property holds the specific changes of the object
|
|
39
|
-
# - the properties that have changed
|
|
40
|
-
# @note
|
|
41
|
-
# * there should not be difference between `null` and `""` (empty string)
|
|
42
|
-
# @param a [Hash] current hash model
|
|
43
|
-
# @param b [Hash] previous hash model
|
|
44
|
-
# @return [Hash] a `change data`
|
|
45
|
-
def change_diff(a, b, ignore: [])
|
|
46
|
-
ignore = to_a(ignore)
|
|
47
|
-
|
|
48
|
-
if b.is_a?(Hash) && !empty?(b) && empty?(a)
|
|
49
|
-
patch_delete(b)
|
|
50
|
-
elsif a.is_a?(Hash) && !empty?(a) && empty?(b)
|
|
51
|
-
patch_new(a, ignore: ignore)
|
|
52
|
-
elsif a.is_a?(Hash) && b.is_a?(Hash)
|
|
53
|
-
patch_update(a, b, ignore: ignore)
|
|
54
|
-
elsif any_array?(a, b)
|
|
55
|
-
patch_data_array(a, b, ignore: ignore)
|
|
56
|
-
else
|
|
57
|
-
a
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
private
|
|
62
|
-
|
|
63
|
-
# Compares `a` as carrying changes of `b`
|
|
64
|
-
# @return [Hash] change data object with only changes
|
|
65
|
-
def change_data(a, b = nil, delete: false, ignore: [])
|
|
66
|
-
{}.tap do |data_hash|
|
|
67
|
-
next if delete
|
|
68
|
-
|
|
69
|
-
a.each do |key, a_value|
|
|
70
|
-
key = key.to_sym
|
|
71
|
-
|
|
72
|
-
next if meta_keys.include?(key)
|
|
73
|
-
next if ignore.include?(key)
|
|
74
|
-
|
|
75
|
-
b_value = nil
|
|
76
|
-
|
|
77
|
-
if b&.key?(key)
|
|
78
|
-
b_value = b[key]
|
|
79
|
-
next if equal_values?(a_value, b_value)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
data_hash[key] = change_diff(a_value, b_value)
|
|
83
|
-
|
|
84
|
-
data_hash.delete(key) if data_hash[key] == NO_CHANGES
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
return NO_CHANGES if (data_hash.keys - meta_keys).empty?
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def patch_delete(b)
|
|
92
|
-
return NO_CHANGES unless b.is_a?(Hash)
|
|
93
|
-
return unless (id = get_id(b, exception: false))
|
|
94
|
-
|
|
95
|
-
{
|
|
96
|
-
id: id,
|
|
97
|
-
api_operation: :delete,
|
|
98
|
-
change_data: change_data(b, delete: true)
|
|
99
|
-
}
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def patch_new(a, ignore: [])
|
|
103
|
-
return NO_CHANGES unless a.is_a?(Hash)
|
|
104
|
-
return a unless (id = get_id(a, exception: false))
|
|
105
|
-
|
|
106
|
-
{
|
|
107
|
-
id: id,
|
|
108
|
-
api_operation: :create,
|
|
109
|
-
change_data: change_data(a, ignore: ignore)
|
|
110
|
-
}
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def patch_update(a, b, ignore: [])
|
|
114
|
-
return NO_CHANGES unless a.is_a?(Hash)
|
|
115
|
-
return a unless (id = get_id(a, exception: false))
|
|
116
|
-
|
|
117
|
-
{
|
|
118
|
-
id: id,
|
|
119
|
-
api_operation: :update,
|
|
120
|
-
change_data: change_data(a, b, ignore: ignore)
|
|
121
|
-
}.tap do |update_hash|
|
|
122
|
-
return nil unless update_hash[:change_data] != NO_CHANGES
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def patch_data_array(a, b, ignore: [])
|
|
127
|
-
return patch_data_nested_array(a, b, ignore: ignore) if nested_array?(a, b)
|
|
128
|
-
|
|
129
|
-
patch_data_flat_array(a, b)
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
def patch_data_flat_array(a, b)
|
|
133
|
-
original_b = b
|
|
134
|
-
a ||= []
|
|
135
|
-
b ||= []
|
|
136
|
-
|
|
137
|
-
same_elements =
|
|
138
|
-
a.length == b.length &&
|
|
139
|
-
(a & b).length == b.length
|
|
140
|
-
|
|
141
|
-
return a unless same_elements
|
|
142
|
-
return NO_CHANGES if original_b
|
|
143
|
-
|
|
144
|
-
a
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
def patch_data_nested_array(a, b, ignore: [])
|
|
148
|
-
a ||= []
|
|
149
|
-
b ||= []
|
|
150
|
-
|
|
151
|
-
# array with nested elements
|
|
152
|
-
a_ids = array_ids(a)
|
|
153
|
-
b_ids = array_ids(b)
|
|
154
|
-
|
|
155
|
-
del_ids = b_ids - a_ids
|
|
156
|
-
oth_ids = b_ids & a_ids
|
|
157
|
-
new_ids = a_ids - b_ids
|
|
158
|
-
|
|
159
|
-
arr_delete = del_ids.map do |id|
|
|
160
|
-
patch_delete(array_id_item(b, id))
|
|
161
|
-
end.compact
|
|
162
|
-
|
|
163
|
-
arr_update = oth_ids.map do |id|
|
|
164
|
-
patch_update(array_id_item(a, id), array_id_item(b, id), ignore: ignore)
|
|
165
|
-
end.compact
|
|
166
|
-
|
|
167
|
-
arr_new = new_ids.map do |id|
|
|
168
|
-
patch_new(array_id_item(a, id), ignore: ignore)
|
|
169
|
-
end.compact
|
|
170
|
-
|
|
171
|
-
arr_delete.concat(arr_update).concat(arr_new).tap do |patch_array|
|
|
172
|
-
# remove data with no `id`
|
|
173
|
-
patch_array.select! {|item| item.is_a?(Hash)}
|
|
174
|
-
return NO_CHANGES if patch_array.empty?
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
def nested_array?(*arr)
|
|
179
|
-
if arr.length > 1
|
|
180
|
-
arr.any? {|a| nested_array?(a)}
|
|
181
|
-
elsif arr.length == 1
|
|
182
|
-
arr = arr.first || []
|
|
183
|
-
arr.any? do |item|
|
|
184
|
-
next false unless item.is_a?(Hash)
|
|
185
|
-
next true if item.key?(:id)
|
|
186
|
-
|
|
187
|
-
false
|
|
188
|
-
end
|
|
189
|
-
else
|
|
190
|
-
false
|
|
191
|
-
end
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
def any_array?(a, b)
|
|
195
|
-
[a, b].any?(Array)
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
def get_id(doc, exception: true)
|
|
199
|
-
id = nil
|
|
200
|
-
id ||= doc.id if doc.respond_to?(:id)
|
|
201
|
-
id ||= doc['id'] if doc.is_a?(Hash)
|
|
202
|
-
id ||= doc[:id] if doc.is_a?(Hash)
|
|
203
|
-
id ||= doc if doc.is_a?(String)
|
|
204
|
-
|
|
205
|
-
raise 'No ID has been given!' unless id || !exception
|
|
206
|
-
|
|
207
|
-
id
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
# @param arr [Array] the source Array of id-bearing items
|
|
211
|
-
# @return [Array<String>] the `id`s thereof
|
|
212
|
-
def array_ids(arr)
|
|
213
|
-
return [] if !arr.is_a?(Array) || arr.empty?
|
|
214
|
-
|
|
215
|
-
arr.map {|item| get_id(item, exception: false)}
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
# @param arr [Array] the source Array
|
|
219
|
-
# @return [Integer, nil] the position of the item with the given `id`
|
|
220
|
-
def array_id_index(arr, id)
|
|
221
|
-
return unless arr.is_a?(Array)
|
|
222
|
-
|
|
223
|
-
arr.index {|item| get_id(item, exception: false) == id}
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
# @param arr [Array] the source Array
|
|
227
|
-
# @return [Object, nil] the item with the given `id`
|
|
228
|
-
def array_id_item(arr, id)
|
|
229
|
-
return unless (idx = array_id_index(arr, id))
|
|
230
|
-
|
|
231
|
-
arr[idx]
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
def meta_keys
|
|
235
|
-
return self::META_KEYS if respond_to?(:const_get)
|
|
236
|
-
|
|
237
|
-
self.class::META_KEYS
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
def equal_values?(a, b)
|
|
241
|
-
if a.is_a?(String) || b.is_a?(String)
|
|
242
|
-
a_empty = a.to_s.strip.empty?
|
|
243
|
-
b_empty = b.to_s.strip.empty?
|
|
244
|
-
|
|
245
|
-
return true if a_empty && b_empty
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
a == b
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
def empty?(a)
|
|
252
|
-
bool = !a
|
|
253
|
-
bool ||= a.respond_to?(:empty?) && a.empty?
|
|
254
|
-
bool
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
def to_a(*values)
|
|
258
|
-
[values].flatten.compact.uniq
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
# Hash path helpers — used by DiffService#diff_reduce to navigate
|
|
262
|
-
# and modify nested result hashes during cascaded diffing.
|
|
263
|
-
|
|
264
|
-
def dig_path?(obj, keys)
|
|
265
|
-
return false unless obj.is_a?(Hash)
|
|
266
|
-
return obj.key?(keys.first) if keys.length == 1
|
|
267
|
-
return false unless obj.key?(keys.first)
|
|
268
|
-
|
|
269
|
-
dig_path?(obj[keys.first], keys[1..])
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
def dig_set!(obj, keys, value)
|
|
273
|
-
if keys.length == 1
|
|
274
|
-
obj[keys.first] = value
|
|
275
|
-
else
|
|
276
|
-
dig_set!(obj[keys.first], keys[1..], value)
|
|
277
|
-
end
|
|
278
|
-
end
|
|
279
|
-
|
|
280
|
-
def dig_delete!(obj, keys)
|
|
281
|
-
if keys.length == 1
|
|
282
|
-
return unless obj.respond_to?(:delete)
|
|
283
|
-
|
|
284
|
-
obj.delete(keys.first)
|
|
285
|
-
else
|
|
286
|
-
dig_delete!(obj[keys.first], keys[1..])
|
|
287
|
-
end
|
|
288
|
-
end
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
extend InstanceMethods
|
|
292
|
-
end
|
|
293
|
-
end
|
|
294
|
-
|
|
295
|
-
# rubocop:enable Naming/MethodParameterName
|
|
1
|
+
# rubocop:disable Naming/MethodParameterName
|
|
2
|
+
module Ecoportal::API::Common::GraphQL::Model::Diffable
|
|
3
|
+
# @note this is a literal copy of ecoportal-api-v2 gem `has_diff` function.
|
|
4
|
+
# @todo the aim is to adapt it by:
|
|
5
|
+
# 1. Removing the `patch_ver` model ✅
|
|
6
|
+
# 2. Using symbol keys ✅
|
|
7
|
+
module HashDiffNesting
|
|
8
|
+
class << self
|
|
9
|
+
def included(base)
|
|
10
|
+
super
|
|
11
|
+
|
|
12
|
+
base.send :include, InstanceMethods
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
META_KEYS = %i[id].freeze
|
|
17
|
+
NO_CHANGES = "%not-changed!%".freeze
|
|
18
|
+
|
|
19
|
+
module InstanceMethods
|
|
20
|
+
# The `change data` is built as follows:
|
|
21
|
+
# 1. detect changes that have occurred translate into one `api_operation` of `OP_TYPE`:
|
|
22
|
+
# * `:update`: meaning that the object has changed (existed and has not been removed)
|
|
23
|
+
# * `:delete`: the object has been removed
|
|
24
|
+
# * `:create`: the object is new
|
|
25
|
+
# 2. at the level of the target object of the model, the object is opened for change
|
|
26
|
+
# with `id` and `api_operation` as follows:
|
|
27
|
+
#
|
|
28
|
+
# ```json
|
|
29
|
+
# {
|
|
30
|
+
# "id": "objectID",
|
|
31
|
+
# "api_operation": "OP_TYPE",
|
|
32
|
+
# "change_data" {
|
|
33
|
+
# "property": "value",
|
|
34
|
+
# "...": "..."
|
|
35
|
+
# }
|
|
36
|
+
# }
|
|
37
|
+
# ```
|
|
38
|
+
# 3. the `change_data` property holds the specific changes of the object
|
|
39
|
+
# - the properties that have changed
|
|
40
|
+
# @note
|
|
41
|
+
# * there should not be difference between `null` and `""` (empty string)
|
|
42
|
+
# @param a [Hash] current hash model
|
|
43
|
+
# @param b [Hash] previous hash model
|
|
44
|
+
# @return [Hash] a `change data`
|
|
45
|
+
def change_diff(a, b, ignore: [])
|
|
46
|
+
ignore = to_a(ignore)
|
|
47
|
+
|
|
48
|
+
if b.is_a?(Hash) && !empty?(b) && empty?(a)
|
|
49
|
+
patch_delete(b)
|
|
50
|
+
elsif a.is_a?(Hash) && !empty?(a) && empty?(b)
|
|
51
|
+
patch_new(a, ignore: ignore)
|
|
52
|
+
elsif a.is_a?(Hash) && b.is_a?(Hash)
|
|
53
|
+
patch_update(a, b, ignore: ignore)
|
|
54
|
+
elsif any_array?(a, b)
|
|
55
|
+
patch_data_array(a, b, ignore: ignore)
|
|
56
|
+
else
|
|
57
|
+
a
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
# Compares `a` as carrying changes of `b`
|
|
64
|
+
# @return [Hash] change data object with only changes
|
|
65
|
+
def change_data(a, b = nil, delete: false, ignore: [])
|
|
66
|
+
{}.tap do |data_hash|
|
|
67
|
+
next if delete
|
|
68
|
+
|
|
69
|
+
a.each do |key, a_value|
|
|
70
|
+
key = key.to_sym
|
|
71
|
+
|
|
72
|
+
next if meta_keys.include?(key)
|
|
73
|
+
next if ignore.include?(key)
|
|
74
|
+
|
|
75
|
+
b_value = nil
|
|
76
|
+
|
|
77
|
+
if b&.key?(key)
|
|
78
|
+
b_value = b[key]
|
|
79
|
+
next if equal_values?(a_value, b_value)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
data_hash[key] = change_diff(a_value, b_value)
|
|
83
|
+
|
|
84
|
+
data_hash.delete(key) if data_hash[key] == NO_CHANGES
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
return NO_CHANGES if (data_hash.keys - meta_keys).empty?
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def patch_delete(b)
|
|
92
|
+
return NO_CHANGES unless b.is_a?(Hash)
|
|
93
|
+
return unless (id = get_id(b, exception: false))
|
|
94
|
+
|
|
95
|
+
{
|
|
96
|
+
id: id,
|
|
97
|
+
api_operation: :delete,
|
|
98
|
+
change_data: change_data(b, delete: true)
|
|
99
|
+
}
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def patch_new(a, ignore: [])
|
|
103
|
+
return NO_CHANGES unless a.is_a?(Hash)
|
|
104
|
+
return a unless (id = get_id(a, exception: false))
|
|
105
|
+
|
|
106
|
+
{
|
|
107
|
+
id: id,
|
|
108
|
+
api_operation: :create,
|
|
109
|
+
change_data: change_data(a, ignore: ignore)
|
|
110
|
+
}
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def patch_update(a, b, ignore: [])
|
|
114
|
+
return NO_CHANGES unless a.is_a?(Hash)
|
|
115
|
+
return a unless (id = get_id(a, exception: false))
|
|
116
|
+
|
|
117
|
+
{
|
|
118
|
+
id: id,
|
|
119
|
+
api_operation: :update,
|
|
120
|
+
change_data: change_data(a, b, ignore: ignore)
|
|
121
|
+
}.tap do |update_hash|
|
|
122
|
+
return nil unless update_hash[:change_data] != NO_CHANGES
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def patch_data_array(a, b, ignore: [])
|
|
127
|
+
return patch_data_nested_array(a, b, ignore: ignore) if nested_array?(a, b)
|
|
128
|
+
|
|
129
|
+
patch_data_flat_array(a, b)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def patch_data_flat_array(a, b)
|
|
133
|
+
original_b = b
|
|
134
|
+
a ||= []
|
|
135
|
+
b ||= []
|
|
136
|
+
|
|
137
|
+
same_elements =
|
|
138
|
+
a.length == b.length &&
|
|
139
|
+
(a & b).length == b.length
|
|
140
|
+
|
|
141
|
+
return a unless same_elements
|
|
142
|
+
return NO_CHANGES if original_b
|
|
143
|
+
|
|
144
|
+
a
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def patch_data_nested_array(a, b, ignore: [])
|
|
148
|
+
a ||= []
|
|
149
|
+
b ||= []
|
|
150
|
+
|
|
151
|
+
# array with nested elements
|
|
152
|
+
a_ids = array_ids(a)
|
|
153
|
+
b_ids = array_ids(b)
|
|
154
|
+
|
|
155
|
+
del_ids = b_ids - a_ids
|
|
156
|
+
oth_ids = b_ids & a_ids
|
|
157
|
+
new_ids = a_ids - b_ids
|
|
158
|
+
|
|
159
|
+
arr_delete = del_ids.map do |id|
|
|
160
|
+
patch_delete(array_id_item(b, id))
|
|
161
|
+
end.compact
|
|
162
|
+
|
|
163
|
+
arr_update = oth_ids.map do |id|
|
|
164
|
+
patch_update(array_id_item(a, id), array_id_item(b, id), ignore: ignore)
|
|
165
|
+
end.compact
|
|
166
|
+
|
|
167
|
+
arr_new = new_ids.map do |id|
|
|
168
|
+
patch_new(array_id_item(a, id), ignore: ignore)
|
|
169
|
+
end.compact
|
|
170
|
+
|
|
171
|
+
arr_delete.concat(arr_update).concat(arr_new).tap do |patch_array|
|
|
172
|
+
# remove data with no `id`
|
|
173
|
+
patch_array.select! {|item| item.is_a?(Hash)}
|
|
174
|
+
return NO_CHANGES if patch_array.empty?
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def nested_array?(*arr)
|
|
179
|
+
if arr.length > 1
|
|
180
|
+
arr.any? {|a| nested_array?(a)}
|
|
181
|
+
elsif arr.length == 1
|
|
182
|
+
arr = arr.first || []
|
|
183
|
+
arr.any? do |item|
|
|
184
|
+
next false unless item.is_a?(Hash)
|
|
185
|
+
next true if item.key?(:id)
|
|
186
|
+
|
|
187
|
+
false
|
|
188
|
+
end
|
|
189
|
+
else
|
|
190
|
+
false
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def any_array?(a, b)
|
|
195
|
+
[a, b].any?(Array)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def get_id(doc, exception: true)
|
|
199
|
+
id = nil
|
|
200
|
+
id ||= doc.id if doc.respond_to?(:id)
|
|
201
|
+
id ||= doc['id'] if doc.is_a?(Hash)
|
|
202
|
+
id ||= doc[:id] if doc.is_a?(Hash)
|
|
203
|
+
id ||= doc if doc.is_a?(String)
|
|
204
|
+
|
|
205
|
+
raise 'No ID has been given!' unless id || !exception
|
|
206
|
+
|
|
207
|
+
id
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# @param arr [Array] the source Array of id-bearing items
|
|
211
|
+
# @return [Array<String>] the `id`s thereof
|
|
212
|
+
def array_ids(arr)
|
|
213
|
+
return [] if !arr.is_a?(Array) || arr.empty?
|
|
214
|
+
|
|
215
|
+
arr.map {|item| get_id(item, exception: false)}
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# @param arr [Array] the source Array
|
|
219
|
+
# @return [Integer, nil] the position of the item with the given `id`
|
|
220
|
+
def array_id_index(arr, id)
|
|
221
|
+
return unless arr.is_a?(Array)
|
|
222
|
+
|
|
223
|
+
arr.index {|item| get_id(item, exception: false) == id}
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# @param arr [Array] the source Array
|
|
227
|
+
# @return [Object, nil] the item with the given `id`
|
|
228
|
+
def array_id_item(arr, id)
|
|
229
|
+
return unless (idx = array_id_index(arr, id))
|
|
230
|
+
|
|
231
|
+
arr[idx]
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def meta_keys
|
|
235
|
+
return self::META_KEYS if respond_to?(:const_get)
|
|
236
|
+
|
|
237
|
+
self.class::META_KEYS
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def equal_values?(a, b)
|
|
241
|
+
if a.is_a?(String) || b.is_a?(String)
|
|
242
|
+
a_empty = a.to_s.strip.empty?
|
|
243
|
+
b_empty = b.to_s.strip.empty?
|
|
244
|
+
|
|
245
|
+
return true if a_empty && b_empty
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
a == b
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def empty?(a)
|
|
252
|
+
bool = !a
|
|
253
|
+
bool ||= a.respond_to?(:empty?) && a.empty?
|
|
254
|
+
bool
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def to_a(*values)
|
|
258
|
+
[values].flatten.compact.uniq
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Hash path helpers — used by DiffService#diff_reduce to navigate
|
|
262
|
+
# and modify nested result hashes during cascaded diffing.
|
|
263
|
+
|
|
264
|
+
def dig_path?(obj, keys)
|
|
265
|
+
return false unless obj.is_a?(Hash)
|
|
266
|
+
return obj.key?(keys.first) if keys.length == 1
|
|
267
|
+
return false unless obj.key?(keys.first)
|
|
268
|
+
|
|
269
|
+
dig_path?(obj[keys.first], keys[1..])
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def dig_set!(obj, keys, value)
|
|
273
|
+
if keys.length == 1
|
|
274
|
+
obj[keys.first] = value
|
|
275
|
+
else
|
|
276
|
+
dig_set!(obj[keys.first], keys[1..], value)
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def dig_delete!(obj, keys)
|
|
281
|
+
if keys.length == 1
|
|
282
|
+
return unless obj.respond_to?(:delete)
|
|
283
|
+
|
|
284
|
+
obj.delete(keys.first)
|
|
285
|
+
else
|
|
286
|
+
dig_delete!(obj[keys.first], keys[1..])
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
extend InstanceMethods
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
# rubocop:enable Naming/MethodParameterName
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
module Ecoportal::API::Common::GraphQL::Model::Diffable
|
|
2
|
+
# Diff strategy for models whose *array* attributes are leaf DATA, not nested
|
|
3
|
+
# `GraphQL::Model` children.
|
|
4
|
+
#
|
|
5
|
+
# Array attributes declared with `passarray` (tag lists, id lists, config lists)
|
|
6
|
+
# — and `embeds_many` id-collections written as a whole set (e.g. page `locations`)
|
|
7
|
+
# — are registered as *cascaded* attributes. The default `DiffService`:
|
|
8
|
+
# 1. strips cascaded keys from the flat classic diff
|
|
9
|
+
# (`doc_with_non_cascaded_attributes`), on the assumption that a later
|
|
10
|
+
# `diff_reduce` pass re-adds them by cascading into nested `GraphQL::Model`
|
|
11
|
+
# children; and
|
|
12
|
+
# 2. in `diff_reduce`, deletes the flat placeholder for every cascaded key and
|
|
13
|
+
# only re-adds it when the child object `is_a?(GraphQL::Model)`.
|
|
14
|
+
# A `passarray` is wrapped as a v2 `ArrayModel` and a whole-set `embeds_many` as a
|
|
15
|
+
# `CollectionModel` — neither is a `GraphQL::Model`, so the re-add never happens and
|
|
16
|
+
# the array change becomes **invisible to `as_update`** (scalar `passthrough` fields
|
|
17
|
+
# are unaffected). This is the systemic "array/leaf fields don't diff" root cause
|
|
18
|
+
# (see `.ai-assistance/code/model_input_mapping/SYNTHESIS.md` §3.1).
|
|
19
|
+
#
|
|
20
|
+
# This service fixes it for leaf models by:
|
|
21
|
+
# 1. keeping cascaded keys in the flat classic diff (`doc_with_non_cascaded_attributes`
|
|
22
|
+
# is a no-op), and
|
|
23
|
+
# 2. overriding `diff_reduce` so the flat-diff placeholder for a NON-model leaf
|
|
24
|
+
# child is preserved (only real `GraphQL::Model` children are cascade-diffed;
|
|
25
|
+
# `root!` children are still dropped as independent entities), and
|
|
26
|
+
# 3. treating a leaf array as an OPAQUE value: a change replaces the whole array
|
|
27
|
+
# (a full-set replace), rather than the id-keyed nested update/delete/create
|
|
28
|
+
# patch-ops the default array diff would emit. This matches how the write inputs
|
|
29
|
+
# consume these arrays (`PageInput.otherTags`, `PageInput.locations = [{ id: }]`,
|
|
30
|
+
# register `filterTags`, PresetView `fieldConfigurations`).
|
|
31
|
+
#
|
|
32
|
+
# A model can either behave as a full leaf (call `dirty?`/`as_update` with
|
|
33
|
+
# `flat: true`, as `Base::Page::DataField` does — it has no nested `GraphQL::Model`
|
|
34
|
+
# children at all) or as a mixed model with both leaf arrays and real nested model
|
|
35
|
+
# children (page / register / preset view — the default cascaded `as_update` still
|
|
36
|
+
# recurses into the model children while the leaf arrays now diff inline).
|
|
37
|
+
class LeafDiffService < DiffService
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
# Keep all doc keys: leaf-field arrays are data, not nested models, so the flat
|
|
41
|
+
# classic diff must see them (the default strips every cascaded key).
|
|
42
|
+
def doc_with_non_cascaded_attributes(json)
|
|
43
|
+
json
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Treat array values as opaque leaves: emit the whole (current) array on any
|
|
47
|
+
# change, instead of the default id-keyed nested-array patch-ops. Non-array
|
|
48
|
+
# values fall through to the standard diff.
|
|
49
|
+
def change_diff(curr, prev, ignore: [])
|
|
50
|
+
return super unless curr.is_a?(Array) || prev.is_a?(Array)
|
|
51
|
+
return NO_CHANGES if same_array?(curr, prev)
|
|
52
|
+
|
|
53
|
+
keys_to_sym_deep(curr)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Full-set equality (order-insensitive), mirroring `patch_data_flat_array`.
|
|
57
|
+
def same_array?(curr, prev)
|
|
58
|
+
curr ||= []
|
|
59
|
+
prev ||= []
|
|
60
|
+
curr.length == prev.length && (curr & prev).length == prev.length
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Preserve the flat-diff placeholder for non-model leaf children; only
|
|
64
|
+
# cascade-diff real `GraphQL::Model` children, and still drop `root!` children.
|
|
65
|
+
def diff_reduce(init, ignore: [])
|
|
66
|
+
subject.cascaded_reduce(init, recurs: false) do |result, obj, _key, key_path, _trace|
|
|
67
|
+
next result if key_path.empty?
|
|
68
|
+
next result if obj == subject
|
|
69
|
+
|
|
70
|
+
sym_path = key_path.map(&:to_sym)
|
|
71
|
+
|
|
72
|
+
unless cascadeable_model?(obj)
|
|
73
|
+
# Leaf array (ArrayModel / CollectionModel) → keep the flat-diff value.
|
|
74
|
+
# A root! child is not mutation payload → drop its placeholder.
|
|
75
|
+
dig_delete!(result, sym_path) if root?(obj) && result && dig_path?(result, sym_path)
|
|
76
|
+
next result
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Remove the flat-diff placeholder before the child computes its own diff.
|
|
80
|
+
dig_delete!(result, sym_path) if result && dig_path?(result, sym_path)
|
|
81
|
+
|
|
82
|
+
value = obj.as_update(ignore: ignore)
|
|
83
|
+
next result if value.nil?
|
|
84
|
+
|
|
85
|
+
result ||= {}
|
|
86
|
+
result[:id] ||= get_id(keys_to_sym_deep(curr_doc(flat: true) || {}), exception: false)
|
|
87
|
+
dig_set!(result, sym_path, value)
|
|
88
|
+
result
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# A child worth cascading into: a non-root GraphQL::Model.
|
|
93
|
+
def cascadeable_model?(obj)
|
|
94
|
+
obj.is_a?(Ecoportal::API::Common::GraphQL::Model) && !root?(obj)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|