"use strict";
/**
 * RED-GREEN tests for F-NEW-PRODUCT-PROXY-SELFSERVE-ONBOARDING (W4.4).
 *
 * @connexum/ai-governance  F-NEW-PRODUCT-PROXY-SELFSERVE-ONBOARDING
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = require("node:test");
const assert = __importStar(require("node:assert/strict"));
const proxy_onboarding_1 = require("./proxy-onboarding");
const ALL_PROVIDERS = [
    'anthropic',
    'openai',
    'gemini-aistudio',
    'gemini-vertex',
    'bedrock',
    'azure-openai',
    'deepseek',
    'replicate',
    'huggingface',
];
(0, node_test_1.describe)('F-NEW-PRODUCT-PROXY-SELFSERVE-ONBOARDING (W4.4)', () => {
    (0, node_test_1.it)('SUPPORTED_PROVIDERS covers all 9 Mode A v1 providers', () => {
        assert.equal(proxy_onboarding_1.SUPPORTED_PROVIDERS.length, 9);
        const ids = proxy_onboarding_1.SUPPORTED_PROVIDERS.map((p) => p.id).sort();
        assert.deepEqual(ids, [...ALL_PROVIDERS].sort());
    });
    (0, node_test_1.it)('every provider produces a non-empty TypeScript snippet', () => {
        for (const provider of ALL_PROVIDERS) {
            const payload = (0, proxy_onboarding_1.buildProxyOnboardingPayload)({ tenantId: 'tenant-1', provider });
            assert.equal(payload.language, 'typescript');
            assert.ok(payload.snippet.length > 0, `${provider} TS snippet`);
            assert.ok(payload.snippet.includes('proxy.my-cc.io'), `${provider} TS snippet must reference proxy host`);
        }
    });
    (0, node_test_1.it)('every provider produces a non-empty Python snippet', () => {
        for (const provider of ALL_PROVIDERS) {
            const payload = (0, proxy_onboarding_1.buildProxyOnboardingPayload)({
                tenantId: 'tenant-1',
                provider,
                language: 'python',
            });
            assert.equal(payload.language, 'python');
            assert.ok(payload.snippet.length > 0, `${provider} Python snippet`);
            assert.ok(payload.snippet.includes('proxy.my-cc.io'), `${provider} Python snippet must reference proxy host`);
        }
    });
    (0, node_test_1.it)('snippet embeds the tenantId', () => {
        const payload = (0, proxy_onboarding_1.buildProxyOnboardingPayload)({
            tenantId: 'org-acme-7821',
            provider: 'anthropic',
        });
        assert.ok(payload.snippet.includes('org-acme-7821'));
    });
    (0, node_test_1.it)('Anthropic TS snippet references X-LLM-API-Key header', () => {
        const payload = (0, proxy_onboarding_1.buildProxyOnboardingPayload)({
            tenantId: 'tenant-1',
            provider: 'anthropic',
        });
        assert.ok(payload.snippet.includes('X-LLM-API-Key'));
    });
    (0, node_test_1.it)('OpenAI TS snippet uses /openai/v1 path', () => {
        const payload = (0, proxy_onboarding_1.buildProxyOnboardingPayload)({
            tenantId: 'tenant-1',
            provider: 'openai',
        });
        assert.ok(payload.snippet.includes('/openai/v1'));
    });
    (0, node_test_1.it)('Azure OpenAI snippet includes X-Azure-Resource header', () => {
        const payload = (0, proxy_onboarding_1.buildProxyOnboardingPayload)({
            tenantId: 'tenant-1',
            provider: 'azure-openai',
        });
        assert.ok(payload.snippet.includes('X-Azure-Resource'));
    });
    (0, node_test_1.it)('proxyHost override is honored', () => {
        const payload = (0, proxy_onboarding_1.buildProxyOnboardingPayload)({
            tenantId: 'tenant-1',
            provider: 'anthropic',
            proxyHost: 'staging-proxy.my-cc.io',
        });
        assert.equal(payload.proxyBaseUrl, 'https://staging-proxy.my-cc.io');
        assert.ok(payload.snippet.includes('staging-proxy.my-cc.io'));
    });
    (0, node_test_1.it)('envVars match the provider', () => {
        const a = (0, proxy_onboarding_1.buildProxyOnboardingPayload)({ tenantId: 't', provider: 'anthropic' });
        const b = (0, proxy_onboarding_1.buildProxyOnboardingPayload)({ tenantId: 't', provider: 'bedrock' });
        assert.ok('ANTHROPIC_API_KEY' in a.envVars);
        assert.ok('AWS_ACCESS_KEY_ID' in b.envVars);
    });
    (0, node_test_1.it)('firstEventEndpoint includes URL-encoded tenant id', () => {
        const payload = (0, proxy_onboarding_1.buildProxyOnboardingPayload)({
            tenantId: 'acme co/123',
            provider: 'anthropic',
        });
        assert.ok(payload.firstEventEndpoint.includes('acme%20co%2F123'));
    });
    (0, node_test_1.it)('missing tenantId throws (fail-closed)', () => {
        assert.throws(() => (0, proxy_onboarding_1.buildProxyOnboardingPayload)({ tenantId: '', provider: 'anthropic' }), /tenantId is required/);
    });
});
//# sourceMappingURL=proxy-onboarding.test.js.map