UNPKG

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

Version:

Implementation of a redux feature to manage authoring layouts.

240 lines (228 loc) 8.19 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 {?} */ var VERSION = { version: { major: '9', minor: '0', patch: '10076', branch: 'master' }, build: new Date(1585229427693) }; /** * Module name * @type {?} */ var 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 {?} */ var ACTION_ADD_AUTH_LAYOUT = 'ACTION_ADD_AUTH_LAYOUT'; /** @type {?} */ var addAuthoringLayoutAction = createAction(ACTION_ADD_AUTH_LAYOUT); /** * Do not add a side effect to this action * @type {?} */ var ACTION_SET_AUTH_LAYOUT = 'ACTION_SET_AUTH_LAYOUT'; /** @type {?} */ var setAuthoringLayoutAction = createAction(ACTION_SET_AUTH_LAYOUT); /** @type {?} */ var ACTION_LOAD_AUTH_LAYOUT = 'ACTION_LOAD_AUTH_LAYOUT'; /** @type {?} */ var loadAuthoringLayoutAction = createAction(ACTION_LOAD_AUTH_LAYOUT); /** @type {?} */ var ACTION_GUARANTEE_AUTH_LAYOUT = 'ACTION_GUARANTEE_AUTH_LAYOUT'; /** @type {?} */ var guaranteeAuthoringLayoutAction = createAction(ACTION_GUARANTEE_AUTH_LAYOUT); /** @type {?} */ var 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 {?} */ var 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 {?} */ var AUTH_LAYOUT_FEATURE = 'authLayout'; var _a; /** @type {?} */ var DEFAULT_STATE = {}; /** @type {?} */ var selectAuthoringLayout = (/** * @param {?} id * @return {?} */ function (id) { return selectByDeliveryId(id); }); /** @type {?} */ var setLayout = (/** * @param {?} state * @param {?} action * @return {?} */ function (state, action) { return updateItemsWithRevision(state, selectPayload(action)); }); var ɵ0 = setLayout; /** * reducers for authoring content * @type {?} */ var authoringLayoutReducer = handleActions((_a = {}, _a[ACTION_ADD_AUTH_LAYOUT] = setLayout, _a[ACTION_SET_AUTH_LAYOUT] = setLayout, _a), DEFAULT_STATE); var _a$1; /** * * @record */ function AuthLayoutFeatureState() { } if (false) { /* Skipping unnamed member: [AUTH_LAYOUT_FEATURE]: AuthoringLayoutState;*/ } /** * * @type {?} */ var authLayoutFeatureReducer = (_a$1 = {}, _a$1[AUTH_LAYOUT_FEATURE] = authoringLayoutReducer, _a$1); /** * Select the authoring type feature * @type {?} */ var 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 {?} */ var 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 {?} */ var loadLayoutEpic = (/** * @param {?} actions$ * @param {?} state$ * @param {?} __2 * @return {?} */ function (actions$, state$, _a) { var fetchText = _a.fetchText, logSvc = _a.logSvc; // logger /** @type {?} */ var logger = logSvc.get(LOGGER); // loader /** @type {?} */ var loader = (/** * @param {?} id * @return {?} */ function (id) { return 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 {?} */ var opLoader = createAuthenticatedLoader(state$, loader, logger); return rxPipe(actions$, ofType(ACTION_LOAD_AUTH_LAYOUT), // extract the id of the type map(selectPayload), // load opLoader); }); var ɵ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 {?} */ function (layout) { return layout.layout.id; })); } // epic to convert from ACTION_ADD_AUTH_LAYOUT to ACTION_SET_AUTH_LAYOUT /** @type {?} */ var setLayoutEpic = addToSetEpic(ACTION_ADD_AUTH_LAYOUT, ACTION_SET_AUTH_LAYOUT); /** * Handles layout guarantees * @type {?} */ var guaranteeLayoutEpic = guaranteeEpic(ACTION_GUARANTEE_AUTH_LAYOUT, loadAuthoringLayoutAction, selectAuthLayoutFeature); /** * Handles non existent items * @type {?} */ var nonExistentLayoutEpic = nonExistentEpic(ACTION_ADD_AUTH_LAYOUT_IF_NONEXISTENT, addAuthoringLayoutAction, getDeliveryIdFromAuthoringItem, selectAuthLayoutFeature); /** @type {?} */ var 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 {?} */ var 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