@formspec/build 0.1.0-alpha.43 → 0.1.0-alpha.45
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/analyzer/class-analyzer.d.ts.map +1 -1
- package/dist/analyzer/program.d.ts +4 -1
- package/dist/analyzer/program.d.ts.map +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
- package/dist/browser.cjs +35 -9
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +36 -12
- package/dist/browser.js.map +1 -1
- package/dist/build-alpha.d.ts +106 -5
- package/dist/build-beta.d.ts +106 -5
- package/dist/build-internal.d.ts +106 -5
- package/dist/build.d.ts +106 -5
- package/dist/cli.cjs +343 -59
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +339 -58
- package/dist/cli.js.map +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/registry.d.ts +64 -5
- package/dist/extensions/registry.d.ts.map +1 -1
- package/dist/extensions/symbol-registry.d.ts +33 -0
- package/dist/extensions/symbol-registry.d.ts.map +1 -0
- package/dist/generators/class-schema.d.ts +16 -0
- package/dist/generators/class-schema.d.ts.map +1 -1
- package/dist/generators/discovered-schema.d.ts.map +1 -1
- package/dist/index.cjs +328 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +329 -54
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +124 -10
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.d.ts +1 -1
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +125 -13
- package/dist/internals.js.map +1 -1
- package/dist/json-schema/generator.d.ts.map +1 -1
- package/dist/metadata/collision-guards.d.ts.map +1 -1
- package/dist/metadata/policy.d.ts.map +1 -1
- package/dist/metadata/resolve.d.ts.map +1 -1
- package/dist/ui-schema/ir-generator.d.ts.map +1 -1
- package/dist/validate/constraint-validator.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/browser.js
CHANGED
|
@@ -220,7 +220,9 @@ function resolveTypeNodeMetadata(type, options) {
|
|
|
220
220
|
case "object":
|
|
221
221
|
return {
|
|
222
222
|
...type,
|
|
223
|
-
properties: type.properties.map(
|
|
223
|
+
properties: type.properties.map(
|
|
224
|
+
(property) => resolveObjectPropertyMetadata(property, options)
|
|
225
|
+
)
|
|
224
226
|
};
|
|
225
227
|
case "record":
|
|
226
228
|
return {
|
|
@@ -1423,7 +1425,7 @@ function generateCustomType(type, ctx) {
|
|
|
1423
1425
|
}
|
|
1424
1426
|
return registration.toJsonSchema(type.payload, ctx.vendorPrefix);
|
|
1425
1427
|
}
|
|
1426
|
-
var
|
|
1428
|
+
var VOCABULARY_MODE_BLOCKED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1427
1429
|
"$schema",
|
|
1428
1430
|
"$ref",
|
|
1429
1431
|
"$defs",
|
|
@@ -1494,7 +1496,7 @@ function applyCustomConstraint(schema, constraint, ctx) {
|
|
|
1494
1496
|
if (registration.emitsVocabularyKeywords) {
|
|
1495
1497
|
const target = schema;
|
|
1496
1498
|
for (const [key, value] of Object.entries(extensionSchema)) {
|
|
1497
|
-
if (
|
|
1499
|
+
if (VOCABULARY_MODE_BLOCKED_KEYWORDS.has(key)) {
|
|
1498
1500
|
throw new Error(
|
|
1499
1501
|
`Custom constraint "${constraint.constraintId}" with emitsVocabularyKeywords must not overwrite standard JSON Schema keyword "${key}"`
|
|
1500
1502
|
);
|
|
@@ -1543,10 +1545,7 @@ function generateJsonSchema(form, options) {
|
|
|
1543
1545
|
const metadata = options?.metadata;
|
|
1544
1546
|
const vendorPrefix = options?.vendorPrefix;
|
|
1545
1547
|
const enumSerialization = options?.enumSerialization;
|
|
1546
|
-
const ir = canonicalizeChainDSL(
|
|
1547
|
-
form,
|
|
1548
|
-
metadata !== void 0 ? { metadata } : void 0
|
|
1549
|
-
);
|
|
1548
|
+
const ir = canonicalizeChainDSL(form, metadata !== void 0 ? { metadata } : void 0);
|
|
1550
1549
|
const internalOptions = vendorPrefix === void 0 && enumSerialization === void 0 ? void 0 : {
|
|
1551
1550
|
...vendorPrefix !== void 0 && { vendorPrefix },
|
|
1552
1551
|
...enumSerialization !== void 0 && { enumSerialization }
|
|
@@ -1762,7 +1761,10 @@ function irElementsToUiSchema(elements, fieldNameMap, parentRule) {
|
|
|
1762
1761
|
break;
|
|
1763
1762
|
}
|
|
1764
1763
|
case "conditional": {
|
|
1765
|
-
const newRule = createShowRule(
|
|
1764
|
+
const newRule = createShowRule(
|
|
1765
|
+
fieldNameMap.get(element.fieldName) ?? element.fieldName,
|
|
1766
|
+
element.value
|
|
1767
|
+
);
|
|
1766
1768
|
const combinedRule = parentRule !== void 0 ? combineRules(parentRule, newRule) : newRule;
|
|
1767
1769
|
const childElements = irElementsToUiSchema(element.elements, fieldNameMap, combinedRule);
|
|
1768
1770
|
result.push(...childElements);
|
|
@@ -1847,8 +1849,10 @@ function buildConstraintTagSources(extensions) {
|
|
|
1847
1849
|
}
|
|
1848
1850
|
function createExtensionRegistry(extensions) {
|
|
1849
1851
|
const reservedTagSources = buildConstraintTagSources(extensions);
|
|
1852
|
+
let symbolMap = /* @__PURE__ */ new Map();
|
|
1850
1853
|
const typeMap = /* @__PURE__ */ new Map();
|
|
1851
1854
|
const typeNameMap = /* @__PURE__ */ new Map();
|
|
1855
|
+
const brandMap = /* @__PURE__ */ new Map();
|
|
1852
1856
|
const constraintMap = /* @__PURE__ */ new Map();
|
|
1853
1857
|
const constraintTagMap = /* @__PURE__ */ new Map();
|
|
1854
1858
|
const builtinBroadeningMap = /* @__PURE__ */ new Map();
|
|
@@ -1872,6 +1876,20 @@ function createExtensionRegistry(extensions) {
|
|
|
1872
1876
|
registration: type
|
|
1873
1877
|
});
|
|
1874
1878
|
}
|
|
1879
|
+
if (type.brand !== void 0) {
|
|
1880
|
+
if (type.brand === "__integerBrand") {
|
|
1881
|
+
throw new Error(
|
|
1882
|
+
`Brand "__integerBrand" is reserved for the builtin Integer type and cannot be registered by extensions`
|
|
1883
|
+
);
|
|
1884
|
+
}
|
|
1885
|
+
if (brandMap.has(type.brand)) {
|
|
1886
|
+
throw new Error(`Duplicate custom type brand: "${type.brand}"`);
|
|
1887
|
+
}
|
|
1888
|
+
brandMap.set(type.brand, {
|
|
1889
|
+
extensionId: ext.extensionId,
|
|
1890
|
+
registration: type
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1875
1893
|
if (type.builtinConstraintBroadenings !== void 0) {
|
|
1876
1894
|
for (const broadening of type.builtinConstraintBroadenings) {
|
|
1877
1895
|
const key = `${qualifiedId}:${broadening.tagName}`;
|
|
@@ -1941,7 +1959,10 @@ function createExtensionRegistry(extensions) {
|
|
|
1941
1959
|
`Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${canonicalTagName}".`
|
|
1942
1960
|
);
|
|
1943
1961
|
}
|
|
1944
|
-
if (Object.hasOwn(
|
|
1962
|
+
if (Object.hasOwn(
|
|
1963
|
+
BUILTIN_CONSTRAINT_DEFINITIONS,
|
|
1964
|
+
normalizeConstraintTagName(canonicalTagName)
|
|
1965
|
+
)) {
|
|
1945
1966
|
throw new Error(
|
|
1946
1967
|
`Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${normalizeConstraintTagName(canonicalTagName)}".`
|
|
1947
1968
|
);
|
|
@@ -1962,6 +1983,11 @@ function createExtensionRegistry(extensions) {
|
|
|
1962
1983
|
extensions,
|
|
1963
1984
|
findType: (typeId) => typeMap.get(typeId),
|
|
1964
1985
|
findTypeByName: (typeName) => typeNameMap.get(typeName),
|
|
1986
|
+
findTypeByBrand: (brand) => brandMap.get(brand),
|
|
1987
|
+
findTypeBySymbol: (symbol) => symbolMap.get(symbol),
|
|
1988
|
+
setSymbolMap: (map) => {
|
|
1989
|
+
symbolMap = map;
|
|
1990
|
+
},
|
|
1965
1991
|
findConstraint: (constraintId) => constraintMap.get(constraintId),
|
|
1966
1992
|
findConstraintTag: (tagName) => constraintTagMap.get(normalizeFormSpecTagName(tagName)),
|
|
1967
1993
|
findBuiltinConstraintBroadening: (typeId, tagName) => builtinBroadeningMap.get(`${typeId}:${tagName}`),
|
|
@@ -2032,9 +2058,7 @@ var jsonSchema7Schema = z3.lazy(
|
|
|
2032
2058
|
);
|
|
2033
2059
|
|
|
2034
2060
|
// src/validate/constraint-validator.ts
|
|
2035
|
-
import {
|
|
2036
|
-
analyzeConstraintTargets
|
|
2037
|
-
} from "@formspec/analysis/internal";
|
|
2061
|
+
import { analyzeConstraintTargets } from "@formspec/analysis/internal";
|
|
2038
2062
|
function validateFieldNode(ctx, field) {
|
|
2039
2063
|
const analysis = analyzeConstraintTargets(
|
|
2040
2064
|
field.name,
|