@nullplatform/ui-plugin-sdk 0.20.0-beta.0 → 0.20.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 ConfirmOptions, type FilePickOptions, type FileUpload, type PickedFile, type ApiRequest, type BridgeMethodName, type BridgeMethods, type HostMessage, type HttpRequest, type HttpResponse, type NavigationTarget, type PluginContext, type ProgressPanel, 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;
@@ -42,42 +42,6 @@ export declare const nullplatform: {
42
42
  * time per plugin (a second one rejects with `BUSY`). A host older than the call rejects with `UNKNOWN_METHOD`.
43
43
  */
44
44
  confirm(options: ConfirmOptions): Promise<boolean>;
45
- /**
46
- * Shows work that takes a while in the host's progress panel, in a corner of the page: a title and one line per
47
- * item, each `waiting`, `running`, `done` or `failed`. Every call replaces the plugin's panel; `null` removes
48
- * it. The person can fold it, and close it once nothing is waiting or running; it goes when the plugin stops.
49
- * A host older than the call rejects with `UNKNOWN_METHOD`.
50
- */
51
- progress(panel: ProgressPanel | null): Promise<void>;
52
- /**
53
- * Shows an approval request in the host's own modal, with its checklist when it has one: the person reads it and
54
- * acts on it there, without leaving the page. Resolves once they close it. It says nothing about what they did,
55
- * so read again whatever the approval decides. `approvalId` is the request's id, its digits as a string
56
- * (`BAD_REQUEST` otherwise). Waits up to 30 minutes; one at a time per plugin (a second one rejects with `BUSY`).
57
- * Offer it only when `hostSupports('ui.approval')`: a host older than the call rejects with `UNKNOWN_METHOD`, one
58
- * that shows no approvals with `APPROVALS_NOT_SUPPORTED`.
59
- */
60
- approval(approvalId: string): Promise<void>;
61
- };
62
- /**
63
- * Files from the person's computer. A plugin cannot open a file picker or read a file: the host does both, and
64
- * hands back only the file's name, size and type. A host older than these calls rejects with `UNKNOWN_METHOD`;
65
- * one that offers no file picker or upload, with `FILES_NOT_SUPPORTED`.
66
- */
67
- files: {
68
- /**
69
- * Opens the host's file picker. Resolves the picked files: none when the person cancels, one unless `multiple`.
70
- * Call it from a press: browsers only open a file picker shortly after one. Waits up to 10 minutes; one picker
71
- * at a time per plugin (a second one rejects with `BUSY`). More files than `FILE_LIMITS.picked` in one pick
72
- * rejects with `TOO_MANY_FILES`.
73
- */
74
- pick(options?: FilePickOptions): Promise<PickedFile[]>;
75
- /**
76
- * Sends a picked file as a form POST to a host declared in `permissions.upload` (an S3 presigned POST, for
77
- * example). Resolves when the form was sent; the host cannot read the answer, so check that the file arrived.
78
- * Rejects with `PERMISSION_DENIED` for an undeclared host and `UNKNOWN_FILE` for an id it does not hold.
79
- */
80
- upload(upload: FileUpload): Promise<void>;
81
45
  };
82
46
  context: {
83
47
  get(): Promise<PluginContext>;
package/dist/bridge.js CHANGED
@@ -111,50 +111,6 @@ export const nullplatform = {
111
111
  confirm(options) {
112
112
  return bridge.call('ui.confirm', options);
113
113
  },
114
- /**
115
- * Shows work that takes a while in the host's progress panel, in a corner of the page: a title and one line per
116
- * item, each `waiting`, `running`, `done` or `failed`. Every call replaces the plugin's panel; `null` removes
117
- * it. The person can fold it, and close it once nothing is waiting or running; it goes when the plugin stops.
118
- * A host older than the call rejects with `UNKNOWN_METHOD`.
119
- */
120
- progress(panel) {
121
- return bridge.call('ui.progress', panel);
122
- },
123
- /**
124
- * Shows an approval request in the host's own modal, with its checklist when it has one: the person reads it and
125
- * acts on it there, without leaving the page. Resolves once they close it. It says nothing about what they did,
126
- * so read again whatever the approval decides. `approvalId` is the request's id, its digits as a string
127
- * (`BAD_REQUEST` otherwise). Waits up to 30 minutes; one at a time per plugin (a second one rejects with `BUSY`).
128
- * Offer it only when `hostSupports('ui.approval')`: a host older than the call rejects with `UNKNOWN_METHOD`, one
129
- * that shows no approvals with `APPROVALS_NOT_SUPPORTED`.
130
- */
131
- approval(approvalId) {
132
- return bridge.call('ui.approval', approvalId);
133
- },
134
- },
135
- /**
136
- * Files from the person's computer. A plugin cannot open a file picker or read a file: the host does both, and
137
- * hands back only the file's name, size and type. A host older than these calls rejects with `UNKNOWN_METHOD`;
138
- * one that offers no file picker or upload, with `FILES_NOT_SUPPORTED`.
139
- */
140
- files: {
141
- /**
142
- * Opens the host's file picker. Resolves the picked files: none when the person cancels, one unless `multiple`.
143
- * Call it from a press: browsers only open a file picker shortly after one. Waits up to 10 minutes; one picker
144
- * at a time per plugin (a second one rejects with `BUSY`). More files than `FILE_LIMITS.picked` in one pick
145
- * rejects with `TOO_MANY_FILES`.
146
- */
147
- pick(options) {
148
- return bridge.call('files.pick', options);
149
- },
150
- /**
151
- * Sends a picked file as a form POST to a host declared in `permissions.upload` (an S3 presigned POST, for
152
- * example). Resolves when the form was sent; the host cannot read the answer, so check that the file arrived.
153
- * Rejects with `PERMISSION_DENIED` for an undeclared host and `UNKNOWN_FILE` for an id it does not hold.
154
- */
155
- upload(upload) {
156
- return bridge.call('files.upload', upload);
157
- },
158
114
  },
159
115
  context: {
160
116
  get() {
@@ -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 {};
package/dist/catalog.js CHANGED
@@ -199,7 +199,6 @@ const OWN_CATALOG = [
199
199
  href: "string",
200
200
  color: "string",
201
201
  underline: "string",
202
- newTab: "boolean",
203
202
  },
204
203
  events: { press: "onPress" },
205
204
  values: CATALOG_PROP_VALUES.Link,
@@ -399,6 +398,8 @@ const OWN_CATALOG = [
399
398
  xScale: "string",
400
399
  xFormat: "string",
401
400
  yFormat: "string",
401
+ xTicks: "array",
402
+ yTicks: "array",
402
403
  xMax: "number",
403
404
  yMax: "number",
404
405
  selected: "string",
@@ -8,6 +8,8 @@ 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";
12
+ export type { FilterSingleDateChange, FilterSingleDatePreset } from "./filterSingleDate.js";
11
13
  export type { DataTableAvatar, DataTableColor, DataTableColumn, DataTableFormatter, DataTableLabelVariant, DataTableLink, DataTablePagination, DataTableRow, DataTableRowAction, DataTableState, DataTableTypography, } from "./dataTable.js";
12
14
  export declare const TextField: import("react").ComponentType<{
13
15
  label: string;
@@ -137,8 +139,6 @@ export declare const Link: import("react").ComponentType<{
137
139
  color?: LinkColor;
138
140
  /** Unset, the theme's: underlined on hover. */
139
141
  underline?: LinkUnderline;
140
- /** Opens a `to` page in a new tab and leaves this one where it is. An `href` always opens in a new tab. */
141
- newTab?: boolean;
142
142
  onPress?: () => void;
143
143
  } & {
144
144
  children?: ReactNode;
@@ -350,12 +350,21 @@ export interface ScatterPoint {
350
350
  label: string;
351
351
  x: number;
352
352
  y: number;
353
+ /** Text for this point's x value in its tooltip; the axis formatter when left out. */
354
+ xLabel?: string;
355
+ /** Text for this point's y value in its tooltip; the axis formatter when left out. */
356
+ yLabel?: string;
353
357
  /** Relative area: the largest point gets the largest dot. Every dot is the same size when left out. */
354
358
  size?: number;
355
359
  color?: ThemeColor | string;
356
360
  /** Outline with a faint fill, for points that matter less. */
357
361
  hollow?: boolean;
358
362
  }
363
+ /** A numeric position with the text the axis and tooltip should show for it. */
364
+ export interface ScatterAxisTick {
365
+ value: number;
366
+ label: string;
367
+ }
359
368
  /**
360
369
  * Splits the plane at `x` and `y`. `labels` names the corners and `colors` tints them, both in reading order
361
370
  * (top left, top right, bottom left, bottom right); `null` leaves a corner untinted.
@@ -382,7 +391,11 @@ export declare const Scatter: import("react").ComponentType<{
382
391
  xScale?: ScatterScale;
383
392
  xFormat?: ValueFormat;
384
393
  yFormat?: ValueFormat;
385
- /** Axis ends; the data's maximum, rounded, when left out. Both axes start at the data's minimum on `log`, at 0 otherwise. */
394
+ /** Replaces generated numeric ticks and formats matching tooltip values. Useful for elapsed-time landmarks. */
395
+ xTicks?: ScatterAxisTick[];
396
+ /** Replaces generated numeric ticks and formats matching tooltip values. Useful for ordered categories. */
397
+ yTicks?: ScatterAxisTick[];
398
+ /** Axis maxima; custom ticks may extend either end. Otherwise, log x starts at the data minimum and linear axes at 0. */
386
399
  xMax?: number;
387
400
  yMax?: number;
388
401
  /** The `id` of the point drawn as chosen. */
@@ -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,126 @@ 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<Omit<{
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
+ } & {}, "onChange" | "value" | "preset" | "presets"> & Pick<{
656
+ value?: string | null;
657
+ preset?: string | null;
658
+ presets?: readonly import("./filterSingleDate").FilterSingleDatePreset[];
659
+ onChange?: (change: import("./filterSingleDate").FilterSingleDateChange) => void;
660
+ }, "onChange" | "value" | "preset" | "presets"> & {
661
+ children?: import("react").ReactNode;
662
+ }>;
663
+ export declare const Stepper: import("react").ComponentType<{
664
+ activeStep?: number | undefined;
665
+ orientation?: "horizontal" | "vertical" | undefined;
666
+ alternativeLabel?: boolean | undefined;
667
+ nonLinear?: boolean | undefined;
668
+ } & {} & {} & {
669
+ children?: import("react").ReactNode;
670
+ }>;
671
+ export declare const Step: import("react").ComponentType<{
672
+ index?: number | undefined;
673
+ last?: boolean | undefined;
674
+ active?: boolean | undefined;
675
+ completed?: boolean | undefined;
676
+ disabled?: boolean | undefined;
677
+ } & {} & {} & {
678
+ children?: import("react").ReactNode;
679
+ }>;
680
+ export declare const StepLabel: import("react").ComponentType<{
681
+ error?: boolean | undefined;
682
+ } & {} & {
683
+ optional?: import("react").ReactNode;
684
+ } & {
685
+ children?: import("react").ReactNode;
686
+ }>;
@@ -1,4 +1,4 @@
1
- // Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.16.10. 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");
package/dist/context.d.ts CHANGED
@@ -33,12 +33,6 @@ export declare function useNullplatform(): {
33
33
  ui: {
34
34
  snackbar(options: import("./protocol").SnackbarOptions): Promise<void>;
35
35
  confirm(options: import("./protocol").ConfirmOptions): Promise<boolean>;
36
- progress(panel: import("./protocol").ProgressPanel | null): Promise<void>;
37
- approval(approvalId: string): Promise<void>;
38
- };
39
- files: {
40
- pick(options?: import("./protocol").FilePickOptions): Promise<import("./protocol").PickedFile[]>;
41
- upload(upload: import("./protocol").FileUpload): Promise<void>;
42
36
  };
43
37
  context: {
44
38
  get(): Promise<PluginContext>;
@@ -1,4 +1,4 @@
1
- import type { ApiPermission, HttpPermission, UploadPermission } from './manifest.js';
1
+ import type { ApiPermission, HttpPermission } from './manifest.js';
2
2
  /** Splits a path into segments; rejects traversal, empty segments and query/hash fragments. */
3
3
  export declare function normalizePath(path: string): string[] | null;
4
4
  /**
@@ -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.
@@ -22,10 +27,3 @@ export declare const isRequestAllowed: typeof isApiRequestAllowed;
22
27
  * declared method and path pattern.
23
28
  */
24
29
  export declare function isHttpRequestAllowed(permissions: HttpPermission[] | undefined, method: string, url: string): boolean;
25
- /**
26
- * Decides whether a file may be uploaded to `url` under `permissions.upload`: https only, no credentials in the URL,
27
- * and a declared host. An exact host matches itself (port included when declared); `*.example.com` matches every
28
- * host under `example.com` on the default port, never `example.com` itself. The path and the query are the
29
- * upload's own business: a presigned POST goes to `/`.
30
- */
31
- export declare function isUploadAllowed(permissions: UploadPermission[] | undefined, url: string): boolean;
@@ -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`. */
@@ -82,29 +160,3 @@ export function isHttpRequestAllowed(permissions, method, url) {
82
160
  (permission.method === '*' || permission.method === requestMethod) &&
83
161
  pathMatches(permission.path, requestSegments));
84
162
  }
85
- /**
86
- * Decides whether a file may be uploaded to `url` under `permissions.upload`: https only, no credentials in the URL,
87
- * and a declared host. An exact host matches itself (port included when declared); `*.example.com` matches every
88
- * host under `example.com` on the default port, never `example.com` itself. The path and the query are the
89
- * upload's own business: a presigned POST goes to `/`.
90
- */
91
- export function isUploadAllowed(permissions, url) {
92
- if (!permissions?.length)
93
- return false;
94
- let parsed;
95
- try {
96
- parsed = new URL(url);
97
- }
98
- catch {
99
- return false;
100
- }
101
- if (parsed.protocol !== 'https:' || parsed.username || parsed.password)
102
- return false;
103
- const host = parsed.host.toLowerCase();
104
- return permissions.some((permission) => {
105
- const declared = permission.host.toLowerCase();
106
- if (!declared.startsWith('*.'))
107
- return declared === host;
108
- return !parsed.port && host.endsWith(declared.slice(1));
109
- });
110
- }
@@ -1,8 +1,8 @@
1
- export { PROTOCOL_VERSION, validateManifest, validatePublishableManifest, unnamedContributions, contributionId, RESERVED_PLUGIN_ID, isSectionSlot, ManifestError, type PluginManifest, type Contribution, type ApiPermission, type HttpPermission, type UploadPermission, type HttpMethod, } from './manifest.js';
1
+ export { PROTOCOL_VERSION, validateManifest, validatePublishableManifest, validateAuthoredApiPermissions, unnamedContributions, contributionId, RESERVED_PLUGIN_ID, isSectionSlot, ManifestError, type PluginManifest, type Contribution, type ApiPermission, type HttpPermission, type HttpMethod, } from './manifest.js';
2
2
  export { PLACE_ROOTS, missingContext, contextSatisfies, readPlaceRoots, type PlaceRoot } from './context.js';
3
3
  export { pageOf, layoutConflicts, type LayoutConflict } from './layout.js';
4
4
  export { PAGE_AREAS, REQUIRED_PAGE_AREA, MIN_PAGE_AREA_WIDTH, pageTemplateProblems, isPageTemplateDefinition, type PageArea, type PageTemplateBreakpoint, type PageTemplateDefinition, type PageTemplateResponsive, type PageTemplateTracks, } from './pageTemplate.js';
5
- export { isApiRequestAllowed, isHttpRequestAllowed, isUploadAllowed, isRequestAllowed, normalizePath, canonicalizePath } from './allowlist.js';
5
+ export { isApiRequestAllowed, isHttpRequestAllowed, isRequestAllowed, isReservedApiRequest, normalizePath, canonicalizePath } from './allowlist.js';
6
6
  export { matchFixture, type Fixtures, type FixtureMatch } from './fixtures.js';
7
7
  export { CONTEXT_ROOTS, extractRoots, validateWhen, evaluateWhen, rolloutIncludes, WhenError, type WhenQuery, type ContextRoot, type Rollout, } from './when.js';
8
8
  export { PLUGIN_STORAGE_ORIGIN, validateStorageUrl, resolveAssetUrl } from './storage.js';
@@ -1,8 +1,8 @@
1
- export { PROTOCOL_VERSION, validateManifest, validatePublishableManifest, unnamedContributions, contributionId, RESERVED_PLUGIN_ID, isSectionSlot, ManifestError, } from './manifest.js';
1
+ export { PROTOCOL_VERSION, validateManifest, validatePublishableManifest, validateAuthoredApiPermissions, unnamedContributions, contributionId, RESERVED_PLUGIN_ID, isSectionSlot, ManifestError, } from './manifest.js';
2
2
  export { PLACE_ROOTS, missingContext, contextSatisfies, readPlaceRoots } from './context.js';
3
3
  export { pageOf, layoutConflicts } from './layout.js';
4
4
  export { PAGE_AREAS, REQUIRED_PAGE_AREA, MIN_PAGE_AREA_WIDTH, pageTemplateProblems, isPageTemplateDefinition, } from './pageTemplate.js';
5
- export { isApiRequestAllowed, isHttpRequestAllowed, isUploadAllowed, isRequestAllowed, normalizePath, canonicalizePath } from './allowlist.js';
5
+ export { isApiRequestAllowed, isHttpRequestAllowed, isRequestAllowed, isReservedApiRequest, normalizePath, canonicalizePath } from './allowlist.js';
6
6
  export { matchFixture } from './fixtures.js';
7
7
  export { CONTEXT_ROOTS, extractRoots, validateWhen, evaluateWhen, rolloutIncludes, WhenError, } from './when.js';
8
8
  export { PLUGIN_STORAGE_ORIGIN, validateStorageUrl, resolveAssetUrl } from './storage.js';