// Creates a document — version 1 in its history. The row-history plugin // snapshots the insert automatically (no code here); read it back via the // documents.history / documents.asOf actions. import { defineMutation } from '@voltro/protocol' import { Schema } from 'effect' export const createDocument = defineMutation({ name: 'documents.create', target: { table: 'documents', op: 'insert' }, // Open: writes only the title + content the caller sent, into the request's // tenant (`tenant()` auto-stamps `tenantId`), and touches no existing row. // No auth strategy and no rbac ship in this template, so every caller is an // anonymous Subject holding no scopes and a `guards: [{ scope }]` would deny // all of them rather than the wrong ones. openAccess: 'inserts a document built only from caller-supplied fields into the request\'s tenant; ' + 'reads nothing and modifies no existing row. No auth strategy ships here, so there is no ' + 'identity a scope guard could name.', input: Schema.Struct({ title: Schema.NonEmptyString, content: Schema.String, }), output: Schema.Struct({ id: Schema.String, title: Schema.String, content: Schema.String, tenantId: Schema.String, }), })