@selfhelp/shared 1.14.24 → 1.15.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.
@@ -1,5 +1,6 @@
1
1
  // src/plugin-sdk/version.ts
2
2
  var PLUGIN_API_VERSION = "0.1.0";
3
+ var MOBILE_RENDERER_VERSION = "0.1.0";
3
4
  var SEMVER_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
4
5
  function parseSemver(version) {
5
6
  const match = SEMVER_REGEX.exec(version);
@@ -85,6 +86,14 @@ function assertPluginApiVersion(required) {
85
86
  );
86
87
  }
87
88
  }
89
+ function isMobileRendererCompatible(requiredRange, host = MOBILE_RENDERER_VERSION) {
90
+ if (!requiredRange) return false;
91
+ try {
92
+ return satisfiesSemverRange(host, requiredRange);
93
+ } catch {
94
+ return false;
95
+ }
96
+ }
88
97
  function assertCmsCompatibility(cmsVersion, range) {
89
98
  if (!satisfiesSemverRange(cmsVersion, range)) {
90
99
  throw new Error(
@@ -477,6 +486,7 @@ var PLUGIN_RUNTIME_IMPORT_MAP = Object.freeze(
477
486
  )
478
487
  );
479
488
  export {
489
+ MOBILE_RENDERER_VERSION,
480
490
  PLUGIN_API_VERSION,
481
491
  PLUGIN_REGISTRY_CHANNELS,
482
492
  PLUGIN_RUNTIME_GLOBAL_KEY,
@@ -491,6 +501,7 @@ export {
491
501
  defineMobilePlugin,
492
502
  definePlugin,
493
503
  definePluginRealtimeTopic,
504
+ isMobileRendererCompatible,
494
505
  isPluginApiCompatible,
495
506
  isPluginRuntimeShimSpecifier,
496
507
  parseSemver,
@@ -1,4 +1,4 @@
1
- import { I as IPluginManifest } from '../manifest-C8sBTLJb.mjs';
1
+ import { I as IPluginManifest } from '../manifest-8YXAk-4o.mjs';
2
2
 
3
3
  /**
4
4
  * `@selfhelp/shared/testing` — the plugin certification kit.
@@ -1,4 +1,4 @@
1
- import { I as IPluginManifest } from '../manifest-C8sBTLJb.js';
1
+ import { I as IPluginManifest } from '../manifest-8YXAk-4o.js';
2
2
 
3
3
  /**
4
4
  * `@selfhelp/shared/testing` — the plugin certification kit.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selfhelp/shared",
3
- "version": "1.14.24",
3
+ "version": "1.15.1",
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",
@@ -0,0 +1,40 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ import { describe, expect, it } from 'vitest';
6
+ import {
7
+ MOBILE_RENDERER_VERSION,
8
+ isMobileRendererCompatible,
9
+ parseSemver,
10
+ } from '../version';
11
+
12
+ describe('mobile renderer compatibility (compatibility.mobile axis)', () => {
13
+ it('exposes a valid semver MOBILE_RENDERER_VERSION constant', () => {
14
+ const v = parseSemver(MOBILE_RENDERER_VERSION);
15
+ expect(v.major).toBeGreaterThanOrEqual(0);
16
+ expect(typeof v.minor).toBe('number');
17
+ expect(typeof v.patch).toBe('number');
18
+ });
19
+
20
+ it('accepts a range that covers the host renderer version', () => {
21
+ expect(isMobileRendererCompatible('>=0.1.0 <0.2.0', '0.1.0')).toBe(true);
22
+ expect(isMobileRendererCompatible('^0.2.0', '0.2.3')).toBe(true);
23
+ // Default host arg = MOBILE_RENDERER_VERSION.
24
+ expect(isMobileRendererCompatible(`>=${MOBILE_RENDERER_VERSION}`)).toBe(true);
25
+ });
26
+
27
+ it('rejects a range outside the host renderer version', () => {
28
+ expect(isMobileRendererCompatible('>=0.2.0', '0.1.0')).toBe(false);
29
+ expect(isMobileRendererCompatible('<0.1.0', '0.1.0')).toBe(false);
30
+ });
31
+
32
+ it('treats a missing range as "no mobile support declared" (web-only plugin)', () => {
33
+ expect(isMobileRendererCompatible(undefined)).toBe(false);
34
+ expect(isMobileRendererCompatible('')).toBe(false);
35
+ });
36
+
37
+ it('never throws on a malformed range', () => {
38
+ expect(isMobileRendererCompatible('not-a-range', '0.1.0')).toBe(false);
39
+ });
40
+ });
@@ -17,8 +17,10 @@ SPDX-License-Identifier: MPL-2.0
17
17
 
18
18
  export {
19
19
  PLUGIN_API_VERSION,
20
+ MOBILE_RENDERER_VERSION,
20
21
  assertPluginApiVersion,
21
22
  isPluginApiCompatible,
23
+ isMobileRendererCompatible,
22
24
  assertCmsCompatibility,
23
25
  assertPluginVersionSemantics,
24
26
  parseSemver,
@@ -46,6 +46,14 @@ export interface IPluginManifestCompatibility {
46
46
  reactNative?: string;
47
47
  /** SemVer range for Expo SDK. */
48
48
  expoSdk?: string;
49
+ /**
50
+ * SemVer range for the host mobile renderer contract
51
+ * (`MOBILE_RENDERER_VERSION`) the plugin's mobile package supports. The
52
+ * SelfHelp Manager gates a plugin's mobile package against the selected
53
+ * `selfhelp-mobile-preview` image's advertised `mobileRendererVersion`.
54
+ * Absent for web-only plugins.
55
+ */
56
+ mobile?: string;
49
57
  }
50
58
 
51
59
  export interface IPluginManifestDependency {
@@ -84,6 +84,12 @@ export interface IPluginRelease {
84
84
  core: string;
85
85
  /** Semver range of host plugin-API versions this plugin runs on. */
86
86
  pluginApi: string;
87
+ /**
88
+ * Semver range of the host mobile renderer contract
89
+ * (`mobileRendererVersion`) this plugin's mobile package supports.
90
+ * Additive; absent for web-only plugins.
91
+ */
92
+ mobile?: string;
87
93
  };
88
94
  /** Optional other-plugin requirements consumed by the resolver. */
89
95
  dependencies?: {
@@ -132,6 +138,11 @@ export interface IPluginRegistry {
132
138
  worker: IRegistryReleaseRef[];
133
139
  /** Plugin release refs (CMS-installed) — multi-version, one ref per published version. */
134
140
  plugins: IRegistryReleaseRef[];
141
+ /**
142
+ * Mobile-preview web image release refs (Manager-installed). Additive in
143
+ * registry `schemaVersion` 1.1 — older managers ignore the unknown array.
144
+ */
145
+ mobilePreview?: IRegistryReleaseRef[];
135
146
  /** Optional path to the security advisory feed. */
136
147
  advisoriesUrl?: string;
137
148
  /** Optional path to the cross-component compatibility feed. */
@@ -16,6 +16,24 @@ SPDX-License-Identifier: MPL-2.0
16
16
  */
17
17
  export const PLUGIN_API_VERSION = '0.1.0' as const;
18
18
 
19
+ /**
20
+ * Mobile renderer contract version. This is the SECOND, mobile-only
21
+ * compatibility axis (independent of `PLUGIN_API_VERSION`): it versions the
22
+ * mobile plugin rendering surface — the `registerMobile()` shape, `IStyleProps`
23
+ * / `TPluginStyleImplMap`, and the mobile host SDK primitives — that a plugin's
24
+ * mobile npm package compiles against.
25
+ *
26
+ * The mobile app and the `selfhelp-mobile-preview` image advertise this value
27
+ * (in `version.json` + the signed `mobile-preview-release.json`). A plugin
28
+ * declares the range it supports in `plugin.json` under `compatibility.mobile`;
29
+ * the SelfHelp Manager gates the plugin against the selected preview image's
30
+ * advertised `mobileRendererVersion` using {@see isMobileRendererCompatible}.
31
+ *
32
+ * Bump rules mirror the SDK contract: patch = additive fix, minor = additive
33
+ * renderer feature, major = breaking mobile renderer change.
34
+ */
35
+ export const MOBILE_RENDERER_VERSION = '0.1.0' as const;
36
+
19
37
  export interface ISemver {
20
38
  major: number;
21
39
  minor: number;
@@ -139,6 +157,26 @@ export function assertPluginApiVersion(required: string): void {
139
157
  }
140
158
  }
141
159
 
160
+ /**
161
+ * Non-throwing satisfaction check for the mobile-renderer axis: returns true
162
+ * when the host's `mobileRendererVersion` falls inside the plugin's declared
163
+ * `compatibility.mobile` range. Used by the SelfHelp Manager preflight to gate
164
+ * an enabled plugin's mobile package against the selected preview image, and by
165
+ * the mobile/preview runtime to skip an incompatible plugin instead of crashing.
166
+ * An empty/undefined range is treated as "no mobile support declared" → false.
167
+ */
168
+ export function isMobileRendererCompatible(
169
+ requiredRange: string | undefined,
170
+ host: string = MOBILE_RENDERER_VERSION,
171
+ ): boolean {
172
+ if (!requiredRange) return false;
173
+ try {
174
+ return satisfiesSemverRange(host, requiredRange);
175
+ } catch {
176
+ return false;
177
+ }
178
+ }
179
+
142
180
  /**
143
181
  * Throw if the running CMS version is not in the plugin's declared
144
182
  * compatibility range.
@@ -10,6 +10,7 @@ import type {
10
10
  AdvisoryFeed,
11
11
  CompatibilityRules,
12
12
  CoreRelease,
13
+ MobilePreviewRelease,
13
14
  PluginRelease,
14
15
  RegistryIndex,
15
16
  } from '../distribution';
@@ -29,7 +30,7 @@ function readExample(name: string): Record<string, unknown> {
29
30
  const SPEC: Record<string, { required: string[]; optional?: string[]; kind?: string }> = {
30
31
  'registry-index.json': {
31
32
  required: ['schemaVersion', 'requiresManager', 'publishedAt', 'baseUrl', 'publisher', 'core', 'frontend', 'scheduler', 'worker', 'plugins'],
32
- optional: ['advisoriesUrl', 'compatibilityUrl', 'trustedKeysUrl'],
33
+ optional: ['mobilePreview', 'advisoriesUrl', 'compatibilityUrl', 'trustedKeysUrl'],
33
34
  },
34
35
  'core-release.json': {
35
36
  kind: 'selfhelp-core-release',
@@ -165,4 +166,57 @@ describe('distribution contracts compile and are usable', () => {
165
166
  expect(advisories.advisories[0]?.blocked).toBe(true);
166
167
  expect(compatibility.rules[0]?.runtime.mysql.recommendedImage).toBe('mysql:8.4');
167
168
  });
169
+
170
+ it('types a mobile-preview release with bundled plugins + renderer version', () => {
171
+ const preview: MobilePreviewRelease = {
172
+ kind: 'selfhelp-mobile-preview-release',
173
+ id: 'selfhelp-mobile-preview-0.2.0',
174
+ version: '0.2.0',
175
+ channel: 'stable',
176
+ image: 'ghcr.io/humdek-unibe-ch/selfhelp-mobile-preview:0.2.0',
177
+ digest: 'sha256:abc',
178
+ backendCompatibility: { requiredCoreRange: '>=0.1.0 <0.2.0', requiredApiVersion: '0.1.0' },
179
+ mobileRendererVersion: '0.1.0',
180
+ bundledPlugins: [
181
+ {
182
+ id: 'sh2-shp-survey-js',
183
+ version: '0.2.23',
184
+ mobilePackage: '@humdek/sh2-shp-survey-js-mobile',
185
+ mobilePackageVersion: '0.2.23',
186
+ },
187
+ ],
188
+ security: { signature: 'sig', keyId: 'selfhelp-dev-fixture' },
189
+ };
190
+ // Index can carry the additive mobilePreview ref array; a plugin can
191
+ // declare the additive compatibility.mobile axis.
192
+ const index: RegistryIndex = {
193
+ schemaVersion: '1.1',
194
+ requiresManager: '>=0.1.0',
195
+ publishedAt: '2026-06-23T12:00:00Z',
196
+ baseUrl: 'https://example/',
197
+ publisher: { name: 'SelfHelp', url: 'https://example/' },
198
+ core: [],
199
+ frontend: [],
200
+ scheduler: [],
201
+ worker: [],
202
+ plugins: [],
203
+ mobilePreview: [
204
+ { id: preview.id, version: preview.version, channel: 'stable', releaseUrl: 'releases/mobile-preview/x.json' },
205
+ ],
206
+ };
207
+ const plugin: PluginRelease = {
208
+ kind: 'selfhelp-plugin-release',
209
+ id: 'sh2-shp-survey-js',
210
+ version: '0.2.23',
211
+ channel: 'stable',
212
+ official: true,
213
+ compatibility: { core: '>=0.1.0 <0.2.0', pluginApi: '0.1.0', mobile: '>=0.1.0 <0.2.0' },
214
+ artifacts: { manifestUrl: 'm', archiveUrl: 'a', sha256: 'sha256:0' },
215
+ security: { signature: 'sig', keyId: 'selfhelp-dev-fixture' },
216
+ };
217
+ expect(preview.bundledPlugins[0]?.mobilePackage).toBe('@humdek/sh2-shp-survey-js-mobile');
218
+ expect(preview.mobileRendererVersion).toBe('0.1.0');
219
+ expect(index.mobilePreview?.[0]?.version).toBe('0.2.0');
220
+ expect(plugin.compatibility.mobile).toBe('>=0.1.0 <0.2.0');
221
+ });
168
222
  });
@@ -11,6 +11,10 @@ import {
11
11
  type IFrontendUpdateRequest,
12
12
  type IFrontendUpdateRequestResponse,
13
13
  type IMaintenanceSetRequest,
14
+ type IMobilePreviewUpdatePreflight,
15
+ type IMobilePreviewUpdateReleases,
16
+ type IMobilePreviewUpdateRequest,
17
+ type IMobilePreviewUpdateRequestResponse,
14
18
  type ISystemAdvisories,
15
19
  type ISystemAdvisoriesResponse,
16
20
  type ISystemAdvisory,
@@ -159,6 +163,7 @@ describe('system maintenance contracts', () => {
159
163
  selfhelp_version: '1.4.0',
160
164
  backend_version: '1.4.0',
161
165
  frontend_version: '1.4.0',
166
+ mobile_preview_version: '0.2.0',
162
167
  plugin_api_version: '2.1',
163
168
  database_migration_version: 'Version20260605081254',
164
169
  safe_mode: false,
@@ -183,6 +188,7 @@ describe('system maintenance contracts', () => {
183
188
  kind: 'core',
184
189
  target_version: '1.5.0',
185
190
  target_frontend_version: null,
191
+ target_mobile_preview_version: null,
186
192
  progress_percent: 42,
187
193
  steps: [{ name: 'backup', status: 'succeeded' }],
188
194
  requested_at: '2026-06-08T00:00:00Z',
@@ -248,6 +254,7 @@ describe('system maintenance contracts', () => {
248
254
  kind: 'core',
249
255
  target_version: '8.0.1',
250
256
  target_frontend_version: null,
257
+ target_mobile_preview_version: null,
251
258
  progress_percent: 100,
252
259
  steps: [],
253
260
  requested_at: '2026-06-08T00:00:00Z',
@@ -290,6 +297,7 @@ describe('system maintenance contracts', () => {
290
297
  kind: 'core',
291
298
  target_version: '8.0.1',
292
299
  target_frontend_version: null,
300
+ target_mobile_preview_version: null,
293
301
  progress_percent: 100,
294
302
  steps: [{ name: 'migrate', status: 'succeeded' }],
295
303
  requested_at: '2026-06-08T00:00:00Z',
@@ -380,4 +388,79 @@ describe('system maintenance contracts', () => {
380
388
  expect(accepted.data.kind).toBe('frontend');
381
389
  expect(accepted.data.target_frontend_version).toBe('0.1.7');
382
390
  });
391
+
392
+ it('exposes the mobile-preview update endpoints under the system prefix', () => {
393
+ expect(SYSTEM_ENDPOINTS.UPDATE_MOBILE_PREVIEW_RELEASES).toBe(
394
+ '/cms-api/v1/admin/system/update/mobile-preview/releases',
395
+ );
396
+ expect(SYSTEM_ENDPOINTS.UPDATE_MOBILE_PREVIEW_PREFLIGHT).toBe(
397
+ '/cms-api/v1/admin/system/update/mobile-preview/preflight',
398
+ );
399
+ expect(SYSTEM_ENDPOINTS.UPDATE_MOBILE_PREVIEW_REQUEST).toBe(
400
+ '/cms-api/v1/admin/system/update/mobile-preview/request',
401
+ );
402
+ });
403
+
404
+ it('models the mobile-preview update flow (stateless swap + core-compat verdict)', () => {
405
+ // mobile-preview is a first-class update kind alongside core/frontend.
406
+ const kinds: TUpdateKind[] = ['core', 'frontend', 'mobile-preview'];
407
+ expect(kinds).toContain('mobile-preview');
408
+
409
+ const releases: IMobilePreviewUpdateReleases = {
410
+ available: true,
411
+ current_version: 'not_installed',
412
+ releases: [
413
+ { version: '0.2.1', channel: 'stable', blocked: false },
414
+ { version: '0.2.0', channel: 'stable', blocked: false },
415
+ ],
416
+ };
417
+
418
+ const preflight: IMobilePreviewUpdatePreflight = {
419
+ preflight_id: 'mp-pf-001',
420
+ status: 'ok',
421
+ instance_id: 'inst-a',
422
+ current_version: 'not_installed',
423
+ target_version: '0.2.1',
424
+ // The preview ⇄ core rule is evaluated server-side against signed
425
+ // registry metadata, so the CMS verdict matches the manager's.
426
+ checks: [
427
+ {
428
+ code: 'mobile_preview_compatibility',
429
+ severity: 'info',
430
+ message: 'Core 0.1.19 satisfies the target preview required core range.',
431
+ component: 'mobile-preview',
432
+ },
433
+ ],
434
+ options: [{ type: 'mobile-preview', version: '0.2.1', label: 'SelfHelp mobile preview 0.2.1' }],
435
+ // The preview image is stateless: a swap is never destructive.
436
+ database: { destructive: false, requires_backup: false, manual_confirmation_required: false },
437
+ rollback: { automatic_before_migrations: true, automatic_after_destructive_migrations: true },
438
+ };
439
+
440
+ // No accepted_migration_risk: a preview swap is stateless. Requesting it
441
+ // onto a not_installed instance doubles as the enable/bootstrap path.
442
+ const request: IMobilePreviewUpdateRequest = { target_version: '0.2.1', preflight_id: 'mp-pf-001' };
443
+
444
+ const accepted: IMobilePreviewUpdateRequestResponse = {
445
+ status: 202,
446
+ message: 'Accepted',
447
+ error: null,
448
+ logged_in: true,
449
+ meta: { version: 'v1', timestamp: '2026-06-23T00:00:00Z' },
450
+ data: {
451
+ operation_id: 'op-mp-1',
452
+ instance_id: 'inst-a',
453
+ status: 'requested',
454
+ kind: 'mobile-preview',
455
+ target_mobile_preview_version: '0.2.1',
456
+ },
457
+ };
458
+
459
+ expect(releases.current_version).toBe('not_installed');
460
+ expect(preflight.checks[0]?.component).toBe('mobile-preview');
461
+ expect(preflight.database.requires_backup).toBe(false);
462
+ expect(request.target_version).toBe('0.2.1');
463
+ expect(accepted.data.kind).toBe('mobile-preview');
464
+ expect(accepted.data.target_mobile_preview_version).toBe('0.2.1');
465
+ });
383
466
  });
@@ -8,3 +8,4 @@ export * from './forms';
8
8
  export * from './language';
9
9
  export * from './page';
10
10
  export * from './system';
11
+ export * from './mobile-preview';
@@ -0,0 +1,71 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * Mobile preview session contracts (CMS admin <-> backend <-> mobile-preview
7
+ * web image).
8
+ *
9
+ * Flow: the CMS admin mints a SHORT-LIVED, SINGLE-USE preview code (bound to the
10
+ * admin user + an optional scope). The `selfhelp-mobile-preview` web image
11
+ * exchanges that one-time code for an in-memory, scoped JWT
12
+ * (`purpose: 'mobile_preview'`) used for read-only `/cms-api` calls. The admin
13
+ * JWT is never exposed to the preview iframe.
14
+ *
15
+ * Snake_case is the wire contract (these mirror the backend JSON schemas under
16
+ * `config/schemas/api/v1/{requests,responses}/`).
17
+ */
18
+ import type { IBaseApiResponse } from './envelope';
19
+ import type { IUserData } from '../auth';
20
+
21
+ const MOBILE_PREVIEW_PREFIX = '/cms-api/v1';
22
+
23
+ /** Mobile preview session endpoints. */
24
+ export const MOBILE_PREVIEW_ENDPOINTS = {
25
+ /** Admin-only: mint a one-time preview session code. */
26
+ SESSION: `${MOBILE_PREVIEW_PREFIX}/admin/mobile-preview/session`,
27
+ /** Public: exchange a one-time code for a scoped preview JWT. */
28
+ EXCHANGE: `${MOBILE_PREVIEW_PREFIX}/mobile-preview/session/exchange`,
29
+ } as const;
30
+
31
+ /**
32
+ * POST /admin/mobile-preview/session — mint a one-time preview code. No
33
+ * `instance_id`: the backend derives + verifies the admin server-side. The
34
+ * optional scope is bound into the code and enforced on exchange.
35
+ */
36
+ export interface IMobilePreviewSessionRequest {
37
+ /** Page keyword to preview. */
38
+ keyword?: string;
39
+ /** Page id to preview (alternative to `keyword`). */
40
+ page_id?: number;
41
+ /** Language id to render in. */
42
+ language_id?: number;
43
+ /** Whether to preview the unpublished draft version. */
44
+ draft?: boolean;
45
+ }
46
+
47
+ export interface IMobilePreviewSessionData {
48
+ /** Opaque one-time code (safe in the iframe URL; invalid after exchange). */
49
+ code: string;
50
+ /** ISO-8601 expiry of the one-time code. */
51
+ expires_at: string;
52
+ }
53
+ export type IMobilePreviewSessionResponse = IBaseApiResponse<IMobilePreviewSessionData>;
54
+
55
+ /**
56
+ * POST /mobile-preview/session/exchange — public route; the one-time code IS the
57
+ * credential. Consumes (deletes) the code and mints a scoped preview JWT.
58
+ */
59
+ export interface IMobilePreviewExchangeRequest {
60
+ code: string;
61
+ }
62
+
63
+ export interface IMobilePreviewExchangeData {
64
+ /** Short-lived scoped JWT (`purpose: 'mobile_preview'`); held in memory only. */
65
+ access_token: string;
66
+ /** Seconds until the scoped token expires. */
67
+ expires_in: number;
68
+ /** The previewed user (the minting admin), for the preview UI. */
69
+ user: IUserData;
70
+ }
71
+ export type IMobilePreviewExchangeResponse = IBaseApiResponse<IMobilePreviewExchangeData>;
@@ -35,10 +35,25 @@ export const SYSTEM_ENDPOINTS = {
35
35
  UPDATE_FRONTEND_RELEASES: `${SYSTEM_PREFIX}/update/frontend/releases`,
36
36
  UPDATE_FRONTEND_PREFLIGHT: `${SYSTEM_PREFIX}/update/frontend/preflight`,
37
37
  UPDATE_FRONTEND_REQUEST: `${SYSTEM_PREFIX}/update/frontend/request`,
38
+ // Mobile-preview update flow. The `selfhelp-mobile-preview` web image is
39
+ // provisioned with every install and ships independently of the core (like
40
+ // the frontend), so an instance can move it to a newer compatible version on
41
+ // its own. These reuse the core preflight/releases response shapes; the
42
+ // request body omits `accepted_migration_risk` (a preview swap is stateless).
43
+ // Requesting one onto an instance that never had it doubles as the
44
+ // enable/bootstrap path (the SelfHelp Manager provisions it).
45
+ UPDATE_MOBILE_PREVIEW_RELEASES: `${SYSTEM_PREFIX}/update/mobile-preview/releases`,
46
+ UPDATE_MOBILE_PREVIEW_PREFLIGHT: `${SYSTEM_PREFIX}/update/mobile-preview/preflight`,
47
+ UPDATE_MOBILE_PREVIEW_REQUEST: `${SYSTEM_PREFIX}/update/mobile-preview/request`,
38
48
  } as const;
39
49
 
40
- /** Discriminates a core (full-stack) update from a frontend-only update. */
41
- export type TUpdateKind = 'core' | 'frontend';
50
+ /**
51
+ * Discriminates a core (full-stack) update from the stateless component-only
52
+ * swaps. `frontend` swaps the Next.js image; `mobile-preview` swaps the
53
+ * `selfhelp-mobile-preview` web image. Both are lightweight (no DB migration,
54
+ * no backup) and performed by the SelfHelp Manager.
55
+ */
56
+ export type TUpdateKind = 'core' | 'frontend' | 'mobile-preview';
42
57
 
43
58
  export interface ISystemInstalledPlugin {
44
59
  id: string;
@@ -59,6 +74,16 @@ export interface ISystemVersion {
59
74
  selfhelp_version: string;
60
75
  backend_version: string;
61
76
  frontend_version: string;
77
+ /**
78
+ * The provisioned `selfhelp-mobile-preview` web image version reported by the
79
+ * backend (set by the SelfHelp Manager via `SELFHELP_MOBILE_PREVIEW_VERSION`
80
+ * when it provisions/updates the service). `unknown` until the manager stamps
81
+ * it; `not_installed` when no preview service is provisioned for this
82
+ * instance (e.g. an instance that predates default provisioning, or a dev
83
+ * source checkout). The page-editor preview panel additionally probes the
84
+ * running image's `version.json` for the live value.
85
+ */
86
+ mobile_preview_version: string;
62
87
  plugin_api_version: string;
63
88
  database_migration_version: string;
64
89
  deployment: TSystemDeployment;
@@ -214,7 +239,7 @@ export interface IUpdatePreflightCheck {
214
239
  * and the plugin-specific `pinned` affordance). Snake_case is the wire contract.
215
240
  */
216
241
  export interface ICompatibilityError {
217
- component: 'core' | 'frontend' | 'plugin';
242
+ component: 'core' | 'frontend' | 'mobile-preview' | 'plugin';
218
243
  component_id: string;
219
244
  current_version: string | null;
220
245
  target_version: string | null;
@@ -347,6 +372,11 @@ export interface IUpdateStatus {
347
372
  * for the synthetic `idle` status.
348
373
  */
349
374
  target_frontend_version: string | null;
375
+ /**
376
+ * The mobile-preview image version a `mobile-preview`-kind operation targets;
377
+ * `null` for core/frontend operations and the synthetic `idle` status.
378
+ */
379
+ target_mobile_preview_version: string | null;
350
380
  progress_percent: number;
351
381
  steps: IUpdateStep[];
352
382
  requested_at: string;
@@ -409,3 +439,53 @@ export type IFrontendUpdateRequestResponse = IBaseApiResponse<{
409
439
  kind: 'frontend';
410
440
  target_frontend_version: string;
411
441
  }>;
442
+
443
+ /**
444
+ * POST /admin/system/update/mobile-preview/request — request a MOBILE-PREVIEW
445
+ * update for THIS instance. Like {@link IFrontendUpdateRequest} it carries no
446
+ * `instance_id` (the backend derives + verifies it) and no
447
+ * `accepted_migration_risk` (a preview swap is stateless). Requesting it onto an
448
+ * instance that has no preview yet is also the enable/bootstrap path: the
449
+ * SelfHelp Manager provisions the `selfhelp-mobile-preview` service. The manager
450
+ * re-resolves the signed release and is the final authority on compatibility +
451
+ * signatures + image digests before it swaps the container.
452
+ */
453
+ export interface IMobilePreviewUpdateRequest {
454
+ target_version: string;
455
+ preflight_id: string;
456
+ }
457
+
458
+ /**
459
+ * GET /admin/system/update/mobile-preview/releases — mobile-preview image
460
+ * versions published in the official registry (newest first). Reuses
461
+ * {@link IUpdateReleases}: `current_version` is the instance's provisioned
462
+ * preview version (or `not_installed`) and `available: false` means the registry
463
+ * was unreachable (fall back to manual entry). Aliased for call-site clarity.
464
+ */
465
+ export type IMobilePreviewUpdateReleases = IUpdateReleases;
466
+ export type IMobilePreviewUpdateReleasesResponse = IUpdateReleasesResponse;
467
+
468
+ /**
469
+ * GET /admin/system/update/mobile-preview/preflight — compatibility verdict for
470
+ * a mobile-preview target. Reuses {@link IUpdatePreflight}; the preview is
471
+ * stateless so `database.destructive`/`requires_backup` are always false. The
472
+ * preview ⇄ core compatibility rule IS evaluated here (as a
473
+ * `mobile_preview_compatibility` check) against the same signed registry
474
+ * metadata the SelfHelp Manager resolves — the running core must satisfy the
475
+ * target preview's `backendCompatibility.requiredCoreRange` — so the CMS verdict
476
+ * matches the manager's instead of always reporting "OK". The manager still
477
+ * re-verifies signatures + image digests and re-runs the per-plugin RN/Expo
478
+ * twin-axis gate at execution and remains the final authority. Aliased for
479
+ * call-site clarity.
480
+ */
481
+ export type IMobilePreviewUpdatePreflight = IUpdatePreflight;
482
+ export type IMobilePreviewUpdatePreflightResponse = IUpdatePreflightResponse;
483
+
484
+ /** POST /admin/system/update/mobile-preview/request — accepted record. */
485
+ export type IMobilePreviewUpdateRequestResponse = IBaseApiResponse<{
486
+ operation_id: string;
487
+ instance_id: string;
488
+ status: TUpdateOperationStatus;
489
+ kind: 'mobile-preview';
490
+ target_mobile_preview_version: string;
491
+ }>;