blixify-server 0.1.80 → 0.1.82
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":"mondayWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/mondayWrapper.ts"],"names":[],"mappings":"AAEA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"mondayWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/mondayWrapper.ts"],"names":[],"mappings":"AAEA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAqB5C,eAAO,MAAM,cAAc,UAClB,MAAM,SACN,GAAG,cACE,GAAG,qDAchB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,aAAa;IACxB,WAAW,SAAM;IACjB,OAAO,SAAM;IACb,OAAO,SAAM;IACb,MAAM,EAAE,cAAc,CAQpB;IACF,GAAG,EAAE,UAAU,CAAC;IAEhB,YAAY,QAAS,GAAG,aAEtB;IACF,SAAS;cAAe,MAAM,EAAE;;;;MAK9B;gBAGA,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,OAAO,EACrD,SAAS,EAAE,MAAM;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE;YAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KAAE,EACpE,GAAG,EAAE,UAAU;IAWjB,UAAU,eAAgB;QACxB,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,MAAM,CAAC;QACb,aAAa,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KAC9D,SAaC;IAEF,UAAU,QACH,GAAG,OACH,GAAG,qBACU,GAAG,KAAK,QAAQ,GAAG,CAAC;;mBAuDtC;IAEF,OAAO,QAAe,GAAG,OAAO,GAAG;;mBA+CjC;IAEF,QAAQ,QAAe,GAAG,OAAO,GAAG;;;mBAuMlC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG;;mBAsFpC;IAEF,UAAU,QACH,GAAG,OACH,GAAG,qBACU,GAAG,KAAK,QAAQ,GAAG,CAAC;;mBA8DtC;IAEF,IAAI,YA8CF;CACH"}
|
|
@@ -15,12 +15,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.MondayWrapper = exports.queryMondayApi = void 0;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
const QueryModel_1 = require("../model/QueryModel");
|
|
18
|
+
const handleFormatRules = (rules) => {
|
|
19
|
+
return rules
|
|
20
|
+
.map((rule) => {
|
|
21
|
+
return `{\n column_id:"${rule.column_id}",\n compare_value:"${rule.compare_value}",\n operator:${rule.operator}\n}`;
|
|
22
|
+
})
|
|
23
|
+
.join(",\n");
|
|
24
|
+
};
|
|
18
25
|
const queryMondayApi = (token, query, variables) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
26
|
const mondayResponse = yield axios_1.default.post("https://api.monday.com/v2", { query, variables }, {
|
|
20
27
|
headers: {
|
|
21
28
|
"Content-Type": "application/json",
|
|
22
29
|
Authorization: token !== null && token !== void 0 ? token : "",
|
|
23
|
-
"API-version": "
|
|
30
|
+
"API-version": "2024-10",
|
|
24
31
|
},
|
|
25
32
|
});
|
|
26
33
|
return mondayResponse;
|
|
@@ -205,14 +212,109 @@ class MondayWrapper {
|
|
|
205
212
|
}`;
|
|
206
213
|
}
|
|
207
214
|
else {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
215
|
+
const orQueries = [];
|
|
216
|
+
const andQueries = [];
|
|
217
|
+
// INFO - Monday Not Support ><
|
|
218
|
+
reqQuery.map((eachQuery) => {
|
|
219
|
+
var _a;
|
|
220
|
+
const queryId = (_a = eachQuery.queryId) !== null && _a !== void 0 ? _a : "";
|
|
221
|
+
const value = eachQuery.value;
|
|
222
|
+
const isOr = eachQuery.orQuery;
|
|
223
|
+
switch (eachQuery.type) {
|
|
224
|
+
case "search":
|
|
225
|
+
if (eachQuery.searchIds && eachQuery.searchIds.length > 0) {
|
|
226
|
+
eachQuery.searchIds.map((eachSearchIds) => {
|
|
227
|
+
orQueries.push({
|
|
228
|
+
column_id: eachSearchIds,
|
|
229
|
+
compare_value: value,
|
|
230
|
+
operator: "contains_text",
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
case "=":
|
|
236
|
+
isOr
|
|
237
|
+
? orQueries.push({
|
|
238
|
+
column_id: queryId,
|
|
239
|
+
compare_value: value,
|
|
240
|
+
operator: "contains_terms",
|
|
241
|
+
})
|
|
242
|
+
: andQueries.push({
|
|
243
|
+
column_id: queryId,
|
|
244
|
+
compare_value: value,
|
|
245
|
+
operator: "contains_terms",
|
|
246
|
+
});
|
|
247
|
+
break;
|
|
248
|
+
case "in":
|
|
249
|
+
isOr
|
|
250
|
+
? orQueries.push({
|
|
251
|
+
column_id: queryId,
|
|
252
|
+
compare_value: value,
|
|
253
|
+
operator: "contains_text",
|
|
254
|
+
})
|
|
255
|
+
: andQueries.push({
|
|
256
|
+
column_id: queryId,
|
|
257
|
+
compare_value: value,
|
|
258
|
+
operator: "contains_text",
|
|
259
|
+
});
|
|
260
|
+
break;
|
|
261
|
+
case "!=":
|
|
262
|
+
isOr
|
|
263
|
+
? orQueries.push({
|
|
264
|
+
column_id: queryId,
|
|
265
|
+
compare_value: value,
|
|
266
|
+
operator: "not_any_of",
|
|
267
|
+
})
|
|
268
|
+
: andQueries.push({
|
|
269
|
+
column_id: queryId,
|
|
270
|
+
compare_value: value,
|
|
271
|
+
operator: "not_any_of",
|
|
272
|
+
});
|
|
273
|
+
break;
|
|
274
|
+
case ">":
|
|
275
|
+
isOr
|
|
276
|
+
? orQueries.push({
|
|
277
|
+
column_id: queryId,
|
|
278
|
+
compare_value: value,
|
|
279
|
+
operator: "greater_than",
|
|
280
|
+
})
|
|
281
|
+
: andQueries.push({
|
|
282
|
+
column_id: queryId,
|
|
283
|
+
compare_value: value,
|
|
284
|
+
operator: "greater_than",
|
|
285
|
+
});
|
|
286
|
+
break;
|
|
287
|
+
case "<":
|
|
288
|
+
isOr
|
|
289
|
+
? orQueries.push({
|
|
290
|
+
column_id: queryId,
|
|
291
|
+
compare_value: value,
|
|
292
|
+
operator: "lower_than",
|
|
293
|
+
})
|
|
294
|
+
: andQueries.push({
|
|
295
|
+
column_id: queryId,
|
|
296
|
+
compare_value: value,
|
|
297
|
+
operator: "lower_than",
|
|
298
|
+
});
|
|
299
|
+
break;
|
|
300
|
+
default:
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
query = `query {
|
|
214
305
|
boards(ids:${this.boardId}){
|
|
215
|
-
items_page(
|
|
306
|
+
items_page(
|
|
307
|
+
${limitQuery}
|
|
308
|
+
query_params: {
|
|
309
|
+
groups: {
|
|
310
|
+
rules: [\n${handleFormatRules(andQueries)}\n],
|
|
311
|
+
operator: and,
|
|
312
|
+
groups: {
|
|
313
|
+
rules: [\n${handleFormatRules(orQueries)}\n],
|
|
314
|
+
operator: or
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}) {
|
|
216
318
|
cursor
|
|
217
319
|
items {
|
|
218
320
|
id
|
|
@@ -226,20 +328,13 @@ class MondayWrapper {
|
|
|
226
328
|
}
|
|
227
329
|
}
|
|
228
330
|
}`;
|
|
229
|
-
}
|
|
230
331
|
}
|
|
231
332
|
mondayResponse = yield (0, exports.queryMondayApi)(this.mondayToken, query);
|
|
232
333
|
if (cursorQuery) {
|
|
233
334
|
mondayDataList = mondayResponse.data.data.next_items_page.items;
|
|
234
335
|
}
|
|
235
336
|
else {
|
|
236
|
-
|
|
237
|
-
mondayDataList =
|
|
238
|
-
mondayResponse.data.data.items_page_by_column_values.items;
|
|
239
|
-
}
|
|
240
|
-
else
|
|
241
|
-
mondayDataList =
|
|
242
|
-
mondayResponse.data.data.boards[0].items_page.items;
|
|
337
|
+
mondayDataList = mondayResponse.data.data.boards[0].items_page.items;
|
|
243
338
|
}
|
|
244
339
|
let validOpsConfig = true;
|
|
245
340
|
const dataList = [];
|
|
@@ -260,12 +355,7 @@ class MondayWrapper {
|
|
|
260
355
|
cursor = mondayResponse.data.data.next_items_page.cursor;
|
|
261
356
|
}
|
|
262
357
|
else {
|
|
263
|
-
|
|
264
|
-
cursor =
|
|
265
|
-
mondayResponse.data.data.items_page_by_column_values.cursor;
|
|
266
|
-
}
|
|
267
|
-
else
|
|
268
|
-
cursor = mondayResponse.data.data.boards[0].items_page.cursor;
|
|
358
|
+
cursor = mondayResponse.data.data.boards[0].items_page.cursor;
|
|
269
359
|
}
|
|
270
360
|
}
|
|
271
361
|
const resBody = {
|
|
@@ -15,9 +15,10 @@ export declare class MongoWrapper {
|
|
|
15
15
|
lib: WrapperLib;
|
|
16
16
|
tableId: string;
|
|
17
17
|
logId: string;
|
|
18
|
+
logWorkflow: any;
|
|
18
19
|
debug: any;
|
|
19
20
|
modelChecker: (obj: any) => boolean;
|
|
20
|
-
constructor(mongoDB: any, collection: string, isProd: boolean, config: SecurityConfig, modelChecker: (obj: any, ignore?: boolean) => boolean, lib: WrapperLib, tableId?: string, logId?: string, debug?: (reqBody: any, curBody: any, errMsg: any) => void);
|
|
21
|
+
constructor(mongoDB: any, collection: string, isProd: boolean, config: SecurityConfig, modelChecker: (obj: any, ignore?: boolean) => boolean, lib: WrapperLib, tableId?: string, logId?: string, logWorkflow?: (data: any) => Promise<any>, debug?: (reqBody: any, curBody: any, errMsg: any) => void);
|
|
21
22
|
parseModel: (data: any) => any;
|
|
22
23
|
handleLogging: (mongoId: any, type: "create" | "update" | "delete", req: any, value?: {
|
|
23
24
|
new?: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongoWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/mongoWrapper.ts"],"names":[],"mappings":"AAUA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AAGrD,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAmGD;;;;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,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,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI;
|
|
1
|
+
{"version":3,"file":"mongoWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/mongoWrapper.ts"],"names":[],"mappings":"AAUA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AAGrD,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAmGD;;;;GAIG;AACH,qBAAa,YAAY;IACvB,O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AAK,QAAQ,GAAG,CAAC;;mBAgGtC;IAEF,eAAe,QACR,GAAG,OACH,GAAG,yBACc,GAAG,EAAE,KAAK,QAAQ,GAAG,CAAC;;mBA6H5C;IAEF,UAAU,QACH,GAAG,OACH,GAAG,qBACU,GAAG,KAAK,QAAQ,GAAG,CAAC;;mBAwCtC;IAEF,QAAQ,QAAe,GAAG,OAAO,GAAG;;;;;mBAoQlC;IAEF,IAAI,YA+EF;CACH"}
|
|
@@ -124,7 +124,7 @@ const handleParseQueryFilter = (queryList, prefix) => {
|
|
|
124
124
|
*
|
|
125
125
|
*/
|
|
126
126
|
class MongoWrapper {
|
|
127
|
-
constructor(mongoDB, collection, isProd, config, modelChecker, lib, tableId, logId, debug) {
|
|
127
|
+
constructor(mongoDB, collection, isProd, config, modelChecker, lib, tableId, logId, logWorkflow, debug) {
|
|
128
128
|
this.mongoDB = "";
|
|
129
129
|
this.collection = "";
|
|
130
130
|
this.isProd = false;
|
|
@@ -188,6 +188,8 @@ class MongoWrapper {
|
|
|
188
188
|
.db(this.tableId)
|
|
189
189
|
.collection(this.logId);
|
|
190
190
|
yield mongoLogCollection.insertOne(logItem);
|
|
191
|
+
if (this.logWorkflow)
|
|
192
|
+
yield this.logWorkflow(logItem);
|
|
191
193
|
}
|
|
192
194
|
catch (err) { }
|
|
193
195
|
});
|
|
@@ -286,7 +288,7 @@ class MongoWrapper {
|
|
|
286
288
|
yield workflow(req.body.data);
|
|
287
289
|
const mongoResult = yield mongoCollection.insertOne(req.body.data);
|
|
288
290
|
const mongoId = mongoResult.insertedId.toString();
|
|
289
|
-
this.handleLogging(mongoId, "create", req);
|
|
291
|
+
yield this.handleLogging(mongoId, "create", req);
|
|
290
292
|
const resBody = { success: true };
|
|
291
293
|
if ((_c = req.body) === null || _c === void 0 ? void 0 : _c.stopRes)
|
|
292
294
|
return resBody;
|
|
@@ -520,7 +522,7 @@ class MongoWrapper {
|
|
|
520
522
|
Object.keys(data).map((eachUpdateKey) => {
|
|
521
523
|
oldData[eachUpdateKey] = mongoData[eachUpdateKey];
|
|
522
524
|
});
|
|
523
|
-
this.handleLogging(valid, "update", req, {
|
|
525
|
+
yield this.handleLogging(valid, "update", req, {
|
|
524
526
|
old: oldData,
|
|
525
527
|
new: data,
|
|
526
528
|
});
|
|
@@ -682,7 +684,9 @@ class MongoWrapper {
|
|
|
682
684
|
yield mongoCollection.findOneAndDelete({
|
|
683
685
|
_id: valid,
|
|
684
686
|
});
|
|
685
|
-
this.handleLogging(mongoData._id, "delete", req, {
|
|
687
|
+
yield this.handleLogging(mongoData._id, "delete", req, {
|
|
688
|
+
new: mongoData,
|
|
689
|
+
});
|
|
686
690
|
const resBody = { success: true };
|
|
687
691
|
if ((_o = req.body) === null || _o === void 0 ? void 0 : _o.stopRes)
|
|
688
692
|
return resBody;
|
|
@@ -1000,6 +1004,7 @@ class MongoWrapper {
|
|
|
1000
1004
|
const tableSuffix = this.isProd ? "prod" : "dev";
|
|
1001
1005
|
this.tableId = tableId ? `${tableId}-${tableSuffix}` : tableSuffix;
|
|
1002
1006
|
this.logId = logId !== null && logId !== void 0 ? logId : "";
|
|
1007
|
+
this.logWorkflow = logWorkflow;
|
|
1003
1008
|
this.debug = debug;
|
|
1004
1009
|
}
|
|
1005
1010
|
}
|