@cervio/plugin-sdk 1.0.0 → 1.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/README.md +9 -8
- package/dist/index.cjs +24 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +414 -15
- package/dist/index.d.ts +414 -15
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/dist/pdf/index.cjs +357 -0
- package/dist/pdf/index.cjs.map +1 -0
- package/dist/pdf/index.d.cts +38 -0
- package/dist/pdf/index.d.ts +38 -0
- package/dist/pdf/index.js +355 -0
- package/dist/pdf/index.js.map +1 -0
- package/package.json +26 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Publishable typed client mirroring `window.CervioUI` injected by the Cervio host.
|
|
3
|
-
* Docs: Admin
|
|
3
|
+
* Docs: https://docs.cervio.app/docs/plugins/ui (Admin Components = catalog + try-it only).
|
|
4
4
|
*
|
|
5
|
-
* `CERVIO_UI_API_VERSION` tracks the host `window.CervioUI.apiVersion`
|
|
6
|
-
*
|
|
5
|
+
* `CERVIO_UI_API_VERSION` tracks the host `window.CervioUI.apiVersion` wire
|
|
6
|
+
* contract (additive namespaces may ship in a package minor without bumping it).
|
|
7
7
|
*/
|
|
8
8
|
declare const CERVIO_UI_API_VERSION: "1.0.0";
|
|
9
9
|
type CervioUiToastType = 'success' | 'error' | 'warning' | 'info';
|
|
@@ -33,6 +33,11 @@ interface CervioUiFrameOpenOptions {
|
|
|
33
33
|
title?: string;
|
|
34
34
|
size?: CervioUiFrameSize;
|
|
35
35
|
showClose?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Optional body height in px (120–900) for `dialog.surface`.
|
|
38
|
+
* Host sizes the dialog to content; omit to let the surface report via `update`.
|
|
39
|
+
*/
|
|
40
|
+
height?: number;
|
|
36
41
|
}
|
|
37
42
|
interface CervioUiSurfaceOpenOptions extends CervioUiFrameOpenOptions {
|
|
38
43
|
/** Plain JSON forwarded to `dist/surface.html` on open (max ~64KB). */
|
|
@@ -56,6 +61,209 @@ interface CervioUiThemeSnapshot {
|
|
|
56
61
|
tokens: Record<string, string>;
|
|
57
62
|
colorScheme: 'dark' | 'light';
|
|
58
63
|
}
|
|
64
|
+
/** Host locale/date/number preferences pushed via `__cervioPluginFormat`; see `CervioUI.format.*`. */
|
|
65
|
+
interface CervioUiFormatSnapshot {
|
|
66
|
+
/** BCP47 tag (e.g. `it-IT`). */
|
|
67
|
+
locale: string;
|
|
68
|
+
dateFormat: 'dd/MM/yyyy' | 'MM/dd/yyyy' | 'yyyy-MM-dd';
|
|
69
|
+
decimalSeparator: ',' | '.';
|
|
70
|
+
thousandsSeparator: string;
|
|
71
|
+
/** IANA timezone (e.g. `Europe/Rome`). */
|
|
72
|
+
timeZone: string;
|
|
73
|
+
/** System UI locale (`NEXT_LOCALE`). */
|
|
74
|
+
uiLocale: 'it' | 'en';
|
|
75
|
+
}
|
|
76
|
+
/** Opaque file metadata: the `File`/blob never crosses postMessage. */
|
|
77
|
+
interface CervioUiFileMeta {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
mime: string;
|
|
81
|
+
size: number;
|
|
82
|
+
}
|
|
83
|
+
/** `{ id, label }` action used by `actionSheet.open`. */
|
|
84
|
+
interface CervioUiActionSheetAction {
|
|
85
|
+
id: string;
|
|
86
|
+
label: string;
|
|
87
|
+
variant?: CervioUiDialogVariant;
|
|
88
|
+
}
|
|
89
|
+
/** Wider variant set accepted by `sheet.open` (mirrors button variants). */
|
|
90
|
+
interface CervioUiSheetAction {
|
|
91
|
+
id: string;
|
|
92
|
+
label: string;
|
|
93
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost';
|
|
94
|
+
}
|
|
95
|
+
/** `{ value, label, subtitle? }` option resolved by domain pickers. */
|
|
96
|
+
interface CervioUiDomainPickOption {
|
|
97
|
+
value: string;
|
|
98
|
+
label: string;
|
|
99
|
+
subtitle?: string;
|
|
100
|
+
}
|
|
101
|
+
interface CervioUiActionSheetOpenOptions {
|
|
102
|
+
title?: string;
|
|
103
|
+
actions: CervioUiActionSheetAction[];
|
|
104
|
+
cancelLabel?: string;
|
|
105
|
+
}
|
|
106
|
+
interface CervioUiFilesPickOptions {
|
|
107
|
+
/** MIME types / extensions, e.g. `['image/*', '.pdf']`. Omit to allow the default document types. */
|
|
108
|
+
accept?: string[];
|
|
109
|
+
multiple?: boolean;
|
|
110
|
+
/** Default 20. */
|
|
111
|
+
maxFiles?: number;
|
|
112
|
+
/** Default: host document upload limit (50 MB). */
|
|
113
|
+
maxBytes?: number;
|
|
114
|
+
title?: string;
|
|
115
|
+
dropHint?: string;
|
|
116
|
+
pickLabel?: string;
|
|
117
|
+
}
|
|
118
|
+
interface CervioUiFilesCaptureOptions {
|
|
119
|
+
facing?: 'environment' | 'user';
|
|
120
|
+
title?: string;
|
|
121
|
+
}
|
|
122
|
+
interface CervioUiFilesPickResult {
|
|
123
|
+
files: CervioUiFileMeta[];
|
|
124
|
+
}
|
|
125
|
+
interface CervioUiFilesUploadOptions {
|
|
126
|
+
entityId: string;
|
|
127
|
+
recordId: string;
|
|
128
|
+
/** Ids returned by `files.pick` / `files.capture` - consumed on upload (removed from the host's in-memory store). */
|
|
129
|
+
fileIds: string[];
|
|
130
|
+
title?: string;
|
|
131
|
+
fileName?: string;
|
|
132
|
+
}
|
|
133
|
+
type CervioUiFilesUploadResult = {
|
|
134
|
+
ok: true;
|
|
135
|
+
documents: unknown[];
|
|
136
|
+
} | {
|
|
137
|
+
ok: false;
|
|
138
|
+
error: string;
|
|
139
|
+
};
|
|
140
|
+
interface CervioUiProgressShowOptions {
|
|
141
|
+
/** Plugin-chosen id; reuse it with `update` / `hide`. */
|
|
142
|
+
id: string;
|
|
143
|
+
label?: string;
|
|
144
|
+
/** 0-100; omit for an indeterminate bar. */
|
|
145
|
+
value?: number;
|
|
146
|
+
}
|
|
147
|
+
interface CervioUiProgressUpdateOptions {
|
|
148
|
+
id: string;
|
|
149
|
+
label?: string;
|
|
150
|
+
value?: number;
|
|
151
|
+
}
|
|
152
|
+
interface CervioUiDateOpenOptions {
|
|
153
|
+
title?: string;
|
|
154
|
+
/** ISO date (`yyyy-MM-dd`) or datetime string. */
|
|
155
|
+
value?: string;
|
|
156
|
+
mode?: 'date' | 'datetime';
|
|
157
|
+
min?: string;
|
|
158
|
+
max?: string;
|
|
159
|
+
/** Default true. */
|
|
160
|
+
clearable?: boolean;
|
|
161
|
+
}
|
|
162
|
+
interface CervioUiRecordPickOptions {
|
|
163
|
+
title?: string;
|
|
164
|
+
entityId?: string;
|
|
165
|
+
/** Resolved by exact match against entity name/label when `entityId` is omitted. */
|
|
166
|
+
entityName?: string;
|
|
167
|
+
value?: string;
|
|
168
|
+
/** Default true. */
|
|
169
|
+
searchable?: boolean;
|
|
170
|
+
}
|
|
171
|
+
interface CervioUiEntityPickOptions {
|
|
172
|
+
title?: string;
|
|
173
|
+
value?: string;
|
|
174
|
+
}
|
|
175
|
+
interface CervioUiUserPickOptions {
|
|
176
|
+
title?: string;
|
|
177
|
+
value?: string;
|
|
178
|
+
}
|
|
179
|
+
interface CervioUiGroupPickOptions {
|
|
180
|
+
title?: string;
|
|
181
|
+
value?: string;
|
|
182
|
+
}
|
|
183
|
+
interface CervioUiSheetOpenOptions {
|
|
184
|
+
title?: string;
|
|
185
|
+
description?: string;
|
|
186
|
+
actions: CervioUiSheetAction[];
|
|
187
|
+
}
|
|
188
|
+
/** At least one of `title`, `text`, `url` is required. */
|
|
189
|
+
interface CervioUiShareOpenOptions {
|
|
190
|
+
title?: string;
|
|
191
|
+
text?: string;
|
|
192
|
+
/** Same-origin path starting with `/` (resolved to an absolute URL by the host). */
|
|
193
|
+
url?: string;
|
|
194
|
+
}
|
|
195
|
+
type CervioUiShareResult = {
|
|
196
|
+
ok: boolean;
|
|
197
|
+
fallback?: 'clipboard';
|
|
198
|
+
};
|
|
199
|
+
/** Exactly one of `fileId` / `url` is required. */
|
|
200
|
+
interface CervioUiPrintOpenOptions {
|
|
201
|
+
fileId?: string;
|
|
202
|
+
/** Same-origin path starting with `/`. */
|
|
203
|
+
url?: string;
|
|
204
|
+
}
|
|
205
|
+
/** Exactly one of `fileId` / `url` is required. */
|
|
206
|
+
interface CervioUiExportDownloadOptions {
|
|
207
|
+
fileId?: string;
|
|
208
|
+
/** Same-origin path starting with `/`. */
|
|
209
|
+
url?: string;
|
|
210
|
+
fileName?: string;
|
|
211
|
+
}
|
|
212
|
+
interface CervioUiNavConfirmLeaveOptions {
|
|
213
|
+
enabled: boolean;
|
|
214
|
+
message?: string;
|
|
215
|
+
}
|
|
216
|
+
interface CervioUiCameraOpenOptions {
|
|
217
|
+
title?: string;
|
|
218
|
+
facing?: 'environment' | 'user';
|
|
219
|
+
}
|
|
220
|
+
interface CervioUiBarcodeScanOptions {
|
|
221
|
+
title?: string;
|
|
222
|
+
}
|
|
223
|
+
type CervioUiBarcodeScanResult = {
|
|
224
|
+
value: string;
|
|
225
|
+
format?: string;
|
|
226
|
+
} | null;
|
|
227
|
+
interface CervioUiLocationPickOptions {
|
|
228
|
+
title?: string;
|
|
229
|
+
}
|
|
230
|
+
interface CervioUiTaskOutcome {
|
|
231
|
+
value: string;
|
|
232
|
+
label: string;
|
|
233
|
+
}
|
|
234
|
+
interface CervioUiTaskSummary {
|
|
235
|
+
id: string;
|
|
236
|
+
status: string;
|
|
237
|
+
title: string;
|
|
238
|
+
outcomes: CervioUiTaskOutcome[];
|
|
239
|
+
entityDataId: string | null;
|
|
240
|
+
canComplete: boolean;
|
|
241
|
+
blockReason: string | null;
|
|
242
|
+
requiresFullView: boolean;
|
|
243
|
+
}
|
|
244
|
+
interface CervioUiTaskListItem {
|
|
245
|
+
id: string;
|
|
246
|
+
title: string;
|
|
247
|
+
outcomes: CervioUiTaskOutcome[];
|
|
248
|
+
status: string;
|
|
249
|
+
}
|
|
250
|
+
interface CervioUiTaskCompleteOptions {
|
|
251
|
+
taskId: string;
|
|
252
|
+
outcomeKey: string;
|
|
253
|
+
response?: Record<string, unknown>;
|
|
254
|
+
}
|
|
255
|
+
interface CervioUiTaskCompleteResult {
|
|
256
|
+
taskCompleted: boolean;
|
|
257
|
+
}
|
|
258
|
+
interface CervioUiTaskOpenResult {
|
|
259
|
+
completed: boolean;
|
|
260
|
+
outcomeKey?: string;
|
|
261
|
+
}
|
|
262
|
+
type CervioUiLocationResult = {
|
|
263
|
+
lat: number;
|
|
264
|
+
lng: number;
|
|
265
|
+
accuracy?: number;
|
|
266
|
+
} | null;
|
|
59
267
|
interface CervioUI {
|
|
60
268
|
apiVersion: typeof CERVIO_UI_API_VERSION;
|
|
61
269
|
capabilities(): Promise<string[]>;
|
|
@@ -88,6 +296,7 @@ interface CervioUI {
|
|
|
88
296
|
}>;
|
|
89
297
|
update(opts: {
|
|
90
298
|
title?: string;
|
|
299
|
+
height?: number;
|
|
91
300
|
}): Promise<{
|
|
92
301
|
ok: true;
|
|
93
302
|
}>;
|
|
@@ -115,6 +324,131 @@ interface CervioUI {
|
|
|
115
324
|
theme: {
|
|
116
325
|
get(): CervioUiThemeSnapshot | null;
|
|
117
326
|
};
|
|
327
|
+
/** Host locale/date/number prefs (`__cervioPluginFormat`). `date`/`dateTime`/`number`/`currency` format client-side, no RPC. */
|
|
328
|
+
format: {
|
|
329
|
+
/** Last host format push (seeded from `__CERVIO_PLUGIN_CONTEXT__.format`). */
|
|
330
|
+
get(): CervioUiFormatSnapshot;
|
|
331
|
+
date(value: unknown): string;
|
|
332
|
+
dateTime(value: unknown): string;
|
|
333
|
+
number(value: unknown, opts?: {
|
|
334
|
+
maxDecimals?: number;
|
|
335
|
+
}): string;
|
|
336
|
+
currency(value: unknown, currency?: string): string;
|
|
337
|
+
};
|
|
338
|
+
/** Host bottom sheet with a short list of tappable actions. */
|
|
339
|
+
actionSheet: {
|
|
340
|
+
open(opts: CervioUiActionSheetOpenOptions): Promise<string | null>;
|
|
341
|
+
};
|
|
342
|
+
/** Host file picker (pick/capture) and upload to an entity record; blobs never cross postMessage. */
|
|
343
|
+
files: {
|
|
344
|
+
pick(opts?: CervioUiFilesPickOptions): Promise<CervioUiFilesPickResult | null>;
|
|
345
|
+
capture(opts?: CervioUiFilesCaptureOptions): Promise<CervioUiFilesPickResult | null>;
|
|
346
|
+
upload(opts: CervioUiFilesUploadOptions): Promise<CervioUiFilesUploadResult>;
|
|
347
|
+
/** Experimental: image/PDF preview dialog for a previously picked/uploaded file. */
|
|
348
|
+
preview(opts: {
|
|
349
|
+
fileId: string;
|
|
350
|
+
}): Promise<{
|
|
351
|
+
ok: true;
|
|
352
|
+
}>;
|
|
353
|
+
/** Experimental: v1 pass-through - resolves the same fileId, no pixel manipulation yet. */
|
|
354
|
+
crop(opts: {
|
|
355
|
+
fileId: string;
|
|
356
|
+
}): Promise<string | null>;
|
|
357
|
+
};
|
|
358
|
+
/** Host top overlay stack of determinate/indeterminate progress bars keyed by plugin-chosen id. */
|
|
359
|
+
progress: {
|
|
360
|
+
show(opts: CervioUiProgressShowOptions): Promise<{
|
|
361
|
+
ok: true;
|
|
362
|
+
}>;
|
|
363
|
+
update(opts: CervioUiProgressUpdateOptions): Promise<{
|
|
364
|
+
ok: true;
|
|
365
|
+
}>;
|
|
366
|
+
hide(id: string): Promise<{
|
|
367
|
+
ok: true;
|
|
368
|
+
}>;
|
|
369
|
+
};
|
|
370
|
+
date: {
|
|
371
|
+
/** Host date / datetime picker; ISO in, ISO out. */
|
|
372
|
+
open(opts?: CervioUiDateOpenOptions): Promise<string | null>;
|
|
373
|
+
};
|
|
374
|
+
record: {
|
|
375
|
+
/** Host searchable picker over records of a given entity. */
|
|
376
|
+
pick(opts?: CervioUiRecordPickOptions): Promise<string | null>;
|
|
377
|
+
};
|
|
378
|
+
entity: {
|
|
379
|
+
/** Host searchable picker over entity types visible to the caller. */
|
|
380
|
+
pick(opts?: CervioUiEntityPickOptions): Promise<string | null>;
|
|
381
|
+
};
|
|
382
|
+
user: {
|
|
383
|
+
/** Host searchable picker over organization users. */
|
|
384
|
+
pick(opts?: CervioUiUserPickOptions): Promise<string | null>;
|
|
385
|
+
};
|
|
386
|
+
group: {
|
|
387
|
+
/** Host searchable picker over organization groups. */
|
|
388
|
+
pick(opts?: CervioUiGroupPickOptions): Promise<string | null>;
|
|
389
|
+
};
|
|
390
|
+
/** Host bottom sheet with title, description and a richer action variant set than `actionSheet`. */
|
|
391
|
+
sheet: {
|
|
392
|
+
open(opts: CervioUiSheetOpenOptions): Promise<string | null>;
|
|
393
|
+
};
|
|
394
|
+
/** Host-mediated clipboard write (sandboxed iframes cannot access the Clipboard API directly). */
|
|
395
|
+
clipboard: {
|
|
396
|
+
write(text: string): Promise<{
|
|
397
|
+
ok: boolean;
|
|
398
|
+
}>;
|
|
399
|
+
};
|
|
400
|
+
/** Host Web Share (falls back to clipboard copy when unsupported). */
|
|
401
|
+
share: {
|
|
402
|
+
open(opts: CervioUiShareOpenOptions): Promise<CervioUiShareResult>;
|
|
403
|
+
};
|
|
404
|
+
/** Host-driven print (fileId or same-origin url). */
|
|
405
|
+
print: {
|
|
406
|
+
open(opts: CervioUiPrintOpenOptions): Promise<{
|
|
407
|
+
ok: true;
|
|
408
|
+
}>;
|
|
409
|
+
};
|
|
410
|
+
/** Host-driven file download (fileId or same-origin url). */
|
|
411
|
+
export: {
|
|
412
|
+
download(opts: CervioUiExportDownloadOptions): Promise<{
|
|
413
|
+
ok: true;
|
|
414
|
+
}>;
|
|
415
|
+
};
|
|
416
|
+
/** Plugin-controlled "leave without saving?" confirmation on shell navigation / tab close. */
|
|
417
|
+
nav: {
|
|
418
|
+
confirmLeave(opts: CervioUiNavConfirmLeaveOptions): Promise<{
|
|
419
|
+
ok: true;
|
|
420
|
+
}>;
|
|
421
|
+
};
|
|
422
|
+
/** Experimental: host camera capture (getUserMedia), resolves a single photo file. */
|
|
423
|
+
camera: {
|
|
424
|
+
open(opts?: CervioUiCameraOpenOptions): Promise<CervioUiFileMeta | null>;
|
|
425
|
+
};
|
|
426
|
+
/** Experimental: host barcode/QR scan; rejects with `code: 'barcode_error'` on scan failure. */
|
|
427
|
+
barcode: {
|
|
428
|
+
scan(opts?: CervioUiBarcodeScanOptions): Promise<CervioUiBarcodeScanResult>;
|
|
429
|
+
};
|
|
430
|
+
/** Experimental: host geolocation lookup on explicit user action. */
|
|
431
|
+
location: {
|
|
432
|
+
pick(opts?: CervioUiLocationPickOptions): Promise<CervioUiLocationResult>;
|
|
433
|
+
};
|
|
434
|
+
/**
|
|
435
|
+
* Contextual workflow tasks for route plugins (assignee-gated complete).
|
|
436
|
+
* Rejects with `{ code, message }` for Unauthorized | Forbidden | task_not_open |
|
|
437
|
+
* already_responded | reassigned | workflow_not_active | invalid_outcome |
|
|
438
|
+
* variable_required | document_upload_required | record_link_required | in_flight.
|
|
439
|
+
*/
|
|
440
|
+
task: {
|
|
441
|
+
get(opts: {
|
|
442
|
+
taskId: string;
|
|
443
|
+
}): Promise<CervioUiTaskSummary>;
|
|
444
|
+
complete(opts: CervioUiTaskCompleteOptions): Promise<CervioUiTaskCompleteResult>;
|
|
445
|
+
open(opts: {
|
|
446
|
+
taskId: string;
|
|
447
|
+
}): Promise<CervioUiTaskOpenResult>;
|
|
448
|
+
listForRecord(opts: {
|
|
449
|
+
entityDataId: string;
|
|
450
|
+
}): Promise<CervioUiTaskListItem[]>;
|
|
451
|
+
};
|
|
118
452
|
}
|
|
119
453
|
declare global {
|
|
120
454
|
interface Window {
|
|
@@ -164,7 +498,7 @@ type CervioUiHostEvent = CervioUiFrameMetricsEvent | CervioUiFrameClosedEvent |
|
|
|
164
498
|
* Typed access to `window.__CERVIO_PLUGIN_CONTEXT__`, the boot payload the
|
|
165
499
|
* Cervio host injects into every route plugin `srcDoc` iframe.
|
|
166
500
|
*
|
|
167
|
-
* Docs:
|
|
501
|
+
* Docs: https://docs.cervio.app/docs/authoring ("Auth inside the iframe", "Plugin i18n /
|
|
168
502
|
* locale"). Field shape is set by `components/plugins/plugin-route-sandbox-host.tsx`.
|
|
169
503
|
*/
|
|
170
504
|
interface CervioPluginRuntimeSettings {
|
|
@@ -186,7 +520,7 @@ interface CervioPluginContext {
|
|
|
186
520
|
userLocale?: string;
|
|
187
521
|
mountedAt?: string;
|
|
188
522
|
/**
|
|
189
|
-
* Real app origin
|
|
523
|
+
* Real app origin - always set by the host. Use this for API base URLs.
|
|
190
524
|
* Never use `window.location.origin`: in sandboxed `srcDoc` iframes it
|
|
191
525
|
* frequently serializes as the literal string `"null"`.
|
|
192
526
|
*/
|
|
@@ -212,6 +546,8 @@ declare global {
|
|
|
212
546
|
__CERVIO_PLUGIN_CONTEXT__?: CervioPluginContext;
|
|
213
547
|
/** Host-mediated top-level navigation (OAuth consent, cross-plugin deep links). */
|
|
214
548
|
__cervioOpenExternalAuth?: (url: string) => boolean;
|
|
549
|
+
/** Same-route query/path sync without reloading the iframe (shareable deep links). */
|
|
550
|
+
__cervioSyncParentUrl?: (url: string, replace?: boolean) => boolean;
|
|
215
551
|
}
|
|
216
552
|
}
|
|
217
553
|
/** Returns the host boot payload, or `null` outside the Cervio sandbox. */
|
|
@@ -224,10 +560,71 @@ declare function isInsideCervioSandbox(): boolean;
|
|
|
224
560
|
*/
|
|
225
561
|
declare function openExternalAuth(url: string): boolean;
|
|
226
562
|
|
|
563
|
+
/**
|
|
564
|
+
* Typed access to the task-plugin boot payload + submit/draft bridge, injected
|
|
565
|
+
* by `components/plugins/task-plugin-sandbox-host.tsx` when a human-task node
|
|
566
|
+
* uses `taskUiMode: 'plugin'`. Shares the `window.__CERVIO_PLUGIN_CONTEXT__`
|
|
567
|
+
* global with route plugins (never both on one page, so no collision), but
|
|
568
|
+
* with a different shape — use these helpers rather than `getPluginContext()`.
|
|
569
|
+
*/
|
|
570
|
+
interface CervioTaskOutcome {
|
|
571
|
+
value: string;
|
|
572
|
+
label: string;
|
|
573
|
+
}
|
|
574
|
+
interface CervioTaskPluginContextData {
|
|
575
|
+
taskId: string;
|
|
576
|
+
workflowInstanceId: string;
|
|
577
|
+
entityDataId: string | null;
|
|
578
|
+
outcomes: CervioTaskOutcome[];
|
|
579
|
+
/** Allowlisted subset of workflow instance variables declared by the node's exposedVariables config — never the full workflow_instances.context. */
|
|
580
|
+
instanceVariables: Record<string, unknown>;
|
|
581
|
+
/**
|
|
582
|
+
* The task's last `setTaskDraft()` payload (`workflow_tasks.draft_response_payload`),
|
|
583
|
+
* or `null` when none was saved yet. Only one `TaskPluginSandboxHost` is ever
|
|
584
|
+
* mounted at a time (compact XOR expanded modal) — switching between them
|
|
585
|
+
* unmounts/remounts the plugin's iframe, discarding its in-memory state. A
|
|
586
|
+
* plugin that seeds its editable fields from extraction data on every mount
|
|
587
|
+
* (rather than from this draft first) silently reverts any edit made just
|
|
588
|
+
* before that remount, once its own re-seed reaches the host. Read this on
|
|
589
|
+
* mount and prefer it over re-deriving initial values from scratch.
|
|
590
|
+
*/
|
|
591
|
+
draft: Record<string, unknown> | null;
|
|
592
|
+
}
|
|
593
|
+
interface CervioTaskPluginBoot {
|
|
594
|
+
pluginType: 'task' | 'task_form';
|
|
595
|
+
/** UI hint only: true when this is a task_form plugin on an open task the viewer may complete. Server re-checks independently on every submit. */
|
|
596
|
+
canSubmit: boolean;
|
|
597
|
+
pluginContext: CervioTaskPluginContextData;
|
|
598
|
+
}
|
|
599
|
+
interface CervioTaskSubmitResult {
|
|
600
|
+
ok: boolean;
|
|
601
|
+
taskCompleted?: boolean;
|
|
602
|
+
error?: string;
|
|
603
|
+
}
|
|
604
|
+
interface CervioTaskDraftResult {
|
|
605
|
+
ok: boolean;
|
|
606
|
+
error?: string;
|
|
607
|
+
}
|
|
608
|
+
declare global {
|
|
609
|
+
interface Window {
|
|
610
|
+
__cervioTaskSetDraft?: (data: unknown) => Promise<CervioTaskDraftResult>;
|
|
611
|
+
__cervioTaskSubmit?: (outcomeKey: string, data?: unknown) => Promise<CervioTaskSubmitResult>;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/** Returns the task boot payload, or `null` outside a task-plugin sandbox. */
|
|
615
|
+
declare function getTaskPluginContext(): CervioTaskPluginBoot | null;
|
|
616
|
+
/** Incremental autosave (no completion). No-op outside a task-plugin sandbox. */
|
|
617
|
+
declare function setTaskDraft(data: Record<string, unknown>): Promise<CervioTaskDraftResult>;
|
|
618
|
+
/**
|
|
619
|
+
* Completes the task with the given outcome. Only works for `task_form`
|
|
620
|
+
* plugins — the host rejects the call server-side for plain `task` plugins.
|
|
621
|
+
*/
|
|
622
|
+
declare function submitTaskOutcome(outcomeKey: string, data?: Record<string, unknown>): Promise<CervioTaskSubmitResult>;
|
|
623
|
+
|
|
227
624
|
/**
|
|
228
625
|
* Typed wrapper around the host's `__cervioPluginTheme` postMessage push.
|
|
229
626
|
* The CervioUI inject script already applies host tokens to `document`
|
|
230
|
-
* automatically (`var(--background)`, etc.)
|
|
627
|
+
* automatically (`var(--background)`, etc.) - use this only when your plugin
|
|
231
628
|
* needs to *react* to a theme change in JS (e.g. re-render a canvas/chart).
|
|
232
629
|
*/
|
|
233
630
|
type CervioColorScheme = 'dark' | 'light';
|
|
@@ -255,12 +652,12 @@ declare function getCurrentTheme(): CervioThemeSnapshot | null;
|
|
|
255
652
|
* plugins and external scripts.
|
|
256
653
|
*
|
|
257
654
|
* Two flavors:
|
|
258
|
-
* - `createCervioClient`
|
|
259
|
-
* - `createCervioSessionClient`
|
|
655
|
+
* - `createCervioClient` - Bearer token (PAT / OAuth2 access token).
|
|
656
|
+
* - `createCervioSessionClient` - same-origin session cookies (typical when
|
|
260
657
|
* running inside the Cervio app shell iframe).
|
|
261
658
|
*
|
|
262
659
|
* Both resolve a missing `baseUrl` from `__CERVIO_PLUGIN_CONTEXT__.parentOrigin`
|
|
263
|
-
*
|
|
660
|
+
* - **never** from `window.location.origin`, which frequently serializes as
|
|
264
661
|
* the literal string `"null"` inside a sandboxed `srcDoc` iframe.
|
|
265
662
|
*/
|
|
266
663
|
interface Identity {
|
|
@@ -319,6 +716,8 @@ type ExternalConnectionStatus = {
|
|
|
319
716
|
account_email: string | null;
|
|
320
717
|
scopes: string[];
|
|
321
718
|
allowed_apis: unknown;
|
|
719
|
+
/** True when user has separate "product" (Profilo) connection for same builtin provider, but not this plugin's own. UX hint only, not auto-usable. */
|
|
720
|
+
has_product_connection?: boolean;
|
|
322
721
|
};
|
|
323
722
|
type ExternalProxyInput = {
|
|
324
723
|
/** Required when the manifest requirement allows more than one API host. */
|
|
@@ -369,7 +768,7 @@ declare function createCervioSessionClient(opts?: CervioSessionClientOptions): {
|
|
|
369
768
|
}) => Promise<{
|
|
370
769
|
records: EntityRecord[];
|
|
371
770
|
}>;
|
|
372
|
-
/** External Connections
|
|
771
|
+
/** External Connections - requires admin bind + `X-Cervio-Plugin-Key` (host injects on relay). */
|
|
373
772
|
connectionStatus: (connectionId: string) => Promise<ExternalConnectionStatus>;
|
|
374
773
|
connectionStart: (connectionId: string, returnTo?: string) => Promise<{
|
|
375
774
|
authorizeUrl?: string;
|
|
@@ -396,14 +795,14 @@ type CervioListRecordsClient = {
|
|
|
396
795
|
};
|
|
397
796
|
/** Total visible records for the caller (paginates until exhausted; cap 200k). */
|
|
398
797
|
declare function countVisibleRecords(api: CervioListRecordsClient, entityId: string, pageSize?: number): Promise<number>;
|
|
399
|
-
/** Find an entity by technical name (case-insensitive)
|
|
798
|
+
/** Find an entity by technical name (case-insensitive) - prefer names over hard-coded UUIDs. */
|
|
400
799
|
declare function findEntityByName(entities: Entity[], technicalName: string): Entity | undefined;
|
|
401
800
|
|
|
402
801
|
/**
|
|
403
802
|
* Minimal i18n helper for route plugins. Route plugins run in a sandboxed
|
|
404
803
|
* `srcDoc` iframe: next-intl / `public/locales` are not available, so ship
|
|
405
804
|
* your own catalogs in the ZIP and resolve the active locale from the host
|
|
406
|
-
* bootstrap. See
|
|
805
|
+
* bootstrap. See https://docs.cervio.app/docs/authoring → "Plugin i18n / locale".
|
|
407
806
|
*
|
|
408
807
|
* Resolve order (mandatory):
|
|
409
808
|
* 1. host locale (`__CERVIO_PLUGIN_CONTEXT__.locale`), if enabled for this plugin
|
|
@@ -417,10 +816,10 @@ interface ResolvePluginLocaleOptions {
|
|
|
417
816
|
availableLocales: string[];
|
|
418
817
|
defaultLocale: string;
|
|
419
818
|
}
|
|
420
|
-
/** Resolve order only
|
|
819
|
+
/** Resolve order only - does not read message catalogs. */
|
|
421
820
|
declare function resolvePluginLocale(opts: ResolvePluginLocaleOptions): string;
|
|
422
821
|
interface CreateI18nOptions {
|
|
423
|
-
/** `{ it: { toolbar: { newEntry: '...' } }, en: { ... } }`
|
|
822
|
+
/** `{ it: { toolbar: { newEntry: '...' } }, en: { ... } }` - identical key sets. */
|
|
424
823
|
messages: CervioI18nCatalog;
|
|
425
824
|
defaultLocale: string;
|
|
426
825
|
/** Defaults to `Object.keys(messages)`. */
|
|
@@ -439,4 +838,4 @@ interface CervioI18n {
|
|
|
439
838
|
/** Build a small `t()` + locale resolver from bundled catalogs. */
|
|
440
839
|
declare function createI18n(opts: CreateI18nOptions): CervioI18n;
|
|
441
840
|
|
|
442
|
-
export { CERVIO_UI_API_VERSION, CervioApiError, type CervioClient, type CervioClientOptions, type CervioColorScheme, type CervioHostThemeMessage, type CervioI18n, type CervioI18nCatalog, type CervioI18nMessages, type CervioListRecordsClient, type CervioPluginContext, type CervioPluginRuntimeSettings, type CervioSessionClient, type CervioSessionClientOptions, type CervioThemeChangeHandler, type CervioThemeSnapshot, type CervioUI, type CervioUiAlertOptions, type CervioUiConfirmOptions, type CervioUiDialogVariant, type CervioUiFrameClosedEvent, type CervioUiFrameMetricsEvent, type CervioUiFrameOpenOptions, type CervioUiFrameSize, type CervioUiFrameSlot, type CervioUiHostEvent, type CervioUiSelectOpenOptions, type CervioUiSelectOption, type CervioUiSurfaceClosedEvent, type CervioUiSurfaceMessageEvent, type CervioUiSurfaceOpenOptions, type CervioUiSurfaceOpenedEvent, type CervioUiThemeSnapshot, type CervioUiToastOptions, type CervioUiToastType, type CreateI18nOptions, type Entity, type EntityCapabilities, type EntityRecord, type ExternalConnectionStatus, type ExternalProxyInput, type Identity, type ResolvePluginLocaleOptions, countVisibleRecords, createCervioClient, createCervioSessionClient, createI18n, ensureExternalConnection, findEntityByName, getCervioUI, getCurrentTheme, getPluginContext, isCervioUIAvailable, isInsideCervioSandbox, onThemeChange, openExternalAuth, resolveApiBaseUrl, resolvePluginLocale };
|
|
841
|
+
export { CERVIO_UI_API_VERSION, CervioApiError, type CervioClient, type CervioClientOptions, type CervioColorScheme, type CervioHostThemeMessage, type CervioI18n, type CervioI18nCatalog, type CervioI18nMessages, type CervioListRecordsClient, type CervioPluginContext, type CervioPluginRuntimeSettings, type CervioSessionClient, type CervioSessionClientOptions, type CervioTaskDraftResult, type CervioTaskOutcome, type CervioTaskPluginBoot, type CervioTaskPluginContextData, type CervioTaskSubmitResult, type CervioThemeChangeHandler, type CervioThemeSnapshot, type CervioUI, type CervioUiActionSheetAction, type CervioUiActionSheetOpenOptions, type CervioUiAlertOptions, type CervioUiBarcodeScanOptions, type CervioUiBarcodeScanResult, type CervioUiCameraOpenOptions, type CervioUiConfirmOptions, type CervioUiDateOpenOptions, type CervioUiDialogVariant, type CervioUiDomainPickOption, type CervioUiEntityPickOptions, type CervioUiExportDownloadOptions, type CervioUiFileMeta, type CervioUiFilesCaptureOptions, type CervioUiFilesPickOptions, type CervioUiFilesPickResult, type CervioUiFilesUploadOptions, type CervioUiFilesUploadResult, type CervioUiFormatSnapshot, type CervioUiFrameClosedEvent, type CervioUiFrameMetricsEvent, type CervioUiFrameOpenOptions, type CervioUiFrameSize, type CervioUiFrameSlot, type CervioUiGroupPickOptions, type CervioUiHostEvent, type CervioUiLocationPickOptions, type CervioUiLocationResult, type CervioUiNavConfirmLeaveOptions, type CervioUiPrintOpenOptions, type CervioUiProgressShowOptions, type CervioUiProgressUpdateOptions, type CervioUiRecordPickOptions, type CervioUiSelectOpenOptions, type CervioUiSelectOption, type CervioUiShareOpenOptions, type CervioUiShareResult, type CervioUiSheetAction, type CervioUiSheetOpenOptions, type CervioUiSurfaceClosedEvent, type CervioUiSurfaceMessageEvent, type CervioUiSurfaceOpenOptions, type CervioUiSurfaceOpenedEvent, type CervioUiTaskCompleteOptions, type CervioUiTaskCompleteResult, type CervioUiTaskListItem, type CervioUiTaskOpenResult, type CervioUiTaskOutcome, type CervioUiTaskSummary, type CervioUiThemeSnapshot, type CervioUiToastOptions, type CervioUiToastType, type CervioUiUserPickOptions, type CreateI18nOptions, type Entity, type EntityCapabilities, type EntityRecord, type ExternalConnectionStatus, type ExternalProxyInput, type Identity, type ResolvePluginLocaleOptions, countVisibleRecords, createCervioClient, createCervioSessionClient, createI18n, ensureExternalConnection, findEntityByName, getCervioUI, getCurrentTheme, getPluginContext, getTaskPluginContext, isCervioUIAvailable, isInsideCervioSandbox, onThemeChange, openExternalAuth, resolveApiBaseUrl, resolvePluginLocale, setTaskDraft, submitTaskOutcome };
|