@guardian/commercial-core 7.1.0 → 27.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.
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 +399 -63
  39. package/dist/cjs/types.js +10 -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 +399 -63
  76. package/dist/esm/types.js +10 -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,423 @@
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
+ type HeaderBiddingSize = AdSize;
4
+ interface Advert {
5
+ id: string;
6
+ node: HTMLElement;
7
+ prebidAdUnit: string;
8
+ sizes: SizeMapping;
9
+ headerBiddingSizes: HeaderBiddingSize[] | null;
10
+ size: AdSize | 'fluid' | null;
11
+ slot: googletag.Slot;
12
+ isEmpty: boolean | null;
13
+ isRendered: boolean;
14
+ shouldRefresh: boolean;
15
+ whenSlotReady: Promise<void>;
16
+ extraNodeClasses: string[];
17
+ hasPrebidSize: boolean;
18
+ headerBiddingBidRequest: Promise<unknown> | null;
19
+ lineItemId: number | null;
20
+ creativeId: number | null;
21
+ creativeTemplateId: number | null;
22
+ testgroup: string | undefined;
23
+ finishedRendering(isRendered: boolean): void;
24
+ updateExtraSlotClasses(...newClasses: string[]): Promise<void>;
25
+ generateSizeMapping(additionalSizeMapping: SizeMapping): SizeMapping;
26
+ updateSizeMapping(additionalSizeMapping: SizeMapping): void;
27
+ }
28
+ interface DfpEnv {
29
+ renderStartTime: number;
30
+ adSlotSelector: string;
31
+ lazyLoadEnabled: boolean;
32
+ lazyLoadObserve: boolean;
33
+ advertsToLoad: Advert[];
34
+ adverts: Map<Advert['id'], Advert>;
35
+ shouldLazyLoad: () => boolean;
36
+ }
37
+ type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
38
+ interface NetworkInformation extends EventTarget {
4
39
  readonly type?: ConnectionType;
5
40
  readonly downlink?: number;
6
41
  readonly effectiveType?: string;
7
42
  }
8
- export type TagAttribute = {
9
- name: string;
10
- value: string;
43
+ type OphanRecordFunction = (event: Record<string, unknown> & {
44
+ /**
45
+ * the experiences key will override previously set values.
46
+ * Use `recordExperiences` instead.
47
+ */
48
+ experiences?: never;
49
+ }, callback?: () => void) => void;
50
+ /**
51
+ * Generates a type which represents possible indices of this array
52
+ *
53
+ * Example usage:
54
+ * const list = ['foo', 'bar', 'baz'] as const;
55
+ * type Test = Indices<typeof list>
56
+ */
57
+ type Indices<T extends readonly unknown[]> = Exclude<Partial<T>['length'], T['length']>;
58
+ type Edition = 'UK' | 'AU' | 'US';
59
+ type AdsConfigDisabled = {
60
+ disableAds: true;
61
+ };
62
+ type AdsConfigBasic = {
63
+ adTagParameters: {
64
+ iu: string;
65
+ cust_params: string;
66
+ };
67
+ };
68
+ type AdsConfigUSNATorAus = AdsConfigBasic & {
69
+ restrictedDataProcessor: boolean;
11
70
  };
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;
71
+ type AdsConfigTCFV2 = AdsConfigBasic & {
72
+ adTagParameters: {
73
+ cmpGdpr: number;
74
+ cmpVcd: string;
75
+ cmpGvcd: string;
76
+ };
77
+ nonPersonalizedAd: boolean;
23
78
  };
24
- export type GetThirdPartyTag = (arg0: {
25
- shouldRun: boolean;
26
- }) => ThirdPartyTag;
27
- export type GuardianAnalyticsConfig = {
28
- trackers: Record<string, string>;
79
+ interface Ophan {
80
+ trackComponentAttention: (name: string, el: Element, visiblityThreshold: number) => void;
81
+ record: OphanRecordFunction;
82
+ viewId: string;
83
+ pageViewId: string;
84
+ }
85
+ type PrebidBreakpoint = 'D' | 'T' | 'M';
86
+ type PrebidIndexSite = {
87
+ bp: PrebidBreakpoint;
88
+ id: number;
29
89
  };
30
- export type Edition = 'UK' | 'AU' | 'US';
31
- export type GuardianWindowConfig = {
32
- googleAnalytics?: GuardianAnalyticsConfig;
90
+ interface CommercialPageConfig {
91
+ pbIndexSites: PrebidIndexSite[];
92
+ adUnit: string;
93
+ appNexusPageTargeting?: string;
94
+ sharedAdTargeting?: Record<string, string | string[]>;
95
+ shouldHideAdverts: boolean;
96
+ pageAdTargeting?: PageTargeting;
97
+ dfpAccountId: string;
98
+ ipsosTag?: string;
99
+ a9PublisherId: string;
100
+ libs?: {
101
+ googletag?: string;
102
+ };
103
+ }
104
+ interface PageConfig extends CommercialPageConfig {
105
+ ajaxUrl?: string;
106
+ assetsPath: string;
107
+ author: string;
108
+ authorIds: string;
109
+ blogIds: string;
110
+ commentable: boolean;
111
+ contentType: string;
112
+ dcrCouldRender: boolean;
113
+ edition: Edition;
114
+ frontendAssetsFullURL?: string;
115
+ hasPageSkin: boolean;
116
+ hasShowcaseMainElement: boolean;
117
+ hasYouTubeAtom: boolean;
118
+ headline: string;
119
+ host: string;
120
+ idApiUrl?: string;
121
+ idUrl?: string;
122
+ isbn?: string;
123
+ isDev: boolean;
124
+ isFront: boolean;
125
+ isHosted: boolean;
126
+ isImmersive?: boolean;
127
+ isLiveBlog?: boolean;
128
+ isPaidContent: boolean;
129
+ isPreview: boolean;
130
+ isProd: boolean;
131
+ isSensitive: boolean;
132
+ isMinuteArticle: boolean;
133
+ keywordIds: string;
134
+ keywords: string;
135
+ lightboxImages?: {
136
+ images: Array<{
137
+ src: string;
138
+ }>;
139
+ };
140
+ pageId: string;
141
+ publication: string;
142
+ revisionNumber: string;
143
+ section: string;
144
+ sectionName: string;
145
+ sentryHost: string;
146
+ sentryPublicApiKey: string;
147
+ series: string;
148
+ seriesId: string;
149
+ sharedAdTargeting?: Record<string, string | string[]>;
150
+ shouldHideReaderRevenue?: boolean;
151
+ showNewRecipeDesign?: boolean;
152
+ showRelatedContent?: boolean;
153
+ source: string;
154
+ sponsorshipType: string;
155
+ toneIds: string;
156
+ tones: string;
157
+ videoDuration: number;
158
+ webPublicationDate: number;
159
+ userAttributesApiUrl?: string;
160
+ }
161
+ type Stage = 'DEV' | 'CODE' | 'PROD';
162
+ interface UserConfig {
163
+ accountCreatedDate: number;
164
+ displayName: string;
165
+ emailVerified: boolean;
166
+ id: string;
167
+ rawResponse: string;
168
+ }
169
+ interface Config {
170
+ commercialMetricsInitialised?: boolean;
171
+ frontendAssetsFullURL?: string;
33
172
  isDotcomRendering: boolean;
34
173
  ophan: {
35
174
  browserId?: string;
36
175
  pageViewId: string;
37
176
  };
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
- };
177
+ page: PageConfig;
178
+ shouldSendCommercialMetrics?: boolean;
179
+ stage: Stage;
180
+ switches: Record<string, boolean | undefined>;
49
181
  tests?: {
50
182
  [key: `${string}Control`]: 'control';
51
183
  [key: `${string}Variant`]: 'variant';
52
184
  };
185
+ user?: UserConfig;
186
+ }
187
+ type AdBlockers = {
188
+ active: boolean | undefined;
189
+ onDetect: Array<(value: boolean | PromiseLike<boolean>) => void>;
53
190
  };
54
- export type GoogleTagParams = unknown;
55
- export type GoogleTrackConversionObject = {
56
- google_conversion_id: number;
57
- google_custom_params: GoogleTagParams;
58
- google_remarketing_only: boolean;
191
+ type TagCounts = Record<string, number>;
192
+ type WeeklyArticleLog = {
193
+ week: number;
194
+ count: number;
195
+ tags?: TagCounts;
59
196
  };
60
- export type MaybeArray<T> = T | T[];
61
- export type CustomParams = Record<string, MaybeArray<string | number | boolean>>;
62
- export type AdsConfigDisabled = {
63
- disableAds: true;
197
+ type WeeklyArticleHistory = WeeklyArticleLog[];
198
+ interface DailyArticleCount {
199
+ day: number;
200
+ count: number;
201
+ }
202
+ type DailyArticleHistory = DailyArticleCount[];
203
+ interface ArticleCounts {
204
+ weeklyArticleHistory: WeeklyArticleHistory;
205
+ dailyArticleHistory: DailyArticleHistory;
206
+ }
207
+ type FetchBidSizes = {
208
+ adSizes: `${number}x${number}`;
64
209
  };
65
- export type AdsConfigBasic = {
66
- adTagParameters: {
67
- iu: string;
68
- cust_params: string;
210
+ type FetchBidResponse = {
211
+ amznbid: string;
212
+ amzniid: string;
213
+ amznp: string;
214
+ amznsz: FetchBidSizes;
215
+ size: FetchBidSizes;
216
+ slotID: string;
217
+ };
218
+ interface HeaderNotification {
219
+ id: string;
220
+ target: string;
221
+ message: string;
222
+ ophanLabel: string;
223
+ logImpression: () => void;
224
+ }
225
+ interface OptOutInitializeOptions {
226
+ publisher: number;
227
+ onlyNoConsent?: 0 | 1;
228
+ alwaysNoConsent?: 0 | 1;
229
+ consentTimeOutMS?: 5000;
230
+ noLogging?: 0 | 1;
231
+ lazyLoading?: {
232
+ fractionInView?: number;
233
+ viewPortMargin?: string;
69
234
  };
235
+ noRequestsOnPageLoad?: 0 | 1;
236
+ frequencyScript?: string;
237
+ timeoutFrequencyCappingMS?: number;
238
+ debug_forceCap?: number;
239
+ }
240
+ interface OptOutResponse {
241
+ adSlot: string;
242
+ width: number;
243
+ height: number;
244
+ ad: string;
245
+ creativeId: string;
246
+ meta: {
247
+ networkId: string;
248
+ networkName: string;
249
+ agencyId: string;
250
+ agencyName: string;
251
+ advertiserId: string;
252
+ advertiserName: string;
253
+ advertiserDomains: string[];
254
+ };
255
+ optOutExt: {
256
+ noSafeFrame: boolean;
257
+ tags: string[];
258
+ };
259
+ }
260
+ type OptOutFilledCallback = (adSlot: OptOutAdSlot, response: OptOutResponse) => void;
261
+ interface OptOutAdSlot {
262
+ adSlot: string;
263
+ targetId: string;
264
+ id: string;
265
+ filledCallback?: OptOutFilledCallback;
266
+ emptyCallback?: (adSlot: OptOutAdSlot) => void;
267
+ adShownCallback?: (adSlot: OptOutAdSlot, response: OptOutResponse) => void;
268
+ }
269
+ interface ImpressionsDfpObject {
270
+ s: string;
271
+ ad: string;
272
+ c: string;
273
+ I: string;
274
+ o: string;
275
+ A: string;
276
+ y: string;
277
+ co: string;
278
+ }
279
+ declare enum BlockingType {
280
+ Manual = 1,// Deprecated
281
+ Creative = 2,// Creative-based detection
282
+ ProviderSecurity = 3,// Domain-based detection for unsafe domains
283
+ BannedDomain = 4,// Domain-based detection for banned domains
284
+ ProviderIbv = 5,// Domain-based detection for in-banner-video
285
+ UnsafeJS = 6,// JavaScript-based detection for unsafe ads
286
+ Hrap = 7
287
+ }
288
+ type ConfiantCallback = (blockingType: BlockingType, blockingId: string, isBlocked: boolean, wrapperId: string, tagId: string, impressionsData?: {
289
+ prebid?: {
290
+ adId?: string | null;
291
+ cpm?: number | null;
292
+ s?: string;
293
+ };
294
+ dfp?: ImpressionsDfpObject;
295
+ }) => void;
296
+ interface Confiant extends Record<string, unknown> {
297
+ settings: {
298
+ callback: ConfiantCallback;
299
+ [key: string]: unknown;
300
+ };
301
+ }
302
+ interface Permutive {
303
+ config?: {
304
+ projectId?: string;
305
+ apiKey?: string;
306
+ environment?: string;
307
+ };
308
+ q?: Array<{
309
+ functionName: string;
310
+ arguments: unknown[];
311
+ }>;
312
+ addon?: (name: string, props: Record<string, unknown>) => void;
313
+ identify?: (user: Array<{
314
+ id: string;
315
+ tag: string;
316
+ }>) => void;
317
+ track?: (name: string, props: Record<string, unknown>) => void;
318
+ }
319
+ type ApstagInitConfig = {
320
+ pubID: string;
321
+ adServer?: string;
322
+ bidTimeout?: number;
323
+ blockedBidders?: string[];
70
324
  };
71
- export type AdsConfigCCPAorAus = AdsConfigBasic & {
72
- restrictedDataProcessor: boolean;
325
+ interface A9AdUnitInterface {
326
+ slotID: string;
327
+ slotName?: string;
328
+ sizes: number[][];
329
+ }
330
+ type FetchBidsBidConfig = {
331
+ slots: A9AdUnitInterface[];
73
332
  };
74
- export type AdsConfigTCFV2 = AdsConfigBasic & {
75
- adTagParameters: {
76
- cmpGdpr: number;
77
- cmpVcd: string;
78
- cmpGvcd: string;
333
+ type Apstag = {
334
+ init: (arg0: ApstagInitConfig) => void;
335
+ fetchBids: (arg0: FetchBidsBidConfig, callback: (res: FetchBidResponse[]) => void) => void;
336
+ setDisplayBids: () => void;
337
+ };
338
+ type ComscoreGlobals = {
339
+ c1: string;
340
+ c2: string;
341
+ cs_ucfr: string;
342
+ comscorekw?: string;
343
+ options?: {
344
+ enableFirstPartyCookie?: boolean;
79
345
  };
80
- nonPersonalizedAd: boolean;
81
346
  };
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';
347
+ interface IasPETSlot {
348
+ adSlotId: string;
349
+ size: Array<[number, number]>;
350
+ adUnitPath: string;
351
+ }
352
+ interface IasPET {
353
+ queue?: Array<{
354
+ adSlots: IasPETSlot[];
355
+ dataHandler: (targetingJSON: string) => void;
356
+ }>;
357
+ pubId?: string;
358
+ }
359
+ interface TeadsAnalytics {
360
+ analytics_tag_id?: string;
361
+ share?: () => void;
362
+ shared_data?: unknown[];
363
+ }
364
+ /**
365
+ * Types for the IAB Safeframe API
366
+ *
367
+ * Note this type definition is incomplete.
368
+ * These types can be refined as/when they are required
369
+ */
370
+ interface SafeFrameAPI {
371
+ ver: string;
372
+ specVersion: string;
373
+ lib: {
374
+ lang: Record<string, unknown>;
375
+ dom: {
376
+ iframes: Record<string, unknown>;
377
+ msghost: Record<string, unknown>;
378
+ };
379
+ logger: Record<string, unknown>;
380
+ };
381
+ env: {
382
+ isIE: boolean;
383
+ ua: Record<string, unknown>;
384
+ };
385
+ info: {
386
+ errs: unknown[];
387
+ list: unknown[];
388
+ };
389
+ host: {
390
+ Config: {
391
+ new (o: {
392
+ renderFile: string;
393
+ positions: Record<string, unknown>;
394
+ }): unknown;
395
+ };
396
+ };
397
+ }
398
+ /**
399
+ * Types for IMR Worldwide
400
+ */
401
+ interface NSdkInstance {
402
+ ggPM: (type: string, dcrStaticMetadata: {
403
+ type: string;
404
+ assetid: unknown;
405
+ section: string;
406
+ }) => void;
407
+ ggInitialize: (nolggGlobalParams: {
408
+ sfcode: string;
409
+ apid: string;
410
+ apn: string;
411
+ }) => void;
412
+ }
413
+ interface Trac {
414
+ record: () => this;
415
+ post: () => this;
416
+ }
417
+ type GoogleTagParams = unknown;
418
+ type GoogleTrackConversionObject = {
419
+ google_conversion_id: number;
420
+ google_custom_params: GoogleTagParams;
421
+ google_remarketing_only: boolean;
422
+ };
423
+ export type { Advert, DfpEnv, ConnectionType, NetworkInformation, OphanRecordFunction, Indices, Edition, AdsConfigDisabled, AdsConfigBasic, AdsConfigUSNATorAus, AdsConfigTCFV2, 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,10 @@
1
- export {};
1
+ var BlockingType;
2
+ (function (BlockingType) {
3
+ BlockingType[BlockingType["Manual"] = 1] = "Manual";
4
+ BlockingType[BlockingType["Creative"] = 2] = "Creative";
5
+ BlockingType[BlockingType["ProviderSecurity"] = 3] = "ProviderSecurity";
6
+ BlockingType[BlockingType["BannedDomain"] = 4] = "BannedDomain";
7
+ BlockingType[BlockingType["ProviderIbv"] = 5] = "ProviderIbv";
8
+ BlockingType[BlockingType["UnsafeJS"] = 6] = "UnsafeJS";
9
+ BlockingType[BlockingType["Hrap"] = 7] = "Hrap";
10
+ })(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.0.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
+ },
40
+ "devDependencies": {
41
+ "@types/node": "24.0.12",
42
+ "@types/googletag": "~3.3.0",
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;