@gravity-ai/api 1.1.9 → 1.2.0
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.
- package/README.md +2 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +12 -6
- package/dist/index.mjs +12 -6
- package/dist/opentui.d.mts +1 -1
- package/dist/opentui.d.ts +1 -1
- package/dist/{types-C_krF5uC.d.mts → types-CnuFH98L.d.mts} +47 -3
- package/dist/{types-C_krF5uC.d.ts → types-CnuFH98L.d.ts} +47 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,8 +160,9 @@ const gravity = new Gravity({
|
|
|
160
160
|
|--------|------|---------|-------------|
|
|
161
161
|
| `apiKey` | `string` | `process.env.GRAVITY_API_KEY` | Gravity API key |
|
|
162
162
|
| `production` | `boolean` | `false` | `true` = real ads. `false` = test ads (no billing). |
|
|
163
|
+
| `alwaysReturn` | `boolean` | `false` | Test-only: return a default test ad instead of a 204 no-fill, so your slot always has an ad to render. Ignored when `production: true`. |
|
|
163
164
|
| `relevancy` | `number` | `0.2` | Minimum relevancy threshold (0-1). Lower = more ads. |
|
|
164
|
-
| `timeoutMs` | `number` | `
|
|
165
|
+
| `timeoutMs` | `number` | `4000` | Request timeout in ms |
|
|
165
166
|
| `excludedTopics` | `string[]` | — | Topics to exclude from ad matching |
|
|
166
167
|
| `gravityApi` | `string` | production URL | Custom API endpoint |
|
|
167
168
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GravityAdsOptions, I as IncomingAdRequest, M as MessageObject, P as PlacementObject, a as GravityAdsResult, b as GravityContextOverrides, c as GravityContext, A as AdParams, d as Ad } from './types-
|
|
2
|
-
export {
|
|
1
|
+
import { G as GravityAdsOptions, I as IncomingAdRequest, M as MessageObject, P as PlacementObject, a as GravityAdsResult, b as GravityContextOverrides, c as GravityContext, A as AdParams, d as Ad } from './types-CnuFH98L.mjs';
|
|
2
|
+
export { e as AdLayout, h as ApiErrorResponse, D as DeviceObject, k as Gender, g as LeadFormConfig, L as LeadFormField, f as LeadFormPrefill, i as Placement, R as RenderEnvelope, j as Role, U as UserObject } from './types-CnuFH98L.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Gravity ad client.
|
|
@@ -37,8 +37,9 @@ declare class Gravity {
|
|
|
37
37
|
* |--------|------|---------|-------------|
|
|
38
38
|
* | `apiKey` | `string` | `process.env.GRAVITY_API_KEY` | Gravity API key |
|
|
39
39
|
* | `production` | `boolean` | `false` | `true` = real ads. `false` = test ads (no billing). |
|
|
40
|
+
* | `alwaysReturn` | `boolean` | `false` | Test-only: return a default test ad instead of a 204 no-fill. Ignored in production. |
|
|
40
41
|
* | `relevancy` | `number` | `0.2` | Minimum relevancy threshold (0-1) |
|
|
41
|
-
* | `timeoutMs` | `number` | `
|
|
42
|
+
* | `timeoutMs` | `number` | `4000` | Request timeout in ms |
|
|
42
43
|
* | `excludedTopics` | `string[]` | — | Topics to exclude from ad matching |
|
|
43
44
|
* | `gravityApi` | `string` | production URL | Custom API endpoint |
|
|
44
45
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GravityAdsOptions, I as IncomingAdRequest, M as MessageObject, P as PlacementObject, a as GravityAdsResult, b as GravityContextOverrides, c as GravityContext, A as AdParams, d as Ad } from './types-
|
|
2
|
-
export {
|
|
1
|
+
import { G as GravityAdsOptions, I as IncomingAdRequest, M as MessageObject, P as PlacementObject, a as GravityAdsResult, b as GravityContextOverrides, c as GravityContext, A as AdParams, d as Ad } from './types-CnuFH98L.js';
|
|
2
|
+
export { e as AdLayout, h as ApiErrorResponse, D as DeviceObject, k as Gender, g as LeadFormConfig, L as LeadFormField, f as LeadFormPrefill, i as Placement, R as RenderEnvelope, j as Role, U as UserObject } from './types-CnuFH98L.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Gravity ad client.
|
|
@@ -37,8 +37,9 @@ declare class Gravity {
|
|
|
37
37
|
* |--------|------|---------|-------------|
|
|
38
38
|
* | `apiKey` | `string` | `process.env.GRAVITY_API_KEY` | Gravity API key |
|
|
39
39
|
* | `production` | `boolean` | `false` | `true` = real ads. `false` = test ads (no billing). |
|
|
40
|
+
* | `alwaysReturn` | `boolean` | `false` | Test-only: return a default test ad instead of a 204 no-fill. Ignored in production. |
|
|
40
41
|
* | `relevancy` | `number` | `0.2` | Minimum relevancy threshold (0-1) |
|
|
41
|
-
* | `timeoutMs` | `number` | `
|
|
42
|
+
* | `timeoutMs` | `number` | `4000` | Request timeout in ms |
|
|
42
43
|
* | `excludedTopics` | `string[]` | — | Topics to exclude from ad matching |
|
|
43
44
|
* | `gravityApi` | `string` | production URL | Custom API endpoint |
|
|
44
45
|
*/
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var require_package = __commonJS({
|
|
|
35
35
|
"package.json"(exports2, module2) {
|
|
36
36
|
module2.exports = {
|
|
37
37
|
name: "@gravity-ai/api",
|
|
38
|
-
version: "1.
|
|
38
|
+
version: "1.2.0",
|
|
39
39
|
description: "Gravity JS SDK for retrieving targeted advertisements",
|
|
40
40
|
main: "dist/index.js",
|
|
41
41
|
module: "dist/index.mjs",
|
|
@@ -137,7 +137,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
137
137
|
|
|
138
138
|
// ads.ts
|
|
139
139
|
var DEFAULT_GRAVITY_API = "https://server.trygravity.ai/api/v1/ad";
|
|
140
|
-
var DEFAULT_TIMEOUT_MS =
|
|
140
|
+
var DEFAULT_TIMEOUT_MS = 4e3;
|
|
141
141
|
function toGravityMessages(messages, maxTurns = 2) {
|
|
142
142
|
if (!messages || messages.length === 0) return [];
|
|
143
143
|
return messages.slice(-maxTurns).map((m) => ({
|
|
@@ -187,9 +187,12 @@ async function gravityAds(req, messages, placements, opts = {}) {
|
|
|
187
187
|
}
|
|
188
188
|
body.relevancy = opts.relevancy ?? 0.2;
|
|
189
189
|
body.testAd = opts.production === true ? false : true;
|
|
190
|
+
if (body.testAd && opts.alwaysReturn === true) body.alwaysReturn = true;
|
|
190
191
|
const supportsSpec = opts.supportsSpec ?? true;
|
|
191
192
|
body.supportsSpec = supportsSpec;
|
|
192
193
|
if (supportsSpec) body.specCapabilities = opts.specCapabilities ?? "web1";
|
|
194
|
+
if (opts.enableFrames ?? supportsSpec) body.supportsFrames = true;
|
|
195
|
+
if (body.testAd && opts.adLayout) body.adLayout = opts.adLayout;
|
|
193
196
|
if (opts.excludedTopics) body.excludedTopics = opts.excludedTopics;
|
|
194
197
|
const start = performance.now();
|
|
195
198
|
try {
|
|
@@ -203,8 +206,8 @@ async function gravityAds(req, messages, placements, opts = {}) {
|
|
|
203
206
|
signal: AbortSignal.timeout(timeoutMs)
|
|
204
207
|
});
|
|
205
208
|
const elapsed = (performance.now() - start).toFixed(0);
|
|
206
|
-
if (res.status === 204) {
|
|
207
|
-
return { ads: [], status:
|
|
209
|
+
if (res.status === 204 || res.status === 202) {
|
|
210
|
+
return { ads: [], status: res.status, elapsed, requestBody: body };
|
|
208
211
|
}
|
|
209
212
|
if (!res.ok) {
|
|
210
213
|
const errText = await res.text().catch(() => "");
|
|
@@ -235,8 +238,9 @@ var Gravity = class {
|
|
|
235
238
|
* |--------|------|---------|-------------|
|
|
236
239
|
* | `apiKey` | `string` | `process.env.GRAVITY_API_KEY` | Gravity API key |
|
|
237
240
|
* | `production` | `boolean` | `false` | `true` = real ads. `false` = test ads (no billing). |
|
|
241
|
+
* | `alwaysReturn` | `boolean` | `false` | Test-only: return a default test ad instead of a 204 no-fill. Ignored in production. |
|
|
238
242
|
* | `relevancy` | `number` | `0.2` | Minimum relevancy threshold (0-1) |
|
|
239
|
-
* | `timeoutMs` | `number` | `
|
|
243
|
+
* | `timeoutMs` | `number` | `4000` | Request timeout in ms |
|
|
240
244
|
* | `excludedTopics` | `string[]` | — | Topics to exclude from ad matching |
|
|
241
245
|
* | `gravityApi` | `string` | production URL | Custom API endpoint |
|
|
242
246
|
*/
|
|
@@ -579,8 +583,10 @@ var Client = class {
|
|
|
579
583
|
async getAd(params) {
|
|
580
584
|
try {
|
|
581
585
|
const supportsSpec = params.supportsSpec ?? true;
|
|
586
|
+
const { enableFrames, ...requestParams } = params;
|
|
582
587
|
const body = {
|
|
583
|
-
...
|
|
588
|
+
...requestParams,
|
|
589
|
+
...enableFrames ?? supportsSpec ? { supportsFrames: true } : {},
|
|
584
590
|
supportsSpec,
|
|
585
591
|
...supportsSpec ? { specCapabilities: params.specCapabilities ?? "web1" } : { specCapabilities: void 0 },
|
|
586
592
|
excludedTopics: params.excludedTopics ?? this.excludedTopics,
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ var require_package = __commonJS({
|
|
|
8
8
|
"package.json"(exports, module) {
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@gravity-ai/api",
|
|
11
|
-
version: "1.
|
|
11
|
+
version: "1.2.0",
|
|
12
12
|
description: "Gravity JS SDK for retrieving targeted advertisements",
|
|
13
13
|
main: "dist/index.js",
|
|
14
14
|
module: "dist/index.mjs",
|
|
@@ -92,7 +92,7 @@ var require_package = __commonJS({
|
|
|
92
92
|
|
|
93
93
|
// ads.ts
|
|
94
94
|
var DEFAULT_GRAVITY_API = "https://server.trygravity.ai/api/v1/ad";
|
|
95
|
-
var DEFAULT_TIMEOUT_MS =
|
|
95
|
+
var DEFAULT_TIMEOUT_MS = 4e3;
|
|
96
96
|
function toGravityMessages(messages, maxTurns = 2) {
|
|
97
97
|
if (!messages || messages.length === 0) return [];
|
|
98
98
|
return messages.slice(-maxTurns).map((m) => ({
|
|
@@ -142,9 +142,12 @@ async function gravityAds(req, messages, placements, opts = {}) {
|
|
|
142
142
|
}
|
|
143
143
|
body.relevancy = opts.relevancy ?? 0.2;
|
|
144
144
|
body.testAd = opts.production === true ? false : true;
|
|
145
|
+
if (body.testAd && opts.alwaysReturn === true) body.alwaysReturn = true;
|
|
145
146
|
const supportsSpec = opts.supportsSpec ?? true;
|
|
146
147
|
body.supportsSpec = supportsSpec;
|
|
147
148
|
if (supportsSpec) body.specCapabilities = opts.specCapabilities ?? "web1";
|
|
149
|
+
if (opts.enableFrames ?? supportsSpec) body.supportsFrames = true;
|
|
150
|
+
if (body.testAd && opts.adLayout) body.adLayout = opts.adLayout;
|
|
148
151
|
if (opts.excludedTopics) body.excludedTopics = opts.excludedTopics;
|
|
149
152
|
const start = performance.now();
|
|
150
153
|
try {
|
|
@@ -158,8 +161,8 @@ async function gravityAds(req, messages, placements, opts = {}) {
|
|
|
158
161
|
signal: AbortSignal.timeout(timeoutMs)
|
|
159
162
|
});
|
|
160
163
|
const elapsed = (performance.now() - start).toFixed(0);
|
|
161
|
-
if (res.status === 204) {
|
|
162
|
-
return { ads: [], status:
|
|
164
|
+
if (res.status === 204 || res.status === 202) {
|
|
165
|
+
return { ads: [], status: res.status, elapsed, requestBody: body };
|
|
163
166
|
}
|
|
164
167
|
if (!res.ok) {
|
|
165
168
|
const errText = await res.text().catch(() => "");
|
|
@@ -190,8 +193,9 @@ var Gravity = class {
|
|
|
190
193
|
* |--------|------|---------|-------------|
|
|
191
194
|
* | `apiKey` | `string` | `process.env.GRAVITY_API_KEY` | Gravity API key |
|
|
192
195
|
* | `production` | `boolean` | `false` | `true` = real ads. `false` = test ads (no billing). |
|
|
196
|
+
* | `alwaysReturn` | `boolean` | `false` | Test-only: return a default test ad instead of a 204 no-fill. Ignored in production. |
|
|
193
197
|
* | `relevancy` | `number` | `0.2` | Minimum relevancy threshold (0-1) |
|
|
194
|
-
* | `timeoutMs` | `number` | `
|
|
198
|
+
* | `timeoutMs` | `number` | `4000` | Request timeout in ms |
|
|
195
199
|
* | `excludedTopics` | `string[]` | — | Topics to exclude from ad matching |
|
|
196
200
|
* | `gravityApi` | `string` | production URL | Custom API endpoint |
|
|
197
201
|
*/
|
|
@@ -534,8 +538,10 @@ var Client = class {
|
|
|
534
538
|
async getAd(params) {
|
|
535
539
|
try {
|
|
536
540
|
const supportsSpec = params.supportsSpec ?? true;
|
|
541
|
+
const { enableFrames, ...requestParams } = params;
|
|
537
542
|
const body = {
|
|
538
|
-
...
|
|
543
|
+
...requestParams,
|
|
544
|
+
...enableFrames ?? supportsSpec ? { supportsFrames: true } : {},
|
|
539
545
|
supportsSpec,
|
|
540
546
|
...supportsSpec ? { specCapabilities: params.specCapabilities ?? "web1" } : { specCapabilities: void 0 },
|
|
541
547
|
excludedTopics: params.excludedTopics ?? this.excludedTopics,
|
package/dist/opentui.d.mts
CHANGED
package/dist/opentui.d.ts
CHANGED
|
@@ -136,6 +136,19 @@ interface AdParams {
|
|
|
136
136
|
supportsSpec?: boolean;
|
|
137
137
|
/** Spec capability profile. Default: `"web1"`. */
|
|
138
138
|
specCapabilities?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Declare support for iframe compositions (rich HTML creatives hosted in
|
|
141
|
+
* a sandboxed iframe). Defaults to `true`; the engine only serves frames
|
|
142
|
+
* to publishers it has enabled server-side. Set `false` to opt out, e.g.
|
|
143
|
+
* when rendering ads with your own markup.
|
|
144
|
+
*/
|
|
145
|
+
enableFrames?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* @deprecated The engine picks the image layout per publisher. Only sent
|
|
148
|
+
* on test ads (`production` unset) to preview `image_left` /
|
|
149
|
+
* `image_right` / `image_top`.
|
|
150
|
+
*/
|
|
151
|
+
adLayout?: AdLayout;
|
|
139
152
|
/**
|
|
140
153
|
* Additional custom fields for publisher-specific targeting
|
|
141
154
|
* @description Any additional key-value pairs will be passed to the API
|
|
@@ -218,7 +231,7 @@ interface LeadFormConfig {
|
|
|
218
231
|
submit_url: string;
|
|
219
232
|
}
|
|
220
233
|
/** A field on the ad payload that a renderer-spec node can bind to. */
|
|
221
|
-
type RendererSpecAdField = 'adText' | 'title' | 'cta' | 'brandName' | 'url' | 'favicon';
|
|
234
|
+
type RendererSpecAdField = 'adText' | 'title' | 'cta' | 'brandName' | 'url' | 'favicon' | 'brandImage';
|
|
222
235
|
type RendererSpecNodeType = 'box' | 'text' | 'image' | 'link';
|
|
223
236
|
/**
|
|
224
237
|
* A single node in a server-delivered renderer spec. Pure data — nodes map
|
|
@@ -255,6 +268,18 @@ interface RendererSpec {
|
|
|
255
268
|
/** Root node of the layout tree. */
|
|
256
269
|
root: RendererSpecNode;
|
|
257
270
|
}
|
|
271
|
+
type AdLayout = 'image_left' | 'image_right' | 'image_top';
|
|
272
|
+
/**
|
|
273
|
+
* How the slot should paint the ad. `iframe`: host `frameUrl` in a sandboxed
|
|
274
|
+
* iframe, painting `fallback` if it fails. `spec`: paint `renderer_spec`
|
|
275
|
+
* (`layout` set for image layouts). `native`: the SDK's built-in look.
|
|
276
|
+
*/
|
|
277
|
+
interface RenderEnvelope {
|
|
278
|
+
mode: 'iframe' | 'spec' | 'native';
|
|
279
|
+
frameUrl?: string;
|
|
280
|
+
fallback?: 'spec' | 'native';
|
|
281
|
+
layout?: AdLayout;
|
|
282
|
+
}
|
|
258
283
|
interface Ad {
|
|
259
284
|
/** The advertisement copy text */
|
|
260
285
|
adText: string;
|
|
@@ -268,6 +293,10 @@ interface Ad {
|
|
|
268
293
|
url?: string;
|
|
269
294
|
/** Favicon URL */
|
|
270
295
|
favicon?: string;
|
|
296
|
+
/** Ad image URL (campaign image), bound by image-layout specs */
|
|
297
|
+
brandImage?: string;
|
|
298
|
+
/** Render envelope: which mode the slot should paint this ad in */
|
|
299
|
+
render?: RenderEnvelope;
|
|
271
300
|
/** Impression tracking URL - fire this when ad is displayed */
|
|
272
301
|
impUrl?: string;
|
|
273
302
|
/** Click-through tracking URL - use this as href for ad clicks */
|
|
@@ -367,7 +396,7 @@ interface GravityAdsOptions {
|
|
|
367
396
|
apiKey?: string;
|
|
368
397
|
/** Gravity ad endpoint URL. Defaults to production. */
|
|
369
398
|
gravityApi?: string;
|
|
370
|
-
/** Abort after this many ms. Default: `
|
|
399
|
+
/** Abort after this many ms. Default: `4000`. */
|
|
371
400
|
timeoutMs?: number;
|
|
372
401
|
/** Minimum relevancy threshold (0-1). Default: `0.2`. */
|
|
373
402
|
relevancy?: number;
|
|
@@ -376,6 +405,12 @@ interface GravityAdsOptions {
|
|
|
376
405
|
* Pass `production: true` when you're ready to go live.
|
|
377
406
|
*/
|
|
378
407
|
production?: boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Test-only: when `true` the engine returns a default Gravity test ad
|
|
410
|
+
* instead of a 204 no-fill, so the slot always has something to render.
|
|
411
|
+
* Ignored when `production: true`.
|
|
412
|
+
*/
|
|
413
|
+
alwaysReturn?: boolean;
|
|
379
414
|
/** Topics to exclude from ad matching. */
|
|
380
415
|
excludedTopics?: string[];
|
|
381
416
|
/**
|
|
@@ -387,6 +422,15 @@ interface GravityAdsOptions {
|
|
|
387
422
|
supportsSpec?: boolean;
|
|
388
423
|
/** Spec capability profile sent when `supportsSpec` is on. Default: `"web1"`. */
|
|
389
424
|
specCapabilities?: string;
|
|
425
|
+
/**
|
|
426
|
+
* Declare support for iframe compositions (rich HTML creatives hosted in
|
|
427
|
+
* a sandboxed iframe). Defaults to `true`; the engine only serves frames
|
|
428
|
+
* to publishers it has enabled server-side. Set `false` to opt out, e.g.
|
|
429
|
+
* when rendering ads with your own markup.
|
|
430
|
+
*/
|
|
431
|
+
enableFrames?: boolean;
|
|
432
|
+
/** @deprecated See {@link AdParams.adLayout}. */
|
|
433
|
+
adLayout?: AdLayout;
|
|
390
434
|
}
|
|
391
435
|
/** Result returned by `gravityAds()`. Never throws. */
|
|
392
436
|
interface GravityAdsResult {
|
|
@@ -420,4 +464,4 @@ interface IncomingAdRequest {
|
|
|
420
464
|
ip?: string;
|
|
421
465
|
}
|
|
422
466
|
|
|
423
|
-
export type { AdParams as A, DeviceObject as D, GravityAdsOptions as G, IncomingAdRequest as I, LeadFormField as L, MessageObject as M, PlacementObject as P,
|
|
467
|
+
export type { AdParams as A, DeviceObject as D, GravityAdsOptions as G, IncomingAdRequest as I, LeadFormField as L, MessageObject as M, PlacementObject as P, RenderEnvelope as R, UserObject as U, GravityAdsResult as a, GravityContextOverrides as b, GravityContext as c, Ad as d, AdLayout as e, LeadFormPrefill as f, LeadFormConfig as g, ApiErrorResponse as h, Placement as i, Role as j, Gender as k };
|
|
@@ -136,6 +136,19 @@ interface AdParams {
|
|
|
136
136
|
supportsSpec?: boolean;
|
|
137
137
|
/** Spec capability profile. Default: `"web1"`. */
|
|
138
138
|
specCapabilities?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Declare support for iframe compositions (rich HTML creatives hosted in
|
|
141
|
+
* a sandboxed iframe). Defaults to `true`; the engine only serves frames
|
|
142
|
+
* to publishers it has enabled server-side. Set `false` to opt out, e.g.
|
|
143
|
+
* when rendering ads with your own markup.
|
|
144
|
+
*/
|
|
145
|
+
enableFrames?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* @deprecated The engine picks the image layout per publisher. Only sent
|
|
148
|
+
* on test ads (`production` unset) to preview `image_left` /
|
|
149
|
+
* `image_right` / `image_top`.
|
|
150
|
+
*/
|
|
151
|
+
adLayout?: AdLayout;
|
|
139
152
|
/**
|
|
140
153
|
* Additional custom fields for publisher-specific targeting
|
|
141
154
|
* @description Any additional key-value pairs will be passed to the API
|
|
@@ -218,7 +231,7 @@ interface LeadFormConfig {
|
|
|
218
231
|
submit_url: string;
|
|
219
232
|
}
|
|
220
233
|
/** A field on the ad payload that a renderer-spec node can bind to. */
|
|
221
|
-
type RendererSpecAdField = 'adText' | 'title' | 'cta' | 'brandName' | 'url' | 'favicon';
|
|
234
|
+
type RendererSpecAdField = 'adText' | 'title' | 'cta' | 'brandName' | 'url' | 'favicon' | 'brandImage';
|
|
222
235
|
type RendererSpecNodeType = 'box' | 'text' | 'image' | 'link';
|
|
223
236
|
/**
|
|
224
237
|
* A single node in a server-delivered renderer spec. Pure data — nodes map
|
|
@@ -255,6 +268,18 @@ interface RendererSpec {
|
|
|
255
268
|
/** Root node of the layout tree. */
|
|
256
269
|
root: RendererSpecNode;
|
|
257
270
|
}
|
|
271
|
+
type AdLayout = 'image_left' | 'image_right' | 'image_top';
|
|
272
|
+
/**
|
|
273
|
+
* How the slot should paint the ad. `iframe`: host `frameUrl` in a sandboxed
|
|
274
|
+
* iframe, painting `fallback` if it fails. `spec`: paint `renderer_spec`
|
|
275
|
+
* (`layout` set for image layouts). `native`: the SDK's built-in look.
|
|
276
|
+
*/
|
|
277
|
+
interface RenderEnvelope {
|
|
278
|
+
mode: 'iframe' | 'spec' | 'native';
|
|
279
|
+
frameUrl?: string;
|
|
280
|
+
fallback?: 'spec' | 'native';
|
|
281
|
+
layout?: AdLayout;
|
|
282
|
+
}
|
|
258
283
|
interface Ad {
|
|
259
284
|
/** The advertisement copy text */
|
|
260
285
|
adText: string;
|
|
@@ -268,6 +293,10 @@ interface Ad {
|
|
|
268
293
|
url?: string;
|
|
269
294
|
/** Favicon URL */
|
|
270
295
|
favicon?: string;
|
|
296
|
+
/** Ad image URL (campaign image), bound by image-layout specs */
|
|
297
|
+
brandImage?: string;
|
|
298
|
+
/** Render envelope: which mode the slot should paint this ad in */
|
|
299
|
+
render?: RenderEnvelope;
|
|
271
300
|
/** Impression tracking URL - fire this when ad is displayed */
|
|
272
301
|
impUrl?: string;
|
|
273
302
|
/** Click-through tracking URL - use this as href for ad clicks */
|
|
@@ -367,7 +396,7 @@ interface GravityAdsOptions {
|
|
|
367
396
|
apiKey?: string;
|
|
368
397
|
/** Gravity ad endpoint URL. Defaults to production. */
|
|
369
398
|
gravityApi?: string;
|
|
370
|
-
/** Abort after this many ms. Default: `
|
|
399
|
+
/** Abort after this many ms. Default: `4000`. */
|
|
371
400
|
timeoutMs?: number;
|
|
372
401
|
/** Minimum relevancy threshold (0-1). Default: `0.2`. */
|
|
373
402
|
relevancy?: number;
|
|
@@ -376,6 +405,12 @@ interface GravityAdsOptions {
|
|
|
376
405
|
* Pass `production: true` when you're ready to go live.
|
|
377
406
|
*/
|
|
378
407
|
production?: boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Test-only: when `true` the engine returns a default Gravity test ad
|
|
410
|
+
* instead of a 204 no-fill, so the slot always has something to render.
|
|
411
|
+
* Ignored when `production: true`.
|
|
412
|
+
*/
|
|
413
|
+
alwaysReturn?: boolean;
|
|
379
414
|
/** Topics to exclude from ad matching. */
|
|
380
415
|
excludedTopics?: string[];
|
|
381
416
|
/**
|
|
@@ -387,6 +422,15 @@ interface GravityAdsOptions {
|
|
|
387
422
|
supportsSpec?: boolean;
|
|
388
423
|
/** Spec capability profile sent when `supportsSpec` is on. Default: `"web1"`. */
|
|
389
424
|
specCapabilities?: string;
|
|
425
|
+
/**
|
|
426
|
+
* Declare support for iframe compositions (rich HTML creatives hosted in
|
|
427
|
+
* a sandboxed iframe). Defaults to `true`; the engine only serves frames
|
|
428
|
+
* to publishers it has enabled server-side. Set `false` to opt out, e.g.
|
|
429
|
+
* when rendering ads with your own markup.
|
|
430
|
+
*/
|
|
431
|
+
enableFrames?: boolean;
|
|
432
|
+
/** @deprecated See {@link AdParams.adLayout}. */
|
|
433
|
+
adLayout?: AdLayout;
|
|
390
434
|
}
|
|
391
435
|
/** Result returned by `gravityAds()`. Never throws. */
|
|
392
436
|
interface GravityAdsResult {
|
|
@@ -420,4 +464,4 @@ interface IncomingAdRequest {
|
|
|
420
464
|
ip?: string;
|
|
421
465
|
}
|
|
422
466
|
|
|
423
|
-
export type { AdParams as A, DeviceObject as D, GravityAdsOptions as G, IncomingAdRequest as I, LeadFormField as L, MessageObject as M, PlacementObject as P,
|
|
467
|
+
export type { AdParams as A, DeviceObject as D, GravityAdsOptions as G, IncomingAdRequest as I, LeadFormField as L, MessageObject as M, PlacementObject as P, RenderEnvelope as R, UserObject as U, GravityAdsResult as a, GravityContextOverrides as b, GravityContext as c, Ad as d, AdLayout as e, LeadFormPrefill as f, LeadFormConfig as g, ApiErrorResponse as h, Placement as i, Role as j, Gender as k };
|