@steedos-labs/content-compliance 0.1.1 → 0.1.2

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.
@@ -8,6 +8,7 @@ var lodash_1 = require("lodash");
8
8
  var material_1 = require("./material");
9
9
  var content_hub_1 = require("./content_hub");
10
10
  var AI_1 = require("./AI");
11
+ var notification_1 = require("./notification");
11
12
  var getApproverStepRule = function (ctx) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
12
13
  var rules, rule;
13
14
  return tslib_1.__generator(this, function (_a) {
@@ -190,111 +191,11 @@ var getReviewStatus = function (nextStep) {
190
191
  return consts_1.ReviewStatus.under_review;
191
192
  }
192
193
  };
193
- var sendNotifications = function (ctx, materialApproval, nextApprovers, actionLabel) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
194
- var nextApprovers_1, nextApprovers_1_1, to, e_1_1, spaceUsers, spaceUsers_1, spaceUsers_1_1, spaceUser, error_1, e_2_1, error_2;
195
- var e_1, _a, e_2, _b;
196
- return tslib_1.__generator(this, function (_c) {
197
- switch (_c.label) {
198
- case 0:
199
- _c.trys.push([0, 20, , 21]);
200
- _c.label = 1;
201
- case 1:
202
- _c.trys.push([1, 6, 7, 8]);
203
- nextApprovers_1 = tslib_1.__values(nextApprovers), nextApprovers_1_1 = nextApprovers_1.next();
204
- _c.label = 2;
205
- case 2:
206
- if (!!nextApprovers_1_1.done) return [3, 5];
207
- to = nextApprovers_1_1.value;
208
- return [4, ctx.broker.call('notifications.add', {
209
- message: {
210
- name: "".concat(actionLabel, ": ").concat(materialApproval.name),
211
- body: "",
212
- related_to: {
213
- o: "pepsico_material_approval",
214
- ids: [materialApproval._id]
215
- },
216
- related_name: materialApproval.name,
217
- from: materialApproval.owner,
218
- space: materialApproval.space
219
- },
220
- from: materialApproval.owner,
221
- to: to
222
- })];
223
- case 3:
224
- _c.sent();
225
- _c.label = 4;
226
- case 4:
227
- nextApprovers_1_1 = nextApprovers_1.next();
228
- return [3, 2];
229
- case 5: return [3, 8];
230
- case 6:
231
- e_1_1 = _c.sent();
232
- e_1 = { error: e_1_1 };
233
- return [3, 8];
234
- case 7:
235
- try {
236
- if (nextApprovers_1_1 && !nextApprovers_1_1.done && (_a = nextApprovers_1.return)) _a.call(nextApprovers_1);
237
- }
238
- finally { if (e_1) throw e_1.error; }
239
- return [7];
240
- case 8: return [4, ctx.getObject('space_users').find({ filters: [['user', '=', nextApprovers], ['space', '=', materialApproval.space]] })];
241
- case 9:
242
- spaceUsers = _c.sent();
243
- console.time('sendNotifications-email: ' + nextApprovers.length);
244
- _c.label = 10;
245
- case 10:
246
- _c.trys.push([10, 17, 18, 19]);
247
- spaceUsers_1 = tslib_1.__values(spaceUsers), spaceUsers_1_1 = spaceUsers_1.next();
248
- _c.label = 11;
249
- case 11:
250
- if (!!spaceUsers_1_1.done) return [3, 16];
251
- spaceUser = spaceUsers_1_1.value;
252
- if (!(spaceUser.email && spaceUser.email_notification)) return [3, 15];
253
- _c.label = 12;
254
- case 12:
255
- _c.trys.push([12, 14, , 15]);
256
- return [4, ctx.broker.call('@builder6/email.send', {
257
- to: spaceUser.email,
258
- subject: "".concat(actionLabel, ": ").concat(materialApproval.name),
259
- html: "\n <p>\u60A8\u6709\u4E00\u4EFD\u65B0\u7684\u5F85\u5BA1\u6838\u6587\u4EF6\u9700\u8981\u67E5\u770B\u548C\u5904\u7406\u3002\u8BF7\u70B9\u51FB\u4E0B\u9762\u7684\u94FE\u63A5\u6765\u8BBF\u95EE\u8BE5\u6587\u4EF6\uFF1A</p>\n <a href=\"".concat(process.env.ROOT_URL, "/app/pepsico_content_review/pepsico_material_approval/view/").concat(materialApproval._id, "?side_object=pepsico_material_approval&side_listview_id=pending\">").concat(materialApproval.name, "</a>\n ")
260
- })];
261
- case 13:
262
- _c.sent();
263
- return [3, 15];
264
- case 14:
265
- error_1 = _c.sent();
266
- console.log(error_1);
267
- return [3, 15];
268
- case 15:
269
- spaceUsers_1_1 = spaceUsers_1.next();
270
- return [3, 11];
271
- case 16: return [3, 19];
272
- case 17:
273
- e_2_1 = _c.sent();
274
- e_2 = { error: e_2_1 };
275
- return [3, 19];
276
- case 18:
277
- try {
278
- if (spaceUsers_1_1 && !spaceUsers_1_1.done && (_b = spaceUsers_1.return)) _b.call(spaceUsers_1);
279
- }
280
- finally { if (e_2) throw e_2.error; }
281
- return [7];
282
- case 19:
283
- console.timeEnd('sendNotifications-email: ' + nextApprovers.length);
284
- return [3, 21];
285
- case 20:
286
- error_2 = _c.sent();
287
- console.log(error_2);
288
- return [3, 21];
289
- case 21: return [2];
290
- }
291
- });
292
- }); };
293
194
  var updateUserStepStatus = function (ctx, materialApproval, _a) {
294
195
  var approvalStatus = _a.approvalStatus;
295
196
  return tslib_1.__awaiter(void 0, void 0, void 0, function () {
296
- var user, process, process_1, process_1_1, item, processOthers, processOthers_1, processOthers_1_1, item_1, e_3_1, e_4_1;
297
- var e_4, _b, e_3, _c;
197
+ var user, process, process_1, process_1_1, item, processOthers, processOthers_1, processOthers_1_1, item_1, e_1_1, e_2_1;
198
+ var e_2, _b, e_1, _c;
298
199
  return tslib_1.__generator(this, function (_d) {
299
200
  switch (_d.label) {
300
201
  case 0:
@@ -344,7 +245,7 @@ var updateUserStepStatus = function (ctx, materialApproval, _a) {
344
245
  _d.label = 6;
345
246
  case 6:
346
247
  _d.trys.push([6, 11, 12, 13]);
347
- processOthers_1 = (e_3 = void 0, tslib_1.__values(processOthers)), processOthers_1_1 = processOthers_1.next();
248
+ processOthers_1 = (e_1 = void 0, tslib_1.__values(processOthers)), processOthers_1_1 = processOthers_1.next();
348
249
  _d.label = 7;
349
250
  case 7:
350
251
  if (!!processOthers_1_1.done) return [3, 10];
@@ -362,28 +263,28 @@ var updateUserStepStatus = function (ctx, materialApproval, _a) {
362
263
  return [3, 7];
363
264
  case 10: return [3, 13];
364
265
  case 11:
365
- e_3_1 = _d.sent();
366
- e_3 = { error: e_3_1 };
266
+ e_1_1 = _d.sent();
267
+ e_1 = { error: e_1_1 };
367
268
  return [3, 13];
368
269
  case 12:
369
270
  try {
370
271
  if (processOthers_1_1 && !processOthers_1_1.done && (_c = processOthers_1.return)) _c.call(processOthers_1);
371
272
  }
372
- finally { if (e_3) throw e_3.error; }
273
+ finally { if (e_1) throw e_1.error; }
373
274
  return [7];
374
275
  case 13:
375
276
  process_1_1 = process_1.next();
376
277
  return [3, 3];
377
278
  case 14: return [3, 17];
378
279
  case 15:
379
- e_4_1 = _d.sent();
380
- e_4 = { error: e_4_1 };
280
+ e_2_1 = _d.sent();
281
+ e_2 = { error: e_2_1 };
381
282
  return [3, 17];
382
283
  case 16:
383
284
  try {
384
285
  if (process_1_1 && !process_1_1.done && (_b = process_1.return)) _b.call(process_1);
385
286
  }
386
- finally { if (e_4) throw e_4.error; }
287
+ finally { if (e_2) throw e_2.error; }
387
288
  return [7];
388
289
  case 17: return [2];
389
290
  }
@@ -410,8 +311,8 @@ var updateApproveFieldStatus = function (ctx, recordId, approveField, approveFie
410
311
  var changeApprovalProcess = function (ctx, materialApproval, _a) {
411
312
  var nextStep = _a.nextStep, nextApprovers = _a.nextApprovers, description = _a.description;
412
313
  return tslib_1.__awaiter(void 0, void 0, void 0, function () {
413
- var user, count, now, sUsers, _b, nextApprovers_2, nextApprovers_2_1, nextApprover, _c, _d, userId, spaceUsers, e_5_1, e_6_1;
414
- var e_6, _e, e_5, _f;
314
+ var user, count, now, sUsers, _b, nextApprovers_1, nextApprovers_1_1, nextApprover, _c, _d, userId, spaceUsers, e_3_1, e_4_1;
315
+ var e_4, _e, e_3, _f;
415
316
  return tslib_1.__generator(this, function (_g) {
416
317
  switch (_g.label) {
417
318
  case 0:
@@ -460,15 +361,15 @@ var changeApprovalProcess = function (ctx, materialApproval, _a) {
460
361
  return [3, 21];
461
362
  case 4:
462
363
  _g.trys.push([4, 16, 17, 18]);
463
- nextApprovers_2 = tslib_1.__values(nextApprovers), nextApprovers_2_1 = nextApprovers_2.next();
364
+ nextApprovers_1 = tslib_1.__values(nextApprovers), nextApprovers_1_1 = nextApprovers_1.next();
464
365
  _g.label = 5;
465
366
  case 5:
466
- if (!!nextApprovers_2_1.done) return [3, 15];
467
- nextApprover = nextApprovers_2_1.value;
367
+ if (!!nextApprovers_1_1.done) return [3, 15];
368
+ nextApprover = nextApprovers_1_1.value;
468
369
  _g.label = 6;
469
370
  case 6:
470
371
  _g.trys.push([6, 12, 13, 14]);
471
- _c = (e_5 = void 0, tslib_1.__values(nextApprover.userIds)), _d = _c.next();
372
+ _c = (e_3 = void 0, tslib_1.__values(nextApprover.userIds)), _d = _c.next();
472
373
  _g.label = 7;
473
374
  case 7:
474
375
  if (!!_d.done) return [3, 11];
@@ -498,28 +399,28 @@ var changeApprovalProcess = function (ctx, materialApproval, _a) {
498
399
  return [3, 7];
499
400
  case 11: return [3, 14];
500
401
  case 12:
501
- e_5_1 = _g.sent();
502
- e_5 = { error: e_5_1 };
402
+ e_3_1 = _g.sent();
403
+ e_3 = { error: e_3_1 };
503
404
  return [3, 14];
504
405
  case 13:
505
406
  try {
506
407
  if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
507
408
  }
508
- finally { if (e_5) throw e_5.error; }
409
+ finally { if (e_3) throw e_3.error; }
509
410
  return [7];
510
411
  case 14:
511
- nextApprovers_2_1 = nextApprovers_2.next();
412
+ nextApprovers_1_1 = nextApprovers_1.next();
512
413
  return [3, 5];
513
414
  case 15: return [3, 18];
514
415
  case 16:
515
- e_6_1 = _g.sent();
516
- e_6 = { error: e_6_1 };
416
+ e_4_1 = _g.sent();
417
+ e_4 = { error: e_4_1 };
517
418
  return [3, 18];
518
419
  case 17:
519
420
  try {
520
- if (nextApprovers_2_1 && !nextApprovers_2_1.done && (_e = nextApprovers_2.return)) _e.call(nextApprovers_2);
421
+ if (nextApprovers_1_1 && !nextApprovers_1_1.done && (_e = nextApprovers_1.return)) _e.call(nextApprovers_1);
521
422
  }
522
- finally { if (e_6) throw e_6.error; }
423
+ finally { if (e_4) throw e_4.error; }
523
424
  return [7];
524
425
  case 18: return [3, 22];
525
426
  case 19: return [4, ctx.getObject('pepsico_approval_process').insert({
@@ -569,30 +470,90 @@ var setPersonView = function (ctx, materialApproval) { return tslib_1.__awaiter(
569
470
  });
570
471
  }); };
571
472
  var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
572
- var actionLabel, user, record, nextStep, nextApprovers, nextApproversUserIds_1, nextApprovers_3, nextApprovers_3_1, nextApprover, e_7_1, error_3;
573
- var e_7, _a;
574
- return tslib_1.__generator(this, function (_b) {
575
- switch (_b.label) {
473
+ var actionLabel, user, record, nextStep, nextApprovers, _nextApprovers, nextApprovers_2, nextApprovers_2_1, reviewer, fieldName, status, e_5_1, nextApproversUserIds_1, nextApprovers_3, nextApprovers_3_1, nextApprover, e_6_1, error_1;
474
+ var e_5, _a, _b, _c, e_6, _d;
475
+ return tslib_1.__generator(this, function (_e) {
476
+ switch (_e.label) {
576
477
  case 0:
577
- _b.trys.push([0, 41, , 42]);
478
+ _e.trys.push([0, 55, , 56]);
578
479
  actionLabel = '请查看';
579
480
  user = ctx.meta.user;
580
481
  return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
581
482
  case 1:
582
- record = _b.sent();
483
+ record = _e.sent();
583
484
  console.log('[advanceApproval]', record.current_step, record.person_pending_approve, user.userId);
584
485
  if (record.current_step != consts_1.Step.draft && !(0, lodash_1.includes)(record.person_pending_approve, user.userId)) {
585
486
  return [2, {}];
586
487
  }
587
488
  return [4, canSubmit(record)];
588
489
  case 2:
589
- _b.sent();
490
+ _e.sent();
590
491
  return [4, getNextStep(ctx, record, currentStepApprovalStatus)];
591
492
  case 3:
592
- nextStep = _b.sent();
493
+ nextStep = _e.sent();
593
494
  return [4, getNextApprovers(ctx, record, nextStep)];
594
495
  case 4:
595
- nextApprovers = _b.sent();
496
+ nextApprovers = _e.sent();
497
+ if (!(record.current_step === consts_1.Step.submitter_revisions && (nextStep === consts_1.Step.departmental_review || nextStep === consts_1.Step.personnel_review))) return [3, 18];
498
+ _nextApprovers = [];
499
+ _e.label = 5;
500
+ case 5:
501
+ _e.trys.push([5, 13, 14, 15]);
502
+ nextApprovers_2 = tslib_1.__values(nextApprovers), nextApprovers_2_1 = nextApprovers_2.next();
503
+ _e.label = 6;
504
+ case 6:
505
+ if (!!nextApprovers_2_1.done) return [3, 12];
506
+ reviewer = nextApprovers_2_1.value;
507
+ fieldName = (0, material_1.getApproverFieldByType)(reviewer.type);
508
+ console.log("getApproverFieldByType", reviewer.type, fieldName);
509
+ if (!fieldName) {
510
+ return [3, 11];
511
+ }
512
+ return [4, (0, material_1.getUserReviewedAllMaterialsStatus)(ctx, record._id, fieldName)];
513
+ case 7:
514
+ status = _e.sent();
515
+ console.log("getUserReviewedAllMaterialsStatus", record._id, fieldName, status);
516
+ if (!(status === consts_1.ApprovalStatus.approved)) return [3, 9];
517
+ console.log("[advanceApproval] \u81EA\u52A8\u66F4\u65B0\u5BA1\u6279\u5355\u4E0A\u7684\u72B6\u6001\u5B57\u6BB5", recordId, (_b = {},
518
+ _b[fieldName] = consts_1.ApprovalStatus.approved,
519
+ _b));
520
+ return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, (_c = {},
521
+ _c[fieldName] = true,
522
+ _c))];
523
+ case 8:
524
+ _e.sent();
525
+ return [3, 10];
526
+ case 9:
527
+ _nextApprovers.push(reviewer);
528
+ _e.label = 10;
529
+ case 10:
530
+ ;
531
+ _e.label = 11;
532
+ case 11:
533
+ nextApprovers_2_1 = nextApprovers_2.next();
534
+ return [3, 6];
535
+ case 12: return [3, 15];
536
+ case 13:
537
+ e_5_1 = _e.sent();
538
+ e_5 = { error: e_5_1 };
539
+ return [3, 15];
540
+ case 14:
541
+ try {
542
+ if (nextApprovers_2_1 && !nextApprovers_2_1.done && (_a = nextApprovers_2.return)) _a.call(nextApprovers_2);
543
+ }
544
+ finally { if (e_5) throw e_5.error; }
545
+ return [7];
546
+ case 15:
547
+ if (!(_nextApprovers.length > 0)) return [3, 16];
548
+ nextApprovers = _nextApprovers;
549
+ return [3, 18];
550
+ case 16:
551
+ nextStep = consts_1.Step.awaiting_deployment;
552
+ return [4, getNextApprovers(ctx, record, nextStep)];
553
+ case 17:
554
+ nextApprovers = _e.sent();
555
+ _e.label = 18;
556
+ case 18:
596
557
  console.log("[advanceApproval] currentStepApprovalStatus:", currentStepApprovalStatus, " nextStep:", nextStep, " nextApprovers:", nextApprovers);
597
558
  nextApproversUserIds_1 = [];
598
559
  (0, lodash_1.map)(nextApprovers, function (item) {
@@ -608,149 +569,149 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
608
569
  }
609
570
  }
610
571
  })];
611
- case 5:
612
- _b.sent();
572
+ case 19:
573
+ _e.sent();
613
574
  return [4, changeApprovalProcess(ctx, record, {
614
575
  nextStep: nextStep,
615
576
  nextApprovers: nextApprovers,
616
577
  description: ""
617
578
  })];
618
- case 6:
619
- _b.sent();
620
- if (!(nextStep === consts_1.Step.ai_review)) return [3, 8];
579
+ case 20:
580
+ _e.sent();
581
+ if (!(nextStep === consts_1.Step.ai_review)) return [3, 22];
621
582
  console.time('callAIReview: ' + recordId);
622
583
  return [4, (0, AI_1.callAIReview)(ctx, recordId)];
623
- case 7:
624
- _b.sent();
584
+ case 21:
585
+ _e.sent();
625
586
  console.timeEnd('callAIReview: ' + recordId);
626
- _b.label = 8;
627
- case 8:
628
- _b.trys.push([8, 29, 30, 31]);
587
+ _e.label = 22;
588
+ case 22:
589
+ _e.trys.push([22, 43, 44, 45]);
629
590
  nextApprovers_3 = tslib_1.__values(nextApprovers), nextApprovers_3_1 = nextApprovers_3.next();
630
- _b.label = 9;
631
- case 9:
632
- if (!!nextApprovers_3_1.done) return [3, 28];
591
+ _e.label = 23;
592
+ case 23:
593
+ if (!!nextApprovers_3_1.done) return [3, 42];
633
594
  nextApprover = nextApprovers_3_1.value;
634
- if (!(nextApprover.type === consts_1.ProcessApprovalType.CA)) return [3, 12];
595
+ if (!(nextApprover.type === consts_1.ProcessApprovalType.CA)) return [3, 26];
635
596
  return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
636
597
  ca_approval_status: ''
637
598
  })];
638
- case 10:
639
- _b.sent();
599
+ case 24:
600
+ _e.sent();
640
601
  return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['ca_approval_status', '=', false]], {
641
602
  ca_approval_status: ''
642
603
  })];
643
- case 11:
644
- _b.sent();
645
- _b.label = 12;
646
- case 12:
647
- if (!(nextApprover.type === consts_1.ProcessApprovalType.Legal)) return [3, 15];
604
+ case 25:
605
+ _e.sent();
606
+ _e.label = 26;
607
+ case 26:
608
+ if (!(nextApprover.type === consts_1.ProcessApprovalType.Legal)) return [3, 29];
648
609
  return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
649
610
  legal_approval_status: ''
650
611
  })];
651
- case 13:
652
- _b.sent();
612
+ case 27:
613
+ _e.sent();
653
614
  return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['legal_approval_status', '=', false]], {
654
615
  legal_approval_status: ''
655
616
  })];
656
- case 14:
657
- _b.sent();
658
- _b.label = 15;
659
- case 15:
660
- if (!(nextApprover.type === consts_1.ProcessApprovalType.NS)) return [3, 18];
617
+ case 28:
618
+ _e.sent();
619
+ _e.label = 29;
620
+ case 29:
621
+ if (!(nextApprover.type === consts_1.ProcessApprovalType.NS)) return [3, 32];
661
622
  return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
662
623
  ns_approval_status: ''
663
624
  })];
664
- case 16:
665
- _b.sent();
625
+ case 30:
626
+ _e.sent();
666
627
  return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['ns_approval_status', '=', false]], {
667
628
  ns_approval_status: ''
668
629
  })];
669
- case 17:
670
- _b.sent();
671
- _b.label = 18;
672
- case 18:
673
- if (!(nextApprover.type === consts_1.ProcessApprovalType.SRA)) return [3, 21];
630
+ case 31:
631
+ _e.sent();
632
+ _e.label = 32;
633
+ case 32:
634
+ if (!(nextApprover.type === consts_1.ProcessApprovalType.SRA)) return [3, 35];
674
635
  return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
675
636
  sra_approval_status: ''
676
637
  })];
677
- case 19:
678
- _b.sent();
638
+ case 33:
639
+ _e.sent();
679
640
  return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['sra_approval_status', '=', false]], {
680
641
  sra_approval_status: ''
681
642
  })];
682
- case 20:
683
- _b.sent();
684
- _b.label = 21;
685
- case 21:
686
- if (!(nextApprover.type === consts_1.ProcessApprovalType.guding)) return [3, 24];
643
+ case 34:
644
+ _e.sent();
645
+ _e.label = 35;
646
+ case 35:
647
+ if (!(nextApprover.type === consts_1.ProcessApprovalType.guding)) return [3, 38];
687
648
  return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
688
649
  approval_status: ''
689
650
  })];
690
- case 22:
691
- _b.sent();
651
+ case 36:
652
+ _e.sent();
692
653
  return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['approval_status', '=', false]], {
693
654
  approval_status: ''
694
655
  })];
695
- case 23:
696
- _b.sent();
697
- _b.label = 24;
698
- case 24:
699
- if (!(nextApprover.type === consts_1.ProcessApprovalType.Kids)) return [3, 27];
656
+ case 37:
657
+ _e.sent();
658
+ _e.label = 38;
659
+ case 38:
660
+ if (!(nextApprover.type === consts_1.ProcessApprovalType.Kids)) return [3, 41];
700
661
  return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
701
662
  kids_approval_status: ''
702
663
  })];
703
- case 25:
704
- _b.sent();
664
+ case 39:
665
+ _e.sent();
705
666
  return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['kids_approval_status', '=', false]], {
706
667
  kids_approval_status: ''
707
668
  })];
708
- case 26:
709
- _b.sent();
710
- _b.label = 27;
711
- case 27:
669
+ case 40:
670
+ _e.sent();
671
+ _e.label = 41;
672
+ case 41:
712
673
  nextApprovers_3_1 = nextApprovers_3.next();
713
- return [3, 9];
714
- case 28: return [3, 31];
715
- case 29:
716
- e_7_1 = _b.sent();
717
- e_7 = { error: e_7_1 };
718
- return [3, 31];
719
- case 30:
674
+ return [3, 23];
675
+ case 42: return [3, 45];
676
+ case 43:
677
+ e_6_1 = _e.sent();
678
+ e_6 = { error: e_6_1 };
679
+ return [3, 45];
680
+ case 44:
720
681
  try {
721
- if (nextApprovers_3_1 && !nextApprovers_3_1.done && (_a = nextApprovers_3.return)) _a.call(nextApprovers_3);
682
+ if (nextApprovers_3_1 && !nextApprovers_3_1.done && (_d = nextApprovers_3.return)) _d.call(nextApprovers_3);
722
683
  }
723
- finally { if (e_7) throw e_7.error; }
684
+ finally { if (e_6) throw e_6.error; }
724
685
  return [7];
725
- case 31:
726
- if (!(nextStep === consts_1.Step.departmental_review || nextStep === consts_1.Step.personnel_review)) return [3, 33];
686
+ case 45:
687
+ if (!(nextStep === consts_1.Step.departmental_review || nextStep === consts_1.Step.personnel_review)) return [3, 47];
727
688
  return [4, setPersonView(ctx, record)];
728
- case 32:
729
- _b.sent();
730
- _b.label = 33;
731
- case 33:
732
- if (!(record.current_step === consts_1.Step.departmental_review || record.current_step === consts_1.Step.personnel_review)) return [3, 35];
689
+ case 46:
690
+ _e.sent();
691
+ _e.label = 47;
692
+ case 47:
693
+ if (!(record.current_step === consts_1.Step.departmental_review || record.current_step === consts_1.Step.personnel_review)) return [3, 49];
733
694
  return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
734
695
  materials_remove_share_link_from_onedrive_status: 'pending'
735
696
  })];
736
- case 34:
737
- _b.sent();
738
- _b.label = 35;
739
- case 35:
740
- if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 37];
697
+ case 48:
698
+ _e.sent();
699
+ _e.label = 49;
700
+ case 49:
701
+ if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 51];
741
702
  return [4, pendingDeployment(ctx, recordId)];
742
- case 36:
743
- _b.sent();
744
- _b.label = 37;
745
- case 37:
746
- if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 39];
703
+ case 50:
704
+ _e.sent();
705
+ _e.label = 51;
706
+ case 51:
707
+ if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 53];
747
708
  return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
748
709
  materials_download_from_onedrive_status: 'pending'
749
710
  })];
750
- case 38:
751
- _b.sent();
752
- _b.label = 39;
753
- case 39:
711
+ case 52:
712
+ _e.sent();
713
+ _e.label = 53;
714
+ case 53:
754
715
  if (currentStepApprovalStatus === consts_1.ApprovalStatus.rejected) {
755
716
  actionLabel = '内容审批被驳回';
756
717
  }
@@ -761,17 +722,17 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
761
722
  if (nextStep === consts_1.Step.awaiting_deployment) {
762
723
  actionLabel = "\u5185\u5BB9\u5BA1\u6279\u5DF2\u901A\u8FC7\u5F85\u4E0A\u7EBF";
763
724
  }
764
- return [4, sendNotifications(ctx, record, nextApproversUserIds_1, actionLabel)];
765
- case 40:
766
- _b.sent();
725
+ return [4, (0, notification_1.sendNotifications)(ctx, record, nextApproversUserIds_1, actionLabel)];
726
+ case 54:
727
+ _e.sent();
767
728
  return [2, {}];
768
- case 41:
769
- error_3 = _b.sent();
729
+ case 55:
730
+ error_1 = _e.sent();
770
731
  return [2, {
771
- msg: error_3.message,
732
+ msg: error_1.message,
772
733
  status: 500
773
734
  }];
774
- case 42: return [2];
735
+ case 56: return [2];
775
736
  }
776
737
  });
777
738
  }); };
@@ -1019,8 +980,8 @@ var submitKidsContent = function (ctx, recordId, currentStepApprovalStatus) {
1019
980
  exports.submitKidsContent = submitKidsContent;
1020
981
  var submitContent = function (ctx, recordId, currentStepApprovalStatus) {
1021
982
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1022
- var approvalNew, approvalType, allTrue1, allTrue, spaceUsers, owner, materials, materials_1, materials_1_1, material, e_8_1, pendingXmlToWordMaterials, pendingUploadMaterials;
1023
- var e_8, _a;
983
+ var approvalNew, approvalType, allTrue1, allTrue, spaceUsers, owner, materials, materials_1, materials_1_1, material, e_7_1, pendingXmlToWordMaterials, pendingUploadMaterials;
984
+ var e_7, _a;
1024
985
  return tslib_1.__generator(this, function (_b) {
1025
986
  switch (_b.label) {
1026
987
  case 0: return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
@@ -1110,14 +1071,14 @@ var submitContent = function (ctx, recordId, currentStepApprovalStatus) {
1110
1071
  return [3, 13];
1111
1072
  case 16: return [3, 19];
1112
1073
  case 17:
1113
- e_8_1 = _b.sent();
1114
- e_8 = { error: e_8_1 };
1074
+ e_7_1 = _b.sent();
1075
+ e_7 = { error: e_7_1 };
1115
1076
  return [3, 19];
1116
1077
  case 18:
1117
1078
  try {
1118
1079
  if (materials_1_1 && !materials_1_1.done && (_a = materials_1.return)) _a.call(materials_1);
1119
1080
  }
1120
- finally { if (e_8) throw e_8.error; }
1081
+ finally { if (e_7) throw e_7.error; }
1121
1082
  return [7];
1122
1083
  case 19: return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
1123
1084
  case 20: