{
    "schema": "1.0",
    "key": "comment-on-multiple-items",
    "title": "Comment on multiple items",
    "userInputs": [
        {
            "key": "comment",
            "title": "Comment",
            "description": "",
            "required": true,
            "type": "TEXT",
            "default": "Hello"
        }
    ],
    "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_comment_threads",
            "description": "Generate comment threads",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "data": {
                    "message": "${workflow.input.comment}",
                    "suggestions": "${find_suggestions.output.result.json}"
                },
                "queryExpression": ".data.message as $msg\n| {\n    operations: (\n      .data.suggestions\n      | to_entries\n      | map({\n          key: ((.key + 1) | tostring),\n          element: {\n            comments: [{ message: $msg }],\n            targetId: .value.id,\n            targetType: \"suggestion\",\n            object: \"comment_thread\"\n          }\n        })\n    )\n  }"
            }
        },
        {
            "name": "data-comment-thread-create",
            "taskReferenceName": "create_comment_threads",
            "description": "Create comment threads",
            "type": "SUB_WORKFLOW",
            "optional": false,
            "inputParameters": {
                "request": {
                    "method": "INLINE",
                    "contentType": "application/json",
                    "model": "default",
                    "json": {
                        "operations": "${generate_comment_threads.output.result.operations}"
                    }
                }
            }
        }
    ]
}
