@webresto/graphql 1.3.7 → 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 -72
  29. package/lib/graphqlHelper.ts +329 -185
  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 +35 -16
  47. package/src/resolvers/checkout.js +171 -94
  48. package/src/resolvers/checkout.ts +214 -104
  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 -278
  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,53 +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
- } else {
26
- if(!data.address) throw `Address is required for non self service orders`
27
- }
28
84
 
85
+ let message;
29
86
  try {
30
87
  var order = await Order.findOne(data.orderId);
31
-
88
+ const shouldSendSucessMessage = order.state !== "CHECKOUT"
32
89
  if (!order) {
33
- return eventHelper.sendMessage(args.orderId, {
90
+ message = eventHelper.sendMessage({
91
+ deviceId: context.connectionParams.deviceId,
34
92
  type: "error",
35
- title: "Order not found",
36
- 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),
37
95
  });
38
96
  }
39
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
+
40
107
  if (order.state === "ORDER") {
41
- return eventHelper.sendMessage(args.orderId, {
108
+ message = eventHelper.sendMessage({
109
+ deviceId: context.connectionParams.deviceId,
42
110
  type: "error",
43
- title: "Ошибка",
44
- message: "Корзина уже заказана",
111
+ title: context.i18n.__("Error"),
112
+ message: context.i18n.__("Cart was ordered"),
45
113
  });
46
114
  }
47
115
 
48
116
  if (data.paymentMethodId) {
49
117
  if (!PaymentMethod.checkAvailable(data.paymentMethodId)) {
50
- return eventHelper.sendMessage(args.orderId, {
118
+ message = eventHelper.sendMessage({
119
+ deviceId: context.connectionParams.deviceId,
51
120
  type: "error",
52
- title: "Ошибка",
53
- message: "Проверка платежной системы завершилась неудачей",
121
+ title: context.i18n.__("Error"),
122
+ message: context.i18n.__("Checking the payment system ended in failure"),
54
123
  });
55
124
  }
56
125
  }
57
126
 
58
- if (data.address) {
59
- data.address.city =
60
- 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},
61
149
  }
62
150
 
63
- order.personsCount = data.personsCount ? data.personsCount : "";
151
+ order.personsCount = data.personsCount ? data.personsCount+"" : "";
64
152
  if (data.comment) order.comment = data.comment;
65
153
 
66
- if (data.date) order.date = data.date;
154
+ order.date = data.date;
67
155
 
68
- // callback: boolean - перезвонить для уточнения деталей
156
+ // callback: boolean -call back to clarify details
69
157
  if (data.customData && data.customData.callback) {
70
158
  if (!order.customData) order.customData = {};
71
159
  order.customData.callback = data.customData.callback;
@@ -73,140 +161,162 @@ export default {
73
161
 
74
162
  await Order.update({ id: order.id }, order).fetch();
75
163
 
164
+ let userId = null;
165
+ if (context && context.connectionParams.authorization) {
166
+ userId = (await JWTAuth.verify(context.connectionParams.authorization)).userId;
167
+ }
168
+
76
169
  await Order.check(
77
- order.id,
170
+ {id: order.id},
78
171
  data.customer,
79
172
  isSelfService,
80
173
  data.address,
81
- data.paymentMethodId
174
+ data.paymentMethodId,
175
+ userId,
176
+ data.spendBonus !== undefined && userId !== null ? data.spendBonus : null
82
177
  );
83
178
 
84
179
  order = await Order.findOne(data.orderId);
85
180
 
86
- let message;
87
-
88
- if (order.state === "CHECKOUT") {
181
+ if (order.state === "CHECKOUT" && shouldSendSucessMessage) {
89
182
  message = {
183
+ deviceId: context.connectionParams.deviceId,
90
184
  type: "info",
91
- title: "Внимание",
185
+ title: context.i18n.__("Attention"),
92
186
  message: order.message
93
- ? order.message
94
- : "Заказ готов к оформлению",
187
+ ? context.i18n.__(order.message)
188
+ : context.i18n.__("Ready for order"),
95
189
  };
96
190
 
97
191
  } else {
98
192
  if (order.message) {
99
193
  message = {
194
+ deviceId: context.connectionParams.deviceId,
100
195
  type: "error",
101
- title: "Внимание",
196
+ title: "Attention",
102
197
  message: order.message
103
- ? order.message
104
- : "Не удалось проверить заказ.",
198
+ ? context.i18n.__(order.message)
199
+ : context.i18n.__("It was not possible to check the order"),
105
200
  }
106
201
  }
107
202
  }
108
203
 
109
- eventHelper.sendMessage(args.orderId, message);
110
- return { message: message, order: order };
204
+ if(message){
205
+ eventHelper.sendMessage(message);
206
+ }
207
+
208
+ return {
209
+ order: order,
210
+ ...message && { message: message }
211
+ };
111
212
  } catch (e) {
112
213
  let message = {
113
214
  type: "error",
114
- title: "Ошибка",
215
+ title: context.i18n.__("Error"),
115
216
  message: "",
116
- };
217
+ } as Message;
117
218
  if (e.code === 1) {
118
- message.message = "Введите имя заказчика";
219
+ message.message = context.i18n.__("Enter the name of the customer");
119
220
  } else if (e.code === 2) {
120
- message.message = "Введите телефон заказчика";
221
+ message.message = context.i18n.__("Enter the customer's phone");
121
222
  } else if (e.code === 3) {
122
- message.message = "Неверный формат имени заказчика";
223
+ message.message = context.i18n.__("The wrong format of the name of the customer");
123
224
  } else if (e.code === 4) {
124
- message.message = "Неверный формат номера заказчика";
225
+ message.message = context.i18n.__("The wrong format of the customer number");
125
226
  } else if (e.code === 5) {
126
- message.message = "Не указана улица";
227
+ message.message = context.i18n.__("No point of Street");
127
228
  } else if (e.code === 6) {
128
- message.message = "Не указан номер дома";
229
+ message.message = context.i18n.__("Not indicated the house number");
129
230
  } else if (e.code === 7) {
130
- message.message = "Не указан город";
231
+ message.message = context.i18n.__("The city is not indicated");
131
232
  } else if (e.code === 8) {
132
- 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) ;
133
236
  } else if (e.code === 10) {
134
- 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");
135
240
  } else {
136
241
  message.message = e.error
137
242
  ? e.error
138
- : `Проблема при проверки заказа: ${e}`;
243
+ : context.i18n.__(`Problem when checking the order: %s`, e);
139
244
  }
140
245
 
141
- eventHelper.sendMessage(args.orderId, message);
246
+ order = await Order.findOne(data.orderId);
142
247
  sails.log.error(e)
143
- return { message: message };
248
+ eventHelper.sendMessage(message);
249
+ return {
250
+ order: order,
251
+ message: message
252
+ };
144
253
  }
145
254
  },
146
255
  },
147
256
  sendOrder: {
148
257
  def: "sendOrder(orderId: String!): CheckResponse",
149
258
  fn: async function (parent, args, context) {
259
+ if (!context.connectionParams.deviceId) {
260
+ throw `Missed deviceId`;
261
+ }
150
262
  let data = args;
151
-
152
- try {
153
- var order = await Order.findOne({ id: data.orderId });
154
- if (!order) {
155
- const errorMessage = `Order with id ${data.orderId} not found`;
156
- eventHelper.sendMessage(args.orderId, {
157
- type: "error",
158
- title: "Order not found",
159
- 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,
160
272
  });
161
- sails.log.error(`${errorMessage}`)
162
- throw new Error(0,errorMessage);
163
- }
164
-
165
- if (!(await PaymentMethod.isPaymentPromise(order.paymentMethod))) {
166
- try {
167
- let paymentResponse = await Order.payment({id: order.id});
168
-
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 });
169
279
  const action = {
170
- type: "PaymentRedirect",
171
- data: {
172
- redirectLink: paymentResponse.redirectLink,
173
- },
280
+ deviceId: context.connectionParams.deviceId,
281
+ type: "Redirect",
282
+ data: {
283
+ link: paymentResponse.redirectLink,
284
+ },
174
285
  };
175
- eventHelper.sendAction(args.orderId, action);
176
- order = await Order.populate(order.id);
286
+ eventHelper.sendAction(action);
287
+ order = await Order.populate({ id: order.id });
177
288
  return { order: order, action: action };
178
- } catch (e) {
179
- eventHelper.sendMessage(args.orderId, {
180
- type: "error",
181
- title: "Ошибка",
182
- message: "Попытка регистрации платежа завершилась неудачно",
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"),
183
296
  });
184
-
185
- sails.log.error(e);
186
- throw new Error(JSON.stringify(e));
187
- }
297
+ const error = `External payment: ${e}`
298
+ sails.log.error(error);
299
+ throw new Error(error);
188
300
  }
301
+ }
189
302
 
190
- await Order.order(order.id);
191
- order = await Order.findOne({ id: data.orderId })
192
- const message = {
193
- type: "info",
194
- title: "Успешно",
195
- message: "Ваш заказ принят в обработку",
196
- };
197
- eventHelper.sendMessage(args.orderId, message);
198
- return { order: order, message: message };
199
- } catch (e) {
200
- eventHelper.sendMessage(args.orderId, {
201
- type: "error",
202
- title: "Ошибка",
203
- message: e,
204
- });
205
-
206
- sails.log.error("sendOrder error :", e);
207
- 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);
208
318
  }
209
319
  },
210
320
  },
211
321
  },
212
- };
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
+ }