kui-crm_actions 0.0.62 → 0.0.63
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/cjs/index.js +53 -106
- package/cjs/index.js.map +1 -1
- package/index.d.ts +141 -173
- package/index.js +54 -107
- package/index.js.map +1 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
@@ -189,27 +189,27 @@ var inspectionsRequestBody = {
|
|
189
189
|
}); }),
|
190
190
|
};
|
191
191
|
},
|
192
|
-
getPostBodyRegularInspection: function (inspection, roomsImages
|
192
|
+
getPostBodyRegularInspection: function (inspection, roomsImages) {
|
193
193
|
return {
|
194
194
|
date: luxon.DateTime.now().toISODate(),
|
195
195
|
inspection_type: "regular",
|
196
196
|
based_on: null,
|
197
197
|
dropbox_link: inspection.dropboxLink,
|
198
198
|
photo_groups: roomsImages,
|
199
|
-
regular: this.getPartialInspectionMeters(inspection.meters
|
199
|
+
regular: this.getPartialInspectionMeters(inspection.meters),
|
200
200
|
};
|
201
201
|
},
|
202
|
-
getPostBodyTransferInspection: function (inspection, roomsImages
|
202
|
+
getPostBodyTransferInspection: function (inspection, roomsImages) {
|
203
203
|
return {
|
204
204
|
date: luxon.DateTime.now().toISODate(),
|
205
205
|
inspection_type: "transfer",
|
206
206
|
based_on: null,
|
207
207
|
dropbox_link: inspection.dropboxLink,
|
208
208
|
photo_groups: roomsImages,
|
209
|
-
transfer: __assign({ transfer_type: inspection.transferType }, this.getPartialInspectionMeters(inspection.meters
|
209
|
+
transfer: __assign({ transfer_type: inspection.transferType }, this.getPartialInspectionMeters(inspection.meters)),
|
210
210
|
};
|
211
211
|
},
|
212
|
-
getPartialInspectionMeters: function (meters
|
212
|
+
getPartialInspectionMeters: function (meters) {
|
213
213
|
var _this = this;
|
214
214
|
return {
|
215
215
|
meters: meters.map(function (meter, index) { return ({
|
@@ -217,12 +217,13 @@ var inspectionsRequestBody = {
|
|
217
217
|
resource_type: meter.resource,
|
218
218
|
meter_type: meter.type,
|
219
219
|
passport_number: meter.number,
|
220
|
-
photos:
|
220
|
+
photos: _this.getFilesParams(meter.images),
|
221
221
|
values: kuiUtils.clearNotValidFields(_this.getInspectionMeterValues(meter)),
|
222
222
|
}); }),
|
223
223
|
};
|
224
224
|
},
|
225
|
-
getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles
|
225
|
+
getPostBodyInventoryInspection: function (inspection, roomsImages, fillingFiles, metersFiles) {
|
226
|
+
var _this = this;
|
226
227
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
227
228
|
return {
|
228
229
|
date: luxon.DateTime.now().toISODate(),
|
@@ -247,16 +248,16 @@ var inspectionsRequestBody = {
|
|
247
248
|
description: filling.name,
|
248
249
|
serial_code: filling.serialNumber,
|
249
250
|
amount: filling.numberOfSubjects,
|
250
|
-
photos:
|
251
|
+
photos: _this.getFilesParams(filling.images),
|
251
252
|
instruction: fillingFiles[index],
|
252
253
|
});
|
253
|
-
}) }, this.getInventoryInspectionMeters(inspection.meters, metersFiles
|
254
|
+
}) }, this.getInventoryInspectionMeters(inspection.meters, metersFiles)),
|
254
255
|
};
|
255
256
|
},
|
256
|
-
getInventoryInspectionMeters: function (meters, metersFiles
|
257
|
+
getInventoryInspectionMeters: function (meters, metersFiles) {
|
257
258
|
var _this = this;
|
258
259
|
return {
|
259
|
-
meters: (meters === null || meters === void 0 ? void 0 : meters.map(function (meter, index) { return (__assign(__assign({}, _this.getMeterCommonFields(meter)), { passport: metersFiles[index], values: kuiUtils.clearNotValidFields(_this.getInspectionMeterValues(meter, "initialValue")), photos:
|
260
|
+
meters: (meters === null || meters === void 0 ? void 0 : meters.map(function (meter, index) { return (__assign(__assign({}, _this.getMeterCommonFields(meter)), { passport: metersFiles[index], values: kuiUtils.clearNotValidFields(_this.getInspectionMeterValues(meter, "initialValue")), photos: _this.getFilesParams(meter.images), no_tariff: meter.noTariff, auto_sending: meter.withAutoSending })); })) || [],
|
260
261
|
};
|
261
262
|
},
|
262
263
|
getInspectionMeterValues: function (meter, fieldName) {
|
@@ -299,6 +300,11 @@ var inspectionsRequestBody = {
|
|
299
300
|
last_value: lastValue,
|
300
301
|
});
|
301
302
|
},
|
303
|
+
getFilesParams: function (files) {
|
304
|
+
return files
|
305
|
+
.map(function (file) { return file.uploadedData; })
|
306
|
+
.filter(function (data) { return data; });
|
307
|
+
},
|
302
308
|
};
|
303
309
|
|
304
310
|
var inspectionsRequests = {
|
@@ -317,138 +323,79 @@ var inspectionsRequests = {
|
|
317
323
|
});
|
318
324
|
});
|
319
325
|
},
|
320
|
-
loadInspectionImages: function (loader, roomsImages) {
|
321
|
-
var _a;
|
322
|
-
return __awaiter(this, void 0, void 0, function () {
|
323
|
-
var promises, images, bedroomCount, roomIndex, bedroomIndex;
|
324
|
-
var _this = this;
|
325
|
-
return __generator(this, function (_b) {
|
326
|
-
switch (_b.label) {
|
327
|
-
case 0:
|
328
|
-
promises = [];
|
329
|
-
roomsImages.forEach(function (room) {
|
330
|
-
promises.push(kuiCrm.uploadImages(loader, room.files));
|
331
|
-
});
|
332
|
-
return [4 /*yield*/, kuiUtils.callPromises(promises)];
|
333
|
-
case 1:
|
334
|
-
images = _b.sent();
|
335
|
-
bedroomCount = (_a = roomsImages.filter(function (imagesGroup) { return imagesGroup.type === "bedroom"; })) === null || _a === void 0 ? void 0 : _a.length;
|
336
|
-
roomIndex = bedroomCount || 0;
|
337
|
-
bedroomIndex = 0;
|
338
|
-
return [2 /*return*/, roomsImages.map(function (room, index) {
|
339
|
-
if (room.type === "room") {
|
340
|
-
return __assign(__assign({}, _this.getRoomParams(room, images[index])), {
|
341
|
-
// eslint-disable-next-line no-plusplus
|
342
|
-
room_order_number: roomIndex++ });
|
343
|
-
}
|
344
|
-
if (room.type === "bedroom") {
|
345
|
-
return __assign(__assign({}, _this.getRoomParams(room, images[index])), {
|
346
|
-
// eslint-disable-next-line no-plusplus
|
347
|
-
room_order_number: bedroomIndex++ });
|
348
|
-
}
|
349
|
-
return _this.getRoomParams(room, images[index]);
|
350
|
-
})];
|
351
|
-
}
|
352
|
-
});
|
353
|
-
});
|
354
|
-
},
|
355
326
|
createInitialInspection: function (data, apartmentId, loader) {
|
356
327
|
return __awaiter(this, void 0, void 0, function () {
|
357
328
|
var roomsImages, body;
|
358
329
|
return __generator(this, function (_a) {
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
case 1:
|
365
|
-
roomsImages = _a.sent();
|
366
|
-
body = inspectionsRequestBody.getPostBodyInitialInspection(data, roomsImages);
|
367
|
-
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
368
|
-
case 2: return [2 /*return*/, null];
|
330
|
+
if (apartmentId) {
|
331
|
+
loader.startLoading("inspection creation");
|
332
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
333
|
+
body = inspectionsRequestBody.getPostBodyInitialInspection(data, roomsImages);
|
334
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
369
335
|
}
|
336
|
+
return [2 /*return*/, null];
|
370
337
|
});
|
371
338
|
});
|
372
339
|
},
|
373
340
|
createRegularInspection: function (data, apartmentId, loader) {
|
374
|
-
var _a;
|
375
341
|
return __awaiter(this, void 0, void 0, function () {
|
376
|
-
var
|
377
|
-
return __generator(this, function (
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
return [4 /*yield*/, kuiUtils.callPromises(__spreadArray([
|
384
|
-
this.loadInspectionImages(loader, data.roomsImages)
|
385
|
-
], metersImages, true))];
|
386
|
-
case 1:
|
387
|
-
files = _b.sent();
|
388
|
-
body = inspectionsRequestBody.getPostBodyRegularInspection(data, files[0], files.slice(1));
|
389
|
-
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
390
|
-
case 2: return [2 /*return*/, null];
|
342
|
+
var roomsImages, body;
|
343
|
+
return __generator(this, function (_a) {
|
344
|
+
if (apartmentId) {
|
345
|
+
loader.startLoading("inspection creation");
|
346
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
347
|
+
body = inspectionsRequestBody.getPostBodyRegularInspection(data, roomsImages);
|
348
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
391
349
|
}
|
350
|
+
return [2 /*return*/, null];
|
392
351
|
});
|
393
352
|
});
|
394
353
|
},
|
395
354
|
createTransferInspection: function (data, apartmentId, loader) {
|
396
|
-
var _a;
|
397
355
|
return __awaiter(this, void 0, void 0, function () {
|
398
|
-
var
|
399
|
-
return __generator(this, function (
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
return [4 /*yield*/, kuiUtils.callPromises(__spreadArray([
|
406
|
-
this.loadInspectionImages(loader, data.roomsImages)
|
407
|
-
], metersImages, true))];
|
408
|
-
case 1:
|
409
|
-
files = _b.sent();
|
410
|
-
body = inspectionsRequestBody.getPostBodyTransferInspection(data, files[0], files.slice(1));
|
411
|
-
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
412
|
-
case 2: return [2 /*return*/, null];
|
356
|
+
var roomsImages, body;
|
357
|
+
return __generator(this, function (_a) {
|
358
|
+
if (apartmentId) {
|
359
|
+
loader.startLoading("inspection creation");
|
360
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
361
|
+
body = inspectionsRequestBody.getPostBodyTransferInspection(data, roomsImages);
|
362
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
413
363
|
}
|
364
|
+
return [2 /*return*/, null];
|
414
365
|
});
|
415
366
|
});
|
416
367
|
},
|
417
368
|
createInventoryInspection: function (data, apartmentId, loader) {
|
418
|
-
var _a
|
369
|
+
var _a;
|
419
370
|
return __awaiter(this, void 0, void 0, function () {
|
420
|
-
var fillingFiles, metersFiles,
|
421
|
-
return __generator(this, function (
|
422
|
-
switch (
|
371
|
+
var fillingFiles, metersFiles, files, roomsImages, body;
|
372
|
+
return __generator(this, function (_b) {
|
373
|
+
switch (_b.label) {
|
423
374
|
case 0:
|
424
375
|
if (!apartmentId) return [3 /*break*/, 2];
|
425
376
|
loader.startLoading("inspection creation");
|
426
377
|
fillingFiles = data.fillingList.map(function (filling) { return filling.instruction; });
|
427
378
|
metersFiles = ((_a = data.meters) === null || _a === void 0 ? void 0 : _a.map(function (meter) { return meter.passportFile; })) || [];
|
428
|
-
|
429
|
-
fillingImages = data.fillingList.map(function (filling) {
|
430
|
-
return kuiCrm.uploadImages(loader, filling.images);
|
431
|
-
});
|
432
|
-
return [4 /*yield*/, kuiUtils.callPromises(__spreadArray(__spreadArray([
|
433
|
-
this.loadInspectionImages(loader, data.roomsImages),
|
379
|
+
return [4 /*yield*/, kuiUtils.callPromises([
|
434
380
|
kuiCrm.uploadFiles(loader, fillingFiles),
|
435
|
-
kuiCrm.uploadFiles(loader, metersFiles)
|
436
|
-
]
|
381
|
+
kuiCrm.uploadFiles(loader, metersFiles),
|
382
|
+
])];
|
437
383
|
case 1:
|
438
|
-
files =
|
439
|
-
|
384
|
+
files = _b.sent();
|
385
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
386
|
+
body = inspectionsRequestBody.getPostBodyInventoryInspection(data, roomsImages, files[0], files[1]);
|
440
387
|
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
441
388
|
case 2: return [2 /*return*/, null];
|
442
389
|
}
|
443
390
|
});
|
444
391
|
});
|
445
392
|
},
|
446
|
-
getRoomParams: function (
|
447
|
-
return {
|
393
|
+
getRoomParams: function (rooms) {
|
394
|
+
return rooms.map(function (room) { return ({
|
448
395
|
purpose: room.type,
|
449
396
|
comment: room.comment,
|
450
|
-
photos:
|
451
|
-
};
|
397
|
+
photos: inspectionsRequestBody.getFilesParams(room.files),
|
398
|
+
}); });
|
452
399
|
},
|
453
400
|
};
|
454
401
|
|