@webex/storage-adapter-local-forage 3.0.0-bnr.5 → 3.0.0-next.10
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 -0
- package/babel.config.js +3 -0
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/jest.config.js +3 -0
- package/package.json +25 -8
- package/process +1 -0
- package/dist/types/index.d.ts +0 -35
package/.eslintrc.js
ADDED
package/babel.config.js
ADDED
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ var loggers = new _weakMap.default();
|
|
|
27
27
|
/**
|
|
28
28
|
* IndexedDB adapter for webex-core storage layer
|
|
29
29
|
*/
|
|
30
|
-
var StorageAdapterLocalForage = /*#__PURE__*/function () {
|
|
30
|
+
var StorageAdapterLocalForage = exports.default = /*#__PURE__*/function () {
|
|
31
31
|
/**
|
|
32
32
|
* @constructs {StorageAdapterLocalForage}
|
|
33
33
|
* @param {string} basekey localforage key under which
|
|
@@ -144,5 +144,4 @@ var StorageAdapterLocalForage = /*#__PURE__*/function () {
|
|
|
144
144
|
}]);
|
|
145
145
|
return StorageAdapterLocalForage;
|
|
146
146
|
}();
|
|
147
|
-
exports.default = StorageAdapterLocalForage;
|
|
148
147
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["namespaces","loggers","StorageAdapterLocalForage","Bound","oneFlight","keyFactory","key","namespace","options","set","logger","get","debug","resolve","localforage","
|
|
1
|
+
{"version":3,"names":["_localforage","_interopRequireDefault","require","_common","_webexCore","namespaces","_weakMap","default","loggers","StorageAdapterLocalForage","exports","_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"],"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,CAAY,CAAC;AAChC,IAAMC,OAAO,GAAG,IAAAF,QAAA,CAAAC,OAAA,CAAY,CAAC;;AAE7B;AACA;AACA;AAFA,IAGqBE,yBAAyB,GAAAC,OAAA,CAAAH,OAAA;EAC5C;AACF;AACA;AACA;AACA;EACE,SAAAE,0BAAA,EAAc;IAAA,IAAAE,IAAA,EAAAC,KAAA,EAAAC,MAAA;IAAA,IAAAC,gBAAA,CAAAP,OAAA,QAAAE,yBAAA;IACZ;AACJ;AACA;IACI,IAAI,CAACM,KAAK,IAAAJ,IAAA,GAsBP,IAAAK,iBAAS,EAAC;MACTC,UAA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,MAAA;IAAA,UAAA8B,0BAAA,CAAApC,OAAA,EAAAM,MAAA,CAAA+B,SAAA,UAAAjC,IAAA,OAAAkC,yBAAA,CAAAtC,OAAA,EAAAM,MAAA,CAAA+B,SAAA,UAAA/B,MAAA,CAAA+B,SAAA,OAAAD,0BAAA,CAAApC,OAAA,EAAAM,MAAA,CAAA+B,SAAA,UAAAhC,KAAA,OAAAiC,yBAAA,CAAAtC,OAAA,EAAAM,MAAA,CAAA+B,SAAA,UAAA/B,MAAA,CAAA+B,SAAA,IAAA/B,MAAA,EACF;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;EALE,IAAAU,aAAA,CAAAhB,OAAA,EAAAE,yBAAA;IAAAS,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,CAAArB,OAAA,CAAQgC,MAAM,CAAC,IAAIQ,KAAK,CAAC,yBAAyB,CAAC,CAAC;MAC7D;MAEA,IAAI,CAAC3B,OAAO,CAACE,MAAM,EAAE;QACnB,OAAOM,QAAA,CAAArB,OAAA,CAAQgC,MAAM,CAAC,IAAIQ,KAAK,CAAC,8BAA8B,CAAC,CAAC;MAClE;MAEA3B,OAAO,CAACE,MAAM,CAAC0B,IAAI,CAAC,iDAAiD,CAAC;MAEtE,OAAOpB,QAAA,CAAArB,OAAA,CAAQsB,OAAO,CAAC,IAAI,IAAI,CAACd,KAAK,CAACI,SAAS,EAAEC,OAAO,CAAC,CAAC;IAC5D;EAAC;EAAA,OAAAX,yBAAA;AAAA"}
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/storage-adapter-local-forage",
|
|
3
|
-
"version": "3.0.0-bnr.5",
|
|
4
3
|
"description": "",
|
|
5
4
|
"license": "MIT",
|
|
6
5
|
"author": "Matt Norris <matthew.g.norris@gmail.com>",
|
|
@@ -21,13 +20,31 @@
|
|
|
21
20
|
]
|
|
22
21
|
},
|
|
23
22
|
"devDependencies": {
|
|
24
|
-
"@
|
|
23
|
+
"@babel/core": "^7.17.10",
|
|
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": "3.0.0-next.10",
|
|
29
|
+
"@webex/test-helper-mocha": "3.0.0-next.10",
|
|
30
|
+
"@webex/test-helper-mock-webex": "3.0.0-next.10",
|
|
31
|
+
"@webex/test-helper-test-users": "3.0.0-next.10",
|
|
32
|
+
"eslint": "^8.24.0",
|
|
33
|
+
"prettier": "^2.7.1"
|
|
25
34
|
},
|
|
26
35
|
"dependencies": {
|
|
27
|
-
"@webex/common": "3.0.0-
|
|
28
|
-
"@webex/storage-adapter-
|
|
29
|
-
"@webex/
|
|
30
|
-
"@webex/webex-core": "3.0.0-bnr.5",
|
|
36
|
+
"@webex/common": "3.0.0-next.10",
|
|
37
|
+
"@webex/storage-adapter-spec": "3.0.0-next.10",
|
|
38
|
+
"@webex/webex-core": "3.0.0-next.10",
|
|
31
39
|
"localforage": "^1.7.3"
|
|
32
|
-
}
|
|
33
|
-
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "yarn build:src",
|
|
43
|
+
"build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
|
|
44
|
+
"deploy:npm": "yarn npm publish",
|
|
45
|
+
"test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
|
|
46
|
+
"test:browser": "webex-legacy-tools test --unit --runner karma",
|
|
47
|
+
"test:style": "eslint ./src/**/*.*"
|
|
48
|
+
},
|
|
49
|
+
"version": "3.0.0-next.10"
|
|
50
|
+
}
|
package/process
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {browser: true};
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IndexedDB adapter for webex-core storage layer
|
|
3
|
-
*/
|
|
4
|
-
export default class StorageAdapterLocalForage {
|
|
5
|
-
/**
|
|
6
|
-
* localforage binding
|
|
7
|
-
*/
|
|
8
|
-
Bound: {
|
|
9
|
-
new (namespace: string, options: any): {
|
|
10
|
-
/**
|
|
11
|
-
* Clears the localforage
|
|
12
|
-
* @param {string} key
|
|
13
|
-
* @returns {Promise}
|
|
14
|
-
*/
|
|
15
|
-
clear(): Promise<any>;
|
|
16
|
-
del(key: any): Promise<void>;
|
|
17
|
-
get(key: any): Promise<any>;
|
|
18
|
-
/**
|
|
19
|
-
* Stores the specified value at the specified key.
|
|
20
|
-
* If key is undefined, removes the specified key.
|
|
21
|
-
* @param {string} key
|
|
22
|
-
* @param {mixed} value
|
|
23
|
-
* @returns {Promise}
|
|
24
|
-
*/
|
|
25
|
-
put(key: string, value: mixed): Promise<any>;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Returns an adapter bound to the specified namespace
|
|
30
|
-
* @param {string} namespace
|
|
31
|
-
* @param {Object} options
|
|
32
|
-
* @returns {Promise<Bound>}
|
|
33
|
-
*/
|
|
34
|
-
bind(namespace: string, options: any): Promise<Bound>;
|
|
35
|
-
}
|