magic-hour 0.0.2

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 (307) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -0
  3. package/dist/client.d.ts +17 -0
  4. package/dist/client.js +19 -0
  5. package/dist/core/api-error.d.ts +9 -0
  6. package/dist/core/api-error.js +14 -0
  7. package/dist/core/api-promise.d.ts +22 -0
  8. package/dist/core/api-promise.js +67 -0
  9. package/dist/core/auth.d.ts +36 -0
  10. package/dist/core/auth.js +98 -0
  11. package/dist/core/binary-response.d.ts +9 -0
  12. package/dist/core/binary-response.js +13 -0
  13. package/dist/core/content-type.d.ts +7 -0
  14. package/dist/core/content-type.js +15 -0
  15. package/dist/core/core-client.d.ts +46 -0
  16. package/dist/core/core-client.js +149 -0
  17. package/dist/core/form-data.d.ts +30 -0
  18. package/dist/core/form-data.js +87 -0
  19. package/dist/core/index.d.ts +10 -0
  20. package/dist/core/index.js +26 -0
  21. package/dist/core/runtime.d.ts +7 -0
  22. package/dist/core/runtime.js +23 -0
  23. package/dist/environment.d.ts +6 -0
  24. package/dist/environment.js +10 -0
  25. package/dist/index.d.ts +8 -0
  26. package/dist/index.js +39 -0
  27. package/dist/resources/index.d.ts +4 -0
  28. package/dist/resources/index.js +30 -0
  29. package/dist/resources/v1/ai-image-generator/index.d.ts +5 -0
  30. package/dist/resources/v1/ai-image-generator/index.js +8 -0
  31. package/dist/resources/v1/ai-image-generator/request-types.d.ts +7 -0
  32. package/dist/resources/v1/ai-image-generator/request-types.js +5 -0
  33. package/dist/resources/v1/ai-image-generator/resource-client.d.ts +13 -0
  34. package/dist/resources/v1/ai-image-generator/resource-client.js +27 -0
  35. package/dist/resources/v1/face-swap/index.d.ts +5 -0
  36. package/dist/resources/v1/face-swap/index.js +8 -0
  37. package/dist/resources/v1/face-swap/request-types.d.ts +7 -0
  38. package/dist/resources/v1/face-swap/request-types.js +5 -0
  39. package/dist/resources/v1/face-swap/resource-client.d.ts +16 -0
  40. package/dist/resources/v1/face-swap/resource-client.js +30 -0
  41. package/dist/resources/v1/face-swap-photo/index.d.ts +5 -0
  42. package/dist/resources/v1/face-swap-photo/index.js +8 -0
  43. package/dist/resources/v1/face-swap-photo/request-types.d.ts +7 -0
  44. package/dist/resources/v1/face-swap-photo/request-types.js +5 -0
  45. package/dist/resources/v1/face-swap-photo/resource-client.d.ts +13 -0
  46. package/dist/resources/v1/face-swap-photo/resource-client.js +27 -0
  47. package/dist/resources/v1/files/index.d.ts +5 -0
  48. package/dist/resources/v1/files/index.js +32 -0
  49. package/dist/resources/v1/files/resource-client.d.ts +9 -0
  50. package/dist/resources/v1/files/resource-client.js +15 -0
  51. package/dist/resources/v1/files/upload-urls/index.d.ts +5 -0
  52. package/dist/resources/v1/files/upload-urls/index.js +8 -0
  53. package/dist/resources/v1/files/upload-urls/request-types.d.ts +7 -0
  54. package/dist/resources/v1/files/upload-urls/request-types.js +5 -0
  55. package/dist/resources/v1/files/upload-urls/resource-client.d.ts +32 -0
  56. package/dist/resources/v1/files/upload-urls/resource-client.js +46 -0
  57. package/dist/resources/v1/image-projects/index.d.ts +5 -0
  58. package/dist/resources/v1/image-projects/index.js +8 -0
  59. package/dist/resources/v1/image-projects/request-types.d.ts +6 -0
  60. package/dist/resources/v1/image-projects/request-types.js +5 -0
  61. package/dist/resources/v1/image-projects/resource-client.d.ts +22 -0
  62. package/dist/resources/v1/image-projects/resource-client.js +34 -0
  63. package/dist/resources/v1/image-to-video/index.d.ts +5 -0
  64. package/dist/resources/v1/image-to-video/index.js +8 -0
  65. package/dist/resources/v1/image-to-video/request-types.d.ts +7 -0
  66. package/dist/resources/v1/image-to-video/request-types.js +5 -0
  67. package/dist/resources/v1/image-to-video/resource-client.d.ts +16 -0
  68. package/dist/resources/v1/image-to-video/resource-client.js +30 -0
  69. package/dist/resources/v1/index.d.ts +14 -0
  70. package/dist/resources/v1/index.js +41 -0
  71. package/dist/resources/v1/lip-sync/index.d.ts +5 -0
  72. package/dist/resources/v1/lip-sync/index.js +8 -0
  73. package/dist/resources/v1/lip-sync/request-types.d.ts +7 -0
  74. package/dist/resources/v1/lip-sync/request-types.js +5 -0
  75. package/dist/resources/v1/lip-sync/resource-client.d.ts +16 -0
  76. package/dist/resources/v1/lip-sync/resource-client.js +30 -0
  77. package/dist/resources/v1/resource-client.d.ts +27 -0
  78. package/dist/resources/v1/resource-client.js +33 -0
  79. package/dist/resources/v1/text-to-video/index.d.ts +5 -0
  80. package/dist/resources/v1/text-to-video/index.js +8 -0
  81. package/dist/resources/v1/text-to-video/request-types.d.ts +7 -0
  82. package/dist/resources/v1/text-to-video/request-types.js +5 -0
  83. package/dist/resources/v1/text-to-video/resource-client.d.ts +16 -0
  84. package/dist/resources/v1/text-to-video/resource-client.js +30 -0
  85. package/dist/resources/v1/video-projects/index.d.ts +5 -0
  86. package/dist/resources/v1/video-projects/index.js +8 -0
  87. package/dist/resources/v1/video-projects/request-types.d.ts +6 -0
  88. package/dist/resources/v1/video-projects/request-types.js +5 -0
  89. package/dist/resources/v1/video-projects/resource-client.d.ts +22 -0
  90. package/dist/resources/v1/video-projects/resource-client.js +34 -0
  91. package/dist/resources/v1/video-to-video/index.d.ts +5 -0
  92. package/dist/resources/v1/video-to-video/index.js +8 -0
  93. package/dist/resources/v1/video-to-video/request-types.d.ts +7 -0
  94. package/dist/resources/v1/video-to-video/request-types.js +5 -0
  95. package/dist/resources/v1/video-to-video/resource-client.d.ts +16 -0
  96. package/dist/resources/v1/video-to-video/resource-client.js +30 -0
  97. package/dist/types/get-v1-image-projects-id-response-downloads-item.d.ts +7 -0
  98. package/dist/types/get-v1-image-projects-id-response-downloads-item.js +5 -0
  99. package/dist/types/get-v1-image-projects-id-response-status-enum.d.ts +11 -0
  100. package/dist/types/get-v1-image-projects-id-response-status-enum.js +15 -0
  101. package/dist/types/get-v1-image-projects-id-response-type-enum.d.ts +10 -0
  102. package/dist/types/get-v1-image-projects-id-response-type-enum.js +14 -0
  103. package/dist/types/get-v1-image-projects-id-response.d.ts +29 -0
  104. package/dist/types/get-v1-image-projects-id-response.js +5 -0
  105. package/dist/types/get-v1-image-projects-id-response400.d.ts +6 -0
  106. package/dist/types/get-v1-image-projects-id-response400.js +5 -0
  107. package/dist/types/get-v1-image-projects-id-response401-message-enum.d.ts +6 -0
  108. package/dist/types/get-v1-image-projects-id-response401-message-enum.js +10 -0
  109. package/dist/types/get-v1-image-projects-id-response401.d.ts +7 -0
  110. package/dist/types/get-v1-image-projects-id-response401.js +5 -0
  111. package/dist/types/get-v1-image-projects-id-response404-message-enum.d.ts +6 -0
  112. package/dist/types/get-v1-image-projects-id-response404-message-enum.js +10 -0
  113. package/dist/types/get-v1-image-projects-id-response404.d.ts +7 -0
  114. package/dist/types/get-v1-image-projects-id-response404.js +5 -0
  115. package/dist/types/get-v1-video-projects-id-response-download.d.ts +7 -0
  116. package/dist/types/get-v1-video-projects-id-response-download.js +5 -0
  117. package/dist/types/get-v1-video-projects-id-response-status-enum.d.ts +11 -0
  118. package/dist/types/get-v1-video-projects-id-response-status-enum.js +15 -0
  119. package/dist/types/get-v1-video-projects-id-response-type-enum.d.ts +11 -0
  120. package/dist/types/get-v1-video-projects-id-response-type-enum.js +15 -0
  121. package/dist/types/get-v1-video-projects-id-response.d.ts +48 -0
  122. package/dist/types/get-v1-video-projects-id-response.js +5 -0
  123. package/dist/types/get-v1-video-projects-id-response400.d.ts +6 -0
  124. package/dist/types/get-v1-video-projects-id-response400.js +5 -0
  125. package/dist/types/get-v1-video-projects-id-response401-message-enum.d.ts +6 -0
  126. package/dist/types/get-v1-video-projects-id-response401-message-enum.js +10 -0
  127. package/dist/types/get-v1-video-projects-id-response401.d.ts +7 -0
  128. package/dist/types/get-v1-video-projects-id-response401.js +5 -0
  129. package/dist/types/get-v1-video-projects-id-response404-message-enum.d.ts +6 -0
  130. package/dist/types/get-v1-video-projects-id-response404-message-enum.js +10 -0
  131. package/dist/types/get-v1-video-projects-id-response404.d.ts +7 -0
  132. package/dist/types/get-v1-video-projects-id-response404.js +5 -0
  133. package/dist/types/index.d.ts +107 -0
  134. package/dist/types/index.js +76 -0
  135. package/dist/types/post-v1-ai-image-generator-body-orientation-enum.d.ts +8 -0
  136. package/dist/types/post-v1-ai-image-generator-body-orientation-enum.js +12 -0
  137. package/dist/types/post-v1-ai-image-generator-body-style.d.ts +9 -0
  138. package/dist/types/post-v1-ai-image-generator-body-style.js +5 -0
  139. package/dist/types/post-v1-ai-image-generator-body.d.ts +16 -0
  140. package/dist/types/post-v1-ai-image-generator-body.js +5 -0
  141. package/dist/types/post-v1-ai-image-generator-response.d.ts +10 -0
  142. package/dist/types/post-v1-ai-image-generator-response.js +5 -0
  143. package/dist/types/post-v1-ai-image-generator-response400.d.ts +6 -0
  144. package/dist/types/post-v1-ai-image-generator-response400.js +5 -0
  145. package/dist/types/post-v1-ai-image-generator-response401-message-enum.d.ts +6 -0
  146. package/dist/types/post-v1-ai-image-generator-response401-message-enum.js +10 -0
  147. package/dist/types/post-v1-ai-image-generator-response401.d.ts +7 -0
  148. package/dist/types/post-v1-ai-image-generator-response401.js +5 -0
  149. package/dist/types/post-v1-ai-image-generator-response404-message-enum.d.ts +6 -0
  150. package/dist/types/post-v1-ai-image-generator-response404-message-enum.js +10 -0
  151. package/dist/types/post-v1-ai-image-generator-response404.d.ts +7 -0
  152. package/dist/types/post-v1-ai-image-generator-response404.js +5 -0
  153. package/dist/types/post-v1-ai-image-generator-response422.d.ts +6 -0
  154. package/dist/types/post-v1-ai-image-generator-response422.js +5 -0
  155. package/dist/types/post-v1-face-swap-body-assets-video-source-enum.d.ts +7 -0
  156. package/dist/types/post-v1-face-swap-body-assets-video-source-enum.js +11 -0
  157. package/dist/types/post-v1-face-swap-body-assets.d.ts +19 -0
  158. package/dist/types/post-v1-face-swap-body-assets.js +5 -0
  159. package/dist/types/post-v1-face-swap-body.d.ts +30 -0
  160. package/dist/types/post-v1-face-swap-body.js +5 -0
  161. package/dist/types/post-v1-face-swap-photo-body-assets.d.ts +13 -0
  162. package/dist/types/post-v1-face-swap-photo-body-assets.js +5 -0
  163. package/dist/types/post-v1-face-swap-photo-body.d.ts +14 -0
  164. package/dist/types/post-v1-face-swap-photo-body.js +5 -0
  165. package/dist/types/post-v1-face-swap-photo-response.d.ts +10 -0
  166. package/dist/types/post-v1-face-swap-photo-response.js +5 -0
  167. package/dist/types/post-v1-face-swap-photo-response400.d.ts +6 -0
  168. package/dist/types/post-v1-face-swap-photo-response400.js +5 -0
  169. package/dist/types/post-v1-face-swap-photo-response401-message-enum.d.ts +6 -0
  170. package/dist/types/post-v1-face-swap-photo-response401-message-enum.js +10 -0
  171. package/dist/types/post-v1-face-swap-photo-response401.d.ts +7 -0
  172. package/dist/types/post-v1-face-swap-photo-response401.js +5 -0
  173. package/dist/types/post-v1-face-swap-photo-response404-message-enum.d.ts +6 -0
  174. package/dist/types/post-v1-face-swap-photo-response404-message-enum.js +10 -0
  175. package/dist/types/post-v1-face-swap-photo-response404.d.ts +7 -0
  176. package/dist/types/post-v1-face-swap-photo-response404.js +5 -0
  177. package/dist/types/post-v1-face-swap-photo-response422.d.ts +6 -0
  178. package/dist/types/post-v1-face-swap-photo-response422.js +5 -0
  179. package/dist/types/post-v1-face-swap-response.d.ts +13 -0
  180. package/dist/types/post-v1-face-swap-response.js +5 -0
  181. package/dist/types/post-v1-face-swap-response400.d.ts +6 -0
  182. package/dist/types/post-v1-face-swap-response400.js +5 -0
  183. package/dist/types/post-v1-face-swap-response401-message-enum.d.ts +6 -0
  184. package/dist/types/post-v1-face-swap-response401-message-enum.js +10 -0
  185. package/dist/types/post-v1-face-swap-response401.d.ts +7 -0
  186. package/dist/types/post-v1-face-swap-response401.js +5 -0
  187. package/dist/types/post-v1-face-swap-response404-message-enum.d.ts +6 -0
  188. package/dist/types/post-v1-face-swap-response404-message-enum.js +10 -0
  189. package/dist/types/post-v1-face-swap-response404.d.ts +7 -0
  190. package/dist/types/post-v1-face-swap-response404.js +5 -0
  191. package/dist/types/post-v1-face-swap-response422.d.ts +6 -0
  192. package/dist/types/post-v1-face-swap-response422.js +5 -0
  193. package/dist/types/post-v1-files-upload-urls-body-items-item-type-enum.d.ts +8 -0
  194. package/dist/types/post-v1-files-upload-urls-body-items-item-type-enum.js +12 -0
  195. package/dist/types/post-v1-files-upload-urls-body-items-item.d.ts +14 -0
  196. package/dist/types/post-v1-files-upload-urls-body-items-item.js +5 -0
  197. package/dist/types/post-v1-files-upload-urls-body.d.ts +7 -0
  198. package/dist/types/post-v1-files-upload-urls-body.js +5 -0
  199. package/dist/types/post-v1-files-upload-urls-response-items-item.d.ts +8 -0
  200. package/dist/types/post-v1-files-upload-urls-response-items-item.js +5 -0
  201. package/dist/types/post-v1-files-upload-urls-response.d.ts +7 -0
  202. package/dist/types/post-v1-files-upload-urls-response.js +5 -0
  203. package/dist/types/post-v1-files-upload-urls-response400.d.ts +6 -0
  204. package/dist/types/post-v1-files-upload-urls-response400.js +5 -0
  205. package/dist/types/post-v1-files-upload-urls-response401-message-enum.d.ts +6 -0
  206. package/dist/types/post-v1-files-upload-urls-response401-message-enum.js +10 -0
  207. package/dist/types/post-v1-files-upload-urls-response401.d.ts +7 -0
  208. package/dist/types/post-v1-files-upload-urls-response401.js +5 -0
  209. package/dist/types/post-v1-files-upload-urls-response404-message-enum.d.ts +6 -0
  210. package/dist/types/post-v1-files-upload-urls-response404-message-enum.js +10 -0
  211. package/dist/types/post-v1-files-upload-urls-response404.d.ts +7 -0
  212. package/dist/types/post-v1-files-upload-urls-response404.js +5 -0
  213. package/dist/types/post-v1-files-upload-urls-response422.d.ts +6 -0
  214. package/dist/types/post-v1-files-upload-urls-response422.js +5 -0
  215. package/dist/types/post-v1-image-to-video-body-assets.d.ts +9 -0
  216. package/dist/types/post-v1-image-to-video-body-assets.js +5 -0
  217. package/dist/types/post-v1-image-to-video-body-style.d.ts +9 -0
  218. package/dist/types/post-v1-image-to-video-body-style.js +5 -0
  219. package/dist/types/post-v1-image-to-video-body.d.ts +27 -0
  220. package/dist/types/post-v1-image-to-video-body.js +5 -0
  221. package/dist/types/post-v1-image-to-video-response.d.ts +13 -0
  222. package/dist/types/post-v1-image-to-video-response.js +5 -0
  223. package/dist/types/post-v1-image-to-video-response400.d.ts +6 -0
  224. package/dist/types/post-v1-image-to-video-response400.js +5 -0
  225. package/dist/types/post-v1-image-to-video-response401-message-enum.d.ts +6 -0
  226. package/dist/types/post-v1-image-to-video-response401-message-enum.js +10 -0
  227. package/dist/types/post-v1-image-to-video-response401.d.ts +7 -0
  228. package/dist/types/post-v1-image-to-video-response401.js +5 -0
  229. package/dist/types/post-v1-image-to-video-response404-message-enum.d.ts +6 -0
  230. package/dist/types/post-v1-image-to-video-response404-message-enum.js +10 -0
  231. package/dist/types/post-v1-image-to-video-response404.d.ts +7 -0
  232. package/dist/types/post-v1-image-to-video-response404.js +5 -0
  233. package/dist/types/post-v1-image-to-video-response422.d.ts +6 -0
  234. package/dist/types/post-v1-image-to-video-response422.js +5 -0
  235. package/dist/types/post-v1-lip-sync-body-assets-video-source-enum.d.ts +7 -0
  236. package/dist/types/post-v1-lip-sync-body-assets-video-source-enum.js +11 -0
  237. package/dist/types/post-v1-lip-sync-body-assets.d.ts +19 -0
  238. package/dist/types/post-v1-lip-sync-body-assets.js +5 -0
  239. package/dist/types/post-v1-lip-sync-body.d.ts +30 -0
  240. package/dist/types/post-v1-lip-sync-body.js +5 -0
  241. package/dist/types/post-v1-lip-sync-response.d.ts +13 -0
  242. package/dist/types/post-v1-lip-sync-response.js +5 -0
  243. package/dist/types/post-v1-lip-sync-response400.d.ts +6 -0
  244. package/dist/types/post-v1-lip-sync-response400.js +5 -0
  245. package/dist/types/post-v1-lip-sync-response401-message-enum.d.ts +6 -0
  246. package/dist/types/post-v1-lip-sync-response401-message-enum.js +10 -0
  247. package/dist/types/post-v1-lip-sync-response401.d.ts +7 -0
  248. package/dist/types/post-v1-lip-sync-response401.js +5 -0
  249. package/dist/types/post-v1-lip-sync-response404-message-enum.d.ts +6 -0
  250. package/dist/types/post-v1-lip-sync-response404-message-enum.js +10 -0
  251. package/dist/types/post-v1-lip-sync-response404.d.ts +7 -0
  252. package/dist/types/post-v1-lip-sync-response404.js +5 -0
  253. package/dist/types/post-v1-lip-sync-response422.d.ts +6 -0
  254. package/dist/types/post-v1-lip-sync-response422.js +5 -0
  255. package/dist/types/post-v1-text-to-video-body-orientation-enum.d.ts +8 -0
  256. package/dist/types/post-v1-text-to-video-body-orientation-enum.js +12 -0
  257. package/dist/types/post-v1-text-to-video-body-style.d.ts +9 -0
  258. package/dist/types/post-v1-text-to-video-body-style.js +5 -0
  259. package/dist/types/post-v1-text-to-video-body.d.ts +19 -0
  260. package/dist/types/post-v1-text-to-video-body.js +5 -0
  261. package/dist/types/post-v1-text-to-video-response.d.ts +13 -0
  262. package/dist/types/post-v1-text-to-video-response.js +5 -0
  263. package/dist/types/post-v1-text-to-video-response400.d.ts +6 -0
  264. package/dist/types/post-v1-text-to-video-response400.js +5 -0
  265. package/dist/types/post-v1-text-to-video-response401-message-enum.d.ts +6 -0
  266. package/dist/types/post-v1-text-to-video-response401-message-enum.js +10 -0
  267. package/dist/types/post-v1-text-to-video-response401.d.ts +7 -0
  268. package/dist/types/post-v1-text-to-video-response401.js +5 -0
  269. package/dist/types/post-v1-text-to-video-response404-message-enum.d.ts +6 -0
  270. package/dist/types/post-v1-text-to-video-response404-message-enum.js +10 -0
  271. package/dist/types/post-v1-text-to-video-response404.d.ts +7 -0
  272. package/dist/types/post-v1-text-to-video-response404.js +5 -0
  273. package/dist/types/post-v1-text-to-video-response422.d.ts +6 -0
  274. package/dist/types/post-v1-text-to-video-response422.js +5 -0
  275. package/dist/types/post-v1-video-to-video-body-assets-video-source-enum.d.ts +7 -0
  276. package/dist/types/post-v1-video-to-video-body-assets-video-source-enum.js +11 -0
  277. package/dist/types/post-v1-video-to-video-body-assets.d.ts +15 -0
  278. package/dist/types/post-v1-video-to-video-body-assets.js +5 -0
  279. package/dist/types/post-v1-video-to-video-body-fps-resolution-enum.d.ts +7 -0
  280. package/dist/types/post-v1-video-to-video-body-fps-resolution-enum.js +11 -0
  281. package/dist/types/post-v1-video-to-video-body-style-art-style-enum.d.ts +64 -0
  282. package/dist/types/post-v1-video-to-video-body-style-art-style-enum.js +68 -0
  283. package/dist/types/post-v1-video-to-video-body-style-model-enum.d.ts +9 -0
  284. package/dist/types/post-v1-video-to-video-body-style-model-enum.js +13 -0
  285. package/dist/types/post-v1-video-to-video-body-style-prompt-type-enum.d.ts +8 -0
  286. package/dist/types/post-v1-video-to-video-body-style-prompt-type-enum.js +12 -0
  287. package/dist/types/post-v1-video-to-video-body-style-version-enum.d.ts +8 -0
  288. package/dist/types/post-v1-video-to-video-body-style-version-enum.js +12 -0
  289. package/dist/types/post-v1-video-to-video-body-style.d.ts +30 -0
  290. package/dist/types/post-v1-video-to-video-body-style.js +5 -0
  291. package/dist/types/post-v1-video-to-video-body.d.ts +37 -0
  292. package/dist/types/post-v1-video-to-video-body.js +5 -0
  293. package/dist/types/post-v1-video-to-video-response.d.ts +13 -0
  294. package/dist/types/post-v1-video-to-video-response.js +5 -0
  295. package/dist/types/post-v1-video-to-video-response400.d.ts +6 -0
  296. package/dist/types/post-v1-video-to-video-response400.js +5 -0
  297. package/dist/types/post-v1-video-to-video-response401-message-enum.d.ts +6 -0
  298. package/dist/types/post-v1-video-to-video-response401-message-enum.js +10 -0
  299. package/dist/types/post-v1-video-to-video-response401.d.ts +7 -0
  300. package/dist/types/post-v1-video-to-video-response401.js +5 -0
  301. package/dist/types/post-v1-video-to-video-response404-message-enum.d.ts +6 -0
  302. package/dist/types/post-v1-video-to-video-response404-message-enum.js +10 -0
  303. package/dist/types/post-v1-video-to-video-response404.d.ts +7 -0
  304. package/dist/types/post-v1-video-to-video-response404.js +5 -0
  305. package/dist/types/post-v1-video-to-video-response422.d.ts +6 -0
  306. package/dist/types/post-v1-video-to-video-response422.js +5 -0
  307. package/package.json +37 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Magic Hour AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+
2
+ # Magic Hour API Typescript SDK
3
+
4
+
5
+ ## Overview
6
+
7
+ # Introduction
8
+
9
+ Magic Hour provides an API (beta) that can be integrated into your own application to generate videos using AI.
10
+
11
+ Webhook documentation can be found [here](https://magichour.ai/docs/webhook).
12
+
13
+ If you have any questions, please reach out to us via [discord](https://discord.gg/JX5rgsZaJp).
14
+
15
+ # Authentication
16
+
17
+ Every request requires an API key.
18
+
19
+ To get started, first generate your API key [here](https://magichour.ai/settings/developer).
20
+
21
+ Then, add the `Authorization` header to the request.
22
+
23
+ | Key | Value |
24
+ |-|-|
25
+ | Authorization | Bearer mhk_live_apikey |
26
+
27
+ > **Warning**: any API call that renders a video will utilize frames in your account.
28
+
29
+
30
+
31
+ ### Example Client Initialization
32
+
33
+ ```typescript
34
+ import Client from "magic-hour";
35
+
36
+ const client = new Client({ token: process.env["API_TOKEN"]!! });
37
+ ```
38
+
39
+ ### SDK Usage
40
+ See [SDK Examples](SDK_EXAMPLES.md) for example usage of all SDK functionality
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Generated by Sideko (sideko.dev)
3
+ **/
4
+ import { CoreClient } from "./core";
5
+ import { Environment } from "./environment";
6
+ import { V1Client } from "./resources/v1";
7
+ export interface ClientOptions {
8
+ baseUrl?: string;
9
+ environment?: Environment;
10
+ timeout?: number;
11
+ token?: string;
12
+ }
13
+ export declare class Client {
14
+ protected _client: CoreClient;
15
+ v1: V1Client;
16
+ constructor(opts?: ClientOptions);
17
+ }
package/dist/client.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ /**
3
+ * Generated by Sideko (sideko.dev)
4
+ **/
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Client = void 0;
7
+ const core_1 = require("./core");
8
+ const environment_1 = require("./environment");
9
+ const v1_1 = require("./resources/v1");
10
+ class Client {
11
+ constructor(opts) {
12
+ var _a, _b;
13
+ const baseUrl = (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.baseUrl) !== null && _a !== void 0 ? _a : opts === null || opts === void 0 ? void 0 : opts.environment) !== null && _b !== void 0 ? _b : environment_1.Environment.Environment;
14
+ this._client = new core_1.CoreClient({ baseUrl, timeout: opts === null || opts === void 0 ? void 0 : opts.timeout });
15
+ this._client.registerAuth("bearerAuth", new core_1.AuthBearer(opts === null || opts === void 0 ? void 0 : opts.token));
16
+ this.v1 = new v1_1.V1Client(this._client);
17
+ }
18
+ }
19
+ exports.Client = Client;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generated by Sideko (sideko.dev)
3
+ **/
4
+ import { RequestConfig } from "./core-client";
5
+ export declare class ApiError extends Error {
6
+ request: RequestConfig;
7
+ response: Response;
8
+ constructor(request: RequestConfig, response: Response);
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /**
3
+ * Generated by Sideko (sideko.dev)
4
+ **/
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ApiError = void 0;
7
+ class ApiError extends Error {
8
+ constructor(request, response) {
9
+ super(`${response.status} was returned from ${request.method} ${request.path}`);
10
+ this.request = request;
11
+ this.response = response;
12
+ }
13
+ }
14
+ exports.ApiError = ApiError;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Generated by Sideko (sideko.dev)
3
+ **/
4
+ import { Response as NodeResponse } from "node-fetch";
5
+ import { ResponseType } from "./core-client";
6
+ export interface ApiPromiseProps {
7
+ response: Response | NodeResponse;
8
+ responseType: ResponseType | undefined;
9
+ }
10
+ export declare class ApiPromise<T> extends Promise<T> {
11
+ private responsePromise;
12
+ constructor(responsePromise: Promise<ApiPromiseProps>);
13
+ /**
14
+ * Gets the raw response as rentured by `fetch` rather than automatically
15
+ * parsing the response.
16
+ */
17
+ asResponse(): Promise<Response | NodeResponse>;
18
+ private parseResponse;
19
+ then<Result1 = T, Result2 = never>(onfulfilled?: ((value: T) => Result1 | PromiseLike<Result1>) | undefined | null, onrejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
20
+ catch<Result = never>(onrejected?: ((reason: any) => Result | PromiseLike<Result>) | undefined | null): Promise<T | Result>;
21
+ finally(onfinally?: (() => void) | undefined | null): Promise<T>;
22
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /**
3
+ * Generated by Sideko (sideko.dev)
4
+ **/
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ApiPromise = void 0;
16
+ const binary_response_1 = require("./binary-response");
17
+ class ApiPromise extends Promise {
18
+ constructor(responsePromise) {
19
+ super((resolve) => {
20
+ // left purposely as a no-op to avoid automatically parsing the response
21
+ // body. Instead, .then, .catch, and .finally overridden to explicitly
22
+ // parse the response
23
+ resolve(null);
24
+ });
25
+ this.responsePromise = responsePromise;
26
+ }
27
+ /**
28
+ * Gets the raw response as rentured by `fetch` rather than automatically
29
+ * parsing the response.
30
+ */
31
+ asResponse() {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ return (yield this.responsePromise).response;
34
+ });
35
+ }
36
+ parseResponse() {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const { response, responseType } = yield this.responsePromise;
39
+ const contentType = response.headers.get("content-type");
40
+ if (response.status === 204) {
41
+ return null;
42
+ }
43
+ else if (responseType === "blob") {
44
+ return new binary_response_1.BinaryResponse(yield response.blob(), contentType);
45
+ }
46
+ // use a pattern to match json content type to handle
47
+ // base case of application/json as well as vendor specfic
48
+ // headers e.g. application/vnd.github+json
49
+ const jsonPattern = /application\/.*json/g;
50
+ if (contentType === null || contentType === void 0 ? void 0 : contentType.match(jsonPattern)) {
51
+ return (yield response.json());
52
+ }
53
+ // fall back on text
54
+ return (yield response.text());
55
+ });
56
+ }
57
+ then(onfulfilled, onrejected) {
58
+ return this.parseResponse().then(onfulfilled, onrejected);
59
+ }
60
+ catch(onrejected) {
61
+ return this.parseResponse().catch(onrejected);
62
+ }
63
+ finally(onfinally) {
64
+ return this.parseResponse().finally(onfinally);
65
+ }
66
+ }
67
+ exports.ApiPromise = ApiPromise;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Generated by Sideko (sideko.dev)
3
+ **/
4
+ import { RequestConfig } from "./core-client";
5
+ export interface AuthProvider {
6
+ applyAuth(cfg: RequestConfig): RequestConfig;
7
+ }
8
+ export declare class AuthBasic implements AuthProvider {
9
+ username: string | null;
10
+ password: string | null;
11
+ constructor(username?: string, password?: string);
12
+ applyAuth(cfg: RequestConfig): RequestConfig;
13
+ }
14
+ export declare class AuthBearer implements AuthProvider {
15
+ token: string | null;
16
+ constructor(token?: string);
17
+ applyAuth(cfg: RequestConfig): RequestConfig;
18
+ }
19
+ export declare class AuthKeyQuery implements AuthProvider {
20
+ name: string;
21
+ key: string | null;
22
+ constructor(name: string, key?: string);
23
+ applyAuth(cfg: RequestConfig): RequestConfig;
24
+ }
25
+ export declare class AuthKeyHeader implements AuthProvider {
26
+ name: string;
27
+ key: string | null;
28
+ constructor(name: string, key?: string);
29
+ applyAuth(cfg: RequestConfig): RequestConfig;
30
+ }
31
+ export declare class AuthCookieHeader implements AuthProvider {
32
+ name: string;
33
+ key: string | null;
34
+ constructor(name: string, key?: string);
35
+ applyAuth(cfg: RequestConfig): RequestConfig;
36
+ }
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ /**
3
+ * Generated by Sideko (sideko.dev)
4
+ **/
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AuthCookieHeader = exports.AuthKeyHeader = exports.AuthKeyQuery = exports.AuthBearer = exports.AuthBasic = void 0;
10
+ const qs_1 = __importDefault(require("qs"));
11
+ const js_base64_1 = require("js-base64");
12
+ const runtime_1 = require("./runtime");
13
+ const AUTHORIZATION = "Authorization";
14
+ const COOKIE = "Cookie";
15
+ class AuthBasic {
16
+ constructor(username, password) {
17
+ this.username = username !== null && username !== void 0 ? username : null;
18
+ this.password = password !== null && password !== void 0 ? password : null;
19
+ }
20
+ applyAuth(cfg) {
21
+ var _a;
22
+ if (this.username !== null && this.password !== null) {
23
+ const headers = (_a = cfg.headers) !== null && _a !== void 0 ? _a : {};
24
+ const encoded = (0, js_base64_1.toBase64)(`${this.username}:${this.password}`);
25
+ headers[AUTHORIZATION] = `Basic ${encoded}`;
26
+ cfg.headers = headers;
27
+ }
28
+ return cfg;
29
+ }
30
+ }
31
+ exports.AuthBasic = AuthBasic;
32
+ class AuthBearer {
33
+ constructor(token) {
34
+ this.token = token !== null && token !== void 0 ? token : null;
35
+ }
36
+ applyAuth(cfg) {
37
+ var _a;
38
+ if (this.token !== null) {
39
+ const headers = (_a = cfg.headers) !== null && _a !== void 0 ? _a : {};
40
+ headers[AUTHORIZATION] = `Bearer ${this.token}`;
41
+ cfg.headers = headers;
42
+ }
43
+ return cfg;
44
+ }
45
+ }
46
+ exports.AuthBearer = AuthBearer;
47
+ class AuthKeyQuery {
48
+ constructor(name, key) {
49
+ this.name = name;
50
+ this.key = key !== null && key !== void 0 ? key : null;
51
+ }
52
+ applyAuth(cfg) {
53
+ var _a;
54
+ if (this.key !== null) {
55
+ const query = (_a = cfg.query) !== null && _a !== void 0 ? _a : [];
56
+ query.push(qs_1.default.stringify({ [this.name]: this.key }));
57
+ cfg.query = query;
58
+ }
59
+ return cfg;
60
+ }
61
+ }
62
+ exports.AuthKeyQuery = AuthKeyQuery;
63
+ class AuthKeyHeader {
64
+ constructor(name, key) {
65
+ this.name = name;
66
+ this.key = key !== null && key !== void 0 ? key : null;
67
+ }
68
+ applyAuth(cfg) {
69
+ var _a;
70
+ if (this.key !== null) {
71
+ const headers = (_a = cfg.headers) !== null && _a !== void 0 ? _a : {};
72
+ headers[this.name] = this.key;
73
+ cfg.headers = headers;
74
+ }
75
+ return cfg;
76
+ }
77
+ }
78
+ exports.AuthKeyHeader = AuthKeyHeader;
79
+ class AuthCookieHeader {
80
+ constructor(name, key) {
81
+ this.name = name;
82
+ this.key = key !== null && key !== void 0 ? key : null;
83
+ }
84
+ applyAuth(cfg) {
85
+ var _a, _b;
86
+ if (runtime_1.RUNTIME.type === "browser") {
87
+ cfg.withCredentials = true;
88
+ }
89
+ else if (this.key !== null) {
90
+ const headers = (_a = cfg.headers) !== null && _a !== void 0 ? _a : {};
91
+ const cookies = (_b = headers[COOKIE]) !== null && _b !== void 0 ? _b : "";
92
+ headers[COOKIE] = `${cookies.length > 0 ? ";" : ""}${this.name}=${this.key}`;
93
+ cfg.headers = headers;
94
+ }
95
+ return cfg;
96
+ }
97
+ }
98
+ exports.AuthCookieHeader = AuthCookieHeader;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generated by Sideko (sideko.dev)
3
+ **/
4
+ import { Blob as NodeBlob } from "node-fetch";
5
+ export declare class BinaryResponse {
6
+ content: Blob | NodeBlob;
7
+ contentType: string | null;
8
+ constructor(content: Blob | NodeBlob, contentType: string | null);
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ /**
3
+ * Generated by Sideko (sideko.dev)
4
+ **/
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BinaryResponse = void 0;
7
+ class BinaryResponse {
8
+ constructor(content, contentType) {
9
+ this.content = content;
10
+ this.contentType = contentType;
11
+ }
12
+ }
13
+ exports.BinaryResponse = BinaryResponse;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generated by Sideko (sideko.dev)
3
+ **/
4
+ export declare const JSON_PATTERN: RegExp;
5
+ export declare const TEXT_PATTERN: RegExp;
6
+ export declare const MULTIPART_FORM = "multipart/form-data";
7
+ export declare const URL_FORM = "application/x-www-form-urlencoded";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * Generated by Sideko (sideko.dev)
4
+ **/
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.URL_FORM = exports.MULTIPART_FORM = exports.TEXT_PATTERN = exports.JSON_PATTERN = void 0;
7
+ // use a pattern to match json content type to handle
8
+ // base case of application/json as well as vendor specfic
9
+ // headers e.g. application/vnd.github+json
10
+ exports.JSON_PATTERN = /application\/.*json/g;
11
+ // use a pattern to match text types to handle base case
12
+ // of text/plain as well as more specfic cases e.g. text/html
13
+ exports.TEXT_PATTERN = /text\/.+/g;
14
+ exports.MULTIPART_FORM = "multipart/form-data";
15
+ exports.URL_FORM = "application/x-www-form-urlencoded";
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Generated by Sideko (sideko.dev)
3
+ **/
4
+ import { AuthProvider } from "./auth";
5
+ import { ApiPromise } from "./api-promise";
6
+ export interface CoreClientProps {
7
+ baseUrl: string;
8
+ timeout?: number | undefined;
9
+ }
10
+ export declare type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
11
+ export declare type ResponseType = "json" | "blob" | "unknown";
12
+ export declare type RequestConfig = {
13
+ method: HttpMethod;
14
+ path: string;
15
+ responseType: ResponseType;
16
+ auth?: string[];
17
+ query?: string[];
18
+ body?: any;
19
+ contentType?: string;
20
+ headers?: Record<string, string>;
21
+ opts?: RequestOptions | undefined;
22
+ withCredentials?: boolean;
23
+ };
24
+ export interface RequestOptions {
25
+ timeout?: number;
26
+ additionalHeaders?: Record<string, string>;
27
+ additionalQuery?: Record<string, string>;
28
+ }
29
+ export declare class CoreClient {
30
+ baseUrl: string;
31
+ private auths;
32
+ private timeout;
33
+ constructor(props: CoreClientProps);
34
+ registerAuth(name: string, provider: AuthProvider): void;
35
+ private applyAuths;
36
+ private buildUrl;
37
+ private applyHeaders;
38
+ private encodeBodyByContentType;
39
+ private buildRequestInit;
40
+ private request;
41
+ makeRequest<R>(cfg: RequestConfig): ApiPromise<R>;
42
+ }
43
+ export declare class CoreResourceClient {
44
+ protected _client: CoreClient;
45
+ constructor(client: CoreClient);
46
+ }
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ /**
3
+ * Generated by Sideko (sideko.dev)
4
+ **/
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CoreResourceClient = exports.CoreClient = void 0;
19
+ const form_urlencoded_1 = __importDefault(require("form-urlencoded"));
20
+ const runtime_1 = require("./runtime");
21
+ const api_promise_1 = require("./api-promise");
22
+ const api_error_1 = require("./api-error");
23
+ const form_data_1 = require("./form-data");
24
+ const content_type_1 = require("./content-type");
25
+ class CoreClient {
26
+ // private agent: any // TODO
27
+ constructor(props) {
28
+ this.baseUrl = props.baseUrl;
29
+ this.auths = {};
30
+ this.timeout = props.timeout;
31
+ }
32
+ registerAuth(name, provider) {
33
+ this.auths[name] = provider;
34
+ }
35
+ applyAuths(cfg) {
36
+ var _a;
37
+ for (const name of (_a = cfg.auth) !== null && _a !== void 0 ? _a : []) {
38
+ const provider = this.auths[name];
39
+ if (provider) {
40
+ cfg = provider.applyAuth(cfg);
41
+ }
42
+ }
43
+ return cfg;
44
+ }
45
+ buildUrl(cfg) {
46
+ var _a, _b, _c;
47
+ const base = this.baseUrl.endsWith("/")
48
+ ? this.baseUrl.slice(0, -1)
49
+ : this.baseUrl;
50
+ const path = cfg.path.startsWith("/") ? cfg.path.slice(1) : cfg.path;
51
+ let url = `${base}/${path}`;
52
+ const searchParams = new URLSearchParams(((_a = cfg.query) !== null && _a !== void 0 ? _a : []).join("&"));
53
+ for (const [key, val] of Object.entries((_c = (_b = cfg.opts) === null || _b === void 0 ? void 0 : _b.additionalQuery) !== null && _c !== void 0 ? _c : {})) {
54
+ searchParams.append(key, val);
55
+ }
56
+ if (searchParams.toString().length > 0) {
57
+ url += `?${searchParams.toString()}`;
58
+ }
59
+ return url;
60
+ }
61
+ applyHeaders(cfg, reqInit) {
62
+ var _a, _b, _c;
63
+ const finalHeaders = Object.assign(Object.assign(Object.assign(Object.assign({ "x-sideko-sdk-language": "Javascript", "x-sideko-runtime": runtime_1.RUNTIME.type }, ((_a = reqInit.headers) !== null && _a !== void 0 ? _a : {})), ((_b = cfg.headers) !== null && _b !== void 0 ? _b : {})), (cfg.contentType ? { "content-type": cfg.contentType } : {})), (_c = cfg.opts) === null || _c === void 0 ? void 0 : _c.additionalHeaders);
64
+ reqInit.headers = finalHeaders;
65
+ return reqInit;
66
+ }
67
+ encodeBodyByContentType(cfg, reqInit) {
68
+ var _a, _b, _c, _d, _e, _f, _g;
69
+ const contentTypeOverride = (_c = (_b = (_a = cfg.opts) === null || _a === void 0 ? void 0 : _a.additionalHeaders) === null || _b === void 0 ? void 0 : _b["content-type"]) !== null && _c !== void 0 ? _c : (_e = (_d = cfg.opts) === null || _d === void 0 ? void 0 : _d.additionalHeaders) === null || _e === void 0 ? void 0 : _e["Content-Type"];
70
+ const contentType = (_f = contentTypeOverride !== null && contentTypeOverride !== void 0 ? contentTypeOverride : cfg.contentType) !== null && _f !== void 0 ? _f : "";
71
+ if (typeof cfg.body === "undefined") {
72
+ return reqInit;
73
+ }
74
+ else if (contentType.match(content_type_1.JSON_PATTERN)) {
75
+ reqInit.body = JSON.stringify(cfg.body);
76
+ }
77
+ else if (contentType.match(content_type_1.TEXT_PATTERN)) {
78
+ reqInit.body = String(cfg.body);
79
+ }
80
+ else if (contentType === content_type_1.MULTIPART_FORM) {
81
+ // encode form
82
+ const form = (0, form_data_1.createForm)(cfg.body);
83
+ const headers = (_g = reqInit.headers) !== null && _g !== void 0 ? _g : {};
84
+ if (runtime_1.RUNTIME.type === "node") {
85
+ // explicitly set boundary
86
+ headers["content-type"] = `${content_type_1.MULTIPART_FORM}; boundary=${form.getBoundary()}`;
87
+ }
88
+ else {
89
+ // the browser should automatically set the content type
90
+ delete headers["content-type"];
91
+ }
92
+ reqInit.headers = headers;
93
+ reqInit.body = form;
94
+ }
95
+ else if (contentType === content_type_1.URL_FORM) {
96
+ reqInit.body = (0, form_urlencoded_1.default)(cfg.body);
97
+ }
98
+ else {
99
+ // we expect body to already be encoded in the correct fashion
100
+ reqInit.body = cfg.body;
101
+ }
102
+ return reqInit;
103
+ }
104
+ buildRequestInit(cfg) {
105
+ let reqInit = { method: cfg.method.toUpperCase() };
106
+ reqInit = this.applyHeaders(cfg, reqInit);
107
+ reqInit = this.encodeBodyByContentType(cfg, reqInit);
108
+ if (cfg.withCredentials) {
109
+ reqInit.credentials = "include";
110
+ }
111
+ return reqInit;
112
+ }
113
+ request(cfg) {
114
+ var _a, _b;
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ const fetcherFn = runtime_1.RUNTIME.type === "node" || typeof fetch !== "function"
117
+ ? require("node-fetch").default
118
+ : fetch;
119
+ cfg = this.applyAuths(cfg);
120
+ const reqInit = this.buildRequestInit(cfg);
121
+ const url = this.buildUrl(cfg);
122
+ const timeout = (_b = (_a = cfg.opts) === null || _a === void 0 ? void 0 : _a.timeout) !== null && _b !== void 0 ? _b : this.timeout;
123
+ const controller = new AbortController();
124
+ let timeoutId;
125
+ if (typeof timeout !== "undefined") {
126
+ timeoutId = setTimeout(() => controller.abort(), timeout);
127
+ }
128
+ reqInit.signal = controller.signal;
129
+ const response = yield fetcherFn(url, reqInit);
130
+ if (timeoutId) {
131
+ clearTimeout(timeoutId);
132
+ }
133
+ if (!response.ok) {
134
+ throw new api_error_1.ApiError(cfg, response);
135
+ }
136
+ return { response, responseType: cfg.responseType };
137
+ });
138
+ }
139
+ makeRequest(cfg) {
140
+ return new api_promise_1.ApiPromise(this.request(cfg));
141
+ }
142
+ }
143
+ exports.CoreClient = CoreClient;
144
+ class CoreResourceClient {
145
+ constructor(client) {
146
+ this._client = client;
147
+ }
148
+ }
149
+ exports.CoreResourceClient = CoreResourceClient;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Generated by Sideko (sideko.dev)
3
+ **/
4
+ /// <reference types="node" />
5
+ import { type ReadStream as NodeReadStream } from "node:fs";
6
+ export declare type UploadFile = FileLike | NodeReadStream;
7
+ export declare function isUploadFile(val: any): val is UploadFile;
8
+ export declare function isNodeReadStream(val: any): val is NodeReadStream;
9
+ /**
10
+ * Defines common File spec compatible with modern browser File, node-fetch, etc.
11
+ */
12
+ export interface FileLike extends BlobLike {
13
+ lastModified: number;
14
+ name: string;
15
+ }
16
+ export declare function isFileLike(val: any): val is FileLike;
17
+ /**
18
+ * Defines common Blob spec compatible with modern browser Blob, fetch-blob, etc.
19
+ */
20
+ export interface BlobLike {
21
+ type: string;
22
+ size: number;
23
+ slice(start?: number, end?: number, type?: string): BlobLike;
24
+ text(): Promise<string>;
25
+ arrayBuffer(): Promise<ArrayBuffer>;
26
+ }
27
+ export declare function isBlobLike(val: any): val is BlobLike;
28
+ export declare function createForm(data: {
29
+ [key: string]: unknown;
30
+ }): any;