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