Adds documentations for adapters and main constructors (#4951)
* wip * Adds documentations for adapters, and constructors * nits * nit
This commit is contained in:
@@ -1,4 +1,15 @@
|
||||
export function loadAdapter(adapter, defaultAdapter, options) {
|
||||
/**
|
||||
* @module AdapterLoader
|
||||
*/
|
||||
/**
|
||||
* @static
|
||||
* Attempt to load an adapter or fallback to the default.
|
||||
* @param {Adapter} adapter an adapter
|
||||
* @param {Adapter} defaultAdapter the default adapter to load
|
||||
* @param {any} options options to pass to the contstructor
|
||||
* @returns {Object} the loaded adapter
|
||||
*/
|
||||
export function loadAdapter<T>(adapter, defaultAdapter, options): T {
|
||||
if (!adapter) {
|
||||
if (!defaultAdapter) {
|
||||
return options;
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
/*eslint no-unused-vars: "off"*/
|
||||
/**
|
||||
* @module Adapters
|
||||
*/
|
||||
/**
|
||||
* @interface AnalyticsAdapter
|
||||
*/
|
||||
export class AnalyticsAdapter {
|
||||
|
||||
/*
|
||||
@param parameters: the analytics request body, analytics info will be in the dimensions property
|
||||
@param req: the original http request
|
||||
/**
|
||||
@param {any} parameters: the analytics request body, analytics info will be in the dimensions property
|
||||
@param {Request} req: the original http request
|
||||
*/
|
||||
appOpened(parameters, req) {
|
||||
return Promise.resolve({});
|
||||
}
|
||||
|
||||
/*
|
||||
@param eventName: the name of the custom eventName
|
||||
@param parameters: the analytics request body, analytics info will be in the dimensions property
|
||||
@param req: the original http request
|
||||
/**
|
||||
@param {String} eventName: the name of the custom eventName
|
||||
@param {any} parameters: the analytics request body, analytics info will be in the dimensions property
|
||||
@param {Request} req: the original http request
|
||||
*/
|
||||
trackEvent(eventName, parameters, req) {
|
||||
return Promise.resolve({});
|
||||
|
||||
@@ -1,23 +1,29 @@
|
||||
/*eslint no-unused-vars: "off"*/
|
||||
/**
|
||||
* @module Adapters
|
||||
*/
|
||||
/**
|
||||
* @interface CacheAdapter
|
||||
*/
|
||||
export class CacheAdapter {
|
||||
/**
|
||||
* Get a value in the cache
|
||||
* @param key Cache key to get
|
||||
* @return Promise that will eventually resolve to the value in the cache.
|
||||
* @param {String} key Cache key to get
|
||||
* @return {Promise} that will eventually resolve to the value in the cache.
|
||||
*/
|
||||
get(key) {}
|
||||
|
||||
/**
|
||||
* Set a value in the cache
|
||||
* @param key Cache key to set
|
||||
* @param value Value to set the key
|
||||
* @param ttl Optional TTL
|
||||
* @param {String} key Cache key to set
|
||||
* @param {String} value Value to set the key
|
||||
* @param {String} ttl Optional TTL
|
||||
*/
|
||||
put(key, value, ttl) {}
|
||||
|
||||
/**
|
||||
* Remove a value from the cache.
|
||||
* @param key Cache key to remove
|
||||
* @param {String} key Cache key to remove
|
||||
*/
|
||||
del(key) {}
|
||||
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
/*eslint no-unused-vars: "off"*/
|
||||
/*
|
||||
Mail Adapter prototype
|
||||
A MailAdapter should implement at least sendMail()
|
||||
/**
|
||||
* @module Adapters
|
||||
*/
|
||||
/**
|
||||
* @interface MailAdapter
|
||||
* Mail Adapter prototype
|
||||
* A MailAdapter should implement at least sendMail()
|
||||
*/
|
||||
export class MailAdapter {
|
||||
/*
|
||||
/**
|
||||
* A method for sending mail
|
||||
* @param options would have the parameters
|
||||
* - to: the recipient
|
||||
|
||||
@@ -14,10 +14,15 @@
|
||||
// database adapter.
|
||||
|
||||
import type { Config } from '../../Config'
|
||||
|
||||
/**
|
||||
* @module Adapters
|
||||
*/
|
||||
/**
|
||||
* @interface FilesAdapter
|
||||
*/
|
||||
export class FilesAdapter {
|
||||
|
||||
/* Responsible for storing the file in order to be retrieved later by its filename
|
||||
/** Responsible for storing the file in order to be retrieved later by its filename
|
||||
*
|
||||
* @param {string} filename - the filename to save
|
||||
* @param {*} data - the buffer of data from the file
|
||||
@@ -28,7 +33,7 @@ export class FilesAdapter {
|
||||
*/
|
||||
createFile(filename: string, data, contentType: string): Promise { }
|
||||
|
||||
/* Responsible for deleting the specified file
|
||||
/** Responsible for deleting the specified file
|
||||
*
|
||||
* @param {string} filename - the filename to delete
|
||||
*
|
||||
@@ -36,7 +41,7 @@ export class FilesAdapter {
|
||||
*/
|
||||
deleteFile(filename: string): Promise { }
|
||||
|
||||
/* Responsible for retrieving the data of the specified file
|
||||
/** Responsible for retrieving the data of the specified file
|
||||
*
|
||||
* @param {string} filename - the name of file to retrieve
|
||||
*
|
||||
@@ -44,7 +49,7 @@ export class FilesAdapter {
|
||||
*/
|
||||
getFileData(filename: string): Promise<any> { }
|
||||
|
||||
/* Returns an absolute URL where the file can be accessed
|
||||
/** Returns an absolute URL where the file can be accessed
|
||||
*
|
||||
* @param {Config} config - server configuration
|
||||
* @param {string} filename
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
/*eslint no-unused-vars: "off"*/
|
||||
// Logger Adapter
|
||||
//
|
||||
// Allows you to change the logger mechanism
|
||||
//
|
||||
// Adapter classes must implement the following functions:
|
||||
// * log() {}
|
||||
// * query(options, callback) /* optional */
|
||||
// Default is WinstonLoggerAdapter.js
|
||||
|
||||
/**
|
||||
* @module Adapters
|
||||
*/
|
||||
/**
|
||||
* @interface LoggerAdapter
|
||||
* Logger Adapter
|
||||
* Allows you to change the logger mechanism
|
||||
* Default is WinstonLoggerAdapter.js
|
||||
*/
|
||||
export class LoggerAdapter {
|
||||
constructor(options) {}
|
||||
/**
|
||||
* log
|
||||
* @param {String} level
|
||||
* @param {String} message
|
||||
* @param {Object} metadata
|
||||
*/
|
||||
log(level, message, /* meta */) {}
|
||||
}
|
||||
|
||||
|
||||
49
src/Adapters/PubSub/PubSubAdapter.js
Normal file
49
src/Adapters/PubSub/PubSubAdapter.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/*eslint no-unused-vars: "off"*/
|
||||
/**
|
||||
* @module Adapters
|
||||
*/
|
||||
/**
|
||||
* @interface PubSubAdapter
|
||||
*/
|
||||
export class PubSubAdapter {
|
||||
/**
|
||||
* @returns {PubSubAdapter.Publisher}
|
||||
*/
|
||||
static createPublisher() {}
|
||||
/**
|
||||
* @returns {PubSubAdapter.Subscriber}
|
||||
*/
|
||||
static createSubscriber() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @interface Publisher
|
||||
* @memberof PubSubAdapter
|
||||
*/
|
||||
interface Publisher {
|
||||
/**
|
||||
* @param {String} channel the channel in which to publish
|
||||
* @param {String} message the message to publish
|
||||
*/
|
||||
publish(channel: string, message: string):void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @interface Subscriber
|
||||
* @memberof PubSubAdapter
|
||||
*/
|
||||
interface Subscriber {
|
||||
/**
|
||||
* called when a new subscription the channel is required
|
||||
* @param {String} channel the channel to subscribe
|
||||
*/
|
||||
subscribe(channel: string): void;
|
||||
|
||||
/**
|
||||
* called when the subscription from the channel should be stopped
|
||||
* @param {String} channel
|
||||
*/
|
||||
unsubscribe(channel: string): void;
|
||||
}
|
||||
|
||||
export default PubSubAdapter;
|
||||
@@ -11,7 +11,19 @@
|
||||
// Default is ParsePushAdapter, which uses GCM for
|
||||
// android push and APNS for ios push.
|
||||
|
||||
/**
|
||||
* @module Adapters
|
||||
*/
|
||||
/**
|
||||
* @interface PushAdapter
|
||||
*/
|
||||
export class PushAdapter {
|
||||
/**
|
||||
* @param {any} body
|
||||
* @param {Parse.Installation[]} installations
|
||||
* @param {any} pushStatus
|
||||
* @returns {Promise}
|
||||
*/
|
||||
send(body: any, installations: any[], pushStatus: any): ?Promise<*> {}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user