cardus 0.0.56 → 0.0.59

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.js CHANGED
@@ -83,7 +83,7 @@ class IntegrationManager {
83
83
  this.getAgencyIdForTempShipment = params.getAgencyIdForTempShipment;
84
84
  }
85
85
  insertTempShipments(_a) {
86
- return __awaiter(this, arguments, void 0, function* ({ payload: { idUsuario, agencyId, addressId, warehouseId, group }, fetchAllOrders, crearBulto, modificarOrdenOriginal }) {
86
+ return __awaiter(this, arguments, void 0, function* ({ payload: { idUsuario, agencyId, addressId, warehouseId, group, sequentialInsertion = false }, fetchAllOrders, crearBulto, modificarOrdenOriginal }) {
87
87
  const user = yield this.services.usersService.obtenerUsuarioId(idUsuario);
88
88
  const { integrationsService, addressesService } = this.services;
89
89
  // esto hay que pasarlo ya en los parametros
@@ -134,7 +134,7 @@ class IntegrationManager {
134
134
  return Object.assign(parsedOrder, { idEnvioTemporal, agencyId });
135
135
  }),
136
136
  regularExecutionTime: 8000, // ms
137
- initialBatchQuantity: 5 // de cinco en cinco
137
+ initialBatchQuantity: sequentialInsertion ? 1 : 5 // si la insercion no es secuencial, de cinco en cinco
138
138
  }).upload();
139
139
  const successfullShipments = insertOrdersResult
140
140
  .filter(Boolean)
@@ -151,7 +151,7 @@ class IntegrationManager {
151
151
  tempShimpmentIds: successfullShipments.map((successfullShipment) => successfullShipment.idEnvioTemporal)
152
152
  });
153
153
  // modificamos la agencia, cuando se tenga que hacer
154
- successfullShipments.forEach((order) => __awaiter(this, void 0, void 0, function* () {
154
+ yield Promise.allSettled(successfullShipments.map((order) => __awaiter(this, void 0, void 0, function* () {
155
155
  const shipmentDetails = this.dataToInsert.details.filter(({ id_envio }) => {
156
156
  return id_envio === order.idEnvioTemporal;
157
157
  });
@@ -164,18 +164,24 @@ class IntegrationManager {
164
164
  shipmentDetails
165
165
  });
166
166
  if (newAgencyId !== order.agencyId) {
167
- integrationsService.updateTempShimpment({
167
+ yield integrationsService.updateTempShimpment({
168
168
  id_envio: order.idEnvioTemporal,
169
169
  id_usuario: idUsuario,
170
170
  id_agencia: newAgencyId
171
171
  });
172
172
  }
173
- }));
174
- integrationsService.insertTempShipmentMultipleLines(this.dataToInsert.lines);
175
- integrationsService.insertTempShipmentMultipleDetails(this.dataToInsert.details);
176
- integrationsService.insertTempShipmentMultipleContents(this.dataToInsert.contents);
177
- integrationsService.insertTempShipmentMultipleExternals(this.dataToInsert.externals);
178
- return { filteredOrders, insertedTempShipments: successfullShipments };
173
+ })));
174
+ yield Promise.allSettled([
175
+ integrationsService.insertTempShipmentMultipleLines(this.dataToInsert.lines),
176
+ integrationsService.insertTempShipmentMultipleDetails(this.dataToInsert.details),
177
+ integrationsService.insertTempShipmentMultipleContents(this.dataToInsert.contents),
178
+ integrationsService.insertTempShipmentMultipleExternals(this.dataToInsert.externals)
179
+ ]);
180
+ return {
181
+ filteredOrders,
182
+ insertedTempShipments: successfullShipments,
183
+ sequentialInsertion
184
+ };
179
185
  });
180
186
  }
181
187
  insertUserDefaultConfigurationContent(_a) {
@@ -197,7 +203,7 @@ class IntegrationManager {
197
203
  const userFakeData = configurationService.getFakeDefaultProformaConfiguration(idUsuario, user.dni);
198
204
  userConfiguration = userFakeData;
199
205
  }
200
- if (userConfiguration && userConfiguration !== null) {
206
+ if (userConfiguration) {
201
207
  tempShimpmentIds.forEach((tempShimpmentId) => {
202
208
  if (userConfiguration) {
203
209
  insert(userConfiguration, tempShimpmentId);
package/index.ts CHANGED
@@ -88,7 +88,14 @@ export class IntegrationManager {
88
88
  }
89
89
 
90
90
  async insertTempShipments({
91
- payload: { idUsuario, agencyId, addressId, warehouseId, group },
91
+ payload: {
92
+ idUsuario,
93
+ agencyId,
94
+ addressId,
95
+ warehouseId,
96
+ group,
97
+ sequentialInsertion = false
98
+ },
92
99
  fetchAllOrders,
93
100
  crearBulto,
94
101
  modificarOrdenOriginal
@@ -161,7 +168,7 @@ export class IntegrationManager {
161
168
  return Object.assign(parsedOrder, { idEnvioTemporal, agencyId });
162
169
  },
163
170
  regularExecutionTime: 8000, // ms
164
- initialBatchQuantity: 5 // de cinco en cinco
171
+ initialBatchQuantity: sequentialInsertion ? 1 : 5 // si la insercion no es secuencial, de cinco en cinco
165
172
  }).upload();
166
173
 
167
174
  const successfullShipments = insertOrdersResult
@@ -187,46 +194,53 @@ export class IntegrationManager {
187
194
  });
188
195
 
189
196
  // modificamos la agencia, cuando se tenga que hacer
197
+ await Promise.allSettled(
198
+ successfullShipments.map(async (order) => {
199
+ const shipmentDetails = this.dataToInsert.details.filter(
200
+ ({ id_envio }) => {
201
+ return id_envio === order.idEnvioTemporal;
202
+ }
203
+ );
190
204
 
191
- successfullShipments.forEach(async (order) => {
192
- const shipmentDetails = this.dataToInsert.details.filter(
193
- ({ id_envio }) => {
194
- return id_envio === order.idEnvioTemporal;
195
- }
196
- );
197
-
198
- const newAgencyId = await this.getAgencyIdForTempShipment({
199
- defaultAgencyId: agencyId,
200
- userId: idUsuario,
201
- integrationId: this.integrationType,
202
- tempShipmentData: order,
203
- sellerAddress,
204
- shipmentDetails
205
- });
206
-
207
- if (newAgencyId !== order.agencyId) {
208
- integrationsService.updateTempShimpment({
209
- id_envio: order.idEnvioTemporal,
210
- id_usuario: idUsuario,
211
- id_agencia: newAgencyId
205
+ const newAgencyId = await this.getAgencyIdForTempShipment({
206
+ defaultAgencyId: agencyId,
207
+ userId: idUsuario,
208
+ integrationId: this.integrationType,
209
+ tempShipmentData: order,
210
+ sellerAddress,
211
+ shipmentDetails
212
212
  });
213
- }
214
- });
215
213
 
216
- integrationsService.insertTempShipmentMultipleLines(
217
- this.dataToInsert.lines
218
- );
219
- integrationsService.insertTempShipmentMultipleDetails(
220
- this.dataToInsert.details
221
- );
222
- integrationsService.insertTempShipmentMultipleContents(
223
- this.dataToInsert.contents
224
- );
225
- integrationsService.insertTempShipmentMultipleExternals(
226
- this.dataToInsert.externals
214
+ if (newAgencyId !== order.agencyId) {
215
+ await integrationsService.updateTempShimpment({
216
+ id_envio: order.idEnvioTemporal,
217
+ id_usuario: idUsuario,
218
+ id_agencia: newAgencyId
219
+ });
220
+ }
221
+ })
227
222
  );
228
223
 
229
- return { filteredOrders, insertedTempShipments: successfullShipments };
224
+ await Promise.allSettled([
225
+ integrationsService.insertTempShipmentMultipleLines(
226
+ this.dataToInsert.lines
227
+ ),
228
+ integrationsService.insertTempShipmentMultipleDetails(
229
+ this.dataToInsert.details
230
+ ),
231
+ integrationsService.insertTempShipmentMultipleContents(
232
+ this.dataToInsert.contents
233
+ ),
234
+ integrationsService.insertTempShipmentMultipleExternals(
235
+ this.dataToInsert.externals
236
+ )
237
+ ]);
238
+
239
+ return {
240
+ filteredOrders,
241
+ insertedTempShipments: successfullShipments,
242
+ sequentialInsertion
243
+ };
230
244
  }
231
245
 
232
246
  async insertUserDefaultConfigurationContent({
@@ -265,7 +279,7 @@ export class IntegrationManager {
265
279
  );
266
280
  userConfiguration = userFakeData;
267
281
  }
268
- if (userConfiguration && userConfiguration !== null) {
282
+ if (userConfiguration) {
269
283
  tempShimpmentIds.forEach((tempShimpmentId) => {
270
284
  if (userConfiguration) {
271
285
  insert(userConfiguration, tempShimpmentId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cardus",
3
- "version": "0.0.56",
3
+ "version": "0.0.59",
4
4
  "description": "an integration manager",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/types/index.ts CHANGED
@@ -157,6 +157,7 @@ export interface InsertParams {
157
157
  addressId: number;
158
158
  warehouseId: number;
159
159
  group: Group;
160
+ sequentialInsertion?: boolean;
160
161
  };
161
162
  fetchAllOrders: FetchAllOrders;
162
163
  crearBulto: CrearBulto;