Skip to content

Instantly share code, notes, and snippets.

@Gozala
Created February 8, 2024 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gozala/c098097aa17b0bc65294bfe3b85b8b57 to your computer and use it in GitHub Desktop.
Save Gozala/c098097aa17b0bc65294bfe3b85b8b57 to your computer and use it in GitHub Desktop.
interface Account {
plan: AccountPlan
// ...
}
interface AccountPlan {
customer: AccountDID
request(): Plan
list(): Plan[]
// Verifies that plan.customer === this.customer
add(terms: Terms): Plan
remove(plan: Plan): {}
}
type Plan = Variant<{
active: ActivePlan
pending: PendingPlan
}>
interface PendingPlan {
// URL user can navigate to complete setup
url: URL
customer: AccountDID
}
interface ActivePlan extends UCAN<{ with: ServiceDID: can: "plan/*", nb: { customer: AccountDID } }> {
terms: Terms // terms of service
customer: AccountDID // Account that has a subscription
subscription: PlanSubscription
// ensures that terms.customer === this.customer
update({ terms: Terms }): void
}
interface Terms extends UCAN<{ with: ProviderDID, nb: { customer: AccountDID } }> {
price: Price
provider: ProviderDID
customer: AccountDID
protocol: Record<Ability, Schema>
}
interface Price extends Record<string, number> {}
interface PlanSubscription {
list(): Subscription[]
add(subscripton: Subscription): {}
remove(subscription: Subscription): {}
}
interface Subscription {
consumer: SpaceDID
limit: Limit
}
interface Limit extends Record<PropertyKey, never> {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment