2020-04-02 10:21:03 +02:00
|
|
|
function selectKitContent(content) {
|
2020-02-02 11:42:05 +01:00
|
|
|
return content.map(i => ({id: i, name: i}))
|
|
|
|
}
|
|
|
|
|
2020-03-21 18:30:11 +01:00
|
|
|
function generateName(id) {
|
2020-04-03 00:47:32 +02:00
|
|
|
return id ? sentenceCase(id) : '';
|
2020-04-02 10:21:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function generateId(name) {
|
2020-04-03 00:47:32 +02:00
|
|
|
return name ? snakeCase(name) : '';
|
2020-04-02 10:21:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function sentenceCase(string) {
|
|
|
|
return string.replace(/[_\-]+/g, ' ')
|
2020-03-21 18:30:11 +01:00
|
|
|
.toLowerCase()
|
|
|
|
.replace(/(^\w|\b\w)/g, (m) => m.toUpperCase())
|
|
|
|
}
|
|
|
|
|
2020-04-02 10:21:03 +02:00
|
|
|
function snakeCase(string) {
|
|
|
|
return string.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
|
|
|
.map(x => x.toLowerCase())
|
|
|
|
.join('_')
|
|
|
|
}
|
|
|
|
|
|
|
|
function camelCase(string) {
|
|
|
|
return string.replace(/([-_][a-z])/ig, ($1) => {
|
|
|
|
return $1.toUpperCase()
|
|
|
|
.replace('-', '')
|
|
|
|
.replace('_', '');
|
|
|
|
});
|
2020-04-01 07:03:26 +02:00
|
|
|
}
|
|
|
|
|
2020-03-21 18:30:11 +01:00
|
|
|
const profileFields = [
|
|
|
|
'name',
|
2020-03-30 08:16:03 +02:00
|
|
|
'username',
|
|
|
|
'email',
|
2020-03-21 18:30:11 +01:00
|
|
|
'date_of_birth',
|
|
|
|
'title',
|
|
|
|
'locale',
|
|
|
|
'location',
|
|
|
|
'website',
|
|
|
|
'bio_raw',
|
2020-03-30 08:16:03 +02:00
|
|
|
'trust_level'
|
2020-03-21 18:30:11 +01:00
|
|
|
];
|
|
|
|
|
2020-04-01 12:58:30 +02:00
|
|
|
const wizardProperties = [
|
|
|
|
'id',
|
|
|
|
'name',
|
|
|
|
'background',
|
|
|
|
'save_submissions',
|
|
|
|
'multiple_submissions',
|
|
|
|
'after_signup',
|
|
|
|
'after_time',
|
|
|
|
'after_time_scheduled',
|
|
|
|
'required',
|
|
|
|
'prompt_completion',
|
|
|
|
'restart_on_revisit',
|
|
|
|
'theme_id',
|
|
|
|
'permitted'
|
|
|
|
];
|
|
|
|
|
|
|
|
const stepProperties = [
|
|
|
|
'id',
|
|
|
|
'title',
|
|
|
|
'key',
|
|
|
|
'banner',
|
|
|
|
'raw_description',
|
|
|
|
'required_data',
|
|
|
|
'required_data_message',
|
|
|
|
'permitted_params'
|
|
|
|
]
|
|
|
|
|
|
|
|
const fieldProperties = [
|
|
|
|
'id',
|
|
|
|
'label',
|
|
|
|
'key',
|
|
|
|
'image',
|
|
|
|
'description',
|
|
|
|
'type',
|
|
|
|
'required',
|
|
|
|
'min_length',
|
|
|
|
'file_types',
|
|
|
|
'property',
|
|
|
|
'limit',
|
|
|
|
'prefill',
|
|
|
|
'content',
|
|
|
|
]
|
|
|
|
|
|
|
|
const actionProperties = [
|
|
|
|
'id',
|
|
|
|
'type',
|
|
|
|
'title',
|
|
|
|
'post',
|
2020-04-02 07:21:57 +02:00
|
|
|
'post_builder',
|
2020-04-01 12:58:30 +02:00
|
|
|
'post_template',
|
|
|
|
'category',
|
|
|
|
'tags',
|
|
|
|
'skip_redirect',
|
|
|
|
'custom_fields',
|
|
|
|
'required',
|
|
|
|
'recipient',
|
|
|
|
'profile_updates',
|
|
|
|
'group',
|
|
|
|
'url',
|
|
|
|
'code',
|
|
|
|
'api',
|
|
|
|
'api_endpoint',
|
|
|
|
'api_body'
|
|
|
|
]
|
|
|
|
|
|
|
|
const properties = {
|
|
|
|
wizard: wizardProperties,
|
|
|
|
step: stepProperties,
|
|
|
|
field: fieldProperties,
|
|
|
|
action: actionProperties
|
|
|
|
}
|
|
|
|
|
2020-04-02 07:21:57 +02:00
|
|
|
const mappedProperties = {
|
|
|
|
wizard: [
|
|
|
|
'permitted'
|
|
|
|
],
|
|
|
|
step: [
|
|
|
|
'required_data',
|
|
|
|
'permitted_params'
|
|
|
|
],
|
|
|
|
field: [
|
|
|
|
'choices',
|
|
|
|
'prefill',
|
|
|
|
'content'
|
|
|
|
],
|
|
|
|
action: [
|
|
|
|
'title',
|
|
|
|
'category',
|
|
|
|
'tags',
|
|
|
|
'custom_fields',
|
|
|
|
'required',
|
|
|
|
'recipient',
|
|
|
|
'profile_updates',
|
|
|
|
'group'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2020-04-02 11:29:22 +02:00
|
|
|
const advancedProperties = {
|
|
|
|
step: [
|
|
|
|
'required_data',
|
|
|
|
'permitted_params'
|
|
|
|
],
|
|
|
|
field: [
|
|
|
|
'property',
|
|
|
|
'prefill',
|
|
|
|
'content'
|
|
|
|
],
|
|
|
|
action: [
|
|
|
|
'code',
|
|
|
|
'custom_fields',
|
|
|
|
'skip_redirect',
|
|
|
|
'required'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2020-03-21 18:30:11 +01:00
|
|
|
const actionTypes = [
|
|
|
|
'create_topic',
|
|
|
|
'update_profile',
|
|
|
|
'create_topic',
|
|
|
|
'update_profile',
|
|
|
|
'send_message',
|
|
|
|
'send_to_api',
|
|
|
|
'add_to_group',
|
|
|
|
'route_to',
|
|
|
|
'open_composer'
|
|
|
|
];
|
|
|
|
|
|
|
|
export {
|
2020-04-02 10:21:03 +02:00
|
|
|
selectKitContent,
|
2020-03-21 18:30:11 +01:00
|
|
|
generateName,
|
2020-04-01 12:58:30 +02:00
|
|
|
generateId,
|
2020-04-02 10:21:03 +02:00
|
|
|
camelCase,
|
|
|
|
snakeCase,
|
2020-04-01 12:58:30 +02:00
|
|
|
properties,
|
|
|
|
wizardProperties,
|
2020-04-02 07:21:57 +02:00
|
|
|
mappedProperties,
|
2020-04-01 12:58:30 +02:00
|
|
|
profileFields,
|
2020-04-02 11:29:22 +02:00
|
|
|
advancedProperties,
|
2020-04-01 12:58:30 +02:00
|
|
|
actionTypes
|
2020-03-21 18:30:11 +01:00
|
|
|
};
|