@nodaro/shared 3.14.0 → 3.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/index.cjs +1679 -81
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +1822 -49
  4. package/dist/index.d.ts +1822 -49
  5. package/dist/index.js +1491 -82
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/__tests__/apply-edl-credit-id.test.ts +25 -0
  9. package/src/__tests__/camera-switch-contract.test.ts +98 -0
  10. package/src/__tests__/competitors.test.ts +49 -0
  11. package/src/__tests__/content-recipe-ideas.test.ts +96 -0
  12. package/src/__tests__/edl-multicam.test.ts +192 -0
  13. package/src/__tests__/exposed-field-keys.test.ts +78 -0
  14. package/src/__tests__/instagram-scrape.test.ts +62 -0
  15. package/src/__tests__/llm-models.test.ts +5 -2
  16. package/src/__tests__/music-provider.test.ts +17 -0
  17. package/src/__tests__/node-runtime-keys.test.ts +11 -0
  18. package/src/__tests__/parameter-node-value.test.ts +2 -1
  19. package/src/__tests__/per-unit-video-pricing.test.ts +97 -0
  20. package/src/__tests__/producer-types.test.ts +35 -0
  21. package/src/__tests__/saved-posts.test.ts +37 -0
  22. package/src/__tests__/script-settings.test.ts +61 -0
  23. package/src/__tests__/settings-input.test.ts +252 -0
  24. package/src/__tests__/social-search.test.ts +243 -0
  25. package/src/__tests__/studio-sequence-owner.test.ts +356 -0
  26. package/src/__tests__/studio-take-voice.test.ts +200 -0
  27. package/src/__tests__/studio-transient.test.ts +71 -0
  28. package/src/__tests__/sub-gates.test.ts +21 -0
  29. package/src/__tests__/telegram-account-trigger.test.ts +120 -0
  30. package/src/__tests__/text-to-audio-pricing.test.ts +71 -0
  31. package/src/__tests__/tts-capabilities.test.ts +237 -0
  32. package/src/__tests__/video-analysis-pricing.test.ts +27 -13
  33. package/src/__tests__/video-link.test.ts +2 -2
  34. package/src/__tests__/video-utils.test.ts +89 -83
  35. package/src/__tests__/workflow-export-strip.test.ts +37 -0
  36. package/src/camera-switch-contract.ts +166 -0
  37. package/src/catalog-projection.ts +7 -0
  38. package/src/competitors.ts +430 -0
  39. package/src/content-recipe-ideas.ts +69 -0
  40. package/src/credit-estimators/index.ts +21 -0
  41. package/src/credit-estimators/ltx-extend.ts +33 -0
  42. package/src/credit-estimators/ltx-retake.ts +30 -0
  43. package/src/credit-estimators/text-to-audio.ts +58 -0
  44. package/src/credit-estimators/video-sfx.ts +41 -0
  45. package/src/credit-estimators/video-utils.ts +38 -24
  46. package/src/credit-identifiers.ts +22 -0
  47. package/src/edl-multicam.ts +220 -0
  48. package/src/exposed-field-keys.ts +49 -0
  49. package/src/fan-out-rows.ts +7 -2
  50. package/src/i18n/action-fx.ko.ts +18 -18
  51. package/src/i18n/action-fx.pt-BR.ts +66 -66
  52. package/src/i18n/aesthetic.ko.ts +49 -49
  53. package/src/i18n/aesthetic.pt-BR.ts +14 -14
  54. package/src/i18n/animals.ko.ts +126 -126
  55. package/src/i18n/animals.pt-BR.ts +33 -33
  56. package/src/i18n/atmosphere.ko.ts +37 -37
  57. package/src/i18n/atmosphere.pt-BR.ts +29 -29
  58. package/src/i18n/backdrop.ko.ts +40 -40
  59. package/src/i18n/backdrop.pt-BR.ts +38 -38
  60. package/src/i18n/camera-format.ko.ts +31 -31
  61. package/src/i18n/camera-format.pt-BR.ts +12 -12
  62. package/src/i18n/camera-motions.ko.ts +66 -66
  63. package/src/i18n/camera-motions.pt-BR.ts +51 -51
  64. package/src/i18n/character-fx.ko.ts +19 -19
  65. package/src/i18n/character-fx.pt-BR.ts +64 -52
  66. package/src/i18n/character-motion.ko.ts +164 -164
  67. package/src/i18n/character-motion.pt-BR.ts +867 -858
  68. package/src/i18n/color-look.ko.ts +41 -41
  69. package/src/i18n/color-look.pt-BR.ts +23 -23
  70. package/src/i18n/composition-effects.ko.ts +18 -18
  71. package/src/i18n/composition-effects.pt-BR.ts +17 -17
  72. package/src/i18n/era.ko.ts +28 -28
  73. package/src/i18n/era.pt-BR.ts +20 -20
  74. package/src/i18n/exposure-settings.ko.ts +20 -20
  75. package/src/i18n/exposure-settings.pt-BR.ts +3 -3
  76. package/src/i18n/framing.ko.ts +66 -66
  77. package/src/i18n/framing.pt-BR.ts +50 -50
  78. package/src/i18n/furniture.ko.ts +78 -78
  79. package/src/i18n/furniture.pt-BR.ts +46 -46
  80. package/src/i18n/held-prop.ko.ts +60 -60
  81. package/src/i18n/held-prop.pt-BR.ts +30 -30
  82. package/src/i18n/instrumentation.ko.ts +62 -62
  83. package/src/i18n/instrumentation.pt-BR.ts +64 -64
  84. package/src/i18n/lens.ko.ts +16 -16
  85. package/src/i18n/lens.pt-BR.ts +5 -5
  86. package/src/i18n/lighting.ko.ts +68 -68
  87. package/src/i18n/lighting.pt-BR.ts +43 -43
  88. package/src/i18n/loop-subject.ko.ts +1 -1
  89. package/src/i18n/loop-subject.pt-BR.ts +31 -31
  90. package/src/i18n/materials.ko.ts +66 -66
  91. package/src/i18n/materials.pt-BR.ts +22 -22
  92. package/src/i18n/mood.ko.ts +50 -50
  93. package/src/i18n/mood.pt-BR.ts +12 -12
  94. package/src/i18n/music-genre.ko.ts +28 -28
  95. package/src/i18n/music-genre.pt-BR.ts +50 -50
  96. package/src/i18n/music-mood.ko.ts +27 -27
  97. package/src/i18n/music-mood.pt-BR.ts +20 -20
  98. package/src/i18n/person.ko.ts +396 -396
  99. package/src/i18n/person.pt-BR.ts +237 -237
  100. package/src/i18n/photo-genre.ko.ts +46 -46
  101. package/src/i18n/photo-genre.pt-BR.ts +32 -32
  102. package/src/i18n/photographer.ko.ts +63 -63
  103. package/src/i18n/photographer.pt-BR.ts +15 -15
  104. package/src/i18n/pose.ko.ts +81 -81
  105. package/src/i18n/pose.pt-BR.ts +65 -65
  106. package/src/i18n/post-process-effects.ko.ts +18 -18
  107. package/src/i18n/post-process-effects.pt-BR.ts +18 -18
  108. package/src/i18n/render-quality.ko.ts +24 -24
  109. package/src/i18n/render-quality.pt-BR.ts +12 -12
  110. package/src/i18n/setting.ko.ts +64 -64
  111. package/src/i18n/setting.pt-BR.ts +41 -41
  112. package/src/i18n/style.ko.ts +49 -49
  113. package/src/i18n/style.pt-BR.ts +19 -19
  114. package/src/i18n/styling.ko.ts +265 -265
  115. package/src/i18n/styling.pt-BR.ts +141 -141
  116. package/src/i18n/temporal.ko.ts +18 -18
  117. package/src/i18n/temporal.pt-BR.ts +12 -12
  118. package/src/i18n/transitions.ko.ts +14 -14
  119. package/src/i18n/transitions.pt-BR.ts +83 -71
  120. package/src/i18n/vehicles.ko.ts +107 -107
  121. package/src/i18n/vehicles.pt-BR.ts +55 -55
  122. package/src/i18n/voice-character.ko.ts +19 -19
  123. package/src/i18n/voice-character.pt-BR.ts +19 -19
  124. package/src/i18n/voice-delivery.ko.ts +22 -22
  125. package/src/i18n/voice-delivery.pt-BR.ts +22 -22
  126. package/src/i18n/weapons.ko.ts +85 -85
  127. package/src/i18n/weapons.pt-BR.ts +46 -46
  128. package/src/index.ts +236 -1
  129. package/src/instagram-scrape.ts +91 -16
  130. package/src/llm-models.ts +11 -0
  131. package/src/model-catalog.ts +151 -16
  132. package/src/model-constants.ts +54 -16
  133. package/src/node-mappable-fields.ts +21 -5
  134. package/src/node-runtime-keys.ts +45 -0
  135. package/src/oauth-scopes.ts +28 -0
  136. package/src/parameter-node-value.ts +13 -5
  137. package/src/pipeline-defaults.ts +14 -0
  138. package/src/pipeline-state-types.ts +14 -0
  139. package/src/presentation-utils.ts +5 -1
  140. package/src/producer-types.ts +85 -0
  141. package/src/recast-segment-packs.ts +13 -0
  142. package/src/resolve-field-mappings.ts +15 -5
  143. package/src/saved-posts.ts +106 -0
  144. package/src/script-settings.ts +70 -0
  145. package/src/settings-input.ts +366 -0
  146. package/src/social-search.ts +467 -0
  147. package/src/studio-transient.ts +479 -7
  148. package/src/telegram-account-send.ts +32 -0
  149. package/src/telegram-account-trigger.ts +108 -0
  150. package/src/tts-capabilities.ts +75 -0
  151. package/src/video-analysis-pricing.ts +17 -6
  152. package/src/video-link.ts +16 -4
  153. 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,11 @@
1
1
  import { describe, it, expect } from "vitest"
2
2
 
3
3
  import {
4
+ STUDIO_PREVIZ_RUN_STATE_KEYS,
5
+ STUDIO_SHOT_DRAFT_KEYS,
4
6
  STUDIO_SHOT_TRANSIENT_KEYS,
5
7
  STUDIO_TRANSIENT_KEYS,
8
+ stripStudioDraftSettings,
6
9
  stripStudioTransientSettings,
7
10
  } from "../studio-transient.js"
8
11
 
@@ -185,6 +188,69 @@ describe("stripStudioTransientSettings", () => {
185
188
  expect(out.version).toBe(3)
186
189
  })
187
190
 
191
+ it("drops a shot's empty media slots — the owner's drafts, never a viewer's (T11)", () => {
192
+ const settings = { studio: { version: 3, shots: [
193
+ { id: "s1", imageNodeId: "img-1", stillSlots: [{ id: "slot-1", inputs: { prompt: "an unsent idea" } }],
194
+ clipSlots: [{ id: "slot-2", inputs: {} }],
195
+ // A run started from a slot: its marker carries the slot's inputs.
196
+ pendingStills: [{ jobId: "job-1", startedAt: 1, slotId: "slot-1", prompt: "an unsent idea" }] },
197
+ { id: "s2" },
198
+ ] } }
199
+ const shots = studioOf(stripStudioTransientSettings(settings)).shots
200
+ expect(shots).toEqual([{ id: "s1", imageNodeId: "img-1" }, { id: "s2" }])
201
+ })
202
+
203
+ it("stripStudioDraftSettings drops a shot's slots AND its in-flight runs — a `view` read keeps the rest", () => {
204
+ // The per-shot run markers go with the slots: a viewer cannot land the
205
+ // owner's runs, and a slot-tagged marker carries that slot's unsent inputs.
206
+ // The bin and the document-level markers stay (the bin loses only the
207
+ // owner's drafts in it — `studio-take-voice.test.ts`).
208
+ const settings = { studio: { version: 3, trash: [{ id: "t-1" }], pendingMusic: { jobId: "job-9" }, shots: [
209
+ { id: "s1", pendingClips: [{ jobId: "job-1" }], pendingClip: { jobId: "job-0" },
210
+ pendingStills: [{ jobId: "job-2", startedAt: 1, slotId: "slot-1", prompt: "an unsent idea" }],
211
+ stillSlots: [{ id: "slot-1", inputs: {} }], clipSlots: [{ id: "slot-2", inputs: {} }] },
212
+ ] } }
213
+ expect(stripStudioDraftSettings(settings)).toEqual({ studio: { version: 3, trash: [{ id: "t-1" }],
214
+ pendingMusic: { jobId: "job-9" }, shots: [{ id: "s1" }] } })
215
+ // A marker alone — no slot on the scene — goes too.
216
+ const runOnly = { studio: { version: 3, shots: [{ id: "s1", pendingStills: [{ jobId: "job-3" }] }] } }
217
+ expect(stripStudioDraftSettings(runOnly)).toEqual({ studio: { version: 3, shots: [{ id: "s1" }] } })
218
+ const none = { studio: { version: 3, shots: [{ id: "s1" }] } }
219
+ expect(stripStudioDraftSettings(none)).toBe(none)
220
+ expect(stripStudioDraftSettings(null)).toBeNull()
221
+ })
222
+
223
+ it("drops a scene's 3D run state — its jobs in flight and its Pro submission — and keeps its finished renders", () => {
224
+ // The studio codec's own non-owner projection (`stripTransientSettings`)
225
+ // drops these two; the public share read must not hand out what the
226
+ // codec withholds. The codec's fixture shape, plus a Pro submission.
227
+ const settings = { studio: { version: 3, shots: [{ id: "s1", previsualization: {
228
+ pendingJobs: [{ jobId: "private-job" }],
229
+ proSubmission: { idempotencyKey: "pro-key-1", body: { kind: "scene", sceneRevisionId: "rev-1" } },
230
+ renders: [{ url: "https://cdn/blockout.mp4" }],
231
+ pendingPlan: { revisionId: "rev-2" },
232
+ sceneNodeId: "scene-node",
233
+ } }] } }
234
+ const before = JSON.stringify(settings)
235
+ expect(stripStudioTransientSettings(settings)).toEqual({ studio: { version: 3, shots: [{ id: "s1", previsualization: {
236
+ renders: [{ url: "https://cdn/blockout.mp4" }],
237
+ pendingPlan: { revisionId: "rev-2" },
238
+ sceneNodeId: "scene-node",
239
+ } }] } })
240
+ expect(JSON.stringify(settings)).toBe(before)
241
+ // Each key on its own is enough to strip.
242
+ const proOnly = { studio: { shots: [{ id: "s1", previsualization: { proSubmission: { idempotencyKey: "k" } } }] } }
243
+ expect(stripStudioTransientSettings(proOnly)).toEqual({ studio: { shots: [{ id: "s1", previsualization: {} }] } })
244
+ // A scene with a previsualization and no run state is handed back as it is.
245
+ const idle = { studio: { shots: [{ id: "s1", previsualization: { renders: [{ url: "u" }] } }] } }
246
+ expect(stripStudioTransientSettings(idle)).toBe(idle)
247
+ })
248
+
249
+ it("a `view` read keeps a scene's 3D run state, as the codec's read-only load does", () => {
250
+ const settings = { studio: { shots: [{ id: "s1", previsualization: { pendingJobs: [{ jobId: "j" }], proSubmission: { idempotencyKey: "k" } } }] } }
251
+ expect(stripStudioDraftSettings(settings)).toBe(settings)
252
+ })
253
+
188
254
  it("pins the two lists — a key added to the type alone strips nothing", () => {
189
255
  // The lists are the contract: the codec's own strip re-exports them, so a
190
256
  // key that falls off here falls off there too, silently, on both sides.
@@ -201,5 +267,10 @@ describe("stripStudioTransientSettings", () => {
201
267
  "pendingClip",
202
268
  "pendingStills",
203
269
  ])
270
+ // The owner's drafts are a list of their own: the export projection reads
271
+ // the transient list, and the owner's exports keep their slots.
272
+ expect([...STUDIO_SHOT_DRAFT_KEYS]).toEqual(["stillSlots", "clipSlots"])
273
+ // The 3D run state the codec's non-owner projection drops.
274
+ expect([...STUDIO_PREVIZ_RUN_STATE_KEYS]).toEqual(["pendingJobs", "proSubmission"])
204
275
  })
205
276
  })
@@ -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
+ })
@@ -0,0 +1,71 @@
1
+ import { describe, it, expect } from "vitest"
2
+ import {
3
+ TEXT_TO_AUDIO_PRICING,
4
+ TEXT_TO_AUDIO_SFX_CREDIT_IDS,
5
+ textToAudioBilledSeconds,
6
+ textToAudioCreditId,
7
+ } from "../credit-estimators/index.js"
8
+
9
+ describe("textToAudioBilledSeconds — whole seconds, rounded up", () => {
10
+ it.each([
11
+ [0.5, 1],
12
+ [1, 1],
13
+ [1.2, 2],
14
+ [10, 10],
15
+ [22, 22],
16
+ [22.3, 23],
17
+ [30, 30],
18
+ ])("%s s bills %i s", (duration, billed) => {
19
+ expect(textToAudioBilledSeconds(duration)).toBe(billed)
20
+ })
21
+
22
+ it.each([[undefined], [null], [0], [-3], [Number.NaN], [Number.POSITIVE_INFINITY], ["abc"], [""]])(
23
+ "no usable duration (%s) bills the default %i s",
24
+ (duration) => {
25
+ expect(textToAudioBilledSeconds(duration)).toBe(TEXT_TO_AUDIO_PRICING.DEFAULT_BILLED_SEC)
26
+ expect(TEXT_TO_AUDIO_PRICING.DEFAULT_BILLED_SEC).toBe(5)
27
+ },
28
+ )
29
+
30
+ it("reads a numeric string (a field mapping can deliver one)", () => {
31
+ expect(textToAudioBilledSeconds("7.5")).toBe(8)
32
+ })
33
+
34
+ it("never bills past the longest clip the model makes", () => {
35
+ expect(textToAudioBilledSeconds(45)).toBe(30)
36
+ })
37
+ })
38
+
39
+ describe("textToAudioCreditId — the price row a Text to Audio run is charged from", () => {
40
+ it.each([
41
+ [0.5, "elevenlabs-sfx:1s"],
42
+ [6, "elevenlabs-sfx:6s"],
43
+ [10, "elevenlabs-sfx:10s"],
44
+ [22, "elevenlabs-sfx:22s"],
45
+ [30, "elevenlabs-sfx:30s"],
46
+ ])("%s s → %s", (duration, id) => {
47
+ expect(textToAudioCreditId("elevenlabs-sfx", duration)).toBe(id)
48
+ })
49
+
50
+ it("no duration → the 5 s row", () => {
51
+ expect(textToAudioCreditId("elevenlabs-sfx", undefined)).toBe("elevenlabs-sfx:5s")
52
+ })
53
+
54
+ it("no provider → the default engine's row", () => {
55
+ expect(textToAudioCreditId(undefined, 8)).toBe("elevenlabs-sfx:8s")
56
+ expect(textToAudioCreditId("", undefined)).toBe("elevenlabs-sfx:5s")
57
+ })
58
+
59
+ it("an engine not priced per second keeps its own row", () => {
60
+ expect(textToAudioCreditId("tangoflux", 8)).toBe("tangoflux")
61
+ })
62
+
63
+ it("every id it can return is in the published per-second id list (1 s … 30 s)", () => {
64
+ expect(TEXT_TO_AUDIO_SFX_CREDIT_IDS).toHaveLength(30)
65
+ expect(TEXT_TO_AUDIO_SFX_CREDIT_IDS[0]).toBe("elevenlabs-sfx:1s")
66
+ expect(TEXT_TO_AUDIO_SFX_CREDIT_IDS[29]).toBe("elevenlabs-sfx:30s")
67
+ for (const d of [undefined, 0.5, 1, 4.2, 22, 30, 99]) {
68
+ expect(TEXT_TO_AUDIO_SFX_CREDIT_IDS).toContain(textToAudioCreditId("elevenlabs-sfx", d))
69
+ }
70
+ })
71
+ })