// engine/event-schema-validator/version-utils.ts — Version bumping and schema building (SPEC-031)
/**
 * Generate a dual-version emission strategy for breaking schema changes.
 * Returns an EventVersion record with dualEmissionEndAt set 28 days from now.
 */
export function generateDualVersionStrategy(_oldVersion, newVersion, changeDescription, removedFields, changedFields) {
    const now = new Date();
    const endDate = new Date(now.getTime() + 28 * 24 * 60 * 60 * 1000);
    return {
        version: newVersion,
        changeKind: 'breaking',
        changeDescription,
        removedFields,
        changedFields,
        dualEmissionEndAt: endDate.toISOString(),
    };
}
/**
 * Bump a semver string according to the change kind.
 * - breaking → major bump (minor and patch reset to 0)
 * - additive → minor bump (patch reset to 0)
 * - deprecation → patch bump
 */
export function bumpVersion(current, kind) {
    const parts = current.split('.').map(Number);
    /* v8 ignore next 3 */
    const major = parts[0] ?? 0;
    const minor = parts[1] ?? 0;
    const patch = parts[2] ?? 0;
    switch (kind) {
        case 'breaking':
            return `${major + 1}.0.0`;
        case 'additive':
            return `${major}.${minor + 1}.0`;
        case 'deprecation':
            return `${major}.${minor}.${patch + 1}`;
    }
}
/**
 * Build a JSON Schema draft-07 object from a list of field definitions.
 */
export function buildJsonSchema(fields) {
    const properties = {};
    const required = [];
    for (const field of fields) {
        properties[field.name] = {
            type: field.type,
            ...(field.description ? { description: field.description } : {}),
        };
        if (field.required) {
            required.push(field.name);
        }
    }
    return {
        $schema: 'http://json-schema.org/draft-07/schema#',
        type: 'object',
        properties,
        required,
        additionalProperties: true,
    };
}
//# sourceMappingURL=version-utils.js.map