@nodaro/shared 3.32.0 → 3.35.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.
Files changed (274) hide show
  1. package/dist/{chunk-VWGNPMJZ.cjs → chunk-24ZKPE33.cjs} +5 -5
  2. package/dist/{chunk-VWGNPMJZ.cjs.map → chunk-24ZKPE33.cjs.map} +1 -1
  3. package/dist/{chunk-CK3GK34R.js → chunk-2HIDE3QV.js} +9 -3
  4. package/dist/chunk-2HIDE3QV.js.map +1 -0
  5. package/dist/{chunk-WDIBOWAA.js → chunk-2HVFF5SS.js} +6 -6
  6. package/dist/chunk-2HVFF5SS.js.map +1 -0
  7. package/dist/{chunk-KHCBJ7KD.js → chunk-2QWNPYDG.js} +3 -3
  8. package/dist/{chunk-KHCBJ7KD.js.map → chunk-2QWNPYDG.js.map} +1 -1
  9. package/dist/{chunk-J6KHW2E5.cjs → chunk-3YG3MYDE.cjs} +153 -24
  10. package/dist/chunk-3YG3MYDE.cjs.map +1 -0
  11. package/dist/{chunk-ULXI7A6Q.cjs → chunk-5VNBQ4QK.cjs} +16 -16
  12. package/dist/{chunk-ULXI7A6Q.cjs.map → chunk-5VNBQ4QK.cjs.map} +1 -1
  13. package/dist/{chunk-5AUSSJIM.cjs → chunk-5ZCXWA7J.cjs} +232 -15
  14. package/dist/chunk-5ZCXWA7J.cjs.map +1 -0
  15. package/dist/{chunk-Z2OL5AJD.cjs → chunk-6F6GGX2W.cjs} +4 -3
  16. package/dist/chunk-6F6GGX2W.cjs.map +1 -0
  17. package/dist/{chunk-E2TGXG6X.cjs → chunk-72IFMNJE.cjs} +80 -52
  18. package/dist/chunk-72IFMNJE.cjs.map +1 -0
  19. package/dist/{chunk-NB72XWXQ.cjs → chunk-A5Z3IMSJ.cjs} +6 -6
  20. package/dist/{chunk-NB72XWXQ.cjs.map → chunk-A5Z3IMSJ.cjs.map} +1 -1
  21. package/dist/{chunk-NT6IJH4L.cjs → chunk-AGEZY4LL.cjs} +66 -47
  22. package/dist/chunk-AGEZY4LL.cjs.map +1 -0
  23. package/dist/{chunk-3CUFITU7.js → chunk-ANOQWAMU.js} +88 -54
  24. package/dist/chunk-ANOQWAMU.js.map +1 -0
  25. package/dist/{chunk-PRYE7AZQ.cjs → chunk-AWWOQH46.cjs} +7 -7
  26. package/dist/chunk-AWWOQH46.cjs.map +1 -0
  27. package/dist/{chunk-QELDJGDK.cjs → chunk-B7WJJHJS.cjs} +7 -4
  28. package/dist/chunk-B7WJJHJS.cjs.map +1 -0
  29. package/dist/{chunk-AVQK77G6.cjs → chunk-BBLE4UTG.cjs} +88 -54
  30. package/dist/chunk-BBLE4UTG.cjs.map +1 -0
  31. package/dist/{chunk-HGC5JNVA.cjs → chunk-BVVKMQKR.cjs} +9 -2
  32. package/dist/chunk-BVVKMQKR.cjs.map +1 -0
  33. package/dist/{chunk-YYV35XOS.js → chunk-C4R7BTBQ.js} +4 -3
  34. package/dist/chunk-C4R7BTBQ.js.map +1 -0
  35. package/dist/{chunk-AROWPFO2.js → chunk-ETXUOETU.js} +29 -36
  36. package/dist/chunk-ETXUOETU.js.map +1 -0
  37. package/dist/{chunk-S5DMKUWK.cjs → chunk-F4ZT5X2S.cjs} +11 -11
  38. package/dist/{chunk-S5DMKUWK.cjs.map → chunk-F4ZT5X2S.cjs.map} +1 -1
  39. package/dist/{chunk-YBPBK5KI.js → chunk-FKQJYMCO.js} +97 -23
  40. package/dist/chunk-FKQJYMCO.js.map +1 -0
  41. package/dist/{chunk-ZDFHA2EC.js → chunk-FVKCNAEQ.js} +51 -7
  42. package/dist/chunk-FVKCNAEQ.js.map +1 -0
  43. package/dist/{chunk-JSNV5O2F.cjs → chunk-GHBXS5RT.cjs} +4 -4
  44. package/dist/{chunk-JSNV5O2F.cjs.map → chunk-GHBXS5RT.cjs.map} +1 -1
  45. package/dist/{chunk-C57NEO3X.js → chunk-GKJRNIP4.js} +230 -16
  46. package/dist/chunk-GKJRNIP4.js.map +1 -0
  47. package/dist/{chunk-QNGNOU4Z.js → chunk-GRIMIJJ3.js} +3 -3
  48. package/dist/{chunk-QNGNOU4Z.js.map → chunk-GRIMIJJ3.js.map} +1 -1
  49. package/dist/{chunk-IEBZHTPE.js → chunk-GVHBHUFV.js} +34 -16
  50. package/dist/chunk-GVHBHUFV.js.map +1 -0
  51. package/dist/chunk-GZH2SIOF.cjs +99 -0
  52. package/dist/chunk-GZH2SIOF.cjs.map +1 -0
  53. package/dist/{chunk-YHRG7UOC.js → chunk-IJNQYMN7.js} +4 -4
  54. package/dist/{chunk-YHRG7UOC.js.map → chunk-IJNQYMN7.js.map} +1 -1
  55. package/dist/{chunk-JX5YZ4DH.cjs → chunk-IRUPCNW2.cjs} +49 -46
  56. package/dist/chunk-IRUPCNW2.cjs.map +1 -0
  57. package/dist/{chunk-JL4C5VJ7.cjs → chunk-J65CAOUV.cjs} +14 -2
  58. package/dist/chunk-J65CAOUV.cjs.map +1 -0
  59. package/dist/{chunk-ISJDAFKS.js → chunk-LJMNCSDG.js} +38 -15
  60. package/dist/chunk-LJMNCSDG.js.map +1 -0
  61. package/dist/{chunk-ZT77RY6R.js → chunk-MEN7VLQ5.js} +8 -5
  62. package/dist/chunk-MEN7VLQ5.js.map +1 -0
  63. package/dist/{chunk-VIWSWVAW.js → chunk-MUA5L25B.js} +125 -12
  64. package/dist/chunk-MUA5L25B.js.map +1 -0
  65. package/dist/{chunk-6IJOPRZP.cjs → chunk-NWXB4F6D.cjs} +21 -21
  66. package/dist/{chunk-6IJOPRZP.cjs.map → chunk-NWXB4F6D.cjs.map} +1 -1
  67. package/dist/{chunk-PQHS255G.js → chunk-OHSIVNJO.js} +3 -3
  68. package/dist/chunk-OHSIVNJO.js.map +1 -0
  69. package/dist/{chunk-LKAIXWK3.js → chunk-PVVO23LZ.js} +3 -3
  70. package/dist/{chunk-LKAIXWK3.js.map → chunk-PVVO23LZ.js.map} +1 -1
  71. package/dist/{chunk-XAMC4S53.js → chunk-Q4ZXDDWA.js} +3 -3
  72. package/dist/{chunk-XAMC4S53.js.map → chunk-Q4ZXDDWA.js.map} +1 -1
  73. package/dist/{chunk-EK362Q45.cjs → chunk-QIIG2QDP.cjs} +8 -8
  74. package/dist/{chunk-EK362Q45.cjs.map → chunk-QIIG2QDP.cjs.map} +1 -1
  75. package/dist/{chunk-Q4CDQ2KO.js → chunk-QXW6O56Z.js} +6 -6
  76. package/dist/chunk-QXW6O56Z.js.map +1 -0
  77. package/dist/{chunk-5PC6JBGJ.cjs → chunk-R2VF5NQG.cjs} +3 -3
  78. package/dist/chunk-R2VF5NQG.cjs.map +1 -0
  79. package/dist/{chunk-6DKDOWBL.js → chunk-RRI5YBUK.js} +6 -3
  80. package/dist/{chunk-QELDJGDK.cjs.map → chunk-RRI5YBUK.js.map} +1 -1
  81. package/dist/{chunk-RJL7RCEM.cjs → chunk-RUKFN3LJ.cjs} +6 -6
  82. package/dist/chunk-RUKFN3LJ.cjs.map +1 -0
  83. package/dist/chunk-TCBHVIMD.js +89 -0
  84. package/dist/chunk-TCBHVIMD.js.map +1 -0
  85. package/dist/{chunk-SES6GDBQ.cjs → chunk-UJJUX6NW.cjs} +59 -8
  86. package/dist/chunk-UJJUX6NW.cjs.map +1 -0
  87. package/dist/{chunk-ZRL2UFTH.cjs → chunk-V3N56Z2S.cjs} +101 -22
  88. package/dist/chunk-V3N56Z2S.cjs.map +1 -0
  89. package/dist/{chunk-Z4AZW6FY.js → chunk-W36WCZS2.js} +6 -6
  90. package/dist/{chunk-Z4AZW6FY.js.map → chunk-W36WCZS2.js.map} +1 -1
  91. package/dist/{chunk-M36G6SRP.js → chunk-WXNQMJ67.js} +14 -3
  92. package/dist/chunk-WXNQMJ67.js.map +1 -0
  93. package/dist/{chunk-O7PUQLJ3.cjs → chunk-XE5PE54B.cjs} +33 -40
  94. package/dist/chunk-XE5PE54B.cjs.map +1 -0
  95. package/dist/{chunk-LPW3XNC2.js → chunk-XJOBMAWW.js} +3 -3
  96. package/dist/{chunk-LPW3XNC2.js.map → chunk-XJOBMAWW.js.map} +1 -1
  97. package/dist/{chunk-5U7VLG43.js → chunk-XS7FI4JA.js} +3 -3
  98. package/dist/chunk-XS7FI4JA.js.map +1 -0
  99. package/dist/{chunk-O5MP52U2.cjs → chunk-YD3JA36S.cjs} +4 -4
  100. package/dist/{chunk-O5MP52U2.cjs.map → chunk-YD3JA36S.cjs.map} +1 -1
  101. package/dist/chunk-YYODFQEU.cjs +25 -0
  102. package/dist/chunk-YYODFQEU.cjs.map +1 -0
  103. package/dist/{chunk-RN3RMBJZ.js → chunk-ZXBSARZX.js} +4 -4
  104. package/dist/{chunk-RN3RMBJZ.js.map → chunk-ZXBSARZX.js.map} +1 -1
  105. package/dist/entries/apps.cjs +43 -42
  106. package/dist/entries/apps.d.cts +11 -2
  107. package/dist/entries/apps.d.ts +11 -2
  108. package/dist/entries/apps.js +8 -7
  109. package/dist/entries/catalogs.d.cts +1 -1
  110. package/dist/entries/catalogs.d.ts +1 -1
  111. package/dist/entries/credits.cjs +156 -152
  112. package/dist/entries/credits.d.cts +41 -10
  113. package/dist/entries/credits.d.ts +41 -10
  114. package/dist/entries/credits.js +8 -8
  115. package/dist/entries/edl.cjs +130 -102
  116. package/dist/entries/edl.d.cts +74 -3
  117. package/dist/entries/edl.d.ts +74 -3
  118. package/dist/entries/edl.js +2 -2
  119. package/dist/entries/entities.cjs +126 -122
  120. package/dist/entries/entities.d.cts +2 -2
  121. package/dist/entries/entities.d.ts +2 -2
  122. package/dist/entries/entities.js +1 -1
  123. package/dist/entries/i18n.cjs +11 -11
  124. package/dist/entries/i18n.d.cts +2 -2
  125. package/dist/entries/i18n.d.ts +2 -2
  126. package/dist/entries/i18n.js +1 -1
  127. package/dist/entries/llm-models.cjs +63 -43
  128. package/dist/entries/llm-models.d.cts +71 -4
  129. package/dist/entries/llm-models.d.ts +71 -4
  130. package/dist/entries/llm-models.js +1 -1
  131. package/dist/entries/media.cjs +45 -41
  132. package/dist/entries/media.d.cts +39 -1
  133. package/dist/entries/media.d.ts +39 -1
  134. package/dist/entries/media.js +1 -1
  135. package/dist/entries/model-catalog.cjs +75 -63
  136. package/dist/entries/model-catalog.d.cts +2 -2
  137. package/dist/entries/model-catalog.d.ts +2 -2
  138. package/dist/entries/model-catalog.js +4 -4
  139. package/dist/entries/models.cjs +274 -210
  140. package/dist/entries/models.d.cts +3 -3
  141. package/dist/entries/models.d.ts +3 -3
  142. package/dist/entries/models.js +5 -5
  143. package/dist/entries/nodes.cjs +222 -201
  144. package/dist/entries/nodes.d.cts +48 -8
  145. package/dist/entries/nodes.d.ts +48 -8
  146. package/dist/entries/nodes.js +10 -9
  147. package/dist/entries/pipeline.cjs +149 -149
  148. package/dist/entries/pipeline.d.cts +12 -8
  149. package/dist/entries/pipeline.d.ts +12 -8
  150. package/dist/entries/pipeline.js +3 -3
  151. package/dist/entries/social.cjs +174 -174
  152. package/dist/entries/social.d.cts +13 -5
  153. package/dist/entries/social.d.ts +13 -5
  154. package/dist/entries/social.js +2 -2
  155. package/dist/entries/types.d.cts +1 -1
  156. package/dist/entries/types.d.ts +1 -1
  157. package/dist/entries/ugc.cjs +71 -71
  158. package/dist/entries/ugc.js +4 -4
  159. package/dist/entries/video.cjs +115 -115
  160. package/dist/entries/video.d.cts +4 -3
  161. package/dist/entries/video.d.ts +4 -3
  162. package/dist/entries/video.js +4 -4
  163. package/dist/entries/workflow.cjs +96 -95
  164. package/dist/entries/workflow.d.cts +19 -20
  165. package/dist/entries/workflow.d.ts +19 -20
  166. package/dist/entries/workflow.js +2 -1
  167. package/dist/index.cjs +1720 -1563
  168. package/dist/index.d.cts +10 -10
  169. package/dist/index.d.ts +10 -10
  170. package/dist/index.js +26 -25
  171. package/dist/{model-catalog-flJYaa-g.d.ts → model-catalog-VIHGmQL2.d.cts} +113 -1
  172. package/dist/{model-catalog-flJYaa-g.d.cts → model-catalog-VIHGmQL2.d.ts} +113 -1
  173. package/dist/{presentation-utils-BIqiCzSA.d.cts → presentation-utils-A4i92SYo.d.cts} +3 -1
  174. package/dist/{presentation-utils-BdiObtwq.d.ts → presentation-utils-DjdPtM9k.d.ts} +3 -1
  175. package/dist/{scene-node-types-DjenYFLO.d.ts → scene-node-types-Cvbtf-0a.d.cts} +147 -6
  176. package/dist/{scene-node-types-DjenYFLO.d.cts → scene-node-types-Cvbtf-0a.d.ts} +147 -6
  177. package/dist/{types-DffyGSy5.d.ts → types-CU6SQnMS.d.cts} +0 -5
  178. package/dist/{types-DffyGSy5.d.cts → types-CU6SQnMS.d.ts} +0 -5
  179. package/dist/{types-BRlFPEru.d.cts → types-DzUBR7yr.d.cts} +8 -1
  180. package/dist/{types-BRlFPEru.d.ts → types-DzUBR7yr.d.ts} +8 -1
  181. package/package.json +1 -1
  182. package/src/__tests__/camera-switch-contract.test.ts +33 -1
  183. package/src/__tests__/character-mention-slug.test.ts +0 -8
  184. package/src/__tests__/effective-tier.test.ts +3 -14
  185. package/src/__tests__/fixtures/camera-switch-speaker-map-parity.json +178 -0
  186. package/src/__tests__/fixtures/root-exports.baseline.json +21 -0
  187. package/src/__tests__/fixtures/speaker-map-camera-ids.json +26 -0
  188. package/src/__tests__/gvp-supported-providers.test.ts +1 -0
  189. package/src/__tests__/i18n-locale-completeness.test.ts +38 -3
  190. package/src/__tests__/llm-models.test.ts +200 -20
  191. package/src/__tests__/model-makers.test.ts +76 -0
  192. package/src/__tests__/node-preset-extract.test.ts +10 -0
  193. package/src/__tests__/presentation-utils.test.ts +15 -0
  194. package/src/__tests__/preview-gate-use-case.test.ts +16 -1
  195. package/src/__tests__/private-host.test.ts +53 -0
  196. package/src/__tests__/producer-types.test.ts +19 -0
  197. package/src/__tests__/run-continuation.test.ts +4 -1
  198. package/src/__tests__/speaker-map-contract.test.ts +48 -0
  199. package/src/__tests__/unit-contract-compose.test.ts +129 -0
  200. package/src/__tests__/unit-contracts.test.ts +134 -0
  201. package/src/__tests__/use-case-types.test.ts +33 -0
  202. package/src/__tests__/video-collapse-parity.test.ts +10 -0
  203. package/src/__tests__/video-frame-slot.test.ts +85 -0
  204. package/src/__tests__/video-mode-aliases.test.ts +1 -0
  205. package/src/__tests__/video-reference-only.test.ts +117 -0
  206. package/src/__tests__/vidu-q4-catalog.test.ts +230 -0
  207. package/src/camera-switch-contract.ts +36 -2
  208. package/src/component-types.ts +9 -0
  209. package/src/credit-identifiers.ts +81 -23
  210. package/src/entity-asset-types.ts +13 -0
  211. package/src/entries/credits.ts +1 -0
  212. package/src/entries/edl.ts +2 -0
  213. package/src/entries/llm-models.ts +5 -0
  214. package/src/entries/media.ts +1 -0
  215. package/src/entries/model-catalog.ts +6 -0
  216. package/src/entries/models.ts +25 -0
  217. package/src/entries/nodes.ts +5 -1
  218. package/src/fan-out-rows.ts +36 -3
  219. package/src/generate-mask.ts +40 -0
  220. package/src/generated/unit-contracts.ts +58 -0
  221. package/src/i18n/types.ts +13 -2
  222. package/src/json-kinds.ts +24 -4
  223. package/src/llm-models.ts +184 -31
  224. package/src/meta-ads-scrape.ts +16 -8
  225. package/src/model-catalog.ts +285 -13
  226. package/src/model-constants.ts +260 -5
  227. package/src/node-default-mappings.ts +3 -0
  228. package/src/node-preset-extract.ts +8 -0
  229. package/src/pipeline-types.ts +3 -0
  230. package/src/presentation-utils.ts +19 -12
  231. package/src/preview-gate.ts +4 -2
  232. package/src/private-host.ts +89 -59
  233. package/src/producer-types.ts +19 -19
  234. package/src/run-continuation.ts +26 -4
  235. package/src/speaker-layouts.ts +8 -3
  236. package/src/speaker-map-contract.ts +77 -0
  237. package/src/unit-contract-compose.ts +55 -0
  238. package/src/use-case-types.ts +19 -0
  239. package/src/video-ui-defaults.ts +7 -5
  240. package/dist/chunk-3CUFITU7.js.map +0 -1
  241. package/dist/chunk-5AUSSJIM.cjs.map +0 -1
  242. package/dist/chunk-5PC6JBGJ.cjs.map +0 -1
  243. package/dist/chunk-5U7VLG43.js.map +0 -1
  244. package/dist/chunk-6DKDOWBL.js.map +0 -1
  245. package/dist/chunk-AROWPFO2.js.map +0 -1
  246. package/dist/chunk-AVQK77G6.cjs.map +0 -1
  247. package/dist/chunk-C57NEO3X.js.map +0 -1
  248. package/dist/chunk-CK3GK34R.js.map +0 -1
  249. package/dist/chunk-E2TGXG6X.cjs.map +0 -1
  250. package/dist/chunk-HGC5JNVA.cjs.map +0 -1
  251. package/dist/chunk-IEBZHTPE.js.map +0 -1
  252. package/dist/chunk-ISJDAFKS.js.map +0 -1
  253. package/dist/chunk-J6KHW2E5.cjs.map +0 -1
  254. package/dist/chunk-JL4C5VJ7.cjs.map +0 -1
  255. package/dist/chunk-JX5YZ4DH.cjs.map +0 -1
  256. package/dist/chunk-M36G6SRP.js.map +0 -1
  257. package/dist/chunk-NT6IJH4L.cjs.map +0 -1
  258. package/dist/chunk-O7PUQLJ3.cjs.map +0 -1
  259. package/dist/chunk-PQHS255G.js.map +0 -1
  260. package/dist/chunk-PRYE7AZQ.cjs.map +0 -1
  261. package/dist/chunk-Q4CDQ2KO.js.map +0 -1
  262. package/dist/chunk-RJL7RCEM.cjs.map +0 -1
  263. package/dist/chunk-SES6GDBQ.cjs.map +0 -1
  264. package/dist/chunk-VIWSWVAW.js.map +0 -1
  265. package/dist/chunk-WDIBOWAA.js.map +0 -1
  266. package/dist/chunk-WNG7HRVA.cjs +0 -25
  267. package/dist/chunk-WNG7HRVA.cjs.map +0 -1
  268. package/dist/chunk-YBPBK5KI.js.map +0 -1
  269. package/dist/chunk-YYV35XOS.js.map +0 -1
  270. package/dist/chunk-Z2OL5AJD.cjs.map +0 -1
  271. package/dist/chunk-ZDFHA2EC.js.map +0 -1
  272. package/dist/chunk-ZRL2UFTH.cjs.map +0 -1
  273. package/dist/chunk-ZT77RY6R.js.map +0 -1
  274. package/src/__tests__/__snapshots__/prompt-builder-segments.test.ts.snap +0 -65
@@ -0,0 +1,48 @@
1
+ import { describe, it, expect } from "vitest"
2
+ import { SPEAKER_MAP_DEFAULT_MARGIN_DB, speakerMapByOrdinal, speakerMapResultOf } from "../speaker-map-contract.js"
3
+ import { transcriptSpeakerLabels } from "../camera-switch-contract.js"
4
+
5
+ const transcript = { words: [
6
+ { text: "hi", startMs: 0, endMs: 300, speaker: "speaker_1" },
7
+ { text: "yo", startMs: 400, endMs: 700, speaker: "speaker_0" },
8
+ ] }
9
+
10
+ describe("speakerMapResultOf", () => {
11
+ it("reads a result object or its JSON string; anything else is null", () => {
12
+ const r = { version: 1, speakerMap: { speaker_0: "cam-a", speaker_1: "" }, confidence: { speaker_0: { camera: "cam-a", marginDb: 6.2 }, speaker_1: { camera: "", marginDb: 0.8 } }, notes: [] }
13
+ expect(speakerMapResultOf(r)).toEqual(r)
14
+ expect(speakerMapResultOf(JSON.stringify(r))).toEqual(r)
15
+ expect(speakerMapResultOf({ speakerMap: "x" })).toBeNull()
16
+ expect(speakerMapResultOf("not json")).toBeNull()
17
+ expect(speakerMapResultOf({ version: 1, speakerMap: { a: 3 }, confidence: {}, notes: [] })).toBeNull()
18
+ })
19
+ it("every confidence entry and note must be well-typed, so a reader can trust them", () => {
20
+ const base = { version: 1, speakerMap: { s0: "a" }, confidence: { s0: { camera: "a", marginDb: 6.2 } }, notes: ["a note"] }
21
+ expect(speakerMapResultOf(base)).toEqual(base)
22
+ expect(speakerMapResultOf({ ...base, confidence: { s0: { camera: "", marginDb: null } } })).not.toBeNull()
23
+ for (const confidence of [{ s0: 3 }, { s0: null }, { s0: { camera: 1, marginDb: 2 } }, { s0: { marginDb: 2 } }, { s0: { camera: "a", marginDb: "6" } }, { s0: { camera: "a", marginDb: Number.NaN } }, { s0: { camera: "a", marginDb: Number.POSITIVE_INFINITY } }, { s0: { camera: "a" } }]) {
24
+ expect(speakerMapResultOf({ ...base, confidence })).toBeNull()
25
+ }
26
+ for (const notes of [[1], [null], ["ok", { text: "x" }]]) expect(speakerMapResultOf({ ...base, notes })).toBeNull()
27
+ })
28
+ it("the default margin is the spec's 3 dB", () => expect(SPEAKER_MAP_DEFAULT_MARGIN_DB).toBe(3))
29
+ })
30
+
31
+ describe("speakerMapByOrdinal (the override's keys, decided 2026-10-17)", () => {
32
+ it("ordinal 1 is the first voice heard, whatever its label", () => {
33
+ expect(speakerMapByOrdinal(transcriptSpeakerLabels(transcript), { "1": "cam-b", "2": "" })).toEqual({ speaker_1: "cam-b", speaker_0: "" })
34
+ })
35
+ it("an ordinal past the transcript's speakers maps nobody", () => {
36
+ expect(speakerMapByOrdinal(transcriptSpeakerLabels(transcript), { "3": "cam-a" })).toEqual({})
37
+ expect(speakerMapByOrdinal(transcriptSpeakerLabels(transcript), undefined)).toEqual({})
38
+ })
39
+ it("only a plainly written whole number from 1 is an ordinal", () => {
40
+ const labels = transcriptSpeakerLabels(transcript)
41
+ for (const key of [" 1", "1 ", "01", "1.0", "1e0", "0", "-1", "+1", "0x1", "", "one"]) expect(speakerMapByOrdinal(labels, { [key]: "cam-a" })).toEqual({})
42
+ expect(speakerMapByOrdinal(labels, { "2": "cam-a" })).toEqual({ speaker_0: "cam-a" })
43
+ })
44
+ it("an override that is not an object maps nobody (a hand-written workflow)", () => {
45
+ const labels = transcriptSpeakerLabels(transcript)
46
+ for (const bad of ["cam-b", ["cam-a", "cam-b"], null, 3]) expect(speakerMapByOrdinal(labels, bad as never)).toEqual({})
47
+ })
48
+ })
@@ -0,0 +1,129 @@
1
+ import { afterEach, describe, expect, it, vi } from "vitest"
2
+
3
+ /**
4
+ * The tables that compose the node units' generated rows (unit-contract-compose.ts):
5
+ * the presentation sets, JSON_OUTPUT_KINDS, NON_PROMPT_TEXT_LANES, the review
6
+ * holds, USE_CASE_NODE_TYPES and FAN_OUT_EACH_HANDLES. Each case loads the modules fresh over
7
+ * stand-in rows (the real units' rows left out) — a unit is added after the
8
+ * hand-written entries, and a type that is in both refuses to load. The
9
+ * use-case types and the review holds have no hand-written entries left.
10
+ */
11
+
12
+ type Rows = {
13
+ UNIT_CONTRACTS?: ReadonlyArray<readonly [string, string]>
14
+ UNIT_USE_CASE_TYPES?: readonly string[]
15
+ UNIT_JSON_PIPS?: ReadonlyArray<readonly [string, Record<string, string>]>
16
+ UNIT_NON_PROMPT_INPUTS?: ReadonlyArray<readonly [string, readonly string[]]>
17
+ UNIT_REVIEW_HOLDS?: readonly string[]
18
+ UNIT_PRESENTS?: ReadonlyArray<readonly [string, string]>
19
+ UNIT_FAN_OUT_EACH?: ReadonlyArray<readonly [string, { each: readonly string[]; primary: string }]>
20
+ }
21
+
22
+ function withRows(rows: Rows): void {
23
+ vi.resetModules()
24
+ vi.doMock("../generated/unit-contracts.js", () => ({
25
+ UNIT_CONTRACTS: [],
26
+ UNIT_USE_CASE_TYPES: [],
27
+ UNIT_JSON_PIPS: [],
28
+ UNIT_NON_PROMPT_INPUTS: [],
29
+ UNIT_REVIEW_HOLDS: [],
30
+ UNIT_PRESENTS: [],
31
+ UNIT_FAN_OUT_EACH: [],
32
+ ...rows,
33
+ }))
34
+ }
35
+
36
+ afterEach(() => {
37
+ vi.doUnmock("../generated/unit-contracts.js")
38
+ vi.resetModules()
39
+ })
40
+
41
+ describe("a node unit's contract rows join the published tables", () => {
42
+ it("each table gains the unit after its hand-written entries", async () => {
43
+ withRows({
44
+ UNIT_USE_CASE_TYPES: ["fixture-case"],
45
+ UNIT_JSON_PIPS: [["fixture-case", { json: "edl" }]],
46
+ UNIT_NON_PROMPT_INPUTS: [["fixture-case", ["music", "media", "negative"]]],
47
+ UNIT_REVIEW_HOLDS: ["fixture-case"],
48
+ UNIT_PRESENTS: [["fixture-case", "text"]],
49
+ UNIT_FAN_OUT_EACH: [["fixture-case", { each: ["media"], primary: "media" }]],
50
+ })
51
+ const { getOutputType } = await import("../presentation-utils.js")
52
+ const { declaredJsonOutput, declaredJsonOutputRows } = await import("../json-kinds.js")
53
+ const { NON_PROMPT_TEXT_LANES, fanOutTextFeedsPrompt } = await import("../fan-out-rows.js")
54
+ const { REVIEW_HOLDING_USE_CASE_TYPES, isPreviewHoldingType } = await import("../preview-gate.js")
55
+ const { USE_CASE_NODE_TYPES, isUseCaseNodeType } = await import("../use-case-types.js")
56
+
57
+ expect(getOutputType("fixture-case")).toBe("text")
58
+ expect(getOutputType("apply-edl")).toBe("video")
59
+
60
+ expect(declaredJsonOutput("fixture-case", "json")).toBe("edl")
61
+ // A unit has no primary pip: an edge with no sourceHandle reads no JSON.
62
+ expect(declaredJsonOutput("fixture-case", undefined)).toBeUndefined()
63
+ expect(declaredJsonOutputRows().at(-1)).toEqual(["fixture-case", "json", "edl"])
64
+
65
+ expect(NON_PROMPT_TEXT_LANES.negative).toBe("*")
66
+ // A handle no list named gets one, after every hand-written key.
67
+ expect(NON_PROMPT_TEXT_LANES.music).toEqual(["fixture-case"])
68
+ expect(NON_PROMPT_TEXT_LANES.media).toEqual(["fixture-case"])
69
+ expect(Object.keys(NON_PROMPT_TEXT_LANES).at(-1)).toBe("media")
70
+ expect(fanOutTextFeedsPrompt("fixture-case", "music")).toBe(false)
71
+ expect(fanOutTextFeedsPrompt("fixture-case", "prompt")).toBe(true)
72
+
73
+ expect([...REVIEW_HOLDING_USE_CASE_TYPES]).toEqual(["fixture-case"])
74
+ expect(isPreviewHoldingType("fixture-case")).toBe(true)
75
+
76
+ expect([...USE_CASE_NODE_TYPES]).toEqual(["fixture-case"])
77
+ expect(isUseCaseNodeType("fixture-case")).toBe(true)
78
+
79
+ const { FAN_OUT_EACH_HANDLES, defaultEdgeOutputMode, listResultsServeHandle } = await import("../producer-types.js")
80
+ expect(Object.keys(FAN_OUT_EACH_HANDLES).at(-1)).toBe("fixture-case")
81
+ expect(FAN_OUT_EACH_HANDLES["camera-switch"]).toEqual({ each: ["edl"], primary: "edl" })
82
+ expect(defaultEdgeOutputMode("fixture-case", "media")).toBe("each")
83
+ expect(defaultEdgeOutputMode("fixture-case", undefined)).toBe("each")
84
+ expect(defaultEdgeOutputMode("fixture-case", "json")).toBe("last")
85
+ expect(listResultsServeHandle("fixture-case", "json")).toBe(false)
86
+ })
87
+
88
+ it("with no rows every table is exactly its hand-written entries", async () => {
89
+ withRows({})
90
+ const { FAN_OUT_EACH_HANDLES } = await import("../producer-types.js")
91
+ expect(Object.keys(FAN_OUT_EACH_HANDLES)).toEqual(["camera-switch", "ugc-clips"])
92
+ const { NON_PROMPT_TEXT_LANES } = await import("../fan-out-rows.js")
93
+ const { REVIEW_HOLDING_USE_CASE_TYPES } = await import("../preview-gate.js")
94
+ expect(NON_PROMPT_TEXT_LANES.music).toBeUndefined()
95
+ expect(Object.keys(NON_PROMPT_TEXT_LANES).at(-1)).toBe("link")
96
+ expect([...REVIEW_HOLDING_USE_CASE_TYPES]).toEqual([])
97
+ })
98
+ })
99
+
100
+ describe("a type that is hand-written and a node unit refuses to load", () => {
101
+ const cases: ReadonlyArray<readonly [string, Rows, RegExp]> = [
102
+ ["../presentation-utils.js", { UNIT_PRESENTS: [["upload-image", "image"]] }, /IMAGE_OUTPUT_TYPES: upload-image is both hand-written and a node unit/],
103
+ ["../json-kinds.js", { UNIT_JSON_PIPS: [["transcribe", { json: "transcript" }]] }, /JSON_OUTPUT_KINDS: transcribe is both a legacy entry and a node unit/],
104
+ ["../fan-out-rows.js", { UNIT_NON_PROMPT_INPUTS: [["apply-edl", ["transcript"]]] }, /NON_PROMPT_TEXT_LANES: apply-edl is listed for "transcript" both by hand and as a node unit/],
105
+ ["../use-case-types.js", { UNIT_USE_CASE_TYPES: ["episode-chapters", "episode-chapters"] }, /USE_CASE_NODE_TYPES: .* lists a type twice/],
106
+ ["../producer-types.js", { UNIT_CONTRACTS: [["upload-video", "video"]] }, /VIDEO_PRODUCER_TYPES: upload-video is both hand-written and a node unit/],
107
+ ["../producer-types.js", { UNIT_FAN_OUT_EACH: [["camera-switch", { each: ["edl"], primary: "edl" }]] }, /FAN_OUT_EACH_HANDLES: camera-switch is both hand-written and a node unit/],
108
+ ]
109
+ for (const [mod, rows, message] of cases) {
110
+ it(mod, async () => {
111
+ withRows(rows)
112
+ await expect(import(/* @vite-ignore */ mod)).rejects.toThrow(message)
113
+ })
114
+ }
115
+ })
116
+
117
+ describe("a node unit with two fan-out rows refuses to load", () => {
118
+ it("../producer-types.js", async () => {
119
+ withRows({ UNIT_FAN_OUT_EACH: [["fixture-case", { each: ["media"], primary: "media" }], ["fixture-case", { each: ["json"], primary: "json" }]] })
120
+ await expect(import("../producer-types.js")).rejects.toThrow(/FAN_OUT_EACH_HANDLES: node unit fixture-case has more than one row/)
121
+ })
122
+ })
123
+
124
+ describe("a node unit's own row that names one handle twice refuses to load", () => {
125
+ it("../fan-out-rows.js", async () => {
126
+ withRows({ UNIT_NON_PROMPT_INPUTS: [["fixture-case", ["media", "media"]]] })
127
+ await expect(import("../fan-out-rows.js")).rejects.toThrow(/NON_PROMPT_TEXT_LANES: node unit fixture-case lists "media" twice in its contract\.nonPromptInputs/)
128
+ })
129
+ })
@@ -0,0 +1,134 @@
1
+ // @test-watches packages/shared/src/generated/unit-contracts.ts tools/units/__fixtures__/expected/packages/shared/src/generated/unit-contracts.ts
2
+ import { readFileSync } from "node:fs"
3
+ import path from "node:path"
4
+ import { describe, expect, it } from "vitest"
5
+ import { UNIT_CONTRACTS, UNIT_FAN_OUT_EACH, UNIT_JSON_PIPS, UNIT_NON_PROMPT_INPUTS, UNIT_PRESENTS, UNIT_REVIEW_HOLDS, UNIT_USE_CASE_TYPES } from "../generated/unit-contracts.js"
6
+
7
+ /**
8
+ * What the node units may put in @nodaro/shared (decided 2026-10-16, widened
9
+ * 2026-10-18): node type ids with closed vocabularies — the producer kind, the
10
+ * use-case types, what a JSON pip carries, the non-prompt input pips, the
11
+ * review holds, how a published app presents the result and which output pips
12
+ * fan out item by item. Each feeds a published table beside its hand-written
13
+ * rows. Never a price, a credit id, a number, prompt or
14
+ * doctrine text: every published version of this package is an irrevocable
15
+ * Apache grant, and those live in backend/ (prices, ee/) and @nodaro/prompts
16
+ * (FSL). gen:units writes the file; this holds it to that.
17
+ */
18
+ const SOURCE = readFileSync(path.resolve(__dirname, "../generated/unit-contracts.ts"), "utf8")
19
+ // The generator's golden for its fixture units — a file WITH rows, so the line rule is proven on one.
20
+ const GOLDEN = readFileSync(path.resolve(__dirname, "../../../../tools/units/__fixtures__/expected/packages/shared/src/generated/unit-contracts.ts"), "utf8")
21
+
22
+ const TYPE = "[a-z][a-z0-9-]*"
23
+ const ROW_END = `, \\/\\/ unit:${TYPE}$`
24
+ const PIP = `"[a-zA-Z][\\w-]*"`
25
+ /** The seven declarations, in order, each with the one row shape its block may hold, and how the block ends. */
26
+ const DECLARATIONS: ReadonlyArray<{ readonly head: RegExp; readonly row: RegExp; readonly end: string }> = [
27
+ {
28
+ head: /^export const UNIT_CONTRACTS: ReadonlyArray<readonly \[type: string, producer: "audio" \| "video" \| "image" \| "dynamic"\]> = \[$/,
29
+ row: new RegExp(`^ {2}\\["${TYPE}", "(?:audio|video|image|dynamic)"\\]${ROW_END}`),
30
+ end: "]",
31
+ },
32
+ { head: /^export const UNIT_USE_CASE_TYPES = \[$/, row: new RegExp(`^ {2}"${TYPE}"${ROW_END}`), end: "] as const" },
33
+ {
34
+ head: /^export const UNIT_JSON_PIPS: ReadonlyArray<readonly \[type: string, pips: Readonly<Record<string, "transcript" \| "edl" \| "other">>\]> = \[$/,
35
+ row: new RegExp(`^ {2}\\["${TYPE}", \\{ ${PIP}: "(?:transcript|edl|other)"(?:, ${PIP}: "(?:transcript|edl|other)")* \\}\\]${ROW_END}`),
36
+ end: "]",
37
+ },
38
+ {
39
+ head: /^export const UNIT_NON_PROMPT_INPUTS: ReadonlyArray<readonly \[type: string, handles: ReadonlyArray<string>\]> = \[$/,
40
+ row: new RegExp(`^ {2}\\["${TYPE}", \\[${PIP}(?:, ${PIP})*\\]\\]${ROW_END}`),
41
+ end: "]",
42
+ },
43
+ { head: /^export const UNIT_REVIEW_HOLDS: ReadonlyArray<string> = \[$/, row: new RegExp(`^ {2}"${TYPE}"${ROW_END}`), end: "]" },
44
+ {
45
+ head: /^export const UNIT_PRESENTS: ReadonlyArray<readonly \[type: string, presents: "image" \| "video" \| "audio" \| "text"\]> = \[$/,
46
+ row: new RegExp(`^ {2}\\["${TYPE}", "(?:image|video|audio|text)"\\]${ROW_END}`),
47
+ end: "]",
48
+ },
49
+ {
50
+ head: /^export const UNIT_FAN_OUT_EACH: ReadonlyArray<readonly \[type: string, handles: \{ readonly each: ReadonlyArray<string>; readonly primary: string \}\]> = \[$/,
51
+ row: new RegExp(`^ {2}\\["${TYPE}", \\{ "each": \\[${PIP}(?:, ${PIP})*\\], "primary": ${PIP} \\}\\]${ROW_END}`),
52
+ end: "]",
53
+ },
54
+ ]
55
+
56
+ /**
57
+ * Problems with a contracts file's code lines (`//` comments and blanks aside —
58
+ * a `/** … *\/` line is code, and refused); [] when it holds exactly the seven
59
+ * declarations, in order, each followed only by its own rows and its end line.
60
+ */
61
+ function contractProblems(source: string): string[] {
62
+ const code = source.split("\n").filter((l) => !l.trim().startsWith("//") && l.trim() !== "")
63
+ const out: string[] = []
64
+ let i = 0
65
+ for (const d of DECLARATIONS) {
66
+ if (!d.head.test(code[i] ?? "")) { out.push(`declaration: ${code[i]}`); return out }
67
+ i++
68
+ while (i < code.length && code[i] !== d.end && !code[i].startsWith("export ")) {
69
+ if (!d.row.test(code[i])) out.push(`row: ${code[i]}`)
70
+ i++
71
+ }
72
+ if (code[i] !== d.end) { out.push(`end: ${code[i]}`); return out }
73
+ i++
74
+ }
75
+ for (const line of code.slice(i)) out.push(`after the declarations: ${line}`)
76
+ // No digit outside a type id, a pip id or the comment tags: a price can never slip in.
77
+ for (const line of code) if (/\d/.test(line.replace(new RegExp(`"[a-zA-Z][\\w-]*"|// unit:${TYPE}`, "g"), ""))) out.push(`digit: ${line}`)
78
+ return out
79
+ }
80
+
81
+ describe("generated/unit-contracts.ts carries only type ids with closed vocabularies", () => {
82
+ it("every row is a kebab-case type id and a closed-vocabulary value", () => {
83
+ const KEBAB = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/
84
+ for (const row of UNIT_CONTRACTS) {
85
+ expect(row).toHaveLength(2)
86
+ expect(row[0]).toMatch(KEBAB)
87
+ expect(["audio", "video", "image", "dynamic"]).toContain(row[1])
88
+ }
89
+ expect(new Set(UNIT_CONTRACTS.map(([t]) => t)).size).toBe(UNIT_CONTRACTS.length)
90
+ for (const t of [...UNIT_USE_CASE_TYPES, ...UNIT_REVIEW_HOLDS, ...UNIT_JSON_PIPS.map(([x]) => x), ...UNIT_NON_PROMPT_INPUTS.map(([x]) => x), ...UNIT_PRESENTS.map(([x]) => x)]) expect(t).toMatch(KEBAB)
91
+ for (const [, pips] of UNIT_JSON_PIPS) for (const v of Object.values(pips)) expect(["transcript", "edl", "other"]).toContain(v)
92
+ for (const [, p] of UNIT_PRESENTS) expect(["image", "video", "audio", "text"]).toContain(p)
93
+ // A fan-out row is a type id and pip ids only.
94
+ const PIP_ID = /^[a-zA-Z][\w-]*$/
95
+ for (const [t, h] of UNIT_FAN_OUT_EACH) {
96
+ expect(t).toMatch(KEBAB)
97
+ expect(Object.keys(h)).toEqual(["each", "primary"])
98
+ expect(h.each.length).toBeGreaterThan(0)
99
+ for (const pip of [...h.each, h.primary]) expect(pip).toMatch(PIP_ID)
100
+ }
101
+ })
102
+
103
+ it("the file holds nothing else: the seven declarations and their rows", () => {
104
+ expect(contractProblems(SOURCE)).toEqual([])
105
+ })
106
+
107
+ it("the line rule accepts real rows and refuses a price, a credit id, prose or a doc comment", () => {
108
+ expect(contractProblems(GOLDEN)).toEqual([])
109
+ // A row in every block is accepted.
110
+ const full = GOLDEN
111
+ .replace("ReadonlyArray<string>]> = [\n", 'ReadonlyArray<string>]> = [\n ["fixture-case", ["media"]], // unit:fixture-case\n')
112
+ .replace("UNIT_REVIEW_HOLDS: ReadonlyArray<string> = [\n", 'UNIT_REVIEW_HOLDS: ReadonlyArray<string> = [\n "fixture-case", // unit:fixture-case\n')
113
+ expect(full).not.toBe(GOLDEN)
114
+ expect(contractProblems(full)).toEqual([])
115
+ const refused = [
116
+ GOLDEN.replace('"video"], // unit', '"video", 20], // unit'),
117
+ GOLDEN.replace("]\n", ' ["remove-audio:pro", "video"], // unit:remove-audio\n]\n'),
118
+ `${GOLDEN}export const PROMPT = "Write a poem"\n`,
119
+ GOLDEN.replace(' "fixture-case", // unit:fixture-case\n] as const', ' "fixture-case", 10, // unit:fixture-case\n] as const'),
120
+ GOLDEN.replace('{ "json": "other" }', '{ "json": "other", "fee": 10 }'),
121
+ full.replace('["fixture-case", ["media"]]', '["fixture-case", [10]]'),
122
+ full.replace(' "fixture-case", // unit:fixture-case\n]\n\n', ' 10, // unit:fixture-case\n]\n\n'),
123
+ GOLDEN.replace('["fixture-case", "text"]', '["fixture-case", "text", 10]'),
124
+ GOLDEN.replace("export const UNIT_USE_CASE_TYPES", "/** The use-case types. */\nexport const UNIT_USE_CASE_TYPES"),
125
+ GOLDEN.replace('{ "each": ["text"], "primary": "text" }', '{ "each": ["text", 10], "primary": "text" }'),
126
+ GOLDEN.replace('{ "each": ["text"], "primary": "text" }', '{ "each": ["text"], "primary": "text", "fee": "x" }'),
127
+ GOLDEN.replace('{ "each": ["text"], "primary": "text" }', '{ "each": ["Make it cinematic"], "primary": "text" }'),
128
+ ]
129
+ for (const [i, src] of refused.entries()) {
130
+ expect(src, `case ${i} changed the golden`).not.toBe(GOLDEN)
131
+ expect(contractProblems(src), `case ${i}`).not.toEqual([])
132
+ }
133
+ })
134
+ })
@@ -0,0 +1,33 @@
1
+ import { describe, expect, expectTypeOf, it } from "vitest"
2
+ // Through the entry consumers import (`@nodaro/shared/nodes`).
3
+ import { USE_CASE_NODE_TYPES, isUseCaseNodeType, type UseCaseNodeType } from "../entries/nodes.js"
4
+ import { UNIT_USE_CASE_TYPES } from "../generated/unit-contracts.js"
5
+
6
+ describe("USE_CASE_NODE_TYPES: the public use-case node types", () => {
7
+ // Their order is the editor's composed order (frontend units-vocabulary.test.ts guards it).
8
+ it("lists the use-case units' types, each once", () => {
9
+ expect(USE_CASE_NODE_TYPES.length).toBeGreaterThan(0)
10
+ expect([...USE_CASE_NODE_TYPES]).toEqual([...UNIT_USE_CASE_TYPES])
11
+ expect(new Set(USE_CASE_NODE_TYPES).size).toBe(USE_CASE_NODE_TYPES.length)
12
+ })
13
+
14
+ it("isUseCaseNodeType answers for the listed strings only, whatever it is handed", () => {
15
+ for (const t of USE_CASE_NODE_TYPES) expect(isUseCaseNodeType(t)).toBe(true)
16
+ expect(isUseCaseNodeType("constructor")).toBe(false)
17
+ expect(isUseCaseNodeType("apply-edl")).toBe(false)
18
+ expect(isUseCaseNodeType("")).toBe(false)
19
+ expect(isUseCaseNodeType(null)).toBe(false)
20
+ expect(isUseCaseNodeType(undefined)).toBe(false)
21
+ expect(isUseCaseNodeType(42)).toBe(false)
22
+ expect(isUseCaseNodeType({ type: "tighten-episode" })).toBe(false)
23
+ })
24
+
25
+ it("UseCaseNodeType is a literal union, and the guard narrows an unknown to it", () => {
26
+ // The units' literal types — never widened to string.
27
+ expectTypeOf<UseCaseNodeType>().toEqualTypeOf<(typeof UNIT_USE_CASE_TYPES)[number]>()
28
+ expectTypeOf<string>().not.toExtend<UseCaseNodeType>()
29
+ expectTypeOf(isUseCaseNodeType).parameter(0).toBeUnknown()
30
+ const value: unknown = "episode-chapters"
31
+ if (isUseCaseNodeType(value)) expectTypeOf(value).toEqualTypeOf<UseCaseNodeType>()
32
+ })
33
+ })
@@ -3,6 +3,7 @@ import { MODEL_CATALOG, normalizeVideoRequestParams } from "../index.js"
3
3
  import {
4
4
  normalizeMinimaxH3Resolution,
5
5
  normalizeWan3Resolution,
6
+ normalizeViduQ4Resolution,
6
7
  VIDEO_GEN_PROVIDERS,
7
8
  } from "../model-constants.js"
8
9
 
@@ -49,6 +50,15 @@ describe("unlistedResolutionRendersAs matches the provider's own collapse rule",
49
50
  }
50
51
  })
51
52
 
53
+ it("vidu-q4 declares what normalizeViduQ4Resolution collapses to", () => {
54
+ const declared = MODEL_CATALOG["vidu-q4"]!.unlistedResolutionRendersAs
55
+ expect(declared).toBeDefined()
56
+ for (const off of ["480p", "8k", "nonsense"]) {
57
+ expect(normalizeViduQ4Resolution(off), `vidu-q4 renders ${off} as`).toBe(declared)
58
+ expect(normalizeVideoRequestParams("vidu-q4", { resolution: off }).resolution).toBe(declared)
59
+ }
60
+ })
61
+
52
62
  it("a declared collapse target is always one of the model's own bands", () => {
53
63
  for (const provider of VIDEO_GEN_PROVIDERS) {
54
64
  const entry = MODEL_CATALOG[provider]
@@ -0,0 +1,85 @@
1
+ import { describe, it, expect } from "vitest"
2
+ import { MODEL_CATALOG } from "../model-catalog.js"
3
+ import {
4
+ VIDEO_PROVIDERS_WITH_SEPARATE_FRAME_CHANNEL,
5
+ videoProviderAppendsFrames,
6
+ videoProviderRefModeFrameSeats,
7
+ videoProviderReferenceSyntax,
8
+ } from "../model-constants.js"
9
+
10
+ /**
11
+ * The frames-after-references convention, as a catalog capability.
12
+ *
13
+ * Every reference-capable video model either appends its frames after the
14
+ * caller's references (one shared image list, the platform convention) or
15
+ * rides them on a channel of their own. A new reference-capable model is
16
+ * appending by default, so it cannot ship frame-first by accident.
17
+ */
18
+ const refCapable = Object.values(MODEL_CATALOG).filter(
19
+ (m) => m.kind === "video" && m.features?.includes("reference-image") === true,
20
+ )
21
+
22
+ describe("videoProviderAppendsFrames", () => {
23
+ it("every reference-capable video model appends frames unless its frames have their own channel", () => {
24
+ for (const m of refCapable) {
25
+ const separate = VIDEO_PROVIDERS_WITH_SEPARATE_FRAME_CHANNEL.has(m.id)
26
+ expect(videoProviderAppendsFrames(m.id) || separate, `${m.id} neither appends nor has a frame channel`).toBe(true)
27
+ expect(videoProviderAppendsFrames(m.id) && separate, `${m.id} cannot be both`).toBe(false)
28
+ }
29
+ })
30
+
31
+ it("the separate-channel set names only reference-capable video models", () => {
32
+ for (const id of VIDEO_PROVIDERS_WITH_SEPARATE_FRAME_CHANNEL) {
33
+ expect(refCapable.map((m) => m.id), id).toContain(id)
34
+ }
35
+ })
36
+
37
+ it("is false for a model with no reference images and for unknown ids", () => {
38
+ expect(videoProviderAppendsFrames("kling")).toBe(false)
39
+ expect(videoProviderAppendsFrames("nope")).toBe(false)
40
+ expect(videoProviderAppendsFrames(undefined)).toBe(false)
41
+ })
42
+ })
43
+
44
+ describe("videoProviderRefModeFrameSeats", () => {
45
+ it("counts the start frame, and the end frame only where the model takes one", () => {
46
+ expect(videoProviderRefModeFrameSeats("seedance-2", { hasStartFrame: true, hasEndFrame: true })).toBe(2)
47
+ expect(videoProviderRefModeFrameSeats("seedance-2", { hasStartFrame: false, hasEndFrame: true })).toBe(1)
48
+ expect(videoProviderRefModeFrameSeats("vidu-q4", { hasStartFrame: true, hasEndFrame: true })).toBe(1)
49
+ expect(videoProviderRefModeFrameSeats("seedance-2", { hasStartFrame: false, hasEndFrame: false })).toBe(0)
50
+ })
51
+
52
+ it("is 0 on a model whose frames ride their own channel", () => {
53
+ for (const id of VIDEO_PROVIDERS_WITH_SEPARATE_FRAME_CHANNEL) {
54
+ expect(videoProviderRefModeFrameSeats(id, { hasStartFrame: true, hasEndFrame: true }), id).toBe(0)
55
+ }
56
+ })
57
+
58
+ it("never exceeds the frames wired, and agrees with the catalog end-frame feature", () => {
59
+ for (const m of refCapable) {
60
+ if (!videoProviderAppendsFrames(m.id)) continue
61
+ const both = videoProviderRefModeFrameSeats(m.id, { hasStartFrame: true, hasEndFrame: true })
62
+ expect(both, m.id).toBe(m.features?.includes("end-frame") ? 2 : 1)
63
+ }
64
+ })
65
+ })
66
+
67
+ describe("videoProviderReferenceSyntax", () => {
68
+ it("defaults to the platform's @image_N", () => {
69
+ expect(videoProviderReferenceSyntax("seedance-2")).toBe("@image_N")
70
+ expect(videoProviderReferenceSyntax(undefined)).toBe("@image_N")
71
+ })
72
+
73
+ it("names the providers' own documented forms", () => {
74
+ expect(videoProviderReferenceSyntax("grok-i2v")).toBe("@image(n)")
75
+ expect(videoProviderReferenceSyntax("happyhorse-ref2v")).toBe("[Image N]")
76
+ })
77
+
78
+ it("is declared only on reference-capable video models", () => {
79
+ for (const m of Object.values(MODEL_CATALOG)) {
80
+ if (!m.referenceSyntax) continue
81
+ expect(m.kind, m.id).toBe("video")
82
+ expect(m.features, m.id).toContain("reference-image")
83
+ }
84
+ })
85
+ })
@@ -138,6 +138,7 @@ describe("VIDEO_PROVIDERS_REQUIRING_IMAGE (derived from MODEL_CATALOG modes)", (
138
138
  "hailuo-2.3-pro",
139
139
  "bytedance-pro-fast",
140
140
  "happyhorse-ref2v",
141
+ "vidu-q4",
141
142
  ]),
142
143
  )
143
144
  })
@@ -0,0 +1,117 @@
1
+ import { describe, it, expect } from "vitest"
2
+ import { MODEL_CATALOG } from "../model-catalog.js"
3
+ import {
4
+ IMAGE_TO_VIDEO_PROVIDERS,
5
+ TEXT_TO_VIDEO_PROVIDERS,
6
+ VIDEO_GEN_PROVIDERS,
7
+ VIDEO_REF_LIMITS_BY_PROVIDER,
8
+ VIDEO_PROVIDERS_WITHOUT_DISPATCH,
9
+ resolveVideoModeForInputs,
10
+ resolveVideoProviderForMode,
11
+ videoProviderRequiresImage,
12
+ videoProviderRunsFromReferences,
13
+ } from "../model-constants.js"
14
+
15
+ /**
16
+ * References-only runs (reference images wired, no start frame) — the
17
+ * catalog-walking totality guard.
18
+ *
19
+ * Every unified-picker video model that takes reference images either declares
20
+ * the `reference-to-video` capability (its provider runs from references
21
+ * alone) and is then NEVER blocked by the "image required" gate, or is listed
22
+ * below with the reason it cannot run that way. A new ref-capable model must
23
+ * pick one, so it cannot silently regress to "image required" again.
24
+ *
25
+ * The resolver is the one rule the editor gate (`video-image-gate.ts`), the
26
+ * browser DAG (`execute-node.ts`) and the orchestrator (`payload-builder.ts`)
27
+ * all read, so asserting it here covers the four surfaces at once (the API's
28
+ * `/v1/generate-video` uses the per-kind `hasMultimodalRef` rule, which the
29
+ * route tests pin).
30
+ */
31
+
32
+ /** Ref-capable models that CANNOT run from references alone, with the reason. */
33
+ const BLOCKED_WITHOUT_A_FRAME: Readonly<Record<string, string>> = {
34
+ // No working dispatch at all (VIDEO_PROVIDERS_WITHOUT_DISPATCH): every run
35
+ // fails at the router, so advertising a references-only run would be a lie.
36
+ "kling-3-omni": "no dispatch path",
37
+ }
38
+
39
+ const T2V = "text-to-video" as const
40
+ const I2V = "image-to-video" as const
41
+
42
+ const refCapable = (VIDEO_GEN_PROVIDERS as readonly string[]).filter(
43
+ (p) => (VIDEO_REF_LIMITS_BY_PROVIDER[p]?.images ?? 0) > 0,
44
+ )
45
+
46
+ describe("reference-to-video capability (catalog)", () => {
47
+ it("is declared only on video models that also take reference images", () => {
48
+ for (const m of Object.values(MODEL_CATALOG)) {
49
+ if (!m.features?.includes("reference-to-video")) continue
50
+ expect(m.kind, m.id).toBe("video")
51
+ expect(m.features, m.id).toContain("reference-image")
52
+ expect(VIDEO_REF_LIMITS_BY_PROVIDER[m.id]?.images ?? 0, m.id).toBeGreaterThan(0)
53
+ }
54
+ })
55
+
56
+ it("every ref-capable unified-picker model is either reference-to-video or listed as blocked", () => {
57
+ for (const p of refCapable) {
58
+ const declared = videoProviderRunsFromReferences(p)
59
+ const blocked = p in BLOCKED_WITHOUT_A_FRAME
60
+ expect(declared !== blocked, `${p}: declare "reference-to-video" or list it in BLOCKED_WITHOUT_A_FRAME`).toBe(true)
61
+ }
62
+ for (const p of Object.keys(BLOCKED_WITHOUT_A_FRAME)) {
63
+ expect(refCapable, `${p} is no longer ref-capable — drop it from the list`).toContain(p)
64
+ }
65
+ })
66
+
67
+ it("the blocked list is exactly the undispatchable ref-capable models", () => {
68
+ expect(Object.keys(BLOCKED_WITHOUT_A_FRAME).sort()).toEqual(
69
+ refCapable.filter((p) => VIDEO_PROVIDERS_WITHOUT_DISPATCH.has(p)).sort(),
70
+ )
71
+ })
72
+ })
73
+
74
+ describe("references-only runs are never image-gated on a reference-to-video model", () => {
75
+ for (const p of refCapable.filter((id) => videoProviderRunsFromReferences(id))) {
76
+ it(`${p}: refs alone resolve to a lane that takes them`, () => {
77
+ const mode = resolveVideoModeForInputs(p, { hasStartFrame: false, hasImageRefs: true })
78
+ const resolved = resolveVideoProviderForMode(p, mode)
79
+ // The t2v lane refuses an image-required model before looking at refs.
80
+ expect(mode === T2V && videoProviderRequiresImage(resolved), `${p} would be refused as "image required"`).toBe(false)
81
+ // ...and the lane chosen is a route enum member that carries the refs.
82
+ const lane = (mode === I2V ? IMAGE_TO_VIDEO_PROVIDERS : TEXT_TO_VIDEO_PROVIDERS) as readonly string[]
83
+ expect(lane, `${resolved} on ${mode}`).toContain(resolved)
84
+ expect(VIDEO_REF_LIMITS_BY_PROVIDER[resolved]?.images ?? 0, resolved).toBeGreaterThan(0)
85
+ })
86
+ }
87
+
88
+ it("a model with no text-to-video mode takes the image-to-video lane for refs alone", () => {
89
+ for (const p of ["vidu-q4", "happyhorse-ref2v"]) {
90
+ expect(resolveVideoModeForInputs(p, { hasStartFrame: false, hasImageRefs: true }), p).toBe(I2V)
91
+ }
92
+ })
93
+
94
+ it("a single-id model WITH a text-to-video mode keeps the t2v lane for refs alone (unchanged)", () => {
95
+ for (const p of ["seedance-2", "seedance-2-5", "minimax-h3", "wan-3", "gemini-omni-video", "veo3.1"]) {
96
+ expect(resolveVideoModeForInputs(p, { hasStartFrame: false, hasImageRefs: true }), p).toBe(T2V)
97
+ }
98
+ })
99
+ })
100
+
101
+ describe("the friendly image-required refusal still stands", () => {
102
+ it("nothing wired on an image-required model resolves to the gated t2v lane", () => {
103
+ for (const p of VIDEO_GEN_PROVIDERS as readonly string[]) {
104
+ if (!videoProviderRequiresImage(p)) continue
105
+ const mode = resolveVideoModeForInputs(p, { hasStartFrame: false, hasImageRefs: false })
106
+ expect(mode, p).toBe(T2V)
107
+ expect(videoProviderRequiresImage(resolveVideoProviderForMode(p, mode)), p).toBe(true)
108
+ }
109
+ })
110
+
111
+ it("a blocked-without-a-frame model is still refused when only refs are wired", () => {
112
+ for (const p of Object.keys(BLOCKED_WITHOUT_A_FRAME)) {
113
+ const mode = resolveVideoModeForInputs(p, { hasStartFrame: false, hasImageRefs: true })
114
+ expect(mode === T2V && videoProviderRequiresImage(resolveVideoProviderForMode(p, mode)), p).toBe(true)
115
+ }
116
+ })
117
+ })