UNPKG

@acoustic-content-sdk/redux-feature-auth-layout

Version:

Implementation of a redux feature to manage authoring layouts.

243 lines (231 loc) 8.51 kB
import { createAction, handleActions } from 'redux-actions'; import { selectPayload, selectFeature, createReduxFeatureModule } from '@acoustic-content-sdk/redux-store'; import { selectByDeliveryId, updateItemsWithRevision, addToSetEpic, getDeliveryIdFromAuthoringItem } from '@acoustic-content-sdk/redux-utils'; import { PROJECT_ID_QUERY_PARAM, createAuthenticatedLoader, guaranteeEpic, nonExistentEpic, loadingFeature } from '@acoustic-content-sdk/redux-feature-load'; import { loggedInFeature } from '@acoustic-content-sdk/redux-feature-login'; import { rxPipe, jsonParse, mapArray } from '@acoustic-content-sdk/utils'; import { ofType, combineEpics } from 'redux-observable'; import { map } from 'rxjs/operators'; /** * @fileoverview added by tsickle * Generated from: version.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * Version and build number of the package * @type {?} */ const VERSION = { version: { major: '9', minor: '0', patch: '10076', branch: 'master' }, build: new Date(1585229427693) }; /** * Module name * @type {?} */ const MODULE = '@acoustic-content-sdk/redux-feature-auth-layout'; /** * @fileoverview added by tsickle * Generated from: state/auth-layout/auth.layout.actions.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const ACTION_ADD_AUTH_LAYOUT = 'ACTION_ADD_AUTH_LAYOUT'; /** @type {?} */ const addAuthoringLayoutAction = createAction(ACTION_ADD_AUTH_LAYOUT); /** * Do not add a side effect to this action * @type {?} */ const ACTION_SET_AUTH_LAYOUT = 'ACTION_SET_AUTH_LAYOUT'; /** @type {?} */ const setAuthoringLayoutAction = createAction(ACTION_SET_AUTH_LAYOUT); /** @type {?} */ const ACTION_LOAD_AUTH_LAYOUT = 'ACTION_LOAD_AUTH_LAYOUT'; /** @type {?} */ const loadAuthoringLayoutAction = createAction(ACTION_LOAD_AUTH_LAYOUT); /** @type {?} */ const ACTION_GUARANTEE_AUTH_LAYOUT = 'ACTION_GUARANTEE_AUTH_LAYOUT'; /** @type {?} */ const guaranteeAuthoringLayoutAction = createAction(ACTION_GUARANTEE_AUTH_LAYOUT); /** @type {?} */ const ACTION_ADD_AUTH_LAYOUT_IF_NONEXISTENT = 'ACTION_ADD_AUTH_LAYOUT_IF_NONEXISTENT'; /** * Adds this content item to the store only if the item does not exist, yet. If the item * does not exist, this triggers a {\@link addAuthoringLayoutAction}. * * \@param aItem - the content item to add * \@return the action * @type {?} */ const addAuthoringLayoutIfNonExistentAction = createAction(ACTION_ADD_AUTH_LAYOUT_IF_NONEXISTENT); /** * @fileoverview added by tsickle * Generated from: state/auth-layout/auth.layout.id.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const AUTH_LAYOUT_FEATURE = 'authLayout'; /** * @fileoverview added by tsickle * Generated from: state/auth-layout/auth.layout.reducer.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const DEFAULT_STATE = {}; /** @type {?} */ const selectAuthoringLayout = (/** * @param {?} id * @return {?} */ id => selectByDeliveryId(id)); /** @type {?} */ const setLayout = (/** * @param {?} state * @param {?} action * @return {?} */ (state, action) => updateItemsWithRevision(state, selectPayload(action))); const ɵ0 = setLayout; /** * reducers for authoring content * @type {?} */ const authoringLayoutReducer = handleActions({ [ACTION_ADD_AUTH_LAYOUT]: setLayout, [ACTION_SET_AUTH_LAYOUT]: setLayout }, DEFAULT_STATE); /** * @fileoverview added by tsickle * Generated from: state/auth-layout/auth.layout.feature.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * * @record */ function AuthLayoutFeatureState() { } if (false) { /* Skipping unnamed member: [AUTH_LAYOUT_FEATURE]: AuthoringLayoutState;*/ } /** * * @type {?} */ const authLayoutFeatureReducer = { [AUTH_LAYOUT_FEATURE]: authoringLayoutReducer }; /** * Select the authoring type feature * @type {?} */ const selectAuthLayoutFeature = selectFeature(AUTH_LAYOUT_FEATURE); /** * @fileoverview added by tsickle * Generated from: state/auth-layout/auth.layout.epics.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const LOGGER = 'AuthLayoutEpic'; /** * @record */ function AuthoringLayoutDependencies() { } if (false) { /** @type {?} */ AuthoringLayoutDependencies.prototype.fetchText; /** @type {?} */ AuthoringLayoutDependencies.prototype.logSvc; } // TODO type fallback for layouts! /** * Initialize the active page * @type {?} */ const loadLayoutEpic = (/** * @param {?} actions$ * @param {?} state$ * @param {?} __2 * @return {?} */ (actions$, state$, { fetchText, logSvc }) => { // logger /** @type {?} */ const logger = logSvc.get(LOGGER); // loader /** @type {?} */ const loader = (/** * @param {?} id * @return {?} */ (id) => rxPipe(fetchText(`authoring/v1/layouts/${encodeURIComponent(id)}?${PROJECT_ID_QUERY_PARAM}`), // convert text to json map(jsonParse), // save the loaded asset map(addAuthoringLayoutAction))); // our loader /** @type {?} */ const opLoader = createAuthenticatedLoader(state$, loader, logger); return rxPipe(actions$, ofType(ACTION_LOAD_AUTH_LAYOUT), // extract the id of the type map(selectPayload), // load opLoader); }); const ɵ0$1 = loadLayoutEpic; /** * Determine the IDs of the layouts to resolve * * @param {?} aLayouts - the authoring layouts * @return {?} the resolved layout IDs */ function idsFromSelectedLayouts(aLayouts) { return mapArray(aLayouts, (/** * @param {?} layout * @return {?} */ (layout) => layout.layout.id)); } // epic to convert from ACTION_ADD_AUTH_LAYOUT to ACTION_SET_AUTH_LAYOUT /** @type {?} */ const setLayoutEpic = addToSetEpic(ACTION_ADD_AUTH_LAYOUT, ACTION_SET_AUTH_LAYOUT); /** * Handles layout guarantees * @type {?} */ const guaranteeLayoutEpic = guaranteeEpic(ACTION_GUARANTEE_AUTH_LAYOUT, loadAuthoringLayoutAction, selectAuthLayoutFeature); /** * Handles non existent items * @type {?} */ const nonExistentLayoutEpic = nonExistentEpic(ACTION_ADD_AUTH_LAYOUT_IF_NONEXISTENT, addAuthoringLayoutAction, getDeliveryIdFromAuthoringItem, selectAuthLayoutFeature); /** @type {?} */ const authoringLayoutEpic = combineEpics(loadLayoutEpic, guaranteeLayoutEpic, nonExistentLayoutEpic, setLayoutEpic); /** * @fileoverview added by tsickle * Generated from: state/auth-layout/auth.layout.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * Exposes the feature module selector * @type {?} */ const authoringLayoutFeature = createReduxFeatureModule(AUTH_LAYOUT_FEATURE, authoringLayoutReducer, authoringLayoutEpic, [ loadingFeature, loggedInFeature ]); /** * @fileoverview added by tsickle * Generated from: state/auth-layout/index.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: public_api.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: acoustic-content-sdk-redux-feature-auth-layout.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { ACTION_ADD_AUTH_LAYOUT, ACTION_ADD_AUTH_LAYOUT_IF_NONEXISTENT, ACTION_GUARANTEE_AUTH_LAYOUT, ACTION_LOAD_AUTH_LAYOUT, ACTION_SET_AUTH_LAYOUT, AUTH_LAYOUT_FEATURE, VERSION, addAuthoringLayoutAction, addAuthoringLayoutIfNonExistentAction, authLayoutFeatureReducer, authoringLayoutFeature, authoringLayoutReducer, guaranteeAuthoringLayoutAction, loadAuthoringLayoutAction, selectAuthLayoutFeature, selectAuthoringLayout, setAuthoringLayoutAction, authoringLayoutEpic as ɵa }; //# sourceMappingURL=acoustic-content-sdk-redux-feature-auth-layout.js.map