@selfhelp/shared 1.3.2 → 1.4.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 +47 -0
- package/dist/index.d.mts +649 -1
- package/dist/index.d.ts +649 -1
- package/dist/index.js +19 -0
- package/dist/index.mjs +17 -0
- package/dist/plugin-sdk/index.d.mts +118 -101
- package/dist/plugin-sdk/index.d.ts +118 -101
- package/dist/plugin-sdk/index.js +6 -1
- package/dist/plugin-sdk/index.mjs +5 -1
- package/package.json +2 -2
- package/src/plugin-sdk/index.ts +4 -2
- package/src/plugin-sdk/registry.ts +115 -79
- package/src/plugin-sdk/version.ts +1 -1
- package/src/types/__tests__/channel-parity.test.ts +74 -0
- package/src/types/__tests__/distribution.test.ts +168 -0
- package/src/types/api/__tests__/compatibility-error-parity.test.ts +107 -0
- package/src/types/api/__tests__/system.test.ts +287 -0
- package/src/types/api/index.ts +1 -0
- package/src/types/api/system.ts +293 -0
- package/src/types/distribution.ts +446 -0
- package/src/types/index.ts +1 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, it } from 'vitest';
|
|
7
|
+
import { SYSTEM_ENDPOINTS } from '../system';
|
|
8
|
+
import type {
|
|
9
|
+
IMaintenanceSetRequest,
|
|
10
|
+
ISystemAdvisories,
|
|
11
|
+
ISystemAdvisoriesResponse,
|
|
12
|
+
ISystemAdvisory,
|
|
13
|
+
ISystemHealth,
|
|
14
|
+
ISystemMaintenance,
|
|
15
|
+
ISystemVersion,
|
|
16
|
+
IUpdatePreflight,
|
|
17
|
+
IUpdateRequest,
|
|
18
|
+
IUpdateRequestResponse,
|
|
19
|
+
IUpdateStatus,
|
|
20
|
+
IUpdateStatusResponse,
|
|
21
|
+
TSystemAdvisorySeverity,
|
|
22
|
+
TUpdateOperationStatus,
|
|
23
|
+
} from '../system';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Contract coverage for the instance-scoped system maintenance / update flow
|
|
27
|
+
* (SelfHelp Manager <-> CMS <-> admin UI). The hard cross-repo invariant under
|
|
28
|
+
* test: an update request carries NO `instance_id` — the backend derives and
|
|
29
|
+
* verifies the instance identity server-side, so the browser can never target a
|
|
30
|
+
* different instance.
|
|
31
|
+
*/
|
|
32
|
+
describe('system maintenance contracts', () => {
|
|
33
|
+
it('exposes admin system endpoints under /cms-api/v1/admin/system', () => {
|
|
34
|
+
expect(SYSTEM_ENDPOINTS.VERSION).toBe('/cms-api/v1/admin/system/version');
|
|
35
|
+
expect(SYSTEM_ENDPOINTS.HEALTH).toBe('/cms-api/v1/admin/system/health');
|
|
36
|
+
expect(SYSTEM_ENDPOINTS.ADVISORIES).toBe('/cms-api/v1/admin/system/advisories');
|
|
37
|
+
expect(SYSTEM_ENDPOINTS.MAINTENANCE).toBe('/cms-api/v1/admin/system/maintenance');
|
|
38
|
+
expect(SYSTEM_ENDPOINTS.UPDATE_PREFLIGHT).toBe('/cms-api/v1/admin/system/update/preflight');
|
|
39
|
+
expect(SYSTEM_ENDPOINTS.UPDATE_REQUEST).toBe('/cms-api/v1/admin/system/update/request');
|
|
40
|
+
expect(SYSTEM_ENDPOINTS.UPDATE_STATUS).toBe('/cms-api/v1/admin/system/update/status');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('advisories model the registry feed filtered to installed components', () => {
|
|
44
|
+
const offline: ISystemAdvisories = { available: false, advisories: [] };
|
|
45
|
+
expect(offline.available).toBe(false);
|
|
46
|
+
|
|
47
|
+
const advisories: ISystemAdvisories = {
|
|
48
|
+
available: true,
|
|
49
|
+
advisories: [
|
|
50
|
+
{
|
|
51
|
+
id: 'SHSA-2026-0001',
|
|
52
|
+
severity: 'high',
|
|
53
|
+
recommended_action: 'Update SelfHelp core.',
|
|
54
|
+
blocked: true,
|
|
55
|
+
details_url: 'https://example.test/advisory',
|
|
56
|
+
affected: [{ kind: 'core', id: 'selfhelp-core', installed_version: '0.1.0' }],
|
|
57
|
+
fixed_versions: ['0.1.1'],
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
expect(advisories.advisories[0]?.severity).toBe('high');
|
|
62
|
+
expect(advisories.advisories[0]?.affected[0]?.kind).toBe('core');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('advisory severity covers the full registry feed union', () => {
|
|
66
|
+
const severities: TSystemAdvisorySeverity[] = ['low', 'medium', 'high', 'critical'];
|
|
67
|
+
expect(severities).toHaveLength(4);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('an advisory with no details page models details_url as null and may be non-blocking', () => {
|
|
71
|
+
// A low-severity, multi-component, non-blocking advisory with no details
|
|
72
|
+
// page — the variant the existing happy-path test does not exercise.
|
|
73
|
+
const advisory: ISystemAdvisory = {
|
|
74
|
+
id: 'SHSA-2026-0002',
|
|
75
|
+
severity: 'low',
|
|
76
|
+
recommended_action: 'Upgrade the affected plugin at your convenience.',
|
|
77
|
+
blocked: false,
|
|
78
|
+
details_url: null,
|
|
79
|
+
affected: [
|
|
80
|
+
{ kind: 'frontend', id: 'selfhelp-frontend', installed_version: '0.1.0' },
|
|
81
|
+
{ kind: 'plugin', id: 'sh2-shp-survey-js', installed_version: '0.2.20' },
|
|
82
|
+
],
|
|
83
|
+
fixed_versions: [],
|
|
84
|
+
};
|
|
85
|
+
expect(advisory.details_url).toBeNull();
|
|
86
|
+
expect(advisory.blocked).toBe(false);
|
|
87
|
+
expect(advisory.affected.map((a) => a.kind)).toEqual(['frontend', 'plugin']);
|
|
88
|
+
expect(advisory.fixed_versions).toEqual([]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('models the aggregated, secret-free health payload consumed by the admin dashboard', () => {
|
|
92
|
+
const health: ISystemHealth = {
|
|
93
|
+
instance_id: 'inst-a',
|
|
94
|
+
overall: 'degraded',
|
|
95
|
+
checked_at: '2026-06-08T00:00:00Z',
|
|
96
|
+
safe_mode: false,
|
|
97
|
+
maintenance_mode: true,
|
|
98
|
+
version: {
|
|
99
|
+
selfhelp: '0.1.0',
|
|
100
|
+
backend: '0.1.0',
|
|
101
|
+
frontend: '0.1.0',
|
|
102
|
+
plugin_api: '0.1.0',
|
|
103
|
+
database_migration: 'Version20260608174905',
|
|
104
|
+
},
|
|
105
|
+
update: { operation_id: 'op-001', status: 'running', progress_percent: 42 },
|
|
106
|
+
components: [
|
|
107
|
+
{ name: 'database', status: 'ok', detail: 'reachable' },
|
|
108
|
+
{ name: 'mercure', status: 'not_configured', detail: 'no hub configured' },
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
expect(health.overall).toBe('degraded');
|
|
112
|
+
expect(health.update.progress_percent).toBe(42);
|
|
113
|
+
// Health is secret-free: connection strings are reduced to a status word.
|
|
114
|
+
expect(JSON.stringify(health)).not.toContain('mysql://');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('maintenance state models the env-forced + safe-mode flags and carries no secret', () => {
|
|
118
|
+
const state: ISystemMaintenance = {
|
|
119
|
+
enabled: true,
|
|
120
|
+
forced_by_env: false,
|
|
121
|
+
message: 'Upgrade window',
|
|
122
|
+
since: '2026-06-08T18:00:00Z',
|
|
123
|
+
updated_by: 'user:42',
|
|
124
|
+
safe_mode: false,
|
|
125
|
+
};
|
|
126
|
+
expect(state.enabled).toBe(true);
|
|
127
|
+
expect(state.forced_by_env).toBe(false);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('maintenance set request never includes an instance_id (server-derived only)', () => {
|
|
131
|
+
const req: IMaintenanceSetRequest = { enabled: true, message: 'window' };
|
|
132
|
+
expect(Object.keys(req)).not.toContain('instance_id');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('update request DTO never includes an instance_id (server-derived only)', () => {
|
|
136
|
+
const req: IUpdateRequest = {
|
|
137
|
+
target_version: '1.5.0',
|
|
138
|
+
preflight_id: 'pf-001',
|
|
139
|
+
accepted_migration_risk: false,
|
|
140
|
+
};
|
|
141
|
+
expect(Object.keys(req)).not.toContain('instance_id');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('models the version, preflight and status shapes consumed by the admin UI', () => {
|
|
145
|
+
const version: ISystemVersion = {
|
|
146
|
+
instance_id: 'inst-a',
|
|
147
|
+
selfhelp_version: '1.4.0',
|
|
148
|
+
backend_version: '1.4.0',
|
|
149
|
+
frontend_version: '1.4.0',
|
|
150
|
+
plugin_api_version: '2.1',
|
|
151
|
+
database_migration_version: 'Version20260605081254',
|
|
152
|
+
safe_mode: false,
|
|
153
|
+
maintenance_mode: false,
|
|
154
|
+
installed_plugins: [{ id: 'sh2-shp-survey-js', version: '0.2.20', compatible: true }],
|
|
155
|
+
};
|
|
156
|
+
const preflight: IUpdatePreflight = {
|
|
157
|
+
preflight_id: 'pf-001',
|
|
158
|
+
status: 'ok',
|
|
159
|
+
instance_id: 'inst-a',
|
|
160
|
+
current_version: '1.4.0',
|
|
161
|
+
target_version: '1.5.0',
|
|
162
|
+
checks: [{ code: 'disk', severity: 'info', message: 'ok' }],
|
|
163
|
+
options: [{ type: 'frontend', version: '1.5.0', label: 'Frontend 1.5.0' }],
|
|
164
|
+
database: { destructive: false, requires_backup: true, manual_confirmation_required: false },
|
|
165
|
+
rollback: { automatic_before_migrations: true, automatic_after_destructive_migrations: false },
|
|
166
|
+
};
|
|
167
|
+
const status: IUpdateStatus = {
|
|
168
|
+
instance_id: 'inst-a',
|
|
169
|
+
operation_id: 'op-001',
|
|
170
|
+
status: 'running',
|
|
171
|
+
target_version: '1.5.0',
|
|
172
|
+
progress_percent: 42,
|
|
173
|
+
steps: [{ name: 'backup', status: 'succeeded' }],
|
|
174
|
+
requested_at: '2026-06-08T00:00:00Z',
|
|
175
|
+
updated_at: '2026-06-08T00:01:00Z',
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
expect(version.installed_plugins[0]?.compatible).toBe(true);
|
|
179
|
+
expect(preflight.status).toBe('ok');
|
|
180
|
+
expect(status.progress_percent).toBe(42);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('carries the standardized compatibility-error fields on a blocked preflight check', () => {
|
|
184
|
+
// A plugin_compatibility check raised by the core-update preflight when an
|
|
185
|
+
// installed (pinned) plugin does not admit the target core version. This is
|
|
186
|
+
// the SAME standardized compatibility-error shape the plugin install/update
|
|
187
|
+
// flow emits (backend CompatibilityError::toArray()), so the admin/operator
|
|
188
|
+
// sees the blocking component + the required range, not just a message.
|
|
189
|
+
const blocked: IUpdatePreflight = {
|
|
190
|
+
preflight_id: 'pf-002',
|
|
191
|
+
status: 'blocked',
|
|
192
|
+
instance_id: 'inst-a',
|
|
193
|
+
current_version: '0.1.0',
|
|
194
|
+
target_version: '0.2.0',
|
|
195
|
+
checks: [
|
|
196
|
+
{
|
|
197
|
+
code: 'plugin_compatibility',
|
|
198
|
+
severity: 'error',
|
|
199
|
+
message:
|
|
200
|
+
'Plugin sh2-shp-survey-js requires SelfHelp >=0.1.0 <0.2.0 and is not compatible with target version 0.2.0 (current 0.1.0).',
|
|
201
|
+
component: 'plugin',
|
|
202
|
+
component_id: 'sh2-shp-survey-js',
|
|
203
|
+
current_version: '0.1.0',
|
|
204
|
+
target_version: '0.2.0',
|
|
205
|
+
required_range: '>=0.1.0 <0.2.0',
|
|
206
|
+
blocking: true,
|
|
207
|
+
pinned: true,
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
options: [],
|
|
211
|
+
database: { destructive: false, requires_backup: true, manual_confirmation_required: false },
|
|
212
|
+
rollback: { automatic_before_migrations: true, automatic_after_destructive_migrations: false },
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const check = blocked.checks[0]!;
|
|
216
|
+
expect(blocked.status).toBe('blocked');
|
|
217
|
+
expect(check.component).toBe('plugin');
|
|
218
|
+
expect(check.component_id).toBe('sh2-shp-survey-js');
|
|
219
|
+
expect(check.required_range).toBe('>=0.1.0 <0.2.0');
|
|
220
|
+
expect(check.current_version).toBe('0.1.0');
|
|
221
|
+
expect(check.target_version).toBe('0.2.0');
|
|
222
|
+
expect(check.blocking).toBe(true);
|
|
223
|
+
expect(check.pinned).toBe(true);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('covers the manager-driven terminal lifecycle states', () => {
|
|
227
|
+
// The states the SelfHelp Manager writes back as an operation finishes.
|
|
228
|
+
const terminal: TUpdateOperationStatus[] = ['succeeded', 'failed', 'rolled_back', 'rollback_failed', 'rejected'];
|
|
229
|
+
for (const s of terminal) {
|
|
230
|
+
const status: IUpdateStatus = {
|
|
231
|
+
instance_id: 'inst-a',
|
|
232
|
+
operation_id: 'op-term',
|
|
233
|
+
status: s,
|
|
234
|
+
target_version: '8.0.1',
|
|
235
|
+
progress_percent: 100,
|
|
236
|
+
steps: [],
|
|
237
|
+
requested_at: '2026-06-08T00:00:00Z',
|
|
238
|
+
updated_at: '2026-06-08T00:05:00Z',
|
|
239
|
+
};
|
|
240
|
+
expect(status.status).toBe(s);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('wraps system payloads in the standard backend envelope', () => {
|
|
245
|
+
// The admin UI consumes the envelope-wrapped responses; assert the
|
|
246
|
+
// generic IBaseApiResponse<T> wrappers compose with the system data
|
|
247
|
+
// types (status/error/logged_in/meta/data).
|
|
248
|
+
const advisories: ISystemAdvisoriesResponse = {
|
|
249
|
+
status: 200,
|
|
250
|
+
message: 'OK',
|
|
251
|
+
error: null,
|
|
252
|
+
logged_in: true,
|
|
253
|
+
meta: { version: 'v1', timestamp: '2026-06-08T00:00:00Z' },
|
|
254
|
+
data: { available: true, advisories: [] },
|
|
255
|
+
};
|
|
256
|
+
const requested: IUpdateRequestResponse = {
|
|
257
|
+
status: 202,
|
|
258
|
+
message: 'Accepted',
|
|
259
|
+
error: null,
|
|
260
|
+
logged_in: true,
|
|
261
|
+
meta: { version: 'v1', timestamp: '2026-06-08T00:00:00Z' },
|
|
262
|
+
data: { operation_id: 'op-001', instance_id: 'inst-a', status: 'requested' },
|
|
263
|
+
};
|
|
264
|
+
const statusResponse: IUpdateStatusResponse = {
|
|
265
|
+
status: 200,
|
|
266
|
+
message: 'OK',
|
|
267
|
+
error: null,
|
|
268
|
+
logged_in: true,
|
|
269
|
+
meta: { version: 'v1', timestamp: '2026-06-08T00:00:00Z' },
|
|
270
|
+
data: {
|
|
271
|
+
instance_id: 'inst-a',
|
|
272
|
+
operation_id: 'op-001',
|
|
273
|
+
status: 'succeeded',
|
|
274
|
+
target_version: '8.0.1',
|
|
275
|
+
progress_percent: 100,
|
|
276
|
+
steps: [{ name: 'migrate', status: 'succeeded' }],
|
|
277
|
+
requested_at: '2026-06-08T00:00:00Z',
|
|
278
|
+
updated_at: '2026-06-08T00:05:00Z',
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
expect(advisories.data.available).toBe(true);
|
|
283
|
+
expect(requested.data.status).toBe('requested');
|
|
284
|
+
expect(requested.status).toBe(202);
|
|
285
|
+
expect(statusResponse.data.status).toBe('succeeded');
|
|
286
|
+
});
|
|
287
|
+
});
|
package/src/types/api/index.ts
CHANGED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System maintenance / update contracts (SelfHelp Manager <-> CMS <-> admin UI).
|
|
7
|
+
*
|
|
8
|
+
* Hard rule: the CMS admin update flow is scoped to the CURRENT instance only.
|
|
9
|
+
* The browser MUST NOT send an arbitrary `instance_id` for update execution; the
|
|
10
|
+
* backend derives and verifies the instance identity server-side. That is why
|
|
11
|
+
* {@link IUpdateRequest} intentionally has no `instance_id` field.
|
|
12
|
+
*
|
|
13
|
+
* These mirror the manager's `@shm/schemas` shapes and the backend JSON schemas
|
|
14
|
+
* under `config/schemas/api/v1/{responses,requests}/admin/`.
|
|
15
|
+
*/
|
|
16
|
+
import type { IBaseApiResponse } from './envelope';
|
|
17
|
+
|
|
18
|
+
const SYSTEM_PREFIX = '/cms-api/v1/admin/system';
|
|
19
|
+
|
|
20
|
+
/** Admin system maintenance endpoints (web admin; not part of the mobile subset). */
|
|
21
|
+
export const SYSTEM_ENDPOINTS = {
|
|
22
|
+
VERSION: `${SYSTEM_PREFIX}/version`,
|
|
23
|
+
HEALTH: `${SYSTEM_PREFIX}/health`,
|
|
24
|
+
ADVISORIES: `${SYSTEM_PREFIX}/advisories`,
|
|
25
|
+
MAINTENANCE: `${SYSTEM_PREFIX}/maintenance`,
|
|
26
|
+
UPDATE_PREFLIGHT: `${SYSTEM_PREFIX}/update/preflight`,
|
|
27
|
+
UPDATE_REQUEST: `${SYSTEM_PREFIX}/update/request`,
|
|
28
|
+
UPDATE_STATUS: `${SYSTEM_PREFIX}/update/status`,
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
export interface ISystemInstalledPlugin {
|
|
32
|
+
id: string;
|
|
33
|
+
version: string;
|
|
34
|
+
compatible: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** GET /admin/system/version — current instance version summary. */
|
|
38
|
+
export interface ISystemVersion {
|
|
39
|
+
instance_id: string;
|
|
40
|
+
selfhelp_version: string;
|
|
41
|
+
backend_version: string;
|
|
42
|
+
frontend_version: string;
|
|
43
|
+
plugin_api_version: string;
|
|
44
|
+
database_migration_version: string;
|
|
45
|
+
safe_mode: boolean;
|
|
46
|
+
maintenance_mode: boolean;
|
|
47
|
+
installed_plugins: ISystemInstalledPlugin[];
|
|
48
|
+
}
|
|
49
|
+
export type ISystemVersionResponse = IBaseApiResponse<ISystemVersion>;
|
|
50
|
+
|
|
51
|
+
/** Overall verdict for the aggregated system health endpoint. */
|
|
52
|
+
export type TSystemHealthOverall = 'healthy' | 'degraded' | 'down';
|
|
53
|
+
|
|
54
|
+
/** Per-subsystem health status. `not_configured`/`unknown` are informational. */
|
|
55
|
+
export type TSystemComponentStatus =
|
|
56
|
+
| 'ok'
|
|
57
|
+
| 'down'
|
|
58
|
+
| 'degraded'
|
|
59
|
+
| 'configured'
|
|
60
|
+
| 'not_configured'
|
|
61
|
+
| 'unknown';
|
|
62
|
+
|
|
63
|
+
export interface ISystemHealthComponent {
|
|
64
|
+
name: string;
|
|
65
|
+
status: TSystemComponentStatus;
|
|
66
|
+
detail: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* GET /admin/system/health — aggregated, instance-scoped health/status.
|
|
71
|
+
* Never contains secrets: connection strings are reduced to configured/not.
|
|
72
|
+
*/
|
|
73
|
+
export interface ISystemHealth {
|
|
74
|
+
instance_id: string;
|
|
75
|
+
overall: TSystemHealthOverall;
|
|
76
|
+
checked_at: string;
|
|
77
|
+
safe_mode: boolean;
|
|
78
|
+
maintenance_mode: boolean;
|
|
79
|
+
version: {
|
|
80
|
+
selfhelp: string;
|
|
81
|
+
backend: string;
|
|
82
|
+
frontend: string;
|
|
83
|
+
plugin_api: string;
|
|
84
|
+
database_migration: string;
|
|
85
|
+
};
|
|
86
|
+
update: {
|
|
87
|
+
operation_id: string;
|
|
88
|
+
status: string;
|
|
89
|
+
progress_percent: number;
|
|
90
|
+
};
|
|
91
|
+
components: ISystemHealthComponent[];
|
|
92
|
+
}
|
|
93
|
+
export type ISystemHealthResponse = IBaseApiResponse<ISystemHealth>;
|
|
94
|
+
|
|
95
|
+
/** Advisory severity, matching the registry advisory feed. */
|
|
96
|
+
export type TSystemAdvisorySeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
97
|
+
|
|
98
|
+
/** An installed component (core/frontend/plugin) an advisory affects. */
|
|
99
|
+
export interface ISystemAdvisoryAffected {
|
|
100
|
+
kind: 'core' | 'frontend' | 'plugin';
|
|
101
|
+
id: string;
|
|
102
|
+
installed_version: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface ISystemAdvisory {
|
|
106
|
+
id: string;
|
|
107
|
+
severity: TSystemAdvisorySeverity;
|
|
108
|
+
recommended_action: string;
|
|
109
|
+
/** Whether the manager blocks updates while an affected version is installed. */
|
|
110
|
+
blocked: boolean;
|
|
111
|
+
details_url: string | null;
|
|
112
|
+
affected: ISystemAdvisoryAffected[];
|
|
113
|
+
fixed_versions: string[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* GET /admin/system/advisories — security advisories from the registry feed,
|
|
118
|
+
* filtered to the components installed on THIS instance. `available: false`
|
|
119
|
+
* means the registry could not be reached (the UI shows "could not check").
|
|
120
|
+
*/
|
|
121
|
+
export interface ISystemAdvisories {
|
|
122
|
+
available: boolean;
|
|
123
|
+
advisories: ISystemAdvisory[];
|
|
124
|
+
}
|
|
125
|
+
export type ISystemAdvisoriesResponse = IBaseApiResponse<ISystemAdvisories>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* GET /admin/system/maintenance — current maintenance-mode state for THIS
|
|
129
|
+
* instance. `forced_by_env` means the env hard switch
|
|
130
|
+
* (SELFHELP_MAINTENANCE_MODE) is on and the CMS cannot disable it. Never
|
|
131
|
+
* contains secrets — only an operator note + the acting user id.
|
|
132
|
+
*/
|
|
133
|
+
export interface ISystemMaintenance {
|
|
134
|
+
enabled: boolean;
|
|
135
|
+
forced_by_env: boolean;
|
|
136
|
+
message: string;
|
|
137
|
+
since: string;
|
|
138
|
+
updated_by: string;
|
|
139
|
+
safe_mode: boolean;
|
|
140
|
+
}
|
|
141
|
+
export type ISystemMaintenanceResponse = IBaseApiResponse<ISystemMaintenance>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* PUT /admin/system/maintenance — enable/disable maintenance for THIS instance.
|
|
145
|
+
* No `instance_id`: the backend derives + verifies it server-side.
|
|
146
|
+
*/
|
|
147
|
+
export interface IMaintenanceSetRequest {
|
|
148
|
+
enabled: boolean;
|
|
149
|
+
message?: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export type TUpdatePreflightStatus = 'ok' | 'warning' | 'blocked';
|
|
153
|
+
export type TUpdateCheckSeverity = 'info' | 'warning' | 'error';
|
|
154
|
+
|
|
155
|
+
export interface IUpdatePreflightCheck {
|
|
156
|
+
code: string;
|
|
157
|
+
severity: TUpdateCheckSeverity;
|
|
158
|
+
message: string;
|
|
159
|
+
/**
|
|
160
|
+
* Standardized compatibility-error fields. Version/compatibility checks
|
|
161
|
+
* (e.g. `plugin_compatibility`) populate these so the admin/operator sees
|
|
162
|
+
* exactly which component blocks which target and the range it requires.
|
|
163
|
+
* Absent on non-compatibility checks.
|
|
164
|
+
*/
|
|
165
|
+
component?: string;
|
|
166
|
+
component_id?: string;
|
|
167
|
+
current_version?: string;
|
|
168
|
+
target_version?: string;
|
|
169
|
+
required_range?: string;
|
|
170
|
+
/** Whether this compatibility error blocks the update (mirrors `CompatibilityError.blocking`). */
|
|
171
|
+
blocking?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* For `plugin_compatibility` checks: whether the blocking plugin is pinned and
|
|
174
|
+
* therefore must be unpinned (or removed) before it can be updated to a
|
|
175
|
+
* compatible version. Absent on non-plugin checks.
|
|
176
|
+
*/
|
|
177
|
+
pinned?: boolean;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The single, standardized compatibility-error object used by BOTH the core
|
|
182
|
+
* update preflight AND the plugin install/update flow, so an operator sees the
|
|
183
|
+
* SAME shape regardless of which installer raised it.
|
|
184
|
+
*
|
|
185
|
+
* Canonical cross-repo contract (the field set MUST match on every side):
|
|
186
|
+
* - backend `App\Plugin\Registry\Unified\CompatibilityError::toArray()`,
|
|
187
|
+
* - SelfHelp Manager `@shm/resolver` `CompatibilityError`,
|
|
188
|
+
* - frontend `IPluginCompatibilityError`.
|
|
189
|
+
*
|
|
190
|
+
* The compatibility fields embedded in {@link IUpdatePreflightCheck} mirror this
|
|
191
|
+
* shape (a preflight check additionally carries the generic `code`/`severity`
|
|
192
|
+
* and the plugin-specific `pinned` affordance). Snake_case is the wire contract.
|
|
193
|
+
*/
|
|
194
|
+
export interface ICompatibilityError {
|
|
195
|
+
component: 'core' | 'frontend' | 'plugin';
|
|
196
|
+
component_id: string;
|
|
197
|
+
current_version: string | null;
|
|
198
|
+
target_version: string | null;
|
|
199
|
+
required_range: string;
|
|
200
|
+
blocking: boolean;
|
|
201
|
+
message: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface IUpdatePreflightOption {
|
|
205
|
+
type: string;
|
|
206
|
+
version?: string;
|
|
207
|
+
label: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** GET /admin/system/update/preflight — latest preflight for THIS instance. */
|
|
211
|
+
export interface IUpdatePreflight {
|
|
212
|
+
preflight_id: string;
|
|
213
|
+
status: TUpdatePreflightStatus;
|
|
214
|
+
instance_id: string;
|
|
215
|
+
current_version: string;
|
|
216
|
+
target_version: string;
|
|
217
|
+
checks: IUpdatePreflightCheck[];
|
|
218
|
+
options: IUpdatePreflightOption[];
|
|
219
|
+
database: {
|
|
220
|
+
destructive: boolean;
|
|
221
|
+
requires_backup: boolean;
|
|
222
|
+
manual_confirmation_required: boolean;
|
|
223
|
+
};
|
|
224
|
+
rollback: {
|
|
225
|
+
automatic_before_migrations: boolean;
|
|
226
|
+
automatic_after_destructive_migrations: boolean;
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
export type IUpdatePreflightResponse = IBaseApiResponse<IUpdatePreflight>;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* POST /admin/system/update/request — request an update for THIS instance.
|
|
233
|
+
* No `instance_id`: the backend derives + verifies it. A destructive migration
|
|
234
|
+
* requires `accepted_migration_risk: true` (and the typed confirmation).
|
|
235
|
+
*/
|
|
236
|
+
export interface IUpdateRequest {
|
|
237
|
+
target_version: string;
|
|
238
|
+
preflight_id: string;
|
|
239
|
+
accepted_migration_risk: boolean;
|
|
240
|
+
typed_confirmation?: string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Update operation lifecycle. `idle` is the synthetic state for an instance that
|
|
245
|
+
* has never run an update (no operation row) — the backend returns it instead of
|
|
246
|
+
* a misleading `succeeded`/100%. The CMS records `requested`; the SelfHelp
|
|
247
|
+
* Manager writes the granular execution states back through the manager loop.
|
|
248
|
+
* `approved` and `running` are kept as coarse legacy states for compatibility.
|
|
249
|
+
*/
|
|
250
|
+
export type TUpdateOperationStatus =
|
|
251
|
+
| 'idle'
|
|
252
|
+
| 'requested'
|
|
253
|
+
| 'approved'
|
|
254
|
+
| 'accepted'
|
|
255
|
+
| 'running'
|
|
256
|
+
| 'preflight_running'
|
|
257
|
+
| 'preflight_failed'
|
|
258
|
+
| 'backup_running'
|
|
259
|
+
| 'update_running'
|
|
260
|
+
| 'migration_running'
|
|
261
|
+
| 'health_check_running'
|
|
262
|
+
| 'succeeded'
|
|
263
|
+
| 'failed'
|
|
264
|
+
| 'rollback_running'
|
|
265
|
+
| 'rolled_back'
|
|
266
|
+
| 'rollback_failed'
|
|
267
|
+
| 'rejected';
|
|
268
|
+
|
|
269
|
+
export interface IUpdateStep {
|
|
270
|
+
name: string;
|
|
271
|
+
status: string;
|
|
272
|
+
detail?: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** GET /admin/system/update/status — status/progress for THIS instance. */
|
|
276
|
+
export interface IUpdateStatus {
|
|
277
|
+
instance_id: string;
|
|
278
|
+
operation_id: string;
|
|
279
|
+
status: TUpdateOperationStatus;
|
|
280
|
+
target_version: string;
|
|
281
|
+
progress_percent: number;
|
|
282
|
+
steps: IUpdateStep[];
|
|
283
|
+
requested_at: string;
|
|
284
|
+
updated_at: string;
|
|
285
|
+
message?: string;
|
|
286
|
+
}
|
|
287
|
+
export type IUpdateStatusResponse = IBaseApiResponse<IUpdateStatus>;
|
|
288
|
+
|
|
289
|
+
export type IUpdateRequestResponse = IBaseApiResponse<{
|
|
290
|
+
operation_id: string;
|
|
291
|
+
instance_id: string;
|
|
292
|
+
status: TUpdateOperationStatus;
|
|
293
|
+
}>;
|