@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.
@@ -4228,19 +4228,30 @@ function getShotsPath(assetId) {
4228
4228
  return `/video/v1/assets/${assetId}/shots`;
4229
4229
  }
4230
4230
  function mapManifestShots(shots) {
4231
- return shots.map((shot, index) => {
4232
- const { start_time: startTime, image_url: imageUrl } = shot;
4231
+ let usedDeprecatedField = false;
4232
+ const mapped = shots.map((shot, index) => {
4233
+ const { start_time: startTime } = shot;
4234
+ const imageUrl = shot.shot_preview_image_url ?? shot.image_url;
4235
+ if (shot.shot_preview_image_url === void 0 && shot.image_url !== void 0) {
4236
+ usedDeprecatedField = true;
4237
+ }
4233
4238
  if (typeof startTime !== "number" || !Number.isFinite(startTime)) {
4234
4239
  throw new TypeError(`Invalid shot start_time in shots manifest at index ${index}`);
4235
4240
  }
4236
4241
  if (typeof imageUrl !== "string" || imageUrl.length === 0) {
4237
- throw new TypeError(`Invalid shot image_url in shots manifest at index ${index}`);
4242
+ throw new TypeError(`Invalid shot shot_preview_image_url in shots manifest at index ${index}`);
4238
4243
  }
4239
4244
  return {
4240
4245
  startTime,
4241
4246
  imageUrl
4242
4247
  };
4243
4248
  });
4249
+ if (usedDeprecatedField) {
4250
+ console.warn(
4251
+ "The 'image_url' field in the Mux shots manifest is deprecated and will be removed. Use 'shot_preview_image_url' instead."
4252
+ );
4253
+ }
4254
+ return mapped;
4244
4255
  }
4245
4256
  async function fetchShotsFromManifest(shotsManifestUrl) {
4246
4257
  const response = await fetch(shotsManifestUrl);
@@ -5528,6 +5539,15 @@ async function getModerationScores(assetId, options = {}) {
5528
5539
  import { generateText as generateText6, Output as Output6 } from "ai";
5529
5540
  import dedent6 from "dedent";
5530
5541
  import { z as z7 } from "zod";
5542
+
5543
+ // src/lib/markdown-normalization.ts
5544
+ var ESCAPED_LINE_BREAK_REGEX = /\\r\\n|\\n|\\r/g;
5545
+ var MULTIPLE_BLANK_LINES_REGEX = /\n{3,}/g;
5546
+ function normalizeMarkdownDescription(description) {
5547
+ 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");
5548
+ }
5549
+
5550
+ // src/workflows/summarization.ts
5531
5551
  var DEFAULT_SUMMARY_KEYWORD_LIMIT = 10;
5532
5552
  var DEFAULT_TITLE_LENGTH = 10;
5533
5553
  var DEFAULT_DESCRIPTION_LENGTH = 50;
@@ -6054,7 +6074,8 @@ async function getSummaryAndTags(assetId, options) {
6054
6074
  }
6055
6075
  }
6056
6076
  const scrubbedTitle = safety.scrub(analysisResponse.result.title, "title");
6057
- const scrubbedDescription = safety.scrub(analysisResponse.result.description, "description");
6077
+ const normalizedDescription = normalizeMarkdownDescription(analysisResponse.result.description);
6078
+ const scrubbedDescription = safety.scrub(normalizedDescription, "description");
6058
6079
  const scrubbedKeywords = (analysisResponse.result.keywords ?? []).map((kw, i) => safety.scrubDetailed(kw, `keywords[${i}]`)).filter((result) => !result.leaked).map((result) => result.text);
6059
6080
  return {
6060
6081
  assetId,