@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.
package/dist/cli.cjs CHANGED
@@ -1622,12 +1622,25 @@ function applyCustomConstraint(schema, constraint, ctx) {
1622
1622
  `Cannot generate JSON Schema for custom constraint "${constraint.constraintId}" without a matching extension registration`
1623
1623
  );
1624
1624
  }
1625
- assignVendorPrefixedExtensionKeywords(
1626
- schema,
1627
- registration.toJsonSchema(constraint.payload, ctx.vendorPrefix),
1628
- ctx.vendorPrefix,
1629
- `custom constraint "${constraint.constraintId}"`
1630
- );
1625
+ const extensionSchema = registration.toJsonSchema(constraint.payload, ctx.vendorPrefix);
1626
+ if (registration.emitsVocabularyKeywords) {
1627
+ const target = schema;
1628
+ for (const [key, value] of Object.entries(extensionSchema)) {
1629
+ if (JSON_SCHEMA_STRUCTURAL_KEYWORDS.has(key)) {
1630
+ throw new Error(
1631
+ `Custom constraint "${constraint.constraintId}" with emitsVocabularyKeywords must not overwrite standard JSON Schema keyword "${key}"`
1632
+ );
1633
+ }
1634
+ target[key] = value;
1635
+ }
1636
+ } else {
1637
+ assignVendorPrefixedExtensionKeywords(
1638
+ schema,
1639
+ extensionSchema,
1640
+ ctx.vendorPrefix,
1641
+ `custom constraint "${constraint.constraintId}"`
1642
+ );
1643
+ }
1631
1644
  }
1632
1645
  function applyCustomAnnotation(schema, annotation, ctx) {
1633
1646
  const registration = ctx.extensionRegistry?.findAnnotation(annotation.annotationId);
@@ -1656,11 +1669,72 @@ function assignVendorPrefixedExtensionKeywords(schema, extensionSchema, vendorPr
1656
1669
  schema[key] = value;
1657
1670
  }
1658
1671
  }
1672
+ var JSON_SCHEMA_STRUCTURAL_KEYWORDS;
1659
1673
  var init_ir_generator = __esm({
1660
1674
  "src/json-schema/ir-generator.ts"() {
1661
1675
  "use strict";
1662
1676
  init_metadata();
1663
1677
  init_collision_guards();
1678
+ JSON_SCHEMA_STRUCTURAL_KEYWORDS = /* @__PURE__ */ new Set([
1679
+ "$schema",
1680
+ "$ref",
1681
+ "$defs",
1682
+ "$id",
1683
+ "$anchor",
1684
+ "$dynamicRef",
1685
+ "$dynamicAnchor",
1686
+ "$vocabulary",
1687
+ "$comment",
1688
+ "type",
1689
+ "enum",
1690
+ "const",
1691
+ "properties",
1692
+ "patternProperties",
1693
+ "additionalProperties",
1694
+ "required",
1695
+ "items",
1696
+ "prefixItems",
1697
+ "additionalItems",
1698
+ "contains",
1699
+ "allOf",
1700
+ "oneOf",
1701
+ "anyOf",
1702
+ "not",
1703
+ "if",
1704
+ "then",
1705
+ "else",
1706
+ "minimum",
1707
+ "maximum",
1708
+ "exclusiveMinimum",
1709
+ "exclusiveMaximum",
1710
+ "multipleOf",
1711
+ "minLength",
1712
+ "maxLength",
1713
+ "pattern",
1714
+ "minItems",
1715
+ "maxItems",
1716
+ "uniqueItems",
1717
+ "minProperties",
1718
+ "maxProperties",
1719
+ "minContains",
1720
+ "maxContains",
1721
+ "format",
1722
+ "title",
1723
+ "description",
1724
+ "default",
1725
+ "deprecated",
1726
+ "readOnly",
1727
+ "writeOnly",
1728
+ "examples",
1729
+ "dependentRequired",
1730
+ "dependentSchemas",
1731
+ "propertyNames",
1732
+ "unevaluatedItems",
1733
+ "unevaluatedProperties",
1734
+ "contentEncoding",
1735
+ "contentMediaType",
1736
+ "contentSchema"
1737
+ ]);
1664
1738
  }
1665
1739
  });
1666
1740