/**
 * Provisioning Types
 *
 * TypeScript type definitions for the DigitalOcean provisioning service.
 * Includes configuration, Droplet models, error types, and type guards.
 *
 * @module services/provisioning/provisioning.types
 */
// ---------------------------------------------------------------------------
// Constants
// ---------------------------------------------------------------------------
/** Default Ubuntu 24.04 LTS image slug for DigitalOcean. */
export const DEFAULT_IMAGE_SLUG = 'ubuntu-24-04-x64';
/** Default Droplet size (2 vCPUs, 4 GB RAM). */
export const DEFAULT_DROPLET_SIZE = 's-2vcpu-4gb';
/** Default region for new Droplets. */
export const DEFAULT_REGION = 'nyc1';
/** Tag applied to all Crewly-managed Droplets. */
export const CREWLY_DROPLET_TAG = 'crewly-pro';
/** DigitalOcean API v2 base URL. */
export const DO_API_BASE_URL = 'https://api.digitalocean.com/v2';
/** Default timeout (in ms) for waitForDropletReady polling. */
export const DEFAULT_READY_TIMEOUT_MS = 300_000;
/** Polling interval (in ms) for waitForDropletReady. */
export const POLLING_INTERVAL_MS = 5_000;
/** Firewall ports opened on Crewly Droplets. */
export const CREWLY_FIREWALL_PORTS = {
    SSH: 22,
    WEB_UI: 8787,
};
/**
 * Custom error class for provisioning failures.
 * Wraps DigitalOcean API errors with structured metadata.
 */
export class ProvisioningError extends Error {
    /** Structured error code for programmatic handling. */
    code;
    /** Associated Droplet ID, if applicable. */
    dropletId;
    /**
     * Create a new ProvisioningError.
     *
     * @param code - Structured error code
     * @param message - Human-readable error description
     * @param dropletId - Associated Droplet ID (optional)
     */
    constructor(code, message, dropletId) {
        super(message);
        this.name = 'ProvisioningError';
        this.code = code;
        this.dropletId = dropletId;
    }
}
// ---------------------------------------------------------------------------
// Type Guards
// ---------------------------------------------------------------------------
/** Valid Droplet status strings. */
const VALID_DROPLET_STATUSES = new Set([
    'new',
    'active',
    'off',
    'archive',
]);
/**
 * Check whether a string is a valid DropletStatus.
 *
 * @param value - Value to check
 * @returns True if value is a valid DropletStatus
 */
export function isDropletStatus(value) {
    return typeof value === 'string' && VALID_DROPLET_STATUSES.has(value);
}
/**
 * Check whether a value is a valid ProvisioningErrorCode.
 *
 * @param value - Value to check
 * @returns True if value is a valid ProvisioningErrorCode
 */
export function isProvisioningErrorCode(value) {
    const codes = new Set([
        'RATE_LIMITED',
        'AUTH_FAILURE',
        'NOT_FOUND',
        'SERVER_ERROR',
        'TIMEOUT',
        'NETWORK_ERROR',
        'UNKNOWN',
    ]);
    return typeof value === 'string' && codes.has(value);
}
/**
 * Check whether a value looks like a DoApiDroplet (duck-type check).
 * Validates the minimum fields required for normalization.
 *
 * @param value - Value to check
 * @returns True if value has the expected shape
 */
export function isDoApiDroplet(value) {
    if (typeof value !== 'object' || value === null) {
        return false;
    }
    const obj = value;
    return (typeof obj['id'] === 'number' &&
        typeof obj['name'] === 'string' &&
        typeof obj['status'] === 'string' &&
        typeof obj['region'] === 'object' &&
        obj['region'] !== null &&
        typeof obj['created_at'] === 'string');
}
/**
 * Check whether a value is a ProvisioningError instance.
 *
 * @param value - Value to check
 * @returns True if value is a ProvisioningError
 */
export function isProvisioningError(value) {
    return value instanceof ProvisioningError;
}
//# sourceMappingURL=provisioning.types.js.map