// Reactive list of the tenant's projects. The runtime AND-merges // `eq('tenantId', subject.tenantId)` (the table carries `tenant()`), so this // never leaks across tenants — no manual filter needed. import { defineQuery } from '@voltro/protocol' import { Schema } from 'effect' export const listProjects = defineQuery({ name: 'projects.list', source: 'projects', // Open: `tenant()` confines every delivery to the tenantId on the request, so // one tenant's projects never reach another's subscription. This template // bundles billing + notifications + presence and deliberately ships NO auth // strategy — pair it with `api-auth` / `api-saas-starter` for the identity // half. Until then the tenantId is the caller's own `x-tenant` header, and a // `guards: [{ scope }]` would be unsatisfiable: an anonymous Subject holds no // scopes, so the guard would deny 100% of traffic. openAccess: 'lists the request tenant\'s own projects (`tenant()` scopes every delivery). This ' + 'template ships no auth strategy — see `api-saas-starter`, which does and guards these ' + 'same procedures — so the tenant comes from the caller\'s `x-tenant` header.', input: Schema.Struct({}), output: Schema.Array(Schema.Struct({ id: Schema.String, name: Schema.String, tenantId: Schema.String, createdAt: Schema.Date, })), })