@resolveio/server-lib 9.2.19 → 9.2.21
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/client-server-app.js +55 -1
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +40 -1
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +40 -1
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +43 -1
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +71 -1
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +74 -1
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +55 -1
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +50 -1
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +62 -1
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +44 -1
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +53 -1
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +57 -1
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +72 -1
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +58 -1
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.js +51 -1
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.js +55 -1
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +57 -1
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.js +66 -1
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.js +74 -1
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +68 -1
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +62 -1
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +40 -1
- package/collections/notification.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +93 -1
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +76 -1
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +138 -1
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +79 -1
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +46 -1
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +248 -1
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +161 -1
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +72 -1
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +62 -1
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +697 -1
- package/http/auth.js.map +1 -1
- package/http/health.js +10 -1
- package/http/health.js.map +1 -1
- package/http/home.js +64 -1
- package/http/home.js.map +1 -1
- package/index.js +123 -1
- package/index.js.map +1 -1
- package/managers/cron.manager.js +205 -1
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +599 -1
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +1777 -1
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +334 -1
- package/managers/monitor.manager.js.map +1 -1
- package/managers/subscription.manager.js +867 -1
- package/managers/subscription.manager.js.map +1 -1
- package/managers/subscription.performance.js +100 -1
- package/managers/subscription.performance.js.map +1 -1
- package/methods/accounts.js +224 -1
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +449 -1
- package/methods/aws.js.map +1 -1
- package/methods/cloudconvert.js +214 -1
- package/methods/cloudconvert.js.map +1 -1
- package/methods/collections.js +526 -1
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +121 -1
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +1284 -1
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +8 -1
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +370 -1
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +384 -1
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +685 -1
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +826 -1
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +263 -1
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +3 -1
- package/models/app-status.model.js.map +1 -1
- package/models/app-version.model.js +3 -1
- package/models/app-version.model.js.map +1 -1
- package/models/billing-logged-in-users.model.js +3 -1
- package/models/billing-logged-in-users.model.js.map +1 -1
- package/models/collection-document.model.js +3 -1
- package/models/collection-document.model.js.map +1 -1
- package/models/counter.model.js +3 -1
- package/models/counter.model.js.map +1 -1
- package/models/cron-job-history.model.js +3 -1
- package/models/cron-job-history.model.js.map +1 -1
- package/models/cron-job.model.js +3 -1
- package/models/cron-job.model.js.map +1 -1
- package/models/dialog.model.js +3 -1
- package/models/dialog.model.js.map +1 -1
- package/models/email-history.model.js +3 -1
- package/models/email-history.model.js.map +1 -1
- package/models/email-verified.model.js +3 -1
- package/models/email-verified.model.js.map +1 -1
- package/models/file.model.js +3 -1
- package/models/file.model.js.map +1 -1
- package/models/flag.model.js +3 -1
- package/models/flag.model.js.map +1 -1
- package/models/log-method-latency.model.js +3 -1
- package/models/log-method-latency.model.js.map +1 -1
- package/models/log-subscription.model.js +3 -1
- package/models/log-subscription.model.js.map +1 -1
- package/models/log.model.js +3 -1
- package/models/log.model.js.map +1 -1
- package/models/logged-in-users.model.js +3 -1
- package/models/logged-in-users.model.js.map +1 -1
- package/models/method-call.model.js +3 -1
- package/models/method-call.model.js.map +1 -1
- package/models/method-response.model.js +3 -1
- package/models/method-response.model.js.map +1 -1
- package/models/method.model.js +3 -1
- package/models/method.model.js.map +1 -1
- package/models/monitor-cpu.model.js +3 -1
- package/models/monitor-cpu.model.js.map +1 -1
- package/models/monitor-https-inbound.model.js +3 -1
- package/models/monitor-https-inbound.model.js.map +1 -1
- package/models/monitor-https-outbound.model.js +3 -1
- package/models/monitor-https-outbound.model.js.map +1 -1
- package/models/monitor-memory.model.js +3 -1
- package/models/monitor-memory.model.js.map +1 -1
- package/models/monitor-mongo.model.js +3 -1
- package/models/monitor-mongo.model.js.map +1 -1
- package/models/notification.model.js +3 -1
- package/models/notification.model.js.map +1 -1
- package/models/pagination.model.js +23 -1
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +3 -1
- package/models/permission.model.js.map +1 -1
- package/models/report-builder-dashboard-builder.model.js +3 -1
- package/models/report-builder-dashboard-builder.model.js.map +1 -1
- package/models/report-builder-library.model.js +3 -1
- package/models/report-builder-library.model.js.map +1 -1
- package/models/report-builder-report.model.js +3 -1
- package/models/report-builder-report.model.js.map +1 -1
- package/models/report-builder.model.js +3 -1
- package/models/report-builder.model.js.map +1 -1
- package/models/select-data-label.model.js +3 -1
- package/models/select-data-label.model.js.map +1 -1
- package/models/server-response.model.js +3 -1
- package/models/server-response.model.js.map +1 -1
- package/models/subscription.model.js +3 -1
- package/models/subscription.model.js.map +1 -1
- package/models/support-ticket.model.js +3 -1
- package/models/support-ticket.model.js.map +1 -1
- package/models/user-group.model.js +3 -1
- package/models/user-group.model.js.map +1 -1
- package/models/user-guide.model.js +3 -1
- package/models/user-guide.model.js.map +1 -1
- package/models/user.model.js +3 -1
- package/models/user.model.js.map +1 -1
- package/package.json +1 -2
- package/public_api.js +78 -1
- package/public_api.js.map +1 -1
- package/publications/app-status.js +16 -1
- package/publications/app-status.js.map +1 -1
- package/publications/app-version.js +16 -1
- package/publications/app-version.js.map +1 -1
- package/publications/cron-jobs.js +32 -1
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +36 -1
- package/publications/files.js.map +1 -1
- package/publications/flags.js +22 -1
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +90 -1
- package/publications/logs.js.map +1 -1
- package/publications/method-calls.js +16 -1
- package/publications/method-calls.js.map +1 -1
- package/publications/method-responses.js +16 -1
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +16 -1
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +42 -1
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +89 -1
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +50 -1
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +16 -1
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +16 -1
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +16 -1
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +682 -1
- package/server-app.js.map +1 -1
- package/util/common.js +498 -1
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +452 -1
- package/util/schema-report-builder.js.map +1 -1
|
@@ -1,2 +1,249 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserVersions = exports.Users = void 0;
|
|
4
|
+
var index_1 = require("../index");
|
|
5
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
6
|
+
var schema = {
|
|
7
|
+
_id: {
|
|
8
|
+
type: String,
|
|
9
|
+
optional: true
|
|
10
|
+
},
|
|
11
|
+
__v: {
|
|
12
|
+
type: Number,
|
|
13
|
+
optional: true
|
|
14
|
+
},
|
|
15
|
+
updatedAt: {
|
|
16
|
+
type: Date,
|
|
17
|
+
optional: true
|
|
18
|
+
},
|
|
19
|
+
createdAt: {
|
|
20
|
+
type: Date,
|
|
21
|
+
optional: true
|
|
22
|
+
},
|
|
23
|
+
roles: {
|
|
24
|
+
type: Object
|
|
25
|
+
},
|
|
26
|
+
'roles.super_admin': {
|
|
27
|
+
type: Boolean
|
|
28
|
+
},
|
|
29
|
+
'roles.approvals': {
|
|
30
|
+
type: Array
|
|
31
|
+
},
|
|
32
|
+
'roles.approvals.$': {
|
|
33
|
+
type: Object
|
|
34
|
+
},
|
|
35
|
+
'roles.approvals.$.type': {
|
|
36
|
+
type: String
|
|
37
|
+
},
|
|
38
|
+
'roles.approvals.$.key_1': {
|
|
39
|
+
type: String,
|
|
40
|
+
optional: true
|
|
41
|
+
},
|
|
42
|
+
'roles.approvals.$.key_2': {
|
|
43
|
+
type: String,
|
|
44
|
+
optional: true
|
|
45
|
+
},
|
|
46
|
+
'roles.approvals.$.key_3': {
|
|
47
|
+
type: String,
|
|
48
|
+
optional: true
|
|
49
|
+
},
|
|
50
|
+
'roles.approvals.$.name': {
|
|
51
|
+
type: String
|
|
52
|
+
},
|
|
53
|
+
'roles.groups': {
|
|
54
|
+
type: Array
|
|
55
|
+
},
|
|
56
|
+
'roles.groups.$': {
|
|
57
|
+
type: Object
|
|
58
|
+
},
|
|
59
|
+
'roles.groups.$.name': {
|
|
60
|
+
type: String
|
|
61
|
+
},
|
|
62
|
+
'roles.groups.$.views': {
|
|
63
|
+
type: Array
|
|
64
|
+
},
|
|
65
|
+
'roles.groups.$.views.$': {
|
|
66
|
+
type: String
|
|
67
|
+
},
|
|
68
|
+
'roles.groups.$.yard': {
|
|
69
|
+
type: String,
|
|
70
|
+
optional: true
|
|
71
|
+
},
|
|
72
|
+
'roles.notifications': {
|
|
73
|
+
type: Array
|
|
74
|
+
},
|
|
75
|
+
'roles.notifications.$': {
|
|
76
|
+
type: String
|
|
77
|
+
},
|
|
78
|
+
'roles.miscs': {
|
|
79
|
+
type: Array
|
|
80
|
+
},
|
|
81
|
+
'roles.miscs.$': {
|
|
82
|
+
type: String
|
|
83
|
+
},
|
|
84
|
+
username: {
|
|
85
|
+
type: String,
|
|
86
|
+
optional: true
|
|
87
|
+
},
|
|
88
|
+
email: {
|
|
89
|
+
type: String,
|
|
90
|
+
optional: true
|
|
91
|
+
},
|
|
92
|
+
fullname: {
|
|
93
|
+
type: String
|
|
94
|
+
},
|
|
95
|
+
active: {
|
|
96
|
+
type: Boolean
|
|
97
|
+
},
|
|
98
|
+
phonenumber: {
|
|
99
|
+
type: String,
|
|
100
|
+
optional: true
|
|
101
|
+
},
|
|
102
|
+
readonly: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
optional: true
|
|
105
|
+
},
|
|
106
|
+
other: {
|
|
107
|
+
type: Object,
|
|
108
|
+
blackbox: true
|
|
109
|
+
},
|
|
110
|
+
settings: {
|
|
111
|
+
type: Object,
|
|
112
|
+
optional: true
|
|
113
|
+
},
|
|
114
|
+
'settings.table_color': {
|
|
115
|
+
type: String
|
|
116
|
+
},
|
|
117
|
+
'settings.table_font_color': {
|
|
118
|
+
type: String
|
|
119
|
+
},
|
|
120
|
+
'settings.secondary_table_color': {
|
|
121
|
+
type: String
|
|
122
|
+
},
|
|
123
|
+
'settings.secondary_table_font_color': {
|
|
124
|
+
type: String
|
|
125
|
+
},
|
|
126
|
+
'settings.tertiary_table_color': {
|
|
127
|
+
type: String
|
|
128
|
+
},
|
|
129
|
+
'settings.tertiary_table_font_color': {
|
|
130
|
+
type: String
|
|
131
|
+
},
|
|
132
|
+
'settings.font_size': {
|
|
133
|
+
type: Number
|
|
134
|
+
},
|
|
135
|
+
'settings.collapsable_menu': {
|
|
136
|
+
type: Boolean
|
|
137
|
+
},
|
|
138
|
+
'settings.entries_per_page': {
|
|
139
|
+
type: String
|
|
140
|
+
},
|
|
141
|
+
'settings.warning_color': {
|
|
142
|
+
type: String
|
|
143
|
+
},
|
|
144
|
+
'settings.warning_font_color': {
|
|
145
|
+
type: String
|
|
146
|
+
},
|
|
147
|
+
'settings.warning_hover_color': {
|
|
148
|
+
type: String
|
|
149
|
+
},
|
|
150
|
+
'settings.success_color': {
|
|
151
|
+
type: String
|
|
152
|
+
},
|
|
153
|
+
'settings.success_font_color': {
|
|
154
|
+
type: String
|
|
155
|
+
},
|
|
156
|
+
'settings.success_hover_color': {
|
|
157
|
+
type: String
|
|
158
|
+
},
|
|
159
|
+
'settings.danger_color': {
|
|
160
|
+
type: String
|
|
161
|
+
},
|
|
162
|
+
'settings.danger_font_color': {
|
|
163
|
+
type: String
|
|
164
|
+
},
|
|
165
|
+
'settings.danger_hover_color': {
|
|
166
|
+
type: String
|
|
167
|
+
},
|
|
168
|
+
'settings.info_color': {
|
|
169
|
+
type: String
|
|
170
|
+
},
|
|
171
|
+
'settings.info_font_color': {
|
|
172
|
+
type: String
|
|
173
|
+
},
|
|
174
|
+
'settings.info_hover_color': {
|
|
175
|
+
type: String
|
|
176
|
+
},
|
|
177
|
+
'settings.primary_color': {
|
|
178
|
+
type: String
|
|
179
|
+
},
|
|
180
|
+
'settings.primary_font_color': {
|
|
181
|
+
type: String
|
|
182
|
+
},
|
|
183
|
+
'settings.primary_hover_color': {
|
|
184
|
+
type: String
|
|
185
|
+
},
|
|
186
|
+
'settings.secondary_color': {
|
|
187
|
+
type: String
|
|
188
|
+
},
|
|
189
|
+
'settings.secondary_font_color': {
|
|
190
|
+
type: String
|
|
191
|
+
},
|
|
192
|
+
'settings.secondary_hover_color': {
|
|
193
|
+
type: String
|
|
194
|
+
},
|
|
195
|
+
'settings.routing_preference': {
|
|
196
|
+
type: String
|
|
197
|
+
},
|
|
198
|
+
'settings.opening_route': {
|
|
199
|
+
type: String
|
|
200
|
+
},
|
|
201
|
+
salt: {
|
|
202
|
+
type: String
|
|
203
|
+
},
|
|
204
|
+
hash: {
|
|
205
|
+
type: String
|
|
206
|
+
},
|
|
207
|
+
attempts: {
|
|
208
|
+
type: Number
|
|
209
|
+
},
|
|
210
|
+
last: {
|
|
211
|
+
type: Date,
|
|
212
|
+
optional: true
|
|
213
|
+
},
|
|
214
|
+
services: {
|
|
215
|
+
type: Object,
|
|
216
|
+
optional: true
|
|
217
|
+
},
|
|
218
|
+
'services.enrollment': {
|
|
219
|
+
type: String,
|
|
220
|
+
optional: true
|
|
221
|
+
},
|
|
222
|
+
'services.forgot_password': {
|
|
223
|
+
type: String,
|
|
224
|
+
optional: true
|
|
225
|
+
},
|
|
226
|
+
'services.reset_password': {
|
|
227
|
+
type: String,
|
|
228
|
+
optional: true
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
exports.Users = null;
|
|
232
|
+
exports.UserVersions = null;
|
|
233
|
+
initializeCollection();
|
|
234
|
+
function initializeCollection() {
|
|
235
|
+
if (index_1.ResolveIOServer && index_1.ResolveIOServer.getMainDB()) {
|
|
236
|
+
var model = new mongo_manager_1.Model('users', schema, true, true);
|
|
237
|
+
exports.Users = model.collection_main;
|
|
238
|
+
exports.Users.createIndex({ fullname: 1 });
|
|
239
|
+
exports.Users.createIndex({ active: 1 });
|
|
240
|
+
exports.UserVersions = model.collection_version;
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
setTimeout(function () {
|
|
244
|
+
initializeCollection();
|
|
245
|
+
}, 1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
2
249
|
//# sourceMappingURL=user.collection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/user.collection.ts"],"names":[
|
|
1
|
+
{"version":3,"sources":["../../src/collections/user.collection.ts"],"names":[],"mappings":";;;AAAA,kCAA2C;AAC3C,2DAAkE;AAGlE,IAAI,MAAM,GAAQ;IACjB,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,KAAK,EAAE;QACN,IAAI,EAAE,MAAM;KACZ;IACD,mBAAmB,EAAE;QACpB,IAAI,EAAE,OAAO;KACb;IACD,iBAAiB,EAAE;QAClB,IAAI,EAAE,KAAK;KACX;IACD,mBAAmB,EAAE;QACpB,IAAI,EAAE,MAAM;KACZ;IACD,wB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,CAAC,WAAW,CAAC,EAAC,MAAM,EAAE,CAAC,EAAC,CAAC,CAAC;QAC/B,oBAAY,GAA8B,KAAK,CAAC,kBAAkB,CAAC;KACnE;SACI;QACJ,UAAU,CAAC;YACV,oBAAoB,EAAE,CAAC;QACxB,CAAC,EAAE,CAAC,CAAC,CAAC;KACN;AACF,CAAC","file":"user.collection.js","sourcesContent":["import { ResolveIOServer } from '../index';\nimport { Model, UserCollection } from '../managers/mongo.manager';\nimport { UserModel } from '../models/user.model';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\troles: {\n\t\ttype: Object\n\t},\n\t'roles.super_admin': {\n\t\ttype: Boolean\n\t},\n\t'roles.approvals': {\n\t\ttype: Array\n\t},\n\t'roles.approvals.$': {\n\t\ttype: Object\n\t},\n\t'roles.approvals.$.type': {\n\t\ttype: String\n\t},\n\t'roles.approvals.$.key_1': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'roles.approvals.$.key_2': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'roles.approvals.$.key_3': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'roles.approvals.$.name': {\n\t\ttype: String\n\t},\n\t'roles.groups': {\n\t\ttype: Array\n\t},\n\t'roles.groups.$': {\n\t\ttype: Object\n\t},\n\t'roles.groups.$.name': {\n\t\ttype: String\n\t},\n\t'roles.groups.$.views': {\n\t\ttype: Array\n\t},\n\t'roles.groups.$.views.$': {\n\t\ttype: String\n\t},\n\t'roles.groups.$.yard': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'roles.notifications': {\n\t\ttype: Array\n\t},\n\t'roles.notifications.$': {\n\t\ttype: String\n\t},\n\t'roles.miscs': {\n\t\ttype: Array\n\t},\n\t'roles.miscs.$': {\n\t\ttype: String\n\t},\n\tusername: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\temail: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tfullname: {\n\t\ttype: String\n\t},\n\tactive: {\n\t\ttype: Boolean\n\t},\n\tphonenumber: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\treadonly: {\n\t\ttype: Boolean,\n\t\toptional: true\n\t},\n\tother: {\n\t\ttype: Object,\n\t\tblackbox: true\n\t},\n\tsettings: {\n\t\ttype: Object,\n\t\toptional: true\n\t},\n\t'settings.table_color': {\n\t\ttype: String\n\t},\n\t'settings.table_font_color': {\n\t\ttype: String\n\t},\n\t'settings.secondary_table_color': {\n\t\ttype: String\n\t},\n\t'settings.secondary_table_font_color': {\n\t\ttype: String\n\t},\n\t'settings.tertiary_table_color': {\n\t\ttype: String\n\t},\n\t'settings.tertiary_table_font_color': {\n\t\ttype: String\n\t},\n\t'settings.font_size': {\n\t\ttype: Number\n\t},\n\t'settings.collapsable_menu': {\n\t\ttype: Boolean\n\t},\n\t'settings.entries_per_page': {\n\t\ttype: String\n\t},\n\t'settings.warning_color': {\n\t\ttype: String\n\t},\n\t'settings.warning_font_color': {\n\t\ttype: String\n\t},\n\t'settings.warning_hover_color': {\n\t\ttype: String\n\t},\n\t'settings.success_color': {\n\t\ttype: String\n\t},\n\t'settings.success_font_color': {\n\t\ttype: String\n\t},\n\t'settings.success_hover_color': {\n\t\ttype: String\n\t},\n\t'settings.danger_color': {\n\t\ttype: String\n\t},\n\t'settings.danger_font_color': {\n\t\ttype: String\n\t},\n\t'settings.danger_hover_color': {\n\t\ttype: String\n\t},\n\t'settings.info_color': {\n\t\ttype: String\n\t},\n\t'settings.info_font_color': {\n\t\ttype: String\n\t},\n\t'settings.info_hover_color': {\n\t\ttype: String\n\t},\n\t'settings.primary_color': {\n\t\ttype: String\n\t},\n\t'settings.primary_font_color': {\n\t\ttype: String\n\t},\n\t'settings.primary_hover_color': {\n\t\ttype: String\n\t},\n\t'settings.secondary_color': {\n\t\ttype: String\n\t},\n\t'settings.secondary_font_color': {\n\t\ttype: String\n\t},\n\t'settings.secondary_hover_color': {\n\t\ttype: String\n\t},\n\t'settings.routing_preference': {\n\t\ttype: String\n\t},\n\t'settings.opening_route': {\n\t\ttype: String\n\t},\n\tsalt: {\n\t\ttype: String\n\t},\n\thash: {\n\t\ttype: String\n\t},\n\tattempts: {\n\t\ttype: Number\n\t},\n\tlast: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tservices: {\n\t\ttype: Object,\n\t\toptional: true\n\t},\n\t'services.enrollment': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.forgot_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.reset_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n};\n\nexport let Users: UserCollection<UserModel> = null;\nexport let UserVersions: UserCollection<UserModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB()) {\n\t\tconst model = new Model<UserModel>('users', schema, true, true);\n\t\tUsers = <UserCollection<UserModel>>model.collection_main;\n\t\tUsers.createIndex({fullname: 1});\n\t\tUsers.createIndex({active: 1});\n\t\tUserVersions = <UserCollection<UserModel>>model.collection_version;\n\t}\n\telse {\n\t\tsetTimeout(() => {\n\t\t\tinitializeCollection();\n\t\t}, 1);\n\t}\n}"]}
|
package/cron/cron.js
CHANGED
|
@@ -1,2 +1,162 @@
|
|
|
1
|
-
var CronJobPackage
|
|
1
|
+
var CronJobPackage = require('cron').CronJob;
|
|
2
|
+
function CrontabManager(key, tab, task, options) {
|
|
3
|
+
this.jobs = {};
|
|
4
|
+
if (key && tab && task) {
|
|
5
|
+
this.add(key, tab, task, options);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
CrontabManager.prototype.getJob = function (key) {
|
|
9
|
+
return this.jobs[key];
|
|
10
|
+
};
|
|
11
|
+
CrontabManager.prototype.getJobs = function () {
|
|
12
|
+
return Object.keys(this.jobs);
|
|
13
|
+
};
|
|
14
|
+
CrontabManager.prototype.add = function (key, tab, task, options) {
|
|
15
|
+
if ((typeof tab === 'string' || tab instanceof Date) && typeof key === 'string' && task instanceof Function) {
|
|
16
|
+
options = combineOptions(tab, task, options);
|
|
17
|
+
try {
|
|
18
|
+
if (this.jobs[key]) {
|
|
19
|
+
this.deleteJob(key);
|
|
20
|
+
console.warn(key + " already existed and was deleted from the manager...");
|
|
21
|
+
}
|
|
22
|
+
this.jobs[key] = new CronJobPackage(options);
|
|
23
|
+
}
|
|
24
|
+
catch (fooBaredByUser) {
|
|
25
|
+
console.error("crontab: " + tab + " possibly not valid, job " + key + " not started..." + fooBaredByUser.message);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.warn("couldn't add: " + key + " improper arguments");
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
CrontabManager.prototype.update = function () {
|
|
33
|
+
if (arguments.length === 2) {
|
|
34
|
+
if (typeof arguments[1] === 'string' || arguments[1] instanceof Date) {
|
|
35
|
+
updateTab.call(this, arguments[0], arguments[1]);
|
|
36
|
+
}
|
|
37
|
+
else if (arguments[1] instanceof Function) {
|
|
38
|
+
updateTask.call(this, arguments[0], arguments[1]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else if (arguments.length === 3) {
|
|
42
|
+
updateTab.call(this, arguments[0], arguments[1]);
|
|
43
|
+
updateTask.call(this, arguments[0], arguments[2]);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
console.error("incorrect number of arguents passed to update.. won't update.. " + arguments[0]);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
CrontabManager.prototype.deleteJob = function (key) {
|
|
50
|
+
try {
|
|
51
|
+
this.jobs[key].stop();
|
|
52
|
+
delete this.jobs[key];
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
console.error("error in trying to stop job: " + key + ": " + err);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
CrontabManager.prototype.start = function (key) {
|
|
59
|
+
try {
|
|
60
|
+
if (this.jobs[key].running) {
|
|
61
|
+
console.warn(key + " job already running");
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.jobs[key].start();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
console.error("couldn't start job: " + key + ": " + err);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
CrontabManager.prototype.stop = function (key) {
|
|
72
|
+
try {
|
|
73
|
+
if (!this.jobs[key].running) {
|
|
74
|
+
console.warn(key + " job already stopped");
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.jobs[key].stop();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
console.error("couldn't stop job: " + key + ": " + err);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
CrontabManager.prototype.stopAll = function () {
|
|
85
|
+
// tslint:disable-next-line:forin
|
|
86
|
+
for (var jobKey in this.jobs) {
|
|
87
|
+
try {
|
|
88
|
+
this.jobs[jobKey].stop();
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
CrontabManager.prototype.toString = function () {
|
|
95
|
+
var manString = '{\n';
|
|
96
|
+
// tslint:disable-next-line:forin
|
|
97
|
+
for (var jobKey in this.jobs) {
|
|
98
|
+
manString += "'" + jobKey + "': " + this.jobs[jobKey].cronTime.source + ": " + this.jobs[jobKey]._callbacks[0] + ": " + (this.jobs[jobKey].running ? 'Running' : 'Stopped');
|
|
99
|
+
}
|
|
100
|
+
manString += '\n}';
|
|
101
|
+
return manString;
|
|
102
|
+
};
|
|
103
|
+
CrontabManager.prototype.listCrons = function () {
|
|
104
|
+
var manString = '{\n';
|
|
105
|
+
// tslint:disable-next-line:forin
|
|
106
|
+
for (var jobKey in this.jobs) {
|
|
107
|
+
manString += "'" + jobKey + "': " + this.jobs[jobKey].cronTime.source + " status: " + (this.jobs[jobKey].running ? 'Running' : 'Stopped') + " \n";
|
|
108
|
+
}
|
|
109
|
+
manString += '\n}';
|
|
110
|
+
return manString;
|
|
111
|
+
};
|
|
112
|
+
CrontabManager.prototype.exists = function (tabKey) {
|
|
113
|
+
if (this.jobs[tabKey]) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
};
|
|
118
|
+
function combineOptions(tab, task, options) {
|
|
119
|
+
var newOpts = {};
|
|
120
|
+
newOpts['cronTime'] = tab;
|
|
121
|
+
newOpts['onTick'] = task;
|
|
122
|
+
if (options instanceof Object) {
|
|
123
|
+
// might overwrite... please be careful.
|
|
124
|
+
// tslint:disable-next-line:forin
|
|
125
|
+
for (var optionKey in options) {
|
|
126
|
+
newOpts[optionKey] = options[optionKey];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return newOpts;
|
|
130
|
+
}
|
|
131
|
+
function updateTab(key, cronstring) {
|
|
132
|
+
try {
|
|
133
|
+
var running = this.jobs[key].running;
|
|
134
|
+
this.jobs[key].stop();
|
|
135
|
+
if (typeof cronstring === 'string' || cronstring instanceof Date) {
|
|
136
|
+
this.jobs[key] = new CronJobPackage(cronstring, this.jobs[key]._callbacks[0], this.jobs[key].onComplete, running, this.jobs[key].zone);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
throw new Error("The cron definition passed was not a string or a Date object! " + key + " was stopped and not updated");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (tabErr) {
|
|
143
|
+
console.error("error updating tab: " + key + " - " + tabErr.message);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function updateTask(key, task) {
|
|
147
|
+
try {
|
|
148
|
+
var running = this.jobs[key].running;
|
|
149
|
+
this.jobs[key].stop();
|
|
150
|
+
if (!(task instanceof Function)) {
|
|
151
|
+
console.error("can't update with something that is not a function: " + typeof (task));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.jobs[key] = new CronJobPackage(this.jobs[key].cronTime.source, task, this.jobs[key].onComplete, running, this.jobs[key].zone);
|
|
155
|
+
}
|
|
156
|
+
catch (tabErr) {
|
|
157
|
+
console.error("error updating task: " + key + " - " + tabErr.message);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
module.exports = CrontabManager;
|
|
161
|
+
|
|
2
162
|
//# sourceMappingURL=cron.js.map
|
package/cron/cron.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cron/cron.ts"],"names":["CronJobPackage","require","CronJob","CrontabManager","key","tab","task","options","this","jobs","add","combineOptions","newOpts","Object","optionKey","updateTab","cronstring","running","stop","Date","Error","_callbacks","onComplete","zone","tabErr","console","error","message","updateTask","Function","cronTime","source","prototype","getJob","getJobs","keys","deleteJob","warn","fooBaredByUser","update","arguments","length","call","err","start","stopAll","jobKey","toString","manString","listCrons","exists","tabKey","module","exports"],"mappings":"AAAA,IAAIA,eAAiBC,QAAQ,QAAQC,QAErC,SAASC,eAAeC,EAAKC,EAAKC,EAAMC,GACvCC,KAAKC,KAAO,GACRL,GAAOC,GAAOC,GACjBE,KAAKE,IAAIN,EAAKC,EAAKC,EAAMC,GAkI3B,SAASI,eAAeN,EAAKC,EAAMC,GAClC,IAAIK,EAAU,GAId,GAHAA,EAAkB,SAAIP,EACtBO,EAAgB,OAAIN,EAEhBC,aAAmBM,OAGtB,IAAK,IAAIC,KAAaP,EACrBK,EAAQE,GAAaP,EAAQO,GAG/B,OAAOF,EAGR,SAASG,UAAUX,EAAKY,GAEvB,IACC,IAAIC,EAAUT,KAAKC,KAAKL,GAAKa,QAG7B,GAFAT,KAAKC,KAAKL,GAAKc,SAEW,iBAAfF,GAA2BA,aAAsBG,MAI3D,MAAM,IAAIC,MAAM,iEAAiEhB,EAAG,gCAHpFI,KAAKC,KAAK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B,UAAY,WACpC,IAAID,EAAY,MAEhB,IAAK,IAAIF,KAAUtC,KAAKC,KACvBuC,GAAa,IAAIF,EAAM,MAAMtC,KAAKC,KAAKqC,GAAQhB,SAASC,OAAM,aAAYvB,KAAKC,KAAKqC,GAAQ7B,QAAU,UAAY,WAAS,MAG5H,OADA+B,GAAa,OAId7C,eAAe6B,UAAUkB,OAAS,SAASC,GAC1C,QAAI3C,KAAKC,KAAK0C,IA2DfC,OAAOC,QAAUlD","file":"cron.js","sourcesContent":["let CronJobPackage = require('cron').CronJob;\n\nfunction CrontabManager(key, tab, task, options) {\n\tthis.jobs = {};\n\tif (key && tab && task) {\n\t\tthis.add(key, tab, task, options);\n\t}\n\n}\n\nCrontabManager.prototype.getJob = function(key) {\n\treturn this.jobs[key];\n};\n\nCrontabManager.prototype.getJobs = function() {\n\treturn Object.keys(this.jobs);\n};\n\nCrontabManager.prototype.add = function(key, tab, task, options) {\n\tif ((typeof tab === 'string' || tab instanceof Date) && typeof key === 'string' && task instanceof Function) {\n\t\toptions = combineOptions(tab, task, options);\n\t\ttry {\n\t\t\tif (this.jobs[key]) {\n\t\t\t\tthis.deleteJob(key);\n\t\t\t\tconsole.warn(`${key} already existed and was deleted from the manager...`);\n\t\t\t}\n\t\t\t\n\t\t\tthis.jobs[key] = new CronJobPackage(options);\n\t\t} \n\t\tcatch (fooBaredByUser) {\n\t\t\tconsole.error(`crontab: ${tab} possibly not valid, job ${key} not started...${fooBaredByUser.message}`);\n\t\t}\n\t}\n\telse {\n\t\tconsole.warn(`couldn't add: ${key} improper arguments`);\n\t}\n};\n\nCrontabManager.prototype.update = function() {\n\tif (arguments.length === 2) {\n\t\tif (typeof arguments[1] === 'string' || arguments[1] instanceof Date) {\n\t\t\tupdateTab.call(this, arguments[0], arguments[1]);\n\t\t}\n\t\telse if (arguments[1] instanceof Function) {\n\t\t\tupdateTask.call(this, arguments[0], arguments[1]);\n\t\t}\n\t} \n\telse if (arguments.length === 3) {\n\t\tupdateTab.call(this, arguments[0], arguments[1]);\n\t\tupdateTask.call(this, arguments[0], arguments[2]);\n\t}\n\telse {\n\t\tconsole.error(`incorrect number of arguents passed to update.. won't update.. ${arguments[0]}`);\n\t}\n};\n\nCrontabManager.prototype.deleteJob = function(key) {\n\ttry {\n\t\tthis.jobs[key].stop();\n\t\tdelete this.jobs[key];\n\t}\n\tcatch (err) { \n\t\tconsole.error(`error in trying to stop job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.start = function(key) {\n\ttry {\n\t\tif (this.jobs[key].running) {\n\t\t\tconsole.warn(`${key} job already running`);\n\t\t}\n\t\telse {\n\t\t\tthis.jobs[key].start();\n\t\t}\n\t}\n\tcatch (err) {\n\t\tconsole.error(`couldn't start job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.stop = function(key) {\n\ttry {\n\t\tif (! this.jobs[key].running ) {\n\t\t\tconsole.warn(`${key} job already stopped`);\n\t\t}\n\t\telse {\n\t\t\tthis.jobs[key].stop();\n\t\t}\n\t}\n\tcatch (err) {\n\t\tconsole.error(`couldn't stop job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.stopAll = function() {\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\t\ttry {\n\t\t\tthis.jobs[jobKey].stop();\n\t\t}\n\t\tcatch (err) {\n\n\t\t}\n\t}\n};\n\nCrontabManager.prototype.toString = function() {\n\tlet manString = '{\\n';\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\n\t\tmanString += `'${jobKey}': ${this.jobs[jobKey].cronTime.source}: ${this.jobs[jobKey]._callbacks[0]}: ${this.jobs[jobKey].running ? 'Running' : 'Stopped'}`;\n\t}\n\tmanString += '\\n}';\n\treturn manString;\n};\n\nCrontabManager.prototype.listCrons = function() {\n\tlet manString = '{\\n';\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\t\tmanString += `'${jobKey}': ${this.jobs[jobKey].cronTime.source} status: ${this.jobs[jobKey].running ? 'Running' : 'Stopped'} \\n`;\n\t}\n\tmanString += '\\n}';\n\treturn manString;\n};\n\nCrontabManager.prototype.exists = function(tabKey) {\n\tif (this.jobs[tabKey]) {\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\nfunction combineOptions(tab, task, options) {\n\tlet newOpts = {};\n\tnewOpts['cronTime'] = tab; \n\tnewOpts['onTick'] = task;\n\n\tif (options instanceof Object) {\n\t\t// might overwrite... please be careful.\n\t\t// tslint:disable-next-line:forin\n\t\tfor (let optionKey in options) {\n\t\t\tnewOpts[optionKey] = options[optionKey];\n\t\t}\n\t}\n\treturn newOpts;\n}\n\nfunction updateTab(key, cronstring) {\n\n\ttry {\n\t\tlet running = this.jobs[key].running;\n\t\tthis.jobs[key].stop();\n\n\t\tif (typeof cronstring === 'string' || cronstring instanceof Date) {\n\t\t\tthis.jobs[key] = new CronJobPackage(cronstring, this.jobs[key]._callbacks[0], this.jobs[key].onComplete, running, this.jobs[key].zone);\n\t\t}\n\t\telse {\n\t\t\tthrow new Error(`The cron definition passed was not a string or a Date object! ${key} was stopped and not updated`);\n\t\t}\n\t}\n\tcatch (tabErr) {\n\t\tconsole.error(`error updating tab: ${key} - ${tabErr.message}`);\n\t}\n}\n\nfunction updateTask(key, task) {\n\ttry {\n\t\tlet running = this.jobs[key].running;\n\t\tthis.jobs[key].stop();\n\n\t\tif (!(task instanceof Function)) {\n\t\t\tconsole.error(`can't update with something that is not a function: ${typeof(task)}`);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.jobs[key] = new CronJobPackage(this.jobs[key].cronTime.source, task, this.jobs[key].onComplete, running, this.jobs[key].zone);\n\n\n\t} \n\tcatch (tabErr) {\n\t\tconsole.error(`error updating task: ${key} - ${tabErr.message}`);\n\t}\n}\n\nmodule.exports = CrontabManager;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cron/cron.ts"],"names":[],"mappings":"AAAA,IAAI,cAAc,GAAG,OAAO,CAAC,MAAM,C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AED,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAI,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;KAGpI;IACD,OAAO,MAAM,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,0BAAwB,GAAG,YAAO,MAAM,CAAC,OAAS,CAAC,CAAC;KAClE;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,cAAc,CAAC","file":"cron.js","sourcesContent":["let CronJobPackage = require('cron').CronJob;\n\nfunction CrontabManager(key, tab, task, options) {\n\tthis.jobs = {};\n\tif (key && tab && task) {\n\t\tthis.add(key, tab, task, options);\n\t}\n\n}\n\nCrontabManager.prototype.getJob = function(key) {\n\treturn this.jobs[key];\n};\n\nCrontabManager.prototype.getJobs = function() {\n\treturn Object.keys(this.jobs);\n};\n\nCrontabManager.prototype.add = function(key, tab, task, options) {\n\tif ((typeof tab === 'string' || tab instanceof Date) && typeof key === 'string' && task instanceof Function) {\n\t\toptions = combineOptions(tab, task, options);\n\t\ttry {\n\t\t\tif (this.jobs[key]) {\n\t\t\t\tthis.deleteJob(key);\n\t\t\t\tconsole.warn(`${key} already existed and was deleted from the manager...`);\n\t\t\t}\n\t\t\t\n\t\t\tthis.jobs[key] = new CronJobPackage(options);\n\t\t} \n\t\tcatch (fooBaredByUser) {\n\t\t\tconsole.error(`crontab: ${tab} possibly not valid, job ${key} not started...${fooBaredByUser.message}`);\n\t\t}\n\t}\n\telse {\n\t\tconsole.warn(`couldn't add: ${key} improper arguments`);\n\t}\n};\n\nCrontabManager.prototype.update = function() {\n\tif (arguments.length === 2) {\n\t\tif (typeof arguments[1] === 'string' || arguments[1] instanceof Date) {\n\t\t\tupdateTab.call(this, arguments[0], arguments[1]);\n\t\t}\n\t\telse if (arguments[1] instanceof Function) {\n\t\t\tupdateTask.call(this, arguments[0], arguments[1]);\n\t\t}\n\t} \n\telse if (arguments.length === 3) {\n\t\tupdateTab.call(this, arguments[0], arguments[1]);\n\t\tupdateTask.call(this, arguments[0], arguments[2]);\n\t}\n\telse {\n\t\tconsole.error(`incorrect number of arguents passed to update.. won't update.. ${arguments[0]}`);\n\t}\n};\n\nCrontabManager.prototype.deleteJob = function(key) {\n\ttry {\n\t\tthis.jobs[key].stop();\n\t\tdelete this.jobs[key];\n\t}\n\tcatch (err) { \n\t\tconsole.error(`error in trying to stop job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.start = function(key) {\n\ttry {\n\t\tif (this.jobs[key].running) {\n\t\t\tconsole.warn(`${key} job already running`);\n\t\t}\n\t\telse {\n\t\t\tthis.jobs[key].start();\n\t\t}\n\t}\n\tcatch (err) {\n\t\tconsole.error(`couldn't start job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.stop = function(key) {\n\ttry {\n\t\tif (! this.jobs[key].running ) {\n\t\t\tconsole.warn(`${key} job already stopped`);\n\t\t}\n\t\telse {\n\t\t\tthis.jobs[key].stop();\n\t\t}\n\t}\n\tcatch (err) {\n\t\tconsole.error(`couldn't stop job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.stopAll = function() {\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\t\ttry {\n\t\t\tthis.jobs[jobKey].stop();\n\t\t}\n\t\tcatch (err) {\n\n\t\t}\n\t}\n};\n\nCrontabManager.prototype.toString = function() {\n\tlet manString = '{\\n';\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\n\t\tmanString += `'${jobKey}': ${this.jobs[jobKey].cronTime.source}: ${this.jobs[jobKey]._callbacks[0]}: ${this.jobs[jobKey].running ? 'Running' : 'Stopped'}`;\n\t}\n\tmanString += '\\n}';\n\treturn manString;\n};\n\nCrontabManager.prototype.listCrons = function() {\n\tlet manString = '{\\n';\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\t\tmanString += `'${jobKey}': ${this.jobs[jobKey].cronTime.source} status: ${this.jobs[jobKey].running ? 'Running' : 'Stopped'} \\n`;\n\t}\n\tmanString += '\\n}';\n\treturn manString;\n};\n\nCrontabManager.prototype.exists = function(tabKey) {\n\tif (this.jobs[tabKey]) {\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\nfunction combineOptions(tab, task, options) {\n\tlet newOpts = {};\n\tnewOpts['cronTime'] = tab; \n\tnewOpts['onTick'] = task;\n\n\tif (options instanceof Object) {\n\t\t// might overwrite... please be careful.\n\t\t// tslint:disable-next-line:forin\n\t\tfor (let optionKey in options) {\n\t\t\tnewOpts[optionKey] = options[optionKey];\n\t\t}\n\t}\n\treturn newOpts;\n}\n\nfunction updateTab(key, cronstring) {\n\n\ttry {\n\t\tlet running = this.jobs[key].running;\n\t\tthis.jobs[key].stop();\n\n\t\tif (typeof cronstring === 'string' || cronstring instanceof Date) {\n\t\t\tthis.jobs[key] = new CronJobPackage(cronstring, this.jobs[key]._callbacks[0], this.jobs[key].onComplete, running, this.jobs[key].zone);\n\t\t}\n\t\telse {\n\t\t\tthrow new Error(`The cron definition passed was not a string or a Date object! ${key} was stopped and not updated`);\n\t\t}\n\t}\n\tcatch (tabErr) {\n\t\tconsole.error(`error updating tab: ${key} - ${tabErr.message}`);\n\t}\n}\n\nfunction updateTask(key, task) {\n\ttry {\n\t\tlet running = this.jobs[key].running;\n\t\tthis.jobs[key].stop();\n\n\t\tif (!(task instanceof Function)) {\n\t\t\tconsole.error(`can't update with something that is not a function: ${typeof(task)}`);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.jobs[key] = new CronJobPackage(this.jobs[key].cronTime.source, task, this.jobs[key].onComplete, running, this.jobs[key].zone);\n\n\n\t} \n\tcatch (tabErr) {\n\t\tconsole.error(`error updating task: ${key} - ${tabErr.message}`);\n\t}\n}\n\nmodule.exports = CrontabManager;\n"]}
|
package/fixtures/cron-jobs.js
CHANGED
|
@@ -1,2 +1,73 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.loadServerCronJobs = void 0;
|
|
40
|
+
var cron_job_collection_1 = require("../collections/cron-job.collection");
|
|
41
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
42
|
+
function loadServerCronJobs() {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var cronJobs;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, cron_job_collection_1.CronJobs.find({})];
|
|
48
|
+
case 1:
|
|
49
|
+
cronJobs = _a.sent();
|
|
50
|
+
if (!cronJobs.some(function (a) { return a.name === 'Email Merged Docs Cleanup'; })) {
|
|
51
|
+
cron_job_collection_1.CronJobs.create({
|
|
52
|
+
_id: mongo_manager_1.objectIdHexString(),
|
|
53
|
+
__v: 0,
|
|
54
|
+
name: 'Email Merged Docs Cleanup',
|
|
55
|
+
repeat: true,
|
|
56
|
+
time_to_run: '0 0 * * *',
|
|
57
|
+
method_run: 'cronEmailMergedDocsCleanUp',
|
|
58
|
+
method_run_data: null,
|
|
59
|
+
next_run: new Date(),
|
|
60
|
+
running: false
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
cronJobs.filter(function (a) { return a.running && a.next_run && a.next_run.getTime() < (new Date()).getTime(); }).forEach(function (cronJob) {
|
|
64
|
+
cron_job_collection_1.CronJobs.updateOne({ _id: cronJob._id }, { $set: { running: false } });
|
|
65
|
+
});
|
|
66
|
+
return [2 /*return*/];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
exports.loadServerCronJobs = loadServerCronJobs;
|
|
72
|
+
|
|
2
73
|
//# sourceMappingURL=cron-jobs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fixtures/cron-jobs.ts"],"names":[
|
|
1
|
+
{"version":3,"sources":["../../src/fixtures/cron-jobs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAA8D;AAC9D,2DAA8D;AAE9D,SAAsB,kBAAkB;;;;;wBAExB,qBAAM,8BAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAA;;oBAAlC,QAAQ,GAAG,SAAuB;oBAEtC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,KAAK,2BAA2B,EAAtC,CAAsC,CAAC,EAAE;wBAChE,8BAAQ,CAAC,MAAM,CAAC;4BACf,GAAG,EAAE,iCAAiB,EAAE;4BACxB,GAAG,EAAE,CAAC;4BACN,IAAI,EAAG,2BAA2B;4BAClC,MAAM,EAAG,IAAI;4BACb,WAAW,EAAG,WAAW;4BACzB,UAAU,EAAG,4BAA4B;4BACzC,eAAe,EAAG,IAAI;4BACtB,QAAQ,EAAG,IAAI,IAAI,EAAE;4BACrB,OAAO,EAAG,KAAK;yBACf,CAAC,CAAC;qBACH;oBAED,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,EAAxE,CAAwE,CAAC,CAAC,OAAO,CAAC,UAAA,OAAO;wBAC7G,8BAAQ,CAAC,SAAS,CAAC,EAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC,EAAC,CAAC,CAAC;oBAClE,CAAC,CAAC,CAAC;;;;;CACH;AArBD,gDAqBC","file":"cron-jobs.js","sourcesContent":["import { CronJobs } from '../collections/cron-job.collection';\nimport { objectIdHexString } from '../managers/mongo.manager';\n\nexport async function loadServerCronJobs() {\n\n\tlet cronJobs = await CronJobs.find({});\n\n\tif (!cronJobs.some(a => a.name === 'Email Merged Docs Cleanup')) {\n\t\tCronJobs.create({\n\t\t\t_id: objectIdHexString(),\n\t\t\t__v: 0,\n\t\t\tname : 'Email Merged Docs Cleanup', \n\t\t\trepeat : true, \n\t\t\ttime_to_run : '0 0 * * *', \n\t\t\tmethod_run : 'cronEmailMergedDocsCleanUp', \n\t\t\tmethod_run_data : null, \n\t\t\tnext_run : new Date(), \n\t\t\trunning : false\n\t\t});\n\t}\n\n\tcronJobs.filter(a => a.running && a.next_run && a.next_run.getTime() < (new Date()).getTime()).forEach(cronJob => {\n\t\tCronJobs.updateOne({_id: cronJob._id}, {$set: {running: false}});\n\t});\n} "]}
|