{
  "schemaVersion": "1.0",
  "metadata": {
    "id": "canvas_example",
    "title": "Çalışma alanı",
    "locale": "tr"
  },
  "compatibility": {
    "contract": "1.0",
    "requiredCapabilities": [
      "bar",
      "dashboard",
      "date",
      "datetime",
      "form",
      "kpi",
      "line",
      "message",
      "money",
      "navigate",
      "number",
      "percent",
      "settings",
      "table",
      "text",
      "boolean",
      "request",
      "canvas",
      "view"
    ]
  },
  "connections": {
    "crm": {
      "origin": "https://crm.example.test"
    }
  },
  "operations": {
    "login": {
      "connection": "crm",
      "method": "POST",
      "path": "/auth/login",
      "auth": "none",
      "response": {
        "data": "/data"
      },
      "body": {
        "email": {
          "kind": "binding",
          "source": "input",
          "pointer": "/email"
        },
        "password": {
          "kind": "binding",
          "source": "input",
          "pointer": "/password"
        }
      }
    },
    "refresh": {
      "connection": "crm",
      "method": "POST",
      "path": "/auth/refresh",
      "auth": "none",
      "response": {
        "data": "/data"
      },
      "body": {
        "refresh_token": {
          "kind": "binding",
          "source": "session",
          "pointer": "/refresh_token"
        }
      }
    },
    "me": {
      "connection": "crm",
      "method": "GET",
      "path": "/me",
      "auth": "session",
      "response": {
        "data": "/data"
      }
    },
    "customers_list": {
      "connection": "crm",
      "method": "GET",
      "path": "/customers",
      "auth": "session",
      "response": {
        "data": "/data"
      }
    },
    "customer_update": {
      "connection": "crm",
      "method": "PATCH",
      "path": "/customers/{id}",
      "auth": "session",
      "response": {
        "data": "/data",
        "fieldErrors": "/error/fields"
      },
      "pathParams": {
        "id": {
          "kind": "binding",
          "source": "record",
          "pointer": "/id"
        }
      },
      "body": {
        "name": {
          "kind": "binding",
          "source": "form",
          "pointer": "/name"
        },
        "company": {
          "kind": "binding",
          "source": "form",
          "pointer": "/company"
        }
      }
    },
    "companies_search": {
      "connection": "crm",
      "method": "GET",
      "path": "/companies",
      "auth": "session",
      "response": {
        "data": "/data",
        "nextCursor": "/next"
      },
      "query": {
        "q": {
          "kind": "binding",
          "source": "input",
          "pointer": "/search"
        }
      },
      "pagination": {
        "mode": "cursor",
        "parameter": "cursor",
        "pageSize": 25
      }
    },
    "settings_load": {
      "connection": "crm",
      "method": "GET",
      "path": "/settings",
      "auth": "session",
      "response": {
        "data": "/data"
      }
    },
    "settings_save": {
      "connection": "crm",
      "method": "PATCH",
      "path": "/settings",
      "auth": "session",
      "response": {
        "data": "/data",
        "fieldErrors": "/error/fields"
      },
      "body": {
        "title": {
          "kind": "binding",
          "source": "form",
          "pointer": "/title"
        }
      }
    },
    "logout": {
      "connection": "crm",
      "method": "POST",
      "path": "/auth/logout",
      "auth": "session",
      "response": {
        "data": "/data"
      },
      "body": {
        "refresh_token": {
          "kind": "binding",
          "source": "session",
          "pointer": "/refresh_token"
        }
      }
    },
    "invoices_list": {
      "connection": "crm",
      "method": "GET",
      "path": "/invoices",
      "auth": "session",
      "response": {
        "data": "/data"
      }
    },
    "invoice_update": {
      "connection": "crm",
      "method": "PATCH",
      "path": "/invoices/{id}",
      "auth": "session",
      "response": {
        "data": "/data",
        "fieldErrors": "/error/fields"
      },
      "pathParams": {
        "id": {
          "kind": "binding",
          "source": "record",
          "pointer": "/id"
        }
      },
      "body": {
        "name": {
          "kind": "binding",
          "source": "form",
          "pointer": "/name"
        },
        "amount": {
          "kind": "binding",
          "source": "form",
          "pointer": "/amount"
        },
        "tax": {
          "kind": "binding",
          "source": "form",
          "pointer": "/tax"
        },
        "count": {
          "kind": "binding",
          "source": "form",
          "pointer": "/count"
        },
        "issued_on": {
          "kind": "binding",
          "source": "form",
          "pointer": "/issued_on"
        },
        "meeting_at": {
          "kind": "binding",
          "source": "form",
          "pointer": "/meeting_at"
        }
      }
    },
    "preferences_load": {
      "connection": "crm",
      "method": "GET",
      "path": "/preferences",
      "auth": "session",
      "response": {
        "data": "/data"
      }
    },
    "preferences_save": {
      "connection": "crm",
      "method": "PATCH",
      "path": "/preferences",
      "auth": "session",
      "response": {
        "data": "/data",
        "fieldErrors": "/error/fields"
      },
      "body": {
        "title": {
          "kind": "binding",
          "source": "form",
          "pointer": "/title"
        },
        "monthly_budget": {
          "kind": "binding",
          "source": "form",
          "pointer": "/monthly_budget"
        },
        "reminder_on": {
          "kind": "binding",
          "source": "form",
          "pointer": "/reminder_on"
        },
        "notify": {
          "kind": "binding",
          "source": "form",
          "pointer": "/notify"
        }
      }
    },
    "revenue": {
      "connection": "crm",
      "method": "GET",
      "path": "/metrics",
      "auth": "session",
      "response": {
        "data": "/data/revenue"
      }
    },
    "series": {
      "connection": "crm",
      "method": "GET",
      "path": "/metrics",
      "auth": "session",
      "response": {
        "data": "/data/series"
      }
    }
  },
  "auth": {
    "mode": "bearer",
    "connection": "crm",
    "login": "login",
    "refresh": "refresh",
    "me": "me",
    "tokenPointer": "/data/access_token",
    "refreshTokenPointer": "/data/refresh_token",
    "header": "Authorization",
    "prefix": "Bearer ",
    "subjectPointer": "/data/subject",
    "permissionsPointer": "/data/permissions",
    "tenantPointer": "/data/tenant",
    "logout": "logout"
  },
  "permissions": {
    "customers_read": "Müşterileri gör",
    "customers_write": "Müşterileri düzenle",
    "settings_write": "Şirket ayarlarını düzenle",
    "balance_read": "Bakiyeleri gör"
  },
  "rules": {},
  "actions": {
    "edit_invoice": {
      "type": "navigate",
      "view": "invoice_edit",
      "permission": "customers_write"
    },
    "save_invoice": {
      "type": "request",
      "operation": "invoice_update",
      "permission": "customers_write",
      "next": "saved"
    },
    "saved": {
      "type": "message",
      "text": "Kaydedildi"
    },
    "show_invoices": {
      "type": "navigate",
      "view": "invoices"
    }
  },
  "resources": {
    "invoices": {
      "label": "Faturalar",
      "list": "invoices_list",
      "update": "invoice_update",
      "access": {
        "read": "customers_read",
        "write": "customers_write"
      },
      "fields": {
        "name": {
          "type": "text",
          "label": "Açıklama",
          "required": true
        },
        "amount": {
          "type": "money",
          "label": "Tutar",
          "required": true,
          "number": {
            "scale": 2,
            "rounding": "half_even",
            "currency": "TRY",
            "min": "0",
            "max": "1000000000000000000"
          },
          "access": {
            "read": "balance_read",
            "write": "customers_write"
          }
        },
        "tax": {
          "type": "percent",
          "label": "Vergi oranı",
          "number": {
            "scale": 3,
            "rounding": "half_up",
            "min": "0",
            "max": "100"
          }
        },
        "count": {
          "type": "number",
          "label": "Adet",
          "number": {
            "scale": 0,
            "rounding": "down",
            "min": "0",
            "max": "1000000"
          }
        },
        "issued_on": {
          "type": "date",
          "label": "Fatura tarihi",
          "required": true
        },
        "meeting_at": {
          "type": "datetime",
          "label": "Görüşme zamanı"
        }
      }
    }
  },
  "views": {
    "invoices": {
      "type": "table",
      "title": "Faturalar",
      "resource": "invoices",
      "columns": [
        "name",
        "amount",
        "issued_on"
      ],
      "actions": [
        "edit_invoice"
      ]
    },
    "invoice_edit": {
      "type": "form",
      "title": "Faturayı düzenle",
      "resource": "invoices",
      "fields": [
        "name",
        "amount",
        "tax",
        "count",
        "issued_on",
        "meeting_at"
      ],
      "actions": [
        "save_invoice"
      ]
    },
    "preferences": {
      "type": "settings",
      "title": "Şirket tercihleri",
      "settingsGroup": "preferences"
    },
    "overview": {
      "type": "canvas",
      "title": "Genel bakış",
      "access": {
        "read": "balance_read"
      },
      "widgets": [
        {
          "type": "kpi",
          "title": "Toplam tutar",
          "operation": "revenue",
          "valuePointer": "",
          "clickAction": "show_invoices"
        },
        {
          "type": "bar",
          "title": "Aylık tutarlar",
          "operation": "series",
          "labelPointer": "/label",
          "valuePointer": "/value",
          "clickAction": "show_invoices"
        },
        {
          "type": "line",
          "title": "Tutar eğilimi",
          "operation": "series",
          "labelPointer": "/label",
          "valuePointer": "/value"
        },
        {
          "type": "view",
          "title": "Son faturalar",
          "view": "invoices",
          "height": 480
        }
      ]
    }
  },
  "settings": {
    "preferences": {
      "title": "Şirket tercihleri",
      "scope": "tenant",
      "load": "preferences_load",
      "save": "preferences_save",
      "access": {
        "read": "customers_read",
        "write": "settings_write"
      },
      "fields": {
        "title": {
          "type": "text",
          "label": "Şirket adı",
          "required": true
        },
        "monthly_budget": {
          "type": "money",
          "label": "Aylık bütçe",
          "number": {
            "scale": 2,
            "rounding": "half_even",
            "currency": "TRY",
            "min": "0"
          },
          "access": {
            "read": "balance_read",
            "write": "settings_write"
          }
        },
        "reminder_on": {
          "type": "date",
          "label": "Hatırlatma tarihi"
        },
        "notify": {
          "type": "boolean",
          "label": "Bildirimleri etkinleştir"
        }
      }
    }
  },
  "navigation": [
    {
      "label": "Çalışma alanı",
      "view": "overview"
    }
  ]
}
