app: the House of Prayer's backend (APP-1.0-PLAN §3)
Commitments stored as rules (start, length, once/daily/weekly, end, skips) in the church's timezone, daylight saving included; the day's coverage as counts only, cached until a booking changes, live over server-sent events (X-Accel-Buffering off, a comment every 25 s). Booking, skipping, changing, cancelling within the 8-hour rule, renewing (a signed single-use link), "I prayed" (self-reported). Campaigns and moderated testimonies; the admin's bookings with names, always access-logged; booking on a member's behalf. Reminders (every minute) and renewal notices (14 and 3 days before) queued in an outbox for the messaging slice. The heartbeat's prayer counts; export and delete for a member's prayer. Migration 20261202000000_house_of_prayer (checked on PostgreSQL 18: applies, no diff). 66 backend tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,322 @@
|
||||
import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import type { AddressInfo } from 'node:net';
|
||||
import request from 'supertest';
|
||||
import { stats } from '../src/hub/client.js';
|
||||
import { sendReminders, sendRenewalNotices } from '../src/prayer/jobs.js';
|
||||
import { prayerToken } from '../src/prayer/tokens.js';
|
||||
import { cookieHeader, harness, MEMBER, signInAs, type Harness } from './support/harness.js';
|
||||
|
||||
const OTHER = '44444444-4444-4444-8444-444444444444';
|
||||
const COORD = '55555555-5555-4555-8555-555555555555';
|
||||
|
||||
const DAY = 24 * 3600e3;
|
||||
|
||||
// The clock starts on Tuesday 1 December 2026 at 08:00 in Johannesburg (06:00 UTC).
|
||||
const slot = (over: object = {}) => ({ startDate: '2026-12-02', startMinute: 120, durationMinutes: 60, recurrence: 'once', ...over });
|
||||
|
||||
async function setup() {
|
||||
const h = await harness() as Harness;
|
||||
const member = await signInAs(h, { sub: MEMBER, name: 'Thandi Mokoena', email: 'thandi@hope.test' });
|
||||
const other = await signInAs(h, { sub: OTHER, name: 'Pieter Botha', email: 'pieter@hope.test' });
|
||||
const as = (cookies: Record<string, string>) => ({
|
||||
get: (path: string) => request(h.app).get(path).set('Cookie', cookieHeader(cookies)),
|
||||
post: (path: string, body: object = {}) => request(h.app).post(path).set('Cookie', cookieHeader(cookies)).set('Origin', 'https://app.hope.test').send(body),
|
||||
patch: (path: string, body: object) => request(h.app).patch(path).set('Cookie', cookieHeader(cookies)).set('Origin', 'https://app.hope.test').send(body),
|
||||
put: (path: string, body: object) => request(h.app).put(path).set('Cookie', cookieHeader(cookies)).set('Origin', 'https://app.hope.test').send(body),
|
||||
del: (path: string) => request(h.app).delete(path).set('Cookie', cookieHeader(cookies)).set('Origin', 'https://app.hope.test'),
|
||||
});
|
||||
return { h, thandi: as(member), pieter: as(other), visitor: as({}), as };
|
||||
}
|
||||
|
||||
describe('the prayer wall', () => {
|
||||
it('shows the day as counts only: no name, email or id of anyone, and "mine" only to the member', async () => {
|
||||
const { thandi, pieter, visitor } = await setup();
|
||||
assert.equal((await thandi.post('/api/v1/me/prayer/commitments', slot())).status, 201);
|
||||
assert.equal((await pieter.post('/api/v1/me/prayer/commitments', slot({ recurrence: 'daily' }))).status, 201);
|
||||
|
||||
const pub = await visitor.get('/api/v1/prayer/day?date=2026-12-02');
|
||||
assert.equal(pub.status, 200);
|
||||
assert.match(pub.headers['cache-control']!, /public/);
|
||||
const two = pub.body.slots.find((s: { minute: number }) => s.minute === 120);
|
||||
assert.deepEqual({ count: two.count, covered: two.covered, mine: two.mine }, { count: 2, covered: true, mine: false });
|
||||
assert.equal(pub.body.covered, 1);
|
||||
assert.equal(pub.body.total, 24);
|
||||
assert.equal(pub.body.target, 1);
|
||||
|
||||
const own = await thandi.get('/api/v1/prayer/day?date=2026-12-02');
|
||||
assert.match(own.headers['cache-control']!, /private/);
|
||||
assert.equal(own.body.slots.find((s: { minute: number }) => s.minute === 120).mine, true);
|
||||
assert.equal(own.body.slots.filter((s: { mine: boolean }) => s.mine).length, 1);
|
||||
|
||||
for (const res of [pub, own, await visitor.get('/api/v1/prayer/day'), await visitor.get('/api/v1/prayer/campaign'), await visitor.get('/api/v1/prayer/testimonies')]) {
|
||||
const text = JSON.stringify(res.body);
|
||||
for (const secret of ['Thandi', 'Pieter', 'thandi@', 'pieter@', MEMBER, OTHER]) assert.ok(!text.includes(secret), `${secret} in an answer`);
|
||||
}
|
||||
});
|
||||
|
||||
it('refuses everything while the House of Prayer is switched off', async () => {
|
||||
const { h, visitor, thandi } = await setup();
|
||||
await h.ctx.settings.set('modules', JSON.stringify({ 'house-of-prayer': false }));
|
||||
assert.equal((await visitor.get('/api/v1/prayer/day')).body.error.code, 'MODULE_OFF');
|
||||
assert.equal((await thandi.post('/api/v1/me/prayer/commitments', slot())).status, 404);
|
||||
});
|
||||
|
||||
it('needs a sign-in to book, and checks the wall\'s rules', async () => {
|
||||
const { visitor, thandi } = await setup();
|
||||
assert.equal((await visitor.post('/api/v1/me/prayer/commitments', slot())).status, 401);
|
||||
const bad = await thandi.post('/api/v1/me/prayer/commitments', slot({ startMinute: 90 }));
|
||||
assert.equal(bad.status, 400);
|
||||
assert.equal(bad.body.error.code, 'NOT_A_SLOT');
|
||||
assert.equal((await thandi.post('/api/v1/me/prayer/commitments', slot({ startDate: '2026-12-01', startMinute: 420 }))).body.error.code, 'IN_THE_PAST');
|
||||
assert.equal((await thandi.post('/api/v1/me/prayer/commitments', slot({ recurrence: 'daily', endDate: '2027-12-05' }))).body.error.code, 'TOO_LONG');
|
||||
assert.equal((await thandi.post('/api/v1/me/prayer/commitments', { ...slot(), name: 'x' })).body.error.code, 'VALIDATION');
|
||||
});
|
||||
|
||||
it('refuses a change from another site', async () => {
|
||||
const { h } = await setup();
|
||||
const res = await request(h.app).post('/api/v1/me/prayer/commitments').set('Origin', 'https://evil.test').send(slot());
|
||||
assert.equal(res.status, 403);
|
||||
});
|
||||
});
|
||||
|
||||
describe('a member\'s commitments', () => {
|
||||
it('books every week, skips a date outside the 8 hours, and not one inside them', async () => {
|
||||
const { h, thandi } = await setup();
|
||||
const { body } = await thandi.post('/api/v1/me/prayer/commitments', slot({ startDate: '2026-12-01', startMinute: 15 * 60, recurrence: 'weekly', endDate: '2027-03-01' }));
|
||||
// Today at 15:00 is 7 hours away: locked.
|
||||
const locked = await thandi.post(`/api/v1/me/prayer/commitments/${body.id}/skip`, { date: '2026-12-01' });
|
||||
assert.equal(locked.status, 409);
|
||||
assert.equal(locked.body.error.code, 'LOCKED');
|
||||
assert.equal((await thandi.post(`/api/v1/me/prayer/commitments/${body.id}/skip`, { date: '2026-12-08' })).status, 200);
|
||||
assert.equal((await thandi.post(`/api/v1/me/prayer/commitments/${body.id}/skip`, { date: '2026-12-09' })).body.error.code, 'NO_OCCURRENCE');
|
||||
const day = await thandi.get('/api/v1/prayer/day?date=2026-12-08');
|
||||
assert.equal(day.body.covered, 0);
|
||||
assert.equal((await thandi.del(`/api/v1/me/prayer/commitments/${body.id}/skip/2026-12-08`)).status, 200);
|
||||
assert.equal((await thandi.get('/api/v1/prayer/day?date=2026-12-08')).body.covered, 1);
|
||||
|
||||
const mine = await thandi.get('/api/v1/me/prayer');
|
||||
assert.equal(mine.status, 200);
|
||||
const c = mine.body.commitments[0];
|
||||
assert.equal(c.upcoming[0].date, '2026-12-01');
|
||||
assert.equal(c.upcoming[0].locked, true);
|
||||
assert.equal(c.upcoming[1].locked, false);
|
||||
assert.equal(mine.body.rules.cancelHours, 8);
|
||||
assert.ok(h.db.tables.get('prayerSkip')!.size === 0);
|
||||
});
|
||||
|
||||
it('says who to contact inside the window, as Settings says', async () => {
|
||||
const { h, thandi } = await setup();
|
||||
await h.ctx.settings.set('prayer_wall', JSON.stringify({ coordinator: { name: 'Lerato', contact: '082 555 0101' } }));
|
||||
const { body } = await thandi.post('/api/v1/me/prayer/commitments', slot({ startDate: '2026-12-01', startMinute: 12 * 60 }));
|
||||
const res = await thandi.del(`/api/v1/me/prayer/commitments/${body.id}`);
|
||||
assert.equal(res.status, 409);
|
||||
assert.match(res.body.error.message, /Lerato \(082 555 0101\)/);
|
||||
});
|
||||
|
||||
it('cancels: a booking with nothing done goes; a running one ends after its last locked date', async () => {
|
||||
const { h, thandi } = await setup();
|
||||
const once = (await thandi.post('/api/v1/me/prayer/commitments', slot())).body;
|
||||
assert.deepEqual((await thandi.del(`/api/v1/me/prayer/commitments/${once.id}`)).body, { removed: true, endDate: null });
|
||||
|
||||
const daily = (await thandi.post('/api/v1/me/prayer/commitments', slot({ startDate: '2026-12-01', startMinute: 12 * 60, recurrence: 'daily' }))).body;
|
||||
h.clock.add(2 * DAY); // 3 December, 08:00: today's 12:00 is locked.
|
||||
const res = await thandi.del(`/api/v1/me/prayer/commitments/${daily.id}`);
|
||||
assert.deepEqual(res.body, { removed: false, endDate: '2026-12-03' });
|
||||
assert.equal((await thandi.get('/api/v1/prayer/day?date=2026-12-04')).body.covered, 0);
|
||||
assert.equal((await thandi.get('/api/v1/prayer/day?date=2026-12-02')).body.covered, 1);
|
||||
});
|
||||
|
||||
it('changes the reminder in place, the end date within the limits, and a new time as a new rule', async () => {
|
||||
const { h, thandi } = await setup();
|
||||
const { id } = (await thandi.post('/api/v1/me/prayer/commitments', slot({ startDate: '2026-12-01', startMinute: 12 * 60, recurrence: 'daily', endDate: '2027-01-31' }))).body;
|
||||
assert.equal((await thandi.patch(`/api/v1/me/prayer/commitments/${id}`, { reminder: 'evening', channel: 'whatsapp' })).body.id, id);
|
||||
assert.equal((await thandi.patch(`/api/v1/me/prayer/commitments/${id}`, { endDate: '2027-06-30' })).body.endDate, '2027-06-30');
|
||||
assert.equal((await thandi.patch(`/api/v1/me/prayer/commitments/${id}`, { endDate: '2027-12-31' })).body.error.code, 'TOO_LONG');
|
||||
const moved = await thandi.patch(`/api/v1/me/prayer/commitments/${id}`, { startDate: '2026-12-05', startMinute: 3 * 60 });
|
||||
assert.notEqual(moved.body.id, id);
|
||||
const old = await h.db.prayerCommitment.findUnique({ where: { id } });
|
||||
assert.equal(old!.endDate, '2026-12-01');
|
||||
const fresh = await h.db.prayerCommitment.findUnique({ where: { id: moved.body.id } });
|
||||
assert.equal(fresh!.reminder, 'evening');
|
||||
assert.equal(fresh!.endDate, '2027-06-30');
|
||||
});
|
||||
|
||||
it('marks "I prayed" once the slot has ended, in the App or from the reminder\'s link', async () => {
|
||||
const { h, thandi, visitor } = await setup();
|
||||
const { id } = (await thandi.post('/api/v1/me/prayer/commitments', slot({ recurrence: 'daily', endDate: '2026-12-10' }))).body;
|
||||
assert.equal((await thandi.post(`/api/v1/me/prayer/commitments/${id}/prayed`, { date: '2026-12-02' })).body.error.code, 'NOT_YET');
|
||||
h.clock.add(DAY); // 2 December, 08:00
|
||||
assert.equal((await thandi.post(`/api/v1/me/prayer/commitments/${id}/prayed`, { date: '2026-12-02' })).body.prayed, true);
|
||||
assert.equal((await thandi.post(`/api/v1/me/prayer/commitments/${id}/prayed`, { date: '2026-12-02' })).body.prayed, true);
|
||||
h.clock.add(DAY);
|
||||
const token = prayerToken(h.ctx, 'prayed', id, '2026-12-03');
|
||||
assert.equal((await visitor.post('/api/v1/prayer/prayed', { token })).body.prayed, true);
|
||||
assert.equal((await visitor.post('/api/v1/prayer/prayed', { token: token.replace(/.$/, token.endsWith('A') ? 'B' : 'A') })).status, 410);
|
||||
assert.equal(await h.db.prayedMark.count({ where: { commitmentId: id } }), 2);
|
||||
assert.equal((await thandi.get('/api/v1/me/prayer')).body.prayedTotal, 2);
|
||||
});
|
||||
|
||||
it('renews for another year from the notice\'s link, once', async () => {
|
||||
const { h, thandi, visitor } = await setup();
|
||||
const { id } = (await thandi.post('/api/v1/me/prayer/commitments', slot({ recurrence: 'weekly', endDate: '2026-12-20' }))).body;
|
||||
const token = prayerToken(h.ctx, 'renew', id, '2026-12-20');
|
||||
const res = await visitor.post('/api/v1/prayer/renew', { token });
|
||||
assert.deepEqual(res.body, { renewed: true, endDate: '2027-12-20' });
|
||||
assert.equal((await visitor.post('/api/v1/prayer/renew', { token })).body.error.code, 'LINK_USED');
|
||||
});
|
||||
|
||||
it('keeps someone else\'s commitments out of reach', async () => {
|
||||
const { thandi, pieter } = await setup();
|
||||
const { id } = (await thandi.post('/api/v1/me/prayer/commitments', slot())).body;
|
||||
assert.equal((await pieter.del(`/api/v1/me/prayer/commitments/${id}`)).status, 404);
|
||||
assert.equal((await pieter.get('/api/v1/me/prayer')).body.commitments.length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('reminders and renewal notices', () => {
|
||||
it('queues a reminder once when it\'s due, on the member\'s channel, and none for a skipped date', async () => {
|
||||
const { h, thandi } = await setup();
|
||||
const { id } = (await thandi.post('/api/v1/me/prayer/commitments', slot({ recurrence: 'daily', endDate: '2026-12-10', channel: 'whatsapp' }))).body;
|
||||
await thandi.post(`/api/v1/me/prayer/commitments/${id}/skip`, { date: '2026-12-03' });
|
||||
assert.deepEqual(await sendReminders(h.ctx), { queued: 0 });
|
||||
h.clock.set('2026-12-01T23:00:00Z'); // 01:00 on 2 December, an hour before.
|
||||
assert.deepEqual(await sendReminders(h.ctx), { queued: 1 });
|
||||
assert.deepEqual(await sendReminders(h.ctx), { queued: 0 });
|
||||
const [m] = [...h.db.tables.get('outboxMessage')!.values()] as { kind: string; channel: string; payload: { date: string; prayedPath: string } }[];
|
||||
assert.equal(m!.kind, 'prayer-reminder');
|
||||
assert.equal(m!.channel, 'whatsapp');
|
||||
assert.equal(m!.payload.date, '2026-12-02');
|
||||
assert.match(m!.payload.prayedPath, /^\/prayer\/prayed\?token=/);
|
||||
h.clock.set('2026-12-02T23:10:00Z');
|
||||
assert.deepEqual(await sendReminders(h.ctx), { queued: 0 });
|
||||
});
|
||||
|
||||
it('sends the renewal notice 14 days before the end and again 3 days before', async () => {
|
||||
const { h, thandi } = await setup();
|
||||
await thandi.post('/api/v1/me/prayer/commitments', slot({ recurrence: 'weekly', endDate: '2026-12-31' }));
|
||||
assert.deepEqual(await sendRenewalNotices(h.ctx), { queued: 0 });
|
||||
h.clock.set('2026-12-17T07:00:00Z');
|
||||
assert.deepEqual(await sendRenewalNotices(h.ctx), { queued: 1 });
|
||||
assert.deepEqual(await sendRenewalNotices(h.ctx), { queued: 0 });
|
||||
h.clock.set('2026-12-28T07:00:00Z');
|
||||
assert.deepEqual(await sendRenewalNotices(h.ctx), { queued: 1 });
|
||||
const kinds = [...h.db.tables.get('outboxMessage')!.values()].map((m) => (m as { payload: { renewPath: string } }).payload.renewPath);
|
||||
assert.equal(kinds.length, 2);
|
||||
assert.match(kinds[0]!, /^\/prayer\/renew\?token=/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('live coverage', () => {
|
||||
it('streams which dates changed, unbuffered', async () => {
|
||||
const { h, thandi } = await setup();
|
||||
const server = h.app.listen(0);
|
||||
try {
|
||||
const port = (server.address() as AddressInfo).port;
|
||||
const ac = new AbortController();
|
||||
const res = await fetch(`http://127.0.0.1:${port}/api/v1/prayer/stream`, { signal: ac.signal });
|
||||
assert.equal(res.headers.get('content-type'), 'text/event-stream; charset=utf-8');
|
||||
assert.equal(res.headers.get('x-accel-buffering'), 'no');
|
||||
const reader = res.body!.getReader();
|
||||
let text = '';
|
||||
await thandi.post('/api/v1/me/prayer/commitments', slot());
|
||||
while (!text.includes('event: changed')) text += new TextDecoder().decode((await reader.read()).value);
|
||||
assert.match(text, /data: \{"dates":\["2026-12-02"\]\}/);
|
||||
ac.abort();
|
||||
} finally {
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('the admin', () => {
|
||||
it('shows names only to a prayer coordinator with 2FA, and logs every view', async () => {
|
||||
const { h, thandi, pieter, as } = await setup();
|
||||
await thandi.post('/api/v1/me/prayer/commitments', slot());
|
||||
assert.equal((await pieter.get('/api/v1/admin/prayer/bookings?date=2026-12-02')).status, 403);
|
||||
const coord = as(await signInAs(h, { sub: COORD, name: 'Lerato', roles: ['prayer_coordinator'] }, true));
|
||||
const res = await coord.get('/api/v1/admin/prayer/bookings?date=2026-12-02');
|
||||
assert.equal(res.status, 200);
|
||||
assert.equal(res.body.people[0].member.name, 'Thandi Mokoena');
|
||||
const log = [...h.db.tables.get('accessLog')!.values()] as { actorId: string; action: string; targetId: string }[];
|
||||
assert.deepEqual(log.map((l) => [l.actorId, l.action, l.targetId]), [[COORD, 'prayer_bookings_viewed', '2026-12-02']]);
|
||||
const week = await coord.get('/api/v1/admin/prayer/week?from=2026-12-01');
|
||||
assert.equal(week.body.days[1].covered, 1);
|
||||
assert.ok(!JSON.stringify(week.body).includes('Thandi'));
|
||||
});
|
||||
|
||||
it('books on a member\'s behalf, changes the rules and runs a campaign', async () => {
|
||||
const { h, visitor, as } = await setup();
|
||||
const coord = as(await signInAs(h, { sub: COORD, name: 'Lerato', roles: ['prayer_coordinator'] }, true));
|
||||
const booked = await coord.post('/api/v1/admin/prayer/commitments', { ...slot({ recurrence: 'daily' }), memberId: MEMBER });
|
||||
assert.equal(booked.status, 201);
|
||||
assert.equal((await h.db.prayerCommitment.findUnique({ where: { id: booked.body.id } }))!.bookedById, COORD);
|
||||
assert.equal((await coord.put('/api/v1/admin/prayer/wall', { cancelHours: 49 })).status, 400);
|
||||
assert.equal((await coord.put('/api/v1/admin/prayer/wall', { slotMinutes: 30, targetPerSlot: 2 })).body.wall.slotMinutes, 30);
|
||||
assert.equal((await visitor.get('/api/v1/prayer/day?date=2026-12-02')).body.total, 48);
|
||||
|
||||
const c = await coord.post('/api/v1/admin/prayer/campaigns', { title: '21 days of prayer', description: 'Before the conference', startDate: '2026-11-28', endDate: '2026-12-18', targetPerSlot: 3 });
|
||||
assert.equal(c.status, 201);
|
||||
const summary = (await visitor.get('/api/v1/prayer/campaign')).body.campaign;
|
||||
assert.equal(summary.title, '21 days of prayer');
|
||||
assert.equal(summary.daysLeft, 18);
|
||||
assert.equal(summary.hoursPrayed, 0);
|
||||
assert.equal((await visitor.get('/api/v1/prayer/day?date=2026-12-02')).body.target, 3);
|
||||
});
|
||||
|
||||
it('moderates testimonies before anyone sees them, with the first name or "Anonymous"', async () => {
|
||||
const { h, thandi, pieter, visitor, as } = await setup();
|
||||
const a = (await thandi.post('/api/v1/me/prayer/testimonies', { text: 'My mother is home from hospital.', showName: true })).body;
|
||||
const b = (await pieter.post('/api/v1/me/prayer/testimonies', { text: 'Work came through after months.' })).body;
|
||||
assert.equal(a.status, 'pending');
|
||||
assert.deepEqual((await visitor.get('/api/v1/prayer/testimonies')).body.testimonies, []);
|
||||
const coord = as(await signInAs(h, { sub: COORD, name: 'Lerato', roles: ['prayer_coordinator'] }, true));
|
||||
assert.equal((await coord.get('/api/v1/admin/prayer/testimonies')).body.testimonies.length, 2);
|
||||
await coord.post(`/api/v1/admin/prayer/testimonies/${a.id}/approve`);
|
||||
await coord.post(`/api/v1/admin/prayer/testimonies/${b.id}/approve`);
|
||||
const shown = (await visitor.get('/api/v1/prayer/testimonies')).body.testimonies.map((t: { by: string }) => t.by).sort();
|
||||
assert.deepEqual(shown, ['Anonymous', 'Thandi']);
|
||||
assert.equal((await coord.post(`/api/v1/admin/prayer/testimonies/${b.id}/remove`, {})).status, 400);
|
||||
await coord.post(`/api/v1/admin/prayer/testimonies/${b.id}/remove`, { reason: 'It names a colleague.' });
|
||||
assert.equal((await pieter.get('/api/v1/me/prayer/testimonies')).body.testimonies[0].removedReason, 'It names a colleague.');
|
||||
assert.equal([...h.db.tables.get('outboxMessage')!.values()].length, 1);
|
||||
assert.equal((await thandi.del(`/api/v1/me/prayer/testimonies/${a.id}`)).status, 200);
|
||||
assert.deepEqual((await visitor.get('/api/v1/prayer/testimonies')).body.testimonies, []);
|
||||
});
|
||||
});
|
||||
|
||||
describe('the heartbeat, export and delete', () => {
|
||||
it('reports last week\'s coverage and active commitments, as counts', async () => {
|
||||
const { h, thandi } = await setup();
|
||||
await thandi.post('/api/v1/me/prayer/commitments', slot({ startDate: '2026-12-01', startMinute: 12 * 60, durationMinutes: 12 * 60, recurrence: 'daily' }));
|
||||
h.clock.add(8 * DAY);
|
||||
const s = await stats(h.ctx);
|
||||
// 1 December is half covered from 12:00, and the 6 days after it are too.
|
||||
assert.deepEqual(s.prayer, { coverageLast7dPercent: 50, activeCommitments: 1 });
|
||||
});
|
||||
|
||||
it('exports a member\'s prayer and, when they delete their account, opens their future slots', async () => {
|
||||
const { h, thandi } = await setup();
|
||||
const daily = (await thandi.post('/api/v1/me/prayer/commitments', slot({ recurrence: 'daily' }))).body;
|
||||
const later = (await thandi.post('/api/v1/me/prayer/commitments', slot({ startDate: '2026-12-20' }))).body;
|
||||
await thandi.post('/api/v1/me/prayer/testimonies', { text: 'Thank you for praying with us.' });
|
||||
h.clock.add(3 * DAY);
|
||||
await thandi.post(`/api/v1/me/prayer/commitments/${daily.id}/prayed`, { date: '2026-12-03' });
|
||||
const call = (type: string, extra: object = {}) => request(h.app).post('/api/accounts/v1/events').set('x-test-signed', 'yes').set('Content-Type', 'application/json')
|
||||
.send(JSON.stringify({ schema: 'crosscode.identity/1', callId: '66666666-6666-4666-8666-666666666666', occurredAt: '2026-12-04T06:00:00.000Z', sub: MEMBER, type, ...extra }));
|
||||
const exp = await call('user.export', { exportId: '77777777-7777-4777-8777-777777777777' });
|
||||
assert.deepEqual(exp.body.sections.map((s: { key: string }) => s.key), ['app_member', 'app_prayer_commitments', 'app_prayed', 'app_testimonies']);
|
||||
assert.equal(exp.body.sections[1].records[0].time, '02:00');
|
||||
|
||||
await call('user.deleted');
|
||||
assert.equal(await h.db.prayerCommitment.findUnique({ where: { id: later.id } }), null);
|
||||
const kept = await h.db.prayerCommitment.findUnique({ where: { id: daily.id } });
|
||||
assert.deepEqual([kept!.memberId, kept!.endDate], [null, '2026-12-03']);
|
||||
assert.equal(await h.db.testimony.count(), 0);
|
||||
assert.equal((await h.db.prayedMark.findFirst({}))!.memberId, null);
|
||||
const past = await request(h.app).get('/api/v1/prayer/day?date=2026-12-03');
|
||||
assert.equal(past.body.covered, 1);
|
||||
assert.equal((await request(h.app).get('/api/v1/prayer/day?date=2026-12-05')).body.covered, 0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { addMonths, localParts, zonedTime } from '../src/lib/zoned.js';
|
||||
import {
|
||||
cancelledEndDate, checkBooking, coveragePercent, dayCoverage, daySlots, DEFAULT_WALL, isLocked, nextOccurrence,
|
||||
occurrencesBetween, reminderAt, renewedEndDate, type Rule,
|
||||
} from '../src/prayer/rules.js';
|
||||
|
||||
const SA = 'Africa/Johannesburg';
|
||||
const LONDON = 'Europe/London';
|
||||
|
||||
const rule = (over: Partial<Rule>): Rule => ({
|
||||
id: 'r1', memberId: 'm1', startDate: '2026-12-01', startMinute: 120, durationMinutes: 60, recurrence: 'once', endDate: '2026-12-01', skips: [], ...over,
|
||||
});
|
||||
|
||||
describe('local times in the church\'s timezone', () => {
|
||||
it('turns a local date and minute into an instant and back', () => {
|
||||
const t = zonedTime('2026-12-01', 120, SA)!;
|
||||
assert.equal(t.toISOString(), '2026-12-01T00:00:00.000Z');
|
||||
assert.deepEqual(localParts(t, SA), { date: '2026-12-01', minute: 120, weekday: 2 });
|
||||
assert.equal(zonedTime('2026-12-01', 1440 + 60, SA)!.toISOString(), '2026-12-01T23:00:00.000Z');
|
||||
});
|
||||
|
||||
it('has no instant for a time the clocks jump over, and the first of a time that happens twice', () => {
|
||||
assert.equal(zonedTime('2027-03-28', 60, LONDON), null);
|
||||
assert.equal(zonedTime('2027-03-28', 120, LONDON)!.toISOString(), '2027-03-28T01:00:00.000Z');
|
||||
assert.equal(zonedTime('2026-10-25', 60, LONDON)!.toISOString(), '2026-10-25T00:00:00.000Z');
|
||||
});
|
||||
|
||||
it('keeps a month\'s end inside the month', () => {
|
||||
assert.equal(addMonths('2027-01-31', 1), '2027-02-28');
|
||||
assert.equal(addMonths('2026-12-01', 12), '2027-12-01');
|
||||
});
|
||||
});
|
||||
|
||||
describe('slots', () => {
|
||||
it('cuts the day into 24, 48 or 96 slots', () => {
|
||||
assert.equal(daySlots('2026-12-01', 60, SA).length, 24);
|
||||
assert.equal(daySlots('2026-12-01', 30, SA).length, 48);
|
||||
assert.equal(daySlots('2026-12-01', 15, SA).length, 96);
|
||||
assert.equal(daySlots('2026-12-01', 60, SA)[0]!.start.toISOString(), '2026-11-30T22:00:00.000Z');
|
||||
});
|
||||
|
||||
it('gives a day with daylight saving whole hours: 23 when the clocks jump forward, 24 when they go back', () => {
|
||||
const spring = daySlots('2027-03-28', 60, LONDON);
|
||||
assert.equal(spring.length, 23);
|
||||
assert.ok(!spring.some((s) => s.minute === 60));
|
||||
for (const s of spring) assert.equal(s.end.getTime() - s.start.getTime(), 3600e3);
|
||||
const autumn = daySlots('2026-10-25', 60, LONDON);
|
||||
assert.equal(autumn.length, 24);
|
||||
// 01:00 happens twice: its slot runs to the (first) 02:00, two hours later.
|
||||
assert.equal(autumn.find((s) => s.minute === 60)!.end.getTime() - autumn.find((s) => s.minute === 60)!.start.getTime(), 2 * 3600e3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('commitments as rules', () => {
|
||||
it('works out daily, weekly and once occurrences, without the skipped dates', () => {
|
||||
const from = zonedTime('2026-12-01', 0, SA)!;
|
||||
const to = zonedTime('2026-12-15', 0, SA)!;
|
||||
const daily = rule({ recurrence: 'daily', endDate: '2027-11-30', skips: ['2026-12-03'] });
|
||||
assert.equal(occurrencesBetween(daily, from, to, SA).length, 13);
|
||||
const weekly = rule({ recurrence: 'weekly', endDate: '2027-11-30' });
|
||||
assert.deepEqual(occurrencesBetween(weekly, from, to, SA).map((o) => o.date), ['2026-12-01', '2026-12-08']);
|
||||
assert.equal(occurrencesBetween(rule({}), from, to, SA).length, 1);
|
||||
});
|
||||
|
||||
it('keeps a weekly rule on its weekday and stops at its end date', () => {
|
||||
const r = rule({ recurrence: 'weekly', startDate: '2026-12-03', endDate: '2026-12-24' });
|
||||
const all = occurrencesBetween(r, zonedTime('2026-11-01', 0, SA)!, zonedTime('2027-02-01', 0, SA)!, SA);
|
||||
assert.deepEqual(all.map((o) => o.date), ['2026-12-03', '2026-12-10', '2026-12-17', '2026-12-24']);
|
||||
});
|
||||
|
||||
it('a year of daily slots is one rule', () => {
|
||||
const r = rule({ recurrence: 'daily', endDate: '2027-11-30' });
|
||||
assert.equal(occurrencesBetween(r, zonedTime('2026-12-01', 0, SA)!, zonedTime('2027-12-01', 0, SA)!, SA).length, 365);
|
||||
});
|
||||
|
||||
it('finds the next occurrence', () => {
|
||||
const r = rule({ recurrence: 'daily', endDate: '2026-12-10' });
|
||||
assert.equal(nextOccurrence(r, new Date('2026-12-01T06:00:00Z'), SA)!.date, '2026-12-02');
|
||||
assert.equal(nextOccurrence(r, new Date('2026-12-11T06:00:00Z'), SA), null);
|
||||
});
|
||||
|
||||
it('moves a start the clocks jump over to just after the jump', () => {
|
||||
const r = rule({ startDate: '2027-03-28', endDate: '2027-03-28', startMinute: 60 });
|
||||
const [o] = occurrencesBetween(r, zonedTime('2027-03-27', 0, LONDON)!, zonedTime('2027-03-29', 0, LONDON)!, LONDON);
|
||||
assert.equal(o!.start.toISOString(), '2027-03-28T01:00:00.000Z');
|
||||
});
|
||||
});
|
||||
|
||||
describe('coverage', () => {
|
||||
it('counts people per slot, once each, and marks the asker\'s own; no names', () => {
|
||||
const rules = [
|
||||
rule({ id: 'a', memberId: 'm1', startMinute: 120, durationMinutes: 120 }),
|
||||
rule({ id: 'b', memberId: 'm1', startMinute: 120, durationMinutes: 60 }),
|
||||
rule({ id: 'c', memberId: 'm2', startMinute: 180, durationMinutes: 60, recurrence: 'daily', endDate: '2027-01-01' }),
|
||||
rule({ id: 'd', memberId: null, startMinute: 600, durationMinutes: 60 }),
|
||||
];
|
||||
const day = dayCoverage('2026-12-01', rules, { slotMinutes: 60 }, SA, 'm2');
|
||||
const at = (h: number) => day.slots.find((s) => s.minute === h * 60)!;
|
||||
assert.equal(at(2).count, 1);
|
||||
assert.equal(at(2).mine, false);
|
||||
assert.equal(at(3).count, 2);
|
||||
assert.equal(at(3).mine, true);
|
||||
assert.equal(at(10).count, 1);
|
||||
assert.equal(day.covered, 3);
|
||||
assert.equal(day.total, 24);
|
||||
assert.deepEqual(Object.keys(at(3)).sort(), ['count', 'covered', 'end', 'mine', 'minute', 'start']);
|
||||
assert.ok(!JSON.stringify(day).includes('m1'));
|
||||
});
|
||||
|
||||
it('counts a slot that runs past midnight on the next day too', () => {
|
||||
const r = rule({ startMinute: 23 * 60, durationMinutes: 120 });
|
||||
const next = dayCoverage('2026-12-02', [r], { slotMinutes: 60 }, SA);
|
||||
assert.equal(next.slots[0]!.count, 1);
|
||||
assert.equal(next.covered, 1);
|
||||
});
|
||||
|
||||
it('counts a 1-hour commitment in both 30-minute slots it covers', () => {
|
||||
const day = dayCoverage('2026-12-01', [rule({ startMinute: 120 })], { slotMinutes: 30 }, SA);
|
||||
assert.equal(day.covered, 2);
|
||||
assert.equal(day.total, 48);
|
||||
});
|
||||
|
||||
it('gives the share of slots covered', () => {
|
||||
const one = dayCoverage('2026-12-01', [rule({ durationMinutes: 12 * 60, startMinute: 0 })], { slotMinutes: 60 }, SA);
|
||||
assert.equal(coveragePercent([one]), 50);
|
||||
assert.equal(coveragePercent([]), 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('booking rules', () => {
|
||||
const now = new Date('2026-12-01T06:00:00Z'); // 08:00 SAST
|
||||
|
||||
it('books once, every day or every week, up to 12 months', () => {
|
||||
assert.deepEqual(checkBooking({ startDate: '2026-12-02', startMinute: 120, durationMinutes: 60, recurrence: 'once' }, now, DEFAULT_WALL, SA), { endDate: '2026-12-02' });
|
||||
assert.deepEqual(checkBooking({ startDate: '2026-12-02', startMinute: 120, durationMinutes: 120, recurrence: 'daily' }, now, DEFAULT_WALL, SA), { endDate: '2027-12-01' });
|
||||
assert.deepEqual(checkBooking({ startDate: '2026-12-02', startMinute: 120, durationMinutes: 60, recurrence: 'weekly', endDate: '2027-03-01' }, now, DEFAULT_WALL, SA), { endDate: '2027-03-01' });
|
||||
});
|
||||
|
||||
it('refuses what the rules don\'t allow', () => {
|
||||
const code = (input: Parameters<typeof checkBooking>[0], wall = DEFAULT_WALL) => {
|
||||
const r = checkBooking(input, now, wall, SA);
|
||||
return 'error' in r ? r.error.code : 'ok';
|
||||
};
|
||||
assert.equal(code({ startDate: '2026-12-02', startMinute: 90, durationMinutes: 60, recurrence: 'once' }), 'NOT_A_SLOT');
|
||||
assert.equal(code({ startDate: '2026-12-02', startMinute: 120, durationMinutes: 45, recurrence: 'once' }), 'BAD_LENGTH');
|
||||
assert.equal(code({ startDate: '2026-12-02', startMinute: 120, durationMinutes: 13 * 60, recurrence: 'once' }), 'BAD_LENGTH');
|
||||
assert.equal(code({ startDate: '2027-12-02', startMinute: 120, durationMinutes: 60, recurrence: 'once' }), 'TOO_FAR_AHEAD');
|
||||
assert.equal(code({ startDate: '2026-12-02', startMinute: 120, durationMinutes: 60, recurrence: 'daily', endDate: '2027-12-02' }), 'TOO_LONG');
|
||||
assert.equal(code({ startDate: '2026-12-02', startMinute: 120, durationMinutes: 60, recurrence: 'daily', endDate: '2026-12-01' }), 'END_BEFORE_START');
|
||||
assert.equal(code({ startDate: '2026-12-01', startMinute: 7 * 60, durationMinutes: 60, recurrence: 'once' }), 'IN_THE_PAST');
|
||||
assert.equal(code({ startDate: '2026-12-01', startMinute: 30, durationMinutes: 30, recurrence: 'once' }, { ...DEFAULT_WALL, slotMinutes: 30 }), 'IN_THE_PAST');
|
||||
assert.equal(code({ startDate: '2026-12-02', startMinute: 30, durationMinutes: 30, recurrence: 'once' }, { ...DEFAULT_WALL, slotMinutes: 30 }), 'ok');
|
||||
assert.equal(code({ startDate: '2027-03-01', startMinute: 0, durationMinutes: 60, recurrence: 'once' }, { ...DEFAULT_WALL, bookAheadMonths: 2 }), 'TOO_FAR_AHEAD');
|
||||
});
|
||||
|
||||
it('locks an occurrence within the cancel window', () => {
|
||||
assert.equal(isLocked({ start: new Date('2026-12-01T13:00:00Z') }, now, 8), true);
|
||||
assert.equal(isLocked({ start: new Date('2026-12-01T14:00:00Z') }, now, 8), false);
|
||||
assert.equal(isLocked({ start: new Date('2026-12-01T07:00:00Z') }, now, 0), false);
|
||||
});
|
||||
|
||||
it('ends a cancelled rule after its last locked occurrence, or removes it when nothing happened yet', () => {
|
||||
// Daily at 02:00 from 25 November: 1 December's has happened, 2 December's is 18 hours away.
|
||||
const daily = rule({ startDate: '2026-11-25', recurrence: 'daily', endDate: '2027-11-24' });
|
||||
assert.equal(cancelledEndDate(daily, now, DEFAULT_WALL, SA), '2026-12-01');
|
||||
// With a 24-hour window, 2 December's 02:00 is locked too.
|
||||
assert.equal(cancelledEndDate(daily, now, { cancelHours: 24 }, SA), '2026-12-02');
|
||||
assert.equal(cancelledEndDate(rule({ startDate: '2026-12-05', endDate: '2026-12-05' }), now, DEFAULT_WALL, SA), null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('reminders and renewals', () => {
|
||||
it('reminds 15 minutes or an hour before, or at 20:00 the evening before', () => {
|
||||
const o = { date: '2026-12-02', start: zonedTime('2026-12-02', 120, SA)! };
|
||||
assert.equal(reminderAt('none', o, SA), null);
|
||||
assert.equal(reminderAt('min15', o, SA)!.toISOString(), '2026-12-01T23:45:00.000Z');
|
||||
assert.equal(reminderAt('hour1', o, SA)!.toISOString(), '2026-12-01T23:00:00.000Z');
|
||||
assert.equal(reminderAt('evening', o, SA)!.toISOString(), '2026-12-01T18:00:00.000Z');
|
||||
});
|
||||
|
||||
it('renews for another year from the current end', () => {
|
||||
assert.equal(renewedEndDate({ endDate: '2027-11-30' }, DEFAULT_WALL), '2028-11-30');
|
||||
});
|
||||
});
|
||||
@@ -113,3 +113,19 @@ export function cookiesFrom(res: { headers: Record<string, unknown> }, keep: Rec
|
||||
}
|
||||
|
||||
export const cookieHeader = (c: Record<string, string>) => Object.entries(c).map(([k, v]) => `${k}=${v}`).join('; ');
|
||||
|
||||
/**
|
||||
* Signs `who` in through the stand-in Accounts (with 2FA when `mfa`), creating them as a Member
|
||||
* with `roles` first if given; answers the cookies to send.
|
||||
*/
|
||||
export async function signInAs(h: Harness, who: { sub: string; name?: string; email?: string; roles?: string[] }, mfa = false): Promise<Record<string, string>> {
|
||||
const { default: request } = await import('supertest');
|
||||
if (who.roles?.length) {
|
||||
await h.db.member.upsert({ where: { id: who.sub }, create: { id: who.sub, name: who.name ?? 'Someone', email: who.email ?? `${who.sub}@hope.test`, roles: who.roles }, update: { roles: who.roles } });
|
||||
}
|
||||
h.fake.next = { sub: who.sub, name: who.name ?? 'Someone', email: who.email ?? `${who.sub.slice(0, 8)}@hope.test`, amr: mfa ? ['pwd', 'mfa'] : ['pwd'] };
|
||||
const start = await request(h.app).get(`/api/auth/signin?returnTo=%2F${mfa ? '&mfa=1' : ''}`);
|
||||
const after = cookiesFrom(start);
|
||||
const back = await request(h.app).get('/api/auth/callback?code=abc&state=xyz').set('Cookie', cookieHeader(after));
|
||||
return cookiesFrom(back, after);
|
||||
}
|
||||
|
||||
@@ -14,13 +14,21 @@ const DEFAULTS: Record<string, () => Row> = {
|
||||
session: () => ({ sid: null, mfa: false, idToken: null, lastSeenAt: new Date() }),
|
||||
productLink: () => ({ connectedById: null, lastSyncError: null, showEvents: true, lastSyncAt: null, lastGoodAt: null }),
|
||||
auditLog: () => ({ actorId: null, targetId: null, metadata: null, ip: null }),
|
||||
prayerCommitment: () => ({ reminder: 'hour1', channel: 'email', note: null, bookedById: null, renewalNoticesSent: 0, renewedAt: null }),
|
||||
prayedMark: () => ({ memberId: null }),
|
||||
prayerCampaign: () => ({ imageUrl: null, goal: null, targetPerSlot: null, createdById: null }),
|
||||
testimony: () => ({ campaignId: null, showName: false, status: 'pending', removedReason: null, moderatedById: null, moderatedAt: null }),
|
||||
accessLog: () => ({ targetId: null, metadata: null, ip: null }),
|
||||
outboxMessage: () => ({ sentAt: null, failedAt: null, error: null, attempts: 0 }),
|
||||
};
|
||||
const KEYS: Record<string, string> = { appSetting: 'key', productLink: 'installId', linkNonce: 'nonce' };
|
||||
const UNIQUE: Record<string, string[]> = { session: ['tokenHash'] };
|
||||
const HAS_UPDATED_AT = new Set(['member', 'appSetting', 'productLink']);
|
||||
/** Unique fields: one field, or several together (`@@unique([a, b])`). */
|
||||
const UNIQUE: Record<string, (string | string[])[]> = { session: ['tokenHash'], outboxMessage: ['dedupeKey'], prayerSkip: [['commitmentId', 'date']], prayedMark: [['commitmentId', 'date']] };
|
||||
const HAS_UPDATED_AT = new Set(['member', 'appSetting', 'productLink', 'prayerCommitment', 'prayerCampaign']);
|
||||
/** `include` support: model → relation → [other model, foreign key on the other (many) or on this row (one)]. */
|
||||
const RELATIONS: Record<string, Record<string, { model: string; many: boolean; key: string }>> = {
|
||||
member: { sessions: { model: 'session', many: true, key: 'memberId' } },
|
||||
prayerCommitment: { skips: { model: 'prayerSkip', many: true, key: 'commitmentId' }, marks: { model: 'prayedMark', many: true, key: 'commitmentId' } },
|
||||
};
|
||||
|
||||
const v = (x: unknown) => (x instanceof Date ? x.getTime() : x);
|
||||
@@ -89,19 +97,20 @@ function model(name: string, tables: Map<string, Map<unknown, Row>>) {
|
||||
};
|
||||
const findWhere = (where: Row) => {
|
||||
if (where && key in where && typeof where[key] !== 'object') return table().get(where[key]) ?? null;
|
||||
for (const u of UNIQUE[name] ?? []) if (where && u in where) return [...table().values()].find((r) => r[u] === where[u]) ?? null;
|
||||
for (const u of UNIQUE[name] ?? []) if (typeof u === 'string' && where && u in where) return [...table().values()].find((r) => r[u] === where[u]) ?? null;
|
||||
return [...table().values()].find((r) => matches(r, where)) ?? null;
|
||||
};
|
||||
const checkUnique = (row: Row, except?: unknown) => {
|
||||
for (const u of UNIQUE[name] ?? []) {
|
||||
if (row[u] == null) continue;
|
||||
if ([...table().values()].some((r) => r[key] !== except && r[u] === row[u])) throw prismaError('P2002', `Unique constraint failed on ${name}.${u}`);
|
||||
const fields = typeof u === 'string' ? [u] : u;
|
||||
if (fields.some((f) => row[f] == null)) continue;
|
||||
if ([...table().values()].some((r) => r[key] !== except && fields.every((f) => v(r[f]) === v(row[f])))) throw prismaError('P2002', `Unique constraint failed on ${name}.${fields.join('_')}`);
|
||||
}
|
||||
};
|
||||
const api = {
|
||||
findUnique: async ({ where, select }: { where: Row; select?: Row }) => { const r = findWhere(where); return r ? pick(clone(r), select) : null; },
|
||||
findUnique: async ({ where, select, include }: { where: Row; select?: Row; include?: Row }) => { const r = findWhere(where); return r ? withIncludes(pick(clone(r), select), include) : null; },
|
||||
findUniqueOrThrow: async (args: { where: Row; select?: Row }) => { const r = await api.findUnique(args); if (!r) throw prismaError('P2025', `${name} not found`); return r; },
|
||||
findFirst: async ({ where, orderBy, select }: { where?: Row; orderBy?: Row | Row[]; select?: Row } = {}) => { const r = order([...table().values()].filter((x) => matches(x, where)), orderBy)[0]; return r ? pick(clone(r), select) : null; },
|
||||
findFirst: async ({ where, orderBy, select, include }: { where?: Row; orderBy?: Row | Row[]; select?: Row; include?: Row } = {}) => { const r = order([...table().values()].filter((x) => matches(x, where)), orderBy)[0]; return r ? withIncludes(pick(clone(r), select), include) : null; },
|
||||
findMany: async ({ where, orderBy, take, skip, select, include }: { where?: Row; orderBy?: Row | Row[]; take?: number; skip?: number; select?: Row; include?: Row } = {}) =>
|
||||
order([...table().values()].filter((x) => matches(x, where)), orderBy).slice(skip ?? 0, (skip ?? 0) + (take ?? Infinity)).map((r) => withIncludes(pick(clone(r), select), include)),
|
||||
aggregate: async ({ where, _sum }: { where?: Row; _sum: Row }) => {
|
||||
@@ -148,7 +157,11 @@ function model(name: string, tables: Map<string, Map<unknown, Row>>) {
|
||||
},
|
||||
};
|
||||
const cascade = (from: string, id: unknown) => {
|
||||
if (from === 'member') for (const [k, r] of tables.get('session') ?? []) if (r.memberId === id) tables.get('session')!.delete(k);
|
||||
const drop = (model: string, field: string) => { for (const [k, r] of tables.get(model) ?? []) if (r[field] === id) tables.get(model)!.delete(k); };
|
||||
const unset = (model: string, field: string) => { for (const r of tables.get(model)?.values() ?? []) if (r[field] === id) r[field] = null; };
|
||||
if (from === 'member') { drop('session', 'memberId'); drop('testimony', 'memberId'); drop('outboxMessage', 'memberId'); unset('prayerCommitment', 'memberId'); }
|
||||
if (from === 'prayerCommitment') { drop('prayerSkip', 'commitmentId'); drop('prayedMark', 'commitmentId'); }
|
||||
if (from === 'prayerCampaign') unset('testimony', 'campaignId');
|
||||
};
|
||||
const withIncludes = (row: Row, include?: Row) => {
|
||||
for (const [rel, on] of Object.entries(include ?? {})) {
|
||||
|
||||
Reference in New Issue
Block a user