Skip to content

Commit 9afaa86

Browse files
authored
TW-1464 Prepare backend for new native ads (#165)
* TW-1464 Prepare backend for new native ads * TW-1464 Update API documentation * TW-1464 Enable adding native ads in replace-only mode
1 parent 02f98e3 commit 9afaa86

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

src/advertising/external-ads.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export interface AdPlacesRule extends ExtVersionConstraints {
9999
};
100100
stylesOverrides?: AdStylesOverrides[];
101101
shouldHideOriginal?: boolean;
102+
isNative?: boolean;
102103
}
103104

104105
export interface PermanentAdPlacesRule extends ExtVersionConstraints {
@@ -117,9 +118,14 @@ export interface PermanentAdPlacesRule extends ExtVersionConstraints {
117118
insertBeforeSelector?: string;
118119
insertAfterSelector?: string;
119120
insertionsCount?: number;
120-
shouldUseDivWrapper: boolean;
121+
shouldUseDivWrapper?: boolean;
122+
wrapperType?: string;
123+
colsBefore?: number;
124+
colspan?: number;
125+
colsAfter?: number;
121126
elementStyle?: Record<StylePropName, string>;
122127
divWrapperStyle?: Record<StylePropName, string>;
128+
wrapperStyle?: Record<StylePropName, string>;
123129
elementToMeasureSelector?: string;
124130
stylesOverrides?: AdStylesOverrides[];
125131
shouldHideOriginal?: boolean;

src/routers/slise-ad-rules/ad-places.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ const transformAdPlacesDictionary = <T extends ExtVersionConstraints>(rules: Rec
108108
* type: boolean
109109
* description: Whether original ads banners should be hidden but not removed
110110
* default: false
111+
* isNative:
112+
* type: boolean
113+
* description: Whether the ad is native
114+
* default: false
111115
* example:
112116
* urlRegexes:
113117
* - '^https://goerli\.etherscan\.io/?$'
@@ -158,7 +162,6 @@ const transformAdPlacesDictionary = <T extends ExtVersionConstraints>(rules: Rec
158162
* - urlRegexes
159163
* - adSelector
160164
* - parentSelector
161-
* - shouldUseDivWrapper
162165
* properties:
163166
* urlRegexes:
164167
* type: array
@@ -233,6 +236,32 @@ const transformAdPlacesDictionary = <T extends ExtVersionConstraints>(rules: Rec
233236
* shouldUseDivWrapper:
234237
* type: boolean
235238
* description: Whether the ads banner should be wrapped in a div
239+
* wrapperType:
240+
* type: string
241+
* enum:
242+
* - div
243+
* - tbody
244+
* colsBefore:
245+
* type: number
246+
* integer: true
247+
* min: 0
248+
* description: >
249+
* If `wrapperType` is `tbody`, this property describes how many table columns should be inserted before
250+
* the new ads banner.
251+
* colspan:
252+
* type: number
253+
* integer: true
254+
* min: 1
255+
* description: >
256+
* If `wrapperType` is `tbody`, this property describes how many table columns should be spanned by the
257+
* new ads banner.
258+
* colsAfter:
259+
* type: number
260+
* integer: true
261+
* min: 0
262+
* description: >
263+
* If `wrapperType` is `tbody`, this property describes how many table columns should be inserted after
264+
* the new ads banner.
236265
* elementStyle:
237266
* type: object
238267
* description: Style of the new ad banner
@@ -243,6 +272,11 @@ const transformAdPlacesDictionary = <T extends ExtVersionConstraints>(rules: Rec
243272
* description: Style of the div wrapper
244273
* additionalProperties:
245274
* type: string
275+
* wrapperStyle:
276+
* type: object
277+
* description: Style of the new ad banner's wrapper
278+
* additionalProperties:
279+
* type: string
246280
* elementToMeasureSelector:
247281
* type: string
248282
* description: A selector of the element which should be measured to define banner size

src/utils/schemas.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ const adPlacesRulesSchema = arraySchema()
129129
.required(),
130130
stylesOverrides: arraySchema().of(adStylesOverridesSchema.clone().required()),
131131
shouldHideOriginal: booleanSchema(),
132+
isNative: booleanSchema(),
132133
extVersion: versionRangeSchema.clone().required()
133134
})
134135
.required()
@@ -163,9 +164,14 @@ const permanentAdPlacesRulesSchema = arraySchema()
163164
insertBeforeSelector: cssSelectorSchema,
164165
insertAfterSelector: cssSelectorSchema,
165166
insertionsCount: numberSchema().integer().min(1),
166-
shouldUseDivWrapper: booleanSchema().required(),
167+
shouldUseDivWrapper: booleanSchema(),
168+
wrapperType: stringSchema().oneOf(['div', 'tbody']),
169+
colsBefore: numberSchema().integer().min(0),
170+
colspan: numberSchema().integer().min(1),
171+
colsAfter: numberSchema().integer().min(0),
167172
elementStyle: styleSchema,
168173
divWrapperStyle: styleSchema,
174+
wrapperStyle: styleSchema,
169175
elementToMeasureSelector: cssSelectorSchema,
170176
stylesOverrides: arraySchema().of(adStylesOverridesSchema.clone().required()),
171177
shouldHideOriginal: booleanSchema(),

0 commit comments

Comments
 (0)