@meith/plugin-kit 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/LICENSE.md ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@meith/plugin-kit",
3
+ "version": "0.1.0",
4
+ "description": "The SDK for writing a Meith plugin: typed manifests, hooks, routes, pages and migrations.",
5
+ "license": "LGPL-3.0-or-later",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/meith-dev/meith.git",
9
+ "directory": "packages/plugin-kit"
10
+ },
11
+ "type": "module",
12
+ "main": "./src/index.ts",
13
+ "types": "./src/index.ts",
14
+ "files": [
15
+ "src",
16
+ "!src/**/*.test.*",
17
+ "!src/**/*.type-test.*"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "@meith/theme-kit": "^0.1.0"
24
+ },
25
+ "peerDependencies": {
26
+ "react": "^19.2.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/react": "^19.2.3"
30
+ }
31
+ }
package/src/hooks.ts ADDED
@@ -0,0 +1,497 @@
1
+ /**
2
+ * The hook registry.
3
+ *
4
+ * Every point at which a plugin may observe or alter what the board does is
5
+ * named here, exactly once, with its **kind**. The registry is data for the same
6
+ * three reasons the slot registry is: a type map is derived from it, a host
7
+ * dispatches through it, and a documentation generator reads it.
8
+ *
9
+ * ## Two kinds, and the difference is the whole safety model
10
+ *
11
+ * A **filter** is handed a value and returns a replacement. Its result is used,
12
+ * so a filter that throws, hangs or returns rubbish changes what a reader sees.
13
+ * Filters are chained: each plugin receives what the previous one returned.
14
+ *
15
+ * An **event** is told that something happened and its return value is
16
+ * discarded. An event handler cannot change an outcome, which is why anything
17
+ * that merely wants to know — logging, an outbound webhook, a counter — must be
18
+ * an event and not a filter. Making it a filter would give it the power to
19
+ * corrupt the thing it only wanted to watch.
20
+ *
21
+ * The kind is declared rather than inferred because the same handler signature
22
+ * fits both, and the difference is invisible at the call site of a plugin.
23
+ *
24
+ * ## Deterministic
25
+ *
26
+ * "Typed deterministic hooks" is the acceptance criterion, and the second word
27
+ * is the harder one. Two plugins filtering the same value must compose the same
28
+ * way on every request, on every instance, in every deployment — otherwise a
29
+ * board's rendered output depends on module evaluation order, which differs
30
+ * between the dev server, a serverless bundle and the worker.
31
+ *
32
+ * So ordering is **(priority, plugin key)**, both total and both declared: never
33
+ * registration order, never the order `community.config.ts` happens to list plugins
34
+ * in, and never `Object.keys`. See `host.ts`.
35
+ *
36
+ * ## What is deliberately not here
37
+ *
38
+ * There is no hook that decides **authorization**, and there never will be one.
39
+ * `authorization.can()` is the single answer to "may this actor do this",
40
+ * and a plugin able to filter its result is a plugin able to grant itself
41
+ * anything. Plugins receive what a viewer may already see and change how it is
42
+ * presented or what happens afterwards.
43
+ *
44
+ * For the same reason there is no hook inside the visibility filter. A
45
+ * plugin that could rewrite a `where` clause is a plugin that can leak a private
46
+ * forum, and no amount of isolation makes that recoverable.
47
+ */
48
+
49
+ export type HookKind = 'filter' | 'event'
50
+
51
+ export interface HookSpec {
52
+ readonly kind: HookKind
53
+ /** What a plugin is seeing or changing. */
54
+ readonly purpose: string
55
+ }
56
+
57
+ /**
58
+ * Every hook, with its kind. `as const` so `HOOKS[K]['kind']` is a literal type
59
+ * and the handler signature can branch on it.
60
+ */
61
+ export const HOOKS = {
62
+ /* ---- Content rendering ---- */
63
+ 'markdown.parse.text': {
64
+ kind: 'filter',
65
+ purpose: 'The raw Markdown source, before it is parsed. Last chance to rewrite input.',
66
+ },
67
+ 'markdown.render.html': {
68
+ kind: 'filter',
69
+ purpose:
70
+ 'Rendered HTML, after the renderer has constructed it. Anything added here is ' +
71
+ 'trusted output and nothing escapes it afterwards.',
72
+ },
73
+ 'markdown.directives': {
74
+ kind: 'filter',
75
+ purpose:
76
+ 'The declarative directive list, so a plugin can add a `:::name` block or ' +
77
+ '`:name[…]` span without core changes.',
78
+ },
79
+ 'post.body.html': {
80
+ kind: 'filter',
81
+ purpose: 'One post’s rendered body, in the context of the thread it is being read in.',
82
+ },
83
+ 'signature.html': {
84
+ kind: 'filter',
85
+ purpose: 'A member’s rendered signature, wherever it appears.',
86
+ },
87
+ 'smilies.list': {
88
+ kind: 'filter',
89
+ purpose: 'The smilie set offered by the editor and substituted at render.',
90
+ },
91
+ 'word-filter.patterns': {
92
+ kind: 'filter',
93
+ purpose: 'The render-time word filter’s pattern list.',
94
+ },
95
+
96
+ /* ---- View models ---- */
97
+ 'view.header': {
98
+ kind: 'filter',
99
+ purpose: 'The header model, before the theme renders it.',
100
+ },
101
+ 'view.user-panel': {
102
+ kind: 'filter',
103
+ purpose: 'The user panel model: greeting, counts, account links.',
104
+ },
105
+ 'view.navigation': {
106
+ kind: 'filter',
107
+ purpose: 'The breadcrumb trail.',
108
+ },
109
+ 'view.footer': {
110
+ kind: 'filter',
111
+ purpose: 'The footer model, including its link list.',
112
+ },
113
+ 'view.forum-jump': {
114
+ kind: 'filter',
115
+ purpose:
116
+ 'The jump box model. A plugin adding a destination must give it a real ' +
117
+ 'forum id — the route re-authorises whatever is submitted.',
118
+ },
119
+ 'view.announcement': {
120
+ kind: 'filter',
121
+ purpose:
122
+ 'One announcement, on its way to the theme. Its body is already rendered ' +
123
+ 'HTML from the board\u2019s own renderer, so a plugin replacing it is ' +
124
+ 'replacing trusted markup — the one hook where that is true of a body.',
125
+ },
126
+ 'view.board-index': {
127
+ kind: 'filter',
128
+ purpose: 'The index page model.',
129
+ },
130
+ 'view.forum-row': {
131
+ kind: 'filter',
132
+ purpose: 'One forum row in a listing. Runs once per row — keep it cheap.',
133
+ },
134
+ 'view.thread-row': {
135
+ kind: 'filter',
136
+ purpose: 'One thread row in a listing. Runs once per row.',
137
+ },
138
+ 'view.post-bit': {
139
+ kind: 'filter',
140
+ purpose:
141
+ 'One post as the theme will receive it. The busiest hook on the board: it ' +
142
+ 'runs once per post on every thread page.',
143
+ },
144
+ 'view.post-actions': {
145
+ kind: 'filter',
146
+ purpose: 'The per-post control links. Adding one here does not create permission to use it.',
147
+ },
148
+ 'view.member-profile': {
149
+ kind: 'filter',
150
+ purpose: 'A member’s profile model, including its custom fields and action links.',
151
+ },
152
+ 'view.board-stats': {
153
+ kind: 'filter',
154
+ purpose: 'The board totals block.',
155
+ },
156
+ 'view.who-is-online': {
157
+ kind: 'filter',
158
+ purpose: 'The online list, already resolved against the reader.',
159
+ },
160
+ 'view.latest-threads': {
161
+ kind: 'filter',
162
+ purpose:
163
+ 'The index sidebar’s newest-threads panel. Runs again on every refresh ' +
164
+ 'of the live region, not only on the page load — keep it cheap.',
165
+ },
166
+ 'view.latest-posts': {
167
+ kind: 'filter',
168
+ purpose: 'The index sidebar’s newest-posts panel. Same refresh cost as view.latest-threads.',
169
+ },
170
+ 'view.pagination': {
171
+ kind: 'filter',
172
+ purpose: 'A resolved page-link window.',
173
+ },
174
+ 'view.search-form': {
175
+ kind: 'filter',
176
+ purpose: 'The search form model, including its filter options.',
177
+ },
178
+ 'view.error-notice': {
179
+ kind: 'filter',
180
+ purpose: 'The error page model. Runs on the page that renders when things are broken.',
181
+ },
182
+ 'view.shell': {
183
+ kind: 'filter',
184
+ purpose: 'The page frame’s model. Runs on every page including the error pages.',
185
+ },
186
+ 'view.notice': {
187
+ kind: 'filter',
188
+ purpose: 'A board notice or flash message, before the theme renders it.',
189
+ },
190
+ 'view.category-block': {
191
+ kind: 'filter',
192
+ purpose: 'One category on the index, with its rendered forum rows.',
193
+ },
194
+ 'view.subforum-list': {
195
+ kind: 'filter',
196
+ purpose: 'The compact child-forum list above a thread listing.',
197
+ },
198
+ 'view.forum-display': {
199
+ kind: 'filter',
200
+ purpose: 'A forum page’s model, including its rendered regions.',
201
+ },
202
+ 'view.thread-view': {
203
+ kind: 'filter',
204
+ purpose: 'A thread page’s model, including its rendered post list.',
205
+ },
206
+ 'view.post-form': {
207
+ kind: 'filter',
208
+ purpose: 'The composer page’s model. The form itself is app-rendered and arrives as a region.',
209
+ },
210
+ 'view.redirect-notice': {
211
+ kind: 'filter',
212
+ purpose: 'The interstitial shown after a mutation, before the meta refresh fires.',
213
+ },
214
+
215
+ /* ---- Posting ---- */
216
+ 'thread.create.validate': {
217
+ kind: 'filter',
218
+ purpose: 'Validation messages for a new thread. Returning a non-empty list refuses the post.',
219
+ },
220
+ 'thread.create.before': {
221
+ kind: 'filter',
222
+ purpose: 'The thread draft, before it is written. Subject, body, prefix, options.',
223
+ },
224
+ 'thread.created': {
225
+ kind: 'event',
226
+ purpose: 'A thread was created and committed.',
227
+ },
228
+ 'post.create.validate': {
229
+ kind: 'filter',
230
+ purpose: 'Validation messages for a reply.',
231
+ },
232
+ 'post.create.before': {
233
+ kind: 'filter',
234
+ purpose: 'The reply draft, before it is written.',
235
+ },
236
+ 'post.created': {
237
+ kind: 'event',
238
+ purpose: 'A reply was created and committed.',
239
+ },
240
+ 'post.edit.before': {
241
+ kind: 'filter',
242
+ purpose: 'An edit’s new body and reason, before the revision is written.',
243
+ },
244
+ 'post.edited': {
245
+ kind: 'event',
246
+ purpose: 'A post was edited and a revision recorded.',
247
+ },
248
+ 'post.delete.before': {
249
+ kind: 'event',
250
+ purpose: 'A post is about to be soft-deleted. Observation only: refusing is a permission.',
251
+ },
252
+ 'post.deleted': {
253
+ kind: 'event',
254
+ purpose: 'A post was soft-deleted.',
255
+ },
256
+ 'post.restored': {
257
+ kind: 'event',
258
+ purpose: 'A soft-deleted post was restored.',
259
+ },
260
+ 'thread.moved': {
261
+ kind: 'event',
262
+ purpose: 'A thread changed forum. Carries both forum ids.',
263
+ },
264
+ 'thread.merged': {
265
+ kind: 'event',
266
+ purpose: 'Two threads became one.',
267
+ },
268
+ 'thread.split': {
269
+ kind: 'event',
270
+ purpose: 'Posts were split out into a new thread.',
271
+ },
272
+ 'thread.locked': {
273
+ kind: 'event',
274
+ purpose: 'A thread was opened or closed.',
275
+ },
276
+ 'thread.stickied': {
277
+ kind: 'event',
278
+ purpose: 'A thread was pinned or unpinned.',
279
+ },
280
+ 'attachment.upload.validate': {
281
+ kind: 'filter',
282
+ purpose:
283
+ 'Validation messages for an upload, after the magic-byte check. A plugin may ' +
284
+ 'refuse a file core would accept; it can never accept one core refused.',
285
+ },
286
+ 'attachment.uploaded': {
287
+ kind: 'event',
288
+ purpose: 'A file finished uploading and re-encoding.',
289
+ },
290
+ 'attachment.deleted': {
291
+ kind: 'event',
292
+ purpose: 'An attachment was removed, by a member or by the orphan sweep.',
293
+ },
294
+ 'poll.created': {
295
+ kind: 'event',
296
+ purpose: 'A poll was attached to a thread.',
297
+ },
298
+ 'poll.voted': {
299
+ kind: 'event',
300
+ purpose: 'A vote was cast. Fires once; the database enforces one per member.',
301
+ },
302
+ 'rating.recorded': {
303
+ kind: 'event',
304
+ purpose: 'A thread rating was recorded or changed.',
305
+ },
306
+
307
+ /* ---- Moderation ---- */
308
+ 'report.created': {
309
+ kind: 'event',
310
+ purpose: 'Something was reported. The hook a notifier or a webhook wants.',
311
+ },
312
+ 'report.resolved': {
313
+ kind: 'event',
314
+ purpose: 'A report was closed, with the resolution.',
315
+ },
316
+ 'approval.queued': {
317
+ kind: 'event',
318
+ purpose: 'Content entered the approval queue.',
319
+ },
320
+ 'approval.decided': {
321
+ kind: 'event',
322
+ purpose: 'Queued content was approved or rejected.',
323
+ },
324
+ 'warning.issued': {
325
+ kind: 'event',
326
+ purpose: 'A warning was issued, with its points and expiry.',
327
+ },
328
+ 'warning.revoked': {
329
+ kind: 'event',
330
+ purpose: 'A warning was revoked or expired.',
331
+ },
332
+ 'moderation.logged': {
333
+ kind: 'event',
334
+ purpose: 'A moderation action was written to the log.',
335
+ },
336
+
337
+ /* ---- Identity ---- */
338
+ 'user.register.validate': {
339
+ kind: 'filter',
340
+ purpose:
341
+ 'Validation messages for a registration. Where a custom question or an ' +
342
+ 'external blocklist belongs.',
343
+ },
344
+ 'user.registered': {
345
+ kind: 'event',
346
+ purpose: 'An account was created, before or after activation depending on the mode.',
347
+ },
348
+ 'user.activated': {
349
+ kind: 'event',
350
+ purpose: 'An account finished activation.',
351
+ },
352
+ 'user.login.attempted': {
353
+ kind: 'event',
354
+ purpose:
355
+ 'A sign-in was attempted, with the outcome. Never carries the password or the ' +
356
+ 'session token.',
357
+ },
358
+ 'user.logged-in': {
359
+ kind: 'event',
360
+ purpose: 'A session was established.',
361
+ },
362
+ 'user.logged-out': {
363
+ kind: 'event',
364
+ purpose: 'A session was ended, by the member or by revocation.',
365
+ },
366
+ 'user.banned': {
367
+ kind: 'event',
368
+ purpose: 'A member was banned, with the expiry when there is one.',
369
+ },
370
+ 'user.unbanned': {
371
+ kind: 'event',
372
+ purpose: 'A ban was lifted or expired and the prior group restored.',
373
+ },
374
+ 'user.groups.changed': {
375
+ kind: 'event',
376
+ purpose: 'Primary or secondary group membership changed.',
377
+ },
378
+ 'user.profile.updated': {
379
+ kind: 'event',
380
+ purpose: 'A member saved profile or option changes.',
381
+ },
382
+ 'user.merged': {
383
+ kind: 'event',
384
+ purpose: 'Two accounts were merged. Carries the winner and the account that went.',
385
+ },
386
+ 'user.deleted': {
387
+ kind: 'event',
388
+ purpose: 'An account was pruned or deleted.',
389
+ },
390
+
391
+ /* ---- Mail, notifications, messages ---- */
392
+ 'notification.create.before': {
393
+ kind: 'filter',
394
+ purpose: 'A notification about to be created. Returning `null` suppresses it.',
395
+ },
396
+ 'notification.created': {
397
+ kind: 'event',
398
+ purpose: 'A notification was stored.',
399
+ },
400
+ 'mail.send.before': {
401
+ kind: 'filter',
402
+ purpose:
403
+ 'A queued message, before it is handed to the mail driver. Subject, body and ' +
404
+ 'recipient; returning `null` drops it.',
405
+ },
406
+ 'mail.sent': {
407
+ kind: 'event',
408
+ purpose: 'A message was accepted by the driver. Not proof of delivery.',
409
+ },
410
+ 'pm.send.before': {
411
+ kind: 'filter',
412
+ purpose: 'A private message, before it is stored.',
413
+ },
414
+ 'pm.sent': {
415
+ kind: 'event',
416
+ purpose: 'A private message was delivered to its recipients’ folders.',
417
+ },
418
+ 'subscription.changed': {
419
+ kind: 'event',
420
+ purpose: 'A member subscribed to or unsubscribed from a thread or forum.',
421
+ },
422
+ 'reputation.changed': {
423
+ kind: 'event',
424
+ purpose: 'Reputation was given, changed or removed.',
425
+ },
426
+
427
+ /* ---- Search, discovery, syndication ---- */
428
+ 'search.query.before': {
429
+ kind: 'filter',
430
+ purpose: 'The parsed search terms, before the query runs. The scope is not filterable.',
431
+ },
432
+ 'search.results': {
433
+ kind: 'filter',
434
+ purpose:
435
+ 'A page of results, already permission-filtered in SQL. A plugin may reorder or ' +
436
+ 'drop; adding a row here would add one the viewer may not see.',
437
+ },
438
+ 'feed.items': {
439
+ kind: 'filter',
440
+ purpose: 'The items of a feed, rendered as a guest. Anything added is public.',
441
+ },
442
+ 'sitemap.entries': {
443
+ kind: 'filter',
444
+ purpose: 'One chunk of the sitemap.',
445
+ },
446
+ 'metadata.page': {
447
+ kind: 'filter',
448
+ purpose: 'Title, description and social card for a page.',
449
+ },
450
+
451
+ /* ---- Admin and system ---- */
452
+ 'admin.navigation': {
453
+ kind: 'filter',
454
+ purpose: 'The admin panel’s section links, so a plugin page can be reached.',
455
+ },
456
+ 'settings.saved': {
457
+ kind: 'event',
458
+ purpose: 'Board settings changed. Carries the keys, never the values.',
459
+ },
460
+ 'task.run.before': {
461
+ kind: 'event',
462
+ purpose: 'A scheduled task is about to run.',
463
+ },
464
+ 'task.run.after': {
465
+ kind: 'event',
466
+ purpose: 'A scheduled task finished, with its outcome and duration.',
467
+ },
468
+ 'cache.invalidated': {
469
+ kind: 'event',
470
+ purpose: 'A cache tag was invalidated.',
471
+ },
472
+ 'plugin.enabled': {
473
+ kind: 'event',
474
+ purpose: 'A plugin was enabled — including this one, which is how it learns it is on.',
475
+ },
476
+ 'plugin.disabled': {
477
+ kind: 'event',
478
+ purpose:
479
+ 'A plugin was disabled, by an operator or by the host after repeated failures. ' +
480
+ 'Carries the reason.',
481
+ },
482
+ } as const satisfies Readonly<Record<string, HookSpec>>
483
+
484
+ /** Every hook name. Derived from the registry — never hand-written. */
485
+ export type HookName = keyof typeof HOOKS
486
+
487
+ /** The registry as an iterable list, in declaration order. */
488
+ export const HOOK_NAMES = Object.keys(HOOKS) as readonly HookName[]
489
+
490
+ /** Narrow an arbitrary string to a hook name. Used when validating a manifest. */
491
+ export function isHookName(value: string): value is HookName {
492
+ return Object.hasOwn(HOOKS, value)
493
+ }
494
+
495
+ export function hookKind(name: HookName): HookKind {
496
+ return HOOKS[name].kind
497
+ }