@justflows/sdk 0.0.0-stage → 1.2.1

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.
Files changed (78) hide show
  1. package/README.md +95 -2
  2. package/dist/api-urls.d.ts +4 -0
  3. package/dist/api-urls.d.ts.map +1 -0
  4. package/dist/api-urls.js +22 -0
  5. package/dist/api-urls.js.map +1 -0
  6. package/dist/cache.d.ts +63 -0
  7. package/dist/cache.d.ts.map +1 -0
  8. package/dist/cache.js +28 -0
  9. package/dist/cache.js.map +1 -0
  10. package/dist/capabilities.d.ts +73 -0
  11. package/dist/capabilities.d.ts.map +1 -0
  12. package/dist/capabilities.js +118 -0
  13. package/dist/capabilities.js.map +1 -0
  14. package/dist/compatibility.d.ts +7 -0
  15. package/dist/compatibility.d.ts.map +1 -0
  16. package/dist/compatibility.js +7 -0
  17. package/dist/compatibility.js.map +1 -0
  18. package/dist/cookies.d.ts +60 -0
  19. package/dist/cookies.d.ts.map +1 -0
  20. package/dist/cookies.js +60 -0
  21. package/dist/cookies.js.map +1 -0
  22. package/dist/hooks.d.ts +1393 -0
  23. package/dist/hooks.d.ts.map +1 -0
  24. package/dist/hooks.js +102 -0
  25. package/dist/hooks.js.map +1 -0
  26. package/dist/index.d.ts +30 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +25 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/license.d.ts +26 -0
  31. package/dist/license.d.ts.map +1 -0
  32. package/dist/license.js +90 -0
  33. package/dist/license.js.map +1 -0
  34. package/dist/media-html.d.ts +85 -0
  35. package/dist/media-html.d.ts.map +1 -0
  36. package/dist/media-html.js +181 -0
  37. package/dist/media-html.js.map +1 -0
  38. package/dist/patterns.d.ts +72 -0
  39. package/dist/patterns.d.ts.map +1 -0
  40. package/dist/patterns.js +86 -0
  41. package/dist/patterns.js.map +1 -0
  42. package/dist/placeholders.d.ts +64 -0
  43. package/dist/placeholders.d.ts.map +1 -0
  44. package/dist/placeholders.js +38 -0
  45. package/dist/placeholders.js.map +1 -0
  46. package/dist/plugin.d.ts +2424 -0
  47. package/dist/plugin.d.ts.map +1 -0
  48. package/dist/plugin.js +724 -0
  49. package/dist/plugin.js.map +1 -0
  50. package/dist/publisher-namespace.d.ts +49 -0
  51. package/dist/publisher-namespace.d.ts.map +1 -0
  52. package/dist/publisher-namespace.js +106 -0
  53. package/dist/publisher-namespace.js.map +1 -0
  54. package/dist/registry.d.ts +64 -0
  55. package/dist/registry.d.ts.map +1 -0
  56. package/dist/registry.js +132 -0
  57. package/dist/registry.js.map +1 -0
  58. package/dist/search.d.ts +25 -0
  59. package/dist/search.d.ts.map +1 -0
  60. package/dist/search.js +2 -0
  61. package/dist/search.js.map +1 -0
  62. package/dist/spam.d.ts +30 -0
  63. package/dist/spam.d.ts.map +1 -0
  64. package/dist/spam.js +3 -0
  65. package/dist/spam.js.map +1 -0
  66. package/dist/templates.d.ts +37 -0
  67. package/dist/templates.d.ts.map +1 -0
  68. package/dist/templates.js +52 -0
  69. package/dist/templates.js.map +1 -0
  70. package/dist/version.d.ts +5 -0
  71. package/dist/version.d.ts.map +1 -0
  72. package/dist/version.js +6 -0
  73. package/dist/version.js.map +1 -0
  74. package/dist/visibility.d.ts +79 -0
  75. package/dist/visibility.d.ts.map +1 -0
  76. package/dist/visibility.js +3 -0
  77. package/dist/visibility.js.map +1 -0
  78. package/package.json +46 -4
@@ -0,0 +1,1393 @@
1
+ /**
2
+ * @justflows/sdk — Typed hook contracts
3
+ *
4
+ * This is the stable public contract for plugin and theme developers.
5
+ * Every name and payload shape here is public API under semantic versioning.
6
+ *
7
+ * INTERNAL NOTE: This file must never import from @justflows/core —
8
+ * it is the public surface that extensions depend on.
9
+ */
10
+ import type { PluginSettingsField } from "./plugin.js";
11
+ import type { PlaceholderFilterContext, PlaceholderImage } from "./placeholders.js";
12
+ import type { SearchBackend } from "./search.js";
13
+ import type { SpamCheckBackend } from "./spam.js";
14
+ /** A public page being rendered, as `html.head`, `html.title`, `html.canonical`, and `html.alternates` see it. */
15
+ export interface PublicPageContext {
16
+ siteId: string;
17
+ /** Path without a locale prefix. */
18
+ path: string;
19
+ locale: string;
20
+ /** The page or entry title, before any title template. */
21
+ title: string;
22
+ contentId?: string;
23
+ /** The entry's content type, when the page shows an entry. */
24
+ contentType?: string;
25
+ /** The entry's custom fields (for example `seoTitle`), when the page shows an entry. */
26
+ fields?: Record<string, unknown>;
27
+ /** The entry's excerpt, or the page's own description. May be empty. */
28
+ description?: string;
29
+ /** Absolute canonical URL the host would use. */
30
+ canonical?: string;
31
+ /** Absolute or site-root URL of a share image: the site logo or the `og` placeholder. May be empty. */
32
+ image?: string;
33
+ /** Public origin of the site, such as `https://example.com`. */
34
+ origin?: string;
35
+ /** False when the entry's type is kept out of search engines. */
36
+ indexable?: boolean;
37
+ }
38
+ /** One `<link rel="alternate" hreflang>` of a public page. */
39
+ export interface HtmlAlternate {
40
+ /** A language tag such as `nl` or `en-US`, or `x-default`. */
41
+ locale: string;
42
+ /** Absolute URL of the page in that language. */
43
+ href: string;
44
+ }
45
+ export type HookSource = "http" | "job" | "cli" | "system";
46
+ export interface HookActor {
47
+ readonly userId?: string;
48
+ readonly role?: string;
49
+ }
50
+ /**
51
+ * Correlation data handed to every handler as the second argument.
52
+ * Identity and provenance only — never secrets or runtime internals.
53
+ */
54
+ export interface HookContext {
55
+ readonly siteId?: string;
56
+ readonly requestId?: string;
57
+ readonly source?: HookSource;
58
+ /** The host persisted outbound webhook deliveries before dispatching this action. */
59
+ readonly webhookQueued?: boolean;
60
+ readonly actor?: HookActor;
61
+ }
62
+ /** A gate payload: the event plus the right to cancel the operation. */
63
+ export type Cancellable<T> = T & {
64
+ /**
65
+ * Abort the pending operation. The reason is surfaced to the end user,
66
+ * so write it for a human.
67
+ */
68
+ cancel(reason: string): void;
69
+ };
70
+ export type Unsubscribe = () => void;
71
+ export interface HookRegisterOptions {
72
+ /** Lower runs earlier. Default 100. */
73
+ priority?: number;
74
+ /** Auto-dispose after the first dispatch. */
75
+ once?: boolean;
76
+ /** Stable label shown in hook diagnostics. */
77
+ id?: string;
78
+ /**
79
+ * Run on every site in the installation, not only where this plugin is
80
+ * active, while the plugin is active on the main site. Requires the
81
+ * `platform:network` permission; registering without it throws. Use it for
82
+ * behaviour the main site applies network-wide, and read the main site's
83
+ * choices with `ctx.network.mainSiteSettings`. Other registrations stay
84
+ * limited to the sites that activated the plugin.
85
+ */
86
+ network?: true;
87
+ }
88
+ /** An authenticated account view. Identity comes from the verified site session. */
89
+ export interface AccountSectionContext {
90
+ readonly siteId: string;
91
+ readonly userId: string;
92
+ readonly email: string;
93
+ readonly role: string;
94
+ readonly installationRoot: boolean;
95
+ }
96
+ /** A POST action. The endpoint must enforce its own ownership and CSRF checks. */
97
+ export interface AccountAction {
98
+ label: string;
99
+ /** Same-origin /api/account/… or /ext/<plugin-id>/account/… endpoint. */
100
+ endpoint: string;
101
+ confirm?: string;
102
+ }
103
+ /** Text is escaped by the host; links accept same-origin paths or HTTPS URLs. */
104
+ export interface AccountCard {
105
+ title: string;
106
+ fields?: {
107
+ label: string;
108
+ value: string;
109
+ }[];
110
+ links?: {
111
+ label: string;
112
+ href: string;
113
+ }[];
114
+ actions?: AccountAction[];
115
+ }
116
+ /** Server-rendered, request-scoped contributions to the default /account page. */
117
+ /**
118
+ * Whose data a request is about: a site account (with its sign-in email), or
119
+ * a guest known only by an email address (`userId` null). Match on both when
120
+ * you store either.
121
+ */
122
+ export interface PrivacySubject {
123
+ readonly userId: string | null;
124
+ readonly email: string;
125
+ }
126
+ export interface PrivacyRequestContext {
127
+ readonly siteId: string;
128
+ /** The administrator handling the request. */
129
+ readonly actor: {
130
+ readonly userId: string;
131
+ readonly role: string;
132
+ };
133
+ /** When the request was made (ISO 8601). */
134
+ readonly requestedAt: string;
135
+ /**
136
+ * What the site must keep by law, set by the site owner in core. Financial
137
+ * records (orders, invoices, payments, refunds, credit notes) are kept for
138
+ * `financialRecordsYears` after the end of the year they belong to; keep
139
+ * only what the record legally needs (amounts, tax, the billing name and
140
+ * address on the invoice) and remove the rest now. Remove what is kept
141
+ * once its period has passed.
142
+ */
143
+ readonly retention: {
144
+ readonly financialRecordsYears: number;
145
+ };
146
+ }
147
+ /** What a plugin holds about the subject, as plain JSON for the download. */
148
+ export interface PrivacyExportPart {
149
+ /** Number of records found; 0 when there is nothing. */
150
+ count: number;
151
+ /** The records, grouped as the plugin likes, such as `{ bookings: [...] }`. */
152
+ records: Record<string, unknown>;
153
+ /** Short notes for the person handling the request. */
154
+ notes?: string[];
155
+ }
156
+ /** What a plugin removed or anonymised, and what it must keep for now. */
157
+ export interface PrivacyErasePart {
158
+ /** Per kind of record, how many were removed or anonymised. */
159
+ counts: Record<string, number>;
160
+ /**
161
+ * Records kept because the law requires them, per kind, with the date they
162
+ * will be removed (ISO 8601). Shown to the person handling the request and
163
+ * recorded in the audit trail.
164
+ */
165
+ kept?: {
166
+ kind: string;
167
+ count: number;
168
+ until: string;
169
+ reason: string;
170
+ }[];
171
+ /** Anything else the person handling the request should know. */
172
+ notes?: string[];
173
+ }
174
+ /**
175
+ * A plugin's part in data requests (GDPR Art. 15 and 17). Return it from the
176
+ * `privacy.providers` filter. Core calls every active plugin's provider from
177
+ * the user page and Users → Data requests, puts the parts into one download,
178
+ * runs erasure across all of them, and audits the request. A plugin never
179
+ * offers its own data-request page.
180
+ *
181
+ * Erasure removes every personal detail the site is not legally required to
182
+ * keep. Records the law requires (financial records for
183
+ * `context.retention.financialRecordsYears`) are reduced to what they legally
184
+ * need, reported in `kept` with their removal date, and removed by the plugin
185
+ * once that date passes. Erasure must be safe to repeat, and must not delete
186
+ * what other records still need: anonymise instead.
187
+ */
188
+ export interface PrivacyProvider {
189
+ /** The plugin id. */
190
+ id: string;
191
+ /** What people know this data as, such as "Bookings". */
192
+ label: string;
193
+ export(subject: PrivacySubject, context: PrivacyRequestContext): Promise<PrivacyExportPart>;
194
+ erase(subject: PrivacySubject, context: PrivacyRequestContext): Promise<PrivacyErasePart>;
195
+ }
196
+ export interface AccountSection {
197
+ /** Stable anchor, preferably namespaced: acme.memberships. */
198
+ id: string;
199
+ title: string;
200
+ description?: string;
201
+ cards: AccountCard[];
202
+ }
203
+ export interface AppEvent {
204
+ readonly version: string;
205
+ }
206
+ export interface ContentRef {
207
+ readonly contentId: string;
208
+ readonly siteId: string;
209
+ /** Content type slug when the host knows it (`product`, `page`, …). */
210
+ readonly type?: string;
211
+ /** Shared id for every locale of this entry. Absent on older hosts. */
212
+ readonly translationGroupId?: string;
213
+ }
214
+ /** `content.deleted` payload. Extends `ContentRef` with group-empty signalling. */
215
+ export interface ContentDeletedRef extends ContentRef {
216
+ /**
217
+ * True when no other locales remain in the translation group after this
218
+ * delete. Absent on older hosts.
219
+ */
220
+ readonly lastInTranslationGroup?: boolean;
221
+ }
222
+ /** Canonical live-or-working fields a revision gate/filter may inspect. */
223
+ export interface ContentRevisionSnapshot {
224
+ readonly title: string;
225
+ readonly slug: string;
226
+ readonly excerpt: string | null;
227
+ readonly blocks: unknown;
228
+ readonly fields: Record<string, unknown>;
229
+ }
230
+ export interface ContentRevisionRef extends ContentRef {
231
+ readonly revisionId: string;
232
+ readonly source?: "manual" | "autosave" | "import" | "api";
233
+ readonly actorId?: string;
234
+ }
235
+ /** A comment was stored. No email, address, or comment text. */
236
+ export interface CommentCreatedEvent {
237
+ readonly siteId: string;
238
+ readonly contentId: string;
239
+ readonly commentId: string;
240
+ readonly parentId: string;
241
+ readonly status: "pending" | "approved";
242
+ }
243
+ export interface ContentUpdateGateEvent extends ContentRef {
244
+ readonly revision?: ContentRevisionSnapshot;
245
+ readonly revisionId?: string;
246
+ }
247
+ export interface ContentConflict {
248
+ readonly contentId: string;
249
+ readonly expectedVersion: number;
250
+ readonly actualVersion: number;
251
+ }
252
+ /** Fields copied into a new translation. Plugins may blank or reshape them. */
253
+ export interface ContentTranslationSeed {
254
+ type: string;
255
+ title: string;
256
+ excerpt: string | null;
257
+ fields: unknown;
258
+ blocks: unknown;
259
+ }
260
+ export interface ContentRenderContext {
261
+ readonly siteId: string;
262
+ readonly contentId: string;
263
+ readonly type?: string;
264
+ readonly title?: string;
265
+ readonly excerpt?: string | null;
266
+ readonly translationGroupId?: string;
267
+ /**
268
+ * Language of the page being rendered (the URL's locale). Can differ from the
269
+ * entry's own locale when an untranslated entry is shown under another
270
+ * language's prefix. Absent on older hosts.
271
+ */
272
+ readonly locale?: string;
273
+ }
274
+ /** One approved comment in the public thread, passed to `comments.render`. */
275
+ export interface PublicComment {
276
+ readonly id: string;
277
+ readonly parentId: string | null;
278
+ readonly authorName: string;
279
+ readonly authorUrl: string | null;
280
+ /** Sanitised HTML — a small safe formatting subset. */
281
+ readonly bodyHtml: string;
282
+ /** ISO 8601. */
283
+ readonly createdAt: string;
284
+ readonly editedAt: string | null;
285
+ /** 0 for a top-level comment. */
286
+ readonly depth: number;
287
+ readonly replies: PublicComment[];
288
+ }
289
+ /**
290
+ * Context for `comments.render` — the rendered `justflows.comments.thread`
291
+ * block, plus the threaded data behind it so a handler can rebuild the markup
292
+ * from scratch.
293
+ */
294
+ export interface CommentsBlockRenderContext {
295
+ readonly siteId: string;
296
+ readonly contentId: string;
297
+ readonly contentType: string;
298
+ readonly slug: string | null;
299
+ readonly locale: string;
300
+ /** Permalink of the page the block sits on (for reply / pagination links). */
301
+ readonly basePath: string;
302
+ /** Block props set in the page builder. */
303
+ readonly props: {
304
+ readonly title: string;
305
+ readonly order: "oldest" | "newest";
306
+ };
307
+ /** Whether the section renders at all, and whether it still takes new comments. */
308
+ readonly visible: boolean;
309
+ readonly accepting: boolean;
310
+ /** Threaded approved comments for the current page. */
311
+ readonly comments: PublicComment[];
312
+ /** Total approved comments across every page. */
313
+ readonly total: number;
314
+ readonly page: number;
315
+ readonly totalPages: number;
316
+ /** Set only on the render right after a submission redirect. */
317
+ readonly banner: "posted" | "pending" | "error" | "captcha" | "rate_limited" | null;
318
+ /** The signed-in commenter, if any. */
319
+ readonly currentUser: {
320
+ readonly name: string;
321
+ readonly email: string;
322
+ } | null;
323
+ readonly captchaProvider: "none" | "turnstile" | "hcaptcha" | "recaptcha" | "recaptcha-v3";
324
+ }
325
+ export interface ContentDraft {
326
+ readonly siteId: string;
327
+ readonly type?: string;
328
+ readonly title: string;
329
+ readonly slug?: string;
330
+ readonly excerpt?: string | null;
331
+ readonly fields?: Record<string, unknown>;
332
+ }
333
+ export interface ContentCreateGateEvent {
334
+ readonly input: ContentDraft;
335
+ }
336
+ export interface MediaRef {
337
+ readonly siteId: string;
338
+ readonly mediaId: string;
339
+ }
340
+ export interface MediaUploadGateEvent {
341
+ readonly siteId: string;
342
+ readonly filename: string;
343
+ readonly mimeType: string;
344
+ readonly sizeBytes: number;
345
+ }
346
+ export interface MediaUploadedEvent extends MediaRef {
347
+ readonly url: string;
348
+ }
349
+ export interface UserEvent {
350
+ readonly userId: string;
351
+ }
352
+ export interface UserAccessChangedEvent extends UserEvent {
353
+ readonly roleId: string;
354
+ }
355
+ export interface AccessRoleEvent {
356
+ readonly roleId: string;
357
+ }
358
+ export interface AuthEvent {
359
+ readonly userId: string;
360
+ readonly email: string;
361
+ }
362
+ export interface AuthFailureEvent {
363
+ readonly email: string;
364
+ readonly reason: string;
365
+ }
366
+ export interface PluginEvent {
367
+ readonly pluginId: string;
368
+ readonly version: string;
369
+ readonly siteId?: string;
370
+ }
371
+ export interface ThemeEvent {
372
+ readonly themeId: string;
373
+ readonly version: string;
374
+ readonly siteId?: string;
375
+ }
376
+ export interface CoreUpdatedEvent {
377
+ readonly fromVersion: string;
378
+ readonly toVersion: string;
379
+ readonly source: "upload" | "remote" | "automatic";
380
+ }
381
+ export interface WebhookDeliveryEvent {
382
+ readonly deliveryId: string;
383
+ readonly endpointId: string;
384
+ readonly event: string;
385
+ readonly data: unknown;
386
+ readonly attempt: number;
387
+ readonly status: "delivered" | "retrying" | "failed";
388
+ readonly responseStatus: number | null;
389
+ readonly responseBody: string | null;
390
+ readonly error: string | null;
391
+ }
392
+ export interface RequestStartEvent {
393
+ readonly method: string;
394
+ readonly path: string;
395
+ }
396
+ export interface RequestEndEvent extends RequestStartEvent {
397
+ readonly statusCode: number;
398
+ readonly durationMs: number;
399
+ }
400
+ /**
401
+ * A visitor received a public page from the server: status below 400, not a
402
+ * preview, and not the static-site exporter's crawl. Fired after the response
403
+ * is sent, so a handler never delays the page. A statically-exported page has
404
+ * no server render; a plugin that counts views there ships its own beacon.
405
+ */
406
+ export interface PageViewedEvent {
407
+ readonly siteId: string;
408
+ /** Path as requested, without the query string. */
409
+ readonly path: string;
410
+ readonly locale?: string;
411
+ readonly contentId?: string;
412
+ readonly userAgent: string;
413
+ /** The `Referer` header, when the browser sent one. */
414
+ readonly referrer?: string;
415
+ readonly host: string;
416
+ }
417
+ export interface UnderConstructionContext {
418
+ readonly siteId: string;
419
+ readonly siteTitle: string;
420
+ readonly tagline: string;
421
+ }
422
+ export interface UnderConstructionViewedEvent {
423
+ readonly siteId: string;
424
+ }
425
+ export interface EmailDeliveryContext {
426
+ readonly deliveryId?: string;
427
+ readonly templateKey?: string;
428
+ readonly templateVersion?: number;
429
+ readonly locale?: string;
430
+ readonly messageType: string;
431
+ readonly recipient: string;
432
+ readonly transport: string;
433
+ readonly correlationId?: string;
434
+ }
435
+ export interface EmailBeforeSendEvent extends EmailDeliveryContext {
436
+ }
437
+ /**
438
+ * Where an inbound message should be delivered.
439
+ * The value is the mailbox owner's site id. Return `siteId` to file it on the
440
+ * site whose database is open.
441
+ */
442
+ export interface EmailRouteContext {
443
+ readonly from: string;
444
+ readonly to: string;
445
+ readonly subject: string;
446
+ readonly text: string;
447
+ /** The site whose database is open for this check. */
448
+ readonly siteId: string;
449
+ }
450
+ /** A message accepted by the site's inbound mail address. Text only; no attachments. */
451
+ export interface EmailReceivedEvent {
452
+ readonly from: string;
453
+ readonly to: string;
454
+ readonly subject: string;
455
+ readonly text: string;
456
+ }
457
+ export interface EmailDeliveryEvent extends EmailDeliveryContext {
458
+ readonly status: "queued" | "sent" | "deferred" | "failed" | "bounced";
459
+ readonly attempt: number;
460
+ /** Bounded, sanitized provider response or failure detail. */
461
+ readonly detail?: string;
462
+ }
463
+ export interface EmailSender {
464
+ /** RFC-compatible From header produced by the host. */
465
+ readonly from: string;
466
+ readonly replyTo?: string;
467
+ readonly envelopeSender?: string;
468
+ }
469
+ /** Cache layers that can be selectively revalidated. */
470
+ export type CacheObjectType = "pages" | "content" | "menus" | "theme" | "cssProviders" | "site";
471
+ export type CacheRevalidateTrigger = "content" | "menus" | "theme" | "settings" | "cssProviders" | "manual" | "plugin";
472
+ export interface CacheRevalidatedEvent {
473
+ readonly trigger: CacheRevalidateTrigger;
474
+ readonly objects: readonly CacheObjectType[];
475
+ readonly siteId?: string;
476
+ }
477
+ /** Summary of a completed static-site export run (`staticExport.completed`). */
478
+ export interface StaticExportCompletedEvent {
479
+ readonly ok: boolean;
480
+ readonly mode: "full" | "incremental";
481
+ /** Absolute directory the files were written to. */
482
+ readonly outDir: string;
483
+ /** Public origin the pages are meant to be served from (may be ""). */
484
+ readonly publicUrl: string;
485
+ readonly pages: number;
486
+ readonly assets: number;
487
+ readonly bytes: number;
488
+ readonly pruned: number;
489
+ readonly durationMs: number;
490
+ readonly errors: readonly string[];
491
+ }
492
+ /**
493
+ * Fired after `staticExport.completed`, carrying enough context for a plugin to
494
+ * push the generated directory to object storage or a CDN and invalidate the
495
+ * changed paths. `manifest` is the parsed `_static-export.json`.
496
+ */
497
+ export interface StaticExportDeployEvent {
498
+ readonly outDir: string;
499
+ readonly publicUrl: string;
500
+ readonly manifest: unknown;
501
+ readonly summary: StaticExportCompletedEvent;
502
+ }
503
+ /**
504
+ * A URL path the static-site exporter leaves to the live app
505
+ * (`staticExport.exclude`). The path is never crawled, written, or linked to
506
+ * as a static file; copies from earlier runs are removed; the generated
507
+ * `.htaccess` / `_nginx.conf` route it to the app; and with
508
+ * `STATIC_EXPORT_ORIGIN_URL` set, links and form actions pointing at it are
509
+ * rewritten to that origin.
510
+ */
511
+ export interface StaticExportExclusion {
512
+ /** Root-relative URL path, e.g. `/account/profile`. Letters, digits, `.`, `_`, `~`, `-` per segment. */
513
+ path: string;
514
+ /** `prefix` (default) also covers every path below it on a `/` boundary; `exact` only this path. */
515
+ match?: "exact" | "prefix";
516
+ }
517
+ export interface NavigationItem {
518
+ id: string;
519
+ label: string;
520
+ url: string;
521
+ children?: NavigationItem[];
522
+ }
523
+ /** Menu-level layout a menu designer instance renders as. */
524
+ export declare const MENU_LAYOUTS: readonly ["horizontal", "vertical", "dropdown", "multi-level-dropdown", "mega", "footer", "drawer"];
525
+ export type MenuLayout = (typeof MENU_LAYOUTS)[number];
526
+ /** How a top-level item's dropdown/mega panel is opened. */
527
+ export declare const MENU_ACTIVATIONS: readonly ["hover", "click", "both"];
528
+ export type MenuActivation = (typeof MENU_ACTIVATIONS)[number];
529
+ /**
530
+ * How the menu presents below its breakpoint. The pre-1.0 value `"drawer"` is
531
+ * accepted by the host and mapped to `"drawer-right"` on read.
532
+ */
533
+ export declare const MENU_MOBILE_PATTERNS: readonly ["dropdown", "accordion", "drawer-right", "drawer-left", "fullscreen"];
534
+ export type MenuMobilePattern = (typeof MENU_MOBILE_PATTERNS)[number];
535
+ /** Enter/exit motion for the open mobile menu (`prefers-reduced-motion` forces `none` at render). */
536
+ export declare const MENU_MOBILE_MOTIONS: readonly ["slide", "fade", "none"];
537
+ export type MenuMobileMotion = (typeof MENU_MOBILE_MOTIONS)[number];
538
+ /** Top-level alignment of the menu bar. */
539
+ export declare const MENU_ALIGNMENTS: readonly ["start", "center", "end", "space-between"];
540
+ export type MenuAlignment = (typeof MENU_ALIGNMENTS)[number];
541
+ /**
542
+ * Fixed subset of `@justflows/blocks` core kinds a mega-menu region may
543
+ * contain. Deliberately excludes `core.html`/`core.code`/`core.embed` even
544
+ * though the host sanitizer would clean them — menu content must never carry
545
+ * arbitrary scripts or raw HTML, not merely sanitized versions of them.
546
+ */
547
+ export declare const MEGA_MENU_SAFE_BLOCK_KINDS: readonly ["core.paragraph", "core.heading", "core.image", "core.button", "core.link-list", "core.divider", "core.spacer", "core.section", "core.container", "core.group", "core.columns", "core.column", "core.grid", "core.reusable"];
548
+ export type MegaMenuSafeBlockKind = (typeof MEGA_MENU_SAFE_BLOCK_KINDS)[number];
549
+ /**
550
+ * The layout/design fields a preset seeds onto a menu. Mirrors the host's
551
+ * `MenuDesign` one-for-one (minus `presetId`, which the host assigns) so a
552
+ * plugin-supplied preset and a hand-edited design are the same shape. The host
553
+ * re-parses whatever a filter returns, clamping numbers and dropping unknown
554
+ * enum values, so a preset can never widen what the designer itself allows.
555
+ */
556
+ export interface MenuDesignSeed {
557
+ layout: MenuLayout;
558
+ activation: MenuActivation;
559
+ /** px; below this width the mobile pattern applies (clamped to 320–1400). */
560
+ breakpoint: number;
561
+ mobilePattern: MenuMobilePattern;
562
+ mobileMotion?: MenuMobileMotion;
563
+ /** Motion duration in ms (clamped to 120–800). */
564
+ mobileMotionMs?: number;
565
+ alignment: MenuAlignment;
566
+ /** Clamped to 1–4. */
567
+ maxDepth: number;
568
+ /** Clamped to 1–40. */
569
+ maxItemsPerLevel: number;
570
+ }
571
+ /**
572
+ * A built-in-style menu design a plugin or theme contributes through the
573
+ * `menu.design.presets` filter. It appears as a one-click starting point in
574
+ * the menu designer's design panel — picking it fills in the menu's layout
575
+ * config, it does not persist any relationship to the preset afterward.
576
+ */
577
+ export interface MenuDesignPreset {
578
+ /** `"<pluginId>:<slug>"` — must sit under the contributing plugin's namespace. */
579
+ readonly id: string;
580
+ readonly name: string;
581
+ /** Plugin or theme id that contributed it. */
582
+ readonly source?: string;
583
+ readonly description?: string;
584
+ readonly design: MenuDesignSeed;
585
+ }
586
+ /** Who is viewing, for a `menu.visibility.evaluate` check. */
587
+ export interface MenuVisibilityEvaluateContext {
588
+ readonly siteId: string;
589
+ readonly authState: "guest" | "authenticated";
590
+ readonly role?: string;
591
+ readonly locale: string;
592
+ }
593
+ /**
594
+ * The header configuration a page renders. Mirrors the host's internal
595
+ * `PageHeaderConfig`; the host re-validates and sanitises every field it
596
+ * receives back from a filter (blocks are capped, `background` must be a safe
597
+ * CSS colour, enums are clamped).
598
+ */
599
+ export interface HeaderConfig {
600
+ visible: boolean;
601
+ menuMode: "inherit" | "menu" | "none";
602
+ menuSlug: string;
603
+ showLogo: boolean;
604
+ showTitle: boolean;
605
+ layout: "logo-left" | "logo-center" | "split";
606
+ sticky: boolean;
607
+ background: string;
608
+ showLanguageSwitcher: boolean;
609
+ languageSwitcherStyle: "locale-full" | "locale-short" | "flags" | "flag-locale" | "flag-country";
610
+ showColorScheme: boolean;
611
+ showColorSchemeSystem: boolean;
612
+ showAuthLinks: boolean;
613
+ /** Free blocks rendered into the header, same schema as page-body blocks. */
614
+ blocks: unknown[];
615
+ }
616
+ export interface HeaderBuildContext {
617
+ readonly siteId: string;
618
+ readonly locale: string;
619
+ readonly defaultLocale: string;
620
+ }
621
+ /**
622
+ * A header design a plugin or theme contributes through the `header.templates`
623
+ * filter. It appears in the per-page header dropdown and the customizer's
624
+ * "start from" list. Selecting it stores the ref `"<pluginId>:<slug>"` on the
625
+ * page; the host calls `build()` at render time (cached per ref + locale), so
626
+ * it may read plugin data and vary by locale.
627
+ */
628
+ export interface HeaderTemplate {
629
+ /** `"<pluginId>:<slug>"` — must sit under the contributing plugin's namespace. */
630
+ readonly id: string;
631
+ readonly name: string;
632
+ /** Plugin or theme id that contributed it. */
633
+ readonly source?: string;
634
+ readonly description?: string;
635
+ build(ctx: HeaderBuildContext): HeaderConfig | Promise<HeaderConfig>;
636
+ }
637
+ export interface HeaderResolveContext {
638
+ readonly siteId: string;
639
+ readonly locale: string;
640
+ readonly defaultLocale: string;
641
+ /** The stored ref: `"__default__"` | `"__none__"` | `"<lib-uuid>"` | `"<pluginId>:<slug>"`. */
642
+ readonly ref: string;
643
+ /** Present when a content page is rendering; absent for 404 / fallback chrome. */
644
+ readonly contentId?: string;
645
+ readonly contentType?: string;
646
+ }
647
+ /**
648
+ * One admin sidebar entry a plugin contributes through the `admin.menu` filter
649
+ * (and/or `adminMenu` in its manifest). The host re-validates every field.
650
+ */
651
+ export interface AdminNavItem {
652
+ pluginId: string;
653
+ id: string;
654
+ label: string;
655
+ labelKey?: string;
656
+ /** Locale code → label. Wins over `labelKey` and `label` in that locale. */
657
+ labels?: Record<string, string>;
658
+ /**
659
+ * Relative to `/admin/plugins/<pluginId>` — `""` / omit for the namespace
660
+ * root, else a lowercase leaf like `"orders"`. The host prepends the
661
+ * namespace; an absolute path (or one repeating the id) is rejected.
662
+ */
663
+ path?: string;
664
+ icon?: string;
665
+ domain?: string;
666
+ end?: boolean;
667
+ /** Host-only: `GET /ext/{pluginId}/setup` is rendered on this path, not on nested pages. */
668
+ setupPath?: string;
669
+ /** Host lists CMS entries of this type on the plugin page. */
670
+ contentType?: string;
671
+ /** When false, the page is reachable but omitted from the admin nav. */
672
+ listed?: boolean;
673
+ /** Roles that may open this page. Omitted: administrators and editors. */
674
+ roles?: string[];
675
+ }
676
+ /** OpenAPI 3.1 document plugins may extend through the `openapi.document` filter. */
677
+ export interface OpenApiDocument {
678
+ openapi: string;
679
+ info: Record<string, unknown>;
680
+ paths: Record<string, unknown>;
681
+ [key: string]: unknown;
682
+ }
683
+ /** Who an MCP or assistant tool call runs as. */
684
+ export interface McpToolCallContext {
685
+ siteId: string;
686
+ userId: string;
687
+ /** `mcp` for an external MCP client, `assistant` for the in-admin assistant. */
688
+ via: "mcp" | "assistant";
689
+ /** Client display name ("Claude", "Cursor", "Assistant"). */
690
+ client: string;
691
+ /** The capabilities this call may exercise (key or grant ∩ the user's current access). */
692
+ capabilities: readonly string[];
693
+ }
694
+ /**
695
+ * An extra agent tool a plugin contributes through the `mcp.tools` filter. The
696
+ * host lists it only to sessions that hold `capability`, checks it again before
697
+ * every call, and records each non-read-only call in the audit log. `handler`
698
+ * must enforce any finer-grained (per-resource) checks itself.
699
+ */
700
+ export interface McpToolDefinition {
701
+ /** Unique, `snake_case`, prefixed with the plugin (`acme_seo_score`). */
702
+ name: string;
703
+ title?: string;
704
+ /** Written for a model: what the tool does and when to use it. */
705
+ description: string;
706
+ /** JSON Schema for the arguments (`type: "object"`). */
707
+ inputSchema: Record<string, unknown>;
708
+ capability: string;
709
+ annotations?: {
710
+ readOnlyHint?: boolean;
711
+ destructiveHint?: boolean;
712
+ idempotentHint?: boolean;
713
+ };
714
+ handler(args: Record<string, unknown>, context: McpToolCallContext): unknown | Promise<unknown>;
715
+ }
716
+ /** A workspace a plugin may observe. Connection secrets are never included. */
717
+ export interface WorkspaceEvent {
718
+ tenantId: string;
719
+ siteId: string;
720
+ hostname: string;
721
+ userMode: "isolated" | "shared";
722
+ databaseMode: "current" | "separate";
723
+ }
724
+ /**
725
+ * `workspace.created` plus who administers the new workspace. Listening requires
726
+ * `platform:tenancy`, because it carries an email address.
727
+ */
728
+ export interface TenancyWorkspaceCreatedEvent extends WorkspaceEvent {
729
+ /** Sign-in email of the workspace's first administrator. Empty when unknown. */
730
+ adminEmail: string;
731
+ }
732
+ export interface WorkspaceStatusEvent {
733
+ tenantId: string;
734
+ }
735
+ export interface WorkspaceDeleteEvent {
736
+ tenantId: string;
737
+ dropDatabase: boolean;
738
+ }
739
+ export interface WorkspaceCreateGateEvent {
740
+ name: string;
741
+ slug: string;
742
+ userMode: "isolated" | "shared";
743
+ databaseMode: "current" | "separate";
744
+ siteName: string;
745
+ hostname: string;
746
+ }
747
+ export interface SiteCreateEvent {
748
+ tenantId: string;
749
+ siteId: string;
750
+ hostname: string;
751
+ databaseChoice: "inherit" | "current" | "separate";
752
+ }
753
+ export interface QuotaUpdatedEvent {
754
+ scope: "workspace" | "site";
755
+ scopeId: string;
756
+ /** Meter key to the stored limit. `null` means that meter is unlimited. */
757
+ limits: Record<string, number | null>;
758
+ }
759
+ /**
760
+ * Everything stored under one language was moved to another language of the
761
+ * same site (Settings → Languages → Move content). Plugins that keep their own
762
+ * per-language data move it from `from` to `to` here.
763
+ */
764
+ export interface LanguageContentMovedEvent {
765
+ siteId: string;
766
+ /** The source locale code, e.g. `en`. */
767
+ from: string;
768
+ /** The target locale code, e.g. `en-US`. */
769
+ to: string;
770
+ /** The source language was deleted after the move. */
771
+ sourceRemoved: boolean;
772
+ }
773
+ /** A custom domain a website connected. */
774
+ export interface DomainEvent {
775
+ siteId: string;
776
+ domainId: string;
777
+ hostname: string;
778
+ /** `records`: the customer edits their own DNS. `nameservers`: the platform hosts the zone. */
779
+ mode: "records" | "nameservers";
780
+ provider: "manual" | "bunny";
781
+ }
782
+ export interface DomainAddGateEvent {
783
+ siteId: string;
784
+ hostname: string;
785
+ mode: "records" | "nameservers";
786
+ }
787
+ export interface QuotaLimitContext {
788
+ key: string;
789
+ scope: "workspace" | "site";
790
+ scopeId: string;
791
+ /** The value stored for this meter, before this filter. `null` means unlimited. */
792
+ storedLimit: number | null;
793
+ }
794
+ export interface SiteCreateGateEvent {
795
+ tenantId: string;
796
+ name: string;
797
+ hostname: string;
798
+ databaseChoice: "inherit" | "current" | "separate";
799
+ userMode: "isolated" | "shared";
800
+ databaseMode: "current" | "separate";
801
+ }
802
+ /**
803
+ * Every core action, mapped to its payload. Actions observe something that
804
+ * already happened; they cannot cancel it.
805
+ *
806
+ * Plugins publishing their own actions augment this by declaration merging:
807
+ *
808
+ * @example
809
+ * declare module "@justflows/sdk" {
810
+ * interface ActionEventMap {
811
+ * "acme.seo.scoreCalculated": { contentId: string; score: number };
812
+ * }
813
+ * }
814
+ */
815
+ export interface ActionEventMap {
816
+ "app.starting": AppEvent;
817
+ "app.started": AppEvent;
818
+ "app.stopping": Record<string, never>;
819
+ "content.created": ContentRef;
820
+ "content.updated": ContentRef;
821
+ "content.deleted": ContentDeletedRef;
822
+ "content.published": ContentRef;
823
+ "content.unpublished": ContentRef;
824
+ "content.revisionSaved": ContentRevisionRef;
825
+ "content.revisionDiscarded": ContentRevisionRef;
826
+ "content.revisionRestored": ContentRevisionRef;
827
+ "comments.created": CommentCreatedEvent;
828
+ "media.uploaded": MediaUploadedEvent;
829
+ "media.deleted": MediaRef;
830
+ "user.created": UserEvent;
831
+ "user.updated": UserEvent;
832
+ "user.deleted": UserEvent;
833
+ "user.accessChanged": UserAccessChangedEvent;
834
+ "access.roleCreated": AccessRoleEvent;
835
+ "access.roleUpdated": AccessRoleEvent;
836
+ "access.roleDeleted": AccessRoleEvent;
837
+ "auth.login": AuthEvent;
838
+ "auth.logout": AuthEvent;
839
+ "auth.loginFailed": AuthFailureEvent;
840
+ "plugin.installed": PluginEvent;
841
+ "plugin.activated": PluginEvent;
842
+ "plugin.deactivated": PluginEvent;
843
+ /** Fired after that plugin's `deleteData()` hook has finished. */
844
+ "plugin.deleteData": PluginEvent;
845
+ "plugin.uninstalled": PluginEvent;
846
+ "theme.installed": ThemeEvent;
847
+ "theme.activated": ThemeEvent;
848
+ "core.updated": CoreUpdatedEvent;
849
+ /** Observe the bounded response or error after every outbound attempt. */
850
+ "webhook.delivered": WebhookDeliveryEvent;
851
+ "workspace.created": WorkspaceEvent;
852
+ "tenancy.workspaceCreated": TenancyWorkspaceCreatedEvent;
853
+ "workspace.suspended": WorkspaceStatusEvent;
854
+ "workspace.reactivated": WorkspaceStatusEvent;
855
+ "workspace.deleted": WorkspaceDeleteEvent;
856
+ /** Final removal completed; records are no longer available. */
857
+ "workspace.purged": WorkspaceStatusEvent;
858
+ "site.created": SiteCreateEvent;
859
+ "request.before": RequestStartEvent;
860
+ "request.after": RequestEndEvent;
861
+ "page.viewed": PageViewedEvent;
862
+ "site.underConstruction.viewed": UnderConstructionViewedEvent;
863
+ /** Core content of one language was moved to another language. */
864
+ "language.contentMoved": LanguageContentMovedEvent;
865
+ /** Fired after selective cache revalidation completes. */
866
+ "cache.revalidated": CacheRevalidatedEvent;
867
+ /** A static-site export run finished (manual, CLI, or auto-rebuild). */
868
+ "staticExport.completed": StaticExportCompletedEvent;
869
+ /** Deploy the generated directory to object storage / a CDN. */
870
+ "staticExport.deploy": StaticExportDeployEvent;
871
+ /** An inbound message was accepted for this site. Listening requires `mail:hook`. */
872
+ "email.received": EmailReceivedEvent;
873
+ /** Delivery has been accepted by the host and recorded, before transport I/O. */
874
+ "email.queued": EmailDeliveryEvent;
875
+ /** The transport accepted the message. */
876
+ "email.sent": EmailDeliveryEvent;
877
+ /** The attempt failed or was deferred. */
878
+ "email.failed": EmailDeliveryEvent;
879
+ /** Fired after a platform operator or a plugin saves quota limits. */
880
+ "quota.updated": QuotaUpdatedEvent;
881
+ /** A website added a custom domain. It is not served until it is verified. */
882
+ "domain.added": DomainEvent;
883
+ /** DNS was verified and the certificate is in place. The domain is served. */
884
+ "domain.activated": DomainEvent;
885
+ /** An active domain failed its checks too often and is no longer served. */
886
+ "domain.failed": DomainEvent;
887
+ /** Removed by the website, or released after it stayed unverified. */
888
+ "domain.removed": DomainEvent;
889
+ }
890
+ /**
891
+ * Every core gate, mapped to its payload. Gates run *before* the operation
892
+ * commits and may cancel it. They fail closed — a handler that throws aborts
893
+ * the operation.
894
+ */
895
+ export interface GateEventMap {
896
+ "content.beforeCreate": ContentCreateGateEvent;
897
+ "content.beforeUpdate": ContentUpdateGateEvent;
898
+ "content.beforeDelete": ContentRef;
899
+ "content.beforePublish": ContentUpdateGateEvent;
900
+ "media.beforeUpload": MediaUploadGateEvent;
901
+ "media.beforeDelete": MediaRef;
902
+ /** Cancel a final, rendered delivery before it is queued or sent. */
903
+ "email.beforeSend": EmailBeforeSendEvent;
904
+ "workspace.beforeCreate": WorkspaceCreateGateEvent;
905
+ "workspace.beforeSuspend": WorkspaceStatusEvent;
906
+ "workspace.beforeReactivate": WorkspaceStatusEvent;
907
+ "workspace.beforeDelete": WorkspaceDeleteEvent;
908
+ /** Required external/plugin cleanup before permanent removal. Failures are retried. */
909
+ "workspace.beforePurge": WorkspaceStatusEvent;
910
+ "site.beforeCreate": SiteCreateGateEvent;
911
+ /** Before a website adds a custom domain. Cancel to refuse it, for example to require a paid plan. */
912
+ "domain.beforeAdd": DomainAddGateEvent;
913
+ }
914
+ /**
915
+ * Every core filter, mapped to `[value, context]`. A filter must return the
916
+ * next value; returning nothing keeps the previous value and logs a warning.
917
+ */
918
+ export interface FilterValueMap {
919
+ /**
920
+ * Ask the host to create a 32-byte operator key in the installation
921
+ * environment when it is missing. Call it with `hooks.apply`. The name must
922
+ * belong to this plugin (`justflows.example` may use `JUSTFLOWS_EXAMPLE_*`).
923
+ * An existing valid key is kept. The value is not returned and is not stored
924
+ * in the database. The host replaces `pluginId` with the plugin that called.
925
+ */
926
+ "operatorKey.ensure": [{
927
+ name: string;
928
+ }, {
929
+ pluginId: string;
930
+ }];
931
+ /** Signed-in account sections. Requires users:read; never share-cache returned data. */
932
+ "account.sections": [AccountSection[], AccountSectionContext];
933
+ /**
934
+ * Add this plugin's part in personal data requests. Requires users:read.
935
+ * Append one `PrivacyProvider` and return the list.
936
+ */
937
+ "privacy.providers": [PrivacyProvider[], PrivacyRequestContext];
938
+ /** Supply an external candidate engine; host authorization is never delegated. */
939
+ "search.backend": [SearchBackend | null, {
940
+ siteId: string;
941
+ }];
942
+ /**
943
+ * Content types included in public search. Seeded from search settings
944
+ * (`page` and `post` when unset). Plugins append their own type slugs.
945
+ */
946
+ "search.publicTypes": [string[], {
947
+ siteId: string;
948
+ }];
949
+ /** Event names administrators may subscribe to. Plugins append their names. */
950
+ "webhook.eventTypes": [string[], Record<string, never>];
951
+ /** Shape JSON-safe event data before the host builds and signs its envelope. */
952
+ "webhook.payload": [unknown, {
953
+ event: string;
954
+ siteId: string;
955
+ }];
956
+ "content.input": [Record<string, unknown>, {
957
+ siteId: string;
958
+ }];
959
+ "content.output": [Record<string, unknown>, {
960
+ siteId: string;
961
+ }];
962
+ /** Stored blocks before HTML render. Plugins fill `{{tags}}` here. */
963
+ "content.blocks": [unknown, ContentRenderContext];
964
+ "content.render": [string, ContentRenderContext];
965
+ /**
966
+ * Merge-tag values for the editor preview. Seeded with title and excerpt.
967
+ * Plugins add their own keys. Keys are the names inside `{{name}}`.
968
+ */
969
+ "content.mergeTags": [Record<string, string>, ContentRenderContext];
970
+ /**
971
+ * Block editor vs field editor for a content type. Seeded with `"blocks"` for
972
+ * `page` and `"fields"` otherwise. Plugins return `"blocks"` for types that
973
+ * use the page builder.
974
+ */
975
+ "content.editor": ["blocks" | "fields", {
976
+ siteId: string;
977
+ type: string;
978
+ }];
979
+ /**
980
+ * Title, excerpt, fields, and blocks copied when a translation is created.
981
+ * Plugins return a replacement seed.
982
+ */
983
+ "content.translationSeed": [
984
+ ContentTranslationSeed,
985
+ {
986
+ siteId: string;
987
+ sourceId: string;
988
+ locale: string;
989
+ }
990
+ ];
991
+ /**
992
+ * Content types that start from a same-named pattern. Seeded with `["post"]`.
993
+ * Plugins append their own type slugs.
994
+ */
995
+ "content.patternTypes": [string[], {
996
+ siteId: string;
997
+ }];
998
+ /**
999
+ * The rendered public comments block (`justflows.comments.thread`). The value
1000
+ * is the default HTML; return replacement HTML for full markup control, or
1001
+ * the value unchanged to keep the default. The context carries the threaded
1002
+ * comment data so a handler can render from scratch. Handlers may be async.
1003
+ * Deactivating the plugin restores the default markup.
1004
+ */
1005
+ "comments.render": [string, CommentsBlockRenderContext];
1006
+ /**
1007
+ * Optional external candidate spam-scoring service for public comment
1008
+ * submissions (Akismet-style). Seeded with `null`; the host always applies
1009
+ * its own thresholds and never requires a handler to be registered.
1010
+ */
1011
+ "comments.spamBackend": [SpamCheckBackend | null, {
1012
+ siteId: string;
1013
+ }];
1014
+ "content.revision": [ContentRevisionSnapshot, {
1015
+ siteId: string;
1016
+ contentId: string;
1017
+ }];
1018
+ "media.metadata": [Record<string, unknown>, MediaRef];
1019
+ /**
1020
+ * The placeholder shown for an empty image slot of `kind`. Seeded with the
1021
+ * plugin-registered or shipped image; return another image, or `null` to
1022
+ * leave the slot empty. Skipped when the site owner picked their own image
1023
+ * or switched placeholders off. Runs on block render, so handlers must be
1024
+ * synchronous.
1025
+ */
1026
+ "media.placeholder": [
1027
+ PlaceholderImage | null,
1028
+ PlaceholderFilterContext
1029
+ ];
1030
+ "navigation.items": [NavigationItem[], {
1031
+ siteId: string;
1032
+ location: string;
1033
+ }];
1034
+ /**
1035
+ * Menu design presets a site owner can pick beyond the built-in set, shown
1036
+ * in the menu designer's design panel. Seeded with `[]`; each handler
1037
+ * appends its presets.
1038
+ */
1039
+ "menu.design.presets": [MenuDesignPreset[], {
1040
+ siteId: string;
1041
+ }];
1042
+ /**
1043
+ * Evaluate a plugin-provided menu-item visibility condition (an item whose
1044
+ * `visibility.condition.id` the host does not recognize on its own). Seeded
1045
+ * with `false` — an unrecognized or uninstalled condition hides the item
1046
+ * (deny-by-default), never exposes it.
1047
+ */
1048
+ "menu.visibility.evaluate": [
1049
+ boolean,
1050
+ {
1051
+ item: NavigationItem;
1052
+ condition: {
1053
+ id: string;
1054
+ params?: Record<string, unknown>;
1055
+ };
1056
+ context: MenuVisibilityEvaluateContext;
1057
+ }
1058
+ ];
1059
+ /**
1060
+ * Header designs a site owner can pick beyond their own library. Seeded with
1061
+ * `[]`; each handler appends its templates. Metadata only — `build()` runs
1062
+ * later, at render time.
1063
+ */
1064
+ "header.templates": [HeaderTemplate[], {
1065
+ siteId: string;
1066
+ locale: string;
1067
+ defaultLocale: string;
1068
+ }];
1069
+ /**
1070
+ * Take over which header a page renders, before the host resolves the stored
1071
+ * ref. Return a `HeaderConfig` to own it, or `null` to let the host resolve
1072
+ * normally. Use for headers that must be computed per request.
1073
+ */
1074
+ "header.resolve": [HeaderConfig | null, HeaderResolveContext];
1075
+ /**
1076
+ * Adjust the resolved header just before render — inject a block, flip a
1077
+ * widget, swap the menu. Runs for every header, whatever its source.
1078
+ */
1079
+ "header.config": [HeaderConfig, HeaderResolveContext];
1080
+ "admin.menu": [AdminNavItem[], {
1081
+ siteId: string;
1082
+ }];
1083
+ /** Overlay plugin settings shown on Admin → Plugins → Settings. */
1084
+ "plugin.settings": [Record<string, unknown>, {
1085
+ pluginId: string;
1086
+ siteId: string;
1087
+ }];
1088
+ /**
1089
+ * Adjust a plugin's settings form for this site before Admin → Plugins →
1090
+ * Settings shows it and before a save is checked against it: drop fields,
1091
+ * or fill `options` for a `select`. A key removed here is neither shown nor
1092
+ * saved. Check `pluginId`; the filter runs for every plugin.
1093
+ */
1094
+ "plugin.settings.schema": [Record<string, PluginSettingsField>, {
1095
+ pluginId: string;
1096
+ siteId: string;
1097
+ }];
1098
+ /** Intercept a settings save so a plugin can persist domain rows and drop keys. */
1099
+ "plugin.settings.write": [Record<string, unknown>, {
1100
+ pluginId: string;
1101
+ siteId: string;
1102
+ }];
1103
+ "openapi.document": [OpenApiDocument, {
1104
+ version: string;
1105
+ }];
1106
+ /**
1107
+ * Extra tools for the MCP server and the in-admin assistant. Seeded with
1108
+ * `[]`; each handler appends its tools. Mirrors `openapi.document`.
1109
+ */
1110
+ "mcp.tools": [McpToolDefinition[], {
1111
+ siteId: string;
1112
+ }];
1113
+ "http.responseHeaders": [Record<string, string>, {
1114
+ method: string;
1115
+ path: string;
1116
+ }];
1117
+ /**
1118
+ * Extra Content-Security-Policy hosts for this response. Seeded with `{}`.
1119
+ * Append `https://` origins your plugin's public page actually loads — a
1120
+ * script, frame, image, or API call. The host drops anything else
1121
+ * (`'unsafe-inline'`, `*`, a path, `http:`). `frame-ancestors` is not
1122
+ * available here. Deactivating the plugin removes the hosts.
1123
+ */
1124
+ "security.cspSources": [CspSourceContribution, {
1125
+ siteId: string;
1126
+ area: "public" | "admin";
1127
+ }];
1128
+ /**
1129
+ * Extra markup for a public page's `<head>`. Seeded with what the host
1130
+ * already adds (favicon, KaTeX, plugin assets, PWA). The context describes
1131
+ * the page, so an SEO plugin can write meta tags from it.
1132
+ */
1133
+ "html.head": [string, PublicPageContext];
1134
+ /**
1135
+ * The page's `<title>`. Seeded with the page title. An SEO plugin applies a
1136
+ * title template or a per-page title here.
1137
+ */
1138
+ "html.title": [string, PublicPageContext];
1139
+ /**
1140
+ * The absolute URL in the page's `<link rel="canonical">`, seeded with
1141
+ * `context.canonical`. Return `""` to leave the link out. Not applied when
1142
+ * `context.indexable` is false.
1143
+ */
1144
+ "html.canonical": [string, PublicPageContext];
1145
+ /**
1146
+ * The page's hreflang links, one per active language plus `x-default`, as
1147
+ * absolute URLs built from each translation's permalink. Seeded with `[]` on
1148
+ * single-language sites and on an untranslated entry shown under another
1149
+ * language. Return `[]` to leave them all out. The host keeps only entries
1150
+ * with a valid language tag and an http(s) URL (a site-root path gets the
1151
+ * site origin), and only the first entry per language. Not applied on 404
1152
+ * pages or when the site discourages search engines.
1153
+ */
1154
+ "html.alternates": [HtmlAlternate[], PublicPageContext];
1155
+ /**
1156
+ * The site title and tagline themes show and pages fall back to, seeded from
1157
+ * the site's identity settings. An SEO plugin can supply its own per locale.
1158
+ */
1159
+ "site.identity": [{
1160
+ siteTitle: string;
1161
+ tagline: string;
1162
+ }, {
1163
+ siteId: string;
1164
+ locale: string;
1165
+ }];
1166
+ /**
1167
+ * Extra HTML inserted before `</body>` on administration screens. Seeded with
1168
+ * `""`. Handlers may be async. `locale` is the current admin UI locale;
1169
+ * `rootSite` is true on the installation's own admin while other sites exist.
1170
+ * A thrown handler is logged and the admin page still renders. Deactivating
1171
+ * the plugin removes its markup.
1172
+ */
1173
+ "admin.body": [string, {
1174
+ siteId: string;
1175
+ locale: string;
1176
+ rootSite?: boolean;
1177
+ }];
1178
+ /**
1179
+ * Tracking markup for a public page's `<head>`, seeded with `""`. A plugin
1180
+ * that adds a measurement tag appends it here with a low `priority` (below
1181
+ * the default 100). A consent plugin filters at the default priority and
1182
+ * rewrites what it finds, e.g. to `type="text/plain" data-jf-consent="analytics"`,
1183
+ * so the tag does not run until the visitor grants that category. Use a
1184
+ * same-origin script for any inline setup: the host adds no CSP hashes.
1185
+ * Runs on the sync render path, so handlers must be synchronous.
1186
+ */
1187
+ "analytics.head": [string, {
1188
+ siteId: string;
1189
+ path: string;
1190
+ gated?: boolean;
1191
+ }];
1192
+ /**
1193
+ * Whether this site gates `analytics.head`, seeded with `false`. A consent
1194
+ * plugin returns `true` when it will rewrite that markup on this site, and
1195
+ * the incoming value otherwise, so another plugin's `true` is kept.
1196
+ * The host passes the result as `gated` on `analytics.head`. A tag plugin
1197
+ * must not look up a consent plugin by id. Synchronous.
1198
+ */
1199
+ "analytics.consentGate": [boolean, {
1200
+ siteId: string;
1201
+ }];
1202
+ /**
1203
+ * Extra CSS appended to the site stylesheet served at `/theme.css`, after the
1204
+ * theme's own styles and the Customizer tokens but before the site owner's
1205
+ * Additional CSS. The value is seeded with `""` and each handler appends its
1206
+ * plugin's stylesheet. Runs once per `/theme.css` build (cached, not per
1207
+ * page), so handlers may be async — read a file, minify once, memoise.
1208
+ * Reverting is automatic: deactivating the plugin drops the handler and the
1209
+ * next `/theme.css` build omits its CSS. `preview` is true when the
1210
+ * Customizer is previewing an unpublished draft.
1211
+ */
1212
+ "theme.css": [string, {
1213
+ siteId: string;
1214
+ preview: boolean;
1215
+ }];
1216
+ /**
1217
+ * Layout targets in the theme customizer (content width and wide width).
1218
+ * Seeded with `[]`. An active plugin appends one entry per public section
1219
+ * whose width should differ from the site default. Deactivating the plugin
1220
+ * removes the entry. Core does not ship any.
1221
+ */
1222
+ "theme.layoutScopes": [ThemeLayoutScope[], {
1223
+ siteId: string;
1224
+ }];
1225
+ /**
1226
+ * Widget areas a site owner can fill from Appearance → Customize → Widgets.
1227
+ * Seeded with the core `sidebar` area plus the areas the active theme
1228
+ * declares. Append `{ key, label, ... }` to add an area of your own, with
1229
+ * optional `defaultBlocks` (shown until the owner saves the area) and
1230
+ * `defaultLayout` (content types that show the area until the owner assigns
1231
+ * them). Deactivating the plugin removes the area from the public site; the
1232
+ * owner's saved blocks are kept.
1233
+ */
1234
+ "widgets.areas": [WidgetAreaDefinition[], {
1235
+ siteId: string;
1236
+ }];
1237
+ /**
1238
+ * Default permalink bases keyed by content type. Seeded with the stored
1239
+ * bases. A plugin fills bases for its own types; stored values already in
1240
+ * the seed win. Deactivating the plugin drops the defaults.
1241
+ */
1242
+ "permalinks.typeBases": [Record<string, string>, {
1243
+ siteId: string;
1244
+ }];
1245
+ "seo.sitemapPaths": [string[], {
1246
+ siteId: string;
1247
+ }];
1248
+ /**
1249
+ * The seed URL paths the static-site exporter will crawl, before link
1250
+ * discovery. Seeded from `sitemap.xml` plus every published entry. Add paths a
1251
+ * plugin renders dynamically. A dropped seed is still crawled when a page
1252
+ * links to it; use `staticExport.exclude` to keep a path out of the export.
1253
+ */
1254
+ "staticExport.routes": [string[], {
1255
+ siteId: string;
1256
+ }];
1257
+ /**
1258
+ * The `<form action>` written into exported HTML for a dynamic endpoint that a
1259
+ * static host cannot serve. Seeded with the origin-absolute URL when
1260
+ * `STATIC_EXPORT_ORIGIN_URL` is set, else the relative default. Return a
1261
+ * serverless function URL, a third-party form endpoint, etc.
1262
+ *
1263
+ * Core only emits `"comments"`. A plugin may pass its own endpoint name.
1264
+ */
1265
+ "staticExport.formAction": [
1266
+ string,
1267
+ {
1268
+ siteId: string;
1269
+ endpoint: "comments" | (string & {});
1270
+ defaultAction: string;
1271
+ }
1272
+ ];
1273
+ /**
1274
+ * Same-origin asset URLs the static-site exporter should download, seeded with
1275
+ * everything it found by scanning `<script>`, `<link>`, `<img>`, `srcset` and
1276
+ * CSS `url()`. Append assets a plugin or custom theme loads in a way the
1277
+ * scanner cannot see — a dynamically-imported chunk, a Web Worker, a JSON
1278
+ * config fetched at runtime, a font referenced only from inline JS.
1279
+ */
1280
+ "staticExport.assets": [string[], {
1281
+ siteId: string;
1282
+ }];
1283
+ /**
1284
+ * Paths the static-site exporter must leave to the live app: per-visitor
1285
+ * pages (cart, checkout, account), pages that must always show live data,
1286
+ * or asset URLs that must not be copied. Seeded empty. Invalid entries,
1287
+ * `/`, and the core dynamic prefixes (admin, `/api`, auth pages) are ignored.
1288
+ */
1289
+ "staticExport.exclude": [StaticExportExclusion[], {
1290
+ siteId: string;
1291
+ }];
1292
+ "site.underConstruction.render": [string, UnderConstructionContext];
1293
+ /** Adjust final sender fields. The host revalidates all header values. */
1294
+ "email.sender": [EmailSender, EmailDeliveryContext];
1295
+ /** Adjust the final subject. CR/LF and oversized output are rejected. */
1296
+ "email.subject": [string, EmailDeliveryContext];
1297
+ /** Adjust final HTML. Changed output is sanitized to the supported email subset. */
1298
+ "email.html": [string, EmailDeliveryContext];
1299
+ /** Adjust final plain text. Changed output is stripped to plain text. */
1300
+ "email.text": [string, EmailDeliveryContext];
1301
+ /**
1302
+ * The site that should receive an inbound message. Seeded with the mailbox
1303
+ * owner's site id. Return `siteId` from the context when the open database
1304
+ * owns the message. Listening requires `mail:hook`.
1305
+ */
1306
+ "email.route": [string, EmailRouteContext];
1307
+ /**
1308
+ * The limit that will be enforced. Seeded with the stored value (`null` means
1309
+ * unlimited). Return a lower number to tighten it. A higher number or `null`
1310
+ * cannot raise a stored limit. Listening requires `platform:tenancy`.
1311
+ */
1312
+ "quota.effectiveLimit": [number | null, QuotaLimitContext];
1313
+ }
1314
+ /**
1315
+ * Hosts a plugin needs added to the response Content-Security-Policy.
1316
+ * Each value is a list of `https://` origins, or `https://*.example.com`.
1317
+ */
1318
+ export interface CspSourceContribution {
1319
+ "script-src"?: string[];
1320
+ "script-src-elem"?: string[];
1321
+ "style-src"?: string[];
1322
+ "img-src"?: string[];
1323
+ "font-src"?: string[];
1324
+ "connect-src"?: string[];
1325
+ "frame-src"?: string[];
1326
+ "media-src"?: string[];
1327
+ "worker-src"?: string[];
1328
+ "form-action"?: string[];
1329
+ }
1330
+ /** One customizer layout target contributed by an active plugin. */
1331
+ export interface ThemeLayoutScope {
1332
+ /** Stable id used in CSS and stored mods, such as `product`. */
1333
+ id: string;
1334
+ label: string;
1335
+ /** Public prefix without slashes, such as `product`. */
1336
+ base: string;
1337
+ /** CMS row published at `/{base}` — the parent of entries under that prefix. */
1338
+ index?: {
1339
+ type: string;
1340
+ slug: string;
1341
+ };
1342
+ }
1343
+ /** Where a widget area sits next to the page content. */
1344
+ export type WidgetAreaPosition = "left" | "right" | "top";
1345
+ /** One widget area: a named slot of blocks the site owner fills. */
1346
+ export interface WidgetAreaDefinition {
1347
+ /** Stable key, such as `sidebar` or `article-sidebar`: lowercase letters, digits, and dashes, at most 32 characters. */
1348
+ key: string;
1349
+ label: string;
1350
+ description?: string;
1351
+ /**
1352
+ * Blocks shown while the owner has never saved this area. Any registered
1353
+ * block type may be used; give widget-style blocks `category: "widgets"` so
1354
+ * they are grouped in the block library.
1355
+ */
1356
+ defaultBlocks?: unknown[];
1357
+ /** Content types that show this area until the owner assigns a layout for them. */
1358
+ defaultLayout?: {
1359
+ contentTypes: string[];
1360
+ position: WidgetAreaPosition;
1361
+ };
1362
+ }
1363
+ /** Filters applied on synchronous render paths — handlers must not be async. */
1364
+ export declare const SYNC_FILTERS: readonly ["http.responseHeaders", "html.head", "analytics.head", "analytics.consentGate", "site.underConstruction.render", "media.placeholder"];
1365
+ /** Known hook names autocomplete; plugin-namespaced names stay assignable. */
1366
+ type Loose<K extends string> = K | (string & {});
1367
+ export type ActionName = Loose<keyof ActionEventMap & string>;
1368
+ export type GateName = Loose<keyof GateEventMap & string>;
1369
+ export type FilterName = Loose<keyof FilterValueMap & string>;
1370
+ export type ActionPayload<K> = K extends keyof ActionEventMap ? ActionEventMap[K] : unknown;
1371
+ export type GatePayload<K> = K extends keyof GateEventMap ? GateEventMap[K] : object;
1372
+ export type FilterValue<K> = K extends keyof FilterValueMap ? FilterValueMap[K][0] : unknown;
1373
+ export type FilterContext<K> = K extends keyof FilterValueMap ? FilterValueMap[K][1] : unknown;
1374
+ export type ActionHandlerFor<K> = (event: ActionPayload<K>, context: HookContext) => void | Promise<void>;
1375
+ export type GateHandlerFor<K> = (event: Cancellable<GatePayload<K>>, context: HookContext) => void | Promise<void>;
1376
+ export type FilterHandlerFor<K> = (value: FilterValue<K>, context: FilterContext<K>, hookContext: HookContext) => FilterValue<K> | Promise<FilterValue<K>>;
1377
+ /**
1378
+ * Hook namespaces that require a manifest permission to listen on. Registering
1379
+ * without the permission fails at activation, not silently at runtime.
1380
+ */
1381
+ export declare const HOOK_PERMISSION_PREFIXES: readonly {
1382
+ readonly prefix: string;
1383
+ readonly permission: string;
1384
+ }[];
1385
+ /** The permission a hook name requires, or `null` when it is unrestricted. */
1386
+ export declare function requiredPermissionForHook(hook: string): string | null;
1387
+ /**
1388
+ * A plugin may only emit hooks under its own manifest ID. This keeps the core
1389
+ * namespace un-spoofable and makes hook ownership readable from the name.
1390
+ */
1391
+ export declare function isOwnedHookName(pluginId: string, hook: string): boolean;
1392
+ export {};
1393
+ //# sourceMappingURL=hooks.d.ts.map