@selfhelp/shared 1.0.3 → 1.0.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.
- package/CHANGELOG.md +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +92 -3
- package/dist/index.mjs +84 -3
- package/dist/plugin-sdk/index.d.mts +906 -0
- package/dist/plugin-sdk/index.d.ts +906 -0
- package/dist/plugin-sdk/index.js +490 -0
- package/dist/plugin-sdk/index.mjs +452 -0
- package/dist/registry/index.d.mts +56 -1
- package/dist/registry/index.d.ts +56 -1
- package/dist/registry/index.js +94 -5
- package/dist/registry/index.mjs +85 -4
- package/dist/{index-Bg60YTsF.d.mts → styles.registry-C3bux91U.d.mts} +569 -28
- package/dist/{index-DEOVT86P.d.ts → styles.registry-Cr961HQ0.d.ts} +569 -28
- package/package.json +19 -3
- package/src/plugin-sdk/define.ts +89 -0
- package/src/plugin-sdk/index.ts +91 -0
- package/src/plugin-sdk/lock.ts +124 -0
- package/src/plugin-sdk/manifest.ts +295 -0
- package/src/plugin-sdk/realtime.ts +277 -0
- package/src/plugin-sdk/registry.ts +95 -0
- package/src/plugin-sdk/types.ts +265 -0
- package/src/plugin-sdk/version.ts +209 -0
- package/src/registry/index.ts +68 -11
- package/src/registry/styles.registry.ts +149 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selfhelp/shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
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",
|
|
@@ -33,6 +33,11 @@
|
|
|
33
33
|
"types": "./dist/theme/tailwind.d.ts",
|
|
34
34
|
"import": "./dist/theme/tailwind.mjs",
|
|
35
35
|
"require": "./dist/theme/tailwind.js"
|
|
36
|
+
},
|
|
37
|
+
"./plugin-sdk": {
|
|
38
|
+
"types": "./dist/plugin-sdk/index.d.ts",
|
|
39
|
+
"import": "./dist/plugin-sdk/index.mjs",
|
|
40
|
+
"require": "./dist/plugin-sdk/index.js"
|
|
36
41
|
}
|
|
37
42
|
},
|
|
38
43
|
"files": [
|
|
@@ -42,11 +47,12 @@
|
|
|
42
47
|
"CHANGELOG.md"
|
|
43
48
|
],
|
|
44
49
|
"scripts": {
|
|
45
|
-
"build": "tsup src/index.ts src/registry/index.ts src/theme/index.ts src/theme/tailwind.ts --format cjs,esm --dts --clean --no-splitting",
|
|
46
|
-
"dev": "tsup src/index.ts src/registry/index.ts src/theme/index.ts src/theme/tailwind.ts --format cjs,esm --dts --watch --no-splitting",
|
|
50
|
+
"build": "tsup src/index.ts src/registry/index.ts src/theme/index.ts src/theme/tailwind.ts src/plugin-sdk/index.ts --format cjs,esm --dts --clean --no-splitting",
|
|
51
|
+
"dev": "tsup src/index.ts src/registry/index.ts src/theme/index.ts src/theme/tailwind.ts src/plugin-sdk/index.ts --format cjs,esm --dts --watch --no-splitting",
|
|
47
52
|
"lint": "eslint . --ext .ts",
|
|
48
53
|
"typecheck": "tsc --noEmit",
|
|
49
54
|
"test": "vitest run",
|
|
55
|
+
"check:schemas": "node scripts/check-schema-parity.mjs",
|
|
50
56
|
"prepublishOnly": "npm run build",
|
|
51
57
|
"headers:check": "license-check-and-add check -f license-check-and-add-config.json",
|
|
52
58
|
"headers:add": "license-check-and-add add -f license-check-and-add-config.json",
|
|
@@ -55,13 +61,23 @@
|
|
|
55
61
|
"dependencies": {
|
|
56
62
|
"json-logic-js": "^2.0.5"
|
|
57
63
|
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
66
|
+
},
|
|
67
|
+
"peerDependenciesMeta": {
|
|
68
|
+
"react": {
|
|
69
|
+
"optional": true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
58
72
|
"devDependencies": {
|
|
59
73
|
"@types/json-logic-js": "^2.0.8",
|
|
60
74
|
"@types/node": "^22.10.0",
|
|
75
|
+
"@types/react": "^19.2.15",
|
|
61
76
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
62
77
|
"@typescript-eslint/parser": "^8.0.0",
|
|
63
78
|
"eslint": "^9.18.0",
|
|
64
79
|
"license-check-and-add": "^4.0.5",
|
|
80
|
+
"react": "^19.2.6",
|
|
65
81
|
"tsup": "^8.3.5",
|
|
66
82
|
"typescript": "^5.6.0",
|
|
67
83
|
"vitest": "^2.1.0"
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
IAdminPageDefinition,
|
|
71
|
+
IMenuItemDefinition,
|
|
72
|
+
IPluginApi,
|
|
73
|
+
IMobilePluginApi,
|
|
74
|
+
IPluginHealthCheck,
|
|
75
|
+
IPluginFeatureFlag,
|
|
76
|
+
IPluginRealtimeTopic,
|
|
77
|
+
IPluginRealtimePublisher,
|
|
78
|
+
IRichTextEditorAdapter,
|
|
79
|
+
IRichTextEditorAdapterOptions,
|
|
80
|
+
IRichTextEditorValue,
|
|
81
|
+
} from './types';
|
|
82
|
+
|
|
83
|
+
export { definePlugin, defineMobilePlugin, definePluginRealtimeTopic } from './define';
|
|
84
|
+
|
|
85
|
+
export type {
|
|
86
|
+
IRealtimeTransport,
|
|
87
|
+
TRealtimeTransportFactory,
|
|
88
|
+
IUsePluginRealtimeOptions,
|
|
89
|
+
IUsePluginRealtimeResult,
|
|
90
|
+
} from './realtime';
|
|
91
|
+
export { usePluginRealtime } from './realtime';
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* TypeScript mirror of `plugin.json` (the schema lives in
|
|
7
|
+
* `sh-selfhelp_backend/docs/plugins/plugin-manifest.schema.json`). When
|
|
8
|
+
* the JSON Schema changes, update these types and bump the
|
|
9
|
+
* `@selfhelp/shared` minor version.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export type IPluginManifestTrustLevel = 'official' | 'reviewed' | 'untrusted';
|
|
13
|
+
|
|
14
|
+
/** Every privileged capability is deny-by-default. */
|
|
15
|
+
export type IPluginManifestCapability =
|
|
16
|
+
| 'backendBundle'
|
|
17
|
+
| 'databaseMigrations'
|
|
18
|
+
| 'readUsers'
|
|
19
|
+
| 'writeUsers'
|
|
20
|
+
| 'deleteUsers'
|
|
21
|
+
| 'readDataTables'
|
|
22
|
+
| 'writeDataTables'
|
|
23
|
+
| 'deleteDataTables'
|
|
24
|
+
| 'externalNetworkAccess'
|
|
25
|
+
| 'scheduledJobs'
|
|
26
|
+
| 'publicCallbacks'
|
|
27
|
+
| 'adminPages'
|
|
28
|
+
| 'frontendStyles'
|
|
29
|
+
| 'mobileStyles'
|
|
30
|
+
| 'realtimePublish'
|
|
31
|
+
| 'fileUploads'
|
|
32
|
+
| 'secretAccess';
|
|
33
|
+
|
|
34
|
+
export interface IPluginManifestCompatibility {
|
|
35
|
+
/** SemVer range for the SelfHelp CMS version (e.g. `^2.0`). */
|
|
36
|
+
selfhelp: string;
|
|
37
|
+
/** SemVer range for PHP runtime. */
|
|
38
|
+
php?: string;
|
|
39
|
+
/** SemVer range for Node runtime. */
|
|
40
|
+
node?: string;
|
|
41
|
+
/** SemVer range for React (web). */
|
|
42
|
+
react?: string;
|
|
43
|
+
/** SemVer range for React Native (mobile). */
|
|
44
|
+
reactNative?: string;
|
|
45
|
+
/** SemVer range for Expo SDK. */
|
|
46
|
+
expoSdk?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface IPluginManifestDependency {
|
|
50
|
+
/** Plugin id this plugin requires. */
|
|
51
|
+
pluginId: string;
|
|
52
|
+
/** Required SemVer range. */
|
|
53
|
+
version: string;
|
|
54
|
+
/** Optional / required dependency. */
|
|
55
|
+
required: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* When `required: false`, the plugin still works without the dep
|
|
58
|
+
* but enables additional features when present.
|
|
59
|
+
*/
|
|
60
|
+
featureFlag?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface IPluginManifestConflict {
|
|
64
|
+
pluginId: string;
|
|
65
|
+
/** SemVer range that conflicts. */
|
|
66
|
+
version: string;
|
|
67
|
+
reason: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface IPluginManifestExternalHost {
|
|
71
|
+
/** Wildcards allowed, e.g. `cdn.example.com` or `*.example.com`. */
|
|
72
|
+
host: string;
|
|
73
|
+
/** What is loaded — `script`, `style`, `font`, `image`, `iframe`, `fetch`. */
|
|
74
|
+
type: 'script' | 'style' | 'font' | 'image' | 'iframe' | 'fetch';
|
|
75
|
+
/** Reason for the external host (shown in admin UI). */
|
|
76
|
+
reason: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface IPluginManifestSecurity {
|
|
80
|
+
trustLevel: IPluginManifestTrustLevel;
|
|
81
|
+
capabilities: IPluginManifestCapability[];
|
|
82
|
+
/** CSP rules the installer must add (only for `trustLevel !== 'untrusted'`). */
|
|
83
|
+
cspRules?: {
|
|
84
|
+
/** Maps a CSP directive to extra sources. */
|
|
85
|
+
[directive: string]: string[];
|
|
86
|
+
};
|
|
87
|
+
/** External hosts the plugin will load assets/data from. */
|
|
88
|
+
externalHosts?: IPluginManifestExternalHost[];
|
|
89
|
+
/** Path to file containing checksum/signature, optional. */
|
|
90
|
+
signaturePath?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface IPluginManifestDataAccess {
|
|
94
|
+
/**
|
|
95
|
+
* Tables the plugin reads. May be `dataTable:*` for any plugin-owned
|
|
96
|
+
* data table, `lookup:<typeCode>` for lookup reads, `dataTable:my`
|
|
97
|
+
* for tables created by this plugin.
|
|
98
|
+
*/
|
|
99
|
+
read?: string[];
|
|
100
|
+
/** Tables the plugin writes. */
|
|
101
|
+
write?: string[];
|
|
102
|
+
/** Tables the plugin deletes (rare; requires capability). */
|
|
103
|
+
delete?: string[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface IPluginManifestRealtimeTopic {
|
|
107
|
+
/** Topic key, scoped to this plugin. Example: `survey-response`. */
|
|
108
|
+
key: string;
|
|
109
|
+
/** Human description shown in admin UI. */
|
|
110
|
+
description: string;
|
|
111
|
+
/** Permission required to subscribe; resolved via `PluginRealtimePermissionResolver`. */
|
|
112
|
+
requiredPermission?: string;
|
|
113
|
+
/** JSON Schema path of the topic payload. */
|
|
114
|
+
payloadSchemaPath?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface IPluginManifestFeatureFlag {
|
|
118
|
+
key: string;
|
|
119
|
+
description: string;
|
|
120
|
+
/** Default state when no `plugin_feature_flags` row exists. */
|
|
121
|
+
defaultEnabled: boolean;
|
|
122
|
+
/** Optional capability gate; flag cannot be turned on without it. */
|
|
123
|
+
capability?: IPluginManifestCapability;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface IPluginManifestLookupExtension {
|
|
127
|
+
/** Lookup type code, e.g. `survey_question_type`. */
|
|
128
|
+
typeCode: string;
|
|
129
|
+
/** Whether the plugin OWNS the type code or only extends it. */
|
|
130
|
+
ownership: 'plugin_extendable' | 'plugin_owned';
|
|
131
|
+
entries: {
|
|
132
|
+
code: string;
|
|
133
|
+
value: string;
|
|
134
|
+
description?: string;
|
|
135
|
+
}[];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface IPluginManifestPermission {
|
|
139
|
+
/** Permission key, namespaced like `surveyjs.surveys.manage`. */
|
|
140
|
+
key: string;
|
|
141
|
+
description: string;
|
|
142
|
+
/** Optional default role keys the permission is granted to. */
|
|
143
|
+
defaultRoles?: string[];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface IPluginManifestStyle {
|
|
147
|
+
/** Style name (used as `style_name` discriminator). */
|
|
148
|
+
name: string;
|
|
149
|
+
description: string;
|
|
150
|
+
canHaveChildren: boolean;
|
|
151
|
+
/** Optional capability requirement (e.g. `frontendStyles`). */
|
|
152
|
+
capability?: IPluginManifestCapability;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface IPluginManifestAdminPage {
|
|
156
|
+
/** Slug under `/admin/plugins-host/{pluginId}/`. */
|
|
157
|
+
slug: string;
|
|
158
|
+
/** Menu label. */
|
|
159
|
+
label: string;
|
|
160
|
+
/** Required permission key. */
|
|
161
|
+
permission: string;
|
|
162
|
+
/** Optional menu icon (Tabler icon name). */
|
|
163
|
+
icon?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface IPluginManifestApiRoute {
|
|
167
|
+
/** Symfony route name (must be namespaced with the plugin id). */
|
|
168
|
+
name: string;
|
|
169
|
+
/** HTTP path under `/cms-api/v1/plugins/{pluginId}/...`. */
|
|
170
|
+
path: string;
|
|
171
|
+
methods: ('GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE')[];
|
|
172
|
+
/** Permission key required. */
|
|
173
|
+
permission?: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface IPluginManifestScheduledJob {
|
|
177
|
+
/** Job type key. */
|
|
178
|
+
type: string;
|
|
179
|
+
description: string;
|
|
180
|
+
/** Capability gate (always requires `scheduledJobs`). */
|
|
181
|
+
capability: 'scheduledJobs';
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface IPluginManifestAsset {
|
|
185
|
+
/** Source path within the plugin package. */
|
|
186
|
+
src: string;
|
|
187
|
+
/** Destination path under `/assets/plugins/{pluginId}/...`. */
|
|
188
|
+
dest: string;
|
|
189
|
+
/** Asset type. */
|
|
190
|
+
type: 'script' | 'style' | 'font' | 'image' | 'other';
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface IPluginManifestHealth {
|
|
194
|
+
/** Optional health-check endpoint name. */
|
|
195
|
+
endpoint?: string;
|
|
196
|
+
/** Health-check service id (resolved through Symfony). */
|
|
197
|
+
serviceId?: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface IPluginManifestMobile {
|
|
201
|
+
/** npm package name of the mobile component bundle. */
|
|
202
|
+
package: string;
|
|
203
|
+
/** Required SemVer range. */
|
|
204
|
+
version: string;
|
|
205
|
+
/** Whether the mobile package only renders payloads (readonly). */
|
|
206
|
+
readonly: boolean;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Full `plugin.json` shape.
|
|
211
|
+
*/
|
|
212
|
+
export interface IPluginManifest {
|
|
213
|
+
/** Plugin identifier, e.g. `sh2-shp-survey-js`. */
|
|
214
|
+
id: string;
|
|
215
|
+
/** Human-readable display name. */
|
|
216
|
+
name: string;
|
|
217
|
+
/** Short description. */
|
|
218
|
+
description?: string;
|
|
219
|
+
/** Plugin SemVer version. */
|
|
220
|
+
version: string;
|
|
221
|
+
/** Author / vendor. */
|
|
222
|
+
author?: { name: string; email?: string; url?: string };
|
|
223
|
+
/** SPDX license id. */
|
|
224
|
+
license?: string;
|
|
225
|
+
/** Plugin homepage / repo URL. */
|
|
226
|
+
homepage?: string;
|
|
227
|
+
/** SDK contract version the plugin targets (e.g. `1.0`). */
|
|
228
|
+
pluginApiVersion: string;
|
|
229
|
+
|
|
230
|
+
/** Compatibility with the host stack. */
|
|
231
|
+
compatibility: IPluginManifestCompatibility;
|
|
232
|
+
|
|
233
|
+
/** Required + optional plugin dependencies. */
|
|
234
|
+
dependencies?: IPluginManifestDependency[];
|
|
235
|
+
|
|
236
|
+
/** Plugin conflicts. */
|
|
237
|
+
conflicts?: IPluginManifestConflict[];
|
|
238
|
+
|
|
239
|
+
/** Composer package (only for `trustLevel !== 'untrusted'`). */
|
|
240
|
+
backend?: {
|
|
241
|
+
package: string;
|
|
242
|
+
bundleClass: string;
|
|
243
|
+
migrationsNamespace?: string;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/** npm package for frontend. */
|
|
247
|
+
frontend?: {
|
|
248
|
+
package: string;
|
|
249
|
+
version: string;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/** Optional mobile package. */
|
|
253
|
+
mobile?: IPluginManifestMobile;
|
|
254
|
+
|
|
255
|
+
/** Required security declarations. */
|
|
256
|
+
security: IPluginManifestSecurity;
|
|
257
|
+
|
|
258
|
+
/** Permissions the plugin contributes. */
|
|
259
|
+
permissions?: IPluginManifestPermission[];
|
|
260
|
+
|
|
261
|
+
/** Manifest-declared data access. */
|
|
262
|
+
dataAccess?: IPluginManifestDataAccess;
|
|
263
|
+
|
|
264
|
+
/** Realtime topics. */
|
|
265
|
+
realtimeTopics?: IPluginManifestRealtimeTopic[];
|
|
266
|
+
|
|
267
|
+
/** Feature flags. */
|
|
268
|
+
featureFlags?: IPluginManifestFeatureFlag[];
|
|
269
|
+
|
|
270
|
+
/** Lookup contributions. */
|
|
271
|
+
lookups?: {
|
|
272
|
+
extends?: IPluginManifestLookupExtension[];
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
/** Styles contributed to the registry. */
|
|
276
|
+
styles?: IPluginManifestStyle[];
|
|
277
|
+
|
|
278
|
+
/** Admin pages mounted under `/admin/plugins-host/{pluginId}/`. */
|
|
279
|
+
adminPages?: IPluginManifestAdminPage[];
|
|
280
|
+
|
|
281
|
+
/** Plugin-owned API routes. */
|
|
282
|
+
apiRoutes?: IPluginManifestApiRoute[];
|
|
283
|
+
|
|
284
|
+
/** Scheduled jobs. */
|
|
285
|
+
scheduledJobs?: IPluginManifestScheduledJob[];
|
|
286
|
+
|
|
287
|
+
/** Vendored assets. */
|
|
288
|
+
assets?: IPluginManifestAsset[];
|
|
289
|
+
|
|
290
|
+
/** Health-check declaration. */
|
|
291
|
+
health?: IPluginManifestHealth;
|
|
292
|
+
|
|
293
|
+
/** Optional metadata / labels. */
|
|
294
|
+
labels?: Record<string, string>;
|
|
295
|
+
}
|