"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = require("node:test");
const strict_1 = __importDefault(require("node:assert/strict"));
const node_fs_1 = require("node:fs");
const node_path_1 = require("node:path");
/** Paths used by HttpHybxClient (must match placeholder OpenAPI). */
const HTTP_CLIENT_PATHS = [
    { method: 'POST', path: '/v1/payments' },
    { method: 'GET', pathPrefix: '/v1/payments/' },
    { method: 'GET', path: '/v1/settlement-events' },
];
function repoRootFromTestDir() {
    // dist/hybx → proxmox root (5 levels up)
    return (0, node_path_1.resolve)(__dirname, '../../../../..');
}
function loadPlaceholderOpenApi() {
    const openApiPath = (0, node_path_1.resolve)(repoRootFromTestDir(), 'docs/api/openapi-hybx-integration-placeholder.yaml');
    strict_1.default.ok((0, node_fs_1.existsSync)(openApiPath), `placeholder OpenAPI missing: ${openApiPath}`);
    return (0, node_fs_1.readFileSync)(openApiPath, 'utf8');
}
(0, node_test_1.describe)('HYBX placeholder OpenAPI contract', () => {
    (0, node_test_1.it)('declares HttpHybxClient payment and settlement paths', () => {
        const spec = loadPlaceholderOpenApi();
        for (const entry of HTTP_CLIENT_PATHS) {
            if (entry.path) {
                strict_1.default.match(spec, new RegExp(`^\\s+${entry.path.replace(/\//g, '\\/')}:\\s*$`, 'm'));
            }
            if (entry.pathPrefix) {
                strict_1.default.match(spec, /\/v1\/payments\/\{paymentId\}:/);
            }
        }
    });
    (0, node_test_1.it)('defines initiatePayment and getPaymentStatus operationIds', () => {
        const spec = loadPlaceholderOpenApi();
        strict_1.default.match(spec, /operationId:\s*initiatePayment/);
        strict_1.default.match(spec, /operationId:\s*getPaymentStatus/);
        strict_1.default.match(spec, /operationId:\s*listSettlementEvents/);
    });
    (0, node_test_1.it)('requires HybxPaymentRequest core fields', () => {
        const spec = loadPlaceholderOpenApi();
        for (const field of ['idempotencyKey', 'entityId', 'tenantId', 'amount', 'currency']) {
            strict_1.default.match(spec, new RegExp(`${field}:\\s*\\{`));
        }
    });
});
