drapcode-utility 1.2.0 → 1.2.1-beta

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.
@@ -119,21 +119,21 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
119
119
  finder = query.finder, sortBy = query.sortBy, orderBy = query.orderBy;
120
120
  if (!(finder != "COUNT" && refCollectionFieldsInItems)) return [3 /*break*/, 2];
121
121
  return [4 /*yield*/, Promise.all(refCollectionFieldsInItems.map(function (field) {
122
- var _a, _b, _c;
122
+ var _a;
123
123
  if (["reference", "multi_reference", "belongsTo"].includes(field.type)) {
124
124
  var collectionName_1 = field.refCollection
125
125
  ? field.refCollection["collectionName"]
126
126
  : null;
127
127
  if (collectionName_1) {
128
128
  if (field.type === "belongsTo") {
129
- aggregateQuery.push({
130
- $lookup: {
131
- from: "".concat(collectionName_1),
132
- localField: field.fieldName,
133
- foreignField: "uuid",
134
- as: field.fieldName,
135
- },
136
- });
129
+ // aggregateQuery.push({
130
+ // $lookup: {
131
+ // from: `${collectionName}`,
132
+ // localField: field.fieldName,
133
+ // foreignField: "uuid",
134
+ // as: field.fieldName,
135
+ // },
136
+ // });
137
137
  aggregateQuery.push({
138
138
  $addFields: (_a = {},
139
139
  _a["_$belongsToMetaData"] = field,
@@ -141,65 +141,66 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
141
141
  });
142
142
  }
143
143
  else {
144
- aggregateQuery.push({
145
- $lookup: {
146
- from: "".concat(collectionName_1),
147
- let: (_b = {}, _b["".concat(field.fieldName)] = "$".concat(field.fieldName), _b),
148
- pipeline: [
149
- {
150
- $match: {
151
- $expr: {
152
- $in: [
153
- "$uuid",
154
- {
155
- $cond: {
156
- if: {
157
- $in: ["$$".concat(field.fieldName), ["", null]],
158
- },
159
- then: [],
160
- else: { $ifNull: ["$$".concat(field.fieldName), []] },
161
- },
162
- },
163
- ],
164
- },
165
- },
166
- },
167
- {
168
- $lookup: {
169
- from: "user",
170
- let: { createdBy: "$createdBy" },
171
- pipeline: [
172
- {
173
- $match: {
174
- $expr: { $eq: ["$uuid", "$$createdBy"] },
175
- },
176
- },
177
- { $project: { _id: 0, password: 0 } },
178
- ],
179
- as: "createdBy",
180
- },
181
- },
182
- ],
183
- as: field.fieldName,
184
- },
185
- });
144
+ // aggregateQuery.push({
145
+ // $lookup: {
146
+ // from: `${collectionName}`,
147
+ // let: { [`${field.fieldName}`]: `$${field.fieldName}` },
148
+ // pipeline: [
149
+ // {
150
+ // $match: {
151
+ // $expr: {
152
+ // $in: [
153
+ // "$uuid",
154
+ // {
155
+ // $cond: {
156
+ // if: {
157
+ // $in: [`$$${field.fieldName}`, ["", null]],
158
+ // },
159
+ // then: [],
160
+ // else: { $ifNull: [`$$${field.fieldName}`, []] },
161
+ // },
162
+ // },
163
+ // ],
164
+ // },
165
+ // },
166
+ // },
167
+ // {
168
+ // $lookup: {
169
+ // from: "user",
170
+ // let: { createdBy: "$createdBy" },
171
+ // pipeline: [
172
+ // {
173
+ // $match: {
174
+ // $expr: { $eq: ["$uuid", "$$createdBy"] },
175
+ // },
176
+ // },
177
+ // { $project: { _id: 0, password: 0 } },
178
+ // ],
179
+ // as: "createdBy",
180
+ // },
181
+ // },
182
+ // ],
183
+ // as: field.fieldName,
184
+ // },
185
+ // });
186
186
  }
187
187
  }
188
188
  }
189
- if (field.type === "createdBy")
190
- aggregateQuery.push({
191
- $lookup: {
192
- from: "user",
193
- let: (_c = {}, _c["".concat(field.fieldName)] = "$".concat(field.fieldName), _c),
194
- pipeline: [
195
- {
196
- $match: { $expr: { $eq: ["$uuid", "$$".concat(field.fieldName)] } },
197
- },
198
- { $project: { _id: 0, password: 0 } },
199
- ],
200
- as: field.fieldName,
201
- },
202
- });
189
+ if (field.type === "createdBy") {
190
+ }
191
+ // aggregateQuery.push({
192
+ // $lookup: {
193
+ // from: `user`,
194
+ // let: { [`${field.fieldName}`]: `$${field.fieldName}` },
195
+ // pipeline: [
196
+ // {
197
+ // $match: { $expr: { $eq: ["$uuid", `$$${field.fieldName}`] } },
198
+ // },
199
+ // { $project: { _id: 0, password: 0 } },
200
+ // ],
201
+ // as: field.fieldName,
202
+ // },
203
+ // });
203
204
  }))];
204
205
  case 1:
205
206
  _e.sent();
@@ -209,21 +209,21 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
209
209
  finder = query.finder, sortBy = query.sortBy, orderBy = query.orderBy, aggregateFunctionField = query.aggregateFunctionField;
210
210
  if (!(finder != "COUNT" && refCollectionFieldsInItems)) return [3 /*break*/, 2];
211
211
  return [4 /*yield*/, Promise.all(refCollectionFieldsInItems.map(function (field) {
212
- var _a, _b, _c;
212
+ var _a;
213
213
  if (["reference", "multi_reference", "belongsTo"].includes(field.type)) {
214
214
  var collectionName_1 = field.refCollection
215
215
  ? field.refCollection["collectionName"]
216
216
  : null;
217
217
  if (collectionName_1) {
218
218
  if (field.type === "belongsTo") {
219
- aggregateQuery.push({
220
- $lookup: {
221
- from: "".concat(collectionName_1),
222
- localField: field.fieldName,
223
- foreignField: "uuid",
224
- as: field.fieldName,
225
- },
226
- });
219
+ // aggregateQuery.push({
220
+ // $lookup: {
221
+ // from: `${collectionName}`,
222
+ // localField: field.fieldName,
223
+ // foreignField: "uuid",
224
+ // as: field.fieldName,
225
+ // },
226
+ // });
227
227
  aggregateQuery.push({
228
228
  $addFields: (_a = {},
229
229
  _a["_$belongsToMetaData"] = field,
@@ -231,65 +231,66 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
231
231
  });
232
232
  }
233
233
  else {
234
- aggregateQuery.push({
235
- $lookup: {
236
- from: "".concat(collectionName_1),
237
- let: (_b = {}, _b["".concat(field.fieldName)] = "$".concat(field.fieldName), _b),
238
- pipeline: [
239
- {
240
- $match: {
241
- $expr: {
242
- $in: [
243
- "$uuid",
244
- {
245
- $cond: {
246
- if: {
247
- $in: ["$$".concat(field.fieldName), ["", null]],
248
- },
249
- then: [],
250
- else: { $ifNull: ["$$".concat(field.fieldName), []] },
251
- },
252
- },
253
- ],
254
- },
255
- },
256
- },
257
- {
258
- $lookup: {
259
- from: "user",
260
- let: { createdBy: "$createdBy" },
261
- pipeline: [
262
- {
263
- $match: {
264
- $expr: { $eq: ["$uuid", "$$createdBy"] },
265
- },
266
- },
267
- { $project: { _id: 0, password: 0 } },
268
- ],
269
- as: "createdBy",
270
- },
271
- },
272
- ],
273
- as: field.fieldName,
274
- },
275
- });
234
+ // aggregateQuery.push({
235
+ // $lookup: {
236
+ // from: `${collectionName}`,
237
+ // let: { [`${field.fieldName}`]: `$${field.fieldName}` },
238
+ // pipeline: [
239
+ // {
240
+ // $match: {
241
+ // $expr: {
242
+ // $in: [
243
+ // "$uuid",
244
+ // {
245
+ // $cond: {
246
+ // if: {
247
+ // $in: [`$$${field.fieldName}`, ["", null]],
248
+ // },
249
+ // then: [],
250
+ // else: { $ifNull: [`$$${field.fieldName}`, []] },
251
+ // },
252
+ // },
253
+ // ],
254
+ // },
255
+ // },
256
+ // },
257
+ // {
258
+ // $lookup: {
259
+ // from: "user",
260
+ // let: { createdBy: "$createdBy" },
261
+ // pipeline: [
262
+ // {
263
+ // $match: {
264
+ // $expr: { $eq: ["$uuid", "$$createdBy"] },
265
+ // },
266
+ // },
267
+ // { $project: { _id: 0, password: 0 } },
268
+ // ],
269
+ // as: "createdBy",
270
+ // },
271
+ // },
272
+ // ],
273
+ // as: field.fieldName,
274
+ // },
275
+ // });
276
276
  }
277
277
  }
278
278
  }
279
- if (field.type === "createdBy")
280
- aggregateQuery.push({
281
- $lookup: {
282
- from: "user",
283
- let: (_c = {}, _c["".concat(field.fieldName)] = "$".concat(field.fieldName), _c),
284
- pipeline: [
285
- {
286
- $match: { $expr: { $eq: ["$uuid", "$$".concat(field.fieldName)] } },
287
- },
288
- { $project: { _id: 0, password: 0 } },
289
- ],
290
- as: field.fieldName,
291
- },
292
- });
279
+ if (field.type === "createdBy") {
280
+ }
281
+ // aggregateQuery.push({
282
+ // $lookup: {
283
+ // from: `user`,
284
+ // let: { [`${field.fieldName}`]: `$${field.fieldName}` },
285
+ // pipeline: [
286
+ // {
287
+ // $match: { $expr: { $eq: ["$uuid", `$$${field.fieldName}`] } },
288
+ // },
289
+ // { $project: { _id: 0, password: 0 } },
290
+ // ],
291
+ // as: field.fieldName,
292
+ // },
293
+ // });
293
294
  }))];
294
295
  case 1:
295
296
  _b.sent();
@@ -79,6 +79,7 @@ var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
79
79
  return __generator(this, function (_d) {
80
80
  switch (_d.label) {
81
81
  case 0:
82
+ if (!encryption) return [3 /*break*/, 2];
82
83
  awsConfig = encryption.awsConfig, encryptionType = encryption.encryptionType, dataKey = encryption.dataKey;
83
84
  if (!(encryptionType === "KMS")) return [3 /*break*/, 2];
84
85
  accessKeyId = awsConfig.accessKeyId, secretAccessKey = awsConfig.secretAccessKey, region = awsConfig.region;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "1.2.0",
3
+ "version": "1.2.1-beta",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",