@web3-storage/capabilities
Advanced tools
Comparing version
@@ -8,2 +8,11 @@ /** | ||
}>, {}>>; | ||
/** | ||
* Capability can be invoked by an account to change its billing plan. | ||
*/ | ||
export const set: import("@ucanto/interface").TheCapabilityParser<import("@ucanto/interface").CapabilityMatch<"plan/set", `did:mailto:${string}` & `did:${string}` & import("@ucanto/interface").Phantom<{ | ||
protocol: "did:"; | ||
}>, import("@ucanto/validator").InferStruct<{ | ||
product: typeof DID; | ||
}>>>; | ||
import { DID } from '@ucanto/validator'; | ||
//# sourceMappingURL=plan.d.ts.map |
@@ -469,5 +469,17 @@ import type { TupleToUnion } from 'type-fest'; | ||
export type PlanGetFailure = PlanNotFound; | ||
export type PlanSet = InferInvokedCapability<typeof PlanCaps.set>; | ||
export type PlanSetSuccess = Unit; | ||
/** | ||
* @deprecate currently unused - used to be part of PlanSetFailure but we switched to CustomerNotFound | ||
*/ | ||
export interface AccountNotFound extends Ucanto.Failure { | ||
name: 'AccountNotFound'; | ||
} | ||
export interface InvalidPlanName extends Ucanto.Failure { | ||
name: 'InvalidPlanName'; | ||
} | ||
export type PlanSetFailure = CustomerNotFound; | ||
export type Top = InferInvokedCapability<typeof top>; | ||
export type Abilities = TupleToUnion<AbilitiesArray>; | ||
export type AbilitiesArray = [ | ||
export type ServiceAbility = TupleToUnion<ServiceAbilityArray>; | ||
export type ServiceAbilityArray = [ | ||
Top['can'], | ||
@@ -514,2 +526,10 @@ ProviderAdd['can'], | ||
]; | ||
/** | ||
* @deprecated use ServiceAbility | ||
*/ | ||
export type Abilities = ServiceAbility; | ||
/** | ||
* @deprecated use ServiceAbilityArray | ||
*/ | ||
export type AbilitiesArray = ServiceAbilityArray; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@web3-storage/capabilities", | ||
"version": "13.0.0", | ||
"version": "13.1.0", | ||
"description": "UCAN Capabilities provided by web3.storage", | ||
@@ -5,0 +5,0 @@ "homepage": "https://web3.storage", |
@@ -1,3 +0,3 @@ | ||
import { capability, ok } from '@ucanto/validator' | ||
import { AccountDID, equalWith, and } from './utils.js' | ||
import { DID, capability, ok, struct } from '@ucanto/validator' | ||
import { AccountDID, equal, equalWith, and } from './utils.js' | ||
@@ -15,1 +15,19 @@ /** | ||
}) | ||
/** | ||
* Capability can be invoked by an account to change its billing plan. | ||
*/ | ||
export const set = capability({ | ||
can: 'plan/set', | ||
with: AccountDID, | ||
nb: struct({ | ||
product: DID, | ||
}), | ||
derives: (child, parent) => { | ||
return ( | ||
and(equalWith(child, parent)) || | ||
and(equal(child.nb.product, parent.nb.product, 'product')) || | ||
ok({}) | ||
) | ||
}, | ||
}) |
@@ -633,8 +633,25 @@ import type { TupleToUnion } from 'type-fest' | ||
export type PlanSet = InferInvokedCapability<typeof PlanCaps.set> | ||
export type PlanSetSuccess = Unit | ||
/** | ||
* @deprecate currently unused - used to be part of PlanSetFailure but we switched to CustomerNotFound | ||
*/ | ||
export interface AccountNotFound extends Ucanto.Failure { | ||
name: 'AccountNotFound' | ||
} | ||
export interface InvalidPlanName extends Ucanto.Failure { | ||
name: 'InvalidPlanName' | ||
} | ||
export type PlanSetFailure = CustomerNotFound | ||
// Top | ||
export type Top = InferInvokedCapability<typeof top> | ||
export type Abilities = TupleToUnion<AbilitiesArray> | ||
export type ServiceAbility = TupleToUnion<ServiceAbilityArray> | ||
export type AbilitiesArray = [ | ||
export type ServiceAbilityArray = [ | ||
Top['can'], | ||
@@ -681,1 +698,11 @@ ProviderAdd['can'], | ||
] | ||
/** | ||
* @deprecated use ServiceAbility | ||
*/ | ||
export type Abilities = ServiceAbility | ||
/** | ||
* @deprecated use ServiceAbilityArray | ||
*/ | ||
export type AbilitiesArray = ServiceAbilityArray |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
152493
1.67%3544
1.9%