// Edits a document's content — a new version in its history. Each update is // snapshotted, so you can list every version or read the value as of any past // instant. import { defineMutation } from '@voltro/protocol' import { Schema } from 'effect' export const updateDocument = defineMutation({ name: 'documents.update', target: { table: 'documents', op: 'update' }, // Open: `tenant()` scopes the update, so a caller-supplied `id` from another // tenant matches no row. Nothing is destroyed either — the row-history plugin // snapshots the previous value, so every edit is recoverable through // `documents.history` / `documents.asOf`. // // History is an audit trail, not an access control: it tells you WHAT // changed, never whether the change was allowed. No auth strategy or rbac // ships here, so a `guards: [{ scope }]` would deny every caller. openAccess: 'edits a document of the request\'s tenant (an id outside it matches no row); the previous ' + 'value is snapshotted, so nothing is destroyed. Version history records changes — it ' + 'does not authorize them.', input: Schema.Struct({ id: Schema.String, content: Schema.String, }), output: Schema.Struct({ id: Schema.String, title: Schema.String, content: Schema.String, tenantId: Schema.String, }), })