From e5d44b6a86c7612358f067cf54e82dfe8e77ff8f Mon Sep 17 00:00:00 2001 From: Kornii Date: Thu, 11 Jul 2024 09:50:32 +0100 Subject: [PATCH] TW-1464 Prepare backend for new native ads (#165) (#166) * 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 --- src/advertising/external-ads.ts | 8 +++++- src/routers/slise-ad-rules/ad-places.ts | 36 ++++++++++++++++++++++++- src/utils/schemas.ts | 8 +++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/advertising/external-ads.ts b/src/advertising/external-ads.ts index a735339..16328b9 100644 --- a/src/advertising/external-ads.ts +++ b/src/advertising/external-ads.ts @@ -99,6 +99,7 @@ export interface AdPlacesRule extends ExtVersionConstraints { }; stylesOverrides?: AdStylesOverrides[]; shouldHideOriginal?: boolean; + isNative?: boolean; } export interface PermanentAdPlacesRule extends ExtVersionConstraints { @@ -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; divWrapperStyle?: Record; + wrapperStyle?: Record; elementToMeasureSelector?: string; stylesOverrides?: AdStylesOverrides[]; shouldHideOriginal?: boolean; diff --git a/src/routers/slise-ad-rules/ad-places.ts b/src/routers/slise-ad-rules/ad-places.ts index 169fd29..40058d1 100644 --- a/src/routers/slise-ad-rules/ad-places.ts +++ b/src/routers/slise-ad-rules/ad-places.ts @@ -108,6 +108,10 @@ const transformAdPlacesDictionary = (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/?$' @@ -158,7 +162,6 @@ const transformAdPlacesDictionary = (rules: Rec * - urlRegexes * - adSelector * - parentSelector - * - shouldUseDivWrapper * properties: * urlRegexes: * type: array @@ -233,6 +236,32 @@ const transformAdPlacesDictionary = (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 @@ -243,6 +272,11 @@ const transformAdPlacesDictionary = (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 diff --git a/src/utils/schemas.ts b/src/utils/schemas.ts index d624f45..1ffb518 100644 --- a/src/utils/schemas.ts +++ b/src/utils/schemas.ts @@ -124,6 +124,7 @@ const adPlacesRulesSchema = arraySchema() .required(), stylesOverrides: arraySchema().of(adStylesOverridesSchema.clone().required()), shouldHideOriginal: booleanSchema(), + isNative: booleanSchema(), extVersion: versionRangeSchema.clone().required() }) .required() @@ -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(),