@daffodil/payment 0.94.1 → 0.95.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.
- package/fesm2022/daffodil-payment-driver-in-memory.mjs +151 -118
- package/fesm2022/daffodil-payment-driver-in-memory.mjs.map +1 -1
- package/fesm2022/daffodil-payment-driver-testing.mjs +93 -60
- package/fesm2022/daffodil-payment-driver-testing.mjs.map +1 -1
- package/fesm2022/daffodil-payment-driver.mjs +12 -35
- package/fesm2022/daffodil-payment-driver.mjs.map +1 -1
- package/fesm2022/daffodil-payment-state-testing.mjs +85 -49
- package/fesm2022/daffodil-payment-state-testing.mjs.map +1 -1
- package/fesm2022/daffodil-payment-state.mjs +154 -238
- package/fesm2022/daffodil-payment-state.mjs.map +1 -1
- package/fesm2022/daffodil-payment-testing.mjs +178 -139
- package/fesm2022/daffodil-payment-testing.mjs.map +1 -1
- package/fesm2022/daffodil-payment.mjs +0 -4
- package/package.json +1 -1
- package/types/daffodil-payment-driver-in-memory.d.ts +54 -54
- package/types/daffodil-payment-driver-testing.d.ts +25 -23
- package/types/daffodil-payment-driver.d.ts +17 -25
- package/types/daffodil-payment-state-testing.d.ts +22 -19
- package/types/daffodil-payment-state.d.ts +114 -131
- package/types/daffodil-payment-testing.d.ts +37 -39
- package/types/daffodil-payment.d.ts +20 -23
- package/fesm2022/daffodil-payment.mjs.map +0 -1
|
@@ -1 +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/injection-tokens/error-matcher.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 { DaffIdentifiable } from '@daffodil/core';\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 DaffPaymentGenerateTokenPayload<T extends DaffPaymentRequest = DaffPaymentRequest> {\n readonly request: T;\n readonly address?: DaffPersonalAddress | DaffIdentifiable;\n}\nexport interface DaffPaymentGenerateToken<T extends DaffPaymentRequest = DaffPaymentRequest> extends DaffPaymentGenerateTokenPayload<T>, Action {}\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> =\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 { ActionReducer } from '@ngrx/store';\n\nimport { createMultiInjectionToken } from '@daffodil/core';\n\nimport { DaffPaymentReducersState } from '../reducers.interface';\n\nexport const {\n /**\n * A token to hold the injectable extra reducers.\n *\n * Prefer using {@link daffPaymentProvideExtraReducers}.\n */\n token: DAFF_PAYMENT_EXTRA_REDUCERS,\n\n /**\n * Provides additional reducers that run after the standard Daffodil cart reducers.\n *\n * @example\n * ```ts\n * providers: [\n * ...daffPaymentProvideExtraReducers(\n * myReducer1,\n * myReducer2\n * )\n * ]\n * ```\n */\n provider: daffPaymentProvideExtraReducers,\n} = createMultiInjectionToken<ActionReducer<DaffPaymentReducersState>>(\n 'DAFF_PAYMENT_EXTRA_REDUCERS',\n { providedIn: 'any' },\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(errors: DaffStateError[], state: DaffPaymentReducerState): DaffPaymentReducerState {\n return {\n ...state,\n errors,\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 { DaffPaymentStateReducerAdapter } from './adapter';\nimport { daffPaymentInitialState } from './initial-state';\nimport { DaffPaymentReducerState } from './interface';\nimport {\n DaffPaymentGenerateToken,\n DaffPaymentActionTypes,\n DaffPaymentActions,\n DaffPaymentGenerateTokenFailure,\n} from '../../actions/payment.actions';\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 defaultMemoize,\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: () => DaffPaymentFeatureSelector = defaultMemoize(() => ({\n selectPaymentFeatureState: createFeatureSelector<DaffPaymentReducersState>(DAFF_PAYMENT_STORE_FEATURE_KEY),\n})).memoized;\n","import {\n createSelector,\n MemoizedSelector,\n defaultMemoize,\n} from '@ngrx/store';\n\nimport { DaffStateError } from '@daffodil/core/state';\n\nimport { getDaffPaymentReducersStateSelector } from './feature.selector';\nimport { DaffPaymentStateRootSlice } from '../reducers/public_api';\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: () => DaffPaymentSelectors = defaultMemoize(() => daffPaymentCreateSelectors()).memoized;\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 { DaffPaymentPageFacadeInterface } from './interface';\nimport { DaffPaymentStateRootSlice } from '../../reducers/public_api';\nimport { daffPaymentGetSelectors } from '../../selectors/public_api';\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 { createMultiInjectionToken } from '@daffodil/core';\n\nimport { DaffPaymentAvailableProcessor } from '../models/public_api';\n\nexport const {\n /**\n * A multi-provider injection token for registering payment processors.\n */\n token: DAFF_PAYMENT_AVAILABLE_PROCESSORS,\n\n /**\n * Provides a payment processor registration.\n *\n * See {@link DaffPaymentAvailableProcessor}.\n */\n provider: daffPaymentProvideAvailableProcessors,\n} = createMultiInjectionToken<DaffPaymentAvailableProcessor>(\n 'DAFF_PAYMENT_AVAILABLE_PROCESSORS',\n { providedIn: 'any' },\n);\n","import { inject } from '@angular/core';\n\nimport {\n createSingleInjectionToken,\n daffArrayToDict,\n} from '@daffodil/core';\n\nimport { DAFF_PAYMENT_AVAILABLE_PROCESSORS } from './available-processors.token';\nimport { DaffPaymentProcessorCollection } from '../models/public_api';\n\nexport const {\n /**\n * An internal token to combine the available payment processors into a single collection.\n */\n token: DAFF_PAYMENT_PROCESSOR_COLLECTION,\n /**\n * Provider function for {@link DAFF_PAYMENT_PROCESSOR_COLLECTION}.\n */\n provider: provideDaffPaymentProcessorCollection,\n} = createSingleInjectionToken<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 { createSingleInjectionToken } from '@daffodil/core';\nimport { daffTransformErrorToStateError } from '@daffodil/core/state';\n\nexport const {\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 */\n token: DAFF_PAYMENT_ERROR_MATCHER,\n /**\n * Provider function for {@link DAFF_PAYMENT_ERROR_MATCHER}.\n */\n provider: provideDaffPaymentErrorMatcher,\n} = createSingleInjectionToken<typeof daffTransformErrorToStateError>(\n 'DAFF_PAYMENT_ERROR_MATCHER',\n { factory: () => daffTransformErrorToStateError },\n);\n","import { inject } from '@angular/core';\nimport {\n ActionReducer,\n combineReducers,\n} from '@ngrx/store';\n\nimport { createSingleInjectionToken } from '@daffodil/core';\nimport { daffComposeReducers } from '@daffodil/core/state';\n\nimport { DAFF_PAYMENT_EXTRA_REDUCERS } from './extra.token';\nimport { DAFF_PAYMENT_AVAILABLE_PROCESSORS } from '../../injection-tokens/public_api';\nimport { daffPaymentReducerFactory } from '../payment/reducer';\nimport { DaffPaymentReducersState } from '../reducers.interface';\n\nexport const {\n /**\n * An internal token to hold the Daffodil payment reducers.\n * Includes the extra and standard reducers.\n *\n * @docs-private\n */\n token: DAFF_PAYMENT_REDUCERS,\n /**\n * Provider function for {@link DAFF_PAYMENT_REDUCERS}.\n */\n provider: provideDaffPaymentReducers,\n} = createSingleInjectionToken<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":";;;;;;;AAUA;;AAEG;IACS;AAAZ,CAAA,UAAY,sBAAsB,EAAA;AAChC,IAAA,sBAAA,CAAA,4BAAA,CAAA,GAAA,mDAAgF;AAChF,IAAA,sBAAA,CAAA,4BAAA,CAAA,GAAA,mDAAgF;AAClF,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,GAAA,EAAA,CAAA,CAAA;AAgBlC;;AAEG;MACU,+BAA+B,CAAA;AAG1C,IAAA,WAAA,CAAmB,OAAU,EAAA;QAAV,IAAA,CAAA,OA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EAAE,qBAAqB,CAAC;AAC9E,qBAAA;AACF,iBAAA;;;ACbD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"daffodil-payment-state.mjs","names":[],"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/injection-tokens/error-matcher.token.ts","../../../libs/payment/state/src/reducers/token/reducers.token.ts","../../../libs/payment/state/src/payment.module.ts","../../../libs/payment/state/src/provider.ts"],"sourcesContent":["import { Action } from '@ngrx/store';\n\nimport { DaffIdentifiable } from '@daffodil/core';\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 DaffPaymentGenerateTokenPayload<T extends DaffPaymentRequest = DaffPaymentRequest> {\n readonly request: T;\n readonly address?: DaffPersonalAddress | DaffIdentifiable;\n}\nexport interface DaffPaymentGenerateToken<T extends DaffPaymentRequest = DaffPaymentRequest> extends DaffPaymentGenerateTokenPayload<T>, Action {}\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> =\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 { ActionReducer } from '@ngrx/store';\n\nimport { createMultiInjectionToken } from '@daffodil/core';\n\nimport { DaffPaymentReducersState } from '../reducers.interface';\n\nexport const {\n /**\n * A token to hold the injectable extra reducers.\n *\n * Prefer using {@link daffPaymentProvideExtraReducers}.\n */\n token: DAFF_PAYMENT_EXTRA_REDUCERS,\n\n /**\n * Provides additional reducers that run after the standard Daffodil cart reducers.\n *\n * @example\n * ```ts\n * providers: [\n * ...daffPaymentProvideExtraReducers(\n * myReducer1,\n * myReducer2\n * )\n * ]\n * ```\n */\n provider: daffPaymentProvideExtraReducers,\n} = createMultiInjectionToken<ActionReducer<DaffPaymentReducersState>>(\n 'DAFF_PAYMENT_EXTRA_REDUCERS',\n { providedIn: 'any' },\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(errors: DaffStateError[], state: DaffPaymentReducerState): DaffPaymentReducerState {\n return {\n ...state,\n errors,\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 { DaffPaymentStateReducerAdapter } from './adapter';\nimport { daffPaymentInitialState } from './initial-state';\nimport { DaffPaymentReducerState } from './interface';\nimport {\n DaffPaymentGenerateToken,\n DaffPaymentActionTypes,\n DaffPaymentActions,\n DaffPaymentGenerateTokenFailure,\n} from '../../actions/payment.actions';\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 defaultMemoize,\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: () => DaffPaymentFeatureSelector = defaultMemoize(() => ({\n selectPaymentFeatureState: createFeatureSelector<DaffPaymentReducersState>(DAFF_PAYMENT_STORE_FEATURE_KEY),\n})).memoized;\n","import {\n createSelector,\n MemoizedSelector,\n defaultMemoize,\n} from '@ngrx/store';\n\nimport { DaffStateError } from '@daffodil/core/state';\n\nimport { getDaffPaymentReducersStateSelector } from './feature.selector';\nimport { DaffPaymentStateRootSlice } from '../reducers/public_api';\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: () => DaffPaymentSelectors = defaultMemoize(() => daffPaymentCreateSelectors()).memoized;\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 { DaffPaymentPageFacadeInterface } from './interface';\nimport { DaffPaymentStateRootSlice } from '../../reducers/public_api';\nimport { daffPaymentGetSelectors } from '../../selectors/public_api';\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 { createMultiInjectionToken } from '@daffodil/core';\n\nimport { DaffPaymentAvailableProcessor } from '../models/public_api';\n\nexport const {\n /**\n * A multi-provider injection token for registering payment processors.\n */\n token: DAFF_PAYMENT_AVAILABLE_PROCESSORS,\n\n /**\n * Provides a payment processor registration.\n *\n * See {@link DaffPaymentAvailableProcessor}.\n */\n provider: daffPaymentProvideAvailableProcessors,\n} = createMultiInjectionToken<DaffPaymentAvailableProcessor>(\n 'DAFF_PAYMENT_AVAILABLE_PROCESSORS',\n { providedIn: 'any' },\n);\n","import { inject } from '@angular/core';\n\nimport {\n createSingleInjectionToken,\n daffArrayToDict,\n} from '@daffodil/core';\n\nimport { DAFF_PAYMENT_AVAILABLE_PROCESSORS } from './available-processors.token';\nimport { DaffPaymentProcessorCollection } from '../models/public_api';\n\nexport const {\n /**\n * An internal token to combine the available payment processors into a single collection.\n */\n token: DAFF_PAYMENT_PROCESSOR_COLLECTION,\n /**\n * Provider function for {@link DAFF_PAYMENT_PROCESSOR_COLLECTION}.\n */\n provider: provideDaffPaymentProcessorCollection,\n} = createSingleInjectionToken<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 { createSingleInjectionToken } from '@daffodil/core';\nimport { daffTransformErrorToStateError } from '@daffodil/core/state';\n\nexport const {\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 */\n token: DAFF_PAYMENT_ERROR_MATCHER,\n /**\n * Provider function for {@link DAFF_PAYMENT_ERROR_MATCHER}.\n */\n provider: provideDaffPaymentErrorMatcher,\n} = createSingleInjectionToken<typeof daffTransformErrorToStateError>(\n 'DAFF_PAYMENT_ERROR_MATCHER',\n { factory: () => daffTransformErrorToStateError },\n);\n","import { ActionReducer } from '@ngrx/store';\n\nimport { createSingleInjectionToken } from '@daffodil/core';\n\nimport { DaffPaymentReducersState } from '../reducers.interface';\n\nexport const {\n /**\n * An internal token to hold the Daffodil payment reducers.\n * Includes the extra and standard reducers.\n *\n * @docs-private\n */\n token: DAFF_PAYMENT_REDUCERS,\n /**\n * Provider function for {@link DAFF_PAYMENT_REDUCERS}.\n */\n provider: provideDaffPaymentReducers,\n /**\n * Factory provider function for {@link DAFF_PAYMENT_REDUCERS}.\n */\n factoryProvider: provideDaffPaymentReducersFactory,\n} = createSingleInjectionToken<ActionReducer<DaffPaymentReducersState>>(\n 'DAFF_PAYMENT_REDUCERS',\n);\n","import {\n inject,\n NgModule,\n} from '@angular/core';\nimport {\n combineReducers,\n StoreModule,\n} from '@ngrx/store';\n\nimport { daffComposeReducers } from '@daffodil/core/state';\n\nimport { DAFF_PAYMENT_AVAILABLE_PROCESSORS } from './injection-tokens/public_api';\nimport { daffPaymentReducerFactory } from './reducers/payment/reducer';\nimport { DAFF_PAYMENT_STORE_FEATURE_KEY } from './reducers/public_api';\nimport { DAFF_PAYMENT_EXTRA_REDUCERS } from './reducers/token/extra.token';\nimport {\n DAFF_PAYMENT_REDUCERS,\n provideDaffPaymentReducersFactory,\n} from './reducers/token/reducers.token';\n\n/**\n * Creates the payment feature store.\n *\n * @deprecated in favor of {@link provideDaffPaymentState} Deprecated in version 0.95.0. Will be removed in version 0.98.0.\n */\n@NgModule({\n imports: [\n StoreModule.forFeature(DAFF_PAYMENT_STORE_FEATURE_KEY, DAFF_PAYMENT_REDUCERS),\n ],\n providers: [\n provideDaffPaymentReducersFactory(() => daffComposeReducers([\n combineReducers({\n payment: daffPaymentReducerFactory(inject(DAFF_PAYMENT_AVAILABLE_PROCESSORS).map(({ action }) => action)),\n }),\n ...inject(DAFF_PAYMENT_EXTRA_REDUCERS),\n ])),\n ],\n})\nexport class DaffPaymentStateModule {}\n","import {\n EnvironmentProviders,\n inject,\n makeEnvironmentProviders,\n} from '@angular/core';\nimport {\n combineReducers,\n provideState,\n} from '@ngrx/store';\n\nimport { daffComposeReducers } from '@daffodil/core/state';\n\nimport { DAFF_PAYMENT_AVAILABLE_PROCESSORS } from './injection-tokens/public_api';\nimport { daffPaymentReducerFactory } from './reducers/payment/reducer';\nimport { DAFF_PAYMENT_STORE_FEATURE_KEY } from './reducers/public_api';\nimport { DAFF_PAYMENT_EXTRA_REDUCERS } from './reducers/token/extra.token';\nimport {\n DAFF_PAYMENT_REDUCERS,\n provideDaffPaymentReducersFactory,\n} from './reducers/token/reducers.token';\n\n/**\n * Provides the `@daffodil/payment/state` feature state.\n */\nexport const provideDaffPaymentState = (): EnvironmentProviders => makeEnvironmentProviders([\n provideState(DAFF_PAYMENT_STORE_FEATURE_KEY, DAFF_PAYMENT_REDUCERS),\n provideDaffPaymentReducersFactory(() => daffComposeReducers([\n combineReducers({\n payment: daffPaymentReducerFactory(inject(DAFF_PAYMENT_AVAILABLE_PROCESSORS).map(({ action }) => action)),\n }),\n ...inject(DAFF_PAYMENT_EXTRA_REDUCERS),\n ])),\n]);\n"],"mappings":";;;;;;AAaA,IAAY;CAAZ,SAAY,wBAAsB;CAChC,uBAAA,gCAAA;CACA,uBAAA,gCAAA;AACF,EAAA,CAHY,2BAAA,yBAAsB,CAAA,EAAA;AAmBlC,IAAa,kCAAb,MAA4C;CAG1C,YAAmB,SAAU;EAAV,KAAA,UAAA;EAFV,KAAA,OAAO,uBAAuB;CAEP;AACjC;AAKD,IAAa,kCAAb,MAA4C;CAG1C,YAAmB,SAAuB;EAAvB,KAAA,UAA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
|
5
|
-
import { createServicesInjectionToken, sample } from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
i0.ɵɵ
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
class DaffPaymentRequestFactory extends DaffModelFactory {
|
|
46
|
-
constructor() {
|
|
47
|
-
super(MockPaymentRequest);
|
|
48
|
-
}
|
|
49
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentRequestFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
50
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentRequestFactory, providedIn: 'root' }); }
|
|
51
|
-
}
|
|
52
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentRequestFactory, decorators: [{
|
|
53
|
-
type: Injectable,
|
|
54
|
-
args: [{
|
|
55
|
-
providedIn: 'root',
|
|
56
|
-
}]
|
|
57
|
-
}], ctorParameters: () => [] });
|
|
58
|
-
|
|
59
|
-
const {
|
|
60
|
-
/**
|
|
61
|
-
* A multi-provider injection token for providing extra payment result kind factories.
|
|
62
|
-
* These factories correspond to different types of payment results that may be added by other packages.
|
|
63
|
-
* This is useful for backend mocks (such as the testing driver) to generate an accurate representation
|
|
64
|
-
* of the variety of results that an application can receive in production.
|
|
65
|
-
*/
|
|
66
|
-
token: DAFF_PAYMENT_RESPONSE_KIND_FACTORIES,
|
|
67
|
-
/**
|
|
68
|
-
* Provides extra payment result factory kinds.
|
|
69
|
-
*
|
|
70
|
-
* See {@link DAFF_PAYMENT_RESPONSE_KIND_FACTORIES}.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```ts
|
|
74
|
-
* providers: [
|
|
75
|
-
* ...provideDaffPaymentResponseKindFactories(
|
|
76
|
-
* MyPaymentResponseFactory
|
|
77
|
-
* )
|
|
78
|
-
* ]
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
provider: provideDaffPaymentResponseKindFactories, } = createServicesInjectionToken('DAFF_PAYMENT_RESPONSE_KIND_FACTORIES', {
|
|
82
|
-
factory: () => [inject(DaffPaymentResponseFactory)],
|
|
83
|
-
providedIn: 'root',
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Inject, Injectable, NgModule, inject, makeEnvironmentProviders } from "@angular/core";
|
|
3
|
+
import { faker } from "@faker-js/faker/locale/en_US";
|
|
4
|
+
import { DaffModelFactory } from "@daffodil/core/testing";
|
|
5
|
+
import { createServicesInjectionToken, sample } from "@daffodil/core";
|
|
6
|
+
var MockPaymentResponse = class {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.method = faker.lorem.word();
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var DaffPaymentResponseFactory = class DaffPaymentResponseFactory extends DaffModelFactory {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(MockPaymentResponse);
|
|
14
|
+
}
|
|
15
|
+
static {
|
|
16
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
17
|
+
minVersion: "12.0.0",
|
|
18
|
+
version: "22.2.4",
|
|
19
|
+
ngImport: i0,
|
|
20
|
+
type: DaffPaymentResponseFactory,
|
|
21
|
+
deps: [],
|
|
22
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
static {
|
|
26
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
27
|
+
minVersion: "12.0.0",
|
|
28
|
+
version: "22.2.4",
|
|
29
|
+
ngImport: i0,
|
|
30
|
+
type: DaffPaymentResponseFactory,
|
|
31
|
+
providedIn: "root"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
36
|
+
minVersion: "12.0.0",
|
|
37
|
+
version: "22.2.4",
|
|
38
|
+
ngImport: i0,
|
|
39
|
+
type: DaffPaymentResponseFactory,
|
|
40
|
+
decorators: [{
|
|
41
|
+
type: Injectable,
|
|
42
|
+
args: [{ providedIn: "root" }]
|
|
43
|
+
}],
|
|
44
|
+
ctorParameters: () => []
|
|
84
45
|
});
|
|
46
|
+
var MockPaymentRequest = class {
|
|
47
|
+
constructor() {
|
|
48
|
+
this.kind = faker.lorem.word();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var DaffPaymentRequestFactory = class DaffPaymentRequestFactory extends DaffModelFactory {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(MockPaymentRequest);
|
|
54
|
+
}
|
|
55
|
+
static {
|
|
56
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
57
|
+
minVersion: "12.0.0",
|
|
58
|
+
version: "22.2.4",
|
|
59
|
+
ngImport: i0,
|
|
60
|
+
type: DaffPaymentRequestFactory,
|
|
61
|
+
deps: [],
|
|
62
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
static {
|
|
66
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
67
|
+
minVersion: "12.0.0",
|
|
68
|
+
version: "22.2.4",
|
|
69
|
+
ngImport: i0,
|
|
70
|
+
type: DaffPaymentRequestFactory,
|
|
71
|
+
providedIn: "root"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
76
|
+
minVersion: "12.0.0",
|
|
77
|
+
version: "22.2.4",
|
|
78
|
+
ngImport: i0,
|
|
79
|
+
type: DaffPaymentRequestFactory,
|
|
80
|
+
decorators: [{
|
|
81
|
+
type: Injectable,
|
|
82
|
+
args: [{ providedIn: "root" }]
|
|
83
|
+
}],
|
|
84
|
+
ctorParameters: () => []
|
|
85
|
+
});
|
|
86
|
+
const { token: DAFF_PAYMENT_RESPONSE_KIND_FACTORIES, provider: provideDaffPaymentResponseKindFactories } = createServicesInjectionToken("DAFF_PAYMENT_RESPONSE_KIND_FACTORIES", {
|
|
87
|
+
factory: () => [inject(DaffPaymentResponseFactory)],
|
|
88
|
+
providedIn: "root"
|
|
89
|
+
});
|
|
90
|
+
var DaffPaymentResponseKindFactory = class DaffPaymentResponseKindFactory extends DaffModelFactory {
|
|
91
|
+
constructor(kindFactories) {
|
|
92
|
+
super(MockPaymentResponse);
|
|
93
|
+
this.kindFactories = kindFactories;
|
|
94
|
+
}
|
|
95
|
+
get _randomFactory() {
|
|
96
|
+
return sample(this.kindFactories);
|
|
97
|
+
}
|
|
98
|
+
create(partial = {}) {
|
|
99
|
+
return this._randomFactory.create(partial);
|
|
100
|
+
}
|
|
101
|
+
static {
|
|
102
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
103
|
+
minVersion: "12.0.0",
|
|
104
|
+
version: "22.2.4",
|
|
105
|
+
ngImport: i0,
|
|
106
|
+
type: DaffPaymentResponseKindFactory,
|
|
107
|
+
deps: [{ token: DAFF_PAYMENT_RESPONSE_KIND_FACTORIES }],
|
|
108
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
static {
|
|
112
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
113
|
+
minVersion: "12.0.0",
|
|
114
|
+
version: "22.2.4",
|
|
115
|
+
ngImport: i0,
|
|
116
|
+
type: DaffPaymentResponseKindFactory,
|
|
117
|
+
providedIn: "root"
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
122
|
+
minVersion: "12.0.0",
|
|
123
|
+
version: "22.2.4",
|
|
124
|
+
ngImport: i0,
|
|
125
|
+
type: DaffPaymentResponseKindFactory,
|
|
126
|
+
decorators: [{
|
|
127
|
+
type: Injectable,
|
|
128
|
+
args: [{ providedIn: "root" }]
|
|
129
|
+
}],
|
|
130
|
+
ctorParameters: () => [{
|
|
131
|
+
type: void 0,
|
|
132
|
+
decorators: [{
|
|
133
|
+
type: Inject,
|
|
134
|
+
args: [DAFF_PAYMENT_RESPONSE_KIND_FACTORIES]
|
|
135
|
+
}]
|
|
136
|
+
}]
|
|
137
|
+
});
|
|
138
|
+
const provideDaffPaymentTesting = () => makeEnvironmentProviders([provideDaffPaymentResponseKindFactories(DaffPaymentResponseFactory)]);
|
|
139
|
+
var DaffPaymentTestingModule = class DaffPaymentTestingModule {
|
|
140
|
+
static {
|
|
141
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
142
|
+
minVersion: "12.0.0",
|
|
143
|
+
version: "22.2.4",
|
|
144
|
+
ngImport: i0,
|
|
145
|
+
type: DaffPaymentTestingModule,
|
|
146
|
+
deps: [],
|
|
147
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
static {
|
|
151
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
152
|
+
minVersion: "14.0.0",
|
|
153
|
+
version: "22.2.4",
|
|
154
|
+
ngImport: i0,
|
|
155
|
+
type: DaffPaymentTestingModule
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
static {
|
|
159
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
160
|
+
minVersion: "12.0.0",
|
|
161
|
+
version: "22.2.4",
|
|
162
|
+
ngImport: i0,
|
|
163
|
+
type: DaffPaymentTestingModule,
|
|
164
|
+
providers: [provideDaffPaymentTesting()]
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
169
|
+
minVersion: "12.0.0",
|
|
170
|
+
version: "22.2.4",
|
|
171
|
+
ngImport: i0,
|
|
172
|
+
type: DaffPaymentTestingModule,
|
|
173
|
+
decorators: [{
|
|
174
|
+
type: NgModule,
|
|
175
|
+
args: [{ providers: [provideDaffPaymentTesting()] }]
|
|
176
|
+
}]
|
|
177
|
+
});
|
|
178
|
+
export { DAFF_PAYMENT_RESPONSE_KIND_FACTORIES, DaffPaymentRequestFactory, DaffPaymentResponseFactory, DaffPaymentResponseKindFactory, DaffPaymentTestingModule, MockPaymentRequest, MockPaymentResponse, provideDaffPaymentResponseKindFactories, provideDaffPaymentTesting };
|
|
85
179
|
|
|
86
|
-
|
|
87
|
-
* Factory for creating DaffPaymentResponses.
|
|
88
|
-
* This will create a payment response of random kind.
|
|
89
|
-
*/
|
|
90
|
-
class DaffPaymentResponseKindFactory extends DaffModelFactory {
|
|
91
|
-
constructor(kindFactories) {
|
|
92
|
-
super(MockPaymentResponse);
|
|
93
|
-
this.kindFactories = kindFactories;
|
|
94
|
-
}
|
|
95
|
-
get _randomFactory() {
|
|
96
|
-
return sample(this.kindFactories);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Creates a payment result of random kind.
|
|
100
|
-
*/
|
|
101
|
-
create(partial = {}) {
|
|
102
|
-
return this._randomFactory.create(partial);
|
|
103
|
-
}
|
|
104
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentResponseKindFactory, deps: [{ token: DAFF_PAYMENT_RESPONSE_KIND_FACTORIES }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
105
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentResponseKindFactory, providedIn: 'root' }); }
|
|
106
|
-
}
|
|
107
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentResponseKindFactory, decorators: [{
|
|
108
|
-
type: Injectable,
|
|
109
|
-
args: [{
|
|
110
|
-
providedIn: 'root',
|
|
111
|
-
}]
|
|
112
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
113
|
-
type: Inject,
|
|
114
|
-
args: [DAFF_PAYMENT_RESPONSE_KIND_FACTORIES]
|
|
115
|
-
}] }] });
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Provides the default payment result factory as a payment result type factory.
|
|
119
|
-
*/
|
|
120
|
-
class DaffPaymentTestingModule {
|
|
121
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
122
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentTestingModule }); }
|
|
123
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentTestingModule, providers: [
|
|
124
|
-
provideDaffPaymentResponseKindFactories(DaffPaymentResponseFactory),
|
|
125
|
-
] }); }
|
|
126
|
-
}
|
|
127
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentTestingModule, decorators: [{
|
|
128
|
-
type: NgModule,
|
|
129
|
-
args: [{
|
|
130
|
-
providers: [
|
|
131
|
-
provideDaffPaymentResponseKindFactories(DaffPaymentResponseFactory),
|
|
132
|
-
],
|
|
133
|
-
}]
|
|
134
|
-
}] });
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Generated bundle index. Do not edit.
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
export { DAFF_PAYMENT_RESPONSE_KIND_FACTORIES, DaffPaymentRequestFactory, DaffPaymentResponseFactory, DaffPaymentResponseKindFactory, DaffPaymentTestingModule, MockPaymentRequest, MockPaymentResponse, provideDaffPaymentResponseKindFactories };
|
|
141
|
-
//# sourceMappingURL=daffodil-payment-testing.mjs.map
|
|
180
|
+
//# sourceMappingURL=daffodil-payment-testing.mjs.map
|
|
@@ -1 +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/
|
|
1
|
+
{"version":3,"file":"daffodil-payment-testing.mjs","names":[],"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/provider.ts","../../../libs/payment/testing/src/testing.module.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { 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.lorem.word();\n};\n\n/**\n * Model factory for {@link DaffPaymentResponse}.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffPaymentResponseFactory extends DaffModelFactory<DaffPaymentResponse, typeof MockPaymentResponse>{\n constructor() {\n super(MockPaymentResponse);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { 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.lorem.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 { inject } from '@angular/core';\n\nimport { createServicesInjectionToken } from '@daffodil/core';\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { DaffPaymentResponse } from '@daffodil/payment';\n\nimport { DaffPaymentResponseFactory } from '../../factories/payment-response.factory';\n\nexport const {\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 */\n token: DAFF_PAYMENT_RESPONSE_KIND_FACTORIES,\n\n /**\n * Provides extra payment result factory kinds.\n *\n * See {@link DAFF_PAYMENT_RESPONSE_KIND_FACTORIES}.\n *\n * @example\n * ```ts\n * providers: [\n * ...provideDaffPaymentResponseKindFactories(\n * MyPaymentResponseFactory\n * )\n * ]\n * ```\n */\n provider: provideDaffPaymentResponseKindFactories,\n} = createServicesInjectionToken<DaffModelFactory<DaffPaymentResponse>>(\n 'DAFF_PAYMENT_RESPONSE_KIND_FACTORIES',\n {\n factory: () => [inject(DaffPaymentResponseFactory)],\n providedIn: 'root',\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 { MockPaymentResponse } from './payment-response.factory';\nimport { DAFF_PAYMENT_RESPONSE_KIND_FACTORIES } from '../injection-tokens/factories/kind.token';\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 {\n EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { DaffPaymentResponseFactory } from './factories/public_api';\nimport { provideDaffPaymentResponseKindFactories } from './injection-tokens/public_api';\n\n/**\n * Provides the default payment result factory as a payment result type factory.\n */\nexport const provideDaffPaymentTesting = (): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffPaymentResponseKindFactories(DaffPaymentResponseFactory),\n]);\n","import { NgModule } from '@angular/core';\n\nimport { provideDaffPaymentTesting } from './provider';\n\n/**\n * Provides the default payment result factory as a payment result type factory.\n *\n * @deprecated in favor of {@link provideDaffPaymentTesting} Deprecated in version 0.95.0. Will be removed in version 0.98.0.\n */\n@NgModule({\n providers: [\n provideDaffPaymentTesting(),\n ],\n})\nexport class DaffPaymentTestingModule { }\n"],"mappings":";;;;;AASA,IAAa,sBAAb,MAAgC;CAAhC,cAAA;EACE,KAAA,SAAS,MAAM,MAAM,KAAI;CAC3B;AAAC;AAQD,IAAa,6BAAb,MAAa,mCAAmC,iBAAiE;CAC/G,cAAA;EACE,MAAM,mBAAmB;CAC3B;CAHW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,M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odil/payment","nx":{"targets":{"build":{"outputs":["{workspaceRoot}/dist/payment"]}}},"version":"0.
|
|
1
|
+
{"name":"@daffodil/payment","nx":{"targets":{"build":{"outputs":["{workspaceRoot}/dist/payment"]}}},"version":"0.95.1","description":"Platform-agnostic models, state management, and drivers for ecommerce payment processing. Part of the Daffodil ecommerce framework.","repository":{"type":"git","url":"https://github.com/graycoreio/daffodil"},"author":"Graycore LLC","license":"MIT","bugs":{"url":"https://github.com/graycoreio/daffodil/issues"},"homepage":"https://github.com/graycoreio/daffodil","peerDependencies":{"@angular/common":"^22","@angular/core":"^22","@daffodil/core":"0.95.1","@ngrx/effects":"^22","@ngrx/store":"^22","rxjs":"^7.0.0"},"optionalDependencies":{"@apollo/client":"^4.0.13","@daffodil/driver":"0.95.1","apollo-angular":"^14.0.0","@faker-js/faker":"^10.3.0"},"module":"fesm2022/daffodil-payment.mjs","typings":"types/daffodil-payment.d.ts","exports":{"./package.json":{"default":"./package.json"},".":{"types":"./types/daffodil-payment.d.ts","default":"./fesm2022/daffodil-payment.mjs"},"./driver":{"types":"./types/daffodil-payment-driver.d.ts","default":"./fesm2022/daffodil-payment-driver.mjs"},"./driver/in-memory":{"types":"./types/daffodil-payment-driver-in-memory.d.ts","default":"./fesm2022/daffodil-payment-driver-in-memory.mjs"},"./driver/testing":{"types":"./types/daffodil-payment-driver-testing.d.ts","default":"./fesm2022/daffodil-payment-driver-testing.mjs"},"./state":{"types":"./types/daffodil-payment-state.d.ts","default":"./fesm2022/daffodil-payment-state.mjs"},"./state/testing":{"types":"./types/daffodil-payment-state-testing.d.ts","default":"./fesm2022/daffodil-payment-state-testing.mjs"},"./testing":{"types":"./types/daffodil-payment-testing.d.ts","default":"./fesm2022/daffodil-payment-testing.mjs"}},"sideEffects":false,"type":"module","dependencies":{"tslib":"^2.6.2"}}
|
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import { DaffPaymentDriverInterface } from '@daffodil/payment/driver';
|
|
12
|
-
import * as i1 from '@angular/common';
|
|
13
|
-
|
|
1
|
+
import { InMemoryBackendConfig, InMemoryDbService, ParsedRequestUrl, RequestInfo, RequestInfoUtilities } from "angular-in-memory-web-api";
|
|
2
|
+
import { DaffInMemoryDriverBase, DaffInMemorySingleRouteableBackend } from "@daffodil/driver/in-memory";
|
|
3
|
+
import { DaffPaymentResponseKindFactory } from "@daffodil/payment/testing";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import { EnvironmentProviders, ModuleWithProviders } from "@angular/core";
|
|
6
|
+
import { HttpClient } from "@angular/common/http";
|
|
7
|
+
import { Observable } from "rxjs";
|
|
8
|
+
import { DaffPaymentRequest, DaffPaymentResponse } from "@daffodil/payment";
|
|
9
|
+
import { DaffPaymentDriverInterface } from "@daffodil/payment/driver";
|
|
10
|
+
import * as i1 from "@angular/common";
|
|
14
11
|
/**
|
|
15
12
|
* An in-memory service that delegates payment queries to child backends
|
|
16
13
|
* via the {@link DAFF_PAYMENT_IN_MEMORY_BACKENDS}.
|
|
17
14
|
*/
|
|
18
|
-
declare class DaffPaymentInMemoryBackendService implements InMemoryDbService, DaffInMemorySingleRouteableBackend {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
15
|
+
export declare class DaffPaymentInMemoryBackendService implements InMemoryDbService, DaffInMemorySingleRouteableBackend {
|
|
16
|
+
private factory;
|
|
17
|
+
readonly collectionName = "payment";
|
|
18
|
+
constructor(factory: DaffPaymentResponseKindFactory);
|
|
19
|
+
/**
|
|
20
|
+
* Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.
|
|
21
|
+
*
|
|
22
|
+
* @param url initial url
|
|
23
|
+
* @param utils utility to parse url
|
|
24
|
+
* @returns ParsedRequestUrl
|
|
25
|
+
* @docs-private
|
|
26
|
+
*/
|
|
27
|
+
parseRequestUrl(url: string, utils: RequestInfoUtilities): ParsedRequestUrl;
|
|
28
|
+
/**
|
|
29
|
+
* @docs-private
|
|
30
|
+
*/
|
|
31
|
+
createDb(): any;
|
|
32
|
+
/**
|
|
33
|
+
* Generates a token from a processor backend.
|
|
34
|
+
*
|
|
35
|
+
* @param reqInfo request object
|
|
36
|
+
* @returns An http response object
|
|
37
|
+
*/
|
|
38
|
+
get(reqInfo: RequestInfo): import("rxjs").Observable<any>;
|
|
39
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentInMemoryBackendService, never>;
|
|
40
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
44
41
|
}
|
|
45
|
-
|
|
46
42
|
/**
|
|
47
43
|
* The payment inmemory driver to mock the payment backend service.
|
|
48
44
|
*
|
|
49
45
|
* @inheritdoc
|
|
50
46
|
*/
|
|
51
|
-
declare class DaffPaymentInMemoryDriver extends DaffInMemoryDriverBase implements DaffPaymentDriverInterface {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
export declare class DaffPaymentInMemoryDriver extends DaffInMemoryDriverBase implements DaffPaymentDriverInterface {
|
|
48
|
+
private http;
|
|
49
|
+
constructor(http: HttpClient, config: InMemoryBackendConfig);
|
|
50
|
+
generateToken(request: DaffPaymentRequest): Observable<DaffPaymentResponse>;
|
|
51
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentInMemoryDriver, never>;
|
|
52
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
57
53
|
}
|
|
58
|
-
|
|
59
54
|
/**
|
|
60
55
|
* Provides the {@link DaffPaymentInMemoryDriver} as the {@link DaffPaymentDriver}.
|
|
56
|
+
*
|
|
57
|
+
* @deprecated in favor of {@link provideDaffPaymentInMemoryDriver} Deprecated in version 0.95.0. Will be removed in version 0.98.0.
|
|
61
58
|
*/
|
|
62
|
-
declare class DaffPaymentInMemoryDriverModule {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
export declare class DaffPaymentInMemoryDriverModule {
|
|
60
|
+
static forRoot(): ModuleWithProviders<DaffPaymentInMemoryDriverModule>;
|
|
61
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentInMemoryDriverModule, never>;
|
|
62
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<DaffPaymentInMemoryDriverModule, never, [typeof i1.CommonModule], never>;
|
|
63
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<DaffPaymentInMemoryDriverModule>;
|
|
67
64
|
}
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Provides the {@link DaffPaymentInMemoryDriver} as the {@link DaffPaymentDriver}.
|
|
67
|
+
* Includes {@link provideDaffPaymentTesting}.
|
|
68
|
+
*/
|
|
69
|
+
export declare const provideDaffPaymentInMemoryDriver: () => EnvironmentProviders;
|