"use strict";
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;
    };
})();
/**
 * Guards the CSP fix from #21276 at the level the bundle-grep guard CANNOT:
 * execution timing. The SDK broke under a strict CSP because `dbt/validation.ts`
 * compiled an Ajv validator (`new Function`) *at module import*. Making Ajv lazy
 * does not change the bundled text — only WHEN it runs — so a text grep of the
 * SDK bundle is blind to a regression here. This test asserts the runtime
 * property directly: importing the module must not generate code at all.
 */
describe('CSP: dbt/validation must not generate code at import (#21276)', () => {
    const RealFunction = global.Function;
    afterEach(() => {
        global.Function = RealFunction;
        vi.resetModules();
    });
    it('importing the module invokes no `new Function` (no eval-based codegen)', async () => {
        const constructed = [];
        // Intercept every `new Function(...)` during the import. A clean import
        // produces none; any call (Ajv schema compilation, or any other
        // code-generating dependency that creeps onto the import path) fails the
        // test, because it would break the SDK under a strict CSP.
        function FunctionTrap(...args) {
            constructed.push(String(args[args.length - 1] ?? '').slice(0, 80));
            return Reflect.construct(RealFunction, args);
        }
        FunctionTrap.prototype = RealFunction.prototype;
        global.Function = FunctionTrap;
        vi.resetModules();
        await Promise.resolve().then(() => __importStar(require('./validation')));
        expect(constructed).toEqual([]);
    });
});
//# sourceMappingURL=validation.csp.test.js.map