@nodaro/shared 3.70.0 → 3.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-M7LU4NTI.cjs → chunk-26GM45QE.cjs} +18 -2
- package/dist/chunk-26GM45QE.cjs.map +1 -0
- package/dist/{chunk-PWIKUOLB.cjs → chunk-32QY5AIY.cjs} +8 -8
- package/dist/{chunk-PWIKUOLB.cjs.map → chunk-32QY5AIY.cjs.map} +1 -1
- package/dist/{chunk-4U7QAUV3.cjs → chunk-4BCODXK6.cjs} +61 -61
- package/dist/{chunk-4U7QAUV3.cjs.map → chunk-4BCODXK6.cjs.map} +1 -1
- package/dist/{chunk-DOY47F7S.cjs → chunk-5WXVPPRH.cjs} +7 -7
- package/dist/{chunk-DOY47F7S.cjs.map → chunk-5WXVPPRH.cjs.map} +1 -1
- package/dist/{chunk-NS34PZ2S.js → chunk-7DMK7B3Q.js} +3 -3
- package/dist/{chunk-NS34PZ2S.js.map → chunk-7DMK7B3Q.js.map} +1 -1
- package/dist/{chunk-5DRSENY3.cjs → chunk-AIPOZKQV.cjs} +14 -12
- package/dist/{chunk-PKWRAMVB.js.map → chunk-AIPOZKQV.cjs.map} +1 -1
- package/dist/{chunk-HWBLZSM3.cjs → chunk-AXDTMRWR.cjs} +51 -28
- package/dist/chunk-AXDTMRWR.cjs.map +1 -0
- package/dist/{chunk-OW5AXH2Y.js → chunk-CL7ECTK2.js} +5 -4
- package/dist/chunk-CL7ECTK2.js.map +1 -0
- package/dist/{chunk-KKFFQUMM.js → chunk-D5NRBVUH.js} +5 -5
- package/dist/chunk-D5NRBVUH.js.map +1 -0
- package/dist/{chunk-52JNQG4K.js → chunk-D7DCDIMU.js} +3 -3
- package/dist/{chunk-52JNQG4K.js.map → chunk-D7DCDIMU.js.map} +1 -1
- package/dist/{chunk-HW6TLOK4.cjs → chunk-DRPHRE4J.cjs} +2 -2
- package/dist/{chunk-HW6TLOK4.cjs.map → chunk-DRPHRE4J.cjs.map} +1 -1
- package/dist/{chunk-PKWRAMVB.js → chunk-EI4V43DI.js} +7 -5
- package/dist/chunk-EI4V43DI.js.map +1 -0
- package/dist/{chunk-EWNDK4FV.js → chunk-EOYQD6DU.js} +3 -3
- package/dist/{chunk-EWNDK4FV.js.map → chunk-EOYQD6DU.js.map} +1 -1
- package/dist/{chunk-HA2PVTER.js → chunk-GCOS7CFL.js} +4 -4
- package/dist/{chunk-HA2PVTER.js.map → chunk-GCOS7CFL.js.map} +1 -1
- package/dist/{chunk-XBHDXURR.cjs → chunk-HJGL2UNQ.cjs} +78 -78
- package/dist/chunk-HJGL2UNQ.cjs.map +1 -0
- package/dist/{chunk-HBRDKHIW.cjs → chunk-HOQ4TLDW.cjs} +21 -21
- package/dist/{chunk-HBRDKHIW.cjs.map → chunk-HOQ4TLDW.cjs.map} +1 -1
- package/dist/{chunk-POZBRZUM.cjs → chunk-I2GFLOLD.cjs} +41 -41
- package/dist/{chunk-POZBRZUM.cjs.map → chunk-I2GFLOLD.cjs.map} +1 -1
- package/dist/{chunk-LTBM2KMY.js → chunk-INJP7EFI.js} +235 -9
- package/dist/chunk-INJP7EFI.js.map +1 -0
- package/dist/{chunk-BLGZW3UF.cjs → chunk-JUCWBIEE.cjs} +291 -20
- package/dist/chunk-JUCWBIEE.cjs.map +1 -0
- package/dist/{chunk-JEUZNHLL.cjs → chunk-L2WHTUBA.cjs} +40 -34
- package/dist/chunk-L2WHTUBA.cjs.map +1 -0
- package/dist/{chunk-V6TC2NDG.js → chunk-LMBHF5TZ.js} +4 -4
- package/dist/{chunk-V6TC2NDG.js.map → chunk-LMBHF5TZ.js.map} +1 -1
- package/dist/{chunk-QCVQVKCI.js → chunk-LP5KZZAF.js} +3 -3
- package/dist/{chunk-QCVQVKCI.js.map → chunk-LP5KZZAF.js.map} +1 -1
- package/dist/{chunk-42ICEVUN.js → chunk-M4MXK7RJ.js} +3 -3
- package/dist/{chunk-42ICEVUN.js.map → chunk-M4MXK7RJ.js.map} +1 -1
- package/dist/{chunk-BIQ7COJP.js → chunk-MR4KSZY3.js} +5 -5
- package/dist/{chunk-BIQ7COJP.js.map → chunk-MR4KSZY3.js.map} +1 -1
- package/dist/{chunk-OZHE77T3.cjs → chunk-NEBO32KZ.cjs} +9 -9
- package/dist/{chunk-OZHE77T3.cjs.map → chunk-NEBO32KZ.cjs.map} +1 -1
- package/dist/{chunk-MZ772ZXA.cjs → chunk-NSKH5ULV.cjs} +17 -17
- package/dist/{chunk-MZ772ZXA.cjs.map → chunk-NSKH5ULV.cjs.map} +1 -1
- package/dist/{chunk-QV32JI4L.cjs → chunk-OALWH5VV.cjs} +4 -4
- package/dist/{chunk-QV32JI4L.cjs.map → chunk-OALWH5VV.cjs.map} +1 -1
- package/dist/{chunk-IKN54UGB.js → chunk-OWNGS4DF.js} +3 -3
- package/dist/{chunk-IKN54UGB.js.map → chunk-OWNGS4DF.js.map} +1 -1
- package/dist/{chunk-FWPGRC4X.cjs → chunk-QFW25UCC.cjs} +5 -5
- package/dist/{chunk-FWPGRC4X.cjs.map → chunk-QFW25UCC.cjs.map} +1 -1
- package/dist/{chunk-FMQ43SJP.cjs → chunk-QVRAPR4D.cjs} +6 -6
- package/dist/{chunk-FMQ43SJP.cjs.map → chunk-QVRAPR4D.cjs.map} +1 -1
- package/dist/{chunk-PYYYBINP.cjs → chunk-RMDTBXYT.cjs} +6 -6
- package/dist/{chunk-PYYYBINP.cjs.map → chunk-RMDTBXYT.cjs.map} +1 -1
- package/dist/{chunk-O53P2D4V.js → chunk-SXDLBXSB.js} +9 -5
- package/dist/chunk-SXDLBXSB.js.map +1 -0
- package/dist/{chunk-YLDY23N2.js → chunk-U7PHAD2O.js} +5 -5
- package/dist/{chunk-YLDY23N2.js.map → chunk-U7PHAD2O.js.map} +1 -1
- package/dist/{chunk-TADEEG5E.js → chunk-UC3CMPDN.js} +18 -3
- package/dist/chunk-UC3CMPDN.js.map +1 -0
- package/dist/{chunk-QCZYYAPZ.cjs → chunk-UMUSJHH2.cjs} +48 -48
- package/dist/{chunk-QCZYYAPZ.cjs.map → chunk-UMUSJHH2.cjs.map} +1 -1
- package/dist/{chunk-H2E4QXEZ.js → chunk-VVLW63HD.js} +3 -3
- package/dist/{chunk-H2E4QXEZ.js.map → chunk-VVLW63HD.js.map} +1 -1
- package/dist/{chunk-HP3YIWNJ.js → chunk-WARGPM7P.js} +2 -2
- package/dist/{chunk-HP3YIWNJ.js.map → chunk-WARGPM7P.js.map} +1 -1
- package/dist/{chunk-QVAUBB2T.js → chunk-WXJMPWYR.js} +9 -9
- package/dist/{chunk-QVAUBB2T.js.map → chunk-WXJMPWYR.js.map} +1 -1
- package/dist/{chunk-R22UHRR6.js → chunk-X7UDZGXW.js} +51 -28
- package/dist/chunk-X7UDZGXW.js.map +1 -0
- package/dist/{chunk-2VOXSVIE.js → chunk-XEMEUKXK.js} +3 -3
- package/dist/{chunk-2VOXSVIE.js.map → chunk-XEMEUKXK.js.map} +1 -1
- package/dist/{chunk-GC77W57T.cjs → chunk-YHDTBO45.cjs} +9 -9
- package/dist/{chunk-GC77W57T.cjs.map → chunk-YHDTBO45.cjs.map} +1 -1
- package/dist/{chunk-WHV7MDNC.cjs → chunk-ZJQ2L3MI.cjs} +5 -3
- package/dist/chunk-ZJQ2L3MI.cjs.map +1 -0
- package/dist/entries/apps.cjs +42 -42
- package/dist/entries/apps.js +7 -7
- package/dist/entries/credits.cjs +418 -238
- package/dist/entries/credits.d.cts +263 -2
- package/dist/entries/credits.d.ts +263 -2
- package/dist/entries/credits.js +9 -9
- package/dist/entries/edl.cjs +60 -60
- package/dist/entries/edl.d.cts +96 -1
- package/dist/entries/edl.d.ts +96 -1
- package/dist/entries/edl.js +1 -1
- package/dist/entries/i18n.cjs +15 -11
- package/dist/entries/i18n.d.cts +19 -1
- package/dist/entries/i18n.d.ts +19 -1
- package/dist/entries/i18n.js +1 -1
- package/dist/entries/llm-models.d.cts +1 -1
- package/dist/entries/llm-models.d.ts +1 -1
- package/dist/entries/model-catalog.cjs +133 -133
- package/dist/entries/model-catalog.js +4 -4
- package/dist/entries/models.cjs +412 -404
- package/dist/entries/models.d.cts +2 -2
- package/dist/entries/models.d.ts +2 -2
- package/dist/entries/models.js +5 -5
- package/dist/entries/nodes.cjs +212 -212
- package/dist/entries/nodes.js +8 -8
- package/dist/entries/pipeline.cjs +153 -153
- package/dist/entries/pipeline.d.cts +1 -1
- package/dist/entries/pipeline.d.ts +1 -1
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/social.cjs +195 -191
- package/dist/entries/social.d.cts +9 -3
- package/dist/entries/social.d.ts +9 -3
- package/dist/entries/social.js +1 -1
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +152 -152
- package/dist/entries/video.js +6 -6
- package/dist/index.cjs +1835 -1639
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +21 -21
- package/dist/{model-constants-CQr_d3Kw.d.cts → model-constants-C4RL9Xtn.d.cts} +20 -4
- package/dist/{model-constants-B5DNHIP8.d.ts → model-constants-kRg3YCIJ.d.ts} +20 -4
- package/dist/style.ar-4WUT56YH.js +63 -0
- package/dist/style.ar-4WUT56YH.js.map +1 -0
- package/dist/style.ar-ZRS6ZSSS.cjs +65 -0
- package/dist/style.ar-ZRS6ZSSS.cjs.map +1 -0
- package/dist/style.de-6543OVTB.cjs +65 -0
- package/dist/style.de-6543OVTB.cjs.map +1 -0
- package/dist/style.de-HQS4NOVN.js +63 -0
- package/dist/style.de-HQS4NOVN.js.map +1 -0
- package/dist/style.es-ADFPO6LM.cjs +65 -0
- package/dist/style.es-ADFPO6LM.cjs.map +1 -0
- package/dist/style.es-O4N36TIJ.js +63 -0
- package/dist/style.es-O4N36TIJ.js.map +1 -0
- package/dist/style.fr-A3ZO6BP3.cjs +65 -0
- package/dist/style.fr-A3ZO6BP3.cjs.map +1 -0
- package/dist/style.fr-XKYO3NOK.js +63 -0
- package/dist/style.fr-XKYO3NOK.js.map +1 -0
- package/dist/style.he-DI4PXGJG.cjs +65 -0
- package/dist/style.he-DI4PXGJG.cjs.map +1 -0
- package/dist/style.he-L4SD3G7D.js +63 -0
- package/dist/style.he-L4SD3G7D.js.map +1 -0
- package/dist/style.hi-K625E6UR.js +63 -0
- package/dist/style.hi-K625E6UR.js.map +1 -0
- package/dist/style.hi-LMDM6S3Q.cjs +65 -0
- package/dist/style.hi-LMDM6S3Q.cjs.map +1 -0
- package/dist/style.ja-3YGEMQKQ.js +63 -0
- package/dist/style.ja-3YGEMQKQ.js.map +1 -0
- package/dist/style.ja-QV4Z4B3Y.cjs +65 -0
- package/dist/style.ja-QV4Z4B3Y.cjs.map +1 -0
- package/dist/style.ko-KIKAE2WS.js +63 -0
- package/dist/style.ko-KIKAE2WS.js.map +1 -0
- package/dist/style.ko-WXYT3ZAL.cjs +65 -0
- package/dist/style.ko-WXYT3ZAL.cjs.map +1 -0
- package/dist/style.pt-BR-R6WOR67L.js +64 -0
- package/dist/style.pt-BR-R6WOR67L.js.map +1 -0
- package/dist/style.pt-BR-WWGO7RUX.cjs +66 -0
- package/dist/style.pt-BR-WWGO7RUX.cjs.map +1 -0
- package/dist/style.ru-UVLIITMR.js +63 -0
- package/dist/style.ru-UVLIITMR.js.map +1 -0
- package/dist/style.ru-ZCB4IUCW.cjs +65 -0
- package/dist/style.ru-ZCB4IUCW.cjs.map +1 -0
- package/dist/style.zh-CN-IFAAZ475.cjs +65 -0
- package/dist/style.zh-CN-IFAAZ475.cjs.map +1 -0
- package/dist/style.zh-CN-RQEZCV44.js +63 -0
- package/dist/style.zh-CN-RQEZCV44.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/audio-isolation-pricing.test.ts +49 -0
- package/src/__tests__/competitors.test.ts +6 -1
- package/src/__tests__/credit-identifiers.test.ts +9 -10
- package/src/__tests__/motion-transfer-pricing.test.ts +252 -0
- package/src/__tests__/normalize-node-params.test.ts +9 -2
- package/src/__tests__/style-sidecar-loaders.test.ts +29 -0
- package/src/__tests__/video-catalog-totality.test.ts +37 -5
- package/src/__tests__/video-to-video-pricing.test.ts +151 -0
- package/src/audio-isolation-pricing.ts +80 -0
- package/src/competitors.ts +8 -2
- package/src/credit-identifiers.ts +6 -0
- package/src/entries/credits.ts +54 -0
- package/src/entries/edl.ts +2 -0
- package/src/entries/i18n.ts +1 -0
- package/src/entries/models.ts +2 -0
- package/src/entries/social.ts +1 -0
- package/src/i18n/style-sidecar-loaders.ts +30 -0
- package/src/model-catalog.ts +49 -23
- package/src/model-constants.ts +24 -4
- package/src/motion-transfer-pricing.ts +239 -0
- package/src/producer-types.ts +2 -0
- package/src/use-case-output.ts +102 -0
- package/src/video-to-video-pricing.ts +248 -0
- package/dist/chunk-5DRSENY3.cjs.map +0 -1
- package/dist/chunk-BLGZW3UF.cjs.map +0 -1
- package/dist/chunk-HWBLZSM3.cjs.map +0 -1
- package/dist/chunk-JEUZNHLL.cjs.map +0 -1
- package/dist/chunk-KKFFQUMM.js.map +0 -1
- package/dist/chunk-LTBM2KMY.js.map +0 -1
- package/dist/chunk-M7LU4NTI.cjs.map +0 -1
- package/dist/chunk-O53P2D4V.js.map +0 -1
- package/dist/chunk-OW5AXH2Y.js.map +0 -1
- package/dist/chunk-R22UHRR6.js.map +0 -1
- package/dist/chunk-TADEEG5E.js.map +0 -1
- package/dist/chunk-WHV7MDNC.cjs.map +0 -1
- package/dist/chunk-XBHDXURR.cjs.map +0 -1
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
checkMotionTransferLength,
|
|
4
|
+
motionTransferBilledSeconds,
|
|
5
|
+
motionTransferEstimatePrice,
|
|
6
|
+
motionTransferEstimateSeconds,
|
|
7
|
+
motionTransferMaxSec,
|
|
8
|
+
motionTransferPrice,
|
|
9
|
+
motionTransferRateOf,
|
|
10
|
+
motionTransferBaseCharge,
|
|
11
|
+
motionTransferChargedPrice,
|
|
12
|
+
MOTION_TRANSFER_FLOOR_IDS,
|
|
13
|
+
MOTION_TRANSFER_RATE_IDS,
|
|
14
|
+
MOTION_TRANSFER_SECOND_RATES,
|
|
15
|
+
} from "../motion-transfer-pricing.js"
|
|
16
|
+
import { motionTransferResolution } from "../credit-identifiers.js"
|
|
17
|
+
|
|
18
|
+
/** The rows as they are seeded (migrations 668 and 670, and the flat Wan Animate rows they never change). */
|
|
19
|
+
const ROWS: Record<string, number> = {
|
|
20
|
+
"motion-transfer:720p:per-4s": 126,
|
|
21
|
+
"motion-transfer:1080p:per-4s": 203,
|
|
22
|
+
"kling-3.0-motion:720p:per-4s": 228,
|
|
23
|
+
"kling-3.0-motion:1080p:per-4s": 302,
|
|
24
|
+
"wan-animate-replace:480p:per-4s": 60,
|
|
25
|
+
"wan-animate-replace:580p:per-4s": 95,
|
|
26
|
+
"wan-animate-replace:720p:per-4s": 125,
|
|
27
|
+
"wan-animate-move:720p:per-4s": 125,
|
|
28
|
+
"wan-animate-move": 255,
|
|
29
|
+
"wan-animate-move:580p": 330,
|
|
30
|
+
"wan-animate-move:720p": 410,
|
|
31
|
+
"wan-animate-replace": 255,
|
|
32
|
+
"wan-animate-replace:580p": 330,
|
|
33
|
+
"wan-animate-replace:720p": 410,
|
|
34
|
+
}
|
|
35
|
+
/** The base credits and the row a run of `seconds` billed seconds is charged at the seeded rows. */
|
|
36
|
+
const charge = (provider: string, resolution: string, seconds: number) => motionTransferBaseCharge(motionTransferPrice(provider, resolution, seconds), (id) => ROWS[id])
|
|
37
|
+
|
|
38
|
+
describe("Motion Transfer pricing from the driving video's length", () => {
|
|
39
|
+
describe("billed seconds", () => {
|
|
40
|
+
it("rounds the measured length up to a whole second", () => {
|
|
41
|
+
expect(motionTransferBilledSeconds(3)).toBe(3)
|
|
42
|
+
expect(motionTransferBilledSeconds(3.2)).toBe(4)
|
|
43
|
+
expect(motionTransferBilledSeconds(9.5)).toBe(10)
|
|
44
|
+
})
|
|
45
|
+
it("forgives up to 0.05 s past a whole second", () => {
|
|
46
|
+
expect(motionTransferBilledSeconds(10.05)).toBe(10)
|
|
47
|
+
expect(motionTransferBilledSeconds(10.04)).toBe(10)
|
|
48
|
+
expect(motionTransferBilledSeconds(10.06)).toBe(11)
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe("limits", () => {
|
|
53
|
+
it("Kling 2.6 and Kling 3.0 take 10 s keeping the image's orientation (the default), 30 s following the video's", () => {
|
|
54
|
+
for (const provider of ["kling", "kling-3.0"]) {
|
|
55
|
+
expect(motionTransferMaxSec(provider, undefined)).toBe(10)
|
|
56
|
+
expect(motionTransferMaxSec(provider, "image")).toBe(10)
|
|
57
|
+
expect(motionTransferMaxSec(provider, "bogus")).toBe(10)
|
|
58
|
+
expect(motionTransferMaxSec(provider, "video")).toBe(30)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
it("Wan Animate takes 30 s whatever the orientation", () => {
|
|
62
|
+
expect(motionTransferMaxSec("wan-animate-move", "image")).toBe(30)
|
|
63
|
+
expect(motionTransferMaxSec("wan-animate-replace", undefined)).toBe(30)
|
|
64
|
+
})
|
|
65
|
+
it("refuses a clip under 3 s", () => {
|
|
66
|
+
const r = checkMotionTransferLength("kling", "image", 2.9)
|
|
67
|
+
expect(r.ok).toBe(false)
|
|
68
|
+
if (!r.ok) {
|
|
69
|
+
expect(r.code).toBe("video_too_short")
|
|
70
|
+
expect(r.message).toContain("at least 3 seconds")
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
it("refuses a clip past the limit, naming it and asking to trim", () => {
|
|
74
|
+
const r = checkMotionTransferLength("kling-3.0", "image", 12)
|
|
75
|
+
expect(r.ok).toBe(false)
|
|
76
|
+
if (!r.ok) {
|
|
77
|
+
expect(r.code).toBe("video_too_long")
|
|
78
|
+
expect(r.message).toContain("at most 10 seconds")
|
|
79
|
+
expect(r.message).toContain("Trim the video first")
|
|
80
|
+
}
|
|
81
|
+
const v = checkMotionTransferLength("kling-3.0", "video", 31)
|
|
82
|
+
expect(v.ok).toBe(false)
|
|
83
|
+
if (!v.ok) expect(v.message).toContain("at most 30 seconds")
|
|
84
|
+
expect(checkMotionTransferLength("wan-animate-move", "image", 30.5).ok).toBe(false)
|
|
85
|
+
})
|
|
86
|
+
it("accepts a clip within 0.05 s past the limit and bills it at the limit", () => {
|
|
87
|
+
expect(checkMotionTransferLength("kling", "image", 10.05)).toEqual({ ok: true, billedSeconds: 10 })
|
|
88
|
+
expect(checkMotionTransferLength("kling", "image", 10.06).ok).toBe(false)
|
|
89
|
+
expect(checkMotionTransferLength("kling-3.0", "video", 30.04)).toEqual({ ok: true, billedSeconds: 30 })
|
|
90
|
+
})
|
|
91
|
+
it("accepts 3 s exactly", () => {
|
|
92
|
+
expect(checkMotionTransferLength("kling", "image", 3)).toEqual({ ok: true, billedSeconds: 3 })
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
describe("Kling 3.0 at 720p: a per-second rate", () => {
|
|
97
|
+
it("is charged its four-second row × billed seconds ÷ 4", () => {
|
|
98
|
+
expect(motionTransferPrice("kling-3.0", "720p", 10)).toEqual({ creditId: "kling-3.0-motion:720p:per-4s", units: 2.5 })
|
|
99
|
+
expect(motionTransferPrice("kling-3.0", "720p", 3)).toEqual({ creditId: "kling-3.0-motion:720p:per-4s", units: 0.75 })
|
|
100
|
+
})
|
|
101
|
+
it("worked examples: 10 s → 570 base credits, 3 s → 171 (the 228 row)", () => {
|
|
102
|
+
expect(charge("kling-3.0", "720p", 10)).toEqual({ creditId: "kling-3.0-motion:720p:per-4s", units: 2.5, baseCredits: 570 })
|
|
103
|
+
expect(charge("kling-3.0", "720p", 3).baseCredits).toBe(171)
|
|
104
|
+
})
|
|
105
|
+
it("any size but 1080p is charged as 720p, so it is on the rate too", () => {
|
|
106
|
+
expect(motionTransferRateOf("kling-3.0", "480p").rateId).toBe("kling-3.0-motion:720p:per-4s")
|
|
107
|
+
expect(motionTransferRateOf("kling-3.0", "580p").rateId).toBe("kling-3.0-motion:720p:per-4s")
|
|
108
|
+
expect(motionTransferRateOf("kling-3.0", undefined).rateId).toBe("kling-3.0-motion:720p:per-4s")
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
describe("every model and size is charged per second (decided 2026-11-18)", () => {
|
|
113
|
+
it("lists every rate row once and every floor row once", () => {
|
|
114
|
+
expect([...MOTION_TRANSFER_RATE_IDS].sort()).toEqual([
|
|
115
|
+
"kling-3.0-motion:1080p:per-4s",
|
|
116
|
+
"kling-3.0-motion:720p:per-4s",
|
|
117
|
+
"motion-transfer:1080p:per-4s",
|
|
118
|
+
"motion-transfer:720p:per-4s",
|
|
119
|
+
"wan-animate-move:720p:per-4s",
|
|
120
|
+
"wan-animate-replace:480p:per-4s",
|
|
121
|
+
"wan-animate-replace:580p:per-4s",
|
|
122
|
+
"wan-animate-replace:720p:per-4s",
|
|
123
|
+
])
|
|
124
|
+
expect([...MOTION_TRANSFER_FLOOR_IDS].sort()).toEqual([
|
|
125
|
+
"wan-animate-move:720p",
|
|
126
|
+
"wan-animate-replace",
|
|
127
|
+
"wan-animate-replace:580p",
|
|
128
|
+
"wan-animate-replace:720p",
|
|
129
|
+
])
|
|
130
|
+
})
|
|
131
|
+
it("every size a model runs at has a rate, and no rate is a length tier", () => {
|
|
132
|
+
for (const provider of ["kling", "kling-3.0", "wan-animate-move", "wan-animate-replace"]) {
|
|
133
|
+
for (const size of ["480p", "580p", "720p", "1080p", undefined]) {
|
|
134
|
+
const sized = motionTransferResolution(provider, size ?? "720p").resolution
|
|
135
|
+
const rate = motionTransferRateOf(provider, size)
|
|
136
|
+
expect(rate.rateId).toMatch(/:per-4s$/)
|
|
137
|
+
if (provider.startsWith("wan-")) expect(Object.prototype.hasOwnProperty.call(MOTION_TRANSFER_SECOND_RATES, `${provider}:${sized}`)).toBe(true)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
it("a model Motion Transfer does not have is priced as its default, Kling 2.6", () => {
|
|
142
|
+
expect(motionTransferRateOf("bogus", "720p").rateId).toBe("motion-transfer:720p:per-4s")
|
|
143
|
+
expect(motionTransferRateOf(undefined, "1080p").rateId).toBe("motion-transfer:1080p:per-4s")
|
|
144
|
+
})
|
|
145
|
+
it("Kling 2.6: 126 base credits per 4 s at 720p, 203 at 1080p, no floor", () => {
|
|
146
|
+
expect(charge("kling", "720p", 10)).toEqual({ creditId: "motion-transfer:720p:per-4s", units: 2.5, baseCredits: 315 })
|
|
147
|
+
expect(charge("kling", "720p", 3).baseCredits).toBe(95)
|
|
148
|
+
expect(charge("kling", "1080p", 10)).toEqual({ creditId: "motion-transfer:1080p:per-4s", units: 2.5, baseCredits: 508 })
|
|
149
|
+
expect(charge("kling", "1080p", 30).baseCredits).toBe(1523)
|
|
150
|
+
expect(charge("kling", "480p", 5).creditId).toBe("motion-transfer:720p:per-4s")
|
|
151
|
+
})
|
|
152
|
+
it("Kling 3.0 at 1080p: 302 base credits per 4 s, no floor", () => {
|
|
153
|
+
expect(charge("kling-3.0", "1080p", 10)).toEqual({ creditId: "kling-3.0-motion:1080p:per-4s", units: 2.5, baseCredits: 755 })
|
|
154
|
+
expect(charge("kling-3.0", "1080p", 3).baseCredits).toBe(227)
|
|
155
|
+
})
|
|
156
|
+
it("a 10.5 s clip is billed 11 s", () => {
|
|
157
|
+
expect(charge("kling", "720p", motionTransferBilledSeconds(10.5)).baseCredits).toBe(Math.ceil((126 * 11) / 4))
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
describe("Wan Animate: per second, never below today's flat price for the size", () => {
|
|
162
|
+
it("Replace 720p: 3 s stays at today's 410; 30 s is ceil(125 × 30 ÷ 4) = 938", () => {
|
|
163
|
+
expect(charge("wan-animate-replace", "720p", 3)).toEqual({ creditId: "wan-animate-replace:720p", baseCredits: 410 })
|
|
164
|
+
expect(charge("wan-animate-replace", "720p", 30)).toEqual({ creditId: "wan-animate-replace:720p:per-4s", units: 7.5, baseCredits: 938 })
|
|
165
|
+
})
|
|
166
|
+
// Each floored row on both sides of the length where the rate passes it.
|
|
167
|
+
it.each([
|
|
168
|
+
["wan-animate-replace", "480p", 17, "wan-animate-replace", 255, 18, 270],
|
|
169
|
+
["wan-animate-replace", "580p", 13, "wan-animate-replace:580p", 330, 14, 333],
|
|
170
|
+
["wan-animate-replace", "720p", 13, "wan-animate-replace:720p", 410, 14, 438],
|
|
171
|
+
["wan-animate-move", "720p", 13, "wan-animate-move:720p", 410, 14, 438],
|
|
172
|
+
["wan-animate-move", "480p", 13, "wan-animate-move:720p", 410, 14, 438],
|
|
173
|
+
["wan-animate-move", "580p", 13, "wan-animate-move:720p", 410, 14, 438],
|
|
174
|
+
] as const)("%s %s: %d s is the floor row, %d s past it the rate", (provider, size, onFloor, floorId, floorBase, past, pastBase) => {
|
|
175
|
+
expect(charge(provider, size, onFloor)).toEqual({ creditId: floorId, baseCredits: floorBase })
|
|
176
|
+
expect(charge(provider, size, past)).toMatchObject({ creditId: motionTransferRateOf(provider, size).rateId, units: past / 4, baseCredits: pastBase })
|
|
177
|
+
})
|
|
178
|
+
it("a tie goes to the floor row: Replace 480p at 17 s is 255 either way", () => {
|
|
179
|
+
expect(Math.ceil((60 * 17) / 4)).toBe(255)
|
|
180
|
+
expect(charge("wan-animate-replace", "480p", 17).creditId).toBe("wan-animate-replace")
|
|
181
|
+
})
|
|
182
|
+
it("Move runs at 720p only: any size it names is sent and charged as 720p, floored at the 720p row", () => {
|
|
183
|
+
for (const size of ["480p", "580p", "720p", "1080p"]) {
|
|
184
|
+
expect(motionTransferResolution("wan-animate-move", size).resolution).toBe("720p")
|
|
185
|
+
expect(motionTransferRateOf("wan-animate-move", size)).toEqual({ rateId: "wan-animate-move:720p:per-4s", rateSeconds: 4, floorId: "wan-animate-move:720p" })
|
|
186
|
+
}
|
|
187
|
+
expect(charge("wan-animate-move", "480p", 30)).toMatchObject({ creditId: "wan-animate-move:720p:per-4s", baseCredits: 938 })
|
|
188
|
+
expect(charge("wan-animate-move", "480p", 5)).toEqual({ creditId: "wan-animate-move:720p", baseCredits: 410 })
|
|
189
|
+
})
|
|
190
|
+
it("Replace keeps its three sizes", () => {
|
|
191
|
+
for (const size of ["480p", "580p", "720p"]) expect(motionTransferResolution("wan-animate-replace", size).resolution).toBe(size)
|
|
192
|
+
})
|
|
193
|
+
it("a 1080p request runs, and is charged, as 720p", () => {
|
|
194
|
+
expect(motionTransferRateOf("wan-animate-replace", "1080p")).toEqual({ rateId: "wan-animate-replace:720p:per-4s", rateSeconds: 4, floorId: "wan-animate-replace:720p" })
|
|
195
|
+
})
|
|
196
|
+
it("the floor rule reads charged figures the same way (the editor's)", () => {
|
|
197
|
+
const price = motionTransferPrice("wan-animate-replace", "720p", 10)
|
|
198
|
+
expect(motionTransferChargedPrice(price, { perSecond: 360, floor: 472 })).toEqual({ creditId: "wan-animate-replace:720p" })
|
|
199
|
+
expect(motionTransferChargedPrice(price, { perSecond: 500, floor: 472 })).toEqual({ creditId: "wan-animate-replace:720p:per-4s", units: 2.5 })
|
|
200
|
+
})
|
|
201
|
+
it("a row priced nowhere leaves the rate, whose own lookup refuses it", () => {
|
|
202
|
+
const price = motionTransferPrice("wan-animate-replace", "720p", 3)
|
|
203
|
+
expect(motionTransferChargedPrice(price, { perSecond: undefined, floor: 410 })).toEqual({ creditId: "wan-animate-replace:720p:per-4s", units: 0.75 })
|
|
204
|
+
expect(motionTransferChargedPrice(price, { perSecond: 94, floor: undefined })).toEqual({ creditId: "wan-animate-replace:720p:per-4s", units: 0.75 })
|
|
205
|
+
})
|
|
206
|
+
it("the charge never falls as the clip grows, and is never below the floor", () => {
|
|
207
|
+
for (const [provider, size] of [["wan-animate-replace", "480p"], ["wan-animate-replace", "580p"], ["wan-animate-replace", "720p"], ["wan-animate-move", "480p"], ["wan-animate-move", "720p"]] as const) {
|
|
208
|
+
const floor = ROWS[motionTransferRateOf(provider, size).floorId!]!
|
|
209
|
+
let last = 0
|
|
210
|
+
for (let sec = 3; sec <= 30; sec++) {
|
|
211
|
+
const base = charge(provider, size, sec).baseCredits!
|
|
212
|
+
expect(base).toBeGreaterThanOrEqual(Math.max(last, floor))
|
|
213
|
+
last = base
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
describe("estimates", () => {
|
|
220
|
+
it("quote the known length, billed as a run bills it, at most the limit", () => {
|
|
221
|
+
expect(motionTransferEstimateSeconds("kling-3.0", "image", 6.2)).toBe(7)
|
|
222
|
+
expect(motionTransferEstimateSeconds("kling-3.0", "image", 25)).toBe(10)
|
|
223
|
+
expect(motionTransferEstimateSeconds("kling-3.0", "video", 25)).toBe(25)
|
|
224
|
+
})
|
|
225
|
+
it("quote the orientation's limit when the length is unknown", () => {
|
|
226
|
+
expect(motionTransferEstimateSeconds("kling-3.0", undefined, undefined)).toBe(10)
|
|
227
|
+
expect(motionTransferEstimateSeconds("kling-3.0", "video", null)).toBe(30)
|
|
228
|
+
expect(motionTransferEstimatePrice("kling-3.0", "720p", "image", undefined)).toEqual({
|
|
229
|
+
creditId: "kling-3.0-motion:720p:per-4s",
|
|
230
|
+
units: 2.5,
|
|
231
|
+
lengthKnown: false,
|
|
232
|
+
})
|
|
233
|
+
expect(motionTransferEstimatePrice("kling", "720p", "video", undefined)).toEqual({ creditId: "motion-transfer:720p:per-4s", units: 7.5, lengthKnown: false })
|
|
234
|
+
expect(motionTransferEstimatePrice("wan-animate-move", "480p", "image", undefined)).toEqual({
|
|
235
|
+
creditId: "wan-animate-move:720p:per-4s",
|
|
236
|
+
units: 7.5,
|
|
237
|
+
floorId: "wan-animate-move:720p",
|
|
238
|
+
lengthKnown: false,
|
|
239
|
+
})
|
|
240
|
+
})
|
|
241
|
+
it("never quotes below a run of the same clip", () => {
|
|
242
|
+
for (let tenth = 30; tenth <= 300; tenth++) {
|
|
243
|
+
const sec = tenth / 10
|
|
244
|
+
for (const orientation of ["image", "video"]) {
|
|
245
|
+
const run = checkMotionTransferLength("kling-3.0", orientation, sec)
|
|
246
|
+
if (!run.ok) continue
|
|
247
|
+
expect(motionTransferEstimateSeconds("kling-3.0", orientation, sec)).toBeGreaterThanOrEqual(run.billedSeconds)
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
})
|
|
251
|
+
})
|
|
252
|
+
})
|
|
@@ -218,9 +218,16 @@ describe("normalizeNodeModelParams — a stored reference task type (decided 202
|
|
|
218
218
|
nodes.forEach((n, i) => expect(n).toBe(input[i]))
|
|
219
219
|
})
|
|
220
220
|
|
|
221
|
-
it("a node naming no model is judged on the model its run uses
|
|
221
|
+
it("a node naming no model is judged on the model its run uses", () => {
|
|
222
222
|
for (const type of VIDEO_TYPES) {
|
|
223
|
-
const
|
|
223
|
+
const input = [node("d", type, { referenceTaskType: "edit" })]
|
|
224
|
+
const { nodes, adjustments } = normalizeNodeModelParams(input)
|
|
225
|
+
// Video to Video's default is Seedance 2.5 edit, which lists task types: the field stays.
|
|
226
|
+
if (type === "video-to-video") {
|
|
227
|
+
expect(nodes[0], type).toBe(input[0])
|
|
228
|
+
expect(adjustments, type).toEqual([])
|
|
229
|
+
continue
|
|
230
|
+
}
|
|
224
231
|
expect(nodes[0]!.data, type).toStrictEqual({})
|
|
225
232
|
expect(adjustments.map((a) => a.field), type).toEqual(["referenceTaskType"])
|
|
226
233
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { readdirSync } from "node:fs"
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
import { fileURLToPath } from "node:url"
|
|
4
|
+
import { describe, expect, it } from "vitest"
|
|
5
|
+
import { NON_EN_LOCALE_IDS, type LocaleCatalogMap } from "../i18n/types.js"
|
|
6
|
+
import { STYLE_SIDECAR_LOADERS } from "../i18n/style-sidecar-loaders.js"
|
|
7
|
+
|
|
8
|
+
const I18N_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "i18n")
|
|
9
|
+
|
|
10
|
+
describe("STYLE_SIDECAR_LOADERS", () => {
|
|
11
|
+
it("has one loader per style sidecar file, and one per non-English language", () => {
|
|
12
|
+
const files = readdirSync(I18N_DIR).filter((f) => /^style\.[\w-]+\.ts$/.test(f))
|
|
13
|
+
expect(Object.keys(STYLE_SIDECAR_LOADERS).sort()).toEqual(files.map((f) => `./${f}`).sort())
|
|
14
|
+
expect(Object.keys(STYLE_SIDECAR_LOADERS).sort()).toEqual(NON_EN_LOCALE_IDS.map((l) => `./style.${l}.ts`).sort())
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it("each loader answers its own language's sidecar", async () => {
|
|
18
|
+
const labels: Record<string, string> = {}
|
|
19
|
+
for (const [key, load] of Object.entries(STYLE_SIDECAR_LOADERS)) {
|
|
20
|
+
const mod = (await load()) as { default: LocaleCatalogMap }
|
|
21
|
+
const label = mod.default.watercolor?.label
|
|
22
|
+
expect(typeof label, key).toBe("string")
|
|
23
|
+
labels[key] = label ?? ""
|
|
24
|
+
}
|
|
25
|
+
expect(labels["./style.he.ts"]).toBe("צבעי מים")
|
|
26
|
+
expect(labels["./style.ja.ts"]).toBe("水彩画")
|
|
27
|
+
expect(labels["./style.pt-BR.ts"]).toBe("Aquarela")
|
|
28
|
+
})
|
|
29
|
+
})
|
|
@@ -43,16 +43,48 @@ describe("MODEL_CATALOG covers every generatable video provider", () => {
|
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* Every /v1/video-to-video model is listed too, as a
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* Every /v1/video-to-video model is listed too, as a video entry: `/v1/models`
|
|
47
|
+
* and MCP `list_models` read only the catalog, so a model outside it is one no
|
|
48
|
+
* client can offer (luma-modify was, until 2026-10-19).
|
|
49
|
+
*
|
|
50
|
+
* The mode "v2v" means the model EDITS the clip it is given: it is what the
|
|
51
|
+
* surfaces that list "edit" models read. So every Video to Video provider
|
|
52
|
+
* carries it EXCEPT the reference-to-video ones named here, which take the
|
|
53
|
+
* clip's subject and make a NEW clip of the scene the prompt describes. Those
|
|
54
|
+
* stay Video to Video providers (the route takes them, the node's menu offers
|
|
55
|
+
* them) and are picked there by id; they are not listed as edit models.
|
|
56
|
+
*
|
|
57
|
+
* A new Video to Video provider must be an edit model with "v2v", or be added
|
|
58
|
+
* to this list with its reason: it cannot be neither unnoticed.
|
|
49
59
|
*/
|
|
60
|
+
const REFERENCE_TO_VIDEO_PROVIDERS: Readonly<Record<string, string>> = {
|
|
61
|
+
"wan": "Wan 2.6 video-to-video makes a new clip featuring the input video's subject; it does not edit the clip",
|
|
62
|
+
"wan-flash": "the faster tier of the same Wan 2.6 reference-to-video model",
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
describe("MODEL_CATALOG covers every video-to-video provider", () => {
|
|
51
|
-
it.each([...VIDEO_TO_VIDEO_PROVIDERS])("%s has a
|
|
66
|
+
it.each([...VIDEO_TO_VIDEO_PROVIDERS])("%s has a video entry", (p) => {
|
|
52
67
|
const entry = MODEL_CATALOG[p]
|
|
53
68
|
expect(entry, `Add a MODEL_CATALOG entry for ${p}`).toBeDefined()
|
|
54
69
|
expect(entry!.kind).toBe("video")
|
|
55
|
-
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it("every provider is an edit model (\"v2v\") except the named reference-to-video ones", () => {
|
|
73
|
+
const others = VIDEO_TO_VIDEO_PROVIDERS.filter((p) => !MODEL_CATALOG[p]!.modes.includes("v2v"))
|
|
74
|
+
expect([...others].sort()).toEqual(Object.keys(REFERENCE_TO_VIDEO_PROVIDERS).sort())
|
|
75
|
+
for (const id of ["happyhorse-edit", "luma-modify", "runway-aleph", "wan-videoedit"]) {
|
|
76
|
+
expect(MODEL_CATALOG[id]!.modes, id).toContain("v2v")
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it("a reference-to-video model is a Video to Video provider and no edit model", () => {
|
|
81
|
+
for (const id of Object.keys(REFERENCE_TO_VIDEO_PROVIDERS)) {
|
|
82
|
+
expect(VIDEO_TO_VIDEO_PROVIDERS as readonly string[]).toContain(id)
|
|
83
|
+
expect(MODEL_CATALOG[id]!.modes).not.toContain("v2v")
|
|
84
|
+
}
|
|
85
|
+
// The shared id keeps its text-to-video listing; the fast tier has no other lane.
|
|
86
|
+
expect(MODEL_CATALOG["wan"]!.modes).toEqual(["t2v"])
|
|
87
|
+
expect(MODEL_CATALOG["wan-flash"]!.modes).toEqual([])
|
|
56
88
|
})
|
|
57
89
|
})
|
|
58
90
|
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
checkVideoToVideoClipLength,
|
|
4
|
+
isClipPricedV2vProvider,
|
|
5
|
+
V2V_CLIP_RATE_IDS,
|
|
6
|
+
videoToVideoBilledSeconds,
|
|
7
|
+
videoToVideoClipPrice,
|
|
8
|
+
videoToVideoClipRateOf,
|
|
9
|
+
videoToVideoEstimatePrice,
|
|
10
|
+
videoToVideoSentResolution,
|
|
11
|
+
wanVideoEditRateFromSeconds,
|
|
12
|
+
} from "../video-to-video-pricing.js"
|
|
13
|
+
|
|
14
|
+
/** The rows as seeded (STATIC_CREDIT_COSTS / migration 671), base credits. */
|
|
15
|
+
const ROWS: Readonly<Record<string, number>> = {
|
|
16
|
+
"wan-videoedit": 320,
|
|
17
|
+
"wan-videoedit:1080p:per-4s": 240,
|
|
18
|
+
"happyhorse-edit:720p:per-4s": 560,
|
|
19
|
+
"happyhorse-edit:1080p:per-4s": 960,
|
|
20
|
+
}
|
|
21
|
+
const rowOf = (id: string) => ROWS[id]
|
|
22
|
+
/** The base a price stands for, as every lane charges it: a rate × units rounded up once, else the flat row. */
|
|
23
|
+
const base = (p: { creditId: string; units?: number }) => (p.units === undefined ? ROWS[p.creditId]! : Math.ceil(ROWS[p.creditId]! * p.units))
|
|
24
|
+
|
|
25
|
+
const priceOf = (provider: "happyhorse-edit" | "wan-videoedit", resolution: unknown, clipSec: number, videoEditDuration?: unknown) => {
|
|
26
|
+
const check = checkVideoToVideoClipLength(provider, clipSec, videoEditDuration)
|
|
27
|
+
if (!check.ok) throw new Error(check.message)
|
|
28
|
+
return videoToVideoClipPrice(provider, resolution, check.billedSeconds, rowOf)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe("Video to Video priced by the clip's length", () => {
|
|
32
|
+
it("only HappyHorse Edit and Wan 2.7 VideoEdit are priced by their clip", () => {
|
|
33
|
+
expect(isClipPricedV2vProvider("happyhorse-edit")).toBe(true)
|
|
34
|
+
expect(isClipPricedV2vProvider("wan-videoedit")).toBe(true)
|
|
35
|
+
for (const other of ["wan", "wan-flash", "runway-aleph", "luma-modify", "seedance-2-5", undefined]) {
|
|
36
|
+
expect(isClipPricedV2vProvider(other)).toBe(false)
|
|
37
|
+
expect(videoToVideoClipRateOf(other, "720p")).toBeUndefined()
|
|
38
|
+
}
|
|
39
|
+
expect(V2V_CLIP_RATE_IDS).toEqual(["happyhorse-edit:720p:per-4s", "happyhorse-edit:1080p:per-4s", "wan-videoedit:1080p:per-4s"])
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
describe("HappyHorse Edit", () => {
|
|
43
|
+
it("bills every started half-second of the clip, forgiving float noise only", () => {
|
|
44
|
+
expect(videoToVideoBilledSeconds("happyhorse-edit", 3)).toBe(3)
|
|
45
|
+
expect(videoToVideoBilledSeconds("happyhorse-edit", 3.0000000001)).toBe(3)
|
|
46
|
+
expect(videoToVideoBilledSeconds("happyhorse-edit", 3.01)).toBe(3.5)
|
|
47
|
+
expect(videoToVideoBilledSeconds("happyhorse-edit", 10.04)).toBe(10.5)
|
|
48
|
+
expect(videoToVideoBilledSeconds("happyhorse-edit", 10.5)).toBe(10.5)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it("worked examples: 3.00 s at 720p = 420, 10.04 s at 720p = 1,470, 3.00 s at 1080p = 720 (base)", () => {
|
|
52
|
+
const a = priceOf("happyhorse-edit", "720p", 3)
|
|
53
|
+
expect(a).toEqual({ creditId: "happyhorse-edit:720p:per-4s", units: 0.75 })
|
|
54
|
+
expect(base(a)).toBe(420)
|
|
55
|
+
const b = priceOf("happyhorse-edit", undefined, 10.04)
|
|
56
|
+
expect(b).toEqual({ creditId: "happyhorse-edit:720p:per-4s", units: 2.625 })
|
|
57
|
+
expect(base(b)).toBe(1470)
|
|
58
|
+
const c = priceOf("happyhorse-edit", "1080p", 3)
|
|
59
|
+
expect(c).toEqual({ creditId: "happyhorse-edit:1080p:per-4s", units: 0.75 })
|
|
60
|
+
expect(base(c)).toBe(720)
|
|
61
|
+
expect(base(priceOf("happyhorse-edit", "720p", 60))).toBe(8400)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it("prices and sends 720p unless the request says 1080p", () => {
|
|
65
|
+
expect(videoToVideoSentResolution("happyhorse-edit", undefined)).toBe("720p")
|
|
66
|
+
expect(videoToVideoSentResolution("happyhorse-edit", "480p")).toBe("720p")
|
|
67
|
+
expect(videoToVideoSentResolution("happyhorse-edit", "720p")).toBe("720p")
|
|
68
|
+
expect(videoToVideoSentResolution("happyhorse-edit", "1080p")).toBe("1080p")
|
|
69
|
+
expect(videoToVideoClipRateOf("happyhorse-edit", "480p")?.rateId).toBe("happyhorse-edit:720p:per-4s")
|
|
70
|
+
// Every other model's resolution is left as sent.
|
|
71
|
+
expect(videoToVideoSentResolution("wan", "1080p")).toBe("1080p")
|
|
72
|
+
expect(videoToVideoSentResolution("wan-videoedit", undefined)).toBeUndefined()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it("refuses a clip shorter than 3 s or longer than 60 s, with no grace", () => {
|
|
76
|
+
expect(checkVideoToVideoClipLength("happyhorse-edit", 2.99)).toMatchObject({ ok: false, code: "video_too_short" })
|
|
77
|
+
expect(checkVideoToVideoClipLength("happyhorse-edit", 3)).toEqual({ ok: true, billedSeconds: 3 })
|
|
78
|
+
expect(checkVideoToVideoClipLength("happyhorse-edit", 60)).toEqual({ ok: true, billedSeconds: 60 })
|
|
79
|
+
const long = checkVideoToVideoClipLength("happyhorse-edit", 60.02)
|
|
80
|
+
expect(long).toMatchObject({ ok: false, code: "video_too_long" })
|
|
81
|
+
expect(long.ok ? "" : long.message).toMatch(/at most 60 seconds\. Trim the video first\./)
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
describe("Wan 2.7 VideoEdit", () => {
|
|
86
|
+
it("bills the clip it delivers: the clip's length, or the shorter length asked for, whole seconds after 0.05 s", () => {
|
|
87
|
+
expect(videoToVideoBilledSeconds("wan-videoedit", 6, "0")).toBe(6)
|
|
88
|
+
expect(videoToVideoBilledSeconds("wan-videoedit", 6, undefined)).toBe(6)
|
|
89
|
+
expect(videoToVideoBilledSeconds("wan-videoedit", 6.05)).toBe(6)
|
|
90
|
+
expect(videoToVideoBilledSeconds("wan-videoedit", 6.06)).toBe(7)
|
|
91
|
+
expect(videoToVideoBilledSeconds("wan-videoedit", 9, "5")).toBe(5)
|
|
92
|
+
expect(videoToVideoBilledSeconds("wan-videoedit", 3, "5")).toBe(3)
|
|
93
|
+
expect(videoToVideoBilledSeconds("wan-videoedit", 10.04, "10")).toBe(10)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it("is charged the larger of its flat row and its rate: 3 s stays 320, 5 s 320, 6 s 360, 10 s 600 (base)", () => {
|
|
97
|
+
expect(priceOf("wan-videoedit", "1080p", 3)).toEqual({ creditId: "wan-videoedit" })
|
|
98
|
+
expect(base(priceOf("wan-videoedit", "1080p", 3))).toBe(320)
|
|
99
|
+
expect(base(priceOf("wan-videoedit", "1080p", 5))).toBe(320)
|
|
100
|
+
expect(priceOf("wan-videoedit", "1080p", 6)).toEqual({ creditId: "wan-videoedit:1080p:per-4s", units: 1.5 })
|
|
101
|
+
expect(base(priceOf("wan-videoedit", "1080p", 6))).toBe(360)
|
|
102
|
+
expect(base(priceOf("wan-videoedit", undefined, 10))).toBe(600)
|
|
103
|
+
// Asked for 5 s of a 10 s clip: 5 billed seconds, the flat row.
|
|
104
|
+
expect(base(priceOf("wan-videoedit", "1080p", 10, "5"))).toBe(320)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it("never costs less than the flat row, at any length it takes", () => {
|
|
108
|
+
for (let tenths = 20; tenths <= 100; tenths++) {
|
|
109
|
+
const p = priceOf("wan-videoedit", "1080p", tenths / 10)
|
|
110
|
+
expect(base(p)).toBeGreaterThanOrEqual(320)
|
|
111
|
+
expect(base(p)).toBe(Math.max(320, Math.ceil((240 * videoToVideoBilledSeconds("wan-videoedit", tenths / 10)) / 4)))
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it("follows the live rows: a repriced row moves where the rate takes over", () => {
|
|
116
|
+
expect(wanVideoEditRateFromSeconds("1080p", rowOf)).toBe(6)
|
|
117
|
+
expect(wanVideoEditRateFromSeconds("1080p", (id) => (id === "wan-videoedit" ? 100 : ROWS[id]))).toBe(2)
|
|
118
|
+
expect(wanVideoEditRateFromSeconds("1080p", (id) => (id === "wan-videoedit" ? 10_000 : ROWS[id]))).toBeUndefined()
|
|
119
|
+
// A rate the table does not price never wins.
|
|
120
|
+
expect(videoToVideoClipPrice("wan-videoedit", "1080p", 10, (id) => (id === "wan-videoedit" ? 320 : undefined))).toEqual({ creditId: "wan-videoedit" })
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it("720p is charged at the 1080p rate for now", () => {
|
|
124
|
+
expect(videoToVideoClipRateOf("wan-videoedit", "720p")?.rateId).toBe("wan-videoedit:1080p:per-4s")
|
|
125
|
+
expect(base(priceOf("wan-videoedit", "720p", 10))).toBe(600)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it("refuses a clip shorter than 2 s or past 10 s by more than 0.05 s (a clip within it is billed at 10 s)", () => {
|
|
129
|
+
expect(checkVideoToVideoClipLength("wan-videoedit", 1.9)).toMatchObject({ ok: false, code: "video_too_short" })
|
|
130
|
+
expect(checkVideoToVideoClipLength("wan-videoedit", 2)).toEqual({ ok: true, billedSeconds: 2 })
|
|
131
|
+
expect(checkVideoToVideoClipLength("wan-videoedit", 10.05)).toEqual({ ok: true, billedSeconds: 10 })
|
|
132
|
+
expect(checkVideoToVideoClipLength("wan-videoedit", 10.06)).toMatchObject({ ok: false, code: "video_too_long" })
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
describe("estimates", () => {
|
|
137
|
+
it("quote the known length as a run bills it", () => {
|
|
138
|
+
expect(videoToVideoEstimatePrice("happyhorse-edit", "720p", undefined, 10.04, rowOf)).toEqual({ creditId: "happyhorse-edit:720p:per-4s", units: 2.625, lengthKnown: true })
|
|
139
|
+
expect(videoToVideoEstimatePrice("wan-videoedit", "1080p", "0", 4, rowOf)).toEqual({ creditId: "wan-videoedit", lengthKnown: true })
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it("quote the longest clip the model takes when the length is not known — never below the hold", () => {
|
|
143
|
+
const hh = videoToVideoEstimatePrice("happyhorse-edit", "720p", undefined, undefined, rowOf)
|
|
144
|
+
expect(hh).toEqual({ creditId: "happyhorse-edit:720p:per-4s", units: 15, lengthKnown: false })
|
|
145
|
+
const wan = videoToVideoEstimatePrice("wan-videoedit", "1080p", "0", null, rowOf)
|
|
146
|
+
expect(wan).toEqual({ creditId: "wan-videoedit:1080p:per-4s", units: 2.5, lengthKnown: false })
|
|
147
|
+
for (let tenths = 30; tenths <= 600; tenths += 7) expect(base(hh)).toBeGreaterThanOrEqual(base(priceOf("happyhorse-edit", "720p", tenths / 10)))
|
|
148
|
+
for (let tenths = 20; tenths <= 100; tenths++) expect(base(wan)).toBeGreaterThanOrEqual(base(priceOf("wan-videoedit", "1080p", tenths / 10)))
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
})
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How an Audio Isolation run is priced (decided 2026-11-18): from the length
|
|
3
|
+
* of its audio as the server reads it before anything is held, never a length
|
|
4
|
+
* the caller declares.
|
|
5
|
+
*
|
|
6
|
+
* - The run is charged {@link AUDIO_ISOLATION_RATE_ID} once per started
|
|
7
|
+
* {@link AUDIO_ISOLATION_RATE_SECONDS} seconds of the audio, at least once,
|
|
8
|
+
* after forgiving `CLIP_PRICE_GRACE_SEC` past a mark. The hold IS the charge.
|
|
9
|
+
* - Audio longer than {@link AUDIO_ISOLATION_MAX_SEC} (30 minutes, a hair past
|
|
10
|
+
* it forgiven) is refused before anything is held; so is a file larger than
|
|
11
|
+
* {@link AUDIO_ISOLATION_MAX_BYTES}.
|
|
12
|
+
*
|
|
13
|
+
* The route, the workflow run, the MCP verb (which calls the route) and both
|
|
14
|
+
* estimates read this one module.
|
|
15
|
+
*/
|
|
16
|
+
import { CLIP_PRICE_GRACE_SEC, gracedMeasuredSec } from "./priced-clip-seconds.js"
|
|
17
|
+
|
|
18
|
+
/** Float noise: a length that is arithmetic can land a hair past the limit, and must not be refused for it. */
|
|
19
|
+
const FLOAT_NOISE_SEC = 1e-9
|
|
20
|
+
|
|
21
|
+
/** The row an Audio Isolation run reserves and is charged: the price of ten seconds of audio. */
|
|
22
|
+
export const AUDIO_ISOLATION_RATE_ID = "elevenlabs-isolation:per-10s"
|
|
23
|
+
|
|
24
|
+
/** The seconds of audio one unit of {@link AUDIO_ISOLATION_RATE_ID} prices. */
|
|
25
|
+
export const AUDIO_ISOLATION_RATE_SECONDS = 10
|
|
26
|
+
|
|
27
|
+
/** The longest audio a run takes: 30 minutes. */
|
|
28
|
+
export const AUDIO_ISOLATION_MAX_SEC = 1800
|
|
29
|
+
|
|
30
|
+
/** The largest file a run takes (the provider's own limit): 500 MB. */
|
|
31
|
+
export const AUDIO_ISOLATION_MAX_BYTES = 500 * 1024 * 1024
|
|
32
|
+
|
|
33
|
+
/** The most units a run can be charged: the 30-minute cap's. */
|
|
34
|
+
export const AUDIO_ISOLATION_MAX_UNITS = AUDIO_ISOLATION_MAX_SEC / AUDIO_ISOLATION_RATE_SECONDS
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The units of {@link AUDIO_ISOLATION_RATE_ID} an audio of `seconds` is
|
|
38
|
+
* charged: every started ten seconds after the grace, at least one, at most
|
|
39
|
+
* the cap's. THE one rounding every lane reads.
|
|
40
|
+
*/
|
|
41
|
+
export function audioIsolationUnits(seconds: number): number {
|
|
42
|
+
if (!Number.isFinite(seconds) || seconds <= 0) return 1
|
|
43
|
+
const units = Math.ceil(gracedMeasuredSec(seconds) / AUDIO_ISOLATION_RATE_SECONDS)
|
|
44
|
+
return Math.min(AUDIO_ISOLATION_MAX_UNITS, Math.max(1, units))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** What the length check answers for an audio of a given length. */
|
|
48
|
+
export type AudioIsolationLengthCheck =
|
|
49
|
+
| { readonly ok: true; readonly units: number }
|
|
50
|
+
| { readonly ok: false; readonly code: "audio_too_long"; readonly message: string }
|
|
51
|
+
|
|
52
|
+
/** The refusal of an audio past the 30-minute cap: how long it is, the limit, and what to do. */
|
|
53
|
+
export function audioIsolationTooLongMessage(seconds: number): string {
|
|
54
|
+
const minutes = Math.floor(seconds / 60)
|
|
55
|
+
const rest = Math.round(seconds - minutes * 60)
|
|
56
|
+
const length = rest > 0 ? `${minutes} min ${rest} s` : `${minutes} min`
|
|
57
|
+
return `The audio is ${length} long. Audio Isolation takes audio up to 30 minutes: split or trim it to 30 minutes or less first.`
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Whether an audio of `seconds` can run, and the units it is charged. Past
|
|
62
|
+
* the 30-minute cap by more than `CLIP_PRICE_GRACE_SEC` is refused; within
|
|
63
|
+
* that grace it is charged at the cap.
|
|
64
|
+
*/
|
|
65
|
+
export function checkAudioIsolationLength(seconds: number): AudioIsolationLengthCheck {
|
|
66
|
+
if (seconds > AUDIO_ISOLATION_MAX_SEC + CLIP_PRICE_GRACE_SEC + FLOAT_NOISE_SEC) {
|
|
67
|
+
return { ok: false, code: "audio_too_long", message: audioIsolationTooLongMessage(seconds) }
|
|
68
|
+
}
|
|
69
|
+
return { ok: true, units: audioIsolationUnits(seconds) }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The units an ESTIMATE quotes before the run reads the audio: the length
|
|
74
|
+
* the graph gives, at most the cap; a length it does not know quotes the cap
|
|
75
|
+
* (the most a run can be charged), and the caller marks it as an estimate.
|
|
76
|
+
*/
|
|
77
|
+
export function audioIsolationEstimateUnits(knownSec?: number | null): number {
|
|
78
|
+
if (knownSec == null || !Number.isFinite(knownSec) || knownSec <= 0) return AUDIO_ISOLATION_MAX_UNITS
|
|
79
|
+
return audioIsolationUnits(knownSec)
|
|
80
|
+
}
|
package/src/competitors.ts
CHANGED
|
@@ -45,8 +45,14 @@ export interface CompetitorSearch {
|
|
|
45
45
|
readonly term?: string
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
/**
|
|
49
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The most search terms any brand can have (the platform's own ceiling; a plan
|
|
50
|
+
* allows fewer). A platform admin has no cap on terms, only on one scan's
|
|
51
|
+
* size (`COMPETITOR_SCAN_SEARCH_LIMIT`): one platform fits up to this many.
|
|
52
|
+
*/
|
|
53
|
+
export const COMPETITOR_SEARCH_TERMS_MAX = 100
|
|
54
|
+
/** A brand whose scan would run more searches than this (each account, and each about-platform once per term) cannot be saved or scanned. */
|
|
55
|
+
export const COMPETITOR_SCAN_SEARCH_LIMIT = 100
|
|
50
56
|
/** The longest a search term can be. */
|
|
51
57
|
export const COMPETITOR_SEARCH_TERM_MAX_LENGTH = 100
|
|
52
58
|
/** A brand scan is charged this id per Social Search page it runs, summed (a topic scan has its own, `TOPIC_SCAN_PAGE_CREDIT_ID`). */
|
|
@@ -1206,6 +1206,12 @@ export function pricedVideoSelection(opts: {
|
|
|
1206
1206
|
* Compute composite model identifier for motion control with duration-tiered pricing.
|
|
1207
1207
|
* Examples: "kling-3.0-motion:10s", "kling-3.0-motion:1080p:15s", "motion-transfer:5s"
|
|
1208
1208
|
*
|
|
1209
|
+
* This is the old TIER row only, kept for older code and saved quotes: no
|
|
1210
|
+
* run is priced from it. A run is priced through `motionTransferPrice`
|
|
1211
|
+
* (motion-transfer-pricing.ts), per second of the driving video as the server
|
|
1212
|
+
* reads it, for every model and size (Wan Animate's flat rows below are its
|
|
1213
|
+
* floor).
|
|
1214
|
+
*
|
|
1209
1215
|
* Wan Animate providers use resolution-tiered pricing (not per-second):
|
|
1210
1216
|
* "wan-animate-move" (480p default), "wan-animate-move:580p", "wan-animate-move:720p"
|
|
1211
1217
|
*
|