@gravity-ai/api 1.1.9 → 1.2.1

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 CHANGED
@@ -109,7 +109,7 @@ Ad latency never blocks the chat response.
109
109
 
110
110
  ## Server — Python
111
111
 
112
- For Python backends (FastAPI, Django, Flask), use the [`gravity-py`](https://github.com/Try-Gravity/gravity-py) package:
112
+ For Python backends (FastAPI, Django, Flask), use the [`gravity-sdk`](https://docs.trygravity.ai/sdks/python) package:
113
113
 
114
114
  ```bash
115
115
  pip install gravity-sdk
@@ -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` | `3000` | Request timeout in ms |
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-C_krF5uC.mjs';
2
- export { g as ApiErrorResponse, D as DeviceObject, i as Gender, f as LeadFormConfig, L as LeadFormField, e as LeadFormPrefill, h as Placement, R as Role, U as UserObject } from './types-C_krF5uC.mjs';
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` | `3000` | Request timeout in ms |
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-C_krF5uC.js';
2
- export { g as ApiErrorResponse, D as DeviceObject, i as Gender, f as LeadFormConfig, L as LeadFormField, e as LeadFormPrefill, h as Placement, R as Role, U as UserObject } from './types-C_krF5uC.js';
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` | `3000` | Request timeout in ms |
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.1.9",
38
+ version: "1.2.1",
39
39
  description: "Gravity JS SDK for retrieving targeted advertisements",
40
40
  main: "dist/index.js",
41
41
  module: "dist/index.mjs",
@@ -81,15 +81,7 @@ var require_package = __commonJS({
81
81
  ],
82
82
  author: "Gravity Team",
83
83
  license: "MIT",
84
- homepage: "https://github.com/Try-Gravity/gravity-js#readme",
85
- repository: {
86
- type: "git",
87
- url: "git+https://github.com/Try-Gravity/gravity-js.git",
88
- directory: "packages/api"
89
- },
90
- bugs: {
91
- url: "https://github.com/Try-Gravity/gravity-js/issues"
92
- },
84
+ homepage: "https://docs.trygravity.ai/sdks/javascript",
93
85
  publishConfig: {
94
86
  access: "public"
95
87
  },
@@ -137,7 +129,7 @@ module.exports = __toCommonJS(index_exports);
137
129
 
138
130
  // ads.ts
139
131
  var DEFAULT_GRAVITY_API = "https://server.trygravity.ai/api/v1/ad";
140
- var DEFAULT_TIMEOUT_MS = 3e3;
132
+ var DEFAULT_TIMEOUT_MS = 4e3;
141
133
  function toGravityMessages(messages, maxTurns = 2) {
142
134
  if (!messages || messages.length === 0) return [];
143
135
  return messages.slice(-maxTurns).map((m) => ({
@@ -187,9 +179,12 @@ async function gravityAds(req, messages, placements, opts = {}) {
187
179
  }
188
180
  body.relevancy = opts.relevancy ?? 0.2;
189
181
  body.testAd = opts.production === true ? false : true;
182
+ if (body.testAd && opts.alwaysReturn === true) body.alwaysReturn = true;
190
183
  const supportsSpec = opts.supportsSpec ?? true;
191
184
  body.supportsSpec = supportsSpec;
192
185
  if (supportsSpec) body.specCapabilities = opts.specCapabilities ?? "web1";
186
+ if (opts.enableFrames ?? supportsSpec) body.supportsFrames = true;
187
+ if (body.testAd && opts.adLayout) body.adLayout = opts.adLayout;
193
188
  if (opts.excludedTopics) body.excludedTopics = opts.excludedTopics;
194
189
  const start = performance.now();
195
190
  try {
@@ -203,8 +198,8 @@ async function gravityAds(req, messages, placements, opts = {}) {
203
198
  signal: AbortSignal.timeout(timeoutMs)
204
199
  });
205
200
  const elapsed = (performance.now() - start).toFixed(0);
206
- if (res.status === 204) {
207
- return { ads: [], status: 204, elapsed, requestBody: body };
201
+ if (res.status === 204 || res.status === 202) {
202
+ return { ads: [], status: res.status, elapsed, requestBody: body };
208
203
  }
209
204
  if (!res.ok) {
210
205
  const errText = await res.text().catch(() => "");
@@ -235,8 +230,9 @@ var Gravity = class {
235
230
  * |--------|------|---------|-------------|
236
231
  * | `apiKey` | `string` | `process.env.GRAVITY_API_KEY` | Gravity API key |
237
232
  * | `production` | `boolean` | `false` | `true` = real ads. `false` = test ads (no billing). |
233
+ * | `alwaysReturn` | `boolean` | `false` | Test-only: return a default test ad instead of a 204 no-fill. Ignored in production. |
238
234
  * | `relevancy` | `number` | `0.2` | Minimum relevancy threshold (0-1) |
239
- * | `timeoutMs` | `number` | `3000` | Request timeout in ms |
235
+ * | `timeoutMs` | `number` | `4000` | Request timeout in ms |
240
236
  * | `excludedTopics` | `string[]` | — | Topics to exclude from ad matching |
241
237
  * | `gravityApi` | `string` | production URL | Custom API endpoint |
242
238
  */
@@ -579,8 +575,10 @@ var Client = class {
579
575
  async getAd(params) {
580
576
  try {
581
577
  const supportsSpec = params.supportsSpec ?? true;
578
+ const { enableFrames, ...requestParams } = params;
582
579
  const body = {
583
- ...params,
580
+ ...requestParams,
581
+ ...enableFrames ?? supportsSpec ? { supportsFrames: true } : {},
584
582
  supportsSpec,
585
583
  ...supportsSpec ? { specCapabilities: params.specCapabilities ?? "web1" } : { specCapabilities: void 0 },
586
584
  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.1.9",
11
+ version: "1.2.1",
12
12
  description: "Gravity JS SDK for retrieving targeted advertisements",
13
13
  main: "dist/index.js",
14
14
  module: "dist/index.mjs",
@@ -54,15 +54,7 @@ var require_package = __commonJS({
54
54
  ],
55
55
  author: "Gravity Team",
56
56
  license: "MIT",
57
- homepage: "https://github.com/Try-Gravity/gravity-js#readme",
58
- repository: {
59
- type: "git",
60
- url: "git+https://github.com/Try-Gravity/gravity-js.git",
61
- directory: "packages/api"
62
- },
63
- bugs: {
64
- url: "https://github.com/Try-Gravity/gravity-js/issues"
65
- },
57
+ homepage: "https://docs.trygravity.ai/sdks/javascript",
66
58
  publishConfig: {
67
59
  access: "public"
68
60
  },
@@ -92,7 +84,7 @@ var require_package = __commonJS({
92
84
 
93
85
  // ads.ts
94
86
  var DEFAULT_GRAVITY_API = "https://server.trygravity.ai/api/v1/ad";
95
- var DEFAULT_TIMEOUT_MS = 3e3;
87
+ var DEFAULT_TIMEOUT_MS = 4e3;
96
88
  function toGravityMessages(messages, maxTurns = 2) {
97
89
  if (!messages || messages.length === 0) return [];
98
90
  return messages.slice(-maxTurns).map((m) => ({
@@ -142,9 +134,12 @@ async function gravityAds(req, messages, placements, opts = {}) {
142
134
  }
143
135
  body.relevancy = opts.relevancy ?? 0.2;
144
136
  body.testAd = opts.production === true ? false : true;
137
+ if (body.testAd && opts.alwaysReturn === true) body.alwaysReturn = true;
145
138
  const supportsSpec = opts.supportsSpec ?? true;
146
139
  body.supportsSpec = supportsSpec;
147
140
  if (supportsSpec) body.specCapabilities = opts.specCapabilities ?? "web1";
141
+ if (opts.enableFrames ?? supportsSpec) body.supportsFrames = true;
142
+ if (body.testAd && opts.adLayout) body.adLayout = opts.adLayout;
148
143
  if (opts.excludedTopics) body.excludedTopics = opts.excludedTopics;
149
144
  const start = performance.now();
150
145
  try {
@@ -158,8 +153,8 @@ async function gravityAds(req, messages, placements, opts = {}) {
158
153
  signal: AbortSignal.timeout(timeoutMs)
159
154
  });
160
155
  const elapsed = (performance.now() - start).toFixed(0);
161
- if (res.status === 204) {
162
- return { ads: [], status: 204, elapsed, requestBody: body };
156
+ if (res.status === 204 || res.status === 202) {
157
+ return { ads: [], status: res.status, elapsed, requestBody: body };
163
158
  }
164
159
  if (!res.ok) {
165
160
  const errText = await res.text().catch(() => "");
@@ -190,8 +185,9 @@ var Gravity = class {
190
185
  * |--------|------|---------|-------------|
191
186
  * | `apiKey` | `string` | `process.env.GRAVITY_API_KEY` | Gravity API key |
192
187
  * | `production` | `boolean` | `false` | `true` = real ads. `false` = test ads (no billing). |
188
+ * | `alwaysReturn` | `boolean` | `false` | Test-only: return a default test ad instead of a 204 no-fill. Ignored in production. |
193
189
  * | `relevancy` | `number` | `0.2` | Minimum relevancy threshold (0-1) |
194
- * | `timeoutMs` | `number` | `3000` | Request timeout in ms |
190
+ * | `timeoutMs` | `number` | `4000` | Request timeout in ms |
195
191
  * | `excludedTopics` | `string[]` | — | Topics to exclude from ad matching |
196
192
  * | `gravityApi` | `string` | production URL | Custom API endpoint |
197
193
  */
@@ -534,8 +530,10 @@ var Client = class {
534
530
  async getAd(params) {
535
531
  try {
536
532
  const supportsSpec = params.supportsSpec ?? true;
533
+ const { enableFrames, ...requestParams } = params;
537
534
  const body = {
538
- ...params,
535
+ ...requestParams,
536
+ ...enableFrames ?? supportsSpec ? { supportsFrames: true } : {},
539
537
  supportsSpec,
540
538
  ...supportsSpec ? { specCapabilities: params.specCapabilities ?? "web1" } : { specCapabilities: void 0 },
541
539
  excludedTopics: params.excludedTopics ?? this.excludedTopics,
@@ -1,4 +1,4 @@
1
- import { d as Ad } from './types-C_krF5uC.mjs';
1
+ import { d as Ad } from './types-CnuFH98L.mjs';
2
2
 
3
3
  /**
4
4
  * @gravity-ai/api/opentui — Gravity ad rendering + tracking for OpenTUI terminals
package/dist/opentui.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { d as Ad } from './types-C_krF5uC.js';
1
+ import { d as Ad } from './types-CnuFH98L.js';
2
2
 
3
3
  /**
4
4
  * @gravity-ai/api/opentui — Gravity ad rendering + tracking for OpenTUI terminals
@@ -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: `3000`. */
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, Role as R, UserObject as U, GravityAdsResult as a, GravityContextOverrides as b, GravityContext as c, Ad as d, LeadFormPrefill as e, LeadFormConfig as f, ApiErrorResponse as g, Placement as h, Gender as i };
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: `3000`. */
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, Role as R, UserObject as U, GravityAdsResult as a, GravityContextOverrides as b, GravityContext as c, Ad as d, LeadFormPrefill as e, LeadFormConfig as f, ApiErrorResponse as g, Placement as h, Gender as i };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ai/api",
3
- "version": "1.1.9",
3
+ "version": "1.2.1",
4
4
  "description": "Gravity JS SDK for retrieving targeted advertisements",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -46,15 +46,7 @@
46
46
  ],
47
47
  "author": "Gravity Team",
48
48
  "license": "MIT",
49
- "homepage": "https://github.com/Try-Gravity/gravity-js#readme",
50
- "repository": {
51
- "type": "git",
52
- "url": "git+https://github.com/Try-Gravity/gravity-js.git",
53
- "directory": "packages/api"
54
- },
55
- "bugs": {
56
- "url": "https://github.com/Try-Gravity/gravity-js/issues"
57
- },
49
+ "homepage": "https://docs.trygravity.ai/sdks/javascript",
58
50
  "publishConfig": {
59
51
  "access": "public"
60
52
  },