@selfhelp/shared 1.2.2 → 1.2.4

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.
@@ -0,0 +1,251 @@
1
+ /**
2
+ * TypeScript mirror of `plugin.json` (the schema lives in
3
+ * `sh-selfhelp_backend/docs/plugins/plugin-manifest.schema.json`). When
4
+ * the JSON Schema changes, update these types and bump the
5
+ * `@selfhelp/shared` minor version.
6
+ */
7
+ type IPluginManifestTrustLevel = 'official' | 'reviewed' | 'untrusted';
8
+ /** Every privileged capability is deny-by-default. */
9
+ type IPluginManifestCapability = 'backendBundle' | 'databaseMigrations' | 'readUsers' | 'writeUsers' | 'deleteUsers' | 'readDataTables' | 'writeDataTables' | 'deleteDataTables' | 'externalNetworkAccess' | 'scheduledJobs' | 'publicCallbacks' | 'adminPages' | 'frontendStyles' | 'mobileStyles' | 'realtimePublish' | 'fileUploads' | 'secretAccess' | 'lookupExtend' | 'lookupOwnGroup';
10
+ interface IPluginManifestCompatibility {
11
+ /** SemVer range for the SelfHelp CMS version (e.g. `^2.0`). */
12
+ selfhelp: string;
13
+ /** SemVer range for PHP runtime. */
14
+ php?: string;
15
+ /** SemVer range for Node runtime. */
16
+ node?: string;
17
+ /** SemVer range for React (web). */
18
+ react?: string;
19
+ /** SemVer range for React Native (mobile). */
20
+ reactNative?: string;
21
+ /** SemVer range for Expo SDK. */
22
+ expoSdk?: string;
23
+ }
24
+ interface IPluginManifestDependency {
25
+ /** Plugin id this plugin requires. */
26
+ pluginId: string;
27
+ /** Required SemVer range. */
28
+ version: string;
29
+ /** Optional / required dependency. */
30
+ required: boolean;
31
+ /**
32
+ * When `required: false`, the plugin still works without the dep
33
+ * but enables additional features when present.
34
+ */
35
+ featureFlag?: string;
36
+ }
37
+ interface IPluginManifestConflict {
38
+ pluginId: string;
39
+ /** SemVer range that conflicts. */
40
+ version: string;
41
+ reason: string;
42
+ }
43
+ interface IPluginManifestExternalHost {
44
+ /** Wildcards allowed, e.g. `cdn.example.com` or `*.example.com`. */
45
+ host: string;
46
+ /** What is loaded — `script`, `style`, `font`, `image`, `iframe`, `fetch`. */
47
+ type: 'script' | 'style' | 'font' | 'image' | 'iframe' | 'fetch';
48
+ /** Reason for the external host (shown in admin UI). */
49
+ reason: string;
50
+ }
51
+ interface IPluginManifestSecurity {
52
+ trustLevel: IPluginManifestTrustLevel;
53
+ capabilities: IPluginManifestCapability[];
54
+ /** CSP rules the installer must add (only for `trustLevel !== 'untrusted'`). */
55
+ cspRules?: {
56
+ /** Maps a CSP directive to extra sources. */
57
+ [directive: string]: string[];
58
+ };
59
+ /** External hosts the plugin will load assets/data from. */
60
+ externalHosts?: IPluginManifestExternalHost[];
61
+ /** Path to file containing checksum/signature, optional. */
62
+ signaturePath?: string;
63
+ }
64
+ interface IPluginManifestDataAccess {
65
+ /**
66
+ * Dedicated tables the plugin owns (created by its migrations). Must be
67
+ * `lowercase_snake_case` (schema pattern `^[a-z][a-z0-9_]*$`).
68
+ */
69
+ ownedTables?: string[];
70
+ /**
71
+ * Prefix for CMS `data_tables` rows the plugin creates at runtime. Must be
72
+ * `lowercase_snake_case` ending in `_` (schema pattern `^[a-z][a-z0-9_]*_$`).
73
+ */
74
+ ownedDataTablePrefix?: string;
75
+ /**
76
+ * Tables the plugin reads. May be `dataTable:*` for any plugin-owned
77
+ * data table, `lookup:<typeCode>` for lookup reads, `dataTable:my`
78
+ * for tables created by this plugin.
79
+ */
80
+ read?: string[];
81
+ /** Tables the plugin writes. */
82
+ write?: string[];
83
+ /** Tables the plugin deletes (rare; requires capability). */
84
+ delete?: string[];
85
+ }
86
+ interface IPluginManifestRealtimeTopic {
87
+ /** Topic key, scoped to this plugin. Example: `survey-response`. */
88
+ key: string;
89
+ /** Human description shown in admin UI. */
90
+ description: string;
91
+ /** Permission required to subscribe; resolved via `PluginRealtimePermissionResolver`. */
92
+ requiredPermission?: string;
93
+ /** JSON Schema path of the topic payload. */
94
+ payloadSchemaPath?: string;
95
+ }
96
+ interface IPluginManifestFeatureFlag {
97
+ key: string;
98
+ description: string;
99
+ /** Default state when no `plugin_feature_flags` row exists. */
100
+ defaultEnabled: boolean;
101
+ /** Optional capability gate; flag cannot be turned on without it. */
102
+ capability?: IPluginManifestCapability;
103
+ }
104
+ interface IPluginManifestLookupExtension {
105
+ /** Lookup type code, e.g. `survey_question_type`. */
106
+ typeCode: string;
107
+ /** Whether the plugin OWNS the type code or only extends it. */
108
+ ownership: 'plugin_extendable' | 'plugin_owned';
109
+ entries: {
110
+ code: string;
111
+ value: string;
112
+ description?: string;
113
+ }[];
114
+ }
115
+ interface IPluginManifestPermission {
116
+ /** Permission key, namespaced like `surveyjs.surveys.manage`. */
117
+ key: string;
118
+ description: string;
119
+ /** Optional default role keys the permission is granted to. */
120
+ defaultRoles?: string[];
121
+ }
122
+ interface IPluginManifestStyle {
123
+ /** Style name (used as `style_name` discriminator). */
124
+ name: string;
125
+ description: string;
126
+ canHaveChildren: boolean;
127
+ /** Optional capability requirement (e.g. `frontendStyles`). */
128
+ capability?: IPluginManifestCapability;
129
+ }
130
+ interface IPluginManifestAdminPage {
131
+ /** Slug under `/admin/plugins-host/{pluginId}/`. */
132
+ slug: string;
133
+ /** Menu label. */
134
+ label: string;
135
+ /** Required permission key. */
136
+ permission: string;
137
+ /** Optional menu icon (Tabler icon name). */
138
+ icon?: string;
139
+ }
140
+ interface IPluginManifestApiRoute {
141
+ /** Symfony route name (must be namespaced with the plugin id). */
142
+ name: string;
143
+ /** HTTP path under `/cms-api/v1/plugins/{pluginId}/...`. */
144
+ path: string;
145
+ methods: ('GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE')[];
146
+ /** Permission key required. */
147
+ permission?: string;
148
+ }
149
+ interface IPluginManifestScheduledJob {
150
+ /** Job type key. */
151
+ type: string;
152
+ description: string;
153
+ /** Capability gate (always requires `scheduledJobs`). */
154
+ capability: 'scheduledJobs';
155
+ }
156
+ interface IPluginManifestAsset {
157
+ /** Source path within the plugin package. */
158
+ src: string;
159
+ /** Destination path under `/assets/plugins/{pluginId}/...`. */
160
+ dest: string;
161
+ /** Asset type. */
162
+ type: 'script' | 'style' | 'font' | 'image' | 'other';
163
+ }
164
+ interface IPluginManifestHealth {
165
+ /** Optional health-check endpoint name. */
166
+ endpoint?: string;
167
+ /** Health-check service id (resolved through Symfony). */
168
+ serviceId?: string;
169
+ }
170
+ interface IPluginManifestMobile {
171
+ /** npm package name of the mobile component bundle. */
172
+ package: string;
173
+ /** Required SemVer range. */
174
+ version: string;
175
+ /** Whether the mobile package only renders payloads (readonly). */
176
+ readonly: boolean;
177
+ }
178
+ /**
179
+ * Full `plugin.json` shape.
180
+ */
181
+ interface IPluginManifest {
182
+ /** Plugin identifier, e.g. `sh2-shp-survey-js`. */
183
+ id: string;
184
+ /** Human-readable display name. */
185
+ name: string;
186
+ /** Short description. */
187
+ description?: string;
188
+ /** Plugin SemVer version. */
189
+ version: string;
190
+ /** Author / vendor. */
191
+ author?: {
192
+ name: string;
193
+ email?: string;
194
+ url?: string;
195
+ };
196
+ /** SPDX license id. */
197
+ license?: string;
198
+ /** Plugin homepage / repo URL. */
199
+ homepage?: string;
200
+ /** SDK contract version the plugin targets (e.g. `1.0`). */
201
+ pluginApiVersion: string;
202
+ /** Compatibility with the host stack. */
203
+ compatibility: IPluginManifestCompatibility;
204
+ /** Required + optional plugin dependencies. */
205
+ dependencies?: IPluginManifestDependency[];
206
+ /** Plugin conflicts. */
207
+ conflicts?: IPluginManifestConflict[];
208
+ /** Composer package (only for `trustLevel !== 'untrusted'`). */
209
+ backend?: {
210
+ package: string;
211
+ bundleClass: string;
212
+ migrationsNamespace?: string;
213
+ };
214
+ /** npm package for frontend. */
215
+ frontend?: {
216
+ package: string;
217
+ version: string;
218
+ };
219
+ /** Optional mobile package. */
220
+ mobile?: IPluginManifestMobile;
221
+ /** Required security declarations. */
222
+ security: IPluginManifestSecurity;
223
+ /** Permissions the plugin contributes. */
224
+ permissions?: IPluginManifestPermission[];
225
+ /** Manifest-declared data access. */
226
+ dataAccess?: IPluginManifestDataAccess;
227
+ /** Realtime topics. */
228
+ realtimeTopics?: IPluginManifestRealtimeTopic[];
229
+ /** Feature flags. */
230
+ featureFlags?: IPluginManifestFeatureFlag[];
231
+ /** Lookup contributions. */
232
+ lookups?: {
233
+ extends?: IPluginManifestLookupExtension[];
234
+ };
235
+ /** Styles contributed to the registry. */
236
+ styles?: IPluginManifestStyle[];
237
+ /** Admin pages mounted under `/admin/plugins-host/{pluginId}/`. */
238
+ adminPages?: IPluginManifestAdminPage[];
239
+ /** Plugin-owned API routes. */
240
+ apiRoutes?: IPluginManifestApiRoute[];
241
+ /** Scheduled jobs. */
242
+ scheduledJobs?: IPluginManifestScheduledJob[];
243
+ /** Vendored assets. */
244
+ assets?: IPluginManifestAsset[];
245
+ /** Health-check declaration. */
246
+ health?: IPluginManifestHealth;
247
+ /** Optional metadata / labels. */
248
+ labels?: Record<string, string>;
249
+ }
250
+
251
+ export type { IPluginManifest as I, IPluginManifestAdminPage as a, IPluginManifestApiRoute as b, IPluginManifestAsset as c, IPluginManifestCapability as d, IPluginManifestCompatibility as e, IPluginManifestConflict as f, IPluginManifestDataAccess as g, IPluginManifestDependency as h, IPluginManifestExternalHost as i, IPluginManifestFeatureFlag as j, IPluginManifestHealth as k, IPluginManifestLookupExtension as l, IPluginManifestMobile as m, IPluginManifestPermission as n, IPluginManifestRealtimeTopic as o, IPluginManifestScheduledJob as p, IPluginManifestSecurity as q, IPluginManifestStyle as r, IPluginManifestTrustLevel as s };
@@ -0,0 +1,251 @@
1
+ /**
2
+ * TypeScript mirror of `plugin.json` (the schema lives in
3
+ * `sh-selfhelp_backend/docs/plugins/plugin-manifest.schema.json`). When
4
+ * the JSON Schema changes, update these types and bump the
5
+ * `@selfhelp/shared` minor version.
6
+ */
7
+ type IPluginManifestTrustLevel = 'official' | 'reviewed' | 'untrusted';
8
+ /** Every privileged capability is deny-by-default. */
9
+ type IPluginManifestCapability = 'backendBundle' | 'databaseMigrations' | 'readUsers' | 'writeUsers' | 'deleteUsers' | 'readDataTables' | 'writeDataTables' | 'deleteDataTables' | 'externalNetworkAccess' | 'scheduledJobs' | 'publicCallbacks' | 'adminPages' | 'frontendStyles' | 'mobileStyles' | 'realtimePublish' | 'fileUploads' | 'secretAccess' | 'lookupExtend' | 'lookupOwnGroup';
10
+ interface IPluginManifestCompatibility {
11
+ /** SemVer range for the SelfHelp CMS version (e.g. `^2.0`). */
12
+ selfhelp: string;
13
+ /** SemVer range for PHP runtime. */
14
+ php?: string;
15
+ /** SemVer range for Node runtime. */
16
+ node?: string;
17
+ /** SemVer range for React (web). */
18
+ react?: string;
19
+ /** SemVer range for React Native (mobile). */
20
+ reactNative?: string;
21
+ /** SemVer range for Expo SDK. */
22
+ expoSdk?: string;
23
+ }
24
+ interface IPluginManifestDependency {
25
+ /** Plugin id this plugin requires. */
26
+ pluginId: string;
27
+ /** Required SemVer range. */
28
+ version: string;
29
+ /** Optional / required dependency. */
30
+ required: boolean;
31
+ /**
32
+ * When `required: false`, the plugin still works without the dep
33
+ * but enables additional features when present.
34
+ */
35
+ featureFlag?: string;
36
+ }
37
+ interface IPluginManifestConflict {
38
+ pluginId: string;
39
+ /** SemVer range that conflicts. */
40
+ version: string;
41
+ reason: string;
42
+ }
43
+ interface IPluginManifestExternalHost {
44
+ /** Wildcards allowed, e.g. `cdn.example.com` or `*.example.com`. */
45
+ host: string;
46
+ /** What is loaded — `script`, `style`, `font`, `image`, `iframe`, `fetch`. */
47
+ type: 'script' | 'style' | 'font' | 'image' | 'iframe' | 'fetch';
48
+ /** Reason for the external host (shown in admin UI). */
49
+ reason: string;
50
+ }
51
+ interface IPluginManifestSecurity {
52
+ trustLevel: IPluginManifestTrustLevel;
53
+ capabilities: IPluginManifestCapability[];
54
+ /** CSP rules the installer must add (only for `trustLevel !== 'untrusted'`). */
55
+ cspRules?: {
56
+ /** Maps a CSP directive to extra sources. */
57
+ [directive: string]: string[];
58
+ };
59
+ /** External hosts the plugin will load assets/data from. */
60
+ externalHosts?: IPluginManifestExternalHost[];
61
+ /** Path to file containing checksum/signature, optional. */
62
+ signaturePath?: string;
63
+ }
64
+ interface IPluginManifestDataAccess {
65
+ /**
66
+ * Dedicated tables the plugin owns (created by its migrations). Must be
67
+ * `lowercase_snake_case` (schema pattern `^[a-z][a-z0-9_]*$`).
68
+ */
69
+ ownedTables?: string[];
70
+ /**
71
+ * Prefix for CMS `data_tables` rows the plugin creates at runtime. Must be
72
+ * `lowercase_snake_case` ending in `_` (schema pattern `^[a-z][a-z0-9_]*_$`).
73
+ */
74
+ ownedDataTablePrefix?: string;
75
+ /**
76
+ * Tables the plugin reads. May be `dataTable:*` for any plugin-owned
77
+ * data table, `lookup:<typeCode>` for lookup reads, `dataTable:my`
78
+ * for tables created by this plugin.
79
+ */
80
+ read?: string[];
81
+ /** Tables the plugin writes. */
82
+ write?: string[];
83
+ /** Tables the plugin deletes (rare; requires capability). */
84
+ delete?: string[];
85
+ }
86
+ interface IPluginManifestRealtimeTopic {
87
+ /** Topic key, scoped to this plugin. Example: `survey-response`. */
88
+ key: string;
89
+ /** Human description shown in admin UI. */
90
+ description: string;
91
+ /** Permission required to subscribe; resolved via `PluginRealtimePermissionResolver`. */
92
+ requiredPermission?: string;
93
+ /** JSON Schema path of the topic payload. */
94
+ payloadSchemaPath?: string;
95
+ }
96
+ interface IPluginManifestFeatureFlag {
97
+ key: string;
98
+ description: string;
99
+ /** Default state when no `plugin_feature_flags` row exists. */
100
+ defaultEnabled: boolean;
101
+ /** Optional capability gate; flag cannot be turned on without it. */
102
+ capability?: IPluginManifestCapability;
103
+ }
104
+ interface IPluginManifestLookupExtension {
105
+ /** Lookup type code, e.g. `survey_question_type`. */
106
+ typeCode: string;
107
+ /** Whether the plugin OWNS the type code or only extends it. */
108
+ ownership: 'plugin_extendable' | 'plugin_owned';
109
+ entries: {
110
+ code: string;
111
+ value: string;
112
+ description?: string;
113
+ }[];
114
+ }
115
+ interface IPluginManifestPermission {
116
+ /** Permission key, namespaced like `surveyjs.surveys.manage`. */
117
+ key: string;
118
+ description: string;
119
+ /** Optional default role keys the permission is granted to. */
120
+ defaultRoles?: string[];
121
+ }
122
+ interface IPluginManifestStyle {
123
+ /** Style name (used as `style_name` discriminator). */
124
+ name: string;
125
+ description: string;
126
+ canHaveChildren: boolean;
127
+ /** Optional capability requirement (e.g. `frontendStyles`). */
128
+ capability?: IPluginManifestCapability;
129
+ }
130
+ interface IPluginManifestAdminPage {
131
+ /** Slug under `/admin/plugins-host/{pluginId}/`. */
132
+ slug: string;
133
+ /** Menu label. */
134
+ label: string;
135
+ /** Required permission key. */
136
+ permission: string;
137
+ /** Optional menu icon (Tabler icon name). */
138
+ icon?: string;
139
+ }
140
+ interface IPluginManifestApiRoute {
141
+ /** Symfony route name (must be namespaced with the plugin id). */
142
+ name: string;
143
+ /** HTTP path under `/cms-api/v1/plugins/{pluginId}/...`. */
144
+ path: string;
145
+ methods: ('GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE')[];
146
+ /** Permission key required. */
147
+ permission?: string;
148
+ }
149
+ interface IPluginManifestScheduledJob {
150
+ /** Job type key. */
151
+ type: string;
152
+ description: string;
153
+ /** Capability gate (always requires `scheduledJobs`). */
154
+ capability: 'scheduledJobs';
155
+ }
156
+ interface IPluginManifestAsset {
157
+ /** Source path within the plugin package. */
158
+ src: string;
159
+ /** Destination path under `/assets/plugins/{pluginId}/...`. */
160
+ dest: string;
161
+ /** Asset type. */
162
+ type: 'script' | 'style' | 'font' | 'image' | 'other';
163
+ }
164
+ interface IPluginManifestHealth {
165
+ /** Optional health-check endpoint name. */
166
+ endpoint?: string;
167
+ /** Health-check service id (resolved through Symfony). */
168
+ serviceId?: string;
169
+ }
170
+ interface IPluginManifestMobile {
171
+ /** npm package name of the mobile component bundle. */
172
+ package: string;
173
+ /** Required SemVer range. */
174
+ version: string;
175
+ /** Whether the mobile package only renders payloads (readonly). */
176
+ readonly: boolean;
177
+ }
178
+ /**
179
+ * Full `plugin.json` shape.
180
+ */
181
+ interface IPluginManifest {
182
+ /** Plugin identifier, e.g. `sh2-shp-survey-js`. */
183
+ id: string;
184
+ /** Human-readable display name. */
185
+ name: string;
186
+ /** Short description. */
187
+ description?: string;
188
+ /** Plugin SemVer version. */
189
+ version: string;
190
+ /** Author / vendor. */
191
+ author?: {
192
+ name: string;
193
+ email?: string;
194
+ url?: string;
195
+ };
196
+ /** SPDX license id. */
197
+ license?: string;
198
+ /** Plugin homepage / repo URL. */
199
+ homepage?: string;
200
+ /** SDK contract version the plugin targets (e.g. `1.0`). */
201
+ pluginApiVersion: string;
202
+ /** Compatibility with the host stack. */
203
+ compatibility: IPluginManifestCompatibility;
204
+ /** Required + optional plugin dependencies. */
205
+ dependencies?: IPluginManifestDependency[];
206
+ /** Plugin conflicts. */
207
+ conflicts?: IPluginManifestConflict[];
208
+ /** Composer package (only for `trustLevel !== 'untrusted'`). */
209
+ backend?: {
210
+ package: string;
211
+ bundleClass: string;
212
+ migrationsNamespace?: string;
213
+ };
214
+ /** npm package for frontend. */
215
+ frontend?: {
216
+ package: string;
217
+ version: string;
218
+ };
219
+ /** Optional mobile package. */
220
+ mobile?: IPluginManifestMobile;
221
+ /** Required security declarations. */
222
+ security: IPluginManifestSecurity;
223
+ /** Permissions the plugin contributes. */
224
+ permissions?: IPluginManifestPermission[];
225
+ /** Manifest-declared data access. */
226
+ dataAccess?: IPluginManifestDataAccess;
227
+ /** Realtime topics. */
228
+ realtimeTopics?: IPluginManifestRealtimeTopic[];
229
+ /** Feature flags. */
230
+ featureFlags?: IPluginManifestFeatureFlag[];
231
+ /** Lookup contributions. */
232
+ lookups?: {
233
+ extends?: IPluginManifestLookupExtension[];
234
+ };
235
+ /** Styles contributed to the registry. */
236
+ styles?: IPluginManifestStyle[];
237
+ /** Admin pages mounted under `/admin/plugins-host/{pluginId}/`. */
238
+ adminPages?: IPluginManifestAdminPage[];
239
+ /** Plugin-owned API routes. */
240
+ apiRoutes?: IPluginManifestApiRoute[];
241
+ /** Scheduled jobs. */
242
+ scheduledJobs?: IPluginManifestScheduledJob[];
243
+ /** Vendored assets. */
244
+ assets?: IPluginManifestAsset[];
245
+ /** Health-check declaration. */
246
+ health?: IPluginManifestHealth;
247
+ /** Optional metadata / labels. */
248
+ labels?: Record<string, string>;
249
+ }
250
+
251
+ export type { IPluginManifest as I, IPluginManifestAdminPage as a, IPluginManifestApiRoute as b, IPluginManifestAsset as c, IPluginManifestCapability as d, IPluginManifestCompatibility as e, IPluginManifestConflict as f, IPluginManifestDataAccess as g, IPluginManifestDependency as h, IPluginManifestExternalHost as i, IPluginManifestFeatureFlag as j, IPluginManifestHealth as k, IPluginManifestLookupExtension as l, IPluginManifestMobile as m, IPluginManifestPermission as n, IPluginManifestRealtimeTopic as o, IPluginManifestScheduledJob as p, IPluginManifestSecurity as q, IPluginManifestStyle as r, IPluginManifestTrustLevel as s };