@selfhelp/shared 1.3.0 → 1.3.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +341 -341
  2. package/LICENSE +381 -381
  3. package/README.md +57 -57
  4. package/package.json +102 -102
  5. package/src/api/__tests__/endpoints.test.ts +45 -45
  6. package/src/api/index.ts +5 -5
  7. package/src/assets/__tests__/resolveAssetUrl.test.ts +61 -61
  8. package/src/assets/index.ts +5 -5
  9. package/src/assets/resolveAssetUrl.ts +44 -44
  10. package/src/cms-classes/__tests__/classify.test.ts +63 -63
  11. package/src/cms-classes/allow-list.ts +158 -158
  12. package/src/cms-classes/classify.ts +90 -90
  13. package/src/cms-classes/index.ts +7 -7
  14. package/src/cms-classes/remap.ts +44 -44
  15. package/src/condition/__tests__/evaluate.test.ts +54 -54
  16. package/src/condition/evaluate.ts +121 -121
  17. package/src/condition/index.ts +5 -5
  18. package/src/index.ts +25 -25
  19. package/src/interpolation/__tests__/replaceCalcedValues.test.ts +41 -41
  20. package/src/interpolation/index.ts +5 -5
  21. package/src/interpolation/replaceCalcedValues.ts +27 -27
  22. package/src/plugin-sdk/define.ts +89 -89
  23. package/src/plugin-sdk/index.ts +103 -103
  24. package/src/plugin-sdk/lock.ts +124 -124
  25. package/src/plugin-sdk/manifest.ts +307 -307
  26. package/src/plugin-sdk/realtime.ts +277 -277
  27. package/src/plugin-sdk/registry.ts +105 -105
  28. package/src/plugin-sdk/runtime-shim.ts +140 -140
  29. package/src/plugin-sdk/types.ts +315 -315
  30. package/src/plugin-sdk/version.ts +209 -209
  31. package/src/registry/__tests__/registry.test.ts +135 -135
  32. package/src/registry/index.ts +94 -94
  33. package/src/registry/styles.registry.ts +295 -295
  34. package/src/testing/__tests__/testing-kit.test.ts +228 -228
  35. package/src/testing/index.ts +483 -483
  36. package/src/theme/index.ts +6 -6
  37. package/src/theme/tailwind.ts +73 -73
  38. package/src/theme/tokens.ts +177 -177
  39. package/src/types/api/envelope.ts +34 -34
  40. package/src/types/api/forms.ts +76 -76
  41. package/src/types/api/index.ts +9 -9
  42. package/src/types/api/language.ts +12 -12
  43. package/src/types/api/page.ts +9 -9
  44. package/src/types/index.ts +17 -17
  45. package/src/types/mantine/common.ts +142 -142
  46. package/src/types/pages.ts +107 -107
  47. package/src/types/styles/auth.ts +184 -184
  48. package/src/types/styles/base.ts +72 -72
  49. package/src/types/styles/composite.ts +131 -131
  50. package/src/types/styles/forms.ts +439 -439
  51. package/src/types/styles/interactive.ts +165 -165
  52. package/src/types/styles/layout.ts +184 -184
  53. package/src/types/styles/media.ts +68 -68
  54. package/src/types/styles/typography.ts +118 -118
  55. package/src/types/styles/unknown.ts +220 -220
  56. package/src/utils/__tests__/transformPageData.test.ts +69 -69
  57. package/src/utils/spacing.ts +64 -64
  58. package/src/utils/transformPageData.ts +99 -99
@@ -1,89 +1,89 @@
1
- /*
2
- SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
- SPDX-License-Identifier: MPL-2.0
4
- */
5
- /**
6
- * `definePlugin()` / `defineMobilePlugin()` are the only entry points
7
- * plugins call. They validate the SDK version, register style entries
8
- * in the shared registry, and return the registration object the host
9
- * `PluginRuntime` reads.
10
- */
11
-
12
- import {
13
- extendStyleRegistry,
14
- type IStyleRegistryEntry,
15
- } from '../registry/styles.registry';
16
-
17
- import type {
18
- IMobilePluginRegistration,
19
- IPluginRealtimeTopic,
20
- IPluginRegistration,
21
- IStyleDefinition,
22
- } from './types';
23
-
24
- import { assertPluginApiVersion } from './version';
25
-
26
- /**
27
- * Plugin frontend / admin entry point.
28
- *
29
- * Example:
30
- * export const register = definePlugin({
31
- * id: 'sh2-shp-survey-js',
32
- * version: '1.0.0',
33
- * pluginApiVersion: '1.0',
34
- * styles: [{ name: 'surveyjs', component: SurveyJsStyle, ... }],
35
- * });
36
- */
37
- export function definePlugin(registration: IPluginRegistration): IPluginRegistration {
38
- assertPluginApiVersion(registration.pluginApiVersion);
39
- if (registration.styles?.length) {
40
- extendStyleRegistry(toRegistryRecord(registration.styles), {
41
- pluginId: registration.id,
42
- pluginVersion: registration.version,
43
- });
44
- }
45
- return registration;
46
- }
47
-
48
- /**
49
- * Plugin mobile entry point. Same contract as `definePlugin()` but
50
- * mobile-only. Mobile builds bundle plugin packages per EAS profile,
51
- * so this runs inside the mobile Metro bundle at app boot.
52
- */
53
- export function defineMobilePlugin(
54
- registration: IMobilePluginRegistration,
55
- ): IMobilePluginRegistration {
56
- assertPluginApiVersion(registration.pluginApiVersion);
57
- if (registration.styles?.length) {
58
- extendStyleRegistry(toRegistryRecord(registration.styles), {
59
- pluginId: registration.id,
60
- pluginVersion: registration.version,
61
- });
62
- }
63
- return registration;
64
- }
65
-
66
- /**
67
- * Declare a realtime topic for type-safe publish/subscribe. Returns the
68
- * topic descriptor; the host installer registers it through
69
- * `PluginRealtimeTopicRegistryEvent` so admins can audit topics in the
70
- * Plugin detail page.
71
- */
72
- export function definePluginRealtimeTopic<TPayload>(
73
- descriptor: IPluginRealtimeTopic<TPayload>,
74
- ): IPluginRealtimeTopic<TPayload> {
75
- return descriptor;
76
- }
77
-
78
- function toRegistryRecord(styles: IStyleDefinition[]): Record<string, IStyleRegistryEntry> {
79
- const out: Record<string, IStyleRegistryEntry> = {};
80
- for (const style of styles) {
81
- out[style.name] = {
82
- description: style.description,
83
- category: style.category,
84
- frontendOnly: true,
85
- canHaveChildren: style.canHaveChildren,
86
- };
87
- }
88
- return out;
89
- }
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * `definePlugin()` / `defineMobilePlugin()` are the only entry points
7
+ * plugins call. They validate the SDK version, register style entries
8
+ * in the shared registry, and return the registration object the host
9
+ * `PluginRuntime` reads.
10
+ */
11
+
12
+ import {
13
+ extendStyleRegistry,
14
+ type IStyleRegistryEntry,
15
+ } from '../registry/styles.registry';
16
+
17
+ import type {
18
+ IMobilePluginRegistration,
19
+ IPluginRealtimeTopic,
20
+ IPluginRegistration,
21
+ IStyleDefinition,
22
+ } from './types';
23
+
24
+ import { assertPluginApiVersion } from './version';
25
+
26
+ /**
27
+ * Plugin frontend / admin entry point.
28
+ *
29
+ * Example:
30
+ * export const register = definePlugin({
31
+ * id: 'sh2-shp-survey-js',
32
+ * version: '1.0.0',
33
+ * pluginApiVersion: '1.0',
34
+ * styles: [{ name: 'surveyjs', component: SurveyJsStyle, ... }],
35
+ * });
36
+ */
37
+ export function definePlugin(registration: IPluginRegistration): IPluginRegistration {
38
+ assertPluginApiVersion(registration.pluginApiVersion);
39
+ if (registration.styles?.length) {
40
+ extendStyleRegistry(toRegistryRecord(registration.styles), {
41
+ pluginId: registration.id,
42
+ pluginVersion: registration.version,
43
+ });
44
+ }
45
+ return registration;
46
+ }
47
+
48
+ /**
49
+ * Plugin mobile entry point. Same contract as `definePlugin()` but
50
+ * mobile-only. Mobile builds bundle plugin packages per EAS profile,
51
+ * so this runs inside the mobile Metro bundle at app boot.
52
+ */
53
+ export function defineMobilePlugin(
54
+ registration: IMobilePluginRegistration,
55
+ ): IMobilePluginRegistration {
56
+ assertPluginApiVersion(registration.pluginApiVersion);
57
+ if (registration.styles?.length) {
58
+ extendStyleRegistry(toRegistryRecord(registration.styles), {
59
+ pluginId: registration.id,
60
+ pluginVersion: registration.version,
61
+ });
62
+ }
63
+ return registration;
64
+ }
65
+
66
+ /**
67
+ * Declare a realtime topic for type-safe publish/subscribe. Returns the
68
+ * topic descriptor; the host installer registers it through
69
+ * `PluginRealtimeTopicRegistryEvent` so admins can audit topics in the
70
+ * Plugin detail page.
71
+ */
72
+ export function definePluginRealtimeTopic<TPayload>(
73
+ descriptor: IPluginRealtimeTopic<TPayload>,
74
+ ): IPluginRealtimeTopic<TPayload> {
75
+ return descriptor;
76
+ }
77
+
78
+ function toRegistryRecord(styles: IStyleDefinition[]): Record<string, IStyleRegistryEntry> {
79
+ const out: Record<string, IStyleRegistryEntry> = {};
80
+ for (const style of styles) {
81
+ out[style.name] = {
82
+ description: style.description,
83
+ category: style.category,
84
+ frontendOnly: true,
85
+ canHaveChildren: style.canHaveChildren,
86
+ };
87
+ }
88
+ return out;
89
+ }
@@ -1,103 +1,103 @@
1
- /*
2
- SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
- SPDX-License-Identifier: MPL-2.0
4
- */
5
- /**
6
- * `@selfhelp/shared/plugin-sdk` — public SDK consumed by every SelfHelp
7
- * plugin's frontend and mobile package.
8
- *
9
- * Plugins import from this subpath ONLY. Importing from other internal
10
- * paths of `@selfhelp/shared` is not supported.
11
- *
12
- * The SDK has its own `pluginApiVersion` (see `version.ts`). Plugins
13
- * declare which `pluginApiVersion` they target in `plugin.json`; the
14
- * host installer compares the declaration with `PLUGIN_API_VERSION`
15
- * before allowing the plugin to load.
16
- */
17
-
18
- export {
19
- PLUGIN_API_VERSION,
20
- assertPluginApiVersion,
21
- isPluginApiCompatible,
22
- assertCmsCompatibility,
23
- assertPluginVersionSemantics,
24
- parseSemver,
25
- compareSemver,
26
- satisfiesSemverRange,
27
- } from './version';
28
-
29
- export type {
30
- IPluginManifest,
31
- IPluginManifestCompatibility,
32
- IPluginManifestDependency,
33
- IPluginManifestConflict,
34
- IPluginManifestSecurity,
35
- IPluginManifestCapability,
36
- IPluginManifestTrustLevel,
37
- IPluginManifestRealtimeTopic,
38
- IPluginManifestFeatureFlag,
39
- IPluginManifestLookupExtension,
40
- IPluginManifestPermission,
41
- IPluginManifestStyle,
42
- IPluginManifestAdminPage,
43
- IPluginManifestApiRoute,
44
- IPluginManifestScheduledJob,
45
- IPluginManifestAsset,
46
- IPluginManifestMobile,
47
- IPluginManifestExternalHost,
48
- IPluginManifestDataAccess,
49
- IPluginManifestHealth,
50
- } from './manifest';
51
-
52
- export type {
53
- IPluginRegistry,
54
- IPluginRegistryEntry,
55
- IPluginRegistryVersionEntry,
56
- TPluginRegistryChannel,
57
- } from './registry';
58
-
59
- export type {
60
- IPluginLock,
61
- IPluginLockEntry,
62
- IPluginLockMobileEntry,
63
- IPluginLockMigration,
64
- } from './lock';
65
-
66
- export type {
67
- IPluginRegistration,
68
- IMobilePluginRegistration,
69
- IStyleDefinition,
70
- IFieldRendererDefinition,
71
- IPluginFieldRendererProps,
72
- IAdminPageDefinition,
73
- IMenuItemDefinition,
74
- IPluginApi,
75
- IMobilePluginApi,
76
- IPluginHealthCheck,
77
- IPluginFeatureFlag,
78
- IPluginRealtimeTopic,
79
- IPluginRealtimePublisher,
80
- IRichTextEditorAdapter,
81
- IRichTextEditorAdapterOptions,
82
- IRichTextEditorValue,
83
- } from './types';
84
-
85
- export { definePlugin, defineMobilePlugin, definePluginRealtimeTopic } from './define';
86
-
87
- export type {
88
- IRealtimeTransport,
89
- TRealtimeTransportFactory,
90
- IUsePluginRealtimeOptions,
91
- IUsePluginRealtimeResult,
92
- } from './realtime';
93
- export { usePluginRealtime } from './realtime';
94
-
95
- export type { TPluginRuntimeShimSpecifier } from './runtime-shim';
96
- export {
97
- PLUGIN_RUNTIME_SHIM_SPECIFIERS,
98
- PLUGIN_RUNTIME_SHIM_BASE_PATH,
99
- PLUGIN_RUNTIME_GLOBAL_KEY,
100
- PLUGIN_RUNTIME_IMPORT_MAP,
101
- buildPluginRuntimeShimPath,
102
- isPluginRuntimeShimSpecifier,
103
- } from './runtime-shim';
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * `@selfhelp/shared/plugin-sdk` — public SDK consumed by every SelfHelp
7
+ * plugin's frontend and mobile package.
8
+ *
9
+ * Plugins import from this subpath ONLY. Importing from other internal
10
+ * paths of `@selfhelp/shared` is not supported.
11
+ *
12
+ * The SDK has its own `pluginApiVersion` (see `version.ts`). Plugins
13
+ * declare which `pluginApiVersion` they target in `plugin.json`; the
14
+ * host installer compares the declaration with `PLUGIN_API_VERSION`
15
+ * before allowing the plugin to load.
16
+ */
17
+
18
+ export {
19
+ PLUGIN_API_VERSION,
20
+ assertPluginApiVersion,
21
+ isPluginApiCompatible,
22
+ assertCmsCompatibility,
23
+ assertPluginVersionSemantics,
24
+ parseSemver,
25
+ compareSemver,
26
+ satisfiesSemverRange,
27
+ } from './version';
28
+
29
+ export type {
30
+ IPluginManifest,
31
+ IPluginManifestCompatibility,
32
+ IPluginManifestDependency,
33
+ IPluginManifestConflict,
34
+ IPluginManifestSecurity,
35
+ IPluginManifestCapability,
36
+ IPluginManifestTrustLevel,
37
+ IPluginManifestRealtimeTopic,
38
+ IPluginManifestFeatureFlag,
39
+ IPluginManifestLookupExtension,
40
+ IPluginManifestPermission,
41
+ IPluginManifestStyle,
42
+ IPluginManifestAdminPage,
43
+ IPluginManifestApiRoute,
44
+ IPluginManifestScheduledJob,
45
+ IPluginManifestAsset,
46
+ IPluginManifestMobile,
47
+ IPluginManifestExternalHost,
48
+ IPluginManifestDataAccess,
49
+ IPluginManifestHealth,
50
+ } from './manifest';
51
+
52
+ export type {
53
+ IPluginRegistry,
54
+ IPluginRegistryEntry,
55
+ IPluginRegistryVersionEntry,
56
+ TPluginRegistryChannel,
57
+ } from './registry';
58
+
59
+ export type {
60
+ IPluginLock,
61
+ IPluginLockEntry,
62
+ IPluginLockMobileEntry,
63
+ IPluginLockMigration,
64
+ } from './lock';
65
+
66
+ export type {
67
+ IPluginRegistration,
68
+ IMobilePluginRegistration,
69
+ IStyleDefinition,
70
+ IFieldRendererDefinition,
71
+ IPluginFieldRendererProps,
72
+ IAdminPageDefinition,
73
+ IMenuItemDefinition,
74
+ IPluginApi,
75
+ IMobilePluginApi,
76
+ IPluginHealthCheck,
77
+ IPluginFeatureFlag,
78
+ IPluginRealtimeTopic,
79
+ IPluginRealtimePublisher,
80
+ IRichTextEditorAdapter,
81
+ IRichTextEditorAdapterOptions,
82
+ IRichTextEditorValue,
83
+ } from './types';
84
+
85
+ export { definePlugin, defineMobilePlugin, definePluginRealtimeTopic } from './define';
86
+
87
+ export type {
88
+ IRealtimeTransport,
89
+ TRealtimeTransportFactory,
90
+ IUsePluginRealtimeOptions,
91
+ IUsePluginRealtimeResult,
92
+ } from './realtime';
93
+ export { usePluginRealtime } from './realtime';
94
+
95
+ export type { TPluginRuntimeShimSpecifier } from './runtime-shim';
96
+ export {
97
+ PLUGIN_RUNTIME_SHIM_SPECIFIERS,
98
+ PLUGIN_RUNTIME_SHIM_BASE_PATH,
99
+ PLUGIN_RUNTIME_GLOBAL_KEY,
100
+ PLUGIN_RUNTIME_IMPORT_MAP,
101
+ buildPluginRuntimeShimPath,
102
+ isPluginRuntimeShimSpecifier,
103
+ } from './runtime-shim';
@@ -1,124 +1,124 @@
1
- /*
2
- SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
- SPDX-License-Identifier: MPL-2.0
4
- */
5
- /**
6
- * TypeScript mirror of `selfhelp.plugins.lock.json`. This file lives at
7
- * the project root of the backend deployment and is the deterministic
8
- * source of truth for which plugin versions are installed, what migrations
9
- * ran, which checksums are pinned, and what mobile packages each EAS
10
- * profile bundles.
11
- *
12
- * The lock file is written atomically by the install/update command. It
13
- * is NEVER edited by hand.
14
- */
15
-
16
- export interface IPluginLockMigration {
17
- /** Doctrine migration class name. */
18
- className: string;
19
- /** Migration file SHA-256 hash, recorded for tamper detection. */
20
- sha256: string;
21
- /** ISO datetime the migration was executed. */
22
- executedAt: string;
23
- /** Whether `down()` is declared safe by the plugin. */
24
- safeDown: boolean;
25
- }
26
-
27
- export interface IPluginLockMobileEntry {
28
- /** EAS profile name (e.g. `production-default`, `production-bern`). */
29
- profile: string;
30
- /** npm package + version that this profile bundles for the plugin. */
31
- package: string;
32
- version: string;
33
- }
34
-
35
- export interface IPluginLockEntry {
36
- /** Plugin id. */
37
- id: string;
38
- /** Pinned plugin version (the manifest version that was installed). */
39
- version: string;
40
- /** SDK contract version the plugin targets. */
41
- pluginApiVersion: string;
42
- /** Trust level recorded at install time. */
43
- trustLevel: 'official' | 'reviewed' | 'untrusted';
44
- /** Capabilities granted at install time. */
45
- capabilities: string[];
46
- /** Source descriptor that produced the install. */
47
- source: {
48
- kind: 'public-registry' | 'private-registry' | 'git' | 'local';
49
- url?: string;
50
- gitSha?: string;
51
- registryUrl?: string;
52
- };
53
- /** Backend Composer package + version, if any. */
54
- backend?: {
55
- package: string;
56
- version: string;
57
- bundleClass: string;
58
- };
59
- /** Frontend npm package + version, if any. */
60
- frontend?: {
61
- package: string;
62
- version: string;
63
- };
64
- /** Per-EAS-profile mobile package pin. */
65
- mobile?: IPluginLockMobileEntry[];
66
- /** SHA-256 checksum of the published artifact. */
67
- checksumSha256: string;
68
- /** Optional Ed25519 signature, base64. */
69
- signatureEd25519?: string;
70
- /** Hashes of every migration this plugin has executed. */
71
- migrations: IPluginLockMigration[];
72
- /** Plugin-owned style names contributed at install time. */
73
- ownedStyles: string[];
74
- /** Plugin-owned API route names contributed at install time. */
75
- ownedApiRoutes: string[];
76
- /** Plugin-owned realtime topics contributed at install time. */
77
- ownedRealtimeTopics: string[];
78
- /** Plugin-owned lookup type codes (`plugin_owned`) contributed at install time. */
79
- ownedLookupTypeCodes: string[];
80
- /** Feature flags shipped with the plugin and their default state. */
81
- featureFlags: { key: string; defaultEnabled: boolean }[];
82
- /** Whether the plugin is currently enabled. */
83
- enabled: boolean;
84
- /** ISO datetime of the install/update event. */
85
- installedAt: string;
86
- /** ISO datetime of the last update. */
87
- updatedAt: string;
88
- /** Optional notes that the installer wants to surface. */
89
- notes?: string;
90
- }
91
-
92
- /**
93
- * Root document of `selfhelp.plugins.lock.json`.
94
- *
95
- * Mirrors `plugin-lock.schema.json`. The schema requires
96
- * `lockfileVersion`, `generatedAt`, `sdk`, and `plugins`. The schema
97
- * stores plugins as a keyed object (`{ [pluginId]: lockedPlugin }`),
98
- * but for typed consumers we expose it as an array of entries plus the
99
- * keyed object so both shapes are usable.
100
- */
101
- export interface IPluginLock {
102
- /** Lock-file schema generation. Bumped only on breaking changes. */
103
- lockfileVersion: number;
104
- /** ISO datetime the lock file was last written. */
105
- generatedAt: string;
106
- /** SDK contract pin captured at write time. */
107
- sdk: {
108
- /** SemVer of the `@selfhelp/shared` package that wrote this file. */
109
- version: string;
110
- /** Plugin API version the host honors at write time. */
111
- pluginApiVersion: string;
112
- };
113
- /**
114
- * Installed plugins keyed by plugin id. Each entry follows
115
- * `IPluginLockEntry`. The schema stores this as an object, not an
116
- * array, so iteration order is undefined.
117
- */
118
- plugins: Record<string, IPluginLockEntry>;
119
- /**
120
- * Optional install mode hint, preserved for tooling that already
121
- * read it from earlier lock-file revisions.
122
- */
123
- installMode?: 'development' | 'managed' | 'trusted';
124
- }
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * TypeScript mirror of `selfhelp.plugins.lock.json`. This file lives at
7
+ * the project root of the backend deployment and is the deterministic
8
+ * source of truth for which plugin versions are installed, what migrations
9
+ * ran, which checksums are pinned, and what mobile packages each EAS
10
+ * profile bundles.
11
+ *
12
+ * The lock file is written atomically by the install/update command. It
13
+ * is NEVER edited by hand.
14
+ */
15
+
16
+ export interface IPluginLockMigration {
17
+ /** Doctrine migration class name. */
18
+ className: string;
19
+ /** Migration file SHA-256 hash, recorded for tamper detection. */
20
+ sha256: string;
21
+ /** ISO datetime the migration was executed. */
22
+ executedAt: string;
23
+ /** Whether `down()` is declared safe by the plugin. */
24
+ safeDown: boolean;
25
+ }
26
+
27
+ export interface IPluginLockMobileEntry {
28
+ /** EAS profile name (e.g. `production-default`, `production-bern`). */
29
+ profile: string;
30
+ /** npm package + version that this profile bundles for the plugin. */
31
+ package: string;
32
+ version: string;
33
+ }
34
+
35
+ export interface IPluginLockEntry {
36
+ /** Plugin id. */
37
+ id: string;
38
+ /** Pinned plugin version (the manifest version that was installed). */
39
+ version: string;
40
+ /** SDK contract version the plugin targets. */
41
+ pluginApiVersion: string;
42
+ /** Trust level recorded at install time. */
43
+ trustLevel: 'official' | 'reviewed' | 'untrusted';
44
+ /** Capabilities granted at install time. */
45
+ capabilities: string[];
46
+ /** Source descriptor that produced the install. */
47
+ source: {
48
+ kind: 'public-registry' | 'private-registry' | 'git' | 'local';
49
+ url?: string;
50
+ gitSha?: string;
51
+ registryUrl?: string;
52
+ };
53
+ /** Backend Composer package + version, if any. */
54
+ backend?: {
55
+ package: string;
56
+ version: string;
57
+ bundleClass: string;
58
+ };
59
+ /** Frontend npm package + version, if any. */
60
+ frontend?: {
61
+ package: string;
62
+ version: string;
63
+ };
64
+ /** Per-EAS-profile mobile package pin. */
65
+ mobile?: IPluginLockMobileEntry[];
66
+ /** SHA-256 checksum of the published artifact. */
67
+ checksumSha256: string;
68
+ /** Optional Ed25519 signature, base64. */
69
+ signatureEd25519?: string;
70
+ /** Hashes of every migration this plugin has executed. */
71
+ migrations: IPluginLockMigration[];
72
+ /** Plugin-owned style names contributed at install time. */
73
+ ownedStyles: string[];
74
+ /** Plugin-owned API route names contributed at install time. */
75
+ ownedApiRoutes: string[];
76
+ /** Plugin-owned realtime topics contributed at install time. */
77
+ ownedRealtimeTopics: string[];
78
+ /** Plugin-owned lookup type codes (`plugin_owned`) contributed at install time. */
79
+ ownedLookupTypeCodes: string[];
80
+ /** Feature flags shipped with the plugin and their default state. */
81
+ featureFlags: { key: string; defaultEnabled: boolean }[];
82
+ /** Whether the plugin is currently enabled. */
83
+ enabled: boolean;
84
+ /** ISO datetime of the install/update event. */
85
+ installedAt: string;
86
+ /** ISO datetime of the last update. */
87
+ updatedAt: string;
88
+ /** Optional notes that the installer wants to surface. */
89
+ notes?: string;
90
+ }
91
+
92
+ /**
93
+ * Root document of `selfhelp.plugins.lock.json`.
94
+ *
95
+ * Mirrors `plugin-lock.schema.json`. The schema requires
96
+ * `lockfileVersion`, `generatedAt`, `sdk`, and `plugins`. The schema
97
+ * stores plugins as a keyed object (`{ [pluginId]: lockedPlugin }`),
98
+ * but for typed consumers we expose it as an array of entries plus the
99
+ * keyed object so both shapes are usable.
100
+ */
101
+ export interface IPluginLock {
102
+ /** Lock-file schema generation. Bumped only on breaking changes. */
103
+ lockfileVersion: number;
104
+ /** ISO datetime the lock file was last written. */
105
+ generatedAt: string;
106
+ /** SDK contract pin captured at write time. */
107
+ sdk: {
108
+ /** SemVer of the `@selfhelp/shared` package that wrote this file. */
109
+ version: string;
110
+ /** Plugin API version the host honors at write time. */
111
+ pluginApiVersion: string;
112
+ };
113
+ /**
114
+ * Installed plugins keyed by plugin id. Each entry follows
115
+ * `IPluginLockEntry`. The schema stores this as an object, not an
116
+ * array, so iteration order is undefined.
117
+ */
118
+ plugins: Record<string, IPluginLockEntry>;
119
+ /**
120
+ * Optional install mode hint, preserved for tooling that already
121
+ * read it from earlier lock-file revisions.
122
+ */
123
+ installMode?: 'development' | 'managed' | 'trusted';
124
+ }