UNPKG

@reactivehub/cli

Version:
85 lines (68 loc) 2.67 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends2 = require('babel-runtime/helpers/extends'); var _extends3 = _interopRequireDefault(_extends2); var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator'); var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); var _api = require('../../services/api'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const hookEvents = [{ id: '*' }, { id: 'added' }, { id: 'updated' }, { id: 'merged' }, { id: 'deleted' }]; const hookObjects = [{ id: '*' }, { id: 'activity' }, { id: 'activityType' }, { id: 'deal' }, { id: 'note' }, { id: 'organization' }, { id: 'person' }, { id: 'pipeline' }, { id: 'product' }, { id: 'stage' }, { id: 'user' }]; const filterMatchInput = (input, inputList) => inputList.filter(({ id = '', name = '' }) => id.match(input) || name.match(input) || !input).map(({ id }) => id); const questions = [{ type: 'autocomplete', name: 'event_action', message: 'Select the event action!', source: (() => { var _ref = (0, _asyncToGenerator3.default)(function* (answersSoFar, input) { return filterMatchInput(input, hookEvents); }); return function source(_x, _x2) { return _ref.apply(this, arguments); }; })() }, { type: 'autocomplete', name: 'event_object', message: 'Select the event object!', source: (() => { var _ref2 = (0, _asyncToGenerator3.default)(function* (answersSoFar, input) { return filterMatchInput(input, hookObjects); }); return function source(_x3, _x4) { return _ref2.apply(this, arguments); }; })() }, { type: 'input', name: 'subscription_url', message: 'Destination URL:' }]; const LIST_WEBHOOKS = { name: 'LIST_WEBHOOKS', deploy: (action, eventInfo) => (0, _api.sendAction)(eventInfo, (0, _extends3.default)({ serviceAction: 'LIST_WEBHOOKS' }, action)), buildTemplate: () => ({}), questions: () => [] }; const CREATE_WEBHOOK = { name: 'CREATE_WEBHOOK', deploy: (action, eventInfo) => (0, _api.sendAction)(eventInfo, (0, _extends3.default)({ serviceAction: 'CREATE_WEBHOOK' }, action)), buildTemplate: (answers = {}) => (0, _extends3.default)({}, answers), questions: () => questions }; const DELETE_WEBHOOK = { name: 'DELETE_WEBHOOK', deploy: (action, eventInfo) => (0, _api.sendAction)(eventInfo, (0, _extends3.default)({ serviceAction: 'DELETE_WEBHOOK' }, action)), buildTemplate: () => ({ id: 'String' }), questions: () => null }; exports.default = { LIST_WEBHOOKS, CREATE_WEBHOOK, DELETE_WEBHOOK }; //# sourceMappingURL=webhook.js.map