@acoustic-content-sdk/redux-feature-auth-layout
Version:
Implementation of a redux feature to manage authoring layouts.
240 lines (229 loc) • 10.2 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('redux-actions'), require('@acoustic-content-sdk/redux-store'), require('@acoustic-content-sdk/redux-utils'), require('@acoustic-content-sdk/redux-feature-load'), require('@acoustic-content-sdk/redux-feature-login'), require('@acoustic-content-sdk/utils'), require('redux-observable'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define('@acoustic-content-sdk/redux-feature-auth-layout', ['exports', 'redux-actions', '@acoustic-content-sdk/redux-store', '@acoustic-content-sdk/redux-utils', '@acoustic-content-sdk/redux-feature-load', '@acoustic-content-sdk/redux-feature-login', '@acoustic-content-sdk/utils', 'redux-observable', 'rxjs/operators'], factory) :
(global = global || self, factory((global['acoustic-content-sdk'] = global['acoustic-content-sdk'] || {}, global['acoustic-content-sdk']['redux-feature-auth-layout'] = {}), global.ReduxActions, global['acoustic-content-sdk']['redux-store'], global['acoustic-content-sdk']['redux-utils'], global['acoustic-content-sdk']['redux-feature-load'], global['acoustic-content-sdk']['redux-feature-login'], global['acoustic-content-sdk'].utils, global.ReduxObservable, global.rxjs.operators));
}(this, (function (exports, reduxActions, reduxStore, reduxUtils, reduxFeatureLoad, reduxFeatureLogin, utils, reduxObservable, operators) { 'use strict';
/**
* @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 = reduxActions.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 = reduxActions.createAction(ACTION_SET_AUTH_LAYOUT);
/** @type {?} */
var ACTION_LOAD_AUTH_LAYOUT = 'ACTION_LOAD_AUTH_LAYOUT';
/** @type {?} */
var loadAuthoringLayoutAction = reduxActions.createAction(ACTION_LOAD_AUTH_LAYOUT);
/** @type {?} */
var ACTION_GUARANTEE_AUTH_LAYOUT = 'ACTION_GUARANTEE_AUTH_LAYOUT';
/** @type {?} */
var guaranteeAuthoringLayoutAction = reduxActions.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 = reduxActions.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 reduxUtils.selectByDeliveryId(id); });
/** @type {?} */
var setLayout = (/**
* @param {?} state
* @param {?} action
* @return {?}
*/
function (state, action) {
return reduxUtils.updateItemsWithRevision(state, reduxStore.selectPayload(action));
});
var ɵ0 = setLayout;
/**
* reducers for authoring content
* @type {?}
*/
var authoringLayoutReducer = reduxActions.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 = reduxStore.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 utils.rxPipe(fetchText("authoring/v1/layouts/" + encodeURIComponent(id) + "?" + reduxFeatureLoad.PROJECT_ID_QUERY_PARAM),
// convert text to json
operators.map(utils.jsonParse),
// save the loaded asset
operators.map(addAuthoringLayoutAction));
});
// our loader
/** @type {?} */
var opLoader = reduxFeatureLoad.createAuthenticatedLoader(state$, loader, logger);
return utils.rxPipe(actions$, reduxObservable.ofType(ACTION_LOAD_AUTH_LAYOUT),
// extract the id of the type
operators.map(reduxStore.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 utils.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 = reduxUtils.addToSetEpic(ACTION_ADD_AUTH_LAYOUT, ACTION_SET_AUTH_LAYOUT);
/**
* Handles layout guarantees
* @type {?}
*/
var guaranteeLayoutEpic = reduxFeatureLoad.guaranteeEpic(ACTION_GUARANTEE_AUTH_LAYOUT, loadAuthoringLayoutAction, selectAuthLayoutFeature);
/**
* Handles non existent items
* @type {?}
*/
var nonExistentLayoutEpic = reduxFeatureLoad.nonExistentEpic(ACTION_ADD_AUTH_LAYOUT_IF_NONEXISTENT, addAuthoringLayoutAction, reduxUtils.getDeliveryIdFromAuthoringItem, selectAuthLayoutFeature);
/** @type {?} */
var authoringLayoutEpic = reduxObservable.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 = reduxStore.createReduxFeatureModule(AUTH_LAYOUT_FEATURE, authoringLayoutReducer, authoringLayoutEpic, [
reduxFeatureLoad.loadingFeature,
reduxFeatureLogin.loggedInFeature
]);
exports.ACTION_ADD_AUTH_LAYOUT = ACTION_ADD_AUTH_LAYOUT;
exports.ACTION_ADD_AUTH_LAYOUT_IF_NONEXISTENT = ACTION_ADD_AUTH_LAYOUT_IF_NONEXISTENT;
exports.ACTION_GUARANTEE_AUTH_LAYOUT = ACTION_GUARANTEE_AUTH_LAYOUT;
exports.ACTION_LOAD_AUTH_LAYOUT = ACTION_LOAD_AUTH_LAYOUT;
exports.ACTION_SET_AUTH_LAYOUT = ACTION_SET_AUTH_LAYOUT;
exports.AUTH_LAYOUT_FEATURE = AUTH_LAYOUT_FEATURE;
exports.VERSION = VERSION;
exports.addAuthoringLayoutAction = addAuthoringLayoutAction;
exports.addAuthoringLayoutIfNonExistentAction = addAuthoringLayoutIfNonExistentAction;
exports.authLayoutFeatureReducer = authLayoutFeatureReducer;
exports.authoringLayoutFeature = authoringLayoutFeature;
exports.authoringLayoutReducer = authoringLayoutReducer;
exports.guaranteeAuthoringLayoutAction = guaranteeAuthoringLayoutAction;
exports.loadAuthoringLayoutAction = loadAuthoringLayoutAction;
exports.selectAuthLayoutFeature = selectAuthLayoutFeature;
exports.selectAuthoringLayout = selectAuthoringLayout;
exports.setAuthoringLayoutAction = setAuthoringLayoutAction;
exports.ɵa = authoringLayoutEpic;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=acoustic-content-sdk-redux-feature-auth-layout.umd.js.map