All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
zapier.model.mustache Maven / Gradle / Ivy
const utils = require('../utils/utils');
{{#imports}}{{{import}}}
{{/imports}}
{{#models}}
{{#model}}
{{#isEnum}}
module.exports = {
fields: (key) => (
{
label: `{{#description}}{{{.}}} - {{/description}}[${key.replaceAll('__', '.')}]`,
choices: [
{{#allowableValues}}
{{#values}}
'{{.}}',
{{/values}}
{{/allowableValues}}
],
}
)
}
{{/isEnum}}
{{^isEnum}}
module.exports = {
fields: (prefix = '', isInput = true, isArrayChild = false) => {
const {keyPrefix, labelPrefix} = utils.buildKeyAndLabel(prefix, isInput, isArrayChild)
return [
{{#vars}}
{{#isPrimitiveType}}
{
key: `${keyPrefix}{{baseName}}`,
label: `{{#description}}{{{.}}} - {{/description}}[${labelPrefix}{{baseName}}]`,
{{#isArray}}
list: true,
type: '{{#items}}{{baseType}}{{/items}}',
{{/isArray}}
{{^isArray}}
{{#isFreeFormObject}}
dict: true,
{{/isFreeFormObject}}
{{^isFreeFormObject}}
type: '{{baseType}}',
{{/isFreeFormObject}}
{{/isArray}}
{{#isEnum}}
choices: [
{{#_enum}}
'{{.}}',
{{/_enum}}
],
{{/isEnum}}
},
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isArray}}
{
key: `${keyPrefix}{{baseName}}`,{{#items}}{{^isEnumRef}}
label: `{{#description}}{{{.}}} - {{/description}}[${labelPrefix}{{baseName}}]`,
children: {{complexType}}.fields(`${keyPrefix}{{baseName}}${!isInput ? '[]' : ''}`, isInput, true), {{/isEnumRef}}{{#isEnumRef}}
list: true,
type: 'string',
...{{complexType}}.fields(`${keyPrefix}{{baseName}}`, isInput),{{/isEnumRef}}{{/items}}
},
{{/isArray}}
{{^isArray}}
{{^allowableValues}}
{{^isFreeFormObject}}
...{{complexType}}.fields(`${keyPrefix}{{baseName}}`, isInput),
{{/isFreeFormObject}}
{{/allowableValues}}
{{#allowableValues}}
{
key: `${keyPrefix}{{baseName}}`,
...{{complexType}}.fields(`${keyPrefix}{{baseName}}`, isInput),
},
{{/allowableValues}}
{{/isArray}}
{{/isPrimitiveType}}
{{/vars}}
]
},
mapping: (bundle, prefix = '') => {
const {keyPrefix} = utils.buildKeyAndLabel(prefix)
return {
{{#vars}}
'{{baseName}}': {{#isPrimitiveType}}bundle.inputData?.[`${keyPrefix}{{baseName}}`]{{/isPrimitiveType}}{{^isPrimitiveType}}{{^allowableValues}}{{^isArray}}utils.removeIfEmpty({{complexType}}.mapping(bundle, `${keyPrefix}{{baseName}}`)){{/isArray}}{{#isArray}}{{^isEnumRef}}utils.childMapping(bundle.inputData?.[`${keyPrefix}{{baseName}}`], `${keyPrefix}{{baseName}}`, {{complexType}}){{/isEnumRef}}{{#isEnumRef}}bundle.inputData?.[`${keyPrefix}{{baseName}}`]{{/isEnumRef}}{{/isArray}}{{/allowableValues}}{{#allowableValues}}bundle.inputData?.[`${keyPrefix}{{baseName}}`]{{/allowableValues}}{{/isPrimitiveType}},
{{/vars}}
}
},
}
{{/isEnum}}
{{/model}}
{{/models}}