@nodaro/shared 3.13.0 → 3.16.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 +1293 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1502 -30
- package/dist/index.d.ts +1502 -30
- package/dist/index.js +1134 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/camera-switch-contract.test.ts +98 -0
- package/src/__tests__/competitors.test.ts +49 -0
- package/src/__tests__/content-recipe-ideas.test.ts +96 -0
- package/src/__tests__/edl-multicam.test.ts +192 -0
- package/src/__tests__/llm-models.test.ts +5 -2
- package/src/__tests__/music-provider.test.ts +17 -0
- package/src/__tests__/node-runtime-keys.test.ts +10 -0
- package/src/__tests__/parameter-node-value.test.ts +2 -1
- package/src/__tests__/per-unit-video-pricing.test.ts +97 -0
- package/src/__tests__/producer-types.test.ts +35 -0
- package/src/__tests__/saved-posts.test.ts +37 -0
- package/src/__tests__/script-settings.test.ts +61 -0
- package/src/__tests__/settings-input.test.ts +252 -0
- package/src/__tests__/social-search.test.ts +243 -0
- package/src/__tests__/studio-take-voice.test.ts +200 -0
- package/src/__tests__/studio-transient.test.ts +37 -0
- package/src/__tests__/sub-gates.test.ts +21 -0
- package/src/__tests__/telegram-account-trigger.test.ts +120 -0
- package/src/__tests__/video-analysis-pricing.test.ts +27 -13
- package/src/__tests__/video-link.test.ts +2 -2
- package/src/__tests__/video-utils.test.ts +89 -83
- package/src/__tests__/workflow-export-strip.test.ts +37 -0
- package/src/camera-switch-contract.ts +166 -0
- package/src/catalog-projection.ts +27 -0
- package/src/competitors.ts +430 -0
- package/src/content-recipe-ideas.ts +69 -0
- package/src/credit-estimators/index.ts +14 -0
- package/src/credit-estimators/ltx-extend.ts +33 -0
- package/src/credit-estimators/ltx-retake.ts +30 -0
- package/src/credit-estimators/video-sfx.ts +41 -0
- package/src/credit-estimators/video-utils.ts +38 -24
- package/src/credit-identifiers.ts +10 -0
- package/src/edl-multicam.ts +220 -0
- package/src/fan-out-rows.ts +7 -2
- package/src/i18n/action-fx.ko.ts +18 -18
- package/src/i18n/action-fx.pt-BR.ts +66 -66
- package/src/i18n/aesthetic.ko.ts +49 -49
- package/src/i18n/aesthetic.pt-BR.ts +14 -14
- package/src/i18n/animals.ko.ts +126 -126
- package/src/i18n/animals.pt-BR.ts +33 -33
- package/src/i18n/atmosphere.ko.ts +37 -37
- package/src/i18n/atmosphere.pt-BR.ts +29 -29
- package/src/i18n/backdrop.ko.ts +40 -40
- package/src/i18n/backdrop.pt-BR.ts +38 -38
- package/src/i18n/camera-format.ko.ts +31 -31
- package/src/i18n/camera-format.pt-BR.ts +12 -12
- package/src/i18n/camera-motions.ko.ts +66 -66
- package/src/i18n/camera-motions.pt-BR.ts +51 -51
- package/src/i18n/character-fx.ko.ts +19 -19
- package/src/i18n/character-fx.pt-BR.ts +64 -52
- package/src/i18n/character-motion.ko.ts +164 -164
- package/src/i18n/character-motion.pt-BR.ts +867 -858
- package/src/i18n/color-look.ko.ts +41 -41
- package/src/i18n/color-look.pt-BR.ts +23 -23
- package/src/i18n/composition-effects.ko.ts +18 -18
- package/src/i18n/composition-effects.pt-BR.ts +17 -17
- package/src/i18n/era.ko.ts +28 -28
- package/src/i18n/era.pt-BR.ts +20 -20
- package/src/i18n/exposure-settings.ko.ts +20 -20
- package/src/i18n/exposure-settings.pt-BR.ts +3 -3
- package/src/i18n/framing.ko.ts +66 -66
- package/src/i18n/framing.pt-BR.ts +50 -50
- package/src/i18n/furniture.ko.ts +78 -78
- package/src/i18n/furniture.pt-BR.ts +46 -46
- package/src/i18n/held-prop.ko.ts +60 -60
- package/src/i18n/held-prop.pt-BR.ts +30 -30
- package/src/i18n/instrumentation.ko.ts +62 -62
- package/src/i18n/instrumentation.pt-BR.ts +64 -64
- package/src/i18n/lens.ko.ts +16 -16
- package/src/i18n/lens.pt-BR.ts +5 -5
- package/src/i18n/lighting.ko.ts +68 -68
- package/src/i18n/lighting.pt-BR.ts +43 -43
- package/src/i18n/loop-subject.ko.ts +1 -1
- package/src/i18n/loop-subject.pt-BR.ts +31 -31
- package/src/i18n/materials.ko.ts +66 -66
- package/src/i18n/materials.pt-BR.ts +22 -22
- package/src/i18n/mood.ko.ts +50 -50
- package/src/i18n/mood.pt-BR.ts +12 -12
- package/src/i18n/music-genre.ko.ts +28 -28
- package/src/i18n/music-genre.pt-BR.ts +50 -50
- package/src/i18n/music-mood.ko.ts +27 -27
- package/src/i18n/music-mood.pt-BR.ts +20 -20
- package/src/i18n/person.ko.ts +396 -396
- package/src/i18n/person.pt-BR.ts +237 -237
- package/src/i18n/photo-genre.ko.ts +46 -46
- package/src/i18n/photo-genre.pt-BR.ts +32 -32
- package/src/i18n/photographer.ko.ts +63 -63
- package/src/i18n/photographer.pt-BR.ts +15 -15
- package/src/i18n/pose.ko.ts +81 -81
- package/src/i18n/pose.pt-BR.ts +65 -65
- package/src/i18n/post-process-effects.ko.ts +18 -18
- package/src/i18n/post-process-effects.pt-BR.ts +18 -18
- package/src/i18n/render-quality.ko.ts +24 -24
- package/src/i18n/render-quality.pt-BR.ts +12 -12
- package/src/i18n/setting.ko.ts +64 -64
- package/src/i18n/setting.pt-BR.ts +41 -41
- package/src/i18n/style.ko.ts +49 -49
- package/src/i18n/style.pt-BR.ts +19 -19
- package/src/i18n/styling.ko.ts +265 -265
- package/src/i18n/styling.pt-BR.ts +141 -141
- package/src/i18n/temporal.ko.ts +18 -18
- package/src/i18n/temporal.pt-BR.ts +12 -12
- package/src/i18n/transitions.ko.ts +14 -14
- package/src/i18n/transitions.pt-BR.ts +83 -71
- package/src/i18n/vehicles.ko.ts +107 -107
- package/src/i18n/vehicles.pt-BR.ts +55 -55
- package/src/i18n/voice-character.ko.ts +19 -19
- package/src/i18n/voice-character.pt-BR.ts +19 -19
- package/src/i18n/voice-delivery.ko.ts +22 -22
- package/src/i18n/voice-delivery.pt-BR.ts +22 -22
- package/src/i18n/weapons.ko.ts +85 -85
- package/src/i18n/weapons.pt-BR.ts +46 -46
- package/src/index.ts +202 -1
- package/src/llm-models.ts +11 -0
- package/src/model-catalog.ts +30 -14
- package/src/model-constants.ts +28 -0
- package/src/node-mappable-fields.ts +21 -5
- package/src/node-runtime-keys.ts +33 -0
- package/src/oauth-scopes.ts +28 -0
- package/src/parameter-node-value.ts +13 -5
- package/src/pipeline-defaults.ts +14 -0
- package/src/pipeline-state-types.ts +14 -0
- package/src/producer-types.ts +85 -0
- package/src/recast-segment-packs.ts +13 -0
- package/src/resolve-field-mappings.ts +15 -5
- package/src/saved-posts.ts +106 -0
- package/src/script-settings.ts +70 -0
- package/src/settings-input.ts +366 -0
- package/src/social-search.ts +467 -0
- package/src/studio-transient.ts +176 -5
- package/src/telegram-account-send.ts +32 -0
- package/src/telegram-account-trigger.ts +108 -0
- package/src/video-analysis-pricing.ts +17 -6
- package/src/video-link.ts +16 -4
- package/src/workflow-export.ts +7 -0
package/package.json
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
CAMERA_SWITCH_BOUNDS, CAMERA_SWITCH_DEFAULTS, CAMERA_SWITCH_NAME_MAX, cameraSwitchCameras, cameraSwitchEdlProblem,
|
|
4
|
+
cameraSwitchSettingsPayload, clampCameraSwitchSetting, cleanSpeakerNames, defaultSpeakerMap, transcriptSpeakerLabels,
|
|
5
|
+
} from "../camera-switch-contract.js"
|
|
6
|
+
|
|
7
|
+
// camera-switch (B5, decided 2026-10-03): the shared reads every caller makes.
|
|
8
|
+
|
|
9
|
+
describe("transcriptSpeakerLabels", () => {
|
|
10
|
+
const t = { version: 1, words: [{ text: "a", startMs: 0, endMs: 1, speaker: "speaker_1" }, { text: "b", startMs: 1, endMs: 2 }, { text: "c", startMs: 2, endMs: 3, speaker: "speaker_0" }, { text: "d", startMs: 3, endMs: 4, speaker: "speaker_1" }] }
|
|
11
|
+
it("distinct labels in order of first appearance, from an object or its JSON string", () => {
|
|
12
|
+
expect(transcriptSpeakerLabels(t)).toEqual(["speaker_1", "speaker_0"])
|
|
13
|
+
expect(transcriptSpeakerLabels(JSON.stringify(t))).toEqual(["speaker_1", "speaker_0"])
|
|
14
|
+
})
|
|
15
|
+
it("none for an undiarized transcript or anything that is not one", () => {
|
|
16
|
+
expect(transcriptSpeakerLabels({ words: [{ text: "a", startMs: 0, endMs: 1 }] })).toEqual([])
|
|
17
|
+
for (const bad of [undefined, null, "nope", 4, { words: "x" }]) expect(transcriptSpeakerLabels(bad)).toEqual([])
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe("cameraSwitchCameras", () => {
|
|
22
|
+
it("an EDL's video sources in order — never the mic, the wide or the screen", () => {
|
|
23
|
+
const edl = { sources: [
|
|
24
|
+
{ id: "mic", kind: "audio", role: "master-audio" }, { id: "camA", kind: "video" }, { id: "wide", kind: "video", role: "wide" },
|
|
25
|
+
{ id: "camB", kind: "video", role: "camera" }, { id: "screen", kind: "video", role: "screen" },
|
|
26
|
+
] }
|
|
27
|
+
expect(cameraSwitchCameras(edl).map((c) => c.id)).toEqual(["camA", "camB"])
|
|
28
|
+
expect(cameraSwitchCameras(JSON.stringify(edl)).map((c) => c.id)).toEqual(["camA", "camB"])
|
|
29
|
+
expect(cameraSwitchCameras(undefined)).toEqual([])
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
describe("defaultSpeakerMap — the table pre-filled by order (decided 2026-10-03)", () => {
|
|
34
|
+
it("speaker 1 → camera 1, speaker 2 → camera 2; past the last camera a speaker stays unmapped", () => {
|
|
35
|
+
expect(defaultSpeakerMap(["s0", "s1", "s2"], ["camA", "camB"])).toEqual({ s0: "camA", s1: "camB" })
|
|
36
|
+
})
|
|
37
|
+
it("keeps what the person set — and an explicit \"\" (no camera of their own) is SENT, so it beats sources[].speakers", () => {
|
|
38
|
+
expect(defaultSpeakerMap(["s0", "s1"], ["camA", "camB"], { s0: "camB" })).toEqual({ s0: "camB", s1: "camB" })
|
|
39
|
+
expect(defaultSpeakerMap(["s0", "s1"], ["camA", "camB"], { s0: "" })).toStrictEqual({ s0: "", s1: "camB" })
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it("the defaults are the decided ones", () => {
|
|
44
|
+
expect(CAMERA_SWITCH_DEFAULTS).toEqual({ minShotMs: 2_500, leadMs: 200, maxShotMs: 20_000, wideEvery: 0, layoutHints: false })
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// The Cloud route answers 400 outside these ranges — every caller clamps first
|
|
48
|
+
// (review of #1749: the panel accepted a 0 s shortest shot).
|
|
49
|
+
describe("settings bounds", () => {
|
|
50
|
+
it("are the route's ranges", () => {
|
|
51
|
+
expect(CAMERA_SWITCH_BOUNDS).toEqual({
|
|
52
|
+
minShotMs: { min: 500, max: 60_000 }, leadMs: { min: 0, max: 5_000 }, maxShotMs: { min: 0, max: 600_000 }, wideEvery: { min: 0, max: 20 },
|
|
53
|
+
})
|
|
54
|
+
expect(CAMERA_SWITCH_NAME_MAX).toBe(80)
|
|
55
|
+
})
|
|
56
|
+
it("clamp into range as whole numbers; unset stays unset", () => {
|
|
57
|
+
expect(clampCameraSwitchSetting("minShotMs", 0)).toBe(500)
|
|
58
|
+
expect(clampCameraSwitchSetting("minShotMs", 2_499.6)).toBe(2_500)
|
|
59
|
+
expect(clampCameraSwitchSetting("leadMs", 9_000)).toBe(5_000)
|
|
60
|
+
expect(clampCameraSwitchSetting("wideEvery", -3)).toBe(0)
|
|
61
|
+
for (const v of [undefined, null, "300", Number.NaN]) expect(clampCameraSwitchSetting("leadMs", v)).toBeUndefined()
|
|
62
|
+
})
|
|
63
|
+
it("names are trimmed, cut to the limit, and empty ones dropped", () => {
|
|
64
|
+
expect(cleanSpeakerNames({ s0: " Dana ", s1: " ", s2: "x".repeat(100), s3: 4 })).toEqual({ s0: "Dana", s2: "x".repeat(80) })
|
|
65
|
+
expect(cleanSpeakerNames(undefined)).toEqual({})
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe("cameraSwitchEdlProblem — the route's 400 invalid_edl, before anything is reserved", () => {
|
|
70
|
+
const edl = { version: 1, clock: "master", sources: [{ id: "camA", kind: "video" }], segments: [{ id: "s", inMs: 0, outMs: 1_000 }] }
|
|
71
|
+
it("accepts one master-clock edit, as an object or its JSON string", () => {
|
|
72
|
+
expect(cameraSwitchEdlProblem(edl)).toBeNull()
|
|
73
|
+
expect(cameraSwitchEdlProblem(JSON.stringify(edl))).toBeNull()
|
|
74
|
+
})
|
|
75
|
+
it("refuses a clip set, a chapters plan, an output-clock edit, no segments, a bad segment", () => {
|
|
76
|
+
expect(cameraSwitchEdlProblem({ clips: [edl] })).toMatch(/clip set/)
|
|
77
|
+
expect(cameraSwitchEdlProblem([edl])).toMatch(/one edit/)
|
|
78
|
+
expect(cameraSwitchEdlProblem({ version: 1, chapters: [] })).toMatch(/needs `sources` and `segments`/)
|
|
79
|
+
expect(cameraSwitchEdlProblem({ ...edl, clock: "output" })).toMatch(/master clock/)
|
|
80
|
+
expect(cameraSwitchEdlProblem({ ...edl, segments: [] })).toMatch(/no segments/)
|
|
81
|
+
expect(cameraSwitchEdlProblem({ ...edl, segments: [{ inMs: 5, outMs: 5 }] })).toMatch(/segment 0/)
|
|
82
|
+
expect(cameraSwitchEdlProblem("{nope")).toMatch(/one edit/)
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
describe("cameraSwitchSettingsPayload — one funnel for both engines", () => {
|
|
87
|
+
const edl = { sources: [{ id: "mic", kind: "audio", role: "master-audio" }, { id: "camA", kind: "video" }, { id: "camB", kind: "video" }], segments: [] }
|
|
88
|
+
const transcript = { words: [{ text: "a", startMs: 0, endMs: 1, speaker: "s0" }, { text: "b", startMs: 1, endMs: 2, speaker: "s1" }] }
|
|
89
|
+
it("pre-fills the table, keeps \"\", cleans names, clamps settings, leaves unset settings out", () => {
|
|
90
|
+
expect(cameraSwitchSettingsPayload({ speakerMap: { s1: "" }, speakerNames: { s0: " Dana " }, minShotMs: 100, leadMs: 300 }, edl, transcript)).toStrictEqual({
|
|
91
|
+
speakerMap: { s0: "camA", s1: "" },
|
|
92
|
+
speakerNames: { s0: "Dana" },
|
|
93
|
+
layoutHints: false,
|
|
94
|
+
minShotMs: 500,
|
|
95
|
+
leadMs: 300,
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
COMPETITOR_SCAN_CREDIT_COSTS,
|
|
4
|
+
COMPETITOR_SCAN_MAX_SEARCHES,
|
|
5
|
+
SOCIAL_SEARCH_CREDITS_PER_PAGE,
|
|
6
|
+
competitorScanCreditId,
|
|
7
|
+
competitorScanCredits,
|
|
8
|
+
competitorScanSearches,
|
|
9
|
+
} from "../index.js"
|
|
10
|
+
|
|
11
|
+
describe("competitor scan pricing", () => {
|
|
12
|
+
it("counts one search per filled account and per about-platform", () => {
|
|
13
|
+
expect(competitorScanSearches({ accounts: { tiktok: "acme", x: " ", instagram: "" }, aboutPlatforms: ["reddit", "x", "myspace"] })).toBe(3)
|
|
14
|
+
expect(competitorScanSearches({})).toBe(0)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it("prices a scan as one Social Search page per search", () => {
|
|
18
|
+
expect(Object.keys(COMPETITOR_SCAN_CREDIT_COSTS)).toHaveLength(COMPETITOR_SCAN_MAX_SEARCHES)
|
|
19
|
+
expect(COMPETITOR_SCAN_CREDIT_COSTS["competitor-scan:3"]).toBe(3 * SOCIAL_SEARCH_CREDITS_PER_PAGE)
|
|
20
|
+
expect(competitorScanCredits(4)).toBe(4 * SOCIAL_SEARCH_CREDITS_PER_PAGE)
|
|
21
|
+
expect(competitorScanCredits(0)).toBe(0)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it("keeps the credit id inside the priced range", () => {
|
|
25
|
+
expect(competitorScanCreditId(0)).toBe("competitor-scan:1")
|
|
26
|
+
expect(competitorScanCreditId(99)).toBe(`competitor-scan:${COMPETITOR_SCAN_MAX_SEARCHES}`)
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
describe("did it work", () => {
|
|
31
|
+
it("offers \"I did this\" only on cards whose advice ends in a post of one's own", async () => {
|
|
32
|
+
const { isMeasurableCard, adviceFamilyOf, ACTION_CARD_KINDS, ADVICE_FAMILIES } = await import("../index.js")
|
|
33
|
+
const card = (kind: (typeof ACTION_CARD_KINDS)[number], own = false) => ({ kind, params: { own } })
|
|
34
|
+
expect(isMeasurableCard(card("outlier"))).toBe(true)
|
|
35
|
+
expect(isMeasurableCard(card("outlier", true))).toBe(true)
|
|
36
|
+
expect(isMeasurableCard(card("sound"))).toBe(true)
|
|
37
|
+
expect(isMeasurableCard(card("market_sound"))).toBe(true)
|
|
38
|
+
expect(isMeasurableCard(card("launch"))).toBe(true)
|
|
39
|
+
expect(isMeasurableCard(card("complaints"))).toBe(true)
|
|
40
|
+
expect(isMeasurableCard(card("complaints", true))).toBe(false)
|
|
41
|
+
for (const kind of ["spreading", "mentions_up", "pace", "top_in_sources"] as const) expect(isMeasurableCard(card(kind))).toBe(false)
|
|
42
|
+
expect(adviceFamilyOf("market_sound")).toBe("sound")
|
|
43
|
+
// Every measurable kind belongs to a family the record can name.
|
|
44
|
+
for (const kind of ACTION_CARD_KINDS) {
|
|
45
|
+
const family = adviceFamilyOf(kind)
|
|
46
|
+
if (family) expect(ADVICE_FAMILIES).toContain(family)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
})
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
clampContentIdeasCount,
|
|
4
|
+
contentIdeasCreditFeature,
|
|
5
|
+
contentIdeasCreditId,
|
|
6
|
+
contentRecipeCreditId,
|
|
7
|
+
CONTENT_RECIPE_IDEAS_CREDIT_IDS,
|
|
8
|
+
effectiveContentModel,
|
|
9
|
+
} from "../content-recipe-ideas.js"
|
|
10
|
+
import { FAN_IN_TARGETS, FAN_OUT_EACH_TYPES, isFanInEdge, isFanInNodeType } from "../producer-types.js"
|
|
11
|
+
import { LLM_FEATURE_DEFAULTS } from "../llm-models.js"
|
|
12
|
+
import { videoLinkPageUrl } from "../video-link.js"
|
|
13
|
+
|
|
14
|
+
describe("content recipe / ideas pricing", () => {
|
|
15
|
+
it("bills the EFFECTIVE model's tier — an unset model is the economy default, never the bare id", () => {
|
|
16
|
+
expect(LLM_FEATURE_DEFAULTS["content-recipe"]).toBe("gemini-3.6-flash")
|
|
17
|
+
expect(LLM_FEATURE_DEFAULTS["content-ideas"]).toBe("gemini-3.6-flash")
|
|
18
|
+
expect(contentRecipeCreditId()).toBe("content-recipe:economy")
|
|
19
|
+
expect(contentRecipeCreditId("claude-sonnet-4.6")).toBe("content-recipe")
|
|
20
|
+
expect(contentRecipeCreditId("claude-opus-5")).toBe("content-recipe:premium")
|
|
21
|
+
expect(contentIdeasCreditId(undefined)).toBe("content-ideas:economy")
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it("a model without structured output falls back to the default", () => {
|
|
25
|
+
expect(effectiveContentModel("content-ideas", "gpt-5.2")).toBe("gemini-3.6-flash")
|
|
26
|
+
expect(effectiveContentModel("content-ideas", "no-such-model")).toBe("gemini-3.6-flash")
|
|
27
|
+
expect(effectiveContentModel("content-ideas", "claude-opus-5")).toBe("claude-opus-5")
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it("ideas are charged per batch of five", () => {
|
|
31
|
+
expect(contentIdeasCreditFeature(5)).toBe("content-ideas")
|
|
32
|
+
expect(contentIdeasCreditFeature(6)).toBe("content-ideas:10")
|
|
33
|
+
expect(contentIdeasCreditId(5, "claude-sonnet-4.6")).toBe("content-ideas")
|
|
34
|
+
expect(contentIdeasCreditId(6, "claude-sonnet-4.6")).toBe("content-ideas:10")
|
|
35
|
+
expect(contentIdeasCreditId(10)).toBe("content-ideas:10:economy")
|
|
36
|
+
expect(contentIdeasCreditId(10, "claude-opus-5")).toBe("content-ideas:10:premium")
|
|
37
|
+
// an xhigh/max effort bumps one tier, as for every LLM node
|
|
38
|
+
expect(contentIdeasCreditId(3, "claude-sonnet-4.6", "max")).toBe("content-ideas:premium")
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it("count: numbers only, clamped to 1..10", () => {
|
|
42
|
+
expect(clampContentIdeasCount(undefined)).toBe(5)
|
|
43
|
+
expect(clampContentIdeasCount("8")).toBe(5)
|
|
44
|
+
expect(clampContentIdeasCount(0)).toBe(1)
|
|
45
|
+
expect(clampContentIdeasCount(42)).toBe(10)
|
|
46
|
+
expect(clampContentIdeasCount(6.9)).toBe(6)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it("every id a run can bill is listed", () => {
|
|
50
|
+
const reachable = new Set<string>()
|
|
51
|
+
for (const model of [undefined, "claude-sonnet-4.6", "claude-opus-5"]) {
|
|
52
|
+
reachable.add(contentRecipeCreditId(model))
|
|
53
|
+
for (const count of [1, 5, 6, 10]) reachable.add(contentIdeasCreditId(count, model))
|
|
54
|
+
}
|
|
55
|
+
expect([...reachable].sort()).toEqual([...CONTENT_RECIPE_IDEAS_CREDIT_IDS].sort())
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
describe("fan-in / fan-out vocabulary", () => {
|
|
60
|
+
it("Content Ideas emits a list (each) and folds only its recipes", () => {
|
|
61
|
+
expect(FAN_OUT_EACH_TYPES.has("content-ideas")).toBe(true)
|
|
62
|
+
expect(isFanInNodeType("content-ideas")).toBe(true)
|
|
63
|
+
expect(isFanInEdge("content-ideas", "recipes")).toBe(true)
|
|
64
|
+
expect(isFanInEdge("content-ideas", undefined)).toBe(true) // agent-written JSON omits the handle
|
|
65
|
+
expect(isFanInEdge("content-ideas", null)).toBe(true)
|
|
66
|
+
expect(isFanInEdge("content-ideas", "field-brand")).toBe(false)
|
|
67
|
+
expect(isFanInEdge("content-ideas", "field-language")).toBe(false)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it("Choose Best still folds every wire, whatever its handle", () => {
|
|
71
|
+
expect(FAN_IN_TARGETS.reduce).toBe("*")
|
|
72
|
+
for (const handle of [undefined, null, "", "in", "inputs", "anything"]) {
|
|
73
|
+
expect(isFanInEdge("reduce", handle)).toBe(true)
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it("other nodes never fold", () => {
|
|
78
|
+
expect(isFanInNodeType("llm-chat")).toBe(false)
|
|
79
|
+
expect(isFanInNodeType("constructor")).toBe(false) // no prototype leak
|
|
80
|
+
expect(isFanInEdge("generate-script", "prompt")).toBe(false)
|
|
81
|
+
expect(isFanInNodeType(undefined)).toBe(false)
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
describe("videoLinkPageUrl", () => {
|
|
86
|
+
it("is the page link, never the downloaded file", () => {
|
|
87
|
+
expect(
|
|
88
|
+
videoLinkPageUrl({
|
|
89
|
+
youtubeUrl: " https://www.tiktok.com/@a/video/1 ",
|
|
90
|
+
downloadedVideoUrl: "https://r2.example/videos/x.mp4",
|
|
91
|
+
}),
|
|
92
|
+
).toBe("https://www.tiktok.com/@a/video/1")
|
|
93
|
+
expect(videoLinkPageUrl({ youtubeUrl: " " })).toBeUndefined()
|
|
94
|
+
expect(videoLinkPageUrl({})).toBeUndefined()
|
|
95
|
+
})
|
|
96
|
+
})
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest"
|
|
2
2
|
import { remapMsThroughEdl, type Edl, type EdlRegion, type EdlSegment } from "../edl.js"
|
|
3
3
|
import {
|
|
4
|
+
AUDIO_SYNC_MIN_CONFIDENCE,
|
|
4
5
|
EDL_FULL_FRAME,
|
|
6
|
+
applyAudioSyncOffsets,
|
|
7
|
+
describeAudioSyncOffsetIssue,
|
|
8
|
+
editPlanTranscriptOrigin,
|
|
5
9
|
mergeEdlSourceOffsets,
|
|
10
|
+
resolveEditPlanSources,
|
|
6
11
|
resolveEdlSegmentSlots,
|
|
7
12
|
type ResolveEdlSlotsOptions,
|
|
8
13
|
} from "../edl-multicam.js"
|
|
@@ -302,3 +307,190 @@ describe("mergeEdlSourceOffsets — anchored rebase", () => {
|
|
|
302
307
|
expect(() => mergeEdlSourceOffsets(podcast(), null as unknown as Record<string, number>)).not.toThrow()
|
|
303
308
|
})
|
|
304
309
|
})
|
|
310
|
+
|
|
311
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
312
|
+
// applyAudioSyncOffsets — B4 (decided 2026-09-25)
|
|
313
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
314
|
+
|
|
315
|
+
describe("applyAudioSyncOffsets — audio-sync offsets onto a planner's sources (B4)", () => {
|
|
316
|
+
const MIC = { id: "mic", url: "https://x/mic.wav", kind: "audio", role: "master-audio" }
|
|
317
|
+
const CAM_A = { id: "cam-a", url: "https://x/a.mp4", kind: "video" }
|
|
318
|
+
const CAM_B = { id: "cam-b", url: "https://x/b.mp4", kind: "video" }
|
|
319
|
+
const row = (sourceId: string, offsetMs: number, confidence = 0.9) => ({ sourceId, offsetMs, confidence, driftMsPerHour: 0 })
|
|
320
|
+
/** audio-sync's result with the mic as the reference: camera A started 2 s
|
|
321
|
+
* after the mic (referenceMs = camMs + 2000), camera B 0.5 s after A. */
|
|
322
|
+
const byMic = { version: 1, reference: "mic", offsets: [row("mic", 0, 1), row("cam-a", 2_000), row("cam-b", 2_500)], notes: [] }
|
|
323
|
+
const offsetsOf = (r: ReturnType<typeof applyAudioSyncOffsets>) => (r.ok ? Object.fromEntries(r.sources.map((s) => [s.id, (s as { offsetMs?: number }).offsetMs])) : r.issues)
|
|
324
|
+
|
|
325
|
+
it("writes each camera's offset on the master's clock (masterMs = sourceMs + offsetMs) and leaves the master at its own clock", () => {
|
|
326
|
+
const r = applyAudioSyncOffsets([MIC, CAM_A, CAM_B], byMic)
|
|
327
|
+
expect(offsetsOf(r)).toEqual({ mic: undefined, "cam-a": 2_000, "cam-b": 2_500 })
|
|
328
|
+
expect(r).toMatchObject({ ok: true, anchor: "mic", applied: ["cam-a", "cam-b"] })
|
|
329
|
+
})
|
|
330
|
+
|
|
331
|
+
it("rebases onto the master when audio-sync's reference was a camera — the same instants, the same offsets", () => {
|
|
332
|
+
// Same recordings measured against camera A: the mic started 2 s BEFORE A
|
|
333
|
+
// (camAms = micMs − 2000 → offset(mic) = −2000), B 0.5 s after A.
|
|
334
|
+
const byCamA = { version: 1, reference: "cam-a", offsets: [row("mic", -2_000), row("cam-a", 0, 1), row("cam-b", 500)], notes: [] }
|
|
335
|
+
expect(offsetsOf(applyAudioSyncOffsets([MIC, CAM_A, CAM_B], byCamA))).toEqual({ mic: undefined, "cam-a": 2_000, "cam-b": 2_500 })
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
it("accepts the JSON string a canvas handle carries", () => {
|
|
339
|
+
expect(offsetsOf(applyAudioSyncOffsets([MIC, CAM_A], JSON.stringify(byMic)))).toEqual({ mic: undefined, "cam-a": 2_000 })
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
it("anchors on edit-plan's own rule: the master-audio source wherever it sits, else the first source", () => {
|
|
343
|
+
expect(applyAudioSyncOffsets([CAM_A, MIC], byMic)).toMatchObject({ ok: true, anchor: "mic" })
|
|
344
|
+
const noRole = [{ ...CAM_A }, { ...MIC, role: undefined }]
|
|
345
|
+
const r = applyAudioSyncOffsets(noRole, byMic)
|
|
346
|
+
expect(r).toMatchObject({ ok: true, anchor: "cam-a" })
|
|
347
|
+
expect(offsetsOf(r)).toEqual({ "cam-a": undefined, mic: -2_000 })
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
it("a hand-set offset always wins over the measured one — including a hand-set 0", () => {
|
|
351
|
+
expect(offsetsOf(applyAudioSyncOffsets([MIC, { ...CAM_A, offsetMs: 1_234 }, { ...CAM_B, offsetMs: 0 }], byMic)))
|
|
352
|
+
.toEqual({ mic: undefined, "cam-a": 1_234, "cam-b": 0 })
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
it("is idempotent: applying the result again changes nothing", () => {
|
|
356
|
+
const once = applyAudioSyncOffsets([MIC, CAM_A, CAM_B], byMic)
|
|
357
|
+
expect(once.ok).toBe(true)
|
|
358
|
+
if (once.ok) expect(offsetsOf(applyAudioSyncOffsets(once.sources, byMic))).toEqual(offsetsOf(once))
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
it("ignores rows for sources the planner does not have", () => {
|
|
362
|
+
const extra = { ...byMic, offsets: [...byMic.offsets, row("lav-2", 900)] }
|
|
363
|
+
expect(offsetsOf(applyAudioSyncOffsets([MIC, CAM_A], extra))).toEqual({ mic: undefined, "cam-a": 2_000 })
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
it("a weak match fails, naming the source and its confidence — unless its offset is hand-set", () => {
|
|
367
|
+
const weak = { ...byMic, offsets: [row("mic", 0, 1), row("cam-a", 2_000, 0.49), row("cam-b", 2_500)] }
|
|
368
|
+
expect(applyAudioSyncOffsets([MIC, CAM_A, CAM_B], weak)).toEqual({ ok: false, issues: [{ code: "weak-match", sourceId: "cam-a", confidence: 0.49, anchor: false }] })
|
|
369
|
+
expect(applyAudioSyncOffsets([MIC, { ...CAM_A, offsetMs: 1_900 }, CAM_B], weak).ok).toBe(true)
|
|
370
|
+
// Exactly the threshold is trusted.
|
|
371
|
+
const edge = { ...byMic, offsets: [row("mic", 0, 1), row("cam-a", 2_000, AUDIO_SYNC_MIN_CONFIDENCE)] }
|
|
372
|
+
expect(applyAudioSyncOffsets([MIC, CAM_A], edge).ok).toBe(true)
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
it("a source audio-sync could not hear (its row at confidence 0) is a weak match", () => {
|
|
376
|
+
const silent = { ...byMic, offsets: [row("mic", 0, 1), row("cam-a", 0, 0)] }
|
|
377
|
+
expect(applyAudioSyncOffsets([MIC, CAM_A], silent)).toMatchObject({ ok: false, issues: [{ code: "weak-match", sourceId: "cam-a", confidence: 0 }] })
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
it("a camera audio-sync did not measure fails — unless its offset is hand-set", () => {
|
|
381
|
+
const partial = { ...byMic, offsets: [row("mic", 0, 1), row("cam-a", 2_000)] }
|
|
382
|
+
expect(applyAudioSyncOffsets([MIC, CAM_A, CAM_B], partial)).toEqual({ ok: false, issues: [{ code: "unmeasured", sourceId: "cam-b" }] })
|
|
383
|
+
expect(applyAudioSyncOffsets([MIC, CAM_A, { ...CAM_B, offsetMs: 0 }], partial).ok).toBe(true)
|
|
384
|
+
})
|
|
385
|
+
|
|
386
|
+
it("the master must be measured when a camera takes a measured offset — else every offset is on the wrong clock", () => {
|
|
387
|
+
const withoutMic = { version: 1, reference: "cam-a", offsets: [row("cam-a", 0, 1), row("cam-b", 500)], notes: [] }
|
|
388
|
+
expect(applyAudioSyncOffsets([MIC, CAM_A, CAM_B], withoutMic)).toEqual({ ok: false, issues: [{ code: "anchor-unmeasured", sourceId: "mic" }] })
|
|
389
|
+
// Every camera hand-set → the master's measurement is not needed.
|
|
390
|
+
expect(applyAudioSyncOffsets([MIC, { ...CAM_A, offsetMs: 2_000 }, { ...CAM_B, offsetMs: 2_500 }], withoutMic).ok).toBe(true)
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
it("a weakly-measured master fails, flagged as the master", () => {
|
|
394
|
+
const weakMic = { version: 1, reference: "cam-a", offsets: [row("mic", -2_000, 0.3), row("cam-a", 0, 1), row("cam-b", 500)], notes: [] }
|
|
395
|
+
expect(applyAudioSyncOffsets([MIC, CAM_A, CAM_B], weakMic)).toEqual({ ok: false, issues: [{ code: "weak-match", sourceId: "mic", confidence: 0.3, anchor: true }] })
|
|
396
|
+
})
|
|
397
|
+
|
|
398
|
+
it("a hand-set non-zero offset on the master fails (the plan follows its clock); a hand-set 0 is fine", () => {
|
|
399
|
+
expect(applyAudioSyncOffsets([{ ...MIC, offsetMs: 40 }, CAM_A], byMic)).toMatchObject({ ok: false, issues: [{ code: "anchor-offset", sourceId: "mic", offsetMs: 40 }] })
|
|
400
|
+
expect(applyAudioSyncOffsets([{ ...MIC, offsetMs: 0 }, CAM_A], byMic).ok).toBe(true)
|
|
401
|
+
})
|
|
402
|
+
|
|
403
|
+
it("reports every issue at once", () => {
|
|
404
|
+
const r = applyAudioSyncOffsets([MIC, CAM_A, CAM_B], { ...byMic, offsets: [row("mic", 0, 1), row("cam-a", 2_000, 0.1)] })
|
|
405
|
+
expect(r).toEqual({ ok: false, issues: [{ code: "weak-match", sourceId: "cam-a", confidence: 0.1, anchor: false }, { code: "unmeasured", sourceId: "cam-b" }] })
|
|
406
|
+
})
|
|
407
|
+
|
|
408
|
+
it("refuses anything that is not an audio-sync result, and never throws", () => {
|
|
409
|
+
for (const bad of [null, 42, "not json", "{}", { offsets: "x" }, { offsets: [{ sourceId: "a" }] }, { offsets: [null] }]) {
|
|
410
|
+
expect(applyAudioSyncOffsets([MIC, CAM_A], bad)).toEqual({ ok: false, issues: [{ code: "not-audio-sync" }] })
|
|
411
|
+
}
|
|
412
|
+
expect(() => applyAudioSyncOffsets(null as never, byMic)).not.toThrow()
|
|
413
|
+
expect(applyAudioSyncOffsets([], byMic)).toEqual({ ok: true, sources: [], applied: [] })
|
|
414
|
+
})
|
|
415
|
+
|
|
416
|
+
it("names the source with the caller's label in every message", () => {
|
|
417
|
+
const label = (id: string) => ({ mic: "Zoom H6", "cam-b": "Wide camera" })[id] ?? id
|
|
418
|
+
expect(describeAudioSyncOffsetIssue({ code: "unmeasured", sourceId: "cam-b" }, label)).toMatch(/"Wide camera" was not measured by audio-sync — wire it into audio-sync, or set its offset by hand/)
|
|
419
|
+
expect(describeAudioSyncOffsetIssue({ code: "weak-match", sourceId: "cam-b", confidence: 0.31, anchor: false }, label)).toMatch(/"Wide camera" is too weak to trust \(confidence 0.31; 0.5 needed\) — set its offset by hand/)
|
|
420
|
+
expect(describeAudioSyncOffsetIssue({ code: "anchor-unmeasured", sourceId: "mic" }, label)).toMatch(/did not measure "Zoom H6", the master/)
|
|
421
|
+
expect(describeAudioSyncOffsetIssue({ code: "anchor-offset", sourceId: "mic", offsetMs: 40 }, label)).toMatch(/"Zoom H6" is the master .* must be 0, not 40 ms/)
|
|
422
|
+
})
|
|
423
|
+
})
|
|
424
|
+
|
|
425
|
+
describe("resolveEditPlanSources — the one pre-dispatch check (B4)", () => {
|
|
426
|
+
const MIC = { id: "mic", role: "master-audio" }
|
|
427
|
+
const CAM_A = { id: "cam-a" }
|
|
428
|
+
const CAM_B = { id: "cam-b" }
|
|
429
|
+
const row = (sourceId: string, offsetMs: number, confidence = 0.9) => ({ sourceId, offsetMs, confidence })
|
|
430
|
+
const byMic = { reference: "mic", offsets: [row("mic", 0, 1), row("cam-a", 2_000), row("cam-b", 2_500)] }
|
|
431
|
+
|
|
432
|
+
it("without offsets, passes the sources through untouched (today's behaviour)", () => {
|
|
433
|
+
expect(resolveEditPlanSources([MIC, { ...CAM_A, offsetMs: 300 }])).toEqual({ ok: true, sources: [MIC, { ...CAM_A, offsetMs: 300 }] })
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
it("wired offsets are applied; wired-but-empty (null / \"\") fails rather than planning unsynced", () => {
|
|
437
|
+
expect(resolveEditPlanSources([MIC, CAM_A], { offsets: byMic })).toMatchObject({ ok: true, sources: [MIC, { id: "cam-a", offsetMs: 2_000 }] })
|
|
438
|
+
for (const empty of [null, ""]) {
|
|
439
|
+
expect(resolveEditPlanSources([MIC, CAM_A], { offsets: empty })).toEqual({ ok: false, issues: [{ code: "not-audio-sync" }] })
|
|
440
|
+
}
|
|
441
|
+
})
|
|
442
|
+
|
|
443
|
+
it("refuses a hand-set non-zero master offset before charging — with or without offsets", () => {
|
|
444
|
+
expect(resolveEditPlanSources([{ ...MIC, offsetMs: 25 }, CAM_A])).toEqual({ ok: false, issues: [{ code: "anchor-offset", sourceId: "mic", offsetMs: 25 }] })
|
|
445
|
+
expect(resolveEditPlanSources([{ ...MIC, offsetMs: 25 }, CAM_A], { offsets: byMic })).toEqual({ ok: false, issues: [{ code: "anchor-offset", sourceId: "mic", offsetMs: 25 }] })
|
|
446
|
+
})
|
|
447
|
+
|
|
448
|
+
it("a transcript made from an offset camera fails, naming both — the cuts would land off by its offset", () => {
|
|
449
|
+
expect(resolveEditPlanSources([MIC, CAM_A], { offsets: byMic, transcriptSourceId: "cam-a" }))
|
|
450
|
+
.toEqual({ ok: false, issues: [{ code: "transcript-off-clock", sourceId: "cam-a", masterId: "mic", offsetMs: 2_000 }] })
|
|
451
|
+
// Hand-set offsets count too.
|
|
452
|
+
expect(resolveEditPlanSources([MIC, { ...CAM_A, offsetMs: 700 }], { transcriptSourceId: "cam-a" }))
|
|
453
|
+
.toMatchObject({ ok: false, issues: [{ code: "transcript-off-clock", sourceId: "cam-a" }] })
|
|
454
|
+
})
|
|
455
|
+
|
|
456
|
+
it("a transcript made from the master, or from a source at offset 0, is fine — and its id is echoed to stamp", () => {
|
|
457
|
+
expect(resolveEditPlanSources([MIC, CAM_A], { offsets: byMic, transcriptSourceId: "mic" })).toMatchObject({ ok: true, transcriptSourceId: "mic" })
|
|
458
|
+
expect(resolveEditPlanSources([MIC, { ...CAM_A, offsetMs: 0 }], { transcriptSourceId: "cam-a" })).toMatchObject({ ok: true, transcriptSourceId: "cam-a" })
|
|
459
|
+
})
|
|
460
|
+
|
|
461
|
+
it("a transcript whose origin is unknown, or not one of the sources, is assumed to be the master's", () => {
|
|
462
|
+
expect(resolveEditPlanSources([MIC, CAM_A], { offsets: byMic })).toMatchObject({ ok: true })
|
|
463
|
+
const r = resolveEditPlanSources([MIC, CAM_A], { offsets: byMic, transcriptSourceId: "elsewhere" })
|
|
464
|
+
expect(r).toMatchObject({ ok: true })
|
|
465
|
+
expect(r.ok && r.transcriptSourceId).toBeFalsy()
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
it("a hand-set offset that is not a number is refused, never summed as a string or read as absent", () => {
|
|
469
|
+
expect(resolveEditPlanSources([{ ...MIC, offsetMs: "500" as unknown as number }, CAM_A], { offsets: byMic }))
|
|
470
|
+
.toEqual({ ok: false, issues: [{ code: "invalid-offset", sourceId: "mic" }] })
|
|
471
|
+
expect(resolveEditPlanSources([MIC, { ...CAM_A, offsetMs: "1200" as unknown as number }]))
|
|
472
|
+
.toEqual({ ok: false, issues: [{ code: "invalid-offset", sourceId: "cam-a" }] })
|
|
473
|
+
})
|
|
474
|
+
|
|
475
|
+
it("phrases the transcript issue with the caller's labels", () => {
|
|
476
|
+
const label = (id: string) => ({ mic: "Zoom H6", "cam-a": "Camera A" })[id] ?? id
|
|
477
|
+
expect(describeAudioSyncOffsetIssue({ code: "transcript-off-clock", sourceId: "cam-a", masterId: "mic", offsetMs: 2_000 }, label))
|
|
478
|
+
.toBe('the transcript was made from "Camera A", which is 2000 ms off the master "Zoom H6" — the plan follows the master\'s clock, so transcribe "Zoom H6", or mark "Camera A" as master audio')
|
|
479
|
+
})
|
|
480
|
+
})
|
|
481
|
+
|
|
482
|
+
describe("editPlanTranscriptOrigin — the recording a canvas transcript was made from", () => {
|
|
483
|
+
const types: Record<string, string> = { t: "transcribe", ea: "extract-audio", cam: "upload-video", mic: "upload-audio", llm: "llm-chat" }
|
|
484
|
+
const typeOf = (id: string) => types[id]
|
|
485
|
+
it("the node feeding the transcriber", () => {
|
|
486
|
+
expect(editPlanTranscriptOrigin("t", typeOf, [{ source: "mic", target: "t" }])).toBe("mic")
|
|
487
|
+
})
|
|
488
|
+
it("through extract-audio (it keeps the clock)", () => {
|
|
489
|
+
expect(editPlanTranscriptOrigin("t", typeOf, [{ source: "ea", target: "t" }, { source: "cam", target: "ea" }])).toBe("cam")
|
|
490
|
+
})
|
|
491
|
+
it("unknown when the producer is not a transcriber, or the trace is ambiguous or missing", () => {
|
|
492
|
+
expect(editPlanTranscriptOrigin("llm", typeOf, [{ source: "mic", target: "llm" }])).toBeUndefined()
|
|
493
|
+
expect(editPlanTranscriptOrigin("t", typeOf, [{ source: "mic", target: "t" }, { source: "cam", target: "t" }])).toBeUndefined()
|
|
494
|
+
expect(editPlanTranscriptOrigin("t", typeOf, [])).toBeUndefined()
|
|
495
|
+
})
|
|
496
|
+
})
|
|
@@ -400,10 +400,13 @@ describe("LLM_FEATURE_DEFAULTS", () => {
|
|
|
400
400
|
"workflow-copilot",
|
|
401
401
|
// Scene3D previz authoring — generate-3d-scene AND edit-3d-scene share it.
|
|
402
402
|
"3d-scene",
|
|
403
|
+
// "Steal the format" — Content Recipe and Content Ideas.
|
|
404
|
+
"content-recipe",
|
|
405
|
+
"content-ideas",
|
|
403
406
|
]
|
|
404
407
|
|
|
405
|
-
it("has entries for all
|
|
406
|
-
expect(Object.keys(LLM_FEATURE_DEFAULTS)).toHaveLength(
|
|
408
|
+
it("has entries for all 21 features", () => {
|
|
409
|
+
expect(Object.keys(LLM_FEATURE_DEFAULTS)).toHaveLength(21)
|
|
407
410
|
for (const feature of ALL_FEATURES) {
|
|
408
411
|
expect(LLM_FEATURE_DEFAULTS).toHaveProperty(feature)
|
|
409
412
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import { DEFAULT_MUSIC_PROVIDER, MUSIC_PROVIDERS, MUSIC_PROVIDER_LABELS, resolveMusicProvider } from "../model-constants.js"
|
|
3
|
+
|
|
4
|
+
describe("resolveMusicProvider", () => {
|
|
5
|
+
it("keeps a model the node offers", () => {
|
|
6
|
+
for (const p of MUSIC_PROVIDERS) expect(resolveMusicProvider(p)).toBe(p)
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
// New nodes started on "suno"; older ones carry retired models.
|
|
10
|
+
it.each(["suno", "musicgen", "lyria", "bark", undefined, "", 7])("runs %s as the default model", (value) => {
|
|
11
|
+
expect(resolveMusicProvider(value)).toBe(DEFAULT_MUSIC_PROVIDER)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it("names every model it offers", () => {
|
|
15
|
+
for (const p of MUSIC_PROVIDERS) expect(MUSIC_PROVIDER_LABELS[p]).toBeTruthy()
|
|
16
|
+
})
|
|
17
|
+
})
|
|
@@ -104,6 +104,16 @@ describe("stripTransientRuntimeData", () => {
|
|
|
104
104
|
expect(out[0]!.type).toBe("generate-image")
|
|
105
105
|
})
|
|
106
106
|
|
|
107
|
+
it("never saves a trigger's last run values — run history keeps them, under its retention", () => {
|
|
108
|
+
const trigger = {
|
|
109
|
+
id: "t1",
|
|
110
|
+
type: "telegram-account-trigger",
|
|
111
|
+
data: { label: "Inbox", chatIds: ["777"], __triggerData: { text: "a message", senderId: "555" } },
|
|
112
|
+
}
|
|
113
|
+
const [out] = stripTransientRuntimeData([trigger])
|
|
114
|
+
expect(out!.data).toEqual({ label: "Inbox", chatIds: ["777"] })
|
|
115
|
+
})
|
|
116
|
+
|
|
107
117
|
it("passes through nodes without data and avoids copying when nothing is transient", () => {
|
|
108
118
|
const bare = { id: "n2" } as { id: string; data?: Record<string, unknown> }
|
|
109
119
|
const clean = { id: "n3", data: { label: "T", prompt: "p" } }
|
|
@@ -143,8 +143,9 @@ describe("getParameterValue — character-motion", () => {
|
|
|
143
143
|
|
|
144
144
|
describe("VIDEO_ONLY_PARAMETER_NODE_TYPES", () => {
|
|
145
145
|
it("names exactly the pickers a still image must never receive", () => {
|
|
146
|
+
// + motion: how much the shot moves (a Settings-input clause on video nodes).
|
|
146
147
|
expect([...VIDEO_ONLY_PARAMETER_NODE_TYPES].sort()).toEqual(
|
|
147
|
-
["camera-motion", "character-fx", "character-motion", "temporal", "transition"],
|
|
148
|
+
["camera-motion", "character-fx", "character-motion", "motion", "temporal", "transition"],
|
|
148
149
|
)
|
|
149
150
|
})
|
|
150
151
|
it("is a subset of PARAMETER_NODE_TYPES", () => {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
LTX_EXTEND_DURATION,
|
|
4
|
+
LTX_RETAKE_MIN_DURATION_SEC,
|
|
5
|
+
LTX_RETAKE_PER_SECOND_CREDIT_ID,
|
|
6
|
+
ltxRetakeDurationSec,
|
|
7
|
+
LTX_EXTEND_PER_SECOND_CREDIT_ID,
|
|
8
|
+
VIDEO_SFX_PRICING,
|
|
9
|
+
ltxExtendDurationSec,
|
|
10
|
+
videoSfxCreditId,
|
|
11
|
+
} from "../index.js"
|
|
12
|
+
|
|
13
|
+
describe("videoSfxCreditId", () => {
|
|
14
|
+
it.each([
|
|
15
|
+
[1, "replicate-mmaudio:8s"],
|
|
16
|
+
[5, "replicate-mmaudio:8s"],
|
|
17
|
+
[8, "replicate-mmaudio:8s"],
|
|
18
|
+
[8.3, "replicate-mmaudio:15s"],
|
|
19
|
+
[9, "replicate-mmaudio:15s"],
|
|
20
|
+
[12, "replicate-mmaudio:15s"],
|
|
21
|
+
[15, "replicate-mmaudio:15s"],
|
|
22
|
+
[16, "replicate-mmaudio:30s"],
|
|
23
|
+
[30, "replicate-mmaudio:30s"],
|
|
24
|
+
[31, "replicate-mmaudio:60s"],
|
|
25
|
+
[60, "replicate-mmaudio:60s"],
|
|
26
|
+
[61, "replicate-mmaudio:120s"],
|
|
27
|
+
[120, "replicate-mmaudio:120s"],
|
|
28
|
+
[121, "replicate-mmaudio:300s"],
|
|
29
|
+
[180, "replicate-mmaudio:300s"],
|
|
30
|
+
[300, "replicate-mmaudio:300s"],
|
|
31
|
+
])("%s s → %s", (seconds, id) => {
|
|
32
|
+
expect(videoSfxCreditId(seconds)).toBe(id)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it("prices the fallback length when the video could not be measured", () => {
|
|
36
|
+
const fallback = videoSfxCreditId(VIDEO_SFX_PRICING.FALLBACK_DURATION_SEC)
|
|
37
|
+
for (const unknown of [undefined, null, 0, -4, Number.NaN, Number.POSITIVE_INFINITY]) {
|
|
38
|
+
expect(videoSfxCreditId(unknown)).toBe(fallback)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it("a length past the cap prices the last bucket", () => {
|
|
43
|
+
expect(videoSfxCreditId(VIDEO_SFX_PRICING.MAX_DURATION_SEC + 1)).toBe("replicate-mmaudio:300s")
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
describe("ltxExtendDurationSec", () => {
|
|
48
|
+
it("names the per-second price row", () => {
|
|
49
|
+
expect(LTX_EXTEND_PER_SECOND_CREDIT_ID).toBe("ltx-2.3-pro-extend:per-second")
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it.each([
|
|
53
|
+
[2, 2],
|
|
54
|
+
[6, 6],
|
|
55
|
+
[20, 20],
|
|
56
|
+
[7.4, 7],
|
|
57
|
+
[7.5, 8],
|
|
58
|
+
["8", 8],
|
|
59
|
+
[" 12 ", 12],
|
|
60
|
+
[0, 1],
|
|
61
|
+
[-3, 1],
|
|
62
|
+
[25, 20],
|
|
63
|
+
])("%j → %i seconds", (raw, seconds) => {
|
|
64
|
+
expect(ltxExtendDurationSec(raw)).toBe(seconds)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it("an absent or unreadable length is the model's default", () => {
|
|
68
|
+
for (const raw of [undefined, null, "", "abc", Number.NaN, {}, true]) {
|
|
69
|
+
expect(ltxExtendDurationSec(raw)).toBe(LTX_EXTEND_DURATION.DEFAULT_SEC)
|
|
70
|
+
}
|
|
71
|
+
expect(LTX_EXTEND_DURATION.DEFAULT_SEC).toBe(6)
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
describe("ltxRetakeDurationSec", () => {
|
|
76
|
+
it("names the per-second price row", () => {
|
|
77
|
+
expect(LTX_RETAKE_PER_SECOND_CREDIT_ID).toBe("ltx-2.3-pro-retake:per-second")
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it.each([
|
|
81
|
+
[2, 2],
|
|
82
|
+
[2.5, 2.5],
|
|
83
|
+
[12, 12],
|
|
84
|
+
["4", 4],
|
|
85
|
+
[1, 2],
|
|
86
|
+
[0, 2],
|
|
87
|
+
[-3, 2],
|
|
88
|
+
])("%j → %s seconds (never below the 2-second minimum)", (raw, seconds) => {
|
|
89
|
+
expect(ltxRetakeDurationSec(raw)).toBe(seconds)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it("an absent or unreadable window is the minimum", () => {
|
|
93
|
+
for (const raw of [undefined, null, "", "abc", Number.NaN, {}]) {
|
|
94
|
+
expect(ltxRetakeDurationSec(raw)).toBe(LTX_RETAKE_MIN_DURATION_SEC)
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
})
|