"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const dayjs_1 = __importDefault(require("dayjs"));
const constants_1 = require("../constants");
const action = {
    title: 'Send user profiles',
    description: 'Send identify calls to Toplyne',
    defaultSubscription: 'type = "identify"',
    fields: {
        userId: {
            type: 'string',
            label: 'User ID',
            description: 'The ID of the user to send properties for. Required if anonymousId is not provided',
            required: false,
            default: { '@path': '$.userId' }
        },
        anonymousId: {
            type: 'string',
            label: 'Anonymous ID',
            description: 'The anonymous ID of the user to send properties for. Required if userId is not provided',
            required: false,
            default: { '@path': '$.anonymousId' }
        },
        creationTime: {
            type: 'datetime',
            label: 'Creation time',
            description: 'Toplyne calculates the creation time of the user using the timestamp of the first track or identify call',
            required: true,
            default: { '@path': '$.timestamp' }
        },
        userProperties: {
            type: 'object',
            label: 'User Properties',
            description: 'The properties of the user',
            required: false,
            default: { '@path': '$.traits' }
        }
    },
    perform: (request, data) => {
        return request(`${constants_1.baseUrl}/upload/users/profiles`, {
            json: {
                profiles: [
                    {
                        ...data.payload,
                        creationTime: (0, dayjs_1.default)(data.payload.creationTime).unix()
                    }
                ]
            }
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map