blixify-server 0.3.29 → 1.0.0

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.
Files changed (37) hide show
  1. package/dist/apis/authWrapper.d.ts.map +1 -1
  2. package/dist/apis/authWrapper.js +1 -228
  3. package/dist/apis/crypto.d.ts.map +1 -1
  4. package/dist/apis/crypto.js +1 -63
  5. package/dist/apis/dayjs.d.ts +3 -0
  6. package/dist/apis/dayjs.d.ts.map +1 -0
  7. package/dist/apis/dayjs.js +1 -0
  8. package/dist/apis/fbWrapper.d.ts +6 -6
  9. package/dist/apis/fbWrapper.d.ts.map +1 -1
  10. package/dist/apis/fbWrapper.js +1 -839
  11. package/dist/apis/googleAnalyticsWrapper.d.ts.map +1 -1
  12. package/dist/apis/googleAnalyticsWrapper.js +1 -223
  13. package/dist/apis/index.js +1 -21
  14. package/dist/apis/mondayWrapper.d.ts +2 -2
  15. package/dist/apis/mondayWrapper.d.ts.map +1 -1
  16. package/dist/apis/mondayWrapper.js +32 -527
  17. package/dist/apis/mongoWrapper.d.ts +6 -6
  18. package/dist/apis/mongoWrapper.d.ts.map +1 -1
  19. package/dist/apis/mongoWrapper.js +1 -1526
  20. package/dist/apis/postgresqlWrapper.d.ts +3 -3
  21. package/dist/apis/postgresqlWrapper.d.ts.map +1 -1
  22. package/dist/apis/postgresqlWrapper.js +1 -514
  23. package/dist/apis/security.d.ts.map +1 -1
  24. package/dist/apis/security.js +1 -80
  25. package/dist/apis/trackVisionWrapper.d.ts.map +1 -1
  26. package/dist/apis/trackVisionWrapper.js +1 -150
  27. package/dist/apis/uploadWrapper.d.ts.map +1 -1
  28. package/dist/apis/uploadWrapper.js +1 -481
  29. package/dist/apis/utils.d.ts +1 -1
  30. package/dist/apis/utils.d.ts.map +1 -1
  31. package/dist/apis/utils.js +1 -25
  32. package/dist/buildtsconfig.tsbuildinfo +1 -0
  33. package/dist/model/Log.js +1 -2
  34. package/dist/model/QueryModel.d.ts.map +1 -1
  35. package/dist/model/QueryModel.js +1 -118
  36. package/dist/model/SecurityConfig.js +1 -2
  37. package/package.json +21 -12
@@ -1,106 +1,9 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.MondayWrapper = exports.queryMondayApi = void 0;
16
- const axios_1 = __importDefault(require("axios"));
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
22
- compare_value:${Array.isArray(rule.compare_value)
23
- ? `[ ${rule.compare_value.map((each) => `"${each}"`)} ]`
24
- : `"${rule.compare_value}"`},\n operator:${rule.operator}\n}`;
25
- })
26
- .join(",\n");
27
- };
28
- const queryMondayApi = (token, query, variables) => __awaiter(void 0, void 0, void 0, function* () {
29
- const mondayResponse = yield axios_1.default.post("https://api.monday.com/v2", { query, variables }, {
30
- headers: {
31
- "Content-Type": "application/json",
32
- Authorization: token !== null && token !== void 0 ? token : "",
33
- "API-version": "2025-01",
34
- },
35
- });
36
- return mondayResponse;
37
- });
38
- exports.queryMondayApi = queryMondayApi;
39
- /**
40
- * @Wrapper
41
- * collection - Monday Collection
42
- *
43
- */
44
- class MondayWrapper {
45
- constructor(mondayToken, boardId, groupId, config, modelChecker, modelType, lib) {
46
- this.mondayToken = "";
47
- this.boardId = "";
48
- this.groupId = "";
49
- this.config = {
50
- baseConfig: [],
51
- opsConfig: {
52
- read: [],
53
- create: [],
54
- update: [],
55
- delete: [],
56
- },
57
- };
58
- // eslint-disable-next-line
59
- this.modelChecker = (obj) => {
60
- return false;
61
- };
62
- this.modelType = () => {
63
- return {
64
- read: [],
65
- write: {},
66
- };
67
- };
68
- this.parseModel = (mondayData) => {
69
- const data = {
70
- id: mondayData.id,
71
- name: mondayData.name,
72
- };
73
- mondayData.column_values.map((eachColumn) => {
74
- var _a;
75
- if (eachColumn.id === "subitems")
76
- return;
77
- let retrieveText = true;
78
- let resultValue = eachColumn.value;
79
- const modelType = this.modelType().read;
80
- if (modelType.includes(eachColumn.id))
81
- retrieveText = false;
82
- if (eachColumn.type === "mirror") {
83
- resultValue = (_a = eachColumn.display_value) !== null && _a !== void 0 ? _a : eachColumn.value;
84
- }
85
- else if (retrieveText)
86
- resultValue = eachColumn.text;
87
- data[eachColumn.id] = resultValue;
88
- });
89
- return data;
90
- };
91
- this.initCreate = (req, res, workflow) => __awaiter(this, void 0, void 0, function* () {
92
- var _a, _b, _c, _d, _e;
93
- try {
94
- const valid = this.modelChecker(req.body.data);
95
- if (valid) {
96
- //INFO : Security Checker
97
- const validBaseConfig = (0, QueryModel_1.checkBaseConfig)(this.config, req);
98
- const validOpsConfig = (0, QueryModel_1.checkOpsConfig)(this.config, "create", req, req.body.data);
99
- if (!validBaseConfig || !validOpsConfig) {
100
- res.status(400).json({ err: "Invalid Security Configuration" });
101
- return;
102
- }
103
- const query = `
1
+ var __awaiter=this&&this.__awaiter||function(e,s,d,n){return new(d=d||Promise)(function(a,t){function i(e){try{o(n.next(e))}catch(e){t(e)}}function r(e){try{o(n.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?a(e.value):((t=e.value)instanceof d?t:new d(function(e){e(t)})).then(i,r)}o((n=n.apply(e,s||[])).next())})},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MondayWrapper=exports.queryMondayApi=void 0;let axios_1=__importDefault(require("axios")),QueryModel_1=require("../model/QueryModel"),handleFormatRules=e=>e.map(e=>`{
2
+ column_id:"${e.column_id}",
3
+
4
+ compare_value:${Array.isArray(e.compare_value)?`[ ${e.compare_value.map(e=>`"${e}"`)} ]`:`"${e.compare_value}"`},
5
+ operator:${e.operator}
6
+ }`).join(",\n"),queryMondayApi=(e,t,a)=>__awaiter(void 0,void 0,void 0,function*(){return yield axios_1.default.post("https://api.monday.com/v2",{query:t,variables:a},{headers:{"Content-Type":"application/json",Authorization:null!=e?e:"","API-version":"2025-01"}})});exports.queryMondayApi=queryMondayApi;class MondayWrapper{constructor(e,t,a,i,r,o,s){this.mondayToken="",this.boardId="",this.groupId="",this.config={baseConfig:[],opsConfig:{read:[],create:[],update:[],delete:[]}},this.modelChecker=e=>!1,this.modelType=()=>({read:[],write:{}}),this.parseModel=e=>{let r={id:e.id,name:e.name};return e.column_values.map(a=>{var i;if("subitems"!==a.id){let e=!0,t=a.value;this.modelType().read.includes(a.id)&&(e=!1),"mirror"===a.type?t=null!=(i=a.display_value)?i:a.value:e&&(t=a.text),r[a.id]=t}}),r},this.initCreate=(p,m,y)=>__awaiter(this,void 0,void 0,function*(){var e,t,a,i,r;try{if(this.modelChecker(p.body.data)){var o=(0,QueryModel_1.checkBaseConfig)(this.config,p),s=(0,QueryModel_1.checkOpsConfig)(this.config,"create",p,p.body.data);if(o&&s){var d=p.body.data,n=p.body.mondayGroupId,u=(y&&(yield y(d)),{boardId:this.boardId,groupId:null!=n?n:this.groupId,itemName:null!=(e=p.body.data.name)?e:"Item",columnValues:JSON.stringify(d)}),l=yield(0,exports.queryMondayApi)(this.mondayToken,`
104
7
  mutation ($boardId: ID!, $groupId: String!, $itemName: String!, $columnValues: JSON!) {
105
8
  create_item (
106
9
  board_id: $boardId,
@@ -111,58 +14,14 @@ class MondayWrapper {
111
14
  id
112
15
  }
113
16
  }
114
- `;
115
- const data = req.body.data;
116
- const mondayGroupId = req.body.mondayGroupId;
117
- if (workflow)
118
- yield workflow(data);
119
- const variables = {
120
- boardId: this.boardId,
121
- groupId: mondayGroupId !== null && mondayGroupId !== void 0 ? mondayGroupId : this.groupId,
122
- itemName: (_a = req.body.data.name) !== null && _a !== void 0 ? _a : "Item",
123
- columnValues: JSON.stringify(data),
124
- };
125
- const mondayResponse = yield (0, exports.queryMondayApi)(this.mondayToken, query, variables);
126
- if ((_c = (_b = mondayResponse.data.data) === null || _b === void 0 ? void 0 : _b.create_item) === null || _c === void 0 ? void 0 : _c.id) {
127
- const itemId = mondayResponse.data.data.create_item.id;
128
- const resBody = { success: itemId };
129
- if ((_d = req.body) === null || _d === void 0 ? void 0 : _d.stopRes)
130
- return resBody;
131
- res.send(resBody);
132
- }
133
- else {
134
- res.status(400).json({
135
- err: JSON.stringify((_e = mondayResponse.data.errors) === null || _e === void 0 ? void 0 : _e[0].message) ||
136
- "Monday Internal Structure Errors",
137
- });
138
- }
139
- }
140
- else {
141
- res.status(400).json({ err: "Invalid Model Structure" });
142
- }
143
- }
144
- catch (err) {
145
- res.status(400).json({ err: err });
146
- }
147
- });
148
- this.initGet = (req, res) => __awaiter(this, void 0, void 0, function* () {
149
- var _f;
150
- try {
151
- const valid = req.body.id;
152
- if (valid) {
153
- const columnValuesIds = req.body.attributeIds && req.body.attributeIds.length > 0
154
- ? `ids: [${req.body.attributeIds
155
- .map((id) => `"${id}"`)
156
- .join(", ")}]`
157
- : "";
158
- const query = `query {
17
+ `,u);if(null!=(a=null==(t=l.data.data)?void 0:t.create_item)&&a.id){var c={success:l.data.data.create_item.id};if(null!=(i=p.body)&&i.stopRes)return c;m.send(c)}else m.status(400).json({err:JSON.stringify(null==(r=l.data.errors)?void 0:r[0].message)||"Monday Internal Structure Errors"})}else m.status(400).json({err:"Invalid Security Configuration"})}else m.status(400).json({err:"Invalid Model Structure"})}catch(e){m.status(400).json({err:e})}}),this.initGet=(n,u)=>__awaiter(this,void 0,void 0,function*(){var e;try{if(n.body.id){var t=n.body.attributeIds&&0<n.body.attributeIds.length?`ids: [${n.body.attributeIds.map(e=>`"${e}"`).join(", ")}]`:"",a=`query {
159
18
  boards(ids: ${this.boardId}) {
160
- items_page (limit: 1, query_params: {ids:${req.body.id}}) {
19
+ items_page (limit: 1, query_params: {ids:${n.body.id}}) {
161
20
  cursor
162
21
  items {
163
22
  id
164
23
  name
165
- column_values${columnValuesIds ? `(${columnValuesIds})` : ""} {
24
+ column_values${t?`(${t})`:""} {
166
25
  id text value type
167
26
  ... on MirrorValue {
168
27
  display_value
@@ -172,73 +31,13 @@ class MondayWrapper {
172
31
  }
173
32
  }
174
33
  }
175
- }`;
176
- const mondayResponse = yield (0, exports.queryMondayApi)(this.mondayToken, query);
177
- const mondayData = mondayResponse.data.data.boards[0].items_page.items;
178
- if (mondayData.length > 0) {
179
- const parsedData = this.parseModel(mondayData[0]);
180
- const validBaseConfig = (0, QueryModel_1.checkBaseConfig)(this.config, req);
181
- const validOpsConfig = (0, QueryModel_1.checkOpsConfig)(this.config, "read", req, parsedData);
182
- if (!validBaseConfig || !validOpsConfig) {
183
- res.status(400).json({ err: "Invalid Security Configuration" });
184
- return;
185
- }
186
- const resBody = { data: parsedData };
187
- if ((_f = req.body) === null || _f === void 0 ? void 0 : _f.stopRes)
188
- return resBody;
189
- res.send(resBody);
190
- }
191
- else
192
- res.send({ data: null });
193
- }
194
- else {
195
- res.status(400).json({ err: "Invalid Fields" });
196
- }
197
- }
198
- catch (err) {
199
- res.status(400).json({ err: err });
200
- }
201
- });
202
- this.initList = (req, res) => __awaiter(this, void 0, void 0, function* () {
203
- var _g;
204
- try {
205
- const validBaseConfig = (0, QueryModel_1.checkBaseConfig)(this.config, req);
206
- if (validBaseConfig) {
207
- //INFO : Monday can only support 1 query & "=" condition only
208
- const reqQuery = req.body.query;
209
- const sort = req.body.sort;
210
- let mondayDataList = [];
211
- let mondayResponse = undefined;
212
- let query = "";
213
- let limitQuery = "";
214
- let cursorQuery = "";
215
- let sortQuery = "";
216
- if (req.body.limit)
217
- limitQuery = `limit: ${req.body.limit}`;
218
- if (req.body.cursor)
219
- cursorQuery = `cursor: "${String(req.body.cursor)}"`;
220
- if (req.body.sort) {
221
- sortQuery = `order_by: [{column_id: "${sort.sortId}", direction: ${sort.type}}]`;
222
- }
223
- let combinedString = "";
224
- if (limitQuery && cursorQuery) {
225
- combinedString = limitQuery + ", " + cursorQuery;
226
- }
227
- else
228
- combinedString = limitQuery ? limitQuery : cursorQuery;
229
- const columnValuesIds = req.body.attributeIds && req.body.attributeIds.length > 0
230
- ? `ids: [${req.body.attributeIds
231
- .map((id) => `"${id}"`)
232
- .join(", ")}]`
233
- : "";
234
- if (cursorQuery) {
235
- query = `query {
236
- next_items_page(${combinedString}) {
34
+ }`,i=(yield(0,exports.queryMondayApi)(this.mondayToken,a)).data.data.boards[0].items_page.items;if(0<i.length){var r,o=this.parseModel(i[0]),s=(0,QueryModel_1.checkBaseConfig)(this.config,n),d=(0,QueryModel_1.checkOpsConfig)(this.config,"read",n,o);if(s&&d)return r={data:o},null!=(e=n.body)&&e.stopRes?r:void u.send(r);u.status(400).json({err:"Invalid Security Configuration"})}else u.send({data:null})}else u.status(400).json({err:"Invalid Fields"})}catch(e){u.status(400).json({err:e})}}),this.initList=(h,_)=>__awaiter(this,void 0,void 0,function*(){var n;try{var u=(0,QueryModel_1.checkBaseConfig)(this.config,h);if(u){var l=h.body.query,c=h.body.sort;let e=[];var p;let t="",a="",i="",r="",d=(h.body.limit&&(a="limit: "+h.body.limit),h.body.cursor&&(i=`cursor: "${String(h.body.cursor)}"`),h.body.sort&&(r=`order_by: [{column_id: "${c.sortId}", direction: ${c.type}}]`),"");d=a&&i?a+", "+i:a||i;var m=h.body.attributeIds&&0<h.body.attributeIds.length?`ids: [${h.body.attributeIds.map(e=>`"${e}"`).join(", ")}]`:"";if(i)t=`query {
35
+ next_items_page(${d}) {
237
36
  cursor
238
37
  items {
239
38
  id
240
39
  name
241
- column_values${columnValuesIds ? `(${columnValuesIds})` : ""} {
40
+ column_values${m?`(${m})`:""} {
242
41
  id text value type
243
42
  ... on MirrorValue {
244
43
  display_value
@@ -247,123 +46,21 @@ class MondayWrapper {
247
46
  }
248
47
  }
249
48
  }
250
- }`;
251
- }
252
- else {
253
- const orQueries = [];
254
- const andQueries = [];
255
- // INFO - Monday Not Support ><
256
- if (reqQuery && reqQuery.length > 0) {
257
- reqQuery.map((eachQuery) => {
258
- var _a;
259
- const queryId = (_a = eachQuery.queryId) !== null && _a !== void 0 ? _a : "";
260
- const value = eachQuery.value;
261
- const isOr = eachQuery.orQuery;
262
- switch (eachQuery.type) {
263
- case "search":
264
- if (eachQuery.searchIds && eachQuery.searchIds.length > 0) {
265
- eachQuery.searchIds.map((eachSearchIds) => {
266
- orQueries.push({
267
- column_id: eachSearchIds,
268
- compare_value: value,
269
- operator: "contains_text",
270
- });
271
- });
272
- }
273
- break;
274
- case "=":
275
- isOr
276
- ? orQueries.push({
277
- column_id: queryId,
278
- compare_value: value,
279
- operator: "contains_terms",
280
- })
281
- : andQueries.push({
282
- column_id: queryId,
283
- compare_value: value,
284
- operator: "contains_terms",
285
- });
286
- break;
287
- case "in":
288
- isOr
289
- ? orQueries.push({
290
- column_id: queryId,
291
- compare_value: value,
292
- operator: "contains_text",
293
- })
294
- : andQueries.push({
295
- column_id: queryId,
296
- compare_value: value,
297
- operator: "contains_text",
298
- });
299
- break;
300
- case "!=":
301
- isOr
302
- ? orQueries.push({
303
- column_id: queryId,
304
- compare_value: value,
305
- operator: "not_any_of",
306
- })
307
- : andQueries.push({
308
- column_id: queryId,
309
- compare_value: value,
310
- operator: "not_any_of",
311
- });
312
- break;
313
- case ">":
314
- isOr
315
- ? orQueries.push({
316
- column_id: queryId,
317
- compare_value: value,
318
- operator: "greater_than",
319
- })
320
- : andQueries.push({
321
- column_id: queryId,
322
- compare_value: value,
323
- operator: "greater_than",
324
- });
325
- break;
326
- case "<":
327
- isOr
328
- ? orQueries.push({
329
- column_id: queryId,
330
- compare_value: value,
331
- operator: "lower_than",
332
- })
333
- : andQueries.push({
334
- column_id: queryId,
335
- compare_value: value,
336
- operator: "lower_than",
337
- });
338
- break;
339
- case "isEmpty":
340
- isOr
341
- ? orQueries.push({
342
- column_id: queryId,
343
- compare_value: value,
344
- operator: "is_empty",
345
- })
346
- : andQueries.push({
347
- column_id: queryId,
348
- compare_value: value,
349
- operator: "is_empty",
350
- });
351
- break;
352
- default:
353
- break;
354
- }
355
- });
356
- query = `query {
49
+ }`;else{let o=[],s=[];t=l&&0<l.length?(l.map(e=>{var t,a=null!=(t=e.queryId)?t:"";let i=e.value;var r=e.orQuery;switch(e.type){case"search":e.searchIds&&0<e.searchIds.length&&e.searchIds.map(e=>{o.push({column_id:e,compare_value:i,operator:"contains_text"})});break;case"=":(r?o:s).push({column_id:a,compare_value:i,operator:"contains_terms"});break;case"in":(r?o:s).push({column_id:a,compare_value:i,operator:"contains_text"});break;case"!=":(r?o:s).push({column_id:a,compare_value:i,operator:"not_any_of"});break;case">":(r?o:s).push({column_id:a,compare_value:i,operator:"greater_than"});break;case"<":(r?o:s).push({column_id:a,compare_value:i,operator:"lower_than"});break;case"isEmpty":(r?o:s).push({column_id:a,compare_value:i,operator:"is_empty"})}}),`query {
357
50
  boards(ids:${this.boardId}){
358
51
  items_page(
359
- ${combinedString}
52
+ ${d}
360
53
  query_params: {
361
- ${sortQuery},
54
+ ${r},
362
55
  groups: {
363
- rules: [\n${handleFormatRules(andQueries)}\n],
56
+ rules: [
57
+ ${handleFormatRules(s)}
58
+ ],
364
59
  operator: and,
365
60
  groups: {
366
- rules: [\n${handleFormatRules(orQueries)}\n],
61
+ rules: [
62
+ ${handleFormatRules(o)}
63
+ ],
367
64
  operator: or
368
65
  }
369
66
  },
@@ -372,7 +69,7 @@ class MondayWrapper {
372
69
  items {
373
70
  id
374
71
  name
375
- column_values${columnValuesIds ? `(${columnValuesIds})` : ""} {
72
+ column_values${m?`(${m})`:""} {
376
73
  id text value type
377
74
  ... on MirrorValue {
378
75
  display_value
@@ -382,17 +79,14 @@ class MondayWrapper {
382
79
  }
383
80
  }
384
81
  }
385
- }`;
386
- }
387
- else {
388
- query = `query {
82
+ }`):`query {
389
83
  boards(ids:${this.boardId}){
390
- items_page(${limitQuery}) {
84
+ items_page(${a}) {
391
85
  cursor
392
86
  items {
393
87
  id
394
88
  name
395
- column_values${columnValuesIds ? `(${columnValuesIds})` : ""} {
89
+ column_values${m?`(${m})`:""} {
396
90
  id text value type
397
91
  ... on MirrorValue {
398
92
  display_value
@@ -402,62 +96,9 @@ class MondayWrapper {
402
96
  }
403
97
  }
404
98
  }
405
- }`;
406
- }
407
- }
408
- mondayResponse = yield (0, exports.queryMondayApi)(this.mondayToken, query);
409
- if (cursorQuery) {
410
- mondayDataList = mondayResponse.data.data.next_items_page.items;
411
- }
412
- else {
413
- mondayDataList = mondayResponse.data.data.boards[0].items_page.items;
414
- }
415
- let validOpsConfig = true;
416
- const dataList = [];
417
- mondayDataList.map((eachMondayData) => {
418
- const eachData = this.parseModel(eachMondayData);
419
- dataList.push(eachData);
420
- if (!(0, QueryModel_1.checkOpsConfig)(this.config, "read", req, eachData)) {
421
- validOpsConfig = false;
422
- }
423
- });
424
- if (!validBaseConfig || !validOpsConfig) {
425
- res.status(400).json({ err: "Invalid Security Configuration" });
426
- return;
427
- }
428
- let cursor = null;
429
- if (dataList.length === req.body.limit) {
430
- if (cursorQuery) {
431
- cursor = mondayResponse.data.data.next_items_page.cursor;
432
- }
433
- else {
434
- cursor = mondayResponse.data.data.boards[0].items_page.cursor;
435
- }
436
- }
437
- const resBody = {
438
- data: dataList,
439
- count: cursor,
440
- };
441
- if ((_g = req.body) === null || _g === void 0 ? void 0 : _g.stopRes)
442
- return resBody;
443
- res.send(resBody);
444
- }
445
- else {
446
- res.status(400).json({ err: "Invalid Fields" });
447
- }
448
- }
449
- catch (err) {
450
- res.status(400).json({ err: err });
451
- }
452
- });
453
- this.initUpdate = (req, res) => __awaiter(this, void 0, void 0, function* () {
454
- var _h;
455
- try {
456
- const valid = this.modelChecker(req.body.data) && req.body.id;
457
- if (valid) {
458
- const getQuery = `query {
99
+ }`}p=yield(0,exports.queryMondayApi)(this.mondayToken,t),e=(i?p.data.data.next_items_page:p.data.data.boards[0].items_page).items;let o=!0,s=[];if(e.map(e=>{e=this.parseModel(e);s.push(e),(0,QueryModel_1.checkOpsConfig)(this.config,"read",h,e)||(o=!1)}),u&&o){let e=null;s.length===h.body.limit&&(e=(i?p.data.data.next_items_page:p.data.data.boards[0].items_page).cursor);var y={data:s,count:e};if(null!=(n=h.body)&&n.stopRes)return y;_.send(y)}else _.status(400).json({err:"Invalid Security Configuration"})}else _.status(400).json({err:"Invalid Fields"})}catch(e){_.status(400).json({err:e})}}),this.initUpdate=(d,n)=>__awaiter(this,void 0,void 0,function*(){var e;try{if(this.modelChecker(d.body.data)&&d.body.id){var t=`query {
459
100
  boards(ids: ${this.boardId}) {
460
- items_page (limit: 1, query_params: {ids:${req.body.id}}) {
101
+ items_page (limit: 1, query_params: {ids:${d.body.id}}) {
461
102
  cursor
462
103
  items {
463
104
  id
@@ -470,20 +111,7 @@ class MondayWrapper {
470
111
  }
471
112
  }
472
113
  }
473
- }`;
474
- const getMondayResponse = yield (0, exports.queryMondayApi)(this.mondayToken, getQuery);
475
- const mondayData = getMondayResponse.data.data.boards[0].items_page.items;
476
- if (mondayData.length <= 0)
477
- throw "Error";
478
- const parsedData = this.parseModel(mondayData[0]);
479
- //INFO : Security Checker
480
- const validBaseConfig = (0, QueryModel_1.checkBaseConfig)(this.config, req);
481
- const validOpsConfig = (0, QueryModel_1.checkOpsConfig)(this.config, "update", req, parsedData);
482
- if (!validBaseConfig || !validOpsConfig) {
483
- res.status(400).json({ err: "Invalid Security Configuration" });
484
- return;
485
- }
486
- const query = `
114
+ }`,a=(yield(0,exports.queryMondayApi)(this.mondayToken,t)).data.data.boards[0].items_page.items;if(a.length<=0)throw"Error";var i=this.parseModel(a[0]),r=(0,QueryModel_1.checkBaseConfig)(this.config,d),o=(0,QueryModel_1.checkOpsConfig)(this.config,"update",d,i);if(r&&o){let i=d.body.data,r={boardId:this.boardId,itemId:d.body.id,columnValues:{}};Object.keys(i).map(t=>{if("id"!==t){var a=this.modelType().write;let e="";(e=a[t]?a[t]:e)?r.columnValues[t]={[e]:i[t]}:r.columnValues[t]=i[t]}}),r.columnValues=JSON.stringify(r.columnValues),yield(0,exports.queryMondayApi)(this.mondayToken,`
487
115
  mutation ($boardId: ID!, $itemId: ID!, $columnValues: JSON!) {
488
116
  change_multiple_column_values(
489
117
  item_id: $itemId,
@@ -493,50 +121,9 @@ class MondayWrapper {
493
121
  id
494
122
  }
495
123
  }
496
- `;
497
- const data = req.body.data;
498
- const variables = {
499
- boardId: this.boardId,
500
- itemId: req.body.id,
501
- columnValues: {},
502
- };
503
- Object.keys(data).map((eachKey) => {
504
- if (eachKey === "id")
505
- return;
506
- const modelType = this.modelType().write;
507
- let typeAvailable = "";
508
- if (modelType[eachKey])
509
- typeAvailable = modelType[eachKey];
510
- if (typeAvailable)
511
- variables["columnValues"][eachKey] = {
512
- [typeAvailable]: data[eachKey],
513
- };
514
- else
515
- variables["columnValues"][eachKey] = data[eachKey];
516
- });
517
- variables["columnValues"] = JSON.stringify(variables["columnValues"]);
518
- yield (0, exports.queryMondayApi)(this.mondayToken, query, variables);
519
- const resBody = { success: true };
520
- if ((_h = req.body) === null || _h === void 0 ? void 0 : _h.stopRes)
521
- return resBody;
522
- res.send(resBody);
523
- }
524
- else {
525
- res.status(400).json({ err: "Invalid Fields" });
526
- }
527
- }
528
- catch (err) {
529
- res.status(400).json({ err: err });
530
- }
531
- });
532
- this.initDelete = (req, res, workflow) => __awaiter(this, void 0, void 0, function* () {
533
- var _j;
534
- try {
535
- const valid = req.body.id;
536
- if (valid) {
537
- const getQuery = `query {
124
+ `,r);var s={success:!0};if(null!=(e=d.body)&&e.stopRes)return s;n.send(s)}else n.status(400).json({err:"Invalid Security Configuration"})}else n.status(400).json({err:"Invalid Fields"})}catch(e){n.status(400).json({err:e})}}),this.initDelete=(n,u,l)=>__awaiter(this,void 0,void 0,function*(){var e;try{if(n.body.id){var t=`query {
538
125
  boards(ids: ${this.boardId}) {
539
- items_page (limit: 1, query_params: {ids:${req.body.id}}) {
126
+ items_page (limit: 1, query_params: {ids:${n.body.id}}) {
540
127
  cursor
541
128
  items {
542
129
  id
@@ -549,92 +136,10 @@ class MondayWrapper {
549
136
  }
550
137
  }
551
138
  }
552
- }`;
553
- const getMondayResponse = yield (0, exports.queryMondayApi)(this.mondayToken, getQuery);
554
- const mondayData = getMondayResponse.data.data.boards[0].items_page.items;
555
- if (mondayData.length <= 0)
556
- throw "Error";
557
- const parsedData = this.parseModel(mondayData[0]);
558
- const validBaseConfig = (0, QueryModel_1.checkBaseConfig)(this.config, req);
559
- const validOpsConfig = (0, QueryModel_1.checkOpsConfig)(this.config, "delete", req, parsedData);
560
- if (!validBaseConfig || !validOpsConfig) {
561
- res.status(400).json({ err: "Invalid Security Configuration" });
562
- return;
563
- }
564
- if (workflow)
565
- yield workflow(parsedData);
566
- const query = `
139
+ }`,a=(yield(0,exports.queryMondayApi)(this.mondayToken,t)).data.data.boards[0].items_page.items;if(a.length<=0)throw"Error";var i=this.parseModel(a[0]),r=(0,QueryModel_1.checkBaseConfig)(this.config,n),o=(0,QueryModel_1.checkOpsConfig)(this.config,"delete",n,i);if(r&&o){l&&(yield l(i));var s={itemId:n.body.id},d=(yield(0,exports.queryMondayApi)(this.mondayToken,`
567
140
  mutation ($itemId: ID!){
568
141
  delete_item (item_id: $itemId) {
569
142
  id
570
143
  }
571
144
  }
572
- `;
573
- const variables = {
574
- itemId: req.body.id,
575
- };
576
- yield (0, exports.queryMondayApi)(this.mondayToken, query, variables);
577
- const resBody = { success: true };
578
- if ((_j = req.body) === null || _j === void 0 ? void 0 : _j.stopRes)
579
- return resBody;
580
- res.send(resBody);
581
- }
582
- else {
583
- res.status(400).json({ err: "Invalid Model Structure" });
584
- }
585
- }
586
- catch (err) {
587
- res.status(400).json({ err: err });
588
- }
589
- });
590
- this.init = () => {
591
- const router = this.lib.express.Router();
592
- /**
593
- * @Input :
594
- * data - Model
595
- */
596
- router.post("/create", (req, res) => {
597
- this.initCreate(req, res);
598
- });
599
- /**
600
- * @Input :
601
- * id - string
602
- */
603
- router.post("/get", (req, res) => {
604
- this.initGet(req, res);
605
- });
606
- /**
607
- * @Input
608
- * query - Query interface (Optional)
609
- * limit - number (Optional)
610
- */
611
- router.post("/list", (req, res) => {
612
- this.initList(req, res);
613
- });
614
- /**
615
- * @Input :
616
- * data - Model
617
- * id - string
618
- */
619
- router.post("/update", (req, res) => {
620
- this.initUpdate(req, res);
621
- });
622
- /**
623
- * @Input :
624
- * id - string
625
- */
626
- router.post("/delete", (req, res) => {
627
- this.initDelete(req, res);
628
- });
629
- return router;
630
- };
631
- this.mondayToken = mondayToken;
632
- this.boardId = boardId;
633
- this.groupId = groupId;
634
- this.config = config;
635
- this.modelChecker = modelChecker;
636
- this.modelType = modelType;
637
- this.lib = lib;
638
- }
639
- }
640
- exports.MondayWrapper = MondayWrapper;
145
+ `,s),{success:!0});if(null!=(e=n.body)&&e.stopRes)return d;u.send(d)}else u.status(400).json({err:"Invalid Security Configuration"})}else u.status(400).json({err:"Invalid Model Structure"})}catch(e){u.status(400).json({err:e})}}),this.init=()=>{var e=this.lib.express.Router();return e.post("/create",(e,t)=>{this.initCreate(e,t)}),e.post("/get",(e,t)=>{this.initGet(e,t)}),e.post("/list",(e,t)=>{this.initList(e,t)}),e.post("/update",(e,t)=>{this.initUpdate(e,t)}),e.post("/delete",(e,t)=>{this.initDelete(e,t)}),e},this.mondayToken=e,this.boardId=t,this.groupId=a,this.config=i,this.modelChecker=r,this.modelType=o,this.lib=s}}exports.MondayWrapper=MondayWrapper;