feat: billing (#624)

* feat: init lago client

* feat: billable meter

* feat: db persistence

* wip: expose sub

* feat: rename page

* wip: billing section

* wip: lago integration

* feat: separate plan and period

* wip: webhook

* feat: improve empty state

* feat: update limits on plan changes

* feat: can change plans

* feat: change plan loading state

* feat: yearly filter

* feat: billing clarification

* fix: treatment

* feat: filter plans

* feat: prevent non-owner from changing plan

* fix: loading state

* fix: jit portal link

* fix: rm import

* fix: build errors

* fix: default to free

* fix: wrong files

* fix: select or insert customer

* fix: note

* feat: upgrade dependent on payment method state

* fix: dedupe

* chore: remove github-app from core

* chore: port to cloud

* chore: port to cloud

* chore: port to cloud

* chore: port to cloud

* chore: port to cloud

* add new components, repository callbacks

* chore: rm unused packages

* chore: fix generation

* chore: gen

* fix: cloud api references

* debug

* debug

* fix: actually set plans

* chore: rm debug

* fix: build

* feat: callbacks

* fix: add generated code

* chore: group cloud components

* chore: group by feature

* feat: alert change

* feat: confirm

* fix: confirm modal

* fix: ui

* fix: remove arrears

* fix: open in same tab

* fix: wan alert

* fix: call the callback

* fix: callback obj

* fix: disable if no cloud meta

---------

Co-authored-by: Alexander Belanger <alexander@hatchet.run>
This commit is contained in:
Gabe Ruttner
2024-06-25 10:57:16 -07:00
committed by GitHub
parent 771054a401
commit 697757879f
91 changed files with 1822 additions and 60355 deletions
@@ -102,8 +102,6 @@ Workflow:
$ref: "./workflow.yaml#/Workflow"
WorkflowConcurrency:
$ref: "./workflow.yaml#/WorkflowConcurrency"
WorkflowDeploymentConfig:
$ref: "./workflow.yaml#/WorkflowDeploymentConfig"
WorkflowVersionMeta:
$ref: "./workflow.yaml#/WorkflowVersionMeta"
WorkflowVersion:
@@ -172,20 +170,6 @@ RerunStepRunRequest:
$ref: "./workflow_run.yaml#/RerunStepRunRequest"
TriggerWorkflowRunRequest:
$ref: "./workflow_run.yaml#/TriggerWorkflowRunRequest"
LinkGithubRepositoryRequest:
$ref: "./workflow.yaml#/LinkGithubRepositoryRequest"
GithubBranch:
$ref: "./github_app.yaml#/GithubBranch"
GithubRepo:
$ref: "./github_app.yaml#/GithubRepo"
GithubAppInstallation:
$ref: "./github_app.yaml#/GithubAppInstallation"
ListGithubAppInstallationsResponse:
$ref: "./github_app.yaml#/ListGithubAppInstallationsResponse"
ListGithubReposResponse:
$ref: "./github_app.yaml#/ListGithubReposResponse"
ListGithubBranchesResponse:
$ref: "./github_app.yaml#/ListGithubBranchesResponse"
CreatePullRequestFromStepRun:
$ref: "./workflow_run.yaml#/CreatePullRequestFromStepRun"
GetStepRunDiffResponse:
@@ -1,61 +0,0 @@
GithubBranch:
type: object
properties:
branch_name:
type: string
is_default:
type: boolean
required:
- branch_name
- is_default
GithubRepo:
type: object
properties:
repo_owner:
type: string
repo_name:
type: string
required:
- repo_owner
- repo_name
GithubAppInstallation:
type: object
properties:
metadata:
$ref: "./metadata.yaml#/APIResourceMeta"
installation_settings_url:
type: string
account_name:
type: string
account_avatar_url:
type: string
required:
- metadata
- installation_settings_url
- account_name
- account_avatar_url
ListGithubAppInstallationsResponse:
type: object
properties:
pagination:
$ref: "./metadata.yaml#/PaginationResponse"
rows:
type: array
items:
$ref: "#/GithubAppInstallation"
required:
- pagination
- rows
ListGithubReposResponse:
type: array
items:
$ref: "#/GithubRepo"
ListGithubBranchesResponse:
type: array
items:
$ref: "#/GithubBranch"
@@ -24,38 +24,10 @@ Workflow:
items:
$ref: "#/Job"
description: The jobs of the workflow.
deployment:
$ref: "#/WorkflowDeploymentConfig"
required:
- metadata
- name
type: object
WorkflowDeploymentConfig:
properties:
metadata:
$ref: "./metadata.yaml#/APIResourceMeta"
gitRepoName:
type: string
description: The repository name.
gitRepoOwner:
type: string
description: The repository owner.
gitRepoBranch:
type: string
description: The repository branch.
githubAppInstallation:
$ref: "./_index.yaml#/GithubAppInstallation"
description: The Github App installation.
githubAppInstallationId:
type: string
format: uuid
description: The id of the Github App installation.
required:
- metadata
- gitRepoName
- gitRepoOwner
- gitRepoBranch
- githubAppInstallationId
WorkflowTag:
type: object
-22
View File
@@ -38,18 +38,10 @@ paths:
$ref: "./paths/user/user.yaml#/oauth-start-github"
/api/v1/users/github/callback:
$ref: "./paths/user/user.yaml#/oauth-callback-github"
/api/v1/users/github-app/start:
$ref: "./paths/user/user.yaml#/oauth-start-github-app"
/api/v1/users/github-app/callback:
$ref: "./paths/user/user.yaml#/oauth-callback-github-app"
/api/v1/tenants/{tenant}/slack/start:
$ref: "./paths/user/user.yaml#/oauth-start-slack"
/api/v1/users/slack/callback:
$ref: "./paths/user/user.yaml#/oauth-callback-slack"
/api/v1/github/webhook:
$ref: "./paths/github-app/github-app.yaml#/globalWebhook"
/api/v1/github/webhook/{webhook}:
$ref: "./paths/github-app/github-app.yaml#/tenantWebhook"
/api/v1/sns/{tenant}/{event}:
$ref: "./paths/ingestors/ingestors.yaml#/sns"
/api/v1/tenants/{tenant}/sns:
@@ -122,16 +114,10 @@ paths:
$ref: "./paths/workflow/workflow.yaml#/triggerWorkflow"
/api/v1/workflows/{workflow}/versions/definition:
$ref: "./paths/workflow/workflow.yaml#/workflowVersionDefinition"
/api/v1/workflows/{workflow}/link-github:
$ref: "./paths/workflow/workflow.yaml#/linkGithub"
/api/v1/workflows/{workflow}/metrics:
$ref: "./paths/workflow/workflow.yaml#/getMetrics"
/api/v1/step-runs/{step-run}/create-pr:
$ref: "./paths/workflow/workflow.yaml#/createPullRequest"
/api/v1/step-runs/{step-run}/logs:
$ref: "./paths/log/log.yaml#/withStepRun"
/api/v1/step-runs/{step-run}/diff:
$ref: "./paths/workflow/workflow.yaml#/getDiff"
/api/v1/step-runs/{step-run}/events:
$ref: "./paths/step-run/step-run.yaml#/listEvents"
/api/v1/tenants/{tenant}/workflows/runs:
@@ -140,8 +126,6 @@ paths:
$ref: "./paths/workflow/workflow.yaml#/workflowRunsMetrics"
/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}:
$ref: "./paths/workflow/workflow.yaml#/workflowRun"
/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}/prs:
$ref: "./paths/workflow/workflow.yaml#/listPullRequests"
/api/v1/tenants/{tenant}/step-runs/{step-run}:
$ref: "./paths/step-run/step-run.yaml#/stepRunScoped"
/api/v1/tenants/{tenant}/step-runs/{step-run}/rerun:
@@ -154,9 +138,3 @@ paths:
$ref: "./paths/worker/worker.yaml#/withTenant"
/api/v1/workers/{worker}:
$ref: "./paths/worker/worker.yaml#/withWorker"
/api/v1/github-app/installations:
$ref: "./paths/github-app/github-app.yaml#/installations"
/api/v1/github-app/installations/{gh-installation}/repos:
$ref: "./paths/github-app/github-app.yaml#/repos"
/api/v1/github-app/installations/{gh-installation}/repos/{gh-repo-owner}/{gh-repo-name}/branches:
$ref: "./paths/github-app/github-app.yaml#/branches"
@@ -1,204 +0,0 @@
globalWebhook:
post:
description: Github App global webhook
operationId: github:update:global-webhook
responses:
"200":
description: Successfully processed webhook
"400":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: A malformed or bad request
"401":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Unauthorized
"405":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Method not allowed
security: []
summary: Github app global webhook
tags:
- Github
tenantWebhook:
post:
description: Github App tenant webhook
operationId: github:update:tenant-webhook
parameters:
- description: The webhook id
in: path
name: webhook
required: true
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
responses:
"200":
description: Successfully processed webhook
"400":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: A malformed or bad request
"401":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Unauthorized
"405":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Method not allowed
security: []
summary: Github app tenant webhook
tags:
- Github
installations:
get:
description: List Github App installations
operationId: github-app:list:installations
responses:
"200":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/ListGithubAppInstallationsResponse"
description: Successfully retrieved the installations
"400":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: A malformed or bad request
"401":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Unauthorized
"405":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Method not allowed
security:
- cookieAuth: []
summary: List Github App installations
tags:
- Github
repos:
get:
description: List Github App repositories
operationId: github-app:list:repos
x-resources: ["gh-installation"]
parameters:
- description: The installation id
in: path
name: gh-installation
required: true
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
responses:
"200":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/ListGithubReposResponse"
description: Successfully retrieved the repositories
"400":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: A malformed or bad request
"401":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Unauthorized
"405":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Method not allowed
security:
- cookieAuth: []
summary: List Github App repositories
tags:
- Github
branches:
get:
description: List Github App branches
operationId: github-app:list:branches
x-resources: ["gh-installation"]
parameters:
- description: The installation id
in: path
name: gh-installation
required: true
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
- description: The repository owner
in: path
name: gh-repo-owner
required: true
schema:
type: string
- description: The repository name
in: path
name: gh-repo-name
required: true
schema:
type: string
responses:
"200":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/ListGithubBranchesResponse"
description: Successfully retrieved the branches
"400":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: A malformed or bad request
"401":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Unauthorized
"405":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Method not allowed
security:
- cookieAuth: []
summary: List Github App branches
tags:
- Github
@@ -207,42 +207,6 @@ oauth-callback-github:
summary: Complete OAuth flow
tags:
- User
oauth-start-github-app:
get:
description: Starts the OAuth flow
operationId: user:update:github-app-oauth-start
responses:
"302":
description: Successfully started the OAuth flow
headers:
location:
schema:
type: string
# Note that the security scheme requires cookies, because this endpoint is for linking
# a GitHub account to an existing user account.
security:
- cookieAuth: []
summary: Start OAuth flow
tags:
- User
oauth-callback-github-app:
get:
description: Completes the OAuth flow
operationId: user:update:github-app-oauth-callback
responses:
"302":
description: Successfully completed the OAuth flow
headers:
location:
schema:
type: string
# Note that the security scheme requires cookies, because this endpoint is for linking
# a GitHub account to an existing user account.
security:
- cookieAuth: []
summary: Complete OAuth flow
tags:
- User
oauth-start-slack:
get:
x-resources: ["tenant"]
@@ -563,201 +563,6 @@ workflowRun:
summary: Get workflow run
tags:
- Workflow
linkGithub:
post:
x-resources: ["tenant", "workflow"]
description: Link a github repository to a workflow
operationId: workflow:update:link-github
parameters:
- description: The workflow id
in: path
name: workflow
required: true
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
requestBody:
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/LinkGithubRepositoryRequest"
description: The input to link a github repository
required: true
responses:
"200":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/Workflow"
description: Successfully linked the github repository
"400":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: A malformed or bad request
"403":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Forbidden
"404":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Not found
summary: Link github repository
tags:
- Workflow
createPullRequest:
post:
x-resources: ["tenant", "step-run"]
description: Create a pull request for a workflow
operationId: step-run:update:create-pr
parameters:
- description: The step run id
in: path
name: step-run
required: true
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
requestBody:
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/CreatePullRequestFromStepRun"
description: The input to create a pull request
required: true
responses:
"200":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/CreatePullRequestFromStepRun"
description: Successfully created the pull request
"400":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: A malformed or bad request
"403":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Forbidden
"404":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Not found
summary: Create pull request
tags:
- Workflow
listPullRequests:
get:
x-resources: ["tenant", "workflow-run"]
description: List all pull requests for a workflow run
operationId: workflow-run:list:pull-requests
parameters:
- description: The tenant id
in: path
name: tenant
required: true
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
- description: The workflow run id
in: path
name: workflow-run
required: true
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
- description: The pull request state
in: query
name: state
required: false
schema:
$ref: "../../components/schemas/_index.yaml#/PullRequestState"
responses:
"200":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/ListPullRequestsResponse"
description: Successfully retrieved the list of pull requests
"400":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: A malformed or bad request
"403":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Forbidden
summary: List pull requests
tags:
- Workflow
getDiff:
get:
x-resources: ["tenant", "step-run"]
description: Get the diff for a step run between the most recent run and the first run.
operationId: step-run:get:diff
parameters:
- description: The step run id
in: path
name: step-run
required: true
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
responses:
"200":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/GetStepRunDiffResponse"
description: Successfully retrieved the diff
"400":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: A malformed or bad request
"403":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Forbidden
"404":
content:
application/json:
schema:
$ref: "../../components/schemas/_index.yaml#/APIErrors"
description: Not found
summary: Get diff
tags:
- Workflow
getMetrics:
get:
x-resources: ["tenant", "workflow"]