@getquick/content 0.0.0-stage → 0.1.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 +142 -2
- package/consent-migrations/0001_consent_records.sql +34 -0
- package/dist/bearer-DMOCoSci.js +16 -0
- package/dist/client-config-B3LNSOxl.js +4 -0
- package/dist/configuration-C_JGygQI.d.ts +259 -0
- package/dist/consent-astro.d.ts +36 -0
- package/dist/consent-astro.js +94 -0
- package/dist/consent-client.d.ts +37 -0
- package/dist/consent-client.js +321 -0
- package/dist/consent-migrations.d.ts +8 -0
- package/dist/consent-migrations.js +10 -0
- package/dist/consent-server.d.ts +77 -0
- package/dist/consent-server.js +292 -0
- package/dist/consent-testing.d.ts +96 -0
- package/dist/consent-testing.js +188 -0
- package/dist/consent.d.ts +114 -0
- package/dist/consent.js +5 -0
- package/dist/embeds-p9SyGNZI.js +344 -0
- package/dist/formatting-wOk2jz6J.js +276 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +20 -0
- package/dist/legal-C5Xiq59W.d.ts +48 -0
- package/dist/migrations.d.ts +4 -0
- package/dist/migrations.js +6 -0
- package/dist/paths-Cmzzof3v.js +5 -0
- package/dist/records-CACA2O0Q.d.ts +56 -0
- package/dist/records-Dumrz759.js +74 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +6368 -0
- package/dist/state-BYWc5TUB.js +559 -0
- package/dist/state-Dzd52F3c.d.ts +77 -0
- package/dist/version-Dn6VLZJO.js +6 -0
- package/dist/wordpress-CPL40-vq.d.ts +318 -0
- package/migrations/0001_publications.sql +31 -0
- package/migrations/0002_entries.sql +14 -0
- package/migrations/0003_publication_events.sql +36 -0
- package/migrations/0004_withdrawals.sql +30 -0
- package/migrations/0005_reconciliation.sql +45 -0
- package/package.json +56 -3
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { r as ConsentConfiguration, t as AnalyticsSettings } from "./configuration-C_JGygQI.js";
|
|
2
|
+
import { r as LegalLanguage } from "./legal-C5Xiq59W.js";
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region frontend/src/site-language.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The `<html lang>` for a WordPress locale: its language and region as a
|
|
7
|
+
* BCP 47 tag (pt_PT_ao90 → pt-PT). WordPress's variants (ao90, formal) aren't
|
|
8
|
+
* BCP 47 subtags, so they are left out; no locale means English.
|
|
9
|
+
*/
|
|
10
|
+
declare function htmlLang(locale: string | undefined): string;
|
|
11
|
+
/** A language the site serves. */
|
|
12
|
+
interface SiteLanguage {
|
|
13
|
+
/** Its WordPress locale (pt_PT_ao90); empty when configuration names none. */
|
|
14
|
+
locale: string;
|
|
15
|
+
/** Polylang's slug, its URL directory: the default language's is its language code. */
|
|
16
|
+
slug: string;
|
|
17
|
+
/** Its GraphQL LanguageCodeEnum value: the slug in upper case (pt-br → PT_BR). */
|
|
18
|
+
code: string;
|
|
19
|
+
/** Its `<html lang>`. */
|
|
20
|
+
lang: string;
|
|
21
|
+
isDefault: boolean;
|
|
22
|
+
/** Its home route: / for the default language, /<slug>/ for the others. */
|
|
23
|
+
home: string;
|
|
24
|
+
}
|
|
25
|
+
interface WordPressLanguages {
|
|
26
|
+
locale?: string;
|
|
27
|
+
languages?: readonly {
|
|
28
|
+
locale: string;
|
|
29
|
+
slug: string;
|
|
30
|
+
}[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* configuration's languages: wordpress.locale, the default, served at /, then
|
|
34
|
+
* each of wordpress.languages under its slug. A monolingual Site has one.
|
|
35
|
+
*/
|
|
36
|
+
declare function siteLanguages(wordpress: WordPressLanguages | undefined): SiteLanguage[];
|
|
37
|
+
/**
|
|
38
|
+
* A route's language: the one whose slug is its first segment, else the
|
|
39
|
+
* default language, which has no directory.
|
|
40
|
+
*/
|
|
41
|
+
declare function routeLanguage(route: string, among: readonly SiteLanguage[]): SiteLanguage;
|
|
42
|
+
/**
|
|
43
|
+
* How logs and reports name something a language has: "the front page" for
|
|
44
|
+
* the default language's, "the en front page" for another's.
|
|
45
|
+
*/
|
|
46
|
+
declare function languageSubject(language: SiteLanguage, what: string): string;
|
|
47
|
+
/** Whether a route is a language's home (/, /en/): served as a home, never as an entry. */
|
|
48
|
+
declare function isLanguageHome(route: string, among: readonly SiteLanguage[]): boolean;
|
|
49
|
+
declare namespace content_types_d_exports {
|
|
50
|
+
export { CmsFailure, CmsFailureReason, Delivery, DesignPresets, EntryContent, Found, HomeContent, Missing, PublishedEntry, SiteChrome, Translation, Unavailable, WordPressImage, WordPressMenuItem, WordPressPost, WordPressSettings };
|
|
51
|
+
}
|
|
52
|
+
interface WordPressImage {
|
|
53
|
+
sourceUrl: string;
|
|
54
|
+
altText: string;
|
|
55
|
+
}
|
|
56
|
+
interface WordPressPost {
|
|
57
|
+
id: string;
|
|
58
|
+
title: string;
|
|
59
|
+
excerpt: string;
|
|
60
|
+
content: string;
|
|
61
|
+
uri: string;
|
|
62
|
+
date: string;
|
|
63
|
+
featuredImage: WordPressImage | null;
|
|
64
|
+
hasVideoHero: boolean;
|
|
65
|
+
}
|
|
66
|
+
interface WordPressMenuItem {
|
|
67
|
+
id: string;
|
|
68
|
+
label: string;
|
|
69
|
+
href: string;
|
|
70
|
+
target: string | null;
|
|
71
|
+
children: WordPressMenuItem[];
|
|
72
|
+
}
|
|
73
|
+
interface WordPressSettings {
|
|
74
|
+
title: string;
|
|
75
|
+
description: string;
|
|
76
|
+
}
|
|
77
|
+
interface DesignPresets {
|
|
78
|
+
spacingSizes: Array<{
|
|
79
|
+
slug: string;
|
|
80
|
+
size: string;
|
|
81
|
+
}>;
|
|
82
|
+
colors: Array<{
|
|
83
|
+
slug: string;
|
|
84
|
+
color: string;
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
interface HomeContent extends DesignPresets {
|
|
88
|
+
/** The front page's WordPress entry (WPGraphQL's global id), if WordPress gave it. */
|
|
89
|
+
nodeId: string | null;
|
|
90
|
+
settings: WordPressSettings;
|
|
91
|
+
page: {
|
|
92
|
+
title: string;
|
|
93
|
+
content: string;
|
|
94
|
+
hasVideoHero: boolean;
|
|
95
|
+
};
|
|
96
|
+
/** WordPress failed on the blocks, so this is the page without them. */
|
|
97
|
+
blocksOmitted: boolean;
|
|
98
|
+
}
|
|
99
|
+
/** A published translation of an entry: its URI and its language's slug. */
|
|
100
|
+
interface Translation {
|
|
101
|
+
uri: string;
|
|
102
|
+
language: string;
|
|
103
|
+
}
|
|
104
|
+
interface EntryContent extends WordPressPost, DesignPresets {
|
|
105
|
+
/** Its language's slug, on a multilingual Site. */
|
|
106
|
+
language?: string;
|
|
107
|
+
/** Its published translations into the site's other languages, on a multilingual Site. */
|
|
108
|
+
translations?: Translation[];
|
|
109
|
+
/** WordPress failed on the blocks, so this is the entry without them. */
|
|
110
|
+
blocksOmitted: boolean;
|
|
111
|
+
/** When WordPress last modified it (ms, the CMS's clock), if it said. */
|
|
112
|
+
modifiedAt: number | null;
|
|
113
|
+
}
|
|
114
|
+
/** A published page or post as WordPress lists it: its id, URI and last modification. */
|
|
115
|
+
interface PublishedEntry {
|
|
116
|
+
/** WPGraphQL's global id, when WordPress gives it. */
|
|
117
|
+
id: string | null;
|
|
118
|
+
uri: string;
|
|
119
|
+
/** When WordPress last modified it (ms, the CMS's clock), if it said. */
|
|
120
|
+
modifiedAt: number | null;
|
|
121
|
+
}
|
|
122
|
+
interface SiteChrome {
|
|
123
|
+
menuItems: WordPressMenuItem[];
|
|
124
|
+
siteIcon: WordPressImage | null;
|
|
125
|
+
siteLogo: WordPressImage | null;
|
|
126
|
+
/**
|
|
127
|
+
* This language's LEGAL-1 Contract from gq-config, on a Site with consent
|
|
128
|
+
* CMS settings enabled (null when gq-config has none for it).
|
|
129
|
+
*/
|
|
130
|
+
legal?: LegalLanguage | null;
|
|
131
|
+
/** gq-config's GA4 settings, on a Site with consent CMS settings enabled. */
|
|
132
|
+
analytics?: AnalyticsSettings;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Why WordPress couldn't deliver: it didn't answer in time (`timeout`), couldn't
|
|
136
|
+
* be reached (`network`), answered with an HTTP error (`http`) or GraphQL errors
|
|
137
|
+
* (`graphql`), or answered with data missing the fields the Frontend requires
|
|
138
|
+
* (`schema`).
|
|
139
|
+
*/
|
|
140
|
+
type CmsFailureReason = "timeout" | "network" | "http" | "graphql" | "schema";
|
|
141
|
+
interface CmsFailure {
|
|
142
|
+
reason: CmsFailureReason;
|
|
143
|
+
message: string;
|
|
144
|
+
httpStatus?: number;
|
|
145
|
+
}
|
|
146
|
+
interface Found<T> {
|
|
147
|
+
kind: "found";
|
|
148
|
+
content: T;
|
|
149
|
+
}
|
|
150
|
+
/** WordPress answered with valid data, and has nothing published there. */
|
|
151
|
+
interface Missing {
|
|
152
|
+
kind: "missing";
|
|
153
|
+
}
|
|
154
|
+
/** The content couldn't be read. This says nothing about whether it exists. */
|
|
155
|
+
interface Unavailable {
|
|
156
|
+
kind: "unavailable";
|
|
157
|
+
failure: CmsFailure;
|
|
158
|
+
}
|
|
159
|
+
type Delivery<T> = Found<T> | Missing | Unavailable;
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region frontend/src/bindings.d.ts
|
|
162
|
+
interface SqlStatement {
|
|
163
|
+
bind(...values: unknown[]): SqlStatement;
|
|
164
|
+
first<T = Record<string, unknown>>(): Promise<T | null>;
|
|
165
|
+
all<T = Record<string, unknown>>(): Promise<{
|
|
166
|
+
results: T[];
|
|
167
|
+
}>;
|
|
168
|
+
run(): Promise<{
|
|
169
|
+
meta: {
|
|
170
|
+
changes: number;
|
|
171
|
+
};
|
|
172
|
+
}>;
|
|
173
|
+
}
|
|
174
|
+
interface SqlDatabase {
|
|
175
|
+
prepare(query: string): SqlStatement;
|
|
176
|
+
/** Runs the statements in order as one transaction: all of them apply, or none. */
|
|
177
|
+
batch<T = Record<string, unknown>>(statements: SqlStatement[]): Promise<Array<{
|
|
178
|
+
results: T[];
|
|
179
|
+
}>>;
|
|
180
|
+
}
|
|
181
|
+
interface ContentBindings {
|
|
182
|
+
/** The publication store (D1). */
|
|
183
|
+
PUBLICATION_DB?: SqlDatabase;
|
|
184
|
+
/** The trusted refresh's bearer token (a Worker secret). */
|
|
185
|
+
FRONTEND_REFRESH_TOKEN?: string;
|
|
186
|
+
/** The key the CMS signs its publication events with (a Worker secret). */
|
|
187
|
+
PUBLICATION_EVENT_SECRET?: string;
|
|
188
|
+
/** Read-only CMS edge identity; never the automation service or public env. */
|
|
189
|
+
GQ_AUTH_GRAPHQL_CLIENT_ID?: string;
|
|
190
|
+
GQ_AUTH_GRAPHQL_CLIENT_SECRET?: string;
|
|
191
|
+
}
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region frontend/src/page-types.d.ts
|
|
194
|
+
/** The front page as stored: what WordPress delivered, without read details. */
|
|
195
|
+
type HomePublication = Omit<HomeContent, "blocksOmitted" | "nodeId">;
|
|
196
|
+
/** A published page or post as stored, with the design presets it was read with. */
|
|
197
|
+
type EntryPublication = Omit<EntryContent, "blocksOmitted" | "modifiedAt">;
|
|
198
|
+
/**
|
|
199
|
+
* A page in another language that a visitor of this one may switch to: its
|
|
200
|
+
* published translation (`translation`), or else that language's home.
|
|
201
|
+
*/
|
|
202
|
+
interface Alternate {
|
|
203
|
+
language: SiteLanguage;
|
|
204
|
+
route: string;
|
|
205
|
+
translation: boolean;
|
|
206
|
+
}
|
|
207
|
+
interface HomePage {
|
|
208
|
+
home: HomePublication;
|
|
209
|
+
chrome: SiteChrome;
|
|
210
|
+
/** The other languages' homes that are served; none on a monolingual Site. */
|
|
211
|
+
alternates: Alternate[];
|
|
212
|
+
}
|
|
213
|
+
interface EntryPage {
|
|
214
|
+
entry: EntryPublication;
|
|
215
|
+
chrome: SiteChrome;
|
|
216
|
+
/** Where its readers may switch language; none on a monolingual Site. */
|
|
217
|
+
alternates: Alternate[];
|
|
218
|
+
}
|
|
219
|
+
/** The entry a route served is published at another URI now: the route redirects there. */
|
|
220
|
+
interface Moved {
|
|
221
|
+
kind: "moved";
|
|
222
|
+
uri: string;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Why there is nothing to serve: the CMS failed (live reads, in explicit development),
|
|
226
|
+
* the store couldn't be read (`store`), or the Site has never been refreshed,
|
|
227
|
+
* or holds only state this Frontend can't read (`not-ready`).
|
|
228
|
+
*/
|
|
229
|
+
type DeliveryFailureReason = CmsFailureReason | "store" | "not-ready";
|
|
230
|
+
interface NotServed {
|
|
231
|
+
kind: "unavailable";
|
|
232
|
+
failure: {
|
|
233
|
+
reason: DeliveryFailureReason;
|
|
234
|
+
message: string;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
type HomeDelivery = Found<HomePage> | (Missing & {
|
|
238
|
+
chrome: SiteChrome | null;
|
|
239
|
+
}) | NotServed;
|
|
240
|
+
type EntryDelivery = Found<EntryPage> | (Missing & {
|
|
241
|
+
chrome: SiteChrome | null;
|
|
242
|
+
}) | Moved | NotServed;
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region frontend/src/server.d.ts
|
|
245
|
+
interface ContentConfig {
|
|
246
|
+
site: string;
|
|
247
|
+
graphqlEndpoint: string;
|
|
248
|
+
cmsOrigin: string;
|
|
249
|
+
wordpress?: WordPressLanguages;
|
|
250
|
+
/** Live delivery without a publication store is opt-in; false by default. */
|
|
251
|
+
development?: boolean;
|
|
252
|
+
isServer: () => boolean;
|
|
253
|
+
bindings: () => ContentBindings | Promise<ContentBindings>;
|
|
254
|
+
fetch?: typeof globalThis.fetch;
|
|
255
|
+
/**
|
|
256
|
+
* CONSENT-1 for this Site. Present, every published body's third-party
|
|
257
|
+
* embeds are rewritten into consent placeholders (unknown hosts blocked) on
|
|
258
|
+
* delivery; absent, bodies are delivered as published.
|
|
259
|
+
*/
|
|
260
|
+
consent?: ContentConsentConfig;
|
|
261
|
+
}
|
|
262
|
+
interface ContentConsentConfig {
|
|
263
|
+
/** The catalog services the Site declares in code (e.g. "youtube", "google_maps"). */
|
|
264
|
+
services?: readonly string[];
|
|
265
|
+
/**
|
|
266
|
+
* Hosts that are the Site itself besides relative URLs: its Frontend and its
|
|
267
|
+
* CMS/media origin. The CMS origin is included by default.
|
|
268
|
+
*/
|
|
269
|
+
firstPartyHosts?: readonly string[];
|
|
270
|
+
/**
|
|
271
|
+
* Read gq-config's Legal Contract and GA4 settings into each language's
|
|
272
|
+
* chrome (requires gq-config with the `getquickLegal` field). Their changes
|
|
273
|
+
* arrive as `legal` and `analytics` settings events.
|
|
274
|
+
*/
|
|
275
|
+
cmsSettings?: boolean;
|
|
276
|
+
}
|
|
277
|
+
declare function createContentRuntime(input: ContentConfig): {
|
|
278
|
+
languages: SiteLanguage[];
|
|
279
|
+
defaultLanguage: SiteLanguage;
|
|
280
|
+
multilingual: boolean;
|
|
281
|
+
routeLanguage: (route: string) => SiteLanguage;
|
|
282
|
+
isLanguageHome: (route: string) => boolean;
|
|
283
|
+
wordpress: WordPressClient;
|
|
284
|
+
handleEvent: (request: Request, context?: {
|
|
285
|
+
siteOrigin?: string;
|
|
286
|
+
}) => Promise<Response>;
|
|
287
|
+
handleRefresh: (request: Request, context?: {
|
|
288
|
+
siteOrigin?: string;
|
|
289
|
+
}) => Promise<Response>;
|
|
290
|
+
publishedHome: (siteOrigin?: string, language?: SiteLanguage) => Promise<HomeDelivery>;
|
|
291
|
+
publishedEntry: (path: string, siteOrigin?: string) => Promise<EntryDelivery>;
|
|
292
|
+
pageChrome: (siteOrigin?: string) => Promise<SiteChrome | null>;
|
|
293
|
+
/**
|
|
294
|
+
* The Site's consent configuration for a page served with this chrome:
|
|
295
|
+
* declared services, GA4 when gq-config's toggle is on, and the
|
|
296
|
+
* controller from the Legal Contract. Null when consent isn't configured.
|
|
297
|
+
*/
|
|
298
|
+
consentConfiguration: (chrome?: SiteChrome | null) => ConsentConfiguration | null;
|
|
299
|
+
};
|
|
300
|
+
type ContentRuntime = ReturnType<typeof createContentRuntime>;
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region frontend/src/wordpress.d.ts
|
|
303
|
+
interface WordPressClient {
|
|
304
|
+
getHomeContent(this: void, language?: SiteLanguage): Promise<Delivery<HomeContent>>;
|
|
305
|
+
getEntryByUri(this: void, uri: string): Promise<Delivery<EntryContent>>;
|
|
306
|
+
getDesignPresets(this: void): Promise<Found<DesignPresets> | Unavailable>;
|
|
307
|
+
getPublishedEntries(this: void): Promise<Found<{
|
|
308
|
+
entries: PublishedEntry[];
|
|
309
|
+
requests: number;
|
|
310
|
+
}> | Unavailable>;
|
|
311
|
+
getPublishedRoutes(this: void): Promise<Found<string[]> | Unavailable>;
|
|
312
|
+
getSiteChrome(this: void, siteOrigin?: string, options?: {
|
|
313
|
+
location?: string;
|
|
314
|
+
language?: SiteLanguage;
|
|
315
|
+
}): Promise<Found<SiteChrome> | Unavailable>;
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
318
|
+
export { Unavailable as A, routeLanguage as B, EntryContent as C, PublishedEntry as D, Missing as E, SiteLanguage as F, WordPressLanguages as I, htmlLang as L, WordPressMenuItem as M, WordPressPost as N, SiteChrome as O, WordPressSettings as P, isLanguageHome as R, DesignPresets as S, HomeContent as T, siteLanguages as V, SqlDatabase as _, createContentRuntime as a, CmsFailureReason as b, EntryDelivery as c, HomeDelivery as d, HomePage as f, ContentBindings as g, NotServed as h, ContentRuntime as i, WordPressImage as j, Translation as k, EntryPage as l, Moved as m, ContentConfig as n, Alternate as o, HomePublication as p, ContentConsentConfig as r, DeliveryFailureReason as s, WordPressClient as t, EntryPublication as u, SqlStatement as v, Found as w, Delivery as x, CmsFailure as y, languageSubject as z };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
-- The Frontend's durable published content: the last-known-good public
|
|
2
|
+
-- representation of each published thing ("home", "chrome"), and the outcome
|
|
3
|
+
-- of the last refresh of each. Alchemy applies these files in order on deploy
|
|
4
|
+
-- (infra/frontend.run.ts), before the Worker is updated, so a migration must
|
|
5
|
+
-- keep working with the Worker version it replaces: add, never rewrite.
|
|
6
|
+
|
|
7
|
+
CREATE TABLE publications (
|
|
8
|
+
-- What the row is: "home" (the front page), "chrome" (menu, logo, icon).
|
|
9
|
+
key TEXT PRIMARY KEY,
|
|
10
|
+
-- "published" (body holds it) or "missing" (the CMS confirmed nothing is
|
|
11
|
+
-- published there).
|
|
12
|
+
state TEXT NOT NULL,
|
|
13
|
+
-- The version of body's shape. A Worker only serves the formats it knows.
|
|
14
|
+
format INTEGER NOT NULL,
|
|
15
|
+
body TEXT,
|
|
16
|
+
-- When the CMS read behind this row started (ms since the epoch). A
|
|
17
|
+
-- promotion only replaces a row whose read started earlier, so a slow or
|
|
18
|
+
-- delayed refresh can't overwrite a newer one.
|
|
19
|
+
read_started_at INTEGER NOT NULL,
|
|
20
|
+
promoted_at INTEGER NOT NULL
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
CREATE TABLE refresh_attempts (
|
|
24
|
+
key TEXT PRIMARY KEY,
|
|
25
|
+
attempted_at INTEGER NOT NULL,
|
|
26
|
+
-- "promoted", "superseded" (a newer read was already promoted) or "kept"
|
|
27
|
+
-- (the read failed, so the stored row was left as it was).
|
|
28
|
+
outcome TEXT NOT NULL,
|
|
29
|
+
reason TEXT,
|
|
30
|
+
message TEXT
|
|
31
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- Published entries (pages and posts), one row each in publications, keyed
|
|
2
|
+
-- "entry:<uri>". Added for them, and harmless to the Worker version before:
|
|
3
|
+
-- it never names node_id, so its writes leave it NULL.
|
|
4
|
+
|
|
5
|
+
-- Which WordPress post or page a row holds (WPGraphQL's global id), so a
|
|
6
|
+
-- refresh that finds it at another URI can reconcile the route it left, and
|
|
7
|
+
-- a later withdrawal can find every route that served it.
|
|
8
|
+
ALTER TABLE publications ADD COLUMN node_id TEXT;
|
|
9
|
+
|
|
10
|
+
CREATE INDEX publications_node_id ON publications (node_id);
|
|
11
|
+
|
|
12
|
+
-- publications.state gains "moved": the entry the row held is published at
|
|
13
|
+
-- another URI now (body: {"uri": "<its URI>"}), so the route redirects there
|
|
14
|
+
-- instead of presenting its superseded copy as current.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
-- The CMS's publication events (POST /gq/events): one row per event the
|
|
2
|
+
-- Frontend accepted, so a duplicate is recognised, a delayed one can't undo a
|
|
3
|
+
-- newer one, and one whose refresh failed stays on record for a retry. Added
|
|
4
|
+
-- for them, and harmless to the Worker version before: it never reads it.
|
|
5
|
+
|
|
6
|
+
CREATE TABLE publication_events (
|
|
7
|
+
-- The event's identity, chosen by the CMS (a UUID). A delivery of an id
|
|
8
|
+
-- already recorded is a duplicate, or a retry of one that failed.
|
|
9
|
+
id TEXT PRIMARY KEY,
|
|
10
|
+
-- What happened: "publish" (a page or post was published or updated).
|
|
11
|
+
action TEXT NOT NULL,
|
|
12
|
+
-- The WordPress entry it is about (WPGraphQL's global id), as in
|
|
13
|
+
-- publications.node_id.
|
|
14
|
+
node_id TEXT NOT NULL,
|
|
15
|
+
-- The entry's URI when the event happened, and the one it had before, if it
|
|
16
|
+
-- moved.
|
|
17
|
+
uri TEXT NOT NULL,
|
|
18
|
+
previous_uri TEXT,
|
|
19
|
+
-- When it happened in the CMS (ms since the epoch): the order of one
|
|
20
|
+
-- entry's events. An event older than one already refreshed for the same
|
|
21
|
+
-- entry is superseded, never processed.
|
|
22
|
+
occurred_at INTEGER NOT NULL,
|
|
23
|
+
received_at INTEGER NOT NULL,
|
|
24
|
+
-- "received" (not processed yet, or interrupted), "refreshed", "failed"
|
|
25
|
+
-- (its refresh kept the stored versions; a retry may process it again) or
|
|
26
|
+
-- "superseded" (a newer event for the entry was refreshed).
|
|
27
|
+
status TEXT NOT NULL,
|
|
28
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
29
|
+
processed_at INTEGER,
|
|
30
|
+
-- Why it failed, when it did (a refresh failure reason and its message).
|
|
31
|
+
reason TEXT,
|
|
32
|
+
message TEXT
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
CREATE INDEX publication_events_node ON publication_events (node_id, occurred_at);
|
|
36
|
+
CREATE INDEX publication_events_status ON publication_events (status, received_at);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
-- The CMS's withdrawals (a page or post unpublished, made private or
|
|
2
|
+
-- password-protected, trashed or deleted): one row per WordPress entry whose
|
|
3
|
+
-- last accepted lifecycle event withdrew it. While a withdrawal is in force,
|
|
4
|
+
-- nothing promotes that entry's content again, whatever a read returns; only a
|
|
5
|
+
-- publication event that happened after it lifts it. Added for them, and
|
|
6
|
+
-- harmless to the Worker version before: it never reads this table, and a
|
|
7
|
+
-- "withdrawn" row is a state it doesn't know, so it serves it as a 503, never
|
|
8
|
+
-- as content.
|
|
9
|
+
|
|
10
|
+
CREATE TABLE withdrawals (
|
|
11
|
+
-- The WordPress entry (WPGraphQL's global id), as in publications.node_id.
|
|
12
|
+
node_id TEXT PRIMARY KEY,
|
|
13
|
+
-- The withdraw event in force (publication_events.id) and the URI the entry
|
|
14
|
+
-- had while it was published.
|
|
15
|
+
event_id TEXT NOT NULL,
|
|
16
|
+
uri TEXT NOT NULL,
|
|
17
|
+
-- When it happened in the CMS (ms since the epoch), and when the Frontend
|
|
18
|
+
-- accepted it (ms, the Frontend's clock).
|
|
19
|
+
withdrawn_at INTEGER NOT NULL,
|
|
20
|
+
accepted_at INTEGER NOT NULL,
|
|
21
|
+
-- The newer publication event that lifted it, and when that happened in the
|
|
22
|
+
-- CMS. NULL while the withdrawal is in force.
|
|
23
|
+
republished_by TEXT,
|
|
24
|
+
republished_at INTEGER
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
-- publications.state gains "withdrawn": the entry the row held was withdrawn
|
|
28
|
+
-- (body NULL). It is a 404, and nothing older than the withdrawal replaces it.
|
|
29
|
+
-- publication_events.action gains "withdraw"; one that was applied is
|
|
30
|
+
-- recorded "refreshed", like a publication: the store is up to date with it.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
-- Reconciliation (ADR 0009): the CMS's scheduler asks the Frontend, every
|
|
2
|
+
-- minute, to compare its publication store with what WordPress publishes and
|
|
3
|
+
-- to refresh what differs, so a change whose event never arrived still
|
|
4
|
+
-- reaches visitors. Added for it, and harmless to the Worker version before:
|
|
5
|
+
-- it never names these columns or this table.
|
|
6
|
+
|
|
7
|
+
-- When WordPress last modified the entry a row holds (ms since the epoch, the
|
|
8
|
+
-- CMS's clock: WPGraphQL's modifiedGmt), as the read that promoted it saw it.
|
|
9
|
+
-- NULL for rows promoted before this column, or by a read without it: a
|
|
10
|
+
-- reconciliation reads those again.
|
|
11
|
+
ALTER TABLE publications ADD COLUMN modified_at INTEGER;
|
|
12
|
+
|
|
13
|
+
-- The Site's reconciliation: one row, holding the lease that keeps two runs
|
|
14
|
+
-- from overlapping and the outcome of the last run, for diagnostics.
|
|
15
|
+
CREATE TABLE reconciliation (
|
|
16
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
17
|
+
-- The run holding the lease (the reconcile event's id), and until when (ms).
|
|
18
|
+
-- A run that was interrupted leaves it to expire.
|
|
19
|
+
run_id TEXT,
|
|
20
|
+
lease_until INTEGER NOT NULL DEFAULT 0,
|
|
21
|
+
started_at INTEGER,
|
|
22
|
+
finished_at INTEGER,
|
|
23
|
+
-- "reconciled" (nothing differs any more), "behind" (changes left for the
|
|
24
|
+
-- next run) or "failed" (a read or a refresh failed; what was stored is
|
|
25
|
+
-- kept).
|
|
26
|
+
outcome TEXT,
|
|
27
|
+
-- What the last run found: the published entries it compared, the changes it
|
|
28
|
+
-- refreshed, those it left for the next run, and those whose refresh failed.
|
|
29
|
+
checked INTEGER,
|
|
30
|
+
changed INTEGER,
|
|
31
|
+
pending INTEGER,
|
|
32
|
+
failed INTEGER,
|
|
33
|
+
-- The first failure's reason and message (no content, no secret).
|
|
34
|
+
reason TEXT,
|
|
35
|
+
message TEXT,
|
|
36
|
+
-- When the last run that left nothing behind started: the store matched
|
|
37
|
+
-- WordPress as of then.
|
|
38
|
+
reconciled_at INTEGER
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
-- Reconciliation records the change it found in an entry, when WordPress
|
|
42
|
+
-- gives its id and modification time, as a publication event in
|
|
43
|
+
-- publication_events (an id starting "reconcile-", the same for the same
|
|
44
|
+
-- change, and occurred_at its modification time), so it is processed, ordered
|
|
45
|
+
-- and retried by the same rules as one the CMS sent.
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getquick/content",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"migrations",
|
|
8
|
+
"consent-migrations"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./server": {
|
|
18
|
+
"types": "./dist/server.d.ts",
|
|
19
|
+
"import": "./dist/server.js"
|
|
20
|
+
},
|
|
21
|
+
"./migrations": {
|
|
22
|
+
"types": "./dist/migrations.d.ts",
|
|
23
|
+
"import": "./dist/migrations.js"
|
|
24
|
+
},
|
|
25
|
+
"./consent": {
|
|
26
|
+
"types": "./dist/consent.d.ts",
|
|
27
|
+
"import": "./dist/consent.js"
|
|
28
|
+
},
|
|
29
|
+
"./consent/client": {
|
|
30
|
+
"types": "./dist/consent-client.d.ts",
|
|
31
|
+
"import": "./dist/consent-client.js"
|
|
32
|
+
},
|
|
33
|
+
"./consent/server": {
|
|
34
|
+
"types": "./dist/consent-server.d.ts",
|
|
35
|
+
"import": "./dist/consent-server.js"
|
|
36
|
+
},
|
|
37
|
+
"./consent/migrations": {
|
|
38
|
+
"types": "./dist/consent-migrations.d.ts",
|
|
39
|
+
"import": "./dist/consent-migrations.js"
|
|
40
|
+
},
|
|
41
|
+
"./consent/astro": {
|
|
42
|
+
"types": "./dist/consent-astro.d.ts",
|
|
43
|
+
"import": "./dist/consent-astro.js"
|
|
44
|
+
},
|
|
45
|
+
"./consent/testing": {
|
|
46
|
+
"types": "./dist/consent-testing.d.ts",
|
|
47
|
+
"import": "./dist/consent-testing.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"zod": "3.25.76"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=22"
|
|
58
|
+
}
|
|
6
59
|
}
|