@resolveio/server-lib 3.2.11 → 3.2.12

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/collections/active-subscription.collection.d.ts +7 -0
  2. package/collections/active-subscription.collection.js +68 -0
  3. package/collections/app-status.collection.d.ts +7 -0
  4. package/collections/app-status.collection.js +43 -0
  5. package/collections/app-version.collection.d.ts +7 -0
  6. package/collections/app-version.collection.js +56 -0
  7. package/collections/billing-logged-in-users.collection.d.ts +7 -0
  8. package/collections/billing-logged-in-users.collection.js +73 -0
  9. package/collections/counter.collection.d.ts +9 -0
  10. package/collections/counter.collection.js +73 -0
  11. package/collections/cron-job-history.collection.d.ts +7 -0
  12. package/collections/cron-job-history.collection.js +86 -0
  13. package/collections/cron-job.collection.d.ts +7 -0
  14. package/collections/cron-job.collection.js +89 -0
  15. package/collections/file.collection.d.ts +9 -0
  16. package/collections/file.collection.js +73 -0
  17. package/collections/flag.collection.d.ts +7 -0
  18. package/collections/flag.collection.js +47 -0
  19. package/collections/log.collection.d.ts +7 -0
  20. package/collections/log.collection.js +65 -0
  21. package/collections/logged-in-users.collection.d.ts +7 -0
  22. package/collections/logged-in-users.collection.js +70 -0
  23. package/collections/method-call.collection.d.ts +6 -0
  24. package/collections/method-call.collection.js +44 -0
  25. package/collections/method-response.collection.d.ts +6 -0
  26. package/collections/method-response.collection.js +48 -0
  27. package/collections/notification.collection.d.ts +7 -0
  28. package/collections/notification.collection.js +43 -0
  29. package/collections/queue-flag.collection.d.ts +7 -0
  30. package/collections/queue-flag.collection.js +41 -0
  31. package/collections/queue-method.collection.d.ts +7 -0
  32. package/collections/queue-method.collection.js +119 -0
  33. package/collections/queue-response.collection.d.ts +7 -0
  34. package/collections/queue-response.collection.js +74 -0
  35. package/collections/support-ticket.collection.d.ts +7 -0
  36. package/collections/support-ticket.collection.js +200 -0
  37. package/collections/user.collection.d.ts +9 -0
  38. package/collections/user.collection.js +153 -0
  39. package/cron/cron.d.ts +5 -0
  40. package/cron/cron.js +160 -0
  41. package/fixtures/cron-jobs.d.ts +1 -0
  42. package/fixtures/cron-jobs.js +90 -0
  43. package/fixtures/init.d.ts +1 -0
  44. package/fixtures/init.js +67 -0
  45. package/http/auth.d.ts +2 -0
  46. package/http/auth.js +468 -0
  47. package/http/health.d.ts +1 -0
  48. package/http/health.js +8 -0
  49. package/index.d.ts +16 -0
  50. package/index.js +125 -0
  51. package/managers/cron.manager.d.ts +16 -0
  52. package/managers/cron.manager.js +202 -0
  53. package/managers/database.manager.d.ts +6 -0
  54. package/managers/database.manager.js +12 -0
  55. package/managers/method.manager.d.ts +28 -0
  56. package/managers/method.manager.js +584 -0
  57. package/managers/queue-method.manager.d.ts +13 -0
  58. package/managers/queue-method.manager.js +240 -0
  59. package/managers/subscription.manager.d.ts +28 -0
  60. package/managers/subscription.manager.js +808 -0
  61. package/managers/support.manager.d.ts +22 -0
  62. package/managers/support.manager.js +320 -0
  63. package/methods/accounts.d.ts +2 -0
  64. package/methods/accounts.js +253 -0
  65. package/methods/aws.d.ts +2 -0
  66. package/methods/aws.js +387 -0
  67. package/methods/cloudconvert.d.ts +2 -0
  68. package/methods/cloudconvert.js +37 -0
  69. package/methods/collections.d.ts +2 -0
  70. package/methods/collections.js +750 -0
  71. package/methods/counters.d.ts +2 -0
  72. package/methods/counters.js +107 -0
  73. package/methods/cron-jobs.d.ts +2 -0
  74. package/methods/cron-jobs.js +132 -0
  75. package/methods/flags.d.ts +2 -0
  76. package/methods/flags.js +6 -0
  77. package/methods/logs.d.ts +2 -0
  78. package/methods/logs.js +29 -0
  79. package/methods/pdf.d.ts +2 -0
  80. package/methods/pdf.js +303 -0
  81. package/models/active-subscription.model.d.ts +13 -0
  82. package/models/active-subscription.model.js +2 -0
  83. package/models/app-status.model.d.ts +4 -0
  84. package/models/app-status.model.js +2 -0
  85. package/models/app-version.model.d.ts +4 -0
  86. package/models/app-version.model.js +2 -0
  87. package/models/billing-logged-in-users.model.d.ts +7 -0
  88. package/models/billing-logged-in-users.model.js +2 -0
  89. package/models/collection-document.model.d.ts +6 -0
  90. package/models/collection-document.model.js +2 -0
  91. package/models/counter.model.d.ts +5 -0
  92. package/models/counter.model.js +2 -0
  93. package/models/cron-job-history.model.d.ts +12 -0
  94. package/models/cron-job-history.model.js +2 -0
  95. package/models/cron-job.model.d.ts +13 -0
  96. package/models/cron-job.model.js +2 -0
  97. package/models/dialog.model.d.ts +23 -0
  98. package/models/dialog.model.js +2 -0
  99. package/models/file.model.d.ts +9 -0
  100. package/models/file.model.js +2 -0
  101. package/models/flag.model.d.ts +5 -0
  102. package/models/flag.model.js +2 -0
  103. package/models/log.model.d.ts +11 -0
  104. package/models/log.model.js +2 -0
  105. package/models/logged-in-users.model.d.ts +9 -0
  106. package/models/logged-in-users.model.js +2 -0
  107. package/models/method-call.model.d.ts +7 -0
  108. package/models/method-call.model.js +2 -0
  109. package/models/method-response.model.d.ts +8 -0
  110. package/models/method-response.model.js +2 -0
  111. package/models/method.model.d.ts +10 -0
  112. package/models/method.model.js +2 -0
  113. package/models/notification.model.d.ts +4 -0
  114. package/models/notification.model.js +2 -0
  115. package/models/pagination.model.d.ts +11 -0
  116. package/models/pagination.model.js +20 -0
  117. package/models/permission.model.d.ts +12 -0
  118. package/models/permission.model.js +2 -0
  119. package/models/queue-method.model.d.ts +10 -0
  120. package/models/queue-method.model.js +2 -0
  121. package/models/queue-response.model.d.ts +10 -0
  122. package/models/queue-response.model.js +2 -0
  123. package/models/select-data-label.model.d.ts +9 -0
  124. package/models/select-data-label.model.js +2 -0
  125. package/models/server-response.model.d.ts +5 -0
  126. package/models/server-response.model.js +2 -0
  127. package/models/subscription.model.d.ts +30 -0
  128. package/models/subscription.model.js +2 -0
  129. package/models/support-method.model.d.ts +9 -0
  130. package/models/support-method.model.js +2 -0
  131. package/models/support-ticket.model.d.ts +61 -0
  132. package/models/support-ticket.model.js +2 -0
  133. package/models/user.model.d.ts +14 -0
  134. package/models/user.model.js +2 -0
  135. package/package.json +1 -1
  136. package/private/email-templates/enrollment.html +12 -0
  137. package/private/email-templates/forgot-password.html +12 -0
  138. package/private/email-templates/support-ticket-deleted.html +40 -0
  139. package/private/email-templates/support-ticket-modified.html +71 -0
  140. package/private/email-templates/support-ticket.html +71 -0
  141. package/private/images/ResolveIO.png +0 -0
  142. package/publications/app-status.d.ts +2 -0
  143. package/publications/app-status.js +14 -0
  144. package/publications/app-version.d.ts +2 -0
  145. package/publications/app-version.js +14 -0
  146. package/publications/billing-logged-in-users.d.ts +1 -0
  147. package/publications/billing-logged-in-users.js +63 -0
  148. package/publications/cron-jobs.d.ts +2 -0
  149. package/publications/cron-jobs.js +14 -0
  150. package/publications/files.d.ts +2 -0
  151. package/publications/files.js +71 -0
  152. package/publications/flags.d.ts +2 -0
  153. package/publications/flags.js +23 -0
  154. package/publications/logs.d.ts +2 -0
  155. package/publications/logs.js +26 -0
  156. package/publications/method-calls.d.ts +2 -0
  157. package/publications/method-calls.js +14 -0
  158. package/publications/method-responses.d.ts +2 -0
  159. package/publications/method-responses.js +14 -0
  160. package/publications/notifications.d.ts +2 -0
  161. package/publications/notifications.js +14 -0
  162. package/publications/super-admin.d.ts +2 -0
  163. package/publications/super-admin.js +21 -0
  164. package/publications/support-tickets.d.ts +1 -0
  165. package/publications/support-tickets.js +200 -0
  166. package/server-app.d.ts +35 -0
  167. package/server-app.js +638 -0
  168. package/support-methods/aws.d.ts +2 -0
  169. package/support-methods/aws.js +276 -0
  170. package/support-methods/collections.d.ts +2 -0
  171. package/support-methods/collections.js +471 -0
  172. package/support-methods/counters.d.ts +2 -0
  173. package/support-methods/counters.js +189 -0
  174. package/support-methods/support.d.ts +2 -0
  175. package/support-methods/support.js +236 -0
  176. package/util/common.d.ts +14 -0
  177. package/util/common.js +341 -0
@@ -0,0 +1,200 @@
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
+ }
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,153 @@
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 ADDED
@@ -0,0 +1,5 @@
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 ADDED
@@ -0,0 +1,160 @@
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;
@@ -0,0 +1 @@
1
+ export declare function loadServerCronJobs(): Promise<void>;
@@ -0,0 +1,90 @@
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;
@@ -0,0 +1 @@
1
+ export declare function loadServerInit(): Promise<void>;
@@ -0,0 +1,67 @@
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 app_version_collection_1 = require("../collections/app-version.collection");
39
+ var logged_in_users_collection_1 = require("../collections/logged-in-users.collection");
40
+ var active_subscription_collection_1 = require("../collections/active-subscription.collection");
41
+ var mongoose_1 = require("mongoose");
42
+ function loadServerInit() {
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ var appVersion;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0: return [4 /*yield*/, app_version_collection_1.AppVersions.findOne()];
48
+ case 1:
49
+ appVersion = _a.sent();
50
+ if (!appVersion) {
51
+ app_version_collection_1.AppVersions.create({
52
+ _id: mongoose_1.Types.ObjectId().toHexString(),
53
+ version: 1
54
+ });
55
+ }
56
+ return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.deleteMany({}).exec()];
57
+ case 2:
58
+ _a.sent();
59
+ return [4 /*yield*/, active_subscription_collection_1.ActiveSubscriptions.deleteMany({}).exec()];
60
+ case 3:
61
+ _a.sent();
62
+ return [2 /*return*/];
63
+ }
64
+ });
65
+ });
66
+ }
67
+ exports.loadServerInit = loadServerInit;
package/http/auth.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import ResolveIOMainServer from '../server-app';
2
+ export declare function setupAuthRoutes(mainServer: ResolveIOMainServer, app: any, serverConfig: any): void;