@daffodil/payment 0.47.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 (176) hide show
  1. package/README.md +11 -0
  2. package/daffodil-payment.d.ts +5 -0
  3. package/driver/daffodil-payment-driver.d.ts +5 -0
  4. package/driver/errors/invalid-api-response.d.ts +10 -0
  5. package/driver/errors/map.d.ts +7 -0
  6. package/driver/errors/public_api.d.ts +2 -0
  7. package/driver/in-memory/backend/payment.service.d.ts +33 -0
  8. package/driver/in-memory/daffodil-payment-driver-in-memory.d.ts +5 -0
  9. package/driver/in-memory/driver/payment-driver.module.d.ts +13 -0
  10. package/driver/in-memory/driver/payment.service.d.ts +21 -0
  11. package/driver/in-memory/index.d.ts +1 -0
  12. package/driver/in-memory/package.json +10 -0
  13. package/driver/in-memory/public_api.d.ts +3 -0
  14. package/driver/index.d.ts +1 -0
  15. package/driver/interfaces/payment-service.interface.d.ts +16 -0
  16. package/driver/package.json +10 -0
  17. package/driver/public_api.d.ts +2 -0
  18. package/driver/testing/daffodil-payment-driver-testing.d.ts +5 -0
  19. package/driver/testing/drivers/payment-driver.module.d.ts +12 -0
  20. package/driver/testing/drivers/payment.service.d.ts +18 -0
  21. package/driver/testing/drivers/public_api.d.ts +2 -0
  22. package/driver/testing/index.d.ts +1 -0
  23. package/driver/testing/package.json +10 -0
  24. package/driver/testing/public_api.d.ts +1 -0
  25. package/esm2020/daffodil-payment.mjs +5 -0
  26. package/esm2020/driver/daffodil-payment-driver.mjs +5 -0
  27. package/esm2020/driver/errors/invalid-api-response.mjs +13 -0
  28. package/esm2020/driver/errors/map.mjs +8 -0
  29. package/esm2020/driver/errors/public_api.mjs +3 -0
  30. package/esm2020/driver/in-memory/backend/payment.service.mjs +52 -0
  31. package/esm2020/driver/in-memory/daffodil-payment-driver-in-memory.mjs +5 -0
  32. package/esm2020/driver/in-memory/driver/payment-driver.module.mjs +39 -0
  33. package/esm2020/driver/in-memory/driver/payment.service.mjs +30 -0
  34. package/esm2020/driver/in-memory/index.mjs +2 -0
  35. package/esm2020/driver/in-memory/public_api.mjs +4 -0
  36. package/esm2020/driver/index.mjs +2 -0
  37. package/esm2020/driver/interfaces/payment-service.interface.mjs +6 -0
  38. package/esm2020/driver/public_api.mjs +3 -0
  39. package/esm2020/driver/testing/daffodil-payment-driver-testing.mjs +5 -0
  40. package/esm2020/driver/testing/drivers/payment-driver.module.mjs +35 -0
  41. package/esm2020/driver/testing/drivers/payment.service.mjs +28 -0
  42. package/esm2020/driver/testing/drivers/public_api.mjs +3 -0
  43. package/esm2020/driver/testing/index.mjs +2 -0
  44. package/esm2020/driver/testing/public_api.mjs +2 -0
  45. package/esm2020/index.mjs +2 -0
  46. package/esm2020/injection-tokens/error-matcher.token.mjs +8 -0
  47. package/esm2020/injection-tokens/public_api.mjs +2 -0
  48. package/esm2020/models/public_api.mjs +2 -0
  49. package/esm2020/models/request.type.mjs +2 -0
  50. package/esm2020/models/response.type.mjs +2 -0
  51. package/esm2020/public_api.mjs +3 -0
  52. package/esm2020/state/actions/payment.actions.mjs +27 -0
  53. package/esm2020/state/daffodil-payment-state.mjs +5 -0
  54. package/esm2020/state/facades/payment/facade.mjs +31 -0
  55. package/esm2020/state/facades/payment/interface.mjs +2 -0
  56. package/esm2020/state/facades/public_api.mjs +2 -0
  57. package/esm2020/state/index.mjs +2 -0
  58. package/esm2020/state/injection-tokens/available-processors.token.mjs +19 -0
  59. package/esm2020/state/injection-tokens/processor-collection.token.mjs +13 -0
  60. package/esm2020/state/injection-tokens/public_api.mjs +3 -0
  61. package/esm2020/state/models/available-processor.type.mjs +2 -0
  62. package/esm2020/state/models/processor-collection.type.mjs +2 -0
  63. package/esm2020/state/models/public_api.mjs +2 -0
  64. package/esm2020/state/payment.module.mjs +25 -0
  65. package/esm2020/state/public_api.mjs +8 -0
  66. package/esm2020/state/reducers/payment/adapter.mjs +40 -0
  67. package/esm2020/state/reducers/payment/initial-state.mjs +8 -0
  68. package/esm2020/state/reducers/payment/interface.mjs +2 -0
  69. package/esm2020/state/reducers/payment/public_api.mjs +4 -0
  70. package/esm2020/state/reducers/payment/reducer.mjs +20 -0
  71. package/esm2020/state/reducers/public_api.mjs +4 -0
  72. package/esm2020/state/reducers/reducers.interface.mjs +2 -0
  73. package/esm2020/state/reducers/store-feature-key.mjs +5 -0
  74. package/esm2020/state/reducers/token/extra.token.mjs +30 -0
  75. package/esm2020/state/reducers/token/public_api.mjs +2 -0
  76. package/esm2020/state/reducers/token/reducers.token.mjs +22 -0
  77. package/esm2020/state/selectors/feature.selector.mjs +9 -0
  78. package/esm2020/state/selectors/payment.selector.mjs +20 -0
  79. package/esm2020/state/selectors/public_api.mjs +2 -0
  80. package/esm2020/state/testing/daffodil-payment-state-testing.mjs +5 -0
  81. package/esm2020/state/testing/index.mjs +2 -0
  82. package/esm2020/state/testing/mock-payment-facade.mjs +23 -0
  83. package/esm2020/state/testing/payment-testing.module.mjs +23 -0
  84. package/esm2020/state/testing/public_api.mjs +3 -0
  85. package/esm2020/testing/daffodil-payment-testing.mjs +5 -0
  86. package/esm2020/testing/factories/kind.factory.mjs +37 -0
  87. package/esm2020/testing/factories/payment-request.factory.mjs +31 -0
  88. package/esm2020/testing/factories/payment-response.factory.mjs +31 -0
  89. package/esm2020/testing/factories/public_api.mjs +4 -0
  90. package/esm2020/testing/index.mjs +2 -0
  91. package/esm2020/testing/injection-tokens/factories/kind.token.mjs +30 -0
  92. package/esm2020/testing/injection-tokens/public_api.mjs +2 -0
  93. package/esm2020/testing/public_api.mjs +4 -0
  94. package/esm2020/testing/testing.module.mjs +31 -0
  95. package/fesm2015/daffodil-payment-driver-in-memory.mjs +121 -0
  96. package/fesm2015/daffodil-payment-driver-in-memory.mjs.map +1 -0
  97. package/fesm2015/daffodil-payment-driver-testing.mjs +66 -0
  98. package/fesm2015/daffodil-payment-driver-testing.mjs.map +1 -0
  99. package/fesm2015/daffodil-payment-driver.mjs +33 -0
  100. package/fesm2015/daffodil-payment-driver.mjs.map +1 -0
  101. package/fesm2015/daffodil-payment-state-testing.mjs +50 -0
  102. package/fesm2015/daffodil-payment-state-testing.mjs.map +1 -0
  103. package/fesm2015/daffodil-payment-state.mjs +242 -0
  104. package/fesm2015/daffodil-payment-state.mjs.map +1 -0
  105. package/fesm2015/daffodil-payment-testing.mjs +154 -0
  106. package/fesm2015/daffodil-payment-testing.mjs.map +1 -0
  107. package/fesm2015/daffodil-payment.mjs +15 -0
  108. package/fesm2015/daffodil-payment.mjs.map +1 -0
  109. package/fesm2020/daffodil-payment-driver-in-memory.mjs +121 -0
  110. package/fesm2020/daffodil-payment-driver-in-memory.mjs.map +1 -0
  111. package/fesm2020/daffodil-payment-driver-testing.mjs +66 -0
  112. package/fesm2020/daffodil-payment-driver-testing.mjs.map +1 -0
  113. package/fesm2020/daffodil-payment-driver.mjs +33 -0
  114. package/fesm2020/daffodil-payment-driver.mjs.map +1 -0
  115. package/fesm2020/daffodil-payment-state-testing.mjs +50 -0
  116. package/fesm2020/daffodil-payment-state-testing.mjs.map +1 -0
  117. package/fesm2020/daffodil-payment-state.mjs +253 -0
  118. package/fesm2020/daffodil-payment-state.mjs.map +1 -0
  119. package/fesm2020/daffodil-payment-testing.mjs +152 -0
  120. package/fesm2020/daffodil-payment-testing.mjs.map +1 -0
  121. package/fesm2020/daffodil-payment.mjs +15 -0
  122. package/fesm2020/daffodil-payment.mjs.map +1 -0
  123. package/index.d.ts +1 -0
  124. package/injection-tokens/error-matcher.token.d.ts +7 -0
  125. package/injection-tokens/public_api.d.ts +1 -0
  126. package/models/public_api.d.ts +2 -0
  127. package/models/request.type.d.ts +13 -0
  128. package/models/response.type.d.ts +14 -0
  129. package/package.json +100 -0
  130. package/public_api.d.ts +2 -0
  131. package/state/actions/payment.actions.d.ts +40 -0
  132. package/state/daffodil-payment-state.d.ts +5 -0
  133. package/state/facades/payment/facade.d.ts +21 -0
  134. package/state/facades/payment/interface.d.ts +16 -0
  135. package/state/facades/public_api.d.ts +2 -0
  136. package/state/index.d.ts +1 -0
  137. package/state/injection-tokens/available-processors.token.d.ts +12 -0
  138. package/state/injection-tokens/processor-collection.token.d.ts +6 -0
  139. package/state/injection-tokens/public_api.d.ts +2 -0
  140. package/state/models/available-processor.type.d.ts +21 -0
  141. package/state/models/processor-collection.type.d.ts +5 -0
  142. package/state/models/public_api.d.ts +2 -0
  143. package/state/package.json +10 -0
  144. package/state/payment.module.d.ts +10 -0
  145. package/state/public_api.d.ts +7 -0
  146. package/state/reducers/payment/adapter.d.ts +21 -0
  147. package/state/reducers/payment/initial-state.d.ts +5 -0
  148. package/state/reducers/payment/interface.d.ts +15 -0
  149. package/state/reducers/payment/public_api.d.ts +4 -0
  150. package/state/reducers/payment/reducer.d.ts +7 -0
  151. package/state/reducers/public_api.d.ts +4 -0
  152. package/state/reducers/reducers.interface.d.ts +14 -0
  153. package/state/reducers/store-feature-key.d.ts +4 -0
  154. package/state/reducers/token/extra.token.d.ts +22 -0
  155. package/state/reducers/token/public_api.d.ts +1 -0
  156. package/state/reducers/token/reducers.token.d.ts +10 -0
  157. package/state/selectors/feature.selector.d.ts +9 -0
  158. package/state/selectors/payment.selector.d.ts +17 -0
  159. package/state/selectors/public_api.d.ts +1 -0
  160. package/state/testing/daffodil-payment-state-testing.d.ts +5 -0
  161. package/state/testing/index.d.ts +1 -0
  162. package/state/testing/mock-payment-facade.d.ts +17 -0
  163. package/state/testing/package.json +10 -0
  164. package/state/testing/payment-testing.module.d.ts +9 -0
  165. package/state/testing/public_api.d.ts +2 -0
  166. package/testing/daffodil-payment-testing.d.ts +5 -0
  167. package/testing/factories/kind.factory.d.ts +18 -0
  168. package/testing/factories/payment-request.factory.d.ts +18 -0
  169. package/testing/factories/payment-response.factory.d.ts +18 -0
  170. package/testing/factories/public_api.d.ts +3 -0
  171. package/testing/index.d.ts +1 -0
  172. package/testing/injection-tokens/factories/kind.token.d.ts +24 -0
  173. package/testing/injection-tokens/public_api.d.ts +1 -0
  174. package/testing/package.json +10 -0
  175. package/testing/public_api.d.ts +3 -0
  176. package/testing/testing.module.d.ts +9 -0
@@ -0,0 +1,242 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, Injectable, inject, NgModule } from '@angular/core';
3
+ import * as i1 from '@ngrx/store';
4
+ import { createFeatureSelector, createSelector, select, combineReducers, StoreModule } from '@ngrx/store';
5
+ import { daffArrayToDict } from '@daffodil/core';
6
+ import { daffComposeReducers } from '@daffodil/core/state';
7
+
8
+ /**
9
+ * The payment action types enum.
10
+ */
11
+ var DaffPaymentActionTypes;
12
+ (function (DaffPaymentActionTypes) {
13
+ DaffPaymentActionTypes["GenerateTokenSuccessAction"] = "[@daffodil/payment] Generate Token Success Action";
14
+ DaffPaymentActionTypes["GenerateTokenFailureAction"] = "[@daffodil/payment] Generate Token Failure Action";
15
+ })(DaffPaymentActionTypes || (DaffPaymentActionTypes = {}));
16
+ /**
17
+ * Indicates a successful generation of a payment token.
18
+ */
19
+ class DaffPaymentGenerateTokenSuccess {
20
+ constructor(payload) {
21
+ this.payload = payload;
22
+ this.type = DaffPaymentActionTypes.GenerateTokenSuccessAction;
23
+ }
24
+ }
25
+ /**
26
+ * A failed payment with the error message.
27
+ */
28
+ class DaffPaymentGenerateTokenFailure {
29
+ constructor(payload) {
30
+ this.payload = payload;
31
+ this.type = DaffPaymentActionTypes.GenerateTokenFailureAction;
32
+ }
33
+ }
34
+
35
+ /**
36
+ * The key under which the payment feature state will be stored.
37
+ */
38
+ const DAFF_PAYMENT_STORE_FEATURE_KEY = 'daffPayment';
39
+
40
+ /**
41
+ * A token to hold the injectable extra reducers.
42
+ *
43
+ * Prefer using {@link daffPaymentProvideExtraReducers}.
44
+ */
45
+ const DAFF_PAYMENT_EXTRA_REDUCERS = new InjectionToken('DAFF_PAYMENT_EXTRA_REDUCERS', {
46
+ factory: () => [],
47
+ providedIn: 'any',
48
+ });
49
+ /**
50
+ * Provides additional reducers that run after the standard Daffodil cart reducers.
51
+ *
52
+ * ```ts
53
+ * providers: [
54
+ * ...daffPaymentProvideExtraReducers(
55
+ * myReducer1,
56
+ * myReducer2
57
+ * )
58
+ * ]
59
+ * ```
60
+ */
61
+ function daffPaymentProvideExtraReducers(...reducers) {
62
+ return reducers.map(reducer => ({
63
+ provide: DAFF_PAYMENT_EXTRA_REDUCERS,
64
+ useValue: reducer,
65
+ multi: true,
66
+ }));
67
+ }
68
+
69
+ /**
70
+ * Manages {@link DaffPaymentReducerState}.
71
+ */
72
+ class DaffPaymentStateReducerAdapter {
73
+ /**
74
+ * Begins the payment operation flow.
75
+ * Sets loading to true.
76
+ */
77
+ generateToken(state) {
78
+ return Object.assign(Object.assign({}, state), { loading: true });
79
+ }
80
+ /**
81
+ * Sets loading to false and resets errors.
82
+ */
83
+ tokenGenerated(state) {
84
+ return Object.assign(Object.assign({}, state), { loading: false, errors: [] });
85
+ }
86
+ /**
87
+ * Stores the from a failed payment.
88
+ * Also sets loading to false.
89
+ */
90
+ storeError(error, state) {
91
+ return Object.assign(Object.assign({}, state), { errors: [
92
+ ...state.errors,
93
+ error,
94
+ ], loading: false });
95
+ }
96
+ }
97
+
98
+ /**
99
+ * The initial state for the main payment state, see {@link DaffPaymentReducerState}.
100
+ */
101
+ const daffPaymentInitialState = {
102
+ loading: false,
103
+ errors: [],
104
+ };
105
+
106
+ /**
107
+ * The reducer for the payment page state, see {@link DaffPaymentReducerState}.
108
+ */
109
+ const daffPaymentReducerFactory = (actions) => (state = daffPaymentInitialState, action) => {
110
+ const adapter = new DaffPaymentStateReducerAdapter();
111
+ switch (true) {
112
+ case actions.includes(action.type):
113
+ return adapter.generateToken(state);
114
+ case action.type === DaffPaymentActionTypes.GenerateTokenSuccessAction:
115
+ return adapter.tokenGenerated(state);
116
+ case action.type === DaffPaymentActionTypes.GenerateTokenFailureAction:
117
+ return adapter.storeError(action.payload, state);
118
+ default:
119
+ return state;
120
+ }
121
+ };
122
+
123
+ const getDaffPaymentReducersStateSelector = (() => {
124
+ let cache;
125
+ return () => cache = cache || {
126
+ selectPaymentFeatureState: createFeatureSelector(DAFF_PAYMENT_STORE_FEATURE_KEY),
127
+ };
128
+ })();
129
+
130
+ /**
131
+ * Creates a group of selectors for {@link DaffPaymentReducerState} that use the passed state selector as the basis.
132
+ */
133
+ const daffPaymentCreateSelectors = () => {
134
+ const { selectPaymentFeatureState } = getDaffPaymentReducersStateSelector();
135
+ const selectPaymentState = createSelector(selectPaymentFeatureState, state => state.payment);
136
+ const selectPaymentLoading = createSelector(selectPaymentState, state => state.loading);
137
+ const selectPaymentErrors = createSelector(selectPaymentState, state => state.errors);
138
+ return {
139
+ selectPaymentLoading,
140
+ selectPaymentErrors,
141
+ };
142
+ };
143
+ const daffPaymentGetSelectors = (() => {
144
+ let cache;
145
+ return () => cache = cache || daffPaymentCreateSelectors();
146
+ })();
147
+
148
+ /**
149
+ * @inheritdoc
150
+ *
151
+ * Serves as the base for a payment facade.
152
+ * Extend this class and pass in the selectors for the specific state you wish to target.
153
+ */
154
+ class DaffPaymentPageFacade {
155
+ constructor(store) {
156
+ this.store = store;
157
+ const { selectPaymentLoading, selectPaymentErrors, } = daffPaymentGetSelectors();
158
+ this.loading$ = this.store.pipe(select(selectPaymentLoading));
159
+ this.errors$ = this.store.pipe(select(selectPaymentErrors));
160
+ }
161
+ dispatch(action) {
162
+ this.store.dispatch(action);
163
+ }
164
+ }
165
+ /** @nocollapse */ DaffPaymentPageFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentPageFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable });
166
+ /** @nocollapse */ DaffPaymentPageFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentPageFacade, providedIn: 'root' });
167
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentPageFacade, decorators: [{
168
+ type: Injectable,
169
+ args: [{
170
+ providedIn: 'root',
171
+ }]
172
+ }], ctorParameters: function () { return [{ type: i1.Store }]; } });
173
+
174
+ /**
175
+ * A multi-provider injection token for registering payment processors.
176
+ */
177
+ const DAFF_PAYMENT_AVAILABLE_PROCESSORS = new InjectionToken('DAFF_PAYMENT_AVAILABLE_PROCESSORS', {
178
+ factory: () => [],
179
+ providedIn: 'any',
180
+ });
181
+ /**
182
+ * Provides a payment processor registration.
183
+ *
184
+ * See {@link DaffPaymentAvailableProcessor}.
185
+ */
186
+ const daffPaymentProvideAvailableProcessors = (...processors) => processors.map(processor => ({
187
+ provide: DAFF_PAYMENT_AVAILABLE_PROCESSORS,
188
+ useValue: processor,
189
+ multi: true,
190
+ }));
191
+
192
+ /**
193
+ * An internal token to combine the available payment processors into a single collection.
194
+ */
195
+ const DAFF_PAYMENT_PROCESSOR_COLLECTION = new InjectionToken('DAFF_PAYMENT_PROCESSOR_COLLECTION', {
196
+ factory: () => {
197
+ const processors = inject(DAFF_PAYMENT_AVAILABLE_PROCESSORS);
198
+ return daffArrayToDict(processors, ({ kind }) => kind);
199
+ },
200
+ });
201
+
202
+ /**
203
+ * An internal token to hold the Daffodil payment reducers.
204
+ * Includes the extra and standard reducers.
205
+ *
206
+ * @docs-private
207
+ */
208
+ const DAFF_PAYMENT_REDUCERS = new InjectionToken('DAFF_PAYMENT_REDUCERS', {
209
+ providedIn: 'any',
210
+ factory: () => daffComposeReducers([
211
+ combineReducers({
212
+ payment: daffPaymentReducerFactory(inject(DAFF_PAYMENT_AVAILABLE_PROCESSORS).map(({ action }) => action)),
213
+ }),
214
+ ...inject(DAFF_PAYMENT_EXTRA_REDUCERS),
215
+ ]),
216
+ });
217
+
218
+ /**
219
+ * Creates the payment feature store.
220
+ */
221
+ class DaffPaymentStateModule {
222
+ }
223
+ /** @nocollapse */ DaffPaymentStateModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
224
+ /** @nocollapse */ DaffPaymentStateModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentStateModule, imports: [i1.StoreFeatureModule] });
225
+ /** @nocollapse */ DaffPaymentStateModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentStateModule, imports: [[
226
+ StoreModule.forFeature(DAFF_PAYMENT_STORE_FEATURE_KEY, DAFF_PAYMENT_REDUCERS),
227
+ ]] });
228
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentStateModule, decorators: [{
229
+ type: NgModule,
230
+ args: [{
231
+ imports: [
232
+ StoreModule.forFeature(DAFF_PAYMENT_STORE_FEATURE_KEY, DAFF_PAYMENT_REDUCERS),
233
+ ],
234
+ }]
235
+ }] });
236
+
237
+ /**
238
+ * Generated bundle index. Do not edit.
239
+ */
240
+
241
+ export { DAFF_PAYMENT_AVAILABLE_PROCESSORS, DAFF_PAYMENT_EXTRA_REDUCERS, DAFF_PAYMENT_PROCESSOR_COLLECTION, DAFF_PAYMENT_STORE_FEATURE_KEY, DaffPaymentActionTypes, DaffPaymentGenerateTokenFailure, DaffPaymentGenerateTokenSuccess, DaffPaymentPageFacade, DaffPaymentStateModule, DaffPaymentStateReducerAdapter, daffPaymentGetSelectors, daffPaymentInitialState, daffPaymentProvideAvailableProcessors, daffPaymentProvideExtraReducers, daffPaymentReducerFactory };
242
+ //# sourceMappingURL=daffodil-payment-state.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daffodil-payment-state.mjs","sources":["../../../libs/payment/state/src/actions/payment.actions.ts","../../../libs/payment/state/src/reducers/store-feature-key.ts","../../../libs/payment/state/src/reducers/token/extra.token.ts","../../../libs/payment/state/src/reducers/payment/adapter.ts","../../../libs/payment/state/src/reducers/payment/initial-state.ts","../../../libs/payment/state/src/reducers/payment/reducer.ts","../../../libs/payment/state/src/selectors/feature.selector.ts","../../../libs/payment/state/src/selectors/payment.selector.ts","../../../libs/payment/state/src/facades/payment/facade.ts","../../../libs/payment/state/src/injection-tokens/available-processors.token.ts","../../../libs/payment/state/src/injection-tokens/processor-collection.token.ts","../../../libs/payment/state/src/reducers/token/reducers.token.ts","../../../libs/payment/state/src/payment.module.ts","../../../libs/payment/state/src/daffodil-payment-state.ts"],"sourcesContent":["import { Action } from '@ngrx/store';\n\nimport { DaffStateError } from '@daffodil/core/state';\nimport { DaffPersonalAddress } from '@daffodil/geography';\nimport {\n DaffPaymentRequest,\n DaffPaymentResponse,\n} from '@daffodil/payment';\n\n/**\n * The payment action types enum.\n */\nexport enum DaffPaymentActionTypes {\n GenerateTokenSuccessAction = '[@daffodil/payment] Generate Token Success Action',\n GenerateTokenFailureAction = '[@daffodil/payment] Generate Token Failure Action',\n}\n\n/**\n * Generates a payment token.\n *\n * @param query The payment query.\n */\nexport interface DaffPaymentGenerateToken<T extends DaffPaymentRequest = DaffPaymentRequest> extends Action {\n readonly request: T;\n readonly address?: DaffPersonalAddress;\n}\n\n/**\n * Indicates a successful generation of a payment token.\n */\nexport class DaffPaymentGenerateTokenSuccess<T extends DaffPaymentResponse = DaffPaymentResponse> implements Action {\n readonly type = DaffPaymentActionTypes.GenerateTokenSuccessAction;\n\n constructor(public payload: T) {}\n}\n\n/**\n * A failed payment with the error message.\n */\nexport class DaffPaymentGenerateTokenFailure implements Action {\n readonly type = DaffPaymentActionTypes.GenerateTokenFailureAction;\n\n constructor(public payload: DaffStateError) {}\n}\n\n/**\n * A union of the payment action types.\n */\nexport type DaffPaymentActions<\n T extends DaffPaymentResponse = DaffPaymentResponse,\n R extends DaffPaymentRequest = DaffPaymentRequest,\n> =\n | DaffPaymentGenerateToken<R>\n | DaffPaymentGenerateTokenSuccess<T>\n | DaffPaymentGenerateTokenFailure;\n","/**\n * The key under which the payment feature state will be stored.\n */\nexport const DAFF_PAYMENT_STORE_FEATURE_KEY = 'daffPayment';\n","import {\n InjectionToken,\n Provider,\n} from '@angular/core';\nimport { ActionReducer } from '@ngrx/store';\n\nimport { DaffPaymentReducersState } from '../reducers.interface';\n\n/**\n * A token to hold the injectable extra reducers.\n *\n * Prefer using {@link daffPaymentProvideExtraReducers}.\n */\nexport const DAFF_PAYMENT_EXTRA_REDUCERS = new InjectionToken<ActionReducer<DaffPaymentReducersState>[]>(\n 'DAFF_PAYMENT_EXTRA_REDUCERS',\n {\n factory: () => [],\n providedIn: 'any',\n },\n);\n\n/**\n * Provides additional reducers that run after the standard Daffodil cart reducers.\n *\n * ```ts\n * providers: [\n * ...daffPaymentProvideExtraReducers(\n * myReducer1,\n * myReducer2\n * )\n * ]\n * ```\n */\nexport function daffPaymentProvideExtraReducers(\n ...reducers: ActionReducer<DaffPaymentReducersState>[]\n): Provider[] {\n return reducers.map(reducer => ({\n provide: DAFF_PAYMENT_EXTRA_REDUCERS,\n useValue: reducer,\n multi: true,\n }));\n}\n","import { DaffStateError } from '@daffodil/core/state';\n\nimport { DaffPaymentReducerState } from './interface';\n\n/**\n * Manages {@link DaffPaymentReducerState}.\n */\nexport class DaffPaymentStateReducerAdapter {\n\n /**\n * Begins the payment operation flow.\n * Sets loading to true.\n */\n generateToken(state: DaffPaymentReducerState): DaffPaymentReducerState {\n return {\n ...state,\n loading: true,\n };\n }\n\n /**\n * Sets loading to false and resets errors.\n */\n tokenGenerated(state: DaffPaymentReducerState): DaffPaymentReducerState {\n return {\n ...state,\n loading: false,\n errors: [],\n };\n }\n\n /**\n * Stores the from a failed payment.\n * Also sets loading to false.\n */\n storeError(error: DaffStateError, state: DaffPaymentReducerState): DaffPaymentReducerState {\n return {\n ...state,\n errors: [\n ...state.errors,\n error,\n ],\n loading: false,\n };\n }\n}\n","import { DaffPaymentReducerState } from './interface';\n\n/**\n * The initial state for the main payment state, see {@link DaffPaymentReducerState}.\n */\nexport const daffPaymentInitialState: DaffPaymentReducerState = {\n loading: false,\n errors: [],\n};\n","import { DaffPaymentResponse } from '@daffodil/payment';\n\nimport {\n DaffPaymentGenerateToken,\n DaffPaymentActionTypes,\n DaffPaymentActions,\n DaffPaymentGenerateTokenFailure,\n} from '../../actions/payment.actions';\nimport { DaffPaymentStateReducerAdapter } from './adapter';\nimport { daffPaymentInitialState } from './initial-state';\nimport { DaffPaymentReducerState } from './interface';\n\n/**\n * The reducer for the payment page state, see {@link DaffPaymentReducerState}.\n */\nexport const daffPaymentReducerFactory = <T extends DaffPaymentResponse = DaffPaymentResponse>(actions: DaffPaymentGenerateToken['type'][]) =>\n (\n state = daffPaymentInitialState,\n action: DaffPaymentActions<T>,\n ): DaffPaymentReducerState => {\n const adapter = new DaffPaymentStateReducerAdapter();\n switch (true) {\n case actions.includes(action.type):\n return adapter.generateToken(state);\n\n case action.type === DaffPaymentActionTypes.GenerateTokenSuccessAction:\n return adapter.tokenGenerated(state);\n\n case action.type === DaffPaymentActionTypes.GenerateTokenFailureAction:\n return adapter.storeError((<DaffPaymentGenerateTokenFailure>action).payload, state);\n\n default:\n return state;\n }\n };\n","import {\n createFeatureSelector,\n MemoizedSelector,\n} from '@ngrx/store';\n\nimport {\n DaffPaymentStateRootSlice,\n DaffPaymentReducersState,\n DAFF_PAYMENT_STORE_FEATURE_KEY,\n} from '../reducers/public_api';\n\n/**\n * Selector for the payment feature state.\n */\nexport interface DaffPaymentFeatureSelector {\n selectPaymentFeatureState: MemoizedSelector<DaffPaymentStateRootSlice, DaffPaymentReducersState>;\n}\n\nexport const getDaffPaymentReducersStateSelector = (() => {\n let cache;\n return (): DaffPaymentFeatureSelector =>\n cache = cache || {\n selectPaymentFeatureState: createFeatureSelector<DaffPaymentReducersState>(DAFF_PAYMENT_STORE_FEATURE_KEY),\n };\n})();\n","import {\n createSelector,\n MemoizedSelector,\n} from '@ngrx/store';\n\nimport { DaffStateError } from '@daffodil/core/state';\n\nimport { DaffPaymentStateRootSlice } from '../reducers/public_api';\nimport { getDaffPaymentReducersStateSelector } from './feature.selector';\n\n/**\n * Selectors for the main part of payment state.\n */\nexport interface DaffPaymentSelectors {\n /**\n * Selects whether there is a pending payment operation.\n */\n selectPaymentLoading: MemoizedSelector<DaffPaymentStateRootSlice, boolean>;\n /**\n * Selects the list of payment errors, if any.\n */\n selectPaymentErrors: MemoizedSelector<DaffPaymentStateRootSlice, DaffStateError[]>;\n}\n\n/**\n * Creates a group of selectors for {@link DaffPaymentReducerState} that use the passed state selector as the basis.\n */\nconst daffPaymentCreateSelectors = () => {\n const { selectPaymentFeatureState } = getDaffPaymentReducersStateSelector();\n const selectPaymentState = createSelector(\n selectPaymentFeatureState,\n state => state.payment,\n );\n\n const selectPaymentLoading = createSelector(\n selectPaymentState,\n state => state.loading,\n );\n\n const selectPaymentErrors = createSelector(\n selectPaymentState,\n state => state.errors,\n );\n\n return {\n selectPaymentLoading,\n selectPaymentErrors,\n };\n};\n\n\nexport const daffPaymentGetSelectors = (() => {\n let cache;\n return (): DaffPaymentSelectors =>\n cache = cache || daffPaymentCreateSelectors();\n})();\n\n","import { Injectable } from '@angular/core';\nimport {\n Action,\n Store,\n select,\n} from '@ngrx/store';\nimport { Observable } from 'rxjs';\n\nimport { DaffStateError } from '@daffodil/core/state';\n\nimport { DaffPaymentStateRootSlice } from '../../reducers/public_api';\nimport { daffPaymentGetSelectors } from '../../selectors/public_api';\nimport { DaffPaymentPageFacadeInterface } from './interface';\n\n/**\n * @inheritdoc\n *\n * Serves as the base for a payment facade.\n * Extend this class and pass in the selectors for the specific state you wish to target.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffPaymentPageFacade implements DaffPaymentPageFacadeInterface {\n loading$: Observable<boolean>;\n errors$: Observable<DaffStateError[]>;\n\n constructor(\n private store: Store<DaffPaymentStateRootSlice>,\n ) {\n const {\n selectPaymentLoading,\n selectPaymentErrors,\n } = daffPaymentGetSelectors();\n\n this.loading$ = this.store.pipe(select(selectPaymentLoading));\n this.errors$ = this.store.pipe(select(selectPaymentErrors));\n }\n\n dispatch(action: Action) {\n this.store.dispatch(action);\n }\n}\n","import {\n InjectionToken,\n ValueProvider,\n} from '@angular/core';\n\nimport { DaffPaymentAvailableProcessor } from '../models/public_api';\n\n/**\n * A multi-provider injection token for registering payment processors.\n */\nexport const DAFF_PAYMENT_AVAILABLE_PROCESSORS = new InjectionToken<DaffPaymentAvailableProcessor[]>(\n 'DAFF_PAYMENT_AVAILABLE_PROCESSORS',\n {\n factory: () => [],\n providedIn: 'any',\n },\n);\n\n/**\n * Provides a payment processor registration.\n *\n * See {@link DaffPaymentAvailableProcessor}.\n */\nexport const daffPaymentProvideAvailableProcessors = (...processors: DaffPaymentAvailableProcessor[]): ValueProvider[] =>\n processors.map(processor => ({\n provide: DAFF_PAYMENT_AVAILABLE_PROCESSORS,\n useValue: processor,\n multi: true,\n }));\n","import {\n inject,\n InjectionToken,\n} from '@angular/core';\n\nimport { daffArrayToDict } from '@daffodil/core';\n\nimport { DaffPaymentProcessorCollection } from '../models/public_api';\nimport { DAFF_PAYMENT_AVAILABLE_PROCESSORS } from './available-processors.token';\n\n/**\n * An internal token to combine the available payment processors into a single collection.\n */\nexport const DAFF_PAYMENT_PROCESSOR_COLLECTION = new InjectionToken<DaffPaymentProcessorCollection>(\n 'DAFF_PAYMENT_PROCESSOR_COLLECTION',\n {\n factory: () => {\n const processors = inject(DAFF_PAYMENT_AVAILABLE_PROCESSORS);\n return daffArrayToDict(processors, ({ kind }) => kind);\n },\n },\n);\n","import {\n inject,\n InjectionToken,\n} from '@angular/core';\nimport {\n ActionReducer,\n combineReducers,\n} from '@ngrx/store';\n\nimport { daffComposeReducers } from '@daffodil/core/state';\n// these unused imports are a workaround\nimport { DaffPaymentResponse } from '@daffodil/payment';\n\nimport { DAFF_PAYMENT_AVAILABLE_PROCESSORS } from '../../injection-tokens/public_api';\nimport { daffPaymentReducerFactory } from '../payment/reducer';\nimport { DaffPaymentReducersState } from '../reducers.interface';\nimport { DAFF_PAYMENT_EXTRA_REDUCERS } from './extra.token';\n\n/**\n * An internal token to hold the Daffodil payment reducers.\n * Includes the extra and standard reducers.\n *\n * @docs-private\n */\nexport const DAFF_PAYMENT_REDUCERS = new InjectionToken<ActionReducer<DaffPaymentReducersState>>(\n 'DAFF_PAYMENT_REDUCERS',\n {\n providedIn: 'any',\n factory: () => daffComposeReducers([\n combineReducers({\n payment: daffPaymentReducerFactory(inject(DAFF_PAYMENT_AVAILABLE_PROCESSORS).map(({ action }) => action)),\n }),\n ...inject(DAFF_PAYMENT_EXTRA_REDUCERS),\n ]),\n },\n);\n","import { NgModule } from '@angular/core';\nimport { StoreModule } from '@ngrx/store';\n\nimport { DAFF_PAYMENT_STORE_FEATURE_KEY } from './reducers/public_api';\nimport { DAFF_PAYMENT_REDUCERS } from './reducers/token/reducers.token';\n\n/**\n * Creates the payment feature store.\n */\n@NgModule({\n imports: [\n StoreModule.forFeature(DAFF_PAYMENT_STORE_FEATURE_KEY, DAFF_PAYMENT_REDUCERS),\n ],\n})\nexport class DaffPaymentStateModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AASA;;AAEG;AACS,IAAA,uBAGX;AAHD,CAAA,UAAY,sBAAsB,EAAA;AAChC,IAAA,sBAAA,CAAA,4BAAA,CAAA,GAAA,mDAAgF,CAAA;AAChF,IAAA,sBAAA,CAAA,4BAAA,CAAA,GAAA,mDAAgF,CAAA;AAClF,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,GAGjC,EAAA,CAAA,CAAA,CAAA;AAYD;;AAEG;MACU,+BAA+B,CAAA;AAG1C,IAAA,WAAA,CAAmB,OAAU,EAAA;AAAV,QAAA,IAAO,CAAA,OAAA,GAAP,OAAO,CAAG;AAFpB,QAAA,IAAA,CAAA,IAAI,GAAG,sBAAsB,CAAC,0BAA0B,CAAC;KAEjC;AAClC,CAAA;AAED;;AAEG;MACU,+BAA+B,CAAA;AAG1C,IAAA,WAAA,CAAmB,OAAuB,EAAA;AAAvB,QA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,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;uIAAtB,sBAAsB,EAAA,OAAA,EAAA,CAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,CAAA,CAAA;AAAtB,mBAAA,sBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,sBAAsB,EAJxB,OAAA,EAAA,CAAA;AACP,YAAA,WAAW,CAAC,UAAU,CAAC,8BAA8B,EAAE,qBAAqB,CAAC;SAC9E,CAAA,EAAA,CAAA,CAAA;2FAEU,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBALlC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;AACP,wBAAA,WAAW,CAAC,UAAU,CAAC,8BAA8B,EAAE,qBAAqB,CAAC;AAC9E,qBAAA;iBACF,CAAA;;;ACbD;;AAEG;;;;"}
@@ -0,0 +1,154 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, InjectionToken, inject, Inject, NgModule } from '@angular/core';
3
+ import * as faker from '@faker-js/faker/locale/en_US';
4
+ import { DaffModelFactory } from '@daffodil/core/testing';
5
+ import { sample } from '@daffodil/core';
6
+
7
+ /**
8
+ * Mock class for {@link DaffPaymentResponse}.
9
+ */
10
+ class MockPaymentResponse {
11
+ constructor() {
12
+ this.method = faker.random.word();
13
+ this.data = faker.random.word();
14
+ }
15
+ }
16
+ ;
17
+ /**
18
+ * Model factory for {@link DaffPaymentResponse}.
19
+ */
20
+ class DaffPaymentResponseFactory extends DaffModelFactory {
21
+ constructor() {
22
+ super(MockPaymentResponse);
23
+ }
24
+ }
25
+ /** @nocollapse */ DaffPaymentResponseFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentResponseFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
26
+ /** @nocollapse */ DaffPaymentResponseFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentResponseFactory, providedIn: 'root' });
27
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentResponseFactory, decorators: [{
28
+ type: Injectable,
29
+ args: [{
30
+ providedIn: 'root',
31
+ }]
32
+ }], ctorParameters: function () { return []; } });
33
+
34
+ /**
35
+ * Mock class for {@link DaffPaymentRequest}.
36
+ */
37
+ class MockPaymentRequest {
38
+ constructor() {
39
+ this.kind = faker.random.word();
40
+ this.data = faker.random.word();
41
+ }
42
+ }
43
+ ;
44
+ /**
45
+ * Model factory for {@link DaffPaymentRequest}.
46
+ */
47
+ class DaffPaymentRequestFactory extends DaffModelFactory {
48
+ constructor() {
49
+ super(MockPaymentRequest);
50
+ }
51
+ }
52
+ /** @nocollapse */ DaffPaymentRequestFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentRequestFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
53
+ /** @nocollapse */ DaffPaymentRequestFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentRequestFactory, providedIn: 'root' });
54
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentRequestFactory, decorators: [{
55
+ type: Injectable,
56
+ args: [{
57
+ providedIn: 'root',
58
+ }]
59
+ }], ctorParameters: function () { return []; } });
60
+
61
+ /**
62
+ * A multi-provider injection token for providing extra payment result kind factories.
63
+ * These factories correspond to different types of payment results that may be added by other packages.
64
+ * This is useful for backend mocks (such as the testing driver) to generate an accurate representation
65
+ * of the variety of results that an application can receive in production.
66
+ */
67
+ const DAFF_PAYMENT_RESPONSE_KIND_FACTORIES = new InjectionToken('DAFF_PAYMENT_RESPONSE_KIND_FACTORIES', { factory: () => [inject(DaffPaymentResponseFactory)], providedIn: 'root' });
68
+ /**
69
+ * Provides extra payment result factory kinds.
70
+ *
71
+ * See {@link DAFF_PAYMENT_RESPONSE_KIND_FACTORIES}.
72
+ *
73
+ * ```ts
74
+ * providers: [
75
+ * ...daffProvidePaymentResponseKindFactories(
76
+ * MyPaymentResponseFactory
77
+ * )
78
+ * ]
79
+ * ```
80
+ */
81
+ function daffProvidePaymentResponseKindFactories(...factoryTypes) {
82
+ return factoryTypes.map(factoryType => ({
83
+ provide: DAFF_PAYMENT_RESPONSE_KIND_FACTORIES,
84
+ useExisting: factoryType,
85
+ multi: true,
86
+ }));
87
+ }
88
+
89
+ /**
90
+ * Factory for creating DaffPaymentResponses.
91
+ * This will create a payment response of random kind.
92
+ */
93
+ class DaffPaymentResponseKindFactory extends DaffModelFactory {
94
+ constructor(kindFactories) {
95
+ super(MockPaymentResponse);
96
+ this.kindFactories = kindFactories;
97
+ }
98
+ get _randomFactory() {
99
+ return sample(this.kindFactories);
100
+ }
101
+ /**
102
+ * Creates a payment result of random kind.
103
+ */
104
+ create(partial = {}) {
105
+ return this._randomFactory.create(partial);
106
+ }
107
+ }
108
+ /** @nocollapse */ DaffPaymentResponseKindFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentResponseKindFactory, deps: [{ token: DAFF_PAYMENT_RESPONSE_KIND_FACTORIES }], target: i0.ɵɵFactoryTarget.Injectable });
109
+ /** @nocollapse */ DaffPaymentResponseKindFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentResponseKindFactory, providedIn: 'root' });
110
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentResponseKindFactory, decorators: [{
111
+ type: Injectable,
112
+ args: [{
113
+ providedIn: 'root',
114
+ }]
115
+ }], ctorParameters: function () {
116
+ return [{ type: undefined, decorators: [{
117
+ type: Inject,
118
+ args: [DAFF_PAYMENT_RESPONSE_KIND_FACTORIES]
119
+ }] }];
120
+ } });
121
+
122
+ /**
123
+ * Provides the default payment result factory as a payment result type factory.
124
+ */
125
+ class DaffPaymentTestingModule {
126
+ }
127
+ /** @nocollapse */ DaffPaymentTestingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
128
+ /** @nocollapse */ DaffPaymentTestingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentTestingModule });
129
+ /** @nocollapse */ DaffPaymentTestingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentTestingModule, providers: [
130
+ {
131
+ provide: DAFF_PAYMENT_RESPONSE_KIND_FACTORIES,
132
+ useExisting: DaffPaymentResponseFactory,
133
+ multi: true,
134
+ },
135
+ ] });
136
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentTestingModule, decorators: [{
137
+ type: NgModule,
138
+ args: [{
139
+ providers: [
140
+ {
141
+ provide: DAFF_PAYMENT_RESPONSE_KIND_FACTORIES,
142
+ useExisting: DaffPaymentResponseFactory,
143
+ multi: true,
144
+ },
145
+ ],
146
+ }]
147
+ }] });
148
+
149
+ /**
150
+ * Generated bundle index. Do not edit.
151
+ */
152
+
153
+ export { DAFF_PAYMENT_RESPONSE_KIND_FACTORIES, DaffPaymentRequestFactory, DaffPaymentResponseFactory, DaffPaymentResponseKindFactory, DaffPaymentTestingModule, MockPaymentRequest, MockPaymentResponse, daffProvidePaymentResponseKindFactories };
154
+ //# sourceMappingURL=daffodil-payment-testing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daffodil-payment-testing.mjs","sources":["../../../libs/payment/testing/src/factories/payment-response.factory.ts","../../../libs/payment/testing/src/factories/payment-request.factory.ts","../../../libs/payment/testing/src/injection-tokens/factories/kind.token.ts","../../../libs/payment/testing/src/factories/kind.factory.ts","../../../libs/payment/testing/src/testing.module.ts","../../../libs/payment/testing/src/daffodil-payment-testing.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffPaymentResponse } from '@daffodil/payment';\n\n/**\n * Mock class for {@link DaffPaymentResponse}.\n */\nexport class MockPaymentResponse implements DaffPaymentResponse {\n method = faker.random.word();\n data = faker.random.word();\n};\n\n/**\n * Model factory for {@link DaffPaymentResponse}.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffPaymentResponseFactory extends DaffModelFactory<DaffPaymentResponse>{\n constructor() {\n super(MockPaymentResponse);\n }\n}\n","import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffPaymentRequest } from '@daffodil/payment';\n\n/**\n * Mock class for {@link DaffPaymentRequest}.\n */\nexport class MockPaymentRequest implements DaffPaymentRequest {\n kind = faker.random.word();\n data = faker.random.word();\n};\n\n/**\n * Model factory for {@link DaffPaymentRequest}.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffPaymentRequestFactory extends DaffModelFactory<DaffPaymentRequest>{\n constructor() {\n super(MockPaymentRequest);\n }\n}\n","import {\n inject,\n InjectionToken,\n Provider,\n Type,\n} from '@angular/core';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffPaymentResponse } from '@daffodil/payment';\n\nimport { DaffPaymentResponseFactory } from '../../factories/payment-response.factory';\n\n/**\n * A multi-provider injection token for providing extra payment result kind factories.\n * These factories correspond to different types of payment results that may be added by other packages.\n * This is useful for backend mocks (such as the testing driver) to generate an accurate representation\n * of the variety of results that an application can receive in production.\n */\nexport const DAFF_PAYMENT_RESPONSE_KIND_FACTORIES = new InjectionToken<DaffModelFactory<DaffPaymentResponse>[]>(\n 'DAFF_PAYMENT_RESPONSE_KIND_FACTORIES',\n { factory: () => [inject(DaffPaymentResponseFactory)], providedIn: 'root' },\n);\n\n/**\n * Provides extra payment result factory kinds.\n *\n * See {@link DAFF_PAYMENT_RESPONSE_KIND_FACTORIES}.\n *\n * ```ts\n * providers: [\n * ...daffProvidePaymentResponseKindFactories(\n * MyPaymentResponseFactory\n * )\n * ]\n * ```\n */\nexport function daffProvidePaymentResponseKindFactories<T extends DaffPaymentResponse = DaffPaymentResponse>(...factoryTypes: Type<DaffModelFactory<T>>[]): Provider[] {\n return factoryTypes.map(factoryType => ({\n provide: DAFF_PAYMENT_RESPONSE_KIND_FACTORIES,\n useExisting: factoryType,\n multi: true,\n }));\n}\n","import {\n Injectable,\n Inject,\n} from '@angular/core';\n\nimport { sample } from '@daffodil/core';\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffPaymentResponse } from '@daffodil/payment';\n\nimport { DAFF_PAYMENT_RESPONSE_KIND_FACTORIES } from '../injection-tokens/factories/kind.token';\nimport { MockPaymentResponse } from './payment-response.factory';\n\n/**\n * Factory for creating DaffPaymentResponses.\n * This will create a payment response of random kind.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffPaymentResponseKindFactory extends DaffModelFactory<DaffPaymentResponse> {\n constructor(\n @Inject(DAFF_PAYMENT_RESPONSE_KIND_FACTORIES) private kindFactories: DaffModelFactory<DaffPaymentResponse>[],\n ) {\n super(MockPaymentResponse);\n }\n\n private get _randomFactory(): DaffModelFactory<DaffPaymentResponse> {\n return sample(this.kindFactories);\n }\n\n /**\n * Creates a payment result of random kind.\n */\n create(partial = {}): DaffPaymentResponse {\n return this._randomFactory.create(partial);\n }\n}\n","import { NgModule } from '@angular/core';\n\nimport { DaffPaymentResponseFactory } from './factories/public_api';\nimport { DAFF_PAYMENT_RESPONSE_KIND_FACTORIES } from './injection-tokens/public_api';\n\n/**\n * Provides the default payment result factory as a payment result type factory.\n */\n@NgModule({\n providers: [\n {\n provide: DAFF_PAYMENT_RESPONSE_KIND_FACTORIES,\n useExisting: DaffPaymentResponseFactory,\n multi: true,\n },\n ],\n})\nexport class DaffPaymentTestingModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAMA;;AAEG;MACU,mBAAmB,CAAA;AAAhC,IAAA,WAAA,GAAA;QACE,IAAA,CAAA,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAA,CAAA,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;KAC5B;AAAA,CAAA;AAAA,CAAC;AAEF;;AAEG;AAIG,MAAO,0BAA2B,SAAQ,gBAAqC,CAAA;AACnF,IAAA,WAAA,GAAA;QACE,KAAK,CAAC,mBAAmB,CAAC,CAAC;KAC5B;;0IAHU,0BAA0B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAA1B,mBAAA,0BAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,0BAA0B,cAFzB,MAAM,EAAA,CAAA,CAAA;2FAEP,0BAA0B,EAAA,UAAA,EAAA,CAAA;kBAHtC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;iBACnB,CAAA;;;ACbD;;AAEG;MACU,kBAAkB,CAAA;AAA/B,IAAA,WAAA,GAAA;QACE,IAAA,CAAA,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,I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A,EAAA,wBAAwB,EARxB,SAAA,EAAA;AACT,QAAA;AACE,YAAA,OAAO,EAAE,oCAAoC;AAC7C,YAAA,WAAW,EAAE,0BAA0B;AACvC,YAAA,KAAK,EAAE,IAAI;AACZ,SAAA;AACF,KAAA,EAAA,CAAA,CAAA;2FAEU,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBATpC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,SAAS,EAAE;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,oCAAoC;AAC7C,4BAAA,WAAW,EAAE,0BAA0B;AACvC,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;AACF,qBAAA;iBACF,CAAA;;;AChBD;;AAEG;;;;"}
@@ -0,0 +1,15 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { daffTransformErrorToStateError } from '@daffodil/core/state';
3
+
4
+ /**
5
+ * Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
6
+ * Can be used to further refine Daffodil errors into more specific app errors.
7
+ */
8
+ const DAFF_PAYMENT_ERROR_MATCHER = new InjectionToken('DAFF_PAYMENT_ERROR_MATCHER', { factory: () => daffTransformErrorToStateError });
9
+
10
+ /**
11
+ * Generated bundle index. Do not edit.
12
+ */
13
+
14
+ export { DAFF_PAYMENT_ERROR_MATCHER };
15
+ //# sourceMappingURL=daffodil-payment.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daffodil-payment.mjs","sources":["../../../libs/payment/src/injection-tokens/error-matcher.token.ts","../../../libs/payment/src/daffodil-payment.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nimport { daffTransformErrorToStateError } from '@daffodil/core/state';\n\n/**\n * Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.\n * Can be used to further refine Daffodil errors into more specific app errors.\n */\nexport const DAFF_PAYMENT_ERROR_MATCHER = new InjectionToken<typeof daffTransformErrorToStateError>(\n 'DAFF_PAYMENT_ERROR_MATCHER',\n { factory: () => daffTransformErrorToStateError },\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAIA;;;AAGG;AACU,MAAA,0BAA0B,GAAG,IAAI,cAAc,CAC1D,4BAA4B,EAC5B,EAAE,OAAO,EAAE,MAAM,8BAA8B,EAAE;;ACVnD;;AAEG;;;;"}
@@ -0,0 +1,121 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, NgModule } from '@angular/core';
3
+ import { STATUS } from 'angular-in-memory-web-api';
4
+ import * as i1 from '@daffodil/payment/testing';
5
+ import { DaffPaymentTestingModule } from '@daffodil/payment/testing';
6
+ import * as i1$1 from '@angular/common/http';
7
+ import { CommonModule } from '@angular/common';
8
+ import { DaffPaymentDriver } from '@daffodil/payment/driver';
9
+
10
+ /**
11
+ * An in-memory service that delegates payment queries to child backends
12
+ * via the {@link DAFF_PAYMENT_IN_MEMORY_BACKENDS}.
13
+ */
14
+ class DaffPaymentInMemoryBackendService {
15
+ constructor(factory) {
16
+ this.factory = factory;
17
+ }
18
+ /**
19
+ * Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.
20
+ *
21
+ * @param url initial url
22
+ * @param utils utility to parse url
23
+ * @returns ParsedRequestUrl
24
+ * @docs-private
25
+ */
26
+ parseRequestUrl(url, utils) {
27
+ return utils.parseRequestUrl(url);
28
+ }
29
+ /**
30
+ * @docs-private
31
+ */
32
+ createDb() {
33
+ return {};
34
+ }
35
+ /**
36
+ * Generates a token from a processor backend.
37
+ *
38
+ * @param reqInfo request object
39
+ * @returns An http response object
40
+ */
41
+ get(reqInfo) {
42
+ return reqInfo.utils.createResponse$(() => ({
43
+ status: STATUS.OK,
44
+ body: this.factory.create(),
45
+ }));
46
+ }
47
+ }
48
+ /** @nocollapse */ DaffPaymentInMemoryBackendService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentInMemoryBackendService, deps: [{ token: i1.DaffPaymentResponseKindFactory }], target: i0.ɵɵFactoryTarget.Injectable });
49
+ /** @nocollapse */ DaffPaymentInMemoryBackendService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentInMemoryBackendService, providedIn: 'root' });
50
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentInMemoryBackendService, decorators: [{
51
+ type: Injectable,
52
+ args: [{
53
+ providedIn: 'root',
54
+ }]
55
+ }], ctorParameters: function () { return [{ type: i1.DaffPaymentResponseKindFactory }]; } });
56
+
57
+ /**
58
+ * The payment inmemory driver to mock the payment backend service.
59
+ *
60
+ * @inheritdoc
61
+ */
62
+ class DaffPaymentInMemoryDriver {
63
+ constructor(http) {
64
+ this.http = http;
65
+ /**
66
+ * @docs-private
67
+ */
68
+ this.url = '/api/payment';
69
+ }
70
+ generateToken(request) {
71
+ return this.http.get(this.url);
72
+ }
73
+ }
74
+ /** @nocollapse */ DaffPaymentInMemoryDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentInMemoryDriver, deps: [{ token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
75
+ /** @nocollapse */ DaffPaymentInMemoryDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentInMemoryDriver, providedIn: 'root' });
76
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentInMemoryDriver, decorators: [{
77
+ type: Injectable,
78
+ args: [{
79
+ providedIn: 'root',
80
+ }]
81
+ }], ctorParameters: function () { return [{ type: i1$1.HttpClient }]; } });
82
+
83
+ /**
84
+ * Provides the {@link DaffPaymentInMemoryDriver} as the {@link DaffPaymentDriver}.
85
+ */
86
+ class DaffPaymentInMemoryDriverModule {
87
+ static forRoot() {
88
+ return {
89
+ ngModule: DaffPaymentInMemoryDriverModule,
90
+ providers: [
91
+ {
92
+ provide: DaffPaymentDriver,
93
+ useExisting: DaffPaymentInMemoryDriver,
94
+ },
95
+ ],
96
+ };
97
+ }
98
+ }
99
+ /** @nocollapse */ DaffPaymentInMemoryDriverModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentInMemoryDriverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
100
+ /** @nocollapse */ DaffPaymentInMemoryDriverModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentInMemoryDriverModule, imports: [CommonModule,
101
+ DaffPaymentTestingModule] });
102
+ /** @nocollapse */ DaffPaymentInMemoryDriverModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentInMemoryDriverModule, imports: [[
103
+ CommonModule,
104
+ DaffPaymentTestingModule,
105
+ ]] });
106
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffPaymentInMemoryDriverModule, decorators: [{
107
+ type: NgModule,
108
+ args: [{
109
+ imports: [
110
+ CommonModule,
111
+ DaffPaymentTestingModule,
112
+ ],
113
+ }]
114
+ }] });
115
+
116
+ /**
117
+ * Generated bundle index. Do not edit.
118
+ */
119
+
120
+ export { DaffPaymentInMemoryBackendService, DaffPaymentInMemoryDriver, DaffPaymentInMemoryDriverModule };
121
+ //# sourceMappingURL=daffodil-payment-driver-in-memory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daffodil-payment-driver-in-memory.mjs","sources":["../../../libs/payment/driver/in-memory/src/backend/payment.service.ts","../../../libs/payment/driver/in-memory/src/driver/payment.service.ts","../../../libs/payment/driver/in-memory/src/driver/payment-driver.module.ts","../../../libs/payment/driver/in-memory/src/daffodil-payment-driver-in-memory.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport {\n InMemoryDbService,\n RequestInfoUtilities,\n ParsedRequestUrl,\n STATUS,\n RequestInfo,\n} from 'angular-in-memory-web-api';\n\nimport { DaffPaymentResponseKindFactory } from '@daffodil/payment/testing';\n\n/**\n * An in-memory service that delegates payment queries to child backends\n * via the {@link DAFF_PAYMENT_IN_MEMORY_BACKENDS}.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffPaymentInMemoryBackendService implements InMemoryDbService {\n constructor(\n private factory: DaffPaymentResponseKindFactory,\n ) {}\n\n /**\n * Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.\n *\n * @param url initial url\n * @param utils utility to parse url\n * @returns ParsedRequestUrl\n * @docs-private\n */\n parseRequestUrl(url: string, utils: RequestInfoUtilities): ParsedRequestUrl {\n return utils.parseRequestUrl(url);\n }\n\n /**\n * @docs-private\n */\n createDb(): any {\n return {};\n }\n\n /**\n * Generates a token from a processor backend.\n *\n * @param reqInfo request object\n * @returns An http response object\n */\n get(reqInfo: RequestInfo) {\n return reqInfo.utils.createResponse$(() => ({\n status: STATUS.OK,\n body: this.factory.create(),\n }));\n }\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nimport {\n DaffPaymentRequest,\n DaffPaymentResponse,\n} from '@daffodil/payment';\nimport { DaffPaymentDriverInterface } from '@daffodil/payment/driver';\n\n/**\n * The payment inmemory driver to mock the payment backend service.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffPaymentInMemoryDriver implements DaffPaymentDriverInterface {\n /**\n * @docs-private\n */\n url = '/api/payment';\n\n constructor(\n private http: HttpClient,\n ) {}\n\n generateToken(request: DaffPaymentRequest): Observable<DaffPaymentResponse> {\n return this.http.get<DaffPaymentResponse>(this.url);\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { DaffPaymentDriver } from '@daffodil/payment/driver';\nimport { DaffPaymentTestingModule } from '@daffodil/payment/testing';\n\nimport { DaffPaymentInMemoryDriver } from './payment.service';\n\n/**\n * Provides the {@link DaffPaymentInMemoryDriver} as the {@link DaffPaymentDriver}.\n */\n@NgModule({\n imports: [\n CommonModule,\n DaffPaymentTestingModule,\n ],\n})\nexport class DaffPaymentInMemoryDriverModule {\n static forRoot(): ModuleWithProviders<DaffPaymentInMemoryDriverModule> {\n return {\n ngModule: DaffPaymentInMemoryDriverModule,\n providers: [\n {\n provide: DaffPaymentDriver,\n useExisting: DaffPaymentInMemoryDriver,\n },\n ],\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;;;AAWA;;;AAGG;MAIU,iCAAiC,CAAA;AAC5C,IAAA,WAAA,CACU,OAAuC,EAAA;QAAvC,IAAO,CAAA,OAAA,GAAP,OAAO,CAAgC;KAC7C;AAEJ;;;;;;;AAOG;IACH,eAAe,CAAC,GAAW,EAAE,KAA2B,EAAA;AACtD,QAAA,OAAO,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;KACnC;AAED;;AAEG;IACH,QAAQ,GAAA;AACN,QAAA,OAAO,EAAE,CAAC;KACX;AAED;;;;;AAKG;AACH,IAAA,GAAG,CAAC,OAAoB,EAAA;QACtB,OAAO,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO;YAC1C,MAAM,EAAE,MAAM,CAAC,EAAE;AACjB,YAAA,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;AAC5B,SAAA,CAAC,CAAC,CAAC;KACL;;iJAnCU,iCAAiC,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAjC,mBAAA,iCAAA,CAA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