@daffodil/customer 0.50.0 → 0.51.1

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.
Files changed (183) hide show
  1. package/README.md +1 -1
  2. package/driver/errors/address-not-found.d.ts +10 -0
  3. package/driver/errors/codes.d.ts +6 -0
  4. package/driver/errors/default-billing-address-deletion.d.ts +10 -0
  5. package/driver/errors/default-shipping-address-deletion.d.ts +10 -0
  6. package/driver/errors/map.d.ts +6 -0
  7. package/driver/errors/public_api.d.ts +4 -0
  8. package/driver/in-memory/backend/address.service.d.ts +37 -0
  9. package/driver/in-memory/driver/address.service.d.ts +26 -0
  10. package/driver/in-memory/public_api.d.ts +2 -0
  11. package/driver/interfaces/address-service.interface.d.ts +33 -0
  12. package/driver/magento/address.service.d.ts +27 -0
  13. package/driver/magento/errors/map.d.ts +3 -0
  14. package/driver/magento/errors/transform.d.ts +9 -1
  15. package/driver/magento/models/requests/address-attribute-input.type.d.ts +4 -0
  16. package/driver/magento/models/requests/address-input.type.d.ts +22 -0
  17. package/driver/magento/models/requests/address-region-input.type.d.ts +8 -0
  18. package/driver/magento/models/requests/public_api.d.ts +3 -0
  19. package/driver/magento/models/responses/create-customer-address.type.d.ts +4 -0
  20. package/driver/magento/models/responses/customer-address.type.d.ts +4 -2
  21. package/driver/magento/models/responses/delete-customer-address.type.d.ts +3 -0
  22. package/driver/magento/models/responses/get-customer-addresses.type.d.ts +4 -0
  23. package/driver/magento/models/responses/public_api.d.ts +4 -0
  24. package/driver/magento/models/responses/update-customer-address.type.d.ts +4 -0
  25. package/driver/magento/queries/create-customer-address.d.ts +1 -0
  26. package/driver/magento/queries/delete-customer-address.d.ts +1 -0
  27. package/driver/magento/queries/get-customer-addresses.d.ts +2 -0
  28. package/driver/magento/queries/public_api.d.ts +4 -0
  29. package/driver/magento/queries/update-customer-address.d.ts +1 -0
  30. package/driver/magento/testing/factories/address.factory.d.ts +3 -1
  31. package/driver/magento/transforms/requests/address-input.d.ts +3 -0
  32. package/driver/magento/transforms/requests/public_api.d.ts +1 -0
  33. package/driver/magento/validators/create-customer-address.d.ts +3 -0
  34. package/driver/magento/validators/delete-customer-address.d.ts +3 -0
  35. package/driver/magento/validators/get-customer-addresses.d.ts +3 -0
  36. package/driver/magento/validators/public_api.d.ts +7 -0
  37. package/driver/magento/validators/update-customer-address.d.ts +3 -0
  38. package/driver/public_api.d.ts +1 -0
  39. package/driver/testing/drivers/address.service.d.ts +23 -0
  40. package/driver/testing/drivers/public_api.d.ts +1 -0
  41. package/esm2020/driver/errors/address-not-found.mjs +13 -0
  42. package/esm2020/driver/errors/codes.mjs +11 -0
  43. package/esm2020/driver/errors/default-billing-address-deletion.mjs +13 -0
  44. package/esm2020/driver/errors/default-shipping-address-deletion.mjs +13 -0
  45. package/esm2020/driver/errors/map.mjs +7 -1
  46. package/esm2020/driver/errors/public_api.mjs +5 -1
  47. package/esm2020/driver/in-memory/backend/address.service.mjs +110 -0
  48. package/esm2020/driver/in-memory/driver/address.service.mjs +42 -0
  49. package/esm2020/driver/in-memory/driver/customer-driver.module.mjs +6 -2
  50. package/esm2020/driver/in-memory/public_api.mjs +3 -1
  51. package/esm2020/driver/interfaces/address-service.interface.mjs +6 -0
  52. package/esm2020/driver/magento/address.service.mjs +91 -0
  53. package/esm2020/driver/magento/customer-driver.module.mjs +13 -3
  54. package/esm2020/driver/magento/errors/map.mjs +6 -0
  55. package/esm2020/driver/magento/errors/transform.mjs +28 -4
  56. package/esm2020/driver/magento/models/requests/address-attribute-input.type.mjs +2 -0
  57. package/esm2020/driver/magento/models/requests/address-input.type.mjs +2 -0
  58. package/esm2020/driver/magento/models/requests/address-region-input.type.mjs +2 -0
  59. package/esm2020/driver/magento/models/requests/public_api.mjs +1 -1
  60. package/esm2020/driver/magento/models/responses/create-customer-address.type.mjs +2 -0
  61. package/esm2020/driver/magento/models/responses/customer-address.type.mjs +1 -1
  62. package/esm2020/driver/magento/models/responses/delete-customer-address.type.mjs +2 -0
  63. package/esm2020/driver/magento/models/responses/get-customer-addresses.type.mjs +2 -0
  64. package/esm2020/driver/magento/models/responses/public_api.mjs +1 -1
  65. package/esm2020/driver/magento/models/responses/update-customer-address.type.mjs +2 -0
  66. package/esm2020/driver/magento/queries/create-customer-address.mjs +11 -0
  67. package/esm2020/driver/magento/queries/delete-customer-address.mjs +7 -0
  68. package/esm2020/driver/magento/queries/fragments/customer-address.mjs +4 -2
  69. package/esm2020/driver/magento/queries/get-customer-addresses.mjs +14 -0
  70. package/esm2020/driver/magento/queries/public_api.mjs +5 -1
  71. package/esm2020/driver/magento/queries/update-customer-address.mjs +11 -0
  72. package/esm2020/driver/magento/testing/factories/address.factory.mjs +4 -2
  73. package/esm2020/driver/magento/transforms/requests/address-input.mjs +22 -0
  74. package/esm2020/driver/magento/transforms/requests/public_api.mjs +2 -1
  75. package/esm2020/driver/magento/transforms/responses/customer-address.mjs +6 -3
  76. package/esm2020/driver/magento/validators/create-customer-address.mjs +10 -0
  77. package/esm2020/driver/magento/validators/delete-customer-address.mjs +10 -0
  78. package/esm2020/driver/magento/validators/get-customer-addresses.mjs +10 -0
  79. package/esm2020/driver/magento/validators/public_api.mjs +8 -1
  80. package/esm2020/driver/magento/validators/update-customer-address.mjs +10 -0
  81. package/esm2020/driver/public_api.mjs +2 -1
  82. package/esm2020/driver/testing/drivers/address.service.mjs +40 -0
  83. package/esm2020/driver/testing/drivers/customer-driver.module.mjs +7 -2
  84. package/esm2020/driver/testing/drivers/public_api.mjs +2 -1
  85. package/esm2020/models/address.type.mjs +1 -1
  86. package/esm2020/state/actions/address.actions.mjs +175 -0
  87. package/esm2020/state/actions/public_api.mjs +3 -0
  88. package/esm2020/state/customer.module.mjs +4 -1
  89. package/esm2020/state/effects/address.effects.mjs +45 -0
  90. package/esm2020/state/facades/address/facade.mjs +41 -0
  91. package/esm2020/state/facades/address/interface.mjs +2 -0
  92. package/esm2020/state/facades/public_api.mjs +2 -1
  93. package/esm2020/state/models/address.type.mjs +2 -0
  94. package/esm2020/state/models/public_api.mjs +2 -0
  95. package/esm2020/state/public_api.mjs +3 -2
  96. package/esm2020/state/reducers/address/initial-state.mjs +6 -0
  97. package/esm2020/state/reducers/address/public_api.mjs +3 -0
  98. package/esm2020/state/reducers/address/reducer.mjs +32 -0
  99. package/esm2020/state/reducers/address/type.mjs +2 -0
  100. package/esm2020/state/reducers/address-entities/adapter.mjs +10 -0
  101. package/esm2020/state/reducers/address-entities/public_api.mjs +3 -0
  102. package/esm2020/state/reducers/address-entities/reducer.mjs +43 -0
  103. package/esm2020/state/reducers/customer/adapter.mjs +15 -1
  104. package/esm2020/state/reducers/customer/reducer.mjs +20 -17
  105. package/esm2020/state/reducers/public_api.mjs +3 -1
  106. package/esm2020/state/reducers/reducers.interface.mjs +1 -1
  107. package/esm2020/state/reducers/token/reducers.token.mjs +5 -1
  108. package/esm2020/state/selectors/address/selector.mjs +23 -0
  109. package/esm2020/state/selectors/customer/selector.mjs +20 -0
  110. package/esm2020/state/selectors/feature.selector.mjs +1 -1
  111. package/esm2020/state/selectors/public_api.mjs +4 -2
  112. package/esm2020/state/testing/customer-testing.module.mjs +5 -2
  113. package/esm2020/state/testing/factories/customer-address.factory.mjs +32 -0
  114. package/esm2020/state/testing/factories/public_api.mjs +2 -0
  115. package/esm2020/state/testing/mock-address-facade.mjs +28 -0
  116. package/esm2020/state/testing/public_api.mjs +3 -1
  117. package/esm2020/testing/factories/customer-address.factory.mjs +3 -1
  118. package/fesm2015/daffodil-customer-driver-in-memory.mjs +145 -2
  119. package/fesm2015/daffodil-customer-driver-in-memory.mjs.map +1 -1
  120. package/fesm2015/daffodil-customer-driver-magento-testing.mjs +3 -1
  121. package/fesm2015/daffodil-customer-driver-magento-testing.mjs.map +1 -1
  122. package/fesm2015/daffodil-customer-driver-magento.mjs +227 -8
  123. package/fesm2015/daffodil-customer-driver-magento.mjs.map +1 -1
  124. package/fesm2015/daffodil-customer-driver-testing.mjs +41 -2
  125. package/fesm2015/daffodil-customer-driver-testing.mjs.map +1 -1
  126. package/fesm2015/daffodil-customer-driver.mjs +52 -1
  127. package/fesm2015/daffodil-customer-driver.mjs.map +1 -1
  128. package/fesm2015/daffodil-customer-state-testing.mjs +59 -3
  129. package/fesm2015/daffodil-customer-state-testing.mjs.map +1 -1
  130. package/fesm2015/daffodil-customer-state.mjs +378 -17
  131. package/fesm2015/daffodil-customer-state.mjs.map +1 -1
  132. package/fesm2015/daffodil-customer-testing.mjs +2 -0
  133. package/fesm2015/daffodil-customer-testing.mjs.map +1 -1
  134. package/fesm2020/daffodil-customer-driver-in-memory.mjs +148 -2
  135. package/fesm2020/daffodil-customer-driver-in-memory.mjs.map +1 -1
  136. package/fesm2020/daffodil-customer-driver-magento-testing.mjs +3 -1
  137. package/fesm2020/daffodil-customer-driver-magento-testing.mjs.map +1 -1
  138. package/fesm2020/daffodil-customer-driver-magento.mjs +223 -8
  139. package/fesm2020/daffodil-customer-driver-magento.mjs.map +1 -1
  140. package/fesm2020/daffodil-customer-driver-testing.mjs +41 -2
  141. package/fesm2020/daffodil-customer-driver-testing.mjs.map +1 -1
  142. package/fesm2020/daffodil-customer-driver.mjs +52 -1
  143. package/fesm2020/daffodil-customer-driver.mjs.map +1 -1
  144. package/fesm2020/daffodil-customer-state-testing.mjs +59 -3
  145. package/fesm2020/daffodil-customer-state-testing.mjs.map +1 -1
  146. package/fesm2020/daffodil-customer-state.mjs +387 -17
  147. package/fesm2020/daffodil-customer-state.mjs.map +1 -1
  148. package/fesm2020/daffodil-customer-testing.mjs +2 -0
  149. package/fesm2020/daffodil-customer-testing.mjs.map +1 -1
  150. package/models/address.type.d.ts +8 -0
  151. package/package.json +4 -4
  152. package/state/actions/address.actions.d.ts +166 -0
  153. package/state/actions/public_api.d.ts +2 -0
  154. package/state/effects/address.effects.d.ts +31 -0
  155. package/state/facades/address/facade.d.ts +28 -0
  156. package/state/facades/address/interface.d.ts +14 -0
  157. package/state/facades/public_api.d.ts +2 -0
  158. package/state/models/address.type.d.ts +3 -0
  159. package/state/models/public_api.d.ts +1 -0
  160. package/state/public_api.d.ts +2 -1
  161. package/state/reducers/address/initial-state.d.ts +5 -0
  162. package/state/reducers/address/public_api.d.ts +3 -0
  163. package/state/reducers/address/reducer.d.ts +7 -0
  164. package/state/reducers/address/type.d.ts +5 -0
  165. package/state/reducers/address-entities/adapter.d.ts +6 -0
  166. package/state/reducers/address-entities/public_api.d.ts +2 -0
  167. package/state/reducers/address-entities/reducer.d.ts +12 -0
  168. package/state/reducers/customer/adapter.d.ts +5 -0
  169. package/state/reducers/customer/reducer.d.ts +2 -2
  170. package/state/reducers/public_api.d.ts +2 -0
  171. package/state/reducers/reducers.interface.d.ts +9 -5
  172. package/state/reducers/token/extra.token.d.ts +1 -1
  173. package/state/reducers/token/reducers.token.d.ts +1 -1
  174. package/state/selectors/address/selector.d.ts +15 -0
  175. package/state/selectors/{customer.selector.d.ts → customer/selector.d.ts} +1 -1
  176. package/state/selectors/feature.selector.d.ts +4 -4
  177. package/state/selectors/public_api.d.ts +3 -1
  178. package/state/testing/factories/customer-address.factory.d.ts +21 -0
  179. package/state/testing/factories/public_api.d.ts +1 -0
  180. package/state/testing/mock-address-facade.d.ts +19 -0
  181. package/state/testing/public_api.d.ts +2 -0
  182. package/testing/factories/customer-address.factory.d.ts +2 -0
  183. 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.
@@ -195,6 +371,13 @@ function daffCustomerProvideExtraReducers(...reducers) {
195
371
  function daffCustomerStateStoreCustomer(customer, state) {
196
372
  return Object.assign(Object.assign(Object.assign({}, state), daffCompleteOperation(state)), { customer });
197
373
  }
374
+ /**
375
+ * Stores customer addresses.
376
+ * Sets loading to false and resets errors.
377
+ */
378
+ function daffCustomerStateStoreAddresses(addresses, state) {
379
+ return Object.assign(Object.assign(Object.assign({}, state), daffCompleteOperation(state)), { customer: Object.assign(Object.assign({}, state.customer), { addresses }) });
380
+ }
198
381
 
199
382
  /**
200
383
  * The initial state for the main customer state, see {@link DaffCustomerReducerState}.
@@ -205,31 +388,116 @@ const daffCustomerInitialState = Object.assign(Object.assign({}, daffOperationIn
205
388
  * The reducer for the customer page state, see {@link DaffCustomerReducerState}.
206
389
  */
207
390
  const daffCustomerReducer = (state = daffCustomerInitialState, action) => {
208
- switch (true) {
209
- case action.type === DaffCustomerActionTypes.CustomerLoadAction:
391
+ switch (action.type) {
392
+ case DaffCustomerActionTypes.CustomerLoadAction:
210
393
  return daffStartResolution(state);
211
- case action.type === DaffCustomerActionTypes.CustomerUpdateAction:
212
- case action.type === DaffCustomerActionTypes.CustomerChangeEmailAction:
213
- case action.type === DaffCustomerActionTypes.CustomerChangePasswordAction:
394
+ case DaffCustomerActionTypes.CustomerUpdateAction:
395
+ case DaffCustomerActionTypes.CustomerChangeEmailAction:
396
+ case DaffCustomerActionTypes.CustomerChangePasswordAction:
214
397
  return daffStartMutation(state);
215
- case action.type === DaffCustomerActionTypes.CustomerLoadSuccessAction:
216
- case action.type === DaffCustomerActionTypes.CustomerUpdateSuccessAction:
217
- case action.type === DaffCustomerActionTypes.CustomerChangeEmailSuccessAction:
398
+ case DaffCustomerActionTypes.CustomerLoadSuccessAction:
399
+ case DaffCustomerActionTypes.CustomerUpdateSuccessAction:
400
+ case DaffCustomerActionTypes.CustomerChangeEmailSuccessAction:
218
401
  return daffCustomerStateStoreCustomer(action.payload, state);
219
- case action.type === DaffCustomerActionTypes.CustomerChangePasswordSuccessAction:
402
+ case DaffCustomerActionTypes.CustomerChangePasswordSuccessAction:
220
403
  return daffCompleteOperation(state);
221
- case action.type === DaffCustomerActionTypes.CustomerLoadFailureAction:
222
- case action.type === DaffCustomerActionTypes.CustomerUpdateFailureAction:
223
- case action.type === DaffCustomerActionTypes.CustomerChangeEmailFailureAction:
224
- case action.type === DaffCustomerActionTypes.CustomerChangePasswordFailureAction:
404
+ case DaffCustomerActionTypes.CustomerLoadFailureAction:
405
+ case DaffCustomerActionTypes.CustomerUpdateFailureAction:
406
+ case DaffCustomerActionTypes.CustomerChangeEmailFailureAction:
407
+ case DaffCustomerActionTypes.CustomerChangePasswordFailureAction:
225
408
  return daffOperationFailed([action.payload], state);
226
- case action.type === DaffCustomerActionTypes.CustomerClearErrorsAction:
409
+ case DaffCustomerActionTypes.CustomerClearErrorsAction:
227
410
  return daffClearErrors(state);
411
+ case DaffCustomerAddressActionTypes.AddressDeleteSuccessAction:
412
+ case DaffCustomerAddressActionTypes.AddressAddSuccessAction:
413
+ return daffCustomerStateStoreAddresses(action.payload, state);
228
414
  default:
229
415
  return state;
230
416
  }
231
417
  };
232
418
 
419
+ /**
420
+ * The initial state for the main customer state, see {@link DaffCustomerAddressReducerState}.
421
+ */
422
+ const daffCustomerAddressInitialState = daffOperationInitialState;
423
+
424
+ /**
425
+ * The reducer for the customer page state, see {@link DaffCustomerAddressReducerState}.
426
+ */
427
+ const daffCustomerAddressReducer = (state = daffCustomerAddressInitialState, action) => {
428
+ switch (true) {
429
+ case action.type === DaffCustomerAddressActionTypes.AddressListAction:
430
+ case action.type === DaffCustomerAddressActionTypes.AddressLoadAction:
431
+ return daffStartResolution(state);
432
+ case action.type === DaffCustomerAddressActionTypes.AddressUpdateAction:
433
+ case action.type === DaffCustomerAddressActionTypes.AddressAddAction:
434
+ case action.type === DaffCustomerAddressActionTypes.AddressDeleteAction:
435
+ return daffStartMutation(state);
436
+ case action.type === DaffCustomerAddressActionTypes.AddressListSuccessAction:
437
+ case action.type === DaffCustomerAddressActionTypes.AddressLoadSuccessAction:
438
+ case action.type === DaffCustomerAddressActionTypes.AddressUpdateSuccessAction:
439
+ case action.type === DaffCustomerAddressActionTypes.AddressAddSuccessAction:
440
+ case action.type === DaffCustomerAddressActionTypes.AddressDeleteSuccessAction:
441
+ return daffCompleteOperation(state);
442
+ case action.type === DaffCustomerAddressActionTypes.AddressListFailureAction:
443
+ case action.type === DaffCustomerAddressActionTypes.AddressLoadFailureAction:
444
+ case action.type === DaffCustomerAddressActionTypes.AddressUpdateFailureAction:
445
+ case action.type === DaffCustomerAddressActionTypes.AddressAddFailureAction:
446
+ case action.type === DaffCustomerAddressActionTypes.AddressDeleteFailureAction:
447
+ return daffOperationFailed([action.payload], state);
448
+ default:
449
+ return state;
450
+ }
451
+ };
452
+
453
+ /**
454
+ * Customer Address Entities Adapter for changing/overwriting entity state.
455
+ */
456
+ const daffCustomerAddressEntitiesAdapter = (() => {
457
+ let cache;
458
+ return () => cache = cache || daffCreateOperationEntityStateAdapter(createEntityAdapter({ selectId: item => item.id }));
459
+ })();
460
+
461
+ /**
462
+ * Reducer function that catches actions and changes/overwrites product entities state.
463
+ *
464
+ * @param state current State of the redux store
465
+ * @param action CartItemGrid, BestSellers, or CartItem actions
466
+ * @returns CartItem entities state
467
+ */
468
+ function daffCustomerAddressEntitiesReducer(state = daffCustomerAddressEntitiesAdapter().getInitialState(), action) {
469
+ const adapter = daffCustomerAddressEntitiesAdapter();
470
+ switch (action.type) {
471
+ case DaffCustomerAddressActionTypes.AddressLoadAction:
472
+ return adapter.preload(action.addressId, state);
473
+ case DaffCustomerAddressActionTypes.AddressAddAction:
474
+ return adapter.preadd(action.address, state, action.placeholderId);
475
+ case DaffCustomerAddressActionTypes.AddressDeleteAction:
476
+ return adapter.preremove(action.addressId, state);
477
+ case DaffCustomerAddressActionTypes.AddressUpdateAction:
478
+ return adapter.preupdate(action.address, state);
479
+ case DaffCustomerAddressActionTypes.AddressLoadSuccessAction:
480
+ return adapter.load(action.payload, state);
481
+ case DaffCustomerAddressActionTypes.AddressListSuccessAction:
482
+ return adapter.list(action.payload, state);
483
+ case DaffCustomerActionTypes.CustomerChangeEmailSuccessAction:
484
+ case DaffCustomerActionTypes.CustomerUpdateSuccessAction:
485
+ case DaffCustomerActionTypes.CustomerLoadSuccessAction:
486
+ return adapter.list(action.payload.addresses, state);
487
+ case DaffCustomerAddressActionTypes.AddressUpdateSuccessAction:
488
+ case DaffCustomerAddressActionTypes.AddressDeleteSuccessAction:
489
+ case DaffCustomerAddressActionTypes.AddressAddSuccessAction:
490
+ return adapter.list(action.payload, state);
491
+ case DaffCustomerAddressActionTypes.AddressDeleteFailureAction:
492
+ case DaffCustomerAddressActionTypes.AddressAddFailureAction:
493
+ case DaffCustomerAddressActionTypes.AddressLoadFailureAction:
494
+ case DaffCustomerAddressActionTypes.AddressUpdateFailureAction:
495
+ return adapter.operationFailed(action.id, [action.payload], state);
496
+ default:
497
+ return state;
498
+ }
499
+ }
500
+
233
501
  const getDaffCustomerReducersStateSelector = (() => {
234
502
  let cache;
235
503
  return () => cache = cache || {
@@ -251,6 +519,21 @@ const daffCustomerGetSelectors = (() => {
251
519
  return () => cache = cache || daffCustomerCreateSelectors();
252
520
  })();
253
521
 
522
+ /**
523
+ * Creates a group of selectors for {@link DaffCustomerAddressReducerState} that use the passed state selector as the basis.
524
+ */
525
+ const daffCustomerAddressCreateSelectors = () => {
526
+ const { selectCustomerFeatureState } = getDaffCustomerReducersStateSelector();
527
+ const selectCustomerAddressState = createSelector(selectCustomerFeatureState, state => state.address);
528
+ const selectCustomerAddressEntitiesState = createSelector(selectCustomerFeatureState, state => state.addressEntities);
529
+ const { selectEntity, selectOptimisticList, } = daffCustomerAddressEntitiesAdapter().getSelectors(selectCustomerAddressEntitiesState);
530
+ return Object.assign(Object.assign({}, daffOperationStateSelectorFactory(selectCustomerAddressState)), { selectAddress: selectEntity, selectAddresses: selectOptimisticList });
531
+ };
532
+ const daffCustomerAddressGetSelectors = (() => {
533
+ let cache;
534
+ return () => cache = cache || daffCustomerAddressCreateSelectors();
535
+ })();
536
+
254
537
  /**
255
538
  * @inheritdoc
256
539
  *
@@ -282,6 +565,80 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
282
565
  }]
283
566
  }], ctorParameters: function () { return [{ type: i1.Store }]; } });
284
567
 
568
+ // TODO: address entities?
569
+ /**
570
+ * @inheritdoc
571
+ *
572
+ * Serves as the base for a customer facade.
573
+ * Extend this class and pass in the selectors for the specific state you wish to target.
574
+ */
575
+ class DaffCustomerAddressPageFacade {
576
+ constructor(store) {
577
+ this.store = store;
578
+ const { selectAddress, selectAddresses, selectErrors, selectHasErrors, selectLoading, selectLoadingState, selectMutating, selectResolving, } = daffCustomerAddressGetSelectors();
579
+ this._selectAddress = selectAddress;
580
+ this.addresses$ = this.store.pipe(select(selectAddresses));
581
+ this.loadingState$ = this.store.pipe(select(selectLoadingState));
582
+ this.loading$ = this.store.pipe(select(selectLoading));
583
+ this.resolving$ = this.store.pipe(select(selectResolving));
584
+ this.mutating$ = this.store.pipe(select(selectMutating));
585
+ this.errors$ = this.store.pipe(select(selectErrors));
586
+ this.hasErrors$ = this.store.pipe(select(selectHasErrors));
587
+ }
588
+ getAddress(id) {
589
+ return this.store.pipe(select(this._selectAddress(id)));
590
+ }
591
+ dispatch(action) {
592
+ this.store.dispatch(action);
593
+ }
594
+ }
595
+ /** @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 });
596
+ /** @nocollapse */ DaffCustomerAddressPageFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerAddressPageFacade, providedIn: 'root' });
597
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerAddressPageFacade, decorators: [{
598
+ type: Injectable,
599
+ args: [{
600
+ providedIn: 'root',
601
+ }]
602
+ }], ctorParameters: function () { return [{ type: i1.Store }]; } });
603
+
604
+ class DaffCustomerAddressEffects {
605
+ constructor(actions$, driver, errorMatcher) {
606
+ this.actions$ = actions$;
607
+ this.driver = driver;
608
+ this.errorMatcher = errorMatcher;
609
+ 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))))))));
610
+ /**
611
+ * An effect for loading a customer address.
612
+ */
613
+ 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)))))));
614
+ /**
615
+ * An effect for updating a customer address.
616
+ */
617
+ 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)))))));
618
+ /**
619
+ * An effect for adding a new customer address.
620
+ */
621
+ 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)))))));
622
+ /**
623
+ * An effect for adding a new customer address.
624
+ */
625
+ 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)))))));
626
+ }
627
+ }
628
+ /** @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 });
629
+ /** @nocollapse */ DaffCustomerAddressEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerAddressEffects });
630
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerAddressEffects, decorators: [{
631
+ type: Injectable
632
+ }], ctorParameters: function () {
633
+ return [{ type: i1$1.Actions }, { type: undefined, decorators: [{
634
+ type: Inject,
635
+ args: [DaffCustomerAddressDriver]
636
+ }] }, { type: undefined, decorators: [{
637
+ type: Inject,
638
+ args: [DAFF_CUSTOMER_ERROR_MATCHER]
639
+ }] }];
640
+ } });
641
+
285
642
  class DaffCustomerEffects {
286
643
  constructor(actions$, driver, errorMatcher) {
287
644
  this.actions$ = actions$;
@@ -330,6 +687,8 @@ const DAFF_CUSTOMER_REDUCERS = new InjectionToken('DAFF_CUSTOMER_REDUCERS', {
330
687
  factory: () => daffComposeReducers([
331
688
  combineReducers({
332
689
  customer: daffCustomerReducer,
690
+ address: daffCustomerAddressReducer,
691
+ addressEntities: daffCustomerAddressEntitiesReducer,
333
692
  }),
334
693
  ...inject(DAFF_CUSTOMER_EXTRA_REDUCERS),
335
694
  ]),
@@ -346,6 +705,7 @@ class DaffCustomerStateModule {
346
705
  StoreModule.forFeature(DAFF_CUSTOMER_STORE_FEATURE_KEY, DAFF_CUSTOMER_REDUCERS),
347
706
  EffectsModule.forFeature([
348
707
  DaffCustomerEffects,
708
+ DaffCustomerAddressEffects,
349
709
  ]),
350
710
  ]] });
351
711
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerStateModule, decorators: [{
@@ -355,6 +715,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
355
715
  StoreModule.forFeature(DAFF_CUSTOMER_STORE_FEATURE_KEY, DAFF_CUSTOMER_REDUCERS),
356
716
  EffectsModule.forFeature([
357
717
  DaffCustomerEffects,
718
+ DaffCustomerAddressEffects,
358
719
  ]),
359
720
  ],
360
721
  }]
@@ -364,5 +725,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
364
725
  * Generated bundle index. Do not edit.
365
726
  */
366
727
 
367
- 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 };
728
+ 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 };
368
729
  //# sourceMappingURL=daffodil-customer-state.mjs.map