@infrab4a/connect-angular 6.0.0-alpha.0 → 6.0.0-beta.0
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/angular-connect.module.d.ts +36 -0
- package/angular-elastic-search.module.d.ts +9 -0
- package/angular-firebase-auth.module.d.ts +11 -0
- package/angular-firestore.module.d.ts +17 -0
- package/angular-hasura-graphql.module.d.ts +14 -0
- package/angular-vertex-search.module.d.ts +9 -0
- package/consts/backend-url.const.d.ts +1 -0
- package/consts/category-structure.d.ts +1 -0
- package/consts/default-shop.const.d.ts +1 -0
- package/consts/es-config.const.d.ts +1 -0
- package/consts/firebase-const.d.ts +4 -0
- package/consts/hasura-options.const.d.ts +1 -0
- package/consts/index.d.ts +8 -0
- package/consts/persistence.const.d.ts +1 -0
- package/consts/storage-base-url.const.d.ts +1 -0
- package/consts/vertex-config.const.d.ts +1 -0
- package/esm2022/angular-connect.module.mjs +291 -0
- package/esm2022/angular-elastic-search.module.mjs +34 -0
- package/esm2022/angular-firebase-auth.module.mjs +141 -0
- package/esm2022/angular-firestore.module.mjs +541 -0
- package/esm2022/angular-hasura-graphql.module.mjs +333 -0
- package/esm2022/angular-vertex-search.module.mjs +34 -0
- package/esm2022/consts/backend-url.const.mjs +2 -0
- package/esm2022/consts/category-structure.mjs +2 -0
- package/esm2022/consts/default-shop.const.mjs +2 -0
- package/esm2022/consts/es-config.const.mjs +2 -0
- package/esm2022/consts/firebase-const.mjs +5 -0
- package/esm2022/consts/hasura-options.const.mjs +2 -0
- package/esm2022/consts/index.mjs +9 -0
- package/esm2022/consts/persistence.const.mjs +2 -0
- package/esm2022/consts/storage-base-url.const.mjs +2 -0
- package/esm2022/consts/vertex-config.const.mjs +2 -0
- package/esm2022/helpers/index.mjs +2 -0
- package/esm2022/helpers/mobile-operation-system-checker.helper.mjs +7 -0
- package/esm2022/index.mjs +7 -0
- package/esm2022/infrab4a-connect-angular.mjs +5 -0
- package/esm2022/interfaces/catalog-strategies.interface.mjs +2 -0
- package/esm2022/interfaces/category-facades.interface.mjs +2 -0
- package/esm2022/interfaces/index.mjs +3 -0
- package/esm2022/persistence/cookie-data-persistence.mjs +22 -0
- package/esm2022/persistence/data-persistence.mjs +2 -0
- package/esm2022/persistence/index.mjs +3 -0
- package/esm2022/services/auth.service.mjs +37 -0
- package/esm2022/services/cart/cart-services.facade.mjs +21 -0
- package/esm2022/services/cart/index.mjs +2 -0
- package/esm2022/services/cart.service.mjs +73 -0
- package/esm2022/services/catalog/adapters/category-structure.adapter.mjs +2 -0
- package/esm2022/services/catalog/adapters/index.mjs +4 -0
- package/esm2022/services/catalog/adapters/new-category-structure.adapter.mjs +43 -0
- package/esm2022/services/catalog/adapters/old-category-structure.adapter.mjs +23 -0
- package/esm2022/services/catalog/catalog.service.mjs +111 -0
- package/esm2022/services/catalog/category.service.mjs +39 -0
- package/esm2022/services/catalog/context/catalog-search.context.mjs +40 -0
- package/esm2022/services/catalog/enums/index.mjs +2 -0
- package/esm2022/services/catalog/enums/product-sorts.enum.mjs +11 -0
- package/esm2022/services/catalog/facades/catalog-service.facade.mjs +32 -0
- package/esm2022/services/catalog/facades/catalog-strategies.facade.mjs +17 -0
- package/esm2022/services/catalog/facades/category-repository.facade.mjs +20 -0
- package/esm2022/services/catalog/facades/category-service.facade.mjs +30 -0
- package/esm2022/services/catalog/facades/index.mjs +6 -0
- package/esm2022/services/catalog/facades/product-catalog.facade.mjs +21 -0
- package/esm2022/services/catalog/helpers/brand-manager.helper.mjs +57 -0
- package/esm2022/services/catalog/helpers/catalog-filter.helper.mjs +44 -0
- package/esm2022/services/catalog/helpers/catalog-sort.helper.mjs +52 -0
- package/esm2022/services/catalog/helpers/index.mjs +5 -0
- package/esm2022/services/catalog/helpers/product-fields.helper.mjs +39 -0
- package/esm2022/services/catalog/index.mjs +8 -0
- package/esm2022/services/catalog/models/category-with-tree.model.mjs +10 -0
- package/esm2022/services/catalog/models/index.mjs +2 -0
- package/esm2022/services/catalog/services/catalog-helpers.service.mjs +33 -0
- package/esm2022/services/catalog/services/catalog-operations.facade.mjs +26 -0
- package/esm2022/services/catalog/services/catalog-repository.service.mjs +25 -0
- package/esm2022/services/catalog/services/index.mjs +5 -0
- package/esm2022/services/catalog/services/product-management.facade.mjs +25 -0
- package/esm2022/services/catalog/strategies/category-search.strategy.mjs +133 -0
- package/esm2022/services/catalog/strategies/index.mjs +4 -0
- package/esm2022/services/catalog/strategies/profile-search.strategy.mjs +42 -0
- package/esm2022/services/catalog/strategies/term-search.strategy.mjs +123 -0
- package/esm2022/services/catalog/strategies/types/strategy-params.type.mjs +2 -0
- package/esm2022/services/catalog/types/fetch-products-options.type.mjs +2 -0
- package/esm2022/services/catalog/types/fetch-products-params.type.mjs +2 -0
- package/esm2022/services/catalog/types/fetch-products-response.type.mjs +2 -0
- package/esm2022/services/catalog/types/index.mjs +6 -0
- package/esm2022/services/catalog/types/method-params.type.mjs +2 -0
- package/esm2022/services/catalog/types/product-sort.type.mjs +2 -0
- package/esm2022/services/catalog/wishlist.service.mjs +254 -0
- package/esm2022/services/checkout/checkout-dependencies.facade.mjs +20 -0
- package/esm2022/services/checkout/checkout-repositories.facade.mjs +20 -0
- package/esm2022/services/checkout/index.mjs +3 -0
- package/esm2022/services/checkout-subscription.service.mjs +55 -0
- package/esm2022/services/checkout.service.mjs +106 -0
- package/esm2022/services/coupon/coupon-repositories.facade.mjs +24 -0
- package/esm2022/services/coupon/index.mjs +2 -0
- package/esm2022/services/coupon/types/coupon-params.type.mjs +2 -0
- package/esm2022/services/coupon.service.mjs +248 -0
- package/esm2022/services/helpers/index.mjs +2 -0
- package/esm2022/services/helpers/util.helper.mjs +18 -0
- package/esm2022/services/home-shop/home-shop-repositories.facade.mjs +24 -0
- package/esm2022/services/home-shop/index.mjs +2 -0
- package/esm2022/services/home-shop.service.mjs +119 -0
- package/esm2022/services/index.mjs +11 -0
- package/esm2022/services/order-product-review.service.mjs +81 -0
- package/esm2022/services/order.service.mjs +30 -0
- package/esm2022/services/shared/configuration.facade.mjs +29 -0
- package/esm2022/services/shared/index.mjs +2 -0
- package/esm2022/services/types/index.mjs +5 -0
- package/esm2022/services/types/pending-product-review.type.mjs +2 -0
- package/esm2022/services/types/product-review-create.type.mjs +2 -0
- package/esm2022/services/types/required-checkout-data.type.mjs +2 -0
- package/esm2022/services/types/required-checkout-subscription-data.type.mjs +2 -0
- package/esm2022/types/firebase-app-config.type.mjs +2 -0
- package/esm2022/types/index.mjs +2 -0
- package/fesm2022/infrab4a-connect-angular.mjs +3352 -0
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/mobile-operation-system-checker.helper.d.ts +3 -0
- package/index.d.ts +6 -0
- package/interfaces/catalog-strategies.interface.d.ts +31 -0
- package/interfaces/category-facades.interface.d.ts +6 -0
- package/interfaces/index.d.ts +2 -0
- package/package.json +23 -9
- package/persistence/cookie-data-persistence.d.ts +10 -0
- package/persistence/data-persistence.d.ts +6 -0
- package/persistence/index.d.ts +2 -0
- package/services/auth.service.d.ts +18 -0
- package/services/cart/cart-services.facade.d.ts +12 -0
- package/services/cart/index.d.ts +1 -0
- package/services/cart.service.d.ts +26 -0
- package/services/catalog/adapters/category-structure.adapter.d.ts +4 -0
- package/services/catalog/adapters/index.d.ts +3 -0
- package/services/catalog/adapters/new-category-structure.adapter.d.ts +12 -0
- package/services/catalog/adapters/old-category-structure.adapter.d.ts +10 -0
- package/services/catalog/catalog.service.d.ts +24 -0
- package/services/catalog/category.service.d.ts +22 -0
- package/services/catalog/context/catalog-search.context.d.ts +14 -0
- package/services/catalog/enums/index.d.ts +1 -0
- package/services/catalog/enums/product-sorts.enum.d.ts +9 -0
- package/services/catalog/facades/catalog-service.facade.d.ts +15 -0
- package/services/catalog/facades/catalog-strategies.facade.d.ts +10 -0
- package/services/catalog/facades/category-repository.facade.d.ts +9 -0
- package/services/catalog/facades/category-service.facade.d.ts +15 -0
- package/{src/services/catalog/facades/index.ts → services/catalog/facades/index.d.ts} +5 -5
- package/services/catalog/facades/product-catalog.facade.d.ts +10 -0
- package/services/catalog/helpers/brand-manager.helper.d.ts +14 -0
- package/services/catalog/helpers/catalog-filter.helper.d.ts +8 -0
- package/services/catalog/helpers/catalog-sort.helper.d.ts +7 -0
- package/services/catalog/helpers/index.d.ts +4 -0
- package/services/catalog/helpers/product-fields.helper.d.ts +7 -0
- package/services/catalog/index.d.ts +7 -0
- package/services/catalog/models/category-with-tree.model.d.ts +4 -0
- package/services/catalog/models/index.d.ts +1 -0
- package/services/catalog/services/catalog-helpers.service.d.ts +17 -0
- package/services/catalog/services/catalog-operations.facade.d.ts +13 -0
- package/services/catalog/services/catalog-repository.service.d.ts +12 -0
- package/{src/services/catalog/services/index.ts → services/catalog/services/index.d.ts} +4 -4
- package/services/catalog/services/product-management.facade.d.ts +12 -0
- package/services/catalog/strategies/category-search.strategy.d.ts +19 -0
- package/services/catalog/strategies/index.d.ts +3 -0
- package/services/catalog/strategies/profile-search.strategy.d.ts +14 -0
- package/services/catalog/strategies/term-search.strategy.d.ts +20 -0
- package/services/catalog/strategies/types/strategy-params.type.d.ts +58 -0
- package/services/catalog/types/fetch-products-options.type.d.ts +8 -0
- package/services/catalog/types/fetch-products-params.type.d.ts +25 -0
- package/services/catalog/types/fetch-products-response.type.d.ts +19 -0
- package/services/catalog/types/index.d.ts +5 -0
- package/services/catalog/types/method-params.type.d.ts +17 -0
- package/services/catalog/types/product-sort.type.d.ts +2 -0
- package/services/catalog/wishlist.service.d.ts +59 -0
- package/services/checkout/checkout-dependencies.facade.d.ts +10 -0
- package/services/checkout/checkout-repositories.facade.d.ts +9 -0
- package/{src/services/checkout/index.ts → services/checkout/index.d.ts} +2 -2
- package/services/checkout-subscription.service.d.ts +19 -0
- package/services/checkout.service.d.ts +30 -0
- package/services/coupon/coupon-repositories.facade.d.ts +10 -0
- package/{src/services/coupon/index.ts → services/coupon/index.d.ts} +1 -1
- package/services/coupon/types/coupon-params.type.d.ts +13 -0
- package/services/coupon.service.d.ts +36 -0
- package/services/helpers/index.d.ts +1 -0
- package/services/helpers/util.helper.d.ts +3 -0
- package/services/home-shop/home-shop-repositories.facade.d.ts +10 -0
- package/{src/services/home-shop/index.ts → services/home-shop/index.d.ts} +1 -1
- package/services/home-shop.service.d.ts +26 -0
- package/services/index.d.ts +10 -0
- package/services/order-product-review.service.d.ts +13 -0
- package/services/order.service.d.ts +13 -0
- package/services/shared/configuration.facade.d.ts +12 -0
- package/services/shared/index.d.ts +1 -0
- package/services/types/index.d.ts +4 -0
- package/services/types/pending-product-review.type.d.ts +10 -0
- package/services/types/product-review-create.type.d.ts +14 -0
- package/services/types/required-checkout-data.type.d.ts +2 -0
- package/services/types/required-checkout-subscription-data.type.d.ts +2 -0
- package/types/firebase-app-config.type.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/eslint.config.js +0 -18
- package/index.ts +0 -1
- package/karma.conf.js +0 -32
- package/ng-package.json +0 -8
- package/project.json +0 -37
- package/src/angular-connect.module.ts +0 -256
- package/src/angular-elastic-search.module.ts +0 -23
- package/src/angular-firebase-auth.module.ts +0 -101
- package/src/angular-firestore.module.ts +0 -371
- package/src/angular-hasura-graphql.module.ts +0 -219
- package/src/angular-vertex-search.module.ts +0 -23
- package/src/consts/backend-url.const.ts +0 -1
- package/src/consts/category-structure.ts +0 -1
- package/src/consts/default-shop.const.ts +0 -1
- package/src/consts/es-config.const.ts +0 -1
- package/src/consts/firebase-const.ts +0 -5
- package/src/consts/hasura-options.const.ts +0 -1
- package/src/consts/index.ts +0 -8
- package/src/consts/persistence.const.ts +0 -1
- package/src/consts/storage-base-url.const.ts +0 -1
- package/src/consts/vertex-config.const.ts +0 -1
- package/src/helpers/index.ts +0 -1
- package/src/helpers/mobile-operation-system-checker.helper.ts +0 -10
- package/src/index.ts +0 -6
- package/src/interfaces/catalog-strategies.interface.ts +0 -36
- package/src/interfaces/category-facades.interface.ts +0 -7
- package/src/interfaces/index.ts +0 -2
- package/src/persistence/cookie-data-persistence.ts +0 -21
- package/src/persistence/data-persistence.ts +0 -7
- package/src/persistence/index.ts +0 -2
- package/src/services/auth.service.ts +0 -39
- package/src/services/cart/cart-services.facade.ts +0 -14
- package/src/services/cart/index.ts +0 -1
- package/src/services/cart.service.ts +0 -124
- package/src/services/catalog/adapters/category-structure.adapter.ts +0 -5
- package/src/services/catalog/adapters/index.ts +0 -3
- package/src/services/catalog/adapters/new-category-structure.adapter.ts +0 -42
- package/src/services/catalog/adapters/old-category-structure.adapter.ts +0 -17
- package/src/services/catalog/catalog.service.ts +0 -153
- package/src/services/catalog/category.service.ts +0 -52
- package/src/services/catalog/context/catalog-search.context.ts +0 -61
- package/src/services/catalog/enums/index.ts +0 -1
- package/src/services/catalog/enums/product-sorts.enum.ts +0 -9
- package/src/services/catalog/facades/catalog-service.facade.ts +0 -32
- package/src/services/catalog/facades/catalog-strategies.facade.ts +0 -12
- package/src/services/catalog/facades/category-repository.facade.ts +0 -10
- package/src/services/catalog/facades/category-service.facade.ts +0 -25
- package/src/services/catalog/facades/product-catalog.facade.ts +0 -13
- package/src/services/catalog/helpers/brand-manager.helper.ts +0 -63
- package/src/services/catalog/helpers/catalog-filter.helper.ts +0 -50
- package/src/services/catalog/helpers/catalog-sort.helper.ts +0 -54
- package/src/services/catalog/helpers/index.ts +0 -4
- package/src/services/catalog/helpers/product-fields.helper.ts +0 -35
- package/src/services/catalog/index.ts +0 -7
- package/src/services/catalog/models/category-with-tree.model.ts +0 -7
- package/src/services/catalog/models/index.ts +0 -1
- package/src/services/catalog/services/catalog-helpers.service.ts +0 -35
- package/src/services/catalog/services/catalog-operations.facade.ts +0 -24
- package/src/services/catalog/services/catalog-repository.service.ts +0 -20
- package/src/services/catalog/services/product-management.facade.ts +0 -20
- package/src/services/catalog/strategies/category-search.strategy.ts +0 -172
- package/src/services/catalog/strategies/index.ts +0 -3
- package/src/services/catalog/strategies/profile-search.strategy.ts +0 -51
- package/src/services/catalog/strategies/term-search.strategy.ts +0 -178
- package/src/services/catalog/strategies/types/strategy-params.type.ts +0 -58
- package/src/services/catalog/types/fetch-products-options.type.ts +0 -10
- package/src/services/catalog/types/fetch-products-params.type.ts +0 -27
- package/src/services/catalog/types/fetch-products-response.type.ts +0 -11
- package/src/services/catalog/types/index.ts +0 -5
- package/src/services/catalog/types/method-params.type.ts +0 -21
- package/src/services/catalog/types/product-sort.type.ts +0 -3
- package/src/services/catalog/wishlist.service.ts +0 -368
- package/src/services/checkout/checkout-dependencies.facade.ts +0 -13
- package/src/services/checkout/checkout-repositories.facade.ts +0 -10
- package/src/services/checkout-subscription.service.ts +0 -76
- package/src/services/checkout.service.ts +0 -196
- package/src/services/coupon/coupon-repositories.facade.ts +0 -11
- package/src/services/coupon/types/coupon-params.type.ts +0 -15
- package/src/services/coupon.service.ts +0 -347
- package/src/services/errors/group-invalid-coupon.error.ts +0 -9
- package/src/services/errors/index.ts +0 -2
- package/src/services/errors/invalid-coupon.error.ts +0 -7
- package/src/services/helpers/index.ts +0 -1
- package/src/services/helpers/util.helper.ts +0 -17
- package/src/services/home-shop/home-shop-repositories.facade.ts +0 -11
- package/src/services/home-shop.service.ts +0 -196
- package/src/services/index.ts +0 -9
- package/src/services/order.service.ts +0 -23
- package/src/services/shared/configuration.facade.ts +0 -21
- package/src/services/shared/index.ts +0 -1
- package/src/services/types/index.ts +0 -2
- package/src/services/types/required-checkout-data.type.ts +0 -3
- package/src/services/types/required-checkout-subscription-data.type.ts +0 -3
- package/src/types/firebase-app-config.type.ts +0 -1
- package/src/types/index.ts +0 -1
- package/tsconfig.json +0 -17
- package/tsconfig.lib.json +0 -13
- package/tsconfig.lib.prod.json +0 -13
- package/tsconfig.spec.json +0 -17
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core'
|
|
2
|
-
import {
|
|
3
|
-
Product,
|
|
4
|
-
ProductSearch,
|
|
5
|
-
RepositoryCacheOptions,
|
|
6
|
-
RepositoryFindResult,
|
|
7
|
-
Shops,
|
|
8
|
-
Where,
|
|
9
|
-
isEmpty,
|
|
10
|
-
} from '@infrab4a/connect'
|
|
11
|
-
|
|
12
|
-
import { CatalogSearchParams, CatalogSearchStrategy } from '../../../interfaces'
|
|
13
|
-
import { CatalogHelpersService, CatalogRepositoryService } from '../services'
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
SortByTermRelevanceParams,
|
|
17
|
-
TermSearchDefaultParams,
|
|
18
|
-
TermSearchMostRelevantParams,
|
|
19
|
-
} from './types/strategy-params.type'
|
|
20
|
-
|
|
21
|
-
@Injectable()
|
|
22
|
-
export class TermSearchStrategy implements CatalogSearchStrategy {
|
|
23
|
-
private productsByTerm: Record<string, string[]> = {}
|
|
24
|
-
|
|
25
|
-
constructor(
|
|
26
|
-
private readonly repositoryService: CatalogRepositoryService,
|
|
27
|
-
private readonly helpersService: CatalogHelpersService,
|
|
28
|
-
) {}
|
|
29
|
-
|
|
30
|
-
async search(
|
|
31
|
-
params: CatalogSearchParams,
|
|
32
|
-
shop: Shops,
|
|
33
|
-
_optionsCache?: { cache?: RepositoryCacheOptions },
|
|
34
|
-
): Promise<RepositoryFindResult<Product>> {
|
|
35
|
-
const { term, filters, limits, sort, mainGender } = params
|
|
36
|
-
|
|
37
|
-
if (!term) {
|
|
38
|
-
throw new Error('Term is required for TermSearchStrategy')
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const productIds = await this.findCatalogIdsBySearch(term, shop)
|
|
42
|
-
|
|
43
|
-
if (sort === 'most-relevant') {
|
|
44
|
-
return this.searchWithMostRelevant({
|
|
45
|
-
productIds,
|
|
46
|
-
filters,
|
|
47
|
-
limits,
|
|
48
|
-
shop,
|
|
49
|
-
mainGender,
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return this.searchDefault({
|
|
54
|
-
productIds,
|
|
55
|
-
filters,
|
|
56
|
-
limits,
|
|
57
|
-
shop,
|
|
58
|
-
mainGender,
|
|
59
|
-
fields: this.helpersService.getFieldsHelper().getStandardFields(),
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private async searchWithMostRelevant(params: TermSearchMostRelevantParams): Promise<RepositoryFindResult<Product>> {
|
|
64
|
-
const { productIds, filters, shop, mainGender } = params
|
|
65
|
-
const productCatalog = this.repositoryService.getProductCatalog()
|
|
66
|
-
const filterHelper = this.helpersService.getFilterHelper()
|
|
67
|
-
|
|
68
|
-
const totalResult = await productCatalog.productRepository.findCatalog(
|
|
69
|
-
{
|
|
70
|
-
fields: ['id', 'stock', 'gender'],
|
|
71
|
-
filters: {
|
|
72
|
-
id: { operator: Where.IN, value: productIds },
|
|
73
|
-
published: { operator: Where.EQUALS, value: true },
|
|
74
|
-
...filterHelper.buildFilterQuery(filters || {}),
|
|
75
|
-
},
|
|
76
|
-
options: {
|
|
77
|
-
minimal: ['price'],
|
|
78
|
-
maximum: ['price'],
|
|
79
|
-
...(isEmpty(filters?.brands) ? { distinct: ['brand'] } : {}),
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
mainGender || (shop === Shops.MENSMARKET ? 'male' : 'female'),
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
return this.sortByTermRelevance({
|
|
86
|
-
productIds,
|
|
87
|
-
totalResult,
|
|
88
|
-
limits: params.limits,
|
|
89
|
-
filters,
|
|
90
|
-
fieldsHelper: this.helpersService.getFieldsHelper(),
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private async searchDefault(params: TermSearchDefaultParams): Promise<RepositoryFindResult<Product>> {
|
|
95
|
-
const { productIds, filters, limits, shop, mainGender, fields } = params
|
|
96
|
-
const productCatalog = this.repositoryService.getProductCatalog()
|
|
97
|
-
const filterHelper = this.helpersService.getFilterHelper()
|
|
98
|
-
|
|
99
|
-
return productCatalog.productRepository.findCatalog(
|
|
100
|
-
{
|
|
101
|
-
fields,
|
|
102
|
-
filters: {
|
|
103
|
-
id: { operator: Where.IN, value: productIds },
|
|
104
|
-
published: { operator: Where.EQUALS, value: true },
|
|
105
|
-
...filterHelper.buildFilterQuery(filters || {}),
|
|
106
|
-
},
|
|
107
|
-
limits,
|
|
108
|
-
options: {
|
|
109
|
-
minimal: ['price'],
|
|
110
|
-
maximum: ['price'],
|
|
111
|
-
distinct: ['brand'],
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
mainGender || (shop === Shops.MENSMARKET ? 'male' : 'female'),
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private sortByTermRelevance(params: SortByTermRelevanceParams) {
|
|
119
|
-
const { productIds, totalResult, limits, filters, fieldsHelper } = params
|
|
120
|
-
const defaultGender = filters?.gender?.at(0) || 'male'
|
|
121
|
-
const stockData = totalResult.data.filter((product: any) => product.stock.quantity > 0)
|
|
122
|
-
const stockOut = totalResult.data.filter((product: any) => product.stock.quantity <= 0)
|
|
123
|
-
|
|
124
|
-
const productIdsStockGender = productIds.filter((product) =>
|
|
125
|
-
stockData.some(
|
|
126
|
-
(result: any) =>
|
|
127
|
-
result.id === product && (result.gender?.includes(defaultGender) || result.gender?.includes('unisex')),
|
|
128
|
-
),
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
const productIdsStockNotGender = productIds.filter((product) =>
|
|
132
|
-
stockData.some(
|
|
133
|
-
(result: any) =>
|
|
134
|
-
result.id === product && !result.gender?.includes(defaultGender) && !result.gender?.includes('unisex'),
|
|
135
|
-
),
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
const productIdsStock = productIdsStockGender.concat(productIdsStockNotGender)
|
|
139
|
-
const productIdsStockOut = productIds.filter((product) => stockOut.some((result: any) => result.id === product))
|
|
140
|
-
|
|
141
|
-
const limitedProductId = productIdsStock
|
|
142
|
-
.concat(productIdsStockOut)
|
|
143
|
-
.slice(limits.offset, limits.offset + limits.limit)
|
|
144
|
-
|
|
145
|
-
const orderedId = productIds.filter((product) => limitedProductId.includes(product))
|
|
146
|
-
|
|
147
|
-
return this.getDetailedProducts(orderedId, totalResult, fieldsHelper)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private async getDetailedProducts(orderedId: string[], totalResult: any, fieldsHelper: any) {
|
|
151
|
-
const productCatalog = this.repositoryService.getProductCatalog()
|
|
152
|
-
const fields = fieldsHelper.getStandardFields()
|
|
153
|
-
const productResult = await productCatalog.productRepository.findCatalog({
|
|
154
|
-
filters: {
|
|
155
|
-
id: { operator: Where.IN, value: orderedId },
|
|
156
|
-
},
|
|
157
|
-
fields,
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
data: orderedId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
|
|
162
|
-
count: totalResult.count,
|
|
163
|
-
maximum: totalResult.maximum,
|
|
164
|
-
minimal: totalResult.minimal,
|
|
165
|
-
distinct: totalResult.distinct,
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
private async findCatalogIdsBySearch(term: string, shop: Shops): Promise<string[]> {
|
|
170
|
-
if (this.productsByTerm[term]) return this.productsByTerm[term]
|
|
171
|
-
|
|
172
|
-
const productServices = this.repositoryService.getProductServices()
|
|
173
|
-
|
|
174
|
-
return (this.productsByTerm[term] = await productServices.productSearch
|
|
175
|
-
.search<ProductSearch>(term, 999, shop === Shops.GLAMSHOP ? 'female' : 'male')
|
|
176
|
-
.then((products) => [...new Set(products.map((product) => product.id))]))
|
|
177
|
-
}
|
|
178
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { RepositoryCacheOptions, Shops } from '@infrab4a/connect'
|
|
2
|
-
|
|
3
|
-
export type SearchWithMostRelevantParams = {
|
|
4
|
-
category: any
|
|
5
|
-
filters: any
|
|
6
|
-
limits: any
|
|
7
|
-
shop: Shops
|
|
8
|
-
mainGender: any
|
|
9
|
-
optionsCache: { cache?: RepositoryCacheOptions } | undefined
|
|
10
|
-
fields: any
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type SearchDefaultParams = {
|
|
14
|
-
category: any
|
|
15
|
-
filters: any
|
|
16
|
-
limits: any
|
|
17
|
-
shop: Shops
|
|
18
|
-
mainGender: any
|
|
19
|
-
sort: any
|
|
20
|
-
optionsCache: { cache?: RepositoryCacheOptions } | undefined
|
|
21
|
-
fields: any
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type FindAndSortByMostRelevantParams = {
|
|
25
|
-
mostRelevants: string[]
|
|
26
|
-
productIds: string[]
|
|
27
|
-
filters: any
|
|
28
|
-
limits: any
|
|
29
|
-
shop: Shops
|
|
30
|
-
mainGender: any
|
|
31
|
-
optionsCache: { cache?: RepositoryCacheOptions } | undefined
|
|
32
|
-
fields: any
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type TermSearchMostRelevantParams = {
|
|
36
|
-
productIds: string[]
|
|
37
|
-
filters: any
|
|
38
|
-
limits: any
|
|
39
|
-
mainGender: any
|
|
40
|
-
shop: Shops
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export type TermSearchDefaultParams = {
|
|
44
|
-
productIds: string[]
|
|
45
|
-
filters: any
|
|
46
|
-
limits: any
|
|
47
|
-
mainGender: any
|
|
48
|
-
shop: Shops
|
|
49
|
-
fields: any
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export type SortByTermRelevanceParams = {
|
|
53
|
-
productIds: string[]
|
|
54
|
-
totalResult: any
|
|
55
|
-
limits: any
|
|
56
|
-
filters: any
|
|
57
|
-
fieldsHelper: any
|
|
58
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Category } from '@infrab4a/connect'
|
|
2
|
-
|
|
3
|
-
import { CatalogFilters } from '../../../interfaces'
|
|
4
|
-
|
|
5
|
-
import { FetchProductsOptions } from './fetch-products-options.type'
|
|
6
|
-
|
|
7
|
-
export type FetchProductsMainParams<T extends Category> = {
|
|
8
|
-
category?: T
|
|
9
|
-
profile?: string[]
|
|
10
|
-
term?: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type FetchProductsParams<T extends Category> = FetchProductsOptions &
|
|
14
|
-
(
|
|
15
|
-
| {
|
|
16
|
-
category: FetchProductsMainParams<T>['category']
|
|
17
|
-
filters?: CatalogFilters & { customOptions?: never }
|
|
18
|
-
}
|
|
19
|
-
| {
|
|
20
|
-
profile: FetchProductsMainParams<T>['profile']
|
|
21
|
-
filters?: CatalogFilters & { customOptions?: never; tags?: never }
|
|
22
|
-
}
|
|
23
|
-
| {
|
|
24
|
-
term: FetchProductsMainParams<T>['term']
|
|
25
|
-
filters?: CatalogFilters & { customOptions?: never }
|
|
26
|
-
}
|
|
27
|
-
)
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Product } from '@infrab4a/connect'
|
|
2
|
-
|
|
3
|
-
export type FetchProductsResponse = {
|
|
4
|
-
products: { data: Product[]; total: number }
|
|
5
|
-
pages: number
|
|
6
|
-
prices: {
|
|
7
|
-
price: { min: number; max: number }
|
|
8
|
-
subscriberPrice: { min: number; max: number }
|
|
9
|
-
}
|
|
10
|
-
brands?: string[]
|
|
11
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Category, Product, Shops } from '@infrab4a/connect'
|
|
2
|
-
|
|
3
|
-
import { CatalogSearchParams } from '../../../interfaces'
|
|
4
|
-
|
|
5
|
-
import { FetchProductsParams } from './fetch-products-params.type'
|
|
6
|
-
|
|
7
|
-
export type StockNotificationParams = {
|
|
8
|
-
shop: Shops
|
|
9
|
-
productId: string
|
|
10
|
-
name: string
|
|
11
|
-
email: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type BuildResponseParams<T extends Category = Category> = {
|
|
15
|
-
data: Product[]
|
|
16
|
-
total: number
|
|
17
|
-
maximum: any
|
|
18
|
-
minimal: any
|
|
19
|
-
searchParams: CatalogSearchParams
|
|
20
|
-
options: FetchProductsParams<T>
|
|
21
|
-
}
|
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
import { Inject, Injectable } from '@angular/core'
|
|
2
|
-
import {
|
|
3
|
-
LogRepository,
|
|
4
|
-
PersonType,
|
|
5
|
-
PersonTypes,
|
|
6
|
-
Product,
|
|
7
|
-
Shops,
|
|
8
|
-
Wishlist,
|
|
9
|
-
WishlistLogType,
|
|
10
|
-
WishlistRepository,
|
|
11
|
-
} from '@infrab4a/connect'
|
|
12
|
-
|
|
13
|
-
import { DEFAULT_SHOP } from '../../consts'
|
|
14
|
-
|
|
15
|
-
import { CatalogService } from './catalog.service'
|
|
16
|
-
import { CategoryService } from './category.service'
|
|
17
|
-
import { CatalogServiceFacade, CategoryServiceFacade } from './facades'
|
|
18
|
-
|
|
19
|
-
@Injectable()
|
|
20
|
-
export class WishlistService {
|
|
21
|
-
private catalogService: CatalogService
|
|
22
|
-
private categoryService: CategoryService
|
|
23
|
-
|
|
24
|
-
constructor(
|
|
25
|
-
@Inject('WishlistRepository') private readonly wishlistRepository: WishlistRepository,
|
|
26
|
-
@Inject(DEFAULT_SHOP) private readonly shop: Shops,
|
|
27
|
-
@Inject('LogRepository') private readonly logRepository: LogRepository,
|
|
28
|
-
) {}
|
|
29
|
-
|
|
30
|
-
initializeServices(catalogServiceFacade: CatalogServiceFacade, categoryServiceFacade: CategoryServiceFacade): void {
|
|
31
|
-
this.catalogService = catalogServiceFacade.getCatalogService()
|
|
32
|
-
this.categoryService = categoryServiceFacade.getCategoryService()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
getCatalogService() {
|
|
36
|
-
return this.catalogService
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
getCategoryService() {
|
|
40
|
-
return this.categoryService
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async create({
|
|
44
|
-
personId,
|
|
45
|
-
title,
|
|
46
|
-
description,
|
|
47
|
-
published,
|
|
48
|
-
userFullName,
|
|
49
|
-
userPhoto,
|
|
50
|
-
theme,
|
|
51
|
-
bannerUrl,
|
|
52
|
-
personType,
|
|
53
|
-
personIsSubscriber,
|
|
54
|
-
}: {
|
|
55
|
-
personId: string
|
|
56
|
-
title: string
|
|
57
|
-
description: string
|
|
58
|
-
published: boolean
|
|
59
|
-
userFullName: string
|
|
60
|
-
userPhoto?: string
|
|
61
|
-
theme?: string
|
|
62
|
-
bannerUrl?: string
|
|
63
|
-
personType?: PersonType
|
|
64
|
-
personIsSubscriber?: boolean
|
|
65
|
-
}): Promise<Wishlist> {
|
|
66
|
-
const wishlistData = this.buildWishlistData({
|
|
67
|
-
title,
|
|
68
|
-
description,
|
|
69
|
-
published,
|
|
70
|
-
userFullName,
|
|
71
|
-
userPhoto,
|
|
72
|
-
theme,
|
|
73
|
-
bannerUrl,
|
|
74
|
-
personType,
|
|
75
|
-
personIsSubscriber,
|
|
76
|
-
personId,
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
const existingWishlist = await this.findExistingWishlistByPersonId(personId)
|
|
80
|
-
|
|
81
|
-
await this.createWishlistLog(WishlistLogType.CREATE, wishlistData as Wishlist)
|
|
82
|
-
|
|
83
|
-
if (existingWishlist) return existingWishlist
|
|
84
|
-
|
|
85
|
-
return this.createNewWishlist(wishlistData)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private buildWishlistData({
|
|
89
|
-
title,
|
|
90
|
-
description,
|
|
91
|
-
published,
|
|
92
|
-
userFullName,
|
|
93
|
-
userPhoto,
|
|
94
|
-
theme,
|
|
95
|
-
bannerUrl,
|
|
96
|
-
personType,
|
|
97
|
-
personIsSubscriber,
|
|
98
|
-
personId,
|
|
99
|
-
}: {
|
|
100
|
-
title: string
|
|
101
|
-
description: string
|
|
102
|
-
published: boolean
|
|
103
|
-
userFullName: string
|
|
104
|
-
userPhoto?: string
|
|
105
|
-
theme?: string
|
|
106
|
-
bannerUrl?: string
|
|
107
|
-
personType?: PersonType
|
|
108
|
-
personIsSubscriber?: boolean
|
|
109
|
-
personId: string
|
|
110
|
-
}) {
|
|
111
|
-
return {
|
|
112
|
-
slug: '',
|
|
113
|
-
name: title,
|
|
114
|
-
description,
|
|
115
|
-
metadatas: [
|
|
116
|
-
{
|
|
117
|
-
shop: this.shop,
|
|
118
|
-
title: `${userFullName} - ${title}`,
|
|
119
|
-
description: `${userFullName} - ${description}`,
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
shop: this.shop,
|
|
123
|
-
shops: [this.shop],
|
|
124
|
-
personId,
|
|
125
|
-
personName: userFullName,
|
|
126
|
-
personPhoto: userPhoto,
|
|
127
|
-
brandCategory: false,
|
|
128
|
-
published,
|
|
129
|
-
theme,
|
|
130
|
-
bannerUrl,
|
|
131
|
-
personType: personType ?? PersonTypes.NONE,
|
|
132
|
-
personIsSubscriber: personIsSubscriber ?? false,
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
private async findExistingWishlistByPersonId(personId: string): Promise<Wishlist | null> {
|
|
137
|
-
const hasWishlist = await this.wishlistRepository
|
|
138
|
-
.find({
|
|
139
|
-
filters: {
|
|
140
|
-
personId,
|
|
141
|
-
},
|
|
142
|
-
options: {
|
|
143
|
-
enableCount: false,
|
|
144
|
-
},
|
|
145
|
-
orderBy: {
|
|
146
|
-
id: 'asc',
|
|
147
|
-
},
|
|
148
|
-
})
|
|
149
|
-
.then((res) => res.data)
|
|
150
|
-
|
|
151
|
-
return hasWishlist.length ? hasWishlist.at(0) : null
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
private async createNewWishlist(data: any): Promise<Wishlist> {
|
|
155
|
-
const newWishlist = await this.wishlistRepository.create(data)
|
|
156
|
-
|
|
157
|
-
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id })
|
|
158
|
-
|
|
159
|
-
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id })
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async update({
|
|
163
|
-
id,
|
|
164
|
-
title,
|
|
165
|
-
description,
|
|
166
|
-
published,
|
|
167
|
-
userFullName,
|
|
168
|
-
userPhoto,
|
|
169
|
-
theme,
|
|
170
|
-
bannerUrl,
|
|
171
|
-
personType,
|
|
172
|
-
personIsSubscriber,
|
|
173
|
-
}: {
|
|
174
|
-
id: string
|
|
175
|
-
title: string
|
|
176
|
-
description: string
|
|
177
|
-
published: boolean
|
|
178
|
-
userFullName: string
|
|
179
|
-
userPhoto?: string
|
|
180
|
-
theme?: string
|
|
181
|
-
bannerUrl?: string
|
|
182
|
-
personType?: PersonType
|
|
183
|
-
personIsSubscriber?: boolean
|
|
184
|
-
}): Promise<Wishlist> {
|
|
185
|
-
const data = {
|
|
186
|
-
id,
|
|
187
|
-
name: title,
|
|
188
|
-
description,
|
|
189
|
-
published,
|
|
190
|
-
metadatas: [
|
|
191
|
-
{
|
|
192
|
-
shop: this.shop,
|
|
193
|
-
title: `${userFullName} - ${title}`,
|
|
194
|
-
description: `${userFullName} - ${description}`,
|
|
195
|
-
},
|
|
196
|
-
],
|
|
197
|
-
personName: userFullName,
|
|
198
|
-
personPhoto: userPhoto,
|
|
199
|
-
theme,
|
|
200
|
-
bannerUrl,
|
|
201
|
-
personType: personType ?? PersonTypes.NONE,
|
|
202
|
-
personIsSubscriber: personIsSubscriber ?? false,
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
await this.createWishlistLog(WishlistLogType.UPDATE, data as Wishlist)
|
|
206
|
-
|
|
207
|
-
return this.wishlistRepository.update(data)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
async delete(wishlistId: string): Promise<void> {
|
|
211
|
-
const wishlist = await this.findById(wishlistId)
|
|
212
|
-
|
|
213
|
-
await this.createWishlistLog(WishlistLogType.DELETE, wishlist)
|
|
214
|
-
|
|
215
|
-
return this.wishlistRepository.delete({ id: wishlistId })
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
getWishlistBySlug(slug: string): Promise<Wishlist> {
|
|
219
|
-
const [id] = slug.split('-')
|
|
220
|
-
|
|
221
|
-
if (+id) return this.wishlistRepository.get({ id })
|
|
222
|
-
|
|
223
|
-
return this.wishlistRepository.getWishlistBySlug(slug)
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
getWishlistsByPerson(personId: string): Promise<Wishlist[]> {
|
|
227
|
-
return this.wishlistRepository.getWishlistByPerson(personId)
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
async addProduct(wishlistId: string, productId: string): Promise<Wishlist> {
|
|
231
|
-
const wishlist = await this.wishlistRepository.get({ id: wishlistId })
|
|
232
|
-
const hasProduct = wishlist.products.some((p) => p == productId)
|
|
233
|
-
|
|
234
|
-
const wishlistData = await this.findById(wishlistId)
|
|
235
|
-
const productData = await this.findProductById(productId)
|
|
236
|
-
|
|
237
|
-
await this.createWishlistLog(WishlistLogType.ADD_PRODUCT, wishlistData, productData)
|
|
238
|
-
|
|
239
|
-
if (!hasProduct) {
|
|
240
|
-
wishlist.products = [...wishlist.products, productId]
|
|
241
|
-
await this.wishlistRepository.addProduct(wishlistId, productId)
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return wishlist
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
async removeProduct(wishlistId: string, productId: string): Promise<Wishlist> {
|
|
248
|
-
const wishlist = await this.wishlistRepository.get({ id: wishlistId })
|
|
249
|
-
const productIndex = wishlist.products.findIndex((p) => p == productId)
|
|
250
|
-
|
|
251
|
-
if (productIndex != -1) {
|
|
252
|
-
wishlist.products.splice(productIndex, 1)
|
|
253
|
-
const wishlistData = await this.findById(wishlistId)
|
|
254
|
-
const productData = await this.findProductById(productId)
|
|
255
|
-
|
|
256
|
-
await this.createWishlistLog(WishlistLogType.REMOVE_PRODUCT, wishlistData, productData)
|
|
257
|
-
await this.wishlistRepository.removeProduct(wishlistId, productId)
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
return wishlist
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
private async findById(id: string): Promise<Wishlist> {
|
|
264
|
-
return this.wishlistRepository
|
|
265
|
-
.find({
|
|
266
|
-
fields: ['id', 'name', 'description', 'personId', 'personIsSubscriber', 'personType', 'personName'],
|
|
267
|
-
filters: {
|
|
268
|
-
id,
|
|
269
|
-
},
|
|
270
|
-
})
|
|
271
|
-
.then((res) => res.data.at(0))
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
private async findProductById(id: string): Promise<Product> {
|
|
275
|
-
if (!this.catalogService) {
|
|
276
|
-
throw new Error('CatalogService not initialized. Call initializeServices first.')
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Acessar o ProductRepository através do CatalogHelpersService
|
|
280
|
-
const helpersService = this.catalogService['helpersService'] as any
|
|
281
|
-
const productServices = helpersService.getProductServices()
|
|
282
|
-
|
|
283
|
-
return productServices.productRepository
|
|
284
|
-
.find({
|
|
285
|
-
fields: ['id', 'sku', 'EAN', 'name', 'brand'],
|
|
286
|
-
filters: {
|
|
287
|
-
id,
|
|
288
|
-
},
|
|
289
|
-
})
|
|
290
|
-
.then((res) => res.data.at(0))
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
private async createWishlistLog(type: WishlistLogType, wishlist: Wishlist, product?: Product) {
|
|
294
|
-
switch (type) {
|
|
295
|
-
case WishlistLogType.CREATE:
|
|
296
|
-
case WishlistLogType.UPDATE:
|
|
297
|
-
case WishlistLogType.DELETE:
|
|
298
|
-
await this.createWishlistOperationLog(type, wishlist)
|
|
299
|
-
break
|
|
300
|
-
|
|
301
|
-
case WishlistLogType.ADD_PRODUCT:
|
|
302
|
-
case WishlistLogType.REMOVE_PRODUCT:
|
|
303
|
-
await this.createWishlistProductLog(type, wishlist, product)
|
|
304
|
-
break
|
|
305
|
-
|
|
306
|
-
default:
|
|
307
|
-
break
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
private async createWishlistOperationLog(type: WishlistLogType, wishlist: Wishlist): Promise<void> {
|
|
312
|
-
const operation = this.getOperationTypeFromWishlistLogType(type)
|
|
313
|
-
|
|
314
|
-
await this.logRepository.create({
|
|
315
|
-
collection: 'wishlist',
|
|
316
|
-
date: new Date(),
|
|
317
|
-
operation,
|
|
318
|
-
documentId: wishlist.id,
|
|
319
|
-
document: this.buildWishlistLogDocument(wishlist, type),
|
|
320
|
-
})
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
private async createWishlistProductLog(type: WishlistLogType, wishlist: Wishlist, product: Product): Promise<void> {
|
|
324
|
-
await this.logRepository.create({
|
|
325
|
-
collection: 'wishlist',
|
|
326
|
-
date: new Date(),
|
|
327
|
-
operation: 'UPDATE',
|
|
328
|
-
documentId: wishlist.id,
|
|
329
|
-
document: {
|
|
330
|
-
...this.buildWishlistLogDocument(wishlist, type),
|
|
331
|
-
...this.buildProductLogData(product),
|
|
332
|
-
},
|
|
333
|
-
})
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
private getOperationTypeFromWishlistLogType(type: WishlistLogType): 'CREATE' | 'UPDATE' | 'DELETE' {
|
|
337
|
-
if (type === WishlistLogType.CREATE) return 'CREATE'
|
|
338
|
-
|
|
339
|
-
if (type === WishlistLogType.UPDATE) return 'UPDATE'
|
|
340
|
-
|
|
341
|
-
return 'DELETE'
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
private buildWishlistLogDocument(wishlist: Wishlist, type: WishlistLogType) {
|
|
345
|
-
return {
|
|
346
|
-
id: wishlist.id,
|
|
347
|
-
shop: this.shop,
|
|
348
|
-
name: wishlist.name,
|
|
349
|
-
description: wishlist.description,
|
|
350
|
-
published: wishlist.published,
|
|
351
|
-
type: type,
|
|
352
|
-
personType: wishlist.personType,
|
|
353
|
-
personId: wishlist.personId,
|
|
354
|
-
personName: wishlist.personName,
|
|
355
|
-
personIsSubscriber: wishlist.personIsSubscriber,
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
private buildProductLogData(product: Product) {
|
|
360
|
-
return {
|
|
361
|
-
productId: product.id,
|
|
362
|
-
productEAN: product.EAN,
|
|
363
|
-
productSKU: product.sku,
|
|
364
|
-
productName: product.name,
|
|
365
|
-
productBrand: product.brand,
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from '@angular/common/http'
|
|
2
|
-
import { Inject, Injectable } from '@angular/core'
|
|
3
|
-
|
|
4
|
-
import { PERSISTENCE_PROVIDER } from '../../consts'
|
|
5
|
-
import { DataPersistence } from '../../persistence'
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class CheckoutDependenciesFacade {
|
|
9
|
-
constructor(
|
|
10
|
-
@Inject(PERSISTENCE_PROVIDER) public readonly dataPersistence: DataPersistence,
|
|
11
|
-
public readonly httpClient: HttpClient,
|
|
12
|
-
) {}
|
|
13
|
-
}
|