@guardian/support-dotcom-components 1.0.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/README.md +15 -0
- package/dist/dotcom/src/index.d.ts +4 -0
- package/dist/dotcom/src/index.d.ts.map +1 -0
- package/dist/dotcom/src/requests.d.ts +19 -0
- package/dist/dotcom/src/requests.d.ts.map +1 -0
- package/dist/dotcom/src/types.d.ts +3 -0
- package/dist/dotcom/src/types.d.ts.map +1 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.js +1 -0
- package/dist/shared/src/lib/history.d.ts +20 -0
- package/dist/shared/src/lib/history.d.ts.map +1 -0
- package/dist/shared/src/lib/viewLog.d.ts +17 -0
- package/dist/shared/src/lib/viewLog.d.ts.map +1 -0
- package/dist/shared/src/types/abTests/shared.d.ts +46 -0
- package/dist/shared/src/types/abTests/shared.d.ts.map +1 -0
- package/dist/shared/src/types/ophan.d.ts +28 -0
- package/dist/shared/src/types/ophan.d.ts.map +1 -0
- package/dist/shared/src/types/targeting/banner.d.ts +21 -0
- package/dist/shared/src/types/targeting/banner.d.ts.map +1 -0
- package/dist/shared/src/types/targeting/epic.d.ts +31 -0
- package/dist/shared/src/types/targeting/epic.d.ts.map +1 -0
- package/dist/shared/src/types/targeting/header.d.ts +16 -0
- package/dist/shared/src/types/targeting/header.d.ts.map +1 -0
- package/dist/shared/src/types/targeting/index.d.ts +5 -0
- package/dist/shared/src/types/targeting/index.d.ts.map +1 -0
- package/dist/shared/src/types/targeting/shared.d.ts +24 -0
- package/dist/shared/src/types/targeting/shared.d.ts.map +1 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## @sdc/dotcom
|
|
2
|
+
|
|
3
|
+
A library for use by dotcom (frontend/DCR). This is for sharing logic and types with dotcom (frontend + dcr).
|
|
4
|
+
|
|
5
|
+
### Publishing
|
|
6
|
+
|
|
7
|
+
From the project root directory:
|
|
8
|
+
|
|
9
|
+
Dry-run - build then check what's going to be published:
|
|
10
|
+
|
|
11
|
+
`yarn dotcom publishDryRun`
|
|
12
|
+
|
|
13
|
+
Build and publish to npm:
|
|
14
|
+
|
|
15
|
+
`yarn dotcom publish`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AACpG,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BannerPayload, EpicPayload, HeaderPayload } from '../../shared/src/types/targeting';
|
|
2
|
+
import { TestTracking } from '../../shared/src/types/abTests/shared';
|
|
3
|
+
export interface ModuleData {
|
|
4
|
+
url: string;
|
|
5
|
+
name: string;
|
|
6
|
+
props: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export interface ModuleDataResponse {
|
|
9
|
+
data?: {
|
|
10
|
+
module: ModuleData;
|
|
11
|
+
meta: TestTracking;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const getEpic: (baseUrl: string, payload: EpicPayload) => Promise<ModuleDataResponse>;
|
|
15
|
+
export declare const getLiveblogEpic: (baseUrl: string, payload: EpicPayload) => Promise<ModuleDataResponse>;
|
|
16
|
+
export declare const getBanner: (baseUrl: string, payload: BannerPayload) => Promise<ModuleDataResponse>;
|
|
17
|
+
export declare const getPuzzlesBanner: (baseUrl: string, payload: BannerPayload) => Promise<ModuleDataResponse>;
|
|
18
|
+
export declare const getHeader: (baseUrl: string, payload: HeaderPayload) => Promise<ModuleDataResponse>;
|
|
19
|
+
//# sourceMappingURL=requests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../src/requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE,MAAM,WAAW,UAAU;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IAC/B,IAAI,CAAC,EAAE;QACH,MAAM,EAAE,UAAU,CAAC;QACnB,IAAI,EAAE,YAAY,CAAC;KACtB,CAAC;CACL;AA4CD,eAAO,MAAM,OAAO,YAAa,MAAM,WAAW,WAAW,KAAG,QAAQ,kBAAkB,CAC/C,CAAC;AAE5C,eAAO,MAAM,eAAe,YACf,MAAM,WACN,WAAW,KACrB,QAAQ,kBAAkB,CAAqD,CAAC;AAEnF,eAAO,MAAM,SAAS,YAAa,MAAM,WAAW,aAAa,KAAG,QAAQ,kBAAkB,CACjD,CAAC;AAE9C,eAAO,MAAM,gBAAgB,YAChB,MAAM,WACN,aAAa,KACvB,QAAQ,kBAAkB,CAA+C,CAAC;AAE7E,eAAO,MAAM,SAAS,YAAa,MAAM,WAAW,aAAa,KAAG,QAAQ,kBAAkB,CACjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EACb,WAAW,EACX,aAAa,EACb,oBAAoB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>e.get("gu.contributions.views")||void 0,t=e=>{const t=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(t-1))/864e5},s=e=>e.get("gu.history.weeklyArticleCount")||void 0,r=new Set(["environment/climate-change","environment/climate-crisis","environment/environment","science/science","politics/politics","us-news/us-politics","australia-news/australian-politics","world/world","world/europe-news","world/russia","books/books","culture/culture","world/coronavirus-outbreak","world/race","inequality/inequality","technology/technology","business/business"]),o=(e,t={})=>(e.forEach(e=>{r.has(e)&&(t[e]=(t[e]??0)+1)}),t),n=(e,s,r)=>{if(!((e,s)=>{const r=t(new Date),o=e.get("gu.history.articleCountsThisWeek");if(o&&o.week===r){const t=o.articles[s]||0;return e.set("gu.history.articleCountsThisWeek",{week:r,articles:{...o.articles,[s]:t+1}}),t>0}return e.set("gu.history.articleCountsThisWeek",{week:r,articles:{[s]:1}}),!1})(e,s)){const s=t(new Date),n=e.get("gu.history.weeklyArticleCount")||[],i=n[0];if(i&&i.week&&i.week===s)i.count+=1,i.tags=o(r,i.tags),e.set("gu.history.weeklyArticleCount",n);else{n.unshift({week:s,count:1,tags:o(r,{})});const t=s-365,i=n.filter(e=>e.week>=t);e.set("gu.history.weeklyArticleCount",i)}}},i=(e,t,s)=>{const r=(e=>{if(URLSearchParams){const t=new URLSearchParams(window.location.search).get("force-"+e);if(t)return t}return null})(e);return fetch(`${t}/${e}${r?"?force="+r:""}`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}).then(t=>{if(!t.ok)throw Error(t.statusText||`Supporter Revenue ${e} | Api call returned HTTP status ${t.status}`);return t}).then(e=>e.json())},c=(e,t)=>i("epic",e,t),u=(e,t)=>i("liveblog-epic",e,t),a=(e,t)=>i("banner",e,t),l=(e,t)=>i("puzzles",e,t),w=(e,t)=>i("header",e,t);export{a as getBanner,c as getEpic,e as getEpicViewLog,w as getHeader,u as getLiveblogEpic,l as getPuzzlesBanner,s as getWeeklyArticleHistory,n as incrementWeeklyArticleCount};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>{const t=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(t-1))/864e5},t=new Set(["environment/climate-change","environment/climate-crisis","environment/environment","science/science","politics/politics","us-news/us-politics","australia-news/australian-politics","world/world","world/europe-news","world/russia","books/books","culture/culture","world/coronavirus-outbreak","world/race","inequality/inequality","technology/technology","business/business"]),r=(e,r={})=>(e.forEach(e=>{t.has(e)&&(r[e]=(r[e]??0)+1)}),r),s=(e,t,r)=>{const s=(e=>{if(URLSearchParams){const t=new URLSearchParams(window.location.search).get("force-"+e);if(t)return t}return null})(e);return fetch(`${t}/${e}${s?"?force="+s:""}`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then(t=>{if(!t.ok)throw Error(t.statusText||`Supporter Revenue ${e} | Api call returned HTTP status ${t.status}`);return t}).then(e=>e.json())};exports.getBanner=(e,t)=>s("banner",e,t),exports.getEpic=(e,t)=>s("epic",e,t),exports.getEpicViewLog=e=>e.get("gu.contributions.views")||void 0,exports.getHeader=(e,t)=>s("header",e,t),exports.getLiveblogEpic=(e,t)=>s("liveblog-epic",e,t),exports.getPuzzlesBanner=(e,t)=>s("puzzles",e,t),exports.getWeeklyArticleHistory=e=>e.get("gu.history.weeklyArticleCount")||void 0,exports.incrementWeeklyArticleCount=(t,s,o)=>{if(!((t,r)=>{const s=e(new Date),o=t.get("gu.history.articleCountsThisWeek");if(o&&o.week===s){const e=o.articles[r]||0;return t.set("gu.history.articleCountsThisWeek",{week:s,articles:{...o.articles,[r]:e+1}}),e>0}return t.set("gu.history.articleCountsThisWeek",{week:s,articles:{[r]:1}}),!1})(t,s)){const s=e(new Date),i=t.get("gu.history.weeklyArticleCount")||[],n=i[0];if(n&&n.week&&n.week===s)n.count+=1,n.tags=r(o,n.tags),t.set("gu.history.weeklyArticleCount",i);else{i.unshift({week:s,count:1,tags:r(o,{})});const e=s-365,n=i.filter(t=>t.week>=e);t.set("gu.history.weeklyArticleCount",n)}}};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LocalStorage, WeeklyArticleHistory } from '../types/targeting';
|
|
2
|
+
export interface ArticleCountsThisWeek {
|
|
3
|
+
week: number;
|
|
4
|
+
articles: {
|
|
5
|
+
[pageId: string]: number;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare const getMondayFromDate: (date: Date) => number;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the weekly article history object
|
|
11
|
+
*/
|
|
12
|
+
export declare const getWeeklyArticleHistory: (localStorage: LocalStorage) => WeeklyArticleHistory | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Increment the weekly article counter
|
|
15
|
+
* Checks whether an object already exists for the current week
|
|
16
|
+
* If so, increment the value; otherwise, create new object and set counter to 1.
|
|
17
|
+
* Also uses the `articleCountsThisWeek` item to deduplicate urls in the current week.
|
|
18
|
+
*/
|
|
19
|
+
export declare const incrementWeeklyArticleCount: (localStorage: LocalStorage, pageId: string, tagIds: string[]) => void;
|
|
20
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../../../shared/src/lib/history.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EAEZ,oBAAoB,EAEvB,MAAM,oBAAoB,CAAC;AAK5B,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE;QACN,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;KAC5B,CAAC;CACL;AAGD,eAAO,MAAM,iBAAiB,SAAU,IAAI,KAAG,MAI9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,iBAClB,YAAY,KAC3B,oBAAoB,GAAG,SAEzB,CAAC;AAiEF;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,iBACtB,YAAY,UAClB,MAAM,UACN,MAAM,EAAE,KACjB,IAgCF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LocalStorage } from '../types/targeting/shared';
|
|
2
|
+
interface EpicView {
|
|
3
|
+
date: number;
|
|
4
|
+
testId: string;
|
|
5
|
+
}
|
|
6
|
+
export declare type EpicViewLog = EpicView[];
|
|
7
|
+
/**
|
|
8
|
+
* Return the entire viewLog.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getEpicViewLog: (localStorage: LocalStorage) => EpicViewLog | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Add a new entry to the viewLog.
|
|
13
|
+
* The number of entries is limited to the number in maxLogEntries.
|
|
14
|
+
*/
|
|
15
|
+
export declare const logEpicView: (testId: string) => void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=viewLog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewLog.d.ts","sourceRoot":"","sources":["../../../../../shared/src/lib/viewLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAUzD,UAAU,QAAQ;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AACD,oBAAY,WAAW,GAAG,QAAQ,EAAE,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,cAAc,iBAAkB,YAAY,KAAG,WAAW,GAAG,SAKzE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,WAAY,MAAM,KAAG,IAc5C,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { OphanComponentType, OphanProduct } from '../ophan';
|
|
2
|
+
export interface Variant {
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Test<V extends Variant> {
|
|
6
|
+
name: string;
|
|
7
|
+
variants: V[];
|
|
8
|
+
controlProportionSettings?: ControlProportionSettings;
|
|
9
|
+
audienceOffset?: number;
|
|
10
|
+
audience?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ControlProportionSettings {
|
|
13
|
+
proportion: number;
|
|
14
|
+
offset: number;
|
|
15
|
+
}
|
|
16
|
+
export declare type UserCohort = 'AllExistingSupporters' | 'AllNonSupporters' | 'Everyone' | 'PostAskPauseSingleContributors';
|
|
17
|
+
export interface ArticlesViewedSettings {
|
|
18
|
+
minViews: number;
|
|
19
|
+
maxViews?: number;
|
|
20
|
+
periodInWeeks: number;
|
|
21
|
+
}
|
|
22
|
+
export interface ArticlesViewedByTagSettings {
|
|
23
|
+
tagId: string;
|
|
24
|
+
minViews: number;
|
|
25
|
+
periodInWeeks: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Targeting tests are for experimenting with targeting rules.
|
|
29
|
+
* It is not a message test and should not affect what the user sees once they're in a test.
|
|
30
|
+
* But we do need to carry the test/variant names through in the tracking.
|
|
31
|
+
*/
|
|
32
|
+
export interface TargetingAbTest {
|
|
33
|
+
testName: string;
|
|
34
|
+
variantName: string;
|
|
35
|
+
}
|
|
36
|
+
export declare type TestTracking = {
|
|
37
|
+
abTestName: string;
|
|
38
|
+
abTestVariant: string;
|
|
39
|
+
campaignCode: string;
|
|
40
|
+
campaignId?: string;
|
|
41
|
+
componentType: OphanComponentType;
|
|
42
|
+
products?: OphanProduct[];
|
|
43
|
+
labels?: string[];
|
|
44
|
+
targetingAbTest?: TargetingAbTest;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/types/abTests/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE5D,MAAM,WAAW,OAAO;IACpB,IAAI,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,IAAI,CAAC,CAAC,SAAS,OAAO;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,yBAAyB,CAAC,EAAE,yBAAyB,CAAC;IACtD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,yBAAyB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,oBAAY,UAAU,GAChB,uBAAuB,GACvB,kBAAkB,GAClB,UAAU,GACV,gCAAgC,CAAC;AAEvC,MAAM,WAAW,sBAAsB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,2BAA2B;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,oBAAY,YAAY,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,CAAC,EAAE,eAAe,CAAC;CACrC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Note - zod validators for these ophan types are in /props/shared.ts
|
|
3
|
+
* This is to avoid including zod in the dotcom library
|
|
4
|
+
*/
|
|
5
|
+
export declare type OphanProduct = 'CONTRIBUTION' | 'MEMBERSHIP_SUPPORTER' | 'DIGITAL_SUBSCRIPTION' | 'PRINT_SUBSCRIPTION';
|
|
6
|
+
export declare type OphanAction = 'CLICK' | 'VIEW' | 'INSERT';
|
|
7
|
+
export declare type OphanComponentType = 'ACQUISITIONS_EPIC' | 'ACQUISITIONS_ENGAGEMENT_BANNER' | 'ACQUISITIONS_SUBSCRIPTIONS_BANNER' | 'ACQUISITIONS_HEADER' | 'ACQUISITIONS_OTHER';
|
|
8
|
+
export declare type OphanComponent = {
|
|
9
|
+
componentType: OphanComponentType;
|
|
10
|
+
id?: string;
|
|
11
|
+
products?: OphanProduct[];
|
|
12
|
+
campaignCode?: string;
|
|
13
|
+
labels?: string[];
|
|
14
|
+
};
|
|
15
|
+
interface OphanAbTest {
|
|
16
|
+
name: string;
|
|
17
|
+
variant: string;
|
|
18
|
+
}
|
|
19
|
+
export declare type OphanComponentEvent = {
|
|
20
|
+
component: OphanComponent;
|
|
21
|
+
action: OphanAction;
|
|
22
|
+
value?: string;
|
|
23
|
+
id?: string;
|
|
24
|
+
abTest?: OphanAbTest;
|
|
25
|
+
targetingAbTest?: OphanAbTest;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=ophan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ophan.d.ts","sourceRoot":"","sources":["../../../../../shared/src/types/ophan.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,YAAY,GAClB,cAAc,GACd,sBAAsB,GACtB,sBAAsB,GACtB,oBAAoB,CAAC;AAE3B,oBAAY,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtD,oBAAY,kBAAkB,GACxB,mBAAmB,GACnB,gCAAgC,GAChC,mCAAmC,GACnC,qBAAqB,GACrB,oBAAoB,CAAC;AAE3B,oBAAY,cAAc,GAAG;IACzB,aAAa,EAAE,kBAAkB,CAAC;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,UAAU,WAAW;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,oBAAY,mBAAmB,GAAG;IAC9B,SAAS,EAAE,cAAc,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,eAAe,CAAC,EAAE,WAAW,CAAC;CACjC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PageTracking, WeeklyArticleHistory } from './shared';
|
|
2
|
+
export declare type BannerTargeting = {
|
|
3
|
+
alreadyVisitedCount: number;
|
|
4
|
+
shouldHideReaderRevenue?: boolean;
|
|
5
|
+
isPaidContent?: boolean;
|
|
6
|
+
showSupportMessaging: boolean;
|
|
7
|
+
engagementBannerLastClosedAt?: string;
|
|
8
|
+
subscriptionBannerLastClosedAt?: string;
|
|
9
|
+
mvtId: number;
|
|
10
|
+
countryCode: string;
|
|
11
|
+
weeklyArticleHistory?: WeeklyArticleHistory;
|
|
12
|
+
hasOptedOutOfArticleCount: boolean;
|
|
13
|
+
modulesVersion?: string;
|
|
14
|
+
sectionId?: string;
|
|
15
|
+
tagIds?: string[];
|
|
16
|
+
};
|
|
17
|
+
export declare type BannerPayload = {
|
|
18
|
+
tracking: PageTracking;
|
|
19
|
+
targeting: BannerTargeting;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=banner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/types/targeting/banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE9D,oBAAY,eAAe,GAAG;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,yBAAyB,EAAE,OAAO,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,oBAAY,aAAa,GAAG;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,eAAe,CAAC;CAC9B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { EpicViewLog } from '../../lib/viewLog';
|
|
2
|
+
import { PageTracking, WeeklyArticleHistory } from './shared';
|
|
3
|
+
export declare type Tag = {
|
|
4
|
+
id: string;
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
export declare type EpicTargeting = {
|
|
8
|
+
contentType: string;
|
|
9
|
+
sectionName?: string;
|
|
10
|
+
sectionId?: string;
|
|
11
|
+
shouldHideReaderRevenue: boolean;
|
|
12
|
+
isMinuteArticle: boolean;
|
|
13
|
+
isPaidContent: boolean;
|
|
14
|
+
tags: Tag[];
|
|
15
|
+
mvtId?: number;
|
|
16
|
+
epicViewLog?: EpicViewLog;
|
|
17
|
+
countryCode?: string;
|
|
18
|
+
weeklyArticleHistory?: WeeklyArticleHistory;
|
|
19
|
+
hasOptedOutOfArticleCount: boolean;
|
|
20
|
+
showSupportMessaging: boolean;
|
|
21
|
+
isRecurringContributor: boolean;
|
|
22
|
+
lastOneOffContributionDate?: number;
|
|
23
|
+
modulesVersion?: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
browserId?: string;
|
|
26
|
+
};
|
|
27
|
+
export declare type EpicPayload = {
|
|
28
|
+
tracking: PageTracking;
|
|
29
|
+
targeting: EpicTargeting;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=epic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epic.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/types/targeting/epic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE9D,oBAAY,GAAG,GAAG;IACd,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,aAAa,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uBAAuB,EAAE,OAAO,CAAC;IAEjC,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IAEvB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,yBAAyB,EAAE,OAAO,CAAC;IACnC,oBAAoB,EAAE,OAAO,CAAC;IAC9B,sBAAsB,EAAE,OAAO,CAAC;IAChC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,oBAAY,WAAW,GAAG;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,aAAa,CAAC;CAC5B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PageTracking } from './shared';
|
|
2
|
+
export declare type Edition = 'UK' | 'US' | 'AU' | 'INT';
|
|
3
|
+
export interface HeaderTargeting {
|
|
4
|
+
showSupportMessaging: boolean;
|
|
5
|
+
edition: Edition;
|
|
6
|
+
countryCode: string;
|
|
7
|
+
modulesVersion?: string;
|
|
8
|
+
mvtId: number;
|
|
9
|
+
lastOneOffContributionDate?: string;
|
|
10
|
+
numArticles?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare type HeaderPayload = {
|
|
13
|
+
tracking: PageTracking;
|
|
14
|
+
targeting: HeaderTargeting;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/types/targeting/header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,oBAAY,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC5B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,oBAAY,aAAa,GAAG;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,eAAe,CAAC;CAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/types/targeting/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare type PageTracking = {
|
|
2
|
+
ophanPageId: string;
|
|
3
|
+
platformId: string;
|
|
4
|
+
referrerUrl: string;
|
|
5
|
+
clientName: string;
|
|
6
|
+
};
|
|
7
|
+
export declare type TagCounts = {
|
|
8
|
+
[tag: string]: number;
|
|
9
|
+
};
|
|
10
|
+
export declare type WeeklyArticleLog = {
|
|
11
|
+
week: number;
|
|
12
|
+
count: number;
|
|
13
|
+
tags?: TagCounts;
|
|
14
|
+
};
|
|
15
|
+
export declare type WeeklyArticleHistory = WeeklyArticleLog[];
|
|
16
|
+
/**
|
|
17
|
+
* This interface is duplicated from the @guardian/libs definition of StorageFactory. This is to avoid adding the
|
|
18
|
+
* whole library as a dependency.
|
|
19
|
+
*/
|
|
20
|
+
export interface LocalStorage {
|
|
21
|
+
set(key: string, value: unknown): void;
|
|
22
|
+
get(key: string): any;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../../../shared/src/types/targeting/shared.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,oBAAY,SAAS,GAAG;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,oBAAY,oBAAoB,GAAG,gBAAgB,EAAE,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAEvC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACzB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@guardian/support-dotcom-components",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/dotcom/src/index.d.ts",
|
|
8
|
+
"files": ["dist/**/*"],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"lint": "eslint 'src/**/*.{ts,tsx}'",
|
|
11
|
+
"build": "rollup -c",
|
|
12
|
+
"types": "tsc --project tsconfig.types.json",
|
|
13
|
+
"test": "jest --passWithNoTests",
|
|
14
|
+
"publishDryRun": "yarn build && yarn types && npm publish --dry-run",
|
|
15
|
+
"publish": "yarn build && yarn types && npm publish --access public"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"jest": "^26.6.3",
|
|
19
|
+
"ts-jest": "^26.5.4",
|
|
20
|
+
"ts-loader": "^9.2.5",
|
|
21
|
+
"typescript": "^4.2.4",
|
|
22
|
+
"@babel/core": "7.16.0",
|
|
23
|
+
"@babel/preset-env": "7.16.4",
|
|
24
|
+
"babel-loader": "^8.2.3",
|
|
25
|
+
"rollup": "^2.23.0",
|
|
26
|
+
"rollup-plugin-external-globals": "^0.5.0",
|
|
27
|
+
"rollup-plugin-filesize": "^9.0.2",
|
|
28
|
+
"rollup-plugin-peer-deps-external": "^2.2.3",
|
|
29
|
+
"rollup-plugin-terser": "^6.1.0",
|
|
30
|
+
"@rollup/plugin-alias": "^3.1.1",
|
|
31
|
+
"@rollup/plugin-babel": "^5.1.0",
|
|
32
|
+
"@rollup/plugin-commonjs": "^14.0.0",
|
|
33
|
+
"@rollup/plugin-node-resolve": "^8.4.0",
|
|
34
|
+
"@rollup/plugin-replace": "^2.3.3"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
}
|
|
38
|
+
}
|