{
  "$schema": "./.schemas/page.schema.json",
  "title": "Vercel",
  "icon": "triangle.fill",
  "sources": {
    "team": {
      "url": "https://api.vercel.com",
      "secret": "vercel",
      "every": "1m",
      "requests": {
        "deploys": "/v7/deployments?limit=100&since={date.days_ago_6_unix}000"
      },
      "derive": [
        {
          "name": "rows",
          "value": {
            "each": "deploys.deployments",
            "limit": 4,
            "fields": {
              "is_candidate": {
                "if": {
                  "path": "candidate.uid",
                  "exists": true
                },
                "then": {
                  "template": "yes"
                },
                "else": {
                  "template": "no"
                }
              },
              "uid": "uid",
              "name": "name",
              "projectId": "projectId",
              "state": "state",
              "target": {
                "path": "target",
                "default": "preview"
              },
              "readySubstate": "readySubstate",
              "created": "created",
              "inspectorUrl": "inspectorUrl",
              "buildingAt": {
                "if": {
                  "path": "buildingAt",
                  "exists": true
                },
                "then": "buildingAt",
                "else": "created"
              },
              "ready": "ready",
              "message": {
                "if": {
                  "path": "meta.githubCommitMessage",
                  "exists": true
                },
                "then": "meta.githubCommitMessage",
                "else": {
                  "if": {
                    "path": "meta.gitlabCommitMessage",
                    "exists": true
                  },
                  "then": "meta.gitlabCommitMessage",
                  "else": {
                    "if": {
                      "path": "meta.bitbucketCommitMessage",
                      "exists": true
                    },
                    "then": "meta.bitbucketCommitMessage",
                    "else": {
                      "template": "{name}"
                    }
                  }
                }
              },
              "branch": {
                "if": {
                  "path": "meta.githubCommitRef",
                  "exists": true
                },
                "then": "meta.githubCommitRef",
                "else": {
                  "if": {
                    "path": "meta.gitlabCommitRef",
                    "exists": true
                  },
                  "then": "meta.gitlabCommitRef",
                  "else": {
                    "if": {
                      "path": "meta.bitbucketCommitRef",
                      "exists": true
                    },
                    "then": "meta.bitbucketCommitRef",
                    "else": {
                      "if": {
                        "path": "target",
                        "equals": "production"
                      },
                      "then": {
                        "template": "Production"
                      },
                      "else": {
                        "template": "Preview"
                      }
                    }
                  }
                }
              },
              "target_word": {
                "if": {
                  "path": "target",
                  "equals": "production"
                },
                "then": {
                  "template": "Production"
                },
                "else": {
                  "template": "Preview"
                }
              },
              "state_word": {
                "if": {
                  "all": [
                    {
                      "path": "state",
                      "equals": "READY"
                    },
                    {
                      "path": "readySubstate",
                      "equals": "STAGED"
                    },
                    {
                      "path": "target",
                      "equals": "production"
                    }
                  ]
                },
                "then": {
                  "template": "Staged"
                },
                "else": {
                  "if": {
                    "path": "state",
                    "in": [
                      "READY",
                      "ERROR",
                      "CANCELED",
                      "BUILDING",
                      "INITIALIZING",
                      "QUEUED",
                      "BLOCKED",
                      "DELETED"
                    ]
                  },
                  "then": {
                    "path": "state",
                    "values": {
                      "READY": "Ready",
                      "ERROR": "Failed",
                      "CANCELED": "Cancelled",
                      "BUILDING": "Building",
                      "INITIALIZING": "Building",
                      "QUEUED": "Queued",
                      "BLOCKED": "Blocked",
                      "DELETED": "Deleted"
                    }
                  },
                  "else": {
                    "template": "{state|title}"
                  }
                }
              }
            }
          }
        },
        {
          "name": "running_names",
          "value": {
            "join": "name",
            "of": "deploys.deployments",
            "where": {
              "path": "state",
              "in": [
                "QUEUED",
                "INITIALIZING",
                "BUILDING"
              ]
            },
            "sort": "name",
            "collapse": "name",
            "separator": ", "
          }
        },
        {
          "name": "running_count",
          "value": {
            "count": "deploys.deployments",
            "where": {
              "path": "state",
              "in": [
                "QUEUED",
                "INITIALIZING",
                "BUILDING"
              ]
            },
            "default": 0
          }
        },
        {
          "name": "oldest_read",
          "value": {
            "min": "created",
            "of": "deploys.deployments"
          }
        },
        {
          "name": "day_partial",
          "value": {
            "if": {
              "all": [
                {
                  "path": "deploys.pagination.next",
                  "exists": true
                },
                {
                  "value": {
                    "since": "oldest_read"
                  },
                  "lt": 86400
                }
              ]
            },
            "then": {
              "template": "yes"
            },
            "else": {
              "template": "no"
            }
          }
        },
        {
          "name": "day_count",
          "value": {
            "count": "deploys.deployments",
            "where": {
              "value": {
                "since": "created"
              },
              "lt": 86400
            },
            "default": 0
          }
        },
        {
          "name": "day_failed",
          "value": {
            "count": "deploys.deployments",
            "where": {
              "all": [
                {
                  "value": {
                    "since": "created"
                  },
                  "lt": 86400
                },
                {
                  "path": "state",
                  "equals": "ERROR"
                }
              ]
            },
            "default": 0
          }
        },
        {
          "name": "stamps",
          "value": {
            "each": "deploys.deployments",
            "fields": {
              "t": {
                "divide": [
                  "created",
                  1000
                ]
              }
            }
          }
        },
        {
          "name": "last_prod_name",
          "value": {
            "first": "name",
            "of": "deploys.deployments",
            "where": {
              "all": [
                {
                  "path": "target",
                  "equals": "production"
                },
                {
                  "path": "state",
                  "equals": "READY"
                }
              ]
            }
          }
        },
        {
          "name": "last_prod_at",
          "value": {
            "first": "ready",
            "of": "deploys.deployments",
            "where": {
              "all": [
                {
                  "path": "target",
                  "equals": "production"
                },
                {
                  "path": "state",
                  "equals": "READY"
                }
              ]
            }
          }
        },
        {
          "name": "days",
          "value": {
            "each": "stamps",
            "by_day": {
              "at": "t",
              "from": "{date.days_ago_6}",
              "through": "{date.today}"
            },
            "fields": {
              "day": "from",
              "count": "count"
            }
          }
        },
        {
          "name": "cut",
          "value": {
            "if": {
              "path": "deploys.pagination.next",
              "exists": true
            },
            "then": {
              "template": "yes"
            },
            "else": {
              "template": "no"
            }
          }
        }
      ]
    },
    "projects": {
      "url": "https://api.vercel.com",
      "secret": "vercel",
      "every": "2m",
      "requests": {
        "list": "/v10/projects?limit=40",
        "aliases": "/v4/aliases?limit=100"
      },
      "derive": [
        {
          "name": "aliases_more",
          "value": {
            "if": {
              "path": "aliases.pagination.next",
              "exists": true
            },
            "then": {
              "template": "yes"
            },
            "else": {
              "template": "no"
            }
          }
        },
        {
          "name": "base",
          "value": {
            "each": "list.projects",
            "sort": "name",
            "lookup": {
              "from": "aliases.aliases",
              "by": "alias",
              "on": "targets.production.alias[0]",
              "as": "live"
            },
            "fields": {
              "id": "id",
              "name": "name",
              "paused": {
                "path": "paused",
                "default": false
              },
              "prod_id": "targets.production.id",
              "prod_state": "targets.production.readyState",
              "prod_at": "targets.production.createdAt",
              "prod_ready": {
                "if": {
                  "path": "targets.production.readyAt",
                  "exists": true
                },
                "then": "targets.production.readyAt",
                "else": "targets.production.createdAt"
              },
              "serving_id": "live.deploymentId",
              "any_state": {
                "first": "readyState",
                "of": "latestDeployments",
                "sort": {
                  "by": "createdAt",
                  "order": "desc"
                }
              },
              "any_at": {
                "first": "createdAt",
                "of": "latestDeployments",
                "sort": {
                  "by": "createdAt",
                  "order": "desc"
                }
              },
              "any_id": {
                "first": "id",
                "of": "latestDeployments",
                "sort": {
                  "by": "createdAt",
                  "order": "desc"
                }
              },
              "lp_id": {
                "first": "id",
                "of": "latestDeployments",
                "where": {
                  "path": "target",
                  "equals": "production"
                },
                "sort": {
                  "by": "createdAt",
                  "order": "desc"
                }
              },
              "lp_state": {
                "first": "readyState",
                "of": "latestDeployments",
                "where": {
                  "path": "target",
                  "equals": "production"
                },
                "sort": {
                  "by": "createdAt",
                  "order": "desc"
                }
              },
              "lp_at": {
                "first": "createdAt",
                "of": "latestDeployments",
                "where": {
                  "path": "target",
                  "equals": "production"
                },
                "sort": {
                  "by": "createdAt",
                  "order": "desc"
                }
              }
            }
          }
        },
        {
          "name": "rows",
          "value": {
            "if": {
              "path": "aliases_more",
              "equals": "no"
            },
            "then": {
              "each": "base",
              "fields": {
                "id": "id",
                "name": "name",
                "state": {
                  "if": {
                    "path": "paused",
                    "equals": true
                  },
                  "then": {
                    "template": "off"
                  },
                  "else": {
                    "if": {
                      "all": [
                        {
                          "path": "lp_state",
                          "equals": "ERROR"
                        },
                        {
                          "path": "lp_id",
                          "not": {
                            "path": "prod_id"
                          }
                        },
                        {
                          "path": "prod_state",
                          "equals": "READY"
                        }
                      ]
                    },
                    "then": {
                      "template": "warning"
                    },
                    "else": {
                      "if": {
                        "path": "prod_state",
                        "equals": "ERROR"
                      },
                      "then": {
                        "if": {
                          "all": [
                            {
                              "path": "serving_id",
                              "exists": true
                            },
                            {
                              "path": "serving_id",
                              "not": {
                                "path": "prod_id"
                              }
                            }
                          ]
                        },
                        "then": {
                          "template": "warning"
                        },
                        "else": {
                          "template": "critical"
                        }
                      },
                      "else": {
                        "if": {
                          "path": "prod_state",
                          "equals": "BLOCKED"
                        },
                        "then": {
                          "template": "warning"
                        },
                        "else": {
                          "if": {
                            "path": "prod_state",
                            "exists": true
                          },
                          "then": {
                            "template": "ok"
                          },
                          "else": {
                            "if": {
                              "path": "any_state",
                              "in": [
                                "QUEUED",
                                "INITIALIZING",
                                "BUILDING"
                              ]
                            },
                            "then": {
                              "template": "ok"
                            },
                            "else": {
                              "template": "off"
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "detail": {
                  "if": {
                    "path": "paused",
                    "equals": true
                  },
                  "then": {
                    "template": "Paused"
                  },
                  "else": {
                    "if": {
                      "all": [
                        {
                          "path": "lp_state",
                          "equals": "ERROR"
                        },
                        {
                          "path": "lp_id",
                          "not": {
                            "path": "prod_id"
                          }
                        },
                        {
                          "path": "prod_state",
                          "equals": "READY"
                        }
                      ]
                    },
                    "then": {
                      "template": "Latest production build failed {lp_at|ago} · an earlier build still serves"
                    },
                    "else": {
                      "if": {
                        "path": "prod_state",
                        "equals": "ERROR"
                      },
                      "then": {
                        "if": {
                          "all": [
                            {
                              "path": "serving_id",
                              "exists": true
                            },
                            {
                              "path": "serving_id",
                              "not": {
                                "path": "prod_id"
                              }
                            }
                          ]
                        },
                        "then": {
                          "template": "Latest production build failed {prod_at|ago} · an earlier build still serves"
                        },
                        "else": {
                          "template": "Production build failed {prod_at|ago} · nothing serving"
                        }
                      },
                      "else": {
                        "if": {
                          "path": "prod_state",
                          "in": [
                            "QUEUED",
                            "INITIALIZING",
                            "BUILDING"
                          ]
                        },
                        "then": {
                          "template": "Building for production"
                        },
                        "else": {
                          "if": {
                            "path": "any_state",
                            "in": [
                              "QUEUED",
                              "INITIALIZING",
                              "BUILDING"
                            ]
                          },
                          "then": {
                            "template": "Building a preview"
                          },
                          "else": {
                            "if": {
                              "path": "prod_state",
                              "equals": "BLOCKED"
                            },
                            "then": {
                              "template": "Latest production build blocked {prod_at|ago}"
                            },
                            "else": {
                              "if": {
                                "path": "prod_state",
                                "equals": "CANCELED"
                              },
                              "then": {
                                "template": "Latest production build cancelled {prod_at|ago}"
                              },
                              "else": {
                                "if": {
                                  "all": [
                                    {
                                      "path": "any_state",
                                      "equals": "ERROR"
                                    },
                                    {
                                      "path": "any_id",
                                      "not": {
                                        "path": "lp_id"
                                      }
                                    },
                                    {
                                      "path": "prod_state",
                                      "exists": true
                                    }
                                  ]
                                },
                                "then": {
                                  "template": "Preview failed {any_at|ago} · production deployed {prod_ready|ago}"
                                },
                                "else": {
                                  "if": {
                                    "path": "prod_state",
                                    "equals": "READY"
                                  },
                                  "then": {
                                    "template": "Ready · deployed {prod_ready|ago}"
                                  },
                                  "else": {
                                    "if": {
                                      "path": "prod_state",
                                      "exists": true
                                    },
                                    "then": {
                                      "template": "Latest production build {prod_state|lower} {prod_at|ago}"
                                    },
                                    "else": {
                                      "template": "No production deployment yet"
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            },
            "else": {
              "each": "base",
              "fields": {
                "id": "id",
                "name": "name",
                "state": {
                  "if": {
                    "path": "paused",
                    "equals": true
                  },
                  "then": {
                    "template": "off"
                  },
                  "else": {
                    "if": {
                      "all": [
                        {
                          "path": "lp_state",
                          "equals": "ERROR"
                        },
                        {
                          "path": "lp_id",
                          "not": {
                            "path": "prod_id"
                          }
                        },
                        {
                          "path": "prod_state",
                          "equals": "READY"
                        }
                      ]
                    },
                    "then": {
                      "template": "warning"
                    },
                    "else": {
                      "if": {
                        "path": "prod_state",
                        "equals": "ERROR"
                      },
                      "then": {
                        "if": {
                          "all": [
                            {
                              "path": "serving_id",
                              "exists": true
                            },
                            {
                              "path": "serving_id",
                              "not": {
                                "path": "prod_id"
                              }
                            }
                          ]
                        },
                        "then": {
                          "template": "warning"
                        },
                        "else": {
                          "template": "warning"
                        }
                      },
                      "else": {
                        "if": {
                          "path": "prod_state",
                          "equals": "BLOCKED"
                        },
                        "then": {
                          "template": "warning"
                        },
                        "else": {
                          "if": {
                            "path": "prod_state",
                            "exists": true
                          },
                          "then": {
                            "template": "ok"
                          },
                          "else": {
                            "if": {
                              "path": "any_state",
                              "in": [
                                "QUEUED",
                                "INITIALIZING",
                                "BUILDING"
                              ]
                            },
                            "then": {
                              "template": "ok"
                            },
                            "else": {
                              "template": "off"
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "detail": {
                  "if": {
                    "path": "paused",
                    "equals": true
                  },
                  "then": {
                    "template": "Paused"
                  },
                  "else": {
                    "if": {
                      "all": [
                        {
                          "path": "lp_state",
                          "equals": "ERROR"
                        },
                        {
                          "path": "lp_id",
                          "not": {
                            "path": "prod_id"
                          }
                        },
                        {
                          "path": "prod_state",
                          "equals": "READY"
                        }
                      ]
                    },
                    "then": {
                      "template": "Latest production build failed {lp_at|ago} · an earlier build still serves"
                    },
                    "else": {
                      "if": {
                        "path": "prod_state",
                        "equals": "ERROR"
                      },
                      "then": {
                        "if": {
                          "all": [
                            {
                              "path": "serving_id",
                              "exists": true
                            },
                            {
                              "path": "serving_id",
                              "not": {
                                "path": "prod_id"
                              }
                            }
                          ]
                        },
                        "then": {
                          "template": "Latest production build failed {prod_at|ago} · an earlier build still serves"
                        },
                        "else": {
                          "template": "Latest production build failed {prod_at|ago}"
                        }
                      },
                      "else": {
                        "if": {
                          "path": "prod_state",
                          "in": [
                            "QUEUED",
                            "INITIALIZING",
                            "BUILDING"
                          ]
                        },
                        "then": {
                          "template": "Building for production"
                        },
                        "else": {
                          "if": {
                            "path": "any_state",
                            "in": [
                              "QUEUED",
                              "INITIALIZING",
                              "BUILDING"
                            ]
                          },
                          "then": {
                            "template": "Building a preview"
                          },
                          "else": {
                            "if": {
                              "path": "prod_state",
                              "equals": "BLOCKED"
                            },
                            "then": {
                              "template": "Latest production build blocked {prod_at|ago}"
                            },
                            "else": {
                              "if": {
                                "path": "prod_state",
                                "equals": "CANCELED"
                              },
                              "then": {
                                "template": "Latest production build cancelled {prod_at|ago}"
                              },
                              "else": {
                                "if": {
                                  "all": [
                                    {
                                      "path": "any_state",
                                      "equals": "ERROR"
                                    },
                                    {
                                      "path": "any_id",
                                      "not": {
                                        "path": "lp_id"
                                      }
                                    },
                                    {
                                      "path": "prod_state",
                                      "exists": true
                                    }
                                  ]
                                },
                                "then": {
                                  "template": "Preview failed {any_at|ago} · production deployed {prod_ready|ago}"
                                },
                                "else": {
                                  "if": {
                                    "path": "prod_state",
                                    "equals": "READY"
                                  },
                                  "then": {
                                    "template": "Ready · deployed {prod_ready|ago}"
                                  },
                                  "else": {
                                    "if": {
                                      "path": "prod_state",
                                      "exists": true
                                    },
                                    "then": {
                                      "template": "Latest production build {prod_state|lower} {prod_at|ago}"
                                    },
                                    "else": {
                                      "template": "No production deployment yet"
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        {
          "name": "more",
          "value": {
            "if": {
              "path": "list.pagination.next",
              "exists": true
            },
            "then": {
              "template": "yes"
            },
            "else": {
              "template": "no"
            }
          }
        }
      ]
    },
    "account": {
      "url": "https://api.vercel.com",
      "secret": "vercel",
      "every": "1h",
      "secret_expires": "token_expires",
      "requests": {
        "domains": "/v5/domains?limit=100"
      },
      "derive": [
        {
          "name": "bought",
          "value": {
            "each": "domains.domains",
            "where": {
              "path": "expiresAt",
              "exists": true
            },
            "sort": "expiresAt",
            "fields": {
              "name": "name",
              "at": "expiresAt",
              "renew": {
                "path": "renew",
                "default": false
              },
              "state": {
                "if": {
                  "path": "renew",
                  "equals": true
                },
                "then": {
                  "template": "ok"
                },
                "else": {
                  "expires": {
                    "date": "expiresAt"
                  },
                  "warning": 30,
                  "critical": 7,
                  "as": "state"
                }
              },
              "left": {
                "expires": {
                  "date": "expiresAt"
                },
                "as": "text"
              }
            }
          }
        },
        {
          "name": "domains_cut",
          "value": {
            "if": {
              "path": "domains.pagination.next",
              "exists": true
            },
            "then": {
              "template": "yes"
            },
            "else": {
              "template": "no"
            }
          }
        },
        {
          "name": "bought_count",
          "value": {
            "count": "bought",
            "default": 0
          }
        },
        {
          "name": "domain_worst",
          "value": {
            "worst": "state",
            "of": "bought",
            "default": "ok"
          }
        },
        {
          "name": "alert_name",
          "value": {
            "first": "name",
            "of": "bought",
            "where": {
              "path": "state",
              "in": [
                "warning",
                "critical"
              ]
            }
          }
        },
        {
          "name": "alert_left",
          "value": {
            "first": "left",
            "of": "bought",
            "where": {
              "path": "state",
              "in": [
                "warning",
                "critical"
              ]
            }
          }
        },
        {
          "name": "next_name",
          "value": {
            "first": "name",
            "of": "bought"
          }
        },
        {
          "name": "next_at",
          "value": {
            "first": "at",
            "of": "bought"
          }
        }
      ]
    }
  },
  "cards": [
    {
      "id": "health",
      "type": "status",
      "width": "full",
      "placement": "page_info",
      "label": "Domains and token",
      "state": "unknown",
      "url": "https://vercel.com/dashboard",
      "source": {
        "ref": "account",
        "map": {
          "state": {
            "if": {
              "any": [
                {
                  "value": {
                    "expires": {
                      "date": "token_expires"
                    },
                    "as": "state",
                    "default": "ok"
                  },
                  "equals": "critical"
                },
                {
                  "path": "domain_worst",
                  "equals": "critical"
                }
              ]
            },
            "then": {
              "template": "critical"
            },
            "else": {
              "if": {
                "any": [
                  {
                    "value": {
                      "expires": {
                        "date": "token_expires"
                      },
                      "as": "state",
                      "default": "ok"
                    },
                    "equals": "warning"
                  },
                  {
                    "path": "domain_worst",
                    "equals": "warning"
                  }
                ]
              },
              "then": {
                "template": "warning"
              },
              "else": {
                "if": {
                  "any": [
                    {
                      "path": "bought_count",
                      "gt": 0
                    },
                    {
                      "path": "token_expires",
                      "exists": true
                    },
                    {
                      "path": "domains_cut",
                      "equals": "yes"
                    }
                  ]
                },
                "then": {
                  "template": "ok"
                },
                "else": {
                  "template": "off"
                }
              }
            }
          },
          "detail": {
            "if": {
              "path": "domain_worst",
              "in": [
                "warning",
                "critical"
              ]
            },
            "then": {
              "template": "{alert_name|clip:60}: {alert_left}, auto-renew off"
            },
            "else": {
              "if": {
                "value": {
                  "expires": {
                    "date": "token_expires"
                  },
                  "as": "state",
                  "default": "ok"
                },
                "in": [
                  "warning",
                  "critical"
                ]
              },
              "then": {
                "if": {
                  "value": {
                    "expires": {
                      "date": "token_expires"
                    },
                    "as": "state",
                    "default": "ok"
                  },
                  "equals": "critical"
                },
                "then": {
                  "template": "Access token expired {token_expires|day}"
                },
                "else": {
                  "template": "Access token expires {token_expires|day}"
                }
              },
              "else": {
                "if": {
                  "path": "domains_cut",
                  "equals": "yes"
                },
                "then": {
                  "if": {
                    "path": "bought_count",
                    "gt": 0
                  },
                  "then": {
                    "template": "Next renewal {next_name|clip:50} · {next_at|day}, of the first 100 domains"
                  },
                  "else": {
                    "template": "None of the first 100 domains was bought through Vercel"
                  }
                },
                "else": {
                  "if": {
                    "path": "bought_count",
                    "gt": 0
                  },
                  "then": {
                    "template": "Next renewal {next_name|clip:60} · {next_at|day}"
                  },
                  "else": {
                    "if": {
                      "path": "token_expires",
                      "exists": true
                    },
                    "then": {
                      "template": "Access token expires {token_expires|day}"
                    },
                    "else": {
                      "template": "No domains bought through Vercel"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    {
      "id": "team",
      "type": "facts",
      "label": "Team",
      "items": [
        {
          "key": "Building",
          "value": "—"
        },
        {
          "key": "Last 24 hours",
          "value": "—"
        },
        {
          "key": "Last production deploy",
          "value": "—"
        }
      ],
      "source": {
        "ref": "team",
        "map": {
          "items[0].value": {
            "if": {
              "path": "running_count",
              "gt": 0
            },
            "then": {
              "template": "{running_names|clip:80}"
            },
            "else": {
              "template": "—"
            }
          },
          "items[1].value": {
            "if": {
              "path": "day_partial",
              "equals": "yes"
            },
            "then": {
              "if": {
                "path": "day_failed",
                "gt": 0
              },
              "then": {
                "template": "At least {day_count} deployments · {day_failed} failed"
              },
              "else": {
                "template": "At least {day_count} deployments"
              }
            },
            "else": {
              "if": {
                "path": "day_failed",
                "gt": 0
              },
              "then": {
                "template": "{day_count} deployments · {day_failed} failed"
              },
              "else": {
                "if": {
                  "path": "day_count",
                  "equals": 1
                },
                "then": {
                  "template": "1 deployment"
                },
                "else": {
                  "template": "{day_count} deployments"
                }
              }
            }
          },
          "items[2].value": {
            "if": {
              "path": "last_prod_name",
              "exists": true
            },
            "then": {
              "template": "{last_prod_name|clip:60} · {last_prod_at|ago}"
            },
            "else": {
              "if": {
                "path": "cut",
                "equals": "yes"
              },
              "then": {
                "template": "None in the newest 100"
              },
              "else": {
                "template": "None this week"
              }
            }
          }
        }
      }
    },
    {
      "id": "per-day",
      "type": "columns",
      "label": "Deployments",
      "series": [
        "Deployments"
      ],
      "items": [],
      "source": {
        "ref": "team",
        "map": {
          "detail": {
            "if": {
              "path": "cut",
              "equals": "yes"
            },
            "then": {
              "template": "The 100 newest, since {oldest_read|day}"
            },
            "else": {
              "template": "Last 7 days"
            }
          },
          "items": {
            "each": "days",
            "fields": {
              "label": {
                "template": "{day|weekday}"
              },
              "values[0]": "count"
            }
          }
        }
      }
    },
    {
      "id": "projects",
      "type": "fleet",
      "label": "Projects",
      "max_items": 24,
      "items": [],
      "source": {
        "ref": "projects",
        "map": {
          "label": {
            "if": {
              "path": "more",
              "equals": "yes"
            },
            "then": {
              "template": "Projects · first 40"
            },
            "else": {
              "template": "Projects"
            }
          },
          "items": {
            "each": "rows",
            "fields": {
              "name": "name",
              "state": "state",
              "detail": "detail",
              "url": {
                "template": "legato://page/vercel-project?id={id}"
              }
            }
          }
        }
      }
    },
    {
      "id": "recent",
      "type": "list",
      "label": "Recent deployments",
      "max_items": 4,
      "items": [],
      "source": {
        "ref": "team",
        "empty": {
          "text": "Nothing deployed this week.",
          "when": {
            "value": {
              "count": "deploys.deployments",
              "default": 0
            },
            "equals": 0
          }
        },
        "map": {
          "items": {
            "each": "rows",
            "limit": 4,
            "fields": {
              "key": "uid",
              "text": {
                "template": "{message|plain|clip:80}"
              },
              "subtitle": {
                "template": "{name|clip:40} · {target_word} · {state_word}"
              },
              "detail": {
                "if": {
                  "path": "state",
                  "in": [
                    "QUEUED",
                    "INITIALIZING",
                    "BUILDING"
                  ]
                },
                "then": {
                  "template": "{buildingAt|ago}"
                },
                "else": {
                  "template": "{created|ago}"
                }
              },
              "icon": {
                "path": "state",
                "values": {
                  "READY": "checkmark.circle",
                  "ERROR": "xmark.octagon.fill",
                  "CANCELED": "xmark.circle",
                  "BUILDING": "hammer",
                  "INITIALIZING": "hammer",
                  "QUEUED": "clock",
                  "BLOCKED": "hand.raised"
                },
                "default": "questionmark.circle"
              },
              "color": {
                "path": "state",
                "values": {
                  "ERROR": "red",
                  "BLOCKED": "orange"
                }
              },
              "url": "inspectorUrl"
            }
          }
        }
      },
      "row_actions": [
        {
          "label": "Cancel build",
          "icon": "stop.fill",
          "method": "PATCH",
          "path": "/v12/deployments/{uid}/cancel",
          "confirm": {
            "message": "Cancel the build of {name}?",
            "button": "Cancel build"
          },
          "error": "error.message",
          "when": {
            "path": "state",
            "in": [
              "QUEUED",
              "INITIALIZING",
              "BUILDING"
            ]
          }
        }
      ]
    }
  ]
}
