@nodaro/shared 3.14.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 +1483 -30
- package/dist/index.d.ts +1483 -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 +7 -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
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
STUDIO_TAKE_VOICE_KEYS,
|
|
5
|
+
stripStudioDraftSettings,
|
|
6
|
+
stripStudioDraftWorkflow,
|
|
7
|
+
stripStudioTakeVoiceRecords,
|
|
8
|
+
} from "../studio-transient.js"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A finished take's VOICE RECORD is the owner's (studio ruling T42): the plan
|
|
12
|
+
* the clip was recast with — the OWNER's voice ids — and the Voice control's
|
|
13
|
+
* mode. It rides the canvas node's `data.generatedResults` rows, not
|
|
14
|
+
* `settings.studio`, so a settings-only strip never reaches it. A reader who
|
|
15
|
+
* may look but not edit loses it; the owner and an edit collaborator keep it.
|
|
16
|
+
*
|
|
17
|
+
* The bin carries the same things again, deleted (T11 / T42 on the bin): a
|
|
18
|
+
* deleted empty slot, a deleted take with its record, a deleted scene whose
|
|
19
|
+
* one-scene graph holds both.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const PLAN = { orderedVoices: [{ voiceId: "voice-owner-abi", voiceName: "Abi" }], settings: { stability: 0.5 } }
|
|
23
|
+
|
|
24
|
+
/** A studio clip node whose two takes carry the record, beside a still node that never does. */
|
|
25
|
+
function nodes(): Array<Record<string, unknown>> {
|
|
26
|
+
return [
|
|
27
|
+
{ id: "generate-image-s1", type: "generate-image", position: { x: 0, y: 0 },
|
|
28
|
+
data: { prompt: "a lighthouse", generatedResults: [{ url: "https://r2/a.png", prompt: "a lighthouse" }] } },
|
|
29
|
+
{ id: "generate-video-s1", type: "generate-video", position: { x: 0, y: 0 },
|
|
30
|
+
data: { prompt: "Abi speaks", provider: "seedance-2", activeResultIndex: 1, generatedResults: [
|
|
31
|
+
{ url: "https://r2/a.mp4", prompt: "Abi speaks", revoiceTo: PLAN, voiceMode: "character" },
|
|
32
|
+
{ url: "https://r2/b.mp4", prompt: "Abi whispers", voiceMode: "off", name: "Quiet" },
|
|
33
|
+
] } },
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const rowsOf = (list: unknown) =>
|
|
38
|
+
(list as Array<{ data?: { generatedResults?: Array<Record<string, unknown>> } }>)
|
|
39
|
+
.flatMap((node) => node.data?.generatedResults ?? [])
|
|
40
|
+
|
|
41
|
+
describe("stripStudioTakeVoiceRecords — a take's voice record is the owner's (T42)", () => {
|
|
42
|
+
it("drops every result row's plan and mode and keeps the rest of the take", () => {
|
|
43
|
+
const stored = nodes()
|
|
44
|
+
const out = stripStudioTakeVoiceRecords(stored)
|
|
45
|
+
expect(JSON.stringify(out)).not.toContain("voice-owner-abi")
|
|
46
|
+
expect(JSON.stringify(out)).not.toContain("voiceMode")
|
|
47
|
+
expect(rowsOf(out)).toEqual([
|
|
48
|
+
{ url: "https://r2/a.png", prompt: "a lighthouse" },
|
|
49
|
+
{ url: "https://r2/a.mp4", prompt: "Abi speaks" },
|
|
50
|
+
{ url: "https://r2/b.mp4", prompt: "Abi whispers", name: "Quiet" },
|
|
51
|
+
])
|
|
52
|
+
// The node itself — everything beside its result rows — is untouched.
|
|
53
|
+
const clip = (out as typeof stored)[1]!
|
|
54
|
+
expect(clip).toMatchObject({ id: "generate-video-s1", type: "generate-video" })
|
|
55
|
+
expect(clip.data).toMatchObject({ prompt: "Abi speaks", provider: "seedance-2", activeResultIndex: 1 })
|
|
56
|
+
// Copy-on-write: the stored rows keep the record, and a node with nothing
|
|
57
|
+
// to drop is the SAME node.
|
|
58
|
+
expect(JSON.stringify(stored)).toContain("voice-owner-abi")
|
|
59
|
+
expect((out as typeof stored)[0]).toBe(stored[0])
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it("walks every node, not only a clip node: the keys are what matters, not the type", () => {
|
|
63
|
+
const odd = [{ id: "n1", type: "some-future-node", data: { generatedResults: [{ url: "u", voiceMode: "auto" }] } }]
|
|
64
|
+
expect(rowsOf(stripStudioTakeVoiceRecords(odd))).toEqual([{ url: "u" }])
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it("hands back the SAME array when no row carries either key", () => {
|
|
68
|
+
const plain = [{ id: "n1", data: { generatedResults: [{ url: "u" }] } }, { id: "n2", data: {} }]
|
|
69
|
+
expect(stripStudioTakeVoiceRecords(plain)).toBe(plain)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it("lets anything that is not node-shaped ride through — it runs on whatever is in the column", () => {
|
|
73
|
+
expect(stripStudioTakeVoiceRecords(null)).toBeNull()
|
|
74
|
+
expect(stripStudioTakeVoiceRecords(undefined)).toBeUndefined()
|
|
75
|
+
const junk = { nodes: "not a list" }
|
|
76
|
+
expect(stripStudioTakeVoiceRecords(junk)).toBe(junk)
|
|
77
|
+
const mixed = [null, 7, "x", [], { data: null }, { data: { generatedResults: "nope" } },
|
|
78
|
+
{ data: { generatedResults: [null, 3, { url: "u", revoiceTo: PLAN }] } }]
|
|
79
|
+
const out = stripStudioTakeVoiceRecords(mixed) as unknown[]
|
|
80
|
+
expect(out.slice(0, 6)).toEqual(mixed.slice(0, 6))
|
|
81
|
+
expect((out[6] as { data: { generatedResults: unknown[] } }).data.generatedResults).toEqual([null, 3, { url: "u" }])
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it("leaves the scene's RECIPE voice mode and the clip-level revoiced voice alone — T42 is results only", () => {
|
|
85
|
+
const settings = { studio: { version: 3, shots: [
|
|
86
|
+
{ id: "s1", recipe: { directing: { prompt: "p", voiceMode: "character" } }, revoicedVoiceId: "v-1" },
|
|
87
|
+
] } }
|
|
88
|
+
expect(stripStudioDraftSettings(settings)).toBe(settings)
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
/** The owner's bin, one entry of each kind that can carry the owner's drafts. */
|
|
93
|
+
function bin(): Array<Record<string, unknown>> {
|
|
94
|
+
return [
|
|
95
|
+
// A deleted EMPTY slot — an unsubmitted draft, whole.
|
|
96
|
+
{ kind: "slot", id: "t-slot", shotId: "s1", index: 0, deletedAt: "2026-10-01T10:00:00.000Z",
|
|
97
|
+
stage: "still", slot: { id: "slot-1", inputs: { prompt: "an unsent idea" } } },
|
|
98
|
+
// A deleted take with its record.
|
|
99
|
+
{ kind: "clip", id: "t-clip", shotId: "s1", index: 0, deletedAt: "2026-10-01T10:00:00.000Z",
|
|
100
|
+
clipBase: { nodeId: "generate-video-s1" },
|
|
101
|
+
result: { url: "https://r2/c.mp4", prompt: "Abi sings", revoiceTo: PLAN, voiceMode: "character" } },
|
|
102
|
+
// A legacy entry with no kind reads as a clip.
|
|
103
|
+
{ id: "t-legacy", shotId: "s1", index: 1, deletedAt: "2026-10-01T10:00:00.000Z",
|
|
104
|
+
result: { url: "https://r2/d.mp4", voiceMode: "auto" } },
|
|
105
|
+
// A deleted SCENE: a one-scene production graph, its take's record on the
|
|
106
|
+
// graph's nodes and its slots and run on the graph's scene entry.
|
|
107
|
+
{ kind: "shot", id: "t-shot", shotId: "s2", index: 1, deletedAt: "2026-10-01T10:00:00.000Z",
|
|
108
|
+
graph: { nodes: nodes(), edges: [], settings: { studio: { version: 3, shots: [
|
|
109
|
+
{ id: "s2", clipSlots: [{ id: "slot-9", inputs: { prompt: "an unsent move" } }],
|
|
110
|
+
pendingStills: [{ jobId: "job-7", startedAt: 1, slotId: "slot-9", prompt: "an unsent run" }] },
|
|
111
|
+
] } } } },
|
|
112
|
+
// A deleted still and keyframe carry neither, and ride through.
|
|
113
|
+
{ kind: "still", id: "t-still", shotId: "s1", index: 0, deletedAt: "2026-10-01T10:00:00.000Z",
|
|
114
|
+
stillBase: { nodeId: "generate-image-s1" }, result: { url: "https://r2/e.png" } },
|
|
115
|
+
{ kind: "keyframe", id: "t-key", index: 0, deletedAt: "2026-10-01T10:00:00.000Z", keyframe: { id: "k1" } },
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const trashOf = (settings: unknown) =>
|
|
120
|
+
(settings as { studio: { trash: Array<Record<string, unknown>> } }).studio.trash
|
|
121
|
+
|
|
122
|
+
describe("stripStudioDraftSettings — the bin keeps what was deleted, without the owner's drafts in it", () => {
|
|
123
|
+
it("drops a deleted empty slot whole (T11)", () => {
|
|
124
|
+
const out = trashOf(stripStudioDraftSettings({ studio: { version: 3, trash: bin() } }))
|
|
125
|
+
expect(out.map((entry) => entry.id)).toEqual(["t-clip", "t-legacy", "t-shot", "t-still", "t-key"])
|
|
126
|
+
expect(JSON.stringify(out)).not.toContain("an unsent idea")
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
it("keeps a deleted take and drops its voice record — a legacy no-kind entry too (T42)", () => {
|
|
130
|
+
const out = trashOf(stripStudioDraftSettings({ studio: { version: 3, trash: bin() } }))
|
|
131
|
+
expect(out.find((entry) => entry.id === "t-clip")!.result).toEqual({ url: "https://r2/c.mp4", prompt: "Abi sings" })
|
|
132
|
+
expect(out.find((entry) => entry.id === "t-legacy")!.result).toEqual({ url: "https://r2/d.mp4" })
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it("gives a deleted scene what a live production gets: no take record on its nodes, no slot or run on its scene", () => {
|
|
136
|
+
const out = trashOf(stripStudioDraftSettings({ studio: { version: 3, trash: bin() } }))
|
|
137
|
+
const graph = out.find((entry) => entry.id === "t-shot")!.graph as { nodes: unknown; settings: unknown }
|
|
138
|
+
expect(JSON.stringify(graph)).not.toContain("voice-owner-abi")
|
|
139
|
+
expect(JSON.stringify(graph)).not.toContain("an unsent")
|
|
140
|
+
expect(rowsOf(graph.nodes)).toHaveLength(3)
|
|
141
|
+
expect(graph.settings).toEqual({ studio: { version: 3, shots: [{ id: "s2" }] } })
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it("rides a deleted still and keyframe through as they are", () => {
|
|
145
|
+
const stored = bin()
|
|
146
|
+
const out = trashOf(stripStudioDraftSettings({ studio: { version: 3, trash: stored } }))
|
|
147
|
+
expect(out.find((entry) => entry.id === "t-still")).toBe(stored[4])
|
|
148
|
+
expect(out.find((entry) => entry.id === "t-key")).toBe(stored[5])
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
it("is copy-on-write, and the SAME settings back when neither a scene nor the bin carries any of it", () => {
|
|
152
|
+
const stored = { studio: { version: 3, trash: bin() } }
|
|
153
|
+
stripStudioDraftSettings(stored)
|
|
154
|
+
expect(JSON.stringify(stored)).toContain("voice-owner-abi")
|
|
155
|
+
expect(JSON.stringify(stored)).toContain("an unsent idea")
|
|
156
|
+
const clean = { studio: { version: 3, shots: [{ id: "s1" }], trash: [bin()[4], bin()[5], { id: "t-1" }] } }
|
|
157
|
+
expect(stripStudioDraftSettings(clean)).toBe(clean)
|
|
158
|
+
// A bin that is not a list rides through.
|
|
159
|
+
const odd = { studio: { version: 3, trash: "nope" } }
|
|
160
|
+
expect(stripStudioDraftSettings(odd)).toBe(odd)
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
describe("stripStudioDraftWorkflow — the one strip every `view` door applies", () => {
|
|
165
|
+
it("strips the take records off the nodes AND the drafts off the settings, and keeps the rest of the row", () => {
|
|
166
|
+
const row = { id: "wf-1", name: "Film", edges: [{ id: "e1" }], nodes: nodes(), settings: { studio: { version: 3,
|
|
167
|
+
shots: [{ id: "s1", stillSlots: [{ id: "slot-1", inputs: { prompt: "an unsent idea" } }] }], trash: bin() } } }
|
|
168
|
+
const out = stripStudioDraftWorkflow(row)
|
|
169
|
+
expect(JSON.stringify(out)).not.toContain("voice-owner-abi")
|
|
170
|
+
expect(JSON.stringify(out)).not.toContain("an unsent")
|
|
171
|
+
expect(out).toMatchObject({ id: "wf-1", name: "Film", edges: [{ id: "e1" }] })
|
|
172
|
+
expect(rowsOf(out.nodes)).toHaveLength(3)
|
|
173
|
+
// Copy-on-write.
|
|
174
|
+
expect(JSON.stringify(row)).toContain("voice-owner-abi")
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it("strips either half alone", () => {
|
|
178
|
+
const voiced = { nodes: nodes(), settings: { studio: { version: 3 } } }
|
|
179
|
+
const out = stripStudioDraftWorkflow(voiced)
|
|
180
|
+
expect(JSON.stringify(out.nodes)).not.toContain("voice-owner-abi")
|
|
181
|
+
expect(out.settings).toBe(voiced.settings)
|
|
182
|
+
const drafted = { nodes: [], settings: { studio: { version: 3, shots: [{ id: "s1", clipSlots: [] }] } } }
|
|
183
|
+
const out2 = stripStudioDraftWorkflow(drafted)
|
|
184
|
+
expect(out2.nodes).toBe(drafted.nodes)
|
|
185
|
+
expect(out2.settings).toEqual({ studio: { version: 3, shots: [{ id: "s1" }] } })
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it("hands back the SAME row when there is nothing of the owner's on it", () => {
|
|
189
|
+
const plain = { nodes: [{ id: "n1", data: {} }], settings: { foo: 1 } }
|
|
190
|
+
expect(stripStudioDraftWorkflow(plain)).toBe(plain)
|
|
191
|
+
const bare: { name: string; settings?: unknown } = { name: "no graph read" }
|
|
192
|
+
expect(stripStudioDraftWorkflow(bare)).toBe(bare)
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
describe("the take list", () => {
|
|
197
|
+
it("names the two keys — the studio codec's own `READER_PRIVATE_TAKE_KEYS` holds the same two", () => {
|
|
198
|
+
expect([...STUDIO_TAKE_VOICE_KEYS]).toEqual(["revoiceTo", "voiceMode"])
|
|
199
|
+
})
|
|
200
|
+
})
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest"
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
STUDIO_SHOT_DRAFT_KEYS,
|
|
4
5
|
STUDIO_SHOT_TRANSIENT_KEYS,
|
|
5
6
|
STUDIO_TRANSIENT_KEYS,
|
|
7
|
+
stripStudioDraftSettings,
|
|
6
8
|
stripStudioTransientSettings,
|
|
7
9
|
} from "../studio-transient.js"
|
|
8
10
|
|
|
@@ -185,6 +187,38 @@ describe("stripStudioTransientSettings", () => {
|
|
|
185
187
|
expect(out.version).toBe(3)
|
|
186
188
|
})
|
|
187
189
|
|
|
190
|
+
it("drops a shot's empty media slots — the owner's drafts, never a viewer's (T11)", () => {
|
|
191
|
+
const settings = { studio: { version: 3, shots: [
|
|
192
|
+
{ id: "s1", imageNodeId: "img-1", stillSlots: [{ id: "slot-1", inputs: { prompt: "an unsent idea" } }],
|
|
193
|
+
clipSlots: [{ id: "slot-2", inputs: {} }],
|
|
194
|
+
// A run started from a slot: its marker carries the slot's inputs.
|
|
195
|
+
pendingStills: [{ jobId: "job-1", startedAt: 1, slotId: "slot-1", prompt: "an unsent idea" }] },
|
|
196
|
+
{ id: "s2" },
|
|
197
|
+
] } }
|
|
198
|
+
const shots = studioOf(stripStudioTransientSettings(settings)).shots
|
|
199
|
+
expect(shots).toEqual([{ id: "s1", imageNodeId: "img-1" }, { id: "s2" }])
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
it("stripStudioDraftSettings drops a shot's slots AND its in-flight runs — a `view` read keeps the rest", () => {
|
|
203
|
+
// The per-shot run markers go with the slots: a viewer cannot land the
|
|
204
|
+
// owner's runs, and a slot-tagged marker carries that slot's unsent inputs.
|
|
205
|
+
// The bin and the document-level markers stay (the bin loses only the
|
|
206
|
+
// owner's drafts in it — `studio-take-voice.test.ts`).
|
|
207
|
+
const settings = { studio: { version: 3, trash: [{ id: "t-1" }], pendingMusic: { jobId: "job-9" }, shots: [
|
|
208
|
+
{ id: "s1", pendingClips: [{ jobId: "job-1" }], pendingClip: { jobId: "job-0" },
|
|
209
|
+
pendingStills: [{ jobId: "job-2", startedAt: 1, slotId: "slot-1", prompt: "an unsent idea" }],
|
|
210
|
+
stillSlots: [{ id: "slot-1", inputs: {} }], clipSlots: [{ id: "slot-2", inputs: {} }] },
|
|
211
|
+
] } }
|
|
212
|
+
expect(stripStudioDraftSettings(settings)).toEqual({ studio: { version: 3, trash: [{ id: "t-1" }],
|
|
213
|
+
pendingMusic: { jobId: "job-9" }, shots: [{ id: "s1" }] } })
|
|
214
|
+
// A marker alone — no slot on the scene — goes too.
|
|
215
|
+
const runOnly = { studio: { version: 3, shots: [{ id: "s1", pendingStills: [{ jobId: "job-3" }] }] } }
|
|
216
|
+
expect(stripStudioDraftSettings(runOnly)).toEqual({ studio: { version: 3, shots: [{ id: "s1" }] } })
|
|
217
|
+
const none = { studio: { version: 3, shots: [{ id: "s1" }] } }
|
|
218
|
+
expect(stripStudioDraftSettings(none)).toBe(none)
|
|
219
|
+
expect(stripStudioDraftSettings(null)).toBeNull()
|
|
220
|
+
})
|
|
221
|
+
|
|
188
222
|
it("pins the two lists — a key added to the type alone strips nothing", () => {
|
|
189
223
|
// The lists are the contract: the codec's own strip re-exports them, so a
|
|
190
224
|
// key that falls off here falls off there too, silently, on both sides.
|
|
@@ -201,5 +235,8 @@ describe("stripStudioTransientSettings", () => {
|
|
|
201
235
|
"pendingClip",
|
|
202
236
|
"pendingStills",
|
|
203
237
|
])
|
|
238
|
+
// The owner's drafts are a list of their own: the export projection reads
|
|
239
|
+
// the transient list, and the owner's exports keep their slots.
|
|
240
|
+
expect([...STUDIO_SHOT_DRAFT_KEYS]).toEqual(["stillSlots", "clipSlots"])
|
|
204
241
|
})
|
|
205
242
|
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import { ANIMATE_SUB_GATES, MATCH_CUT_BREAK_GATE, SubGateNameSchema } from "../pipeline-state-types.js"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Every sub-gate a stage can pause at must have a way to clear it. Stage 7's
|
|
6
|
+
* resolve through `POST /v1/pipelines/:id/sub-gates/:gate/{approve,reject}`
|
|
7
|
+
* (`ANIMATE_SUB_GATES`); Stage 6's match-cut gate clears one break at a time
|
|
8
|
+
* through its scene helper. The SDK once documented approveSubGate for the
|
|
9
|
+
* match-cut gate, a call that could never succeed. A new gate fails here until
|
|
10
|
+
* someone decides which of the two it is.
|
|
11
|
+
*/
|
|
12
|
+
describe("sub-gates", () => {
|
|
13
|
+
it("each is resolved by the sub-gate routes or is the per-break match-cut gate", () => {
|
|
14
|
+
const handled = [...ANIMATE_SUB_GATES, MATCH_CUT_BREAK_GATE].sort()
|
|
15
|
+
expect([...SubGateNameSchema.options].sort()).toEqual(handled)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it("the sub-gate routes never take the match-cut gate", () => {
|
|
19
|
+
expect(ANIMATE_SUB_GATES).not.toContain(MATCH_CUT_BREAK_GATE)
|
|
20
|
+
})
|
|
21
|
+
})
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
TELEGRAM_ACCOUNT_TRIGGER_OUTPUT_HANDLES,
|
|
4
|
+
TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS,
|
|
5
|
+
isTelegramAccountTriggerNamedHandle,
|
|
6
|
+
telegramAccountTriggerOutputs,
|
|
7
|
+
} from "../telegram-account-trigger.js"
|
|
8
|
+
|
|
9
|
+
describe("Telegram Account Trigger outputs", () => {
|
|
10
|
+
it("the card shows the message first, then every post field", () => {
|
|
11
|
+
expect(TELEGRAM_ACCOUNT_TRIGGER_OUTPUT_HANDLES).toEqual(["out", "videoLink", "postText", "postLink"])
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it("every post field is present in a run's outputs, empty when the trigger data has none", () => {
|
|
15
|
+
const outputs = telegramAccountTriggerOutputs({ text: "hello", chatId: "-1001" })
|
|
16
|
+
for (const key of TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS) expect(outputs[key]).toBe("")
|
|
17
|
+
expect(Object.keys(outputs)).toEqual(expect.arrayContaining([...TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS]))
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it("carries the post fields and the message facts it was given, trimmed", () => {
|
|
21
|
+
const outputs = telegramAccountTriggerOutputs({
|
|
22
|
+
videoLink: " https://www.tiktok.com/@a/video/1 ",
|
|
23
|
+
postText: "",
|
|
24
|
+
postLink: "https://www.tiktok.com/@a/video/1",
|
|
25
|
+
chatId: "777",
|
|
26
|
+
chatType: "private",
|
|
27
|
+
messageId: 42,
|
|
28
|
+
})
|
|
29
|
+
expect(outputs).toEqual({
|
|
30
|
+
videoLink: "https://www.tiktok.com/@a/video/1",
|
|
31
|
+
postText: "",
|
|
32
|
+
postLink: "https://www.tiktok.com/@a/video/1",
|
|
33
|
+
chatId: "777",
|
|
34
|
+
chatType: "private",
|
|
35
|
+
messageId: "42",
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it("a message fact without a value is left out, never written as an empty string", () => {
|
|
40
|
+
const outputs = telegramAccountTriggerOutputs({ chatId: "", senderId: null })
|
|
41
|
+
expect("chatId" in outputs).toBe(false)
|
|
42
|
+
expect("senderId" in outputs).toBe(false)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it("non-string values never become text", () => {
|
|
46
|
+
const outputs = telegramAccountTriggerOutputs({ videoLink: { url: "x" }, postText: ["a"] })
|
|
47
|
+
expect(outputs.videoLink).toBe("")
|
|
48
|
+
expect(outputs.postText).toBe("")
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it("no trigger data at all still yields every post field", () => {
|
|
52
|
+
expect(telegramAccountTriggerOutputs(undefined)).toEqual({ videoLink: "", postText: "", postLink: "" })
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it("every handle but the message names one value of the run", () => {
|
|
56
|
+
expect(isTelegramAccountTriggerNamedHandle("videoLink")).toBe(true)
|
|
57
|
+
expect(isTelegramAccountTriggerNamedHandle("chatId")).toBe(true)
|
|
58
|
+
expect(isTelegramAccountTriggerNamedHandle("out")).toBe(false)
|
|
59
|
+
// An older spelling of the message handle routes as the message, not as a named value.
|
|
60
|
+
expect(isTelegramAccountTriggerNamedHandle("text")).toBe(false)
|
|
61
|
+
expect(isTelegramAccountTriggerNamedHandle(undefined)).toBe(false)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
describe("telegramAccountListeningSignature", () => {
|
|
66
|
+
const base = { accountId: "acc-1", chatIds: ["777", "-1001"], keywords: ["idea"], isActive: true }
|
|
67
|
+
|
|
68
|
+
it("is the same for the same listening settings, whatever their order, spacing or the node's other fields", async () => {
|
|
69
|
+
const { telegramAccountListeningSignature: sig } = await import("../telegram-account-trigger.js")
|
|
70
|
+
expect(sig({ ...base, label: "Inbox", chatTitles: { "777": "Saved Messages" } })).toBe(
|
|
71
|
+
sig({ isActive: true, keywords: [" idea "], chatIds: ["-1001", "777", "777"], accountId: "acc-1" }),
|
|
72
|
+
)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it("reads the account id exactly as written: a padded id is another, which never listens", async () => {
|
|
76
|
+
const { telegramAccountListeningSignature: sig } = await import("../telegram-account-trigger.js")
|
|
77
|
+
expect(sig({ ...base, accountId: " acc-1 " })).not.toBe(sig(base))
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it("changes with every setting the owner alone may set", async () => {
|
|
81
|
+
const { telegramAccountListeningSignature: sig } = await import("../telegram-account-trigger.js")
|
|
82
|
+
const changes: Array<Record<string, unknown>> = [
|
|
83
|
+
{ accountId: "acc-2" },
|
|
84
|
+
{ chatIds: ["777"] },
|
|
85
|
+
{ senderIds: ["555"] },
|
|
86
|
+
{ messageTypeFilters: ["video"] },
|
|
87
|
+
{ keywords: [] },
|
|
88
|
+
{ includeOutgoing: true },
|
|
89
|
+
{ inboxMode: true },
|
|
90
|
+
{ isActive: false },
|
|
91
|
+
]
|
|
92
|
+
for (const change of changes) expect(sig({ ...base, ...change }), JSON.stringify(change)).not.toBe(sig(base))
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it("reads anything that is not a node's data as nothing set", async () => {
|
|
96
|
+
const { telegramAccountListeningSignature: sig } = await import("../telegram-account-trigger.js")
|
|
97
|
+
expect(sig(undefined)).toBe(sig({}))
|
|
98
|
+
expect(sig("nonsense")).toBe(sig({}))
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it("in inbox mode the own-messages setting is moot: the owner's messages are heard either way", async () => {
|
|
102
|
+
const { telegramAccountListeningSignature: sig } = await import("../telegram-account-trigger.js")
|
|
103
|
+
expect(sig({ ...base, inboxMode: true, includeOutgoing: false })).toBe(sig({ ...base, inboxMode: true, includeOutgoing: true }))
|
|
104
|
+
expect(sig({ ...base, includeOutgoing: false })).not.toBe(sig({ ...base, includeOutgoing: true }))
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
describe("resolveFieldMappings — the wire's handle", () => {
|
|
109
|
+
it("reaches the source reader when the wire names it; an id alone still resolves", async () => {
|
|
110
|
+
const { resolveFieldMappings } = await import("../resolve-field-mappings.js")
|
|
111
|
+
const seen: Array<[string, string | null | undefined]> = []
|
|
112
|
+
const read = (id: string, handle?: string | null) => {
|
|
113
|
+
seen.push([id, handle])
|
|
114
|
+
return handle ? `${id}:${handle}` : id
|
|
115
|
+
}
|
|
116
|
+
expect(resolveFieldMappings({}, undefined, ["a"], read, () => ({ sourceNodeId: "n1", sourceHandle: "videoLink" })).a).toBe("n1:videoLink")
|
|
117
|
+
expect(resolveFieldMappings({}, undefined, ["a"], read, () => "n2").a).toBe("n2")
|
|
118
|
+
expect(seen).toEqual([["n1", "videoLink"], ["n2", undefined]])
|
|
119
|
+
})
|
|
120
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest"
|
|
2
2
|
import {
|
|
3
|
-
VIDEO_ANALYSIS_DURATION_BUCKETS, VIDEO_ANALYSIS_DURATION_TOLERANCE_SEC,
|
|
3
|
+
VIDEO_ANALYSIS_DURATION_BUCKETS, VIDEO_ANALYSIS_DURATION_TOLERANCE_SEC, VIDEO_ANALYSIS_BUCKET_GRACE_SEC,
|
|
4
4
|
VIDEO_ANALYSIS_BUCKET_CREDITS,
|
|
5
5
|
pickVideoAnalysisBucket, buildVideoAnalysisCreditId, bucketSecondsFromCreditId,
|
|
6
6
|
videoAnalysisNumWindows,
|
|
@@ -25,7 +25,14 @@ describe("video-analysis-pricing", () => {
|
|
|
25
25
|
it("buckets and ids", () => {
|
|
26
26
|
expect(VIDEO_ANALYSIS_DURATION_BUCKETS).toEqual([60, 180, 360, 600])
|
|
27
27
|
expect(pickVideoAnalysisBucket(59.6)).toBe(60)
|
|
28
|
-
|
|
28
|
+
// A part chosen as 1:00 downloads at about 1:03 (cut on keyframes): the
|
|
29
|
+
// bucket grace prices it as a minute. Past the grace, the next bucket.
|
|
30
|
+
expect(pickVideoAnalysisBucket(60.4)).toBe(60)
|
|
31
|
+
expect(pickVideoAnalysisBucket(63)).toBe(60)
|
|
32
|
+
expect(pickVideoAnalysisBucket(63.5)).toBe(180)
|
|
33
|
+
expect(pickVideoAnalysisBucket(183)).toBe(180)
|
|
34
|
+
expect(pickVideoAnalysisBucket(184)).toBe(360)
|
|
35
|
+
expect(buildVideoAnalysisCreditId("gemini-3.1-pro", 63)).toBe("video-analysis:gemini-3.1-pro:60s")
|
|
29
36
|
expect(buildVideoAnalysisCreditId("gemini-3-flash", 170)).toBe("video-analysis:gemini-3-flash:180s")
|
|
30
37
|
expect(buildVideoAnalysisCreditId("gemini-3.1-pro")).toBe("video-analysis:gemini-3.1-pro:600s") // unknown → ceiling
|
|
31
38
|
expect(bucketSecondsFromCreditId("video-analysis:gemini-3-flash:180s")).toBe(180)
|
|
@@ -38,8 +45,18 @@ describe("video-analysis-pricing", () => {
|
|
|
38
45
|
expect(videoAnalysisNumWindows(600)).toBe(5)
|
|
39
46
|
})
|
|
40
47
|
|
|
41
|
-
it("
|
|
42
|
-
expect(
|
|
48
|
+
it("the worker re-check tolerates the pricing grace PLUS float drift on top of it", () => {
|
|
49
|
+
expect(VIDEO_ANALYSIS_BUCKET_GRACE_SEC).toBe(3)
|
|
50
|
+
// A clip priced into a bucket by the grace (probe says 63 s → 60 s bucket)
|
|
51
|
+
// must not then fail the worker gate on ffprobe float drift (63.4 s): the
|
|
52
|
+
// worker allows bucket + tolerance, so the tolerance must exceed the grace.
|
|
53
|
+
expect(VIDEO_ANALYSIS_DURATION_TOLERANCE_SEC).toBe(6)
|
|
54
|
+
expect(VIDEO_ANALYSIS_DURATION_TOLERANCE_SEC - VIDEO_ANALYSIS_BUCKET_GRACE_SEC).toBeGreaterThanOrEqual(3)
|
|
55
|
+
for (const bucket of VIDEO_ANALYSIS_DURATION_BUCKETS) {
|
|
56
|
+
const pricedAt = bucket + VIDEO_ANALYSIS_BUCKET_GRACE_SEC
|
|
57
|
+
expect(pickVideoAnalysisBucket(pricedAt)).toBe(bucket)
|
|
58
|
+
expect(pricedAt + 2 <= bucket + VIDEO_ANALYSIS_DURATION_TOLERANCE_SEC).toBe(true)
|
|
59
|
+
}
|
|
43
60
|
})
|
|
44
61
|
|
|
45
62
|
it("model SSOT is capability-derived and Gemini-only today", () => {
|
|
@@ -154,17 +171,14 @@ describe("video-audit-pricing", () => {
|
|
|
154
171
|
expect(buildVideoAuditCreditId({ analysisProvided: true, durationSec: 360 })).toBe("video-audit:360s")
|
|
155
172
|
expect(buildVideoAuditCreditId({ analysisProvided: true, durationSec: 600 })).toBe("video-audit:600s")
|
|
156
173
|
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
// pickVideoAnalysisBucket / buildVideoAnalysisCreditId; any tolerance
|
|
161
|
-
// grace is a WORKER re-check concern, private to the plugin, never baked
|
|
162
|
-
// into this pure id builder).
|
|
174
|
+
// Boundary edges: the same bucket grace as pickVideoAnalysisBucket /
|
|
175
|
+
// buildVideoAnalysisCreditId (one ladder, one rule) — up to 63 s stays in
|
|
176
|
+
// the 60s bucket; 64 s moves to the next one.
|
|
163
177
|
expect(buildVideoAuditCreditId({ analysisProvided: true, durationSec: 60 })).toBe("video-audit:60s")
|
|
164
|
-
expect(buildVideoAuditCreditId({ analysisProvided: true, durationSec: 61 })).toBe("video-audit:
|
|
165
|
-
expect(buildVideoAuditCreditId({ analysisProvided: true, durationSec: 63 })).toBe("video-audit:
|
|
178
|
+
expect(buildVideoAuditCreditId({ analysisProvided: true, durationSec: 61 })).toBe("video-audit:60s")
|
|
179
|
+
expect(buildVideoAuditCreditId({ analysisProvided: true, durationSec: 63 })).toBe("video-audit:60s")
|
|
166
180
|
expect(buildVideoAuditCreditId({ analysisProvided: true, durationSec: 64 })).toBe("video-audit:180s")
|
|
167
|
-
expect(buildVideoAuditCreditId({ analysisProvided: false, durationSec: 61 })).toBe("video-audit:auto:
|
|
181
|
+
expect(buildVideoAuditCreditId({ analysisProvided: false, durationSec: 61 })).toBe("video-audit:auto:60s")
|
|
168
182
|
|
|
169
183
|
// No / invalid duration → 600s ceiling composite, both families — the
|
|
170
184
|
// ONLY silent-ceiling path, matching buildVideoAnalysisCreditId.
|
|
@@ -68,8 +68,8 @@ describe("links that URL parsers read differently", () => {
|
|
|
68
68
|
})
|
|
69
69
|
|
|
70
70
|
describe("consumers that do not need the video file", () => {
|
|
71
|
-
it("names exactly the
|
|
72
|
-
expect([...VIDEO_LINK_TOLERANT_CONSUMER_TYPES].sort()).toEqual(["dubbing", "suno-cover", "transcribe"])
|
|
71
|
+
it("names exactly the readers that take the audio track or the page link", () => {
|
|
72
|
+
expect([...VIDEO_LINK_TOLERANT_CONSUMER_TYPES].sort()).toEqual(["content-recipe", "dubbing", "suno-cover", "transcribe"])
|
|
73
73
|
})
|
|
74
74
|
})
|
|
75
75
|
|