@nullplatform/ui-plugin-sdk 0.4.0 → 0.5.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/catalog.d.ts +31 -0
- package/dist/catalog.js +26 -0
- package/dist/components.d.ts +11 -8
- package/dist/components.js +1 -1
- package/dist/contract/when.d.ts +6 -2
- package/dist/contract/when.js +14 -2
- package/dist/contract-cjs/when.js +14 -2
- package/dist/protocol.d.ts +14 -0
- package/package.json +2 -2
package/dist/catalog.d.ts
CHANGED
|
@@ -22,5 +22,36 @@ export interface CatalogElementSpec {
|
|
|
22
22
|
}
|
|
23
23
|
export declare const CATALOG: readonly CatalogElementSpec[];
|
|
24
24
|
export declare const CATALOG_BY_TAG: ReadonlyMap<string, CatalogElementSpec>;
|
|
25
|
+
/**
|
|
26
|
+
* The values a plugin may pass to these props. The SDK's components are typed from these lists, and
|
|
27
|
+
* the host checks each value against them again at runtime, falling back to the element's default:
|
|
28
|
+
* a published bundle has already left TypeScript behind.
|
|
29
|
+
*/
|
|
30
|
+
export declare const CATALOG_PROP_VALUES: {
|
|
31
|
+
readonly Text: {
|
|
32
|
+
readonly variant: readonly ["h1", "h2", "h3", "h4", "h5", "h6", "subtitle1", "subtitle2", "body1", "body2", "caption", "overline", "button"];
|
|
33
|
+
readonly align: readonly ["inherit", "left", "center", "right", "justify"];
|
|
34
|
+
};
|
|
35
|
+
readonly Button: {
|
|
36
|
+
readonly variant: readonly ["contained", "outlined", "text", "soft"];
|
|
37
|
+
readonly color: readonly ["inherit", "primary", "secondary", "success", "error", "info", "warning"];
|
|
38
|
+
};
|
|
39
|
+
readonly Chip: {
|
|
40
|
+
readonly color: readonly ["default", "primary", "secondary", "success", "error", "info", "warning"];
|
|
41
|
+
readonly variant: readonly ["filled", "outlined", "soft"];
|
|
42
|
+
readonly size: readonly ["small", "medium"];
|
|
43
|
+
};
|
|
44
|
+
readonly Skeleton: {
|
|
45
|
+
readonly variant: readonly ["text", "rectangular", "rounded", "circular"];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export type TextVariant = (typeof CATALOG_PROP_VALUES.Text.variant)[number];
|
|
49
|
+
export type TextAlign = (typeof CATALOG_PROP_VALUES.Text.align)[number];
|
|
50
|
+
export type ButtonVariant = (typeof CATALOG_PROP_VALUES.Button.variant)[number];
|
|
51
|
+
export type ButtonColor = (typeof CATALOG_PROP_VALUES.Button.color)[number];
|
|
52
|
+
export type ChipColor = (typeof CATALOG_PROP_VALUES.Chip.color)[number];
|
|
53
|
+
export type ChipVariant = (typeof CATALOG_PROP_VALUES.Chip.variant)[number];
|
|
54
|
+
export type ChipSize = (typeof CATALOG_PROP_VALUES.Chip.size)[number];
|
|
55
|
+
export type SkeletonVariant = (typeof CATALOG_PROP_VALUES.Skeleton.variant)[number];
|
|
25
56
|
/** Name of the wrapper element remote-dom uses for React elements passed as props. */
|
|
26
57
|
export declare const FRAGMENT_TAG = "remote-fragment";
|
package/dist/catalog.js
CHANGED
|
@@ -286,5 +286,31 @@ export const CATALOG = [
|
|
|
286
286
|
},
|
|
287
287
|
];
|
|
288
288
|
export const CATALOG_BY_TAG = new Map(CATALOG.map((spec) => [spec.tag, spec]));
|
|
289
|
+
/**
|
|
290
|
+
* The values a plugin may pass to these props. The SDK's components are typed from these lists, and
|
|
291
|
+
* the host checks each value against them again at runtime, falling back to the element's default:
|
|
292
|
+
* a published bundle has already left TypeScript behind.
|
|
293
|
+
*/
|
|
294
|
+
export const CATALOG_PROP_VALUES = {
|
|
295
|
+
Text: {
|
|
296
|
+
variant: [
|
|
297
|
+
"h1", "h2", "h3", "h4", "h5", "h6",
|
|
298
|
+
"subtitle1", "subtitle2", "body1", "body2", "caption", "overline", "button",
|
|
299
|
+
],
|
|
300
|
+
align: ["inherit", "left", "center", "right", "justify"],
|
|
301
|
+
},
|
|
302
|
+
Button: {
|
|
303
|
+
variant: ["contained", "outlined", "text", "soft"],
|
|
304
|
+
color: ["inherit", "primary", "secondary", "success", "error", "info", "warning"],
|
|
305
|
+
},
|
|
306
|
+
Chip: {
|
|
307
|
+
color: ["default", "primary", "secondary", "success", "error", "info", "warning"],
|
|
308
|
+
variant: ["filled", "outlined", "soft"],
|
|
309
|
+
size: ["small", "medium"],
|
|
310
|
+
},
|
|
311
|
+
Skeleton: {
|
|
312
|
+
variant: ["text", "rectangular", "rounded", "circular"],
|
|
313
|
+
},
|
|
314
|
+
};
|
|
289
315
|
/** Name of the wrapper element remote-dom uses for React elements passed as props. */
|
|
290
316
|
export const FRAGMENT_TAG = "remote-fragment";
|
package/dist/components.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import "./polyfill.js";
|
|
|
5
5
|
*/
|
|
6
6
|
import "@remote-dom/react/polyfill";
|
|
7
7
|
import { type ComponentType, type ReactNode } from "react";
|
|
8
|
+
import { type ButtonColor, type ButtonVariant, type ChipColor, type ChipSize, type ChipVariant, type SkeletonVariant, type TextAlign, type TextVariant } from "./catalog.js";
|
|
9
|
+
export type { ButtonColor, ButtonVariant, ChipColor, ChipSize, ChipVariant, SkeletonVariant, TextAlign, TextVariant, } from "./catalog.js";
|
|
8
10
|
export declare const TextField: ComponentType<{
|
|
9
11
|
label: string;
|
|
10
12
|
value: string;
|
|
@@ -85,16 +87,17 @@ export declare const Stack: ComponentType<{
|
|
|
85
87
|
children?: ReactNode;
|
|
86
88
|
}>;
|
|
87
89
|
export declare const Text: ComponentType<{
|
|
88
|
-
variant?:
|
|
90
|
+
variant?: TextVariant;
|
|
91
|
+
/** A theme color path (`text.secondary`, `error.main`) or any CSS color. */
|
|
89
92
|
color?: string;
|
|
90
|
-
align?:
|
|
93
|
+
align?: TextAlign;
|
|
91
94
|
noWrap?: boolean;
|
|
92
95
|
} & {
|
|
93
96
|
children?: ReactNode;
|
|
94
97
|
}>;
|
|
95
98
|
export declare const Button: ComponentType<{
|
|
96
|
-
variant?:
|
|
97
|
-
color?:
|
|
99
|
+
variant?: ButtonVariant;
|
|
100
|
+
color?: ButtonColor;
|
|
98
101
|
size?: "small" | "medium" | "large";
|
|
99
102
|
disabled?: boolean;
|
|
100
103
|
loading?: boolean;
|
|
@@ -105,9 +108,9 @@ export declare const Button: ComponentType<{
|
|
|
105
108
|
}>;
|
|
106
109
|
export declare const Chip: ComponentType<{
|
|
107
110
|
label: string;
|
|
108
|
-
color?:
|
|
109
|
-
variant?:
|
|
110
|
-
size?:
|
|
111
|
+
color?: ChipColor;
|
|
112
|
+
variant?: ChipVariant;
|
|
113
|
+
size?: ChipSize;
|
|
111
114
|
} & {
|
|
112
115
|
children?: ReactNode;
|
|
113
116
|
}>;
|
|
@@ -131,7 +134,7 @@ export declare const Table: ComponentType<{
|
|
|
131
134
|
export declare const Skeleton: ComponentType<{
|
|
132
135
|
height?: number;
|
|
133
136
|
width?: string;
|
|
134
|
-
variant?:
|
|
137
|
+
variant?: SkeletonVariant;
|
|
135
138
|
} & {
|
|
136
139
|
children?: ReactNode;
|
|
137
140
|
}>;
|
package/dist/components.js
CHANGED
|
@@ -6,7 +6,7 @@ import "./polyfill.js";
|
|
|
6
6
|
import "@remote-dom/react/polyfill";
|
|
7
7
|
import { createRemoteComponent } from "@remote-dom/react";
|
|
8
8
|
import { createElement } from "react";
|
|
9
|
-
import { CATALOG_BY_TAG } from "./catalog.js";
|
|
9
|
+
import { CATALOG_BY_TAG, } from "./catalog.js";
|
|
10
10
|
import { defineCatalogElements } from "./elements.js";
|
|
11
11
|
const elements = defineCatalogElements();
|
|
12
12
|
function component(tag) {
|
package/dist/contract/when.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export type WhenQuery = Record<string, unknown>;
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Roots a condition may reference. The API knows how to load each one; anything else is rejected at write time.
|
|
4
|
+
* `locale` and `route` are in the plugin context but are not roots: the platform resolves installations without
|
|
5
|
+
* knowing either, so a condition on them could only ever hold in developer mode.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CONTEXT_ROOTS: readonly ["nrn", "organization", "account", "namespace", "application", "user"];
|
|
4
8
|
export type ContextRoot = (typeof CONTEXT_ROOTS)[number];
|
|
5
9
|
export declare const WHEN_LIMITS: {
|
|
6
10
|
readonly depth: 16;
|
package/dist/contract/when.js
CHANGED
|
@@ -4,8 +4,17 @@
|
|
|
4
4
|
* the API (installations and manifests) and in the host (developer mode).
|
|
5
5
|
*/
|
|
6
6
|
import sift from 'sift';
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Roots a condition may reference. The API knows how to load each one; anything else is rejected at write time.
|
|
9
|
+
* `locale` and `route` are in the plugin context but are not roots: the platform resolves installations without
|
|
10
|
+
* knowing either, so a condition on them could only ever hold in developer mode.
|
|
11
|
+
*/
|
|
12
|
+
export const CONTEXT_ROOTS = ['nrn', 'organization', 'account', 'namespace', 'application', 'user'];
|
|
13
|
+
/**
|
|
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.
|
|
16
|
+
*/
|
|
17
|
+
const UNSUPPORTED_ROOTS = new Set(['scope', 'deployment']);
|
|
9
18
|
/** Operators that would execute code or are meaningless outside MongoDB. */
|
|
10
19
|
const ALLOWED_OPERATORS = new Set(['$eq', '$ne', '$gt', '$gte', '$lt', '$lte', '$in', '$nin', '$exists', '$size', '$all', '$elemMatch', '$not', '$and', '$or', '$nor', '$mod']);
|
|
11
20
|
export const WHEN_LIMITS = { depth: 16, nodes: 512, array: 100, string: 1024 };
|
|
@@ -84,6 +93,9 @@ export function validateWhen(input) {
|
|
|
84
93
|
throw new WhenError('when must be an object');
|
|
85
94
|
assertSafe(input);
|
|
86
95
|
for (const root of extractRoots(input)) {
|
|
96
|
+
if (UNSUPPORTED_ROOTS.has(root)) {
|
|
97
|
+
throw new WhenError(`Context root "${root}" is not supported yet: plugins resolve for the application, so it would never match`);
|
|
98
|
+
}
|
|
87
99
|
if (!CONTEXT_ROOTS.includes(root)) {
|
|
88
100
|
throw new WhenError(`Unknown context root "${root}" (allowed: ${CONTEXT_ROOTS.join(', ')})`);
|
|
89
101
|
}
|
|
@@ -14,8 +14,17 @@ exports.rolloutIncludes = rolloutIncludes;
|
|
|
14
14
|
* the API (installations and manifests) and in the host (developer mode).
|
|
15
15
|
*/
|
|
16
16
|
const sift_1 = __importDefault(require("sift"));
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Roots a condition may reference. The API knows how to load each one; anything else is rejected at write time.
|
|
19
|
+
* `locale` and `route` are in the plugin context but are not roots: the platform resolves installations without
|
|
20
|
+
* knowing either, so a condition on them could only ever hold in developer mode.
|
|
21
|
+
*/
|
|
22
|
+
exports.CONTEXT_ROOTS = ['nrn', 'organization', 'account', 'namespace', 'application', 'user'];
|
|
23
|
+
/**
|
|
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.
|
|
26
|
+
*/
|
|
27
|
+
const UNSUPPORTED_ROOTS = new Set(['scope', 'deployment']);
|
|
19
28
|
/** Operators that would execute code or are meaningless outside MongoDB. */
|
|
20
29
|
const ALLOWED_OPERATORS = new Set(['$eq', '$ne', '$gt', '$gte', '$lt', '$lte', '$in', '$nin', '$exists', '$size', '$all', '$elemMatch', '$not', '$and', '$or', '$nor', '$mod']);
|
|
21
30
|
exports.WHEN_LIMITS = { depth: 16, nodes: 512, array: 100, string: 1024 };
|
|
@@ -95,6 +104,9 @@ function validateWhen(input) {
|
|
|
95
104
|
throw new WhenError('when must be an object');
|
|
96
105
|
assertSafe(input);
|
|
97
106
|
for (const root of extractRoots(input)) {
|
|
107
|
+
if (UNSUPPORTED_ROOTS.has(root)) {
|
|
108
|
+
throw new WhenError(`Context root "${root}" is not supported yet: plugins resolve for the application, so it would never match`);
|
|
109
|
+
}
|
|
98
110
|
if (!exports.CONTEXT_ROOTS.includes(root)) {
|
|
99
111
|
throw new WhenError(`Unknown context root "${root}" (allowed: ${exports.CONTEXT_ROOTS.join(', ')})`);
|
|
100
112
|
}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export declare const PROTOCOL_VERSION = 1;
|
|
|
10
10
|
export type FunctionToken = {
|
|
11
11
|
$fn: string;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Where the plugin is rendering. Identity only (ids, slugs, names): every plugin receives it whatever its
|
|
15
|
+
* permissions, so anything else about an entity goes through `api` with a declared permission.
|
|
16
|
+
*/
|
|
13
17
|
export interface PluginContext {
|
|
14
18
|
organization?: {
|
|
15
19
|
id: number | string;
|
|
@@ -31,6 +35,16 @@ export interface PluginContext {
|
|
|
31
35
|
slug?: string;
|
|
32
36
|
name?: string;
|
|
33
37
|
};
|
|
38
|
+
/** Set on scope pages. Not usable in `when` yet (see `CONTEXT_ROOTS`). */
|
|
39
|
+
scope?: {
|
|
40
|
+
id: number | string;
|
|
41
|
+
slug?: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
};
|
|
44
|
+
/** Set on deployment pages. Not usable in `when` yet (see `CONTEXT_ROOTS`). */
|
|
45
|
+
deployment?: {
|
|
46
|
+
id: number | string;
|
|
47
|
+
};
|
|
34
48
|
nrn?: string;
|
|
35
49
|
user?: {
|
|
36
50
|
id: number | string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nullplatform/ui-plugin-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsc -p tsconfig.json && tsc -p tsconfig.contract.cjs.json && node scripts/finish-build.mjs",
|
|
35
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
35
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test-types.json",
|
|
36
36
|
"test": "vitest run --passWithNoTests"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|