vidspotai-shared 1.0.82-dev.0 → 1.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (468) hide show
  1. package/lib/globals/aiModels/enums.d.ts +11 -1
  2. package/lib/globals/aiModels/enums.d.ts.map +1 -1
  3. package/lib/globals/aiModels/enums.js +24 -1
  4. package/lib/globals/aiModels/index.d.ts.map +1 -1
  5. package/lib/globals/aiModels/index.js +2 -0
  6. package/lib/globals/aiModels/providers/anthropic.d.ts +12 -0
  7. package/lib/globals/aiModels/providers/anthropic.d.ts.map +1 -0
  8. package/lib/globals/aiModels/providers/anthropic.js +88 -0
  9. package/lib/globals/aiModels/providers/google.d.ts.map +1 -1
  10. package/lib/globals/aiModels/providers/google.js +115 -10
  11. package/lib/globals/aiModels/providers/openai.d.ts.map +1 -1
  12. package/lib/globals/aiModels/providers/openai.js +63 -4
  13. package/lib/globals/aiModels/tierHelpers.d.ts +12 -0
  14. package/lib/globals/aiModels/tierHelpers.d.ts.map +1 -1
  15. package/lib/globals/aiModels/tierHelpers.js +83 -0
  16. package/lib/globals/aiModels/types.d.ts +19 -0
  17. package/lib/globals/aiModels/types.d.ts.map +1 -1
  18. package/lib/globals/types.d.ts +120 -1
  19. package/lib/globals/types.d.ts.map +1 -1
  20. package/lib/globals/types.js +135 -1
  21. package/lib/models/agent.model.d.ts +41 -1
  22. package/lib/models/agent.model.d.ts.map +1 -1
  23. package/lib/models/index.d.ts +1 -0
  24. package/lib/models/index.d.ts.map +1 -1
  25. package/lib/models/index.js +1 -0
  26. package/lib/models/social.model.d.ts +180 -0
  27. package/lib/models/social.model.d.ts.map +1 -0
  28. package/lib/models/social.model.js +2 -0
  29. package/lib/models/user.model.d.ts +10 -0
  30. package/lib/models/user.model.d.ts.map +1 -1
  31. package/lib/models/video.model.d.ts +6 -0
  32. package/lib/models/video.model.d.ts.map +1 -1
  33. package/lib/schemas/brief.schema.d.ts +46 -0
  34. package/lib/schemas/brief.schema.d.ts.map +1 -1
  35. package/lib/schemas/brief.schema.js +72 -1
  36. package/lib/schemas/index.d.ts +1 -0
  37. package/lib/schemas/index.d.ts.map +1 -1
  38. package/lib/schemas/index.js +1 -0
  39. package/lib/schemas/project.schema.d.ts +70 -3
  40. package/lib/schemas/project.schema.d.ts.map +1 -1
  41. package/lib/schemas/project.schema.js +12 -0
  42. package/lib/schemas/social.schema.d.ts +91 -0
  43. package/lib/schemas/social.schema.d.ts.map +1 -0
  44. package/lib/schemas/social.schema.js +114 -0
  45. package/lib/schemas/videoPlan.schema.d.ts +117 -3
  46. package/lib/schemas/videoPlan.schema.d.ts.map +1 -1
  47. package/lib/schemas/videoPlan.schema.js +141 -1
  48. package/lib/services/agent/chatAgent.d.ts +25 -1
  49. package/lib/services/agent/chatAgent.d.ts.map +1 -1
  50. package/lib/services/agent/chatAgent.js +145 -9
  51. package/lib/services/agent/costPreflight.d.ts +11 -1
  52. package/lib/services/agent/costPreflight.d.ts.map +1 -1
  53. package/lib/services/agent/costPreflight.js +18 -1
  54. package/lib/services/agent/covers/coverPlanner.d.ts +41 -0
  55. package/lib/services/agent/covers/coverPlanner.d.ts.map +1 -0
  56. package/lib/services/agent/covers/coverPlanner.js +278 -0
  57. package/lib/services/agent/covers/covers.schema.d.ts +158 -0
  58. package/lib/services/agent/covers/covers.schema.d.ts.map +1 -0
  59. package/lib/services/agent/covers/covers.schema.js +166 -0
  60. package/lib/services/agent/covers/index.d.ts +3 -0
  61. package/lib/services/agent/covers/index.d.ts.map +1 -0
  62. package/lib/services/agent/covers/index.js +18 -0
  63. package/lib/services/agent/critic.d.ts +10 -0
  64. package/lib/services/agent/critic.d.ts.map +1 -1
  65. package/lib/services/agent/critic.js +37 -1
  66. package/lib/services/agent/editClassifier.d.ts +4 -4
  67. package/lib/services/agent/editClassifier.js +2 -2
  68. package/lib/services/agent/editExisting/editAssembler.d.ts +78 -0
  69. package/lib/services/agent/editExisting/editAssembler.d.ts.map +1 -0
  70. package/lib/services/agent/editExisting/editAssembler.js +172 -0
  71. package/lib/services/agent/editExisting/editExisting.schema.d.ts +119 -0
  72. package/lib/services/agent/editExisting/editExisting.schema.d.ts.map +1 -0
  73. package/lib/services/agent/editExisting/editExisting.schema.js +157 -0
  74. package/lib/services/agent/editExisting/highlightPicker.d.ts +48 -0
  75. package/lib/services/agent/editExisting/highlightPicker.d.ts.map +1 -0
  76. package/lib/services/agent/editExisting/highlightPicker.js +199 -0
  77. package/lib/services/agent/editExisting/index.d.ts +4 -0
  78. package/lib/services/agent/editExisting/index.d.ts.map +1 -0
  79. package/lib/services/agent/editExisting/index.js +19 -0
  80. package/lib/services/agent/eval/recorder.d.ts +13 -1
  81. package/lib/services/agent/eval/recorder.d.ts.map +1 -1
  82. package/lib/services/agent/eval/recorder.js +59 -0
  83. package/lib/services/agent/eval/seedBriefs.d.ts +4 -3
  84. package/lib/services/agent/eval/seedBriefs.d.ts.map +1 -1
  85. package/lib/services/agent/eval/seedBriefs.js +283 -3
  86. package/lib/services/agent/eval/types.d.ts +10 -0
  87. package/lib/services/agent/eval/types.d.ts.map +1 -1
  88. package/lib/services/agent/executor/core.d.ts +70 -0
  89. package/lib/services/agent/executor/core.d.ts.map +1 -0
  90. package/lib/services/agent/executor/core.js +250 -0
  91. package/lib/services/agent/executor/duration.d.ts +20 -0
  92. package/lib/services/agent/executor/duration.d.ts.map +1 -0
  93. package/lib/services/agent/executor/duration.js +46 -0
  94. package/lib/services/agent/executor/index.d.ts +15 -0
  95. package/lib/services/agent/executor/index.d.ts.map +1 -0
  96. package/lib/services/agent/executor/index.js +32 -0
  97. package/lib/services/agent/executor/types.d.ts +183 -0
  98. package/lib/services/agent/executor/types.d.ts.map +1 -0
  99. package/lib/services/agent/executor/types.js +29 -0
  100. package/lib/services/agent/executor/visual.d.ts +32 -0
  101. package/lib/services/agent/executor/visual.d.ts.map +1 -0
  102. package/lib/services/agent/executor/visual.js +400 -0
  103. package/lib/services/agent/executor/voice.d.ts +17 -0
  104. package/lib/services/agent/executor/voice.d.ts.map +1 -0
  105. package/lib/services/agent/executor/voice.js +119 -0
  106. package/lib/services/agent/extendChain.d.ts +101 -0
  107. package/lib/services/agent/extendChain.d.ts.map +1 -0
  108. package/lib/services/agent/extendChain.js +177 -0
  109. package/lib/services/agent/index.d.ts +11 -1
  110. package/lib/services/agent/index.d.ts.map +1 -1
  111. package/lib/services/agent/index.js +11 -1
  112. package/lib/services/agent/llmCaller.d.ts +7 -8
  113. package/lib/services/agent/llmCaller.d.ts.map +1 -1
  114. package/lib/services/agent/llmCallerAnthropic.d.ts +44 -31
  115. package/lib/services/agent/llmCallerAnthropic.d.ts.map +1 -1
  116. package/lib/services/agent/llmCallerAnthropic.js +135 -60
  117. package/lib/services/agent/llmCallerFactory.d.ts +34 -0
  118. package/lib/services/agent/llmCallerFactory.d.ts.map +1 -0
  119. package/lib/services/agent/llmCallerFactory.js +31 -0
  120. package/lib/services/agent/llmCallerGemini.d.ts +62 -0
  121. package/lib/services/agent/llmCallerGemini.d.ts.map +1 -0
  122. package/lib/services/agent/llmCallerGemini.js +235 -0
  123. package/lib/services/agent/llmCallerOpenai.d.ts +56 -0
  124. package/lib/services/agent/llmCallerOpenai.d.ts.map +1 -0
  125. package/lib/services/agent/llmCallerOpenai.js +230 -0
  126. package/lib/services/agent/llmCallerRegistry.d.ts.map +1 -1
  127. package/lib/services/agent/llmCallerRegistry.js +7 -7
  128. package/lib/services/agent/llmCallerRouting.d.ts +63 -0
  129. package/lib/services/agent/llmCallerRouting.d.ts.map +1 -0
  130. package/lib/services/agent/llmCallerRouting.js +124 -0
  131. package/lib/services/agent/llmModelRegistry.d.ts +59 -0
  132. package/lib/services/agent/llmModelRegistry.d.ts.map +1 -0
  133. package/lib/services/agent/llmModelRegistry.js +168 -0
  134. package/lib/services/agent/llmRetry.d.ts +57 -0
  135. package/lib/services/agent/llmRetry.d.ts.map +1 -0
  136. package/lib/services/agent/llmRetry.js +102 -0
  137. package/lib/services/agent/modelRouter.d.ts +3 -3
  138. package/lib/services/agent/modelRouter.d.ts.map +1 -1
  139. package/lib/services/agent/modelRouter.js +27 -13
  140. package/lib/services/agent/planMutations.d.ts +54 -1
  141. package/lib/services/agent/planMutations.d.ts.map +1 -1
  142. package/lib/services/agent/planMutations.js +78 -0
  143. package/lib/services/agent/planner/Planner.d.ts +0 -17
  144. package/lib/services/agent/planner/Planner.d.ts.map +1 -1
  145. package/lib/services/agent/planner/Planner.js +67 -303
  146. package/lib/services/agent/planner/overlayRegen.d.ts +38 -0
  147. package/lib/services/agent/planner/overlayRegen.d.ts.map +1 -0
  148. package/lib/services/agent/planner/overlayRegen.js +145 -0
  149. package/lib/services/agent/planner/plannerMessages.d.ts +34 -0
  150. package/lib/services/agent/planner/plannerMessages.d.ts.map +1 -0
  151. package/lib/services/agent/planner/plannerMessages.js +185 -0
  152. package/lib/services/agent/planner/promptSections.d.ts +12 -0
  153. package/lib/services/agent/planner/promptSections.d.ts.map +1 -1
  154. package/lib/services/agent/planner/promptSections.js +57 -0
  155. package/lib/services/agent/planner/scriptFirstPlanner.d.ts +35 -0
  156. package/lib/services/agent/planner/scriptFirstPlanner.d.ts.map +1 -0
  157. package/lib/services/agent/planner/scriptFirstPlanner.js +140 -0
  158. package/lib/services/agent/planner/structuralRules.d.ts +10 -0
  159. package/lib/services/agent/planner/structuralRules.d.ts.map +1 -1
  160. package/lib/services/agent/planner/structuralRules.js +92 -9
  161. package/lib/services/agent/planner/validators.d.ts +18 -0
  162. package/lib/services/agent/planner/validators.d.ts.map +1 -1
  163. package/lib/services/agent/planner/validators.js +97 -0
  164. package/lib/services/agent/planner.d.ts +2 -1
  165. package/lib/services/agent/planner.d.ts.map +1 -1
  166. package/lib/services/agent/planner.js +5 -1
  167. package/lib/services/agent/priorProject.d.ts +26 -0
  168. package/lib/services/agent/priorProject.d.ts.map +1 -0
  169. package/lib/services/agent/priorProject.js +51 -0
  170. package/lib/services/agent/providerFallback/chains.d.ts.map +1 -1
  171. package/lib/services/agent/providerFallback/chains.js +27 -15
  172. package/lib/services/agent/repurpose/index.d.ts +3 -0
  173. package/lib/services/agent/repurpose/index.d.ts.map +1 -0
  174. package/lib/services/agent/repurpose/index.js +18 -0
  175. package/lib/services/agent/repurpose/repurpose.schema.d.ts +132 -0
  176. package/lib/services/agent/repurpose/repurpose.schema.d.ts.map +1 -0
  177. package/lib/services/agent/repurpose/repurpose.schema.js +144 -0
  178. package/lib/services/agent/repurpose/shortsPicker.d.ts +25 -0
  179. package/lib/services/agent/repurpose/shortsPicker.d.ts.map +1 -0
  180. package/lib/services/agent/repurpose/shortsPicker.js +218 -0
  181. package/lib/services/agent/runHelpers.d.ts +21 -2
  182. package/lib/services/agent/runHelpers.d.ts.map +1 -1
  183. package/lib/services/agent/runHelpers.js +71 -2
  184. package/lib/services/agent/tools/animateImage.tool.d.ts +1 -0
  185. package/lib/services/agent/tools/animateImage.tool.d.ts.map +1 -1
  186. package/lib/services/agent/tools/animateImage.tool.js +12 -0
  187. package/lib/services/agent/tools/chapterOutline.tool.d.ts +42 -0
  188. package/lib/services/agent/tools/chapterOutline.tool.d.ts.map +1 -0
  189. package/lib/services/agent/tools/chapterOutline.tool.js +115 -0
  190. package/lib/services/agent/tools/composeScene.tool.d.ts +65 -2
  191. package/lib/services/agent/tools/composeScene.tool.d.ts.map +1 -1
  192. package/lib/services/agent/tools/estimateCost.tool.d.ts +28 -1
  193. package/lib/services/agent/tools/estimateCost.tool.d.ts.map +1 -1
  194. package/lib/services/agent/tools/estimateCost.tool.js +55 -7
  195. package/lib/services/agent/tools/extendVideo.tool.d.ts +26 -0
  196. package/lib/services/agent/tools/extendVideo.tool.d.ts.map +1 -0
  197. package/lib/services/agent/tools/extendVideo.tool.js +149 -0
  198. package/lib/services/agent/tools/generateScript.tool.d.ts +184 -0
  199. package/lib/services/agent/tools/generateScript.tool.d.ts.map +1 -0
  200. package/lib/services/agent/tools/generateScript.tool.js +123 -0
  201. package/lib/services/agent/tools/generateVideo.tool.d.ts +1 -0
  202. package/lib/services/agent/tools/generateVideo.tool.d.ts.map +1 -1
  203. package/lib/services/agent/tools/generateVideo.tool.js +20 -1
  204. package/lib/services/agent/tools/index.d.ts +4 -0
  205. package/lib/services/agent/tools/index.d.ts.map +1 -1
  206. package/lib/services/agent/tools/index.js +4 -0
  207. package/lib/services/agent/tools/matchBrollToScript.tool.d.ts +50 -0
  208. package/lib/services/agent/tools/matchBrollToScript.tool.d.ts.map +1 -0
  209. package/lib/services/agent/tools/matchBrollToScript.tool.js +139 -0
  210. package/lib/services/agent/tools/planVideo.tool.d.ts +57 -1
  211. package/lib/services/agent/tools/planVideo.tool.d.ts.map +1 -1
  212. package/lib/services/agent/tools/planVideo.tool.js +3 -3
  213. package/lib/services/agent/tools/render.tool.d.ts +22 -1
  214. package/lib/services/agent/tools/render.tool.d.ts.map +1 -1
  215. package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
  216. package/lib/services/aiGen/aiGenFactory.service.js +18 -3
  217. package/lib/services/aiGen/helpers.d.ts +8 -0
  218. package/lib/services/aiGen/helpers.d.ts.map +1 -1
  219. package/lib/services/aiGen/helpers.js +12 -0
  220. package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts +26 -0
  221. package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts.map +1 -0
  222. package/lib/services/aiGen/providers/anthropic/anthropic.service.js +95 -0
  223. package/lib/services/aiGen/providers/google/google.service.d.ts +25 -1
  224. package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
  225. package/lib/services/aiGen/providers/google/google.service.js +136 -237
  226. package/lib/services/aiGen/providers/google/googleApiKeys.d.ts +71 -0
  227. package/lib/services/aiGen/providers/google/googleApiKeys.d.ts.map +1 -0
  228. package/lib/services/aiGen/providers/google/googleApiKeys.js +137 -0
  229. package/lib/services/aiGen/providers/google/googleErrors.d.ts +13 -0
  230. package/lib/services/aiGen/providers/google/googleErrors.d.ts.map +1 -0
  231. package/lib/services/aiGen/providers/google/googleErrors.js +102 -0
  232. package/lib/services/aiGen/providers/google/googleFetch.d.ts +8 -0
  233. package/lib/services/aiGen/providers/google/googleFetch.d.ts.map +1 -0
  234. package/lib/services/aiGen/providers/google/googleFetch.js +96 -0
  235. package/lib/services/aiGen/providers/google/googleKeyPool.d.ts +52 -0
  236. package/lib/services/aiGen/providers/google/googleKeyPool.d.ts.map +1 -0
  237. package/lib/services/aiGen/providers/google/googleKeyPool.js +129 -0
  238. package/lib/services/aiGen/providers/google/googleMusic.d.ts +15 -0
  239. package/lib/services/aiGen/providers/google/googleMusic.d.ts.map +1 -0
  240. package/lib/services/aiGen/providers/google/googleMusic.js +77 -0
  241. package/lib/services/aiGen/providers/kling/kling.service.d.ts +7 -3
  242. package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
  243. package/lib/services/aiGen/providers/kling/kling.service.js +23 -367
  244. package/lib/services/aiGen/providers/kling/klingCredits.d.ts +9 -0
  245. package/lib/services/aiGen/providers/kling/klingCredits.d.ts.map +1 -0
  246. package/lib/services/aiGen/providers/kling/klingCredits.js +63 -0
  247. package/lib/services/aiGen/providers/kling/klingRequests.d.ts +32 -0
  248. package/lib/services/aiGen/providers/kling/klingRequests.d.ts.map +1 -0
  249. package/lib/services/aiGen/providers/kling/klingRequests.js +194 -0
  250. package/lib/services/aiGen/providers/kling/klingStatus.d.ts +16 -0
  251. package/lib/services/aiGen/providers/kling/klingStatus.d.ts.map +1 -0
  252. package/lib/services/aiGen/providers/kling/klingStatus.js +173 -0
  253. package/lib/services/aiGen/providers/pixverse/pixverse.service.d.ts.map +1 -1
  254. package/lib/services/aiGen/providers/pixverse/pixverse.service.js +7 -1
  255. package/lib/services/bullmq.service.d.ts +61 -0
  256. package/lib/services/bullmq.service.d.ts.map +1 -1
  257. package/lib/services/bullmq.service.js +124 -2
  258. package/lib/services/crypto/index.d.ts +2 -0
  259. package/lib/services/crypto/index.d.ts.map +1 -0
  260. package/lib/services/crypto/index.js +17 -0
  261. package/lib/services/crypto/tokenVault.d.ts +47 -0
  262. package/lib/services/crypto/tokenVault.d.ts.map +1 -0
  263. package/lib/services/crypto/tokenVault.js +179 -0
  264. package/lib/services/editor/captionStyleHint.d.ts +3 -0
  265. package/lib/services/editor/captionStyleHint.d.ts.map +1 -0
  266. package/lib/services/editor/captionStyleHint.js +112 -0
  267. package/lib/services/editor/planToProject.d.ts +7 -66
  268. package/lib/services/editor/planToProject.d.ts.map +1 -1
  269. package/lib/services/editor/planToProject.helpers.d.ts +40 -0
  270. package/lib/services/editor/planToProject.helpers.d.ts.map +1 -0
  271. package/lib/services/editor/planToProject.helpers.js +177 -0
  272. package/lib/services/editor/planToProject.js +197 -180
  273. package/lib/services/editor/planToProject.types.d.ts +94 -0
  274. package/lib/services/editor/planToProject.types.d.ts.map +1 -0
  275. package/lib/services/editor/planToProject.types.js +2 -0
  276. package/lib/services/firestore.service.d.ts +5 -0
  277. package/lib/services/firestore.service.d.ts.map +1 -1
  278. package/lib/services/firestore.service.js +13 -0
  279. package/lib/services/index.d.ts +13 -0
  280. package/lib/services/index.d.ts.map +1 -1
  281. package/lib/services/index.js +13 -0
  282. package/lib/services/promptEnhancer/index.d.ts +18 -0
  283. package/lib/services/promptEnhancer/index.d.ts.map +1 -0
  284. package/lib/services/promptEnhancer/index.js +33 -0
  285. package/lib/services/promptEnhancer/models.d.ts +54 -0
  286. package/lib/services/promptEnhancer/models.d.ts.map +1 -0
  287. package/lib/services/promptEnhancer/models.js +37 -0
  288. package/lib/services/promptEnhancer/profiles/agent.profile.d.ts +14 -0
  289. package/lib/services/promptEnhancer/profiles/agent.profile.d.ts.map +1 -0
  290. package/lib/services/promptEnhancer/profiles/agent.profile.js +40 -0
  291. package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts +13 -0
  292. package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts.map +1 -0
  293. package/lib/services/promptEnhancer/profiles/avatar.profile.js +40 -0
  294. package/lib/services/promptEnhancer/profiles/base.d.ts +28 -0
  295. package/lib/services/promptEnhancer/profiles/base.d.ts.map +1 -0
  296. package/lib/services/promptEnhancer/profiles/base.js +35 -0
  297. package/lib/services/promptEnhancer/profiles/image.profile.d.ts +11 -0
  298. package/lib/services/promptEnhancer/profiles/image.profile.d.ts.map +1 -0
  299. package/lib/services/promptEnhancer/profiles/image.profile.js +42 -0
  300. package/lib/services/promptEnhancer/profiles/index.d.ts +12 -0
  301. package/lib/services/promptEnhancer/profiles/index.d.ts.map +1 -0
  302. package/lib/services/promptEnhancer/profiles/index.js +33 -0
  303. package/lib/services/promptEnhancer/profiles/video.profile.d.ts +15 -0
  304. package/lib/services/promptEnhancer/profiles/video.profile.d.ts.map +1 -0
  305. package/lib/services/promptEnhancer/profiles/video.profile.js +81 -0
  306. package/lib/services/promptEnhancer/promptEnhancer.service.d.ts +45 -0
  307. package/lib/services/promptEnhancer/promptEnhancer.service.d.ts.map +1 -0
  308. package/lib/services/promptEnhancer/promptEnhancer.service.js +157 -0
  309. package/lib/services/promptEnhancer/schema.d.ts +19 -0
  310. package/lib/services/promptEnhancer/schema.d.ts.map +1 -0
  311. package/lib/services/promptEnhancer/schema.js +43 -0
  312. package/lib/services/promptEnhancer/types.d.ts +112 -0
  313. package/lib/services/promptEnhancer/types.d.ts.map +1 -0
  314. package/lib/services/promptEnhancer/types.js +2 -0
  315. package/lib/services/rateLimiter/distributedRateLimiter.service.d.ts +60 -5
  316. package/lib/services/rateLimiter/distributedRateLimiter.service.d.ts.map +1 -1
  317. package/lib/services/rateLimiter/distributedRateLimiter.service.js +184 -16
  318. package/lib/services/socialAI/captionGen.d.ts +81 -0
  319. package/lib/services/socialAI/captionGen.d.ts.map +1 -0
  320. package/lib/services/socialAI/captionGen.js +206 -0
  321. package/lib/services/socialAI/hookScore.d.ts +85 -0
  322. package/lib/services/socialAI/hookScore.d.ts.map +1 -0
  323. package/lib/services/socialAI/hookScore.js +170 -0
  324. package/lib/services/socialAI/index.d.ts +3 -0
  325. package/lib/services/socialAI/index.d.ts.map +1 -0
  326. package/lib/services/socialAI/index.js +18 -0
  327. package/lib/services/socialAccounts/index.d.ts +2 -0
  328. package/lib/services/socialAccounts/index.d.ts.map +1 -0
  329. package/lib/services/socialAccounts/index.js +17 -0
  330. package/lib/services/socialAccounts/socialAccountService.d.ts +25 -0
  331. package/lib/services/socialAccounts/socialAccountService.d.ts.map +1 -0
  332. package/lib/services/socialAccounts/socialAccountService.js +105 -0
  333. package/lib/services/socialEngage/factory.d.ts +7 -0
  334. package/lib/services/socialEngage/factory.d.ts.map +1 -0
  335. package/lib/services/socialEngage/factory.js +25 -0
  336. package/lib/services/socialEngage/index.d.ts +6 -0
  337. package/lib/services/socialEngage/index.d.ts.map +1 -0
  338. package/lib/services/socialEngage/index.js +21 -0
  339. package/lib/services/socialEngage/meta.engage.d.ts +17 -0
  340. package/lib/services/socialEngage/meta.engage.d.ts.map +1 -0
  341. package/lib/services/socialEngage/meta.engage.js +128 -0
  342. package/lib/services/socialEngage/metaWebhook.d.ts +50 -0
  343. package/lib/services/socialEngage/metaWebhook.d.ts.map +1 -0
  344. package/lib/services/socialEngage/metaWebhook.js +93 -0
  345. package/lib/services/socialEngage/types.d.ts +72 -0
  346. package/lib/services/socialEngage/types.d.ts.map +1 -0
  347. package/lib/services/socialEngage/types.js +10 -0
  348. package/lib/services/socialEngage/youtube.engage.d.ts +9 -0
  349. package/lib/services/socialEngage/youtube.engage.d.ts.map +1 -0
  350. package/lib/services/socialEngage/youtube.engage.js +87 -0
  351. package/lib/services/socialFormat/aspectGeometry.d.ts +74 -0
  352. package/lib/services/socialFormat/aspectGeometry.d.ts.map +1 -0
  353. package/lib/services/socialFormat/aspectGeometry.js +135 -0
  354. package/lib/services/socialFormat/index.d.ts +2 -0
  355. package/lib/services/socialFormat/index.d.ts.map +1 -0
  356. package/lib/services/socialFormat/index.js +19 -0
  357. package/lib/services/socialInsights/index.d.ts +3 -0
  358. package/lib/services/socialInsights/index.d.ts.map +1 -0
  359. package/lib/services/socialInsights/index.js +18 -0
  360. package/lib/services/socialInsights/recommendations.d.ts +131 -0
  361. package/lib/services/socialInsights/recommendations.d.ts.map +1 -0
  362. package/lib/services/socialInsights/recommendations.js +277 -0
  363. package/lib/services/socialInsights/timeBuckets.d.ts +35 -0
  364. package/lib/services/socialInsights/timeBuckets.d.ts.map +1 -0
  365. package/lib/services/socialInsights/timeBuckets.js +78 -0
  366. package/lib/services/socialMetrics/factory.d.ts +5 -0
  367. package/lib/services/socialMetrics/factory.d.ts.map +1 -0
  368. package/lib/services/socialMetrics/factory.js +24 -0
  369. package/lib/services/socialMetrics/index.d.ts +6 -0
  370. package/lib/services/socialMetrics/index.d.ts.map +1 -0
  371. package/lib/services/socialMetrics/index.js +21 -0
  372. package/lib/services/socialMetrics/meta.metrics.d.ts +22 -0
  373. package/lib/services/socialMetrics/meta.metrics.d.ts.map +1 -0
  374. package/lib/services/socialMetrics/meta.metrics.js +137 -0
  375. package/lib/services/socialMetrics/tiktok.metrics.d.ts +8 -0
  376. package/lib/services/socialMetrics/tiktok.metrics.d.ts.map +1 -0
  377. package/lib/services/socialMetrics/tiktok.metrics.js +43 -0
  378. package/lib/services/socialMetrics/types.d.ts +54 -0
  379. package/lib/services/socialMetrics/types.d.ts.map +1 -0
  380. package/lib/services/socialMetrics/types.js +2 -0
  381. package/lib/services/socialMetrics/youtube.metrics.d.ts +8 -0
  382. package/lib/services/socialMetrics/youtube.metrics.d.ts.map +1 -0
  383. package/lib/services/socialMetrics/youtube.metrics.js +43 -0
  384. package/lib/services/socialOAuth/factory.d.ts +7 -0
  385. package/lib/services/socialOAuth/factory.d.ts.map +1 -0
  386. package/lib/services/socialOAuth/factory.js +42 -0
  387. package/lib/services/socialOAuth/index.d.ts +11 -0
  388. package/lib/services/socialOAuth/index.d.ts.map +1 -0
  389. package/lib/services/socialOAuth/index.js +26 -0
  390. package/lib/services/socialOAuth/linkedin.oauth.d.ts +14 -0
  391. package/lib/services/socialOAuth/linkedin.oauth.d.ts.map +1 -0
  392. package/lib/services/socialOAuth/linkedin.oauth.js +127 -0
  393. package/lib/services/socialOAuth/meta.oauth.d.ts +31 -0
  394. package/lib/services/socialOAuth/meta.oauth.d.ts.map +1 -0
  395. package/lib/services/socialOAuth/meta.oauth.js +214 -0
  396. package/lib/services/socialOAuth/oauthState.d.ts +14 -0
  397. package/lib/services/socialOAuth/oauthState.d.ts.map +1 -0
  398. package/lib/services/socialOAuth/oauthState.js +66 -0
  399. package/lib/services/socialOAuth/pinterest.oauth.d.ts +15 -0
  400. package/lib/services/socialOAuth/pinterest.oauth.d.ts.map +1 -0
  401. package/lib/services/socialOAuth/pinterest.oauth.js +126 -0
  402. package/lib/services/socialOAuth/threads.oauth.d.ts +14 -0
  403. package/lib/services/socialOAuth/threads.oauth.d.ts.map +1 -0
  404. package/lib/services/socialOAuth/threads.oauth.js +129 -0
  405. package/lib/services/socialOAuth/tiktok.oauth.d.ts +15 -0
  406. package/lib/services/socialOAuth/tiktok.oauth.d.ts.map +1 -0
  407. package/lib/services/socialOAuth/tiktok.oauth.js +151 -0
  408. package/lib/services/socialOAuth/types.d.ts +67 -0
  409. package/lib/services/socialOAuth/types.d.ts.map +1 -0
  410. package/lib/services/socialOAuth/types.js +2 -0
  411. package/lib/services/socialOAuth/x.oauth.d.ts +17 -0
  412. package/lib/services/socialOAuth/x.oauth.d.ts.map +1 -0
  413. package/lib/services/socialOAuth/x.oauth.js +134 -0
  414. package/lib/services/socialOAuth/youtube.oauth.d.ts +15 -0
  415. package/lib/services/socialOAuth/youtube.oauth.d.ts.map +1 -0
  416. package/lib/services/socialOAuth/youtube.oauth.js +156 -0
  417. package/lib/services/socialPublish/factory.d.ts +5 -0
  418. package/lib/services/socialPublish/factory.d.ts.map +1 -0
  419. package/lib/services/socialPublish/factory.js +32 -0
  420. package/lib/services/socialPublish/index.d.ts +10 -0
  421. package/lib/services/socialPublish/index.d.ts.map +1 -0
  422. package/lib/services/socialPublish/index.js +25 -0
  423. package/lib/services/socialPublish/linkedin.publish.d.ts +9 -0
  424. package/lib/services/socialPublish/linkedin.publish.d.ts.map +1 -0
  425. package/lib/services/socialPublish/linkedin.publish.js +143 -0
  426. package/lib/services/socialPublish/meta.publish.d.ts +28 -0
  427. package/lib/services/socialPublish/meta.publish.d.ts.map +1 -0
  428. package/lib/services/socialPublish/meta.publish.js +149 -0
  429. package/lib/services/socialPublish/pinterest.publish.d.ts +13 -0
  430. package/lib/services/socialPublish/pinterest.publish.d.ts.map +1 -0
  431. package/lib/services/socialPublish/pinterest.publish.js +130 -0
  432. package/lib/services/socialPublish/threads.publish.d.ts +12 -0
  433. package/lib/services/socialPublish/threads.publish.d.ts.map +1 -0
  434. package/lib/services/socialPublish/threads.publish.js +96 -0
  435. package/lib/services/socialPublish/tiktok.publish.d.ts +13 -0
  436. package/lib/services/socialPublish/tiktok.publish.d.ts.map +1 -0
  437. package/lib/services/socialPublish/tiktok.publish.js +118 -0
  438. package/lib/services/socialPublish/types.d.ts +47 -0
  439. package/lib/services/socialPublish/types.d.ts.map +1 -0
  440. package/lib/services/socialPublish/types.js +2 -0
  441. package/lib/services/socialPublish/x.publish.d.ts +12 -0
  442. package/lib/services/socialPublish/x.publish.d.ts.map +1 -0
  443. package/lib/services/socialPublish/x.publish.js +147 -0
  444. package/lib/services/socialPublish/youtube.publish.d.ts +9 -0
  445. package/lib/services/socialPublish/youtube.publish.d.ts.map +1 -0
  446. package/lib/services/socialPublish/youtube.publish.js +107 -0
  447. package/lib/services/stock/index.d.ts +2 -0
  448. package/lib/services/stock/index.d.ts.map +1 -0
  449. package/lib/services/stock/index.js +17 -0
  450. package/lib/services/stock/realPersonSafety.d.ts +99 -0
  451. package/lib/services/stock/realPersonSafety.d.ts.map +1 -0
  452. package/lib/services/stock/realPersonSafety.js +248 -0
  453. package/lib/services/translation/index.d.ts +2 -0
  454. package/lib/services/translation/index.d.ts.map +1 -0
  455. package/lib/services/translation/index.js +9 -0
  456. package/lib/services/translation/translation.service.d.ts +50 -0
  457. package/lib/services/translation/translation.service.d.ts.map +1 -0
  458. package/lib/services/translation/translation.service.js +211 -0
  459. package/lib/utils/helpers.d.ts +2 -4
  460. package/lib/utils/helpers.d.ts.map +1 -1
  461. package/lib/utils/helpers.js +9 -63
  462. package/lib/utils/index.d.ts +1 -0
  463. package/lib/utils/index.d.ts.map +1 -1
  464. package/lib/utils/index.js +1 -0
  465. package/lib/utils/renderTier.d.ts +26 -0
  466. package/lib/utils/renderTier.d.ts.map +1 -0
  467. package/lib/utils/renderTier.js +34 -0
  468. package/package.json +1 -1
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LinkedInPublisher = void 0;
4
+ const types_1 = require("../../globals/types");
5
+ const logger_1 = require("../../utils/logger");
6
+ /**
7
+ * LinkedIn publisher — Phase 6. Member-feed video via the versioned Videos +
8
+ * Posts REST API:
9
+ * 1. POST /rest/videos?action=initializeUpload → video URN + upload URL(s)
10
+ * 2. PUT the bytes to each upload URL → collect ETags
11
+ * 3. POST /rest/videos?action=finalizeUpload (uploadedPartIds = ETags)
12
+ * 4. POST /rest/posts (author, commentary, content.media = video URN)
13
+ *
14
+ * Author = urn:li:person:{providerAccountId}. Company-page posting (author =
15
+ * urn:li:organization:{id}) is a business-tier follow-on. No native scheduling.
16
+ *
17
+ * Config (env): LINKEDIN_API_VERSION (optional, default "202401").
18
+ */
19
+ const REST_BASE = "https://api.linkedin.com/rest";
20
+ function apiVersion() {
21
+ return process.env.LINKEDIN_API_VERSION || "202401";
22
+ }
23
+ function headers(token) {
24
+ return {
25
+ Authorization: `Bearer ${token}`,
26
+ "Content-Type": "application/json",
27
+ "LinkedIn-Version": apiVersion(),
28
+ "X-Restli-Protocol-Version": "2.0.0",
29
+ };
30
+ }
31
+ class LinkedInPublisher {
32
+ constructor() {
33
+ this.provider = types_1.ESocialProvider.LINKEDIN;
34
+ }
35
+ async publish(input) {
36
+ const memberId = input.providerAccountId;
37
+ if (!memberId) {
38
+ throw new Error("LinkedInPublisher: missing providerAccountId (member id)");
39
+ }
40
+ const author = `urn:li:person:${memberId}`;
41
+ const token = input.accessToken;
42
+ // 0. Fetch the media bytes (worker passes a public/rendered URL).
43
+ const mediaResp = await fetch(input.mediaUrl);
44
+ if (!mediaResp.ok) {
45
+ throw new Error(`LinkedInPublisher: media fetch ${mediaResp.status}`);
46
+ }
47
+ const bytes = Buffer.from(await mediaResp.arrayBuffer());
48
+ // 1. Initialize the upload.
49
+ const initResp = await fetch(`${REST_BASE}/videos?action=initializeUpload`, {
50
+ method: "POST",
51
+ headers: headers(token),
52
+ body: JSON.stringify({
53
+ initializeUploadRequest: {
54
+ owner: author,
55
+ fileSizeBytes: bytes.length,
56
+ uploadCaptions: false,
57
+ uploadThumbnail: false,
58
+ },
59
+ }),
60
+ });
61
+ const init = (await initResp.json());
62
+ const videoUrn = init.value?.video;
63
+ const instructions = init.value?.uploadInstructions ?? [];
64
+ if (!initResp.ok || !videoUrn || instructions.length === 0) {
65
+ throw new Error(`LinkedInPublisher: initializeUpload ${initResp.status} ${init.error?.message ?? ""}`.trim());
66
+ }
67
+ // 2. Upload each byte range; collect ETags in order.
68
+ const uploadedPartIds = [];
69
+ for (const instr of instructions) {
70
+ if (!instr.uploadUrl)
71
+ continue;
72
+ const first = instr.firstByte ?? 0;
73
+ const last = instr.lastByte ?? bytes.length - 1;
74
+ const chunk = bytes.subarray(first, last + 1);
75
+ const putResp = await fetch(instr.uploadUrl, {
76
+ method: "PUT",
77
+ headers: { Authorization: `Bearer ${token}` },
78
+ body: chunk,
79
+ });
80
+ if (!putResp.ok) {
81
+ throw new Error(`LinkedInPublisher: chunk upload ${putResp.status}`);
82
+ }
83
+ const etag = putResp.headers.get("etag");
84
+ if (etag)
85
+ uploadedPartIds.push(etag.replace(/"/g, ""));
86
+ }
87
+ // 3. Finalize the upload.
88
+ const finalizeResp = await fetch(`${REST_BASE}/videos?action=finalizeUpload`, {
89
+ method: "POST",
90
+ headers: headers(token),
91
+ body: JSON.stringify({
92
+ finalizeUploadRequest: { video: videoUrn, uploadToken: "", uploadedPartIds },
93
+ }),
94
+ });
95
+ if (!finalizeResp.ok) {
96
+ const text = await finalizeResp.text();
97
+ throw new Error(`LinkedInPublisher: finalizeUpload ${finalizeResp.status} ${text}`);
98
+ }
99
+ // 4. Create the post referencing the video URN.
100
+ const postResp = await fetch(`${REST_BASE}/posts`, {
101
+ method: "POST",
102
+ headers: headers(token),
103
+ body: JSON.stringify({
104
+ author,
105
+ commentary: this.buildCommentary(input),
106
+ visibility: this.resolveVisibility(input),
107
+ distribution: {
108
+ feedDistribution: "MAIN_FEED",
109
+ targetEntities: [],
110
+ thirdPartyDistributionChannels: [],
111
+ },
112
+ content: { media: { id: videoUrn, title: (input.title ?? "").slice(0, 200) } },
113
+ lifecycleState: "PUBLISHED",
114
+ isReshareDisabledByAuthor: false,
115
+ }),
116
+ });
117
+ if (!postResp.ok) {
118
+ const text = await postResp.text();
119
+ throw new Error(`LinkedInPublisher: create post ${postResp.status} ${text}`);
120
+ }
121
+ // The new post URN is returned in the x-restli-id (or x-linkedin-id) header.
122
+ const postUrn = postResp.headers.get("x-restli-id") ??
123
+ postResp.headers.get("x-linkedin-id") ??
124
+ videoUrn;
125
+ logger_1.logger.info("LinkedInPublisher: published", { postUrn });
126
+ return {
127
+ providerPostId: postUrn,
128
+ publishedUrl: `https://www.linkedin.com/feed/update/${postUrn}`,
129
+ };
130
+ }
131
+ resolveVisibility(input) {
132
+ const p = (input.privacy ?? "public").toUpperCase();
133
+ return p === "CONNECTIONS" ? "CONNECTIONS" : "PUBLIC";
134
+ }
135
+ buildCommentary(input) {
136
+ const tags = input.hashtags && input.hashtags.length
137
+ ? "\n\n" +
138
+ input.hashtags.map((h) => (h.startsWith("#") ? h : `#${h}`)).join(" ")
139
+ : "";
140
+ return `${input.caption ?? ""}${tags}`.trim().slice(0, 3000);
141
+ }
142
+ }
143
+ exports.LinkedInPublisher = LinkedInPublisher;
@@ -0,0 +1,28 @@
1
+ import { ESocialProvider } from "../../globals/types";
2
+ import { ISocialPublisher, PublishInput, PublishResult } from "./types";
3
+ /**
4
+ * Instagram publisher — Reels via the two-step container flow:
5
+ * 1. POST /{ig-user-id}/media (media_type=REELS, video_url, caption) → container
6
+ * 2. Poll /{container-id}?fields=status_code until FINISHED
7
+ * 3. POST /{ig-user-id}/media_publish (creation_id) → media id
8
+ * IG has no native API scheduling — the worker schedules via BullMQ delay, so we
9
+ * always publish immediately here.
10
+ */
11
+ export declare class InstagramPublisher implements ISocialPublisher {
12
+ readonly provider = ESocialProvider.INSTAGRAM;
13
+ private readonly maxPolls;
14
+ private readonly pollDelayMs;
15
+ publish(input: PublishInput): Promise<PublishResult>;
16
+ private waitForContainer;
17
+ private resolvePermalink;
18
+ }
19
+ /**
20
+ * Facebook Page publisher — posts a video to the Page via /{page-id}/videos with
21
+ * a hosted `file_url` (Graph downloads it). Supports native scheduling through
22
+ * `published=false` + `scheduled_publish_time` (unix seconds, 10m–6mo out).
23
+ */
24
+ export declare class FacebookPublisher implements ISocialPublisher {
25
+ readonly provider = ESocialProvider.FACEBOOK;
26
+ publish(input: PublishInput): Promise<PublishResult>;
27
+ }
28
+ //# sourceMappingURL=meta.publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.publish.d.ts","sourceRoot":"","sources":["../../../src/services/socialPublish/meta.publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA+DxE;;;;;;;GAOG;AACH,qBAAa,kBAAmB,YAAW,gBAAgB;IACzD,QAAQ,CAAC,QAAQ,6BAA6B;IAE9C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAM;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IAE9B,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;YAsC5C,gBAAgB;YAyBhB,gBAAgB;CAgB/B;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,gBAAgB;IACxD,QAAQ,CAAC,QAAQ,4BAA4B;IAEvC,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;CAmC3D"}
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FacebookPublisher = exports.InstagramPublisher = void 0;
4
+ const types_1 = require("../../globals/types");
5
+ const logger_1 = require("../../utils/logger");
6
+ /**
7
+ * Meta publishers — Phase 3. Instagram and Facebook both run on the Graph API
8
+ * but with different publish flows, so they are separate ISocialPublisher impls
9
+ * (registered under INSTAGRAM / FACEBOOK).
10
+ *
11
+ * Both take the managing Page access token (provided by MetaOAuthProvider) and
12
+ * the account's providerAccountId (IG user id / FB Page id) via PublishInput.
13
+ *
14
+ * Config (env): META_GRAPH_VERSION (optional, default v21.0).
15
+ */
16
+ const DEFAULT_GRAPH_VERSION = "v21.0";
17
+ function graphVersion() {
18
+ return process.env.META_GRAPH_VERSION || DEFAULT_GRAPH_VERSION;
19
+ }
20
+ function graph(path) {
21
+ return `https://graph.facebook.com/${graphVersion()}${path}`;
22
+ }
23
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
24
+ function buildCaption(input) {
25
+ const tags = input.hashtags && input.hashtags.length
26
+ ? "\n\n" +
27
+ input.hashtags.map((h) => (h.startsWith("#") ? h : `#${h}`)).join(" ")
28
+ : "";
29
+ return `${input.caption ?? ""}${tags}`.trim();
30
+ }
31
+ async function postForm(url, form) {
32
+ const resp = await fetch(url, {
33
+ method: "POST",
34
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
35
+ body: form.toString(),
36
+ });
37
+ const json = (await resp.json());
38
+ if (!resp.ok || json.error || !json.id) {
39
+ throw new Error(`Meta graph POST ${resp.status} ${json.error?.message ?? "no id returned"}`);
40
+ }
41
+ return json;
42
+ }
43
+ /**
44
+ * Instagram publisher — Reels via the two-step container flow:
45
+ * 1. POST /{ig-user-id}/media (media_type=REELS, video_url, caption) → container
46
+ * 2. Poll /{container-id}?fields=status_code until FINISHED
47
+ * 3. POST /{ig-user-id}/media_publish (creation_id) → media id
48
+ * IG has no native API scheduling — the worker schedules via BullMQ delay, so we
49
+ * always publish immediately here.
50
+ */
51
+ class InstagramPublisher {
52
+ constructor() {
53
+ this.provider = types_1.ESocialProvider.INSTAGRAM;
54
+ this.maxPolls = 30;
55
+ this.pollDelayMs = 5000;
56
+ }
57
+ async publish(input) {
58
+ const igUserId = input.providerAccountId;
59
+ if (!igUserId) {
60
+ throw new Error("InstagramPublisher: missing providerAccountId (IG user id)");
61
+ }
62
+ // 1. Create the media container.
63
+ const container = await postForm(graph(`/${igUserId}/media`), new URLSearchParams({
64
+ media_type: "REELS",
65
+ video_url: input.mediaUrl,
66
+ caption: buildCaption(input),
67
+ access_token: input.accessToken,
68
+ }));
69
+ const creationId = container.id;
70
+ // 2. Poll until the upload/transcode finishes.
71
+ await this.waitForContainer(creationId, input.accessToken);
72
+ // 3. Publish the container.
73
+ const published = await postForm(graph(`/${igUserId}/media_publish`), new URLSearchParams({
74
+ creation_id: creationId,
75
+ access_token: input.accessToken,
76
+ }));
77
+ const mediaId = published.id;
78
+ logger_1.logger.info("InstagramPublisher: published", { igUserId, mediaId });
79
+ return {
80
+ providerPostId: mediaId,
81
+ publishedUrl: await this.resolvePermalink(mediaId, input.accessToken),
82
+ };
83
+ }
84
+ async waitForContainer(containerId, accessToken) {
85
+ for (let i = 0; i < this.maxPolls; i++) {
86
+ const resp = await fetch(graph(`/${containerId}?fields=status_code,status&access_token=${encodeURIComponent(accessToken)}`));
87
+ const json = (await resp.json());
88
+ const code = json.status_code;
89
+ if (code === "FINISHED")
90
+ return;
91
+ if (code === "ERROR" || code === "EXPIRED") {
92
+ throw new Error(`InstagramPublisher: container ${code} ${json.status ?? ""}`.trim());
93
+ }
94
+ await sleep(this.pollDelayMs);
95
+ }
96
+ throw new Error(`InstagramPublisher: container not ready after ${this.maxPolls} polls`);
97
+ }
98
+ async resolvePermalink(mediaId, accessToken) {
99
+ try {
100
+ const resp = await fetch(graph(`/${mediaId}?fields=permalink&access_token=${encodeURIComponent(accessToken)}`));
101
+ const json = (await resp.json());
102
+ return json.permalink;
103
+ }
104
+ catch {
105
+ return undefined;
106
+ }
107
+ }
108
+ }
109
+ exports.InstagramPublisher = InstagramPublisher;
110
+ /**
111
+ * Facebook Page publisher — posts a video to the Page via /{page-id}/videos with
112
+ * a hosted `file_url` (Graph downloads it). Supports native scheduling through
113
+ * `published=false` + `scheduled_publish_time` (unix seconds, 10m–6mo out).
114
+ */
115
+ class FacebookPublisher {
116
+ constructor() {
117
+ this.provider = types_1.ESocialProvider.FACEBOOK;
118
+ }
119
+ async publish(input) {
120
+ const pageId = input.providerAccountId;
121
+ if (!pageId) {
122
+ throw new Error("FacebookPublisher: missing providerAccountId (Page id)");
123
+ }
124
+ const form = new URLSearchParams({
125
+ file_url: input.mediaUrl,
126
+ description: buildCaption(input),
127
+ access_token: input.accessToken,
128
+ });
129
+ if (input.title)
130
+ form.set("title", input.title);
131
+ // Native scheduling: FB requires published=false + a unix-seconds timestamp.
132
+ if (input.scheduledAt && input.scheduledAt > Date.now()) {
133
+ form.set("published", "false");
134
+ form.set("scheduled_publish_time", String(Math.floor(input.scheduledAt / 1000)));
135
+ }
136
+ const result = await postForm(graph(`/${pageId}/videos`), form);
137
+ const videoId = result.id;
138
+ logger_1.logger.info("FacebookPublisher: published", {
139
+ pageId,
140
+ videoId,
141
+ scheduled: Boolean(input.scheduledAt),
142
+ });
143
+ return {
144
+ providerPostId: videoId,
145
+ publishedUrl: `https://www.facebook.com/watch/?v=${videoId}`,
146
+ };
147
+ }
148
+ }
149
+ exports.FacebookPublisher = FacebookPublisher;
@@ -0,0 +1,13 @@
1
+ import { ESocialProvider } from "../../globals/types";
2
+ import { ISocialPublisher, PublishInput, PublishResult } from "./types";
3
+ export declare class PinterestPublisher implements ISocialPublisher {
4
+ readonly provider = ESocialProvider.PINTEREST;
5
+ private readonly maxPolls;
6
+ private readonly pollDelayMs;
7
+ publish(input: PublishInput): Promise<PublishResult>;
8
+ private firstBoardId;
9
+ private pollMedia;
10
+ private json;
11
+ private buildDescription;
12
+ }
13
+ //# sourceMappingURL=pinterest.publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pinterest.publish.d.ts","sourceRoot":"","sources":["../../../src/services/socialPublish/pinterest.publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAoCxE,qBAAa,kBAAmB,YAAW,gBAAgB;IACzD,QAAQ,CAAC,QAAQ,6BAA6B;IAE9C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAM;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IAE9B,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;YA0E5C,YAAY;YAgBZ,SAAS;YAiBT,IAAI;IAQlB,OAAO,CAAC,gBAAgB;CAQzB"}
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PinterestPublisher = void 0;
4
+ const types_1 = require("../../globals/types");
5
+ const logger_1 = require("../../utils/logger");
6
+ /**
7
+ * Pinterest publisher (v5) — Phase 6. Video Pin flow:
8
+ * 1. POST /v5/media (media_type=video) → { media_id, upload_url, upload_parameters }
9
+ * 2. POST the bytes to the (S3) upload_url with the returned form parameters
10
+ * 3. Poll GET /v5/media/{media_id} until status=succeeded
11
+ * 4. POST /v5/pins { board_id, title, description, media_source }
12
+ *
13
+ * Two Pinterest-specific realities handled here:
14
+ * - A pin needs a BOARD. PublishInput carries none, so we pin to the account's
15
+ * first board (GET /v5/boards). A board picker is a future enhancement.
16
+ * - A video pin REQUIRES a cover image. We use input.thumbnailUrl when the
17
+ * worker provides it; the worker must populate it (videoJob poster) for
18
+ * Pinterest to publish. (Documented in PublishInput + ACTION_PLAN.)
19
+ */
20
+ const API = "https://api.pinterest.com/v5";
21
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
22
+ class PinterestPublisher {
23
+ constructor() {
24
+ this.provider = types_1.ESocialProvider.PINTEREST;
25
+ this.maxPolls = 30;
26
+ this.pollDelayMs = 4000;
27
+ }
28
+ async publish(input) {
29
+ const token = input.accessToken;
30
+ // 0. Resolve a destination board (first board for now).
31
+ const boardId = await this.firstBoardId(token);
32
+ // 1. Register the video upload.
33
+ const reg = await this.json(await fetch(`${API}/media`, {
34
+ method: "POST",
35
+ headers: {
36
+ Authorization: `Bearer ${token}`,
37
+ "Content-Type": "application/json",
38
+ },
39
+ body: JSON.stringify({ media_type: "video" }),
40
+ }), "register media");
41
+ if (!reg.media_id || !reg.upload_url || !reg.upload_parameters) {
42
+ throw new Error("PinterestPublisher: media register returned no upload target");
43
+ }
44
+ // 2. Upload the bytes to S3 with the supplied form parameters.
45
+ const mediaResp = await fetch(input.mediaUrl);
46
+ if (!mediaResp.ok) {
47
+ throw new Error(`PinterestPublisher: media fetch ${mediaResp.status}`);
48
+ }
49
+ const bytes = Buffer.from(await mediaResp.arrayBuffer());
50
+ const form = new FormData();
51
+ for (const [k, v] of Object.entries(reg.upload_parameters))
52
+ form.append(k, v);
53
+ form.append("file", new Blob([bytes]));
54
+ const s3Resp = await fetch(reg.upload_url, { method: "POST", body: form });
55
+ if (!s3Resp.ok) {
56
+ throw new Error(`PinterestPublisher: media upload ${s3Resp.status}`);
57
+ }
58
+ // 3. Poll until the media is processed.
59
+ await this.pollMedia(token, reg.media_id);
60
+ // 4. Create the pin.
61
+ const mediaSource = {
62
+ source_type: "video_id",
63
+ media_id: reg.media_id,
64
+ };
65
+ if (input.thumbnailUrl)
66
+ mediaSource.cover_image_url = input.thumbnailUrl;
67
+ else
68
+ mediaSource.cover_image_key_frame_time = 0;
69
+ const pin = await this.json(await fetch(`${API}/pins`, {
70
+ method: "POST",
71
+ headers: {
72
+ Authorization: `Bearer ${token}`,
73
+ "Content-Type": "application/json",
74
+ },
75
+ body: JSON.stringify({
76
+ board_id: boardId,
77
+ title: (input.title ?? input.caption ?? "VidSpot video").slice(0, 100),
78
+ description: this.buildDescription(input),
79
+ media_source: mediaSource,
80
+ }),
81
+ }), "create pin");
82
+ if (!pin.id) {
83
+ throw new Error(`PinterestPublisher: create pin failed ${pin.message ?? ""}`);
84
+ }
85
+ logger_1.logger.info("PinterestPublisher: published", { pinId: pin.id, boardId });
86
+ return {
87
+ providerPostId: pin.id,
88
+ publishedUrl: `https://www.pinterest.com/pin/${pin.id}/`,
89
+ };
90
+ }
91
+ async firstBoardId(token) {
92
+ const boards = await this.json(await fetch(`${API}/boards?page_size=1`, {
93
+ headers: { Authorization: `Bearer ${token}` },
94
+ }), "list boards");
95
+ const id = boards.items?.[0]?.id;
96
+ if (!id) {
97
+ throw new Error("PinterestPublisher: account has no board to pin to — create one first");
98
+ }
99
+ return id;
100
+ }
101
+ async pollMedia(token, mediaId) {
102
+ for (let i = 0; i < this.maxPolls; i++) {
103
+ await sleep(this.pollDelayMs);
104
+ const status = await this.json(await fetch(`${API}/media/${mediaId}`, {
105
+ headers: { Authorization: `Bearer ${token}` },
106
+ }), "media status");
107
+ if (status.status === "succeeded")
108
+ return;
109
+ if (status.status === "failed") {
110
+ throw new Error("PinterestPublisher: media processing failed");
111
+ }
112
+ }
113
+ throw new Error("PinterestPublisher: timed out waiting for media processing");
114
+ }
115
+ async json(resp, what) {
116
+ if (!resp.ok) {
117
+ const text = await resp.text();
118
+ throw new Error(`PinterestPublisher: ${what} ${resp.status} ${text}`);
119
+ }
120
+ return (await resp.json());
121
+ }
122
+ buildDescription(input) {
123
+ const tags = input.hashtags && input.hashtags.length
124
+ ? "\n\n" +
125
+ input.hashtags.map((h) => (h.startsWith("#") ? h : `#${h}`)).join(" ")
126
+ : "";
127
+ return `${input.caption ?? ""}${tags}`.trim().slice(0, 800);
128
+ }
129
+ }
130
+ exports.PinterestPublisher = PinterestPublisher;
@@ -0,0 +1,12 @@
1
+ import { ESocialProvider } from "../../globals/types";
2
+ import { ISocialPublisher, PublishInput, PublishResult } from "./types";
3
+ export declare class ThreadsPublisher implements ISocialPublisher {
4
+ readonly provider = ESocialProvider.THREADS;
5
+ private readonly maxPolls;
6
+ private readonly pollDelayMs;
7
+ publish(input: PublishInput): Promise<PublishResult>;
8
+ private pollContainer;
9
+ private fetchPermalink;
10
+ private buildText;
11
+ }
12
+ //# sourceMappingURL=threads.publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threads.publish.d.ts","sourceRoot":"","sources":["../../../src/services/socialPublish/threads.publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA6BxE,qBAAa,gBAAiB,YAAW,gBAAgB;IACvD,QAAQ,CAAC,QAAQ,2BAA2B;IAE5C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAM;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IAE9B,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;YAmD5C,aAAa;YAiBb,cAAc;IAe5B,OAAO,CAAC,SAAS;CAQlB"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadsPublisher = void 0;
4
+ const types_1 = require("../../globals/types");
5
+ const logger_1 = require("../../utils/logger");
6
+ /**
7
+ * Threads publisher — Phase 6. Two-step container flow (same shape as IG Reels):
8
+ * 1. POST /v1.0/{user-id}/threads (media_type=VIDEO, video_url, text) → creation_id
9
+ * 2. Poll /v1.0/{creation_id}?fields=status until FINISHED
10
+ * 3. POST /v1.0/{user-id}/threads_publish (creation_id) → media id
11
+ * 4. GET /v1.0/{media-id}?fields=permalink for the public URL
12
+ *
13
+ * Threads has no native scheduling — the worker schedules via BullMQ delay.
14
+ */
15
+ const API_BASE = "https://graph.threads.net/v1.0";
16
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
17
+ class ThreadsPublisher {
18
+ constructor() {
19
+ this.provider = types_1.ESocialProvider.THREADS;
20
+ this.maxPolls = 30;
21
+ this.pollDelayMs = 4000;
22
+ }
23
+ async publish(input) {
24
+ const userId = input.providerAccountId;
25
+ if (!userId) {
26
+ throw new Error("ThreadsPublisher: missing providerAccountId (Threads user id)");
27
+ }
28
+ const token = input.accessToken;
29
+ const text = this.buildText(input);
30
+ // 1. Create the media container.
31
+ const createResp = await fetch(`${API_BASE}/${userId}/threads`, {
32
+ method: "POST",
33
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
34
+ body: new URLSearchParams({
35
+ media_type: "VIDEO",
36
+ video_url: input.mediaUrl,
37
+ text,
38
+ access_token: token,
39
+ }).toString(),
40
+ });
41
+ const created = (await createResp.json());
42
+ if (!createResp.ok || created.error || !created.id) {
43
+ throw new Error(`ThreadsPublisher: create container ${createResp.status} ${created.error?.message ?? ""}`.trim());
44
+ }
45
+ const creationId = created.id;
46
+ // 2. Poll until the container finishes processing.
47
+ await this.pollContainer(creationId, token);
48
+ // 3. Publish the container.
49
+ const pubResp = await fetch(`${API_BASE}/${userId}/threads_publish`, {
50
+ method: "POST",
51
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
52
+ body: new URLSearchParams({
53
+ creation_id: creationId,
54
+ access_token: token,
55
+ }).toString(),
56
+ });
57
+ const published = (await pubResp.json());
58
+ if (!pubResp.ok || published.error || !published.id) {
59
+ throw new Error(`ThreadsPublisher: publish ${pubResp.status} ${published.error?.message ?? ""}`.trim());
60
+ }
61
+ logger_1.logger.info("ThreadsPublisher: published", { mediaId: published.id });
62
+ const permalink = await this.fetchPermalink(published.id, token);
63
+ return { providerPostId: published.id, publishedUrl: permalink };
64
+ }
65
+ async pollContainer(creationId, token) {
66
+ for (let i = 0; i < this.maxPolls; i++) {
67
+ await sleep(this.pollDelayMs);
68
+ const resp = await fetch(`${API_BASE}/${creationId}?fields=status,error_message&access_token=${encodeURIComponent(token)}`);
69
+ const json = (await resp.json());
70
+ if (json.status === "FINISHED")
71
+ return;
72
+ if (json.status === "ERROR" || json.status === "EXPIRED") {
73
+ throw new Error(`ThreadsPublisher: container ${json.status} — ${json.error_message ?? ""}`);
74
+ }
75
+ }
76
+ throw new Error("ThreadsPublisher: timed out waiting for container");
77
+ }
78
+ async fetchPermalink(mediaId, token) {
79
+ try {
80
+ const resp = await fetch(`${API_BASE}/${mediaId}?fields=permalink&access_token=${encodeURIComponent(token)}`);
81
+ const json = (await resp.json());
82
+ return json.permalink;
83
+ }
84
+ catch {
85
+ return undefined;
86
+ }
87
+ }
88
+ buildText(input) {
89
+ const tags = input.hashtags && input.hashtags.length
90
+ ? "\n\n" +
91
+ input.hashtags.map((h) => (h.startsWith("#") ? h : `#${h}`)).join(" ")
92
+ : "";
93
+ return `${input.caption ?? ""}${tags}`.trim().slice(0, 500);
94
+ }
95
+ }
96
+ exports.ThreadsPublisher = ThreadsPublisher;
@@ -0,0 +1,13 @@
1
+ import { ESocialProvider } from "../../globals/types";
2
+ import { ISocialPublisher, PublishInput, PublishResult } from "./types";
3
+ export declare class TikTokPublisher implements ISocialPublisher {
4
+ readonly provider = ESocialProvider.TIKTOK;
5
+ private readonly maxPolls;
6
+ private readonly pollDelayMs;
7
+ publish(input: PublishInput): Promise<PublishResult>;
8
+ private pollStatus;
9
+ /** TikTok caption ("title") max ~2200 chars; merge hashtags inline. */
10
+ private buildTitle;
11
+ private resolvePrivacy;
12
+ }
13
+ //# sourceMappingURL=tiktok.publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiktok.publish.d.ts","sourceRoot":"","sources":["../../../src/services/socialPublish/tiktok.publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAyCxE,qBAAa,eAAgB,YAAW,gBAAgB;IACtD,QAAQ,CAAC,QAAQ,0BAA0B;IAE3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAM;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IAE9B,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;YA6C5C,UAAU;IA6BxB,uEAAuE;IACvE,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,cAAc;CAQvB"}