-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Future API Sketch #1156
Comments
This is roughly the interface I had in mind when talking about it interface ConnecionModel {
/**
* Local keypair use to sign messages send over the connection.
*/
readonly issuer: Ucanto.Signer
/**
* DID of the destination.
*/
readonly audience: Ucanto.Principal
/**
* Wire transport encoding.
*/
readonly codec: Ucanto.Transport.OutboundCodec
/**
* Ucanto Transport channel.
*/
readonly channel: Ucanto.Transport.Channel
}
interface Model {
/**
* Connection to the (remote) agent a.k.a service.
*/
connection: ConnecionModel
/**
* Set of delegations that can be used to invoke capabilities over `connection`.
*/
authorization: Store<Ucanto.Delegation>
}
interface AgentView {
model: Model
accounts: AgentAccounts
login(email: string): Promise<AccountView>
}
interface AgentAccounts extends Iterable<AccountView> {
get(email: string): AccountView
add(account: AccountView): Promise<AccountView>
remove(account: AccountView): Promise<void>
}
interface AccountView {
spaces: Spaces
plan: AccountPlan
}
interface AccountPlan {
get(): PlanView
}
interface PlanView {
subscriptions: Subscriptions
}
interface Subscriptions extends Iterable<Subscription> {
get(id: string): Subscription
add(subscription: Subscription): Promise<Subscription>
remove(subscription: Subscription): Promise<void>
}
interface Subscription {
consumer: SpaceDID
}
interface Spaces extends Iterable<SpaceView> {
get(name: string): SpaceView
add(space: SpaceView): Promise<SpaceView>
remove(space: SpaceView): Promise<void>
}
interface SpaceView {
upload: UploadView
store: StoreView
createFileUploader(): FileUploader
createDirectoryUploader(): DirectoryUploader
createArchiveUploader(): ArchiveUploader
}
export interface Uploader {
/**
* Writes contents of the upload to the space without adding it to the upload
* list.
*/
store(space?: SpaceView): Promise<Upload>
/**
* Writes content of the upload to the space and adds it to the upload list.
*/
upload(space?: SpaceView): Promise<Upload>
}
interface FileUploader extends Uploader {
}
interface DirectoryUploader extends Uploader {
}
interface ArchiveUploader extends Uploader {
}
interface Upload {
root: Link
shards: CARLink[]
}
interface UploadView {
add(upload: Upload): Promise<Upload>
remove(upload: Upload): Promise<Unit>
list(): Promise<Upload[]>
}
interface StoreView {
add(shard: Archive): Promise<ArchiveWriter>
remove(shard: Archive): Promise<Unit>
list(): Promise<Archive[]>
}
interface Archive {
link: Link
size: number
}
interface ArchiveWriter {
write(bytes: Uint8Array): Promise<void>
} |
This looks great, really nice to be able to design something like this now we have our domain model figured out. I realise just a sketch but here's some notes on missing/wanted things so we don't forget:
|
@alanshaw I've heard about the client refactor, and I'd love to hear from you what you see as the goal of this refactor, in qualitative terms.
Essentially what makes worth it to spend 2 weeks at minimum to implement all this plus the pain of getting folks to upgrade? I think it would super useful also for @Peeja as someone with deep frontend experience to have strong input on this. I will say for myself by far one of the hardest parts of working in the w3up repo is the abundance of packages and the fact that a typical operational function will cross potentially multiple different packages. (and on the server side, into the w3infra repo and back) Also, would it help to defer this for a bit until @hakierka and @Peeja have a few weeks experience working on the code and /or helping clients so they can have more informed input? |
I've likely missed a few things here... FYI we have a planning ticket open for this also: storacha/project-tracking#2 My ask in discord was not for this to be worked on by @hakierka or @Peeja just yet, I just wondered, given the proposed API and the in-flight PR, if, (in their opinion!) the proposed API might be better than the current, given they are new to the project, just learning the ropes and experiencing the pains other users might also be experiencing. I also think their opinion is valuable given their expertise. This would provide us with some more validation and hence would give us more reason to work on it. |
Me @alanshaw, @vasco-santos and @travis had been talking about revisiting API for the client at the labweek and have got some feedback from the workshop which was validating of the one we were entertaining, I thought I'd sketch it here so we can discuss it further. Before I proceed let me call out some high level goals I have in my mind.
AgentView
- Convenience wrapper of what I have access to on this agent.AccountView
- Agent may have access to arbitrary number of accounts represented viaAccountView
which should simply be another view over the "proofs store". When you login you get a newAccountView
(holding account to agent delegation) if you do want to persist reference to the account across the agent sessions you doagent.add(account)
.SpaceView
- Agent may have access to arbitrary number of spaces represented viaSpaceView
which should also be views over "proofs store". When you create a space you get a newOwnedSpaceView
. If you want to retain access to space across devices and sessions you'd callaccount.add(space)
. If you do not want to add space to the account you can add it it e.g.agent.local.add(space)
or something like that so we emphasize the fact that space is detached from any account.account.remove(space)
which simply revokes delegation from space to account.UploadView
andStoreView
will be just be views that expose correspondingupload/*
andstore/*
capabilities of the space. I don't mean subclasses here, simply views over the same model. And space could probably have.upload
and and.store
fields with the corresponding views.The text was updated successfully, but these errors were encountered: