dcos-core-monalisav2-latam 1.0.3 → 1.1.1
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/index.js +3 -1
- package/package.json +4 -5
- package/src/common/utils/util.js +17 -2
- package/src/functions/account/clients.js +2 -1
- package/src/functions/account/index.js +1 -1
- package/src/functions/clients/clients-audience.js +0 -1
- package/src/functions/clients/clients-producer.js +8 -8
- package/src/functions/distributors/distributor.js +7 -6
- package/src/functions/financialpolicy/assign-financialpolicy.js +3 -2
- package/src/functions/financialpolicy/get-financialpolicy.js +4 -3
- package/src/functions/inventory/inventory-producer.js +3 -2
- package/src/functions/multiPresentation/multipres.js +2 -3
- package/src/functions/orders/orders-cancel-handler.js +4 -2
- package/src/functions/orders/orders-handler.js +2 -1
- package/src/functions/orders/orders-notifications-handler.js +2 -1
- package/src/functions/orders/orders-status-producer.js +3 -3
- package/src/functions/prices/prices-producer.js +2 -2
- package/src/functions/prices/promotion-and-tax.js +5 -4
- package/src/functions/sftpIntegrations/sftp-config-producer.js +2 -1
- package/src/functions/vtex/vtex-helpers.js +4 -3
- package/src/auth/handler.js +0 -3
package/index.js
CHANGED
|
@@ -347,4 +347,6 @@ const clientConstructor = {
|
|
|
347
347
|
clients_product_queue,
|
|
348
348
|
};
|
|
349
349
|
|
|
350
|
-
|
|
350
|
+
const authservicesall = require("dcos-sls-auth-app");
|
|
351
|
+
|
|
352
|
+
module.exports = { ...clientConstructor, ...clientFuntions, ...authservicesall };
|
package/package.json
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dcos-core-monalisav2-latam",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"devDependencies": {
|
|
5
|
-
},
|
|
3
|
+
"version": "1.1.1",
|
|
6
4
|
"scripts": {
|
|
7
5
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
6
|
},
|
|
@@ -24,13 +22,14 @@
|
|
|
24
22
|
"adm-zip": "^0.5.16",
|
|
25
23
|
"archiver": "^7.0.1",
|
|
26
24
|
"aws-multipart-parser": "^0.2.1",
|
|
25
|
+
"aws-sdk": "^2.1693.0",
|
|
27
26
|
"aws-sdk-mock": "^6.2.0",
|
|
28
27
|
"axios": "^1.3.4",
|
|
29
28
|
"cron-parser": "^4.9.0",
|
|
30
29
|
"csv": "^6.3.0",
|
|
31
30
|
"csv-parser": "^3.0.0",
|
|
32
31
|
"csvtojson": "^2.0.10",
|
|
33
|
-
"dcos-sls-auth-app": "
|
|
32
|
+
"dcos-sls-auth-app": "1.0.x",
|
|
34
33
|
"dotenv": "^10.0.0",
|
|
35
34
|
"ftp": "^0.3.10",
|
|
36
35
|
"json-2-csv": "^5.5.1",
|
|
@@ -42,7 +41,7 @@
|
|
|
42
41
|
"moment": "^2.30.1",
|
|
43
42
|
"node-cron": "^3.0.0",
|
|
44
43
|
"node-fetch": "^3.2.10",
|
|
45
|
-
"node-flow-br": "
|
|
44
|
+
"node-flow-br-2": "1.0.x",
|
|
46
45
|
"nodemailer": "^6.8.0",
|
|
47
46
|
"parse-multipart": "^1.0.4",
|
|
48
47
|
"ssh2-sftp-client": "^12.0.0",
|
package/src/common/utils/util.js
CHANGED
|
@@ -11,7 +11,7 @@ const Logger = require("./logger");
|
|
|
11
11
|
|
|
12
12
|
const roundPrice = (price, roundUpDecimalPrice) => {
|
|
13
13
|
const { roundUpAmountDecimal = 2, typeRounded = 'default' } = roundUpDecimalPrice;
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
// Factor para determinar los decimales
|
|
16
16
|
const factor = Math.pow(10, roundUpAmountDecimal);
|
|
17
17
|
const scaledPrice = price * factor;
|
|
@@ -217,6 +217,20 @@ const setQueryParams = (url, queryParams) => {
|
|
|
217
217
|
return url + queryText
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
/**
|
|
221
|
+
*
|
|
222
|
+
* @param {*} event
|
|
223
|
+
* @returns
|
|
224
|
+
*/
|
|
225
|
+
const getClaimsData = (event) => {
|
|
226
|
+
const { client_id, scope, claims } = event?.requestContext?.authorizer ?? {};
|
|
227
|
+
// Se valida si existe la propiedad "claims" para retornar los valores respectivos
|
|
228
|
+
if (claims?.client_id && claims?.scope) {
|
|
229
|
+
return claims;
|
|
230
|
+
}
|
|
231
|
+
return { client_id, scope };
|
|
232
|
+
}
|
|
233
|
+
|
|
220
234
|
module.exports = {
|
|
221
235
|
delayToProcess: delayToProcess,
|
|
222
236
|
convertDecimal: convertDecimal,
|
|
@@ -232,5 +246,6 @@ module.exports = {
|
|
|
232
246
|
getErrorData,
|
|
233
247
|
getDateValues,
|
|
234
248
|
setQueryParams,
|
|
235
|
-
roundPrice
|
|
249
|
+
roundPrice,
|
|
250
|
+
getClaimsData
|
|
236
251
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const client = require('../../entities/clients');
|
|
2
2
|
const ApiResponse = require("../../common/utils/api-response");
|
|
3
|
+
const { getClaimsData } = require('../../common/utils/util');
|
|
3
4
|
|
|
4
5
|
const handler = async (event) => {
|
|
5
|
-
const clientId = event
|
|
6
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
6
7
|
const listAccounts = await client.getListAccountByClient(clientId);
|
|
7
8
|
return ApiResponse.responseNoCors(200, listAccounts);
|
|
8
9
|
};
|
|
@@ -7,7 +7,7 @@ const getHandlers = require("../../common/utils/cron-ftp-get");
|
|
|
7
7
|
const sftp_schemas_file = require("../sftpIntegrations/schemas/record-schema");
|
|
8
8
|
const credential_schema = require("../sftpIntegrations/schemas/credential-schema");
|
|
9
9
|
const handle_schemas = require("../schemas/vtex/handle-schemas");
|
|
10
|
-
const clientauthadmin = require("
|
|
10
|
+
const clientauthadmin = require("dcos-sls-auth-app");
|
|
11
11
|
|
|
12
12
|
module.exports.handler = async (req, res) => {
|
|
13
13
|
const resource = req?.resource ?? null;
|
|
@@ -9,7 +9,6 @@ const Logger = require("../../common/utils/logger");
|
|
|
9
9
|
* @returns {Promise<ApiResponse>}
|
|
10
10
|
*/
|
|
11
11
|
const handler = async (event) => {
|
|
12
|
-
const { client_id: clientId } = event.requestContext.authorizer.claims || {};
|
|
13
12
|
const email = event?.queryStringParameters?.email ? decodeURIComponent(event.queryStringParameters.email.trim().replace(/\s/g, "+")) : null;
|
|
14
13
|
const accountNameURL = event?.queryStringParameters?.an ? event?.queryStringParameters?.an : null;
|
|
15
14
|
const accountName = accountNameURL || null;
|
|
@@ -8,6 +8,7 @@ const Logger = require("../../common/utils/logger");
|
|
|
8
8
|
const VtexApi = require("../../vtex/clients/VtexApi");
|
|
9
9
|
|
|
10
10
|
const suggestedProductMdlz = require("./helpers/suggested-product-mdlz");
|
|
11
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
11
12
|
|
|
12
13
|
const LIMIT_ITEMS_TO_PROCESS = process?.env?.LIMIT_ITEMS_TO_PROCESS || 150;
|
|
13
14
|
const SQS_CLIENT_QUEUE_URL = process.env.SQS_CLIENT_QUEUE_URL;
|
|
@@ -49,8 +50,7 @@ const handleCreateClient = async (event) => {
|
|
|
49
50
|
Logger.log(JSON.stringify(event));
|
|
50
51
|
const request = JSON.parse(event.body);
|
|
51
52
|
|
|
52
|
-
const
|
|
53
|
-
const scope = event?.requestContext?.authorizer?.claims?.scope;
|
|
53
|
+
const { client_id, scope } = getClaimsData(event);
|
|
54
54
|
const accountName = request?.an;
|
|
55
55
|
const clients = request?.clients;
|
|
56
56
|
|
|
@@ -61,9 +61,9 @@ const handleCreateClient = async (event) => {
|
|
|
61
61
|
|
|
62
62
|
if (!event?.internalService) {
|
|
63
63
|
if (!scope?.includes("admin")) {
|
|
64
|
-
const validateAccount = await ClientData.validateAccount(
|
|
64
|
+
const validateAccount = await ClientData.validateAccount(client_id, accountName);
|
|
65
65
|
if (!validateAccount) {
|
|
66
|
-
Logger.error("Account not found: ", accountName, ". ClientId: ",
|
|
66
|
+
Logger.error("Account not found: ", accountName, ". ClientId: ", client_id);
|
|
67
67
|
return ApiResponse.response(404, "Account not found");
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -132,16 +132,16 @@ const handleCreateClient = async (event) => {
|
|
|
132
132
|
};
|
|
133
133
|
|
|
134
134
|
const handleFindClients = async (event) => {
|
|
135
|
-
const { headers, pathParameters, queryStringParameters, internalService
|
|
135
|
+
const { headers, pathParameters, queryStringParameters, internalService } = event;
|
|
136
136
|
const { an: accountName, method } = pathParameters;
|
|
137
137
|
|
|
138
|
-
const { client_id
|
|
138
|
+
const { client_id, scope } = getClaimsData(event);
|
|
139
139
|
|
|
140
140
|
if (!internalService) {
|
|
141
141
|
if (!scope?.includes("admin")) {
|
|
142
|
-
const validateAccount = await ClientData.validateAccount(
|
|
142
|
+
const validateAccount = await ClientData.validateAccount(client_id, accountName);
|
|
143
143
|
if (!validateAccount) {
|
|
144
|
-
Logger.error("Account not found: ", accountName, ". ClientId: ",
|
|
144
|
+
Logger.error("Account not found: ", accountName, ". ClientId: ", client_id);
|
|
145
145
|
return ApiResponse.response(404, "Account not found");
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -2,6 +2,7 @@ const ApiResponse = require("../../common/utils/api-response");
|
|
|
2
2
|
const { DynamoDB } = require("aws-sdk");
|
|
3
3
|
const ClientData = require("../../entities/clients");
|
|
4
4
|
const Logger = require("../../common/utils/logger");
|
|
5
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
5
6
|
|
|
6
7
|
const dynamoDb = new DynamoDB.DocumentClient();
|
|
7
8
|
const SKU_DATA_DISTRIBUTOR_TABLE = process?.env?.SKU_DATA_DISTRIBUTOR_TABLE;
|
|
@@ -74,7 +75,7 @@ async function createDistributorCodeTemplate(accountNameAndSkuDis, accountName,
|
|
|
74
75
|
async function createDistributorCode(event) {
|
|
75
76
|
try {
|
|
76
77
|
const request = JSON.parse(event.body);
|
|
77
|
-
const clientId = event
|
|
78
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
78
79
|
const requestDataArray = Array.isArray(request) ? request : [request];
|
|
79
80
|
|
|
80
81
|
for (const requestData of requestDataArray) {
|
|
@@ -110,7 +111,7 @@ async function createDistributorCode(event) {
|
|
|
110
111
|
async function createOrUpdateDistributorCodes(event) {
|
|
111
112
|
try {
|
|
112
113
|
const request = JSON.parse(event.body);
|
|
113
|
-
const clientId = event
|
|
114
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
114
115
|
|
|
115
116
|
// Array to store the log messages
|
|
116
117
|
const logMessages = [];
|
|
@@ -206,7 +207,7 @@ async function updateDistributorCodeTemplate(accountNameAndSkuDis, accountName,
|
|
|
206
207
|
*/
|
|
207
208
|
async function updateDistributorCode(event) {
|
|
208
209
|
try {
|
|
209
|
-
const clientId = event
|
|
210
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
210
211
|
const distributorCode = event?.pathParameters?.id;
|
|
211
212
|
const accountName = distributorCode.split('-')[0];
|
|
212
213
|
const isValid = await ClientData.validateAccount(clientId, accountName);
|
|
@@ -243,7 +244,7 @@ async function updateDistributorCode(event) {
|
|
|
243
244
|
*/
|
|
244
245
|
async function deleteDistributorCode(event) {
|
|
245
246
|
try {
|
|
246
|
-
const clientId = event
|
|
247
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
247
248
|
const distributorCode = event?.pathParameters?.id;
|
|
248
249
|
const accountName = distributorCode.split('-')[0];
|
|
249
250
|
const isValid = await ClientData.validateAccount(clientId, accountName);
|
|
@@ -332,7 +333,7 @@ async function getAllItemsByAccountName(accountName) {
|
|
|
332
333
|
*/
|
|
333
334
|
async function getAllDistributorsCodes(event) {
|
|
334
335
|
try {
|
|
335
|
-
const clientId = event
|
|
336
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
336
337
|
const accountName = event?.queryStringParameters?.accountName;
|
|
337
338
|
|
|
338
339
|
let params = {
|
|
@@ -384,7 +385,7 @@ async function getAllDistributorsCodes(event) {
|
|
|
384
385
|
*/
|
|
385
386
|
async function getDistributorByCode(event) {
|
|
386
387
|
try {
|
|
387
|
-
const clientId = event
|
|
388
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
388
389
|
const distributorCode = event?.pathParameters?.id;
|
|
389
390
|
const accountName = distributorCode.split('-')[0];
|
|
390
391
|
const isValid = await ClientData.validateAccount(clientId, accountName);
|
|
@@ -4,6 +4,7 @@ const ClientData = require("../../entities/clients");
|
|
|
4
4
|
const MobilvendorApi = require("../../integrations/mobilvendor/MobilvendorApi");
|
|
5
5
|
const FinancialPolicyApi = require("../../integrations/financialPolicy/FinancialPolicyApi");
|
|
6
6
|
const Logger = require("../../common/utils/logger");
|
|
7
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @param {import("aws-lambda").APIGatewayProxyEvent} event
|
|
@@ -16,7 +17,7 @@ const Logger = require("../../common/utils/logger");
|
|
|
16
17
|
|
|
17
18
|
const handler = async (event) => {
|
|
18
19
|
const { orderFormId } = event.pathParameters;
|
|
19
|
-
const { client_id: clientId } = event
|
|
20
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
20
21
|
const { assign = true, creditDays = 0 } = JSON.parse(event.body) || {};
|
|
21
22
|
try {
|
|
22
23
|
const listAccounts = await ClientData.getClient(clientId);
|
|
@@ -65,7 +66,7 @@ const handler = async (event) => {
|
|
|
65
66
|
const configAccountWl = await AccountData.getAccountDataByAccountName(accountNameWl);
|
|
66
67
|
if (configAccountWl?.FinancialPolicyEcu && responseApi.setConfig) {
|
|
67
68
|
responseApi.setConfig(configAccountWl.FinancialPolicyEcu);
|
|
68
|
-
} else if(!responseApi.setConfig) {
|
|
69
|
+
} else if (!responseApi.setConfig) {
|
|
69
70
|
return ApiResponse.response(400, { approved: false, message: "Function setConfig not found" });
|
|
70
71
|
} else {
|
|
71
72
|
return ApiResponse.response(400, { approved: false, message: "AccountWl not found" });
|
|
@@ -4,6 +4,7 @@ const ClientData = require("../../entities/clients");
|
|
|
4
4
|
const MobilvendorApi = require("../../integrations/mobilvendor/MobilvendorApi");
|
|
5
5
|
const FinancialPolicyApi = require("../../integrations/financialPolicy/FinancialPolicyApi");
|
|
6
6
|
const Logger = require("../../common/utils/logger");
|
|
7
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @param {import("aws-lambda").APIGatewayProxyEvent} event
|
|
@@ -15,7 +16,7 @@ const Logger = require("../../common/utils/logger");
|
|
|
15
16
|
*/
|
|
16
17
|
const handler = async (event) => {
|
|
17
18
|
const { orderFormId } = event.pathParameters || {};
|
|
18
|
-
const { client_id: clientId } = event
|
|
19
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
19
20
|
try {
|
|
20
21
|
const listAccounts = await ClientData.getClient(clientId);
|
|
21
22
|
const accountName = listAccounts.AccountNames.values[0] || null;
|
|
@@ -63,9 +64,9 @@ const handler = async (event) => {
|
|
|
63
64
|
const configAccountWl = await AccountData.getAccountDataByAccountName(accountNameWl);
|
|
64
65
|
if (configAccountWl?.FinancialPolicyEcu && responseApi.setConfig) {
|
|
65
66
|
responseApi.setConfig(configAccountWl.FinancialPolicyEcu);
|
|
66
|
-
} else if(!responseApi.setConfig){
|
|
67
|
+
} else if (!responseApi.setConfig) {
|
|
67
68
|
return ApiResponse.response(400, { approved: false, message: "Function setConfig not found" });
|
|
68
|
-
}else{
|
|
69
|
+
} else {
|
|
69
70
|
return ApiResponse.response(400, { approved: false, message: "AccountWl not found" });
|
|
70
71
|
}
|
|
71
72
|
}
|
|
@@ -8,6 +8,7 @@ const DistributorData = require("../distributors/distributor");
|
|
|
8
8
|
const LIMIT_ITEMS_TO_PROCESS = process?.env?.LIMIT_ITEMS_TO_PROCESS || 150;
|
|
9
9
|
const SQS_INVENTORY_QUEUE_URL = process?.env?.SQS_INVENTORY_QUEUE_URL;
|
|
10
10
|
const Logger = require("../../common/utils/logger");
|
|
11
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
*
|
|
@@ -22,12 +23,12 @@ const producer = async (event) => {
|
|
|
22
23
|
return ApiResponse.response(400, "No body was found");
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
const clientId = event
|
|
26
|
+
const { client_id: clientId, scope } = getClaimsData(event);
|
|
27
|
+
|
|
26
28
|
Logger.log(JSON.stringify(JSON.parse(event.body)), clientId);
|
|
27
29
|
|
|
28
30
|
try {
|
|
29
31
|
const request = validateRequestBody(JSON.parse(event.body));
|
|
30
|
-
const scope = event?.requestContext?.authorizer?.claims?.scope;
|
|
31
32
|
const accountName = request?.an;
|
|
32
33
|
const inventory = request?.inventory;
|
|
33
34
|
|
|
@@ -3,6 +3,7 @@ const ApiResponse = require("../../common/utils/api-response");
|
|
|
3
3
|
const AWSServices = require("../../common/utils/aws-services");
|
|
4
4
|
const ClientData = require("../../entities/clients");
|
|
5
5
|
const Logger = require("../../common/utils/logger");
|
|
6
|
+
const { getClaimsData } = require('../../common/utils/util');
|
|
6
7
|
const SQS_MULTIPRE_PRODUCT_QUEUE_URL = process.env.SQS_MULTIPRE_PRODUCT_QUEUE_URL;
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -423,10 +424,8 @@ const producer = async (event) => {
|
|
|
423
424
|
let statusCode = 200;
|
|
424
425
|
let message;
|
|
425
426
|
|
|
426
|
-
Logger.log('Context', event?.requestContext);
|
|
427
427
|
try {
|
|
428
|
-
const clientId = event
|
|
429
|
-
const scope = event?.requestContext?.authorizer?.claims?.scope;
|
|
428
|
+
const { client_id: clientId, scope } = getClaimsData(event);
|
|
430
429
|
const accountName = event?.pathParameters?.accountName ?? null;
|
|
431
430
|
|
|
432
431
|
if (!accountName) {
|
|
@@ -5,11 +5,13 @@ const OrderData = require("../../entities/orders");
|
|
|
5
5
|
const VtexApi = require("../../vtex/clients/VtexApi");
|
|
6
6
|
const ApiResponse = require("../../common/utils/api-response");
|
|
7
7
|
const Logger = require("../../common/utils/logger");
|
|
8
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
8
9
|
|
|
9
10
|
const cancel = async (event) => {
|
|
10
11
|
const orderId = event.pathParameters?.orderId;
|
|
11
|
-
|
|
12
|
-
const scope = event
|
|
12
|
+
|
|
13
|
+
const { client_id: clientId, scope } = getClaimsData(event);
|
|
14
|
+
|
|
13
15
|
ApiResponse.validateRequiredParam("ClientId", clientId);
|
|
14
16
|
ApiResponse.validateRequiredParam("OrderId", orderId);
|
|
15
17
|
const dataOrder = await OrderData.getOrderDataByOrderId(orderId);
|
|
@@ -7,6 +7,7 @@ const ApiResponse = require("../../common/utils/api-response");
|
|
|
7
7
|
const Convert = require("../../common/MondelezCastOrder");
|
|
8
8
|
const TaxPromotionsData = require("../../entities/taxpromotion");
|
|
9
9
|
const Logger = require("../../common/utils/logger");
|
|
10
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
10
11
|
/**
|
|
11
12
|
*
|
|
12
13
|
* @param {import("aws-lambda").APIGatewayProxyEvent} event
|
|
@@ -16,7 +17,7 @@ const getOrders = async (event) => {
|
|
|
16
17
|
try {
|
|
17
18
|
//Modify this search data
|
|
18
19
|
|
|
19
|
-
const clientId = event
|
|
20
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
20
21
|
const orderId = event?.pathParameters?.orderId;
|
|
21
22
|
|
|
22
23
|
const order = await OrderData.getOrderDataByOrderId(orderId);
|
|
@@ -3,6 +3,7 @@ const ClientData = require("../../entities/clients");
|
|
|
3
3
|
const OrderData = require("../../entities/orders");
|
|
4
4
|
const ApiResponse = require("../../common/utils/api-response");
|
|
5
5
|
const Logger = require("../../common/utils/logger");
|
|
6
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
6
7
|
/**
|
|
7
8
|
*
|
|
8
9
|
* @param {import("aws-lambda").APIGatewayProxyEvent} event
|
|
@@ -17,7 +18,7 @@ module.exports.notifications = async (event) => {
|
|
|
17
18
|
const minutesWaiting = event?.queryStringParameters?.minutesWaiting ?? 6;
|
|
18
19
|
const limitPerPage = event?.queryStringParameters?.limit;
|
|
19
20
|
const page = parseInt(event?.queryStringParameters?.p); // || 1
|
|
20
|
-
const clientId = event
|
|
21
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
21
22
|
|
|
22
23
|
Logger.log("Event: ", account, from, to, state, page, clientId);
|
|
23
24
|
|
|
@@ -10,6 +10,7 @@ const Constants = require("../../common/utils/constants");
|
|
|
10
10
|
const DistributorData = require("../distributors/distributor");
|
|
11
11
|
const Status = require("../../common/utils/status");
|
|
12
12
|
const Logger = require("../../common/utils/logger");
|
|
13
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
13
14
|
|
|
14
15
|
const ORDER_STATUS_QUEUE_URL = process.env.ORDER_STATUS_QUEUE_URL;
|
|
15
16
|
const LIMIT_ITEMS_TO_PROCESS = process?.env?.LIMIT_ITEMS_TO_PROCESS || 150;
|
|
@@ -20,7 +21,7 @@ const producer = async (event) => {
|
|
|
20
21
|
let statusCode = 202;
|
|
21
22
|
let message;
|
|
22
23
|
|
|
23
|
-
const client_id = event
|
|
24
|
+
const { client_id } = getClaimsData(event);
|
|
24
25
|
Logger.log(JSON.stringify(JSON.parse(event.body)), client_id);
|
|
25
26
|
|
|
26
27
|
try {
|
|
@@ -115,8 +116,7 @@ const validInitial = async ({ event = null }) => {
|
|
|
115
116
|
|
|
116
117
|
errors.data.request = request;
|
|
117
118
|
|
|
118
|
-
const clientId = event
|
|
119
|
-
const scope = event?.requestContext?.authorizer?.claims?.scope;
|
|
119
|
+
const { client_id: clientId, scope } = getClaimsData(event);
|
|
120
120
|
const pathParameters = event.pathParameters;
|
|
121
121
|
|
|
122
122
|
if (!pathParameters) {
|
|
@@ -5,6 +5,7 @@ const AccountData = require("../../entities/account");
|
|
|
5
5
|
const SkuData = require("../../entities/sku");
|
|
6
6
|
const DistributorData = require("../distributors/distributor");
|
|
7
7
|
const Logger = require("../../common/utils/logger");
|
|
8
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
8
9
|
const LIMIT_ITEMS_TO_PROCESS = process?.env?.LIMIT_ITEMS_TO_PROCESS || 150;
|
|
9
10
|
const SQS_PRICE_QUEUE_URL = process?.env?.SQS_PRICE_QUEUE_URL;
|
|
10
11
|
const SQS_PROCESSTAX_QUEUE_URL = process?.env?.SQS_PROCESSTAX_QUEUE_URL ?? null;
|
|
@@ -22,12 +23,11 @@ const producer = async (event) => {
|
|
|
22
23
|
return ApiResponse.response(400, "No body was found");
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
const clientId = event
|
|
26
|
+
const { client_id: clientId, scope } = getClaimsData(event);
|
|
26
27
|
Logger.log(JSON.stringify(JSON.parse(event.body)), clientId);
|
|
27
28
|
|
|
28
29
|
try {
|
|
29
30
|
let request = JSON.parse(event.body);
|
|
30
|
-
const scope = event?.requestContext?.authorizer?.claims?.scope;
|
|
31
31
|
const accountName = request?.an;
|
|
32
32
|
const prices = orderPricesASC(request?.prices);
|
|
33
33
|
let pricesDiscount = [];
|
|
@@ -6,6 +6,7 @@ const TaxPromotionsData = require("../../entities/taxpromotion");
|
|
|
6
6
|
const ClientData = require("../../entities/clients");
|
|
7
7
|
const AccountData = require("../../entities/account");
|
|
8
8
|
const Logger = require("../../common/utils/logger");
|
|
9
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
9
10
|
const SQS_PROCESSTAX_QUEUE_URL= process?.env?.SQS_PROCESSTAX_QUEUE_URL ?? null;
|
|
10
11
|
const SQS_PROCESSTAX_DQL_QUEUE_URL= process?.env?.SQS_PROCESSTAX_DQL_QUEUE_URL ?? null;
|
|
11
12
|
const MAX_ATTEMPS= process?.env?.MAX_ATTEMPS ?? null;
|
|
@@ -738,7 +739,7 @@ const saveTaxOrPromotion= async ({data=null, vtexApi=null, returnCatch=false})=>
|
|
|
738
739
|
const createorupdate= async (event)=>{
|
|
739
740
|
|
|
740
741
|
let data = JSON.parse(event.body);
|
|
741
|
-
const clientId = event
|
|
742
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
742
743
|
const accountName= data?.idSeller;
|
|
743
744
|
|
|
744
745
|
const validateAccount = await ClientData.validateAccount(clientId, accountName);
|
|
@@ -968,7 +969,7 @@ const getDataCompleteTaxPromotions= ({data=null, idPromotionTax=null})=>{
|
|
|
968
969
|
**/
|
|
969
970
|
const gettaxesorpromotions= async (event)=>{
|
|
970
971
|
// benefits | taxes
|
|
971
|
-
const clientId = event
|
|
972
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
972
973
|
const typeSearch= event?.pathParameters?.type ?? 'benefits';
|
|
973
974
|
|
|
974
975
|
const listAccounts = await ClientData.getClient(clientId);
|
|
@@ -1062,7 +1063,7 @@ const getJsonListPromotion= (items, itemsVtex)=>{
|
|
|
1062
1063
|
**/
|
|
1063
1064
|
const gettaxorpromotion= async (event)=>{
|
|
1064
1065
|
let data = JSON.parse(event.body);
|
|
1065
|
-
const clientId = event
|
|
1066
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
1066
1067
|
const idPromotionOrTax= event?.pathParameters?.idCalculatorConfiguration ?? null;
|
|
1067
1068
|
|
|
1068
1069
|
if(!idPromotionOrTax){
|
|
@@ -1178,7 +1179,7 @@ const archivePromotionOrtaxVtex= async ({id=null, vtexApi=null})=>{
|
|
|
1178
1179
|
**/
|
|
1179
1180
|
const archivetaxorpromotion= async (event)=>{
|
|
1180
1181
|
let data = JSON.parse(event.body);
|
|
1181
|
-
const clientId = event
|
|
1182
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
1182
1183
|
const idPromotionOrTax= event?.pathParameters?.idCalculatorConfiguration ?? null;
|
|
1183
1184
|
|
|
1184
1185
|
if(!idPromotionOrTax){
|
|
@@ -6,6 +6,7 @@ const requiredFieldsConfig = require('./schemas/sftp_required_fields.json');
|
|
|
6
6
|
const AccountData = require("../../entities/account");
|
|
7
7
|
const ClientData = require("../../entities/clients");
|
|
8
8
|
const Logger = require("../../common/utils/logger");
|
|
9
|
+
const { getClaimsData } = require('../../common/utils/util');
|
|
9
10
|
|
|
10
11
|
const SQS_CONNECTION_SFTP_QUEUE_URL = process.env.SQS_CONNECTION_SFTP_QUEUE_URL
|
|
11
12
|
|
|
@@ -14,7 +15,7 @@ module.exports.producer = async (event) => {
|
|
|
14
15
|
let message
|
|
15
16
|
let body = JSON.parse(event.body);
|
|
16
17
|
|
|
17
|
-
const { client_id: clientId } = event
|
|
18
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
18
19
|
Logger.log("EVENT:", event?.body, clientId);
|
|
19
20
|
// OBTENER LA CONFIGURACION DEL ACCOUNT ✅
|
|
20
21
|
try {
|
|
@@ -3,13 +3,14 @@ const ApiResponse = require("../../common/utils/api-response");
|
|
|
3
3
|
const AccountData = require("../../entities/account");
|
|
4
4
|
const ClientData = require("../../entities/clients");
|
|
5
5
|
const Logger = require("../../common/utils/logger");
|
|
6
|
+
const { getClaimsData } = require("../../common/utils/util");
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @param {import("aws-lambda").APIGatewayProxyEvent} event
|
|
9
10
|
* @returns
|
|
10
11
|
*/
|
|
11
12
|
const list_products_vtex = async (event) => {
|
|
12
|
-
const clientId = event
|
|
13
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
13
14
|
let statusCode = 200;
|
|
14
15
|
let responseService = [];
|
|
15
16
|
|
|
@@ -72,7 +73,7 @@ const list_products_vtex = async (event) => {
|
|
|
72
73
|
* @returns
|
|
73
74
|
*/
|
|
74
75
|
const list_categories_vtex = async (event) => {
|
|
75
|
-
const clientId = event
|
|
76
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
76
77
|
const anRequest = event?.queryStringParameters?.an ?? null;
|
|
77
78
|
if(anRequest){
|
|
78
79
|
const validAccount = await ClientData.validateAccount(clientId, anRequest);
|
|
@@ -127,7 +128,7 @@ const list_categories_vtex = async (event) => {
|
|
|
127
128
|
* @returns
|
|
128
129
|
*/
|
|
129
130
|
const list_brands_vtex = async (event) => {
|
|
130
|
-
const clientId = event
|
|
131
|
+
const { client_id: clientId } = getClaimsData(event);
|
|
131
132
|
const anRequest = event?.queryStringParameters?.an ?? null;
|
|
132
133
|
if(anRequest){
|
|
133
134
|
const validAccount = await ClientData.validateAccount(clientId, anRequest);
|
package/src/auth/handler.js
DELETED