@selfhelp/shared 1.29.0 → 1.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -0
- package/dist/index.d.mts +35 -85
- package/dist/index.d.ts +35 -85
- package/dist/index.js +18 -5
- package/dist/index.mjs +15 -5
- package/dist/inlineFormat-Duu5VLMU.d.mts +73 -0
- package/dist/inlineFormat-Duu5VLMU.d.ts +73 -0
- package/dist/{manifest-BNnCN1Qo.d.mts → manifest-DWHD0PQA.d.mts} +168 -1
- package/dist/{manifest-BNnCN1Qo.d.ts → manifest-DWHD0PQA.d.ts} +168 -1
- package/dist/plugin-sdk/index.d.mts +260 -7
- package/dist/plugin-sdk/index.d.ts +260 -7
- package/dist/plugin-sdk/index.js +174 -2
- package/dist/plugin-sdk/index.mjs +171 -2
- package/dist/plugin-sdk/sync-map.d.mts +22 -0
- package/dist/plugin-sdk/sync-map.d.ts +22 -0
- package/dist/plugin-sdk/sync-map.js +58 -0
- package/dist/plugin-sdk/sync-map.mjs +33 -0
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.d.ts +2 -2
- package/dist/{styles.registry-DnIJqEzM.d.mts → styles.registry-B2cyNdo3.d.mts} +26 -1
- package/dist/{styles.registry-C2ACy7H0.d.ts → styles.registry-G_KUYGPv.d.ts} +26 -1
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/package.json +3 -3
- package/src/content/__tests__/languageIndependent.test.ts +26 -0
- package/src/content/__tests__/languageIndependentLiteral.test.ts +62 -0
- package/src/content/formRecordPrefill.ts +9 -7
- package/src/content/index.ts +1 -0
- package/src/content/languageIndependent.ts +28 -0
- package/src/plugin-sdk/__tests__/define-sync.test.ts +106 -0
- package/src/plugin-sdk/__tests__/exports.test.ts +29 -0
- package/src/plugin-sdk/__tests__/host-services.test.ts +96 -6
- package/src/plugin-sdk/__tests__/sync-map.test.ts +48 -0
- package/src/plugin-sdk/__tests__/version.test.ts +9 -0
- package/src/plugin-sdk/host-services.ts +106 -0
- package/src/plugin-sdk/index.ts +31 -0
- package/src/plugin-sdk/manifest.ts +193 -0
- package/src/plugin-sdk/sync-map.ts +61 -0
- package/src/plugin-sdk/types.ts +142 -2
- package/src/plugin-sdk/version.ts +19 -2
- package/src/sync/__tests__/sync.test.ts +19 -0
- package/src/sync/sync.ts +3 -2
- package/src/sync/types.ts +9 -6
- package/src/types/api/form-lists.ts +16 -1
- package/src/types/api/forms.ts +10 -0
|
@@ -127,6 +127,16 @@ interface IPluginManifestPermission {
|
|
|
127
127
|
/** Optional default role keys the permission is granted to. */
|
|
128
128
|
defaultRoles?: string[];
|
|
129
129
|
}
|
|
130
|
+
/** A field linked to a plugin style, with its editor metadata. */
|
|
131
|
+
interface IPluginManifestStyleField {
|
|
132
|
+
/** A field of the plugin (`fields`) or a core field such as `own_entries_only`. */
|
|
133
|
+
name: string;
|
|
134
|
+
title?: string;
|
|
135
|
+
help?: string;
|
|
136
|
+
default?: string | null;
|
|
137
|
+
hidden?: boolean;
|
|
138
|
+
disabled?: boolean;
|
|
139
|
+
}
|
|
130
140
|
interface IPluginManifestStyle {
|
|
131
141
|
/** Style name (used as `style_name` discriminator). */
|
|
132
142
|
name: string;
|
|
@@ -134,6 +144,40 @@ interface IPluginManifestStyle {
|
|
|
134
144
|
canHaveChildren: boolean;
|
|
135
145
|
/** Optional capability requirement (e.g. `frontendStyles`). */
|
|
136
146
|
capability?: IPluginManifestCapability;
|
|
147
|
+
/** Style group name; required when the installer creates the style. */
|
|
148
|
+
group?: string;
|
|
149
|
+
/** Earlier names of this style; the installer renames the row in place. */
|
|
150
|
+
renamedFrom?: string[];
|
|
151
|
+
/** When present, the installer makes the style's field links match this list. */
|
|
152
|
+
fields?: IPluginManifestStyleField[];
|
|
153
|
+
/**
|
|
154
|
+
* Field name → registered resource type of this plugin (`resourceTypes`
|
|
155
|
+
* lookup). The field must be declared for the style. Needs `pluginApiVersion`
|
|
156
|
+
* >= 0.2.0.
|
|
157
|
+
*/
|
|
158
|
+
resourceFields?: Record<string, string>;
|
|
159
|
+
}
|
|
160
|
+
/** Style group written into `style_groups` by the host installer (rule 7.8). */
|
|
161
|
+
interface IPluginManifestStyleGroup {
|
|
162
|
+
name: string;
|
|
163
|
+
description?: string;
|
|
164
|
+
position?: number;
|
|
165
|
+
}
|
|
166
|
+
/** Field type (editor control) written into `field_types`; kebab-case name. */
|
|
167
|
+
interface IPluginManifestFieldType {
|
|
168
|
+
name: string;
|
|
169
|
+
position?: number;
|
|
170
|
+
}
|
|
171
|
+
/** Plugin-owned field written into `fields`; snake_case name. */
|
|
172
|
+
interface IPluginManifestField {
|
|
173
|
+
name: string;
|
|
174
|
+
/** A core field type or one declared under `fieldTypes`. */
|
|
175
|
+
type: string;
|
|
176
|
+
/** True for participant-facing content stored per language. */
|
|
177
|
+
translatable?: boolean;
|
|
178
|
+
config?: Record<string, unknown> | null;
|
|
179
|
+
/** Earlier names of this field; the installer renames the row in place. */
|
|
180
|
+
renamedFrom?: string[];
|
|
137
181
|
}
|
|
138
182
|
interface IPluginManifestAdminPage {
|
|
139
183
|
/** Slug under `/admin/plugins-host/{pluginId}/`. */
|
|
@@ -161,12 +205,99 @@ interface IPluginManifestApiRoute {
|
|
|
161
205
|
*/
|
|
162
206
|
public?: boolean;
|
|
163
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Inline JSON Schema for an action-plannable plugin job config. Allowed property
|
|
210
|
+
* types are `string`, `integer`, `number` and `boolean`; nesting is not allowed.
|
|
211
|
+
* `format: "variable-text"` marks a string that accepts `{{variables}}`.
|
|
212
|
+
*/
|
|
213
|
+
interface IPluginManifestJobConfigSchema {
|
|
214
|
+
type: 'object';
|
|
215
|
+
properties?: Record<string, IPluginManifestJobConfigProperty>;
|
|
216
|
+
required?: string[];
|
|
217
|
+
additionalProperties?: boolean;
|
|
218
|
+
}
|
|
219
|
+
interface IPluginManifestJobConfigProperty {
|
|
220
|
+
type: 'string' | 'integer' | 'number' | 'boolean';
|
|
221
|
+
enum?: Array<string | number | boolean>;
|
|
222
|
+
minimum?: number;
|
|
223
|
+
maximum?: number;
|
|
224
|
+
maxLength?: number;
|
|
225
|
+
title?: string;
|
|
226
|
+
description?: string;
|
|
227
|
+
default?: string | number | boolean;
|
|
228
|
+
/** Marks a string that accepts `{{variables}}` when the action plans the job. */
|
|
229
|
+
format?: 'variable-text';
|
|
230
|
+
}
|
|
164
231
|
interface IPluginManifestScheduledJob {
|
|
165
232
|
/** Job type key. */
|
|
166
233
|
type: string;
|
|
167
234
|
description: string;
|
|
168
235
|
/** Capability gate (always requires `scheduledJobs`). */
|
|
169
236
|
capability: 'scheduledJobs';
|
|
237
|
+
/** Required when `actionPlannable` is true. Shown in the action builder. */
|
|
238
|
+
label?: string;
|
|
239
|
+
/** When true, editors may plan this job type in an action. Default false. */
|
|
240
|
+
actionPlannable?: boolean;
|
|
241
|
+
/** Inline JSON Schema for `plugin_config` when the job is planned from an action. */
|
|
242
|
+
configSchema?: IPluginManifestJobConfigSchema;
|
|
243
|
+
/** Config property → registered resource type of this plugin. */
|
|
244
|
+
resourceFields?: Record<string, string>;
|
|
245
|
+
/** Child-process timeout in seconds (10 to 900). Default 120. */
|
|
246
|
+
timeoutSeconds?: number;
|
|
247
|
+
}
|
|
248
|
+
/** Cache category declared by a plugin; stored as `<plugin id>.<name>`. */
|
|
249
|
+
interface IPluginManifestCacheCategory {
|
|
250
|
+
/** `^[a-z][a-z0-9_]{0,40}$`. */
|
|
251
|
+
name: string;
|
|
252
|
+
/** Lifetime in seconds (60 to 86400). */
|
|
253
|
+
ttlSeconds: number;
|
|
254
|
+
description?: string;
|
|
255
|
+
}
|
|
256
|
+
/** Instance setting declared by a plugin; stored by the host (C14). */
|
|
257
|
+
interface IPluginManifestSetting {
|
|
258
|
+
/** `^[a-z][a-z0-9_]{0,63}$`. */
|
|
259
|
+
key: string;
|
|
260
|
+
label: string;
|
|
261
|
+
type: 'string' | 'number' | 'boolean' | 'url';
|
|
262
|
+
/** Default false. Secrets are encrypted at rest and never returned clear. */
|
|
263
|
+
secret?: boolean;
|
|
264
|
+
/** Default false. */
|
|
265
|
+
required?: boolean;
|
|
266
|
+
/** Not allowed when `secret` is true. */
|
|
267
|
+
default?: string | number | boolean;
|
|
268
|
+
/** `^[A-Z][A-Z0-9_]{2,63}$`, unique across enabled plugins. */
|
|
269
|
+
envOverride?: string;
|
|
270
|
+
}
|
|
271
|
+
/** Rate limit declared by a plugin (C15). */
|
|
272
|
+
interface IPluginManifestRateLimit {
|
|
273
|
+
/** `^[a-z][a-z0-9_]{0,40}$`. */
|
|
274
|
+
name: string;
|
|
275
|
+
policy: 'sliding_window' | 'fixed_window';
|
|
276
|
+
/** 1 to 100000. */
|
|
277
|
+
limit: number;
|
|
278
|
+
/** Symfony rate-limiter interval string (e.g. `1 minute`). */
|
|
279
|
+
interval: string;
|
|
280
|
+
}
|
|
281
|
+
/** JSON Logic operation declared by a plugin (C16). */
|
|
282
|
+
interface IPluginManifestJsonLogicOperation {
|
|
283
|
+
/** `^[a-z][a-z0-9_]*\.[a-z][a-z0-9_]*$`; the namespace belongs to one plugin. */
|
|
284
|
+
name: string;
|
|
285
|
+
description: string;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* After-commit domain events a plugin may listen to (C24). Must match the host
|
|
289
|
+
* event names exactly.
|
|
290
|
+
*/
|
|
291
|
+
type TPluginDomainEventName = 'record.saved' | 'record.deleted' | 'user.created' | 'user.deleted' | 'page.published';
|
|
292
|
+
/** Recurring plugin job (C25). `type` must be one of the plugin's `scheduledJobs`. */
|
|
293
|
+
interface IPluginManifestRecurringJob {
|
|
294
|
+
/** `^[a-z][a-z0-9_]{0,40}$`. */
|
|
295
|
+
name: string;
|
|
296
|
+
/** One of this plugin's `scheduledJobs[].type`. */
|
|
297
|
+
type: string;
|
|
298
|
+
/** Five-field cron, UTC, at least 5 minutes apart. */
|
|
299
|
+
cron: string;
|
|
300
|
+
description: string;
|
|
170
301
|
}
|
|
171
302
|
interface IPluginManifestAsset {
|
|
172
303
|
/** Source path within the plugin package. */
|
|
@@ -249,12 +380,48 @@ interface IPluginManifest {
|
|
|
249
380
|
};
|
|
250
381
|
/** Styles contributed to the registry. */
|
|
251
382
|
styles?: IPluginManifestStyle[];
|
|
383
|
+
/** Style groups the host installer writes (rule 7.8). */
|
|
384
|
+
styleGroups?: IPluginManifestStyleGroup[];
|
|
385
|
+
/** Field types the host installer writes (rule 7.8). */
|
|
386
|
+
fieldTypes?: IPluginManifestFieldType[];
|
|
387
|
+
/** Plugin-owned fields the host installer writes (rule 7.8). */
|
|
388
|
+
fields?: IPluginManifestField[];
|
|
252
389
|
/** Admin pages mounted under `/admin/plugins-host/{pluginId}/`. */
|
|
253
390
|
adminPages?: IPluginManifestAdminPage[];
|
|
254
391
|
/** Plugin-owned API routes. */
|
|
255
392
|
apiRoutes?: IPluginManifestApiRoute[];
|
|
256
393
|
/** Scheduled jobs. */
|
|
257
394
|
scheduledJobs?: IPluginManifestScheduledJob[];
|
|
395
|
+
/**
|
|
396
|
+
* Cache categories the host registers for this plugin (C4). Needs
|
|
397
|
+
* `pluginApiVersion` >= 0.2.0.
|
|
398
|
+
*/
|
|
399
|
+
cacheCategories?: IPluginManifestCacheCategory[];
|
|
400
|
+
/**
|
|
401
|
+
* Instance settings and secrets stored by the host (C14). Needs
|
|
402
|
+
* `pluginApiVersion` >= 0.2.0.
|
|
403
|
+
*/
|
|
404
|
+
settings?: IPluginManifestSetting[];
|
|
405
|
+
/**
|
|
406
|
+
* Rate limits the host builds for this plugin (C15). Needs
|
|
407
|
+
* `pluginApiVersion` >= 0.2.0.
|
|
408
|
+
*/
|
|
409
|
+
rateLimits?: IPluginManifestRateLimit[];
|
|
410
|
+
/**
|
|
411
|
+
* JSON Logic operations the host registers for conditions (C16). Needs
|
|
412
|
+
* `pluginApiVersion` >= 0.2.0.
|
|
413
|
+
*/
|
|
414
|
+
jsonLogicOperations?: IPluginManifestJsonLogicOperation[];
|
|
415
|
+
/**
|
|
416
|
+
* After-commit domain events this plugin's listeners receive (C24). Needs
|
|
417
|
+
* `pluginApiVersion` >= 0.2.0.
|
|
418
|
+
*/
|
|
419
|
+
listens?: TPluginDomainEventName[];
|
|
420
|
+
/**
|
|
421
|
+
* Recurring jobs the host keeps queued while the plugin is enabled (C25).
|
|
422
|
+
* Needs `pluginApiVersion` >= 0.2.0.
|
|
423
|
+
*/
|
|
424
|
+
recurringJobs?: IPluginManifestRecurringJob[];
|
|
258
425
|
/** Vendored assets. */
|
|
259
426
|
assets?: IPluginManifestAsset[];
|
|
260
427
|
/** Health-check declaration. */
|
|
@@ -263,4 +430,4 @@ interface IPluginManifest {
|
|
|
263
430
|
labels?: Record<string, string>;
|
|
264
431
|
}
|
|
265
432
|
|
|
266
|
-
export type { IPluginManifest as I, IPluginManifestAdminPage as a, IPluginManifestApiRoute as b, IPluginManifestAsset as c,
|
|
433
|
+
export type { IPluginManifestStyle as A, IPluginManifestStyleField as B, IPluginManifestStyleGroup as C, IPluginManifestTrustLevel as D, IPluginManifest as I, TPluginDomainEventName as T, IPluginManifestAdminPage as a, IPluginManifestApiRoute as b, IPluginManifestAsset as c, IPluginManifestCacheCategory as d, IPluginManifestCapability as e, IPluginManifestCompatibility as f, IPluginManifestConflict as g, IPluginManifestDataAccess as h, IPluginManifestDependency as i, IPluginManifestExternalHost as j, IPluginManifestFeatureFlag as k, IPluginManifestField as l, IPluginManifestFieldType as m, IPluginManifestHealth as n, IPluginManifestJobConfigProperty as o, IPluginManifestJobConfigSchema as p, IPluginManifestJsonLogicOperation as q, IPluginManifestLookupExtension as r, IPluginManifestMobile as s, IPluginManifestPermission as t, IPluginManifestRateLimit as u, IPluginManifestRealtimeTopic as v, IPluginManifestRecurringJob as w, IPluginManifestScheduledJob as x, IPluginManifestSecurity as y, IPluginManifestSetting as z };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export { I as IPluginManifest, a as IPluginManifestAdminPage, b as IPluginManifestApiRoute, c as IPluginManifestAsset, d as
|
|
2
|
-
import { I as IStyleRegistryEntry } from '../styles.registry-
|
|
1
|
+
export { I as IPluginManifest, a as IPluginManifestAdminPage, b as IPluginManifestApiRoute, c as IPluginManifestAsset, d as IPluginManifestCacheCategory, e as IPluginManifestCapability, f as IPluginManifestCompatibility, g as IPluginManifestConflict, h as IPluginManifestDataAccess, i as IPluginManifestDependency, j as IPluginManifestExternalHost, k as IPluginManifestFeatureFlag, l as IPluginManifestField, m as IPluginManifestFieldType, n as IPluginManifestHealth, o as IPluginManifestJobConfigProperty, p as IPluginManifestJobConfigSchema, q as IPluginManifestJsonLogicOperation, r as IPluginManifestLookupExtension, s as IPluginManifestMobile, t as IPluginManifestPermission, u as IPluginManifestRateLimit, v as IPluginManifestRealtimeTopic, w as IPluginManifestRecurringJob, x as IPluginManifestScheduledJob, y as IPluginManifestSecurity, z as IPluginManifestSetting, A as IPluginManifestStyle, B as IPluginManifestStyleField, C as IPluginManifestStyleGroup, D as IPluginManifestTrustLevel, T as TPluginDomainEventName } from '../manifest-DWHD0PQA.mjs';
|
|
2
|
+
import { I as IStyleRegistryEntry } from '../styles.registry-B2cyNdo3.mjs';
|
|
3
|
+
import { IPluginSyncEntry } from './sync-map.mjs';
|
|
4
|
+
export { matchPluginSyncEntries } from './sync-map.mjs';
|
|
5
|
+
export { I as IInlineNode, p as parseInlineRich, s as stripHtmlToText } from '../inlineFormat-Duu5VLMU.mjs';
|
|
3
6
|
import '../common-qaDIAYS3.mjs';
|
|
4
7
|
|
|
5
8
|
/**
|
|
@@ -13,8 +16,16 @@ import '../common-qaDIAYS3.mjs';
|
|
|
13
16
|
* - major (1.x -> 2.0) — breaking SDK change.
|
|
14
17
|
*
|
|
15
18
|
* Independent from the npm `version` of `@selfhelp/shared`.
|
|
19
|
+
*
|
|
20
|
+
* `0.2.0` adds resource tags, the plugin sync map, manifest keys for settings /
|
|
21
|
+
* rate limits / JSON Logic / cache categories / action-plannable jobs, and the
|
|
22
|
+
* web SDK `resources` / `settings` / `sectionAnchor` surface (task
|
|
23
|
+
* `2026-11-25-plugin-resource-hooks`). It also covers the optional mobile host
|
|
24
|
+
* services `upload`, `requestPermission` / `openAppSettings` and
|
|
25
|
+
* `getPluginStorage`, and the `parseInlineRich` / `stripHtmlToText` /
|
|
26
|
+
* `IInlineNode` exports (the mobile renderer axis is `0.4.0`).
|
|
16
27
|
*/
|
|
17
|
-
declare const PLUGIN_API_VERSION: "0.
|
|
28
|
+
declare const PLUGIN_API_VERSION: "0.2.0";
|
|
18
29
|
/**
|
|
19
30
|
* Mobile renderer contract version. This is the SECOND, mobile-only
|
|
20
31
|
* compatibility axis (independent of `PLUGIN_API_VERSION`): it versions the
|
|
@@ -41,8 +52,17 @@ declare const PLUGIN_API_VERSION: "0.1.0";
|
|
|
41
52
|
* through the host router (correct in the native app AND the CMS web preview
|
|
42
53
|
* iframe) instead of touching `window.location` — an additive renderer feature.
|
|
43
54
|
* It is optional, so older plugins/hosts stay compatible.
|
|
55
|
+
*
|
|
56
|
+
* `0.4.0` adds three optional host services and one text-helper export (task
|
|
57
|
+
* `2026-11-25-plugin-resource-hooks`, C27 to C30): `upload` (multipart through
|
|
58
|
+
* the host with the host's token), `requestPermission` / `openAppSettings`
|
|
59
|
+
* (microphone and camera, asked by the app), `getPluginStorage` (a small device
|
|
60
|
+
* key-value store per server, user and plugin), and `parseInlineRich` /
|
|
61
|
+
* `stripHtmlToText` / `IInlineNode` exported from `plugin-sdk`. All members are
|
|
62
|
+
* optional, so a plugin feature-detects them; plugins declare `>=` ranges in
|
|
63
|
+
* `compatibility.mobile`.
|
|
44
64
|
*/
|
|
45
|
-
declare const MOBILE_RENDERER_VERSION: "0.
|
|
65
|
+
declare const MOBILE_RENDERER_VERSION: "0.4.0";
|
|
46
66
|
interface ISemver {
|
|
47
67
|
major: number;
|
|
48
68
|
minor: number;
|
|
@@ -389,6 +409,42 @@ interface IPluginLock {
|
|
|
389
409
|
* component type at registration time.
|
|
390
410
|
*/
|
|
391
411
|
type TPluginComponent<TProps = unknown> = (props: TProps) => unknown;
|
|
412
|
+
/**
|
|
413
|
+
* Where a plugin item is used (C7). Pages the caller may not read are counted
|
|
414
|
+
* only in `hidden_count`.
|
|
415
|
+
*/
|
|
416
|
+
interface IResourceUsage {
|
|
417
|
+
pages: Array<{
|
|
418
|
+
id: number;
|
|
419
|
+
keyword: string;
|
|
420
|
+
title: string | null;
|
|
421
|
+
draft_uses: boolean;
|
|
422
|
+
published_uses: boolean;
|
|
423
|
+
}>;
|
|
424
|
+
actions: Array<{
|
|
425
|
+
id: number;
|
|
426
|
+
name: string;
|
|
427
|
+
}>;
|
|
428
|
+
hidden_count: number;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* One item of `GET /admin/plugins/{pluginId}/settings` (C14). Secrets never
|
|
432
|
+
* carry a clear `value`; `hint` is the last 4 characters when the secret is
|
|
433
|
+
* long enough, otherwise null.
|
|
434
|
+
*/
|
|
435
|
+
interface IPluginSettingViewItem {
|
|
436
|
+
key: string;
|
|
437
|
+
label: string;
|
|
438
|
+
type: 'string' | 'number' | 'boolean' | 'url';
|
|
439
|
+
secret: boolean;
|
|
440
|
+
required: boolean;
|
|
441
|
+
has_value: boolean;
|
|
442
|
+
value: string | number | boolean | null;
|
|
443
|
+
hint: string | null;
|
|
444
|
+
overridden_by_env: boolean;
|
|
445
|
+
}
|
|
446
|
+
/** The C14 GET settings list for one plugin. */
|
|
447
|
+
type IPluginSettingsView = IPluginSettingViewItem[];
|
|
392
448
|
/**
|
|
393
449
|
* Definition of a CMS style contributed by a plugin.
|
|
394
450
|
*/
|
|
@@ -404,6 +460,49 @@ interface IStyleDefinition extends Omit<IStyleRegistryEntry, 'category'> {
|
|
|
404
460
|
/** Style implementation component (React or React Native). */
|
|
405
461
|
component: TPluginComponent;
|
|
406
462
|
}
|
|
463
|
+
/**
|
|
464
|
+
* The popup a page is shown in, as the host sees it. Outside a popup
|
|
465
|
+
* `inModal` is false and `closeModal()` does nothing, so a plugin can call
|
|
466
|
+
* it unconditionally (for example after a save, like the core form's
|
|
467
|
+
* `close_modal_on_save`).
|
|
468
|
+
*/
|
|
469
|
+
interface IPluginPageModal {
|
|
470
|
+
inModal: boolean;
|
|
471
|
+
closeModal: () => void;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* The page a plugin section is drawn on. A plugin endpoint that serves or
|
|
475
|
+
* accepts data for the section names the page and the section in every call
|
|
476
|
+
* (with this language, preview state and route), so the server can check
|
|
477
|
+
* access and read the section's settings itself (rule 7.7), like the core
|
|
478
|
+
* form and form list do.
|
|
479
|
+
*/
|
|
480
|
+
interface IPluginStylePage {
|
|
481
|
+
/** Page id; null while the page content is not known yet. */
|
|
482
|
+
id: number | null;
|
|
483
|
+
languageId: number | null;
|
|
484
|
+
/** Whether the page is shown as the editor's draft (preview mode). */
|
|
485
|
+
preview: boolean;
|
|
486
|
+
/** The page's declared route parameters (`page.route_params`). */
|
|
487
|
+
routeParams: Record<string, string>;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Props the host passes to a plugin style component (the `component` of an
|
|
491
|
+
* {@link IStyleDefinition}). `style` is the section as the page payload
|
|
492
|
+
* carries it (fields keyed by name).
|
|
493
|
+
*/
|
|
494
|
+
interface IPluginStyleProps {
|
|
495
|
+
style: Record<string, unknown>;
|
|
496
|
+
styleProps: Record<string, string>;
|
|
497
|
+
cssClass: string;
|
|
498
|
+
parentActive?: number;
|
|
499
|
+
childIndex?: number;
|
|
500
|
+
parentColor?: string;
|
|
501
|
+
/** The popup the page is shown in; a no-op outside one. */
|
|
502
|
+
pageModal: IPluginPageModal;
|
|
503
|
+
/** The page the section is on, to name in plugin calls. */
|
|
504
|
+
page: IPluginStylePage;
|
|
505
|
+
}
|
|
407
506
|
/**
|
|
408
507
|
* Props passed by the host's section-field editor to a plugin-supplied
|
|
409
508
|
* field renderer. The host owns the surrounding label / help tooltip /
|
|
@@ -605,6 +704,40 @@ interface IPluginApi {
|
|
|
605
704
|
realtime?: IPluginRealtimePublisher;
|
|
606
705
|
/** Host rich-text editor adapter. */
|
|
607
706
|
richTextEditor: IRichTextEditorAdapter;
|
|
707
|
+
/**
|
|
708
|
+
* The host's HTML sanitizer, with the same rules core pages use (web:
|
|
709
|
+
* DOMPurify, plus the host's link rewrites). Call it before rendering any
|
|
710
|
+
* CMS or user HTML; never bundle a sanitizer of your own. `inline` keeps
|
|
711
|
+
* inline markup only, `block` also keeps headings, lists and paragraphs.
|
|
712
|
+
*/
|
|
713
|
+
sanitizeHtml(html: string, mode: 'inline' | 'block'): string;
|
|
714
|
+
/**
|
|
715
|
+
* CSS selector for a rendered section element (C23). Returns
|
|
716
|
+
* `.section-<id>`. Web only.
|
|
717
|
+
*/
|
|
718
|
+
sectionAnchor(sectionId: number): string;
|
|
719
|
+
/** Where-used for a plugin item the caller may view (C7, C11). */
|
|
720
|
+
resources: {
|
|
721
|
+
usage(type: string, id: number): Promise<IResourceUsage>;
|
|
722
|
+
};
|
|
723
|
+
/**
|
|
724
|
+
* Optional host UI parts. `ResourceUsageList` is offered when the host
|
|
725
|
+
* ships a shared where-used list for delete warnings.
|
|
726
|
+
*/
|
|
727
|
+
ui?: {
|
|
728
|
+
ResourceUsageList: TPluginComponent<{
|
|
729
|
+
type: string;
|
|
730
|
+
id: number;
|
|
731
|
+
warnBeforeDelete?: boolean;
|
|
732
|
+
}>;
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
735
|
+
* This plugin's settings as the host stores them (C14). Secrets show
|
|
736
|
+
* `has_value` only; clear values are never returned for secrets.
|
|
737
|
+
*/
|
|
738
|
+
settings: {
|
|
739
|
+
get(): Promise<IPluginSettingsView>;
|
|
740
|
+
};
|
|
608
741
|
/**
|
|
609
742
|
* Logger that respects the host's debug config. Avoid `console.log`
|
|
610
743
|
* in plugin code; route everything through this.
|
|
@@ -618,9 +751,18 @@ interface IPluginApi {
|
|
|
618
751
|
}
|
|
619
752
|
/**
|
|
620
753
|
* Same shape on mobile, minus the rich-text editor adapter when the
|
|
621
|
-
* plugin only supports read-only mobile rendering.
|
|
754
|
+
* plugin only supports read-only mobile rendering. Web-only C11 / C23 members
|
|
755
|
+
* are omitted. React Native does not render HTML, so there is no
|
|
756
|
+
* `sanitizeHtml` on mobile. HTML rule for mobile plugins:
|
|
757
|
+
* - Native React Native text: `parseInlineRich` (inline formatting and
|
|
758
|
+
* links) and `stripHtmlToText` (plain text), both exported from
|
|
759
|
+
* `@selfhelp/shared/plugin-sdk`.
|
|
760
|
+
* - HTML inside the plugin's own WebView: the plugin bundles a sanitizer into
|
|
761
|
+
* the WebView runtime and keeps a strict CSP. The host offers no sanitizer
|
|
762
|
+
* on mobile.
|
|
763
|
+
* - Web part: `api.sanitizeHtml`; never bundle a sanitizer there.
|
|
622
764
|
*/
|
|
623
|
-
interface IMobilePluginApi extends Omit<IPluginApi, 'richTextEditor'> {
|
|
765
|
+
interface IMobilePluginApi extends Omit<IPluginApi, 'richTextEditor' | 'sanitizeHtml' | 'sectionAnchor' | 'resources' | 'ui' | 'settings'> {
|
|
624
766
|
/** Mobile builds without rich-text support set this to `null`. */
|
|
625
767
|
richTextEditor: IRichTextEditorAdapter | null;
|
|
626
768
|
}
|
|
@@ -654,6 +796,11 @@ interface IPluginRegistration {
|
|
|
654
796
|
* `field_types`) without the host having to hardcode the renderer.
|
|
655
797
|
*/
|
|
656
798
|
fieldRenderers?: IFieldRendererDefinition[];
|
|
799
|
+
/**
|
|
800
|
+
* Declarative sync map (C10). The host invalidates each matching
|
|
801
|
+
* `queryKey` as a prefix when a change notice carries a listed tag.
|
|
802
|
+
*/
|
|
803
|
+
sync?: IPluginSyncEntry[];
|
|
657
804
|
}
|
|
658
805
|
/**
|
|
659
806
|
* Returned by `defineMobilePlugin()` for the mobile side of a plugin.
|
|
@@ -668,6 +815,11 @@ interface IMobilePluginRegistration {
|
|
|
668
815
|
realtimeTopics?: IPluginRealtimeTopic[];
|
|
669
816
|
/** Mobile feature flags (mirror of the manifest flags). */
|
|
670
817
|
featureFlags?: IPluginFeatureFlag[];
|
|
818
|
+
/**
|
|
819
|
+
* Declarative sync map (C10). Same shape as the web registration; the
|
|
820
|
+
* mobile host invalidates matching query keys from `applySyncTags`.
|
|
821
|
+
*/
|
|
822
|
+
sync?: IPluginSyncEntry[];
|
|
671
823
|
}
|
|
672
824
|
|
|
673
825
|
/**
|
|
@@ -773,6 +925,67 @@ interface IMobileHostResponse<TData = unknown> {
|
|
|
773
925
|
*/
|
|
774
926
|
sessionExpired?: boolean;
|
|
775
927
|
}
|
|
928
|
+
/**
|
|
929
|
+
* One file part of a multipart upload the plugin asks the host to send
|
|
930
|
+
* (renderer 0.4.0, C27). Give exactly one of {@link uri} or {@link base64}.
|
|
931
|
+
*/
|
|
932
|
+
interface IMobileHostUploadFile {
|
|
933
|
+
/** Multipart part name (the field name the plugin's route reads). */
|
|
934
|
+
field: string;
|
|
935
|
+
/** File name sent to the server. */
|
|
936
|
+
name: string;
|
|
937
|
+
/** MIME type, e.g. `audio/m4a`. */
|
|
938
|
+
type: string;
|
|
939
|
+
/**
|
|
940
|
+
* `file://` or `content://` (native), `blob:` or `data:` (web preview).
|
|
941
|
+
* Exclusive with {@link base64}.
|
|
942
|
+
*/
|
|
943
|
+
uri?: string;
|
|
944
|
+
/** Raw base64 without a `data:` prefix. Exclusive with {@link uri}. */
|
|
945
|
+
base64?: string;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* A protected multipart upload (renderer 0.4.0, C27). Same path rules as
|
|
949
|
+
* {@link IMobileHostRequest}: relative to the host API base, absolute URLs are
|
|
950
|
+
* refused.
|
|
951
|
+
*/
|
|
952
|
+
interface IMobileHostUploadRequest {
|
|
953
|
+
/** Path relative to the host API base, like {@link IMobileHostRequest.path}. */
|
|
954
|
+
path: string;
|
|
955
|
+
/** HTTP method. Defaults to `POST`. */
|
|
956
|
+
method?: 'POST' | 'PUT';
|
|
957
|
+
/** Text parts of the multipart body. */
|
|
958
|
+
fields?: Record<string, string>;
|
|
959
|
+
/** File parts. At least one is required. */
|
|
960
|
+
files: IMobileHostUploadFile[];
|
|
961
|
+
/** Extra request headers. */
|
|
962
|
+
headers?: Record<string, string>;
|
|
963
|
+
/** Query parameters appended to the path. */
|
|
964
|
+
query?: Record<string, string | number | boolean>;
|
|
965
|
+
}
|
|
966
|
+
/** What a plugin may ask the host to request from the system (C28). */
|
|
967
|
+
type TMobileHostPermission = 'microphone' | 'camera';
|
|
968
|
+
/**
|
|
969
|
+
* Answer to {@link IMobileHostServices.requestPermission}: `granted`, `denied`
|
|
970
|
+
* (the user said no and the app may ask again) or `blocked` (the system will
|
|
971
|
+
* not show the prompt again; send the user to {@link IMobileHostServices.openAppSettings}).
|
|
972
|
+
*/
|
|
973
|
+
type TMobileHostPermissionState = 'granted' | 'denied' | 'blocked';
|
|
974
|
+
/**
|
|
975
|
+
* Small device key-value store for one plugin, one user and one server (C29).
|
|
976
|
+
* Meant for drafts and view state. It is not encrypted: never keep secrets or
|
|
977
|
+
* tokens in it. The server still decides everything on submit.
|
|
978
|
+
*/
|
|
979
|
+
interface IMobilePluginStorage {
|
|
980
|
+
/** The stored value, or `null` when the key is not set. */
|
|
981
|
+
getItem(key: string): Promise<string | null>;
|
|
982
|
+
/** Stores a value; rejects with `Error('plugin_storage_full')` over the size cap and changes nothing. */
|
|
983
|
+
setItem(key: string, value: string): Promise<void>;
|
|
984
|
+
/** Removes one key. */
|
|
985
|
+
removeItem(key: string): Promise<void>;
|
|
986
|
+
/** Removes everything of this plugin, this user and this server only. */
|
|
987
|
+
clear(): Promise<void>;
|
|
988
|
+
}
|
|
776
989
|
/**
|
|
777
990
|
* Authenticated host services exposed to a plugin's mobile package. The
|
|
778
991
|
* host owns the token + refresh; the plugin only describes the request.
|
|
@@ -810,6 +1023,46 @@ interface IMobileHostServices {
|
|
|
810
1023
|
* gracefully rather than assume it exists.
|
|
811
1024
|
*/
|
|
812
1025
|
navigate?(target: string, external?: boolean): void;
|
|
1026
|
+
/**
|
|
1027
|
+
* Send a `multipart/form-data` request through the host (renderer 0.4.0).
|
|
1028
|
+
* The host attaches the token and client headers, makes one 401 refresh
|
|
1029
|
+
* retry and answers in the {@link IMobileHostResponse} shape, like
|
|
1030
|
+
* {@link request}. An absolute path is refused. Nothing is sent, and the
|
|
1031
|
+
* answer is `{ ok: false, status: 0, reason }`, when `reason` is
|
|
1032
|
+
* `invalid_upload` (no file, or a file with both or neither of `uri` and
|
|
1033
|
+
* `base64`) or `file_too_large` (one total size limit per request). The
|
|
1034
|
+
* host removes any temporary file it wrote for a `base64` input.
|
|
1035
|
+
*
|
|
1036
|
+
* Optional: an older host omits it, so a plugin MUST feature-detect
|
|
1037
|
+
* (`if (host.upload)`) and degrade gracefully.
|
|
1038
|
+
*/
|
|
1039
|
+
upload?<TData = unknown>(req: IMobileHostUploadRequest): Promise<IMobileHostResponse<TData>>;
|
|
1040
|
+
/**
|
|
1041
|
+
* Ask the system for microphone or camera access (renderer 0.4.0). Only the
|
|
1042
|
+
* app asks; a plugin in a WebView cannot. Resolves to `granted`, `denied`
|
|
1043
|
+
* or `blocked` ({@link TMobileHostPermissionState}); on `blocked` the plugin
|
|
1044
|
+
* should explain why it needs the permission and offer
|
|
1045
|
+
* {@link openAppSettings}.
|
|
1046
|
+
*
|
|
1047
|
+
* Optional: feature-detect (`if (host.requestPermission)`).
|
|
1048
|
+
*/
|
|
1049
|
+
requestPermission?(kind: TMobileHostPermission): Promise<TMobileHostPermissionState>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Open the app's system settings page so the user can change a `blocked`
|
|
1052
|
+
* permission (renderer 0.4.0). Does nothing in the web preview.
|
|
1053
|
+
*
|
|
1054
|
+
* Optional: feature-detect (`if (host.openAppSettings)`).
|
|
1055
|
+
*/
|
|
1056
|
+
openAppSettings?(): void;
|
|
1057
|
+
/**
|
|
1058
|
+
* Device storage for the given plugin id, scoped to the current server and
|
|
1059
|
+
* user (guest = 0), emptied on logout, server switch and a rejected token
|
|
1060
|
+
* refresh (renderer 0.4.0, C29). Throws when `pluginId` does not match the
|
|
1061
|
+
* manifest id pattern. Not for secrets.
|
|
1062
|
+
*
|
|
1063
|
+
* Optional: feature-detect (`if (host.getPluginStorage)`).
|
|
1064
|
+
*/
|
|
1065
|
+
getPluginStorage?(pluginId: string): IMobilePluginStorage;
|
|
813
1066
|
}
|
|
814
1067
|
/**
|
|
815
1068
|
* Register the host services implementation. Called once by the native
|
|
@@ -1006,4 +1259,4 @@ declare function isPluginRuntimeShimSpecifier(value: unknown): value is TPluginR
|
|
|
1006
1259
|
*/
|
|
1007
1260
|
declare const PLUGIN_RUNTIME_IMPORT_MAP: Readonly<Record<TPluginRuntimeShimSpecifier, string>>;
|
|
1008
1261
|
|
|
1009
|
-
export { type IAdminPageDefinition, type IFieldRendererDefinition, type IMenuItemDefinition, type IMobileHostRequest, type IMobileHostResponse, type IMobileHostServices, type IMobilePluginApi, type IMobilePluginRegistration, type IPluginApi, type IPluginFeatureFlag, type IPluginFieldRendererProps, type IPluginHealthCheck, type IPluginLock, type IPluginLockEntry, type IPluginLockMigration, type IPluginLockMobileEntry, type IPluginRealtimePublisher, type IPluginRealtimeTopic, type IPluginRegistration, type IPluginRegistry, type IPluginRelease, type IRealtimeTransport, type IRegistryReleaseRef, type IRegistrySignatureBlock, type IRichTextEditorAdapter, type IRichTextEditorAdapterOptions, type IRichTextEditorValue, type IStyleDefinition, type IUsePluginRealtimeOptions, type IUsePluginRealtimeResult, MOBILE_RENDERER_VERSION, PLUGIN_API_VERSION, PLUGIN_REGISTRY_CHANNELS, PLUGIN_RUNTIME_GLOBAL_KEY, PLUGIN_RUNTIME_IMPORT_MAP, PLUGIN_RUNTIME_SHIM_BASE_PATH, PLUGIN_RUNTIME_SHIM_SPECIFIERS, type TMobileHostMethod, type TPluginRegistryChannel, type TPluginRuntimeShimSpecifier, type TRealtimeTransportFactory, assertCmsCompatibility, assertPluginApiVersion, assertPluginVersionSemantics, buildPluginRuntimeShimPath, compareSemver, defineMobilePlugin, definePlugin, definePluginRealtimeTopic, getMobileHostServices, isMobileRendererCompatible, isPluginApiCompatible, isPluginRuntimeShimSpecifier, parseSemver, satisfiesSemverRange, setMobileHostServices, usePluginRealtime };
|
|
1262
|
+
export { type IAdminPageDefinition, type IFieldRendererDefinition, type IMenuItemDefinition, type IMobileHostRequest, type IMobileHostResponse, type IMobileHostServices, type IMobileHostUploadFile, type IMobileHostUploadRequest, type IMobilePluginApi, type IMobilePluginRegistration, type IMobilePluginStorage, type IPluginApi, type IPluginFeatureFlag, type IPluginFieldRendererProps, type IPluginHealthCheck, type IPluginLock, type IPluginLockEntry, type IPluginLockMigration, type IPluginLockMobileEntry, type IPluginPageModal, type IPluginRealtimePublisher, type IPluginRealtimeTopic, type IPluginRegistration, type IPluginRegistry, type IPluginRelease, type IPluginSettingViewItem, type IPluginSettingsView, type IPluginStylePage, type IPluginStyleProps, IPluginSyncEntry, type IRealtimeTransport, type IRegistryReleaseRef, type IRegistrySignatureBlock, type IResourceUsage, type IRichTextEditorAdapter, type IRichTextEditorAdapterOptions, type IRichTextEditorValue, type IStyleDefinition, type IUsePluginRealtimeOptions, type IUsePluginRealtimeResult, MOBILE_RENDERER_VERSION, PLUGIN_API_VERSION, PLUGIN_REGISTRY_CHANNELS, PLUGIN_RUNTIME_GLOBAL_KEY, PLUGIN_RUNTIME_IMPORT_MAP, PLUGIN_RUNTIME_SHIM_BASE_PATH, PLUGIN_RUNTIME_SHIM_SPECIFIERS, type TMobileHostMethod, type TMobileHostPermission, type TMobileHostPermissionState, type TPluginRegistryChannel, type TPluginRuntimeShimSpecifier, type TRealtimeTransportFactory, assertCmsCompatibility, assertPluginApiVersion, assertPluginVersionSemantics, buildPluginRuntimeShimPath, compareSemver, defineMobilePlugin, definePlugin, definePluginRealtimeTopic, getMobileHostServices, isMobileRendererCompatible, isPluginApiCompatible, isPluginRuntimeShimSpecifier, parseSemver, satisfiesSemverRange, setMobileHostServices, usePluginRealtime };
|