@selfhelp/shared 1.0.4 → 1.1.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 CHANGED
@@ -4,6 +4,106 @@ All notable changes to `@selfhelp/shared` will be documented in this file.
4
4
 
5
5
  This project follows semantic versioning.
6
6
 
7
+ ## [1.1.0] - 2026-05-25
8
+
9
+ ### Added
10
+
11
+ - Plugin SDK field-renderer contracts:
12
+ `IFieldRendererDefinition`, `IPluginFieldRendererProps`, and
13
+ `fieldRenderers` on `IPluginRegistration`, so plugins can contribute
14
+ custom CMS section-field editor controls for plugin-owned field types.
15
+
16
+ ### Changed
17
+
18
+ - Bumped `PLUGIN_API_VERSION` from `1.0` to `1.1` to reflect the new
19
+ additive plugin SDK surface.
20
+ - Re-exported the new field-renderer types from `@selfhelp/shared/plugin-sdk`.
21
+
22
+ ## [1.0.4] - 2026-05-22
23
+
24
+ ### Added
25
+
26
+ - New `plugin-sdk` surface for the SelfHelp plugin ecosystem:
27
+ - `definePlugin()` / `defineMobilePlugin()` helpers for typed plugin
28
+ manifests.
29
+ - `definePluginRealtimeTopic()` topic helpers with template expansion.
30
+ - `usePluginRealtime()` React hook for Mercure topic subscription. The
31
+ hook accepts a `transportFactory` so frontend hosts can inject
32
+ `EventSource` and mobile hosts can inject `react-native-sse` without
33
+ forcing the SDK to depend on either runtime.
34
+ - TypeScript mirrors for `IPluginManifest`, `IPluginRegistry`, and
35
+ `IPluginLock` plus the `scripts/check-schema-parity.mjs` script that
36
+ verifies the JSON schemas stay in lockstep with the TS types.
37
+ - React is now declared as an **optional peer dependency**
38
+ (`react ^18 || ^19`). Non-React consumers can keep using the package
39
+ without installing React; the `usePluginRealtime` hook is only required
40
+ if you opt into realtime updates.
41
+
42
+ ### Changed (breaking type contracts)
43
+
44
+ These changes broaden the schema-mirroring types so they actually match
45
+ the canonical JSON Schemas the backend publishes. Plugin authors
46
+ upgrading from `1.0.3` need to update any code that constructed these
47
+ shapes literally:
48
+
49
+ - `IPluginRegistry`
50
+ - Renamed `schemaVersion` (string `'1.0'`) to **`registryVersion`**
51
+ (`number`, currently `1`).
52
+ - Added required field `name: string`.
53
+ - Added optional `homepage`, `publishedAt`, `trustKey`, and `channels`
54
+ fields to align with `plugin-registry.schema.json`.
55
+ - `IPluginLock`
56
+ - Added required field **`lockfileVersion: number`** (currently `1`).
57
+ - Added required nested object **`sdk: { version: string; pluginApiVersion: string }`**
58
+ so lockfiles always advertise which SDK version they were generated
59
+ against.
60
+ - `plugins` is now `Record<string, IPluginLockEntry>` instead of an
61
+ array — keyed by plugin id, which matches the schema and removes
62
+ the need for clients to do an extra lookup.
63
+ - `installMode` is now optional at the top level (per-entry
64
+ `installMode` already exists inside each plugin entry).
65
+ - `IPluginManifest`
66
+ - `dataAccess` gained `ownedTables: string[]` and
67
+ `ownedDataTablePrefix?: string` so plugins can declare their owned
68
+ tables for the install-time validator and the purger.
69
+
70
+ ### Migration notes for plugin authors
71
+
72
+ ```ts
73
+ // before (1.0.3)
74
+ const registry: IPluginRegistry = {
75
+ schemaVersion: '1.0',
76
+ plugins: [],
77
+ };
78
+
79
+ // after (1.0.4)
80
+ const registry: IPluginRegistry = {
81
+ registryVersion: 1,
82
+ name: 'my-registry',
83
+ plugins: [],
84
+ };
85
+ ```
86
+
87
+ ```ts
88
+ // before (1.0.3)
89
+ const lock: IPluginLock = {
90
+ generatedAt: '...',
91
+ plugins: [],
92
+ installMode: 'managed',
93
+ };
94
+
95
+ // after (1.0.4)
96
+ const lock: IPluginLock = {
97
+ lockfileVersion: 1,
98
+ generatedAt: '...',
99
+ sdk: { version: '1.0.4', pluginApiVersion: '1.0' },
100
+ plugins: {},
101
+ };
102
+ ```
103
+
104
+ Run `npm run check:schemas` (from `sh-selfhelp_shared`) to verify your
105
+ TypeScript matches the canonical JSON schemas after the upgrade.
106
+
7
107
  ## [1.0.3] - 2026-05-19
8
108
 
9
109
  - Adjust types after the DB refactoring
@@ -13,7 +13,7 @@ import '../common-B96dASgu.mjs';
13
13
  *
14
14
  * Independent from the npm `version` of `@selfhelp/shared`.
15
15
  */
16
- declare const PLUGIN_API_VERSION: "1.0";
16
+ declare const PLUGIN_API_VERSION: "1.1";
17
17
  interface ISemver {
18
18
  major: number;
19
19
  minor: number;
@@ -70,7 +70,7 @@ declare function assertPluginVersionSemantics(prevVersion: string | undefined, n
70
70
  */
71
71
  type IPluginManifestTrustLevel = 'official' | 'reviewed' | 'untrusted';
72
72
  /** Every privileged capability is deny-by-default. */
73
- type IPluginManifestCapability = 'backendBundle' | 'databaseMigrations' | 'readUsers' | 'writeUsers' | 'deleteUsers' | 'readDataTables' | 'writeDataTables' | 'deleteDataTables' | 'externalNetworkAccess' | 'scheduledJobs' | 'publicCallbacks' | 'adminPages' | 'frontendStyles' | 'mobileStyles' | 'realtimePublish' | 'fileUploads' | 'secretAccess';
73
+ type IPluginManifestCapability = 'backendBundle' | 'databaseMigrations' | 'readUsers' | 'writeUsers' | 'deleteUsers' | 'readDataTables' | 'writeDataTables' | 'deleteDataTables' | 'externalNetworkAccess' | 'scheduledJobs' | 'publicCallbacks' | 'adminPages' | 'frontendStyles' | 'mobileStyles' | 'realtimePublish' | 'fileUploads' | 'secretAccess' | 'lookupExtend' | 'lookupOwnGroup';
74
74
  interface IPluginManifestCompatibility {
75
75
  /** SemVer range for the SelfHelp CMS version (e.g. `^2.0`). */
76
76
  selfhelp: string;
@@ -385,10 +385,9 @@ interface IPluginRegistryEntry {
385
385
  /**
386
386
  * Registry root document.
387
387
  *
388
- * Mirrors `plugin-registry.schema.json`. The schema document calls the
389
- * version field `registryVersion` (integer, bumped only on breaking
390
- * registry-document changes); we keep the legacy `schemaVersion` field
391
- * as a compatibility alias so existing consumers do not break.
388
+ * Mirrors `plugin-registry.schema.json`. The version field is named
389
+ * `registryVersion` (integer, bumped only on breaking registry-document
390
+ * changes).
392
391
  */
393
392
  interface IPluginRegistry {
394
393
  /** Registry schema generation. Bumped only on breaking registry-document changes. */
@@ -565,6 +564,47 @@ interface IStyleDefinition extends Omit<IStyleRegistryEntry, 'category'> {
565
564
  /** Style implementation component (React or React Native). */
566
565
  component: TPluginComponent;
567
566
  }
567
+ /**
568
+ * Props passed by the host's section-field editor to a plugin-supplied
569
+ * field renderer. The host owns the surrounding label / help tooltip /
570
+ * type badge; the plugin only owns the actual input control.
571
+ *
572
+ * `field` is intentionally typed as a loose record because the host's
573
+ * `IFieldData` lives in the frontend repo and must not leak into the
574
+ * shared SDK contract — plugins read only what they need (id, name,
575
+ * config, default_value, etc.).
576
+ */
577
+ interface IPluginFieldRendererProps {
578
+ /** Field id (database row id). */
579
+ fieldId: number;
580
+ /** Field name (DB `fields.name`). */
581
+ fieldName: string;
582
+ /** Field type (`fields.type`, e.g. `select-survey-js`). */
583
+ fieldType: string;
584
+ /** Current string value bound to the section_field translation. */
585
+ value: string;
586
+ /** Persist a new string value on the section_field translation. */
587
+ onChange: (value: string) => void;
588
+ /** Whether the input is disabled by the host. */
589
+ disabled?: boolean;
590
+ /** Loose pass-through of the host field row (config, default, help, ...). */
591
+ field?: Record<string, unknown>;
592
+ }
593
+ /**
594
+ * Field renderer contributed by a plugin. Replaces the host default
595
+ * editor control for the given `fieldType`. Used by the CMS
596
+ * section-field editor in the frontend repo so plugins can ship custom
597
+ * pickers (e.g. SurveyJS survey select) without the host having to
598
+ * hardcode plugin-specific UI in `FieldRenderer.tsx`.
599
+ *
600
+ * The component receives {@link IPluginFieldRendererProps}.
601
+ */
602
+ interface IFieldRendererDefinition {
603
+ /** Field type discriminator (`fields.type`, e.g. `select-survey-js`). */
604
+ fieldType: string;
605
+ /** React component that renders the input control. */
606
+ component: TPluginComponent<IPluginFieldRendererProps>;
607
+ }
568
608
  /**
569
609
  * Admin page contributed by a plugin. Mounted under
570
610
  * `/admin/plugins-host/{pluginId}/{slug}` in the frontend.
@@ -767,6 +807,13 @@ interface IPluginRegistration {
767
807
  featureFlags?: IPluginFeatureFlag[];
768
808
  /** Realtime topics the plugin publishes / subscribes to. */
769
809
  realtimeTopics?: IPluginRealtimeTopic[];
810
+ /**
811
+ * CMS section-field editor renderers contributed by the plugin.
812
+ * Allows plugins to ship custom pickers for plugin-owned field types
813
+ * (declared in the plugin's Doctrine migration as new rows in
814
+ * `field_types`) without the host having to hardcode the renderer.
815
+ */
816
+ fieldRenderers?: IFieldRendererDefinition[];
770
817
  }
771
818
  /**
772
819
  * Returned by `defineMobilePlugin()` for the mobile side of a plugin.
@@ -903,4 +950,4 @@ interface IUsePluginRealtimeResult<TPayload = unknown> {
903
950
  */
904
951
  declare function usePluginRealtime<TPayload = unknown>(options: IUsePluginRealtimeOptions<TPayload>): IUsePluginRealtimeResult<TPayload>;
905
952
 
906
- export { type IAdminPageDefinition, type IMenuItemDefinition, type IMobilePluginApi, type IMobilePluginRegistration, type IPluginApi, type IPluginFeatureFlag, type IPluginHealthCheck, type IPluginLock, type IPluginLockEntry, type IPluginLockMigration, type IPluginLockMobileEntry, type IPluginManifest, type IPluginManifestAdminPage, type IPluginManifestApiRoute, type IPluginManifestAsset, type IPluginManifestCapability, type IPluginManifestCompatibility, type IPluginManifestConflict, type IPluginManifestDataAccess, type IPluginManifestDependency, type IPluginManifestExternalHost, type IPluginManifestFeatureFlag, type IPluginManifestHealth, type IPluginManifestLookupExtension, type IPluginManifestMobile, type IPluginManifestPermission, type IPluginManifestRealtimeTopic, type IPluginManifestScheduledJob, type IPluginManifestSecurity, type IPluginManifestStyle, type IPluginManifestTrustLevel, type IPluginRealtimePublisher, type IPluginRealtimeTopic, type IPluginRegistration, type IPluginRegistry, type IPluginRegistryEntry, type IPluginRegistryVersionEntry, type IRealtimeTransport, type IRichTextEditorAdapter, type IRichTextEditorAdapterOptions, type IRichTextEditorValue, type IStyleDefinition, type IUsePluginRealtimeOptions, type IUsePluginRealtimeResult, PLUGIN_API_VERSION, type TPluginRegistryChannel, type TRealtimeTransportFactory, assertCmsCompatibility, assertPluginApiVersion, assertPluginVersionSemantics, compareSemver, defineMobilePlugin, definePlugin, definePluginRealtimeTopic, isPluginApiCompatible, parseSemver, satisfiesSemverRange, usePluginRealtime };
953
+ export { type IAdminPageDefinition, type IFieldRendererDefinition, type IMenuItemDefinition, type IMobilePluginApi, type IMobilePluginRegistration, type IPluginApi, type IPluginFeatureFlag, type IPluginFieldRendererProps, type IPluginHealthCheck, type IPluginLock, type IPluginLockEntry, type IPluginLockMigration, type IPluginLockMobileEntry, type IPluginManifest, type IPluginManifestAdminPage, type IPluginManifestApiRoute, type IPluginManifestAsset, type IPluginManifestCapability, type IPluginManifestCompatibility, type IPluginManifestConflict, type IPluginManifestDataAccess, type IPluginManifestDependency, type IPluginManifestExternalHost, type IPluginManifestFeatureFlag, type IPluginManifestHealth, type IPluginManifestLookupExtension, type IPluginManifestMobile, type IPluginManifestPermission, type IPluginManifestRealtimeTopic, type IPluginManifestScheduledJob, type IPluginManifestSecurity, type IPluginManifestStyle, type IPluginManifestTrustLevel, type IPluginRealtimePublisher, type IPluginRealtimeTopic, type IPluginRegistration, type IPluginRegistry, type IPluginRegistryEntry, type IPluginRegistryVersionEntry, type IRealtimeTransport, type IRichTextEditorAdapter, type IRichTextEditorAdapterOptions, type IRichTextEditorValue, type IStyleDefinition, type IUsePluginRealtimeOptions, type IUsePluginRealtimeResult, PLUGIN_API_VERSION, type TPluginRegistryChannel, type TRealtimeTransportFactory, assertCmsCompatibility, assertPluginApiVersion, assertPluginVersionSemantics, compareSemver, defineMobilePlugin, definePlugin, definePluginRealtimeTopic, isPluginApiCompatible, parseSemver, satisfiesSemverRange, usePluginRealtime };
@@ -13,7 +13,7 @@ import '../common-B96dASgu.js';
13
13
  *
14
14
  * Independent from the npm `version` of `@selfhelp/shared`.
15
15
  */
16
- declare const PLUGIN_API_VERSION: "1.0";
16
+ declare const PLUGIN_API_VERSION: "1.1";
17
17
  interface ISemver {
18
18
  major: number;
19
19
  minor: number;
@@ -70,7 +70,7 @@ declare function assertPluginVersionSemantics(prevVersion: string | undefined, n
70
70
  */
71
71
  type IPluginManifestTrustLevel = 'official' | 'reviewed' | 'untrusted';
72
72
  /** Every privileged capability is deny-by-default. */
73
- type IPluginManifestCapability = 'backendBundle' | 'databaseMigrations' | 'readUsers' | 'writeUsers' | 'deleteUsers' | 'readDataTables' | 'writeDataTables' | 'deleteDataTables' | 'externalNetworkAccess' | 'scheduledJobs' | 'publicCallbacks' | 'adminPages' | 'frontendStyles' | 'mobileStyles' | 'realtimePublish' | 'fileUploads' | 'secretAccess';
73
+ type IPluginManifestCapability = 'backendBundle' | 'databaseMigrations' | 'readUsers' | 'writeUsers' | 'deleteUsers' | 'readDataTables' | 'writeDataTables' | 'deleteDataTables' | 'externalNetworkAccess' | 'scheduledJobs' | 'publicCallbacks' | 'adminPages' | 'frontendStyles' | 'mobileStyles' | 'realtimePublish' | 'fileUploads' | 'secretAccess' | 'lookupExtend' | 'lookupOwnGroup';
74
74
  interface IPluginManifestCompatibility {
75
75
  /** SemVer range for the SelfHelp CMS version (e.g. `^2.0`). */
76
76
  selfhelp: string;
@@ -385,10 +385,9 @@ interface IPluginRegistryEntry {
385
385
  /**
386
386
  * Registry root document.
387
387
  *
388
- * Mirrors `plugin-registry.schema.json`. The schema document calls the
389
- * version field `registryVersion` (integer, bumped only on breaking
390
- * registry-document changes); we keep the legacy `schemaVersion` field
391
- * as a compatibility alias so existing consumers do not break.
388
+ * Mirrors `plugin-registry.schema.json`. The version field is named
389
+ * `registryVersion` (integer, bumped only on breaking registry-document
390
+ * changes).
392
391
  */
393
392
  interface IPluginRegistry {
394
393
  /** Registry schema generation. Bumped only on breaking registry-document changes. */
@@ -565,6 +564,47 @@ interface IStyleDefinition extends Omit<IStyleRegistryEntry, 'category'> {
565
564
  /** Style implementation component (React or React Native). */
566
565
  component: TPluginComponent;
567
566
  }
567
+ /**
568
+ * Props passed by the host's section-field editor to a plugin-supplied
569
+ * field renderer. The host owns the surrounding label / help tooltip /
570
+ * type badge; the plugin only owns the actual input control.
571
+ *
572
+ * `field` is intentionally typed as a loose record because the host's
573
+ * `IFieldData` lives in the frontend repo and must not leak into the
574
+ * shared SDK contract — plugins read only what they need (id, name,
575
+ * config, default_value, etc.).
576
+ */
577
+ interface IPluginFieldRendererProps {
578
+ /** Field id (database row id). */
579
+ fieldId: number;
580
+ /** Field name (DB `fields.name`). */
581
+ fieldName: string;
582
+ /** Field type (`fields.type`, e.g. `select-survey-js`). */
583
+ fieldType: string;
584
+ /** Current string value bound to the section_field translation. */
585
+ value: string;
586
+ /** Persist a new string value on the section_field translation. */
587
+ onChange: (value: string) => void;
588
+ /** Whether the input is disabled by the host. */
589
+ disabled?: boolean;
590
+ /** Loose pass-through of the host field row (config, default, help, ...). */
591
+ field?: Record<string, unknown>;
592
+ }
593
+ /**
594
+ * Field renderer contributed by a plugin. Replaces the host default
595
+ * editor control for the given `fieldType`. Used by the CMS
596
+ * section-field editor in the frontend repo so plugins can ship custom
597
+ * pickers (e.g. SurveyJS survey select) without the host having to
598
+ * hardcode plugin-specific UI in `FieldRenderer.tsx`.
599
+ *
600
+ * The component receives {@link IPluginFieldRendererProps}.
601
+ */
602
+ interface IFieldRendererDefinition {
603
+ /** Field type discriminator (`fields.type`, e.g. `select-survey-js`). */
604
+ fieldType: string;
605
+ /** React component that renders the input control. */
606
+ component: TPluginComponent<IPluginFieldRendererProps>;
607
+ }
568
608
  /**
569
609
  * Admin page contributed by a plugin. Mounted under
570
610
  * `/admin/plugins-host/{pluginId}/{slug}` in the frontend.
@@ -767,6 +807,13 @@ interface IPluginRegistration {
767
807
  featureFlags?: IPluginFeatureFlag[];
768
808
  /** Realtime topics the plugin publishes / subscribes to. */
769
809
  realtimeTopics?: IPluginRealtimeTopic[];
810
+ /**
811
+ * CMS section-field editor renderers contributed by the plugin.
812
+ * Allows plugins to ship custom pickers for plugin-owned field types
813
+ * (declared in the plugin's Doctrine migration as new rows in
814
+ * `field_types`) without the host having to hardcode the renderer.
815
+ */
816
+ fieldRenderers?: IFieldRendererDefinition[];
770
817
  }
771
818
  /**
772
819
  * Returned by `defineMobilePlugin()` for the mobile side of a plugin.
@@ -903,4 +950,4 @@ interface IUsePluginRealtimeResult<TPayload = unknown> {
903
950
  */
904
951
  declare function usePluginRealtime<TPayload = unknown>(options: IUsePluginRealtimeOptions<TPayload>): IUsePluginRealtimeResult<TPayload>;
905
952
 
906
- export { type IAdminPageDefinition, type IMenuItemDefinition, type IMobilePluginApi, type IMobilePluginRegistration, type IPluginApi, type IPluginFeatureFlag, type IPluginHealthCheck, type IPluginLock, type IPluginLockEntry, type IPluginLockMigration, type IPluginLockMobileEntry, type IPluginManifest, type IPluginManifestAdminPage, type IPluginManifestApiRoute, type IPluginManifestAsset, type IPluginManifestCapability, type IPluginManifestCompatibility, type IPluginManifestConflict, type IPluginManifestDataAccess, type IPluginManifestDependency, type IPluginManifestExternalHost, type IPluginManifestFeatureFlag, type IPluginManifestHealth, type IPluginManifestLookupExtension, type IPluginManifestMobile, type IPluginManifestPermission, type IPluginManifestRealtimeTopic, type IPluginManifestScheduledJob, type IPluginManifestSecurity, type IPluginManifestStyle, type IPluginManifestTrustLevel, type IPluginRealtimePublisher, type IPluginRealtimeTopic, type IPluginRegistration, type IPluginRegistry, type IPluginRegistryEntry, type IPluginRegistryVersionEntry, type IRealtimeTransport, type IRichTextEditorAdapter, type IRichTextEditorAdapterOptions, type IRichTextEditorValue, type IStyleDefinition, type IUsePluginRealtimeOptions, type IUsePluginRealtimeResult, PLUGIN_API_VERSION, type TPluginRegistryChannel, type TRealtimeTransportFactory, assertCmsCompatibility, assertPluginApiVersion, assertPluginVersionSemantics, compareSemver, defineMobilePlugin, definePlugin, definePluginRealtimeTopic, isPluginApiCompatible, parseSemver, satisfiesSemverRange, usePluginRealtime };
953
+ export { type IAdminPageDefinition, type IFieldRendererDefinition, type IMenuItemDefinition, type IMobilePluginApi, type IMobilePluginRegistration, type IPluginApi, type IPluginFeatureFlag, type IPluginFieldRendererProps, type IPluginHealthCheck, type IPluginLock, type IPluginLockEntry, type IPluginLockMigration, type IPluginLockMobileEntry, type IPluginManifest, type IPluginManifestAdminPage, type IPluginManifestApiRoute, type IPluginManifestAsset, type IPluginManifestCapability, type IPluginManifestCompatibility, type IPluginManifestConflict, type IPluginManifestDataAccess, type IPluginManifestDependency, type IPluginManifestExternalHost, type IPluginManifestFeatureFlag, type IPluginManifestHealth, type IPluginManifestLookupExtension, type IPluginManifestMobile, type IPluginManifestPermission, type IPluginManifestRealtimeTopic, type IPluginManifestScheduledJob, type IPluginManifestSecurity, type IPluginManifestStyle, type IPluginManifestTrustLevel, type IPluginRealtimePublisher, type IPluginRealtimeTopic, type IPluginRegistration, type IPluginRegistry, type IPluginRegistryEntry, type IPluginRegistryVersionEntry, type IRealtimeTransport, type IRichTextEditorAdapter, type IRichTextEditorAdapterOptions, type IRichTextEditorValue, type IStyleDefinition, type IUsePluginRealtimeOptions, type IUsePluginRealtimeResult, PLUGIN_API_VERSION, type TPluginRegistryChannel, type TRealtimeTransportFactory, assertCmsCompatibility, assertPluginApiVersion, assertPluginVersionSemantics, compareSemver, defineMobilePlugin, definePlugin, definePluginRealtimeTopic, isPluginApiCompatible, parseSemver, satisfiesSemverRange, usePluginRealtime };
@@ -36,7 +36,7 @@ __export(plugin_sdk_exports, {
36
36
  module.exports = __toCommonJS(plugin_sdk_exports);
37
37
 
38
38
  // src/plugin-sdk/version.ts
39
- var PLUGIN_API_VERSION = "1.0";
39
+ var PLUGIN_API_VERSION = "1.1";
40
40
  var SEMVER_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
41
41
  function parseSemver(version) {
42
42
  const match = SEMVER_REGEX.exec(version);
@@ -1,5 +1,5 @@
1
1
  // src/plugin-sdk/version.ts
2
- var PLUGIN_API_VERSION = "1.0";
2
+ var PLUGIN_API_VERSION = "1.1";
3
3
  var SEMVER_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
4
4
  function parseSemver(version) {
5
5
  const match = SEMVER_REGEX.exec(version);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selfhelp/shared",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "Shared TypeScript package for SelfHelp web frontend and mobile app: style registry, types, API contracts, Mantine theme tokens, condition + interpolation engines, CMS class allow-list.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -67,6 +67,8 @@ export type {
67
67
  IPluginRegistration,
68
68
  IMobilePluginRegistration,
69
69
  IStyleDefinition,
70
+ IFieldRendererDefinition,
71
+ IPluginFieldRendererProps,
70
72
  IAdminPageDefinition,
71
73
  IMenuItemDefinition,
72
74
  IPluginApi,
@@ -29,7 +29,9 @@ export type IPluginManifestCapability =
29
29
  | 'mobileStyles'
30
30
  | 'realtimePublish'
31
31
  | 'fileUploads'
32
- | 'secretAccess';
32
+ | 'secretAccess'
33
+ | 'lookupExtend'
34
+ | 'lookupOwnGroup';
33
35
 
34
36
  export interface IPluginManifestCompatibility {
35
37
  /** SemVer range for the SelfHelp CMS version (e.g. `^2.0`). */
@@ -72,10 +72,9 @@ export interface IPluginRegistryEntry {
72
72
  /**
73
73
  * Registry root document.
74
74
  *
75
- * Mirrors `plugin-registry.schema.json`. The schema document calls the
76
- * version field `registryVersion` (integer, bumped only on breaking
77
- * registry-document changes); we keep the legacy `schemaVersion` field
78
- * as a compatibility alias so existing consumers do not break.
75
+ * Mirrors `plugin-registry.schema.json`. The version field is named
76
+ * `registryVersion` (integer, bumped only on breaking registry-document
77
+ * changes).
79
78
  */
80
79
  export interface IPluginRegistry {
81
80
  /** Registry schema generation. Bumped only on breaking registry-document changes. */
@@ -40,6 +40,49 @@ export interface IStyleDefinition extends Omit<IStyleRegistryEntry, 'category'>
40
40
  component: TPluginComponent;
41
41
  }
42
42
 
43
+ /**
44
+ * Props passed by the host's section-field editor to a plugin-supplied
45
+ * field renderer. The host owns the surrounding label / help tooltip /
46
+ * type badge; the plugin only owns the actual input control.
47
+ *
48
+ * `field` is intentionally typed as a loose record because the host's
49
+ * `IFieldData` lives in the frontend repo and must not leak into the
50
+ * shared SDK contract — plugins read only what they need (id, name,
51
+ * config, default_value, etc.).
52
+ */
53
+ export interface IPluginFieldRendererProps {
54
+ /** Field id (database row id). */
55
+ fieldId: number;
56
+ /** Field name (DB `fields.name`). */
57
+ fieldName: string;
58
+ /** Field type (`fields.type`, e.g. `select-survey-js`). */
59
+ fieldType: string;
60
+ /** Current string value bound to the section_field translation. */
61
+ value: string;
62
+ /** Persist a new string value on the section_field translation. */
63
+ onChange: (value: string) => void;
64
+ /** Whether the input is disabled by the host. */
65
+ disabled?: boolean;
66
+ /** Loose pass-through of the host field row (config, default, help, ...). */
67
+ field?: Record<string, unknown>;
68
+ }
69
+
70
+ /**
71
+ * Field renderer contributed by a plugin. Replaces the host default
72
+ * editor control for the given `fieldType`. Used by the CMS
73
+ * section-field editor in the frontend repo so plugins can ship custom
74
+ * pickers (e.g. SurveyJS survey select) without the host having to
75
+ * hardcode plugin-specific UI in `FieldRenderer.tsx`.
76
+ *
77
+ * The component receives {@link IPluginFieldRendererProps}.
78
+ */
79
+ export interface IFieldRendererDefinition {
80
+ /** Field type discriminator (`fields.type`, e.g. `select-survey-js`). */
81
+ fieldType: string;
82
+ /** React component that renders the input control. */
83
+ component: TPluginComponent<IPluginFieldRendererProps>;
84
+ }
85
+
43
86
  /**
44
87
  * Admin page contributed by a plugin. Mounted under
45
88
  * `/admin/plugins-host/{pluginId}/{slug}` in the frontend.
@@ -247,6 +290,13 @@ export interface IPluginRegistration {
247
290
  featureFlags?: IPluginFeatureFlag[];
248
291
  /** Realtime topics the plugin publishes / subscribes to. */
249
292
  realtimeTopics?: IPluginRealtimeTopic[];
293
+ /**
294
+ * CMS section-field editor renderers contributed by the plugin.
295
+ * Allows plugins to ship custom pickers for plugin-owned field types
296
+ * (declared in the plugin's Doctrine migration as new rows in
297
+ * `field_types`) without the host having to hardcode the renderer.
298
+ */
299
+ fieldRenderers?: IFieldRendererDefinition[];
250
300
  }
251
301
 
252
302
  /**
@@ -14,7 +14,7 @@ SPDX-License-Identifier: MPL-2.0
14
14
  *
15
15
  * Independent from the npm `version` of `@selfhelp/shared`.
16
16
  */
17
- export const PLUGIN_API_VERSION = '1.0' as const;
17
+ export const PLUGIN_API_VERSION = '1.1' as const;
18
18
 
19
19
  export interface ISemver {
20
20
  major: number;