@telia-ace/widget-services 1.1.2-rc.1 → 1.1.2-rc.11
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/index.mjs +91 -54
- package/package.json +2 -2
- package/storage/index.d.ts +1 -1
package/index.mjs
CHANGED
|
@@ -23,7 +23,13 @@ const V = (e, t, n, r = {}) => I(e, n).then((s) => (process.env.NODE_ENV !== "pr
|
|
|
23
23
|
duration: u
|
|
24
24
|
} = r, m = j();
|
|
25
25
|
return m[c][t] = D(o, n, u), a === l.Cookie ? R(e, m) : z(e, a, m);
|
|
26
|
-
})))), L = (e, t, n = l.Session) => (K(e), typeof t > "u" ? (process.env.NODE_ENV !== "production" && g.warn(
|
|
26
|
+
})))), L = (e, t, n = l.Session) => (K(e), typeof t > "u" ? (process.env.NODE_ENV !== "production" && g.warn(
|
|
27
|
+
"readStorage: Undefined key passed when reading storage. ",
|
|
28
|
+
t,
|
|
29
|
+
n
|
|
30
|
+
), Promise.resolve(void 0)) : n === l.Cookie ? F(e).then((r) => w(r, t)) : q(e, n).then(
|
|
31
|
+
(r) => w(r, t)
|
|
32
|
+
)), p = (e) => !!Object.entries(e).filter(([t, n]) => typeof n < "u").length, $ = (e) => Object.entries(e).filter(([t, n]) => typeof n < "u").forEach(([t, { value: n }]) => {
|
|
27
33
|
typeof n > "u" && delete e[t];
|
|
28
34
|
}), b = (e, t) => {
|
|
29
35
|
const n = {
|
|
@@ -32,13 +38,16 @@ const V = (e, t, n, r = {}) => I(e, n).then((s) => (process.env.NODE_ENV !== "pr
|
|
|
32
38
|
widget: { ...e.widget, ...t.widget }
|
|
33
39
|
};
|
|
34
40
|
return $(n.tenant), $(n.implementation), $(n.widget), n;
|
|
35
|
-
}, W = (e) => Object.entries(e).reduce(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
41
|
+
}, W = (e) => Object.entries(e).reduce(
|
|
42
|
+
(n, r) => {
|
|
43
|
+
const [s, o] = r;
|
|
44
|
+
return Object.entries(o).forEach((i) => {
|
|
45
|
+
const [c, { expiration: a }] = i;
|
|
46
|
+
a && n.push(a);
|
|
47
|
+
}), n;
|
|
48
|
+
},
|
|
49
|
+
[]
|
|
50
|
+
).slice().sort((n, r) => new Date(r).valueOf() - new Date(n).valueOf()).shift() || O(), h = (e) => {
|
|
42
51
|
const {
|
|
43
52
|
name: t,
|
|
44
53
|
implementation: { name: n, tenant: r }
|
|
@@ -63,11 +72,19 @@ const V = (e, t, n, r = {}) => I(e, n).then((s) => (process.env.NODE_ENV !== "pr
|
|
|
63
72
|
};
|
|
64
73
|
}, x = (e, t) => {
|
|
65
74
|
const n = P(e), r = b(n, t), [s, o, i] = h(e), { tenant: c, implementation: a, widget: u } = r, m = W(t), v = O({ days: -1 });
|
|
66
|
-
A(
|
|
75
|
+
A(
|
|
76
|
+
s,
|
|
77
|
+
c,
|
|
78
|
+
p(c) ? m : v
|
|
79
|
+
), A(
|
|
67
80
|
o,
|
|
68
81
|
a,
|
|
69
82
|
p(a) ? m : v
|
|
70
|
-
), A(
|
|
83
|
+
), A(
|
|
84
|
+
i,
|
|
85
|
+
u,
|
|
86
|
+
p(u) ? m : v
|
|
87
|
+
);
|
|
71
88
|
}, S = (e, t) => {
|
|
72
89
|
const [n, r, s] = h(e), o = t.getItem(n) || "{}", i = t.getItem(r) || "{}", c = t.getItem(s) || "{}";
|
|
73
90
|
return {
|
|
@@ -77,8 +94,15 @@ const V = (e, t, n, r = {}) => I(e, n).then((s) => (process.env.NODE_ENV !== "pr
|
|
|
77
94
|
};
|
|
78
95
|
}, J = (e, t, n) => {
|
|
79
96
|
const r = S(e, t), s = b(r, n), [o, i, c] = h(e), { tenant: a, implementation: u, widget: m } = s;
|
|
80
|
-
p(a) ? t.setItem(o, JSON.stringify(a)) : t.removeItem(o), p(u) ? t.setItem(
|
|
81
|
-
|
|
97
|
+
p(a) ? t.setItem(o, JSON.stringify(a)) : t.removeItem(o), p(u) ? t.setItem(
|
|
98
|
+
i,
|
|
99
|
+
JSON.stringify(u)
|
|
100
|
+
) : t.removeItem(i), p(m) ? t.setItem(c, JSON.stringify(m)) : t.removeItem(c);
|
|
101
|
+
}, j = () => ({
|
|
102
|
+
tenant: {},
|
|
103
|
+
implementation: {},
|
|
104
|
+
widget: {}
|
|
105
|
+
}), M = (e) => e ? !!e && /* @__PURE__ */ new Date() > new Date(e) : !1, w = (e, t) => {
|
|
82
106
|
const n = e.widget[t] || e.implementation[t] || e.tenant[t];
|
|
83
107
|
return n == null ? void 0 : n.value;
|
|
84
108
|
}, D = (e, t, n) => n ? {
|
|
@@ -96,7 +120,11 @@ const V = (e, t, n, r = {}) => I(e, n).then((s) => (process.env.NODE_ENV !== "pr
|
|
|
96
120
|
(M(c) || U(t, a)) && (s[o] = D(void 0, a, c));
|
|
97
121
|
});
|
|
98
122
|
}), n;
|
|
99
|
-
}, I = (e, t) => L(
|
|
123
|
+
}, I = (e, t) => L(
|
|
124
|
+
e,
|
|
125
|
+
"storagePolicy",
|
|
126
|
+
l.Cookie
|
|
127
|
+
).then(
|
|
100
128
|
(n = [d.Necessary]) => !!t && n.indexOf(t) === -1
|
|
101
129
|
), U = (e = [d.Necessary], t) => !!t && e.indexOf(t) === -1, K = (e) => {
|
|
102
130
|
const t = P(e), n = S(e, window.localStorage), r = S(e, sessionStorage), s = w(t, "storagePolicy"), [o, i, c] = [
|
|
@@ -125,7 +153,9 @@ class C {
|
|
|
125
153
|
}
|
|
126
154
|
async setItem(t, n, r = {}) {
|
|
127
155
|
return y(this)(() => {
|
|
128
|
-
const s = f(this.memory, [
|
|
156
|
+
const s = f(this.memory, [
|
|
157
|
+
d.Necessary
|
|
158
|
+
]), { scope: o = N.Tenant, expiration: i } = r;
|
|
129
159
|
s[o][t] = D(
|
|
130
160
|
n,
|
|
131
161
|
d.Necessary,
|
|
@@ -141,7 +171,9 @@ class C {
|
|
|
141
171
|
}
|
|
142
172
|
async getItem(t) {
|
|
143
173
|
return y(this)(() => {
|
|
144
|
-
const n = f(this.memory, [
|
|
174
|
+
const n = f(this.memory, [
|
|
175
|
+
d.Necessary
|
|
176
|
+
]);
|
|
145
177
|
process.env.NODE_ENV !== "production" && g.warn(
|
|
146
178
|
`StorageProvider: StorageProvider is deprecated, use createStorageWriter and readStorage instead, value fetched from legacy memory storage.
|
|
147
179
|
Key: ${t}
|
|
@@ -153,7 +185,9 @@ class C {
|
|
|
153
185
|
}
|
|
154
186
|
async removeItem(t) {
|
|
155
187
|
return y(this)(() => {
|
|
156
|
-
const n = f(this.memory, [
|
|
188
|
+
const n = f(this.memory, [
|
|
189
|
+
d.Necessary
|
|
190
|
+
]);
|
|
157
191
|
delete n.tenant[t], delete n.implementation[t], delete n.widget[t], this.memory = n, process.env.NODE_ENV !== "production" && g.warn(
|
|
158
192
|
`StorageProvider: StorageProvider is deprecated, use createStorageWriter and readStorage instead, value removed from memory.
|
|
159
193
|
Key: ${t}
|
|
@@ -171,48 +205,51 @@ class H {
|
|
|
171
205
|
}
|
|
172
206
|
}
|
|
173
207
|
const Q = T((e) => {
|
|
174
|
-
e.createCommand(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (Array.isArray(r) && !r.every(
|
|
185
|
-
(o) => typeof o == "number" || typeof o == "string"
|
|
186
|
-
)) {
|
|
187
|
-
process.env.NODE_ENV !== "production" && g.warn(
|
|
188
|
-
`storagePolicyConfigurationApi: passed consent is not valid. Consent either has to be a number, a string, an array of strings or an array of numbers.
|
|
208
|
+
e.createCommand(
|
|
209
|
+
"storage",
|
|
210
|
+
(t) => (n = {}) => {
|
|
211
|
+
const { consent: r } = n;
|
|
212
|
+
if (typeof r < "u") {
|
|
213
|
+
if (typeof r != "number" && typeof r != "string" && !Array.isArray(r)) {
|
|
214
|
+
process.env.NODE_ENV !== "production" && g.warn(
|
|
215
|
+
`storagePolicyConfigurationApi: passed consent is not valid. Consent either has to be a number, a string, an array of strings or an array of numbers.
|
|
189
216
|
Passed consent: ${JSON.stringify(r)}`
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
].filter((o, i, c) => typeof r == "number" ? r > i : typeof r == "string" ? c.indexOf(r) + 1 > i : Array.isArray(r) ? r.findIndex((a) => a === i + 1 || a === o) > -1 : !0);
|
|
199
|
-
return s.indexOf(d.Necessary) === -1 && (process.env.NODE_ENV !== "production" && g.warn(
|
|
200
|
-
`storagePolicyConfigurationApi: passed consent does not include category: '${d.Necessary}'. Consent has to atleast include the '${d.Necessary}' category.
|
|
217
|
+
);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (Array.isArray(r) && !r.every(
|
|
221
|
+
(o) => typeof o == "number" || typeof o == "string"
|
|
222
|
+
)) {
|
|
223
|
+
process.env.NODE_ENV !== "production" && g.warn(
|
|
224
|
+
`storagePolicyConfigurationApi: passed consent is not valid. Consent either has to be a number, a string, an array of strings or an array of numbers.
|
|
201
225
|
Passed consent: ${JSON.stringify(r)}`
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
"storagePolicy",
|
|
205
|
-
d.Necessary,
|
|
206
|
-
{
|
|
207
|
-
medium: l.Cookie,
|
|
208
|
-
scope: N.Tenant,
|
|
209
|
-
duration: { days: 365 }
|
|
226
|
+
);
|
|
227
|
+
return;
|
|
210
228
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
229
|
+
const s = [
|
|
230
|
+
d.Necessary,
|
|
231
|
+
d.Functional,
|
|
232
|
+
d.Analytical,
|
|
233
|
+
d.Marketing
|
|
234
|
+
].filter((o, i, c) => typeof r == "number" ? r > i : typeof r == "string" ? c.indexOf(r) + 1 > i : Array.isArray(r) ? r.findIndex((a) => a === i + 1 || a === o) > -1 : !0);
|
|
235
|
+
return s.indexOf(d.Necessary) === -1 && (process.env.NODE_ENV !== "production" && g.warn(
|
|
236
|
+
`storagePolicyConfigurationApi: passed consent does not include category: '${d.Necessary}'. Consent has to atleast include the '${d.Necessary}' category.
|
|
237
|
+
Passed consent: ${JSON.stringify(r)}`
|
|
238
|
+
), s.unshift(d.Necessary)), V(
|
|
239
|
+
t.container,
|
|
240
|
+
"storagePolicy",
|
|
241
|
+
d.Necessary,
|
|
242
|
+
{
|
|
243
|
+
medium: l.Cookie,
|
|
244
|
+
scope: N.Tenant,
|
|
245
|
+
duration: { days: 365 }
|
|
246
|
+
}
|
|
247
|
+
).then((o) => o(s)).then(() => {
|
|
248
|
+
K(t.container), t.events.dispatch("storage:policy-changed", s);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
214
251
|
}
|
|
215
|
-
|
|
252
|
+
);
|
|
216
253
|
});
|
|
217
254
|
export {
|
|
218
255
|
d as StorageCategory,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/widget-services",
|
|
3
|
-
"version": "1.1.2-rc.
|
|
3
|
+
"version": "1.1.2-rc.11",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@telia-ace/widget-utilities": "^1.1.2-rc.
|
|
5
|
+
"@telia-ace/widget-utilities": "^1.1.2-rc.11",
|
|
6
6
|
"@webprovisions/platform": "^1.1.4"
|
|
7
7
|
},
|
|
8
8
|
"main": "./index.js",
|
package/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as LegacyStorageProvider, LegacyStorage } from './legacy-storage-provider';
|
|
1
|
+
export { default as LegacyStorageProvider, LegacyStorage, } from './legacy-storage-provider';
|
|
2
2
|
export { createStorageWriter, readStorage } from './storage';
|
|
3
3
|
export { default as storagePolicyConfigurationApi } from './storage-policy-configuration-api';
|
|
4
4
|
export { StorageCategory, StorageMedium, StorageScope } from './types';
|