/**
 * External Issue Adapter Types
 *
 * Canonical types for normalizing issues from external sources
 * (Linear and Jira) into a shared IssueEnvelope format
 * that can be mapped to spawn context.
 */
/**
 * All valid issue sources as a const array.
 */
export const ISSUE_SOURCES = ['linear', 'jira'];
/**
 * Typed error for external issue operations.
 */
export class ExternalIssueError extends Error {
    code;
    source;
    validationErrors;
    constructor(code, message, source, validationErrors) {
        super(message);
        this.code = code;
        this.source = source;
        this.validationErrors = validationErrors;
        this.name = 'ExternalIssueError';
    }
}
/**
 * Typed error for external issue adapter operations.
 *
 * Covers config, auth, payload, and request failures that occur
 * when interacting with a specific external issue source.
 */
export class ExternalIssueAdapterError extends Error {
    code;
    causeDetail;
    constructor(code, message, causeDetail) {
        super(message);
        this.code = code;
        this.causeDetail = causeDetail;
        this.name = 'ExternalIssueAdapterError';
    }
}
/**
 * Convert a canonical IssueEnvelope to a NormalizedIssueEnvelope.
 *
 * Deterministic: same input always produces same output.
 */
export function toNormalizedEnvelope(envelope, category) {
    return {
        source: {
            name: envelope.source,
            externalId: envelope.external_id,
            externalKey: envelope.external_key,
            url: envelope.url,
            raw: envelope.raw,
        },
        title: envelope.title,
        description: envelope.description,
        labels: envelope.labels,
        priority: envelope.priority,
        status: envelope.status,
        projectKey: envelope.project_key,
        assignee: envelope.assignee,
        category: category ?? null,
        itemType: envelope.item_type ?? null,
    };
}
//# sourceMappingURL=types.js.map