// Creates a profile. `ssn` is an `.encrypted()` column — you pass plaintext, // the store middleware encrypts it on write (the cipher is registered by // governancePlugin's fieldEncryption). Nothing special in the handler. import { defineMutation } from '@voltro/protocol' import { Schema } from 'effect' export const createProfile = defineMutation({ name: 'profiles.create', target: { table: 'profiles', op: 'insert' }, // Open: writes exactly the three fields the caller passed and echoes back // only `{ id, name, email }` — `ssn` is `.serverOnly()` and is deliberately // absent from the output, so what the caller sent in never comes back out. // It reads nothing and cannot reach an existing row. // // No auth strategy and no rbac ship in this template, so every caller is an // anonymous Subject holding no scopes; a `guards: [{ scope }]` would deny all // of them rather than the wrong ones. Add an identity, then the guard. openAccess: 'inserts only the fields the caller supplied and echoes back `{ id, name, email }` — the ' + '`ssn` it takes is `.serverOnly()` and never appears in a response. Reads nothing, ' + 'modifies no existing row.', input: Schema.Struct({ name: Schema.NonEmptyString, email: Schema.String, ssn: Schema.String, }), output: Schema.Struct({ id: Schema.String, name: Schema.String, email: Schema.String, }), })