@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.
- package/.gitattributes +2 -0
- package/.gitlab-ci.yml +18 -0
- package/.vscode/extensions.json +5 -0
- package/docs/actions.md +25 -0
- package/docs/authorization.md +215 -0
- package/docs/captcha.md +71 -0
- package/docs/device-id.md +30 -0
- package/docs/messages.md +10 -0
- package/docs/user.md +54 -0
- package/index.d.ts +0 -1
- package/index.js +6 -2
- package/index.ts +2 -2
- package/lib/afterHook.js +8 -0
- package/lib/afterHook.ts +9 -0
- package/lib/bindTranslations.d.ts +1 -0
- package/lib/bindTranslations.js +40 -0
- package/lib/bindTranslations.ts +39 -0
- package/lib/defaults.d.ts +1 -0
- package/lib/defaults.js +49 -10
- package/lib/defaults.ts +55 -0
- package/lib/eventHelper.d.ts +14 -5
- package/lib/eventHelper.js +28 -9
- package/lib/eventHelper.ts +41 -8
- package/lib/getRecomended.d.ts +1 -0
- package/lib/getRecomended.js +29 -0
- package/lib/getRecomended.ts +31 -0
- package/lib/graphqlHelper.d.ts +3 -4
- package/lib/graphqlHelper.js +184 -72
- package/lib/graphqlHelper.ts +329 -185
- package/lib/jwt.d.ts +10 -0
- package/lib/jwt.js +43 -0
- package/lib/jwt.ts +61 -0
- package/package.json +13 -6
- package/src/additionalResolvers.d.ts +72 -9
- package/src/additionalResolvers.js +93 -24
- package/src/additionalResolvers.ts +105 -34
- package/src/graphql.d.ts +5 -3
- package/src/graphql.js +170 -37
- package/src/graphql.ts +210 -60
- package/src/resolvers/bonusProgram.d.ts +32 -0
- package/src/resolvers/bonusProgram.js +65 -0
- package/src/resolvers/bonusProgram.ts +79 -0
- package/src/resolvers/captcha.d.ts +11 -0
- package/src/resolvers/captcha.js +19 -0
- package/src/resolvers/captcha.ts +16 -0
- package/src/resolvers/checkout.d.ts +35 -16
- package/src/resolvers/checkout.js +171 -94
- package/src/resolvers/checkout.ts +214 -104
- package/src/resolvers/dishAndModifier.js +8 -4
- package/src/resolvers/dishAndModifier.ts +4 -0
- package/src/resolvers/error.d.ts +9 -0
- package/src/resolvers/error.js +21 -0
- package/src/resolvers/error.ts +21 -0
- package/src/resolvers/menu.d.ts +9 -0
- package/src/resolvers/menu.js +12 -0
- package/src/resolvers/menu.ts +10 -0
- package/src/resolvers/order.d.ts +527 -0
- package/src/resolvers/order.js +349 -0
- package/src/resolvers/order.ts +435 -0
- package/src/resolvers/paymentMethod.js +7 -3
- package/src/resolvers/paymentMethod.ts +9 -5
- package/src/resolvers/pickupPoint.d.ts +1 -0
- package/src/resolvers/pickupPoint.js +24 -0
- package/src/resolvers/pickupPoint.ts +23 -0
- package/src/resolvers/recomended.d.ts +13 -0
- package/src/resolvers/recomended.js +80 -0
- package/src/resolvers/recomended.ts +86 -0
- package/src/resolvers/restrictions.d.ts +37 -1
- package/src/resolvers/restrictions.js +100 -15
- package/src/resolvers/restrictions.ts +106 -14
- package/src/resolvers/streets.d.ts +1 -1
- package/src/resolvers/streets.js +1 -4
- package/src/resolvers/streets.ts +1 -3
- package/src/resolvers/subscriptions.d.ts +4 -4
- package/src/resolvers/subscriptions.js +49 -12
- package/src/resolvers/subscriptions.ts +59 -14
- package/src/resolvers/telemetry.d.ts +14 -0
- package/src/resolvers/telemetry.js +25 -0
- package/src/resolvers/telemetry.ts +24 -0
- package/src/resolvers/user.d.ts +82 -0
- package/src/resolvers/user.js +416 -0
- package/src/resolvers/user.ts +621 -0
- package/src/resolvers/userLocation.d.ts +53 -0
- package/src/resolvers/userLocation.js +74 -0
- package/src/resolvers/userLocation.ts +125 -0
- package/src/resolvers/userOTPrequest.d.ts +21 -0
- package/src/resolvers/userOTPrequest.js +57 -0
- package/src/resolvers/userOTPrequest.ts +75 -0
- package/test/e2e_helper.js +157 -0
- package/test/e2e_helper.ts +212 -0
- package/test/fixture/config/i18n.js +7 -20
- package/test/fixture/config/locales/de.json +1 -0
- package/test/fixture/config/locales/en.json +10 -0
- package/test/fixture/config/locales/es.json +3 -0
- package/test/fixture/config/locales/fr.json +1 -0
- package/test/fixture/config/log.js +1 -1
- package/test/fixture/package.json +5 -6
- package/test/fixture/patches/rttc+10.0.1.patch +17 -0
- package/test/integration/captcha.test.js +20 -0
- package/test/integration/captcha.test.ts +25 -0
- package/test/integration/dish.test.js +35 -0
- package/test/integration/dish.test.ts +43 -0
- package/test/integration/graphql.test.js +5 -2
- package/test/integration/graphql.test.ts +2 -4
- package/test/integration/images.test.js +35 -0
- package/test/integration/images.test.ts +40 -0
- package/test/integration/locale.test.js +26 -0
- package/test/integration/locale.test.ts +32 -0
- package/test/integration/order.test.js +56 -43
- package/test/integration/order.test.ts +59 -59
- package/test/integration/subscriptions.test.js +136 -0
- package/test/integration/subscriptions.test.ts +162 -0
- package/test/integration/user.test.js +249 -0
- package/test/integration/user.test.ts +299 -0
- package/test/unit/first.test.js +4 -2
- package/test/unit/first.test.ts +1 -1
- package/test/unit/get-recomended.test.js +56 -0
- package/test/unit/get-recomended.test.ts +63 -0
- package/translations/de.json +2 -0
- package/translations/en.json +3 -0
- package/translations/es.json +3 -0
- package/translations/fr.json +2 -0
- package/translations/ru.json +36 -0
- package/tsconfig.json +20 -5
- package/types/global.d.ts +30 -0
- package/types/global.js +2 -0
- package/types/global.ts +31 -0
- package/types/primitives.d.ts +19 -0
- package/types/references.d.ts +1 -0
- package/types/restoGraphQLConfig.d.ts +13 -0
- package/lib/afterHook.ts___graphql-transport-ws +0 -138
- package/lib/afterHook.ts___graphql-ws +0 -133
- package/lib/errorWrapper.d.ts +0 -4
- package/lib/errorWrapper.js +0 -13
- package/lib/errorWrapper.ts +0 -12
- package/notes.md +0 -1976
- package/src/resolvers/cart.d.ts +0 -343
- package/src/resolvers/cart.js +0 -196
- package/src/resolvers/cart.ts +0 -278
- package/test/fixture/config/connections.js +0 -9
- package/test/integration/sails_not_crash.test.js +0 -3
- package/test/integration/sails_not_crash.test.ts +0 -3
|
@@ -1,12 +1,74 @@
|
|
|
1
1
|
import * as eventHelper from "../../lib/eventHelper";
|
|
2
|
-
import {
|
|
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:
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
90
|
+
message = eventHelper.sendMessage({
|
|
91
|
+
deviceId: context.connectionParams.deviceId,
|
|
34
92
|
type: "error",
|
|
35
|
-
title: "Order not found",
|
|
36
|
-
message:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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 =
|
|
151
|
+
order.personsCount = data.personsCount ? data.personsCount+"" : "";
|
|
64
152
|
if (data.comment) order.comment = data.comment;
|
|
65
153
|
|
|
66
|
-
|
|
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
|
-
|
|
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
|
-
|
|
110
|
-
|
|
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
|
-
:
|
|
243
|
+
: context.i18n.__(`Problem when checking the order: %s`, e);
|
|
139
244
|
}
|
|
140
245
|
|
|
141
|
-
|
|
246
|
+
order = await Order.findOne(data.orderId);
|
|
142
247
|
sails.log.error(e)
|
|
143
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
280
|
+
deviceId: context.connectionParams.deviceId,
|
|
281
|
+
type: "Redirect",
|
|
282
|
+
data: {
|
|
283
|
+
link: paymentResponse.redirectLink,
|
|
284
|
+
},
|
|
174
285
|
};
|
|
175
|
-
eventHelper.sendAction(
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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(
|
|
186
|
-
throw new Error(
|
|
187
|
-
}
|
|
297
|
+
const error = `External payment: ${e}`
|
|
298
|
+
sails.log.error(error);
|
|
299
|
+
throw new Error(error);
|
|
188
300
|
}
|
|
301
|
+
}
|
|
189
302
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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,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,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
|
+
};
|