codai-sdk 0.68.0 → 0.69.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/dist/index.js CHANGED
@@ -1985,6 +1985,8 @@ var Exports = class {
1985
1985
 
1986
1986
  //#endregion
1987
1987
  //#region src/resources/creatives.ts
1988
+ /** True when a `build` answer is the 202 carousel / print export job (poll `exports.wait(r.export.id)`). */
1989
+ const isPagedBuild = (r) => "export" in r && r.export != null;
1988
1990
  const path$5 = (id, tail = "") => `/v1/studio/creatives/${encodeURIComponent(id)}${tail}`;
1989
1991
  const lottieQuery = (q) => ({
1990
1992
  format: q.format,
@@ -2326,6 +2328,11 @@ var Creatives = class {
2326
2328
  * Studio document (`document`, exactly the `POST /v1/studio/documents` body). Converter notes come back in
2327
2329
  * `warnings`. The file is free; `preview: true` also queues a billed preview (poll it with
2328
2330
  * `documents.waitForPreview`). 400 `not_supported_for_kind` (video / image) or `invalid_spec`.
2331
+ *
2332
+ * A carousel (`format: 'png'` zip of slides or `'pdf'`) or print (`'pdf'`, PDF/X-4 with bleed and optional
2333
+ * `crop_marks`) creative answers HTTP 202 with a queued export job in `export` (`format_id` picks the format,
2334
+ * `quote_micro_usd` is held). Tell the two apart with `isPagedBuild`, poll with `exports.wait(r.export.id)` or use
2335
+ * `buildAndWait`.
2329
2336
  */
2330
2337
  build(id, body = {}, opts = {}) {
2331
2338
  return this.http.json(path$5(id, "/build"), {
@@ -2337,6 +2344,69 @@ var Creatives = class {
2337
2344
  });
2338
2345
  }
2339
2346
  /**
2347
+ * `build`, then — for a carousel / print creative — poll the export job until it has `succeeded` or `failed`
2348
+ * (`exports.wait`). Resolves to the 200 build for deck / doc / sheet, or to the finished `StudioExport`.
2349
+ */
2350
+ async buildAndWait(id, body = {}, opts = {}) {
2351
+ const r = await this.build(id, body, {
2352
+ ext: opts.ext,
2353
+ signal: opts.signal
2354
+ });
2355
+ if (!isPagedBuild(r)) return r;
2356
+ const e = r.export;
2357
+ if (e.status === "succeeded" || e.status === "failed") return e;
2358
+ return new Exports(this.http).wait(e.id, opts);
2359
+ }
2360
+ /**
2361
+ * Social post copy for a carousel, image or video creative: a caption + hashtags per platform (`platforms`,
2362
+ * default Instagram + LinkedIn; `language` `ro` (default) | `en`; optional `brief`, `tone`, `seq`) and one alt text
2363
+ * per slide, every answer repaired to the platform's hard limits (changes listed in `fixes`). Nothing is written to
2364
+ * the creative. Token-metered (`cost_micro_usd`) under a small wallet hold (402 `insufficient_funds`); 400
2365
+ * `not_supported_for_kind`, 422 `no_post_copy`, 504 `timeout`. `idempotencyKey` replays a retry (24 h).
2366
+ */
2367
+ postCopy(id, body = {}, opts = {}) {
2368
+ return this.http.json(path$5(id, "/post-copy"), {
2369
+ method: "POST",
2370
+ body: stripUndefined(body),
2371
+ headers: opts.idempotencyKey ? { "Idempotency-Key": opts.idempotencyKey } : void 0,
2372
+ ext: opts.ext,
2373
+ signal: opts.signal,
2374
+ noRetry: !opts.idempotencyKey
2375
+ });
2376
+ }
2377
+ /**
2378
+ * Edit a video clip by its transcript: delete word ranges (`remove: [{ from_word, to_word }]`, indexes into the
2379
+ * clip asset's cached transcript from `captions`) from video node `node_id`; the pieces are placed back to back as
2380
+ * one new version (`base_seq` rebased like `edit`, locks honoured unless `force`). Free. 409 `captions_required`
2381
+ * (run `captions` on that clip first) or `stale`; video creatives only.
2382
+ */
2383
+ transcriptCut(id, body, opts = {}) {
2384
+ return this.http.json(path$5(id, "/transcript-cut"), {
2385
+ method: "POST",
2386
+ body: stripUndefined(body),
2387
+ ext: opts.ext,
2388
+ signal: opts.signal,
2389
+ noRetry: true
2390
+ });
2391
+ }
2392
+ /**
2393
+ * Generate a new picture for an `image` node (`prompt`, optional `model`, `aspect_ratio` — default the closest
2394
+ * ratio of the node box — `base_seq`, `force`) and swap it in as one new version. A node with a `castId` sends that
2395
+ * cast entry's `refAssetIds` as references and appends its `description`, so the subject stays consistent. Billed
2396
+ * like `images.generate` (402 `insufficient_funds`); 400 `content_filtered` charges nothing. `idempotencyKey`
2397
+ * replays a retry (24 h).
2398
+ */
2399
+ regenerateNode(id, nodeId, body, opts = {}) {
2400
+ return this.http.json(path$5(id, `/nodes/${encodeURIComponent(nodeId)}/regenerate`), {
2401
+ method: "POST",
2402
+ body: stripUndefined(body),
2403
+ headers: opts.idempotencyKey ? { "Idempotency-Key": opts.idempotencyKey } : void 0,
2404
+ ext: opts.ext,
2405
+ signal: opts.signal,
2406
+ noRetry: !opts.idempotencyKey
2407
+ });
2408
+ }
2409
+ /**
2340
2410
  * Re-apply a brand kit (`brand_kit_id`) or a flat token map (`tokens`) to the creative as one new version: literal
2341
2411
  * colours equal to the old brand become token refs, `snap: true` maps every other colour to the nearest kit colour,
2342
2412
  * `fonts` (default true) sets heading / body font refs by role, locked nodes are skipped unless `force`. The kit
@@ -2802,7 +2872,8 @@ function abortableSleep$3(ms, signal) {
2802
2872
  }
2803
2873
  const toBody = (input) => ({
2804
2874
  asset_ids: input.assetIds ?? [],
2805
- params: input.params ?? {}
2875
+ params: input.params ?? {},
2876
+ ...input.maskPngB64 !== void 0 ? { mask_png_b64: input.maskPngB64 } : {}
2806
2877
  });
2807
2878
  /** A run answer is a job (async op, HTTP 202) when `object` is `media_op.job`. */
2808
2879
  const isMediaOpJob = (r) => r.object === "media_op.job";
@@ -6770,6 +6841,9 @@ const OPERATION_METHODS = {
6770
6841
  getStudioExport: "exports.retrieve",
6771
6842
  createCreativeFromDocument: "creatives.fromDocument",
6772
6843
  buildCreative: "creatives.build",
6844
+ writeCreativePostCopy: "creatives.postCopy",
6845
+ transcriptCutCreative: "creatives.transcriptCut",
6846
+ regenerateCreativeNode: "creatives.regenerateNode",
6773
6847
  createSystemOne: "systemOne.create",
6774
6848
  createTranscription: "audio.transcribe",
6775
6849
  createSpeech: "audio.speech",
@@ -7556,5 +7630,5 @@ function allKeys(obj) {
7556
7630
  }
7557
7631
 
7558
7632
  //#endregion
7559
- export { AbuseReports, Account, AgentRuns, Agents, Assets, Audio, Batches, Billing, BrandKits, Cards, Chat, ChatCompletions, Codai, Codai as default, CodaiApps, CodaiError, Creatives, Devices, Documents, Embeddings, EnvironmentFiles, EnvironmentJobs, EnvironmentMembers, EnvironmentPorts, EnvironmentSecrets, EnvironmentTasks, Environments, Exports, Feedback, Health, Heartbeats, Hosts, HttpClient, Images, JAM_CLOSE_CODES, JAM_SCALES, JAM_SUBPROTOCOL, Jam, JamSession, Keys, Lists, LyricsResource, MediaOps, Memory, Messages, Models, Music, Notifications, OPERATION_METHODS, OrgMembers, Orgs, OsGate, PROVENANCE_MAX_BYTES, PhoneModels, Productions, Projects, Prompts, Provenance, RESOLVE_ATTESTATION_PAYLOAD_TYPE, RESOLVE_OPERATION_METHODS, RESOLVE_TERMINAL_STATUSES, Realtime, RealtimeSession, Receipts, Referrals, Renders, Research, Resolve, ResolveError, ResolveInsufficientFundsError, Responses, STREAMING_OPERATIONS, SandboxFiles, Sandboxes, ScheduleExecutor, SchedulerHosts, Schedules, SessionControls, SessionEvents, SessionLease, SessionShares, Sessions, Settings, Sfx, Shares, SystemOne, TUS_CHUNK_BYTES, Tasks, Templates, Tokens, Tools, Transcripts, Triggers, Usage, Vault, VaultDevices, Verify, Videos, VoiceRevocations, extensionHeaders, frameJson, isAssetDto, isMediaOpJob, isMediaOpJobFinished, isProductionFinished, isResearchFinished, jamUrl, mergeToolCall, readSse, realtimeUrl, resolveAttestationStatement, settingsConflictCurrent, shareTokenFrom, uploadIdFromLocation, vaultUnlockMessage, verifyAttestationWithKeys, verifyResolveWebhook };
7633
+ export { AbuseReports, Account, AgentRuns, Agents, Assets, Audio, Batches, Billing, BrandKits, Cards, Chat, ChatCompletions, Codai, Codai as default, CodaiApps, CodaiError, Creatives, Devices, Documents, Embeddings, EnvironmentFiles, EnvironmentJobs, EnvironmentMembers, EnvironmentPorts, EnvironmentSecrets, EnvironmentTasks, Environments, Exports, Feedback, Health, Heartbeats, Hosts, HttpClient, Images, JAM_CLOSE_CODES, JAM_SCALES, JAM_SUBPROTOCOL, Jam, JamSession, Keys, Lists, LyricsResource, MediaOps, Memory, Messages, Models, Music, Notifications, OPERATION_METHODS, OrgMembers, Orgs, OsGate, PROVENANCE_MAX_BYTES, PhoneModels, Productions, Projects, Prompts, Provenance, RESOLVE_ATTESTATION_PAYLOAD_TYPE, RESOLVE_OPERATION_METHODS, RESOLVE_TERMINAL_STATUSES, Realtime, RealtimeSession, Receipts, Referrals, Renders, Research, Resolve, ResolveError, ResolveInsufficientFundsError, Responses, STREAMING_OPERATIONS, SandboxFiles, Sandboxes, ScheduleExecutor, SchedulerHosts, Schedules, SessionControls, SessionEvents, SessionLease, SessionShares, Sessions, Settings, Sfx, Shares, SystemOne, TUS_CHUNK_BYTES, Tasks, Templates, Tokens, Tools, Transcripts, Triggers, Usage, Vault, VaultDevices, Verify, Videos, VoiceRevocations, extensionHeaders, frameJson, isAssetDto, isMediaOpJob, isMediaOpJobFinished, isPagedBuild, isProductionFinished, isResearchFinished, jamUrl, mergeToolCall, readSse, realtimeUrl, resolveAttestationStatement, settingsConflictCurrent, shareTokenFrom, uploadIdFromLocation, vaultUnlockMessage, verifyAttestationWithKeys, verifyResolveWebhook };
7560
7634
  //# sourceMappingURL=index.js.map