@webresto/graphql 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.editorconfig +10 -0
- package/index.d.ts +3 -0
- package/index.js +22 -0
- package/index.ts +14 -0
- package/lib/afterHook.d.ts +1 -0
- package/lib/afterHook.js +24 -0
- package/lib/afterHook.ts +26 -0
- package/lib/afterHook.ts___graphql-transport-ws +138 -0
- package/lib/afterHook.ts___graphql-ws +133 -0
- package/lib/defaults.js +12 -0
- package/lib/errorWrapper.d.ts +4 -0
- package/lib/errorWrapper.js +13 -0
- package/lib/errorWrapper.ts +12 -0
- package/lib/eventHelper.d.ts +21 -0
- package/lib/eventHelper.js +32 -0
- package/lib/eventHelper.ts +35 -0
- package/lib/graphqlHelper.d.ts +115 -0
- package/lib/graphqlHelper.js +596 -0
- package/lib/graphqlHelper.ts +692 -0
- package/lib/initialize.d.ts +1 -0
- package/lib/initialize.js +22 -0
- package/lib/initialize.ts +21 -0
- package/notes.md +1976 -0
- package/package.json +47 -0
- package/readme.md +258 -0
- package/restApi.http +11 -0
- package/src/additionalResolvers.d.ts +19 -0
- package/src/additionalResolvers.js +114 -0
- package/src/additionalResolvers.ts +111 -0
- package/src/graphql.d.ts +7 -0
- package/src/graphql.js +144 -0
- package/src/graphql.ts +160 -0
- package/src/resolvers/cart.d.ts +123 -0
- package/src/resolvers/cart.js +176 -0
- package/src/resolvers/cart.ts +256 -0
- package/src/resolvers/checkout.d.ts +30 -0
- package/src/resolvers/checkout.js +226 -0
- package/src/resolvers/checkout.ts +242 -0
- package/src/resolvers/dishAndModifier.d.ts +2 -0
- package/src/resolvers/dishAndModifier.js +35 -0
- package/src/resolvers/dishAndModifier.ts +38 -0
- package/src/resolvers/maintenance.d.ts +9 -0
- package/src/resolvers/maintenance.js +12 -0
- package/src/resolvers/maintenance.ts +11 -0
- package/src/resolvers/paymentMethod.d.ts +9 -0
- package/src/resolvers/paymentMethod.js +22 -0
- package/src/resolvers/paymentMethod.ts +20 -0
- package/src/resolvers/restrictions.d.ts +9 -0
- package/src/resolvers/restrictions.js +24 -0
- package/src/resolvers/restrictions.ts +22 -0
- package/src/resolvers/streets.d.ts +9 -0
- package/src/resolvers/streets.js +16 -0
- package/src/resolvers/streets.ts +13 -0
- package/src/resolvers/subscriptions.d.ts +33 -0
- package/src/resolvers/subscriptions.js +52 -0
- package/src/resolvers/subscriptions.ts +63 -0
- package/test/.eslintrc +8 -0
- package/test/_bootstrap.js +29 -0
- package/test/fixtures/v0.12-app/.gitignore +11 -0
- package/test/fixtures/v0.12-app/.sailsrc +11 -0
- package/test/fixtures/v0.12-app/api/controllers/.gitkeep +0 -0
- package/test/fixtures/v0.12-app/api/models/.gitkeep +0 -0
- package/test/fixtures/v0.12-app/api/models/TestModel.js +22 -0
- package/test/fixtures/v0.12-app/api/responses/badRequest.js +76 -0
- package/test/fixtures/v0.12-app/api/responses/created.js +60 -0
- package/test/fixtures/v0.12-app/api/responses/forbidden.js +89 -0
- package/test/fixtures/v0.12-app/api/responses/notFound.js +94 -0
- package/test/fixtures/v0.12-app/api/responses/ok.js +60 -0
- package/test/fixtures/v0.12-app/api/responses/serverError.js +89 -0
- package/test/fixtures/v0.12-app/api/services/.gitkeep +0 -0
- package/test/fixtures/v0.12-app/app.js +73 -0
- package/test/fixtures/v0.12-app/config/bootstrap.js +6 -0
- package/test/fixtures/v0.12-app/config/connections.js +5 -0
- package/test/fixtures/v0.12-app/config/cors.js +78 -0
- package/test/fixtures/v0.12-app/config/csrf.js +64 -0
- package/test/fixtures/v0.12-app/config/env/development.js +10 -0
- package/test/fixtures/v0.12-app/config/env/production.js +16 -0
- package/test/fixtures/v0.12-app/config/globals.js +63 -0
- package/test/fixtures/v0.12-app/config/hookTimeout.js +8 -0
- package/test/fixtures/v0.12-app/config/http.js +93 -0
- package/test/fixtures/v0.12-app/config/i18n.js +57 -0
- package/test/fixtures/v0.12-app/config/log.js +29 -0
- package/test/fixtures/v0.12-app/config/models.js +3 -0
- package/test/fixtures/v0.12-app/config/policies.js +51 -0
- package/test/fixtures/v0.12-app/config/restoapi.js +3 -0
- package/test/fixtures/v0.12-app/config/restocore.js +39 -0
- package/test/fixtures/v0.12-app/config/routes.js +49 -0
- package/test/fixtures/v0.12-app/config/session.js +100 -0
- package/test/fixtures/v0.12-app/config/sockets.js +141 -0
- package/test/fixtures/v0.12-app/config/stateflow.js +4 -0
- package/test/fixtures/v0.12-app/config/views.js +95 -0
- package/test/fixtures/v0.12-app/package.json +34 -0
- package/test/fixtures/v0.12-app/views/403.ejs +68 -0
- package/test/fixtures/v0.12-app/views/404.ejs +68 -0
- package/test/fixtures/v0.12-app/views/500.ejs +73 -0
- package/test/fixtures/v0.12-app/views/homepage.ejs +74 -0
- package/test/fixtures/v0.12-app/views/layout.ejs +91 -0
- package/test/mocha.opts +2 -0
- package/test/readme.md +0 -0
- package/test/todo +0 -0
- package/test/tslint.json +18 -0
- package/test/unit/first.test.js +11 -0
- package/test/unit/sails_not_crash.test.js +3 -0
- package/todo.md +1 -0
- package/tsconfig.json +10 -0
@@ -0,0 +1,242 @@
|
|
1
|
+
import * as eventHelper from "../../lib/eventHelper";
|
2
|
+
import { Error } from "../../lib/errorWrapper";
|
3
|
+
|
4
|
+
export default {
|
5
|
+
Mutation: {
|
6
|
+
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;
|
10
|
+
|
11
|
+
// if (data.date) {
|
12
|
+
// let date = moment(data.date)
|
13
|
+
// if(!date.isValid()){
|
14
|
+
// return eventHelper.sendMessage(args.orderId, "Please order.date format is ISO (YYYY-MM-DD HH:mm:ss)");
|
15
|
+
// } else {
|
16
|
+
// data.date = date.format('YYYY-MM-DD HH:mm:ss');
|
17
|
+
// }
|
18
|
+
// }
|
19
|
+
|
20
|
+
let isSelfService: boolean;
|
21
|
+
|
22
|
+
//@ts-ignore
|
23
|
+
if (data.selfService || data.selfDelivery) {
|
24
|
+
isSelfService = true;
|
25
|
+
}
|
26
|
+
|
27
|
+
try {
|
28
|
+
var order = await Order.findOne(data.orderId);
|
29
|
+
|
30
|
+
if (!order) {
|
31
|
+
return eventHelper.sendMessage(args.orderId, {
|
32
|
+
type: "error",
|
33
|
+
title: "Order not found",
|
34
|
+
message: `Order with id ${data.orderId} not found`,
|
35
|
+
});
|
36
|
+
}
|
37
|
+
|
38
|
+
if (order.state === "ORDER") {
|
39
|
+
return eventHelper.sendMessage(args.orderId, {
|
40
|
+
type: "error",
|
41
|
+
title: "Ошибка",
|
42
|
+
message: "Корзина уже заказана",
|
43
|
+
});
|
44
|
+
}
|
45
|
+
if (data.paymentMethodId) {
|
46
|
+
if (!PaymentMethod.checkAvailable(data.paymentMethodId)) {
|
47
|
+
return eventHelper.sendMessage(args.orderId, {
|
48
|
+
type: "error",
|
49
|
+
title: "Ошибка",
|
50
|
+
message: "Проверка платежной системы завершилась неудачей",
|
51
|
+
});
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
if (data.address) {
|
56
|
+
data.address.city =
|
57
|
+
data.address.city || (await Settings.use("city"));
|
58
|
+
}
|
59
|
+
|
60
|
+
order.personsCount = data.personsCount ? data.personsCount : "";
|
61
|
+
if (data.comment) order.comment = data.comment;
|
62
|
+
|
63
|
+
if (data.date) order.date = data.date;
|
64
|
+
|
65
|
+
// callback: boolean - перезвонить для уточнения деталей
|
66
|
+
if (data.customData && data.customData.callback) {
|
67
|
+
if (!order.customData) order.customData = {};
|
68
|
+
order.customData.callback = data.customData.callback;
|
69
|
+
}
|
70
|
+
|
71
|
+
await Order.update({ id: order.id }, order).fetch();
|
72
|
+
|
73
|
+
let success: boolean;
|
74
|
+
|
75
|
+
success = await Order.check(
|
76
|
+
order.id,
|
77
|
+
data.customer,
|
78
|
+
isSelfService,
|
79
|
+
data.address,
|
80
|
+
data.paymentMethodId
|
81
|
+
);
|
82
|
+
order = await Order.findOne(data.orderId).populateAll();
|
83
|
+
let message;
|
84
|
+
|
85
|
+
if (success && order.state === "CHECKOUT") {
|
86
|
+
message = {
|
87
|
+
type: "info",
|
88
|
+
title: "Внимание",
|
89
|
+
message: order.message
|
90
|
+
? order.message
|
91
|
+
: "Заказ готов к оформлению",
|
92
|
+
};
|
93
|
+
} else {
|
94
|
+
if (order.message) {
|
95
|
+
return eventHelper.sendMessage(args.orderId, {
|
96
|
+
type: "error",
|
97
|
+
title: "Внимание",
|
98
|
+
message: order.message
|
99
|
+
? order.message
|
100
|
+
: "Не удалось проверить заказ.",
|
101
|
+
});
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
return { order: order };
|
106
|
+
} catch (e) {
|
107
|
+
let message = {
|
108
|
+
type: "error",
|
109
|
+
title: "Ошибка",
|
110
|
+
message: "",
|
111
|
+
};
|
112
|
+
if (e.code === 1) {
|
113
|
+
message.message = "Введите имя заказчика";
|
114
|
+
} else if (e.code === 2) {
|
115
|
+
message.message = "Введите телефон заказчика";
|
116
|
+
} else if (e.code === 3) {
|
117
|
+
message.message = "Неверный формат имени заказчика";
|
118
|
+
} else if (e.code === 4) {
|
119
|
+
message.message = "Неверный формат номера заказчика";
|
120
|
+
} else if (e.code === 5) {
|
121
|
+
message.message = "Не указана улица";
|
122
|
+
} else if (e.code === 6) {
|
123
|
+
message.message = "Не указан номер дома";
|
124
|
+
} else if (e.code === 7) {
|
125
|
+
message.message = "Не указан город";
|
126
|
+
} else if (e.code === 8) {
|
127
|
+
message.message = "Платежная система недоступна";
|
128
|
+
} else if (e.code === 10) {
|
129
|
+
message.message = "Дата выполнения заказа не верная";
|
130
|
+
} else {
|
131
|
+
message.message = e.error
|
132
|
+
? e.error
|
133
|
+
: `Проблема при проверки заказа: ${e}`;
|
134
|
+
}
|
135
|
+
|
136
|
+
eventHelper.sendMessage(args.orderId, message);
|
137
|
+
sails.log.error(e)
|
138
|
+
return { message: message };
|
139
|
+
}
|
140
|
+
},
|
141
|
+
},
|
142
|
+
sendOrder: {
|
143
|
+
def: "sendOrder(orderId: String!): CheckResponse",
|
144
|
+
fn: async function (parent, args, context) {
|
145
|
+
let data = args;
|
146
|
+
|
147
|
+
// if (data.date) {
|
148
|
+
// let date = moment(data.date)
|
149
|
+
// if(!date.isValid()){
|
150
|
+
// return eventHelper.sendMessage(args.orderId,"Please order.date format is ISO (YYYY-MM-DD HH:mm:ss)");
|
151
|
+
// } else {
|
152
|
+
// data.date = date.format('YYYY-MM-DD HH:mm:ss');
|
153
|
+
// }
|
154
|
+
// }
|
155
|
+
|
156
|
+
try {
|
157
|
+
var order = await Order.findOne({ id: data.orderId });
|
158
|
+
if (!order) {
|
159
|
+
const errorMessage = `Order with id ${data.orderId} not found`;
|
160
|
+
eventHelper.sendMessage(args.orderId, {
|
161
|
+
type: "error",
|
162
|
+
title: "Order not found",
|
163
|
+
message: errorMessage,
|
164
|
+
});
|
165
|
+
sails.log.error(`${errorMessage}`)
|
166
|
+
throw new Error(0,errorMessage);
|
167
|
+
}
|
168
|
+
|
169
|
+
// if (data.comment) order.comment = data.comment;
|
170
|
+
|
171
|
+
// if (data.paymentMethodId) {
|
172
|
+
// if (order.paymentMethod !== data.paymentMethodId) {
|
173
|
+
// await Order.check(
|
174
|
+
// order.id,
|
175
|
+
// null,
|
176
|
+
// null,
|
177
|
+
// null,
|
178
|
+
// data.paymentMethodId
|
179
|
+
// );
|
180
|
+
// order = await Order.findOne({ id: data.orderId });
|
181
|
+
// }
|
182
|
+
// }
|
183
|
+
|
184
|
+
// if (order.paymentMethod) {
|
185
|
+
// if (!(await PaymentMethod.checkAvailable(order.paymentMethod))) {
|
186
|
+
// let errorMessage = `Проверка платежной системы завершилась неудачно`;
|
187
|
+
// eventHelper.sendMessage(args.orderId, {
|
188
|
+
// type: "error",
|
189
|
+
// title: "Ошибка",
|
190
|
+
// message: errorMessage,
|
191
|
+
// });
|
192
|
+
// sails.log.error(`${errorMessage}`)
|
193
|
+
// throw new Error(0,errorMessage);
|
194
|
+
// }
|
195
|
+
|
196
|
+
// if (!(await PaymentMethod.isPaymentPromise(data.paymentMethodId))) {
|
197
|
+
// try {
|
198
|
+
// let paymentResponse = await order.payment();
|
199
|
+
// const action = {
|
200
|
+
// type: "PaymentRedirect",
|
201
|
+
// data: {
|
202
|
+
// redirectLink: paymentResponse.redirectLink,
|
203
|
+
// },
|
204
|
+
// };
|
205
|
+
// eventHelper.sendAction(args.orderId, action);
|
206
|
+
// return { order: order, action: action };
|
207
|
+
// } catch (e) {
|
208
|
+
// eventHelper.sendMessage(args.orderId, {
|
209
|
+
// type: "error",
|
210
|
+
// title: "Ошибка",
|
211
|
+
// message: "Попытка регистрации платежа завершилась неудачно",
|
212
|
+
// });
|
213
|
+
|
214
|
+
// sails.log.error(e);
|
215
|
+
// throw new Error(0, JSON.stringify(e));
|
216
|
+
// }
|
217
|
+
// }
|
218
|
+
// }
|
219
|
+
|
220
|
+
await Order.order(order.id);
|
221
|
+
|
222
|
+
const message = {
|
223
|
+
type: "info",
|
224
|
+
title: "Успешно",
|
225
|
+
message: "Ваш заказ принят в обработку",
|
226
|
+
};
|
227
|
+
eventHelper.sendMessage(args.orderId, message);
|
228
|
+
return { order: order, message: message };
|
229
|
+
} catch (e) {
|
230
|
+
eventHelper.sendMessage(args.orderId, {
|
231
|
+
type: "error",
|
232
|
+
title: "Ошибка",
|
233
|
+
message: e,
|
234
|
+
});
|
235
|
+
|
236
|
+
sails.log.error("sendOrder error :", e);
|
237
|
+
throw new Error(0,`${e}`);
|
238
|
+
}
|
239
|
+
},
|
240
|
+
},
|
241
|
+
},
|
242
|
+
};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const graphqlHelper_1 = require("@webresto/graphql/lib/graphqlHelper");
|
4
|
+
// init
|
5
|
+
graphqlHelper_1.addToReplaceList("Dish.modifiers", "modifiers: [GroupModifier]");
|
6
|
+
graphqlHelper_1.addToReplaceList("OrderDish.modifiers", "modifiers: [OrderModifier]");
|
7
|
+
graphqlHelper_1.addType(`
|
8
|
+
type GroupModifier {
|
9
|
+
maxAmount: Int
|
10
|
+
minAmount: Int
|
11
|
+
modifierId: String
|
12
|
+
required: Boolean
|
13
|
+
childModifiers: [Modifier]
|
14
|
+
group: Group
|
15
|
+
}
|
16
|
+
type Modifier {
|
17
|
+
modifierId: String
|
18
|
+
maxAmount: Int
|
19
|
+
minAmount: Int
|
20
|
+
defaultAmount: Int
|
21
|
+
hideIfDefaultAmount: Boolean
|
22
|
+
dish: Dish
|
23
|
+
}
|
24
|
+
`);
|
25
|
+
graphqlHelper_1.addType(`
|
26
|
+
type OrderModifier {
|
27
|
+
id: String
|
28
|
+
dish: Dish
|
29
|
+
amount: Int
|
30
|
+
groupId: String
|
31
|
+
group: Group
|
32
|
+
}
|
33
|
+
`);
|
34
|
+
// resolver
|
35
|
+
exports.default = {};
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { addToReplaceList, addType } from "@webresto/graphql/lib/graphqlHelper";
|
2
|
+
|
3
|
+
// init
|
4
|
+
addToReplaceList("Dish.modifiers", "modifiers: [GroupModifier]");
|
5
|
+
addToReplaceList("OrderDish.modifiers", "modifiers: [OrderModifier]");
|
6
|
+
|
7
|
+
addType(`
|
8
|
+
type GroupModifier {
|
9
|
+
maxAmount: Int
|
10
|
+
minAmount: Int
|
11
|
+
modifierId: String
|
12
|
+
required: Boolean
|
13
|
+
childModifiers: [Modifier]
|
14
|
+
group: Group
|
15
|
+
}
|
16
|
+
type Modifier {
|
17
|
+
modifierId: String
|
18
|
+
maxAmount: Int
|
19
|
+
minAmount: Int
|
20
|
+
defaultAmount: Int
|
21
|
+
hideIfDefaultAmount: Boolean
|
22
|
+
dish: Dish
|
23
|
+
}
|
24
|
+
`);
|
25
|
+
addType(`
|
26
|
+
type OrderModifier {
|
27
|
+
id: String
|
28
|
+
dish: Dish
|
29
|
+
amount: Int
|
30
|
+
groupId: String
|
31
|
+
group: Group
|
32
|
+
}
|
33
|
+
`);
|
34
|
+
|
35
|
+
// resolver
|
36
|
+
export default {
|
37
|
+
|
38
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = {
|
4
|
+
Query: {
|
5
|
+
maintenance: {
|
6
|
+
def: 'maintenance: Maintenance',
|
7
|
+
fn: async function (parent, args, context) {
|
8
|
+
return await Maintenance.getActiveMaintenance();
|
9
|
+
}
|
10
|
+
}
|
11
|
+
}
|
12
|
+
};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const getEmitter_1 = require("@webresto/core/libs/getEmitter");
|
4
|
+
exports.default = {
|
5
|
+
Query: {
|
6
|
+
paymentMethod: {
|
7
|
+
def: 'paymentMethod(orderId: String!): [PaymentMethod]',
|
8
|
+
fn: async function (parent, args, context) {
|
9
|
+
const orderId = args.orderId;
|
10
|
+
try {
|
11
|
+
const data = await PaymentMethod.getAvailable();
|
12
|
+
await getEmitter_1.default().emit('graphql-return-payment-method', orderId, data);
|
13
|
+
return data;
|
14
|
+
}
|
15
|
+
catch (e) {
|
16
|
+
sails.log.error(e);
|
17
|
+
throw new Error(0, JSON.stringify(e));
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import getEmitter from "@webresto/core/libs/getEmitter";
|
2
|
+
|
3
|
+
export default {
|
4
|
+
Query: {
|
5
|
+
paymentMethod: {
|
6
|
+
def: 'paymentMethod(orderId: String!): [PaymentMethod]',
|
7
|
+
fn: async function (parent, args, context) {
|
8
|
+
const orderId = args.orderId;
|
9
|
+
try {
|
10
|
+
const data = await PaymentMethod.getAvailable();
|
11
|
+
await getEmitter().emit('graphql-return-payment-method', orderId, data);
|
12
|
+
return data;
|
13
|
+
} catch (e) {
|
14
|
+
sails.log.error(e); throw new Error(0, JSON.stringify(e));
|
15
|
+
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = {
|
4
|
+
Query: {
|
5
|
+
restrictions: {
|
6
|
+
def: 'restrictions: Restrictions',
|
7
|
+
fn: async function (parent, args, context) {
|
8
|
+
try {
|
9
|
+
let restrictions = {};
|
10
|
+
restrictions.workTime = await Settings.use('workTime');
|
11
|
+
restrictions.periodPossibleForOrder = await Settings.use('PeriodPossibleForOrder');
|
12
|
+
restrictions.timezone = await Settings.use('timezone');
|
13
|
+
restrictions.deliveryDescription = await Settings.use('DeliveryDescription');
|
14
|
+
restrictions.minDeliveryTime = await Settings.use('minDeliveryTime') || "40";
|
15
|
+
return restrictions;
|
16
|
+
}
|
17
|
+
catch (e) {
|
18
|
+
sails.log.error(e);
|
19
|
+
throw new Error(0, JSON.stringify(e));
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
export default {
|
3
|
+
Query: {
|
4
|
+
restrictions: {
|
5
|
+
def: 'restrictions: Restrictions',
|
6
|
+
fn: async function (parent, args, context) {
|
7
|
+
try {
|
8
|
+
let restrictions :any = {};
|
9
|
+
restrictions.workTime = await Settings.use('workTime');
|
10
|
+
restrictions.periodPossibleForOrder = await Settings.use('PeriodPossibleForOrder');
|
11
|
+
restrictions.timezone = await Settings.use('timezone');
|
12
|
+
restrictions.deliveryDescription = await Settings.use('DeliveryDescription');
|
13
|
+
restrictions.minDeliveryTime = await Settings.use('minDeliveryTime') || "40";
|
14
|
+
return restrictions;
|
15
|
+
} catch (e) {
|
16
|
+
sails.log.error(e); throw new Error(0, JSON.stringify(e));
|
17
|
+
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = {
|
4
|
+
Query: {
|
5
|
+
streets: {
|
6
|
+
def: "streets: [Street]",
|
7
|
+
fn: async (parent, args, context, info) => {
|
8
|
+
let streetModel = await Settings.use("StreetModel");
|
9
|
+
if (!streetModel && !sails.models[streetModel])
|
10
|
+
streetModel = 'street';
|
11
|
+
const streets = await sails.models[streetModel.toLowerCase()].find({ isDeleted: false });
|
12
|
+
return streets;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export default {
|
2
|
+
Query: {
|
3
|
+
streets: {
|
4
|
+
def: "streets: [Street]",
|
5
|
+
fn: async (parent, args, context, info) => {
|
6
|
+
let streetModel = await Settings.use("StreetModel")
|
7
|
+
if (!streetModel && ! sails.models[streetModel]) streetModel = 'street'
|
8
|
+
const streets = await sails.models[streetModel.toLowerCase()].find({isDeleted: false});
|
9
|
+
return streets;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
declare const _default: {
|
2
|
+
Subscription: {
|
3
|
+
order: {
|
4
|
+
def: string;
|
5
|
+
fn: {
|
6
|
+
subscribe: any;
|
7
|
+
resolve: (payload: any) => any;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
message: {
|
11
|
+
def: string;
|
12
|
+
fn: {
|
13
|
+
subscribe: any;
|
14
|
+
resolve: (payload: any) => any;
|
15
|
+
};
|
16
|
+
};
|
17
|
+
action: {
|
18
|
+
def: string;
|
19
|
+
fn: {
|
20
|
+
subscribe: any;
|
21
|
+
resolve: (payload: any) => any;
|
22
|
+
};
|
23
|
+
};
|
24
|
+
maintenance: {
|
25
|
+
def: string;
|
26
|
+
fn: {
|
27
|
+
subscribe: any;
|
28
|
+
resolve: (payload: any) => any;
|
29
|
+
};
|
30
|
+
};
|
31
|
+
};
|
32
|
+
};
|
33
|
+
export default _default;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const { withFilter } = require('apollo-server');
|
4
|
+
exports.default = {
|
5
|
+
Subscription: {
|
6
|
+
order: {
|
7
|
+
def: 'order(orderId: String): Order',
|
8
|
+
fn: {
|
9
|
+
subscribe: withFilter((rootValue, args, context, info) => context.pubsub.asyncIterator('order-changed'), (payload, query) => {
|
10
|
+
return payload.id === query.orderId;
|
11
|
+
}),
|
12
|
+
resolve: payload => {
|
13
|
+
const order = payload;
|
14
|
+
return order;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
},
|
18
|
+
message: {
|
19
|
+
def: 'message(orderId: String): Message',
|
20
|
+
fn: {
|
21
|
+
subscribe: withFilter((rootValue, args, context, info) => context.pubsub.asyncIterator('message'), (payload, query) => {
|
22
|
+
return payload.orderId === query.orderId;
|
23
|
+
}),
|
24
|
+
resolve: payload => {
|
25
|
+
return payload.message;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
},
|
29
|
+
action: {
|
30
|
+
def: 'action(orderId: String): Action',
|
31
|
+
fn: {
|
32
|
+
subscribe: withFilter((rootValue, args, context, info) => context.pubsub.asyncIterator('action'), (payload, query) => {
|
33
|
+
return payload.orderId === query.orderId;
|
34
|
+
}),
|
35
|
+
resolve: payload => {
|
36
|
+
return payload.action;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
},
|
40
|
+
maintenance: {
|
41
|
+
def: 'maintenance: Maintenance',
|
42
|
+
fn: {
|
43
|
+
subscribe: withFilter((rootValue, args, context, info) => context.pubsub.asyncIterator('maintenance'), (payload, query) => {
|
44
|
+
return true;
|
45
|
+
}),
|
46
|
+
resolve: payload => {
|
47
|
+
return payload;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
};
|
@@ -0,0 +1,63 @@
|
|
1
|
+
const { withFilter } = require('apollo-server');
|
2
|
+
|
3
|
+
export default {
|
4
|
+
Subscription: {
|
5
|
+
order: {
|
6
|
+
def: 'order(orderId: String): Order',
|
7
|
+
fn: {
|
8
|
+
subscribe: withFilter(
|
9
|
+
(rootValue, args, context, info) => context.pubsub.asyncIterator('order-changed'),
|
10
|
+
(payload, query) => {
|
11
|
+
return payload.id === query.orderId;
|
12
|
+
}
|
13
|
+
),
|
14
|
+
resolve: payload => {
|
15
|
+
const order = payload;
|
16
|
+
return order;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
},
|
20
|
+
message: {
|
21
|
+
def: 'message(orderId: String): Message',
|
22
|
+
fn: {
|
23
|
+
subscribe: withFilter(
|
24
|
+
(rootValue, args, context, info) => context.pubsub.asyncIterator('message'),
|
25
|
+
(payload, query) => {
|
26
|
+
return payload.orderId === query.orderId;
|
27
|
+
}
|
28
|
+
),
|
29
|
+
resolve: payload => {
|
30
|
+
return payload.message;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
},
|
34
|
+
action: {
|
35
|
+
def: 'action(orderId: String): Action',
|
36
|
+
fn: {
|
37
|
+
subscribe: withFilter(
|
38
|
+
(rootValue, args, context, info) => context.pubsub.asyncIterator('action'),
|
39
|
+
(payload, query) => {
|
40
|
+
return payload.orderId === query.orderId;
|
41
|
+
}
|
42
|
+
),
|
43
|
+
resolve: payload => {
|
44
|
+
return payload.action;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
},
|
48
|
+
maintenance: {
|
49
|
+
def: 'maintenance: Maintenance',
|
50
|
+
fn: {
|
51
|
+
subscribe: withFilter(
|
52
|
+
(rootValue, args, context, info) => context.pubsub.asyncIterator('maintenance'),
|
53
|
+
(payload, query) => {
|
54
|
+
return true;
|
55
|
+
}
|
56
|
+
),
|
57
|
+
resolve: payload => {
|
58
|
+
return payload;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|