@nodaro/shared 3.24.0 → 3.25.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/index.cjs +595 -128
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +375 -48
- package/dist/index.d.ts +375 -48
- package/dist/index.js +553 -129
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/credit-identifiers.test.ts +19 -6
- package/src/__tests__/dialogue-capabilities.test.ts +3 -2
- package/src/__tests__/edit-plan-minute-ids.test.ts +82 -0
- package/src/__tests__/json-kinds.test.ts +179 -0
- package/src/__tests__/presentation-utils.test.ts +1 -0
- package/src/__tests__/preview-gate.test.ts +2 -2
- package/src/__tests__/pricing-default-duration.test.ts +56 -15
- package/src/__tests__/private-host.test.ts +24 -0
- package/src/__tests__/render-nodes.test.ts +22 -3
- package/src/__tests__/tts-capabilities.test.ts +61 -1
- package/src/__tests__/video-link-input.test.ts +148 -0
- package/src/__tests__/video-link-needs.test.ts +67 -0
- package/src/__tests__/video-request-normalize.test.ts +18 -3
- package/src/credit-identifiers.ts +48 -37
- package/src/edit-plan-contract.ts +67 -1
- package/src/fan-out-rows.ts +2 -2
- package/src/index.ts +45 -1
- package/src/json-kinds.ts +188 -0
- package/src/model-catalog.ts +121 -8
- package/src/model-constants.ts +68 -42
- package/src/node-default-mappings.ts +1 -0
- package/src/pipeline-types.ts +13 -2
- package/src/presentation-utils.ts +8 -1
- package/src/private-host.ts +91 -0
- package/src/producer-types.ts +3 -0
- package/src/render-nodes.ts +12 -1
- package/src/scene-node-types.ts +17 -5
- package/src/social-post-readers.ts +37 -0
- package/src/video-link.ts +238 -0
- package/src/voices.ts +16 -9
package/package.json
CHANGED
|
@@ -105,6 +105,15 @@ describe("buildCreditModelIdentifier", () => {
|
|
|
105
105
|
})
|
|
106
106
|
})
|
|
107
107
|
|
|
108
|
+
// --- nano-banana-2-1 ---
|
|
109
|
+
describe("nano-banana-2-1", () => {
|
|
110
|
+
it("2K and 4K return composite identifiers; 1K is the bare id", () => {
|
|
111
|
+
expect(buildCreditModelIdentifier("nano-banana-2-1", undefined, "2K")).toBe("nano-banana-2-1:2K")
|
|
112
|
+
expect(buildCreditModelIdentifier("nano-banana-2-1", undefined, "4K")).toBe("nano-banana-2-1:4K")
|
|
113
|
+
expect(buildCreditModelIdentifier("nano-banana-2-1", undefined, "1K")).toBe("nano-banana-2-1")
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
|
|
108
117
|
// --- topaz-image-upscale ---
|
|
109
118
|
describe("topaz-image-upscale", () => {
|
|
110
119
|
it('targetResolution="4K" returns composite identifier', () => {
|
|
@@ -509,16 +518,20 @@ describe("buildVideoCreditModelIdentifier", () => {
|
|
|
509
518
|
expect(buildVideoCreditModelIdentifier("seedance", 8)).toBe("seedance:8s")
|
|
510
519
|
})
|
|
511
520
|
|
|
512
|
-
it("6s
|
|
513
|
-
expect(buildVideoCreditModelIdentifier("seedance", 6)).toBe("seedance:
|
|
521
|
+
it("6s is charged as the 4s the runner renders (nearest offered length, a tie goes shorter)", () => {
|
|
522
|
+
expect(buildVideoCreditModelIdentifier("seedance", 6)).toBe("seedance:4s")
|
|
514
523
|
})
|
|
515
524
|
|
|
516
525
|
it("12s -> :12s", () => {
|
|
517
526
|
expect(buildVideoCreditModelIdentifier("seedance", 12)).toBe("seedance:12s")
|
|
518
527
|
})
|
|
519
528
|
|
|
520
|
-
it("10s
|
|
521
|
-
expect(buildVideoCreditModelIdentifier("seedance", 10)).toBe("seedance:
|
|
529
|
+
it("10s is charged as the 8s the runner renders (nearest offered length)", () => {
|
|
530
|
+
expect(buildVideoCreditModelIdentifier("seedance", 10)).toBe("seedance:8s")
|
|
531
|
+
})
|
|
532
|
+
|
|
533
|
+
it("11s is charged as the 12s the runner renders", () => {
|
|
534
|
+
expect(buildVideoCreditModelIdentifier("seedance", 11)).toBe("seedance:12s")
|
|
522
535
|
})
|
|
523
536
|
|
|
524
537
|
it("exceeding max clamps to 12s", () => {
|
|
@@ -560,8 +573,8 @@ describe("buildVideoCreditModelIdentifier", () => {
|
|
|
560
573
|
expect(buildVideoCreditModelIdentifier("grok-i2v", 6)).toBe("grok-i2v:6s")
|
|
561
574
|
})
|
|
562
575
|
|
|
563
|
-
it("grok-i2v 15s", () => {
|
|
564
|
-
expect(buildVideoCreditModelIdentifier("grok-i2v", 15)).toBe("grok-i2v:
|
|
576
|
+
it("grok-i2v 15s is charged as the 10s clip it renders (it offers 6s and 10s only)", () => {
|
|
577
|
+
expect(buildVideoCreditModelIdentifier("grok-i2v", 15)).toBe("grok-i2v:10s")
|
|
565
578
|
})
|
|
566
579
|
})
|
|
567
580
|
|
|
@@ -119,8 +119,9 @@ describe("elevenlabs-dialogue-v4 — added beside v3 dialogue", () => {
|
|
|
119
119
|
expect(c.levers).toEqual(["stability", "similarity"])
|
|
120
120
|
expect(c.stabilitySteps).toBeUndefined()
|
|
121
121
|
expect(c.languageCode).toBe(true)
|
|
122
|
-
// The live-probe number
|
|
123
|
-
expect(c.maxChars).toBe(
|
|
122
|
+
// The live-probe number: a 10,000-character v4 dialogue voiced whole in 130 s (measured 2026-10-06).
|
|
123
|
+
expect(c.maxChars).toBe(10000)
|
|
124
|
+
expect(getDialogueCapabilities("elevenlabs-dialogue").maxChars).toBe(5000) // v3 dialogue did not move
|
|
124
125
|
expect(c.languages).toEqual(getDialogueCapabilities("elevenlabs-dialogue").languages)
|
|
125
126
|
})
|
|
126
127
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit Plan per started minute (decided 2026-10-07): the id a run reserves is
|
|
3
|
+
* `edit-plan:<mode>:<tier>:<N>m`, N = the started minutes of the source, priced
|
|
4
|
+
* flat + rate × N from one rate row and one flat row per mode × tier. The step
|
|
5
|
+
* ids (15/30/60/90/120/180) keep the same shape, so one parser reads both.
|
|
6
|
+
*/
|
|
7
|
+
import { describe, it, expect } from "vitest"
|
|
8
|
+
import {
|
|
9
|
+
EDIT_PLAN_MAX_MINUTES,
|
|
10
|
+
buildEditPlanCreditId,
|
|
11
|
+
editPlanFlatCreditId,
|
|
12
|
+
editPlanMinutesBaseCredits,
|
|
13
|
+
editPlanRateCreditId,
|
|
14
|
+
editPlanReserveCreditId,
|
|
15
|
+
editPlanStartedMinutes,
|
|
16
|
+
parseEditPlanMinutesCreditId,
|
|
17
|
+
} from "../edit-plan-contract.js"
|
|
18
|
+
|
|
19
|
+
describe("started minutes", () => {
|
|
20
|
+
it.each([
|
|
21
|
+
[1, 1],
|
|
22
|
+
[60, 1],
|
|
23
|
+
[61, 2],
|
|
24
|
+
[44 * 60 + 1, 45],
|
|
25
|
+
[180 * 60, 180],
|
|
26
|
+
[500 * 60, EDIT_PLAN_MAX_MINUTES],
|
|
27
|
+
[0, 1],
|
|
28
|
+
])("%s s → %s", (sec, minutes) => {
|
|
29
|
+
expect(editPlanStartedMinutes(sec)).toBe(minutes)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it("an unknown length is the maximum", () => {
|
|
33
|
+
expect(editPlanStartedMinutes(undefined)).toBe(180)
|
|
34
|
+
expect(editPlanStartedMinutes(Number.NaN)).toBe(180)
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
describe("the reserve id", () => {
|
|
39
|
+
it("per started minute when the plugin charges that way", () => {
|
|
40
|
+
expect(editPlanReserveCreditId("tighten", "standard", 44 * 60 + 1, true)).toBe("edit-plan:tighten:standard:45m")
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it("the step otherwise, exactly as before", () => {
|
|
44
|
+
expect(editPlanReserveCreditId("tighten", "standard", 44 * 60 + 1, false)).toBe(buildEditPlanCreditId("tighten", "standard", 44 * 60 + 1))
|
|
45
|
+
expect(editPlanReserveCreditId("tighten", "standard", 44 * 60 + 1, false)).toBe("edit-plan:tighten:standard:60m")
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it("an unknown length reserves the 180-minute maximum either way", () => {
|
|
49
|
+
expect(editPlanReserveCreditId("clips", "premium", undefined, true)).toBe("edit-plan:clips:premium:180m")
|
|
50
|
+
expect(editPlanReserveCreditId("clips", "premium", undefined, false)).toBe("edit-plan:clips:premium:180m")
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
describe("the price rows", () => {
|
|
55
|
+
it("one rate row and one flat row per mode × tier, neither a minutes id", () => {
|
|
56
|
+
expect(editPlanRateCreditId("trailer", "economy")).toBe("edit-plan:trailer:economy:per-minute")
|
|
57
|
+
expect(editPlanFlatCreditId("trailer", "economy")).toBe("edit-plan:trailer:economy:flat")
|
|
58
|
+
expect(parseEditPlanMinutesCreditId(editPlanRateCreditId("trailer", "economy"))).toBeUndefined()
|
|
59
|
+
expect(parseEditPlanMinutesCreditId(editPlanFlatCreditId("trailer", "economy"))).toBeUndefined()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it("flat + rate × N, rounded up, at least 1", () => {
|
|
63
|
+
expect(editPlanMinutesBaseCredits(20, 4, 45)).toBe(200)
|
|
64
|
+
expect(editPlanMinutesBaseCredits(0, 2, 1)).toBe(2)
|
|
65
|
+
expect(editPlanMinutesBaseCredits(0, 0, 1)).toBe(1)
|
|
66
|
+
expect(editPlanMinutesBaseCredits(0, 0.5, 3)).toBe(2)
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
describe("parsing a minutes id", () => {
|
|
71
|
+
it("reads a started-minute id and a step id alike", () => {
|
|
72
|
+
expect(parseEditPlanMinutesCreditId("edit-plan:tighten:standard:45m")).toEqual({ mode: "tighten", tier: "standard", minutes: 45 })
|
|
73
|
+
expect(parseEditPlanMinutesCreditId("edit-plan:trailer:premium:180m")).toEqual({ mode: "trailer", tier: "premium", minutes: 180 })
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it.each(["edit-plan", "edit-plan:tighten:standard:0m", "edit-plan:tighten:standard:181m", "edit-plan:cut:standard:5m", "edit-plan:tighten:gold:5m", "apply-edl"])(
|
|
77
|
+
"refuses %s",
|
|
78
|
+
(id) => {
|
|
79
|
+
expect(parseEditPlanMinutesCreditId(id)).toBeUndefined()
|
|
80
|
+
},
|
|
81
|
+
)
|
|
82
|
+
})
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
// Through the package index: the shared handle typing both canvas validators
|
|
3
|
+
// and the server's edge normalization read (decided 2026-10-07).
|
|
4
|
+
import {
|
|
5
|
+
RENDER_NODE_TYPES,
|
|
6
|
+
jsonInputKind,
|
|
7
|
+
jsonKindMismatch,
|
|
8
|
+
jsonKindMismatchMessage,
|
|
9
|
+
jsonOutputKind,
|
|
10
|
+
declaredJsonOutput,
|
|
11
|
+
declaredJsonOutputRows,
|
|
12
|
+
type RenderNodeDescriptor,
|
|
13
|
+
} from "../index.js"
|
|
14
|
+
|
|
15
|
+
describe("jsonOutputKind — what a json output carries", () => {
|
|
16
|
+
it("Edit Plan's edl and Camera Switch's edl are EDLs; Camera Switch's transcript is a Transcript", () => {
|
|
17
|
+
expect(jsonOutputKind("edit-plan", "edl")).toBe("edl")
|
|
18
|
+
expect(jsonOutputKind("camera-switch", "edl")).toBe("edl")
|
|
19
|
+
expect(jsonOutputKind("camera-switch", "transcript")).toBe("transcript")
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it("a Transcribe's json is a Transcript (decided 2026-10-08), its text is not a kind", () => {
|
|
23
|
+
expect(jsonOutputKind("transcribe", "json")).toBe("transcript")
|
|
24
|
+
expect(jsonOutputKind("transcribe", undefined)).toBe("transcript")
|
|
25
|
+
expect(jsonOutputKind("transcribe", "text")).toBeUndefined()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it("reads a render's json pip from the render registry (jsonKind), never a node-name list", () => {
|
|
29
|
+
expect(jsonOutputKind("apply-edl", "json")).toBe("transcript")
|
|
30
|
+
// a render registered later with an EDL-emitting json (Speaker View)
|
|
31
|
+
const speakerLike = { ...RENDER_NODE_TYPES["apply-edl"]!, jsonKind: "edl" } as RenderNodeDescriptor
|
|
32
|
+
expect(jsonOutputKind("speaker-view", "json", { "speaker-view": speakerLike })).toBe("edl")
|
|
33
|
+
expect(jsonOutputKind("speaker-view", undefined, { "speaker-view": speakerLike })).toBe("edl")
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it("every registered render's json pip answers its own jsonKind", () => {
|
|
37
|
+
for (const [type, d] of Object.entries(RENDER_NODE_TYPES)) {
|
|
38
|
+
expect(jsonOutputKind(type, "json")).toBe(d.jsonKind)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it("an edge with no sourceHandle reads the node's primary pip", () => {
|
|
43
|
+
expect(jsonOutputKind("edit-plan", undefined)).toBe("edl")
|
|
44
|
+
expect(jsonOutputKind("camera-switch", null)).toBe("edl")
|
|
45
|
+
expect(jsonOutputKind("apply-edl", undefined)).toBe("transcript")
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it("is undefined for anything it does not know", () => {
|
|
49
|
+
expect(jsonOutputKind("transcribe", "text")).toBeUndefined()
|
|
50
|
+
expect(jsonOutputKind("edit-plan", "nope")).toBeUndefined()
|
|
51
|
+
expect(jsonOutputKind("constructor", "json")).toBeUndefined()
|
|
52
|
+
expect(jsonOutputKind(undefined, "json")).toBeUndefined()
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
describe("jsonInputKind — what a json input expects", () => {
|
|
57
|
+
it("a `transcript` input expects a Transcript, an `edl` input an EDL", () => {
|
|
58
|
+
expect(jsonInputKind("add-captions", "transcript")).toBe("transcript")
|
|
59
|
+
expect(jsonInputKind("apply-edl", "transcript")).toBe("transcript")
|
|
60
|
+
expect(jsonInputKind("camera-switch", "transcript")).toBe("transcript")
|
|
61
|
+
expect(jsonInputKind("edit-plan", "transcript")).toBe("transcript")
|
|
62
|
+
expect(jsonInputKind("apply-edl", "edl")).toBe("edl")
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it("is undefined for every other input", () => {
|
|
66
|
+
expect(jsonInputKind("add-captions", "in")).toBeUndefined()
|
|
67
|
+
expect(jsonInputKind("add-captions", "captionPlan")).toBeUndefined()
|
|
68
|
+
expect(jsonInputKind("edit-plan", "silence")).toBeUndefined()
|
|
69
|
+
expect(jsonInputKind("add-captions", undefined)).toBeUndefined()
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
describe("jsonKindMismatch — an EDL is not a transcript", () => {
|
|
74
|
+
it("blocks every EDL output into a Transcript input", () => {
|
|
75
|
+
for (const [src, srcHandle] of [["edit-plan", "edl"], ["camera-switch", "edl"]] as const) {
|
|
76
|
+
for (const [tgt, tgtHandle] of [["add-captions", "transcript"], ["apply-edl", "transcript"], ["camera-switch", "transcript"], ["edit-plan", "transcript"]] as const) {
|
|
77
|
+
expect(jsonKindMismatch(src, srcHandle, tgt, tgtHandle), `${src}.${srcHandle} -> ${tgt}.${tgtHandle}`).toEqual({ output: "edl", input: "transcript" })
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it("still lets a Transcript into a Transcript input, and an EDL into an EDL input", () => {
|
|
83
|
+
expect(jsonKindMismatch("camera-switch", "transcript", "add-captions", "transcript")).toBeNull()
|
|
84
|
+
expect(jsonKindMismatch("apply-edl", "json", "add-captions", "transcript")).toBeNull()
|
|
85
|
+
expect(jsonKindMismatch("edit-plan", "edl", "apply-edl", "edl")).toBeNull()
|
|
86
|
+
expect(jsonKindMismatch("camera-switch", "edl", "camera-switch", "edl")).toBeNull()
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it("judges only what it can tell: an unknown source, a bare source handle, or another input is left alone", () => {
|
|
90
|
+
expect(jsonKindMismatch("web-scrape", "json", "add-captions", "transcript")).toBeNull()
|
|
91
|
+
expect(jsonKindMismatch("web-scrape", "json", "apply-edl", "edl")).toBeNull()
|
|
92
|
+
expect(jsonKindMismatch("transcribe", "text", "apply-edl", "edl")).toBeNull()
|
|
93
|
+
expect(jsonKindMismatch("transcribe", "json", "apply-edl", "sources")).toBeNull()
|
|
94
|
+
expect(jsonKindMismatch("edit-plan", "edl", "add-captions", "captionPlan")).toBeNull()
|
|
95
|
+
expect(jsonKindMismatch("edit-plan", "edl", "add-captions", "in")).toBeNull()
|
|
96
|
+
expect(jsonKindMismatch("edit-plan", "edl", "add-captions", undefined)).toBeNull()
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it("blocks every Transcript output into an EDL input (decided 2026-10-08), from the same table", () => {
|
|
100
|
+
for (const [src, srcHandle] of [["transcribe", "json"], ["camera-switch", "transcript"], ["apply-edl", "json"]] as const) {
|
|
101
|
+
for (const [tgt, tgtHandle] of [["apply-edl", "edl"], ["camera-switch", "edl"]] as const) {
|
|
102
|
+
expect(jsonKindMismatch(src, srcHandle, tgt, tgtHandle), `${src}.${srcHandle} -> ${tgt}.${tgtHandle}`).toEqual({ output: "transcript", input: "edl" })
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it("a Transcript-emitting render's json is blocked from an EDL input too (registry-driven)", () => {
|
|
108
|
+
const d = { ...RENDER_NODE_TYPES["apply-edl"]!, jsonKind: "transcript" } as RenderNodeDescriptor
|
|
109
|
+
expect(jsonKindMismatch("r", "json", "apply-edl", "edl", { r: d })).toEqual({ output: "transcript", input: "edl" })
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it("an EDL-emitting render's json is blocked from a Transcript input too", () => {
|
|
113
|
+
const speakerLike = { ...RENDER_NODE_TYPES["apply-edl"]!, jsonKind: "edl" } as RenderNodeDescriptor
|
|
114
|
+
expect(jsonKindMismatch("speaker-view", "json", "add-captions", "transcript", { "speaker-view": speakerLike })).toEqual({ output: "edl", input: "transcript" })
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it("says what to do instead, naming both nodes", () => {
|
|
118
|
+
const m = jsonKindMismatch("edit-plan", "edl", "add-captions", "transcript")!
|
|
119
|
+
const msg = jsonKindMismatchMessage(m, { sourceLabel: "Edit Plan", targetLabel: "Add Captions" })
|
|
120
|
+
expect(msg).toContain("Edit Plan")
|
|
121
|
+
expect(msg).toContain("Add Captions")
|
|
122
|
+
expect(msg).toMatch(/edit list|EDL/)
|
|
123
|
+
expect(msg).toMatch(/not a transcript/i)
|
|
124
|
+
expect(msg).toMatch(/Transcribe/)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it("the reverse direction says so: a transcript is not an edit list, and points at an EDL source", () => {
|
|
128
|
+
const m = jsonKindMismatch("transcribe", "json", "apply-edl", "edl")!
|
|
129
|
+
const msg = jsonKindMismatchMessage(m, { sourceLabel: "Transcribe", targetLabel: "Apply EDL" })
|
|
130
|
+
expect(msg).toContain("Transcribe")
|
|
131
|
+
expect(msg).toContain("Apply EDL")
|
|
132
|
+
expect(msg).toMatch(/outputs a transcript/i)
|
|
133
|
+
expect(msg).toMatch(/not an edit list/i)
|
|
134
|
+
expect(msg).toMatch(/EDL input/)
|
|
135
|
+
expect(msg).toMatch(/Edit Plan/)
|
|
136
|
+
expect(msg).not.toMatch(/not a transcript/i)
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
describe("declaredJsonOutput — every JSON pip is classified (decided 2026-10-08)", () => {
|
|
141
|
+
it("a Text to Dialogue's json is a Transcript, so the EDL block covers it; its default read is the audio", () => {
|
|
142
|
+
expect(declaredJsonOutput("text-to-dialogue", "json")).toBe("transcript")
|
|
143
|
+
expect(jsonOutputKind("text-to-dialogue", "json")).toBe("transcript")
|
|
144
|
+
expect(declaredJsonOutput("text-to-dialogue", undefined)).toBeUndefined()
|
|
145
|
+
expect(declaredJsonOutput("text-to-dialogue", "audio")).toBeUndefined()
|
|
146
|
+
expect(jsonKindMismatch("text-to-dialogue", "json", "apply-edl", "edl")).toEqual({ output: "transcript", input: "edl" })
|
|
147
|
+
expect(jsonKindMismatch("text-to-dialogue", "json", "add-captions", "transcript")).toBeNull()
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
it("`other` is a recorded classification, not a kind: it blocks nothing", () => {
|
|
151
|
+
expect(declaredJsonOutput("web-scrape", "json")).toBe("other")
|
|
152
|
+
expect(declaredJsonOutput("forced-alignment", "data")).toBe("other")
|
|
153
|
+
expect(declaredJsonOutput("describe-to-picker", "picker-json")).toBe("other")
|
|
154
|
+
expect(jsonOutputKind("web-scrape", "json")).toBeUndefined()
|
|
155
|
+
expect(jsonKindMismatch("video-analysis", "json", "add-captions", "transcript")).toBeNull()
|
|
156
|
+
expect(jsonKindMismatch("silence-detect", "json", "apply-edl", "edl")).toBeNull()
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
it("answers a render's json from the registry and nothing else on a render", () => {
|
|
160
|
+
expect(declaredJsonOutput("speaker-view", "json")).toBe("edl")
|
|
161
|
+
expect(declaredJsonOutput("speaker-view", "video")).toBeUndefined()
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it("is undefined for anything undeclared, and never reads inherited keys", () => {
|
|
165
|
+
expect(declaredJsonOutput("generate-image", "json")).toBeUndefined()
|
|
166
|
+
expect(declaredJsonOutput("constructor", "json")).toBeUndefined()
|
|
167
|
+
expect(declaredJsonOutput("web-scrape", "constructor")).toBeUndefined()
|
|
168
|
+
expect(declaredJsonOutput(undefined, "json")).toBeUndefined()
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
it("lists its rows, each declaring one of the three classifications", () => {
|
|
172
|
+
const rows = declaredJsonOutputRows()
|
|
173
|
+
expect(rows.length).toBeGreaterThan(0)
|
|
174
|
+
for (const [type, pip, kind] of rows) {
|
|
175
|
+
expect(["transcript", "edl", "other"], `${type}.${pip}`).toContain(kind)
|
|
176
|
+
expect(declaredJsonOutput(type, pip)).toBe(kind)
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
})
|
|
@@ -51,8 +51,8 @@ function tighten(quality: "proxy" | "final" | undefined) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
describe("PREVIEW_RENDER_NODE_TYPES", () => {
|
|
54
|
-
it("names the render nodes a run can stop at (apply-edl
|
|
55
|
-
expect([...PREVIEW_RENDER_NODE_TYPES]).toEqual(["apply-edl"])
|
|
54
|
+
it("names the render nodes a run can stop at (apply-edl and speaker-view)", () => {
|
|
55
|
+
expect([...PREVIEW_RENDER_NODE_TYPES]).toEqual(["apply-edl", "speaker-view"])
|
|
56
56
|
})
|
|
57
57
|
})
|
|
58
58
|
|
|
@@ -1,39 +1,69 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest"
|
|
2
|
-
import {
|
|
2
|
+
import { MODEL_CATALOG } from "../model-catalog.js"
|
|
3
|
+
import { pricedOutputDurationSec, snapToNearestDuration, videoDefaultDurationSec } from "../model-constants.js"
|
|
3
4
|
import { buildVideoCreditModelIdentifier } from "../credit-identifiers.js"
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* A video request that names no duration is CHARGED for the length the model
|
|
8
|
+
* renders by default (catalog `defaultDuration`), never for a global 5 s; one
|
|
9
|
+
* that names a length the model does not offer is charged for the nearest length
|
|
10
|
+
* it does (the runners' own snap rule). `pricedOutputDurationSec` is the one
|
|
11
|
+
* funnel every price path reads.
|
|
10
12
|
*/
|
|
11
13
|
describe("pricedOutputDurationSec", () => {
|
|
12
|
-
it("
|
|
14
|
+
it("an offered duration wins, as a number or a numeric string", () => {
|
|
13
15
|
expect(pricedOutputDurationSec("seedance-2-5", 12)).toBe(12)
|
|
14
16
|
expect(pricedOutputDurationSec("seedance-2-5", "12")).toBe(12)
|
|
15
17
|
expect(pricedOutputDurationSec("minimax-h3", 4)).toBe(4)
|
|
16
18
|
})
|
|
17
19
|
|
|
18
|
-
it("an omitted duration
|
|
20
|
+
it("an omitted duration is the model's catalog default render length", () => {
|
|
21
|
+
expect(pricedOutputDurationSec("seedance-2", undefined)).toBe(8)
|
|
22
|
+
expect(pricedOutputDurationSec("seedance-2-fast", undefined)).toBe(8)
|
|
23
|
+
expect(pricedOutputDurationSec("seedance-2-mini", undefined)).toBe(8)
|
|
19
24
|
expect(pricedOutputDurationSec("seedance-2-5", undefined)).toBe(8)
|
|
25
|
+
expect(pricedOutputDurationSec("grok-i2v", undefined)).toBe(6)
|
|
20
26
|
expect(pricedOutputDurationSec("grok-imagine-video-1.5", undefined)).toBe(8)
|
|
21
27
|
expect(pricedOutputDurationSec("minimax-h3", undefined)).toBe(6)
|
|
22
|
-
expect(
|
|
28
|
+
expect(pricedOutputDurationSec("hailuo-2.3-pro", undefined)).toBe(6)
|
|
29
|
+
expect(pricedOutputDurationSec("kling", undefined)).toBe(5)
|
|
30
|
+
expect(pricedOutputDurationSec("ltx-2.3-pro", undefined)).toBe(6)
|
|
23
31
|
})
|
|
24
32
|
|
|
25
|
-
it("
|
|
26
|
-
expect(pricedOutputDurationSec("seedance-2",
|
|
27
|
-
expect(pricedOutputDurationSec("
|
|
33
|
+
it("an unparseable duration is priced the same way", () => {
|
|
34
|
+
expect(pricedOutputDurationSec("seedance-2", "abc")).toBe(8)
|
|
35
|
+
expect(pricedOutputDurationSec("grok-i2v", "abc")).toBe(6)
|
|
28
36
|
})
|
|
29
37
|
|
|
30
|
-
it("
|
|
31
|
-
expect(pricedOutputDurationSec("
|
|
32
|
-
expect(pricedOutputDurationSec("
|
|
38
|
+
it("a length the model does not offer is charged as the nearest one it does (a tie goes shorter)", () => {
|
|
39
|
+
expect(pricedOutputDurationSec("kling", 7)).toBe(5)
|
|
40
|
+
expect(pricedOutputDurationSec("kling", 8)).toBe(10)
|
|
41
|
+
expect(pricedOutputDurationSec("grok-i2v", 8)).toBe(6)
|
|
42
|
+
expect(pricedOutputDurationSec("grok-i2v", 15)).toBe(10)
|
|
43
|
+
expect(pricedOutputDurationSec("seedance", 6)).toBe(4)
|
|
44
|
+
expect(pricedOutputDurationSec("seedance", 10)).toBe(8)
|
|
33
45
|
})
|
|
34
46
|
|
|
35
|
-
it("
|
|
47
|
+
it("snapToNearestDuration is the runners' rule: offered values pass, ties go to the earlier entry", () => {
|
|
48
|
+
expect(snapToNearestDuration(5, [4, 8, 12])).toBe(4)
|
|
49
|
+
expect(snapToNearestDuration(6, [4, 8, 12])).toBe(4)
|
|
50
|
+
expect(snapToNearestDuration(7, [4, 8, 12])).toBe(8)
|
|
51
|
+
expect(snapToNearestDuration(9, undefined)).toBe(9)
|
|
52
|
+
expect(snapToNearestDuration(9, [])).toBe(9)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it("every default is a length the model offers", () => {
|
|
56
|
+
for (const e of Object.values(MODEL_CATALOG)) {
|
|
57
|
+
if (e.defaultDuration === undefined) continue
|
|
58
|
+
expect(e.durations, `${e.id} declares defaultDuration but no durations`).toBeDefined()
|
|
59
|
+
expect(e.durations, `${e.id}: defaultDuration ${e.defaultDuration}`).toContain(e.defaultDuration)
|
|
60
|
+
expect(videoDefaultDurationSec(e.id)).toBe(e.defaultDuration)
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it("an unset duration prices the SAME tier as that default sent explicitly (worked examples)", () => {
|
|
36
65
|
for (const nodeType of ["image-to-video", "text-to-video"] as const) {
|
|
66
|
+
expect(buildVideoCreditModelIdentifier("seedance-2", undefined, undefined, nodeType, undefined, "720p")).toBe("seedance-2:8s:720p")
|
|
37
67
|
expect(buildVideoCreditModelIdentifier("seedance-2-5", undefined, undefined, nodeType, undefined, "720p")).toBe(
|
|
38
68
|
buildVideoCreditModelIdentifier("seedance-2-5", 8, undefined, nodeType, undefined, "720p"),
|
|
39
69
|
)
|
|
@@ -41,5 +71,16 @@ describe("pricedOutputDurationSec", () => {
|
|
|
41
71
|
"seedance-2-5:8s:720p-ref",
|
|
42
72
|
)
|
|
43
73
|
}
|
|
74
|
+
expect(buildVideoCreditModelIdentifier("grok-i2v", undefined, undefined, "image-to-video")).toBe("grok-i2v:6s")
|
|
75
|
+
expect(buildVideoCreditModelIdentifier("ltx-2.3-fast", undefined)).toBe("ltx-2.3-fast:1080p:6s")
|
|
76
|
+
expect(buildVideoCreditModelIdentifier("gemini-omni-video", undefined)).toBe("gemini-omni-video:8")
|
|
77
|
+
expect(buildVideoCreditModelIdentifier("gemini-omni-video", 7)).toBe("gemini-omni-video:6")
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it("a snapped length is charged as the tier it renders (worked examples)", () => {
|
|
81
|
+
expect(buildVideoCreditModelIdentifier("kling", 7)).toBe("kling:5s")
|
|
82
|
+
expect(buildVideoCreditModelIdentifier("kling", 8)).toBe("kling:10s")
|
|
83
|
+
expect(buildVideoCreditModelIdentifier("ltx-2.3-pro", 7)).toBe("ltx-2.3-pro:1080p:6s")
|
|
84
|
+
expect(buildVideoCreditModelIdentifier("ltx-2.3-fast", 14, undefined, undefined, undefined, "2k")).toBe("ltx-2.3-fast:2k:10s")
|
|
44
85
|
})
|
|
45
86
|
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest"
|
|
2
|
+
import { isLocalOrPrivateHostname, isPrivateOrReservedIP } from "../private-host.js"
|
|
3
|
+
|
|
4
|
+
describe("isPrivateOrReservedIP", () => {
|
|
5
|
+
it("refuses loopback, private, link-local, CGN, multicast and mapped addresses", () => {
|
|
6
|
+
for (const ip of ["0.0.0.0", "127.0.0.1", "10.1.2.3", "172.16.0.1", "172.31.255.255", "192.168.0.1", "169.254.169.254", "100.64.0.1", "198.18.0.1", "224.0.0.1", "255.255.255.255", "::", "::1", "fe80::1", "fd00::1", "ff02::1", "::ffff:127.0.0.1", "::ffff:7f00:1", "::7f00:1"]) {
|
|
7
|
+
expect(isPrivateOrReservedIP(ip), ip).toBe(true)
|
|
8
|
+
}
|
|
9
|
+
})
|
|
10
|
+
it("passes public addresses", () => {
|
|
11
|
+
for (const ip of ["8.8.8.8", "93.184.216.34", "172.32.0.1", "2606:4700::1"]) expect(isPrivateOrReservedIP(ip), ip).toBe(false)
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
describe("isLocalOrPrivateHostname", () => {
|
|
16
|
+
it("reads a URL hostname the way the server's SSRF schema does", () => {
|
|
17
|
+
for (const host of ["localhost", "LOCALHOST", "localhost.", "app.localhost", "[::1]", "[fe80::1]", "127.0.0.1", "192.168.1.5"]) {
|
|
18
|
+
expect(isLocalOrPrivateHostname(host), host).toBe(true)
|
|
19
|
+
}
|
|
20
|
+
for (const host of ["cdn.example.com", "youtube.com", "93.184.216.34", "[2606:4700::1]", "localhost.example.com", "notlocalhost"]) {
|
|
21
|
+
expect(isLocalOrPrivateHostname(host), host).toBe(false)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
})
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
OWNER_ONLY_LISTING_RENDER_TYPES,
|
|
8
8
|
PREVIEW_RENDER_NODE_TYPES,
|
|
9
9
|
applyEdlCreditId,
|
|
10
|
+
speakerViewCreditId,
|
|
10
11
|
isRenderNodeType,
|
|
11
12
|
renderNodeOf,
|
|
12
13
|
rendersLatestBatch,
|
|
@@ -14,9 +15,27 @@ import {
|
|
|
14
15
|
} from "../index.js"
|
|
15
16
|
|
|
16
17
|
describe("RENDER_NODE_TYPES — one render-node registry (SV18)", () => {
|
|
17
|
-
it("holds Apply EDL
|
|
18
|
-
expect(Object.keys(RENDER_NODE_TYPES)).toEqual(["apply-edl"])
|
|
19
|
-
expect(RENDER_NODE_TYPE_IDS).toEqual(["apply-edl"])
|
|
18
|
+
it("holds Apply EDL and Speaker View", () => {
|
|
19
|
+
expect(Object.keys(RENDER_NODE_TYPES)).toEqual(["apply-edl", "speaker-view"])
|
|
20
|
+
expect(RENDER_NODE_TYPE_IDS).toEqual(["apply-edl", "speaker-view"])
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it("describes Speaker View: video only, mapped through the EDL it emits, a json that is an EDL (C3.2)", () => {
|
|
24
|
+
const d = renderNodeOf("speaker-view")!
|
|
25
|
+
expect(d.clockMapFrom).toBe("output-json")
|
|
26
|
+
expect(d.ownerOnlyListing).toBe(true)
|
|
27
|
+
expect(d.latestBatch).toBe(true)
|
|
28
|
+
expect(d.jsonKind).toBe("edl")
|
|
29
|
+
expect(d.mediumOf({ output: "audio" })).toBe("video")
|
|
30
|
+
expect(d.mediumOf({})).toBe("video")
|
|
31
|
+
expect(rendersTranscriptJson("speaker-view")).toBe(false)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it("prices a Preview on its own row and everything else on the final's", () => {
|
|
35
|
+
const d = renderNodeOf("speaker-view")!
|
|
36
|
+
expect(d.creditId("proxy")).toBe("speaker-view:proxy")
|
|
37
|
+
for (const q of ["final", undefined, null, "", "high", 3]) expect(d.creditId(q)).toBe("speaker-view")
|
|
38
|
+
expect(speakerViewCreditId("proxy")).toBe("speaker-view:proxy")
|
|
20
39
|
})
|
|
21
40
|
|
|
22
41
|
it("describes Apply EDL exactly as its hard-coded sites behaved", () => {
|
|
@@ -57,7 +57,7 @@ describe("speech-model capability sheets — totality", () => {
|
|
|
57
57
|
}
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
-
it("every sheet says whether the model returns timings, and all
|
|
60
|
+
it("every sheet says whether the model returns timings, and all seven speech models do", () => {
|
|
61
61
|
const yes = Object.values(MODEL_CATALOG).filter((m) => m.tts?.timestamps === true).map((m) => m.id).sort()
|
|
62
62
|
for (const m of Object.values(MODEL_CATALOG)) {
|
|
63
63
|
if (!m.tts) continue
|
|
@@ -65,6 +65,7 @@ describe("speech-model capability sheets — totality", () => {
|
|
|
65
65
|
}
|
|
66
66
|
// Measured 2026-10-04 (v4) and 2026-10-06 (the rest): /with-timestamps answers 200 on every
|
|
67
67
|
// speech model at the same character cost. A new model joins this list only once it is measured.
|
|
68
|
+
// v4 Turbo measured 2026-10-07: with-timestamps 200 at equal character-cost.
|
|
68
69
|
expect(yes).toEqual([
|
|
69
70
|
"elevenlabs-dialogue",
|
|
70
71
|
"elevenlabs-dialogue-v4",
|
|
@@ -72,6 +73,7 @@ describe("speech-model capability sheets — totality", () => {
|
|
|
72
73
|
"elevenlabs-turbo",
|
|
73
74
|
"elevenlabs-v3",
|
|
74
75
|
"elevenlabs-v4",
|
|
76
|
+
"elevenlabs-v4-turbo",
|
|
75
77
|
])
|
|
76
78
|
})
|
|
77
79
|
})
|
|
@@ -263,6 +265,64 @@ describe("elevenlabs-v4 — added beside v3", () => {
|
|
|
263
265
|
})
|
|
264
266
|
})
|
|
265
267
|
|
|
268
|
+
describe("elevenlabs-v4-turbo — the fast v4, added beside v4 (decided 2026-10-06)", () => {
|
|
269
|
+
it("is a text-to-speech provider, in the catalog, listed after v3 and before Turbo v2.5", () => {
|
|
270
|
+
expect(TTS_PROVIDERS).toContain("elevenlabs-v4-turbo")
|
|
271
|
+
expect(MODEL_CATALOG["elevenlabs-v4-turbo"]?.modes).toContain("tts")
|
|
272
|
+
const order = TTS_PROVIDERS.filter((id) => ["elevenlabs-v3", "elevenlabs-v4-turbo", "elevenlabs-turbo"].includes(id))
|
|
273
|
+
expect(order).toEqual(["elevenlabs-v3", "elevenlabs-v4-turbo", "elevenlabs-turbo"])
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
it("the sheet: tags, no SSML, stability + similarity, language code, v4's curated 46 languages, the cap", () => {
|
|
277
|
+
const c = getTtsCapabilities("elevenlabs-v4-turbo")
|
|
278
|
+
expect(c.audioTags).toBe(true)
|
|
279
|
+
expect(c.ssmlBreaks).toBe(false)
|
|
280
|
+
expect(c.levers).toEqual(["stability", "similarity"])
|
|
281
|
+
expect(c.languageCode).toBe(true)
|
|
282
|
+
expect(c.languages).toEqual(getTtsCapabilities("elevenlabs-v4").languages)
|
|
283
|
+
expect(c.maxChars).toBe(10000) // measured 2026-10-07: the vendor declares 10,000; live, 10,000 AND 10,001 both returned 200 — the declared (smaller) figure is the clamp
|
|
284
|
+
expect(getMaxTtsChars("elevenlabs-v4-turbo")).toBe(c.maxChars)
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
it("stitching and timestamps are the probe's values, declared, never undefined", () => {
|
|
288
|
+
const c = getTtsCapabilities("elevenlabs-v4-turbo")
|
|
289
|
+
expect(c.stitching).toBe(true) // measured 2026-10-07: neighbour-text 200 at the plain call's character-cost
|
|
290
|
+
expect(c.timestamps).toBe(true) // measured 2026-10-07: with-timestamps 200 at equal character-cost
|
|
291
|
+
expect(ttsSupportsStitching("elevenlabs-v4-turbo")).toBe(c.stitching)
|
|
292
|
+
expect(ttsSupportsTimestamps("elevenlabs-v4-turbo")).toBe(c.timestamps)
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
it("keeps [audio tags], has no SSML breaks, honours similarity but not speed, style or speaker boost", () => {
|
|
296
|
+
expect(ttsSupportsAudioTags("elevenlabs-v4-turbo")).toBe(true)
|
|
297
|
+
expect(ttsSupportsSsmlBreaks("elevenlabs-v4-turbo")).toBe(false)
|
|
298
|
+
expect(ttsHasLever("elevenlabs-v4-turbo", "similarity")).toBe(true)
|
|
299
|
+
for (const lever of ["speed", "style", "speakerBoost"] as const) expect(ttsHasLever("elevenlabs-v4-turbo", lever), lever).toBe(false)
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
it("its flat row is 15 with no note — Turbo v2.5 parity — beside a 2-credit per-100-characters row; it is not featured", () => {
|
|
303
|
+
expect(MODEL_CATALOG["elevenlabs-v4-turbo"]!.pricing).toEqual([
|
|
304
|
+
{ identifier: "elevenlabs-v4-turbo", credits: 15 },
|
|
305
|
+
{ identifier: "elevenlabs-v4-turbo:per-100-chars", credits: 2, note: SPEECH_UNIT_PRICE_NOTE },
|
|
306
|
+
])
|
|
307
|
+
expect(MODEL_CATALOG["elevenlabs-v4-turbo"]!.featured).toBeUndefined()
|
|
308
|
+
expect(MODEL_CATALOG["elevenlabs-turbo"]!.pricing[0]!.credits).toBe(15)
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
it("every existing speech sheet is exactly what it was", () => {
|
|
312
|
+
expect(getTtsCapabilities("elevenlabs-v4").maxChars).toBe(10000)
|
|
313
|
+
expect(getTtsCapabilities("elevenlabs-v3").maxChars).toBe(5000)
|
|
314
|
+
expect(getTtsCapabilities("elevenlabs-turbo").maxChars).toBe(40000)
|
|
315
|
+
expect(getTtsCapabilities("elevenlabs-multilingual").maxChars).toBe(10000)
|
|
316
|
+
expect(TTS_PROVIDERS.filter((id) => id !== "elevenlabs-v4-turbo")).toEqual(["elevenlabs-v3", "elevenlabs-v4", "elevenlabs-turbo", "elevenlabs-multilingual", "elevenlabs"])
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
it("the narration recommendation keeps v4 first and places v4 Turbo after v3, before Turbo v2.5", async () => {
|
|
320
|
+
const { MODEL_RECOMMENDATIONS } = await import("../model-catalog.js")
|
|
321
|
+
const narration = MODEL_RECOMMENDATIONS.find((r) => r.intent === "voice over / narration")
|
|
322
|
+
expect(narration?.modelIds).toEqual(["elevenlabs-v4", "elevenlabs-v3", "elevenlabs-v4-turbo", "elevenlabs-turbo"])
|
|
323
|
+
})
|
|
324
|
+
})
|
|
325
|
+
|
|
266
326
|
describe("ttsSupportsTimestamps", () => {
|
|
267
327
|
it("answers for the model the request runs as", () => {
|
|
268
328
|
expect(ttsSupportsTimestamps("elevenlabs-v4")).toBe(true)
|