"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;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.backendModuleXlPortGenerator = exports.backendModuleXlPortGeneratorId = void 0;
const path = __importStar(require("node:path"));
const Generator = __importStar(require("@postxl/generator"));
const generator_1 = require("@postxl/generator");
const backend_generator_1 = require("../backend.generator");
exports.backendModuleXlPortGeneratorId = Generator.toGeneratorInterfaceId('backend-core-module-xlport');
exports.backendModuleXlPortGenerator = {
    id: exports.backendModuleXlPortGeneratorId,
    requires: [backend_generator_1.backendGeneratorId],
    register: ({ backend: { modules, packageJson } }) => {
        const xlPortModule = {
            name: (0, generator_1.toBackendModuleName)('xlport'),
            moduleClass: {
                name: (0, generator_1.toClassName)('XlPortModule'),
                location: (0, generator_1.toBackendModuleLocation)('@xlport/xlport.module'),
            },
            apiModuleRegistration: {
                code: (0, generator_1.ts)(`XlPortModule.forRoot(config.xlport)`),
            },
            envConfig: {
                dotEnvExample: `
XLPORT_APIKEY=pass123
#XLPORT_URL=http://localhost:8433
`,
                decoder: (0, generator_1.ts)(`
  XLPORT_APIKEY: z.string(),
  XLPORT_URL: z.string().url().optional()`),
                transformer: (0, generator_1.ts)(`
    xlport: {
  apiKey: val.XLPORT_APIKEY,
  url: val.XLPORT_URL,
}`),
            },
        };
        modules.push(xlPortModule);
        packageJson.dependencies.push({ packageName: 'xlport', version: '0.4.1' });
    },
    generate: async ({ vfs }) => {
        await vfs.loadFolder({
            diskPath: path.resolve(__dirname, '../template/libs/xlport'),
            targetPath: './backend/libs/xlport',
        });
    },
};
//# sourceMappingURL=backend-module-xlport.generator.js.map