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. |
ensureReady() | Explicitly await authentication and provisioning before mutations. Most useful in imperative startup flows and before imperative writes. |
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 collections declared as in: ["user"], omitting in uses the current signed-in user's built-in user row. 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. For collections declared as in: ["user"], omitting in uses the current signed-in user's built-in user row. |
watchQuery(collection, options, callbacks) | Subscribe to repeated query refreshes via callbacks.onChange. For collections declared as in: ["user"], omitting in uses the current signed-in user's built-in user row. Returns a handle with .disconnect(). |
createInviteToken(row) | Generate a new invite token for a row and return a MutationReceipt<InviteToken>. Most apps can use .value immediately. |
getExistingInviteToken(row) | Return the existing token if one exists, or null. |
createShareLink(row, token) | Build a shareable URL containing a serialized row ref and token. |
parseInvite(input) | Parse an invite URL into { ref, inviteToken? }. |
acceptInvite(input) | Join a row via invite URL or parsed invite object, and return its handle. Invite joins become direct "editor" members by default. |
saveRow(key, row) | Persist one current row for the signed-in user under your app-defined key. |
openSavedRow(key) | Re-open the saved row for the signed-in user, or null. |
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. |
addMember(row, username, role) | Grant a user access and return a MutationReceipt<void>. Roles: "editor" and "viewer". "editor" can update fields, manage members, manage parents, and send CRDT messages; "viewer" is read-only. |
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. |