@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.
Files changed (142) hide show
  1. package/dist/index.cjs +1293 -55
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +1502 -30
  4. package/dist/index.d.ts +1502 -30
  5. package/dist/index.js +1134 -56
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/__tests__/camera-switch-contract.test.ts +98 -0
  9. package/src/__tests__/competitors.test.ts +49 -0
  10. package/src/__tests__/content-recipe-ideas.test.ts +96 -0
  11. package/src/__tests__/edl-multicam.test.ts +192 -0
  12. package/src/__tests__/llm-models.test.ts +5 -2
  13. package/src/__tests__/music-provider.test.ts +17 -0
  14. package/src/__tests__/node-runtime-keys.test.ts +10 -0
  15. package/src/__tests__/parameter-node-value.test.ts +2 -1
  16. package/src/__tests__/per-unit-video-pricing.test.ts +97 -0
  17. package/src/__tests__/producer-types.test.ts +35 -0
  18. package/src/__tests__/saved-posts.test.ts +37 -0
  19. package/src/__tests__/script-settings.test.ts +61 -0
  20. package/src/__tests__/settings-input.test.ts +252 -0
  21. package/src/__tests__/social-search.test.ts +243 -0
  22. package/src/__tests__/studio-take-voice.test.ts +200 -0
  23. package/src/__tests__/studio-transient.test.ts +37 -0
  24. package/src/__tests__/sub-gates.test.ts +21 -0
  25. package/src/__tests__/telegram-account-trigger.test.ts +120 -0
  26. package/src/__tests__/video-analysis-pricing.test.ts +27 -13
  27. package/src/__tests__/video-link.test.ts +2 -2
  28. package/src/__tests__/video-utils.test.ts +89 -83
  29. package/src/__tests__/workflow-export-strip.test.ts +37 -0
  30. package/src/camera-switch-contract.ts +166 -0
  31. package/src/catalog-projection.ts +27 -0
  32. package/src/competitors.ts +430 -0
  33. package/src/content-recipe-ideas.ts +69 -0
  34. package/src/credit-estimators/index.ts +14 -0
  35. package/src/credit-estimators/ltx-extend.ts +33 -0
  36. package/src/credit-estimators/ltx-retake.ts +30 -0
  37. package/src/credit-estimators/video-sfx.ts +41 -0
  38. package/src/credit-estimators/video-utils.ts +38 -24
  39. package/src/credit-identifiers.ts +10 -0
  40. package/src/edl-multicam.ts +220 -0
  41. package/src/fan-out-rows.ts +7 -2
  42. package/src/i18n/action-fx.ko.ts +18 -18
  43. package/src/i18n/action-fx.pt-BR.ts +66 -66
  44. package/src/i18n/aesthetic.ko.ts +49 -49
  45. package/src/i18n/aesthetic.pt-BR.ts +14 -14
  46. package/src/i18n/animals.ko.ts +126 -126
  47. package/src/i18n/animals.pt-BR.ts +33 -33
  48. package/src/i18n/atmosphere.ko.ts +37 -37
  49. package/src/i18n/atmosphere.pt-BR.ts +29 -29
  50. package/src/i18n/backdrop.ko.ts +40 -40
  51. package/src/i18n/backdrop.pt-BR.ts +38 -38
  52. package/src/i18n/camera-format.ko.ts +31 -31
  53. package/src/i18n/camera-format.pt-BR.ts +12 -12
  54. package/src/i18n/camera-motions.ko.ts +66 -66
  55. package/src/i18n/camera-motions.pt-BR.ts +51 -51
  56. package/src/i18n/character-fx.ko.ts +19 -19
  57. package/src/i18n/character-fx.pt-BR.ts +64 -52
  58. package/src/i18n/character-motion.ko.ts +164 -164
  59. package/src/i18n/character-motion.pt-BR.ts +867 -858
  60. package/src/i18n/color-look.ko.ts +41 -41
  61. package/src/i18n/color-look.pt-BR.ts +23 -23
  62. package/src/i18n/composition-effects.ko.ts +18 -18
  63. package/src/i18n/composition-effects.pt-BR.ts +17 -17
  64. package/src/i18n/era.ko.ts +28 -28
  65. package/src/i18n/era.pt-BR.ts +20 -20
  66. package/src/i18n/exposure-settings.ko.ts +20 -20
  67. package/src/i18n/exposure-settings.pt-BR.ts +3 -3
  68. package/src/i18n/framing.ko.ts +66 -66
  69. package/src/i18n/framing.pt-BR.ts +50 -50
  70. package/src/i18n/furniture.ko.ts +78 -78
  71. package/src/i18n/furniture.pt-BR.ts +46 -46
  72. package/src/i18n/held-prop.ko.ts +60 -60
  73. package/src/i18n/held-prop.pt-BR.ts +30 -30
  74. package/src/i18n/instrumentation.ko.ts +62 -62
  75. package/src/i18n/instrumentation.pt-BR.ts +64 -64
  76. package/src/i18n/lens.ko.ts +16 -16
  77. package/src/i18n/lens.pt-BR.ts +5 -5
  78. package/src/i18n/lighting.ko.ts +68 -68
  79. package/src/i18n/lighting.pt-BR.ts +43 -43
  80. package/src/i18n/loop-subject.ko.ts +1 -1
  81. package/src/i18n/loop-subject.pt-BR.ts +31 -31
  82. package/src/i18n/materials.ko.ts +66 -66
  83. package/src/i18n/materials.pt-BR.ts +22 -22
  84. package/src/i18n/mood.ko.ts +50 -50
  85. package/src/i18n/mood.pt-BR.ts +12 -12
  86. package/src/i18n/music-genre.ko.ts +28 -28
  87. package/src/i18n/music-genre.pt-BR.ts +50 -50
  88. package/src/i18n/music-mood.ko.ts +27 -27
  89. package/src/i18n/music-mood.pt-BR.ts +20 -20
  90. package/src/i18n/person.ko.ts +396 -396
  91. package/src/i18n/person.pt-BR.ts +237 -237
  92. package/src/i18n/photo-genre.ko.ts +46 -46
  93. package/src/i18n/photo-genre.pt-BR.ts +32 -32
  94. package/src/i18n/photographer.ko.ts +63 -63
  95. package/src/i18n/photographer.pt-BR.ts +15 -15
  96. package/src/i18n/pose.ko.ts +81 -81
  97. package/src/i18n/pose.pt-BR.ts +65 -65
  98. package/src/i18n/post-process-effects.ko.ts +18 -18
  99. package/src/i18n/post-process-effects.pt-BR.ts +18 -18
  100. package/src/i18n/render-quality.ko.ts +24 -24
  101. package/src/i18n/render-quality.pt-BR.ts +12 -12
  102. package/src/i18n/setting.ko.ts +64 -64
  103. package/src/i18n/setting.pt-BR.ts +41 -41
  104. package/src/i18n/style.ko.ts +49 -49
  105. package/src/i18n/style.pt-BR.ts +19 -19
  106. package/src/i18n/styling.ko.ts +265 -265
  107. package/src/i18n/styling.pt-BR.ts +141 -141
  108. package/src/i18n/temporal.ko.ts +18 -18
  109. package/src/i18n/temporal.pt-BR.ts +12 -12
  110. package/src/i18n/transitions.ko.ts +14 -14
  111. package/src/i18n/transitions.pt-BR.ts +83 -71
  112. package/src/i18n/vehicles.ko.ts +107 -107
  113. package/src/i18n/vehicles.pt-BR.ts +55 -55
  114. package/src/i18n/voice-character.ko.ts +19 -19
  115. package/src/i18n/voice-character.pt-BR.ts +19 -19
  116. package/src/i18n/voice-delivery.ko.ts +22 -22
  117. package/src/i18n/voice-delivery.pt-BR.ts +22 -22
  118. package/src/i18n/weapons.ko.ts +85 -85
  119. package/src/i18n/weapons.pt-BR.ts +46 -46
  120. package/src/index.ts +202 -1
  121. package/src/llm-models.ts +11 -0
  122. package/src/model-catalog.ts +30 -14
  123. package/src/model-constants.ts +28 -0
  124. package/src/node-mappable-fields.ts +21 -5
  125. package/src/node-runtime-keys.ts +33 -0
  126. package/src/oauth-scopes.ts +28 -0
  127. package/src/parameter-node-value.ts +13 -5
  128. package/src/pipeline-defaults.ts +14 -0
  129. package/src/pipeline-state-types.ts +14 -0
  130. package/src/producer-types.ts +85 -0
  131. package/src/recast-segment-packs.ts +13 -0
  132. package/src/resolve-field-mappings.ts +15 -5
  133. package/src/saved-posts.ts +106 -0
  134. package/src/script-settings.ts +70 -0
  135. package/src/settings-input.ts +366 -0
  136. package/src/social-search.ts +467 -0
  137. package/src/studio-transient.ts +176 -5
  138. package/src/telegram-account-send.ts +32 -0
  139. package/src/telegram-account-trigger.ts +108 -0
  140. package/src/video-analysis-pricing.ts +17 -6
  141. package/src/video-link.ts +16 -4
  142. package/src/workflow-export.ts +7 -0
@@ -14,30 +14,30 @@ import { assembleNarratedVideoCredits } from "../credit-estimators/video-utils.j
14
14
  describe("estimateLoopVideoCredits", () => {
15
15
  describe("repeat mode", () => {
16
16
  it("uses upstream duration when provided", () => {
17
- // 4× a 5s clip = 20s output → ceil(20/5) = 4
18
- expect(estimateLoopVideoCredits({ mode: "repeat", repeatCount: 4 }, 5)).toBe(4)
17
+ // 4× a 5s clip = 20s output → ceil(20/5) = 4 units × 10 credits
18
+ expect(estimateLoopVideoCredits({ mode: "repeat", repeatCount: 4 }, 5)).toBe(40)
19
19
  })
20
20
 
21
21
  it("falls back to 8s per repeat when upstream duration is missing", () => {
22
- // 4 × 8 = 32s → ceil(32/5) = 7
23
- expect(estimateLoopVideoCredits({ mode: "repeat", repeatCount: 4 })).toBe(7)
22
+ // 4 × 8 = 32s → ceil(32/5) = 7 units × 10 credits
23
+ expect(estimateLoopVideoCredits({ mode: "repeat", repeatCount: 4 })).toBe(70)
24
24
  })
25
25
 
26
26
  it("defaults repeatCount to 2 when missing", () => {
27
- // 2 × 8 = 16s → ceil(16/5) = 4
28
- expect(estimateLoopVideoCredits({ mode: "repeat" })).toBe(4)
27
+ // 2 × 8 = 16s → ceil(16/5) = 4 units × 10 credits
28
+ expect(estimateLoopVideoCredits({ mode: "repeat" })).toBe(40)
29
29
  })
30
30
  })
31
31
 
32
32
  describe("duration mode", () => {
33
33
  it("uses targetDuration regardless of upstream", () => {
34
- // ceil(60/5) = 12
35
- expect(estimateLoopVideoCredits({ mode: "duration", targetDuration: 60 }, 5)).toBe(12)
34
+ // ceil(60/5) = 12 units × 10 credits
35
+ expect(estimateLoopVideoCredits({ mode: "duration", targetDuration: 60 }, 5)).toBe(120)
36
36
  })
37
37
 
38
38
  it("defaults targetDuration to fallback when missing", () => {
39
- // ceil(8/5) = 2
40
- expect(estimateLoopVideoCredits({ mode: "duration" })).toBe(2)
39
+ // ceil(8/5) = 2 units × 10 credits
40
+ expect(estimateLoopVideoCredits({ mode: "duration" })).toBe(20)
41
41
  })
42
42
  })
43
43
 
@@ -47,15 +47,15 @@ describe("estimateLoopVideoCredits", () => {
47
47
  expect(estimateLoopVideoCredits({
48
48
  mode: "duration", targetDuration: 30,
49
49
  smartLoopCutBeforeRepeat: true, smartLoopCutLookback: 16,
50
- })).toBe(7)
50
+ })).toBe(70)
51
51
  })
52
52
 
53
53
  it("uses default lookback 16 when smart-cut on but lookback missing", () => {
54
- // 60s base = 12, default lookback 16 → +1 = 13
54
+ // 60s base = 12, default lookback 16 → +1 = 13 units × 10 credits
55
55
  expect(estimateLoopVideoCredits({
56
56
  mode: "duration", targetDuration: 60,
57
57
  smartLoopCutBeforeRepeat: true,
58
- })).toBe(13)
58
+ })).toBe(130)
59
59
  })
60
60
 
61
61
  it("max lookback 64 stays within bound", () => {
@@ -63,26 +63,27 @@ describe("estimateLoopVideoCredits", () => {
63
63
  expect(estimateLoopVideoCredits({
64
64
  mode: "duration", targetDuration: 60,
65
65
  smartLoopCutBeforeRepeat: true, smartLoopCutLookback: 64,
66
- })).toBe(15)
66
+ })).toBe(150)
67
67
  })
68
68
 
69
69
  it("does NOT add when smartLoopCutBeforeRepeat is false", () => {
70
70
  expect(estimateLoopVideoCredits({
71
71
  mode: "duration", targetDuration: 60,
72
72
  smartLoopCutBeforeRepeat: false, smartLoopCutLookback: 64,
73
- })).toBe(12)
73
+ })).toBe(120)
74
74
  })
75
75
  })
76
76
 
77
77
  describe("min-1 floor", () => {
78
- it("never returns 0 — even for sub-second output", () => {
79
- expect(estimateLoopVideoCredits({ mode: "duration", targetDuration: 0.5 })).toBe(1)
78
+ it("never returns less than one unit — even for sub-second output", () => {
79
+ expect(estimateLoopVideoCredits({ mode: "duration", targetDuration: 0.5 })).toBe(10)
80
80
  })
81
81
  })
82
82
 
83
83
  describe("constants", () => {
84
84
  it("exports the expected pricing constants", () => {
85
- expect(VIDEO_UTIL_PRICING.CREDITS_PER_5_SEC).toBe(1)
85
+ expect(VIDEO_UTIL_PRICING.CREDIT_UNIT).toBe(10)
86
+ expect(VIDEO_UTIL_PRICING.CREDITS_PER_5_SEC).toBe(10)
86
87
  expect(VIDEO_UTIL_PRICING.FRAMES_PER_CREDIT).toBe(24)
87
88
  expect(VIDEO_UTIL_PRICING.FALLBACK_DURATION_SECONDS).toBe(8)
88
89
  })
@@ -92,101 +93,101 @@ describe("estimateLoopVideoCredits", () => {
92
93
  describe("estimateTrimVideoCredits", () => {
93
94
  describe("time mode (default)", () => {
94
95
  it("computes credits from endTime - startTime", () => {
95
- // 0–10s = 10s → ceil(10/5) = 2
96
- expect(estimateTrimVideoCredits({ trimMode: "time", startTime: 0, endTime: 10 })).toBe(2)
96
+ // 0–10s = 10s → ceil(10/5) = 2 units × 10 credits
97
+ expect(estimateTrimVideoCredits({ trimMode: "time", startTime: 0, endTime: 10 })).toBe(20)
97
98
  })
98
99
 
99
100
  it("treats missing trimMode as time mode", () => {
100
- // ceil(15/5) = 3
101
- expect(estimateTrimVideoCredits({ startTime: 5, endTime: 20 })).toBe(3)
101
+ // ceil(15/5) = 3 units × 10 credits
102
+ expect(estimateTrimVideoCredits({ startTime: 5, endTime: 20 })).toBe(30)
102
103
  })
103
104
 
104
105
  it("defaults missing start/end to 0", () => {
105
- // 0-0 = 0s, but min-1 → 1
106
- expect(estimateTrimVideoCredits({ trimMode: "time" })).toBe(1)
106
+ // 0-0 = 0s, but min-1 → 1 unit × 10 credits
107
+ expect(estimateTrimVideoCredits({ trimMode: "time" })).toBe(10)
107
108
  })
108
109
  })
109
110
 
110
111
  describe("frames mode", () => {
111
112
  it("subtracts trim frames from upstream duration at 24fps", () => {
112
- // 10s upstream - 24/24 - 24/24 = 8s → ceil(8/5) = 2
113
+ // 10s upstream - 24/24 - 24/24 = 8s → ceil(8/5) = 2 units × 10 credits
113
114
  expect(estimateTrimVideoCredits({
114
115
  trimMode: "frames", trimStartFrames: 24, trimEndFrames: 24,
115
- }, 10)).toBe(2)
116
+ }, 10)).toBe(20)
116
117
  })
117
118
 
118
119
  it("uses 8s fallback when upstream missing", () => {
119
- // 8s - 0 - 0 = 8s → ceil(8/5) = 2
120
- expect(estimateTrimVideoCredits({ trimMode: "frames" })).toBe(2)
120
+ // 8s - 0 - 0 = 8s → ceil(8/5) = 2 units × 10 credits
121
+ expect(estimateTrimVideoCredits({ trimMode: "frames" })).toBe(20)
121
122
  })
122
123
 
123
124
  it("clamps to 0 if frame trim exceeds duration", () => {
124
- // 5s - 240/24 - 0 = -5 clamped to 0 → max(1, ceil(0)) = 1
125
+ // 5s - 240/24 - 0 = -5 clamped to 0 → max(1, ceil(0)) = 1 unit × 10 credits
125
126
  expect(estimateTrimVideoCredits({
126
127
  trimMode: "frames", trimStartFrames: 240, trimEndFrames: 0,
127
- }, 5)).toBe(1)
128
+ }, 5)).toBe(10)
128
129
  })
129
130
  })
130
131
 
131
132
  describe("smart-loop-cut mode", () => {
132
133
  it("upstream-based base + lookback adder", () => {
133
- // 10s upstream → base 2, lookback 16 → +1 = 3
134
+ // 10s upstream → base 2, lookback 16 → +1 = 3 units × 10 credits
134
135
  expect(estimateTrimVideoCredits({
135
136
  trimMode: "smart-loop-cut", smartLoopCutLookback: 16,
136
- }, 10)).toBe(3)
137
+ }, 10)).toBe(30)
137
138
  })
138
139
 
139
140
  it("uses default lookback 16 when missing", () => {
140
- // 8s upstream → base 2, default 16 → +1 = 3
141
- expect(estimateTrimVideoCredits({ trimMode: "smart-loop-cut" })).toBe(3)
141
+ // 8s upstream → base 2, default 16 → +1 = 3 units × 10 credits
142
+ expect(estimateTrimVideoCredits({ trimMode: "smart-loop-cut" })).toBe(30)
142
143
  })
143
144
  })
144
145
 
145
146
  describe("seconds mode (relative trim in seconds)", () => {
146
147
  it("subtracts trim seconds from upstream duration", () => {
147
- // 30s - 2 - 3 = 25s → ceil(25/5) = 5
148
+ // 30s - 2 - 3 = 25s → ceil(25/5) = 5 units × 10 credits
148
149
  expect(estimateTrimVideoCredits({
149
150
  trimMode: "seconds", trimStartSeconds: 2, trimEndSeconds: 3,
150
- }, 30)).toBe(5)
151
+ }, 30)).toBe(50)
151
152
  })
152
153
 
153
- it("clamps to min 1 credit if trim exceeds duration", () => {
154
- // 5s - 10 - 0 = -5 clamp to 0 → max(1, ceil(0)) = 1
154
+ it("clamps to one unit if trim exceeds duration", () => {
155
+ // 5s - 10 - 0 = -5 clamp to 0 → max(1, ceil(0)) = 1 unit × 10 credits
155
156
  expect(estimateTrimVideoCredits({
156
157
  trimMode: "seconds", trimStartSeconds: 10,
157
- }, 5)).toBe(1)
158
+ }, 5)).toBe(10)
158
159
  })
159
160
  })
160
161
 
161
162
  describe("keep-first-seconds mode", () => {
162
163
  it("output is min(upstream, keepFirstSeconds)", () => {
163
- // keepFirst=8, upstream=20 → output 8s → ceil(8/5) = 2
164
+ // keepFirst=8, upstream=20 → output 8s → ceil(8/5) = 2 units × 10 credits
164
165
  expect(estimateTrimVideoCredits({
165
166
  trimMode: "keep-first-seconds", keepFirstSeconds: 8,
166
- }, 20)).toBe(2)
167
+ }, 20)).toBe(20)
167
168
  })
168
169
 
169
170
  it("clamps to upstream when keep > upstream", () => {
170
- // keepFirst=30, upstream=5 → output 5s → ceil(5/5) = 1
171
+ // keepFirst=30, upstream=5 → output 5s → ceil(5/5) = 1 unit × 10 credits
171
172
  expect(estimateTrimVideoCredits({
172
173
  trimMode: "keep-first-seconds", keepFirstSeconds: 30,
173
- }, 5)).toBe(1)
174
+ }, 5)).toBe(10)
174
175
  })
175
176
  })
176
177
 
177
178
  describe("keep-last-seconds mode", () => {
178
179
  it("output is min(upstream, keepLastSeconds)", () => {
179
- // keepLast=10, upstream=30 → output 10s → ceil(10/5) = 2
180
+ // keepLast=10, upstream=30 → output 10s → ceil(10/5) = 2 units × 10 credits
180
181
  expect(estimateTrimVideoCredits({
181
182
  trimMode: "keep-last-seconds", keepLastSeconds: 10,
182
- }, 30)).toBe(2)
183
+ }, 30)).toBe(20)
183
184
  })
184
185
 
185
186
  it("uses 8s fallback when upstream missing", () => {
186
- // keepLast=10, upstream undefined → upstream=8 → min(8,10)=8 → ceil(8/5)=2
187
+ // keepLast=10, upstream undefined → upstream=8 → min(8,10)=8 → ceil(8/5)=2 units × 10 credits
187
188
  expect(estimateTrimVideoCredits({
188
189
  trimMode: "keep-last-seconds", keepLastSeconds: 10,
189
- })).toBe(2)
190
+ })).toBe(20)
190
191
  })
191
192
  })
192
193
  })
@@ -194,56 +195,56 @@ describe("estimateTrimVideoCredits", () => {
194
195
  describe("estimateCombineVideosCredits", () => {
195
196
  it("2 inputs with cut transition", () => {
196
197
  // 5+5=10s, cut → 0 transition overlap, 0 frame trim, numInputs-2=0
197
- // → ceil(10/5) + 0 = 2
198
- expect(estimateCombineVideosCredits({ transition: "cut" }, [5, 5])).toBe(2)
198
+ // → ceil(10/5) + 0 = 2 units × 10 credits
199
+ expect(estimateCombineVideosCredits({ transition: "cut" }, [5, 5])).toBe(20)
199
200
  })
200
201
 
201
202
  it("3 inputs with fade transition (0.5s)", () => {
202
203
  // 10+10+10=30s, 2 fades × 0.5 = 1s overlap → 29s → ceil(29/5)=6
203
- // numInputs-2 = 1 → 6 + 1 = 7
204
+ // numInputs-2 = 1 → 6 + 1 = 7 units × 10 credits
204
205
  expect(estimateCombineVideosCredits({
205
206
  transition: "fade", transitionDuration: 0.5,
206
- }, [10, 10, 10])).toBe(7)
207
+ }, [10, 10, 10])).toBe(70)
207
208
  })
208
209
 
209
210
  it("5 inputs with dissolve and per-clip frame trim (24+24)", () => {
210
211
  // 5×8=40s, 4 transitions × 0.5 = 2s overlap, frame trim 48/24=2s × 5 = 10s
211
212
  // → 40 - 2 - 10 = 28s → ceil(28/5) = 6
212
- // numInputs-2 = 3 → 6 + 3 = 9
213
+ // numInputs-2 = 3 → 6 + 3 = 9 units × 10 credits
213
214
  expect(estimateCombineVideosCredits({
214
215
  transition: "dissolve",
215
216
  transitionDuration: 0.5,
216
217
  trimStartFrames: 24,
217
218
  trimEndFrames: 24,
218
- }, [8, 8, 8, 8, 8])).toBe(9)
219
+ }, [8, 8, 8, 8, 8])).toBe(90)
219
220
  })
220
221
 
221
222
  it("falls back to 8s per missing upstream entry", () => {
222
- // [undef, undef, undef] → 3×8=24s, cut → ceil(24/5)=5, +1 (numInputs-2) = 6
223
+ // [undef, undef, undef] → 3×8=24s, cut → ceil(24/5)=5, +1 (numInputs-2) = 6 units × 10 credits
223
224
  expect(estimateCombineVideosCredits(
224
225
  { transition: "cut" },
225
226
  [undefined, undefined, undefined],
226
- )).toBe(6)
227
+ )).toBe(60)
227
228
  })
228
229
 
229
230
  it("treats empty input array as 2-input fallback", () => {
230
- // numInputs = 0 || 2 = 2; total = 0 → max(1, …) = 1
231
- expect(estimateCombineVideosCredits({ transition: "cut" }, [])).toBe(1)
231
+ // numInputs = 0 || 2 = 2; total = 0 → max(1, …) = 1 unit × 10 credits
232
+ expect(estimateCombineVideosCredits({ transition: "cut" }, [])).toBe(10)
232
233
  })
233
234
 
234
- it("min-1 floor when total clamps to 0", () => {
235
- // 2 × 0s = 0, no overlap, num-2=0 → max(1, ceil(0)) = 1
236
- expect(estimateCombineVideosCredits({ transition: "cut" }, [0, 0])).toBe(1)
235
+ it("one-unit floor when total clamps to 0", () => {
236
+ // 2 × 0s = 0, no overlap, num-2=0 → max(1, ceil(0)) = 1 unit × 10 credits
237
+ expect(estimateCombineVideosCredits({ transition: "cut" }, [0, 0])).toBe(10)
237
238
  })
238
239
 
239
240
  it("does not subtract transition overlap on cut", () => {
240
- // [10, 10] cut → ceil(20/5)=4, numInputs-2=0 → 4
241
- expect(estimateCombineVideosCredits({ transition: "cut", transitionDuration: 999 }, [10, 10])).toBe(4)
241
+ // [10, 10] cut → ceil(20/5)=4, numInputs-2=0 → 4 units × 10 credits
242
+ expect(estimateCombineVideosCredits({ transition: "cut", transitionDuration: 999 }, [10, 10])).toBe(40)
242
243
  })
243
244
 
244
245
  it("uses default transitionDuration 0.5 when missing on a non-cut", () => {
245
- // [10, 10] fade, no transitionDuration → 20 - 0.5 = 19.5 → ceil(19.5/5)=4
246
- expect(estimateCombineVideosCredits({ transition: "fade" }, [10, 10])).toBe(4)
246
+ // [10, 10] fade, no transitionDuration → 20 - 0.5 = 19.5 → ceil(19.5/5)=4 units × 10 credits
247
+ expect(estimateCombineVideosCredits({ transition: "fade" }, [10, 10])).toBe(40)
247
248
  })
248
249
  })
249
250
 
@@ -256,29 +257,34 @@ describe("estimateLoopTrimAddonCredits", () => {
256
257
  expect(estimateLoopTrimAddonCredits({ enabled: false }, 8)).toBe(0)
257
258
  })
258
259
 
259
- it("computes ceil(duration/5) + ceil(framesToTest/24) when enabled", () => {
260
- // 8s / 5 = 2 (ceil), 16 / 24 = 1 (ceil) → 3
261
- expect(estimateLoopTrimAddonCredits({ enabled: true, framesToTest: 16 }, 8)).toBe(3)
260
+ // In the video-utility unit (VIDEO_UTIL_PRICING.CREDIT_UNIT = 10), the
261
+ // same as Trim Video's smart loop cut. Worked examples repeated in
262
+ // docs/nodes/ai-video/generate-video.md ("Loop trim add-on").
263
+ it("computes 10 × (ceil(duration/5) + ceil(framesToTest/24)) when enabled", () => {
264
+ // 8s / 5 = 2 (ceil), 16 / 24 = 1 (ceil) → 3 units → 30
265
+ expect(estimateLoopTrimAddonCredits({ enabled: true, framesToTest: 16 }, 8)).toBe(30)
266
+ // 5s / 5 = 1, 16 / 24 = 1 → 2 units → 20
267
+ expect(estimateLoopTrimAddonCredits({ enabled: true, framesToTest: 16 }, 5)).toBe(20)
262
268
  })
263
269
 
264
270
  it("uses default framesToTest=16 when omitted", () => {
265
- // 10s / 5 = 2, 16 / 24 = 1 → 3
266
- expect(estimateLoopTrimAddonCredits({ enabled: true }, 10)).toBe(3)
271
+ // 10s / 5 = 2, 16 / 24 = 1 → 3 units → 30
272
+ expect(estimateLoopTrimAddonCredits({ enabled: true }, 10)).toBe(30)
267
273
  })
268
274
 
269
275
  it("clamps framesToTest to 64 max", () => {
270
- // 8s / 5 = 2, 64 / 24 = 3 → 5
271
- expect(estimateLoopTrimAddonCredits({ enabled: true, framesToTest: 999 }, 8)).toBe(5)
276
+ // 8s / 5 = 2, 64 / 24 = 3 → 5 units → 50
277
+ expect(estimateLoopTrimAddonCredits({ enabled: true, framesToTest: 999 }, 8)).toBe(50)
272
278
  })
273
279
 
274
280
  it("clamps framesToTest to 1 min", () => {
275
- // 8s / 5 = 2, 1 / 24 = 1 → 3
276
- expect(estimateLoopTrimAddonCredits({ enabled: true, framesToTest: 0 }, 8)).toBe(3)
281
+ // 8s / 5 = 2, 1 / 24 = 1 → 3 units → 30
282
+ expect(estimateLoopTrimAddonCredits({ enabled: true, framesToTest: 0 }, 8)).toBe(30)
277
283
  })
278
284
 
279
285
  it("scales with output duration", () => {
280
- // 60s / 5 = 12, 16 / 24 = 1 → 13
281
- expect(estimateLoopTrimAddonCredits({ enabled: true, framesToTest: 16 }, 60)).toBe(13)
286
+ // 60s / 5 = 12, 16 / 24 = 1 → 13 units → 130
287
+ expect(estimateLoopTrimAddonCredits({ enabled: true, framesToTest: 16 }, 60)).toBe(130)
282
288
  })
283
289
 
284
290
  it("returns 0 when framesToTest=64 but enabled is false (precedence)", () => {
@@ -287,17 +293,17 @@ describe("estimateLoopTrimAddonCredits", () => {
287
293
  })
288
294
 
289
295
  describe("assembleNarratedVideoCredits", () => {
290
- it("matches the worked examples 6→4, 24→7, 60→13", () => {
291
- expect(assembleNarratedVideoCredits(6)).toBe(4)
292
- expect(assembleNarratedVideoCredits(24)).toBe(7)
293
- expect(assembleNarratedVideoCredits(60)).toBe(13)
296
+ it("matches the worked examples 6→40, 24→70, 60→130", () => {
297
+ expect(assembleNarratedVideoCredits(6)).toBe(40)
298
+ expect(assembleNarratedVideoCredits(24)).toBe(70)
299
+ expect(assembleNarratedVideoCredits(60)).toBe(130)
294
300
  })
295
301
 
296
- it("is 3 flat credits at the theoretical N=0 floor (never shown directly — call sites clamp N to 1)", () => {
297
- expect(assembleNarratedVideoCredits(0)).toBe(3)
302
+ it("is 3 flat units at the theoretical N=0 floor (never shown directly — call sites clamp N to 1)", () => {
303
+ expect(assembleNarratedVideoCredits(0)).toBe(30)
298
304
  })
299
305
 
300
- it("returns the 1-block floor of 4 credits", () => {
301
- expect(assembleNarratedVideoCredits(1)).toBe(4)
306
+ it("returns the 1-block floor of 40 credits", () => {
307
+ expect(assembleNarratedVideoCredits(1)).toBe(40)
302
308
  })
303
309
  })
@@ -72,6 +72,43 @@ describe("stripExportContent — template export hygiene", () => {
72
72
  expect((outPost.data as Record<string, unknown>).text).toBe("hello")
73
73
  })
74
74
 
75
+ it("clears a Telegram Account Trigger's account and chats — the exporter's account, and a Saved Messages id is their Telegram id", () => {
76
+ const trigger: GenericNode = {
77
+ id: "t1",
78
+ type: "telegram-account-trigger",
79
+ data: {
80
+ label: "Inbox",
81
+ accountId: "acct-1",
82
+ chatIds: ["777000"],
83
+ chatTitles: { "777000": "Saved Messages" },
84
+ senderIds: ["777000"],
85
+ inboxMode: true,
86
+ keywords: ["idea"],
87
+ isActive: true,
88
+ },
89
+ }
90
+ const [out] = stripUnownedRefs([trigger])
91
+ const data = out.data as Record<string, unknown>
92
+ for (const field of ["accountId", "chatIds", "chatTitles", "senderIds"]) expect(data[field], field).toBeUndefined()
93
+ // The importer's own choices start from the exporter's settings.
94
+ expect(data.inboxMode).toBe(true)
95
+ expect(data.keywords).toEqual(["idea"])
96
+ expect(trigger.data.accountId, "input not mutated").toBe("acct-1")
97
+ })
98
+
99
+ it("a template carries no armed account trigger and no trigger's last run values", () => {
100
+ const trigger: GenericNode = {
101
+ id: "t1",
102
+ type: "telegram-account-trigger",
103
+ data: { label: "Inbox", isActive: true, inboxMode: true, __triggerData: { postText: "a stranger's words", senderId: "555" } },
104
+ }
105
+ const [out] = stripExportContent([trigger])
106
+ const data = out.data as Record<string, unknown>
107
+ expect(data.isActive).toBeUndefined()
108
+ expect(data.__triggerData).toBeUndefined()
109
+ expect(data.inboxMode).toBe(true)
110
+ })
111
+
75
112
  it("stripUnownedRefs alone covers the asset-bundle export, which keeps every other field", () => {
76
113
  const hook: GenericNode = {
77
114
  id: "h1",
@@ -0,0 +1,166 @@
1
+ /**
2
+ * camera-switch (podcast B5, decided 2026-10-03) — the structural pieces every
3
+ * caller shares: the canvas engines, the editor, MCP and the SDK. WHO is on
4
+ * screen is decided by the Cloud plugin; these only read the inputs it needs
5
+ * and pre-fill the speaker table. Pure, no I/O.
6
+ */
7
+
8
+ /** The settings and their decided defaults (the plugin holds its own copy, D13). */
9
+ export const CAMERA_SWITCH_DEFAULTS = Object.freeze({
10
+ /** The shortest shot; a shorter turn (an interjection) holds the shot. */
11
+ minShotMs: 2_500,
12
+ /** Cut this long before the new speaker starts. */
13
+ leadMs: 200,
14
+ /** With a `wide` camera: break to it after this long on one camera. */
15
+ maxShotMs: 20_000,
16
+ /** With a `wide` camera: every N-th cut goes to the wide (0 = off). */
17
+ wideEvery: 0,
18
+ /** Overlapping speech → a side-by-side / stacked layout hint. */
19
+ layoutHints: false,
20
+ })
21
+
22
+ /** The flat credit id and price (decided 2026-10-03). */
23
+ export const CAMERA_SWITCH_CREDIT_ID = "camera-switch"
24
+
25
+ const parseMaybe = (raw: unknown): unknown => {
26
+ if (typeof raw !== "string") return raw
27
+ try { return JSON.parse(raw) } catch { return undefined }
28
+ }
29
+
30
+ /** Distinct speaker labels of a transcript (an object or its JSON string), in
31
+ * order of first appearance. Empty → camera-switch refuses before charging. */
32
+ export function transcriptSpeakerLabels(transcript: unknown): string[] {
33
+ const words = (parseMaybe(transcript) as { words?: unknown } | null | undefined)?.words
34
+ if (!Array.isArray(words)) return []
35
+ const seen = new Set<string>()
36
+ for (const w of words) {
37
+ const s = (w as { speaker?: unknown } | null)?.speaker
38
+ if (typeof s === "string" && s && !seen.has(s)) seen.add(s)
39
+ }
40
+ return [...seen]
41
+ }
42
+
43
+ /** The cameras a speaker can be given: an EDL's video sources in order,
44
+ * without the `wide` / `screen` angles (those are not anyone's close-up). */
45
+ export function cameraSwitchCameras(edl: unknown): Array<{ id: string; role?: string }> {
46
+ const sources = (parseMaybe(edl) as { sources?: unknown } | null | undefined)?.sources
47
+ if (!Array.isArray(sources)) return []
48
+ return sources
49
+ .filter((s): s is { id: string; kind?: string; role?: string } => !!s && typeof (s as { id?: unknown }).id === "string")
50
+ .filter((s) => s.kind !== "audio" && s.role !== "wide" && s.role !== "screen" && s.role !== "master-audio")
51
+ .map((s) => ({ id: s.id, ...(s.role ? { role: s.role } : {}) }))
52
+ }
53
+
54
+ /** The settings' accepted ranges — exactly the Cloud route's (it answers 400
55
+ * outside them), so every caller clamps to the same numbers before sending. */
56
+ export const CAMERA_SWITCH_BOUNDS = Object.freeze({
57
+ minShotMs: Object.freeze({ min: 500, max: 60_000 }),
58
+ leadMs: Object.freeze({ min: 0, max: 5_000 }),
59
+ maxShotMs: Object.freeze({ min: 0, max: 600_000 }),
60
+ wideEvery: Object.freeze({ min: 0, max: 20 }),
61
+ })
62
+
63
+ /** The longest display name a speaker can be given. */
64
+ export const CAMERA_SWITCH_NAME_MAX = 80
65
+
66
+ export type CameraSwitchNumericSetting = keyof typeof CAMERA_SWITCH_BOUNDS
67
+
68
+ /** A setting as a whole number inside its range; undefined when unset. */
69
+ export function clampCameraSwitchSetting(key: CameraSwitchNumericSetting, value: unknown): number | undefined {
70
+ if (typeof value !== "number" || !Number.isFinite(value)) return undefined
71
+ const { min, max } = CAMERA_SWITCH_BOUNDS[key]
72
+ return Math.min(max, Math.max(min, Math.round(value)))
73
+ }
74
+
75
+ /** Display names trimmed, empty ones dropped, each cut to
76
+ * `CAMERA_SWITCH_NAME_MAX` characters. */
77
+ export function cleanSpeakerNames(raw: unknown): Record<string, string> {
78
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {}
79
+ const out: Record<string, string> = {}
80
+ for (const [label, name] of Object.entries(raw as Record<string, unknown>)) {
81
+ const trimmed = typeof name === "string" ? name.trim() : ""
82
+ if (label && trimmed) out[label] = trimmed.slice(0, CAMERA_SWITCH_NAME_MAX)
83
+ }
84
+ return out
85
+ }
86
+
87
+ /** Why camera-switch would refuse this edit (the route's 400 `invalid_edl`),
88
+ * or null. One edit (an object or its JSON string) on the master clock, with
89
+ * sources and at least one segment of numeric inMs < outMs; a clip SET is
90
+ * refused — on the canvas each clip fans out to its own run. */
91
+ export function cameraSwitchEdlProblem(edl: unknown): string | null {
92
+ const v = parseMaybe(edl) as Record<string, unknown> | null | undefined
93
+ if (!v || typeof v !== "object" || Array.isArray(v)) return "camera-switch: `edl` must be one edit (an EDL object)."
94
+ if (Array.isArray(v.clips)) return "camera-switch: `edl` is a clip set — pass one clip's EDL (a clip set fans out one run per clip on the canvas)."
95
+ if (!Array.isArray(v.sources) || !Array.isArray(v.segments)) return "camera-switch: `edl` needs `sources` and `segments`."
96
+ if (v.segments.length === 0) return "camera-switch: `edl` has no segments."
97
+ const num = (x: unknown) => (typeof x === "number" && Number.isFinite(x) ? x : undefined)
98
+ for (const [i, row] of (v.segments as unknown[]).entries()) {
99
+ const seg = row as { inMs?: unknown; outMs?: unknown } | null
100
+ const inMs = num(seg?.inMs), outMs = num(seg?.outMs)
101
+ if (inMs === undefined || outMs === undefined || !(outMs > inMs)) return `camera-switch: segment ${i} needs a numeric inMs < outMs.`
102
+ }
103
+ if (v.clock === "output") return "camera-switch: the edit must be on the master clock (an edit-plan EDL), not a rendered output's."
104
+ return null
105
+ }
106
+
107
+ /** The speaker table pre-filled by order (decided 2026-10-03): speaker 1 →
108
+ * camera 1, speaker 2 → camera 2 … A speaker past the last camera stays
109
+ * unmapped (the wide shows them, else any camera with picture). `existing`
110
+ * entries are kept as the person set them — an explicit `""` means "no
111
+ * camera of their own" and is SENT as `""`, so it also beats a source whose
112
+ * `speakers` list names them. */
113
+ export function defaultSpeakerMap(
114
+ labels: readonly string[],
115
+ cameraIds: readonly string[],
116
+ existing: Readonly<Record<string, string>> = {},
117
+ ): Record<string, string> {
118
+ const out: Record<string, string> = {}
119
+ labels.forEach((label, i) => {
120
+ if (Object.prototype.hasOwnProperty.call(existing, label)) {
121
+ const kept = existing[label]
122
+ if (typeof kept === "string") out[label] = kept
123
+ return
124
+ }
125
+ if (i < cameraIds.length) out[label] = cameraIds[i]!
126
+ })
127
+ return out
128
+ }
129
+
130
+ /** What a Camera Switch node sends besides its two inputs — ONE funnel for the
131
+ * canvas executor and the orchestrator, so both send the same clamped
132
+ * settings and the same pre-filled speaker table. */
133
+ export interface CameraSwitchNodeSettings {
134
+ readonly speakerMap?: Readonly<Record<string, string>>
135
+ readonly speakerNames?: Readonly<Record<string, string>>
136
+ readonly minShotMs?: number
137
+ readonly leadMs?: number
138
+ readonly maxShotMs?: number
139
+ readonly wideEvery?: number
140
+ readonly layoutHints?: boolean
141
+ }
142
+ export function cameraSwitchSettingsPayload(
143
+ data: CameraSwitchNodeSettings,
144
+ edl: unknown,
145
+ transcript: unknown,
146
+ ): {
147
+ speakerMap: Record<string, string>
148
+ speakerNames: Record<string, string>
149
+ minShotMs?: number
150
+ leadMs?: number
151
+ maxShotMs?: number
152
+ wideEvery?: number
153
+ layoutHints: boolean
154
+ } {
155
+ const existing = data.speakerMap && typeof data.speakerMap === "object" ? data.speakerMap : {}
156
+ const out: ReturnType<typeof cameraSwitchSettingsPayload> = {
157
+ speakerMap: defaultSpeakerMap(transcriptSpeakerLabels(transcript), cameraSwitchCameras(edl).map((c) => c.id), existing),
158
+ speakerNames: cleanSpeakerNames(data.speakerNames),
159
+ layoutHints: data.layoutHints === true,
160
+ }
161
+ for (const key of Object.keys(CAMERA_SWITCH_BOUNDS) as CameraSwitchNumericSetting[]) {
162
+ const v = clampCameraSwitchSetting(key, data[key])
163
+ if (v !== undefined) out[key] = v
164
+ }
165
+ return out
166
+ }
@@ -24,6 +24,21 @@ export interface ProjectedCatalogOption {
24
24
  icon?: string
25
25
  /** Authored Character Motion prerequisites and sequence state. Missing means unknown. */
26
26
  motion?: CharacterMotionMetadata
27
+ /**
28
+ * Per-option parameters — node-data fields that apply only while THIS option
29
+ * is picked (the Transition catalog's `wipe` → `wipeDirection`). Same shape
30
+ * as a catalog's `dimensions`, at both detail levels; `auto` leads each list
31
+ * and means "send nothing". Absent on every other option.
32
+ */
33
+ params?: ProjectedCatalogDimension[]
34
+ /**
35
+ * Absolute URL of the option's picture (a photo, 3D emoji, flag or rendered
36
+ * look preview), on the installation's own host — or the Nodaro CDN for the
37
+ * look previews, which only Nodaro Cloud serves. Absent when the option has
38
+ * no picture. Content-hashed where self-hosted: a changed picture gets a new
39
+ * URL, so it can be cached indefinitely.
40
+ */
41
+ imageUrl?: string
27
42
  }
28
43
 
29
44
  export interface ProjectedCatalogDimension {
@@ -32,6 +47,16 @@ export interface ProjectedCatalogDimension {
32
47
  options: ProjectedCatalogOption[]
33
48
  }
34
49
 
50
+ /** A topic the editor groups a multi-dim catalog's settings under (Person, Styling). */
51
+ export interface ProjectedCatalogSection {
52
+ /** English topic name, e.g. "Identity", "Beauty & Hair". */
53
+ label: string
54
+ /** Node-data fields of the settings in this topic, in display order. */
55
+ fields: readonly string[]
56
+ /** Absolute URL of the topic's round picture. Absent when it has none. */
57
+ imageUrl?: string
58
+ }
59
+
35
60
  export interface ProjectedCatalog {
36
61
  nodeType: string
37
62
  label: string
@@ -51,4 +76,6 @@ export interface ProjectedCatalog {
51
76
  * single-dim catalog carries them when it has secondary parameter
52
77
  * fields beside its main picker (transition position/duration/intensity). */
53
78
  dimensions?: ProjectedCatalogDimension[]
79
+ /** Person and Styling: the topics their settings are grouped under, in order. */
80
+ sections?: ProjectedCatalogSection[]
54
81
  }