Skip to content

Commit

Permalink
feat(all): use provider functions for providing configs (#3280)
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 authored Oct 16, 2024
1 parent d612544 commit ed7930f
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 54 deletions.
3 changes: 2 additions & 1 deletion libs/analytics/src/lib/analytics.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
DaffAnalyticsConfig,
DaffAnalyticsConfigInterface,
defaultConfig,
provideDaffAnalyticsConfig,
} from './config/config';
import { DaffAnalyticsEffects } from './effects/analytics-effects';
import { daffAnalyticsServiceProvider } from './provider';
Expand All @@ -28,7 +29,7 @@ export class DaffAnalyticsModule {
return {
ngModule: DaffAnalyticsModule,
providers: [
{ provide: DaffAnalyticsConfig, useValue: config },
provideDaffAnalyticsConfig(config),
...daffAnalyticsServiceProvider(services),
],
};
Expand Down
7 changes: 2 additions & 5 deletions libs/authorizenet/driver/magento/src/authorize-net.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {

import {
DaffAuthorizeNetConfig,
DaffAuthorizeNetConfigToken,
provideDaffAuthorizeNetConfigToken,
provideDaffAuthorizeNetDriver,
provideDaffAuthorizeNetPaymentDriver,
DaffAuthorizeNetPaymentId,
Expand All @@ -30,10 +30,7 @@ export class DaffMagentoAuthorizeNetDriverModule {
return {
ngModule: DaffMagentoAuthorizeNetDriverModule,
providers: [
{
provide: DaffAuthorizeNetConfigToken,
useValue: config,
},
provideDaffAuthorizeNetConfigToken(config),
provideDaffAuthorizeNetDriver(DaffMagentoAuthorizeNetService),
provideDaffAuthorizeNetPaymentDriver(DaffMagentoAuthorizeNetPaymentService),
{
Expand Down
11 changes: 2 additions & 9 deletions libs/cart/routing/src/cart-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {

import {
DaffCartRoutingConfiguration,
DAFF_CART_ROUTING_CONFIG,
daffCartRoutingConfigurationDefault,
provideDaffCartRoutingConfig,
} from './config/config';
import {
DaffCartBillingAddressGuardRedirectUrl,
Expand Down Expand Up @@ -40,13 +39,7 @@ export class DaffCartRoutingModule {
return {
ngModule: DaffCartRoutingModule,
providers: [
{
provide: DAFF_CART_ROUTING_CONFIG,
useValue: {
...daffCartRoutingConfigurationDefault,
...config,
},
},
provideDaffCartRoutingConfig(config),
],
};
}
Expand Down
4 changes: 2 additions & 2 deletions libs/contact/driver/hubspot/src/hubspot-driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { provideDaffContactDriver } from '@daffodil/contact/driver';
import { DaffHubspotConfig } from '@daffodil/driver/hubspot';

import { DaffContactConfigToken } from './config/contact-config.interface';
import { provideDaffContactConfigToken } from './config/contact-config.interface';
import { DaffContactHubspotService } from './contact.service';

@NgModule({
Expand All @@ -21,7 +21,7 @@ export class DaffContactHubSpotDriverModule {
ngModule: DaffContactHubSpotDriverModule,
providers: [
provideDaffContactDriver(DaffContactHubspotService),
{ provide: DaffContactConfigToken, useValue: config },
provideDaffContactConfigToken(config),
],
};
}
Expand Down
11 changes: 2 additions & 9 deletions libs/external-router/driver/in-memory/src/in-memory.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import {
NgModule,
ModuleWithProviders,
InjectionToken,
inject,
} from '@angular/core';

import { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';

import {
DaffExternalRouterDriverInMemoryConfig,
DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG,
provideDaffExternalRouterDriverInMemoryConfig,
} from './config';
import { DaffExternalRouterInMemoryDriver } from './in-memory.service';

Expand All @@ -30,13 +29,7 @@ export class DaffExternalRouterDriverInMemoryModule {
ngModule: DaffExternalRouterDriverInMemoryModule,
providers: [
provideDaffExternalRouterDriver(DaffExternalRouterInMemoryDriver),
{
provide: DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG,
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
useFactory() {
return config instanceof InjectionToken ? inject(config) : config;
},
},
provideDaffExternalRouterDriverInMemoryConfig(config),
],
};
}
Expand Down
7 changes: 2 additions & 5 deletions libs/external-router/driver/testing/src/testing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { provideDaffExternalRouterDriver } from '@daffodil/external-router/drive

import {
DaffExternalRouterDriverTestingConfig,
DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,
provideDaffExternalRouterDriverTestingConfig,
} from './config';
import { DaffExternalRouterTestingDriver } from './testing.service';

Expand All @@ -28,10 +28,7 @@ export class DaffExternalRouterDriverTestingModule {
ngModule: DaffExternalRouterDriverTestingModule,
providers: [
provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),
{
provide: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,
useValue: config,
},
provideDaffExternalRouterDriverTestingConfig(config),
],
};
}
Expand Down
5 changes: 2 additions & 3 deletions libs/external-router/src/external-router.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {

import {
DaffExternalRouterConfiguration,
DAFF_EXTERNAL_ROUTER_CONFIG,
daffExternalRouterConfigurationDefault,
provideDaffExternalRouterConfig,
} from './config';
import { DaffTypeRoutePair } from './model/type-route-pair';
import { provideDaffRoutesResolvableByType } from './token/type-resolvable-routes.token';
Expand All @@ -28,7 +27,7 @@ export class DaffExternalRouterModule {
return {
ngModule: DaffExternalRouterModule,
providers: [
{ provide: DAFF_EXTERNAL_ROUTER_CONFIG, useValue: { ...daffExternalRouterConfigurationDefault, ...config }},
provideDaffExternalRouterConfig(config),
...provideDaffRoutesResolvableByType(...routes),
],
};
Expand Down
7 changes: 2 additions & 5 deletions libs/newsletter/driver/hubspot/src/hubspot-driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { DaffHubspotConfig } from '@daffodil/driver/hubspot';
import { provideDaffNewsletterDriver } from '@daffodil/newsletter/driver';

import { DaffNewsletterConfigToken } from './config/newsletter-config.interface';
import { provideDaffNewsletterConfigToken } from './config/newsletter-config.interface';
import { DaffNewsletterHubspotService } from './newsletter.service';

@NgModule({
Expand All @@ -21,10 +21,7 @@ export class DaffNewsletterHubSpotDriverModule {
ngModule: DaffNewsletterHubSpotDriverModule,
providers: [
provideDaffNewsletterDriver(DaffNewsletterHubspotService),
{
provide: DaffNewsletterConfigToken,
useValue: config,
},
provideDaffNewsletterConfigToken(config),
],
};
}
Expand Down
13 changes: 5 additions & 8 deletions libs/paypal/driver/magento/src/paypal-driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
} from '@angular/core';

import {
DAFF_PAYPAL_EXPRESS_DRIVER_CONFIG,
DaffPaypalExpressDriverConfig,
provideDaffPaypalExpressDriver,
provideDaffPaypalExpressDriverConfig,
provideDaffPaypalExpressPaymentDriver,
} from '@daffodil/paypal/driver';

Expand All @@ -27,13 +27,10 @@ export class DaffPaypalMagentoDriverModule {
providers: [
provideDaffPaypalExpressDriver(DaffMagentoPaypalService),
provideDaffPaypalExpressPaymentDriver(DaffMagentoPaypalPaymentService),
{
provide: DAFF_PAYPAL_EXPRESS_DRIVER_CONFIG,
useValue: {
...MAGENTO_PAYPAL_EXPRESS_DRIVER_CONFIG_DEFAULT,
...config,
},
},
provideDaffPaypalExpressDriverConfig({
...MAGENTO_PAYPAL_EXPRESS_DRIVER_CONFIG_DEFAULT,
...config,
}),
],
};
}
Expand Down
2 changes: 1 addition & 1 deletion libs/search/state/src/config/public_api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { DAFF_SEARCH_STATE_CONFIG_DEFAULT } from './default';
export { DaffSearchStateConfig } from './interface';
export { DAFF_SEARCH_STATE_CONFIG } from './token';
export * from './token';
2 changes: 1 addition & 1 deletion libs/search/state/src/config/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export const {
* The token used to provide @daffodil/search/state config data.
*/
token: DAFF_SEARCH_STATE_CONFIG,
provider: provideDaffAuthRoutingConfig,
provider: provideDaffSearchStateConfig,
} = createConfigInjectionToken<DaffSearchStateConfig>(DAFF_SEARCH_STATE_CONFIG_DEFAULT, 'DAFF_SEARCH_STATE_CONFIG');
7 changes: 2 additions & 5 deletions libs/search/state/src/incremental.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { EffectsModule } from '@ngrx/effects';

import {
DaffSearchStateConfig,
DAFF_SEARCH_STATE_CONFIG,
provideDaffSearchStateConfig,
DAFF_SEARCH_STATE_CONFIG_DEFAULT,
} from './config/public_api';
import { DaffSearchIncrementalEffects } from './effects/incremental.effects';
Expand All @@ -25,10 +25,7 @@ export class DaffSearchIncrementalStateModule {
return {
ngModule: DaffSearchIncrementalStateModule,
providers: [
{
provide: DAFF_SEARCH_STATE_CONFIG,
useValue: config,
},
provideDaffSearchStateConfig(config),
],
};
}
Expand Down

0 comments on commit ed7930f

Please sign in to comment.