"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.eventSchema = eventSchema;
function eventSchema(payload) {
    const { event_name, properties } = payload;
    const props = {};
    if (properties) {
        Object.entries(properties).forEach(([property, value]) => {
            if (value !== null) {
                props[property] = {
                    type: typeof value,
                    stringFormat: typeof value === 'string' ? stringFormat(value) : undefined
                };
            }
        });
    }
    return { name: event_name, primaryObject: payload.record_details.object_type, properties: props };
}
function stringFormat(str) {
    const isoDateTimeRegex = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])(?:([ T])(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;
    const dateOnlyRegex = /^\d{4}-\d{2}-\d{2}$/;
    if (isoDateTimeRegex.test(str)) {
        return dateOnlyRegex.test(str) ? 'date' : 'datetime';
    }
    else {
        return 'string';
    }
}
//# sourceMappingURL=schema-functions.js.map