@mediarithmics/plugins-nodejs-sdk
Version:
This is the mediarithmics nodejs to help plugin developers bootstrapping their plugin without having to deal with most of the plugin boilerplate
39 lines (38 loc) • 2.18 kB
TypeScript
import { TemplatingEngine } from '../../common/TemplatingInterface';
import { AdRendererBaseInstanceContext, AdRendererBasePlugin } from '../base/AdRendererBasePlugin';
export interface AdRendererTemplateInstanceContext extends AdRendererBaseInstanceContext {
width: string;
height: string;
creative_click_url?: string;
render_click_url?: (...args: unknown[]) => string;
ias_client_id?: string;
render_additional_html?: (...args: unknown[]) => string;
}
export declare abstract class AdRendererTemplatePlugin extends AdRendererBasePlugin<AdRendererBaseInstanceContext> {
/**
* The engineBuilder that can be used to compile the template
* during the InstanceContext building
*
* Have to be overriden (see examples)
*/
protected abstract engineBuilder: TemplatingEngine<unknown, string | undefined, (...args: unknown[]) => string>;
constructor(enableThrottling?: boolean);
/**
* Build a basic InstanceContext for "template" aware AdRenderer.
* This method can be overriden by your implementation (and you can then still call it with `super.instanceContextBuilder(creativeId, forceReload)`)
*
* This instanceContext takes the hypothesis that:
* - You have exactly one "URL" Plugin property on your instance
* - You have one "STRING" Plugin property on your instance called "additional_html" that contains 'templateable' HTML
* - You have one "STRING" Plugin property on your instance called "ias_client_id" that contains an IAS Client Id as a String
*
* If your Plugin instance don't respect those hypothesis, the returned InstanceContext will have `undefined` values in some/all fields.
*
* If you want to do Templating but you don't want to validate the above hypothesis, you're encouraged to build your Plugin Impl. by extending `AdRendererBasePlugin<AdRendererBaseInstanceContext>`
* instead of this class. This class should then only be used as an example.
*
* @param creativeId
* @param forceReload
*/
protected instanceContextBuilder(creativeId: string, forceReload?: boolean): Promise<AdRendererTemplateInstanceContext>;
}