@nodaro/shared 3.30.0 → 3.31.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 (36) hide show
  1. package/dist/index.cjs +733 -93
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +501 -36
  4. package/dist/index.d.ts +501 -36
  5. package/dist/index.js +673 -94
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/__tests__/entity-image-handle.test.ts +61 -1
  9. package/src/__tests__/json-kinds.test.ts +10 -0
  10. package/src/__tests__/model-seed-capability.test.ts +34 -0
  11. package/src/__tests__/node-preset-extract.test.ts +8 -0
  12. package/src/__tests__/node-run-routes.test.ts +63 -0
  13. package/src/__tests__/node-runtime-keys.test.ts +61 -0
  14. package/src/__tests__/presentation-utils.test.ts +14 -0
  15. package/src/__tests__/producer-types.test.ts +15 -0
  16. package/src/__tests__/seedance-draft.test.ts +74 -0
  17. package/src/__tests__/ugc-clip-saved-list.test.ts +19 -0
  18. package/src/__tests__/ugc-node-wires.test.ts +600 -0
  19. package/src/__tests__/ugc-run-state.test.ts +80 -3
  20. package/src/__tests__/workflow-export-strip.test.ts +14 -0
  21. package/src/entity-image-handle.ts +48 -1
  22. package/src/index.ts +8 -1
  23. package/src/json-kinds.ts +9 -0
  24. package/src/model-catalog.ts +61 -2
  25. package/src/model-constants.ts +3 -0
  26. package/src/node-preset-export.ts +2 -2
  27. package/src/node-preset-extract.ts +6 -4
  28. package/src/node-run-routes.ts +76 -0
  29. package/src/node-runtime-keys.ts +42 -1
  30. package/src/presentation-utils.ts +3 -0
  31. package/src/producer-types.ts +10 -0
  32. package/src/seedance-draft.ts +64 -0
  33. package/src/social-post.ts +13 -0
  34. package/src/ugc-node-wires.ts +623 -0
  35. package/src/ugc-run-state.ts +60 -5
  36. package/src/workflow-export.ts +3 -1
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Seedance 2.5 Draft mode — the single source of truth for which models offer a
3
+ * draft, what a draft renders at, and how its 1080p finalize is priced.
4
+ *
5
+ * A DRAFT is an ordinary Seedance 2.5 run with the provider's draft flag set: it
6
+ * renders at 480p only and costs exactly what a normal 480p run of the same
7
+ * shape costs. The FINALIZE ("Seedance 2.5 HD (from draft)", a Video Upscale
8
+ * provider) re-renders that same take — same seed, prompt, references and
9
+ * timing — at 1080p, frame for frame, at the draft's own length. Nothing
10
+ * creative is re-sent: the finalize names the draft's provider task and nothing
11
+ * else.
12
+ *
13
+ * Every surface (generation routes, the workflow engine, MCP, the editor's
14
+ * toggle) gates on {@link isSeedanceDraftCapable}; never hand-list the model.
15
+ */
16
+
17
+ /** Models that accept the draft flag. */
18
+ export const SEEDANCE_DRAFT_MODELS = ["seedance-2-5"] as const
19
+ export type SeedanceDraftModel = typeof SEEDANCE_DRAFT_MODELS[number]
20
+
21
+ export function isSeedanceDraftCapable(provider: string | undefined): provider is SeedanceDraftModel {
22
+ return !!provider && (SEEDANCE_DRAFT_MODELS as readonly string[]).includes(provider)
23
+ }
24
+
25
+ /** The only resolution a draft renders at. Any other value is coerced to it. */
26
+ export const SEEDANCE_DRAFT_RESOLUTION = "480p"
27
+
28
+ /** The Video Upscale provider that finalizes a draft. */
29
+ export const SEEDANCE_DRAFT_FINALIZE_PROVIDER = "seedance-2-5-hd"
30
+
31
+ /** The only resolution a finalize renders at. */
32
+ export const SEEDANCE_DRAFT_FINALIZE_RESOLUTION = "1080p"
33
+
34
+ /** Shortest / longest output the finalize price ladder is seeded for. */
35
+ export const SEEDANCE_DRAFT_FINALIZE_MIN_SEC = 4
36
+ export const SEEDANCE_DRAFT_FINALIZE_MAX_SEC = 30
37
+
38
+ /**
39
+ * Whole seconds the finalize bills for a measured draft length.
40
+ *
41
+ * A container reports a hair over the nominal length (4.04 s for a 4 s clip), so
42
+ * the seconds round UP only past a quarter second — the same rule the Seedance
43
+ * auto-duration settlement uses — and land on the seeded ladder (4–30 s).
44
+ */
45
+ export function seedanceDraftFinalizeBillableSec(measuredSec: number): number {
46
+ const whole = Math.max(1, Math.ceil(measuredSec - 0.25))
47
+ return Math.min(SEEDANCE_DRAFT_FINALIZE_MAX_SEC, Math.max(SEEDANCE_DRAFT_FINALIZE_MIN_SEC, whole))
48
+ }
49
+
50
+ /**
51
+ * The credit identifier a finalize reserves under.
52
+ *
53
+ * Same encoding as the Seedance 2.5 generation ladder: one row per OUTPUT second
54
+ * (`seedance-2-5-hd:{N}s`), and a `-ref` twin for a draft that had a reference
55
+ * VIDEO. As on the generation lane, the `-ref` row encodes the per-second rate
56
+ * only; a reference run bills `rate × (input + output)` seconds, which the
57
+ * reservation computes from the 8 s `-ref` row (see the backend's
58
+ * `seedanceDraftFinalizeRefBaseCredits`). Reference IMAGES do not change the
59
+ * rate — only a reference video does.
60
+ */
61
+ export function seedanceDraftFinalizeCreditId(durationSec: number, hasRefVideo: boolean): string {
62
+ const n = seedanceDraftFinalizeBillableSec(durationSec)
63
+ return `${SEEDANCE_DRAFT_FINALIZE_PROVIDER}:${n}s${hasRefVideo ? "-ref" : ""}`
64
+ }
@@ -22,6 +22,19 @@ export const SOCIAL_POST_NODE_TYPES = new Set([
22
22
  "publish-social",
23
23
  ])
24
24
 
25
+ /** The platform each per-platform social post node publishes to. The unified
26
+ * `publish-social` node is absent on purpose: its platform comes from the
27
+ * chosen connection (`data.platform`). */
28
+ export const SOCIAL_POST_NODE_PLATFORM: Readonly<Record<string, string>> = Object.freeze({
29
+ "instagram-post": "instagram",
30
+ "tiktok-post": "tiktok",
31
+ "youtube-upload": "youtube",
32
+ "linkedin-post": "linkedin",
33
+ "x-post": "x",
34
+ "facebook-post": "facebook",
35
+ "telegram-post": "telegram",
36
+ })
37
+
25
38
  /** Instagram carousel limits per Meta Graph API.
26
39
  * Meta's documented limit is 10 items; sending >10 fails at container
27
40
  * creation with "(#100) too little or too many attachments". */