@formspec/build 0.1.0-alpha.41 → 0.1.0-alpha.42

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.
@@ -4859,6 +4859,66 @@ function generateCustomType(type, ctx) {
4859
4859
  }
4860
4860
  return registration.toJsonSchema(type.payload, ctx.vendorPrefix);
4861
4861
  }
4862
+ var JSON_SCHEMA_STRUCTURAL_KEYWORDS = /* @__PURE__ */ new Set([
4863
+ "$schema",
4864
+ "$ref",
4865
+ "$defs",
4866
+ "$id",
4867
+ "$anchor",
4868
+ "$dynamicRef",
4869
+ "$dynamicAnchor",
4870
+ "$vocabulary",
4871
+ "$comment",
4872
+ "type",
4873
+ "enum",
4874
+ "const",
4875
+ "properties",
4876
+ "patternProperties",
4877
+ "additionalProperties",
4878
+ "required",
4879
+ "items",
4880
+ "prefixItems",
4881
+ "additionalItems",
4882
+ "contains",
4883
+ "allOf",
4884
+ "oneOf",
4885
+ "anyOf",
4886
+ "not",
4887
+ "if",
4888
+ "then",
4889
+ "else",
4890
+ "minimum",
4891
+ "maximum",
4892
+ "exclusiveMinimum",
4893
+ "exclusiveMaximum",
4894
+ "multipleOf",
4895
+ "minLength",
4896
+ "maxLength",
4897
+ "pattern",
4898
+ "minItems",
4899
+ "maxItems",
4900
+ "uniqueItems",
4901
+ "minProperties",
4902
+ "maxProperties",
4903
+ "minContains",
4904
+ "maxContains",
4905
+ "format",
4906
+ "title",
4907
+ "description",
4908
+ "default",
4909
+ "deprecated",
4910
+ "readOnly",
4911
+ "writeOnly",
4912
+ "examples",
4913
+ "dependentRequired",
4914
+ "dependentSchemas",
4915
+ "propertyNames",
4916
+ "unevaluatedItems",
4917
+ "unevaluatedProperties",
4918
+ "contentEncoding",
4919
+ "contentMediaType",
4920
+ "contentSchema"
4921
+ ]);
4862
4922
  function applyCustomConstraint(schema, constraint, ctx) {
4863
4923
  const registration = ctx.extensionRegistry?.findConstraint(constraint.constraintId);
4864
4924
  if (registration === void 0) {
@@ -4866,12 +4926,25 @@ function applyCustomConstraint(schema, constraint, ctx) {
4866
4926
  `Cannot generate JSON Schema for custom constraint "${constraint.constraintId}" without a matching extension registration`
4867
4927
  );
4868
4928
  }
4869
- assignVendorPrefixedExtensionKeywords(
4870
- schema,
4871
- registration.toJsonSchema(constraint.payload, ctx.vendorPrefix),
4872
- ctx.vendorPrefix,
4873
- `custom constraint "${constraint.constraintId}"`
4874
- );
4929
+ const extensionSchema = registration.toJsonSchema(constraint.payload, ctx.vendorPrefix);
4930
+ if (registration.emitsVocabularyKeywords) {
4931
+ const target = schema;
4932
+ for (const [key, value] of Object.entries(extensionSchema)) {
4933
+ if (JSON_SCHEMA_STRUCTURAL_KEYWORDS.has(key)) {
4934
+ throw new Error(
4935
+ `Custom constraint "${constraint.constraintId}" with emitsVocabularyKeywords must not overwrite standard JSON Schema keyword "${key}"`
4936
+ );
4937
+ }
4938
+ target[key] = value;
4939
+ }
4940
+ } else {
4941
+ assignVendorPrefixedExtensionKeywords(
4942
+ schema,
4943
+ extensionSchema,
4944
+ ctx.vendorPrefix,
4945
+ `custom constraint "${constraint.constraintId}"`
4946
+ );
4947
+ }
4875
4948
  }
4876
4949
  function applyCustomAnnotation(schema, annotation, ctx) {
4877
4950
  const registration = ctx.extensionRegistry?.findAnnotation(annotation.annotationId);