@justflows/sdk 0.0.0-stage → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -2
- package/dist/api-urls.d.ts +4 -0
- package/dist/api-urls.d.ts.map +1 -0
- package/dist/api-urls.js +22 -0
- package/dist/api-urls.js.map +1 -0
- package/dist/cache.d.ts +63 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +28 -0
- package/dist/cache.js.map +1 -0
- package/dist/capabilities.d.ts +73 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +118 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/compatibility.d.ts +7 -0
- package/dist/compatibility.d.ts.map +1 -0
- package/dist/compatibility.js +7 -0
- package/dist/compatibility.js.map +1 -0
- package/dist/cookies.d.ts +60 -0
- package/dist/cookies.d.ts.map +1 -0
- package/dist/cookies.js +60 -0
- package/dist/cookies.js.map +1 -0
- package/dist/hooks.d.ts +1393 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +102 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/license.d.ts +26 -0
- package/dist/license.d.ts.map +1 -0
- package/dist/license.js +90 -0
- package/dist/license.js.map +1 -0
- package/dist/media-html.d.ts +85 -0
- package/dist/media-html.d.ts.map +1 -0
- package/dist/media-html.js +181 -0
- package/dist/media-html.js.map +1 -0
- package/dist/patterns.d.ts +72 -0
- package/dist/patterns.d.ts.map +1 -0
- package/dist/patterns.js +86 -0
- package/dist/patterns.js.map +1 -0
- package/dist/placeholders.d.ts +64 -0
- package/dist/placeholders.d.ts.map +1 -0
- package/dist/placeholders.js +38 -0
- package/dist/placeholders.js.map +1 -0
- package/dist/plugin.d.ts +2424 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +724 -0
- package/dist/plugin.js.map +1 -0
- package/dist/publisher-namespace.d.ts +49 -0
- package/dist/publisher-namespace.d.ts.map +1 -0
- package/dist/publisher-namespace.js +106 -0
- package/dist/publisher-namespace.js.map +1 -0
- package/dist/registry.d.ts +64 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +132 -0
- package/dist/registry.js.map +1 -0
- package/dist/search.d.ts +25 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +2 -0
- package/dist/search.js.map +1 -0
- package/dist/spam.d.ts +30 -0
- package/dist/spam.d.ts.map +1 -0
- package/dist/spam.js +3 -0
- package/dist/spam.js.map +1 -0
- package/dist/templates.d.ts +37 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +52 -0
- package/dist/templates.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/visibility.d.ts +79 -0
- package/dist/visibility.d.ts.map +1 -0
- package/dist/visibility.js +3 -0
- package/dist/visibility.js.map +1 -0
- package/package.json +46 -4
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,2424 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CacheStoreDefinition } from "./cache.js";
|
|
3
|
+
import type { PluginMediaApi } from "./placeholders.js";
|
|
4
|
+
import type { PluginVisibilityApi } from "./visibility.js";
|
|
5
|
+
import type { PluginCookiesApi } from "./cookies.js";
|
|
6
|
+
import type { BlockPattern } from "./patterns.js";
|
|
7
|
+
import type { AccessPolicy, UserCapability, UserCapabilityDefinition } from "./capabilities.js";
|
|
8
|
+
import type { ActionName, ActionHandlerFor, ActionPayload, FilterName, FilterHandlerFor, FilterValue, FilterContext, GateName, GateHandlerFor, GatePayload, HookRegisterOptions, Unsubscribe } from "./hooks.js";
|
|
9
|
+
export declare const PluginPermissionSchema: z.ZodEnum<{
|
|
10
|
+
"admin:extend": "admin:extend";
|
|
11
|
+
"auth:hook": "auth:hook";
|
|
12
|
+
"cache:store": "cache:store";
|
|
13
|
+
"content:create": "content:create";
|
|
14
|
+
"content:delete": "content:delete";
|
|
15
|
+
"content:publish": "content:publish";
|
|
16
|
+
"content:read": "content:read";
|
|
17
|
+
"content:revisions:discard": "content:revisions:discard";
|
|
18
|
+
"content:revisions:read": "content:revisions:read";
|
|
19
|
+
"content:revisions:restore": "content:revisions:restore";
|
|
20
|
+
"content:update": "content:update";
|
|
21
|
+
"diagnostics:publish": "diagnostics:publish";
|
|
22
|
+
"files:private": "files:private";
|
|
23
|
+
"jobs:register": "jobs:register";
|
|
24
|
+
"mail:hook": "mail:hook";
|
|
25
|
+
"mail:send": "mail:send";
|
|
26
|
+
"mail:templates": "mail:templates";
|
|
27
|
+
"mail:transport": "mail:transport";
|
|
28
|
+
"media:delete": "media:delete";
|
|
29
|
+
"media:read": "media:read";
|
|
30
|
+
"media:upload": "media:upload";
|
|
31
|
+
"network:outbound": "network:outbound";
|
|
32
|
+
"platform:network": "platform:network";
|
|
33
|
+
"platform:tenancy": "platform:tenancy";
|
|
34
|
+
"settings:manage": "settings:manage";
|
|
35
|
+
"settings:read": "settings:read";
|
|
36
|
+
"users:manage": "users:manage";
|
|
37
|
+
"users:read": "users:read";
|
|
38
|
+
}>;
|
|
39
|
+
export type PluginPermission = z.infer<typeof PluginPermissionSchema>;
|
|
40
|
+
export declare const SENSITIVE_PERMISSIONS: PluginPermission[];
|
|
41
|
+
/** Host/runtime versions exposed to an activated extension. */
|
|
42
|
+
export interface JustflowsRuntimeVersions {
|
|
43
|
+
/** Installed Justflows CE version. */
|
|
44
|
+
readonly justflows: string;
|
|
45
|
+
/** Installed `@justflows/sdk` package version. */
|
|
46
|
+
readonly sdk: string;
|
|
47
|
+
/** Major contract revision for runtime feature detection. */
|
|
48
|
+
readonly sdkApi: number;
|
|
49
|
+
}
|
|
50
|
+
/** Sidebar groups an extension may contribute an admin page to. */
|
|
51
|
+
export declare const ADMIN_MENU_DOMAINS: readonly ["content", "commerce", "appearance", "users", "plugin", "extensions", "tools", "security", "system"];
|
|
52
|
+
export type AdminMenuDomain = (typeof ADMIN_MENU_DOMAINS)[number];
|
|
53
|
+
/**
|
|
54
|
+
* The admin URL namespace the host reserves for one plugin's own pages:
|
|
55
|
+
* `/admin/plugins/<pluginId>`. Every plugin admin screen lives here, so a URL
|
|
56
|
+
* always says whether it is core or plugin-owned.
|
|
57
|
+
*/
|
|
58
|
+
export declare function pluginAdminBasePath(pluginId: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Compose a plugin-relative admin path (`""`, `"orders"`, `"orders/refunds"`)
|
|
61
|
+
* into its absolute URL under the plugin's namespace. `""` / nullish is the
|
|
62
|
+
* namespace root.
|
|
63
|
+
*/
|
|
64
|
+
export declare function resolvePluginAdminPath(pluginId: string, relativePath?: string | null): string;
|
|
65
|
+
/**
|
|
66
|
+
* A plugin-relative admin path: the empty string (the plugin's namespace root)
|
|
67
|
+
* or a lowercase `leaf` / `leaf/child` under it. It must **not** start with
|
|
68
|
+
* `/`, name `admin`, contain a `.` (so it can never be an absolute `/admin/…`
|
|
69
|
+
* route or repeat the dot-namespaced plugin id) — the host prepends
|
|
70
|
+
* `/admin/plugins/<pluginId>/`.
|
|
71
|
+
*/
|
|
72
|
+
export declare const RELATIVE_ADMIN_PATH_RE: RegExp;
|
|
73
|
+
/**
|
|
74
|
+
* One admin navigation entry owned by a plugin. The host renders these only
|
|
75
|
+
* while the plugin is installed, so uninstalling a plugin takes its pages out
|
|
76
|
+
* of the sidebar with it.
|
|
77
|
+
*/
|
|
78
|
+
export declare const AdminMenuItemSchema: z.ZodObject<{
|
|
79
|
+
id: z.ZodString;
|
|
80
|
+
label: z.ZodString;
|
|
81
|
+
labelKey: z.ZodOptional<z.ZodString>;
|
|
82
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
83
|
+
path: z.ZodOptional<z.ZodString>;
|
|
84
|
+
icon: z.ZodDefault<z.ZodString>;
|
|
85
|
+
domain: z.ZodCatch<z.ZodDefault<z.ZodEnum<{
|
|
86
|
+
appearance: "appearance";
|
|
87
|
+
commerce: "commerce";
|
|
88
|
+
content: "content";
|
|
89
|
+
extensions: "extensions";
|
|
90
|
+
plugin: "plugin";
|
|
91
|
+
security: "security";
|
|
92
|
+
system: "system";
|
|
93
|
+
tools: "tools";
|
|
94
|
+
users: "users";
|
|
95
|
+
}>>>;
|
|
96
|
+
end: z.ZodOptional<z.ZodBoolean>;
|
|
97
|
+
listed: z.ZodOptional<z.ZodBoolean>;
|
|
98
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
99
|
+
badge: z.ZodOptional<z.ZodString>;
|
|
100
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
export type PluginAdminMenuItem = z.infer<typeof AdminMenuItemSchema>;
|
|
103
|
+
/**
|
|
104
|
+
* Text shown in the admin: one string, or `{ "<locale>": "<text>" }`. The editor
|
|
105
|
+
* uses the admin language, then its base language, then `en`, then any entry.
|
|
106
|
+
*/
|
|
107
|
+
export declare const LocalizedTextSchema: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
108
|
+
export type LocalizedText = z.infer<typeof LocalizedTextSchema>;
|
|
109
|
+
/**
|
|
110
|
+
* One field of a content editor panel. The value is saved in the entry's
|
|
111
|
+
* `fields` under `key`. In `placeholder`, `{title}`, `{excerpt}`, and `{url}`
|
|
112
|
+
* become the entry's title, excerpt, and public address.
|
|
113
|
+
*/
|
|
114
|
+
export declare const EditorPanelFieldSchema: z.ZodObject<{
|
|
115
|
+
key: z.ZodString;
|
|
116
|
+
type: z.ZodEnum<{
|
|
117
|
+
checkbox: "checkbox";
|
|
118
|
+
image: "image";
|
|
119
|
+
text: "text";
|
|
120
|
+
textarea: "textarea";
|
|
121
|
+
url: "url";
|
|
122
|
+
}>;
|
|
123
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
124
|
+
hint: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
125
|
+
placeholder: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
/**
|
|
128
|
+
* A section a plugin adds to the content editor, next to Content, Discussion,
|
|
129
|
+
* and Advanced. Shown while the plugin is active, for every content type.
|
|
130
|
+
*/
|
|
131
|
+
export declare const EditorPanelSchema: z.ZodObject<{
|
|
132
|
+
id: z.ZodString;
|
|
133
|
+
title: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
134
|
+
indexableOnly: z.ZodOptional<z.ZodBoolean>;
|
|
135
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
136
|
+
key: z.ZodString;
|
|
137
|
+
type: z.ZodEnum<{
|
|
138
|
+
checkbox: "checkbox";
|
|
139
|
+
image: "image";
|
|
140
|
+
text: "text";
|
|
141
|
+
textarea: "textarea";
|
|
142
|
+
url: "url";
|
|
143
|
+
}>;
|
|
144
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
145
|
+
hint: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
146
|
+
placeholder: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
147
|
+
}, z.core.$strip>>>;
|
|
148
|
+
app: z.ZodOptional<z.ZodString>;
|
|
149
|
+
}, z.core.$strip>;
|
|
150
|
+
export type PluginEditorPanel = z.infer<typeof EditorPanelSchema>;
|
|
151
|
+
/**
|
|
152
|
+
* The plugin's own sidebar section. Menu items with `domain: "plugin"` are
|
|
153
|
+
* listed there instead of in a shared section.
|
|
154
|
+
*/
|
|
155
|
+
export declare const AdminSectionSchema: z.ZodObject<{
|
|
156
|
+
label: z.ZodString;
|
|
157
|
+
labelKey: z.ZodOptional<z.ZodString>;
|
|
158
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
159
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
160
|
+
}, z.core.$strip>;
|
|
161
|
+
export type PluginAdminSection = z.infer<typeof AdminSectionSchema>;
|
|
162
|
+
/**
|
|
163
|
+
* A card a plugin adds to Platform → Workspace. The host embeds the relative
|
|
164
|
+
* admin-app path and passes the workspace id being viewed.
|
|
165
|
+
*/
|
|
166
|
+
export declare const WorkspacePanelSchema: z.ZodObject<{
|
|
167
|
+
id: z.ZodString;
|
|
168
|
+
title: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
169
|
+
app: z.ZodString;
|
|
170
|
+
}, z.core.$strip>;
|
|
171
|
+
export type PluginWorkspacePanel = z.infer<typeof WorkspacePanelSchema>;
|
|
172
|
+
/**
|
|
173
|
+
* A card on the admin Home page, filled by the plugin's own admin app
|
|
174
|
+
* (`/ext/<plugin id>/admin/<app>`), like a workspace panel. The card shows to
|
|
175
|
+
* users who may open the plugin's admin pages. Keep it to a summary that
|
|
176
|
+
* links into the plugin, such as today's orders or the next bookings.
|
|
177
|
+
*/
|
|
178
|
+
export declare const DashboardPanelSchema: z.ZodObject<{
|
|
179
|
+
id: z.ZodString;
|
|
180
|
+
title: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
181
|
+
app: z.ZodString;
|
|
182
|
+
size: z.ZodOptional<z.ZodEnum<{
|
|
183
|
+
small: "small";
|
|
184
|
+
wide: "wide";
|
|
185
|
+
}>>;
|
|
186
|
+
}, z.core.$strip>;
|
|
187
|
+
export type PluginDashboardPanel = z.infer<typeof DashboardPanelSchema>;
|
|
188
|
+
/**
|
|
189
|
+
* Something a user can do from admin search (⌘K), such as "Add a product".
|
|
190
|
+
* It opens one of the plugin's own admin pages, so a role that cannot open
|
|
191
|
+
* that page never sees the action.
|
|
192
|
+
*/
|
|
193
|
+
export declare const AdminActionSchema: z.ZodObject<{
|
|
194
|
+
id: z.ZodString;
|
|
195
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
196
|
+
path: z.ZodOptional<z.ZodString>;
|
|
197
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
198
|
+
keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
export type PluginAdminAction = z.infer<typeof AdminActionSchema>;
|
|
201
|
+
/** Assets one block type needs, relative to the assets `dir`. */
|
|
202
|
+
export declare const PluginBlockAssetsSchema: z.ZodObject<{
|
|
203
|
+
scripts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
204
|
+
styles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
205
|
+
}, z.core.$strip>;
|
|
206
|
+
/**
|
|
207
|
+
* A selector a page must contain for an `assets.markup` rule to apply:
|
|
208
|
+
* `#id`, `.class`, `.class-prefix*` (any class starting with the prefix), or
|
|
209
|
+
* `[attribute]`. Matched against the finished HTML, so it finds markup from
|
|
210
|
+
* any source: content, templates, plugin routes, header and footer.
|
|
211
|
+
*/
|
|
212
|
+
export declare const AssetMarkupSelectorSchema: z.ZodString;
|
|
213
|
+
/** Assets a page loads when it contains any of `match`. Paths are relative to the assets `dir`. */
|
|
214
|
+
export declare const PluginMarkupAssetsSchema: z.ZodObject<{
|
|
215
|
+
match: z.ZodArray<z.ZodString>;
|
|
216
|
+
scripts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
217
|
+
styles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
218
|
+
}, z.core.$strip>;
|
|
219
|
+
/**
|
|
220
|
+
* Client-side assets a plugin ships in its package. On activation the host
|
|
221
|
+
* serves `<dir>/**` at `/ext/<pluginId>/**` and auto-enqueues `scripts` /
|
|
222
|
+
* `styles` on every public page — no `ctx.http` route or `html.head` filter.
|
|
223
|
+
* `blocks` maps one of the plugin's own block types, and `markup` a list of
|
|
224
|
+
* selectors, to assets the host adds only to pages that render that block or
|
|
225
|
+
* contain that markup (from content, templates, header, footer, widget areas,
|
|
226
|
+
* or plugin routes), with a content-hashed URL that browsers cache for good.
|
|
227
|
+
* Prefer them to `scripts` / `styles` for anything not every page needs.
|
|
228
|
+
* The static exporter downloads them like any other same-origin asset.
|
|
229
|
+
*/
|
|
230
|
+
export declare const PluginAssetsSchema: z.ZodObject<{
|
|
231
|
+
dir: z.ZodOptional<z.ZodString>;
|
|
232
|
+
scripts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
233
|
+
styles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
234
|
+
blocks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
235
|
+
scripts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
236
|
+
styles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
237
|
+
}, z.core.$strip>>>;
|
|
238
|
+
markup: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
239
|
+
match: z.ZodArray<z.ZodString>;
|
|
240
|
+
scripts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
241
|
+
styles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
242
|
+
}, z.core.$strip>>>;
|
|
243
|
+
}, z.core.$strip>;
|
|
244
|
+
/**
|
|
245
|
+
* Page templates a plugin ships in its package: `<dir>/<slug>.json` block
|
|
246
|
+
* documents (same shape as a theme's `templates/*.json`). While the plugin is
|
|
247
|
+
* active the host resolves them after the site override and the active theme's
|
|
248
|
+
* own file for that slug, so templates for plugin-owned content types (e.g.
|
|
249
|
+
* `single-product`) live with the plugin, and a theme can still override them.
|
|
250
|
+
*/
|
|
251
|
+
export declare const PluginTemplatesSchema: z.ZodObject<{
|
|
252
|
+
dir: z.ZodOptional<z.ZodString>;
|
|
253
|
+
}, z.core.$strip>;
|
|
254
|
+
declare const PluginAdminRouteSchema: z.ZodObject<{
|
|
255
|
+
path: z.ZodOptional<z.ZodString>;
|
|
256
|
+
entry: z.ZodString;
|
|
257
|
+
title: z.ZodOptional<z.ZodString>;
|
|
258
|
+
}, z.core.$strip>;
|
|
259
|
+
export type PluginAdminRoute = z.infer<typeof PluginAdminRouteSchema>;
|
|
260
|
+
/**
|
|
261
|
+
* A self-contained admin app the plugin ships in its own package. The host
|
|
262
|
+
* serves `<dir>/**` at `/ext/<pluginId>/admin/**` and, for each declared
|
|
263
|
+
* route, mounts the `entry` HTML in a same-origin `<iframe>` inside the admin
|
|
264
|
+
* shell — the plugin owns the whole screen and its design, talks only to its
|
|
265
|
+
* own `ctx.http` routes, and reaches the host through `@justflows/admin-bridge`
|
|
266
|
+
* (`postMessage`), never a shared React runtime. Requires `admin:extend`.
|
|
267
|
+
*/
|
|
268
|
+
export declare const PluginAdminAppSchema: z.ZodObject<{
|
|
269
|
+
dir: z.ZodOptional<z.ZodString>;
|
|
270
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
271
|
+
path: z.ZodOptional<z.ZodString>;
|
|
272
|
+
entry: z.ZodString;
|
|
273
|
+
title: z.ZodOptional<z.ZodString>;
|
|
274
|
+
}, z.core.$strip>>;
|
|
275
|
+
locales: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
276
|
+
}, z.core.$strip>;
|
|
277
|
+
/**
|
|
278
|
+
* Every extension id is `<namespace>.<name>`: `justflows.forms` for official
|
|
279
|
+
* extensions, `acme.forms` for a publisher that owns `acme`, and deeper ids
|
|
280
|
+
* such as `justflows.theme.dark`. The admin URL (`/admin/plugins/<id>`) and
|
|
281
|
+
* the asset mount (`/ext/<id>/…`) are built from it, so it stays lowercase
|
|
282
|
+
* letters, digits, single hyphens, and dots. See `publisher-namespace.ts` for
|
|
283
|
+
* reserved namespaces and what the namespace does and does not prove.
|
|
284
|
+
*/
|
|
285
|
+
export declare const PLUGIN_ID_RE: RegExp;
|
|
286
|
+
/** Shared message for ids that do not match `PLUGIN_ID_RE`. */
|
|
287
|
+
export declare const PLUGIN_ID_MESSAGE = "ID must be <namespace>.<name> in lowercase, for example acme.forms";
|
|
288
|
+
/**
|
|
289
|
+
* Namespace rules shared by the plugin manifest and the package manifest: the
|
|
290
|
+
* id may not use a reserved namespace other than `justflows`, and a
|
|
291
|
+
* third-party API namespace must stay inside the publisher namespace.
|
|
292
|
+
*/
|
|
293
|
+
export declare function addPublisherNamespaceIssues(manifest: {
|
|
294
|
+
id: string;
|
|
295
|
+
apiNamespace?: string | undefined;
|
|
296
|
+
}, ctx: z.RefinementCtx): void;
|
|
297
|
+
export declare const PluginManifestSchema: z.ZodPipe<z.ZodObject<{
|
|
298
|
+
id: z.ZodString;
|
|
299
|
+
apiNamespace: z.ZodOptional<z.ZodString>;
|
|
300
|
+
name: z.ZodString;
|
|
301
|
+
version: z.ZodString;
|
|
302
|
+
description: z.ZodOptional<z.ZodString>;
|
|
303
|
+
author: z.ZodOptional<z.ZodString>;
|
|
304
|
+
homepage: z.ZodOptional<z.ZodURL>;
|
|
305
|
+
license: z.ZodString;
|
|
306
|
+
engines: z.ZodOptional<z.ZodObject<{
|
|
307
|
+
justflows: z.ZodString;
|
|
308
|
+
}, z.core.$strip>>;
|
|
309
|
+
minJustflowsVersion: z.ZodOptional<z.ZodString>;
|
|
310
|
+
maxJustflowsVersion: z.ZodOptional<z.ZodString>;
|
|
311
|
+
permissions: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
312
|
+
"admin:extend": "admin:extend";
|
|
313
|
+
"auth:hook": "auth:hook";
|
|
314
|
+
"cache:store": "cache:store";
|
|
315
|
+
"content:create": "content:create";
|
|
316
|
+
"content:delete": "content:delete";
|
|
317
|
+
"content:publish": "content:publish";
|
|
318
|
+
"content:read": "content:read";
|
|
319
|
+
"content:revisions:discard": "content:revisions:discard";
|
|
320
|
+
"content:revisions:read": "content:revisions:read";
|
|
321
|
+
"content:revisions:restore": "content:revisions:restore";
|
|
322
|
+
"content:update": "content:update";
|
|
323
|
+
"diagnostics:publish": "diagnostics:publish";
|
|
324
|
+
"files:private": "files:private";
|
|
325
|
+
"jobs:register": "jobs:register";
|
|
326
|
+
"mail:hook": "mail:hook";
|
|
327
|
+
"mail:send": "mail:send";
|
|
328
|
+
"mail:templates": "mail:templates";
|
|
329
|
+
"mail:transport": "mail:transport";
|
|
330
|
+
"media:delete": "media:delete";
|
|
331
|
+
"media:read": "media:read";
|
|
332
|
+
"media:upload": "media:upload";
|
|
333
|
+
"network:outbound": "network:outbound";
|
|
334
|
+
"platform:network": "platform:network";
|
|
335
|
+
"platform:tenancy": "platform:tenancy";
|
|
336
|
+
"settings:manage": "settings:manage";
|
|
337
|
+
"settings:read": "settings:read";
|
|
338
|
+
"users:manage": "users:manage";
|
|
339
|
+
"users:read": "users:read";
|
|
340
|
+
}>>>;
|
|
341
|
+
main: z.ZodDefault<z.ZodString>;
|
|
342
|
+
allowMultisite: z.ZodOptional<z.ZodBoolean>;
|
|
343
|
+
requires: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
344
|
+
settingsSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
345
|
+
type: z.ZodEnum<{
|
|
346
|
+
boolean: "boolean";
|
|
347
|
+
number: "number";
|
|
348
|
+
select: "select";
|
|
349
|
+
string: "string";
|
|
350
|
+
text: "text";
|
|
351
|
+
}>;
|
|
352
|
+
label: z.ZodString;
|
|
353
|
+
description: z.ZodOptional<z.ZodString>;
|
|
354
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
355
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
356
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
357
|
+
value: z.ZodString;
|
|
358
|
+
label: z.ZodString;
|
|
359
|
+
}, z.core.$strip>>>;
|
|
360
|
+
optionsSource: z.ZodOptional<z.ZodEnum<{
|
|
361
|
+
countries: "countries";
|
|
362
|
+
timezones: "timezones";
|
|
363
|
+
}>>;
|
|
364
|
+
}, z.core.$strip>>>;
|
|
365
|
+
adminMenu: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
366
|
+
id: z.ZodString;
|
|
367
|
+
label: z.ZodString;
|
|
368
|
+
labelKey: z.ZodOptional<z.ZodString>;
|
|
369
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
370
|
+
path: z.ZodOptional<z.ZodString>;
|
|
371
|
+
icon: z.ZodDefault<z.ZodString>;
|
|
372
|
+
domain: z.ZodCatch<z.ZodDefault<z.ZodEnum<{
|
|
373
|
+
appearance: "appearance";
|
|
374
|
+
commerce: "commerce";
|
|
375
|
+
content: "content";
|
|
376
|
+
extensions: "extensions";
|
|
377
|
+
plugin: "plugin";
|
|
378
|
+
security: "security";
|
|
379
|
+
system: "system";
|
|
380
|
+
tools: "tools";
|
|
381
|
+
users: "users";
|
|
382
|
+
}>>>;
|
|
383
|
+
end: z.ZodOptional<z.ZodBoolean>;
|
|
384
|
+
listed: z.ZodOptional<z.ZodBoolean>;
|
|
385
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
386
|
+
badge: z.ZodOptional<z.ZodString>;
|
|
387
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
388
|
+
}, z.core.$strip>>>;
|
|
389
|
+
editorPanels: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
390
|
+
id: z.ZodString;
|
|
391
|
+
title: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
392
|
+
indexableOnly: z.ZodOptional<z.ZodBoolean>;
|
|
393
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
394
|
+
key: z.ZodString;
|
|
395
|
+
type: z.ZodEnum<{
|
|
396
|
+
checkbox: "checkbox";
|
|
397
|
+
image: "image";
|
|
398
|
+
text: "text";
|
|
399
|
+
textarea: "textarea";
|
|
400
|
+
url: "url";
|
|
401
|
+
}>;
|
|
402
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
403
|
+
hint: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
404
|
+
placeholder: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
405
|
+
}, z.core.$strip>>>;
|
|
406
|
+
app: z.ZodOptional<z.ZodString>;
|
|
407
|
+
}, z.core.$strip>>>;
|
|
408
|
+
adminSection: z.ZodOptional<z.ZodObject<{
|
|
409
|
+
label: z.ZodString;
|
|
410
|
+
labelKey: z.ZodOptional<z.ZodString>;
|
|
411
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
412
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
413
|
+
}, z.core.$strip>>;
|
|
414
|
+
workspacePanels: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
415
|
+
id: z.ZodString;
|
|
416
|
+
title: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
417
|
+
app: z.ZodString;
|
|
418
|
+
}, z.core.$strip>>>;
|
|
419
|
+
dashboardPanels: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
420
|
+
id: z.ZodString;
|
|
421
|
+
title: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
422
|
+
app: z.ZodString;
|
|
423
|
+
size: z.ZodOptional<z.ZodEnum<{
|
|
424
|
+
small: "small";
|
|
425
|
+
wide: "wide";
|
|
426
|
+
}>>;
|
|
427
|
+
}, z.core.$strip>>>;
|
|
428
|
+
setupSteps: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
429
|
+
id: z.ZodString;
|
|
430
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
431
|
+
path: z.ZodOptional<z.ZodString>;
|
|
432
|
+
status: z.ZodString;
|
|
433
|
+
}, z.core.$strip>>>;
|
|
434
|
+
adminActions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
435
|
+
id: z.ZodString;
|
|
436
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
437
|
+
path: z.ZodOptional<z.ZodString>;
|
|
438
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
439
|
+
keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
440
|
+
}, z.core.$strip>>>;
|
|
441
|
+
setupPath: z.ZodOptional<z.ZodString>;
|
|
442
|
+
registry: z.ZodOptional<z.ZodObject<{
|
|
443
|
+
commercialMarketplace: z.ZodDefault<z.ZodBoolean>;
|
|
444
|
+
listed: z.ZodDefault<z.ZodBoolean>;
|
|
445
|
+
free: z.ZodDefault<z.ZodBoolean>;
|
|
446
|
+
comingSoon: z.ZodDefault<z.ZodBoolean>;
|
|
447
|
+
beta: z.ZodOptional<z.ZodBoolean>;
|
|
448
|
+
category: z.ZodOptional<z.ZodString>;
|
|
449
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
450
|
+
screenshots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
451
|
+
price: z.ZodOptional<z.ZodObject<{
|
|
452
|
+
amount: z.ZodNumber;
|
|
453
|
+
currency: z.ZodString;
|
|
454
|
+
interval: z.ZodDefault<z.ZodEnum<{
|
|
455
|
+
month: "month";
|
|
456
|
+
once: "once";
|
|
457
|
+
year: "year";
|
|
458
|
+
}>>;
|
|
459
|
+
}, z.core.$strip>>;
|
|
460
|
+
}, z.core.$strip>>;
|
|
461
|
+
contentTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
462
|
+
assets: z.ZodOptional<z.ZodObject<{
|
|
463
|
+
dir: z.ZodOptional<z.ZodString>;
|
|
464
|
+
scripts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
465
|
+
styles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
466
|
+
blocks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
467
|
+
scripts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
468
|
+
styles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
469
|
+
}, z.core.$strip>>>;
|
|
470
|
+
markup: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
471
|
+
match: z.ZodArray<z.ZodString>;
|
|
472
|
+
scripts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
473
|
+
styles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
474
|
+
}, z.core.$strip>>>;
|
|
475
|
+
}, z.core.$strip>>;
|
|
476
|
+
templates: z.ZodOptional<z.ZodObject<{
|
|
477
|
+
dir: z.ZodOptional<z.ZodString>;
|
|
478
|
+
}, z.core.$strip>>;
|
|
479
|
+
adminApp: z.ZodOptional<z.ZodObject<{
|
|
480
|
+
dir: z.ZodOptional<z.ZodString>;
|
|
481
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
482
|
+
path: z.ZodOptional<z.ZodString>;
|
|
483
|
+
entry: z.ZodString;
|
|
484
|
+
title: z.ZodOptional<z.ZodString>;
|
|
485
|
+
}, z.core.$strip>>;
|
|
486
|
+
locales: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
487
|
+
}, z.core.$strip>>;
|
|
488
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
489
|
+
id: string;
|
|
490
|
+
apiNamespace?: string | undefined;
|
|
491
|
+
name: string;
|
|
492
|
+
version: string;
|
|
493
|
+
description?: string | undefined;
|
|
494
|
+
author?: string | undefined;
|
|
495
|
+
homepage?: string | undefined;
|
|
496
|
+
license: string;
|
|
497
|
+
engines?: {
|
|
498
|
+
justflows: string;
|
|
499
|
+
} | undefined;
|
|
500
|
+
minJustflowsVersion?: string | undefined;
|
|
501
|
+
maxJustflowsVersion?: string | undefined;
|
|
502
|
+
permissions: ("admin:extend" | "auth:hook" | "cache:store" | "content:create" | "content:delete" | "content:publish" | "content:read" | "content:revisions:discard" | "content:revisions:read" | "content:revisions:restore" | "content:update" | "diagnostics:publish" | "files:private" | "jobs:register" | "mail:hook" | "mail:send" | "mail:templates" | "mail:transport" | "media:delete" | "media:read" | "media:upload" | "network:outbound" | "platform:network" | "platform:tenancy" | "settings:manage" | "settings:read" | "users:manage" | "users:read")[];
|
|
503
|
+
main: string;
|
|
504
|
+
allowMultisite?: boolean | undefined;
|
|
505
|
+
requires?: string[] | undefined;
|
|
506
|
+
settingsSchema?: Record<string, {
|
|
507
|
+
type: "boolean" | "number" | "select" | "string" | "text";
|
|
508
|
+
label: string;
|
|
509
|
+
description?: string | undefined;
|
|
510
|
+
default?: unknown;
|
|
511
|
+
localized?: boolean | undefined;
|
|
512
|
+
options?: {
|
|
513
|
+
value: string;
|
|
514
|
+
label: string;
|
|
515
|
+
}[] | undefined;
|
|
516
|
+
optionsSource?: "countries" | "timezones" | undefined;
|
|
517
|
+
}> | undefined;
|
|
518
|
+
adminMenu?: {
|
|
519
|
+
id: string;
|
|
520
|
+
label: string;
|
|
521
|
+
labelKey?: string | undefined;
|
|
522
|
+
labels?: Record<string, string> | undefined;
|
|
523
|
+
path?: string | undefined;
|
|
524
|
+
icon: string;
|
|
525
|
+
domain: "appearance" | "commerce" | "content" | "extensions" | "plugin" | "security" | "system" | "tools" | "users";
|
|
526
|
+
end?: boolean | undefined;
|
|
527
|
+
listed?: boolean | undefined;
|
|
528
|
+
roles?: string[] | undefined;
|
|
529
|
+
badge?: string | undefined;
|
|
530
|
+
contentType?: string | undefined;
|
|
531
|
+
}[] | undefined;
|
|
532
|
+
editorPanels?: {
|
|
533
|
+
id: string;
|
|
534
|
+
title: string | Record<string, string>;
|
|
535
|
+
indexableOnly?: boolean | undefined;
|
|
536
|
+
fields?: {
|
|
537
|
+
key: string;
|
|
538
|
+
type: "checkbox" | "image" | "text" | "textarea" | "url";
|
|
539
|
+
label: string | Record<string, string>;
|
|
540
|
+
hint?: string | Record<string, string> | undefined;
|
|
541
|
+
placeholder?: string | Record<string, string> | undefined;
|
|
542
|
+
}[] | undefined;
|
|
543
|
+
app?: string | undefined;
|
|
544
|
+
}[] | undefined;
|
|
545
|
+
adminSection?: {
|
|
546
|
+
label: string;
|
|
547
|
+
labelKey?: string | undefined;
|
|
548
|
+
labels?: Record<string, string> | undefined;
|
|
549
|
+
icon?: string | undefined;
|
|
550
|
+
} | undefined;
|
|
551
|
+
workspacePanels?: {
|
|
552
|
+
id: string;
|
|
553
|
+
title: string | Record<string, string>;
|
|
554
|
+
app: string;
|
|
555
|
+
}[] | undefined;
|
|
556
|
+
dashboardPanels?: {
|
|
557
|
+
id: string;
|
|
558
|
+
title: string | Record<string, string>;
|
|
559
|
+
app: string;
|
|
560
|
+
size?: "small" | "wide" | undefined;
|
|
561
|
+
}[] | undefined;
|
|
562
|
+
setupSteps?: {
|
|
563
|
+
id: string;
|
|
564
|
+
label: string | Record<string, string>;
|
|
565
|
+
path?: string | undefined;
|
|
566
|
+
status: string;
|
|
567
|
+
}[] | undefined;
|
|
568
|
+
adminActions?: {
|
|
569
|
+
id: string;
|
|
570
|
+
label: string | Record<string, string>;
|
|
571
|
+
path?: string | undefined;
|
|
572
|
+
icon?: string | undefined;
|
|
573
|
+
keywords?: string[] | undefined;
|
|
574
|
+
}[] | undefined;
|
|
575
|
+
setupPath?: string | undefined;
|
|
576
|
+
registry?: {
|
|
577
|
+
commercialMarketplace: boolean;
|
|
578
|
+
listed: boolean;
|
|
579
|
+
free: boolean;
|
|
580
|
+
comingSoon: boolean;
|
|
581
|
+
beta?: boolean | undefined;
|
|
582
|
+
category?: string | undefined;
|
|
583
|
+
tags?: string[] | undefined;
|
|
584
|
+
screenshots?: string[] | undefined;
|
|
585
|
+
price?: {
|
|
586
|
+
amount: number;
|
|
587
|
+
currency: string;
|
|
588
|
+
interval: "month" | "once" | "year";
|
|
589
|
+
} | undefined;
|
|
590
|
+
} | undefined;
|
|
591
|
+
contentTypes?: string[] | undefined;
|
|
592
|
+
assets?: {
|
|
593
|
+
dir?: string | undefined;
|
|
594
|
+
scripts?: string[] | undefined;
|
|
595
|
+
styles?: string[] | undefined;
|
|
596
|
+
blocks?: Record<string, {
|
|
597
|
+
scripts?: string[] | undefined;
|
|
598
|
+
styles?: string[] | undefined;
|
|
599
|
+
}> | undefined;
|
|
600
|
+
markup?: {
|
|
601
|
+
match: string[];
|
|
602
|
+
scripts?: string[] | undefined;
|
|
603
|
+
styles?: string[] | undefined;
|
|
604
|
+
}[] | undefined;
|
|
605
|
+
} | undefined;
|
|
606
|
+
templates?: {
|
|
607
|
+
dir?: string | undefined;
|
|
608
|
+
} | undefined;
|
|
609
|
+
adminApp?: {
|
|
610
|
+
dir?: string | undefined;
|
|
611
|
+
routes: {
|
|
612
|
+
path?: string | undefined;
|
|
613
|
+
entry: string;
|
|
614
|
+
title?: string | undefined;
|
|
615
|
+
}[];
|
|
616
|
+
locales?: Record<string, string> | undefined;
|
|
617
|
+
} | undefined;
|
|
618
|
+
}, {
|
|
619
|
+
id: string;
|
|
620
|
+
apiNamespace?: string | undefined;
|
|
621
|
+
name: string;
|
|
622
|
+
version: string;
|
|
623
|
+
description?: string | undefined;
|
|
624
|
+
author?: string | undefined;
|
|
625
|
+
homepage?: string | undefined;
|
|
626
|
+
license: string;
|
|
627
|
+
engines?: {
|
|
628
|
+
justflows: string;
|
|
629
|
+
} | undefined;
|
|
630
|
+
minJustflowsVersion?: string | undefined;
|
|
631
|
+
maxJustflowsVersion?: string | undefined;
|
|
632
|
+
permissions: ("admin:extend" | "auth:hook" | "cache:store" | "content:create" | "content:delete" | "content:publish" | "content:read" | "content:revisions:discard" | "content:revisions:read" | "content:revisions:restore" | "content:update" | "diagnostics:publish" | "files:private" | "jobs:register" | "mail:hook" | "mail:send" | "mail:templates" | "mail:transport" | "media:delete" | "media:read" | "media:upload" | "network:outbound" | "platform:network" | "platform:tenancy" | "settings:manage" | "settings:read" | "users:manage" | "users:read")[];
|
|
633
|
+
main: string;
|
|
634
|
+
allowMultisite?: boolean | undefined;
|
|
635
|
+
requires?: string[] | undefined;
|
|
636
|
+
settingsSchema?: Record<string, {
|
|
637
|
+
type: "boolean" | "number" | "select" | "string" | "text";
|
|
638
|
+
label: string;
|
|
639
|
+
description?: string | undefined;
|
|
640
|
+
default?: unknown;
|
|
641
|
+
localized?: boolean | undefined;
|
|
642
|
+
options?: {
|
|
643
|
+
value: string;
|
|
644
|
+
label: string;
|
|
645
|
+
}[] | undefined;
|
|
646
|
+
optionsSource?: "countries" | "timezones" | undefined;
|
|
647
|
+
}> | undefined;
|
|
648
|
+
adminMenu?: {
|
|
649
|
+
id: string;
|
|
650
|
+
label: string;
|
|
651
|
+
labelKey?: string | undefined;
|
|
652
|
+
labels?: Record<string, string> | undefined;
|
|
653
|
+
path?: string | undefined;
|
|
654
|
+
icon: string;
|
|
655
|
+
domain: "appearance" | "commerce" | "content" | "extensions" | "plugin" | "security" | "system" | "tools" | "users";
|
|
656
|
+
end?: boolean | undefined;
|
|
657
|
+
listed?: boolean | undefined;
|
|
658
|
+
roles?: string[] | undefined;
|
|
659
|
+
badge?: string | undefined;
|
|
660
|
+
contentType?: string | undefined;
|
|
661
|
+
}[] | undefined;
|
|
662
|
+
editorPanels?: {
|
|
663
|
+
id: string;
|
|
664
|
+
title: string | Record<string, string>;
|
|
665
|
+
indexableOnly?: boolean | undefined;
|
|
666
|
+
fields?: {
|
|
667
|
+
key: string;
|
|
668
|
+
type: "checkbox" | "image" | "text" | "textarea" | "url";
|
|
669
|
+
label: string | Record<string, string>;
|
|
670
|
+
hint?: string | Record<string, string> | undefined;
|
|
671
|
+
placeholder?: string | Record<string, string> | undefined;
|
|
672
|
+
}[] | undefined;
|
|
673
|
+
app?: string | undefined;
|
|
674
|
+
}[] | undefined;
|
|
675
|
+
adminSection?: {
|
|
676
|
+
label: string;
|
|
677
|
+
labelKey?: string | undefined;
|
|
678
|
+
labels?: Record<string, string> | undefined;
|
|
679
|
+
icon?: string | undefined;
|
|
680
|
+
} | undefined;
|
|
681
|
+
workspacePanels?: {
|
|
682
|
+
id: string;
|
|
683
|
+
title: string | Record<string, string>;
|
|
684
|
+
app: string;
|
|
685
|
+
}[] | undefined;
|
|
686
|
+
dashboardPanels?: {
|
|
687
|
+
id: string;
|
|
688
|
+
title: string | Record<string, string>;
|
|
689
|
+
app: string;
|
|
690
|
+
size?: "small" | "wide" | undefined;
|
|
691
|
+
}[] | undefined;
|
|
692
|
+
setupSteps?: {
|
|
693
|
+
id: string;
|
|
694
|
+
label: string | Record<string, string>;
|
|
695
|
+
path?: string | undefined;
|
|
696
|
+
status: string;
|
|
697
|
+
}[] | undefined;
|
|
698
|
+
adminActions?: {
|
|
699
|
+
id: string;
|
|
700
|
+
label: string | Record<string, string>;
|
|
701
|
+
path?: string | undefined;
|
|
702
|
+
icon?: string | undefined;
|
|
703
|
+
keywords?: string[] | undefined;
|
|
704
|
+
}[] | undefined;
|
|
705
|
+
setupPath?: string | undefined;
|
|
706
|
+
registry?: {
|
|
707
|
+
commercialMarketplace: boolean;
|
|
708
|
+
listed: boolean;
|
|
709
|
+
free: boolean;
|
|
710
|
+
comingSoon: boolean;
|
|
711
|
+
beta?: boolean | undefined;
|
|
712
|
+
category?: string | undefined;
|
|
713
|
+
tags?: string[] | undefined;
|
|
714
|
+
screenshots?: string[] | undefined;
|
|
715
|
+
price?: {
|
|
716
|
+
amount: number;
|
|
717
|
+
currency: string;
|
|
718
|
+
interval: "month" | "once" | "year";
|
|
719
|
+
} | undefined;
|
|
720
|
+
} | undefined;
|
|
721
|
+
contentTypes?: string[] | undefined;
|
|
722
|
+
assets?: {
|
|
723
|
+
dir?: string | undefined;
|
|
724
|
+
scripts?: string[] | undefined;
|
|
725
|
+
styles?: string[] | undefined;
|
|
726
|
+
blocks?: Record<string, {
|
|
727
|
+
scripts?: string[] | undefined;
|
|
728
|
+
styles?: string[] | undefined;
|
|
729
|
+
}> | undefined;
|
|
730
|
+
markup?: {
|
|
731
|
+
match: string[];
|
|
732
|
+
scripts?: string[] | undefined;
|
|
733
|
+
styles?: string[] | undefined;
|
|
734
|
+
}[] | undefined;
|
|
735
|
+
} | undefined;
|
|
736
|
+
templates?: {
|
|
737
|
+
dir?: string | undefined;
|
|
738
|
+
} | undefined;
|
|
739
|
+
adminApp?: {
|
|
740
|
+
dir?: string | undefined;
|
|
741
|
+
routes: {
|
|
742
|
+
path?: string | undefined;
|
|
743
|
+
entry: string;
|
|
744
|
+
title?: string | undefined;
|
|
745
|
+
}[];
|
|
746
|
+
locales?: Record<string, string> | undefined;
|
|
747
|
+
} | undefined;
|
|
748
|
+
}>>;
|
|
749
|
+
export type PluginManifest = z.infer<typeof PluginManifestSchema>;
|
|
750
|
+
/** One field of a plugin's `settingsSchema`. */
|
|
751
|
+
export type PluginSettingsField = NonNullable<PluginManifest["settingsSchema"]>[string];
|
|
752
|
+
/**
|
|
753
|
+
* Namespaced access to the shared jf-cache. Every key is stored under
|
|
754
|
+
* `plugin:{pluginId}:…` so plugins cannot read or wipe core / other-plugin keys.
|
|
755
|
+
*/
|
|
756
|
+
export interface PluginCacheApi {
|
|
757
|
+
readonly enabled: boolean;
|
|
758
|
+
/** Read-through cache with in-flight deduplication. */
|
|
759
|
+
remember<T>(key: string, ttlSeconds: number, fn: () => Promise<T>): Promise<T>;
|
|
760
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
761
|
+
set<T = unknown>(key: string, value: T, ttlSeconds?: number): Promise<void>;
|
|
762
|
+
delete(key: string): Promise<void>;
|
|
763
|
+
/**
|
|
764
|
+
* Invalidate keys under this plugin's namespace.
|
|
765
|
+
* Pass a relative prefix (e.g. `"products:"`) or omit to clear the whole plugin tree.
|
|
766
|
+
*/
|
|
767
|
+
invalidate(prefix?: string): Promise<void>;
|
|
768
|
+
/**
|
|
769
|
+
* Offer a store that can back the whole installation's jf-cache, such as an
|
|
770
|
+
* external key-value service shared by several application processes. The
|
|
771
|
+
* operator picks it as the cache driver in Admin → Tools (its id there is
|
|
772
|
+
* `plugin:<pluginId>.<id>`). Requires `cache:store` and is honoured only
|
|
773
|
+
* while the plugin is active on the main site. Removed on deactivate.
|
|
774
|
+
* Absent on older hosts. Available from SDK 0.1.9.
|
|
775
|
+
*/
|
|
776
|
+
registerStore?(definition: CacheStoreDefinition): void;
|
|
777
|
+
}
|
|
778
|
+
export interface PluginCapabilitiesApi {
|
|
779
|
+
/** Register a user capability for as long as this plugin is active. */
|
|
780
|
+
register(definition: UserCapabilityDefinition): void;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* A user role this plugin contributes while it is active. The id is stored on
|
|
784
|
+
* `users.role` (for example a `customer` role). It must not replace a core role.
|
|
785
|
+
*/
|
|
786
|
+
export interface PluginRoleDefinition {
|
|
787
|
+
/** Lowercase id, 2–32 characters: letters, digits, and hyphens. */
|
|
788
|
+
readonly id: string;
|
|
789
|
+
readonly label: string;
|
|
790
|
+
readonly description?: string;
|
|
791
|
+
/** Capabilities granted to this role. Empty means no administration access. */
|
|
792
|
+
readonly capabilities?: readonly UserCapability[];
|
|
793
|
+
}
|
|
794
|
+
export interface PluginRolesApi {
|
|
795
|
+
/** Register a user role for as long as this plugin is active. */
|
|
796
|
+
register(definition: PluginRoleDefinition): void;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Signed-in staff member a plugin attributes a user mutation to. For an account
|
|
800
|
+
* a visitor creates for themselves (for example at a shop checkout), pass an
|
|
801
|
+
* empty `userId`; the audit log then records the change without an actor.
|
|
802
|
+
*/
|
|
803
|
+
export interface PluginUserActor {
|
|
804
|
+
userId: string;
|
|
805
|
+
role: string;
|
|
806
|
+
}
|
|
807
|
+
export interface PluginUserCreateInput {
|
|
808
|
+
email: string;
|
|
809
|
+
username: string;
|
|
810
|
+
displayName: string;
|
|
811
|
+
password: string;
|
|
812
|
+
/** Must be a role this plugin registered. Core roles are rejected. */
|
|
813
|
+
role: string;
|
|
814
|
+
}
|
|
815
|
+
export interface PluginCreatedUser {
|
|
816
|
+
id: string;
|
|
817
|
+
email: string;
|
|
818
|
+
username: string;
|
|
819
|
+
displayName: string;
|
|
820
|
+
role: string;
|
|
821
|
+
/**
|
|
822
|
+
* The member's date of birth (`YYYY-MM-DD`) when they gave one, for
|
|
823
|
+
* checking an age. Returned by `find` and `get` only; absent on older
|
|
824
|
+
* hosts and from `create` and `search`. Personal data: do not show it to
|
|
825
|
+
* other members or copy it further than the check needs.
|
|
826
|
+
*/
|
|
827
|
+
birthDate?: string | null;
|
|
828
|
+
}
|
|
829
|
+
export type PluginUserCreateResult = {
|
|
830
|
+
ok: true;
|
|
831
|
+
user: PluginCreatedUser;
|
|
832
|
+
} | {
|
|
833
|
+
ok: false;
|
|
834
|
+
status: number;
|
|
835
|
+
error: string;
|
|
836
|
+
};
|
|
837
|
+
/** Which existing user `ctx.users.addRole()` targets: by id or by sign-in email. */
|
|
838
|
+
export type PluginUserTarget = {
|
|
839
|
+
userId: string;
|
|
840
|
+
} | {
|
|
841
|
+
email: string;
|
|
842
|
+
};
|
|
843
|
+
/** The sign-in factors an account has beyond its password. */
|
|
844
|
+
export interface PluginUserSecondFactors {
|
|
845
|
+
/** An authenticator app (TOTP) is turned on. */
|
|
846
|
+
totp: boolean;
|
|
847
|
+
/** How many passkeys the account has registered. */
|
|
848
|
+
passkeys: number;
|
|
849
|
+
}
|
|
850
|
+
export interface PluginRoleUser extends PluginCreatedUser {
|
|
851
|
+
/** Primary role first, then additional roles. */
|
|
852
|
+
roles: readonly string[];
|
|
853
|
+
}
|
|
854
|
+
export type PluginUserRoleResult = {
|
|
855
|
+
ok: true;
|
|
856
|
+
user: PluginRoleUser;
|
|
857
|
+
} | {
|
|
858
|
+
ok: false;
|
|
859
|
+
status: number;
|
|
860
|
+
error: string;
|
|
861
|
+
};
|
|
862
|
+
export interface PluginUsersApi {
|
|
863
|
+
/**
|
|
864
|
+
* Create a site user in a role this plugin registered.
|
|
865
|
+
* Requires the `users:manage` manifest permission. The host still applies
|
|
866
|
+
* password policy, uniqueness, and audit logging.
|
|
867
|
+
*/
|
|
868
|
+
create(input: PluginUserCreateInput, actor: PluginUserActor): Promise<PluginUserCreateResult>;
|
|
869
|
+
/**
|
|
870
|
+
* Give an existing user a role this plugin registered, as an additional
|
|
871
|
+
* role next to the one they have. Their primary role, sign-in, and every
|
|
872
|
+
* other role stay as they are; the new role's capabilities are added.
|
|
873
|
+
* Doing nothing when the user already holds the role is a success.
|
|
874
|
+
* Requires the `users:manage` manifest permission.
|
|
875
|
+
* Optional: older hosts do not provide it.
|
|
876
|
+
*/
|
|
877
|
+
addRole?(target: PluginUserTarget, role: string, actor: PluginUserActor): Promise<PluginUserRoleResult>;
|
|
878
|
+
/**
|
|
879
|
+
* Read one site user with all their roles, or null when there is none.
|
|
880
|
+
* Requires the `users:manage` manifest permission. Use it from a
|
|
881
|
+
* `user.created` / `user.updated` action to react to role changes.
|
|
882
|
+
* Optional: older hosts do not provide it.
|
|
883
|
+
*/
|
|
884
|
+
get?(userId: string): Promise<PluginRoleUser | null>;
|
|
885
|
+
/**
|
|
886
|
+
* Find one site user by id or by sign-in email (case-insensitive), with all
|
|
887
|
+
* their roles, or null when there is none. For attaching something a
|
|
888
|
+
* customer bought or was given to their existing account.
|
|
889
|
+
* Requires the `users:read` manifest permission.
|
|
890
|
+
* Optional: older hosts do not provide it.
|
|
891
|
+
*/
|
|
892
|
+
find?(target: PluginUserTarget): Promise<PluginRoleUser | null>;
|
|
893
|
+
/**
|
|
894
|
+
* Site users whose email, username, or display name contains `query`
|
|
895
|
+
* (case-insensitive), at most `limit` (default 20, at most 50), ordered by
|
|
896
|
+
* display name, then email, then id. `offset` skips that many matches
|
|
897
|
+
* (default 0, at most 100000) so a caller can read the list in pages.
|
|
898
|
+
* For letting staff pick an existing account. An empty query lists users
|
|
899
|
+
* in that order. Requires the `users:read` manifest permission.
|
|
900
|
+
* Optional: older hosts do not provide it, and hosts that predate `offset`
|
|
901
|
+
* ignore it and always return the first page.
|
|
902
|
+
*/
|
|
903
|
+
search?(input: {
|
|
904
|
+
query: string;
|
|
905
|
+
limit?: number;
|
|
906
|
+
offset?: number;
|
|
907
|
+
}): Promise<PluginCreatedUser[]>;
|
|
908
|
+
/**
|
|
909
|
+
* Which second factors an account on this site has: an authenticator app
|
|
910
|
+
* and a count of passkeys. Null when the user is not on this site. For
|
|
911
|
+
* features that should only open to accounts with a second factor; the
|
|
912
|
+
* host's own sign-in policy still decides how people sign in. Requires the
|
|
913
|
+
* `users:read` manifest permission. Optional: older hosts do not provide it.
|
|
914
|
+
*/
|
|
915
|
+
secondFactors?(userId: string): Promise<PluginUserSecondFactors | null>;
|
|
916
|
+
/**
|
|
917
|
+
* Take back an additional role this plugin registered, such as a membership
|
|
918
|
+
* that ended. The user's primary role is never changed. Doing nothing when
|
|
919
|
+
* the user does not hold the role is a success.
|
|
920
|
+
* Requires the `users:manage` manifest permission.
|
|
921
|
+
* Optional: older hosts do not provide it.
|
|
922
|
+
*/
|
|
923
|
+
removeRole?(target: PluginUserTarget, role: string, actor: PluginUserActor): Promise<PluginUserRoleResult>;
|
|
924
|
+
/**
|
|
925
|
+
* Email a user a single-use link (valid three days) to choose their
|
|
926
|
+
* password, on the sign-in pages their account belongs to. For accounts a
|
|
927
|
+
* plugin made for someone with `create`, who never typed a password. Only
|
|
928
|
+
* users holding a role this plugin registered. Nothing changes until the
|
|
929
|
+
* person uses the link. Requires the `users:manage` manifest permission.
|
|
930
|
+
* Optional: older hosts do not provide it.
|
|
931
|
+
*/
|
|
932
|
+
sendPasswordSetup?(target: PluginUserTarget, actor: PluginUserActor): Promise<PluginPasswordSetupResult>;
|
|
933
|
+
/**
|
|
934
|
+
* Delete an account this plugin is wholly responsible for: every role the
|
|
935
|
+
* user holds is one this plugin registered (so never an administrator,
|
|
936
|
+
* a member who signed up themselves, or someone another plugin manages).
|
|
937
|
+
* For removing accounts the plugin made, such as demo data. Fires
|
|
938
|
+
* `user.deleted` like any deletion. Requires the `users:manage` manifest
|
|
939
|
+
* permission. Optional: older hosts do not provide it.
|
|
940
|
+
*/
|
|
941
|
+
delete?(target: PluginUserTarget, actor: PluginUserActor): Promise<{
|
|
942
|
+
ok: true;
|
|
943
|
+
} | {
|
|
944
|
+
ok: false;
|
|
945
|
+
status: number;
|
|
946
|
+
error: string;
|
|
947
|
+
}>;
|
|
948
|
+
/**
|
|
949
|
+
* Set profile fields on an account, so a value is kept in one place (the
|
|
950
|
+
* account) instead of in the plugin. Allowed for the signed-in member's
|
|
951
|
+
* own account when they act (`actor.userId` is the target), or for an
|
|
952
|
+
* account whose every role this plugin registered. `birthDate` is
|
|
953
|
+
* `YYYY-MM-DD` or null; the host checks it, audits the change without the
|
|
954
|
+
* value, and fires `user.updated`. Requires the `users:manage` manifest
|
|
955
|
+
* permission. Optional: older hosts do not provide it.
|
|
956
|
+
*/
|
|
957
|
+
updateProfile?(target: PluginUserTarget, fields: {
|
|
958
|
+
birthDate?: string | null;
|
|
959
|
+
}, actor: PluginUserActor): Promise<{
|
|
960
|
+
ok: true;
|
|
961
|
+
} | {
|
|
962
|
+
ok: false;
|
|
963
|
+
status: number;
|
|
964
|
+
error: string;
|
|
965
|
+
}>;
|
|
966
|
+
}
|
|
967
|
+
export type PluginPasswordSetupResult = {
|
|
968
|
+
ok: true;
|
|
969
|
+
expiresAt: string;
|
|
970
|
+
} | {
|
|
971
|
+
ok: false;
|
|
972
|
+
status: number;
|
|
973
|
+
error: string;
|
|
974
|
+
};
|
|
975
|
+
/** The signed-in user behind a plugin request, when there is one. */
|
|
976
|
+
export interface PluginHttpSession {
|
|
977
|
+
userId: string;
|
|
978
|
+
siteId: string;
|
|
979
|
+
role: string;
|
|
980
|
+
/**
|
|
981
|
+
* Primary role first, then any additional roles. Absent on older hosts;
|
|
982
|
+
* fall back to `[role]`.
|
|
983
|
+
*/
|
|
984
|
+
roles?: readonly string[];
|
|
985
|
+
email: string;
|
|
986
|
+
/**
|
|
987
|
+
* The name shown for this account (`users.display_name`, or the username).
|
|
988
|
+
* Absent on older hosts and when the user record has no name.
|
|
989
|
+
*/
|
|
990
|
+
displayName?: string;
|
|
991
|
+
/** Effective grants after role, per-user additions, and explicit denies. */
|
|
992
|
+
capabilities: readonly UserCapability[];
|
|
993
|
+
/** Resource constraints the host enforces for scoped operations. */
|
|
994
|
+
scopes: AccessPolicy["scopes"];
|
|
995
|
+
}
|
|
996
|
+
/** The Discussion CAPTCHA, without the secret. Null when no provider is configured. */
|
|
997
|
+
export interface PluginCaptchaConfig {
|
|
998
|
+
provider: "turnstile" | "hcaptcha" | "recaptcha" | "recaptcha-v3";
|
|
999
|
+
siteKey: string;
|
|
1000
|
+
field: string;
|
|
1001
|
+
scriptSrc: string;
|
|
1002
|
+
widgetClass: string;
|
|
1003
|
+
}
|
|
1004
|
+
/** Verify the site's Settings → Discussion CAPTCHA. The secret never leaves the host. */
|
|
1005
|
+
export interface PluginCaptchaApi {
|
|
1006
|
+
config(): Promise<PluginCaptchaConfig | null>;
|
|
1007
|
+
verify(token: string, action?: string, ip?: string): Promise<boolean>;
|
|
1008
|
+
}
|
|
1009
|
+
/** One in-process call to another active plugin's HTTP route, as the given session. */
|
|
1010
|
+
export interface PluginCallRequest {
|
|
1011
|
+
method: PluginHttpMethod;
|
|
1012
|
+
/** Path relative to that plugin, such as `orders` or `payments/attempts/:id/refund`. */
|
|
1013
|
+
path: string;
|
|
1014
|
+
query?: Record<string, string>;
|
|
1015
|
+
body?: unknown;
|
|
1016
|
+
session?: PluginHttpSession | null;
|
|
1017
|
+
/**
|
|
1018
|
+
* Run the route as this site. The caller needs `platform:tenancy`. The host
|
|
1019
|
+
* allows only another active site in the same workspace, and the plugin
|
|
1020
|
+
* that is called still checks the session. Absent means the
|
|
1021
|
+
* current site. Older hosts ignore this field.
|
|
1022
|
+
*/
|
|
1023
|
+
siteId?: string;
|
|
1024
|
+
}
|
|
1025
|
+
export interface PluginBridgeApi {
|
|
1026
|
+
call(pluginId: string, request: PluginCallRequest): Promise<PluginHttpResponse>;
|
|
1027
|
+
}
|
|
1028
|
+
/** One short completion from the site's configured assistant. */
|
|
1029
|
+
export interface PluginAiResult {
|
|
1030
|
+
ok: boolean;
|
|
1031
|
+
text?: string;
|
|
1032
|
+
error?: string;
|
|
1033
|
+
}
|
|
1034
|
+
export interface PluginAiApi {
|
|
1035
|
+
/**
|
|
1036
|
+
* `system` is the plugin's own role for the assistant, such as drafting a
|
|
1037
|
+
* support reply. The host always adds that `text` is data written by someone
|
|
1038
|
+
* else and must not be followed as instructions.
|
|
1039
|
+
*/
|
|
1040
|
+
complete(input: {
|
|
1041
|
+
instruction: string;
|
|
1042
|
+
text: string;
|
|
1043
|
+
system?: string;
|
|
1044
|
+
}): Promise<PluginAiResult>;
|
|
1045
|
+
}
|
|
1046
|
+
export type PluginHttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
1047
|
+
export interface PluginHttpRequest {
|
|
1048
|
+
method: PluginHttpMethod;
|
|
1049
|
+
path: string;
|
|
1050
|
+
query: Record<string, string>;
|
|
1051
|
+
params: Record<string, string>;
|
|
1052
|
+
body: unknown;
|
|
1053
|
+
/**
|
|
1054
|
+
* Exact request bytes for signature checks. Set only for routes that opt in
|
|
1055
|
+
* at the host JSON parser, such as payment webhooks. Absent for every other
|
|
1056
|
+
* plugin route.
|
|
1057
|
+
*/
|
|
1058
|
+
rawBody?: string;
|
|
1059
|
+
/**
|
|
1060
|
+
* Request headers, with `cookie` and `authorization` removed — a plugin route
|
|
1061
|
+
* has no reason to read the session cookie, and handing it over made every
|
|
1062
|
+
* installed plugin a credential holder. Use `session` for identity.
|
|
1063
|
+
*/
|
|
1064
|
+
headers: Record<string, string>;
|
|
1065
|
+
/**
|
|
1066
|
+
* The caller's session, or null when anonymous.
|
|
1067
|
+
*
|
|
1068
|
+
* Plugin routes are public unless the handler checks this. There was no way to
|
|
1069
|
+
* check at all before, so every plugin endpoint was unauthenticated by
|
|
1070
|
+
* construction, whatever its author intended.
|
|
1071
|
+
*/
|
|
1072
|
+
session: PluginHttpSession | null;
|
|
1073
|
+
/**
|
|
1074
|
+
* True when the browser's `Origin` is this site or an origin the host
|
|
1075
|
+
* vouches for (the same allow-list `cors` uses). False for any other
|
|
1076
|
+
* `Origin`, and absent when the request carried none, as a same-origin GET
|
|
1077
|
+
* or a non-browser client does. Use it to ignore a beacon another site fires
|
|
1078
|
+
* at this one. Absent on older hosts.
|
|
1079
|
+
*/
|
|
1080
|
+
trustedOrigin?: boolean;
|
|
1081
|
+
/**
|
|
1082
|
+
* The visitor's language: the locale of the site page that made the request
|
|
1083
|
+
* (`/nl-NL/shop` → `nl-NL`), otherwise the site default. Pass it to
|
|
1084
|
+
* `ctx.content.listPublished({ locale, fallback: true })` to answer in the
|
|
1085
|
+
* visitor's language. Absent on older hosts.
|
|
1086
|
+
*/
|
|
1087
|
+
locale?: string;
|
|
1088
|
+
}
|
|
1089
|
+
export interface PluginHttpResponse {
|
|
1090
|
+
status?: number;
|
|
1091
|
+
headers?: Record<string, string>;
|
|
1092
|
+
body?: string | Buffer | Record<string, unknown> | unknown[];
|
|
1093
|
+
type?: string;
|
|
1094
|
+
/**
|
|
1095
|
+
* Ask the host to run site-wide cache revalidation once this response is
|
|
1096
|
+
* sent. Set it on a non-GET route that changed something public pages
|
|
1097
|
+
* reflect — a setting the plugin injects via `html.head`, a block's stored
|
|
1098
|
+
* config — so page caches drop and, when static-export auto-rebuild is on,
|
|
1099
|
+
* the export regenerates. Ignored on GET and on a 4xx/5xx status.
|
|
1100
|
+
*
|
|
1101
|
+
* `"network"` does the same for every site in the installation. It needs
|
|
1102
|
+
* `platform:network` and a request on the main site; otherwise it acts as
|
|
1103
|
+
* `true`. Use it after saving something `{ network: true }` hooks inject.
|
|
1104
|
+
*/
|
|
1105
|
+
revalidate?: boolean | "network";
|
|
1106
|
+
/**
|
|
1107
|
+
* Answer with one of this plugin's private files (`ctx.files`) instead of a
|
|
1108
|
+
* body. The host streams it from wherever the site stores private files,
|
|
1109
|
+
* honours `Range` requests, and never reveals the storage address. Only the
|
|
1110
|
+
* route's own plugin's files on the current site can be sent. A missing
|
|
1111
|
+
* file answers 404.
|
|
1112
|
+
*/
|
|
1113
|
+
file?: {
|
|
1114
|
+
key: string;
|
|
1115
|
+
/** Download name; defaults to the key's last segment. */
|
|
1116
|
+
filename?: string;
|
|
1117
|
+
/** `attachment` (default) asks the browser to save it. */
|
|
1118
|
+
disposition?: "attachment" | "inline";
|
|
1119
|
+
};
|
|
1120
|
+
/**
|
|
1121
|
+
* Let a statically-exported page (served from a different origin) read this
|
|
1122
|
+
* response cross-origin. The host adds `Access-Control-Allow-Origin` for
|
|
1123
|
+
* vouched-for origins only — `APP_URL`, `STATIC_EXPORT_BASE_URL`, anything in
|
|
1124
|
+
* `STATIC_EXPORT_ALLOWED_ORIGINS`, plus any `localhost` port outside
|
|
1125
|
+
* production — the same allow-list core's comment endpoints use.
|
|
1126
|
+
* Set it on a public read the runtime `fetch()`es (a config or disclosure
|
|
1127
|
+
* route); a plain `<img>`/beacon GET needs nothing.
|
|
1128
|
+
*/
|
|
1129
|
+
cors?: boolean;
|
|
1130
|
+
/**
|
|
1131
|
+
* Send the browser to a same-site path. The host allows only a path that
|
|
1132
|
+
* starts with one `/` (a query string is fine) and answers 303 when `status`
|
|
1133
|
+
* is not already a redirect. Absolute URLs and protocol-relative paths are
|
|
1134
|
+
* ignored, so a plugin cannot send a visitor off the site.
|
|
1135
|
+
*/
|
|
1136
|
+
redirect?: string;
|
|
1137
|
+
/**
|
|
1138
|
+
* Render a published page of this site in the active theme, at the URL the
|
|
1139
|
+
* visitor asked for. The slug is one path segment (`support-ticket`). The
|
|
1140
|
+
* host follows `redirect` instead when that is set, refuses anything that is not a
|
|
1141
|
+
* published public page, and does not cache the response.
|
|
1142
|
+
*/
|
|
1143
|
+
renderPage?: string;
|
|
1144
|
+
}
|
|
1145
|
+
export type PluginHttpHandler = (req: PluginHttpRequest) => PluginHttpResponse | Promise<PluginHttpResponse>;
|
|
1146
|
+
/**
|
|
1147
|
+
* Per-IP ceiling the host enforces before the handler runs.
|
|
1148
|
+
* `limit` is an integer from 1 to 10_000. `windowMs` is an integer from
|
|
1149
|
+
* 1_000 to 3_600_000. `key` shares one counter across several routes of this
|
|
1150
|
+
* plugin (cart add and cart update). It is letters, digits, and hyphens, up
|
|
1151
|
+
* to 40 characters, and must start with a letter or digit. Without `key`,
|
|
1152
|
+
* the route has its own counter.
|
|
1153
|
+
*/
|
|
1154
|
+
export interface PluginHttpRateLimit {
|
|
1155
|
+
limit: number;
|
|
1156
|
+
windowMs: number;
|
|
1157
|
+
key?: string;
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Policy the host applies to one registered route. Defaults stay strict:
|
|
1161
|
+
* a non-GET route requires the session CSRF token, nothing is rate-limited,
|
|
1162
|
+
* and the handler does not receive the raw request bytes.
|
|
1163
|
+
*/
|
|
1164
|
+
export interface PluginHttpRouteOptions {
|
|
1165
|
+
/** Host guard failures use { error: { code, message } } for a stable JSON API. */
|
|
1166
|
+
structuredErrors?: true;
|
|
1167
|
+
/**
|
|
1168
|
+
* Skip the session CSRF token. Use this only when the plugin authenticates
|
|
1169
|
+
* the call another way, such as a signed webhook. GET never requires CSRF.
|
|
1170
|
+
*/
|
|
1171
|
+
csrf?: false;
|
|
1172
|
+
rateLimit?: PluginHttpRateLimit;
|
|
1173
|
+
/**
|
|
1174
|
+
* Keep the exact request bytes on `req.rawBody` so the handler can verify
|
|
1175
|
+
* a signature. Parsed JSON is not the signed payload.
|
|
1176
|
+
*/
|
|
1177
|
+
rawBody?: true;
|
|
1178
|
+
/**
|
|
1179
|
+
* Accept the request body as raw bytes instead of JSON: `req.body` is a
|
|
1180
|
+
* `Buffer` and `content-type` says what it is. For file uploads, up to
|
|
1181
|
+
* `maxBytes` (host maximum 1 GiB). CSRF and rate limits still apply.
|
|
1182
|
+
*/
|
|
1183
|
+
binaryBody?: {
|
|
1184
|
+
maxBytes: number;
|
|
1185
|
+
};
|
|
1186
|
+
/**
|
|
1187
|
+
* Offer this route to AI agents as an MCP tool. Off unless set: the plugin
|
|
1188
|
+
* chooses which of its functions agents may use. See `PluginHttpMcpTool`.
|
|
1189
|
+
*/
|
|
1190
|
+
mcp?: PluginHttpMcpTool;
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* A plugin route offered to AI agents (MCP clients and the admin assistant).
|
|
1194
|
+
*
|
|
1195
|
+
* The host lists the tool only on sites where the plugin is active, and only
|
|
1196
|
+
* to sessions that hold `capability`. A call runs this route's own handler
|
|
1197
|
+
* with the agent's session (`role: "api-key"`, its capabilities), so the
|
|
1198
|
+
* handler's existing checks apply unchanged. Path parameters (`:id`) become
|
|
1199
|
+
* required string arguments; the other arguments are the query string for
|
|
1200
|
+
* GET and DELETE, and the JSON body otherwise. Non-read-only calls are
|
|
1201
|
+
* audited. A file or binary response is not passed to the agent.
|
|
1202
|
+
*/
|
|
1203
|
+
export interface PluginHttpMcpTool {
|
|
1204
|
+
/** `snake_case`, unique, prefixed with the plugin (`shop_products_save`). */
|
|
1205
|
+
name: string;
|
|
1206
|
+
title?: string;
|
|
1207
|
+
/** Written for a model: what the tool does and when to use it. */
|
|
1208
|
+
description: string;
|
|
1209
|
+
/** Needed to see and call the tool. Use the capability the handler checks. */
|
|
1210
|
+
capability: string;
|
|
1211
|
+
/** JSON Schema (`type: "object"`) for the query or body arguments. */
|
|
1212
|
+
inputSchema?: Record<string, unknown>;
|
|
1213
|
+
annotations?: {
|
|
1214
|
+
readOnlyHint?: boolean;
|
|
1215
|
+
destructiveHint?: boolean;
|
|
1216
|
+
idempotentHint?: boolean;
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
export interface PluginHttpApi {
|
|
1220
|
+
/** Neutral API URL when apiNamespace is declared; legacy URL otherwise. */
|
|
1221
|
+
url(path?: string): string;
|
|
1222
|
+
get(path: string, handler: PluginHttpHandler, options?: PluginHttpRouteOptions): void;
|
|
1223
|
+
post(path: string, handler: PluginHttpHandler, options?: PluginHttpRouteOptions): void;
|
|
1224
|
+
put(path: string, handler: PluginHttpHandler, options?: PluginHttpRouteOptions): void;
|
|
1225
|
+
patch(path: string, handler: PluginHttpHandler, options?: PluginHttpRouteOptions): void;
|
|
1226
|
+
delete(path: string, handler: PluginHttpHandler, options?: PluginHttpRouteOptions): void;
|
|
1227
|
+
}
|
|
1228
|
+
export interface PluginJobContext {
|
|
1229
|
+
jobId: string;
|
|
1230
|
+
name: string;
|
|
1231
|
+
attempt: number;
|
|
1232
|
+
scheduledAt: Date;
|
|
1233
|
+
payload?: unknown;
|
|
1234
|
+
/** The site this run is for. Set when the job was registered with `perSite`. */
|
|
1235
|
+
siteId?: string;
|
|
1236
|
+
}
|
|
1237
|
+
export interface PluginJobResult {
|
|
1238
|
+
success: boolean;
|
|
1239
|
+
message?: string;
|
|
1240
|
+
}
|
|
1241
|
+
export interface PluginJobDefinition {
|
|
1242
|
+
name: string;
|
|
1243
|
+
schedule?: string;
|
|
1244
|
+
maxAttempts?: number;
|
|
1245
|
+
/**
|
|
1246
|
+
* Run the handler once for every site where the plugin is active, inside
|
|
1247
|
+
* that site's context, so `ctx.databases`, `ctx.settings`, and `ctx.secrets`
|
|
1248
|
+
* act on that site. One site's failure does not stop the others.
|
|
1249
|
+
* Without it, the handler runs once with no site context.
|
|
1250
|
+
*/
|
|
1251
|
+
perSite?: boolean;
|
|
1252
|
+
handler(ctx: PluginJobContext): Promise<PluginJobResult>;
|
|
1253
|
+
}
|
|
1254
|
+
export interface PluginJobsApi {
|
|
1255
|
+
register(def: PluginJobDefinition): void;
|
|
1256
|
+
/**
|
|
1257
|
+
* Run a registered job once, after `delayMs`. Each call is its own run with
|
|
1258
|
+
* its own `payload` (JSON, up to 1 MB). On hosts with the durable queue
|
|
1259
|
+
* (core 0.3.6) the run is stored first and survives a restart; the returned
|
|
1260
|
+
* promise resolves once it is stored and never rejects. A run whose handler
|
|
1261
|
+
* throws or returns `success: false` is retried until `maxAttempts`
|
|
1262
|
+
* (default 3), so handlers must be safe to repeat; failed runs are listed in
|
|
1263
|
+
* Diagnostics. A `perSite` job enqueued while handling a site's request or
|
|
1264
|
+
* job runs only for that site; enqueued outside one, for every site.
|
|
1265
|
+
* Throws when the job is not registered.
|
|
1266
|
+
*/
|
|
1267
|
+
enqueue(name: string, options?: {
|
|
1268
|
+
delayMs?: number;
|
|
1269
|
+
payload?: unknown;
|
|
1270
|
+
}): void | Promise<void>;
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* A file sent with an email, for example an invoice PDF. The host accepts up
|
|
1274
|
+
* to 5 per message, each up to 10 MB and 15 MB together, of the types PDF,
|
|
1275
|
+
* PNG, JPEG, CSV, plain text, and calendar (`text/calendar`). Attachments are
|
|
1276
|
+
* not kept in the delivery log, so a delivery retried from the admin goes out
|
|
1277
|
+
* without them. Older hosts ignore the field and send the email without them.
|
|
1278
|
+
*/
|
|
1279
|
+
export interface PluginMailAttachment {
|
|
1280
|
+
filename: string;
|
|
1281
|
+
content: Buffer;
|
|
1282
|
+
contentType: string;
|
|
1283
|
+
}
|
|
1284
|
+
export interface PluginMailTransportMessage {
|
|
1285
|
+
from: string;
|
|
1286
|
+
to: string;
|
|
1287
|
+
subject: string;
|
|
1288
|
+
text: string;
|
|
1289
|
+
html: string;
|
|
1290
|
+
replyTo?: string;
|
|
1291
|
+
envelopeSender?: string;
|
|
1292
|
+
/** Files to send with the message. Transports written before attachments existed ignore them. */
|
|
1293
|
+
attachments?: PluginMailAttachment[];
|
|
1294
|
+
}
|
|
1295
|
+
export interface PluginMailMessage {
|
|
1296
|
+
to: string;
|
|
1297
|
+
subject: string;
|
|
1298
|
+
text: string;
|
|
1299
|
+
html?: string;
|
|
1300
|
+
replyTo?: string;
|
|
1301
|
+
attachments?: PluginMailAttachment[];
|
|
1302
|
+
}
|
|
1303
|
+
export type PluginMailResult = {
|
|
1304
|
+
ok: true;
|
|
1305
|
+
messageId?: string;
|
|
1306
|
+
} | {
|
|
1307
|
+
ok: false;
|
|
1308
|
+
error: string;
|
|
1309
|
+
};
|
|
1310
|
+
/**
|
|
1311
|
+
* A one-off replacement for a registered template. Fields that are left out
|
|
1312
|
+
* stay on the published template. The site design (logo, colours, footer)
|
|
1313
|
+
* still wraps the HTML.
|
|
1314
|
+
*/
|
|
1315
|
+
export interface PluginTemplateMailContent {
|
|
1316
|
+
subject?: string;
|
|
1317
|
+
preheader?: string;
|
|
1318
|
+
html?: string;
|
|
1319
|
+
text?: string;
|
|
1320
|
+
}
|
|
1321
|
+
/** Send one registered template. `values` fills `{{tokens}}` declared on that template. */
|
|
1322
|
+
export interface PluginTemplateMail {
|
|
1323
|
+
to: string;
|
|
1324
|
+
/** Must begin with the calling plugin's manifest id followed by a dot. */
|
|
1325
|
+
key: string;
|
|
1326
|
+
values: Record<string, string>;
|
|
1327
|
+
locale?: string;
|
|
1328
|
+
replyTo?: string;
|
|
1329
|
+
/** This send only. Does not change the template saved under Admin → Emails. */
|
|
1330
|
+
content?: PluginTemplateMailContent;
|
|
1331
|
+
}
|
|
1332
|
+
export interface PluginMailTransportApi {
|
|
1333
|
+
/** Send through the host's configured transport. Requires `mail:send`. */
|
|
1334
|
+
send(message: PluginMailMessage): Promise<PluginMailResult>;
|
|
1335
|
+
/**
|
|
1336
|
+
* Send a template this plugin registered, wrapped in the site design from
|
|
1337
|
+
* Admin → Emails. Requires `mail:send`. The key must start with this plugin's
|
|
1338
|
+
* id. `content` replaces the saved subject, preheader, HTML, or plain text
|
|
1339
|
+
* for this send only. A template an administrator has turned off is not sent.
|
|
1340
|
+
* Hosts that predate this method do not provide it.
|
|
1341
|
+
*/
|
|
1342
|
+
sendTemplate(input: PluginTemplateMail): Promise<PluginMailResult>;
|
|
1343
|
+
register(transport: {
|
|
1344
|
+
id: string;
|
|
1345
|
+
label: string;
|
|
1346
|
+
send(message: PluginMailTransportMessage): Promise<{
|
|
1347
|
+
response: string;
|
|
1348
|
+
messageId?: string;
|
|
1349
|
+
status?: "sent" | "deferred" | "failed" | "bounced";
|
|
1350
|
+
}>;
|
|
1351
|
+
}): void;
|
|
1352
|
+
/** Register a namespaced system-email type. Requires `mail:templates`. */
|
|
1353
|
+
registerTemplate(template: PluginEmailTemplateDefinition): void;
|
|
1354
|
+
}
|
|
1355
|
+
export interface PluginEmailVariableDefinition {
|
|
1356
|
+
key: string;
|
|
1357
|
+
label: string;
|
|
1358
|
+
description: string;
|
|
1359
|
+
kind: "text" | "url";
|
|
1360
|
+
example: string;
|
|
1361
|
+
required?: boolean;
|
|
1362
|
+
}
|
|
1363
|
+
export interface PluginEmailTemplateDefinition {
|
|
1364
|
+
/** Must begin with the registering plugin's manifest id followed by a dot. */
|
|
1365
|
+
key: string;
|
|
1366
|
+
label: string;
|
|
1367
|
+
description: string;
|
|
1368
|
+
purpose: "account" | "security" | "administrative";
|
|
1369
|
+
recipient: "user" | "administrator";
|
|
1370
|
+
disableSafe?: boolean;
|
|
1371
|
+
variables: PluginEmailVariableDefinition[];
|
|
1372
|
+
defaults: {
|
|
1373
|
+
subject: string;
|
|
1374
|
+
preheader: string;
|
|
1375
|
+
html: string;
|
|
1376
|
+
text: string;
|
|
1377
|
+
};
|
|
1378
|
+
/** Optional built-in catalogs keyed by an active Justflows locale code. */
|
|
1379
|
+
localizedDefaults?: Record<string, {
|
|
1380
|
+
subject: string;
|
|
1381
|
+
preheader: string;
|
|
1382
|
+
html: string;
|
|
1383
|
+
text: string;
|
|
1384
|
+
}>;
|
|
1385
|
+
}
|
|
1386
|
+
export interface PluginDataRecord<T = unknown> {
|
|
1387
|
+
id: string;
|
|
1388
|
+
data: T;
|
|
1389
|
+
createdAt: string;
|
|
1390
|
+
updatedAt: string;
|
|
1391
|
+
}
|
|
1392
|
+
export interface PluginDataApi {
|
|
1393
|
+
list<T = unknown>(collection: string): Promise<PluginDataRecord<T>[]>;
|
|
1394
|
+
get<T = unknown>(collection: string, id: string): Promise<PluginDataRecord<T> | undefined>;
|
|
1395
|
+
put<T = unknown>(collection: string, id: string, data: T): Promise<void>;
|
|
1396
|
+
delete(collection: string, id: string): Promise<void>;
|
|
1397
|
+
/**
|
|
1398
|
+
* Compare-and-set. Returns false when `expectedUpdatedAt` does not match the
|
|
1399
|
+
* stored row — callers retry rather than overwriting a concurrent write.
|
|
1400
|
+
*/
|
|
1401
|
+
cas<T = unknown>(collection: string, id: string, expectedUpdatedAt: string, data: T): Promise<boolean>;
|
|
1402
|
+
/** Run several data operations in one SQL transaction when the host supports it. */
|
|
1403
|
+
transaction<T>(fn: (tx: PluginDataApi) => Promise<T>): Promise<T>;
|
|
1404
|
+
/** Delete every document this plugin stored. */
|
|
1405
|
+
clear(): Promise<void>;
|
|
1406
|
+
}
|
|
1407
|
+
/** One editable prop of a plugin block, as the page-builder inspector shows it. */
|
|
1408
|
+
export interface PluginBlockField {
|
|
1409
|
+
/**
|
|
1410
|
+
* `text`, `textarea`, `richtext`, `number`, `boolean`, `select`, `url`,
|
|
1411
|
+
* `media` (one image URL), or `images` (a list of `{ src, alt, caption }`
|
|
1412
|
+
* with upload and the media library). For `media` and `images` the host adds
|
|
1413
|
+
* a `responsive` prop when it renders the block: a map from image URL to its
|
|
1414
|
+
* `ResponsiveImageProp`, ready for `applyResponsiveProp` and
|
|
1415
|
+
* `renderResponsiveImage`.
|
|
1416
|
+
*/
|
|
1417
|
+
type: string;
|
|
1418
|
+
required?: boolean;
|
|
1419
|
+
default?: unknown;
|
|
1420
|
+
/** Fixed choices. The field renders as a dropdown, or checkboxes with `multiple`. */
|
|
1421
|
+
options?: string[];
|
|
1422
|
+
/** Display text per option value. The raw value is shown when one is missing. */
|
|
1423
|
+
optionLabels?: Record<string, string>;
|
|
1424
|
+
/** Inspector label. Defaults to the prop key. */
|
|
1425
|
+
label?: string;
|
|
1426
|
+
/** One line of help under the field. */
|
|
1427
|
+
help?: string;
|
|
1428
|
+
/**
|
|
1429
|
+
* Same-origin path the editor GETs for choices instead of `options`. It must
|
|
1430
|
+
* answer `{ options: [{ value, label }] }`; plugins usually point it at their
|
|
1431
|
+
* own route, e.g. `/ext/<plugin-id>/blocks/options/products`.
|
|
1432
|
+
*/
|
|
1433
|
+
optionsUrl?: string;
|
|
1434
|
+
/** Pick several choices. The prop is saved as a string array. */
|
|
1435
|
+
multiple?: boolean;
|
|
1436
|
+
/** Only show the field while another prop equals one of these values. */
|
|
1437
|
+
showWhen?: {
|
|
1438
|
+
field: string;
|
|
1439
|
+
equals: string | string[];
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
export interface PluginBlockDefinition {
|
|
1443
|
+
type: string;
|
|
1444
|
+
version: number;
|
|
1445
|
+
title: string;
|
|
1446
|
+
description?: string;
|
|
1447
|
+
icon?: string;
|
|
1448
|
+
category?: string;
|
|
1449
|
+
schema: Record<string, PluginBlockField>;
|
|
1450
|
+
supportsChildren?: boolean;
|
|
1451
|
+
allowedChildTypes?: string[];
|
|
1452
|
+
/**
|
|
1453
|
+
* Turn the builder's generic settings sections on or off for this block.
|
|
1454
|
+
* Unset keys keep the default: everything on except `themeVariables`.
|
|
1455
|
+
* `hideFields` drops single layout fields, e.g. `["textAlign"]` when the
|
|
1456
|
+
* block has its own alignment field.
|
|
1457
|
+
*/
|
|
1458
|
+
inspector?: Partial<Record<"themeVariables" | "animation" | "spacing" | "size" | "appearance" | "colors" | "advanced", boolean>> & {
|
|
1459
|
+
hideFields?: ("padTop" | "padBottom" | "padX" | "marginTop" | "marginBottom" | "width" | "alignSelf" | "minHeight" | "maxWidth" | "maxHeight" | "textAlign" | "radius" | "shadow" | "background" | "textColor" | "accent" | "opacity")[];
|
|
1460
|
+
};
|
|
1461
|
+
/**
|
|
1462
|
+
* Props an author may edit directly on the builder canvas. Mark the element
|
|
1463
|
+
* that shows each one with `data-jf-inline="<prop>"` in `render`. Plugin
|
|
1464
|
+
* fields are plain text: a declared `rich` mode is treated as `plain`, and
|
|
1465
|
+
* `render` must escape the value as it does any prop.
|
|
1466
|
+
*/
|
|
1467
|
+
inline?: Record<string, {
|
|
1468
|
+
mode: "plain" | "rich";
|
|
1469
|
+
multiline?: boolean;
|
|
1470
|
+
maxLength?: number;
|
|
1471
|
+
}>;
|
|
1472
|
+
/**
|
|
1473
|
+
* Builder 2.0 editor contract (justflows-ce#305). Everything below is
|
|
1474
|
+
* optional; see docs/BLOCK-CONTRACT.md for the rules and examples.
|
|
1475
|
+
*
|
|
1476
|
+
* `apiVersion`: the contract version this block was written for, today
|
|
1477
|
+
* `BLOCK_API_VERSION` (1). A host that does not support it refuses the
|
|
1478
|
+
* block at activation with a clear message instead of misbehaving.
|
|
1479
|
+
*/
|
|
1480
|
+
apiVersion?: number;
|
|
1481
|
+
/** Extra words the block library search matches, e.g. `["price", "plan"]`. */
|
|
1482
|
+
keywords?: string[];
|
|
1483
|
+
/** Parent block types this block may be placed in; `"$root"` is a page, header, footer or template root. */
|
|
1484
|
+
parents?: string[];
|
|
1485
|
+
/** Props a newly inserted block starts with. Always passed through `validateProps`. */
|
|
1486
|
+
defaults?: Record<string, unknown>;
|
|
1487
|
+
/** Hide the block from the library; existing blocks keep rendering. */
|
|
1488
|
+
deprecated?: true | {
|
|
1489
|
+
since: string;
|
|
1490
|
+
replacedBy?: string;
|
|
1491
|
+
message?: string;
|
|
1492
|
+
};
|
|
1493
|
+
/** One-click prop changes offered in the block's menu (and its canvas toolbar with `toolbar: true`). */
|
|
1494
|
+
actions?: {
|
|
1495
|
+
id: string;
|
|
1496
|
+
label: string;
|
|
1497
|
+
props: Record<string, unknown>;
|
|
1498
|
+
toolbar?: boolean;
|
|
1499
|
+
}[];
|
|
1500
|
+
/** How the builder previews the block: its own render (`server`, default) or a `placeholder`, with optional sample props. */
|
|
1501
|
+
preview?: {
|
|
1502
|
+
mode?: "server" | "placeholder";
|
|
1503
|
+
sampleProps?: Record<string, unknown>;
|
|
1504
|
+
minHeight?: number;
|
|
1505
|
+
};
|
|
1506
|
+
/** Host features the block takes part in: `containerLayout` lets a container become a row, column or grid. */
|
|
1507
|
+
supports?: {
|
|
1508
|
+
containerLayout?: boolean | {
|
|
1509
|
+
target?: string;
|
|
1510
|
+
};
|
|
1511
|
+
};
|
|
1512
|
+
/** Steps that upgrade stored props from an older `version`, from N to N + 1, covering every version below the current one. */
|
|
1513
|
+
migrations?: {
|
|
1514
|
+
from: number;
|
|
1515
|
+
to: number;
|
|
1516
|
+
migrate(props: Readonly<Record<string, unknown>>): Record<string, unknown>;
|
|
1517
|
+
}[];
|
|
1518
|
+
render(props: Record<string, unknown>, children?: string): string;
|
|
1519
|
+
validateProps(raw: unknown): Record<string, unknown>;
|
|
1520
|
+
}
|
|
1521
|
+
/** The Builder 2.0 block contract version this SDK describes (justflows-ce#305). */
|
|
1522
|
+
export declare const BLOCK_API_VERSION = 1;
|
|
1523
|
+
export interface PluginBlocksApi {
|
|
1524
|
+
register(definition: PluginBlockDefinition): void;
|
|
1525
|
+
}
|
|
1526
|
+
/** Pattern contribution scoped to the registering plugin. */
|
|
1527
|
+
export type PluginPatternDefinition = Omit<BlockPattern, "schemaVersion" | "version" | "category" | "requiresBlockTypes"> & {
|
|
1528
|
+
schemaVersion?: 1;
|
|
1529
|
+
version?: string;
|
|
1530
|
+
category?: string;
|
|
1531
|
+
requiresBlockTypes?: string[];
|
|
1532
|
+
};
|
|
1533
|
+
export interface PluginPatternsApi {
|
|
1534
|
+
/** Register an editable pattern. Validated immediately and removed on deactivate. */
|
|
1535
|
+
register(pattern: PluginPatternDefinition): Unsubscribe;
|
|
1536
|
+
}
|
|
1537
|
+
/** Idempotent content-type and page helpers. Require `content:create` (and `content:publish` to publish). */
|
|
1538
|
+
export type PluginContentField = {
|
|
1539
|
+
key: string;
|
|
1540
|
+
label: string;
|
|
1541
|
+
type: "text" | "textarea" | "richtext" | "number" | "boolean" | "media" | "date" | "select";
|
|
1542
|
+
required?: boolean;
|
|
1543
|
+
options?: string[];
|
|
1544
|
+
};
|
|
1545
|
+
export type PluginContentEnsureResult = {
|
|
1546
|
+
created: boolean;
|
|
1547
|
+
id: string;
|
|
1548
|
+
slug: string;
|
|
1549
|
+
};
|
|
1550
|
+
export type PluginContentDeleteTypeResult = {
|
|
1551
|
+
pages: number;
|
|
1552
|
+
typeDeleted: boolean;
|
|
1553
|
+
};
|
|
1554
|
+
/** Records removed because one user created them. */
|
|
1555
|
+
export interface PluginDeleteCreatedByCounts {
|
|
1556
|
+
content: number;
|
|
1557
|
+
media: number;
|
|
1558
|
+
comments: number;
|
|
1559
|
+
}
|
|
1560
|
+
export type PluginDeleteCreatedByResult = ({
|
|
1561
|
+
ok: true;
|
|
1562
|
+
} & PluginDeleteCreatedByCounts) | {
|
|
1563
|
+
ok: false;
|
|
1564
|
+
error: string;
|
|
1565
|
+
};
|
|
1566
|
+
/** One published content entry as returned by {@link PluginContentApi.listPublished}. */
|
|
1567
|
+
export interface PluginPublishedEntry {
|
|
1568
|
+
id: string;
|
|
1569
|
+
type: string;
|
|
1570
|
+
title: string;
|
|
1571
|
+
slug: string;
|
|
1572
|
+
locale: string;
|
|
1573
|
+
/**
|
|
1574
|
+
* Shared id of every language version of this entry. The original's own id,
|
|
1575
|
+
* so a plugin table keyed by the original content id joins on this.
|
|
1576
|
+
* Absent on older hosts.
|
|
1577
|
+
*/
|
|
1578
|
+
translationGroupId?: string;
|
|
1579
|
+
excerpt: string | null;
|
|
1580
|
+
fields: Record<string, unknown>;
|
|
1581
|
+
authorId: string | null;
|
|
1582
|
+
/** `users.display_name` (or username), resolved by the host; null when unattributed. */
|
|
1583
|
+
authorName: string | null;
|
|
1584
|
+
/** ISO 8601, or null when never explicitly dated. */
|
|
1585
|
+
publishedAt: string | null;
|
|
1586
|
+
updatedAt: string;
|
|
1587
|
+
createdAt: string;
|
|
1588
|
+
}
|
|
1589
|
+
export interface PluginListPublishedQuery {
|
|
1590
|
+
/** Content-type slugs. Omit for every type. */
|
|
1591
|
+
types?: string[];
|
|
1592
|
+
/** Restrict to one locale. Omit for every active locale. */
|
|
1593
|
+
locale?: string;
|
|
1594
|
+
/**
|
|
1595
|
+
* With `locale`: return one entry per translation group, the `locale`
|
|
1596
|
+
* version when it exists and the default-locale original otherwise.
|
|
1597
|
+
*/
|
|
1598
|
+
fallback?: boolean;
|
|
1599
|
+
authorId?: string;
|
|
1600
|
+
/** `users.username`; resolved to an id by the host. */
|
|
1601
|
+
authorUsername?: string;
|
|
1602
|
+
/** Newest first. Default 20, hard cap 200. */
|
|
1603
|
+
limit?: number;
|
|
1604
|
+
/** Include entries whose `publishedAt` is in the future. Default false. */
|
|
1605
|
+
includeScheduled?: boolean;
|
|
1606
|
+
}
|
|
1607
|
+
/** One published entry with its blocks, as returned by {@link PluginContentApi.getPublished}. */
|
|
1608
|
+
export interface PluginPublishedPage extends PluginPublishedEntry {
|
|
1609
|
+
/** The entry's block tree (the `blocks` of its block document), as published. */
|
|
1610
|
+
blocks: unknown[];
|
|
1611
|
+
}
|
|
1612
|
+
export interface PluginGetPublishedQuery {
|
|
1613
|
+
/** Content-type slug. */
|
|
1614
|
+
type: string;
|
|
1615
|
+
/** The entry's slug, in the site's default locale. */
|
|
1616
|
+
slug: string;
|
|
1617
|
+
/**
|
|
1618
|
+
* Visitor locale. Returns the published translation in this locale when
|
|
1619
|
+
* there is one, otherwise the default-locale entry. Omit for the default.
|
|
1620
|
+
*/
|
|
1621
|
+
locale?: string;
|
|
1622
|
+
}
|
|
1623
|
+
/** A private file as `ctx.files` describes it. */
|
|
1624
|
+
export interface PluginPrivateFile {
|
|
1625
|
+
/** The plugin's own key, for example `downloads/<productId>/manual.pdf`. */
|
|
1626
|
+
key: string;
|
|
1627
|
+
size: number;
|
|
1628
|
+
contentType: string;
|
|
1629
|
+
sha256: string;
|
|
1630
|
+
createdAt: string;
|
|
1631
|
+
updatedAt: string;
|
|
1632
|
+
}
|
|
1633
|
+
export interface PluginFilesApi {
|
|
1634
|
+
/**
|
|
1635
|
+
* Store or replace a file. Keys are relative paths without `..`. Throws a
|
|
1636
|
+
* quota error (status 409) when the site's private-file limits are reached.
|
|
1637
|
+
*/
|
|
1638
|
+
put(key: string, data: Buffer, options?: {
|
|
1639
|
+
contentType?: string;
|
|
1640
|
+
}): Promise<PluginPrivateFile>;
|
|
1641
|
+
get(key: string): Promise<PluginPrivateFile | null>;
|
|
1642
|
+
/** The whole file in memory. Prefer answering a route with `{ file }` for downloads. */
|
|
1643
|
+
read(key: string): Promise<Buffer | null>;
|
|
1644
|
+
delete(key: string): Promise<boolean>;
|
|
1645
|
+
/** Files under a key prefix (all when omitted), up to 500. */
|
|
1646
|
+
list(prefix?: string): Promise<PluginPrivateFile[]>;
|
|
1647
|
+
}
|
|
1648
|
+
export interface PluginContentApi {
|
|
1649
|
+
/**
|
|
1650
|
+
* One published entry by type and slug, with its blocks — for example a page
|
|
1651
|
+
* a plugin uses as a shared layout. Null when no such entry is published.
|
|
1652
|
+
* Requires the `content:read` permission. Absent on older hosts.
|
|
1653
|
+
*/
|
|
1654
|
+
getPublished?(query: PluginGetPublishedQuery): Promise<PluginPublishedPage | null>;
|
|
1655
|
+
/**
|
|
1656
|
+
* List published content, newest first. Requires the `content:read` permission.
|
|
1657
|
+
* Like `getPublished`, this always answers as an anonymous visitor: an entry
|
|
1658
|
+
* with visibility rules that exclude anonymous visitors is left out.
|
|
1659
|
+
* Scheduled (future `publishedAt`) and expired entries are excluded unless
|
|
1660
|
+
* `includeScheduled` is set.
|
|
1661
|
+
*/
|
|
1662
|
+
listPublished(query?: PluginListPublishedQuery): Promise<PluginPublishedEntry[]>;
|
|
1663
|
+
/** Create a content type if this site does not already have that slug. */
|
|
1664
|
+
ensureType(input: {
|
|
1665
|
+
slug: string;
|
|
1666
|
+
label: string;
|
|
1667
|
+
description?: string;
|
|
1668
|
+
fields?: PluginContentField[];
|
|
1669
|
+
}): Promise<PluginContentEnsureResult>;
|
|
1670
|
+
/** Create a content entry if this site does not already have that type+slug+locale.
|
|
1671
|
+
* When the row already exists, title and excerpt are updated. Blocks and
|
|
1672
|
+
* cache policy are written only on insert, so a later edit of the canvas is
|
|
1673
|
+
* kept. `aliases` are previous slugs to rename. Pass `create: false` to only
|
|
1674
|
+
* repair, never insert.
|
|
1675
|
+
*/
|
|
1676
|
+
ensurePage(input: {
|
|
1677
|
+
type: string;
|
|
1678
|
+
title: string;
|
|
1679
|
+
slug: string;
|
|
1680
|
+
excerpt?: string;
|
|
1681
|
+
status?: "draft" | "published";
|
|
1682
|
+
aliases?: string[];
|
|
1683
|
+
create?: boolean;
|
|
1684
|
+
/**
|
|
1685
|
+
* Block document stored only when the row is inserted. A later activation
|
|
1686
|
+
* leaves an edited canvas alone.
|
|
1687
|
+
*/
|
|
1688
|
+
blocks?: {
|
|
1689
|
+
version?: 1;
|
|
1690
|
+
blocks: unknown[];
|
|
1691
|
+
};
|
|
1692
|
+
/**
|
|
1693
|
+
* Cache-Control stored only on insert. `private, no-store` keeps the page
|
|
1694
|
+
* out of shared caches. Ignored when the row already exists.
|
|
1695
|
+
*/
|
|
1696
|
+
cacheControl?: string;
|
|
1697
|
+
/**
|
|
1698
|
+
* Trash entries of these types that use the same slug. A signed-in page
|
|
1699
|
+
* that moves from `page` to `account` passes `["page"]` so the public
|
|
1700
|
+
* copy does not keep the address.
|
|
1701
|
+
*/
|
|
1702
|
+
retireTypes?: string[];
|
|
1703
|
+
}): Promise<PluginContentEnsureResult>;
|
|
1704
|
+
/**
|
|
1705
|
+
* Delete every content row of this type (all locales) and the type itself.
|
|
1706
|
+
* Built-in slugs `post` and `page` cannot be deleted.
|
|
1707
|
+
*/
|
|
1708
|
+
deleteType(slug: string): Promise<PluginContentDeleteTypeResult>;
|
|
1709
|
+
/**
|
|
1710
|
+
* Permanently delete entries of this type and slug, in every locale,
|
|
1711
|
+
* including copies in trash and their translations. The content type stays.
|
|
1712
|
+
* Requires `content:delete`.
|
|
1713
|
+
*/
|
|
1714
|
+
deletePages(input: {
|
|
1715
|
+
type: string;
|
|
1716
|
+
slug: string;
|
|
1717
|
+
}): Promise<{
|
|
1718
|
+
deleted: number;
|
|
1719
|
+
}>;
|
|
1720
|
+
/**
|
|
1721
|
+
* Permanently delete records this user created: content they authored (any
|
|
1722
|
+
* status, including trash), media they uploaded, and comments they wrote.
|
|
1723
|
+
* Also drops their unpublished working revisions on other people's entries.
|
|
1724
|
+
* Does not delete the user, and refuses when that user is an administrator.
|
|
1725
|
+
* Requires `content:delete`.
|
|
1726
|
+
*/
|
|
1727
|
+
deleteCreatedBy(userId: string): Promise<PluginDeleteCreatedByResult>;
|
|
1728
|
+
}
|
|
1729
|
+
export type PluginDatabaseDriver = "postgres" | "mysql" | "mariadb";
|
|
1730
|
+
export interface PluginDatabaseTarget {
|
|
1731
|
+
driver: PluginDatabaseDriver;
|
|
1732
|
+
host: string;
|
|
1733
|
+
port: number;
|
|
1734
|
+
database: string;
|
|
1735
|
+
username: string;
|
|
1736
|
+
password: string;
|
|
1737
|
+
ssl: boolean;
|
|
1738
|
+
rejectUnauthorized?: boolean;
|
|
1739
|
+
}
|
|
1740
|
+
export interface PluginDatabaseProbeResult {
|
|
1741
|
+
ok: boolean;
|
|
1742
|
+
error?: string;
|
|
1743
|
+
dialect?: PluginDatabaseDriver;
|
|
1744
|
+
serverVersion?: string;
|
|
1745
|
+
tls: boolean;
|
|
1746
|
+
latencyMs: number;
|
|
1747
|
+
}
|
|
1748
|
+
export type PluginColumnType = "uuid" | "text" | "int" | "bigint" | "boolean" | "timestamptz" | "json" | "varchar";
|
|
1749
|
+
export interface PluginSchemaColumn {
|
|
1750
|
+
name: string;
|
|
1751
|
+
type: PluginColumnType;
|
|
1752
|
+
/** Required when `type` is `varchar`. */
|
|
1753
|
+
length?: number;
|
|
1754
|
+
primary?: boolean;
|
|
1755
|
+
notNull?: boolean;
|
|
1756
|
+
unique?: boolean;
|
|
1757
|
+
}
|
|
1758
|
+
export interface PluginSchemaIndex {
|
|
1759
|
+
name: string;
|
|
1760
|
+
columns: string[];
|
|
1761
|
+
unique?: boolean;
|
|
1762
|
+
}
|
|
1763
|
+
/** Unprefixed table. The host creates `{pluginSlug}_{name}` (e.g. `shop_products`). */
|
|
1764
|
+
export interface PluginSchemaTable {
|
|
1765
|
+
name: string;
|
|
1766
|
+
columns: PluginSchemaColumn[];
|
|
1767
|
+
indexes?: PluginSchemaIndex[];
|
|
1768
|
+
}
|
|
1769
|
+
export interface PluginSchemaApplyResult {
|
|
1770
|
+
ok: boolean;
|
|
1771
|
+
tables: string[];
|
|
1772
|
+
error?: string;
|
|
1773
|
+
/**
|
|
1774
|
+
* `ensureSchema` only: declared columns it added to tables that already
|
|
1775
|
+
* existed (`shop_orders.channel`). Added columns are nullable and not unique.
|
|
1776
|
+
*/
|
|
1777
|
+
columnsAdded?: string[];
|
|
1778
|
+
/** `ensureSchema` only: declared indexes it added to tables that already existed. */
|
|
1779
|
+
indexesAdded?: string[];
|
|
1780
|
+
}
|
|
1781
|
+
export interface PluginWorkspace {
|
|
1782
|
+
id: string;
|
|
1783
|
+
/** The administrator's billing account on the installation root site, when linked. */
|
|
1784
|
+
ownerUserId?: string | null;
|
|
1785
|
+
name: string;
|
|
1786
|
+
slug: string;
|
|
1787
|
+
status: "active" | "suspended" | "provisioning" | "deleted";
|
|
1788
|
+
userMode: "isolated" | "shared";
|
|
1789
|
+
databaseMode: "current" | "separate";
|
|
1790
|
+
}
|
|
1791
|
+
export interface PluginWorkspaceSite {
|
|
1792
|
+
id: string;
|
|
1793
|
+
tenantId: string;
|
|
1794
|
+
name: string;
|
|
1795
|
+
hostname: string | null;
|
|
1796
|
+
status: string;
|
|
1797
|
+
databaseChoice: "inherit" | "current" | "separate";
|
|
1798
|
+
}
|
|
1799
|
+
/** The workspace bound to the current request. No connection secrets. */
|
|
1800
|
+
export interface PluginWorkspaceContext {
|
|
1801
|
+
tenantId: string;
|
|
1802
|
+
siteId: string;
|
|
1803
|
+
hostname: string;
|
|
1804
|
+
userMode: "isolated" | "shared";
|
|
1805
|
+
databaseMode: "current" | "separate";
|
|
1806
|
+
/** True on the site created with the installation. */
|
|
1807
|
+
rootSite: boolean;
|
|
1808
|
+
}
|
|
1809
|
+
export interface PluginWorkspaceAdminInput {
|
|
1810
|
+
email: string;
|
|
1811
|
+
username: string;
|
|
1812
|
+
displayName: string;
|
|
1813
|
+
password: string;
|
|
1814
|
+
}
|
|
1815
|
+
export interface PluginWorkspaceDatabaseInput {
|
|
1816
|
+
host: string;
|
|
1817
|
+
port: number;
|
|
1818
|
+
database: string;
|
|
1819
|
+
username: string;
|
|
1820
|
+
password: string;
|
|
1821
|
+
}
|
|
1822
|
+
export interface PluginCreateWorkspaceInput {
|
|
1823
|
+
name: string;
|
|
1824
|
+
slug?: string;
|
|
1825
|
+
userMode: "isolated" | "shared";
|
|
1826
|
+
databaseMode: "current" | "separate";
|
|
1827
|
+
siteName: string;
|
|
1828
|
+
hostname: string;
|
|
1829
|
+
admin: PluginWorkspaceAdminInput;
|
|
1830
|
+
database?: PluginWorkspaceDatabaseInput;
|
|
1831
|
+
}
|
|
1832
|
+
export interface PluginAddSiteInput {
|
|
1833
|
+
name: string;
|
|
1834
|
+
hostname: string;
|
|
1835
|
+
databaseChoice: "inherit" | "current" | "separate";
|
|
1836
|
+
database?: PluginWorkspaceDatabaseInput;
|
|
1837
|
+
admin?: PluginWorkspaceAdminInput;
|
|
1838
|
+
}
|
|
1839
|
+
export type PluginTenancyResult = {
|
|
1840
|
+
ok: true;
|
|
1841
|
+
tenantId: string;
|
|
1842
|
+
siteId: string;
|
|
1843
|
+
hostname: string;
|
|
1844
|
+
} | {
|
|
1845
|
+
ok: false;
|
|
1846
|
+
status: number;
|
|
1847
|
+
error: string;
|
|
1848
|
+
};
|
|
1849
|
+
/**
|
|
1850
|
+
* Workspace and site placement. `current()` is available to every plugin.
|
|
1851
|
+
* `siblingSites()` lists the current workspace from any of its sites.
|
|
1852
|
+
* Every other call requires `platform:tenancy`, runs only on the
|
|
1853
|
+
* installation's root site, and is refused while the plugin works on behalf
|
|
1854
|
+
* of an AI agent, an API key or a connected app (an MCP or assistant tool
|
|
1855
|
+
* call, or a key-authenticated request). The host enforces this whatever the
|
|
1856
|
+
* plugin's code does. Stored database passwords are never returned.
|
|
1857
|
+
*/
|
|
1858
|
+
export interface PluginTenancyApi {
|
|
1859
|
+
current(): Promise<PluginWorkspaceContext | null>;
|
|
1860
|
+
/**
|
|
1861
|
+
* Active sites in the workspace handling this request. Requires
|
|
1862
|
+
* `platform:tenancy`. It works from any site in that workspace and cannot
|
|
1863
|
+
* see another workspace. Absent on older hosts.
|
|
1864
|
+
*/
|
|
1865
|
+
siblingSites?(): Promise<PluginWorkspaceSite[]>;
|
|
1866
|
+
listWorkspaces(): Promise<PluginWorkspace[]>;
|
|
1867
|
+
listSites(tenantId: string): Promise<PluginWorkspaceSite[]>;
|
|
1868
|
+
createWorkspace(input: PluginCreateWorkspaceInput): Promise<PluginTenancyResult>;
|
|
1869
|
+
addSite(tenantId: string, input: PluginAddSiteInput): Promise<PluginTenancyResult>;
|
|
1870
|
+
suspend(tenantId: string): Promise<PluginTenancyResult>;
|
|
1871
|
+
reactivate(tenantId: string): Promise<PluginTenancyResult>;
|
|
1872
|
+
/** Mark deleted for retention cleanup; dropDatabase requests full immediate purge. */
|
|
1873
|
+
deleteWorkspace(tenantId: string, options?: {
|
|
1874
|
+
dropDatabase?: boolean;
|
|
1875
|
+
}): Promise<PluginTenancyResult>;
|
|
1876
|
+
}
|
|
1877
|
+
/** One live site in the installation, as `ctx.network.sites()` lists it. */
|
|
1878
|
+
export interface PluginNetworkSite {
|
|
1879
|
+
id: string;
|
|
1880
|
+
name: string;
|
|
1881
|
+
/** Primary hostname, or null when the site has none yet. */
|
|
1882
|
+
hostname: string | null;
|
|
1883
|
+
/** True for the site created with the installation. */
|
|
1884
|
+
mainSite: boolean;
|
|
1885
|
+
}
|
|
1886
|
+
/**
|
|
1887
|
+
* Behaviour the installation's main site applies to every site. Requires
|
|
1888
|
+
* `platform:network`; absent without it and on older hosts.
|
|
1889
|
+
*
|
|
1890
|
+
* Pair it with hooks registered as `{ network: true }`: those handlers run on
|
|
1891
|
+
* every site while this plugin is active on the main site, even where a site
|
|
1892
|
+
* has not activated it. Inside them, `ctx.settings` and `ctx.data` still
|
|
1893
|
+
* belong to the request's site; read the main site's choices through
|
|
1894
|
+
* `mainSiteSettings`.
|
|
1895
|
+
*/
|
|
1896
|
+
export interface PluginNetworkApi {
|
|
1897
|
+
/** This plugin's settings on the main site, read-only, from any site. */
|
|
1898
|
+
mainSiteSettings: {
|
|
1899
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
1900
|
+
};
|
|
1901
|
+
/**
|
|
1902
|
+
* This plugin's secrets on the main site, read-only, from any site.
|
|
1903
|
+
* Absent on older hosts. The same key rules as `ctx.secrets` apply.
|
|
1904
|
+
* A hosted site cannot write them; the main site saves through `ctx.secrets`.
|
|
1905
|
+
*/
|
|
1906
|
+
mainSiteSecrets?: {
|
|
1907
|
+
get(key: string): Promise<string | undefined>;
|
|
1908
|
+
has(key: string): Promise<boolean>;
|
|
1909
|
+
};
|
|
1910
|
+
/**
|
|
1911
|
+
* Every live site in the installation, main site first. Only on the main
|
|
1912
|
+
* site; on any other site it rejects. The plugin decides what each site
|
|
1913
|
+
* gets, so another site's admins never see or change it.
|
|
1914
|
+
*/
|
|
1915
|
+
sites(): Promise<PluginNetworkSite[]>;
|
|
1916
|
+
/**
|
|
1917
|
+
* One live site and its public address, from any site. Omit `siteId` for
|
|
1918
|
+
* the main site. Null for an unknown or inactive site, and on an install
|
|
1919
|
+
* without sites. Absent on older hosts.
|
|
1920
|
+
*/
|
|
1921
|
+
site?(siteId?: string): Promise<PluginNetworkSiteAddress | null>;
|
|
1922
|
+
}
|
|
1923
|
+
/** One outbound request. Bodies are text; the response body is read as UTF-8 text. */
|
|
1924
|
+
export interface PluginOutboundRequest {
|
|
1925
|
+
method?: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
1926
|
+
headers?: Record<string, string>;
|
|
1927
|
+
body?: string;
|
|
1928
|
+
/** Default 15 000, at most 30 000. */
|
|
1929
|
+
timeoutMs?: number;
|
|
1930
|
+
/** Largest response body accepted. Default 1 MB, at most 10 MB. */
|
|
1931
|
+
maxBytes?: number;
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* A finished request, or why none was made or read. `blocked` means the URL
|
|
1935
|
+
* (or a redirect hop) points at a private, loopback, or otherwise refused
|
|
1936
|
+
* address, a port other than 80/443, or carries credentials.
|
|
1937
|
+
*/
|
|
1938
|
+
export type PluginOutboundResponse = {
|
|
1939
|
+
ok: true;
|
|
1940
|
+
status: number;
|
|
1941
|
+
headers: Record<string, string>;
|
|
1942
|
+
body: string;
|
|
1943
|
+
url: string;
|
|
1944
|
+
} | {
|
|
1945
|
+
ok: false;
|
|
1946
|
+
code: "blocked" | "too_large" | "timeout" | "failed";
|
|
1947
|
+
error: string;
|
|
1948
|
+
};
|
|
1949
|
+
/**
|
|
1950
|
+
* HTTP to addresses on the public internet, with the host's SSRF guard on the
|
|
1951
|
+
* first URL and every redirect hop, DNS pinned to the checked address, a
|
|
1952
|
+
* timeout, and a size limit. Requires `network:outbound`.
|
|
1953
|
+
*/
|
|
1954
|
+
export interface PluginOutboundApi {
|
|
1955
|
+
fetch(url: string, request?: PluginOutboundRequest): Promise<PluginOutboundResponse>;
|
|
1956
|
+
}
|
|
1957
|
+
/** A site with the origin its public pages are served from, such as `https://shop.example.com`. */
|
|
1958
|
+
export interface PluginNetworkSiteAddress extends PluginNetworkSite {
|
|
1959
|
+
url: string;
|
|
1960
|
+
}
|
|
1961
|
+
export type QuotaScope = "workspace" | "site";
|
|
1962
|
+
export type QuotaUnit = "count" | "bytes" | "flag";
|
|
1963
|
+
/** A meter a plugin asks the host to enforce. The key must start with the plugin id. */
|
|
1964
|
+
export interface QuotaMeterRegistration {
|
|
1965
|
+
key: string;
|
|
1966
|
+
scope: QuotaScope;
|
|
1967
|
+
label: string;
|
|
1968
|
+
unit: QuotaUnit;
|
|
1969
|
+
/**
|
|
1970
|
+
* Flags are on until a stored limit of 0 turns them off. `"off"` means a
|
|
1971
|
+
* missing limit stays off, and only a limit above 0 turns the flag on.
|
|
1972
|
+
* Use that for a feature a plan or an operator turns on.
|
|
1973
|
+
*/
|
|
1974
|
+
whenUnset?: "on" | "off";
|
|
1975
|
+
/**
|
|
1976
|
+
* Current usage for one workspace or site. The platform limits page calls
|
|
1977
|
+
* this. Omit it when the plugin only passes `used` to `check`.
|
|
1978
|
+
*/
|
|
1979
|
+
count?(scopeId: string): Promise<number>;
|
|
1980
|
+
}
|
|
1981
|
+
/** Result of `quotas.check`. `limit` and `remaining` are null when nothing is configured. */
|
|
1982
|
+
export interface QuotaDecision {
|
|
1983
|
+
ok: boolean;
|
|
1984
|
+
limit: number | null;
|
|
1985
|
+
used: number;
|
|
1986
|
+
remaining: number | null;
|
|
1987
|
+
}
|
|
1988
|
+
/** One meter as the host currently knows it. `used` is null when it could not be counted. */
|
|
1989
|
+
export interface QuotaMeterView {
|
|
1990
|
+
key: string;
|
|
1991
|
+
scope: QuotaScope;
|
|
1992
|
+
label: string;
|
|
1993
|
+
unit: QuotaUnit;
|
|
1994
|
+
limit: number | null;
|
|
1995
|
+
used: number | null;
|
|
1996
|
+
/** Present when a missing flag limit means off. */
|
|
1997
|
+
whenUnset?: "off";
|
|
1998
|
+
}
|
|
1999
|
+
/**
|
|
2000
|
+
* Another workspace or site to read or write limits for. Only with
|
|
2001
|
+
* `platform:tenancy`, and only from the installation's root site: a plugin on a
|
|
2002
|
+
* hosted site cannot change other workspaces. A `siteId` reaches workspace
|
|
2003
|
+
* meters through that site's workspace; a `tenantId` reaches workspace meters only.
|
|
2004
|
+
*/
|
|
2005
|
+
export type PluginQuotaTarget = {
|
|
2006
|
+
tenantId: string;
|
|
2007
|
+
} | {
|
|
2008
|
+
siteId: string;
|
|
2009
|
+
};
|
|
2010
|
+
/** A meter the host knows: core meters and those plugins registered. */
|
|
2011
|
+
export interface PluginQuotaMeterInfo {
|
|
2012
|
+
key: string;
|
|
2013
|
+
scope: QuotaScope;
|
|
2014
|
+
label: string;
|
|
2015
|
+
unit: QuotaUnit;
|
|
2016
|
+
/** `core`, or the id of the plugin that registered it. */
|
|
2017
|
+
owner: string;
|
|
2018
|
+
}
|
|
2019
|
+
/**
|
|
2020
|
+
* Configured ceilings. Every plugin may register meters and check them.
|
|
2021
|
+
* `set` writes the same limits a platform operator edits: it requires
|
|
2022
|
+
* `platform:tenancy`, runs only on the installation's root site (also for the
|
|
2023
|
+
* plugin's own workspace), and is refused on behalf of an AI agent or API
|
|
2024
|
+
* key. A missing limit is unlimited.
|
|
2025
|
+
*/
|
|
2026
|
+
export interface PluginQuotasApi {
|
|
2027
|
+
register(meter: QuotaMeterRegistration): Unsubscribe;
|
|
2028
|
+
/**
|
|
2029
|
+
* Whether `delta` more units still fit. Core meters (`sites`, `users`,
|
|
2030
|
+
* `content`, `media.bytes`) are counted by the host. A plugin meter needs
|
|
2031
|
+
* `used`, the plugin's own current count, before the new units.
|
|
2032
|
+
*/
|
|
2033
|
+
check(key: string, input?: {
|
|
2034
|
+
delta?: number;
|
|
2035
|
+
used?: number;
|
|
2036
|
+
}): Promise<QuotaDecision>;
|
|
2037
|
+
/** With `target`, the meter of that workspace or site (see `PluginQuotaTarget`). */
|
|
2038
|
+
get(key: string, target?: PluginQuotaTarget): Promise<QuotaMeterView>;
|
|
2039
|
+
/**
|
|
2040
|
+
* `null` clears the meter back to unlimited. Without `target`, this plugin's
|
|
2041
|
+
* own workspace or site; with it, that one (see `PluginQuotaTarget`).
|
|
2042
|
+
*/
|
|
2043
|
+
set(key: string, limit: number | null, target?: PluginQuotaTarget): Promise<void>;
|
|
2044
|
+
/** Every meter the host enforces. Optional: older hosts do not provide it. */
|
|
2045
|
+
meters?(): Promise<PluginQuotaMeterInfo[]>;
|
|
2046
|
+
}
|
|
2047
|
+
export type PluginRowValue = string | number | boolean | null;
|
|
2048
|
+
/** Column equality filters. A `null` value matches `IS NULL`. */
|
|
2049
|
+
export type PluginRowMatch = Record<string, PluginRowValue>;
|
|
2050
|
+
export interface PluginRowOrder {
|
|
2051
|
+
column: string;
|
|
2052
|
+
direction?: "asc" | "desc";
|
|
2053
|
+
}
|
|
2054
|
+
/** Bounds on one column. Values are compared as the database compares them. */
|
|
2055
|
+
export interface PluginRowRange {
|
|
2056
|
+
gt?: Exclude<PluginRowValue, null>;
|
|
2057
|
+
gte?: Exclude<PluginRowValue, null>;
|
|
2058
|
+
lt?: Exclude<PluginRowValue, null>;
|
|
2059
|
+
lte?: Exclude<PluginRowValue, null>;
|
|
2060
|
+
}
|
|
2061
|
+
export interface PluginRowFindOptions {
|
|
2062
|
+
/** Defaults to 100, capped at 500. */
|
|
2063
|
+
limit?: number;
|
|
2064
|
+
/** Deterministic order. Add `id` last when other columns can tie. */
|
|
2065
|
+
orderBy?: PluginRowOrder[];
|
|
2066
|
+
/**
|
|
2067
|
+
* Range conditions, combined with the equality `where`:
|
|
2068
|
+
* `{ created_at: { gte: "2026-10-01 00:00:00", lt: "2026-11-01 00:00:00" } }`.
|
|
2069
|
+
*/
|
|
2070
|
+
range?: Record<string, PluginRowRange>;
|
|
2071
|
+
/**
|
|
2072
|
+
* Keyset paging: return the rows after this one in `orderBy` order. Pass the
|
|
2073
|
+
* `orderBy` column values of the last row of the previous page; every
|
|
2074
|
+
* `orderBy` column is required and may not be null. Requires `orderBy`.
|
|
2075
|
+
*/
|
|
2076
|
+
after?: PluginRowMatch;
|
|
2077
|
+
/**
|
|
2078
|
+
* Lock the matched rows (`SELECT … FOR UPDATE`) until the surrounding
|
|
2079
|
+
* `transaction` ends. Has no lasting effect outside a transaction.
|
|
2080
|
+
*/
|
|
2081
|
+
lock?: boolean;
|
|
2082
|
+
}
|
|
2083
|
+
export interface PluginRowIncrementOptions {
|
|
2084
|
+
/**
|
|
2085
|
+
* Lower bounds the row must still meet after the change. A row that would
|
|
2086
|
+
* fall below one is left alone and is not counted.
|
|
2087
|
+
*/
|
|
2088
|
+
min?: Record<string, number>;
|
|
2089
|
+
/** Plain values written in the same statement, such as `updated_at`. */
|
|
2090
|
+
set?: PluginRowMatch;
|
|
2091
|
+
}
|
|
2092
|
+
/**
|
|
2093
|
+
* Row operations on plugin-owned tables, always scoped to the current site.
|
|
2094
|
+
* Inside `transaction`, the same methods run on the transaction's connection
|
|
2095
|
+
* and errors propagate instead of returning empty results.
|
|
2096
|
+
*/
|
|
2097
|
+
export interface PluginRowOps {
|
|
2098
|
+
findOne(table: string, where?: PluginRowMatch, options?: Omit<PluginRowFindOptions, "limit">): Promise<Record<string, unknown> | undefined>;
|
|
2099
|
+
find(table: string, where?: PluginRowMatch, options?: PluginRowFindOptions): Promise<Record<string, unknown>[]>;
|
|
2100
|
+
/**
|
|
2101
|
+
* Insert one row. Returns `false`, and writes nothing, when a unique key
|
|
2102
|
+
* already holds an equal value. Use it to claim an idempotency key or event.
|
|
2103
|
+
*/
|
|
2104
|
+
insert(table: string, row: PluginRowMatch): Promise<boolean>;
|
|
2105
|
+
upsert(table: string, row: PluginRowMatch, options?: {
|
|
2106
|
+
match?: string[];
|
|
2107
|
+
}): Promise<void>;
|
|
2108
|
+
/**
|
|
2109
|
+
* Set `values` on every row matching `where`. Returns the number of matched
|
|
2110
|
+
* rows, so a status or version in `where` works as compare-and-set.
|
|
2111
|
+
* `where` must name at least one column.
|
|
2112
|
+
*/
|
|
2113
|
+
update(table: string, where: PluginRowMatch, values: PluginRowMatch): Promise<number>;
|
|
2114
|
+
/**
|
|
2115
|
+
* Add integer deltas in one statement (`available = available - 2`), so
|
|
2116
|
+
* concurrent callers cannot lose each other's change. Returns matched rows.
|
|
2117
|
+
*/
|
|
2118
|
+
increment(table: string, where: PluginRowMatch, deltas: Record<string, number>, options?: PluginRowIncrementOptions): Promise<number>;
|
|
2119
|
+
/** Returns the number of deleted rows. `where` must name at least one column. */
|
|
2120
|
+
delete(table: string, where: PluginRowMatch): Promise<number | void>;
|
|
2121
|
+
}
|
|
2122
|
+
export interface PluginDatabasesApi {
|
|
2123
|
+
/** Probe the site's existing Justflows database. */
|
|
2124
|
+
probeShared(): Promise<PluginDatabaseProbeResult>;
|
|
2125
|
+
/**
|
|
2126
|
+
* Open a short-lived connection to a database the plugin does not yet own.
|
|
2127
|
+
* Remote hosts require the `network:outbound` permission.
|
|
2128
|
+
*/
|
|
2129
|
+
probe(target: PluginDatabaseTarget): Promise<PluginDatabaseProbeResult>;
|
|
2130
|
+
/**
|
|
2131
|
+
* Create the plugin's tables if they are missing. Names are prefixed with the
|
|
2132
|
+
* plugin slug so a plugin cannot create `users` or other core tables.
|
|
2133
|
+
* Omit `target` to use the current Justflows database.
|
|
2134
|
+
*
|
|
2135
|
+
* Tables that already exist get the declared columns and indexes they lack,
|
|
2136
|
+
* so adding a column to a declaration upgrades existing installations. An
|
|
2137
|
+
* added column is nullable and not unique (existing rows have no value);
|
|
2138
|
+
* declare a unique index for it instead. Types, removed columns and removed
|
|
2139
|
+
* indexes are never changed: a plugin migrates its data itself.
|
|
2140
|
+
*/
|
|
2141
|
+
ensureSchema(tables: PluginSchemaTable[], options?: {
|
|
2142
|
+
target?: PluginDatabaseTarget;
|
|
2143
|
+
rebuild?: string[];
|
|
2144
|
+
}): Promise<PluginSchemaApplyResult>;
|
|
2145
|
+
/**
|
|
2146
|
+
* Drop this plugin's prefixed tables. Pass the same `tables` / `target` used
|
|
2147
|
+
* with `ensureSchema`. Omit `tables` to drop every table owned by the prefix.
|
|
2148
|
+
* Call this from `deleteData()` on the main site. Another site cannot drop
|
|
2149
|
+
* the tables: the host deletes that site's rows instead.
|
|
2150
|
+
*/
|
|
2151
|
+
dropSchema(tables?: PluginSchemaTable[], options?: {
|
|
2152
|
+
target?: PluginDatabaseTarget;
|
|
2153
|
+
}): Promise<PluginSchemaApplyResult>;
|
|
2154
|
+
/**
|
|
2155
|
+
* Delete this site's rows from the plugin's tables. Tables stay, so other
|
|
2156
|
+
* sites keep their rows. `site_id` is the only match.
|
|
2157
|
+
*/
|
|
2158
|
+
clear(tables?: PluginSchemaTable[]): Promise<PluginSchemaApplyResult>;
|
|
2159
|
+
/**
|
|
2160
|
+
* Insert or replace a row in a plugin-owned table (`stores` → `shop_stores`).
|
|
2161
|
+
* The host always sets `site_id`. `match` selects the existing row (default `id`).
|
|
2162
|
+
*/
|
|
2163
|
+
upsert(table: string, row: Record<string, string | number | boolean | null>, options?: {
|
|
2164
|
+
match?: string[];
|
|
2165
|
+
}): Promise<void>;
|
|
2166
|
+
/** First matching row in a plugin-owned table, always scoped to this site. */
|
|
2167
|
+
findOne(table: string, where?: PluginRowMatch, options?: Omit<PluginRowFindOptions, "limit">): Promise<Record<string, unknown> | undefined>;
|
|
2168
|
+
/**
|
|
2169
|
+
* Matching rows in a plugin-owned table, always scoped to this site.
|
|
2170
|
+
* `limit` defaults to 100 and is capped at 500.
|
|
2171
|
+
*/
|
|
2172
|
+
find(table: string, where?: PluginRowMatch, options?: PluginRowFindOptions): Promise<Record<string, unknown>[]>;
|
|
2173
|
+
/**
|
|
2174
|
+
* Delete matching rows in a plugin-owned table. `where` must include at
|
|
2175
|
+
* least one column besides the implicit site scope.
|
|
2176
|
+
*/
|
|
2177
|
+
delete(table: string, where: PluginRowMatch): Promise<void>;
|
|
2178
|
+
/** See `PluginRowOps.insert`. */
|
|
2179
|
+
insert(table: string, row: PluginRowMatch): Promise<boolean>;
|
|
2180
|
+
/** See `PluginRowOps.update`. */
|
|
2181
|
+
update(table: string, where: PluginRowMatch, values: PluginRowMatch): Promise<number>;
|
|
2182
|
+
/** See `PluginRowOps.increment`. */
|
|
2183
|
+
increment(table: string, where: PluginRowMatch, deltas: Record<string, number>, options?: PluginRowIncrementOptions): Promise<number>;
|
|
2184
|
+
/**
|
|
2185
|
+
* Run `fn` in one transaction on the database holding this plugin's tables:
|
|
2186
|
+
* it commits when `fn` resolves and rolls back when it throws. Calls to
|
|
2187
|
+
* `ctx.databases` row methods made while `fn` runs join the same
|
|
2188
|
+
* transaction, as does a nested `transaction`. Keep network calls out of
|
|
2189
|
+
* `fn`; locks are held until it returns.
|
|
2190
|
+
*/
|
|
2191
|
+
transaction<T>(fn: (tx: PluginRowOps) => Promise<T>): Promise<T>;
|
|
2192
|
+
/** Column names for a plugin-owned table, or `[]` when the table does not exist. */
|
|
2193
|
+
columns(table: string): Promise<string[]>;
|
|
2194
|
+
/**
|
|
2195
|
+
* This plugin's rows on another site in the installation. Requires
|
|
2196
|
+
* `platform:tenancy` and the installation's main site. Absent on older hosts.
|
|
2197
|
+
*/
|
|
2198
|
+
forSite?(siteId: string): PluginRowOps;
|
|
2199
|
+
}
|
|
2200
|
+
export interface PluginSecretsApi {
|
|
2201
|
+
set(key: string, value: string): Promise<void>;
|
|
2202
|
+
get(key: string): Promise<string | undefined>;
|
|
2203
|
+
has(key: string): Promise<boolean>;
|
|
2204
|
+
delete(key: string): Promise<void>;
|
|
2205
|
+
}
|
|
2206
|
+
export type PluginDiagnosticStatus = "ok" | "warning" | "error";
|
|
2207
|
+
export interface PluginDiagnosticResult {
|
|
2208
|
+
status: PluginDiagnosticStatus;
|
|
2209
|
+
summary: string;
|
|
2210
|
+
details?: Record<string, string | number | boolean | null>;
|
|
2211
|
+
}
|
|
2212
|
+
export interface PluginDiagnosticCheck {
|
|
2213
|
+
id: string;
|
|
2214
|
+
label: string;
|
|
2215
|
+
run(): PluginDiagnosticResult | Promise<PluginDiagnosticResult>;
|
|
2216
|
+
}
|
|
2217
|
+
export interface PluginDiagnosticsApi {
|
|
2218
|
+
/** Publish a sanitized, read-only health check. Requires `diagnostics:publish`. */ register(check: PluginDiagnosticCheck): Unsubscribe;
|
|
2219
|
+
}
|
|
2220
|
+
/**
|
|
2221
|
+
* The context object injected into every plugin's activate() function.
|
|
2222
|
+
* Extensions import this type from @justflows/sdk — never from @justflows/core.
|
|
2223
|
+
*/
|
|
2224
|
+
export interface PluginContext {
|
|
2225
|
+
readonly pluginId: string;
|
|
2226
|
+
/** Version of the activated plugin. */
|
|
2227
|
+
readonly version: string;
|
|
2228
|
+
/** Host and SDK versions for runtime feature detection and diagnostics. */
|
|
2229
|
+
readonly runtime: JustflowsRuntimeVersions;
|
|
2230
|
+
readonly permissions: ReadonlySet<PluginPermission>;
|
|
2231
|
+
readonly capabilities: PluginCapabilitiesApi;
|
|
2232
|
+
readonly roles: PluginRolesApi;
|
|
2233
|
+
readonly users: PluginUsersApi;
|
|
2234
|
+
readonly diagnostics: PluginDiagnosticsApi;
|
|
2235
|
+
/**
|
|
2236
|
+
* Shared jf-cache, scoped to this plugin. Always available; when caching is
|
|
2237
|
+
* disabled globally, reads miss and writes are no-ops (same as core).
|
|
2238
|
+
*/
|
|
2239
|
+
cache: PluginCacheApi;
|
|
2240
|
+
/**
|
|
2241
|
+
* Typed hook registration. Hook names autocomplete, payloads infer, and a
|
|
2242
|
+
* wrong handler signature fails at compile time. Every registration is owned
|
|
2243
|
+
* by this plugin and removed automatically on deactivation.
|
|
2244
|
+
*/
|
|
2245
|
+
hooks: {
|
|
2246
|
+
/** Observe an event. Failures are isolated and attributed to this plugin. */
|
|
2247
|
+
action<K extends ActionName>(hook: K, handler: ActionHandlerFor<K>, options?: HookRegisterOptions): Unsubscribe;
|
|
2248
|
+
/**
|
|
2249
|
+
* Validate a pending operation. Call `event.cancel(reason)` to block it.
|
|
2250
|
+
* Gates fail closed — throwing also aborts the operation.
|
|
2251
|
+
*/
|
|
2252
|
+
gate<K extends GateName>(hook: K, handler: GateHandlerFor<K>, options?: HookRegisterOptions): Unsubscribe;
|
|
2253
|
+
/** Transform a value. Handlers must return the next value. */
|
|
2254
|
+
filter<K extends FilterName>(hook: K, handler: FilterHandlerFor<K>, options?: HookRegisterOptions): Unsubscribe;
|
|
2255
|
+
/** Emit a hook owned by this plugin. Names outside its namespace are rejected. */
|
|
2256
|
+
/** Durable dispatch queues outbound webhooks first and propagates queue failures. */
|
|
2257
|
+
emit<K extends ActionName>(hook: K, event: ActionPayload<K>, options?: {
|
|
2258
|
+
durable?: true;
|
|
2259
|
+
}): Promise<void>;
|
|
2260
|
+
/** Apply a filter owned by this plugin. Names outside its namespace are rejected. */
|
|
2261
|
+
apply<K extends FilterName>(hook: K, value: FilterValue<K>, context: FilterContext<K>): Promise<FilterValue<K>>;
|
|
2262
|
+
/**
|
|
2263
|
+
* Run a gate owned by this plugin. Throws when a listener cancels.
|
|
2264
|
+
* Names outside its namespace are rejected.
|
|
2265
|
+
*/
|
|
2266
|
+
check<K extends GateName>(hook: K, event: GatePayload<K>): Promise<void>;
|
|
2267
|
+
/** True when anything is listening — use to skip expensive payload work. */
|
|
2268
|
+
has(hook: string): boolean;
|
|
2269
|
+
};
|
|
2270
|
+
/**
|
|
2271
|
+
* Plugin key-value rows in `plugin_data` (not `site_settings`). Use dedicated
|
|
2272
|
+
* plugin tables for domain records such as a store or catalog.
|
|
2273
|
+
*/
|
|
2274
|
+
settings: {
|
|
2275
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
2276
|
+
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
2277
|
+
delete(key: string): Promise<void>;
|
|
2278
|
+
};
|
|
2279
|
+
/** Plugin-owned public HTTP routes. Paths starting with `/` claim a site-root path. */
|
|
2280
|
+
http: PluginHttpApi;
|
|
2281
|
+
/**
|
|
2282
|
+
* Durable-enough background work. Requires `jobs:register`. Registrations
|
|
2283
|
+
* are removed on deactivate.
|
|
2284
|
+
*/
|
|
2285
|
+
jobs: PluginJobsApi;
|
|
2286
|
+
/** Send mail or register outbound providers and namespaced email types. */
|
|
2287
|
+
mail: PluginMailTransportApi;
|
|
2288
|
+
/** Plugin-scoped JSON documents. No raw SQL. */
|
|
2289
|
+
data: PluginDataApi;
|
|
2290
|
+
/**
|
|
2291
|
+
* Encrypted credentials. Values are never returned by public APIs; `has()`
|
|
2292
|
+
* is the safe way to tell the admin UI a secret is already stored.
|
|
2293
|
+
*/
|
|
2294
|
+
secrets: PluginSecretsApi;
|
|
2295
|
+
/** Short-lived database probes for plugin-owned storage topology. */
|
|
2296
|
+
databases: PluginDatabasesApi;
|
|
2297
|
+
/**
|
|
2298
|
+
* Workspaces and sites. Read the request with `current()`. Creating,
|
|
2299
|
+
* suspending, and deleting requires `platform:tenancy`.
|
|
2300
|
+
*/
|
|
2301
|
+
tenancy: PluginTenancyApi;
|
|
2302
|
+
/**
|
|
2303
|
+
* Network-wide behaviour set on the main site. Requires `platform:network`.
|
|
2304
|
+
* Absent without that permission and on older hosts. See `PluginNetworkApi`.
|
|
2305
|
+
*/
|
|
2306
|
+
network?: PluginNetworkApi;
|
|
2307
|
+
/**
|
|
2308
|
+
* Guarded outbound HTTP. Requires `network:outbound`; absent without it and
|
|
2309
|
+
* on older hosts. See `PluginOutboundApi`.
|
|
2310
|
+
*/
|
|
2311
|
+
outbound?: PluginOutboundApi;
|
|
2312
|
+
/**
|
|
2313
|
+
* Workspace and site ceilings. Register a meter, then `check` it before
|
|
2314
|
+
* creating a record the host does not count itself. `set` requires
|
|
2315
|
+
* `platform:tenancy`.
|
|
2316
|
+
*/
|
|
2317
|
+
quotas: PluginQuotasApi;
|
|
2318
|
+
/**
|
|
2319
|
+
* Private files for this site, never public. Requires `files:private`.
|
|
2320
|
+
* Stored on the storage the site resolves to (its own S3 connection, the
|
|
2321
|
+
* root site's, the environment bucket, or local disk) and counted against
|
|
2322
|
+
* the site's `files.count` / `files.bytes` limits. Serve one with a route
|
|
2323
|
+
* that returns `{ file: { key } }`. Absent on older hosts.
|
|
2324
|
+
*/
|
|
2325
|
+
files?: PluginFilesApi;
|
|
2326
|
+
/**
|
|
2327
|
+
* The site cookie registry. `declare()` every non-essential cookie this plugin
|
|
2328
|
+
* sets so the consent banner can disclose it and expire it on withdrawal;
|
|
2329
|
+
* `list()` returns the whole registry (host + all plugins) with operator
|
|
2330
|
+
* overrides applied. Declarations are removed on deactivate.
|
|
2331
|
+
*/
|
|
2332
|
+
cookies: PluginCookiesApi;
|
|
2333
|
+
/** Register block types for the editor and public renderer. Removed on deactivate. */
|
|
2334
|
+
blocks: PluginBlocksApi;
|
|
2335
|
+
/** Register sanitized block patterns for the editor. Removed on deactivate. */
|
|
2336
|
+
patterns: PluginPatternsApi;
|
|
2337
|
+
/**
|
|
2338
|
+
* Add content visibility rule types. Requires `content:read`. Removed on
|
|
2339
|
+
* deactivate. See `docs/CONTENT_VISIBILITY.md`.
|
|
2340
|
+
*/
|
|
2341
|
+
visibility: PluginVisibilityApi;
|
|
2342
|
+
/**
|
|
2343
|
+
* Placeholder images for empty image slots. Use `placeholder()` instead of
|
|
2344
|
+
* shipping a private fallback so the site owner's choice applies everywhere.
|
|
2345
|
+
* No permission required.
|
|
2346
|
+
*/
|
|
2347
|
+
media: PluginMediaApi;
|
|
2348
|
+
/**
|
|
2349
|
+
* Create content types and pages the plugin needs. Requires `content:create`.
|
|
2350
|
+
* Publishing a page also requires `content:publish`. `deleteType` requires
|
|
2351
|
+
* `content:delete`. Existing slugs are left alone on create (idempotent).
|
|
2352
|
+
* `listPublished` and `getPublished` require `content:read`.
|
|
2353
|
+
*/
|
|
2354
|
+
content: PluginContentApi;
|
|
2355
|
+
/** The site's configured locales. Read-only; no permission required. */
|
|
2356
|
+
i18n: {
|
|
2357
|
+
/** The site's default locale code (BCP-47), e.g. `en-US`. */
|
|
2358
|
+
defaultLocale(): Promise<string>;
|
|
2359
|
+
/** Every active locale code, default first. */
|
|
2360
|
+
locales(): Promise<string[]>;
|
|
2361
|
+
/** The site's time zone (IANA) from Settings → General, e.g. `Europe/Amsterdam`. `UTC` when unset. */
|
|
2362
|
+
timeZone(): Promise<string>;
|
|
2363
|
+
/**
|
|
2364
|
+
* Every ISO 3166-1 country with its name in `locale` (default: the site's
|
|
2365
|
+
* default locale), sorted by name. The same list core and plugin settings use.
|
|
2366
|
+
*/
|
|
2367
|
+
countries(locale?: string): Promise<{
|
|
2368
|
+
code: string;
|
|
2369
|
+
name: string;
|
|
2370
|
+
}[]>;
|
|
2371
|
+
};
|
|
2372
|
+
/**
|
|
2373
|
+
* The site's Discussion CAPTCHA. Absent on older hosts. `config()` never
|
|
2374
|
+
* includes the secret.
|
|
2375
|
+
*/
|
|
2376
|
+
captcha?: PluginCaptchaApi;
|
|
2377
|
+
/**
|
|
2378
|
+
* Call another active plugin's own HTTP route in-process. The session is the
|
|
2379
|
+
* one you pass; this does not grant that plugin's capabilities. Absent on
|
|
2380
|
+
* older hosts.
|
|
2381
|
+
*/
|
|
2382
|
+
plugins?: PluginBridgeApi;
|
|
2383
|
+
/** The site's configured assistant. Absent on older hosts. */
|
|
2384
|
+
ai?: PluginAiApi;
|
|
2385
|
+
logger: {
|
|
2386
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
2387
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
2388
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
2389
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
2390
|
+
};
|
|
2391
|
+
}
|
|
2392
|
+
/**
|
|
2393
|
+
* Setting key for a keep/delete choice on uninstall. When absent, `deleteData`
|
|
2394
|
+
* should run its cleanup (silent). When present, honour the stored boolean.
|
|
2395
|
+
*/
|
|
2396
|
+
export declare const PLUGIN_DELETE_DATA_SETTING = "deleteDataOnUninstall";
|
|
2397
|
+
/** Setting key for deleting CMS types and entries the plugin created on uninstall. */
|
|
2398
|
+
export declare const PLUGIN_DELETE_CONTENT_SETTING = "deleteContentOnUninstall";
|
|
2399
|
+
export declare function pluginShouldDeleteData(ctx: Pick<PluginContext, "settings">, silentDefault?: boolean): Promise<boolean>;
|
|
2400
|
+
export declare function pluginShouldDeleteContent(ctx: Pick<PluginContext, "settings">, silentDefault?: boolean): Promise<boolean>;
|
|
2401
|
+
/**
|
|
2402
|
+
* A Justflows plugin module must export an object matching this interface.
|
|
2403
|
+
*/
|
|
2404
|
+
export interface PluginModule {
|
|
2405
|
+
manifest: PluginManifest;
|
|
2406
|
+
activate(ctx: PluginContext): void | Promise<void>;
|
|
2407
|
+
/**
|
|
2408
|
+
* Called when a site activates the plugin and the module is already running
|
|
2409
|
+
* because another site loaded it first. Create tables here. `activate` still
|
|
2410
|
+
* runs the first time the module loads.
|
|
2411
|
+
*/
|
|
2412
|
+
provision?(ctx: PluginContext): void | Promise<void>;
|
|
2413
|
+
deactivate?(ctx: PluginContext): void | Promise<void>;
|
|
2414
|
+
/**
|
|
2415
|
+
* Called when the plugin is deleted, before deactivation. Drop tables and
|
|
2416
|
+
* stored rows here (`ctx.databases.dropSchema`, `ctx.data.clear`). Delete
|
|
2417
|
+
* CMS types the plugin created with `ctx.content.deleteType`. Run silently,
|
|
2418
|
+
* or honour `PLUGIN_DELETE_DATA_SETTING` / `PLUGIN_DELETE_CONTENT_SETTING`
|
|
2419
|
+
* if the plugin exposes those checkboxes in `settingsSchema`.
|
|
2420
|
+
*/
|
|
2421
|
+
deleteData(ctx: PluginContext): void | Promise<void>;
|
|
2422
|
+
}
|
|
2423
|
+
export {};
|
|
2424
|
+
//# sourceMappingURL=plugin.d.ts.map
|