@makehq/forman-schema 1.8.0 → 1.8.2
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 +26 -10
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -89,6 +89,15 @@ function normalizeFormanFieldType(field) {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
+
function findValueInSelectOptions(field, value, optionsAndGroups) {
|
|
93
|
+
if (!optionsAndGroups) return void 0;
|
|
94
|
+
if (field.grouped) {
|
|
95
|
+
const found2 = optionsAndGroups.flatMap((group) => "options" in group ? group.options : []).find((option) => option.value === value);
|
|
96
|
+
if (found2) return found2;
|
|
97
|
+
}
|
|
98
|
+
const found = optionsAndGroups.find((option) => "value" in option && option.value === value);
|
|
99
|
+
return found;
|
|
100
|
+
}
|
|
92
101
|
function buildRestoreStructure(items) {
|
|
93
102
|
const result = {};
|
|
94
103
|
for (const item of items) {
|
|
@@ -241,6 +250,7 @@ var FORMAN_TYPE_MAP = {
|
|
|
241
250
|
editor: "string",
|
|
242
251
|
number: "number",
|
|
243
252
|
boolean: "boolean",
|
|
253
|
+
checkbox: "boolean",
|
|
244
254
|
date: "string",
|
|
245
255
|
json: "string",
|
|
246
256
|
buffer: "string",
|
|
@@ -463,12 +473,15 @@ function handleSelectOrPathType(field, result, context) {
|
|
|
463
473
|
value: appendQueryString(optionsOrGroups, context.domain, context.tail)
|
|
464
474
|
});
|
|
465
475
|
} else {
|
|
466
|
-
const options = optionsOrGroups?.
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
476
|
+
const options = optionsOrGroups?.flatMap((optionOrGroup) => {
|
|
477
|
+
if (isOptionGroup(optionOrGroup)) {
|
|
478
|
+
return optionOrGroup.options.map((option) => ({
|
|
479
|
+
...option,
|
|
480
|
+
label: `${optionOrGroup.label}: ${option.label || option.value}`
|
|
481
|
+
}));
|
|
482
|
+
}
|
|
483
|
+
return optionOrGroup;
|
|
484
|
+
});
|
|
472
485
|
if (options?.some((option) => {
|
|
473
486
|
if (isOptionGroup(option)) return option.options.some((option2) => option2.label || option2.nested);
|
|
474
487
|
return option.label || option.nested;
|
|
@@ -613,6 +626,7 @@ var FORMAN_TYPE_MAP2 = {
|
|
|
613
626
|
text: "string",
|
|
614
627
|
number: "number",
|
|
615
628
|
boolean: "boolean",
|
|
629
|
+
checkbox: "boolean",
|
|
616
630
|
date: "string",
|
|
617
631
|
json: "string",
|
|
618
632
|
buffer: "string",
|
|
@@ -1134,9 +1148,11 @@ async function handleSelectType(value, field, context) {
|
|
|
1134
1148
|
};
|
|
1135
1149
|
}
|
|
1136
1150
|
for (const singleValue of value) {
|
|
1137
|
-
const found =
|
|
1138
|
-
|
|
1139
|
-
|
|
1151
|
+
const found = findValueInSelectOptions(
|
|
1152
|
+
field,
|
|
1153
|
+
singleValue,
|
|
1154
|
+
optionsOrGroups
|
|
1155
|
+
);
|
|
1140
1156
|
if (!found) {
|
|
1141
1157
|
errors.push({
|
|
1142
1158
|
domain: context.domain,
|
|
@@ -1162,7 +1178,7 @@ async function handleSelectType(value, field, context) {
|
|
|
1162
1178
|
}
|
|
1163
1179
|
}
|
|
1164
1180
|
} else {
|
|
1165
|
-
const item = field
|
|
1181
|
+
const item = findValueInSelectOptions(field, value, optionsOrGroups);
|
|
1166
1182
|
if (!item) {
|
|
1167
1183
|
return {
|
|
1168
1184
|
valid: false,
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { JSONSchema7 } from 'json-schema';
|
|
|
3
3
|
/**
|
|
4
4
|
* Valid Forman Schema field types
|
|
5
5
|
*/
|
|
6
|
-
type FormanSchemaFieldType = 'aiagent' | 'account' | 'hook' | 'device' | 'keychain' | 'datastore' | 'udt' | 'scenario' | 'array' | 'collection' | 'text' | 'number' | 'boolean' | 'date' | 'json' | 'buffer' | 'cert' | 'color' | 'email' | 'filename' | 'file' | 'filter' | 'folder' | 'hidden' | 'integer' | 'uinteger' | 'path' | 'pkey' | 'port' | 'select' | 'time' | 'timestamp' | 'timezone' | 'url' | 'uuid' | `account:${string}` | `hook:${string}` | `keychain:${string}` | `device:${string}` | 'banner' | 'markdown' | 'html' | 'separator' | string;
|
|
6
|
+
type FormanSchemaFieldType = 'aiagent' | 'account' | 'hook' | 'device' | 'keychain' | 'datastore' | 'udt' | 'scenario' | 'array' | 'collection' | 'text' | 'number' | 'boolean' | 'checkbox' | 'date' | 'json' | 'buffer' | 'cert' | 'color' | 'email' | 'filename' | 'file' | 'filter' | 'folder' | 'hidden' | 'integer' | 'uinteger' | 'path' | 'pkey' | 'port' | 'select' | 'time' | 'timestamp' | 'timezone' | 'url' | 'uuid' | `account:${string}` | `hook:${string}` | `keychain:${string}` | `device:${string}` | 'banner' | 'markdown' | 'html' | 'separator' | string;
|
|
7
7
|
/**
|
|
8
8
|
* Validation configuration for Forman Schema fields
|
|
9
9
|
*/
|
|
@@ -36,7 +36,7 @@ type FormanSchemaField = {
|
|
|
36
36
|
/** Default value for the field */
|
|
37
37
|
default?: FormanSchemaValue;
|
|
38
38
|
/** Available options for fields which support them */
|
|
39
|
-
options?: FormanSchemaOption
|
|
39
|
+
options?: (FormanSchemaOption | FormanSchemaOptionGroup)[] | FormanSchemaDirectoryOption[] | FormanSchemaPathExtendedOptions | FormanSchemaExtendedOptions | string;
|
|
40
40
|
/** Help text or description for the field */
|
|
41
41
|
help?: string;
|
|
42
42
|
/** Sub-fields specification for collection or array types */
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JSONSchema7 } from 'json-schema';
|
|
|
3
3
|
/**
|
|
4
4
|
* Valid Forman Schema field types
|
|
5
5
|
*/
|
|
6
|
-
type FormanSchemaFieldType = 'aiagent' | 'account' | 'hook' | 'device' | 'keychain' | 'datastore' | 'udt' | 'scenario' | 'array' | 'collection' | 'text' | 'number' | 'boolean' | 'date' | 'json' | 'buffer' | 'cert' | 'color' | 'email' | 'filename' | 'file' | 'filter' | 'folder' | 'hidden' | 'integer' | 'uinteger' | 'path' | 'pkey' | 'port' | 'select' | 'time' | 'timestamp' | 'timezone' | 'url' | 'uuid' | `account:${string}` | `hook:${string}` | `keychain:${string}` | `device:${string}` | 'banner' | 'markdown' | 'html' | 'separator' | string;
|
|
6
|
+
type FormanSchemaFieldType = 'aiagent' | 'account' | 'hook' | 'device' | 'keychain' | 'datastore' | 'udt' | 'scenario' | 'array' | 'collection' | 'text' | 'number' | 'boolean' | 'checkbox' | 'date' | 'json' | 'buffer' | 'cert' | 'color' | 'email' | 'filename' | 'file' | 'filter' | 'folder' | 'hidden' | 'integer' | 'uinteger' | 'path' | 'pkey' | 'port' | 'select' | 'time' | 'timestamp' | 'timezone' | 'url' | 'uuid' | `account:${string}` | `hook:${string}` | `keychain:${string}` | `device:${string}` | 'banner' | 'markdown' | 'html' | 'separator' | string;
|
|
7
7
|
/**
|
|
8
8
|
* Validation configuration for Forman Schema fields
|
|
9
9
|
*/
|
|
@@ -36,7 +36,7 @@ type FormanSchemaField = {
|
|
|
36
36
|
/** Default value for the field */
|
|
37
37
|
default?: FormanSchemaValue;
|
|
38
38
|
/** Available options for fields which support them */
|
|
39
|
-
options?: FormanSchemaOption
|
|
39
|
+
options?: (FormanSchemaOption | FormanSchemaOptionGroup)[] | FormanSchemaDirectoryOption[] | FormanSchemaPathExtendedOptions | FormanSchemaExtendedOptions | string;
|
|
40
40
|
/** Help text or description for the field */
|
|
41
41
|
help?: string;
|
|
42
42
|
/** Sub-fields specification for collection or array types */
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,15 @@ function normalizeFormanFieldType(field) {
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
+
function findValueInSelectOptions(field, value, optionsAndGroups) {
|
|
64
|
+
if (!optionsAndGroups) return void 0;
|
|
65
|
+
if (field.grouped) {
|
|
66
|
+
const found2 = optionsAndGroups.flatMap((group) => "options" in group ? group.options : []).find((option) => option.value === value);
|
|
67
|
+
if (found2) return found2;
|
|
68
|
+
}
|
|
69
|
+
const found = optionsAndGroups.find((option) => "value" in option && option.value === value);
|
|
70
|
+
return found;
|
|
71
|
+
}
|
|
63
72
|
function buildRestoreStructure(items) {
|
|
64
73
|
const result = {};
|
|
65
74
|
for (const item of items) {
|
|
@@ -212,6 +221,7 @@ var FORMAN_TYPE_MAP = {
|
|
|
212
221
|
editor: "string",
|
|
213
222
|
number: "number",
|
|
214
223
|
boolean: "boolean",
|
|
224
|
+
checkbox: "boolean",
|
|
215
225
|
date: "string",
|
|
216
226
|
json: "string",
|
|
217
227
|
buffer: "string",
|
|
@@ -434,12 +444,15 @@ function handleSelectOrPathType(field, result, context) {
|
|
|
434
444
|
value: appendQueryString(optionsOrGroups, context.domain, context.tail)
|
|
435
445
|
});
|
|
436
446
|
} else {
|
|
437
|
-
const options = optionsOrGroups?.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
447
|
+
const options = optionsOrGroups?.flatMap((optionOrGroup) => {
|
|
448
|
+
if (isOptionGroup(optionOrGroup)) {
|
|
449
|
+
return optionOrGroup.options.map((option) => ({
|
|
450
|
+
...option,
|
|
451
|
+
label: `${optionOrGroup.label}: ${option.label || option.value}`
|
|
452
|
+
}));
|
|
453
|
+
}
|
|
454
|
+
return optionOrGroup;
|
|
455
|
+
});
|
|
443
456
|
if (options?.some((option) => {
|
|
444
457
|
if (isOptionGroup(option)) return option.options.some((option2) => option2.label || option2.nested);
|
|
445
458
|
return option.label || option.nested;
|
|
@@ -584,6 +597,7 @@ var FORMAN_TYPE_MAP2 = {
|
|
|
584
597
|
text: "string",
|
|
585
598
|
number: "number",
|
|
586
599
|
boolean: "boolean",
|
|
600
|
+
checkbox: "boolean",
|
|
587
601
|
date: "string",
|
|
588
602
|
json: "string",
|
|
589
603
|
buffer: "string",
|
|
@@ -1105,9 +1119,11 @@ async function handleSelectType(value, field, context) {
|
|
|
1105
1119
|
};
|
|
1106
1120
|
}
|
|
1107
1121
|
for (const singleValue of value) {
|
|
1108
|
-
const found =
|
|
1109
|
-
|
|
1110
|
-
|
|
1122
|
+
const found = findValueInSelectOptions(
|
|
1123
|
+
field,
|
|
1124
|
+
singleValue,
|
|
1125
|
+
optionsOrGroups
|
|
1126
|
+
);
|
|
1111
1127
|
if (!found) {
|
|
1112
1128
|
errors.push({
|
|
1113
1129
|
domain: context.domain,
|
|
@@ -1133,7 +1149,7 @@ async function handleSelectType(value, field, context) {
|
|
|
1133
1149
|
}
|
|
1134
1150
|
}
|
|
1135
1151
|
} else {
|
|
1136
|
-
const item = field
|
|
1152
|
+
const item = findValueInSelectOptions(field, value, optionsOrGroups);
|
|
1137
1153
|
if (!item) {
|
|
1138
1154
|
return {
|
|
1139
1155
|
valid: false,
|