@webresto/graphql 1.3.0 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/package.json +25 -8
  2. package/src/additionalResolvers.js +1 -1
  3. package/src/additionalResolvers.ts +1 -1
  4. package/src/graphql.js +40 -22
  5. package/src/graphql.ts +42 -25
  6. package/src/resolvers/cart.d.ts +229 -9
  7. package/src/resolvers/cart.js +27 -7
  8. package/src/resolvers/cart.ts +29 -8
  9. package/src/resolvers/checkout.ts +1 -0
  10. package/test/{_bootstrap.js → bootstrap.js} +6 -7
  11. package/test/bootstrap.ts +36 -0
  12. package/test/fixture/.sailsrc +14 -0
  13. package/test/{fixtures/v0.12-app → fixture}/api/controllers/.gitkeep +0 -0
  14. package/test/{fixtures/v0.12-app → fixture}/api/models/.gitkeep +0 -0
  15. package/test/{fixtures/v0.12-app → fixture}/api/services/.gitkeep +0 -0
  16. package/test/{fixtures/v0.12-app/app.js → fixture/app-export.js} +2 -2
  17. package/test/fixture/app.js +56 -0
  18. package/test/fixture/config/adminpanel.js +25 -0
  19. package/test/fixture/config/bootstrap.js +161 -0
  20. package/test/fixture/config/connections.js +9 -0
  21. package/test/fixture/config/env/development.js +10 -0
  22. package/test/{fixtures/v0.12-app → fixture}/config/env/production.js +5 -5
  23. package/test/fixture/config/globals.js +16 -0
  24. package/test/{fixtures/v0.12-app → fixture}/config/hookTimeout.js +0 -0
  25. package/test/{fixtures/v0.12-app → fixture}/config/http.js +0 -0
  26. package/test/{fixtures/v0.12-app → fixture}/config/i18n.js +0 -0
  27. package/test/{fixtures/v0.12-app → fixture}/config/log.js +1 -1
  28. package/test/fixture/config/models.js +9 -0
  29. package/test/fixture/config/modulemanager.js +22 -0
  30. package/test/{fixtures/v0.12-app → fixture}/config/policies.js +0 -0
  31. package/test/{fixtures/v0.12-app → fixture}/config/routes.js +0 -0
  32. package/test/{fixtures/v0.12-app → fixture}/config/session.js +0 -0
  33. package/test/{fixtures/v0.12-app → fixture}/config/sockets.js +0 -0
  34. package/test/{fixtures/v0.12-app → fixture}/config/views.js +0 -0
  35. package/test/fixture/hacks/waterline.js +39 -0
  36. package/test/fixture/package.json +33 -0
  37. package/test/fixture/seeds/dish.json +37042 -0
  38. package/test/fixture/seeds/group.json +1418 -0
  39. package/test/fixture/seeds/iikoDiscount.json +365 -0
  40. package/test/{fixtures/v0.12-app → fixture}/views/403.ejs +0 -0
  41. package/test/{fixtures/v0.12-app → fixture}/views/404.ejs +0 -0
  42. package/test/{fixtures/v0.12-app → fixture}/views/500.ejs +0 -0
  43. package/test/{fixtures/v0.12-app → fixture}/views/homepage.ejs +0 -0
  44. package/test/{fixtures/v0.12-app → fixture}/views/layout.ejs +0 -0
  45. package/test/integration/graphql.test.js +11 -0
  46. package/test/integration/graphql.test.ts +15 -0
  47. package/test/{unit → integration}/sails_not_crash.test.js +0 -0
  48. package/test/integration/sails_not_crash.test.ts +3 -0
  49. package/test/unit/first.test.js +6 -8
  50. package/test/unit/first.test.ts +11 -0
  51. package/test/fixtures/v0.12-app/.gitignore +0 -11
  52. package/test/fixtures/v0.12-app/.sailsrc +0 -11
  53. package/test/fixtures/v0.12-app/api/models/TestModel.js +0 -22
  54. package/test/fixtures/v0.12-app/api/responses/badRequest.js +0 -76
  55. package/test/fixtures/v0.12-app/api/responses/created.js +0 -60
  56. package/test/fixtures/v0.12-app/api/responses/forbidden.js +0 -89
  57. package/test/fixtures/v0.12-app/api/responses/notFound.js +0 -94
  58. package/test/fixtures/v0.12-app/api/responses/ok.js +0 -60
  59. package/test/fixtures/v0.12-app/api/responses/serverError.js +0 -89
  60. package/test/fixtures/v0.12-app/config/bootstrap.js +0 -6
  61. package/test/fixtures/v0.12-app/config/connections.js +0 -5
  62. package/test/fixtures/v0.12-app/config/cors.js +0 -78
  63. package/test/fixtures/v0.12-app/config/csrf.js +0 -64
  64. package/test/fixtures/v0.12-app/config/env/development.js +0 -10
  65. package/test/fixtures/v0.12-app/config/globals.js +0 -63
  66. package/test/fixtures/v0.12-app/config/models.js +0 -3
  67. package/test/fixtures/v0.12-app/config/restoapi.js +0 -3
  68. package/test/fixtures/v0.12-app/config/restocore.js +0 -39
  69. package/test/fixtures/v0.12-app/config/stateflow.js +0 -4
  70. package/test/fixtures/v0.12-app/package.json +0 -34
package/package.json CHANGED
@@ -10,6 +10,27 @@
10
10
  "graphql": "^15.5.0",
11
11
  "waterline-criteria": "^2.0.0"
12
12
  },
13
+ "devDependencies": {
14
+ "@42pub/typed-sails": "^1.0.0",
15
+ "@types/bluebird": "^3.5.32",
16
+ "@types/bluebird-global": "^3.5.12",
17
+ "@types/body-parser": "^1.19.0",
18
+ "@types/chai": "^4.2.11",
19
+ "@types/express": "^4.17.7",
20
+ "@types/faker": "^4.1.12",
21
+ "@types/lodash": "^4.14.157",
22
+ "@types/mocha": "^8.0.2",
23
+ "@types/node": "^14.14.35",
24
+ "@types/uuid": "^8.0.0",
25
+ "@types/waterline": "^0.13.4",
26
+ "@webresto/core": "^1.0.0",
27
+ "chai": "^4.2.0",
28
+ "dotenv": "^16.0.0",
29
+ "faker": "^4.1.0",
30
+ "mocha": "^8.1.1",
31
+ "ts-node": "^10.7.0",
32
+ "typescript": "^3.9.7"
33
+ },
13
34
  "deprecated": false,
14
35
  "description": "Webresto graphql api",
15
36
  "directories": {
@@ -35,13 +56,9 @@
35
56
  },
36
57
  "scripts": {
37
58
  "gendoc": "apidoc -o apidoc/ && apidoc-markdown2 -p apidoc -o docs/api.md",
38
- "test": "echo \"Error: no test specified\" && exit 1",
39
- "test:js": "mocha test/_bootstrap.js test/**/*.test.js",
40
- "test:init": "cd ./test/fixtures/v0.12-app && npm i --no-package-lock --prefix ./ && cd -"
59
+ "test": "mocha -r ts-node/register test/bootstrap.ts './test/{,!(fixture)/**}/*.test.ts' --exit",
60
+ "test:js": "mocha test/bootstrap.js './test/{,!(fixture)/**}/*.test.js' --exit",
61
+ "test:init": "cd ./test/fixture && npm i --no-package-lock --prefix ./ && cd -"
41
62
  },
42
- "version": "1.3.0",
43
- "devDependencies": {
44
- "@types/node": "^14.14.35",
45
- "@webresto/core": "^1.0.0"
46
- }
63
+ "version": "1.3.3"
47
64
  }
@@ -46,7 +46,7 @@ exports.additionalResolver = {
46
46
  },
47
47
  OrderModifier: {
48
48
  dish: async (parent, args, context, info) => {
49
- return (await Dish.find({ id: parent.id, balance: { "!": 0 }, isDeleted: false }).populateAll())[0];
49
+ return (await Dish.find({ id: parent.id, balance: { "!=": 0 }, isDeleted: false }).populateAll())[0];
50
50
  },
51
51
  group: async (parent, args) => {
52
52
  return (await Group.find({ id: parent.groupId, isDeleted: false }).populateAll())[0];
@@ -43,7 +43,7 @@ export const additionalResolver = {
43
43
 
44
44
  OrderModifier: {
45
45
  dish: async (parent, args, context, info) => {
46
- return (await Dish.find({id: parent.id, balance: { "!": 0 }, isDeleted: false}).populateAll())[0];
46
+ return (await Dish.find({id: parent.id, balance: { "!=": 0 }, isDeleted: false}).populateAll())[0];
47
47
  },
48
48
  group: async (parent, args) => {
49
49
  return (await Group.find({id: parent.groupId, isDeleted: false}).populateAll())[0];
package/src/graphql.js CHANGED
@@ -65,6 +65,11 @@ exports.default = {
65
65
  type: String
66
66
  message: String
67
67
  }
68
+ type Street {
69
+ id: String
70
+ name: String
71
+ customData: Json
72
+ }
68
73
  type Action {
69
74
  type: String
70
75
  data: Json
@@ -98,6 +103,13 @@ exports.default = {
98
103
  type Subscription {
99
104
  _root: String
100
105
  }`);
106
+ /**
107
+ * Discount fields global support
108
+ */
109
+ helper.addCustomField("Dish", "discountAmount: Float");
110
+ helper.addCustomField("Dish", "discountType: String");
111
+ helper.addCustomField("Dish", "oldPrice: Float");
112
+ helper.addCustomField("Group", "discount: String");
101
113
  const { typeDefs, resolvers } = helper.getSchema();
102
114
  getEmitter_1.default().on('core-order-after-count', 'graphql', function (order) {
103
115
  pubsub.publish("order-changed", order);
@@ -114,30 +126,36 @@ exports.default = {
114
126
  getEmitter_1.default().on("core-maintenance-disabled", "graphql", function () {
115
127
  pubsub.publish("maintenance", null);
116
128
  });
117
- const apolloServer = new ApolloServer({
118
- typeDefs,
119
- resolvers: [resolvers, AdditionalResolvers],
120
- subscriptions: {
121
- onConnect: (connectionParams, webSocket) => {
122
- let exContext = {};
123
- if (connectionParams) {
124
- if (!connectionParams['authorization'] && connectionParams['Authorization'])
125
- connectionParams['authorization'] = connectionParams['Authorization'];
126
- exContext['connectionParams'] = connectionParams;
127
- }
128
- exContext['pubsub'] = pubsub;
129
- return exContext;
129
+ let apolloServer;
130
+ try {
131
+ apolloServer = new ApolloServer({
132
+ typeDefs,
133
+ resolvers: [resolvers, AdditionalResolvers],
134
+ subscriptions: {
135
+ onConnect: (connectionParams, webSocket) => {
136
+ let exContext = {};
137
+ if (connectionParams) {
138
+ if (!connectionParams['authorization'] && connectionParams['Authorization'])
139
+ connectionParams['authorization'] = connectionParams['Authorization'];
140
+ exContext['connectionParams'] = connectionParams;
141
+ }
142
+ exContext['pubsub'] = pubsub;
143
+ return exContext;
144
+ },
130
145
  },
131
- },
132
- context: async ({ req, connection }) => {
133
- if (connection) {
134
- return connection.context;
135
- }
136
- else {
137
- return { ...req };
146
+ context: async ({ req, connection }) => {
147
+ if (connection) {
148
+ return connection.context;
149
+ }
150
+ else {
151
+ return { ...req };
152
+ }
138
153
  }
139
- }
140
- });
154
+ });
155
+ }
156
+ catch (error) {
157
+ console.error("GraphQL start error: ", error);
158
+ }
141
159
  server = apolloServer;
142
160
  return apolloServer;
143
161
  }
package/src/graphql.ts CHANGED
@@ -74,6 +74,11 @@ export default {
74
74
  type: String
75
75
  message: String
76
76
  }
77
+ type Street {
78
+ id: String
79
+ name: String
80
+ customData: Json
81
+ }
77
82
  type Action {
78
83
  type: String
79
84
  data: Json
@@ -110,6 +115,14 @@ export default {
110
115
  type Subscription {
111
116
  _root: String
112
117
  }`);
118
+
119
+ /**
120
+ * Discount fields global support
121
+ */
122
+ helper.addCustomField("Dish", "discountAmount: Float")
123
+ helper.addCustomField("Dish", "discountType: String")
124
+ helper.addCustomField("Dish", "oldPrice: Float")
125
+ helper.addCustomField("Group", "discount: String")
113
126
 
114
127
  const { typeDefs, resolvers } = helper.getSchema();
115
128
 
@@ -128,31 +141,35 @@ export default {
128
141
  getEmitter().on("core-maintenance-disabled", "graphql", function () {
129
142
  pubsub.publish("maintenance", null);
130
143
  });
131
-
132
- const apolloServer = new ApolloServer({
133
- typeDefs,
134
- resolvers: [resolvers, AdditionalResolvers],
135
- subscriptions: {
136
- onConnect: (connectionParams, webSocket) => {
137
- let exContext = {}
138
- if (connectionParams) {
139
- if (!connectionParams['authorization'] && connectionParams['Authorization'])
140
- connectionParams['authorization'] = connectionParams['Authorization'];
141
-
142
- exContext['connectionParams'] = connectionParams
143
- }
144
- exContext['pubsub'] = pubsub;
145
- return exContext;
146
- },
147
- },
148
- context: async ({ req , connection}) => {
149
- if (connection) {
150
- return connection.context;
151
- } else {
152
- return { ...req };
153
- }
154
- }
155
- });
144
+ let apolloServer
145
+ try {
146
+ apolloServer = new ApolloServer({
147
+ typeDefs,
148
+ resolvers: [resolvers, AdditionalResolvers],
149
+ subscriptions: {
150
+ onConnect: (connectionParams, webSocket) => {
151
+ let exContext = {}
152
+ if (connectionParams) {
153
+ if (!connectionParams['authorization'] && connectionParams['Authorization'])
154
+ connectionParams['authorization'] = connectionParams['Authorization'];
155
+
156
+ exContext['connectionParams'] = connectionParams
157
+ }
158
+ exContext['pubsub'] = pubsub;
159
+ return exContext;
160
+ },
161
+ },
162
+ context: async ({ req , connection}) => {
163
+ if (connection) {
164
+ return connection.context;
165
+ } else {
166
+ return { ...req };
167
+ }
168
+ }
169
+ });
170
+ } catch (error) {
171
+ console.error("GraphQL start error: ", error)
172
+ }
156
173
 
157
174
  server = apolloServer;
158
175
  return apolloServer;
@@ -6,7 +6,6 @@ declare const _default: {
6
6
  id: string;
7
7
  shortId: string;
8
8
  dishes: number[] | import("@webresto/core/models/OrderDish").default[];
9
- discount: any;
10
9
  paymentMethod: any;
11
10
  paymentMethodTitle: string;
12
11
  paid: {
@@ -38,8 +37,9 @@ declare const _default: {
38
37
  deliveryItem: any;
39
38
  deliveryCost: number;
40
39
  totalWeight: number;
41
- total: number;
42
40
  trifleFrom: number;
41
+ bonusesTotal: number;
42
+ total: number;
43
43
  orderTotal: number;
44
44
  discountTotal: number;
45
45
  orderDate: string;
@@ -52,23 +52,243 @@ declare const _default: {
52
52
  Mutation: {
53
53
  orderAddDish: {
54
54
  def: string;
55
- fn: (parent: any, args: any, context: any) => Promise<import("@webresto/core/models/Order").default>;
55
+ fn: (parent: any, args: any, context: any) => Promise<{
56
+ id: string;
57
+ shortId: string;
58
+ dishes: number[] | import("@webresto/core/models/OrderDish").default[];
59
+ paymentMethod: any;
60
+ paymentMethodTitle: string;
61
+ paid: {
62
+ type: string;
63
+ defaultsTo: boolean;
64
+ };
65
+ isPaymentPromise: boolean;
66
+ dishesCount: number;
67
+ uniqueDishes: number;
68
+ modifiers: any;
69
+ customer: any;
70
+ address: any;
71
+ comment: string;
72
+ personsCount: string;
73
+ date: string;
74
+ problem: boolean;
75
+ rmsDelivered: boolean;
76
+ rmsId: string;
77
+ rmsOrderNumber: string;
78
+ rmsOrderData: any;
79
+ rmsDeliveryDate: string;
80
+ rmsErrorMessage: string;
81
+ rmsErrorCode: string;
82
+ rmsStatusCode: string;
83
+ deliveryStatus: string;
84
+ selfService: boolean;
85
+ deliveryDescription: string;
86
+ message: string;
87
+ deliveryItem: any;
88
+ deliveryCost: number;
89
+ totalWeight: number;
90
+ trifleFrom: number;
91
+ bonusesTotal: number;
92
+ total: number;
93
+ orderTotal: number;
94
+ discountTotal: number;
95
+ orderDate: string;
96
+ customData: any;
97
+ state: string;
98
+ toJSON(): any;
99
+ }>;
56
100
  };
57
101
  orderReplaceDish: {
58
102
  def: string;
59
- fn: (parent: any, args: any, context: any) => Promise<import("@webresto/core/models/Order").default>;
103
+ fn: (parent: any, args: any, context: any) => Promise<{
104
+ id: string;
105
+ shortId: string;
106
+ dishes: number[] | import("@webresto/core/models/OrderDish").default[];
107
+ paymentMethod: any;
108
+ paymentMethodTitle: string;
109
+ paid: {
110
+ type: string;
111
+ defaultsTo: boolean;
112
+ };
113
+ isPaymentPromise: boolean;
114
+ dishesCount: number;
115
+ uniqueDishes: number;
116
+ modifiers: any;
117
+ customer: any;
118
+ address: any;
119
+ comment: string;
120
+ personsCount: string;
121
+ date: string;
122
+ problem: boolean;
123
+ rmsDelivered: boolean;
124
+ rmsId: string;
125
+ rmsOrderNumber: string;
126
+ rmsOrderData: any;
127
+ rmsDeliveryDate: string;
128
+ rmsErrorMessage: string;
129
+ rmsErrorCode: string;
130
+ rmsStatusCode: string;
131
+ deliveryStatus: string;
132
+ selfService: boolean;
133
+ deliveryDescription: string;
134
+ message: string;
135
+ deliveryItem: any;
136
+ deliveryCost: number;
137
+ totalWeight: number;
138
+ trifleFrom: number;
139
+ bonusesTotal: number;
140
+ total: number;
141
+ orderTotal: number;
142
+ discountTotal: number;
143
+ orderDate: string;
144
+ customData: any;
145
+ state: string;
146
+ toJSON(): any;
147
+ }>;
60
148
  };
61
149
  orderRemoveDish: {
62
150
  def: string;
63
- fn: (parent: any, args: any, context: any) => Promise<import("@webresto/core/models/Order").default>;
151
+ fn: (parent: any, args: any, context: any) => Promise<{
152
+ id: string;
153
+ shortId: string;
154
+ dishes: number[] | import("@webresto/core/models/OrderDish").default[];
155
+ paymentMethod: any;
156
+ paymentMethodTitle: string;
157
+ paid: {
158
+ type: string;
159
+ defaultsTo: boolean;
160
+ };
161
+ isPaymentPromise: boolean;
162
+ dishesCount: number;
163
+ uniqueDishes: number;
164
+ modifiers: any;
165
+ customer: any;
166
+ address: any;
167
+ comment: string;
168
+ personsCount: string;
169
+ date: string;
170
+ problem: boolean;
171
+ rmsDelivered: boolean;
172
+ rmsId: string;
173
+ rmsOrderNumber: string;
174
+ rmsOrderData: any;
175
+ rmsDeliveryDate: string;
176
+ rmsErrorMessage: string;
177
+ rmsErrorCode: string;
178
+ rmsStatusCode: string;
179
+ deliveryStatus: string;
180
+ selfService: boolean;
181
+ deliveryDescription: string;
182
+ message: string;
183
+ deliveryItem: any;
184
+ deliveryCost: number;
185
+ totalWeight: number;
186
+ trifleFrom: number;
187
+ bonusesTotal: number;
188
+ total: number;
189
+ orderTotal: number;
190
+ discountTotal: number;
191
+ orderDate: string;
192
+ customData: any;
193
+ state: string;
194
+ toJSON(): any;
195
+ }>;
64
196
  };
65
197
  orderSetDishAmount: {
66
198
  def: string;
67
- fn: (parent: any, args: any, context: any) => Promise<import("@webresto/core/models/Order").default>;
199
+ fn: (parent: any, args: any, context: any) => Promise<{
200
+ id: string;
201
+ shortId: string;
202
+ dishes: number[] | import("@webresto/core/models/OrderDish").default[];
203
+ paymentMethod: any;
204
+ paymentMethodTitle: string;
205
+ paid: {
206
+ type: string;
207
+ defaultsTo: boolean;
208
+ };
209
+ isPaymentPromise: boolean;
210
+ dishesCount: number;
211
+ uniqueDishes: number;
212
+ modifiers: any;
213
+ customer: any;
214
+ address: any;
215
+ comment: string;
216
+ personsCount: string;
217
+ date: string;
218
+ problem: boolean;
219
+ rmsDelivered: boolean;
220
+ rmsId: string;
221
+ rmsOrderNumber: string;
222
+ rmsOrderData: any;
223
+ rmsDeliveryDate: string;
224
+ rmsErrorMessage: string;
225
+ rmsErrorCode: string;
226
+ rmsStatusCode: string;
227
+ deliveryStatus: string;
228
+ selfService: boolean;
229
+ deliveryDescription: string;
230
+ message: string;
231
+ deliveryItem: any;
232
+ deliveryCost: number;
233
+ totalWeight: number;
234
+ trifleFrom: number;
235
+ bonusesTotal: number;
236
+ total: number;
237
+ orderTotal: number;
238
+ discountTotal: number;
239
+ orderDate: string;
240
+ customData: any;
241
+ state: string;
242
+ toJSON(): any;
243
+ }>;
68
244
  };
69
245
  orderSetDishComment: {
70
246
  def: string;
71
- fn: (parent: any, args: any, context: any) => Promise<import("@webresto/core/models/Order").default>;
247
+ fn: (parent: any, args: any, context: any) => Promise<{
248
+ id: string;
249
+ shortId: string;
250
+ dishes: number[] | import("@webresto/core/models/OrderDish").default[];
251
+ paymentMethod: any;
252
+ paymentMethodTitle: string;
253
+ paid: {
254
+ type: string;
255
+ defaultsTo: boolean;
256
+ };
257
+ isPaymentPromise: boolean;
258
+ dishesCount: number;
259
+ uniqueDishes: number;
260
+ modifiers: any;
261
+ customer: any;
262
+ address: any;
263
+ comment: string;
264
+ personsCount: string;
265
+ date: string;
266
+ problem: boolean;
267
+ rmsDelivered: boolean;
268
+ rmsId: string;
269
+ rmsOrderNumber: string;
270
+ rmsOrderData: any;
271
+ rmsDeliveryDate: string;
272
+ rmsErrorMessage: string;
273
+ rmsErrorCode: string;
274
+ rmsStatusCode: string;
275
+ deliveryStatus: string;
276
+ selfService: boolean;
277
+ deliveryDescription: string;
278
+ message: string;
279
+ deliveryItem: any;
280
+ deliveryCost: number;
281
+ totalWeight: number;
282
+ trifleFrom: number;
283
+ bonusesTotal: number;
284
+ total: number;
285
+ orderTotal: number;
286
+ discountTotal: number;
287
+ orderDate: string;
288
+ customData: any;
289
+ state: string;
290
+ toJSON(): any;
291
+ }>;
72
292
  };
73
293
  orderUpdate: {
74
294
  def: string;
@@ -76,7 +296,6 @@ declare const _default: {
76
296
  id: string;
77
297
  shortId: string;
78
298
  dishes: number[] | import("@webresto/core/models/OrderDish").default[];
79
- discount: any;
80
299
  paymentMethod: any;
81
300
  paymentMethodTitle: string;
82
301
  paid: {
@@ -108,8 +327,9 @@ declare const _default: {
108
327
  deliveryItem: any;
109
328
  deliveryCost: number;
110
329
  totalWeight: number;
111
- total: number;
112
330
  trifleFrom: number;
331
+ bonusesTotal: number;
332
+ total: number;
113
333
  orderTotal: number;
114
334
  discountTotal: number;
115
335
  orderDate: string;
@@ -27,7 +27,9 @@ exports.default = {
27
27
  sails.log.error("GQL > order resolver error: ", `order with id ${args.orderId} . Trying make new cart.`);
28
28
  order = await getNewCart(args.orderId);
29
29
  }
30
- return await Order.populate(order.id);
30
+ let fullOrder = await Order.populate(order.id);
31
+ getEmitter_1.default().emit("http-api:before-response-order", fullOrder);
32
+ return fullOrder;
31
33
  },
32
34
  },
33
35
  },
@@ -65,7 +67,10 @@ exports.default = {
65
67
  }
66
68
  }
67
69
  await Order.addDish(order.id, args.dishId, args.amount, args.modifiers || [], args.comment, args.from, args.replace, args.orderDishId);
68
- return await Order.countCart(order);
70
+ await Order.countCart(order);
71
+ let fullOrder = await Order.populate(order.id);
72
+ getEmitter_1.default().emit("http-api:before-response-order-add-dish", fullOrder);
73
+ return fullOrder;
69
74
  },
70
75
  },
71
76
  orderReplaceDish: {
@@ -82,7 +87,10 @@ exports.default = {
82
87
  order = await getNewCart();
83
88
  }
84
89
  await Order.addDish(order.id, args.dishId, args.amount, args.modifiers || [], args.comment, args.from, args.replace, args.orderDishId);
85
- return await Order.countCart(order);
90
+ await Order.countCart(order);
91
+ let fullOrder = await Order.populate(order.id);
92
+ getEmitter_1.default().emit("http-api:before-response-order-replace-dish", fullOrder);
93
+ return fullOrder;
86
94
  },
87
95
  },
88
96
  orderRemoveDish: {
@@ -99,7 +107,10 @@ exports.default = {
99
107
  }
100
108
  const orderDish = await OrderDish.findOne({ id: args.orderDishId });
101
109
  await Order.removeDish(order.id, orderDish, args.amount, false);
102
- return await Order.countCart(order);
110
+ await Order.countCart(order);
111
+ let fullOrder = await Order.populate(order.id);
112
+ getEmitter_1.default().emit("http-api:before-response-order-remove-dish", fullOrder);
113
+ return fullOrder;
103
114
  },
104
115
  },
105
116
  orderSetDishAmount: {
@@ -120,7 +131,10 @@ exports.default = {
120
131
  if (!dish.dish)
121
132
  throw new errorWrapper_1.Error(0, "ERROR", `Dish in OrderDish with id ${args.orderDishId} not found`);
122
133
  await Order.setCount(order.id, dish, args.amount);
123
- return await Order.countCart(order);
134
+ await Order.countCart(order);
135
+ let fullOrder = await Order.populate(order.id);
136
+ getEmitter_1.default().emit("http-api:before-response-order-set-dish-amount", fullOrder);
137
+ return fullOrder;
124
138
  },
125
139
  },
126
140
  orderSetDishComment: {
@@ -147,7 +161,10 @@ exports.default = {
147
161
  throw new errorWrapper_1.Error(0, "ERROR", `Dish with id ${dishId} not found`);
148
162
  }
149
163
  await order.setComment(dish, comment);
150
- return await Order.countCart(order);
164
+ await Order.countCart(order);
165
+ let fullOrder = await Order.populate(order.id);
166
+ getEmitter_1.default().emit("http-api:before-response-order-set-dish-comment", fullOrder);
167
+ return fullOrder;
151
168
  },
152
169
  },
153
170
  orderUpdate: {
@@ -157,7 +174,10 @@ exports.default = {
157
174
  if (!order.id)
158
175
  throw "order.id field is required";
159
176
  await Order.update({ id: order.id }, { trifleFrom: order.trifleFrom });
160
- return await Order.populate(order.id);
177
+ await Order.populate(order.id);
178
+ let fullOrder = await Order.populate(order.id);
179
+ getEmitter_1.default().emit("http-api:before-response-order-update", fullOrder);
180
+ return fullOrder;
161
181
  },
162
182
  },
163
183
  },