Created
February 8, 2024 22:04
-
-
Save Gozala/c098097aa17b0bc65294bfe3b85b8b57 to your computer and use it in GitHub Desktop.
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
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