@resolveio/server-lib 9.0.34 → 9.0.35
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/client-server-app.js +48 -7
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +11 -8
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +11 -8
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +11 -8
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +12 -9
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +11 -8
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +11 -8
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +12 -9
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +11 -8
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +11 -8
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +14 -11
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +16 -13
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +19 -16
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +12 -9
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.js +13 -10
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.js +13 -10
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +16 -13
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.js +16 -13
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.js +18 -15
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +15 -12
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +15 -12
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +11 -8
- package/collections/notification.collection.js.map +1 -1
- package/collections/queue-flag.collection.js +12 -9
- package/collections/queue-flag.collection.js.map +1 -1
- package/collections/queue-method.collection.js +12 -9
- package/collections/queue-method.collection.js.map +1 -1
- package/collections/queue-response.collection.js +12 -9
- package/collections/queue-response.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +13 -10
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +14 -11
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +14 -11
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +14 -11
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +11 -8
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +15 -12
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +25 -25
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +80 -30
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +59 -9
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +460 -344
- package/http/auth.js.map +1 -1
- package/http/health.js +5 -1
- package/http/health.js.map +1 -1
- package/http/home.js +11 -7
- package/http/home.js.map +1 -1
- package/index.js +98 -36
- package/index.js.map +1 -1
- package/managers/cron.manager.js +157 -78
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +302 -314
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +1001 -739
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +254 -171
- package/managers/monitor.manager.js.map +1 -1
- package/managers/queue-method.manager.js +166 -69
- package/managers/queue-method.manager.js.map +1 -1
- package/managers/subscription.manager.js +714 -515
- package/managers/subscription.manager.js.map +1 -1
- package/methods/accounts.js +183 -111
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +262 -156
- package/methods/aws.js.map +1 -1
- package/methods/cloudconvert.js +180 -100
- package/methods/cloudconvert.js.map +1 -1
- package/methods/collections.js +110 -103
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +79 -29
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +884 -819
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +5 -1
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +313 -258
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +348 -289
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +340 -341
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +657 -565
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +185 -67
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +2 -1
- package/models/app-version.model.js +2 -1
- package/models/billing-logged-in-users.model.js +2 -1
- package/models/collection-document.model.js +2 -1
- package/models/counter.model.js +2 -1
- package/models/cron-job-history.model.js +2 -1
- package/models/cron-job.model.js +2 -1
- package/models/dialog.model.js +2 -1
- package/models/email-history.model.js +2 -1
- package/models/email-verified.model.js +2 -1
- package/models/file.model.js +2 -1
- package/models/flag.model.js +2 -1
- package/models/log-method-latency.model.js +2 -1
- package/models/log-subscription.model.js +2 -1
- package/models/log.model.js +2 -1
- package/models/logged-in-users.model.js +2 -1
- package/models/method-call.model.js +2 -1
- package/models/method-response.model.js +2 -1
- package/models/method.model.js +2 -1
- package/models/monitor-cpu.model.js +2 -1
- package/models/monitor-https-inbound.model.js +2 -1
- package/models/monitor-https-outbound.model.js +2 -1
- package/models/monitor-memory.model.js +2 -1
- package/models/monitor-mongo.model.js +2 -1
- package/models/notification.model.js +2 -1
- package/models/pagination.model.js +5 -2
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +2 -1
- package/models/queue-method.model.js +2 -1
- package/models/queue-response.model.js +2 -1
- package/models/report-builder-dashboard-builder.model.js +2 -1
- package/models/report-builder-library.model.js +2 -1
- package/models/report-builder-report.model.js +2 -1
- package/models/report-builder.model.js +2 -1
- package/models/select-data-label.model.js +2 -1
- package/models/server-response.model.js +2 -1
- package/models/subscription.model.js +2 -1
- package/models/support-ticket.model.js +2 -1
- package/models/user-group.model.js +2 -1
- package/models/user-guide.model.js +2 -1
- package/models/user.model.js +2 -1
- package/package.json +1 -1
- package/public_api.js +82 -70
- package/public_api.js.map +1 -1
- package/publications/app-status.js +8 -4
- package/publications/app-status.js.map +1 -1
- package/publications/app-version.js +8 -4
- package/publications/app-version.js.map +1 -1
- package/publications/cron-jobs.js +13 -9
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +15 -11
- package/publications/files.js.map +1 -1
- package/publications/flags.js +11 -7
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +35 -31
- package/publications/logs.js.map +1 -1
- package/publications/method-calls.js +8 -4
- package/publications/method-calls.js.map +1 -1
- package/publications/method-responses.js +8 -4
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +8 -4
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +12 -8
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +66 -16
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +21 -17
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +7 -3
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +8 -4
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +8 -4
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +534 -393
- package/server-app.js.map +1 -1
- package/util/common.js +92 -55
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +134 -76
- package/util/schema-report-builder.js.map +1 -1
package/methods/collections.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadCollectionMethods = void 0;
|
|
4
|
+
var common_1 = require("../util/common");
|
|
5
|
+
var simpl_schema_1 = require("simpl-schema");
|
|
6
|
+
var pagination_model_1 = require("../models/pagination.model");
|
|
7
|
+
var index_1 = require("../index");
|
|
8
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
9
|
+
function loadCollectionMethods(methodManager) {
|
|
7
10
|
methodManager.methods({
|
|
8
11
|
collectionListAll: {
|
|
9
12
|
skipQueue: true,
|
|
10
13
|
function: function () {
|
|
11
|
-
return new Promise((resolve, reject)
|
|
12
|
-
resolve(ResolveIOServer.getMongoManager().collections().map(a
|
|
14
|
+
return new Promise(function (resolve, reject) {
|
|
15
|
+
resolve(index_1.ResolveIOServer.getMongoManager().collections().map(function (a) { return a.collectionName; }).sort(function (a, b) { return a.localeCompare(b); }));
|
|
13
16
|
});
|
|
14
17
|
}
|
|
15
18
|
},
|
|
16
19
|
collectionListRB: {
|
|
17
20
|
skipQueue: true,
|
|
18
21
|
function: function () {
|
|
19
|
-
return new Promise((resolve, reject)
|
|
20
|
-
resolve(ResolveIOServer.getMongoManager().collections().filter(a
|
|
22
|
+
return new Promise(function (resolve, reject) {
|
|
23
|
+
resolve(index_1.ResolveIOServer.getMongoManager().collections().filter(function (a) { return a.useRB; }).map(function (a) { return a.collectionName; }).sort(function (a, b) { return a.localeCompare(b); }));
|
|
21
24
|
});
|
|
22
25
|
}
|
|
23
26
|
},
|
|
24
27
|
// Query database for any collection and query
|
|
25
28
|
findOne: {
|
|
26
29
|
skipQueue: true,
|
|
27
|
-
check: new
|
|
30
|
+
check: new simpl_schema_1.default({
|
|
28
31
|
collection: {
|
|
29
32
|
type: String
|
|
30
33
|
},
|
|
@@ -33,20 +36,21 @@ export function loadCollectionMethods(methodManager) {
|
|
|
33
36
|
blackbox: true
|
|
34
37
|
}
|
|
35
38
|
}),
|
|
36
|
-
function: function (collection, query
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
function: function (collection, query) {
|
|
40
|
+
if (query === void 0) { query = {}; }
|
|
41
|
+
return new Promise(function (resolve, reject) {
|
|
42
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
39
43
|
reject('Invalid collection');
|
|
40
44
|
}
|
|
41
45
|
else {
|
|
42
|
-
ResolveIOServer.getMongoManager().collection(collection).findOne(query).then(res
|
|
46
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).findOne(query).then(function (res) { return resolve(res); }, function (err) { return reject(err); });
|
|
43
47
|
}
|
|
44
48
|
});
|
|
45
49
|
}
|
|
46
50
|
},
|
|
47
51
|
find: {
|
|
48
52
|
skipQueue: true,
|
|
49
|
-
check: new
|
|
53
|
+
check: new simpl_schema_1.default({
|
|
50
54
|
collection: {
|
|
51
55
|
type: String
|
|
52
56
|
},
|
|
@@ -60,20 +64,22 @@ export function loadCollectionMethods(methodManager) {
|
|
|
60
64
|
optional: true
|
|
61
65
|
}
|
|
62
66
|
}),
|
|
63
|
-
function: function (collection, query
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
function: function (collection, query, sortQuery) {
|
|
68
|
+
if (query === void 0) { query = {}; }
|
|
69
|
+
if (sortQuery === void 0) { sortQuery = {}; }
|
|
70
|
+
return new Promise(function (resolve, reject) {
|
|
71
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
66
72
|
reject('Invalid collection');
|
|
67
73
|
}
|
|
68
74
|
else {
|
|
69
|
-
ResolveIOServer.getMongoManager().collection(collection).find(query, { sort: sortQuery }).then(res
|
|
75
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).find(query, { sort: sortQuery }).then(function (res) { return resolve(res); }, function (err) { return reject(err); });
|
|
70
76
|
}
|
|
71
77
|
});
|
|
72
78
|
}
|
|
73
79
|
},
|
|
74
80
|
findWithOptions: {
|
|
75
81
|
skipQueue: true,
|
|
76
|
-
check: new
|
|
82
|
+
check: new simpl_schema_1.default({
|
|
77
83
|
collection: {
|
|
78
84
|
type: String
|
|
79
85
|
},
|
|
@@ -82,16 +88,16 @@ export function loadCollectionMethods(methodManager) {
|
|
|
82
88
|
blackbox: true
|
|
83
89
|
},
|
|
84
90
|
options: {
|
|
85
|
-
type: PaginationOptionsSchema
|
|
91
|
+
type: pagination_model_1.PaginationOptionsSchema
|
|
86
92
|
}
|
|
87
93
|
}),
|
|
88
94
|
function: function (collection, query, options) {
|
|
89
|
-
return new Promise((resolve, reject)
|
|
90
|
-
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
95
|
+
return new Promise(function (resolve, reject) {
|
|
96
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
91
97
|
reject('Invalid collection');
|
|
92
98
|
}
|
|
93
99
|
else {
|
|
94
|
-
|
|
100
|
+
var optionsQuery = {};
|
|
95
101
|
if (options.fields && Object.keys(options.fields).length) {
|
|
96
102
|
optionsQuery['projection'] = options.fields;
|
|
97
103
|
}
|
|
@@ -104,7 +110,7 @@ export function loadCollectionMethods(methodManager) {
|
|
|
104
110
|
if (options.skip) {
|
|
105
111
|
optionsQuery['skip'] = options.skip;
|
|
106
112
|
}
|
|
107
|
-
ResolveIOServer.getMongoManager().collection(collection).find(query, optionsQuery).then(res
|
|
113
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).find(query, optionsQuery).then(function (res) { return resolve(res); }, function (err) { return reject(err); });
|
|
108
114
|
}
|
|
109
115
|
});
|
|
110
116
|
}
|
|
@@ -113,7 +119,7 @@ export function loadCollectionMethods(methodManager) {
|
|
|
113
119
|
// @Inputs: collection, document
|
|
114
120
|
// @Outputs: res = _id of new document, err = not inserted
|
|
115
121
|
insertDocument: {
|
|
116
|
-
check: new
|
|
122
|
+
check: new simpl_schema_1.default({
|
|
117
123
|
collection: {
|
|
118
124
|
type: String
|
|
119
125
|
},
|
|
@@ -123,15 +129,15 @@ export function loadCollectionMethods(methodManager) {
|
|
|
123
129
|
}
|
|
124
130
|
}),
|
|
125
131
|
function: function (collection, document) {
|
|
126
|
-
return new Promise((resolve, reject)
|
|
127
|
-
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
132
|
+
return new Promise(function (resolve, reject) {
|
|
133
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
128
134
|
reject('Invalid collection');
|
|
129
135
|
}
|
|
130
136
|
else {
|
|
131
|
-
|
|
132
|
-
document['_id'] =
|
|
137
|
+
var id_1 = mongo_manager_1.objectIdHexString();
|
|
138
|
+
document['_id'] = id_1;
|
|
133
139
|
document['__v'] = 0;
|
|
134
|
-
ResolveIOServer.getMongoManager().collection(collection).insertOne(document).then(()
|
|
140
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).insertOne(document).then(function () { return resolve(id_1); }, function (err) { return reject(err); });
|
|
135
141
|
}
|
|
136
142
|
});
|
|
137
143
|
}
|
|
@@ -140,7 +146,7 @@ export function loadCollectionMethods(methodManager) {
|
|
|
140
146
|
// @Inputs: collection, document
|
|
141
147
|
// @Outputs: res = _id of new document, err = not inserted
|
|
142
148
|
insertManyDocuments: {
|
|
143
|
-
check: new
|
|
149
|
+
check: new simpl_schema_1.default({
|
|
144
150
|
collection: {
|
|
145
151
|
type: String
|
|
146
152
|
},
|
|
@@ -153,16 +159,16 @@ export function loadCollectionMethods(methodManager) {
|
|
|
153
159
|
}
|
|
154
160
|
}),
|
|
155
161
|
function: function (collection, documents) {
|
|
156
|
-
return new Promise((resolve, reject)
|
|
157
|
-
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
162
|
+
return new Promise(function (resolve, reject) {
|
|
163
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
158
164
|
reject('Invalid collection');
|
|
159
165
|
}
|
|
160
166
|
else {
|
|
161
|
-
documents.forEach(document
|
|
162
|
-
document['_id'] = objectIdHexString();
|
|
167
|
+
documents.forEach(function (document) {
|
|
168
|
+
document['_id'] = mongo_manager_1.objectIdHexString();
|
|
163
169
|
document['__v'] = 0;
|
|
164
170
|
});
|
|
165
|
-
ResolveIOServer.getMongoManager().collection(collection).insertMany(documents).then(()
|
|
171
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).insertMany(documents).then(function () { return resolve(documents.map(function (a) { return a['_id']; })); }, function (err) { return reject(err); });
|
|
166
172
|
}
|
|
167
173
|
});
|
|
168
174
|
}
|
|
@@ -172,7 +178,7 @@ export function loadCollectionMethods(methodManager) {
|
|
|
172
178
|
// @Outputs: res = 1 (updated 1), err = not updated/wrong version
|
|
173
179
|
// Search for doc, check version, if found then try and update
|
|
174
180
|
updateDocument: {
|
|
175
|
-
check: new
|
|
181
|
+
check: new simpl_schema_1.default({
|
|
176
182
|
collection: {
|
|
177
183
|
type: String
|
|
178
184
|
},
|
|
@@ -182,12 +188,12 @@ export function loadCollectionMethods(methodManager) {
|
|
|
182
188
|
}
|
|
183
189
|
}),
|
|
184
190
|
function: function (collection, f_document) {
|
|
185
|
-
return new Promise((resolve, reject)
|
|
186
|
-
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
191
|
+
return new Promise(function (resolve, reject) {
|
|
192
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
187
193
|
reject('Invalid collection');
|
|
188
194
|
}
|
|
189
195
|
else {
|
|
190
|
-
ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: f_document['_id'] }, f_document).then(res
|
|
196
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: f_document['_id'] }, f_document).then(function (res) { return resolve(res); }, function (err) { return reject(err); });
|
|
191
197
|
}
|
|
192
198
|
});
|
|
193
199
|
}
|
|
@@ -197,7 +203,7 @@ export function loadCollectionMethods(methodManager) {
|
|
|
197
203
|
// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version
|
|
198
204
|
// Search for doc, check version, if found then try and update props
|
|
199
205
|
updateDocumentProps: {
|
|
200
|
-
check: new
|
|
206
|
+
check: new simpl_schema_1.default({
|
|
201
207
|
collection: {
|
|
202
208
|
type: String
|
|
203
209
|
},
|
|
@@ -216,43 +222,43 @@ export function loadCollectionMethods(methodManager) {
|
|
|
216
222
|
}
|
|
217
223
|
}),
|
|
218
224
|
function: function (collection, doc_id, updateParams, doc__v) {
|
|
219
|
-
return new Promise((resolve, reject)
|
|
220
|
-
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
225
|
+
return new Promise(function (resolve, reject) {
|
|
226
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
221
227
|
reject('Invalid collection');
|
|
222
228
|
}
|
|
223
229
|
else {
|
|
224
|
-
ResolveIOServer.getMongoManager().collection(collection).findOne({ _id: doc_id }).then(currDoc
|
|
230
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).findOne({ _id: doc_id }).then(function (currDoc) {
|
|
225
231
|
if (currDoc) {
|
|
226
|
-
|
|
227
|
-
updateParams.forEach(data
|
|
228
|
-
|
|
232
|
+
var modifiedDoc_1 = common_1.deepCopy(currDoc);
|
|
233
|
+
updateParams.forEach(function (data) {
|
|
234
|
+
modifiedDoc_1[data.prop] = data.data;
|
|
229
235
|
});
|
|
230
|
-
if (
|
|
231
|
-
ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id:
|
|
236
|
+
if (modifiedDoc_1.__v === doc__v) {
|
|
237
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: modifiedDoc_1._id }, modifiedDoc_1, {}, false, true).then(function (res) {
|
|
232
238
|
resolve(res);
|
|
233
|
-
}, err
|
|
239
|
+
}, function (err) { return reject(err); });
|
|
234
240
|
}
|
|
235
241
|
else {
|
|
236
242
|
console.log(new Date(), 'invalid version - ' + collection, currDoc.__v, doc__v);
|
|
237
|
-
if (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {
|
|
238
|
-
ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({
|
|
243
|
+
if (index_1.ResolveIOServer.getMongoManager().collection(collection + '.versions')) {
|
|
244
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({
|
|
239
245
|
$and: [
|
|
240
246
|
{ '_id._id': currDoc._id },
|
|
241
247
|
{ '_id.__v': doc__v }
|
|
242
248
|
]
|
|
243
|
-
}).then(oldDoc
|
|
244
|
-
|
|
249
|
+
}).then(function (oldDoc) {
|
|
250
|
+
var newCurrDocId = currDoc._id;
|
|
245
251
|
if (oldDoc) {
|
|
246
|
-
|
|
252
|
+
var updatedDoc = common_1.getMongoMergeUpdatedDoc(modifiedDoc_1, currDoc, oldDoc);
|
|
247
253
|
updatedDoc._id = newCurrDocId;
|
|
248
|
-
ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: newCurrDocId }, updatedDoc, {}, false, true).then(res
|
|
254
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: newCurrDocId }, updatedDoc, {}, false, true).then(function (res) {
|
|
249
255
|
resolve(res);
|
|
250
|
-
}, err
|
|
256
|
+
}, function (err) { return reject(err); });
|
|
251
257
|
}
|
|
252
258
|
else {
|
|
253
259
|
reject('Invalid Version And Could Not Find History Props - DB: ' + currDoc.__v + ', Trying to update with :' + doc__v);
|
|
254
260
|
}
|
|
255
|
-
}, ()
|
|
261
|
+
}, function () { });
|
|
256
262
|
}
|
|
257
263
|
else {
|
|
258
264
|
reject('Invalid Version And We Are NOT Using Versions On This Collection!');
|
|
@@ -262,13 +268,13 @@ export function loadCollectionMethods(methodManager) {
|
|
|
262
268
|
else {
|
|
263
269
|
reject('No Document');
|
|
264
270
|
}
|
|
265
|
-
}, ()
|
|
271
|
+
}, function () { });
|
|
266
272
|
}
|
|
267
273
|
});
|
|
268
274
|
}
|
|
269
275
|
},
|
|
270
276
|
updateDocumentOffline: {
|
|
271
|
-
check: new
|
|
277
|
+
check: new simpl_schema_1.default({
|
|
272
278
|
collection: {
|
|
273
279
|
type: String
|
|
274
280
|
},
|
|
@@ -282,27 +288,27 @@ export function loadCollectionMethods(methodManager) {
|
|
|
282
288
|
}
|
|
283
289
|
}),
|
|
284
290
|
function: function (collection, f_document, f_oldDocument) {
|
|
285
|
-
return new Promise((resolve, reject)
|
|
286
|
-
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
291
|
+
return new Promise(function (resolve, reject) {
|
|
292
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
287
293
|
reject('Invalid collection');
|
|
288
294
|
}
|
|
289
295
|
else {
|
|
290
|
-
ResolveIOServer.getMongoManager().collection(collection).findOne({ _id: f_document['_id'] }).then(currDoc
|
|
296
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).findOne({ _id: f_document['_id'] }).then(function (currDoc) {
|
|
291
297
|
if (currDoc) {
|
|
292
298
|
if (currDoc.__v === f_document['__v']) {
|
|
293
|
-
ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: f_document['_id'] }, f_document, {}, false, true).then(res
|
|
299
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: f_document['_id'] }, f_document, {}, false, true).then(function (res) {
|
|
294
300
|
resolve(res);
|
|
295
|
-
}, err
|
|
301
|
+
}, function (err) { return reject(err); });
|
|
296
302
|
}
|
|
297
303
|
else {
|
|
298
304
|
console.log('OFFLINE - invalid version - ' + collection, currDoc.__v, f_document['__v']);
|
|
299
|
-
|
|
305
|
+
var newCurrDocId = currDoc._id;
|
|
300
306
|
if (f_oldDocument) {
|
|
301
|
-
|
|
307
|
+
var updatedDoc = common_1.getMongoMergeUpdatedDoc(f_document, currDoc, f_oldDocument);
|
|
302
308
|
updatedDoc._id = newCurrDocId;
|
|
303
|
-
ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: newCurrDocId }, updatedDoc, {}, false, true).then(res
|
|
309
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: newCurrDocId }, updatedDoc, {}, false, true).then(function (res) {
|
|
304
310
|
resolve(res);
|
|
305
|
-
}, err
|
|
311
|
+
}, function (err) { return reject(err); });
|
|
306
312
|
}
|
|
307
313
|
else {
|
|
308
314
|
reject('OFFLINE - Invalid Version And Could Not Find History - DB: ' + currDoc.__v + ', Trying to update with :' + f_document['__v']);
|
|
@@ -312,7 +318,7 @@ export function loadCollectionMethods(methodManager) {
|
|
|
312
318
|
else {
|
|
313
319
|
reject('No Document');
|
|
314
320
|
}
|
|
315
|
-
}, ()
|
|
321
|
+
}, function () { });
|
|
316
322
|
}
|
|
317
323
|
});
|
|
318
324
|
}
|
|
@@ -322,7 +328,7 @@ export function loadCollectionMethods(methodManager) {
|
|
|
322
328
|
// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version
|
|
323
329
|
// Search for doc, check version, if found then try and update props
|
|
324
330
|
updateDocumentPropsOffline: {
|
|
325
|
-
check: new
|
|
331
|
+
check: new simpl_schema_1.default({
|
|
326
332
|
collection: {
|
|
327
333
|
type: String
|
|
328
334
|
},
|
|
@@ -345,41 +351,41 @@ export function loadCollectionMethods(methodManager) {
|
|
|
345
351
|
}
|
|
346
352
|
}),
|
|
347
353
|
function: function (collection, doc_id, updateParams, doc__v, f_oldDocument) {
|
|
348
|
-
return new Promise((resolve, reject)
|
|
349
|
-
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
354
|
+
return new Promise(function (resolve, reject) {
|
|
355
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
350
356
|
reject('Invalid collection');
|
|
351
357
|
}
|
|
352
358
|
else {
|
|
353
|
-
ResolveIOServer.getMongoManager().collection(collection).findOne({ _id: doc_id }).then(currDoc
|
|
359
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).findOne({ _id: doc_id }).then(function (currDoc) {
|
|
354
360
|
if (currDoc) {
|
|
355
|
-
|
|
356
|
-
updateParams.forEach(data
|
|
357
|
-
|
|
361
|
+
var modifiedDoc_2 = common_1.deepCopy(currDoc);
|
|
362
|
+
updateParams.forEach(function (data) {
|
|
363
|
+
modifiedDoc_2[data.prop] = data.data;
|
|
358
364
|
});
|
|
359
|
-
if (
|
|
360
|
-
ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id:
|
|
365
|
+
if (modifiedDoc_2.__v === doc__v) {
|
|
366
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: modifiedDoc_2._id }, modifiedDoc_2, {}, false, true).then(function (res) {
|
|
361
367
|
resolve(res);
|
|
362
|
-
}, err
|
|
368
|
+
}, function (err) { return reject(err); });
|
|
363
369
|
}
|
|
364
370
|
else {
|
|
365
371
|
console.log('OFFLINE - invalid version - ' + collection, currDoc.__v, doc__v);
|
|
366
|
-
|
|
372
|
+
var newCurrDocId = currDoc._id;
|
|
367
373
|
if (f_oldDocument) {
|
|
368
|
-
|
|
374
|
+
var updatedDoc = common_1.getMongoMergeUpdatedDoc(modifiedDoc_2, currDoc, f_oldDocument);
|
|
369
375
|
updatedDoc._id = newCurrDocId;
|
|
370
|
-
ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: newCurrDocId }, updatedDoc).then(res
|
|
376
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).replaceOne({ _id: newCurrDocId }, updatedDoc).then(function (res) {
|
|
371
377
|
resolve(res);
|
|
372
|
-
}, err
|
|
378
|
+
}, function (err) { return reject(err); });
|
|
373
379
|
}
|
|
374
380
|
else {
|
|
375
|
-
reject('OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + currDoc.__v + ', Trying to update with :' +
|
|
381
|
+
reject('OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + currDoc.__v + ', Trying to update with :' + modifiedDoc_2.__v);
|
|
376
382
|
}
|
|
377
383
|
}
|
|
378
384
|
}
|
|
379
385
|
else {
|
|
380
386
|
reject('No Document');
|
|
381
387
|
}
|
|
382
|
-
}, ()
|
|
388
|
+
}, function () { });
|
|
383
389
|
}
|
|
384
390
|
});
|
|
385
391
|
}
|
|
@@ -389,7 +395,7 @@ export function loadCollectionMethods(methodManager) {
|
|
|
389
395
|
// @Outputs: res = 1 (deleted), res = 0 (not deleted), err = not deleted
|
|
390
396
|
// Search for doc, if found then try and remove
|
|
391
397
|
removeDocument: {
|
|
392
|
-
check: new
|
|
398
|
+
check: new simpl_schema_1.default({
|
|
393
399
|
collection: {
|
|
394
400
|
type: String
|
|
395
401
|
},
|
|
@@ -398,14 +404,14 @@ export function loadCollectionMethods(methodManager) {
|
|
|
398
404
|
}
|
|
399
405
|
}),
|
|
400
406
|
function: function (collection, doc_id) {
|
|
401
|
-
return new Promise((resolve, reject)
|
|
402
|
-
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
407
|
+
return new Promise(function (resolve, reject) {
|
|
408
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
403
409
|
reject('Invalid collection');
|
|
404
410
|
}
|
|
405
411
|
else {
|
|
406
|
-
ResolveIOServer.getMongoManager().collection(collection).deleteOne({ _id: doc_id }).then(res
|
|
412
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).deleteOne({ _id: doc_id }).then(function (res) {
|
|
407
413
|
resolve(res);
|
|
408
|
-
}, err
|
|
414
|
+
}, function (err) {
|
|
409
415
|
reject(err);
|
|
410
416
|
});
|
|
411
417
|
}
|
|
@@ -413,7 +419,7 @@ export function loadCollectionMethods(methodManager) {
|
|
|
413
419
|
}
|
|
414
420
|
},
|
|
415
421
|
removeDocumentWithQuery: {
|
|
416
|
-
check: new
|
|
422
|
+
check: new simpl_schema_1.default({
|
|
417
423
|
collection: {
|
|
418
424
|
type: String
|
|
419
425
|
},
|
|
@@ -423,14 +429,14 @@ export function loadCollectionMethods(methodManager) {
|
|
|
423
429
|
}
|
|
424
430
|
}),
|
|
425
431
|
function: function (collection, query) {
|
|
426
|
-
return new Promise((resolve, reject)
|
|
427
|
-
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
432
|
+
return new Promise(function (resolve, reject) {
|
|
433
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
428
434
|
reject('Invalid collection');
|
|
429
435
|
}
|
|
430
436
|
else {
|
|
431
|
-
ResolveIOServer.getMongoManager().collection(collection).deleteOne(query).then(res
|
|
437
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).deleteOne(query).then(function (res) {
|
|
432
438
|
resolve(res);
|
|
433
|
-
}, err
|
|
439
|
+
}, function (err) {
|
|
434
440
|
reject(err);
|
|
435
441
|
});
|
|
436
442
|
}
|
|
@@ -438,7 +444,7 @@ export function loadCollectionMethods(methodManager) {
|
|
|
438
444
|
}
|
|
439
445
|
},
|
|
440
446
|
removeDocumentsWithQuery: {
|
|
441
|
-
check: new
|
|
447
|
+
check: new simpl_schema_1.default({
|
|
442
448
|
collection: {
|
|
443
449
|
type: String
|
|
444
450
|
},
|
|
@@ -448,14 +454,14 @@ export function loadCollectionMethods(methodManager) {
|
|
|
448
454
|
}
|
|
449
455
|
}),
|
|
450
456
|
function: function (collection, query) {
|
|
451
|
-
return new Promise((resolve, reject)
|
|
452
|
-
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
457
|
+
return new Promise(function (resolve, reject) {
|
|
458
|
+
if (!index_1.ResolveIOServer.getMongoManager().collection(collection)) {
|
|
453
459
|
reject('Invalid collection');
|
|
454
460
|
}
|
|
455
461
|
else {
|
|
456
|
-
ResolveIOServer.getMongoManager().collection(collection).deleteMany(query).then(res
|
|
462
|
+
index_1.ResolveIOServer.getMongoManager().collection(collection).deleteMany(query).then(function (res) {
|
|
457
463
|
resolve(res);
|
|
458
|
-
}, err
|
|
464
|
+
}, function (err) {
|
|
459
465
|
reject(err);
|
|
460
466
|
});
|
|
461
467
|
}
|
|
@@ -464,5 +470,6 @@ export function loadCollectionMethods(methodManager) {
|
|
|
464
470
|
}
|
|
465
471
|
});
|
|
466
472
|
}
|
|
473
|
+
exports.loadCollectionMethods = loadCollectionMethods;
|
|
467
474
|
|
|
468
475
|
//# sourceMappingURL=collections.js.map
|