@lyxa.ai/core 1.4.313-alpha-2 → 1.4.313-alpha-5
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/dist/libraries/mongo/models/service-control.model.d.ts +2 -0
- package/dist/libraries/mongo/models/service-control.model.js +10 -0
- package/dist/libraries/mongo/models/service-control.model.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/libraries/mongo/models/service-control.model.d.ts +2 -0
- package/dist/types/libraries/mongo/models/service-control.model.js +10 -0
- package/dist/types/libraries/mongo/models/service-control.model.js.map +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/shared/common-methods.d.ts +5 -4
- package/dist/types/utilities/shared/common-methods.js +24 -4
- package/dist/types/utilities/shared/common-methods.js.map +1 -1
- package/dist/utilities/shared/common-methods.d.ts +5 -4
- package/dist/utilities/shared/common-methods.js +24 -4
- package/dist/utilities/shared/common-methods.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,8 @@ export declare class ServiceControl extends TimeStamps {
|
|
|
11
11
|
isTagVisible?: boolean;
|
|
12
12
|
isListContainerVisible?: boolean;
|
|
13
13
|
isSearchAble?: boolean;
|
|
14
|
+
isFeaturedMarketingAllowed?: boolean;
|
|
15
|
+
isDiscountMarketingAllowed?: boolean;
|
|
14
16
|
productConfig?: ServiceControlProductConfig;
|
|
15
17
|
imageUrl?: string;
|
|
16
18
|
sortingOrder?: number;
|
|
@@ -26,6 +26,8 @@ let ServiceControl = class ServiceControl extends defaultClasses_1.TimeStamps {
|
|
|
26
26
|
isTagVisible;
|
|
27
27
|
isListContainerVisible;
|
|
28
28
|
isSearchAble;
|
|
29
|
+
isFeaturedMarketingAllowed;
|
|
30
|
+
isDiscountMarketingAllowed;
|
|
29
31
|
productConfig;
|
|
30
32
|
imageUrl;
|
|
31
33
|
sortingOrder;
|
|
@@ -67,6 +69,14 @@ __decorate([
|
|
|
67
69
|
(0, typegoose_1.prop)({ type: Boolean }),
|
|
68
70
|
__metadata("design:type", Boolean)
|
|
69
71
|
], ServiceControl.prototype, "isSearchAble", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, typegoose_1.prop)({ type: Boolean }),
|
|
74
|
+
__metadata("design:type", Boolean)
|
|
75
|
+
], ServiceControl.prototype, "isFeaturedMarketingAllowed", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, typegoose_1.prop)({ type: Boolean }),
|
|
78
|
+
__metadata("design:type", Boolean)
|
|
79
|
+
], ServiceControl.prototype, "isDiscountMarketingAllowed", void 0);
|
|
70
80
|
__decorate([
|
|
71
81
|
(0, typegoose_1.prop)({ type: service_control_product_config_model_1.ServiceControlProductConfig }),
|
|
72
82
|
__metadata("design:type", service_control_product_config_model_1.ServiceControlProductConfig)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-control.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-control.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wBAAwC;AACxC,4EAAqE;AACrE,oDAAsE;AACtE,0EAA2E;AAC3E,kDAAuF;AACvF,0GAA8F;AAWvF,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,2BAAU;IAEtC,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,WAAW,CAA6B;IAGxC,iBAAiB,CAAqB;IAGtC,QAAQ,CAAW;IAGnB,kBAAkB,CAAW;IAG7B,YAAY,CAAW;IAGvB,sBAAsB,CAAW;IAGjC,YAAY,CAAW;IAGvB,aAAa,CAA+B;IAG5C,QAAQ,CAAU;IAGlB,YAAY,CAAU;CAC7B,CAAA;
|
|
1
|
+
{"version":3,"file":"service-control.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-control.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wBAAwC;AACxC,4EAAqE;AACrE,oDAAsE;AACtE,0EAA2E;AAC3E,kDAAuF;AACvF,0GAA8F;AAWvF,IAAM,cAAc,GAApB,MAAM,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EACoB;AAGrC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,kEAA2B,EAAE,CAAC;8BACrB,kEAA2B;qDAAC;AAG5C;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDACE;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDACM;yBAzCjB,cAAc;IAT1B,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IAClF,IAAA,iBAAK,EAAC,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IAC1F,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,CAAC;IAClE,IAAA,eAAG,EAAiB,MAAM,EAAE,KAAK,WAAW,IAAI;QAEhD,MAAM,6CAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,sBAAmB,CAAC,CAAC;QAE9D,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,cAAc,CA0C1B","sourcesContent":["import { ServiceControlModel } from '.';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Index, modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { handlePreSaveForSorting } from '../utilities/sorting-order.hooks';\nimport { ServiceControlServiceType, ServiceFamilyType } from '../../../utilities/enum';\nimport { ServiceControlProductConfig } from './embedded/service-control-product-config.model';\n\n@Index({ name: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@Index({ sortingOrder: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@modelOptions({ schemaOptions: { collection: 'service-control' } })\n@pre<ServiceControl>('save', async function (next) {\n\t// Set sortingOrder\n\tawait handlePreSaveForSorting.call(this, ServiceControlModel);\n\n\tnext();\n})\nexport class ServiceControl extends TimeStamps {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic alias?: string;\n\n\t@prop({ required: true, enum: ServiceControlServiceType })\n\tpublic serviceType!: ServiceControlServiceType;\n\n\t@prop({ enum: ServiceFamilyType })\n\tpublic serviceFamilyType?: ServiceFamilyType;\n\n\t@prop({ type: Boolean })\n\tpublic isCoffee?: boolean;\n\n\t@prop({ required: true, type: Boolean })\n\tpublic isVisibleToUserApp!: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isTagVisible?: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isListContainerVisible?: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isSearchAble?: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isFeaturedMarketingAllowed?: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isDiscountMarketingAllowed?: boolean;\n\n\t@prop({ type: ServiceControlProductConfig })\n\tpublic productConfig?: ServiceControlProductConfig;\n\n\t@prop({ type: String })\n\tpublic imageUrl?: string;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
package/dist/types/README.md
CHANGED
|
@@ -11,6 +11,8 @@ export declare class ServiceControl extends TimeStamps {
|
|
|
11
11
|
isTagVisible?: boolean;
|
|
12
12
|
isListContainerVisible?: boolean;
|
|
13
13
|
isSearchAble?: boolean;
|
|
14
|
+
isFeaturedMarketingAllowed?: boolean;
|
|
15
|
+
isDiscountMarketingAllowed?: boolean;
|
|
14
16
|
productConfig?: ServiceControlProductConfig;
|
|
15
17
|
imageUrl?: string;
|
|
16
18
|
sortingOrder?: number;
|
|
@@ -26,6 +26,8 @@ let ServiceControl = class ServiceControl extends defaultClasses_1.TimeStamps {
|
|
|
26
26
|
isTagVisible;
|
|
27
27
|
isListContainerVisible;
|
|
28
28
|
isSearchAble;
|
|
29
|
+
isFeaturedMarketingAllowed;
|
|
30
|
+
isDiscountMarketingAllowed;
|
|
29
31
|
productConfig;
|
|
30
32
|
imageUrl;
|
|
31
33
|
sortingOrder;
|
|
@@ -67,6 +69,14 @@ __decorate([
|
|
|
67
69
|
(0, typegoose_1.prop)({ type: Boolean }),
|
|
68
70
|
__metadata("design:type", Boolean)
|
|
69
71
|
], ServiceControl.prototype, "isSearchAble", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, typegoose_1.prop)({ type: Boolean }),
|
|
74
|
+
__metadata("design:type", Boolean)
|
|
75
|
+
], ServiceControl.prototype, "isFeaturedMarketingAllowed", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, typegoose_1.prop)({ type: Boolean }),
|
|
78
|
+
__metadata("design:type", Boolean)
|
|
79
|
+
], ServiceControl.prototype, "isDiscountMarketingAllowed", void 0);
|
|
70
80
|
__decorate([
|
|
71
81
|
(0, typegoose_1.prop)({ type: service_control_product_config_model_1.ServiceControlProductConfig }),
|
|
72
82
|
__metadata("design:type", service_control_product_config_model_1.ServiceControlProductConfig)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-control.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-control.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wBAAwC;AACxC,4EAAqE;AACrE,oDAAsE;AACtE,0EAA2E;AAC3E,kDAAuF;AACvF,0GAA8F;AAWvF,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,2BAAU;IAEtC,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,WAAW,CAA6B;IAGxC,iBAAiB,CAAqB;IAGtC,QAAQ,CAAW;IAGnB,kBAAkB,CAAW;IAG7B,YAAY,CAAW;IAGvB,sBAAsB,CAAW;IAGjC,YAAY,CAAW;IAGvB,aAAa,CAA+B;IAG5C,QAAQ,CAAU;IAGlB,YAAY,CAAU;CAC7B,CAAA;
|
|
1
|
+
{"version":3,"file":"service-control.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C,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;oDACM;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;kEACoB;AAGrC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;kEACoB;AAGrC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,kEAA2B,EAAE,CAAC;8BACrB,kEAA2B;qDAAC;AAG5C;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDACE;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDACM;yBAzCjB,cAAc;IAT1B,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IAClF,IAAA,iBAAK,EAAC,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IAC1F,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,CAAC;IAClE,IAAA,eAAG,EAAiB,MAAM,EAAE,KAAK,WAAW,IAAI;QAEhD,MAAM,6CAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,sBAAmB,CAAC,CAAC;QAE9D,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,cAAc,CA0C1B","sourcesContent":["import { ServiceControlModel } from '.';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Index, modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { handlePreSaveForSorting } from '../utilities/sorting-order.hooks';\nimport { ServiceControlServiceType, ServiceFamilyType } from '../../../utilities/enum';\nimport { ServiceControlProductConfig } from './embedded/service-control-product-config.model';\n\n@Index({ name: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@Index({ sortingOrder: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@modelOptions({ schemaOptions: { collection: 'service-control' } })\n@pre<ServiceControl>('save', async function (next) {\n\t// Set sortingOrder\n\tawait handlePreSaveForSorting.call(this, ServiceControlModel);\n\n\tnext();\n})\nexport class ServiceControl extends TimeStamps {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic alias?: string;\n\n\t@prop({ required: true, enum: ServiceControlServiceType })\n\tpublic serviceType!: ServiceControlServiceType;\n\n\t@prop({ enum: ServiceFamilyType })\n\tpublic serviceFamilyType?: ServiceFamilyType;\n\n\t@prop({ type: Boolean })\n\tpublic isCoffee?: boolean;\n\n\t@prop({ required: true, type: Boolean })\n\tpublic isVisibleToUserApp!: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isTagVisible?: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isListContainerVisible?: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isSearchAble?: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isFeaturedMarketingAllowed?: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isDiscountMarketingAllowed?: boolean;\n\n\t@prop({ type: ServiceControlProductConfig })\n\tpublic productConfig?: ServiceControlProductConfig;\n\n\t@prop({ type: String })\n\tpublic imageUrl?: string;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
package/dist/types/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lyxa.ai/types",
|
|
3
|
-
"version": "1.4.313-alpha-
|
|
3
|
+
"version": "1.4.313-alpha-5",
|
|
4
4
|
"description": "Lyxa type definitions and validation schemas for both frontend and backend",
|
|
5
5
|
"author": "elie <42282499+Internalizable@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MarketingType, ProductDietaryType } from '../enum';
|
|
2
2
|
export declare function getGroceryFamilyItemTypes(): Promise<string[]>;
|
|
3
3
|
export declare function getUserAppSearchAbleItemTypes(): Promise<string[]>;
|
|
4
|
-
export declare function isGroceryFamilyItemType(itemType: string): boolean
|
|
5
|
-
export declare function
|
|
4
|
+
export declare function isGroceryFamilyItemType(itemType: string): Promise<boolean>;
|
|
5
|
+
export declare function getMarketingAllowedServices(marketingType: MarketingType): Promise<string[]>;
|
|
6
|
+
export declare function getProductDietariesByItemType(itemType: string): Promise<{
|
|
6
7
|
icon: string;
|
|
7
8
|
label: string;
|
|
8
9
|
productDietaryType: ProductDietaryType;
|
|
9
|
-
}[]
|
|
10
|
+
}[]>;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getGroceryFamilyItemTypes = getGroceryFamilyItemTypes;
|
|
4
4
|
exports.getUserAppSearchAbleItemTypes = getUserAppSearchAbleItemTypes;
|
|
5
5
|
exports.isGroceryFamilyItemType = isGroceryFamilyItemType;
|
|
6
|
+
exports.getMarketingAllowedServices = getMarketingAllowedServices;
|
|
6
7
|
exports.getProductDietariesByItemType = getProductDietariesByItemType;
|
|
7
8
|
const models_1 = require("../../libraries/mongo/models");
|
|
8
9
|
const enum_1 = require("../enum");
|
|
@@ -33,11 +34,30 @@ async function getUserAppSearchAbleItemTypes() {
|
|
|
33
34
|
.lean();
|
|
34
35
|
return services.map(service => service.name);
|
|
35
36
|
}
|
|
36
|
-
function isGroceryFamilyItemType(itemType) {
|
|
37
|
-
|
|
37
|
+
async function isGroceryFamilyItemType(itemType) {
|
|
38
|
+
const groceryFamilyTypeItemTypes = await getGroceryFamilyItemTypes();
|
|
39
|
+
return groceryFamilyTypeItemTypes.includes(itemType);
|
|
38
40
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
+
async function getMarketingAllowedServices(marketingType) {
|
|
42
|
+
const fieldMap = {
|
|
43
|
+
[enum_1.MarketingType.FEATURED]: 'isFeaturedMarketingAllowed',
|
|
44
|
+
[enum_1.MarketingType.DISCOUNT]: 'isDiscountMarketingAllowed',
|
|
45
|
+
};
|
|
46
|
+
const allowedField = fieldMap[marketingType];
|
|
47
|
+
if (!allowedField) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const services = await models_1.ServiceControlModel.find({
|
|
51
|
+
deletedAt: null,
|
|
52
|
+
[allowedField]: true,
|
|
53
|
+
})
|
|
54
|
+
.select('name')
|
|
55
|
+
.lean();
|
|
56
|
+
return services.map(({ name }) => name);
|
|
57
|
+
}
|
|
58
|
+
async function getProductDietariesByItemType(itemType) {
|
|
59
|
+
const isItemTypeOfGroceryFamilyType = await isGroceryFamilyItemType(itemType);
|
|
60
|
+
if (isItemTypeOfGroceryFamilyType) {
|
|
41
61
|
return [
|
|
42
62
|
{ icon: '', label: 'Gluten Free', productDietaryType: enum_1.ProductDietaryType.GLUTEN_FREE },
|
|
43
63
|
{ icon: '', label: 'Lactose Free', productDietaryType: enum_1.ProductDietaryType.LACTOSE_FREE },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-methods.js","sourceRoot":"/","sources":["utilities/shared/common-methods.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"common-methods.js","sourceRoot":"/","sources":["utilities/shared/common-methods.ts"],"names":[],"mappings":";;AAiBA,8DAWC;AAED,sEAWC;AAED,0DAGC;AAED,kEAoBC;AAED,sEA8CC;AApHD,yDAAmF;AACnF,kCAMiB;AAEjB,MAAM,yBAAyB,GAAa;IAC3C,eAAQ,CAAC,OAAO;IAChB,eAAQ,CAAC,GAAG;IACZ,eAAQ,CAAC,QAAQ;IACjB,eAAQ,CAAC,WAAW;IACpB,eAAQ,CAAC,MAAM;CACN,CAAC;AAEJ,KAAK,UAAU,yBAAyB;IAC9C,MAAM,QAA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gBACC,IAAI,EAAE,iFAAiF;gBACvF,KAAK,EAAE,YAAY;gBACnB,kBAAkB,EAAE,yBAAkB,CAAC,UAAU;aACjD;YACD;gBACC,IAAI,EAAE,4EAA4E;gBAClF,KAAK,EAAE,OAAO;gBACd,kBAAkB,EAAE,yBAAkB,CAAC,KAAK;aAC5C;YACD;gBACC,IAAI,EAAE,iFAAiF;gBACvF,KAAK,EAAE,aAAa;gBACpB,kBAAkB,EAAE,yBAAkB,CAAC,WAAW;aAClD;YACD;gBACC,IAAI,EAAE,sFAAsF;gBAC5F,KAAK,EAAE,SAAS;gBAChB,kBAAkB,EAAE,yBAAkB,CAAC,OAAO;aAC9C;SACD,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["import { ServiceControl, ServiceControlModel } from '../../libraries/mongo/models';\nimport {\n\tItemType,\n\tMarketingType,\n\tProductDietaryType,\n\tServiceControlServiceType,\n\tServiceFamilyType,\n} from '../enum';\n\nconst GROCERY_FAMILY_ITEM_TYPES: string[] = [\n\tItemType.GROCERY,\n\tItemType.PET,\n\tItemType.WELLNESS,\n\tItemType.ELECTRONICS,\n\tItemType.BEAUTY,\n] as const;\n\nexport async function getGroceryFamilyItemTypes() {\n\tconst services = await ServiceControlModel.find({\n\t\tisVisibleToUserApp: true,\n\t\tdeletedAt: null,\n\t\t// $or: [{ serviceType: ServiceControlServiceType.REGULAR }, { isCoffee: true }],\n\t\t$or: [{ serviceType: ServiceControlServiceType.REGULAR, serviceFamilyType: ServiceFamilyType.GROCERY }],\n\t})\n\t\t.select('name')\n\t\t.lean();\n\n\treturn services.map(service => service.name);\n}\n\nexport async function getUserAppSearchAbleItemTypes() {\n\tconst services = await ServiceControlModel.find({\n\t\tisVisibleToUserApp: true,\n\t\tdeletedAt: null,\n\t\t// $or: [{ serviceType: ServiceControlServiceType.REGULAR }, { isCoffee: true }],\n\t\t$or: [{ serviceType: ServiceControlServiceType.REGULAR, isSearchAble: true }],\n\t})\n\t\t.select('name')\n\t\t.lean();\n\n\treturn services.map(service => service.name);\n}\n\nexport async function isGroceryFamilyItemType(itemType: string): Promise<boolean> {\n\tconst groceryFamilyTypeItemTypes = await getGroceryFamilyItemTypes();\n\treturn groceryFamilyTypeItemTypes.includes(itemType);\n}\n\nexport async function getMarketingAllowedServices(marketingType: MarketingType): Promise<string[]> {\n\tconst fieldMap: Partial<Record<MarketingType, keyof ServiceControl>> = {\n\t\t[MarketingType.FEATURED]: 'isFeaturedMarketingAllowed',\n\t\t[MarketingType.DISCOUNT]: 'isDiscountMarketingAllowed', // Add more if other marketings require it. make dynamic if possible\n\t};\n\n\tconst allowedField = fieldMap[marketingType];\n\n\tif (!allowedField) {\n\t\treturn [];\n\t}\n\n\tconst services = await ServiceControlModel.find({\n\t\tdeletedAt: null,\n\t\t[allowedField]: true,\n\t})\n\t\t.select('name')\n\t\t.lean();\n\n\treturn services.map(({ name }) => name);\n}\n\nexport async function getProductDietariesByItemType(\n\titemType: string\n): Promise<{ icon: string; label: string; productDietaryType: ProductDietaryType }[]> {\n\tconst isItemTypeOfGroceryFamilyType = await isGroceryFamilyItemType(itemType);\n\tif (isItemTypeOfGroceryFamilyType) {\n\t\treturn [\n\t\t\t{ icon: '', label: 'Gluten Free', productDietaryType: ProductDietaryType.GLUTEN_FREE },\n\t\t\t{ icon: '', label: 'Lactose Free', productDietaryType: ProductDietaryType.LACTOSE_FREE },\n\t\t\t{ icon: '', label: 'Low Cal', productDietaryType: ProductDietaryType.LOW_CAL },\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/vegetarian.png',\n\t\t\t\tlabel: 'Vegetarian',\n\t\t\t\tproductDietaryType: ProductDietaryType.VEGETARIAN,\n\t\t\t},\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/vegan.png',\n\t\t\t\tlabel: 'Vegan',\n\t\t\t\tproductDietaryType: ProductDietaryType.VEGAN,\n\t\t\t},\n\t\t\t{ icon: '', label: 'Keto', productDietaryType: ProductDietaryType.KETO },\n\t\t\t{ icon: '', label: 'High Protein', productDietaryType: ProductDietaryType.HIGH_PROTEIN },\n\t\t];\n\t} else {\n\t\treturn [\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/vegetarian.png',\n\t\t\t\tlabel: 'Vegeterian',\n\t\t\t\tproductDietaryType: ProductDietaryType.VEGETARIAN,\n\t\t\t},\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/vegan.png',\n\t\t\t\tlabel: 'Vegan',\n\t\t\t\tproductDietaryType: ProductDietaryType.VEGAN,\n\t\t\t},\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/glutenFree.png',\n\t\t\t\tlabel: 'Gluten Free',\n\t\t\t\tproductDietaryType: ProductDietaryType.GLUTEN_FREE,\n\t\t\t},\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/allergyFriendly.png',\n\t\t\t\tlabel: 'Low Cal',\n\t\t\t\tproductDietaryType: ProductDietaryType.LOW_CAL,\n\t\t\t},\n\t\t];\n\t}\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MarketingType, ProductDietaryType } from '../enum';
|
|
2
2
|
export declare function getGroceryFamilyItemTypes(): Promise<string[]>;
|
|
3
3
|
export declare function getUserAppSearchAbleItemTypes(): Promise<string[]>;
|
|
4
|
-
export declare function isGroceryFamilyItemType(itemType: string): boolean
|
|
5
|
-
export declare function
|
|
4
|
+
export declare function isGroceryFamilyItemType(itemType: string): Promise<boolean>;
|
|
5
|
+
export declare function getMarketingAllowedServices(marketingType: MarketingType): Promise<string[]>;
|
|
6
|
+
export declare function getProductDietariesByItemType(itemType: string): Promise<{
|
|
6
7
|
icon: string;
|
|
7
8
|
label: string;
|
|
8
9
|
productDietaryType: ProductDietaryType;
|
|
9
|
-
}[]
|
|
10
|
+
}[]>;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getGroceryFamilyItemTypes = getGroceryFamilyItemTypes;
|
|
4
4
|
exports.getUserAppSearchAbleItemTypes = getUserAppSearchAbleItemTypes;
|
|
5
5
|
exports.isGroceryFamilyItemType = isGroceryFamilyItemType;
|
|
6
|
+
exports.getMarketingAllowedServices = getMarketingAllowedServices;
|
|
6
7
|
exports.getProductDietariesByItemType = getProductDietariesByItemType;
|
|
7
8
|
const models_1 = require("../../libraries/mongo/models");
|
|
8
9
|
const enum_1 = require("../enum");
|
|
@@ -33,11 +34,30 @@ async function getUserAppSearchAbleItemTypes() {
|
|
|
33
34
|
.lean();
|
|
34
35
|
return services.map(service => service.name);
|
|
35
36
|
}
|
|
36
|
-
function isGroceryFamilyItemType(itemType) {
|
|
37
|
-
|
|
37
|
+
async function isGroceryFamilyItemType(itemType) {
|
|
38
|
+
const groceryFamilyTypeItemTypes = await getGroceryFamilyItemTypes();
|
|
39
|
+
return groceryFamilyTypeItemTypes.includes(itemType);
|
|
38
40
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
+
async function getMarketingAllowedServices(marketingType) {
|
|
42
|
+
const fieldMap = {
|
|
43
|
+
[enum_1.MarketingType.FEATURED]: 'isFeaturedMarketingAllowed',
|
|
44
|
+
[enum_1.MarketingType.DISCOUNT]: 'isDiscountMarketingAllowed',
|
|
45
|
+
};
|
|
46
|
+
const allowedField = fieldMap[marketingType];
|
|
47
|
+
if (!allowedField) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const services = await models_1.ServiceControlModel.find({
|
|
51
|
+
deletedAt: null,
|
|
52
|
+
[allowedField]: true,
|
|
53
|
+
})
|
|
54
|
+
.select('name')
|
|
55
|
+
.lean();
|
|
56
|
+
return services.map(({ name }) => name);
|
|
57
|
+
}
|
|
58
|
+
async function getProductDietariesByItemType(itemType) {
|
|
59
|
+
const isItemTypeOfGroceryFamilyType = await isGroceryFamilyItemType(itemType);
|
|
60
|
+
if (isItemTypeOfGroceryFamilyType) {
|
|
41
61
|
return [
|
|
42
62
|
{ icon: '', label: 'Gluten Free', productDietaryType: enum_1.ProductDietaryType.GLUTEN_FREE },
|
|
43
63
|
{ icon: '', label: 'Lactose Free', productDietaryType: enum_1.ProductDietaryType.LACTOSE_FREE },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-methods.js","sourceRoot":"/","sources":["utilities/shared/common-methods.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"common-methods.js","sourceRoot":"/","sources":["utilities/shared/common-methods.ts"],"names":[],"mappings":";;AAiBA,8DAWC;AAED,sEAWC;AAED,0DAGC;AAED,kEAoBC;AAED,sEA8CC;AApHD,yDAAmF;AACnF,kCAMiB;AAEjB,MAAM,yBAAyB,GAAa;IAC3C,eAAQ,CAAC,OAAO;IAChB,eAAQ,CAAC,GAAG;IACZ,eAAQ,CAAC,QAAQ;IACjB,eAAQ,CAAC,WAAW;IACpB,eAAQ,CAAC,MAAM;CACN,CAAC;AAEJ,KAAK,UAAU,yBAAyB;IAC9C,MAAM,QAAQ,GAAG,MAAM,4BAAmB,CAAC,IAAI,CAAC;QAC/C,kBAAkB,EAAE,IAAI;QACxB,SAAS,EAAE,IAAI;QAEf,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,gCAAyB,CAAC,OAAO,EAAE,iBAAiB,EAAE,wBAAiB,CAAC,OAAO,EAAE,CAAC;KACvG,CAAC;SACA,MAAM,CAAC,MAAM,CAAC;SACd,IAAI,EAAE,CAAC;IAET,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC;AAEM,KAAK,UAAU,6BAA6B;IAClD,MAAM,QAAQ,GAAG,MAAM,4BAAmB,CAAC,IAAI,CAAC;QAC/C,kBAAkB,EAAE,IAAI;Q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mongo/models';\nimport {\n\tItemType,\n\tMarketingType,\n\tProductDietaryType,\n\tServiceControlServiceType,\n\tServiceFamilyType,\n} from '../enum';\n\nconst GROCERY_FAMILY_ITEM_TYPES: string[] = [\n\tItemType.GROCERY,\n\tItemType.PET,\n\tItemType.WELLNESS,\n\tItemType.ELECTRONICS,\n\tItemType.BEAUTY,\n] as const;\n\nexport async function getGroceryFamilyItemTypes() {\n\tconst services = await ServiceControlModel.find({\n\t\tisVisibleToUserApp: true,\n\t\tdeletedAt: null,\n\t\t// $or: [{ serviceType: ServiceControlServiceType.REGULAR }, { isCoffee: true }],\n\t\t$or: [{ serviceType: ServiceControlServiceType.REGULAR, serviceFamilyType: ServiceFamilyType.GROCERY }],\n\t})\n\t\t.select('name')\n\t\t.lean();\n\n\treturn services.map(service => service.name);\n}\n\nexport async function getUserAppSearchAbleItemTypes() {\n\tconst services = await ServiceControlModel.find({\n\t\tisVisibleToUserApp: true,\n\t\tdeletedAt: null,\n\t\t// $or: [{ serviceType: ServiceControlServiceType.REGULAR }, { isCoffee: true }],\n\t\t$or: [{ serviceType: ServiceControlServiceType.REGULAR, isSearchAble: true }],\n\t})\n\t\t.select('name')\n\t\t.lean();\n\n\treturn services.map(service => service.name);\n}\n\nexport async function isGroceryFamilyItemType(itemType: string): Promise<boolean> {\n\tconst groceryFamilyTypeItemTypes = await getGroceryFamilyItemTypes();\n\treturn groceryFamilyTypeItemTypes.includes(itemType);\n}\n\nexport async function getMarketingAllowedServices(marketingType: MarketingType): Promise<string[]> {\n\tconst fieldMap: Partial<Record<MarketingType, keyof ServiceControl>> = {\n\t\t[MarketingType.FEATURED]: 'isFeaturedMarketingAllowed',\n\t\t[MarketingType.DISCOUNT]: 'isDiscountMarketingAllowed', // Add more if other marketings require it. make dynamic if possible\n\t};\n\n\tconst allowedField = fieldMap[marketingType];\n\n\tif (!allowedField) {\n\t\treturn [];\n\t}\n\n\tconst services = await ServiceControlModel.find({\n\t\tdeletedAt: null,\n\t\t[allowedField]: true,\n\t})\n\t\t.select('name')\n\t\t.lean();\n\n\treturn services.map(({ name }) => name);\n}\n\nexport async function getProductDietariesByItemType(\n\titemType: string\n): Promise<{ icon: string; label: string; productDietaryType: ProductDietaryType }[]> {\n\tconst isItemTypeOfGroceryFamilyType = await isGroceryFamilyItemType(itemType);\n\tif (isItemTypeOfGroceryFamilyType) {\n\t\treturn [\n\t\t\t{ icon: '', label: 'Gluten Free', productDietaryType: ProductDietaryType.GLUTEN_FREE },\n\t\t\t{ icon: '', label: 'Lactose Free', productDietaryType: ProductDietaryType.LACTOSE_FREE },\n\t\t\t{ icon: '', label: 'Low Cal', productDietaryType: ProductDietaryType.LOW_CAL },\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/vegetarian.png',\n\t\t\t\tlabel: 'Vegetarian',\n\t\t\t\tproductDietaryType: ProductDietaryType.VEGETARIAN,\n\t\t\t},\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/vegan.png',\n\t\t\t\tlabel: 'Vegan',\n\t\t\t\tproductDietaryType: ProductDietaryType.VEGAN,\n\t\t\t},\n\t\t\t{ icon: '', label: 'Keto', productDietaryType: ProductDietaryType.KETO },\n\t\t\t{ icon: '', label: 'High Protein', productDietaryType: ProductDietaryType.HIGH_PROTEIN },\n\t\t];\n\t} else {\n\t\treturn [\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/vegetarian.png',\n\t\t\t\tlabel: 'Vegeterian',\n\t\t\t\tproductDietaryType: ProductDietaryType.VEGETARIAN,\n\t\t\t},\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/vegan.png',\n\t\t\t\tlabel: 'Vegan',\n\t\t\t\tproductDietaryType: ProductDietaryType.VEGAN,\n\t\t\t},\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/glutenFree.png',\n\t\t\t\tlabel: 'Gluten Free',\n\t\t\t\tproductDietaryType: ProductDietaryType.GLUTEN_FREE,\n\t\t\t},\n\t\t\t{\n\t\t\t\ticon: 'https://storage.googleapis.com/lyxa-global/product-dietary-icons/allergyFriendly.png',\n\t\t\t\tlabel: 'Low Cal',\n\t\t\t\tproductDietaryType: ProductDietaryType.LOW_CAL,\n\t\t\t},\n\t\t];\n\t}\n}\n"]}
|
package/package.json
CHANGED