@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,276 @@
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 file_collection_1 = require("../collections/file.collection");
39
+ var mongoose_1 = require("mongoose");
40
+ var simpl_schema_1 = require("simpl-schema");
41
+ var pdfCnt = 1000000;
42
+ function loadAWSMethods(supportManager) {
43
+ supportManager.supportMethods({
44
+ uploadFileAndSave: {
45
+ check: new simpl_schema_1.default({
46
+ fileName: {
47
+ type: String
48
+ },
49
+ fileData: {
50
+ type: String
51
+ },
52
+ fileSize: {
53
+ type: Number
54
+ },
55
+ fileOrder: {
56
+ type: Number
57
+ },
58
+ fileType: {
59
+ type: String
60
+ }
61
+ }),
62
+ function: function (fileName, fileData, fileSize, fileOrder, fileType) {
63
+ var that = this;
64
+ return new Promise(function (resolve, reject) {
65
+ if (fileName) {
66
+ var key_1 = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;
67
+ var newParams = { Bucket: that.serverConfig.AWSBUCKET, Key: key_1, Body: Buffer.from(fileData.replace('data:' + fileData.split(',')[0].split(':')[1].split(';')[0] + ';base64,', ''), 'base64'), ACL: 'private', ContentType: fileData.split(',')[0].split(':')[1].split(';')[0], ContentDisposition: 'inline' };
68
+ that.getAWS().upload(newParams, function (err, res) {
69
+ if (err) {
70
+ reject(err);
71
+ }
72
+ else if (res) {
73
+ file_collection_1.SupportFiles.create({
74
+ _id: mongoose_1.Types.ObjectId().toHexString(), name: fileName, size: fileSize, key: key_1, order: fileOrder, type: fileType
75
+ }).then(function (resFile) {
76
+ resolve(resFile);
77
+ }, function (errFile) { return reject(errFile); });
78
+ }
79
+ });
80
+ }
81
+ });
82
+ }
83
+ },
84
+ deleteFiles: {
85
+ check: new simpl_schema_1.default({
86
+ keys: {
87
+ type: Array
88
+ },
89
+ 'keys.$': {
90
+ type: String
91
+ }
92
+ }),
93
+ function: function (keys) {
94
+ var _this = this;
95
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
96
+ var files, deleteCnt;
97
+ var _this = this;
98
+ return __generator(this, function (_a) {
99
+ switch (_a.label) {
100
+ case 0: return [4 /*yield*/, file_collection_1.SupportFiles.find({ key: { $in: keys } })];
101
+ case 1:
102
+ files = _a.sent();
103
+ deleteCnt = files.length;
104
+ files.forEach(function (file) {
105
+ file_collection_1.SupportFiles.deleteOne({ _id: file._id }).exec();
106
+ var delParams = { Bucket: _this.serverConfig.AWSBUCKET, Key: file.key };
107
+ _this.getAWS().deleteObject(delParams, function (err, res) {
108
+ if (err) {
109
+ reject(err);
110
+ }
111
+ else {
112
+ deleteCnt--;
113
+ if (!deleteCnt) {
114
+ resolve(res);
115
+ }
116
+ }
117
+ });
118
+ });
119
+ return [2 /*return*/];
120
+ }
121
+ });
122
+ }); });
123
+ }
124
+ },
125
+ deleteFile: {
126
+ check: new simpl_schema_1.default({
127
+ key: {
128
+ type: String
129
+ }
130
+ }),
131
+ function: function (key) {
132
+ var _this = this;
133
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
134
+ var file, delParams;
135
+ return __generator(this, function (_a) {
136
+ switch (_a.label) {
137
+ case 0: return [4 /*yield*/, file_collection_1.SupportFiles.findOne({ key: key })];
138
+ case 1:
139
+ file = _a.sent();
140
+ if (!file) {
141
+ reject('Could not find file');
142
+ }
143
+ file_collection_1.SupportFiles.deleteOne({ _id: file._id }).exec();
144
+ delParams = { Bucket: this.serverConfig['AWSBUCKET'], Key: key };
145
+ this.getAWS().deleteObject(delParams, function (err, res) {
146
+ if (err) {
147
+ reject(err);
148
+ }
149
+ else {
150
+ resolve(res);
151
+ }
152
+ });
153
+ return [2 /*return*/];
154
+ }
155
+ });
156
+ }); });
157
+ }
158
+ },
159
+ deleteFileWithId: {
160
+ check: new simpl_schema_1.default({
161
+ id_file: {
162
+ type: String
163
+ }
164
+ }),
165
+ function: function (id_file) {
166
+ var _this = this;
167
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
168
+ var file, delParams;
169
+ return __generator(this, function (_a) {
170
+ switch (_a.label) {
171
+ case 0: return [4 /*yield*/, file_collection_1.SupportFiles.findOne({ _id: id_file })];
172
+ case 1:
173
+ file = _a.sent();
174
+ if (!file) {
175
+ reject('Could not find file');
176
+ }
177
+ delParams = { Bucket: this.serverConfig['AWSBUCKET'], Key: file.key };
178
+ this.getAWS().deleteObject(delParams, function (err, res) {
179
+ if (err) {
180
+ reject(err);
181
+ }
182
+ else {
183
+ resolve(res);
184
+ }
185
+ });
186
+ file_collection_1.SupportFiles.deleteOne({ _id: file._id }).exec();
187
+ return [2 /*return*/];
188
+ }
189
+ });
190
+ }); });
191
+ }
192
+ },
193
+ getSignedUrlWithId: {
194
+ check: new simpl_schema_1.default({
195
+ id_file: {
196
+ type: String
197
+ },
198
+ expires: {
199
+ type: Number
200
+ }
201
+ }),
202
+ function: function (id_file, expires) {
203
+ var _this = this;
204
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
205
+ var file, params;
206
+ return __generator(this, function (_a) {
207
+ switch (_a.label) {
208
+ case 0: return [4 /*yield*/, file_collection_1.SupportFiles.findOne({ _id: id_file })];
209
+ case 1:
210
+ file = _a.sent();
211
+ params = { Bucket: this.serverConfig.AWSBUCKET, Key: file.key, Expires: expires };
212
+ this.getAWS().getSignedUrl('getObject', params, function (err, res) {
213
+ if (err) {
214
+ reject(err);
215
+ }
216
+ else {
217
+ resolve(res);
218
+ }
219
+ });
220
+ return [2 /*return*/];
221
+ }
222
+ });
223
+ }); });
224
+ }
225
+ },
226
+ getSignedUrl: {
227
+ check: new simpl_schema_1.default({
228
+ key: {
229
+ type: String
230
+ },
231
+ expires: {
232
+ type: Number
233
+ }
234
+ }),
235
+ function: function (key, expires) {
236
+ var _this = this;
237
+ return new Promise(function (resolve, reject) {
238
+ var params = { Bucket: _this.serverConfig.AWSBUCKET, Key: key, Expires: expires };
239
+ _this.getAWS().getSignedUrl('getObject', params, function (err, res) {
240
+ if (err) {
241
+ reject(err);
242
+ }
243
+ else {
244
+ resolve(res);
245
+ }
246
+ });
247
+ });
248
+ }
249
+ },
250
+ getSignedUrls: {
251
+ check: new simpl_schema_1.default({
252
+ keys: {
253
+ type: Array
254
+ },
255
+ 'keys.$': {
256
+ type: String
257
+ },
258
+ expires: {
259
+ type: Number
260
+ }
261
+ }),
262
+ function: function (keys, expires) {
263
+ var _this = this;
264
+ return new Promise(function (resolve, reject) {
265
+ var res = [];
266
+ keys.forEach(function (key) {
267
+ var params = { Bucket: _this.serverConfig.AWSBUCKET, Key: key, Expires: expires };
268
+ res.push(_this.getAWS().getSignedUrl('getObject', params));
269
+ });
270
+ resolve(res);
271
+ });
272
+ }
273
+ }
274
+ });
275
+ }
276
+ exports.loadAWSMethods = loadAWSMethods;
@@ -0,0 +1,2 @@
1
+ import { SupportManager } from '../managers/support.manager';
2
+ export declare function loadSupportCollectionMethods(supportManager: SupportManager): void;