Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(all): use functions for providing configs #3283

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions libs/category/driver/magento/src/category-driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ import {

import { provideDaffCategoryDriver } from '@daffodil/category/driver';
import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
import {
provideDaffProductMagentoExtraProductPreviewFragments,
DAFF_MAGENTO_GET_FILTER_TYPES_QUERY_NAME,
magentoProductPreviewFragment,
} from '@daffodil/product/driver/magento';
import { DAFF_MAGENTO_GET_FILTER_TYPES_QUERY_NAME } from '@daffodil/product/driver/magento';

import { DaffMagentoCategoryService } from './category.service';
import { MAGENTO_CATEGORY_CONFIG_DEFAULT } from './config/default';
import {
DaffCategoryMagentoDriverConfig,
MAGENTO_CATEGORY_CONFIG_TOKEN,
provideMagentoCategoryConfig,
} from './interfaces/public_api';
import {
DAFF_MAGENTO_GET_CATEGORY_AND_PRODUCTS_QUERY_NAME,
Expand Down Expand Up @@ -61,13 +57,7 @@ export class DaffCategoryMagentoDriverModule {
useValue: DAFF_MAGENTO_RESOLVE_CATEGORY_URL_QUERY_NAME,
multi: true,
},
{
provide: MAGENTO_CATEGORY_CONFIG_TOKEN,
useValue: {
...MAGENTO_CATEGORY_CONFIG_DEFAULT,
...config,
},
},
provideMagentoCategoryConfig(config),
],
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const {
* Mandatory for the Magento driver.
*/
token: MAGENTO_CATEGORY_CONFIG_TOKEN,
provider: provideDaffAnalyticsConfig,
provider: provideMagentoCategoryConfig,
} = createConfigInjectionToken<DaffCategoryMagentoDriverConfig>(
MAGENTO_CATEGORY_CONFIG_DEFAULT,
'MAGENTO_CATEGORY_CONFIG_TOKEN',
Expand Down
10 changes: 2 additions & 8 deletions libs/navigation/driver/magento/src/navigation-driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import {
MagentoNavigationDriverConfig,
MAGENTO_NAVIGATION_DRIVER_CONFIG_DEFAULT,
MAGENTO_NAVIGATION_DRIVER_CONFIG,
provideMagentoNavigationDriverConfig,
} from './config/public_api';
import { DaffMagentoNavigationService } from './navigation.service';
import { DAFF_MAGENTO_GET_CATEGORY_TREE_QUERY_NAME } from './queries/get-category-tree';
Expand All @@ -34,13 +34,7 @@ export class DaffNavigationMagentoDriverModule {
provide: DaffNavigationTransformer,
useExisting: DaffMagentoNavigationTransformerService,
},
{
provide: MAGENTO_NAVIGATION_DRIVER_CONFIG,
useValue: {
...MAGENTO_NAVIGATION_DRIVER_CONFIG_DEFAULT,
...config,
},
},
provideMagentoNavigationDriverConfig(config),
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_GET_CATEGORY_TREE_QUERY_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const {
* Mandatory for the Magento driver.
*/
token: MAGENTO_PRODUCT_CONFIG_TOKEN,
provider: provideDaffProductMagentoConfig,
provider: provideMagentoProductConfig,
} = createConfigInjectionToken<DaffProductMagentoDriverConfig>(
MAGENTO_PRODUCT_CONFIG_DEFAULT,
'MAGENTO_PRODUCT_CONFIG_TOKEN',
Expand Down
10 changes: 2 additions & 8 deletions libs/product/driver/magento/src/product-driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { provideDaffProductDriver } from '@daffodil/product/driver';
import { MAGENTO_PRODUCT_CONFIG_DEFAULT } from './config/public_api';
import {
DaffProductMagentoDriverConfig,
MAGENTO_PRODUCT_CONFIG_TOKEN,
provideMagentoProductConfig,
} from './interfaces/public_api';
import { DaffMagentoProductService } from './product.service';
import { DAFF_MAGENTO_GET_ALL_PRODUCTS_QUERY_NAME } from './queries/get-all-products';
Expand Down Expand Up @@ -47,13 +47,7 @@ export class DaffProductMagentoDriverModule {
useValue: DAFF_MAGENTO_GET_A_PRODUCT_BY_URL_QUERY_NAME,
multi: true,
},
{
provide: MAGENTO_PRODUCT_CONFIG_TOKEN,
useValue: {
...MAGENTO_PRODUCT_CONFIG_DEFAULT,
...config,
},
},
provideMagentoProductConfig(config),
],
};
}
Expand Down
2 changes: 1 addition & 1 deletion libs/search/driver/federated/src/config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { DaffSearchFederatedDriverConfig } from './interface';
/**
* The default configuration for the {@link DaffSearchFederatedDriverConfig}.
*/
export const SEARCH_FEDERATED_CONFIG_DEFAULT: DaffSearchFederatedDriverConfig = {};
export const DAFF_SEARCH_FEDERATED_CONFIG_DEFAULT: DaffSearchFederatedDriverConfig = {};
10 changes: 5 additions & 5 deletions libs/search/driver/federated/src/config/interface.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { createConfigInjectionToken } from '@daffodil/core';

import { SEARCH_FEDERATED_CONFIG_DEFAULT } from './default';
import { DAFF_SEARCH_FEDERATED_CONFIG_DEFAULT } from './default';

export const {
/**
* The token used to provide @daffodil/search/driver/federated config data.
* Mandatory for the Magento driver.
*/
token: SEARCH_FEDERATED_CONFIG_TOKEN,
provider: provideDaffAnalyticsConfig,
token: DAFF_SEARCH_FEDERATED_CONFIG_TOKEN,
provider: provideDaffSearchFederatedConfig,
} = createConfigInjectionToken<DaffSearchFederatedDriverConfig>(
SEARCH_FEDERATED_CONFIG_DEFAULT,
'SEARCH_FEDERATED_CONFIG_TOKEN',
DAFF_SEARCH_FEDERATED_CONFIG_DEFAULT,
'DAFF_SEARCH_FEDERATED_CONFIG_TOKEN',
);

/**
Expand Down
7 changes: 2 additions & 5 deletions libs/search/driver/federated/src/config/public_api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
export { SEARCH_FEDERATED_CONFIG_DEFAULT } from './default';
export {
SEARCH_FEDERATED_CONFIG_TOKEN,
DaffSearchFederatedDriverConfig,
} from './interface';
export { DAFF_SEARCH_FEDERATED_CONFIG_DEFAULT } from './default';
export * from './interface';
24 changes: 6 additions & 18 deletions libs/search/driver/federated/src/search-driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {

import {
DaffSearchFederatedDriverConfig,
SEARCH_FEDERATED_CONFIG_DEFAULT,
SEARCH_FEDERATED_CONFIG_TOKEN,
DAFF_SEARCH_FEDERATED_CONFIG_DEFAULT,
provideDaffSearchFederatedConfig,
} from './config/public_api';
import { DaffSearchFederatedDriver } from './search.service';

Expand All @@ -25,37 +25,25 @@ import { DaffSearchFederatedDriver } from './search.service';
],
})
export class DaffSearchFederatedDriverModule {
static forRoot(config: DaffSearchFederatedDriverConfig = SEARCH_FEDERATED_CONFIG_DEFAULT): ModuleWithProviders<DaffSearchFederatedDriverModule> {
static forRoot(config: DaffSearchFederatedDriverConfig = DAFF_SEARCH_FEDERATED_CONFIG_DEFAULT): ModuleWithProviders<DaffSearchFederatedDriverModule> {
return {
ngModule: DaffSearchFederatedDriverModule,
providers: [
provideDaffSearchDriver(DaffSearchFederatedDriver),
{
provide: SEARCH_FEDERATED_CONFIG_TOKEN,
useValue: {
...SEARCH_FEDERATED_CONFIG_DEFAULT,
...config,
},
},
provideDaffSearchFederatedConfig(config),
],
};
}

static forFeature(config: DaffSearchFederatedDriverConfig = SEARCH_FEDERATED_CONFIG_DEFAULT): ModuleWithProviders<DaffSearchFederatedDriverModule> {
static forFeature(config: DaffSearchFederatedDriverConfig = DAFF_SEARCH_FEDERATED_CONFIG_DEFAULT): ModuleWithProviders<DaffSearchFederatedDriverModule> {
return {
ngModule: DaffSearchFederatedDriverModule,
providers: [
{
provide: DaffSearchDriver,
useClass: DaffSearchFederatedDriver,
},
{
provide: SEARCH_FEDERATED_CONFIG_TOKEN,
useValue: {
...SEARCH_FEDERATED_CONFIG_DEFAULT,
...config,
},
},
provideDaffSearchFederatedConfig(config),
],
};
}
Expand Down
4 changes: 2 additions & 2 deletions libs/search/driver/federated/src/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {

import {
DaffSearchFederatedDriverConfig,
SEARCH_FEDERATED_CONFIG_TOKEN,
DAFF_SEARCH_FEDERATED_CONFIG_TOKEN,
} from './config/public_api';
import { DAFF_SEARCH_FEDERATED_DRIVERS } from './injection-tokens/drivers.token';

Expand All @@ -33,7 +33,7 @@ import { DAFF_SEARCH_FEDERATED_DRIVERS } from './injection-tokens/drivers.token'
export class DaffSearchFederatedDriver implements DaffSearchDriverInterface {
constructor(
@Inject(DAFF_SEARCH_FEDERATED_DRIVERS) private drivers: DaffSearchDriverKindedInterface[],
@Inject(SEARCH_FEDERATED_CONFIG_TOKEN) private config: DaffSearchFederatedDriverConfig,
@Inject(DAFF_SEARCH_FEDERATED_CONFIG_TOKEN) private config: DaffSearchFederatedDriverConfig,
) {}

search(query: string, options: DaffSearchDriverOptions = {}): Observable<DaffSearchDriverResponse> {
Expand Down
Loading