@shlomoa/openui-spec 0.1.1 → 0.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/README.md CHANGED
@@ -9,13 +9,15 @@ This repository contains a technology-independent specification for a Web UI fra
9
9
  Contributor and developer entry points for this repository:
10
10
 
11
11
  - [Contributing guide](CONTRIBUTING.md) — local setup and validation basics.
12
+ - [Changelog](CHANGELOG.md) — release notes, breaking changes, and upgrade guidance.
12
13
 
13
14
  ## OpenUI JSON API
14
15
 
15
16
  The [`@shlomoa/openui-spec`](package.json) package provides `OpenUiJson` for
16
17
  loading, validating, and editing an OpenUI JSON document. It bundles
17
18
  `spec/openui.schema.json` and `spec/openui.json`; validation checks both the
18
- schema and the object types supported by the canonical catalog.
19
+ schema and exact [known object type](spec/README.md#known-object-type)
20
+ membership in the canonical catalog.
19
21
 
20
22
  ```bash
21
23
  npm install @shlomoa/openui-spec
@@ -42,6 +42,7 @@ export declare class OpenUiJson {
42
42
  }): void;
43
43
  updateAttributes(objectId: string, attributes: Record<string, string | null>): void;
44
44
  private validateChild;
45
+ private catalogTypes;
45
46
  private validateNode;
46
47
  private find;
47
48
  private findParent;
package/dist/src/index.js CHANGED
@@ -77,15 +77,15 @@ class OpenUiJson {
77
77
  if (!validator(this.document)) {
78
78
  throw new OpenUiValidationError(formatValidationErrors(validator.errors));
79
79
  }
80
- const supportedTypes = new Set([...this.walk(catalog)].map((node) => node.type));
80
+ const knownTypes = this.catalogTypes(catalog);
81
81
  const seenIds = new Set();
82
82
  for (const node of this.walk(this.document)) {
83
83
  if (seenIds.has(node.id)) {
84
84
  throw new OpenUiValidationError(`duplicate object id: ${node.id}`);
85
85
  }
86
86
  seenIds.add(node.id);
87
- if (!supportedTypes.has(node.type)) {
88
- throw new OpenUiValidationError(`unsupported object type: ${node.type}`);
87
+ if (!knownTypes.has(node.type)) {
88
+ throw new OpenUiValidationError(`unknown OpenUI object type: ${node.type}`);
89
89
  }
90
90
  }
91
91
  }
@@ -164,18 +164,21 @@ class OpenUiJson {
164
164
  validateChild(child) {
165
165
  this.validateNode(child, false);
166
166
  const catalog = this.loadJson(this.options.catalog, this.options.catalogPath, "catalog");
167
- const supportedTypes = new Set([...this.walk(catalog)].map((node) => node.type));
167
+ const knownTypes = this.catalogTypes(catalog);
168
168
  const seenIds = new Set();
169
169
  for (const node of this.walk(child)) {
170
170
  if (seenIds.has(node.id)) {
171
171
  throw new OpenUiJsonError(`duplicate object id: ${node.id}`);
172
172
  }
173
173
  seenIds.add(node.id);
174
- if (!supportedTypes.has(node.type)) {
175
- throw new OpenUiJsonError(`unsupported object type: ${node.type}`);
174
+ if (!knownTypes.has(node.type)) {
175
+ throw new OpenUiJsonError(`unknown OpenUI object type: ${node.type}`);
176
176
  }
177
177
  }
178
178
  }
179
+ catalogTypes(catalog) {
180
+ return new Set([...this.walk(catalog)].map((node) => node.type));
181
+ }
179
182
  validateNode(node, isRoot) {
180
183
  const schema = this.loadJson(this.options.schema, this.options.schemaPath, "schema");
181
184
  const definition = isRoot ? schema : { $ref: "#/$defs/element", $defs: schema.$defs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shlomoa/openui-spec",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Load, validate, and edit OpenUI JSON documents.",
5
5
  "scripts": {
6
6
  "build:tsc": "tsc -p tsconfig.json",
package/spec/openui.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "root",
3
3
  "type": "html",
4
- "version": "0.1.0",
4
+ "version": "0.2.0",
5
5
  "attrs": {
6
6
  "name": "OpenUI",
7
7
  "description": "Technology-independent Web UI framework specification",