@steedos-labs/content-compliance 0.7.18 → 0.7.19
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/main/default/objects/pepsico_material_approval/buttons/pepsico_postpone_review.button.yml +1 -1
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_urgent_review.button.yml +1 -1
- package/package.json +1 -1
- package/dist/index.js +0 -1
- package/lib/actions/addBulkMaterials.d.ts +0 -15
- package/lib/actions/addBulkMaterials.js +0 -69
- package/lib/actions/addBulkMaterials.js.map +0 -1
- package/lib/actions/briefFlows.d.ts +0 -14
- package/lib/actions/briefFlows.js +0 -46
- package/lib/actions/briefFlows.js.map +0 -1
- package/lib/actions/bypassApproval.d.ts +0 -10
- package/lib/actions/bypassApproval.js +0 -269
- package/lib/actions/bypassApproval.js.map +0 -1
- package/lib/actions/bypassMaterial.d.ts +0 -10
- package/lib/actions/bypassMaterial.js +0 -190
- package/lib/actions/bypassMaterial.js.map +0 -1
- package/lib/actions/calculateSpotCheckRates.d.ts +0 -13
- package/lib/actions/calculateSpotCheckRates.js +0 -94
- package/lib/actions/calculateSpotCheckRates.js.map +0 -1
- package/lib/actions/collection.d.ts +0 -2
- package/lib/actions/collection.js +0 -26
- package/lib/actions/collection.js.map +0 -1
- package/lib/actions/confirmDeployment.d.ts +0 -7
- package/lib/actions/confirmDeployment.js +0 -31
- package/lib/actions/confirmDeployment.js.map +0 -1
- package/lib/actions/dashboard_sync_data.d.ts +0 -7
- package/lib/actions/dashboard_sync_data.js +0 -30
- package/lib/actions/dashboard_sync_data.js.map +0 -1
- package/lib/actions/fixStuckPersonnelReview.d.ts +0 -20
- package/lib/actions/fixStuckPersonnelReview.js +0 -145
- package/lib/actions/fixStuckPersonnelReview.js.map +0 -1
- package/lib/actions/hasDuplicateMaterials.d.ts +0 -9
- package/lib/actions/hasDuplicateMaterials.js +0 -30
- package/lib/actions/hasDuplicateMaterials.js.map +0 -1
- package/lib/actions/imageComparison.d.ts +0 -34
- package/lib/actions/imageComparison.js +0 -95
- package/lib/actions/imageComparison.js.map +0 -1
- package/lib/actions/index.d.ts +0 -27
- package/lib/actions/index.js +0 -31
- package/lib/actions/index.js.map +0 -1
- package/lib/actions/initCollaborator.d.ts +0 -13
- package/lib/actions/initCollaborator.js +0 -87
- package/lib/actions/initCollaborator.js.map +0 -1
- package/lib/actions/initUrgentQuota.d.ts +0 -17
- package/lib/actions/initUrgentQuota.js +0 -99
- package/lib/actions/initUrgentQuota.js.map +0 -1
- package/lib/actions/migrateReviewCompletedDate.d.ts +0 -21
- package/lib/actions/migrateReviewCompletedDate.js +0 -150
- package/lib/actions/migrateReviewCompletedDate.js.map +0 -1
- package/lib/actions/migrateSpotCheckData.d.ts +0 -23
- package/lib/actions/migrateSpotCheckData.js +0 -143
- package/lib/actions/migrateSpotCheckData.js.map +0 -1
- package/lib/actions/migrateSpotCheckDepartments.d.ts +0 -25
- package/lib/actions/migrateSpotCheckDepartments.js +0 -142
- package/lib/actions/migrateSpotCheckDepartments.js.map +0 -1
- package/lib/actions/postponeDeployment.d.ts +0 -7
- package/lib/actions/postponeDeployment.js +0 -30
- package/lib/actions/postponeDeployment.js.map +0 -1
- package/lib/actions/postponeReview.d.ts +0 -7
- package/lib/actions/postponeReview.js +0 -30
- package/lib/actions/postponeReview.js.map +0 -1
- package/lib/actions/progress.d.ts +0 -18
- package/lib/actions/progress.js +0 -71
- package/lib/actions/progress.js.map +0 -1
- package/lib/actions/rule.d.ts +0 -7
- package/lib/actions/rule.js +0 -27
- package/lib/actions/rule.js.map +0 -1
- package/lib/actions/sendToContentHub.d.ts +0 -7
- package/lib/actions/sendToContentHub.js +0 -37
- package/lib/actions/sendToContentHub.js.map +0 -1
- package/lib/actions/spotCheckMaterial.d.ts +0 -46
- package/lib/actions/spotCheckMaterial.js +0 -591
- package/lib/actions/spotCheckMaterial.js.map +0 -1
- package/lib/actions/submit.d.ts +0 -7
- package/lib/actions/submit.js +0 -48
- package/lib/actions/submit.js.map +0 -1
- package/lib/actions/submitKids.d.ts +0 -7
- package/lib/actions/submitKids.js +0 -30
- package/lib/actions/submitKids.js.map +0 -1
- package/lib/actions/submitMaterial.d.ts +0 -7
- package/lib/actions/submitMaterial.js +0 -30
- package/lib/actions/submitMaterial.js.map +0 -1
- package/lib/actions/submitPreReview.d.ts +0 -7
- package/lib/actions/submitPreReview.js +0 -34
- package/lib/actions/submitPreReview.js.map +0 -1
- package/lib/actions/terminate.d.ts +0 -7
- package/lib/actions/terminate.js +0 -30
- package/lib/actions/terminate.js.map +0 -1
- package/lib/actions/urgentApproval.d.ts +0 -14
- package/lib/actions/urgentApproval.js +0 -51
- package/lib/actions/urgentApproval.js.map +0 -1
- package/lib/const.d.ts +0 -1
- package/lib/const.js +0 -6
- package/lib/const.js.map +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1238
- package/lib/index.js.map +0 -1
- package/lib/methods/AI.d.ts +0 -1
- package/lib/methods/AI.js +0 -45
- package/lib/methods/AI.js.map +0 -1
- package/lib/methods/__tests__/__mocks__/empty.d.ts +0 -2
- package/lib/methods/__tests__/__mocks__/empty.js +0 -4
- package/lib/methods/__tests__/__mocks__/empty.js.map +0 -1
- package/lib/methods/__tests__/postponeReview.test.d.ts +0 -1
- package/lib/methods/__tests__/postponeReview.test.js +0 -102
- package/lib/methods/__tests__/postponeReview.test.js.map +0 -1
- package/lib/methods/__tests__/pre_review_flow.test.d.ts +0 -1
- package/lib/methods/__tests__/pre_review_flow.test.js +0 -583
- package/lib/methods/__tests__/pre_review_flow.test.js.map +0 -1
- package/lib/methods/__tests__/pre_review_helpers.test.d.ts +0 -1
- package/lib/methods/__tests__/pre_review_helpers.test.js +0 -306
- package/lib/methods/__tests__/pre_review_helpers.test.js.map +0 -1
- package/lib/methods/__tests__/urgent.test.d.ts +0 -1
- package/lib/methods/__tests__/urgent.test.js +0 -121
- package/lib/methods/__tests__/urgent.test.js.map +0 -1
- package/lib/methods/agent.d.ts +0 -4
- package/lib/methods/agent.js +0 -86
- package/lib/methods/agent.js.map +0 -1
- package/lib/methods/approval_engine.d.ts +0 -40
- package/lib/methods/approval_engine.js +0 -2302
- package/lib/methods/approval_engine.js.map +0 -1
- package/lib/methods/consts.d.ts +0 -209
- package/lib/methods/consts.js +0 -46
- package/lib/methods/consts.js.map +0 -1
- package/lib/methods/content_hub.d.ts +0 -2
- package/lib/methods/content_hub.js +0 -228
- package/lib/methods/content_hub.js.map +0 -1
- package/lib/methods/dashboard_sync_data.d.ts +0 -4
- package/lib/methods/dashboard_sync_data.js +0 -346
- package/lib/methods/dashboard_sync_data.js.map +0 -1
- package/lib/methods/docx.d.ts +0 -3
- package/lib/methods/docx.js +0 -12
- package/lib/methods/docx.js.map +0 -1
- package/lib/methods/image_comparison.d.ts +0 -39
- package/lib/methods/image_comparison.js +0 -454
- package/lib/methods/image_comparison.js.map +0 -1
- package/lib/methods/index.d.ts +0 -7
- package/lib/methods/index.js +0 -11
- package/lib/methods/index.js.map +0 -1
- package/lib/methods/material.d.ts +0 -15
- package/lib/methods/material.js +0 -756
- package/lib/methods/material.js.map +0 -1
- package/lib/methods/notification.d.ts +0 -4
- package/lib/methods/notification.js +0 -270
- package/lib/methods/notification.js.map +0 -1
- package/lib/methods/password_expiry.d.ts +0 -1
- package/lib/methods/password_expiry.js +0 -151
- package/lib/methods/password_expiry.js.map +0 -1
- package/lib/methods/pls.d.ts +0 -1
- package/lib/methods/pls.js +0 -217
- package/lib/methods/pls.js.map +0 -1
- package/lib/methods/task.d.ts +0 -7
- package/lib/methods/task.js +0 -317
- package/lib/methods/task.js.map +0 -1
- package/lib/methods/urgent.d.ts +0 -20
- package/lib/methods/urgent.js +0 -259
- package/lib/methods/urgent.js.map +0 -1
package/lib/index.js
DELETED
|
@@ -1,1238 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
|
-
var actions = require("./actions");
|
|
5
|
-
var methods = require("./methods");
|
|
6
|
-
var consts_1 = require("./methods/consts");
|
|
7
|
-
var notification_1 = require("./methods/notification");
|
|
8
|
-
var pls_1 = require("./methods/pls");
|
|
9
|
-
var image_comparison_1 = require("./methods/image_comparison");
|
|
10
|
-
var password_expiry_1 = require("./methods/password_expiry");
|
|
11
|
-
var objectql = require('@steedos/objectql');
|
|
12
|
-
var _ = require('lodash');
|
|
13
|
-
var path = require('path');
|
|
14
|
-
var project = require('../package.json');
|
|
15
|
-
var packageName = project.name;
|
|
16
|
-
var CronMixin = require("moleculer-cron");
|
|
17
|
-
var packageLoader = require('@steedos/service-package-loader');
|
|
18
|
-
var moment = require('moment');
|
|
19
|
-
function getCollection(name) {
|
|
20
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
21
|
-
var adapter;
|
|
22
|
-
return tslib_1.__generator(this, function (_a) {
|
|
23
|
-
switch (_a.label) {
|
|
24
|
-
case 0:
|
|
25
|
-
adapter = objectql.getDataSource('default').adapter;
|
|
26
|
-
return [4, adapter.connect()];
|
|
27
|
-
case 1:
|
|
28
|
-
_a.sent();
|
|
29
|
-
return [2, adapter.collection(name)];
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
var STEEDOS_CRON_ENABLED = process.env.STEEDOS_CRON_ENABLED;
|
|
35
|
-
var PEPSICO_CRON_SEND_DELAY_NOTIFICATION_INTERVAL_MINUTES = Number(process.env.PEPSICO_CRON_SEND_DELAY_NOTIFICATION_INTERVAL_MINUTES || 5);
|
|
36
|
-
var PEPSICO_CRON_PASSWORD_EXPIRY_CHECK_DISABLE = process.env.PEPSICO_CRON_PASSWORD_EXPIRY_CHECK_DISABLE === 'true';
|
|
37
|
-
var cronJobs = [
|
|
38
|
-
{
|
|
39
|
-
name: "materialsUploadToOneDriveJob",
|
|
40
|
-
cronTime: process.env.PEPSICO_CRON_MATERIAL_UPLOAD_ONEDRIVE,
|
|
41
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
42
|
-
manualStart: false,
|
|
43
|
-
onTick: function () {
|
|
44
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var e_1;
|
|
46
|
-
return tslib_1.__generator(this, function (_a) {
|
|
47
|
-
switch (_a.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
_a.trys.push([0, 2, , 3]);
|
|
50
|
-
console.log('materialsUploadToOneDriveJob run', new Date());
|
|
51
|
-
return [4, this.broker.call("".concat(packageName, ".materialsUploadToOneDrive"))];
|
|
52
|
-
case 1:
|
|
53
|
-
_a.sent();
|
|
54
|
-
return [3, 3];
|
|
55
|
-
case 2:
|
|
56
|
-
e_1 = _a.sent();
|
|
57
|
-
console.log("materialsUploadToOneDriveJob error ", e_1);
|
|
58
|
-
return [3, 3];
|
|
59
|
-
case 3: return [2];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
onInitialize: function () {
|
|
65
|
-
this.startJob("materialsUploadToOneDriveJob");
|
|
66
|
-
},
|
|
67
|
-
onComplete: function () {
|
|
68
|
-
console.log("materialsUploadToOneDriveJob is stopped");
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: "materialsDownloadFromOneDriveJob",
|
|
73
|
-
cronTime: process.env.PEPSICO_CRON_MATERIAL_DOWNLOAD_ONEDRIVE,
|
|
74
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
75
|
-
manualStart: false,
|
|
76
|
-
onTick: function () {
|
|
77
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
78
|
-
var e_2;
|
|
79
|
-
return tslib_1.__generator(this, function (_a) {
|
|
80
|
-
switch (_a.label) {
|
|
81
|
-
case 0:
|
|
82
|
-
_a.trys.push([0, 2, , 3]);
|
|
83
|
-
console.log('materialsDownloadFromOneDriveJob run', new Date());
|
|
84
|
-
return [4, this.broker.call("".concat(packageName, ".materialsDownloadFromOneDrive"))];
|
|
85
|
-
case 1:
|
|
86
|
-
_a.sent();
|
|
87
|
-
return [3, 3];
|
|
88
|
-
case 2:
|
|
89
|
-
e_2 = _a.sent();
|
|
90
|
-
console.log("materialsDownloadFromOneDriveJob error ", e_2);
|
|
91
|
-
return [3, 3];
|
|
92
|
-
case 3: return [2];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
onInitialize: function () {
|
|
98
|
-
this.startJob("materialsDownloadFromOneDriveJob");
|
|
99
|
-
},
|
|
100
|
-
onComplete: function () {
|
|
101
|
-
console.log("materialsDownloadFromOneDriveJob is stopped");
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: "materialsRemoveShareLinkToOneDriveJob",
|
|
106
|
-
cronTime: process.env.PEPSICO_CRON_MATERIAL_DOWNLOAD_ONEDRIVE,
|
|
107
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
108
|
-
manualStart: false,
|
|
109
|
-
onTick: function () {
|
|
110
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
111
|
-
var e_3;
|
|
112
|
-
return tslib_1.__generator(this, function (_a) {
|
|
113
|
-
switch (_a.label) {
|
|
114
|
-
case 0:
|
|
115
|
-
_a.trys.push([0, 2, , 3]);
|
|
116
|
-
console.log('materialsRemoveShareLinkToOneDriveJob run', new Date());
|
|
117
|
-
return [4, this.broker.call("".concat(packageName, ".materialsRemoveShareLinkToOneDrive"))];
|
|
118
|
-
case 1:
|
|
119
|
-
_a.sent();
|
|
120
|
-
return [3, 3];
|
|
121
|
-
case 2:
|
|
122
|
-
e_3 = _a.sent();
|
|
123
|
-
console.log("materialsRemoveShareLinkToOneDriveJob error ", e_3);
|
|
124
|
-
return [3, 3];
|
|
125
|
-
case 3: return [2];
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
},
|
|
130
|
-
onInitialize: function () {
|
|
131
|
-
this.startJob("materialsRemoveShareLinkToOneDriveJob");
|
|
132
|
-
},
|
|
133
|
-
onComplete: function () {
|
|
134
|
-
console.log("materialsRemoveShareLinkToOneDriveJob is stopped");
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
name: "sendDelayNotificationsJob",
|
|
139
|
-
cronTime: "0 */".concat(PEPSICO_CRON_SEND_DELAY_NOTIFICATION_INTERVAL_MINUTES, " * * * *"),
|
|
140
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
141
|
-
manualStart: false,
|
|
142
|
-
onTick: function () {
|
|
143
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
144
|
-
var e_4;
|
|
145
|
-
return tslib_1.__generator(this, function (_a) {
|
|
146
|
-
switch (_a.label) {
|
|
147
|
-
case 0:
|
|
148
|
-
_a.trys.push([0, 2, , 3]);
|
|
149
|
-
console.log('sendDelayNotificationsJob run', new Date());
|
|
150
|
-
return [4, this.broker.call("".concat(packageName, ".sendDelayNotifications"))];
|
|
151
|
-
case 1:
|
|
152
|
-
_a.sent();
|
|
153
|
-
return [3, 3];
|
|
154
|
-
case 2:
|
|
155
|
-
e_4 = _a.sent();
|
|
156
|
-
console.log("sendDelayNotificationsJob error ", e_4);
|
|
157
|
-
return [3, 3];
|
|
158
|
-
case 3: return [2];
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
},
|
|
163
|
-
onInitialize: function () {
|
|
164
|
-
this.startJob("sendDelayNotificationsJob");
|
|
165
|
-
},
|
|
166
|
-
onComplete: function () {
|
|
167
|
-
console.log("sendDelayNotificationsJob is stopped");
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
name: "processPostponeReviewNotificationsJob",
|
|
171
|
-
cronTime: "0 */".concat(PEPSICO_CRON_SEND_DELAY_NOTIFICATION_INTERVAL_MINUTES, " * * * *"),
|
|
172
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
173
|
-
manualStart: false,
|
|
174
|
-
onTick: function () {
|
|
175
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
176
|
-
var e_5;
|
|
177
|
-
return tslib_1.__generator(this, function (_a) {
|
|
178
|
-
switch (_a.label) {
|
|
179
|
-
case 0:
|
|
180
|
-
_a.trys.push([0, 2, , 3]);
|
|
181
|
-
console.log('processPostponeReviewNotificationsJob run', new Date());
|
|
182
|
-
return [4, this.broker.call("".concat(packageName, ".processPostponeReviewNotifications"))];
|
|
183
|
-
case 1:
|
|
184
|
-
_a.sent();
|
|
185
|
-
return [3, 3];
|
|
186
|
-
case 2:
|
|
187
|
-
e_5 = _a.sent();
|
|
188
|
-
console.log("processPostponeReviewNotificationsJob error ", e_5);
|
|
189
|
-
return [3, 3];
|
|
190
|
-
case 3: return [2];
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
},
|
|
195
|
-
onInitialize: function () {
|
|
196
|
-
this.startJob("processPostponeReviewNotificationsJob");
|
|
197
|
-
},
|
|
198
|
-
onComplete: function () {
|
|
199
|
-
console.log("processPostponeReviewNotificationsJob is stopped");
|
|
200
|
-
}
|
|
201
|
-
}, {
|
|
202
|
-
cronTime: process.env.PEPSICO_CRON_DASHBOARD_SYNC_DATA || '0 3 * * *',
|
|
203
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
204
|
-
manualStart: false,
|
|
205
|
-
onTick: function () {
|
|
206
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
207
|
-
var e_6;
|
|
208
|
-
return tslib_1.__generator(this, function (_a) {
|
|
209
|
-
switch (_a.label) {
|
|
210
|
-
case 0:
|
|
211
|
-
_a.trys.push([0, 2, , 3]);
|
|
212
|
-
console.log('syncDashboard run', new Date());
|
|
213
|
-
return [4, this.broker.call("".concat(packageName, ".dashboardSyncData"))];
|
|
214
|
-
case 1:
|
|
215
|
-
_a.sent();
|
|
216
|
-
return [3, 3];
|
|
217
|
-
case 2:
|
|
218
|
-
e_6 = _a.sent();
|
|
219
|
-
console.log("syncDashboard error ", e_6);
|
|
220
|
-
return [3, 3];
|
|
221
|
-
case 3: return [2];
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
},
|
|
226
|
-
onInitialize: function () {
|
|
227
|
-
this.startJob("syncDashboard");
|
|
228
|
-
},
|
|
229
|
-
onComplete: function () {
|
|
230
|
-
console.log("syncDashboard is stopped");
|
|
231
|
-
}
|
|
232
|
-
}, {
|
|
233
|
-
name: "scanPLSFiles",
|
|
234
|
-
cronTime: process.env.PEPSICO_CRON_PLS_SCAN || '0 23 * * *',
|
|
235
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
236
|
-
manualStart: false,
|
|
237
|
-
onTick: function () {
|
|
238
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
239
|
-
var e_7;
|
|
240
|
-
return tslib_1.__generator(this, function (_a) {
|
|
241
|
-
switch (_a.label) {
|
|
242
|
-
case 0:
|
|
243
|
-
_a.trys.push([0, 2, , 3]);
|
|
244
|
-
console.log('scanPLSFiles run', new Date());
|
|
245
|
-
return [4, this.broker.call("".concat(packageName, ".scanPLSFiles"))];
|
|
246
|
-
case 1:
|
|
247
|
-
_a.sent();
|
|
248
|
-
return [3, 3];
|
|
249
|
-
case 2:
|
|
250
|
-
e_7 = _a.sent();
|
|
251
|
-
console.log("scanPLSFiles error ", e_7);
|
|
252
|
-
return [3, 3];
|
|
253
|
-
case 3: return [2];
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
},
|
|
258
|
-
onInitialize: function () {
|
|
259
|
-
this.startJob("scanPLSFiles");
|
|
260
|
-
},
|
|
261
|
-
onComplete: function () {
|
|
262
|
-
console.log("scanPLSFiles is stopped");
|
|
263
|
-
}
|
|
264
|
-
}, {
|
|
265
|
-
name: "scanInactiveUsers",
|
|
266
|
-
cronTime: process.env.PEPSICO_CRON_INACTIVE_USERS_SCAN || '0 1 * * *',
|
|
267
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
268
|
-
manualStart: false,
|
|
269
|
-
onTick: function () {
|
|
270
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
271
|
-
var e_8;
|
|
272
|
-
return tslib_1.__generator(this, function (_a) {
|
|
273
|
-
switch (_a.label) {
|
|
274
|
-
case 0:
|
|
275
|
-
_a.trys.push([0, 2, , 3]);
|
|
276
|
-
console.log('scanInactiveUsers run', new Date());
|
|
277
|
-
return [4, this.broker.call("".concat(packageName, ".scanInactiveUsers"))];
|
|
278
|
-
case 1:
|
|
279
|
-
_a.sent();
|
|
280
|
-
return [3, 3];
|
|
281
|
-
case 2:
|
|
282
|
-
e_8 = _a.sent();
|
|
283
|
-
console.log("scanInactiveUsers error ", e_8);
|
|
284
|
-
return [3, 3];
|
|
285
|
-
case 3: return [2];
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
},
|
|
290
|
-
onInitialize: function () {
|
|
291
|
-
this.startJob("scanInactiveUsers");
|
|
292
|
-
},
|
|
293
|
-
onComplete: function () {
|
|
294
|
-
console.log("scanInactiveUsers is stopped");
|
|
295
|
-
}
|
|
296
|
-
}, {
|
|
297
|
-
name: "sendMonthlySpotCheckReportJob",
|
|
298
|
-
cronTime: process.env.PEPSICO_CRON_SEND_SPOT_REPORT || '0 10 * * *',
|
|
299
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
300
|
-
manualStart: false,
|
|
301
|
-
onTick: function () {
|
|
302
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
303
|
-
var rid, e_9;
|
|
304
|
-
return tslib_1.__generator(this, function (_a) {
|
|
305
|
-
switch (_a.label) {
|
|
306
|
-
case 0:
|
|
307
|
-
_a.trys.push([0, 4, , 5]);
|
|
308
|
-
console.log('sendMonthlySpotCheckReportJob run', new Date());
|
|
309
|
-
return [4, this.broker.call("".concat(packageName, ".getReportId"))];
|
|
310
|
-
case 1:
|
|
311
|
-
rid = _a.sent();
|
|
312
|
-
if (!rid) return [3, 3];
|
|
313
|
-
return [4, this.broker.call("".concat(packageName, ".sendMonthlySpotCheckReport"), { rid: rid })];
|
|
314
|
-
case 2:
|
|
315
|
-
_a.sent();
|
|
316
|
-
_a.label = 3;
|
|
317
|
-
case 3: return [3, 5];
|
|
318
|
-
case 4:
|
|
319
|
-
e_9 = _a.sent();
|
|
320
|
-
console.log("sendMonthlySpotCheckReportJob error ", e_9);
|
|
321
|
-
return [3, 5];
|
|
322
|
-
case 5: return [2];
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
},
|
|
327
|
-
onInitialize: function () {
|
|
328
|
-
this.startJob("sendMonthlySpotCheckReportJob");
|
|
329
|
-
},
|
|
330
|
-
onComplete: function () {
|
|
331
|
-
console.log("sendMonthlySpotCheckReportJob is stopped");
|
|
332
|
-
}
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
name: "scanApprovalAndDeletedMaterialFromSharepointJob",
|
|
336
|
-
cronTime: process.env.PEPSICO_CRON_DELETE_MATERIAL_FROM_SHAREPOINT || '0 2 * * *',
|
|
337
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
338
|
-
manualStart: false,
|
|
339
|
-
onTick: function () {
|
|
340
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
341
|
-
var e_10;
|
|
342
|
-
return tslib_1.__generator(this, function (_a) {
|
|
343
|
-
switch (_a.label) {
|
|
344
|
-
case 0:
|
|
345
|
-
_a.trys.push([0, 4, , 5]);
|
|
346
|
-
console.log('scanApprovalAndDeletedMaterialFromSharepointJob run', new Date());
|
|
347
|
-
if (!(process.env.PEPSICO_CRON_DELETE_MATERIAL_FROM_SHAREPOINT_DISABLE == 'true')) return [3, 1];
|
|
348
|
-
console.log('已停用自动批量删除Sharepoint过期素材');
|
|
349
|
-
return [3, 3];
|
|
350
|
-
case 1: return [4, this.broker.call("".concat(packageName, ".scanApprovalAndDeletedMaterialFromSharepoint"))];
|
|
351
|
-
case 2:
|
|
352
|
-
_a.sent();
|
|
353
|
-
_a.label = 3;
|
|
354
|
-
case 3: return [3, 5];
|
|
355
|
-
case 4:
|
|
356
|
-
e_10 = _a.sent();
|
|
357
|
-
console.log("scanApprovalAndDeletedMaterialFromSharepointJob error ", e_10);
|
|
358
|
-
return [3, 5];
|
|
359
|
-
case 5: return [2];
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
},
|
|
364
|
-
onInitialize: function () {
|
|
365
|
-
this.startJob("scanApprovalAndDeletedMaterialFromSharepointJob");
|
|
366
|
-
},
|
|
367
|
-
onComplete: function () {
|
|
368
|
-
console.log("scanApprovalAndDeletedMaterialFromSharepointJob is stopped");
|
|
369
|
-
}
|
|
370
|
-
}, {
|
|
371
|
-
name: "imageComparisonJob",
|
|
372
|
-
cronTime: process.env.PEPSICO_CRON_IMAGE_COMPARISON || '*/30 * * * * *',
|
|
373
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
374
|
-
manualStart: false,
|
|
375
|
-
onTick: function () {
|
|
376
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
377
|
-
var e_11;
|
|
378
|
-
return tslib_1.__generator(this, function (_a) {
|
|
379
|
-
switch (_a.label) {
|
|
380
|
-
case 0:
|
|
381
|
-
_a.trys.push([0, 2, , 3]);
|
|
382
|
-
console.log('imageComparisonJob run', new Date());
|
|
383
|
-
return [4, this.broker.call("".concat(packageName, ".processImageComparisons"))];
|
|
384
|
-
case 1:
|
|
385
|
-
_a.sent();
|
|
386
|
-
return [3, 3];
|
|
387
|
-
case 2:
|
|
388
|
-
e_11 = _a.sent();
|
|
389
|
-
console.log("imageComparisonJob error ", e_11);
|
|
390
|
-
return [3, 3];
|
|
391
|
-
case 3: return [2];
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
},
|
|
396
|
-
onInitialize: function () {
|
|
397
|
-
this.startJob("imageComparisonJob");
|
|
398
|
-
},
|
|
399
|
-
onComplete: function () {
|
|
400
|
-
console.log("imageComparisonJob is stopped");
|
|
401
|
-
}
|
|
402
|
-
}, {
|
|
403
|
-
name: "checkUserPasswordExpirationJob",
|
|
404
|
-
cronTime: process.env.PEPSICO_CRON_PASSWORD_EXPIRY_CHECK || '0 10 * * *',
|
|
405
|
-
timeZone: process.env.STEEDOS_CRON_TIME_ZONE || 'Asia/Shanghai',
|
|
406
|
-
manualStart: false,
|
|
407
|
-
onTick: function () {
|
|
408
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
409
|
-
var e_12;
|
|
410
|
-
return tslib_1.__generator(this, function (_a) {
|
|
411
|
-
switch (_a.label) {
|
|
412
|
-
case 0:
|
|
413
|
-
_a.trys.push([0, 2, , 3]);
|
|
414
|
-
if (PEPSICO_CRON_PASSWORD_EXPIRY_CHECK_DISABLE) {
|
|
415
|
-
console.log('已停用 checkUserPasswordExpirationJob');
|
|
416
|
-
return [2];
|
|
417
|
-
}
|
|
418
|
-
console.log('checkUserPasswordExpirationJob run', new Date());
|
|
419
|
-
return [4, this.broker.call("".concat(packageName, ".checkUserPasswordExpiration"))];
|
|
420
|
-
case 1:
|
|
421
|
-
_a.sent();
|
|
422
|
-
return [3, 3];
|
|
423
|
-
case 2:
|
|
424
|
-
e_12 = _a.sent();
|
|
425
|
-
console.log("checkUserPasswordExpirationJob error ", e_12);
|
|
426
|
-
return [3, 3];
|
|
427
|
-
case 3: return [2];
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
});
|
|
431
|
-
},
|
|
432
|
-
onInitialize: function () {
|
|
433
|
-
this.startJob("checkUserPasswordExpirationJob");
|
|
434
|
-
},
|
|
435
|
-
onComplete: function () {
|
|
436
|
-
console.log("checkUserPasswordExpirationJob is stopped");
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
];
|
|
440
|
-
module.exports = {
|
|
441
|
-
name: packageName,
|
|
442
|
-
namespace: "steedos",
|
|
443
|
-
mixins: [packageLoader, CronMixin],
|
|
444
|
-
settings: {
|
|
445
|
-
cronJobs: STEEDOS_CRON_ENABLED == true || STEEDOS_CRON_ENABLED == 'true' ? cronJobs : null,
|
|
446
|
-
},
|
|
447
|
-
metadata: {
|
|
448
|
-
$package: {
|
|
449
|
-
name: project.name,
|
|
450
|
-
path: path.join(__dirname, ".."),
|
|
451
|
-
isPackage: true
|
|
452
|
-
}
|
|
453
|
-
},
|
|
454
|
-
dependencies: ['~packages-standard-objects'],
|
|
455
|
-
actions: tslib_1.__assign(tslib_1.__assign({}, actions), { materialsUploadToOneDrive: function (ctx) {
|
|
456
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
457
|
-
var logger, pendingApprovals, pendingApprovals_1, pendingApprovals_1_1, pendingApproval, allTrue, error_1, e_13_1;
|
|
458
|
-
var e_13, _a;
|
|
459
|
-
return tslib_1.__generator(this, function (_b) {
|
|
460
|
-
switch (_b.label) {
|
|
461
|
-
case 0: return [4, this.getLogger()];
|
|
462
|
-
case 1:
|
|
463
|
-
logger = _b.sent();
|
|
464
|
-
return [4, this.getObject('pepsico_material_approval').find({
|
|
465
|
-
filters: [
|
|
466
|
-
['current_step', '=', 'ai_review'],
|
|
467
|
-
['materials_uploaded_to_onedrive_status', 'in', ['pending', 'failed']],
|
|
468
|
-
],
|
|
469
|
-
top: 10,
|
|
470
|
-
sort: "modified desc"
|
|
471
|
-
})];
|
|
472
|
-
case 2:
|
|
473
|
-
pendingApprovals = _b.sent();
|
|
474
|
-
console.log("定时任务[素材上传到oneDrive] count: " + pendingApprovals.length, { objectName: 'pepsico_material_approval', count: pendingApprovals.length, approvals: _.map(pendingApprovals, function (item) { return _.pick(item, ['_id', 'materials_uploaded_to_onedrive_failed_count', 'current_step', 'materials_uploaded_to_onedrive_status']); }) });
|
|
475
|
-
ctx.meta.user = {
|
|
476
|
-
userId: process.env.PEPSICO_CONTENT_APPROVAL_AI_USERID
|
|
477
|
-
};
|
|
478
|
-
ctx.getObject = this.getObject;
|
|
479
|
-
ctx.logger = logger;
|
|
480
|
-
_b.label = 3;
|
|
481
|
-
case 3:
|
|
482
|
-
_b.trys.push([3, 13, 14, 15]);
|
|
483
|
-
pendingApprovals_1 = tslib_1.__values(pendingApprovals), pendingApprovals_1_1 = pendingApprovals_1.next();
|
|
484
|
-
_b.label = 4;
|
|
485
|
-
case 4:
|
|
486
|
-
if (!!pendingApprovals_1_1.done) return [3, 12];
|
|
487
|
-
pendingApproval = pendingApprovals_1_1.value;
|
|
488
|
-
if (!(!pendingApproval.materials_uploaded_to_onedrive_failed_count || pendingApproval.materials_uploaded_to_onedrive_failed_count < 5)) return [3, 11];
|
|
489
|
-
_b.label = 5;
|
|
490
|
-
case 5:
|
|
491
|
-
_b.trys.push([5, 9, , 11]);
|
|
492
|
-
return [4, this.uploadBulkDocToOneDrive(ctx, pendingApproval._id)];
|
|
493
|
-
case 6:
|
|
494
|
-
allTrue = _b.sent();
|
|
495
|
-
if (!allTrue) return [3, 8];
|
|
496
|
-
return [4, this.submitContent(ctx, pendingApproval._id, consts_1.ApprovalStatus.approved)];
|
|
497
|
-
case 7:
|
|
498
|
-
_b.sent();
|
|
499
|
-
_b.label = 8;
|
|
500
|
-
case 8: return [3, 11];
|
|
501
|
-
case 9:
|
|
502
|
-
error_1 = _b.sent();
|
|
503
|
-
return [4, this.getObject('pepsico_material_approval').directUpdate(pendingApproval._id, {
|
|
504
|
-
materials_uploaded_to_onedrive_status: 'failed',
|
|
505
|
-
$inc: {
|
|
506
|
-
materials_uploaded_to_onedrive_failed_count: 1
|
|
507
|
-
}
|
|
508
|
-
})];
|
|
509
|
-
case 10:
|
|
510
|
-
_b.sent();
|
|
511
|
-
logger.error("".concat(pendingApproval._id, "-[\u7D20\u6750\u4E0A\u4F20\u5230oneDrive\u5931\u8D25]:").concat(error_1.message), { objectName: 'pepsico_material_approval', _id: pendingApproval._id });
|
|
512
|
-
return [3, 11];
|
|
513
|
-
case 11:
|
|
514
|
-
pendingApprovals_1_1 = pendingApprovals_1.next();
|
|
515
|
-
return [3, 4];
|
|
516
|
-
case 12: return [3, 15];
|
|
517
|
-
case 13:
|
|
518
|
-
e_13_1 = _b.sent();
|
|
519
|
-
e_13 = { error: e_13_1 };
|
|
520
|
-
return [3, 15];
|
|
521
|
-
case 14:
|
|
522
|
-
try {
|
|
523
|
-
if (pendingApprovals_1_1 && !pendingApprovals_1_1.done && (_a = pendingApprovals_1.return)) _a.call(pendingApprovals_1);
|
|
524
|
-
}
|
|
525
|
-
finally { if (e_13) throw e_13.error; }
|
|
526
|
-
return [7];
|
|
527
|
-
case 15: return [2];
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
});
|
|
531
|
-
}, materialsDownloadFromOneDrive: function (ctx) {
|
|
532
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
533
|
-
var logger, pendingApprovals, pendingApprovals_2, pendingApprovals_2_1, pendingApproval, error_2, e_14_1;
|
|
534
|
-
var e_14, _a;
|
|
535
|
-
return tslib_1.__generator(this, function (_b) {
|
|
536
|
-
switch (_b.label) {
|
|
537
|
-
case 0: return [4, this.getLogger()];
|
|
538
|
-
case 1:
|
|
539
|
-
logger = _b.sent();
|
|
540
|
-
return [4, this.getObject('pepsico_material_approval').find({
|
|
541
|
-
filters: [
|
|
542
|
-
['current_step', '=', ['awaiting_deployment', 'conclusion']],
|
|
543
|
-
['materials_download_from_onedrive_status', 'in', ['pending', 'failed']],
|
|
544
|
-
],
|
|
545
|
-
top: 10,
|
|
546
|
-
sort: "modified desc"
|
|
547
|
-
})];
|
|
548
|
-
case 2:
|
|
549
|
-
pendingApprovals = _b.sent();
|
|
550
|
-
console.log("定时任务[从oneDrive下载素材] count: " + pendingApprovals.length, { objectName: 'pepsico_material_approval', count: pendingApprovals.length, approvals: _.map(pendingApprovals, function (item) { return _.pick(item, ['_id', 'materials_download_from_onedrive_failed_count', 'current_step', 'materials_download_from_onedrive_status']); }) });
|
|
551
|
-
ctx.meta.user = {
|
|
552
|
-
userId: process.env.PEPSICO_CONTENT_APPROVAL_AI_USERID
|
|
553
|
-
};
|
|
554
|
-
ctx.getObject = this.getObject;
|
|
555
|
-
ctx.logger = logger;
|
|
556
|
-
_b.label = 3;
|
|
557
|
-
case 3:
|
|
558
|
-
_b.trys.push([3, 11, 12, 13]);
|
|
559
|
-
pendingApprovals_2 = tslib_1.__values(pendingApprovals), pendingApprovals_2_1 = pendingApprovals_2.next();
|
|
560
|
-
_b.label = 4;
|
|
561
|
-
case 4:
|
|
562
|
-
if (!!pendingApprovals_2_1.done) return [3, 10];
|
|
563
|
-
pendingApproval = pendingApprovals_2_1.value;
|
|
564
|
-
if (!(!pendingApproval.materials_download_from_onedrive_failed_count || pendingApproval.materials_download_from_onedrive_failed_count < 5)) return [3, 9];
|
|
565
|
-
_b.label = 5;
|
|
566
|
-
case 5:
|
|
567
|
-
_b.trys.push([5, 7, , 9]);
|
|
568
|
-
return [4, this.downloadBulkFromOneDriveDoc(ctx, pendingApproval._id)];
|
|
569
|
-
case 6:
|
|
570
|
-
_b.sent();
|
|
571
|
-
return [3, 9];
|
|
572
|
-
case 7:
|
|
573
|
-
error_2 = _b.sent();
|
|
574
|
-
return [4, this.getObject('pepsico_material_approval').directUpdate(pendingApproval._id, {
|
|
575
|
-
materials_download_from_onedrive_status: 'failed',
|
|
576
|
-
$inc: {
|
|
577
|
-
materials_download_from_onedrive_failed_count: 1
|
|
578
|
-
}
|
|
579
|
-
})];
|
|
580
|
-
case 8:
|
|
581
|
-
_b.sent();
|
|
582
|
-
logger.error("".concat(pendingApproval._id, "-[\u4ECEoneDrive\u4E0B\u8F7D\u7D20\u6750\u5931\u8D25]:").concat(error_2.message), { objectName: 'pepsico_material_approval', _id: pendingApproval._id });
|
|
583
|
-
return [3, 9];
|
|
584
|
-
case 9:
|
|
585
|
-
pendingApprovals_2_1 = pendingApprovals_2.next();
|
|
586
|
-
return [3, 4];
|
|
587
|
-
case 10: return [3, 13];
|
|
588
|
-
case 11:
|
|
589
|
-
e_14_1 = _b.sent();
|
|
590
|
-
e_14 = { error: e_14_1 };
|
|
591
|
-
return [3, 13];
|
|
592
|
-
case 12:
|
|
593
|
-
try {
|
|
594
|
-
if (pendingApprovals_2_1 && !pendingApprovals_2_1.done && (_a = pendingApprovals_2.return)) _a.call(pendingApprovals_2);
|
|
595
|
-
}
|
|
596
|
-
finally { if (e_14) throw e_14.error; }
|
|
597
|
-
return [7];
|
|
598
|
-
case 13: return [2];
|
|
599
|
-
}
|
|
600
|
-
});
|
|
601
|
-
});
|
|
602
|
-
}, materialsRemoveShareLinkToOneDrive: function (ctx) {
|
|
603
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
604
|
-
var logger, pendingApprovals, pendingApprovals_3, pendingApprovals_3_1, pendingApproval, error_3, e_15_1;
|
|
605
|
-
var e_15, _a;
|
|
606
|
-
return tslib_1.__generator(this, function (_b) {
|
|
607
|
-
switch (_b.label) {
|
|
608
|
-
case 0: return [4, this.getLogger()];
|
|
609
|
-
case 1:
|
|
610
|
-
logger = _b.sent();
|
|
611
|
-
return [4, this.getObject('pepsico_material_approval').find({
|
|
612
|
-
filters: [
|
|
613
|
-
['current_step', '=', ['awaiting_deployment', 'conclusion']],
|
|
614
|
-
['materials_remove_share_link_from_onedrive_status', 'in', ['pending', 'failed']],
|
|
615
|
-
],
|
|
616
|
-
top: 10,
|
|
617
|
-
sort: "modified desc"
|
|
618
|
-
})];
|
|
619
|
-
case 2:
|
|
620
|
-
pendingApprovals = _b.sent();
|
|
621
|
-
console.log("定时任务[从oneDrive删除共享连接] count: " + pendingApprovals.length, { objectName: 'pepsico_material_approval', count: pendingApprovals.length, approvals: _.map(pendingApprovals, function (item) { return _.pick(item, ['_id', 'materials_remove_share_link_from_onedrive_failed_count', 'current_step', 'materials_remove_share_link_from_onedrive_status']); }) });
|
|
622
|
-
ctx.meta.user = {
|
|
623
|
-
userId: process.env.PEPSICO_CONTENT_APPROVAL_AI_USERID
|
|
624
|
-
};
|
|
625
|
-
ctx.getObject = this.getObject;
|
|
626
|
-
ctx.logger = logger;
|
|
627
|
-
_b.label = 3;
|
|
628
|
-
case 3:
|
|
629
|
-
_b.trys.push([3, 11, 12, 13]);
|
|
630
|
-
pendingApprovals_3 = tslib_1.__values(pendingApprovals), pendingApprovals_3_1 = pendingApprovals_3.next();
|
|
631
|
-
_b.label = 4;
|
|
632
|
-
case 4:
|
|
633
|
-
if (!!pendingApprovals_3_1.done) return [3, 10];
|
|
634
|
-
pendingApproval = pendingApprovals_3_1.value;
|
|
635
|
-
if (!(!pendingApproval.materials_remove_share_link_from_onedrive_failed_count || pendingApproval.materials_remove_share_link_from_onedrive_failed_count < 5)) return [3, 9];
|
|
636
|
-
_b.label = 5;
|
|
637
|
-
case 5:
|
|
638
|
-
_b.trys.push([5, 7, , 9]);
|
|
639
|
-
return [4, this.deleteBulkDocOneDriveShareLink(ctx, pendingApproval._id)];
|
|
640
|
-
case 6:
|
|
641
|
-
_b.sent();
|
|
642
|
-
return [3, 9];
|
|
643
|
-
case 7:
|
|
644
|
-
error_3 = _b.sent();
|
|
645
|
-
return [4, this.getObject('pepsico_material_approval').directUpdate(pendingApproval._id, {
|
|
646
|
-
materials_remove_share_link_from_onedrive_status: 'failed',
|
|
647
|
-
$inc: {
|
|
648
|
-
materials_remove_share_link_from_onedrive_failed_count: 1
|
|
649
|
-
}
|
|
650
|
-
})];
|
|
651
|
-
case 8:
|
|
652
|
-
_b.sent();
|
|
653
|
-
logger.error("".concat(pendingApproval._id, "-[\u4ECEoneDrive\u5220\u9664\u5171\u4EAB\u8FDE\u63A5\u5931\u8D25]:").concat(error_3.message), { objectName: 'pepsico_material_approval', _id: pendingApproval._id });
|
|
654
|
-
return [3, 9];
|
|
655
|
-
case 9:
|
|
656
|
-
pendingApprovals_3_1 = pendingApprovals_3.next();
|
|
657
|
-
return [3, 4];
|
|
658
|
-
case 10: return [3, 13];
|
|
659
|
-
case 11:
|
|
660
|
-
e_15_1 = _b.sent();
|
|
661
|
-
e_15 = { error: e_15_1 };
|
|
662
|
-
return [3, 13];
|
|
663
|
-
case 12:
|
|
664
|
-
try {
|
|
665
|
-
if (pendingApprovals_3_1 && !pendingApprovals_3_1.done && (_a = pendingApprovals_3.return)) _a.call(pendingApprovals_3);
|
|
666
|
-
}
|
|
667
|
-
finally { if (e_15) throw e_15.error; }
|
|
668
|
-
return [7];
|
|
669
|
-
case 13: return [2];
|
|
670
|
-
}
|
|
671
|
-
});
|
|
672
|
-
});
|
|
673
|
-
}, sendDelayNotifications: function (ctx) {
|
|
674
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
675
|
-
var logger;
|
|
676
|
-
return tslib_1.__generator(this, function (_a) {
|
|
677
|
-
switch (_a.label) {
|
|
678
|
-
case 0: return [4, this.getLogger()];
|
|
679
|
-
case 1:
|
|
680
|
-
logger = _a.sent();
|
|
681
|
-
ctx.getObject = this.getObject;
|
|
682
|
-
ctx.logger = logger;
|
|
683
|
-
return [4, (0, notification_1.sendDelayNotifications)(ctx, PEPSICO_CRON_SEND_DELAY_NOTIFICATION_INTERVAL_MINUTES)];
|
|
684
|
-
case 2:
|
|
685
|
-
_a.sent();
|
|
686
|
-
return [2];
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
});
|
|
690
|
-
}, processPostponeReviewNotifications: function (ctx) {
|
|
691
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
692
|
-
var logger;
|
|
693
|
-
return tslib_1.__generator(this, function (_a) {
|
|
694
|
-
switch (_a.label) {
|
|
695
|
-
case 0: return [4, this.getLogger()];
|
|
696
|
-
case 1:
|
|
697
|
-
logger = _a.sent();
|
|
698
|
-
ctx.getObject = this.getObject;
|
|
699
|
-
ctx.logger = logger;
|
|
700
|
-
return [4, (0, notification_1.processPostponeReviewNotifications)(ctx, PEPSICO_CRON_SEND_DELAY_NOTIFICATION_INTERVAL_MINUTES)];
|
|
701
|
-
case 2:
|
|
702
|
-
_a.sent();
|
|
703
|
-
return [2];
|
|
704
|
-
}
|
|
705
|
-
});
|
|
706
|
-
});
|
|
707
|
-
}, processImageComparisons: function (ctx) {
|
|
708
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
709
|
-
var logger;
|
|
710
|
-
return tslib_1.__generator(this, function (_a) {
|
|
711
|
-
switch (_a.label) {
|
|
712
|
-
case 0: return [4, this.getLogger()];
|
|
713
|
-
case 1:
|
|
714
|
-
logger = _a.sent();
|
|
715
|
-
ctx.meta.user = {
|
|
716
|
-
userId: process.env.PEPSICO_CONTENT_APPROVAL_AI_USERID
|
|
717
|
-
};
|
|
718
|
-
ctx.getObject = this.getObject;
|
|
719
|
-
ctx.logger = logger;
|
|
720
|
-
return [4, (0, image_comparison_1.processPendingImageComparisons)(ctx)];
|
|
721
|
-
case 2:
|
|
722
|
-
_a.sent();
|
|
723
|
-
return [2];
|
|
724
|
-
}
|
|
725
|
-
});
|
|
726
|
-
});
|
|
727
|
-
}, checkUserPasswordExpiration: function (ctx) {
|
|
728
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
729
|
-
var logger;
|
|
730
|
-
return tslib_1.__generator(this, function (_a) {
|
|
731
|
-
switch (_a.label) {
|
|
732
|
-
case 0: return [4, this.getLogger()];
|
|
733
|
-
case 1:
|
|
734
|
-
logger = _a.sent();
|
|
735
|
-
ctx.getObject = this.getObject;
|
|
736
|
-
ctx.logger = logger;
|
|
737
|
-
return [4, (0, password_expiry_1.checkUserPasswordExpiration)(ctx)];
|
|
738
|
-
case 2:
|
|
739
|
-
_a.sent();
|
|
740
|
-
return [2];
|
|
741
|
-
}
|
|
742
|
-
});
|
|
743
|
-
});
|
|
744
|
-
}, scanPLSFiles: {
|
|
745
|
-
rest: {
|
|
746
|
-
method: 'GET',
|
|
747
|
-
fullPath: '/api/pepsico-content/scan/pls'
|
|
748
|
-
},
|
|
749
|
-
handler: function (ctx) {
|
|
750
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
751
|
-
var user, logger, addPLSCount;
|
|
752
|
-
return tslib_1.__generator(this, function (_a) {
|
|
753
|
-
switch (_a.label) {
|
|
754
|
-
case 0:
|
|
755
|
-
user = ctx.meta.user;
|
|
756
|
-
if (user && !user.is_space_admin) {
|
|
757
|
-
return [2, { error: '没有权限' }];
|
|
758
|
-
}
|
|
759
|
-
return [4, this.getLogger()];
|
|
760
|
-
case 1:
|
|
761
|
-
logger = _a.sent();
|
|
762
|
-
ctx.getObject = this.getObject;
|
|
763
|
-
ctx.logger = logger;
|
|
764
|
-
return [4, (0, pls_1.scanPLSFiles)(ctx)];
|
|
765
|
-
case 2:
|
|
766
|
-
addPLSCount = _a.sent();
|
|
767
|
-
return [2, {
|
|
768
|
-
'新增PLS记录数量': addPLSCount
|
|
769
|
-
}];
|
|
770
|
-
}
|
|
771
|
-
});
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
}, scanInactiveUsers: {
|
|
775
|
-
rest: {
|
|
776
|
-
method: 'GET',
|
|
777
|
-
fullPath: '/api/pepsico-content/scan/inactive-users'
|
|
778
|
-
},
|
|
779
|
-
handler: function (ctx) {
|
|
780
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
781
|
-
var user, logger, today, ninetyDaysAgo, coll, suColl, users, users_1, users_1_1, user_1, e_16_1;
|
|
782
|
-
var e_16, _a;
|
|
783
|
-
return tslib_1.__generator(this, function (_b) {
|
|
784
|
-
switch (_b.label) {
|
|
785
|
-
case 0:
|
|
786
|
-
user = ctx.meta.user;
|
|
787
|
-
if (user && !user.is_space_admin) {
|
|
788
|
-
return [2, { error: '没有权限' }];
|
|
789
|
-
}
|
|
790
|
-
return [4, this.getLogger()];
|
|
791
|
-
case 1:
|
|
792
|
-
logger = _b.sent();
|
|
793
|
-
ctx.getObject = this.getObject;
|
|
794
|
-
ctx.logger = logger;
|
|
795
|
-
today = new Date();
|
|
796
|
-
ninetyDaysAgo = new Date();
|
|
797
|
-
ninetyDaysAgo.setDate(today.getDate() - 90);
|
|
798
|
-
return [4, getCollection('users')];
|
|
799
|
-
case 2:
|
|
800
|
-
coll = _b.sent();
|
|
801
|
-
return [4, getCollection('space_users')];
|
|
802
|
-
case 3:
|
|
803
|
-
suColl = _b.sent();
|
|
804
|
-
return [4, coll.updateMany({}, {
|
|
805
|
-
$set: {
|
|
806
|
-
login_expired: false
|
|
807
|
-
}
|
|
808
|
-
})];
|
|
809
|
-
case 4:
|
|
810
|
-
_b.sent();
|
|
811
|
-
return [4, suColl.updateMany({}, {
|
|
812
|
-
$set: {
|
|
813
|
-
login_expired: false
|
|
814
|
-
}
|
|
815
|
-
})];
|
|
816
|
-
case 5:
|
|
817
|
-
_b.sent();
|
|
818
|
-
return [4, coll.find({
|
|
819
|
-
$or: [
|
|
820
|
-
{
|
|
821
|
-
$and: [
|
|
822
|
-
{ last_logon: { $ne: null } },
|
|
823
|
-
{ last_logon: { $lt: ninetyDaysAgo } }
|
|
824
|
-
]
|
|
825
|
-
},
|
|
826
|
-
{
|
|
827
|
-
$and: [
|
|
828
|
-
{ last_logon: null },
|
|
829
|
-
{ created: { $lt: ninetyDaysAgo } }
|
|
830
|
-
]
|
|
831
|
-
}
|
|
832
|
-
]
|
|
833
|
-
}).toArray()];
|
|
834
|
-
case 6:
|
|
835
|
-
users = _b.sent();
|
|
836
|
-
_b.label = 7;
|
|
837
|
-
case 7:
|
|
838
|
-
_b.trys.push([7, 13, 14, 15]);
|
|
839
|
-
users_1 = tslib_1.__values(users), users_1_1 = users_1.next();
|
|
840
|
-
_b.label = 8;
|
|
841
|
-
case 8:
|
|
842
|
-
if (!!users_1_1.done) return [3, 12];
|
|
843
|
-
user_1 = users_1_1.value;
|
|
844
|
-
return [4, this.getObject('users').directUpdate(user_1._id, {
|
|
845
|
-
login_expired: true
|
|
846
|
-
})];
|
|
847
|
-
case 9:
|
|
848
|
-
_b.sent();
|
|
849
|
-
return [4, this.getObject('space_users').directUpdateMany(['user', '=', user_1._id], {
|
|
850
|
-
login_expired: true
|
|
851
|
-
})];
|
|
852
|
-
case 10:
|
|
853
|
-
_b.sent();
|
|
854
|
-
_b.label = 11;
|
|
855
|
-
case 11:
|
|
856
|
-
users_1_1 = users_1.next();
|
|
857
|
-
return [3, 8];
|
|
858
|
-
case 12: return [3, 15];
|
|
859
|
-
case 13:
|
|
860
|
-
e_16_1 = _b.sent();
|
|
861
|
-
e_16 = { error: e_16_1 };
|
|
862
|
-
return [3, 15];
|
|
863
|
-
case 14:
|
|
864
|
-
try {
|
|
865
|
-
if (users_1_1 && !users_1_1.done && (_a = users_1.return)) _a.call(users_1);
|
|
866
|
-
}
|
|
867
|
-
finally { if (e_16) throw e_16.error; }
|
|
868
|
-
return [7];
|
|
869
|
-
case 15: return [2, {
|
|
870
|
-
'新增90天未登录用户数量': users.length
|
|
871
|
-
}];
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
}, getReportId: function (ctx) {
|
|
877
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
878
|
-
var logger, lastMonth, report, day, dayOfWeek, spaces, newReport;
|
|
879
|
-
return tslib_1.__generator(this, function (_a) {
|
|
880
|
-
switch (_a.label) {
|
|
881
|
-
case 0: return [4, this.getLogger()];
|
|
882
|
-
case 1:
|
|
883
|
-
logger = _a.sent();
|
|
884
|
-
ctx.getObject = this.getObject;
|
|
885
|
-
ctx.logger = logger;
|
|
886
|
-
lastMonth = moment().subtract(1, 'month').format('YYYY-MM');
|
|
887
|
-
return [4, ctx.getObject('pepsico_spot_check_report').directFind({
|
|
888
|
-
filters: ['year_month', '=', lastMonth]
|
|
889
|
-
})];
|
|
890
|
-
case 2:
|
|
891
|
-
report = _a.sent();
|
|
892
|
-
if (report.length > 0) {
|
|
893
|
-
return [2];
|
|
894
|
-
}
|
|
895
|
-
day = moment().get('date');
|
|
896
|
-
dayOfWeek = moment().day();
|
|
897
|
-
return [4, ctx.getObject('spaces').find({ filters: [] })];
|
|
898
|
-
case 3:
|
|
899
|
-
spaces = _a.sent();
|
|
900
|
-
if (!(day >= 10 && dayOfWeek != 0 && dayOfWeek != 6)) return [3, 5];
|
|
901
|
-
return [4, ctx.getObject('pepsico_spot_check_report').directInsert({
|
|
902
|
-
name: "Report-".concat(lastMonth),
|
|
903
|
-
year_month: lastMonth,
|
|
904
|
-
owner: spaces[0].owner,
|
|
905
|
-
space: spaces[0]._id,
|
|
906
|
-
created: new Date(),
|
|
907
|
-
modified: new Date(),
|
|
908
|
-
created_by: spaces[0].owner,
|
|
909
|
-
modified_by: spaces[0].owner
|
|
910
|
-
})];
|
|
911
|
-
case 4:
|
|
912
|
-
newReport = _a.sent();
|
|
913
|
-
return [2, newReport._id];
|
|
914
|
-
case 5: return [2];
|
|
915
|
-
}
|
|
916
|
-
});
|
|
917
|
-
});
|
|
918
|
-
}, permanentDeleteMaterialFromSharePoint: {
|
|
919
|
-
rest: {
|
|
920
|
-
method: 'POST',
|
|
921
|
-
fullPath: '/api/pepsico-content/material/permanent-delete'
|
|
922
|
-
},
|
|
923
|
-
handler: function (ctx) {
|
|
924
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
925
|
-
var user, id, material, error_4;
|
|
926
|
-
return tslib_1.__generator(this, function (_a) {
|
|
927
|
-
switch (_a.label) {
|
|
928
|
-
case 0:
|
|
929
|
-
user = ctx.meta.user;
|
|
930
|
-
if (user && !user.is_space_admin) {
|
|
931
|
-
return [2, { error: '没有权限' }];
|
|
932
|
-
}
|
|
933
|
-
ctx.getObject = this.getObject;
|
|
934
|
-
id = ctx.params.id;
|
|
935
|
-
return [4, ctx.getObject('pepsico_material').findOne(id)];
|
|
936
|
-
case 1:
|
|
937
|
-
material = _a.sent();
|
|
938
|
-
if (!material) {
|
|
939
|
-
return [2, { error: '无效的ID' }];
|
|
940
|
-
}
|
|
941
|
-
_a.label = 2;
|
|
942
|
-
case 2:
|
|
943
|
-
_a.trys.push([2, 6, , 8]);
|
|
944
|
-
return [4, ctx.broker.call('content-version-bridge.material_permanentDeleteFromOneDrive', {
|
|
945
|
-
material: material
|
|
946
|
-
})];
|
|
947
|
-
case 3:
|
|
948
|
-
_a.sent();
|
|
949
|
-
return [4, ctx.getObject('pepsico_material').directUpdate(material._id, {
|
|
950
|
-
permanent_deleted: true,
|
|
951
|
-
permanent_deleted_date: new Date()
|
|
952
|
-
})];
|
|
953
|
-
case 4:
|
|
954
|
-
_a.sent();
|
|
955
|
-
return [4, ctx.logger.info("[\u6C38\u4E45\u5220\u9664sharepoint\u7D20\u6750]-".concat(material.pepsico_material_approval, "-").concat(material._id), {
|
|
956
|
-
pepsico_material_approval: material.pepsico_material_approval,
|
|
957
|
-
material: material._id
|
|
958
|
-
})];
|
|
959
|
-
case 5:
|
|
960
|
-
_a.sent();
|
|
961
|
-
return [3, 8];
|
|
962
|
-
case 6:
|
|
963
|
-
error_4 = _a.sent();
|
|
964
|
-
console.log("error", error_4);
|
|
965
|
-
return [4, ctx.logger.error("[\u6C38\u4E45\u5220\u9664sharepoint\u7D20\u6750]-".concat(material.pepsico_material_approval, "-").concat(material._id), {
|
|
966
|
-
pepsico_material_approval: material.pepsico_material_approval,
|
|
967
|
-
material: material._id,
|
|
968
|
-
error: error_4.message
|
|
969
|
-
})];
|
|
970
|
-
case 7:
|
|
971
|
-
_a.sent();
|
|
972
|
-
return [3, 8];
|
|
973
|
-
case 8: return [2, {}];
|
|
974
|
-
}
|
|
975
|
-
});
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
}, scanApprovalAndDeletedMaterialFromSharepoint: function (ctx) {
|
|
979
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
980
|
-
var logger, lastMonth, approvalRecords, approvalRecords_1, approvalRecords_1_1, approval, e_17_1;
|
|
981
|
-
var e_17, _a;
|
|
982
|
-
return tslib_1.__generator(this, function (_b) {
|
|
983
|
-
switch (_b.label) {
|
|
984
|
-
case 0: return [4, this.getLogger()];
|
|
985
|
-
case 1:
|
|
986
|
-
logger = _b.sent();
|
|
987
|
-
ctx.getObject = this.getObject;
|
|
988
|
-
ctx.logger = logger;
|
|
989
|
-
lastMonth = moment().subtract(3, 'month').toDate();
|
|
990
|
-
return [4, ctx.getObject('pepsico_material_approval').find({
|
|
991
|
-
filters: [['permanent_deleted', '!=', true], ['review_status', '=', 'approved'], ['current_step', '=', 'conclusion'], ['modified', '<=', lastMonth]]
|
|
992
|
-
})];
|
|
993
|
-
case 2:
|
|
994
|
-
approvalRecords = _b.sent();
|
|
995
|
-
_b.label = 3;
|
|
996
|
-
case 3:
|
|
997
|
-
_b.trys.push([3, 8, 9, 10]);
|
|
998
|
-
approvalRecords_1 = tslib_1.__values(approvalRecords), approvalRecords_1_1 = approvalRecords_1.next();
|
|
999
|
-
_b.label = 4;
|
|
1000
|
-
case 4:
|
|
1001
|
-
if (!!approvalRecords_1_1.done) return [3, 7];
|
|
1002
|
-
approval = approvalRecords_1_1.value;
|
|
1003
|
-
return [4, this.permanentlyDeleteApprovalAllMaterialFromSharePoint(ctx, approval)];
|
|
1004
|
-
case 5:
|
|
1005
|
-
_b.sent();
|
|
1006
|
-
_b.label = 6;
|
|
1007
|
-
case 6:
|
|
1008
|
-
approvalRecords_1_1 = approvalRecords_1.next();
|
|
1009
|
-
return [3, 4];
|
|
1010
|
-
case 7: return [3, 10];
|
|
1011
|
-
case 8:
|
|
1012
|
-
e_17_1 = _b.sent();
|
|
1013
|
-
e_17 = { error: e_17_1 };
|
|
1014
|
-
return [3, 10];
|
|
1015
|
-
case 9:
|
|
1016
|
-
try {
|
|
1017
|
-
if (approvalRecords_1_1 && !approvalRecords_1_1.done && (_a = approvalRecords_1.return)) _a.call(approvalRecords_1);
|
|
1018
|
-
}
|
|
1019
|
-
finally { if (e_17) throw e_17.error; }
|
|
1020
|
-
return [7];
|
|
1021
|
-
case 10: return [2];
|
|
1022
|
-
}
|
|
1023
|
-
});
|
|
1024
|
-
});
|
|
1025
|
-
}, permanentlyDeleteApprovalAllMaterialFromSharePoint: {
|
|
1026
|
-
rest: {
|
|
1027
|
-
method: 'POST',
|
|
1028
|
-
fullPath: '/api/pepsico-content/approval/permanent-delete'
|
|
1029
|
-
},
|
|
1030
|
-
handler: function (ctx) {
|
|
1031
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1032
|
-
var user, logger, id, approval;
|
|
1033
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1034
|
-
switch (_a.label) {
|
|
1035
|
-
case 0:
|
|
1036
|
-
user = ctx.meta.user;
|
|
1037
|
-
if (user && !user.is_space_admin) {
|
|
1038
|
-
return [2, { error: '没有权限' }];
|
|
1039
|
-
}
|
|
1040
|
-
return [4, this.getLogger()];
|
|
1041
|
-
case 1:
|
|
1042
|
-
logger = _a.sent();
|
|
1043
|
-
ctx.getObject = this.getObject;
|
|
1044
|
-
ctx.logger = logger;
|
|
1045
|
-
id = ctx.params.id;
|
|
1046
|
-
return [4, ctx.getObject('pepsico_material_approval').findOne(id)];
|
|
1047
|
-
case 2:
|
|
1048
|
-
approval = _a.sent();
|
|
1049
|
-
if (!approval) {
|
|
1050
|
-
return [2, { error: '无效的ID' }];
|
|
1051
|
-
}
|
|
1052
|
-
return [4, this.permanentlyDeleteApprovalAllMaterialFromSharePoint(ctx, approval)];
|
|
1053
|
-
case 3:
|
|
1054
|
-
_a.sent();
|
|
1055
|
-
return [2, {}];
|
|
1056
|
-
}
|
|
1057
|
-
});
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
} }),
|
|
1061
|
-
events: {
|
|
1062
|
-
'pepsico_material_approval.mentioned': function (ctx) {
|
|
1063
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1064
|
-
var _a, recordId, userId;
|
|
1065
|
-
return tslib_1.__generator(this, function (_b) {
|
|
1066
|
-
switch (_b.label) {
|
|
1067
|
-
case 0:
|
|
1068
|
-
_a = ctx.params, recordId = _a.recordId, userId = _a.userId;
|
|
1069
|
-
console.log('EVENT[pepsico_material_approval.mentioned]', recordId, userId);
|
|
1070
|
-
if (!(recordId && userId)) return [3, 2];
|
|
1071
|
-
return [4, this.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1072
|
-
$addToSet: {
|
|
1073
|
-
person_view: userId
|
|
1074
|
-
}
|
|
1075
|
-
})];
|
|
1076
|
-
case 1:
|
|
1077
|
-
_b.sent();
|
|
1078
|
-
_b.label = 2;
|
|
1079
|
-
case 2: return [2];
|
|
1080
|
-
}
|
|
1081
|
-
});
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
},
|
|
1085
|
-
methods: tslib_1.__assign(tslib_1.__assign({}, methods), { permanentlyDeleteApprovalAllMaterialFromSharePoint: function (ctx, approval) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1086
|
-
var materialRecords, allSuccessful, materialRecords_1, materialRecords_1_1, material, downloaded, maxRetries, attempt, success, error_5, e_18_1, error_6;
|
|
1087
|
-
var e_18, _a;
|
|
1088
|
-
return tslib_1.__generator(this, function (_b) {
|
|
1089
|
-
switch (_b.label) {
|
|
1090
|
-
case 0:
|
|
1091
|
-
_b.trys.push([0, 24, , 26]);
|
|
1092
|
-
return [4, ctx.getObject('pepsico_material').find({
|
|
1093
|
-
filters: [['pepsico_material_approval', '=', approval._id], ['permanent_deleted', '!=', true], ['extension_type', 'in', ['doc', 'docx', 'ppt', 'pptx']]]
|
|
1094
|
-
})];
|
|
1095
|
-
case 1:
|
|
1096
|
-
materialRecords = _b.sent();
|
|
1097
|
-
allSuccessful = true;
|
|
1098
|
-
_b.label = 2;
|
|
1099
|
-
case 2:
|
|
1100
|
-
_b.trys.push([2, 18, 19, 20]);
|
|
1101
|
-
materialRecords_1 = tslib_1.__values(materialRecords), materialRecords_1_1 = materialRecords_1.next();
|
|
1102
|
-
_b.label = 3;
|
|
1103
|
-
case 3:
|
|
1104
|
-
if (!!materialRecords_1_1.done) return [3, 17];
|
|
1105
|
-
material = materialRecords_1_1.value;
|
|
1106
|
-
if (!(material.download_from_onedrive !== true)) return [3, 10];
|
|
1107
|
-
downloaded = false;
|
|
1108
|
-
maxRetries = 5;
|
|
1109
|
-
attempt = 1;
|
|
1110
|
-
_b.label = 4;
|
|
1111
|
-
case 4:
|
|
1112
|
-
if (!(attempt <= maxRetries)) return [3, 8];
|
|
1113
|
-
return [4, ctx.logger.info("[\u6C38\u4E45\u5220\u9664sharepoint\u7D20\u6750]-".concat(approval._id, "-").concat(material._id, "-\u5C1D\u8BD5\u4E0B\u8F7D\u7D20\u6750(\u7B2C").concat(attempt, "\u6B21)"), {
|
|
1114
|
-
pepsico_material_approval: approval._id,
|
|
1115
|
-
material: material._id,
|
|
1116
|
-
attempt: attempt
|
|
1117
|
-
})];
|
|
1118
|
-
case 5:
|
|
1119
|
-
_b.sent();
|
|
1120
|
-
return [4, methods.downloadDocFromOneDriveDoc(ctx, material)];
|
|
1121
|
-
case 6:
|
|
1122
|
-
success = _b.sent();
|
|
1123
|
-
if (success === true) {
|
|
1124
|
-
downloaded = true;
|
|
1125
|
-
return [3, 8];
|
|
1126
|
-
}
|
|
1127
|
-
_b.label = 7;
|
|
1128
|
-
case 7:
|
|
1129
|
-
attempt++;
|
|
1130
|
-
return [3, 4];
|
|
1131
|
-
case 8:
|
|
1132
|
-
if (!!downloaded) return [3, 10];
|
|
1133
|
-
allSuccessful = false;
|
|
1134
|
-
return [4, ctx.logger.error("[\u6C38\u4E45\u5220\u9664sharepoint\u7D20\u6750]-".concat(approval._id, "-").concat(material._id), {
|
|
1135
|
-
pepsico_material_approval: approval._id,
|
|
1136
|
-
material: material._id,
|
|
1137
|
-
error: "\u5C1D\u8BD5\u4E0B\u8F7D\u7D20\u6750".concat(maxRetries, "\u6B21\u540E\u4ECD\u7136\u5931\u8D25, \u8DF3\u8FC7\u5220\u9664.")
|
|
1138
|
-
})];
|
|
1139
|
-
case 9:
|
|
1140
|
-
_b.sent();
|
|
1141
|
-
return [3, 16];
|
|
1142
|
-
case 10:
|
|
1143
|
-
_b.trys.push([10, 14, , 16]);
|
|
1144
|
-
return [4, ctx.broker.call('content-version-bridge.material_permanentDeleteFromOneDrive', {
|
|
1145
|
-
material: material
|
|
1146
|
-
})];
|
|
1147
|
-
case 11:
|
|
1148
|
-
_b.sent();
|
|
1149
|
-
return [4, ctx.getObject('pepsico_material').directUpdate(material._id, {
|
|
1150
|
-
permanent_deleted: true,
|
|
1151
|
-
permanent_deleted_date: new Date()
|
|
1152
|
-
})];
|
|
1153
|
-
case 12:
|
|
1154
|
-
_b.sent();
|
|
1155
|
-
return [4, ctx.logger.info("[\u6C38\u4E45\u5220\u9664sharepoint\u7D20\u6750]-".concat(approval._id, "-").concat(material._id), {
|
|
1156
|
-
pepsico_material_approval: approval._id,
|
|
1157
|
-
material: material._id
|
|
1158
|
-
})];
|
|
1159
|
-
case 13:
|
|
1160
|
-
_b.sent();
|
|
1161
|
-
return [3, 16];
|
|
1162
|
-
case 14:
|
|
1163
|
-
error_5 = _b.sent();
|
|
1164
|
-
allSuccessful = false;
|
|
1165
|
-
console.log("error", error_5);
|
|
1166
|
-
return [4, ctx.logger.error("[\u6C38\u4E45\u5220\u9664sharepoint\u7D20\u6750]-".concat(approval._id, "-").concat(material._id), {
|
|
1167
|
-
pepsico_material_approval: approval._id,
|
|
1168
|
-
material: material._id,
|
|
1169
|
-
error: error_5.message
|
|
1170
|
-
})];
|
|
1171
|
-
case 15:
|
|
1172
|
-
_b.sent();
|
|
1173
|
-
return [3, 16];
|
|
1174
|
-
case 16:
|
|
1175
|
-
materialRecords_1_1 = materialRecords_1.next();
|
|
1176
|
-
return [3, 3];
|
|
1177
|
-
case 17: return [3, 20];
|
|
1178
|
-
case 18:
|
|
1179
|
-
e_18_1 = _b.sent();
|
|
1180
|
-
e_18 = { error: e_18_1 };
|
|
1181
|
-
return [3, 20];
|
|
1182
|
-
case 19:
|
|
1183
|
-
try {
|
|
1184
|
-
if (materialRecords_1_1 && !materialRecords_1_1.done && (_a = materialRecords_1.return)) _a.call(materialRecords_1);
|
|
1185
|
-
}
|
|
1186
|
-
finally { if (e_18) throw e_18.error; }
|
|
1187
|
-
return [7];
|
|
1188
|
-
case 20:
|
|
1189
|
-
if (!allSuccessful) return [3, 23];
|
|
1190
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(approval._id, {
|
|
1191
|
-
permanent_deleted: true,
|
|
1192
|
-
permanent_deleted_date: new Date()
|
|
1193
|
-
})];
|
|
1194
|
-
case 21:
|
|
1195
|
-
_b.sent();
|
|
1196
|
-
return [4, ctx.logger.info("[\u6C38\u4E45\u5220\u9664sharepoint\u7D20\u6750]-".concat(approval._id), {
|
|
1197
|
-
pepsico_material_approval: approval._id
|
|
1198
|
-
})];
|
|
1199
|
-
case 22:
|
|
1200
|
-
_b.sent();
|
|
1201
|
-
_b.label = 23;
|
|
1202
|
-
case 23: return [3, 26];
|
|
1203
|
-
case 24:
|
|
1204
|
-
error_6 = _b.sent();
|
|
1205
|
-
return [4, ctx.logger.info("[\u6C38\u4E45\u5220\u9664sharepoint\u7D20\u6750]-".concat(approval._id), {
|
|
1206
|
-
pepsico_material_approval: approval._id,
|
|
1207
|
-
error: error_6.message
|
|
1208
|
-
})];
|
|
1209
|
-
case 25:
|
|
1210
|
-
_b.sent();
|
|
1211
|
-
return [3, 26];
|
|
1212
|
-
case 26: return [2];
|
|
1213
|
-
}
|
|
1214
|
-
});
|
|
1215
|
-
}); } }),
|
|
1216
|
-
created: function () {
|
|
1217
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1218
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1219
|
-
return [2];
|
|
1220
|
-
});
|
|
1221
|
-
});
|
|
1222
|
-
},
|
|
1223
|
-
started: function () {
|
|
1224
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1225
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1226
|
-
return [2];
|
|
1227
|
-
});
|
|
1228
|
-
});
|
|
1229
|
-
},
|
|
1230
|
-
stopped: function () {
|
|
1231
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1232
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1233
|
-
return [2];
|
|
1234
|
-
});
|
|
1235
|
-
});
|
|
1236
|
-
}
|
|
1237
|
-
};
|
|
1238
|
-
//# sourceMappingURL=index.js.map
|