{
    "schema": "1.0",
    "key": "appl-all-suggestions-on-a-set-of-items",
    "title": "Apply all suggestions on a set of items",
    "tasks": [
        {
            "name": "data-suggestion-find",
            "taskReferenceName": "find_suggestions",
            "description": "Find suggestions for the given items",
            "type": "SUB_WORKFLOW",
            "optional": false,
            "inputParameters": {
                "findMode": "REQUEST",
                "request": {
                    "method": "INLINE",
                    "contentType": "application/json",
                    "json": {
                        "criteria": {
                            "type": "in",
                            "caseSensitive": true,
                            "field": "toItemId",
                            "value": "${workflow.input.context.selection.ids}"
                        }
                    }
                }
            }
        },
        {
            "name": "json-transform-jq",
            "taskReferenceName": "generate_operations",
            "description": "Generate comment threads",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "data": {
                    "suggestions": "${find_suggestions.output.result.json}"
                },
                "queryExpression": "{\n    operations: (\n      .data.suggestions\n      | to_entries\n      | map({\n          key: ((.key + 1) | tostring),\n          context: {\n            suggestionId: .value.id\n          },\n          element: {\n            isAcknowledged: true\n          }\n        })\n    )\n  }"
            }
        },
        {
            "name": "data-suggestion-apply-all",
            "taskReferenceName": "apply_all_suggestions",
            "description": "Apply all suggestions",
            "type": "SUB_WORKFLOW",
            "optional": false,
            "inputParameters": {
                "request": {
                    "method": "INLINE",
                    "contentType": "application/json",
                    "model": "default",
                    "json": {
                        "operations": "${generate_operations.output.result.operations}"
                    }
                }
            }
        }
    ]
}
