@amedia/user 0.13.26 → 0.13.28
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/amedia-user-js.iml +9 -0
- package/checkVersion.js +12 -0
- package/dist/cache/engines/indexeddb.d.ts +7 -0
- package/dist/clients/europa.d.ts +3 -7
- package/dist/index.d.ts +36 -7
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +14 -0
- package/dist/index.js.map +3 -3
- package/dist/janitor/index.spec.d.ts +4 -0
- package/dist/lib/PaywallUnlocker.d.ts +16 -0
- package/dist/lib/PaywallUnlocker.spec.d.ts +4 -0
- package/dist/lib/User.d.ts +21 -0
- package/dist/utils/debouncer.d.ts +26 -0
- package/dist/utils/debouncer.spec.d.ts +1 -0
- package/dist/utils/logValidationError.d.ts +1 -0
- package/eik.json +1 -1
- package/esm/actions/authentication.d.ts +5 -0
- package/esm/actions/authentication.spec.d.ts +4 -0
- package/esm/actions/authorization.d.ts +9 -0
- package/esm/actions/preferences.d.ts +9 -0
- package/esm/actions/preferences.spec.d.ts +1 -0
- package/esm/actions/storage.d.ts +4 -0
- package/esm/actions/userData.d.ts +2 -0
- package/esm/autologin/index.d.ts +1 -0
- package/esm/autologin/thirdPartyCookie.d.ts +3 -0
- package/esm/autologin/thirdPartyCookie.spec.d.ts +1 -0
- package/esm/cache/engines/global.d.ts +21 -0
- package/esm/cache/engines/global.spec.d.ts +1 -0
- package/esm/cache/engines/indexeddb.d.ts +7 -0
- package/esm/cache/index.d.ts +11 -0
- package/esm/cache/index.spec.d.ts +4 -0
- package/esm/cache/types.d.ts +11 -0
- package/esm/clients/europa.d.ts +28 -0
- package/esm/clients/europa.spec.d.ts +1 -0
- package/esm/clients/jupiter.d.ts +30 -0
- package/esm/clients/jupiter.spec.d.ts +1 -0
- package/esm/clients/mercury.d.ts +18 -0
- package/esm/clients/mercury.spec.d.ts +4 -0
- package/esm/clients/nebula.d.ts +2 -0
- package/esm/clients/nebula.spec.d.ts +1 -0
- package/esm/clients/pluto.d.ts +3 -0
- package/esm/clients/pluto.spec.d.ts +1 -0
- package/esm/eventHandlers/activation.d.ts +15 -0
- package/esm/eventHandlers/authentication.d.ts +17 -0
- package/esm/eventHandlers/userAttributes.d.ts +24 -0
- package/esm/exceptions/PaywallError.d.ts +7 -0
- package/esm/index-authentcation.spec.d.ts +4 -0
- package/esm/index-storage.spec.d.ts +4 -0
- package/esm/index-subscription.spec.d.ts +4 -0
- package/esm/index.d.ts +26 -0
- package/esm/janitor/index.d.ts +10 -0
- package/esm/janitor/jobs/accessCookieRefresher.d.ts +1 -0
- package/esm/janitor/jobs/accessCookieRefresher.spec.d.ts +4 -0
- package/esm/lib/PaywallUnlocker.d.ts +16 -0
- package/esm/lib/PaywallUnlocker.spec.d.ts +4 -0
- package/esm/lib/User.d.ts +21 -0
- package/esm/lib/cookie.d.ts +5 -0
- package/esm/lib/rpc.d.ts +6 -0
- package/esm/store/index.d.ts +22 -0
- package/esm/store/index.spec.d.ts +1 -0
- package/esm/types.d.ts +22 -0
- package/esm/user.js +2 -0
- package/esm/user.js.map +1 -0
- package/esm/utils/customEventWrapper.d.ts +17 -0
- package/esm/utils/deepEquals.d.ts +4 -0
- package/esm/utils/getOrUpdate.d.ts +6 -0
- package/esm/utils/getOrUpdate.spec.d.ts +1 -0
- package/esm/utils/location.d.ts +3 -0
- package/esm/utils/log.d.ts +26 -0
- package/esm/utils/queue.d.ts +12 -0
- package/esm/utils/url.d.ts +6 -0
- package/esm/utils/url.spec.d.ts +1 -0
- package/package.json +3 -2
- package/src/clients/europa.spec.ts +8 -13
- package/src/clients/europa.ts +41 -40
- package/src/clients/mercuryLog.ts +3 -1
- package/src/utils/debouncer.spec.ts +257 -0
- package/src/utils/debouncer.ts +123 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
package/checkVersion.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const pkg = require('./package.json');
|
|
2
|
+
const eik = require('./eik.json');
|
|
3
|
+
|
|
4
|
+
const FgRed = '\x1b[31m';
|
|
5
|
+
|
|
6
|
+
if (pkg.version !== eik.version) {
|
|
7
|
+
console.warn(`NPM: ${pkg.version} vs. ${eik.version} :EIK`);
|
|
8
|
+
console.error(
|
|
9
|
+
`${FgRed}NPM and EIK package versions must be identical. Exiting\n`
|
|
10
|
+
);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CacheEntry, Engine } from '../types';
|
|
2
|
+
export declare const get: (key: string) => Promise<CacheEntry>;
|
|
3
|
+
export declare const set: (key: string, data: unknown, expires: number) => Promise<void>;
|
|
4
|
+
export declare const remove: (key: string) => Promise<void>;
|
|
5
|
+
export declare const clear: () => Promise<void>;
|
|
6
|
+
declare const _default: Engine;
|
|
7
|
+
export default _default;
|
package/dist/clients/europa.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const EuropaSchema:
|
|
3
|
-
namespaces: Dictionary<Unknown, string>;
|
|
4
|
-
}, false>;
|
|
1
|
+
import { Unknown, Dictionary } from 'runtypes';
|
|
2
|
+
export declare const EuropaSchema: Dictionary<Unknown, string>;
|
|
5
3
|
export declare const clearLocalCache: () => Promise<void>;
|
|
6
4
|
export declare const updateNamespace: (namespace: string, data: Object) => Promise<void | {}>;
|
|
7
5
|
export declare const getNamespaces: <S extends {
|
|
@@ -17,9 +15,7 @@ export declare const saveNamespace: (namespace: string, data: Object) => Promise
|
|
|
17
15
|
};
|
|
18
16
|
}, string>>;
|
|
19
17
|
export declare const getAllNamespaces: () => Promise<{
|
|
20
|
-
|
|
21
|
-
[x: string]: unknown;
|
|
22
|
-
};
|
|
18
|
+
[x: string]: unknown;
|
|
23
19
|
}>;
|
|
24
20
|
export declare const deleteNamespaceKey: (namespace: string, key: string) => Promise<Pick<{
|
|
25
21
|
[namespace: string]: {
|
package/dist/index.d.ts
CHANGED
|
@@ -159,10 +159,8 @@ declare module '@amedia/user/cache/types' {
|
|
|
159
159
|
|
|
160
160
|
}
|
|
161
161
|
declare module '@amedia/user/clients/europa' {
|
|
162
|
-
import {
|
|
163
|
-
export const EuropaSchema:
|
|
164
|
-
namespaces: Dictionary<Unknown, string>;
|
|
165
|
-
}, false>;
|
|
162
|
+
import { Unknown, Dictionary } from 'runtypes';
|
|
163
|
+
export const EuropaSchema: Dictionary<Unknown, string>;
|
|
166
164
|
export const clearLocalCache: () => Promise<void>;
|
|
167
165
|
export const updateNamespace: (namespace: string, data: Object) => Promise<void | {}>;
|
|
168
166
|
export const getNamespaces: <S extends {
|
|
@@ -178,9 +176,7 @@ declare module '@amedia/user/clients/europa' {
|
|
|
178
176
|
};
|
|
179
177
|
}, string>>;
|
|
180
178
|
export const getAllNamespaces: () => Promise<{
|
|
181
|
-
|
|
182
|
-
[x: string]: unknown;
|
|
183
|
-
};
|
|
179
|
+
[x: string]: unknown;
|
|
184
180
|
}>;
|
|
185
181
|
export const deleteNamespaceKey: (namespace: string, key: string) => Promise<Pick<{
|
|
186
182
|
[namespace: string]: {
|
|
@@ -630,6 +626,39 @@ declare module '@amedia/user/utils/customEventWrapper' {
|
|
|
630
626
|
export const dispatch: <T extends Event>(event: T) => void;
|
|
631
627
|
export {};
|
|
632
628
|
|
|
629
|
+
}
|
|
630
|
+
declare module '@amedia/user/utils/debouncer' {
|
|
631
|
+
/**
|
|
632
|
+
* The Debouncer can be used when we want a clean way to say 'I want to fetch this and that, and once it's done,
|
|
633
|
+
* resolve my promise', but instead of the fetch being performed right away, we want to wait for more users to
|
|
634
|
+
* request other stuff. This will keep us from performing lots of individual fetches to the backend.
|
|
635
|
+
*
|
|
636
|
+
* Our main use case is a standard publication front page where one component on the page requests the euucp namespace
|
|
637
|
+
* from Europa, and then another component requests the privacy_preferences namespace. Instead of the Europa client
|
|
638
|
+
* calling two fetches to the server, one for euucp and another for privacy_preferences, we want the Debouncer to
|
|
639
|
+
* aggregate these calls into one call to the backend, that requests both euucp AND privacy_preferences, so the response
|
|
640
|
+
* to both components will be both namespaces (which the Europa client can filter before it actually reaches the
|
|
641
|
+
* component).
|
|
642
|
+
*/
|
|
643
|
+
class Debouncer<ParamsType, ResultType> {
|
|
644
|
+
private timeoutMs;
|
|
645
|
+
private defaultParams;
|
|
646
|
+
private paramAccumulator;
|
|
647
|
+
private workload;
|
|
648
|
+
private timer;
|
|
649
|
+
private params;
|
|
650
|
+
private queue;
|
|
651
|
+
constructor(timeoutMs: number, defaultParams: ParamsType, paramAccumulator: (previousParams: ParamsType, newParams: ParamsType) => ParamsType, workload: (params: ParamsType) => Promise<ResultType>);
|
|
652
|
+
perform(newParams: ParamsType): Promise<ResultType>;
|
|
653
|
+
static stringListParamsAccumulator(accumulatedParams: string[], newParams: string[]): string[];
|
|
654
|
+
static stringMapParamsAccumulator(previousParams: Record<string, any>, newParams: Record<string, any>): Record<string, any>;
|
|
655
|
+
}
|
|
656
|
+
export default Debouncer;
|
|
657
|
+
|
|
658
|
+
}
|
|
659
|
+
declare module '@amedia/user/utils/debouncer.spec' {
|
|
660
|
+
export {};
|
|
661
|
+
|
|
633
662
|
}
|
|
634
663
|
declare module '@amedia/user/utils/deepEquals' {
|
|
635
664
|
export const deepEquals: (a: unknown, b: unknown) => boolean;
|