@makehq/forman-schema 1.12.1 → 1.13.0

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 CHANGED
@@ -93,13 +93,20 @@ function normalizeFormanFieldType(field) {
93
93
  }
94
94
  };
95
95
  }
96
+ function valuesMatch(a, b) {
97
+ if (a === b) return true;
98
+ if (isObject(a) && isObject(b)) return JSON.stringify(a) === JSON.stringify(b);
99
+ return false;
100
+ }
96
101
  function findValueInSelectOptions(field, value, optionsAndGroups) {
97
102
  if (!optionsAndGroups) return void 0;
103
+ const valueKey = isObject(field.options) && field.options.value ? field.options.value : "value";
104
+ const matches = (option) => valuesMatch(option[valueKey], value);
98
105
  if (field.grouped) {
99
- const found2 = optionsAndGroups.flatMap((group) => "options" in group ? group.options : []).find((option) => option.value === value);
106
+ const found2 = optionsAndGroups.flatMap((group) => "options" in group ? group.options : []).find(matches);
100
107
  if (found2) return found2;
101
108
  }
102
- const found = optionsAndGroups.find((option) => "value" in option && option.value === value);
109
+ const found = optionsAndGroups.find((option) => valueKey in option && matches(option));
103
110
  return found;
104
111
  }
105
112
  function pathToString(path) {
@@ -569,6 +576,8 @@ var FORMAN_TYPE_MAP = {
569
576
  path: "string",
570
577
  pkey: "string",
571
578
  port: "number",
579
+ list: "string",
580
+ radio: "string",
572
581
  select: "string",
573
582
  udttype: "string",
574
583
  udtspec: "array",
@@ -659,6 +668,8 @@ function toJSONSchemaInternal(field, context) {
659
668
  return handleCollectionType(normalizedField, result, context);
660
669
  case "array":
661
670
  return handleArrayType(normalizedField, result, context);
671
+ case "list":
672
+ case "radio":
662
673
  case "select":
663
674
  case "account":
664
675
  case "hook":
@@ -873,6 +884,32 @@ function handleSelectOrPathType(field, result, context) {
873
884
  writable: true,
874
885
  value: appendQueryString(optionsOrGroups, context.domain, context.tail)
875
886
  });
887
+ const xFetchOptions = {};
888
+ if (isObject(field.options)) {
889
+ for (const transferKey of ["label", "value"]) {
890
+ const transferValue = field.options[transferKey];
891
+ if (transferValue) xFetchOptions[transferKey] = transferValue;
892
+ }
893
+ }
894
+ if (![
895
+ // Reference Types are distinguished by the Loader Tool Name directly
896
+ ...FORMAN_REFERENCE_TYPES,
897
+ // Select is default
898
+ "select",
899
+ // File and Folder are distinguished by the x-path metadata, so we don't need to append it here
900
+ "file",
901
+ "folder"
902
+ ].includes(field.type)) {
903
+ xFetchOptions["type"] = field.type;
904
+ }
905
+ if (Object.keys(xFetchOptions).length) {
906
+ Object.defineProperty(result, "x-fetch-options", {
907
+ configurable: true,
908
+ enumerable: true,
909
+ writable: true,
910
+ value: xFetchOptions
911
+ });
912
+ }
876
913
  } else {
877
914
  let options = optionsOrGroups?.flatMap((optionOrGroup) => {
878
915
  if (isOptionGroup(optionOrGroup)) {
@@ -1141,6 +1178,8 @@ var FORMAN_TYPE_MAP2 = {
1141
1178
  path: "string",
1142
1179
  pkey: "string",
1143
1180
  port: "number",
1181
+ list: void 0,
1182
+ radio: void 0,
1144
1183
  select: void 0,
1145
1184
  udttype: "string",
1146
1185
  udtspec: "array",
@@ -1352,6 +1391,8 @@ async function validateFormanValue(value, field, context) {
1352
1391
  return handleCollectionType2(value, normalizedField, context);
1353
1392
  case "array":
1354
1393
  return handleArrayType2(value, normalizedField, context);
1394
+ case "list":
1395
+ case "radio":
1355
1396
  case "select":
1356
1397
  case "account":
1357
1398
  case "hook":
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' | '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;
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' | 'list' | 'radio' | '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
  */
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' | '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;
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' | 'list' | 'radio' | '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
  */
package/dist/index.js CHANGED
@@ -64,13 +64,20 @@ function normalizeFormanFieldType(field) {
64
64
  }
65
65
  };
66
66
  }
67
+ function valuesMatch(a, b) {
68
+ if (a === b) return true;
69
+ if (isObject(a) && isObject(b)) return JSON.stringify(a) === JSON.stringify(b);
70
+ return false;
71
+ }
67
72
  function findValueInSelectOptions(field, value, optionsAndGroups) {
68
73
  if (!optionsAndGroups) return void 0;
74
+ const valueKey = isObject(field.options) && field.options.value ? field.options.value : "value";
75
+ const matches = (option) => valuesMatch(option[valueKey], value);
69
76
  if (field.grouped) {
70
- const found2 = optionsAndGroups.flatMap((group) => "options" in group ? group.options : []).find((option) => option.value === value);
77
+ const found2 = optionsAndGroups.flatMap((group) => "options" in group ? group.options : []).find(matches);
71
78
  if (found2) return found2;
72
79
  }
73
- const found = optionsAndGroups.find((option) => "value" in option && option.value === value);
80
+ const found = optionsAndGroups.find((option) => valueKey in option && matches(option));
74
81
  return found;
75
82
  }
76
83
  function pathToString(path) {
@@ -540,6 +547,8 @@ var FORMAN_TYPE_MAP = {
540
547
  path: "string",
541
548
  pkey: "string",
542
549
  port: "number",
550
+ list: "string",
551
+ radio: "string",
543
552
  select: "string",
544
553
  udttype: "string",
545
554
  udtspec: "array",
@@ -630,6 +639,8 @@ function toJSONSchemaInternal(field, context) {
630
639
  return handleCollectionType(normalizedField, result, context);
631
640
  case "array":
632
641
  return handleArrayType(normalizedField, result, context);
642
+ case "list":
643
+ case "radio":
633
644
  case "select":
634
645
  case "account":
635
646
  case "hook":
@@ -844,6 +855,32 @@ function handleSelectOrPathType(field, result, context) {
844
855
  writable: true,
845
856
  value: appendQueryString(optionsOrGroups, context.domain, context.tail)
846
857
  });
858
+ const xFetchOptions = {};
859
+ if (isObject(field.options)) {
860
+ for (const transferKey of ["label", "value"]) {
861
+ const transferValue = field.options[transferKey];
862
+ if (transferValue) xFetchOptions[transferKey] = transferValue;
863
+ }
864
+ }
865
+ if (![
866
+ // Reference Types are distinguished by the Loader Tool Name directly
867
+ ...FORMAN_REFERENCE_TYPES,
868
+ // Select is default
869
+ "select",
870
+ // File and Folder are distinguished by the x-path metadata, so we don't need to append it here
871
+ "file",
872
+ "folder"
873
+ ].includes(field.type)) {
874
+ xFetchOptions["type"] = field.type;
875
+ }
876
+ if (Object.keys(xFetchOptions).length) {
877
+ Object.defineProperty(result, "x-fetch-options", {
878
+ configurable: true,
879
+ enumerable: true,
880
+ writable: true,
881
+ value: xFetchOptions
882
+ });
883
+ }
847
884
  } else {
848
885
  let options = optionsOrGroups?.flatMap((optionOrGroup) => {
849
886
  if (isOptionGroup(optionOrGroup)) {
@@ -1112,6 +1149,8 @@ var FORMAN_TYPE_MAP2 = {
1112
1149
  path: "string",
1113
1150
  pkey: "string",
1114
1151
  port: "number",
1152
+ list: void 0,
1153
+ radio: void 0,
1115
1154
  select: void 0,
1116
1155
  udttype: "string",
1117
1156
  udtspec: "array",
@@ -1323,6 +1362,8 @@ async function validateFormanValue(value, field, context) {
1323
1362
  return handleCollectionType2(value, normalizedField, context);
1324
1363
  case "array":
1325
1364
  return handleArrayType2(value, normalizedField, context);
1365
+ case "list":
1366
+ case "radio":
1326
1367
  case "select":
1327
1368
  case "account":
1328
1369
  case "hook":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makehq/forman-schema",
3
- "version": "1.12.1",
3
+ "version": "1.13.0",
4
4
  "description": "Forman Schema Tools",
5
5
  "license": "MIT",
6
6
  "author": "Make",