@stxt-lang/core 0.6.2 → 0.6.3

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.
@@ -16,9 +16,13 @@ export declare class SchemaProviderMeta implements SchemaProvider {
16
16
  /**
17
17
  * Serves the meta-schema of the schema language.
18
18
  *
19
+ * Follows the {@link SchemaProvider} contract: providers never throw "not found". Any
20
+ * namespace other than `@stxt.schema` yields `null`, so that this provider can sit at
21
+ * the end of a fallback chain (it is the default parent of {@link SchemaProviderMemory})
22
+ * and the {@link SchemaValidator} is the only one reporting `SCHEMA_NOT_FOUND`.
23
+ *
19
24
  * @param namespace namespace whose schema is wanted; only `@stxt.schema` is served.
20
- * @returns the meta-schema of the schema language.
21
- * @throws RuntimeException with code `RESOURCE_NOT_FOUND` if any other namespace is asked for.
25
+ * @returns the meta-schema of the schema language, or `null` for any other namespace.
22
26
  */
23
- getSchema(namespace: string): Schema;
27
+ getSchema(namespace: string): Schema | null;
24
28
  }
@@ -4,7 +4,6 @@ exports.SchemaProviderMeta = void 0;
4
4
  const Schema_1 = require("./Schema");
5
5
  const Parser_1 = require("../core/Parser");
6
6
  const ValidationException_1 = require("../exceptions/ValidationException");
7
- const RuntimeException_1 = require("../exceptions/RuntimeException");
8
7
  const SchemaParser_1 = require("./SchemaParser");
9
8
  /**
10
9
  * {@link SchemaProvider} that defines in code the meta-schema of the schema language itself
@@ -27,13 +26,17 @@ class SchemaProviderMeta {
27
26
  /**
28
27
  * Serves the meta-schema of the schema language.
29
28
  *
29
+ * Follows the {@link SchemaProvider} contract: providers never throw "not found". Any
30
+ * namespace other than `@stxt.schema` yields `null`, so that this provider can sit at
31
+ * the end of a fallback chain (it is the default parent of {@link SchemaProviderMemory})
32
+ * and the {@link SchemaValidator} is the only one reporting `SCHEMA_NOT_FOUND`.
33
+ *
30
34
  * @param namespace namespace whose schema is wanted; only `@stxt.schema` is served.
31
- * @returns the meta-schema of the schema language.
32
- * @throws RuntimeException with code `RESOURCE_NOT_FOUND` if any other namespace is asked for.
35
+ * @returns the meta-schema of the schema language, or `null` for any other namespace.
33
36
  */
34
37
  getSchema(namespace) {
35
38
  if (namespace !== Schema_1.Schema.SCHEMA_NAMESPACE) {
36
- throw new RuntimeException_1.RuntimeException("RESOURCE_NOT_FOUND", `Not found '${namespace}' in namespace: ${Schema_1.Schema.SCHEMA_NAMESPACE}`);
39
+ return null;
37
40
  }
38
41
  if (!this.meta) {
39
42
  throw new ValidationException_1.ValidationException(0, "META_SCHEMA_NOT_AVAILABLE", "Meta schema not available");
@@ -16,9 +16,12 @@ export declare class MetaTemplateSchemaProvider implements SchemaProvider {
16
16
  /**
17
17
  * Serves the meta-schema of the template language.
18
18
  *
19
+ * Follows the {@link SchemaProvider} contract: providers never throw "not found". Any
20
+ * namespace other than `@stxt.template` yields `null`; only the `SchemaValidator`
21
+ * reports `SCHEMA_NOT_FOUND`.
22
+ *
19
23
  * @param namespace namespace whose schema is wanted; only `@stxt.template` is served.
20
- * @returns the meta-schema of the template language.
21
- * @throws RuntimeException with code `RESOURCE_NOT_FOUND` if any other namespace is asked for.
24
+ * @returns the meta-schema of the template language, or `null` for any other namespace.
22
25
  */
23
- getSchema(namespace: string): Schema;
26
+ getSchema(namespace: string): Schema | null;
24
27
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MetaTemplateSchemaProvider = void 0;
4
4
  const Parser_1 = require("../core/Parser");
5
5
  const ValidationException_1 = require("../exceptions/ValidationException");
6
- const RuntimeException_1 = require("../exceptions/RuntimeException");
7
6
  const TemplateParser_1 = require("./TemplateParser");
8
7
  /**
9
8
  * {@link SchemaProvider} that defines in code the meta-schema of the template language itself
@@ -26,13 +25,16 @@ class MetaTemplateSchemaProvider {
26
25
  /**
27
26
  * Serves the meta-schema of the template language.
28
27
  *
28
+ * Follows the {@link SchemaProvider} contract: providers never throw "not found". Any
29
+ * namespace other than `@stxt.template` yields `null`; only the `SchemaValidator`
30
+ * reports `SCHEMA_NOT_FOUND`.
31
+ *
29
32
  * @param namespace namespace whose schema is wanted; only `@stxt.template` is served.
30
- * @returns the meta-schema of the template language.
31
- * @throws RuntimeException with code `RESOURCE_NOT_FOUND` if any other namespace is asked for.
33
+ * @returns the meta-schema of the template language, or `null` for any other namespace.
32
34
  */
33
35
  getSchema(namespace) {
34
36
  if (namespace !== "@stxt.template") {
35
- throw new RuntimeException_1.RuntimeException("RESOURCE_NOT_FOUND", `Not found '${namespace}' in namespace: @stxt.template`);
37
+ return null;
36
38
  }
37
39
  // meta always exists once the constructor finished, but this mirrors the Java version
38
40
  if (!this.meta) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stxt-lang/core",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Parser and schema validator for STXT, an indentation-based structured-text format.",
5
5
  "main": "out/all.js",
6
6
  "types": "out/all.d.ts",