@connextar/house 0.21.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -1
- package/dist/editor/suggestions.d.ts +14 -0
- package/dist/editor/suggestions.d.ts.map +1 -1
- package/dist/editor/suggestions.js +49 -1
- package/dist/editor/suggestions.js.map +1 -1
- package/dist/maintenance/core.d.ts +102 -0
- package/dist/maintenance/core.d.ts.map +1 -0
- package/dist/maintenance/core.js +164 -0
- package/dist/maintenance/core.js.map +1 -0
- package/dist/maintenance/gate.d.ts +48 -0
- package/dist/maintenance/gate.d.ts.map +1 -0
- package/dist/maintenance/gate.js +114 -0
- package/dist/maintenance/gate.js.map +1 -0
- package/dist/maintenance/index.d.ts +7 -0
- package/dist/maintenance/index.d.ts.map +1 -0
- package/dist/maintenance/index.js +7 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/maintenance/page.d.ts +21 -0
- package/dist/maintenance/page.d.ts.map +1 -0
- package/dist/maintenance/page.js +53 -0
- package/dist/maintenance/page.js.map +1 -0
- package/dist/maintenance/proxy.d.ts +41 -0
- package/dist/maintenance/proxy.d.ts.map +1 -0
- package/dist/maintenance/proxy.js +33 -0
- package/dist/maintenance/proxy.js.map +1 -0
- package/dist/maintenance/react-index.d.ts +2 -0
- package/dist/maintenance/react-index.d.ts.map +1 -0
- package/dist/maintenance/react-index.js +2 -0
- package/dist/maintenance/react-index.js.map +1 -0
- package/dist/maintenance/react.d.ts +36 -0
- package/dist/maintenance/react.d.ts.map +1 -0
- package/dist/maintenance/react.js +141 -0
- package/dist/maintenance/react.js.map +1 -0
- package/dist/maintenance/route.d.ts +37 -0
- package/dist/maintenance/route.d.ts.map +1 -0
- package/dist/maintenance/route.js +41 -0
- package/dist/maintenance/route.js.map +1 -0
- package/dist/maintenance/unavailable.d.ts +11 -0
- package/dist/maintenance/unavailable.d.ts.map +1 -0
- package/dist/maintenance/unavailable.js +63 -0
- package/dist/maintenance/unavailable.js.map +1 -0
- package/docs/Maintenance.md +121 -0
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -1591,6 +1591,97 @@ export async function GET() {
|
|
|
1591
1591
|
}
|
|
1592
1592
|
```
|
|
1593
1593
|
|
|
1594
|
+
### `@connextar/house/maintenance`, `/maintenance/react`
|
|
1595
|
+
|
|
1596
|
+
Planned maintenance on the database server an app depends on, shown to people
|
|
1597
|
+
instead of database errors: a dismissible **planned maintenance** notice while a
|
|
1598
|
+
window is coming, a **maintenance page** while it's under way, and everything back
|
|
1599
|
+
by itself — usually within 15 seconds of the server saying it's done, long before
|
|
1600
|
+
the window's end. The design, the feed's contract and the order of work are in
|
|
1601
|
+
[docs/Maintenance.md](docs/Maintenance.md).
|
|
1602
|
+
|
|
1603
|
+
Each server publishes `GET /maintenance.json` (CX_PGSQL_Node_1:
|
|
1604
|
+
`https://pgsql-node-1.connextar.com/maintenance.json`); the app reads it. The
|
|
1605
|
+
server's reboots announce themselves; anything else is booked with
|
|
1606
|
+
`cx-pgsql maintenance plan|start|extend|end|cancel`.
|
|
1607
|
+
|
|
1608
|
+
**Server half** (`@connextar/house/maintenance`, no package imported — it runs in
|
|
1609
|
+
`proxy.ts` before every request):
|
|
1610
|
+
|
|
1611
|
+
- `maintenanceGateFromEnv(env?, options?)` → a gate, from `HOUSE_MAINTENANCE_FEEDS`
|
|
1612
|
+
(feed URLs, commas or spaces) and `HOUSE_MAINTENANCE` (`on` forces the page,
|
|
1613
|
+
`off` never shows it, `auto` or unset follows the feeds). `createMaintenanceGate({
|
|
1614
|
+
feeds, override, timing, timeoutMs, … })` is the same with everything said.
|
|
1615
|
+
Keep one per process (module scope). It re-reads a feed when its copy is a minute
|
|
1616
|
+
old — 15 seconds near or during a window — with a one-second timeout, and **keeps
|
|
1617
|
+
its copy when the server doesn't answer**: during a reboot nothing does, and the
|
|
1618
|
+
copy is what turns the page on at the start. It never throws; `onError(feed,
|
|
1619
|
+
error)` hears about failures.
|
|
1620
|
+
- `maintenanceResponse(request, gate, { page: { appName }, keepUp?, statePath?,
|
|
1621
|
+
cronPrefix?, apiPrefix? })` → the response to send during a window, or
|
|
1622
|
+
`undefined` to carry on. Pages get the maintenance page itself
|
|
1623
|
+
(`maintenancePageHtml`: a whole document, no script, no stylesheet, no app
|
|
1624
|
+
layout, so it renders with the database down; it reloads itself every 30
|
|
1625
|
+
seconds) with `503` and `Retry-After`; `/api/` gets `503` JSON; `/api/cron/` gets
|
|
1626
|
+
`200 { skipped: "maintenance" }`; the state route, `/_next/`, static files and
|
|
1627
|
+
`keepUp` prefixes pass. The gate starts a minute before the window
|
|
1628
|
+
(`timing.leadSeconds`), so requests in flight finish before Postgres cuts them off.
|
|
1629
|
+
- `createMaintenanceRoute(gate, { probe })` → `{ GET }` for
|
|
1630
|
+
`app/api/house/maintenance/route.ts`: the state as JSON for the browser. With
|
|
1631
|
+
`?probe=1` it also runs the app's probe (a `SELECT 1`; 1.5 s timeout, one probe
|
|
1632
|
+
per 5 s whoever asks) and says `service: "up" | "down"`.
|
|
1633
|
+
- `isUnavailableError(error)` — a connection refused, a pool timeout, Postgres
|
|
1634
|
+
shutting down (Prisma P1001/P1002/P1017/P2024, SQLSTATE 57P0x/08xxx/53300,
|
|
1635
|
+
socket errnos), followed through `cause`, Prisma's `meta.driverAdapterError` and
|
|
1636
|
+
`AggregateError`. For an API route's catch: a 503, not a 500.
|
|
1637
|
+
- `maintenanceState(windows, now, timing)`, `parseMaintenanceFeed(json)`,
|
|
1638
|
+
`describeWindow(window, { timeZone })` ("Wed 4 Nov, 23:00–23:15 GMT") — the pure
|
|
1639
|
+
rules underneath.
|
|
1640
|
+
|
|
1641
|
+
**Browser half** (`@connextar/house/maintenance/react`, client components):
|
|
1642
|
+
|
|
1643
|
+
- `<MaintenanceBanner appName="AltEd" />` — at the top of the root layout. Drawn
|
|
1644
|
+
after load from the state route, so a page built ahead of time shows it without
|
|
1645
|
+
a rebuild. Dismissal is remembered per window (a moved window shows again);
|
|
1646
|
+
under way it says until when and can't be dismissed. Tailwind token classes, as
|
|
1647
|
+
every house component.
|
|
1648
|
+
- `useServiceCheck()` → `"checking" | "up" | "down" | "maintenance" | "unknown"`,
|
|
1649
|
+
for `error.tsx`. In production an error page gets a digest, never the message,
|
|
1650
|
+
so it asks the state route to probe instead: `maintenance` and `down` deserve
|
|
1651
|
+
"temporarily unavailable, try again shortly".
|
|
1652
|
+
|
|
1653
|
+
Adoption, per app:
|
|
1654
|
+
|
|
1655
|
+
```ts
|
|
1656
|
+
// lib/maintenance.ts
|
|
1657
|
+
import { maintenanceGateFromEnv } from "@connextar/house/maintenance";
|
|
1658
|
+
export const maintenanceGate = maintenanceGateFromEnv(process.env, {
|
|
1659
|
+
onError: (feed, error) => console.warn("maintenance feed", feed, error),
|
|
1660
|
+
});
|
|
1661
|
+
|
|
1662
|
+
// proxy.ts (Next 16)
|
|
1663
|
+
import type { NextRequest } from "next/server";
|
|
1664
|
+
import { maintenanceResponse } from "@connextar/house/maintenance";
|
|
1665
|
+
import { maintenanceGate } from "./lib/maintenance";
|
|
1666
|
+
export async function proxy(request: NextRequest) {
|
|
1667
|
+
return maintenanceResponse(request, maintenanceGate, { page: { appName: "AltEd" }, keepUp: ["/blog"] });
|
|
1668
|
+
}
|
|
1669
|
+
export const config = { matcher: ["/((?!_next/static|_next/image|favicon.ico|healthz).*)"] };
|
|
1670
|
+
|
|
1671
|
+
// app/api/house/maintenance/route.ts
|
|
1672
|
+
import { createMaintenanceRoute } from "@connextar/house/maintenance";
|
|
1673
|
+
import { maintenanceGate } from "@/lib/maintenance";
|
|
1674
|
+
import { prisma } from "@/lib/db/prisma";
|
|
1675
|
+
export const { GET } = createMaintenanceRoute(maintenanceGate, { probe: () => prisma.$queryRaw`select 1` });
|
|
1676
|
+
```
|
|
1677
|
+
|
|
1678
|
+
Then `HOUSE_MAINTENANCE_FEEDS=https://pgsql-node-1.connextar.com/maintenance.json`
|
|
1679
|
+
in the deployment's environment, the banner in the root layout, `useServiceCheck`
|
|
1680
|
+
in `error.tsx`, and a connect timeout on the database pool (pg waits for ever by
|
|
1681
|
+
default: `connectionTimeoutMillis: 5000`). An offline-capable app's service worker
|
|
1682
|
+
must show a `503` page as it is — never cache it, never swap it for the offline
|
|
1683
|
+
page.
|
|
1684
|
+
|
|
1594
1685
|
### `@connextar/house/trail`
|
|
1595
1686
|
|
|
1596
1687
|
Where you came from, rather than where the URL says you are. A breadcrumb built
|
|
@@ -1644,7 +1735,11 @@ into, duplicate, move up, move down, delete); `:` completes an emoji shortcode.
|
|
|
1644
1735
|
`@` references and `#` tags work when the app passes `sources`, because only the
|
|
1645
1736
|
app knows what its people, records and tags are. **Storage is plain Markdown with
|
|
1646
1737
|
no new node types** — a reference is `[@Ann Lee](/people/1)` — so every existing
|
|
1647
|
-
text column keeps working and a server can read mentions with a regex.
|
|
1738
|
+
text column keeps working and a server can read mentions with a regex. An `@` lookup runs on past spaces while it
|
|
1739
|
+
still finds something, so a name of several words ("Ben Okafor", "Commitments & obligation") can be typed out; at the
|
|
1740
|
+
first query with a space that finds nothing it lets go, and the rest is ordinary writing (0.21.2). The query is
|
|
1741
|
+
passed as typed, every character in it; the name is written into the link escaped as Markdown (`\[`, `\*`), so a
|
|
1742
|
+
server that reads the label should allow backslash escapes in it.
|
|
1648
1743
|
|
|
1649
1744
|
**Sections** (0.21.0). A heading carries everything under it — up to the next heading of its level or higher, a
|
|
1650
1745
|
divider or an empty block (`sections.ts`). Dragging a heading by its grip, or **Move section up / down**, moves the
|
|
@@ -78,6 +78,20 @@ export declare function emojiItems(query: string): SuggestionItem[];
|
|
|
78
78
|
export declare function slashItems(query: string, sources: SuggestionSources, options: SuggestionOptions): SuggestionItem[];
|
|
79
79
|
/** Apply an accepted row to the document, replacing the trigger text. */
|
|
80
80
|
export declare function applySuggestion(editor: Editor, range: Range, item: SuggestionItem): void;
|
|
81
|
+
/**
|
|
82
|
+
* How far an `@` lookup reaches. Names have spaces in them ("Ben Okafor",
|
|
83
|
+
* "Commitments & obligation"), so the query runs on past a space — but only
|
|
84
|
+
* while it is still finding something. Once a query with a space in it comes
|
|
85
|
+
* back empty, anything typed after it is ordinary writing, and the lookup lets
|
|
86
|
+
* go instead of following the rest of the sentence. Any character may appear in
|
|
87
|
+
* the query; the source decides what matches.
|
|
88
|
+
*/
|
|
89
|
+
export declare function referenceReach(): {
|
|
90
|
+
/** Whether the lookup should stay open for this query. */
|
|
91
|
+
reaches(query: string): boolean;
|
|
92
|
+
/** Note what a query found, once its items arrive. True when it has just reached a dead end. */
|
|
93
|
+
found(query: string, count: number): boolean;
|
|
94
|
+
};
|
|
81
95
|
/**
|
|
82
96
|
* Every lookup as one extension. `ui` and `sources` are ref-like holders read
|
|
83
97
|
* lazily on every callback, so the extension (created once per editor) always
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestions.d.ts","sourceRoot":"","sources":["../../src/editor/suggestions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAGlE,OAAO,EAA0C,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAKvF;;;;;;;;;;;;;;;;GAgBG;AAEH,+DAA+D;AAC/D,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,MAAM,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IACpD,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,MAAM,EACF;QAAE,IAAI,EAAE,WAAW,CAAC;QAA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E;AACzE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI,CA0BxF;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc;IAK1B,0DAA0D;mBAC3C,MAAM,GAAG,OAAO;IAQ/B,gGAAgG;iBACnF,MAAM,SAAS,MAAM,GAAG,OAAO;EAQ/C;AAeD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,EACnC,OAAO,EAAE;IAAE,OAAO,EAAE,iBAAiB,CAAA;CAAE,EACvC,OAAO,EAAE;IAAE,OAAO,EAAE,iBAAiB,CAAA;CAAE,uBAuExC"}
|
|
@@ -104,6 +104,40 @@ export function applySuggestion(editor, range, item) {
|
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* How far an `@` lookup reaches. Names have spaces in them ("Ben Okafor",
|
|
109
|
+
* "Commitments & obligation"), so the query runs on past a space — but only
|
|
110
|
+
* while it is still finding something. Once a query with a space in it comes
|
|
111
|
+
* back empty, anything typed after it is ordinary writing, and the lookup lets
|
|
112
|
+
* go instead of following the rest of the sentence. Any character may appear in
|
|
113
|
+
* the query; the source decides what matches.
|
|
114
|
+
*/
|
|
115
|
+
export function referenceReach() {
|
|
116
|
+
// The shortest query with a space in it that found nothing, normalised.
|
|
117
|
+
let deadEnd = null;
|
|
118
|
+
const normalise = (query) => query.replace(/\s+/g, " ").trimStart().toLowerCase();
|
|
119
|
+
return {
|
|
120
|
+
/** Whether the lookup should stay open for this query. */
|
|
121
|
+
reaches(query) {
|
|
122
|
+
if (!/\s/.test(query)) {
|
|
123
|
+
// A new word-only query starts afresh.
|
|
124
|
+
deadEnd = null;
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
return deadEnd === null || !normalise(query).startsWith(deadEnd);
|
|
128
|
+
},
|
|
129
|
+
/** Note what a query found, once its items arrive. True when it has just reached a dead end. */
|
|
130
|
+
found(query, count) {
|
|
131
|
+
if (count > 0 || !/\s/.test(query))
|
|
132
|
+
return false;
|
|
133
|
+
const at = normalise(query);
|
|
134
|
+
if (deadEnd !== null && at.startsWith(deadEnd))
|
|
135
|
+
return false;
|
|
136
|
+
deadEnd = at;
|
|
137
|
+
return true;
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
107
141
|
function renderInto(ui) {
|
|
108
142
|
return () => ({
|
|
109
143
|
onStart: (props) => {
|
|
@@ -127,6 +161,7 @@ export function createSuggestions(ui, sources, options) {
|
|
|
127
161
|
command: ({ editor, range, props }) => applySuggestion(editor, range, props),
|
|
128
162
|
render: renderInto(ui),
|
|
129
163
|
};
|
|
164
|
+
const reach = referenceReach();
|
|
130
165
|
return Extension.create({
|
|
131
166
|
name: "houseSuggestions",
|
|
132
167
|
addProseMirrorPlugins() {
|
|
@@ -140,8 +175,21 @@ export function createSuggestions(ui, sources, options) {
|
|
|
140
175
|
// work with before anything is typed.
|
|
141
176
|
minQueryLength: 0,
|
|
142
177
|
debounce: 150,
|
|
178
|
+
// Past spaces too, for names with more than one word — see `referenceReach`.
|
|
179
|
+
allowSpaces: true,
|
|
143
180
|
allow: () => Boolean(sources.current.references),
|
|
144
|
-
|
|
181
|
+
shouldShow: ({ query }) => reach.reaches(query),
|
|
182
|
+
items: async ({ editor, query }) => {
|
|
183
|
+
const items = (await sources.current.references?.(query)) ?? [];
|
|
184
|
+
// At a dead end, let go now rather than at the next keystroke, so the
|
|
185
|
+
// lookup's highlight doesn't sit over the sentence in the meantime.
|
|
186
|
+
if (reach.found(query, items.length))
|
|
187
|
+
setTimeout(() => {
|
|
188
|
+
if (!editor.isDestroyed)
|
|
189
|
+
editor.view.dispatch(editor.state.tr.setMeta("houseReferenceReach", true));
|
|
190
|
+
});
|
|
191
|
+
return items;
|
|
192
|
+
},
|
|
145
193
|
}),
|
|
146
194
|
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AC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;oBAC1C,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE;iBAC1D,CAAC;gBACF,UAAU,CAAiC;oBACzC,GAAG,MAAM;oBACT,SAAS,EAAE,IAAI,SAAS,CAAC,sBAAsB,CAAC;oBAChD,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,IAAI,EAAE,GAAG;oBACT,qEAAqE;oBACrE,wCAAwC;oBACxC,eAAe,EAAE,CAAC,GAAG,CAAC;oBACtB,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;iBAC1E,CAAC;gBACF,UAAU,CAAiC;oBACzC,GAAG,MAAM;oBACT,SAAS,EAAE,IAAI,SAAS,CAAC,sBAAsB,CAAC;oBAChD,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,IAAI,EAAE,GAAG;oBACT,cAAc,EAAE,CAAC;oBACjB,eAAe,EAAE,CAAC,GAAG,CAAC;oBACtB,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;iBACxC,CAAC;aACH,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planned maintenance: what a database server says about its downtime, and what
|
|
3
|
+
* an app should do about it now.
|
|
4
|
+
*
|
|
5
|
+
* Each server publishes `GET /maintenance.json` (the contract is in
|
|
6
|
+
* docs/Maintenance.md §2). This module reads that document and decides, from
|
|
7
|
+
* the window times alone, whether the app is in a window, has one coming, or
|
|
8
|
+
* neither. It decides from the times — not from the `state` the server worked
|
|
9
|
+
* out when it served the document — because an app keeps its last copy and must
|
|
10
|
+
* reach the right answer at 23:00 when the server it would ask is the thing
|
|
11
|
+
* that's down.
|
|
12
|
+
*
|
|
13
|
+
* Pure: no I/O, no clock of its own, no framework.
|
|
14
|
+
*/
|
|
15
|
+
/** The feed version this module understands. A different one is ignored, never guessed at. */
|
|
16
|
+
export declare const MAINTENANCE_FEED_VERSION = 1;
|
|
17
|
+
export type MaintenanceWindowKind = "reboot" | "maintenance";
|
|
18
|
+
/** One window, as an app holds it. Times are ISO strings in UTC. */
|
|
19
|
+
export interface MaintenanceWindow {
|
|
20
|
+
id: string;
|
|
21
|
+
/** `reboot`: booked by the server itself (an update). `maintenance`: booked by hand. */
|
|
22
|
+
kind: MaintenanceWindowKind;
|
|
23
|
+
startsAt: string;
|
|
24
|
+
/** The latest it should be over. After it, the app serves again whatever the server says. */
|
|
25
|
+
endsBy: string;
|
|
26
|
+
/** The honest estimate of the downtime, which is what people are told. */
|
|
27
|
+
expectedMinutes: number;
|
|
28
|
+
/** Set when the work finished — usually well before `endsBy`. */
|
|
29
|
+
endedAt: string | null;
|
|
30
|
+
cancelled: boolean;
|
|
31
|
+
/** What is unavailable meanwhile: `postgres`, `objects`. */
|
|
32
|
+
affects: string[];
|
|
33
|
+
/** Public text from whoever booked it. */
|
|
34
|
+
message: string | null;
|
|
35
|
+
/** The server that published it. */
|
|
36
|
+
server: string;
|
|
37
|
+
}
|
|
38
|
+
export interface MaintenanceFeed {
|
|
39
|
+
server: string;
|
|
40
|
+
generatedAt: string | null;
|
|
41
|
+
windows: MaintenanceWindow[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The feed, or null when it isn't one this module understands. Malformed
|
|
45
|
+
* windows are dropped one by one rather than failing the whole document, and
|
|
46
|
+
* nothing beyond the contract's fields is kept.
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseMaintenanceFeed(input: unknown): MaintenanceFeed | null;
|
|
49
|
+
export type MaintenancePhase = "none" | "upcoming" | "active";
|
|
50
|
+
export interface MaintenanceState {
|
|
51
|
+
phase: MaintenancePhase;
|
|
52
|
+
/** The window the phase is about: the active one, or the next one coming. */
|
|
53
|
+
window: MaintenanceWindow | null;
|
|
54
|
+
/** While active: seconds until the window's `endsBy`, for a `Retry-After` header. */
|
|
55
|
+
retryAfterSeconds: number | null;
|
|
56
|
+
}
|
|
57
|
+
export interface MaintenanceTiming {
|
|
58
|
+
/**
|
|
59
|
+
* How long before the start an app stops serving: requests in flight finish
|
|
60
|
+
* before Postgres terminates their connections. Default 60 seconds.
|
|
61
|
+
*/
|
|
62
|
+
leadSeconds?: number;
|
|
63
|
+
/** How far ahead a window is announced. Default 7 days. */
|
|
64
|
+
announceHours?: number;
|
|
65
|
+
}
|
|
66
|
+
export declare const NO_MAINTENANCE: MaintenanceState;
|
|
67
|
+
/**
|
|
68
|
+
* The phase now, from the windows' times:
|
|
69
|
+
*
|
|
70
|
+
* - **active** from `leadSeconds` before a window starts until it ended
|
|
71
|
+
* (`endedAt`) or ran out (`endsBy`), unless it was cancelled;
|
|
72
|
+
* - **upcoming** when a window starts within `announceHours`;
|
|
73
|
+
* - **none** otherwise.
|
|
74
|
+
*
|
|
75
|
+
* Of several active windows the one ending last wins; of several coming, the
|
|
76
|
+
* soonest.
|
|
77
|
+
*/
|
|
78
|
+
export declare function maintenanceState(windows: readonly MaintenanceWindow[], now: Date, timing?: MaintenanceTiming): MaintenanceState;
|
|
79
|
+
/** A window standing in for `HOUSE_MAINTENANCE=on`: from now, for an hour, renewed on every read. */
|
|
80
|
+
export declare function overrideWindow(now: Date): MaintenanceWindow;
|
|
81
|
+
export interface WindowWording {
|
|
82
|
+
timeZone?: string;
|
|
83
|
+
locale?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface DescribedWindow {
|
|
86
|
+
/** "Wed 4 Nov" */
|
|
87
|
+
day: string;
|
|
88
|
+
/** "23:00" */
|
|
89
|
+
start: string;
|
|
90
|
+
/** "23:15" */
|
|
91
|
+
end: string;
|
|
92
|
+
/** "GMT" or "BST" */
|
|
93
|
+
zone: string;
|
|
94
|
+
/** "Wed 4 Nov, 23:00–23:15 GMT", or both days when it crosses midnight. */
|
|
95
|
+
text: string;
|
|
96
|
+
/** "a few minutes", "about 30 minutes", "about 2 hours" */
|
|
97
|
+
expected: string;
|
|
98
|
+
}
|
|
99
|
+
/** A window in words, in the app's time zone (Europe/London unless said otherwise). */
|
|
100
|
+
export declare function describeWindow(window: MaintenanceWindow, { timeZone, locale }?: WindowWording): DescribedWindow;
|
|
101
|
+
export declare function expectedText(minutes: number): string;
|
|
102
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/maintenance/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,8FAA8F;AAC9F,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,aAAa,CAAC;AAE7D,oEAAoE;AACpE,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,wFAAwF;IACxF,IAAI,EAAE,qBAAqB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,6FAA6F;IAC7F,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,eAAe,EAAE,MAAM,CAAC;IACxB,iEAAiE;IACjE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,iBAAiB,EAAE,CAAC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B,EAAE,QAA0B,EAAE,MAAgB,EAAE,GAAE,aAAkB,GACnE,eAAe,CAUjB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMpD"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planned maintenance: what a database server says about its downtime, and what
|
|
3
|
+
* an app should do about it now.
|
|
4
|
+
*
|
|
5
|
+
* Each server publishes `GET /maintenance.json` (the contract is in
|
|
6
|
+
* docs/Maintenance.md §2). This module reads that document and decides, from
|
|
7
|
+
* the window times alone, whether the app is in a window, has one coming, or
|
|
8
|
+
* neither. It decides from the times — not from the `state` the server worked
|
|
9
|
+
* out when it served the document — because an app keeps its last copy and must
|
|
10
|
+
* reach the right answer at 23:00 when the server it would ask is the thing
|
|
11
|
+
* that's down.
|
|
12
|
+
*
|
|
13
|
+
* Pure: no I/O, no clock of its own, no framework.
|
|
14
|
+
*/
|
|
15
|
+
/** The feed version this module understands. A different one is ignored, never guessed at. */
|
|
16
|
+
export const MAINTENANCE_FEED_VERSION = 1;
|
|
17
|
+
const KINDS = new Set(["reboot", "maintenance"]);
|
|
18
|
+
const MESSAGE_MAX = 280;
|
|
19
|
+
function isRecord(value) {
|
|
20
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
function time(value) {
|
|
23
|
+
if (typeof value !== "string" || value === "")
|
|
24
|
+
return null;
|
|
25
|
+
const ms = Date.parse(value);
|
|
26
|
+
return Number.isNaN(ms) ? null : ms;
|
|
27
|
+
}
|
|
28
|
+
function iso(ms) {
|
|
29
|
+
return new Date(ms).toISOString();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The feed, or null when it isn't one this module understands. Malformed
|
|
33
|
+
* windows are dropped one by one rather than failing the whole document, and
|
|
34
|
+
* nothing beyond the contract's fields is kept.
|
|
35
|
+
*/
|
|
36
|
+
export function parseMaintenanceFeed(input) {
|
|
37
|
+
if (!isRecord(input) || input.version !== MAINTENANCE_FEED_VERSION || !Array.isArray(input.windows))
|
|
38
|
+
return null;
|
|
39
|
+
const server = typeof input.server === "string" && input.server ? input.server.slice(0, 100) : "server";
|
|
40
|
+
const windows = [];
|
|
41
|
+
for (const raw of input.windows) {
|
|
42
|
+
if (!isRecord(raw) || typeof raw.id !== "string" || !raw.id)
|
|
43
|
+
continue;
|
|
44
|
+
const startsAt = time(raw.starts_at);
|
|
45
|
+
const endsBy = time(raw.ends_by);
|
|
46
|
+
if (startsAt === null || endsBy === null || endsBy <= startsAt)
|
|
47
|
+
continue;
|
|
48
|
+
const endedAt = time(raw.ended_at);
|
|
49
|
+
const expected = typeof raw.expected_minutes === "number" && raw.expected_minutes > 0 ? raw.expected_minutes : null;
|
|
50
|
+
windows.push({
|
|
51
|
+
id: raw.id.slice(0, 100),
|
|
52
|
+
kind: KINDS.has(raw.kind) ? raw.kind : "maintenance",
|
|
53
|
+
startsAt: iso(startsAt),
|
|
54
|
+
endsBy: iso(endsBy),
|
|
55
|
+
expectedMinutes: Math.ceil(expected ?? (endsBy - startsAt) / 60_000),
|
|
56
|
+
endedAt: endedAt === null ? null : iso(endedAt),
|
|
57
|
+
cancelled: raw.state === "cancelled",
|
|
58
|
+
affects: Array.isArray(raw.affects)
|
|
59
|
+
? raw.affects.filter((a) => typeof a === "string").slice(0, 10)
|
|
60
|
+
: [],
|
|
61
|
+
message: typeof raw.message === "string" && raw.message.trim() ? raw.message.trim().slice(0, MESSAGE_MAX) : null,
|
|
62
|
+
server,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return { server, generatedAt: typeof input.generated_at === "string" ? input.generated_at : null, windows };
|
|
66
|
+
}
|
|
67
|
+
export const NO_MAINTENANCE = Object.freeze({ phase: "none", window: null, retryAfterSeconds: null });
|
|
68
|
+
/**
|
|
69
|
+
* The phase now, from the windows' times:
|
|
70
|
+
*
|
|
71
|
+
* - **active** from `leadSeconds` before a window starts until it ended
|
|
72
|
+
* (`endedAt`) or ran out (`endsBy`), unless it was cancelled;
|
|
73
|
+
* - **upcoming** when a window starts within `announceHours`;
|
|
74
|
+
* - **none** otherwise.
|
|
75
|
+
*
|
|
76
|
+
* Of several active windows the one ending last wins; of several coming, the
|
|
77
|
+
* soonest.
|
|
78
|
+
*/
|
|
79
|
+
export function maintenanceState(windows, now, timing = {}) {
|
|
80
|
+
const t = now.getTime();
|
|
81
|
+
const lead = (timing.leadSeconds ?? 60) * 1000;
|
|
82
|
+
const announce = (timing.announceHours ?? 168) * 3_600_000;
|
|
83
|
+
let active = null;
|
|
84
|
+
let upcoming = null;
|
|
85
|
+
for (const w of windows) {
|
|
86
|
+
if (w.cancelled)
|
|
87
|
+
continue;
|
|
88
|
+
const ended = time(w.endedAt);
|
|
89
|
+
if (ended !== null && ended <= t)
|
|
90
|
+
continue;
|
|
91
|
+
const start = Date.parse(w.startsAt);
|
|
92
|
+
const end = Date.parse(w.endsBy);
|
|
93
|
+
if (t >= end)
|
|
94
|
+
continue;
|
|
95
|
+
if (t >= start - lead) {
|
|
96
|
+
if (!active || end > Date.parse(active.endsBy))
|
|
97
|
+
active = w;
|
|
98
|
+
}
|
|
99
|
+
else if (start - t <= announce) {
|
|
100
|
+
if (!upcoming || start < Date.parse(upcoming.startsAt))
|
|
101
|
+
upcoming = w;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (active)
|
|
105
|
+
return {
|
|
106
|
+
phase: "active",
|
|
107
|
+
window: active,
|
|
108
|
+
retryAfterSeconds: Math.max(1, Math.ceil((Date.parse(active.endsBy) - t) / 1000)),
|
|
109
|
+
};
|
|
110
|
+
if (upcoming)
|
|
111
|
+
return { phase: "upcoming", window: upcoming, retryAfterSeconds: null };
|
|
112
|
+
return NO_MAINTENANCE;
|
|
113
|
+
}
|
|
114
|
+
/** A window standing in for `HOUSE_MAINTENANCE=on`: from now, for an hour, renewed on every read. */
|
|
115
|
+
export function overrideWindow(now) {
|
|
116
|
+
return {
|
|
117
|
+
id: "override",
|
|
118
|
+
kind: "maintenance",
|
|
119
|
+
startsAt: iso(now.getTime()),
|
|
120
|
+
endsBy: iso(now.getTime() + 3_600_000),
|
|
121
|
+
expectedMinutes: 60,
|
|
122
|
+
endedAt: null,
|
|
123
|
+
cancelled: false,
|
|
124
|
+
affects: ["postgres"],
|
|
125
|
+
message: null,
|
|
126
|
+
server: "app",
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function parts(ms, timeZone, locale) {
|
|
130
|
+
return Object.fromEntries(new Intl.DateTimeFormat(locale, {
|
|
131
|
+
timeZone,
|
|
132
|
+
weekday: "short",
|
|
133
|
+
day: "numeric",
|
|
134
|
+
month: "short",
|
|
135
|
+
hour: "2-digit",
|
|
136
|
+
minute: "2-digit",
|
|
137
|
+
hourCycle: "h23",
|
|
138
|
+
timeZoneName: "short",
|
|
139
|
+
})
|
|
140
|
+
.formatToParts(new Date(ms))
|
|
141
|
+
.map((p) => [p.type, p.value]));
|
|
142
|
+
}
|
|
143
|
+
/** A window in words, in the app's time zone (Europe/London unless said otherwise). */
|
|
144
|
+
export function describeWindow(window, { timeZone = "Europe/London", locale = "en-GB" } = {}) {
|
|
145
|
+
const s = parts(Date.parse(window.startsAt), timeZone, locale);
|
|
146
|
+
const e = parts(Date.parse(window.endsBy), timeZone, locale);
|
|
147
|
+
const day = `${s.weekday} ${s.day} ${s.month}`;
|
|
148
|
+
const endDay = `${e.weekday} ${e.day} ${e.month}`;
|
|
149
|
+
const start = `${s.hour}:${s.minute}`;
|
|
150
|
+
const end = `${e.hour}:${e.minute}`;
|
|
151
|
+
const zone = e.timeZoneName ?? "";
|
|
152
|
+
const text = day === endDay ? `${day}, ${start}–${end} ${zone}` : `${day} ${start} – ${endDay} ${end} ${zone}`;
|
|
153
|
+
return { day, start, end, zone, text, expected: expectedText(window.expectedMinutes) };
|
|
154
|
+
}
|
|
155
|
+
export function expectedText(minutes) {
|
|
156
|
+
const m = Math.max(1, Math.ceil(minutes));
|
|
157
|
+
if (m <= 5)
|
|
158
|
+
return "a few minutes";
|
|
159
|
+
if (m < 90)
|
|
160
|
+
return `about ${m} minutes`;
|
|
161
|
+
const hours = Math.round(m / 30) / 2;
|
|
162
|
+
return `about ${hours} hour${hours === 1 ? "" : "s"}`;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/maintenance/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,8FAA8F;AAC9F,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AA+B1C,MAAM,KAAK,GAAG,IAAI,GAAG,CAAwB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;AACxE,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,IAAI,CAAC,KAAc;IAC1B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC;AAED,SAAS,GAAG,CAAC,EAAU;IACrB,OAAO,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,KAAK,wBAAwB,IAAI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C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1C,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,eAAe,CAAC;IACnC,IAAI,CAAC,GAAG,EAAE;QAAE,OAAO,SAAS,CAAC,UAAU,CAAC;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,SAAS,KAAK,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type MaintenanceState, type MaintenanceTiming } from "./core.js";
|
|
2
|
+
/**
|
|
3
|
+
* The app's view of every server it depends on, kept in memory.
|
|
4
|
+
*
|
|
5
|
+
* One gate per process (module scope), read on every request by the proxy. It
|
|
6
|
+
* fetches a feed only when its copy is older than a minute — every 15 seconds
|
|
7
|
+
* near or during a window — with a short timeout, so a request never waits on a
|
|
8
|
+
* slow server for long. A failed fetch keeps the copy it has: during a reboot
|
|
9
|
+
* nothing answers, and the copy is what turns the maintenance page on at 23:00.
|
|
10
|
+
* A gate never throws.
|
|
11
|
+
*/
|
|
12
|
+
export interface MaintenanceGateOptions {
|
|
13
|
+
/** Each server's feed, e.g. `https://pgsql-node-1.connextar.com/maintenance.json`. */
|
|
14
|
+
feeds: readonly string[];
|
|
15
|
+
/** `on` forces the maintenance page, `off` never shows it, `auto` (or unset) follows the feeds. */
|
|
16
|
+
override?: string | undefined;
|
|
17
|
+
timing?: MaintenanceTiming;
|
|
18
|
+
/** Per fetch. Default 1000 ms. */
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
/** How old a copy may get with nothing near. Default 60 s. */
|
|
21
|
+
idleRefreshSeconds?: number;
|
|
22
|
+
/** How old a copy may get within ten minutes of a window, or during one. Default 15 s. */
|
|
23
|
+
nearRefreshSeconds?: number;
|
|
24
|
+
fetch?: typeof fetch;
|
|
25
|
+
now?: () => Date;
|
|
26
|
+
/** A feed that failed (network, status, shape). Called on each failure; the app decides what to log. */
|
|
27
|
+
onError?: (feed: string, error: unknown) => void;
|
|
28
|
+
}
|
|
29
|
+
export interface MaintenanceGate {
|
|
30
|
+
/** The state now, refreshing a feed first when its copy is stale. */
|
|
31
|
+
state(): Promise<MaintenanceState>;
|
|
32
|
+
/** The state from the copies held, without fetching. */
|
|
33
|
+
peek(): MaintenanceState;
|
|
34
|
+
/** Fetch every feed now. */
|
|
35
|
+
refresh(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
type Override = "on" | "off" | "auto";
|
|
38
|
+
export declare function parseOverride(value: string | undefined): Override;
|
|
39
|
+
export declare function createMaintenanceGate(options: MaintenanceGateOptions): MaintenanceGate;
|
|
40
|
+
/**
|
|
41
|
+
* A gate from the environment: `HOUSE_MAINTENANCE_FEEDS` (feed URLs, separated
|
|
42
|
+
* by commas or spaces) and `HOUSE_MAINTENANCE` (`on` / `off` / `auto`). Anything
|
|
43
|
+
* in a feed list that isn't an https URL (http on localhost) is left out.
|
|
44
|
+
*/
|
|
45
|
+
export declare function maintenanceGateFromEnv(env?: Record<string, string | undefined>, options?: Omit<MaintenanceGateOptions, "feeds" | "override">): MaintenanceGate;
|
|
46
|
+
export declare function feedsFromEnv(value: string | undefined): string[];
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../../src/maintenance/gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEvB,MAAM,WAAW,CAAC;AAEnB;;;;;;;;;GASG;AACH,MAAM,WAAW,sBAAsB;IACrC,sFAAsF;IACtF,KAAK,EAAE,SAAS,MAAM,E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