"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const insider_helpers_1 = require("../insider-helpers");
const action = {
    title: 'Insider Audiences',
    description: 'Sync Audiences and Computed Traits from Segment to Insider InOne',
    defaultSubscription: 'type = "track" or type = "identify"',
    fields: {
        custom_audience_name: {
            label: 'Custom Audience Name',
            description: 'Name of custom audience list to which emails should added/removed',
            type: 'string',
            required: true,
            default: {
                '@path': '$.context.personas.computation_key'
            }
        },
        segment_computation_action: {
            label: 'Segment Computation Action',
            description: "Segment computation class used to determine if action is an 'Engage-Audience'",
            type: 'string',
            required: true,
            default: {
                '@path': '$.context.personas.computation_class'
            }
        },
        append_arrays: {
            label: 'Append Array Fields',
            type: 'boolean',
            description: 'If enabled, new data for array fields will be appended to the existing values in Insider.',
            default: false
        },
        email: {
            label: 'Email',
            description: "User's email address for including/excluding from custom audience",
            type: 'string',
            format: 'email',
            required: false,
            default: {
                '@if': {
                    exists: { '@path': '$.context.traits.email' },
                    then: { '@path': '$.context.traits.email' },
                    else: { '@path': '$.traits.email' }
                }
            }
        },
        phone: {
            label: 'Phone',
            description: "User's phone number for including/excluding from custom audience",
            type: 'string',
            format: 'text',
            required: false,
            default: {
                '@if': {
                    exists: { '@path': '$.context.traits.phone' },
                    then: { '@path': '$.context.traits.phone' },
                    else: { '@path': '$.traits.phone' }
                }
            }
        },
        traits_or_props: {
            label: 'traits or properties object',
            description: 'Object which will be computed differently for track and identify events',
            type: 'object',
            required: true,
            default: {
                '@if': {
                    exists: { '@path': '$.properties' },
                    then: { '@path': '$.properties' },
                    else: { '@path': '$.traits' }
                }
            }
        },
        user_id: {
            label: 'User ID',
            description: 'Known user identifier for the user',
            type: 'string',
            required: false,
            default: {
                '@path': '$.userId'
            }
        },
        anonymous_id: {
            label: 'Anonymous ID',
            description: 'Anonymous user identifier for the user',
            type: 'string',
            required: false,
            default: {
                '@path': '$.anonymousId'
            }
        },
        event_type: {
            label: 'Event Type',
            description: 'Type of event',
            type: 'string',
            required: true,
            default: {
                '@path': '$.type'
            }
        },
        event_name: {
            label: 'Event Name',
            description: 'Name of event',
            type: 'string',
            required: false,
            default: {
                '@if': {
                    exists: { '@path': '$.event' },
                    then: { '@path': '$.event' },
                    else: { '@path': '$.name' }
                }
            }
        },
        timestamp: {
            label: 'Timestamp',
            description: 'Timestamp of event',
            type: 'string',
            required: true,
            default: {
                '@path': '$.timestamp'
            }
        }
    },
    perform: (request, { payload }) => {
        return (0, insider_helpers_1.processPayload)(request, [payload]);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map