@resolveio/server-lib 1.0.0-rc19 → 1.0.0-rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/collections/active-subscription.collection.js +1 -68
- package/collections/app-status.collection.js +1 -43
- package/collections/app-version.collection.js +1 -56
- package/collections/counter.collection.js +1 -73
- package/collections/cron-job-history.collection.js +1 -86
- package/collections/cron-job.collection.js +1 -89
- package/collections/file.collection.js +1 -73
- package/collections/flag.collection.js +1 -47
- package/collections/log.collection.js +1 -64
- package/collections/logged-in-users.collection.js +1 -70
- package/collections/method-call.collection.js +1 -44
- package/collections/method-response.collection.js +1 -48
- package/collections/queue-flag.collection.js +1 -41
- package/collections/queue-method.collection.js +1 -116
- package/collections/queue-response.collection.js +1 -78
- package/collections/support-ticket.collection.js +1 -146
- package/collections/user.collection.js +1 -108
- package/cron/cron.js +1 -160
- package/fixtures/cron-jobs.js +1 -72
- package/fixtures/init.js +1 -73
- package/http/auth.js +1 -472
- package/http/health.js +1 -8
- package/index.js +1 -123
- package/managers/cron.manager.js +1 -193
- package/managers/method.manager.js +1 -513
- package/managers/queue-method.manager.js +1 -239
- package/managers/subscription.manager.js +1 -700
- package/managers/support.manager.js +1 -208
- package/methods/accounts.js +1 -253
- package/methods/aws.js +1 -323
- package/methods/cloudconvert.js +1 -37
- package/methods/collections.js +1 -738
- package/methods/counters.js +1 -404
- package/methods/cron-jobs.js +1 -63
- package/methods/flags.js +1 -6
- package/methods/logs.js +1 -29
- package/methods/pdf.js +1 -303
- package/models/active-subscription.model.js +1 -2
- package/models/app-status.model.js +1 -2
- package/models/app-version.model.js +1 -2
- package/models/collection-document.model.js +1 -2
- package/models/counter.model.js +1 -2
- package/models/cron-job-history.model.js +1 -2
- package/models/cron-job.model.js +1 -2
- package/models/dialog.model.js +1 -2
- package/models/file.model.js +1 -2
- package/models/flag.model.js +1 -2
- package/models/log.model.js +1 -2
- package/models/logged-in-users.model.js +1 -2
- package/models/method-call.model.js +1 -2
- package/models/method-response.model.js +1 -2
- package/models/method.model.js +1 -2
- package/models/pagination.model.js +1 -20
- package/models/permission.model.js +1 -2
- package/models/queue-method.model.js +1 -2
- package/models/queue-response.model.js +1 -2
- package/models/select-data-label.model.js +1 -2
- package/models/server-response.model.js +1 -2
- package/models/subscription.model.js +1 -2
- package/models/support-method.model.js +1 -2
- package/models/support-ticket.model.js +1 -2
- package/models/user.model.js +1 -2
- package/package.json +2 -5
- package/publications/app-status.js +1 -14
- package/publications/app-version.js +1 -14
- package/publications/cron-jobs.js +1 -14
- package/publications/files.js +1 -71
- package/publications/flags.js +1 -23
- package/publications/logs.js +1 -26
- package/publications/method-calls.js +1 -14
- package/publications/method-responses.js +1 -14
- package/publications/super-admin.js +1 -21
- package/publications/support-tickets.js +1 -118
- package/server-app.js +1 -640
- package/support-methods/aws.js +1 -276
- package/support-methods/collections.js +1 -471
- package/support-methods/counters.js +1 -189
- package/support-methods/support.js +1 -19
- package/util/common.js +1 -334
- package/collections/active-subscription.collection.d.ts +0 -8
- package/collections/app-status.collection.d.ts +0 -8
- package/collections/app-version.collection.d.ts +0 -8
- package/collections/counter.collection.d.ts +0 -10
- package/collections/cron-job-history.collection.d.ts +0 -8
- package/collections/cron-job.collection.d.ts +0 -8
- package/collections/file.collection.d.ts +0 -10
- package/collections/flag.collection.d.ts +0 -8
- package/collections/log.collection.d.ts +0 -8
- package/collections/logged-in-users.collection.d.ts +0 -8
- package/collections/method-call.collection.d.ts +0 -7
- package/collections/method-response.collection.d.ts +0 -7
- package/collections/queue-flag.collection.d.ts +0 -8
- package/collections/queue-method.collection.d.ts +0 -8
- package/collections/queue-response.collection.d.ts +0 -8
- package/collections/support-ticket.collection.d.ts +0 -8
- package/collections/user.collection.d.ts +0 -9
- package/cron/cron.d.ts +0 -6
- package/fixtures/cron-jobs.d.ts +0 -2
- package/fixtures/init.d.ts +0 -2
- package/http/auth.d.ts +0 -3
- package/http/health.d.ts +0 -2
- package/index.d.ts +0 -15
- package/managers/cron.manager.d.ts +0 -17
- package/managers/method.manager.d.ts +0 -27
- package/managers/queue-method.manager.d.ts +0 -14
- package/managers/subscription.manager.d.ts +0 -27
- package/managers/support.manager.d.ts +0 -18
- package/methods/accounts.d.ts +0 -3
- package/methods/aws.d.ts +0 -3
- package/methods/cloudconvert.d.ts +0 -3
- package/methods/collections.d.ts +0 -3
- package/methods/counters.d.ts +0 -3
- package/methods/cron-jobs.d.ts +0 -3
- package/methods/flags.d.ts +0 -3
- package/methods/logs.d.ts +0 -3
- package/methods/pdf.d.ts +0 -3
- package/models/active-subscription.model.d.ts +0 -14
- package/models/app-status.model.d.ts +0 -5
- package/models/app-version.model.d.ts +0 -5
- package/models/collection-document.model.d.ts +0 -7
- package/models/counter.model.d.ts +0 -6
- package/models/cron-job-history.model.d.ts +0 -13
- package/models/cron-job.model.d.ts +0 -14
- package/models/dialog.model.d.ts +0 -24
- package/models/file.model.d.ts +0 -10
- package/models/flag.model.d.ts +0 -6
- package/models/log.model.d.ts +0 -12
- package/models/logged-in-users.model.d.ts +0 -10
- package/models/method-call.model.d.ts +0 -8
- package/models/method-response.model.d.ts +0 -9
- package/models/method.model.d.ts +0 -11
- package/models/pagination.model.d.ts +0 -12
- package/models/permission.model.d.ts +0 -13
- package/models/queue-method.model.d.ts +0 -10
- package/models/queue-response.model.d.ts +0 -11
- package/models/select-data-label.model.d.ts +0 -10
- package/models/server-response.model.d.ts +0 -6
- package/models/subscription.model.d.ts +0 -31
- package/models/support-method.model.d.ts +0 -10
- package/models/support-ticket.model.d.ts +0 -40
- package/models/user.model.d.ts +0 -15
- package/publications/app-status.d.ts +0 -3
- package/publications/app-version.d.ts +0 -3
- package/publications/cron-jobs.d.ts +0 -3
- package/publications/files.d.ts +0 -3
- package/publications/flags.d.ts +0 -3
- package/publications/logs.d.ts +0 -3
- package/publications/method-calls.d.ts +0 -3
- package/publications/method-responses.d.ts +0 -3
- package/publications/super-admin.d.ts +0 -3
- package/publications/support-tickets.d.ts +0 -2
- package/server-app.d.ts +0 -33
- package/support-methods/aws.d.ts +0 -3
- package/support-methods/collections.d.ts +0 -3
- package/support-methods/counters.d.ts +0 -3
- package/support-methods/support.d.ts +0 -3
- package/util/common.d.ts +0 -15
package/methods/counters.js
CHANGED
|
@@ -1,404 +1 @@
|
|
|
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 mongoose_1 = require("mongoose");
|
|
39
|
-
var counter_collection_1 = require("../collections/counter.collection");
|
|
40
|
-
var simpl_schema_1 = require("simpl-schema");
|
|
41
|
-
var __1 = require("..");
|
|
42
|
-
function loadCounterMethods(methodManager) {
|
|
43
|
-
methodManager.methods({
|
|
44
|
-
incCounter: {
|
|
45
|
-
skipQueue: true,
|
|
46
|
-
check: new simpl_schema_1.default({
|
|
47
|
-
counterType: {
|
|
48
|
-
type: String
|
|
49
|
-
}
|
|
50
|
-
}),
|
|
51
|
-
function: function (counterType) {
|
|
52
|
-
var _this = this;
|
|
53
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
54
|
-
var counter, newCount;
|
|
55
|
-
return __generator(this, function (_a) {
|
|
56
|
-
switch (_a.label) {
|
|
57
|
-
case 0: return [4 /*yield*/, counter_collection_1.Counters.findOne({ type: counterType })];
|
|
58
|
-
case 1:
|
|
59
|
-
counter = _a.sent();
|
|
60
|
-
if (!!counter) return [3 /*break*/, 2];
|
|
61
|
-
counter_collection_1.Counters.create({
|
|
62
|
-
_id: mongoose_1.Types.ObjectId().toHexString(),
|
|
63
|
-
count: 2,
|
|
64
|
-
type: counterType
|
|
65
|
-
});
|
|
66
|
-
resolve(1);
|
|
67
|
-
return [3 /*break*/, 4];
|
|
68
|
-
case 2: return [4 /*yield*/, counter_collection_1.Counters.findOneAndUpdate({ type: counterType }, { $inc: { count: 1 } }).exec()];
|
|
69
|
-
case 3:
|
|
70
|
-
newCount = _a.sent();
|
|
71
|
-
resolve(newCount.count);
|
|
72
|
-
_a.label = 4;
|
|
73
|
-
case 4: return [2 /*return*/];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}); });
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
countCollectionWithQuery: {
|
|
80
|
-
skipQueue: true,
|
|
81
|
-
check: new simpl_schema_1.default({
|
|
82
|
-
collectionType: {
|
|
83
|
-
type: String
|
|
84
|
-
},
|
|
85
|
-
query: {
|
|
86
|
-
type: Object,
|
|
87
|
-
blackbox: true
|
|
88
|
-
}
|
|
89
|
-
}),
|
|
90
|
-
function: function (collectionType, query) {
|
|
91
|
-
return __1.ResolveIOServer.getMainDB().model(collectionType).collection.countDocuments(query);
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
countQuery: {
|
|
95
|
-
skipQueue: true,
|
|
96
|
-
check: new simpl_schema_1.default({
|
|
97
|
-
collectionType: {
|
|
98
|
-
type: String
|
|
99
|
-
},
|
|
100
|
-
search: {
|
|
101
|
-
type: String,
|
|
102
|
-
optional: true
|
|
103
|
-
},
|
|
104
|
-
filters: simpl_schema_1.default.oneOf({
|
|
105
|
-
type: Array,
|
|
106
|
-
optional: true
|
|
107
|
-
}, {
|
|
108
|
-
type: Object,
|
|
109
|
-
blackbox: true,
|
|
110
|
-
optional: true
|
|
111
|
-
}),
|
|
112
|
-
'filters.$': {
|
|
113
|
-
type: Object,
|
|
114
|
-
optional: true,
|
|
115
|
-
blackbox: true
|
|
116
|
-
},
|
|
117
|
-
subType: {
|
|
118
|
-
type: String,
|
|
119
|
-
optional: true
|
|
120
|
-
}
|
|
121
|
-
}),
|
|
122
|
-
function: function (collectionType, search, filters) {
|
|
123
|
-
if (search === void 0) { search = ''; }
|
|
124
|
-
if (filters === void 0) { filters = []; }
|
|
125
|
-
var query = {};
|
|
126
|
-
if (!search && (!filters || !filters.length)) {
|
|
127
|
-
query = {};
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
if (filters && filters.length) {
|
|
131
|
-
query['$and'] = [];
|
|
132
|
-
filters.forEach(function (filter) {
|
|
133
|
-
var _a;
|
|
134
|
-
if (filters.filter(function (a) { return a.prop === 'job'; }).length) {
|
|
135
|
-
if (filters.filter(function (a) { return a.prop === 'job'; })[0].data) {
|
|
136
|
-
query['$and'].push({
|
|
137
|
-
$or: [
|
|
138
|
-
{ type: 'request' },
|
|
139
|
-
{ type: 'initIso' },
|
|
140
|
-
{ type: 'return' },
|
|
141
|
-
{ type: 'returnIso' },
|
|
142
|
-
{ type: 'transferOut' },
|
|
143
|
-
{ type: 'transferIn' }
|
|
144
|
-
]
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
query['$and'].push({
|
|
149
|
-
$or: [
|
|
150
|
-
{ type: 'Customer Pickup' },
|
|
151
|
-
{ type: 'Direct Sale' },
|
|
152
|
-
{ type: 'Third Party' },
|
|
153
|
-
{ type: 'Sale Return' },
|
|
154
|
-
{ type: 'transferYard' }
|
|
155
|
-
]
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
filters.splice(filters.map(function (a) { return a.prop; }).indexOf('job'), 1);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
query['$and'].push((_a = {}, _a[filter['prop']] = filter['data'], _a));
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
if (search && collectionType === 'jobs') {
|
|
166
|
-
var searchRegEx = { '$regex': '.*' + (search || '') + '.*', '$options': 'i' };
|
|
167
|
-
if (query['$and']) {
|
|
168
|
-
query['$and'].push({
|
|
169
|
-
$or: [
|
|
170
|
-
{
|
|
171
|
-
status: searchRegEx
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
operator: searchRegEx
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
pumping_company: searchRegEx
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
afe: searchRegEx
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
po: searchRegEx
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
county: searchRegEx
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
state: searchRegEx
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
well: searchRegEx
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
query = {
|
|
199
|
-
$or: [
|
|
200
|
-
{
|
|
201
|
-
status: searchRegEx
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
operator: searchRegEx
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
pumping_company: searchRegEx
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
afe: searchRegEx
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
po: searchRegEx
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
county: searchRegEx
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
state: searchRegEx
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
well: searchRegEx
|
|
223
|
-
}
|
|
224
|
-
]
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
else if (search && collectionType === 'chemicals') {
|
|
229
|
-
var searchRegEx = { '$regex': '.*' + (search || '') + '.*', '$options': 'i' };
|
|
230
|
-
if (query['$and']) {
|
|
231
|
-
query['$and'].push({
|
|
232
|
-
$or: [
|
|
233
|
-
{
|
|
234
|
-
chemical_category: searchRegEx
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
container: searchRegEx
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
type: searchRegEx
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
description: searchRegEx
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
quantity_string: searchRegEx
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
unit: searchRegEx
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
min_stock_string: searchRegEx
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
max_stock_string: searchRegEx
|
|
256
|
-
}
|
|
257
|
-
]
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
query = {
|
|
262
|
-
$or: [
|
|
263
|
-
{
|
|
264
|
-
chemical_category: searchRegEx
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
container: searchRegEx
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
type: searchRegEx
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
description: searchRegEx
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
quantity_string: searchRegEx
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
unit: searchRegEx
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
min_stock_string: searchRegEx
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
max_stock_string: searchRegEx
|
|
286
|
-
}
|
|
287
|
-
]
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
else if (search && collectionType === 'bols') {
|
|
292
|
-
var searchRegEx = { '$regex': '.*' + (search || '') + '.*', '$options': 'i' };
|
|
293
|
-
if (query['$and']) {
|
|
294
|
-
query['$and'].push({
|
|
295
|
-
$or: [
|
|
296
|
-
{
|
|
297
|
-
date_string: searchRegEx
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
bol_string: searchRegEx
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
chemical: searchRegEx
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
locTo: searchRegEx
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
locFrom: searchRegEx
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
quantity_string: searchRegEx
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
file_status: searchRegEx
|
|
316
|
-
}
|
|
317
|
-
]
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
query = {
|
|
322
|
-
$or: [
|
|
323
|
-
{
|
|
324
|
-
date_string: searchRegEx
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
bol_string: searchRegEx
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
chemical: searchRegEx
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
locTo: searchRegEx
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
locFrom: searchRegEx
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
quantity_string: searchRegEx
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
file_status: searchRegEx
|
|
343
|
-
}
|
|
344
|
-
]
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
else if (search && collectionType === 'isotanks') {
|
|
349
|
-
var searchRegEx = { '$regex': '.*' + (search || '') + '.*', '$options': 'i' };
|
|
350
|
-
if (query['$and']) {
|
|
351
|
-
query['$and'].push({
|
|
352
|
-
$or: [
|
|
353
|
-
{
|
|
354
|
-
tank_number: searchRegEx
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
quantity_string: searchRegEx
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
current_location: searchRegEx
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
current_chemical: searchRegEx
|
|
364
|
-
}
|
|
365
|
-
]
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
query = {
|
|
370
|
-
$or: [
|
|
371
|
-
{
|
|
372
|
-
tank_number: searchRegEx
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
quantity_string: searchRegEx
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
current_location: searchRegEx
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
current_chemical: searchRegEx
|
|
382
|
-
}
|
|
383
|
-
]
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return __1.ResolveIOServer.getMainDB().model(collectionType).collection.countDocuments(query);
|
|
389
|
-
}
|
|
390
|
-
},
|
|
391
|
-
countCollection: {
|
|
392
|
-
skipQueue: true,
|
|
393
|
-
check: new simpl_schema_1.default({
|
|
394
|
-
collectionType: {
|
|
395
|
-
type: String
|
|
396
|
-
}
|
|
397
|
-
}),
|
|
398
|
-
function: function (collectionType) {
|
|
399
|
-
return __1.ResolveIOServer.getMainDB().model(collectionType).collection.countDocuments();
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
exports.loadCounterMethods = loadCounterMethods;
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(i,c,a,u){return new(a||(a=Promise))(function(e,t){function n(e){try{r(u.next(e))}catch(e){t(e)}}function o(e){try{r(u.throw(e))}catch(e){t(e)}}function r(t){t.done?e(t.value):new a(function(e){e(t.value)}).then(n,o)}r((u=u.apply(i,c||[])).next())})},__generator=this&&this.__generator||function(n,o){var r,i,c,e,a={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,i&&(c=2&t[0]?i.return:t[0]?i.throw||((c=i.return)&&c.call(i),0):i.next)&&!(c=c.call(i,t[1])).done)return c;switch(i=0,c&&(t=[2&t[0],c.value]),t[0]){case 0:case 1:c=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,i=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(c=0<(c=a.trys).length&&c[c.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!c||t[1]>c[0]&&t[1]<c[3])){a.label=t[1];break}if(6===t[0]&&a.label<c[1]){a.label=c[1],c=t;break}if(c&&a.label<c[2]){a.label=c[2],a.ops.push(t);break}c[2]&&a.ops.pop(),a.trys.pop();continue}t=o.call(n,a)}catch(e){t=[6,e],i=0}finally{r=c=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}};Object.defineProperty(exports,"__esModule",{value:!0});var mongoose_1=require("mongoose"),counter_collection_1=require("../collections/counter.collection"),simpl_schema_1=require("simpl-schema"),__1=require("..");function loadCounterMethods(e){e.methods({incCounter:{skipQueue:!0,check:new simpl_schema_1.default({counterType:{type:String}}),function:function(o){var t=this;return new Promise(function(n,e){return __awaiter(t,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,counter_collection_1.Counters.findOne({type:o})];case 1:return e.sent()?[3,2]:(counter_collection_1.Counters.create({_id:mongoose_1.Types.ObjectId().toHexString(),count:2,type:o}),n(1),[3,4]);case 2:return[4,counter_collection_1.Counters.findOneAndUpdate({type:o},{$inc:{count:1}}).exec()];case 3:t=e.sent(),n(t.count),e.label=4;case 4:return[2]}})})})}},countCollectionWithQuery:{skipQueue:!0,check:new simpl_schema_1.default({collectionType:{type:String},query:{type:Object,blackbox:!0}}),function:function(e,t){return __1.default.getMainDB().model(e).collection.countDocuments(t)}},countQuery:{skipQueue:!0,check:new simpl_schema_1.default({collectionType:{type:String},search:{type:String,optional:!0},filters:simpl_schema_1.default.oneOf({type:Array,optional:!0},{type:Object,blackbox:!0,optional:!0}),"filters.$":{type:Object,optional:!0,blackbox:!0},subType:{type:String,optional:!0}}),function:function(e,t,n){void 0===t&&(t=""),void 0===n&&(n=[]);var o={};if(t||n&&n.length){if(n&&n.length&&(o.$and=[],n.forEach(function(e){var t;n.filter(function(e){return"job"===e.prop}).length?(n.filter(function(e){return"job"===e.prop})[0].data?o.$and.push({$or:[{type:"request"},{type:"initIso"},{type:"return"},{type:"returnIso"},{type:"transferOut"},{type:"transferIn"}]}):o.$and.push({$or:[{type:"Customer Pickup"},{type:"Direct Sale"},{type:"Third Party"},{type:"Sale Return"},{type:"transferYard"}]}),n.splice(n.map(function(e){return e.prop}).indexOf("job"),1)):o.$and.push(((t={})[e.prop]=e.data,t))})),t&&"jobs"===e){var r={$regex:".*"+(t||"")+".*",$options:"i"};o.$and?o.$and.push({$or:[{status:r},{operator:r},{pumping_company:r},{afe:r},{po:r},{county:r},{state:r},{well:r}]}):o={$or:[{status:r},{operator:r},{pumping_company:r},{afe:r},{po:r},{county:r},{state:r},{well:r}]}}else if(t&&"chemicals"===e){r={$regex:".*"+(t||"")+".*",$options:"i"};o.$and?o.$and.push({$or:[{chemical_category:r},{container:r},{type:r},{description:r},{quantity_string:r},{unit:r},{min_stock_string:r},{max_stock_string:r}]}):o={$or:[{chemical_category:r},{container:r},{type:r},{description:r},{quantity_string:r},{unit:r},{min_stock_string:r},{max_stock_string:r}]}}else if(t&&"bols"===e){r={$regex:".*"+(t||"")+".*",$options:"i"};o.$and?o.$and.push({$or:[{date_string:r},{bol_string:r},{chemical:r},{locTo:r},{locFrom:r},{quantity_string:r},{file_status:r}]}):o={$or:[{date_string:r},{bol_string:r},{chemical:r},{locTo:r},{locFrom:r},{quantity_string:r},{file_status:r}]}}else if(t&&"isotanks"===e){r={$regex:".*"+(t||"")+".*",$options:"i"};o.$and?o.$and.push({$or:[{tank_number:r},{quantity_string:r},{current_location:r},{current_chemical:r}]}):o={$or:[{tank_number:r},{quantity_string:r},{current_location:r},{current_chemical:r}]}}}else o={};return __1.default.getMainDB().model(e).collection.countDocuments(o)}},countCollection:{skipQueue:!0,check:new simpl_schema_1.default({collectionType:{type:String}}),function:function(e){return __1.default.getMainDB().model(e).collection.countDocuments()}}})}exports.loadCounterMethods=loadCounterMethods;
|
package/methods/cron-jobs.js
CHANGED
|
@@ -1,63 +1 @@
|
|
|
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 queue_method_collection_1 = require("../collections/queue-method.collection");
|
|
39
|
-
function loadCronJobMethods(methodManager) {
|
|
40
|
-
methodManager.methods({
|
|
41
|
-
methodQueue: {
|
|
42
|
-
function: function () {
|
|
43
|
-
var _this = this;
|
|
44
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
45
|
-
var updateCnt;
|
|
46
|
-
return __generator(this, function (_a) {
|
|
47
|
-
switch (_a.label) {
|
|
48
|
-
case 0: return [4 /*yield*/, queue_method_collection_1.QueueMethods.collection.countDocuments()];
|
|
49
|
-
case 1:
|
|
50
|
-
updateCnt = _a.sent();
|
|
51
|
-
if (updateCnt) {
|
|
52
|
-
methodManager.getMainServer().getQueueManager().runMethodQueue();
|
|
53
|
-
}
|
|
54
|
-
resolve();
|
|
55
|
-
return [2 /*return*/];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}); });
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
exports.loadCronJobMethods = loadCronJobMethods;
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(u,i,a,c){return new(a||(a=Promise))(function(e,t){function n(e){try{r(c.next(e))}catch(e){t(e)}}function o(e){try{r(c.throw(e))}catch(e){t(e)}}function r(t){t.done?e(t.value):new a(function(e){e(t.value)}).then(n,o)}r((c=c.apply(u,i||[])).next())})},__generator=this&&this.__generator||function(n,o){var r,u,i,e,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,u&&(i=2&t[0]?u.return:t[0]?u.throw||((i=u.return)&&i.call(u),0):u.next)&&!(i=i.call(u,t[1])).done)return i;switch(u=0,i&&(t=[2&t[0],i.value]),t[0]){case 0:case 1:i=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,u=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(i=0<(i=a.trys).length&&i[i.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!i||t[1]>i[0]&&t[1]<i[3])){a.label=t[1];break}if(6===t[0]&&a.label<i[1]){a.label=i[1],i=t;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(t);break}i[2]&&a.ops.pop(),a.trys.pop();continue}t=o.call(n,a)}catch(e){t=[6,e],u=0}finally{r=i=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}};Object.defineProperty(exports,"__esModule",{value:!0});var queue_method_collection_1=require("../collections/queue-method.collection");function loadCronJobMethods(o){o.methods({methodQueue:{function:function(){var n=this;return new Promise(function(t,e){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,queue_method_collection_1.QueueMethods.collection.countDocuments()];case 1:return e.sent()&&o.getMainServer().getQueueManager().runMethodQueue(),t(),[2]}})})})}}})}exports.loadCronJobMethods=loadCronJobMethods;
|
package/methods/flags.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function loadFlagMethods(methodManager) {
|
|
4
|
-
methodManager.methods({});
|
|
5
|
-
}
|
|
6
|
-
exports.loadFlagMethods = loadFlagMethods;
|
|
1
|
+
"use strict";function loadFlagMethods(e){e.methods({})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadFlagMethods=loadFlagMethods;
|
package/methods/logs.js
CHANGED
|
@@ -1,29 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var mongoose_1 = require("mongoose");
|
|
4
|
-
var log_collection_1 = require("../collections/log.collection");
|
|
5
|
-
var index_1 = require("../index");
|
|
6
|
-
function loadLogMethods(methodManager) {
|
|
7
|
-
methodManager.methods({
|
|
8
|
-
insertErrorLog: {
|
|
9
|
-
skipQueue: true,
|
|
10
|
-
function: function (message, data) {
|
|
11
|
-
this.sendEmail('dev@resolveio.com', 'Error Detected - ' + index_1.ResolveIOServer.getClientName(), this.user + '\n' + message + '\n' + JSON.stringify(data, null, 2));
|
|
12
|
-
return log_collection_1.Logs.create({
|
|
13
|
-
_id: mongoose_1.Types.ObjectId().toHexString(),
|
|
14
|
-
__v: 0,
|
|
15
|
-
date: new Date(),
|
|
16
|
-
type: 'error',
|
|
17
|
-
title: 'Error - User: ' + this.user,
|
|
18
|
-
message: message,
|
|
19
|
-
payload: data,
|
|
20
|
-
method: '',
|
|
21
|
-
user: this.user,
|
|
22
|
-
messageId: ''
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
skipValidation: true
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
exports.loadLogMethods = loadLogMethods;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var mongoose_1=require("mongoose"),log_collection_1=require("../collections/log.collection"),index_1=require("../index");function loadLogMethods(e){e.methods({insertErrorLog:{skipQueue:!0,function:function(e,o){return this.sendEmail("dev@resolveio.com","Error Detected - "+index_1.default.getClientName(),this.user+"\n"+e+"\n"+JSON.stringify(o,null,2)),log_collection_1.Logs.create({_id:mongoose_1.Types.ObjectId().toHexString(),__v:0,date:new Date,type:"error",title:"Error - User: "+this.user,message:e,payload:o,method:"",user:this.user,messageId:""})},skipValidation:!0}})}exports.loadLogMethods=loadLogMethods;
|