contracts 1.24.0: devotionals two years ahead; Apps fetch 2 weeks

CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS (24) for how far ahead the Hub
schedules Cross Code's devotionals, CROSSCODE_DEVOTIONALS_FETCH_DAYS (14)
for what GET /api/v2/devotionals answers. The CSV takes 800 rows and
8 MB, so two years fit in one file. CROSSCODE_DEVOTIONALS_AHEAD_MONTHS
kept, deprecated. Docs: Hub 2.26.1, hub-protocol.md §3c, the App plan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 23:23:18 +02:00
co-authored by Claude Opus 5.5
parent 986d69d51d
commit 9cf2956aff
9 changed files with 77 additions and 29 deletions
+11
View File
@@ -2,6 +2,17 @@
Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …). Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …).
## contracts@1.24.0 - 2026-11-30
Cross Code's devotionals two years ahead, and Apps fetch 2 weeks (Joshua, 2026-11-30). Additive.
- `CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS` (24): how far ahead the Hub schedules them.
- `CROSSCODE_DEVOTIONALS_FETCH_DAYS` (14): the most days one `GET /api/v2/devotionals` answer
covers, `from` included. `CROSSCODE_DEVOTIONALS_AHEAD_MONTHS` (3) is kept but deprecated.
- The devotionals CSV takes 800 rows and 8 MB (was 400 and 2 MB), so two years fit in one file; a
date past `latestDate` says "too far ahead (the last day is …)" instead of naming 3 months.
- Checked: contracts' tests (341), typecheck.
## agent@1.7.0 + contracts@1.23.0 + crosscode script - 2026-11-30 ## agent@1.7.0 + contracts@1.23.0 + crosscode script - 2026-11-30
Church App 1.0.0 groundwork in the server agent (docs/APP-1.0-PLAN.md §12, "Demo scenarios"). Church App 1.0.0 groundwork in the server agent (docs/APP-1.0-PLAN.md §12, "Demo scenarios").
+10 -9
View File
@@ -45,7 +45,7 @@ it goes on sale (crosscode-site, ROADMAP §9).
the App from New install (after Accounts) and lists its releases. the App from New install (after Accounts) and lists its releases.
- On a demo client, **Load a demo scenario** in the Hub loads Accounts, Events, the Website and - On a demo client, **Load a demo scenario** in the Hub loads Accounts, Events, the Website and
the App with the same church, people and events, in one step (§12, "Demo scenarios"). the App with the same church, people and events, in one step (§12, "Demo scenarios").
- The Hub holds 3 months of Cross Code devotionals (written or imported from CSV) in the free - The Hub holds at least 3 months of Cross Code devotionals (written or imported from CSV) in the free
translations (KJV, BSB; decision 14), and an App set to "From Cross Code" shows and sends them translations (KJV, BSB; decision 14), and an App set to "From Cross Code" shows and sends them
with the translation's notice. with the translation's notice.
- A member can add the App to their home screen (Android and iPhone), sign in once, book a one-off - A member can add the App to their home screen (Android and iPhone), sign in once, book a one-off
@@ -309,14 +309,15 @@ Decision 1: **two sources**, chosen in Settings → Devotionals:
so no AI feature reads, writes, translates or summarises a devotional's passage (§4 already keeps so no AI feature reads, writes, translates or summarises a devotional's passage (§4 already keeps
AI away from prayer). AI away from prayer).
- **The Hub** (Hub 2.26.0, decision 1): a **Devotionals** page to write and schedule Cross Code's - **The Hub** (Hub 2.26.0, decision 1): a **Devotionals** page to write and schedule Cross Code's
devotionals **up to 3 months ahead**, with a calendar showing which days are filled, and an devotionals **up to two years ahead** (Hub 2.26.1, contracts 1.24.0; 3 months in 2.26.0), with a calendar showing which days are filled, and an
**Import CSV** button: upload, a preview with every row checked (date, required fields, a **Import CSV** button: upload, a preview with every row checked (date, required fields, a
reference YouVersion understands, a date already taken), then import the valid rows, replacing reference YouVersion understands, a date already taken), then import the valid rows, replacing
or skipping days already filled. Columns: `date, title, passage, translation, passage_text, or skipping days already filled. Columns: `date, title, passage, translation, passage_text,
body, prayer, author`. A template CSV can be downloaded from the page. body, prayer, author`. A template CSV can be downloaded from the page.
- **Getting them to the App:** an App on "From Cross Code" fetches the next 3 months from the Hub - **Getting them to the App:** an App on "From Cross Code" fetches the next **2 weeks** from the
(`GET /api/v2/devotionals`, with its licence token) once a night and keeps them, so a Hub outage Hub (`GET /api/v2/devotionals`, with its licence token; Joshua, 2026-11-30: 2 weeks at most,
changes nothing (ROADMAP §1, rule 2). Edits in the Hub reach the App by the next night, or at contracts `CROSSCODE_DEVOTIONALS_FETCH_DAYS`) once a night and keeps them, so a Hub outage of
less than 2 weeks changes nothing (ROADMAP §1, rule 2). Edits in the Hub reach the App by the next night, or at
once with **Sync now** in the App's settings. The format is `crosscode.devotional/1` once with **Sync now** in the App's settings. The format is `crosscode.devotional/1`
(contracts 1.20.0), so a church's own and Cross Code's devotionals look the same. (contracts 1.20.0), so a church's own and Cross Code's devotionals look the same.
- **Our own:** the same fields and the same CSV import in the App's admin, scheduled as far ahead as - **Our own:** the same fields and the same CSV import in the App's admin, scheduled as far ahead as
@@ -439,7 +440,7 @@ the band in Settings → Licence. Visitors browsing signed out never count.
Network) used for billing, with the band from the heartbeat shown on the install and a Network) used for billing, with the band from the heartbeat shown on the install and a
**renewal check** (the tier is checked once a year at renewal, ROADMAP §10) that flags an install **renewal check** (the tier is checked once a year at renewal, ROADMAP §10) that flags an install
whose band is above its tier; the FastPanel email for `app.`; the App in Jobs' product filter whose band is above its tier; the FastPanel email for `app.`; the App in Jobs' product filter
(already) and demo data; and **Devotionals** (§6): write and schedule up to 3 months ahead, the (already) and demo data; and **Devotionals** (§6): write and schedule up to two years ahead (2.26.1), the
calendar, Import CSV with its preview (the free translations only, §6), and calendar, Import CSV with its preview (the free translations only, §6), and
`GET /api/v2/devotionals` for App installs (licence token, App licences only). `GET /api/v2/devotionals` for App installs (licence token, App licences only).
- **Contracts 1.20.0:** `app` in `DEMO_PRODUCTS`; the `app` section of the church export; the - **Contracts 1.20.0:** `app` in `DEMO_PRODUCTS`; the `app` section of the church export; the
@@ -561,7 +562,7 @@ data that describes **the same church**, so a demo shows the three products work
| `crosscode-platform` `packages/ui` | The tab bar and bottom sheet, if worth sharing; otherwise nothing | workspace | | `crosscode-platform` `packages/ui` | The tab bar and bottom sheet, if worth sharing; otherwise nothing | workspace |
| `crosscode-platform` `packages/seo` | `Article` builder for devotionals and announcements; the icon generator for the manifest | workspace | | `crosscode-platform` `packages/seo` | `Article` builder for devotionals and announcements; the icon generator for the manifest | workspace |
| `crosscode-platform` `scripts/` | `products/app.sh`, `app.env.template.json`, bats tests | — | | `crosscode-platform` `scripts/` | `products/app.sh`, `app.env.template.json`, bats tests | — |
| `events-hub` | App in New install, its releases, env template, billing on the band, renewal check, FastPanel email, Devotionals (write, schedule 3 months ahead, Import CSV in the free translations, the endpoint for Apps), **Load a demo scenario** on a demo client (one `seed-scenario` job; vendored contracts 1.23.0) | Hub `v2.26.0` (**released 2026-11-30**) | | `events-hub` | App in New install, its releases, env template, billing on the band, renewal check, FastPanel email, Devotionals (write, schedule up to two years ahead, Import CSV in the free translations, the endpoint for Apps), **Load a demo scenario** on a demo client (one `seed-scenario` job; vendored contracts 1.23.0) | Hub `v2.26.0` (**released 2026-11-30**) |
| `crosscode-site` | Church App on sale (ROADMAP §9): its page, the active-member tiers, House of Prayer screenshots, the bundle examples (§10), FAQ, `SoftwareApplication` JSON-LD | `v1.10.0` | | `crosscode-site` | Church App on sale (ROADMAP §9): its page, the active-member tiers, House of Prayer screenshots, the bundle examples (§10), FAQ, `SoftwareApplication` JSON-LD | `v1.10.0` |
## 14. Testing ## 14. Testing
@@ -615,8 +616,8 @@ data that describes **the same church**, so a demo shows the three products work
Made by Joshua on 2026-11-30, after the first draft and the mockup: Made by Joshua on 2026-11-30, after the first draft and the mockup:
1. **Devotionals have two sources:** from Cross Code (written in the Hub, scheduled up to 3 months 1. **Devotionals have two sources:** from Cross Code (written in the Hub, scheduled up to two years
ahead, with a CSV import) or the church's own (§6). Verses open in **YouVersion**. ahead (changed from 3 months by Joshua, 2026-11-30; Apps fetch 2 weeks at a time), with a CSV import) or the church's own (§6). Verses open in **YouVersion**.
2. **The House of Prayer is a 24-hour clock**, not a grid (§3; mockup redrawn). 2. **The House of Prayer is a 24-hour clock**, not a grid (§3; mockup redrawn).
3. **Ask for prayer as drawn**, and **every shared request is approved first** (§4). 3. **Ask for prayer as drawn**, and **every shared request is approved first** (§4).
4. **One set of email and WhatsApp credentials per church,** shared by Events, Accounts and the 4. **One set of email and WhatsApp credentials per church,** shared by Events, Accounts and the
+3 -2
View File
@@ -35,7 +35,7 @@ every release).
| 4 | Cross Events 3.0.0: sign-in through Accounts | **Released, rolled out and tested** (`events@3.7.2` rolled out; `3.8.0` released 2026-11-30 for phase 6, not deployed; [EVENTS-3.0-PLAN.md](./EVENTS-3.0-PLAN.md)). Churches sign in through their Accounts; crosscode-site `v1.6.0` deployed | | 4 | Cross Events 3.0.0: sign-in through Accounts | **Released, rolled out and tested** (`events@3.7.2` rolled out; `3.8.0` released 2026-11-30 for phase 6, not deployed; [EVENTS-3.0-PLAN.md](./EVENTS-3.0-PLAN.md)). Churches sign in through their Accounts; crosscode-site `v1.6.0` deployed |
| 4+ | Running it: jobs from the dashboard, styled emails, .env from the Hub, sign-in health, the nightly people check; then frp config and one-product uninstalls, and the Hub's popups, pickers and port list | **Released, deployed and tested** 2026-11-20 and 2026-11-23 (below) | | 4+ | Running it: jobs from the dashboard, styled emails, .env from the Hub, sign-in health, the nightly people check; then frp config and one-product uninstalls, and the Hub's popups, pickers and port list | **Released, deployed and tested** 2026-11-20 and 2026-11-23 (below) |
| 5 | Church Website 1.0.0 | **Released 2026-11-26** (planned 2026-11-21: [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md), all decisions confirmed). Font pairings confirmed 2026-11-24, section variants per template 2026-11-25 (§3). `contracts@1.17.0`, `accounts@1.7.0` and `events@3.7.0` released 2026-11-24, Hub `v2.21.0` 2026-11-25 (the Hub deployed 2026-11-25; the others not rolled out yet). `contracts@1.18.0` and Hub `v2.22.0` (Get more storage) released 2026-11-25, the Hub deployed 2026-11-26. **`website@1.0.0` and `1.0.1` released 2026-11-26**, crosscode-site `v1.7.0` (the Website on sale) released 2026-11-26. **Done** (confirmed by Joshua 2026-11-30): crosscode-site deployed, Hope Family Church and a second church live, the remaining release checks finished. Now `website@1.8.0` (VERSIONS.md) | | 5 | Church Website 1.0.0 | **Released 2026-11-26** (planned 2026-11-21: [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md), all decisions confirmed). Font pairings confirmed 2026-11-24, section variants per template 2026-11-25 (§3). `contracts@1.17.0`, `accounts@1.7.0` and `events@3.7.0` released 2026-11-24, Hub `v2.21.0` 2026-11-25 (the Hub deployed 2026-11-25; the others not rolled out yet). `contracts@1.18.0` and Hub `v2.22.0` (Get more storage) released 2026-11-25, the Hub deployed 2026-11-26. **`website@1.0.0` and `1.0.1` released 2026-11-26**, crosscode-site `v1.7.0` (the Website on sale) released 2026-11-26. **Done** (confirmed by Joshua 2026-11-30): crosscode-site deployed, Hope Family Church and a second church live, the remaining release checks finished. Now `website@1.8.0` (VERSIONS.md) |
| 6 | Church App 1.0.0 | **Under way** (planned and started 2026-11-30): [APP-1.0-PLAN.md](./APP-1.0-PLAN.md), decisions confirmed 2026-11-30 (decision 13, the demo scenarios, added the same day); mockup on the Design canvas "Church App 1.0 mockup". Released 2026-11-30, not deployed: `contracts@1.20.0` to `1.23.0`, `accounts@1.9.0`, `events@3.8.0`, `website@1.8.0`, `agent@1.7.0`, Hub `v2.26.0` (below). Next: deploy the Hub, the first devotionals, `app@1.0.0` | | 6 | Church App 1.0.0 | **Under way** (planned and started 2026-11-30): [APP-1.0-PLAN.md](./APP-1.0-PLAN.md), decisions confirmed 2026-11-30 (decision 13, the demo scenarios, added the same day); mockup on the Design canvas "Church App 1.0 mockup". Released 2026-11-30, not deployed: `contracts@1.20.0` to `1.24.0`, `accounts@1.9.0`, `events@3.8.0`, `website@1.8.0`, `agent@1.7.0`, Hub `v2.26.0` and `v2.26.1` (below). Next: deploy the Hub, the first devotionals, `app@1.0.0` |
| 7 | App 1.x | Not started | | 7 | App 1.x | Not started |
## Released 2026-11-30 (phase 6, first steps) ## Released 2026-11-30 (phase 6, first steps)
@@ -52,6 +52,7 @@ Tagged and pushed on 2026-11-30, **not deployed yet** (Accounts and Events have
| `events@3.8.0`, `@crosscode/demo` 1.1.0 | STOP stops all WhatsApp (not only news), checked before every message and passed on to Accounts; the eight scenarios as Events demo profiles, around each church's own people and campuses | | `events@3.8.0`, `@crosscode/demo` 1.1.0 | STOP stops all WhatsApp (not only news), checked before every message and passed on to Accounts; the eight scenarios as Events demo profiles, around each church's own people and campuses |
| `contracts@1.23.0`, `agent@1.7.0` | `seed-scenario`: a whole demo scenario in one job, on whatever the church has installed (Accounts first, the rest skipped, every release checked first); `seed-demo` for Accounts and the App, and `--scenario` passed on to every product | | `contracts@1.23.0`, `agent@1.7.0` | `seed-scenario`: a whole demo scenario in one job, on whatever the church has installed (Accounts first, the rest skipped, every release checked first); `seed-demo` for Accounts and the App, and `--scenario` passed on to every product |
| `website@1.8.0` | A profile loaded with `--scenario` takes the scenario's people as its leaders and, with a linked Cross Events, shows Events' events through the feed instead of its own; `crosscode demo <church> website --scenario`; `packages/demo` built with the Website. No migration | | `website@1.8.0` | A profile loaded with `--scenario` takes the scenario's people as its leaders and, with a linked Cross Events, shows Events' events through the feed instead of its own; `crosscode demo <church> website --scenario`; `packages/demo` built with the Website. No migration |
| `contracts@1.24.0`, Hub `v2.26.1` | Devotionals up to two years ahead (a CSV of two years in one file); `GET /api/v2/devotionals` answers 2 weeks (what an App fetches each night). No migration |
| Hub `v2.26.0` | The App from New install (Accounts 1.9.0 first) and in every product list and filter; **Load a demo scenario** on a demo client (one `seed-scenario` job, "out of step" installs); demo data for every product; the Website's and App's .env; **Devotionals** (3 months ahead, Import CSV, KJV/BSB only) and `GET /api/v2/devotionals` (hub-protocol.md §3c); the App's tier alert. One migration (Hub) | | Hub `v2.26.0` | The App from New install (Accounts 1.9.0 first) and in every product list and filter; **Load a demo scenario** on a demo client (one `seed-scenario` job, "out of step" installs); demo data for every product; the Website's and App's .env; **Devotionals** (3 months ahead, Import CSV, KJV/BSB only) and `GET /api/v2/devotionals` (hub-protocol.md §3c); the App's tier alert. One migration (Hub) |
All four were checked on PostgreSQL 18 (local, details in `temp/`, never committed): migrations, All four were checked on PostgreSQL 18 (local, details in `temp/`, never committed): migrations,
@@ -138,7 +139,7 @@ Joshua 2026-11-30; VERSIONS.md, "Deployed / rolled out").
the active-member band, **Load a demo scenario** on a demo client (one `seed-scenario` job, the active-member band, **Load a demo scenario** on a demo client (one `seed-scenario` job,
agent 1.7.0+: the server seeds whatever the client has installed, Accounts first; show the agent 1.7.0+: the server seeds whatever the client has installed, Accounts first; show the
report's `loaded` / `skipped`), the **Devotionals** page report's `loaded` / `skipped`), the **Devotionals** page
(3 months ahead, Import CSV, the free translations only: KJV and BSB) and (up to two years ahead from 2.26.1, Import CSV, the free translations only: KJV and BSB) and
`GET /api/v2/devotionals`. **Next:** deploy it (`scripts/deploy.sh` in events-hub, one `GET /api/v2/devotionals`. **Next:** deploy it (`scripts/deploy.sh` in events-hub, one
migration), then write or import the first 3 months of Cross Code devotionals in the KJV or migration), then write or import the first 3 months of Cross Code devotionals in the KJV or
BSB (Hub → Devotionals). BSB (Hub → Devotionals).
+8 -2
View File
@@ -14,8 +14,8 @@ separately below; the two often differ.
| Church Website | `crosscode-platform` (`apps/website`) | **1.8.0** | `website@1.8.0` | 2026-11-30 | | Church Website | `crosscode-platform` (`apps/website`) | **1.8.0** | `website@1.8.0` | 2026-11-30 |
| Accounts | `crosscode-platform` (`apps/accounts`) | **1.9.0** | `accounts@1.9.0` | 2026-11-30 | | Accounts | `crosscode-platform` (`apps/accounts`) | **1.9.0** | `accounts@1.9.0` | 2026-11-30 |
| Server agent | `crosscode-platform` (`apps/agent`) | **1.7.0** | `agent@1.7.0` | 2026-11-30 | | Server agent | `crosscode-platform` (`apps/agent`) | **1.7.0** | `agent@1.7.0` | 2026-11-30 |
| Contracts | `crosscode-platform` (`packages/contracts`) | **1.23.0** | `contracts@1.23.0` | 2026-11-30 | | Contracts | `crosscode-platform` (`packages/contracts`) | **1.24.0** | `contracts@1.24.0` | 2026-11-30 |
| Cross Code Hub | `events-hub` | **2.26.0** | `v2.26.0` | 2026-11-30 | | Cross Code Hub | `events-hub` | **2.26.1** | `v2.26.1` | 2026-11-30 |
| crosscode.co.za | `crosscode-site` | **1.9.1** | `v1.9.1` | 2026-11-27 | | crosscode.co.za | `crosscode-site` | **1.9.1** | `v1.9.1` | 2026-11-27 |
| `crosscode` script | `crosscode-platform` (`scripts/`) | `main` | none | 2026-11-30 (last change: `crosscode demo <church> --scenario <s>` loads a whole scenario on whatever is installed; `crosscode demo <church> app` refused clearly until App 1.0.0; `--scenario` passed on to the Website's demo, the Website builds `packages/demo`; before that Events takes the demo scenarios as profiles, `crosscode demo <church> accounts`, Accounts and Events build `packages/demo`) | | `crosscode` script | `crosscode-platform` (`scripts/`) | `main` | none | 2026-11-30 (last change: `crosscode demo <church> --scenario <s>` loads a whole scenario on whatever is installed; `crosscode demo <church> app` refused clearly until App 1.0.0; `--scenario` passed on to the Website's demo, the Website builds `packages/demo`; before that Events takes the demo scenarios as profiles, `crosscode demo <church> accounts`, Accounts and Events build `packages/demo`) |
@@ -39,6 +39,12 @@ need their own tags until something outside this repo depends on them.
## What each latest release was for ## What each latest release was for
- **Hub 2.26.1 + contracts 1.24.0 (2026-11-30):** Cross Code's devotionals can be scheduled up to
**two years ahead** (was 3 months; `CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS`), and a CSV holds two
years in one file (800 rows, 8 MB). `GET /api/v2/devotionals` answers **2 weeks**
(`CROSSCODE_DEVOTIONALS_FETCH_DAYS`), not 3 months: what an App fetches each night. No
migration. Checked: contracts' tests (341), the Hub's backend tests (301), frontend typecheck and
lint. Not deployed yet.
- **Hub 2.26.0 (2026-11-30):** the Church App (APP-1.0-PLAN §6, §12). The App from New install on - **Hub 2.26.0 (2026-11-30):** the Church App (APP-1.0-PLAN §6, §12). The App from New install on
`app.<address>`, with Accounts 1.9.0 first (also without "requires" in its notes), and in every `app.<address>`, with Accounts 1.9.0 first (also without "requires" in its notes), and in every
product list and filter (installs, Updates). **Load a demo scenario** on a demo client: one product list and filter (installs, Updates). **Load a demo scenario** on a demo client: one
+3 -2
View File
@@ -264,9 +264,10 @@ X-Hub-Install / X-Hub-Timestamp / X-Hub-Signature (as in §3)
`GET /api/v2/devotionals?from=YYYY-MM-DD` (contracts `hub.DEVOTIONALS_PATH`), with `GET /api/v2/devotionals?from=YYYY-MM-DD` (contracts `hub.DEVOTIONALS_PATH`), with
`Authorization: Bearer <the install's licence token>` (§4); no signature. An App set to "From `Authorization: Bearer <the install's licence token>` (§4); no signature. An App set to "From
Cross Code" calls it once a night (and on "Sync now") and keeps what it gets, so a Hub outage Cross Code" calls it once a night (and on "Sync now") and keeps what it gets, so a Hub outage
changes nothing. of less than 2 weeks changes nothing.
- `from` defaults to today (South Africa); the answer covers `from` to 3 months on, one - `from` defaults to today (South Africa); the answer covers `from` and the 13 days after it
(2 weeks, contracts `CROSSCODE_DEVOTIONALS_FETCH_DAYS`; Hub 2.26.0 answered 3 months), one
devotional per day at most, oldest first (`devotionalsReplySchema`, `crosscode.devotional/1`, devotional per day at most, oldest first (`devotionalsReplySchema`, `crosscode.devotional/1`,
each with `source: "crosscode"`). The App replaces its copy of that range: a day missing from each with `source: "crosscode"`). The App replaces its copy of that range: a day missing from
the list was removed in the Hub. the list was removed in the Hub.
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@crosscode/contracts", "name": "@crosscode/contracts",
"version": "1.23.0", "version": "1.24.0",
"description": "The shared JSON formats used by every Cross Code product: zod schemas, JSON Schema, TypeScript types and sample payloads", "description": "The shared JSON formats used by every Cross Code product: zod schemas, JSON Schema, TypeScript types and sample payloads",
"license": "UNLICENSED", "license": "UNLICENSED",
"type": "commonjs", "type": "commonjs",
+27 -10
View File
@@ -12,7 +12,8 @@ import {
* wrote it in the App, so both show and send alike. * wrote it in the App, so both show and send alike.
* *
* Cross Code's reach an App set to "From Cross Code" from the Hub: `GET /api/v2/devotionals` * Cross Code's reach an App set to "From Cross Code" from the Hub: `GET /api/v2/devotionals`
* (`hub.DEVOTIONALS_PATH`), once a night, the next 3 months (`devotionalsReplySchema`). * (`hub.DEVOTIONALS_PATH`), once a night, the next 2 weeks at most (1.24.0, `CROSSCODE_DEVOTIONALS_FETCH_DAYS`;
* `devotionalsReplySchema`).
* *
* Both write them by hand or import a CSV (`DEVOTIONAL_CSV_COLUMNS`, `checkDevotionalCsv`), with * Both write them by hand or import a CSV (`DEVOTIONAL_CSV_COLUMNS`, `checkDevotionalCsv`), with
* the same checks in the Hub and the App. * the same checks in the Hub and the App.
@@ -25,9 +26,21 @@ export const DEVOTIONAL_SOURCES = ["crosscode", "church"] as const;
export const devotionalSourceSchema = z.enum(DEVOTIONAL_SOURCES); export const devotionalSourceSchema = z.enum(DEVOTIONAL_SOURCES);
export type DevotionalSource = z.infer<typeof devotionalSourceSchema>; export type DevotionalSource = z.infer<typeof devotionalSourceSchema>;
/** How far ahead the Hub schedules Cross Code's devotionals, and how far ahead an App fetches them. */ /**
* 1.24.0: the most days one `GET /api/v2/devotionals` answer covers, `from` included (two weeks):
* an App fetches them each night, so it always has the days ahead even if the Hub is down for a while.
*/
export const CROSSCODE_DEVOTIONALS_FETCH_DAYS = 14;
/**
* @deprecated 1.24.0: the Hub schedules `CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS` ahead and an App
* fetches `CROSSCODE_DEVOTIONALS_FETCH_DAYS`. Kept so nothing that read it breaks.
*/
export const CROSSCODE_DEVOTIONALS_AHEAD_MONTHS = 3; export const CROSSCODE_DEVOTIONALS_AHEAD_MONTHS = 3;
/** 1.24.0: how far ahead the Hub schedules Cross Code's devotionals (two years; was 3 months). */
export const CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS = 24;
export const DEVOTIONAL_LIMITS = { title: 200, reference: 100, passageText: 10_000, body: 20_000, prayer: 5_000, author: 200 } as const; export const DEVOTIONAL_LIMITS = { title: 200, reference: 100, passageText: 10_000, body: 20_000, prayer: 5_000, author: 200 } as const;
/** /**
@@ -66,14 +79,15 @@ export type Devotional = z.infer<typeof devotionalSchema>;
/** /**
* The Hub's answer to `GET /api/v2/devotionals?from=YYYY-MM-DD`: Cross Code's devotionals from * The Hub's answer to `GET /api/v2/devotionals?from=YYYY-MM-DD`: Cross Code's devotionals from
* `from` to `to` (3 months on), one per day at most, oldest first. The App replaces its copy of * `from` to `to` (1.24.0: at most `CROSSCODE_DEVOTIONALS_FETCH_DAYS` days, `from` included; 3 months
* before), one per day at most, oldest first. The App replaces its copy of
* that range with them (a day missing from the list was removed in the Hub). * that range with them (a day missing from the list was removed in the Hub).
*/ */
export const devotionalsReplySchema = z.object({ export const devotionalsReplySchema = z.object({
schema: z.literal(DEVOTIONAL_SCHEMA), schema: z.literal(DEVOTIONAL_SCHEMA),
from: dateSchema, from: dateSchema,
to: dateSchema, to: dateSchema,
devotionals: z.array(devotionalSchema.extend({ source: z.literal("crosscode") })).max(100), devotionals: z.array(devotionalSchema.extend({ source: z.literal("crosscode") })).max(100), // 14 from 1.24.0; 100 kept for older Hubs
generatedAt: dateTimeSchema, generatedAt: dateTimeSchema,
}); });
export type DevotionalsReply = z.infer<typeof devotionalsReplySchema>; export type DevotionalsReply = z.infer<typeof devotionalsReplySchema>;
@@ -114,9 +128,12 @@ export const DEVOTIONAL_CSV_COLUMNS = ["date", "title", "passage", "translation"
export type DevotionalCsvColumn = (typeof DEVOTIONAL_CSV_COLUMNS)[number]; export type DevotionalCsvColumn = (typeof DEVOTIONAL_CSV_COLUMNS)[number];
const REQUIRED_COLUMNS: readonly DevotionalCsvColumn[] = ["date", "title", "passage", "translation", "passage_text", "body"]; const REQUIRED_COLUMNS: readonly DevotionalCsvColumn[] = ["date", "title", "passage", "translation", "passage_text", "body"];
/** Rows per import (a year and a bit), and the file size the Hub and App accept. */ /**
export const DEVOTIONAL_CSV_MAX_ROWS = 400; * Rows per import and the file size the Hub and App accept. 1.24.0: two years and a bit (800 rows,
export const DEVOTIONAL_CSV_MAX_BYTES = 2 * 1024 * 1024; * 8 MB; was 400 and 2 MB), so the Hub's two years ahead fit in one file.
*/
export const DEVOTIONAL_CSV_MAX_ROWS = 800;
export const DEVOTIONAL_CSV_MAX_BYTES = 8 * 1024 * 1024;
/** /**
* Reads CSV (RFC 4180: quoted fields, `""` for a quote, line breaks inside quotes), with or * Reads CSV (RFC 4180: quoted fields, `""` for a quote, line breaks inside quotes), with or
@@ -180,7 +197,7 @@ export interface DevotionalCsvResult {
export interface DevotionalCsvOptions { export interface DevotionalCsvOptions {
/** Dates that already have a devotional. */ /** Dates that already have a devotional. */
taken?: Iterable<string>; taken?: Iterable<string>;
/** The last date allowed (the Hub: 3 months from today). Later dates are errors. */ /** The last date allowed (the Hub: two years from today). Later dates are errors. */
latestDate?: string; latestDate?: string;
/** The translations allowed (the Hub and App 1.0: `FREE_BIBLE_TRANSLATION_IDS`). Any by default. */ /** The translations allowed (the Hub and App 1.0: `FREE_BIBLE_TRANSLATION_IDS`). Any by default. */
translations?: readonly BibleTranslationId[]; translations?: readonly BibleTranslationId[];
@@ -192,7 +209,7 @@ export interface DevotionalCsvOptions {
* twice in the file, a date already filled). Never throws. * twice in the file, a date already filled). Never throws.
*/ */
export function checkDevotionalCsv(text: string, options: DevotionalCsvOptions = {}): DevotionalCsvResult { export function checkDevotionalCsv(text: string, options: DevotionalCsvOptions = {}): DevotionalCsvResult {
if (text.length > DEVOTIONAL_CSV_MAX_BYTES) return { fileError: "The file is larger than 2 MB", rows: [] }; if (text.length > DEVOTIONAL_CSV_MAX_BYTES) return { fileError: `The file is larger than ${DEVOTIONAL_CSV_MAX_BYTES / 1024 / 1024} MB`, rows: [] };
const all = parseCsv(text); const all = parseCsv(text);
const header = all[0]; const header = all[0];
if (!header) return { fileError: "The file is empty", rows: [] }; if (!header) return { fileError: "The file is empty", rows: [] };
@@ -228,7 +245,7 @@ export function checkDevotionalCsv(text: string, options: DevotionalCsvOptions =
const date = required("date", "The date"); const date = required("date", "The date");
if (date && !dateSchema.safeParse(date).success) errors.push({ column: "date", message: `"${date}" isn't a date (use YYYY-MM-DD, e.g. 2027-01-05)` }); if (date && !dateSchema.safeParse(date).success) errors.push({ column: "date", message: `"${date}" isn't a date (use YYYY-MM-DD, e.g. 2027-01-05)` });
else if (date && options.latestDate && date > options.latestDate) errors.push({ column: "date", message: `${date} is more than ${CROSSCODE_DEVOTIONALS_AHEAD_MONTHS} months ahead (the last day is ${options.latestDate})` }); else if (date && options.latestDate && date > options.latestDate) errors.push({ column: "date", message: `${date} is too far ahead (the last day is ${options.latestDate})` });
else if (date && seen.has(date)) errors.push({ column: "date", message: `${date} is also on line ${seen.get(date)}` }); else if (date && seen.has(date)) errors.push({ column: "date", message: `${date} is also on line ${seen.get(date)}` });
if (date && !seen.has(date)) seen.set(date, line); if (date && !seen.has(date)) seen.set(date, line);
+2 -2
View File
@@ -327,8 +327,8 @@ export type StorageRequestResponse = z.infer<typeof storageRequestResponseSchema
// --------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------
// Cross Code's devotionals (contracts 1.20.0, Hub 2.26.0, APP-1.0-PLAN §6): an App set to "From // Cross Code's devotionals (contracts 1.20.0, Hub 2.26.0, APP-1.0-PLAN §6): an App set to "From
// Cross Code" fetches the next 3 months once a night (and on "Sync now"), and keeps its copy, so a // Cross Code" fetches the next 2 weeks once a night (1.24.0, `CROSSCODE_DEVOTIONALS_FETCH_DAYS`; 3 months
// Hub outage changes nothing. `GET /api/v2/devotionals?from=YYYY-MM-DD` with // before) and on "Sync now", and keeps its copy, so a Hub outage of under 2 weeks changes nothing. `GET /api/v2/devotionals?from=YYYY-MM-DD` with
// `Authorization: Bearer <the install's licence token>`; App licences only (`403 NOT_AN_APP`), // `Authorization: Bearer <the install's licence token>`; App licences only (`403 NOT_AN_APP`),
// active or in grace (`403 LICENCE_INACTIVE`). The answer is a `devotionalsReplySchema`. // active or in grace (`403 LICENCE_INACTIVE`). The answer is a `devotionalsReplySchema`.
// --------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------
+12 -1
View File
@@ -2,6 +2,7 @@ import {
BIBLE_BOOKS, BIBLE_TRANSLATIONS, DEVOTIONAL_CSV_COLUMNS, FREE_BIBLE_TRANSLATION_IDS, FREE_QUOTE_VERSES, DEVOTIONAL_CSV_TEMPLATE, checkDevotionalCsv, devotionalCsv, BIBLE_BOOKS, BIBLE_TRANSLATIONS, DEVOTIONAL_CSV_COLUMNS, FREE_BIBLE_TRANSLATION_IDS, FREE_QUOTE_VERSES, DEVOTIONAL_CSV_TEMPLATE, checkDevotionalCsv, devotionalCsv,
devotionalDisclaimer, devotionalsReplySchema, findBibleBook, quotedVerses, formatBibleReference, parseBibleReference, parseCsv, passageVerseCount, youVersionUrl, devotionalDisclaimer, devotionalsReplySchema, findBibleBook, quotedVerses, formatBibleReference, parseBibleReference, parseCsv, passageVerseCount, youVersionUrl,
type PassageLocation, type PassageLocation,
CROSSCODE_DEVOTIONALS_FETCH_DAYS, CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS, DEVOTIONAL_CSV_MAX_ROWS,
} from "../src"; } from "../src";
import { sample } from "./helpers"; import { sample } from "./helpers";
@@ -202,7 +203,17 @@ describe("checkDevotionalCsv", () => {
expect(r.rows[0]).toMatchObject({ taken: true, errors: [] }); expect(r.rows[0]).toMatchObject({ taken: true, errors: [] });
expect(r.rows[1]!.warnings[0]!.message).toContain("40 verses"); expect(r.rows[1]!.warnings[0]!.message).toContain("40 verses");
expect(r.rows[1]!.devotional).not.toBeNull(); expect(r.rows[1]!.devotional).not.toBeNull();
expect(r.rows[2]!.errors[0]!.message).toContain("more than 3 months ahead"); expect(r.rows[2]!.errors[0]!.message).toContain("too far ahead (the last day is 2027-03-31)");
});
it("1.24.0: two years ahead in the Hub, in one file; Apps fetch 2 weeks", () => {
expect([CROSSCODE_DEVOTIONALS_SCHEDULE_MONTHS, CROSSCODE_DEVOTIONALS_FETCH_DAYS]).toEqual([24, 14]);
const start = Date.UTC(2027, 0, 1);
const rows = Array.from({ length: 731 }, (_, i) => row({ date: new Date(start + i * 864e5).toISOString().slice(0, 10), translation: "KJV" }));
const r = checkDevotionalCsv(devotionalCsv(rows), { latestDate: "2028-12-31" });
expect(DEVOTIONAL_CSV_MAX_ROWS).toBeGreaterThanOrEqual(731);
expect(r.fileError).toBeNull();
expect(r.rows.filter((x) => x.devotional)).toHaveLength(731);
}); });
it("refuses a file without the required columns, or without rows", () => { it("refuses a file without the required columns, or without rows", () => {