apacuana-sdk-core 0.2.0 → 0.3.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/README.md +64 -15
- package/coverage/clover.xml +145 -111
- package/coverage/coverage-final.json +6 -6
- package/coverage/lcov-report/index.html +30 -30
- package/coverage/lcov-report/src/api/certs.js.html +73 -28
- package/coverage/lcov-report/src/api/index.html +31 -31
- package/coverage/lcov-report/src/api/revocations.js.html +1 -1
- package/coverage/lcov-report/src/api/signatures.js.html +186 -159
- package/coverage/lcov-report/src/api/users.js.html +24 -63
- package/coverage/lcov-report/src/config/index.html +1 -1
- package/coverage/lcov-report/src/config/index.js.html +1 -1
- package/coverage/lcov-report/src/errors/index.html +1 -1
- package/coverage/lcov-report/src/errors/index.js.html +8 -8
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.js.html +1 -1
- package/coverage/lcov-report/src/utils/constant.js.html +4 -4
- package/coverage/lcov-report/src/utils/helpers.js.html +101 -50
- package/coverage/lcov-report/src/utils/httpClient.js.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +19 -19
- package/coverage/lcov.info +277 -205
- package/dist/index.js +136 -242
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +136 -242
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/certs.js +25 -10
- package/src/api/signatures.js +106 -97
- package/src/api/users.js +16 -29
- package/src/utils/helpers.js +17 -0
- package/tests/api/certs.test.js +58 -74
- package/tests/api/signatures.test.js +18 -73
- package/tests/api/users.test.js +10 -10
package/dist/index.mjs
CHANGED
|
@@ -520,7 +520,7 @@ var httpRequest = /*#__PURE__*/function () {
|
|
|
520
520
|
* Este método es útil para endpoints que requieren datos en el cuerpo de la petición
|
|
521
521
|
* para buscar un usuario, como un ID de sesión o un token de acceso.
|
|
522
522
|
*
|
|
523
|
-
* @returns {Promise<object>} Objeto con los
|
|
523
|
+
* @returns {Promise<{token: string, userData: object, success: boolean}>} Objeto con el token de sesión, los datos del usuario y un indicador de éxito.
|
|
524
524
|
* @throws {Error} Si los parámetros de entrada son inválidos.
|
|
525
525
|
* @throws {ApacuanaAPIError} Si ocurre un error en la API de Apacuana.
|
|
526
526
|
*/
|
|
@@ -531,62 +531,46 @@ var getCustomer = /*#__PURE__*/function () {
|
|
|
531
531
|
while (1) switch (_context.p = _context.n) {
|
|
532
532
|
case 0:
|
|
533
533
|
_getConfig = getConfig(), verificationId = _getConfig.verificationId, customerId = _getConfig.customerId;
|
|
534
|
-
|
|
535
|
-
verificationid: verificationId,
|
|
536
|
-
customerid: customerId
|
|
537
|
-
}; // eslint-disable-next-line no-console
|
|
538
|
-
console.log("-> Función 'getCustomer' ejecutada.");
|
|
539
|
-
// eslint-disable-next-line no-console
|
|
540
|
-
console.log("Parámetros recibidos para buscar usuario:", body);
|
|
541
|
-
|
|
542
|
-
// 1. Validación de Parámetros de Entrada (Lado del SDK)
|
|
543
|
-
if (!(!body || !body.verificationid || !body.customerid)) {
|
|
534
|
+
if (!(!verificationId || !customerId)) {
|
|
544
535
|
_context.n = 1;
|
|
545
536
|
break;
|
|
546
537
|
}
|
|
547
|
-
throw new
|
|
538
|
+
throw new ApacuanaAPIError("Both 'verificationId' and 'customerId' must be configured.", 400, "CONFIGURATION_ERROR");
|
|
548
539
|
case 1:
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
"POST");
|
|
556
|
-
case
|
|
540
|
+
body = {
|
|
541
|
+
verificationid: verificationId,
|
|
542
|
+
customerid: customerId
|
|
543
|
+
};
|
|
544
|
+
_context.p = 2;
|
|
545
|
+
_context.n = 3;
|
|
546
|
+
return httpRequest("services/api/register/init", body, "POST");
|
|
547
|
+
case 3:
|
|
557
548
|
response = _context.v;
|
|
558
|
-
// 3. Procesar la Respuesta del Backend
|
|
559
|
-
// Asumiendo que la respuesta exitosa del backend incluye un objeto 'user'
|
|
560
|
-
// eslint-disable-next-line no-console
|
|
561
|
-
console.log("Respuesta del servidor para el token:", response);
|
|
562
549
|
if (!(!response.sessionid || !response.entry)) {
|
|
563
|
-
_context.n =
|
|
550
|
+
_context.n = 4;
|
|
564
551
|
break;
|
|
565
552
|
}
|
|
566
|
-
throw new ApacuanaAPIError("
|
|
567
|
-
case
|
|
553
|
+
throw new ApacuanaAPIError("The API response does not contain the user.", 200, "INVALID_API_RESPONSE");
|
|
554
|
+
case 4:
|
|
568
555
|
return _context.a(2, {
|
|
569
556
|
token: response.sessionid,
|
|
570
557
|
userData: response.entry,
|
|
571
558
|
success: true
|
|
572
559
|
});
|
|
573
|
-
case
|
|
574
|
-
_context.p =
|
|
560
|
+
case 5:
|
|
561
|
+
_context.p = 5;
|
|
575
562
|
_t = _context.v;
|
|
576
|
-
// 4. Manejo de Errores
|
|
577
|
-
// eslint-disable-next-line no-console
|
|
578
|
-
console.error("Error en getCustomer:", _t);
|
|
579
563
|
if (!(_t instanceof ApacuanaAPIError)) {
|
|
580
|
-
_context.n =
|
|
564
|
+
_context.n = 6;
|
|
581
565
|
break;
|
|
582
566
|
}
|
|
583
567
|
throw _t;
|
|
584
|
-
case 5:
|
|
585
|
-
throw new ApacuanaAPIError("Fallo inesperado al obtener el token: ".concat(_t.message || "Error desconocido"));
|
|
586
568
|
case 6:
|
|
569
|
+
throw new ApacuanaAPIError("Unexpected failure getting token: ".concat(_t.message || "Unknown error"));
|
|
570
|
+
case 7:
|
|
587
571
|
return _context.a(2);
|
|
588
572
|
}
|
|
589
|
-
}, _callee, null, [[
|
|
573
|
+
}, _callee, null, [[2, 5]]);
|
|
590
574
|
}));
|
|
591
575
|
return function getCustomer() {
|
|
592
576
|
return _ref.apply(this, arguments);
|
|
@@ -32769,6 +32753,11 @@ var validateGetDocsData = function validateGetDocsData(data) {
|
|
|
32769
32753
|
throw new ApacuanaAPIError("El parámetro 'status' no es válido. Los valores permitidos son: -1, 0, 1, 2.", 400, "INVALID_PARAMETER");
|
|
32770
32754
|
}
|
|
32771
32755
|
};
|
|
32756
|
+
var validateGetDigestData = function validateGetDigestData(signData) {
|
|
32757
|
+
if (!signData || !signData.cert || typeof signData.cert !== "string" || !signData.signatureId || typeof signData.signatureId !== "string") {
|
|
32758
|
+
throw new ApacuanaAPIError("Los parámetros 'cert' y 'signatureId' son requeridos y deben ser cadenas de texto.", 400, "INVALID_PARAMETER");
|
|
32759
|
+
}
|
|
32760
|
+
};
|
|
32772
32761
|
var helpers = {
|
|
32773
32762
|
getCertificateStatus: getCertificateStatus,
|
|
32774
32763
|
exportPrivateKey: exportPrivateKey,
|
|
@@ -32776,9 +32765,15 @@ var helpers = {
|
|
|
32776
32765
|
encryptedCsr: encryptedCsr,
|
|
32777
32766
|
validateOnBoardingSignerData: validateOnBoardingSignerData,
|
|
32778
32767
|
validateCsr: validateCsr,
|
|
32779
|
-
validateGetDocsData: validateGetDocsData
|
|
32768
|
+
validateGetDocsData: validateGetDocsData,
|
|
32769
|
+
validateGetDigestData: validateGetDigestData
|
|
32780
32770
|
};
|
|
32781
32771
|
|
|
32772
|
+
/**
|
|
32773
|
+
* Gets the user's certificate status.
|
|
32774
|
+
* @param {boolean} [isCertificateInDevice=false] - Indicates if the certificate is already on the device.
|
|
32775
|
+
* @returns {{status: string, success: boolean}} Object with the certificate status and a success indicator.
|
|
32776
|
+
*/
|
|
32782
32777
|
var getCertStatus = function getCertStatus() {
|
|
32783
32778
|
var isCertificateInDevice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
32784
32779
|
var config = getConfig();
|
|
@@ -32789,299 +32784,198 @@ var getCertStatus = function getCertStatus() {
|
|
|
32789
32784
|
};
|
|
32790
32785
|
};
|
|
32791
32786
|
|
|
32792
|
-
/*
|
|
32793
|
-
const signDocumentOnBoarding = async (documentData, signatureData) => {
|
|
32794
|
-
try {
|
|
32795
|
-
const response = await httpRequest(
|
|
32796
|
-
"/docs/sign",
|
|
32797
|
-
{ documentData, signatureData },
|
|
32798
|
-
"POST"
|
|
32799
|
-
);
|
|
32800
|
-
if (!response.success) {
|
|
32801
|
-
throw new ApacuanaAPIError(
|
|
32802
|
-
response.message || "Error desconocido al firmar documento."
|
|
32803
|
-
);
|
|
32804
|
-
}
|
|
32805
|
-
return { signedDocId: response.id, status: response.message };
|
|
32806
|
-
} catch (error) {
|
|
32807
|
-
if (error.name === "ApacuanaAPIError") {
|
|
32808
|
-
throw error;
|
|
32809
|
-
}
|
|
32810
|
-
throw new ApacuanaAPIError(
|
|
32811
|
-
`Fallo en la firma del documento (on-boarding): ${error.message}`
|
|
32812
|
-
);
|
|
32813
|
-
}
|
|
32814
|
-
};
|
|
32815
|
-
|
|
32816
|
-
const signDocumentOnPremise = async (signature, cert, privateKey) => {
|
|
32817
|
-
helpers.validateSignOnPremiseData({ signature, cert, privateKey });
|
|
32818
|
-
try {
|
|
32819
|
-
const digestBody = {
|
|
32820
|
-
publickey: cert,
|
|
32821
|
-
};
|
|
32822
|
-
|
|
32823
|
-
const digestResponse = await httpRequest(
|
|
32824
|
-
`services/api/documents/getdigest/${signature.id}`,
|
|
32825
|
-
digestBody,
|
|
32826
|
-
"POST"
|
|
32827
|
-
);
|
|
32828
|
-
|
|
32829
|
-
const digest = digestResponse.data?.digest || digestResponse.digest;
|
|
32830
|
-
if (!digest) {
|
|
32831
|
-
throw new ApacuanaAPIError(
|
|
32832
|
-
"La generación de firma ha fallado: no se pudo obtener el digest del documento."
|
|
32833
|
-
);
|
|
32834
|
-
}
|
|
32835
|
-
|
|
32836
|
-
const signedDigest = await helpers.signDigest(digest, privateKey);
|
|
32837
|
-
|
|
32838
|
-
const signBody = {
|
|
32839
|
-
positions: JSON.stringify(
|
|
32840
|
-
signature.positions.map((p) => ({
|
|
32841
|
-
x: p.x,
|
|
32842
|
-
y: p.y,
|
|
32843
|
-
page: p.page,
|
|
32844
|
-
status: 1,
|
|
32845
|
-
}))
|
|
32846
|
-
),
|
|
32847
|
-
publickey: cert,
|
|
32848
|
-
signeddigest: signedDigest,
|
|
32849
|
-
};
|
|
32850
|
-
|
|
32851
|
-
const signResponse = await httpRequest(
|
|
32852
|
-
`services/api/documents/sign/${signature.id}`,
|
|
32853
|
-
signBody,
|
|
32854
|
-
"PUT"
|
|
32855
|
-
);
|
|
32856
|
-
|
|
32857
|
-
return signResponse;
|
|
32858
|
-
} catch (error) {
|
|
32859
|
-
if (error.name === "ApacuanaAPIError") {
|
|
32860
|
-
throw error;
|
|
32861
|
-
}
|
|
32862
|
-
throw new ApacuanaAPIError(
|
|
32863
|
-
`Fallo en la firma del documento (on-premise): ${error.message}`
|
|
32864
|
-
);
|
|
32865
|
-
}
|
|
32866
|
-
};
|
|
32867
|
-
*/
|
|
32868
|
-
|
|
32869
|
-
/**
|
|
32870
|
-
* Firma un documento PDF con un certificado digital.
|
|
32871
|
-
* @param {object} data - Datos para la firma. Para 'on-boarding', debe contener {documentData, signatureData}. Para 'on-premise', debe contener {signature, cert, privateKey}.
|
|
32872
|
-
* @returns {Promise<object>} Objeto con el resultado de la firma.
|
|
32873
|
-
*/
|
|
32874
|
-
/*
|
|
32875
|
-
export const signDocument = async (signData) => {
|
|
32876
|
-
if (
|
|
32877
|
-
!signData ||
|
|
32878
|
-
typeof signData !== "object" ||
|
|
32879
|
-
Object.keys(signData).length === 0
|
|
32880
|
-
) {
|
|
32881
|
-
throw new ApacuanaAPIError(
|
|
32882
|
-
"El parámetro 'data' es requerido y debe ser un objeto no vacío.",
|
|
32883
|
-
400,
|
|
32884
|
-
"INVALID_PARAMETER"
|
|
32885
|
-
);
|
|
32886
|
-
}
|
|
32887
|
-
|
|
32888
|
-
const { integrationType } = getConfig();
|
|
32889
|
-
|
|
32890
|
-
if (integrationType === INTEGRATION_TYPE.ONBOARDING) {
|
|
32891
|
-
return signDocumentOnBoarding(signData);
|
|
32892
|
-
}
|
|
32893
|
-
|
|
32894
|
-
if (integrationType === INTEGRATION_TYPE.ONPREMISE) {
|
|
32895
|
-
return signDocumentOnPremise(signData);
|
|
32896
|
-
}
|
|
32897
|
-
|
|
32898
|
-
throw new ApacuanaAPIError(
|
|
32899
|
-
`Tipo de integración no soportado: ${integrationType}`,
|
|
32900
|
-
400,
|
|
32901
|
-
"UNSUPPORTED_INTEGRATION_TYPE"
|
|
32902
|
-
);
|
|
32903
|
-
};
|
|
32904
|
-
*/
|
|
32905
|
-
|
|
32906
32787
|
var addSignerOnBoarding = /*#__PURE__*/function () {
|
|
32907
|
-
var
|
|
32908
|
-
var
|
|
32909
|
-
return _regenerator().w(function (
|
|
32910
|
-
while (1) switch (
|
|
32788
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(signerData) {
|
|
32789
|
+
var _t2;
|
|
32790
|
+
return _regenerator().w(function (_context7) {
|
|
32791
|
+
while (1) switch (_context7.p = _context7.n) {
|
|
32911
32792
|
case 0:
|
|
32912
32793
|
helpers.validateOnBoardingSignerData(signerData);
|
|
32913
|
-
|
|
32914
|
-
|
|
32794
|
+
_context7.p = 1;
|
|
32795
|
+
_context7.n = 2;
|
|
32915
32796
|
return httpRequest("services/api/documents/signing", signerData, "POST");
|
|
32916
32797
|
case 2:
|
|
32917
|
-
return
|
|
32798
|
+
return _context7.a(2, {
|
|
32918
32799
|
signer: signerData.typedoc + signerData.doc,
|
|
32919
32800
|
success: true
|
|
32920
32801
|
});
|
|
32921
32802
|
case 3:
|
|
32922
|
-
|
|
32923
|
-
|
|
32924
|
-
if (!(
|
|
32925
|
-
|
|
32803
|
+
_context7.p = 3;
|
|
32804
|
+
_t2 = _context7.v;
|
|
32805
|
+
if (!(_t2 instanceof ApacuanaAPIError)) {
|
|
32806
|
+
_context7.n = 4;
|
|
32926
32807
|
break;
|
|
32927
32808
|
}
|
|
32928
|
-
throw
|
|
32809
|
+
throw _t2;
|
|
32929
32810
|
case 4:
|
|
32930
|
-
throw new Error("
|
|
32811
|
+
throw new Error("Failed to add signer in On-Boarding: ".concat(_t2.message));
|
|
32931
32812
|
case 5:
|
|
32932
|
-
return
|
|
32813
|
+
return _context7.a(2);
|
|
32933
32814
|
}
|
|
32934
|
-
},
|
|
32815
|
+
}, _callee7, null, [[1, 3]]);
|
|
32935
32816
|
}));
|
|
32936
|
-
return function addSignerOnBoarding(
|
|
32937
|
-
return
|
|
32817
|
+
return function addSignerOnBoarding(_x3) {
|
|
32818
|
+
return _ref7.apply(this, arguments);
|
|
32938
32819
|
};
|
|
32939
32820
|
}();
|
|
32940
32821
|
var addSignerOnPremise = /*#__PURE__*/function () {
|
|
32941
|
-
var
|
|
32942
|
-
return _regenerator().w(function (
|
|
32943
|
-
while (1) switch (
|
|
32822
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
32823
|
+
return _regenerator().w(function (_context8) {
|
|
32824
|
+
while (1) switch (_context8.n) {
|
|
32944
32825
|
case 0:
|
|
32945
|
-
|
|
32946
|
-
|
|
32947
|
-
|
|
32948
|
-
}));
|
|
32826
|
+
throw new ApacuanaAPIError("Adding signers is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
|
|
32827
|
+
case 1:
|
|
32828
|
+
return _context8.a(2);
|
|
32949
32829
|
}
|
|
32950
|
-
},
|
|
32830
|
+
}, _callee8);
|
|
32951
32831
|
}));
|
|
32952
32832
|
return function addSignerOnPremise() {
|
|
32953
|
-
return
|
|
32833
|
+
return _ref8.apply(this, arguments);
|
|
32954
32834
|
};
|
|
32955
32835
|
}();
|
|
32956
32836
|
|
|
32957
32837
|
/**
|
|
32958
|
-
*
|
|
32959
|
-
* @param {object} signerData -
|
|
32960
|
-
* @returns {Promise<
|
|
32838
|
+
* Adds a signer to a document, handling different integration types.
|
|
32839
|
+
* @param {object} signerData - Data of the signer to be added.
|
|
32840
|
+
* @returns {Promise<{signer: string, success: boolean}>} Object with the result of adding the signer.
|
|
32841
|
+
* @throws {ApacuanaAPIError} If the signer data is invalid, if the API call fails, or if the integration type is not supported.
|
|
32961
32842
|
*/
|
|
32962
32843
|
var addSigner = /*#__PURE__*/function () {
|
|
32963
|
-
var
|
|
32964
|
-
var
|
|
32965
|
-
return _regenerator().w(function (
|
|
32966
|
-
while (1) switch (
|
|
32844
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(signerData) {
|
|
32845
|
+
var _getConfig3, integrationType;
|
|
32846
|
+
return _regenerator().w(function (_context9) {
|
|
32847
|
+
while (1) switch (_context9.n) {
|
|
32967
32848
|
case 0:
|
|
32968
32849
|
if (!(!signerData || _typeof(signerData) !== "object" || Object.keys(signerData).length === 0)) {
|
|
32969
|
-
|
|
32850
|
+
_context9.n = 1;
|
|
32970
32851
|
break;
|
|
32971
32852
|
}
|
|
32972
|
-
throw new ApacuanaAPIError("
|
|
32853
|
+
throw new ApacuanaAPIError("Signer data (signerData) is required and must be a non-empty object.", 400, "INVALID_PARAMETER");
|
|
32973
32854
|
case 1:
|
|
32974
|
-
|
|
32855
|
+
_getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
|
|
32975
32856
|
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
32976
|
-
|
|
32857
|
+
_context9.n = 2;
|
|
32977
32858
|
break;
|
|
32978
32859
|
}
|
|
32979
|
-
return
|
|
32860
|
+
return _context9.a(2, addSignerOnBoarding(signerData));
|
|
32980
32861
|
case 2:
|
|
32981
32862
|
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
32982
|
-
|
|
32863
|
+
_context9.n = 3;
|
|
32983
32864
|
break;
|
|
32984
32865
|
}
|
|
32985
|
-
return
|
|
32866
|
+
return _context9.a(2, addSignerOnPremise(signerData));
|
|
32986
32867
|
case 3:
|
|
32987
|
-
throw new ApacuanaAPIError("
|
|
32868
|
+
throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
|
|
32988
32869
|
case 4:
|
|
32989
|
-
return
|
|
32870
|
+
return _context9.a(2);
|
|
32990
32871
|
}
|
|
32991
|
-
},
|
|
32872
|
+
}, _callee9);
|
|
32992
32873
|
}));
|
|
32993
|
-
return function addSigner(
|
|
32994
|
-
return
|
|
32874
|
+
return function addSigner(_x4) {
|
|
32875
|
+
return _ref9.apply(this, arguments);
|
|
32995
32876
|
};
|
|
32996
32877
|
}();
|
|
32997
32878
|
var getDocsOnPremise = /*#__PURE__*/function () {
|
|
32998
|
-
var
|
|
32999
|
-
return _regenerator().w(function (
|
|
33000
|
-
while (1) switch (
|
|
32879
|
+
var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
32880
|
+
return _regenerator().w(function (_context0) {
|
|
32881
|
+
while (1) switch (_context0.n) {
|
|
33001
32882
|
case 0:
|
|
33002
|
-
throw new ApacuanaAPIError("
|
|
32883
|
+
throw new ApacuanaAPIError("Document retrieval is not supported for integration type: ONBOARDING", 501, "NOT_IMPLEMENTED");
|
|
33003
32884
|
case 1:
|
|
33004
|
-
return
|
|
32885
|
+
return _context0.a(2);
|
|
33005
32886
|
}
|
|
33006
|
-
},
|
|
32887
|
+
}, _callee0);
|
|
33007
32888
|
}));
|
|
33008
32889
|
return function getDocsOnPremise() {
|
|
33009
|
-
return
|
|
32890
|
+
return _ref0.apply(this, arguments);
|
|
33010
32891
|
};
|
|
33011
32892
|
}();
|
|
33012
32893
|
var getDocsOnBoarding = /*#__PURE__*/function () {
|
|
33013
|
-
var
|
|
33014
|
-
var
|
|
33015
|
-
return _regenerator().w(function (
|
|
33016
|
-
while (1) switch (
|
|
32894
|
+
var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(data) {
|
|
32895
|
+
var _getConfig4, customerId, params, apiUrl, response, _t3;
|
|
32896
|
+
return _regenerator().w(function (_context1) {
|
|
32897
|
+
while (1) switch (_context1.p = _context1.n) {
|
|
33017
32898
|
case 0:
|
|
33018
|
-
|
|
32899
|
+
_getConfig4 = getConfig(), customerId = _getConfig4.customerId;
|
|
33019
32900
|
if (customerId) {
|
|
33020
|
-
|
|
32901
|
+
_context1.n = 1;
|
|
33021
32902
|
break;
|
|
33022
32903
|
}
|
|
33023
|
-
throw new ApacuanaAPIError("
|
|
32904
|
+
throw new ApacuanaAPIError("'customerId' is not configured. Please configure the SDK.", 400, "CONFIGURATION_ERROR");
|
|
33024
32905
|
case 1:
|
|
33025
|
-
|
|
33026
|
-
|
|
33027
|
-
|
|
32906
|
+
_context1.p = 1;
|
|
32907
|
+
params = new URLSearchParams({
|
|
32908
|
+
page: data.page,
|
|
32909
|
+
customerid: customerId,
|
|
32910
|
+
size: data.size
|
|
32911
|
+
});
|
|
32912
|
+
if (typeof data.status !== "undefined") {
|
|
32913
|
+
params.append("status", data.status);
|
|
32914
|
+
}
|
|
32915
|
+
apiUrl = "services/api/documents/listcustomer?".concat(params.toString());
|
|
32916
|
+
_context1.n = 2;
|
|
33028
32917
|
return httpRequest(apiUrl, {}, "GET");
|
|
33029
32918
|
case 2:
|
|
33030
|
-
response =
|
|
33031
|
-
return
|
|
32919
|
+
response = _context1.v;
|
|
32920
|
+
return _context1.a(2, {
|
|
32921
|
+
totalRecords: response.numofrecords,
|
|
32922
|
+
records: response.records,
|
|
32923
|
+
success: true
|
|
32924
|
+
});
|
|
33032
32925
|
case 3:
|
|
33033
|
-
|
|
33034
|
-
|
|
33035
|
-
if (!(
|
|
33036
|
-
|
|
32926
|
+
_context1.p = 3;
|
|
32927
|
+
_t3 = _context1.v;
|
|
32928
|
+
if (!(_t3.name === "ApacuanaAPIError")) {
|
|
32929
|
+
_context1.n = 4;
|
|
33037
32930
|
break;
|
|
33038
32931
|
}
|
|
33039
|
-
throw
|
|
32932
|
+
throw _t3;
|
|
33040
32933
|
case 4:
|
|
33041
|
-
throw new ApacuanaAPIError("
|
|
32934
|
+
throw new ApacuanaAPIError("Failed to get document list (on-premise): ".concat(_t3.message));
|
|
33042
32935
|
case 5:
|
|
33043
|
-
return
|
|
32936
|
+
return _context1.a(2);
|
|
33044
32937
|
}
|
|
33045
|
-
},
|
|
32938
|
+
}, _callee1, null, [[1, 3]]);
|
|
33046
32939
|
}));
|
|
33047
|
-
return function getDocsOnBoarding(
|
|
33048
|
-
return
|
|
32940
|
+
return function getDocsOnBoarding(_x5) {
|
|
32941
|
+
return _ref1.apply(this, arguments);
|
|
33049
32942
|
};
|
|
33050
32943
|
}();
|
|
33051
32944
|
|
|
33052
32945
|
/**
|
|
33053
|
-
*
|
|
33054
|
-
* @param {object} data -
|
|
33055
|
-
* @returns {Promise<
|
|
32946
|
+
* Gets a list of documents.
|
|
32947
|
+
* @param {object} data - Object with pagination parameters. Must contain {page, size}.
|
|
32948
|
+
* @returns {Promise<{totalRecords: number, records:any[], success: boolean}>} Object with the list of documents.
|
|
32949
|
+
* @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.
|
|
33056
32950
|
*/
|
|
33057
32951
|
var getDocs = /*#__PURE__*/function () {
|
|
33058
|
-
var
|
|
33059
|
-
var
|
|
33060
|
-
return _regenerator().w(function (
|
|
33061
|
-
while (1) switch (
|
|
32952
|
+
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(data) {
|
|
32953
|
+
var _getConfig5, integrationType;
|
|
32954
|
+
return _regenerator().w(function (_context10) {
|
|
32955
|
+
while (1) switch (_context10.n) {
|
|
33062
32956
|
case 0:
|
|
33063
32957
|
helpers.validateGetDocsData(data);
|
|
33064
|
-
|
|
32958
|
+
_getConfig5 = getConfig(), integrationType = _getConfig5.integrationType;
|
|
33065
32959
|
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
33066
|
-
|
|
32960
|
+
_context10.n = 1;
|
|
33067
32961
|
break;
|
|
33068
32962
|
}
|
|
33069
|
-
return
|
|
32963
|
+
return _context10.a(2, getDocsOnBoarding(data));
|
|
33070
32964
|
case 1:
|
|
33071
32965
|
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
33072
|
-
|
|
32966
|
+
_context10.n = 2;
|
|
33073
32967
|
break;
|
|
33074
32968
|
}
|
|
33075
|
-
return
|
|
32969
|
+
return _context10.a(2, getDocsOnPremise());
|
|
33076
32970
|
case 2:
|
|
33077
|
-
throw new ApacuanaAPIError("
|
|
32971
|
+
throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
|
|
33078
32972
|
case 3:
|
|
33079
|
-
return
|
|
32973
|
+
return _context10.a(2);
|
|
33080
32974
|
}
|
|
33081
|
-
},
|
|
32975
|
+
}, _callee10);
|
|
33082
32976
|
}));
|
|
33083
|
-
return function getDocs(
|
|
33084
|
-
return
|
|
32977
|
+
return function getDocs(_x6) {
|
|
32978
|
+
return _ref10.apply(this, arguments);
|
|
33085
32979
|
};
|
|
33086
32980
|
}();
|
|
33087
32981
|
|