swoop-common 2.2.108 → 2.2.110
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.
|
@@ -25,7 +25,6 @@ export const ComponentPickerProvider = ({ children }) => {
|
|
|
25
25
|
setOpen(true);
|
|
26
26
|
return new Promise((res, rej) => {
|
|
27
27
|
setParentIds(parentIds);
|
|
28
|
-
console.log("GOT DA PARENTS", parentIds);
|
|
29
28
|
// In case of old refs being called (so i dont need to explicitly remove them)
|
|
30
29
|
let done = false;
|
|
31
30
|
changeProp.current = (value) => {
|
|
@@ -2,7 +2,6 @@ import { getType } from "../../registry/fields";
|
|
|
2
2
|
import { generateFieldId } from "../util";
|
|
3
3
|
import "../../prebuild/generated/import_generated";
|
|
4
4
|
export const generateJsonSchema = (formSchema, stage, onlyEditableFields) => {
|
|
5
|
-
// Lazy try catch rn
|
|
6
5
|
try {
|
|
7
6
|
const built = {
|
|
8
7
|
type: "object",
|
|
@@ -31,7 +30,6 @@ export const generateJsonSchema = (formSchema, stage, onlyEditableFields) => {
|
|
|
31
30
|
};
|
|
32
31
|
const defaultConverter = (field, stage, omitTitle, isChild) => {
|
|
33
32
|
var _a, _b, _c, _d;
|
|
34
|
-
// Default field type
|
|
35
33
|
field.fieldType = (_a = field.fieldType) !== null && _a !== void 0 ? _a : "string";
|
|
36
34
|
let schema = getType(field.fieldType);
|
|
37
35
|
if (!schema)
|
|
@@ -40,16 +38,13 @@ const defaultConverter = (field, stage, omitTitle, isChild) => {
|
|
|
40
38
|
"\nFull object: " +
|
|
41
39
|
JSON.stringify(field, null, 2));
|
|
42
40
|
const requiredFields = [];
|
|
43
|
-
// Specific for array
|
|
44
41
|
let arrayItems = field.fieldType === "array"
|
|
45
42
|
? defaultConverter((_b = field.arrayOptions) === null || _b === void 0 ? void 0 : _b.itemDefinition, stage, true, true)
|
|
46
43
|
: undefined;
|
|
47
|
-
// Obj childs
|
|
48
44
|
const properties = {};
|
|
49
45
|
for (const child of (_d = (_c = field.objectOptions) === null || _c === void 0 ? void 0 : _c.properties) !== null && _d !== void 0 ? _d : []) {
|
|
50
46
|
const fieldId = generateFieldId(child.name);
|
|
51
47
|
properties[fieldId] = defaultConverter(child, stage, false, true);
|
|
52
|
-
console.log("FILD TYPE", child.fieldType, "REWQUIRED", child.required);
|
|
53
48
|
if (child.required && child.fieldType != "boolean")
|
|
54
49
|
requiredFields.push(fieldId);
|
|
55
50
|
}
|
|
@@ -73,11 +68,20 @@ const defaultConverter = (field, stage, omitTitle, isChild) => {
|
|
|
73
68
|
return enumOptions;
|
|
74
69
|
})()
|
|
75
70
|
: undefined;
|
|
76
|
-
// Component (probably should change this)
|
|
77
71
|
let templates = field.fieldType === "component" && field.componentOptions
|
|
78
|
-
? { "x-templateIds": field.componentOptions["
|
|
72
|
+
? { "x-templateIds": field.componentOptions["templateIds"] }
|
|
73
|
+
: {};
|
|
74
|
+
const speciallyHandledKeys = new Set([
|
|
75
|
+
"enumValues",
|
|
76
|
+
"itemDefinition",
|
|
77
|
+
"properties",
|
|
78
|
+
"templateIds",
|
|
79
|
+
]);
|
|
80
|
+
const fieldTypeOptions = field[`${field.fieldType}Options`];
|
|
81
|
+
const directOptions = fieldTypeOptions
|
|
82
|
+
? Object.fromEntries(Object.entries(fieldTypeOptions).filter(([key]) => !speciallyHandledKeys.has(key)))
|
|
79
83
|
: {};
|
|
80
84
|
let title = omitTitle ? undefined : field.name;
|
|
81
85
|
let isReadonly = !isChild && !field.editableIn.map(Number).includes(stage);
|
|
82
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (isReadonly && { readOnly: true })), { title, type: schema.schema.type, "x-type": schema.schema["x-type"] }), templates), (schema.schema.type === "object" && { properties })), (field.fieldType === "object" && { required: requiredFields })), (enumOpts && { enum: enumOpts })), (stagedEnumOpts && { items: { enum: stagedEnumOpts, type: "string" } })), (arrayItems && { items: arrayItems })), (field.fieldType === "object" && { properties })),
|
|
86
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (isReadonly && { readOnly: true })), { title, type: schema.schema.type, "x-type": schema.schema["x-type"] }), templates), (schema.schema.type === "object" && { properties })), (field.fieldType === "object" && { required: requiredFields })), (enumOpts && { enum: enumOpts })), (stagedEnumOpts && { items: { enum: stagedEnumOpts, type: "string" } })), (arrayItems && { items: arrayItems })), (field.fieldType === "object" && { properties })), directOptions);
|
|
83
87
|
};
|
package/dist/test.js
CHANGED
|
@@ -1,85 +1,7 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
name: "Journey",
|
|
9
|
-
fieldType: "component",
|
|
10
|
-
existsFrom: "0",
|
|
11
|
-
editableIn: ["0"],
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
required: false,
|
|
15
|
-
name: "Type",
|
|
16
|
-
fieldType: "string",
|
|
17
|
-
existsFrom: "0",
|
|
18
|
-
editableIn: ["0", "1"],
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
required: true,
|
|
22
|
-
name: "Driver",
|
|
23
|
-
fieldType: "boolean",
|
|
24
|
-
existsFrom: "0",
|
|
25
|
-
editableIn: ["0", "1"],
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
required: true,
|
|
29
|
-
name: "Guided",
|
|
30
|
-
fieldType: "boolean",
|
|
31
|
-
existsFrom: "0",
|
|
32
|
-
editableIn: ["0", "1"],
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
required: false,
|
|
36
|
-
name: "Operator",
|
|
37
|
-
fieldType: "string",
|
|
38
|
-
existsFrom: "0",
|
|
39
|
-
editableIn: ["0", "1"],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
required: false,
|
|
43
|
-
name: "Notes",
|
|
44
|
-
fieldType: "object",
|
|
45
|
-
existsFrom: "0",
|
|
46
|
-
editableIn: ["0", "1"],
|
|
47
|
-
objectOptions: {
|
|
48
|
-
properties: [
|
|
49
|
-
{
|
|
50
|
-
required: false,
|
|
51
|
-
name: "Pickup",
|
|
52
|
-
fieldType: "string",
|
|
53
|
-
editableIn: ["0", "1"],
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
required: false,
|
|
57
|
-
name: "Schedule",
|
|
58
|
-
fieldType: "string",
|
|
59
|
-
existsFrom: "0",
|
|
60
|
-
editableIn: ["0", "1"],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
required: false,
|
|
67
|
-
name: "Departure Time",
|
|
68
|
-
fieldType: "string",
|
|
69
|
-
existsFrom: "0",
|
|
70
|
-
editableIn: ["1", "0"],
|
|
71
|
-
stringOptions: { format: "time" },
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
required: false,
|
|
75
|
-
name: "Arrival Time",
|
|
76
|
-
fieldType: "string",
|
|
77
|
-
existsFrom: "0",
|
|
78
|
-
editableIn: ["0", "1"],
|
|
79
|
-
stringOptions: { format: "time" },
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
Stage.Inst
|
|
83
|
-
)
|
|
84
|
-
);
|
|
85
|
-
*/
|
|
2
|
+
// console.log(
|
|
3
|
+
// JSON.stringify(generateJsonSchema(
|
|
4
|
+
// [{ "required": true, "name": "Name", "fieldType": "string", "editableIn": ["1"], "existsFrom": "1" }, { "required": true, "name": "Date", "fieldType": "string", "editableIn": ["1"], "existsFrom": "1", "stringOptions": { "format": "date-time" } }, { "required": true, "name": "Departure Airport", "fieldType": "component", "existsFrom": "1", "editableIn": ["1"], "componentOptions": { "templateIds": ["template_0c105b25350647b096753b4f863ab06c"] } }, { "required": true, "name": "Arrival Airport", "fieldType": "component", "existsFrom": "1", "editableIn": ["1"], "componentOptions": { "templateIds": ["template_0c105b25350647b096753b4f863ab06c"] } }, { "required": false, "name": "Welcome Note", "fieldType": "string", "existsFrom": "1", "editableIn": ["1"], "stringOptions": { "maxLength": 512 } }],
|
|
5
|
+
// Stage.Inst
|
|
6
|
+
// ))
|
|
7
|
+
// );
|