@object-ui/sdui-parser 16.1.0 → 17.2.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/index.d.ts +41 -2
- package/dist/index.js +41 -0
- package/dist/types.d.ts +17 -2
- package/dist/validate.d.ts +2 -2
- package/package.json +7 -3
package/dist/index.d.ts
CHANGED
|
@@ -10,12 +10,12 @@ export { parseJsx, interpretBrace } from './parse.js';
|
|
|
10
10
|
export { validateTree } from './validate.js';
|
|
11
11
|
export { generateDts, propsName, generateBlockList } from './codegen.js';
|
|
12
12
|
export type { CodegenOptions } from './codegen.js';
|
|
13
|
-
import type { Diagnostic, Manifest, SchemaElement,
|
|
13
|
+
import type { Diagnostic, Manifest, SchemaElement, ManifestValidationResult } from './types.js';
|
|
14
14
|
export interface CompileResult {
|
|
15
15
|
tree: SchemaElement | null;
|
|
16
16
|
diagnostics: Diagnostic[];
|
|
17
17
|
requires: string[];
|
|
18
|
-
bindings:
|
|
18
|
+
bindings: ManifestValidationResult['bindings'];
|
|
19
19
|
/** true when there are no error-severity diagnostics — the save gate's pass/fail */
|
|
20
20
|
ok: boolean;
|
|
21
21
|
}
|
|
@@ -43,7 +43,46 @@ export interface RegistryConfigLike {
|
|
|
43
43
|
binding?: 'object' | 'field';
|
|
44
44
|
description?: string;
|
|
45
45
|
}>;
|
|
46
|
+
/**
|
|
47
|
+
* True when the registry entry is a pending lazy stub — registered, but its
|
|
48
|
+
* plugin module has not been imported, so it carries metadata and no
|
|
49
|
+
* `inputs`. See {@link assertFullyLoaded}.
|
|
50
|
+
*/
|
|
51
|
+
lazy?: boolean;
|
|
46
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Build-time guard for the manifest generators.
|
|
55
|
+
*
|
|
56
|
+
* A manifest is the contract's frozen form: the parser's tag whitelist and the
|
|
57
|
+
* save gate's prop validator both read it. So it has to be generated from
|
|
58
|
+
* FULLY LOADED registrations. A `lazy: true` entry means the generator never
|
|
59
|
+
* imported that plugin, and the block would be written out with empty
|
|
60
|
+
* `inputs` — indistinguishable from a block that legitimately takes no props,
|
|
61
|
+
* which turns every prop an author writes on it into an `unknown-prop`
|
|
62
|
+
* diagnostic. Wrong quietly, in the artifact everything downstream trusts.
|
|
63
|
+
*
|
|
64
|
+
* The generators keep their own eager import list, so this is what catches it
|
|
65
|
+
* drifting behind the app's registration list (objectui#2953 was the same
|
|
66
|
+
* class of bug one layer down).
|
|
67
|
+
*/
|
|
68
|
+
export declare function assertFullyLoaded(configs: RegistryConfigLike[]): void;
|
|
69
|
+
/**
|
|
70
|
+
* Project registry configs into the SDUI manifest.
|
|
71
|
+
*
|
|
72
|
+
* ⚠️ Every field here is copied from what the registration **declared**. In
|
|
73
|
+
* particular `inputs` is `config.inputs` verbatim — this function does not, and
|
|
74
|
+
* cannot, observe whether the renderer behind the block reads any of them.
|
|
75
|
+
*
|
|
76
|
+
* Worth stating because of what consumes the output. The framework's
|
|
77
|
+
* `check:react-blocks-declaration-parity` diffs this against the spec's zod
|
|
78
|
+
* schemas, and while that check was named `check:react-conformance` it was read
|
|
79
|
+
* — by its own file header — as confirming the components "ACTUALLY implement"
|
|
80
|
+
* the spec's props. It never could: both sides of that diff are declarations,
|
|
81
|
+
* and this is the side this file produces. Four blocks published an `objectName`
|
|
82
|
+
* no renderer read and sailed through it green (objectstack#4413; corrected in
|
|
83
|
+
* objectstack#4472). Evidence about the render path has to come from the render
|
|
84
|
+
* path — see `apps/console/src/__tests__/public-block-binding-reach.test.tsx`.
|
|
85
|
+
*/
|
|
47
86
|
export declare function manifestFromConfigs(configs: RegistryConfigLike[], opts?: {
|
|
48
87
|
only?: Set<string>;
|
|
49
88
|
publicOnly?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,30 @@ export function compile(source, manifest) {
|
|
|
28
28
|
ok: !diagnostics.some((d) => d.severity === 'error'),
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Build-time guard for the manifest generators.
|
|
33
|
+
*
|
|
34
|
+
* A manifest is the contract's frozen form: the parser's tag whitelist and the
|
|
35
|
+
* save gate's prop validator both read it. So it has to be generated from
|
|
36
|
+
* FULLY LOADED registrations. A `lazy: true` entry means the generator never
|
|
37
|
+
* imported that plugin, and the block would be written out with empty
|
|
38
|
+
* `inputs` — indistinguishable from a block that legitimately takes no props,
|
|
39
|
+
* which turns every prop an author writes on it into an `unknown-prop`
|
|
40
|
+
* diagnostic. Wrong quietly, in the artifact everything downstream trusts.
|
|
41
|
+
*
|
|
42
|
+
* The generators keep their own eager import list, so this is what catches it
|
|
43
|
+
* drifting behind the app's registration list (objectui#2953 was the same
|
|
44
|
+
* class of bug one layer down).
|
|
45
|
+
*/
|
|
46
|
+
export function assertFullyLoaded(configs) {
|
|
47
|
+
const stubs = configs.filter((c) => c.lazy).map((c) => c.type).sort();
|
|
48
|
+
if (stubs.length === 0)
|
|
49
|
+
return;
|
|
50
|
+
throw new Error(`Manifest generation saw ${stubs.length} not-yet-loaded lazy block(s): ${stubs.join(', ')}.\n` +
|
|
51
|
+
`A manifest must describe loaded registrations — these would be written out with no \`inputs\`, ` +
|
|
52
|
+
`so every prop an author passes them would be reported as unknown.\n` +
|
|
53
|
+
`Add an eager \`import\` of each block's plugin to the generator entry.`);
|
|
54
|
+
}
|
|
31
55
|
const INPUT_TYPES = new Set([
|
|
32
56
|
'string',
|
|
33
57
|
'number',
|
|
@@ -41,6 +65,23 @@ const INPUT_TYPES = new Set([
|
|
|
41
65
|
'file',
|
|
42
66
|
'slot',
|
|
43
67
|
]);
|
|
68
|
+
/**
|
|
69
|
+
* Project registry configs into the SDUI manifest.
|
|
70
|
+
*
|
|
71
|
+
* ⚠️ Every field here is copied from what the registration **declared**. In
|
|
72
|
+
* particular `inputs` is `config.inputs` verbatim — this function does not, and
|
|
73
|
+
* cannot, observe whether the renderer behind the block reads any of them.
|
|
74
|
+
*
|
|
75
|
+
* Worth stating because of what consumes the output. The framework's
|
|
76
|
+
* `check:react-blocks-declaration-parity` diffs this against the spec's zod
|
|
77
|
+
* schemas, and while that check was named `check:react-conformance` it was read
|
|
78
|
+
* — by its own file header — as confirming the components "ACTUALLY implement"
|
|
79
|
+
* the spec's props. It never could: both sides of that diff are declarations,
|
|
80
|
+
* and this is the side this file produces. Four blocks published an `objectName`
|
|
81
|
+
* no renderer read and sailed through it green (objectstack#4413; corrected in
|
|
82
|
+
* objectstack#4472). Evidence about the render path has to come from the render
|
|
83
|
+
* path — see `apps/console/src/__tests__/public-block-binding-reach.test.tsx`.
|
|
84
|
+
*/
|
|
44
85
|
export function manifestFromConfigs(configs, opts = {}) {
|
|
45
86
|
const components = {};
|
|
46
87
|
for (const c of configs) {
|
package/dist/types.d.ts
CHANGED
|
@@ -61,8 +61,23 @@ export interface Manifest {
|
|
|
61
61
|
/** keyed by component `type` */
|
|
62
62
|
components: Record<string, ManifestComponent>;
|
|
63
63
|
}
|
|
64
|
-
/**
|
|
65
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Result of validating a compiled tree against the MANIFEST.
|
|
66
|
+
*
|
|
67
|
+
* Named `ManifestValidationResult`, not `ValidationResult` (objectui#3161,
|
|
68
|
+
* objectstack#4115 ledger batch 7), following the convention registered on
|
|
69
|
+
* objectstack#4115 for this name: **`<what was validated>Validation<Error |
|
|
70
|
+
* Result>`**. `ValidationResult` is exported twice by the spec — `kernel` and
|
|
71
|
+
* `contracts`, both `{ valid, errors?: [{ field, message, code? }], warnings? }`
|
|
72
|
+
* for PLUGIN MANIFEST validation — and `@object-ui/core` took
|
|
73
|
+
* `SchemaNodeValidationResult` under the same convention in batch 4
|
|
74
|
+
* (objectui#3188). Three results, three subjects: a plugin, a schema node, and
|
|
75
|
+
* this one, which carries no `valid` flag at all — it returns `diagnostics`
|
|
76
|
+
* (severity lives per entry), the `requires` set the compiled page needs, and
|
|
77
|
+
* the binding sites the server must resolve. Nothing here is assignable to
|
|
78
|
+
* anything there in either direction.
|
|
79
|
+
*/
|
|
80
|
+
export interface ManifestValidationResult {
|
|
66
81
|
diagnostics: Diagnostic[];
|
|
67
82
|
/** unique plugin namespaces referenced — the page's `requires` */
|
|
68
83
|
requires: string[];
|
package/dist/validate.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* and binding sites the SERVER must resolve against object schema (we cannot
|
|
7
7
|
* resolve objects/fields here — that check is framework-side by design).
|
|
8
8
|
*/
|
|
9
|
-
import type { Manifest, SchemaElement,
|
|
10
|
-
export declare function validateTree(tree: SchemaElement | null, manifest: Manifest):
|
|
9
|
+
import type { Manifest, SchemaElement, ManifestValidationResult } from './types.js';
|
|
10
|
+
export declare function validateTree(tree: SchemaElement | null, manifest: Manifest): ManifestValidationResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/sdui-parser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,11 +24,15 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
|
-
"devDependencies": {
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@objectstack/spec": "^17.0.0-rc.1",
|
|
29
|
+
"@object-ui/core": "17.2.0",
|
|
30
|
+
"@object-ui/react": "17.2.0"
|
|
31
|
+
},
|
|
28
32
|
"scripts": {
|
|
29
33
|
"build": "tsc",
|
|
30
34
|
"test": "vitest run",
|
|
31
|
-
"type-check": "tsc --noEmit",
|
|
35
|
+
"type-check": "tsc --noEmit && tsc -p tsconfig.test.json",
|
|
32
36
|
"lint": "eslint ."
|
|
33
37
|
}
|
|
34
38
|
}
|