blixify-server 0.1.65 → 0.1.67

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,13 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UploadWrapper=exports.SecurityMiddleware=exports.MondayWrapper=exports.MongoWrapper=exports.FirebaseWrapper=void 0;var fbWrapper_1=require("./fbWrapper"),mongoWrapper_1=(Object.defineProperty(exports,"FirebaseWrapper",{enumerable:!0,get:function(){return fbWrapper_1.FirebaseWrapper}}),require("./mongoWrapper")),mondayWrapper_1=(Object.defineProperty(exports,"MongoWrapper",{enumerable:!0,get:function(){return mongoWrapper_1.MongoWrapper}}),require("./mondayWrapper")),security_1=(Object.defineProperty(exports,"MondayWrapper",{enumerable:!0,get:function(){return mondayWrapper_1.MondayWrapper}}),require("./security")),uploadWrapper_1=(Object.defineProperty(exports,"SecurityMiddleware",{enumerable:!0,get:function(){return security_1.SecurityMiddleware}}),require("./uploadWrapper"));Object.defineProperty(exports,"UploadWrapper",{enumerable:!0,get:function(){return uploadWrapper_1.UploadWrapper}});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UploadWrapper = exports.SecurityMiddleware = exports.MondayWrapper = exports.MongoWrapper = exports.FirebaseWrapper = void 0;
4
+ var fbWrapper_1 = require("./fbWrapper");
5
+ Object.defineProperty(exports, "FirebaseWrapper", { enumerable: true, get: function () { return fbWrapper_1.FirebaseWrapper; } });
6
+ var mongoWrapper_1 = require("./mongoWrapper");
7
+ Object.defineProperty(exports, "MongoWrapper", { enumerable: true, get: function () { return mongoWrapper_1.MongoWrapper; } });
8
+ var mondayWrapper_1 = require("./mondayWrapper");
9
+ Object.defineProperty(exports, "MondayWrapper", { enumerable: true, get: function () { return mondayWrapper_1.MondayWrapper; } });
10
+ var security_1 = require("./security");
11
+ Object.defineProperty(exports, "SecurityMiddleware", { enumerable: true, get: function () { return security_1.SecurityMiddleware; } });
12
+ var uploadWrapper_1 = require("./uploadWrapper");
13
+ Object.defineProperty(exports, "UploadWrapper", { enumerable: true, get: function () { return uploadWrapper_1.UploadWrapper; } });
@@ -1,4 +1,89 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(e,d,r,n){return new(r=r||Promise)(function(i,t){function a(e){try{o(n.next(e))}catch(e){t(e)}}function s(e){try{o(n.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(a,s)}o((n=n.apply(e,d||[])).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;const axios_1=__importDefault(require("axios")),QueryModel_1=require("../model/QueryModel"),queryMondayApi=(e,t,i)=>__awaiter(void 0,void 0,void 0,function*(){return yield axios_1.default.post("https://api.monday.com/v2",{query:t,variables:i},{headers:{"Content-Type":"application/json",Authorization:null!=e?e:"","API-version":"2023-10"}})});exports.queryMondayApi=queryMondayApi;class MondayWrapper{constructor(e,t,i,a,s,o,d){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=>{const i={id:e.id,name:e.name};return e.column_values.map(t=>{if("subitems"!==t.id){let e=!0;this.modelType().read.includes(t.id)&&(e=!1),i[t.id]=e?t.text:t.value}}),i},this.initCreate=(r,n,u)=>__awaiter(this,void 0,void 0,function*(){var e,t;try{if(this.modelChecker(r.body.data)){var i=(0,QueryModel_1.checkBaseConfig)(this.config,r),a=(0,QueryModel_1.checkOpsConfig)(this.config,"create",r,r.body.data);if(i&&a){var s=r.body.data,o=(u&&(yield u(s)),{boardId:this.boardId,groupId:this.groupId,itemName:null!=(e=r.body.data.name)?e:"Item",columnValues:JSON.stringify(s)}),d={success:(yield(0,exports.queryMondayApi)(this.mondayToken,`
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 queryMondayApi = (token, query, variables) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const mondayResponse = yield axios_1.default.post("https://api.monday.com/v2", { query, variables }, {
20
+ headers: {
21
+ "Content-Type": "application/json",
22
+ Authorization: token !== null && token !== void 0 ? token : "",
23
+ "API-version": "2023-10",
24
+ },
25
+ });
26
+ return mondayResponse;
27
+ });
28
+ exports.queryMondayApi = queryMondayApi;
29
+ /**
30
+ * @Wrapper
31
+ * collection - Monday Collection
32
+ *
33
+ */
34
+ class MondayWrapper {
35
+ constructor(mondayToken, boardId, groupId, config, modelChecker, modelType, lib) {
36
+ this.mondayToken = "";
37
+ this.boardId = "";
38
+ this.groupId = "";
39
+ this.config = {
40
+ baseConfig: [],
41
+ opsConfig: {
42
+ read: [],
43
+ create: [],
44
+ update: [],
45
+ delete: [],
46
+ },
47
+ };
48
+ // eslint-disable-next-line
49
+ this.modelChecker = (obj) => {
50
+ return false;
51
+ };
52
+ this.modelType = () => {
53
+ return {
54
+ read: [],
55
+ write: {},
56
+ };
57
+ };
58
+ this.parseModel = (mondayData) => {
59
+ const data = {
60
+ id: mondayData.id,
61
+ name: mondayData.name,
62
+ };
63
+ mondayData.column_values.map((eachColumn) => {
64
+ if (eachColumn.id === "subitems")
65
+ return;
66
+ let retrieveText = true;
67
+ const modelType = this.modelType().read;
68
+ if (modelType.includes(eachColumn.id))
69
+ retrieveText = false;
70
+ data[eachColumn.id] = retrieveText ? eachColumn.text : eachColumn.value;
71
+ });
72
+ return data;
73
+ };
74
+ this.initCreate = (req, res, workflow) => __awaiter(this, void 0, void 0, function* () {
75
+ var _a, _b;
76
+ try {
77
+ const valid = this.modelChecker(req.body.data);
78
+ if (valid) {
79
+ //INFO : Security Checker
80
+ const validBaseConfig = (0, QueryModel_1.checkBaseConfig)(this.config, req);
81
+ const validOpsConfig = (0, QueryModel_1.checkOpsConfig)(this.config, "create", req, req.body.data);
82
+ if (!validBaseConfig || !validOpsConfig) {
83
+ res.status(400).json({ err: "Invalid Security Configuration" });
84
+ return;
85
+ }
86
+ const query = `
2
87
  mutation ($boardId: ID!, $groupId: String!, $itemName: String!, $columnValues: JSON!) {
3
88
  create_item (
4
89
  board_id: $boardId,
@@ -9,9 +94,39 @@
9
94
  id
10
95
  }
11
96
  }
12
- `,o)).data.data.create_item.id};if(null!=(t=r.body)&&t.stopRes)return d;n.send(d)}else n.status(400).json({err:"Invalid Security Configuration"})}else n.status(400).json({err:"Invalid Model Structure"})}catch(e){n.status(400).json({err:e})}}),this.initGet=(r,n)=>__awaiter(this,void 0,void 0,function*(){var e;try{if(r.body.id){var t=`query {
97
+ `;
98
+ const data = req.body.data;
99
+ if (workflow)
100
+ yield workflow(data);
101
+ const variables = {
102
+ boardId: this.boardId,
103
+ groupId: this.groupId,
104
+ itemName: (_a = req.body.data.name) !== null && _a !== void 0 ? _a : "Item",
105
+ columnValues: JSON.stringify(data),
106
+ };
107
+ const mondayResponse = yield (0, exports.queryMondayApi)(this.mondayToken, query, variables);
108
+ const itemId = mondayResponse.data.data.create_item.id;
109
+ const resBody = { success: itemId };
110
+ if ((_b = req.body) === null || _b === void 0 ? void 0 : _b.stopRes)
111
+ return resBody;
112
+ res.send(resBody);
113
+ }
114
+ else {
115
+ res.status(400).json({ err: "Invalid Model Structure" });
116
+ }
117
+ }
118
+ catch (err) {
119
+ res.status(400).json({ err: err });
120
+ }
121
+ });
122
+ this.initGet = (req, res) => __awaiter(this, void 0, void 0, function* () {
123
+ var _c;
124
+ try {
125
+ const valid = req.body.id;
126
+ if (valid) {
127
+ const query = `query {
13
128
  boards(ids: ${this.boardId}) {
14
- items_page (limit: 1, query_params: {ids:${r.body.id}}) {
129
+ items_page (limit: 1, query_params: {ids:${req.body.id}}) {
15
130
  cursor
16
131
  items {
17
132
  id
@@ -24,8 +139,58 @@
24
139
  }
25
140
  }
26
141
  }
27
- }`,i=(yield(0,exports.queryMondayApi)(this.mondayToken,t)).data.data.boards[0].items_page.items;if(0<i.length){var a,s=this.parseModel(i[0]),o=(0,QueryModel_1.checkBaseConfig)(this.config,r),d=(0,QueryModel_1.checkOpsConfig)(this.config,"read",r,s);if(o&&d)return a={data:s},null!=(e=r.body)&&e.stopRes?a:void n.send(a);n.status(400).json({err:"Invalid Security Configuration"})}else n.send({data:null})}else n.status(400).json({err:"Invalid Fields"})}catch(e){n.status(400).json({err:e})}}),this.initList=(y,h)=>__awaiter(this,void 0,void 0,function*(){var d;try{var r=(0,QueryModel_1.checkBaseConfig)(this.config,y);if(r){var n=y.body.query;let e=[];var u,l;let t="",i="",a="",s=(y.body.limit&&(i="limit: "+y.body.limit),y.body.cursor&&(a=`cursor: "${String(y.body.cursor)}"`),""),o=(s=i&&a?i+", "+a:i||a,t=a?`query {
28
- next_items_page(${s}) {
142
+ }`;
143
+ const mondayResponse = yield (0, exports.queryMondayApi)(this.mondayToken, query);
144
+ const mondayData = mondayResponse.data.data.boards[0].items_page.items;
145
+ if (mondayData.length > 0) {
146
+ const parsedData = this.parseModel(mondayData[0]);
147
+ const validBaseConfig = (0, QueryModel_1.checkBaseConfig)(this.config, req);
148
+ const validOpsConfig = (0, QueryModel_1.checkOpsConfig)(this.config, "read", req, parsedData);
149
+ if (!validBaseConfig || !validOpsConfig) {
150
+ res.status(400).json({ err: "Invalid Security Configuration" });
151
+ return;
152
+ }
153
+ const resBody = { data: parsedData };
154
+ if ((_c = req.body) === null || _c === void 0 ? void 0 : _c.stopRes)
155
+ return resBody;
156
+ res.send(resBody);
157
+ }
158
+ else
159
+ res.send({ data: null });
160
+ }
161
+ else {
162
+ res.status(400).json({ err: "Invalid Fields" });
163
+ }
164
+ }
165
+ catch (err) {
166
+ res.status(400).json({ err: err });
167
+ }
168
+ });
169
+ this.initList = (req, res) => __awaiter(this, void 0, void 0, function* () {
170
+ var _d;
171
+ try {
172
+ const validBaseConfig = (0, QueryModel_1.checkBaseConfig)(this.config, req);
173
+ if (validBaseConfig) {
174
+ //INFO : Monday can only support 1 query & "=" condition only
175
+ const reqQuery = req.body.query;
176
+ let mondayDataList = [];
177
+ let mondayResponse = undefined;
178
+ let query = "";
179
+ let limitQuery = "";
180
+ let cursorQuery = "";
181
+ if (req.body.limit)
182
+ limitQuery = `limit: ${req.body.limit}`;
183
+ if (req.body.cursor)
184
+ cursorQuery = `cursor: "${String(req.body.cursor)}"`;
185
+ let combinedString = "";
186
+ if (limitQuery && cursorQuery) {
187
+ combinedString = limitQuery + ", " + cursorQuery;
188
+ }
189
+ else
190
+ combinedString = limitQuery ? limitQuery : cursorQuery;
191
+ if (cursorQuery) {
192
+ query = `query {
193
+ next_items_page(${combinedString}) {
29
194
  cursor
30
195
  items {
31
196
  id
@@ -37,9 +202,17 @@
37
202
  }
38
203
  }
39
204
  }
40
- }`:n&&0<n.length?(l=n[0],`query { items_page_by_column_values (${i} board_id: ${this.boardId}, columns: [{column_id: "${l.queryId}", column_values: ["${l.value}"]}]) { cursor items {id name column_values {id text value} }}}`):`query {
205
+ }`;
206
+ }
207
+ else {
208
+ if (reqQuery && reqQuery.length > 0) {
209
+ const selectedQuery = reqQuery[0];
210
+ query = `query { items_page_by_column_values (${limitQuery} board_id: ${this.boardId}, columns: [{column_id: "${selectedQuery.queryId}", column_values: ["${selectedQuery.value}"]}]) { cursor items {id name column_values {id text value} }}}`;
211
+ }
212
+ else {
213
+ query = `query {
41
214
  boards(ids:${this.boardId}){
42
- items_page(${i}) {
215
+ items_page(${limitQuery}) {
43
216
  cursor
44
217
  items {
45
218
  id
@@ -52,9 +225,73 @@
52
225
  }
53
226
  }
54
227
  }
55
- }`,u=yield(0,exports.queryMondayApi)(this.mondayToken,t),e=(a?u.data.data.next_items_page:n&&0<n.length?u.data.data.items_page_by_column_values:u.data.data.boards[0].items_page).items,!0);const m=[];if(e.map(e=>{e=this.parseModel(e);m.push(e),(0,QueryModel_1.checkOpsConfig)(this.config,"read",y,e)||(o=!1)}),r&&o){let e=null;m.length===y.body.limit&&(e=(a?u.data.data.next_items_page:n&&0<n.length?u.data.data.items_page_by_column_values:u.data.data.boards[0].items_page).cursor);var c={data:m,count:e};if(null!=(d=y.body)&&d.stopRes)return c;h.send(c)}else h.status(400).json({err:"Invalid Security Configuration"})}else h.status(400).json({err:"Invalid Fields"})}catch(e){h.status(400).json({err:e})}}),this.initUpdate=(u,l)=>__awaiter(this,void 0,void 0,function*(){var e;try{if(this.modelChecker(u.body.data)&&u.body.id){var t=`query {
228
+ }`;
229
+ }
230
+ }
231
+ mondayResponse = yield (0, exports.queryMondayApi)(this.mondayToken, query);
232
+ if (cursorQuery) {
233
+ mondayDataList = mondayResponse.data.data.next_items_page.items;
234
+ }
235
+ else {
236
+ if (reqQuery && reqQuery.length > 0) {
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;
243
+ }
244
+ let validOpsConfig = true;
245
+ const dataList = [];
246
+ mondayDataList.map((eachMondayData) => {
247
+ const eachData = this.parseModel(eachMondayData);
248
+ dataList.push(eachData);
249
+ if (!(0, QueryModel_1.checkOpsConfig)(this.config, "read", req, eachData)) {
250
+ validOpsConfig = false;
251
+ }
252
+ });
253
+ if (!validBaseConfig || !validOpsConfig) {
254
+ res.status(400).json({ err: "Invalid Security Configuration" });
255
+ return;
256
+ }
257
+ let cursor = null;
258
+ if (dataList.length === req.body.limit) {
259
+ if (cursorQuery) {
260
+ cursor = mondayResponse.data.data.next_items_page.cursor;
261
+ }
262
+ else {
263
+ if (reqQuery && reqQuery.length > 0) {
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;
269
+ }
270
+ }
271
+ const resBody = {
272
+ data: dataList,
273
+ count: cursor,
274
+ };
275
+ if ((_d = req.body) === null || _d === void 0 ? void 0 : _d.stopRes)
276
+ return resBody;
277
+ res.send(resBody);
278
+ }
279
+ else {
280
+ res.status(400).json({ err: "Invalid Fields" });
281
+ }
282
+ }
283
+ catch (err) {
284
+ res.status(400).json({ err: err });
285
+ }
286
+ });
287
+ this.initUpdate = (req, res) => __awaiter(this, void 0, void 0, function* () {
288
+ var _e;
289
+ try {
290
+ const valid = this.modelChecker(req.body.data) && req.body.id;
291
+ if (valid) {
292
+ const getQuery = `query {
56
293
  boards(ids: ${this.boardId}) {
57
- items_page (limit: 1, query_params: {ids:${u.body.id}}) {
294
+ items_page (limit: 1, query_params: {ids:${req.body.id}}) {
58
295
  cursor
59
296
  items {
60
297
  id
@@ -67,7 +304,20 @@
67
304
  }
68
305
  }
69
306
  }
70
- }`,i=(yield(0,exports.queryMondayApi)(this.mondayToken,t)).data.data.boards[0].items_page.items;if(i.length<=0)throw"Error";var a=this.parseModel(i[0]),s=(0,QueryModel_1.checkBaseConfig)(this.config,u),o=(0,QueryModel_1.checkOpsConfig)(this.config,"update",u,a);if(s&&o){const r=u.body.data,n={boardId:this.boardId,itemId:u.body.id,columnValues:{}};Object.keys(r).map(t=>{if("id"!==t){var i=this.modelType().write;let e="";(e=i[t]?i[t]:e)?n.columnValues[t]={[e]:r[t]}:n.columnValues[t]=r[t]}}),n.columnValues=JSON.stringify(n.columnValues),yield(0,exports.queryMondayApi)(this.mondayToken,`
307
+ }`;
308
+ const getMondayResponse = yield (0, exports.queryMondayApi)(this.mondayToken, getQuery);
309
+ const mondayData = getMondayResponse.data.data.boards[0].items_page.items;
310
+ if (mondayData.length <= 0)
311
+ throw "Error";
312
+ const parsedData = this.parseModel(mondayData[0]);
313
+ //INFO : Security Checker
314
+ const validBaseConfig = (0, QueryModel_1.checkBaseConfig)(this.config, req);
315
+ const validOpsConfig = (0, QueryModel_1.checkOpsConfig)(this.config, "update", req, parsedData);
316
+ if (!validBaseConfig || !validOpsConfig) {
317
+ res.status(400).json({ err: "Invalid Security Configuration" });
318
+ return;
319
+ }
320
+ const query = `
71
321
  mutation ($boardId: ID!, $itemId: ID!, $columnValues: JSON!) {
72
322
  change_multiple_column_values(
73
323
  item_id: $itemId,
@@ -77,9 +327,50 @@
77
327
  id
78
328
  }
79
329
  }
80
- `,n);var d={success:!0};if(null!=(e=u.body)&&e.stopRes)return d;l.send(d)}else l.status(400).json({err:"Invalid Security Configuration"})}else l.status(400).json({err:"Invalid Fields"})}catch(e){l.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 {
330
+ `;
331
+ const data = req.body.data;
332
+ const variables = {
333
+ boardId: this.boardId,
334
+ itemId: req.body.id,
335
+ columnValues: {},
336
+ };
337
+ Object.keys(data).map((eachKey) => {
338
+ if (eachKey === "id")
339
+ return;
340
+ const modelType = this.modelType().write;
341
+ let typeAvailable = "";
342
+ if (modelType[eachKey])
343
+ typeAvailable = modelType[eachKey];
344
+ if (typeAvailable)
345
+ variables["columnValues"][eachKey] = {
346
+ [typeAvailable]: data[eachKey],
347
+ };
348
+ else
349
+ variables["columnValues"][eachKey] = data[eachKey];
350
+ });
351
+ variables["columnValues"] = JSON.stringify(variables["columnValues"]);
352
+ yield (0, exports.queryMondayApi)(this.mondayToken, query, variables);
353
+ const resBody = { success: true };
354
+ if ((_e = req.body) === null || _e === void 0 ? void 0 : _e.stopRes)
355
+ return resBody;
356
+ res.send(resBody);
357
+ }
358
+ else {
359
+ res.status(400).json({ err: "Invalid Fields" });
360
+ }
361
+ }
362
+ catch (err) {
363
+ res.status(400).json({ err: err });
364
+ }
365
+ });
366
+ this.initDelete = (req, res, workflow) => __awaiter(this, void 0, void 0, function* () {
367
+ var _f;
368
+ try {
369
+ const valid = req.body.id;
370
+ if (valid) {
371
+ const getQuery = `query {
81
372
  boards(ids: ${this.boardId}) {
82
- items_page (limit: 1, query_params: {ids:${n.body.id}}) {
373
+ items_page (limit: 1, query_params: {ids:${req.body.id}}) {
83
374
  cursor
84
375
  items {
85
376
  id
@@ -92,10 +383,92 @@
92
383
  }
93
384
  }
94
385
  }
95
- }`,i=(yield(0,exports.queryMondayApi)(this.mondayToken,t)).data.data.boards[0].items_page.items;if(i.length<=0)throw"Error";var a=this.parseModel(i[0]),s=(0,QueryModel_1.checkBaseConfig)(this.config,n),o=(0,QueryModel_1.checkOpsConfig)(this.config,"delete",n,a);if(s&&o){l&&(yield l(a));var d={itemId:n.body.id},r=(yield(0,exports.queryMondayApi)(this.mondayToken,`
386
+ }`;
387
+ const getMondayResponse = yield (0, exports.queryMondayApi)(this.mondayToken, getQuery);
388
+ const mondayData = getMondayResponse.data.data.boards[0].items_page.items;
389
+ if (mondayData.length <= 0)
390
+ throw "Error";
391
+ const parsedData = this.parseModel(mondayData[0]);
392
+ const validBaseConfig = (0, QueryModel_1.checkBaseConfig)(this.config, req);
393
+ const validOpsConfig = (0, QueryModel_1.checkOpsConfig)(this.config, "delete", req, parsedData);
394
+ if (!validBaseConfig || !validOpsConfig) {
395
+ res.status(400).json({ err: "Invalid Security Configuration" });
396
+ return;
397
+ }
398
+ if (workflow)
399
+ yield workflow(parsedData);
400
+ const query = `
96
401
  mutation ($itemId: ID!){
97
402
  delete_item (item_id: $itemId) {
98
403
  id
99
404
  }
100
405
  }
101
- `,d),{success:!0});if(null!=(e=n.body)&&e.stopRes)return r;u.send(r)}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=i,this.config=a,this.modelChecker=s,this.modelType=o,this.lib=d}}exports.MondayWrapper=MondayWrapper;
406
+ `;
407
+ const variables = {
408
+ itemId: req.body.id,
409
+ };
410
+ yield (0, exports.queryMondayApi)(this.mondayToken, query, variables);
411
+ const resBody = { success: true };
412
+ if ((_f = req.body) === null || _f === void 0 ? void 0 : _f.stopRes)
413
+ return resBody;
414
+ res.send(resBody);
415
+ }
416
+ else {
417
+ res.status(400).json({ err: "Invalid Model Structure" });
418
+ }
419
+ }
420
+ catch (err) {
421
+ res.status(400).json({ err: err });
422
+ }
423
+ });
424
+ this.init = () => {
425
+ const router = this.lib.express.Router();
426
+ /**
427
+ * @Input :
428
+ * data - Model
429
+ */
430
+ router.post("/create", (req, res) => {
431
+ this.initCreate(req, res);
432
+ });
433
+ /**
434
+ * @Input :
435
+ * id - string
436
+ */
437
+ router.post("/get", (req, res) => {
438
+ this.initGet(req, res);
439
+ });
440
+ /**
441
+ * @Input
442
+ * query - Query interface (Optional)
443
+ * limit - number (Optional)
444
+ */
445
+ router.post("/list", (req, res) => {
446
+ this.initList(req, res);
447
+ });
448
+ /**
449
+ * @Input :
450
+ * data - Model
451
+ * id - string
452
+ */
453
+ router.post("/update", (req, res) => {
454
+ this.initUpdate(req, res);
455
+ });
456
+ /**
457
+ * @Input :
458
+ * id - string
459
+ */
460
+ router.post("/delete", (req, res) => {
461
+ this.initDelete(req, res);
462
+ });
463
+ return router;
464
+ };
465
+ this.mondayToken = mondayToken;
466
+ this.boardId = boardId;
467
+ this.groupId = groupId;
468
+ this.config = config;
469
+ this.modelChecker = modelChecker;
470
+ this.modelType = modelType;
471
+ this.lib = lib;
472
+ }
473
+ }
474
+ exports.MondayWrapper = MondayWrapper;