"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const recombeeApiClient_1 = require("../recombeeApiClient");
const action = {
    title: 'Merge Users',
    description: 'Merges interactions (purchases, ratings, bookmarks, detail views, ...) of two different users under a single user ID.',
    defaultSubscription: 'type = "alias"',
    fields: {
        targetUserId: {
            label: 'Target User ID',
            description: 'The ID of the target user that will be **kept** after the merge.',
            type: 'string',
            required: true,
            default: { '@path': '$.userId' }
        },
        sourceUserId: {
            label: 'Source User ID',
            description: 'The ID of the source user that will be **deleted** after the merge.',
            type: 'string',
            required: true,
            default: { '@path': '$.previousId' }
        }
    },
    perform: async (request, data) => {
        const client = new recombeeApiClient_1.RecombeeApiClient(data.settings, request);
        await client.send(new recombeeApiClient_1.MergeUsers(data.payload.targetUserId, data.payload.sourceUserId));
    },
    performBatch: async (request, data) => {
        const client = new recombeeApiClient_1.RecombeeApiClient(data.settings, request);
        await client.send(new recombeeApiClient_1.Batch(data.payload.map((payload) => new recombeeApiClient_1.MergeUsers(payload.targetUserId, payload.sourceUserId))));
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map