@appsemble/lang-sdk 0.40.7 → 0.40.8

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/BasicValidator.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Validator, } from 'jsonschema';
2
2
  import { isValidIconReference } from './icons.js';
3
3
  import { schemas as allSchemas } from './index.js';
4
+ import { skipBaseResolutionForSchemasWithoutId } from './jsonschemaBaseResolution.js';
4
5
  import { escapeJsonPointer } from './jsonPointer.js';
5
6
  import { has } from './miscellaneous.js';
6
7
  export class BaseValidatorFactory {
@@ -9,6 +10,7 @@ export class BaseValidatorFactory {
9
10
  this.schemas = schemas;
10
11
  }
11
12
  build() {
13
+ skipBaseResolutionForSchemasWithoutId();
12
14
  const validator = new Validator();
13
15
  for (const [key, format] of Object.entries({
14
16
  ...BaseValidatorFactory.defaultCustomFormats,
package/blockUtils.js CHANGED
@@ -49,6 +49,9 @@ export function getAppBlocks(definition) {
49
49
  const result = [];
50
50
  iterApp(definition, {
51
51
  onBlock({ type, version }) {
52
+ if (typeof type !== 'string' || typeof version !== 'string') {
53
+ return;
54
+ }
52
55
  const name = normalizeBlockName(type);
53
56
  const asString = `${name}@${version}`;
54
57
  if (!visited.has(asString)) {
package/jsonschema.d.ts CHANGED
@@ -23,6 +23,7 @@ declare module 'jsonschema' {
23
23
  }
24
24
  interface SchemaContext {
25
25
  path: (number | string)[];
26
+ resolve: (target: string) => string;
26
27
  }
27
28
  }
28
29
  /**
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Resolve a child schema's base URI only when that schema declares an id.
3
+ *
4
+ * `jsonschema` resolves a base URI for every schema node it visits, and that URL resolution is the
5
+ * single most expensive part of validating a large app definition. A schema without an `$id` or
6
+ * `id` always resolves to its parent's base, so the resolution only carries information when an id
7
+ * is present. Appsemble's schemas declare no ids, which makes the resolution pure overhead for
8
+ * every node in the document.
9
+ *
10
+ * Calling this more than once is harmless: it installs the same implementation each time rather
11
+ * than wrapping whatever is already there.
12
+ */
13
+ export declare function skipBaseResolutionForSchemasWithoutId(): void;
@@ -0,0 +1,30 @@
1
+ // `jsonschema` ships no types for its internal helpers module, which is where the schema context
2
+ // it builds while validating lives.
3
+ // @ts-expect-error 7016 -- untyped module
4
+ import { SchemaContext as UntypedSchemaContext } from 'jsonschema/lib/helpers.js';
5
+ const SchemaContextConstructor = UntypedSchemaContext;
6
+ /**
7
+ * Resolve a child schema's base URI only when that schema declares an id.
8
+ *
9
+ * `jsonschema` resolves a base URI for every schema node it visits, and that URL resolution is the
10
+ * single most expensive part of validating a large app definition. A schema without an `$id` or
11
+ * `id` always resolves to its parent's base, so the resolution only carries information when an id
12
+ * is present. Appsemble's schemas declare no ids, which makes the resolution pure overhead for
13
+ * every node in the document.
14
+ *
15
+ * Calling this more than once is harmless: it installs the same implementation each time rather
16
+ * than wrapping whatever is already there.
17
+ */
18
+ export function skipBaseResolutionForSchemasWithoutId() {
19
+ SchemaContextConstructor.prototype.makeChild = function makeChild(schema, propertyName) {
20
+ const path = propertyName === undefined ? this.path : [...this.path, propertyName];
21
+ const id = schema.$id ?? schema.id;
22
+ const base = id ? this.resolve(id) : this.base;
23
+ const ctx = new SchemaContextConstructor(schema, this.options, path, base, Object.create(this.schemas));
24
+ if (id && !ctx.schemas[base]) {
25
+ ctx.schemas[base] = schema;
26
+ }
27
+ return ctx;
28
+ };
29
+ }
30
+ //# sourceMappingURL=jsonschemaBaseResolution.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/lang-sdk",
3
- "version": "0.40.7",
3
+ "version": "0.40.8",
4
4
  "description": "Language SDK for Appsemble",
5
5
  "keywords": [
6
6
  "app",