@nullplatform/ui-plugin-sdk 0.18.0 → 0.19.1

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,58 @@
1
+ import type { UI_COMPONENTS_CONTRACTS } from "./contracts.generated.js";
2
+ /**
3
+ * The items the design system's calendars take from a plugin, which their contracts can only type as arrays. Dates
4
+ * are ISO-8601 strings: an instant `end` is exclusive, a date-only `end` includes its day.
5
+ */
6
+ type ContractValues<Tag> = Extract<(typeof UI_COMPONENTS_CONTRACTS)[number], {
7
+ tag: Tag;
8
+ }> extends {
9
+ values: infer V;
10
+ } ? V : never;
11
+ type TimelineValues = ContractValues<"np-calendar-timeline">;
12
+ /** A deploy freeze or a deploy window. */
13
+ export type CalendarEventKind = ContractValues<"np-calendar-month">["events[].kind"][number];
14
+ /** Where an item stands against now. Left out, the calendar derives it from the times. */
15
+ export type CalendarEventState = ContractValues<"np-calendar-month">["events[].state"][number];
16
+ export type CalendarTimelineRowKind = TimelineValues["rows[].kind"][number];
17
+ /** An event on `CalendarMonth` or `CalendarWeek`. */
18
+ export interface CalendarEvent {
19
+ id: string;
20
+ title: string;
21
+ start: string;
22
+ end: string;
23
+ /** Drawn in the week's "all day" row, whatever its times. */
24
+ allDay?: boolean;
25
+ kind: CalendarEventKind;
26
+ state?: CalendarEventState;
27
+ /** A short line after the title: the hours, a scope. */
28
+ meta?: string;
29
+ /** Drawn with a repeat mark. */
30
+ recurring?: boolean;
31
+ }
32
+ /** A resource on `CalendarTimeline`, indented by `depth` under its parent. */
33
+ export interface CalendarTimelineRow {
34
+ id: string;
35
+ label: string;
36
+ kind: CalendarTimelineRowKind;
37
+ depth: number;
38
+ }
39
+ /** A bar on a `CalendarTimeline` row. */
40
+ export interface CalendarTimelineBar {
41
+ id: string;
42
+ rowId: string;
43
+ title: string;
44
+ start: string;
45
+ end: string;
46
+ kind: CalendarEventKind;
47
+ /** Set on a resource from one above it: drawn hatched, with a dashed border. */
48
+ inherited?: boolean;
49
+ state?: CalendarEventState;
50
+ meta?: string;
51
+ recurring?: boolean;
52
+ }
53
+ /** An empty hour of `CalendarWeek`, as instants. */
54
+ export interface CalendarSlot {
55
+ start: string;
56
+ end: string;
57
+ }
58
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -8,6 +8,7 @@ import { type AlertSeverity, type ButtonColor, type ButtonSize, type ButtonVaria
8
8
  export type { AlertSeverity, ButtonColor, ButtonSize, ButtonVariant, CardTone, ChipColor, ChipSize, ChipVariant, LinkColor, LinkUnderline, ScatterScale, SkeletonVariant, StackDirection, TextAlign, TextVariant, } from "./catalog.js";
9
9
  export * from "./components.generated.js";
10
10
  export type { ContractProps, UiComponentsTag } from "./contractProps.js";
11
+ export type { CalendarEvent, CalendarEventKind, CalendarEventState, CalendarSlot, CalendarTimelineBar, CalendarTimelineRow, CalendarTimelineRowKind, } from "./calendar.js";
11
12
  export type { DataTableAvatar, DataTableColor, DataTableColumn, DataTableFormatter, DataTableLabelVariant, DataTableLink, DataTablePagination, DataTableRow, DataTableRowAction, DataTableState, DataTableTypography, } from "./dataTable.js";
12
13
  export declare const TextField: import("react").ComponentType<{
13
14
  label: string;
@@ -446,7 +446,7 @@ export declare const Markdown: import("react").ComponentType<{
446
446
  } & {} & {} & {
447
447
  children?: import("react").ReactNode;
448
448
  }>;
449
- export declare const CalendarMonth: import("react").ComponentType<{
449
+ export declare const CalendarMonth: import("react").ComponentType<Omit<{
450
450
  month?: string | undefined;
451
451
  timeZone?: string | undefined;
452
452
  weekStartsOn?: number | undefined;
@@ -459,10 +459,15 @@ export declare const CalendarMonth: import("react").ComponentType<{
459
459
  readonly onEventPress?: ((payload: unknown) => void) | undefined;
460
460
  readonly onDayPress?: ((payload: unknown) => void) | undefined;
461
461
  readonly onMorePress?: ((payload: unknown) => void) | undefined;
462
- } & {} & {
462
+ } & {}, "onEventPress" | "onDayPress" | "onMorePress" | "events"> & Pick<{
463
+ events?: readonly import("./calendar").CalendarEvent[];
464
+ onEventPress?: (id: string) => void;
465
+ onDayPress?: (day: string) => void;
466
+ onMorePress?: (day: string) => void;
467
+ }, "onEventPress" | "onDayPress" | "onMorePress" | "events"> & {
463
468
  children?: import("react").ReactNode;
464
469
  }>;
465
- export declare const CalendarWeek: import("react").ComponentType<{
470
+ export declare const CalendarWeek: import("react").ComponentType<Omit<{
466
471
  weekStart?: string | undefined;
467
472
  timeZone?: string | undefined;
468
473
  startHour?: number | undefined;
@@ -475,10 +480,14 @@ export declare const CalendarWeek: import("react").ComponentType<{
475
480
  } & {
476
481
  readonly onEventPress?: ((payload: unknown) => void) | undefined;
477
482
  readonly onSlotPress?: ((payload: unknown) => void) | undefined;
478
- } & {} & {
483
+ } & {}, "onEventPress" | "onSlotPress" | "events"> & Pick<{
484
+ events?: readonly import("./calendar").CalendarEvent[];
485
+ onEventPress?: (id: string) => void;
486
+ onSlotPress?: (slot: import("./calendar").CalendarSlot) => void;
487
+ }, "onEventPress" | "onSlotPress" | "events"> & {
479
488
  children?: import("react").ReactNode;
480
489
  }>;
481
- export declare const CalendarTimeline: import("react").ComponentType<{
490
+ export declare const CalendarTimeline: import("react").ComponentType<Omit<{
482
491
  from?: string | undefined;
483
492
  to?: string | undefined;
484
493
  timeZone?: string | undefined;
@@ -488,9 +497,20 @@ export declare const CalendarTimeline: import("react").ComponentType<{
488
497
  now?: string | undefined;
489
498
  locale?: string | undefined;
490
499
  resourceLabel?: string | undefined;
500
+ loading?: boolean | undefined;
501
+ emptyStateProps?: Readonly<Record<string, unknown>> | undefined;
502
+ maxRows?: number | undefined;
491
503
  } & {
492
504
  readonly onBarPress?: ((payload: unknown) => void) | undefined;
493
- } & {} & {
505
+ } & {}, "onBarPress" | "rows" | "bars" | "emptyStateProps"> & Pick<{
506
+ rows?: readonly import("./calendar").CalendarTimelineRow[];
507
+ bars?: readonly import("./calendar").CalendarTimelineBar[];
508
+ emptyStateProps?: {
509
+ title?: string;
510
+ description?: string;
511
+ };
512
+ onBarPress?: (id: string) => void;
513
+ }, "onBarPress" | "rows" | "bars" | "emptyStateProps"> & {
494
514
  children?: import("react").ReactNode;
495
515
  }>;
496
516
  export declare const ToggleButtonBar: import("react").ComponentType<{
@@ -541,3 +561,121 @@ export declare const DateTimeRangeField: import("react").ComponentType<{
541
561
  } & {} & {
542
562
  children?: import("react").ReactNode;
543
563
  }>;
564
+ export declare const Checkbox: import("react").ComponentType<{
565
+ checked?: boolean | undefined;
566
+ disabled?: boolean | undefined;
567
+ } & {
568
+ readonly onChange?: ((payload: unknown) => void) | undefined;
569
+ } & {} & {
570
+ children?: import("react").ReactNode;
571
+ }>;
572
+ export declare const CheckboxCard: import("react").ComponentType<{
573
+ label?: string | undefined;
574
+ description?: string | undefined;
575
+ icon?: string | undefined;
576
+ checked?: boolean | undefined;
577
+ size?: "sm" | "md" | "lg" | undefined;
578
+ variant?: "outline" | "surface" | "subtle" | "solid" | undefined;
579
+ align?: "center" | "start" | "end" | undefined;
580
+ justify?: "center" | "start" | "end" | undefined;
581
+ orientation?: "horizontal" | "vertical" | undefined;
582
+ indicator?: boolean | undefined;
583
+ disabled?: boolean | undefined;
584
+ readOnly?: boolean | undefined;
585
+ error?: boolean | undefined;
586
+ } & {
587
+ readonly onChange?: ((payload: unknown) => void) | undefined;
588
+ } & {} & {
589
+ children?: import("react").ReactNode;
590
+ }>;
591
+ export declare const Slider: import("react").ComponentType<{
592
+ value?: number | undefined;
593
+ min?: number | undefined;
594
+ max?: number | undefined;
595
+ step?: number | undefined;
596
+ disabled?: boolean | undefined;
597
+ "aria-label"?: string | undefined;
598
+ } & {
599
+ readonly onChange?: ((payload: unknown) => void) | undefined;
600
+ readonly onChangeCommitted?: ((payload: unknown) => void) | undefined;
601
+ } & {} & {
602
+ children?: import("react").ReactNode;
603
+ }>;
604
+ export declare const Accordion: import("react").ComponentType<{
605
+ expanded?: boolean | undefined;
606
+ defaultExpanded?: boolean | undefined;
607
+ disabled?: boolean | undefined;
608
+ disableGutters?: boolean | undefined;
609
+ } & {
610
+ readonly onChange?: ((payload: unknown) => void) | undefined;
611
+ } & {} & {
612
+ children?: import("react").ReactNode;
613
+ }>;
614
+ export declare const AccordionSummary: import("react").ComponentType<{} & {} & {
615
+ expandIcon?: import("react").ReactNode;
616
+ } & {
617
+ children?: import("react").ReactNode;
618
+ }>;
619
+ export declare const AccordionDetails: import("react").ComponentType<{} & {} & {} & {
620
+ children?: import("react").ReactNode;
621
+ }>;
622
+ export declare const DatePickerField: import("react").ComponentType<{
623
+ value?: string | undefined;
624
+ minDate?: string | undefined;
625
+ maxDate?: string | undefined;
626
+ timeZone?: string | undefined;
627
+ label?: string | undefined;
628
+ helperText?: string | undefined;
629
+ error?: boolean | undefined;
630
+ disabled?: boolean | undefined;
631
+ } & {
632
+ readonly onChange?: ((payload: unknown) => void) | undefined;
633
+ } & {} & {
634
+ children?: import("react").ReactNode;
635
+ }>;
636
+ export declare const FilterSingleDateField: import("react").ComponentType<{
637
+ value?: string | undefined;
638
+ preset?: string | undefined;
639
+ presets?: readonly unknown[] | undefined;
640
+ timeZone?: string | undefined;
641
+ label?: string | undefined;
642
+ placeholder?: string | undefined;
643
+ customLabel?: string | undefined;
644
+ helperText?: string | undefined;
645
+ error?: boolean | undefined;
646
+ required?: boolean | undefined;
647
+ disabled?: boolean | undefined;
648
+ minDate?: string | undefined;
649
+ maxDate?: string | undefined;
650
+ disablePast?: boolean | undefined;
651
+ disableFuture?: boolean | undefined;
652
+ hideActionButtons?: boolean | undefined;
653
+ } & {
654
+ readonly onChange?: ((payload: unknown) => void) | undefined;
655
+ } & {} & {
656
+ children?: import("react").ReactNode;
657
+ }>;
658
+ export declare const Stepper: import("react").ComponentType<{
659
+ activeStep?: number | undefined;
660
+ orientation?: "horizontal" | "vertical" | undefined;
661
+ alternativeLabel?: boolean | undefined;
662
+ nonLinear?: boolean | undefined;
663
+ } & {} & {} & {
664
+ children?: import("react").ReactNode;
665
+ }>;
666
+ export declare const Step: import("react").ComponentType<{
667
+ index?: number | undefined;
668
+ last?: boolean | undefined;
669
+ active?: boolean | undefined;
670
+ completed?: boolean | undefined;
671
+ disabled?: boolean | undefined;
672
+ } & {} & {} & {
673
+ children?: import("react").ReactNode;
674
+ }>;
675
+ export declare const StepLabel: import("react").ComponentType<{
676
+ error?: boolean | undefined;
677
+ } & {} & {
678
+ optional?: import("react").ReactNode;
679
+ } & {
680
+ children?: import("react").ReactNode;
681
+ }>;
@@ -1,4 +1,4 @@
1
- // Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.16.0. Don't edit: change the contract in
1
+ // Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.16.15. 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");
@@ -54,3 +54,14 @@ export const ToggleButtonBar = component("np-toggle-button-group");
54
54
  export const IconActionButton = component("np-icon-button");
55
55
  export const AutocompleteSelect = component("np-autocomplete");
56
56
  export const DateTimeRangeField = component("np-date-time-range-picker");
57
+ export const Checkbox = component("np-checkbox");
58
+ export const CheckboxCard = component("np-checkbox-card");
59
+ export const Slider = component("np-slider");
60
+ export const Accordion = component("np-accordion");
61
+ export const AccordionSummary = component("np-accordion-summary");
62
+ export const AccordionDetails = component("np-accordion-details");
63
+ export const DatePickerField = component("np-date-picker");
64
+ export const FilterSingleDateField = component("np-filter-single-date");
65
+ export const Stepper = component("np-stepper");
66
+ export const Step = component("np-step");
67
+ export const StepLabel = component("np-step-label");
@@ -9,6 +9,11 @@ export declare function normalizePath(path: string): string[] | null;
9
9
  export declare function canonicalizePath(path: string): string | null;
10
10
  /** `{param}` placeholders match exactly one non-empty segment. */
11
11
  export declare function pathMatches(pattern: string, requestSegments: string[]): boolean;
12
+ /**
13
+ * True when no plugin may call `method` on `path`, whatever its manifest declares. A path that
14
+ * does not normalize is not reserved: `isApiRequestAllowed` already refuses it.
15
+ */
16
+ export declare function isReservedApiRequest(method: string, path: string): boolean;
12
17
  /**
13
18
  * Decides whether a plugin API request (a nullplatform public API path) is covered
14
19
  * by its declared `permissions.api`. Query strings are never part of the decision.
@@ -41,6 +41,81 @@ export function pathMatches(pattern, requestSegments) {
41
41
  return segment === requestSegments[index];
42
42
  });
43
43
  }
44
+ // A plugin call runs with the token of whoever is looking at the page, so a manifest that names
45
+ // one of these would act with an administrator's rights for every administrator who opens it.
46
+ // Each entry is a path prefix: it reserves that path and everything under it.
47
+ const RESERVED_FOR_EVERY_METHOD = [
48
+ // Credentials.
49
+ ['api_key'],
50
+ ['pat'],
51
+ ['token'],
52
+ ];
53
+ const RESERVED_FOR_WRITES = [
54
+ // Who may do what.
55
+ ['authz'],
56
+ ['user'],
57
+ // Which code an organization runs.
58
+ ['packages'],
59
+ ['package_revision'],
60
+ ['package_installations'],
61
+ ['artifacts'],
62
+ ['artifact_revision'],
63
+ ['plugin_bundles'],
64
+ // Catalog lake ingest: it adds entities to the catalog.
65
+ ['catalog', 'lake'],
66
+ ];
67
+ // Writes under a prefix reserved for writes that a plugin may still make. Each is exact: one
68
+ // method, never `*` (which would cover the other writes too), and one path, never a prefix, where
69
+ // `{id}` matches one segment.
70
+ const ALLOWED_UNDER_RESERVED = [
71
+ // Asks whether the viewer may do something; it grants nothing.
72
+ ['POST', '/authz/check'],
73
+ // What the authz backoffice (nullplatform/frontend-authz-backoffice) writes. Allowed for now,
74
+ // to every plugin: nothing yet tells a platform plugin from a customer's (BAC-3552).
75
+ ['POST', '/authz/role'],
76
+ ['PATCH', '/authz/role/{id}'],
77
+ ['POST', '/authz/role/{id}/action'],
78
+ ['POST', '/authz/action'],
79
+ ['PATCH', '/authz/action/{id}'],
80
+ ['POST', '/authz/action_group'],
81
+ ['PATCH', '/authz/action_group/{id}'],
82
+ ['DELETE', '/authz/action_group/{id}'],
83
+ ['POST', '/authz/role_hierarchy'],
84
+ ['DELETE', '/authz/role_hierarchy/{id}'],
85
+ ['POST', '/authz/role_action_modifier'],
86
+ ['DELETE', '/authz/role_action_modifier/{id}'],
87
+ ];
88
+ // `*` counts as a write: a permission declared with it covers the writes too.
89
+ const WRITE_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE', '*']);
90
+ function startsWith(segments, prefix) {
91
+ return prefix.length <= segments.length && prefix.every((segment, index) => segments[index].toLowerCase() === segment);
92
+ }
93
+ function isAllowedUnderReserved(verb, segments) {
94
+ return ALLOWED_UNDER_RESERVED.some(([method, path]) => {
95
+ const pattern = path.split('/').slice(1);
96
+ return (method === verb &&
97
+ pattern.length === segments.length &&
98
+ pattern.every((segment, index) => (segment === '{id}' ? segments[index].length > 0 : segments[index].toLowerCase() === segment)));
99
+ });
100
+ }
101
+ function isReservedSegments(method, segments) {
102
+ if (RESERVED_FOR_EVERY_METHOD.some((prefix) => startsWith(segments, prefix)))
103
+ return true;
104
+ const verb = method.toUpperCase();
105
+ if (!WRITE_METHODS.has(verb))
106
+ return false;
107
+ if (isAllowedUnderReserved(verb, segments))
108
+ return false;
109
+ return RESERVED_FOR_WRITES.some((prefix) => startsWith(segments, prefix));
110
+ }
111
+ /**
112
+ * True when no plugin may call `method` on `path`, whatever its manifest declares. A path that
113
+ * does not normalize is not reserved: `isApiRequestAllowed` already refuses it.
114
+ */
115
+ export function isReservedApiRequest(method, path) {
116
+ const segments = normalizePath(path);
117
+ return segments !== null && isReservedSegments(method, segments);
118
+ }
44
119
  /**
45
120
  * Decides whether a plugin API request (a nullplatform public API path) is covered
46
121
  * by its declared `permissions.api`. Query strings are never part of the decision.
@@ -52,6 +127,9 @@ export function isApiRequestAllowed(permissions, method, path) {
52
127
  const requestSegments = normalizePath(path);
53
128
  if (!requestSegments)
54
129
  return false;
130
+ // Checked on the request, not on the declared patterns, so a placeholder cannot reach one.
131
+ if (isReservedSegments(requestMethod, requestSegments))
132
+ return false;
55
133
  return permissions.some((permission) => (permission.method === '*' || permission.method === requestMethod) && pathMatches(permission.path, requestSegments));
56
134
  }
57
135
  /** @deprecated use `isApiRequestAllowed`. */
@@ -0,0 +1,71 @@
1
+ import type { ApiPermission } from './manifest.js';
2
+ /**
3
+ * Plugin documents (contracts 6 to 8): a `document` contribution is a JSON view in the SDUI vocabulary that the host
4
+ * draws with no plugin code running. This module holds the plugin profile's first cut: which node types a document may
5
+ * use, and the rule every read obeys. The full shape of each node is `@nullplatform/sdui-spec`'s to check, and the
6
+ * caller passes the spec in (`assertDocumentVocabulary`) until it is published, so the SDK depends on no renderer.
7
+ */
8
+ /**
9
+ * The plugin profile per vocabulary line (contract 7, proposal to validate with the SDUI owners): the node types a
10
+ * plugin document of that line may use. Within a line the list only grows, so a document published once keeps
11
+ * drawing; a change that would break one opens a new line. A document declares its line in its root (`vocabulary`),
12
+ * the `VOCABULARY_LINE` of `@nullplatform/sdui-spec`.
13
+ *
14
+ * Line 1, the first cut: layouts, labels, read controls, collections drawn as tables and navigation. Left out until
15
+ * the profile grows: `Definition` and `Reference` (the server expands them), `Page`, `Outlet`, `Slot`,
16
+ * `Categorization` and `Category` (routing and placement are the host's), and `Component` (another plugin's code).
17
+ */
18
+ export declare const DOCUMENT_PROFILES: {
19
+ readonly 1: readonly ["VerticalLayout", "HorizontalLayout", "GridLayout", "Group", "Label", "Control", "Collection", "Action"];
20
+ };
21
+ /** The line documents are written in today; the API accepts every line in `DOCUMENT_PROFILES`. */
22
+ export declare const DOCUMENT_VOCABULARY_LINE = 1;
23
+ /** Node types of the current line's profile. */
24
+ export declare const DOCUMENT_NODE_TYPES: readonly ["VerticalLayout", "HorizontalLayout", "GridLayout", "Group", "Label", "Control", "Collection", "Action"];
25
+ export type DocumentNodeType = (typeof DOCUMENT_PROFILES)[keyof typeof DOCUMENT_PROFILES][number];
26
+ /** A document as the host receives it: a validated JSON object, drawn by the host's renderer. */
27
+ export type PluginDocument = Record<string, unknown> & {
28
+ vocabulary: number;
29
+ type: DocumentNodeType;
30
+ };
31
+ export declare class DocumentError extends Error {
32
+ constructor(message: string);
33
+ }
34
+ /**
35
+ * Validates an untrusted plugin document against the first cut of the plugin profile and the plugin's
36
+ * `permissions.api` (contract 8): every read is a public API path, GET, covered by a declared permission, with its
37
+ * placeholders as whole segments. Throws a `DocumentError` describing the first problem.
38
+ */
39
+ export declare function validatePluginDocument(input: unknown, permissions: ApiPermission[] | undefined): PluginDocument;
40
+ /**
41
+ * The vocabulary a document is drawn with: `@nullplatform/sdui-spec`'s `VOCABULARY_LINE` and `resolvedNodeSchema`. The
42
+ * API passes it at publish and the host before drawing, so both refuse the same documents in the same words.
43
+ */
44
+ export interface DocumentVocabulary {
45
+ line: number;
46
+ node: {
47
+ safeParse(input: unknown): {
48
+ success: boolean;
49
+ error?: {
50
+ issues: readonly {
51
+ path: readonly PropertyKey[];
52
+ message: string;
53
+ }[];
54
+ };
55
+ };
56
+ };
57
+ }
58
+ /**
59
+ * Checks a document against the vocabulary itself (contract 6): a node as the server would answer it, the shape SDUI's
60
+ * renderer draws (ids are uuids, links are `href`, options closed per type). `vocabulary` is the plugin document's own
61
+ * envelope key, so it is set aside first. A line newer than the vocabulary's is refused. Run it after
62
+ * `validatePluginDocument`; throws a `DocumentError` naming up to five problems.
63
+ */
64
+ export declare function assertDocumentVocabulary(document: PluginDocument, vocabulary: DocumentVocabulary): void;
65
+ /**
66
+ * Builds the check for the reads the renderer asks for while drawing a document: a read is allowed when it is a GET,
67
+ * the interpolated url's path matches one of the document's read urls (each placeholder exactly one segment) and
68
+ * `permissions.api` covers it. Query strings are never part of the decision, as with widgets. The document is walked
69
+ * once, here, and not on every read; a document whose reads don't pass allows none.
70
+ */
71
+ export declare function documentReadCheck(document: PluginDocument, permissions: ApiPermission[] | undefined): (method: string, url: string) => boolean;