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,21 @@
1
+ export interface PluginManifest {
2
+ id: string;
3
+ name: string;
4
+ version: string;
5
+ capabilities: string[];
6
+ routes: string[];
7
+ adminPages?: Array<{
8
+ path: string;
9
+ label?: string;
10
+ icon?: string;
11
+ }>;
12
+ adminWidgets?: Array<{
13
+ id: string;
14
+ title?: string;
15
+ size?: string;
16
+ }>;
17
+ }
18
+ /**
19
+ * Store for active plugins list
20
+ */
21
+ export declare const $plugins: import("@nanostores/query").FetcherStore<PluginManifest[], any>;
@@ -0,0 +1,84 @@
1
+ import { type Router } from '@nanostores/router';
2
+ declare const ROUTE_PATTERNS: {
3
+ readonly home: "";
4
+ readonly setup: "/setup";
5
+ readonly login: "/login";
6
+ readonly signup: "/signup";
7
+ readonly collections: "/collections";
8
+ readonly users: "/users";
9
+ readonly settings: "/settings";
10
+ readonly settings_general: "/settings/general";
11
+ readonly settings_seo: "/settings/seo";
12
+ readonly settings_security: "/settings/security";
13
+ readonly settings_signup: "/settings/signup";
14
+ readonly settings_api: "/settings/api";
15
+ readonly device: "/device";
16
+ readonly collection: "/collection/:id/:slug";
17
+ readonly plugins: "/plugins";
18
+ readonly plugin_page: "/plugins/:pluginId";
19
+ readonly plugin_subpage: "/plugins/:pluginId/:page";
20
+ readonly document_list: "/:slug";
21
+ readonly document_edit: "/:slug/:id";
22
+ };
23
+ /**
24
+ * ExtractParams is a mapped type that extracts the parameters for each route.
25
+ */
26
+ type ExtractParams<Path extends string> = Path extends `${string}:${infer Param}/${infer Rest}` ? {
27
+ [K in Param | keyof ExtractParams<`/${Rest}`>]: string;
28
+ } : Path extends `${string}:${infer Param}` ? {
29
+ [K in Param]: string;
30
+ } : {};
31
+ /**
32
+ * RouteParams is a mapped type that extracts the parameters for each route.
33
+ */
34
+ type RouteParams = {
35
+ [K in RouteName]: ExtractParams<RoutePatterns[K]>;
36
+ };
37
+ /**
38
+ * RoutePatterns is a mapped type that extracts the parameters for each route.
39
+ */
40
+ type RoutePatterns = typeof ROUTE_PATTERNS;
41
+ /**
42
+ * RouteName is a mapped type that extracts the parameters for each route.
43
+ */
44
+ export type RouteName = keyof RoutePatterns;
45
+ export declare const $router: import("nanostores").PreinitializedMapStore<{
46
+ hash: string;
47
+ params: any;
48
+ path: string;
49
+ route: any;
50
+ search: Record<string, string>;
51
+ }> & object;
52
+ /**
53
+ * Initializes the router with a specific base path.
54
+ */
55
+ export declare function initRouter(base: string): Router<{
56
+ readonly home: "";
57
+ readonly setup: "/setup";
58
+ readonly login: "/login";
59
+ readonly signup: "/signup";
60
+ readonly collections: "/collections";
61
+ readonly users: "/users";
62
+ readonly settings: "/settings";
63
+ readonly settings_general: "/settings/general";
64
+ readonly settings_seo: "/settings/seo";
65
+ readonly settings_security: "/settings/security";
66
+ readonly settings_signup: "/settings/signup";
67
+ readonly settings_api: "/settings/api";
68
+ readonly device: "/device";
69
+ readonly collection: "/collection/:id/:slug";
70
+ readonly plugins: "/plugins";
71
+ readonly plugin_page: "/plugins/:pluginId";
72
+ readonly plugin_subpage: "/plugins/:pluginId/:page";
73
+ readonly document_list: "/:slug";
74
+ readonly document_edit: "/:slug/:id";
75
+ }>;
76
+ /**
77
+ * Navigate to a named route.
78
+ */
79
+ export declare function navigate<T extends RouteName>(route: T, params?: RouteParams[T], search?: Record<string, string | number>): void;
80
+ /**
81
+ * Redirect to a named route.
82
+ */
83
+ export declare function redirect<T extends RouteName>(route: T, params?: any, search?: Record<string, string | number>): void;
84
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { CollectionSchema, Field } from '../types';
2
+ export declare const $activeSlug: import("nanostores").PreinitializedWritableAtom<string | null> & object;
3
+ export declare const $schema: import("@nanostores/query").FetcherStore<CollectionSchema, any>;
4
+ export declare const $addField: import("@nanostores/query").MutatorStore<Partial<Field> & {
5
+ collectionSlug: string;
6
+ }, Field, any>;
7
+ export declare const $reloadSchema: () => void;
@@ -0,0 +1,7 @@
1
+ export interface Settings {
2
+ [key: string]: string;
3
+ }
4
+ export declare const $settings: import("nanostores").PreinitializedMapStore<Settings> & object;
5
+ export declare function loadSettings(): Promise<void>;
6
+ export declare function updateSettingsLocally(newSettings: Settings): void;
7
+ export declare function getSetting(key: string, fallback?: string): string;
@@ -0,0 +1,31 @@
1
+ export interface Collection {
2
+ id: string;
3
+ slug: string;
4
+ label: string;
5
+ label_singular: string | null;
6
+ description: string | null;
7
+ icon: string | null;
8
+ is_public: number;
9
+ features: string[];
10
+ url_pattern: string | null;
11
+ createdAt: string;
12
+ }
13
+ export interface Field {
14
+ id: string;
15
+ collectionId: string;
16
+ label: string;
17
+ slug: string;
18
+ type: 'text' | 'richtext' | 'number' | 'boolean' | 'date';
19
+ required: boolean;
20
+ createdAt: string;
21
+ }
22
+ export interface CollectionSchema extends Collection {
23
+ fields: Field[];
24
+ }
25
+ export interface ContentEntry {
26
+ id: string;
27
+ slug: string;
28
+ createdAt: Date | string;
29
+ updatedAt: Date | string;
30
+ [key: string]: any;
31
+ }
@@ -0,0 +1,5 @@
1
+ import type { FlareDb } from "./index";
2
+ export declare const FIELD_TYPE_MAP: Record<string, string>;
3
+ export declare function createCollectionTable(db: FlareDb, slug: string): Promise<void>;
4
+ export declare function addFieldToTable(db: FlareDb, collectionSlug: string, fieldSlug: string, type: string): Promise<void>;
5
+ export declare function ensureUniqueSlug(db: FlareDb, collectionName: string, baseSlug: string, excludeId?: string): Promise<string>;
@@ -0,0 +1,8 @@
1
+ import { Kysely } from "kysely";
2
+ import type { Database } from "./schema";
3
+ import type { D1Database } from "@cloudflare/workers-types";
4
+ export * from "./schema";
5
+ export * from "./dynamic";
6
+ export * from "./migrator";
7
+ export declare const createDb: (d1: D1Database) => Kysely<Database>;
8
+ export type FlareDb = ReturnType<typeof createDb>;
@@ -0,0 +1,3 @@
1
+ import { Kysely } from 'kysely';
2
+ export declare function up(db: Kysely<any>): Promise<void>;
3
+ export declare function down(db: Kysely<any>): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { Kysely } from 'kysely';
2
+ export declare function up(db: Kysely<any>): Promise<void>;
3
+ export declare function down(db: Kysely<any>): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { Kysely } from 'kysely';
2
+ export declare function up(db: Kysely<any>): Promise<void>;
3
+ export declare function down(db: Kysely<any>): Promise<void>;
@@ -0,0 +1,10 @@
1
+ import type { FlareDb } from './index';
2
+ /**
3
+ * Manual D1-safe migration runner.
4
+ * We avoid Kysely's built-in Migrator because it uses introspection (sqlite_master)
5
+ * which Cloudflare D1 restricts, causing SQLITE_AUTH errors.
6
+ */
7
+ export declare function runMigrations(db: FlareDb): Promise<{
8
+ name: string;
9
+ status: "Success" | "Skipped" | "Error";
10
+ }[]>;
@@ -0,0 +1,151 @@
1
+ import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
2
+ export interface Database {
3
+ options: OptionsTable;
4
+ fc_collections: CollectionsTable;
5
+ fc_fields: FieldsTable;
6
+ fc_users: UsersTable;
7
+ fc_passkeys: PasskeysTable;
8
+ fc_sessions: SessionsTable;
9
+ fc_api_tokens: ApiTokensTable;
10
+ fc_oauth_accounts: OAuthAccountsTable;
11
+ fc_verification_tokens: VerificationTokensTable;
12
+ fc_device_codes: DeviceCodesTable;
13
+ fc_plugins: PluginsTable;
14
+ _fc_plugin_storage: PluginStorageTable;
15
+ _fc_cron_tasks: CronTasksTable;
16
+ [tableName: string]: any;
17
+ }
18
+ export interface PluginsTable {
19
+ id: string;
20
+ plugin_id: string;
21
+ version: string;
22
+ status: string;
23
+ capabilities: string | null;
24
+ allowed_hosts: string | null;
25
+ storage_config: string | null;
26
+ manifest: string | null;
27
+ backend_code: string | null;
28
+ installed_at: ColumnType<string, string | undefined, never>;
29
+ activated_at: string | null;
30
+ }
31
+ export interface PluginStorageTable {
32
+ plugin_id: string;
33
+ collection: string;
34
+ id: string;
35
+ data: string;
36
+ updated_at: ColumnType<string, string | undefined, string>;
37
+ }
38
+ export interface CronTasksTable {
39
+ id: string;
40
+ plugin_id: string;
41
+ schedule: string;
42
+ last_run_at: string | null;
43
+ next_run_at: string | null;
44
+ enabled: ColumnType<number, number | undefined, number>;
45
+ }
46
+ export interface OptionsTable {
47
+ name: string;
48
+ value: string;
49
+ }
50
+ export type Option = Selectable<OptionsTable>;
51
+ export type NewOption = Insertable<OptionsTable>;
52
+ export interface CollectionsTable {
53
+ id: string;
54
+ slug: string;
55
+ label: string;
56
+ label_singular: string | null;
57
+ description: string | null;
58
+ icon: string | null;
59
+ is_public: ColumnType<number, number | undefined, number>;
60
+ features: string | null;
61
+ url_pattern: string | null;
62
+ created_at: ColumnType<string, string | undefined, never>;
63
+ updated_at: ColumnType<string, string | undefined, string>;
64
+ }
65
+ export type Collection = Selectable<CollectionsTable>;
66
+ export type NewCollection = Insertable<CollectionsTable>;
67
+ export type CollectionUpdate = Updateable<CollectionsTable>;
68
+ export interface FieldsTable {
69
+ id: string;
70
+ collection_id: string;
71
+ label: string;
72
+ slug: string;
73
+ type: string;
74
+ required: ColumnType<number, number | undefined, number>;
75
+ created_at: ColumnType<string, string | undefined, never>;
76
+ }
77
+ export type Field = Selectable<FieldsTable>;
78
+ export type NewField = Insertable<FieldsTable>;
79
+ export interface UsersTable {
80
+ id: string;
81
+ email: string;
82
+ password: string | null;
83
+ role: string;
84
+ disabled: ColumnType<number, number | undefined, number>;
85
+ created_at: ColumnType<string, string | undefined, never>;
86
+ updated_at: ColumnType<string, string | undefined, string>;
87
+ }
88
+ export type User = Selectable<UsersTable>;
89
+ export type NewUser = Insertable<UsersTable>;
90
+ export type UserUpdate = Updateable<UsersTable>;
91
+ export interface PasskeysTable {
92
+ id: string;
93
+ user_id: string;
94
+ name: string | null;
95
+ public_key: string;
96
+ counter: number;
97
+ device_type: string;
98
+ backed_up: number;
99
+ transports: string | null;
100
+ created_at: ColumnType<string, string | undefined, never>;
101
+ last_used_at: string | null;
102
+ }
103
+ export type Passkey = Selectable<PasskeysTable>;
104
+ export type NewPasskey = Insertable<PasskeysTable>;
105
+ export type PasskeyUpdate = Updateable<PasskeysTable>;
106
+ export interface SessionsTable {
107
+ id: string;
108
+ user_id: string;
109
+ expires_at: string;
110
+ }
111
+ export type Session = Selectable<SessionsTable>;
112
+ export type NewSession = Insertable<SessionsTable>;
113
+ export type SessionUpdate = Updateable<SessionsTable>;
114
+ export interface ApiTokensTable {
115
+ id: string;
116
+ user_id: string;
117
+ name: string;
118
+ hash: string;
119
+ scopes: string;
120
+ expires_at: string | null;
121
+ last_used_at: string | null;
122
+ created_at: ColumnType<string, string | undefined, never>;
123
+ }
124
+ export type ApiToken = Selectable<ApiTokensTable>;
125
+ export type NewApiToken = Insertable<ApiTokensTable>;
126
+ export interface OAuthAccountsTable {
127
+ provider_id: string;
128
+ provider_user_id: string;
129
+ user_id: string;
130
+ }
131
+ export type OAuthAccount = Selectable<OAuthAccountsTable>;
132
+ export type NewOAuthAccount = Insertable<OAuthAccountsTable>;
133
+ export interface VerificationTokensTable {
134
+ identifier: string;
135
+ token: string;
136
+ expires_at: string;
137
+ }
138
+ export type VerificationToken = Selectable<VerificationTokensTable>;
139
+ export type NewVerificationToken = Insertable<VerificationTokensTable>;
140
+ export interface DeviceCodesTable {
141
+ device_code: string;
142
+ user_code: string;
143
+ client_id: string;
144
+ user_id: string | null;
145
+ scopes: string;
146
+ expires_at: string;
147
+ created_at: ColumnType<string, string | undefined, never>;
148
+ }
149
+ export type DeviceCode = Selectable<DeviceCodesTable>;
150
+ export type NewDeviceCode = Insertable<DeviceCodesTable>;
151
+ export type DeviceCodeUpdate = Updateable<DeviceCodesTable>;
@@ -0,0 +1,11 @@
1
+ export * from './auth';
2
+ export * from './db';
3
+ export * from './server';
4
+ export * from './client';
5
+ export * from './types';
6
+ import { createFlareAPI } from './server';
7
+ /**
8
+ * @deprecated Use createFlareAPI from 'flarecms/server' for better modularity.
9
+ */
10
+ export declare const flarecms: typeof createFlareAPI;
11
+ export * from './plugins';
@@ -0,0 +1,5 @@
1
+ import type { PluginDescriptor, ResolvedPlugin, FlarePlugin } from './types.js';
2
+ /**
3
+ * Adapts any plugin input (Descriptor or full Plugin object) into a ResolvedPlugin.
4
+ */
5
+ export declare function adaptEntry(input: PluginDescriptor | FlarePlugin): ResolvedPlugin;
@@ -0,0 +1,21 @@
1
+ import type { FlareDb } from '../db/index.js';
2
+ import type { PluginContext, PluginCapability } from './types.js';
3
+ export interface ContextFactoryOptions {
4
+ pluginId: string;
5
+ version: string;
6
+ capabilities: PluginCapability[];
7
+ allowedHosts: string[];
8
+ storageCollections: string[];
9
+ db: FlareDb;
10
+ siteInfo: {
11
+ name: string;
12
+ url: string;
13
+ locale: string;
14
+ };
15
+ encryptionSecret?: string;
16
+ }
17
+ /**
18
+ * Creates an in-process (trusted) PluginContext.
19
+ * Operations are executed directly against the provided database.
20
+ */
21
+ export declare function createPluginContext(options: ContextFactoryOptions): PluginContext;
@@ -0,0 +1,22 @@
1
+ import type { FlarePluginDefinition } from './types.js';
2
+ /**
3
+ * definePlugin() Helper
4
+ *
5
+ * Creates a properly typed plugin definition. This is an identity function
6
+ * that provides type inference and basic validation for the standard plugin format.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { definePlugin } from "flarecms/plugins";
11
+ *
12
+ * export default definePlugin({
13
+ * hooks: {
14
+ * "content:afterSave": async (event, ctx) => {
15
+ * ctx.log.info("Content saved!");
16
+ * },
17
+ * },
18
+ * });
19
+ * ```
20
+ */
21
+ export declare function definePlugin<T extends FlarePluginDefinition>(definition: T): T;
22
+ export default definePlugin;
@@ -0,0 +1,37 @@
1
+ import type { ResolvedPlugin } from './types.js';
2
+ import type { FlareDb } from '../db/index.js';
3
+ /**
4
+ * HookPipeline manages the registration and execution of hooks across all plugins.
5
+ */
6
+ export declare class HookPipeline {
7
+ private hooks;
8
+ private plugins;
9
+ private db;
10
+ private siteInfo;
11
+ constructor(plugins: ResolvedPlugin[], db: FlareDb, siteInfo: {
12
+ name: string;
13
+ url: string;
14
+ locale: string;
15
+ });
16
+ /**
17
+ * Run a chain of hooks that can modify the event data (Waterfall pattern).
18
+ * Example: content:beforeSave
19
+ */
20
+ runChain<T>(hookName: string, initialData: T): Promise<T>;
21
+ /**
22
+ * Run all hooks in parallel (Fire-and-forget pattern).
23
+ * Example: content:afterSave
24
+ */
25
+ runParallel(hookName: string, event: unknown): Promise<void>;
26
+ /**
27
+ * Run hooks where any hook returning 'false' aborts the operation.
28
+ * Example: content:beforeDelete
29
+ */
30
+ runVeto(hookName: string, event: unknown): Promise<boolean>;
31
+ runContentBeforeSave(content: Record<string, unknown>, collection: string, isNew: boolean): Promise<Record<string, unknown>>;
32
+ runContentAfterSave(content: Record<string, unknown>, collection: string, isNew: boolean): Promise<void>;
33
+ runContentBeforeDelete(id: string, collection: string): Promise<boolean>;
34
+ runContentAfterDelete(id: string, collection: string): Promise<void>;
35
+ private createContextForHook;
36
+ private executeWithTimeout;
37
+ }
@@ -0,0 +1,7 @@
1
+ export { definePlugin } from './define-plugin.js';
2
+ export { PluginManager } from './manager.js';
3
+ export { NoopSandboxRunner, SandboxNotAvailableError } from './noop-sandbox.js';
4
+ export { adaptEntry } from './adapt-entry.js';
5
+ export { createPluginContext } from './context.js';
6
+ export { pluginMiddleware } from './middleware.js';
7
+ export type { BlockInteraction, BlockResponse, FlarePluginDefinition, FlarePlugin, PluginDescriptor, PluginManifest, PluginContext, SandboxRunner, SandboxRunnerFactory, PluginCapability, SerializedRequest, RouteCtx, } from './types';
@@ -0,0 +1,41 @@
1
+ import { type InvokeRouteOptions } from './routes.js';
2
+ import type { ResolvedPlugin, BlockInteraction, BlockResponse } from './types.js';
3
+ import type { FlareDb } from '../db/index.js';
4
+ /**
5
+ * PluginManager is the central orchestrator for the FlareCMS plugin system.
6
+ * It coordinates hook execution, route handling, and plugin lifecycle.
7
+ */
8
+ export declare class PluginManager {
9
+ plugins: ResolvedPlugin[];
10
+ db: FlareDb;
11
+ siteInfo: {
12
+ name: string;
13
+ url: string;
14
+ locale: string;
15
+ };
16
+ encryptionSecret?: string | undefined;
17
+ private hookPipeline;
18
+ private routeRegistry;
19
+ constructor(plugins: ResolvedPlugin[], db: FlareDb, siteInfo: {
20
+ name: string;
21
+ url: string;
22
+ locale: string;
23
+ }, encryptionSecret?: string | undefined);
24
+ runContentBeforeSave(content: Record<string, unknown>, collection: string, isNew: boolean): Promise<Record<string, unknown>>;
25
+ runContentAfterSave(content: Record<string, unknown>, collection: string, isNew: boolean): Promise<void>;
26
+ runContentBeforeDelete(id: string, collection: string): Promise<boolean>;
27
+ runContentAfterDelete(id: string, collection: string): Promise<void>;
28
+ invokeRoute(pluginId: string, routeName: string, options: InvokeRouteOptions): Promise<unknown>;
29
+ /**
30
+ * Invokes the administrative UI handler for a plugin.
31
+ */
32
+ invokeAdmin(pluginId: string, interaction: BlockInteraction): Promise<BlockResponse>;
33
+ /**
34
+ * Returns the list of active plugins and their basic info.
35
+ */
36
+ getActivePlugins(): ResolvedPlugin[];
37
+ /**
38
+ * Checks if a specific plugin is loaded and active.
39
+ */
40
+ isActive(pluginId: string): boolean;
41
+ }
@@ -0,0 +1,8 @@
1
+ import type { MiddlewareHandler } from 'hono';
2
+ import type { FlarePlugin, PluginDescriptor } from './types.js';
3
+ /**
4
+ * Hono middleware to initialize the PluginManager.
5
+ *
6
+ * @param staticPlugins - Plugins declared at build-time/config.
7
+ */
8
+ export declare function pluginMiddleware(staticPlugins?: (PluginDescriptor | FlarePlugin)[]): MiddlewareHandler;
@@ -0,0 +1,18 @@
1
+ import type { SandboxRunner, SandboxedPlugin, PluginManifest } from './types.js';
2
+ /**
3
+ * Error thrown when a sandboxed operation is attempted but no sandbox runner is available.
4
+ */
5
+ export declare class SandboxNotAvailableError extends Error {
6
+ constructor(reason?: string);
7
+ }
8
+ /**
9
+ * No-op Sandbox Runner
10
+ *
11
+ * Acts as a fallback for environments where sandboxing (e.g. Worker Loader)
12
+ * is not supported or configured.
13
+ */
14
+ export declare class NoopSandboxRunner implements SandboxRunner {
15
+ isAvailable(): boolean;
16
+ load(_manifest: PluginManifest, _code: string): Promise<SandboxedPlugin>;
17
+ terminateAll(): Promise<void>;
18
+ }
@@ -0,0 +1,32 @@
1
+ import type { ResolvedPlugin, SerializedRequest } from './types.js';
2
+ import type { FlareDb } from '../db/index.js';
3
+ export interface InvokeRouteOptions {
4
+ input: unknown;
5
+ request: SerializedRequest;
6
+ }
7
+ /**
8
+ * PluginRouteRegistry manages custom HTTP routes exposed by plugins.
9
+ */
10
+ export declare class PluginRouteRegistry {
11
+ private plugins;
12
+ private db;
13
+ private siteInfo;
14
+ private encryptionSecret?;
15
+ constructor(db: FlareDb, siteInfo: {
16
+ name: string;
17
+ url: string;
18
+ locale: string;
19
+ }, encryptionSecret?: string);
20
+ /**
21
+ * Registers all routes for a given plugin.
22
+ */
23
+ register(plugin: ResolvedPlugin): void;
24
+ /**
25
+ * Invokes a specific plugin route.
26
+ */
27
+ invoke(pluginId: string, routeName: string, options: InvokeRouteOptions): Promise<unknown>;
28
+ /**
29
+ * Gets all registered routes for a specific plugin.
30
+ */
31
+ getRoutes(pluginId: string): string[];
32
+ }
@@ -0,0 +1,45 @@
1
+ import { WorkerEntrypoint } from 'cloudflare:workers';
2
+ import type { PluginBridgeInterface, PluginBridgeEnv } from './types.js';
3
+ /**
4
+ * PluginBridge is the RPC gateway that runs in the Host process.
5
+ * It exposes secure methods to the Sandboxed Plugin via Service Bindings.
6
+ */
7
+ export declare class PluginBridge extends WorkerEntrypoint<PluginBridgeEnv> implements PluginBridgeInterface {
8
+ private props;
9
+ constructor(ctx: any, env: PluginBridgeEnv);
10
+ private get db();
11
+ private hasCap;
12
+ kvGet(key: string): Promise<any>;
13
+ kvSet(key: string, value: any): Promise<void>;
14
+ kvDelete(key: string): Promise<boolean>;
15
+ kvList(prefix?: string): Promise<{
16
+ key: any;
17
+ value: any;
18
+ }[]>;
19
+ storageGet(collection: string, id: string): Promise<any>;
20
+ storagePut(collection: string, id: string, data: any): Promise<void>;
21
+ storageDelete(collection: string, id: string): Promise<boolean>;
22
+ storageQuery(collection: string, opts?: any): Promise<{
23
+ items: any[];
24
+ hasMore: boolean;
25
+ }>;
26
+ contentGet(collection: string, id: string): Promise<{
27
+ [x: string]: any;
28
+ } | undefined>;
29
+ contentList(collection: string, opts?: any): Promise<{
30
+ items: {
31
+ [x: string]: any;
32
+ }[];
33
+ hasMore: boolean;
34
+ }>;
35
+ contentCreate(collection: string, data: any): Promise<import("kysely").InsertResult[]>;
36
+ contentUpdate(collection: string, id: string, data: any): Promise<import("kysely").UpdateResult[]>;
37
+ contentDelete(collection: string, id: string): Promise<boolean>;
38
+ httpFetch(url: string, init?: any): Promise<{
39
+ status: number;
40
+ ok: boolean;
41
+ headers: Record<string, string>;
42
+ text: string;
43
+ }>;
44
+ log(level: string, message: string, data?: any): void;
45
+ }
@@ -0,0 +1,14 @@
1
+ import type { SandboxRunner, SandboxedPlugin, PluginManifest, SandboxOptions } from '../types.js';
2
+ import type { WorkerLoader } from './types.js';
3
+ /**
4
+ * Sandbox Runner implementation for Cloudflare Workers.
5
+ * Uses the dynamic 'Worker Loader' API to spawn V8 isolates.
6
+ */
7
+ export declare class CloudflareSandboxRunner implements SandboxRunner {
8
+ private loader;
9
+ private options;
10
+ constructor(loader: WorkerLoader, options: SandboxOptions);
11
+ isAvailable(): boolean;
12
+ load(manifest: PluginManifest, code: string): Promise<SandboxedPlugin>;
13
+ terminateAll(): Promise<void>;
14
+ }