{
  "name": "musicteam",
  "label": "MusicTeam",
  "description": "Management of collaboration and contribution data for artists",
  "version": "0.0.0",
  "infoUrl": "https://musicteam.org/",
  "maintainer": "Kendraio",
  "supportUrl": "https://kendra.io",
  "database": [],
  "dashboard": {
    "icon": "brightness_5",
    "label": "MusicTeam",
    "workflowId": "dashboard"
  },
  "services": [
    {
      "label": "Import",
      "icon": "cloud_upload",
      "workflowId": "import"
    },
    {
      "label": "Contributors",
      "icon": "file_copy",
      "workflowId": "contributors"
    },
    {
      "label": "Recordings",
      "icon": "file_copy",
      "workflowId": "recordings"
    },
    {
      "label": "Works",
      "icon": "file_copy",
      "workflowId": "works"
    }
  ],
  "workflow": [
    {
      "title": "Dashboard",
      "workflowId": "dashboard",
      "config": "configs/dashboard.json"
    },
    {
      "title": "Recordings",
      "workflowId": "recordings",
      "config": "configs/recordings.json"
    },
    {
      "title": "Works",
      "workflowId": "works",
      "config": "configs/works.json"
    },
    {
      "title": "Contributors",
      "workflowId": "contributors",
      "config": "configs/contributors.json"
    },
    {
      "title": "Edit contributor",
      "workflowId": "editContributor",
      "config": "configs/editContributor.json"
    },
    {
      "title": "Edit recording",
      "workflowId": "editRecording",
      "config": "configs/editRecording.json"
    },
    {
      "title": "Edit work",
      "workflowId": "editWork",
      "config": "configs/editWork.json"
    },
    {
      "title": "Import",
      "workflowId": "import",
      "config": "configs/import.json"
    }
  ],
  "forms": [],
  "tags": [
    "music",
    "b2b",
    "demo"
  ],
  "attachments": {
    "configs/contributors.json": {
      "title": "MusicTeam contributors",
      "blocks": [
        {
          "type": "init"
        },
        {
          "type": "db",
          "operation": "get",
          "adapterName": "MusicTeam",
          "schema": "contributors"
        },
        {
          "type": "grid",
          "gridOptions": {},
          "columnDefs": [
            {
              "headerName": "Name",
              "field": "name"
            },
            {
              "headerName": "Role",
              "field": "role"
            },
            {
              "headerName": "Operations",
              "cellRenderer": "workflowRenderer",
              "cellRendererParams": {
                "blocks": [
                  {
                    "type": "actions",
                    "buttons": [
                      {
                        "label": "View",
                        "blocks": [
                          {
                            "type": "dialog",
                            "blocks": [
                              {
                                "type": "debug"
                              },
                              {
                                "type": "actions",
                                "buttons": [
                                  {
                                    "label": "OK",
                                    "blocks": [
                                      {
                                        "type": "init"
                                      }
                                    ]
                                  }
                                ]
                              }
                            ]
                          }
                        ]
                      },
                      {
                        "label": "Edit",
                        "blocks": [
                          {
                            "type": "launch",
                            "adapter": "musicteam",
                            "workflowId": "editContributor",
                            "context": {
                              "uuid": "data.uuid"
                            }
                          }
                        ]
                      },
                      {
                        "label": "Delete",
                        "blocks": [
                          {
                            "type": "dialog",
                            "blocks": [
                              {
                                "type": "message",
                                "title": "Are you sure you want to delete {{name}}?",
                                "message": "This action cannot be undone."
                              },
                              {
                                "type": "actions",
                                "buttons": [
                                  {
                                    "label": "Delete",
                                    "color": "warn",
                                    "blocks": [
                                      {
                                        "type": "db",
                                        "operation": "delete",
                                        "uuidGetter": "data.uuid"
                                      },
                                      {
                                        "type": "dispatch",
                                        "action": "refreshWorkflow"
                                      }
                                    ]
                                  },
                                  {
                                    "label": "Cancel",
                                    "blocks": [
                                      {
                                        "type": "init"
                                      }
                                    ]
                                  }
                                ]
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            }
          ]
        },
        {
          "type": "actions",
          "buttons": [
            {
              "label": "Add contributor",
              "blocks": [
                {
                  "type": "mapping",
                  "mapping": "{ uuid: uuid(), title: 'New contributor' }"
                },
                {
                  "type": "db",
                  "operation": "add",
                  "adapterName": "MusicTeam",
                  "schema": "contributors"
                },
                {
                  "type": "dispatch",
                  "action": "refreshWorkflow"
                }
              ]
            }
          ]
        }
      ]
    },
    "configs/dashboard.json": {
      "title": "MusicTeam dashboard",
      "blocks": [
        {
          "type": "init"
        },
        {
          "type": "multi",
          "batches": [
            {
              "blocks": [
                {
                  "type": "db",
                  "operation": "get",
                  "adapterName": "MusicTeam",
                  "schema": "contributors"
                }
              ]
            },
            {
              "blocks": [
                {
                  "type": "db",
                  "operation": "get",
                  "adapterName": "MusicTeam",
                  "schema": "recordings"
                }
              ]
            },
            {
              "blocks": [
                {
                  "type": "db",
                  "operation": "get",
                  "adapterName": "MusicTeam",
                  "schema": "works"
                }
              ]
            }
          ]
        },
        {
          "type": "mapping",
          "//debug": true,
          "mapping": {
            "[": [
              {
                "label": "'Contributors'",
                "value": "length(data[0])"
              },
              {
                "label": "'Recordings'",
                "value": "length(data[1])"
              },
              {
                "label": "'Works'",
                "value": "length(data[2])"
              }
            ]
          }
        },
        {
          "type": "debug"
        },
        {
          "type": "chart"
        }
      ]
    },
    "configs/editContributor.json": {
      "title": "MusicTeam edit contributor",
      "blocks": [
        {
          "type": "init"
        },
        {
          "type": "db",
          "operation": "fetch",
          "uuidGetter": "context.queryParams.uuid"
        },
        {
          "type": "mapping",
          "mapping": "data[0]"
        },
        {
          "type": "form",
          "hasSubmit": false,
          "emitOnInit": true,
          "jsonSchema": {
            "type": "object",
            "properties": {
              "uuid": {
                "title": "uuid",
                "type": "string"
              },
              "name": {
                "title": "Name",
                "type": "string"
              },
              "role": {
                "title": "Role",
                "type": "string",
                "enum": [
                  "artist",
                  "publisher",
                  "collaborator",
                  "creator"
                ]
              },
              "isni_number": {
                "title": "ISNI",
                "type": "string"
              },
              "email": {
                "title": "Email",
                "type": "string"
              }
            }
          },
          "uiSchema": {
            "uuid": {
              "ui:disabled": true
            },
            "owners": {
              "items": {
                "uuid": {
                  "ui:widget": "blocks",
                  "blocksConfig": {
                    "blocks": [
                      {
                        "type": "init"
                      },
                      {
                        "type": "db",
                        "operation": "get",
                        "adapterName": "MusicTeam",
                        "schema": "contributors"
                      },
                      {
                        "type": "reference",
                        "fieldLabel": "Contributor",
                        "labelField": "name",
                        "valueField": "uuid"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        {
          "type": "actions",
          "buttons": [
            {
              "label": "Save",
              "color": "primary",
              "blocks": [
                {
                  "type": "db",
                  "operation": "update",
                  "uuidGetter": "uuid"
                }
              ]
            },
            {
              "label": "Cancel",
              "blocks": [
                {
                  "type": "init"
                }
              ]
            }
          ]
        },
        {
          "type": "launch",
          "adapter": "musicteam",
          "workflowId": "contributors"
        }
      ],
      "id": "editWork"
    },
    "configs/editRecording.json": {
      "title": "MusicTeam edit recording",
      "blocks": [
        {
          "type": "init"
        },
        {
          "type": "db",
          "operation": "fetch",
          "uuidGetter": "context.queryParams.uuid"
        },
        {
          "type": "mapping",
          "mapping": "data[0]"
        },
        {
          "type": "form",
          "hasSubmit": false,
          "emitOnInit": true,
          "jsonSchema": {
            "type": "object",
            "properties": {
              "uuid": {
                "title": "uuid",
                "type": "string"
              },
              "title": {
                "title": "Title",
                "type": "string"
              },
              "isrc": {
                "title": "ISRC",
                "type": "string"
              },
              "owners": {
                "title": "Owners",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "uuid": {
                      "title": "Owner",
                      "type": "string"
                    },
                    "split": {
                      "title": "Split",
                      "type": "integer"
                    }
                  }
                }
              },
              "related_works": {
                "title": "Related works",
                "type": "array",
                "items": {
                  "title": "Related work",
                  "type": "string"
                }
              }
            }
          },
          "uiSchema": {
            "uuid": {
              "ui:disabled": true
            },
            "owners": {
              "ui:widget": "table",
              "colHeadings": [
                "Owner",
                "Split"
              ],
              "blocks": [
                {
                  "type": "actions",
                  "buttons": [
                    {
                      "label": "Edit",
                      "blocks": [
                        {
                          "type": "launch",
                          "adapter": "musicteam",
                          "workflowId": "editContributor",
                          "context": {
                            "uuid": "data.uuid"
                          }
                        }
                      ]
                    }
                  ]
                }
              ],
              "items": {
                "uuid": {
                  "ui:widget": "blocks",
                  "blocksConfig": {
                    "blocks": [
                      {
                        "type": "init"
                      },
                      {
                        "type": "db",
                        "operation": "get",
                        "adapterName": "MusicTeam",
                        "schema": "contributors"
                      },
                      {
                        "type": "reference",
                        "fieldLabel": "Contributor",
                        "labelField": "name",
                        "valueField": "uuid"
                      }
                    ]
                  }
                }
              }
            },
            "related_works": {
              "ui:widget": "table",
              "colHeadings": [
                "Related work"
              ],
              "blocks": [
                {
                  "type": "actions",
                  "buttons": [
                    {
                      "label": "Edit",
                      "blocks": [
                        {
                          "type": "launch",
                          "adapter": "musicteam",
                          "workflowId": "editWork",
                          "context": {
                            "uuid": "data"
                          }
                        }
                      ]
                    }
                  ]
                }
              ],
              "items": {
                "ui:widget": "blocks",
                "blocksConfig": {
                  "blocks": [
                    {
                      "type": "init"
                    },
                    {
                      "type": "db",
                      "operation": "get",
                      "adapterName": "MusicTeam",
                      "schema": "works"
                    },
                    {
                      "type": "reference",
                      "fieldLabel": "Work",
                      "labelField": "title",
                      "valueField": "uuid"
                    }
                  ]
                }
              }
            }
          }
        },
        {
          "type": "actions",
          "buttons": [
            {
              "label": "Save",
              "color": "primary",
              "blocks": [
                {
                  "type": "db",
                  "operation": "update",
                  "uuidGetter": "uuid"
                }
              ]
            },
            {
              "label": "Cancel",
              "blocks": [
                {
                  "type": "init"
                }
              ]
            }
          ]
        },
        {
          "type": "launch",
          "adapter": "musicteam",
          "workflowId": "recordings"
        }
      ],
      "id": "editRecording"
    },
    "configs/editWork.json": {
      "title": "MusicTeam edit work",
      "blocks": [
        {
          "type": "init"
        },
        {
          "type": "db",
          "operation": "fetch",
          "uuidGetter": "context.queryParams.uuid"
        },
        {
          "type": "mapping",
          "mapping": "data[0]"
        },
        {
          "type": "form",
          "hasSubmit": false,
          "emitOnInit": true,
          "jsonSchema": {
            "type": "object",
            "properties": {
              "uuid": {
                "title": "uuid",
                "type": "string"
              },
              "title": {
                "title": "Title",
                "type": "string"
              },
              "iswc": {
                "title": "ISWC",
                "type": "string"
              },
              "owners": {
                "title": "Owners",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "uuid": {
                      "title": "Owner",
                      "type": "string"
                    },
                    "split": {
                      "title": "Split",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "uiSchema": {
            "uuid": {
              "ui:disabled": true
            },
            "owners": {
              "ui:widget": "table",
              "colHeadings": [
                "Owner",
                "Split"
              ],
              "blocks": [
                {
                  "type": "actions",
                  "buttons": [
                    {
                      "label": "Edit",
                      "blocks": [
                        {
                          "type": "launch",
                          "adapter": "musicteam",
                          "workflowId": "editContributor",
                          "context": {
                            "uuid": "data.uuid"
                          }
                        }
                      ]
                    }
                  ]
                }
              ],
              "items": {
                "uuid": {
                  "ui:widget": "blocks",
                  "blocksConfig": {
                    "blocks": [
                      {
                        "type": "init"
                      },
                      {
                        "type": "db",
                        "operation": "get",
                        "adapterName": "MusicTeam",
                        "schema": "contributors"
                      },
                      {
                        "type": "reference",
                        "fieldLabel": "Contributor",
                        "labelField": "name",
                        "valueField": "uuid"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        {
          "type": "actions",
          "buttons": [
            {
              "label": "Save",
              "color": "primary",
              "blocks": [
                {
                  "type": "db",
                  "operation": "update",
                  "uuidGetter": "uuid"
                }
              ]
            },
            {
              "label": "Cancel",
              "blocks": [
                {
                  "type": "init"
                }
              ]
            }
          ]
        },
        {
          "type": "launch",
          "adapter": "musicteam",
          "workflowId": "works"
        }
      ],
      "id": "editWork"
    },
    "configs/import.json": {
      "title": "MusicTeam import",
      "blocks": [
        {
          "type": "message",
          "message": "This workflow will accept JSON data as provided by the MusicTeam system."
        },
        {
          "type": "file-input",
          "label": "Load JSON",
          "accept": [
            "json"
          ]
        },
        {
          "type": "parse-data",
          "csvOptions": {
            "header": true,
            "skipEmptyLines": true
          },
          "xmlOptions": {}
        },
        {
          "type": "mapping",
          "mapping": "data.{ work: merge(work, { uuid: uuid(), owners: work.owners[].merge(@, { uuid: uuid() }) }), recording: merge(recording, { uuid: uuid(), owners: recording.owners[].merge(@, { uuid: uuid() }) }) }"
        },
        {
          "type": "multi",
          "batches": [
            {
              "blocks": [
                {
                  "type": "mapping",
                  "mapping": "data.work.merge(@, { owners: owners[].{ uuid: uuid, split: split } })"
                },
                {
                  "type": "db",
                  "operation": "add",
                  "adapterName": "MusicTeam",
                  "schema": "works",
                  "skipFirst": false
                }
              ]
            },
            {
              "blocks": [
                {
                  "type": "mapping",
                  "mapping": "merge(data.recording.merge(@, { owners: owners[].{ uuid: uuid, split: split } }), { related_works: [ data.work.uuid ] })"
                },
                {
                  "type": "db",
                  "operation": "add",
                  "adapterName": "MusicTeam",
                  "schema": "recordings",
                  "skipFirst": false
                }
              ]
            },
            {
              "blocks": [
                {
                  "type": "mapping",
                  "mapping": "[data.work.owners[], data.recording.owners[]][].omit(@, ['split'])"
                },
                {
                  "type": "batch",
                  "blocks": [
                    {
                      "type": "db",
                      "operation": "add",
                      "adapterName": "MusicTeam",
                      "schema": "contributors",
                      "skipFirst": false
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "type": "debug"
        }
      ]
    },
    "configs/recordings.json": {
      "title": "MusicTeam recordings",
      "blocks": [
        {
          "type": "init"
        },
        {
          "type": "db",
          "operation": "get",
          "adapterName": "MusicTeam",
          "schema": "recordings"
        },
        {
          "type": "grid",
          "gridOptions": {},
          "columnDefs": [
            {
              "headerName": "Title",
              "field": "title"
            },
            {
              "headerName": "ISRC",
              "field": "isrc"
            },
            {
              "headerName": "Operations",
              "cellRenderer": "workflowRenderer",
              "cellRendererParams": {
                "blocks": [
                  {
                    "type": "actions",
                    "buttons": [
                      {
                        "label": "View",
                        "blocks": [
                          {
                            "type": "dialog",
                            "blocks": [
                              {
                                "type": "debug"
                              },
                              {
                                "type": "actions",
                                "buttons": [
                                  {
                                    "label": "OK",
                                    "blocks": [
                                      {
                                        "type": "init"
                                      }
                                    ]
                                  }
                                ]
                              }
                            ]
                          }
                        ]
                      },
                      {
                        "label": "Edit",
                        "blocks": [
                          {
                            "type": "launch",
                            "adapter": "musicteam",
                            "workflowId": "editRecording",
                            "context": {
                              "uuid": "data.uuid"
                            }
                          }
                        ]
                      },
                      {
                        "label": "Delete",
                        "blocks": [
                          {
                            "type": "dialog",
                            "blocks": [
                              {
                                "type": "message",
                                "title": "Are you sure you want to delete {{title}}?",
                                "message": "This action cannot be undone."
                              },
                              {
                                "type": "actions",
                                "buttons": [
                                  {
                                    "label": "Delete",
                                    "color": "warn",
                                    "blocks": [
                                      {
                                        "type": "db",
                                        "operation": "delete",
                                        "uuidGetter": "data.uuid"
                                      },
                                      {
                                        "type": "dispatch",
                                        "action": "refreshWorkflow"
                                      }
                                    ]
                                  },
                                  {
                                    "label": "Cancel",
                                    "blocks": [
                                      {
                                        "type": "init"
                                      }
                                    ]
                                  }
                                ]
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            }
          ]
        },
        {
          "type": "actions",
          "buttons": [
            {
              "label": "Add recording",
              "blocks": [
                {
                  "type": "mapping",
                  "mapping": "{ uuid: uuid(), title: 'New recording' }"
                },
                {
                  "type": "db",
                  "operation": "add",
                  "adapterName": "MusicTeam",
                  "schema": "recordings"
                },
                {
                  "type": "dispatch",
                  "action": "refreshWorkflow"
                }
              ]
            }
          ]
        }
      ]
    },
    "configs/works.json": {
      "title": "MusicTeam works",
      "blocks": [
        {
          "type": "init"
        },
        {
          "type": "db",
          "operation": "get",
          "adapterName": "MusicTeam",
          "schema": "works"
        },
        {
          "type": "grid",
          "gridOptions": {},
          "columnDefs": [
            {
              "headerName": "Title",
              "field": "title"
            },
            {
              "headerName": "ISWC",
              "field": "iswc"
            },
            {
              "headerName": "Operations",
              "cellRenderer": "workflowRenderer",
              "cellRendererParams": {
                "blocks": [
                  {
                    "type": "actions",
                    "buttons": [
                      {
                        "label": "View",
                        "blocks": [
                          {
                            "type": "dialog",
                            "blocks": [
                              {
                                "type": "debug"
                              },
                              {
                                "type": "actions",
                                "buttons": [
                                  {
                                    "label": "OK",
                                    "blocks": [
                                      {
                                        "type": "init"
                                      }
                                    ]
                                  }
                                ]
                              }
                            ]
                          }
                        ]
                      },
                      {
                        "label": "Edit",
                        "blocks": [
                          {
                            "type": "launch",
                            "adapter": "musicteam",
                            "workflowId": "editWork",
                            "context": {
                              "uuid": "data.uuid"
                            }
                          }
                        ]
                      },
                      {
                        "label": "Delete",
                        "blocks": [
                          {
                            "type": "dialog",
                            "blocks": [
                              {
                                "type": "message",
                                "title": "Are you sure you want to delete {{title}}?",
                                "message": "This action cannot be undone."
                              },
                              {
                                "type": "actions",
                                "buttons": [
                                  {
                                    "label": "Delete",
                                    "color": "warn",
                                    "blocks": [
                                      {
                                        "type": "db",
                                        "operation": "delete",
                                        "uuidGetter": "data.uuid"
                                      },
                                      {
                                        "type": "dispatch",
                                        "action": "refreshWorkflow"
                                      }
                                    ]
                                  },
                                  {
                                    "label": "Cancel",
                                    "blocks": [
                                      {
                                        "type": "init"
                                      }
                                    ]
                                  }
                                ]
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            }
          ]
        },
        {
          "type": "actions",
          "buttons": [
            {
              "label": "Add work",
              "blocks": [
                {
                  "type": "mapping",
                  "mapping": "{ uuid: uuid(), title: 'New work' }"
                },
                {
                  "type": "db",
                  "operation": "add",
                  "adapterName": "MusicTeam",
                  "schema": "works"
                },
                {
                  "type": "dispatch",
                  "action": "refreshWorkflow"
                }
              ]
            }
          ]
        }
      ]
    }
  }
}