built.io-browserify
Version:
SDK for Built.io Backend which is compatible with Browserify
184 lines (165 loc) • 5.32 kB
JavaScript
/*
Hold all the plugins.
*/
pluginsHelper = {
plugins: [],
registerPlugin: function(name, plugin) {
var obj = {};
obj[name] = plugin;
this.plugins.push(obj);
}
}
var R = require('ramda');
var rawOptions = require('../config');
var ACL1 = require('./acl');
var utility = require('./utilities/utility');
var App1 = require('./app');
var Loc = require('./location');
var defaultOptions = R.mixin({}, rawOptions);
var Events1 = require('./events');
var Presence1 = require('./presence');
var Constants = require('./constants');
var GroupMultiple1 = require('./group-multiple')
var Group1 = require('./group')
var Upsert1 = require('./upsert')
var Mixin1 = require('./utilities/mixin').Mixin;
defaultOptions.adaptor = require('./adaptors/RestfullAdaptor');
/**
The Built module acts as the entry point for the SDK.
@namespace Built
*/
/*
String constants
*/
var RestfullAdaptor = './adaptors/RestfullAdaptor';
// var SocketAdaptor = './adaptors/SocketAdaptor';
/**
Represents a {@link App}
@memberof Built
*/
// var App = App1(defaultOptions);
var App = utility.wrapper(App1(defaultOptions), ["", {}]);
module.exports.App = App
/**
Represents a {@link ACL}
@name ACL
@memberof Built
*/
var ACL = utility.wrapper(ACL1,[{}]);
module.exports.ACL = ACL
/**
Represents an {@link Location}
@memberof Built
*/
var Location = utility.wrapper(Loc,["",""]);
module.exports.Location = Location
/**
{@link Events} raised on this application. For example, an event is raised every time an http request is fired.
@memberof Built
*/
var Events = Events1;
module.exports.Events = Events
/**
{@link Presence} details of User.
@memberof Built
*/
var Presence = utility.wrapper(Presence1,[{}]);
module.exports.Presence = Presence
/**
Represents a {@link Group}
@memberof Built
*/
var Group = Group1;
module.exports.Group = Group
/**
Represents a {@link GroupMultiple}
@memberof Built
*/
var GroupMultiple = GroupMultiple1;
module.exports.GroupMultiple = GroupMultiple
/**
Represents a {@link Mixin}
@memberof Built
*/
var Mixin = Mixin1;
module.exports.Mixin = Mixin
/**
Represents a {@link Upsert}
@memberof Built
*/
var Upsert = Upsert1;
module.exports.Upsert = Upsert
/**
Set of modes through which logged-in user's session can be maintained
@memberof Built
@enum {String}
@example
//'blt5d4sample2633b' is a dummy Application API key
var app = Built.App('blt5d4sample2633b').persistSessionWith(Built.Session.COOKIE);
*/
var Session = {
/** Set Cookie as the storage medium to maintain session */
COOKIE : 'COOKIE',
/** Set HTML 5 local storage as the storage medium to maintain session */
LOCAL_STORAGE : 'LOCAL_STORAGE',
/** By Default, sessions are not maintained in Node; to maintain sessions, set persistSession to Memory.*/
MEMORY : 'MEMORY',
/** No session would be maintained */
NONE : 'NONE'
}
/**
Constants for system classes names on Built.io Backend
@memberof Built
@enum {String}
@example
//'blt5d4sample2633b' is a dummy Application API key
var app = Built.App('blt5d4sample2633b').Class(Built.Constants.APPLICATION_USER);
*/
var Constants = {
/** Class name for application-user class on Built.io Backend*/
APPLICATION_USER : Constants.APP_USER_CLS,
/** Class name for application-user-role class on Built.io Backend */
APPLICATION_USER_ROLE : Constants.APP_ROLE_CLS,
/** Class name for installation class on Built.io Backend */
INSTALLATION : Constants.APP_INSTALLATION_CLS
}
/**
Set of cache policies
@memberof Built
@enum {String}
@example
//'blt5d4sample2633b' is a dummy Application API key
var app = Built.App('blt5d4sample2633b')
.setCachePolicy(Built.CachePolicy.CACHE_ELSE_NETWORK);
*/
var CachePolicy = {
/** No cache is being maintained. Always a network call is made to retrieve data (Default). */
ONLY_NETWORK : 'ONLY_NETWORK',
/** It will try to first get the data from cache. On failure would make a network call. */
CACHE_ELSE_NETWORK : 'CACHE_ELSE_NETWORK',
/** It will try to make a network call. On failure would fetch it from cache.*/
NETWORK_ELSE_CACHE : 'NETWORK_ELSE_CACHE',
/** Get data from both cache and network. */
CACHE_THEN_NETWORK : 'CACHE_THEN_NETWORK'
}
/*
Set of avaliable adaptors that can be used
@memberof Built
@enum {String}
@example
//'blt5d4sample2633b' is a dummy Application API key
var app = Built.App('blt5d4sample2633b').setAdaptor(Built.Adaptor.SOCKET);
*/
var Adaptor = {
HTTP : RestfullAdaptor/*,
SOCKET : SocketAdaptor*/
}
module.exports.Constants = Constants;
module.exports.Session = Session;
module.exports.CachePolicy = CachePolicy;
module.exports.Adaptor = Adaptor;
utility.copyProperties(module.exports.ACL , ACL1);
// utility.copyProperties(module.exports , module.exports);
utility.copyProperties(module.exports.App , App1);
utility.copyProperties(module.exports.Location , Loc);
utility.copyProperties(module.exports.Presence , Presence1);