flarecms 0.2.1 → 0.2.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.
Files changed (126) hide show
  1. package/dist/api/lib/cache.d.ts +18 -0
  2. package/dist/api/lib/response.d.ts +44 -0
  3. package/dist/api/middlewares/auth.d.ts +10 -0
  4. package/dist/api/middlewares/cors.d.ts +1 -0
  5. package/dist/api/middlewares/rbac.d.ts +21 -0
  6. package/dist/api/routes/auth.d.ts +6 -0
  7. package/dist/api/routes/collections.d.ts +6 -0
  8. package/dist/api/routes/content.d.ts +6 -0
  9. package/dist/api/routes/device.d.ts +6 -0
  10. package/dist/api/routes/magic.d.ts +6 -0
  11. package/dist/api/routes/mcp.d.ts +6 -0
  12. package/dist/api/routes/oauth.d.ts +6 -0
  13. package/dist/api/routes/plugins.d.ts +6 -0
  14. package/dist/api/routes/settings.d.ts +6 -0
  15. package/dist/api/routes/setup.d.ts +6 -0
  16. package/dist/api/routes/tokens.d.ts +6 -0
  17. package/dist/api/schemas/auth.d.ts +12 -0
  18. package/dist/api/schemas/index.d.ts +43 -0
  19. package/dist/api/schemas/tokens.d.ts +20 -0
  20. package/dist/auth/index.d.ts +11 -0
  21. package/dist/cli/commands.d.ts +3 -0
  22. package/dist/cli/commands.js +50 -28
  23. package/dist/cli/index.d.ts +2 -0
  24. package/dist/cli/index.js +50 -28
  25. package/dist/cli/mcp.d.ts +9 -0
  26. package/dist/cli/tests/cli.test.d.ts +1 -0
  27. package/dist/cli/tests/create-plugin-template.test.d.ts +1 -0
  28. package/dist/cli/tests/create.test.d.ts +1 -0
  29. package/dist/cli/tests/plugin.test.d.ts +1 -0
  30. package/dist/cli/tests/publish.test.d.ts +1 -0
  31. package/dist/client/FlareAdminRouter.d.ts +20 -0
  32. package/dist/client/app.d.ts +1 -0
  33. package/dist/client/components/app-sidebar.d.ts +5 -0
  34. package/dist/client/components/blocks/block-card.d.ts +7 -0
  35. package/dist/client/components/blocks/block-form.d.ts +7 -0
  36. package/dist/client/components/blocks/block-renderer.d.ts +10 -0
  37. package/dist/client/components/blocks/block-table.d.ts +7 -0
  38. package/dist/client/components/collection-modal.d.ts +6 -0
  39. package/dist/client/components/content-list.d.ts +3 -0
  40. package/dist/client/components/dynamic-form.d.ts +9 -0
  41. package/dist/client/components/field-modal.d.ts +8 -0
  42. package/dist/client/components/plugin-widget.d.ts +6 -0
  43. package/dist/client/components/settings/api-token-section.d.ts +1 -0
  44. package/dist/client/components/settings/general-section.d.ts +1 -0
  45. package/dist/client/components/settings/security-section.d.ts +1 -0
  46. package/dist/client/components/settings/seo-section.d.ts +1 -0
  47. package/dist/client/components/settings/signup-section.d.ts +1 -0
  48. package/dist/client/components/ui/accordion.d.ts +6 -0
  49. package/dist/client/components/ui/avatar.d.ts +11 -0
  50. package/dist/client/components/ui/badge.d.ts +7 -0
  51. package/dist/client/components/ui/button.d.ts +11 -0
  52. package/dist/client/components/ui/card.d.ts +11 -0
  53. package/dist/client/components/ui/checkbox.d.ts +3 -0
  54. package/dist/client/components/ui/collapsible.d.ts +5 -0
  55. package/dist/client/components/ui/dialog.d.ts +17 -0
  56. package/dist/client/components/ui/icon-picker.d.ts +27 -0
  57. package/dist/client/components/ui/icons-data.d.ts +5 -0
  58. package/dist/client/components/ui/input.d.ts +3 -0
  59. package/dist/client/components/ui/label.d.ts +3 -0
  60. package/dist/client/components/ui/popover.d.ts +10 -0
  61. package/dist/client/components/ui/select.d.ts +15 -0
  62. package/dist/client/components/ui/separator.d.ts +3 -0
  63. package/dist/client/components/ui/sheet.d.ts +14 -0
  64. package/dist/client/components/ui/sidebar.d.ts +63 -0
  65. package/dist/client/components/ui/skeleton.d.ts +2 -0
  66. package/dist/client/components/ui/sonner.d.ts +3 -0
  67. package/dist/client/components/ui/switch.d.ts +5 -0
  68. package/dist/client/components/ui/table.d.ts +10 -0
  69. package/dist/client/components/ui/tabs.d.ts +10 -0
  70. package/dist/client/components/ui/textarea.d.ts +3 -0
  71. package/dist/client/components/ui/tooltip.d.ts +6 -0
  72. package/dist/client/hooks/use-mobile.d.ts +1 -0
  73. package/dist/client/index.d.ts +8 -0
  74. package/dist/client/layouts/admin-layout.d.ts +6 -0
  75. package/dist/client/layouts/settings-layout.d.ts +6 -0
  76. package/dist/client/lib/api.d.ts +18 -0
  77. package/dist/client/lib/block-registry.d.ts +24 -0
  78. package/dist/client/lib/block-types.d.ts +132 -0
  79. package/dist/client/lib/utils.d.ts +2 -0
  80. package/dist/client/main.d.ts +1 -0
  81. package/dist/client/pages/collection-detail.d.ts +7 -0
  82. package/dist/client/pages/collections.d.ts +1 -0
  83. package/dist/client/pages/dashboard.d.ts +1 -0
  84. package/dist/client/pages/device.d.ts +1 -0
  85. package/dist/client/pages/document-detail-page.d.ts +1 -0
  86. package/dist/client/pages/documents-page.d.ts +1 -0
  87. package/dist/client/pages/login.d.ts +1 -0
  88. package/dist/client/pages/plugin-manager.d.ts +1 -0
  89. package/dist/client/pages/plugin-page.d.ts +6 -0
  90. package/dist/client/pages/settings.d.ts +1 -0
  91. package/dist/client/pages/setup.d.ts +1 -0
  92. package/dist/client/pages/signup.d.ts +1 -0
  93. package/dist/client/store/auth.d.ts +10 -0
  94. package/dist/client/store/collections.d.ts +3 -0
  95. package/dist/client/store/config.d.ts +4 -0
  96. package/dist/client/store/fetcher.d.ts +4 -0
  97. package/dist/client/store/plugins.d.ts +21 -0
  98. package/dist/client/store/router.d.ts +84 -0
  99. package/dist/client/store/schema.d.ts +7 -0
  100. package/dist/client/store/settings.d.ts +7 -0
  101. package/dist/client/types.d.ts +31 -0
  102. package/dist/db/dynamic.d.ts +5 -0
  103. package/dist/db/index.d.ts +8 -0
  104. package/dist/db/migrations/001_initial_schema.d.ts +3 -0
  105. package/dist/db/migrations/002_auth_tables.d.ts +3 -0
  106. package/dist/db/migrations/003_plugins.d.ts +3 -0
  107. package/dist/db/migrator.d.ts +10 -0
  108. package/dist/db/schema.d.ts +151 -0
  109. package/dist/index.d.ts +11 -0
  110. package/dist/plugins/adapt-entry.d.ts +5 -0
  111. package/dist/plugins/context.d.ts +21 -0
  112. package/dist/plugins/define-plugin.d.ts +22 -0
  113. package/dist/plugins/hooks.d.ts +37 -0
  114. package/dist/plugins/index.d.ts +7 -0
  115. package/dist/plugins/manager.d.ts +41 -0
  116. package/dist/plugins/middleware.d.ts +8 -0
  117. package/dist/plugins/noop-sandbox.d.ts +18 -0
  118. package/dist/plugins/routes.d.ts +32 -0
  119. package/dist/plugins/sandbox/bridge.d.ts +45 -0
  120. package/dist/plugins/sandbox/runner.d.ts +14 -0
  121. package/dist/plugins/sandbox/types.d.ts +71 -0
  122. package/dist/plugins/sandbox/wrapper.d.ts +6 -0
  123. package/dist/plugins/types.d.ts +725 -0
  124. package/dist/server/index.d.ts +18 -0
  125. package/dist/types.d.ts +19 -0
  126. package/package.json +34 -10
@@ -0,0 +1,725 @@
1
+ import type { Headers } from '@cloudflare/workers-types';
2
+ import type { FlareDb } from '../db';
3
+ /**
4
+ * Available capabilities for FlareCMS plugins.
5
+ * These define what a plugin is allowed to access and do.
6
+ */
7
+ export type PluginCapability = 'read:content' | 'write:content' | 'read:media' | 'write:media' | 'network:fetch' | 'network:fetch:any' | 'read:users' | 'email:send' | 'crypto:encrypt' | 'crypto:decrypt' | 'storage:read' | 'storage:write' | 'storage:delete' | 'storage:list';
8
+ export interface FlarePluginDefinition {
9
+ /**
10
+ * Plugin ID.
11
+ */
12
+ id?: string;
13
+ /**
14
+ * Plugin name.
15
+ */
16
+ name?: string;
17
+ /**
18
+ * Plugin version.
19
+ */
20
+ version?: string;
21
+ /**
22
+ * Plugin format.
23
+ */
24
+ format?: 'standard';
25
+ /**
26
+ * Plugin capabilities.
27
+ */
28
+ capabilities?: PluginCapability[];
29
+ /**
30
+ * Allowed hosts for the plugin.
31
+ */
32
+ allowedHosts?: string[];
33
+ /**
34
+ * Storage collections for the plugin.
35
+ * The key is the collection name and the value is an object with indexes.
36
+ */
37
+ storage?: Record<string, {
38
+ indexes?: string[];
39
+ }>;
40
+ /**
41
+ * Admin pages for the plugin.
42
+ * The key is the path and the value is an object with the page configuration.
43
+ */
44
+ adminPages?: Array<{
45
+ path: string;
46
+ label: string;
47
+ icon?: string;
48
+ }>;
49
+ /**
50
+ * Admin widgets for the plugin.
51
+ * The key is the id and the value is an object with the widget configuration.
52
+ */
53
+ adminWidgets?: Array<{
54
+ id: string;
55
+ title?: string;
56
+ size?: 'full' | 'half' | 'third';
57
+ }>;
58
+ /**
59
+ * Hooks for the plugin.
60
+ * The key is the hook name and the value is the hook handler.
61
+ */
62
+ hooks?: Record<string, FlareHookEntry>;
63
+ /**
64
+ * Routes for the plugin.
65
+ * The key is the route name and the value is the route handler.
66
+ */
67
+ routes?: Record<string, FlareRouteEntry>;
68
+ /**
69
+ * Admin handler for the plugin.
70
+ * The key is the admin handler and the value is the admin handler.
71
+ */
72
+ admin?: {
73
+ handler: (interaction: BlockInteraction, ctx: PluginContext) => Promise<BlockResponse>;
74
+ };
75
+ }
76
+ /**
77
+ * A complete, self-contained FlareCMS plugin.
78
+ */
79
+ export type FlarePlugin = FlarePluginDefinition & {
80
+ id: string;
81
+ version: string;
82
+ };
83
+ /**
84
+ * Block types for the plugin.
85
+ */
86
+ export type BlockType = 'header' | 'text' | 'divider' | 'stat' | 'input' | 'textarea' | 'select' | 'toggle' | 'button' | 'button_group' | 'table' | 'alert' | 'card' | 'grid' | 'form' | 'custom';
87
+ /**
88
+ * Block interface for the plugin.
89
+ */
90
+ export interface Block {
91
+ type: BlockType;
92
+ id?: string;
93
+ className?: string;
94
+ [key: string]: unknown;
95
+ }
96
+ /**
97
+ * Block interaction types for the plugin.
98
+ */
99
+ export type BlockInteraction = {
100
+ type: 'page_load';
101
+ page: string;
102
+ } | {
103
+ type: 'block_action';
104
+ blockId: string;
105
+ value?: unknown;
106
+ } | {
107
+ type: 'form_submit';
108
+ formId: string;
109
+ values: Record<string, unknown>;
110
+ };
111
+ /**
112
+ * Block response for the plugin.
113
+ */
114
+ export interface BlockResponse {
115
+ blocks: Block[];
116
+ toast?: {
117
+ type: 'success' | 'error' | 'info' | 'warning';
118
+ message: string;
119
+ };
120
+ }
121
+ /**
122
+ * Flare hook handler for the plugin.
123
+ */
124
+ export type FlareHookHandler = (event: unknown, ctx: PluginContext) => Promise<unknown>;
125
+ /**
126
+ * Flare hook entry for the plugin.
127
+ */
128
+ export type FlareHookEntry = FlareHookHandler | {
129
+ handler: FlareHookHandler;
130
+ priority?: number;
131
+ timeout?: number;
132
+ };
133
+ /**
134
+ * Flare route entry for the plugin.
135
+ */
136
+ export interface FlareRouteEntry {
137
+ handler: (routeCtx: RouteCtx, ctx: PluginContext) => Promise<unknown>;
138
+ input?: unknown;
139
+ public?: boolean;
140
+ }
141
+ /**
142
+ * Context provided to route handlers.
143
+ */
144
+ export interface RouteCtx {
145
+ input: unknown;
146
+ request: SerializedRequest;
147
+ requestMeta: RequestMeta;
148
+ }
149
+ /**
150
+ * Core context provided to all plugin hooks and routes.
151
+ * Access is gated by the plugin's declared capabilities.
152
+ */
153
+ export interface PluginContext {
154
+ /**
155
+ * Plugin id and version.
156
+ */
157
+ plugin: {
158
+ id: string;
159
+ version: string;
160
+ };
161
+ /**
162
+ * KV storage for the plugin.
163
+ */
164
+ kv: PluginKV;
165
+ /**
166
+ * Storage collections for the plugin.
167
+ */
168
+ storage: Record<string, PluginStorageCollection>;
169
+ /**
170
+ * Content access for the plugin.
171
+ */
172
+ content?: PluginContentAccess;
173
+ /**
174
+ * Media access for the plugin.
175
+ */
176
+ media?: PluginMediaAccess;
177
+ /**
178
+ * HTTP access for the plugin.
179
+ */
180
+ http?: PluginHttpAccess;
181
+ /**
182
+ * Logger for the plugin.
183
+ */
184
+ log: PluginLogger;
185
+ /**
186
+ * Site information for the plugin.
187
+ */
188
+ site: {
189
+ name: string;
190
+ url: string;
191
+ locale: string;
192
+ };
193
+ /**
194
+ * Users access for the plugin.
195
+ */
196
+ users?: PluginUsersAccess;
197
+ /**
198
+ * Email access for the plugin.
199
+ */
200
+ email?: PluginEmailAccess;
201
+ /**
202
+ * Crypto access for the plugin.
203
+ */
204
+ crypto?: PluginCryptoAccess;
205
+ }
206
+ /**
207
+ * Plugin Descriptor used in the host configuration.
208
+ */
209
+ export interface PluginDescriptor {
210
+ /**
211
+ * Plugin id.
212
+ */
213
+ id: string;
214
+ /**
215
+ * Plugin name.
216
+ */
217
+ name?: string;
218
+ /**
219
+ * Plugin version.
220
+ */
221
+ version: string;
222
+ /**
223
+ * Plugin format.
224
+ */
225
+ format: 'standard';
226
+ /**
227
+ * Plugin entrypoint.
228
+ */
229
+ entrypoint: string;
230
+ /**
231
+ * Plugin capabilities.
232
+ */
233
+ capabilities?: PluginCapability[];
234
+ /**
235
+ * Allowed hosts for the plugin.
236
+ */
237
+ allowedHosts?: string[];
238
+ /**
239
+ * Storage collections for the plugin.
240
+ */
241
+ storage?: Record<string, {
242
+ indexes?: string[];
243
+ }>;
244
+ /**
245
+ * Admin pages for the plugin.
246
+ */
247
+ adminPages?: Array<{
248
+ path: string;
249
+ label: string;
250
+ icon?: string;
251
+ }>;
252
+ /**
253
+ * Admin widgets for the plugin.
254
+ */
255
+ adminWidgets?: Array<{
256
+ id: string;
257
+ title?: string;
258
+ size?: 'full' | 'half' | 'third';
259
+ }>;
260
+ }
261
+ /**
262
+ * Manifest describing an installed plugin's requirements and structure.
263
+ */
264
+ export interface PluginManifest {
265
+ /**
266
+ * Plugin id.
267
+ */
268
+ id: string;
269
+ /**
270
+ * Plugin name.
271
+ */
272
+ name: string;
273
+ /**
274
+ * Plugin version.
275
+ */
276
+ version: string;
277
+ /**
278
+ * Plugin capabilities.
279
+ */
280
+ capabilities: PluginCapability[];
281
+ /**
282
+ * Allowed hosts for the plugin.
283
+ */
284
+ allowedHosts: string[];
285
+ /**
286
+ * Storage collections for the plugin.
287
+ */
288
+ storage: Record<string, {
289
+ indexes: string[];
290
+ }>;
291
+ /**
292
+ * Hooks for the plugin.
293
+ */
294
+ hooks: string[];
295
+ /**
296
+ * Routes for the plugin.
297
+ */
298
+ routes: string[];
299
+ /**
300
+ * Admin pages for the plugin.
301
+ */
302
+ adminPages: Array<{
303
+ path: string;
304
+ label: string;
305
+ icon?: string;
306
+ }>;
307
+ /**
308
+ * Admin widgets for the plugin.
309
+ */
310
+ adminWidgets: Array<{
311
+ id: string;
312
+ title?: string;
313
+ size?: string;
314
+ }>;
315
+ }
316
+ /**
317
+ * Internal representation of a plugin after registration and normalization.
318
+ */
319
+ export interface ResolvedPlugin {
320
+ /**
321
+ * Plugin id.
322
+ */
323
+ id: string;
324
+ /**
325
+ * Plugin name.
326
+ */
327
+ name: string;
328
+ /**
329
+ * Plugin version.
330
+ */
331
+ version: string;
332
+ /**
333
+ * Plugin capabilities.
334
+ */
335
+ capabilities: PluginCapability[];
336
+ /**
337
+ * Allowed hosts for the plugin.
338
+ */
339
+ allowedHosts: string[];
340
+ /**
341
+ * Storage collections for the plugin.
342
+ */
343
+ storage: Record<string, {
344
+ indexes: string[];
345
+ }>;
346
+ /**
347
+ * Hooks for the plugin.
348
+ */
349
+ hooks: Record<string, ResolvedHook>;
350
+ /**
351
+ * Routes for the plugin.
352
+ */
353
+ routes: Record<string, ResolvedRoute>;
354
+ /**
355
+ * Admin handler for the plugin.
356
+ */
357
+ admin?: {
358
+ handler: (interaction: BlockInteraction, ctx: PluginContext) => Promise<BlockResponse>;
359
+ };
360
+ /**
361
+ * Admin pages for the plugin.
362
+ */
363
+ adminPages: Array<{
364
+ path: string;
365
+ label: string;
366
+ icon?: string;
367
+ }>;
368
+ /**
369
+ * Admin widgets for the plugin.
370
+ */
371
+ adminWidgets: Array<{
372
+ id: string;
373
+ title?: string;
374
+ size?: 'full' | 'half' | 'third';
375
+ }>;
376
+ }
377
+ /**
378
+ * Resolved hook for the plugin.
379
+ */
380
+ export interface ResolvedHook {
381
+ /**
382
+ * Hook priority.
383
+ */
384
+ priority: number;
385
+ /**
386
+ * Hook timeout.
387
+ */
388
+ timeout: number;
389
+ /**
390
+ * Hook handler.
391
+ */
392
+ handler: FlareHookHandler;
393
+ /**
394
+ * Plugin id.
395
+ */
396
+ pluginId: string;
397
+ }
398
+ /**
399
+ * Resolved route for the plugin.
400
+ */
401
+ export interface ResolvedRoute {
402
+ /**
403
+ * Route input.
404
+ */
405
+ input?: unknown;
406
+ /**
407
+ * Route public.
408
+ */
409
+ public?: boolean;
410
+ /**
411
+ * Route handler.
412
+ */
413
+ handler: (routeCtx: RouteCtx, ctx: PluginContext) => Promise<unknown>;
414
+ }
415
+ /**
416
+ * Sandbox runner for the plugin.
417
+ */
418
+ export interface SandboxRunner {
419
+ /**
420
+ * Check if the sandbox is available.
421
+ */
422
+ isAvailable(): boolean;
423
+ /**
424
+ * Load the plugin in the sandbox.
425
+ */
426
+ load(manifest: PluginManifest, code: string): Promise<SandboxedPlugin>;
427
+ /**
428
+ * Terminate all sandboxes.
429
+ */
430
+ terminateAll(): Promise<void>;
431
+ }
432
+ /**
433
+ * Sandboxed plugin for the plugin.
434
+ */
435
+ export interface SandboxedPlugin {
436
+ /**
437
+ * Plugin id.
438
+ */
439
+ readonly id: string;
440
+ /**
441
+ * Invoke hook for the plugin.
442
+ */
443
+ invokeHook(hookName: string, event: unknown): Promise<unknown>;
444
+ /**
445
+ * Invoke route for the plugin.
446
+ */
447
+ invokeRoute(routeName: string, input: unknown, request: SerializedRequest): Promise<unknown>;
448
+ /**
449
+ * Terminate the plugin.
450
+ */
451
+ terminate(): Promise<void>;
452
+ }
453
+ /**
454
+ * Sandbox options for the plugin.
455
+ */
456
+ export interface SandboxOptions {
457
+ /**
458
+ * Database for the plugin.
459
+ */
460
+ db: FlareDb;
461
+ /**
462
+ * Resource limits for the plugin.
463
+ */
464
+ limits?: ResourceLimits;
465
+ /**
466
+ * Site information for the plugin.
467
+ */
468
+ siteInfo?: {
469
+ name: string;
470
+ url: string;
471
+ locale: string;
472
+ };
473
+ encryptionSecret?: string;
474
+ }
475
+ /**
476
+ * Resource limits for the plugin.
477
+ */
478
+ export interface ResourceLimits {
479
+ /**
480
+ * CPU time limit in milliseconds.
481
+ */
482
+ cpuMs?: number;
483
+ /**
484
+ * Memory limit in megabytes.
485
+ */
486
+ memoryMb?: number;
487
+ /**
488
+ * Subrequest limit.
489
+ */
490
+ subrequests?: number;
491
+ /**
492
+ * Wall time limit in milliseconds.
493
+ */
494
+ wallTimeMs?: number;
495
+ }
496
+ /**
497
+ * Plugin KV for the plugin.
498
+ */
499
+ export interface PluginKV {
500
+ /**
501
+ * Get a value from the KV store.
502
+ */
503
+ get(key: string): Promise<unknown>;
504
+ /**
505
+ * Set a value in the KV store.
506
+ */
507
+ set(key: string, value: unknown): Promise<void>;
508
+ /**
509
+ * Delete a value from the KV store.
510
+ */
511
+ delete(key: string): Promise<boolean>;
512
+ /**
513
+ * List all values in the KV store.
514
+ */
515
+ list(prefix?: string): Promise<Array<{
516
+ key: string;
517
+ value: unknown;
518
+ }>>;
519
+ }
520
+ /**
521
+ * Plugin storage collection for the plugin.
522
+ */
523
+ export interface PluginStorageCollection {
524
+ /**
525
+ * Get a value from the storage collection.
526
+ */
527
+ get(id: string): Promise<unknown>;
528
+ /**
529
+ * Put a value in the storage collection.
530
+ */
531
+ put(id: string, data: unknown): Promise<void>;
532
+ /**
533
+ * Delete a value from the storage collection.
534
+ */
535
+ delete(id: string): Promise<boolean>;
536
+ /**
537
+ * Query the storage collection.
538
+ */
539
+ query(opts?: {
540
+ limit?: number;
541
+ cursor?: string;
542
+ }): Promise<{
543
+ items: unknown[];
544
+ hasMore: boolean;
545
+ cursor?: string;
546
+ }>;
547
+ /**
548
+ * Count the number of items in the storage collection.
549
+ */
550
+ count(): Promise<number>;
551
+ }
552
+ /**
553
+ * Plugin content access for the plugin.
554
+ */
555
+ export interface PluginContentAccess {
556
+ /**
557
+ * Get a value from the content collection.
558
+ */
559
+ get(collection: string, id: string): Promise<unknown>;
560
+ /**
561
+ * List all values in the content collection.
562
+ */
563
+ list(collection: string, opts?: {
564
+ limit?: number;
565
+ cursor?: string;
566
+ }): Promise<{
567
+ items: unknown[];
568
+ hasMore: boolean;
569
+ }>;
570
+ /**
571
+ * Create a new value in the content collection.
572
+ */
573
+ create(collection: string, data: Record<string, unknown>): Promise<unknown>;
574
+ /**
575
+ * Update a value in the content collection.
576
+ */
577
+ update(collection: string, id: string, data: Record<string, unknown>): Promise<unknown>;
578
+ /**
579
+ * Delete a value from the content collection.
580
+ */
581
+ delete(collection: string, id: string): Promise<boolean>;
582
+ }
583
+ /**
584
+ * Plugin media access for the plugin.
585
+ */
586
+ export interface PluginMediaAccess {
587
+ /**
588
+ * Get a value from the media collection.
589
+ */
590
+ get(id: string): Promise<unknown>;
591
+ /**
592
+ * List all values in the media collection.
593
+ */
594
+ list(opts?: {
595
+ limit?: number;
596
+ }): Promise<{
597
+ items: unknown[];
598
+ }>;
599
+ /**
600
+ * Delete a value from the media collection.
601
+ */
602
+ delete(id: string): Promise<boolean>;
603
+ }
604
+ /**
605
+ * Plugin HTTP access for the plugin.
606
+ */
607
+ export interface PluginHttpAccess {
608
+ /**
609
+ * Fetch a resource from the HTTP.
610
+ */
611
+ fetch(url: string, init?: RequestInit): Promise<{
612
+ status: number;
613
+ ok: boolean;
614
+ headers: Headers;
615
+ text(): Promise<string>;
616
+ json(): Promise<unknown>;
617
+ }>;
618
+ }
619
+ /**
620
+ * Plugin logger for the plugin.
621
+ */
622
+ export interface PluginLogger {
623
+ /**
624
+ * Log a debug message.
625
+ */
626
+ debug(msg: string, data?: unknown): void;
627
+ /**
628
+ * Log an info message.
629
+ */
630
+ info(msg: string, data?: unknown): void;
631
+ /**
632
+ * Log a warning message.
633
+ */
634
+ warn(msg: string, data?: unknown): void;
635
+ /**
636
+ * Log an error message.
637
+ */
638
+ error(msg: string, data?: unknown): void;
639
+ }
640
+ /**
641
+ * Plugin users access for the plugin.
642
+ */
643
+ export interface PluginUsersAccess {
644
+ /**
645
+ * Get a user from the users collection.
646
+ */
647
+ get(id: string): Promise<unknown>;
648
+ /**
649
+ * List all users in the users collection.
650
+ */
651
+ list(opts?: {
652
+ limit?: number;
653
+ }): Promise<{
654
+ items: unknown[];
655
+ }>;
656
+ }
657
+ /**
658
+ * Plugin email access for the plugin.
659
+ */
660
+ export interface PluginEmailAccess {
661
+ /**
662
+ * Send an email.
663
+ */
664
+ send(message: {
665
+ to: string;
666
+ subject: string;
667
+ text: string;
668
+ html?: string;
669
+ }): Promise<void>;
670
+ }
671
+ /**
672
+ * Plugin crypto access for the plugin.
673
+ */
674
+ export interface PluginCryptoAccess {
675
+ /**
676
+ * Encrypt a string using the system's secret key.
677
+ */
678
+ encrypt(text: string): Promise<string>;
679
+ /**
680
+ * Decrypt a string using the system's secret key.
681
+ */
682
+ decrypt(ciphertext: string): Promise<string>;
683
+ }
684
+ /**
685
+ * Serialized request for the plugin.
686
+ */
687
+ export interface SerializedRequest {
688
+ /**
689
+ * Request url.
690
+ */
691
+ url: string;
692
+ /**
693
+ * Request method.
694
+ */
695
+ method: string;
696
+ /**
697
+ * Request headers.
698
+ */
699
+ headers: Record<string, string>;
700
+ /**
701
+ * Request meta.
702
+ */
703
+ meta: RequestMeta;
704
+ }
705
+ /**
706
+ * Request meta for the plugin.
707
+ */
708
+ export interface RequestMeta {
709
+ /**
710
+ * Request ip.
711
+ */
712
+ ip: string | null;
713
+ /**
714
+ * Request user agent.
715
+ */
716
+ userAgent: string | null;
717
+ /**
718
+ * Request referer.
719
+ */
720
+ referer: string | null;
721
+ }
722
+ /**
723
+ * Sandbox runner factory for the plugin.
724
+ */
725
+ export type SandboxRunnerFactory = (options: SandboxOptions) => SandboxRunner;