@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 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pinterest-url.ts","../src/scraper-output-schemas.ts","../src/telegram-account-trigger.ts","../src/telegram-account-send.ts","../src/scraper-actors.ts","../src/meta-ads-scrape.ts","../src/instagram-scrape.ts","../src/social-search.ts","../src/saved-posts.ts","../src/social-post-readers.ts","../src/competitors.ts","../src/social-media-specs.ts","../src/telegram-channel.ts"],"names":["analysisSuffix","urlStrings","isRecord","str","emitted"],"mappings":";;;AAgBO,SAAS,sBAAsB,GAAA,EAAqB;AACzD,EAAA,IAAI;AACF,IAAA,MAAM,CAAA,GAAI,IAAI,GAAA,CAAI,GAAG,CAAA;AACrB,IAAA,IAAI,CAAA,CA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AY,KAAA;AAC5F,EAAA,OAAO,EAAE,OAAA,EAAS,QAAA,EAAU,cAAA,GAAiB,YAAY,KAAA,EAAM;AACjE","file":"chunk-WDIBOWAA.js","sourcesContent":["/**\n * Auto-upgrade Pinterest CDN URLs to their highest-resolution variant.\n *\n * `i.pinimg.com` serves the same image at multiple sizes via a path-prefix\n * segment: `/236x/`, `/474x/`, `/564x/`, `/736x/`, `/1200x/`, `/originals/`.\n * The `originals` segment returns the source resolution — much better input\n * for `describe-image`, `image-to-image`, `face-swap`, etc.\n *\n * Returns the input unchanged when:\n * - the URL doesn't parse as a URL\n * - the host isn't `i.pinimg.com`\n * - the path doesn't start with a recognized size segment\n *\n * Used by the upload-image node when a user pastes a Pinterest URL, and by\n * any backend describe-image-style fetch that wants the highest-res input.\n */\nexport function normalizePinterestUrl(url: string): string {\n try {\n const u = new URL(url)\n if (u.hostname !== \"i.pinimg.com\") return url\n const next = u.pathname.replace(/^\\/(?:\\d+x|originals)\\//, \"/originals/\")\n if (next === u.pathname) return url\n u.pathname = next\n return u.toString()\n } catch {\n return url\n }\n}\n","import type { ScraperActorId } from \"./scraper-actors.js\"\n\n/**\n * Scalar fields exposed in the Extract Field dropdown when the direct\n * upstream is a web-scrape node. Nested / non-scalar fields (authorMeta,\n * musicMeta) are intentionally omitted — users access them via the\n * \"Custom path...\" option.\n *\n * content-crawler paths are pre-dotted (`pages.url`, `pages.markdown`)\n * because its root shape is `{ pages: [...] }`, not a top-level array.\n */\nexport const SCRAPER_OUTPUT_FIELDS: Record<ScraperActorId, readonly string[]> = {\n \"content-crawler\": [\"pages.url\", \"pages.markdown\"],\n \"google-search\": [\"title\", \"url\", \"description\"],\n \"instagram\": [\n \"url\", \"shortCode\", \"caption\", \"displayUrl\", \"videoUrl\",\n \"timestamp\", \"likesCount\", \"commentsCount\", \"ownerUsername\", \"type\",\n \"childPosts\",\n ],\n \"tiktok\": [\n \"id\", \"webVideoUrl\", \"videoUrl\", \"text\", \"createTime\",\n \"diggCount\", \"shareCount\", \"playCount\", \"commentCount\",\n ],\n \"rss\": [\"title\", \"url\", \"description\", \"pubDate\", \"guid\"],\n} as const\n","/**\n * The Telegram Account Trigger's named outputs — the wire contract between the\n * Cloud connector that starts a run (it writes these keys into the run's\n * trigger data) and everything that reads them: both workflow engines, the\n * canvas card and the public node registry. A handle id IS the trigger-data\n * key, so the two can never disagree.\n *\n * Structural vocabulary only: the keys and what each one carries. How the\n * connector decides which key a post fills is not part of the contract.\n */\n\n/** The message itself — the card's original output. */\nexport const TELEGRAM_ACCOUNT_TRIGGER_MESSAGE_HANDLE = \"out\"\n\n/**\n * Named outputs, in the order the card shows them. Exactly one of `videoLink`\n * and `postText` carries a value in a run that is about a shared post; both\n * are empty otherwise. Never undefined — an engine reading an empty one gets\n * \"\", never the message text in its place.\n */\nexport const TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS = [\n /** The post's link, when the post has a video to analyze. */\n \"videoLink\",\n /** The post's words, when it has no video: the message, the link's preview, or the forwarded post. */\n \"postText\",\n /** The link of the post this run is about, whatever its kind. */\n \"postLink\",\n] as const\n\nexport type TelegramAccountTriggerPostField = (typeof TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS)[number]\n\n/** Message facts carried alongside — read through trigger tokens and JSON-authored wires. */\nexport const TELEGRAM_ACCOUNT_TRIGGER_MESSAGE_FIELDS = [\n \"chatId\",\n \"chatType\",\n \"messageId\",\n \"senderId\",\n] as const\n\n/** Every handle the card renders, `out` first. */\nexport const TELEGRAM_ACCOUNT_TRIGGER_OUTPUT_HANDLES: readonly string[] = [\n TELEGRAM_ACCOUNT_TRIGGER_MESSAGE_HANDLE,\n ...TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS,\n]\n\nconst NAMED_HANDLES: ReadonlySet<string> = new Set([...TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS, ...TELEGRAM_ACCOUNT_TRIGGER_MESSAGE_FIELDS])\n\n/**\n * A handle naming one value of the run (a post field or a message fact) —\n * every handle but the message itself. A wire from one carries that value,\n * \"\" when the run has none, never the message in its place.\n */\nexport function isTelegramAccountTriggerNamedHandle(handle: unknown): handle is string {\n return typeof handle === \"string\" && NAMED_HANDLES.has(handle)\n}\n\n/**\n * What an account trigger listens to, and whether it listens: the settings\n * only its owner may set. One canonical string, so the editor that changed a\n * trigger and the server that arms it compare the same thing — the server\n * arms a trigger the owner's editor named only while the stored node still\n * says exactly what that editor set.\n *\n * It states what the trigger hears, not how the node spells it: in inbox mode\n * the owner's own messages are always heard, so `includeOutgoing` reads as on\n * there — a setting the panel does not show in that mode never decides a match.\n * The account id is the one exception: it is read exactly as written, because\n * the server never listens on one that is not written exactly (padded), and\n * the editor shows such an id as no account of the owner's.\n */\nexport function telegramAccountListeningSignature(data: unknown): string {\n const d = (data !== null && typeof data === \"object\" ? data : {}) as Record<string, unknown>\n const list = (value: unknown): string[] =>\n Array.isArray(value)\n ? [...new Set(value.filter((x): x is string => typeof x === \"string\").map((x) => x.trim()).filter((x) => x !== \"\"))].sort()\n : []\n return JSON.stringify({\n accountId: typeof d.accountId === \"string\" ? d.accountId : \"\",\n chatIds: list(d.chatIds),\n senderIds: list(d.senderIds),\n messageTypeFilters: list(d.messageTypeFilters),\n keywords: list(d.keywords),\n includeOutgoing: d.inboxMode === true || d.includeOutgoing === true,\n inboxMode: d.inboxMode === true,\n isActive: d.isActive === true,\n })\n}\n\nfunction stringField(value: unknown): string {\n if (typeof value === \"string\") return value.trim()\n if (typeof value === \"number\" && Number.isFinite(value)) return String(value)\n return \"\"\n}\n\n/**\n * The named outputs of one run, from its trigger data: every post field\n * present (possibly \"\"), each message field only when it has a value.\n */\nexport function telegramAccountTriggerOutputs(triggerData: Record<string, unknown> | null | undefined): Record<string, string> {\n const td = triggerData ?? {}\n const out: Record<string, string> = {}\n for (const key of TELEGRAM_ACCOUNT_TRIGGER_POST_FIELDS) out[key] = stringField(td[key])\n for (const key of TELEGRAM_ACCOUNT_TRIGGER_MESSAGE_FIELDS) {\n const value = stringField(td[key])\n if (value !== \"\") out[key] = value\n }\n return out\n}\n","/**\n * Telegram Reply (`telegram-account-send`) — who writes the message and\n * where it goes, as node data spells it. Structural vocabulary only: every\n * destination is the run's OWNER — the chat of the post they shared, their\n * Saved Messages, or their private chat with their own bot. How the Cloud\n * connector sends is not part of the contract.\n */\n\nexport const TELEGRAM_ACCOUNT_SEND_NODE_TYPE = \"telegram-account-send\"\n\n/** `account`: the owner's connected account writes. `bot`: the owner's own bot writes to them privately. */\nexport const TELEGRAM_SEND_AS = [\"account\", \"bot\"] as const\nexport type TelegramSendAs = (typeof TELEGRAM_SEND_AS)[number]\n\n/**\n * Where an account-written message goes. `reply`: under the post that started\n * the run, in its chat (a run started by the Telegram Account Trigger only).\n * `saved`: the owner's Saved Messages. A bot always writes to the owner's\n * private chat with it, so it has no destination to choose.\n */\nexport const TELEGRAM_SEND_DESTINATIONS = [\"reply\", \"saved\"] as const\nexport type TelegramSendDestination = (typeof TELEGRAM_SEND_DESTINATIONS)[number]\n\n/** The node's `sendAs`, as every reader reads it: anything else is the account. */\nexport function telegramSendAsOf(value: unknown): TelegramSendAs {\n return value === \"bot\" ? \"bot\" : \"account\"\n}\n\n/** The node's `destination`, as every reader reads it: anything else is a reply. */\nexport function telegramSendDestinationOf(value: unknown): TelegramSendDestination {\n return value === \"saved\" ? \"saved\" : \"reply\"\n}\n","export const SCRAPER_ACTOR_IDS = [\n \"content-crawler\",\n \"google-search\",\n \"instagram\",\n \"tiktok\",\n \"rss\",\n] as const\n\nexport type ScraperActorId = (typeof SCRAPER_ACTOR_IDS)[number]\n\nexport const SCRAPER_ACTOR_LABELS: Record<ScraperActorId, string> = {\n \"content-crawler\": \"Website Content (Markdown)\",\n \"google-search\": \"Google Search\",\n \"instagram\": \"Instagram\",\n \"tiktok\": \"TikTok\",\n \"rss\": \"RSS Feed\",\n}\n\n/** Credit costs per composite SKU — must stay in sync with STATIC_CREDIT_COSTS in backend.\n *\n * \"Must stay in sync\" was doing no work: these were left at the pre-2026-07-30\n * credit base while the backend moved, so every SKU here read a tenth of the\n * real price. Values below are copied from `model_pricing`, which is what the\n * user is actually charged. */\nexport const SCRAPER_CREDIT_COSTS: Record<string, number> = {\n \"web-scrape\": 20,\n \"web-scrape:google-search\": 30,\n \"web-scrape:content-crawler\": 10,\n \"web-scrape:content-crawler:site\": 50,\n \"web-scrape:instagram\": 10,\n \"web-scrape:tiktok\": 10,\n \"web-scrape:rss\": 10,\n}\n\nexport function isScraperActor(value: unknown): value is ScraperActorId {\n return typeof value === \"string\" && (SCRAPER_ACTOR_IDS as readonly string[]).includes(value)\n}\n\nexport interface ScraperCreditInput {\n actor: ScraperActorId\n mode?: \"page\" | \"site\"\n}\n\nexport function buildScraperCreditId(input: ScraperCreditInput): string {\n if (input.actor === \"content-crawler\") {\n const mode = input.mode ?? \"page\"\n return mode === \"site\" ? \"web-scrape:content-crawler:site\" : \"web-scrape:content-crawler\"\n }\n return `web-scrape:${input.actor}`\n}\n\n/**\n * Resolve the credit identifier from an unvalidated request body.\n * Falls back to a fixed default SKU (google-search) on missing/invalid actor\n * so misrouted requests reserve a known mid-tier price, not the max-cost tier.\n */\nexport function resolveScraperCreditId(body: unknown): string {\n const raw = body as { actor?: unknown; mode?: unknown } | undefined\n if (!raw || !isScraperActor(raw.actor)) return \"web-scrape:google-search\"\n const mode = raw.mode === \"site\" ? \"site\" : \"page\"\n return buildScraperCreditId({ actor: raw.actor, mode })\n}\n","/**\n * Meta Ads scraper node — shared vocabulary + credit identifiers.\n *\n * The node pulls PUBLIC ads (Facebook + Instagram placements) out of Meta's\n * Ad Library, either by keyword search or by Facebook Page URL, and emits a\n * JSON array of normalized ads. Everything the backend guard/reservation, the\n * frontend credit badge and the docs formula must agree on lives here so the\n * three cannot drift apart.\n *\n * The editor has a third, node-only mode — \"advertiser\": pick advertisers by\n * name (a page lookup) and run as their Page urls. The wire contract stays\n * search / pages; `metaAdsScrapeWireSources` is the ONE mapping both engines\n * call, and `metaAdsScrapeSources` the ONE source count every quote reads.\n *\n * Pricing shape: 1 credit per REQUESTED ad, rounded UP to a fixed tier. The\n * requested total is `count × sources` (search = 1 source; pages = one per\n * URL). The route's Zod bounds `count ≤ 100` and `sources ≤ 5`, so the total\n * can never land outside the tier set — an identifier missing from\n * `model_pricing` is a 503 `price_not_configured`, never a silent fallback.\n */\nimport { LLM_FEATURE_DEFAULTS, getLlmTier } from \"./llm-models.js\"\n\nexport const META_ADS_SCRAPE_NODE_TYPE = \"meta-ads-scrape\" as const\n\n/** The WIRE modes — what `POST /v1/meta-ads-scrape` accepts. */\nexport const META_ADS_SCRAPE_MODES = [\"search\", \"pages\"] as const\nexport type MetaAdsScrapeMode = (typeof META_ADS_SCRAPE_MODES)[number]\n\n/** The NODE modes — the wire modes plus the editor-only advertiser picker (runs as pages). */\nexport const META_ADS_NODE_MODES = [...META_ADS_SCRAPE_MODES, \"advertiser\"] as const\nexport type MetaAdsNodeMode = (typeof META_ADS_NODE_MODES)[number]\n\n/** Coerce stored node data to a node mode; anything unknown is the default keyword search. */\nexport function metaAdsNodeMode(value: unknown): MetaAdsNodeMode {\n return typeof value === \"string\" && (META_ADS_NODE_MODES as readonly string[]).includes(value) ? (value as MetaAdsNodeMode) : \"search\"\n}\n\n/** An advertiser the user picked by name — stored on the node, run as its Page url. */\nexport interface MetaAdsAdvertiser {\n readonly pageId: string\n readonly name: string\n /** The Facebook Page url. The actor resolves it to the Ad Library advertiser itself — the Page id and the advertiser id are NOT the same number. */\n readonly url: string\n readonly imageUrl?: string\n readonly verified?: boolean\n}\n\n/** How many matches an advertiser lookup returns — more than the pick cap, so a same-name brand can be told apart by its badge / avatar. */\nexport const META_ADS_ADVERTISER_MAX_RESULTS = 8\nconst META_ADS_URL_MAX_LENGTH = 2048\n\nfunction httpUrlOnHost(value: unknown, host: RegExp): value is string {\n if (typeof value !== \"string\" || value.length > META_ADS_URL_MAX_LENGTH) return false\n try {\n const url = new URL(value)\n return (url.protocol === \"https:\" || url.protocol === \"http:\") && host.test(url.hostname)\n } catch {\n return false\n }\n}\n\n/** http(s) url on facebook.com (any subdomain) — the ONE predicate for a Page address, on the route's Zod and on stored picks alike. */\nexport function isFacebookPageUrl(value: unknown): value is string {\n return httpUrlOnHost(value, /(^|\\.)facebook\\.com$/i)\n}\n\n/** A Page avatar lives on Meta's CDN; anything else is not stored (it would be fetched by every viewer's browser and our image proxy). */\nexport function isMetaCdnImageUrl(value: unknown): value is string {\n return httpUrlOnHost(value, /(^|\\.)(fbcdn\\.net|facebook\\.com)$/i)\n}\n\n/** Stored / relayed advertisers, sanitized: a page id, a name, a facebook.com url, a Meta-CDN avatar; deduped by page id; at most `limit` (the pick cap by default). */\nexport function metaAdsAdvertisersFrom(raw: unknown, limit: number = META_ADS_SCRAPE_MAX_SOURCES): MetaAdsAdvertiser[] {\n if (!Array.isArray(raw) || limit < 1) return []\n const seen = new Set<string>()\n const out: MetaAdsAdvertiser[] = []\n for (const item of raw) {\n if (!item || typeof item !== \"object\") continue\n const r = item as Record<string, unknown>\n const pageId =\n typeof r.pageId === \"string\" ? r.pageId.trim() : typeof r.pageId === \"number\" && Number.isFinite(r.pageId) ? String(r.pageId) : \"\"\n const name = typeof r.name === \"string\" ? r.name.trim().slice(0, 120) : \"\"\n if (!pageId || !name || !isFacebookPageUrl(r.url) || seen.has(pageId)) continue\n seen.add(pageId)\n out.push({\n pageId,\n name,\n url: r.url,\n ...(isMetaCdnImageUrl(r.imageUrl) ? { imageUrl: r.imageUrl } : {}),\n ...(r.verified === true ? { verified: true } : {}),\n })\n if (out.length >= limit) break\n }\n return out\n}\n\nexport const META_ADS_SCRAPE_PERIODS = [\"24h\", \"7d\", \"30d\", \"all\"] as const\nexport type MetaAdsScrapePeriod = (typeof META_ADS_SCRAPE_PERIODS)[number]\n\nexport const META_ADS_SCRAPE_STATUSES = [\"active\", \"inactive\", \"all\"] as const\nexport type MetaAdsScrapeStatus = (typeof META_ADS_SCRAPE_STATUSES)[number]\n\n/** Meta's `publisher_platform` vocabulary — the values an ad's `platforms` carries and the filter the node accepts. */\nexport const META_ADS_PLATFORMS = [\"FACEBOOK\", \"INSTAGRAM\", \"AUDIENCE_NETWORK\", \"MESSENGER\", \"WHATSAPP\", \"THREADS\"] as const\nexport type MetaAdsPlatform = (typeof META_ADS_PLATFORMS)[number]\n\nexport function isMetaAdsPlatform(value: unknown): value is MetaAdsPlatform {\n return typeof value === \"string\" && (META_ADS_PLATFORMS as readonly string[]).includes(value)\n}\n\n/**\n * Creative format, classified from the creative's measured pixels — the\n * user's \"phone vs web\" question. `vertical` = Stories / Reels / mobile feed\n * (9:16, 4:5), `square` = 1:1 (±5 %), `horizontal` = feed / web / banners\n * (16:9, 1.91:1). One classifier for the route (node setting), the Results\n * chips and the card, so they can never disagree.\n */\nexport const META_ADS_FORMATS = [\"vertical\", \"square\", \"horizontal\"] as const\nexport type MetaAdsFormat = (typeof META_ADS_FORMATS)[number]\nexport type MetaAdsCreativeFormat = MetaAdsFormat | \"unknown\"\n\nexport function isMetaAdsFormat(value: unknown): value is MetaAdsFormat {\n return typeof value === \"string\" && (META_ADS_FORMATS as readonly string[]).includes(value)\n}\n\n/** The featured ad index, clamped so a rerun that returned fewer ads never indexes past the end. */\nexport function clampMetaAdsFeaturedIndex(stored: unknown, count: number): number {\n if (count <= 0) return 0\n const n = typeof stored === \"number\" && Number.isFinite(stored) ? Math.trunc(stored) : 0\n return Math.min(Math.max(n, 0), count - 1)\n}\n\nexport interface FeaturedMetaAdOutputs {\n readonly text?: string\n readonly imageUrl?: string\n readonly videoUrl?: string\n}\n\nfunction urlStrings(value: unknown): string[] {\n return Array.isArray(value) ? value.filter((v): v is string => typeof v === \"string\" && v.trim().length > 0) : []\n}\n\n/**\n * What the node's typed `text` / `image` / `video` handles carry: the\n * FEATURED ad's copy (headline + body), first image (else the video poster)\n * and first video. ONE derivation for the route's output_data, the backend\n * saved-output hydration and the editor's extractNodeOutput, so a thumb pick\n * re-hydrates the handles identically everywhere.\n */\nexport function featuredMetaAdOutputs(json: unknown, featuredIndex: unknown): FeaturedMetaAdOutputs {\n if (!Array.isArray(json) || json.length === 0) return {}\n const ad = json[clampMetaAdsFeaturedIndex(featuredIndex, json.length)]\n if (!ad || typeof ad !== \"object\") return {}\n const a = ad as Record<string, unknown>\n const title = typeof a.title === \"string\" ? a.title.trim() : \"\"\n const body = typeof a.text === \"string\" ? a.text.trim() : \"\"\n const text = [title, body].filter((s) => s.length > 0).join(\"\\n\\n\")\n const imageUrl = urlStrings(a.images)[0] ?? urlStrings(a.videoPreviews)[0]\n const videoUrl = urlStrings(a.videos)[0]\n return {\n ...(text ? { text } : {}),\n ...(imageUrl ? { imageUrl } : {}),\n ...(videoUrl ? { videoUrl } : {}),\n }\n}\n\nexport function classifyCreativeFormat(width: unknown, height: unknown): MetaAdsCreativeFormat {\n if (typeof width !== \"number\" || typeof height !== \"number\" || !Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {\n return \"unknown\"\n }\n const ratio = width / height\n if (ratio < 0.95) return \"vertical\"\n if (ratio <= 1.05) return \"square\"\n return \"horizontal\"\n}\n\n/** Presets the config panel offers; the route accepts any integer 1..MAX_COUNT. */\nexport const META_ADS_SCRAPE_COUNT_OPTIONS = [10, 20, 50, 100] as const\nexport const META_ADS_SCRAPE_DEFAULT_COUNT = 20\nexport const META_ADS_SCRAPE_MAX_COUNT = 100\nexport const META_ADS_SCRAPE_MAX_SOURCES = 5\n/** Meta caps Ad Library search terms at 100 characters. */\nexport const META_ADS_SCRAPE_MAX_QUERY_LENGTH = 100\nexport const META_ADS_SCRAPE_DEFAULT_COUNTRY = \"ALL\"\n\n/** Requested-total buckets. Sorted ascending; the last one is `MAX_COUNT × MAX_SOURCES`. */\nexport const META_ADS_SCRAPE_TIERS = [10, 20, 50, 100, 200, 500] as const\nexport type MetaAdsScrapeTier = (typeof META_ADS_SCRAPE_TIERS)[number]\n\n/**\n * Optional per-ad AI analysis — the \"expert competitor ad analyst\" pass.\n * Priced per REQUESTED ad like the scrape, by the analysing model's tier,\n * and folded into the SAME tiered identifier so every quote (guard,\n * reservation, card badge, run total, backend estimator) stays one SKU:\n *\n * meta-ads-scrape:<tier> tier\n * meta-ads-scrape:<tier>:analysis tier × (1 + 3) standard models\n * meta-ads-scrape:<tier>:analysis:economy tier × (1 + 1)\n * meta-ads-scrape:<tier>:analysis:premium tier × (1 + 4)\n *\n * The per-ad SKUs (`meta-ads-analysis[:economy|:premium]`) price the\n * SETTLEMENT: a run commits tier + per-ad × ads actually analysed and\n * refunds the rest (an ad the model failed on, or one the deadline skipped).\n */\nexport const META_ADS_ANALYSIS_TIERS = [\"economy\", \"standard\", \"premium\"] as const\nexport type MetaAdsAnalysisTier = (typeof META_ADS_ANALYSIS_TIERS)[number]\nexport const META_ADS_ANALYSIS_CREDITS_PER_AD: Record<MetaAdsAnalysisTier, number> = { economy: 1, standard: 3, premium: 4 }\nexport const META_ADS_ANALYSIS_CREDIT_ID = \"meta-ads-analysis\" as const\n/** The user's optional analyst focus, appended to the fixed prompt. */\nexport const META_ADS_ANALYSIS_FOCUS_MAX = 500\n\n/** The per-ad settlement SKU for a tier (the bare id is the standard tier). */\nexport function metaAdsAnalysisCreditId(tier: MetaAdsAnalysisTier): string {\n return tier === \"standard\" ? META_ADS_ANALYSIS_CREDIT_ID : `${META_ADS_ANALYSIS_CREDIT_ID}:${tier}`\n}\n\n/** The analysing model's tier; an absent model is the feature default. */\nexport function metaAdsAnalysisTier(modelId?: unknown): MetaAdsAnalysisTier {\n const id = typeof modelId === \"string\" && modelId ? modelId : LLM_FEATURE_DEFAULTS[\"meta-ads-analysis\"]\n return getLlmTier(id)\n}\n\n/** What one analysed ad carries (`ad.analysis`); fixed fields + string lists only — never a map (Gemini via KIE drops map fields). */\nexport interface AdCreativeAnalysis {\n readonly assetType: \"static\" | \"motion\" | \"carousel\" | \"unknown\"\n readonly format: string\n readonly visualHooks: readonly string[]\n readonly audiences: readonly string[]\n readonly graphicIdentity: string\n readonly copywritingHooks: readonly string[]\n readonly usps: readonly string[]\n readonly cta: string\n readonly summary: string\n}\n\nconst strList = (v: unknown): string[] => (Array.isArray(v) ? v.filter((s): s is string => typeof s === \"string\" && s.trim().length > 0) : [])\nconst str = (v: unknown): string => (typeof v === \"string\" ? v : \"\")\n\n/** Read a stored analysis back defensively (a node's saved JSON is untrusted shape); null when there is none. */\nexport function adCreativeAnalysisFrom(raw: unknown): AdCreativeAnalysis | null {\n if (!raw || typeof raw !== \"object\") return null\n const r = raw as Record<string, unknown>\n if (typeof r.summary !== \"string\" || !r.summary.trim()) return null\n const assetType = r.assetType === \"static\" || r.assetType === \"motion\" || r.assetType === \"carousel\" ? r.assetType : \"unknown\"\n return {\n assetType,\n format: str(r.format),\n visualHooks: strList(r.visualHooks),\n audiences: strList(r.audiences),\n graphicIdentity: str(r.graphicIdentity),\n copywritingHooks: strList(r.copywritingHooks),\n usps: strList(r.usps),\n cta: str(r.cta),\n summary: r.summary,\n }\n}\n\n/** The `:analysis[:tier]` suffix on a scrape SKU for an analysis tier. */\nfunction analysisSuffix(tier: MetaAdsAnalysisTier): string {\n return tier === \"standard\" ? \":analysis\" : `:analysis:${tier}`\n}\n\nfunction buildMetaAdsCreditCostTable(): Record<string, number> {\n const table: Record<string, number> = { [META_ADS_SCRAPE_NODE_TYPE]: 20 }\n for (const tier of META_ADS_ANALYSIS_TIERS) table[metaAdsAnalysisCreditId(tier)] = META_ADS_ANALYSIS_CREDITS_PER_AD[tier]\n // Key by the TIER value directly (not via a count that clamps at MAX_COUNT):\n // the 200 / 500 tiers are reachable through sources > 1, so their analysis\n // rows must exist and be tier-based, not count-based.\n for (const t of META_ADS_SCRAPE_TIERS) {\n table[`${META_ADS_SCRAPE_NODE_TYPE}:${t}`] = t\n for (const tier of META_ADS_ANALYSIS_TIERS) {\n table[`${META_ADS_SCRAPE_NODE_TYPE}:${t}${analysisSuffix(tier)}`] = t * (1 + META_ADS_ANALYSIS_CREDITS_PER_AD[tier])\n }\n }\n return table\n}\n\n/**\n * Credit cost per SKU — mirror of the backend `STATIC_CREDIT_COSTS` rows and\n * migrations 428 / 429, for the frontend badge / estimator. 1 credit per\n * requested ad at every tier, plus the analysis multiples above; the bare\n * identifier is the pre-Zod fallback (mid tier, never the max).\n */\nexport const META_ADS_SCRAPE_CREDIT_COSTS: Record<string, number> = buildMetaAdsCreditCostTable()\n\nexport const META_ADS_SCRAPE_FALLBACK_CREDIT_ID = \"meta-ads-scrape:20\"\n\n/**\n * Page urls are typed one per line in the config panel (a FieldMapping\n * injects the same text); the route wants an array. Tolerates commas and\n * whitespace as separators (a url never contains either) and an array that\n * already went through this once.\n */\nexport function splitMetaAdsPageUrls(value: unknown): string[] {\n if (Array.isArray(value)) {\n return value.filter((v): v is string => typeof v === \"string\").map((v) => v.trim()).filter((v) => v.length > 0)\n }\n if (typeof value !== \"string\") return []\n return value.split(/[\\n,\\s]+/).map((v) => v.trim()).filter((v) => v.length > 0)\n}\n\nexport function isMetaAdsScrapeMode(value: unknown): value is MetaAdsScrapeMode {\n return typeof value === \"string\" && (META_ADS_SCRAPE_MODES as readonly string[]).includes(value)\n}\n\n/**\n * Advertiser NAMES to resolve at run time (advertiser mode driven by the `in`\n * input) — one per line or comma-separated. Unlike page urls, a name contains\n * spaces, so this never splits on whitespace. Trimmed, de-duped, each 2..100\n * chars, capped at `MAX_SOURCES`.\n */\nexport function splitMetaAdsAdvertiserNames(value: unknown): string[] {\n const raw = Array.isArray(value)\n ? value.filter((v): v is string => typeof v === \"string\")\n : typeof value === \"string\"\n ? value.split(/[\\n,]+/)\n : []\n const seen = new Set<string>()\n const out: string[] = []\n for (const item of raw) {\n const name = item.trim()\n if (name.length < 2 || name.length > META_ADS_SCRAPE_MAX_QUERY_LENGTH) continue\n const key = name.toLowerCase()\n if (seen.has(key)) continue\n seen.add(key)\n out.push(name)\n if (out.length >= META_ADS_SCRAPE_MAX_SOURCES) break\n }\n return out\n}\n\n/** The node-data fields that decide what a run scrapes (and therefore what it costs). Index-signature so any node-data bag is accepted as-is. */\nexport interface MetaAdsNodeSourceFields {\n readonly [key: string]: unknown\n readonly mode?: unknown\n readonly query?: unknown\n readonly pageUrls?: unknown\n readonly advertisers?: unknown\n}\n\n/**\n * How many sources a run bills — the number the card badge, the run total,\n * the pre-run estimator and the backend quote must all read, so an advertiser\n * pick can never be quoted as one source while the server reserves five. An\n * empty page list / no picks counts as one (the run then fails validation\n * before anything is reserved).\n */\nexport function metaAdsScrapeSources(data: MetaAdsNodeSourceFields): number {\n switch (metaAdsNodeMode(data.mode)) {\n case \"pages\":\n return Math.max(1, Math.min(splitMetaAdsPageUrls(data.pageUrls).length, META_ADS_SCRAPE_MAX_SOURCES))\n case \"advertiser\":\n return Math.max(1, metaAdsAdvertisersFrom(data.advertisers).length)\n default:\n return 1\n }\n}\n\nexport type MetaAdsWireSources =\n | { readonly mode: \"search\"; readonly query: string | undefined }\n | { readonly mode: \"pages\"; readonly pageUrls: string[]; readonly advertiserNames?: string[] }\n\n/**\n * The wire half of a request from node data — ONE mapping for the editor's\n * executor and the orchestrator's payload builder. The keyword / page list\n * falls back to the upstream text so a Prompt or List node can drive the\n * scrape; advertiser picks are explicit (no upstream fallback) and run as\n * their Page urls, which is why the route never sees \"advertiser\".\n */\nexport function metaAdsScrapeWireSources(data: MetaAdsNodeSourceFields, upstream?: unknown): MetaAdsWireSources {\n const upstreamText = typeof upstream === \"string\" ? upstream : undefined\n switch (metaAdsNodeMode(data.mode)) {\n case \"pages\": {\n const own = splitMetaAdsPageUrls(data.pageUrls)\n return { mode: \"pages\", pageUrls: own.length > 0 ? own : splitMetaAdsPageUrls(upstreamText) }\n }\n case \"advertiser\": {\n // Explicit picks run as their Page urls. With no picks but upstream\n // text, the `in` value is advertiser NAME(s) to resolve at run time\n // (the route looks each up and picks the verified/first Page).\n const picks = metaAdsAdvertisersFrom(data.advertisers)\n if (picks.length > 0) return { mode: \"pages\", pageUrls: picks.map((a) => a.url) }\n const names = splitMetaAdsAdvertiserNames(upstreamText)\n return { mode: \"pages\", pageUrls: [], advertiserNames: names }\n }\n default: {\n const own = typeof data.query === \"string\" ? data.query : \"\"\n return { mode: \"search\", query: own || upstreamText }\n }\n }\n}\n\nexport function isMetaAdsScrapeCount(value: unknown): value is number {\n return typeof value === \"number\" && Number.isInteger(value) && value >= 1 && value <= META_ADS_SCRAPE_MAX_COUNT\n}\n\n/** Smallest tier that fits the requested total; clamps to the top tier. */\nexport function metaAdsScrapeTier(requestedTotal: number): MetaAdsScrapeTier {\n for (const tier of META_ADS_SCRAPE_TIERS) {\n if (requestedTotal <= tier) return tier\n }\n return META_ADS_SCRAPE_TIERS[META_ADS_SCRAPE_TIERS.length - 1]\n}\n\nexport interface MetaAdsScrapeCreditInput {\n count: number\n /** Number of input URLs in pages mode; 1 for a keyword search. */\n sources: number\n /** The analysing model's tier when per-ad analysis is on; absent / null = scrape only. */\n analysis?: MetaAdsAnalysisTier | null\n}\n\nexport function buildMetaAdsScrapeCreditId(input: MetaAdsScrapeCreditInput): string {\n const sources = Math.min(Math.max(Math.trunc(input.sources) || 1, 1), META_ADS_SCRAPE_MAX_SOURCES)\n const count = Math.min(Math.max(Math.trunc(input.count) || 1, 1), META_ADS_SCRAPE_MAX_COUNT)\n const base = `${META_ADS_SCRAPE_NODE_TYPE}:${metaAdsScrapeTier(count * sources)}`\n return input.analysis ? `${base}${analysisSuffix(input.analysis)}` : base\n}\n\n/** The analysis tier a request / node asks for, or null when analysis is off. */\nexport function metaAdsAnalysisTierFrom(data: { readonly analyze?: unknown; readonly analysisModel?: unknown }): MetaAdsAnalysisTier | null {\n return data.analyze === true ? metaAdsAnalysisTier(data.analysisModel) : null\n}\n\n/**\n * Resolve the credit identifier from an UNVALIDATED request body (the\n * creditGuard preHandler runs before Zod). It must land on the SAME tier the\n * post-Zod reservation computes, so an OMITTED count is the route's default\n * (Zod fills it in the same way); only a present-but-invalid body reserves\n * the fixed mid tier, and the route then rejects it with a 400 and refunds.\n */\nexport function resolveMetaAdsScrapeCreditId(body: unknown): string {\n const raw = body as { mode?: unknown; count?: unknown; pageUrls?: unknown; advertiserNames?: unknown; analyze?: unknown; analysisModel?: unknown } | null | undefined\n if (!raw || typeof raw !== \"object\") return META_ADS_SCRAPE_FALLBACK_CREDIT_ID\n const count = raw.count === undefined ? META_ADS_SCRAPE_DEFAULT_COUNT : raw.count\n if (!isMetaAdsScrapeCount(count)) return META_ADS_SCRAPE_FALLBACK_CREDIT_ID\n // Pages mode bills per source: the page urls PLUS any advertiser names the\n // route will resolve to page urls at run time. Counting names may over-check\n // when one doesn't resolve — the safe direction (the reservation trues down).\n const sources = raw.mode === \"pages\"\n ? (Array.isArray(raw.pageUrls) ? raw.pageUrls.length : 0) + (Array.isArray(raw.advertiserNames) ? raw.advertiserNames.length : 0)\n : 1\n if (sources < 1 || sources > META_ADS_SCRAPE_MAX_SOURCES) return META_ADS_SCRAPE_FALLBACK_CREDIT_ID\n return buildMetaAdsScrapeCreditId({ count, sources, analysis: metaAdsAnalysisTierFrom(raw) })\n}\n\n/** The node-data fields a quote reads: what a run scrapes, how many, and whether it analyses. */\nexport interface MetaAdsNodeQuoteFields extends MetaAdsNodeSourceFields {\n readonly count?: unknown\n readonly analyze?: unknown\n readonly analysisModel?: unknown\n}\n\n/**\n * The ONE credit identifier for a node's current settings — the card badge,\n * the run total, the pre-run estimator and the backend quote all read this,\n * and it is the same builder the route's guard + reservation use on the wire\n * body, so no surface can quote a different SKU than the one reserved.\n */\nexport function metaAdsScrapeCreditIdFromNode(data: MetaAdsNodeQuoteFields): string {\n const count = typeof data.count === \"number\" ? data.count : META_ADS_SCRAPE_DEFAULT_COUNT\n return buildMetaAdsScrapeCreditId({ count, sources: metaAdsScrapeSources(data), analysis: metaAdsAnalysisTierFrom(data) })\n}\n","/**\n * Instagram scraper node — shared vocabulary + credit identifiers.\n *\n * Pulls PUBLIC Instagram posts (feed images, carousels, reels) by profile, by\n * hashtag or by post link and emits a normalized JSON array. Same shape of contract as the\n * Meta Ads node: everything the backend guard/reservation, the frontend credit\n * badge and the docs formula must agree on lives here.\n *\n * Pricing: 1 credit per REQUESTED post, rounded UP to a fixed tier of\n * `count × sources` (a profile / hashtag / post link is one source, up to 5;\n * a post link is always ONE post — see `instagramRequestedCount`). Optional\n * per-post AI analysis folds into the same identifier, priced by the model's\n * tier — reusing the Meta analysis per-item values so the two nodes stay in\n * lockstep.\n */\nimport {\n META_ADS_ANALYSIS_CREDITS_PER_AD,\n META_ADS_ANALYSIS_TIERS,\n metaAdsAnalysisTier,\n type MetaAdsAnalysisTier,\n} from \"./meta-ads-scrape.js\"\nimport { classifyCreativeFormat, type MetaAdsFormat } from \"./meta-ads-scrape.js\"\n\nexport const INSTAGRAM_SCRAPE_NODE_TYPE = \"instagram-scrape\" as const\n\n/**\n * `profile` = recent posts of an account, `hashtag` = recent posts under a tag,\n * `post` = exactly the posts whose links are given (one post per link — the\n * \"remake this post\" entry point, where a full run must land on THAT post).\n */\nexport const INSTAGRAM_SCRAPE_MODES = [\"profile\", \"hashtag\", \"post\"] as const\nexport type InstagramScrapeMode = (typeof INSTAGRAM_SCRAPE_MODES)[number]\n\nexport function isInstagramScrapeMode(value: unknown): value is InstagramScrapeMode {\n return typeof value === \"string\" && (INSTAGRAM_SCRAPE_MODES as readonly string[]).includes(value)\n}\nexport function instagramScrapeMode(value: unknown): InstagramScrapeMode {\n return isInstagramScrapeMode(value) ? value : \"profile\"\n}\n\n/** Same window vocabulary as Meta Ads; the Instagram actor honours it server-side (`onlyPostsNewerThan`). */\nexport const INSTAGRAM_SCRAPE_PERIODS = [\"24h\", \"7d\", \"30d\", \"all\"] as const\nexport type InstagramScrapePeriod = (typeof INSTAGRAM_SCRAPE_PERIODS)[number]\n\nexport const INSTAGRAM_SCRAPE_DEFAULT_COUNT = 20\nexport const INSTAGRAM_SCRAPE_MAX_COUNT = 100\nexport const INSTAGRAM_SCRAPE_MAX_SOURCES = 5\n/** Instagram usernames / hashtags are short; cap a single target well under a URL. */\nexport const INSTAGRAM_SCRAPE_MAX_TARGET_LENGTH = 200\n\n/** Requested-total buckets — identical shape to Meta (the pricing model is the same). */\nexport const INSTAGRAM_SCRAPE_TIERS = [10, 20, 50, 100, 200, 500] as const\nexport type InstagramScrapeTier = (typeof INSTAGRAM_SCRAPE_TIERS)[number]\n\nexport function instagramScrapeTier(requestedTotal: number): InstagramScrapeTier {\n for (const tier of INSTAGRAM_SCRAPE_TIERS) if (requestedTotal <= tier) return tier\n return INSTAGRAM_SCRAPE_TIERS[INSTAGRAM_SCRAPE_TIERS.length - 1]\n}\n\n/** The analysis tier a request / node asks for, or null when analysis is off. */\nexport function instagramAnalysisTierFrom(data: { readonly analyze?: unknown; readonly analysisModel?: unknown }): MetaAdsAnalysisTier | null {\n return data.analyze === true ? metaAdsAnalysisTier(data.analysisModel) : null\n}\n\nfunction analysisSuffix(tier: MetaAdsAnalysisTier): string {\n return tier === \"standard\" ? \":analysis\" : `:analysis:${tier}`\n}\n\n/** Per-post settlement SKU for a tier (the bare id is the standard tier). */\nexport const INSTAGRAM_ANALYSIS_CREDIT_ID = \"instagram-analysis\" as const\nexport function instagramAnalysisCreditId(tier: MetaAdsAnalysisTier): string {\n return tier === \"standard\" ? INSTAGRAM_ANALYSIS_CREDIT_ID : `${INSTAGRAM_ANALYSIS_CREDIT_ID}:${tier}`\n}\n\nexport interface InstagramScrapeCreditInput {\n count: number\n sources: number\n analysis?: MetaAdsAnalysisTier | null\n}\n\nexport function buildInstagramScrapeCreditId(input: InstagramScrapeCreditInput): string {\n const sources = Math.min(Math.max(Math.trunc(input.sources) || 1, 1), INSTAGRAM_SCRAPE_MAX_SOURCES)\n const count = Math.min(Math.max(Math.trunc(input.count) || 1, 1), INSTAGRAM_SCRAPE_MAX_COUNT)\n const base = `${INSTAGRAM_SCRAPE_NODE_TYPE}:${instagramScrapeTier(count * sources)}`\n return input.analysis ? `${base}${analysisSuffix(input.analysis)}` : base\n}\n\n/**\n * Cost per SKU — mirror of the backend `STATIC_CREDIT_COSTS` rows / migration,\n * for the frontend badge / estimator. 1 credit per requested post at every\n * tier, plus the analysis multiples.\n */\nexport const INSTAGRAM_SCRAPE_CREDIT_COSTS: Record<string, number> = (() => {\n const table: Record<string, number> = { [INSTAGRAM_SCRAPE_NODE_TYPE]: 20 }\n for (const tier of META_ADS_ANALYSIS_TIERS) table[instagramAnalysisCreditId(tier)] = META_ADS_ANALYSIS_CREDITS_PER_AD[tier]\n for (const t of INSTAGRAM_SCRAPE_TIERS) {\n table[`${INSTAGRAM_SCRAPE_NODE_TYPE}:${t}`] = t\n for (const tier of META_ADS_ANALYSIS_TIERS) {\n table[`${INSTAGRAM_SCRAPE_NODE_TYPE}:${t}${analysisSuffix(tier)}`] = t * (1 + META_ADS_ANALYSIS_CREDITS_PER_AD[tier])\n }\n }\n return table\n})()\n\nexport const INSTAGRAM_SCRAPE_FALLBACK_CREDIT_ID = \"instagram-scrape:20\"\n\nexport function isInstagramScrapeCount(value: unknown): value is number {\n return typeof value === \"number\" && Number.isInteger(value) && value >= 1 && value <= INSTAGRAM_SCRAPE_MAX_COUNT\n}\n\n/**\n * A post link: instagram.com (any subdomain, an optional username segment\n * before the kind) or instagr.am, `/p/`, `/reel/`, `/reels/` or `/tv/`, with or\n * without scheme, query string or trailing slash. Group 1 = the kind, group 2 =\n * the shortcode. The shortcode is CASE-SENSITIVE — two codes that differ only\n * in case are two different posts — so the `i` flag only relaxes the host and\n * the kind; the captured code keeps its case.\n *\n * Instagram's own path words are never a username: `/share/p/<token>/` (the\n * token of a share redirect, not a shortcode), `/stories/…`, `/explore/…` and\n * the kinds themselves would otherwise turn into a wrong post that still bills.\n * `/reels/audio/<id>/` is an audio page, not a reel.\n */\nconst INSTAGRAM_POST_LINK_RE =\n /^(?:https?:\\/\\/)?(?:[a-z0-9-]+\\.)*(?:instagram\\.com|instagr\\.am)\\/(?:(?!(?:share|stories|explore|accounts|direct|p|reels?|tv)\\/)[A-Za-z0-9._]+\\/)?(p|reels?|tv)\\/(?!audio(?:[/?#]|$))([A-Za-z0-9_-]+)/i\n\nfunction parseInstagramPostLink(value: string): { readonly link: string; readonly shortcode: string } | null {\n const match = INSTAGRAM_POST_LINK_RE.exec(value.trim())\n if (!match) return null\n const kind = match[1].toLowerCase()\n const segment = kind === \"p\" ? \"p\" : kind === \"tv\" ? \"tv\" : \"reel\"\n return { link: `https://www.instagram.com/${segment}/${match[2]}/`, shortcode: match[2] }\n}\n\n/** The canonical link of the post a value points at, or null when it is not an Instagram post link. */\nexport function instagramPostLink(value: string): string | null {\n return parseInstagramPostLink(value)?.link ?? null\n}\n\n/**\n * Post links, canonicalised, deduped by shortcode (`/p/X` and `/reel/X` are\n * one post), capped at MAX_SOURCES. An item holding several links (an API\n * caller's array entry) is split like typed text.\n */\nfunction splitInstagramPostLinks(raw: readonly string[]): string[] {\n const seen = new Set<string>()\n const out: string[] = []\n for (const item of raw.flatMap((entry) => entry.split(/[\\s,]+/))) {\n const parsed = parseInstagramPostLink(item)\n if (!parsed || seen.has(parsed.shortcode)) continue\n seen.add(parsed.shortcode)\n out.push(parsed.link)\n if (out.length >= INSTAGRAM_SCRAPE_MAX_SOURCES) break\n }\n return out\n}\n\n/**\n * Targets are typed one per line; the route wants an array.\n *\n * - `profile` / `hashtag` (the default — the signature predates post mode):\n * a target can be a bare username / `#tag`, so split on lines / commas only\n * (never whitespace), strip a leading `@` or `#`, dedupe, cap at MAX_SOURCES.\n * - `post`: only Instagram post links count; each is canonicalised (see\n * `instagramPostLink`) and anything else is dropped, so the guard, the\n * reservation and the scrape all see the same set of posts.\n */\nexport function splitInstagramTargets(value: unknown, mode: InstagramScrapeMode = \"profile\"): string[] {\n const separator = mode === \"post\" ? /[\\s,]+/ : /[\\n,]+/\n const raw = Array.isArray(value)\n ? value.filter((v): v is string => typeof v === \"string\")\n : typeof value === \"string\"\n ? value.split(separator)\n : []\n if (mode === \"post\") return splitInstagramPostLinks(raw)\n const seen = new Set<string>()\n const out: string[] = []\n for (const item of raw) {\n const t = item.trim().replace(/^[@#]+/, \"\").trim()\n if (t.length < 1 || t.length > INSTAGRAM_SCRAPE_MAX_TARGET_LENGTH) continue\n const key = t.toLowerCase()\n if (seen.has(key)) continue\n seen.add(key)\n out.push(t)\n if (out.length >= INSTAGRAM_SCRAPE_MAX_SOURCES) break\n }\n return out\n}\n\n/** The featured post index, clamped. */\nexport function clampInstagramFeaturedIndex(stored: unknown, count: number): number {\n if (count <= 0) return 0\n const n = typeof stored === \"number\" && Number.isFinite(stored) ? Math.trunc(stored) : 0\n return Math.min(Math.max(n, 0), count - 1)\n}\n\nexport interface FeaturedInstagramOutputs {\n readonly text?: string\n readonly imageUrl?: string\n readonly videoUrl?: string\n}\n\nfunction urlStrings(value: unknown): string[] {\n return Array.isArray(value) ? value.filter((v): v is string => typeof v === \"string\" && v.trim().length > 0) : []\n}\n\n/** The featured post's caption (`text`), first image / cover (`image`), and first video (`video`). */\nexport function featuredInstagramOutputs(json: unknown, featuredIndex: unknown): FeaturedInstagramOutputs {\n if (!Array.isArray(json) || json.length === 0) return {}\n const post = json[clampInstagramFeaturedIndex(featuredIndex, json.length)]\n if (!post || typeof post !== \"object\") return {}\n const p = post as Record<string, unknown>\n const text = typeof p.caption === \"string\" ? p.caption.trim() : \"\"\n const imageUrl = urlStrings(p.images)[0] ?? urlStrings(p.videoPreviews)[0]\n const videoUrl = urlStrings(p.videos)[0]\n return {\n ...(text ? { text } : {}),\n ...(imageUrl ? { imageUrl } : {}),\n ...(videoUrl ? { videoUrl } : {}),\n }\n}\n\n/** The node-data fields a quote reads. */\nexport interface InstagramNodeQuoteFields {\n readonly [key: string]: unknown\n readonly mode?: unknown\n readonly targets?: unknown\n readonly count?: unknown\n readonly analyze?: unknown\n readonly analysisModel?: unknown\n}\n\n/**\n * Posts requested PER SOURCE: the `count` setting, except in post mode, where\n * every source is one link and so one post (the count setting does not apply).\n * Every price computation goes through this, so the guard, the reservation,\n * the settlement and the node's badge cannot disagree on a post-mode run.\n */\nexport function instagramRequestedCount(mode: InstagramScrapeMode, count: number): number {\n return mode === \"post\" ? 1 : count\n}\n\n/** Billable source count: number of targets (min 1). */\nexport function instagramScrapeSources(data: InstagramNodeQuoteFields): number {\n return Math.max(1, Math.min(splitInstagramTargets(data.targets, instagramScrapeMode(data.mode)).length, INSTAGRAM_SCRAPE_MAX_SOURCES))\n}\n\n/** The ONE credit identifier for a node's current settings. */\nexport function instagramScrapeCreditIdFromNode(data: InstagramNodeQuoteFields): string {\n const count = typeof data.count === \"number\" ? data.count : INSTAGRAM_SCRAPE_DEFAULT_COUNT\n return buildInstagramScrapeCreditId({\n count: instagramRequestedCount(instagramScrapeMode(data.mode), count),\n sources: instagramScrapeSources(data),\n analysis: instagramAnalysisTierFrom(data),\n })\n}\n\n/**\n * Resolve the credit identifier from an UNVALIDATED request body (the guard\n * runs before Zod). Lands on the SAME tier the reservation computes.\n */\nexport function resolveInstagramScrapeCreditId(body: unknown): string {\n const raw = body as { mode?: unknown; count?: unknown; targets?: unknown; analyze?: unknown; analysisModel?: unknown } | null | undefined\n if (!raw || typeof raw !== \"object\") return INSTAGRAM_SCRAPE_FALLBACK_CREDIT_ID\n const count = raw.count === undefined ? INSTAGRAM_SCRAPE_DEFAULT_COUNT : raw.count\n if (!isInstagramScrapeCount(count)) return INSTAGRAM_SCRAPE_FALLBACK_CREDIT_ID\n // Same mode resolution as the route's Zod default (absent → profile) and the\n // same splitter the handler uses for `sources` (dedupes, caps at MAX), so the\n // pre-Zod guard and the post-Zod reservation always land on the same tier —\n // a duplicate target bills once, not per copy.\n const mode = instagramScrapeMode(raw.mode)\n const sources = splitInstagramTargets(raw.targets, mode).length\n if (sources < 1) return INSTAGRAM_SCRAPE_FALLBACK_CREDIT_ID\n return buildInstagramScrapeCreditId({ count: instagramRequestedCount(mode, count), sources, analysis: instagramAnalysisTierFrom(raw) })\n}\n\n// Re-export the shared creative-format vocabulary so the node imports one place.\nexport { classifyCreativeFormat }\nexport type InstagramFormat = MetaAdsFormat\n","/**\n * Social Search node — shared vocabulary, the post shape, credit identifiers,\n * and the rule for which posts a run passes on.\n *\n * One node searches one platform (TikTok, Instagram, YouTube, X, Reddit,\n * LinkedIn, Meta's Ad Library) by keyword or by account and returns up to 60\n * posts in one shape. In the editor a person picks the posts to keep; a\n * workflow run without picks passes on the first few. Everything the route\n * reservation, the orchestrator, the editor, the SDK and the docs must agree\n * on lives here.\n *\n * Why public: `SocialPost` is the node's output and the SDK's return type,\n * and `SocialSearchParams` is the `/v1/social-search` request body. The search\n * itself runs in a private plugin (Cloud only).\n */\n\nexport const SOCIAL_SEARCH_NODE_TYPE = \"social-search\" as const\n\nexport const SOCIAL_PLATFORMS = [\"tiktok\", \"instagram\", \"youtube\", \"x\", \"reddit\", \"linkedin\", \"meta_ads\"] as const\nexport type SocialPlatform = (typeof SOCIAL_PLATFORMS)[number]\n\n/** `account` is a creator, a LinkedIn company page or person's profile, or\n * a Meta advertiser; `community` is a subreddit. */\nexport const SOCIAL_SEARCH_MODES = [\"keyword\", \"account\", \"community\"] as const\nexport type SocialSearchMode = (typeof SOCIAL_SEARCH_MODES)[number]\n\nexport const SOCIAL_SEARCH_PLATFORM_MODES: Readonly<Record<SocialPlatform, readonly SocialSearchMode[]>> = {\n tiktok: [\"keyword\", \"account\"],\n instagram: [\"keyword\", \"account\"],\n youtube: [\"keyword\", \"account\"],\n x: [\"keyword\", \"account\"],\n reddit: [\"keyword\", \"community\"],\n linkedin: [\"keyword\", \"account\"],\n meta_ads: [\"keyword\", \"account\"],\n}\n\nexport const SOCIAL_SEARCH_PERIODS = [\"day\", \"week\", \"month\", \"year\", \"all\"] as const\nexport type SocialSearchPeriod = (typeof SOCIAL_SEARCH_PERIODS)[number]\n\nexport const SOCIAL_SEARCH_SORTS = [\"relevance\", \"popular\", \"newest\"] as const\nexport type SocialSearchSort = (typeof SOCIAL_SEARCH_SORTS)[number]\n\n/** Results per search: one page of the platform per 20 posts. */\nexport const SOCIAL_SEARCH_COUNTS = [20, 40, 60] as const\nexport type SocialSearchCount = (typeof SOCIAL_SEARCH_COUNTS)[number]\n\n/**\n * The searches that can fetch more than one page. Every other one (an\n * account's latest posts on TikTok, Instagram, YouTube or LinkedIn, a YouTube\n * keyword search, a Reddit keyword search) returns one page however many\n * results are asked for, so it is capped at 20 — and billed for one page. The\n * plugin applies the same table to what it fetches and reserves.\n */\nexport const SOCIAL_SEARCH_PAGED_MODES: Readonly<Record<SocialPlatform, readonly SocialSearchMode[]>> = {\n tiktok: [\"keyword\"],\n instagram: [\"keyword\"],\n youtube: [],\n x: [\"keyword\", \"account\"],\n reddit: [\"community\"],\n linkedin: [\"keyword\"],\n meta_ads: [\"keyword\", \"account\"],\n}\n\n/** The most results this platform and mode can return in one search. */\nexport function socialSearchMaxCount(platform: SocialPlatform, mode: SocialSearchMode): SocialSearchCount {\n return SOCIAL_SEARCH_PAGED_MODES[platform].includes(mode) ? 60 : 20\n}\n\nexport const SOCIAL_SEARCH_VIDEO_KINDS = [\"all\", \"videos\", \"shorts\"] as const\nexport type SocialSearchVideoKind = (typeof SOCIAL_SEARCH_VIDEO_KINDS)[number]\n\n/** How many posts a run passes on when nobody picked: the first five. */\nexport const SOCIAL_SEARCH_DEFAULT_PICK_TOP = 5\nexport const SOCIAL_SEARCH_MAX_QUERY_LENGTH = 300\n\n// ── The post ───────────────────────────────────────────────────────────────\n\nexport interface SocialPostAuthor {\n readonly handle: string\n readonly name: string\n readonly avatarUrl?: string\n readonly followers?: number\n readonly verified?: boolean\n readonly url?: string\n}\n\n/** Absent means the platform did not report it, never zero. */\nexport interface SocialPostMetrics {\n readonly views?: number\n readonly likes?: number\n readonly comments?: number\n readonly shares?: number\n readonly saves?: number\n /** Reddit's vote score. */\n readonly score?: number\n}\n\nexport interface SocialPostMedia {\n readonly kind: \"video\" | \"image\" | \"text\"\n /** The platform's own still. Signed links expire within days. */\n readonly thumbnailUrl?: string\n /** A direct video file when the platform hands one out. Also short-lived. */\n readonly videoUrl?: string\n readonly durationSec?: number\n readonly aspect?: \"9:16\" | \"16:9\" | \"1:1\"\n}\n\nexport interface SocialPost {\n /** `<platform>:<the platform's own id>`, stable across searches. */\n readonly id: string\n readonly platform: SocialPlatform\n /** The post's page. */\n readonly url: string\n readonly title?: string\n readonly text: string\n readonly author: SocialPostAuthor\n /** Where it was posted: `r/<subreddit>`, a channel, a company page, an advertiser. */\n readonly container?: string\n /** ISO 8601, UTC. */\n readonly publishedAt?: string\n readonly metrics: SocialPostMetrics\n readonly media: SocialPostMedia\n readonly hashtags: readonly string[]\n /** Platform-specific facts: a TikTok `sound`, an ad's `active` / `endedAt` /\n * `variants` / `cta`, a Reddit `subreddit`, an X `reply` flag. */\n readonly extra: Readonly<Record<string, unknown>>\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\n/** Every field the card, the digest and the picker read, with its type. A\n * saved post that fails this is skipped, never rendered half-broken. */\nexport function isSocialPost(value: unknown): value is SocialPost {\n if (!isRecord(value)) return false\n return (\n typeof value.id === \"string\" &&\n typeof value.url === \"string\" &&\n typeof value.text === \"string\" &&\n typeof value.platform === \"string\" &&\n (SOCIAL_PLATFORMS as readonly string[]).includes(value.platform) &&\n isRecord(value.author) &&\n typeof value.author.handle === \"string\" &&\n typeof value.author.name === \"string\" &&\n isRecord(value.metrics) &&\n isRecord(value.media) &&\n Array.isArray(value.hashtags) &&\n isRecord(value.extra)\n )\n}\n\n/** The posts in an unknown value (a job's output, a node's saved data). */\nexport function socialPostsFrom(value: unknown): SocialPost[] {\n return Array.isArray(value) ? value.filter(isSocialPost) : []\n}\n\n// ── The request ────────────────────────────────────────────────────────────\n\n/** The body of `POST /v1/social-search` (and `nodes.run(\"social-search\", …)`).\n * A type alias, not an interface, so it is assignable to a plain record (the\n * SDK's generic `run` body). */\nexport type SocialSearchParams = {\n readonly platform: SocialPlatform\n /** Default `keyword`. */\n readonly mode?: SocialSearchMode\n /** A keyword, or an account: a handle, a profile link, a subreddit, a\n * LinkedIn company page or profile, a Meta advertiser's name or page id. */\n readonly query: string\n /** 20, 40 or 60 results. Default 20. */\n readonly count?: SocialSearchCount\n /** Default `month`. */\n readonly period?: SocialSearchPeriod\n /** Default `relevance` (the platform's own order). */\n readonly sort?: SocialSearchSort\n /** TikTok keyword search: a two-letter region. */\n readonly region?: string\n /** Meta ads: a two-letter country, or `ALL`. */\n readonly country?: string\n /** Meta ads: only ads that are running now. Default true. */\n readonly activeOnly?: boolean\n /** Reddit keyword search inside one subreddit. */\n readonly subreddit?: string\n /** YouTube: long videos, Shorts, or both. Default `all`. */\n readonly videoKind?: SocialSearchVideoKind\n}\n\nfunction oneOf<T extends string>(list: readonly T[], value: unknown, fallback: T): T {\n return typeof value === \"string\" && (list as readonly string[]).includes(value) ? (value as T) : fallback\n}\n\nexport function socialSearchPlatform(value: unknown): SocialPlatform {\n return oneOf(SOCIAL_PLATFORMS, value, \"tiktok\")\n}\n\n/** The mode, or the platform's first one when the stored mode does not apply\n * (a node switched from Reddit \"community\" to TikTok). */\nexport function socialSearchMode(platform: SocialPlatform, value: unknown): SocialSearchMode {\n const allowed = SOCIAL_SEARCH_PLATFORM_MODES[platform]\n return oneOf(allowed, value, allowed[0]!)\n}\n\nexport function socialSearchCount(value: unknown): SocialSearchCount {\n return value === 60 ? 60 : value === 40 ? 40 : 20\n}\n\nexport function socialSearchPages(count: SocialSearchCount): 1 | 2 | 3 {\n return count === 60 ? 3 : count === 40 ? 2 : 1\n}\n\nfunction cleanText(value: unknown, max: number): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim().slice(0, max) : undefined\n}\n\n/** The count a search really runs at: the asked count, capped for a search\n * that returns one page (`socialSearchMaxCount`). */\nexport function socialSearchEffectiveCount(platform: SocialPlatform, mode: SocialSearchMode, value: unknown): SocialSearchCount {\n const asked = socialSearchCount(value)\n const max = socialSearchMaxCount(platform, mode)\n return asked > max ? max : asked\n}\n\n/** A two-letter region (TikTok), upper-cased, or undefined. */\nexport function socialSearchRegion(value: unknown): string | undefined {\n const text = typeof value === \"string\" ? value.trim().toUpperCase() : \"\"\n return /^[A-Z]{2}$/.test(text) ? text : undefined\n}\n\n/** A two-letter country or ALL (Meta ads), upper-cased; anything else is ALL. */\nexport function socialSearchCountry(value: unknown): string {\n const text = typeof value === \"string\" ? value.trim().toUpperCase() : \"\"\n return /^([A-Z]{2}|ALL)$/.test(text) ? text : \"ALL\"\n}\n\n/**\n * The request a Social Search node sends — the ONE builder the editor's run\n * and the workflow orchestrator share. `query` is the wired text when there is\n * one (a Text node, a List item), else the node's own field.\n */\nexport function socialSearchRequestFromNode(\n data: Readonly<Record<string, unknown>>,\n wiredQuery?: string,\n): SocialSearchParams {\n const platform = socialSearchPlatform(data.platform)\n const mode = socialSearchMode(platform, data.mode)\n const query = cleanText(wiredQuery, SOCIAL_SEARCH_MAX_QUERY_LENGTH) ?? cleanText(data.query, SOCIAL_SEARCH_MAX_QUERY_LENGTH) ?? \"\"\n const region = socialSearchRegion(data.region)\n const country = socialSearchCountry(data.country)\n const subreddit = cleanText(data.subreddit, 100)\n return {\n platform,\n mode,\n query,\n count: socialSearchEffectiveCount(platform, mode, data.count),\n period: oneOf(SOCIAL_SEARCH_PERIODS, data.period, \"month\"),\n sort: oneOf(SOCIAL_SEARCH_SORTS, data.sort, \"relevance\"),\n ...(platform === \"tiktok\" && mode === \"keyword\" && region ? { region } : {}),\n ...(platform === \"meta_ads\" ? { country, activeOnly: data.activeOnly !== false } : {}),\n ...(platform === \"reddit\" && mode === \"keyword\" && subreddit ? { subreddit } : {}),\n ...(platform === \"youtube\" ? { videoKind: oneOf(SOCIAL_SEARCH_VIDEO_KINDS, data.videoKind, \"all\") } : {}),\n }\n}\n\n/**\n * The page link of a Social Search post, read from the node's `json` output\n * as a wire hands it on: one post (a wire in Each mode) or the list of posts\n * (any other wire: the first). Undefined when the output holds no post with\n * an http(s) link.\n */\nexport function socialSearchPostLink(output: string): string | undefined {\n let parsed: unknown\n try {\n parsed = JSON.parse(output)\n } catch {\n return undefined\n }\n const post = Array.isArray(parsed) ? parsed[0] : parsed\n const url = typeof post === \"object\" && post !== null ? (post as { url?: unknown }).url : undefined\n return httpLink(url)\n}\n\nfunction httpLink(value: unknown): string | undefined {\n const link = typeof value === \"string\" ? value.trim() : \"\"\n return /^https?:\\/\\/\\S+$/i.test(link) ? link : undefined\n}\n\n// ── A post's video, for Video Analysis ─────────────────────────────────────\n\n/**\n * A signed link counts as expired this long before its stated end, so it\n * still answers when the run reads it: the length check, then the download.\n */\nexport const SOCIAL_POST_VIDEO_LINK_MARGIN_MS = 60 * 60 * 1000\n\n/**\n * When a platform's signed media link stops working, in epoch milliseconds,\n * if the link says: `oe` (hex seconds: Instagram, Facebook and ad videos),\n * `x-expires` (TikTok), `Expires` (S3, CloudFront), `e` (LinkedIn). Undefined\n * for a link that names no end (an X video's link does not expire).\n */\nexport function signedLinkExpiresAt(link: string): number | undefined {\n let url: URL\n try {\n url = new URL(link)\n } catch {\n return undefined\n }\n const params = url.searchParams\n const oe = params.get(\"oe\")\n if (oe !== null && /^[0-9a-f]{6,10}$/i.test(oe)) return parseInt(oe, 16) * 1000\n const linkedin = /(^|\\.)licdn\\.com$/i.test(url.hostname)\n const seconds = params.get(\"x-expires\") ?? params.get(\"Expires\") ?? params.get(\"expires\") ?? (linkedin ? params.get(\"e\") : null)\n return seconds !== null && /^\\d{9,11}$/.test(seconds) ? Number(seconds) * 1000 : undefined\n}\n\n/**\n * A post's video link when it is a FILE the analysis can download whole; a\n * streaming playlist (an HLS `.m3u8`, which some LinkedIn videos are) is not\n * one, so the post is read by its page instead.\n */\nfunction videoFileLink(value: unknown): string | undefined {\n const link = httpLink(value)\n if (!link) return undefined\n try {\n return /\\.m3u8$/i.test(new URL(link).pathname) ? undefined : link\n } catch {\n return undefined\n }\n}\n\n/** What a Social Search post hands Video Analysis. */\nexport type SocialSearchPostVideo =\n /** The post's own video file, while the platform's signed link is valid. */\n | { readonly kind: \"file\"; readonly url: string }\n /** No file came with the post (TikTok, YouTube): its page, which the analysis fetches. */\n | { readonly kind: \"page\"; readonly url: string }\n /** The file's signed link has expired: the search has to run again. */\n | { readonly kind: \"expired\" }\n /** The post is an image or a text post: there is no video to analyze. */\n | { readonly kind: \"none\" }\n\n/**\n * The video Video Analysis reads from a Social Search node's `json` output,\n * as a wire hands it on: one post (a wire in Each mode) or the list (any\n * other wire: the first post). A post that came with its own video file is\n * analyzed from that file, so the platform's page is never read: Instagram's\n * page does not say how long the video is, and a video without a length\n * cannot be priced. A file whose signed link has expired is reported as such\n * rather than swapped for the page. Undefined when the output holds no post.\n * Both engines read it (input-resolver / node-input-resolver).\n */\nexport function socialSearchPostVideo(output: string, now: number = Date.now()): SocialSearchPostVideo | undefined {\n let parsed: unknown\n try {\n parsed = JSON.parse(output)\n } catch {\n return undefined\n }\n const post = Array.isArray(parsed) ? socialPostsFrom(parsed)[0] : isSocialPost(parsed) ? parsed : undefined\n if (!post) return undefined\n if (post.media.kind !== \"video\") return { kind: \"none\" }\n const file = videoFileLink(post.media.videoUrl)\n if (file) {\n const end = signedLinkExpiresAt(file)\n return end !== undefined && end - SOCIAL_POST_VIDEO_LINK_MARGIN_MS <= now ? { kind: \"expired\" } : { kind: \"file\", url: file }\n }\n const page = httpLink(post.url)\n return page ? { kind: \"page\", url: page } : undefined\n}\n\n/**\n * The longest video among the posts, in seconds: what Video Analysis quotes\n * for each post a Social Search wire hands it (each post is charged by its\n * own length when it runs, so the quote is never lower than the charge).\n * Posts without a video are left out: Video Analysis refuses them without a\n * charge. Undefined when no post has a video, or one of them does not say\n * how long it is (the ceiling quotes it).\n */\nexport function socialPostsLongestVideoSec(posts: readonly SocialPost[]): number | undefined {\n const lengths = posts.filter((p) => p.media.kind === \"video\").map((p) => p.media.durationSec)\n if (lengths.length === 0) return undefined\n return lengths.every((d): d is number => typeof d === \"number\" && Number.isFinite(d) && d > 0)\n ? Math.max(...lengths)\n : undefined\n}\n\n// ── Pricing ────────────────────────────────────────────────────────────────\n\n/**\n * Credits for one page of results (up to 20 posts), set by the owner: 20 /\n * 40 / 60 results cost 20 / 40 / 60 credits on every platform. The\n * `model_pricing` rows seed the same values. A run is charged by the results\n * it asks for (pages), never by the platform.\n */\nexport const SOCIAL_SEARCH_CREDITS_PER_PAGE = 20\n\nexport function socialSearchCreditId(count: SocialSearchCount): string {\n return `${SOCIAL_SEARCH_NODE_TYPE}:${socialSearchPages(count)}`\n}\n\nexport function socialSearchCreditIdFromNode(data: Readonly<Record<string, unknown>>): string {\n const platform = socialSearchPlatform(data.platform)\n return socialSearchCreditId(socialSearchEffectiveCount(platform, socialSearchMode(platform, data.mode), data.count))\n}\n\n/** Every id a search can reserve, plus the bare id (the node's headline price). */\nexport const SOCIAL_SEARCH_CREDIT_COSTS: Readonly<Record<string, number>> = Object.fromEntries([\n [SOCIAL_SEARCH_NODE_TYPE, SOCIAL_SEARCH_CREDITS_PER_PAGE],\n ...SOCIAL_SEARCH_COUNTS.map((count) => [socialSearchCreditId(count), SOCIAL_SEARCH_CREDITS_PER_PAGE * socialSearchPages(count)] as const),\n])\n\n// ── Which posts a run passes on ────────────────────────────────────────────\n\nexport function socialSearchPickTop(value: unknown): number {\n const n = typeof value === \"number\" && Number.isFinite(value) ? Math.round(value) : SOCIAL_SEARCH_DEFAULT_PICK_TOP\n return Math.min(60, Math.max(1, n))\n}\n\n/**\n * The posts passed on: the ones a person picked, in the order they picked\n * them, when any of them is among the results; otherwise the first `pickTop`.\n * Picks belong to the search a person picked from: a NEW search (the editor's\n * run, a workflow run) starts with none, so it passes on the first `pickTop`\n * — the same in both engines. Keeping picks means not searching again\n * (`isSocialSearchPickFrozen`).\n */\nexport function pickSocialPosts(\n results: readonly SocialPost[],\n pickedIds: readonly string[] | undefined,\n pickTop: unknown,\n): SocialPost[] {\n const byId = new Map(results.map((p) => [p.id, p]))\n const picked = (pickedIds ?? []).map((id) => byId.get(id)).filter((p): p is SocialPost => p !== undefined)\n return picked.length > 0 ? picked : results.slice(0, socialSearchPickTop(pickTop))\n}\n\n/**\n * \"Keep my picks\": a node whose author picked posts and chose to keep them\n * does not search again on a workflow run — it passes its picks on, like a\n * frozen (skipped) node. Both engines treat it as skipped.\n */\nexport function isSocialSearchPickFrozen(type: string | undefined, data: Readonly<Record<string, unknown>>): boolean {\n return type === SOCIAL_SEARCH_NODE_TYPE && data.keepPicks === true && socialPostsFrom(data.generatedJson).length > 0\n}\n\nfunction metricLine(post: SocialPost): string {\n const m = post.metrics\n if (m.views !== undefined) return `${m.views} views`\n if (m.score !== undefined) return `${m.score} points`\n if (m.likes !== undefined) return `${m.likes} likes`\n return \"\"\n}\n\n/** One post as a few plain lines: who, when, reach; the words; the link. */\nexport function socialPostDigestLine(post: SocialPost, index: number): string {\n const who = post.author.handle ? `@${post.author.handle.replace(/^@/, \"\")}` : post.author.name || post.container || \"\"\n const when = post.publishedAt ? post.publishedAt.slice(0, 10) : \"\"\n const words = (post.title || post.text).replace(/\\s+/g, \" \").trim()\n const snippet = words.length > 160 ? `${words.slice(0, 159)}…` : words\n const head = `${index + 1}. ${[who, when, metricLine(post)].filter(Boolean).join(\" · \")}`\n return [head, snippet, post.url].filter(Boolean).join(\"\\n \")\n}\n\n/** The posts as text, for nodes that read text (a prompt, a writer). */\nexport function socialPostsDigest(posts: readonly SocialPost[]): string {\n return posts.map(socialPostDigestLine).join(\"\\n\\n\")\n}\n","/**\n * Saved posts — the inspiration wall's wire contract.\n *\n * A person saves a post they found (a Social Search result) with a note and\n * tags, to come back to it or feed it into a workflow. The row keeps a\n * snapshot of the post, because platform links and numbers change, and the\n * post's still is copied into the person's storage so the wall outlives the\n * platform's signed image links.\n *\n * Why public: `SavedPost` is what `GET /v1/saved-posts` returns and the SDK's\n * `savedPosts` resource types.\n */\nimport type { SocialPlatform, SocialPost } from \"./social-search.js\"\n\n/** Where a save came from. */\nexport const SAVED_POST_SOURCES = [\"picker\", \"competitors\", \"manual\", \"api\"] as const\nexport type SavedPostSource = (typeof SAVED_POST_SOURCES)[number]\n\nexport const SAVED_POST_NOTE_MAX = 2000\nexport const SAVED_POST_MAX_TAGS = 10\nexport const SAVED_POST_TAG_MAX = 40\nexport const SAVED_POSTS_PAGE_MAX = 100\n/** How many post ids one lookup may ask about. */\nexport const SAVED_POSTS_LOOKUP_MAX = 200\n\nexport interface SavedPost {\n readonly id: string\n /** The post's own id (`SocialPost.id`); one save per post per person. */\n readonly postId: string\n readonly platform: SocialPlatform\n readonly url: string\n /** The post as it was when saved. */\n readonly post: SocialPost\n /** The still, copied into the person's storage; null when the copy failed\n * (the post's own `media.thumbnailUrl` is then the only, expiring, link). */\n readonly thumbnailUrl: string | null\n readonly note: string\n readonly tags: readonly string[]\n readonly source: SavedPostSource\n readonly createdAt: string\n readonly updatedAt: string\n}\n\n/** The body of `POST /v1/saved-posts`. Saving a post already saved updates\n * its note and tags (when given) and returns the existing save. */\nexport type SavePostInput = {\n readonly post: SocialPost\n readonly note?: string\n readonly tags?: readonly string[]\n readonly source?: SavedPostSource\n}\n\n/** The body of `PATCH /v1/saved-posts/:id`. */\nexport type UpdateSavedPostInput = {\n readonly note?: string\n readonly tags?: readonly string[]\n}\n\n/** Query of `GET /v1/saved-posts`. */\nexport type ListSavedPostsParams = {\n readonly platform?: SocialPlatform\n /** Only saves carrying this tag. */\n readonly tag?: string\n /** Words to find in the note or the post's text. */\n readonly q?: string\n /** The `nextCursor` of the previous page. */\n readonly cursor?: string\n /** 1–100, default 40. */\n readonly limit?: number\n}\n\nexport interface ListSavedPostsResult {\n readonly data: readonly SavedPost[]\n readonly nextCursor: string | null\n}\n\n/** The answer of `POST /v1/saved-posts/lookup`: which of the asked posts are saved. */\nexport interface SavedPostsLookupResult {\n readonly saved: ReadonlyArray<{ readonly postId: string; readonly id: string }>\n}\n\n/**\n * Tags as stored: split on commas (`,` `,` `、`, so \"hooks, openers\" is two\n * tags in any script), trimmed, inner whitespace collapsed, lower-cased, a\n * leading `#` dropped, braces, quotes and backslashes removed (they would\n * change a tag filter's meaning), each at most 40 characters, no repeats, at\n * most 10.\n */\nexport function normalizeSavedPostTags(tags: unknown): string[] {\n if (!Array.isArray(tags)) return []\n const clean = tags\n .filter((t): t is string => typeof t === \"string\")\n .flatMap((t) => t.split(/[,,、]/))\n .map((t) =>\n t\n .replace(/[{}\"\\\\]/g, \"\")\n .trim()\n .replace(/^#+/, \"\")\n .replace(/\\s+/g, \" \")\n .toLowerCase()\n .slice(0, SAVED_POST_TAG_MAX)\n .trim(),\n )\n .filter((t) => t.length > 0)\n return Array.from(new Set(clean)).slice(0, SAVED_POST_MAX_TAGS)\n}\n","/**\n * Read Inspiration and Read Competitor — the nodes that read posts the person\n * already has (the Inspiration library; a tracked brand's scans) and emit them\n * the way Social Search does: `json` the posts (`SocialPost[]`), `text` their\n * digest (`socialPostsDigest`), one list item per post. Both engines' output\n * branches read this ONE list, so a new reader is routed like the rest.\n *\n * The routes behind them (`/v1/inspiration-read`, `/v1/competitor-read`) are\n * free: they read what the account already holds.\n */\n\nexport const INSPIRATION_READ_NODE_TYPE = \"inspiration-read\" as const\nexport const COMPETITOR_READ_NODE_TYPE = \"competitor-read\" as const\n\nexport const SOCIAL_POST_READER_NODE_TYPES: ReadonlySet<string> = new Set([INSPIRATION_READ_NODE_TYPE, COMPETITOR_READ_NODE_TYPE])\n\nexport function isSocialPostReaderNodeType(type: unknown): boolean {\n return typeof type === \"string\" && SOCIAL_POST_READER_NODE_TYPES.has(type)\n}\n\n/** The most posts one run reads. */\nexport const SOCIAL_READ_LIMIT_MAX = 100\nexport const SOCIAL_READ_DEFAULT_LIMIT = 20\n/** A window in hours reaches back at most 30 days; in days, at most a year (Competitors keep at most twelve months of scans). */\nexport const SOCIAL_READ_WINDOW_HOURS_MAX = 720\nexport const SOCIAL_READ_WINDOW_DAYS_MAX = 365\n\n/** `window`: the last N hours or days. `day`: one calendar day in the node's timezone. */\nexport const SOCIAL_READ_PERIODS = [\"window\", \"day\"] as const\nexport type SocialReadPeriod = (typeof SOCIAL_READ_PERIODS)[number]\n\n/** Which of a brand's posts Read Competitor reads: its own, posts about it, or both. */\nexport const COMPETITOR_READ_ROLES = [\"own\", \"about\", \"all\"] as const\nexport type CompetitorReadRole = (typeof COMPETITOR_READ_ROLES)[number]\n\n/** A calendar day as the node stores it. */\nexport const SOCIAL_READ_DAY_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/\n","/**\n * Competitors — the wire contract of the competitor tracking area.\n *\n * A person tracks brands (competitors, or their own brand): their accounts,\n * where to look for posts that name them, and a schedule. Each scan reads the\n * accounts and searches the name, one Social Search page per search, and\n * produces action cards: what happened, why it matters, what to do, with the\n * posts it rests on.\n *\n * Why public: these are the shapes `/v1/competitors*` answers and the SDK's\n * `competitors` resource types; the card `kind` vocabulary is what a client\n * phrases a card by. How a card is decided is not part of the contract.\n */\nimport type { SocialPlatform, SocialPost } from \"./social-search.js\"\nimport { SOCIAL_SEARCH_CREDITS_PER_PAGE } from \"./social-search.js\"\n\n/** The accounts a scan reads straight from. */\nexport const COMPETITOR_ACCOUNT_KEYS = [\"tiktok\", \"instagram\", \"youtube\", \"x\", \"linkedin\", \"meta_ads\"] as const\nexport type CompetitorAccountKey = (typeof COMPETITOR_ACCOUNT_KEYS)[number]\n\n/** Where a scan looks for posts that name the brand. */\nexport const COMPETITOR_ABOUT_PLATFORMS = [\"tiktok\", \"instagram\", \"youtube\", \"x\", \"reddit\", \"linkedin\"] as const\nexport type CompetitorAboutPlatform = (typeof COMPETITOR_ABOUT_PLATFORMS)[number]\nexport const COMPETITOR_DEFAULT_ABOUT_PLATFORMS: readonly CompetitorAboutPlatform[] = [\"tiktok\", \"instagram\", \"youtube\", \"x\", \"reddit\"]\n\nexport const COMPETITOR_SCHEDULES = [\"off\", \"weekly\", \"daily\"] as const\nexport type CompetitorSchedule = (typeof COMPETITOR_SCHEDULES)[number]\n\n/** One search per account and per about-platform. */\nexport const COMPETITOR_SCAN_MAX_SEARCHES = COMPETITOR_ACCOUNT_KEYS.length + COMPETITOR_ABOUT_PLATFORMS.length\nexport const COMPETITOR_SCAN_NODE_TYPE = \"competitor-scan\"\n/** How many brands one person can track. */\nexport const COMPETITORS_MAX = 50\n\nexport type CompetitorAccounts = Partial<Record<CompetitorAccountKey, string>>\n\n/** A search of a brand: its account (\"own\") or its name (\"about\"). */\nexport type CompetitorSearchKind = \"own\" | \"about\"\n\n/** One search a scan runs. */\nexport interface CompetitorSearch {\n readonly kind: CompetitorSearchKind\n readonly platform: SocialPlatform\n}\n\nexport interface TrackedCompetitor {\n readonly id: string\n readonly brand: string\n readonly website: string\n readonly accounts: CompetitorAccounts\n readonly aboutPlatforms: readonly CompetitorAboutPlatform[]\n /** The person's own brand: cards speak to them. */\n readonly isOwn: boolean\n readonly schedule: CompetitorSchedule\n readonly nextScanAt: string | null\n readonly lastScanAt: string | null\n readonly lastScanId: string | null\n /** Why the last scan (or scheduled start) fell short; null when it did not. */\n readonly lastScanError: string | null\n /** A scan is running now. */\n readonly scanning: boolean\n /** Searches one scan runs; a scan costs this many Social Search pages. */\n readonly searches: number\n /** What the next scan searches. Absent from a server older than this field. */\n readonly searchPlan?: readonly CompetitorSearch[]\n readonly createdAt: string\n readonly updatedAt: string\n}\n\n/** What a brand's latest scan found on one platform, and what works for it there. */\nexport interface CompetitorPlatformTally {\n readonly platform: SocialPlatform\n /** The brand's own posts the scan kept there. */\n readonly own: number\n /** Posts about the brand the scan kept there. */\n readonly about: number\n /** The searches the scan ran there. */\n readonly searched: readonly CompetitorSearchKind[]\n /** Of those, the ones that failed; null when the scan cannot say which (a scan stored before this was kept, that had failures). */\n readonly failed: readonly CompetitorSearchKind[] | null\n /** Its typical reach there, in `unit`; null while too few of its posts, or until its next scan. */\n readonly usual: number | null\n readonly unit: \"views\" | \"points\" | \"likes\" | null\n /** What its best posts there share most strongly; null when nothing stands out, or until its next scan. */\n readonly top: BrandLesson | null\n /** The account's followers at this scan; null when the platform gives none (YouTube, Reddit) or no post of its own was read. Absent from an older server. */\n readonly followers?: number | null\n}\n\n/** A brand's latest scan, platform by platform. */\nexport interface CompetitorBrandTally {\n readonly scanId: string\n readonly at: string\n readonly platforms: readonly CompetitorPlatformTally[]\n}\n\nexport const ACTION_CARD_KINDS = [\n \"outlier\",\n \"launch\",\n \"complaints\",\n \"spreading\",\n \"sound\",\n \"mentions_up\",\n \"pace\",\n \"market_sound\",\n \"top_in_sources\",\n] as const\nexport type ActionCardKind = (typeof ACTION_CARD_KINDS)[number]\n\n/** 1 = act now · 2 = an opening worth taking · 3 = good to know. */\nexport type ActionCardPriority = 1 | 2 | 3\n\nexport interface ActionCard {\n /** Stable across scans for the same finding. */\n readonly id: string\n readonly kind: ActionCardKind\n readonly priority: ActionCardPriority\n /** How strong the finding is within its kind, 0 to 1. The API returns\n * cards already in order (priority, then kind, then strength). */\n readonly strength?: number\n /** The tracked brand it is about; null for a market card. */\n readonly subjectId: string | null\n /**\n * The numbers and words to phrase the card with. Common: `brand`, `own`.\n * Per kind: outlier `platform, ratio, over100, reach, usual, unit` ·\n * launch `firstLine, posts` · complaints `count, example` · spreading and\n * top_in_sources `platform, reach, perDay, unit, firstLine` · sound\n * `soundTitle, posts, views` · market_sound `soundTitle, brands, views` ·\n * mentions_up `now, before` · pace `platform, recent, before`.\n */\n readonly params: Readonly<Record<string, string | number | boolean | readonly string[]>>\n /** Ids of the posts it rests on (at most four). */\n readonly evidence: readonly string[]\n /** English text, for surfaces that do not phrase cards themselves. */\n readonly title: string\n readonly why: string\n readonly action: string\n}\n\n/** A post a scan found, with whose it is. */\nexport type CompetitorPost = SocialPost & { readonly role: \"own\" | \"about\" | \"market\" }\n\nexport interface CompetitorScanCounts {\n readonly own: number\n readonly about: number\n readonly searches: number\n readonly failedSearches: number\n /** The searches that returned, as `<own|about>:<platform>`. */\n readonly okSearches?: readonly string[]\n}\n\nexport interface CompetitorScanSummary {\n readonly id: string\n readonly at: string\n readonly counts: CompetitorScanCounts\n readonly cards: number\n}\n\nexport interface CompetitorScan {\n readonly id: string\n readonly at: string\n readonly counts: CompetitorScanCounts\n readonly posts: readonly CompetitorPost[]\n readonly cards: readonly ActionCard[]\n}\n\n/** `GET /v1/competitors`. */\nexport interface CompetitorListResult {\n readonly data: readonly TrackedCompetitor[]\n /** How many months of scans your plan keeps (older scans are deleted at a brand's next scan). Absent from an older server. */\n readonly historyMonths?: number\n}\n\n/** One platform as one scan found and read it. Numbers a scan stored before they were kept answer null. */\nexport interface CompetitorHistoryPlatform {\n readonly platform: SocialPlatform\n readonly own: number | null\n readonly about: number | null\n /** The account's followers at that scan; null when the platform gives none. */\n readonly followers: number | null\n /** The brand's usual reach there as learned at that scan, in `unit`. */\n readonly usual: number | null\n readonly unit: \"views\" | \"points\" | \"likes\" | null\n}\n\nexport interface CompetitorHistoryPoint {\n readonly id: string\n readonly at: string\n readonly platforms: readonly CompetitorHistoryPlatform[]\n}\n\n/** `GET /v1/competitors/:id/history`: the brand's scans, oldest first. */\nexport interface CompetitorHistory {\n readonly scans: readonly CompetitorHistoryPoint[]\n}\n\n/** The followers a scan read, and when. */\nexport interface CompetitorPeriodFollowers {\n readonly value: number\n readonly at: string\n}\n\n/** A brand on one platform over a period. */\nexport interface CompetitorPeriodPlatform {\n readonly platform: SocialPlatform\n /** The brand's own posts published in the period, and the posts about it. */\n readonly own: number\n readonly about: number\n /** The median reach of its own posts in the period; null below three posts. */\n readonly usual: number | null\n readonly unit: \"views\" | \"points\" | \"likes\" | null\n /** From the newest scan inside the period; null when no scan read them. */\n readonly followers: CompetitorPeriodFollowers | null\n /** Followers gained (or lost) since the newest scan before the period; null when either side is unknown. */\n readonly change: number | null\n /** What worked there in the period (the lessons need eight posts). */\n readonly lessons: readonly BrandLesson[]\n /** Its best posts of the period there, best first, at most four. */\n readonly best: readonly string[]\n}\n\nexport interface CompetitorPeriod {\n readonly from: string\n readonly to: string\n readonly platforms: readonly CompetitorPeriodPlatform[]\n}\n\n/** `GET /v1/competitors/:id/compare`: ISO datetimes; a period is at most a year; `vsFrom` and `vsTo` go together. */\nexport interface CompetitorCompareInput {\n readonly from: string\n readonly to: string\n readonly vsFrom?: string\n readonly vsTo?: string\n}\n\n/** One or two periods, and the posts they name. */\nexport interface CompetitorCompareResult {\n readonly periods: readonly CompetitorPeriod[]\n readonly posts: Readonly<Record<string, CompetitorPost>>\n}\n\n/** `GET /v1/competitors/:id`. */\nexport interface CompetitorDetail extends TrackedCompetitor {\n readonly latestScan: CompetitorScan | null\n /** Its latest scan, platform by platform; null before its first scan. Absent from an older server. */\n readonly platforms?: readonly CompetitorPlatformTally[] | null\n /** Newest first, at most twelve. */\n readonly scans: readonly CompetitorScanSummary[]\n}\n\n/** `GET /v1/competitors/cards`: every card, most urgent first, and the posts they rest on. */\nexport interface CompetitorCardsResult {\n readonly cards: readonly ActionCard[]\n readonly posts: Readonly<Record<string, CompetitorPost>>\n /**\n * How the advice the person acted on went, per family. Within a priority,\n * cards of a family marked `proven` come first and `weak` ones last; the\n * order of priorities never changes. Empty until there are verdicts.\n */\n readonly record?: readonly AdviceRecord[]\n /** Each tracked brand with a scan (by id): its latest scan, platform by platform. Absent from an older server. */\n readonly brands?: Readonly<Record<string, CompetitorBrandTally>>\n}\n\n// ── Did it work? (\"I did this\" on a card) ─────────────────────────────────\n\n/**\n * Advice is summed up by family: a competitor's sound and a sound around the\n * market are both \"sound\"; \"outlier\" is making a post like a competitor's\n * best one.\n */\nexport const ADVICE_FAMILIES = [\"sound\", \"outlier\", \"launch\", \"complaints\"] as const\nexport type AdviceFamily = (typeof ADVICE_FAMILIES)[number]\n\n/** The family a card's advice belongs to; null for a card whose advice is not a post. */\nexport function adviceFamilyOf(kind: string): AdviceFamily | null {\n if (kind === \"sound\" || kind === \"market_sound\") return \"sound\"\n if (kind === \"outlier\" || kind === \"launch\" || kind === \"complaints\") return kind\n return null\n}\n\n/**\n * Whether \"I did this\" applies: the card's advice ends in a post of the\n * person's own. Complaints about their own brand end in replies, so not those.\n * The server is the judge; this only decides whether to offer the button.\n */\nexport function isMeasurableCard(card: Pick<ActionCard, \"kind\" | \"params\">): boolean {\n if (card.kind === \"complaints\") return card.params.own !== true\n return adviceFamilyOf(card.kind) !== null\n}\n\n/** What a card said when it was acted on (cards change with every scan). */\nexport interface CardSnapshot {\n readonly title: string\n readonly why: string\n readonly action: string\n readonly priority?: ActionCardPriority\n /** The card's numbers and words, to phrase it as the wall did. */\n readonly params?: ActionCard[\"params\"]\n readonly brand?: string\n readonly platform?: string\n readonly evidence: readonly string[]\n /** A sound card's sound. */\n readonly soundId?: string\n /** When the card first showed. */\n readonly cardAt?: string\n}\n\nexport const CARD_OUTCOME_STATES = [\n \"worked\",\n \"flat\",\n \"missed\",\n \"waiting\",\n \"not_found\",\n \"older_than_advice\",\n \"no_baseline\",\n \"posts_since\",\n \"no_posts_yet\",\n \"no_brand\",\n] as const\n/**\n * worked / flat (about the usual) / missed (below it): the verdict on the one\n * post tied to the card. waiting: that post is too new, or not scanned yet.\n * not_found: the linked post never showed up in the brand's scans.\n * older_than_advice: the linked post went up before the advice.\n * no_baseline: too few of the brand's posts on that platform to compare with.\n * posts_since: nothing tied to the card; the brand's posts since, no verdict.\n * no_posts_yet: nothing tied and no post since. no_brand: no own brand scanned.\n */\nexport type CardOutcomeState = (typeof CARD_OUTCOME_STATES)[number]\n\nexport interface CardOutcome {\n readonly state: CardOutcomeState\n /** The post's reach over the brand's usual. */\n readonly ratio?: number\n readonly liftLabel?: string\n readonly reach?: number\n readonly usual?: number\n readonly unit?: \"views\" | \"points\" | \"likes\"\n readonly platform?: string\n /** The judged post first; with no tie, the best posts since. */\n readonly postIds?: readonly string[]\n readonly ageDays?: number\n /** How the judged post was tied: the person's link, or a sound card's sound. */\n readonly matchedBy?: \"link\" | \"sound\"\n /** The brand's posts since the advice, newest first, to pick the one that came of it. */\n readonly candidates?: readonly string[]\n}\n\n/** The first verdict, kept as it was reached. */\nexport interface CardVerdict {\n readonly state: \"worked\" | \"flat\" | \"missed\"\n readonly ratio: number\n readonly reach: number\n readonly usual: number\n readonly unit: \"views\" | \"points\" | \"likes\"\n readonly platform: string\n readonly postId: string\n readonly matchedBy: \"link\" | \"sound\"\n readonly at: string\n}\n\n/** A card the person acted on, and how it went. */\nexport interface CardAction {\n readonly id: string\n /** The card on the wall it was made on. */\n readonly cardId: string\n readonly cardKind: ActionCardKind\n readonly card: CardSnapshot\n /** The tracked brand it was about; null for a market card (or a removed brand). */\n readonly subjectId: string | null\n readonly postUrl: string | null\n /** When the post was linked. */\n readonly linkedAt: string | null\n readonly actedAt: string\n readonly verdict: CardVerdict | null\n /** When the person first saw the verdict. */\n readonly seenAt: string | null\n /**\n * The card is still on the wall. Once it leaves, the mark stays (in Tried\n * and the record), and the card can be marked anew if it comes back.\n */\n readonly onWall: boolean\n readonly outcome: CardOutcome\n}\n\n/** How one family of advice went for the person, one verdict per post. */\nexport interface AdviceRecord {\n readonly family: AdviceFamily\n readonly tried: number\n readonly worked: number\n readonly flat: number\n readonly missed: number\n /** The mean of those posts' reach over the usual. */\n readonly avgRatio: number\n /** Enough verdicts to show this record. */\n readonly shown: boolean\n /** Whether it moves this family's cards (up when proven, down when weak). */\n readonly tier: \"proven\" | \"weak\" | \"neutral\"\n}\n\n/** `GET /v1/competitors/actions`: the cards the person acted on, newest first. */\nexport interface CompetitorActionsResult {\n readonly actions: readonly CardAction[]\n readonly record: readonly AdviceRecord[]\n /** The posts the outcomes name, by id. */\n readonly posts: Readonly<Record<string, CompetitorPost>>\n}\n\n/** `POST /v1/competitors/actions`: mark a card on the wall as done. */\nexport interface MarkCardInput {\n readonly cardId: string\n /** The person's own post that came of it (http(s), up to 1,000 characters). */\n readonly postUrl?: string | null\n}\n\n/** `POST` and `PATCH /v1/competitors/actions*`: the mark, and the posts its outcome names. */\nexport interface CardActionResult {\n readonly action: CardAction\n readonly posts: Readonly<Record<string, CompetitorPost>>\n /** POST only: false when the card was already marked (the mark is returned as it was). */\n readonly created?: boolean\n}\n\n/** `PATCH /v1/competitors/actions/:id`: link (or unlink with null) the post, or mark the verdict seen. */\nexport interface UpdateCardActionInput {\n readonly postUrl?: string | null\n readonly seen?: true\n}\n\n// ── What works (stage 4: learning from results) ───────────────────────────\n\n/** The traits a brand's best posts can share. */\nexport const BRAND_LESSON_KINDS = [\n \"short_videos\",\n \"long_videos\",\n \"format\",\n \"question_hook\",\n \"number_hook\",\n \"short_caption\",\n \"long_caption\",\n \"hashtag\",\n \"sound\",\n \"weekday\",\n] as const\nexport type BrandLessonKind = (typeof BRAND_LESSON_KINDS)[number]\n\n/**\n * One thing a brand's best posts share, measured on its own posts: the posts\n * with the trait reached `lift` times what the rest did.\n */\nexport interface BrandLesson {\n /** `<platform>:<kind>:<key>`, stable across reads. */\n readonly id: string\n readonly kind: BrandLessonKind\n readonly platform: string\n /**\n * Always `lift` (number), `liftLabel` (\"2.4x\"), `posts` (with the trait),\n * `winners` (of the best among them) and `unit` (\"views\" | \"likes\" |\n * \"points\"). Per kind: short_videos `maxSec` · long_videos `minSec` ·\n * format `format` · short_caption and long_caption `chars` · hashtag `tag` ·\n * sound `sound` · weekday `day` (0 = Sunday, UTC).\n */\n readonly params: Readonly<Record<string, string | number | boolean | readonly string[]>>\n /** Ids of the posts it rests on, best first (at most four). */\n readonly evidence: readonly string[]\n readonly strength: number\n /** English, for surfaces that do not phrase lessons themselves. */\n readonly text: string\n}\n\n/** What works for a brand on one platform. */\nexport interface BrandPlatformLessons {\n readonly platform: string\n /** The brand's own posts counted there. */\n readonly posts: number\n /** Their typical reach; null while there are fewer than `minPosts`. */\n readonly usual: number | null\n readonly unit: \"views\" | \"points\" | \"likes\"\n /** Its best posts, best first. */\n readonly winners: readonly string[]\n /** Its weakest posts, weakest first. */\n readonly misses: readonly string[]\n readonly lessons: readonly BrandLesson[]\n}\n\nexport interface BrandLessons {\n readonly subjectId: string\n /** The user's own brand (\"what works for you\"), not a competitor. */\n readonly isOwn: boolean\n readonly platforms: readonly BrandPlatformLessons[]\n /** Posts a platform needs before it gets lessons. */\n readonly minPosts: number\n}\n\n/** `GET /v1/competitors/:id/lessons`: what works for a tracked brand, and the posts it names. */\nexport interface CompetitorLessonsResult {\n readonly lessons: BrandLessons\n readonly posts: Readonly<Record<string, CompetitorPost>>\n}\n\n/** `POST /v1/competitor-discover`: a brand's accounts found from its website. */\nexport interface CompetitorDiscovery {\n readonly brand: string\n readonly website: string\n readonly accounts: Partial<Record<CompetitorAccountKey, { readonly value: string; readonly from: \"site\" | \"guess\" }>>\n}\n\nexport type CreateCompetitorInput = {\n readonly brand: string\n readonly website?: string\n readonly accounts?: CompetitorAccounts\n readonly aboutPlatforms?: readonly CompetitorAboutPlatform[]\n readonly isOwn?: boolean\n /** Default weekly. */\n readonly schedule?: CompetitorSchedule\n}\n\nexport type UpdateCompetitorInput = Partial<CreateCompetitorInput>\n\n/** Searches a scan of this configuration runs. */\nexport function competitorScanSearches(c: { readonly accounts?: CompetitorAccounts; readonly aboutPlatforms?: readonly string[] }): number {\n const accounts = COMPETITOR_ACCOUNT_KEYS.filter((k) => (c.accounts?.[k] ?? \"\").trim() !== \"\").length\n const about = (c.aboutPlatforms ?? []).filter((p) => (COMPETITOR_ABOUT_PLATFORMS as readonly string[]).includes(p)).length\n return accounts + about\n}\n\n/** The credit id of a scan of `n` searches. */\nexport function competitorScanCreditId(n: number): string {\n const clamped = Math.min(Math.max(Math.round(n), 1), COMPETITOR_SCAN_MAX_SEARCHES)\n return `${COMPETITOR_SCAN_NODE_TYPE}:${clamped}`\n}\n\n/** A scan costs one Social Search page per search: every id it can reserve. */\nexport const COMPETITOR_SCAN_CREDIT_COSTS: Readonly<Record<string, number>> = Object.fromEntries(\n Array.from({ length: COMPETITOR_SCAN_MAX_SEARCHES }, (_, i) => [competitorScanCreditId(i + 1), (i + 1) * SOCIAL_SEARCH_CREDITS_PER_PAGE] as const),\n)\n\n/** The credits a scan of this many searches costs. */\nexport function competitorScanCredits(searches: number): number {\n return searches <= 0 ? 0 : COMPETITOR_SCAN_CREDIT_COSTS[competitorScanCreditId(searches)] ?? 0\n}\n\n/** Whether a platform is one the about-search covers (used by pickers). */\nexport function isCompetitorAboutPlatform(value: string): value is CompetitorAboutPlatform & SocialPlatform {\n return (COMPETITOR_ABOUT_PLATFORMS as readonly string[]).includes(value)\n}\n","export type SocialMediaPlatform = \"instagram\" | \"tiktok\" | \"x\" | \"youtube\" | \"facebook\" | \"linkedin\" | \"telegram\"\n\nexport type SocialMediaContentType =\n | \"feed-square\" | \"feed-portrait\" | \"feed-landscape\" | \"story-reel\" // Instagram\n | \"video\" // TikTok\n | \"image-landscape\" | \"image-square\" | \"x-video\" // X\n | \"short\" // YouTube\n | \"fb-feed-portrait\" | \"reel\" // Facebook\n | \"li-image-landscape\" | \"li-image-square\" | \"li-video\" // LinkedIn\n\nexport interface SocialMediaSpec {\n readonly platform: SocialMediaPlatform\n readonly contentType: SocialMediaContentType\n readonly label: string\n readonly width: number\n readonly height: number\n readonly maxDurationSeconds: number | null // null = image only (no duration limit)\n readonly textLimit: number\n readonly isVideo: boolean\n}\n\nexport const PLATFORM_SPECS: Record<string, SocialMediaSpec> = {\n \"instagram:feed-square\": {\n platform: \"instagram\", contentType: \"feed-square\", label: \"Feed Square\",\n width: 1080, height: 1080, maxDurationSeconds: 60, textLimit: 2200, isVideo: true,\n },\n \"instagram:feed-portrait\": {\n platform: \"instagram\", contentType: \"feed-portrait\", label: \"Feed Portrait\",\n width: 1080, height: 1350, maxDurationSeconds: 60, textLimit: 2200, isVideo: true,\n },\n \"instagram:feed-landscape\": {\n platform: \"instagram\", contentType: \"feed-landscape\", label: \"Feed Landscape\",\n width: 1080, height: 566, maxDurationSeconds: 60, textLimit: 2200, isVideo: true,\n },\n \"instagram:story-reel\": {\n platform: \"instagram\", contentType: \"story-reel\", label: \"Story / Reel\",\n width: 1080, height: 1920, maxDurationSeconds: 180, textLimit: 2200, isVideo: true,\n },\n \"tiktok:video\": {\n platform: \"tiktok\", contentType: \"video\", label: \"Video\",\n width: 1080, height: 1920, maxDurationSeconds: 600, textLimit: 4000, isVideo: true,\n },\n \"x:image-landscape\": {\n platform: \"x\", contentType: \"image-landscape\", label: \"Image Landscape\",\n width: 1200, height: 675, maxDurationSeconds: null, textLimit: 280, isVideo: false,\n },\n \"x:image-square\": {\n platform: \"x\", contentType: \"image-square\", label: \"Image Square\",\n width: 1080, height: 1080, maxDurationSeconds: null, textLimit: 280, isVideo: false,\n },\n \"x:x-video\": {\n platform: \"x\", contentType: \"x-video\", label: \"Video\",\n width: 1920, height: 1080, maxDurationSeconds: 140, textLimit: 280, isVideo: true,\n },\n \"youtube:short\": {\n platform: \"youtube\", contentType: \"short\", label: \"Short\",\n width: 1080, height: 1920, maxDurationSeconds: 180, textLimit: 5000, isVideo: true,\n },\n \"facebook:fb-feed-portrait\": {\n platform: \"facebook\", contentType: \"fb-feed-portrait\", label: \"Feed Portrait\",\n width: 1080, height: 1350, maxDurationSeconds: null, textLimit: 63206, isVideo: false,\n },\n \"facebook:reel\": {\n platform: \"facebook\", contentType: \"reel\", label: \"Reel\",\n width: 1080, height: 1920, maxDurationSeconds: 90, textLimit: 63206, isVideo: true,\n },\n \"linkedin:li-image-landscape\": {\n platform: \"linkedin\", contentType: \"li-image-landscape\", label: \"Image Landscape\",\n width: 1200, height: 627, maxDurationSeconds: null, textLimit: 3000, isVideo: false,\n },\n \"linkedin:li-image-square\": {\n platform: \"linkedin\", contentType: \"li-image-square\", label: \"Image Square\",\n width: 1080, height: 1080, maxDurationSeconds: null, textLimit: 3000, isVideo: false,\n },\n \"linkedin:li-video\": {\n platform: \"linkedin\", contentType: \"li-video\", label: \"Video\",\n width: 1920, height: 1080, maxDurationSeconds: 600, textLimit: 3000, isVideo: true,\n },\n}\n\nexport const CONTENT_TYPES_BY_PLATFORM: Record<SocialMediaPlatform, ReadonlyArray<{ key: string; label: string }>> = {\n instagram: [\n { key: \"instagram:feed-square\", label: \"Feed Square (1080×1080)\" },\n { key: \"instagram:feed-portrait\", label: \"Feed Portrait (1080×1350)\" },\n { key: \"instagram:feed-landscape\", label: \"Feed Landscape (1080×566)\" },\n { key: \"instagram:story-reel\", label: \"Story / Reel (1080×1920)\" },\n ],\n tiktok: [\n { key: \"tiktok:video\", label: \"Video (1080×1920)\" },\n ],\n x: [\n { key: \"x:image-landscape\", label: \"Image Landscape (1200×675)\" },\n { key: \"x:image-square\", label: \"Image Square (1080×1080)\" },\n { key: \"x:x-video\", label: \"Video (1920×1080)\" },\n ],\n youtube: [\n { key: \"youtube:short\", label: \"Short (1080×1920)\" },\n ],\n facebook: [\n { key: \"facebook:fb-feed-portrait\", label: \"Feed Portrait (1080×1350)\" },\n { key: \"facebook:reel\", label: \"Reel (1080×1920)\" },\n ],\n linkedin: [\n { key: \"linkedin:li-image-landscape\", label: \"Image Landscape (1200×627)\" },\n { key: \"linkedin:li-image-square\", label: \"Image Square (1080×1080)\" },\n { key: \"linkedin:li-video\", label: \"Video (1920×1080)\" },\n ],\n telegram: [\n { key: \"telegram:message\", label: \"Message (text)\" },\n ],\n}\n\nexport const PLATFORM_LABELS: Record<SocialMediaPlatform, string> = {\n instagram: \"Instagram\",\n tiktok: \"TikTok\",\n x: \"X (Twitter)\",\n youtube: \"YouTube\",\n facebook: \"Facebook\",\n linkedin: \"LinkedIn\",\n telegram: \"Telegram\",\n}\n","/**\n * Telegram Channel Feed — the post shape the node emits on its `json` handle,\n * the digest its `text` handle carries, and the ONE cursor rule (where the\n * feed's position goes after a run). Structural vocabulary and a pure rule;\n * the fetching lives in the backend (`services/social/telegram-channel.ts`).\n *\n * Media links (`cdn*.telesco.pe/...`) carry a `?token=` and expire within days:\n * a consumer that needs the picture later copies it (an upload node, a\n * collection), never stores the link alone.\n */\n\nexport interface TelegramChannelPostMedia {\n readonly type: \"photo\" | \"video\"\n /** The file — a photo's, or a video's when the preview page embeds the file (\"Watch in Telegram\" players have none). */\n readonly url?: string\n /** A video's poster frame. */\n readonly posterUrl?: string\n}\n\nexport interface TelegramChannelPost {\n /** Sequential per-channel message id. */\n readonly id: number\n /** The channel's bare id (no `@`). */\n readonly channel: string\n /** Canonical link to the post. */\n readonly postUrl: string\n /** Plain text (HTML stripped, entities decoded); a reply's quoted text is not part of it. */\n readonly text: string\n /** ISO timestamp of the post. */\n readonly date?: string\n /** The channel or person the post was forwarded from. */\n readonly forwardedFrom?: { readonly name: string; readonly url?: string }\n /** Every photo and video of the post, in page order (an album is several). */\n readonly media: readonly TelegramChannelPostMedia[]\n /** The first picture — the first photo, else the first video's poster — for a consumer that takes one image. */\n readonly imageUrl?: string\n /** The view counter as the page shows it (\"1.52M\"). */\n readonly views?: string\n}\n\n/** The most posts a poll emits per run — two preview pages at most. */\nexport const TELEGRAM_FEED_LIMIT_MAX = 30\n/** The most posts a peek (\"re-fetch the last N\") can show — one preview page. */\nexport const TELEGRAM_FEED_PEEK_MAX = 20\n/** What one preview page (`t.me/s/<channel>[?after=<id>]`) renders. */\nexport const TELEGRAM_FEED_PAGE_SIZE = 20\n/** The default posts per run. */\nexport const TELEGRAM_FEED_DEFAULT_LIMIT = 5\nexport const TELEGRAM_FEED_DIGEST_SEPARATOR = \"\\n\\n---\\n\\n\"\n\n/** The `text` handle: the posts' text, oldest first, joined by a rule. Posts with no text (a bare picture) add nothing. */\nexport function telegramFeedDigest(posts: ReadonlyArray<Pick<TelegramChannelPost, \"text\">>): string {\n return posts\n .map((p) => p.text)\n .filter((t) => typeof t === \"string\" && t.trim().length > 0)\n .join(TELEGRAM_FEED_DIGEST_SEPARATOR)\n}\n\nconst isRecord = (v: unknown): v is Record<string, unknown> => typeof v === \"object\" && v !== null && !Array.isArray(v)\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" ? v : undefined)\n\n/**\n * The posts held in a saved `generatedJson` / a run's `output.json`, normalized:\n * anything that is not a post with a numeric id and a text is left out, and a\n * post saved before a field existed reads with that field at its default.\n */\nexport function telegramPostsFrom(value: unknown): TelegramChannelPost[] {\n if (!Array.isArray(value)) return []\n const out: TelegramChannelPost[] = []\n for (const item of value) {\n if (!isRecord(item) || typeof item.id !== \"number\" || !Number.isFinite(item.id) || typeof item.text !== \"string\") continue\n const media = Array.isArray(item.media)\n ? item.media.filter((m): m is TelegramChannelPostMedia => isRecord(m) && (m.type === \"photo\" || m.type === \"video\"))\n : []\n const forwarded = isRecord(item.forwardedFrom) && typeof item.forwardedFrom.name === \"string\"\n ? { name: item.forwardedFrom.name, ...(str(item.forwardedFrom.url) ? { url: item.forwardedFrom.url as string } : {}) }\n : undefined\n const channel = str(item.channel) ?? \"\"\n out.push({\n id: item.id,\n channel,\n postUrl: str(item.postUrl) ?? str(item.url) ?? (channel ? `https://t.me/${channel}/${item.id}` : \"\"),\n text: item.text,\n ...(str(item.date) ? { date: item.date as string } : {}),\n ...(forwarded ? { forwardedFrom: forwarded } : {}),\n media,\n ...(str(item.imageUrl) ? { imageUrl: item.imageUrl as string } : {}),\n ...(str(item.views) ? { views: item.views as string } : {}),\n })\n }\n return out\n}\n\nexport interface FeedEmissionPlan<P extends { readonly id: number }> {\n /** The posts this run emits, oldest first. */\n readonly emitted: P[]\n /** The feed's position after this run (the cursor to store), or undefined when there is nothing to stand on. */\n readonly latestId: number | undefined\n}\n\n/**\n * Where the feed stands after a run — the ONE rule both the route and the\n * tests read (decided 2026-10-05):\n *\n * - no position yet (first run, after Reset): the NEWEST `limit` posts, and\n * the position jumps to the newest post — the person asked for what is new\n * from now on; older posts are never revisited;\n * - a stored position: the OLDEST `limit` posts above it, and the position\n * becomes the highest post EMITTED — a backlog drains `limit` per run and\n * nothing is lost (the old rule jumped to the newest post even when `limit`\n * cut the fetch short, and the posts in between were gone for good).\n *\n * `posts` may come in any order and repeat (a pinned post renders twice).\n */\nexport function planFeedEmission<P extends { readonly id: number }>(\n posts: ReadonlyArray<P>,\n since: number | undefined,\n limit: number,\n /**\n * The highest message id the fetched page(s) rendered above `since`, posts\n * with nothing to read included. When nothing readable lies above the\n * position but the page went further, the position moves past the unreadable\n * posts — else the feed reads the same page every tick for ever.\n */\n pageMaxId?: number,\n): FeedEmissionPlan<P> {\n const cap = Math.max(1, Math.min(TELEGRAM_FEED_LIMIT_MAX, Math.floor(Number.isFinite(limit) ? limit : TELEGRAM_FEED_DEFAULT_LIMIT) || 1))\n const byId = new Map<number, P>()\n for (const post of posts) byId.set(post.id, post)\n const sorted = [...byId.values()].sort((a, b) => a.id - b.id)\n if (since === undefined) {\n const emitted = sorted.slice(-cap)\n return { emitted, latestId: sorted.length > 0 ? sorted[sorted.length - 1]!.id : undefined }\n }\n const fresh = sorted.filter((p) => p.id > since)\n const emitted = fresh.slice(0, cap)\n if (emitted.length > 0) return { emitted, latestId: emitted[emitted.length - 1]!.id }\n const pastUnreadable = pageMaxId !== undefined && Number.isFinite(pageMaxId) && pageMaxId > since\n return { emitted, latestId: pastUnreadable ? pageMaxId : since }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkJ6KHW2E5_cjs = require('./chunk-J6KHW2E5.cjs');
|
|
4
|
+
var chunk5AUSSJIM_cjs = require('./chunk-5AUSSJIM.cjs');
|
|
5
|
+
|
|
6
|
+
// src/video-ui-defaults.ts
|
|
7
|
+
function uiAspectRatioFill(provider) {
|
|
8
|
+
return chunkJ6KHW2E5_cjs.isSeedance2Provider(provider) || chunkJ6KHW2E5_cjs.isMinimaxH3Provider(provider) || chunkJ6KHW2E5_cjs.isWan3Provider(provider) ? "adaptive" : void 0;
|
|
9
|
+
}
|
|
10
|
+
function uiResolutionFill(provider) {
|
|
11
|
+
if (chunkJ6KHW2E5_cjs.isWan3Provider(provider)) return chunkJ6KHW2E5_cjs.PRICING_DEFAULT_RESOLUTION[provider];
|
|
12
|
+
if (chunkJ6KHW2E5_cjs.isSeedance2Provider(provider)) return chunk5AUSSJIM_cjs.MODEL_CATALOG[provider]?.resolutions?.[0];
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
function uiDurationFill(provider) {
|
|
16
|
+
if (chunkJ6KHW2E5_cjs.isWan3Provider(provider)) return 5;
|
|
17
|
+
if (chunkJ6KHW2E5_cjs.isGeminiOmniProvider(provider)) return 8;
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.uiAspectRatioFill = uiAspectRatioFill;
|
|
22
|
+
exports.uiDurationFill = uiDurationFill;
|
|
23
|
+
exports.uiResolutionFill = uiResolutionFill;
|
|
24
|
+
//# sourceMappingURL=chunk-WNG7HRVA.cjs.map
|
|
25
|
+
//# sourceMappingURL=chunk-WNG7HRVA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/video-ui-defaults.ts"],"names":["isSeedance2Provider","isMinimaxH3Provider","isWan3Provider","PRICING_DEFAULT_RESOLUTION","MODEL_CATALOG","isGeminiOmniProvider"],"mappings":";;;;;;AAuCO,SAAS,kBAAkB,QAAA,EAAsC;AACtE,EAAA,OAAOA,qCAAA,CAAoB,QAAQ,CAAA,IAAKC,qCAAA,CAAoB,QAAQ,CAAA,IAAKC,gCAAA,CAAe,QAAQ,CAAA,GAC5F,UAAA,GACA,MAAA;AACN;AAIO,SAAS,iBAAiB,QAAA,EAAsC;AACrE,EAAA,IAAIA,gCAAA,CAAe,QAAQ,CAAA,EAAG,OAAOC,6CAA2B,QAAQ,CAAA;AACxE,EAAA,IAAIH,qCAAA,CAAoB,QAAQ,CAAA,EAAG,OAAOI,gCAAc,QAAQ,CAAA,EAAG,cAAc,CAAC,CAAA;AAClF,EAAA,OAAO,MAAA;AACT;AAUO,SAAS,eAAe,QAAA,EAAsC;AACnE,EAAA,IAAIF,gCAAA,CAAe,QAAQ,CAAA,EAAG,OAAO,CAAA;AACrC,EAAA,IAAIG,sCAAA,CAAqB,QAAQ,CAAA,EAAG,OAAO,CAAA;AAC3C,EAAA,OAAO,MAAA;AACT","file":"chunk-WNG7HRVA.cjs","sourcesContent":["/**\n * UI-default fills for the unified video nodes — the ONE source of truth shared\n * by the backend DAG payload builder, the config-panel fail-safe snaps and the\n * node's hover/run strip.\n *\n * Several config panels RENDER a default without persisting it to node data, so\n * an untouched node submits `aspectRatio` / `resolution` undefined and the\n * enqueued job row (and the /v1/jobs echo) then disagrees with what actually\n * renders. Worse, the panels' generic snap writes `resolutions[0]` for a stale\n * value, which is the CHEAPEST tier under the repo's ascending-resolution\n * convention — not necessarily the tier the model renders and bills.\n *\n * These helpers were local to `backend/src/services/workflow-engine/payload-builder.ts`\n * until the Wan 3.0 launch gave the platform its first provider whose declared\n * billing default differs from `resolutions[0]`; three surfaces then had to\n * agree, so they live here.\n *\n * The resolution fill is per-family ON PURPOSE. Wan 3.0 reads its DECLARED\n * billing default (PRICING_DEFAULT_RESOLUTION = 720p) because its catalog list\n * is ascending, so an index-0 fill would write 480p — a tier both `runWan3`\n * (which renders 720P) and the credit identifier (which bills the 720p row)\n * disagree with. The Seedance family keeps its historical first-catalog-tier\n * fill, deliberately: switching it to PRICING_DEFAULT_RESOLUTION would reprice\n * live seedance-2-5 runs, whose declared default (720p) differs from the 480p\n * this has always filled. That 480p-fill vs 720p-billing-default divergence on\n * seedance-2-5 is a KNOWN pre-existing gap, out of scope here — do not \"align\"\n * the branches without repricing it deliberately.\n */\n\nimport {\n PRICING_DEFAULT_RESOLUTION,\n isSeedance2Provider,\n isMinimaxH3Provider,\n isWan3Provider,\n isGeminiOmniProvider,\n} from \"./model-constants.js\"\nimport { MODEL_CATALOG } from \"./model-catalog.js\"\n\n/** `adaptive` is the aspect default for Seedance 2, MiniMax H3 and Wan 3.0. */\nexport function uiAspectRatioFill(provider: string): string | undefined {\n return isSeedance2Provider(provider) || isMinimaxH3Provider(provider) || isWan3Provider(provider)\n ? \"adaptive\"\n : undefined\n}\n\n/** See the file docstring — per-family on purpose; never a generic\n * PRICING_DEFAULT_RESOLUTION read (that would reprice seedance-2-5). */\nexport function uiResolutionFill(provider: string): string | undefined {\n if (isWan3Provider(provider)) return PRICING_DEFAULT_RESOLUTION[provider]\n if (isSeedance2Provider(provider)) return MODEL_CATALOG[provider]?.resolutions?.[0]\n return undefined\n}\n\n/**\n * Duration the node RENDERS and BILLS when `data.duration` is unset, for the\n * families whose credit identifier declares a duration fallback that is NOT\n * `durations[0]`. Wan 3.0's bare identifier is the 5s tier while its ladder\n * starts at 2s; the Gemini Omni family's is the 8s tier while its ladder starts\n * at 4s. Everyone else falls back to the first listed duration, so this returns\n * undefined and the caller keeps `durations[0]`.\n */\nexport function uiDurationFill(provider: string): number | undefined {\n if (isWan3Provider(provider)) return 5\n if (isGeminiOmniProvider(provider)) return 8\n return undefined\n}\n"]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/entity-node-fields.ts
|
|
4
|
+
var ENTITY_NODE_KINDS = ["character", "object", "creature", "location"];
|
|
5
|
+
var ENTITY_DB_ID_FIELD = {
|
|
6
|
+
character: "characterDbId",
|
|
7
|
+
object: "objectDbId",
|
|
8
|
+
creature: "creatureDbId",
|
|
9
|
+
location: "locationDbId"
|
|
10
|
+
};
|
|
11
|
+
var ENTITY_NAME_FIELD = {
|
|
12
|
+
character: "characterName",
|
|
13
|
+
object: "objectName",
|
|
14
|
+
creature: "creatureName",
|
|
15
|
+
location: "locationName"
|
|
16
|
+
};
|
|
17
|
+
var ENTITY_TABLE = {
|
|
18
|
+
character: "characters",
|
|
19
|
+
object: "objects",
|
|
20
|
+
creature: "creatures",
|
|
21
|
+
location: "locations"
|
|
22
|
+
};
|
|
23
|
+
var ENTITY_BUCKET_FIELDS = {
|
|
24
|
+
character: [
|
|
25
|
+
["expressions", "expressions"],
|
|
26
|
+
["poses", "poses"],
|
|
27
|
+
["motions", "motions"],
|
|
28
|
+
["angles", "angles"],
|
|
29
|
+
["body_angles", "bodyAngles"],
|
|
30
|
+
["lighting_variations", "lightingVariations"],
|
|
31
|
+
["outfit_variations", "outfitVariations"],
|
|
32
|
+
["detail_closeups", "detailCloseups"],
|
|
33
|
+
["sheets", "sheets"]
|
|
34
|
+
],
|
|
35
|
+
object: [
|
|
36
|
+
["angles", "angles"],
|
|
37
|
+
["materials", "materials"],
|
|
38
|
+
["variations", "variations"],
|
|
39
|
+
["motion_clips", "motionClips"],
|
|
40
|
+
["detail_closeups", "detailCloseups"],
|
|
41
|
+
["sheets", "sheets"]
|
|
42
|
+
],
|
|
43
|
+
creature: [
|
|
44
|
+
["angles", "angles"],
|
|
45
|
+
["poses", "poses"],
|
|
46
|
+
["variations", "variations"],
|
|
47
|
+
["motion_clips", "motionClips"],
|
|
48
|
+
["detail_closeups", "detailCloseups"],
|
|
49
|
+
["sheets", "sheets"]
|
|
50
|
+
],
|
|
51
|
+
location: [
|
|
52
|
+
["time_of_day", "timeOfDay"],
|
|
53
|
+
["weather", "weather"],
|
|
54
|
+
["angles", "angles"],
|
|
55
|
+
["lighting", "lighting"],
|
|
56
|
+
["seasons", "seasons"],
|
|
57
|
+
["atmosphere_motions", "atmosphereMotions"],
|
|
58
|
+
["detail_closeups", "detailCloseups"],
|
|
59
|
+
["sheets", "sheets"]
|
|
60
|
+
]
|
|
61
|
+
};
|
|
62
|
+
var ENTITY_SCALAR_FIELDS = [
|
|
63
|
+
["name", "__name"],
|
|
64
|
+
// routed to the kind's own name field by the caller
|
|
65
|
+
["description", "description"],
|
|
66
|
+
["canonical_description", "canonicalDescription"],
|
|
67
|
+
["source_image_url", "sourceImageUrl"]
|
|
68
|
+
];
|
|
69
|
+
var ENTITY_KIND_SCALAR_FIELDS = {
|
|
70
|
+
character: [],
|
|
71
|
+
object: [["style_lock", "styleLock"]],
|
|
72
|
+
creature: [["style_lock", "styleLock"]],
|
|
73
|
+
location: [["style_lock", "styleLock"]]
|
|
74
|
+
};
|
|
75
|
+
function entityHydrationColumns(kind) {
|
|
76
|
+
return [
|
|
77
|
+
"id",
|
|
78
|
+
...entityScalarFields(kind).map(([column]) => column),
|
|
79
|
+
...ENTITY_BUCKET_FIELDS[kind].map(([column]) => column)
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
function entityScalarFields(kind) {
|
|
83
|
+
return [...ENTITY_SCALAR_FIELDS, ...ENTITY_KIND_SCALAR_FIELDS[kind]];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
exports.ENTITY_BUCKET_FIELDS = ENTITY_BUCKET_FIELDS;
|
|
87
|
+
exports.ENTITY_DB_ID_FIELD = ENTITY_DB_ID_FIELD;
|
|
88
|
+
exports.ENTITY_KIND_SCALAR_FIELDS = ENTITY_KIND_SCALAR_FIELDS;
|
|
89
|
+
exports.ENTITY_NAME_FIELD = ENTITY_NAME_FIELD;
|
|
90
|
+
exports.ENTITY_NODE_KINDS = ENTITY_NODE_KINDS;
|
|
91
|
+
exports.ENTITY_SCALAR_FIELDS = ENTITY_SCALAR_FIELDS;
|
|
92
|
+
exports.ENTITY_TABLE = ENTITY_TABLE;
|
|
93
|
+
exports.entityHydrationColumns = entityHydrationColumns;
|
|
94
|
+
exports.entityScalarFields = entityScalarFields;
|
|
95
|
+
//# sourceMappingURL=chunk-WNVQ3SMB.cjs.map
|
|
96
|
+
//# sourceMappingURL=chunk-WNVQ3SMB.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/entity-node-fields.ts"],"names":[],"mappings":";;;AA2BO,IAAM,iBAAA,GAAoB,CAAC,WAAA,EAAa,QAAA,EAAU,YAAY,UAAU;AAKxE,IAAM,kBAAA,GAAqD;AAAA,EAChE,SAAA,EAAW,eAAA;AAAA,EACX,MAAA,EAAQ,YAAA;AAAA,EACR,QAAA,EAAU,cAAA;AAAA,EACV,QAAA,EAAU;AACZ;AAGO,IAAM,iBAAA,GAAoD;AAAA,EAC/D,SAAA,EAAW,eAAA;AAAA,EACX,MAAA,EAAQ,YAAA;AAAA,EACR,QAAA,EAAU,cAAA;AAAA,EACV,QAAA,EAAU;AACZ;AAGO,IAAM,YAAA,GAA+C;AAAA,EAC1D,SAAA,EAAW,YAAA;AAAA,EACX,MAAA,EAAQ,SAAA;AAAA,EACR,QAAA,EAAU,WAAA;AAAA,EACV,QAAA,EAAU;AACZ;AASO,IAAM,oBAAA,GAAyF;AAAA,EACpG,SAAA,EAAW;AAAA,IACT,CAAC,eAAe,aAAa,CA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AAA;AAAA,EACjB,CAAC,eAAe,aAAa,CAAA;AAAA,EAC7B,CAAC,yBAAyB,sBAAsB,CAAA;AAAA,EAChD,CAAC,oBAAoB,gBAAgB;AACvC;AAYO,IAAM,yBAAA,GAA8F;AAAA,EACzG,WAAW,EAAC;AAAA,EACZ,MAAA,EAAQ,CAAC,CAAC,YAAA,EAAc,WAAW,CAAC,CAAA;AAAA,EACpC,QAAA,EAAU,CAAC,CAAC,YAAA,EAAc,WAAW,CAAC,CAAA;AAAA,EACtC,QAAA,EAAU,CAAC,CAAC,YAAA,EAAc,WAAW,CAAC;AACxC;AAGO,SAAS,uBAAuB,IAAA,EAAgC;AACrE,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,GAAG,mBAAmB,IAAI,CAAA,CAAE,IAAI,CAAC,CAAC,MAAM,CAAA,KAAM,MAAM,CAAA;AAAA,IACpD,GAAG,qBAAqB,IAAI,CAAA,CAAE,IAAI,CAAC,CAAC,MAAM,CAAA,KAAM,MAAM;AAAA,GACxD;AACF;AAGO,SAAS,mBAAmB,IAAA,EAAgE;AACjG,EAAA,OAAO,CAAC,GAAG,oBAAA,EAAsB,GAAG,yBAAA,CAA0B,IAAI,CAAC,CAAA;AACrE","file":"chunk-WNVQ3SMB.cjs","sourcesContent":["/**\n * Which DB columns of a saved entity land on its canvas node, per kind.\n *\n * Four surfaces copy an entity row onto a node: the browser's load-time\n * hydrator, the browser's library picker, the backend's run-time hydration, and\n * (indirectly) anything that reads a node expecting those fields to be there.\n * They used to be four hand-written lists, and they drifted exactly as you would\n * expect — the load-time hydrator covers `character` and nothing else, so an\n * object node bound by an agent stays media-less until someone rebinds it by\n * hand.\n *\n * This is the field NAMES only — the structural vocabulary. Merge behaviour\n * (defaults, `prev` fallbacks, type narrowing) stays with each caller, because\n * a browser node and a server row disagree about nulls and it is not worth\n * pretending otherwise.\n */\n\n/**\n * Every entity kind, in the order surfaces present them.\n *\n * The list is the invariant: `Record<EntityNodeKind, …>` makes the compiler\n * find every table below, every per-kind UI row in the `@` picker, and the\n * picker’s kind→query map. What the compiler cannot see — that the MCP read\n * tools for a kind exist and are reachable — is pinned by a test instead.\n *\n * Tool names are derivable from it too: `list_<kind>s` / `get_<kind>`.\n */\nexport const ENTITY_NODE_KINDS = [\"character\", \"object\", \"creature\", \"location\"] as const\n\nexport type EntityNodeKind = (typeof ENTITY_NODE_KINDS)[number]\n\n/** The `data.*DbId` field that binds each entity node to its row. */\nexport const ENTITY_DB_ID_FIELD: Record<EntityNodeKind, string> = {\n character: \"characterDbId\",\n object: \"objectDbId\",\n creature: \"creatureDbId\",\n location: \"locationDbId\",\n}\n\n/** The `data.*Name` field each kind stores its display name under. */\nexport const ENTITY_NAME_FIELD: Record<EntityNodeKind, string> = {\n character: \"characterName\",\n object: \"objectName\",\n creature: \"creatureName\",\n location: \"locationName\",\n}\n\n/** Postgres table per kind. */\nexport const ENTITY_TABLE: Record<EntityNodeKind, string> = {\n character: \"characters\",\n object: \"objects\",\n creature: \"creatures\",\n location: \"locations\",\n}\n\n/**\n * `{name,url}[]` buckets per kind, as `[db_column, nodeField]`.\n *\n * These are what a generation actually consumes — the variant a prompt\n * `@mentions`, the extra references a user attaches. A node missing them is not\n * visibly broken; it just quietly generates the wrong picture.\n */\nexport const ENTITY_BUCKET_FIELDS: Record<EntityNodeKind, ReadonlyArray<readonly [string, string]>> = {\n character: [\n [\"expressions\", \"expressions\"],\n [\"poses\", \"poses\"],\n [\"motions\", \"motions\"],\n [\"angles\", \"angles\"],\n [\"body_angles\", \"bodyAngles\"],\n [\"lighting_variations\", \"lightingVariations\"],\n [\"outfit_variations\", \"outfitVariations\"],\n [\"detail_closeups\", \"detailCloseups\"],\n [\"sheets\", \"sheets\"],\n ],\n object: [\n [\"angles\", \"angles\"],\n [\"materials\", \"materials\"],\n [\"variations\", \"variations\"],\n [\"motion_clips\", \"motionClips\"],\n [\"detail_closeups\", \"detailCloseups\"],\n [\"sheets\", \"sheets\"],\n ],\n creature: [\n [\"angles\", \"angles\"],\n [\"poses\", \"poses\"],\n [\"variations\", \"variations\"],\n [\"motion_clips\", \"motionClips\"],\n [\"detail_closeups\", \"detailCloseups\"],\n [\"sheets\", \"sheets\"],\n ],\n location: [\n [\"time_of_day\", \"timeOfDay\"],\n [\"weather\", \"weather\"],\n [\"angles\", \"angles\"],\n [\"lighting\", \"lighting\"],\n [\"seasons\", \"seasons\"],\n [\"atmosphere_motions\", \"atmosphereMotions\"],\n [\"detail_closeups\", \"detailCloseups\"],\n [\"sheets\", \"sheets\"],\n ],\n}\n\n/**\n * Scalars every kind shares, as `[db_column, nodeField]`.\n *\n * `source_image_url` is the load-bearing one: the run engine reads\n * `defaultAssetUrl || sourceImageUrl` and SKIPS the reference entirely when\n * both are empty — no error, no warning, just a generation of the wrong\n * person. A node with an id but no image is the shape an agent produces.\n */\nexport const ENTITY_SCALAR_FIELDS: ReadonlyArray<readonly [string, string]> = [\n [\"name\", \"__name\"], // routed to the kind's own name field by the caller\n [\"description\", \"description\"],\n [\"canonical_description\", \"canonicalDescription\"],\n [\"source_image_url\", \"sourceImageUrl\"],\n]\n\n/**\n * Scalars only SOME kinds have.\n *\n * `style_lock` looks shared and is not: characters never grew the column,\n * because a character's likeness is the lock. Selecting it from `characters`\n * anyway is a PostgREST error, which the run-time hydrator swallows by design\n * — so the whole kind would quietly stop hydrating and every test that mocks\n * the database would still pass. That is why the column lists are checked\n * against the migrations by `entity-hydration-columns.test.ts`.\n */\nexport const ENTITY_KIND_SCALAR_FIELDS: Record<EntityNodeKind, ReadonlyArray<readonly [string, string]>> = {\n character: [],\n object: [[\"style_lock\", \"styleLock\"]],\n creature: [[\"style_lock\", \"styleLock\"]],\n location: [[\"style_lock\", \"styleLock\"]],\n}\n\n/** Every DB column a full hydration of `kind` reads. */\nexport function entityHydrationColumns(kind: EntityNodeKind): string[] {\n return [\n \"id\",\n ...entityScalarFields(kind).map(([column]) => column),\n ...ENTITY_BUCKET_FIELDS[kind].map(([column]) => column),\n ]\n}\n\n/** Every scalar `kind` actually has, shared plus its own. */\nexport function entityScalarFields(kind: EntityNodeKind): ReadonlyArray<readonly [string, string]> {\n return [...ENTITY_SCALAR_FIELDS, ...ENTITY_KIND_SCALAR_FIELDS[kind]]\n}\n"]}
|