@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
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { getRecomendElements } from "../../lib/getRecomended";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
Query: {
|
|
5
|
+
recomendedForDish: {
|
|
6
|
+
def: 'recomendedForDish(dishId: String): [Dish]',
|
|
7
|
+
fn: async function (parent: any, args: any, context: any) {
|
|
8
|
+
try {
|
|
9
|
+
let criteria = {}
|
|
10
|
+
const RECOMENDED_GROUPID_FOR_DISHES = await Settings.get("RECOMENDED_GROUPID_FOR_DISHES") as string
|
|
11
|
+
|
|
12
|
+
let defaultGroup = null;
|
|
13
|
+
let listOfAllowedGroups = null;
|
|
14
|
+
if(RECOMENDED_GROUPID_FOR_DISHES){
|
|
15
|
+
defaultGroup = await Group.find({id: RECOMENDED_GROUPID_FOR_DISHES})
|
|
16
|
+
listOfAllowedGroups = await Group.getMenuTree(defaultGroup);
|
|
17
|
+
} else {
|
|
18
|
+
listOfAllowedGroups = await Group.getMenuTree();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let dish = await Dish.findOne({id: args.dishId});
|
|
22
|
+
|
|
23
|
+
criteria['where'] = {
|
|
24
|
+
'and': [
|
|
25
|
+
{ 'parentGroup': { 'in': listOfAllowedGroups } },
|
|
26
|
+
{ 'balance': { "!=": 0 } },
|
|
27
|
+
{ 'modifier': false },
|
|
28
|
+
{ 'isDeleted': false }
|
|
29
|
+
]
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (dish) {
|
|
33
|
+
criteria['where']['and'].push({'parentGroup': { "!=": dish.parentGroup}})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const array = await Dish.find(criteria);
|
|
37
|
+
return getRecomendElements(array, 7);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
sails.log.error(e);
|
|
40
|
+
throw `${JSON.stringify(e)}`
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
recomendedForOrder: {
|
|
45
|
+
def: 'recomendedForOrder(orderId: String): [Dish]',
|
|
46
|
+
fn: async function (parent: any, args: any, context: any) {
|
|
47
|
+
try {
|
|
48
|
+
|
|
49
|
+
const RECOMENDED_GROUPID_FOR_ORDER = await Settings.get("RECOMENDED_GROUPID_FOR_ORDER") as string
|
|
50
|
+
|
|
51
|
+
let orderDishes = await OrderDish.find({order: args.orderId});
|
|
52
|
+
const orderDishIds = orderDishes.map(orderDish => orderDish.dish as string);
|
|
53
|
+
let criteria = {}
|
|
54
|
+
let defaultGroup = null;
|
|
55
|
+
let listOfAllowedGroups = null;
|
|
56
|
+
|
|
57
|
+
if(RECOMENDED_GROUPID_FOR_ORDER){
|
|
58
|
+
defaultGroup = await Group.find({id: RECOMENDED_GROUPID_FOR_ORDER})
|
|
59
|
+
listOfAllowedGroups = await Group.getMenuTree(defaultGroup);
|
|
60
|
+
} else {
|
|
61
|
+
listOfAllowedGroups = await Group.getMenuTree();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
criteria['where'] = {
|
|
65
|
+
'and': [
|
|
66
|
+
{ 'parentGroup': { 'in': listOfAllowedGroups } },
|
|
67
|
+
{ 'balance': { "!=": 0 } },
|
|
68
|
+
{ 'modifier': false },
|
|
69
|
+
{ 'isDeleted': false }
|
|
70
|
+
]
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (orderDishIds.length) {
|
|
74
|
+
criteria["where"]["and"].push({id : {"!=": orderDishIds}})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const allDishes = await Dish.find(criteria)
|
|
78
|
+
return getRecomendElements(allDishes, 7);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
sails.log.error(e);
|
|
81
|
+
throw `${JSON.stringify(e)}`
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -1,9 +1,45 @@
|
|
|
1
|
+
type PasswordPolicy = "required" | "from_otp" | "disabled";
|
|
1
2
|
declare const _default: {
|
|
2
3
|
Query: {
|
|
3
4
|
restrictions: {
|
|
4
5
|
def: string;
|
|
5
|
-
fn: (
|
|
6
|
+
fn: () => {};
|
|
6
7
|
};
|
|
7
8
|
};
|
|
9
|
+
Restrictions: {
|
|
10
|
+
worktime: () => Promise<(string | number | boolean | string[] | number[]) | {
|
|
11
|
+
[key: string]: string | number | boolean;
|
|
12
|
+
}>;
|
|
13
|
+
graphqlSchemaBackwardCompatibilityVersion: () => number;
|
|
14
|
+
possibleToOrderInMinutes: () => Promise<number>;
|
|
15
|
+
minDeliveryTimeInMinutes: () => Promise<number>;
|
|
16
|
+
timezone: () => Promise<(string | number | boolean | string[] | number[]) | {
|
|
17
|
+
[key: string]: string | number | boolean;
|
|
18
|
+
}>;
|
|
19
|
+
captchaType: () => Promise<string | number | true | string[] | number[] | {
|
|
20
|
+
[key: string]: string | number | boolean;
|
|
21
|
+
}>;
|
|
22
|
+
deliveryDescription: () => Promise<(string | number | boolean | string[] | number[]) | {
|
|
23
|
+
[key: string]: string | number | boolean;
|
|
24
|
+
}>;
|
|
25
|
+
user: () => {};
|
|
26
|
+
};
|
|
27
|
+
UserRestrictions: {
|
|
28
|
+
loginField: () => Promise<string | number | true | string[] | number[] | {
|
|
29
|
+
[key: string]: string | number | boolean;
|
|
30
|
+
}>;
|
|
31
|
+
loginOTPRequired: () => Promise<string | number | boolean | string[] | number[] | {
|
|
32
|
+
[key: string]: string | number | boolean;
|
|
33
|
+
}>;
|
|
34
|
+
customFields: () => Promise<string | number | true | string[] | number[] | {
|
|
35
|
+
[key: string]: string | number | boolean;
|
|
36
|
+
}>;
|
|
37
|
+
passwordPolicy: () => Promise<PasswordPolicy>;
|
|
38
|
+
allowedPhoneCountries: () => Promise<any[]>;
|
|
39
|
+
linkToProcessingPersonalData: () => string;
|
|
40
|
+
linkToUserAgreement: () => string;
|
|
41
|
+
OTPlength: () => number;
|
|
42
|
+
allowBonusSpending: () => Promise<boolean>;
|
|
43
|
+
};
|
|
8
44
|
};
|
|
9
45
|
export default _default;
|
|
@@ -1,24 +1,109 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const graphqlHelper_1 = require("../../lib/graphqlHelper");
|
|
4
|
+
graphqlHelper_1.default.addType(`#graphql
|
|
5
|
+
type UserRestrictions {
|
|
6
|
+
"Indicate main login field"
|
|
7
|
+
loginField: String
|
|
8
|
+
"Indicate required OTP on any login"
|
|
9
|
+
loginOTPRequired: Boolean
|
|
10
|
+
|
|
11
|
+
"List of all custom user fields"
|
|
12
|
+
customFields: [UserCustomField]
|
|
13
|
+
|
|
14
|
+
"Password is required in users accounts"
|
|
15
|
+
passwordPolicy: String
|
|
16
|
+
|
|
17
|
+
"Countries for send OTP"
|
|
18
|
+
allowedPhoneCountries: [Country],
|
|
19
|
+
|
|
20
|
+
linkToProcessingPersonalData: String,
|
|
21
|
+
|
|
22
|
+
linkToUserAgreement: String
|
|
23
|
+
|
|
24
|
+
"Allow spening bonuses"
|
|
25
|
+
allowBonusSpending: Boolean
|
|
26
|
+
|
|
27
|
+
"OTP code Length"
|
|
28
|
+
OTPlength: Int
|
|
29
|
+
}
|
|
30
|
+
type Restrictions {
|
|
31
|
+
"graphql scehma backward compatibility version"
|
|
32
|
+
graphqlSchemaBackwardCompatibilityVersion: Int
|
|
33
|
+
|
|
34
|
+
"Delivery service working time"
|
|
35
|
+
worktime: Json
|
|
36
|
+
|
|
37
|
+
"Time possible for order from now"
|
|
38
|
+
possibleToOrderInMinutes: Int
|
|
39
|
+
timezone: String
|
|
40
|
+
"By default is POW"
|
|
41
|
+
captchaType: String
|
|
42
|
+
"Global delivery discription"
|
|
43
|
+
deliveryDescription: Json
|
|
44
|
+
"The minimum time for which delivery of the order is possible"
|
|
45
|
+
minDeliveryTimeInMinutes: Int
|
|
46
|
+
"Group User restrictions"
|
|
47
|
+
user: UserRestrictions
|
|
48
|
+
}
|
|
49
|
+
`);
|
|
3
50
|
exports.default = {
|
|
4
51
|
Query: {
|
|
5
52
|
restrictions: {
|
|
6
53
|
def: 'restrictions: Restrictions',
|
|
7
|
-
fn:
|
|
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
|
-
}
|
|
54
|
+
fn: () => ({})
|
|
22
55
|
}
|
|
56
|
+
},
|
|
57
|
+
Restrictions: {
|
|
58
|
+
worktime: async () => await Settings.get('WORK_TIME'),
|
|
59
|
+
graphqlSchemaBackwardCompatibilityVersion: () => 1,
|
|
60
|
+
possibleToOrderInMinutes: async () => isNaN(parseInt(await Settings.get('POSSIBLE_TO_ORDER_IN_MINUTES'))) ? 7 * 24 * 60 : parseInt(await Settings.get('POSSIBLE_TO_ORDER_IN_MINUTES')),
|
|
61
|
+
minDeliveryTimeInMinutes: async () => isNaN(parseInt(await Settings.get('MIN_DELIVERY_TIME_IN_MINUTES'))) ? 40 : parseInt(await Settings.get('MIN_DELIVERY_TIME_IN_MINUTES')),
|
|
62
|
+
timezone: async () => {
|
|
63
|
+
return await Settings.get('TZ') ?? 'Etc/GMT';
|
|
64
|
+
},
|
|
65
|
+
captchaType: async () => await Settings.get('CAPTCHA_TYPE') || "POW",
|
|
66
|
+
deliveryDescription: async () => await Settings.get('DELIVERY_DESCRIPTION'),
|
|
67
|
+
user: () => ({}), // Dummy resolver to nest the fields below
|
|
68
|
+
},
|
|
69
|
+
UserRestrictions: {
|
|
70
|
+
loginField: async () => {
|
|
71
|
+
let loginField = await Settings.get("LOGIN_FIELD");
|
|
72
|
+
return loginField || 'phone';
|
|
73
|
+
},
|
|
74
|
+
loginOTPRequired: async () => {
|
|
75
|
+
let loginOTPRequired = await Settings.get("LOGIN_OTP_REQUIRED");
|
|
76
|
+
return loginOTPRequired || false;
|
|
77
|
+
},
|
|
78
|
+
customFields: async () => {
|
|
79
|
+
let customFields = await Settings.get("CUSTOM_FIELDS");
|
|
80
|
+
return customFields || [];
|
|
81
|
+
},
|
|
82
|
+
passwordPolicy: async () => {
|
|
83
|
+
let passwordPolicy = await Settings.get("PASSWORD_POLICY");
|
|
84
|
+
return passwordPolicy || "from_otp";
|
|
85
|
+
},
|
|
86
|
+
allowedPhoneCountries: async () => {
|
|
87
|
+
let allowedPhoneCountriesList = [];
|
|
88
|
+
// ALLOWED_PHONE_COUNTRIES
|
|
89
|
+
let allowedPhoneCountries = await Settings.get("ALLOWED_PHONE_COUNTRIES");
|
|
90
|
+
if (typeof allowedPhoneCountries === "string")
|
|
91
|
+
allowedPhoneCountries = [allowedPhoneCountries];
|
|
92
|
+
if (Array.isArray(allowedPhoneCountries) && typeof allowedPhoneCountries[0] === "string") {
|
|
93
|
+
allowedPhoneCountries.forEach(allowedPhoneCountry => {
|
|
94
|
+
let country = sails.hooks.restocore.dictionaries.countries[allowedPhoneCountry];
|
|
95
|
+
if (country) {
|
|
96
|
+
allowedPhoneCountriesList.push(country);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return allowedPhoneCountriesList;
|
|
101
|
+
},
|
|
102
|
+
linkToProcessingPersonalData: () => "/static/processing_personal_data",
|
|
103
|
+
linkToUserAgreement: () => "/static/user_agreement",
|
|
104
|
+
OTPlength: () => 6,
|
|
105
|
+
allowBonusSpending: async () => {
|
|
106
|
+
return await Settings.get("ALLOW_BONUS_SPENDING") ?? true;
|
|
107
|
+
},
|
|
23
108
|
}
|
|
24
109
|
};
|
|
@@ -1,22 +1,114 @@
|
|
|
1
|
+
import graphqlHelper from "../../lib/graphqlHelper";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
type PasswordPolicy = "required" | "from_otp" | "disabled"
|
|
6
|
+
graphqlHelper.addType(`#graphql
|
|
7
|
+
type UserRestrictions {
|
|
8
|
+
"Indicate main login field"
|
|
9
|
+
loginField: String
|
|
10
|
+
"Indicate required OTP on any login"
|
|
11
|
+
loginOTPRequired: Boolean
|
|
12
|
+
|
|
13
|
+
"List of all custom user fields"
|
|
14
|
+
customFields: [UserCustomField]
|
|
15
|
+
|
|
16
|
+
"Password is required in users accounts"
|
|
17
|
+
passwordPolicy: String
|
|
18
|
+
|
|
19
|
+
"Countries for send OTP"
|
|
20
|
+
allowedPhoneCountries: [Country],
|
|
21
|
+
|
|
22
|
+
linkToProcessingPersonalData: String,
|
|
23
|
+
|
|
24
|
+
linkToUserAgreement: String
|
|
25
|
+
|
|
26
|
+
"Allow spening bonuses"
|
|
27
|
+
allowBonusSpending: Boolean
|
|
28
|
+
|
|
29
|
+
"OTP code Length"
|
|
30
|
+
OTPlength: Int
|
|
31
|
+
}
|
|
32
|
+
type Restrictions {
|
|
33
|
+
"graphql scehma backward compatibility version"
|
|
34
|
+
graphqlSchemaBackwardCompatibilityVersion: Int
|
|
35
|
+
|
|
36
|
+
"Delivery service working time"
|
|
37
|
+
worktime: Json
|
|
38
|
+
|
|
39
|
+
"Time possible for order from now"
|
|
40
|
+
possibleToOrderInMinutes: Int
|
|
41
|
+
timezone: String
|
|
42
|
+
"By default is POW"
|
|
43
|
+
captchaType: String
|
|
44
|
+
"Global delivery discription"
|
|
45
|
+
deliveryDescription: Json
|
|
46
|
+
"The minimum time for which delivery of the order is possible"
|
|
47
|
+
minDeliveryTimeInMinutes: Int
|
|
48
|
+
"Group User restrictions"
|
|
49
|
+
user: UserRestrictions
|
|
50
|
+
}
|
|
51
|
+
`);
|
|
1
52
|
|
|
2
53
|
export default {
|
|
3
54
|
Query: {
|
|
4
55
|
restrictions: {
|
|
5
56
|
def: 'restrictions: Restrictions',
|
|
6
|
-
fn:
|
|
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
|
-
}
|
|
57
|
+
fn: () => ({})
|
|
20
58
|
}
|
|
59
|
+
},
|
|
60
|
+
Restrictions: {
|
|
61
|
+
worktime: async () => await Settings.get('WORK_TIME'),
|
|
62
|
+
graphqlSchemaBackwardCompatibilityVersion: () => 1,
|
|
63
|
+
possibleToOrderInMinutes: async () => isNaN(parseInt(await Settings.get('POSSIBLE_TO_ORDER_IN_MINUTES') as string)) ? 7 * 24 * 60 : parseInt(await Settings.get('POSSIBLE_TO_ORDER_IN_MINUTES') as string),
|
|
64
|
+
minDeliveryTimeInMinutes: async () => isNaN(parseInt(await Settings.get('MIN_DELIVERY_TIME_IN_MINUTES') as string)) ? 40 : parseInt(await Settings.get('MIN_DELIVERY_TIME_IN_MINUTES') as string),
|
|
65
|
+
timezone: async () => {
|
|
66
|
+
return await Settings.get('TZ') ?? 'Etc/GMT'
|
|
67
|
+
},
|
|
68
|
+
captchaType: async () => await Settings.get('CAPTCHA_TYPE') || "POW",
|
|
69
|
+
deliveryDescription: async () => await Settings.get('DELIVERY_DESCRIPTION'),
|
|
70
|
+
user: () => ({}), // Dummy resolver to nest the fields below
|
|
71
|
+
},
|
|
72
|
+
UserRestrictions: {
|
|
73
|
+
loginField: async () => {
|
|
74
|
+
let loginField = await Settings.get("LOGIN_FIELD");
|
|
75
|
+
return loginField || 'phone';
|
|
76
|
+
},
|
|
77
|
+
loginOTPRequired: async () => {
|
|
78
|
+
let loginOTPRequired = await Settings.get("LOGIN_OTP_REQUIRED");
|
|
79
|
+
return loginOTPRequired || false;
|
|
80
|
+
},
|
|
81
|
+
customFields: async () => {
|
|
82
|
+
let customFields = await Settings.get("CUSTOM_FIELDS");
|
|
83
|
+
return customFields || [];
|
|
84
|
+
},
|
|
85
|
+
passwordPolicy: async () => {
|
|
86
|
+
let passwordPolicy = await Settings.get("PASSWORD_POLICY") as PasswordPolicy;
|
|
87
|
+
return passwordPolicy || "from_otp";
|
|
88
|
+
},
|
|
89
|
+
allowedPhoneCountries: async () => {
|
|
90
|
+
let allowedPhoneCountriesList = [];
|
|
91
|
+
|
|
92
|
+
// ALLOWED_PHONE_COUNTRIES
|
|
93
|
+
let allowedPhoneCountries = await Settings.get("ALLOWED_PHONE_COUNTRIES") as string | string[];
|
|
94
|
+
if (typeof allowedPhoneCountries === "string") allowedPhoneCountries = [allowedPhoneCountries];
|
|
95
|
+
|
|
96
|
+
if (Array.isArray(allowedPhoneCountries) && typeof allowedPhoneCountries[0] === "string") {
|
|
97
|
+
allowedPhoneCountries.forEach(allowedPhoneCountry => {
|
|
98
|
+
let country = sails.hooks.restocore.dictionaries.countries[allowedPhoneCountry]
|
|
99
|
+
if (country) {
|
|
100
|
+
allowedPhoneCountriesList.push(country)
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return allowedPhoneCountriesList;
|
|
106
|
+
},
|
|
107
|
+
linkToProcessingPersonalData: () => "/static/processing_personal_data",
|
|
108
|
+
linkToUserAgreement: () => "/static/user_agreement",
|
|
109
|
+
OTPlength: () => 6,
|
|
110
|
+
allowBonusSpending: async () => {
|
|
111
|
+
return await Settings.get("ALLOW_BONUS_SPENDING") as boolean ?? true;
|
|
112
|
+
},
|
|
21
113
|
}
|
|
22
114
|
}
|
|
@@ -2,7 +2,7 @@ declare const _default: {
|
|
|
2
2
|
Query: {
|
|
3
3
|
streets: {
|
|
4
4
|
def: string;
|
|
5
|
-
fn: (parent: any, args: any, context: any, info: any) => Promise<
|
|
5
|
+
fn: (parent: any, args: any, context: any, info: any) => Promise<import("@webresto/core/models/Street").default[]>;
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
8
|
};
|
package/src/resolvers/streets.js
CHANGED
|
@@ -5,10 +5,7 @@ exports.default = {
|
|
|
5
5
|
streets: {
|
|
6
6
|
def: "streets: [Street]",
|
|
7
7
|
fn: async (parent, args, context, info) => {
|
|
8
|
-
|
|
9
|
-
if (!streetModel && !sails.models[streetModel])
|
|
10
|
-
streetModel = 'street';
|
|
11
|
-
const streets = await sails.models[streetModel.toLowerCase()].find({ isDeleted: false });
|
|
8
|
+
const streets = await Street.find({ isDeleted: false });
|
|
12
9
|
return streets;
|
|
13
10
|
}
|
|
14
11
|
}
|
package/src/resolvers/streets.ts
CHANGED
|
@@ -3,9 +3,7 @@ export default {
|
|
|
3
3
|
streets: {
|
|
4
4
|
def: "streets: [Street]",
|
|
5
5
|
fn: async (parent, args, context, info) => {
|
|
6
|
-
|
|
7
|
-
if (!streetModel && ! sails.models[streetModel]) streetModel = 'street'
|
|
8
|
-
const streets = await sails.models[streetModel.toLowerCase()].find({isDeleted: false});
|
|
6
|
+
const streets = await Street.find({isDeleted: false});
|
|
9
7
|
return streets;
|
|
10
8
|
}
|
|
11
9
|
}
|
|
@@ -3,28 +3,28 @@ declare const _default: {
|
|
|
3
3
|
order: {
|
|
4
4
|
def: string;
|
|
5
5
|
fn: {
|
|
6
|
-
subscribe:
|
|
6
|
+
subscribe: import("apollo-server").ResolverFn;
|
|
7
7
|
resolve: (payload: any) => any;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
message: {
|
|
11
11
|
def: string;
|
|
12
12
|
fn: {
|
|
13
|
-
subscribe:
|
|
13
|
+
subscribe: import("apollo-server").ResolverFn;
|
|
14
14
|
resolve: (payload: any) => any;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
action: {
|
|
18
18
|
def: string;
|
|
19
19
|
fn: {
|
|
20
|
-
subscribe:
|
|
20
|
+
subscribe: import("apollo-server").ResolverFn;
|
|
21
21
|
resolve: (payload: any) => any;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
maintenance: {
|
|
25
25
|
def: string;
|
|
26
26
|
fn: {
|
|
27
|
-
subscribe:
|
|
27
|
+
subscribe: import("apollo-server").ResolverFn;
|
|
28
28
|
resolve: (payload: any) => any;
|
|
29
29
|
};
|
|
30
30
|
};
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const apollo_server_1 = require("apollo-server");
|
|
4
4
|
exports.default = {
|
|
5
5
|
Subscription: {
|
|
6
6
|
order: {
|
|
7
|
-
def:
|
|
7
|
+
def: `#graphql
|
|
8
|
+
"If you authorized you should send Authorization header;"
|
|
9
|
+
order(deviceId: String): Order
|
|
10
|
+
`,
|
|
8
11
|
fn: {
|
|
9
|
-
subscribe: withFilter((rootValue, args, context, info) =>
|
|
10
|
-
|
|
12
|
+
subscribe: (0, apollo_server_1.withFilter)((rootValue, args, context, info) => {
|
|
13
|
+
if (args.deviceId) {
|
|
14
|
+
context.connectionParams.deviceId = args.deviceId;
|
|
15
|
+
}
|
|
16
|
+
if (!context.connectionParams.deviceId) {
|
|
17
|
+
throw `Missed deviceId`;
|
|
18
|
+
}
|
|
19
|
+
return context.pubsub.asyncIterator('order-changed');
|
|
20
|
+
}, (payload, query, context, info) => {
|
|
21
|
+
return payload.deviceId === context.connectionParams.deviceId;
|
|
11
22
|
}),
|
|
12
23
|
resolve: payload => {
|
|
13
24
|
const order = payload;
|
|
@@ -16,10 +27,22 @@ exports.default = {
|
|
|
16
27
|
}
|
|
17
28
|
},
|
|
18
29
|
message: {
|
|
19
|
-
def:
|
|
30
|
+
def: `#graphql
|
|
31
|
+
"If you authorized you should send Authorization header, and pass X-Device-Id header;"
|
|
32
|
+
message(deviceId: String): Message
|
|
33
|
+
`,
|
|
20
34
|
fn: {
|
|
21
|
-
subscribe: withFilter((rootValue, args, context, info) =>
|
|
22
|
-
|
|
35
|
+
subscribe: (0, apollo_server_1.withFilter)((rootValue, args, context, info) => {
|
|
36
|
+
if (args.deviceId) {
|
|
37
|
+
context.connectionParams.deviceId = args.deviceId;
|
|
38
|
+
}
|
|
39
|
+
if (!context.connectionParams.deviceId) {
|
|
40
|
+
throw `Missed deviceId`;
|
|
41
|
+
}
|
|
42
|
+
return context.pubsub.asyncIterator('message');
|
|
43
|
+
}, (payload, query, context, info) => {
|
|
44
|
+
console.log(payload.deviceId, context.connectionParams.deviceId);
|
|
45
|
+
return payload.deviceId === context.connectionParams.deviceId;
|
|
23
46
|
}),
|
|
24
47
|
resolve: payload => {
|
|
25
48
|
return payload.message;
|
|
@@ -27,10 +50,22 @@ exports.default = {
|
|
|
27
50
|
}
|
|
28
51
|
},
|
|
29
52
|
action: {
|
|
30
|
-
def:
|
|
53
|
+
def: `#graphql
|
|
54
|
+
"If you authorized you should send Authorization header, and pass X-Device-Id header; Please read full documentation for Actions https://docs.webresto.org/docs/graphql/actions/"
|
|
55
|
+
action(deviceId: String): Action
|
|
56
|
+
`,
|
|
31
57
|
fn: {
|
|
32
|
-
subscribe: withFilter((rootValue, args, context, info) =>
|
|
33
|
-
|
|
58
|
+
subscribe: (0, apollo_server_1.withFilter)((rootValue, args, context, info) => {
|
|
59
|
+
if (args.deviceId) {
|
|
60
|
+
context.connectionParams.deviceId = args.deviceId;
|
|
61
|
+
}
|
|
62
|
+
if (!context.connectionParams.deviceId) {
|
|
63
|
+
throw `Missed deviceId`;
|
|
64
|
+
}
|
|
65
|
+
return context.pubsub.asyncIterator('action');
|
|
66
|
+
}, (payload, query, context, info) => {
|
|
67
|
+
console.log(payload.deviceId, context.connectionParams.deviceId);
|
|
68
|
+
return payload.deviceId === context.connectionParams.deviceId;
|
|
34
69
|
}),
|
|
35
70
|
resolve: payload => {
|
|
36
71
|
return payload.action;
|
|
@@ -38,9 +73,11 @@ exports.default = {
|
|
|
38
73
|
}
|
|
39
74
|
},
|
|
40
75
|
maintenance: {
|
|
41
|
-
def:
|
|
76
|
+
def: `
|
|
77
|
+
"No maintenance when recive null"
|
|
78
|
+
maintenance: Maintenance`,
|
|
42
79
|
fn: {
|
|
43
|
-
subscribe: withFilter((rootValue, args, context, info) => context.pubsub.asyncIterator('maintenance'), (payload, query) => {
|
|
80
|
+
subscribe: (0, apollo_server_1.withFilter)((rootValue, args, context, info) => context.pubsub.asyncIterator('maintenance'), (payload, query) => {
|
|
44
81
|
return true;
|
|
45
82
|
}),
|
|
46
83
|
resolve: payload => {
|
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
import { withFilter } from 'apollo-server';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
Subscription: {
|
|
5
5
|
order: {
|
|
6
|
-
def:
|
|
6
|
+
def: `#graphql
|
|
7
|
+
"If you authorized you should send Authorization header;"
|
|
8
|
+
order(deviceId: String): Order
|
|
9
|
+
`,
|
|
7
10
|
fn: {
|
|
8
11
|
subscribe: withFilter(
|
|
9
|
-
(rootValue, args, context, info) =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
(rootValue, args, context, info) => {
|
|
13
|
+
if(args.deviceId) {
|
|
14
|
+
context.connectionParams.deviceId = args.deviceId;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!context.connectionParams.deviceId) {
|
|
18
|
+
throw `Missed deviceId`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return context.pubsub.asyncIterator('order-changed')
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
(payload, query, context, info) => {
|
|
25
|
+
return payload.deviceId === context.connectionParams.deviceId;
|
|
12
26
|
}
|
|
13
27
|
),
|
|
14
28
|
resolve: payload => {
|
|
@@ -18,12 +32,27 @@ export default {
|
|
|
18
32
|
}
|
|
19
33
|
},
|
|
20
34
|
message: {
|
|
21
|
-
def:
|
|
35
|
+
def: `#graphql
|
|
36
|
+
"If you authorized you should send Authorization header, and pass X-Device-Id header;"
|
|
37
|
+
message(deviceId: String): Message
|
|
38
|
+
`,
|
|
22
39
|
fn: {
|
|
23
40
|
subscribe: withFilter(
|
|
24
|
-
(rootValue, args, context, info) =>
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
(rootValue, args, context, info) => {
|
|
42
|
+
|
|
43
|
+
if(args.deviceId) {
|
|
44
|
+
context.connectionParams.deviceId = args.deviceId;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!context.connectionParams.deviceId) {
|
|
48
|
+
throw `Missed deviceId`
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return context.pubsub.asyncIterator('message')
|
|
52
|
+
},
|
|
53
|
+
(payload, query, context, info) => {
|
|
54
|
+
console.log(payload.deviceId, context.connectionParams.deviceId)
|
|
55
|
+
return payload.deviceId === context.connectionParams.deviceId;
|
|
27
56
|
}
|
|
28
57
|
),
|
|
29
58
|
resolve: payload => {
|
|
@@ -32,12 +61,26 @@ export default {
|
|
|
32
61
|
}
|
|
33
62
|
},
|
|
34
63
|
action: {
|
|
35
|
-
def:
|
|
64
|
+
def: `#graphql
|
|
65
|
+
"If you authorized you should send Authorization header, and pass X-Device-Id header; Please read full documentation for Actions https://docs.webresto.org/docs/graphql/actions/"
|
|
66
|
+
action(deviceId: String): Action
|
|
67
|
+
`,
|
|
36
68
|
fn: {
|
|
37
69
|
subscribe: withFilter(
|
|
38
|
-
(rootValue, args, context, info) =>
|
|
39
|
-
|
|
40
|
-
|
|
70
|
+
(rootValue, args, context, info) => {
|
|
71
|
+
if(args.deviceId) {
|
|
72
|
+
context.connectionParams.deviceId = args.deviceId;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!context.connectionParams.deviceId) {
|
|
76
|
+
throw `Missed deviceId`
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return context.pubsub.asyncIterator('action')
|
|
80
|
+
},
|
|
81
|
+
(payload, query, context, info) => {
|
|
82
|
+
console.log(payload.deviceId, context.connectionParams.deviceId)
|
|
83
|
+
return payload.deviceId === context.connectionParams.deviceId;
|
|
41
84
|
}
|
|
42
85
|
),
|
|
43
86
|
resolve: payload => {
|
|
@@ -46,7 +89,9 @@ export default {
|
|
|
46
89
|
}
|
|
47
90
|
},
|
|
48
91
|
maintenance: {
|
|
49
|
-
def:
|
|
92
|
+
def: `
|
|
93
|
+
"No maintenance when recive null"
|
|
94
|
+
maintenance: Maintenance`,
|
|
50
95
|
fn: {
|
|
51
96
|
subscribe: withFilter(
|
|
52
97
|
(rootValue, args, context, info) => context.pubsub.asyncIterator('maintenance'),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
Query: {
|
|
3
|
+
telemetry: {
|
|
4
|
+
def: string;
|
|
5
|
+
fn: () => {};
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
Telemetry: {
|
|
9
|
+
uptime: () => number;
|
|
10
|
+
i18n: (parent: any, args: any, context: any, info: any) => any;
|
|
11
|
+
locale: (parent: any, args: any, context: any, info: any) => any;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|