@webresto/graphql 1.3.6 → 1.3.8

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 (142) hide show
  1. package/.gitattributes +2 -0
  2. package/.gitlab-ci.yml +18 -0
  3. package/.vscode/extensions.json +5 -0
  4. package/docs/actions.md +25 -0
  5. package/docs/authorization.md +215 -0
  6. package/docs/captcha.md +71 -0
  7. package/docs/device-id.md +30 -0
  8. package/docs/messages.md +10 -0
  9. package/docs/user.md +54 -0
  10. package/index.d.ts +0 -1
  11. package/index.js +6 -2
  12. package/index.ts +2 -2
  13. package/lib/afterHook.js +8 -0
  14. package/lib/afterHook.ts +9 -0
  15. package/lib/bindTranslations.d.ts +1 -0
  16. package/lib/bindTranslations.js +40 -0
  17. package/lib/bindTranslations.ts +39 -0
  18. package/lib/defaults.d.ts +1 -0
  19. package/lib/defaults.js +49 -10
  20. package/lib/defaults.ts +55 -0
  21. package/lib/eventHelper.d.ts +14 -5
  22. package/lib/eventHelper.js +28 -9
  23. package/lib/eventHelper.ts +41 -8
  24. package/lib/getRecomended.d.ts +1 -0
  25. package/lib/getRecomended.js +29 -0
  26. package/lib/getRecomended.ts +31 -0
  27. package/lib/graphqlHelper.d.ts +3 -4
  28. package/lib/graphqlHelper.js +184 -73
  29. package/lib/graphqlHelper.ts +329 -186
  30. package/lib/jwt.d.ts +10 -0
  31. package/lib/jwt.js +43 -0
  32. package/lib/jwt.ts +61 -0
  33. package/package.json +13 -6
  34. package/src/additionalResolvers.d.ts +72 -9
  35. package/src/additionalResolvers.js +93 -24
  36. package/src/additionalResolvers.ts +105 -34
  37. package/src/graphql.d.ts +5 -3
  38. package/src/graphql.js +170 -37
  39. package/src/graphql.ts +210 -60
  40. package/src/resolvers/bonusProgram.d.ts +32 -0
  41. package/src/resolvers/bonusProgram.js +65 -0
  42. package/src/resolvers/bonusProgram.ts +79 -0
  43. package/src/resolvers/captcha.d.ts +11 -0
  44. package/src/resolvers/captcha.js +19 -0
  45. package/src/resolvers/captcha.ts +16 -0
  46. package/src/resolvers/checkout.d.ts +43 -14
  47. package/src/resolvers/checkout.js +172 -122
  48. package/src/resolvers/checkout.ts +218 -142
  49. package/src/resolvers/dishAndModifier.js +8 -4
  50. package/src/resolvers/dishAndModifier.ts +4 -0
  51. package/src/resolvers/error.d.ts +9 -0
  52. package/src/resolvers/error.js +21 -0
  53. package/src/resolvers/error.ts +21 -0
  54. package/src/resolvers/menu.d.ts +9 -0
  55. package/src/resolvers/menu.js +12 -0
  56. package/src/resolvers/menu.ts +10 -0
  57. package/src/resolvers/order.d.ts +527 -0
  58. package/src/resolvers/order.js +349 -0
  59. package/src/resolvers/order.ts +435 -0
  60. package/src/resolvers/paymentMethod.js +7 -3
  61. package/src/resolvers/paymentMethod.ts +9 -5
  62. package/src/resolvers/pickupPoint.d.ts +1 -0
  63. package/src/resolvers/pickupPoint.js +24 -0
  64. package/src/resolvers/pickupPoint.ts +23 -0
  65. package/src/resolvers/recomended.d.ts +13 -0
  66. package/src/resolvers/recomended.js +80 -0
  67. package/src/resolvers/recomended.ts +86 -0
  68. package/src/resolvers/restrictions.d.ts +37 -1
  69. package/src/resolvers/restrictions.js +100 -15
  70. package/src/resolvers/restrictions.ts +106 -14
  71. package/src/resolvers/streets.d.ts +1 -1
  72. package/src/resolvers/streets.js +1 -4
  73. package/src/resolvers/streets.ts +1 -3
  74. package/src/resolvers/subscriptions.d.ts +4 -4
  75. package/src/resolvers/subscriptions.js +49 -12
  76. package/src/resolvers/subscriptions.ts +59 -14
  77. package/src/resolvers/telemetry.d.ts +14 -0
  78. package/src/resolvers/telemetry.js +25 -0
  79. package/src/resolvers/telemetry.ts +24 -0
  80. package/src/resolvers/user.d.ts +82 -0
  81. package/src/resolvers/user.js +416 -0
  82. package/src/resolvers/user.ts +621 -0
  83. package/src/resolvers/userLocation.d.ts +53 -0
  84. package/src/resolvers/userLocation.js +74 -0
  85. package/src/resolvers/userLocation.ts +125 -0
  86. package/src/resolvers/userOTPrequest.d.ts +21 -0
  87. package/src/resolvers/userOTPrequest.js +57 -0
  88. package/src/resolvers/userOTPrequest.ts +75 -0
  89. package/test/e2e_helper.js +157 -0
  90. package/test/e2e_helper.ts +212 -0
  91. package/test/fixture/config/i18n.js +7 -20
  92. package/test/fixture/config/locales/de.json +1 -0
  93. package/test/fixture/config/locales/en.json +10 -0
  94. package/test/fixture/config/locales/es.json +3 -0
  95. package/test/fixture/config/locales/fr.json +1 -0
  96. package/test/fixture/config/log.js +1 -1
  97. package/test/fixture/package.json +5 -6
  98. package/test/fixture/patches/rttc+10.0.1.patch +17 -0
  99. package/test/integration/captcha.test.js +20 -0
  100. package/test/integration/captcha.test.ts +25 -0
  101. package/test/integration/dish.test.js +35 -0
  102. package/test/integration/dish.test.ts +43 -0
  103. package/test/integration/graphql.test.js +5 -2
  104. package/test/integration/graphql.test.ts +2 -4
  105. package/test/integration/images.test.js +35 -0
  106. package/test/integration/images.test.ts +40 -0
  107. package/test/integration/locale.test.js +26 -0
  108. package/test/integration/locale.test.ts +32 -0
  109. package/test/integration/order.test.js +56 -43
  110. package/test/integration/order.test.ts +59 -59
  111. package/test/integration/subscriptions.test.js +136 -0
  112. package/test/integration/subscriptions.test.ts +162 -0
  113. package/test/integration/user.test.js +249 -0
  114. package/test/integration/user.test.ts +299 -0
  115. package/test/unit/first.test.js +4 -2
  116. package/test/unit/first.test.ts +1 -1
  117. package/test/unit/get-recomended.test.js +56 -0
  118. package/test/unit/get-recomended.test.ts +63 -0
  119. package/translations/de.json +2 -0
  120. package/translations/en.json +3 -0
  121. package/translations/es.json +3 -0
  122. package/translations/fr.json +2 -0
  123. package/translations/ru.json +36 -0
  124. package/tsconfig.json +20 -5
  125. package/types/global.d.ts +30 -0
  126. package/types/global.js +2 -0
  127. package/types/global.ts +31 -0
  128. package/types/primitives.d.ts +19 -0
  129. package/types/references.d.ts +1 -0
  130. package/types/restoGraphQLConfig.d.ts +13 -0
  131. package/lib/afterHook.ts___graphql-transport-ws +0 -138
  132. package/lib/afterHook.ts___graphql-ws +0 -133
  133. package/lib/errorWrapper.d.ts +0 -4
  134. package/lib/errorWrapper.js +0 -13
  135. package/lib/errorWrapper.ts +0 -12
  136. package/notes.md +0 -1976
  137. package/src/resolvers/cart.d.ts +0 -343
  138. package/src/resolvers/cart.js +0 -196
  139. package/src/resolvers/cart.ts +0 -277
  140. package/test/fixture/config/connections.js +0 -9
  141. package/test/integration/sails_not_crash.test.js +0 -3
  142. package/test/integration/sails_not_crash.test.ts +0 -3
@@ -1,12 +1,74 @@
1
1
  import * as eventHelper from "../../lib/eventHelper";
2
- import { Error } from "../../lib/errorWrapper";
2
+ import { Action, Message } from "../../types/primitives";
3
+ import Order from "@webresto/core/models/Order"
4
+
5
+ type CheckResponse = {
6
+ order?: Order
7
+ message: Message
8
+ action?: Action
9
+ }
10
+
11
+ import graphqlHelper from "../../lib/graphqlHelper";
12
+ import Address from "@webresto/core/interfaces/Address";
13
+ import Customer from "@webresto/core/interfaces/Customer";
14
+ import { SpendBonus } from "@webresto/core/interfaces/SpendBonus";
15
+ import { JWTAuth } from "../../lib/jwt";
16
+
17
+
18
+ interface InputOrderCheckout {
19
+ orderId: string
20
+ paymentMethodId: string
21
+ selfService?: boolean
22
+ pickupPointId?: string
23
+ address?: Address
24
+ locationId: string
25
+ customer: Customer
26
+ date?: string
27
+ personsCount?: number
28
+ comment: string
29
+ spendBonus: SpendBonus
30
+ customData:{[key: string]: string | number}
31
+ }
32
+
33
+ graphqlHelper.addType(`#graphql
34
+ input InputOrderCheckout {
35
+ orderId: String!
36
+ paymentMethodId: String!
37
+ customer: Customer!
38
+ spendBonus: InputSpendBonus
39
+ selfService: Boolean
40
+ pickupPointId: String
41
+ locationId: String
42
+ address: Address
43
+ date: String
44
+ comment: String
45
+ personsCount: Int
46
+ customData: Json
47
+ }
48
+ `);
49
+
50
+ graphqlHelper.addType(`#graphql
51
+ input InputSpendBonus {
52
+ bonusProgramId: String!
53
+ amount: Int!
54
+ adapter: String!
55
+ bonusProgramName: String!
56
+ }
57
+ `);
58
+
59
+
3
60
 
4
61
  export default {
5
62
  Mutation: {
6
63
  checkOrder: {
7
- def: "checkOrder(orderId: String!, paymentMethodId: String!, selfService: Boolean, address: Address, customer: Customer!, date: String, comment: String, customData: Json): CheckResponse",
8
- fn: async function (parent, args, context) {
9
- let data = args;
64
+ def: `#graphql
65
+ checkOrder(orderCheckout: InputOrderCheckout): CheckResponse`,
66
+ fn: async function (parent, args: { orderCheckout: InputOrderCheckout }, context): Promise<CheckResponse> {
67
+ let data = args.orderCheckout;
68
+
69
+ if (!context.connectionParams.deviceId) {
70
+ throw `Missed deviceId`
71
+ }
10
72
 
11
73
  // if (data.date) {
12
74
  // let date = moment(data.date)
@@ -19,51 +81,79 @@ export default {
19
81
 
20
82
  let isSelfService: boolean;
21
83
 
22
- //@ts-ignore
23
- if (data.selfService || data.selfDelivery) {
24
- isSelfService = true;
25
- }
26
84
 
85
+ let message;
27
86
  try {
28
87
  var order = await Order.findOne(data.orderId);
29
-
88
+ const shouldSendSucessMessage = order.state !== "CHECKOUT"
30
89
  if (!order) {
31
- return eventHelper.sendMessage(args.orderId, {
90
+ message = eventHelper.sendMessage({
91
+ deviceId: context.connectionParams.deviceId,
32
92
  type: "error",
33
- title: "Order not found",
34
- message: `Order with id ${data.orderId} not found`,
93
+ title: context.i18n.__("Order not found"),
94
+ message: context.i18n.__("Order with id %s not found", data.orderId),
35
95
  });
36
96
  }
37
97
 
98
+ //@ts-ignore
99
+ if (data.selfService) {
100
+ isSelfService = true;
101
+ order.pickupPoint = data.pickupPointId;
102
+ } else {
103
+ order.pickupPoint = null;
104
+ if(!data.address && !data.locationId) throw `Address is required for non self service orders`
105
+ }
106
+
38
107
  if (order.state === "ORDER") {
39
- return eventHelper.sendMessage(args.orderId, {
108
+ message = eventHelper.sendMessage({
109
+ deviceId: context.connectionParams.deviceId,
40
110
  type: "error",
41
- title: "Ошибка",
42
- message: "Корзина уже заказана",
111
+ title: context.i18n.__("Error"),
112
+ message: context.i18n.__("Cart was ordered"),
43
113
  });
44
114
  }
45
115
 
46
116
  if (data.paymentMethodId) {
47
117
  if (!PaymentMethod.checkAvailable(data.paymentMethodId)) {
48
- return eventHelper.sendMessage(args.orderId, {
118
+ message = eventHelper.sendMessage({
119
+ deviceId: context.connectionParams.deviceId,
49
120
  type: "error",
50
- title: "Ошибка",
51
- message: "Проверка платежной системы завершилась неудачей",
121
+ title: context.i18n.__("Error"),
122
+ message: context.i18n.__("Checking the payment system ended in failure"),
52
123
  });
53
124
  }
54
125
  }
55
126
 
56
- if (data.address) {
57
- data.address.city =
58
- data.address.city || (await Settings.use("city"));
127
+
128
+ if (data.locationId) {
129
+ var address: Address = await UserLocation.findOne({id: data.locationId}) as Address;
130
+ if (!address) throw `locationId not found`
131
+ } else {
132
+ if (data.address) {
133
+ var address: Address = data.address;
134
+ }
135
+ }
136
+
137
+ address = {
138
+ city: address.city || (await Settings.use("city") as string),
139
+ street: address.street,
140
+ ...address.streetId && {streetId: address.streetId},
141
+ home: address.home,
142
+ ...address.housing && {housing: address.housing},
143
+ ...address.apartment && {apartment: address.apartment},
144
+ ...address.index && {index: address.index},
145
+ ...address.entrance && {entrance: address.entrance},
146
+ ...address.floor && {floor: address.floor},
147
+ ...address.apartment && {apartment: address.apartment},
148
+ ...address.comment && {comment: address.comment},
59
149
  }
60
150
 
61
- order.personsCount = data.personsCount ? data.personsCount : "";
151
+ order.personsCount = data.personsCount ? data.personsCount+"" : "";
62
152
  if (data.comment) order.comment = data.comment;
63
153
 
64
- if (data.date) order.date = data.date;
154
+ order.date = data.date;
65
155
 
66
- // callback: boolean - перезвонить для уточнения деталей
156
+ // callback: boolean -call back to clarify details
67
157
  if (data.customData && data.customData.callback) {
68
158
  if (!order.customData) order.customData = {};
69
159
  order.customData.callback = data.customData.callback;
@@ -71,176 +161,162 @@ export default {
71
161
 
72
162
  await Order.update({ id: order.id }, order).fetch();
73
163
 
164
+ let userId = null;
165
+ if (context && context.connectionParams.authorization) {
166
+ userId = (await JWTAuth.verify(context.connectionParams.authorization)).userId;
167
+ }
168
+
74
169
  await Order.check(
75
- order.id,
170
+ {id: order.id},
76
171
  data.customer,
77
172
  isSelfService,
78
173
  data.address,
79
- data.paymentMethodId
174
+ data.paymentMethodId,
175
+ userId,
176
+ data.spendBonus !== undefined && userId !== null ? data.spendBonus : null
80
177
  );
81
178
 
82
179
  order = await Order.findOne(data.orderId);
83
180
 
84
- let message;
85
-
86
- if (order.state === "CHECKOUT") {
181
+ if (order.state === "CHECKOUT" && shouldSendSucessMessage) {
87
182
  message = {
183
+ deviceId: context.connectionParams.deviceId,
88
184
  type: "info",
89
- title: "Внимание",
185
+ title: context.i18n.__("Attention"),
90
186
  message: order.message
91
- ? order.message
92
- : "Заказ готов к оформлению",
187
+ ? context.i18n.__(order.message)
188
+ : context.i18n.__("Ready for order"),
93
189
  };
94
190
 
95
191
  } else {
96
192
  if (order.message) {
97
193
  message = {
194
+ deviceId: context.connectionParams.deviceId,
98
195
  type: "error",
99
- title: "Внимание",
196
+ title: "Attention",
100
197
  message: order.message
101
- ? order.message
102
- : "Не удалось проверить заказ.",
198
+ ? context.i18n.__(order.message)
199
+ : context.i18n.__("It was not possible to check the order"),
103
200
  }
104
201
  }
105
202
  }
106
203
 
107
- eventHelper.sendMessage(args.orderId, message);
204
+ if(message){
205
+ eventHelper.sendMessage(message);
206
+ }
108
207
 
109
- return { message: message, order: order };
208
+ return {
209
+ order: order,
210
+ ...message && { message: message }
211
+ };
110
212
  } catch (e) {
111
213
  let message = {
112
214
  type: "error",
113
- title: "Ошибка",
215
+ title: context.i18n.__("Error"),
114
216
  message: "",
115
- };
217
+ } as Message;
116
218
  if (e.code === 1) {
117
- message.message = "Введите имя заказчика";
219
+ message.message = context.i18n.__("Enter the name of the customer");
118
220
  } else if (e.code === 2) {
119
- message.message = "Введите телефон заказчика";
221
+ message.message = context.i18n.__("Enter the customer's phone");
120
222
  } else if (e.code === 3) {
121
- message.message = "Неверный формат имени заказчика";
223
+ message.message = context.i18n.__("The wrong format of the name of the customer");
122
224
  } else if (e.code === 4) {
123
- message.message = "Неверный формат номера заказчика";
225
+ message.message = context.i18n.__("The wrong format of the customer number");
124
226
  } else if (e.code === 5) {
125
- message.message = "Не указана улица";
227
+ message.message = context.i18n.__("No point of Street");
126
228
  } else if (e.code === 6) {
127
- message.message = "Не указан номер дома";
229
+ message.message = context.i18n.__("Not indicated the house number");
128
230
  } else if (e.code === 7) {
129
- message.message = "Не указан город";
231
+ message.message = context.i18n.__("The city is not indicated");
130
232
  } else if (e.code === 8) {
131
- message.message = "Платежная система недоступна";
233
+ message.message = context.i18n.__("The payment system is not available");
234
+ } else if (e.code === 11) {
235
+ message.message = context.i18n.__(order.delivery.message) ;
132
236
  } else if (e.code === 10) {
133
- message.message = "Дата выполнения заказа не верная";
237
+ message.message = context.i18n.__("The date of execution of the order is not true");
238
+ } else if (e.code === 15) {
239
+ message.message = context.i18n.__("Ordering for a date in the past is not possible");
134
240
  } else {
135
241
  message.message = e.error
136
242
  ? e.error
137
- : `Проблема при проверки заказа: ${e}`;
243
+ : context.i18n.__(`Problem when checking the order: %s`, e);
138
244
  }
139
245
 
140
- eventHelper.sendMessage(args.orderId, message);
246
+ order = await Order.findOne(data.orderId);
141
247
  sails.log.error(e)
142
- return { message: message };
248
+ eventHelper.sendMessage(message);
249
+ return {
250
+ order: order,
251
+ message: message
252
+ };
143
253
  }
144
254
  },
145
255
  },
146
256
  sendOrder: {
147
257
  def: "sendOrder(orderId: String!): CheckResponse",
148
258
  fn: async function (parent, args, context) {
259
+ if (!context.connectionParams.deviceId) {
260
+ throw `Missed deviceId`;
261
+ }
149
262
  let data = args;
150
-
151
- // if (data.date) {
152
- // let date = moment(data.date)
153
- // if(!date.isValid()){
154
- // return eventHelper.sendMessage(args.orderId,"Please order.date format is ISO (YYYY-MM-DD HH:mm:ss)");
155
- // } else {
156
- // data.date = date.format('YYYY-MM-DD HH:mm:ss');
157
- // }
158
- // }
159
-
160
- try {
161
- var order = await Order.findOne({ id: data.orderId });
162
- if (!order) {
163
- const errorMessage = `Order with id ${data.orderId} not found`;
164
- eventHelper.sendMessage(args.orderId, {
165
- type: "error",
166
- title: "Order not found",
167
- message: errorMessage,
263
+
264
+ var order = await Order.findOne({ id: data.orderId });
265
+ if (!order) {
266
+ const errorMessage = context.i18n.__(`Order with id %s not found`, data.orderId);
267
+ eventHelper.sendMessage({
268
+ deviceId: context.connectionParams.deviceId,
269
+ type: "error",
270
+ title: context.i18n.__("Order not found"),
271
+ message: errorMessage,
168
272
  });
169
- sails.log.error(`${errorMessage}`)
170
- throw new Error(0,errorMessage);
171
- }
172
-
173
- // if (data.comment) order.comment = data.comment;
174
-
175
- // if (data.paymentMethodId) {
176
- // if (order.paymentMethod !== data.paymentMethodId) {
177
- // await Order.check(
178
- // order.id,
179
- // null,
180
- // null,
181
- // null,
182
- // data.paymentMethodId
183
- // );
184
- // order = await Order.findOne({ id: data.orderId });
185
- // }
186
- // }
187
-
188
- // if (order.paymentMethod) {
189
- // if (!(await PaymentMethod.checkAvailable(order.paymentMethod))) {
190
- // let errorMessage = `Проверка платежной системы завершилась неудачно`;
191
- // eventHelper.sendMessage(args.orderId, {
192
- // type: "error",
193
- // title: "Ошибка",
194
- // message: errorMessage,
195
- // });
196
- // sails.log.error(`${errorMessage}`)
197
- // throw new Error(0,errorMessage);
198
- // }
199
-
200
- // if (!(await PaymentMethod.isPaymentPromise(data.paymentMethodId))) {
201
- // try {
202
- // let paymentResponse = await order.payment();
203
- // const action = {
204
- // type: "PaymentRedirect",
205
- // data: {
206
- // redirectLink: paymentResponse.redirectLink,
207
- // },
208
- // };
209
- // eventHelper.sendAction(args.orderId, action);
210
- // return { order: order, action: action };
211
- // } catch (e) {
212
- // eventHelper.sendMessage(args.orderId, {
213
- // type: "error",
214
- // title: "Ошибка",
215
- // message: "Попытка регистрации платежа завершилась неудачно",
216
- // });
217
-
218
- // sails.log.error(e);
219
- // throw new Error(0, JSON.stringify(e));
220
- // }
221
- // }
222
- // }
223
-
224
- await Order.order(order.id);
225
- order = await Order.findOne({ id: data.orderId })
226
- const message = {
227
- type: "info",
228
- title: "Успешно",
229
- message: "Ваш заказ принят в обработку",
230
- };
231
- eventHelper.sendMessage(args.orderId, message);
232
- return { order: order, message: message };
233
- } catch (e) {
234
- eventHelper.sendMessage(args.orderId, {
235
- type: "error",
236
- title: "Ошибка",
237
- message: e,
238
- });
273
+ sails.log.error(`${errorMessage}`);
274
+ throw new Error(errorMessage);
275
+ }
276
+ if (!order.isPaymentPromise) {
277
+ try {
278
+ let paymentResponse = await Order.payment({ id: order.id });
279
+ const action = {
280
+ deviceId: context.connectionParams.deviceId,
281
+ type: "Redirect",
282
+ data: {
283
+ link: paymentResponse.redirectLink,
284
+ },
285
+ };
286
+ eventHelper.sendAction(action);
287
+ order = await Order.populate({ id: order.id });
288
+ return { order: order, action: action };
289
+ }
290
+ catch (e) {
291
+ eventHelper.sendMessage({
292
+ deviceId: context.connectionParams.deviceId,
293
+ type: "error",
294
+ title: context.i18n.__("Error"),
295
+ message: context.i18n.__("The payment of the payment has ended unsuccessfully"),
296
+ });
297
+ const error = `External payment: ${e}`
298
+ sails.log.error(error);
299
+ throw new Error(error);
300
+ }
301
+ }
239
302
 
240
- sails.log.error("sendOrder error :", e);
241
- throw new Error(0,`${e}`);
303
+ try {
304
+ await Order.order({ id: order.id });
305
+ order = await Order.findOne({ id: data.orderId });
306
+ const message = {
307
+ type: "info",
308
+ title: context.i18n.__("Successfully"),
309
+ message: context.i18n.__("Your order is accepted for processing"),
310
+ };
311
+ // eventHelper.sendMessage(message);
312
+ return { order: order, message: message };
313
+ }
314
+ catch (e) {
315
+ const error = `Order finalize error:, ${e}`
316
+ sails.log.error(error);
317
+ throw new Error(error);
242
318
  }
243
319
  },
244
320
  },
245
321
  },
246
- };
322
+ }
@@ -2,10 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const graphqlHelper_1 = require("@webresto/graphql/lib/graphqlHelper");
4
4
  // init
5
- graphqlHelper_1.addToReplaceList("Dish.modifiers", "modifiers: [GroupModifier]");
6
- graphqlHelper_1.addToReplaceList("OrderDish.modifiers", "modifiers: [OrderModifier]");
7
- graphqlHelper_1.addType(`
5
+ (0, graphqlHelper_1.addToReplaceList)("Dish.modifiers", "modifiers: [GroupModifier]");
6
+ (0, graphqlHelper_1.addToReplaceList)("OrderDish.modifiers", "modifiers: [OrderModifier]");
7
+ (0, graphqlHelper_1.addType)(`
8
8
  type GroupModifier {
9
+ "rmsId"
10
+ id: String
9
11
  maxAmount: Int
10
12
  minAmount: Int
11
13
  modifierId: String
@@ -14,6 +16,8 @@ type GroupModifier {
14
16
  group: Group
15
17
  }
16
18
  type Modifier {
19
+ "rmsId"
20
+ id: String
17
21
  modifierId: String
18
22
  maxAmount: Int
19
23
  minAmount: Int
@@ -22,7 +26,7 @@ type Modifier {
22
26
  dish: Dish
23
27
  }
24
28
  `);
25
- graphqlHelper_1.addType(`
29
+ (0, graphqlHelper_1.addType)(`
26
30
  type OrderModifier {
27
31
  id: String
28
32
  dish: Dish
@@ -6,6 +6,8 @@ addToReplaceList("OrderDish.modifiers", "modifiers: [OrderModifier]");
6
6
 
7
7
  addType(`
8
8
  type GroupModifier {
9
+ "rmsId"
10
+ id: String
9
11
  maxAmount: Int
10
12
  minAmount: Int
11
13
  modifierId: String
@@ -14,6 +16,8 @@ type GroupModifier {
14
16
  group: Group
15
17
  }
16
18
  type Modifier {
19
+ "rmsId"
20
+ id: String
17
21
  modifierId: String
18
22
  maxAmount: Int
19
23
  minAmount: Int
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ Query: {
3
+ errorCheck: {
4
+ def: string;
5
+ fn: () => Promise<boolean>;
6
+ };
7
+ };
8
+ };
9
+ export default _default;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ Query: {
5
+ errorCheck: {
6
+ def: 'errorCheck: Boolean',
7
+ fn: async () => {
8
+ throw new Error(`modifier required (amount, id) for dish: amount: `);
9
+ // await Order.check(
10
+ // {id: "order.id"}
11
+ // );
12
+ // try {
13
+ // } catch (error) {
14
+ // console.log(JSON.stringify(error), error.trace())
15
+ // throw error;
16
+ // }
17
+ return true;
18
+ }
19
+ }
20
+ },
21
+ };
@@ -0,0 +1,21 @@
1
+ export default {
2
+ Query: {
3
+ errorCheck: {
4
+ def: 'errorCheck: Boolean',
5
+ fn: async () => {
6
+ throw new Error(
7
+ `modifier required (amount, id) for dish: amount: `
8
+ );
9
+ // await Order.check(
10
+ // {id: "order.id"}
11
+ // );
12
+ // try {
13
+ // } catch (error) {
14
+ // console.log(JSON.stringify(error), error.trace())
15
+ // throw error;
16
+ // }
17
+ return true
18
+ }
19
+ }
20
+ },
21
+ }
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ Query: {
3
+ menu: {
4
+ def: string;
5
+ fn: (parent: any, args: any, context: any, info: any) => Promise<import("@webresto/core/models/Group").default[]>;
6
+ };
7
+ };
8
+ };
9
+ export default _default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ Query: {
5
+ menu: {
6
+ def: "menu(concept: String, topLevelGroupId: String): [Group]",
7
+ fn: async (parent, args, context, info) => {
8
+ return await Group.getMenuGroups(args.concept, args.topLevelGroupId);
9
+ }
10
+ }
11
+ }
12
+ };
@@ -0,0 +1,10 @@
1
+ export default {
2
+ Query: {
3
+ menu: {
4
+ def: "menu(concept: String, topLevelGroupId: String): [Group]",
5
+ fn: async (parent, args, context, info) => {
6
+ return await Group.getMenuGroups(args.concept, args.topLevelGroupId);
7
+ }
8
+ }
9
+ }
10
+ }