// Time-travel: the document's value as of a past instant (`at`, epoch ms). // Returns null if it didn't exist (or was deleted) then. import { defineAction } from '@voltro/protocol' import { Schema } from 'effect' export const documentAsOf = defineAction({ name: 'documents.asOf', // Open, with the same load-bearing detail as `documents.history`: the // executor passes `ctx.request.subject.tenantId` into `rowAsOf` explicitly, // because a version table is not auto-scoped by the `tenant()` mixin. That // argument is what keeps a caller-supplied id from reading another tenant's // past values; do not drop it. // // No auth strategy and no rbac ship in this template, so a scope guard would // deny every caller rather than the wrong ones. openAccess: 'returns one past value of a document in the CALLER\'S OWN tenant — `rowAsOf` is passed ' + '`subject.tenantId` explicitly, so an id from another tenant returns null. Time travel ' + 'reaches only where the live read already could.', input: Schema.Struct({ id: Schema.String, at: Schema.Number }), output: Schema.NullOr(Schema.Struct({ title: Schema.String, content: Schema.String, })), })