@webresto/graphql 1.3.2 → 1.3.3
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/package.json +1 -1
- package/src/additionalResolvers.js +1 -1
- package/src/additionalResolvers.ts +1 -1
- package/src/graphql.js +40 -22
- package/src/graphql.ts +42 -25
- package/src/resolvers/cart.d.ts +225 -7
- package/src/resolvers/cart.js +21 -7
- package/src/resolvers/cart.ts +23 -8
- package/src/resolvers/checkout.ts +1 -0
- package/test/{_bootstrap.js → bootstrap.js} +6 -7
- package/test/bootstrap.ts +3 -0
- package/test/fixture/.sailsrc +14 -0
- package/test/fixture/api/controllers/.gitkeep +0 -0
- package/test/fixture/api/models/.gitkeep +0 -0
- package/test/fixture/api/services/.gitkeep +0 -0
- package/test/fixture/app-export.js +73 -73
- package/test/fixture/app.js +56 -56
- package/test/fixture/config/adminpanel.js +25 -3
- package/test/fixture/config/bootstrap.js +161 -0
- package/test/fixture/config/connections.js +9 -9
- package/test/fixture/config/env/development.js +10 -10
- package/test/fixture/config/env/production.js +16 -16
- package/test/fixture/config/globals.js +16 -16
- package/test/fixture/config/hookTimeout.js +8 -8
- package/test/fixture/config/http.js +93 -93
- package/test/fixture/config/i18n.js +57 -57
- package/test/fixture/config/log.js +29 -29
- package/test/fixture/config/models.js +8 -8
- package/test/fixture/config/modulemanager.js +22 -22
- package/test/fixture/config/policies.js +51 -51
- package/test/fixture/config/routes.js +49 -49
- package/test/fixture/config/session.js +100 -100
- package/test/fixture/config/sockets.js +141 -141
- package/test/fixture/config/views.js +94 -94
- package/test/fixture/hacks/waterline.js +39 -0
- package/test/fixture/package.json +33 -30
- package/test/fixture/seeds/dish.json +37042 -0
- package/test/fixture/seeds/group.json +1418 -0
- package/test/fixture/seeds/iikoDiscount.json +365 -0
- package/test/fixture/views/403.ejs +68 -68
- package/test/fixture/views/404.ejs +68 -68
- package/test/fixture/views/500.ejs +73 -73
- package/test/fixture/views/homepage.ejs +74 -74
- package/test/fixture/views/layout.ejs +91 -91
- package/test/integration/graphql.test.js +11 -0
- package/test/integration/graphql.test.ts +15 -0
- package/test/{unit → integration}/sails_not_crash.test.js +0 -0
- package/test/{unit → integration}/sails_not_crash.test.ts +0 -0
- package/test/unit/first.test.js +1 -1
- package/test/unit/first.test.ts +1 -1
- package/test/fixture/.tmp/localDiskDb/archive.db +0 -1
- package/test/fixture/.tmp/localDiskDb/dish.db +0 -1
- package/test/fixture/.tmp/localDiskDb/dish_images__image_dish.db +0 -1
- package/test/fixture/.tmp/localDiskDb/group.db +0 -1
- package/test/fixture/.tmp/localDiskDb/group_images__image_group.db +0 -1
- package/test/fixture/.tmp/localDiskDb/image.db +0 -1
- package/test/fixture/.tmp/localDiskDb/maintenance.db +0 -1
- package/test/fixture/.tmp/localDiskDb/order.db +0 -1
- package/test/fixture/.tmp/localDiskDb/orderdish.db +0 -1
- package/test/fixture/.tmp/localDiskDb/paymentdocument.db +0 -1
- package/test/fixture/.tmp/localDiskDb/paymentmethod.db +0 -2
- package/test/fixture/.tmp/localDiskDb/place.db +0 -1
- package/test/fixture/.tmp/localDiskDb/settings.db +0 -2
- package/test/fixture/.tmp/localDiskDb/street.db +0 -1
- package/test/fixture/package-lock.json +0 -9805
- package/test.zip +0 -0
package/package.json
CHANGED
@@ -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: { "
|
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: { "
|
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
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
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;
|
package/src/resolvers/cart.d.ts
CHANGED
@@ -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: {
|
@@ -53,23 +52,243 @@ declare const _default: {
|
|
53
52
|
Mutation: {
|
54
53
|
orderAddDish: {
|
55
54
|
def: string;
|
56
|
-
fn: (parent: any, args: any, context: any) => Promise<
|
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
|
+
}>;
|
57
100
|
};
|
58
101
|
orderReplaceDish: {
|
59
102
|
def: string;
|
60
|
-
fn: (parent: any, args: any, context: any) => Promise<
|
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
|
+
}>;
|
61
148
|
};
|
62
149
|
orderRemoveDish: {
|
63
150
|
def: string;
|
64
|
-
fn: (parent: any, args: any, context: any) => Promise<
|
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
|
+
}>;
|
65
196
|
};
|
66
197
|
orderSetDishAmount: {
|
67
198
|
def: string;
|
68
|
-
fn: (parent: any, args: any, context: any) => Promise<
|
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
|
+
}>;
|
69
244
|
};
|
70
245
|
orderSetDishComment: {
|
71
246
|
def: string;
|
72
|
-
fn: (parent: any, args: any, context: any) => Promise<
|
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
|
+
}>;
|
73
292
|
};
|
74
293
|
orderUpdate: {
|
75
294
|
def: string;
|
@@ -77,7 +296,6 @@ declare const _default: {
|
|
77
296
|
id: string;
|
78
297
|
shortId: string;
|
79
298
|
dishes: number[] | import("@webresto/core/models/OrderDish").default[];
|
80
|
-
discount: any;
|
81
299
|
paymentMethod: any;
|
82
300
|
paymentMethodTitle: string;
|
83
301
|
paid: {
|
package/src/resolvers/cart.js
CHANGED
@@ -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
|
-
|
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
|
},
|
@@ -66,7 +68,9 @@ exports.default = {
|
|
66
68
|
}
|
67
69
|
await Order.addDish(order.id, args.dishId, args.amount, args.modifiers || [], args.comment, args.from, args.replace, args.orderDishId);
|
68
70
|
await Order.countCart(order);
|
69
|
-
|
71
|
+
let fullOrder = await Order.populate(order.id);
|
72
|
+
getEmitter_1.default().emit("http-api:before-response-order-add-dish", fullOrder);
|
73
|
+
return fullOrder;
|
70
74
|
},
|
71
75
|
},
|
72
76
|
orderReplaceDish: {
|
@@ -84,7 +88,9 @@ exports.default = {
|
|
84
88
|
}
|
85
89
|
await Order.addDish(order.id, args.dishId, args.amount, args.modifiers || [], args.comment, args.from, args.replace, args.orderDishId);
|
86
90
|
await Order.countCart(order);
|
87
|
-
|
91
|
+
let fullOrder = await Order.populate(order.id);
|
92
|
+
getEmitter_1.default().emit("http-api:before-response-order-replace-dish", fullOrder);
|
93
|
+
return fullOrder;
|
88
94
|
},
|
89
95
|
},
|
90
96
|
orderRemoveDish: {
|
@@ -102,7 +108,9 @@ exports.default = {
|
|
102
108
|
const orderDish = await OrderDish.findOne({ id: args.orderDishId });
|
103
109
|
await Order.removeDish(order.id, orderDish, args.amount, false);
|
104
110
|
await Order.countCart(order);
|
105
|
-
|
111
|
+
let fullOrder = await Order.populate(order.id);
|
112
|
+
getEmitter_1.default().emit("http-api:before-response-order-remove-dish", fullOrder);
|
113
|
+
return fullOrder;
|
106
114
|
},
|
107
115
|
},
|
108
116
|
orderSetDishAmount: {
|
@@ -124,7 +132,9 @@ exports.default = {
|
|
124
132
|
throw new errorWrapper_1.Error(0, "ERROR", `Dish in OrderDish with id ${args.orderDishId} not found`);
|
125
133
|
await Order.setCount(order.id, dish, args.amount);
|
126
134
|
await Order.countCart(order);
|
127
|
-
|
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;
|
128
138
|
},
|
129
139
|
},
|
130
140
|
orderSetDishComment: {
|
@@ -152,7 +162,9 @@ exports.default = {
|
|
152
162
|
}
|
153
163
|
await order.setComment(dish, comment);
|
154
164
|
await Order.countCart(order);
|
155
|
-
|
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;
|
156
168
|
},
|
157
169
|
},
|
158
170
|
orderUpdate: {
|
@@ -163,7 +175,9 @@ exports.default = {
|
|
163
175
|
throw "order.id field is required";
|
164
176
|
await Order.update({ id: order.id }, { trifleFrom: order.trifleFrom });
|
165
177
|
await Order.populate(order.id);
|
166
|
-
|
178
|
+
let fullOrder = await Order.populate(order.id);
|
179
|
+
getEmitter_1.default().emit("http-api:before-response-order-update", fullOrder);
|
180
|
+
return fullOrder;
|
167
181
|
},
|
168
182
|
},
|
169
183
|
},
|
package/src/resolvers/cart.ts
CHANGED
@@ -32,7 +32,10 @@ export default {
|
|
32
32
|
);
|
33
33
|
order = await getNewCart(args.orderId);
|
34
34
|
}
|
35
|
-
|
35
|
+
|
36
|
+
let fullOrder = await Order.populate(order.id);
|
37
|
+
getEmitter().emit("http-api:before-response-order", fullOrder);
|
38
|
+
return fullOrder
|
36
39
|
},
|
37
40
|
},
|
38
41
|
},
|
@@ -96,7 +99,10 @@ export default {
|
|
96
99
|
args.orderDishId
|
97
100
|
);
|
98
101
|
await Order.countCart(order);
|
99
|
-
|
102
|
+
|
103
|
+
let fullOrder = await Order.populate(order.id);
|
104
|
+
getEmitter().emit("http-api:before-response-order-add-dish", fullOrder);
|
105
|
+
return fullOrder
|
100
106
|
},
|
101
107
|
},
|
102
108
|
orderReplaceDish: {
|
@@ -128,7 +134,9 @@ export default {
|
|
128
134
|
args.orderDishId
|
129
135
|
);
|
130
136
|
await Order.countCart(order);
|
131
|
-
|
137
|
+
let fullOrder = await Order.populate(order.id);
|
138
|
+
getEmitter().emit("http-api:before-response-order-replace-dish", fullOrder);
|
139
|
+
return fullOrder
|
132
140
|
},
|
133
141
|
},
|
134
142
|
orderRemoveDish: {
|
@@ -153,7 +161,9 @@ export default {
|
|
153
161
|
|
154
162
|
await Order.removeDish(order.id, orderDish, args.amount, false);
|
155
163
|
await Order.countCart(order);
|
156
|
-
|
164
|
+
let fullOrder = await Order.populate(order.id);
|
165
|
+
getEmitter().emit("http-api:before-response-order-remove-dish", fullOrder);
|
166
|
+
return fullOrder
|
157
167
|
},
|
158
168
|
},
|
159
169
|
orderSetDishAmount: {
|
@@ -191,7 +201,9 @@ export default {
|
|
191
201
|
|
192
202
|
await Order.setCount(order.id, dish, args.amount);
|
193
203
|
await Order.countCart(order);
|
194
|
-
|
204
|
+
let fullOrder = await Order.populate(order.id);
|
205
|
+
getEmitter().emit("http-api:before-response-order-set-dish-amount", fullOrder);
|
206
|
+
return fullOrder
|
195
207
|
},
|
196
208
|
},
|
197
209
|
orderSetDishComment: {
|
@@ -228,8 +240,9 @@ export default {
|
|
228
240
|
|
229
241
|
await order.setComment(dish, comment);
|
230
242
|
await Order.countCart(order);
|
231
|
-
|
232
|
-
|
243
|
+
let fullOrder = await Order.populate(order.id);
|
244
|
+
getEmitter().emit("http-api:before-response-order-set-dish-comment", fullOrder);
|
245
|
+
return fullOrder },
|
233
246
|
},
|
234
247
|
|
235
248
|
orderUpdate: {
|
@@ -240,7 +253,9 @@ export default {
|
|
240
253
|
if (!order.id) throw "order.id field is required"
|
241
254
|
await Order.update({id: order.id}, {trifleFrom: order.trifleFrom})
|
242
255
|
await Order.populate(order.id);
|
243
|
-
|
256
|
+
let fullOrder = await Order.populate(order.id);
|
257
|
+
getEmitter().emit("http-api:before-response-order-update", fullOrder);
|
258
|
+
return fullOrder
|
244
259
|
},
|
245
260
|
},
|
246
261
|
},
|
@@ -1,15 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
require("mocha");
|
4
|
-
|
4
|
+
require("dotenv").config();
|
5
|
+
var Sails = require("./fixture/node_modules/sails").Sails;
|
6
|
+
process.env.DEV = "TRUE";
|
7
|
+
process.env.LOG_LEVEL = 'silent';
|
5
8
|
before(function (done) {
|
6
|
-
|
9
|
+
require("./fixture/app-export");
|
7
10
|
this.timeout(50000);
|
8
|
-
Sails().lift(
|
11
|
+
Sails().lift({}, function (err, _sails) {
|
9
12
|
if (err)
|
10
13
|
return done(err);
|
11
14
|
global.sails = _sails;
|
12
|
-
// console.log(_sails);
|
13
15
|
return done();
|
14
16
|
});
|
15
17
|
});
|
@@ -18,12 +20,9 @@ after(function (done) {
|
|
18
20
|
return global.sails.lower(function (err) {
|
19
21
|
if (err) {
|
20
22
|
done();
|
21
|
-
return process.exit(2);
|
22
23
|
}
|
23
24
|
done();
|
24
|
-
return process.exit(0);
|
25
25
|
});
|
26
26
|
}
|
27
27
|
done();
|
28
|
-
return process.exit(2);
|
29
28
|
});
|
package/test/bootstrap.ts
CHANGED