@combinedk/plugin-host 0.0.0-stage → 3.5.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/dist/index.d.ts +78 -0
- package/package.json +24 -4
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle status carried by entries in `Versioned` collections: `Draft` is offline and
|
|
3
|
+
* `Published` is online. `Archived` is no longer written, because taking a row offline returns it
|
|
4
|
+
* to `Draft`; it stays in the type only so plugins that name it still compile.
|
|
5
|
+
*/
|
|
6
|
+
export type EntityStatus = 'Draft' | 'Published' | 'Archived';
|
|
7
|
+
/**
|
|
8
|
+
* A row returned by the host's plugin-entity endpoints. The wrapper carries
|
|
9
|
+
* lifecycle + audit metadata; `data` is the plugin-author-defined entity body.
|
|
10
|
+
*/
|
|
11
|
+
export interface PluginEntityRow<TData = unknown> {
|
|
12
|
+
id: string;
|
|
13
|
+
parentId?: string | null;
|
|
14
|
+
data: TData;
|
|
15
|
+
status?: EntityStatus | null;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
/**
|
|
19
|
+
* Publish-time scope-exists warning. Present only on
|
|
20
|
+
* an Api publish response whose required scopes have no matching Keycloak
|
|
21
|
+
* realm role yet — advisory, never a block (publish still succeeded). The
|
|
22
|
+
* designer publish flow surfaces these so the author can create the missing
|
|
23
|
+
* realm role(s); absent/null when every scope exists or the lookup degraded.
|
|
24
|
+
*/
|
|
25
|
+
scopeWarnings?: string[] | null;
|
|
26
|
+
}
|
|
27
|
+
export interface ListEntityOptions {
|
|
28
|
+
parentId?: string;
|
|
29
|
+
status?: EntityStatus | string;
|
|
30
|
+
skip?: number;
|
|
31
|
+
take?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Typed entity client built by the host against
|
|
35
|
+
* `/api/plugins/{assemblyId}/entities/{collection}`. Plugin frontends never
|
|
36
|
+
* compose URLs themselves — they call methods on this client.
|
|
37
|
+
*
|
|
38
|
+
* `publish` (Draft → Published, online) and `unpublish` (Published → Draft, offline) apply only
|
|
39
|
+
* to `Versioned` collections and return 404 when invoked against a `Live` collection.
|
|
40
|
+
*/
|
|
41
|
+
export interface PluginEntityClient {
|
|
42
|
+
list<T = unknown>(collection: string, options?: ListEntityOptions): Promise<PluginEntityRow<T>[]>;
|
|
43
|
+
get<T = unknown>(collection: string, id: string): Promise<PluginEntityRow<T>>;
|
|
44
|
+
create<T = unknown>(collection: string, body: unknown): Promise<PluginEntityRow<T>>;
|
|
45
|
+
update<T = unknown>(collection: string, id: string, body: unknown): Promise<PluginEntityRow<T>>;
|
|
46
|
+
delete(collection: string, id: string): Promise<void>;
|
|
47
|
+
publish<T = unknown>(collection: string, id: string): Promise<PluginEntityRow<T>>;
|
|
48
|
+
unpublish<T = unknown>(collection: string, id: string): Promise<PluginEntityRow<T>>;
|
|
49
|
+
/** @deprecated Use `unpublish`, which takes the row offline to `Draft` the same way. */
|
|
50
|
+
archive<T = unknown>(collection: string, id: string): Promise<PluginEntityRow<T>>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Authentication context for a plugin's own direct API calls (calls it makes
|
|
54
|
+
* itself, not through the entity client — which authenticates per request).
|
|
55
|
+
*/
|
|
56
|
+
export interface PluginAuthContext {
|
|
57
|
+
/**
|
|
58
|
+
* Bearer token snapshot resolved at mount time. Null when signed out.
|
|
59
|
+
* Convenient for short-lived calls; prefer `getToken()` in long-lived
|
|
60
|
+
* sessions where this snapshot may expire before the call is made.
|
|
61
|
+
*/
|
|
62
|
+
token: string | null;
|
|
63
|
+
/** Resolves a fresh bearer token per call (null when signed out). */
|
|
64
|
+
getToken(): Promise<string | null>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Everything a plugin frontend receives at mount-time. The host calls
|
|
68
|
+
* `mount(container, context)` exactly once per route entry; plugins should
|
|
69
|
+
* not retain the context across remounts.
|
|
70
|
+
*/
|
|
71
|
+
export interface PluginMountContext {
|
|
72
|
+
assemblyId: string;
|
|
73
|
+
apiBaseUrl: string;
|
|
74
|
+
entities: PluginEntityClient;
|
|
75
|
+
auth: PluginAuthContext;
|
|
76
|
+
}
|
|
77
|
+
/** The shape of the export that the host imports from a plugin's `mount.ts`. */
|
|
78
|
+
export type PluginMountFn = (container: HTMLElement, context: PluginMountContext) => () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combinedk/plugin-host",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "3.5.0",
|
|
4
|
+
"description": "Types and contracts for plugin frontends mounted into the Combine DataController host shell.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"typecheck": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "~6.0.2"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"registry": "https://npm.pkg.github.com",
|
|
24
|
+
"access": "restricted"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/README.md
DELETED