@makehq/forman-schema 1.3.2 → 1.3.4
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 +12 -2
- package/dist/index.js +12 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -90,6 +90,7 @@ var FORMAN_TYPE_MAP = {
|
|
|
90
90
|
udt: "number",
|
|
91
91
|
array: "array",
|
|
92
92
|
collection: "object",
|
|
93
|
+
dynamicCollection: "object",
|
|
93
94
|
text: "string",
|
|
94
95
|
number: "number",
|
|
95
96
|
boolean: "boolean",
|
|
@@ -154,6 +155,7 @@ function toJSONSchemaInternal(field, context = createDefaultContext()) {
|
|
|
154
155
|
};
|
|
155
156
|
switch (normalizedField.type) {
|
|
156
157
|
case "collection":
|
|
158
|
+
case "dynamicCollection":
|
|
157
159
|
return handleCollectionType(normalizedField, result, context);
|
|
158
160
|
case "array":
|
|
159
161
|
return handleArrayType(normalizedField, result, context);
|
|
@@ -180,6 +182,7 @@ function handleCollectionType(field, result, context) {
|
|
|
180
182
|
return;
|
|
181
183
|
}
|
|
182
184
|
if (!subField.name) return;
|
|
185
|
+
if (result.properties && Object.hasOwn(result.properties, subField.name)) return;
|
|
183
186
|
if (subField.required) {
|
|
184
187
|
result.required.push(subField.name);
|
|
185
188
|
}
|
|
@@ -844,12 +847,19 @@ var JSON_PRIMITIVE_TYPE_MAP = {
|
|
|
844
847
|
function toFormanSchema(field) {
|
|
845
848
|
switch (field.type) {
|
|
846
849
|
case "object":
|
|
847
|
-
|
|
850
|
+
if (!field.properties || !Object.entries(field.properties).length) {
|
|
851
|
+
return {
|
|
852
|
+
type: "dynamicCollection",
|
|
853
|
+
label: noEmpty(field.title),
|
|
854
|
+
help: noEmpty(field.description)
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
const spec = Object.entries(field.properties).filter(([name, property]) => !!property).map(([name, property]) => {
|
|
848
858
|
const subField = toFormanSchema(property);
|
|
849
859
|
subField.name = name;
|
|
850
860
|
subField.required = field.required?.includes(name) || false;
|
|
851
861
|
return subField;
|
|
852
|
-
})
|
|
862
|
+
});
|
|
853
863
|
return {
|
|
854
864
|
type: "collection",
|
|
855
865
|
label: noEmpty(field.title),
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,7 @@ var FORMAN_TYPE_MAP = {
|
|
|
61
61
|
udt: "number",
|
|
62
62
|
array: "array",
|
|
63
63
|
collection: "object",
|
|
64
|
+
dynamicCollection: "object",
|
|
64
65
|
text: "string",
|
|
65
66
|
number: "number",
|
|
66
67
|
boolean: "boolean",
|
|
@@ -125,6 +126,7 @@ function toJSONSchemaInternal(field, context = createDefaultContext()) {
|
|
|
125
126
|
};
|
|
126
127
|
switch (normalizedField.type) {
|
|
127
128
|
case "collection":
|
|
129
|
+
case "dynamicCollection":
|
|
128
130
|
return handleCollectionType(normalizedField, result, context);
|
|
129
131
|
case "array":
|
|
130
132
|
return handleArrayType(normalizedField, result, context);
|
|
@@ -151,6 +153,7 @@ function handleCollectionType(field, result, context) {
|
|
|
151
153
|
return;
|
|
152
154
|
}
|
|
153
155
|
if (!subField.name) return;
|
|
156
|
+
if (result.properties && Object.hasOwn(result.properties, subField.name)) return;
|
|
154
157
|
if (subField.required) {
|
|
155
158
|
result.required.push(subField.name);
|
|
156
159
|
}
|
|
@@ -815,12 +818,19 @@ var JSON_PRIMITIVE_TYPE_MAP = {
|
|
|
815
818
|
function toFormanSchema(field) {
|
|
816
819
|
switch (field.type) {
|
|
817
820
|
case "object":
|
|
818
|
-
|
|
821
|
+
if (!field.properties || !Object.entries(field.properties).length) {
|
|
822
|
+
return {
|
|
823
|
+
type: "dynamicCollection",
|
|
824
|
+
label: noEmpty(field.title),
|
|
825
|
+
help: noEmpty(field.description)
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
const spec = Object.entries(field.properties).filter(([name, property]) => !!property).map(([name, property]) => {
|
|
819
829
|
const subField = toFormanSchema(property);
|
|
820
830
|
subField.name = name;
|
|
821
831
|
subField.required = field.required?.includes(name) || false;
|
|
822
832
|
return subField;
|
|
823
|
-
})
|
|
833
|
+
});
|
|
824
834
|
return {
|
|
825
835
|
type: "collection",
|
|
826
836
|
label: noEmpty(field.title),
|