Release events@2.2.0 and contracts@1.2.0
Events 2.2.0: the move into the monorepo and the crosscode script, plus AI use in tokens and the backend under /api. Contracts 1.2.0: token fields on the AI status. Agent phase 1d moves to contracts 1.3.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -38,9 +38,9 @@ visitor ──http───▶ frps (vhost_http_port) ══tunnel══▶ frp
|
||||
On this server, nginx sends `/api`, `/uploads`, `/health` and `/docs` to the backend (port 5000)
|
||||
and everything else to the Next.js site (port 3000), the same as a normal install.
|
||||
|
||||
### One address, one rule (2.3.0 and later)
|
||||
### One address, one rule (2.2.0 and later)
|
||||
|
||||
From 2.3.0 everything the backend serves is under **`/api`**: the API (`/api/v2`), the status page
|
||||
From 2.2.0 everything the backend serves is under **`/api`**: the API (`/api/v2`), the status page
|
||||
(`/api`), health (`/api/health`), the API reference (`/api/docs/v2`) and uploaded files
|
||||
(`/api/uploads/…`). So the site and its API share one address (`events.yourchurch.org`, no
|
||||
separate `events-api.` record), and a web server or panel such as FastPanel needs a single
|
||||
@@ -54,10 +54,10 @@ rule:
|
||||
Set `BACKEND_URL` (backend `.env`) and `NEXT_PUBLIC_API_URL` (frontend `.env.production`) to the
|
||||
same `https://` address as `FRONTEND_URL`, then rebuild the frontend. The old paths (`/health`,
|
||||
`/docs/v2`, `/uploads/…`) still answer on the backend's port, so a site with a separate API
|
||||
address keeps working unchanged. With only `/api` routed, links made before 2.3.0 that point at
|
||||
address keeps working unchanged. With only `/api` routed, links made before 2.2.0 that point at
|
||||
`https://<site>/uploads/…` stop working (they aren't stored that way, but could be in an old
|
||||
email); keep the four-path rule above if that matters. Pictures, logos and attachments are all
|
||||
given out as `/api/uploads/…` from 2.3.0.
|
||||
given out as `/api/uploads/…` from 2.2.0.
|
||||
|
||||
## 2. Before you start
|
||||
|
||||
@@ -285,7 +285,7 @@ setup). If the `[hope-events-https]` section fails to start, check `journalctl -
|
||||
|
||||
## 6. Finish in the browser
|
||||
|
||||
1. Open `https://events.yourchurch.org/api/health` (`/health` before 2.3.0) — it should answer with the version.
|
||||
1. Open `https://events.yourchurch.org/api/health` (`/health` before 2.2.0) — it should answer with the version.
|
||||
2. Open `https://events.yourchurch.org/setup`: create the admin account.
|
||||
3. **Site settings → Licence**: enter the licence key to connect to the Hub. The site checks in
|
||||
every 15 minutes from then on (outgoing HTTPS to `events-hub.crosscode.co.za`, which frp
|
||||
|
||||
@@ -20,7 +20,7 @@ The backend provides a RESTful API for managing users, events, registrations, pa
|
||||
- Static uploads for event images
|
||||
|
||||
Documentation: see Backend API Documentation and Backend README for environment setup and endpoints.
|
||||
- API reference: `/api/docs/v2` on the running site (OpenAPI; admin token; `/docs/v2` before 2.3.0) — ./backend/API_DOCUMENTATION.md
|
||||
- API reference: `/api/docs/v2` on the running site (OpenAPI; admin token; `/docs/v2` before 2.2.0) — ./backend/API_DOCUMENTATION.md
|
||||
- Moving to 2.0 (v1 API removed): ./MIGRATING-TO-2.md
|
||||
- Backend README: ./backend/README.md
|
||||
|
||||
@@ -156,7 +156,7 @@ set names that match your PM2 apps (`pm2 ls`) and the port you use.
|
||||
|
||||
## Useful Links
|
||||
|
||||
- API reference: `/api/docs/v2` on the running site (OpenAPI; admin token; `/docs/v2` before 2.3.0) — ./backend/API_DOCUMENTATION.md
|
||||
- API reference: `/api/docs/v2` on the running site (OpenAPI; admin token; `/docs/v2` before 2.2.0) — ./backend/API_DOCUMENTATION.md
|
||||
- Moving to 2.0 (v1 API removed): ./MIGRATING-TO-2.md
|
||||
- Backend README: ./backend/README.md
|
||||
- Frontend README: ./frontend/README.md
|
||||
|
||||
@@ -12,6 +12,15 @@ Write for church admins, not developers: no environment variables, endpoints or
|
||||
developer log is CHANGELOG.md. A tagged version without a section here shows "No details given".
|
||||
-->
|
||||
|
||||
## 2.2.0
|
||||
|
||||
- **AI use is now shown in tokens.** Site settings → AI shows how much of this month's AI allowance
|
||||
your team has used, as input tokens (what's sent to the AI) and output tokens (its answers), with
|
||||
an estimate of the whole allowance. The tables of who used it and for what show tokens too.
|
||||
- **Behind the scenes:** Cross Events now lives alongside our other church products, so every
|
||||
product is updated the same way. Your site works as before, and your data and settings stay as
|
||||
they are.
|
||||
|
||||
## 2.1.1
|
||||
|
||||
- **Sending feedback forms and reminders no longer makes you wait.** "Send now" and "Remind" on the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/events-backend",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "Event Management System Backend",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
-- 2.3.0: tokens per AI call, which is what the site shows (the rand amount is the Hub's business).
|
||||
-- 2.2.0: tokens per AI call, which is what the site shows (the rand amount is the Hub's business).
|
||||
ALTER TABLE "AiCall" ADD COLUMN "inputTokens" INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE "AiCall" ADD COLUMN "outputTokens" INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
@@ -2342,9 +2342,9 @@ model AiCall {
|
||||
// ok, refused, incomplete, failed, cap_reached, unavailable
|
||||
outcome String
|
||||
// What the church was charged, in cents (fractions of a cent). Kept for the record; the site
|
||||
// shows tokens (2.3.0), and only the Hub shows rand.
|
||||
// shows tokens (2.2.0), and only the Hub shows rand.
|
||||
chargedCents Float @default(0)
|
||||
// Tokens the call used (2.3.0): input counts cached prompt tokens. 0 when the call failed.
|
||||
// Tokens the call used (2.2.0): input counts cached prompt tokens. 0 when the call failed.
|
||||
inputTokens Int @default(0)
|
||||
outputTokens Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* AI helpers (2.0, roadmap §15). The site never holds a Claude API key: every call goes through
|
||||
* the Cross Events Hub (docs/hub-protocol.md §3b), which checks the licence's monthly cap, calls
|
||||
* Claude and meters the call. The site shows that use as tokens and a percentage (2.3.0); the cap's
|
||||
* Claude and meters the call. The site shows that use as tokens and a percentage (2.2.0); the cap's
|
||||
* rand amount stays on the Hub. This module:
|
||||
* - works out what the AI buttons do (`aiStatus`): hidden, working, or disabled until the
|
||||
* allowance renews — from the licence token first, then the Hub (cached for a minute);
|
||||
@@ -35,7 +35,7 @@ export type HelperName = (typeof HELPERS)[number];
|
||||
|
||||
/**
|
||||
* What the Hub says (§3b), as the site keeps it. The Hub also sends the allowance in rand
|
||||
* (`capCents`, `usedCents`); the site drops those (2.3.0): people see tokens and a percentage,
|
||||
* (`capCents`, `usedCents`); the site drops those (2.2.0): people see tokens and a percentage,
|
||||
* and only the Hub shows rand. The token fields are null from a Hub before 2.0.1.
|
||||
*/
|
||||
export type HubAiStatus = {
|
||||
|
||||
@@ -153,7 +153,7 @@ app.use((req, res, next) => {
|
||||
// Licence suspended, revoked or missing: no new or edited events, registrations or payments (src/hub/readOnly.js).
|
||||
app.use(require('./hub/readOnly').licenceReadOnly);
|
||||
|
||||
// Everything the backend serves is under /api (2.3.0), so the site and its API can share one
|
||||
// Everything the backend serves is under /api (2.2.0), so the site and its API can share one
|
||||
// address: the web server sends /api to the backend and everything else to the frontend. The old
|
||||
// paths (/, /health, /docs/v2, /uploads) still work for sites with a separate API address.
|
||||
|
||||
@@ -180,7 +180,7 @@ app.use('/api/v2', require('./v2').v2Router());
|
||||
app.use(legacyLinkRedirects);
|
||||
app.use('/api/docs/v2', require('./v2').v2DocsRouter());
|
||||
app.get('/api/docs', (req, res) => res.redirect(301, '/api/docs/v2'));
|
||||
// Before 2.3.0 the reference was at /docs/v2 (bookmarks, the old status page).
|
||||
// Before 2.2.0 the reference was at /docs/v2 (bookmarks, the old status page).
|
||||
app.use('/docs/v2', (req, res) => res.redirect(301, `/api${req.originalUrl}`));
|
||||
app.get('/docs', (req, res) => res.redirect(301, '/api/docs/v2'));
|
||||
|
||||
@@ -192,7 +192,7 @@ warmCache().catch(() => {});
|
||||
// in the site's origin if opened directly, so pin the safe response headers
|
||||
// (no inline execution, no MIME-sniffing to HTML/script) on every asset here.
|
||||
// Stored paths stay "/uploads/…"; they're given out as /api/uploads/… (v2/schemas.ts absoluteUrl).
|
||||
// /uploads still answers for links made before 2.3.0.
|
||||
// /uploads still answers for links made before 2.2.0.
|
||||
const uploads = express.static('public/uploads', {
|
||||
setHeaders: (res) => {
|
||||
res.setHeader('Content-Security-Policy', "default-src 'none'; style-src 'unsafe-inline'; sandbox");
|
||||
@@ -276,7 +276,7 @@ app.get('/favicon.ico', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '..', 'src', 'favicon.ico'));
|
||||
});
|
||||
|
||||
// ── Status page, at /api (2.3.0); / sends you there ─────────────────────────
|
||||
// ── Status page, at /api (2.2.0); / sends you there ─────────────────────────
|
||||
app.get('/', (req, res) => res.redirect(302, '/api'));
|
||||
app.get('/api', async (req, res) => {
|
||||
const mem = process.memoryUsage();
|
||||
|
||||
@@ -46,7 +46,7 @@ function toAbsoluteUrl(req, url) {
|
||||
return raw; // keep as-is if already absolute and not localhost
|
||||
}
|
||||
// Relative path like /uploads/... => prefix with request origin; uploads are served under
|
||||
// /api/uploads (2.3.0) so they reach the backend when the site and API share one address
|
||||
// /api/uploads (2.2.0) so they reach the backend when the site and API share one address
|
||||
if (raw.startsWith('/')) {
|
||||
return `${req.protocol}://${req.get('host')}${raw.startsWith('/uploads/') ? `/api${raw}` : raw}`;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export function v2Router(): Router {
|
||||
}
|
||||
|
||||
/**
|
||||
* /api/docs/v2 (2.3.0; /docs/v2 before, which now redirects): Swagger UI (served from swagger-ui-dist, nothing from a CDN). The page itself is
|
||||
* /api/docs/v2 (2.2.0; /docs/v2 before, which now redirects): Swagger UI (served from swagger-ui-dist, nothing from a CDN). The page itself is
|
||||
* public; it asks for an admin token and uses it to load openapi.json and to try requests.
|
||||
*/
|
||||
export function v2DocsRouter(): Router {
|
||||
|
||||
@@ -15,7 +15,7 @@ export function iso(d: Date | string | null | undefined): string | null {
|
||||
}
|
||||
|
||||
/**
|
||||
* Where a stored upload path is served: "/uploads/…" (as stored) → "/api/uploads/…" (2.3.0), so it
|
||||
* Where a stored upload path is served: "/uploads/…" (as stored) → "/api/uploads/…" (2.2.0), so it
|
||||
* reaches the backend when the site and its API share one address. Anything else is unchanged.
|
||||
*/
|
||||
export function uploadPath(raw: string): string {
|
||||
|
||||
@@ -72,7 +72,7 @@ describe('status', () => {
|
||||
expect(await aiStatus()).toMatchObject({ enabled: true, available: false });
|
||||
});
|
||||
|
||||
test('the Hub\'s rand amounts never leave the site (2.3.0); a Hub before 2.0.1 sends no tokens', async () => {
|
||||
test('the Hub\'s rand amounts never leave the site (2.2.0); a Hub before 2.0.1 sends no tokens', async () => {
|
||||
mockPost.mockResolvedValueOnce(hubStatus());
|
||||
const s = await aiStatus() as unknown as Record<string, unknown>;
|
||||
expect(s).not.toHaveProperty('capCents');
|
||||
|
||||
@@ -558,7 +558,7 @@ describe('sections, costs, image uploads', () => {
|
||||
expect(res.body.data.url).toMatch(/^http:\/\/[^/]+\/api\/uploads\/events\/event-123\.jpg$/);
|
||||
});
|
||||
|
||||
test('stored uploads are given out under /api/uploads (2.3.0); other addresses are left alone', () => {
|
||||
test('stored uploads are given out under /api/uploads (2.2.0); other addresses are left alone', () => {
|
||||
expect(uploadPath('/uploads/branding/logo.png')).toBe('/api/uploads/branding/logo.png');
|
||||
expect(uploadPath('/api/uploads/x.png')).toBe('/api/uploads/x.png');
|
||||
expect(uploadPath('/images/x.png')).toBe('/images/x.png');
|
||||
|
||||
@@ -99,7 +99,7 @@ test.describe("API v2", () => {
|
||||
expect(ics.headers()["location"]).toBe(`/api/v2/events/${seed().events.conference}/calendar.ics`);
|
||||
const followed = await request.get(`${API}/api/events/${seed().events.conference}/ics`);
|
||||
expect(followed.headers()["content-type"]).toContain("text/calendar");
|
||||
// The old API reference addresses send people to the v2 one, under /api (2.3.0).
|
||||
// The old API reference addresses send people to the v2 one, under /api (2.2.0).
|
||||
const docs = await request.get(`${API}/docs`, { maxRedirects: 0 });
|
||||
expect(docs.headers()["location"]).toBe("/api/docs/v2");
|
||||
const oldDocs = await request.get(`${API}/docs/v2?x=1`, { maxRedirects: 0 });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/events-frontend",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { V2Result } from "@/lib/apiV2";
|
||||
|
||||
/**
|
||||
* AI helpers (2.0). The site calls AI through the Cross Events Hub, which keeps a monthly
|
||||
* allowance per licence, shown here as tokens and a percentage (2.3.0). One status per page load is shared by every AI button
|
||||
* allowance per licence, shown here as tokens and a percentage (2.2.0). One status per page load is shared by every AI button
|
||||
* (`useAiStatus`), and every helper call refreshes it — so the buttons disable straight after the
|
||||
* call that used up the allowance.
|
||||
*/
|
||||
|
||||
@@ -72,7 +72,7 @@ export function resolveToApiOrigin(urlOrPath: string | null | undefined): string
|
||||
} catch {
|
||||
// fall through to relative handling
|
||||
}
|
||||
// Stored uploads ("/uploads/…") are served under /api/uploads (2.3.0), so they reach the
|
||||
// Stored uploads ("/uploads/…") are served under /api/uploads (2.2.0), so they reach the
|
||||
// backend when the site and its API share one address.
|
||||
const path = raw.startsWith("/uploads/") ? `/api${raw}` : raw;
|
||||
return API_BASE ? `${API_BASE}${path}` : path;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/events",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev:backend": "cd backend && npm run dev",
|
||||
|
||||
Reference in New Issue
Block a user