@stackend/api
Version:
JS bindings to api.stackend.com
347 lines • 10.5 kB
JavaScript
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeModuleInfo = exports.addModuleInfo = exports.getModuleLabel = exports.getDefaultComponentContext = exports.getXcapModuleType = exports.getModuleInfo = exports.AUTOMATIC_MODULE_TYPES = exports.MODULE_INFO = exports.ModuleType = void 0;
var ModuleType;
(function (ModuleType) {
/** Styling */
ModuleType["GLOBAL_STYLE"] = "stackend-global-style";
/** Feed (variation of blog) */
ModuleType["FEED"] = "stackend-feed";
ModuleType["FAQ"] = "stackend-faq";
/** Login link and user menu */
ModuleType["LOGIN"] = "stackend-login";
/** Profile popup */
ModuleType["PROFILE"] = "stackend-profile";
/** Comments */
ModuleType["COMMENTS"] = "stackend-comment";
/** A single code bin */
ModuleType["CMS"] = "stackend-cms";
/** Blog (variation of feed) */
ModuleType["BLOG"] = "stackend-blog";
/** Different throbbers */
ModuleType["THROBBER"] = "stackend-throbber";
/** Purely presentational */
ModuleType["SLIDESHOW"] = "stackend-slideshow";
/** Combines content into a page */
ModuleType["PAGE"] = "stackend-page";
/** A container that allows the user to navigate pages, much like an iframe */
ModuleType["SUBSITE"] = "stackend-site";
/** A single product from the shop */
ModuleType["SHOP_PRODUCT"] = "stackend-shop-product";
/** List products from the shop */
ModuleType["SHOP_PRODUCT_LISTING"] = "stackend-shop-listing";
/** A collection of products from the shop */
ModuleType["SHOP_COLLECTION"] = "stackend-shop-collection";
/** The shopping basket and checkout user interface */
ModuleType["SHOP_BASKET"] = "stackend-shop-basket";
/** Live Event with video and chat */
ModuleType["LIVE"] = "stackend-live";
/** Listing of Live Events */
ModuleType["LIVE_LISTING"] = "stackend-live-listing";
/** Forums */
ModuleType["FORUM"] = "stackend-forum";
})(ModuleType = exports.ModuleType || (exports.ModuleType = {}));
exports.MODULE_INFO = (_a = {},
_a[ModuleType.FEED] = {
name: 'Feed',
type: ModuleType.FEED,
singleton: false,
addAutomatically: false,
parameters: ['id'],
simpleId: false,
fetchData: true,
complex: false,
xcapModuleType: 'group',
defaultContext: 'groups'
},
_a[ModuleType.FAQ] = {
name: 'FAQ',
type: ModuleType.FAQ,
singleton: false,
addAutomatically: false,
parameters: ['id'],
simpleId: false,
fetchData: true,
complex: false,
xcapModuleType: 'forum',
defaultContext: 'question'
},
_a[ModuleType.FORUM] = {
name: 'Forum',
type: ModuleType.FORUM,
singleton: false,
addAutomatically: false,
parameters: ['id'],
simpleId: false,
fetchData: true,
complex: false,
xcapModuleType: 'forum',
defaultContext: 'forum'
},
_a[ModuleType.LOGIN] = {
name: 'Login',
type: ModuleType.LOGIN,
singleton: false,
addAutomatically: true,
parameters: ['id'],
simpleId: true,
fetchData: false,
complex: false,
xcapModuleType: null,
defaultContext: 'members'
},
_a[ModuleType.PROFILE] = {
name: 'Profile',
type: ModuleType.PROFILE,
singleton: true,
addAutomatically: true,
parameters: ['id'],
simpleId: true,
fetchData: false,
complex: false,
xcapModuleType: null,
defaultContext: 'members'
},
_a[ModuleType.COMMENTS] = {
name: 'Comments',
type: ModuleType.COMMENTS,
singleton: false,
addAutomatically: false,
parameters: ['id', 'reference-id', 'group-id', 'layout'],
simpleId: false,
fetchData: true,
complex: false,
xcapModuleType: 'comment',
defaultContext: 'comments'
},
_a[ModuleType.CMS] = {
name: 'Code Bin',
type: ModuleType.CMS,
singleton: false,
addAutomatically: false,
parameters: ['id'],
simpleId: false,
fetchData: true,
complex: false,
xcapModuleType: 'cms',
defaultContext: 'cms'
},
_a[ModuleType.PAGE] = {
name: 'Page',
type: ModuleType.PAGE,
singleton: false,
addAutomatically: false,
parameters: ['id'],
simpleId: false,
fetchData: true,
complex: false,
xcapModuleType: 'page',
defaultContext: 'cms'
},
_a[ModuleType.SUBSITE] = {
name: 'Site',
type: ModuleType.SUBSITE,
singleton: false,
addAutomatically: false,
parameters: ['id', 'menu'],
simpleId: false,
fetchData: true,
complex: false,
xcapModuleType: 'tree',
defaultContext: 'cms'
},
_a[ModuleType.BLOG] = {
name: 'Blog',
type: ModuleType.BLOG,
singleton: false,
addAutomatically: false,
parameters: ['id'],
simpleId: false,
fetchData: true,
complex: false,
xcapModuleType: 'blog',
defaultContext: 'news'
},
_a[ModuleType.SLIDESHOW] = {
name: 'Slideshow',
type: ModuleType.SLIDESHOW,
singleton: false,
addAutomatically: false,
parameters: ['delay', 'height', 'arrows', 'indicators', 'auto-play', 'animation-time'],
simpleId: true,
fetchData: false,
complex: true,
xcapModuleType: null,
defaultContext: null
},
_a[ModuleType.THROBBER] = {
name: 'Throbber',
type: ModuleType.THROBBER,
singleton: true,
addAutomatically: true,
parameters: ['id'],
simpleId: true,
fetchData: false,
complex: false,
xcapModuleType: null,
defaultContext: null
},
_a[ModuleType.SHOP_PRODUCT] = {
name: 'Product',
type: ModuleType.SHOP_PRODUCT,
singleton: false,
addAutomatically: false,
parameters: ['id', 'handle', 'layout'],
simpleId: true,
fetchData: true,
complex: false,
xcapModuleType: 'shop',
defaultContext: 'shop'
},
_a[ModuleType.SHOP_PRODUCT_LISTING] = {
name: 'Product listing',
type: ModuleType.SHOP_PRODUCT_LISTING,
singleton: false,
addAutomatically: false,
parameters: ['id', 'q', 'tags', 'productTypes', 'sort', 'layout'],
simpleId: true,
fetchData: true,
complex: false,
xcapModuleType: 'shop',
defaultContext: 'shop'
},
_a[ModuleType.SHOP_COLLECTION] = {
name: 'Product collection',
type: ModuleType.SHOP_COLLECTION,
singleton: false,
addAutomatically: false,
parameters: ['id', 'handle', 'layout'],
simpleId: true,
fetchData: true,
complex: false,
xcapModuleType: 'shop',
defaultContext: 'shop'
},
_a[ModuleType.SHOP_BASKET] = {
name: 'Shopping basket',
type: ModuleType.SHOP_BASKET,
singleton: false,
addAutomatically: false,
parameters: ['id', 'layout'],
simpleId: true,
fetchData: true,
complex: false,
xcapModuleType: 'shop',
defaultContext: 'shop'
},
_a[ModuleType.LIVE] = {
name: 'Live Event',
type: ModuleType.LIVE,
singleton: false,
addAutomatically: false,
parameters: ['id', 'layout'],
simpleId: false,
fetchData: true,
complex: false,
xcapModuleType: 'live',
defaultContext: 'comments'
},
_a[ModuleType.LIVE_LISTING] = {
name: 'Live Event Listing',
type: ModuleType.LIVE_LISTING,
singleton: false,
addAutomatically: false,
parameters: ['id'],
simpleId: true,
fetchData: true,
complex: false,
xcapModuleType: 'live',
defaultContext: 'comments'
},
_a);
/**
* The module types that should be added automatically
*/
exports.AUTOMATIC_MODULE_TYPES = [
ModuleType.GLOBAL_STYLE,
ModuleType.LOGIN,
ModuleType.PROFILE,
ModuleType.THROBBER
];
/**
* Get module info
* @param moduleType
* @returns ModuleInfo
*/
function getModuleInfo(moduleType) {
var i = exports.MODULE_INFO[moduleType];
if (typeof i === 'undefined') {
return null;
}
return i;
}
exports.getModuleInfo = getModuleInfo;
/**
* Translate a ModuleType to a value accepted by index.ts
* @param moduleType
* @returns {string}
*/
function getXcapModuleType(moduleType) {
var i = exports.MODULE_INFO[moduleType];
if (typeof i === 'undefined' || i.xcapModuleType === null) {
throw Error('Module type ' + moduleType + ' has no corresponding xcap type');
}
return i.xcapModuleType;
}
exports.getXcapModuleType = getXcapModuleType;
/**
* Get the default component context of a module type
* @param moduleType
*/
function getDefaultComponentContext(moduleType) {
var i = exports.MODULE_INFO[moduleType];
if (typeof i === 'undefined' || i.defaultContext === null) {
throw Error('Module type ' + moduleType + ' has no default component context');
}
return i.defaultContext;
}
exports.getDefaultComponentContext = getDefaultComponentContext;
/**
* Get a human readable label for the module type
* @param moduleType
* @returns {string}
*/
function getModuleLabel(moduleType) {
return exports.MODULE_INFO[moduleType].name;
}
exports.getModuleLabel = getModuleLabel;
/**
* Add module info
* @param moduleInfo
*/
function addModuleInfo(moduleInfo) {
exports.MODULE_INFO[moduleInfo.type] = moduleInfo;
if (moduleInfo.addAutomatically) {
exports.AUTOMATIC_MODULE_TYPES.push(moduleInfo.type);
}
}
exports.addModuleInfo = addModuleInfo;
/**
* Remove module info
* @param moduleType
*/
function removeModuleInfo(moduleType) {
var m = getModuleInfo(moduleType);
if (m) {
delete exports.MODULE_INFO[moduleType];
if (m.addAutomatically) {
var i = exports.AUTOMATIC_MODULE_TYPES.indexOf(moduleType);
if (i !== -1) {
exports.AUTOMATIC_MODULE_TYPES.splice(i, 1);
}
}
}
}
exports.removeModuleInfo = removeModuleInfo;
//# sourceMappingURL=modules.js.map