-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(driver,customer-order)!: add Magento 2.4.6 support (#2896)
BREAKING CHANGE: `@daffodil/customer/driver/magento` has been renamed to `@daffodil/customer/driver/magento/2-4-5`
- Loading branch information
Showing
123 changed files
with
1,631 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"$schema": "../../../../../node_modules/ng-packagr/ng-entrypoint.schema.json", | ||
"lib": { | ||
"entryFile": "src/index.ts" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ion-tokens/transforms/extra.token.spec.ts → ...ion-tokens/transforms/extra.token.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
...to/src/transforms/responses/order.spec.ts → ...-5/src/transforms/responses/order.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...sting/src/factories/order.factory.spec.ts → ...sting/src/factories/order.factory.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ting/src/factories/orders.factory.spec.ts → ...ting/src/factories/orders.factory.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"$schema": "../../../../../node_modules/ng-packagr/ng-entrypoint.schema.json", | ||
"lib": { | ||
"entryFile": "src/index.ts" | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
libs/customer-order/driver/magento/2-4-6/src/constants/sort/fields.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { DaffSortOptions } from '@daffodil/core'; | ||
|
||
import { MagentoCustomerOrderSortableField } from '../../models/public_api'; | ||
|
||
export const magentoCustomerOrderSortFields: DaffSortOptions = { | ||
options: [ | ||
{ | ||
label: 'Date', | ||
value: MagentoCustomerOrderSortableField.CREATED_AT, | ||
}, | ||
{ | ||
label: 'Number', | ||
value: MagentoCustomerOrderSortableField.NUMBER, | ||
}, | ||
], | ||
default: MagentoCustomerOrderSortableField.CREATED_AT, | ||
}; |
30 changes: 30 additions & 0 deletions
30
libs/customer-order/driver/magento/2-4-6/src/driver.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { | ||
NgModule, | ||
ModuleWithProviders, | ||
} from '@angular/core'; | ||
|
||
import { DaffOrderDriver } from '@daffodil/order/driver'; | ||
|
||
import { DaffCustomerOrderMagentoService } from './order.service'; | ||
import { MagentoCustomerOrderCollectionTransformer } from './transforms/public_api'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
], | ||
}) | ||
export class DaffCustomerOrderMagentoDriverModule { | ||
static forRoot(): ModuleWithProviders<DaffCustomerOrderMagentoDriverModule> { | ||
return { | ||
ngModule: DaffCustomerOrderMagentoDriverModule, | ||
providers: [ | ||
MagentoCustomerOrderCollectionTransformer, | ||
{ | ||
provide: DaffOrderDriver, | ||
useExisting: DaffCustomerOrderMagentoService, | ||
}, | ||
], | ||
}; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
libs/customer-order/driver/magento/2-4-6/src/errors/public_api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { transformMagentoReviewsError } from './transform'; |
6 changes: 6 additions & 0 deletions
6
libs/customer-order/driver/magento/2-4-6/src/errors/transform.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { DaffCustomerInvalidAPIResponseError } from '@daffodil/customer-order/driver'; | ||
import { daffTransformMagentoError } from '@daffodil/driver/magento'; | ||
|
||
export function transformMagentoReviewsError(error: any) { | ||
return daffTransformMagentoError(error, {}) || new DaffCustomerInvalidAPIResponseError(error.message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './public_api'; |
42 changes: 42 additions & 0 deletions
42
libs/customer-order/driver/magento/2-4-6/src/injection-tokens/fragments/order.token.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { gql } from 'apollo-angular'; | ||
import { DocumentNode } from 'graphql'; | ||
|
||
import { | ||
daffProvideCustomerOrderMagentoExtraOrderFragments, | ||
DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS, | ||
} from './order.token'; | ||
|
||
describe('@daffodil/customer-order/driver/magento/2-4-6 | daffProvideCustomerOrderMagentoExtraOrderFragments', () => { | ||
let fragments: DocumentNode[]; | ||
let result: DocumentNode[]; | ||
|
||
beforeEach(() => { | ||
fragments = [ | ||
gql` | ||
fragment one on Query { | ||
__typename | ||
} | ||
`, | ||
gql` | ||
fragment two on Query { | ||
__typename | ||
} | ||
`, | ||
]; | ||
|
||
TestBed.configureTestingModule({ | ||
providers: [ | ||
...daffProvideCustomerOrderMagentoExtraOrderFragments(...fragments), | ||
], | ||
}); | ||
|
||
result = TestBed.inject(DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS); | ||
}); | ||
|
||
it('should provide the fragments to the token', () => { | ||
fragments.forEach(fragment => { | ||
expect(result).toContain(fragment); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
libs/customer-order/driver/magento/2-4-6/src/injection-tokens/fragments/order.token.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { | ||
InjectionToken, | ||
Provider, | ||
} from '@angular/core'; | ||
import { DocumentNode } from 'graphql'; | ||
|
||
/** | ||
* A multi-provider injection token for providing extra GraphQL fragments that will be spread into order queries. | ||
* This can be used to retrieve additional data that is not covered by the standard Daffodil interfaces. | ||
* | ||
* Fragment structure is platform-specific and this feature should be used with care. | ||
* | ||
* This can increase query complexity above the Magento default of 300. | ||
* Daffodil only guarantees that stock queries don't exceed the limit of 300. | ||
* Apps using this token should therefore increase the query complexity limit | ||
* to accommodate the extra complexity contributed by the provided fragments. | ||
*/ | ||
export const DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS = new InjectionToken<DocumentNode[]>( | ||
'DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS', | ||
{ factory: () => []}, | ||
); | ||
|
||
/** | ||
* Provides extra GraphQL fragments for the Magento order driver. | ||
* | ||
* See {@link DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS}. | ||
* | ||
* ```ts | ||
* providers: [ | ||
* ...daffProvideCustomerOrderMagentoExtraOrderFragments( | ||
* myExtraOrderFragment | ||
* ) | ||
* ] | ||
* ``` | ||
*/ | ||
export function daffProvideCustomerOrderMagentoExtraOrderFragments(...fragments: DocumentNode[]): Provider[] { | ||
return fragments.map(fragment => ({ | ||
provide: DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS, | ||
useValue: fragment, | ||
multi: true, | ||
})); | ||
} |
9 changes: 9 additions & 0 deletions
9
libs/customer-order/driver/magento/2-4-6/src/injection-tokens/public_api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export { | ||
daffProvideCustomerOrderMagentoExtraOrderFragments, | ||
DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS, | ||
} from './fragments/order.token'; | ||
export { | ||
daffProvideCustomerOrderMagentoExtraOrderTransforms, | ||
DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS, | ||
} from './transforms/extra.token'; | ||
export { DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM } from './transforms/token'; |
34 changes: 34 additions & 0 deletions
34
libs/customer-order/driver/magento/2-4-6/src/injection-tokens/transforms/extra.token.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { DaffMagentoCustomerOrderExtraTransform } from '@daffodil/customer-order/driver/magento/2-4-6'; | ||
|
||
import { | ||
daffProvideCustomerOrderMagentoExtraOrderTransforms, | ||
DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS, | ||
} from './extra.token'; | ||
|
||
describe('@daffodil/customer-order/driver/magento/2-4-6 | daffProvideCustomerOrderMagentoExtraOrderTransforms', () => { | ||
let transforms: DaffMagentoCustomerOrderExtraTransform[]; | ||
let result: DaffMagentoCustomerOrderExtraTransform[]; | ||
|
||
beforeEach(() => { | ||
transforms = [ | ||
() => null, | ||
() => null, | ||
]; | ||
|
||
TestBed.configureTestingModule({ | ||
providers: [ | ||
...daffProvideCustomerOrderMagentoExtraOrderTransforms(...transforms), | ||
], | ||
}); | ||
|
||
result = TestBed.inject(DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS); | ||
}); | ||
|
||
it('should provide the transforms to the token', () => { | ||
transforms.forEach(fragment => { | ||
expect(result).toContain(fragment); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
libs/customer-order/driver/magento/2-4-6/src/injection-tokens/transforms/extra.token.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { | ||
InjectionToken, | ||
Provider, | ||
} from '@angular/core'; | ||
|
||
// workaround https://github.com/graycoreio/daffodil/issues/1667 | ||
import { DaffOrder } from '@daffodil/order'; | ||
|
||
import { DaffMagentoCustomerOrderExtraTransform } from '../../interfaces/public_api'; | ||
import { MagentoCustomerOrder } from '../../models/public_api'; | ||
|
||
/** | ||
* A multi-provider injection token for providing extra transform logic in the Order Magento driver. | ||
* It is run after the standard transforms for each customer order preview and passed both the current transformed Daffodil customer order and the Magento customer order. | ||
* | ||
* See {@link MagentoCustomerOrder} for more info. | ||
*/ | ||
export const DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS = new InjectionToken<DaffMagentoCustomerOrderExtraTransform[]>( | ||
'DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS', | ||
{ factory: () => []}, | ||
); | ||
|
||
/** | ||
* Provides extra customer order preview transforms for the Magento customer order driver. | ||
* | ||
* See {@link DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS}. | ||
* | ||
* ```ts | ||
* providers: [ | ||
* ...daffProvideCustomerOrderMagentoExtraOrderTransforms( | ||
* myExtraOrderTransform | ||
* ) | ||
* ] | ||
* ``` | ||
*/ | ||
export function daffProvideCustomerOrderMagentoExtraOrderTransforms<T extends MagentoCustomerOrder = MagentoCustomerOrder, V extends DaffOrder = DaffOrder>(...transforms: DaffMagentoCustomerOrderExtraTransform<T, V>[]): Provider[] { | ||
return transforms.map(transform => ({ | ||
provide: DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS, | ||
useValue: transform, | ||
multi: true, | ||
})); | ||
} |
Oops, something went wrong.