blixify-server 0.3.27 → 0.3.29

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.
@@ -1 +1 @@
1
- {"version":3,"file":"mongoWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/mongoWrapper.ts"],"names":[],"mappings":"AASA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AAGrD,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AA6JD;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,EAAE,GAAG,CAAM;IAClB,UAAU,SAAM;IAChB,MAAM,UAAS;IACf,MAAM,EAAE,cAAc,CAQpB;IACF,GAAG,EAAE,UAAU,CAAC;IAChB,OAAO,SAAM;IACb,KAAK,SAAM;IACX,WAAW,EAAE,GAAG,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAM;IAC7B,KAAK,EAAE,GAAG,CAAC;IAEX,YAAY,QAAS,GAAG,aAEtB;gBAGA,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,OAAO,EACrD,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACzC,aAAa,CAAC,EAAE,MAAM,EAAE,EACxB,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI;IAgB3D,UAAU,SAAU,GAAG,SAIrB;IAEF,aAAa,YACF,GAAG,QACN,QAAQ,GAAG,QAAQ,GAAG,QAAQ,OAC/B,GAAG,UACA;QACN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AAQ,GAAG,CAAC;;mBAwCtC;IAEF,mBAAmB,CAAC,GAAG,EAAE,GAAG;IAiT5B,QAAQ,QAAe,GAAG,OAAO,GAAG;;;;;mBAkalC;IAEF,IAAI,YAiFF;CACH"}
@@ -824,7 +824,7 @@ class MongoWrapper {
824
824
  }
825
825
  });
826
826
  this.initList = (req, res) => __awaiter(this, void 0, void 0, function* () {
827
- var _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
827
+ var _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
828
828
  try {
829
829
  //INFO : Security Checker
830
830
  const validBaseConfig = (0, QueryModel_1.checkBaseConfig)(this.config, req);
@@ -846,7 +846,7 @@ class MongoWrapper {
846
846
  }
847
847
  const sort = (_v = req.body.sort) !== null && _v !== void 0 ? _v : { date: -1 };
848
848
  const limit = (_w = req.body.limit) !== null && _w !== void 0 ? _w : 50;
849
- const skip = (_x = req.body.skip) !== null && _x !== void 0 ? _x : 0;
849
+ const skip = (_y = (_x = req.body.cursor) !== null && _x !== void 0 ? _x : req.body.skip) !== null && _y !== void 0 ? _y : 0;
850
850
  const pipeline = [];
851
851
  // Build unionWith pipeline
852
852
  unionCollections.forEach((collectionConfig, index) => {
@@ -931,9 +931,11 @@ class MongoWrapper {
931
931
  if (limit > 0) {
932
932
  pipeline.push({ $limit: limit });
933
933
  }
934
+ // INFO: use unionCollections[0].collection as base so the first pipeline stage runs against the correct collection
935
+ const baseCollection = (_0 = (_z = unionCollections[0]) === null || _z === void 0 ? void 0 : _z.collection) !== null && _0 !== void 0 ? _0 : this.collection;
934
936
  const mongoCollection = this.mongoDB
935
937
  .db(this.tableId)
936
- .collection(this.collection);
938
+ .collection(baseCollection);
937
939
  const dataList = yield mongoCollection.aggregate(pipeline).toArray();
938
940
  const countPipeline = pipeline.filter((stage) => {
939
941
  const stageKey = Object.keys(stage)[0];
@@ -943,7 +945,7 @@ class MongoWrapper {
943
945
  const countResult = yield mongoCollection
944
946
  .aggregate(countPipeline)
945
947
  .toArray();
946
- const count = ((_y = countResult[0]) === null || _y === void 0 ? void 0 : _y.total) || 0;
948
+ const count = ((_1 = countResult[0]) === null || _1 === void 0 ? void 0 : _1.total) || 0;
947
949
  let validOpsConfig = true;
948
950
  dataList.map((eachData) => {
949
951
  if (!(0, QueryModel_1.checkOpsConfig)(this.config, "read", req, eachData)) {
@@ -958,17 +960,17 @@ class MongoWrapper {
958
960
  data: dataList,
959
961
  count,
960
962
  };
961
- if ((_z = req.body) === null || _z === void 0 ? void 0 : _z.stopRes)
963
+ if ((_2 = req.body) === null || _2 === void 0 ? void 0 : _2.stopRes)
962
964
  return resBody;
963
965
  res.send(resBody);
964
966
  return;
965
967
  }
966
968
  if (aggregate) {
967
969
  const dataList = [];
968
- const queryId = (_0 = aggregate.queryId) !== null && _0 !== void 0 ? _0 : "";
969
- const dateId = (_1 = aggregate.dateId) !== null && _1 !== void 0 ? _1 : "baseUpdatedAt";
970
+ const queryId = (_3 = aggregate.queryId) !== null && _3 !== void 0 ? _3 : "";
971
+ const dateId = (_4 = aggregate.dateId) !== null && _4 !== void 0 ? _4 : "baseUpdatedAt";
970
972
  const timezone = aggregate.timezone || "Asia/Kuala_Lumpur";
971
- const dateRanges = (_2 = aggregate.range) !== null && _2 !== void 0 ? _2 : [
973
+ const dateRanges = (_5 = aggregate.range) !== null && _5 !== void 0 ? _5 : [
972
974
  (0, moment_timezone_1.default)().tz(timezone).format("DD/MM/YYYY HH:mm:ss"),
973
975
  ];
974
976
  for (const dateRange of dateRanges) {
@@ -1111,8 +1113,8 @@ class MongoWrapper {
1111
1113
  if (aggregate.groupId)
1112
1114
  value = result;
1113
1115
  else {
1114
- value = (_4 = (_3 = result[0]) === null || _3 === void 0 ? void 0 : _3.value) !== null && _4 !== void 0 ? _4 : 0;
1115
- ids = (_6 = (_5 = result[0]) === null || _5 === void 0 ? void 0 : _5.ids) !== null && _6 !== void 0 ? _6 : [];
1116
+ value = (_7 = (_6 = result[0]) === null || _6 === void 0 ? void 0 : _6.value) !== null && _7 !== void 0 ? _7 : 0;
1117
+ ids = (_9 = (_8 = result[0]) === null || _8 === void 0 ? void 0 : _8.ids) !== null && _9 !== void 0 ? _9 : [];
1116
1118
  }
1117
1119
  dataList.push({
1118
1120
  _id: id,
@@ -1123,7 +1125,7 @@ class MongoWrapper {
1123
1125
  const resBody = {
1124
1126
  data: dataList,
1125
1127
  };
1126
- if ((_7 = req.body) === null || _7 === void 0 ? void 0 : _7.stopRes)
1128
+ if ((_10 = req.body) === null || _10 === void 0 ? void 0 : _10.stopRes)
1127
1129
  return resBody;
1128
1130
  res.send(resBody);
1129
1131
  }
@@ -1141,7 +1143,7 @@ class MongoWrapper {
1141
1143
  mongoCollection.aggregate(pipeline).toArray(),
1142
1144
  mongoCollection.aggregate(countPipeline).toArray(),
1143
1145
  ]);
1144
- const count = ((_8 = countResult[0]) === null || _8 === void 0 ? void 0 : _8.total) || 0;
1146
+ const count = ((_11 = countResult[0]) === null || _11 === void 0 ? void 0 : _11.total) || 0;
1145
1147
  //INFO : Security Checker
1146
1148
  let validOpsConfig = true;
1147
1149
  if (dataList.length > 0) {
@@ -1159,7 +1161,7 @@ class MongoWrapper {
1159
1161
  data: dataList,
1160
1162
  count,
1161
1163
  };
1162
- if ((_9 = req.body) === null || _9 === void 0 ? void 0 : _9.stopRes)
1164
+ if ((_12 = req.body) === null || _12 === void 0 ? void 0 : _12.stopRes)
1163
1165
  return resBody;
1164
1166
  res.send(resBody);
1165
1167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blixify-server",
3
- "version": "0.3.27",
3
+ "version": "0.3.29",
4
4
  "license": "MIT",
5
5
  "main": "dist/apis/index.js",
6
6
  "private": false,