@guardian/commercial-core 0.0.0-beta-20250716121613

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 (111) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +45 -0
  3. package/dist/cjs/ad-sizes.d.ts +202 -0
  4. package/dist/cjs/ad-sizes.js +400 -0
  5. package/dist/cjs/breakpoint.d.ts +8 -0
  6. package/dist/cjs/breakpoint.js +10 -0
  7. package/dist/cjs/constants/ad-label-height.d.ts +4 -0
  8. package/dist/cjs/constants/ad-label-height.js +7 -0
  9. package/dist/cjs/constants/index.d.ts +3 -0
  10. package/dist/cjs/constants/index.js +9 -0
  11. package/dist/cjs/constants/prebid-timeout.d.ts +4 -0
  12. package/dist/cjs/constants/prebid-timeout.js +7 -0
  13. package/dist/cjs/constants/top-above-nav-height.d.ts +10 -0
  14. package/dist/cjs/constants/top-above-nav-height.js +48 -0
  15. package/dist/cjs/detect-ad-blocker.d.ts +12 -0
  16. package/dist/cjs/detect-ad-blocker.js +61 -0
  17. package/dist/cjs/event-timer.d.ts +103 -0
  18. package/dist/cjs/event-timer.js +204 -0
  19. package/dist/cjs/geo/country-code.d.ts +3 -0
  20. package/dist/cjs/geo/country-code.js +34 -0
  21. package/dist/cjs/geo/geo-utils.d.ts +11 -0
  22. package/dist/cjs/geo/geo-utils.js +31 -0
  23. package/dist/cjs/geo/get-locale.d.ts +8 -0
  24. package/dist/cjs/geo/get-locale.js +43 -0
  25. package/dist/cjs/global.d.ts +71 -0
  26. package/dist/cjs/global.js +2 -0
  27. package/dist/cjs/index.d.ts +13 -0
  28. package/dist/cjs/index.js +46 -0
  29. package/dist/cjs/messenger/post-message.d.ts +1 -0
  30. package/dist/cjs/messenger/post-message.js +7 -0
  31. package/dist/cjs/permutive.d.ts +9 -0
  32. package/dist/cjs/permutive.js +38 -0
  33. package/dist/cjs/send-commercial-metrics.d.ts +58 -0
  34. package/dist/cjs/send-commercial-metrics.js +209 -0
  35. package/dist/cjs/targeting/build-page-targeting.d.ts +47 -0
  36. package/dist/cjs/targeting/build-page-targeting.js +112 -0
  37. package/dist/cjs/targeting/content.d.ts +87 -0
  38. package/dist/cjs/targeting/content.js +76 -0
  39. package/dist/cjs/targeting/personalised.d.ts +83 -0
  40. package/dist/cjs/targeting/personalised.js +140 -0
  41. package/dist/cjs/targeting/pick-targeting-values.d.ts +25 -0
  42. package/dist/cjs/targeting/pick-targeting-values.js +47 -0
  43. package/dist/cjs/targeting/session.d.ts +111 -0
  44. package/dist/cjs/targeting/session.js +61 -0
  45. package/dist/cjs/targeting/shared.d.ts +156 -0
  46. package/dist/cjs/targeting/shared.js +28 -0
  47. package/dist/cjs/targeting/teads-eligibility.d.ts +2 -0
  48. package/dist/cjs/targeting/teads-eligibility.js +20 -0
  49. package/dist/cjs/targeting/types.d.ts +6 -0
  50. package/dist/cjs/targeting/types.js +2 -0
  51. package/dist/cjs/targeting/viewport.d.ts +48 -0
  52. package/dist/cjs/targeting/viewport.js +22 -0
  53. package/dist/cjs/targeting/youtube-ima.d.ts +12 -0
  54. package/dist/cjs/targeting/youtube-ima.js +76 -0
  55. package/dist/cjs/types.d.ts +426 -0
  56. package/dist/cjs/types.js +12 -0
  57. package/dist/esm/ad-sizes.d.ts +202 -0
  58. package/dist/esm/ad-sizes.js +390 -0
  59. package/dist/esm/breakpoint.d.ts +8 -0
  60. package/dist/esm/breakpoint.js +6 -0
  61. package/dist/esm/constants/ad-label-height.d.ts +4 -0
  62. package/dist/esm/constants/ad-label-height.js +4 -0
  63. package/dist/esm/constants/index.d.ts +3 -0
  64. package/dist/esm/constants/index.js +3 -0
  65. package/dist/esm/constants/prebid-timeout.d.ts +4 -0
  66. package/dist/esm/constants/prebid-timeout.js +4 -0
  67. package/dist/esm/constants/top-above-nav-height.d.ts +10 -0
  68. package/dist/esm/constants/top-above-nav-height.js +45 -0
  69. package/dist/esm/detect-ad-blocker.d.ts +12 -0
  70. package/dist/esm/detect-ad-blocker.js +58 -0
  71. package/dist/esm/event-timer.d.ts +103 -0
  72. package/dist/esm/event-timer.js +199 -0
  73. package/dist/esm/geo/country-code.d.ts +3 -0
  74. package/dist/esm/geo/country-code.js +31 -0
  75. package/dist/esm/geo/geo-utils.d.ts +11 -0
  76. package/dist/esm/geo/geo-utils.js +20 -0
  77. package/dist/esm/geo/get-locale.d.ts +8 -0
  78. package/dist/esm/geo/get-locale.js +38 -0
  79. package/dist/esm/global.d.ts +71 -0
  80. package/dist/esm/global.js +0 -0
  81. package/dist/esm/index.d.ts +13 -0
  82. package/dist/esm/index.js +10 -0
  83. package/dist/esm/messenger/post-message.d.ts +1 -0
  84. package/dist/esm/messenger/post-message.js +3 -0
  85. package/dist/esm/permutive.d.ts +9 -0
  86. package/dist/esm/permutive.js +33 -0
  87. package/dist/esm/send-commercial-metrics.d.ts +58 -0
  88. package/dist/esm/send-commercial-metrics.js +204 -0
  89. package/dist/esm/targeting/build-page-targeting.d.ts +47 -0
  90. package/dist/esm/targeting/build-page-targeting.js +108 -0
  91. package/dist/esm/targeting/content.d.ts +87 -0
  92. package/dist/esm/targeting/content.js +73 -0
  93. package/dist/esm/targeting/personalised.d.ts +83 -0
  94. package/dist/esm/targeting/personalised.js +137 -0
  95. package/dist/esm/targeting/pick-targeting-values.d.ts +25 -0
  96. package/dist/esm/targeting/pick-targeting-values.js +43 -0
  97. package/dist/esm/targeting/session.d.ts +111 -0
  98. package/dist/esm/targeting/session.js +57 -0
  99. package/dist/esm/targeting/shared.d.ts +156 -0
  100. package/dist/esm/targeting/shared.js +25 -0
  101. package/dist/esm/targeting/teads-eligibility.d.ts +2 -0
  102. package/dist/esm/targeting/teads-eligibility.js +17 -0
  103. package/dist/esm/targeting/types.d.ts +6 -0
  104. package/dist/esm/targeting/types.js +0 -0
  105. package/dist/esm/targeting/viewport.d.ts +48 -0
  106. package/dist/esm/targeting/viewport.js +19 -0
  107. package/dist/esm/targeting/youtube-ima.d.ts +12 -0
  108. package/dist/esm/targeting/youtube-ima.js +73 -0
  109. package/dist/esm/types.d.ts +426 -0
  110. package/dist/esm/types.js +10 -0
  111. package/package.json +65 -0
@@ -0,0 +1,73 @@
1
+ import { log } from '@guardian/libs';
2
+ import { buildPageTargeting, filterValues } from './build-page-targeting';
3
+ /**
4
+ * @param {Record<string, MaybeArray<string|number|boolean>>
5
+ * Follows https://support.google.com/admanager/answer/1080597
6
+ */
7
+ const encodeCustomParams = (params) => {
8
+ const encodedParams = Object.entries(params)
9
+ .map(([key, value]) => {
10
+ const queryValue = Array.isArray(value)
11
+ ? value.join(',')
12
+ : String(value);
13
+ return `${key}=${encodeURIComponent(queryValue)}`;
14
+ })
15
+ .join('&');
16
+ return encodedParams;
17
+ };
18
+ const mergeCustomParamsWithTargeting = (customParams, consentState, clientSideParticipations, isSignedIn) => {
19
+ let pageTargeting = {};
20
+ try {
21
+ pageTargeting = buildPageTargeting({
22
+ adFree: false,
23
+ clientSideParticipations,
24
+ consentState: consentState,
25
+ isSignedIn: isSignedIn,
26
+ });
27
+ }
28
+ catch (e) {
29
+ /**
30
+ * Defensive error handling in case YoutubeAtom is used in an
31
+ * environment where guardian.config, cookies, localstorage etc
32
+ * are not available
33
+ */
34
+ log('commercial', 'Error building YouTube IMA custom params', e);
35
+ return customParams;
36
+ }
37
+ const mergedCustomParams = {
38
+ ...customParams,
39
+ ...pageTargeting,
40
+ };
41
+ return mergedCustomParams;
42
+ };
43
+ const buildImaAdTagUrl = ({ adUnit, clientSideParticipations, consentState, customParams, isSignedIn, }) => {
44
+ const mergedCustomParams = mergeCustomParamsWithTargeting(customParams, consentState, clientSideParticipations, isSignedIn);
45
+ const queryParams = {
46
+ iu: adUnit,
47
+ tfcd: '0',
48
+ npa: '0',
49
+ sz: '480x360|480x361|400x300',
50
+ gdfp_req: '1',
51
+ output: 'vast',
52
+ unviewed_position_start: '1',
53
+ env: 'vp',
54
+ impl: 's',
55
+ vad_type: 'linear',
56
+ vpos: 'preroll',
57
+ plcmt: '1',
58
+ description_url: encodeURIComponent(`${window.guardian.config.page.host}/${window.guardian.config.page.pageId}`),
59
+ /**
60
+ * cust_params string is encoded
61
+ * cust_params values are also encoded so they will get double encoded
62
+ * this ensures any values with separator chars (=&,) do not conflict with the main string
63
+ */
64
+ cust_params: encodeURIComponent(encodeCustomParams(filterValues(mergedCustomParams))),
65
+ };
66
+ const queryParamsArray = [];
67
+ for (const [k, v] of Object.entries(queryParams)) {
68
+ queryParamsArray.push(`${k}=${v}`);
69
+ }
70
+ return ('https://securepubads.g.doubleclick.net/gampad/ads?' +
71
+ queryParamsArray.join('&'));
72
+ };
73
+ export { buildImaAdTagUrl };
@@ -0,0 +1,426 @@
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 {
39
+ readonly type?: ConnectionType;
40
+ readonly downlink?: number;
41
+ readonly effectiveType?: string;
42
+ }
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;
70
+ };
71
+ type AdsConfigTCFV2 = AdsConfigBasic & {
72
+ adTagParameters: {
73
+ cmpGdpr: number;
74
+ cmpVcd: string;
75
+ cmpGvcd: string;
76
+ };
77
+ nonPersonalizedAd: boolean;
78
+ };
79
+ type AdsConfigEnabled = AdsConfigBasic | AdsConfigUSNATorAus | AdsConfigTCFV2;
80
+ type AdsConfig = AdsConfigEnabled | AdsConfigDisabled;
81
+ type AdTargetingBuilder = () => Promise<AdsConfig>;
82
+ interface Ophan {
83
+ trackComponentAttention: (name: string, el: Element, visiblityThreshold: number) => void;
84
+ record: OphanRecordFunction;
85
+ viewId: string;
86
+ pageViewId: string;
87
+ }
88
+ type PrebidBreakpoint = 'D' | 'T' | 'M';
89
+ type PrebidIndexSite = {
90
+ bp: PrebidBreakpoint;
91
+ id: number;
92
+ };
93
+ interface CommercialPageConfig {
94
+ pbIndexSites: PrebidIndexSite[];
95
+ adUnit: string;
96
+ appNexusPageTargeting?: string;
97
+ sharedAdTargeting?: Record<string, string | string[]>;
98
+ shouldHideAdverts: boolean;
99
+ pageAdTargeting?: PageTargeting;
100
+ dfpAccountId: string;
101
+ ipsosTag?: string;
102
+ a9PublisherId: string;
103
+ libs?: {
104
+ googletag?: string;
105
+ };
106
+ }
107
+ interface PageConfig extends CommercialPageConfig {
108
+ ajaxUrl?: string;
109
+ assetsPath: string;
110
+ author: string;
111
+ authorIds: string;
112
+ blogIds: string;
113
+ commentable: boolean;
114
+ contentType: string;
115
+ dcrCouldRender: boolean;
116
+ edition: Edition;
117
+ frontendAssetsFullURL?: string;
118
+ hasPageSkin: boolean;
119
+ hasShowcaseMainElement: boolean;
120
+ hasYouTubeAtom: boolean;
121
+ headline: string;
122
+ host: string;
123
+ idApiUrl?: string;
124
+ idUrl?: string;
125
+ isbn?: string;
126
+ isDev: boolean;
127
+ isFront: boolean;
128
+ isHosted: boolean;
129
+ isImmersive?: boolean;
130
+ isLiveBlog?: boolean;
131
+ isPaidContent: boolean;
132
+ isPreview: boolean;
133
+ isProd: boolean;
134
+ isSensitive: boolean;
135
+ isMinuteArticle: boolean;
136
+ keywordIds: string;
137
+ keywords: string;
138
+ lightboxImages?: {
139
+ images: Array<{
140
+ src: string;
141
+ }>;
142
+ };
143
+ pageId: string;
144
+ publication: string;
145
+ revisionNumber: string;
146
+ section: string;
147
+ sectionName: string;
148
+ sentryHost: string;
149
+ sentryPublicApiKey: string;
150
+ series: string;
151
+ seriesId: string;
152
+ sharedAdTargeting?: Record<string, string | string[]>;
153
+ shouldHideReaderRevenue?: boolean;
154
+ showNewRecipeDesign?: boolean;
155
+ showRelatedContent?: boolean;
156
+ source: string;
157
+ sponsorshipType: string;
158
+ toneIds: string;
159
+ tones: string;
160
+ videoDuration: number;
161
+ webPublicationDate: number;
162
+ userAttributesApiUrl?: string;
163
+ }
164
+ type Stage = 'DEV' | 'CODE' | 'PROD';
165
+ interface UserConfig {
166
+ accountCreatedDate: number;
167
+ displayName: string;
168
+ emailVerified: boolean;
169
+ id: string;
170
+ rawResponse: string;
171
+ }
172
+ interface Config {
173
+ commercialMetricsInitialised?: boolean;
174
+ frontendAssetsFullURL?: string;
175
+ isDotcomRendering: boolean;
176
+ ophan: {
177
+ browserId?: string;
178
+ pageViewId: string;
179
+ };
180
+ page: PageConfig;
181
+ shouldSendCommercialMetrics?: boolean;
182
+ stage: Stage;
183
+ switches: Record<string, boolean | undefined>;
184
+ tests?: {
185
+ [key: `${string}Control`]: 'control';
186
+ [key: `${string}Variant`]: 'variant';
187
+ };
188
+ user?: UserConfig;
189
+ }
190
+ type AdBlockers = {
191
+ active: boolean | undefined;
192
+ onDetect: Array<(value: boolean | PromiseLike<boolean>) => void>;
193
+ };
194
+ type TagCounts = Record<string, number>;
195
+ type WeeklyArticleLog = {
196
+ week: number;
197
+ count: number;
198
+ tags?: TagCounts;
199
+ };
200
+ type WeeklyArticleHistory = WeeklyArticleLog[];
201
+ interface DailyArticleCount {
202
+ day: number;
203
+ count: number;
204
+ }
205
+ type DailyArticleHistory = DailyArticleCount[];
206
+ interface ArticleCounts {
207
+ weeklyArticleHistory: WeeklyArticleHistory;
208
+ dailyArticleHistory: DailyArticleHistory;
209
+ }
210
+ type FetchBidSizes = {
211
+ adSizes: `${number}x${number}`;
212
+ };
213
+ type FetchBidResponse = {
214
+ amznbid: string;
215
+ amzniid: string;
216
+ amznp: string;
217
+ amznsz: FetchBidSizes;
218
+ size: FetchBidSizes;
219
+ slotID: string;
220
+ };
221
+ interface HeaderNotification {
222
+ id: string;
223
+ target: string;
224
+ message: string;
225
+ ophanLabel: string;
226
+ logImpression: () => void;
227
+ }
228
+ interface OptOutInitializeOptions {
229
+ publisher: number;
230
+ onlyNoConsent?: 0 | 1;
231
+ alwaysNoConsent?: 0 | 1;
232
+ consentTimeOutMS?: 5000;
233
+ noLogging?: 0 | 1;
234
+ lazyLoading?: {
235
+ fractionInView?: number;
236
+ viewPortMargin?: string;
237
+ };
238
+ noRequestsOnPageLoad?: 0 | 1;
239
+ frequencyScript?: string;
240
+ timeoutFrequencyCappingMS?: number;
241
+ debug_forceCap?: number;
242
+ }
243
+ interface OptOutResponse {
244
+ adSlot: string;
245
+ width: number;
246
+ height: number;
247
+ ad: string;
248
+ creativeId: string;
249
+ meta: {
250
+ networkId: string;
251
+ networkName: string;
252
+ agencyId: string;
253
+ agencyName: string;
254
+ advertiserId: string;
255
+ advertiserName: string;
256
+ advertiserDomains: string[];
257
+ };
258
+ optOutExt: {
259
+ noSafeFrame: boolean;
260
+ tags: string[];
261
+ };
262
+ }
263
+ type OptOutFilledCallback = (adSlot: OptOutAdSlot, response: OptOutResponse) => void;
264
+ interface OptOutAdSlot {
265
+ adSlot: string;
266
+ targetId: string;
267
+ id: string;
268
+ filledCallback?: OptOutFilledCallback;
269
+ emptyCallback?: (adSlot: OptOutAdSlot) => void;
270
+ adShownCallback?: (adSlot: OptOutAdSlot, response: OptOutResponse) => void;
271
+ }
272
+ interface ImpressionsDfpObject {
273
+ s: string;
274
+ ad: string;
275
+ c: string;
276
+ I: string;
277
+ o: string;
278
+ A: string;
279
+ y: string;
280
+ co: string;
281
+ }
282
+ declare enum BlockingType {
283
+ Manual = 1,// Deprecated
284
+ Creative = 2,// Creative-based detection
285
+ ProviderSecurity = 3,// Domain-based detection for unsafe domains
286
+ BannedDomain = 4,// Domain-based detection for banned domains
287
+ ProviderIbv = 5,// Domain-based detection for in-banner-video
288
+ UnsafeJS = 6,// JavaScript-based detection for unsafe ads
289
+ Hrap = 7
290
+ }
291
+ type ConfiantCallback = (blockingType: BlockingType, blockingId: string, isBlocked: boolean, wrapperId: string, tagId: string, impressionsData?: {
292
+ prebid?: {
293
+ adId?: string | null;
294
+ cpm?: number | null;
295
+ s?: string;
296
+ };
297
+ dfp?: ImpressionsDfpObject;
298
+ }) => void;
299
+ interface Confiant extends Record<string, unknown> {
300
+ settings: {
301
+ callback: ConfiantCallback;
302
+ [key: string]: unknown;
303
+ };
304
+ }
305
+ interface Permutive {
306
+ config?: {
307
+ projectId?: string;
308
+ apiKey?: string;
309
+ environment?: string;
310
+ };
311
+ q?: Array<{
312
+ functionName: string;
313
+ arguments: unknown[];
314
+ }>;
315
+ addon?: (name: string, props: Record<string, unknown>) => void;
316
+ identify?: (user: Array<{
317
+ id: string;
318
+ tag: string;
319
+ }>) => void;
320
+ track?: (name: string, props: Record<string, unknown>) => void;
321
+ }
322
+ type ApstagInitConfig = {
323
+ pubID: string;
324
+ adServer?: string;
325
+ bidTimeout?: number;
326
+ blockedBidders?: string[];
327
+ };
328
+ interface A9AdUnitInterface {
329
+ slotID: string;
330
+ slotName?: string;
331
+ sizes: number[][];
332
+ }
333
+ type FetchBidsBidConfig = {
334
+ slots: A9AdUnitInterface[];
335
+ };
336
+ type Apstag = {
337
+ init: (arg0: ApstagInitConfig) => void;
338
+ fetchBids: (arg0: FetchBidsBidConfig, callback: (res: FetchBidResponse[]) => void) => void;
339
+ setDisplayBids: () => void;
340
+ };
341
+ type ComscoreGlobals = {
342
+ c1: string;
343
+ c2: string;
344
+ cs_ucfr: string;
345
+ comscorekw?: string;
346
+ options?: {
347
+ enableFirstPartyCookie?: boolean;
348
+ };
349
+ };
350
+ interface IasPETSlot {
351
+ adSlotId: string;
352
+ size: Array<[number, number]>;
353
+ adUnitPath: string;
354
+ }
355
+ interface IasPET {
356
+ queue?: Array<{
357
+ adSlots: IasPETSlot[];
358
+ dataHandler: (targetingJSON: string) => void;
359
+ }>;
360
+ pubId?: string;
361
+ }
362
+ interface TeadsAnalytics {
363
+ analytics_tag_id?: string;
364
+ share?: () => void;
365
+ shared_data?: unknown[];
366
+ }
367
+ /**
368
+ * Types for the IAB Safeframe API
369
+ *
370
+ * Note this type definition is incomplete.
371
+ * These types can be refined as/when they are required
372
+ */
373
+ interface SafeFrameAPI {
374
+ ver: string;
375
+ specVersion: string;
376
+ lib: {
377
+ lang: Record<string, unknown>;
378
+ dom: {
379
+ iframes: Record<string, unknown>;
380
+ msghost: Record<string, unknown>;
381
+ };
382
+ logger: Record<string, unknown>;
383
+ };
384
+ env: {
385
+ isIE: boolean;
386
+ ua: Record<string, unknown>;
387
+ };
388
+ info: {
389
+ errs: unknown[];
390
+ list: unknown[];
391
+ };
392
+ host: {
393
+ Config: {
394
+ new (o: {
395
+ renderFile: string;
396
+ positions: Record<string, unknown>;
397
+ }): unknown;
398
+ };
399
+ };
400
+ }
401
+ /**
402
+ * Types for IMR Worldwide
403
+ */
404
+ interface NSdkInstance {
405
+ ggPM: (type: string, dcrStaticMetadata: {
406
+ type: string;
407
+ assetid: unknown;
408
+ section: string;
409
+ }) => void;
410
+ ggInitialize: (nolggGlobalParams: {
411
+ sfcode: string;
412
+ apid: string;
413
+ apn: string;
414
+ }) => void;
415
+ }
416
+ interface Trac {
417
+ record: () => this;
418
+ post: () => this;
419
+ }
420
+ type GoogleTagParams = unknown;
421
+ type GoogleTrackConversionObject = {
422
+ google_conversion_id: number;
423
+ google_custom_params: GoogleTagParams;
424
+ google_remarketing_only: boolean;
425
+ };
426
+ 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, };
@@ -0,0 +1,10 @@
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 ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@guardian/commercial-core",
3
+ "version": "0.0.0-beta-20250716121613",
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
+ }