@webex/storage-adapter-local-forage 2.59.2 → 2.59.3-next.1

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 CHANGED
@@ -1,6 +1,6 @@
1
- const config = {
2
- root: true,
3
- extends: ['@webex/eslint-config-legacy'],
4
- };
5
-
6
- module.exports = config;
1
+ const config = {
2
+ root: true,
3
+ extends: ['@webex/eslint-config-legacy'],
4
+ };
5
+
6
+ module.exports = config;
package/README.md CHANGED
@@ -1,33 +1,33 @@
1
- # @webex/storage-adapter-local-forage
2
-
3
- [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
-
5
- > Local Forage (indexedDB) adapter for the Cisco Webex JS SDK
6
-
7
- - [Install](#install)
8
- - [Usage](#usage)
9
- - [Contribute](#contribute)
10
- - [Maintainers](#maintainers)
11
- - [License](#license)
12
-
13
- ## Install
14
-
15
- ```bash
16
- npm install --save @webex/storage-adapter-local-forage
17
- ```
18
-
19
- ## Usage
20
-
21
- This is a part of the Cisco Webex JS SDK . Please see our [developer portal](https://developer.webex.com/) and the [API docs](https://webex.github.io/webex-js-sdk/api/) for full details.
22
-
23
- ## Maintainers
24
-
25
- This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
26
-
27
- ## Contribute
28
-
29
- Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
30
-
31
- ## License
32
-
33
- © 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
1
+ # @webex/storage-adapter-local-forage
2
+
3
+ [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
+
5
+ > Local Forage (indexedDB) adapter for the Cisco Webex JS SDK
6
+
7
+ - [Install](#install)
8
+ - [Usage](#usage)
9
+ - [Contribute](#contribute)
10
+ - [Maintainers](#maintainers)
11
+ - [License](#license)
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install --save @webex/storage-adapter-local-forage
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ This is a part of the Cisco Webex JS SDK . Please see our [developer portal](https://developer.webex.com/) and the [API docs](https://webex.github.io/webex-js-sdk/api/) for full details.
22
+
23
+ ## Maintainers
24
+
25
+ This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
26
+
27
+ ## Contribute
28
+
29
+ Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
30
+
31
+ ## License
32
+
33
+ © 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
package/babel.config.js CHANGED
@@ -1,3 +1,3 @@
1
- const babelConfigLegacy = require('@webex/babel-config-legacy');
2
-
3
- module.exports = babelConfigLegacy;
1
+ const babelConfigLegacy = require('@webex/babel-config-legacy');
2
+
3
+ module.exports = babelConfigLegacy;
package/dist/index.js CHANGED
@@ -15,8 +15,8 @@ var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-c
15
15
  var _localforage = _interopRequireDefault(require("localforage"));
16
16
  var _common = require("@webex/common");
17
17
  var _webexCore = require("@webex/webex-core");
18
- /*!
19
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
18
+ /*!
19
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
20
20
  */
21
21
 
22
22
  /* eslint-env browser */
@@ -24,20 +24,20 @@ var _webexCore = require("@webex/webex-core");
24
24
  var namespaces = new _weakMap.default();
25
25
  var loggers = new _weakMap.default();
26
26
 
27
- /**
28
- * IndexedDB adapter for webex-core storage layer
27
+ /**
28
+ * IndexedDB adapter for webex-core storage layer
29
29
  */
30
30
  var StorageAdapterLocalForage = /*#__PURE__*/function () {
31
- /**
32
- * @constructs {StorageAdapterLocalForage}
33
- * @param {string} basekey localforage key under which
34
- * all namespaces will be stored
31
+ /**
32
+ * @constructs {StorageAdapterLocalForage}
33
+ * @param {string} basekey localforage key under which
34
+ * all namespaces will be stored
35
35
  */
36
36
  function StorageAdapterLocalForage() {
37
37
  var _dec, _dec2, _class;
38
38
  (0, _classCallCheck2.default)(this, StorageAdapterLocalForage);
39
- /**
40
- * localforage binding
39
+ /**
40
+ * localforage binding
41
41
  */
42
42
  this.Bound = (_dec = (0, _common.oneFlight)({
43
43
  keyFactory: function keyFactory(key) {
@@ -48,10 +48,10 @@ var StorageAdapterLocalForage = /*#__PURE__*/function () {
48
48
  return key;
49
49
  }
50
50
  }), (_class = /*#__PURE__*/function () {
51
- /**
52
- * @constructs {Bound}
53
- * @param {string} namespace
54
- * @param {Object} options
51
+ /**
52
+ * @constructs {Bound}
53
+ * @param {string} namespace
54
+ * @param {Object} options
55
55
  */
56
56
  function _class(namespace, options) {
57
57
  (0, _classCallCheck2.default)(this, _class);
@@ -59,10 +59,10 @@ var StorageAdapterLocalForage = /*#__PURE__*/function () {
59
59
  loggers.set(this, options.logger);
60
60
  }
61
61
 
62
- /**
63
- * Clears the localforage
64
- * @param {string} key
65
- * @returns {Promise}
62
+ /**
63
+ * Clears the localforage
64
+ * @param {string} key
65
+ * @returns {Promise}
66
66
  */
67
67
  (0, _createClass2.default)(_class, [{
68
68
  key: "clear",
@@ -100,12 +100,12 @@ var StorageAdapterLocalForage = /*#__PURE__*/function () {
100
100
  });
101
101
  }
102
102
 
103
- /**
104
- * Stores the specified value at the specified key.
105
- * If key is undefined, removes the specified key.
106
- * @param {string} key
107
- * @param {mixed} value
108
- * @returns {Promise}
103
+ /**
104
+ * Stores the specified value at the specified key.
105
+ * If key is undefined, removes the specified key.
106
+ * @param {string} key
107
+ * @param {mixed} value
108
+ * @returns {Promise}
109
109
  */
110
110
  }, {
111
111
  key: "put",
@@ -122,11 +122,11 @@ var StorageAdapterLocalForage = /*#__PURE__*/function () {
122
122
  }(), ((0, _applyDecoratedDescriptor2.default)(_class.prototype, "del", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "del"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "get", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "get"), _class.prototype)), _class));
123
123
  }
124
124
 
125
- /**
126
- * Returns an adapter bound to the specified namespace
127
- * @param {string} namespace
128
- * @param {Object} options
129
- * @returns {Promise<Bound>}
125
+ /**
126
+ * Returns an adapter bound to the specified namespace
127
+ * @param {string} namespace
128
+ * @param {Object} options
129
+ * @returns {Promise<Bound>}
130
130
  */
131
131
  (0, _createClass2.default)(StorageAdapterLocalForage, [{
132
132
  key: "bind",
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_localforage","_interopRequireDefault","require","_common","_webexCore","namespaces","_weakMap","default","loggers","StorageAdapterLocalForage","_dec","_dec2","_class","_classCallCheck2","Bound","oneFlight","keyFactory","key","namespace","options","set","logger","_createClass2","value","clear","get","debug","_promise","resolve","localforage","del","key_","concat","removeItem","getItem","then","keys","includes","reject","NotFoundError","put","setItem","_applyDecoratedDescriptor2","prototype","_getOwnPropertyDescriptor","bind","Error","info","exports"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-env browser */\n\nimport localforage from 'localforage';\nimport {oneFlight} from '@webex/common';\nimport {NotFoundError} from '@webex/webex-core';\n\nconst namespaces = new WeakMap();\nconst loggers = new WeakMap();\n\n/**\n * IndexedDB adapter for webex-core storage layer\n */\nexport default class StorageAdapterLocalForage {\n /**\n * @constructs {StorageAdapterLocalForage}\n * @param {string} basekey localforage key under which\n * all namespaces will be stored\n */\n constructor() {\n /**\n * localforage binding\n */\n this.Bound = class {\n /**\n * @constructs {Bound}\n * @param {string} namespace\n * @param {Object} options\n */\n constructor(namespace, options) {\n namespaces.set(this, namespace);\n loggers.set(this, options.logger);\n }\n\n /**\n * Clears the localforage\n * @param {string} key\n * @returns {Promise}\n */\n clear() {\n loggers.get(this).debug('storage-adapter-local-forage: clearing localforage');\n\n return Promise.resolve(localforage.clear());\n }\n\n @oneFlight({\n keyFactory: (key) => key,\n })\n /**\n * Removes the specified key\n * @param {string} key\n * @returns {Promise}\n */\n // suppress doc warning because decorators confuse eslint\n // eslint-disable-next-line require-jsdoc\n del(key) {\n const key_ = `${namespaces.get(this)}/${key}`;\n\n loggers.get(this).debug(`storage-adapter-local-forage: deleting \\`${key_}\\``);\n\n return localforage.removeItem(key_);\n }\n\n @oneFlight({\n keyFactory: (key) => key,\n })\n /**\n * Retrieves the data at the specified key\n * @param {string} key\n * @see https://localforage.github.io/localForage/#data-api-getitem\n * @returns {Promise<mixed>}\n */\n // suppress doc warning because decorators confuse eslint\n // eslint-disable-next-line require-jsdoc\n get(key) {\n const key_ = `${namespaces.get(this)}/${key}`;\n\n loggers.get(this).debug(`storage-adapter-local-forage: reading \\`${key_}\\``);\n\n return localforage.getItem(key_).then((value) => {\n // if the key does not exist, getItem() will return null\n if (value === null) {\n // If we got null, we need to check if it's because the key\n // doesn't exist or because it has a saved value of null.\n return localforage.keys().then((keys) => {\n if (keys.includes(key_)) {\n return Promise.resolve(value);\n }\n\n return Promise.reject(new NotFoundError(`No value found for ${key_}`));\n });\n }\n\n // even if undefined is saved, null will be returned by getItem()\n return Promise.resolve(value);\n });\n }\n\n /**\n * Stores the specified value at the specified key.\n * If key is undefined, removes the specified key.\n * @param {string} key\n * @param {mixed} value\n * @returns {Promise}\n */\n put(key, value) {\n if (typeof value === 'undefined') {\n return this.del(key);\n }\n const key_ = `${namespaces.get(this)}/${key}`;\n\n loggers.get(this).debug(`storage-adapter-local-forage: writing \\`${key_}\\``);\n\n return localforage.setItem(key_, value);\n }\n };\n }\n\n /**\n * Returns an adapter bound to the specified namespace\n * @param {string} namespace\n * @param {Object} options\n * @returns {Promise<Bound>}\n */\n bind(namespace, options) {\n options = options || {};\n if (!namespace) {\n return Promise.reject(new Error('`namespace` is required'));\n }\n\n if (!options.logger) {\n return Promise.reject(new Error('`options.logger` is required'));\n }\n\n options.logger.info('storage-adapter-local-forage: returning binding');\n\n return Promise.resolve(new this.Bound(namespace, options));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAMA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AARA;AACA;AACA;;AAEA;;AAMA,IAAMG,UAAU,GAAG,IAAAC,QAAA,CAAAC,OAAA,EAAa;AAChC,IAAMC,OAAO,GAAG,IAAAF,QAAA,CAAAC,OAAA,EAAa;;AAE7B;AACA;AACA;AAFA,IAGqBE,yBAAyB;EAC5C;AACF;AACA;AACA;AACA;EACE,SAAAA,0BAAA,EAAc;IAAA,IAAAC,IAAA,EAAAC,KAAA,EAAAC,MAAA;IAAA,IAAAC,gBAAA,CAAAN,OAAA,QAAAE,yBAAA;IACZ;AACJ;AACA;IACI,IAAI,CAACK,KAAK,IAAAJ,IAAA,GAsBP,IAAAK,iBAAS,EAAC;MACTC,UAAU,EAAE,SAAAA,WAACC,GAAG;QAAA,OAAKA,GAAG;MAAA;IAC1B,CAAC,CAAC,EAAAN,KAAA,GAgBD,IAAAI,iBAAS,EAAC;MACTC,UAAU,EAAE,SAAAA,WAACC,GAAG;QAAA,OAAKA,GAAG;MAAA;IAC1B,CAAC,CAAC,GAAAL,MAAA;MAzCF;AACN;AACA;AACA;AACA;MACM,SAAAA,OAAYM,SAAS,EAAEC,OAAO,EAAE;QAAA,IAAAN,gBAAA,CAAAN,OAAA,QAAAK,MAAA;QAC9BP,UAAU,CAACe,GAAG,CAAC,IAAI,EAAEF,SAAS,CAAC;QAC/BV,OAAO,CAACY,GAAG,CAAC,IAAI,EAAED,OAAO,CAACE,MAAM,CAAC;MACnC;;MAEA;AACN;AACA;AACA;AACA;MAJM,IAAAC,aAAA,CAAAf,OAAA,EAAAK,MAAA;QAAAK,GAAA;QAAAM,KAAA,EAKA,SAAAC,MAAA,EAAQ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,MAAM,CAAC,IAAIQ,KAAK,CAAC,yBAAyB,CAAC,CAAC;MAC7D;MAEA,IAAI,CAAC3B,OAAO,CAACE,MAAM,EAAE;QACnB,OAAOM,QAAA,CAAApB,OAAA,CAAQ+B,MAAM,CAAC,IAAIQ,KAAK,CAAC,8BAA8B,CAAC,CAAC;MAClE;MAEA3B,OAAO,CAACE,MAAM,CAAC0B,IAAI,CAAC,iDAAiD,CAAC;MAEtE,OAAOpB,QAAA,CAAApB,OAAA,CAAQqB,OAAO,CAAC,IAAI,IAAI,CAACd,KAAK,CAACI,SAAS,EAAEC,OAAO,CAAC,CAAC;IAC5D;EAAC;EAAA,OAAAV,yBAAA;AAAA;AAAAuC,OAAA,CAAAzC,OAAA,GAAAE,yBAAA"}
1
+ {"version":3,"names":["_localforage","_interopRequireDefault","require","_common","_webexCore","namespaces","_weakMap","default","loggers","StorageAdapterLocalForage","_dec","_dec2","_class","_classCallCheck2","Bound","oneFlight","keyFactory","key","namespace","options","set","logger","_createClass2","value","clear","get","debug","_promise","resolve","localforage","del","key_","concat","removeItem","getItem","then","keys","includes","reject","NotFoundError","put","setItem","_applyDecoratedDescriptor2","prototype","_getOwnPropertyDescriptor","bind","Error","info","exports"],"sources":["index.js"],"sourcesContent":["/*!\r\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\r\n */\r\n\r\n/* eslint-env browser */\r\n\r\nimport localforage from 'localforage';\r\nimport {oneFlight} from '@webex/common';\r\nimport {NotFoundError} from '@webex/webex-core';\r\n\r\nconst namespaces = new WeakMap();\r\nconst loggers = new WeakMap();\r\n\r\n/**\r\n * IndexedDB adapter for webex-core storage layer\r\n */\r\nexport default class StorageAdapterLocalForage {\r\n /**\r\n * @constructs {StorageAdapterLocalForage}\r\n * @param {string} basekey localforage key under which\r\n * all namespaces will be stored\r\n */\r\n constructor() {\r\n /**\r\n * localforage binding\r\n */\r\n this.Bound = class {\r\n /**\r\n * @constructs {Bound}\r\n * @param {string} namespace\r\n * @param {Object} options\r\n */\r\n constructor(namespace, options) {\r\n namespaces.set(this, namespace);\r\n loggers.set(this, options.logger);\r\n }\r\n\r\n /**\r\n * Clears the localforage\r\n * @param {string} key\r\n * @returns {Promise}\r\n */\r\n clear() {\r\n loggers.get(this).debug('storage-adapter-local-forage: clearing localforage');\r\n\r\n return Promise.resolve(localforage.clear());\r\n }\r\n\r\n @oneFlight({\r\n keyFactory: (key) => key,\r\n })\r\n /**\r\n * Removes the specified key\r\n * @param {string} key\r\n * @returns {Promise}\r\n */\r\n // suppress doc warning because decorators confuse eslint\r\n // eslint-disable-next-line require-jsdoc\r\n del(key) {\r\n const key_ = `${namespaces.get(this)}/${key}`;\r\n\r\n loggers.get(this).debug(`storage-adapter-local-forage: deleting \\`${key_}\\``);\r\n\r\n return localforage.removeItem(key_);\r\n }\r\n\r\n @oneFlight({\r\n keyFactory: (key) => key,\r\n })\r\n /**\r\n * Retrieves the data at the specified key\r\n * @param {string} key\r\n * @see https://localforage.github.io/localForage/#data-api-getitem\r\n * @returns {Promise<mixed>}\r\n */\r\n // suppress doc warning because decorators confuse eslint\r\n // eslint-disable-next-line require-jsdoc\r\n get(key) {\r\n const key_ = `${namespaces.get(this)}/${key}`;\r\n\r\n loggers.get(this).debug(`storage-adapter-local-forage: reading \\`${key_}\\``);\r\n\r\n return localforage.getItem(key_).then((value) => {\r\n // if the key does not exist, getItem() will return null\r\n if (value === null) {\r\n // If we got null, we need to check if it's because the key\r\n // doesn't exist or because it has a saved value of null.\r\n return localforage.keys().then((keys) => {\r\n if (keys.includes(key_)) {\r\n return Promise.resolve(value);\r\n }\r\n\r\n return Promise.reject(new NotFoundError(`No value found for ${key_}`));\r\n });\r\n }\r\n\r\n // even if undefined is saved, null will be returned by getItem()\r\n return Promise.resolve(value);\r\n });\r\n }\r\n\r\n /**\r\n * Stores the specified value at the specified key.\r\n * If key is undefined, removes the specified key.\r\n * @param {string} key\r\n * @param {mixed} value\r\n * @returns {Promise}\r\n */\r\n put(key, value) {\r\n if (typeof value === 'undefined') {\r\n return this.del(key);\r\n }\r\n const key_ = `${namespaces.get(this)}/${key}`;\r\n\r\n loggers.get(this).debug(`storage-adapter-local-forage: writing \\`${key_}\\``);\r\n\r\n return localforage.setItem(key_, value);\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Returns an adapter bound to the specified namespace\r\n * @param {string} namespace\r\n * @param {Object} options\r\n * @returns {Promise<Bound>}\r\n */\r\n bind(namespace, options) {\r\n options = options || {};\r\n if (!namespace) {\r\n return Promise.reject(new Error('`namespace` is required'));\r\n }\r\n\r\n if (!options.logger) {\r\n return Promise.reject(new Error('`options.logger` is required'));\r\n }\r\n\r\n options.logger.info('storage-adapter-local-forage: returning binding');\r\n\r\n return Promise.resolve(new this.Bound(namespace, options));\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;AAMA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AARA;AACA;AACA;;AAEA;;AAMA,IAAMG,UAAU,GAAG,IAAAC,QAAA,CAAAC,OAAA,EAAa;AAChC,IAAMC,OAAO,GAAG,IAAAF,QAAA,CAAAC,OAAA,EAAa;;AAE7B;AACA;AACA;AAFA,IAGqBE,yBAAyB;EAC5C;AACF;AACA;AACA;AACA;EACE,SAAAA,0BAAA,EAAc;IAAA,IAAAC,IAAA,EAAAC,KAAA,EAAAC,MAAA;IAAA,IAAAC,gBAAA,CAAAN,OAAA,QAAAE,yBAAA;IACZ;AACJ;AACA;IACI,IAAI,CAACK,KAAK,IAAAJ,IAAA,GAsBP,IAAAK,iBAAS,EAAC;MACTC,UAAU,EAAE,SAAAA,WAACC,GAAG;QAAA,OAAKA,GAAG;MAAA;IAC1B,CAAC,CAAC,EAAAN,KAAA,GAgBD,IAAAI,iBAAS,EAAC;MACTC,UAAU,EAAE,SAAAA,WAACC,GAAG;QAAA,OAAKA,GAAG;MAAA;IAC1B,CAAC,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,UAAAhC,KAAA,OAAAiC,yBAAA,CAAArC,OAAA,EAAAK,MAAA,CAAA+B,SAAA,UAAA/B,MAAA,CAAA+B,SAAA,IAAA/B,MAAA,EACF;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;EALE,IAAAU,aAAA,CAAAf,OAAA,EAAAE,yBAAA;IAAAQ,GAAA;IAAAM,KAAA,EAMA,SAAAsB,KAAK3B,SAAS,EAAEC,OAAO,EAAE;MACvBA,OAAO,GAAGA,OAAO,IAAI,CAAC,CAAC;MACvB,IAAI,CAACD,SAAS,EAAE;QACd,OAAOS,QAAA,CAAApB,OAAA,CAAQ+B,MAAM,CAAC,IAAIQ,KAAK,CAAC,yBAAyB,CAAC,CAAC;MAC7D;MAEA,IAAI,CAAC3B,OAAO,CAACE,MAAM,EAAE;QACnB,OAAOM,QAAA,CAAApB,OAAA,CAAQ+B,MAAM,CAAC,IAAIQ,KAAK,CAAC,8BAA8B,CAAC,CAAC;MAClE;MAEA3B,OAAO,CAACE,MAAM,CAAC0B,IAAI,CAAC,iDAAiD,CAAC;MAEtE,OAAOpB,QAAA,CAAApB,OAAA,CAAQqB,OAAO,CAAC,IAAI,IAAI,CAACd,KAAK,CAACI,SAAS,EAAEC,OAAO,CAAC,CAAC;IAC5D;EAAC;EAAA,OAAAV,yBAAA;AAAA;AAAAuC,OAAA,CAAAzC,OAAA,GAAAE,yBAAA"}
package/jest.config.js CHANGED
@@ -1,3 +1,3 @@
1
- const config = require('@webex/jest-config-legacy');
2
-
3
- module.exports = config;
1
+ const config = require('@webex/jest-config-legacy');
2
+
3
+ module.exports = config;
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "@webex/storage-adapter-local-forage",
3
- "version": "2.59.2",
4
3
  "description": "",
5
4
  "license": "MIT",
6
5
  "author": "Matt Norris <matthew.g.norris@gmail.com>",
@@ -22,30 +21,32 @@
22
21
  },
23
22
  "devDependencies": {
24
23
  "@babel/core": "^7.17.10",
25
- "@webex/babel-config-legacy": "2.59.2",
26
- "@webex/eslint-config-legacy": "2.59.2",
27
- "@webex/jest-config-legacy": "2.59.2",
28
- "@webex/legacy-tools": "2.59.2",
29
- "@webex/test-helper-chai": "2.59.2",
30
- "@webex/test-helper-mocha": "2.59.2",
31
- "@webex/test-helper-mock-webex": "2.59.2",
32
- "@webex/test-helper-test-users": "2.59.2",
24
+ "@webex/babel-config-legacy": "^0.0.0",
25
+ "@webex/eslint-config-legacy": "^0.0.0",
26
+ "@webex/jest-config-legacy": "^0.0.0",
27
+ "@webex/legacy-tools": "^0.0.0",
28
+ "@webex/test-helper-chai": "^2.59.3-next.1",
29
+ "@webex/test-helper-mocha": "^2.59.3-next.1",
30
+ "@webex/test-helper-mock-webex": "^2.59.3-next.1",
31
+ "@webex/test-helper-test-users": "^2.59.3-next.1",
33
32
  "eslint": "^8.24.0",
34
33
  "prettier": "^2.7.1"
35
34
  },
36
35
  "dependencies": {
37
- "@webex/common": "2.59.2",
38
- "@webex/storage-adapter-spec": "2.59.2",
39
- "@webex/webex-core": "2.59.2",
36
+ "@webex/common": "^2.59.3-next.1",
37
+ "@webex/storage-adapter-spec": "^2.59.3-next.1",
38
+ "@webex/webex-core": "^2.59.3-next.1",
40
39
  "localforage": "^1.7.3"
41
40
  },
42
41
  "scripts": {
43
42
  "build": "yarn build:src",
44
43
  "build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
44
+ "deploy:npm": "yarn npm publish",
45
45
  "test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
46
46
  "test:browser:broken": "webex-legacy-tools test --integration --unit --runner karma",
47
47
  "test:integration": "webex-legacy-tools test --integration --runner mocha",
48
48
  "test:style": "eslint ./src/**/*.*",
49
49
  "test:unit": "webex-legacy-tools test --unit --runner jest"
50
- }
51
- }
50
+ },
51
+ "version": "2.59.3-next.1"
52
+ }
package/process CHANGED
@@ -1 +1 @@
1
- module.exports = {browser: true};
1
+ module.exports = {browser: true};
package/src/index.js CHANGED
@@ -1,142 +1,142 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- /* eslint-env browser */
6
-
7
- import localforage from 'localforage';
8
- import {oneFlight} from '@webex/common';
9
- import {NotFoundError} from '@webex/webex-core';
10
-
11
- const namespaces = new WeakMap();
12
- const loggers = new WeakMap();
13
-
14
- /**
15
- * IndexedDB adapter for webex-core storage layer
16
- */
17
- export default class StorageAdapterLocalForage {
18
- /**
19
- * @constructs {StorageAdapterLocalForage}
20
- * @param {string} basekey localforage key under which
21
- * all namespaces will be stored
22
- */
23
- constructor() {
24
- /**
25
- * localforage binding
26
- */
27
- this.Bound = class {
28
- /**
29
- * @constructs {Bound}
30
- * @param {string} namespace
31
- * @param {Object} options
32
- */
33
- constructor(namespace, options) {
34
- namespaces.set(this, namespace);
35
- loggers.set(this, options.logger);
36
- }
37
-
38
- /**
39
- * Clears the localforage
40
- * @param {string} key
41
- * @returns {Promise}
42
- */
43
- clear() {
44
- loggers.get(this).debug('storage-adapter-local-forage: clearing localforage');
45
-
46
- return Promise.resolve(localforage.clear());
47
- }
48
-
49
- @oneFlight({
50
- keyFactory: (key) => key,
51
- })
52
- /**
53
- * Removes the specified key
54
- * @param {string} key
55
- * @returns {Promise}
56
- */
57
- // suppress doc warning because decorators confuse eslint
58
- // eslint-disable-next-line require-jsdoc
59
- del(key) {
60
- const key_ = `${namespaces.get(this)}/${key}`;
61
-
62
- loggers.get(this).debug(`storage-adapter-local-forage: deleting \`${key_}\``);
63
-
64
- return localforage.removeItem(key_);
65
- }
66
-
67
- @oneFlight({
68
- keyFactory: (key) => key,
69
- })
70
- /**
71
- * Retrieves the data at the specified key
72
- * @param {string} key
73
- * @see https://localforage.github.io/localForage/#data-api-getitem
74
- * @returns {Promise<mixed>}
75
- */
76
- // suppress doc warning because decorators confuse eslint
77
- // eslint-disable-next-line require-jsdoc
78
- get(key) {
79
- const key_ = `${namespaces.get(this)}/${key}`;
80
-
81
- loggers.get(this).debug(`storage-adapter-local-forage: reading \`${key_}\``);
82
-
83
- return localforage.getItem(key_).then((value) => {
84
- // if the key does not exist, getItem() will return null
85
- if (value === null) {
86
- // If we got null, we need to check if it's because the key
87
- // doesn't exist or because it has a saved value of null.
88
- return localforage.keys().then((keys) => {
89
- if (keys.includes(key_)) {
90
- return Promise.resolve(value);
91
- }
92
-
93
- return Promise.reject(new NotFoundError(`No value found for ${key_}`));
94
- });
95
- }
96
-
97
- // even if undefined is saved, null will be returned by getItem()
98
- return Promise.resolve(value);
99
- });
100
- }
101
-
102
- /**
103
- * Stores the specified value at the specified key.
104
- * If key is undefined, removes the specified key.
105
- * @param {string} key
106
- * @param {mixed} value
107
- * @returns {Promise}
108
- */
109
- put(key, value) {
110
- if (typeof value === 'undefined') {
111
- return this.del(key);
112
- }
113
- const key_ = `${namespaces.get(this)}/${key}`;
114
-
115
- loggers.get(this).debug(`storage-adapter-local-forage: writing \`${key_}\``);
116
-
117
- return localforage.setItem(key_, value);
118
- }
119
- };
120
- }
121
-
122
- /**
123
- * Returns an adapter bound to the specified namespace
124
- * @param {string} namespace
125
- * @param {Object} options
126
- * @returns {Promise<Bound>}
127
- */
128
- bind(namespace, options) {
129
- options = options || {};
130
- if (!namespace) {
131
- return Promise.reject(new Error('`namespace` is required'));
132
- }
133
-
134
- if (!options.logger) {
135
- return Promise.reject(new Error('`options.logger` is required'));
136
- }
137
-
138
- options.logger.info('storage-adapter-local-forage: returning binding');
139
-
140
- return Promise.resolve(new this.Bound(namespace, options));
141
- }
142
- }
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ /* eslint-env browser */
6
+
7
+ import localforage from 'localforage';
8
+ import {oneFlight} from '@webex/common';
9
+ import {NotFoundError} from '@webex/webex-core';
10
+
11
+ const namespaces = new WeakMap();
12
+ const loggers = new WeakMap();
13
+
14
+ /**
15
+ * IndexedDB adapter for webex-core storage layer
16
+ */
17
+ export default class StorageAdapterLocalForage {
18
+ /**
19
+ * @constructs {StorageAdapterLocalForage}
20
+ * @param {string} basekey localforage key under which
21
+ * all namespaces will be stored
22
+ */
23
+ constructor() {
24
+ /**
25
+ * localforage binding
26
+ */
27
+ this.Bound = class {
28
+ /**
29
+ * @constructs {Bound}
30
+ * @param {string} namespace
31
+ * @param {Object} options
32
+ */
33
+ constructor(namespace, options) {
34
+ namespaces.set(this, namespace);
35
+ loggers.set(this, options.logger);
36
+ }
37
+
38
+ /**
39
+ * Clears the localforage
40
+ * @param {string} key
41
+ * @returns {Promise}
42
+ */
43
+ clear() {
44
+ loggers.get(this).debug('storage-adapter-local-forage: clearing localforage');
45
+
46
+ return Promise.resolve(localforage.clear());
47
+ }
48
+
49
+ @oneFlight({
50
+ keyFactory: (key) => key,
51
+ })
52
+ /**
53
+ * Removes the specified key
54
+ * @param {string} key
55
+ * @returns {Promise}
56
+ */
57
+ // suppress doc warning because decorators confuse eslint
58
+ // eslint-disable-next-line require-jsdoc
59
+ del(key) {
60
+ const key_ = `${namespaces.get(this)}/${key}`;
61
+
62
+ loggers.get(this).debug(`storage-adapter-local-forage: deleting \`${key_}\``);
63
+
64
+ return localforage.removeItem(key_);
65
+ }
66
+
67
+ @oneFlight({
68
+ keyFactory: (key) => key,
69
+ })
70
+ /**
71
+ * Retrieves the data at the specified key
72
+ * @param {string} key
73
+ * @see https://localforage.github.io/localForage/#data-api-getitem
74
+ * @returns {Promise<mixed>}
75
+ */
76
+ // suppress doc warning because decorators confuse eslint
77
+ // eslint-disable-next-line require-jsdoc
78
+ get(key) {
79
+ const key_ = `${namespaces.get(this)}/${key}`;
80
+
81
+ loggers.get(this).debug(`storage-adapter-local-forage: reading \`${key_}\``);
82
+
83
+ return localforage.getItem(key_).then((value) => {
84
+ // if the key does not exist, getItem() will return null
85
+ if (value === null) {
86
+ // If we got null, we need to check if it's because the key
87
+ // doesn't exist or because it has a saved value of null.
88
+ return localforage.keys().then((keys) => {
89
+ if (keys.includes(key_)) {
90
+ return Promise.resolve(value);
91
+ }
92
+
93
+ return Promise.reject(new NotFoundError(`No value found for ${key_}`));
94
+ });
95
+ }
96
+
97
+ // even if undefined is saved, null will be returned by getItem()
98
+ return Promise.resolve(value);
99
+ });
100
+ }
101
+
102
+ /**
103
+ * Stores the specified value at the specified key.
104
+ * If key is undefined, removes the specified key.
105
+ * @param {string} key
106
+ * @param {mixed} value
107
+ * @returns {Promise}
108
+ */
109
+ put(key, value) {
110
+ if (typeof value === 'undefined') {
111
+ return this.del(key);
112
+ }
113
+ const key_ = `${namespaces.get(this)}/${key}`;
114
+
115
+ loggers.get(this).debug(`storage-adapter-local-forage: writing \`${key_}\``);
116
+
117
+ return localforage.setItem(key_, value);
118
+ }
119
+ };
120
+ }
121
+
122
+ /**
123
+ * Returns an adapter bound to the specified namespace
124
+ * @param {string} namespace
125
+ * @param {Object} options
126
+ * @returns {Promise<Bound>}
127
+ */
128
+ bind(namespace, options) {
129
+ options = options || {};
130
+ if (!namespace) {
131
+ return Promise.reject(new Error('`namespace` is required'));
132
+ }
133
+
134
+ if (!options.logger) {
135
+ return Promise.reject(new Error('`options.logger` is required'));
136
+ }
137
+
138
+ options.logger.info('storage-adapter-local-forage: returning binding');
139
+
140
+ return Promise.resolve(new this.Bound(namespace, options));
141
+ }
142
+ }
@@ -1,11 +1,11 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import runAbstractStorageAdapterSpec from '@webex/storage-adapter-spec';
6
- import {skipInNode} from '@webex/test-helper-mocha';
7
- import StorageAdapterLocalForage from '@webex/storage-adapter-local-forage';
8
-
9
- skipInNode(describe)('StorageAdapterLocalFtorage', () => {
10
- runAbstractStorageAdapterSpec(new StorageAdapterLocalForage('test'));
11
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import runAbstractStorageAdapterSpec from '@webex/storage-adapter-spec';
6
+ import {skipInNode} from '@webex/test-helper-mocha';
7
+ import StorageAdapterLocalForage from '@webex/storage-adapter-local-forage';
8
+
9
+ skipInNode(describe)('StorageAdapterLocalFtorage', () => {
10
+ runAbstractStorageAdapterSpec(new StorageAdapterLocalForage('test'));
11
+ });