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AAA,CAAI,MAAM,QAAA,CAAS,IAAA,EAAM,CAAA;AAChE,IAAA,IAAI,gBAAA,EAAkB;AACpB,MAAA,MAAM,gBAAA;AAAA,IACR;AACA,IAAA,MAAM,EAAE,OAAM,GAAI,IAAA;AAClB,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,MAAM,IAAI,KAAA,CAAM,IAAA,EAAM,KAAA,EAAO,MAAM,OAAO,CAAA;AAAA,IAC5C;AACA,IAAA,IAAA,CAAK,YAAA,GAAe,KAAA;AACpB,IAAA,IAAA,CAAK,aAAA,GAAgB,MAAA;AACrB,IAAA,IAAA,CAAK,GAAA,GAAM,MAAA;AACX,IAAA,IAAA,CAAK,UAAA,GAAa,MAAA;AAClB,IAAA,OAAO,IAAA;AAAA,EACT;AACF","file":"index.cjs","sourcesContent":["export type OdooSearchDomain = any | any[];\n\nexport interface OdooSearchReadOptions {\n  offset?: number;\n  limit?: number;\n  order?: string;\n  context?: any;\n}\nexport type OdooAuthenticateWithApiKeyResponse = {\n  uid: number;\n};\nexport type OdooAuthenticateWithCredentialsResponse = {\n  uid: number;\n  is_system: boolean;\n  is_admin: boolean;\n  is_internal_user: boolean;\n  user_context: UserContext;\n  db: string;\n  user_settings: UserSettings;\n  server_version: string;\n  server_version_info: [number, number, number, string, number, string];\n  support_url: string;\n  name: string;\n  username: string;\n  partner_display_name: string;\n  partner_id: number;\n  'web.base.url': string;\n  active_ids_limit: number;\n  profile_session: any;\n  profile_collectors: any;\n  profile_params: any;\n  max_file_upload_size: number;\n  home_action_id: boolean;\n  cache_hashes: any;\n  currencies: any;\n  bundle_params: any;\n  user_companies: any;\n  show_effect: boolean;\n  display_switch_company_menu: boolean;\n  user_id: number[];\n  max_time_between_keys_in_ms: number;\n  web_tours: any[];\n  tour_disable: boolean;\n  notification_type: string;\n  warning: string;\n  expiration_date: string;\n  expiration_reason: string;\n  map_box_token: boolean;\n  odoobot_initialized: boolean;\n  iap_company_enrich: boolean;\n  ocn_token_key: boolean;\n  fcm_project_id: boolean;\n  inbox_action: number;\n  is_quick_edit_mode_enabled: string;\n  dbuuid: string;\n  multi_lang: boolean;\n};\n\nexport type UserContext = {\n  lang: string;\n  tz: string;\n  uid: number;\n};\n\nexport type UserSettings = {\n  id: number;\n  user_id: UserId;\n  is_discuss_sidebar_category_channel_open: boolean;\n  is_discuss_sidebar_category_chat_open: boolean;\n  push_to_talk_key: boolean;\n  use_push_to_talk: boolean;\n  voice_active_duration: number;\n  volume_settings_ids: [string, any[]][];\n  homemenu_config: boolean;\n};\n\nexport type UserId = {\n  id: number;\n};\nexport type OdooConnectionBase = {\n  baseUrl?: string;\n  port?: number;\n  db?: string;\n};\n\nexport interface ConnectionWithSession extends OdooConnectionBase {\n  sessionId?: string;\n}\n\nexport interface ConnectionWithCredentials extends OdooConnectionBase {\n  username?: string;\n  password?: string;\n  apiKey?: string;\n}\n\nexport type OdooConnection = ConnectionWithSession | ConnectionWithCredentials;\n\nexport const Try = async <T>(fn: () => Promise<T>): Promise<[T, null] | [null, Error]> => {\n  try {\n    const result = await fn();\n    return [result, null];\n  } catch (e) {\n    const error = e as Error;\n    return [null, error];\n  }\n};\n/**\n * Type guard to determine if the authentication response is a full credentials response.\n *\n * This function distinguishes between the two possible authentication response types:\n * - OdooAuthenticateWithCredentialsResponse (full response with user details)\n * - OdooAuthenticateWithApiKeyResponse (simple response with just the user ID)\n *\n * It checks for the presence of the 'username' property, which is only available\n * in the full credentials response.\n *\n * @param response - The authentication response to check\n * @returns true if the response is a full credentials response, false otherwise\n *\n * @example\n * const authResponse = await odoo.connect();\n * if (isCredentialsResponse(authResponse)) {\n *   console.log(\"Authenticated user:\", authResponse.username);\n * } else {\n *   console.log(\"Authenticated with API key, user ID:\", authResponse.uid);\n * }\n */\nexport const isCredentialsResponse = (\n  response: OdooAuthenticateWithCredentialsResponse | OdooAuthenticateWithApiKeyResponse\n): response is OdooAuthenticateWithCredentialsResponse => {\n  return response && 'username' in response;\n};\nexport default class OdooJSONRpc {\n  public url: string | undefined = undefined;\n  public is_connected = false;\n  private session_id: string | undefined = undefined;\n  private auth_response: any = null;\n  private uid: number | undefined = undefined;\n  private api_key: string | undefined = undefined;\n  private config: OdooConnection = {};\n\n  constructor(config: OdooConnection = {}) {\n    this.initialize(config);\n  }\n  get uId(): number | undefined {\n    return this.uid ?? this.auth_response?.uid;\n  }\n  get authResponse(): OdooAuthenticateWithCredentialsResponse | undefined {\n    return this.auth_response;\n  }\n  get sessionId(): string | undefined {\n    return this.session_id;\n  }\n  get port(): number | undefined {\n    return this.config?.port;\n  }\n  //Initializes the OdooJSONRpc instance with the provided configuration.\n  public initialize(config: OdooConnection) {\n    this.config = config;\n    if (config.baseUrl && config.port) {\n      this.url = `${config.baseUrl}:${config.port}`;\n    }\n    if ('sessionId' in config && config.sessionId) {\n      this.session_id = config.sessionId;\n    } else if ('apiKey' in config && config.apiKey) {\n      this.api_key = config.apiKey;\n    }\n    this.is_connected = false;\n    this.auth_response = undefined;\n    this.uid = undefined;\n  }\n  //Connects to the Odoo server using the provided or existing configuration.\n  async connect(config?: OdooConnection): Promise<OdooAuthenticateWithCredentialsResponse | OdooAuthenticateWithApiKeyResponse> {\n    if (config) {\n      this.initialize(config);\n    }\n    if (!this.config.baseUrl || !this.config.port || !this.config.db) {\n      throw new Error('Incomplete configuration. Please provide baseUrl, port, and db.');\n    }\n    const result = await ('sessionId' in this.config\n      ? this.connectWithSessionId()\n      : 'apiKey' in this.config\n      ? this.connectWithApiKey(this.config as ConnectionWithCredentials)\n      : this.connectWithCredentials(this.config as ConnectionWithCredentials));\n\n    if (!result) {\n      throw new Error('Authentication failed. Please check your credentials.');\n    }\n\n    if (isCredentialsResponse(result)) {\n      this.auth_response = result;\n    } else {\n      this.auth_response = result;\n      this.uid = result.uid;\n    }\n    this.is_connected = true;\n    return this.auth_response;\n  }\n  //Connects to the Odoo server using an API key.\n  private async connectWithApiKey(config: ConnectionWithCredentials): Promise<OdooAuthenticateWithApiKeyResponse> {\n    const endpoint = `${this.url}/jsonrpc`;\n    const params = {\n      jsonrpc: '2.0',\n      method: 'call',\n      params: {\n        service: 'common',\n        method: 'authenticate',\n        args: [config.db, config.username, config.apiKey, {}],\n      },\n      id: new Date().getTime(),\n    };\n    const [response, auth_error] = await Try(() =>\n      fetch(endpoint, {\n        method: 'POST',\n        headers: {\n          'Content-Type': 'application/json',\n        },\n        body: JSON.stringify(params),\n      })\n    );\n    if (auth_error) {\n      throw auth_error;\n    }\n    if (!response.ok) {\n      throw new Error(response.statusText);\n    }\n    const [body, body_parse_error] = await Try(() => response.json());\n    if (body_parse_error) {\n      throw body_parse_error;\n    }\n    const { result, odoo_error } = body;\n    if (odoo_error) {\n      throw new Error(body?.error?.data?.message);\n    }\n    this.uid = result;\n    return { uid: result };\n  }\n  //Connects to the Odoo server using username and password credentials.\n  private async connectWithCredentials(config: ConnectionWithCredentials): Promise<OdooAuthenticateWithCredentialsResponse> {\n    const endpoint = `${this.url}/web/session/authenticate`;\n    const params = {\n      jsonrpc: '2.0',\n      method: 'call',\n      params: {\n        db: config.db,\n        login: config.username,\n        password: config.password,\n      },\n      id: new Date().getTime(),\n    };\n    const [response, auth_error] = await Try(() =>\n      fetch(endpoint, {\n        method: 'POST',\n        headers: {\n          'Content-Type': 'application/json',\n        },\n        body: JSON.stringify(params),\n      })\n    );\n    if (auth_error) {\n      throw auth_error;\n    }\n    if (!response.ok) {\n      throw new Error(response.statusText);\n    }\n    const [body, body_parse_error] = await Try(() => response.json());\n    if (body_parse_error) {\n      throw body_parse_error;\n    }\n    const { result, odoo_error } = body;\n    if (odoo_error) {\n      throw new Error(body?.error?.data?.message);\n    }\n    const cookies = response.headers.get('set-cookie');\n    if (!cookies) {\n      throw new Error('Cookie not found in response headers, please check your credentials');\n    }\n    if (!cookies.includes('session_id')) {\n      throw new Error('session_id not found in cookies');\n    }\n    const sessionId = cookies\n      .split(';')\n      .find((cookie) => cookie.includes('session_id'))!\n      .split('=')[1];\n    this.session_id = sessionId;\n    this.auth_response = result;\n    return result;\n  }\n  //Connects to the Odoo server using an existing session ID.\n  private async connectWithSessionId(): Promise<OdooAuthenticateWithCredentialsResponse> {\n    const endpoint = `${this.url}/web/session/get_session_info`;\n    const params = {\n      jsonrpc: '2.0',\n      method: 'call',\n      params: {},\n      id: new Date().getTime(),\n    };\n    const headers: Record<string, string> = {\n      'Content-Type': 'application/json',\n    };\n\n    if (this.session_id) {\n      headers['X-Openerp-Session-Id'] = this.session_id;\n      headers['Cookie'] = `session_id=${this.session_id}`;\n    } else {\n      throw new Error('session_id not found. Please connect first.');\n    }\n    const [response, auth_error] = await Try(() =>\n      fetch(endpoint, {\n        method: 'POST',\n        headers,\n        body: JSON.stringify(params),\n      })\n    );\n    if (auth_error) {\n      throw auth_error;\n    }\n    if (!response.ok) {\n      throw new Error(response.statusText);\n    }\n    const [body, body_parse_error] = await Try(() => response.json());\n    if (body_parse_error) {\n      throw body_parse_error;\n    }\n    const { result, odoo_error } = body;\n    if (odoo_error) {\n      throw new Error(body?.error?.data?.message);\n    }\n    this.auth_response = result;\n    return result;\n  }\n  //Calls a method on the Odoo server using the RPC protocol.\n  async call_kw(model: string, method: string, args: any[], kwargs: any = {}): Promise<any> {\n    if (!this.is_connected) {\n      this.auth_response = await this.connect();\n    }\n    if (!this.session_id && !this.uid) {\n      this.is_connected = false;\n      throw new Error('Please connect with credentials or api key first.');\n    }\n    if (this.session_id) {\n      return this.callWithSessionId(model, method, args, kwargs);\n    } else if (this.uid) {\n      return this.callWithUid(model, method, args, kwargs);\n    }\n  }\n  //Calls a method on the Odoo server using UID and API key authentication.\n  private async callWithUid(model: string, method: string, args: any[], kwargs: any = {}): Promise<any> {\n    const endpoint = `${this.url}/jsonrpc`;\n    const params = {\n      jsonrpc: '2.0',\n      method: 'call',\n      params: {\n        service: 'object',\n        method: 'execute_kw',\n        args: [this.config.db, this.uid, this.api_key, model, method, args, kwargs],\n      },\n      id: new Date().getTime(),\n    };\n    const headers = {\n      'Content-Type': 'application/json',\n    };\n    const [response, request_error] = await Try(() =>\n      fetch(endpoint, {\n        headers,\n        method: 'POST',\n        body: JSON.stringify(params),\n      })\n    );\n    if (request_error) {\n      throw request_error;\n    }\n    if (!response.ok) {\n      throw new Error(response.statusText);\n    }\n    const [body, body_parse_error] = await Try(() => response.json());\n    if (body_parse_error) {\n      throw body_parse_error;\n    }\n    const { result, error } = body;\n    if (error) {\n      throw new Error(body?.error?.data?.message);\n    }\n    return result;\n  }\n  //Calls a method on the Odoo server using session ID authentication.\n  private async callWithSessionId(model: string, method: string, args: any[], kwargs: any = {}): Promise<any> {\n    const endpoint = `${this.url}/web/dataset/call_kw`;\n    const params = {\n      jsonrpc: '2.0',\n      method: 'call',\n      params: {\n        model,\n        method,\n        args,\n        kwargs,\n      },\n      id: new Date().getTime(),\n    };\n    const headers: any = {\n      'Content-Type': 'application/json',\n      'X-Openerp-Session-Id': this.session_id,\n      Cookie: `session_id=${this.session_id}`,\n    };\n    const [response, request_error] = await Try(() =>\n      fetch(endpoint, {\n        headers,\n        method: 'POST',\n        body: JSON.stringify(params),\n      })\n    );\n    if (request_error) {\n      throw request_error;\n    }\n    if (!response.ok) {\n      throw new Error(response.statusText);\n    }\n    const [body, body_parse_error] = await Try(() => response.json());\n    if (body_parse_error) {\n      throw body_parse_error;\n    }\n    const { result, error } = body;\n    if (error) {\n      throw new Error(body?.error?.data?.message);\n    }\n    return result;\n  }\n  //Creates a new record in the specified Odoo model.\n  async create(model: string, values: any): Promise<number> {\n    return this.call_kw(model, 'create', [values]);\n  }\n  //Reads records from the specified Odoo model.\n  async read<T>(model: string, id: number | number[], fields: string[]): Promise<T[]> {\n    return this.call_kw(model, 'read', [id, fields]);\n  }\n  //Updates a record in the specified Odoo model.\n  async update(model: string, id: number, values: any): Promise<boolean> {\n    return this.call_kw(model, 'write', [[id], values]);\n  }\n  /**\n   * Updates the translations for a field in the specified Odoo model.\n   * @param model Model to update eg. product.template\n   * @param id Id of the model to update\n   * @param field field to update eg. name\n   * @param translations object with translations eg. {de_DE: \"Neuer Name\", en_GB: \"Name\"}\n   */\n  async updateFieldTranslations(model: string, id: number, field: string, translations: { [key: string]: string }): Promise<boolean> {\n    return this.call_kw(model, 'update_field_translations', [[id], field, translations]);\n  }\n  //Deletes a record from the specified Odoo model.\n  async delete(model: string, id: number): Promise<boolean> {\n    return this.call_kw(model, 'unlink', [[id]]);\n  }\n  //Searches and reads records from the specified Odoo model.\n  async searchRead<T>(model: string, domain: OdooSearchDomain, fields: string[], opts?: OdooSearchReadOptions): Promise<T[]> {\n    return (await this.call_kw(model, 'search_read', [domain, fields], opts)) || [];\n  }\n  //Searches for records in the specified Odoo model.\n  async search(model: string, domain: OdooSearchDomain): Promise<number[]> {\n    return (await this.call_kw(model, 'search', [domain])) || [];\n  }\n  //Retrieves the fields information for the specified Odoo model.\n  async getFields(model: string): Promise<any> {\n    return this.call_kw(model, 'fields_get', []);\n  }\n  //Executes an action on the specified Odoo model for given record IDs.\n  async action(model: string, action: string, ids: number[]): Promise<boolean> {\n    return this.call_kw(model, action, ids);\n  }\n  //Creates an external ID for a record in the specified Odoo model.\n  async createExternalId(model: string, recordId: number, externalId: string, moduleName?: string): Promise<number> {\n    return await this.call_kw('ir.model.data', 'create', [\n      [\n        {\n          model: model,\n          name: `${externalId}`,\n          res_id: recordId,\n          module: moduleName || '__api__',\n        },\n      ],\n    ]);\n  }\n  //Searches for a record by its external ID.\n  async searchByExternalId(externalId: string): Promise<number> {\n    const irModelData = await this.searchRead<any>('ir.model.data', [['name', '=', externalId]], ['res_id']);\n    if (!irModelData.length) {\n      throw new Error(`No matching record found for external identifier ${externalId}`);\n    }\n    return irModelData[0]['res_id'];\n  }\n  //Reads a record by its external ID.\n  async readByExternalId<T>(externalId: string, fields: string[] = []): Promise<T> {\n    const irModelData = await this.searchRead<any>('ir.model.data', [['name', '=', externalId]], ['res_id', 'model']);\n    if (!irModelData.length) {\n      throw new Error(`No matching record found for external identifier ${externalId}`);\n    }\n    return (await this.read<any>(irModelData[0].model, [irModelData[0].res_id], fields))[0];\n  }\n  //Updates a record by its external ID.\n  async updateByExternalId(externalId: string, params: any = {}): Promise<any> {\n    const irModelData = await this.searchRead<any>('ir.model.data', [['name', '=', externalId]], ['res_id', 'model']);\n    if (!irModelData.length) {\n      throw new Error(`No matching record found for external identifier ${externalId}`);\n    }\n    return await this.update(irModelData[0].model, irModelData[0].res_id, params);\n  }\n  //Deletes a record by its external ID.\n  async deleteByExternalId(externalId: string): Promise<any> {\n    const irModelData = await this.searchRead<any>('ir.model.data', [['name', '=', externalId]], ['res_id', 'model']);\n    if (!irModelData.length) {\n      throw new Error(`No matching record found for external ID ${externalId}`);\n    }\n    return await this.delete(irModelData[0].model, irModelData[0].res_id);\n  }\n  //Disconnects from the Odoo server\n  async disconnect(): Promise<boolean> {\n    const endpoint = `${this.url}/web/session/destroy`;\n    const params = {\n      jsonrpc: '2.0',\n      method: 'call',\n      params: {},\n      id: new Date().getTime(),\n    };\n    const headers: Record<string, string> = {\n      'Content-Type': 'application/json',\n    };\n\n    if (this.session_id) {\n      headers['X-Openerp-Session-Id'] = this.session_id;\n      headers['Cookie'] = `session_id=${this.session_id}`;\n    } else {\n      throw new Error('session_id not found. Please connect first.');\n    }\n\n    const [response, auth_error] = await Try(() =>\n      fetch(endpoint, {\n        method: 'POST',\n        headers,\n        body: JSON.stringify(params),\n      })\n    );\n\n    if (auth_error) {\n      throw auth_error;\n    }\n    if (!response.ok) {\n      throw new Error(response.statusText);\n    }\n    const [body, body_parse_error] = await Try(() => response.json());\n    if (body_parse_error) {\n      throw body_parse_error;\n    }\n    const { error } = body;\n    if (error) {\n      throw new Error(body?.error?.data?.message);\n    }\n    this.is_connected = false;\n    this.auth_response = undefined;\n    this.uid = undefined;\n    this.session_id = undefined;\n    return true;\n  }\n}\n"]}