@resolveio/server-lib 3.2.10 → 3.2.11

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.
Files changed (177) hide show
  1. package/package.json +26 -26
  2. package/collections/active-subscription.collection.d.ts +0 -7
  3. package/collections/active-subscription.collection.js +0 -68
  4. package/collections/app-status.collection.d.ts +0 -7
  5. package/collections/app-status.collection.js +0 -43
  6. package/collections/app-version.collection.d.ts +0 -7
  7. package/collections/app-version.collection.js +0 -56
  8. package/collections/billing-logged-in-users.collection.d.ts +0 -7
  9. package/collections/billing-logged-in-users.collection.js +0 -73
  10. package/collections/counter.collection.d.ts +0 -9
  11. package/collections/counter.collection.js +0 -73
  12. package/collections/cron-job-history.collection.d.ts +0 -7
  13. package/collections/cron-job-history.collection.js +0 -86
  14. package/collections/cron-job.collection.d.ts +0 -7
  15. package/collections/cron-job.collection.js +0 -89
  16. package/collections/file.collection.d.ts +0 -9
  17. package/collections/file.collection.js +0 -73
  18. package/collections/flag.collection.d.ts +0 -7
  19. package/collections/flag.collection.js +0 -47
  20. package/collections/log.collection.d.ts +0 -7
  21. package/collections/log.collection.js +0 -65
  22. package/collections/logged-in-users.collection.d.ts +0 -7
  23. package/collections/logged-in-users.collection.js +0 -70
  24. package/collections/method-call.collection.d.ts +0 -6
  25. package/collections/method-call.collection.js +0 -44
  26. package/collections/method-response.collection.d.ts +0 -6
  27. package/collections/method-response.collection.js +0 -48
  28. package/collections/notification.collection.d.ts +0 -7
  29. package/collections/notification.collection.js +0 -43
  30. package/collections/queue-flag.collection.d.ts +0 -7
  31. package/collections/queue-flag.collection.js +0 -41
  32. package/collections/queue-method.collection.d.ts +0 -7
  33. package/collections/queue-method.collection.js +0 -119
  34. package/collections/queue-response.collection.d.ts +0 -7
  35. package/collections/queue-response.collection.js +0 -74
  36. package/collections/support-ticket.collection.d.ts +0 -7
  37. package/collections/support-ticket.collection.js +0 -200
  38. package/collections/user.collection.d.ts +0 -9
  39. package/collections/user.collection.js +0 -153
  40. package/cron/cron.d.ts +0 -5
  41. package/cron/cron.js +0 -160
  42. package/fixtures/cron-jobs.d.ts +0 -1
  43. package/fixtures/cron-jobs.js +0 -90
  44. package/fixtures/init.d.ts +0 -1
  45. package/fixtures/init.js +0 -67
  46. package/http/auth.d.ts +0 -2
  47. package/http/auth.js +0 -468
  48. package/http/health.d.ts +0 -1
  49. package/http/health.js +0 -8
  50. package/index.d.ts +0 -16
  51. package/index.js +0 -125
  52. package/managers/cron.manager.d.ts +0 -16
  53. package/managers/cron.manager.js +0 -202
  54. package/managers/database.manager.d.ts +0 -6
  55. package/managers/database.manager.js +0 -12
  56. package/managers/method.manager.d.ts +0 -28
  57. package/managers/method.manager.js +0 -584
  58. package/managers/queue-method.manager.d.ts +0 -13
  59. package/managers/queue-method.manager.js +0 -240
  60. package/managers/subscription.manager.d.ts +0 -28
  61. package/managers/subscription.manager.js +0 -803
  62. package/managers/support.manager.d.ts +0 -22
  63. package/managers/support.manager.js +0 -320
  64. package/methods/accounts.d.ts +0 -2
  65. package/methods/accounts.js +0 -253
  66. package/methods/aws.d.ts +0 -2
  67. package/methods/aws.js +0 -387
  68. package/methods/cloudconvert.d.ts +0 -2
  69. package/methods/cloudconvert.js +0 -37
  70. package/methods/collections.d.ts +0 -2
  71. package/methods/collections.js +0 -750
  72. package/methods/counters.d.ts +0 -2
  73. package/methods/counters.js +0 -107
  74. package/methods/cron-jobs.d.ts +0 -2
  75. package/methods/cron-jobs.js +0 -132
  76. package/methods/flags.d.ts +0 -2
  77. package/methods/flags.js +0 -6
  78. package/methods/logs.d.ts +0 -2
  79. package/methods/logs.js +0 -29
  80. package/methods/pdf.d.ts +0 -2
  81. package/methods/pdf.js +0 -303
  82. package/models/active-subscription.model.d.ts +0 -13
  83. package/models/active-subscription.model.js +0 -2
  84. package/models/app-status.model.d.ts +0 -4
  85. package/models/app-status.model.js +0 -2
  86. package/models/app-version.model.d.ts +0 -4
  87. package/models/app-version.model.js +0 -2
  88. package/models/billing-logged-in-users.model.d.ts +0 -7
  89. package/models/billing-logged-in-users.model.js +0 -2
  90. package/models/collection-document.model.d.ts +0 -6
  91. package/models/collection-document.model.js +0 -2
  92. package/models/counter.model.d.ts +0 -5
  93. package/models/counter.model.js +0 -2
  94. package/models/cron-job-history.model.d.ts +0 -12
  95. package/models/cron-job-history.model.js +0 -2
  96. package/models/cron-job.model.d.ts +0 -13
  97. package/models/cron-job.model.js +0 -2
  98. package/models/dialog.model.d.ts +0 -23
  99. package/models/dialog.model.js +0 -2
  100. package/models/file.model.d.ts +0 -9
  101. package/models/file.model.js +0 -2
  102. package/models/flag.model.d.ts +0 -5
  103. package/models/flag.model.js +0 -2
  104. package/models/log.model.d.ts +0 -11
  105. package/models/log.model.js +0 -2
  106. package/models/logged-in-users.model.d.ts +0 -9
  107. package/models/logged-in-users.model.js +0 -2
  108. package/models/method-call.model.d.ts +0 -7
  109. package/models/method-call.model.js +0 -2
  110. package/models/method-response.model.d.ts +0 -8
  111. package/models/method-response.model.js +0 -2
  112. package/models/method.model.d.ts +0 -10
  113. package/models/method.model.js +0 -2
  114. package/models/notification.model.d.ts +0 -4
  115. package/models/notification.model.js +0 -2
  116. package/models/pagination.model.d.ts +0 -11
  117. package/models/pagination.model.js +0 -20
  118. package/models/permission.model.d.ts +0 -12
  119. package/models/permission.model.js +0 -2
  120. package/models/queue-method.model.d.ts +0 -10
  121. package/models/queue-method.model.js +0 -2
  122. package/models/queue-response.model.d.ts +0 -10
  123. package/models/queue-response.model.js +0 -2
  124. package/models/select-data-label.model.d.ts +0 -9
  125. package/models/select-data-label.model.js +0 -2
  126. package/models/server-response.model.d.ts +0 -5
  127. package/models/server-response.model.js +0 -2
  128. package/models/subscription.model.d.ts +0 -30
  129. package/models/subscription.model.js +0 -2
  130. package/models/support-method.model.d.ts +0 -9
  131. package/models/support-method.model.js +0 -2
  132. package/models/support-ticket.model.d.ts +0 -61
  133. package/models/support-ticket.model.js +0 -2
  134. package/models/user.model.d.ts +0 -14
  135. package/models/user.model.js +0 -2
  136. package/private/email-templates/enrollment.html +0 -12
  137. package/private/email-templates/forgot-password.html +0 -12
  138. package/private/email-templates/support-ticket-deleted.html +0 -40
  139. package/private/email-templates/support-ticket-modified.html +0 -71
  140. package/private/email-templates/support-ticket.html +0 -71
  141. package/private/images/ResolveIO.png +0 -0
  142. package/publications/app-status.d.ts +0 -2
  143. package/publications/app-status.js +0 -14
  144. package/publications/app-version.d.ts +0 -2
  145. package/publications/app-version.js +0 -14
  146. package/publications/billing-logged-in-users.d.ts +0 -1
  147. package/publications/billing-logged-in-users.js +0 -63
  148. package/publications/cron-jobs.d.ts +0 -2
  149. package/publications/cron-jobs.js +0 -14
  150. package/publications/files.d.ts +0 -2
  151. package/publications/files.js +0 -71
  152. package/publications/flags.d.ts +0 -2
  153. package/publications/flags.js +0 -23
  154. package/publications/logs.d.ts +0 -2
  155. package/publications/logs.js +0 -26
  156. package/publications/method-calls.d.ts +0 -2
  157. package/publications/method-calls.js +0 -14
  158. package/publications/method-responses.d.ts +0 -2
  159. package/publications/method-responses.js +0 -14
  160. package/publications/notifications.d.ts +0 -2
  161. package/publications/notifications.js +0 -14
  162. package/publications/super-admin.d.ts +0 -2
  163. package/publications/super-admin.js +0 -21
  164. package/publications/support-tickets.d.ts +0 -1
  165. package/publications/support-tickets.js +0 -200
  166. package/server-app.d.ts +0 -35
  167. package/server-app.js +0 -636
  168. package/support-methods/aws.d.ts +0 -2
  169. package/support-methods/aws.js +0 -276
  170. package/support-methods/collections.d.ts +0 -2
  171. package/support-methods/collections.js +0 -471
  172. package/support-methods/counters.d.ts +0 -2
  173. package/support-methods/counters.js +0 -189
  174. package/support-methods/support.d.ts +0 -2
  175. package/support-methods/support.js +0 -236
  176. package/util/common.d.ts +0 -14
  177. package/util/common.js +0 -341
@@ -1,74 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- var mongoose_1 = require("mongoose");
15
- var simpl_schema_1 = require("simpl-schema");
16
- var index_1 = require("../index");
17
- var schema = {
18
- _id: {
19
- type: String,
20
- optional: true
21
- },
22
- __v: {
23
- type: Number,
24
- optional: true
25
- },
26
- updatedAt: {
27
- type: Date,
28
- optional: true
29
- },
30
- createdAt: {
31
- type: Date,
32
- optional: true
33
- },
34
- method: {
35
- type: String
36
- },
37
- id_ws: {
38
- type: String
39
- },
40
- messageId: {
41
- type: Number
42
- },
43
- id_user: {
44
- type: String
45
- },
46
- user: {
47
- type: String
48
- },
49
- response: {
50
- type: Object,
51
- blackbox: true
52
- },
53
- date: {
54
- type: Date
55
- }
56
- };
57
- var DefaultSchema = new mongoose_1.Schema(schema, {
58
- skipVersioning: true,
59
- versionKey: false,
60
- timestamps: true
61
- });
62
- exports.QueueResponses = index_1.ResolveIOServer.getMainDB().model('queue-responses', DefaultSchema);
63
- var vSchema = __assign({}, schema);
64
- vSchema._id = {
65
- type: mongoose_1.Schema.Types.Mixed
66
- };
67
- var VersionSchema = new mongoose_1.Schema(vSchema, {
68
- skipVersioning: true,
69
- versionKey: false,
70
- timestamps: true
71
- });
72
- exports.QueueResponses['versionCollection'] = 'queue-responses.versions';
73
- exports.QueueResponseVersions = index_1.ResolveIOServer.getMainDB().model(exports.QueueResponses['versionCollection'], VersionSchema);
74
- exports.QueueResponses['simplschema'] = new simpl_schema_1.default(schema);
@@ -1,7 +0,0 @@
1
- import { Model, Document } from 'mongoose';
2
- import { SupportTicketModel } from '../models/support-ticket.model';
3
- interface ResolveIOModel extends SupportTicketModel, Document {
4
- }
5
- export declare let SupportTickets: Model<ResolveIOModel>;
6
- export declare let SupportTicketVersions: Model<ResolveIOModel>;
7
- export {};
@@ -1,200 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var mongoose_1 = require("mongoose");
4
- var simpl_schema_1 = require("simpl-schema");
5
- var index_1 = require("../index");
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
- type: {
24
- type: String
25
- },
26
- priority: {
27
- type: String
28
- },
29
- issue: {
30
- type: String
31
- },
32
- support_ticket_number: {
33
- type: Number
34
- },
35
- support_ticket_number_string: {
36
- type: String
37
- },
38
- status: {
39
- type: String
40
- },
41
- substatus: {
42
- type: String
43
- },
44
- client: {
45
- type: String
46
- },
47
- id_client: {
48
- type: String
49
- },
50
- messages: {
51
- type: Array
52
- },
53
- 'messages.$': {
54
- type: Object
55
- },
56
- 'messages.$.message': {
57
- type: String
58
- },
59
- 'messages.$.id_user': {
60
- type: String
61
- },
62
- 'messages.$.user': {
63
- type: String
64
- },
65
- 'messages.$.date': {
66
- type: Date
67
- },
68
- 'messages.$.type': {
69
- type: String
70
- },
71
- date_created: {
72
- type: Date
73
- },
74
- date_created_string: {
75
- type: String
76
- },
77
- id_user_created: {
78
- type: String
79
- },
80
- user_created: {
81
- type: String
82
- },
83
- billable: {
84
- type: Boolean
85
- },
86
- date_investigation: {
87
- type: Date,
88
- optional: true,
89
- },
90
- date_closed: {
91
- type: Date,
92
- optional: true,
93
- },
94
- files: {
95
- type: Array
96
- },
97
- 'files.$': {
98
- type: String
99
- },
100
- current_watchers: {
101
- type: Array
102
- },
103
- 'current_watchers.$': {
104
- type: Object
105
- },
106
- 'current_watchers.$.user': {
107
- type: String
108
- },
109
- 'current_watchers.$.id_user': {
110
- type: String
111
- },
112
- 'current_watchers.$.email': {
113
- type: String
114
- },
115
- client_user: {
116
- type: Object
117
- },
118
- 'client_user.id_user': {
119
- type: String
120
- },
121
- 'client_user.user': {
122
- type: String
123
- },
124
- 'client_user.email': {
125
- type: String
126
- },
127
- id_user_assigned: {
128
- type: String
129
- },
130
- user_assigned: {
131
- type: String
132
- },
133
- resolveio_status: {
134
- type: String
135
- },
136
- estimated_billable_hours: {
137
- type: Number,
138
- optional: true
139
- },
140
- billable_hours: {
141
- type: Number,
142
- optional: true
143
- },
144
- bill_description: {
145
- type: String
146
- },
147
- tasks: {
148
- type: Array,
149
- optional: true
150
- },
151
- 'tasks.$': {
152
- type: Object
153
- },
154
- 'tasks.$.description': {
155
- type: String
156
- },
157
- 'tasks.$.completed': {
158
- type: Boolean
159
- },
160
- 'tasks.$.id_user': {
161
- type: String,
162
- optional: true
163
- },
164
- 'tasks.$.user': {
165
- type: String,
166
- optional: true
167
- },
168
- 'tasks.$.date_created': {
169
- type: Date
170
- },
171
- 'tasks.$.date_completed': {
172
- type: Date,
173
- optional: true
174
- },
175
- };
176
- var DefaultSchema = new mongoose_1.Schema(schema, {
177
- skipVersioning: true,
178
- versionKey: false,
179
- timestamps: true
180
- });
181
- exports.SupportTickets = null;
182
- if (index_1.ResolveIOServer.getSupportDB()) {
183
- exports.SupportTickets = index_1.ResolveIOServer.getSupportDB().model('support-tickets', DefaultSchema);
184
- exports.SupportTickets['simplschema'] = new simpl_schema_1.default(schema);
185
- }
186
- schema._id = {
187
- type: mongoose_1.Schema.Types.Mixed
188
- };
189
- var VersionSchema = new mongoose_1.Schema(schema, {
190
- skipVersioning: true,
191
- versionKey: false,
192
- timestamps: true
193
- });
194
- if (index_1.ResolveIOServer.getSupportDB()) {
195
- exports.SupportTickets['versionCollection'] = 'support-tickets.versions';
196
- }
197
- exports.SupportTicketVersions = null;
198
- if (index_1.ResolveIOServer.getSupportDB()) {
199
- exports.SupportTicketVersions = index_1.ResolveIOServer.getSupportDB().model(exports.SupportTickets['versionCollection'], VersionSchema);
200
- }
@@ -1,9 +0,0 @@
1
- /// <reference types="passport-local-mongoose" />
2
- import { Model, PassportLocalDocument, PassportLocalModel } from 'mongoose';
3
- import { UserModel } from '../models/user.model';
4
- interface ResolveIOModel extends UserModel, PassportLocalDocument {
5
- }
6
- export declare const Users: PassportLocalModel<ResolveIOModel>;
7
- export declare let ClientUsers: PassportLocalModel<ResolveIOModel>;
8
- export declare const UserVersions: Model<ResolveIOModel>;
9
- export {};
@@ -1,153 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var mongoose_1 = require("mongoose");
4
- var passportLocalMongoose = require("passport-local-mongoose");
5
- var simpl_schema_1 = require("simpl-schema");
6
- var index_1 = require("../index");
7
- var schema = {
8
- _id: {
9
- type: String,
10
- optional: true
11
- },
12
- __v: {
13
- type: Number,
14
- optional: true
15
- },
16
- updatedAt: {
17
- type: Date,
18
- optional: true
19
- },
20
- createdAt: {
21
- type: Date,
22
- optional: true
23
- },
24
- readonly: {
25
- type: Boolean,
26
- optional: true
27
- },
28
- active: {
29
- type: Boolean
30
- },
31
- attempts: {
32
- type: Number,
33
- optional: true
34
- },
35
- last: {
36
- type: Date,
37
- optional: true
38
- },
39
- services: {
40
- type: Object,
41
- optional: true
42
- },
43
- 'services.enrollment': {
44
- type: String,
45
- optional: true
46
- },
47
- 'services.forgot_password': {
48
- type: String,
49
- optional: true
50
- },
51
- 'services.reset_password': {
52
- type: String,
53
- optional: true
54
- },
55
- username: {
56
- type: String,
57
- optional: true
58
- },
59
- email: {
60
- type: String,
61
- optional: true
62
- },
63
- fullname: {
64
- type: String
65
- },
66
- roles: {
67
- type: Array
68
- },
69
- 'roles.$': {
70
- type: String
71
- },
72
- phonenumber: {
73
- type: String,
74
- optional: true
75
- },
76
- other: {
77
- type: Object,
78
- blackbox: true,
79
- optional: true
80
- },
81
- assets: {
82
- type: Array,
83
- optional: true
84
- },
85
- 'assets.$': {
86
- type: Object
87
- },
88
- 'assets.$.type': {
89
- type: String
90
- },
91
- 'assets.$.id_asset': {
92
- type: String
93
- },
94
- 'assets.$.asset_number': {
95
- type: String
96
- },
97
- 'assets.$.ownership': {
98
- type: String
99
- },
100
- 'assets.$.ownership_driver': {
101
- type: String
102
- },
103
- 'assets.$.date_start': {
104
- type: Date
105
- },
106
- 'assets.$.date_end': {
107
- type: Date,
108
- optional: true
109
- },
110
- id_function: {
111
- type: String,
112
- optional: true
113
- },
114
- customer: {
115
- type: String,
116
- optional: true,
117
- },
118
- id_customer: {
119
- type: String,
120
- optional: true,
121
- }
122
- };
123
- var DefaultSchema = new mongoose_1.Schema(schema, {
124
- skipVersioning: true,
125
- versionKey: false,
126
- timestamps: true
127
- });
128
- DefaultSchema.plugin(passportLocalMongoose, {
129
- usernameUnique: true,
130
- limitAttempts: true,
131
- maxAttempts: 5,
132
- findByUsername: function (mongooseModel, queryParameters) {
133
- // Add additional query parameter - AND condition - active: true
134
- queryParameters.active = true;
135
- return mongooseModel.findOne(queryParameters);
136
- }
137
- });
138
- exports.Users = index_1.ResolveIOServer.getMainDB().model('users', DefaultSchema);
139
- exports.ClientUsers = null;
140
- if (index_1.ResolveIOServer.getSupportDB()) {
141
- exports.ClientUsers = index_1.ResolveIOServer.getSupportDB().model('client-users', DefaultSchema);
142
- }
143
- exports.Users['simplschema'] = new simpl_schema_1.default(schema);
144
- schema._id = {
145
- type: mongoose_1.Schema.Types.Mixed
146
- };
147
- var VersionSchema = new mongoose_1.Schema(schema, {
148
- skipVersioning: true,
149
- versionKey: false,
150
- timestamps: true
151
- });
152
- exports.Users['versionCollection'] = 'users.versions';
153
- exports.UserVersions = index_1.ResolveIOServer.getMainDB().model(exports.Users['versionCollection'], VersionSchema);
package/cron/cron.d.ts DELETED
@@ -1,5 +0,0 @@
1
- declare let CronJob: any;
2
- declare function CrontabManager(key: any, tab: any, task: any, options: any): void;
3
- declare function combineOptions(tab: any, task: any, options: any): {};
4
- declare function updateTab(key: any, cronstring: any): void;
5
- declare function updateTask(key: any, task: any): void;
package/cron/cron.js DELETED
@@ -1,160 +0,0 @@
1
- var CronJob = 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 CronJob(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 CronJob(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 CronJob(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;
@@ -1 +0,0 @@
1
- export declare function loadServerCronJobs(): Promise<void>;
@@ -1,90 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- 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;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- var cron_job_collection_1 = require("../collections/cron-job.collection");
39
- var mongoose_1 = require("mongoose");
40
- function loadServerCronJobs() {
41
- return __awaiter(this, void 0, void 0, function () {
42
- var cronJobs;
43
- return __generator(this, function (_a) {
44
- switch (_a.label) {
45
- case 0: return [4 /*yield*/, cron_job_collection_1.CronJobs.find({}).exec()];
46
- case 1:
47
- cronJobs = _a.sent();
48
- if (!!cronJobs.filter(function (a) { return a.name === 'Method Queue'; }).length) return [3 /*break*/, 3];
49
- return [4 /*yield*/, cron_job_collection_1.CronJobs.create({
50
- _id: mongoose_1.Types.ObjectId().toHexString(),
51
- __v: 0,
52
- name: 'Method Queue',
53
- "repeat": true,
54
- reoccuring: true,
55
- "time_to_run": "*/5 * * * * *",
56
- "method_run": "methodQueue",
57
- "method_run_data": null,
58
- "next_run": new Date(),
59
- "running": false
60
- })];
61
- case 2:
62
- _a.sent();
63
- _a.label = 3;
64
- case 3:
65
- if (!!cronJobs.filter(function (a) { return a.name === 'Update Client Users'; }).length) return [3 /*break*/, 5];
66
- return [4 /*yield*/, cron_job_collection_1.CronJobs.create({
67
- _id: mongoose_1.Types.ObjectId().toHexString(),
68
- __v: 0,
69
- name: 'Update Client Users',
70
- "repeat": true,
71
- reoccuring: true,
72
- "time_to_run": "0 */1 * * *",
73
- "method_run": "updateClientUsers",
74
- "method_run_data": null,
75
- "next_run": new Date(),
76
- "running": false
77
- })];
78
- case 4:
79
- _a.sent();
80
- _a.label = 5;
81
- case 5:
82
- cronJobs.filter(function (a) { return a.running && a.next_run && a.next_run.getTime() < (new Date()).getTime(); }).forEach(function (cronJob) {
83
- cron_job_collection_1.CronJobs.updateOne({ _id: cronJob._id }, { $set: { running: false } }).exec();
84
- });
85
- return [2 /*return*/];
86
- }
87
- });
88
- });
89
- }
90
- exports.loadServerCronJobs = loadServerCronJobs;