@webex/common 2.59.3-next.1 → 2.59.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +6 -6
- package/README.md +42 -42
- package/babel.config.js +3 -3
- package/dist/base64.js +22 -22
- package/dist/base64.js.map +1 -1
- package/dist/browser-detection.js.map +1 -1
- package/dist/capped-debounce.js +12 -12
- package/dist/capped-debounce.js.map +1 -1
- package/dist/check-required.js +8 -8
- package/dist/check-required.js.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/defer.js +13 -13
- package/dist/defer.js.map +1 -1
- package/dist/deprecated.js +5 -5
- package/dist/deprecated.js.map +1 -1
- package/dist/event-envelope.js +11 -11
- package/dist/event-envelope.js.map +1 -1
- package/dist/events.js +15 -15
- package/dist/events.js.map +1 -1
- package/dist/exception.js +13 -13
- package/dist/exception.js.map +1 -1
- package/dist/in-browser/browser.js +2 -2
- package/dist/in-browser/browser.js.map +1 -1
- package/dist/in-browser/index.js.map +1 -1
- package/dist/in-browser/node.js +2 -2
- package/dist/in-browser/node.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/isBuffer.js +6 -6
- package/dist/isBuffer.js.map +1 -1
- package/dist/make-state-datatype.js +14 -14
- package/dist/make-state-datatype.js.map +1 -1
- package/dist/one-flight.js +13 -13
- package/dist/one-flight.js.map +1 -1
- package/dist/patterns.js +30 -30
- package/dist/patterns.js.map +1 -1
- package/dist/resolve-with.js +19 -19
- package/dist/resolve-with.js.map +1 -1
- package/dist/retry.js +17 -17
- package/dist/retry.js.map +1 -1
- package/dist/tap.js +14 -14
- package/dist/tap.js.map +1 -1
- package/dist/template-container.js +51 -51
- package/dist/template-container.js.map +1 -1
- package/dist/uuid-utils.js +76 -76
- package/dist/uuid-utils.js.map +1 -1
- package/dist/while-in-flight.js +5 -5
- package/dist/while-in-flight.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +11 -12
- package/process +1 -1
- package/src/base64.js +67 -67
- package/src/browser-detection.js +37 -37
- package/src/capped-debounce.js +65 -65
- package/src/check-required.js +18 -18
- package/src/constants.js +79 -79
- package/src/defer.js +24 -24
- package/src/deprecated.js +19 -19
- package/src/event-envelope.js +54 -54
- package/src/events.js +55 -55
- package/src/exception.js +45 -45
- package/src/in-browser/browser.js +5 -5
- package/src/in-browser/index.js +11 -11
- package/src/in-browser/node.js +5 -5
- package/src/index.js +44 -44
- package/src/isBuffer.js +12 -12
- package/src/make-state-datatype.js +91 -91
- package/src/one-flight.js +89 -89
- package/src/patterns.js +51 -51
- package/src/resolve-with.js +27 -27
- package/src/retry.js +124 -124
- package/src/tap.js +25 -25
- package/src/template-container.js +222 -222
- package/src/uuid-utils.js +189 -189
- package/src/while-in-flight.js +38 -38
- package/test/unit/spec/capped-debounce.js +103 -103
- package/test/unit/spec/common.js +42 -42
- package/test/unit/spec/exception.js +102 -102
- package/test/unit/spec/one-flight.js +211 -211
- package/test/unit/spec/template-container.js +81 -81
- package/test/unit/spec/while-in-flight.js +70 -70
package/src/event-envelope.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {SDK_EVENT} from './constants';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Creates a 'webhook' envelope to wrap Webex events in
|
|
9
|
-
* @param {object} webex - sdk object
|
|
10
|
-
* @param {string} resource - resource to create an envelope for
|
|
11
|
-
* @returns {object} - Returns a promise of an event envelope object
|
|
12
|
-
*/
|
|
13
|
-
export function createEventEnvelope(webex, resource) {
|
|
14
|
-
return ensureMyIdIsAvailable(webex)
|
|
15
|
-
.then(() =>
|
|
16
|
-
Promise.resolve({
|
|
17
|
-
createdBy: webex.internal.me.id,
|
|
18
|
-
orgId: webex.internal.me.orgId,
|
|
19
|
-
resource,
|
|
20
|
-
// id -- webhook id concept does not correlate to SDK socket event
|
|
21
|
-
// name -- webhook name concept does not correlate to SDK socket event
|
|
22
|
-
// targetUrl -- targetUrl concept does not correlate to SDK socket event
|
|
23
|
-
// secret -- secret concept does not correlate to SDK socket event
|
|
24
|
-
ownedBy: SDK_EVENT.EXTERNAL.OWNER.CREATOR,
|
|
25
|
-
status: SDK_EVENT.EXTERNAL.STATUS.ACTIVE,
|
|
26
|
-
created: new Date().toISOString(),
|
|
27
|
-
data: {},
|
|
28
|
-
})
|
|
29
|
-
)
|
|
30
|
-
.catch((e) => {
|
|
31
|
-
Promise.reject(
|
|
32
|
-
new Error(`Unable to get person info for ${resource} \
|
|
33
|
-
event envelope: ${e.message}`)
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Stores SDK users info in the sdk object if it doesn't already exist
|
|
40
|
-
* @param {object} webex - sdk object
|
|
41
|
-
* @returns {Promise} - Returns a promise that user info will be available
|
|
42
|
-
*/
|
|
43
|
-
export async function ensureMyIdIsAvailable(webex) {
|
|
44
|
-
// If we don't have it, save info about our user
|
|
45
|
-
if ('me' in webex.internal) {
|
|
46
|
-
return Promise.resolve();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return webex.people.get('me').then((person) => {
|
|
50
|
-
webex.internal.me = person;
|
|
51
|
-
|
|
52
|
-
return Promise.resolve();
|
|
53
|
-
});
|
|
54
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {SDK_EVENT} from './constants';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates a 'webhook' envelope to wrap Webex events in
|
|
9
|
+
* @param {object} webex - sdk object
|
|
10
|
+
* @param {string} resource - resource to create an envelope for
|
|
11
|
+
* @returns {object} - Returns a promise of an event envelope object
|
|
12
|
+
*/
|
|
13
|
+
export function createEventEnvelope(webex, resource) {
|
|
14
|
+
return ensureMyIdIsAvailable(webex)
|
|
15
|
+
.then(() =>
|
|
16
|
+
Promise.resolve({
|
|
17
|
+
createdBy: webex.internal.me.id,
|
|
18
|
+
orgId: webex.internal.me.orgId,
|
|
19
|
+
resource,
|
|
20
|
+
// id -- webhook id concept does not correlate to SDK socket event
|
|
21
|
+
// name -- webhook name concept does not correlate to SDK socket event
|
|
22
|
+
// targetUrl -- targetUrl concept does not correlate to SDK socket event
|
|
23
|
+
// secret -- secret concept does not correlate to SDK socket event
|
|
24
|
+
ownedBy: SDK_EVENT.EXTERNAL.OWNER.CREATOR,
|
|
25
|
+
status: SDK_EVENT.EXTERNAL.STATUS.ACTIVE,
|
|
26
|
+
created: new Date().toISOString(),
|
|
27
|
+
data: {},
|
|
28
|
+
})
|
|
29
|
+
)
|
|
30
|
+
.catch((e) => {
|
|
31
|
+
Promise.reject(
|
|
32
|
+
new Error(`Unable to get person info for ${resource} \
|
|
33
|
+
event envelope: ${e.message}`)
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Stores SDK users info in the sdk object if it doesn't already exist
|
|
40
|
+
* @param {object} webex - sdk object
|
|
41
|
+
* @returns {Promise} - Returns a promise that user info will be available
|
|
42
|
+
*/
|
|
43
|
+
export async function ensureMyIdIsAvailable(webex) {
|
|
44
|
+
// If we don't have it, save info about our user
|
|
45
|
+
if ('me' in webex.internal) {
|
|
46
|
+
return Promise.resolve();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return webex.people.get('me').then((person) => {
|
|
50
|
+
webex.internal.me = person;
|
|
51
|
+
|
|
52
|
+
return Promise.resolve();
|
|
53
|
+
});
|
|
54
|
+
}
|
package/src/events.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {isArray} from 'lodash';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Proxies the event binding methods of emitter onto proxy
|
|
9
|
-
* @param {EventEmitter|EventEmitterProxy} emitter
|
|
10
|
-
* @param {mixed} proxy (probably a promise)
|
|
11
|
-
* @returns {EventEmitter} Returns the source emitter to ease use in promise chains
|
|
12
|
-
*/
|
|
13
|
-
export function proxyEvents(emitter, proxy) {
|
|
14
|
-
['on', 'once'].forEach((key) => {
|
|
15
|
-
proxy[key] = (...args) => {
|
|
16
|
-
emitter[key](...args);
|
|
17
|
-
|
|
18
|
-
return proxy;
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
return emitter;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Given a list of events, fires them on drain when they're emitted from source
|
|
27
|
-
* @param {Array|string} events
|
|
28
|
-
* @param {EventEmitter} source
|
|
29
|
-
* @param {EventEmitter} drain
|
|
30
|
-
* @returns {undefined}
|
|
31
|
-
*/
|
|
32
|
-
export function transferEvents(events, source, drain) {
|
|
33
|
-
events = isArray(events) ? events : [events];
|
|
34
|
-
events.forEach((event) => {
|
|
35
|
-
if (source.on) {
|
|
36
|
-
source.on(event, (...args) => emit(drain, event, ...args));
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Emits an event
|
|
43
|
-
* @param {EventEmitter} target The EventEmitter from which to emit an event
|
|
44
|
-
* @returns {mixed}
|
|
45
|
-
*/
|
|
46
|
-
function emit(target, ...rest) {
|
|
47
|
-
const method = target.trigger || target.emit;
|
|
48
|
-
|
|
49
|
-
/* istanbul ignore if */
|
|
50
|
-
if (!method) {
|
|
51
|
-
throw new Error('count not determine emit method');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return Reflect.apply(method, target, rest);
|
|
55
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {isArray} from 'lodash';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Proxies the event binding methods of emitter onto proxy
|
|
9
|
+
* @param {EventEmitter|EventEmitterProxy} emitter
|
|
10
|
+
* @param {mixed} proxy (probably a promise)
|
|
11
|
+
* @returns {EventEmitter} Returns the source emitter to ease use in promise chains
|
|
12
|
+
*/
|
|
13
|
+
export function proxyEvents(emitter, proxy) {
|
|
14
|
+
['on', 'once'].forEach((key) => {
|
|
15
|
+
proxy[key] = (...args) => {
|
|
16
|
+
emitter[key](...args);
|
|
17
|
+
|
|
18
|
+
return proxy;
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return emitter;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Given a list of events, fires them on drain when they're emitted from source
|
|
27
|
+
* @param {Array|string} events
|
|
28
|
+
* @param {EventEmitter} source
|
|
29
|
+
* @param {EventEmitter} drain
|
|
30
|
+
* @returns {undefined}
|
|
31
|
+
*/
|
|
32
|
+
export function transferEvents(events, source, drain) {
|
|
33
|
+
events = isArray(events) ? events : [events];
|
|
34
|
+
events.forEach((event) => {
|
|
35
|
+
if (source.on) {
|
|
36
|
+
source.on(event, (...args) => emit(drain, event, ...args));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Emits an event
|
|
43
|
+
* @param {EventEmitter} target The EventEmitter from which to emit an event
|
|
44
|
+
* @returns {mixed}
|
|
45
|
+
*/
|
|
46
|
+
function emit(target, ...rest) {
|
|
47
|
+
const method = target.trigger || target.emit;
|
|
48
|
+
|
|
49
|
+
/* istanbul ignore if */
|
|
50
|
+
if (!method) {
|
|
51
|
+
throw new Error('count not determine emit method');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return Reflect.apply(method, target, rest);
|
|
55
|
+
}
|
package/src/exception.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Base Exception class
|
|
7
|
-
*/
|
|
8
|
-
export default class Exception extends Error {
|
|
9
|
-
static defaultMessage = 'An error occurred';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* constructor
|
|
13
|
-
* @param {mixed} args
|
|
14
|
-
* @returns {Exception}
|
|
15
|
-
*/
|
|
16
|
-
constructor(...args) {
|
|
17
|
-
super(...args);
|
|
18
|
-
|
|
19
|
-
let message;
|
|
20
|
-
|
|
21
|
-
if (this.parse) {
|
|
22
|
-
message = this.parse(...args);
|
|
23
|
-
} else if (this.constructor.parse) {
|
|
24
|
-
message = this.constructor.parse(...args);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (!message) {
|
|
28
|
-
message = this.constructor.defaultMessage;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
this.name = this.constructor.name;
|
|
32
|
-
|
|
33
|
-
this.message = message;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Generates the value assigned to `this.message`. You'll probably want to
|
|
38
|
-
* override this in your custom Exception
|
|
39
|
-
* @param {mixed} args
|
|
40
|
-
* @returns {string}
|
|
41
|
-
*/
|
|
42
|
-
static parse(...args) {
|
|
43
|
-
return args[0];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base Exception class
|
|
7
|
+
*/
|
|
8
|
+
export default class Exception extends Error {
|
|
9
|
+
static defaultMessage = 'An error occurred';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* constructor
|
|
13
|
+
* @param {mixed} args
|
|
14
|
+
* @returns {Exception}
|
|
15
|
+
*/
|
|
16
|
+
constructor(...args) {
|
|
17
|
+
super(...args);
|
|
18
|
+
|
|
19
|
+
let message;
|
|
20
|
+
|
|
21
|
+
if (this.parse) {
|
|
22
|
+
message = this.parse(...args);
|
|
23
|
+
} else if (this.constructor.parse) {
|
|
24
|
+
message = this.constructor.parse(...args);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!message) {
|
|
28
|
+
message = this.constructor.defaultMessage;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.name = this.constructor.name;
|
|
32
|
+
|
|
33
|
+
this.message = message;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Generates the value assigned to `this.message`. You'll probably want to
|
|
38
|
+
* override this in your custom Exception
|
|
39
|
+
* @param {mixed} args
|
|
40
|
+
* @returns {string}
|
|
41
|
+
*/
|
|
42
|
+
static parse(...args) {
|
|
43
|
+
return args[0];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export default true;
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export default true;
|
package/src/in-browser/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Constants that, through the magic of bundling should indicate if we're
|
|
7
|
-
* running in a nodejs or a browser environment
|
|
8
|
-
* @name inBrowser
|
|
9
|
-
* @type {boolean}
|
|
10
|
-
*/
|
|
11
|
-
export {default} from './node';
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Constants that, through the magic of bundling should indicate if we're
|
|
7
|
+
* running in a nodejs or a browser environment
|
|
8
|
+
* @name inBrowser
|
|
9
|
+
* @type {boolean}
|
|
10
|
+
*/
|
|
11
|
+
export {default} from './node';
|
package/src/in-browser/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export default false;
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export default false;
|
package/src/index.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export {default as base64} from './base64';
|
|
6
|
-
export {default as isBuffer} from './isBuffer';
|
|
7
|
-
export {default as cappedDebounce} from './capped-debounce';
|
|
8
|
-
export {default as checkRequired} from './check-required';
|
|
9
|
-
export {default as Defer} from './defer';
|
|
10
|
-
export {default as makeStateDataType} from './make-state-datatype';
|
|
11
|
-
export {default as make} from './template-container';
|
|
12
|
-
export {default as oneFlight} from './one-flight';
|
|
13
|
-
export {default as patterns} from './patterns';
|
|
14
|
-
|
|
15
|
-
export {proxyEvents, transferEvents} from './events';
|
|
16
|
-
export {createEventEnvelope, ensureMyIdIsAvailable} from './event-envelope';
|
|
17
|
-
export {default as resolveWith} from './resolve-with';
|
|
18
|
-
export {default as retry} from './retry';
|
|
19
|
-
export {default as tap} from './tap';
|
|
20
|
-
export {default as whileInFlight} from './while-in-flight';
|
|
21
|
-
export {default as Exception} from './exception';
|
|
22
|
-
export {default as deprecated} from './deprecated';
|
|
23
|
-
export {default as inBrowser} from './in-browser';
|
|
24
|
-
export {
|
|
25
|
-
deviceType,
|
|
26
|
-
hydraTypes,
|
|
27
|
-
SDK_EVENT,
|
|
28
|
-
INTERNAL_US_CLUSTER_NAME,
|
|
29
|
-
INTERNAL_US_INTEGRATION_CLUSTER_NAME,
|
|
30
|
-
} from './constants';
|
|
31
|
-
|
|
32
|
-
export {default as BrowserDetection} from './browser-detection';
|
|
33
|
-
export {
|
|
34
|
-
buildHydraMembershipId,
|
|
35
|
-
buildHydraMessageId,
|
|
36
|
-
buildHydraOrgId,
|
|
37
|
-
buildHydraPersonId,
|
|
38
|
-
buildHydraRoomId,
|
|
39
|
-
getHydraRoomType,
|
|
40
|
-
getHydraClusterString,
|
|
41
|
-
getHydraFiles,
|
|
42
|
-
constructHydraId,
|
|
43
|
-
deconstructHydraId,
|
|
44
|
-
} from './uuid-utils';
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export {default as base64} from './base64';
|
|
6
|
+
export {default as isBuffer} from './isBuffer';
|
|
7
|
+
export {default as cappedDebounce} from './capped-debounce';
|
|
8
|
+
export {default as checkRequired} from './check-required';
|
|
9
|
+
export {default as Defer} from './defer';
|
|
10
|
+
export {default as makeStateDataType} from './make-state-datatype';
|
|
11
|
+
export {default as make} from './template-container';
|
|
12
|
+
export {default as oneFlight} from './one-flight';
|
|
13
|
+
export {default as patterns} from './patterns';
|
|
14
|
+
|
|
15
|
+
export {proxyEvents, transferEvents} from './events';
|
|
16
|
+
export {createEventEnvelope, ensureMyIdIsAvailable} from './event-envelope';
|
|
17
|
+
export {default as resolveWith} from './resolve-with';
|
|
18
|
+
export {default as retry} from './retry';
|
|
19
|
+
export {default as tap} from './tap';
|
|
20
|
+
export {default as whileInFlight} from './while-in-flight';
|
|
21
|
+
export {default as Exception} from './exception';
|
|
22
|
+
export {default as deprecated} from './deprecated';
|
|
23
|
+
export {default as inBrowser} from './in-browser';
|
|
24
|
+
export {
|
|
25
|
+
deviceType,
|
|
26
|
+
hydraTypes,
|
|
27
|
+
SDK_EVENT,
|
|
28
|
+
INTERNAL_US_CLUSTER_NAME,
|
|
29
|
+
INTERNAL_US_INTEGRATION_CLUSTER_NAME,
|
|
30
|
+
} from './constants';
|
|
31
|
+
|
|
32
|
+
export {default as BrowserDetection} from './browser-detection';
|
|
33
|
+
export {
|
|
34
|
+
buildHydraMembershipId,
|
|
35
|
+
buildHydraMessageId,
|
|
36
|
+
buildHydraOrgId,
|
|
37
|
+
buildHydraPersonId,
|
|
38
|
+
buildHydraRoomId,
|
|
39
|
+
getHydraRoomType,
|
|
40
|
+
getHydraClusterString,
|
|
41
|
+
getHydraFiles,
|
|
42
|
+
constructHydraId,
|
|
43
|
+
deconstructHydraId,
|
|
44
|
+
} from './uuid-utils';
|
package/src/isBuffer.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* Grabbed from https://github.com/feross/is-buffer/blob/master/index.js => es6 + prettier
|
|
4
|
-
*
|
|
5
|
-
* @param {buffer} buffer
|
|
6
|
-
* @returns {boolean}
|
|
7
|
-
*/
|
|
8
|
-
export default (buffer) =>
|
|
9
|
-
buffer != null &&
|
|
10
|
-
buffer.constructor != null &&
|
|
11
|
-
typeof buffer.constructor.isBuffer === 'function' &&
|
|
12
|
-
buffer.constructor.isBuffer(buffer);
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Grabbed from https://github.com/feross/is-buffer/blob/master/index.js => es6 + prettier
|
|
4
|
+
*
|
|
5
|
+
* @param {buffer} buffer
|
|
6
|
+
* @returns {boolean}
|
|
7
|
+
*/
|
|
8
|
+
export default (buffer) =>
|
|
9
|
+
buffer != null &&
|
|
10
|
+
buffer.constructor != null &&
|
|
11
|
+
typeof buffer.constructor.isBuffer === 'function' &&
|
|
12
|
+
buffer.constructor.isBuffer(buffer);
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// Reminder: any class using this function must have something like the
|
|
6
|
-
// following in its initialize method:
|
|
7
|
-
//
|
|
8
|
-
// // HACK to deal with the fact that AmpersandState#dataTypes#set is a pure
|
|
9
|
-
// // function.
|
|
10
|
-
// this._dataTypes = cloneDeep(this._dataTypes);
|
|
11
|
-
// Object.keys(this._dataTypes).forEach((key) => {
|
|
12
|
-
// if (this._dataTypes[key].set) {
|
|
13
|
-
// this._dataTypes[key].set = this._dataTypes[key].set.bind(this);
|
|
14
|
-
// }
|
|
15
|
-
// });
|
|
16
|
-
// // END HACK
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Creates an ampersand state object that wires its event handlers like a an
|
|
20
|
-
* ampersand child
|
|
21
|
-
* @param {Function} Constructor
|
|
22
|
-
* @param {string} name
|
|
23
|
-
* @returns {Object}
|
|
24
|
-
*/
|
|
25
|
-
export default function makeStateDataType(Constructor, name) {
|
|
26
|
-
if (!Constructor || !name) {
|
|
27
|
-
throw new Error('missing parameter for makeStateDataType');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
dataType: {
|
|
32
|
-
set: function set(newVal) {
|
|
33
|
-
// newVal.parent = this;
|
|
34
|
-
if (newVal instanceof Constructor) {
|
|
35
|
-
newVal.parent = this;
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
val: newVal,
|
|
39
|
-
type: name,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// We only want to construct the new instance if we have some set of
|
|
44
|
-
// attributes (even an empty object) to base it on. This is to deal with
|
|
45
|
-
// the unexpected side effect that AmpState#unset will create a new
|
|
46
|
-
// instance.
|
|
47
|
-
return {
|
|
48
|
-
val: newVal ? new Constructor(newVal, {parent: this}) : undefined,
|
|
49
|
-
type: name,
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
compare: function compare(currentValue, newVal) {
|
|
53
|
-
return currentValue === newVal;
|
|
54
|
-
},
|
|
55
|
-
onChange: function onChange(newVal, previousVal, attributeName) {
|
|
56
|
-
// Copied from ampersand-state.js
|
|
57
|
-
// if this has changed we want to also handle
|
|
58
|
-
// event propagation
|
|
59
|
-
if (previousVal) {
|
|
60
|
-
this.stopListening(
|
|
61
|
-
previousVal,
|
|
62
|
-
'all',
|
|
63
|
-
this._getCachedEventBubblingHandler(attributeName)
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (newVal) {
|
|
68
|
-
this.listenTo(newVal, 'all', this._getCachedEventBubblingHandler(attributeName));
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
prop: {
|
|
73
|
-
/**
|
|
74
|
-
* This is a really unfortunate hack to deal with ampersand`s decision to
|
|
75
|
-
* make the dateType#set function pure. The only function called with the
|
|
76
|
-
* scope of the parent at set time seems to be test
|
|
77
|
-
* @param {AmpersandState} newVal
|
|
78
|
-
* @returns {boolean}
|
|
79
|
-
*/
|
|
80
|
-
test: function test(newVal) {
|
|
81
|
-
if (!newVal) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
newVal.parent = this;
|
|
85
|
-
|
|
86
|
-
return false;
|
|
87
|
-
},
|
|
88
|
-
type: name,
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Reminder: any class using this function must have something like the
|
|
6
|
+
// following in its initialize method:
|
|
7
|
+
//
|
|
8
|
+
// // HACK to deal with the fact that AmpersandState#dataTypes#set is a pure
|
|
9
|
+
// // function.
|
|
10
|
+
// this._dataTypes = cloneDeep(this._dataTypes);
|
|
11
|
+
// Object.keys(this._dataTypes).forEach((key) => {
|
|
12
|
+
// if (this._dataTypes[key].set) {
|
|
13
|
+
// this._dataTypes[key].set = this._dataTypes[key].set.bind(this);
|
|
14
|
+
// }
|
|
15
|
+
// });
|
|
16
|
+
// // END HACK
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates an ampersand state object that wires its event handlers like a an
|
|
20
|
+
* ampersand child
|
|
21
|
+
* @param {Function} Constructor
|
|
22
|
+
* @param {string} name
|
|
23
|
+
* @returns {Object}
|
|
24
|
+
*/
|
|
25
|
+
export default function makeStateDataType(Constructor, name) {
|
|
26
|
+
if (!Constructor || !name) {
|
|
27
|
+
throw new Error('missing parameter for makeStateDataType');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
dataType: {
|
|
32
|
+
set: function set(newVal) {
|
|
33
|
+
// newVal.parent = this;
|
|
34
|
+
if (newVal instanceof Constructor) {
|
|
35
|
+
newVal.parent = this;
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
val: newVal,
|
|
39
|
+
type: name,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// We only want to construct the new instance if we have some set of
|
|
44
|
+
// attributes (even an empty object) to base it on. This is to deal with
|
|
45
|
+
// the unexpected side effect that AmpState#unset will create a new
|
|
46
|
+
// instance.
|
|
47
|
+
return {
|
|
48
|
+
val: newVal ? new Constructor(newVal, {parent: this}) : undefined,
|
|
49
|
+
type: name,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
compare: function compare(currentValue, newVal) {
|
|
53
|
+
return currentValue === newVal;
|
|
54
|
+
},
|
|
55
|
+
onChange: function onChange(newVal, previousVal, attributeName) {
|
|
56
|
+
// Copied from ampersand-state.js
|
|
57
|
+
// if this has changed we want to also handle
|
|
58
|
+
// event propagation
|
|
59
|
+
if (previousVal) {
|
|
60
|
+
this.stopListening(
|
|
61
|
+
previousVal,
|
|
62
|
+
'all',
|
|
63
|
+
this._getCachedEventBubblingHandler(attributeName)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (newVal) {
|
|
68
|
+
this.listenTo(newVal, 'all', this._getCachedEventBubblingHandler(attributeName));
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
prop: {
|
|
73
|
+
/**
|
|
74
|
+
* This is a really unfortunate hack to deal with ampersand`s decision to
|
|
75
|
+
* make the dateType#set function pure. The only function called with the
|
|
76
|
+
* scope of the parent at set time seems to be test
|
|
77
|
+
* @param {AmpersandState} newVal
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
*/
|
|
80
|
+
test: function test(newVal) {
|
|
81
|
+
if (!newVal) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
newVal.parent = this;
|
|
85
|
+
|
|
86
|
+
return false;
|
|
87
|
+
},
|
|
88
|
+
type: name,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|