Преглед изворни кода

refactor(server): Start code reorganizing in service layer

The goal is to isolate all service which access the DB into the "service" dir, then have helpers in the "helpers" dir. This commit sets the initial naming & structure. To follow will be some more complex refactorings of existing helper code into more coherent units.
Michael Bromley пре 7 година
родитељ
комит
00cb2bded5
42 измењених фајлова са 115 додато и 118 уклоњено
  1. 1 1
      server/src/api/common/auth-guard.ts
  2. 1 1
      server/src/api/common/request-context.service.ts
  3. 1 1
      server/src/api/resolvers/administrator.resolver.ts
  4. 1 1
      server/src/api/resolvers/asset.resolver.ts
  5. 2 2
      server/src/api/resolvers/auth.resolver.ts
  6. 1 1
      server/src/api/resolvers/channel.resolver.ts
  7. 1 1
      server/src/api/resolvers/country.resolver.ts
  8. 1 1
      server/src/api/resolvers/customer-group.resolver.ts
  9. 1 1
      server/src/api/resolvers/customer.resolver.ts
  10. 2 2
      server/src/api/resolvers/facet.resolver.ts
  11. 2 2
      server/src/api/resolvers/order.resolver.ts
  12. 2 2
      server/src/api/resolvers/product-option.resolver.ts
  13. 3 3
      server/src/api/resolvers/product.resolver.ts
  14. 1 1
      server/src/api/resolvers/promotion.resolver.ts
  15. 1 1
      server/src/api/resolvers/role.resolver.ts
  16. 1 1
      server/src/api/resolvers/tax-category.resolver.ts
  17. 1 1
      server/src/api/resolvers/tax-rate.resolver.ts
  18. 1 1
      server/src/api/resolvers/zone.resolver.ts
  19. 13 14
      server/src/service/helpers/order-calculator/order-calculator.ts
  20. 4 1
      server/src/service/helpers/password-cipher/password-ciper.ts
  21. 21 25
      server/src/service/helpers/tax-calculator/tax-calculator.spec.ts
  22. 8 8
      server/src/service/helpers/tax-calculator/tax-calculator.ts
  23. 25 25
      server/src/service/service.module.ts
  24. 4 4
      server/src/service/services/administrator.service.ts
  25. 0 0
      server/src/service/services/asset.service.ts
  26. 3 3
      server/src/service/services/auth.service.ts
  27. 0 0
      server/src/service/services/channel.service.ts
  28. 0 0
      server/src/service/services/country.service.ts
  29. 0 0
      server/src/service/services/customer-group.service.ts
  30. 3 3
      server/src/service/services/customer.service.ts
  31. 0 0
      server/src/service/services/facet-value.service.ts
  32. 0 0
      server/src/service/services/facet.service.ts
  33. 3 3
      server/src/service/services/order.service.ts
  34. 0 0
      server/src/service/services/product-option-group.service.ts
  35. 0 0
      server/src/service/services/product-option.service.ts
  36. 7 8
      server/src/service/services/product-variant.service.ts
  37. 0 0
      server/src/service/services/product.service.ts
  38. 0 0
      server/src/service/services/promotion.service.ts
  39. 0 0
      server/src/service/services/role.service.ts
  40. 0 0
      server/src/service/services/tax-category.service.ts
  41. 0 0
      server/src/service/services/tax-rate.service.ts
  42. 0 0
      server/src/service/services/zone.service.ts

+ 1 - 1
server/src/api/common/auth-guard.ts

@@ -6,7 +6,7 @@ import { Permission } from 'shared/generated-types';
 
 import { ConfigService } from '../../config/config.service';
 import { Session } from '../../entity/session/session.entity';
-import { AuthService } from '../../service/providers/auth.service';
+import { AuthService } from '../../service/services/auth.service';
 
 import { extractAuthToken } from './extract-auth-token';
 import { REQUEST_CONTEXT_KEY, RequestContextService } from './request-context.service';

+ 1 - 1
server/src/api/common/request-context.service.ts

@@ -9,7 +9,7 @@ import { AuthenticatedSession } from '../../entity/session/authenticated-session
 import { Session } from '../../entity/session/session.entity';
 import { User } from '../../entity/user/user.entity';
 import { I18nError } from '../../i18n/i18n-error';
-import { ChannelService } from '../../service/providers/channel.service';
+import { ChannelService } from '../../service/services/channel.service';
 
 import { RequestContext } from './request-context';
 

+ 1 - 1
server/src/api/resolvers/administrator.resolver.ts

@@ -11,7 +11,7 @@ import {
 import { PaginatedList } from 'shared/shared-types';
 
 import { Administrator } from '../../entity/administrator/administrator.entity';
-import { AdministratorService } from '../../service/providers/administrator.service';
+import { AdministratorService } from '../../service/services/administrator.service';
 import { Allow } from '../common/auth-guard';
 import { Decode } from '../common/id-interceptor';
 

+ 1 - 1
server/src/api/resolvers/asset.resolver.ts

@@ -8,7 +8,7 @@ import {
 import { PaginatedList } from 'shared/shared-types';
 
 import { Asset } from '../../entity/asset/asset.entity';
-import { AssetService } from '../../service/providers/asset.service';
+import { AssetService } from '../../service/services/asset.service';
 import { Allow } from '../common/auth-guard';
 
 @Resolver('Assets')

+ 2 - 2
server/src/api/resolvers/auth.resolver.ts

@@ -5,8 +5,8 @@ import { LoginMutationArgs, LoginResult, Permission } from 'shared/generated-typ
 import { ConfigService } from '../../config/config.service';
 import { AuthenticatedSession } from '../../entity/session/authenticated-session.entity';
 import { User } from '../../entity/user/user.entity';
-import { AuthService } from '../../service/providers/auth.service';
-import { ChannelService } from '../../service/providers/channel.service';
+import { AuthService } from '../../service/services/auth.service';
+import { ChannelService } from '../../service/services/channel.service';
 import { Allow } from '../common/auth-guard';
 import { extractAuthToken } from '../common/extract-auth-token';
 import { RequestContext } from '../common/request-context';

+ 1 - 1
server/src/api/resolvers/channel.resolver.ts

@@ -7,7 +7,7 @@ import {
 } from 'shared/generated-types';
 
 import { Channel } from '../../entity/channel/channel.entity';
-import { ChannelService } from '../../service/providers/channel.service';
+import { ChannelService } from '../../service/services/channel.service';
 import { Allow } from '../common/auth-guard';
 import { Decode } from '../common/id-interceptor';
 import { RequestContext } from '../common/request-context';

+ 1 - 1
server/src/api/resolvers/country.resolver.ts

@@ -10,7 +10,7 @@ import { PaginatedList } from 'shared/shared-types';
 
 import { Country } from '../../entity/country/country.entity';
 import { Facet } from '../../entity/facet/facet.entity';
-import { CountryService } from '../../service/providers/country.service';
+import { CountryService } from '../../service/services/country.service';
 import { Allow } from '../common/auth-guard';
 import { RequestContext } from '../common/request-context';
 import { Ctx } from '../common/request-context.decorator';

+ 1 - 1
server/src/api/resolvers/customer-group.resolver.ts

@@ -9,7 +9,7 @@ import {
 } from 'shared/generated-types';
 
 import { CustomerGroup } from '../../entity/customer-group/customer-group.entity';
-import { CustomerGroupService } from '../../service/providers/customer-group.service';
+import { CustomerGroupService } from '../../service/services/customer-group.service';
 import { Allow } from '../common/auth-guard';
 import { Decode } from '../common/id-interceptor';
 import { RequestContext } from '../common/request-context';

+ 1 - 1
server/src/api/resolvers/customer.resolver.ts

@@ -10,7 +10,7 @@ import { PaginatedList } from 'shared/shared-types';
 
 import { Address } from '../../entity/address/address.entity';
 import { Customer } from '../../entity/customer/customer.entity';
-import { CustomerService } from '../../service/providers/customer.service';
+import { CustomerService } from '../../service/services/customer.service';
 import { Allow } from '../common/auth-guard';
 import { Decode } from '../common/id-interceptor';
 

+ 2 - 2
server/src/api/resolvers/facet.resolver.ts

@@ -15,8 +15,8 @@ import { Translated } from '../../common/types/locale-types';
 import { FacetValue } from '../../entity/facet-value/facet-value.entity';
 import { Facet } from '../../entity/facet/facet.entity';
 import { I18nError } from '../../i18n/i18n-error';
-import { FacetValueService } from '../../service/providers/facet-value.service';
-import { FacetService } from '../../service/providers/facet.service';
+import { FacetValueService } from '../../service/services/facet-value.service';
+import { FacetService } from '../../service/services/facet.service';
 import { Allow } from '../common/auth-guard';
 import { RequestContext } from '../common/request-context';
 import { Ctx } from '../common/request-context.decorator';

+ 2 - 2
server/src/api/resolvers/order.resolver.ts

@@ -11,8 +11,8 @@ import { PaginatedList } from 'shared/shared-types';
 
 import { Order } from '../../entity/order/order.entity';
 import { I18nError } from '../../i18n/i18n-error';
-import { AuthService } from '../../service/providers/auth.service';
-import { OrderService } from '../../service/providers/order.service';
+import { AuthService } from '../../service/services/auth.service';
+import { OrderService } from '../../service/services/order.service';
 import { Allow } from '../common/auth-guard';
 import { Decode } from '../common/id-interceptor';
 import { RequestContext } from '../common/request-context';

+ 2 - 2
server/src/api/resolvers/product-option.resolver.ts

@@ -10,8 +10,8 @@ import {
 import { Translated } from '../../common/types/locale-types';
 import { ProductOptionGroup } from '../../entity/product-option-group/product-option-group.entity';
 import { ProductOption } from '../../entity/product-option/product-option.entity';
-import { ProductOptionGroupService } from '../../service/providers/product-option-group.service';
-import { ProductOptionService } from '../../service/providers/product-option.service';
+import { ProductOptionGroupService } from '../../service/services/product-option-group.service';
+import { ProductOptionService } from '../../service/services/product-option.service';
 import { Allow } from '../common/auth-guard';
 import { RequestContext } from '../common/request-context';
 import { Ctx } from '../common/request-context.decorator';

+ 3 - 3
server/src/api/resolvers/product.resolver.ts

@@ -19,9 +19,9 @@ import { assertFound } from '../../common/utils';
 import { ProductVariant } from '../../entity/product-variant/product-variant.entity';
 import { Product } from '../../entity/product/product.entity';
 import { I18nError } from '../../i18n/i18n-error';
-import { FacetValueService } from '../../service/providers/facet-value.service';
-import { ProductVariantService } from '../../service/providers/product-variant.service';
-import { ProductService } from '../../service/providers/product.service';
+import { FacetValueService } from '../../service/services/facet-value.service';
+import { ProductVariantService } from '../../service/services/product-variant.service';
+import { ProductService } from '../../service/services/product.service';
 import { Allow } from '../common/auth-guard';
 import { Decode } from '../common/id-interceptor';
 import { RequestContext } from '../common/request-context';

+ 1 - 1
server/src/api/resolvers/promotion.resolver.ts

@@ -9,7 +9,7 @@ import {
 import { PaginatedList } from 'shared/shared-types';
 
 import { Promotion } from '../../entity/promotion/promotion.entity';
-import { PromotionService } from '../../service/providers/promotion.service';
+import { PromotionService } from '../../service/services/promotion.service';
 import { Allow } from '../common/auth-guard';
 import { RequestContext } from '../common/request-context';
 import { Ctx } from '../common/request-context.decorator';

+ 1 - 1
server/src/api/resolvers/role.resolver.ts

@@ -9,7 +9,7 @@ import {
 import { PaginatedList } from 'shared/shared-types';
 
 import { Role } from '../../entity/role/role.entity';
-import { RoleService } from '../../service/providers/role.service';
+import { RoleService } from '../../service/services/role.service';
 import { Allow } from '../common/auth-guard';
 
 @Resolver('Roles')

+ 1 - 1
server/src/api/resolvers/tax-category.resolver.ts

@@ -7,7 +7,7 @@ import {
 } from 'shared/generated-types';
 
 import { TaxCategory } from '../../entity/tax-category/tax-category.entity';
-import { TaxCategoryService } from '../../service/providers/tax-category.service';
+import { TaxCategoryService } from '../../service/services/tax-category.service';
 import { Allow } from '../common/auth-guard';
 import { RequestContext } from '../common/request-context';
 import { Ctx } from '../common/request-context.decorator';

+ 1 - 1
server/src/api/resolvers/tax-rate.resolver.ts

@@ -9,7 +9,7 @@ import {
 import { PaginatedList } from 'shared/shared-types';
 
 import { TaxRate } from '../../entity/tax-rate/tax-rate.entity';
-import { TaxRateService } from '../../service/providers/tax-rate.service';
+import { TaxRateService } from '../../service/services/tax-rate.service';
 import { Allow } from '../common/auth-guard';
 import { Decode } from '../common/id-interceptor';
 import { RequestContext } from '../common/request-context';

+ 1 - 1
server/src/api/resolvers/zone.resolver.ts

@@ -9,7 +9,7 @@ import {
 } from 'shared/generated-types';
 
 import { Zone } from '../../entity/zone/zone.entity';
-import { ZoneService } from '../../service/providers/zone.service';
+import { ZoneService } from '../../service/services/zone.service';
 import { Allow } from '../common/auth-guard';
 import { Decode } from '../common/id-interceptor';
 import { RequestContext } from '../common/request-context';

+ 13 - 14
server/src/service/providers/order-calculator.service.ts → server/src/service/helpers/order-calculator/order-calculator.ts

@@ -1,17 +1,17 @@
 import { Injectable } from '@nestjs/common';
 import { AdjustmentType } from 'shared/generated-types';
 
-import { RequestContext } from '../../api/common/request-context';
-import { Order } from '../../entity/order/order.entity';
-import { Promotion } from '../../entity/promotion/promotion.entity';
-import { Zone } from '../../entity/zone/zone.entity';
+import { RequestContext } from '../../../api/common/request-context';
+import { Order } from '../../../entity/order/order.entity';
+import { Promotion } from '../../../entity/promotion/promotion.entity';
+import { Zone } from '../../../entity/zone/zone.entity';
 
-import { TaxCalculatorService } from './tax-calculator.service';
-import { TaxRateService } from './tax-rate.service';
+import { TaxRateService } from '../../services/tax-rate.service';
+import { TaxCalculator } from '../tax-calculator/tax-calculator';
 
 @Injectable()
-export class OrderCalculatorService {
-    constructor(private taxRateService: TaxRateService, private taxCalculatorService: TaxCalculatorService) {}
+export class OrderCalculator {
+    constructor(private taxRateService: TaxRateService, private taxCalculator: TaxCalculator) {}
 
     /**
      * Applies taxes and promotions to an Order. Mutates the order object.
@@ -41,12 +41,11 @@ export class OrderCalculatorService {
             line.clearAdjustments(AdjustmentType.TAX);
 
             const applicableTaxRate = this.taxRateService.getApplicableTaxRate(activeZone, line.taxCategory);
-            const {
-                price,
-                priceIncludesTax,
-                priceWithTax,
-                priceWithoutTax,
-            } = this.taxCalculatorService.calculate(line.unitPrice, line.taxCategory, ctx);
+            const { price, priceIncludesTax, priceWithTax, priceWithoutTax } = this.taxCalculator.calculate(
+                line.unitPrice,
+                line.taxCategory,
+                ctx,
+            );
 
             line.unitPriceIncludesTax = priceIncludesTax;
             line.includedTaxRate = applicableTaxRate.value;

+ 4 - 1
server/src/service/providers/password.service.ts → server/src/service/helpers/password-cipher/password-ciper.ts

@@ -3,8 +3,11 @@ import * as bcrypt from 'bcrypt';
 
 const SALT_ROUNDS = 12;
 
+/**
+ * A cipher which uses bcrypt (https://en.wikipedia.org/wiki/Bcrypt) to hash plaintext password strings.
+ */
 @Injectable()
-export class PasswordService {
+export class PasswordCiper {
     hash(plaintext: string): Promise<string> {
         return bcrypt.hash(plaintext, SALT_ROUNDS);
     }

+ 21 - 25
server/src/service/providers/tax-calculator.service.spec.ts → server/src/service/helpers/tax-calculator/tax-calculator.spec.ts

@@ -2,17 +2,17 @@ import { Test } from '@nestjs/testing';
 import { LanguageCode } from 'shared/generated-types';
 import { Connection } from 'typeorm';
 
-import { RequestContext } from '../../api/common/request-context';
-import { Channel } from '../../entity/channel/channel.entity';
-import { TaxCategory } from '../../entity/tax-category/tax-category.entity';
-import { TaxRate } from '../../entity/tax-rate/tax-rate.entity';
-import { Zone } from '../../entity/zone/zone.entity';
+import { RequestContext } from '../../../api/common/request-context';
+import { Channel } from '../../../entity/channel/channel.entity';
+import { TaxCategory } from '../../../entity/tax-category/tax-category.entity';
+import { TaxRate } from '../../../entity/tax-rate/tax-rate.entity';
+import { Zone } from '../../../entity/zone/zone.entity';
+import { TaxRateService } from '../../services/tax-rate.service';
 
-import { TaxCalculatorService } from './tax-calculator.service';
-import { TaxRateService } from './tax-rate.service';
+import { TaxCalculator } from './tax-calculator';
 
-describe('TaxCalculatorService', () => {
-    let taxCalculatorService: TaxCalculatorService;
+describe('TaxCalculator', () => {
+    let taxCalculator: TaxCalculator;
     const inputPrice = 6543;
     const taxCategoryStandard = new TaxCategory({
         id: 'taxCategoryStandard',
@@ -99,14 +99,10 @@ describe('TaxCalculatorService', () => {
 
     beforeEach(async () => {
         const module = await Test.createTestingModule({
-            providers: [
-                TaxCalculatorService,
-                TaxRateService,
-                { provide: Connection, useClass: MockConnection },
-            ],
+            providers: [TaxCalculator, TaxRateService, { provide: Connection, useClass: MockConnection }],
         }).compile();
 
-        taxCalculatorService = module.get(TaxCalculatorService);
+        taxCalculator = module.get(TaxCalculator);
         const taxRateService = module.get(TaxRateService);
         await taxRateService.initTaxRates();
     });
@@ -114,7 +110,7 @@ describe('TaxCalculatorService', () => {
     describe('with prices which do not include tax', () => {
         it('standard tax, default zone', () => {
             const ctx = createRequestContext(false, zoneDefault);
-            const result = taxCalculatorService.calculate(inputPrice, taxCategoryStandard, ctx);
+            const result = taxCalculator.calculate(inputPrice, taxCategoryStandard, ctx);
 
             expect(result).toEqual({
                 price: inputPrice,
@@ -126,7 +122,7 @@ describe('TaxCalculatorService', () => {
 
         it('reduced tax, default zone', () => {
             const ctx = createRequestContext(false, zoneDefault);
-            const result = taxCalculatorService.calculate(6543, taxCategoryReduced, ctx);
+            const result = taxCalculator.calculate(6543, taxCategoryReduced, ctx);
 
             expect(result).toEqual({
                 price: inputPrice,
@@ -138,7 +134,7 @@ describe('TaxCalculatorService', () => {
 
         it('standard tax, other zone', () => {
             const ctx = createRequestContext(false, zoneOther);
-            const result = taxCalculatorService.calculate(6543, taxCategoryStandard, ctx);
+            const result = taxCalculator.calculate(6543, taxCategoryStandard, ctx);
 
             expect(result).toEqual({
                 price: inputPrice,
@@ -150,7 +146,7 @@ describe('TaxCalculatorService', () => {
 
         it('reduced tax, other zone', () => {
             const ctx = createRequestContext(false, zoneOther);
-            const result = taxCalculatorService.calculate(inputPrice, taxCategoryReduced, ctx);
+            const result = taxCalculator.calculate(inputPrice, taxCategoryReduced, ctx);
 
             expect(result).toEqual({
                 price: inputPrice,
@@ -162,7 +158,7 @@ describe('TaxCalculatorService', () => {
 
         it('standard tax, unconfigured zone', () => {
             const ctx = createRequestContext(false, zoneWithNoTaxRate);
-            const result = taxCalculatorService.calculate(inputPrice, taxCategoryReduced, ctx);
+            const result = taxCalculator.calculate(inputPrice, taxCategoryReduced, ctx);
 
             expect(result).toEqual({
                 price: inputPrice,
@@ -176,7 +172,7 @@ describe('TaxCalculatorService', () => {
     describe('with prices which include tax', () => {
         it('standard tax, default zone', () => {
             const ctx = createRequestContext(true, zoneDefault);
-            const result = taxCalculatorService.calculate(inputPrice, taxCategoryStandard, ctx);
+            const result = taxCalculator.calculate(inputPrice, taxCategoryStandard, ctx);
 
             expect(result).toEqual({
                 price: inputPrice,
@@ -188,7 +184,7 @@ describe('TaxCalculatorService', () => {
 
         it('reduced tax, default zone', () => {
             const ctx = createRequestContext(true, zoneDefault);
-            const result = taxCalculatorService.calculate(inputPrice, taxCategoryReduced, ctx);
+            const result = taxCalculator.calculate(inputPrice, taxCategoryReduced, ctx);
 
             expect(result).toEqual({
                 price: inputPrice,
@@ -200,7 +196,7 @@ describe('TaxCalculatorService', () => {
 
         it('standard tax, other zone', () => {
             const ctx = createRequestContext(true, zoneOther);
-            const result = taxCalculatorService.calculate(inputPrice, taxCategoryStandard, ctx);
+            const result = taxCalculator.calculate(inputPrice, taxCategoryStandard, ctx);
 
             expect(result).toEqual({
                 price: taxRateDefaultStandard.netPriceOf(inputPrice),
@@ -214,7 +210,7 @@ describe('TaxCalculatorService', () => {
 
         it('reduced tax, other zone', () => {
             const ctx = createRequestContext(true, zoneOther);
-            const result = taxCalculatorService.calculate(inputPrice, taxCategoryReduced, ctx);
+            const result = taxCalculator.calculate(inputPrice, taxCategoryReduced, ctx);
 
             expect(result).toEqual({
                 price: taxRateDefaultReduced.netPriceOf(inputPrice),
@@ -226,7 +222,7 @@ describe('TaxCalculatorService', () => {
 
         it('standard tax, unconfigured zone', () => {
             const ctx = createRequestContext(true, zoneWithNoTaxRate);
-            const result = taxCalculatorService.calculate(inputPrice, taxCategoryStandard, ctx);
+            const result = taxCalculator.calculate(inputPrice, taxCategoryStandard, ctx);
 
             expect(result).toEqual({
                 price: taxRateDefaultStandard.netPriceOf(inputPrice),

+ 8 - 8
server/src/service/providers/tax-calculator.service.ts → server/src/service/helpers/tax-calculator/tax-calculator.ts

@@ -1,13 +1,13 @@
 import { Injectable } from '@nestjs/common';
 
-import { RequestContext } from '../../api/common/request-context';
-import { idsAreEqual } from '../../common/utils';
-import { Channel } from '../../entity/channel/channel.entity';
-import { TaxCategory } from '../../entity/tax-category/tax-category.entity';
-import { TaxRate } from '../../entity/tax-rate/tax-rate.entity';
-import { Zone } from '../../entity/zone/zone.entity';
+import { RequestContext } from '../../../api/common/request-context';
+import { idsAreEqual } from '../../../common/utils';
+import { Channel } from '../../../entity/channel/channel.entity';
+import { TaxCategory } from '../../../entity/tax-category/tax-category.entity';
+import { TaxRate } from '../../../entity/tax-rate/tax-rate.entity';
+import { Zone } from '../../../entity/zone/zone.entity';
 
-import { TaxRateService } from './tax-rate.service';
+import { TaxRateService } from '../../services/tax-rate.service';
 
 export interface TaxCalculationResult {
     price: number;
@@ -17,7 +17,7 @@ export interface TaxCalculationResult {
 }
 
 @Injectable()
-export class TaxCalculatorService {
+export class TaxCalculator {
     constructor(private taxRateService: TaxRateService) {}
 
     /**

+ 25 - 25
server/src/service/service.module.ts

@@ -4,29 +4,29 @@ import { TypeOrmModule } from '@nestjs/typeorm';
 import { ConfigModule } from '../config/config.module';
 import { getConfig } from '../config/vendure-config';
 
+import { OrderCalculator } from './helpers/order-calculator/order-calculator';
+import { PasswordCiper } from './helpers/password-cipher/password-ciper';
+import { TaxCalculator } from './helpers/tax-calculator/tax-calculator';
 import { TranslationUpdaterService } from './helpers/translation-updater.service';
-import { AdministratorService } from './providers/administrator.service';
-import { AssetService } from './providers/asset.service';
-import { AuthService } from './providers/auth.service';
-import { ChannelService } from './providers/channel.service';
-import { CountryService } from './providers/country.service';
-import { CustomerGroupService } from './providers/customer-group.service';
-import { CustomerService } from './providers/customer.service';
-import { FacetValueService } from './providers/facet-value.service';
-import { FacetService } from './providers/facet.service';
-import { OrderCalculatorService } from './providers/order-calculator.service';
-import { OrderService } from './providers/order.service';
-import { PasswordService } from './providers/password.service';
-import { ProductOptionGroupService } from './providers/product-option-group.service';
-import { ProductOptionService } from './providers/product-option.service';
-import { ProductVariantService } from './providers/product-variant.service';
-import { ProductService } from './providers/product.service';
-import { PromotionService } from './providers/promotion.service';
-import { RoleService } from './providers/role.service';
-import { TaxCalculatorService } from './providers/tax-calculator.service';
-import { TaxCategoryService } from './providers/tax-category.service';
-import { TaxRateService } from './providers/tax-rate.service';
-import { ZoneService } from './providers/zone.service';
+import { AdministratorService } from './services/administrator.service';
+import { AssetService } from './services/asset.service';
+import { AuthService } from './services/auth.service';
+import { ChannelService } from './services/channel.service';
+import { CountryService } from './services/country.service';
+import { CustomerGroupService } from './services/customer-group.service';
+import { CustomerService } from './services/customer.service';
+import { FacetValueService } from './services/facet-value.service';
+import { FacetService } from './services/facet.service';
+import { OrderService } from './services/order.service';
+import { ProductOptionGroupService } from './services/product-option-group.service';
+import { ProductOptionService } from './services/product-option.service';
+import { ProductVariantService } from './services/product-variant.service';
+import { ProductService } from './services/product.service';
+import { PromotionService } from './services/promotion.service';
+import { RoleService } from './services/role.service';
+import { TaxCategoryService } from './services/tax-category.service';
+import { TaxRateService } from './services/tax-rate.service';
+import { ZoneService } from './services/zone.service';
 
 const exportedProviders = [
     PromotionService,
@@ -61,10 +61,10 @@ const exportedProviders = [
     imports: [ConfigModule, TypeOrmModule.forRoot(getConfig().dbConnectionOptions)],
     providers: [
         ...exportedProviders,
-        PasswordService,
+        PasswordCiper,
         TranslationUpdaterService,
-        TaxCalculatorService,
-        OrderCalculatorService,
+        TaxCalculator,
+        OrderCalculator,
     ],
     exports: exportedProviders,
 })

+ 4 - 4
server/src/service/providers/administrator.service.ts → server/src/service/services/administrator.service.ts

@@ -10,16 +10,16 @@ import { Administrator } from '../../entity/administrator/administrator.entity';
 import { User } from '../../entity/user/user.entity';
 import { I18nError } from '../../i18n/i18n-error';
 import { buildListQuery } from '../helpers/build-list-query';
+import { PasswordCiper } from '../helpers/password-cipher/password-ciper';
 import { patchEntity } from '../helpers/patch-entity';
 
-import { PasswordService } from './password.service';
 import { RoleService } from './role.service';
 
 @Injectable()
 export class AdministratorService {
     constructor(
         @InjectConnection() private connection: Connection,
-        private passwordService: PasswordService,
+        private passwordCipher: PasswordCiper,
         private roleService: RoleService,
     ) {}
 
@@ -46,7 +46,7 @@ export class AdministratorService {
         const administrator = new Administrator(input);
 
         const user = new User();
-        user.passwordHash = await this.passwordService.hash(input.password);
+        user.passwordHash = await this.passwordCipher.hash(input.password);
         user.identifier = input.emailAddress;
 
         const createdUser = await this.connection.manager.save(user);
@@ -71,7 +71,7 @@ export class AdministratorService {
         await this.connection.manager.save(administrator);
 
         if (input.password) {
-            administrator.user.passwordHash = await this.passwordService.hash(input.password);
+            administrator.user.passwordHash = await this.passwordCipher.hash(input.password);
         }
         if (input.roleIds) {
             administrator.user.roles = [];

+ 0 - 0
server/src/service/providers/asset.service.ts → server/src/service/services/asset.service.ts


+ 3 - 3
server/src/service/providers/auth.service.ts → server/src/service/services/auth.service.ts

@@ -12,7 +12,7 @@ import { AuthenticatedSession } from '../../entity/session/authenticated-session
 import { Session } from '../../entity/session/session.entity';
 import { User } from '../../entity/user/user.entity';
 
-import { PasswordService } from './password.service';
+import { PasswordCiper } from '../helpers/password-cipher/password-ciper';
 
 /**
  * The AuthService manages both authenticated and anonymous sessions.
@@ -22,7 +22,7 @@ export class AuthService {
     private readonly sessionDurationInMs;
 
     constructor(
-        private passwordService: PasswordService,
+        private passwordCipher: PasswordCiper,
         @InjectConnection() private connection: Connection,
         private configService: ConfigService,
     ) {
@@ -34,7 +34,7 @@ export class AuthService {
      */
     async authenticate(identifier: string, password: string): Promise<AuthenticatedSession> {
         const user = await this.getUserFromIdentifier(identifier);
-        const passwordMatches = await this.passwordService.check(password, user.passwordHash);
+        const passwordMatches = await this.passwordCipher.check(password, user.passwordHash);
         if (!passwordMatches) {
             throw new UnauthorizedException();
         }

+ 0 - 0
server/src/service/providers/channel.service.ts → server/src/service/services/channel.service.ts


+ 0 - 0
server/src/service/providers/country.service.ts → server/src/service/services/country.service.ts


+ 0 - 0
server/src/service/providers/customer-group.service.ts → server/src/service/services/customer-group.service.ts


+ 3 - 3
server/src/service/providers/customer.service.ts → server/src/service/services/customer.service.ts

@@ -10,15 +10,15 @@ import { Customer } from '../../entity/customer/customer.entity';
 import { User } from '../../entity/user/user.entity';
 import { I18nError } from '../../i18n/i18n-error';
 import { buildListQuery } from '../helpers/build-list-query';
+import { PasswordCiper } from '../helpers/password-cipher/password-ciper';
 
-import { PasswordService } from './password.service';
 import { RoleService } from './role.service';
 
 @Injectable()
 export class CustomerService {
     constructor(
         @InjectConnection() private connection: Connection,
-        private passwordService: PasswordService,
+        private passwordCipher: PasswordCiper,
         private roleService: RoleService,
     ) {}
 
@@ -45,7 +45,7 @@ export class CustomerService {
 
         if (password) {
             const user = new User();
-            user.passwordHash = await this.passwordService.hash(password);
+            user.passwordHash = await this.passwordCipher.hash(password);
             user.identifier = input.emailAddress;
             user.roles = [await this.roleService.getCustomerRole()];
             const createdUser = await this.connection.manager.save(user);

+ 0 - 0
server/src/service/providers/facet-value.service.ts → server/src/service/services/facet-value.service.ts


+ 0 - 0
server/src/service/providers/facet.service.ts → server/src/service/services/facet.service.ts


+ 3 - 3
server/src/service/providers/order.service.ts → server/src/service/services/order.service.ts

@@ -13,16 +13,16 @@ import { ProductVariant } from '../../entity/product-variant/product-variant.ent
 import { Promotion } from '../../entity/promotion/promotion.entity';
 import { I18nError } from '../../i18n/i18n-error';
 import { buildListQuery } from '../helpers/build-list-query';
+import { OrderCalculator } from '../helpers/order-calculator/order-calculator';
 import { translateDeep } from '../helpers/translate-entity';
 
-import { OrderCalculatorService } from './order-calculator.service';
 import { ProductVariantService } from './product-variant.service';
 
 export class OrderService {
     constructor(
         @InjectConnection() private connection: Connection,
         private productVariantService: ProductVariantService,
-        private orderCalculatorService: OrderCalculatorService,
+        private orderCalculator: OrderCalculator,
     ) {}
 
     findAll(ctx: RequestContext, options?: ListQueryOptions<Order>): Promise<PaginatedList<Order>> {
@@ -174,7 +174,7 @@ export class OrderService {
 
     private async applyTaxesAndPromotions(ctx: RequestContext, order: Order): Promise<Order> {
         const promotions = await this.connection.getRepository(Promotion).find({ where: { enabled: true } });
-        order = this.orderCalculatorService.applyTaxesAndPromotions(ctx, order, promotions);
+        order = this.orderCalculator.applyTaxesAndPromotions(ctx, order, promotions);
         await this.connection.getRepository(Order).save(order);
         await this.connection.getRepository(OrderItem).save(order.getOrderItems());
         await this.connection.getRepository(OrderLine).save(order.lines);

+ 0 - 0
server/src/service/providers/product-option-group.service.ts → server/src/service/services/product-option-group.service.ts


+ 0 - 0
server/src/service/providers/product-option.service.ts → server/src/service/services/product-option.service.ts


+ 7 - 8
server/src/service/providers/product-variant.service.ts → server/src/service/services/product-variant.service.ts

@@ -19,11 +19,11 @@ import { TaxRate } from '../../entity/tax-rate/tax-rate.entity';
 import { Zone } from '../../entity/zone/zone.entity';
 import { I18nError } from '../../i18n/i18n-error';
 import { createTranslatable } from '../helpers/create-translatable';
+import { TaxCalculator } from '../helpers/tax-calculator/tax-calculator';
 import { translateDeep } from '../helpers/translate-entity';
 import { TranslationUpdaterService } from '../helpers/translation-updater.service';
 import { updateTranslatable } from '../helpers/update-translatable';
 
-import { TaxCalculatorService } from './tax-calculator.service';
 import { TaxCategoryService } from './tax-category.service';
 import { TaxRateService } from './tax-rate.service';
 
@@ -33,7 +33,7 @@ export class ProductVariantService {
         @InjectConnection() private connection: Connection,
         private taxCategoryService: TaxCategoryService,
         private taxRateService: TaxRateService,
-        private taxCalculatorService: TaxCalculatorService,
+        private taxCalculator: TaxCalculator,
         private translationUpdaterService: TranslationUpdaterService,
     ) {}
 
@@ -187,12 +187,11 @@ export class ProductVariantService {
             variant.taxCategory,
         );
 
-        const {
-            price,
-            priceIncludesTax,
-            priceWithTax,
-            priceWithoutTax,
-        } = this.taxCalculatorService.calculate(channelPrice.price, variant.taxCategory, ctx);
+        const { price, priceIncludesTax, priceWithTax, priceWithoutTax } = this.taxCalculator.calculate(
+            channelPrice.price,
+            variant.taxCategory,
+            ctx,
+        );
 
         variant.price = price;
         variant.priceIncludesTax = priceIncludesTax;

+ 0 - 0
server/src/service/providers/product.service.ts → server/src/service/services/product.service.ts


+ 0 - 0
server/src/service/providers/promotion.service.ts → server/src/service/services/promotion.service.ts


+ 0 - 0
server/src/service/providers/role.service.ts → server/src/service/services/role.service.ts


+ 0 - 0
server/src/service/providers/tax-category.service.ts → server/src/service/services/tax-category.service.ts


+ 0 - 0
server/src/service/providers/tax-rate.service.ts → server/src/service/services/tax-rate.service.ts


+ 0 - 0
server/src/service/providers/zone.service.ts → server/src/service/services/zone.service.ts