@daffodil/customer 0.50.0 → 0.51.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/README.md +1 -1
- package/driver/errors/address-not-found.d.ts +10 -0
- package/driver/errors/codes.d.ts +6 -0
- package/driver/errors/default-billing-address-deletion.d.ts +10 -0
- package/driver/errors/default-shipping-address-deletion.d.ts +10 -0
- package/driver/errors/map.d.ts +6 -0
- package/driver/errors/public_api.d.ts +4 -0
- package/driver/in-memory/backend/address.service.d.ts +37 -0
- package/driver/in-memory/driver/address.service.d.ts +26 -0
- package/driver/in-memory/public_api.d.ts +2 -0
- package/driver/interfaces/address-service.interface.d.ts +33 -0
- package/driver/magento/address.service.d.ts +27 -0
- package/driver/magento/errors/map.d.ts +3 -0
- package/driver/magento/errors/transform.d.ts +9 -1
- package/driver/magento/models/requests/address-attribute-input.type.d.ts +4 -0
- package/driver/magento/models/requests/address-input.type.d.ts +22 -0
- package/driver/magento/models/requests/address-region-input.type.d.ts +8 -0
- package/driver/magento/models/requests/public_api.d.ts +3 -0
- package/driver/magento/models/responses/create-customer-address.type.d.ts +4 -0
- package/driver/magento/models/responses/customer-address.type.d.ts +4 -2
- package/driver/magento/models/responses/delete-customer-address.type.d.ts +3 -0
- package/driver/magento/models/responses/get-customer-addresses.type.d.ts +4 -0
- package/driver/magento/models/responses/public_api.d.ts +4 -0
- package/driver/magento/models/responses/update-customer-address.type.d.ts +4 -0
- package/driver/magento/queries/create-customer-address.d.ts +1 -0
- package/driver/magento/queries/delete-customer-address.d.ts +1 -0
- package/driver/magento/queries/get-customer-addresses.d.ts +2 -0
- package/driver/magento/queries/public_api.d.ts +4 -0
- package/driver/magento/queries/update-customer-address.d.ts +1 -0
- package/driver/magento/testing/factories/address.factory.d.ts +3 -1
- package/driver/magento/transforms/requests/address-input.d.ts +3 -0
- package/driver/magento/transforms/requests/public_api.d.ts +1 -0
- package/driver/magento/validators/create-customer-address.d.ts +3 -0
- package/driver/magento/validators/delete-customer-address.d.ts +3 -0
- package/driver/magento/validators/get-customer-addresses.d.ts +3 -0
- package/driver/magento/validators/public_api.d.ts +7 -0
- package/driver/magento/validators/update-customer-address.d.ts +3 -0
- package/driver/public_api.d.ts +1 -0
- package/driver/testing/drivers/address.service.d.ts +23 -0
- package/esm2020/driver/errors/address-not-found.mjs +13 -0
- package/esm2020/driver/errors/codes.mjs +11 -0
- package/esm2020/driver/errors/default-billing-address-deletion.mjs +13 -0
- package/esm2020/driver/errors/default-shipping-address-deletion.mjs +13 -0
- package/esm2020/driver/errors/map.mjs +7 -1
- package/esm2020/driver/errors/public_api.mjs +5 -1
- package/esm2020/driver/in-memory/backend/address.service.mjs +110 -0
- package/esm2020/driver/in-memory/driver/address.service.mjs +42 -0
- package/esm2020/driver/in-memory/driver/customer-driver.module.mjs +6 -2
- package/esm2020/driver/in-memory/public_api.mjs +3 -1
- package/esm2020/driver/interfaces/address-service.interface.mjs +6 -0
- package/esm2020/driver/magento/address.service.mjs +91 -0
- package/esm2020/driver/magento/customer-driver.module.mjs +13 -3
- package/esm2020/driver/magento/errors/map.mjs +6 -0
- package/esm2020/driver/magento/errors/transform.mjs +28 -4
- package/esm2020/driver/magento/models/requests/address-attribute-input.type.mjs +2 -0
- package/esm2020/driver/magento/models/requests/address-input.type.mjs +2 -0
- package/esm2020/driver/magento/models/requests/address-region-input.type.mjs +2 -0
- package/esm2020/driver/magento/models/requests/public_api.mjs +1 -1
- package/esm2020/driver/magento/models/responses/create-customer-address.type.mjs +2 -0
- package/esm2020/driver/magento/models/responses/customer-address.type.mjs +1 -1
- package/esm2020/driver/magento/models/responses/delete-customer-address.type.mjs +2 -0
- package/esm2020/driver/magento/models/responses/get-customer-addresses.type.mjs +2 -0
- package/esm2020/driver/magento/models/responses/public_api.mjs +1 -1
- package/esm2020/driver/magento/models/responses/update-customer-address.type.mjs +2 -0
- package/esm2020/driver/magento/queries/create-customer-address.mjs +11 -0
- package/esm2020/driver/magento/queries/delete-customer-address.mjs +7 -0
- package/esm2020/driver/magento/queries/fragments/customer-address.mjs +4 -2
- package/esm2020/driver/magento/queries/get-customer-addresses.mjs +14 -0
- package/esm2020/driver/magento/queries/public_api.mjs +5 -1
- package/esm2020/driver/magento/queries/update-customer-address.mjs +11 -0
- package/esm2020/driver/magento/testing/factories/address.factory.mjs +4 -2
- package/esm2020/driver/magento/transforms/requests/address-input.mjs +22 -0
- package/esm2020/driver/magento/transforms/requests/public_api.mjs +2 -1
- package/esm2020/driver/magento/transforms/responses/customer-address.mjs +6 -3
- package/esm2020/driver/magento/validators/create-customer-address.mjs +10 -0
- package/esm2020/driver/magento/validators/delete-customer-address.mjs +10 -0
- package/esm2020/driver/magento/validators/get-customer-addresses.mjs +10 -0
- package/esm2020/driver/magento/validators/public_api.mjs +8 -1
- package/esm2020/driver/magento/validators/update-customer-address.mjs +10 -0
- package/esm2020/driver/public_api.mjs +2 -1
- package/esm2020/driver/testing/drivers/address.service.mjs +40 -0
- package/esm2020/driver/testing/drivers/customer-driver.module.mjs +7 -2
- package/esm2020/models/address.type.mjs +1 -1
- package/esm2020/state/actions/address.actions.mjs +175 -0
- package/esm2020/state/actions/public_api.mjs +3 -0
- package/esm2020/state/customer.module.mjs +4 -1
- package/esm2020/state/effects/address.effects.mjs +45 -0
- package/esm2020/state/facades/address/facade.mjs +41 -0
- package/esm2020/state/facades/address/interface.mjs +2 -0
- package/esm2020/state/facades/public_api.mjs +2 -1
- package/esm2020/state/models/address.type.mjs +2 -0
- package/esm2020/state/models/public_api.mjs +2 -0
- package/esm2020/state/public_api.mjs +3 -2
- package/esm2020/state/reducers/address/initial-state.mjs +6 -0
- package/esm2020/state/reducers/address/public_api.mjs +3 -0
- package/esm2020/state/reducers/address/reducer.mjs +32 -0
- package/esm2020/state/reducers/address/type.mjs +2 -0
- package/esm2020/state/reducers/address-entities/adapter.mjs +10 -0
- package/esm2020/state/reducers/address-entities/public_api.mjs +3 -0
- package/esm2020/state/reducers/address-entities/reducer.mjs +43 -0
- package/esm2020/state/reducers/customer/adapter.mjs +15 -1
- package/esm2020/state/reducers/customer/reducer.mjs +20 -17
- package/esm2020/state/reducers/public_api.mjs +3 -1
- package/esm2020/state/reducers/reducers.interface.mjs +1 -1
- package/esm2020/state/reducers/token/reducers.token.mjs +5 -1
- package/esm2020/state/selectors/address/selector.mjs +23 -0
- package/esm2020/state/selectors/customer/selector.mjs +20 -0
- package/esm2020/state/selectors/feature.selector.mjs +1 -1
- package/esm2020/state/selectors/public_api.mjs +4 -2
- package/esm2020/testing/factories/customer-address.factory.mjs +3 -1
- package/fesm2015/daffodil-customer-driver-in-memory.mjs +145 -2
- package/fesm2015/daffodil-customer-driver-in-memory.mjs.map +1 -1
- package/fesm2015/daffodil-customer-driver-magento-testing.mjs +3 -1
- package/fesm2015/daffodil-customer-driver-magento-testing.mjs.map +1 -1
- package/fesm2015/daffodil-customer-driver-magento.mjs +227 -8
- package/fesm2015/daffodil-customer-driver-magento.mjs.map +1 -1
- package/fesm2015/daffodil-customer-driver-testing.mjs +40 -1
- package/fesm2015/daffodil-customer-driver-testing.mjs.map +1 -1
- package/fesm2015/daffodil-customer-driver.mjs +52 -1
- package/fesm2015/daffodil-customer-driver.mjs.map +1 -1
- package/fesm2015/daffodil-customer-state.mjs +378 -17
- package/fesm2015/daffodil-customer-state.mjs.map +1 -1
- package/fesm2015/daffodil-customer-testing.mjs +2 -0
- package/fesm2015/daffodil-customer-testing.mjs.map +1 -1
- package/fesm2020/daffodil-customer-driver-in-memory.mjs +148 -2
- package/fesm2020/daffodil-customer-driver-in-memory.mjs.map +1 -1
- package/fesm2020/daffodil-customer-driver-magento-testing.mjs +3 -1
- package/fesm2020/daffodil-customer-driver-magento-testing.mjs.map +1 -1
- package/fesm2020/daffodil-customer-driver-magento.mjs +223 -8
- package/fesm2020/daffodil-customer-driver-magento.mjs.map +1 -1
- package/fesm2020/daffodil-customer-driver-testing.mjs +40 -1
- package/fesm2020/daffodil-customer-driver-testing.mjs.map +1 -1
- package/fesm2020/daffodil-customer-driver.mjs +52 -1
- package/fesm2020/daffodil-customer-driver.mjs.map +1 -1
- package/fesm2020/daffodil-customer-state.mjs +387 -17
- package/fesm2020/daffodil-customer-state.mjs.map +1 -1
- package/fesm2020/daffodil-customer-testing.mjs +2 -0
- package/fesm2020/daffodil-customer-testing.mjs.map +1 -1
- package/models/address.type.d.ts +8 -0
- package/package.json +4 -4
- package/state/actions/address.actions.d.ts +166 -0
- package/state/actions/public_api.d.ts +2 -0
- package/state/effects/address.effects.d.ts +31 -0
- package/state/facades/address/facade.d.ts +28 -0
- package/state/facades/address/interface.d.ts +14 -0
- package/state/facades/public_api.d.ts +2 -0
- package/state/models/address.type.d.ts +3 -0
- package/state/models/public_api.d.ts +1 -0
- package/state/public_api.d.ts +2 -1
- package/state/reducers/address/initial-state.d.ts +5 -0
- package/state/reducers/address/public_api.d.ts +3 -0
- package/state/reducers/address/reducer.d.ts +7 -0
- package/state/reducers/address/type.d.ts +5 -0
- package/state/reducers/address-entities/adapter.d.ts +6 -0
- package/state/reducers/address-entities/public_api.d.ts +2 -0
- package/state/reducers/address-entities/reducer.d.ts +12 -0
- package/state/reducers/customer/adapter.d.ts +5 -0
- package/state/reducers/customer/reducer.d.ts +2 -2
- package/state/reducers/public_api.d.ts +2 -0
- package/state/reducers/reducers.interface.d.ts +9 -5
- package/state/reducers/token/extra.token.d.ts +1 -1
- package/state/reducers/token/reducers.token.d.ts +1 -1
- package/state/selectors/address/selector.d.ts +15 -0
- package/state/selectors/{customer.selector.d.ts → customer/selector.d.ts} +1 -1
- package/state/selectors/feature.selector.d.ts +4 -4
- package/state/selectors/public_api.d.ts +3 -1
- package/testing/factories/customer-address.factory.d.ts +2 -0
- package/esm2020/state/selectors/customer.selector.mjs +0 -20
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, Injectable, Inject, inject, NgModule } from '@angular/core';
|
|
3
|
-
import { daffCompleteOperation, daffOperationInitialState, daffClearErrors, daffOperationFailed, daffStartMutation, daffStartResolution, daffOperationStateSelectorFactory, daffComposeReducers } from '@daffodil/core/state';
|
|
3
|
+
import { daffCompleteOperation, daffOperationInitialState, daffClearErrors, daffOperationFailed, daffStartMutation, daffStartResolution, daffCreateOperationEntityStateAdapter, daffOperationStateSelectorFactory, daffComposeReducers } from '@daffodil/core/state';
|
|
4
|
+
import { createEntityAdapter } from '@ngrx/entity';
|
|
4
5
|
import * as i1 from '@ngrx/store';
|
|
5
6
|
import { createFeatureSelector, createSelector, select, combineReducers, StoreModule } from '@ngrx/store';
|
|
6
7
|
import * as i1$1 from '@ngrx/effects';
|
|
@@ -8,7 +9,182 @@ import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
|
|
|
8
9
|
import { of } from 'rxjs';
|
|
9
10
|
import { switchMap, map, catchError } from 'rxjs/operators';
|
|
10
11
|
import { DAFF_CUSTOMER_ERROR_MATCHER } from '@daffodil/customer';
|
|
11
|
-
import { DaffCustomerDriver } from '@daffodil/customer/driver';
|
|
12
|
+
import { DaffCustomerAddressDriver, DaffCustomerDriver } from '@daffodil/customer/driver';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The customer address action types enum.
|
|
16
|
+
*/
|
|
17
|
+
var DaffCustomerAddressActionTypes;
|
|
18
|
+
(function (DaffCustomerAddressActionTypes) {
|
|
19
|
+
DaffCustomerAddressActionTypes["AddressListAction"] = "[@daffodil/customer] Address List Action";
|
|
20
|
+
DaffCustomerAddressActionTypes["AddressListSuccessAction"] = "[@daffodil/customer] Address List Success Action";
|
|
21
|
+
DaffCustomerAddressActionTypes["AddressListFailureAction"] = "[@daffodil/customer] Address List Failure Action";
|
|
22
|
+
DaffCustomerAddressActionTypes["AddressLoadAction"] = "[@daffodil/customer] Address Load Action";
|
|
23
|
+
DaffCustomerAddressActionTypes["AddressLoadSuccessAction"] = "[@daffodil/customer] Address Load Success Action";
|
|
24
|
+
DaffCustomerAddressActionTypes["AddressLoadFailureAction"] = "[@daffodil/customer] Address Load Failure Action";
|
|
25
|
+
DaffCustomerAddressActionTypes["AddressAddAction"] = "[@daffodil/customer] Address Add Action";
|
|
26
|
+
DaffCustomerAddressActionTypes["AddressAddSuccessAction"] = "[@daffodil/customer] Address Add Success Action";
|
|
27
|
+
DaffCustomerAddressActionTypes["AddressAddFailureAction"] = "[@daffodil/customer] Address Add Failure Action";
|
|
28
|
+
DaffCustomerAddressActionTypes["AddressUpdateAction"] = "[@daffodil/customer] Address Update Action";
|
|
29
|
+
DaffCustomerAddressActionTypes["AddressUpdateSuccessAction"] = "[@daffodil/customer] Address Update Success Action";
|
|
30
|
+
DaffCustomerAddressActionTypes["AddressUpdateFailureAction"] = "[@daffodil/customer] Address Update Failure Action";
|
|
31
|
+
DaffCustomerAddressActionTypes["AddressDeleteAction"] = "[@daffodil/customer] Address Delete Action";
|
|
32
|
+
DaffCustomerAddressActionTypes["AddressDeleteSuccessAction"] = "[@daffodil/customer] Address Delete Success Action";
|
|
33
|
+
DaffCustomerAddressActionTypes["AddressDeleteFailureAction"] = "[@daffodil/customer] Address Delete Failure Action";
|
|
34
|
+
})(DaffCustomerAddressActionTypes || (DaffCustomerAddressActionTypes = {}));
|
|
35
|
+
/**
|
|
36
|
+
* Lists the addresses of the current customer.
|
|
37
|
+
*
|
|
38
|
+
* @param addressId The ID of the address.
|
|
39
|
+
*/
|
|
40
|
+
class DaffCustomerAddressList {
|
|
41
|
+
constructor() {
|
|
42
|
+
this.type = DaffCustomerAddressActionTypes.AddressListAction;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Indicates a successful listing of customer addresses.
|
|
47
|
+
*/
|
|
48
|
+
class DaffCustomerAddressListSuccess {
|
|
49
|
+
constructor(payload) {
|
|
50
|
+
this.payload = payload;
|
|
51
|
+
this.type = DaffCustomerAddressActionTypes.AddressListSuccessAction;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A failed customer address list with the error message.
|
|
56
|
+
*/
|
|
57
|
+
class DaffCustomerAddressListFailure {
|
|
58
|
+
constructor(payload) {
|
|
59
|
+
this.payload = payload;
|
|
60
|
+
this.type = DaffCustomerAddressActionTypes.AddressListFailureAction;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Loads an address of the current customer.
|
|
65
|
+
*
|
|
66
|
+
* @param addressId The ID of the address.
|
|
67
|
+
*/
|
|
68
|
+
class DaffCustomerAddressLoad {
|
|
69
|
+
constructor(addressId) {
|
|
70
|
+
this.addressId = addressId;
|
|
71
|
+
this.type = DaffCustomerAddressActionTypes.AddressLoadAction;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Indicates a successful load of a customer address.
|
|
76
|
+
*/
|
|
77
|
+
class DaffCustomerAddressLoadSuccess {
|
|
78
|
+
constructor(payload) {
|
|
79
|
+
this.payload = payload;
|
|
80
|
+
this.type = DaffCustomerAddressActionTypes.AddressLoadSuccessAction;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A failed customer address load with the error message.
|
|
85
|
+
*/
|
|
86
|
+
class DaffCustomerAddressLoadFailure {
|
|
87
|
+
constructor(payload, id) {
|
|
88
|
+
this.payload = payload;
|
|
89
|
+
this.id = id;
|
|
90
|
+
this.type = DaffCustomerAddressActionTypes.AddressLoadFailureAction;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Updates one of the currently logged-in customer's addresses.
|
|
95
|
+
*
|
|
96
|
+
* @param query The customer query.
|
|
97
|
+
*/
|
|
98
|
+
class DaffCustomerAddressUpdate {
|
|
99
|
+
constructor(address) {
|
|
100
|
+
this.address = address;
|
|
101
|
+
this.type = DaffCustomerAddressActionTypes.AddressUpdateAction;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Indicates a successful update of one of the currently logged-in customer's addresses.
|
|
106
|
+
*/
|
|
107
|
+
class DaffCustomerAddressUpdateSuccess {
|
|
108
|
+
constructor(payload) {
|
|
109
|
+
this.payload = payload;
|
|
110
|
+
this.type = DaffCustomerAddressActionTypes.AddressUpdateSuccessAction;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A failed address update with the error message.
|
|
115
|
+
*/
|
|
116
|
+
class DaffCustomerAddressUpdateFailure {
|
|
117
|
+
constructor(payload, id) {
|
|
118
|
+
this.payload = payload;
|
|
119
|
+
this.id = id;
|
|
120
|
+
this.type = DaffCustomerAddressActionTypes.AddressUpdateFailureAction;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Adds one of the currently logged-in customer's addresses.
|
|
125
|
+
*
|
|
126
|
+
* @param query The customer query.
|
|
127
|
+
*/
|
|
128
|
+
class DaffCustomerAddressAdd {
|
|
129
|
+
constructor(address, placeholderId) {
|
|
130
|
+
this.address = address;
|
|
131
|
+
this.placeholderId = placeholderId;
|
|
132
|
+
this.type = DaffCustomerAddressActionTypes.AddressAddAction;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Indicates a successful addition of one of the currently logged-in customer's addresses.
|
|
137
|
+
*
|
|
138
|
+
* @param payload The updated list of customer addresses.
|
|
139
|
+
*/
|
|
140
|
+
class DaffCustomerAddressAddSuccess {
|
|
141
|
+
constructor(payload) {
|
|
142
|
+
this.payload = payload;
|
|
143
|
+
this.type = DaffCustomerAddressActionTypes.AddressAddSuccessAction;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A failed address addition with the error message.
|
|
148
|
+
*/
|
|
149
|
+
class DaffCustomerAddressAddFailure {
|
|
150
|
+
constructor(payload, id) {
|
|
151
|
+
this.payload = payload;
|
|
152
|
+
this.id = id;
|
|
153
|
+
this.type = DaffCustomerAddressActionTypes.AddressAddFailureAction;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Deletes one of the currently logged-in customer's addresses.
|
|
158
|
+
*
|
|
159
|
+
* @param addressId The ID of the address.
|
|
160
|
+
*/
|
|
161
|
+
class DaffCustomerAddressDelete {
|
|
162
|
+
constructor(addressId) {
|
|
163
|
+
this.addressId = addressId;
|
|
164
|
+
this.type = DaffCustomerAddressActionTypes.AddressDeleteAction;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Indicates a successful deletion of one of the currently logged-in customer's addresses.
|
|
169
|
+
*
|
|
170
|
+
* @param payload The updated list of customer addresses.
|
|
171
|
+
*/
|
|
172
|
+
class DaffCustomerAddressDeleteSuccess {
|
|
173
|
+
constructor(payload) {
|
|
174
|
+
this.payload = payload;
|
|
175
|
+
this.type = DaffCustomerAddressActionTypes.AddressDeleteSuccessAction;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* A failed address deletion with the error message.
|
|
180
|
+
*/
|
|
181
|
+
class DaffCustomerAddressDeleteFailure {
|
|
182
|
+
constructor(payload, id) {
|
|
183
|
+
this.payload = payload;
|
|
184
|
+
this.id = id;
|
|
185
|
+
this.type = DaffCustomerAddressActionTypes.AddressDeleteFailureAction;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
12
188
|
|
|
13
189
|
/**
|
|
14
190
|
* The customer action types enum.
|
|
@@ -199,6 +375,20 @@ function daffCustomerStateStoreCustomer(customer, state) {
|
|
|
199
375
|
customer,
|
|
200
376
|
};
|
|
201
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* Stores customer addresses.
|
|
380
|
+
* Sets loading to false and resets errors.
|
|
381
|
+
*/
|
|
382
|
+
function daffCustomerStateStoreAddresses(addresses, state) {
|
|
383
|
+
return {
|
|
384
|
+
...state,
|
|
385
|
+
...daffCompleteOperation(state),
|
|
386
|
+
customer: {
|
|
387
|
+
...state.customer,
|
|
388
|
+
addresses,
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
}
|
|
202
392
|
|
|
203
393
|
/**
|
|
204
394
|
* The initial state for the main customer state, see {@link DaffCustomerReducerState}.
|
|
@@ -212,31 +402,116 @@ const daffCustomerInitialState = {
|
|
|
212
402
|
* The reducer for the customer page state, see {@link DaffCustomerReducerState}.
|
|
213
403
|
*/
|
|
214
404
|
const daffCustomerReducer = (state = daffCustomerInitialState, action) => {
|
|
215
|
-
switch (
|
|
216
|
-
case
|
|
405
|
+
switch (action.type) {
|
|
406
|
+
case DaffCustomerActionTypes.CustomerLoadAction:
|
|
217
407
|
return daffStartResolution(state);
|
|
218
|
-
case
|
|
219
|
-
case
|
|
220
|
-
case
|
|
408
|
+
case DaffCustomerActionTypes.CustomerUpdateAction:
|
|
409
|
+
case DaffCustomerActionTypes.CustomerChangeEmailAction:
|
|
410
|
+
case DaffCustomerActionTypes.CustomerChangePasswordAction:
|
|
221
411
|
return daffStartMutation(state);
|
|
222
|
-
case
|
|
223
|
-
case
|
|
224
|
-
case
|
|
412
|
+
case DaffCustomerActionTypes.CustomerLoadSuccessAction:
|
|
413
|
+
case DaffCustomerActionTypes.CustomerUpdateSuccessAction:
|
|
414
|
+
case DaffCustomerActionTypes.CustomerChangeEmailSuccessAction:
|
|
225
415
|
return daffCustomerStateStoreCustomer(action.payload, state);
|
|
226
|
-
case
|
|
416
|
+
case DaffCustomerActionTypes.CustomerChangePasswordSuccessAction:
|
|
227
417
|
return daffCompleteOperation(state);
|
|
228
|
-
case
|
|
229
|
-
case
|
|
230
|
-
case
|
|
231
|
-
case
|
|
418
|
+
case DaffCustomerActionTypes.CustomerLoadFailureAction:
|
|
419
|
+
case DaffCustomerActionTypes.CustomerUpdateFailureAction:
|
|
420
|
+
case DaffCustomerActionTypes.CustomerChangeEmailFailureAction:
|
|
421
|
+
case DaffCustomerActionTypes.CustomerChangePasswordFailureAction:
|
|
232
422
|
return daffOperationFailed([action.payload], state);
|
|
233
|
-
case
|
|
423
|
+
case DaffCustomerActionTypes.CustomerClearErrorsAction:
|
|
234
424
|
return daffClearErrors(state);
|
|
425
|
+
case DaffCustomerAddressActionTypes.AddressDeleteSuccessAction:
|
|
426
|
+
case DaffCustomerAddressActionTypes.AddressAddSuccessAction:
|
|
427
|
+
return daffCustomerStateStoreAddresses(action.payload, state);
|
|
235
428
|
default:
|
|
236
429
|
return state;
|
|
237
430
|
}
|
|
238
431
|
};
|
|
239
432
|
|
|
433
|
+
/**
|
|
434
|
+
* The initial state for the main customer state, see {@link DaffCustomerAddressReducerState}.
|
|
435
|
+
*/
|
|
436
|
+
const daffCustomerAddressInitialState = daffOperationInitialState;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* The reducer for the customer page state, see {@link DaffCustomerAddressReducerState}.
|
|
440
|
+
*/
|
|
441
|
+
const daffCustomerAddressReducer = (state = daffCustomerAddressInitialState, action) => {
|
|
442
|
+
switch (true) {
|
|
443
|
+
case action.type === DaffCustomerAddressActionTypes.AddressListAction:
|
|
444
|
+
case action.type === DaffCustomerAddressActionTypes.AddressLoadAction:
|
|
445
|
+
return daffStartResolution(state);
|
|
446
|
+
case action.type === DaffCustomerAddressActionTypes.AddressUpdateAction:
|
|
447
|
+
case action.type === DaffCustomerAddressActionTypes.AddressAddAction:
|
|
448
|
+
case action.type === DaffCustomerAddressActionTypes.AddressDeleteAction:
|
|
449
|
+
return daffStartMutation(state);
|
|
450
|
+
case action.type === DaffCustomerAddressActionTypes.AddressListSuccessAction:
|
|
451
|
+
case action.type === DaffCustomerAddressActionTypes.AddressLoadSuccessAction:
|
|
452
|
+
case action.type === DaffCustomerAddressActionTypes.AddressUpdateSuccessAction:
|
|
453
|
+
case action.type === DaffCustomerAddressActionTypes.AddressAddSuccessAction:
|
|
454
|
+
case action.type === DaffCustomerAddressActionTypes.AddressDeleteSuccessAction:
|
|
455
|
+
return daffCompleteOperation(state);
|
|
456
|
+
case action.type === DaffCustomerAddressActionTypes.AddressListFailureAction:
|
|
457
|
+
case action.type === DaffCustomerAddressActionTypes.AddressLoadFailureAction:
|
|
458
|
+
case action.type === DaffCustomerAddressActionTypes.AddressUpdateFailureAction:
|
|
459
|
+
case action.type === DaffCustomerAddressActionTypes.AddressAddFailureAction:
|
|
460
|
+
case action.type === DaffCustomerAddressActionTypes.AddressDeleteFailureAction:
|
|
461
|
+
return daffOperationFailed([action.payload], state);
|
|
462
|
+
default:
|
|
463
|
+
return state;
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Customer Address Entities Adapter for changing/overwriting entity state.
|
|
469
|
+
*/
|
|
470
|
+
const daffCustomerAddressEntitiesAdapter = (() => {
|
|
471
|
+
let cache;
|
|
472
|
+
return () => cache = cache || daffCreateOperationEntityStateAdapter(createEntityAdapter({ selectId: item => item.id }));
|
|
473
|
+
})();
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Reducer function that catches actions and changes/overwrites product entities state.
|
|
477
|
+
*
|
|
478
|
+
* @param state current State of the redux store
|
|
479
|
+
* @param action CartItemGrid, BestSellers, or CartItem actions
|
|
480
|
+
* @returns CartItem entities state
|
|
481
|
+
*/
|
|
482
|
+
function daffCustomerAddressEntitiesReducer(state = daffCustomerAddressEntitiesAdapter().getInitialState(), action) {
|
|
483
|
+
const adapter = daffCustomerAddressEntitiesAdapter();
|
|
484
|
+
switch (action.type) {
|
|
485
|
+
case DaffCustomerAddressActionTypes.AddressLoadAction:
|
|
486
|
+
return adapter.preload(action.addressId, state);
|
|
487
|
+
case DaffCustomerAddressActionTypes.AddressAddAction:
|
|
488
|
+
return adapter.preadd(action.address, state, action.placeholderId);
|
|
489
|
+
case DaffCustomerAddressActionTypes.AddressDeleteAction:
|
|
490
|
+
return adapter.preremove(action.addressId, state);
|
|
491
|
+
case DaffCustomerAddressActionTypes.AddressUpdateAction:
|
|
492
|
+
return adapter.preupdate(action.address, state);
|
|
493
|
+
case DaffCustomerAddressActionTypes.AddressLoadSuccessAction:
|
|
494
|
+
return adapter.load(action.payload, state);
|
|
495
|
+
case DaffCustomerAddressActionTypes.AddressListSuccessAction:
|
|
496
|
+
return adapter.list(action.payload, state);
|
|
497
|
+
case DaffCustomerActionTypes.CustomerChangeEmailSuccessAction:
|
|
498
|
+
case DaffCustomerActionTypes.CustomerUpdateSuccessAction:
|
|
499
|
+
case DaffCustomerActionTypes.CustomerLoadSuccessAction:
|
|
500
|
+
return adapter.list(action.payload.addresses, state);
|
|
501
|
+
case DaffCustomerAddressActionTypes.AddressUpdateSuccessAction:
|
|
502
|
+
case DaffCustomerAddressActionTypes.AddressDeleteSuccessAction:
|
|
503
|
+
case DaffCustomerAddressActionTypes.AddressAddSuccessAction:
|
|
504
|
+
return adapter.list(action.payload, state);
|
|
505
|
+
case DaffCustomerAddressActionTypes.AddressDeleteFailureAction:
|
|
506
|
+
case DaffCustomerAddressActionTypes.AddressAddFailureAction:
|
|
507
|
+
case DaffCustomerAddressActionTypes.AddressLoadFailureAction:
|
|
508
|
+
case DaffCustomerAddressActionTypes.AddressUpdateFailureAction:
|
|
509
|
+
return adapter.operationFailed(action.id, [action.payload], state);
|
|
510
|
+
default:
|
|
511
|
+
return state;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
240
515
|
const getDaffCustomerReducersStateSelector = (() => {
|
|
241
516
|
let cache;
|
|
242
517
|
return () => cache = cache || {
|
|
@@ -261,6 +536,25 @@ const daffCustomerGetSelectors = (() => {
|
|
|
261
536
|
return () => cache = cache || daffCustomerCreateSelectors();
|
|
262
537
|
})();
|
|
263
538
|
|
|
539
|
+
/**
|
|
540
|
+
* Creates a group of selectors for {@link DaffCustomerAddressReducerState} that use the passed state selector as the basis.
|
|
541
|
+
*/
|
|
542
|
+
const daffCustomerAddressCreateSelectors = () => {
|
|
543
|
+
const { selectCustomerFeatureState } = getDaffCustomerReducersStateSelector();
|
|
544
|
+
const selectCustomerAddressState = createSelector(selectCustomerFeatureState, state => state.address);
|
|
545
|
+
const selectCustomerAddressEntitiesState = createSelector(selectCustomerFeatureState, state => state.addressEntities);
|
|
546
|
+
const { selectEntity, selectOptimisticList, } = daffCustomerAddressEntitiesAdapter().getSelectors(selectCustomerAddressEntitiesState);
|
|
547
|
+
return {
|
|
548
|
+
...daffOperationStateSelectorFactory(selectCustomerAddressState),
|
|
549
|
+
selectAddress: selectEntity,
|
|
550
|
+
selectAddresses: selectOptimisticList,
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
const daffCustomerAddressGetSelectors = (() => {
|
|
554
|
+
let cache;
|
|
555
|
+
return () => cache = cache || daffCustomerAddressCreateSelectors();
|
|
556
|
+
})();
|
|
557
|
+
|
|
264
558
|
/**
|
|
265
559
|
* @inheritdoc
|
|
266
560
|
*
|
|
@@ -292,6 +586,78 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
292
586
|
}]
|
|
293
587
|
}], ctorParameters: function () { return [{ type: i1.Store }]; } });
|
|
294
588
|
|
|
589
|
+
// TODO: address entities?
|
|
590
|
+
/**
|
|
591
|
+
* @inheritdoc
|
|
592
|
+
*
|
|
593
|
+
* Serves as the base for a customer facade.
|
|
594
|
+
* Extend this class and pass in the selectors for the specific state you wish to target.
|
|
595
|
+
*/
|
|
596
|
+
class DaffCustomerAddressPageFacade {
|
|
597
|
+
constructor(store) {
|
|
598
|
+
this.store = store;
|
|
599
|
+
const { selectAddress, selectAddresses, selectErrors, selectHasErrors, selectLoading, selectLoadingState, selectMutating, selectResolving, } = daffCustomerAddressGetSelectors();
|
|
600
|
+
this._selectAddress = selectAddress;
|
|
601
|
+
this.addresses$ = this.store.pipe(select(selectAddresses));
|
|
602
|
+
this.loadingState$ = this.store.pipe(select(selectLoadingState));
|
|
603
|
+
this.loading$ = this.store.pipe(select(selectLoading));
|
|
604
|
+
this.resolving$ = this.store.pipe(select(selectResolving));
|
|
605
|
+
this.mutating$ = this.store.pipe(select(selectMutating));
|
|
606
|
+
this.errors$ = this.store.pipe(select(selectErrors));
|
|
607
|
+
this.hasErrors$ = this.store.pipe(select(selectHasErrors));
|
|
608
|
+
}
|
|
609
|
+
getAddress(id) {
|
|
610
|
+
return this.store.pipe(select(this._selectAddress(id)));
|
|
611
|
+
}
|
|
612
|
+
dispatch(action) {
|
|
613
|
+
this.store.dispatch(action);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
/** @nocollapse */ DaffCustomerAddressPageFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerAddressPageFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
617
|
+
/** @nocollapse */ DaffCustomerAddressPageFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerAddressPageFacade, providedIn: 'root' });
|
|
618
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerAddressPageFacade, decorators: [{
|
|
619
|
+
type: Injectable,
|
|
620
|
+
args: [{
|
|
621
|
+
providedIn: 'root',
|
|
622
|
+
}]
|
|
623
|
+
}], ctorParameters: function () { return [{ type: i1.Store }]; } });
|
|
624
|
+
|
|
625
|
+
class DaffCustomerAddressEffects {
|
|
626
|
+
constructor(actions$, driver, errorMatcher) {
|
|
627
|
+
this.actions$ = actions$;
|
|
628
|
+
this.driver = driver;
|
|
629
|
+
this.errorMatcher = errorMatcher;
|
|
630
|
+
this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCustomerAddressActionTypes.AddressListAction), switchMap((action) => this.driver.list().pipe(map(resp => new DaffCustomerAddressListSuccess(resp)), catchError((error) => of(new DaffCustomerAddressListFailure(this.errorMatcher(error))))))));
|
|
631
|
+
/**
|
|
632
|
+
* An effect for loading a customer address.
|
|
633
|
+
*/
|
|
634
|
+
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCustomerAddressActionTypes.AddressLoadAction), switchMap((action) => this.driver.get(action.addressId).pipe(map(resp => new DaffCustomerAddressLoadSuccess(resp)), catchError((error) => of(new DaffCustomerAddressLoadFailure(this.errorMatcher(error), action.addressId)))))));
|
|
635
|
+
/**
|
|
636
|
+
* An effect for updating a customer address.
|
|
637
|
+
*/
|
|
638
|
+
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCustomerAddressActionTypes.AddressUpdateAction), switchMap((action) => this.driver.update(action.address).pipe(map(resp => new DaffCustomerAddressUpdateSuccess(resp)), catchError((error) => of(new DaffCustomerAddressUpdateFailure(this.errorMatcher(error), action.address.id)))))));
|
|
639
|
+
/**
|
|
640
|
+
* An effect for adding a new customer address.
|
|
641
|
+
*/
|
|
642
|
+
this.add$ = createEffect(() => this.actions$.pipe(ofType(DaffCustomerAddressActionTypes.AddressAddAction), switchMap((action) => this.driver.add(action.address).pipe(map(resp => new DaffCustomerAddressAddSuccess(resp)), catchError((error) => of(new DaffCustomerAddressAddFailure(this.errorMatcher(error), action.placeholderId)))))));
|
|
643
|
+
/**
|
|
644
|
+
* An effect for adding a new customer address.
|
|
645
|
+
*/
|
|
646
|
+
this.delete$ = createEffect(() => this.actions$.pipe(ofType(DaffCustomerAddressActionTypes.AddressDeleteAction), switchMap((action) => this.driver.delete(action.addressId).pipe(map(resp => new DaffCustomerAddressDeleteSuccess(resp)), catchError((error) => of(new DaffCustomerAddressDeleteFailure(this.errorMatcher(error), action.addressId)))))));
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
/** @nocollapse */ DaffCustomerAddressEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerAddressEffects, deps: [{ token: i1$1.Actions }, { token: DaffCustomerAddressDriver }, { token: DAFF_CUSTOMER_ERROR_MATCHER }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
650
|
+
/** @nocollapse */ DaffCustomerAddressEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerAddressEffects });
|
|
651
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerAddressEffects, decorators: [{
|
|
652
|
+
type: Injectable
|
|
653
|
+
}], ctorParameters: function () { return [{ type: i1$1.Actions }, { type: undefined, decorators: [{
|
|
654
|
+
type: Inject,
|
|
655
|
+
args: [DaffCustomerAddressDriver]
|
|
656
|
+
}] }, { type: undefined, decorators: [{
|
|
657
|
+
type: Inject,
|
|
658
|
+
args: [DAFF_CUSTOMER_ERROR_MATCHER]
|
|
659
|
+
}] }]; } });
|
|
660
|
+
|
|
295
661
|
class DaffCustomerEffects {
|
|
296
662
|
constructor(actions$, driver, errorMatcher) {
|
|
297
663
|
this.actions$ = actions$;
|
|
@@ -338,6 +704,8 @@ const DAFF_CUSTOMER_REDUCERS = new InjectionToken('DAFF_CUSTOMER_REDUCERS', {
|
|
|
338
704
|
factory: () => daffComposeReducers([
|
|
339
705
|
combineReducers({
|
|
340
706
|
customer: daffCustomerReducer,
|
|
707
|
+
address: daffCustomerAddressReducer,
|
|
708
|
+
addressEntities: daffCustomerAddressEntitiesReducer,
|
|
341
709
|
}),
|
|
342
710
|
...inject(DAFF_CUSTOMER_EXTRA_REDUCERS),
|
|
343
711
|
]),
|
|
@@ -354,6 +722,7 @@ class DaffCustomerStateModule {
|
|
|
354
722
|
StoreModule.forFeature(DAFF_CUSTOMER_STORE_FEATURE_KEY, DAFF_CUSTOMER_REDUCERS),
|
|
355
723
|
EffectsModule.forFeature([
|
|
356
724
|
DaffCustomerEffects,
|
|
725
|
+
DaffCustomerAddressEffects,
|
|
357
726
|
]),
|
|
358
727
|
]] });
|
|
359
728
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerStateModule, decorators: [{
|
|
@@ -363,6 +732,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
363
732
|
StoreModule.forFeature(DAFF_CUSTOMER_STORE_FEATURE_KEY, DAFF_CUSTOMER_REDUCERS),
|
|
364
733
|
EffectsModule.forFeature([
|
|
365
734
|
DaffCustomerEffects,
|
|
735
|
+
DaffCustomerAddressEffects,
|
|
366
736
|
]),
|
|
367
737
|
],
|
|
368
738
|
}]
|
|
@@ -372,5 +742,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
372
742
|
* Generated bundle index. Do not edit.
|
|
373
743
|
*/
|
|
374
744
|
|
|
375
|
-
export { DAFF_CUSTOMER_EXTRA_REDUCERS, DAFF_CUSTOMER_STORE_FEATURE_KEY, DaffCustomerActionTypes, DaffCustomerChangeEmail, DaffCustomerChangeEmailFailure, DaffCustomerChangeEmailSuccess, DaffCustomerChangePassword, DaffCustomerChangePasswordFailure, DaffCustomerChangePasswordSuccess, DaffCustomerClearErrors, DaffCustomerLoad, DaffCustomerLoadFailure, DaffCustomerLoadSuccess, DaffCustomerPageFacade, DaffCustomerStateModule, DaffCustomerUpdate, DaffCustomerUpdateFailure, DaffCustomerUpdateSuccess, daffCustomerGetSelectors, daffCustomerInitialState, daffCustomerProvideExtraReducers, daffCustomerReducer, daffCustomerStateStoreCustomer };
|
|
745
|
+
export { DAFF_CUSTOMER_EXTRA_REDUCERS, DAFF_CUSTOMER_STORE_FEATURE_KEY, DaffCustomerActionTypes, DaffCustomerAddressActionTypes, DaffCustomerAddressAdd, DaffCustomerAddressAddFailure, DaffCustomerAddressAddSuccess, DaffCustomerAddressDelete, DaffCustomerAddressDeleteFailure, DaffCustomerAddressDeleteSuccess, DaffCustomerAddressList, DaffCustomerAddressListFailure, DaffCustomerAddressListSuccess, DaffCustomerAddressLoad, DaffCustomerAddressLoadFailure, DaffCustomerAddressLoadSuccess, DaffCustomerAddressPageFacade, DaffCustomerAddressUpdate, DaffCustomerAddressUpdateFailure, DaffCustomerAddressUpdateSuccess, DaffCustomerChangeEmail, DaffCustomerChangeEmailFailure, DaffCustomerChangeEmailSuccess, DaffCustomerChangePassword, DaffCustomerChangePasswordFailure, DaffCustomerChangePasswordSuccess, DaffCustomerClearErrors, DaffCustomerLoad, DaffCustomerLoadFailure, DaffCustomerLoadSuccess, DaffCustomerPageFacade, DaffCustomerStateModule, DaffCustomerUpdate, DaffCustomerUpdateFailure, DaffCustomerUpdateSuccess, daffCustomerAddressEntitiesAdapter, daffCustomerAddressEntitiesReducer, daffCustomerAddressGetSelectors, daffCustomerAddressInitialState, daffCustomerAddressReducer, daffCustomerGetSelectors, daffCustomerInitialState, daffCustomerProvideExtraReducers, daffCustomerReducer, daffCustomerStateStoreCustomer, getDaffCustomerReducersStateSelector };
|
|
376
746
|
//# sourceMappingURL=daffodil-customer-state.mjs.map
|