New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wingbot-mongodb

Package Overview
Dependencies
Maintainers
2
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wingbot-mongodb

MongoDB storage for wingbot.ai

  • 2.16.0-alpha.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42
increased by5%
Maintainers
2
Weekly downloads
 
Created
Source

MongoDB plugin for wingbot.ai

Contains storage for tokens, chat states, bot config and chat logs.


API

Classes

StateStorage

Storage for chat states

BotTokenStorage

Storage for webview tokens

ChatLogStorage

Storage for conversation logs

BotConfigStorage

Storage for wingbot.ai conversation config

AttachmentCache

Cache storage for Facebook attachments

NotificationsStorage

Typedefs

State : Object
StateCondition : Object
Token : Object
Target : Object
Subscribtion : Object
Campaign : Object
Task : Object

StateStorage

Storage for chat states

Kind: global class

new StateStorage(mongoDb, collectionName)

ParamTypeDefault
mongoDbmongodb.Db | Object
collectionNamestring"states"

stateStorage._collection : mongodb.Collection

Kind: instance property of StateStorage

stateStorage._getCollection() ⇒ Promise.<mongodb.Collection>

Kind: instance method of StateStorage

stateStorage.getState(senderId, pageId) ⇒ Promise.<(State|null)>

Kind: instance method of StateStorage

ParamType
senderIdstring
pageIdstring

stateStorage.getOrCreateAndLock(senderId, pageId, [defaultState], [timeout]) ⇒ Promise.<Object>

Load state from database and lock it to prevent another reads

Kind: instance method of StateStorage
Returns: Promise.<Object> - - conversation state

ParamTypeDefaultDescription
senderIdstringsender identifier
pageIdstringpage identifier
[defaultState]Objectdefault state of the conversation
[timeout]number300given default state

stateStorage.getStates(condition, limit, lastKey) ⇒ Promise.<{Array.<data:State>, lastKey:string}>

Kind: instance method of StateStorage

ParamTypeDefault
conditionStateCondition
limitnumber20
lastKeystringnull

stateStorage.saveState(state) ⇒ Promise.<Object>

Save the state to database

Kind: instance method of StateStorage

ParamTypeDescription
stateObjectconversation state

BotTokenStorage

Storage for webview tokens

Kind: global class

new BotTokenStorage(mongoDb, collectionName)

ParamTypeDefault
mongoDbmongodb.Db | Object
collectionNamestring"tokens"

botTokenStorage._collection : mongodb.Collection

Kind: instance property of BotTokenStorage

botTokenStorage._getCollection() ⇒ Promise.<mongodb.Collection>

Kind: instance method of BotTokenStorage

botTokenStorage.findByToken(token) ⇒ Promise.<(Token|null)>

Kind: instance method of BotTokenStorage

ParamType
tokenstring

botTokenStorage.getOrCreateToken(senderId, pageId, createToken) ⇒ Promise.<(Token|null)>

Kind: instance method of BotTokenStorage

ParamType
senderIdstring
pageIdstring
createTokenObject

ChatLogStorage

Storage for conversation logs

Kind: global class

new ChatLogStorage(mongoDb, collectionName, [log])

ParamTypeDefaultDescription
mongoDbmongodb.Db | Object
collectionNamestring"chatlogs"
[log]Objectconsole like logger

chatLogStorage._collection : mongodb.Collection

Kind: instance property of ChatLogStorage

chatLogStorage._getCollection() ⇒ Promise.<mongodb.Collection>

Kind: instance method of ChatLogStorage

chatLogStorage.getInteractions(senderId, pageId, [limit], [endAt], [startAt])

Interate history all limits are inclusive

Kind: instance method of ChatLogStorage

ParamTypeDefaultDescription
senderIdstring
pageIdstring
[limit]number10
[endAt]numberiterate backwards to history
[startAt]numberiterate forward to last interaction

chatLogStorage.log(senderId, responses, request, [metadata]) ⇒ Promise

Log single event

Kind: instance method of ChatLogStorage

ParamTypeDescription
senderIdstring
responsesArray.<Object>list of sent responses
requestObjectevent request
[metadata]Objectrequest metadata

BotConfigStorage

Storage for wingbot.ai conversation config

Kind: global class

new BotConfigStorage(mongoDb, collectionName)

ParamTypeDefault
mongoDbmongodb.Db | Object
collectionNamestring"botconfig"

botConfigStorage._collection : mongodb.Collection

Kind: instance property of BotConfigStorage

botConfigStorage._getCollection() ⇒ Promise.<mongodb.Collection>

Kind: instance method of BotConfigStorage

botConfigStorage.api([onUpdate], [acl]) ⇒ Object

Returns botUpdate API for wingbot

Kind: instance method of BotConfigStorage

ParamTypeDescription
[onUpdate]functionasync update handler function
[acl]function | Array.<string>acl configuration

botConfigStorage.invalidateConfig() ⇒ Promise

Invalidates current configuration

Kind: instance method of BotConfigStorage

botConfigStorage.getConfigTimestamp() ⇒ Promise.<number>

Kind: instance method of BotConfigStorage

botConfigStorage.updateConfig(newConfig) ⇒ Promise.<T>

Kind: instance method of BotConfigStorage

ParamType
newConfigT

botConfigStorage.getConfig() ⇒ Promise.<(Object|null)>

Kind: instance method of BotConfigStorage

AttachmentCache

Cache storage for Facebook attachments

Kind: global class

new AttachmentCache(mongoDb, collectionName)

ParamTypeDefault
mongoDbmongodb.Db | Object
collectionNamestring"attachments"

attachmentCache._collection : mongodb.Collection

Kind: instance property of AttachmentCache

attachmentCache._getCollection() ⇒ Promise.<mongodb.Collection>

Kind: instance method of AttachmentCache

attachmentCache.findAttachmentByUrl(url) ⇒ Promise.<(number|null)>

Kind: instance method of AttachmentCache

ParamType
urlstring

attachmentCache.saveAttachmentId(url, attachmentId) ⇒ Promise

Kind: instance method of AttachmentCache

ParamType
urlstring
attachmentIdnumber

NotificationsStorage

Kind: global class

new NotificationsStorage(mongoDb, collectionsPrefix)

ParamType
mongoDbmongodb.Db | Object
collectionsPrefixstring

notificationsStorage._collections : Map.<string, mongodb.Collection>

Kind: instance property of NotificationsStorage

notificationsStorage._getCollection(collectionName) ⇒ Promise.<mongodb.Collection>

Kind: instance method of NotificationsStorage

ParamType
collectionNamestring

notificationsStorage.pushTasks(tasks) ⇒ Promise.<Array.<Task>>

Kind: instance method of NotificationsStorage

ParamType
tasksObject

notificationsStorage.getUnsuccessfulSubscribersByCampaign(campaignId, [sentWithoutReaction], [pageId])

Kind: instance method of NotificationsStorage

ParamTypeDefault
campaignIdstring
[sentWithoutReaction]booleanfalse
[pageId]stringnull

notificationsStorage.updateTask(taskId, data)

Kind: instance method of NotificationsStorage

ParamType
taskIdstring
dataObject

notificationsStorage.getSentTask(pageId, senderId, campaignId) ⇒ Promise.<(Task|null)>

Get last sent task from campaign

Kind: instance method of NotificationsStorage

ParamType
pageIdstring
senderIdstring
campaignIdstring

notificationsStorage.getSentCampagnIds(pageId, senderId, checkCampaignIds) ⇒ Promise.<Array.<string>>

Kind: instance method of NotificationsStorage

ParamType
pageIdstring
senderIdstring
checkCampaignIdsArray.<string>

notificationsStorage.updateTasksByWatermark(senderId, pageId, watermark, eventType, ts) ⇒ Promise.<Array.<Task>>

Kind: instance method of NotificationsStorage

ParamType
senderIdstring
pageIdstring
watermarknumber
eventType'read' | 'delivery'
tsnumber

notificationsStorage.upsertCampaign(campaign, [updateCampaign]) ⇒ Promise.<Campaign>

Kind: instance method of NotificationsStorage

ParamTypeDefault
campaignObject
[updateCampaign]Object

notificationsStorage.removeCampaign(campaignId) ⇒ Promise

Kind: instance method of NotificationsStorage

ParamType
campaignIdstring

notificationsStorage.incrementCampaign(campaignId, increment) ⇒ Promise

Kind: instance method of NotificationsStorage

ParamType
campaignIdstring
incrementObject

notificationsStorage.updateCampaign(campaignId, data) ⇒ Promise.<(Campaign|null)>

Kind: instance method of NotificationsStorage

ParamType
campaignIdstring
dataObject

notificationsStorage.popCampaign([now]) ⇒ Promise.<(Campaign|null)>

Kind: instance method of NotificationsStorage

ParamType
[now]number

notificationsStorage.getCampaignById(campaignId) ⇒ Promise.<(null|Campaign)>

Kind: instance method of NotificationsStorage

ParamType
campaignIdstring

notificationsStorage.getCampaignByIds(campaignIds) ⇒ Promise.<Array.<Campaign>>

Kind: instance method of NotificationsStorage

ParamType
campaignIdsArray.<string>

notificationsStorage.getCampaigns(condition, [limit], [lastKey]) ⇒ Promise.<{Array.<data:Campaign>, lastKey:string}>

Kind: instance method of NotificationsStorage

ParamTypeDefault
conditionObject
[limit]number
[lastKey]Object

notificationsStorage.subscribe(senderId, pageId, tag) ⇒ Promise

Kind: instance method of NotificationsStorage

ParamType
senderIdstring
pageIdstring
tagstring

notificationsStorage.unsubscribe(senderId, pageId, [tag]) ⇒ Promise.<Array.<string>>

Kind: instance method of NotificationsStorage

ParamTypeDefault
senderIdstring
pageIdstring
[tag]stringnull

notificationsStorage.getSubscribtionsCount(include, exclude, [pageId]) ⇒ Promise.<number>

Kind: instance method of NotificationsStorage

ParamTypeDefault
includeArray.<string>
excludeArray.<string>
[pageId]stringnull

notificationsStorage.getSubscribtions(include, exclude, limit, [pageId], lastKey) ⇒ Promise.<{data: Array.<Target>, lastKey: string}>

Kind: instance method of NotificationsStorage

ParamTypeDefault
includeArray.<string>
excludeArray.<string>
limitnumber
[pageId]stringnull
lastKey*

notificationsStorage.getSenderSubscribtions(senderId, pageId) ⇒ Promise.<Array.<string>>

Kind: instance method of NotificationsStorage

ParamType
senderIdstring
pageIdstring

State : Object

Kind: global typedef
Properties

NameType
senderIdstring
pageIdstring
stateObject

StateCondition : Object

Kind: global typedef
Properties

NameType
[search]string

Token : Object

Kind: global typedef
Properties

NameType
senderIdstring
pageIdstring
tokenstring

Target : Object

Kind: global typedef
Properties

NameType
senderIdstring
pageIdstring

Subscribtion : Object

Kind: global typedef
Properties

NameType
senderIdstring
pageIdstring
subsArray.<string>

Campaign : Object

Kind: global typedef
Properties

NameTypeDescription
idstring
namestringTatgeting
includeArray.<string>
excludeArray.<string>Stats
sentnumber
succeedednumber
failednumber
unsubscribednumber
deliverynumber
readnumber
notSentnumber
leavednumber
queuednumberInteraction
actionstring
[data]ObjectSetup
slidingboolean
slidenumber
slideRoundnumber
activeboolean
in24hourWindowboolean
startAtnumber

Task : Object

Kind: global typedef
Properties

NameTypeDescription
idstring
pageIdstring
senderIdstring
campaignIdstring
enqueuenumber
[read]number
[delivery]number
[sent]number
[insEnqueue]number
[reaction]booleanuser reacted
[leaved]numbertime the event was not sent because user left

Keywords

FAQs

Package last updated on 03 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc