@nodaro/shared 3.33.0 → 3.36.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 (266) hide show
  1. package/dist/{chunk-CK3GK34R.js → chunk-2HIDE3QV.js} +9 -3
  2. package/dist/chunk-2HIDE3QV.js.map +1 -0
  3. package/dist/{chunk-WDIBOWAA.js → chunk-2HVFF5SS.js} +6 -6
  4. package/dist/chunk-2HVFF5SS.js.map +1 -0
  5. package/dist/{chunk-PVJBAPYJ.js → chunk-56VQ7V3V.js} +8 -5
  6. package/dist/chunk-56VQ7V3V.js.map +1 -0
  7. package/dist/{chunk-Z2OL5AJD.cjs → chunk-6F6GGX2W.cjs} +4 -3
  8. package/dist/chunk-6F6GGX2W.cjs.map +1 -0
  9. package/dist/{chunk-HKFMXNVQ.cjs → chunk-75ZMA34U.cjs} +11 -11
  10. package/dist/{chunk-HKFMXNVQ.cjs.map → chunk-75ZMA34U.cjs.map} +1 -1
  11. package/dist/{chunk-6WZ2VN7V.js → chunk-7AB3AE5L.js} +6 -6
  12. package/dist/{chunk-6WZ2VN7V.js.map → chunk-7AB3AE5L.js.map} +1 -1
  13. package/dist/{chunk-VXPLKQWY.cjs → chunk-7VQPHLZ5.cjs} +30 -40
  14. package/dist/chunk-7VQPHLZ5.cjs.map +1 -0
  15. package/dist/{chunk-BG5D5CZ6.js → chunk-ANOQWAMU.js} +23 -6
  16. package/dist/chunk-ANOQWAMU.js.map +1 -0
  17. package/dist/{chunk-PRYE7AZQ.cjs → chunk-AWWOQH46.cjs} +7 -7
  18. package/dist/chunk-AWWOQH46.cjs.map +1 -0
  19. package/dist/{chunk-PXFQVLBX.js → chunk-AXUW64ZY.js} +26 -36
  20. package/dist/chunk-AXUW64ZY.js.map +1 -0
  21. package/dist/{chunk-FT5CF6IA.js → chunk-AZBIXGM5.js} +3 -3
  22. package/dist/{chunk-FT5CF6IA.js.map → chunk-AZBIXGM5.js.map} +1 -1
  23. package/dist/{chunk-D6GNRSCV.cjs → chunk-BBLE4UTG.cjs} +23 -6
  24. package/dist/chunk-BBLE4UTG.cjs.map +1 -0
  25. package/dist/{chunk-HUR6ZJ7S.cjs → chunk-BSQCKTXH.cjs} +6 -6
  26. package/dist/{chunk-HUR6ZJ7S.cjs.map → chunk-BSQCKTXH.cjs.map} +1 -1
  27. package/dist/{chunk-HGC5JNVA.cjs → chunk-BVVKMQKR.cjs} +9 -2
  28. package/dist/chunk-BVVKMQKR.cjs.map +1 -0
  29. package/dist/{chunk-SAW5OK36.cjs → chunk-BYP62B7F.cjs} +6 -6
  30. package/dist/{chunk-SAW5OK36.cjs.map → chunk-BYP62B7F.cjs.map} +1 -1
  31. package/dist/{chunk-YYV35XOS.js → chunk-C4R7BTBQ.js} +4 -3
  32. package/dist/chunk-C4R7BTBQ.js.map +1 -0
  33. package/dist/{chunk-UCFWI6D4.js → chunk-CMH2ACOX.js} +3 -3
  34. package/dist/{chunk-UCFWI6D4.js.map → chunk-CMH2ACOX.js.map} +1 -1
  35. package/dist/{chunk-WD6HJRBG.cjs → chunk-DE3PEIIP.cjs} +21 -21
  36. package/dist/{chunk-WD6HJRBG.cjs.map → chunk-DE3PEIIP.cjs.map} +1 -1
  37. package/dist/{chunk-SFW3UB2P.js → chunk-DKTRVOU5.js} +4 -4
  38. package/dist/{chunk-SFW3UB2P.js.map → chunk-DKTRVOU5.js.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-OZSACQ2V.js → chunk-GW54ANCH.js} +3 -3
  44. package/dist/{chunk-OZSACQ2V.js.map → chunk-GW54ANCH.js.map} +1 -1
  45. package/dist/chunk-GZH2SIOF.cjs +99 -0
  46. package/dist/chunk-GZH2SIOF.cjs.map +1 -0
  47. package/dist/{chunk-M7GQBRZU.cjs → chunk-HABDAHZR.cjs} +153 -24
  48. package/dist/chunk-HABDAHZR.cjs.map +1 -0
  49. package/dist/{chunk-CUH22J4D.js → chunk-IIGKJYWL.js} +3 -3
  50. package/dist/{chunk-CUH22J4D.js.map → chunk-IIGKJYWL.js.map} +1 -1
  51. package/dist/{chunk-JL4C5VJ7.cjs → chunk-J65CAOUV.cjs} +14 -2
  52. package/dist/chunk-J65CAOUV.cjs.map +1 -0
  53. package/dist/{chunk-HRXEZ3SX.cjs → chunk-JABZNRXL.cjs} +4 -4
  54. package/dist/{chunk-HRXEZ3SX.cjs.map → chunk-JABZNRXL.cjs.map} +1 -1
  55. package/dist/{chunk-5RYLK3MQ.js → chunk-JMUHMLJP.js} +11 -6
  56. package/dist/chunk-JMUHMLJP.js.map +1 -0
  57. package/dist/{chunk-K3LLGRK7.cjs → chunk-KOP7UTQR.cjs} +72 -15
  58. package/dist/chunk-KOP7UTQR.cjs.map +1 -0
  59. package/dist/{chunk-HC7VKIV5.cjs → chunk-LT5IJO4Y.cjs} +49 -46
  60. package/dist/chunk-LT5IJO4Y.cjs.map +1 -0
  61. package/dist/{chunk-VA42637J.cjs → chunk-MSDECC3A.cjs} +46 -41
  62. package/dist/chunk-MSDECC3A.cjs.map +1 -0
  63. package/dist/{chunk-JFS3NWZ5.cjs → chunk-MSIIC6MY.cjs} +7 -4
  64. package/dist/chunk-MSIIC6MY.cjs.map +1 -0
  65. package/dist/{chunk-D26ENTN2.cjs → chunk-NITAUX3A.cjs} +80 -52
  66. package/dist/chunk-NITAUX3A.cjs.map +1 -0
  67. package/dist/{chunk-23FJQTEA.js → chunk-NTHRTRQK.js} +38 -15
  68. package/dist/chunk-NTHRTRQK.js.map +1 -0
  69. package/dist/{chunk-OTATNBMD.js → chunk-NYMOHNYV.js} +3 -3
  70. package/dist/{chunk-OTATNBMD.js.map → chunk-NYMOHNYV.js.map} +1 -1
  71. package/dist/{chunk-PQHS255G.js → chunk-OHSIVNJO.js} +3 -3
  72. package/dist/chunk-OHSIVNJO.js.map +1 -0
  73. package/dist/{chunk-7Z5LUTGU.js → chunk-QXTCIJP5.js} +6 -3
  74. package/dist/{chunk-JFS3NWZ5.cjs.map → chunk-QXTCIJP5.js.map} +1 -1
  75. package/dist/{chunk-5PC6JBGJ.cjs → chunk-R2VF5NQG.cjs} +3 -3
  76. package/dist/chunk-R2VF5NQG.cjs.map +1 -0
  77. package/dist/{chunk-UTQSSKSG.js → chunk-SPP6HQMM.js} +4 -4
  78. package/dist/{chunk-UTQSSKSG.js.map → chunk-SPP6HQMM.js.map} +1 -1
  79. package/dist/chunk-TCBHVIMD.js +89 -0
  80. package/dist/chunk-TCBHVIMD.js.map +1 -0
  81. package/dist/{chunk-SES6GDBQ.cjs → chunk-UJJUX6NW.cjs} +59 -8
  82. package/dist/chunk-UJJUX6NW.cjs.map +1 -0
  83. package/dist/{chunk-ZRL2UFTH.cjs → chunk-V3N56Z2S.cjs} +101 -22
  84. package/dist/chunk-V3N56Z2S.cjs.map +1 -0
  85. package/dist/{chunk-PHZ23DP3.js → chunk-VRLRPGO7.js} +125 -12
  86. package/dist/chunk-VRLRPGO7.js.map +1 -0
  87. package/dist/{chunk-WKOIGLQX.cjs → chunk-VRUN5TG2.cjs} +8 -8
  88. package/dist/{chunk-WKOIGLQX.cjs.map → chunk-VRUN5TG2.cjs.map} +1 -1
  89. package/dist/{chunk-QA3MVQ32.js → chunk-W4GABGRD.js} +6 -6
  90. package/dist/chunk-W4GABGRD.js.map +1 -0
  91. package/dist/{chunk-M36G6SRP.js → chunk-WXNQMJ67.js} +14 -3
  92. package/dist/chunk-WXNQMJ67.js.map +1 -0
  93. package/dist/chunk-XJ3HJSO5.cjs +25 -0
  94. package/dist/chunk-XJ3HJSO5.cjs.map +1 -0
  95. package/dist/{chunk-XGFTL5XY.js → chunk-YHCG3HOR.js} +3 -3
  96. package/dist/{chunk-XGFTL5XY.js.map → chunk-YHCG3HOR.js.map} +1 -1
  97. package/dist/{chunk-VNQRI2RO.cjs → chunk-YN6AXDN5.cjs} +16 -16
  98. package/dist/{chunk-VNQRI2RO.cjs.map → chunk-YN6AXDN5.cjs.map} +1 -1
  99. package/dist/{chunk-2NQLSLSN.cjs → chunk-YNJ44IAL.cjs} +5 -5
  100. package/dist/{chunk-2NQLSLSN.cjs.map → chunk-YNJ44IAL.cjs.map} +1 -1
  101. package/dist/{chunk-ZL7UM6PU.cjs → chunk-YSEM7JDE.cjs} +4 -4
  102. package/dist/{chunk-ZL7UM6PU.cjs.map → chunk-YSEM7JDE.cjs.map} +1 -1
  103. package/dist/{chunk-ZO5PBBFX.js → chunk-ZG4XSEZV.js} +72 -15
  104. package/dist/chunk-ZG4XSEZV.js.map +1 -0
  105. package/dist/entries/apps.cjs +43 -42
  106. package/dist/entries/apps.d.cts +2 -2
  107. package/dist/entries/apps.d.ts +2 -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 +153 -153
  112. package/dist/entries/credits.d.cts +1 -1
  113. package/dist/entries/credits.d.ts +1 -1
  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 +66 -66
  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 +8 -4
  149. package/dist/entries/pipeline.d.ts +8 -4
  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 +7 -18
  165. package/dist/entries/workflow.d.ts +7 -18
  166. package/dist/entries/workflow.js +2 -1
  167. package/dist/index.cjs +1708 -1567
  168. package/dist/index.d.cts +9 -9
  169. package/dist/index.d.ts +9 -9
  170. package/dist/index.js +26 -25
  171. package/dist/{model-catalog-V-ZNzRSd.d.ts → model-catalog-I48SvalA.d.cts} +25 -0
  172. package/dist/{model-catalog-V-ZNzRSd.d.cts → model-catalog-I48SvalA.d.ts} +25 -0
  173. package/dist/{presentation-utils-D0kxsWf9.d.cts → presentation-utils-A4i92SYo.d.cts} +1 -1
  174. package/dist/{presentation-utils-pZwlEAzo.d.ts → presentation-utils-DjdPtM9k.d.ts} +1 -1
  175. package/dist/{scene-node-types-C3kl_zyK.d.ts → scene-node-types-Cvbtf-0a.d.cts} +147 -6
  176. package/dist/{scene-node-types-C3kl_zyK.d.cts → scene-node-types-Cvbtf-0a.d.ts} +147 -6
  177. package/dist/{types-DffyGSy5.d.cts → types-CU6SQnMS.d.cts} +0 -5
  178. package/dist/{types-DffyGSy5.d.ts → types-CU6SQnMS.d.ts} +0 -5
  179. package/dist/{types-BRlFPEru.d.ts → types-DzUBR7yr.d.cts} +8 -1
  180. package/dist/{types-BRlFPEru.d.cts → 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__/node-preset-extract.test.ts +10 -0
  192. package/src/__tests__/preview-gate-use-case.test.ts +16 -1
  193. package/src/__tests__/producer-types.test.ts +19 -0
  194. package/src/__tests__/run-continuation.test.ts +4 -1
  195. package/src/__tests__/speaker-map-contract.test.ts +48 -0
  196. package/src/__tests__/unit-contract-compose.test.ts +129 -0
  197. package/src/__tests__/unit-contracts.test.ts +134 -0
  198. package/src/__tests__/use-case-types.test.ts +33 -0
  199. package/src/__tests__/video-catalog-totality.test.ts +15 -1
  200. package/src/__tests__/video-collapse-parity.test.ts +10 -0
  201. package/src/__tests__/video-frame-slot.test.ts +85 -0
  202. package/src/__tests__/video-mode-aliases.test.ts +1 -0
  203. package/src/__tests__/video-reference-only.test.ts +117 -0
  204. package/src/__tests__/vidu-q4-catalog.test.ts +230 -0
  205. package/src/camera-switch-contract.ts +36 -2
  206. package/src/credit-identifiers.ts +19 -6
  207. package/src/entity-asset-types.ts +13 -0
  208. package/src/entries/edl.ts +2 -0
  209. package/src/entries/llm-models.ts +5 -0
  210. package/src/entries/media.ts +1 -0
  211. package/src/entries/models.ts +25 -0
  212. package/src/entries/nodes.ts +5 -1
  213. package/src/fan-out-rows.ts +36 -3
  214. package/src/generate-mask.ts +40 -0
  215. package/src/generated/unit-contracts.ts +58 -0
  216. package/src/i18n/types.ts +13 -2
  217. package/src/json-kinds.ts +24 -4
  218. package/src/llm-models.ts +184 -31
  219. package/src/meta-ads-scrape.ts +16 -8
  220. package/src/model-catalog.ts +91 -13
  221. package/src/model-constants.ts +260 -5
  222. package/src/node-default-mappings.ts +3 -0
  223. package/src/node-preset-extract.ts +8 -0
  224. package/src/pipeline-types.ts +3 -0
  225. package/src/presentation-utils.ts +12 -12
  226. package/src/preview-gate.ts +4 -2
  227. package/src/producer-types.ts +19 -19
  228. package/src/run-continuation.ts +26 -4
  229. package/src/speaker-layouts.ts +8 -3
  230. package/src/speaker-map-contract.ts +77 -0
  231. package/src/unit-contract-compose.ts +55 -0
  232. package/src/use-case-types.ts +19 -0
  233. package/src/video-ui-defaults.ts +7 -5
  234. package/dist/chunk-23FJQTEA.js.map +0 -1
  235. package/dist/chunk-5PC6JBGJ.cjs.map +0 -1
  236. package/dist/chunk-5RYLK3MQ.js.map +0 -1
  237. package/dist/chunk-7Z5LUTGU.js.map +0 -1
  238. package/dist/chunk-BG5D5CZ6.js.map +0 -1
  239. package/dist/chunk-CK3GK34R.js.map +0 -1
  240. package/dist/chunk-D26ENTN2.cjs.map +0 -1
  241. package/dist/chunk-D6GNRSCV.cjs.map +0 -1
  242. package/dist/chunk-HC7VKIV5.cjs.map +0 -1
  243. package/dist/chunk-HGC5JNVA.cjs.map +0 -1
  244. package/dist/chunk-JL4C5VJ7.cjs.map +0 -1
  245. package/dist/chunk-K3LLGRK7.cjs.map +0 -1
  246. package/dist/chunk-M36G6SRP.js.map +0 -1
  247. package/dist/chunk-M7GQBRZU.cjs.map +0 -1
  248. package/dist/chunk-PHZ23DP3.js.map +0 -1
  249. package/dist/chunk-PQHS255G.js.map +0 -1
  250. package/dist/chunk-PRYE7AZQ.cjs.map +0 -1
  251. package/dist/chunk-PVJBAPYJ.js.map +0 -1
  252. package/dist/chunk-PXFQVLBX.js.map +0 -1
  253. package/dist/chunk-QA3MVQ32.js.map +0 -1
  254. package/dist/chunk-SES6GDBQ.cjs.map +0 -1
  255. package/dist/chunk-TU33KYKW.cjs +0 -25
  256. package/dist/chunk-TU33KYKW.cjs.map +0 -1
  257. package/dist/chunk-VA42637J.cjs.map +0 -1
  258. package/dist/chunk-VXPLKQWY.cjs.map +0 -1
  259. package/dist/chunk-WDIBOWAA.js.map +0 -1
  260. package/dist/chunk-YBPBK5KI.js.map +0 -1
  261. package/dist/chunk-YYV35XOS.js.map +0 -1
  262. package/dist/chunk-Z2OL5AJD.cjs.map +0 -1
  263. package/dist/chunk-ZDFHA2EC.js.map +0 -1
  264. package/dist/chunk-ZO5PBBFX.js.map +0 -1
  265. package/dist/chunk-ZRL2UFTH.cjs.map +0 -1
  266. package/src/__tests__/__snapshots__/prompt-builder-segments.test.ts.snap +0 -65
@@ -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
+ })
@@ -5,7 +5,7 @@ import {
5
5
  aspectRatioOptionsByKind,
6
6
  durationsByMode,
7
7
  } from "../model-catalog.js"
8
- import { VIDEO_GEN_PROVIDERS } from "../model-constants.js"
8
+ import { VIDEO_GEN_PROVIDERS, VIDEO_TO_VIDEO_PROVIDERS } from "../model-constants.js"
9
9
 
10
10
  /**
11
11
  * Every video model a user can pick must have a catalog entry. The catalog is
@@ -42,6 +42,20 @@ describe("MODEL_CATALOG covers every generatable video provider", () => {
42
42
  })
43
43
  })
44
44
 
45
+ /**
46
+ * Every /v1/video-to-video model is listed too, as a "v2v" video entry —
47
+ * `/v1/models` and MCP `list_models` read only the catalog, so a model outside
48
+ * it is one no client can offer (luma-modify was, until 2026-10-19).
49
+ */
50
+ describe("MODEL_CATALOG covers every video-to-video provider", () => {
51
+ it.each([...VIDEO_TO_VIDEO_PROVIDERS])("%s has a v2v video entry", (p) => {
52
+ const entry = MODEL_CATALOG[p]
53
+ expect(entry, `Add a MODEL_CATALOG entry for ${p}`).toBeDefined()
54
+ expect(entry!.kind).toBe("video")
55
+ expect(entry!.modes).toContain("v2v")
56
+ })
57
+ })
58
+
45
59
  /**
46
60
  * Deleting the LTX hand-splices in frontend/model-options.ts (Task 7 step 5)
47
61
  * hands resolution/aspect/duration option rendering to these catalog-derived
@@ -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
+ })
@@ -0,0 +1,230 @@
1
+ import { describe, it, expect } from "vitest"
2
+ import { MODEL_CATALOG, MODEL_MAKERS, normalizeVideoRequestParams } from "../model-catalog.js"
3
+ import {
4
+ IMAGE_TO_VIDEO_PROVIDERS,
5
+ TEXT_TO_VIDEO_PROVIDERS,
6
+ VIDEO_REF_LIMITS_BY_PROVIDER,
7
+ VIDEO_PROVIDERS_REQUIRING_IMAGE,
8
+ getVideoAudioCapability,
9
+ defaultVideoAspectRatio,
10
+ getMaxVideoPromptChars,
11
+ VIDU_Q4_PROVIDERS,
12
+ isViduQ4Provider,
13
+ VIDU_Q4_DEFAULT_RESOLUTION,
14
+ normalizeViduQ4Resolution,
15
+ isWan3Provider,
16
+ isSeedance2Provider,
17
+ isMinimaxH3Provider,
18
+ DURATION_PRICED_PROVIDERS,
19
+ VIDEO_DURATION_TIERS,
20
+ RESOLUTION_DURATION_PRICING,
21
+ PRICING_DEFAULT_RESOLUTION,
22
+ NATIVE_ADAPTIVE_ASPECT,
23
+ VIDEO_REF_AUDIO_RULES,
24
+ checkRefAudioRules,
25
+ resolveVideoModeForInputs,
26
+ videoProviderFoldsLoneEndFrame,
27
+ GVP_EXTEND_PROVIDERS,
28
+ } from "../model-constants.js"
29
+ import { buildVideoCreditModelIdentifier, videoGenerationCreditId } from "../credit-identifiers.js"
30
+ import { uiDurationFill, uiResolutionFill } from "../video-ui-defaults.js"
31
+
32
+ const ID = "vidu-q4"
33
+ const DURATIONS_3_TO_16 = Array.from({ length: 14 }, (_, i) => i + 3)
34
+ const RESOLUTIONS = ["540p", "720p", "1080p", "2k", "4k"] as const
35
+
36
+ describe("vidu-q4 catalog", () => {
37
+ const entry = MODEL_CATALOG[ID]!
38
+
39
+ it("is ONE i2v-only id made by ShengShu (no t2v mode exists on KIE)", () => {
40
+ expect(entry.kind).toBe("video")
41
+ expect([...entry.modes]).toEqual(["i2v"])
42
+ expect(entry.label).toBe("Vidu Q4")
43
+ expect(entry.series).toBe("Vidu")
44
+ expect(entry.maker).toBe("shengshu")
45
+ expect(MODEL_MAKERS.shengshu.name).toBe("ShengShu")
46
+ })
47
+
48
+ it("lists resolutions ASCENDING with lowercase 2k/4k; the 720p default is declared, not index 0", () => {
49
+ expect(entry.resolutions).toEqual([...RESOLUTIONS])
50
+ expect(PRICING_DEFAULT_RESOLUTION[ID]).toBe("720p")
51
+ expect(VIDU_Q4_DEFAULT_RESOLUTION).toBe("720p")
52
+ expect(entry.unlistedResolutionRendersAs).toBe("720p")
53
+ })
54
+
55
+ it("offers every integer second 3-16 with a 5s default", () => {
56
+ expect(entry.durations).toEqual(DURATIONS_3_TO_16)
57
+ expect(entry.defaultDuration).toBe(5)
58
+ })
59
+
60
+ it("carries the reference-to-video ratio enum and takes no seed", () => {
61
+ expect(entry.aspectRatios).toEqual(["16:9", "9:16", "1:1", "4:3", "3:4"])
62
+ expect(entry.noSeed).toBe(true)
63
+ })
64
+
65
+ it("declares audio + reference-image + reference-to-video, and NOT end-frame or video-reference", () => {
66
+ // reference-to-video: the reference endpoint runs from reference images
67
+ // alone (no start frame), so a references-only run is never image-gated.
68
+ expect([...(entry.features ?? [])].sort()).toEqual(["audio", "reference-image", "reference-to-video"])
69
+ })
70
+ })
71
+
72
+ describe("vidu-q4 capability sets", () => {
73
+ it("is in both route enums and image-gated on the t2v route", () => {
74
+ expect(IMAGE_TO_VIDEO_PROVIDERS as readonly string[]).toContain(ID)
75
+ expect(TEXT_TO_VIDEO_PROVIDERS as readonly string[]).toContain(ID)
76
+ expect(VIDEO_PROVIDERS_REQUIRING_IMAGE.has(ID)).toBe(true)
77
+ })
78
+
79
+ it("routes a start frame to image-to-video and a prompt-only run to the gated t2v lane", () => {
80
+ expect(resolveVideoModeForInputs(ID, { hasStartFrame: true, hasImageRefs: false })).toBe("image-to-video")
81
+ expect(resolveVideoModeForInputs(ID, { hasStartFrame: true, hasImageRefs: true })).toBe("image-to-video")
82
+ expect(resolveVideoModeForInputs(ID, { hasStartFrame: false, hasImageRefs: false })).toBe("text-to-video")
83
+ })
84
+
85
+ it("has no home for a lone end frame (no fold into the references)", () => {
86
+ expect(videoProviderFoldsLoneEndFrame(ID)).toBe(false)
87
+ })
88
+
89
+ it("carries 15 reference images and 3 reference audio clips, no reference videos", () => {
90
+ expect(VIDEO_REF_LIMITS_BY_PROVIDER[ID]).toEqual({ images: 15, audio: 3 })
91
+ })
92
+
93
+ it("audio: ambient behind the model's own `audio` boolean, default on, not cost-affecting", () => {
94
+ expect(getVideoAudioCapability(ID)).toEqual({ mode: "ambient", field: "audio", defaultOn: true })
95
+ })
96
+
97
+ it("keeps the historical 16:9 aspect default (no adaptive token on its enum)", () => {
98
+ expect(defaultVideoAspectRatio(ID)).toBe("16:9")
99
+ expect(NATIVE_ADAPTIVE_ASPECT[ID]).toBeUndefined()
100
+ })
101
+
102
+ it("prompt cap is the documented 20000 chars", () => {
103
+ expect(getMaxVideoPromptChars(ID)).toBe(20000)
104
+ })
105
+
106
+ it("is a family of its own", () => {
107
+ expect([...VIDU_Q4_PROVIDERS]).toEqual([ID])
108
+ expect(isViduQ4Provider(ID)).toBe(true)
109
+ expect(isViduQ4Provider("vidu")).toBe(false)
110
+ expect(isViduQ4Provider(undefined)).toBe(false)
111
+ expect(isWan3Provider(ID) || isSeedance2Provider(ID) || isMinimaxH3Provider(ID)).toBe(false)
112
+ })
113
+
114
+ it("renders keyframes only in generate-video-pro (no video-reference feature)", () => {
115
+ expect(GVP_EXTEND_PROVIDERS as readonly string[]).not.toContain(ID)
116
+ })
117
+
118
+ it("fills the 720p / 5s defaults rather than the ladder's first rung", () => {
119
+ expect(uiResolutionFill(ID)).toBe("720p")
120
+ expect(uiDurationFill(ID)).toBe(5)
121
+ })
122
+ })
123
+
124
+ describe("normalizeViduQ4Resolution", () => {
125
+ it("keeps every supported tier, case-insensitively, in the lowercase wire spelling", () => {
126
+ for (const r of RESOLUTIONS) {
127
+ expect(normalizeViduQ4Resolution(r)).toBe(r)
128
+ expect(normalizeViduQ4Resolution(r.toUpperCase())).toBe(r)
129
+ }
130
+ expect(normalizeViduQ4Resolution(" 2K ")).toBe("2k")
131
+ })
132
+
133
+ it("collapses undefined / garbage / an off-menu tier to the 720p default", () => {
134
+ for (const v of [undefined, "", "480p", "8k", "nonsense"]) {
135
+ expect(normalizeViduQ4Resolution(v)).toBe("720p")
136
+ }
137
+ })
138
+
139
+ it("the catalog funnel canonicalises an uppercase 2K/4K to the lowercase band", () => {
140
+ expect(normalizeVideoRequestParams(ID, { resolution: "4K" }).resolution).toBe("4k")
141
+ expect(normalizeVideoRequestParams(ID, { resolution: "2K" }).resolution).toBe("2k")
142
+ })
143
+ })
144
+
145
+ describe("vidu-q4 credit identifier", () => {
146
+ it("is duration-priced with one tier per allowed second 3-16", () => {
147
+ expect(DURATION_PRICED_PROVIDERS.has(ID)).toBe(true)
148
+ expect(VIDEO_DURATION_TIERS[ID]!.map((t) => t.maxSeconds)).toEqual(DURATIONS_3_TO_16)
149
+ expect(RESOLUTION_DURATION_PRICING[ID]).toEqual([...RESOLUTIONS])
150
+ })
151
+
152
+ it("emits exactly one composite per (duration, resolution) pair — 70 distinct ids", () => {
153
+ const ids = new Set<string>()
154
+ for (const d of DURATIONS_3_TO_16) {
155
+ for (const r of RESOLUTIONS) {
156
+ const id = buildVideoCreditModelIdentifier(ID, d, undefined, "image-to-video", undefined, r)
157
+ expect(id).toBe(`${ID}:${d}s:${r}`)
158
+ ids.add(id)
159
+ }
160
+ }
161
+ expect(ids.size).toBe(70)
162
+ })
163
+
164
+ it("prices an OMITTED resolution and duration at the declared 5s 720p default", () => {
165
+ expect(buildVideoCreditModelIdentifier(ID, undefined, undefined, "image-to-video")).toBe("vidu-q4:5s:720p")
166
+ expect(videoGenerationCreditId({ provider: ID })).toBe("vidu-q4:5s:720p")
167
+ })
168
+
169
+ it("bills the tier it RENDERS for every spelling, and 720p for anything unknown", () => {
170
+ expect(buildVideoCreditModelIdentifier(ID, 8, undefined, "image-to-video", undefined, "4K")).toBe("vidu-q4:8s:4k")
171
+ expect(buildVideoCreditModelIdentifier(ID, 8, undefined, "image-to-video", undefined, "480p")).toBe("vidu-q4:8s:720p")
172
+ expect(buildVideoCreditModelIdentifier(ID, 8, undefined, "image-to-video", undefined, "nonsense")).toBe("vidu-q4:8s:720p")
173
+ })
174
+
175
+ it("has no audio and no reference dimension — one ladder for both endpoints", () => {
176
+ const plain = buildVideoCreditModelIdentifier(ID, 6, undefined, "image-to-video", undefined, "1080p")
177
+ expect(buildVideoCreditModelIdentifier(ID, 6, true, "image-to-video", undefined, "1080p")).toBe(plain)
178
+ expect(buildVideoCreditModelIdentifier(ID, 6, false, "image-to-video", undefined, "1080p")).toBe(plain)
179
+ expect(buildVideoCreditModelIdentifier(ID, 6, undefined, "image-to-video", undefined, "1080p", true)).toBe(plain)
180
+ })
181
+
182
+ it("snaps an off-menu duration into a seeded tier", () => {
183
+ expect(buildVideoCreditModelIdentifier(ID, 2, undefined, "image-to-video", undefined, "720p")).toBe("vidu-q4:3s:720p")
184
+ expect(buildVideoCreditModelIdentifier(ID, 40, undefined, "image-to-video", undefined, "720p")).toBe("vidu-q4:16s:720p")
185
+ })
186
+
187
+ it("every catalog pricing row is an id the builder can emit (or the bare default)", () => {
188
+ const emittable = new Set<string>([ID])
189
+ for (const d of DURATIONS_3_TO_16) for (const r of RESOLUTIONS) emittable.add(`${ID}:${d}s:${r}`)
190
+ for (const row of MODEL_CATALOG[ID]!.pricing) expect(emittable.has(row.identifier), row.identifier).toBe(true)
191
+ })
192
+ })
193
+
194
+ describe("vidu-q4 reference-audio rules", () => {
195
+ it("declares MP3-only clips of 3-12 seconds", () => {
196
+ expect(VIDEO_REF_AUDIO_RULES[ID]).toEqual({ formats: ["mp3"], minSec: 3, maxSec: 12 })
197
+ })
198
+
199
+ it("accepts MP3 clips inside the window", () => {
200
+ expect(checkRefAudioRules(ID, [{ formatNames: ["mp3"], durationSec: 3 }, { formatNames: ["mp3"], durationSec: 12 }])).toEqual({ ok: true })
201
+ })
202
+
203
+ it("refuses a non-MP3 clip with the format code", () => {
204
+ const r = checkRefAudioRules(ID, [{ formatNames: ["mp3"], durationSec: 5 }, { formatNames: ["wav"], durationSec: 5 }])
205
+ expect(r.ok).toBe(false)
206
+ if (!r.ok) {
207
+ expect(r.code).toBe("audio_format_unsupported")
208
+ expect(r.message).toContain("Reference audio 2")
209
+ expect(r.message).toContain("MP3")
210
+ }
211
+ const m4a = checkRefAudioRules(ID, [{ formatNames: ["mov", "mp4", "m4a", "3gp", "3g2", "mj2"], durationSec: 5 }])
212
+ expect(m4a.ok).toBe(false)
213
+ })
214
+
215
+ it("refuses a clip outside 3-12 seconds", () => {
216
+ const short = checkRefAudioRules(ID, [{ formatNames: ["mp3"], durationSec: 2.5 }])
217
+ expect(short.ok === false && short.code).toBe("audio_too_short")
218
+ const long = checkRefAudioRules(ID, [{ formatNames: ["mp3"], durationSec: 12.4 }])
219
+ expect(long.ok === false && long.code).toBe("audio_too_long")
220
+ })
221
+
222
+ it("ignores whatever a probe could not read — a blip never blocks a run", () => {
223
+ expect(checkRefAudioRules(ID, [{}, { durationSec: Number.NaN }, { formatNames: [] }])).toEqual({ ok: true })
224
+ })
225
+
226
+ it("is a no-op for a provider with no declared rule", () => {
227
+ expect(checkRefAudioRules("wan-3", [{ formatNames: ["wav"], durationSec: 1 }])).toEqual({ ok: true })
228
+ expect(checkRefAudioRules(undefined, [{ formatNames: ["wav"] }])).toEqual({ ok: true })
229
+ })
230
+ })