@getquick/content 0.1.0 → 0.3.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 +155 -6
- package/dist/consent-astro.js +1 -1
- package/dist/consent.js +1 -1
- package/dist/dist-D4-CMkrf.js +7047 -0
- package/dist/index.d.ts +20 -4
- package/dist/index.js +24 -5
- package/dist/metadata-content.d.ts +36 -0
- package/dist/metadata-content.js +51 -0
- package/dist/metadata-testing.d.ts +34 -0
- package/dist/metadata-testing.js +142 -0
- package/dist/metadata.d.ts +94 -0
- package/dist/metadata.js +218 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.js +943 -58
- package/dist/{formatting-wOk2jz6J.js → site-language-cBP8SFrS.js} +302 -50
- package/dist/{version-Dn6VLZJO.js → version-D_Ao31D3.js} +1 -1
- package/dist/wordpress-D_HG2rEt.d.ts +606 -0
- package/package.json +13 -1
- package/dist/wordpress-CPL40-vq.d.ts +0 -318
|
@@ -1,318 +0,0 @@
|
|
|
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 };
|