@mux/ai 0.24.0 → 0.26.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.d.ts CHANGED
@@ -9,7 +9,7 @@ import '@ai-sdk/google';
9
9
  import '@ai-sdk/openai';
10
10
  import '@mux/mux-node';
11
11
 
12
- var version = "0.24.0";
12
+ var version = "0.26.0";
13
13
 
14
14
  type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error";
15
15
  /**
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // package.json
8
- var version = "0.24.0";
8
+ var version = "0.26.0";
9
9
 
10
10
  // src/lib/language-codes.ts
11
11
  var ISO639_1_TO_3 = {
@@ -1601,19 +1601,30 @@ function getShotsPath(assetId) {
1601
1601
  return `/video/v1/assets/${assetId}/shots`;
1602
1602
  }
1603
1603
  function mapManifestShots(shots) {
1604
- return shots.map((shot, index) => {
1605
- const { start_time: startTime, image_url: imageUrl } = shot;
1604
+ let usedDeprecatedField = false;
1605
+ const mapped = shots.map((shot, index) => {
1606
+ const { start_time: startTime } = shot;
1607
+ const imageUrl = shot.shot_preview_image_url ?? shot.image_url;
1608
+ if (shot.shot_preview_image_url === void 0 && shot.image_url !== void 0) {
1609
+ usedDeprecatedField = true;
1610
+ }
1606
1611
  if (typeof startTime !== "number" || !Number.isFinite(startTime)) {
1607
1612
  throw new TypeError(`Invalid shot start_time in shots manifest at index ${index}`);
1608
1613
  }
1609
1614
  if (typeof imageUrl !== "string" || imageUrl.length === 0) {
1610
- throw new TypeError(`Invalid shot image_url in shots manifest at index ${index}`);
1615
+ throw new TypeError(`Invalid shot shot_preview_image_url in shots manifest at index ${index}`);
1611
1616
  }
1612
1617
  return {
1613
1618
  startTime,
1614
1619
  imageUrl
1615
1620
  };
1616
1621
  });
1622
+ if (usedDeprecatedField) {
1623
+ console.warn(
1624
+ "The 'image_url' field in the Mux shots manifest is deprecated and will be removed. Use 'shot_preview_image_url' instead."
1625
+ );
1626
+ }
1627
+ return mapped;
1617
1628
  }
1618
1629
  async function fetchShotsFromManifest(shotsManifestUrl) {
1619
1630
  const response = await fetch(shotsManifestUrl);
@@ -5850,6 +5861,15 @@ async function getModerationScores(assetId, options = {}) {
5850
5861
  import { generateText as generateText6, Output as Output6 } from "ai";
5851
5862
  import dedent6 from "dedent";
5852
5863
  import { z as z7 } from "zod";
5864
+
5865
+ // src/lib/markdown-normalization.ts
5866
+ var ESCAPED_LINE_BREAK_REGEX = /\\r\\n|\\n|\\r/g;
5867
+ var MULTIPLE_BLANK_LINES_REGEX = /\n{3,}/g;
5868
+ function normalizeMarkdownDescription(description) {
5869
+ return description.replace(ESCAPED_LINE_BREAK_REGEX, "\n").replace(/([^\n]) {2,}([*-]) (?=\S)/g, "$1\n$2 ").replace(/([.!?:;]) ([*-]) (?=\S)/g, "$1\n$2 ").replace(MULTIPLE_BLANK_LINES_REGEX, "\n\n");
5870
+ }
5871
+
5872
+ // src/workflows/summarization.ts
5853
5873
  var DEFAULT_SUMMARY_KEYWORD_LIMIT = 10;
5854
5874
  var DEFAULT_TITLE_LENGTH = 10;
5855
5875
  var DEFAULT_DESCRIPTION_LENGTH = 50;
@@ -6376,7 +6396,8 @@ async function getSummaryAndTags(assetId, options) {
6376
6396
  }
6377
6397
  }
6378
6398
  const scrubbedTitle = safety.scrub(analysisResponse.result.title, "title");
6379
- const scrubbedDescription = safety.scrub(analysisResponse.result.description, "description");
6399
+ const normalizedDescription = normalizeMarkdownDescription(analysisResponse.result.description);
6400
+ const scrubbedDescription = safety.scrub(normalizedDescription, "description");
6380
6401
  const scrubbedKeywords = (analysisResponse.result.keywords ?? []).map((kw, i) => safety.scrubDetailed(kw, `keywords[${i}]`)).filter((result) => !result.leaked).map((result) => result.text);
6381
6402
  return {
6382
6403
  assetId,