@makehq/forman-schema 1.9.5 → 1.9.6
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/index.cjs +19 -5
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1150,6 +1150,7 @@ async function validateFormanWithDomainsInternal(domains, options) {
|
|
|
1150
1150
|
path: [],
|
|
1151
1151
|
tail: [],
|
|
1152
1152
|
strict: options?.strict === true,
|
|
1153
|
+
domainAliases: options?.domainAliases ?? {},
|
|
1153
1154
|
validateNestedFields: () => {
|
|
1154
1155
|
throw new Error("Cannot validate nested fields without parent field.");
|
|
1155
1156
|
},
|
|
@@ -1192,6 +1193,18 @@ async function validateFormanWithDomainsInternal(domains, options) {
|
|
|
1192
1193
|
}
|
|
1193
1194
|
}
|
|
1194
1195
|
}
|
|
1196
|
+
if (options?.strict) {
|
|
1197
|
+
for (const domain of Object.keys(domains)) {
|
|
1198
|
+
if (!domains[domain]) continue;
|
|
1199
|
+
const root = roots[domain];
|
|
1200
|
+
for (const key of Object.keys(domains[domain].values)) {
|
|
1201
|
+
if (!root.seenFields.has(key)) {
|
|
1202
|
+
root.seenFields.add(key);
|
|
1203
|
+
errors.push({ domain, path: "", message: `Unknown field '${key}'.` });
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1195
1208
|
return {
|
|
1196
1209
|
valid: errors.length === 0,
|
|
1197
1210
|
errors,
|
|
@@ -1374,7 +1387,7 @@ async function handleCollectionType2(value, field, context) {
|
|
|
1374
1387
|
errors.push(...result.errors);
|
|
1375
1388
|
}
|
|
1376
1389
|
}
|
|
1377
|
-
if (context.strict) {
|
|
1390
|
+
if (context.strict && context.path.length > 0) {
|
|
1378
1391
|
for (const key of Object.keys(value)) {
|
|
1379
1392
|
if (!seen.has(key)) {
|
|
1380
1393
|
seen.add(key);
|
|
@@ -1788,15 +1801,16 @@ async function handleNestedFields(nested, value, field, context) {
|
|
|
1788
1801
|
}
|
|
1789
1802
|
store = resolvedStore;
|
|
1790
1803
|
}
|
|
1791
|
-
|
|
1792
|
-
|
|
1804
|
+
const resolvedDomain = domain ? context.domainAliases[domain] ?? domain : domain;
|
|
1805
|
+
if (store && resolvedDomain && resolvedDomain !== context.domain) {
|
|
1806
|
+
if (!context.roots[resolvedDomain]) {
|
|
1793
1807
|
errors.push({
|
|
1794
1808
|
domain: context.domain,
|
|
1795
1809
|
path: context.path.join("."),
|
|
1796
|
-
message: `Unable to process nested fields: Domain '${domain}' not found.`
|
|
1810
|
+
message: resolvedDomain !== domain ? `Unable to process nested fields: Resolved domain '${resolvedDomain}' (from alias '${domain}') not found.` : `Unable to process nested fields: Domain '${domain}' not found.`
|
|
1797
1811
|
});
|
|
1798
1812
|
} else {
|
|
1799
|
-
const result = await context.roots[
|
|
1813
|
+
const result = await context.roots[resolvedDomain].validateFields(store, context);
|
|
1800
1814
|
errors.push(...result.errors);
|
|
1801
1815
|
}
|
|
1802
1816
|
} else if (store) {
|
package/dist/index.d.cts
CHANGED
|
@@ -216,6 +216,8 @@ type FormanValidationOptions = {
|
|
|
216
216
|
states?: boolean;
|
|
217
217
|
/** Remote resource resolver */
|
|
218
218
|
resolveRemote?(path: string, data: Record<string, unknown>): Promise<unknown>;
|
|
219
|
+
/** Maps domain names used in nested.domain to actual domain keys passed to validateFormanWithDomains */
|
|
220
|
+
domainAliases?: Record<string, string>;
|
|
219
221
|
};
|
|
220
222
|
|
|
221
223
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -216,6 +216,8 @@ type FormanValidationOptions = {
|
|
|
216
216
|
states?: boolean;
|
|
217
217
|
/** Remote resource resolver */
|
|
218
218
|
resolveRemote?(path: string, data: Record<string, unknown>): Promise<unknown>;
|
|
219
|
+
/** Maps domain names used in nested.domain to actual domain keys passed to validateFormanWithDomains */
|
|
220
|
+
domainAliases?: Record<string, string>;
|
|
219
221
|
};
|
|
220
222
|
|
|
221
223
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1121,6 +1121,7 @@ async function validateFormanWithDomainsInternal(domains, options) {
|
|
|
1121
1121
|
path: [],
|
|
1122
1122
|
tail: [],
|
|
1123
1123
|
strict: options?.strict === true,
|
|
1124
|
+
domainAliases: options?.domainAliases ?? {},
|
|
1124
1125
|
validateNestedFields: () => {
|
|
1125
1126
|
throw new Error("Cannot validate nested fields without parent field.");
|
|
1126
1127
|
},
|
|
@@ -1163,6 +1164,18 @@ async function validateFormanWithDomainsInternal(domains, options) {
|
|
|
1163
1164
|
}
|
|
1164
1165
|
}
|
|
1165
1166
|
}
|
|
1167
|
+
if (options?.strict) {
|
|
1168
|
+
for (const domain of Object.keys(domains)) {
|
|
1169
|
+
if (!domains[domain]) continue;
|
|
1170
|
+
const root = roots[domain];
|
|
1171
|
+
for (const key of Object.keys(domains[domain].values)) {
|
|
1172
|
+
if (!root.seenFields.has(key)) {
|
|
1173
|
+
root.seenFields.add(key);
|
|
1174
|
+
errors.push({ domain, path: "", message: `Unknown field '${key}'.` });
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1166
1179
|
return {
|
|
1167
1180
|
valid: errors.length === 0,
|
|
1168
1181
|
errors,
|
|
@@ -1345,7 +1358,7 @@ async function handleCollectionType2(value, field, context) {
|
|
|
1345
1358
|
errors.push(...result.errors);
|
|
1346
1359
|
}
|
|
1347
1360
|
}
|
|
1348
|
-
if (context.strict) {
|
|
1361
|
+
if (context.strict && context.path.length > 0) {
|
|
1349
1362
|
for (const key of Object.keys(value)) {
|
|
1350
1363
|
if (!seen.has(key)) {
|
|
1351
1364
|
seen.add(key);
|
|
@@ -1759,15 +1772,16 @@ async function handleNestedFields(nested, value, field, context) {
|
|
|
1759
1772
|
}
|
|
1760
1773
|
store = resolvedStore;
|
|
1761
1774
|
}
|
|
1762
|
-
|
|
1763
|
-
|
|
1775
|
+
const resolvedDomain = domain ? context.domainAliases[domain] ?? domain : domain;
|
|
1776
|
+
if (store && resolvedDomain && resolvedDomain !== context.domain) {
|
|
1777
|
+
if (!context.roots[resolvedDomain]) {
|
|
1764
1778
|
errors.push({
|
|
1765
1779
|
domain: context.domain,
|
|
1766
1780
|
path: context.path.join("."),
|
|
1767
|
-
message: `Unable to process nested fields: Domain '${domain}' not found.`
|
|
1781
|
+
message: resolvedDomain !== domain ? `Unable to process nested fields: Resolved domain '${resolvedDomain}' (from alias '${domain}') not found.` : `Unable to process nested fields: Domain '${domain}' not found.`
|
|
1768
1782
|
});
|
|
1769
1783
|
} else {
|
|
1770
|
-
const result = await context.roots[
|
|
1784
|
+
const result = await context.roots[resolvedDomain].validateFields(store, context);
|
|
1771
1785
|
errors.push(...result.errors);
|
|
1772
1786
|
}
|
|
1773
1787
|
} else if (store) {
|