API reference

Vennbase

MethodDescription
new Vennbase({ schema, appBaseUrl? })Create a Vennbase instance. Pass appBaseUrl so share links point back to your app.
getSession()Check whether the current browser already has a Puter session.
signIn()Start the Puter sign-in flow. Call this from a user gesture such as a button click.
whoAmI()Returns { username } for the signed-in Puter user.
create(collection, fields, options?)Create a row optimistically and return a MutationReceipt<RowHandle> immediately. Pass { in: parent } for child rows, where parent can be a RowHandle or RowRef. For user-scoped collections, pass { in: CURRENT_USER }. Most apps use .value; await .committed when you need remote confirmation.
update(collection, row, fields)Merge field updates onto a row optimistically and return a MutationReceipt<RowHandle> immediately. row can be a RowHandle or RowRef.
getRow(row)Fetch a row by typed reference.
query(collection, options)Load rows under a parent, with optional index, order, and limit. Pass in, including CURRENT_USER for user-scoped collections. Default queries return locatable RowHandle values; select: "indexKeys" returns non-reopenable index-key projections.
watchQuery(collection, options, callbacks)Subscribe to repeated query refreshes via callbacks.onChange. Pass in, including CURRENT_USER for user-scoped collections. Returns a handle with .disconnect(). The callback receives either full RowHandle values or index-key projections depending on select.
createShareToken(row, role)Generate a share token optimistically and return a MutationReceipt<ShareToken>. .value is usable locally right away; await .committed before another client must be able to use it.
getExistingShareToken(row, role)Return the existing token for the requested role if one exists, or null.
createShareLink(row, shareToken)Build a shareable URL containing a serialized row ref and token.
createShareLink(row, role)Generate a future-valid share link for that role and return it as a MutationReceipt<string>. .value is the local URL immediately; .committed resolves when recipients can rely on it remotely.
parseInvite(input)Parse an invite URL into { ref, shareToken? }.
joinInvite(input)Idempotently join a row via invite URL or parsed invite object without opening it, and return { ref, role }.
acceptInvite(input)Join a readable invite and return its handle. Use it for content-* and all-* invites. index-* invites should use joinInvite(...).
saveRow(key, row)Persist one current row for the signed-in user under your app-defined key.
openSavedRow(key, collection)Re-open the saved row for the signed-in user as the expected collection, or null. Throws if the stored row belongs to a different collection.
clearSavedRow(key)Remove the saved row for the signed-in user.
listMembers(row)Returns string[] of all member usernames.
listDirectMembers(row)Returns { username, role }[] for direct members.
listEffectiveMembers(row)Returns resolved membership including grants inherited from parents.
removeMember(row, username)Revoke a user's access and return a MutationReceipt<void>.
addParent(child, parent)Link a row to an additional parent after creation and return a MutationReceipt<void>.
removeParent(child, parent)Unlink a row from a parent and return a MutationReceipt<void>.
listParents(child)Returns all parent references for a row.
connectCrdt(row, callbacks)Bridge a CRDT onto the row's message stream. Returns a CrdtConnection.

RowHandle

MemberDescription
.fieldsCurrent field snapshot, typed from your schema. Treat it as read-only; the object is replaced when fields change.
.collectionThe collection this row belongs to.
.refPortable RowRef object for persistence, invites, ref-typed fields, and reopening the row later.
.id / .ownerRow identity metadata.
.refresh()Re-fetch fields from the server. Resolves to the latest field snapshot.
.connectCrdt(callbacks)Shorthand for db.connectCrdt(row, callbacks).
.in.add(parent) / .in.remove(parent) / .in.list()Manage parent links.
.members.remove(username) / .members.list() / .members.effective() / .members.listAll()Inspect direct/effective membership and revoke direct members.

MutationReceipt<T>

MemberDescription
.valueThe optimistic value available immediately. For create and update, this is the RowHandle.
.committedPromise that resolves to the final value once the write is confirmed remotely. Rejects if the write fails.
.statusCurrent write status: "pending", "committed", or "failed".
.errorThe rejection reason after a failed write. Otherwise undefined.