@plugmatica/plugin-sdk 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +136 -2
- package/dist/advanced.d.ts +315 -0
- package/dist/advanced.js +3 -0
- package/dist/advanced.js.map +1 -0
- package/dist/chunk-ACHELRPS.js +182 -0
- package/dist/chunk-ACHELRPS.js.map +1 -0
- package/dist/chunk-AFVR6B2A.js +256 -0
- package/dist/chunk-AFVR6B2A.js.map +1 -0
- package/dist/chunk-YY4H56JF.js +84 -0
- package/dist/chunk-YY4H56JF.js.map +1 -0
- package/dist/extension-index.d.ts +178 -0
- package/dist/extension-index.js +3 -0
- package/dist/extension-index.js.map +1 -0
- package/dist/host.d.ts +859 -0
- package/dist/host.js +2280 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +1465 -0
- package/dist/index.js +749 -0
- package/dist/index.js.map +1 -0
- package/dist/types-83DpQEKd.d.ts +599 -0
- package/package.json +107 -4
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
import { RuntimeSession, createWorkflowApi, WorkflowRunStatus, createManagedResourceApi, ManagedResourceScope, RuntimeEventHandlerExtension, RuntimeUiExtension, ExtensionSurface, RuntimeOperationHookExtension, OperationExtensionPhase, RuntimeProviderExtension } from '@plugmatica/core-sdk';
|
|
2
|
+
import { ScopedI18nApi } from '@plugmatica/i18n';
|
|
3
|
+
import { UiExtensionRuntime } from '@plugmatica/ui-kit/host';
|
|
4
|
+
import { ReactNode, ComponentType } from 'react';
|
|
5
|
+
|
|
6
|
+
/** HTTP response payload and transport metadata returned by the plugin-scoped API client. */
|
|
7
|
+
type PluginApiResponseMeta<T> = {
|
|
8
|
+
/** Decoded response payload. */
|
|
9
|
+
data: T;
|
|
10
|
+
/** HTTP status code returned by the runtime API. */
|
|
11
|
+
status: number;
|
|
12
|
+
/** HTTP status text returned by the runtime API. */
|
|
13
|
+
statusText: string;
|
|
14
|
+
/** Response headers exposed by the runtime API. */
|
|
15
|
+
headers: Record<string, string>;
|
|
16
|
+
/** Runtime request identifier when supplied by the host. */
|
|
17
|
+
requestId: string | null;
|
|
18
|
+
/** Runtime invocation identifier when supplied by the host. */
|
|
19
|
+
invocationId: string | null;
|
|
20
|
+
};
|
|
21
|
+
/** Request options accepted by plugin-scoped API calls. */
|
|
22
|
+
type PluginApiRequestOptions = Pick<RequestInit, "signal" | "cache" | "credentials"> & {
|
|
23
|
+
/** Additional request headers. */
|
|
24
|
+
headers?: HeadersInit;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Host-supplied, plugin-scoped network capability.
|
|
28
|
+
*
|
|
29
|
+
* Paths are resolved inside the current plugin's runtime boundary, so plugin code
|
|
30
|
+
* does not need to know host API base URLs or import the shell's concrete client.
|
|
31
|
+
*/
|
|
32
|
+
type PluginApiClient = {
|
|
33
|
+
/**
|
|
34
|
+
* Send a GET request and decode the response body.
|
|
35
|
+
* @param path Plugin-scoped runtime API path.
|
|
36
|
+
* @param options Optional request settings.
|
|
37
|
+
* @returns Decoded response payload.
|
|
38
|
+
*/
|
|
39
|
+
get<T>(path: string, options?: PluginApiRequestOptions): Promise<T>;
|
|
40
|
+
/**
|
|
41
|
+
* Send a GET request and return the response as a `Blob`.
|
|
42
|
+
* @param path Plugin-scoped runtime API path.
|
|
43
|
+
* @param options Optional request settings.
|
|
44
|
+
* @returns Binary response body.
|
|
45
|
+
*/
|
|
46
|
+
getBlob(path: string, options?: PluginApiRequestOptions): Promise<Blob>;
|
|
47
|
+
/**
|
|
48
|
+
* Download content from a host-issued browser blob-transfer grant.
|
|
49
|
+
* @param urlPath Host-issued transfer URL path.
|
|
50
|
+
* @param options Optional request settings.
|
|
51
|
+
* @returns Downloaded binary content.
|
|
52
|
+
*/
|
|
53
|
+
getTransferBlob(urlPath: string, options?: PluginApiRequestOptions): Promise<Blob>;
|
|
54
|
+
/**
|
|
55
|
+
* Upload binary content to a host-issued browser blob-transfer grant.
|
|
56
|
+
* @param urlPath Host-issued transfer URL path.
|
|
57
|
+
* @param body Binary content to upload.
|
|
58
|
+
* @param options Optional request settings.
|
|
59
|
+
* @returns Decoded transfer response payload.
|
|
60
|
+
*/
|
|
61
|
+
uploadTransfer<T>(urlPath: string, body: Blob, options?: PluginApiRequestOptions): Promise<T>;
|
|
62
|
+
/**
|
|
63
|
+
* Send a GET request and return the raw response bytes.
|
|
64
|
+
* @param path Plugin-scoped runtime API path.
|
|
65
|
+
* @param options Optional request settings.
|
|
66
|
+
* @returns Raw response bytes.
|
|
67
|
+
*/
|
|
68
|
+
getArrayBuffer(path: string, options?: PluginApiRequestOptions): Promise<ArrayBuffer>;
|
|
69
|
+
/**
|
|
70
|
+
* Send a POST request.
|
|
71
|
+
* @param path Plugin-scoped runtime API path.
|
|
72
|
+
* @param body Optional request body.
|
|
73
|
+
* @param options Optional request settings.
|
|
74
|
+
* @returns Decoded response payload.
|
|
75
|
+
*/
|
|
76
|
+
post<T>(path: string, body?: unknown, options?: PluginApiRequestOptions): Promise<T>;
|
|
77
|
+
/**
|
|
78
|
+
* Send a PUT request.
|
|
79
|
+
* @param path Plugin-scoped runtime API path.
|
|
80
|
+
* @param body Optional request body.
|
|
81
|
+
* @param options Optional request settings.
|
|
82
|
+
* @returns Decoded response payload.
|
|
83
|
+
*/
|
|
84
|
+
put<T>(path: string, body?: unknown, options?: PluginApiRequestOptions): Promise<T>;
|
|
85
|
+
/**
|
|
86
|
+
* Send a PATCH request.
|
|
87
|
+
* @param path Plugin-scoped runtime API path.
|
|
88
|
+
* @param body Optional request body.
|
|
89
|
+
* @param options Optional request settings.
|
|
90
|
+
* @returns Decoded response payload.
|
|
91
|
+
*/
|
|
92
|
+
patch<T>(path: string, body?: unknown, options?: PluginApiRequestOptions): Promise<T>;
|
|
93
|
+
/**
|
|
94
|
+
* Send a DELETE request.
|
|
95
|
+
* @param path Plugin-scoped runtime API path.
|
|
96
|
+
* @param options Optional request settings.
|
|
97
|
+
* @returns Decoded response payload.
|
|
98
|
+
*/
|
|
99
|
+
delete<T>(path: string, options?: PluginApiRequestOptions): Promise<T>;
|
|
100
|
+
/**
|
|
101
|
+
* Send a GET request and retain status/header metadata.
|
|
102
|
+
* @param path Plugin-scoped runtime API path.
|
|
103
|
+
* @param options Optional request settings.
|
|
104
|
+
* @returns Decoded payload plus response metadata.
|
|
105
|
+
*/
|
|
106
|
+
getWithMeta<T>(path: string, options?: PluginApiRequestOptions): Promise<PluginApiResponseMeta<T>>;
|
|
107
|
+
/**
|
|
108
|
+
* Send a POST request and retain status/header metadata.
|
|
109
|
+
* @param path Plugin-scoped runtime API path.
|
|
110
|
+
* @param body Optional request body.
|
|
111
|
+
* @param options Optional request settings.
|
|
112
|
+
* @returns Decoded payload plus response metadata.
|
|
113
|
+
*/
|
|
114
|
+
postWithMeta<T>(path: string, body?: unknown, options?: PluginApiRequestOptions): Promise<PluginApiResponseMeta<T>>;
|
|
115
|
+
/**
|
|
116
|
+
* Send a PUT request and retain status/header metadata.
|
|
117
|
+
* @param path Plugin-scoped runtime API path.
|
|
118
|
+
* @param body Optional request body.
|
|
119
|
+
* @param options Optional request settings.
|
|
120
|
+
* @returns Decoded payload plus response metadata.
|
|
121
|
+
*/
|
|
122
|
+
putWithMeta<T>(path: string, body?: unknown, options?: PluginApiRequestOptions): Promise<PluginApiResponseMeta<T>>;
|
|
123
|
+
/**
|
|
124
|
+
* Send a PATCH request and retain status/header metadata.
|
|
125
|
+
* @param path Plugin-scoped runtime API path.
|
|
126
|
+
* @param body Optional request body.
|
|
127
|
+
* @param options Optional request settings.
|
|
128
|
+
* @returns Decoded payload plus response metadata.
|
|
129
|
+
*/
|
|
130
|
+
patchWithMeta<T>(path: string, body?: unknown, options?: PluginApiRequestOptions): Promise<PluginApiResponseMeta<T>>;
|
|
131
|
+
/**
|
|
132
|
+
* Send a DELETE request and retain status/header metadata.
|
|
133
|
+
* @param path Plugin-scoped runtime API path.
|
|
134
|
+
* @param options Optional request settings.
|
|
135
|
+
* @returns Decoded payload plus response metadata.
|
|
136
|
+
*/
|
|
137
|
+
deleteWithMeta<T>(path: string, options?: PluginApiRequestOptions): Promise<PluginApiResponseMeta<T>>;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Scoped translation API available to plugin code.
|
|
141
|
+
*/
|
|
142
|
+
type PluginI18nApi = ScopedI18nApi;
|
|
143
|
+
/**
|
|
144
|
+
* Authenticated or guest runtime session exposed to the current plugin.
|
|
145
|
+
*/
|
|
146
|
+
type PluginSession = RuntimeSession;
|
|
147
|
+
/**
|
|
148
|
+
* Guest-only lifecycle capability supplied by the host. Authenticated plugin
|
|
149
|
+
* runtimes do not receive this object. The host owns the concrete session
|
|
150
|
+
* transport so plugins can safely finish/reset a public or kiosk interaction
|
|
151
|
+
* without reaching into shell internals.
|
|
152
|
+
*/
|
|
153
|
+
type PluginGuestSessionApi = {
|
|
154
|
+
/**
|
|
155
|
+
* Guest session mode selected by the host.
|
|
156
|
+
*/
|
|
157
|
+
mode: "public" | "kiosk";
|
|
158
|
+
/**
|
|
159
|
+
* Guest exposure key associated with the current public or kiosk session.
|
|
160
|
+
*/
|
|
161
|
+
exposureKey: string;
|
|
162
|
+
/**
|
|
163
|
+
* Reset/finish the current guest interaction and clear host-managed guest session state.
|
|
164
|
+
*
|
|
165
|
+
* @returns Completes when the operation finishes.
|
|
166
|
+
*/
|
|
167
|
+
reset(): Promise<void>;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Stable identity and version of the plugin currently being rendered.
|
|
171
|
+
*/
|
|
172
|
+
type PluginIdentity = {
|
|
173
|
+
/**
|
|
174
|
+
* Stable plugin identifier.
|
|
175
|
+
*/
|
|
176
|
+
identifier: string;
|
|
177
|
+
/**
|
|
178
|
+
* Plugin package/runtime version.
|
|
179
|
+
*/
|
|
180
|
+
version: string;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Options controlling router-agnostic plugin navigation.
|
|
184
|
+
*/
|
|
185
|
+
type PluginNavigationOptions = {
|
|
186
|
+
/**
|
|
187
|
+
* Replace the current history entry instead of pushing a new one.
|
|
188
|
+
*/
|
|
189
|
+
replace?: boolean;
|
|
190
|
+
};
|
|
191
|
+
/** Router-agnostic client navigation supplied by the host runtime. */
|
|
192
|
+
type PluginNavigationApi = {
|
|
193
|
+
/**
|
|
194
|
+
* Navigate to a host route without depending on a specific router implementation.
|
|
195
|
+
*
|
|
196
|
+
* @param to Destination path understood by the host navigation adapter.
|
|
197
|
+
* @param options Optional settings for this operation.
|
|
198
|
+
* @returns Completes when the operation finishes.
|
|
199
|
+
*/
|
|
200
|
+
navigate(to: string, options?: PluginNavigationOptions): void | Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Deliberately leave the application for an external HTTPS identity provider.
|
|
203
|
+
* This is NOT SPA route navigation. The host validates the URL and performs
|
|
204
|
+
* the document-level redirect. Optional for non-browser/test hosts.
|
|
205
|
+
*/
|
|
206
|
+
navigateExternal?(url: string): void | Promise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* Return the current pathname, query and hash as exposed by the host.
|
|
209
|
+
*
|
|
210
|
+
* @returns Result returned by currentPath.
|
|
211
|
+
*/
|
|
212
|
+
currentPath(): string;
|
|
213
|
+
/** Optional host route subscription used by router-agnostic SDK hooks. */
|
|
214
|
+
/**
|
|
215
|
+
* @param listener Callback invoked when the host route changes.
|
|
216
|
+
* @returns Result returned by subscribe.
|
|
217
|
+
*/
|
|
218
|
+
subscribe?(listener: () => void): () => void;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Extension-runtime capabilities exposed to ordinary plugin code.
|
|
222
|
+
*/
|
|
223
|
+
/** A safe, resource-scoped change indication. No run inputs/outputs are streamed. */
|
|
224
|
+
type PluginWorkflowRunChange = {
|
|
225
|
+
eventId: string;
|
|
226
|
+
cursor: string;
|
|
227
|
+
runPid: string;
|
|
228
|
+
status: WorkflowRunStatus;
|
|
229
|
+
};
|
|
230
|
+
type PluginWorkflowRunRealtimeStatus = "connecting" | "recovering" | "live" | "disconnected" | "error";
|
|
231
|
+
type PluginWorkflowRunSubscription = {
|
|
232
|
+
/** Await the domain refresh before the gateway cursor is acknowledged. */
|
|
233
|
+
onChange: (change: PluginWorkflowRunChange) => Promise<void> | void;
|
|
234
|
+
onResync: (reason: string) => Promise<void>;
|
|
235
|
+
onStatus?: (status: PluginWorkflowRunRealtimeStatus) => void;
|
|
236
|
+
onError?: (code: string) => void;
|
|
237
|
+
};
|
|
238
|
+
/** A scope-level change hint, with no run UUID or sensitive run data. */
|
|
239
|
+
type PluginWorkflowListChange = {
|
|
240
|
+
eventId: string;
|
|
241
|
+
cursor: string;
|
|
242
|
+
};
|
|
243
|
+
type PluginWorkflowListSubscription = {
|
|
244
|
+
/** MUST refresh the authoritative filtered list/overview before resolving. */
|
|
245
|
+
onChange: (change: PluginWorkflowListChange) => Promise<void> | void;
|
|
246
|
+
onResync: (reason: string) => Promise<void>;
|
|
247
|
+
onStatus?: (status: PluginWorkflowRunRealtimeStatus) => void;
|
|
248
|
+
onError?: (code: string) => void;
|
|
249
|
+
};
|
|
250
|
+
/** The host authorizes each run or the whole run-list scope. Plugins never
|
|
251
|
+
* receive socket handles, access tokens, or a user-selectable scope. */
|
|
252
|
+
type PluginWorkflowRealtimeApi = {
|
|
253
|
+
subscribeRun(runPid: string, handlers: PluginWorkflowRunSubscription): () => void;
|
|
254
|
+
subscribeList(handlers: PluginWorkflowListSubscription): () => void;
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Project the canonical Core SDK client signatures into the host-controlled
|
|
258
|
+
* capability without re-declaring 89 method/response contracts. The host binds
|
|
259
|
+
* scope; plugin code never supplies or chooses it.
|
|
260
|
+
*
|
|
261
|
+
* These transformations are private type machinery, not public SDK helpers.
|
|
262
|
+
*/
|
|
263
|
+
type CoreWorkflowApi = ReturnType<typeof createWorkflowApi>;
|
|
264
|
+
type CoreManagedResourceApi = ReturnType<typeof createManagedResourceApi>;
|
|
265
|
+
type BoundScopeFirst<F> = F extends (scopeKind: string, scopeKey: string, ...args: infer Args) => infer Result ? (...args: Args) => Result : never;
|
|
266
|
+
type BoundScopeAfterPid<F> = F extends (pid: string, scopeKind: string, scopeKey: string, ...args: infer Args) => infer Result ? (pid: string, ...args: Args) => Result : never;
|
|
267
|
+
type BoundScopeAfterPidAndVersion<F> = F extends (pid: string, version: number, scopeKind: string, scopeKey: string, ...args: infer Args) => infer Result ? (pid: string, version: number, ...args: Args) => Result : never;
|
|
268
|
+
type BoundScopeInput<F> = F extends (input: infer Input) => infer Result ? (input: Omit<Input, "scopeKind" | "scopeKey">) => Result : never;
|
|
269
|
+
type BoundScopeAfterPidInput<F> = F extends (pid: infer Pid, input: infer Input) => infer Result ? (pid: Pid, input: Omit<Input, "scopeKind" | "scopeKey">) => Result : never;
|
|
270
|
+
type BoundScopeQuery<F> = F extends (query: infer Query) => infer Result ? (query?: Omit<Query, "scopeKind" | "scopeKey">) => Result : never;
|
|
271
|
+
type BoundResourceScope<F> = F extends (scope: ManagedResourceScope, ...args: infer Args) => infer Result ? (...args: Args) => Result : never;
|
|
272
|
+
type WorkflowScopeFirst = "listWorkflows" | "listTriggerRegistrations" | "listScheduleRegistrations" | "listWebhookRegistrations" | "listNodeTypes" | "getOperationsOverview" | "getAnalytics" | "getWorkflowSettings" | "updateWorkflowSettings" | "runWorkflowRetentionSweep" | "listWorkflowOperations" | "listCustomEventContracts" | "listApprovalTasks" | "listTemplates" | "listConfigVariables";
|
|
273
|
+
type WorkflowScopeAfterPid = "getTriggerActivity" | "setTriggerOperationalEnabled" | "setScheduleOperationalEnabled" | "setWebhookOperationalEnabled" | "rotateWebhookCredential" | "getCustomEventContract" | "updateCustomEventContract" | "deleteCustomEventContract" | "getCustomEventContractUsage" | "getCustomEventContractHistory" | "getApprovalTask" | "decideApprovalTask" | "getTemplate" | "createTemplateVersion" | "getConfigVariable" | "updateConfigVariable" | "deleteConfigVariable" | "getConfigVariableUsage" | "getConfigVariableHistory";
|
|
274
|
+
type WorkflowScopeInput = "createWorkflow" | "importWorkflow" | "createCustomEventContract" | "createTemplate" | "importTemplate" | "createConfigVariable";
|
|
275
|
+
type WorkflowHostMethodName<K> = K extends "listTriggerRegistrations" ? "listTriggers" : K extends "setTriggerOperationalEnabled" ? "setTriggerEnabled" : K extends "listScheduleRegistrations" ? "listSchedules" : K extends "setScheduleOperationalEnabled" ? "setScheduleEnabled" : K extends "listWebhookRegistrations" ? "listWebhooks" : K extends "setWebhookOperationalEnabled" ? "setWebhookEnabled" : K;
|
|
276
|
+
/**
|
|
277
|
+
* Narrow host-owned Workflow management capability. The key aliases are the
|
|
278
|
+
* original plugin-facing names, not raw operational Core SDK endpoint names.
|
|
279
|
+
*/
|
|
280
|
+
type PluginWorkflowManagementApi = {
|
|
281
|
+
-readonly [K in keyof CoreWorkflowApi as WorkflowHostMethodName<K>]: K extends WorkflowScopeFirst ? BoundScopeFirst<CoreWorkflowApi[K]> : K extends WorkflowScopeAfterPid ? BoundScopeAfterPid<CoreWorkflowApi[K]> : K extends "getTemplateVersion" | "exportTemplate" ? BoundScopeAfterPidAndVersion<CoreWorkflowApi[K]> : K extends WorkflowScopeInput ? BoundScopeInput<CoreWorkflowApi[K]> : K extends "instantiateTemplate" ? BoundScopeAfterPidInput<CoreWorkflowApi[K]> : K extends "listRuns" ? BoundScopeQuery<CoreWorkflowApi[K]> : CoreWorkflowApi[K];
|
|
282
|
+
};
|
|
283
|
+
type ResourceScopeFirst = "listConnections" | "getConnection" | "setConnectionEnabled" | "setConnectionSecret" | "deleteConnectionSecret" | "testConnection" | "reconnectConnection" | "startConnectionOAuth" | "getConnectionOAuthStatus" | "disconnectConnectionOAuth" | "getConnectionUsage" | "getConnectionDefault" | "setConnectionDefault" | "clearConnectionDefault" | "deleteConnection";
|
|
284
|
+
/**
|
|
285
|
+
* Host-mediated management of reusable platform resources, independent of
|
|
286
|
+
* Workflow. Scope stays host-owned and secrets remain write-only.
|
|
287
|
+
*/
|
|
288
|
+
type PluginManagedResourceApi = {
|
|
289
|
+
-readonly [K in keyof CoreManagedResourceApi]: K extends ResourceScopeFirst ? BoundResourceScope<CoreManagedResourceApi[K]> : K extends "upsertConnection" ? BoundScopeInput<CoreManagedResourceApi[K]> : CoreManagedResourceApi[K];
|
|
290
|
+
};
|
|
291
|
+
type PluginExtensionsApi = Pick<UiExtensionRuntime, "registerSurface" | "renderUi" | "resolveUi" | "runOperation" | "emitEvent" | "resolveProviders" | "reportDiagnostic">;
|
|
292
|
+
/**
|
|
293
|
+
* Host-supplied runtime context used to create and render one plugin instance.
|
|
294
|
+
*/
|
|
295
|
+
type PluginRenderContext = {
|
|
296
|
+
/**
|
|
297
|
+
* Plugin identifier or plugin identity associated with this value.
|
|
298
|
+
*/
|
|
299
|
+
plugin: PluginIdentity;
|
|
300
|
+
/**
|
|
301
|
+
* Plugin-scoped API client.
|
|
302
|
+
*/
|
|
303
|
+
api?: PluginApiClient;
|
|
304
|
+
/**
|
|
305
|
+
* Plugin-scoped internationalization API.
|
|
306
|
+
*/
|
|
307
|
+
i18n: PluginI18nApi;
|
|
308
|
+
/**
|
|
309
|
+
* Current runtime session.
|
|
310
|
+
*/
|
|
311
|
+
session: PluginSession;
|
|
312
|
+
/**
|
|
313
|
+
* Guest-session lifecycle API when running in guest mode.
|
|
314
|
+
*/
|
|
315
|
+
guest?: PluginGuestSessionApi;
|
|
316
|
+
/**
|
|
317
|
+
* Host navigation capability.
|
|
318
|
+
*/
|
|
319
|
+
navigation?: PluginNavigationApi;
|
|
320
|
+
/** Host-mediated workflow management, supplied only to trusted workflow authoring surfaces. */
|
|
321
|
+
workflows?: PluginWorkflowManagementApi;
|
|
322
|
+
/** Optional host-owned workflow run realtime subscription capability. */
|
|
323
|
+
workflowRealtime?: PluginWorkflowRealtimeApi;
|
|
324
|
+
/** Host-mediated shared resource management, supplied only to trusted composition surfaces. */
|
|
325
|
+
managedResources?: PluginManagedResourceApi;
|
|
326
|
+
/**
|
|
327
|
+
* Extension-runtime capability set.
|
|
328
|
+
*/
|
|
329
|
+
extensions?: PluginExtensionsApi;
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* React component type exported by a federated plugin module.
|
|
333
|
+
*/
|
|
334
|
+
type FederatedPlugin = ComponentType;
|
|
335
|
+
/**
|
|
336
|
+
* Stable diagnostic codes emitted by the frontend extension runtime.
|
|
337
|
+
*/
|
|
338
|
+
type ExtensionRuntimeErrorCode = "extension_load_failed" | "extension_contract_invalid" | "extension_visibility_failed" | "extension_order_failed" | "extension_render_failed" | "operation_hook_load_failed" | "operation_hook_failed" | "event_handler_load_failed" | "event_handler_failed" | "provider_load_failed" | "provider_failed";
|
|
339
|
+
/**
|
|
340
|
+
* Structured diagnostic emitted when extension loading or execution cannot complete normally.
|
|
341
|
+
*/
|
|
342
|
+
type ExtensionRuntimeDiagnostic = {
|
|
343
|
+
/**
|
|
344
|
+
* Stable machine-readable code.
|
|
345
|
+
*/
|
|
346
|
+
code: ExtensionRuntimeErrorCode;
|
|
347
|
+
/**
|
|
348
|
+
* Human-readable diagnostic/error message.
|
|
349
|
+
*/
|
|
350
|
+
message: string;
|
|
351
|
+
/**
|
|
352
|
+
* Stable runtime extension identifier.
|
|
353
|
+
*/
|
|
354
|
+
extensionId: string;
|
|
355
|
+
/**
|
|
356
|
+
* Identifier of the plugin associated with this operation.
|
|
357
|
+
*/
|
|
358
|
+
pluginIdentifier: string;
|
|
359
|
+
/**
|
|
360
|
+
* Optional structured diagnostic details.
|
|
361
|
+
*/
|
|
362
|
+
details?: unknown;
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Runtime context supplied to UI extension lifecycle callbacks.
|
|
366
|
+
*/
|
|
367
|
+
type ExtensionLifecycleContext = {
|
|
368
|
+
/**
|
|
369
|
+
* Scoped plugin render context.
|
|
370
|
+
*/
|
|
371
|
+
context: PluginRenderContext;
|
|
372
|
+
/**
|
|
373
|
+
* Normalized runtime extension descriptor being executed.
|
|
374
|
+
*/
|
|
375
|
+
extension: RuntimeUiExtension;
|
|
376
|
+
/**
|
|
377
|
+
* Semantic extension surface.
|
|
378
|
+
*/
|
|
379
|
+
surface: ExtensionSurface;
|
|
380
|
+
/**
|
|
381
|
+
* Stable semantic key identifying the concrete surface.
|
|
382
|
+
*/
|
|
383
|
+
surfaceKey: string;
|
|
384
|
+
/**
|
|
385
|
+
* Extension point within the surface.
|
|
386
|
+
*/
|
|
387
|
+
point: string;
|
|
388
|
+
/** Concrete mounted instance identity; never part of public target matching. */
|
|
389
|
+
instanceKey?: string;
|
|
390
|
+
/** Runtime-only owner context for the concrete mounted instance. */
|
|
391
|
+
extensionContext?: unknown;
|
|
392
|
+
/**
|
|
393
|
+
* Current host route path when known.
|
|
394
|
+
*/
|
|
395
|
+
routePath?: string | null;
|
|
396
|
+
/** Aborted when the owning route/surface/instance becomes stale or unloads. */
|
|
397
|
+
signal: AbortSignal;
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* Lifecycle context plus the payload supplied to a renderable extension.
|
|
401
|
+
*/
|
|
402
|
+
type ExtensionRenderContext<TPayload = unknown> = ExtensionLifecycleContext & {
|
|
403
|
+
/** Payload supplied by the host surface or operation for this extension resolution. */
|
|
404
|
+
payload?: TPayload;
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* Structured-contribution context with the plugin-scoped translation function.
|
|
408
|
+
*/
|
|
409
|
+
type ExtensionContributionContext<TPayload = unknown> = ExtensionRenderContext<TPayload> & {
|
|
410
|
+
/**
|
|
411
|
+
* Plugin-scoped translation function.
|
|
412
|
+
*/
|
|
413
|
+
t: ScopedI18nApi["t"];
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* Lifecycle hooks that apply to every registered extension module.
|
|
417
|
+
*/
|
|
418
|
+
type ExtensionRegistrationLifecycleHooks = {
|
|
419
|
+
/** Exactly once after a successful registration within one resolver generation. */
|
|
420
|
+
/**
|
|
421
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
422
|
+
* @returns Completes when the operation finishes.
|
|
423
|
+
*/
|
|
424
|
+
onRegister?(context: ExtensionLifecycleContext): void | Promise<void>;
|
|
425
|
+
};
|
|
426
|
+
/** Lifecycle available only to extensions with a real React mount lifetime. */
|
|
427
|
+
type ExtensionLifecycleHooks = ExtensionRegistrationLifecycleHooks & {
|
|
428
|
+
/**
|
|
429
|
+
* Run when the resolved extension receives a real React mount lifetime.
|
|
430
|
+
*
|
|
431
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
432
|
+
* @returns Completes when the operation finishes.
|
|
433
|
+
*/
|
|
434
|
+
onMount?(context: ExtensionLifecycleContext): void | Promise<void>;
|
|
435
|
+
/**
|
|
436
|
+
* Run when the mounted extension is removed.
|
|
437
|
+
*
|
|
438
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
439
|
+
* @returns Completes when the operation finishes.
|
|
440
|
+
*/
|
|
441
|
+
onUnmount?(context: ExtensionLifecycleContext): void | Promise<void>;
|
|
442
|
+
};
|
|
443
|
+
type ExtensionModuleBase<TPayload = unknown, TLifecycle extends ExtensionRegistrationLifecycleHooks = ExtensionRegistrationLifecycleHooks> = {
|
|
444
|
+
id?: string;
|
|
445
|
+
lifecycle?: TLifecycle;
|
|
446
|
+
visible?(context: ExtensionRenderContext<TPayload>): boolean | Promise<boolean>;
|
|
447
|
+
order?(context: ExtensionRenderContext<TPayload>): number | Promise<number>;
|
|
448
|
+
metadata?(context: ExtensionRenderContext<TPayload>): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
449
|
+
};
|
|
450
|
+
/**
|
|
451
|
+
* Runtime module contract for a UI extension that renders React content.
|
|
452
|
+
*/
|
|
453
|
+
type RenderableUiExtensionModule<TPayload = unknown> = ExtensionModuleBase<TPayload, ExtensionLifecycleHooks> & {
|
|
454
|
+
/**
|
|
455
|
+
* Render React content for the resolved UI extension.
|
|
456
|
+
*
|
|
457
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
458
|
+
* @returns Result returned by render.
|
|
459
|
+
*/
|
|
460
|
+
render(context: ExtensionRenderContext<TPayload>): ReactNode;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* Runtime module contract for a UI extension that contributes structured UI data.
|
|
464
|
+
*/
|
|
465
|
+
type StructuredUiExtensionModule<TContribution = unknown, TPayload = unknown> = ExtensionModuleBase<TPayload, ExtensionRegistrationLifecycleHooks> & {
|
|
466
|
+
/**
|
|
467
|
+
* Produce structured UI contribution data for the target collection point.
|
|
468
|
+
*
|
|
469
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
470
|
+
* @returns Result returned by contribute.
|
|
471
|
+
*/
|
|
472
|
+
contribute(context: ExtensionContributionContext<TPayload>): TContribution | Promise<TContribution>;
|
|
473
|
+
};
|
|
474
|
+
/**
|
|
475
|
+
* Field-level validation failure returned by an operation validation hook.
|
|
476
|
+
*/
|
|
477
|
+
type FieldValidationIssue = {
|
|
478
|
+
/**
|
|
479
|
+
* Entity field referenced by this filter/error.
|
|
480
|
+
*/
|
|
481
|
+
field: string;
|
|
482
|
+
/**
|
|
483
|
+
* Human-readable diagnostic/error message.
|
|
484
|
+
*/
|
|
485
|
+
message: string;
|
|
486
|
+
/**
|
|
487
|
+
* Stable machine-readable code.
|
|
488
|
+
*/
|
|
489
|
+
code?: string;
|
|
490
|
+
};
|
|
491
|
+
type OperationHookContext<TPayload = unknown, TResult = unknown> = {
|
|
492
|
+
context: PluginRenderContext;
|
|
493
|
+
extension: RuntimeOperationHookExtension;
|
|
494
|
+
surface: ExtensionSurface;
|
|
495
|
+
surfaceKey: string;
|
|
496
|
+
instanceKey?: string;
|
|
497
|
+
extensionContext?: unknown;
|
|
498
|
+
operation: string;
|
|
499
|
+
phase: OperationExtensionPhase;
|
|
500
|
+
payload: TPayload;
|
|
501
|
+
result?: TResult;
|
|
502
|
+
error?: unknown;
|
|
503
|
+
signal?: AbortSignal;
|
|
504
|
+
};
|
|
505
|
+
type OperationDecision<TPayload = unknown, TResult = unknown> = {
|
|
506
|
+
kind: "continue";
|
|
507
|
+
payload?: TPayload;
|
|
508
|
+
} | {
|
|
509
|
+
kind: "cancel";
|
|
510
|
+
result?: TResult;
|
|
511
|
+
} | {
|
|
512
|
+
kind: "replace";
|
|
513
|
+
result: TResult;
|
|
514
|
+
};
|
|
515
|
+
/**
|
|
516
|
+
* Optional phase handlers implemented by an operation-hook extension.
|
|
517
|
+
*/
|
|
518
|
+
type OperationHookModule<TPayload = unknown, TResult = unknown> = {
|
|
519
|
+
/**
|
|
520
|
+
* Normalize the operation payload before validation/execution.
|
|
521
|
+
*
|
|
522
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
523
|
+
* @returns Result returned by normalize.
|
|
524
|
+
*/
|
|
525
|
+
normalize?(context: OperationHookContext<TPayload, TResult>): TPayload | Promise<TPayload>;
|
|
526
|
+
/**
|
|
527
|
+
* Validate the operation payload and return field-level issues.
|
|
528
|
+
*
|
|
529
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
530
|
+
* @returns Result returned by validate.
|
|
531
|
+
*/
|
|
532
|
+
validate?(context: OperationHookContext<TPayload, TResult>): FieldValidationIssue[] | null | Promise<FieldValidationIssue[] | null>;
|
|
533
|
+
/**
|
|
534
|
+
* Run before the owner operation and optionally continue, cancel or replace it.
|
|
535
|
+
*
|
|
536
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
537
|
+
* @returns Result returned by before.
|
|
538
|
+
*/
|
|
539
|
+
before?(context: OperationHookContext<TPayload, TResult>): OperationDecision<TPayload, TResult> | Promise<OperationDecision<TPayload, TResult>>;
|
|
540
|
+
/**
|
|
541
|
+
* Run after the owner operation and optionally replace its result.
|
|
542
|
+
*
|
|
543
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
544
|
+
* @returns Result returned by after.
|
|
545
|
+
*/
|
|
546
|
+
after?(context: OperationHookContext<TPayload, TResult>): void | TResult | Promise<void | TResult>;
|
|
547
|
+
/**
|
|
548
|
+
* Observe an owner/hook failure before finalization.
|
|
549
|
+
*
|
|
550
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
551
|
+
* @returns Completes when the operation finishes.
|
|
552
|
+
*/
|
|
553
|
+
error?(context: OperationHookContext<TPayload, TResult>): void | Promise<void>;
|
|
554
|
+
/**
|
|
555
|
+
* Run after the operation regardless of success or failure.
|
|
556
|
+
*
|
|
557
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
558
|
+
* @returns Completes when the operation finishes.
|
|
559
|
+
*/
|
|
560
|
+
finally?(context: OperationHookContext<TPayload, TResult>): void | Promise<void>;
|
|
561
|
+
};
|
|
562
|
+
/**
|
|
563
|
+
* Runtime module contract for an event-handler extension.
|
|
564
|
+
*/
|
|
565
|
+
type EventHandlerModule<TPayload = unknown> = {
|
|
566
|
+
/**
|
|
567
|
+
* Handle one event emitted by the targeted host contract.
|
|
568
|
+
*
|
|
569
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
570
|
+
* @returns Completes when the operation finishes.
|
|
571
|
+
*/
|
|
572
|
+
handle(context: {
|
|
573
|
+
context: PluginRenderContext;
|
|
574
|
+
extension: RuntimeEventHandlerExtension;
|
|
575
|
+
event: string;
|
|
576
|
+
payload: TPayload;
|
|
577
|
+
signal?: AbortSignal;
|
|
578
|
+
}): void | Promise<void>;
|
|
579
|
+
};
|
|
580
|
+
/**
|
|
581
|
+
* Runtime module contract for a provider extension.
|
|
582
|
+
*/
|
|
583
|
+
type ProviderModule<TRequest = unknown, TValue = unknown> = {
|
|
584
|
+
/**
|
|
585
|
+
* Resolve a value for one provider request.
|
|
586
|
+
*
|
|
587
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
588
|
+
* @returns Result returned by provide.
|
|
589
|
+
*/
|
|
590
|
+
provide(context: {
|
|
591
|
+
context: PluginRenderContext;
|
|
592
|
+
extension: RuntimeProviderExtension;
|
|
593
|
+
provider: string;
|
|
594
|
+
request: TRequest;
|
|
595
|
+
signal?: AbortSignal;
|
|
596
|
+
}): TValue | Promise<TValue>;
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
export type { ExtensionRenderContext as A, ExtensionRuntimeDiagnostic as E, FederatedPlugin as F, OperationHookModule as O, PluginRenderContext as P, RenderableUiExtensionModule as R, StructuredUiExtensionModule as S, PluginApiClient as a, PluginI18nApi as b, PluginSession as c, PluginGuestSessionApi as d, PluginNavigationApi as e, PluginWorkflowManagementApi as f, PluginWorkflowRealtimeApi as g, PluginManagedResourceApi as h, PluginExtensionsApi as i, PluginApiRequestOptions as j, ExtensionRuntimeErrorCode as k, FieldValidationIssue as l, PluginApiResponseMeta as m, PluginIdentity as n, PluginNavigationOptions as o, PluginWorkflowListChange as p, PluginWorkflowListSubscription as q, PluginWorkflowRunChange as r, PluginWorkflowRunRealtimeStatus as s, PluginWorkflowRunSubscription as t, EventHandlerModule as u, ProviderModule as v, ExtensionLifecycleHooks as w, ExtensionContributionContext as x, ExtensionLifecycleContext as y, ExtensionRegistrationLifecycleHooks as z };
|