@getsoren/shared-module 2.53.0 → 2.55.0
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/dist/events/catalog/clientEvents.d.ts +245 -0
- package/dist/events/catalog/supplierEvents.d.ts +3 -0
- package/dist/events/constants.d.ts +16 -0
- package/dist/events/hooks/useEventDeclaration/useEventDeclaration.d.ts +40 -0
- package/dist/events/hooks/useEventDeclaration/useEventDeclaration.test.d.ts +1 -0
- package/dist/events/index.d.ts +19 -0
- package/dist/events/locales/ar.d.ts +3 -0
- package/dist/events/locales/de.d.ts +3 -0
- package/dist/events/locales/en.d.ts +3 -0
- package/dist/events/locales/es.d.ts +3 -0
- package/dist/events/locales/fr.d.ts +166 -0
- package/dist/events/locales/it.d.ts +3 -0
- package/dist/events/locales/locales.d.ts +3 -0
- package/dist/events/locales/pt.d.ts +3 -0
- package/dist/events/tenants/bouygues/bouygues.d.ts +3 -0
- package/dist/events/tenants/index.d.ts +11 -0
- package/dist/events/tenants/tenants.test.d.ts +1 -0
- package/dist/events/types.d.ts +164 -0
- package/dist/events/utils/amounts/amounts.d.ts +18 -0
- package/dist/events/utils/payload/payload.d.ts +27 -0
- package/dist/events/utils/payload/payload.test.d.ts +1 -0
- package/dist/events/utils/readEvent/readEvent.d.ts +18 -0
- package/dist/events/utils/readEvent/readEvent.test.d.ts +1 -0
- package/dist/events/utils/steps/steps.d.ts +14 -0
- package/dist/events/utils/steps/steps.test.d.ts +1 -0
- package/dist/events.js +1936 -0
- package/dist/hooks/useCurrentLanguage/useCurrentLanguage.d.ts +1 -1
- package/dist/main.d.ts +4 -0
- package/dist/main.js +190 -146
- package/dist/utils/getCurrentLanguage/getCurrentLanguage.d.ts +10 -0
- package/dist/utils/getCurrentLanguage/getCurrentLanguage.test.d.ts +1 -0
- package/dist/utils/pageDuration/pageDuration.d.ts +30 -0
- package/dist/utils/pageDuration/pageDuration.test.d.ts +1 -0
- package/dist/utils/token/token.d.ts +23 -0
- package/dist/utils/token/token.test.d.ts +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type LocaleType = "short" | "full";
|
|
2
|
+
/**
|
|
3
|
+
* The language in the form asked: `short` keeps the language alone ("fr" from "fr-FR"), `full` keeps
|
|
4
|
+
* the regional tag. Falls back on the browser's language when none is given. Usable outside React
|
|
5
|
+
* (API payloads, Treege labels — which are keyed by short codes); components use `useCurrentLanguage`.
|
|
6
|
+
* @param language - A BCP 47 tag, usually `i18next.language`
|
|
7
|
+
* @param type - "short" for "fr", "full" for "fr-FR"
|
|
8
|
+
*/
|
|
9
|
+
declare const getCurrentLanguage: (language?: string | null, type?: LocaleType) => string;
|
|
10
|
+
export default getCurrentLanguage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time spent on a page, reported to Amplitude as "Page Left" when the user leaves it (route change,
|
|
3
|
+
* tab closed, tab sent to the background). Only the time the tab is visible counts: a page left open
|
|
4
|
+
* behind another window is not a visit. The value is capped so that one forgotten tab does not
|
|
5
|
+
* dominate an average, and very short stays (redirects) are not reported at all.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PAGE_LEFT_EVENT = "Page Left";
|
|
8
|
+
/** Beyond 30 minutes on a page, nobody is reading: the visit is capped there. */
|
|
9
|
+
export declare const PAGE_DURATION_CAP_MS: number;
|
|
10
|
+
/** Under a second, the page was a redirect, not a visit. */
|
|
11
|
+
export declare const PAGE_DURATION_MIN_MS = 1000;
|
|
12
|
+
export interface VisibleStopwatch {
|
|
13
|
+
/** The tab went to the background: stop counting. */
|
|
14
|
+
pause(at: number): void;
|
|
15
|
+
/** The tab is visible again: count again. */
|
|
16
|
+
resume(at: number): void;
|
|
17
|
+
/** The page is left: the visible time in ms, capped. Further calls change nothing. */
|
|
18
|
+
stop(at: number): number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A stopwatch that only counts while the tab is visible.
|
|
22
|
+
* @param startedAt - Timestamp of the arrival on the page (ms)
|
|
23
|
+
* @param visible - Whether the tab is visible at that moment
|
|
24
|
+
*/
|
|
25
|
+
export declare const createVisibleStopwatch: (startedAt: number, visible?: boolean) => VisibleStopwatch;
|
|
26
|
+
/** The event properties for a visit, or `null` when the stay was too short to be a visit. */
|
|
27
|
+
export declare const pageLeftProperties: (pathname: string, durationMs: number) => {
|
|
28
|
+
duration_ms: number;
|
|
29
|
+
page_path: string;
|
|
30
|
+
} | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** What the API puts in an access token. */
|
|
2
|
+
export interface PayloadToken {
|
|
3
|
+
exp: number;
|
|
4
|
+
sub: string;
|
|
5
|
+
entity_id: number;
|
|
6
|
+
scope: string[];
|
|
7
|
+
sassClient: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Payload {
|
|
10
|
+
[key: string]: string | number | Record<string, unknown> | string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The payload of an access token, or null when the token is missing, malformed, or not one of ours.
|
|
14
|
+
* The signature is not checked: this reads a token the API issued, it does not trust it.
|
|
15
|
+
* @param accessToken - A JWT
|
|
16
|
+
*/
|
|
17
|
+
export declare const decodeToken: (accessToken?: string) => PayloadToken | null;
|
|
18
|
+
/**
|
|
19
|
+
* A JWT (HS256) carrying the payload, signed with the secret key.
|
|
20
|
+
* @param payload - What the token carries
|
|
21
|
+
* @param secretKey - The HMAC SHA-256 key
|
|
22
|
+
*/
|
|
23
|
+
export declare const encodeToken: (payload: Payload, secretKey: string) => Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getsoren/shared-module",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.55.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"types": "./dist/main.d.ts",
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"import": "./dist/main.js",
|
|
15
15
|
"default": "./dist/main.js"
|
|
16
16
|
},
|
|
17
|
+
"./events": {
|
|
18
|
+
"types": "./dist/events/index.d.ts",
|
|
19
|
+
"import": "./dist/events.js",
|
|
20
|
+
"default": "./dist/events.js"
|
|
21
|
+
},
|
|
17
22
|
"./orval": {
|
|
18
23
|
"types": "./dist/orval/index.d.ts",
|
|
19
24
|
"import": "./dist/orval.js",
|