UNPKG

@apidaze/node-red-contrib-apidaze

Version:
42 lines (34 loc) 1.35 kB
/** * The address book * * @typedef {Object.<string>, Object} AddressBook - * @property {Object} default - The default contact to use for any flow * execution that do not associate with existing contacts * @property {Object} [{string}] - Any contact that's assigned to a key that is its SIP number */ /** * A contact that resides in an address book * * @typedef {Object} Contact * @property {string} mobileDestination - A mobile number to associate with the contact * @property {string} [{string}] - Any other property that will be available in the flow execution */ module.exports = function (RED) { 'use strict'; function DataProvider(config) { RED.nodes.createNode(this, config); const context = this.context(); /** * @param {Object} msg - The message object * @param {Object} msg.payload - The payload object that contains the flow payload * @param {AddressBook} msg.payload.addressBook - The address book that will be used in the flow executions */ this.on('input', (msg, send, done) => { const { addressBook } = msg.payload; // set the incoming data in the context to make it available in flow executions context.flow.set('addressBook', addressBook); context.flow.set('messageStore', {}); }); } RED.nodes.registerType('data-provider', DataProvider); };