@resolveio/server-lib 20.12.49 → 20.12.51

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/fixtures/init.js CHANGED
@@ -35,22 +35,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
- var __values = (this && this.__values) || function(o) {
39
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
- if (m) return m.call(o);
41
- if (o && typeof o.length === "number") return {
42
- next: function () {
43
- if (o && i >= o.length) o = void 0;
44
- return { value: o && o[i++], done: !o };
45
- }
46
- };
47
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
- };
49
38
  Object.defineProperty(exports, "__esModule", { value: true });
50
39
  exports.loadServerInit = loadServerInit;
51
40
  var email_history_collection_1 = require("../collections/email-history.collection");
52
41
  var flag_collection_1 = require("../collections/flag.collection");
53
- var report_builder_report_collection_1 = require("../collections/report-builder-report.collection");
54
42
  var resolveio_server_app_1 = require("../resolveio-server-app");
55
43
  function loadServerInit() {
56
44
  return __awaiter(this, void 0, void 0, function () {
@@ -82,123 +70,10 @@ function loadServerInit() {
82
70
  case 8:
83
71
  _a.sent();
84
72
  _a.label = 9;
85
- case 9: return [4 /*yield*/, backfillReportBuilderLayouts()];
86
- case 10:
87
- _a.sent();
88
- return [2 /*return*/];
89
- }
90
- });
91
- });
92
- }
93
- function backfillReportBuilderLayouts() {
94
- return __awaiter(this, void 0, void 0, function () {
95
- var reports, ops, _loop_1, reports_1, reports_1_1, report;
96
- var e_1, _a;
97
- return __generator(this, function (_b) {
98
- switch (_b.label) {
99
- case 0:
100
- if (!report_builder_report_collection_1.ReportBuilderReports) {
101
- return [2 /*return*/];
102
- }
103
- return [4 /*yield*/, report_builder_report_collection_1.ReportBuilderReports.find({
104
- $or: [
105
- { fields_layout: { $exists: false } },
106
- { fields_layout: { $size: 0 } }
107
- ]
108
- })];
109
- case 1:
110
- reports = _b.sent();
111
- ops = [];
112
- _loop_1 = function (report) {
113
- var fieldsSelected = report.fields_selected || [];
114
- var collectionKeys = buildCollectionKeys(report);
115
- var layout = fieldsSelected.map(function (field, index) {
116
- var header = field.columnName || field.fieldName || "Column ".concat(index + 1);
117
- var mappings = collectionKeys.map(function (key) {
118
- var matchesKey = key === report.collection_root
119
- ? (field.collection_name === report.collection_root)
120
- : (key === (field.lookup_as || '').trim()) || key === field.collection_name;
121
- if (matchesKey) {
122
- return {
123
- collection: key,
124
- mode: 'variable',
125
- fieldPath: field.fieldPath || '',
126
- fieldId: field.id || "f_layout_".concat(index),
127
- text: '',
128
- leafValueType: field.leafValueType || 'Value',
129
- leafFormatType: field.leafFormatType || ''
130
- };
131
- }
132
- return {
133
- collection: key,
134
- mode: 'text',
135
- fieldPath: '',
136
- fieldId: '',
137
- text: '',
138
- leafValueType: 'Value',
139
- leafFormatType: ''
140
- };
141
- });
142
- return {
143
- id: field.id ? "layout_".concat(field.id) : "layout_".concat(index),
144
- header: header,
145
- mappings: mappings
146
- };
147
- });
148
- ops.push({
149
- updateOne: {
150
- filter: { _id: report._id },
151
- update: {
152
- $set: {
153
- collection_joins: report.collection_joins || [],
154
- fields_layout: layout
155
- }
156
- }
157
- }
158
- });
159
- };
160
- try {
161
- for (reports_1 = __values(reports), reports_1_1 = reports_1.next(); !reports_1_1.done; reports_1_1 = reports_1.next()) {
162
- report = reports_1_1.value;
163
- _loop_1(report);
164
- }
165
- }
166
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
167
- finally {
168
- try {
169
- if (reports_1_1 && !reports_1_1.done && (_a = reports_1.return)) _a.call(reports_1);
170
- }
171
- finally { if (e_1) throw e_1.error; }
172
- }
173
- console.log("Backfilled ".concat(ops.length, " report layouts"));
174
- if (!ops.length) return [3 /*break*/, 3];
175
- return [4 /*yield*/, report_builder_report_collection_1.ReportBuilderReports.bulkWrite(ops, { ordered: false }, false, true, true, true)];
176
- case 2:
177
- _b.sent();
178
- _b.label = 3;
179
- case 3: return [2 /*return*/];
73
+ case 9: return [2 /*return*/];
180
74
  }
181
75
  });
182
76
  });
183
77
  }
184
- function buildCollectionKeys(report) {
185
- var keys = [];
186
- if (report.collection_root) {
187
- keys.push(report.collection_root);
188
- }
189
- (report.collection_joins || []).forEach(function (join) {
190
- if (!join) {
191
- return;
192
- }
193
- var alias = (join.alias || '').trim();
194
- if (alias && !keys.includes(alias)) {
195
- keys.push(alias);
196
- }
197
- else if (join.collection && !keys.includes(join.collection)) {
198
- keys.push(join.collection);
199
- }
200
- });
201
- return keys.length ? keys : ['root'];
202
- }
203
78
 
204
79
  //# sourceMappingURL=init.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fixtures/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,wCAmBC;AAxBD,oFAAyE;AACzE,kEAAuD;AACvD,oGAAuF;AACvF,gEAA0D;AAE1D,SAAsB,cAAc;;;;;wBACnC,qBAAM,yCAAc,CAAC,UAAU,CAAC,EAAC,MAAM,EAAE,YAAY,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,MAAM,EAAE,SAAS,EAAC,EAAC,CAAC,EAAA;;oBAApF,SAAoF,CAAC;oBAE/D,qBAAM,uBAAK,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,cAAc,EAAC,CAAC,EAAA;;oBAA7D,eAAe,GAAG,SAA2C;yBAE7D,CAAC,eAAe,EAAhB,wBAAgB;oBACnB,qBAAM,uBAAK,CAAC,SAAS,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,EAAA;;oBAA3D,SAA2D,CAAC;;wBAGpC,qBAAM,uBAAK,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC,EAAA;;oBAApE,kBAAkB,GAAG,SAA+C;yBAE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CAAC;QAC5B,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC","file":"init.js","sourcesContent":["import { EmailHistories } from '../collections/email-history.collection';\nimport { Flags } from '../collections/flag.collection';\nimport { ReportBuilderReports } from '../collections/report-builder-report.collection';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nexport async function loadServerInit() {\n\tawait EmailHistories.updateMany({status: 'processing'}, {$set: {status: 'pending'}});\n\n\tlet enableDebugFlag = await Flags.findOne({type: 'Enable Debug'});\n\n\tif (!enableDebugFlag) {\n\t\tawait Flags.insertOne({type: 'Enable Debug', value: false});\n\t}\n\n\tlet enableDebugFlagPDF = await Flags.findOne({type: 'Enable Debug PDF'});\n\n\tif (!enableDebugFlagPDF) {\n\t\tawait Flags.insertOne({type: 'Enable Debug PDF', value: false});\n\t}\n\telse if (enableDebugFlagPDF.value && ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200') {\n\t\tawait Flags.updateOne({_id: enableDebugFlagPDF._id}, {$set: {value: false}});\n\t}\n\n\tawait backfillReportBuilderLayouts();\n}\n\nasync function backfillReportBuilderLayouts() {\n\tif (!ReportBuilderReports) {\n\t\treturn;\n\t}\n\n\tconst reports = await ReportBuilderReports.find({\n\t\t$or: [\n\t\t\t{fields_layout: {$exists: false}},\n\t\t\t{fields_layout: {$size: 0}}\n\t\t]\n\t});\n\n\tconst ops = [];\n\n\tfor (const report of reports) {\n\t\tconst fieldsSelected = report.fields_selected || [];\n\t\tconst collectionKeys = buildCollectionKeys(report);\n\n\t\tconst layout = fieldsSelected.map((field, index) => {\n\t\t\tconst header = field.columnName || field.fieldName || `Column ${index + 1}`;\n\n\t\t\tconst mappings = collectionKeys.map(key => {\n\t\t\t\tconst matchesKey = key === report.collection_root\n\t\t\t\t\t? (field.collection_name === report.collection_root)\n\t\t\t\t\t: (key === (field.lookup_as || '').trim()) || key === field.collection_name;\n\n\t\t\t\tif (matchesKey) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcollection: key,\n\t\t\t\t\t\tmode: 'variable',\n\t\t\t\t\t\tfieldPath: field.fieldPath || '',\n\t\t\t\t\t\tfieldId: field.id || `f_layout_${index}`,\n\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\tleafValueType: field.leafValueType || 'Value',\n\t\t\t\t\t\tleafFormatType: field.leafFormatType || ''\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcollection: key,\n\t\t\t\t\tmode: 'text',\n\t\t\t\t\tfieldPath: '',\n\t\t\t\t\tfieldId: '',\n\t\t\t\t\ttext: '',\n\t\t\t\t\tleafValueType: 'Value',\n\t\t\t\t\tleafFormatType: ''\n\t\t\t\t};\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tid: field.id ? `layout_${field.id}` : `layout_${index}`,\n\t\t\t\theader,\n\t\t\t\tmappings\n\t\t\t};\n\t\t});\n\n\t\tops.push({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: {_id: report._id},\n\t\t\t\tupdate: {\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tcollection_joins: report.collection_joins || [],\n\t\t\t\t\t\tfields_layout: layout\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tconsole.log(`Backfilled ${ops.length} report layouts`);\n\n\tif (ops.length) {\n\t\tawait ReportBuilderReports.bulkWrite(ops, {ordered: false}, false, true, true, true);\n\t}\n}\n\nfunction buildCollectionKeys(report: any): string[] {\n\tconst keys: string[] = [];\n\n\tif (report.collection_root) {\n\t\tkeys.push(report.collection_root);\n\t}\n\n\t(report.collection_joins || []).forEach(join => {\n\t\tif (!join) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst alias = (join.alias || '').trim();\n\t\tif (alias && !keys.includes(alias)) {\n\t\t\tkeys.push(alias);\n\t\t}\n\t\telse if (join.collection && !keys.includes(join.collection)) {\n\t\t\tkeys.push(join.collection);\n\t\t}\n\t});\n\n\treturn keys.length ? keys : ['root'];\n}\n"]}
1
+ {"version":3,"sources":["../../src/fixtures/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,wCAiBC;AArBD,oFAAyE;AACzE,kEAAuD;AACvD,gEAA0D;AAE1D,SAAsB,cAAc;;;;;wBACnC,qBAAM,yCAAc,CAAC,UAAU,CAAC,EAAC,MAAM,EAAE,YAAY,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,MAAM,EAAE,SAAS,EAAC,EAAC,CAAC,EAAA;;oBAApF,SAAoF,CAAC;oBAE/D,qBAAM,uBAAK,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,cAAc,EAAC,CAAC,EAAA;;oBAA7D,eAAe,GAAG,SAA2C;yBAE7D,CAAC,eAAe,EAAhB,wBAAgB;oBACnB,qBAAM,uBAAK,CAAC,SAAS,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,EAAA;;oBAA3D,SAA2D,CAAC;;wBAGpC,qBAAM,uBAAK,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC,EAAA;;oBAApE,kBAAkB,GAAG,SAA+C;yBAEpE,CAAC,kBAAkB,EAAnB,wBAAmB;oBACtB,qBAAM,uBAAK,CAAC,SAAS,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,EAAA;;oBAA/D,SAA+D,CAAC;;;yBAExD,CAAA,kBAAkB,CAAC,KAAK,IAAI,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,KAAK,uBAAuB,CAAA,EAArG,wBAAqG;oBAC7G,qBAAM,uBAAK,CAAC,SAAS,CAAC,EAAC,GAAG,EAAE,kBAAkB,CAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,KAAK,EAAE,KAAK,EAAC,EAAC,CAAC,EAAA;;oBAA5E,SAA4E,CAAC;;;;;;CAE9E","file":"init.js","sourcesContent":["import { EmailHistories } from '../collections/email-history.collection';\nimport { Flags } from '../collections/flag.collection';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nexport async function loadServerInit() {\n\tawait EmailHistories.updateMany({status: 'processing'}, {$set: {status: 'pending'}});\n\n\tlet enableDebugFlag = await Flags.findOne({type: 'Enable Debug'});\n\n\tif (!enableDebugFlag) {\n\t\tawait Flags.insertOne({type: 'Enable Debug', value: false});\n\t}\n\n\tlet enableDebugFlagPDF = await Flags.findOne({type: 'Enable Debug PDF'});\n\n\tif (!enableDebugFlagPDF) {\n\t\tawait Flags.insertOne({type: 'Enable Debug PDF', value: false});\n\t}\n\telse if (enableDebugFlagPDF.value && ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200') {\n\t\tawait Flags.updateOne({_id: enableDebugFlagPDF._id}, {$set: {value: false}});\n\t}\n}"]}
@@ -115,6 +115,7 @@ export declare class MongoManager {
115
115
  private getFromCache;
116
116
  private addToCache;
117
117
  invalidateQueryCache(collection: string): void;
118
+ clearQueryCache(reason?: string): void;
118
119
  private setupChangeStream;
119
120
  private teardownChangeStream;
120
121
  private handleChangeStreamFailure;
@@ -836,6 +836,34 @@ var MongoManager = /** @class */ (function () {
836
836
  }
837
837
  this._cacheMap = this._cacheMap.filter(function (a) { return !a.collections.includes(collection); });
838
838
  };
839
+ MongoManager.prototype.clearQueryCache = function (reason) {
840
+ var e_5, _a;
841
+ if (resolveio_server_app_1.ResolveIOServer.getMainServer().getSubscriptionManager() && resolveio_server_app_1.ResolveIOServer.getMainServer().getSubscriptionManager().getEnableDebug()) {
842
+ console.log(new Date(), 'Mongo Clear Cache', reason || '');
843
+ }
844
+ try {
845
+ this._nodeCache.flushAll();
846
+ }
847
+ catch (_b) {
848
+ // ignore flush errors
849
+ }
850
+ this._cacheMap = [];
851
+ try {
852
+ // Mark all in-flight ops invalidated so they don't repopulate cache with stale data.
853
+ // eslint-disable-next-line no-unused-vars
854
+ for (var _c = __values(this._operationInProgress.entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
855
+ var _e = __read(_d.value, 2), key = _e[0], operation = _e[1];
856
+ operation.invalidatedDuringExecution = true;
857
+ }
858
+ }
859
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
860
+ finally {
861
+ try {
862
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
863
+ }
864
+ finally { if (e_5) throw e_5.error; }
865
+ }
866
+ };
839
867
  MongoManager.prototype.setupChangeStream = function () {
840
868
  return __awaiter(this, void 0, void 0, function () {
841
869
  var client, watchDatabases, pipeline, changeStream;
@@ -1288,7 +1316,7 @@ var MongoManagerCollection = /** @class */ (function () {
1288
1316
  MongoManagerCollection.prototype.bulkWrite = function (operations_1, options_1) {
1289
1317
  return __awaiter(this, arguments, void 0, function (operations, options, bypassCheckSchema, bypassLogs, bypassVersions, bypassSession) {
1290
1318
  var BATCH_SIZE, opIndex, mongoSession, _a, session, safeOptions, batchOps, logs, versionOps, batchOps_1, batchOps_1_1, op, opType, doc, validationContext, isValid, affectedDocs, versionFilters, versionInserts, _b, _c, monitor, err_9, bwOptions, affectedDocIds, pipeline, oldVersions, _d;
1291
- var e_5, _e;
1319
+ var e_6, _e;
1292
1320
  if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
1293
1321
  if (bypassLogs === void 0) { bypassLogs = false; }
1294
1322
  if (bypassVersions === void 0) { bypassVersions = false; }
@@ -1318,7 +1346,7 @@ var MongoManagerCollection = /** @class */ (function () {
1318
1346
  logs = [];
1319
1347
  versionOps = [];
1320
1348
  try {
1321
- for (batchOps_1 = (e_5 = void 0, __values(batchOps)), batchOps_1_1 = batchOps_1.next(); !batchOps_1_1.done; batchOps_1_1 = batchOps_1.next()) {
1349
+ for (batchOps_1 = (e_6 = void 0, __values(batchOps)), batchOps_1_1 = batchOps_1.next(); !batchOps_1_1.done; batchOps_1_1 = batchOps_1.next()) {
1322
1350
  op = batchOps_1_1.value;
1323
1351
  opType = Object.keys(op)[0];
1324
1352
  doc = op[opType];
@@ -1489,12 +1517,12 @@ var MongoManagerCollection = /** @class */ (function () {
1489
1517
  }
1490
1518
  }
1491
1519
  }
1492
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1520
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1493
1521
  finally {
1494
1522
  try {
1495
1523
  if (batchOps_1_1 && !batchOps_1_1.done && (_e = batchOps_1.return)) _e.call(batchOps_1);
1496
1524
  }
1497
- finally { if (e_5) throw e_5.error; }
1525
+ finally { if (e_6) throw e_6.error; }
1498
1526
  }
1499
1527
  affectedDocs = [];
1500
1528
  if (!(!bypassVersions && this.useVersions && versionOps.length > 0)) return [3 /*break*/, 10];
@@ -2911,8 +2939,8 @@ var MongoManagerCollection = /** @class */ (function () {
2911
2939
  };
2912
2940
  MongoManagerCollection.prototype.insertMany = function (docs_1, options_1) {
2913
2941
  return __awaiter(this, arguments, void 0, function (docs, options, bypassLogs, bypassCheckSchema, bypassMonitor, bypassSession) {
2914
- var validationResults, docs_2, docs_2_1, doc, validation, isValid, e_6_1, validDocs, mongoSession, _a, session, safeOptions, i, doc, date, monitor, err_27;
2915
- var e_6, _b;
2942
+ var validationResults, docs_2, docs_2_1, doc, validation, isValid, e_7_1, validDocs, mongoSession, _a, session, safeOptions, i, doc, date, monitor, err_27;
2943
+ var e_7, _b;
2916
2944
  if (bypassLogs === void 0) { bypassLogs = false; }
2917
2945
  if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
2918
2946
  if (bypassMonitor === void 0) { bypassMonitor = false; }
@@ -2950,14 +2978,14 @@ var MongoManagerCollection = /** @class */ (function () {
2950
2978
  return [3 /*break*/, 2];
2951
2979
  case 6: return [3 /*break*/, 9];
2952
2980
  case 7:
2953
- e_6_1 = _c.sent();
2954
- e_6 = { error: e_6_1 };
2981
+ e_7_1 = _c.sent();
2982
+ e_7 = { error: e_7_1 };
2955
2983
  return [3 /*break*/, 9];
2956
2984
  case 8:
2957
2985
  try {
2958
2986
  if (docs_2_1 && !docs_2_1.done && (_b = docs_2.return)) _b.call(docs_2);
2959
2987
  }
2960
- finally { if (e_6) throw e_6.error; }
2988
+ finally { if (e_7) throw e_7.error; }
2961
2989
  return [7 /*endfinally*/];
2962
2990
  case 9:
2963
2991
  validDocs = this.checkSchema ? docs.filter(function (a, idx) { return validationResults[idx]; }) : docs;