@webex/common 3.0.0-beta.2 → 3.0.0-beta.21
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/dist/base64.js +4 -18
- package/dist/base64.js.map +1 -1
- package/dist/browser-detection.js +0 -21
- package/dist/browser-detection.js.map +1 -1
- package/dist/capped-debounce.js +6 -16
- package/dist/capped-debounce.js.map +1 -1
- package/dist/check-required.js +0 -3
- package/dist/check-required.js.map +1 -1
- package/dist/constants.js +0 -2
- package/dist/constants.js.map +1 -1
- package/dist/defer.js +0 -7
- package/dist/defer.js.map +1 -1
- package/dist/deprecated.js +0 -5
- package/dist/deprecated.js.map +1 -1
- package/dist/event-envelope.js +16 -31
- package/dist/event-envelope.js.map +1 -1
- package/dist/events.js +3 -14
- package/dist/events.js.map +1 -1
- package/dist/exception.js +1 -28
- package/dist/exception.js.map +1 -1
- package/dist/in-browser/browser.js +0 -3
- package/dist/in-browser/browser.js.map +1 -1
- package/dist/in-browser/index.js +0 -4
- package/dist/in-browser/index.js.map +1 -1
- package/dist/in-browser/node.js +0 -3
- package/dist/in-browser/node.js.map +1 -1
- package/dist/index.js +1 -60
- package/dist/index.js.map +1 -1
- package/dist/isBuffer.js +0 -4
- package/dist/isBuffer.js.map +1 -1
- package/dist/make-state-datatype.js +4 -9
- package/dist/make-state-datatype.js.map +1 -1
- package/dist/one-flight.js +8 -30
- package/dist/one-flight.js.map +1 -1
- package/dist/patterns.js +0 -8
- package/dist/patterns.js.map +1 -1
- package/dist/resolve-with.js +0 -5
- package/dist/resolve-with.js.map +1 -1
- package/dist/retry.js +13 -39
- package/dist/retry.js.map +1 -1
- package/dist/tap.js +0 -5
- package/dist/tap.js.map +1 -1
- package/dist/template-container.js +10 -54
- package/dist/template-container.js.map +1 -1
- package/dist/uuid-utils.js +12 -37
- package/dist/uuid-utils.js.map +1 -1
- package/dist/while-in-flight.js +0 -10
- package/dist/while-in-flight.js.map +1 -1
- package/package.json +3 -3
- package/src/base64.js +1 -1
- package/src/browser-detection.js +7 -6
- package/src/capped-debounce.js +2 -1
- package/src/constants.js +14 -14
- package/src/deprecated.js +3 -1
- package/src/event-envelope.js +25 -21
- package/src/events.js +1 -4
- package/src/exception.js +1 -2
- package/src/index.js +5 -7
- package/src/make-state-datatype.js +10 -6
- package/src/one-flight.js +1 -5
- package/src/patterns.js +5 -3
- package/src/retry.js +5 -6
- package/src/tap.js +6 -5
- package/src/template-container.js +3 -1
- package/src/uuid-utils.js +16 -16
- package/src/while-in-flight.js +12 -8
- package/test/unit/spec/capped-debounce.js +4 -1
- package/test/unit/spec/exception.js +1 -3
- package/test/unit/spec/one-flight.js +38 -55
- package/test/unit/spec/template-container.js +0 -1
- package/test/unit/spec/while-in-flight.js +8 -10
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.default = make;
|
|
12
|
-
|
|
13
9
|
var _construct2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/construct"));
|
|
14
|
-
|
|
15
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
16
|
-
|
|
17
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
18
|
-
|
|
19
12
|
var _weakMap = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/weak-map"));
|
|
20
|
-
|
|
21
13
|
var _util = _interopRequireDefault(require("util"));
|
|
22
|
-
|
|
23
14
|
/*!
|
|
24
15
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
25
16
|
*/
|
|
@@ -34,7 +25,6 @@ function make() {
|
|
|
34
25
|
for (var _len = arguments.length, containers = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
35
26
|
containers[_key] = arguments[_key];
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
var TopContainer = containers.shift();
|
|
39
29
|
var data = new _weakMap.default();
|
|
40
30
|
var sizes = new _weakMap.default();
|
|
@@ -42,51 +32,48 @@ function make() {
|
|
|
42
32
|
var name = "(".concat([TopContainer.name].concat(containers.map(function (container) {
|
|
43
33
|
return container.name;
|
|
44
34
|
})).join(', '), ")");
|
|
35
|
+
|
|
45
36
|
/**
|
|
46
37
|
* Container that wraps an arbitrary set of tupples to their values
|
|
47
38
|
*/
|
|
48
|
-
|
|
49
39
|
var Container = /*#__PURE__*/function () {
|
|
50
40
|
/**
|
|
51
41
|
* @constructs Container
|
|
52
42
|
*/
|
|
53
43
|
function Container() {
|
|
54
44
|
(0, _classCallCheck2.default)(this, Container);
|
|
55
|
-
|
|
56
45
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
57
46
|
args[_key2] = arguments[_key2];
|
|
58
47
|
}
|
|
59
|
-
|
|
60
48
|
data.set(this, (0, _construct2.default)(TopContainer, args));
|
|
61
49
|
sizes.set(this, 0);
|
|
62
50
|
}
|
|
51
|
+
|
|
63
52
|
/**
|
|
64
53
|
* getter for .size
|
|
65
54
|
* @returns {number}
|
|
66
55
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
56
|
(0, _createClass2.default)(Container, [{
|
|
70
57
|
key: "size",
|
|
71
58
|
get: function get() {
|
|
72
59
|
return sizes.get(this);
|
|
73
60
|
}
|
|
61
|
+
|
|
74
62
|
/**
|
|
75
63
|
* Identical to Container#set() but leads slightly more intuitive code when
|
|
76
64
|
* the container is based on a Set rather than a Map.
|
|
77
65
|
* @returns {Container}
|
|
78
66
|
*/
|
|
79
|
-
|
|
80
67
|
}, {
|
|
81
68
|
key: "add",
|
|
82
69
|
value: function add() {
|
|
83
70
|
return this.set.apply(this, arguments);
|
|
84
71
|
}
|
|
72
|
+
|
|
85
73
|
/**
|
|
86
74
|
* Removes all items from the container
|
|
87
75
|
* @returns {undefined}
|
|
88
76
|
*/
|
|
89
|
-
|
|
90
77
|
}, {
|
|
91
78
|
key: "clear",
|
|
92
79
|
value: function clear() {
|
|
@@ -94,92 +81,78 @@ function make() {
|
|
|
94
81
|
sizes.set(this, 0);
|
|
95
82
|
return ret;
|
|
96
83
|
}
|
|
84
|
+
|
|
97
85
|
/**
|
|
98
86
|
* Removes the specified item to the container
|
|
99
87
|
* @param {mixed} key
|
|
100
88
|
* @param {Array<mixed>} keys
|
|
101
89
|
* @returns {boolean}
|
|
102
90
|
*/
|
|
103
|
-
|
|
104
91
|
}, {
|
|
105
92
|
key: "delete",
|
|
106
93
|
value: function _delete(key) {
|
|
107
94
|
var mine = data.get(this);
|
|
108
|
-
|
|
109
95
|
for (var _len3 = arguments.length, keys = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
110
96
|
keys[_key3 - 1] = arguments[_key3];
|
|
111
97
|
}
|
|
112
|
-
|
|
113
98
|
if (!keys.length) {
|
|
114
99
|
return mine.delete(key);
|
|
115
100
|
}
|
|
116
|
-
|
|
117
101
|
var next = mine.get(key);
|
|
118
|
-
|
|
119
102
|
if (!next) {
|
|
120
103
|
return false;
|
|
121
104
|
}
|
|
122
|
-
|
|
123
105
|
var ret = next.delete.apply(next, keys);
|
|
124
|
-
|
|
125
106
|
if (ret) {
|
|
126
107
|
sizes.set(this, sizes.get(this) - 1);
|
|
127
108
|
}
|
|
128
|
-
|
|
129
109
|
if (next.size === 0) {
|
|
130
110
|
mine.delete(key);
|
|
131
111
|
}
|
|
132
|
-
|
|
133
112
|
return ret;
|
|
134
113
|
}
|
|
114
|
+
|
|
135
115
|
/**
|
|
136
116
|
* Retrieves the specified item from the container
|
|
137
117
|
* @param {mixed} key
|
|
138
118
|
* @param {Array<mixed>} keys
|
|
139
119
|
* @returns {mixed}
|
|
140
120
|
*/
|
|
141
|
-
|
|
142
121
|
}, {
|
|
143
122
|
key: "get",
|
|
144
123
|
value: function get(key) {
|
|
145
124
|
var mine = data.get(this);
|
|
146
|
-
|
|
147
125
|
if (!mine.get) {
|
|
148
126
|
return mine;
|
|
149
127
|
}
|
|
150
|
-
|
|
151
128
|
for (var _len4 = arguments.length, keys = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
152
129
|
keys[_key4 - 1] = arguments[_key4];
|
|
153
130
|
}
|
|
154
|
-
|
|
155
131
|
if (!keys.length) {
|
|
156
132
|
return mine.get(key);
|
|
157
133
|
}
|
|
158
|
-
|
|
159
134
|
var next = mine.get(key);
|
|
160
|
-
|
|
161
135
|
if (!next) {
|
|
162
136
|
return undefined;
|
|
163
137
|
}
|
|
164
|
-
|
|
165
138
|
if (!next.get) {
|
|
166
139
|
return next;
|
|
167
140
|
}
|
|
168
|
-
|
|
169
141
|
return next.get.apply(next, keys);
|
|
170
142
|
}
|
|
143
|
+
|
|
171
144
|
/**
|
|
172
145
|
* Indicates whether the container holds the specified item
|
|
173
146
|
* @param {mixed} key
|
|
174
147
|
* @param {Array<mixed>} keys
|
|
175
148
|
* @returns {Boolean}
|
|
176
149
|
*/
|
|
177
|
-
|
|
178
150
|
}, {
|
|
179
151
|
key: "has",
|
|
180
152
|
value: function has() {
|
|
181
153
|
return typeof this.get.apply(this, arguments) !== 'undefined';
|
|
182
154
|
}
|
|
155
|
+
|
|
183
156
|
/**
|
|
184
157
|
* Stores the specified item in the container
|
|
185
158
|
* @param {mixed} key
|
|
@@ -187,53 +160,42 @@ function make() {
|
|
|
187
160
|
* @param {mixed} value
|
|
188
161
|
* @returns {Container}
|
|
189
162
|
*/
|
|
190
|
-
|
|
191
163
|
}, {
|
|
192
164
|
key: "set",
|
|
193
165
|
value: function set() {
|
|
194
166
|
var overwrite = false;
|
|
195
|
-
|
|
196
167
|
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
197
168
|
args[_key5] = arguments[_key5];
|
|
198
169
|
}
|
|
199
|
-
|
|
200
170
|
if (this.has.apply(this, args)) {
|
|
201
171
|
overwrite = true;
|
|
202
172
|
}
|
|
203
|
-
|
|
204
173
|
var mine = data.get(this);
|
|
205
174
|
var key = args.shift();
|
|
206
|
-
|
|
207
175
|
if (!mine.get) {
|
|
208
176
|
insert.apply(void 0, [mine, key].concat(args));
|
|
209
177
|
return this;
|
|
210
178
|
}
|
|
211
|
-
|
|
212
179
|
var next = mine.get(key);
|
|
213
|
-
|
|
214
180
|
if (!next) {
|
|
215
181
|
if (!ChildContainer) {
|
|
216
182
|
insert.apply(void 0, [mine, key].concat(args));
|
|
217
183
|
return this;
|
|
218
184
|
}
|
|
219
|
-
|
|
220
185
|
next = new ChildContainer();
|
|
221
186
|
insert(mine, key, next);
|
|
222
187
|
}
|
|
223
|
-
|
|
224
188
|
insert.apply(void 0, [next].concat(args));
|
|
225
|
-
|
|
226
189
|
if (!overwrite) {
|
|
227
190
|
sizes.set(this, sizes.get(this) + 1);
|
|
228
191
|
}
|
|
229
|
-
|
|
230
192
|
return this;
|
|
231
193
|
}
|
|
194
|
+
|
|
232
195
|
/**
|
|
233
196
|
* @private
|
|
234
197
|
* @returns {string}
|
|
235
198
|
*/
|
|
236
|
-
|
|
237
199
|
}, {
|
|
238
200
|
key: "inspect",
|
|
239
201
|
value: function inspect() {
|
|
@@ -244,9 +206,9 @@ function make() {
|
|
|
244
206
|
}]);
|
|
245
207
|
return Container;
|
|
246
208
|
}();
|
|
247
|
-
|
|
248
209
|
return Container;
|
|
249
210
|
}
|
|
211
|
+
|
|
250
212
|
/**
|
|
251
213
|
* Inserts into an arbitrary container
|
|
252
214
|
* @param {Map|WeakMap|Set|WeakSet} container
|
|
@@ -254,28 +216,22 @@ function make() {
|
|
|
254
216
|
* @private
|
|
255
217
|
* @returns {undefined}
|
|
256
218
|
*/
|
|
257
|
-
|
|
258
|
-
|
|
259
219
|
function insert(container) {
|
|
260
220
|
for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
|
|
261
221
|
args[_key6 - 1] = arguments[_key6];
|
|
262
222
|
}
|
|
263
|
-
|
|
264
223
|
if (container.add) {
|
|
265
224
|
container.add.apply(container, args);
|
|
266
225
|
return;
|
|
267
226
|
}
|
|
268
|
-
|
|
269
227
|
if (container.set) {
|
|
270
228
|
container.set.apply(container, args);
|
|
271
229
|
return;
|
|
272
230
|
}
|
|
273
|
-
|
|
274
231
|
if (container.push) {
|
|
275
232
|
container.push.apply(container, args);
|
|
276
233
|
return;
|
|
277
234
|
}
|
|
278
|
-
|
|
279
235
|
throw new TypeError('Could not determine how to insert into the specified container');
|
|
280
236
|
}
|
|
281
237
|
//# sourceMappingURL=template-container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["make","containers","TopContainer","shift","data","sizes","ChildContainer","length","name","concat","map","container","join","Container","args","set","get","ret","clear","key","mine","keys","delete","next","size","undefined","overwrite","has","insert","util","inspect","depth","add","push","TypeError"],"sources":["template-container.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport util from 'util';\n\n/**\n * Factory which produces a multi-keyed container based on the provided set of\n * constructors\n * @param {mixed} containers\n * @returns {Container}\n */\nfunction make(...containers) {\n const TopContainer = containers.shift();\n\n const data = new WeakMap();\n const sizes = new WeakMap();\n\n const ChildContainer = containers.length > 1 ? make(...containers) : containers[0];\n\n const name = `(${[TopContainer.name].concat(containers.map((container) => container.name)).join(', ')})`;\n\n /**\n * Container that wraps an arbitrary set of tupples to their values\n */\n class Container {\n /**\n * @constructs Container\n */\n constructor(...args) {\n data.set(this, new TopContainer(...args));\n sizes.set(this, 0);\n }\n\n /**\n * getter for .size\n * @returns {number}\n */\n get size() {\n return sizes.get(this);\n }\n\n /**\n * Identical to Container#set() but leads slightly more intuitive code when\n * the container is based on a Set rather than a Map.\n * @returns {Container}\n */\n add(...args) {\n return this.set(...args);\n }\n\n /**\n * Removes all items from the container\n * @returns {undefined}\n */\n clear() {\n const ret = data.get(this).clear();\n\n sizes.set(this, 0);\n\n return ret;\n }\n\n /**\n * Removes the specified item to the container\n * @param {mixed} key\n * @param {Array<mixed>} keys\n * @returns {boolean}\n */\n delete(key, ...keys) {\n const mine = data.get(this);\n\n if (!keys.length) {\n return mine.delete(key);\n }\n\n const next = mine.get(key);\n\n if (!next) {\n return false;\n }\n\n const ret = next.delete(...keys);\n\n if (ret) {\n sizes.set(this, sizes.get(this) - 1);\n }\n\n if (next.size === 0) {\n mine.delete(key);\n }\n\n return ret;\n }\n\n /**\n * Retrieves the specified item from the container\n * @param {mixed} key\n * @param {Array<mixed>} keys\n * @returns {mixed}\n */\n get(key, ...keys) {\n const mine = data.get(this);\n\n if (!mine.get) {\n return mine;\n }\n\n if (!keys.length) {\n return mine.get(key);\n }\n\n const next = mine.get(key);\n\n if (!next) {\n return undefined;\n }\n\n if (!next.get) {\n return next;\n }\n\n return next.get(...keys);\n }\n\n /**\n * Indicates whether the container holds the specified item\n * @param {mixed} key\n * @param {Array<mixed>} keys\n * @returns {Boolean}\n */\n has(...args) {\n return typeof this.get(...args) !== 'undefined';\n }\n\n /**\n * Stores the specified item in the container\n * @param {mixed} key\n * @param {Array<mixed>} args\n * @param {mixed} value\n * @returns {Container}\n */\n set(...args) {\n let overwrite = false;\n\n if (this.has(...args)) {\n overwrite = true;\n }\n const mine = data.get(this);\n\n const key = args.shift();\n\n if (!mine.get) {\n insert(mine, key, ...args);\n\n return this;\n }\n\n let next = mine.get(key);\n\n if (!next) {\n if (!ChildContainer) {\n insert(mine, key, ...args);\n\n return this;\n }\n next = new ChildContainer();\n insert(mine, key, next);\n }\n insert(next, ...args);\n\n if (!overwrite) {\n sizes.set(this, sizes.get(this) + 1);\n }\n\n return this;\n }\n\n /**\n * @private\n * @returns {string}\n */\n inspect() {\n return `Container${name} {\n ${util.inspect(data.get(this), {depth: null})}\n}`;\n }\n }\n\n return Container;\n}\n\n/**\n * Inserts into an arbitrary container\n * @param {Map|WeakMap|Set|WeakSet} container\n * @param {Array<mixed>} args\n * @private\n * @returns {undefined}\n */\nfunction insert(container, ...args) {\n if (container.add) {\n container.add(...args);\n\n return;\n }\n\n if (container.set) {\n container.set(...args);\n\n return;\n }\n\n if (container.push) {\n container.push(...args);\n\n return;\n }\n throw new TypeError('Could not determine how to insert into the specified container');\n}\nexport {make as default};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["make","containers","TopContainer","shift","data","sizes","ChildContainer","length","name","concat","map","container","join","Container","args","set","get","ret","clear","key","mine","keys","delete","next","size","undefined","overwrite","has","insert","util","inspect","depth","add","push","TypeError"],"sources":["template-container.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport util from 'util';\n\n/**\n * Factory which produces a multi-keyed container based on the provided set of\n * constructors\n * @param {mixed} containers\n * @returns {Container}\n */\nfunction make(...containers) {\n const TopContainer = containers.shift();\n\n const data = new WeakMap();\n const sizes = new WeakMap();\n\n const ChildContainer = containers.length > 1 ? make(...containers) : containers[0];\n\n const name = `(${[TopContainer.name]\n .concat(containers.map((container) => container.name))\n .join(', ')})`;\n\n /**\n * Container that wraps an arbitrary set of tupples to their values\n */\n class Container {\n /**\n * @constructs Container\n */\n constructor(...args) {\n data.set(this, new TopContainer(...args));\n sizes.set(this, 0);\n }\n\n /**\n * getter for .size\n * @returns {number}\n */\n get size() {\n return sizes.get(this);\n }\n\n /**\n * Identical to Container#set() but leads slightly more intuitive code when\n * the container is based on a Set rather than a Map.\n * @returns {Container}\n */\n add(...args) {\n return this.set(...args);\n }\n\n /**\n * Removes all items from the container\n * @returns {undefined}\n */\n clear() {\n const ret = data.get(this).clear();\n\n sizes.set(this, 0);\n\n return ret;\n }\n\n /**\n * Removes the specified item to the container\n * @param {mixed} key\n * @param {Array<mixed>} keys\n * @returns {boolean}\n */\n delete(key, ...keys) {\n const mine = data.get(this);\n\n if (!keys.length) {\n return mine.delete(key);\n }\n\n const next = mine.get(key);\n\n if (!next) {\n return false;\n }\n\n const ret = next.delete(...keys);\n\n if (ret) {\n sizes.set(this, sizes.get(this) - 1);\n }\n\n if (next.size === 0) {\n mine.delete(key);\n }\n\n return ret;\n }\n\n /**\n * Retrieves the specified item from the container\n * @param {mixed} key\n * @param {Array<mixed>} keys\n * @returns {mixed}\n */\n get(key, ...keys) {\n const mine = data.get(this);\n\n if (!mine.get) {\n return mine;\n }\n\n if (!keys.length) {\n return mine.get(key);\n }\n\n const next = mine.get(key);\n\n if (!next) {\n return undefined;\n }\n\n if (!next.get) {\n return next;\n }\n\n return next.get(...keys);\n }\n\n /**\n * Indicates whether the container holds the specified item\n * @param {mixed} key\n * @param {Array<mixed>} keys\n * @returns {Boolean}\n */\n has(...args) {\n return typeof this.get(...args) !== 'undefined';\n }\n\n /**\n * Stores the specified item in the container\n * @param {mixed} key\n * @param {Array<mixed>} args\n * @param {mixed} value\n * @returns {Container}\n */\n set(...args) {\n let overwrite = false;\n\n if (this.has(...args)) {\n overwrite = true;\n }\n const mine = data.get(this);\n\n const key = args.shift();\n\n if (!mine.get) {\n insert(mine, key, ...args);\n\n return this;\n }\n\n let next = mine.get(key);\n\n if (!next) {\n if (!ChildContainer) {\n insert(mine, key, ...args);\n\n return this;\n }\n next = new ChildContainer();\n insert(mine, key, next);\n }\n insert(next, ...args);\n\n if (!overwrite) {\n sizes.set(this, sizes.get(this) + 1);\n }\n\n return this;\n }\n\n /**\n * @private\n * @returns {string}\n */\n inspect() {\n return `Container${name} {\n ${util.inspect(data.get(this), {depth: null})}\n}`;\n }\n }\n\n return Container;\n}\n\n/**\n * Inserts into an arbitrary container\n * @param {Map|WeakMap|Set|WeakSet} container\n * @param {Array<mixed>} args\n * @private\n * @returns {undefined}\n */\nfunction insert(container, ...args) {\n if (container.add) {\n container.add(...args);\n\n return;\n }\n\n if (container.set) {\n container.set(...args);\n\n return;\n }\n\n if (container.push) {\n container.push(...args);\n\n return;\n }\n throw new TypeError('Could not determine how to insert into the specified container');\n}\nexport {make as default};\n"],"mappings":";;;;;;;;;;;;AAIA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,IAAI,GAAgB;EAAA,kCAAZC,UAAU;IAAVA,UAAU;EAAA;EACzB,IAAMC,YAAY,GAAGD,UAAU,CAACE,KAAK,EAAE;EAEvC,IAAMC,IAAI,GAAG,sBAAa;EAC1B,IAAMC,KAAK,GAAG,sBAAa;EAE3B,IAAMC,cAAc,GAAGL,UAAU,CAACM,MAAM,GAAG,CAAC,GAAGP,IAAI,eAAIC,UAAU,CAAC,GAAGA,UAAU,CAAC,CAAC,CAAC;EAElF,IAAMO,IAAI,cAAO,CAACN,YAAY,CAACM,IAAI,CAAC,CACjCC,MAAM,CAACR,UAAU,CAACS,GAAG,CAAC,UAACC,SAAS;IAAA,OAAKA,SAAS,CAACH,IAAI;EAAA,EAAC,CAAC,CACrDI,IAAI,CAAC,IAAI,CAAC,MAAG;;EAEhB;AACF;AACA;EAFE,IAGMC,SAAS;IACb;AACJ;AACA;IACI,qBAAqB;MAAA;MAAA,mCAANC,IAAI;QAAJA,IAAI;MAAA;MACjBV,IAAI,CAACW,GAAG,CAAC,IAAI,2BAAMb,YAAY,EAAIY,IAAI,EAAE;MACzCT,KAAK,CAACU,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACpB;;IAEA;AACJ;AACA;AACA;IAHI;MAAA;MAAA,KAIA,eAAW;QACT,OAAOV,KAAK,CAACW,GAAG,CAAC,IAAI,CAAC;MACxB;;MAEA;AACJ;AACA;AACA;AACA;IAJI;MAAA;MAAA,OAKA,eAAa;QACX,OAAO,IAAI,CAACD,GAAG,OAAR,IAAI,YAAa;MAC1B;;MAEA;AACJ;AACA;AACA;I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,IAAI,EAAC;QAErB,IAAI,CAACY,SAAS,EAAE;UACdrB,KAAK,CAACU,GAAG,CAAC,IAAI,EAAEV,KAAK,CAACW,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtC;QAEA,OAAO,IAAI;MACb;;MAEA;AACJ;AACA;AACA;IAHI;MAAA;MAAA,OAIA,mBAAU;QACR,0BAAmBR,IAAI,mBACzBqB,aAAI,CAACC,OAAO,CAAC1B,IAAI,CAACY,GAAG,CAAC,IAAI,CAAC,EAAE;UAACe,KAAK,EAAE;QAAI,CAAC,CAAC;MAE3C;IAAC;IAAA;EAAA;EAGH,OAAOlB,SAAS;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASe,MAAM,CAACjB,SAAS,EAAW;EAAA,mCAANG,IAAI;IAAJA,IAAI;EAAA;EAChC,IAAIH,SAAS,CAACqB,GAAG,EAAE;IACjBrB,SAAS,CAACqB,GAAG,OAAbrB,SAAS,EAAQG,IAAI,CAAC;IAEtB;EACF;EAEA,IAAIH,SAAS,CAACI,GAAG,EAAE;IACjBJ,SAAS,CAACI,GAAG,OAAbJ,SAAS,EAAQG,IAAI,CAAC;IAEtB;EACF;EAEA,IAAIH,SAAS,CAACsB,IAAI,EAAE;IAClBtB,SAAS,CAACsB,IAAI,OAAdtB,SAAS,EAASG,IAAI,CAAC;IAEvB;EACF;EACA,MAAM,IAAIoB,SAAS,CAAC,gEAAgE,CAAC;AACvF"}
|
package/dist/uuid-utils.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
4
|
_Object$defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
|
|
9
7
|
exports.buildHydraMembershipId = buildHydraMembershipId;
|
|
10
8
|
exports.buildHydraMessageId = buildHydraMessageId;
|
|
11
9
|
exports.buildHydraOrgId = buildHydraOrgId;
|
|
@@ -16,16 +14,13 @@ exports.deconstructHydraId = deconstructHydraId;
|
|
|
16
14
|
exports.getHydraClusterString = getHydraClusterString;
|
|
17
15
|
exports.getHydraFiles = getHydraFiles;
|
|
18
16
|
exports.getHydraRoomType = getHydraRoomType;
|
|
19
|
-
|
|
20
17
|
var _base = require("./base64");
|
|
21
|
-
|
|
22
18
|
var _constants = require("./constants");
|
|
23
|
-
|
|
24
19
|
var hydraBaseUrl = 'https://api.ciscospark.com/v1';
|
|
25
|
-
|
|
26
20
|
var isRequired = function isRequired() {
|
|
27
21
|
throw Error('parameter is required');
|
|
28
22
|
};
|
|
23
|
+
|
|
29
24
|
/**
|
|
30
25
|
* Constructs a Hydra ID for a given UUID and type.
|
|
31
26
|
*
|
|
@@ -35,24 +30,20 @@ var isRequired = function isRequired() {
|
|
|
35
30
|
* @param {string} cluster containing the "TYPE" object
|
|
36
31
|
* @returns {string}
|
|
37
32
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
33
|
function constructHydraId() {
|
|
41
34
|
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : isRequired();
|
|
42
35
|
var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isRequired();
|
|
43
36
|
var cluster = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'us';
|
|
44
|
-
|
|
45
37
|
if (!type.toUpperCase) {
|
|
46
38
|
throw Error('"type" must be a string');
|
|
47
39
|
}
|
|
48
|
-
|
|
49
40
|
if (type === _constants.hydraTypes.PEOPLE || type === _constants.hydraTypes.ORGANIZATION) {
|
|
50
41
|
// Cluster is always "us" for people and orgs
|
|
51
42
|
return (0, _base.encode)("ciscospark://us/".concat(type.toUpperCase(), "/").concat(id));
|
|
52
43
|
}
|
|
53
|
-
|
|
54
44
|
return (0, _base.encode)("ciscospark://".concat(cluster, "/").concat(type.toUpperCase(), "/").concat(id));
|
|
55
45
|
}
|
|
46
|
+
|
|
56
47
|
/**
|
|
57
48
|
* @typedef {Object} DeconstructedHydraId
|
|
58
49
|
* @property {UUID} id identifying the object
|
|
@@ -67,8 +58,6 @@ function constructHydraId() {
|
|
|
67
58
|
* @param {String} id Hydra style id
|
|
68
59
|
* @returns {DeconstructedHydraId} deconstructed id
|
|
69
60
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
61
|
function deconstructHydraId(id) {
|
|
73
62
|
var payload = (0, _base.decode)(id).split('/');
|
|
74
63
|
return {
|
|
@@ -77,6 +66,7 @@ function deconstructHydraId(id) {
|
|
|
77
66
|
cluster: payload.pop()
|
|
78
67
|
};
|
|
79
68
|
}
|
|
69
|
+
|
|
80
70
|
/**
|
|
81
71
|
* Constructs a Hydra ID for a message based on internal UUID
|
|
82
72
|
*
|
|
@@ -85,11 +75,10 @@ function deconstructHydraId(id) {
|
|
|
85
75
|
* @param {string} cluster containing the message
|
|
86
76
|
* @returns {string}
|
|
87
77
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
78
|
function buildHydraMessageId(uuid, cluster) {
|
|
91
79
|
return constructHydraId(_constants.hydraTypes.MESSAGE, uuid, cluster);
|
|
92
80
|
}
|
|
81
|
+
|
|
93
82
|
/**
|
|
94
83
|
* Constructs a Hydra ID for a person based on internal UUID
|
|
95
84
|
*
|
|
@@ -98,11 +87,10 @@ function buildHydraMessageId(uuid, cluster) {
|
|
|
98
87
|
* @param {string} cluster containing the person
|
|
99
88
|
* @returns {string}
|
|
100
89
|
*/
|
|
101
|
-
|
|
102
|
-
|
|
103
90
|
function buildHydraPersonId(uuid, cluster) {
|
|
104
91
|
return constructHydraId(_constants.hydraTypes.PEOPLE, uuid, cluster);
|
|
105
92
|
}
|
|
93
|
+
|
|
106
94
|
/**
|
|
107
95
|
* Constructs a Hydra ID for a room based on internal UUID
|
|
108
96
|
*
|
|
@@ -111,11 +99,10 @@ function buildHydraPersonId(uuid, cluster) {
|
|
|
111
99
|
* @param {string} cluster containing the room
|
|
112
100
|
* @returns {string}
|
|
113
101
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
102
|
function buildHydraRoomId(uuid, cluster) {
|
|
117
103
|
return constructHydraId(_constants.hydraTypes.ROOM, uuid, cluster);
|
|
118
104
|
}
|
|
105
|
+
|
|
119
106
|
/**
|
|
120
107
|
* Constructs a Hydra ID for an organization based on internal UUID
|
|
121
108
|
*
|
|
@@ -124,11 +111,10 @@ function buildHydraRoomId(uuid, cluster) {
|
|
|
124
111
|
* @param {string} cluster containing the organization
|
|
125
112
|
* @returns {string}
|
|
126
113
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
114
|
function buildHydraOrgId(uuid, cluster) {
|
|
130
115
|
return constructHydraId(_constants.hydraTypes.ORGANIZATION, uuid, cluster);
|
|
131
116
|
}
|
|
117
|
+
|
|
132
118
|
/**
|
|
133
119
|
* Constructs a Hydra ID for an membership based on an
|
|
134
120
|
* internal UUID for the person, and the space
|
|
@@ -139,11 +125,10 @@ function buildHydraOrgId(uuid, cluster) {
|
|
|
139
125
|
* @param {string} cluster containing the membership
|
|
140
126
|
* @returns {string}
|
|
141
127
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
128
|
function buildHydraMembershipId(personUUID, spaceUUID, cluster) {
|
|
145
129
|
return constructHydraId(_constants.hydraTypes.MEMBERSHIP, "".concat(personUUID, ":").concat(spaceUUID), cluster);
|
|
146
130
|
}
|
|
131
|
+
|
|
147
132
|
/**
|
|
148
133
|
* Returns a hydra cluster string based on a conversation url
|
|
149
134
|
* @private
|
|
@@ -152,24 +137,19 @@ function buildHydraMembershipId(personUUID, spaceUUID, cluster) {
|
|
|
152
137
|
* @param {String} conversationUrl url of space where activity took place
|
|
153
138
|
* @returns {String} string suitable for UUID -> public ID encoding
|
|
154
139
|
*/
|
|
155
|
-
|
|
156
|
-
|
|
157
140
|
function getHydraClusterString(webex, conversationUrl) {
|
|
158
141
|
var internalClusterString = webex.internal.services.getClusterId(conversationUrl);
|
|
159
|
-
|
|
160
142
|
if (internalClusterString.startsWith(_constants.INTERNAL_US_CLUSTER_NAME) || internalClusterString.startsWith(_constants.INTERNAL_US_INTEGRATION_CLUSTER_NAME)) {
|
|
161
143
|
// Original US cluster is simply 'us' for backwards compatibility
|
|
162
144
|
return 'us';
|
|
163
145
|
}
|
|
164
|
-
|
|
165
146
|
var clusterParts = internalClusterString.split(':');
|
|
166
|
-
|
|
167
147
|
if (clusterParts.length < 3) {
|
|
168
148
|
throw Error("Unable to determine cluster for convo: ".concat(conversationUrl));
|
|
169
149
|
}
|
|
170
|
-
|
|
171
150
|
return "".concat(clusterParts[0], ":").concat(clusterParts[1], ":").concat(clusterParts[2]);
|
|
172
151
|
}
|
|
152
|
+
|
|
173
153
|
/**
|
|
174
154
|
* Returns a Hydra roomType based on conversation tags
|
|
175
155
|
*
|
|
@@ -178,15 +158,13 @@ function getHydraClusterString(webex, conversationUrl) {
|
|
|
178
158
|
* @param {any} spaceUUID
|
|
179
159
|
* @returns {string}
|
|
180
160
|
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
161
|
function getHydraRoomType(tags) {
|
|
184
162
|
if (tags.includes(_constants.SDK_EVENT.INTERNAL.ACTIVITY_TAG.ONE_ON_ONE)) {
|
|
185
163
|
return _constants.SDK_EVENT.EXTERNAL.SPACE_TYPE.DIRECT;
|
|
186
164
|
}
|
|
187
|
-
|
|
188
165
|
return _constants.SDK_EVENT.EXTERNAL.SPACE_TYPE.GROUP;
|
|
189
166
|
}
|
|
167
|
+
|
|
190
168
|
/**
|
|
191
169
|
* Returns file URLs for the activity, adhering to Hydra details,
|
|
192
170
|
* e.g., https://api.ciscospark.com/v1/contents/Y2lzY29zcGF...
|
|
@@ -195,21 +173,18 @@ function getHydraRoomType(tags) {
|
|
|
195
173
|
* @param {string} cluster containing the files
|
|
196
174
|
* @returns {Array} file URLs
|
|
197
175
|
*/
|
|
198
|
-
|
|
199
|
-
|
|
200
176
|
function getHydraFiles(activity, cluster) {
|
|
201
177
|
var hydraFiles = [];
|
|
202
178
|
var files = activity.object.files;
|
|
203
|
-
|
|
204
179
|
if (files) {
|
|
205
|
-
var items = files.items;
|
|
180
|
+
var items = files.items;
|
|
206
181
|
|
|
182
|
+
// Note: Generated ID is dependent on file order.
|
|
207
183
|
for (var i = 0; i < items.length; i += 1) {
|
|
208
184
|
var contentId = constructHydraId(_constants.hydraTypes.CONTENT, "".concat(activity.id, "/").concat(i), cluster);
|
|
209
185
|
hydraFiles.push("".concat(hydraBaseUrl, "/contents/").concat(contentId));
|
|
210
186
|
}
|
|
211
187
|
}
|
|
212
|
-
|
|
213
188
|
return hydraFiles;
|
|
214
189
|
}
|
|
215
190
|
//# sourceMappingURL=uuid-utils.js.map
|
package/dist/uuid-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hydraBaseUrl","isRequired","Error","constructHydraId","type","id","cluster","toUpperCase","hydraTypes","PEOPLE","ORGANIZATION","encode","deconstructHydraId","payload","decode","split","pop","buildHydraMessageId","uuid","MESSAGE","buildHydraPersonId","buildHydraRoomId","ROOM","buildHydraOrgId","buildHydraMembershipId","personUUID","spaceUUID","MEMBERSHIP","getHydraClusterString","webex","conversationUrl","internalClusterString","internal","services","getClusterId","startsWith","INTERNAL_US_CLUSTER_NAME","INTERNAL_US_INTEGRATION_CLUSTER_NAME","clusterParts","length","getHydraRoomType","tags","includes","SDK_EVENT","INTERNAL","ACTIVITY_TAG","ONE_ON_ONE","EXTERNAL","SPACE_TYPE","DIRECT","GROUP","getHydraFiles","activity","hydraFiles","files","object","items","i","contentId","CONTENT","push"],"sources":["uuid-utils.js"],"sourcesContent":["import {encode, decode} from './base64';\nimport {SDK_EVENT
|
|
1
|
+
{"version":3,"names":["hydraBaseUrl","isRequired","Error","constructHydraId","type","id","cluster","toUpperCase","hydraTypes","PEOPLE","ORGANIZATION","encode","deconstructHydraId","payload","decode","split","pop","buildHydraMessageId","uuid","MESSAGE","buildHydraPersonId","buildHydraRoomId","ROOM","buildHydraOrgId","buildHydraMembershipId","personUUID","spaceUUID","MEMBERSHIP","getHydraClusterString","webex","conversationUrl","internalClusterString","internal","services","getClusterId","startsWith","INTERNAL_US_CLUSTER_NAME","INTERNAL_US_INTEGRATION_CLUSTER_NAME","clusterParts","length","getHydraRoomType","tags","includes","SDK_EVENT","INTERNAL","ACTIVITY_TAG","ONE_ON_ONE","EXTERNAL","SPACE_TYPE","DIRECT","GROUP","getHydraFiles","activity","hydraFiles","files","object","items","i","contentId","CONTENT","push"],"sources":["uuid-utils.js"],"sourcesContent":["import {encode, decode} from './base64';\nimport {\n SDK_EVENT,\n hydraTypes,\n INTERNAL_US_CLUSTER_NAME,\n INTERNAL_US_INTEGRATION_CLUSTER_NAME,\n} from './constants';\n\nconst hydraBaseUrl = 'https://api.ciscospark.com/v1';\n\nconst isRequired = () => {\n throw Error('parameter is required');\n};\n\n/**\n * Constructs a Hydra ID for a given UUID and type.\n *\n * @export\n * @param {string} type one of PEOPLE, TEAM, ROOM\n * @param {any} id identifying the \"TYPE\" object\n * @param {string} cluster containing the \"TYPE\" object\n * @returns {string}\n */\nexport function constructHydraId(type = isRequired(), id = isRequired(), cluster = 'us') {\n if (!type.toUpperCase) {\n throw Error('\"type\" must be a string');\n }\n\n if (type === hydraTypes.PEOPLE || type === hydraTypes.ORGANIZATION) {\n // Cluster is always \"us\" for people and orgs\n return encode(`ciscospark://us/${type.toUpperCase()}/${id}`);\n }\n\n return encode(`ciscospark://${cluster}/${type.toUpperCase()}/${id}`);\n}\n\n/**\n * @typedef {Object} DeconstructedHydraId\n * @property {UUID} id identifying the object\n * @property {String} type of the object\n * @property {String} cluster containing the object\n */\n\n/**\n * Deconstructs a Hydra ID.\n *\n * @export\n * @param {String} id Hydra style id\n * @returns {DeconstructedHydraId} deconstructed id\n */\nexport function deconstructHydraId(id) {\n const payload = decode(id).split('/');\n\n return {\n id: payload.pop(),\n type: payload.pop(),\n cluster: payload.pop(),\n };\n}\n\n/**\n * Constructs a Hydra ID for a message based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the message\n * @returns {string}\n */\nexport function buildHydraMessageId(uuid, cluster) {\n return constructHydraId(hydraTypes.MESSAGE, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for a person based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the person\n * @returns {string}\n */\nexport function buildHydraPersonId(uuid, cluster) {\n return constructHydraId(hydraTypes.PEOPLE, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for a room based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the room\n * @returns {string}\n */\nexport function buildHydraRoomId(uuid, cluster) {\n return constructHydraId(hydraTypes.ROOM, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for an organization based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the organization\n * @returns {string}\n */\nexport function buildHydraOrgId(uuid, cluster) {\n return constructHydraId(hydraTypes.ORGANIZATION, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for an membership based on an\n * internal UUID for the person, and the space\n *\n * @export\n * @param {any} personUUID\n * @param {any} spaceUUID\n * @param {string} cluster containing the membership\n * @returns {string}\n */\nexport function buildHydraMembershipId(personUUID, spaceUUID, cluster) {\n return constructHydraId(hydraTypes.MEMBERSHIP, `${personUUID}:${spaceUUID}`, cluster);\n}\n\n/**\n * Returns a hydra cluster string based on a conversation url\n * @private\n * @memberof Messages\n * @param {Object} webex sdk instance\n * @param {String} conversationUrl url of space where activity took place\n * @returns {String} string suitable for UUID -> public ID encoding\n */\nexport function getHydraClusterString(webex, conversationUrl) {\n const internalClusterString = webex.internal.services.getClusterId(conversationUrl);\n\n if (\n internalClusterString.startsWith(INTERNAL_US_CLUSTER_NAME) ||\n internalClusterString.startsWith(INTERNAL_US_INTEGRATION_CLUSTER_NAME)\n ) {\n // Original US cluster is simply 'us' for backwards compatibility\n return 'us';\n }\n const clusterParts = internalClusterString.split(':');\n\n if (clusterParts.length < 3) {\n throw Error(`Unable to determine cluster for convo: ${conversationUrl}`);\n }\n\n return `${clusterParts[0]}:${clusterParts[1]}:${clusterParts[2]}`;\n}\n\n/**\n * Returns a Hydra roomType based on conversation tags\n *\n * @export\n * @param {arra} tags\n * @param {any} spaceUUID\n * @returns {string}\n */\nexport function getHydraRoomType(tags) {\n if (tags.includes(SDK_EVENT.INTERNAL.ACTIVITY_TAG.ONE_ON_ONE)) {\n return SDK_EVENT.EXTERNAL.SPACE_TYPE.DIRECT;\n }\n\n return SDK_EVENT.EXTERNAL.SPACE_TYPE.GROUP;\n}\n\n/**\n * Returns file URLs for the activity, adhering to Hydra details,\n * e.g., https://api.ciscospark.com/v1/contents/Y2lzY29zcGF...\n * @see https://developer.webex.com/docs/api/v1/messages/get-message-details\n * @param {Object} activity from mercury\n * @param {string} cluster containing the files\n * @returns {Array} file URLs\n */\nexport function getHydraFiles(activity, cluster) {\n const hydraFiles = [];\n const {files} = activity.object;\n\n if (files) {\n const {items} = files;\n\n // Note: Generated ID is dependent on file order.\n for (let i = 0; i < items.length; i += 1) {\n const contentId = constructHydraId(hydraTypes.CONTENT, `${activity.id}/${i}`, cluster);\n\n hydraFiles.push(`${hydraBaseUrl}/contents/${contentId}`);\n }\n }\n\n return hydraFiles;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAOA,IAAMA,YAAY,GAAG,+BAA+B;AAEpD,IAAMC,UAAU,GAAG,SAAbA,UAAU,GAAS;EACvB,MAAMC,KAAK,CAAC,uBAAuB,CAAC;AACtC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgB,GAAyD;EAAA,IAAxDC,IAAI,uEAAGH,UAAU,EAAE;EAAA,IAAEI,EAAE,uEAAGJ,UAAU,EAAE;EAAA,IAAEK,OAAO,uEAAG,IAAI;EACrF,IAAI,CAACF,IAAI,CAACG,WAAW,EAAE;IACrB,MAAML,KAAK,CAAC,yBAAyB,CAAC;EACxC;EAEA,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AEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,aAAa,CAACC,QAAQ,EAAE9C,OAAO,EAAE;EAC/C,IAAM+C,UAAU,GAAG,EAAE;EACrB,IAAOC,KAAK,GAAIF,QAAQ,CAACG,MAAM,CAAxBD,KAAK;EAEZ,IAAIA,KAAK,EAAE;IACT,IAAOE,KAAK,GAAIF,KAAK,CAAdE,KAAK;;IAEZ;IACA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,KAAK,CAACjB,MAAM,EAAEkB,CAAC,IAAI,CAAC,EAAE;MACxC,IAAMC,SAAS,GAAGvD,gBAAgB,CAACK,qBAAU,CAACmD,OAAO,YAAKP,QAAQ,CAAC/C,EAAE,cAAIoD,CAAC,GAAInD,OAAO,CAAC;MAEtF+C,UAAU,CAACO,IAAI,WAAI5D,YAAY,uBAAa0D,SAAS,EAAG;IAC1D;EACF;EAEA,OAAOL,UAAU;AACnB"}
|
package/dist/while-in-flight.js
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.default = whileInFlight;
|
|
12
|
-
|
|
13
9
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
14
|
-
|
|
15
10
|
var _apply = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/apply"));
|
|
16
|
-
|
|
17
11
|
var _wrap2 = _interopRequireDefault(require("lodash/wrap"));
|
|
18
|
-
|
|
19
12
|
var _tap = _interopRequireDefault(require("./tap"));
|
|
20
|
-
|
|
21
13
|
/**
|
|
22
14
|
* While the promise returned by the decorated is unfullfilled, sets, the
|
|
23
15
|
* specified boolean on the target class to `true`
|
|
@@ -28,11 +20,9 @@ function whileInFlight(param) {
|
|
|
28
20
|
return function whileInFlightDecorator(target, name, descriptor) {
|
|
29
21
|
descriptor.value = (0, _wrap2.default)(descriptor.value, function whileInFlightExecutor(fn) {
|
|
30
22
|
var _this = this;
|
|
31
|
-
|
|
32
23
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
33
24
|
args[_key - 1] = arguments[_key];
|
|
34
25
|
}
|
|
35
|
-
|
|
36
26
|
return new _promise.default(function (resolve) {
|
|
37
27
|
_this[param] = true;
|
|
38
28
|
resolve((0, _apply.default)(fn, _this, args).then((0, _tap.default)(function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["whileInFlight","param","whileInFlightDecorator","target","name","descriptor","value","whileInFlightExecutor","fn","args","resolve","then","tap","catch","reason","reject"],"sources":["while-in-flight.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint no-invalid-this: [0] */\n\nimport {wrap} from 'lodash';\n\nimport tap from './tap';\n\n/**\n * While the promise returned by the decorated is unfullfilled, sets, the\n * specified boolean on the target class to `true`\n * @param {string} param\n * @returns {Function}\n */\nexport default function whileInFlight(param) {\n return function whileInFlightDecorator(target, name, descriptor) {\n descriptor.value = wrap(descriptor.value, function whileInFlightExecutor(fn, ...args) {\n return new Promise((resolve) => {\n this[param] = true;\n resolve(Reflect.apply(fn, this, args)\n
|
|
1
|
+
{"version":3,"names":["whileInFlight","param","whileInFlightDecorator","target","name","descriptor","value","whileInFlightExecutor","fn","args","resolve","then","tap","catch","reason","reject"],"sources":["while-in-flight.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint no-invalid-this: [0] */\n\nimport {wrap} from 'lodash';\n\nimport tap from './tap';\n\n/**\n * While the promise returned by the decorated is unfullfilled, sets, the\n * specified boolean on the target class to `true`\n * @param {string} param\n * @returns {Function}\n */\nexport default function whileInFlight(param) {\n return function whileInFlightDecorator(target, name, descriptor) {\n descriptor.value = wrap(descriptor.value, function whileInFlightExecutor(fn, ...args) {\n return new Promise((resolve) => {\n this[param] = true;\n resolve(\n Reflect.apply(fn, this, args)\n .then(\n tap(() => {\n this[param] = false;\n })\n )\n .catch((reason) => {\n this[param] = false;\n\n return Promise.reject(reason);\n })\n );\n });\n });\n };\n}\n"],"mappings":";;;;;;;;;;;AAQA;AAEA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAa,CAACC,KAAK,EAAE;EAC3C,OAAO,SAASC,sBAAsB,CAACC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAE;IAC/DA,UAAU,CAACC,KAAK,GAAG,oBAAKD,UAAU,CAACC,KAAK,EAAE,SAASC,qBAAqB,CAACC,EAAE,EAAW;MAAA;MAAA,kCAANC,IAAI;QAAJA,IAAI;MAAA;MAClF,OAAO,qBAAY,UAACC,OAAO,EAAK;QAC9B,KAAI,CAACT,KAAK,CAAC,GAAG,IAAI;QAClBS,OAAO,CACL,oBAAcF,EAAE,EAAE,KAAI,EAAEC,IAAI,CAAC,CAC1BE,IAAI,CACH,IAAAC,YAAG,EAAC,YAAM;UACR,KAAI,CAACX,KAAK,CAAC,GAAG,KAAK;QACrB,CAAC,CAAC,CACH,CACAY,KAAK,CAAC,UAACC,MAAM,EAAK;UACjB,KAAI,CAACb,KAAK,CAAC,GAAG,KAAK;UAEnB,OAAO,iBAAQc,MAAM,CAACD,MAAM,CAAC;QAC/B,CAAC,CAAC,CACL;MACH,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC;AACH"}
|