"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.documentTypeUpdated = void 0;
const zod_1 = require("zod");
const dataPoints = {
    webhookData: {
        key: 'webhookData',
        valueType: 'json',
    },
    documentId: {
        key: 'documentId',
        valueType: 'string',
    },
    workspaceId: {
        key: 'workspaceId',
        valueType: 'string',
    },
    typeName: {
        key: 'typeName',
        valueType: 'string',
    },
    typeId: {
        key: 'typeId',
        valueType: 'string',
    },
    userEmail: {
        key: 'userEmail',
        valueType: 'string',
    },
};
const TypeSchema = zod_1.z.object({
    id: zod_1.z.string(),
    name: zod_1.z.string(),
});
const UserSchema = zod_1.z.object({
    id: zod_1.z.string(),
    email: zod_1.z.string(),
});
const DocumentTypeUpdatedPayloadSchema = zod_1.z.object({
    accountId: zod_1.z.string(),
    workspaceId: zod_1.z.string(),
    documentId: zod_1.z.string(),
    user: UserSchema,
    type: TypeSchema,
});
exports.documentTypeUpdated = {
    key: 'documentTypeUpdated',
    description: 'Triggered when a document type is updated in Documo.',
    dataPoints,
    onEvent: async ({ payload: { payload }, onSuccess }) => {
        const parsed = DocumentTypeUpdatedPayloadSchema.parse(payload);
        await onSuccess({
            data_points: {
                webhookData: JSON.stringify(payload),
                documentId: parsed.documentId,
                workspaceId: parsed.workspaceId,
                typeName: parsed.type.name,
                typeId: parsed.type.id,
                userEmail: parsed.user.email,
            },
        });
    },
};
//# sourceMappingURL=documentTypeUpdated.js.map