@plugmatica/blocks 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.
@@ -0,0 +1,551 @@
1
+ import * as React from 'react';
2
+ import { DataTableProps, EmptyStateProps, PageProps, PageHeaderProps, FormProps, FormInput, FormTextArea, FormInputNumber, FormSelect, FormCheckbox, FormSwitch, FormDatePicker, FormDateTimePicker, FormTimePicker, FormSlider, ActionDefinition, ActionInvocationPayload, GridProps, SheetSize, DescriptionListItem, CardProps, DescriptionListProps, SemanticExtensionProps, ButtonColor, DialogSize, ButtonVariant, DialogActionDefinition } from '@plugmatica/ui-kit';
3
+ import { FieldValues } from 'react-hook-form';
4
+ import { PluginManagedResourceApi, WorkflowNodeFields } from '@plugmatica/plugin-sdk';
5
+
6
+ /** A loader must be stable (normally useCallback); it receives cancellation. */
7
+ type ResourceLoader<T> = (signal: AbortSignal) => T | Promise<T>;
8
+ /** Lightweight, uncached resource options. */
9
+ interface ResourceOptions {
10
+ /** Disabled resources do not request and expose no previous data. */
11
+ enabled?: boolean;
12
+ /** Opt in to retaining data across changes of loader/query identity. */
13
+ keepPreviousData?: boolean;
14
+ /** A changed ownership/session boundary always clears previous data. */
15
+ scopeKey?: unknown;
16
+ }
17
+ /** Common result contract consumed by the feedback and table blocks. */
18
+ interface ResourceState<T> {
19
+ value: T | null;
20
+ error: Error | null;
21
+ /** True for initial loading and background refresh. */
22
+ loading: boolean;
23
+ /** Safe for event handlers: failures populate error, not unhandled rejections. */
24
+ refresh(): Promise<T | undefined>;
25
+ /** Imperative variant: rejects on failure, cancellation, or disabled state. */
26
+ reload(): Promise<T>;
27
+ setValue: React.Dispatch<React.SetStateAction<T | null>>;
28
+ }
29
+ /**
30
+ * Uncached resource lifecycle shared by REST and typed-client adapters.
31
+ * Refresh retains current rows. A changed loader clears them unless opted in;
32
+ * disabling always clears them, including on the render before effect cleanup.
33
+ * Use plugin-query instead when caching/invalidation is required.
34
+ */
35
+ declare function useAsyncResource<T>(load: ResourceLoader<T>, { enabled, keepPreviousData, scopeKey }?: ResourceOptions): ResourceState<T>;
36
+
37
+ /**
38
+ * A read-only, uncached request against the current plugin's scoped API.
39
+ * No body means GET; any JSON body (including null/false/0) means POST.
40
+ * Use POST only for read/search endpoints, never for creation side effects.
41
+ */
42
+ declare function usePluginResource<T>(path: string, body?: unknown, options?: ResourceOptions): ResourceState<T>;
43
+
44
+ /** An action result distinguishes failure from a refused duplicate invocation. */
45
+ type ActionResult<T> = {
46
+ status: "success";
47
+ value: T;
48
+ } | {
49
+ status: "error";
50
+ error: Error;
51
+ } | {
52
+ status: "busy";
53
+ };
54
+
55
+ /** Non-throwing outcome; inspect status before closing forms or refreshing. */
56
+ type AsyncActionResult<T> = ActionResult<T>;
57
+ /** State and execution for one logical mutation. */
58
+ interface AsyncAction<TArgs extends unknown[], TResult> {
59
+ pending: boolean;
60
+ error: Error | null;
61
+ run(...args: TArgs): Promise<AsyncActionResult<TResult>>;
62
+ /** Synchronous guard, including before React commits a pending render. */
63
+ isPending(): boolean;
64
+ /** Clears an old error; does nothing while the write is running. */
65
+ reset(): void;
66
+ }
67
+ /**
68
+ * Single-flight mutation state without endpoint, cache, toast, or form policy.
69
+ * All rejection paths are captured, including synchronous exceptions. Writes
70
+ * are not aborted on unmount; only subsequent React state updates are skipped.
71
+ */
72
+ declare function useAsyncAction<TArgs extends unknown[], TResult>(action: (...args: TArgs) => TResult | Promise<TResult>): AsyncAction<TArgs, TResult>;
73
+
74
+ /** Exactly one editor mode can be active; no null/undefined sentinel protocol. */
75
+ type CrudEditorState<TRecord> = {
76
+ mode: "closed";
77
+ } | {
78
+ mode: "create";
79
+ } | {
80
+ mode: "edit";
81
+ record: TRecord;
82
+ };
83
+ /** The plugin owns authorization, validation, URLs, DTOs, and persistence. */
84
+ interface CrudEditorOptions<TRecord, TValues, TResult> {
85
+ create(values: TValues): TResult | Promise<TResult>;
86
+ update?(record: TRecord, values: TValues): TResult | Promise<TResult>;
87
+ }
88
+ /** Editing controls and guarded submission, independent of form/dialog choice. */
89
+ interface CrudEditor<TRecord, TValues, TResult> {
90
+ state: CrudEditorState<TRecord>;
91
+ isOpen: boolean;
92
+ pending: boolean;
93
+ error: Error | null;
94
+ openCreate(): boolean;
95
+ openEdit(record: TRecord): boolean;
96
+ close(): boolean;
97
+ /** A closed editor cannot perform a write. Failure leaves current values open. */
98
+ submit(values: TValues): Promise<AsyncActionResult<TResult> | {
99
+ status: "closed";
100
+ }>;
101
+ }
102
+ /**
103
+ * Create/edit lifecycle with single-flight saves and close-while-saving guards.
104
+ * On success, the editor closes. Refresh/toast/reset happens in the plugin
105
+ * after a successful result, so a failed refresh cannot turn a committed create
106
+ * into a retryable mutation error (and accidentally create a duplicate).
107
+ */
108
+ declare function useCrudEditor<TRecord, TValues, TResult = unknown>(options: CrudEditorOptions<TRecord, TValues, TResult>): CrudEditor<TRecord, TValues, TResult>;
109
+
110
+ /** Shared safe request feedback; raw transport/server messages are not exposed. */
111
+ interface ResourceErrorProps {
112
+ error: unknown;
113
+ retry?: () => unknown | Promise<unknown>;
114
+ title?: React.ReactNode;
115
+ description?: React.ReactNode;
116
+ }
117
+ /** Permission/not-found-aware feedback using the platform's shared catalog. */
118
+ declare function ResourceError({ error, retry, title, description }: ResourceErrorProps): React.JSX.Element;
119
+ /** Accessible shared loading presentation; no new styling or design tokens. */
120
+ declare function ResourceLoading(): React.JSX.Element;
121
+ /** Props for non-table resource content. DataTable should use useResourceTable. */
122
+ interface ResourceBoundaryProps<T> {
123
+ resource: Pick<ResourceState<T>, "value" | "loading" | "error" | "refresh">;
124
+ children(value: T): React.ReactNode;
125
+ empty?: React.ReactNode;
126
+ loading?: React.ReactNode;
127
+ }
128
+ /** Preserve existing content during refresh, and keep refresh failures visible. */
129
+ declare function ResourceBoundary<T>({ resource, children, empty, loading }: ResourceBoundaryProps<T>): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined>;
130
+
131
+ /** Only lifecycle props are owned here; table contracts/columns stay local. */
132
+ type ResourceTableProps<TRow> = Pick<DataTableProps<TRow>, "data" | "loading" | "error" | "errorState" | "onRefresh">;
133
+ type TableResource<T> = Pick<ResourceState<T>, "value" | "loading" | "error"> & {
134
+ refresh(): unknown | Promise<unknown>;
135
+ };
136
+ /** Bind an array resource to a compiler-visible DataTable without wrapper JSX. */
137
+ declare function useResourceTable<TRow>(resource: TableResource<TRow[]>): ResourceTableProps<TRow>;
138
+ /** Bind a domain response envelope while keeping its mapping in the plugin. */
139
+ declare function useResourceTable<TValue, TRow>(resource: TableResource<TValue>, selectRows: (value: TValue) => TRow[]): ResourceTableProps<TRow>;
140
+
141
+ /** Props-first table composition. Columns, filters and actions stay UI-kit APIs. */
142
+ interface CollectionBlockProps<TRow> extends Omit<DataTableProps<TRow>, "getRowId"> {
143
+ /** Required: stable domain identity, never the visible row index. */
144
+ getRowId: NonNullable<DataTableProps<TRow>["getRowId"]>;
145
+ /** First-use/no-data feedback. DataTable still owns its filtered no-results state. */
146
+ empty?: Omit<EmptyStateProps, "children">;
147
+ }
148
+ /**
149
+ * DataTable plus safe request feedback and a props-driven empty state.
150
+ * Bind resources with useResourceTable; transport and pagination policy remain local.
151
+ * Its extension identity is the underlying standard table, not a new surface type.
152
+ */
153
+ declare function CollectionBlock<TRow>({ empty, emptyState, error, errorState, onRefresh, data, ...table }: CollectionBlockProps<TRow>): React.JSX.Element;
154
+
155
+ /** Page, heading and collection configured with data rather than nested JSX. */
156
+ interface CollectionPageProps<TRow> extends Omit<PageProps, "children"> {
157
+ /** Static local object. Title/actions are the existing PageHeader API. */
158
+ header: PageHeaderProps;
159
+ /** Static local object. Columns and row actions remain statically discoverable. */
160
+ table: CollectionBlockProps<TRow>;
161
+ /** Escape hatch for domain-specific summaries, not required for ordinary lists. */
162
+ beforeTable?: React.ReactNode;
163
+ /** Escape hatch for related information or an editor owned by this plugin. */
164
+ afterTable?: React.ReactNode;
165
+ }
166
+ /** Standard Page + PageHeader + CollectionBlock; no router or inferred endpoints. */
167
+ declare function CollectionPage<TRow>({ header, table, beforeTable, afterTable, ...page }: CollectionPageProps<TRow>): React.JSX.Element;
168
+
169
+ /** Control props are the real UI-kit props, not a second field schema. */
170
+ type Field<Kind extends string, Props> = Omit<Props, "label" | "children"> & {
171
+ kind: Kind;
172
+ /** Every ordinary control has a visible, localized label. */
173
+ label: string;
174
+ /** Hide presentation while retaining registration, identity and its current value. */
175
+ hidden?: boolean;
176
+ };
177
+ /** Typed, props-first controls. `name` is a React Hook Form path into TValues. */
178
+ type FieldDefinition<TValues extends FieldValues> = Field<"text", React.ComponentProps<typeof FormInput<TValues>>> | Field<"textarea", React.ComponentProps<typeof FormTextArea<TValues>>> | Field<"number", React.ComponentProps<typeof FormInputNumber<TValues>>> | Field<"select", React.ComponentProps<typeof FormSelect<TValues>>> | Field<"checkbox", React.ComponentProps<typeof FormCheckbox<TValues>>> | Field<"switch", React.ComponentProps<typeof FormSwitch<TValues>>> | Field<"date", React.ComponentProps<typeof FormDatePicker<TValues>>> | Field<"datetime", React.ComponentProps<typeof FormDateTimePicker<TValues>>> | Field<"time", React.ComponentProps<typeof FormTimePicker<TValues>>> | Field<"slider", React.ComponentProps<typeof FormSlider<TValues>>>;
179
+ /** Native form intent plus the platform's structured action presentation. */
180
+ interface FormActionDefinition extends ActionDefinition {
181
+ type?: "button" | "submit" | "reset";
182
+ }
183
+ /** Owner-side action binding; descriptions remain inspectable by builders. */
184
+ type FormActionHandler = (action: Readonly<FormActionDefinition>, payload: ActionInvocationPayload) => unknown | Promise<unknown>;
185
+ /** Form, fields, validation, error feedback and ordered actions as one definition. */
186
+ interface FormBlockProps<TValues extends FieldValues> extends Omit<FormProps<TValues, unknown>, "children"> {
187
+ fields: readonly FieldDefinition<TValues>[];
188
+ actions: readonly FormActionDefinition[];
189
+ onAction?: FormActionHandler;
190
+ /** Optional responsive UI-kit Grid. Omitting it gives the standard form stack. */
191
+ fieldLayout?: Omit<GridProps, "children">;
192
+ /** EditorSheet selects sheet: scrollable fields and persistent footer actions. */
193
+ presentation?: "inline" | "sheet";
194
+ /** External mutation state, in addition to RHF's submission state. */
195
+ pending?: boolean;
196
+ disabled?: boolean;
197
+ /** Safe generic feedback; server text is never rendered from this object. */
198
+ error?: unknown;
199
+ /** Exceptional domain controls still belong to the same UI-kit Form scope. */
200
+ extraFields?: React.ReactNode;
201
+ }
202
+ /** Standard Form composition. Persistence, DTO mapping and success effects stay local. */
203
+ declare function FormBlock<TValues extends FieldValues>({ fields, actions, onAction, pending, disabled, error, extraFields, fieldLayout, presentation, form, onSubmit, ...props }: FormBlockProps<TValues>): React.JSX.Element;
204
+
205
+ /** Right-hand record authoring. Its extension identity is the underlying Form. */
206
+ interface EditorSheetProps<TValues extends FieldValues> extends Omit<FormBlockProps<TValues>, "title" | "presentation"> {
207
+ open: boolean;
208
+ onOpenChange(open: boolean): void;
209
+ title: React.ReactNode;
210
+ description?: React.ReactNode;
211
+ size?: SheetSize;
212
+ /** Defaults to RHF isDirty. Set false only when discarding edits is intentional. */
213
+ dirty?: boolean;
214
+ /** This form action requests guarded dismissal rather than invoking onAction. */
215
+ dismissActionKey?: string;
216
+ /** Copy only: the safe dirty-close behaviour is enabled by default. */
217
+ discard?: {
218
+ title?: React.ReactNode;
219
+ description?: React.ReactNode;
220
+ confirmLabel?: React.ReactNode;
221
+ cancelLabel?: React.ReactNode;
222
+ };
223
+ returnFocusRef?: React.RefObject<HTMLElement | null>;
224
+ }
225
+ /**
226
+ * Sheet + FormBlock. Outside clicks never silently discard input. Escape/close
227
+ * request confirmation for dirty forms and are refused while saving.
228
+ * Programmatic parent closure (for example after save) remains parent-owned.
229
+ */
230
+ declare function EditorSheet<TValues extends FieldValues>({ open, onOpenChange, title, description, size, dirty, discard, returnFocusRef, dismissActionKey, ...formProps }: EditorSheetProps<TValues>): React.JSX.Element;
231
+
232
+ /** Stable, optionally hidden detail item; zero and false are not missing values. */
233
+ interface DetailDefinition extends Omit<DescriptionListItem, "key" | "className"> {
234
+ key: string;
235
+ hidden?: boolean;
236
+ }
237
+ /** Card + semantic description list, using the existing responsive UI-kit layout. */
238
+ interface DetailsBlockProps extends Omit<CardProps, "children"> {
239
+ items: readonly DetailDefinition[];
240
+ columns?: DescriptionListProps["columns"];
241
+ orientation?: DescriptionListProps["orientation"];
242
+ density?: CardProps["density"];
243
+ emptyValue?: React.ReactNode;
244
+ }
245
+ /** A read-only record summary. The owning extension is the standard card. */
246
+ declare function DetailsBlock({ items, columns, orientation, density, emptyValue, ...card }: DetailsBlockProps): React.JSX.Element;
247
+
248
+ /** A settings card with a local, independently submitted form definition. */
249
+ interface SettingsBlockProps<TValues extends FieldValues> extends Omit<CardProps, "children"> {
250
+ form: FormBlockProps<TValues>;
251
+ }
252
+ /** Card + FormBlock; it never merges unrelated settings into one transaction. */
253
+ declare function SettingsBlock<TValues extends FieldValues>({ form, ...card }: SettingsBlockProps<TValues>): React.JSX.Element;
254
+
255
+ /** Controlled confirmation. `extension` identifies the confirm action itself. */
256
+ interface ConfirmDialogProps extends SemanticExtensionProps {
257
+ open: boolean;
258
+ onOpenChange(open: boolean): void;
259
+ title: React.ReactNode;
260
+ /** State the affected record and consequences in the owning plugin's wording. */
261
+ description: React.ReactNode;
262
+ confirmLabel: React.ReactNode;
263
+ cancelLabel?: React.ReactNode;
264
+ color?: ButtonColor;
265
+ disabled?: boolean;
266
+ /** Change when retargeting an already-open confirmation to a different record. */
267
+ requestKey?: string | number;
268
+ /** Reject on failure. Success closes; failure stays open with safe feedback. */
269
+ onConfirm(): unknown | Promise<unknown>;
270
+ /** Connected return-focus target; if removed, fall back to the original opener. */
271
+ returnFocusRef?: React.RefObject<HTMLElement | null>;
272
+ }
273
+ /** Dialog + guarded async confirm/cancel actions. Destructive color is explicit. */
274
+ declare function ConfirmDialog({ open, onOpenChange, title, description, confirmLabel, cancelLabel, color, disabled, onConfirm, returnFocusRef, requestKey, ...semantic }: ConfirmDialogProps): React.JSX.Element;
275
+
276
+ type ReferenceDisplay = {
277
+ key: React.Key;
278
+ label: React.ReactNode;
279
+ detail?: React.ReactNode;
280
+ };
281
+ type UsageReport<T> = {
282
+ referenceCount: number;
283
+ references: readonly T[];
284
+ };
285
+ type ActionIdentity = Pick<DialogActionDefinition, "key" | "label" | "extension">;
286
+ /** Dialog-level deletion composition; callers retain authorization, usage reads and mutations. */
287
+ interface DestructiveConfirmationDialogProps<T> extends SemanticExtensionProps {
288
+ open: boolean;
289
+ onOpenChange(open: boolean): void;
290
+ title: React.ReactNode;
291
+ description?: React.ReactNode;
292
+ closeButtonLabel?: string;
293
+ size?: DialogSize;
294
+ cancelVariant?: ButtonVariant;
295
+ /** Static owner action identities, preserved for plugin extension compilation. */
296
+ actions: readonly [ActionIdentity, ActionIdentity];
297
+ canConfirm: boolean;
298
+ pending: boolean;
299
+ confirmLabel: React.ReactNode;
300
+ pendingLabel?: React.ReactNode;
301
+ onConfirm(): unknown | Promise<unknown>;
302
+ usage?: UsageReport<T> | null;
303
+ usageLoading?: boolean;
304
+ checkingLabel?: React.ReactNode;
305
+ safeLabel?: React.ReactNode;
306
+ blockedLabel?: React.ReactNode;
307
+ renderReference?: (reference: T) => ReferenceDisplay;
308
+ error?: string | null;
309
+ errorTitle?: React.ReactNode;
310
+ children?: React.ReactNode;
311
+ }
312
+ /** UI Kit Dialog retains async locking, ordered action regions and dismissal semantics. */
313
+ declare function DestructiveConfirmationDialog<T>({ open, onOpenChange, title, description, closeButtonLabel, size, cancelVariant, actions, canConfirm, pending, confirmLabel, pendingLabel, onConfirm, usage, usageLoading, checkingLabel, safeLabel, blockedLabel, renderReference, error, errorTitle, children, ...semantic }: DestructiveConfirmationDialogProps<T>): React.JSX.Element;
314
+
315
+ /** Host-owned public resource types. No Settings or integration plugin implementation is imported. */
316
+ type PickerConnection = Awaited<ReturnType<PluginManagedResourceApi["listConnections"]>>[number];
317
+ type PickerConnectionType = Awaited<ReturnType<PluginManagedResourceApi["listConnectionTypes"]>>[number];
318
+ interface ConnectionPickerCompatibility {
319
+ compatibleTypes?: readonly string[];
320
+ compatibleCapabilities?: readonly string[];
321
+ }
322
+ /** A default binding is a semantic choice, not a special connection pid. */
323
+ type ConnectionPickerSelection = {
324
+ kind: "connection";
325
+ pid: string;
326
+ } | {
327
+ kind: "platform-default";
328
+ bindingKey: string;
329
+ };
330
+ type ConnectionPickerUnavailableReason = "provider" | "disabled" | "health" | null;
331
+ type ConnectionPickerOption = {
332
+ profile: PickerConnection;
333
+ descriptor: PickerConnectionType | null;
334
+ unavailableReason: ConnectionPickerUnavailableReason;
335
+ selectable: boolean;
336
+ };
337
+ /** A missing descriptor must never be treated as proof of a required capability. */
338
+ declare function compatibleConnectionOptions(profiles: readonly PickerConnection[], descriptors: readonly PickerConnectionType[], compatibility?: ConnectionPickerCompatibility): ConnectionPickerOption[];
339
+
340
+ type ConnectionProfile$2 = Awaited<ReturnType<PluginManagedResourceApi["getConnection"]>>;
341
+ type ConnectionType$1 = Awaited<ReturnType<PluginManagedResourceApi["listConnectionTypes"]>>[number];
342
+ /** Secret values live only in a transient editor draft. Never hydrate them from a profile. */
343
+ type ConnectionEditorDraft = {
344
+ resourceType: string;
345
+ profileKey: string;
346
+ config: Record<string, unknown>;
347
+ secretValues: Record<string, string>;
348
+ enabled: boolean;
349
+ };
350
+ declare function connectionConfigHasPreset(schema: Record<string, unknown>, field: string): boolean;
351
+ declare function applyConnectionConfigPreset(schema: Record<string, unknown>, config: Record<string, unknown>, field: string, selected: unknown): Record<string, unknown>;
352
+ /** One default-value implementation for the Settings page and contextual picker. */
353
+ declare function defaultConnectionConfig(schema: Record<string, unknown>): Record<string, unknown>;
354
+ declare function createConnectionDraft(type: ConnectionType$1 | null): ConnectionEditorDraft;
355
+ declare function editConnectionDraft(profile: ConnectionProfile$2): ConnectionEditorDraft;
356
+ declare function connectionAuthoringTypes(types: readonly ConnectionType$1[], { compatibleTypes, compatibleCapabilities }?: ConnectionPickerCompatibility): ConnectionType$1[];
357
+ /** Optional host:port UX for any descriptor with host + port fields; no transport/plugin special cases. */
358
+ declare function splitConnectionHostPort(value: string): {
359
+ host: string;
360
+ port: number;
361
+ } | null;
362
+ /** Required secret-schema keys absent from both the host's metadata and this transient draft.
363
+ * Do not accept placeholders as proof a secret has been configured. */
364
+ declare function missingRequiredConnectionSecrets(schema: Record<string, unknown> | null | undefined, storedKeys: Iterable<string>, values: Readonly<Record<string, string>>): string[];
365
+ /** A write-only, host-authorised save operation shared by Settings and the picker. */
366
+ declare function saveConnectionDraft(api: Pick<PluginManagedResourceApi, "upsertConnection" | "setConnectionSecret">, draft: ConnectionEditorDraft): Promise<ConnectionProfile$2>;
367
+
368
+ type ConnectionProfile$1 = Awaited<ReturnType<PluginManagedResourceApi["getConnection"]>>;
369
+ type ConnectionType = Awaited<ReturnType<PluginManagedResourceApi["listConnectionTypes"]>>[number];
370
+ interface ConnectionEditorLabels {
371
+ type: string;
372
+ selectType: string;
373
+ name: string;
374
+ namePlaceholder: string;
375
+ enabled: string;
376
+ enabledDescription: string;
377
+ secretConfigured: string;
378
+ secretKeepExisting: string;
379
+ secretRequired: string;
380
+ testDeclared: (name: string) => string;
381
+ required: string;
382
+ jsonInvalid: string;
383
+ presetHint: string;
384
+ }
385
+ declare const defaultConnectionEditorLabels: ConnectionEditorLabels;
386
+ /**
387
+ * Descriptor-driven form shared between full Settings administration and contextual authoring.
388
+ * No provider-specific code; credentials are never read, and blank edits retain old secrets.
389
+ */
390
+ declare function ConnectionEditorForm({ types, draft, editing, onChange, labels, disabled, onValidityChange, }: {
391
+ types: readonly ConnectionType[];
392
+ draft: ConnectionEditorDraft;
393
+ editing?: ConnectionProfile$1 | null;
394
+ onChange: (next: ConnectionEditorDraft) => void;
395
+ labels?: Partial<ConnectionEditorLabels>;
396
+ disabled?: boolean;
397
+ onValidityChange?: (valid: boolean) => void;
398
+ }): React.JSX.Element;
399
+
400
+ /** Host-approved public catalogue snapshot (never secret values), for draft UIs with their own state lifecycle. */
401
+ type ConnectionPickerInventory = {
402
+ profiles: PickerConnection[];
403
+ descriptors: PickerConnectionType[];
404
+ };
405
+ /** Caller-provided copy for the picker and its optional inline authoring subviews. */
406
+ interface ConnectionPickerLabels {
407
+ title: string;
408
+ description: string;
409
+ search: string;
410
+ category: string;
411
+ allCategories: string;
412
+ refresh: string;
413
+ cancel: string;
414
+ loading: string;
415
+ noConnections: string;
416
+ noMatches: string;
417
+ unavailable: string;
418
+ disabled: string;
419
+ unhealthy: string;
420
+ selected: string;
421
+ defaultTitle: string;
422
+ defaultDescription: string;
423
+ missingSelection: string;
424
+ selectionFailed: string;
425
+ showMore: string;
426
+ accessDenied: string;
427
+ count: (shown: number, total: number) => string;
428
+ health: Partial<Record<"ready" | "missing" | "incompatible" | "disabled" | "unhealthy" | "unknown", string>>;
429
+ create: string;
430
+ manage: string;
431
+ details: string;
432
+ edit: string;
433
+ back: string;
434
+ save: string;
435
+ saving: string;
436
+ saved: string;
437
+ saveFailed: string;
438
+ authoringDenied: string;
439
+ test: string;
440
+ reconnect: string;
441
+ testing: string;
442
+ reconnecting: string;
443
+ testPassed: string;
444
+ testFailed: string;
445
+ reconnectPassed: string;
446
+ reconnectFailed: string;
447
+ actionFailed: string;
448
+ useConnection: string;
449
+ credentialsHint: string;
450
+ configuredCredentials: (count: number) => string;
451
+ form: Partial<ConnectionEditorLabels>;
452
+ }
453
+ interface ConnectionPickerSheetProps extends ConnectionPickerCompatibility {
454
+ open: boolean;
455
+ onOpenChange(open: boolean): void;
456
+ /** The public, host-managed capability; never an integration or Settings private API. */
457
+ managedResources: PluginManagedResourceApi;
458
+ currentConnectionPid?: string | null;
459
+ allowDefault?: boolean;
460
+ defaultBindingKey?: string;
461
+ /** Opt in only on trusted, writable surfaces. The backend still authorises each mutation. */
462
+ enableAuthoring?: boolean;
463
+ onSelect(selection: ConnectionPickerSelection): void | Promise<void>;
464
+ /** Optional catalogue sync; never calls the owner's draft-save or route navigation. */
465
+ onInventoryChange?(inventory: ConnectionPickerInventory): void;
466
+ labels?: Partial<ConnectionPickerLabels>;
467
+ returnFocusRef?: React.RefObject<HTMLElement | null>;
468
+ }
469
+ /**
470
+ * Workflow-safe Connection catalogue + optional in-place authoring.
471
+ * Merely saving, testing, reconnecting or dismissing NEVER updates the host draft.
472
+ * The explicit selection callback is the only way to change a Workflow binding.
473
+ */
474
+ declare function ConnectionPickerSheet({ open, onOpenChange, managedResources, currentConnectionPid, compatibleTypes, compatibleCapabilities, allowDefault, defaultBindingKey, enableAuthoring, onSelect, onInventoryChange, labels, returnFocusRef, }: ConnectionPickerSheetProps): React.JSX.Element;
475
+
476
+ /** Renders host-managed Connection type schemas without importing Workflow or provider code. */
477
+ declare function ConnectionConfigFields({ schema, value, onChange, onFieldBlur, labels, onInvalidFieldChange, }: {
478
+ schema: Record<string, unknown>;
479
+ value: Record<string, unknown>;
480
+ onChange: (next: Record<string, unknown>) => void;
481
+ onFieldBlur?: (field: string, value: unknown) => void;
482
+ labels?: {
483
+ required?: string;
484
+ jsonInvalid?: string;
485
+ presetHint?: string;
486
+ };
487
+ onInvalidFieldChange?: (fieldPath: string, invalid: boolean) => void;
488
+ }): React.JSX.Element;
489
+
490
+ type ConnectionProfile = Awaited<ReturnType<PluginManagedResourceApi["listConnections"]>>[number];
491
+ type ConnectionTypeDescriptor = Awaited<ReturnType<PluginManagedResourceApi["listConnectionTypes"]>>[number];
492
+ /**
493
+ * Public, source-less Connection catalogue projection. This is a presentation
494
+ * layer, never an authorization, compatibility, health or secret boundary.
495
+ */
496
+ type ConnectionCatalogueHealth = "all" | "ready" | "attention" | "disabled";
497
+ type ConnectionCatalogueFilter = {
498
+ capability?: string;
499
+ category?: string;
500
+ health?: ConnectionCatalogueHealth;
501
+ query?: string;
502
+ };
503
+ type ConnectionCataloguePresentation = {
504
+ category: string;
505
+ categoryLabel: string;
506
+ provider: string;
507
+ icon: string;
508
+ documentationUrl: string | null;
509
+ };
510
+ type ConnectionCatalogueEntry = {
511
+ profile: ConnectionProfile;
512
+ descriptor: ConnectionTypeDescriptor | null;
513
+ presentation: ConnectionCataloguePresentation;
514
+ };
515
+ type ConnectionCatalogueGroup = {
516
+ category: string;
517
+ label: string;
518
+ entries: ConnectionCatalogueEntry[];
519
+ };
520
+ type ConnectionCatalogueTypeGroup = {
521
+ category: string;
522
+ label: string;
523
+ types: ConnectionTypeDescriptor[];
524
+ };
525
+ declare function connectionCatalogueCategoryLabel(category: string): string;
526
+ /** Never render arbitrary provider-supplied icon paths or navigation schemes. */
527
+ declare function connectionCataloguePresentation(descriptor: ConnectionTypeDescriptor | null | undefined): ConnectionCataloguePresentation;
528
+ /** Conflicting installed identities are not resolved by catalogue ordering. */
529
+ declare function uniqueConnectionCatalogueTypes(descriptors: readonly ConnectionTypeDescriptor[]): Map<string, ConnectionTypeDescriptor>;
530
+ /** Public fields only: no config JSON, secretMetadata values or OAuth grant state. */
531
+ declare function connectionCatalogueSearchFields(profile: Pick<ConnectionProfile, "profileKey" | "resourceType" | "health" | "transport">, descriptor: ConnectionTypeDescriptor | null): string[];
532
+ declare function connectionCatalogueTypeGroups(descriptors: readonly ConnectionTypeDescriptor[], capability?: string, query?: string): ConnectionCatalogueTypeGroup[];
533
+ declare function buildConnectionCatalogue(profiles: readonly ConnectionProfile[], descriptors: readonly ConnectionTypeDescriptor[], filter?: ConnectionCatalogueFilter): {
534
+ entries: ConnectionCatalogueEntry[];
535
+ groups: ConnectionCatalogueGroup[];
536
+ };
537
+
538
+ /**
539
+ * Public Workflow field UI for independently built plugin editors.
540
+ * Field state, source availability, validation, and writes stay host-managed.
541
+ * Using this component cannot create or mutate a managed Connection.
542
+ */
543
+ declare function WorkflowField({ fields, path, label, description, }: {
544
+ fields: WorkflowNodeFields;
545
+ path: string;
546
+ label?: string;
547
+ description?: string;
548
+ }): React.JSX.Element | null;
549
+
550
+ export { CollectionBlock, CollectionPage, ConfirmDialog, ConnectionConfigFields, ConnectionEditorForm, ConnectionPickerSheet, DestructiveConfirmationDialog, DetailsBlock, EditorSheet, FormBlock, ResourceBoundary, ResourceError, ResourceLoading, SettingsBlock, WorkflowField, applyConnectionConfigPreset, buildConnectionCatalogue, compatibleConnectionOptions, connectionAuthoringTypes, connectionCatalogueCategoryLabel, connectionCataloguePresentation, connectionCatalogueSearchFields, connectionCatalogueTypeGroups, connectionConfigHasPreset, createConnectionDraft, defaultConnectionConfig, defaultConnectionEditorLabels, editConnectionDraft, missingRequiredConnectionSecrets, saveConnectionDraft, splitConnectionHostPort, uniqueConnectionCatalogueTypes, useAsyncAction, useAsyncResource, useCrudEditor, usePluginResource, useResourceTable };
551
+ export type { AsyncAction, AsyncActionResult, CollectionBlockProps, CollectionPageProps, ConfirmDialogProps, ConnectionCatalogueEntry, ConnectionCatalogueFilter, ConnectionCatalogueGroup, ConnectionCatalogueHealth, ConnectionCataloguePresentation, ConnectionCatalogueTypeGroup, ConnectionEditorDraft, ConnectionEditorLabels, ConnectionPickerCompatibility, ConnectionPickerInventory, ConnectionPickerLabels, ConnectionPickerSelection, ConnectionPickerSheetProps, CrudEditor, CrudEditorOptions, CrudEditorState, DestructiveConfirmationDialogProps, DetailDefinition, DetailsBlockProps, EditorSheetProps, FieldDefinition, FormActionDefinition, FormActionHandler, FormBlockProps, ResourceBoundaryProps, ResourceErrorProps, ResourceLoader, ResourceOptions, ResourceState, ResourceTableProps, SettingsBlockProps };