@nullplatform/ui-plugin-sdk 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bridge.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Plugin-side client of the host bridge. The only way out of the sandbox.
3
3
  */
4
- import { type ApiRequest, type BridgeMethodName, type BridgeMethods, type HostMessage, type HttpRequest, type HttpResponse, type NavigationTarget, type PluginContext, type SnackbarOptions, type WorkerMessage } from './protocol.js';
4
+ import { type ConfirmOptions, type ApiRequest, type BridgeMethodName, type BridgeMethods, type HostMessage, type HttpRequest, type HttpResponse, type NavigationTarget, type PluginContext, type SnackbarOptions, type WorkerMessage } from './protocol.js';
5
5
  import { topics as topicsApi } from './topics.js';
6
6
  export declare class BridgeClient {
7
7
  private readonly timeoutMs;
@@ -36,6 +36,12 @@ export declare const nullplatform: {
36
36
  };
37
37
  ui: {
38
38
  snackbar(options: SnackbarOptions): Promise<void>;
39
+ /**
40
+ * Asks the host to confirm with its own dialog, since a plugin cannot draw over the page. Resolves `true` only
41
+ * when the person confirms, `false` when they cancel or the host has no dialog. Waits up to 10 minutes; one at a
42
+ * time per plugin (a second one rejects with `BUSY`). A host older than the call rejects with `UNKNOWN_METHOD`.
43
+ */
44
+ confirm(options: ConfirmOptions): Promise<boolean>;
39
45
  };
40
46
  context: {
41
47
  get(): Promise<PluginContext>;
package/dist/bridge.js CHANGED
@@ -1,8 +1,13 @@
1
1
  /**
2
2
  * Plugin-side client of the host bridge. The only way out of the sandbox.
3
3
  */
4
- import { BridgeError, deserializeError, } from './protocol.js';
4
+ import { BridgeError, BRIDGE_CALL_DEADLINES_MS, deserializeError, } from './protocol.js';
5
5
  import { topics as topicsApi } from './topics.js';
6
+ /**
7
+ * Margin over a long host deadline, so the host's own answer (`TIMEOUT`, or the person's) arrives before this side
8
+ * gives up on the call.
9
+ */
10
+ const LONG_CALL_SLACK_MS = 5000;
6
11
  export class BridgeClient {
7
12
  timeoutMs;
8
13
  port = null;
@@ -35,7 +40,9 @@ export class BridgeClient {
35
40
  reject(new BridgeError('Too many pending calls', 'RATE_LIMIT'));
36
41
  return;
37
42
  }
38
- const timer = setTimeout(() => { this.pending.delete(id); reject(new BridgeError('Bridge call timed out', 'TIMEOUT')); }, this.timeoutMs);
43
+ const longDeadline = BRIDGE_CALL_DEADLINES_MS[method];
44
+ const timeoutMs = longDeadline ? Math.max(this.timeoutMs, longDeadline + LONG_CALL_SLACK_MS) : this.timeoutMs;
45
+ const timer = setTimeout(() => { this.pending.delete(id); reject(new BridgeError('Bridge call timed out', 'TIMEOUT')); }, timeoutMs);
39
46
  this.pending.set(id, { resolve, reject, timer });
40
47
  try {
41
48
  this.post({ type: 'call', id, method, args });
@@ -96,6 +103,14 @@ export const nullplatform = {
96
103
  snackbar(options) {
97
104
  return bridge.call('ui.snackbar', options);
98
105
  },
106
+ /**
107
+ * Asks the host to confirm with its own dialog, since a plugin cannot draw over the page. Resolves `true` only
108
+ * when the person confirms, `false` when they cancel or the host has no dialog. Waits up to 10 minutes; one at a
109
+ * time per plugin (a second one rejects with `BUSY`). A host older than the call rejects with `UNKNOWN_METHOD`.
110
+ */
111
+ confirm(options) {
112
+ return bridge.call('ui.confirm', options);
113
+ },
99
114
  },
100
115
  context: {
101
116
  get() {
package/dist/catalog.d.ts CHANGED
@@ -23,6 +23,7 @@ export interface CatalogElementSpec {
23
23
  /**
24
24
  * Closed lists for string props. The host drops any other value, so the element draws its default. `prop[].key`
25
25
  * names a key of each item in an array prop, which the host drops from an item whose value isn't in the list.
26
+ * `prop[]` names the items of an array of plain values: the host drops each item that isn't in the list.
26
27
  */
27
28
  values?: Readonly<Record<string, readonly string[]>>;
28
29
  /**
package/dist/catalog.js CHANGED
@@ -227,10 +227,11 @@ const OWN_CATALOG = [
227
227
  children: true,
228
228
  },
229
229
  {
230
+ // `actionLabel` draws one action button at the alert's end; pressing it sends `action`.
230
231
  tag: "np-alert",
231
232
  component: "Alert",
232
- properties: { severity: "string", title: "string" },
233
- events: {},
233
+ properties: { severity: "string", title: "string", actionLabel: "string" },
234
+ events: { action: "onAction" },
234
235
  values: CATALOG_PROP_VALUES.Alert,
235
236
  children: true,
236
237
  defaults: { severity: "info" },
@@ -427,6 +428,35 @@ const OWN_CATALOG = [
427
428
  events: {},
428
429
  cssValues: ["color"],
429
430
  },
431
+ {
432
+ // Picks one platform resource (organization, account, namespace or application) by searching the ones the viewer
433
+ // can list. The app draws it with its own selector and data: a host without one shows it as unavailable, see
434
+ // `hostRenders`. `levels` narrows which kinds it offers; `change` sends `{ nrn, resource: { nrn, name, entity } }`.
435
+ tag: "np-resource-selector",
436
+ component: "ResourceSelector",
437
+ properties: {
438
+ label: "string",
439
+ value: "string",
440
+ levels: "array",
441
+ placeholder: "string",
442
+ error: "string",
443
+ helperText: "string",
444
+ disabled: "boolean",
445
+ },
446
+ events: { change: "onChange" },
447
+ // Never below an application, whatever a bundle asks for; the host drops any other level.
448
+ values: { "levels[]": ["organization", "account", "namespace", "application"] },
449
+ },
450
+ {
451
+ // Shows one platform resource by its NRN: kind badge, name and, with `showPath`, where it lives
452
+ // (`organization / account / namespace`); `copyable` adds a button that copies the NRN. The app draws it with its
453
+ // own data (resolved with the viewer's session, never returned to the plugin): a host without one shows it as
454
+ // unavailable, see `hostRenders`.
455
+ tag: "np-resource-display",
456
+ component: "ResourceDisplay",
457
+ properties: { nrn: "string", showPath: "boolean", copyable: "boolean" },
458
+ events: {},
459
+ },
430
460
  ];
431
461
  /**
432
462
  * Every element a plugin can render: the SDK's own, then the design-system components whose contracts
@@ -166,6 +166,9 @@ export declare const Empty: import("react").ComponentType<{
166
166
  export declare const Alert: import("react").ComponentType<{
167
167
  severity?: AlertSeverity;
168
168
  title?: string;
169
+ /** Draws one action button at the alert's end, such as "Ver en el calendario". Needs `onAction`. */
170
+ actionLabel?: string;
171
+ onAction?: () => void;
169
172
  } & {
170
173
  children?: ReactNode;
171
174
  }>;
@@ -429,3 +432,45 @@ export declare const ProgressBar: import("react").ComponentType<{
429
432
  } & {
430
433
  children?: ReactNode;
431
434
  }>;
435
+ /** A kind of platform resource `ResourceSelector` can offer. */
436
+ export type ResourceLevel = "organization" | "account" | "namespace" | "application";
437
+ /** The resource a person picked in `ResourceSelector`. */
438
+ export interface SelectedResource {
439
+ nrn: string;
440
+ name: string;
441
+ entity: string;
442
+ }
443
+ /**
444
+ * Picks one platform resource by searching the ones the viewer can list, drawn by the app with its own selector.
445
+ * Not every host draws it: check `hostRenders(ResourceSelector)`.
446
+ */
447
+ export declare const ResourceSelector: import("react").ComponentType<{
448
+ label?: string;
449
+ /** The chosen resource's NRN. */
450
+ value?: string | null;
451
+ /** Which kinds to offer; organization, account, namespace and application when left out. */
452
+ levels?: ResourceLevel[];
453
+ placeholder?: string;
454
+ error?: string;
455
+ helperText?: string;
456
+ disabled?: boolean;
457
+ onChange?: (change: {
458
+ nrn: string | null;
459
+ resource: SelectedResource | null;
460
+ }) => void;
461
+ } & {
462
+ children?: ReactNode;
463
+ }>;
464
+ /**
465
+ * Shows one platform resource by its NRN (kind badge and name), drawn by the app with its own data: the plugin never
466
+ * gets the resolved name back. Not every host draws it: check `hostRenders(ResourceDisplay)`.
467
+ */
468
+ export declare const ResourceDisplay: import("react").ComponentType<{
469
+ nrn: string;
470
+ /** Also shows where it lives: `organization / account / namespace`. */
471
+ showPath?: boolean;
472
+ /** Adds a button that copies the NRN. */
473
+ copyable?: boolean;
474
+ } & {
475
+ children?: ReactNode;
476
+ }>;
@@ -129,6 +129,18 @@ export declare const FilterDropdownMultiple: import("react").ComponentType<{
129
129
  } & {} & {
130
130
  children?: import("react").ReactNode;
131
131
  }>;
132
+ export declare const FilterBar: import("react").ComponentType<{
133
+ attributes?: readonly unknown[] | undefined;
134
+ value?: Readonly<Record<string, unknown>> | undefined;
135
+ config?: Readonly<Record<string, unknown>> | undefined;
136
+ localeText?: Readonly<Record<string, unknown>> | undefined;
137
+ liveApply?: boolean | undefined;
138
+ loading?: boolean | undefined;
139
+ } & {
140
+ readonly onChange?: ((payload: unknown) => void) | undefined;
141
+ } & {} & {
142
+ children?: import("react").ReactNode;
143
+ }>;
132
144
  export declare const FilterName: import("react").ComponentType<{
133
145
  filterName?: string | undefined;
134
146
  placeholder?: string | undefined;
@@ -161,6 +173,7 @@ export declare const RelativeDate: import("react").ComponentType<{
161
173
  showTooltip?: boolean | undefined;
162
174
  emptyText?: string | undefined;
163
175
  live?: boolean | undefined;
176
+ muted?: boolean | undefined;
164
177
  } & {} & {} & {
165
178
  children?: import("react").ReactNode;
166
179
  }>;
@@ -433,3 +446,98 @@ export declare const Markdown: import("react").ComponentType<{
433
446
  } & {} & {} & {
434
447
  children?: import("react").ReactNode;
435
448
  }>;
449
+ export declare const CalendarMonth: import("react").ComponentType<{
450
+ month?: string | undefined;
451
+ timeZone?: string | undefined;
452
+ weekStartsOn?: number | undefined;
453
+ today?: string | undefined;
454
+ events?: readonly unknown[] | undefined;
455
+ selectedId?: string | undefined;
456
+ maxLanes?: number | undefined;
457
+ locale?: string | undefined;
458
+ } & {
459
+ readonly onEventPress?: ((payload: unknown) => void) | undefined;
460
+ readonly onDayPress?: ((payload: unknown) => void) | undefined;
461
+ readonly onMorePress?: ((payload: unknown) => void) | undefined;
462
+ } & {} & {
463
+ children?: import("react").ReactNode;
464
+ }>;
465
+ export declare const CalendarWeek: import("react").ComponentType<{
466
+ weekStart?: string | undefined;
467
+ timeZone?: string | undefined;
468
+ startHour?: number | undefined;
469
+ endHour?: number | undefined;
470
+ events?: readonly unknown[] | undefined;
471
+ selectedId?: string | undefined;
472
+ now?: string | undefined;
473
+ locale?: string | undefined;
474
+ allDayLabel?: string | undefined;
475
+ } & {
476
+ readonly onEventPress?: ((payload: unknown) => void) | undefined;
477
+ readonly onSlotPress?: ((payload: unknown) => void) | undefined;
478
+ } & {} & {
479
+ children?: import("react").ReactNode;
480
+ }>;
481
+ export declare const CalendarTimeline: import("react").ComponentType<{
482
+ from?: string | undefined;
483
+ to?: string | undefined;
484
+ timeZone?: string | undefined;
485
+ rows?: readonly unknown[] | undefined;
486
+ bars?: readonly unknown[] | undefined;
487
+ selectedId?: string | undefined;
488
+ now?: string | undefined;
489
+ locale?: string | undefined;
490
+ resourceLabel?: string | undefined;
491
+ } & {
492
+ readonly onBarPress?: ((payload: unknown) => void) | undefined;
493
+ } & {} & {
494
+ children?: import("react").ReactNode;
495
+ }>;
496
+ export declare const ToggleButtonBar: import("react").ComponentType<{
497
+ options?: readonly unknown[] | undefined;
498
+ value?: string | undefined;
499
+ size?: "small" | "medium" | "large" | undefined;
500
+ "aria-label"?: string | undefined;
501
+ multiple?: boolean | undefined;
502
+ values?: readonly unknown[] | undefined;
503
+ } & {
504
+ readonly onChange?: ((payload: unknown) => void) | undefined;
505
+ } & {} & {
506
+ children?: import("react").ReactNode;
507
+ }>;
508
+ export declare const IconActionButton: import("react").ComponentType<{
509
+ icon?: string | undefined;
510
+ "aria-label"?: string | undefined;
511
+ color?: "default" | "success" | "error" | "warning" | "info" | "primary" | "secondary" | "inherit" | undefined;
512
+ size?: "small" | "medium" | "large" | undefined;
513
+ disabled?: boolean | undefined;
514
+ } & {
515
+ readonly onPress?: ((payload: unknown) => void) | undefined;
516
+ } & {} & {
517
+ children?: import("react").ReactNode;
518
+ }>;
519
+ export declare const AutocompleteSelect: import("react").ComponentType<{
520
+ options?: readonly unknown[] | undefined;
521
+ value?: string | undefined;
522
+ label?: string | undefined;
523
+ placeholder?: string | undefined;
524
+ disabled?: boolean | undefined;
525
+ } & {
526
+ readonly onChange?: ((payload: unknown) => void) | undefined;
527
+ } & {} & {
528
+ children?: import("react").ReactNode;
529
+ }>;
530
+ export declare const DateTimeRangeField: import("react").ComponentType<{
531
+ start?: string | undefined;
532
+ end?: string | undefined;
533
+ allDay?: boolean | undefined;
534
+ timeZone?: string | undefined;
535
+ locale?: string | undefined;
536
+ label?: string | undefined;
537
+ error?: string | undefined;
538
+ disabled?: boolean | undefined;
539
+ } & {
540
+ readonly onChange?: ((payload: unknown) => void) | undefined;
541
+ } & {} & {
542
+ children?: import("react").ReactNode;
543
+ }>;
@@ -1,4 +1,4 @@
1
- // Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.15.19. Don't edit: change the contract in
1
+ // Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.16.0. Don't edit: change the contract in
2
2
  // react-ui-components, bump `uiComponentsContracts` in package.json and run `pnpm sync:contracts`.
3
3
  import { component } from "./component.js";
4
4
  export const Badge = component("np-badge");
@@ -16,6 +16,7 @@ export const DetailColumn = component("np-detail-column");
16
16
  export const DetailRow = component("np-detail-row");
17
17
  export const FilterDropdown = component("np-filter-dropdown");
18
18
  export const FilterDropdownMultiple = component("np-filter-dropdown-multiple");
19
+ export const FilterBar = component("np-filter-bar");
19
20
  export const FilterName = component("np-filter-name");
20
21
  export const ListItemIcon = component("np-list-item-icon");
21
22
  export const ListItemAvatar = component("np-list-item-avatar");
@@ -46,3 +47,10 @@ export const RadioCard = component("np-radio-card");
46
47
  export const CodeHighlighter = component("np-code-highlighter");
47
48
  export const PageEmptyState = component("np-page-empty-state");
48
49
  export const Markdown = component("np-markdown");
50
+ export const CalendarMonth = component("np-calendar-month");
51
+ export const CalendarWeek = component("np-calendar-week");
52
+ export const CalendarTimeline = component("np-calendar-timeline");
53
+ export const ToggleButtonBar = component("np-toggle-button-group");
54
+ export const IconActionButton = component("np-icon-button");
55
+ export const AutocompleteSelect = component("np-autocomplete");
56
+ export const DateTimeRangeField = component("np-date-time-range-picker");
@@ -52,3 +52,13 @@ export const Scatter = component("np-scatter");
52
52
  export const ClusterMap = component("np-cluster-map");
53
53
  /** Horizontal share bar, `value` in 0..1. */
54
54
  export const ProgressBar = component("np-progress-bar");
55
+ /**
56
+ * Picks one platform resource by searching the ones the viewer can list, drawn by the app with its own selector.
57
+ * Not every host draws it: check `hostRenders(ResourceSelector)`.
58
+ */
59
+ export const ResourceSelector = component("np-resource-selector");
60
+ /**
61
+ * Shows one platform resource by its NRN (kind badge and name), drawn by the app with its own data: the plugin never
62
+ * gets the resolved name back. Not every host draws it: check `hostRenders(ResourceDisplay)`.
63
+ */
64
+ export const ResourceDisplay = component("np-resource-display");
package/dist/context.d.ts CHANGED
@@ -32,6 +32,7 @@ export declare function useNullplatform(): {
32
32
  };
33
33
  ui: {
34
34
  snackbar(options: import("./protocol").SnackbarOptions): Promise<void>;
35
+ confirm(options: import("./protocol").ConfirmOptions): Promise<boolean>;
35
36
  };
36
37
  context: {
37
38
  get(): Promise<PluginContext>;
@@ -3,8 +3,14 @@ export type WhenQuery = Record<string, unknown>;
3
3
  * Roots a condition may reference. The API knows how to load each one; anything else is rejected at write time.
4
4
  * `locale` and `route` are in the plugin context but are not roots: the platform resolves installations without
5
5
  * knowing either, so a condition on them could only ever hold in developer mode.
6
+ *
7
+ * `scope` holds on pages under a scope (the scope itself, its deployments), where the host resolves for the scope's
8
+ * NRN. Besides its fields a custom scope carries `specification` (`id`, `slug`, `name`): the scope type, so a
9
+ * contribution can target one kind of scope (`"scope.specification.slug": "release"`) in every organization. A
10
+ * built-in scope has none (its `provider` is not a specification): `scope.type` tells those apart. Anywhere else
11
+ * `scope` is `undefined`, so a condition on it does not match.
6
12
  */
7
- export declare const CONTEXT_ROOTS: readonly ["nrn", "organization", "account", "namespace", "application", "user"];
13
+ export declare const CONTEXT_ROOTS: readonly ["nrn", "organization", "account", "namespace", "application", "scope", "user"];
8
14
  export type ContextRoot = (typeof CONTEXT_ROOTS)[number];
9
15
  export declare const WHEN_LIMITS: {
10
16
  readonly depth: 16;
@@ -8,13 +8,19 @@ import sift from 'sift';
8
8
  * Roots a condition may reference. The API knows how to load each one; anything else is rejected at write time.
9
9
  * `locale` and `route` are in the plugin context but are not roots: the platform resolves installations without
10
10
  * knowing either, so a condition on them could only ever hold in developer mode.
11
+ *
12
+ * `scope` holds on pages under a scope (the scope itself, its deployments), where the host resolves for the scope's
13
+ * NRN. Besides its fields a custom scope carries `specification` (`id`, `slug`, `name`): the scope type, so a
14
+ * contribution can target one kind of scope (`"scope.specification.slug": "release"`) in every organization. A
15
+ * built-in scope has none (its `provider` is not a specification): `scope.type` tells those apart. Anywhere else
16
+ * `scope` is `undefined`, so a condition on it does not match.
11
17
  */
12
- export const CONTEXT_ROOTS = ['nrn', 'organization', 'account', 'namespace', 'application', 'user'];
18
+ export const CONTEXT_ROOTS = ['nrn', 'organization', 'account', 'namespace', 'application', 'scope', 'user'];
13
19
  /**
14
- * In the plugin context, but not usable in a condition yet. Installations resolve for the application's NRN, so the
15
- * platform never loads a scope or a deployment and a condition on either would silently never match.
20
+ * In the plugin context, but not usable in a condition yet. Installations resolve for the application's NRN (or the
21
+ * scope's), so the platform never loads a deployment or a build and a condition on either would silently never match.
16
22
  */
17
- const UNSUPPORTED_ROOTS = new Set(['scope', 'deployment']);
23
+ const UNSUPPORTED_ROOTS = new Set(['deployment', 'build']);
18
24
  /** Operators that would execute code or are meaningless outside MongoDB. */
19
25
  const ALLOWED_OPERATORS = new Set(['$eq', '$ne', '$gt', '$gte', '$lt', '$lte', '$in', '$nin', '$exists', '$size', '$all', '$elemMatch', '$not', '$and', '$or', '$nor', '$mod']);
20
26
  export const WHEN_LIMITS = { depth: 16, nodes: 512, array: 100, string: 1024 };
@@ -18,13 +18,19 @@ const sift_1 = __importDefault(require("sift"));
18
18
  * Roots a condition may reference. The API knows how to load each one; anything else is rejected at write time.
19
19
  * `locale` and `route` are in the plugin context but are not roots: the platform resolves installations without
20
20
  * knowing either, so a condition on them could only ever hold in developer mode.
21
+ *
22
+ * `scope` holds on pages under a scope (the scope itself, its deployments), where the host resolves for the scope's
23
+ * NRN. Besides its fields a custom scope carries `specification` (`id`, `slug`, `name`): the scope type, so a
24
+ * contribution can target one kind of scope (`"scope.specification.slug": "release"`) in every organization. A
25
+ * built-in scope has none (its `provider` is not a specification): `scope.type` tells those apart. Anywhere else
26
+ * `scope` is `undefined`, so a condition on it does not match.
21
27
  */
22
- exports.CONTEXT_ROOTS = ['nrn', 'organization', 'account', 'namespace', 'application', 'user'];
28
+ exports.CONTEXT_ROOTS = ['nrn', 'organization', 'account', 'namespace', 'application', 'scope', 'user'];
23
29
  /**
24
- * In the plugin context, but not usable in a condition yet. Installations resolve for the application's NRN, so the
25
- * platform never loads a scope or a deployment and a condition on either would silently never match.
30
+ * In the plugin context, but not usable in a condition yet. Installations resolve for the application's NRN (or the
31
+ * scope's), so the platform never loads a deployment or a build and a condition on either would silently never match.
26
32
  */
27
- const UNSUPPORTED_ROOTS = new Set(['scope', 'deployment']);
33
+ const UNSUPPORTED_ROOTS = new Set(['deployment', 'build']);
28
34
  /** Operators that would execute code or are meaningless outside MongoDB. */
29
35
  const ALLOWED_OPERATORS = new Set(['$eq', '$ne', '$gt', '$gte', '$lt', '$lte', '$in', '$nin', '$exists', '$size', '$all', '$elemMatch', '$not', '$and', '$or', '$nor', '$mod']);
30
36
  exports.WHEN_LIMITS = { depth: 16, nodes: 512, array: 100, string: 1024 };
@@ -190,6 +190,23 @@ export declare const UI_COMPONENTS_CONTRACTS: readonly [{
190
190
  readonly events: {
191
191
  readonly change: "onChange";
192
192
  };
193
+ }, {
194
+ readonly tag: "np-filter-bar";
195
+ readonly component: "FilterBar";
196
+ readonly properties: {
197
+ readonly attributes: "array";
198
+ readonly value: "object";
199
+ readonly config: "object";
200
+ readonly localeText: "object";
201
+ readonly liveApply: "boolean";
202
+ readonly loading: "boolean";
203
+ };
204
+ readonly events: {
205
+ readonly change: "onChange";
206
+ };
207
+ readonly values: {
208
+ readonly "attributes[].editor": readonly ["multiSelect", "enum"];
209
+ };
193
210
  }, {
194
211
  readonly tag: "np-filter-name";
195
212
  readonly component: "FilterName";
@@ -239,6 +256,7 @@ export declare const UI_COMPONENTS_CONTRACTS: readonly [{
239
256
  readonly showTooltip: "boolean";
240
257
  readonly emptyText: "string";
241
258
  readonly live: "boolean";
259
+ readonly muted: "boolean";
242
260
  };
243
261
  readonly events: {};
244
262
  }, {
@@ -610,4 +628,141 @@ export declare const UI_COMPONENTS_CONTRACTS: readonly [{
610
628
  readonly defaults: {
611
629
  readonly content: "";
612
630
  };
631
+ }, {
632
+ readonly tag: "np-calendar-month";
633
+ readonly component: "CalendarMonth";
634
+ readonly properties: {
635
+ readonly month: "string";
636
+ readonly timeZone: "string";
637
+ readonly weekStartsOn: "number";
638
+ readonly today: "string";
639
+ readonly events: "array";
640
+ readonly selectedId: "string";
641
+ readonly maxLanes: "number";
642
+ readonly locale: "string";
643
+ };
644
+ readonly events: {
645
+ readonly eventPress: "onEventPress";
646
+ readonly dayPress: "onDayPress";
647
+ readonly morePress: "onMorePress";
648
+ };
649
+ readonly values: {
650
+ readonly "events[].kind": readonly ["freeze", "window"];
651
+ readonly "events[].state": readonly ["active", "upcoming", "past"];
652
+ };
653
+ readonly defaults: {
654
+ readonly weekStartsOn: 1;
655
+ readonly maxLanes: 2;
656
+ };
657
+ }, {
658
+ readonly tag: "np-calendar-week";
659
+ readonly component: "CalendarWeek";
660
+ readonly properties: {
661
+ readonly weekStart: "string";
662
+ readonly timeZone: "string";
663
+ readonly startHour: "number";
664
+ readonly endHour: "number";
665
+ readonly events: "array";
666
+ readonly selectedId: "string";
667
+ readonly now: "string";
668
+ readonly locale: "string";
669
+ readonly allDayLabel: "string";
670
+ };
671
+ readonly events: {
672
+ readonly eventPress: "onEventPress";
673
+ readonly slotPress: "onSlotPress";
674
+ };
675
+ readonly values: {
676
+ readonly "events[].kind": readonly ["freeze", "window"];
677
+ readonly "events[].state": readonly ["active", "upcoming", "past"];
678
+ };
679
+ readonly defaults: {
680
+ readonly startHour: 0;
681
+ readonly endHour: 24;
682
+ };
683
+ }, {
684
+ readonly tag: "np-calendar-timeline";
685
+ readonly component: "CalendarTimeline";
686
+ readonly properties: {
687
+ readonly from: "string";
688
+ readonly to: "string";
689
+ readonly timeZone: "string";
690
+ readonly rows: "array";
691
+ readonly bars: "array";
692
+ readonly selectedId: "string";
693
+ readonly now: "string";
694
+ readonly locale: "string";
695
+ readonly resourceLabel: "string";
696
+ };
697
+ readonly events: {
698
+ readonly barPress: "onBarPress";
699
+ };
700
+ readonly values: {
701
+ readonly "rows[].kind": readonly ["organization", "account", "namespace", "application"];
702
+ readonly "bars[].kind": readonly ["freeze", "window"];
703
+ readonly "bars[].state": readonly ["active", "upcoming", "past"];
704
+ };
705
+ }, {
706
+ readonly tag: "np-toggle-button-group";
707
+ readonly component: "ToggleButtonBar";
708
+ readonly properties: {
709
+ readonly options: "array";
710
+ readonly value: "string";
711
+ readonly size: "string";
712
+ readonly "aria-label": "string";
713
+ readonly multiple: "boolean";
714
+ readonly values: "array";
715
+ };
716
+ readonly events: {
717
+ readonly change: "onChange";
718
+ };
719
+ readonly values: {
720
+ readonly size: readonly ["small", "medium", "large"];
721
+ };
722
+ }, {
723
+ readonly tag: "np-icon-button";
724
+ readonly component: "IconActionButton";
725
+ readonly properties: {
726
+ readonly icon: "string";
727
+ readonly "aria-label": "string";
728
+ readonly color: "string";
729
+ readonly size: "string";
730
+ readonly disabled: "boolean";
731
+ };
732
+ readonly events: {
733
+ readonly press: "onPress";
734
+ };
735
+ readonly values: {
736
+ readonly color: readonly ["default", "inherit", "primary", "secondary", "error", "info", "success", "warning"];
737
+ readonly size: readonly ["small", "medium", "large"];
738
+ };
739
+ }, {
740
+ readonly tag: "np-autocomplete";
741
+ readonly component: "AutocompleteSelect";
742
+ readonly properties: {
743
+ readonly options: "array";
744
+ readonly value: "string";
745
+ readonly label: "string";
746
+ readonly placeholder: "string";
747
+ readonly disabled: "boolean";
748
+ };
749
+ readonly events: {
750
+ readonly change: "onChange";
751
+ };
752
+ }, {
753
+ readonly tag: "np-date-time-range-picker";
754
+ readonly component: "DateTimeRangeField";
755
+ readonly properties: {
756
+ readonly start: "string";
757
+ readonly end: "string";
758
+ readonly allDay: "boolean";
759
+ readonly timeZone: "string";
760
+ readonly locale: "string";
761
+ readonly label: "string";
762
+ readonly error: "string";
763
+ readonly disabled: "boolean";
764
+ };
765
+ readonly events: {
766
+ readonly change: "onChange";
767
+ };
613
768
  }];
@@ -1,4 +1,4 @@
1
- // Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.15.19. Don't edit: change the contract in
1
+ // Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.16.0. Don't edit: change the contract in
2
2
  // react-ui-components, bump `uiComponentsContracts` in package.json and run `pnpm sync:contracts`.
3
3
  export const UI_COMPONENTS_CONTRACTS = [
4
4
  {
@@ -112,6 +112,13 @@ export const UI_COMPONENTS_CONTRACTS = [
112
112
  properties: { "label": "string", "elements": "array", "selected": "array", "loading": "boolean", "disabled": "boolean", "showActions": "boolean" },
113
113
  events: { "change": "onChange" },
114
114
  },
115
+ {
116
+ tag: "np-filter-bar",
117
+ component: "FilterBar",
118
+ properties: { "attributes": "array", "value": "object", "config": "object", "localeText": "object", "liveApply": "boolean", "loading": "boolean" },
119
+ events: { "change": "onChange" },
120
+ values: { "attributes[].editor": ["multiSelect", "enum"] },
121
+ },
115
122
  {
116
123
  tag: "np-filter-name",
117
124
  component: "FilterName",
@@ -143,7 +150,7 @@ export const UI_COMPONENTS_CONTRACTS = [
143
150
  {
144
151
  tag: "np-relative-date",
145
152
  component: "RelativeDate",
146
- properties: { "date": "string", "icon": "string", "label": "string", "hideLabel": "boolean", "options": "object", "showTooltip": "boolean", "emptyText": "string", "live": "boolean" },
153
+ properties: { "date": "string", "icon": "string", "label": "string", "hideLabel": "boolean", "options": "object", "showTooltip": "boolean", "emptyText": "string", "live": "boolean", "muted": "boolean" },
147
154
  events: {},
148
155
  },
149
156
  {
@@ -322,4 +329,53 @@ export const UI_COMPONENTS_CONTRACTS = [
322
329
  events: {},
323
330
  defaults: { "content": "" },
324
331
  },
332
+ {
333
+ tag: "np-calendar-month",
334
+ component: "CalendarMonth",
335
+ properties: { "month": "string", "timeZone": "string", "weekStartsOn": "number", "today": "string", "events": "array", "selectedId": "string", "maxLanes": "number", "locale": "string" },
336
+ events: { "eventPress": "onEventPress", "dayPress": "onDayPress", "morePress": "onMorePress" },
337
+ values: { "events[].kind": ["freeze", "window"], "events[].state": ["active", "upcoming", "past"] },
338
+ defaults: { "weekStartsOn": 1, "maxLanes": 2 },
339
+ },
340
+ {
341
+ tag: "np-calendar-week",
342
+ component: "CalendarWeek",
343
+ properties: { "weekStart": "string", "timeZone": "string", "startHour": "number", "endHour": "number", "events": "array", "selectedId": "string", "now": "string", "locale": "string", "allDayLabel": "string" },
344
+ events: { "eventPress": "onEventPress", "slotPress": "onSlotPress" },
345
+ values: { "events[].kind": ["freeze", "window"], "events[].state": ["active", "upcoming", "past"] },
346
+ defaults: { "startHour": 0, "endHour": 24 },
347
+ },
348
+ {
349
+ tag: "np-calendar-timeline",
350
+ component: "CalendarTimeline",
351
+ properties: { "from": "string", "to": "string", "timeZone": "string", "rows": "array", "bars": "array", "selectedId": "string", "now": "string", "locale": "string", "resourceLabel": "string" },
352
+ events: { "barPress": "onBarPress" },
353
+ values: { "rows[].kind": ["organization", "account", "namespace", "application"], "bars[].kind": ["freeze", "window"], "bars[].state": ["active", "upcoming", "past"] },
354
+ },
355
+ {
356
+ tag: "np-toggle-button-group",
357
+ component: "ToggleButtonBar",
358
+ properties: { "options": "array", "value": "string", "size": "string", "aria-label": "string", "multiple": "boolean", "values": "array" },
359
+ events: { "change": "onChange" },
360
+ values: { "size": ["small", "medium", "large"] },
361
+ },
362
+ {
363
+ tag: "np-icon-button",
364
+ component: "IconActionButton",
365
+ properties: { "icon": "string", "aria-label": "string", "color": "string", "size": "string", "disabled": "boolean" },
366
+ events: { "press": "onPress" },
367
+ values: { "color": ["default", "inherit", "primary", "secondary", "error", "info", "success", "warning"], "size": ["small", "medium", "large"] },
368
+ },
369
+ {
370
+ tag: "np-autocomplete",
371
+ component: "AutocompleteSelect",
372
+ properties: { "options": "array", "value": "string", "label": "string", "placeholder": "string", "disabled": "boolean" },
373
+ events: { "change": "onChange" },
374
+ },
375
+ {
376
+ tag: "np-date-time-range-picker",
377
+ component: "DateTimeRangeField",
378
+ properties: { "start": "string", "end": "string", "allDay": "boolean", "timeZone": "string", "locale": "string", "label": "string", "error": "string", "disabled": "boolean" },
379
+ events: { "change": "onChange" },
380
+ },
325
381
  ];
package/dist/elements.js CHANGED
@@ -11,7 +11,9 @@ const registry = new Map();
11
11
  function defineElement(spec) {
12
12
  const properties = {};
13
13
  for (const [name, type] of Object.entries(spec.properties)) {
14
- const ctor = type === 'number' ? Number : type === 'boolean' ? Boolean : type === 'string' ? String : Object;
14
+ // Not `Boolean` for booleans: remote-dom starts those at `false`, which would override a component whose default
15
+ // is `true` for every plugin that leaves the prop out. The host checks each value against the catalog's type.
16
+ const ctor = type === 'number' ? Number : type === 'string' ? String : Object;
15
17
  properties[name] = { type: ctor, attribute: false };
16
18
  }
17
19
  const events = {};
package/dist/index.d.ts CHANGED
@@ -5,5 +5,5 @@ export { nullplatform, type NullplatformBridge } from './bridge.js';
5
5
  export { useTopic, useSetTopic, type UseTopicOptions, type UseTopicResult, type UseSetTopicOptions, type SetTopicState, type TopicMap, type ServiceDraftV1, } from './topics.js';
6
6
  export * from './components.js';
7
7
  export { hostRenders } from './host.js';
8
- export type { PluginContext, ApiRequest, HttpRequest, HttpResponse, NavigationTarget, SnackbarOptions, TopicSnapshot, TopicStatus } from './protocol.js';
8
+ export type { PluginContext, ApiRequest, HttpRequest, HttpResponse, NavigationTarget, SnackbarOptions, ConfirmOptions, TopicSnapshot, TopicStatus } from './protocol.js';
9
9
  export { BridgeError } from './protocol.js';
@@ -35,16 +35,28 @@ export interface PluginContext {
35
35
  slug?: string;
36
36
  name?: string;
37
37
  };
38
- /** Set on scope pages. Not usable in `when` yet (see `CONTEXT_ROOTS`). */
38
+ /**
39
+ * Set on pages under a scope (the scope, its deployments). `specification` is the scope type, the same a `when`
40
+ * reads as `scope.specification.*` (see `CONTEXT_ROOTS`); a host that does not know it leaves it out.
41
+ */
39
42
  scope?: {
40
43
  id: number | string;
41
44
  slug?: string;
42
45
  name?: string;
46
+ specification?: {
47
+ id: string;
48
+ slug?: string;
49
+ name?: string;
50
+ };
43
51
  };
44
52
  /** Set on deployment pages. Not usable in `when` yet (see `CONTEXT_ROOTS`). */
45
53
  deployment?: {
46
54
  id: number | string;
47
55
  };
56
+ /** Set on build pages. Not usable in `when` yet (see `CONTEXT_ROOTS`). */
57
+ build?: {
58
+ id: number | string;
59
+ };
48
60
  nrn?: string;
49
61
  user?: {
50
62
  id: number | string;
@@ -89,6 +101,27 @@ export interface SnackbarOptions {
89
101
  title: string;
90
102
  variant?: 'default' | 'success' | 'error' | 'warning' | 'info';
91
103
  }
104
+ /**
105
+ * A confirmation the host draws with its own dialog: a plugin cannot draw over the page. The host caps every
106
+ * field (see `CONFIRM_LIMITS`) and rejects options over a cap rather than truncating what the person reads.
107
+ */
108
+ export interface ConfirmOptions {
109
+ title: string;
110
+ message: string;
111
+ confirmLabel?: string;
112
+ cancelLabel?: string;
113
+ /** Draws the confirm action as destructive: the dashboard uses its deletion dialog. */
114
+ destructive?: boolean;
115
+ /** When set, the person must type it to confirm (the dashboard's DeletionModal does this). */
116
+ confirmationToken?: string;
117
+ }
118
+ /** Maximum length of each `ConfirmOptions` string. */
119
+ export declare const CONFIRM_LIMITS: {
120
+ readonly title: 200;
121
+ readonly message: 1000;
122
+ readonly label: 40;
123
+ readonly confirmationToken: 100;
124
+ };
92
125
  /** Methods a plugin can call on the host. */
93
126
  export interface BridgeMethods {
94
127
  'assets.url': (path: string) => Promise<string>;
@@ -96,6 +129,8 @@ export interface BridgeMethods {
96
129
  'http.request': (request: HttpRequest) => Promise<HttpResponse>;
97
130
  'navigation.push': (target: NavigationTarget) => Promise<void>;
98
131
  'ui.snackbar': (options: SnackbarOptions) => Promise<void>;
132
+ /** Resolves `true` only when the person confirms; `false` when they cancel or the host draws no dialog. */
133
+ 'ui.confirm': (options: ConfirmOptions) => Promise<boolean>;
99
134
  'context.get': () => Promise<PluginContext>;
100
135
  'topics.get': (topic: string) => Promise<TopicSnapshot>;
101
136
  'topics.subscribe': (topic: string) => Promise<TopicSnapshot>;
@@ -104,6 +139,12 @@ export interface BridgeMethods {
104
139
  'topics.clear': (topic: string) => Promise<void>;
105
140
  }
106
141
  export type BridgeMethodName = keyof BridgeMethods;
142
+ /** How long the host gives a bridge call before it answers `TIMEOUT`. */
143
+ export declare const BRIDGE_CALL_DEADLINE_MS = 30000;
144
+ /** Calls that wait for a person, not a machine, and so get longer than `BRIDGE_CALL_DEADLINE_MS`. */
145
+ export declare const BRIDGE_CALL_DEADLINES_MS: Readonly<Partial<Record<BridgeMethodName, number>>>;
146
+ /** The host's deadline for one call. */
147
+ export declare function bridgeCallDeadline(method: BridgeMethodName): number;
107
148
  /**
108
149
  * Whether a topic has a value on this page: `waiting` when something on the page provides it but has not
109
150
  * set a value yet, `no-provider` when nothing on the page provides it.
package/dist/protocol.js CHANGED
@@ -7,6 +7,18 @@
7
7
  * host side; the host invokes them with a `fn` message.
8
8
  */
9
9
  export const PROTOCOL_VERSION = 1;
10
+ /** Maximum length of each `ConfirmOptions` string. */
11
+ export const CONFIRM_LIMITS = { title: 200, message: 1000, label: 40, confirmationToken: 100 };
12
+ /** How long the host gives a bridge call before it answers `TIMEOUT`. */
13
+ export const BRIDGE_CALL_DEADLINE_MS = 30000;
14
+ /** Calls that wait for a person, not a machine, and so get longer than `BRIDGE_CALL_DEADLINE_MS`. */
15
+ export const BRIDGE_CALL_DEADLINES_MS = {
16
+ 'ui.confirm': 10 * 60 * 1000,
17
+ };
18
+ /** The host's deadline for one call. */
19
+ export function bridgeCallDeadline(method) {
20
+ return BRIDGE_CALL_DEADLINES_MS[method] ?? BRIDGE_CALL_DEADLINE_MS;
21
+ }
10
22
  export class BridgeError extends Error {
11
23
  code;
12
24
  status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nullplatform/ui-plugin-sdk",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "SDK for nullplatform UI plugins: catalog components, bridge client and defineUI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -42,7 +42,7 @@
42
42
  "test": "vitest run --passWithNoTests",
43
43
  "sync:contracts": "node scripts/sync-contracts.mjs"
44
44
  },
45
- "uiComponentsContracts": "0.15.19",
45
+ "uiComponentsContracts": "0.16.0",
46
46
  "dependencies": {
47
47
  "@remote-dom/core": "^1.11.1",
48
48
  "@remote-dom/react": "^1.2.2",