apacuana-sdk-core 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -32891,125 +32891,83 @@ var getCertStatus = function getCertStatus() {
32891
32891
  };
32892
32892
 
32893
32893
  var addSignerOnBoarding = /*#__PURE__*/function () {
32894
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(signerData) {
32894
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(signerData) {
32895
32895
  var _t2;
32896
- return _regenerator().w(function (_context7) {
32897
- while (1) switch (_context7.p = _context7.n) {
32896
+ return _regenerator().w(function (_context5) {
32897
+ while (1) switch (_context5.p = _context5.n) {
32898
32898
  case 0:
32899
32899
  helpers.validateOnBoardingSignerData(signerData);
32900
- _context7.p = 1;
32901
- _context7.n = 2;
32900
+ _context5.p = 1;
32901
+ _context5.n = 2;
32902
32902
  return httpRequest("services/api/documents/signing", signerData, "POST");
32903
32903
  case 2:
32904
- return _context7.a(2, {
32904
+ return _context5.a(2, {
32905
32905
  signer: signerData.typedoc + signerData.doc,
32906
32906
  success: true
32907
32907
  });
32908
32908
  case 3:
32909
- _context7.p = 3;
32910
- _t2 = _context7.v;
32909
+ _context5.p = 3;
32910
+ _t2 = _context5.v;
32911
32911
  if (!(_t2 instanceof ApacuanaAPIError)) {
32912
- _context7.n = 4;
32912
+ _context5.n = 4;
32913
32913
  break;
32914
32914
  }
32915
32915
  throw _t2;
32916
32916
  case 4:
32917
32917
  throw new Error("Failed to add signer in On-Boarding: ".concat(_t2.message));
32918
32918
  case 5:
32919
- return _context7.a(2);
32919
+ return _context5.a(2);
32920
32920
  }
32921
- }, _callee7, null, [[1, 3]]);
32921
+ }, _callee5, null, [[1, 3]]);
32922
32922
  }));
32923
- return function addSignerOnBoarding(_x3) {
32924
- return _ref7.apply(this, arguments);
32923
+ return function addSignerOnBoarding(_x2) {
32924
+ return _ref5.apply(this, arguments);
32925
32925
  };
32926
32926
  }();
32927
32927
  var addSignerOnPremise = /*#__PURE__*/function () {
32928
- var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
32929
- return _regenerator().w(function (_context8) {
32930
- while (1) switch (_context8.n) {
32928
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
32929
+ return _regenerator().w(function (_context6) {
32930
+ while (1) switch (_context6.n) {
32931
32931
  case 0:
32932
32932
  throw new ApacuanaAPIError("Adding signers is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
32933
32933
  case 1:
32934
- return _context8.a(2);
32934
+ return _context6.a(2);
32935
32935
  }
32936
- }, _callee8);
32936
+ }, _callee6);
32937
32937
  }));
32938
32938
  return function addSignerOnPremise() {
32939
- return _ref8.apply(this, arguments);
32940
- };
32941
- }();
32942
-
32943
- /**
32944
- * Adds a signer to a document, handling different integration types.
32945
- * @param {object} signerData - Data of the signer to be added.
32946
- * @returns {Promise<{signer: string, success: boolean}>} Object with the result of adding the signer.
32947
- * @throws {ApacuanaAPIError} If the signer data is invalid, if the API call fails, or if the integration type is not supported.
32948
- */
32949
- var addSigner = /*#__PURE__*/function () {
32950
- var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(signerData) {
32951
- var _getConfig3, integrationType;
32952
- return _regenerator().w(function (_context9) {
32953
- while (1) switch (_context9.n) {
32954
- case 0:
32955
- if (!(!signerData || _typeof(signerData) !== "object" || Object.keys(signerData).length === 0)) {
32956
- _context9.n = 1;
32957
- break;
32958
- }
32959
- throw new ApacuanaAPIError("Signer data (signerData) is required and must be a non-empty object.", 400, "INVALID_PARAMETER");
32960
- case 1:
32961
- _getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
32962
- if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
32963
- _context9.n = 2;
32964
- break;
32965
- }
32966
- return _context9.a(2, addSignerOnBoarding(signerData));
32967
- case 2:
32968
- if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
32969
- _context9.n = 3;
32970
- break;
32971
- }
32972
- return _context9.a(2, addSignerOnPremise(signerData));
32973
- case 3:
32974
- throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
32975
- case 4:
32976
- return _context9.a(2);
32977
- }
32978
- }, _callee9);
32979
- }));
32980
- return function addSigner(_x4) {
32981
- return _ref9.apply(this, arguments);
32939
+ return _ref6.apply(this, arguments);
32982
32940
  };
32983
32941
  }();
32984
32942
  var getDocsOnPremise = /*#__PURE__*/function () {
32985
- var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
32986
- return _regenerator().w(function (_context0) {
32987
- while (1) switch (_context0.n) {
32943
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
32944
+ return _regenerator().w(function (_context7) {
32945
+ while (1) switch (_context7.n) {
32988
32946
  case 0:
32989
- throw new ApacuanaAPIError("Document retrieval is not supported for integration type: ONBOARDING", 501, "NOT_IMPLEMENTED");
32947
+ throw new ApacuanaAPIError("Document retrieval is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
32990
32948
  case 1:
32991
- return _context0.a(2);
32949
+ return _context7.a(2);
32992
32950
  }
32993
- }, _callee0);
32951
+ }, _callee7);
32994
32952
  }));
32995
32953
  return function getDocsOnPremise() {
32996
- return _ref0.apply(this, arguments);
32954
+ return _ref7.apply(this, arguments);
32997
32955
  };
32998
32956
  }();
32999
32957
  var getDocsOnBoarding = /*#__PURE__*/function () {
33000
- var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(data) {
33001
- var _getConfig4, customerId, params, apiUrl, response, _t3;
33002
- return _regenerator().w(function (_context1) {
33003
- while (1) switch (_context1.p = _context1.n) {
32958
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(data) {
32959
+ var _getConfig, customerId, params, apiUrl, response, _t3;
32960
+ return _regenerator().w(function (_context8) {
32961
+ while (1) switch (_context8.p = _context8.n) {
33004
32962
  case 0:
33005
- _getConfig4 = getConfig(), customerId = _getConfig4.customerId;
32963
+ _getConfig = getConfig(), customerId = _getConfig.customerId;
33006
32964
  if (customerId) {
33007
- _context1.n = 1;
32965
+ _context8.n = 1;
33008
32966
  break;
33009
32967
  }
33010
32968
  throw new ApacuanaAPIError("'customerId' is not configured. Please configure the SDK.", 400, "CONFIGURATION_ERROR");
33011
32969
  case 1:
33012
- _context1.p = 1;
32970
+ _context8.p = 1;
33013
32971
  params = new URLSearchParams({
33014
32972
  page: data.page,
33015
32973
  customerid: customerId,
@@ -33019,40 +32977,82 @@ var getDocsOnBoarding = /*#__PURE__*/function () {
33019
32977
  params.append("status", data.status);
33020
32978
  }
33021
32979
  apiUrl = "services/api/documents/listcustomer?".concat(params.toString());
33022
- _context1.n = 2;
32980
+ _context8.n = 2;
33023
32981
  return httpRequest(apiUrl, {}, "GET");
33024
32982
  case 2:
33025
- response = _context1.v;
33026
- return _context1.a(2, {
32983
+ response = _context8.v;
32984
+ return _context8.a(2, {
33027
32985
  totalRecords: response.numofrecords,
33028
32986
  records: response.records,
33029
32987
  success: true
33030
32988
  });
33031
32989
  case 3:
33032
- _context1.p = 3;
33033
- _t3 = _context1.v;
32990
+ _context8.p = 3;
32991
+ _t3 = _context8.v;
33034
32992
  if (!(_t3.name === "ApacuanaAPIError")) {
33035
- _context1.n = 4;
32993
+ _context8.n = 4;
33036
32994
  break;
33037
32995
  }
33038
32996
  throw _t3;
33039
32997
  case 4:
33040
- throw new ApacuanaAPIError("Failed to get document list (on-premise): ".concat(_t3.message));
32998
+ throw new ApacuanaAPIError("Failed to get document list (on-boarding): ".concat(_t3.message));
33041
32999
  case 5:
33000
+ return _context8.a(2);
33001
+ }
33002
+ }, _callee8, null, [[1, 3]]);
33003
+ }));
33004
+ return function getDocsOnBoarding(_x3) {
33005
+ return _ref8.apply(this, arguments);
33006
+ };
33007
+ }();
33008
+
33009
+ /**
33010
+ * Añade un firmante a un documento.
33011
+ * @param {SignerData} signerData - Los datos del firmante que se va a añadir.
33012
+ * @returns {Promise<AddSignerResponse>} Una promesa que resuelve a un objeto con el resultado de la operación.
33013
+ * @throws {ApacuanaAPIError} Si los datos del firmante son inválidos, la llamada a la API falla, o el tipo de integración no es soportado.
33014
+ */
33015
+ var addSigner = /*#__PURE__*/function () {
33016
+ var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(signerData) {
33017
+ var _getConfig4, integrationType;
33018
+ return _regenerator().w(function (_context1) {
33019
+ while (1) switch (_context1.n) {
33020
+ case 0:
33021
+ if (!(!signerData || _typeof(signerData) !== "object" || Object.keys(signerData).length === 0)) {
33022
+ _context1.n = 1;
33023
+ break;
33024
+ }
33025
+ throw new ApacuanaAPIError("Signer data (signerData) is required and must be a non-empty object.", 400, "INVALID_PARAMETER");
33026
+ case 1:
33027
+ _getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
33028
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33029
+ _context1.n = 2;
33030
+ break;
33031
+ }
33032
+ return _context1.a(2, addSignerOnBoarding(signerData));
33033
+ case 2:
33034
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33035
+ _context1.n = 3;
33036
+ break;
33037
+ }
33038
+ return _context1.a(2, addSignerOnPremise());
33039
+ case 3:
33040
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33041
+ case 4:
33042
33042
  return _context1.a(2);
33043
33043
  }
33044
- }, _callee1, null, [[1, 3]]);
33044
+ }, _callee1);
33045
33045
  }));
33046
- return function getDocsOnBoarding(_x5) {
33046
+ return function addSigner(_x5) {
33047
33047
  return _ref1.apply(this, arguments);
33048
33048
  };
33049
33049
  }();
33050
33050
 
33051
33051
  /**
33052
- * Gets a list of documents.
33053
- * @param {object} data - Object with pagination parameters. Must contain {page, size}.
33054
- * @returns {Promise<{totalRecords: number, records:any[], success: boolean}>} Object with the list of documents.
33055
- * @throws {ApacuanaAPIError} If pagination parameters are invalid, if 'customerId' is not configured, if the API call fails, or if the integration type is not supported.
33052
+ * Obtiene una lista de documentos basada en los filtros especificados.
33053
+ * @param {GetDocsParams} data - Objeto con parámetros de paginación y filtros.
33054
+ * @returns {Promise<GetDocsResponse>} Una promesa que resuelve a un objeto con la lista de documentos.
33055
+ * @throws {ApacuanaAPIError} Si los parámetros de paginación son inválidos, 'customerId' no está configurado, la llamada a la API falla, o el tipo de integración no es soportado.
33056
33056
  */
33057
33057
  var getDocs = /*#__PURE__*/function () {
33058
33058
  var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(data) {