@nodaro/shared 3.60.1 → 3.62.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 (261) hide show
  1. package/dist/{chunk-5Y42RIGY.cjs → chunk-2D5LQFV4.cjs} +18 -332
  2. package/dist/chunk-2D5LQFV4.cjs.map +1 -0
  3. package/dist/{chunk-5G23AJBU.cjs → chunk-2HZGDZZN.cjs} +6 -6
  4. package/dist/{chunk-5G23AJBU.cjs.map → chunk-2HZGDZZN.cjs.map} +1 -1
  5. package/dist/{chunk-DS2TOM32.js → chunk-2QKF7M2Z.js} +28 -4
  6. package/dist/chunk-2QKF7M2Z.js.map +1 -0
  7. package/dist/{chunk-CIOXUPCJ.cjs → chunk-2W745U4A.cjs} +228 -355
  8. package/dist/chunk-2W745U4A.cjs.map +1 -0
  9. package/dist/{chunk-LN3EVFRS.js → chunk-3OYO3XCC.js} +70 -6
  10. package/dist/chunk-3OYO3XCC.js.map +1 -0
  11. package/dist/{chunk-5HK5Z5OB.cjs → chunk-4ZEFP2FQ.cjs} +4 -4
  12. package/dist/{chunk-5HK5Z5OB.cjs.map → chunk-4ZEFP2FQ.cjs.map} +1 -1
  13. package/dist/{chunk-KOLC7AF2.js → chunk-5YYN5X57.js} +398 -38
  14. package/dist/chunk-5YYN5X57.js.map +1 -0
  15. package/dist/{chunk-RRPPXZ36.cjs → chunk-6CSXMWL4.cjs} +4 -4
  16. package/dist/{chunk-RRPPXZ36.cjs.map → chunk-6CSXMWL4.cjs.map} +1 -1
  17. package/dist/{chunk-M3SXUUWC.cjs → chunk-6FQBKI2A.cjs} +4 -11
  18. package/dist/chunk-6FQBKI2A.cjs.map +1 -0
  19. package/dist/{chunk-G4XWVWRI.js → chunk-6G7NN4S4.js} +5 -4
  20. package/dist/chunk-6G7NN4S4.js.map +1 -0
  21. package/dist/{chunk-HOKWJXHA.cjs → chunk-A2PX5IRC.cjs} +31 -4
  22. package/dist/chunk-A2PX5IRC.cjs.map +1 -0
  23. package/dist/{chunk-W4M7TNXG.cjs → chunk-AFYTX4AI.cjs} +52 -43
  24. package/dist/chunk-AFYTX4AI.cjs.map +1 -0
  25. package/dist/chunk-ALRXY4QH.cjs +13 -0
  26. package/dist/chunk-ALRXY4QH.cjs.map +1 -0
  27. package/dist/chunk-AOJ6B7K4.cjs +351 -0
  28. package/dist/chunk-AOJ6B7K4.cjs.map +1 -0
  29. package/dist/{chunk-KJZVQIN4.js → chunk-C7POAYFE.js} +3 -3
  30. package/dist/{chunk-KJZVQIN4.js.map → chunk-C7POAYFE.js.map} +1 -1
  31. package/dist/{chunk-6Q6SI7AG.js → chunk-CC4V2B7S.js} +3 -3
  32. package/dist/{chunk-6Q6SI7AG.js.map → chunk-CC4V2B7S.js.map} +1 -1
  33. package/dist/{chunk-GNPJ2JLE.cjs → chunk-CIPPPT7E.cjs} +6 -6
  34. package/dist/{chunk-GNPJ2JLE.cjs.map → chunk-CIPPPT7E.cjs.map} +1 -1
  35. package/dist/{chunk-6XVHYD5R.js → chunk-CLAKSLXF.js} +4 -9
  36. package/dist/chunk-CLAKSLXF.js.map +1 -0
  37. package/dist/chunk-CTANEPMY.js +61 -0
  38. package/dist/chunk-CTANEPMY.js.map +1 -0
  39. package/dist/{chunk-WGKAOUEQ.cjs → chunk-D34K455O.cjs} +3 -2
  40. package/dist/chunk-D34K455O.cjs.map +1 -0
  41. package/dist/chunk-E2HZTGYX.js +331 -0
  42. package/dist/chunk-E2HZTGYX.js.map +1 -0
  43. package/dist/{chunk-SKFJIFEV.cjs → chunk-G3KVK7OU.cjs} +21 -21
  44. package/dist/{chunk-SKFJIFEV.cjs.map → chunk-G3KVK7OU.cjs.map} +1 -1
  45. package/dist/chunk-G4U3HW6W.js +453 -0
  46. package/dist/chunk-G4U3HW6W.js.map +1 -0
  47. package/dist/{chunk-EN2YI5TV.js → chunk-GSFB537T.js} +3 -3
  48. package/dist/{chunk-EN2YI5TV.js.map → chunk-GSFB537T.js.map} +1 -1
  49. package/dist/chunk-HRY7KGAE.cjs +506 -0
  50. package/dist/chunk-HRY7KGAE.cjs.map +1 -0
  51. package/dist/{chunk-6AJOTEVC.js → chunk-I2RQB7VG.js} +3 -3
  52. package/dist/{chunk-6AJOTEVC.js.map → chunk-I2RQB7VG.js.map} +1 -1
  53. package/dist/chunk-IDTKF5EX.cjs +48 -0
  54. package/dist/chunk-IDTKF5EX.cjs.map +1 -0
  55. package/dist/{chunk-DQIJPDHC.cjs → chunk-IWWVPR3W.cjs} +88 -11
  56. package/dist/chunk-IWWVPR3W.cjs.map +1 -0
  57. package/dist/{chunk-URLDVK67.js → chunk-JJNNM23P.js} +3 -3
  58. package/dist/{chunk-URLDVK67.js.map → chunk-JJNNM23P.js.map} +1 -1
  59. package/dist/{chunk-YHVEZVAO.js → chunk-JZGZ26YB.js} +6 -306
  60. package/dist/chunk-JZGZ26YB.js.map +1 -0
  61. package/dist/{chunk-XROE3CAS.cjs → chunk-KHH54GRP.cjs} +120 -79
  62. package/dist/chunk-KHH54GRP.cjs.map +1 -0
  63. package/dist/{chunk-AXT7YNOR.cjs → chunk-KJSRPHJ2.cjs} +48 -47
  64. package/dist/chunk-KJSRPHJ2.cjs.map +1 -0
  65. package/dist/{chunk-FVVD6XY2.js → chunk-KL6GAYTT.js} +13 -4
  66. package/dist/chunk-KL6GAYTT.js.map +1 -0
  67. package/dist/{chunk-AFQFGZN7.cjs → chunk-KYMHFVAZ.cjs} +8 -6
  68. package/dist/chunk-KYMHFVAZ.cjs.map +1 -0
  69. package/dist/{chunk-A6HRY3WF.cjs → chunk-MYJQELFN.cjs} +420 -37
  70. package/dist/chunk-MYJQELFN.cjs.map +1 -0
  71. package/dist/chunk-N5HH46JF.cjs +68 -0
  72. package/dist/chunk-N5HH46JF.cjs.map +1 -0
  73. package/dist/{chunk-BXNPO3PL.cjs → chunk-N7OUQK7E.cjs} +8 -8
  74. package/dist/{chunk-BXNPO3PL.cjs.map → chunk-N7OUQK7E.cjs.map} +1 -1
  75. package/dist/{chunk-JKZVRKN3.js → chunk-NGKKNSK6.js} +31 -8
  76. package/dist/chunk-NGKKNSK6.js.map +1 -0
  77. package/dist/{chunk-SWVGHAYO.js → chunk-O7RZRUMZ.js} +110 -74
  78. package/dist/chunk-O7RZRUMZ.js.map +1 -0
  79. package/dist/{chunk-SCYBGTX6.js → chunk-PTD6EDUU.js} +3 -3
  80. package/dist/{chunk-SCYBGTX6.js.map → chunk-PTD6EDUU.js.map} +1 -1
  81. package/dist/{chunk-BDXXOEBZ.cjs → chunk-QWYFHQYK.cjs} +79 -54
  82. package/dist/chunk-QWYFHQYK.cjs.map +1 -0
  83. package/dist/{chunk-VB2ARGQ6.js → chunk-RGNHHIMN.js} +3 -3
  84. package/dist/chunk-RGNHHIMN.js.map +1 -0
  85. package/dist/{chunk-AZGONXWV.js → chunk-S24ZBUB4.js} +194 -299
  86. package/dist/chunk-S24ZBUB4.js.map +1 -0
  87. package/dist/{chunk-IV6IDECY.js → chunk-S5TMRJMX.js} +4 -4
  88. package/dist/{chunk-IV6IDECY.js.map → chunk-S5TMRJMX.js.map} +1 -1
  89. package/dist/chunk-SMOO5FAH.js +10 -0
  90. package/dist/chunk-SMOO5FAH.js.map +1 -0
  91. package/dist/{chunk-HYBACFYW.js → chunk-SYWR5G3T.js} +16 -7
  92. package/dist/chunk-SYWR5G3T.js.map +1 -0
  93. package/dist/{chunk-GWBQ3GPO.cjs → chunk-TRVWMKNE.cjs} +343 -53
  94. package/dist/chunk-TRVWMKNE.cjs.map +1 -0
  95. package/dist/{chunk-G6GMY5BC.js → chunk-UDDVDQMF.js} +298 -36
  96. package/dist/chunk-UDDVDQMF.js.map +1 -0
  97. package/dist/{chunk-PONP5J5E.cjs → chunk-V24EPI5N.cjs} +13 -3
  98. package/dist/chunk-V24EPI5N.cjs.map +1 -0
  99. package/dist/{chunk-HDHLZK7C.cjs → chunk-VACPZPUA.cjs} +5 -5
  100. package/dist/{chunk-HDHLZK7C.cjs.map → chunk-VACPZPUA.cjs.map} +1 -1
  101. package/dist/{chunk-ICDLYU4I.js → chunk-Y6X7UJSD.js} +10 -9
  102. package/dist/chunk-Y6X7UJSD.js.map +1 -0
  103. package/dist/chunk-YCXRSWCQ.js +42 -0
  104. package/dist/chunk-YCXRSWCQ.js.map +1 -0
  105. package/dist/entries/apps.cjs +44 -44
  106. package/dist/entries/apps.js +9 -9
  107. package/dist/entries/credits.cjs +217 -152
  108. package/dist/entries/credits.d.cts +112 -6
  109. package/dist/entries/credits.d.ts +112 -6
  110. package/dist/entries/credits.js +13 -8
  111. package/dist/entries/entities.cjs +188 -143
  112. package/dist/entries/entities.d.cts +122 -1
  113. package/dist/entries/entities.d.ts +122 -1
  114. package/dist/entries/entities.js +2 -1
  115. package/dist/entries/llm-models.d.cts +2 -1
  116. package/dist/entries/llm-models.d.ts +2 -1
  117. package/dist/entries/media.cjs +92 -87
  118. package/dist/entries/media.d.cts +11 -1
  119. package/dist/entries/media.d.ts +11 -1
  120. package/dist/entries/media.js +3 -2
  121. package/dist/entries/model-catalog.cjs +207 -99
  122. package/dist/entries/model-catalog.d.cts +90 -4
  123. package/dist/entries/model-catalog.d.ts +90 -4
  124. package/dist/entries/model-catalog.js +5 -5
  125. package/dist/entries/models.cjs +407 -294
  126. package/dist/entries/models.d.cts +4 -3
  127. package/dist/entries/models.d.ts +4 -3
  128. package/dist/entries/models.js +6 -5
  129. package/dist/entries/nodes.cjs +241 -233
  130. package/dist/entries/nodes.d.cts +15 -2
  131. package/dist/entries/nodes.d.ts +15 -2
  132. package/dist/entries/nodes.js +10 -10
  133. package/dist/entries/pipeline.cjs +152 -152
  134. package/dist/entries/pipeline.d.cts +2 -1
  135. package/dist/entries/pipeline.d.ts +2 -1
  136. package/dist/entries/pipeline.js +3 -3
  137. package/dist/entries/ugc.cjs +71 -71
  138. package/dist/entries/ugc.js +4 -4
  139. package/dist/entries/video.cjs +308 -204
  140. package/dist/entries/video.d.cts +480 -98
  141. package/dist/entries/video.d.ts +480 -98
  142. package/dist/entries/video.js +8 -4
  143. package/dist/entries/workflow.cjs +111 -99
  144. package/dist/entries/workflow.d.cts +29 -2
  145. package/dist/entries/workflow.d.ts +29 -2
  146. package/dist/entries/workflow.js +2 -2
  147. package/dist/{gpt-image-2-6-BeZdT-pW.d.cts → gpt-image-2-6-jIRQBRag.d.cts} +6 -0
  148. package/dist/{gpt-image-2-6-BeZdT-pW.d.ts → gpt-image-2-6-jIRQBRag.d.ts} +6 -0
  149. package/dist/index.cjs +2321 -1870
  150. package/dist/index.d.cts +10 -10
  151. package/dist/index.d.ts +10 -10
  152. package/dist/index.js +26 -23
  153. package/dist/{model-catalog-D6Es7VG-.d.cts → model-catalog-CCEcv08q.d.cts} +179 -14
  154. package/dist/{model-catalog-D6Es7VG-.d.ts → model-catalog-CCEcv08q.d.ts} +179 -14
  155. package/dist/{model-constants-22k3fjp1.d.cts → model-constants-B88p6XR0.d.ts} +305 -20
  156. package/dist/{model-constants-22k3fjp1.d.ts → model-constants-Cf3zaITt.d.cts} +305 -20
  157. package/package.json +1 -1
  158. package/src/__tests__/extend-providers.test.ts +114 -0
  159. package/src/__tests__/fixtures/mask-composite-quote-parity.json +118 -0
  160. package/src/__tests__/fixtures/root-exports.baseline.json +68 -0
  161. package/src/__tests__/gpt-image-2-6-formats.test.ts +4 -1
  162. package/src/__tests__/gpt-image-2-6.test.ts +7 -0
  163. package/src/__tests__/grok-video-15-catalog.test.ts +189 -0
  164. package/src/__tests__/gvp-supported-providers.test.ts +5 -2
  165. package/src/__tests__/image-mask-mode.test.ts +34 -1
  166. package/src/__tests__/mask-edit-follows-source.test.ts +150 -0
  167. package/src/__tests__/minimax-h3-image.test.ts +140 -0
  168. package/src/__tests__/model-makers.test.ts +49 -11
  169. package/src/__tests__/model-tree.test.ts +13 -0
  170. package/src/__tests__/retired-video-provider.test.ts +15 -5
  171. package/src/__tests__/seedance-25-catalog-modes.test.ts +1 -1
  172. package/src/__tests__/seedance-task-type.test.ts +178 -0
  173. package/src/__tests__/seedream-5-5.test.ts +117 -0
  174. package/src/__tests__/unit-contract-compose.test.ts +27 -1
  175. package/src/__tests__/unit-contracts.test.ts +20 -6
  176. package/src/__tests__/upscale-factors.test.ts +107 -0
  177. package/src/__tests__/video-character-refs.test.ts +20 -2
  178. package/src/__tests__/video-collapse-parity.test.ts +19 -0
  179. package/src/__tests__/video-overlay-geometry.test.ts +68 -0
  180. package/src/__tests__/video-overlay-layer-plan.test.ts +3 -4
  181. package/src/__tests__/video-overlay-layouts.test.ts +529 -0
  182. package/src/__tests__/video-overlay-pricing.test.ts +61 -0
  183. package/src/__tests__/video-overlay-validate.test.ts +128 -0
  184. package/src/__tests__/video-overlay-wired-kind.test.ts +207 -0
  185. package/src/__tests__/video-overlay.test.ts +280 -194
  186. package/src/__tests__/video-ref-limits.test.ts +2 -1
  187. package/src/__tests__/video-reference-only.test.ts +6 -2
  188. package/src/__tests__/video-start-frame-only.test.ts +98 -0
  189. package/src/__tests__/wired-character-names.test.ts +220 -0
  190. package/src/credit-estimators/index.ts +8 -0
  191. package/src/credit-estimators/video-overlay.ts +70 -0
  192. package/src/credit-identifiers.ts +102 -5
  193. package/src/entity-image-url.ts +21 -0
  194. package/src/entries/credits.ts +14 -0
  195. package/src/entries/entities.ts +14 -0
  196. package/src/entries/model-catalog.ts +39 -1
  197. package/src/entries/models.ts +34 -0
  198. package/src/entries/nodes.ts +2 -0
  199. package/src/entries/video.ts +6 -0
  200. package/src/entries/workflow.ts +1 -0
  201. package/src/generated/unit-contracts.ts +8 -1
  202. package/src/gpt-image-2-6.ts +6 -0
  203. package/src/input-image-pricing.ts +76 -0
  204. package/src/mask-composite.ts +11 -0
  205. package/src/minimax-h3-image.ts +61 -0
  206. package/src/model-catalog.ts +512 -48
  207. package/src/model-constants.ts +602 -34
  208. package/src/node-default-mappings.ts +12 -2
  209. package/src/node-execution-state.ts +4 -1
  210. package/src/producer-types.ts +23 -1
  211. package/src/seedance-task-type.ts +37 -0
  212. package/src/seedream-5-5.ts +45 -0
  213. package/src/unit-contract-compose.ts +4 -1
  214. package/src/upscale-factors.ts +111 -0
  215. package/src/video-character-refs.ts +7 -4
  216. package/src/video-overlay-geometry.ts +99 -0
  217. package/src/video-overlay-input.ts +25 -0
  218. package/src/video-overlay-layout-ids.ts +48 -0
  219. package/src/video-overlay-layouts.ts +315 -0
  220. package/src/video-overlay-validate.ts +223 -0
  221. package/src/video-overlay-video-layers.ts +304 -0
  222. package/src/video-overlay.ts +165 -297
  223. package/src/video-ui-defaults.ts +8 -6
  224. package/src/wired-character-names.ts +202 -0
  225. package/src/wired-image-size.ts +55 -0
  226. package/dist/chunk-5Y42RIGY.cjs.map +0 -1
  227. package/dist/chunk-6XVHYD5R.js.map +0 -1
  228. package/dist/chunk-A6HRY3WF.cjs.map +0 -1
  229. package/dist/chunk-AFQFGZN7.cjs.map +0 -1
  230. package/dist/chunk-AXT7YNOR.cjs.map +0 -1
  231. package/dist/chunk-AZGONXWV.js.map +0 -1
  232. package/dist/chunk-BDXXOEBZ.cjs.map +0 -1
  233. package/dist/chunk-CIOXUPCJ.cjs.map +0 -1
  234. package/dist/chunk-DQIJPDHC.cjs.map +0 -1
  235. package/dist/chunk-DS2TOM32.js.map +0 -1
  236. package/dist/chunk-FVVD6XY2.js.map +0 -1
  237. package/dist/chunk-G4XWVWRI.js.map +0 -1
  238. package/dist/chunk-G6GMY5BC.js.map +0 -1
  239. package/dist/chunk-G7ZYZQKO.cjs +0 -27
  240. package/dist/chunk-G7ZYZQKO.cjs.map +0 -1
  241. package/dist/chunk-GWBQ3GPO.cjs.map +0 -1
  242. package/dist/chunk-HNEF2N5C.cjs +0 -19
  243. package/dist/chunk-HNEF2N5C.cjs.map +0 -1
  244. package/dist/chunk-HOKWJXHA.cjs.map +0 -1
  245. package/dist/chunk-HYBACFYW.js.map +0 -1
  246. package/dist/chunk-ICDLYU4I.js.map +0 -1
  247. package/dist/chunk-JKZVRKN3.js.map +0 -1
  248. package/dist/chunk-KOLC7AF2.js.map +0 -1
  249. package/dist/chunk-LN3EVFRS.js.map +0 -1
  250. package/dist/chunk-M3SXUUWC.cjs.map +0 -1
  251. package/dist/chunk-MHY47BLL.js +0 -23
  252. package/dist/chunk-MHY47BLL.js.map +0 -1
  253. package/dist/chunk-PONP5J5E.cjs.map +0 -1
  254. package/dist/chunk-SWVGHAYO.js.map +0 -1
  255. package/dist/chunk-VB2ARGQ6.js.map +0 -1
  256. package/dist/chunk-VYQ25YQF.js +0 -17
  257. package/dist/chunk-VYQ25YQF.js.map +0 -1
  258. package/dist/chunk-W4M7TNXG.cjs.map +0 -1
  259. package/dist/chunk-WGKAOUEQ.cjs.map +0 -1
  260. package/dist/chunk-XROE3CAS.cjs.map +0 -1
  261. package/dist/chunk-YHVEZVAO.js.map +0 -1
@@ -0,0 +1,128 @@
1
+ import { describe, it, expect } from "vitest"
2
+ import { assembleVideoOverlayRequest, expandVideoOverlayLayer, expandVideoOverlayPresets, type VideoOverlayLayerInput } from "../video-overlay.js"
3
+ import { formatVideoOverlayError, hasDrawableVideoOverlayBox, validateVideoOverlayRequest, type VideoOverlayIssue } from "../video-overlay-validate.js"
4
+
5
+ const IMG = "https://cdn.example/a.png"
6
+
7
+ describe("hasDrawableVideoOverlayBox", () => {
8
+ it("a complete (expanded) layer is drawable", () => {
9
+ expect(hasDrawableVideoOverlayBox(expandVideoOverlayLayer({ imageUrl: IMG, start: 0 }))).toBe(true)
10
+ expect(hasDrawableVideoOverlayBox(expandVideoOverlayLayer({ imageUrl: IMG, start: 0, preset: "card" }))).toBe(true)
11
+ })
12
+
13
+ it("a stored partial box is not — the expansion leaves it as written, the geometry would throw", () => {
14
+ const noAnchor = { imageUrl: IMG, start: 0, width: 40 }
15
+ const nullAnchor = { imageUrl: IMG, start: 0, anchor: null, width: 30 }
16
+ expect(expandVideoOverlayLayer(noAnchor)).toBe(noAnchor)
17
+ expect(hasDrawableVideoOverlayBox(noAnchor)).toBe(false)
18
+ expect(hasDrawableVideoOverlayBox(nullAnchor)).toBe(false)
19
+ expect(hasDrawableVideoOverlayBox({ imageUrl: IMG, start: 0, anchor: "center" })).toBe(false)
20
+ })
21
+
22
+ it("an unknown anchor, a non-finite width or an out-of-range field is not", () => {
23
+ const ok = expandVideoOverlayLayer({ imageUrl: IMG, start: 0 })
24
+ expect(hasDrawableVideoOverlayBox({ ...ok, anchor: "middle" })).toBe(false)
25
+ expect(hasDrawableVideoOverlayBox({ ...ok, width: Number.NaN })).toBe(false)
26
+ expect(hasDrawableVideoOverlayBox({ ...ok, width: "40" })).toBe(false)
27
+ expect(hasDrawableVideoOverlayBox({ ...ok, x: 500 })).toBe(false)
28
+ expect(hasDrawableVideoOverlayBox(null)).toBe(false)
29
+ expect(hasDrawableVideoOverlayBox("layer")).toBe(false)
30
+ })
31
+
32
+ it("agrees with the validator: whatever it passes is drawable", () => {
33
+ const layers = [
34
+ expandVideoOverlayLayer({ imageUrl: IMG, start: 0, anchor: "top-left", width: 30 }),
35
+ expandVideoOverlayLayer({ imageUrl: IMG, start: 0, preset: "full-frame" }),
36
+ ]
37
+ expect(validateVideoOverlayRequest({ layers }).ok).toBe(true)
38
+ for (const l of layers) expect(hasDrawableVideoOverlayBox(l)).toBe(true)
39
+ })
40
+ })
41
+
42
+ describe("validateVideoOverlayRequest (§3.5)", () => {
43
+ const ok = { imageUrl: IMG, start: 0 }
44
+ const fail = (body: Parameters<typeof validateVideoOverlayRequest>[0]) => validateVideoOverlayRequest(body) as VideoOverlayIssue
45
+ it("returns a code, the 0-based layer, the slot when present, and params — never English", () => {
46
+ const r = fail({ layers: [ok, ok, { imageUrl: IMG, start: 5, end: 4 }] })
47
+ expect(r).toEqual({ ok: false, code: "end_before_start", layer: 2, params: { start: 5, end: 4 } })
48
+ expect(formatVideoOverlayError(r)).toBe("layers[2]: end (4 s) must be after start (5 s)")
49
+ const s = fail({ layers: [{ imageUrl: IMG, start: 5, end: 4, slot: 3 }] })
50
+ expect(formatVideoOverlayError(s)).toBe("Layer 3: end (4 s) must be after start (5 s)")
51
+ })
52
+ it("layer count 1..20", () => {
53
+ expect(fail({ layers: [] }).code).toBe("no_layers")
54
+ const many = fail({ layers: Array.from({ length: 21 }, () => ok) })
55
+ expect(many.code).toBe("too_many_layers")
56
+ expect(formatVideoOverlayError(many)).toBe("At most 20 layers (got 21)")
57
+ })
58
+ it("times finite within 0..3600", () => {
59
+ expect(fail({ layers: [{ imageUrl: IMG, start: -1 }] }).code).toBe("time_out_of_range")
60
+ expect(fail({ layers: [{ imageUrl: IMG, start: 0, end: 3601 }] }).code).toBe("time_out_of_range")
61
+ expect(fail({ layers: [{ imageUrl: IMG, start: Number.POSITIVE_INFINITY }] }).code).toBe("time_out_of_range")
62
+ })
63
+ it("a no-preset partial box is incomplete_box; no preset and no box is fine before AND after expansion (D8)", () => {
64
+ const partial = fail({ layers: [{ start: 0, width: 40 }] })
65
+ expect(partial.code).toBe("incomplete_box")
66
+ expect(formatVideoOverlayError(partial)).toBe("layers[0]: anchor and width are required without a preset")
67
+ expect(validateVideoOverlayRequest({ layers: [{ imageUrl: IMG, start: 0 }] })).toEqual({ ok: true })
68
+ expect(validateVideoOverlayRequest({ layers: expandVideoOverlayPresets([{ imageUrl: IMG, start: 0 }]) })).toEqual({ ok: true })
69
+ expect(validateVideoOverlayRequest({ layers: [{ imageUrl: IMG, start: 0, preset: "card", width: 50 }] })).toEqual({ ok: true })
70
+ })
71
+ it("a present box / look field outside VIDEO_OVERLAY_BOUNDS or its enum / type is field_out_of_bounds (spec §4.4, the DAG path's only check)", () => {
72
+ const code = (extra: Record<string, unknown>) => {
73
+ const r = validateVideoOverlayRequest({ layers: [ok, { imageUrl: IMG, start: 0, anchor: "center", width: 30, ...extra } as VideoOverlayLayerInput] })
74
+ return r.ok ? "ok" : ([r.code, r.layer, r.params.field] as const)
75
+ }
76
+ expect(code({ width: 500, height: 100, fit: "cover" })).toEqual(["field_out_of_bounds", 1, "width"])
77
+ expect(code({ width: 101 })).toEqual(["field_out_of_bounds", 1, "width"])
78
+ expect(code({ width: "50" })).toEqual(["field_out_of_bounds", 1, "width"])
79
+ expect(code({ x: -101 })).toEqual(["field_out_of_bounds", 1, "x"])
80
+ expect(code({ height: 0 })).toEqual(["field_out_of_bounds", 1, "height"])
81
+ expect(code({ y: Number.NaN })).toEqual(["field_out_of_bounds", 1, "y"])
82
+ expect(code({ opacity: 5 })).toEqual(["field_out_of_bounds", 1, "opacity"])
83
+ expect(code({ opacity: 9 })).toEqual(["field_out_of_bounds", 1, "opacity"])
84
+ expect(code({ zIndex: 2.5 })).toEqual(["field_out_of_bounds", 1, "zIndex"])
85
+ expect(code({ zIndex: -3 })).toEqual(["field_out_of_bounds", 1, "zIndex"])
86
+ expect(code({ anchor: 7 })).toEqual(["field_out_of_bounds", 1, "anchor"])
87
+ expect(code({ anchor: "middle" })).toEqual(["field_out_of_bounds", 1, "anchor"])
88
+ expect(code({ fit: "stretch" })).toEqual(["field_out_of_bounds", 1, "fit"])
89
+ expect(code({ animate: "yes" })).toEqual(["field_out_of_bounds", 1, "animate"])
90
+ // null reads as absent; the bounds themselves are inclusive
91
+ expect(code({ height: null, zIndex: null, opacity: null })).toBe("ok")
92
+ expect(code({ x: -100, y: 100, width: 100, height: 1, opacity: 0, zIndex: 100, fit: "cover", animate: false })).toBe("ok")
93
+ })
94
+ it("field_out_of_bounds carries the slot, a symbolic range, and renders one English line", () => {
95
+ const r = fail({ layers: [{ imageUrl: IMG, start: 0, anchor: "center", width: 30, zIndex: 2.5, slot: 4 }] })
96
+ expect(r).toEqual({ ok: false, code: "field_out_of_bounds", layer: 0, slot: 4, params: { field: "zIndex", allowed: "integers 0..100" } })
97
+ expect(formatVideoOverlayError(r)).toBe("Layer 4: zIndex is out of range (allowed: integers 0..100)")
98
+ expect(fail({ layers: [{ imageUrl: IMG, start: 0, anchor: "center", width: 30, fit: "stretch" } as unknown as VideoOverlayLayerInput] }).params).toEqual({ field: "fit", allowed: "contain, cover" })
99
+ })
100
+ it("the bounds verdict is the same before and after the expansion (§3.5 order-independence)", () => {
101
+ const bad = [{ imageUrl: IMG, start: 0, preset: "card" as const, width: 500 }]
102
+ expect(fail({ layers: bad }).code).toBe("field_out_of_bounds")
103
+ expect(fail({ layers: expandVideoOverlayPresets(bad) }).code).toBe("field_out_of_bounds")
104
+ const good = [{ imageUrl: IMG, start: 0, preset: "card" as const }]
105
+ expect(validateVideoOverlayRequest({ layers: good })).toEqual({ ok: true })
106
+ expect(validateVideoOverlayRequest({ layers: expandVideoOverlayPresets(good) })).toEqual({ ok: true })
107
+ const noBoxBadLook = [{ imageUrl: IMG, start: 0, opacity: 5 }]
108
+ expect(fail({ layers: noBoxBadLook }).code).toBe("field_out_of_bounds")
109
+ expect(fail({ layers: expandVideoOverlayPresets(noBoxBadLook) }).code).toBe("field_out_of_bounds")
110
+ })
111
+ it("an assembled JSON-written layer with an unbounded box is refused before it reaches the geometry (the DAG path)", () => {
112
+ const req = assembleVideoOverlayRequest({
113
+ videoUrl: "v",
114
+ data: { layers: [{ anchor: "center", width: 100000, height: 100, fit: "cover", start: 0 } as VideoOverlayLayerInput] },
115
+ wiredImageUrls: [IMG],
116
+ })
117
+ expect(validateVideoOverlayRequest(req)).toMatchObject({ ok: false, code: "field_out_of_bounds", slot: 1, params: { field: "width" } })
118
+ const anchor = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [{ anchor: 7, width: 30, start: 0 } as unknown as VideoOverlayLayerInput] }, wiredImageUrls: [IMG] })
119
+ expect(validateVideoOverlayRequest(anchor)).toMatchObject({ ok: false, code: "field_out_of_bounds", params: { field: "anchor" } })
120
+ })
121
+ it("every layer needs an image", () => {
122
+ expect(fail({ layers: [{ start: 0 }] }).code).toBe("layer_without_image")
123
+ })
124
+ it("baseFit / backgroundColor only with an outputAspect", () => {
125
+ expect(fail({ layers: [ok], baseFit: "contain" }).code).toBe("fit_without_aspect")
126
+ expect(validateVideoOverlayRequest({ layers: [ok], outputAspect: "9:16", baseFit: "contain", backgroundColor: "#ff0000" })).toEqual({ ok: true })
127
+ })
128
+ })
@@ -0,0 +1,207 @@
1
+ /**
2
+ * What a source wired to a Video Overlay layer handle draws as — the ONE rule
3
+ * both engines call (`videoOverlayWiredLayerKind`), step by step:
4
+ * 1. the medium the wire is known to carry: a pip row of its own, a declared
5
+ * port medium, or the source's effective type for that handle;
6
+ * 2. the producer sets, for a single-medium producer only;
7
+ * 3. the URL path's extension;
8
+ * 4. an image.
9
+ */
10
+ import { describe, it, expect } from "vitest"
11
+ import { declaredOutputMediaType, listColumnMediaType, videoOverlayWireMediumBeforeRun as beforeRun, videoOverlayWiredLayerKind as kind } from "../video-overlay-video-layers.js"
12
+ import { DYNAMIC_PRODUCER_TYPES, IMAGE_PRODUCER_TYPES, VIDEO_PRODUCER_TYPES } from "../producer-types.js"
13
+
14
+ const NO_EXT = "https://cdn.example/signed/abc?token=1"
15
+ const MP4 = "https://cdn.example/a.mp4"
16
+ const PNG = "https://cdn.example/a.png"
17
+
18
+ describe("videoOverlayWiredLayerKind — 1. the medium the wire is known to carry", () => {
19
+ it("3D Render Pro: its stills pip is an image, its video pip a video — whatever the URL says", () => {
20
+ expect(kind({ type: "pro-3d-render", handle: "stills" }, MP4)).toBe("image")
21
+ expect(kind({ type: "pro-3d-render", handle: "stills" }, NO_EXT)).toBe("image")
22
+ expect(kind({ type: "pro-3d-render", handle: "video" }, NO_EXT)).toBe("video")
23
+ expect(kind({ type: "pro-3d-render", handle: "video" }, PNG)).toBe("video")
24
+ })
25
+
26
+ it("a dynamic producer's video pip is a video, whatever its file is named; its other pips follow the file", () => {
27
+ const videoPips = [
28
+ ["adjust-volume", "video-out"], ["pitch-tempo", "video-out"], ["voice-changer", "video"],
29
+ ["voice-changer-pro", "video"], ["dubbing", "video"], ["split-media", "video"],
30
+ ] as const
31
+ for (const [type, handle] of videoPips) {
32
+ expect(DYNAMIC_PRODUCER_TYPES.has(type)).toBe(true)
33
+ expect(kind({ type, handle }, NO_EXT)).toBe("video")
34
+ expect(kind({ type, handle }, MP4)).toBe("video")
35
+ }
36
+ expect(kind({ type: "adjust-volume", handle: "audio-out" }, NO_EXT)).toBe("image")
37
+ expect(kind({ type: "dubbing", handle: "audio" }, MP4)).toBe("video")
38
+ })
39
+
40
+ it("a declared port medium (a component's or sub-workflow's) decides, before the URL", () => {
41
+ expect(kind({ type: "component", handle: "out_clip", declaredMediaType: "video" }, NO_EXT)).toBe("video")
42
+ expect(kind({ type: "sub-workflow", handle: "out_p", declaredMediaType: "video" }, PNG)).toBe("video")
43
+ expect(kind({ type: "sub-workflow", handle: "out_p", declaredMediaType: "image" }, MP4)).toBe("image")
44
+ })
45
+
46
+ it("a declared medium that is neither (audio, text, any) decides nothing", () => {
47
+ expect(kind({ type: "sub-workflow", handle: "out_p", declaredMediaType: "any" }, MP4)).toBe("video")
48
+ expect(kind({ type: "sub-workflow", handle: "out_p", declaredMediaType: "audio" }, NO_EXT)).toBe("image")
49
+ })
50
+
51
+ it("an aggregate lane carries its lane's medium", () => {
52
+ expect(kind({ type: "collect", handle: "out-video" }, NO_EXT)).toBe("video")
53
+ expect(kind({ type: "group", handle: "out-video" }, NO_EXT)).toBe("video")
54
+ expect(kind({ type: "collect", handle: "out-image" }, MP4)).toBe("image")
55
+ })
56
+
57
+ it("a scraper's typed pips, an entity's image pip and an image output pip carry their medium", () => {
58
+ expect(kind({ type: "meta-ads-scrape", handle: "video" }, NO_EXT)).toBe("video")
59
+ expect(kind({ type: "instagram-scrape", handle: "image" }, MP4)).toBe("image")
60
+ expect(kind({ type: "character", handle: "image" }, MP4)).toBe("image")
61
+ expect(kind({ type: "ugc-creator", handle: "image" }, MP4)).toBe("image")
62
+ })
63
+ })
64
+
65
+ describe("videoOverlayWiredLayerKind — 2. a single-medium producer", () => {
66
+ it("a video producer is a video, an image producer an image", () => {
67
+ expect(kind({ type: "generate-video" }, NO_EXT)).toBe("video")
68
+ expect(kind({ type: "upload-video", handle: "video" }, PNG)).toBe("video")
69
+ expect(kind({ type: "generate-image" }, MP4)).toBe("image")
70
+ })
71
+
72
+ it("a producer in both sets decides nothing on a pip with no row of its own: the URL does", () => {
73
+ const both = [...VIDEO_PRODUCER_TYPES].filter((t) => IMAGE_PRODUCER_TYPES.has(t))
74
+ expect(both).toContain("pro-3d-render")
75
+ for (const type of both) {
76
+ expect(kind({ type, handle: "composition" }, MP4)).toBe("video")
77
+ expect(kind({ type }, PNG)).toBe("image")
78
+ }
79
+ })
80
+
81
+ it("a dynamic producer decides nothing: the URL does", () => {
82
+ for (const type of DYNAMIC_PRODUCER_TYPES) {
83
+ expect(kind({ type }, MP4)).toBe("video")
84
+ expect(kind({ type }, NO_EXT)).toBe("image")
85
+ }
86
+ })
87
+ })
88
+
89
+ describe("videoOverlayWiredLayerKind — 3. the URL, then 4. an image", () => {
90
+ it("a source of no known kind reads by its path, and is an image otherwise", () => {
91
+ expect(kind({ type: "some-future-node", handle: "out" }, "https://x/a.webm?sig=1")).toBe("video")
92
+ expect(kind({ type: "some-future-node" }, NO_EXT)).toBe("image")
93
+ expect(kind({}, NO_EXT)).toBe("image")
94
+ expect(kind({ type: null, handle: null, declaredMediaType: null }, MP4)).toBe("video")
95
+ })
96
+ })
97
+
98
+ describe("declaredOutputMediaType — the medium a component / sub-workflow port declares", () => {
99
+ it("a sub-workflow's output port, by `out_<port>`", () => {
100
+ const data = { routeSnapshot: { outputPorts: [{ id: "p1", mediaType: "video" }, { id: "p2", mediaType: "image" }] } }
101
+ expect(declaredOutputMediaType("sub-workflow", data, "out_p1")).toBe("video")
102
+ expect(declaredOutputMediaType("sub-workflow", data, "out_p2")).toBe("image")
103
+ expect(declaredOutputMediaType("sub-workflow", data, "out_p3")).toBeUndefined()
104
+ })
105
+
106
+ it("a component's output, from its route snapshot, else its metadata", () => {
107
+ const meta = { componentMetadata: { outputs: [{ id: "clip", type: "video" }] } }
108
+ expect(declaredOutputMediaType("component", meta, "out_clip")).toBe("video")
109
+ expect(declaredOutputMediaType("component", { ...meta, routeSnapshot: { outputPorts: [{ id: "clip", mediaType: "image" }] } }, "out_clip")).toBe("image")
110
+ })
111
+
112
+ it("a sub-workflow input port, by its own id", () => {
113
+ expect(declaredOutputMediaType("sub-workflow-input", { ports: [{ id: "in1", mediaType: "video" }] }, "in1")).toBe("video")
114
+ })
115
+
116
+ it("a List's column type is not a port declaration", () => {
117
+ expect(declaredOutputMediaType("list", { columns: [{ handleId: "c", type: "video-url" }] }, "c")).toBeUndefined()
118
+ })
119
+
120
+ it("anything else, or malformed data, declares nothing", () => {
121
+ expect(declaredOutputMediaType("generate-video", { routeSnapshot: { outputPorts: [{ id: "p", mediaType: "video" }] } }, "out_p")).toBeUndefined()
122
+ expect(declaredOutputMediaType("sub-workflow", { routeSnapshot: { outputPorts: [{ id: "p", mediaType: "video" }] } }, null)).toBeUndefined()
123
+ expect(declaredOutputMediaType("sub-workflow", { routeSnapshot: { outputPorts: "p" } }, "out_p")).toBeUndefined()
124
+ expect(declaredOutputMediaType("sub-workflow", { routeSnapshot: { outputPorts: [null, 7, { id: "p", mediaType: 3 }] } }, "out_p")).toBeUndefined()
125
+ expect(declaredOutputMediaType("component", null, "out_p")).toBeUndefined()
126
+ expect(declaredOutputMediaType(undefined, {}, "out_p")).toBeUndefined()
127
+ })
128
+ })
129
+
130
+ describe("listColumnMediaType — what a List column's type declares", () => {
131
+ it("the column the pip names, else the first (the one a List's own `list` pip carries)", () => {
132
+ const data = { columns: [{ id: "a", handleId: "col_a", type: "image-url" }, { id: "b", handleId: "col_b", type: "video-url" }, { id: "c", handleId: "col_c", type: "text" }] }
133
+ expect(listColumnMediaType("list", data, "col_a")).toBe("image")
134
+ expect(listColumnMediaType("list", data, "col_b")).toBe("video")
135
+ expect(listColumnMediaType("list", data, "list")).toBe("image")
136
+ expect(listColumnMediaType("list", data, "col_c")).toBeUndefined()
137
+ expect(listColumnMediaType("list", { columns: [{ handleId: "x", type: "audio-url" }] }, "x")).toBe("audio")
138
+ })
139
+ it("nothing for another source, legacy items, or malformed data", () => {
140
+ expect(listColumnMediaType("sub-workflow", { columns: [{ handleId: "x", type: "video-url" }] }, "x")).toBeUndefined()
141
+ expect(listColumnMediaType("list", { items: "https://x/a.mp4" }, "list")).toBeUndefined()
142
+ expect(listColumnMediaType("list", { columns: "image-url" }, "list")).toBeUndefined()
143
+ expect(listColumnMediaType("list", null, "list")).toBeUndefined()
144
+ })
145
+ })
146
+
147
+ describe("videoOverlayWiredLayerKind — a List column's type ranks below the URL's extension", () => {
148
+ const videoColumn = { type: "list", handle: "list", columnMediaType: "video" }
149
+ const imageColumn = { type: "list", handle: "list", columnMediaType: "image" }
150
+ it("a recognisable extension wins: a .png in a video-url column is an image, an .mp4 in an image-url column a video", () => {
151
+ expect(kind(videoColumn, PNG)).toBe("image")
152
+ expect(kind(videoColumn, "https://x/a.JPG?sig=1")).toBe("image")
153
+ expect(kind(imageColumn, MP4)).toBe("video")
154
+ })
155
+ it("the column type fills the gap for a link with no recognisable extension", () => {
156
+ expect(kind(videoColumn, NO_EXT)).toBe("video")
157
+ expect(kind(imageColumn, NO_EXT)).toBe("image")
158
+ expect(kind({ type: "list", handle: "list", columnMediaType: "audio" }, NO_EXT)).toBe("image")
159
+ })
160
+ it("a producer, a pip row or a declared port still decides before the file", () => {
161
+ expect(kind({ type: "upload-image", columnMediaType: "video" }, NO_EXT)).toBe("image")
162
+ expect(kind({ type: "sub-workflow", handle: "out_p", declaredMediaType: "image", columnMediaType: "video" }, MP4)).toBe("image")
163
+ })
164
+ })
165
+
166
+ describe("videoOverlayWireMediumBeforeRun — what a wire hands a Video Overlay, as far as it is known before the run", () => {
167
+ it("a layer wire whose source decides by itself: the producer, a pip row, a declared port", () => {
168
+ expect(beforeRun({ type: "upload-video" })).toBe("video")
169
+ expect(beforeRun({ type: "upload-image" })).toBe("image")
170
+ expect(beforeRun({ type: "pro-3d-render", handle: "stills" })).toBe("image")
171
+ expect(beforeRun({ type: "sub-workflow", handle: "out_p", declaredMediaType: "video" })).toBe("video")
172
+ })
173
+
174
+ it("a layer wire whose kind follows its file: the known files decide (extension, then column type), else it is not known", () => {
175
+ expect(beforeRun({ type: "list", handle: "list" })).toBe("unknown")
176
+ // A declared column type alone does not decide: an extension in a cell outranks it.
177
+ expect(beforeRun({ type: "list", handle: "list", columnMediaType: "image" })).toBe("unknown")
178
+ expect(beforeRun({ type: "list", handle: "list" }, { knownUrls: [PNG, "https://x/b.jpg"] })).toBe("image")
179
+ expect(beforeRun({ type: "list", handle: "list" }, { knownUrls: [PNG, MP4] })).toBe("video")
180
+ expect(beforeRun({ type: "list", handle: "list", columnMediaType: "video" }, { knownUrls: [PNG] })).toBe("image")
181
+ expect(beforeRun({ type: "list", handle: "list", columnMediaType: "video" }, { knownUrls: [NO_EXT] })).toBe("video")
182
+ expect(beforeRun({ type: "text", handle: "text" })).toBe("unknown")
183
+ expect(beforeRun({ type: "sub-workflow", handle: "out_p" })).toBe("unknown")
184
+ })
185
+
186
+ it("never disagrees with the run's rule once the file is known", () => {
187
+ const sources = [
188
+ { type: "list" }, { type: "list", columnMediaType: "video" }, { type: "list", columnMediaType: "image" },
189
+ { type: "upload-image" }, { type: "upload-video" }, { type: "pro-3d-render", handle: "video" },
190
+ ]
191
+ for (const source of sources) {
192
+ for (const url of [PNG, MP4, NO_EXT]) expect(beforeRun(source, { knownUrls: [url] })).toBe(kind(source, url))
193
+ }
194
+ })
195
+
196
+ it("on the plan handle only a plan pip row answers image: UGC Cards' plan is its card images", () => {
197
+ expect(beforeRun({ type: "ugc-cards", handle: "layerPlan" }, { target: "plan" })).toBe("image")
198
+ expect(beforeRun({ type: "ugc-cards", handle: "captionPlan" }, { target: "plan" })).toBe("unknown")
199
+ // A declared image port, an image producer, an image List column, a layer pip row: what a FILE is, not a plan's layers.
200
+ expect(beforeRun({ type: "sub-workflow", handle: "out_p", declaredMediaType: "image" }, { target: "plan" })).toBe("unknown")
201
+ expect(beforeRun({ type: "upload-image" }, { target: "plan" })).toBe("unknown")
202
+ expect(beforeRun({ type: "list", handle: "list", columnMediaType: "image" }, { target: "plan", knownUrls: [PNG] })).toBe("unknown")
203
+ expect(beforeRun({ type: "pro-3d-render", handle: "stills" }, { target: "plan" })).toBe("unknown")
204
+ expect(beforeRun({ type: "text", handle: "text" }, { target: "plan" })).toBe("unknown")
205
+ expect(beforeRun({ type: "upload-video" }, { target: "plan" })).toBe("video")
206
+ })
207
+ })