@telia-ace/widget-services 1.0.4 → 1.0.5
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/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +431 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/storage/index.d.ts +0 -0
- package/{lib-esm → dist}/storage/legacy-storage-provider.d.ts +0 -0
- package/{lib-esm → dist}/storage/storage-policy-configuration-api.d.ts +0 -0
- package/{lib-esm → dist}/storage/storage.d.ts +0 -0
- package/{lib-esm → dist}/storage/types.d.ts +0 -0
- package/{lib-esm → dist}/storage/utils.d.ts +0 -0
- package/package.json +8 -9
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -12
- package/lib/storage/index.d.ts +0 -5
- package/lib/storage/index.js +0 -18
- package/lib/storage/legacy-storage-provider.d.ts +0 -25
- package/lib/storage/legacy-storage-provider.js +0 -120
- package/lib/storage/storage-policy-configuration-api.d.ts +0 -2
- package/lib/storage/storage-policy-configuration-api.js +0 -73
- package/lib/storage/storage.d.ts +0 -19
- package/lib/storage/storage.js +0 -65
- package/lib/storage/types.d.ts +0 -45
- package/lib/storage/types.js +0 -22
- package/lib/storage/utils.d.ts +0 -36
- package/lib/storage/utils.js +0 -264
- package/lib-esm/index.js +0 -1
- package/lib-esm/storage/index.js +0 -4
- package/lib-esm/storage/legacy-storage-provider.js +0 -117
- package/lib-esm/storage/storage-policy-configuration-api.js +0 -71
- package/lib-esm/storage/storage.js +0 -60
- package/lib-esm/storage/types.js +0 -19
- package/lib-esm/storage/utils.js +0 -248
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { StorageScope } from './types';
|
|
2
|
-
declare type LegacyOptions = {
|
|
3
|
-
scope?: StorageScope;
|
|
4
|
-
expiration?: Date;
|
|
5
|
-
};
|
|
6
|
-
interface LegacyMedium {
|
|
7
|
-
setItem(key: string, value: any, options?: LegacyOptions): Promise<void>;
|
|
8
|
-
getItem(key: string): Promise<any>;
|
|
9
|
-
removeItem(key: string): Promise<void>;
|
|
10
|
-
clear(): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export declare class LegacyStorage implements LegacyMedium {
|
|
13
|
-
private memory;
|
|
14
|
-
setItem(key: string, value: any, options?: LegacyOptions): Promise<void>;
|
|
15
|
-
getItem(key: string): Promise<any>;
|
|
16
|
-
removeItem(key: string): Promise<void>;
|
|
17
|
-
clear(): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
export default class LegacyStorageProvider {
|
|
20
|
-
cookies: LegacyStorage;
|
|
21
|
-
session: LegacyStorage;
|
|
22
|
-
local: LegacyStorage;
|
|
23
|
-
constructor();
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.LegacyStorage = void 0;
|
|
40
|
-
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
41
|
-
var _1 = require(".");
|
|
42
|
-
var types_1 = require("./types");
|
|
43
|
-
var utils_1 = require("./utils");
|
|
44
|
-
var LegacyStorage = /** @class */ (function () {
|
|
45
|
-
function LegacyStorage() {
|
|
46
|
-
this.memory = {
|
|
47
|
-
tenant: {},
|
|
48
|
-
implementation: {},
|
|
49
|
-
widget: {},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
LegacyStorage.prototype.setItem = function (key, value, options) {
|
|
53
|
-
if (options === void 0) { options = {}; }
|
|
54
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
-
var _this = this;
|
|
56
|
-
return __generator(this, function (_a) {
|
|
57
|
-
return [2 /*return*/, (0, widget_utilities_1.lock)(this)(function () {
|
|
58
|
-
var processedStore = (0, utils_1.processStore)(_this.memory, [_1.StorageCategory.Necessary]);
|
|
59
|
-
var _a = options.scope, scope = _a === void 0 ? types_1.StorageScope.Tenant : _a, expiration = options.expiration;
|
|
60
|
-
processedStore[scope][key] = (0, utils_1.createValue)(value, _1.StorageCategory.Necessary, (expiration === null || expiration === void 0 ? void 0 : expiration.toISOString()) || (0, utils_1.createExpirationDate)());
|
|
61
|
-
_this.memory = processedStore;
|
|
62
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
63
|
-
widget_utilities_1.Logger.warn("StorageProvider: StorageProvider is deprecated, use createStorageWriter and readStorage instead, value stored temporarily in memory.\n Key: ".concat(key, "\n Value: ").concat(JSON.stringify(value), "\n Options: ").concat(JSON.stringify(options), "\n Memory: ").concat(JSON.stringify(processedStore)));
|
|
64
|
-
}
|
|
65
|
-
})];
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
LegacyStorage.prototype.getItem = function (key) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
-
var _this = this;
|
|
72
|
-
return __generator(this, function (_a) {
|
|
73
|
-
return [2 /*return*/, (0, widget_utilities_1.lock)(this)(function () {
|
|
74
|
-
var processedStore = (0, utils_1.processStore)(_this.memory, [_1.StorageCategory.Necessary]);
|
|
75
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
76
|
-
widget_utilities_1.Logger.warn("StorageProvider: StorageProvider is deprecated, use createStorageWriter and readStorage instead, value fetched from legacy memory storage.\n Key: ".concat(key, "\n Memory: ").concat(JSON.stringify(processedStore)));
|
|
77
|
-
}
|
|
78
|
-
var value = (0, utils_1.getValue)(processedStore, key);
|
|
79
|
-
_this.memory = processedStore;
|
|
80
|
-
return value;
|
|
81
|
-
})];
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
LegacyStorage.prototype.removeItem = function (key) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
var _this = this;
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
return [2 /*return*/, (0, widget_utilities_1.lock)(this)(function () {
|
|
90
|
-
var processedStore = (0, utils_1.processStore)(_this.memory, [_1.StorageCategory.Necessary]);
|
|
91
|
-
delete processedStore.tenant[key];
|
|
92
|
-
delete processedStore.implementation[key];
|
|
93
|
-
delete processedStore.widget[key];
|
|
94
|
-
_this.memory = processedStore;
|
|
95
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
96
|
-
widget_utilities_1.Logger.warn("StorageProvider: StorageProvider is deprecated, use createStorageWriter and readStorage instead, value removed from memory.\n Key: ".concat(key, "\n Memory: ").concat(JSON.stringify(processedStore)));
|
|
97
|
-
}
|
|
98
|
-
})];
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
LegacyStorage.prototype.clear = function () {
|
|
103
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
-
return __generator(this, function (_a) {
|
|
105
|
-
return [2 /*return*/, Promise.resolve()];
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
return LegacyStorage;
|
|
110
|
-
}());
|
|
111
|
-
exports.LegacyStorage = LegacyStorage;
|
|
112
|
-
var LegacyStorageProvider = /** @class */ (function () {
|
|
113
|
-
function LegacyStorageProvider() {
|
|
114
|
-
this.cookies = new LegacyStorage();
|
|
115
|
-
this.session = new LegacyStorage();
|
|
116
|
-
this.local = new LegacyStorage();
|
|
117
|
-
}
|
|
118
|
-
return LegacyStorageProvider;
|
|
119
|
-
}());
|
|
120
|
-
exports.default = LegacyStorageProvider;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
4
|
-
var platform_1 = require("@webprovisions/platform");
|
|
5
|
-
var storage_1 = require("./storage");
|
|
6
|
-
var types_1 = require("./types");
|
|
7
|
-
var utils_1 = require("./utils");
|
|
8
|
-
exports.default = (0, platform_1.createConfigurationApi)(function (builder) {
|
|
9
|
-
builder.createCommand('storage', function (context) { return function (options) {
|
|
10
|
-
if (options === void 0) { options = {}; }
|
|
11
|
-
var consent = options.consent;
|
|
12
|
-
if (typeof consent !== 'undefined') {
|
|
13
|
-
if (typeof consent !== 'number' &&
|
|
14
|
-
typeof consent !== 'string' &&
|
|
15
|
-
!Array.isArray(consent)) {
|
|
16
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
17
|
-
widget_utilities_1.Logger.warn("storagePolicyConfigurationApi: passed consent is not valid. Consent either has to be a number, a string, an array of strings or an array of numbers.\n Passed consent: ".concat(JSON.stringify(consent)));
|
|
18
|
-
}
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (Array.isArray(consent) &&
|
|
22
|
-
!consent.every(function (c) { return typeof c === 'number' || typeof c === 'string'; })) {
|
|
23
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
24
|
-
widget_utilities_1.Logger.warn("storagePolicyConfigurationApi: passed consent is not valid. Consent either has to be a number, a string, an array of strings or an array of numbers.\n Passed consent: ".concat(JSON.stringify(consent)));
|
|
25
|
-
}
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
var policy_1 = [
|
|
29
|
-
types_1.StorageCategory.Necessary,
|
|
30
|
-
types_1.StorageCategory.Functional,
|
|
31
|
-
types_1.StorageCategory.Analytical,
|
|
32
|
-
types_1.StorageCategory.Marketing,
|
|
33
|
-
].filter(function (category, index, array) {
|
|
34
|
-
if (typeof consent === 'number') {
|
|
35
|
-
// Passed consent is a category level (number)
|
|
36
|
-
// Include the passed category level and all categories below it
|
|
37
|
-
return consent > index;
|
|
38
|
-
}
|
|
39
|
-
else if (typeof consent === 'string') {
|
|
40
|
-
// Passed consent is a category (string)
|
|
41
|
-
// Include the passed category and all categories below its level
|
|
42
|
-
return array.indexOf(consent) + 1 > index;
|
|
43
|
-
}
|
|
44
|
-
else if (Array.isArray(consent)) {
|
|
45
|
-
// Passed consent is an array with category levels (number), categories (string) or both
|
|
46
|
-
// Include all categories in passed array
|
|
47
|
-
return (consent.findIndex(function (c) {
|
|
48
|
-
return c === index + 1 || c === category;
|
|
49
|
-
}) > -1);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
if (policy_1.indexOf(types_1.StorageCategory.Necessary) === -1) {
|
|
56
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
57
|
-
widget_utilities_1.Logger.warn("storagePolicyConfigurationApi: passed consent does not include category: '".concat(types_1.StorageCategory.Necessary, "'. Consent has to atleast include the '").concat(types_1.StorageCategory.Necessary, "' category.\n Passed consent: ").concat(JSON.stringify(consent)));
|
|
58
|
-
}
|
|
59
|
-
policy_1.unshift(types_1.StorageCategory.Necessary);
|
|
60
|
-
}
|
|
61
|
-
return (0, storage_1.createStorageWriter)(context.container, 'storagePolicy', types_1.StorageCategory.Necessary, {
|
|
62
|
-
medium: types_1.StorageMedium.Cookie,
|
|
63
|
-
scope: types_1.StorageScope.Tenant,
|
|
64
|
-
duration: { days: 365 },
|
|
65
|
-
})
|
|
66
|
-
.then(function (write) { return write(policy_1); })
|
|
67
|
-
.then(function () {
|
|
68
|
-
(0, utils_1.processStorage)(context.container);
|
|
69
|
-
context.events.dispatch('storage:policy-changed', policy_1);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}; });
|
|
73
|
-
});
|
package/lib/storage/storage.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Container } from '@webprovisions/platform';
|
|
2
|
-
import { StorageCategory, StorageMedium, StorageWriter, StorageWriterOptions } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a writer to be used to write to cookie, local or session storage.
|
|
5
|
-
* @param container Widget Container.
|
|
6
|
-
* @param key Key to use when writing.
|
|
7
|
-
* @param category StorageCategory to use when writing.
|
|
8
|
-
* @param options StorageWriterOptions to use when writing default {scope: StorageScope.Widget, medium = StorageMedium.Session, duration = infinite }.
|
|
9
|
-
* @returns a function to be used to write a value to the storage using given settings.
|
|
10
|
-
*/
|
|
11
|
-
export declare const createStorageWriter: (container: Container, key: string, category: StorageCategory, options?: StorageWriterOptions) => Promise<StorageWriter>;
|
|
12
|
-
/**
|
|
13
|
-
* Read the widget cookie, local or session storage.
|
|
14
|
-
* @param container Widget Container.
|
|
15
|
-
* @param key Key to read.
|
|
16
|
-
* @param medium Storage medium to read from (default: session).
|
|
17
|
-
* @returns the value stored with passed key.
|
|
18
|
-
*/
|
|
19
|
-
export declare const readStorage: <Type>(container: Container, key: string, medium?: StorageMedium) => Promise<Type | undefined>;
|
package/lib/storage/storage.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readStorage = exports.createStorageWriter = void 0;
|
|
4
|
-
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
5
|
-
var types_1 = require("./types");
|
|
6
|
-
var utils_1 = require("./utils");
|
|
7
|
-
/**
|
|
8
|
-
* Creates a writer to be used to write to cookie, local or session storage.
|
|
9
|
-
* @param container Widget Container.
|
|
10
|
-
* @param key Key to use when writing.
|
|
11
|
-
* @param category StorageCategory to use when writing.
|
|
12
|
-
* @param options StorageWriterOptions to use when writing default {scope: StorageScope.Widget, medium = StorageMedium.Session, duration = infinite }.
|
|
13
|
-
* @returns a function to be used to write a value to the storage using given settings.
|
|
14
|
-
*/
|
|
15
|
-
var createStorageWriter = function (container, key, category, options) {
|
|
16
|
-
if (options === void 0) { options = {}; }
|
|
17
|
-
return (0, utils_1.isNotAllowedAsync)(container, category).then(function (notAllowed) {
|
|
18
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
19
|
-
if (notAllowed) {
|
|
20
|
-
widget_utilities_1.Logger.warn("createStorageWriter: Attempted to create storage writer using unallowed category.\n Key: ".concat(key, "\n Category: ").concat(JSON.stringify(category), "\n Options: ").concat(JSON.stringify(options)));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return function (value) {
|
|
24
|
-
(0, utils_1.processStorage)(container);
|
|
25
|
-
return (0, utils_1.isNotAllowedAsync)(container, category).then(function (notAllowed) {
|
|
26
|
-
if (notAllowed) {
|
|
27
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
28
|
-
widget_utilities_1.Logger.warn("storageWriter: Attempted to write to storage using unallowed category.\n Key: ".concat(key, "\n Category: ").concat(JSON.stringify(category), "\n Value: ").concat(JSON.stringify(value), "\n Options: ").concat(JSON.stringify(options)));
|
|
29
|
-
}
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
var _a = options.scope, scope = _a === void 0 ? types_1.StorageScope.Widget : _a, _b = options.medium, medium = _b === void 0 ? types_1.StorageMedium.Session : _b, duration = options.duration;
|
|
33
|
-
var store = (0, utils_1.createEmptyStore)();
|
|
34
|
-
store[scope][key] = (0, utils_1.createValue)(value, category, duration);
|
|
35
|
-
if (medium === types_1.StorageMedium.Cookie)
|
|
36
|
-
return (0, utils_1.setCookieStoreAsync)(container, store);
|
|
37
|
-
else
|
|
38
|
-
return (0, utils_1.setApplicationStoreAsync)(container, medium, store);
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
exports.createStorageWriter = createStorageWriter;
|
|
44
|
-
/**
|
|
45
|
-
* Read the widget cookie, local or session storage.
|
|
46
|
-
* @param container Widget Container.
|
|
47
|
-
* @param key Key to read.
|
|
48
|
-
* @param medium Storage medium to read from (default: session).
|
|
49
|
-
* @returns the value stored with passed key.
|
|
50
|
-
*/
|
|
51
|
-
var readStorage = function (container, key, medium) {
|
|
52
|
-
if (medium === void 0) { medium = types_1.StorageMedium.Session; }
|
|
53
|
-
(0, utils_1.processStorage)(container);
|
|
54
|
-
if (typeof key === 'undefined') {
|
|
55
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
56
|
-
widget_utilities_1.Logger.warn('readStorage: Undefined key passed when reading storage. ', key, medium);
|
|
57
|
-
}
|
|
58
|
-
return Promise.resolve(undefined);
|
|
59
|
-
}
|
|
60
|
-
if (medium === types_1.StorageMedium.Cookie)
|
|
61
|
-
return (0, utils_1.getCookieStoreAsync)(container).then(function (store) { return (0, utils_1.getValue)(store, key); });
|
|
62
|
-
else
|
|
63
|
-
return (0, utils_1.getApplicationStoreAsync)(container, medium).then(function (store) { return (0, utils_1.getValue)(store, key); });
|
|
64
|
-
};
|
|
65
|
-
exports.readStorage = readStorage;
|
package/lib/storage/types.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export declare enum StorageMedium {
|
|
2
|
-
Cookie = "cookie",
|
|
3
|
-
Local = "local",
|
|
4
|
-
Session = "session"
|
|
5
|
-
}
|
|
6
|
-
export declare enum StorageScope {
|
|
7
|
-
Tenant = "tenant",
|
|
8
|
-
Implementation = "implementation",
|
|
9
|
-
Widget = "widget"
|
|
10
|
-
}
|
|
11
|
-
export declare type Store = {
|
|
12
|
-
tenant: StorageContainer;
|
|
13
|
-
implementation: StorageContainer;
|
|
14
|
-
widget: StorageContainer;
|
|
15
|
-
};
|
|
16
|
-
export declare type StorageContainer = {
|
|
17
|
-
[key: string]: StoredValue;
|
|
18
|
-
};
|
|
19
|
-
export declare type StoredValue = {
|
|
20
|
-
value: any;
|
|
21
|
-
expiration?: string;
|
|
22
|
-
category: StorageCategory;
|
|
23
|
-
};
|
|
24
|
-
export declare enum StorageCategory {
|
|
25
|
-
Necessary = "necessary",
|
|
26
|
-
Functional = "functional",
|
|
27
|
-
Analytical = "analytical",
|
|
28
|
-
Marketing = "marketing"
|
|
29
|
-
}
|
|
30
|
-
export declare type StorageWriter = (value?: any) => Promise<void>;
|
|
31
|
-
export declare type StorageConfigurationOptions = {
|
|
32
|
-
consent?: StorageConsent;
|
|
33
|
-
};
|
|
34
|
-
export declare type StorageConsent = number | number[] | StorageCategory | StorageCategory[];
|
|
35
|
-
export declare type Duration = {
|
|
36
|
-
days?: number;
|
|
37
|
-
hours?: number;
|
|
38
|
-
minutes?: number;
|
|
39
|
-
seconds?: number;
|
|
40
|
-
};
|
|
41
|
-
export declare type StorageWriterOptions = {
|
|
42
|
-
scope?: StorageScope;
|
|
43
|
-
duration?: Duration;
|
|
44
|
-
medium?: StorageMedium;
|
|
45
|
-
};
|
package/lib/storage/types.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StorageCategory = exports.StorageScope = exports.StorageMedium = void 0;
|
|
4
|
-
var StorageMedium;
|
|
5
|
-
(function (StorageMedium) {
|
|
6
|
-
StorageMedium["Cookie"] = "cookie";
|
|
7
|
-
StorageMedium["Local"] = "local";
|
|
8
|
-
StorageMedium["Session"] = "session";
|
|
9
|
-
})(StorageMedium = exports.StorageMedium || (exports.StorageMedium = {}));
|
|
10
|
-
var StorageScope;
|
|
11
|
-
(function (StorageScope) {
|
|
12
|
-
StorageScope["Tenant"] = "tenant";
|
|
13
|
-
StorageScope["Implementation"] = "implementation";
|
|
14
|
-
StorageScope["Widget"] = "widget";
|
|
15
|
-
})(StorageScope = exports.StorageScope || (exports.StorageScope = {}));
|
|
16
|
-
var StorageCategory;
|
|
17
|
-
(function (StorageCategory) {
|
|
18
|
-
StorageCategory["Necessary"] = "necessary";
|
|
19
|
-
StorageCategory["Functional"] = "functional";
|
|
20
|
-
StorageCategory["Analytical"] = "analytical";
|
|
21
|
-
StorageCategory["Marketing"] = "marketing";
|
|
22
|
-
})(StorageCategory = exports.StorageCategory || (exports.StorageCategory = {}));
|
package/lib/storage/utils.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Container } from '@webprovisions/platform';
|
|
2
|
-
import { Duration, StorageCategory, StorageMedium, Store, StoredValue } from './types';
|
|
3
|
-
export declare const createEmptyStore: () => Store;
|
|
4
|
-
export declare const isExpired: (isoDateString?: string | undefined) => boolean;
|
|
5
|
-
export declare const getValue: <Type>(store: Store, key: string) => Type | undefined;
|
|
6
|
-
export declare const createValue: (value: any, category: StorageCategory, duration?: string | Duration | undefined) => StoredValue;
|
|
7
|
-
export declare const processStore: (store: Store, policy?: StorageCategory[] | undefined) => Store;
|
|
8
|
-
/**
|
|
9
|
-
* @param category Storage Category.
|
|
10
|
-
* @param policy Current Storage Policy.
|
|
11
|
-
* @returns true if not allowed, false if allowed.
|
|
12
|
-
*/
|
|
13
|
-
export declare const isNotAllowedAsync: (container: Container, category?: StorageCategory | undefined) => Promise<boolean>;
|
|
14
|
-
/**
|
|
15
|
-
* @param category Storage Category.
|
|
16
|
-
* @param policy Current Storage Policy.
|
|
17
|
-
* @returns true if not allowed, false if allowed.
|
|
18
|
-
*/
|
|
19
|
-
export declare const isNotAllowed: (policy?: StorageCategory[], category?: StorageCategory | undefined) => boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Processes storage and removes items if they are expired or if
|
|
22
|
-
* the storage policy is defined and the category of the stored
|
|
23
|
-
* value is not allowed.
|
|
24
|
-
* @param container Widget Container
|
|
25
|
-
*/
|
|
26
|
-
export declare const processStorage: (container: Container) => void;
|
|
27
|
-
/**
|
|
28
|
-
* Creates an expiration date string with the passed options.
|
|
29
|
-
* @param options Duration options.
|
|
30
|
-
* @returns ISO formatted date string.
|
|
31
|
-
*/
|
|
32
|
-
export declare const createExpirationDate: (options?: Duration) => string;
|
|
33
|
-
export declare const getCookieStoreAsync: (container: Container) => Promise<Store>;
|
|
34
|
-
export declare const setCookieStoreAsync: (container: Container, store: Store) => Promise<any>;
|
|
35
|
-
export declare const getApplicationStoreAsync: (container: Container, type: StorageMedium.Local | StorageMedium.Session) => Promise<Store>;
|
|
36
|
-
export declare const setApplicationStoreAsync: (container: Container, type: StorageMedium.Local | StorageMedium.Session, store: Store) => Promise<void>;
|