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,CAAc,EAAO,KAAW,GAClC,aAAa,KAAK,KAAK,gBAAiB,CACpC,KAAK,OAAO,GACZ,KAAK,IACL,KAAK,OAAO,SACZ,EACA,KACG,GAEX,CAQA,mBAAM,CAAc,KAAW,GAC3B,aAAa,KAAK,KAAK,gBAAiB,CACpC,KAAK,OAAO,GACZ,KAAK,IACL,KAAK,OAAO,SACZ,KACG,GAEX,EAEJ,QAAQ,WAAa","file":"/npm/odoo-xmlrpc-client@0.1.4/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/odoo-xmlrpc-client@0.1.4/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.OdooXMLRPC = void 0;\nconst xmlrpc_1 = __importDefault(require(\"xmlrpc\"));\nclass OdooXMLRPC {\n    constructor(config) {\n        this.uid = 0;\n        this.config = config;\n        this.client = this.makeClient('/xmlrpc/2/object');\n    }\n    makeClient(path) {\n        const url = new URL(this.config.url);\n        const clientOptions = {\n            host: url.hostname,\n            port: parseInt(url.port, 10),\n            path: path,\n        };\n        return url.protocol === 'https:'\n            ? xmlrpc_1.default.createSecureClient(clientOptions)\n            : xmlrpc_1.default.createClient(clientOptions);\n    }\n    async call(method, params, client) {\n        return (await new Promise((resolve, reject) => {\n            (client || this.client).methodCall(method, params, (error, value) => {\n                error ? reject(error) : resolve(value);\n            });\n        }));\n    }\n    /**\n     * Authenticates the user with the provided credentials.\n     * This method must be called before any other method to ensure that the user is authenticated.\n     *\n     * @returns A Promise that resolves to the user ID (uid) upon successful authentication.\n     * @throws An Error with the message 'Invalid credentials' if the authentication fails.\n     */\n    async authenticate() {\n        const uid = await this.call('authenticate', [this.config.db, this.config.username, this.config.password, {}], this.makeClient('/xmlrpc/2/common'));\n        if (!uid) {\n            throw new Error('Invalid credentials');\n        }\n        this.uid = uid;\n        return uid;\n    }\n    /**\n     * Executes a method on a specified Odoo model using the XML-RPC API.\n     *\n     * @template T The type of the result returned by the method.\n     * @param model The name of the Odoo model.\n     * @param method The name of the method to execute.\n     * @param params The parameters to pass to the method.\n     * @returns A promise that resolves to the result of the method execution.\n     */\n    async execute_kw(model, method, ...params) {\n        return await this.call('execute_kw', [\n            this.config.db,\n            this.uid,\n            this.config.password,\n            model,\n            method,\n            ...params,\n        ]);\n    }\n    /**\n     * Executes a method on a model in Odoo using XML-RPC. This is a shorthand method that\n     * calls {@link Odoo.execute_kw} with the specified model and method.\n     *\n     * @param model - The name of the model to execute the method on.\n     * @param method - The method to execute on the model.\n     * @param params - The parameters to pass to the method.\n     * @returns A promise that resolves to the result of the method execution.\n     * @template T - The type of the result.\n     */\n    async execute(model, method, ...params) {\n        return await this.execute_kw(model, method, ...params);\n    }\n    /**\n     * Executes a workflow for a given model and method.\n     *\n     * @param model - The name of the model.\n     * @param method - The name of the method.\n     * @param params - Additional parameters for the method.\n     * @returns A promise that resolves to the result of the workflow execution.\n     */\n    async exec_workflow(model, method, ...params) {\n        return await this.call('exec_workflow', [\n            this.config.db,\n            this.uid,\n            this.config.password,\n            model,\n            method,\n            ...params,\n        ]);\n    }\n    /**\n     * Renders a report using the specified parameters.\n     *\n     * @param report - The name of the report to render.\n     * @param params - Additional parameters for the report.\n     * @returns A promise that resolves to the rendered report.\n     */\n    async render_report(report, ...params) {\n        return await this.call('render_report', [\n            this.config.db,\n            this.uid,\n            this.config.password,\n            report,\n            ...params,\n        ]);\n    }\n}\nexports.OdooXMLRPC = OdooXMLRPC;\n"]}