@nodaro/shared 3.30.0 → 3.32.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/README.md +17 -0
- package/dist/chunk-2NIQO2J3.cjs +54 -0
- package/dist/chunk-2NIQO2J3.cjs.map +1 -0
- package/dist/chunk-2OJIVO7R.cjs +32 -0
- package/dist/chunk-2OJIVO7R.cjs.map +1 -0
- package/dist/chunk-2RF4Z7KG.cjs +803 -0
- package/dist/chunk-2RF4Z7KG.cjs.map +1 -0
- package/dist/chunk-3CUFITU7.js +1905 -0
- package/dist/chunk-3CUFITU7.js.map +1 -0
- package/dist/chunk-3RYKIUAE.js +86 -0
- package/dist/chunk-3RYKIUAE.js.map +1 -0
- package/dist/chunk-44I73CQS.cjs +194 -0
- package/dist/chunk-44I73CQS.cjs.map +1 -0
- package/dist/chunk-5AUSSJIM.cjs +3372 -0
- package/dist/chunk-5AUSSJIM.cjs.map +1 -0
- package/dist/chunk-5PC6JBGJ.cjs +1419 -0
- package/dist/chunk-5PC6JBGJ.cjs.map +1 -0
- package/dist/chunk-5RU2HCW2.js +30 -0
- package/dist/chunk-5RU2HCW2.js.map +1 -0
- package/dist/chunk-5THUHJ3E.js +46 -0
- package/dist/chunk-5THUHJ3E.js.map +1 -0
- package/dist/chunk-5U7VLG43.js +141 -0
- package/dist/chunk-5U7VLG43.js.map +1 -0
- package/dist/chunk-6DAWSVX2.cjs +103 -0
- package/dist/chunk-6DAWSVX2.cjs.map +1 -0
- package/dist/chunk-6DKDOWBL.js +1567 -0
- package/dist/chunk-6DKDOWBL.js.map +1 -0
- package/dist/chunk-6IJOPRZP.cjs +197 -0
- package/dist/chunk-6IJOPRZP.cjs.map +1 -0
- package/dist/chunk-7G7G42KS.js +86 -0
- package/dist/chunk-7G7G42KS.js.map +1 -0
- package/dist/chunk-AINCI23X.js +2171 -0
- package/dist/chunk-AINCI23X.js.map +1 -0
- package/dist/chunk-AROWPFO2.js +773 -0
- package/dist/chunk-AROWPFO2.js.map +1 -0
- package/dist/chunk-AVQK77G6.cjs +2000 -0
- package/dist/chunk-AVQK77G6.cjs.map +1 -0
- package/dist/chunk-C57NEO3X.js +3327 -0
- package/dist/chunk-C57NEO3X.js.map +1 -0
- package/dist/chunk-CK3GK34R.js +1381 -0
- package/dist/chunk-CK3GK34R.js.map +1 -0
- package/dist/chunk-E2TGXG6X.cjs +1770 -0
- package/dist/chunk-E2TGXG6X.cjs.map +1 -0
- package/dist/chunk-EK362Q45.cjs +38 -0
- package/dist/chunk-EK362Q45.cjs.map +1 -0
- package/dist/chunk-FBV5DF6D.js +95 -0
- package/dist/chunk-FBV5DF6D.js.map +1 -0
- package/dist/chunk-FG4E7MTG.cjs +4 -0
- package/dist/chunk-FG4E7MTG.cjs.map +1 -0
- package/dist/chunk-G6IIVKMO.js +26 -0
- package/dist/chunk-G6IIVKMO.js.map +1 -0
- package/dist/chunk-HGC5JNVA.cjs +1503 -0
- package/dist/chunk-HGC5JNVA.cjs.map +1 -0
- package/dist/chunk-HSHCCBIV.js +255 -0
- package/dist/chunk-HSHCCBIV.js.map +1 -0
- package/dist/chunk-IEBZHTPE.js +254 -0
- package/dist/chunk-IEBZHTPE.js.map +1 -0
- package/dist/chunk-ISJDAFKS.js +1604 -0
- package/dist/chunk-ISJDAFKS.js.map +1 -0
- package/dist/chunk-J6KHW2E5.cjs +1963 -0
- package/dist/chunk-J6KHW2E5.cjs.map +1 -0
- package/dist/chunk-J7BMO73N.cjs +114 -0
- package/dist/chunk-J7BMO73N.cjs.map +1 -0
- package/dist/chunk-JL4C5VJ7.cjs +488 -0
- package/dist/chunk-JL4C5VJ7.cjs.map +1 -0
- package/dist/chunk-JSGIEF6Z.cjs +1087 -0
- package/dist/chunk-JSGIEF6Z.cjs.map +1 -0
- package/dist/chunk-JSNV5O2F.cjs +34 -0
- package/dist/chunk-JSNV5O2F.cjs.map +1 -0
- package/dist/chunk-JWA5SGCS.js +203 -0
- package/dist/chunk-JWA5SGCS.js.map +1 -0
- package/dist/chunk-JX5YZ4DH.cjs +430 -0
- package/dist/chunk-JX5YZ4DH.cjs.map +1 -0
- package/dist/chunk-KHCBJ7KD.js +42 -0
- package/dist/chunk-KHCBJ7KD.js.map +1 -0
- package/dist/chunk-KU6S7IYV.cjs +210 -0
- package/dist/chunk-KU6S7IYV.cjs.map +1 -0
- package/dist/chunk-LKAIXWK3.js +181 -0
- package/dist/chunk-LKAIXWK3.js.map +1 -0
- package/dist/chunk-LPW3XNC2.js +471 -0
- package/dist/chunk-LPW3XNC2.js.map +1 -0
- package/dist/chunk-M36G6SRP.js +447 -0
- package/dist/chunk-M36G6SRP.js.map +1 -0
- package/dist/chunk-MRXGWL42.cjs +4 -0
- package/dist/chunk-MRXGWL42.cjs.map +1 -0
- package/dist/chunk-NB72XWXQ.cjs +54 -0
- package/dist/chunk-NB72XWXQ.cjs.map +1 -0
- package/dist/chunk-NEJ2PV4C.cjs +211 -0
- package/dist/chunk-NEJ2PV4C.cjs.map +1 -0
- package/dist/chunk-NT6IJH4L.cjs +273 -0
- package/dist/chunk-NT6IJH4L.cjs.map +1 -0
- package/dist/chunk-O5MP52U2.cjs +526 -0
- package/dist/chunk-O5MP52U2.cjs.map +1 -0
- package/dist/chunk-O7PUQLJ3.cjs +818 -0
- package/dist/chunk-O7PUQLJ3.cjs.map +1 -0
- package/dist/chunk-PQHS255G.js +1369 -0
- package/dist/chunk-PQHS255G.js.map +1 -0
- package/dist/chunk-PRYE7AZQ.cjs +1227 -0
- package/dist/chunk-PRYE7AZQ.cjs.map +1 -0
- package/dist/chunk-Q4CDQ2KO.js +21 -0
- package/dist/chunk-Q4CDQ2KO.js.map +1 -0
- package/dist/chunk-QELDJGDK.cjs +1714 -0
- package/dist/chunk-QELDJGDK.cjs.map +1 -0
- package/dist/chunk-QJRP44ZO.js +769 -0
- package/dist/chunk-QJRP44ZO.js.map +1 -0
- package/dist/chunk-QNGNOU4Z.js +29 -0
- package/dist/chunk-QNGNOU4Z.js.map +1 -0
- package/dist/chunk-RJL7RCEM.cjs +159 -0
- package/dist/chunk-RJL7RCEM.cjs.map +1 -0
- package/dist/chunk-RN3RMBJZ.js +1164 -0
- package/dist/chunk-RN3RMBJZ.js.map +1 -0
- package/dist/chunk-S5DMKUWK.cjs +1273 -0
- package/dist/chunk-S5DMKUWK.cjs.map +1 -0
- package/dist/chunk-SES6GDBQ.cjs +624 -0
- package/dist/chunk-SES6GDBQ.cjs.map +1 -0
- package/dist/chunk-TNPDV7I4.cjs +2346 -0
- package/dist/chunk-TNPDV7I4.cjs.map +1 -0
- package/dist/chunk-TZBIY5C3.js +187 -0
- package/dist/chunk-TZBIY5C3.js.map +1 -0
- package/dist/chunk-TZE673G6.js +3 -0
- package/dist/chunk-TZE673G6.js.map +1 -0
- package/dist/chunk-ULXI7A6Q.cjs +1047 -0
- package/dist/chunk-ULXI7A6Q.cjs.map +1 -0
- package/dist/chunk-VIWSWVAW.js +1782 -0
- package/dist/chunk-VIWSWVAW.js.map +1 -0
- package/dist/chunk-VWGNPMJZ.cjs +19 -0
- package/dist/chunk-VWGNPMJZ.cjs.map +1 -0
- package/dist/chunk-WDIBOWAA.js +1054 -0
- package/dist/chunk-WDIBOWAA.js.map +1 -0
- package/dist/chunk-WNG7HRVA.cjs +25 -0
- package/dist/chunk-WNG7HRVA.cjs.map +1 -0
- package/dist/chunk-WNVQ3SMB.cjs +96 -0
- package/dist/chunk-WNVQ3SMB.cjs.map +1 -0
- package/dist/chunk-WRSWH7US.cjs +285 -0
- package/dist/chunk-WRSWH7US.cjs.map +1 -0
- package/dist/chunk-XAMC4S53.js +17 -0
- package/dist/chunk-XAMC4S53.js.map +1 -0
- package/dist/chunk-XNISPHTZ.js +1039 -0
- package/dist/chunk-XNISPHTZ.js.map +1 -0
- package/dist/chunk-Y2PM3FFL.js +3 -0
- package/dist/chunk-Y2PM3FFL.js.map +1 -0
- package/dist/chunk-YBPBK5KI.js +1030 -0
- package/dist/chunk-YBPBK5KI.js.map +1 -0
- package/dist/chunk-YHRG7UOC.js +31 -0
- package/dist/chunk-YHRG7UOC.js.map +1 -0
- package/dist/chunk-YWNYGYI7.cjs +31 -0
- package/dist/chunk-YWNYGYI7.cjs.map +1 -0
- package/dist/chunk-YYV35XOS.js +122 -0
- package/dist/chunk-YYV35XOS.js.map +1 -0
- package/dist/chunk-Z2OL5AJD.cjs +133 -0
- package/dist/chunk-Z2OL5AJD.cjs.map +1 -0
- package/dist/chunk-Z4AZW6FY.js +920 -0
- package/dist/chunk-Z4AZW6FY.js.map +1 -0
- package/dist/chunk-ZDFHA2EC.js +572 -0
- package/dist/chunk-ZDFHA2EC.js.map +1 -0
- package/dist/chunk-ZNZDQAXN.js +175 -0
- package/dist/chunk-ZNZDQAXN.js.map +1 -0
- package/dist/chunk-ZRL2UFTH.cjs +1073 -0
- package/dist/chunk-ZRL2UFTH.cjs.map +1 -0
- package/dist/chunk-ZT77RY6R.js +404 -0
- package/dist/chunk-ZT77RY6R.js.map +1 -0
- package/dist/entries/apps.cjs +155 -0
- package/dist/entries/apps.cjs.map +1 -0
- package/dist/entries/apps.d.cts +283 -0
- package/dist/entries/apps.d.ts +283 -0
- package/dist/entries/apps.js +10 -0
- package/dist/entries/apps.js.map +1 -0
- package/dist/entries/captions.cjs +124 -0
- package/dist/entries/captions.cjs.map +1 -0
- package/dist/entries/captions.d.cts +354 -0
- package/dist/entries/captions.d.ts +354 -0
- package/dist/entries/captions.js +3 -0
- package/dist/entries/captions.js.map +1 -0
- package/dist/entries/catalogs.cjs +165 -0
- package/dist/entries/catalogs.cjs.map +1 -0
- package/dist/entries/catalogs.d.cts +385 -0
- package/dist/entries/catalogs.d.ts +385 -0
- package/dist/entries/catalogs.js +4 -0
- package/dist/entries/catalogs.js.map +1 -0
- package/dist/entries/credits.cjs +592 -0
- package/dist/entries/credits.cjs.map +1 -0
- package/dist/entries/credits.d.cts +1429 -0
- package/dist/entries/credits.d.ts +1429 -0
- package/dist/entries/credits.js +11 -0
- package/dist/entries/credits.js.map +1 -0
- package/dist/entries/edl.cjs +409 -0
- package/dist/entries/edl.cjs.map +1 -0
- package/dist/entries/edl.d.cts +1199 -0
- package/dist/entries/edl.d.ts +1199 -0
- package/dist/entries/edl.js +4 -0
- package/dist/entries/edl.js.map +1 -0
- package/dist/entries/entities.cjs +530 -0
- package/dist/entries/entities.cjs.map +1 -0
- package/dist/entries/entities.d.cts +1371 -0
- package/dist/entries/entities.d.ts +1371 -0
- package/dist/entries/entities.js +5 -0
- package/dist/entries/entities.js.map +1 -0
- package/dist/entries/i18n.cjs +48 -0
- package/dist/entries/i18n.cjs.map +1 -0
- package/dist/entries/i18n.d.cts +69 -0
- package/dist/entries/i18n.d.ts +69 -0
- package/dist/entries/i18n.js +3 -0
- package/dist/entries/i18n.js.map +1 -0
- package/dist/entries/llm-models.cjs +177 -0
- package/dist/entries/llm-models.cjs.map +1 -0
- package/dist/entries/llm-models.d.cts +435 -0
- package/dist/entries/llm-models.d.ts +435 -0
- package/dist/entries/llm-models.js +4 -0
- package/dist/entries/llm-models.js.map +1 -0
- package/dist/entries/media.cjs +335 -0
- package/dist/entries/media.cjs.map +1 -0
- package/dist/entries/media.d.cts +518 -0
- package/dist/entries/media.d.ts +518 -0
- package/dist/entries/media.js +6 -0
- package/dist/entries/media.js.map +1 -0
- package/dist/entries/model-catalog.cjs +247 -0
- package/dist/entries/model-catalog.cjs.map +1 -0
- package/dist/entries/model-catalog.d.cts +202 -0
- package/dist/entries/model-catalog.d.ts +202 -0
- package/dist/entries/model-catalog.js +6 -0
- package/dist/entries/model-catalog.js.map +1 -0
- package/dist/entries/models.cjs +833 -0
- package/dist/entries/models.cjs.map +1 -0
- package/dist/entries/models.d.cts +287 -0
- package/dist/entries/models.d.ts +287 -0
- package/dist/entries/models.js +8 -0
- package/dist/entries/models.js.map +1 -0
- package/dist/entries/nodes.cjs +789 -0
- package/dist/entries/nodes.cjs.map +1 -0
- package/dist/entries/nodes.d.cts +1600 -0
- package/dist/entries/nodes.d.ts +1600 -0
- package/dist/entries/nodes.js +16 -0
- package/dist/entries/nodes.js.map +1 -0
- package/dist/entries/organizations.cjs +80 -0
- package/dist/entries/organizations.cjs.map +1 -0
- package/dist/entries/organizations.d.cts +466 -0
- package/dist/entries/organizations.d.ts +466 -0
- package/dist/entries/organizations.js +3 -0
- package/dist/entries/organizations.js.map +1 -0
- package/dist/entries/pipeline.cjs +594 -0
- package/dist/entries/pipeline.cjs.map +1 -0
- package/dist/entries/pipeline.d.cts +2617 -0
- package/dist/entries/pipeline.d.ts +2617 -0
- package/dist/entries/pipeline.js +5 -0
- package/dist/entries/pipeline.js.map +1 -0
- package/dist/entries/scene3d.cjs +704 -0
- package/dist/entries/scene3d.cjs.map +1 -0
- package/dist/entries/scene3d.d.cts +4284 -0
- package/dist/entries/scene3d.d.ts +4284 -0
- package/dist/entries/scene3d.js +3 -0
- package/dist/entries/scene3d.js.map +1 -0
- package/dist/entries/social.cjs +714 -0
- package/dist/entries/social.cjs.map +1 -0
- package/dist/entries/social.d.cts +1366 -0
- package/dist/entries/social.d.ts +1366 -0
- package/dist/entries/social.js +5 -0
- package/dist/entries/social.js.map +1 -0
- package/dist/entries/types.cjs +13 -0
- package/dist/entries/types.cjs.map +1 -0
- package/dist/entries/types.d.cts +162 -0
- package/dist/entries/types.d.ts +162 -0
- package/dist/entries/types.js +4 -0
- package/dist/entries/types.js.map +1 -0
- package/dist/entries/ugc.cjs +279 -0
- package/dist/entries/ugc.cjs.map +1 -0
- package/dist/entries/ugc.d.cts +575 -0
- package/dist/entries/ugc.d.ts +575 -0
- package/dist/entries/ugc.js +6 -0
- package/dist/entries/ugc.js.map +1 -0
- package/dist/entries/video.cjs +549 -0
- package/dist/entries/video.cjs.map +1 -0
- package/dist/entries/video.d.cts +1791 -0
- package/dist/entries/video.d.ts +1791 -0
- package/dist/entries/video.js +8 -0
- package/dist/entries/video.js.map +1 -0
- package/dist/entries/workflow.cjs +574 -0
- package/dist/entries/workflow.cjs.map +1 -0
- package/dist/entries/workflow.d.cts +1733 -0
- package/dist/entries/workflow.d.ts +1733 -0
- package/dist/entries/workflow.js +5 -0
- package/dist/entries/workflow.js.map +1 -0
- package/dist/fan-out-meta-Bu6VyXcZ.d.cts +19 -0
- package/dist/fan-out-meta-Bu6VyXcZ.d.ts +19 -0
- package/dist/gemini-omni-voices-zeRXxSbZ.d.cts +174 -0
- package/dist/gemini-omni-voices-zeRXxSbZ.d.ts +174 -0
- package/dist/image-overlay-layers-CyBfRhxJ.d.cts +208 -0
- package/dist/image-overlay-layers-CyBfRhxJ.d.ts +208 -0
- package/dist/index.cjs +7731 -26444
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -23733
- package/dist/index.d.ts +32 -23733
- package/dist/index.js +40 -24641
- package/dist/index.js.map +1 -1
- package/dist/model-catalog-flJYaa-g.d.cts +561 -0
- package/dist/model-catalog-flJYaa-g.d.ts +561 -0
- package/dist/presentation-types-0ENOCjoj.d.cts +61 -0
- package/dist/presentation-types-0ENOCjoj.d.ts +61 -0
- package/dist/presentation-utils-BIqiCzSA.d.cts +90 -0
- package/dist/presentation-utils-BdiObtwq.d.ts +90 -0
- package/dist/scene-node-types-DjenYFLO.d.cts +1949 -0
- package/dist/scene-node-types-DjenYFLO.d.ts +1949 -0
- package/dist/supported-fonts-CRoF1gOy.d.cts +16 -0
- package/dist/supported-fonts-CRoF1gOy.d.ts +16 -0
- package/dist/types-BRlFPEru.d.cts +511 -0
- package/dist/types-BRlFPEru.d.ts +511 -0
- package/dist/types-DffyGSy5.d.cts +67 -0
- package/dist/types-DffyGSy5.d.ts +67 -0
- package/package.json +102 -1
- package/src/__tests__/add-captions-plan.test.ts +6 -2
- package/src/__tests__/caption-edge-dash.test.ts +23 -0
- package/src/__tests__/entity-image-handle.test.ts +61 -1
- package/src/__tests__/fixtures/root-exports.baseline.json +4625 -0
- package/src/__tests__/input-field-extra-keys.test.ts +1 -0
- package/src/__tests__/json-kinds.test.ts +10 -0
- package/src/__tests__/model-seed-capability.test.ts +34 -0
- package/src/__tests__/no-internal-imports.test.ts +1 -1
- package/src/__tests__/node-aspect-ratio.test.ts +25 -0
- package/src/__tests__/node-preset-extract.test.ts +8 -0
- package/src/__tests__/node-run-routes.test.ts +63 -0
- package/src/__tests__/node-runtime-keys.test.ts +70 -0
- package/src/__tests__/package-entries.test.ts +50 -0
- package/src/__tests__/pitch-tempo-pricing.test.ts +21 -0
- package/src/__tests__/presentation-utils.test.ts +14 -0
- package/src/__tests__/preview-gate-use-case.test.ts +151 -0
- package/src/__tests__/producer-types.test.ts +15 -0
- package/src/__tests__/run-continuation.test.ts +7 -1
- package/src/__tests__/seedance-draft.test.ts +74 -0
- package/src/__tests__/site-capture-node.test.ts +58 -0
- package/src/__tests__/ugc-clip-saved-list.test.ts +19 -0
- package/src/__tests__/ugc-lane-wires.test.ts +228 -0
- package/src/__tests__/ugc-node-wires.test.ts +606 -0
- package/src/__tests__/ugc-run-state.test.ts +85 -7
- package/src/__tests__/video-analysis-catalog-sync.test.ts +1 -1
- package/src/__tests__/video-analysis-pricing.test.ts +6 -6
- package/src/__tests__/voice-changer-pro-quote.test.ts +79 -0
- package/src/__tests__/workflow-export-strip.test.ts +14 -0
- package/src/add-captions-plan.ts +9 -3
- package/src/caption-edge-dash.ts +33 -0
- package/src/credit-estimators/index.ts +22 -1
- package/src/credit-estimators/pitch-tempo.ts +15 -1
- package/src/credit-estimators/speech.ts +72 -4
- package/src/credit-estimators/unit-quote.ts +52 -0
- package/src/credit-estimators/video-sfx.ts +15 -0
- package/src/credit-estimators/voice-changer-pro-quote.ts +138 -0
- package/src/entity-image-handle.ts +50 -1
- package/src/entries/apps.ts +63 -0
- package/src/entries/captions.ts +34 -0
- package/src/entries/catalogs.ts +65 -0
- package/src/entries/credits.ts +104 -0
- package/src/entries/edl.ts +42 -0
- package/src/entries/entities.ts +144 -0
- package/src/entries/i18n.ts +31 -0
- package/src/entries/llm-models.ts +63 -0
- package/src/entries/media.ts +36 -0
- package/src/entries/model-catalog.ts +89 -0
- package/src/entries/models.ts +266 -0
- package/src/entries/nodes.ts +245 -0
- package/src/entries/organizations.ts +9 -0
- package/src/entries/pipeline.ts +43 -0
- package/src/entries/scene3d.ts +27 -0
- package/src/entries/social.ts +297 -0
- package/src/entries/types.ts +26 -0
- package/src/entries/ugc.ts +14 -0
- package/src/entries/video.ts +59 -0
- package/src/entries/workflow.ts +172 -0
- package/src/fan-out-rows.ts +2 -0
- package/src/index.ts +25 -1838
- package/src/json-kinds.ts +13 -0
- package/src/model-catalog.ts +97 -36
- package/src/model-constants.ts +3 -0
- package/src/node-mappable-fields.ts +1 -0
- package/src/node-preset-export.ts +2 -2
- package/src/node-preset-extract.ts +6 -4
- package/src/node-run-routes.ts +78 -0
- package/src/node-runtime-keys.ts +50 -1
- package/src/normalize-node-params.ts +30 -0
- package/src/presentation-utils.ts +8 -0
- package/src/preview-gate.ts +92 -14
- package/src/producer-types.ts +26 -2
- package/src/run-continuation.ts +21 -0
- package/src/seedance-draft.ts +64 -0
- package/src/site-capture-node.ts +82 -0
- package/src/social-post.ts +13 -0
- package/src/ugc-lane-wires.ts +246 -0
- package/src/ugc-node-wires.ts +653 -0
- package/src/ugc-run-state.ts +65 -8
- package/src/video-analysis-pricing.ts +31 -29
- package/src/workflow-export.ts +3 -1
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The UGC node wires: every request body the five UGC nodes send and every
|
|
3
|
+
* output they hand on, as ONE pure implementation that both engines (the
|
|
4
|
+
* workflow orchestrator and the editor) call, so the two can never disagree.
|
|
5
|
+
*
|
|
6
|
+
* Content-free. A creator record is read only for `v`, `gender` and
|
|
7
|
+
* `identityImages`, a plan only for `v`, a clip ticket only for `v`, `index`
|
|
8
|
+
* and `durationSec`; every other key is opaque and passes through as it came.
|
|
9
|
+
* Every UGC-private JSON a node emits carries `v: 1`, and a wire with another
|
|
10
|
+
* `v` is refused, never guessed at.
|
|
11
|
+
*/
|
|
12
|
+
import type { CaptionPlan } from "./caption-plan.js"
|
|
13
|
+
import { fanOutItemMeta, type ClipNote } from "./fan-out-meta.js"
|
|
14
|
+
import { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from "./model-constants.js"
|
|
15
|
+
import { ugcPickPending } from "./ugc-run-state.js"
|
|
16
|
+
|
|
17
|
+
/** A UGC call that reached a deployment without the UGC routes (the router's 404). */
|
|
18
|
+
export const UGC_NOT_SERVED_MESSAGE = "UGC videos are a Nodaro Cloud feature and are not served on this deployment."
|
|
19
|
+
/** A wire whose `v` this app does not read. */
|
|
20
|
+
export const UGC_VERSION_MESSAGE = "This workflow was made with a newer version of the UGC nodes."
|
|
21
|
+
/** An answer this app cannot run: a tool it does not know, or a shape it cannot read. */
|
|
22
|
+
export const UGC_NEWER_APP_MESSAGE = "This step needs a newer app version."
|
|
23
|
+
/** A creator pick whose options are gone (another run replaced them, or they were never this node's). */
|
|
24
|
+
export const UGC_PICK_GONE_MESSAGE = "These creator options are no longer available. Run UGC Creator again."
|
|
25
|
+
/** UGC Clips with no creator on its creator input (UGC Creator has not run, or waits for a pick). */
|
|
26
|
+
export const UGC_CREATOR_MISSING_MESSAGE = "UGC Creator has no creator yet. Run it, or pick one of its options."
|
|
27
|
+
/** UGC Script's target length in seconds when the node holds none: the node's default (the route requires a length). */
|
|
28
|
+
export const UGC_SCRIPT_DEFAULT_TARGET_SEC = 15
|
|
29
|
+
/** The range of a UGC script's length, in whole seconds: the script route's, and a plan's own. */
|
|
30
|
+
export const UGC_SCRIPT_MIN_TARGET_SEC = 4
|
|
31
|
+
export const UGC_SCRIPT_MAX_TARGET_SEC = 300
|
|
32
|
+
|
|
33
|
+
const MINOR_AGE_MESSAGE = "That age can't be used: UGC creators are adults only."
|
|
34
|
+
const NEEDS_GENDER = "Choose woman or man."
|
|
35
|
+
const NEEDS_PHOTO = "Connect or upload a photo of yourself."
|
|
36
|
+
const NEEDS_CATEGORY = "Run UGC Script first, or pick a product category."
|
|
37
|
+
const NEEDS_SITE = "Add the product name or website."
|
|
38
|
+
/** The opening of the sentence UGC Clips fails with when the plugin refuses the script: "<this> <each error and its fix>". */
|
|
39
|
+
export const UGC_SCRIPT_NEEDS_CHANGES = "The script needs changes:"
|
|
40
|
+
const NEEDS_PLAN_OUT = "Connect the Script (sized) output of UGC Clips."
|
|
41
|
+
const NEEDS_PLAN = "Connect the Script output of UGC Script."
|
|
42
|
+
const NEEDS_TICKET = "Connect the Clips output of UGC Clips."
|
|
43
|
+
const NEEDS_VIDEO = "Connect the joined video."
|
|
44
|
+
const NEEDS_TRANSCRIPT = "Connect the Transcript output of UGC Clips."
|
|
45
|
+
/**
|
|
46
|
+
* A run of a video whose clips are cut from one recorded speech, on a graph with no UGC Finish on this UGC
|
|
47
|
+
* Clips' Script (sized) output: refused before anything is spent.
|
|
48
|
+
*/
|
|
49
|
+
export const UGC_NEEDS_FINISH_MESSAGE = "Add a UGC Finish node after UGC Clip, and connect UGC Clips' Script (sized) output to it."
|
|
50
|
+
/** UGC Finish with nothing on its clips input. */
|
|
51
|
+
export const UGC_FINISH_NEEDS_CLIPS_MESSAGE = "Connect the Video output of UGC Clip."
|
|
52
|
+
/** UGC Finish's job answered that a clip does not follow its speech (each clip checks itself first, so this is rare). */
|
|
53
|
+
export const UGC_FINISH_NOT_READY_MESSAGE = "A clip did not follow its speech. Re-render it from the UGC Clip node and run again."
|
|
54
|
+
/**
|
|
55
|
+
* A video cut from one recorded speech whose clips, priced once the speech is split, would hold more
|
|
56
|
+
* than the run was checked for before it started: the run stops at UGC Clips, before any clip renders.
|
|
57
|
+
*/
|
|
58
|
+
export const UGC_OVER_HOLD_MESSAGE =
|
|
59
|
+
"The clips for this recording would cost more than this run was checked for, so none was rendered. Run UGC Clips again to record the speech again."
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Every fixed sentence a UGC node fails with, by id: the English both engines write on the node.
|
|
63
|
+
* The editor shows each in the person's language by its id. Not listed: the sentence that opens
|
|
64
|
+
* with `UGC_SCRIPT_NEEDS_CHANGES` (the plugin's own words finish it), a route's own message, and
|
|
65
|
+
* "UGC step failed (<status>)".
|
|
66
|
+
*/
|
|
67
|
+
export const UGC_NODE_MESSAGES = Object.freeze({
|
|
68
|
+
notServed: UGC_NOT_SERVED_MESSAGE,
|
|
69
|
+
version: UGC_VERSION_MESSAGE,
|
|
70
|
+
newerApp: UGC_NEWER_APP_MESSAGE,
|
|
71
|
+
pickGone: UGC_PICK_GONE_MESSAGE,
|
|
72
|
+
creatorMissing: UGC_CREATOR_MISSING_MESSAGE,
|
|
73
|
+
minorAge: MINOR_AGE_MESSAGE,
|
|
74
|
+
needsGender: NEEDS_GENDER,
|
|
75
|
+
needsPhoto: NEEDS_PHOTO,
|
|
76
|
+
needsCategory: NEEDS_CATEGORY,
|
|
77
|
+
needsSite: NEEDS_SITE,
|
|
78
|
+
needsPlanOut: NEEDS_PLAN_OUT,
|
|
79
|
+
needsPlan: NEEDS_PLAN,
|
|
80
|
+
needsTicket: NEEDS_TICKET,
|
|
81
|
+
needsVideo: NEEDS_VIDEO,
|
|
82
|
+
needsTranscript: NEEDS_TRANSCRIPT,
|
|
83
|
+
needsFinish: UGC_NEEDS_FINISH_MESSAGE,
|
|
84
|
+
finishNeedsClips: UGC_FINISH_NEEDS_CLIPS_MESSAGE,
|
|
85
|
+
finishNotReady: UGC_FINISH_NOT_READY_MESSAGE,
|
|
86
|
+
overHold: UGC_OVER_HOLD_MESSAGE,
|
|
87
|
+
} as const)
|
|
88
|
+
|
|
89
|
+
/** The id of a fixed sentence a UGC node fails with (`UGC_NODE_MESSAGES`). */
|
|
90
|
+
export type UgcNodeMessageId = keyof typeof UGC_NODE_MESSAGES
|
|
91
|
+
|
|
92
|
+
/** UGC Script's screenshot inputs, in card order. */
|
|
93
|
+
export const UGC_SCREENSHOT_HANDLES: readonly string[] = [
|
|
94
|
+
"screenshot", "screenshot2", "screenshot3", "screenshot4", "screenshot5", "screenshot6", "screenshot7", "screenshot8",
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
/** Per UGC type, the output an edge with no source handle reads. */
|
|
98
|
+
export const UGC_PRIMARY_HANDLE: Readonly<Record<string, string>> = {
|
|
99
|
+
"ugc-creator": "creator",
|
|
100
|
+
"ugc-script": "plan",
|
|
101
|
+
"ugc-clips": "clips",
|
|
102
|
+
"ugc-clip": "video-out",
|
|
103
|
+
"ugc-cards": "layerPlan",
|
|
104
|
+
"ugc-finish-clips": "video-out",
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** A UGC node's outputs: handle id → the value that handle carries (a JSON string, text or a URL). */
|
|
108
|
+
export type UgcOutputs = Readonly<Record<string, string>>
|
|
109
|
+
|
|
110
|
+
type Obj = Record<string, unknown>
|
|
111
|
+
const isObject = (x: unknown): x is Obj => !!x && typeof x === "object" && !Array.isArray(x)
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The length a saved UGC plan was written to: its own `targetDurationSec`, a whole number of
|
|
115
|
+
* seconds in the script's range. Besides the lines (the opening line, each beat's line, the
|
|
116
|
+
* closing line), one of the two keys of a plan the app reads (the other: whether each beat carries
|
|
117
|
+
* a screenshot, `ugcPlanScreenshotCount`): a script that hands on its saved plan is priced at the
|
|
118
|
+
* plan's length, and shows it, never at the length setting, which may have changed since. Takes
|
|
119
|
+
* the plan or its wire (a JSON string); undefined for anything that is not a plan carrying a length.
|
|
120
|
+
*/
|
|
121
|
+
export function ugcPlanLengthSec(plan: unknown): number | undefined {
|
|
122
|
+
const value = savedPlanOf(plan)
|
|
123
|
+
if (!value) return undefined
|
|
124
|
+
const sec = value.targetDurationSec
|
|
125
|
+
return typeof sec === "number" && Number.isInteger(sec) && sec >= UGC_SCRIPT_MIN_TARGET_SEC && sec <= UGC_SCRIPT_MAX_TARGET_SEC ? sec : undefined
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* How many of a saved UGC plan's beats carry a screenshot: the screenshot cards the plan was
|
|
130
|
+
* written with. Read beat by beat: a beat carries one when its `screenshot` is an object, as the
|
|
131
|
+
* plan's own screenshots are (whatever it names); a beat that is not an object, or whose screenshot
|
|
132
|
+
* is anything else, carries none — and never makes the rest unreadable. A plan whose beats carry
|
|
133
|
+
* none is a talking-head plan (0). Read, like its length, so a script that hands on its saved plan
|
|
134
|
+
* is priced at the screenshots that plan holds, never at the script's wires, which may have changed
|
|
135
|
+
* since. Takes the plan or its wire (a JSON string); undefined only for a plan with no beats to read
|
|
136
|
+
* and for anything that is not a plan.
|
|
137
|
+
*/
|
|
138
|
+
export function ugcPlanScreenshotCount(plan: unknown): number | undefined {
|
|
139
|
+
const value = savedPlanOf(plan)
|
|
140
|
+
if (!value || !Array.isArray(value.beats)) return undefined
|
|
141
|
+
return value.beats.filter((beat) => isObject(beat) && isObject(beat.screenshot)).length
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** A saved plan, or its wire (a JSON string), as an object; undefined for anything else. */
|
|
145
|
+
function savedPlanOf(plan: unknown): Obj | undefined {
|
|
146
|
+
let value: unknown = plan
|
|
147
|
+
if (typeof value === "string") {
|
|
148
|
+
try {
|
|
149
|
+
value = JSON.parse(value)
|
|
150
|
+
} catch {
|
|
151
|
+
return undefined
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return isObject(value) ? value : undefined
|
|
155
|
+
}
|
|
156
|
+
/** A string with something in it; an empty or blank field or input counts as absent. */
|
|
157
|
+
const filled = (x: unknown): string | undefined => (typeof x === "string" && x.trim() !== "" ? x : undefined)
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* What an edge from a UGC node reads, on both engines: the value of the pip it leaves — an edge
|
|
161
|
+
* with no source handle reads the node's primary output — from the node's outputs by pip. Only a
|
|
162
|
+
* pip the outputs hold as a string ("" included: an empty transcript is a value); an inherited
|
|
163
|
+
* key or a non-string is no value.
|
|
164
|
+
*/
|
|
165
|
+
export function ugcPipValue(outputs: unknown, sourceType: string, sourceHandle?: string | null): string | undefined {
|
|
166
|
+
const pip = sourceHandle || (Object.hasOwn(UGC_PRIMARY_HANDLE, sourceType) ? UGC_PRIMARY_HANDLE[sourceType] : undefined)
|
|
167
|
+
if (pip === undefined || !isObject(outputs) || !Object.hasOwn(outputs, pip)) return undefined
|
|
168
|
+
const value = outputs[pip]
|
|
169
|
+
return typeof value === "string" ? value : undefined
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* A UGC wire (a JSON string or an object) → its value when it is an object with `v: 1`.
|
|
174
|
+
* Another `v` → the version message. Anything that is not a UGC wire at all (nothing
|
|
175
|
+
* connected, not JSON, no `v`) → `unreadable`, which a node words as the input it needs.
|
|
176
|
+
*/
|
|
177
|
+
export function readUgcWire(raw: unknown, unreadable: string = UGC_VERSION_MESSAGE): { value: Record<string, unknown> } | { error: string } {
|
|
178
|
+
let parsed: unknown = raw
|
|
179
|
+
if (typeof raw === "string") {
|
|
180
|
+
try {
|
|
181
|
+
parsed = JSON.parse(raw)
|
|
182
|
+
} catch {
|
|
183
|
+
return { error: unreadable }
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (!isObject(parsed) || parsed.v === undefined) return { error: unreadable }
|
|
187
|
+
if (parsed.v !== 1) return { error: UGC_VERSION_MESSAGE }
|
|
188
|
+
return { value: parsed }
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** The route's `{ error: { code, message } }` (or a framework error's top-level `message`). */
|
|
192
|
+
function routeErrorOf(body: string): { code?: string; message?: string } {
|
|
193
|
+
let parsed: unknown
|
|
194
|
+
try {
|
|
195
|
+
parsed = JSON.parse(body)
|
|
196
|
+
} catch {
|
|
197
|
+
return {}
|
|
198
|
+
}
|
|
199
|
+
if (!isObject(parsed)) return {}
|
|
200
|
+
if (isObject(parsed.error)) {
|
|
201
|
+
const { code, message } = parsed.error
|
|
202
|
+
return { code: typeof code === "string" ? code : undefined, message: filled(message) }
|
|
203
|
+
}
|
|
204
|
+
return { message: filled(parsed.message) }
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* A failed UGC call → the sentence the node fails with. A 404 that names no error code is
|
|
209
|
+
* the router's (the route is not registered here) → the Cloud sentence; a route's own 404
|
|
210
|
+
* names a code and keeps its message. `minor_age_refused` → the adults-only sentence. A 4xx
|
|
211
|
+
* or 503 → the route's message. Anything else → "UGC step failed (<status>)".
|
|
212
|
+
*/
|
|
213
|
+
export function ugcFailure(status: number, body: string): string {
|
|
214
|
+
const error = routeErrorOf(body)
|
|
215
|
+
if (status === 404 && error.code === undefined) return UGC_NOT_SERVED_MESSAGE
|
|
216
|
+
if (error.code === "minor_age_refused") return MINOR_AGE_MESSAGE
|
|
217
|
+
if ((status === 503 || (status >= 400 && status < 500)) && error.message) return error.message
|
|
218
|
+
return `UGC step failed (${status})`
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ── UGC Creator ──────────────────────────────────────────────────────────────
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* The pickers whose own set fields shape a sampled creator: the picker types UGC Creator's
|
|
225
|
+
* `pickers` input takes (the route takes no other). One list for the editor's connection rule
|
|
226
|
+
* and both engines' input resolvers.
|
|
227
|
+
*/
|
|
228
|
+
export const UGC_CREATOR_PICKER_TYPES: ReadonlySet<string> = new Set(["person", "styling", "setting", "lighting"])
|
|
229
|
+
|
|
230
|
+
/** The UGC Creator node-data keys its request body reads. */
|
|
231
|
+
export interface UgcCreatorFields {
|
|
232
|
+
readonly source?: string
|
|
233
|
+
readonly gender?: string
|
|
234
|
+
readonly photoUrl?: string
|
|
235
|
+
readonly categoryOverride?: string
|
|
236
|
+
readonly seed?: number
|
|
237
|
+
readonly keepResult?: boolean
|
|
238
|
+
readonly result?: Readonly<Record<string, unknown>>
|
|
239
|
+
/** The options a draw left waiting for the pick (run state): read only for `previous`. */
|
|
240
|
+
readonly candidates?: unknown
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** The traits of the latest creator the person saw: the first waiting option's, else the last result's (Keep off). */
|
|
244
|
+
function previousTraits(data: UgcCreatorFields): unknown {
|
|
245
|
+
if (ugcPickPending(data)) {
|
|
246
|
+
const first: unknown = (data.candidates as readonly unknown[])[0]
|
|
247
|
+
const record = isObject(first) ? first.record : undefined
|
|
248
|
+
return isObject(record) ? record.traits : undefined
|
|
249
|
+
}
|
|
250
|
+
return !data.keepResult && isObject(data.result) ? data.result.traits : undefined
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** The wired pickers that set a field (their own fields, as the resolver read them); undefined when none did. */
|
|
254
|
+
function setPickers(pickers: Record<string, Record<string, unknown>> | undefined): Record<string, Record<string, unknown>> | undefined {
|
|
255
|
+
if (!pickers) return undefined
|
|
256
|
+
const set = Object.entries(pickers).filter(([, fields]) => isObject(fields) && Object.keys(fields).length > 0)
|
|
257
|
+
return set.length > 0 ? Object.fromEntries(set) : undefined
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The `/v1/ugc/creator` body. A photo: the wired photo, else the node's own. A sampled
|
|
262
|
+
* creator: the product category (the node's override, else the wired one), the pickers that
|
|
263
|
+
* set a field, the node's seed, and the traits of the latest creator the person saw as
|
|
264
|
+
* `previous`, so the next one differs: the first option waiting for the pick, else — on a
|
|
265
|
+
* re-run that does not keep the result — the last creator's. Refuses before any call.
|
|
266
|
+
*/
|
|
267
|
+
export function ugcCreatorBody(input: {
|
|
268
|
+
data: UgcCreatorFields
|
|
269
|
+
photoUrl?: string
|
|
270
|
+
category?: string
|
|
271
|
+
pickers?: Record<string, Record<string, unknown>>
|
|
272
|
+
}): { body: Record<string, unknown> } | { error: string } {
|
|
273
|
+
const { data } = input
|
|
274
|
+
const gender = data.gender
|
|
275
|
+
if (gender !== "woman" && gender !== "man") return { error: NEEDS_GENDER }
|
|
276
|
+
if (data.source === "photo") {
|
|
277
|
+
const imageUrl = filled(input.photoUrl) ?? filled(data.photoUrl)
|
|
278
|
+
if (!imageUrl) return { error: NEEDS_PHOTO }
|
|
279
|
+
return { body: { source: { kind: "photo", imageUrl, gender } } }
|
|
280
|
+
}
|
|
281
|
+
const productCategory = filled(data.categoryOverride) ?? filled(input.category)
|
|
282
|
+
if (!productCategory) return { error: NEEDS_CATEGORY }
|
|
283
|
+
const pickers = setPickers(input.pickers)
|
|
284
|
+
const traits = previousTraits(data)
|
|
285
|
+
return {
|
|
286
|
+
body: {
|
|
287
|
+
...(typeof data.seed === "number" ? { seed: data.seed } : {}),
|
|
288
|
+
source: {
|
|
289
|
+
kind: "sampled",
|
|
290
|
+
gender,
|
|
291
|
+
productCategory,
|
|
292
|
+
...(pickers ? { pickers } : {}),
|
|
293
|
+
...(isObject(traits) ? { previous: traits } : {}),
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* The creator the node hands on: the record (`creator`, v1) and its first image (`image`).
|
|
301
|
+
* `identityImages` are the images of the candidate the node hands on — the picked one where
|
|
302
|
+
* a person picked. The record copies the listed fields only, so `candidates`, `fallback`,
|
|
303
|
+
* `pick` and `image` never reach the `creator` wire.
|
|
304
|
+
*/
|
|
305
|
+
export function ugcCreatorOutputs(answer: Record<string, unknown>, identityImages: readonly string[]): { outputs: UgcOutputs; imageUrl: string; record: Record<string, unknown> } {
|
|
306
|
+
const record: Record<string, unknown> = {
|
|
307
|
+
v: 1,
|
|
308
|
+
kind: answer.kind,
|
|
309
|
+
gender: answer.gender,
|
|
310
|
+
identityImages: [...identityImages],
|
|
311
|
+
traits: answer.traits ?? null,
|
|
312
|
+
seed: answer.seed ?? null,
|
|
313
|
+
promptsVersion: answer.promptsVersion,
|
|
314
|
+
productCategory: answer.productCategory ?? null,
|
|
315
|
+
}
|
|
316
|
+
const imageUrl = identityImages[0] ?? ""
|
|
317
|
+
return { outputs: { creator: JSON.stringify(record), ...(imageUrl ? { image: imageUrl } : {}) }, imageUrl, record }
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** One builder call as the app runs it: `tool` and `args`, nothing else (a candidate's other keys, its model included, are never read). */
|
|
321
|
+
export interface UgcCreatorCall { readonly tool: string; readonly args: Readonly<Record<string, unknown>> }
|
|
322
|
+
|
|
323
|
+
/** What a creator answer asks the node to render. */
|
|
324
|
+
export interface UgcCreatorCandidateCalls {
|
|
325
|
+
/** Every candidate's image call, the primary first. One call (`image`) for an answer from before candidates; none for a photo. */
|
|
326
|
+
readonly calls: readonly UgcCreatorCall[]
|
|
327
|
+
/** The round's one moderation fallback: it runs once, and only when every candidate the run rendered was blocked. */
|
|
328
|
+
readonly fallback: UgcCreatorCall | null
|
|
329
|
+
/** "user": a person picks among `calls` where one can be asked; "primary": `calls[0]` alone; null: nothing to render (a photo). */
|
|
330
|
+
readonly pick: "user" | "primary" | null
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const callOf = (raw: unknown): UgcCreatorCall | undefined => {
|
|
334
|
+
if (!raw || typeof raw !== "object") return undefined
|
|
335
|
+
const { tool, args } = raw as { tool?: unknown; args?: unknown }
|
|
336
|
+
if (typeof tool !== "string" || !args || typeof args !== "object" || Array.isArray(args)) return undefined
|
|
337
|
+
return { tool, args: args as Readonly<Record<string, unknown>> }
|
|
338
|
+
}
|
|
339
|
+
const fallbackOf = (image: unknown): unknown => (image && typeof image === "object" ? (image as { fallback?: unknown }).fallback : undefined)
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* A `/v1/ugc/creator` answer's image calls. Content-free: reads `image` (`tool`, `args`,
|
|
343
|
+
* `fallback`), `candidates[].tool|args`, `fallback` and `pick.how` — never a candidate's
|
|
344
|
+
* model. An answer without `candidates` (an older builder) renders `image` alone, as before.
|
|
345
|
+
*/
|
|
346
|
+
export function ugcCreatorCandidates(answer: Readonly<Record<string, unknown>>): UgcCreatorCandidateCalls | { readonly error: string } {
|
|
347
|
+
const listed = answer.candidates
|
|
348
|
+
const noList = listed === undefined || listed === null || (Array.isArray(listed) && listed.length === 0)
|
|
349
|
+
const noImage = answer.image === undefined || answer.image === null
|
|
350
|
+
if (noList && noImage) return { calls: [], fallback: null, pick: null }
|
|
351
|
+
if (noList) {
|
|
352
|
+
const image = callOf(answer.image)
|
|
353
|
+
if (!image) return { error: UGC_NEWER_APP_MESSAGE }
|
|
354
|
+
return { calls: [image], fallback: callOf(fallbackOf(answer.image)) ?? null, pick: "primary" }
|
|
355
|
+
}
|
|
356
|
+
if (!Array.isArray(listed)) return { error: UGC_NEWER_APP_MESSAGE }
|
|
357
|
+
const calls = listed.map(callOf)
|
|
358
|
+
if (calls.some((c) => c === undefined)) return { error: UGC_NEWER_APP_MESSAGE }
|
|
359
|
+
const how = (answer.pick as { how?: unknown } | null | undefined)?.how
|
|
360
|
+
return {
|
|
361
|
+
calls: calls as UgcCreatorCall[],
|
|
362
|
+
fallback: callOf(answer.fallback) ?? callOf(fallbackOf(answer.image)) ?? null,
|
|
363
|
+
pick: how === "user" && calls.length > 1 ? "user" : "primary",
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** The calls a run renders: every candidate where a person is there to pick, else the primary alone. */
|
|
368
|
+
export function ugcCreatorCallsToRender(c: UgcCreatorCandidateCalls, opts: { readonly personPicks: boolean }): readonly UgcCreatorCall[] {
|
|
369
|
+
return opts.personPicks && c.pick === "user" ? c.calls : c.calls.slice(0, 1)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** One rendered candidate that passed its checks, kept on the node until the person picks (run state, never a wire). */
|
|
373
|
+
export interface UgcCreatorCandidate { readonly imageUrl: string; readonly record: Readonly<Record<string, unknown>> }
|
|
374
|
+
|
|
375
|
+
export function ugcCreatorCandidate(answer: Readonly<Record<string, unknown>>, images: readonly string[]): UgcCreatorCandidate {
|
|
376
|
+
const out = ugcCreatorOutputs(answer as Record<string, unknown>, images)
|
|
377
|
+
return { imageUrl: out.imageUrl, record: out.record }
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/** A UGC Creator run output that waits for the person's pick: two or more options (`ugcCandidates`). */
|
|
381
|
+
export function ugcAwaitsPick(output: unknown): boolean {
|
|
382
|
+
const candidates = isObject(output) ? output.ugcCandidates : undefined
|
|
383
|
+
return Array.isArray(candidates) && candidates.length >= 2
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** The person's pick, read back from node data (untrusted): a stale index, a foreign list or another version is refused. */
|
|
387
|
+
export function ugcCreatorPick(candidates: unknown, index: number):
|
|
388
|
+
{ readonly result: Readonly<Record<string, unknown>>; readonly outputs: UgcOutputs; readonly imageUrl: string } | { readonly error: string } {
|
|
389
|
+
const entry: unknown = Array.isArray(candidates) && Number.isInteger(index) && index >= 0 ? candidates[index] : undefined
|
|
390
|
+
const imageUrl = (entry as { imageUrl?: unknown } | undefined)?.imageUrl
|
|
391
|
+
const record = (entry as { record?: unknown } | undefined)?.record
|
|
392
|
+
if (typeof imageUrl !== "string" || !record || typeof record !== "object" || Array.isArray(record)) return { error: UGC_PICK_GONE_MESSAGE }
|
|
393
|
+
const r = record as Record<string, unknown>
|
|
394
|
+
if (r.v !== 1) return { error: UGC_VERSION_MESSAGE }
|
|
395
|
+
if (!Array.isArray(r.identityImages) || r.identityImages[0] !== imageUrl) return { error: UGC_PICK_GONE_MESSAGE }
|
|
396
|
+
return { result: r, outputs: { creator: JSON.stringify(r), image: imageUrl }, imageUrl }
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// ── UGC Script ───────────────────────────────────────────────────────────────
|
|
400
|
+
|
|
401
|
+
/** The languages a UGC script can be written in: the node's choice (`UgcScriptData.language`). */
|
|
402
|
+
export const UGC_SCRIPT_LANGUAGES = ["en", "he"] as const
|
|
403
|
+
export type UgcScriptLanguage = (typeof UGC_SCRIPT_LANGUAGES)[number]
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* The `/v1/ugc/script` body: the product name or website (required), the screenshot slots
|
|
407
|
+
* in card order with the empty ones dropped, the product image when set, the target length
|
|
408
|
+
* (`UGC_SCRIPT_DEFAULT_TARGET_SEC` when the node holds no number), and the language (the
|
|
409
|
+
* node's choice; English when it holds none or one this app does not know).
|
|
410
|
+
*/
|
|
411
|
+
export function ugcScriptBody(input: {
|
|
412
|
+
site?: string
|
|
413
|
+
screenshots: ReadonlyArray<string | undefined>
|
|
414
|
+
productImage?: string
|
|
415
|
+
targetDurationSec?: number
|
|
416
|
+
language?: unknown
|
|
417
|
+
}): { body: Record<string, unknown> } | { error: string } {
|
|
418
|
+
const site = filled(input.site)?.trim()
|
|
419
|
+
if (!site) return { error: NEEDS_SITE }
|
|
420
|
+
const productImage = filled(input.productImage)
|
|
421
|
+
return {
|
|
422
|
+
body: {
|
|
423
|
+
site,
|
|
424
|
+
screenshots: input.screenshots.filter((s): s is string => filled(s) !== undefined),
|
|
425
|
+
...(productImage ? { productImage } : {}),
|
|
426
|
+
targetDurationSec: typeof input.targetDurationSec === "number" ? input.targetDurationSec : UGC_SCRIPT_DEFAULT_TARGET_SEC,
|
|
427
|
+
language: (UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(input.language) ? input.language : "en",
|
|
428
|
+
},
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** A finished UGC Script job → `plan` (the plan, v1) and `category` (text). */
|
|
433
|
+
export function ugcScriptOutputs(outputData: Record<string, unknown>): UgcOutputs {
|
|
434
|
+
const plan = outputData.plan
|
|
435
|
+
const category = filled(outputData.productCategory)
|
|
436
|
+
return {
|
|
437
|
+
...(isObject(plan) ? { plan: JSON.stringify({ v: 1, ...plan }) } : {}),
|
|
438
|
+
...(category ? { category } : {}),
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** UGC Script's last result, as the node holds it. */
|
|
443
|
+
export type UgcScriptResult = {
|
|
444
|
+
plan: Record<string, unknown>
|
|
445
|
+
productCategory: string
|
|
446
|
+
warnings: unknown[]
|
|
447
|
+
notes: string[]
|
|
448
|
+
rounds: number
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/** A finished UGC Script job → the node's `result`, written the same by both engines; none without a plan. */
|
|
452
|
+
export function ugcScriptResult(outputData: Readonly<Record<string, unknown>>): UgcScriptResult | undefined {
|
|
453
|
+
const { plan, productCategory, warnings, notes, rounds } = outputData
|
|
454
|
+
if (!isObject(plan)) return undefined
|
|
455
|
+
return {
|
|
456
|
+
plan,
|
|
457
|
+
productCategory: filled(productCategory) ?? "",
|
|
458
|
+
warnings: Array.isArray(warnings) ? [...warnings] : [],
|
|
459
|
+
notes: Array.isArray(notes) ? notes.filter((n): n is string => typeof n === "string") : [],
|
|
460
|
+
rounds: typeof rounds === "number" && Number.isFinite(rounds) ? rounds : 0,
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// ── Kept results ─────────────────────────────────────────────────────────────
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* What a UGC Creator or UGC Script with Keep on hands on instead of running: the outputs of
|
|
468
|
+
* the result it holds. Null — the node runs — when Keep is off, when the result holds nothing
|
|
469
|
+
* to hand on (a creator without its image, a script without its plan), and for a creator whose
|
|
470
|
+
* options wait for a pick, whatever Keep says. The creator record goes on unread; whoever reads
|
|
471
|
+
* it refuses another version.
|
|
472
|
+
*/
|
|
473
|
+
export function ugcKeptOutputs(type: "ugc-creator" | "ugc-script", data: Readonly<Record<string, unknown>>): UgcOutputs | null {
|
|
474
|
+
if (type === "ugc-creator" && ugcPickPending(data)) return null
|
|
475
|
+
const result = data.keepResult === true ? data.result : undefined
|
|
476
|
+
if (!isObject(result)) return null
|
|
477
|
+
if (type === "ugc-creator") {
|
|
478
|
+
const image = Array.isArray(result.identityImages) ? filled(result.identityImages[0]) : undefined
|
|
479
|
+
return image ? { creator: JSON.stringify(result), image } : null
|
|
480
|
+
}
|
|
481
|
+
if (type === "ugc-script") return isObject(result.plan) ? ugcScriptOutputs(result) : null
|
|
482
|
+
return null
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// ── UGC Clips ────────────────────────────────────────────────────────────────
|
|
486
|
+
|
|
487
|
+
/** The `/v1/ugc/clips` canvas body: the plan, the creator's gender, traits and images, and the picked voice. */
|
|
488
|
+
export function ugcClipsBody(input: { planWire: unknown; creatorWire: unknown; voiceId?: string }): { body: Record<string, unknown> } | { error: string } {
|
|
489
|
+
const plan = readUgcWire(input.planWire, NEEDS_PLAN)
|
|
490
|
+
if ("error" in plan) return plan
|
|
491
|
+
const creator = readUgcWire(input.creatorWire, UGC_CREATOR_MISSING_MESSAGE)
|
|
492
|
+
if ("error" in creator) return creator
|
|
493
|
+
const voiceId = filled(input.voiceId)
|
|
494
|
+
return {
|
|
495
|
+
body: {
|
|
496
|
+
plan: plan.value,
|
|
497
|
+
gender: creator.value.gender,
|
|
498
|
+
traits: creator.value.traits ?? null,
|
|
499
|
+
identityImages: creator.value.identityImages,
|
|
500
|
+
surface: "canvas",
|
|
501
|
+
...(voiceId ? { voiceId } : {}),
|
|
502
|
+
},
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* The `/v1/ugc/clips` answer → the tickets (one per clip, as JSON strings), `clips` (the
|
|
508
|
+
* first), `plan-out` (`{ v: 1, plan, transcribeArgs }` for UGC Cards), `transcript`, whether
|
|
509
|
+
* the plan has cards, and whether the clips go through UGC Finish's job (`finishes`: the plan-out
|
|
510
|
+
* carries a finish call, which is what UGC Finish reads to run it). An answer with errors → "The script needs changes: …" with each
|
|
511
|
+
* error and its fix; an answer without the parts UGC Cards needs fails here, before any clip
|
|
512
|
+
* is paid for.
|
|
513
|
+
*/
|
|
514
|
+
export function ugcClipsOutputs(answer: Record<string, unknown>): { outputs: UgcOutputs; tickets: string[]; hasCards: boolean; finishes: boolean } | { error: string } {
|
|
515
|
+
const errors = Array.isArray(answer.errors) ? answer.errors : []
|
|
516
|
+
if (errors.length > 0) {
|
|
517
|
+
const said = errors.flatMap((e) => (isObject(e) ? [filled(e.message), filled(e.fix)] : [])).filter((s): s is string => s !== undefined)
|
|
518
|
+
return { error: said.length > 0 ? `${UGC_SCRIPT_NEEDS_CHANGES} ${said.join(" ")}` : UGC_NEWER_APP_MESSAGE }
|
|
519
|
+
}
|
|
520
|
+
const { tickets, sizedPlan, transcript, speechCheckCall } = answer
|
|
521
|
+
if (!Array.isArray(tickets) || tickets.length === 0 || !tickets.every(isObject) || !isObject(sizedPlan) || typeof transcript !== "string") {
|
|
522
|
+
return { error: UGC_NEWER_APP_MESSAGE }
|
|
523
|
+
}
|
|
524
|
+
const wires = tickets.map((t) => JSON.stringify(t))
|
|
525
|
+
// The speech check's arguments ride to UGC Cards' transcription unread (an answer without them: none).
|
|
526
|
+
const transcribeArgs = isObject(speechCheckCall) && isObject(speechCheckCall.args) ? speechCheckCall.args : {}
|
|
527
|
+
// A video cut from one recorded speech (the segmented lane) also hands UGC Finish its finish call's
|
|
528
|
+
// arguments (the segments with their room), opaque; any other answer's plan-out is unchanged.
|
|
529
|
+
const finish = isObject(answer.finish) && isObject(answer.finish.args) ? { finish: answer.finish.args } : {}
|
|
530
|
+
return {
|
|
531
|
+
outputs: { clips: wires[0]!, "plan-out": JSON.stringify({ v: 1, plan: sizedPlan, transcribeArgs, ...finish }), transcript },
|
|
532
|
+
tickets: wires,
|
|
533
|
+
hasCards: answer.hasCards === true,
|
|
534
|
+
finishes: "finish" in finish,
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// ── UGC Clip ─────────────────────────────────────────────────────────────────
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* The `/v1/ugc/clip` body for one ticket: the ticket, `nonce` = how many times this clip was
|
|
542
|
+
* re-rendered (`rerender["<clip number>"]`, else 0) and `runKey` when one is given.
|
|
543
|
+
*/
|
|
544
|
+
export function ugcClipBody(input: { ticketWire: unknown; rerender?: Readonly<Record<string, number>>; runKey?: string }):
|
|
545
|
+
{ body: Record<string, unknown>; clipNumber: number; durationSec: number } | { error: string } {
|
|
546
|
+
const read = readUgcWire(input.ticketWire, NEEDS_TICKET)
|
|
547
|
+
if ("error" in read) return read
|
|
548
|
+
const ticket = read.value
|
|
549
|
+
const { index, durationSec } = ticket
|
|
550
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return { error: NEEDS_TICKET }
|
|
551
|
+
if (typeof durationSec !== "number" || !Number.isFinite(durationSec) || durationSec <= 0) return { error: NEEDS_TICKET }
|
|
552
|
+
const clipNumber = index + 1
|
|
553
|
+
const count = input.rerender?.[String(clipNumber)]
|
|
554
|
+
const nonce = typeof count === "number" && Number.isInteger(count) && count >= 0 ? count : 0
|
|
555
|
+
const runKey = filled(input.runKey)
|
|
556
|
+
return { body: { ticket, nonce, ...(runKey ? { runKey } : {}) }, clipNumber, durationSec }
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* A finished UGC Clip job (`{ videoUrl, durationSec, clipWarnings, … }`) → `video-out`, the
|
|
561
|
+
* clip's real length (null when unknown) and its warnings ([] when it has none).
|
|
562
|
+
*/
|
|
563
|
+
export function ugcClipOutputs(outputData: Record<string, unknown>): { outputs: UgcOutputs; videoUrl: string; durationSec: number | null; clipWarnings: string[] } {
|
|
564
|
+
const videoUrl = filled(outputData.videoUrl) ?? ""
|
|
565
|
+
const meta = fanOutItemMeta(outputData)
|
|
566
|
+
return { outputs: videoUrl ? { "video-out": videoUrl } : {}, videoUrl, durationSec: meta.durationSec, clipWarnings: [...meta.warnings] }
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* What a list read (a Bundle edge, a fold) takes from a UGC Clip's saved data, on both engines:
|
|
571
|
+
* its last fanned-out batch — one take per clip, in clip order — when its last run was one; else
|
|
572
|
+
* exactly the take it shows (its active result, else its video). Never the earlier takes it keeps:
|
|
573
|
+
* a video of one clip (one ticket, so no fan-out) would join every take. A single run clears the
|
|
574
|
+
* batch (the editor's job patch), so a batch held is always the last run's. Undefined when it holds
|
|
575
|
+
* no take at all.
|
|
576
|
+
*/
|
|
577
|
+
export function ugcClipSavedList(data: unknown): string[] | undefined {
|
|
578
|
+
if (!isObject(data)) return undefined
|
|
579
|
+
const batch = Array.isArray(data.__listResults) ? data.__listResults.filter((u): u is string => typeof u === "string" && u !== "") : []
|
|
580
|
+
if (batch.length > 0) return batch
|
|
581
|
+
const results = Array.isArray(data.generatedResults) ? data.generatedResults : []
|
|
582
|
+
const index = typeof data.activeResultIndex === "number" && Number.isInteger(data.activeResultIndex) ? data.activeResultIndex : 0
|
|
583
|
+
const active = results[index]
|
|
584
|
+
const url = (isObject(active) ? filled(active.url) : undefined) ?? filled(data.generatedVideoUrl)
|
|
585
|
+
return url ? [url] : undefined
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// ── UGC Cards ────────────────────────────────────────────────────────────────
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* UGC Cards' two timing jobs on the joined video, and the plan they time. The plan input must
|
|
592
|
+
* be UGC Clips' `{ v: 1, plan, transcribeArgs }`; anything else is refused before either job.
|
|
593
|
+
* The transcription spreads `transcribeArgs` unread, then sets the node's own fields last, so
|
|
594
|
+
* the wire can add a language but never change the provider or the word timings.
|
|
595
|
+
*/
|
|
596
|
+
export function ugcCardsJobs(input: { planOutWire: unknown; videoUrl?: string; transcript?: string }): {
|
|
597
|
+
alignment: { path: "/v1/forced-alignment"; body: Record<string, unknown> }
|
|
598
|
+
transcribe: { path: "/v1/transcribe"; body: Record<string, unknown> }
|
|
599
|
+
plan: Record<string, unknown>
|
|
600
|
+
} | { error: string } {
|
|
601
|
+
const read = readUgcWire(input.planOutWire, NEEDS_PLAN_OUT)
|
|
602
|
+
if ("error" in read) return read
|
|
603
|
+
const { plan, transcribeArgs } = read.value
|
|
604
|
+
if (!isObject(plan) || !isObject(transcribeArgs)) return { error: NEEDS_PLAN_OUT }
|
|
605
|
+
const videoUrl = filled(input.videoUrl)
|
|
606
|
+
if (!videoUrl) return { error: NEEDS_VIDEO }
|
|
607
|
+
// An empty transcript is what UGC Clips said, not a missing input: it goes on as it came.
|
|
608
|
+
const transcript = input.transcript
|
|
609
|
+
if (typeof transcript !== "string") return { error: NEEDS_TRANSCRIPT }
|
|
610
|
+
return {
|
|
611
|
+
alignment: { path: "/v1/forced-alignment", body: { audioUrl: videoUrl, transcript } },
|
|
612
|
+
transcribe: { path: "/v1/transcribe", body: { ...transcribeArgs, audioUrl: videoUrl, provider: DEFAULT_TRANSCRIBE_NODE_PROVIDER, wordTimestamps: true } },
|
|
613
|
+
plan,
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* The `/v1/ugc/cards` canvas body: the plan, the video, whichever timing came back as a list,
|
|
619
|
+
* the timing jobs that failed, and the clips' notes.
|
|
620
|
+
*/
|
|
621
|
+
export function ugcCardsBody(input: {
|
|
622
|
+
plan: Record<string, unknown>
|
|
623
|
+
videoUrl: string
|
|
624
|
+
alignment?: unknown
|
|
625
|
+
words?: unknown
|
|
626
|
+
failed: ReadonlyArray<"alignment" | "words">
|
|
627
|
+
clipNotes: ReadonlyArray<ClipNote>
|
|
628
|
+
}): Record<string, unknown> {
|
|
629
|
+
return {
|
|
630
|
+
surface: "canvas",
|
|
631
|
+
plan: input.plan,
|
|
632
|
+
videoUrl: input.videoUrl,
|
|
633
|
+
...(Array.isArray(input.alignment) ? { alignment: input.alignment } : {}),
|
|
634
|
+
...(Array.isArray(input.words) ? { words: input.words } : {}),
|
|
635
|
+
failed: [...input.failed],
|
|
636
|
+
clipNotes: [...input.clipNotes],
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/** The caption plan when nothing could be timed: Add Captions renders no captions from it. */
|
|
641
|
+
const EMPTY_CAPTION_PLAN: CaptionPlan = { v: 1, hookText: "", hookEndMs: 0, bodyEndMs: 0, captions: [] }
|
|
642
|
+
|
|
643
|
+
/** The `/v1/ugc/cards` answer → `layerPlan`, `captionPlan` (v1; the empty plan when untimed) and `report` (one line per sentence). */
|
|
644
|
+
export function ugcCardsOutputs(answer: Record<string, unknown>): UgcOutputs {
|
|
645
|
+
const timing = answer.captionTiming
|
|
646
|
+
const report = answer.report
|
|
647
|
+
const lines = isObject(report) && Array.isArray(report.lines) ? report.lines.filter((l): l is string => typeof l === "string") : []
|
|
648
|
+
return {
|
|
649
|
+
layerPlan: JSON.stringify(Array.isArray(answer.layerPlan) ? answer.layerPlan : []),
|
|
650
|
+
captionPlan: JSON.stringify(isObject(timing) ? { v: 1, ...timing } : EMPTY_CAPTION_PLAN),
|
|
651
|
+
report: lines.join("\n"),
|
|
652
|
+
}
|
|
653
|
+
}
|