@webex/common
Advanced tools
Comparing version 1.58.5 to 1.59.0
@@ -6,3 +6,12 @@ 'use strict'; | ||
}); | ||
exports.ensureMyIdIsAvailable = undefined; | ||
var _regenerator = require('babel-runtime/regenerator'); | ||
var _regenerator2 = _interopRequireDefault(_regenerator); | ||
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator'); | ||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); | ||
var _promise = require('babel-runtime/core-js/promise'); | ||
@@ -12,4 +21,42 @@ | ||
exports.default = createEventEnvelope; | ||
/** | ||
* Stores SDK users info in the sdk object if it doesn't already exist | ||
* @param {object} webex - sdk object | ||
* @returns {Promise} - Returns a promise that user info will be available | ||
*/ | ||
var ensureMyIdIsAvailable = exports.ensureMyIdIsAvailable = function () { | ||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(webex) { | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (!('me' in webex.internal)) { | ||
_context.next = 2; | ||
break; | ||
} | ||
return _context.abrupt('return', _promise2.default.resolve()); | ||
case 2: | ||
return _context.abrupt('return', webex.people.get('me').then(function (person) { | ||
webex.internal.me = person; | ||
return _promise2.default.resolve(); | ||
})); | ||
case 3: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
return function ensureMyIdIsAvailable(_x) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
exports.createEventEnvelope = createEventEnvelope; | ||
var _common = require('@webex/common'); | ||
@@ -26,20 +73,18 @@ | ||
function createEventEnvelope(webex, resource) { | ||
return new _promise2.default(function (resolve, reject) { | ||
webex.people.get('me').then(function (person) { | ||
resolve({ | ||
createdBy: person.id, | ||
orgId: person.orgId, | ||
resource: resource, | ||
// id -- webhook id concept does not correlate to SDK socket event | ||
// name -- webhook name concept does not correlate to SDK socket event | ||
// targetUrl -- targetUrl concept does not correlate to SDK socket event | ||
// secret -- secret concept does not correlate to SDK socket event | ||
ownedBy: _common.SDK_EVENT.EXTERNAL.OWNER.CREATOR, | ||
status: _common.SDK_EVENT.EXTERNAL.STATUS.ACTIVE, | ||
created: new Date().toISOString(), | ||
data: {} | ||
}); | ||
}).catch(function (e) { | ||
reject(new Error('Unable to get person info for ' + resource + ' event envelope: ' + e.message)); | ||
return ensureMyIdIsAvailable(webex).then(function () { | ||
return _promise2.default.resolve({ | ||
createdBy: webex.internal.me.id, | ||
orgId: webex.internal.me.orgId, | ||
resource: resource, | ||
// id -- webhook id concept does not correlate to SDK socket event | ||
// name -- webhook name concept does not correlate to SDK socket event | ||
// targetUrl -- targetUrl concept does not correlate to SDK socket event | ||
// secret -- secret concept does not correlate to SDK socket event | ||
ownedBy: _common.SDK_EVENT.EXTERNAL.OWNER.CREATOR, | ||
status: _common.SDK_EVENT.EXTERNAL.STATUS.ACTIVE, | ||
created: new Date().toISOString(), | ||
data: {} | ||
}); | ||
}).catch(function (e) { | ||
_promise2.default.reject(new Error('Unable to get person info for ' + resource + ' event envelope: ' + e.message)); | ||
}); | ||
@@ -46,0 +91,0 @@ } /*! |
@@ -99,5 +99,11 @@ 'use strict'; | ||
get: function get() { | ||
return _interopRequireDefault(_eventEnvelope).default; | ||
return _eventEnvelope.createEventEnvelope; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'ensureMyIdIsAvailable', { | ||
enumerable: true, | ||
get: function get() { | ||
return _eventEnvelope.ensureMyIdIsAvailable; | ||
} | ||
}); | ||
@@ -239,3 +245,12 @@ var _resolveWith = require('./resolve-with'); | ||
var _wdmRegister = require('./wdm-register.js'); | ||
Object.defineProperty(exports, 'ensureConvoAvailability', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_wdmRegister).default; | ||
} | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@webex/common", | ||
"version": "1.58.5", | ||
"version": "1.59.0", | ||
"description": "Common utilities for Cisco Webex", | ||
@@ -26,3 +26,3 @@ "license": "MIT", | ||
"lodash": "^4.17.11", | ||
"@webex/common": "1.58.5", | ||
"@webex/common": "1.59.0", | ||
"backoff": "^2.5.0", | ||
@@ -29,0 +29,0 @@ "core-decorators": "^0.20.0", |
@@ -13,24 +13,39 @@ /*! | ||
*/ | ||
export default function createEventEnvelope(webex, resource) { | ||
return new Promise((resolve, reject) => { | ||
webex.people.get('me') | ||
.then((person) => { | ||
resolve({ | ||
createdBy: person.id, | ||
orgId: person.orgId, | ||
resource, | ||
// id -- webhook id concept does not correlate to SDK socket event | ||
// name -- webhook name concept does not correlate to SDK socket event | ||
// targetUrl -- targetUrl concept does not correlate to SDK socket event | ||
// secret -- secret concept does not correlate to SDK socket event | ||
ownedBy: SDK_EVENT.EXTERNAL.OWNER.CREATOR, | ||
status: SDK_EVENT.EXTERNAL.STATUS.ACTIVE, | ||
created: new Date().toISOString(), | ||
data: {} | ||
}); | ||
}).catch((e) => { | ||
reject(new Error(`Unable to get person info for ${resource} \ | ||
export function createEventEnvelope(webex, resource) { | ||
return ensureMyIdIsAvailable(webex) | ||
.then(() => Promise.resolve({ | ||
createdBy: webex.internal.me.id, | ||
orgId: webex.internal.me.orgId, | ||
resource, | ||
// id -- webhook id concept does not correlate to SDK socket event | ||
// name -- webhook name concept does not correlate to SDK socket event | ||
// targetUrl -- targetUrl concept does not correlate to SDK socket event | ||
// secret -- secret concept does not correlate to SDK socket event | ||
ownedBy: SDK_EVENT.EXTERNAL.OWNER.CREATOR, | ||
status: SDK_EVENT.EXTERNAL.STATUS.ACTIVE, | ||
created: new Date().toISOString(), | ||
data: {} | ||
})).catch((e) => { | ||
Promise.reject(new Error(`Unable to get person info for ${resource} \ | ||
event envelope: ${e.message}`)); | ||
}); | ||
}); | ||
}); | ||
} | ||
/** | ||
* Stores SDK users info in the sdk object if it doesn't already exist | ||
* @param {object} webex - sdk object | ||
* @returns {Promise} - Returns a promise that user info will be available | ||
*/ | ||
export async function ensureMyIdIsAvailable(webex) { | ||
// If we don't have it, save info about our user | ||
if (('me' in webex.internal)) { | ||
return Promise.resolve(); | ||
} | ||
return webex.people.get('me') | ||
.then((person) => { | ||
webex.internal.me = person; | ||
return Promise.resolve(); | ||
}); | ||
} |
@@ -17,3 +17,3 @@ /*! | ||
} from './events'; | ||
export {default as createEventEnvelope} from './event-envelope'; | ||
export {createEventEnvelope, ensureMyIdIsAvailable} from './event-envelope'; | ||
export {default as resolveWith} from './resolve-with'; | ||
@@ -41,1 +41,2 @@ export {default as retry} from './retry'; | ||
} from './uuid-utils'; | ||
export {default as ensureConvoAvailability} from './wdm-register.js'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153466
77
3218
Updated@webex/common@1.59.0