@guardian/commercial-core 7.1.0 → 27.1.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.
Files changed (173) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +23 -34
  3. package/dist/cjs/ad-sizes.d.ts +150 -8
  4. package/dist/cjs/ad-sizes.js +129 -38
  5. package/dist/cjs/breakpoint.d.ts +8 -0
  6. package/dist/cjs/breakpoint.js +10 -0
  7. package/dist/cjs/constants/index.d.ts +1 -1
  8. package/dist/cjs/constants/index.js +2 -2
  9. package/dist/cjs/detect-ad-blocker.js +1 -2
  10. package/dist/cjs/event-timer.d.ts +60 -48
  11. package/dist/cjs/event-timer.js +149 -115
  12. package/dist/cjs/geo/country-code.d.ts +3 -0
  13. package/dist/cjs/geo/country-code.js +34 -0
  14. package/dist/cjs/geo/geo-utils.d.ts +11 -0
  15. package/dist/cjs/geo/geo-utils.js +31 -0
  16. package/dist/cjs/global.d.ts +58 -10
  17. package/dist/cjs/index.d.ts +9 -39
  18. package/dist/cjs/index.js +12 -67
  19. package/dist/cjs/send-commercial-metrics.d.ts +8 -2
  20. package/dist/cjs/send-commercial-metrics.js +51 -27
  21. package/dist/cjs/targeting/build-page-targeting.d.ts +4 -5
  22. package/dist/cjs/targeting/build-page-targeting.js +35 -7
  23. package/dist/cjs/targeting/content.d.ts +1 -1
  24. package/dist/cjs/targeting/content.js +1 -1
  25. package/dist/cjs/targeting/personalised.d.ts +2 -3
  26. package/dist/cjs/targeting/personalised.js +3 -3
  27. package/dist/cjs/targeting/pick-targeting-values.d.ts +1 -1
  28. package/dist/cjs/targeting/session.d.ts +2 -2
  29. package/dist/cjs/targeting/shared.d.ts +31 -20
  30. package/dist/cjs/targeting/shared.js +0 -30
  31. package/dist/cjs/targeting/teads-eligibility.d.ts +2 -0
  32. package/dist/cjs/targeting/teads-eligibility.js +20 -0
  33. package/dist/cjs/targeting/types.d.ts +6 -0
  34. package/dist/cjs/targeting/types.js +2 -0
  35. package/dist/cjs/targeting/viewport.d.ts +1 -1
  36. package/dist/cjs/targeting/youtube-ima.d.ts +4 -3
  37. package/dist/cjs/targeting/youtube-ima.js +7 -4
  38. package/dist/cjs/types.d.ts +403 -63
  39. package/dist/cjs/types.js +11 -0
  40. package/dist/esm/ad-sizes.d.ts +150 -8
  41. package/dist/esm/ad-sizes.js +127 -38
  42. package/dist/esm/breakpoint.d.ts +8 -0
  43. package/dist/esm/breakpoint.js +6 -0
  44. package/dist/esm/constants/index.d.ts +1 -1
  45. package/dist/esm/constants/index.js +1 -1
  46. package/dist/esm/event-timer.d.ts +60 -48
  47. package/dist/esm/event-timer.js +147 -115
  48. package/dist/esm/geo/country-code.d.ts +3 -0
  49. package/dist/esm/geo/country-code.js +31 -0
  50. package/dist/esm/geo/geo-utils.d.ts +11 -0
  51. package/dist/esm/geo/geo-utils.js +20 -0
  52. package/dist/esm/global.d.ts +58 -10
  53. package/dist/esm/global.js +0 -1
  54. package/dist/esm/index.d.ts +9 -39
  55. package/dist/esm/index.js +6 -31
  56. package/dist/esm/send-commercial-metrics.d.ts +8 -2
  57. package/dist/esm/send-commercial-metrics.js +48 -25
  58. package/dist/esm/targeting/build-page-targeting.d.ts +4 -5
  59. package/dist/esm/targeting/build-page-targeting.js +35 -7
  60. package/dist/esm/targeting/content.d.ts +1 -1
  61. package/dist/esm/targeting/content.js +1 -1
  62. package/dist/esm/targeting/personalised.d.ts +2 -3
  63. package/dist/esm/targeting/personalised.js +3 -3
  64. package/dist/esm/targeting/pick-targeting-values.d.ts +1 -1
  65. package/dist/esm/targeting/session.d.ts +2 -2
  66. package/dist/esm/targeting/shared.d.ts +31 -20
  67. package/dist/esm/targeting/shared.js +0 -30
  68. package/dist/esm/targeting/teads-eligibility.d.ts +2 -0
  69. package/dist/esm/targeting/teads-eligibility.js +17 -0
  70. package/dist/esm/targeting/types.d.ts +6 -0
  71. package/dist/esm/targeting/types.js +0 -0
  72. package/dist/esm/targeting/viewport.d.ts +1 -1
  73. package/dist/esm/targeting/youtube-ima.d.ts +4 -3
  74. package/dist/esm/targeting/youtube-ima.js +7 -4
  75. package/dist/esm/types.d.ts +403 -63
  76. package/dist/esm/types.js +11 -1
  77. package/package.json +64 -83
  78. package/dist/cjs/__vendor/a9-apstag.d.ts +0 -1
  79. package/dist/cjs/__vendor/a9-apstag.js +0 -34
  80. package/dist/cjs/__vendor/ipsos-mori.d.ts +0 -1
  81. package/dist/cjs/__vendor/ipsos-mori.js +0 -18
  82. package/dist/cjs/__vendor/launchpad.d.ts +0 -1
  83. package/dist/cjs/__vendor/launchpad.js +0 -25
  84. package/dist/cjs/__vendor/pubmatic.d.ts +0 -1
  85. package/dist/cjs/__vendor/pubmatic.js +0 -49
  86. package/dist/cjs/__vendor/twitter-script.d.ts +0 -1
  87. package/dist/cjs/__vendor/twitter-script.js +0 -26
  88. package/dist/cjs/create-ad-slot.d.ts +0 -17
  89. package/dist/cjs/create-ad-slot.js +0 -107
  90. package/dist/cjs/google-analytics.d.ts +0 -1
  91. package/dist/cjs/google-analytics.js +0 -14
  92. package/dist/cjs/lib/ab-localstorage.d.ts +0 -2
  93. package/dist/cjs/lib/ab-localstorage.js +0 -14
  94. package/dist/cjs/lib/breakpoint.d.ts +0 -4
  95. package/dist/cjs/lib/breakpoint.js +0 -5
  96. package/dist/cjs/lib/can-use-dom.d.ts +0 -2
  97. package/dist/cjs/lib/can-use-dom.js +0 -9
  98. package/dist/cjs/lib/construct-query.d.ts +0 -3
  99. package/dist/cjs/lib/construct-query.js +0 -12
  100. package/dist/cjs/messenger.d.ts +0 -97
  101. package/dist/cjs/messenger.js +0 -281
  102. package/dist/cjs/targeting/build-page-targeting-consentless.d.ts +0 -15
  103. package/dist/cjs/targeting/build-page-targeting-consentless.js +0 -46
  104. package/dist/cjs/targeting/youtube.d.ts +0 -13
  105. package/dist/cjs/targeting/youtube.js +0 -64
  106. package/dist/cjs/third-party-tags/ias.d.ts +0 -7
  107. package/dist/cjs/third-party-tags/ias.js +0 -14
  108. package/dist/cjs/third-party-tags/inizio.d.ts +0 -13
  109. package/dist/cjs/third-party-tags/inizio.js +0 -39
  110. package/dist/cjs/third-party-tags/permutive.d.ts +0 -6
  111. package/dist/cjs/third-party-tags/permutive.js +0 -13
  112. package/dist/cjs/third-party-tags/remarketing.d.ts +0 -7
  113. package/dist/cjs/third-party-tags/remarketing.js +0 -22
  114. package/dist/cjs/third-party-tags/twitter-uwt.d.ts +0 -7
  115. package/dist/cjs/third-party-tags/twitter-uwt.js +0 -15
  116. package/dist/cjs/track-gpc-signal.d.ts +0 -7
  117. package/dist/cjs/track-gpc-signal.js +0 -17
  118. package/dist/cjs/track-labs-container.d.ts +0 -7
  119. package/dist/cjs/track-labs-container.js +0 -35
  120. package/dist/cjs/track-scroll-depth.d.ts +0 -8
  121. package/dist/cjs/track-scroll-depth.js +0 -41
  122. package/dist/esm/__vendor/a9-apstag.d.ts +0 -1
  123. package/dist/esm/__vendor/a9-apstag.js +0 -30
  124. package/dist/esm/__vendor/ipsos-mori.d.ts +0 -1
  125. package/dist/esm/__vendor/ipsos-mori.js +0 -14
  126. package/dist/esm/__vendor/launchpad.d.ts +0 -1
  127. package/dist/esm/__vendor/launchpad.js +0 -21
  128. package/dist/esm/__vendor/pubmatic.d.ts +0 -1
  129. package/dist/esm/__vendor/pubmatic.js +0 -45
  130. package/dist/esm/__vendor/twitter-script.d.ts +0 -1
  131. package/dist/esm/__vendor/twitter-script.js +0 -22
  132. package/dist/esm/create-ad-slot.d.ts +0 -17
  133. package/dist/esm/create-ad-slot.js +0 -103
  134. package/dist/esm/google-analytics.d.ts +0 -1
  135. package/dist/esm/google-analytics.js +0 -10
  136. package/dist/esm/lib/ab-localstorage.d.ts +0 -2
  137. package/dist/esm/lib/ab-localstorage.js +0 -10
  138. package/dist/esm/lib/breakpoint.d.ts +0 -4
  139. package/dist/esm/lib/breakpoint.js +0 -2
  140. package/dist/esm/lib/can-use-dom.d.ts +0 -2
  141. package/dist/esm/lib/can-use-dom.js +0 -6
  142. package/dist/esm/lib/construct-query.d.ts +0 -3
  143. package/dist/esm/lib/construct-query.js +0 -9
  144. package/dist/esm/messenger.d.ts +0 -97
  145. package/dist/esm/messenger.js +0 -274
  146. package/dist/esm/targeting/build-page-targeting-consentless.d.ts +0 -15
  147. package/dist/esm/targeting/build-page-targeting-consentless.js +0 -43
  148. package/dist/esm/targeting/youtube.d.ts +0 -13
  149. package/dist/esm/targeting/youtube.js +0 -60
  150. package/dist/esm/third-party-tags/ias.d.ts +0 -7
  151. package/dist/esm/third-party-tags/ias.js +0 -10
  152. package/dist/esm/third-party-tags/inizio.d.ts +0 -13
  153. package/dist/esm/third-party-tags/inizio.js +0 -35
  154. package/dist/esm/third-party-tags/permutive.d.ts +0 -6
  155. package/dist/esm/third-party-tags/permutive.js +0 -9
  156. package/dist/esm/third-party-tags/remarketing.d.ts +0 -7
  157. package/dist/esm/third-party-tags/remarketing.js +0 -18
  158. package/dist/esm/third-party-tags/twitter-uwt.d.ts +0 -7
  159. package/dist/esm/third-party-tags/twitter-uwt.js +0 -11
  160. package/dist/esm/track-gpc-signal.d.ts +0 -7
  161. package/dist/esm/track-gpc-signal.js +0 -14
  162. package/dist/esm/track-labs-container.d.ts +0 -7
  163. package/dist/esm/track-labs-container.js +0 -32
  164. package/dist/esm/track-scroll-depth.d.ts +0 -8
  165. package/dist/esm/track-scroll-depth.js +0 -38
  166. /package/dist/cjs/constants/{adLabelHeight.d.ts → ad-label-height.d.ts} +0 -0
  167. /package/dist/cjs/constants/{adLabelHeight.js → ad-label-height.js} +0 -0
  168. /package/dist/cjs/{lib → geo}/get-locale.d.ts +0 -0
  169. /package/dist/cjs/{lib → geo}/get-locale.js +0 -0
  170. /package/dist/esm/constants/{adLabelHeight.d.ts → ad-label-height.d.ts} +0 -0
  171. /package/dist/esm/constants/{adLabelHeight.js → ad-label-height.js} +0 -0
  172. /package/dist/esm/{lib → geo}/get-locale.d.ts +0 -0
  173. /package/dist/esm/{lib → geo}/get-locale.js +0 -0
@@ -1,87 +1,427 @@
1
- import type { VendorName } from '@guardian/consent-management-platform/dist/types';
2
- export type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
3
- export interface NetworkInformation extends EventTarget {
1
+ import type { AdSize, SizeMapping } from './ad-sizes';
2
+ import type { PageTargeting } from './targeting/build-page-targeting';
3
+ import 'googletag';
4
+ type HeaderBiddingSize = AdSize;
5
+ interface Advert {
6
+ id: string;
7
+ node: HTMLElement;
8
+ prebidAdUnit: string;
9
+ sizes: SizeMapping;
10
+ headerBiddingSizes: HeaderBiddingSize[] | null;
11
+ size: AdSize | 'fluid' | null;
12
+ slot: googletag.Slot;
13
+ isEmpty: boolean | null;
14
+ isRendered: boolean;
15
+ shouldRefresh: boolean;
16
+ whenSlotReady: Promise<void>;
17
+ extraNodeClasses: string[];
18
+ hasPrebidSize: boolean;
19
+ headerBiddingBidRequest: Promise<unknown> | null;
20
+ lineItemId: number | null;
21
+ creativeId: number | null;
22
+ creativeTemplateId: number | null;
23
+ testgroup: string | undefined;
24
+ finishedRendering(isRendered: boolean): void;
25
+ updateExtraSlotClasses(...newClasses: string[]): Promise<void>;
26
+ generateSizeMapping(additionalSizeMapping: SizeMapping): SizeMapping;
27
+ updateSizeMapping(additionalSizeMapping: SizeMapping): void;
28
+ }
29
+ interface DfpEnv {
30
+ renderStartTime: number;
31
+ adSlotSelector: string;
32
+ lazyLoadEnabled: boolean;
33
+ lazyLoadObserve: boolean;
34
+ advertsToLoad: Advert[];
35
+ adverts: Map<Advert['id'], Advert>;
36
+ shouldLazyLoad: () => boolean;
37
+ }
38
+ type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
39
+ interface NetworkInformation extends EventTarget {
4
40
  readonly type?: ConnectionType;
5
41
  readonly downlink?: number;
6
42
  readonly effectiveType?: string;
7
43
  }
8
- export type TagAttribute = {
9
- name: string;
10
- value: string;
44
+ type OphanRecordFunction = (event: Record<string, unknown> & {
45
+ /**
46
+ * the experiences key will override previously set values.
47
+ * Use `recordExperiences` instead.
48
+ */
49
+ experiences?: never;
50
+ }, callback?: () => void) => void;
51
+ /**
52
+ * Generates a type which represents possible indices of this array
53
+ *
54
+ * Example usage:
55
+ * const list = ['foo', 'bar', 'baz'] as const;
56
+ * type Test = Indices<typeof list>
57
+ */
58
+ type Indices<T extends readonly unknown[]> = Exclude<Partial<T>['length'], T['length']>;
59
+ type Edition = 'UK' | 'AU' | 'US';
60
+ type AdsConfigDisabled = {
61
+ disableAds: true;
62
+ };
63
+ type AdsConfigBasic = {
64
+ adTagParameters: {
65
+ iu: string;
66
+ cust_params: string;
67
+ };
68
+ };
69
+ type AdsConfigUSNATorAus = AdsConfigBasic & {
70
+ restrictedDataProcessor: boolean;
11
71
  };
12
- export type ThirdPartyTag = {
13
- async?: boolean;
14
- attrs?: TagAttribute[];
15
- beforeLoad?: () => void;
16
- insertSnippet?: () => void;
17
- loaded?: boolean;
18
- onLoad?: () => void;
19
- shouldRun: boolean;
20
- name?: VendorName;
21
- url?: string;
22
- useImage?: boolean;
72
+ type AdsConfigTCFV2 = AdsConfigBasic & {
73
+ adTagParameters: {
74
+ cmpGdpr: number;
75
+ cmpVcd: string;
76
+ cmpGvcd: string;
77
+ };
78
+ nonPersonalizedAd: boolean;
23
79
  };
24
- export type GetThirdPartyTag = (arg0: {
25
- shouldRun: boolean;
26
- }) => ThirdPartyTag;
27
- export type GuardianAnalyticsConfig = {
28
- trackers: Record<string, string>;
80
+ type AdsConfigEnabled = AdsConfigBasic | AdsConfigUSNATorAus | AdsConfigTCFV2;
81
+ type AdsConfig = AdsConfigEnabled | AdsConfigDisabled;
82
+ type AdTargetingBuilder = () => Promise<AdsConfig>;
83
+ interface Ophan {
84
+ trackComponentAttention: (name: string, el: Element, visiblityThreshold: number) => void;
85
+ record: OphanRecordFunction;
86
+ viewId: string;
87
+ pageViewId: string;
88
+ }
89
+ type PrebidBreakpoint = 'D' | 'T' | 'M';
90
+ type PrebidIndexSite = {
91
+ bp: PrebidBreakpoint;
92
+ id: number;
29
93
  };
30
- export type Edition = 'UK' | 'AU' | 'US';
31
- export type GuardianWindowConfig = {
32
- googleAnalytics?: GuardianAnalyticsConfig;
94
+ interface CommercialPageConfig {
95
+ pbIndexSites: PrebidIndexSite[];
96
+ adUnit: string;
97
+ appNexusPageTargeting?: string;
98
+ sharedAdTargeting?: Record<string, string | string[]>;
99
+ shouldHideAdverts: boolean;
100
+ pageAdTargeting?: PageTargeting;
101
+ dfpAccountId: string;
102
+ ipsosTag?: string;
103
+ a9PublisherId: string;
104
+ libs?: {
105
+ googletag?: string;
106
+ };
107
+ }
108
+ interface PageConfig extends CommercialPageConfig {
109
+ ajaxUrl?: string;
110
+ assetsPath: string;
111
+ author: string;
112
+ authorIds: string;
113
+ blogIds: string;
114
+ commentable: boolean;
115
+ contentType: string;
116
+ dcrCouldRender: boolean;
117
+ edition: Edition;
118
+ frontendAssetsFullURL?: string;
119
+ hasPageSkin: boolean;
120
+ hasShowcaseMainElement: boolean;
121
+ hasYouTubeAtom: boolean;
122
+ headline: string;
123
+ host: string;
124
+ idApiUrl?: string;
125
+ idUrl?: string;
126
+ isbn?: string;
127
+ isDev: boolean;
128
+ isFront: boolean;
129
+ isHosted: boolean;
130
+ isImmersive?: boolean;
131
+ isLiveBlog?: boolean;
132
+ isPaidContent: boolean;
133
+ isPreview: boolean;
134
+ isProd: boolean;
135
+ isSensitive: boolean;
136
+ isMinuteArticle: boolean;
137
+ keywordIds: string;
138
+ keywords: string;
139
+ lightboxImages?: {
140
+ images: Array<{
141
+ src: string;
142
+ }>;
143
+ };
144
+ pageId: string;
145
+ publication: string;
146
+ revisionNumber: string;
147
+ section: string;
148
+ sectionName: string;
149
+ sentryHost: string;
150
+ sentryPublicApiKey: string;
151
+ series: string;
152
+ seriesId: string;
153
+ sharedAdTargeting?: Record<string, string | string[]>;
154
+ shouldHideReaderRevenue?: boolean;
155
+ showNewRecipeDesign?: boolean;
156
+ showRelatedContent?: boolean;
157
+ source: string;
158
+ sponsorshipType: string;
159
+ toneIds: string;
160
+ tones: string;
161
+ videoDuration: number;
162
+ webPublicationDate: number;
163
+ userAttributesApiUrl?: string;
164
+ }
165
+ type Stage = 'DEV' | 'CODE' | 'PROD';
166
+ interface UserConfig {
167
+ accountCreatedDate: number;
168
+ displayName: string;
169
+ emailVerified: boolean;
170
+ id: string;
171
+ rawResponse: string;
172
+ }
173
+ interface Config {
174
+ commercialMetricsInitialised?: boolean;
175
+ frontendAssetsFullURL?: string;
33
176
  isDotcomRendering: boolean;
34
177
  ophan: {
35
178
  browserId?: string;
36
179
  pageViewId: string;
37
180
  };
38
- page: {
39
- dcrCouldRender: boolean;
40
- edition: Edition;
41
- isPreview: boolean;
42
- isSensitive: boolean;
43
- pageId: string;
44
- section: string;
45
- sharedAdTargeting?: Record<string, string | string[]>;
46
- videoDuration: number;
47
- webPublicationDate: number;
48
- };
181
+ page: PageConfig;
182
+ shouldSendCommercialMetrics?: boolean;
183
+ stage: Stage;
184
+ switches: Record<string, boolean | undefined>;
49
185
  tests?: {
50
186
  [key: `${string}Control`]: 'control';
51
187
  [key: `${string}Variant`]: 'variant';
52
188
  };
189
+ user?: UserConfig;
190
+ }
191
+ type AdBlockers = {
192
+ active: boolean | undefined;
193
+ onDetect: Array<(value: boolean | PromiseLike<boolean>) => void>;
53
194
  };
54
- export type GoogleTagParams = unknown;
55
- export type GoogleTrackConversionObject = {
56
- google_conversion_id: number;
57
- google_custom_params: GoogleTagParams;
58
- google_remarketing_only: boolean;
195
+ type TagCounts = Record<string, number>;
196
+ type WeeklyArticleLog = {
197
+ week: number;
198
+ count: number;
199
+ tags?: TagCounts;
59
200
  };
60
- export type MaybeArray<T> = T | T[];
61
- export type CustomParams = Record<string, MaybeArray<string | number | boolean>>;
62
- export type AdsConfigDisabled = {
63
- disableAds: true;
201
+ type WeeklyArticleHistory = WeeklyArticleLog[];
202
+ interface DailyArticleCount {
203
+ day: number;
204
+ count: number;
205
+ }
206
+ type DailyArticleHistory = DailyArticleCount[];
207
+ interface ArticleCounts {
208
+ weeklyArticleHistory: WeeklyArticleHistory;
209
+ dailyArticleHistory: DailyArticleHistory;
210
+ }
211
+ type FetchBidSizes = {
212
+ adSizes: `${number}x${number}`;
64
213
  };
65
- export type AdsConfigBasic = {
66
- adTagParameters: {
67
- iu: string;
68
- cust_params: string;
214
+ type FetchBidResponse = {
215
+ amznbid: string;
216
+ amzniid: string;
217
+ amznp: string;
218
+ amznsz: FetchBidSizes;
219
+ size: FetchBidSizes;
220
+ slotID: string;
221
+ };
222
+ interface HeaderNotification {
223
+ id: string;
224
+ target: string;
225
+ message: string;
226
+ ophanLabel: string;
227
+ logImpression: () => void;
228
+ }
229
+ interface OptOutInitializeOptions {
230
+ publisher: number;
231
+ onlyNoConsent?: 0 | 1;
232
+ alwaysNoConsent?: 0 | 1;
233
+ consentTimeOutMS?: 5000;
234
+ noLogging?: 0 | 1;
235
+ lazyLoading?: {
236
+ fractionInView?: number;
237
+ viewPortMargin?: string;
69
238
  };
239
+ noRequestsOnPageLoad?: 0 | 1;
240
+ frequencyScript?: string;
241
+ timeoutFrequencyCappingMS?: number;
242
+ debug_forceCap?: number;
243
+ }
244
+ interface OptOutResponse {
245
+ adSlot: string;
246
+ width: number;
247
+ height: number;
248
+ ad: string;
249
+ creativeId: string;
250
+ meta: {
251
+ networkId: string;
252
+ networkName: string;
253
+ agencyId: string;
254
+ agencyName: string;
255
+ advertiserId: string;
256
+ advertiserName: string;
257
+ advertiserDomains: string[];
258
+ };
259
+ optOutExt: {
260
+ noSafeFrame: boolean;
261
+ tags: string[];
262
+ };
263
+ }
264
+ type OptOutFilledCallback = (adSlot: OptOutAdSlot, response: OptOutResponse) => void;
265
+ interface OptOutAdSlot {
266
+ adSlot: string;
267
+ targetId: string;
268
+ id: string;
269
+ filledCallback?: OptOutFilledCallback;
270
+ emptyCallback?: (adSlot: OptOutAdSlot) => void;
271
+ adShownCallback?: (adSlot: OptOutAdSlot, response: OptOutResponse) => void;
272
+ }
273
+ interface ImpressionsDfpObject {
274
+ s: string;
275
+ ad: string;
276
+ c: string;
277
+ I: string;
278
+ o: string;
279
+ A: string;
280
+ y: string;
281
+ co: string;
282
+ }
283
+ declare enum BlockingType {
284
+ Manual = 1,// Deprecated
285
+ Creative = 2,// Creative-based detection
286
+ ProviderSecurity = 3,// Domain-based detection for unsafe domains
287
+ BannedDomain = 4,// Domain-based detection for banned domains
288
+ ProviderIbv = 5,// Domain-based detection for in-banner-video
289
+ UnsafeJS = 6,// JavaScript-based detection for unsafe ads
290
+ Hrap = 7
291
+ }
292
+ type ConfiantCallback = (blockingType: BlockingType, blockingId: string, isBlocked: boolean, wrapperId: string, tagId: string, impressionsData?: {
293
+ prebid?: {
294
+ adId?: string | null;
295
+ cpm?: number | null;
296
+ s?: string;
297
+ };
298
+ dfp?: ImpressionsDfpObject;
299
+ }) => void;
300
+ interface Confiant extends Record<string, unknown> {
301
+ settings: {
302
+ callback: ConfiantCallback;
303
+ [key: string]: unknown;
304
+ };
305
+ }
306
+ interface Permutive {
307
+ config?: {
308
+ projectId?: string;
309
+ apiKey?: string;
310
+ environment?: string;
311
+ };
312
+ q?: Array<{
313
+ functionName: string;
314
+ arguments: unknown[];
315
+ }>;
316
+ addon?: (name: string, props: Record<string, unknown>) => void;
317
+ identify?: (user: Array<{
318
+ id: string;
319
+ tag: string;
320
+ }>) => void;
321
+ track?: (name: string, props: Record<string, unknown>) => void;
322
+ }
323
+ type ApstagInitConfig = {
324
+ pubID: string;
325
+ adServer?: string;
326
+ bidTimeout?: number;
327
+ blockedBidders?: string[];
70
328
  };
71
- export type AdsConfigCCPAorAus = AdsConfigBasic & {
72
- restrictedDataProcessor: boolean;
329
+ interface A9AdUnitInterface {
330
+ slotID: string;
331
+ slotName?: string;
332
+ sizes: number[][];
333
+ }
334
+ type FetchBidsBidConfig = {
335
+ slots: A9AdUnitInterface[];
73
336
  };
74
- export type AdsConfigTCFV2 = AdsConfigBasic & {
75
- adTagParameters: {
76
- cmpGdpr: number;
77
- cmpVcd: string;
78
- cmpGvcd: string;
337
+ type Apstag = {
338
+ init: (arg0: ApstagInitConfig) => void;
339
+ fetchBids: (arg0: FetchBidsBidConfig, callback: (res: FetchBidResponse[]) => void) => void;
340
+ setDisplayBids: () => void;
341
+ };
342
+ type ComscoreGlobals = {
343
+ c1: string;
344
+ c2: string;
345
+ cs_ucfr: string;
346
+ comscorekw?: string;
347
+ options?: {
348
+ enableFirstPartyCookie?: boolean;
79
349
  };
80
- nonPersonalizedAd: boolean;
81
350
  };
82
- export type AdsConfigEnabled = AdsConfigBasic | AdsConfigCCPAorAus | AdsConfigTCFV2;
83
- export type AdsConfig = AdsConfigEnabled | AdsConfigDisabled;
84
- export type AdTargetingBuilder = () => Promise<AdsConfig>;
85
- export type True = 't';
86
- export type False = 'f';
87
- export type NotApplicable = 'na';
351
+ interface IasPETSlot {
352
+ adSlotId: string;
353
+ size: Array<[number, number]>;
354
+ adUnitPath: string;
355
+ }
356
+ interface IasPET {
357
+ queue?: Array<{
358
+ adSlots: IasPETSlot[];
359
+ dataHandler: (targetingJSON: string) => void;
360
+ }>;
361
+ pubId?: string;
362
+ }
363
+ interface TeadsAnalytics {
364
+ analytics_tag_id?: string;
365
+ share?: () => void;
366
+ shared_data?: unknown[];
367
+ }
368
+ /**
369
+ * Types for the IAB Safeframe API
370
+ *
371
+ * Note this type definition is incomplete.
372
+ * These types can be refined as/when they are required
373
+ */
374
+ interface SafeFrameAPI {
375
+ ver: string;
376
+ specVersion: string;
377
+ lib: {
378
+ lang: Record<string, unknown>;
379
+ dom: {
380
+ iframes: Record<string, unknown>;
381
+ msghost: Record<string, unknown>;
382
+ };
383
+ logger: Record<string, unknown>;
384
+ };
385
+ env: {
386
+ isIE: boolean;
387
+ ua: Record<string, unknown>;
388
+ };
389
+ info: {
390
+ errs: unknown[];
391
+ list: unknown[];
392
+ };
393
+ host: {
394
+ Config: {
395
+ new (o: {
396
+ renderFile: string;
397
+ positions: Record<string, unknown>;
398
+ }): unknown;
399
+ };
400
+ };
401
+ }
402
+ /**
403
+ * Types for IMR Worldwide
404
+ */
405
+ interface NSdkInstance {
406
+ ggPM: (type: string, dcrStaticMetadata: {
407
+ type: string;
408
+ assetid: unknown;
409
+ section: string;
410
+ }) => void;
411
+ ggInitialize: (nolggGlobalParams: {
412
+ sfcode: string;
413
+ apid: string;
414
+ apn: string;
415
+ }) => void;
416
+ }
417
+ interface Trac {
418
+ record: () => this;
419
+ post: () => this;
420
+ }
421
+ type GoogleTagParams = unknown;
422
+ type GoogleTrackConversionObject = {
423
+ google_conversion_id: number;
424
+ google_custom_params: GoogleTagParams;
425
+ google_remarketing_only: boolean;
426
+ };
427
+ export type { Advert, DfpEnv, ConnectionType, NetworkInformation, OphanRecordFunction, Indices, Edition, AdsConfigDisabled, AdsConfigEnabled, AdsConfigBasic, AdsConfigUSNATorAus, AdsConfigTCFV2, AdsConfig, AdTargetingBuilder, Ophan, Config, AdBlockers, ArticleCounts, FetchBidResponse, HeaderNotification, OptOutInitializeOptions, OptOutAdSlot, Confiant, Permutive, Apstag, ComscoreGlobals, IasPET, TeadsAnalytics, SafeFrameAPI, NSdkInstance, Trac, GoogleTagParams, GoogleTrackConversionObject, };
package/dist/esm/types.js CHANGED
@@ -1 +1,11 @@
1
- export {};
1
+ import 'googletag';
2
+ var BlockingType;
3
+ (function (BlockingType) {
4
+ BlockingType[BlockingType["Manual"] = 1] = "Manual";
5
+ BlockingType[BlockingType["Creative"] = 2] = "Creative";
6
+ BlockingType[BlockingType["ProviderSecurity"] = 3] = "ProviderSecurity";
7
+ BlockingType[BlockingType["BannedDomain"] = 4] = "BannedDomain";
8
+ BlockingType[BlockingType["ProviderIbv"] = 5] = "ProviderIbv";
9
+ BlockingType[BlockingType["UnsafeJS"] = 6] = "UnsafeJS";
10
+ BlockingType[BlockingType["Hrap"] = 7] = "Hrap";
11
+ })(BlockingType || (BlockingType = {}));
package/package.json CHANGED
@@ -1,84 +1,65 @@
1
1
  {
2
- "name": "@guardian/commercial-core",
3
- "version": "7.1.0",
4
- "description": "Guardian advertising business logic",
5
- "homepage": "https://github.com/guardian/commercial-core#readme",
6
- "bugs": {
7
- "url": "https://github.com/guardian/commercial-core/issues"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/guardian/commercial-core.git"
12
- },
13
- "license": "Apache-2.0",
14
- "main": "dist/cjs/index.js",
15
- "module": "dist/esm/index.js",
16
- "files": [
17
- "dist"
18
- ],
19
- "scripts": {
20
- "build": "npm-run-all clean --parallel compile:*",
21
- "clean": "rm -rf dist",
22
- "commit": "cz",
23
- "compile:common": "tsc --project ./tsconfig.build.json --outDir ./dist/cjs --module CommonJS",
24
- "compile:esm": "tsc --project ./tsconfig.build.json --outDir ./dist/esm",
25
- "lint": "eslint .",
26
- "prettier:check": "prettier . --check --cache",
27
- "prettier:fix": "prettier . --write --cache",
28
- "precommit:lint": "lint-staged",
29
- "prepush:test": "jest --verbose --runInBand --onlyChanged",
30
- "test": "jest",
31
- "test:watch": "jest --watch",
32
- "test:ci": "jest --coverage --ci",
33
- "tsc": "tsc --noEmit",
34
- "validate": "npm-run-all tsc lint test build"
35
- },
36
- "prettier": "@guardian/prettier",
37
- "devDependencies": {
38
- "@commitlint/cli": "^17.0.3",
39
- "@commitlint/config-conventional": "^17.0.0",
40
- "@guardian/ab-core": "4.0.0",
41
- "@guardian/consent-management-platform": "^13.0.2",
42
- "@guardian/eslint-config-typescript": "^5.0.0",
43
- "@guardian/libs": "14.0.0",
44
- "@guardian/prettier": "^3.0.0",
45
- "@octokit/core": "^4.0.5",
46
- "@semantic-release/github": "^8.0.2",
47
- "@types/google.analytics": "^0.0.42",
48
- "@types/googletag": "^3.0.1",
49
- "@types/jest": "^29.0.3",
50
- "@types/node": "^18.11.9",
51
- "@typescript-eslint/eslint-plugin": "^5.5.0",
52
- "@typescript-eslint/parser": "^5.5.0",
53
- "commitizen": "^4.2.4",
54
- "conventional-changelog-conventionalcommits": "^5.0.0",
55
- "cz-conventional-changelog": "^3.3.0",
56
- "eslint": "^8.4.1",
57
- "eslint-config-prettier": "^8.3.0",
58
- "eslint-plugin-eslint-comments": "^3.2.0",
59
- "eslint-plugin-import": "^2.25.3",
60
- "eslint-plugin-jest": "^27.2.1",
61
- "eslint-plugin-prettier": "^4.0.0",
62
- "jest": "^29.4.1",
63
- "mockdate": "^3.0.5",
64
- "npm-run-all": "^4.1.5",
65
- "prettier": "^2.5.0",
66
- "semantic-release": "^19.0.2",
67
- "semantic-release-monorepo": "^7.0.5",
68
- "ts-jest": "^29.0.5",
69
- "tslib": "^2.4.1",
70
- "type-fest": "2.12.2",
71
- "typescript": "~4.9.5"
72
- },
73
- "publishConfig": {
74
- "access": "public"
75
- },
76
- "peerDependencies": {
77
- "@guardian/ab-core": "^4.0.0",
78
- "@guardian/consent-management-platform": "^13.0.2",
79
- "@guardian/libs": "^14.0.0"
80
- },
81
- "resolutions": {
82
- "typescript": "~4.9.5"
83
- }
84
- }
2
+ "name": "@guardian/commercial-core",
3
+ "version": "27.1.0",
4
+ "description": "Guardian advertising business logic",
5
+ "homepage": "https://github.com/guardian/commercial#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/guardian/commercial/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/guardian/commercial.git"
12
+ },
13
+ "license": "Apache-2.0",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "main": "dist/cjs/index.js",
18
+ "module": "dist/esm/index.js",
19
+ "exports": {
20
+ ".": {
21
+ "import": "./dist/esm/index.js",
22
+ "require": "./dist/cjs/index.js",
23
+ "workspace": "./src/index.ts"
24
+ },
25
+ "./*": {
26
+ "import": "./dist/esm/*.js",
27
+ "require": "./dist/cjs/*.js",
28
+ "workspace": "./src/*.ts"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "peerDependencies": {
33
+ "@guardian/ab-core": "8.0.1",
34
+ "@guardian/libs": "22.5.0"
35
+ },
36
+ "dependencies": {
37
+ "@guardian/ab-core": "8.0.1",
38
+ "@guardian/libs": "22.5.0",
39
+ "@types/googletag": "~3.3.0"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "24.0.12",
43
+ "typescript": "5.5.4",
44
+ "@types/jest": "30.0.0",
45
+ "jest": "^30.0.1",
46
+ "jest-environment-jsdom": "~29.7.0",
47
+ "jest-environment-jsdom-global": "~4.0.0",
48
+ "ts-jest": "^29.2.5",
49
+ "type-fest": "^4.31.0"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "scripts": {
55
+ "build": "pnpm run --parallel --aggregate-output /^build:.*/",
56
+ "clean": "rm -rf dist",
57
+ "build:esm": "tsc --outDir ./dist/esm --project ./tsconfig.esm.json",
58
+ "build:cjs": "tsc --outDir ./dist/cjs --project ./tsconfig.cjs.json",
59
+ "lint": "eslint .",
60
+ "prettier:check": "prettier . --check --cache",
61
+ "prettier:fix": "prettier . --write --cache",
62
+ "test": "jest",
63
+ "tsc": "tsc --noEmit"
64
+ }
65
+ }
@@ -1 +0,0 @@
1
- export function a9Apstag(): void;