// Lists every recorded version of a document — what it looked like after each // change. (`audit()` tells you WHO/WHEN; this tells you WHAT it changed to.) import { defineAction } from '@voltro/protocol' import { Schema } from 'effect' export const documentHistory = defineAction({ name: 'documents.history', // Open — and this one needs its bound named, because a version table is a // second copy of your data that the `tenant()` mixin does NOT scope for you. // The executor passes `ctx.request.subject.tenantId` to `rowHistory` // explicitly, so a caller-supplied id from another tenant yields nothing. // Read that as the load-bearing line it is: drop the argument and this // becomes a cross-tenant read of every past value. // // No auth strategy and no rbac ship in this template, so a // `guards: [{ scope: 'documents:history' }]` would deny every caller. openAccess: 'lists past versions of a document in the CALLER\'S OWN tenant — `rowHistory` is passed ' + '`subject.tenantId` explicitly, so an id from another tenant returns nothing (a version ' + 'table is not auto-scoped by `tenant()`). No auth strategy ships here to guard against.', input: Schema.Struct({ id: Schema.String }), output: Schema.Array(Schema.Struct({ version: Schema.Number, op: Schema.String, title: Schema.NullOr(Schema.String), content: Schema.NullOr(Schema.String), changedAt: Schema.Number, })), })