dineway 0.1.3
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 +9 -0
- package/README.md +89 -0
- package/dist/adapters-BlzWJG82.d.mts +106 -0
- package/dist/apply-CAPvMfoU.mjs +1339 -0
- package/dist/astro/index.d.mts +50 -0
- package/dist/astro/index.mjs +1326 -0
- package/dist/astro/middleware/auth.d.mts +30 -0
- package/dist/astro/middleware/auth.mjs +708 -0
- package/dist/astro/middleware/redirect.d.mts +21 -0
- package/dist/astro/middleware/redirect.mjs +62 -0
- package/dist/astro/middleware/request-context.d.mts +17 -0
- package/dist/astro/middleware/request-context.mjs +1371 -0
- package/dist/astro/middleware/setup.d.mts +19 -0
- package/dist/astro/middleware/setup.mjs +46 -0
- package/dist/astro/middleware.d.mts +12 -0
- package/dist/astro/middleware.mjs +1716 -0
- package/dist/astro/types.d.mts +269 -0
- package/dist/astro/types.mjs +1 -0
- package/dist/base64-F8-DUraK.mjs +58 -0
- package/dist/byline-DeWCMU_i.mjs +234 -0
- package/dist/bylines-DyqBV9EQ.mjs +137 -0
- package/dist/chunk-ClPoSABd.mjs +21 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +3987 -0
- package/dist/client/external-auth-headers.d.mts +38 -0
- package/dist/client/external-auth-headers.mjs +101 -0
- package/dist/client/index.d.mts +397 -0
- package/dist/client/index.mjs +345 -0
- package/dist/config-Cq8H0SfX.mjs +46 -0
- package/dist/connection-C9pxzuag.mjs +52 -0
- package/dist/content-zSgdNmnt.mjs +836 -0
- package/dist/db/index.d.mts +4 -0
- package/dist/db/index.mjs +62 -0
- package/dist/db/libsql.d.mts +10 -0
- package/dist/db/libsql.mjs +21 -0
- package/dist/db/postgres.d.mts +10 -0
- package/dist/db/postgres.mjs +29 -0
- package/dist/db/sqlite.d.mts +10 -0
- package/dist/db/sqlite.mjs +15 -0
- package/dist/default-WYlzADZL.mjs +80 -0
- package/dist/dialect-helpers-B9uSp2GJ.mjs +89 -0
- package/dist/error-DrxtnGPg.mjs +26 -0
- package/dist/index-C-jx21qs.d.mts +4771 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.mjs +30 -0
- package/dist/load-C6FCD1FU.mjs +27 -0
- package/dist/loader-qKmo0wAY.mjs +446 -0
- package/dist/manifest-schema-CTSEyIJ3.mjs +186 -0
- package/dist/media/index.d.mts +25 -0
- package/dist/media/index.mjs +54 -0
- package/dist/media/local-runtime.d.mts +38 -0
- package/dist/media/local-runtime.mjs +132 -0
- package/dist/media-DMTr80Gv.mjs +199 -0
- package/dist/mode-BlyYtIFO.mjs +22 -0
- package/dist/page/index.d.mts +148 -0
- package/dist/page/index.mjs +419 -0
- package/dist/placeholder-B3knXwNc.mjs +267 -0
- package/dist/placeholder-bOx1xCTY.d.mts +283 -0
- package/dist/plugin-utils.d.mts +57 -0
- package/dist/plugin-utils.mjs +77 -0
- package/dist/plugins/adapt-sandbox-entry.d.mts +21 -0
- package/dist/plugins/adapt-sandbox-entry.mjs +112 -0
- package/dist/query-BiaPl_g2.mjs +459 -0
- package/dist/redirect-JPqLAbxa.mjs +328 -0
- package/dist/registry-DSd1GWB8.mjs +851 -0
- package/dist/request-context.d.mts +49 -0
- package/dist/request-context.mjs +42 -0
- package/dist/runner-B5l1JfOj.d.mts +26 -0
- package/dist/runner-BGUGywgG.mjs +1529 -0
- package/dist/runtime.d.mts +25 -0
- package/dist/runtime.mjs +41 -0
- package/dist/search-BNruJHDL.mjs +11054 -0
- package/dist/seed/index.d.mts +3 -0
- package/dist/seed/index.mjs +15 -0
- package/dist/seo/index.d.mts +69 -0
- package/dist/seo/index.mjs +69 -0
- package/dist/storage/local.d.mts +38 -0
- package/dist/storage/local.mjs +165 -0
- package/dist/storage/s3.d.mts +31 -0
- package/dist/storage/s3.mjs +174 -0
- package/dist/tokens-4vgYuXsZ.mjs +170 -0
- package/dist/transport-C5FYnid7.mjs +417 -0
- package/dist/transport-gIL-e43D.d.mts +41 -0
- package/dist/types-BawVha09.mjs +30 -0
- package/dist/types-BgQeVaPj.d.mts +192 -0
- package/dist/types-CLLdsG3g.d.mts +103 -0
- package/dist/types-D38djUXv.d.mts +1196 -0
- package/dist/types-DShnjzb6.mjs +15 -0
- package/dist/types-DkvMXalq.d.mts +425 -0
- package/dist/types-DuNbGKjF.mjs +74 -0
- package/dist/types-ju-_ORz7.d.mts +182 -0
- package/dist/validate-CXnRKfJK.mjs +327 -0
- package/dist/validate-CqRJb_xU.mjs +96 -0
- package/dist/validate-DVKJJ-M_.d.mts +377 -0
- package/locals.d.ts +47 -0
- package/package.json +313 -0
|
@@ -0,0 +1,1196 @@
|
|
|
1
|
+
import { u as FieldType } from "./types-BgQeVaPj.mjs";
|
|
2
|
+
import { z } from "astro/zod";
|
|
3
|
+
import { JSX } from "astro/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region ../blocks/dist/validation-BG2u9jAE.d.ts
|
|
6
|
+
//#region src/types.d.ts
|
|
7
|
+
interface ConfirmDialog {
|
|
8
|
+
title: string;
|
|
9
|
+
text: string;
|
|
10
|
+
confirm: string;
|
|
11
|
+
deny: string;
|
|
12
|
+
style?: "danger";
|
|
13
|
+
}
|
|
14
|
+
interface ButtonElement {
|
|
15
|
+
type: "button";
|
|
16
|
+
action_id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
style?: "primary" | "danger" | "secondary";
|
|
19
|
+
value?: unknown;
|
|
20
|
+
confirm?: ConfirmDialog;
|
|
21
|
+
}
|
|
22
|
+
interface TextInputElement {
|
|
23
|
+
type: "text_input";
|
|
24
|
+
action_id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
initial_value?: string;
|
|
28
|
+
multiline?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface NumberInputElement {
|
|
31
|
+
type: "number_input";
|
|
32
|
+
action_id: string;
|
|
33
|
+
label: string;
|
|
34
|
+
initial_value?: number;
|
|
35
|
+
min?: number;
|
|
36
|
+
max?: number;
|
|
37
|
+
}
|
|
38
|
+
interface SelectElement {
|
|
39
|
+
type: "select";
|
|
40
|
+
action_id: string;
|
|
41
|
+
label: string;
|
|
42
|
+
options: Array<{
|
|
43
|
+
label: string;
|
|
44
|
+
value: string;
|
|
45
|
+
}>;
|
|
46
|
+
initial_value?: string;
|
|
47
|
+
/** Plugin route that returns `{ items: Array<{ id, name }> }` to populate options dynamically */
|
|
48
|
+
optionsRoute?: string;
|
|
49
|
+
}
|
|
50
|
+
interface ToggleElement {
|
|
51
|
+
type: "toggle";
|
|
52
|
+
action_id: string;
|
|
53
|
+
label: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
initial_value?: boolean;
|
|
56
|
+
}
|
|
57
|
+
interface SecretInputElement {
|
|
58
|
+
type: "secret_input";
|
|
59
|
+
action_id: string;
|
|
60
|
+
label: string;
|
|
61
|
+
placeholder?: string;
|
|
62
|
+
has_value?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface CheckboxElement {
|
|
65
|
+
type: "checkbox";
|
|
66
|
+
action_id: string;
|
|
67
|
+
label: string;
|
|
68
|
+
options: Array<{
|
|
69
|
+
label: string;
|
|
70
|
+
value: string;
|
|
71
|
+
}>;
|
|
72
|
+
initial_value?: string[];
|
|
73
|
+
}
|
|
74
|
+
interface DateInputElement {
|
|
75
|
+
type: "date_input";
|
|
76
|
+
action_id: string;
|
|
77
|
+
label: string;
|
|
78
|
+
initial_value?: string;
|
|
79
|
+
placeholder?: string;
|
|
80
|
+
}
|
|
81
|
+
interface ComboboxElement {
|
|
82
|
+
type: "combobox";
|
|
83
|
+
action_id: string;
|
|
84
|
+
label: string;
|
|
85
|
+
options: Array<{
|
|
86
|
+
label: string;
|
|
87
|
+
value: string;
|
|
88
|
+
}>;
|
|
89
|
+
initial_value?: string;
|
|
90
|
+
placeholder?: string;
|
|
91
|
+
}
|
|
92
|
+
interface RadioElement {
|
|
93
|
+
type: "radio";
|
|
94
|
+
action_id: string;
|
|
95
|
+
label: string;
|
|
96
|
+
options: Array<{
|
|
97
|
+
label: string;
|
|
98
|
+
value: string;
|
|
99
|
+
}>;
|
|
100
|
+
initial_value?: string;
|
|
101
|
+
}
|
|
102
|
+
type Element = ButtonElement | TextInputElement | NumberInputElement | SelectElement | ToggleElement | SecretInputElement | CheckboxElement | DateInputElement | ComboboxElement | RadioElement;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/plugins/types.d.ts
|
|
105
|
+
/**
|
|
106
|
+
* Plugin capabilities determine what APIs are available in context
|
|
107
|
+
*/
|
|
108
|
+
type PluginCapability = "network:fetch" | "network:fetch:any" | "read:content" | "write:content" | "read:media" | "write:media" | "read:users" | "email:send" | "email:provide" | "email:intercept" | "page:inject";
|
|
109
|
+
/**
|
|
110
|
+
* Storage collection declaration in plugin definition
|
|
111
|
+
*/
|
|
112
|
+
interface StorageCollectionConfig {
|
|
113
|
+
/**
|
|
114
|
+
* Fields to index for querying.
|
|
115
|
+
* Each entry can be a single field name or an array for composite indexes.
|
|
116
|
+
*/
|
|
117
|
+
indexes: Array<string | string[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Fields with unique constraints.
|
|
120
|
+
* Each entry can be a single field name or an array for composite unique indexes.
|
|
121
|
+
* Unique indexes are also queryable (no need to duplicate in `indexes`).
|
|
122
|
+
*/
|
|
123
|
+
uniqueIndexes?: Array<string | string[]>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Plugin storage configuration
|
|
127
|
+
*/
|
|
128
|
+
type PluginStorageConfig = Record<string, StorageCollectionConfig>;
|
|
129
|
+
/**
|
|
130
|
+
* Query filter operators
|
|
131
|
+
*/
|
|
132
|
+
interface RangeFilter {
|
|
133
|
+
gt?: number | string;
|
|
134
|
+
gte?: number | string;
|
|
135
|
+
lt?: number | string;
|
|
136
|
+
lte?: number | string;
|
|
137
|
+
}
|
|
138
|
+
interface InFilter {
|
|
139
|
+
in: Array<string | number>;
|
|
140
|
+
}
|
|
141
|
+
interface StartsWithFilter {
|
|
142
|
+
startsWith: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Where clause value types
|
|
146
|
+
*/
|
|
147
|
+
type WhereValue = string | number | boolean | null | RangeFilter | InFilter | StartsWithFilter;
|
|
148
|
+
/**
|
|
149
|
+
* Where clause for storage queries
|
|
150
|
+
*/
|
|
151
|
+
type WhereClause = Record<string, WhereValue>;
|
|
152
|
+
/**
|
|
153
|
+
* Query options for storage.query()
|
|
154
|
+
*/
|
|
155
|
+
interface QueryOptions {
|
|
156
|
+
where?: WhereClause;
|
|
157
|
+
orderBy?: Record<string, "asc" | "desc">;
|
|
158
|
+
limit?: number;
|
|
159
|
+
cursor?: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Paginated result (used by storage.query, content.list, media.list)
|
|
163
|
+
*/
|
|
164
|
+
interface PaginatedResult<T> {
|
|
165
|
+
items: T[];
|
|
166
|
+
cursor?: string;
|
|
167
|
+
hasMore: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Storage collection interface - the API exposed to plugins
|
|
171
|
+
* No async iterators - all operations return promises with pagination
|
|
172
|
+
*/
|
|
173
|
+
interface StorageCollection<T = unknown> {
|
|
174
|
+
get(id: string): Promise<T | null>;
|
|
175
|
+
put(id: string, data: T): Promise<void>;
|
|
176
|
+
delete(id: string): Promise<boolean>;
|
|
177
|
+
exists(id: string): Promise<boolean>;
|
|
178
|
+
getMany(ids: string[]): Promise<Map<string, T>>;
|
|
179
|
+
putMany(items: Array<{
|
|
180
|
+
id: string;
|
|
181
|
+
data: T;
|
|
182
|
+
}>): Promise<void>;
|
|
183
|
+
deleteMany(ids: string[]): Promise<number>;
|
|
184
|
+
query(options?: QueryOptions): Promise<PaginatedResult<{
|
|
185
|
+
id: string;
|
|
186
|
+
data: T;
|
|
187
|
+
}>>;
|
|
188
|
+
count(where?: WhereClause): Promise<number>;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Plugin storage context - typed based on declared collections
|
|
192
|
+
*/
|
|
193
|
+
type PluginStorage<T extends PluginStorageConfig> = { [K in keyof T]: StorageCollection };
|
|
194
|
+
/**
|
|
195
|
+
* KV store interface - unified replacement for settings + options
|
|
196
|
+
*
|
|
197
|
+
* Convention:
|
|
198
|
+
* - `settings:*` - User-configurable preferences (shown in admin UI)
|
|
199
|
+
* - `state:*` - Internal plugin state (not shown to users)
|
|
200
|
+
*/
|
|
201
|
+
interface KVAccess {
|
|
202
|
+
get<T>(key: string): Promise<T | null>;
|
|
203
|
+
set(key: string, value: unknown): Promise<void>;
|
|
204
|
+
delete(key: string): Promise<boolean>;
|
|
205
|
+
list(prefix?: string): Promise<Array<{
|
|
206
|
+
key: string;
|
|
207
|
+
value: unknown;
|
|
208
|
+
}>>;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* SEO metadata for a content item, as stored in the core SEO panel.
|
|
212
|
+
*
|
|
213
|
+
* Only present on items in collections with `has_seo = 1`. For collections
|
|
214
|
+
* without SEO enabled, `ContentItem.seo` is `undefined`.
|
|
215
|
+
*/
|
|
216
|
+
interface ContentItemSeo {
|
|
217
|
+
title: string | null;
|
|
218
|
+
description: string | null;
|
|
219
|
+
image: string | null;
|
|
220
|
+
canonical: string | null;
|
|
221
|
+
noIndex: boolean;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* SEO input accepted by content write operations.
|
|
225
|
+
*
|
|
226
|
+
* All fields are optional — only fields that are present overwrite existing
|
|
227
|
+
* values. An empty object is treated as a no-op.
|
|
228
|
+
*/
|
|
229
|
+
interface ContentItemSeoInput {
|
|
230
|
+
title?: string | null;
|
|
231
|
+
description?: string | null;
|
|
232
|
+
image?: string | null;
|
|
233
|
+
canonical?: string | null;
|
|
234
|
+
noIndex?: boolean;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Content item returned from content API
|
|
238
|
+
*/
|
|
239
|
+
interface ContentItem {
|
|
240
|
+
id: string;
|
|
241
|
+
type: string;
|
|
242
|
+
data: Record<string, unknown>;
|
|
243
|
+
/**
|
|
244
|
+
* SEO metadata, populated when the collection has SEO enabled
|
|
245
|
+
* (`has_seo = 1`). `undefined` for non-SEO collections.
|
|
246
|
+
*/
|
|
247
|
+
seo?: ContentItemSeo;
|
|
248
|
+
createdAt: string;
|
|
249
|
+
updatedAt: string;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Content list options
|
|
253
|
+
*/
|
|
254
|
+
interface ContentListOptions {
|
|
255
|
+
limit?: number;
|
|
256
|
+
cursor?: string;
|
|
257
|
+
orderBy?: Record<string, "asc" | "desc">;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Input accepted by `content.create` / `content.update`.
|
|
261
|
+
*
|
|
262
|
+
* Most entries are field slugs mapped to their values. The reserved `seo`
|
|
263
|
+
* key is extracted and routed to the core SEO panel (the `_dineway_seo`
|
|
264
|
+
* table), matching the shape accepted by the REST API. Passing `seo` for a
|
|
265
|
+
* collection that does not have SEO enabled throws a validation error.
|
|
266
|
+
*/
|
|
267
|
+
type ContentWriteInput = Record<string, unknown> & {
|
|
268
|
+
seo?: ContentItemSeoInput;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Content access interface - capability-gated
|
|
272
|
+
*/
|
|
273
|
+
interface ContentAccess {
|
|
274
|
+
get(collection: string, id: string): Promise<ContentItem | null>;
|
|
275
|
+
list(collection: string, options?: ContentListOptions): Promise<PaginatedResult<ContentItem>>;
|
|
276
|
+
create?(collection: string, data: ContentWriteInput): Promise<ContentItem>;
|
|
277
|
+
update?(collection: string, id: string, data: ContentWriteInput): Promise<ContentItem>;
|
|
278
|
+
delete?(collection: string, id: string): Promise<boolean>;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Full content access with write operations
|
|
282
|
+
*/
|
|
283
|
+
interface ContentAccessWithWrite extends ContentAccess {
|
|
284
|
+
create(collection: string, data: ContentWriteInput): Promise<ContentItem>;
|
|
285
|
+
update(collection: string, id: string, data: ContentWriteInput): Promise<ContentItem>;
|
|
286
|
+
delete(collection: string, id: string): Promise<boolean>;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Media item returned from media API
|
|
290
|
+
*/
|
|
291
|
+
interface MediaItem {
|
|
292
|
+
id: string;
|
|
293
|
+
filename: string;
|
|
294
|
+
mimeType: string;
|
|
295
|
+
size: number | null;
|
|
296
|
+
url: string;
|
|
297
|
+
createdAt: string;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Media list options
|
|
301
|
+
*/
|
|
302
|
+
interface MediaListOptions {
|
|
303
|
+
limit?: number;
|
|
304
|
+
cursor?: string;
|
|
305
|
+
mimeType?: string;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Media access interface - capability-gated
|
|
309
|
+
*/
|
|
310
|
+
interface MediaAccess {
|
|
311
|
+
get(id: string): Promise<MediaItem | null>;
|
|
312
|
+
list(options?: MediaListOptions): Promise<PaginatedResult<MediaItem>>;
|
|
313
|
+
getUploadUrl?(filename: string, contentType: string): Promise<{
|
|
314
|
+
uploadUrl: string;
|
|
315
|
+
mediaId: string;
|
|
316
|
+
}>;
|
|
317
|
+
/**
|
|
318
|
+
* Upload media bytes directly. Preferred in sandboxed mode where
|
|
319
|
+
* plugins cannot make external requests to a presigned URL.
|
|
320
|
+
* Returns the created media item.
|
|
321
|
+
*/
|
|
322
|
+
upload?(filename: string, contentType: string, bytes: ArrayBuffer): Promise<{
|
|
323
|
+
mediaId: string;
|
|
324
|
+
storageKey: string;
|
|
325
|
+
url: string;
|
|
326
|
+
}>;
|
|
327
|
+
delete?(id: string): Promise<boolean>;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Full media access with write operations
|
|
331
|
+
*/
|
|
332
|
+
interface MediaAccessWithWrite extends MediaAccess {
|
|
333
|
+
getUploadUrl(filename: string, contentType: string): Promise<{
|
|
334
|
+
uploadUrl: string;
|
|
335
|
+
mediaId: string;
|
|
336
|
+
}>;
|
|
337
|
+
upload(filename: string, contentType: string, bytes: ArrayBuffer): Promise<{
|
|
338
|
+
mediaId: string;
|
|
339
|
+
storageKey: string;
|
|
340
|
+
url: string;
|
|
341
|
+
}>;
|
|
342
|
+
delete(id: string): Promise<boolean>;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* HTTP client interface - requires network:fetch capability
|
|
346
|
+
*/
|
|
347
|
+
interface HttpAccess {
|
|
348
|
+
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Logger interface - always available
|
|
352
|
+
*/
|
|
353
|
+
interface LogAccess {
|
|
354
|
+
debug(message: string, data?: unknown): void;
|
|
355
|
+
info(message: string, data?: unknown): void;
|
|
356
|
+
warn(message: string, data?: unknown): void;
|
|
357
|
+
error(message: string, data?: unknown): void;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Site information available to all plugins
|
|
361
|
+
*/
|
|
362
|
+
interface SiteInfo {
|
|
363
|
+
/** Site name (from settings) */
|
|
364
|
+
name: string;
|
|
365
|
+
/** Site URL (from settings or request) */
|
|
366
|
+
url: string;
|
|
367
|
+
/** Site locale (from settings, defaults to "en") */
|
|
368
|
+
locale: string;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Read-only user information exposed to plugins.
|
|
372
|
+
* Sensitive fields (password hashes, sessions, passkeys) are excluded.
|
|
373
|
+
*/
|
|
374
|
+
interface UserInfo {
|
|
375
|
+
id: string;
|
|
376
|
+
email: string;
|
|
377
|
+
name: string | null;
|
|
378
|
+
role: number;
|
|
379
|
+
createdAt: string;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* User access interface - requires read:users capability
|
|
383
|
+
*/
|
|
384
|
+
interface UserAccess {
|
|
385
|
+
/** Get a user by ID */
|
|
386
|
+
get(id: string): Promise<UserInfo | null>;
|
|
387
|
+
/** Get a user by email */
|
|
388
|
+
getByEmail(email: string): Promise<UserInfo | null>;
|
|
389
|
+
/** List users with optional filters */
|
|
390
|
+
list(opts?: {
|
|
391
|
+
role?: number;
|
|
392
|
+
limit?: number;
|
|
393
|
+
cursor?: string;
|
|
394
|
+
}): Promise<{
|
|
395
|
+
items: UserInfo[];
|
|
396
|
+
nextCursor?: string;
|
|
397
|
+
}>;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* The unified plugin context - same shape for all hooks and routes
|
|
401
|
+
*/
|
|
402
|
+
interface PluginContext<TStorage extends PluginStorageConfig = PluginStorageConfig> {
|
|
403
|
+
/** Plugin metadata */
|
|
404
|
+
plugin: {
|
|
405
|
+
id: string;
|
|
406
|
+
version: string;
|
|
407
|
+
};
|
|
408
|
+
/** Storage collections - only if plugin declares storage */
|
|
409
|
+
storage: PluginStorage<TStorage>;
|
|
410
|
+
/** Key-value store for config and state */
|
|
411
|
+
kv: KVAccess;
|
|
412
|
+
/** Content access - only if read:content or write:content capability */
|
|
413
|
+
content?: ContentAccess | ContentAccessWithWrite;
|
|
414
|
+
/** Media access - only if read:media or write:media capability */
|
|
415
|
+
media?: MediaAccess | MediaAccessWithWrite;
|
|
416
|
+
/** HTTP client - only if network:fetch capability */
|
|
417
|
+
http?: HttpAccess;
|
|
418
|
+
/** Logger - always available */
|
|
419
|
+
log: LogAccess;
|
|
420
|
+
/** Site information - always available */
|
|
421
|
+
site: SiteInfo;
|
|
422
|
+
/** URL helper - generates absolute URLs from paths. Always available. */
|
|
423
|
+
url(path: string): string;
|
|
424
|
+
/** User access - only if read:users capability */
|
|
425
|
+
users?: UserAccess;
|
|
426
|
+
/** Cron task scheduling - always available, scoped to plugin */
|
|
427
|
+
cron?: CronAccess;
|
|
428
|
+
/** Email access - only if email:send capability and a provider is configured */
|
|
429
|
+
email?: EmailAccess;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Cron access interface �� always available on plugin context, scoped to plugin.
|
|
433
|
+
*/
|
|
434
|
+
interface CronAccess {
|
|
435
|
+
/** Schedule a recurring or one-shot task */
|
|
436
|
+
schedule(name: string, opts: {
|
|
437
|
+
schedule: string;
|
|
438
|
+
data?: Record<string, unknown>;
|
|
439
|
+
}): Promise<void>;
|
|
440
|
+
/** Cancel a scheduled task */
|
|
441
|
+
cancel(name: string): Promise<void>;
|
|
442
|
+
/** List this plugin's scheduled tasks */
|
|
443
|
+
list(): Promise<CronTaskInfo[]>;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Task info returned from CronAccess.list()
|
|
447
|
+
*/
|
|
448
|
+
interface CronTaskInfo {
|
|
449
|
+
name: string;
|
|
450
|
+
schedule: string;
|
|
451
|
+
nextRunAt: string;
|
|
452
|
+
lastRunAt: string | null;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Event passed to the `cron` hook handler
|
|
456
|
+
*/
|
|
457
|
+
interface CronEvent {
|
|
458
|
+
name: string;
|
|
459
|
+
data?: Record<string, unknown>;
|
|
460
|
+
scheduledAt: string;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Cron hook handler type
|
|
464
|
+
*/
|
|
465
|
+
type CronHandler = (event: CronEvent, ctx: PluginContext) => Promise<void>;
|
|
466
|
+
/**
|
|
467
|
+
* Email access interface — requires `email:send` capability.
|
|
468
|
+
* Undefined when no `email:deliver` provider is configured.
|
|
469
|
+
*
|
|
470
|
+
* Related capabilities:
|
|
471
|
+
* - `email:send` — grants ctx.email (this interface)
|
|
472
|
+
* - `email:provide` — allows registering the `email:deliver` exclusive hook
|
|
473
|
+
* - `email:intercept` — allows registering `email:beforeSend` / `email:afterSend` hooks
|
|
474
|
+
*/
|
|
475
|
+
interface EmailAccess {
|
|
476
|
+
send(message: EmailMessage): Promise<void>;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Email message shape
|
|
480
|
+
*/
|
|
481
|
+
interface EmailMessage {
|
|
482
|
+
to: string;
|
|
483
|
+
subject: string;
|
|
484
|
+
text: string;
|
|
485
|
+
html?: string;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Event passed to email:beforeSend hooks (middleware — transform, validate, cancel)
|
|
489
|
+
*/
|
|
490
|
+
interface EmailBeforeSendEvent {
|
|
491
|
+
message: EmailMessage;
|
|
492
|
+
/** Where the email originated — "system" for auth emails, plugin ID for plugin emails */
|
|
493
|
+
source: string;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Event passed to email:deliver hook (exclusive — exactly one provider delivers)
|
|
497
|
+
*/
|
|
498
|
+
interface EmailDeliverEvent {
|
|
499
|
+
message: EmailMessage;
|
|
500
|
+
source: string;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Event passed to email:afterSend hooks (logging, analytics, fire-and-forget)
|
|
504
|
+
*/
|
|
505
|
+
interface EmailAfterSendEvent {
|
|
506
|
+
message: EmailMessage;
|
|
507
|
+
source: string;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Handler type for email:beforeSend hooks.
|
|
511
|
+
* Returns modified message, or false to cancel delivery.
|
|
512
|
+
*/
|
|
513
|
+
type EmailBeforeSendHandler = (event: EmailBeforeSendEvent, ctx: PluginContext) => Promise<EmailMessage | false>;
|
|
514
|
+
/**
|
|
515
|
+
* Handler type for email:deliver hooks (exclusive provider).
|
|
516
|
+
*/
|
|
517
|
+
type EmailDeliverHandler = (event: EmailDeliverEvent, ctx: PluginContext) => Promise<void>;
|
|
518
|
+
/**
|
|
519
|
+
* Handler type for email:afterSend hooks (fire-and-forget).
|
|
520
|
+
*/
|
|
521
|
+
type EmailAfterSendHandler = (event: EmailAfterSendEvent, ctx: PluginContext) => Promise<void>;
|
|
522
|
+
/**
|
|
523
|
+
* Collection comment settings (read from _dineway_collections)
|
|
524
|
+
*/
|
|
525
|
+
interface CollectionCommentSettings {
|
|
526
|
+
commentsEnabled: boolean;
|
|
527
|
+
commentsModeration: "all" | "first_time" | "none";
|
|
528
|
+
commentsClosedAfterDays: number;
|
|
529
|
+
commentsAutoApproveUsers: boolean;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Event passed to comment:beforeCreate hooks (middleware — transform, enrich, reject)
|
|
533
|
+
*/
|
|
534
|
+
interface CommentBeforeCreateEvent {
|
|
535
|
+
comment: {
|
|
536
|
+
collection: string;
|
|
537
|
+
contentId: string;
|
|
538
|
+
parentId: string | null;
|
|
539
|
+
authorName: string;
|
|
540
|
+
authorEmail: string;
|
|
541
|
+
authorUserId: string | null;
|
|
542
|
+
body: string;
|
|
543
|
+
ipHash: string | null;
|
|
544
|
+
userAgent: string | null;
|
|
545
|
+
};
|
|
546
|
+
/** Metadata bag — plugins can attach signals for the moderator */
|
|
547
|
+
metadata: Record<string, unknown>;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Event passed to comment:moderate hook (exclusive — decides initial status)
|
|
551
|
+
*/
|
|
552
|
+
interface CommentModerateEvent {
|
|
553
|
+
comment: CommentBeforeCreateEvent["comment"];
|
|
554
|
+
metadata: Record<string, unknown>;
|
|
555
|
+
collectionSettings: CollectionCommentSettings;
|
|
556
|
+
/** Number of prior approved comments from this email address */
|
|
557
|
+
priorApprovedCount: number;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Moderation decision returned by the comment:moderate handler
|
|
561
|
+
*/
|
|
562
|
+
interface ModerationDecision {
|
|
563
|
+
status: "approved" | "pending" | "spam";
|
|
564
|
+
/** Optional reason for admin visibility */
|
|
565
|
+
reason?: string;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Stored comment shape (full record with id, status, timestamps)
|
|
569
|
+
*/
|
|
570
|
+
interface StoredComment {
|
|
571
|
+
id: string;
|
|
572
|
+
collection: string;
|
|
573
|
+
contentId: string;
|
|
574
|
+
parentId: string | null;
|
|
575
|
+
authorName: string;
|
|
576
|
+
authorEmail: string;
|
|
577
|
+
authorUserId: string | null;
|
|
578
|
+
body: string;
|
|
579
|
+
status: string;
|
|
580
|
+
moderationMetadata: Record<string, unknown> | null;
|
|
581
|
+
createdAt: string;
|
|
582
|
+
updatedAt: string;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Event passed to comment:afterCreate hooks (fire-and-forget)
|
|
586
|
+
*/
|
|
587
|
+
interface CommentAfterCreateEvent {
|
|
588
|
+
comment: StoredComment;
|
|
589
|
+
metadata: Record<string, unknown>;
|
|
590
|
+
/** The content item the comment is on */
|
|
591
|
+
content: {
|
|
592
|
+
id: string;
|
|
593
|
+
collection: string;
|
|
594
|
+
slug: string;
|
|
595
|
+
title?: string;
|
|
596
|
+
};
|
|
597
|
+
/** The content author (for notifications) */
|
|
598
|
+
contentAuthor?: {
|
|
599
|
+
id: string;
|
|
600
|
+
name: string | null;
|
|
601
|
+
email: string;
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Event passed to comment:afterModerate hooks (fire-and-forget, admin status change)
|
|
606
|
+
*/
|
|
607
|
+
interface CommentAfterModerateEvent {
|
|
608
|
+
comment: StoredComment;
|
|
609
|
+
previousStatus: string;
|
|
610
|
+
newStatus: string;
|
|
611
|
+
/** The admin who moderated */
|
|
612
|
+
moderator: {
|
|
613
|
+
id: string;
|
|
614
|
+
name: string | null;
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Handler type for comment:beforeCreate hooks.
|
|
619
|
+
* Returns modified event, or false to reject the comment.
|
|
620
|
+
*/
|
|
621
|
+
type CommentBeforeCreateHandler = (event: CommentBeforeCreateEvent, ctx: PluginContext) => Promise<CommentBeforeCreateEvent | false | void>;
|
|
622
|
+
/**
|
|
623
|
+
* Handler type for comment:moderate hook (exclusive provider).
|
|
624
|
+
*/
|
|
625
|
+
type CommentModerateHandler = (event: CommentModerateEvent, ctx: PluginContext) => Promise<ModerationDecision>;
|
|
626
|
+
/**
|
|
627
|
+
* Handler type for comment:afterCreate hooks (fire-and-forget).
|
|
628
|
+
*/
|
|
629
|
+
type CommentAfterCreateHandler = (event: CommentAfterCreateEvent, ctx: PluginContext) => Promise<void>;
|
|
630
|
+
/**
|
|
631
|
+
* Handler type for comment:afterModerate hooks (fire-and-forget).
|
|
632
|
+
*/
|
|
633
|
+
type CommentAfterModerateHandler = (event: CommentAfterModerateEvent, ctx: PluginContext) => Promise<void>;
|
|
634
|
+
/**
|
|
635
|
+
* Hook configuration
|
|
636
|
+
*/
|
|
637
|
+
interface HookConfig<THandler> {
|
|
638
|
+
/** Explicit ordering - lower numbers run first (default: 100) */
|
|
639
|
+
priority?: number;
|
|
640
|
+
/** Max execution time in ms (default: 5000) */
|
|
641
|
+
timeout?: number;
|
|
642
|
+
/** Run after these plugins */
|
|
643
|
+
dependencies?: string[];
|
|
644
|
+
/** Error handling policy */
|
|
645
|
+
errorPolicy?: "continue" | "abort";
|
|
646
|
+
/**
|
|
647
|
+
* Mark this hook as exclusive — only one plugin can be the active provider.
|
|
648
|
+
* Exclusive hooks skip the priority pipeline and dispatch only to the
|
|
649
|
+
* admin-selected provider. Used for email:deliver, search, image optimization, etc.
|
|
650
|
+
*/
|
|
651
|
+
exclusive?: boolean;
|
|
652
|
+
/** The hook handler */
|
|
653
|
+
handler: THandler;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Content hook event
|
|
657
|
+
*/
|
|
658
|
+
interface ContentHookEvent {
|
|
659
|
+
content: Record<string, unknown>;
|
|
660
|
+
collection: string;
|
|
661
|
+
isNew: boolean;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Content delete hook event
|
|
665
|
+
*/
|
|
666
|
+
interface ContentDeleteEvent {
|
|
667
|
+
id: string;
|
|
668
|
+
collection: string;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Content publish state change hook event (fired after publish or unpublish)
|
|
672
|
+
*/
|
|
673
|
+
interface ContentPublishStateChangeEvent {
|
|
674
|
+
content: Record<string, unknown>;
|
|
675
|
+
collection: string;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Media hook event
|
|
679
|
+
*/
|
|
680
|
+
interface MediaUploadEvent {
|
|
681
|
+
file: {
|
|
682
|
+
name: string;
|
|
683
|
+
type: string;
|
|
684
|
+
size: number;
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Media after upload event
|
|
689
|
+
*/
|
|
690
|
+
interface MediaAfterUploadEvent {
|
|
691
|
+
media: MediaItem;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Lifecycle hook event
|
|
695
|
+
*/
|
|
696
|
+
interface LifecycleEvent {}
|
|
697
|
+
/**
|
|
698
|
+
* Uninstall hook event
|
|
699
|
+
*/
|
|
700
|
+
interface UninstallEvent {
|
|
701
|
+
deleteData: boolean;
|
|
702
|
+
}
|
|
703
|
+
type ContentBeforeSaveHandler = (event: ContentHookEvent, ctx: PluginContext) => Promise<Record<string, unknown> | void>;
|
|
704
|
+
type ContentAfterSaveHandler = (event: ContentHookEvent, ctx: PluginContext) => Promise<void>;
|
|
705
|
+
type ContentBeforeDeleteHandler = (event: ContentDeleteEvent, ctx: PluginContext) => Promise<boolean | void>;
|
|
706
|
+
type ContentAfterDeleteHandler = (event: ContentDeleteEvent, ctx: PluginContext) => Promise<void>;
|
|
707
|
+
type ContentAfterPublishHandler = (event: ContentPublishStateChangeEvent, ctx: PluginContext) => Promise<void>;
|
|
708
|
+
type ContentAfterUnpublishHandler = (event: ContentPublishStateChangeEvent, ctx: PluginContext) => Promise<void>;
|
|
709
|
+
type MediaBeforeUploadHandler = (event: MediaUploadEvent, ctx: PluginContext) => Promise<{
|
|
710
|
+
name: string;
|
|
711
|
+
type: string;
|
|
712
|
+
size: number;
|
|
713
|
+
} | void>;
|
|
714
|
+
type MediaAfterUploadHandler = (event: MediaAfterUploadEvent, ctx: PluginContext) => Promise<void>;
|
|
715
|
+
type LifecycleHandler = (event: LifecycleEvent, ctx: PluginContext) => Promise<void>;
|
|
716
|
+
type UninstallHandler = (event: UninstallEvent, ctx: PluginContext) => Promise<void>;
|
|
717
|
+
/** Placement targets for page fragment contributions */
|
|
718
|
+
type PagePlacement = "head" | "body:start" | "body:end";
|
|
719
|
+
/**
|
|
720
|
+
* A single breadcrumb trail item. Used by `PublicPageContext.breadcrumbs`
|
|
721
|
+
* so themes can publish breadcrumb trails that SEO plugins consume.
|
|
722
|
+
*/
|
|
723
|
+
interface BreadcrumbItem {
|
|
724
|
+
/** Display name for this crumb (e.g. "Home", "Blog", "My Post"). */
|
|
725
|
+
name: string;
|
|
726
|
+
/** Absolute or root-relative URL for this crumb. */
|
|
727
|
+
url: string;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Describes the page being rendered. Passed to page hooks so plugins
|
|
731
|
+
* can decide what to contribute without fetching content themselves.
|
|
732
|
+
*/
|
|
733
|
+
interface PublicPageContext {
|
|
734
|
+
url: string;
|
|
735
|
+
path: string;
|
|
736
|
+
locale: string | null;
|
|
737
|
+
kind: "content" | "custom";
|
|
738
|
+
pageType: string;
|
|
739
|
+
/** Full document title for the rendered page */
|
|
740
|
+
title: string | null;
|
|
741
|
+
/** Page-only title for OG/Twitter/JSON-LD headline output */
|
|
742
|
+
pageTitle?: string | null;
|
|
743
|
+
description: string | null;
|
|
744
|
+
canonical: string | null;
|
|
745
|
+
image: string | null;
|
|
746
|
+
content?: {
|
|
747
|
+
collection: string;
|
|
748
|
+
id: string;
|
|
749
|
+
slug: string | null;
|
|
750
|
+
};
|
|
751
|
+
/** SEO meta for base metadata generation in DinewayHead */
|
|
752
|
+
seo?: {
|
|
753
|
+
ogTitle?: string | null;
|
|
754
|
+
ogDescription?: string | null;
|
|
755
|
+
ogImage?: string | null;
|
|
756
|
+
robots?: string | null;
|
|
757
|
+
};
|
|
758
|
+
/** Article metadata for Open Graph article: tags */
|
|
759
|
+
articleMeta?: {
|
|
760
|
+
publishedTime?: string | null;
|
|
761
|
+
modifiedTime?: string | null;
|
|
762
|
+
author?: string | null;
|
|
763
|
+
};
|
|
764
|
+
/** Site name for structured data and og:site_name */
|
|
765
|
+
siteName?: string;
|
|
766
|
+
/**
|
|
767
|
+
* Optional breadcrumb trail for this page, root first. When set,
|
|
768
|
+
* SEO plugins should use this verbatim rather than deriving a trail
|
|
769
|
+
* from `path`. Themes typically populate this at the point they
|
|
770
|
+
* build the context (e.g. from a content hierarchy walk, taxonomy
|
|
771
|
+
* lookup, or per-`pageType` routing logic).
|
|
772
|
+
*
|
|
773
|
+
* Semantics for consumers:
|
|
774
|
+
* - `undefined` — theme has no opinion; consumer falls back to
|
|
775
|
+
* its own derivation.
|
|
776
|
+
* - `[]` — this page has no breadcrumbs (e.g. homepage); consumer
|
|
777
|
+
* should skip `BreadcrumbList` emission entirely.
|
|
778
|
+
* - Non-empty array — used verbatim for `BreadcrumbList` output.
|
|
779
|
+
*/
|
|
780
|
+
breadcrumbs?: BreadcrumbItem[];
|
|
781
|
+
/** Public-facing site URL (origin) for structured data */
|
|
782
|
+
siteUrl?: string;
|
|
783
|
+
}
|
|
784
|
+
interface PageMetadataEvent {
|
|
785
|
+
page: PublicPageContext;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Allowed rel values for link contributions.
|
|
789
|
+
* This is a security-critical allowlist -- sandboxed plugins can only inject
|
|
790
|
+
* link tags with these rel values. Adding "stylesheet", "prefetch", "prerender"
|
|
791
|
+
* etc. would allow sandboxed plugins to inject external resources.
|
|
792
|
+
*/
|
|
793
|
+
type PageMetadataLinkRel = "canonical" | "alternate" | "author" | "license" | "site.standard.document";
|
|
794
|
+
type PageMetadataContribution = {
|
|
795
|
+
kind: "meta";
|
|
796
|
+
name: string;
|
|
797
|
+
content: string;
|
|
798
|
+
key?: string;
|
|
799
|
+
} | {
|
|
800
|
+
kind: "property";
|
|
801
|
+
property: string;
|
|
802
|
+
content: string;
|
|
803
|
+
key?: string;
|
|
804
|
+
} | {
|
|
805
|
+
kind: "link";
|
|
806
|
+
rel: PageMetadataLinkRel;
|
|
807
|
+
href: string;
|
|
808
|
+
hreflang?: string;
|
|
809
|
+
key?: string;
|
|
810
|
+
} | {
|
|
811
|
+
kind: "jsonld";
|
|
812
|
+
id?: string;
|
|
813
|
+
graph: Record<string, unknown> | Array<Record<string, unknown>>;
|
|
814
|
+
};
|
|
815
|
+
type PageMetadataHandler = (event: PageMetadataEvent, ctx: PluginContext) => PageMetadataContribution | PageMetadataContribution[] | null | Promise<PageMetadataContribution | PageMetadataContribution[] | null>;
|
|
816
|
+
interface PageFragmentEvent {
|
|
817
|
+
page: PublicPageContext;
|
|
818
|
+
}
|
|
819
|
+
type PageFragmentContribution = {
|
|
820
|
+
kind: "external-script";
|
|
821
|
+
placement: PagePlacement;
|
|
822
|
+
src: string;
|
|
823
|
+
async?: boolean;
|
|
824
|
+
defer?: boolean;
|
|
825
|
+
attributes?: Record<string, string>;
|
|
826
|
+
key?: string;
|
|
827
|
+
} | {
|
|
828
|
+
kind: "inline-script";
|
|
829
|
+
placement: PagePlacement;
|
|
830
|
+
code: string;
|
|
831
|
+
attributes?: Record<string, string>;
|
|
832
|
+
key?: string;
|
|
833
|
+
} | {
|
|
834
|
+
kind: "html";
|
|
835
|
+
placement: PagePlacement;
|
|
836
|
+
html: string;
|
|
837
|
+
key?: string;
|
|
838
|
+
};
|
|
839
|
+
type PageFragmentHandler = (event: PageFragmentEvent, ctx: PluginContext) => PageFragmentContribution | PageFragmentContribution[] | null | Promise<PageFragmentContribution | PageFragmentContribution[] | null>;
|
|
840
|
+
/**
|
|
841
|
+
* Plugin hooks definition
|
|
842
|
+
*/
|
|
843
|
+
interface PluginHooks {
|
|
844
|
+
"plugin:install"?: HookConfig<LifecycleHandler> | LifecycleHandler;
|
|
845
|
+
"plugin:activate"?: HookConfig<LifecycleHandler> | LifecycleHandler;
|
|
846
|
+
"plugin:deactivate"?: HookConfig<LifecycleHandler> | LifecycleHandler;
|
|
847
|
+
"plugin:uninstall"?: HookConfig<UninstallHandler> | UninstallHandler;
|
|
848
|
+
"content:beforeSave"?: HookConfig<ContentBeforeSaveHandler> | ContentBeforeSaveHandler;
|
|
849
|
+
"content:afterSave"?: HookConfig<ContentAfterSaveHandler> | ContentAfterSaveHandler;
|
|
850
|
+
"content:beforeDelete"?: HookConfig<ContentBeforeDeleteHandler> | ContentBeforeDeleteHandler;
|
|
851
|
+
"content:afterDelete"?: HookConfig<ContentAfterDeleteHandler> | ContentAfterDeleteHandler;
|
|
852
|
+
"content:afterPublish"?: HookConfig<ContentAfterPublishHandler> | ContentAfterPublishHandler;
|
|
853
|
+
"content:afterUnpublish"?: HookConfig<ContentAfterUnpublishHandler> | ContentAfterUnpublishHandler;
|
|
854
|
+
"media:beforeUpload"?: HookConfig<MediaBeforeUploadHandler> | MediaBeforeUploadHandler;
|
|
855
|
+
"media:afterUpload"?: HookConfig<MediaAfterUploadHandler> | MediaAfterUploadHandler;
|
|
856
|
+
cron?: HookConfig<CronHandler> | CronHandler;
|
|
857
|
+
"email:beforeSend"?: HookConfig<EmailBeforeSendHandler> | EmailBeforeSendHandler;
|
|
858
|
+
"email:deliver"?: HookConfig<EmailDeliverHandler> | EmailDeliverHandler;
|
|
859
|
+
"email:afterSend"?: HookConfig<EmailAfterSendHandler> | EmailAfterSendHandler;
|
|
860
|
+
"comment:beforeCreate"?: HookConfig<CommentBeforeCreateHandler> | CommentBeforeCreateHandler;
|
|
861
|
+
"comment:moderate"?: HookConfig<CommentModerateHandler> | CommentModerateHandler;
|
|
862
|
+
"comment:afterCreate"?: HookConfig<CommentAfterCreateHandler> | CommentAfterCreateHandler;
|
|
863
|
+
"comment:afterModerate"?: HookConfig<CommentAfterModerateHandler> | CommentAfterModerateHandler;
|
|
864
|
+
"page:metadata"?: HookConfig<PageMetadataHandler> | PageMetadataHandler;
|
|
865
|
+
"page:fragments"?: HookConfig<PageFragmentHandler> | PageFragmentHandler;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Hook names
|
|
869
|
+
*/
|
|
870
|
+
type HookName = keyof PluginHooks;
|
|
871
|
+
/**
|
|
872
|
+
* Hook metadata entry in a plugin manifest.
|
|
873
|
+
* Replaces the plain hook name string with structured metadata.
|
|
874
|
+
*/
|
|
875
|
+
interface ManifestHookEntry {
|
|
876
|
+
name: string;
|
|
877
|
+
exclusive?: boolean;
|
|
878
|
+
priority?: number;
|
|
879
|
+
timeout?: number;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Route metadata entry in a plugin manifest.
|
|
883
|
+
* Replaces the plain route name string with structured metadata.
|
|
884
|
+
*/
|
|
885
|
+
interface ManifestRouteEntry {
|
|
886
|
+
name: string;
|
|
887
|
+
public?: boolean;
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Resolved hook with normalized config
|
|
891
|
+
*/
|
|
892
|
+
interface ResolvedHook<THandler> {
|
|
893
|
+
priority: number;
|
|
894
|
+
timeout: number;
|
|
895
|
+
dependencies: string[];
|
|
896
|
+
errorPolicy: "continue" | "abort";
|
|
897
|
+
/** Whether this hook is exclusive (provider pattern) */
|
|
898
|
+
exclusive: boolean;
|
|
899
|
+
handler: THandler;
|
|
900
|
+
pluginId: string;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Geographic location information derived from the request.
|
|
904
|
+
* Available when the host runtime provides geographic request metadata
|
|
905
|
+
* (for example via a `request.cf` object).
|
|
906
|
+
*/
|
|
907
|
+
interface GeoInfo {
|
|
908
|
+
country: string | null;
|
|
909
|
+
region: string | null;
|
|
910
|
+
city: string | null;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Normalized request metadata available to plugin route handlers.
|
|
914
|
+
* Extracted from request headers and platform-specific properties.
|
|
915
|
+
*/
|
|
916
|
+
interface RequestMeta {
|
|
917
|
+
ip: string | null;
|
|
918
|
+
userAgent: string | null;
|
|
919
|
+
referer: string | null;
|
|
920
|
+
geo: GeoInfo | null;
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Route handler context extends plugin context with request-specific data
|
|
924
|
+
*/
|
|
925
|
+
interface RouteContext<TInput = unknown> extends PluginContext {
|
|
926
|
+
/** Validated input from request body */
|
|
927
|
+
input: TInput;
|
|
928
|
+
/** Original request */
|
|
929
|
+
request: Request;
|
|
930
|
+
/** Normalized request metadata (IP, user agent, geo) */
|
|
931
|
+
requestMeta: RequestMeta;
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Route definition
|
|
935
|
+
*/
|
|
936
|
+
interface PluginRoute<TInput = unknown> {
|
|
937
|
+
/** Zod schema for input validation */
|
|
938
|
+
input?: z.ZodType<TInput>;
|
|
939
|
+
/**
|
|
940
|
+
* Mark this route as publicly accessible (no authentication required).
|
|
941
|
+
* Public routes skip session/token auth and CSRF checks.
|
|
942
|
+
*/
|
|
943
|
+
public?: boolean;
|
|
944
|
+
/** Route handler */
|
|
945
|
+
handler: (ctx: RouteContext<TInput>) => Promise<unknown>;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Admin page definition
|
|
949
|
+
*/
|
|
950
|
+
interface PluginAdminPage {
|
|
951
|
+
path: string;
|
|
952
|
+
label: string;
|
|
953
|
+
icon?: string;
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Dashboard widget definition
|
|
957
|
+
*/
|
|
958
|
+
interface PluginDashboardWidget {
|
|
959
|
+
id: string;
|
|
960
|
+
size?: "full" | "half" | "third";
|
|
961
|
+
title?: string;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Settings field types (for admin UI generation)
|
|
965
|
+
*/
|
|
966
|
+
type SettingFieldType = "string" | "number" | "boolean" | "select" | "secret";
|
|
967
|
+
interface BaseSettingField {
|
|
968
|
+
type: SettingFieldType;
|
|
969
|
+
label: string;
|
|
970
|
+
description?: string;
|
|
971
|
+
}
|
|
972
|
+
interface StringSettingField extends BaseSettingField {
|
|
973
|
+
type: "string";
|
|
974
|
+
default?: string;
|
|
975
|
+
multiline?: boolean;
|
|
976
|
+
}
|
|
977
|
+
interface NumberSettingField extends BaseSettingField {
|
|
978
|
+
type: "number";
|
|
979
|
+
default?: number;
|
|
980
|
+
min?: number;
|
|
981
|
+
max?: number;
|
|
982
|
+
}
|
|
983
|
+
interface BooleanSettingField extends BaseSettingField {
|
|
984
|
+
type: "boolean";
|
|
985
|
+
default?: boolean;
|
|
986
|
+
}
|
|
987
|
+
interface SelectSettingField extends BaseSettingField {
|
|
988
|
+
type: "select";
|
|
989
|
+
options: Array<{
|
|
990
|
+
value: string;
|
|
991
|
+
label: string;
|
|
992
|
+
}>;
|
|
993
|
+
default?: string;
|
|
994
|
+
}
|
|
995
|
+
interface SecretSettingField extends BaseSettingField {
|
|
996
|
+
type: "secret";
|
|
997
|
+
}
|
|
998
|
+
type SettingField = StringSettingField | NumberSettingField | BooleanSettingField | SelectSettingField | SecretSettingField;
|
|
999
|
+
/**
|
|
1000
|
+
* Block Kit element for block editing fields.
|
|
1001
|
+
* This is the `Element` discriminated union from `@dineway-ai/blocks`.
|
|
1002
|
+
* Plugin authors should use `@dineway-ai/blocks` builder functions to create these.
|
|
1003
|
+
*/
|
|
1004
|
+
type PortableTextBlockField = Element;
|
|
1005
|
+
/**
|
|
1006
|
+
* Configuration for a Portable Text block type contributed by a plugin
|
|
1007
|
+
*/
|
|
1008
|
+
interface PortableTextBlockConfig {
|
|
1009
|
+
/** Block type name (must match the `_type` in Portable Text) */
|
|
1010
|
+
type: string;
|
|
1011
|
+
/** Human-readable label shown in slash commands and modals */
|
|
1012
|
+
label: string;
|
|
1013
|
+
/** Icon key (e.g., "video", "code", "link", "link-external") */
|
|
1014
|
+
icon?: string;
|
|
1015
|
+
/** Description shown in slash command menu */
|
|
1016
|
+
description?: string;
|
|
1017
|
+
/** Placeholder text for the URL input */
|
|
1018
|
+
placeholder?: string;
|
|
1019
|
+
/** Block Kit form fields for the editing UI. If declared, replaces the simple URL input. */
|
|
1020
|
+
fields?: PortableTextBlockField[];
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Configuration for a field widget type contributed by a plugin.
|
|
1024
|
+
* A field widget provides a custom editing UI for a schema field.
|
|
1025
|
+
* The field references the widget via `widget: "pluginId:widgetName"`.
|
|
1026
|
+
*/
|
|
1027
|
+
interface FieldWidgetConfig {
|
|
1028
|
+
/** Widget name (without plugin ID prefix) */
|
|
1029
|
+
name: string;
|
|
1030
|
+
/** Human-readable label for the admin UI */
|
|
1031
|
+
label: string;
|
|
1032
|
+
/** Which field types this widget can edit (e.g., ["json", "string"]) */
|
|
1033
|
+
fieldTypes: FieldType[];
|
|
1034
|
+
/** Block Kit elements for sandboxed rendering. Omit for trusted plugins using React. */
|
|
1035
|
+
elements?: Element[];
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Admin configuration
|
|
1039
|
+
*/
|
|
1040
|
+
interface PluginAdminConfig {
|
|
1041
|
+
/** Module specifier for admin UI exports (e.g., "@dineway-ai/plugin-audit-log/admin") */
|
|
1042
|
+
entry?: string;
|
|
1043
|
+
/** Settings schema for auto-generated UI */
|
|
1044
|
+
settingsSchema?: Record<string, SettingField>;
|
|
1045
|
+
/** Admin pages */
|
|
1046
|
+
pages?: PluginAdminPage[];
|
|
1047
|
+
/** Dashboard widgets */
|
|
1048
|
+
widgets?: PluginDashboardWidget[];
|
|
1049
|
+
/** Portable Text block types this plugin provides */
|
|
1050
|
+
portableTextBlocks?: PortableTextBlockConfig[];
|
|
1051
|
+
/** Field widget types this plugin provides */
|
|
1052
|
+
fieldWidgets?: FieldWidgetConfig[];
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Plugin definition - input to definePlugin()
|
|
1056
|
+
*/
|
|
1057
|
+
interface PluginDefinition<TStorage extends PluginStorageConfig = PluginStorageConfig> {
|
|
1058
|
+
/** Unique plugin identifier */
|
|
1059
|
+
id: string;
|
|
1060
|
+
/** Plugin version (semver) */
|
|
1061
|
+
version: string;
|
|
1062
|
+
/** Declared capabilities */
|
|
1063
|
+
capabilities?: PluginCapability[];
|
|
1064
|
+
/** Allowed hosts for network:fetch (wildcards supported: *.example.com) */
|
|
1065
|
+
allowedHosts?: string[];
|
|
1066
|
+
/** Storage collections with indexes */
|
|
1067
|
+
storage?: TStorage;
|
|
1068
|
+
/** Hooks */
|
|
1069
|
+
hooks?: PluginHooks;
|
|
1070
|
+
/** API routes */
|
|
1071
|
+
routes?: Record<string, PluginRoute>;
|
|
1072
|
+
/** Admin UI configuration */
|
|
1073
|
+
admin?: PluginAdminConfig;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Resolved plugin - after definePlugin() processing
|
|
1077
|
+
*/
|
|
1078
|
+
interface ResolvedPlugin<TStorage extends PluginStorageConfig = PluginStorageConfig> {
|
|
1079
|
+
id: string;
|
|
1080
|
+
version: string;
|
|
1081
|
+
capabilities: PluginCapability[];
|
|
1082
|
+
allowedHosts: string[];
|
|
1083
|
+
storage: TStorage;
|
|
1084
|
+
hooks: ResolvedPluginHooks;
|
|
1085
|
+
routes: Record<string, PluginRoute>;
|
|
1086
|
+
admin: PluginAdminConfig;
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Resolved hooks with normalized config
|
|
1090
|
+
*/
|
|
1091
|
+
interface ResolvedPluginHooks {
|
|
1092
|
+
"plugin:install"?: ResolvedHook<LifecycleHandler>;
|
|
1093
|
+
"plugin:activate"?: ResolvedHook<LifecycleHandler>;
|
|
1094
|
+
"plugin:deactivate"?: ResolvedHook<LifecycleHandler>;
|
|
1095
|
+
"plugin:uninstall"?: ResolvedHook<UninstallHandler>;
|
|
1096
|
+
"content:beforeSave"?: ResolvedHook<ContentBeforeSaveHandler>;
|
|
1097
|
+
"content:afterSave"?: ResolvedHook<ContentAfterSaveHandler>;
|
|
1098
|
+
"content:beforeDelete"?: ResolvedHook<ContentBeforeDeleteHandler>;
|
|
1099
|
+
"content:afterDelete"?: ResolvedHook<ContentAfterDeleteHandler>;
|
|
1100
|
+
"content:afterPublish"?: ResolvedHook<ContentAfterPublishHandler>;
|
|
1101
|
+
"content:afterUnpublish"?: ResolvedHook<ContentAfterUnpublishHandler>;
|
|
1102
|
+
"media:beforeUpload"?: ResolvedHook<MediaBeforeUploadHandler>;
|
|
1103
|
+
"media:afterUpload"?: ResolvedHook<MediaAfterUploadHandler>;
|
|
1104
|
+
cron?: ResolvedHook<CronHandler>;
|
|
1105
|
+
"email:beforeSend"?: ResolvedHook<EmailBeforeSendHandler>;
|
|
1106
|
+
"email:deliver"?: ResolvedHook<EmailDeliverHandler>;
|
|
1107
|
+
"email:afterSend"?: ResolvedHook<EmailAfterSendHandler>;
|
|
1108
|
+
"comment:beforeCreate"?: ResolvedHook<CommentBeforeCreateHandler>;
|
|
1109
|
+
"comment:moderate"?: ResolvedHook<CommentModerateHandler>;
|
|
1110
|
+
"comment:afterCreate"?: ResolvedHook<CommentAfterCreateHandler>;
|
|
1111
|
+
"comment:afterModerate"?: ResolvedHook<CommentAfterModerateHandler>;
|
|
1112
|
+
"page:metadata"?: ResolvedHook<PageMetadataHandler>;
|
|
1113
|
+
"page:fragments"?: ResolvedHook<PageFragmentHandler>;
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Standard plugin hook handler -- same as sandbox entry format.
|
|
1117
|
+
* Receives the event as the first argument and a PluginContext as the second.
|
|
1118
|
+
*
|
|
1119
|
+
* Plugin authors annotate their event parameters with specific types for IDE
|
|
1120
|
+
* support. At the type level, we accept any function with compatible arity.
|
|
1121
|
+
*/
|
|
1122
|
+
type StandardHookHandler = (...args: any[]) => Promise<any>;
|
|
1123
|
+
/**
|
|
1124
|
+
* Standard plugin hook entry -- either a bare handler or a config object.
|
|
1125
|
+
*/
|
|
1126
|
+
type StandardHookEntry = StandardHookHandler | {
|
|
1127
|
+
handler: StandardHookHandler;
|
|
1128
|
+
priority?: number;
|
|
1129
|
+
timeout?: number;
|
|
1130
|
+
dependencies?: string[];
|
|
1131
|
+
errorPolicy?: "continue" | "abort";
|
|
1132
|
+
exclusive?: boolean;
|
|
1133
|
+
};
|
|
1134
|
+
/**
|
|
1135
|
+
* Standard plugin route handler -- takes (routeCtx, pluginCtx) like sandbox entries.
|
|
1136
|
+
* The routeCtx contains input and request info; pluginCtx is the full plugin context.
|
|
1137
|
+
*
|
|
1138
|
+
* Uses `any` for routeCtx to allow plugins to access properties like
|
|
1139
|
+
* `routeCtx.request.url` without needing exact type matches across
|
|
1140
|
+
* trusted (Request object) and sandboxed (plain object) modes.
|
|
1141
|
+
*/
|
|
1142
|
+
type StandardRouteHandler = (routeCtx: any, ctx: PluginContext) => Promise<unknown>;
|
|
1143
|
+
/**
|
|
1144
|
+
* Standard plugin route entry -- either a config object with handler, or just a handler.
|
|
1145
|
+
*/
|
|
1146
|
+
interface StandardRouteEntry {
|
|
1147
|
+
handler: StandardRouteHandler;
|
|
1148
|
+
input?: unknown;
|
|
1149
|
+
public?: boolean;
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Standard plugin definition -- the sandbox entry format.
|
|
1153
|
+
* Used by standard plugins that work in both trusted and sandboxed modes.
|
|
1154
|
+
* No id/version/capabilities -- those come from the descriptor.
|
|
1155
|
+
*
|
|
1156
|
+
* This is the input to definePlugin() for standard-format plugins.
|
|
1157
|
+
*
|
|
1158
|
+
* The hooks and routes use permissive types (Record<string, any>) so that
|
|
1159
|
+
* plugin authors can annotate their handlers with specific event types
|
|
1160
|
+
* without type errors from strictFunctionTypes contravariance.
|
|
1161
|
+
*/
|
|
1162
|
+
interface StandardPluginDefinition {
|
|
1163
|
+
hooks?: Record<string, any>;
|
|
1164
|
+
routes?: Record<string, any>;
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Check if a value is a StandardPluginDefinition (has hooks/routes but no id/version).
|
|
1168
|
+
*/
|
|
1169
|
+
declare function isStandardPluginDefinition(value: unknown): value is StandardPluginDefinition;
|
|
1170
|
+
/**
|
|
1171
|
+
* What a plugin exports from its /admin entrypoint
|
|
1172
|
+
* Uses generic component type to avoid React dependency
|
|
1173
|
+
*/
|
|
1174
|
+
interface PluginAdminExports {
|
|
1175
|
+
widgets?: Record<string, JSX.Element>;
|
|
1176
|
+
pages?: Record<string, JSX.Element>;
|
|
1177
|
+
fields?: Record<string, JSX.Element>;
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Plugin manifest - the metadata portion of a plugin bundle
|
|
1181
|
+
* Used for sandboxed plugins loaded from marketplace
|
|
1182
|
+
*/
|
|
1183
|
+
interface PluginManifest {
|
|
1184
|
+
id: string;
|
|
1185
|
+
version: string;
|
|
1186
|
+
capabilities: PluginCapability[];
|
|
1187
|
+
allowedHosts: string[];
|
|
1188
|
+
storage: PluginStorageConfig;
|
|
1189
|
+
/** Hook declarations — either plain name strings or structured objects */
|
|
1190
|
+
hooks: Array<ManifestHookEntry | HookName>;
|
|
1191
|
+
/** Route declarations — either plain name strings or structured objects */
|
|
1192
|
+
routes: Array<ManifestRouteEntry | string>;
|
|
1193
|
+
admin: PluginAdminConfig;
|
|
1194
|
+
}
|
|
1195
|
+
//#endregion
|
|
1196
|
+
export { StandardPluginDefinition as $, PageMetadataHandler as A, PluginManifest as B, MediaUploadEvent as C, PageFragmentHandler as D, PageFragmentEvent as E, PluginAdminPage as F, PublicPageContext as G, PluginStorageConfig as H, PluginCapability as I, ResolvedPlugin as J, RequestMeta as K, PluginContext as L, PagePlacement as M, PluginAdminConfig as N, PageMetadataContribution as O, PluginAdminExports as P, StandardHookHandler as Q, PluginDefinition as R, MediaItem as S, PageFragmentContribution as T, PortableTextBlockConfig as U, PluginRoute as V, PortableTextBlockField as W, RouteContext as X, ResolvedPluginHooks as Y, StandardHookEntry as Z, HookName as _, CommentAfterModerateEvent as a, Element as at, LogAccess as b, CommentBeforeCreateHandler as c, ContentAccess as d, StandardRouteEntry as et, ContentHookEvent as f, HookConfig as g, FieldWidgetConfig as h, CommentAfterCreateHandler as i, isStandardPluginDefinition as it, PageMetadataLinkRel as j, PageMetadataEvent as k, CommentModerateEvent as l, EmailMessage as m, CollectionCommentSettings as n, StorageCollection as nt, CommentAfterModerateHandler as o, CronEvent as p, ResolvedHook as q, CommentAfterCreateEvent as r, StoredComment as rt, CommentBeforeCreateEvent as s, BreadcrumbItem as t, StandardRouteHandler as tt, CommentModerateHandler as u, HttpAccess as v, ModerationDecision as w, MediaAccess as x, KVAccess as y, PluginHooks as z };
|