2114 timebox make sure the zapier integrations supports custom objects (#3091)

* Fix build command

* Add hidden trigger to fetch object names

* Remove useless actions

* Rename createObject to createRecord
This commit is contained in:
martmull
2023-12-20 18:41:30 +01:00
committed by GitHub
parent 984fc76b94
commit b1841d0e2f
18 changed files with 273 additions and 292 deletions

View File

@ -0,0 +1,54 @@
import { labelling } from "../utils/labelling";
type Infos = {
properties: {
[field: string]: {
type: string;
properties?: { [field: string]: { type: string } }
items?: { [$ref: string]: string }
}
},
example: object,
required: string[]
}
export const computeInputFields = (infos: Infos): object[] => {
const result = []
for (const fieldName of Object.keys(infos.properties)) {
switch (infos.properties[fieldName].type) {
case 'array':
break;
case 'object':
if (!infos.properties[fieldName].properties) {
break;
}
for (const subFieldName of Object.keys(infos.properties[fieldName].properties || {})) {
const field = {
key: `${fieldName}__${subFieldName}`,
label: `${labelling(fieldName)}: ${labelling(subFieldName)}`,
type: infos.properties[fieldName].properties?.[subFieldName].type,
required: false,
}
if (infos.required?.includes(fieldName)) {
field.required = true
}
result.push(field)
}
break;
default:
const field = {
key: fieldName,
label: labelling(fieldName),
type: infos.properties[fieldName].type,
required: false,
}
if (infos.required?.includes(fieldName)) {
field.required = true
}
result.push(field)
}
}
return result
}