Created
February 8, 2024 21:40
-
-
Save Gozala/afa977f9e9c7e921700b60362cb6a984 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { | |
subscriptions: AccountSubscriptions | |
// ... | |
} | |
interface AccountSubscriptions { | |
customer: AccountDID | |
request(): Subscription | |
list(): Subscription[] | |
// Verifies that plan.customer === this.customer | |
add(plan: Plan): Subscription | |
remove(subscription: Subscription): {} | |
} | |
type Subscription = Variant<{ | |
active: ActiveSubscription | |
pending: PendingSubscription | |
}> | |
interface PendingSubscription { | |
// URL user can navigate to complete subscription setup | |
url: URL | |
customer: AccountDID | |
} | |
interface ActiveSubscription extends UCAN<{ with: ServiceDID: can: "subscription/*", nb: { customer: AccountDID } }> { | |
plan: Plan // terms of service | |
customer: AccountDID // Account that has a subscription | |
provisions: SubscriptionProvisions | |
// ensures that plan.customer === this.customer | |
update({ plan: Plan }): void | |
} | |
interface Plan extends UCAN<{ with: ProviderDID, nb: { customer: AccountDID } }> { | |
price: Price | |
provider: ProviderDID | |
customer: AccountDID | |
protocol: Record<Ability, Schema> | |
} | |
interface Price extends Record<string, number> {} | |
interface SubscriptionProvisions { | |
list(): Provision[] | |
add(provision: Provision): {} | |
remove(provision: Provision): {} | |
} | |
interface Provision { | |
consumer: SpaceDID | |
limits: Limits | |
} | |
interface Limits extends Record<PropertyKey, never> { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment