@resolveio/server-lib 6.4.23-newrole → 7.0.0

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 (73) hide show
  1. package/collections/counter.collection.d.ts +0 -2
  2. package/collections/counter.collection.js +0 -14
  3. package/collections/counter.collection.js.map +1 -1
  4. package/collections/file.collection.d.ts +0 -2
  5. package/collections/file.collection.js +0 -14
  6. package/collections/file.collection.js.map +1 -1
  7. package/collections/user.collection.d.ts +0 -1
  8. package/collections/user.collection.js +32 -43
  9. package/collections/user.collection.js.map +1 -1
  10. package/fixtures/cron-jobs.js +0 -17
  11. package/fixtures/cron-jobs.js.map +1 -1
  12. package/http/auth.js +173 -20
  13. package/http/auth.js.map +1 -1
  14. package/http/home.js +37 -0
  15. package/http/home.js.map +1 -1
  16. package/index.d.ts +1 -4
  17. package/index.js +22 -71
  18. package/index.js.map +1 -1
  19. package/managers/method.manager.d.ts +0 -1
  20. package/managers/method.manager.js +2 -28
  21. package/managers/method.manager.js.map +1 -1
  22. package/managers/subscription.manager.d.ts +0 -3
  23. package/managers/subscription.manager.js +19 -142
  24. package/managers/subscription.manager.js.map +1 -1
  25. package/methods/accounts.js.map +1 -1
  26. package/methods/cron-jobs.js +0 -68
  27. package/methods/cron-jobs.js.map +1 -1
  28. package/methods/support.d.ts +2 -0
  29. package/methods/support.js +439 -0
  30. package/methods/support.js.map +1 -0
  31. package/models/user.model.d.ts +14 -25
  32. package/models/user.model.js.map +1 -1
  33. package/package.json +1 -1
  34. package/publications/files.js +0 -31
  35. package/publications/files.js.map +1 -1
  36. package/publications/report-builder-libraries.js +3 -2
  37. package/publications/report-builder-libraries.js.map +1 -1
  38. package/server-app.d.ts +0 -4
  39. package/server-app.js +11 -71
  40. package/server-app.js.map +1 -1
  41. package/client-server-app.d.ts +0 -1
  42. package/client-server-app.js +0 -48
  43. package/client-server-app.js.map +0 -1
  44. package/collections/billing-logged-in-users.collection.d.ts +0 -7
  45. package/collections/billing-logged-in-users.collection.js +0 -75
  46. package/collections/billing-logged-in-users.collection.js.map +0 -1
  47. package/collections/support-ticket.collection.d.ts +0 -7
  48. package/collections/support-ticket.collection.js +0 -226
  49. package/collections/support-ticket.collection.js.map +0 -1
  50. package/managers/support.manager.d.ts +0 -22
  51. package/managers/support.manager.js +0 -329
  52. package/managers/support.manager.js.map +0 -1
  53. package/models/support-method.model.d.ts +0 -9
  54. package/models/support-method.model.js +0 -4
  55. package/models/support-method.model.js.map +0 -1
  56. package/publications/billing-logged-in-users.d.ts +0 -1
  57. package/publications/billing-logged-in-users.js +0 -65
  58. package/publications/billing-logged-in-users.js.map +0 -1
  59. package/publications/support-tickets.d.ts +0 -1
  60. package/publications/support-tickets.js +0 -203
  61. package/publications/support-tickets.js.map +0 -1
  62. package/support-methods/aws.d.ts +0 -2
  63. package/support-methods/aws.js +0 -279
  64. package/support-methods/aws.js.map +0 -1
  65. package/support-methods/collections.d.ts +0 -2
  66. package/support-methods/collections.js +0 -475
  67. package/support-methods/collections.js.map +0 -1
  68. package/support-methods/counters.d.ts +0 -2
  69. package/support-methods/counters.js +0 -192
  70. package/support-methods/counters.js.map +0 -1
  71. package/support-methods/support.d.ts +0 -2
  72. package/support-methods/support.js +0 -282
  73. package/support-methods/support.js.map +0 -1
@@ -1,226 +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
- users_assigned: {
128
- type: Array
129
- },
130
- 'users_assigned.$': {
131
- type: Object
132
- },
133
- 'users_assigned.$.id_user': {
134
- type: String
135
- },
136
- 'users_assigned.$.user': {
137
- type: String
138
- },
139
- 'users_assigned.$.date_created': {
140
- type: Date
141
- },
142
- estimated_billable_hours: {
143
- type: Number,
144
- optional: true
145
- },
146
- billable_hours: {
147
- type: Number,
148
- optional: true
149
- },
150
- bill_description: {
151
- type: String
152
- },
153
- tasks: {
154
- type: Array
155
- },
156
- 'tasks.$': {
157
- type: Object
158
- },
159
- 'tasks.$.description': {
160
- type: String
161
- },
162
- 'tasks.$.completed': {
163
- type: Boolean
164
- },
165
- 'tasks.$.id_user': {
166
- type: String,
167
- },
168
- 'tasks.$.user': {
169
- type: String,
170
- },
171
- 'tasks.$.date_created': {
172
- type: Date
173
- },
174
- 'tasks.$.date_completed': {
175
- type: Date,
176
- optional: true
177
- },
178
- notes: {
179
- type: Array
180
- },
181
- 'notes.$': {
182
- type: Object
183
- },
184
- 'notes.$.description': {
185
- type: String
186
- },
187
- 'notes.$.id_user': {
188
- type: String,
189
- },
190
- 'notes.$.user': {
191
- type: String,
192
- },
193
- 'notes.$.date_created': {
194
- type: Date
195
- },
196
- difficulty: {
197
- type: Number
198
- }
199
- };
200
- var DefaultSchema = new mongoose_1.Schema(schema, {
201
- skipVersioning: true,
202
- versionKey: false,
203
- timestamps: true
204
- });
205
- exports.SupportTickets = null;
206
- if (index_1.ResolveIOServer.getSupportDB()) {
207
- exports.SupportTickets = index_1.ResolveIOServer.getSupportDB().model('support-tickets', DefaultSchema);
208
- exports.SupportTickets['simplschema'] = new simpl_schema_1.default(schema);
209
- }
210
- schema._id = {
211
- type: mongoose_1.Schema.Types.Mixed
212
- };
213
- var VersionSchema = new mongoose_1.Schema(schema, {
214
- skipVersioning: true,
215
- versionKey: false,
216
- timestamps: true
217
- });
218
- if (index_1.ResolveIOServer.getSupportDB()) {
219
- exports.SupportTickets['versionCollection'] = 'support-tickets.versions';
220
- }
221
- exports.SupportTicketVersions = null;
222
- if (index_1.ResolveIOServer.getSupportDB()) {
223
- exports.SupportTicketVersions = index_1.ResolveIOServer.getSupportDB().model(exports.SupportTickets['versionCollection'], VersionSchema);
224
- }
225
-
226
- //# sourceMappingURL=support-ticket.collection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/collections/support-ticket.collection.ts"],"names":[],"mappings":";;AAAA,qCAAmD;AACnD,6CAAwC;AACxC,kCAA2C;AAG3C,IAAI,MAAM,GAAQ;IACjB,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ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;CAChB,CAAC,CAAC;AAEH,IAAI,uBAAe,CAAC,YAAY,EAAE,EAAE;IACnC,sBAAc,CAAC,mBAAmB,CAAC,GAAG,0BAA0B,CAAC;CACjE;AAEU,QAAA,qBAAqB,GAA0B,IAAI,CAAC;AAE/D,IAAI,uBAAe,CAAC,YAAY,EAAE,EAAE;IACnC,6BAAqB,GAAG,uBAAe,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,sBAAc,CAAC,mBAAmB,CAAC,EAAE,aAAa,CAAC,CAAC;CACjH","file":"support-ticket.collection.js","sourcesContent":["import { Schema, Model, Document } from 'mongoose';\nimport SimpleSchema from 'simpl-schema';\nimport { ResolveIOServer } from '../index';\nimport { SupportTicketModel } from '../models/support-ticket.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\ttype: {\n\t\ttype: String\n\t},\n\tpriority: {\n\t\ttype: String\n\t},\n\tissue: {\n\t\ttype: String\n\t},\n\tsupport_ticket_number: {\n\t\ttype: Number\n\t},\n\tsupport_ticket_number_string: {\n\t\ttype: String\n\t},\n\tstatus: {\n\t\ttype: String\n\t},\n\tsubstatus: {\n\t\ttype: String\n\t},\n\tclient: {\n\t\ttype: String\n\t},\n\tid_client: {\n\t\ttype: String\n\t},\n\tmessages: {\n\t\ttype: Array\n\t},\n\t'messages.$': {\n\t\ttype: Object\n\t},\n\t'messages.$.message': {\n\t\ttype: String\n\t},\n\t'messages.$.id_user': {\n\t\ttype: String\n\t},\n\t'messages.$.user': {\n\t\ttype: String\n\t},\n\t'messages.$.date': {\n\t\ttype: Date\n\t},\n\t'messages.$.type': {\n\t\ttype: String\n\t},\n\tdate_created: {\n\t\ttype: Date\n\t},\n\tdate_created_string: {\n\t\ttype: String\n\t},\n\tid_user_created: {\n\t\ttype: String\n\t},\n\tuser_created: {\n\t\ttype: String\n\t},\n\tbillable: {\n\t\ttype: Boolean\n\t},\n\tdate_investigation: {\n\t\ttype: Date,\n\t\toptional: true,\n\t},\n\tdate_closed: {\n\t\ttype: Date,\n\t\toptional: true,\n\t},\n\tfiles: {\n\t\ttype: Array\n\t},\n\t'files.$': {\n\t\ttype: String\n\t},\n\tcurrent_watchers: {\n\t\ttype: Array\n\t},\n\t'current_watchers.$': {\n\t\ttype: Object\n\t},\t\n\t'current_watchers.$.user': {\n\t\ttype: String\n\t},\t\n\t'current_watchers.$.id_user': {\n\t\ttype: String\n\t},\t\n\t'current_watchers.$.email': {\n\t\ttype: String\n\t},\n\tclient_user: {\n\t\ttype: Object\n\t},\n\t'client_user.id_user': {\n\t\ttype: String\n\t},\n\t'client_user.user': {\n\t\ttype: String\n\t},\n\t'client_user.email': {\n\t\ttype: String\n\t},\n\tusers_assigned: {\n\t\ttype: Array\n\t},\n\t'users_assigned.$': {\n\t\ttype: Object\n\t},\n\t'users_assigned.$.id_user': {\n\t\ttype: String\n\t},\n\t'users_assigned.$.user': {\n\t\ttype: String\n\t},\t\n\t'users_assigned.$.date_created': {\n\t\ttype: Date\n\t},\n\testimated_billable_hours: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tbillable_hours: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tbill_description: {\n\t\ttype: String\n\t},\n\ttasks: {\n\t\ttype: Array\n\t},\n\t'tasks.$': {\n\t\ttype: Object\n\t},\n\t'tasks.$.description': {\n\t\ttype: String\n\t},\n\t'tasks.$.completed': {\n\t\ttype: Boolean\n\t},\t\n\t'tasks.$.id_user': {\n\t\ttype: String,\n\t},\t\n\t'tasks.$.user': {\n\t\ttype: String,\n\t},\t\n\t'tasks.$.date_created': {\n\t\ttype: Date\n\t},\t\n\t'tasks.$.date_completed': {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tnotes: {\n\t\ttype: Array\n\t},\n\t'notes.$': {\n\t\ttype: Object\n\t},\n\t'notes.$.description': {\n\t\ttype: String\n\t},\n\t'notes.$.id_user': {\n\t\ttype: String,\n\t},\t\n\t'notes.$.user': {\n\t\ttype: String,\n\t},\n\t'notes.$.date_created': {\n\t\ttype: Date\n\t},\n\tdifficulty: {\n\t\ttype: Number\n\t}\n};\n\nconst DefaultSchema = new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\ninterface ResolveIOModel extends SupportTicketModel, Document {}\n\nexport let SupportTickets: Model<ResolveIOModel> = null;\n\nif (ResolveIOServer.getSupportDB()) {\n\tSupportTickets = ResolveIOServer.getSupportDB().model('support-tickets', DefaultSchema);\n\tSupportTickets['simplschema'] = new SimpleSchema(schema);\n}\n\nschema._id = {\n\ttype: Schema.Types.Mixed\n};\n\nlet VersionSchema = new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\nif (ResolveIOServer.getSupportDB()) {\n\tSupportTickets['versionCollection'] = 'support-tickets.versions';\n}\n\nexport let SupportTicketVersions: Model<ResolveIOModel> = null;\n\nif (ResolveIOServer.getSupportDB()) {\n\tSupportTicketVersions = ResolveIOServer.getSupportDB().model(SupportTickets['versionCollection'], VersionSchema);\n}"]}
@@ -1,22 +0,0 @@
1
- import { SupportMethodModel } from '../models/support-method.model';
2
- import ResolveIOMainServer from '../server-app';
3
- export declare class SupportManager {
4
- private _mainServer;
5
- _supportMethods: SupportMethodModel;
6
- private _mailer;
7
- private _aws;
8
- private serverConfig;
9
- private clientDir;
10
- private _sendQueue;
11
- private _runningQueue;
12
- constructor(mainServer: any, serverConfig: any, clientDir: any);
13
- getMainServer(): ResolveIOMainServer;
14
- supportMethods(supportMethod: SupportMethodModel): void;
15
- callSupportMethod(ws: WebSocket, messageId: any, supportMethod: any, ...methodData: any[]): void;
16
- callSupportMethodInternal(supportMethod: any, ...methodData: any[]): Promise<any>;
17
- callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
18
- private sendWS;
19
- sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], from?: string): void;
20
- readFile(fileName: any): Promise<unknown>;
21
- readImage(fileName: any): Promise<unknown>;
22
- }
@@ -1,329 +0,0 @@
1
- "use strict";
2
- var __spreadArrays = (this && this.__spreadArrays) || function () {
3
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
- r[k] = a[j];
7
- return r;
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- var nodemailer = require("nodemailer");
11
- var aws = require("aws-sdk");
12
- var collections_1 = require("../support-methods/collections");
13
- var support_1 = require("../support-methods/support");
14
- var counters_1 = require("../support-methods/counters");
15
- var mongoose_1 = require("mongoose");
16
- var common_1 = require("../util/common");
17
- var log_collection_1 = require("../collections/log.collection");
18
- var method_manager_1 = require("./method.manager");
19
- var path = require("path");
20
- var fs = require("fs");
21
- var SupportManager = /** @class */ (function () {
22
- function SupportManager(mainServer, serverConfig, clientDir) {
23
- var _this = this;
24
- this._supportMethods = {};
25
- this._sendQueue = [];
26
- this._runningQueue = false;
27
- this._mainServer = mainServer;
28
- this.serverConfig = serverConfig;
29
- this.clientDir = clientDir;
30
- collections_1.loadSupportCollectionMethods(this);
31
- support_1.loadSupportMethods(this);
32
- counters_1.loadCounterMethods(this);
33
- this._mailer = nodemailer.createTransport({
34
- SES: new aws.SES({
35
- apiVersion: '2010-12-01',
36
- accessKeyId: serverConfig.AWSACCESSKEYID,
37
- secretAccessKey: serverConfig.AWSSECRETACCESSKEY,
38
- region: serverConfig.AWSSES_REGION
39
- })
40
- });
41
- this._aws = new aws.S3({
42
- accessKeyId: serverConfig.AWSACCESSKEYID,
43
- secretAccessKey: serverConfig.AWSSECRETACCESSKEY,
44
- region: serverConfig.AWSREGION
45
- });
46
- setInterval(function () {
47
- if (!_this._runningQueue) {
48
- if (_this._sendQueue.length) {
49
- _this._runningQueue = true;
50
- var _loop_1 = function (i) {
51
- var ws = _this._mainServer.getWS(_this._sendQueue[i].id_ws);
52
- if (ws && ws.readyState === ws.OPEN) {
53
- if (ws.bufferedAmount < 20480) {
54
- var sendItem = _this._sendQueue.pop();
55
- ws.send(JSON.stringify(sendItem.data), function (error) {
56
- if (error) {
57
- console.log('Error on WS: ', error);
58
- _this._mainServer.unsubscribeWS(ws);
59
- }
60
- });
61
- // if (sendItem.method !== 'countQuery' && sendItem.method !== 'countCollectionWithQuery' && sendItem.method !== 'find' && sendItem.method !== 'findOne' && sendItem.method !== 'findWithOptions' && sendItem.method !== 'setWSAppVersion' && sendItem.method !== 'uploadFileAndSave') {
62
- if (common_1.getBinarySize(JSON.stringify(sendItem.methodData)) < 200000 && common_1.getBinarySize(JSON.stringify(sendItem.data)) < 200000) {
63
- log_collection_1.Logs.create({
64
- _id: mongoose_1.Types.ObjectId().toHexString(),
65
- date: new Date(),
66
- type: 'client-response',
67
- title: 'Client Response - Support',
68
- message: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Support Method: ' + sendItem.method,
69
- payload: JSON.stringify([sendItem.methodData, sendItem.data], null, 2),
70
- method: sendItem.method,
71
- user: ws['user'],
72
- messageId: sendItem.data.messageId
73
- });
74
- }
75
- else {
76
- log_collection_1.Logs.create({
77
- _id: mongoose_1.Types.ObjectId().toHexString(),
78
- date: new Date(),
79
- type: 'client-response',
80
- title: 'Client Response - Support',
81
- message: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Support Method: ' + sendItem.method,
82
- payload: 'Too Big',
83
- method: sendItem.method,
84
- user: ws['user'],
85
- messageId: sendItem.data.messageId
86
- });
87
- }
88
- // }
89
- }
90
- }
91
- else {
92
- _this._sendQueue.splice(i, 1);
93
- }
94
- };
95
- for (var i = _this._sendQueue.length - 1; i >= 0; i--) {
96
- _loop_1(i);
97
- }
98
- _this._runningQueue = false;
99
- }
100
- }
101
- }, 25);
102
- }
103
- SupportManager.prototype.getMainServer = function () {
104
- return this._mainServer;
105
- };
106
- // Add methods to private methods object
107
- SupportManager.prototype.supportMethods = function (supportMethod) {
108
- this._supportMethods = Object.assign(this._supportMethods, supportMethod);
109
- };
110
- // Call/run method (Emit on Socket)
111
- SupportManager.prototype.callSupportMethod = function (ws, messageId, supportMethod) {
112
- var _a;
113
- var _this = this;
114
- var methodData = [];
115
- for (var _i = 3; _i < arguments.length; _i++) {
116
- methodData[_i - 3] = arguments[_i];
117
- }
118
- var that = this;
119
- if (!that._supportMethods[supportMethod]) {
120
- console.log('No Support Method: ' + supportMethod);
121
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Support Method: ' + supportMethod);
122
- var serverRes = {
123
- messageId: messageId,
124
- hasError: true,
125
- data: 'Internal Error'
126
- };
127
- this.sendWS(ws, supportMethod, methodData, serverRes);
128
- return;
129
- }
130
- if ((methodData.length > 1 || methodData[0])) {
131
- if (!that._supportMethods[supportMethod].check) {
132
- console.error('No Check Function For Support Method ' + supportMethod);
133
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Support Method ' + supportMethod);
134
- var serverRes = {
135
- messageId: messageId,
136
- hasError: true,
137
- data: 'Internal Error'
138
- };
139
- this.sendWS(ws, supportMethod, methodData, serverRes);
140
- return;
141
- }
142
- else if (!that._supportMethods[supportMethod].check._schema) {
143
- console.error('No Check Schema For Method ' + supportMethod);
144
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Support Method ' + supportMethod);
145
- var serverRes = {
146
- messageId: messageId,
147
- hasError: true,
148
- data: 'Internal Error'
149
- };
150
- this.sendWS(ws, supportMethod, methodData, serverRes);
151
- return;
152
- }
153
- else {
154
- var valObj = {};
155
- var valKeys = Object.keys(that._supportMethods[supportMethod].check._schema);
156
- var rootKeys = valKeys.filter(function (a) { return !a.includes('.'); });
157
- for (var i = 0; i < methodData.length; i++) {
158
- valObj[rootKeys[i]] = methodData[i];
159
- }
160
- try {
161
- that._supportMethods[supportMethod].check.validate(valObj);
162
- }
163
- catch (errors) {
164
- if (errors) {
165
- console.error('Error in Support Method Check (' + supportMethod + ')', errors);
166
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Match Error On Support Method ' + supportMethod + '\n\nData Being Checked\n' + JSON.stringify(valObj, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
167
- var serverRes = {
168
- messageId: messageId,
169
- hasError: true,
170
- data: 'Internal Error'
171
- };
172
- this.sendWS(ws, supportMethod, methodData, serverRes);
173
- return;
174
- }
175
- }
176
- }
177
- }
178
- (_a = that._supportMethods[supportMethod].function).call.apply(_a, __spreadArrays([Object.assign({}, that, SupportManager.prototype, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] })], methodData)).then(function (res) {
179
- var serverRes = {
180
- messageId: messageId,
181
- hasError: false,
182
- data: res
183
- };
184
- _this.sendWS(ws, supportMethod, methodData, serverRes);
185
- }, function (err) {
186
- var serverRes = {
187
- messageId: messageId,
188
- hasError: true,
189
- data: err
190
- };
191
- _this.sendWS(ws, supportMethod, methodData, serverRes);
192
- });
193
- };
194
- SupportManager.prototype.callSupportMethodInternal = function (supportMethod) {
195
- var _a;
196
- var methodData = [];
197
- for (var _i = 1; _i < arguments.length; _i++) {
198
- methodData[_i - 1] = arguments[_i];
199
- }
200
- var that = this;
201
- if (!that._supportMethods[supportMethod]) {
202
- console.log('No Support Method: ' + supportMethod);
203
- return;
204
- }
205
- if ((methodData.length > 1 || (methodData[0] && typeof (methodData[0]) !== 'function')) && !that._supportMethods[supportMethod].skipValidation) {
206
- if (!that._supportMethods[supportMethod].check) {
207
- console.error('No Check Function For Method ' + supportMethod);
208
- return;
209
- }
210
- else if (!that._supportMethods[supportMethod].check._schema) {
211
- console.error('No Check Schema For Method ' + supportMethod);
212
- return;
213
- }
214
- }
215
- var promise = (_a = that._supportMethods[supportMethod].function).call.apply(_a, __spreadArrays([Object.assign({}, that, SupportManager.prototype)], methodData));
216
- if (methodData[methodData.length - 1] && typeof (methodData[methodData.length - 1]) === 'function') {
217
- promise.then(function (res) { return methodData[methodData.length - 1](null, res); }, function (err) { return methodData[methodData.length - 1](err, null); });
218
- }
219
- return promise;
220
- };
221
- SupportManager.prototype.callMethodInternal = function (method) {
222
- var _a;
223
- var methodData = [];
224
- for (var _i = 1; _i < arguments.length; _i++) {
225
- methodData[_i - 1] = arguments[_i];
226
- }
227
- var that = this;
228
- if (!that._mainServer.getMethodManager()._methods[method]) {
229
- console.log('No Method: ' + method);
230
- return;
231
- }
232
- if ((methodData.length > 1 || (methodData[0] && typeof (methodData[0]) !== 'function')) && !that._mainServer.getMethodManager()._methods[method].skipValidation) {
233
- if (!that._mainServer.getMethodManager()._methods[method].check) {
234
- console.error('No Check Function For Method ' + method);
235
- return;
236
- }
237
- else if (!that._mainServer.getMethodManager()._methods[method].check._schema) {
238
- console.error('No Check Schema For Method ' + method);
239
- return;
240
- }
241
- }
242
- var promise = (_a = that._mainServer.getMethodManager()._methods[method].function).call.apply(_a, __spreadArrays([Object.assign({}, that, method_manager_1.MethodManager.prototype)], methodData));
243
- if (methodData[methodData.length - 1] && typeof (methodData[methodData.length - 1]) === 'function') {
244
- promise.then(function (res) { return methodData[methodData.length - 1](null, res); }, function (err) { return methodData[methodData.length - 1](err, null); });
245
- }
246
- return promise;
247
- };
248
- SupportManager.prototype.sendWS = function (ws, method, methodData, data) {
249
- this._sendQueue.splice(0, 0, {
250
- id_ws: ws['id_socket'],
251
- method: method,
252
- methodData: methodData,
253
- data: data
254
- });
255
- };
256
- SupportManager.prototype.sendEmail = function (sendTo, subject, text, html, attachments, from) {
257
- this._mailer.sendMail({
258
- replyTo: undefined,
259
- from: from ? from : this.serverConfig.MAIL_FROM,
260
- to: sendTo,
261
- subject: subject,
262
- text: text,
263
- html: html,
264
- attachments: attachments
265
- }, function (err, info) {
266
- if (err) {
267
- console.log(err);
268
- }
269
- });
270
- };
271
- SupportManager.prototype.readFile = function (fileName) {
272
- var _this = this;
273
- return new Promise(function (resolve, reject) {
274
- if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
275
- fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', function (err, res) {
276
- if (err) {
277
- reject(err);
278
- }
279
- else {
280
- resolve(res);
281
- }
282
- });
283
- }
284
- else {
285
- if (fs.existsSync(path.join(_this.clientDir, ('./private/' + fileName)))) {
286
- fs.readFile(path.join(_this.clientDir, ('./private/' + fileName)), 'utf-8', function (err, res) {
287
- if (err) {
288
- reject(err);
289
- }
290
- else {
291
- resolve(res);
292
- }
293
- });
294
- }
295
- }
296
- });
297
- };
298
- SupportManager.prototype.readImage = function (fileName) {
299
- var _this = this;
300
- return new Promise(function (resolve, reject) {
301
- if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
302
- fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', function (err, res) {
303
- if (err) {
304
- reject(err);
305
- }
306
- else {
307
- resolve(res);
308
- }
309
- });
310
- }
311
- else {
312
- if (fs.existsSync(path.join(_this.clientDir, ('./private/' + fileName)))) {
313
- fs.readFile(path.join(_this.clientDir, ('./private/' + fileName)), 'base64', function (err, res) {
314
- if (err) {
315
- reject(err);
316
- }
317
- else {
318
- resolve(res);
319
- }
320
- });
321
- }
322
- }
323
- });
324
- };
325
- return SupportManager;
326
- }());
327
- exports.SupportManager = SupportManager;
328
-
329
- //# sourceMappingURL=support.manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/managers/support.manager.ts"],"names":[],"mappings":";;;;;;;;;AACA,uCAAyC;AACzC,6BAA+B;AAE/B,8DAA8E;AAC9E,sDAAgE;AAChE,wDAAiE;AAEjE,qCAAiC;AACjC,yCAA+C;AAC/C,gEAAqD;A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ent":["import { ServerResponseModel } from '../models/server-response.model';\nimport * as nodemailer from 'nodemailer';\nimport * as aws from 'aws-sdk';\nimport { SupportMethodModel } from '../models/support-method.model';\nimport { loadSupportCollectionMethods } from '../support-methods/collections';\nimport { loadSupportMethods } from '../support-methods/support';\nimport { loadCounterMethods } from '../support-methods/counters';\n\nimport { Types } from 'mongoose';\nimport { getBinarySize } from '../util/common';\nimport { Logs } from '../collections/log.collection';\nimport ResolveIOMainServer from '../server-app';\nimport { MethodManager } from './method.manager';\n\nimport * as path from 'path';\nimport * as fs from 'fs';\n\n\nexport class SupportManager {\n\n\tprivate _mainServer: ResolveIOMainServer;\n\tpublic _supportMethods: SupportMethodModel = {};\n\tprivate _mailer: nodemailer.Transporter;\n\tprivate _aws: aws.S3;\n\tprivate serverConfig;\n\tprivate clientDir;\n\n\tprivate _sendQueue = [];\n\tprivate _runningQueue = false;\n\n\tconstructor(mainServer, serverConfig, clientDir) {\n\t\tthis._mainServer = mainServer;\n\t\tthis.serverConfig = serverConfig;\n\t\tthis.clientDir = clientDir;\n\n\t\tloadSupportCollectionMethods(this);\n\t\tloadSupportMethods(this);\n\t\tloadCounterMethods(this);\n\n\t\tthis._mailer = nodemailer.createTransport({\n\t\t\tSES: new aws.SES({\n\t\t\t\tapiVersion: '2010-12-01',\n\t\t\t\taccessKeyId: serverConfig.AWSACCESSKEYID,\n\t\t\t\tsecretAccessKey: serverConfig.AWSSECRETACCESSKEY,\n\t\t\t\tregion: serverConfig.AWSSES_REGION\n\t\t\t})\n\t\t});\n\n\t\tthis._aws = new aws.S3({\n\t\t\taccessKeyId: serverConfig.AWSACCESSKEYID,\n\t\t\tsecretAccessKey: serverConfig.AWSSECRETACCESSKEY,\n\t\t\tregion: serverConfig.AWSREGION\n\t\t});\n\n\t\tsetInterval(() => {\n\t\t\tif (!this._runningQueue) {\n\t\t\t\tif (this._sendQueue.length) {\n\t\t\t\t\tthis._runningQueue = true;\n\t\t\t\t\tfor (let i = this._sendQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tlet ws = this._mainServer.getWS(this._sendQueue[i].id_ws);\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tif (ws.bufferedAmount < 20480) {\n\t\t\t\t\t\t\t\tlet sendItem = this._sendQueue.pop();\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(sendItem.data), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\tthis._mainServer.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t// if (sendItem.method !== 'countQuery' && sendItem.method !== 'countCollectionWithQuery' && sendItem.method !== 'find' && sendItem.method !== 'findOne' && sendItem.method !== 'findWithOptions' && sendItem.method !== 'setWSAppVersion' && sendItem.method !== 'uploadFileAndSave') {\n\t\t\t\t\t\t\t\t\tif (getBinarySize(JSON.stringify(sendItem.methodData)) < 200000 && getBinarySize(JSON.stringify(sendItem.data)) < 200000) {\n\t\t\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\t\t\ttype: 'client-response',\n\t\t\t\t\t\t\t\t\t\t\ttitle: 'Client Response - Support',\n\t\t\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Support Method: ' + sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tpayload: JSON.stringify([sendItem.methodData, sendItem.data], null, 2),\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\t\t\tmessageId: sendItem.data.messageId\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\t\t\ttype: 'client-response',\n\t\t\t\t\t\t\t\t\t\t\ttitle: 'Client Response - Support',\n\t\t\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Support Method: ' + sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\t\t\tmessageId: sendItem.data.messageId\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._sendQueue.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._runningQueue = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}, 25);\n\t}\n\n\tpublic getMainServer() {\n\t\treturn this._mainServer;\n\t}\n\n\t// Add methods to private methods object\n\tpublic supportMethods(supportMethod: SupportMethodModel) {\n\t\tthis._supportMethods = Object.assign(this._supportMethods, supportMethod);\n\t}\n\n\t// Call/run method (Emit on Socket)\n\tpublic callSupportMethod(ws: WebSocket, messageId, supportMethod, ...methodData: any[]) {\n\t\tlet that = this;\n\n\t\tif (!that._supportMethods[supportMethod]) {\n\t\t\tconsole.log('No Support Method: ' + supportMethod);\n\n\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Support Method: ' + supportMethod);\n\t\t\t\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: 'Internal Error'\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, supportMethod, methodData, serverRes);\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || methodData[0])) {\n\t\t\tif (!that._supportMethods[supportMethod].check) {\n\t\t\t\tconsole.error('No Check Function For Support Method ' + supportMethod);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Support Method ' + supportMethod);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\t\n\t\t\t\tthis.sendWS(ws, supportMethod, methodData, serverRes);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._supportMethods[supportMethod].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + supportMethod);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Support Method ' + supportMethod);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\t\n\t\t\t\tthis.sendWS(ws, supportMethod, methodData, serverRes);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet valObj = {};\n\t\t\t\tlet valKeys = Object.keys(that._supportMethods[supportMethod].check._schema);\n\n\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\n\t\t\t\tfor (let i = 0; i < methodData.length; i++) {\n\t\t\t\t\tvalObj[rootKeys[i]] = methodData[i];\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tthat._supportMethods[supportMethod].check.validate(valObj);\n\t\t\t\t}\n\t\t\t\tcatch (errors) {\n\t\t\t\t\tif (errors) {\n\t\t\t\t\t\tconsole.error('Error in Support Method Check (' + supportMethod + ')', errors);\n\n\t\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Match Error On Support Method ' + supportMethod + '\\n\\nData Being Checked\\n' + JSON.stringify(valObj, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\t\t\t\t\t\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t\t};\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.sendWS(ws, supportMethod, methodData, serverRes);\n\t\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tthat._supportMethods[supportMethod].function.call(Object.assign({}, that, SupportManager.prototype, {id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket']}), ...methodData).then(res => {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: false,\n\t\t\t\tdata: res\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, supportMethod, methodData, serverRes);\n\t\t}, err => {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: err\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, supportMethod, methodData, serverRes);\n\t\t});\n\t}\n\n\tpublic callSupportMethodInternal(supportMethod, ...methodData: any[]): Promise<any> {\n\t\tlet that = this;\n\n\t\tif (!that._supportMethods[supportMethod]) {\n\t\t\tconsole.log('No Support Method: ' + supportMethod);\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || (methodData[0] && typeof(methodData[0]) !== 'function')) && !that._supportMethods[supportMethod].skipValidation) {\n\t\t\tif (!that._supportMethods[supportMethod].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + supportMethod);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._supportMethods[supportMethod].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + supportMethod);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tlet promise = that._supportMethods[supportMethod].function.call(Object.assign({}, that, SupportManager.prototype), ...methodData);\n\n\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\tpromise.then(res => methodData[methodData.length - 1](null, res), err => methodData[methodData.length - 1](err, null));\n\t\t}\n\n\t\treturn promise;\n\t}\n\n\tpublic callMethodInternal(method, ...methodData: any[]): Promise<any> {\n\t\tlet that = this;\n\n\t\tif (!that._mainServer.getMethodManager()._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || (methodData[0] && typeof(methodData[0]) !== 'function')) && !that._mainServer.getMethodManager()._methods[method].skipValidation) {\n\t\t\tif (!that._mainServer.getMethodManager()._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._mainServer.getMethodManager()._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tlet promise = that._mainServer.getMethodManager()._methods[method].function.call(Object.assign({}, that, MethodManager.prototype), ...methodData);\n\n\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\tpromise.then(res => methodData[methodData.length - 1](null, res), err => methodData[methodData.length - 1](err, null));\n\t\t}\n\n\t\treturn promise;\n\t}\n\n\tprivate sendWS(ws: WebSocket, method: string, methodData: any[], data: ServerResponseModel) {\n\t\tthis._sendQueue.splice(0, 0, {\n\t\t\tid_ws: ws['id_socket'],\n\t\t\tmethod: method,\n\t\t\tmethodData: methodData,\n\t\t\tdata: data\n\t\t});\n\t}\n\n\tpublic sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], from?: string) {\n\t\tthis._mailer.sendMail({\n\t\t\treplyTo: undefined,\n\t\t\tfrom: from ? from : this.serverConfig.MAIL_FROM,\n\t\t\tto: sendTo,\n\t\t\tsubject: subject,\n\t\t\ttext: text,\n\t\t\thtml: html,\n\t\t\tattachments: attachments\n\t\t}, (err, info) => {\n\t\t\tif (err) {\n\t\t\t\tconsole.log(err);\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic readFile(fileName) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\t\tfs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', (err, res) => { \n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {\n\t\t\t\t\tfs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'utf-8', (err, res) => { \n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic readImage(fileName) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\t\tfs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', (err, res) => { \n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {\n\t\t\t\t\tfs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'base64', (err, res) => { \n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}"]}
@@ -1,9 +0,0 @@
1
- import SimpleSchema from 'simpl-schema';
2
- export interface SupportMethodModel {
3
- [key: string]: SupportMethodAllModel;
4
- }
5
- export interface SupportMethodAllModel {
6
- check?: SimpleSchema;
7
- function: (...parameters: any[]) => Promise<any | any[]>;
8
- skipValidation?: boolean;
9
- }
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
-
4
- //# sourceMappingURL=support-method.model.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/models/support-method.model.ts"],"names":[],"mappings":"","file":"support-method.model.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\n\nexport interface SupportMethodModel {\n\t[key: string]: SupportMethodAllModel;\n}\n\nexport interface SupportMethodAllModel {\n\tcheck?: SimpleSchema;\n\tfunction: (...parameters: any[]) => Promise<any | any[]>;\n\tskipValidation?: boolean;\n}"]}