Skip to content

Commit

Permalink
TW-1464 Prepare backend for new native ads (#165) (#166)
Browse files Browse the repository at this point in the history
* TW-1464 Prepare backend for new native ads

* TW-1464 Update API documentation

* TW-1464 Enable adding native ads in replace-only mode

Co-authored-by: Inokentii Mazhara <[email protected]>
  • Loading branch information
lourenc and keshan3262 authored Jul 11, 2024
1 parent 0776a75 commit e5d44b6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/advertising/external-ads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export interface AdPlacesRule extends ExtVersionConstraints {
};
stylesOverrides?: AdStylesOverrides[];
shouldHideOriginal?: boolean;
isNative?: boolean;
}

export interface PermanentAdPlacesRule extends ExtVersionConstraints {
Expand All @@ -117,9 +118,14 @@ export interface PermanentAdPlacesRule extends ExtVersionConstraints {
insertBeforeSelector?: string;
insertAfterSelector?: string;
insertionsCount?: number;
shouldUseDivWrapper: boolean;
shouldUseDivWrapper?: boolean;
wrapperType?: string;
colsBefore?: number;
colspan?: number;
colsAfter?: number;
elementStyle?: Record<StylePropName, string>;
divWrapperStyle?: Record<StylePropName, string>;
wrapperStyle?: Record<StylePropName, string>;
elementToMeasureSelector?: string;
stylesOverrides?: AdStylesOverrides[];
shouldHideOriginal?: boolean;
Expand Down
36 changes: 35 additions & 1 deletion src/routers/slise-ad-rules/ad-places.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ const transformAdPlacesDictionary = <T extends ExtVersionConstraints>(rules: Rec
* type: boolean
* description: Whether original ads banners should be hidden but not removed
* default: false
* isNative:
* type: boolean
* description: Whether the ad is native
* default: false
* example:
* urlRegexes:
* - '^https://goerli\.etherscan\.io/?$'
Expand Down Expand Up @@ -158,7 +162,6 @@ const transformAdPlacesDictionary = <T extends ExtVersionConstraints>(rules: Rec
* - urlRegexes
* - adSelector
* - parentSelector
* - shouldUseDivWrapper
* properties:
* urlRegexes:
* type: array
Expand Down Expand Up @@ -233,6 +236,32 @@ const transformAdPlacesDictionary = <T extends ExtVersionConstraints>(rules: Rec
* shouldUseDivWrapper:
* type: boolean
* description: Whether the ads banner should be wrapped in a div
* wrapperType:
* type: string
* enum:
* - div
* - tbody
* colsBefore:
* type: number
* integer: true
* min: 0
* description: >
* If `wrapperType` is `tbody`, this property describes how many table columns should be inserted before
* the new ads banner.
* colspan:
* type: number
* integer: true
* min: 1
* description: >
* If `wrapperType` is `tbody`, this property describes how many table columns should be spanned by the
* new ads banner.
* colsAfter:
* type: number
* integer: true
* min: 0
* description: >
* If `wrapperType` is `tbody`, this property describes how many table columns should be inserted after
* the new ads banner.
* elementStyle:
* type: object
* description: Style of the new ad banner
Expand All @@ -243,6 +272,11 @@ const transformAdPlacesDictionary = <T extends ExtVersionConstraints>(rules: Rec
* description: Style of the div wrapper
* additionalProperties:
* type: string
* wrapperStyle:
* type: object
* description: Style of the new ad banner's wrapper
* additionalProperties:
* type: string
* elementToMeasureSelector:
* type: string
* description: A selector of the element which should be measured to define banner size
Expand Down
8 changes: 7 additions & 1 deletion src/utils/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const adPlacesRulesSchema = arraySchema()
.required(),
stylesOverrides: arraySchema().of(adStylesOverridesSchema.clone().required()),
shouldHideOriginal: booleanSchema(),
isNative: booleanSchema(),
extVersion: versionRangeSchema.clone().required()
})
.required()
Expand Down Expand Up @@ -158,9 +159,14 @@ const permanentAdPlacesRulesSchema = arraySchema()
insertBeforeSelector: cssSelectorSchema,
insertAfterSelector: cssSelectorSchema,
insertionsCount: numberSchema().integer().min(1),
shouldUseDivWrapper: booleanSchema().required(),
shouldUseDivWrapper: booleanSchema(),
wrapperType: stringSchema().oneOf(['div', 'tbody']),
colsBefore: numberSchema().integer().min(0),
colspan: numberSchema().integer().min(1),
colsAfter: numberSchema().integer().min(0),
elementStyle: styleSchema,
divWrapperStyle: styleSchema,
wrapperStyle: styleSchema,
elementToMeasureSelector: cssSelectorSchema,
stylesOverrides: arraySchema().of(adStylesOverridesSchema.clone().required()),
shouldHideOriginal: booleanSchema(),
Expand Down

0 comments on commit e5d44b6

Please sign in to comment.