kui-crm_actions 0.0.62 → 0.0.64
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 +54 -105
- package/cjs/index.js.map +1 -1
- package/index.d.ts +141 -173
- package/index.js +55 -106
- 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,18 @@ 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
257
|
getInventoryInspectionMeters: function (meters, metersFiles, metersImages) {
|
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: metersImages
|
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: metersImages
|
261
|
+
? metersImages[index]
|
262
|
+
: _this.getFilesParams(meter.images), no_tariff: meter.noTariff, auto_sending: meter.withAutoSending })); })) || [],
|
260
263
|
};
|
261
264
|
},
|
262
265
|
getInspectionMeterValues: function (meter, fieldName) {
|
@@ -299,6 +302,11 @@ var inspectionsRequestBody = {
|
|
299
302
|
last_value: lastValue,
|
300
303
|
});
|
301
304
|
},
|
305
|
+
getFilesParams: function (files) {
|
306
|
+
return files
|
307
|
+
.map(function (file) { return file.uploadedData; })
|
308
|
+
.filter(function (data) { return data; });
|
309
|
+
},
|
302
310
|
};
|
303
311
|
|
304
312
|
var inspectionsRequests = {
|
@@ -317,138 +325,79 @@ var inspectionsRequests = {
|
|
317
325
|
});
|
318
326
|
});
|
319
327
|
},
|
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
328
|
createInitialInspection: function (data, apartmentId, loader) {
|
356
329
|
return __awaiter(this, void 0, void 0, function () {
|
357
330
|
var roomsImages, body;
|
358
331
|
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];
|
332
|
+
if (apartmentId) {
|
333
|
+
loader.startLoading("inspection creation");
|
334
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
335
|
+
body = inspectionsRequestBody.getPostBodyInitialInspection(data, roomsImages);
|
336
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
369
337
|
}
|
338
|
+
return [2 /*return*/, null];
|
370
339
|
});
|
371
340
|
});
|
372
341
|
},
|
373
342
|
createRegularInspection: function (data, apartmentId, loader) {
|
374
|
-
var _a;
|
375
343
|
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];
|
344
|
+
var roomsImages, body;
|
345
|
+
return __generator(this, function (_a) {
|
346
|
+
if (apartmentId) {
|
347
|
+
loader.startLoading("inspection creation");
|
348
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
349
|
+
body = inspectionsRequestBody.getPostBodyRegularInspection(data, roomsImages);
|
350
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
391
351
|
}
|
352
|
+
return [2 /*return*/, null];
|
392
353
|
});
|
393
354
|
});
|
394
355
|
},
|
395
356
|
createTransferInspection: function (data, apartmentId, loader) {
|
396
|
-
var _a;
|
397
357
|
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];
|
358
|
+
var roomsImages, body;
|
359
|
+
return __generator(this, function (_a) {
|
360
|
+
if (apartmentId) {
|
361
|
+
loader.startLoading("inspection creation");
|
362
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
363
|
+
body = inspectionsRequestBody.getPostBodyTransferInspection(data, roomsImages);
|
364
|
+
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
413
365
|
}
|
366
|
+
return [2 /*return*/, null];
|
414
367
|
});
|
415
368
|
});
|
416
369
|
},
|
417
370
|
createInventoryInspection: function (data, apartmentId, loader) {
|
418
|
-
var _a
|
371
|
+
var _a;
|
419
372
|
return __awaiter(this, void 0, void 0, function () {
|
420
|
-
var fillingFiles, metersFiles,
|
421
|
-
return __generator(this, function (
|
422
|
-
switch (
|
373
|
+
var fillingFiles, metersFiles, files, roomsImages, body;
|
374
|
+
return __generator(this, function (_b) {
|
375
|
+
switch (_b.label) {
|
423
376
|
case 0:
|
424
377
|
if (!apartmentId) return [3 /*break*/, 2];
|
425
378
|
loader.startLoading("inspection creation");
|
426
379
|
fillingFiles = data.fillingList.map(function (filling) { return filling.instruction; });
|
427
380
|
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),
|
381
|
+
return [4 /*yield*/, kuiUtils.callPromises([
|
434
382
|
kuiCrm.uploadFiles(loader, fillingFiles),
|
435
|
-
kuiCrm.uploadFiles(loader, metersFiles)
|
436
|
-
]
|
383
|
+
kuiCrm.uploadFiles(loader, metersFiles),
|
384
|
+
])];
|
437
385
|
case 1:
|
438
|
-
files =
|
439
|
-
|
386
|
+
files = _b.sent();
|
387
|
+
roomsImages = this.getRoomParams(data.roomsImages);
|
388
|
+
body = inspectionsRequestBody.getPostBodyInventoryInspection(data, roomsImages, files[0], files[1]);
|
440
389
|
return [2 /*return*/, this.createInspection(apartmentId, body, loader)];
|
441
390
|
case 2: return [2 /*return*/, null];
|
442
391
|
}
|
443
392
|
});
|
444
393
|
});
|
445
394
|
},
|
446
|
-
getRoomParams: function (
|
447
|
-
return {
|
395
|
+
getRoomParams: function (rooms) {
|
396
|
+
return rooms.map(function (room) { return ({
|
448
397
|
purpose: room.type,
|
449
398
|
comment: room.comment,
|
450
|
-
photos:
|
451
|
-
};
|
399
|
+
photos: inspectionsRequestBody.getFilesParams(room.files),
|
400
|
+
}); });
|
452
401
|
},
|
453
402
|
};
|
454
403
|
|