Last active
September 25, 2024 22:13
-
-
Save Rieranthony/d3bfe43ac931164cd999ac07ba038577 to your computer and use it in GitHub Desktop.
orchestra-webhook-events.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export enum WebhookEventType { | |
// Task-related events | |
TASK_CREATED = "task.created", | |
TASK_UPDATED = "task.updated", | |
TASK_DELETED = "task.deleted", | |
TASK_ARCHIVED = "task.archived", | |
TASK_UNARCHIVED = "task.unarchived", | |
TASK_STATUS_CHANGED = "task.status_changed", | |
TASK_ASSIGNED = "task.assigned", | |
// COMMENT RELATED | |
COMMENT_ADDED = "comment.added", | |
// Subscriber-related events | |
SUBSCRIBER_CREATED = "subscriber.created", | |
SUBSCRIBER_UPDATED = "subscriber.updated", | |
// Subscription and payment events | |
SUBSCRIPTION_CREATED = "subscription.created", | |
SUBSCRIPTION_CANCELED = "subscription.canceled", | |
SUBSCRIPTION_PAUSED = "subscription.paused", | |
SUBSCRIPTION_RESUMED = "subscription.resumed", | |
SUBSCRIPTION_PAST_DUE = "subscription.past_due", | |
SUBSCRIPTION_UPDATED = "subscription.updated", | |
ALL = "*", | |
} | |
export type EventSubscriptionStatus = | |
| "active" | |
| "past_due" | |
| "unpaid" | |
| "canceled" | |
| "incomplete" | |
| "incomplete_expired" | |
| "trialing" | |
| "paused"; | |
export type EventUser = { | |
id: string; | |
email: string; | |
name: string | null; | |
image: string | null; | |
}; | |
export type EventSubscriber = { | |
id: string; | |
stripeCustomerId: string; | |
subdomain: string; | |
email: string | null; | |
name: string | null; | |
image: string | null; | |
createdAt: string; | |
updatedAt: string; | |
deletedAt: string | null; | |
}; | |
export type EventPrice = { | |
stripePriceId: string; | |
amount: number; | |
interval: string | null; | |
intervalCount: number | null; | |
currency: string; | |
}; | |
export type TaskEventPayload = { | |
taskId: string; | |
title: string; | |
status: string; | |
subscriber: EventSubscriber | null; | |
assignedTo: EventUser | null; | |
createdBy: EventUser; | |
workStartedAt: string | null; | |
workDoneAt: string | null; | |
createdAt: string; | |
updatedAt: string; | |
deletedAt: string | null; | |
}; | |
export type CommentEventPayload = { | |
id: string; | |
task: { | |
title: string; | |
id: string; | |
status: string; | |
}; | |
content: string; | |
commentedBy: EventUser; | |
subscriber: EventSubscriber | null; | |
redirectUrl: string; | |
createdAt: string; | |
}; | |
export type SubscriberEventPayload = { | |
id: string; | |
stripeCustomerId: string; | |
owner: EventUser; | |
email: string; | |
name: string | null; | |
image: string | null; | |
subdomain: string; | |
createdAt: string; | |
updatedAt: string; | |
deletedAt: string | null; | |
}; | |
export type SubscriptionEventPayload = { | |
id: string; | |
subscriber: EventSubscriber; | |
stripeCustomerId: string; | |
plan: { | |
id: string; | |
name: string; | |
prices: EventPrice[]; | |
}; | |
status: EventSubscriptionStatus | null; | |
stripeSubscriptionId: string; | |
}; | |
export type WebhookPayload = | |
| { | |
event: WebhookEventType.TASK_CREATED; | |
data: TaskEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.TASK_UPDATED; | |
data: TaskEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.TASK_DELETED; | |
data: TaskEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.TASK_ARCHIVED; | |
data: TaskEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.TASK_UNARCHIVED; | |
data: TaskEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.TASK_STATUS_CHANGED; | |
data: TaskEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.TASK_ASSIGNED; | |
data: TaskEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.COMMENT_ADDED; | |
data: CommentEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.SUBSCRIBER_CREATED; | |
data: SubscriberEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.SUBSCRIBER_UPDATED; | |
data: SubscriberEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.SUBSCRIPTION_CREATED; | |
data: SubscriptionEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.SUBSCRIPTION_PAST_DUE; | |
data: SubscriptionEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.SUBSCRIPTION_UPDATED; | |
data: SubscriptionEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.SUBSCRIPTION_CANCELED; | |
data: SubscriptionEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.SUBSCRIPTION_PAUSED; | |
data: SubscriptionEventPayload; | |
timestamp: number; | |
} | |
| { | |
event: WebhookEventType.SUBSCRIPTION_RESUMED; | |
data: SubscriptionEventPayload; | |
timestamp: number; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment