@aurora-interactive/fankare-api-sdk 0.0.1

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 (513) hide show
  1. package/FUNCTIONS.md +90 -0
  2. package/README.md +455 -0
  3. package/RUNTIMES.md +48 -0
  4. package/esm/core.d.ts +10 -0
  5. package/esm/core.d.ts.map +1 -0
  6. package/esm/core.js +13 -0
  7. package/esm/core.js.map +1 -0
  8. package/esm/funcs/authentication-login-user.d.ts +15 -0
  9. package/esm/funcs/authentication-login-user.d.ts.map +1 -0
  10. package/esm/funcs/authentication-login-user.js +78 -0
  11. package/esm/funcs/authentication-login-user.js.map +1 -0
  12. package/esm/funcs/authentication-register-user.d.ts +14 -0
  13. package/esm/funcs/authentication-register-user.d.ts.map +1 -0
  14. package/esm/funcs/authentication-register-user.js +77 -0
  15. package/esm/funcs/authentication-register-user.js.map +1 -0
  16. package/esm/funcs/custom-lists-add-list-member.d.ts +14 -0
  17. package/esm/funcs/custom-lists-add-list-member.d.ts.map +1 -0
  18. package/esm/funcs/custom-lists-add-list-member.js +87 -0
  19. package/esm/funcs/custom-lists-add-list-member.js.map +1 -0
  20. package/esm/funcs/custom-lists-create-list.d.ts +15 -0
  21. package/esm/funcs/custom-lists-create-list.d.ts.map +1 -0
  22. package/esm/funcs/custom-lists-create-list.js +78 -0
  23. package/esm/funcs/custom-lists-create-list.js.map +1 -0
  24. package/esm/funcs/custom-lists-get-list-members.d.ts +14 -0
  25. package/esm/funcs/custom-lists-get-list-members.d.ts.map +1 -0
  26. package/esm/funcs/custom-lists-get-list-members.js +86 -0
  27. package/esm/funcs/custom-lists-get-list-members.js.map +1 -0
  28. package/esm/funcs/custom-lists-get-lists.d.ts +14 -0
  29. package/esm/funcs/custom-lists-get-lists.d.ts.map +1 -0
  30. package/esm/funcs/custom-lists-get-lists.js +67 -0
  31. package/esm/funcs/custom-lists-get-lists.js.map +1 -0
  32. package/esm/funcs/custom-lists-remove-list-member.d.ts +13 -0
  33. package/esm/funcs/custom-lists-remove-list-member.d.ts.map +1 -0
  34. package/esm/funcs/custom-lists-remove-list-member.js +90 -0
  35. package/esm/funcs/custom-lists-remove-list-member.js.map +1 -0
  36. package/esm/funcs/posts-create-post.d.ts +18 -0
  37. package/esm/funcs/posts-create-post.d.ts.map +1 -0
  38. package/esm/funcs/posts-create-post.js +81 -0
  39. package/esm/funcs/posts-create-post.js.map +1 -0
  40. package/esm/funcs/posts-get-feed.d.ts +17 -0
  41. package/esm/funcs/posts-get-feed.d.ts.map +1 -0
  42. package/esm/funcs/posts-get-feed.js +88 -0
  43. package/esm/funcs/posts-get-feed.js.map +1 -0
  44. package/esm/funcs/posts-get-list-feed.d.ts +14 -0
  45. package/esm/funcs/posts-get-list-feed.d.ts.map +1 -0
  46. package/esm/funcs/posts-get-list-feed.js +91 -0
  47. package/esm/funcs/posts-get-list-feed.js.map +1 -0
  48. package/esm/funcs/subscriptions-subscribe-to-user.d.ts +13 -0
  49. package/esm/funcs/subscriptions-subscribe-to-user.d.ts.map +1 -0
  50. package/esm/funcs/subscriptions-subscribe-to-user.js +85 -0
  51. package/esm/funcs/subscriptions-subscribe-to-user.js.map +1 -0
  52. package/esm/funcs/subscriptions-unsubscribe-from-user.d.ts +13 -0
  53. package/esm/funcs/subscriptions-unsubscribe-from-user.d.ts.map +1 -0
  54. package/esm/funcs/subscriptions-unsubscribe-from-user.js +85 -0
  55. package/esm/funcs/subscriptions-unsubscribe-from-user.js.map +1 -0
  56. package/esm/hooks/hooks.d.ts +25 -0
  57. package/esm/hooks/hooks.d.ts.map +1 -0
  58. package/esm/hooks/hooks.js +80 -0
  59. package/esm/hooks/hooks.js.map +1 -0
  60. package/esm/hooks/index.d.ts +3 -0
  61. package/esm/hooks/index.d.ts.map +1 -0
  62. package/esm/hooks/index.js +6 -0
  63. package/esm/hooks/index.js.map +1 -0
  64. package/esm/hooks/types.d.ts +77 -0
  65. package/esm/hooks/types.d.ts.map +1 -0
  66. package/esm/hooks/types.js +5 -0
  67. package/esm/hooks/types.js.map +1 -0
  68. package/esm/index.d.ts +6 -0
  69. package/esm/index.d.ts.map +1 -0
  70. package/esm/index.js +8 -0
  71. package/esm/index.js.map +1 -0
  72. package/esm/lib/base64.d.ts +10 -0
  73. package/esm/lib/base64.d.ts.map +1 -0
  74. package/esm/lib/base64.js +31 -0
  75. package/esm/lib/base64.js.map +1 -0
  76. package/esm/lib/config.d.ts +38 -0
  77. package/esm/lib/config.d.ts.map +1 -0
  78. package/esm/lib/config.js +34 -0
  79. package/esm/lib/config.js.map +1 -0
  80. package/esm/lib/encodings.d.ts +54 -0
  81. package/esm/lib/encodings.d.ts.map +1 -0
  82. package/esm/lib/encodings.js +391 -0
  83. package/esm/lib/encodings.js.map +1 -0
  84. package/esm/lib/files.d.ts +26 -0
  85. package/esm/lib/files.d.ts.map +1 -0
  86. package/esm/lib/files.js +91 -0
  87. package/esm/lib/files.js.map +1 -0
  88. package/esm/lib/http.d.ts +67 -0
  89. package/esm/lib/http.d.ts.map +1 -0
  90. package/esm/lib/http.js +209 -0
  91. package/esm/lib/http.js.map +1 -0
  92. package/esm/lib/logger.d.ts +6 -0
  93. package/esm/lib/logger.d.ts.map +1 -0
  94. package/esm/lib/logger.js +5 -0
  95. package/esm/lib/logger.js.map +1 -0
  96. package/esm/lib/matchers.d.ts +59 -0
  97. package/esm/lib/matchers.d.ts.map +1 -0
  98. package/esm/lib/matchers.js +202 -0
  99. package/esm/lib/matchers.js.map +1 -0
  100. package/esm/lib/primitives.d.ts +27 -0
  101. package/esm/lib/primitives.d.ts.map +1 -0
  102. package/esm/lib/primitives.js +120 -0
  103. package/esm/lib/primitives.js.map +1 -0
  104. package/esm/lib/retries.d.ts +38 -0
  105. package/esm/lib/retries.d.ts.map +1 -0
  106. package/esm/lib/retries.js +157 -0
  107. package/esm/lib/retries.js.map +1 -0
  108. package/esm/lib/schemas.d.ts +21 -0
  109. package/esm/lib/schemas.d.ts.map +1 -0
  110. package/esm/lib/schemas.js +57 -0
  111. package/esm/lib/schemas.js.map +1 -0
  112. package/esm/lib/sdks.d.ts +63 -0
  113. package/esm/lib/sdks.d.ts.map +1 -0
  114. package/esm/lib/sdks.js +290 -0
  115. package/esm/lib/sdks.js.map +1 -0
  116. package/esm/lib/security.d.ts +83 -0
  117. package/esm/lib/security.d.ts.map +1 -0
  118. package/esm/lib/security.js +148 -0
  119. package/esm/lib/security.js.map +1 -0
  120. package/esm/lib/url.d.ts +5 -0
  121. package/esm/lib/url.d.ts.map +1 -0
  122. package/esm/lib/url.js +24 -0
  123. package/esm/lib/url.js.map +1 -0
  124. package/esm/models/create-post-request.d.ts +22 -0
  125. package/esm/models/create-post-request.d.ts.map +1 -0
  126. package/esm/models/create-post-request.js +19 -0
  127. package/esm/models/create-post-request.js.map +1 -0
  128. package/esm/models/custom-list.d.ts +12 -0
  129. package/esm/models/custom-list.d.ts.map +1 -0
  130. package/esm/models/custom-list.js +17 -0
  131. package/esm/models/custom-list.js.map +1 -0
  132. package/esm/models/errors/fankare-sdk-default-error.d.ts +10 -0
  133. package/esm/models/errors/fankare-sdk-default-error.d.ts.map +1 -0
  134. package/esm/models/errors/fankare-sdk-default-error.js +30 -0
  135. package/esm/models/errors/fankare-sdk-default-error.js.map +1 -0
  136. package/esm/models/errors/fankare-sdk-error.d.ts +19 -0
  137. package/esm/models/errors/fankare-sdk-error.d.ts.map +1 -0
  138. package/esm/models/errors/fankare-sdk-error.js +26 -0
  139. package/esm/models/errors/fankare-sdk-error.js.map +1 -0
  140. package/esm/models/errors/http-client-errors.d.ts +44 -0
  141. package/esm/models/errors/http-client-errors.d.ts.map +1 -0
  142. package/esm/models/errors/http-client-errors.js +56 -0
  143. package/esm/models/errors/http-client-errors.js.map +1 -0
  144. package/esm/models/errors/index.d.ts +6 -0
  145. package/esm/models/errors/index.d.ts.map +1 -0
  146. package/esm/models/errors/index.js +9 -0
  147. package/esm/models/errors/index.js.map +1 -0
  148. package/esm/models/errors/response-validation-error.d.ts +26 -0
  149. package/esm/models/errors/response-validation-error.d.ts.map +1 -0
  150. package/esm/models/errors/response-validation-error.js +37 -0
  151. package/esm/models/errors/response-validation-error.js.map +1 -0
  152. package/esm/models/errors/sdk-validation-error.d.ts +21 -0
  153. package/esm/models/errors/sdk-validation-error.d.ts.map +1 -0
  154. package/esm/models/errors/sdk-validation-error.js +52 -0
  155. package/esm/models/errors/sdk-validation-error.js.map +1 -0
  156. package/esm/models/index.d.ts +8 -0
  157. package/esm/models/index.d.ts.map +1 -0
  158. package/esm/models/index.js +11 -0
  159. package/esm/models/index.js.map +1 -0
  160. package/esm/models/login-request.d.ts +14 -0
  161. package/esm/models/login-request.d.ts.map +1 -0
  162. package/esm/models/login-request.js +13 -0
  163. package/esm/models/login-request.js.map +1 -0
  164. package/esm/models/operations/add-list-member.d.ts +24 -0
  165. package/esm/models/operations/add-list-member.d.ts.map +1 -0
  166. package/esm/models/operations/add-list-member.js +20 -0
  167. package/esm/models/operations/add-list-member.js.map +1 -0
  168. package/esm/models/operations/create-list.d.ts +12 -0
  169. package/esm/models/operations/create-list.d.ts.map +1 -0
  170. package/esm/models/operations/create-list.js +12 -0
  171. package/esm/models/operations/create-list.js.map +1 -0
  172. package/esm/models/operations/create-post.d.ts +17 -0
  173. package/esm/models/operations/create-post.d.ts.map +1 -0
  174. package/esm/models/operations/create-post.js +15 -0
  175. package/esm/models/operations/create-post.js.map +1 -0
  176. package/esm/models/operations/get-feed.d.ts +30 -0
  177. package/esm/models/operations/get-feed.d.ts.map +1 -0
  178. package/esm/models/operations/get-feed.js +24 -0
  179. package/esm/models/operations/get-feed.js.map +1 -0
  180. package/esm/models/operations/get-list-feed.d.ts +14 -0
  181. package/esm/models/operations/get-list-feed.d.ts.map +1 -0
  182. package/esm/models/operations/get-list-feed.js +13 -0
  183. package/esm/models/operations/get-list-feed.js.map +1 -0
  184. package/esm/models/operations/get-list-members.d.ts +12 -0
  185. package/esm/models/operations/get-list-members.d.ts.map +1 -0
  186. package/esm/models/operations/get-list-members.js +12 -0
  187. package/esm/models/operations/get-list-members.js.map +1 -0
  188. package/esm/models/operations/index.d.ts +11 -0
  189. package/esm/models/operations/index.d.ts.map +1 -0
  190. package/esm/models/operations/index.js +14 -0
  191. package/esm/models/operations/index.js.map +1 -0
  192. package/esm/models/operations/login-user.d.ts +18 -0
  193. package/esm/models/operations/login-user.d.ts.map +1 -0
  194. package/esm/models/operations/login-user.js +16 -0
  195. package/esm/models/operations/login-user.js.map +1 -0
  196. package/esm/models/operations/remove-list-member.d.ts +17 -0
  197. package/esm/models/operations/remove-list-member.d.ts.map +1 -0
  198. package/esm/models/operations/remove-list-member.js +13 -0
  199. package/esm/models/operations/remove-list-member.js.map +1 -0
  200. package/esm/models/operations/subscribe-to-user.d.ts +15 -0
  201. package/esm/models/operations/subscribe-to-user.d.ts.map +1 -0
  202. package/esm/models/operations/subscribe-to-user.js +12 -0
  203. package/esm/models/operations/subscribe-to-user.js.map +1 -0
  204. package/esm/models/operations/unsubscribe-from-user.d.ts +15 -0
  205. package/esm/models/operations/unsubscribe-from-user.d.ts.map +1 -0
  206. package/esm/models/operations/unsubscribe-from-user.js +12 -0
  207. package/esm/models/operations/unsubscribe-from-user.js.map +1 -0
  208. package/esm/models/post.d.ts +44 -0
  209. package/esm/models/post.d.ts.map +1 -0
  210. package/esm/models/post.js +38 -0
  211. package/esm/models/post.js.map +1 -0
  212. package/esm/models/register-request.d.ts +16 -0
  213. package/esm/models/register-request.d.ts.map +1 -0
  214. package/esm/models/register-request.js +14 -0
  215. package/esm/models/register-request.js.map +1 -0
  216. package/esm/models/security.d.ts +12 -0
  217. package/esm/models/security.d.ts.map +1 -0
  218. package/esm/models/security.js +17 -0
  219. package/esm/models/security.js.map +1 -0
  220. package/esm/models/user.d.ts +13 -0
  221. package/esm/models/user.d.ts.map +1 -0
  222. package/esm/models/user.js +17 -0
  223. package/esm/models/user.js.map +1 -0
  224. package/esm/sdk/authentication.d.ts +14 -0
  225. package/esm/sdk/authentication.d.ts.map +1 -0
  226. package/esm/sdk/authentication.js +22 -0
  227. package/esm/sdk/authentication.js.map +1 -0
  228. package/esm/sdk/custom-lists.d.ts +26 -0
  229. package/esm/sdk/custom-lists.d.ts.map +1 -0
  230. package/esm/sdk/custom-lists.js +43 -0
  231. package/esm/sdk/custom-lists.js.map +1 -0
  232. package/esm/sdk/index.d.ts +2 -0
  233. package/esm/sdk/index.d.ts.map +1 -0
  234. package/esm/sdk/index.js +5 -0
  235. package/esm/sdk/index.js.map +1 -0
  236. package/esm/sdk/posts.d.ts +24 -0
  237. package/esm/sdk/posts.d.ts.map +1 -0
  238. package/esm/sdk/posts.js +35 -0
  239. package/esm/sdk/posts.js.map +1 -0
  240. package/esm/sdk/sdk.d.ts +16 -0
  241. package/esm/sdk/sdk.d.ts.map +1 -0
  242. package/esm/sdk/sdk.js +27 -0
  243. package/esm/sdk/sdk.js.map +1 -0
  244. package/esm/sdk/subscriptions.d.ts +12 -0
  245. package/esm/sdk/subscriptions.d.ts.map +1 -0
  246. package/esm/sdk/subscriptions.js +22 -0
  247. package/esm/sdk/subscriptions.js.map +1 -0
  248. package/esm/types/async.d.ts +23 -0
  249. package/esm/types/async.d.ts.map +1 -0
  250. package/esm/types/async.js +28 -0
  251. package/esm/types/async.js.map +1 -0
  252. package/esm/types/blobs.d.ts +4 -0
  253. package/esm/types/blobs.d.ts.map +1 -0
  254. package/esm/types/blobs.js +25 -0
  255. package/esm/types/blobs.js.map +1 -0
  256. package/esm/types/const-date-time.d.ts +3 -0
  257. package/esm/types/const-date-time.d.ts.map +1 -0
  258. package/esm/types/const-date-time.js +10 -0
  259. package/esm/types/const-date-time.js.map +1 -0
  260. package/esm/types/default-to-zero-value.d.ts +12 -0
  261. package/esm/types/default-to-zero-value.d.ts.map +1 -0
  262. package/esm/types/default-to-zero-value.js +31 -0
  263. package/esm/types/default-to-zero-value.js.map +1 -0
  264. package/esm/types/enums.d.ts +9 -0
  265. package/esm/types/enums.d.ts.map +1 -0
  266. package/esm/types/enums.js +27 -0
  267. package/esm/types/enums.js.map +1 -0
  268. package/esm/types/fp.d.ts +31 -0
  269. package/esm/types/fp.d.ts.map +1 -0
  270. package/esm/types/fp.js +31 -0
  271. package/esm/types/fp.js.map +1 -0
  272. package/esm/types/index.d.ts +10 -0
  273. package/esm/types/index.d.ts.map +1 -0
  274. package/esm/types/index.js +10 -0
  275. package/esm/types/index.js.map +1 -0
  276. package/esm/types/operations.d.ts +27 -0
  277. package/esm/types/operations.d.ts.map +1 -0
  278. package/esm/types/operations.js +77 -0
  279. package/esm/types/operations.js.map +1 -0
  280. package/esm/types/primitives.d.ts +9 -0
  281. package/esm/types/primitives.d.ts.map +1 -0
  282. package/esm/types/primitives.js +109 -0
  283. package/esm/types/primitives.js.map +1 -0
  284. package/esm/types/rfcdate.d.ts +21 -0
  285. package/esm/types/rfcdate.d.ts.map +1 -0
  286. package/esm/types/rfcdate.js +43 -0
  287. package/esm/types/rfcdate.js.map +1 -0
  288. package/esm/types/smart-union.d.ts +7 -0
  289. package/esm/types/smart-union.d.ts.map +1 -0
  290. package/esm/types/smart-union.js +117 -0
  291. package/esm/types/smart-union.js.map +1 -0
  292. package/esm/types/streams.d.ts +2 -0
  293. package/esm/types/streams.d.ts.map +1 -0
  294. package/esm/types/streams.js +15 -0
  295. package/esm/types/streams.js.map +1 -0
  296. package/esm/types/unrecognized.d.ts +16 -0
  297. package/esm/types/unrecognized.d.ts.map +1 -0
  298. package/esm/types/unrecognized.js +31 -0
  299. package/esm/types/unrecognized.js.map +1 -0
  300. package/examples/authenticationRegisterUser.example.ts +29 -0
  301. package/examples/node_modules/@types/node/assert/strict.d.ts +8 -0
  302. package/examples/node_modules/@types/node/assert.d.ts +1062 -0
  303. package/examples/node_modules/@types/node/async_hooks.d.ts +605 -0
  304. package/examples/node_modules/@types/node/buffer.buffer.d.ts +471 -0
  305. package/examples/node_modules/@types/node/buffer.d.ts +1936 -0
  306. package/examples/node_modules/@types/node/child_process.d.ts +1475 -0
  307. package/examples/node_modules/@types/node/cluster.d.ts +577 -0
  308. package/examples/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
  309. package/examples/node_modules/@types/node/compatibility/index.d.ts +9 -0
  310. package/examples/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
  311. package/examples/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  312. package/examples/node_modules/@types/node/console.d.ts +452 -0
  313. package/examples/node_modules/@types/node/constants.d.ts +21 -0
  314. package/examples/node_modules/@types/node/crypto.d.ts +4590 -0
  315. package/examples/node_modules/@types/node/dgram.d.ts +597 -0
  316. package/examples/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
  317. package/examples/node_modules/@types/node/dns/promises.d.ts +479 -0
  318. package/examples/node_modules/@types/node/dns.d.ts +871 -0
  319. package/examples/node_modules/@types/node/domain.d.ts +170 -0
  320. package/examples/node_modules/@types/node/events.d.ts +977 -0
  321. package/examples/node_modules/@types/node/fs/promises.d.ts +1270 -0
  322. package/examples/node_modules/@types/node/fs.d.ts +4375 -0
  323. package/examples/node_modules/@types/node/globals.d.ts +172 -0
  324. package/examples/node_modules/@types/node/globals.typedarray.d.ts +38 -0
  325. package/examples/node_modules/@types/node/http.d.ts +2049 -0
  326. package/examples/node_modules/@types/node/http2.d.ts +2712 -0
  327. package/examples/node_modules/@types/node/https.d.ts +578 -0
  328. package/examples/node_modules/@types/node/index.d.ts +93 -0
  329. package/examples/node_modules/@types/node/inspector.generated.d.ts +3966 -0
  330. package/examples/node_modules/@types/node/module.d.ts +539 -0
  331. package/examples/node_modules/@types/node/net.d.ts +1031 -0
  332. package/examples/node_modules/@types/node/os.d.ts +506 -0
  333. package/examples/node_modules/@types/node/path.d.ts +200 -0
  334. package/examples/node_modules/@types/node/perf_hooks.d.ts +961 -0
  335. package/examples/node_modules/@types/node/process.d.ts +1961 -0
  336. package/examples/node_modules/@types/node/punycode.d.ts +117 -0
  337. package/examples/node_modules/@types/node/querystring.d.ts +152 -0
  338. package/examples/node_modules/@types/node/readline/promises.d.ts +162 -0
  339. package/examples/node_modules/@types/node/readline.d.ts +589 -0
  340. package/examples/node_modules/@types/node/repl.d.ts +430 -0
  341. package/examples/node_modules/@types/node/sea.d.ts +153 -0
  342. package/examples/node_modules/@types/node/stream/consumers.d.ts +38 -0
  343. package/examples/node_modules/@types/node/stream/promises.d.ts +90 -0
  344. package/examples/node_modules/@types/node/stream/web.d.ts +533 -0
  345. package/examples/node_modules/@types/node/stream.d.ts +1698 -0
  346. package/examples/node_modules/@types/node/string_decoder.d.ts +67 -0
  347. package/examples/node_modules/@types/node/test.d.ts +1787 -0
  348. package/examples/node_modules/@types/node/timers/promises.d.ts +108 -0
  349. package/examples/node_modules/@types/node/timers.d.ts +286 -0
  350. package/examples/node_modules/@types/node/tls.d.ts +1259 -0
  351. package/examples/node_modules/@types/node/trace_events.d.ts +197 -0
  352. package/examples/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
  353. package/examples/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
  354. package/examples/node_modules/@types/node/ts5.6/index.d.ts +93 -0
  355. package/examples/node_modules/@types/node/tty.d.ts +208 -0
  356. package/examples/node_modules/@types/node/url.d.ts +964 -0
  357. package/examples/node_modules/@types/node/util.d.ts +2331 -0
  358. package/examples/node_modules/@types/node/v8.d.ts +809 -0
  359. package/examples/node_modules/@types/node/vm.d.ts +1001 -0
  360. package/examples/node_modules/@types/node/wasi.d.ts +181 -0
  361. package/examples/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  362. package/examples/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  363. package/examples/node_modules/@types/node/web-globals/events.d.ts +97 -0
  364. package/examples/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
  365. package/examples/node_modules/@types/node/worker_threads.d.ts +715 -0
  366. package/examples/node_modules/@types/node/zlib.d.ts +598 -0
  367. package/examples/node_modules/dotenv/config.d.ts +1 -0
  368. package/examples/node_modules/dotenv/config.js +9 -0
  369. package/examples/node_modules/dotenv/lib/cli-options.js +17 -0
  370. package/examples/node_modules/dotenv/lib/env-options.js +28 -0
  371. package/examples/node_modules/dotenv/lib/main.d.ts +162 -0
  372. package/examples/node_modules/dotenv/lib/main.js +386 -0
  373. package/examples/node_modules/esbuild/install.js +300 -0
  374. package/examples/node_modules/esbuild/lib/main.d.ts +716 -0
  375. package/examples/node_modules/esbuild/lib/main.js +2532 -0
  376. package/examples/node_modules/fsevents/fsevents.d.ts +46 -0
  377. package/examples/node_modules/fsevents/fsevents.js +83 -0
  378. package/examples/node_modules/tsx/dist/cjs/api/index.mjs +1 -0
  379. package/examples/node_modules/tsx/dist/cjs/index.mjs +1 -0
  380. package/examples/node_modules/tsx/dist/cli.mjs +55 -0
  381. package/examples/node_modules/tsx/dist/client-D_mPDF5S.mjs +1 -0
  382. package/examples/node_modules/tsx/dist/esm/api/index.mjs +1 -0
  383. package/examples/node_modules/tsx/dist/esm/index.mjs +1 -0
  384. package/examples/node_modules/tsx/dist/get-pipe-path-_tAJyU_v.mjs +1 -0
  385. package/examples/node_modules/tsx/dist/index-XurvG3JN.mjs +14 -0
  386. package/examples/node_modules/tsx/dist/index-gbaejti9.mjs +1 -0
  387. package/examples/node_modules/tsx/dist/lexer-DQCqS3nf.mjs +3 -0
  388. package/examples/node_modules/tsx/dist/loader.mjs +1 -0
  389. package/examples/node_modules/tsx/dist/node-features-B9BBLzwu.mjs +1 -0
  390. package/examples/node_modules/tsx/dist/package-Bj47PlGH.mjs +1 -0
  391. package/examples/node_modules/tsx/dist/patch-repl.mjs +1 -0
  392. package/examples/node_modules/tsx/dist/preflight.mjs +1 -0
  393. package/examples/node_modules/tsx/dist/register-BnTWPeIB.mjs +10 -0
  394. package/examples/node_modules/tsx/dist/register-CqMfTiWi.mjs +2 -0
  395. package/examples/node_modules/tsx/dist/repl.mjs +3 -0
  396. package/examples/node_modules/tsx/dist/require-DzmC1hVr.mjs +1 -0
  397. package/examples/node_modules/tsx/dist/suppress-warnings.mjs +1 -0
  398. package/examples/node_modules/tsx/dist/temporary-directory-BDDVQOvU.mjs +1 -0
  399. package/examples/node_modules/tsx/dist/types-Cxp8y2TL.d.ts +5 -0
  400. package/examples/node_modules/undici-types/agent.d.ts +31 -0
  401. package/examples/node_modules/undici-types/api.d.ts +43 -0
  402. package/examples/node_modules/undici-types/balanced-pool.d.ts +29 -0
  403. package/examples/node_modules/undici-types/cache.d.ts +36 -0
  404. package/examples/node_modules/undici-types/client.d.ts +108 -0
  405. package/examples/node_modules/undici-types/connector.d.ts +34 -0
  406. package/examples/node_modules/undici-types/content-type.d.ts +21 -0
  407. package/examples/node_modules/undici-types/cookies.d.ts +28 -0
  408. package/examples/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
  409. package/examples/node_modules/undici-types/dispatcher.d.ts +256 -0
  410. package/examples/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
  411. package/examples/node_modules/undici-types/errors.d.ts +149 -0
  412. package/examples/node_modules/undici-types/eventsource.d.ts +61 -0
  413. package/examples/node_modules/undici-types/fetch.d.ts +209 -0
  414. package/examples/node_modules/undici-types/file.d.ts +39 -0
  415. package/examples/node_modules/undici-types/filereader.d.ts +54 -0
  416. package/examples/node_modules/undici-types/formdata.d.ts +108 -0
  417. package/examples/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  418. package/examples/node_modules/undici-types/global-origin.d.ts +7 -0
  419. package/examples/node_modules/undici-types/handlers.d.ts +15 -0
  420. package/examples/node_modules/undici-types/header.d.ts +4 -0
  421. package/examples/node_modules/undici-types/index.d.ts +71 -0
  422. package/examples/node_modules/undici-types/interceptors.d.ts +17 -0
  423. package/examples/node_modules/undici-types/mock-agent.d.ts +50 -0
  424. package/examples/node_modules/undici-types/mock-client.d.ts +25 -0
  425. package/examples/node_modules/undici-types/mock-errors.d.ts +12 -0
  426. package/examples/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  427. package/examples/node_modules/undici-types/mock-pool.d.ts +25 -0
  428. package/examples/node_modules/undici-types/patch.d.ts +33 -0
  429. package/examples/node_modules/undici-types/pool-stats.d.ts +19 -0
  430. package/examples/node_modules/undici-types/pool.d.ts +39 -0
  431. package/examples/node_modules/undici-types/proxy-agent.d.ts +28 -0
  432. package/examples/node_modules/undici-types/readable.d.ts +65 -0
  433. package/examples/node_modules/undici-types/retry-agent.d.ts +8 -0
  434. package/examples/node_modules/undici-types/retry-handler.d.ts +116 -0
  435. package/examples/node_modules/undici-types/util.d.ts +18 -0
  436. package/examples/node_modules/undici-types/webidl.d.ts +228 -0
  437. package/examples/node_modules/undici-types/websocket.d.ts +150 -0
  438. package/jsr.json +27 -0
  439. package/package.json +62 -0
  440. package/src/core.ts +13 -0
  441. package/src/funcs/authentication-login-user.ts +161 -0
  442. package/src/funcs/authentication-register-user.ts +160 -0
  443. package/src/funcs/custom-lists-add-list-member.ts +174 -0
  444. package/src/funcs/custom-lists-create-list.ts +161 -0
  445. package/src/funcs/custom-lists-get-list-members.ts +170 -0
  446. package/src/funcs/custom-lists-get-lists.ts +142 -0
  447. package/src/funcs/custom-lists-remove-list-member.ts +179 -0
  448. package/src/funcs/posts-create-post.ts +164 -0
  449. package/src/funcs/posts-get-feed.ts +177 -0
  450. package/src/funcs/posts-get-list-feed.ts +179 -0
  451. package/src/funcs/subscriptions-subscribe-to-user.ts +169 -0
  452. package/src/funcs/subscriptions-unsubscribe-from-user.ts +170 -0
  453. package/src/hooks/hooks.ts +129 -0
  454. package/src/hooks/index.ts +6 -0
  455. package/src/hooks/types.ts +108 -0
  456. package/src/index.ts +9 -0
  457. package/src/lib/base64.ts +39 -0
  458. package/src/lib/config.ts +67 -0
  459. package/src/lib/encodings.ts +529 -0
  460. package/src/lib/files.ts +104 -0
  461. package/src/lib/http.ts +323 -0
  462. package/src/lib/logger.ts +9 -0
  463. package/src/lib/matchers.ts +353 -0
  464. package/src/lib/primitives.ts +166 -0
  465. package/src/lib/retries.ts +226 -0
  466. package/src/lib/schemas.ts +94 -0
  467. package/src/lib/sdks.ts +438 -0
  468. package/src/lib/security.ts +274 -0
  469. package/src/lib/url.ts +35 -0
  470. package/src/models/create-post-request.ts +47 -0
  471. package/src/models/custom-list.ts +33 -0
  472. package/src/models/errors/fankare-sdk-default-error.ts +40 -0
  473. package/src/models/errors/fankare-sdk-error.ts +35 -0
  474. package/src/models/errors/http-client-errors.ts +62 -0
  475. package/src/models/errors/index.ts +9 -0
  476. package/src/models/errors/response-validation-error.ts +50 -0
  477. package/src/models/errors/sdk-validation-error.ts +54 -0
  478. package/src/models/index.ts +11 -0
  479. package/src/models/login-request.ts +29 -0
  480. package/src/models/operations/add-list-member.ts +58 -0
  481. package/src/models/operations/create-list.ts +30 -0
  482. package/src/models/operations/create-post.ts +39 -0
  483. package/src/models/operations/get-feed.ts +64 -0
  484. package/src/models/operations/get-list-feed.ts +33 -0
  485. package/src/models/operations/get-list-members.ts +30 -0
  486. package/src/models/operations/index.ts +14 -0
  487. package/src/models/operations/login-user.ts +40 -0
  488. package/src/models/operations/remove-list-member.ts +36 -0
  489. package/src/models/operations/subscribe-to-user.ts +33 -0
  490. package/src/models/operations/unsubscribe-from-user.ts +33 -0
  491. package/src/models/post.ts +77 -0
  492. package/src/models/register-request.ts +34 -0
  493. package/src/models/security.ts +34 -0
  494. package/src/models/user.ts +34 -0
  495. package/src/sdk/authentication.ts +40 -0
  496. package/src/sdk/custom-lists.ts +87 -0
  497. package/src/sdk/index.ts +5 -0
  498. package/src/sdk/posts.ts +65 -0
  499. package/src/sdk/sdk.ts +31 -0
  500. package/src/sdk/subscriptions.ts +38 -0
  501. package/src/types/async.ts +69 -0
  502. package/src/types/blobs.ts +33 -0
  503. package/src/types/const-date-time.ts +15 -0
  504. package/src/types/default-to-zero-value.ts +33 -0
  505. package/src/types/enums.ts +45 -0
  506. package/src/types/fp.ts +50 -0
  507. package/src/types/index.ts +13 -0
  508. package/src/types/operations.ts +105 -0
  509. package/src/types/primitives.ts +140 -0
  510. package/src/types/rfcdate.ts +54 -0
  511. package/src/types/smart-union.ts +153 -0
  512. package/src/types/streams.ts +21 -0
  513. package/src/types/unrecognized.ts +35 -0
@@ -0,0 +1,438 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { SDKHooks } from "../hooks/hooks.js";
6
+ import { HookContext } from "../hooks/types.js";
7
+ import {
8
+ ConnectionError,
9
+ InvalidRequestError,
10
+ RequestAbortedError,
11
+ RequestTimeoutError,
12
+ UnexpectedClientError,
13
+ } from "../models/errors/http-client-errors.js";
14
+ import { ERR, OK, Result } from "../types/fp.js";
15
+ import { stringToBase64 } from "./base64.js";
16
+ import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "./config.js";
17
+ import { encodeForm } from "./encodings.js";
18
+ import {
19
+ HTTPClient,
20
+ isAbortError,
21
+ isConnectionError,
22
+ isTimeoutError,
23
+ matchContentType,
24
+ } from "./http.js";
25
+ import { Logger } from "./logger.js";
26
+ import { combineSignals } from "./primitives.js";
27
+ import { retry, RetryConfig } from "./retries.js";
28
+ import { SecurityState } from "./security.js";
29
+
30
+ export type RequestOptions = {
31
+ /**
32
+ * Sets a timeout, in milliseconds, on HTTP requests made by an SDK method. If
33
+ * `fetchOptions.signal` is set then it will take precedence over this option.
34
+ */
35
+ timeoutMs?: number;
36
+ /**
37
+ * Set or override a retry policy on HTTP calls.
38
+ */
39
+ retries?: RetryConfig;
40
+ /**
41
+ * Specifies the status codes which should be retried using the given retry policy.
42
+ */
43
+ retryCodes?: string[];
44
+ /**
45
+ * Overrides the base server URL that will be used by an operation.
46
+ */
47
+ serverURL?: string | URL;
48
+ /**
49
+ * @deprecated `fetchOptions` has been flattened into `RequestOptions`.
50
+ *
51
+ * Sets various request options on the `fetch` call made by an SDK method.
52
+ *
53
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options|Request}
54
+ */
55
+ fetchOptions?: Omit<RequestInit, "method" | "body">;
56
+ } & Omit<RequestInit, "method" | "body">;
57
+
58
+ type RequestConfig = {
59
+ method: string;
60
+ path: string;
61
+ baseURL?: string | URL | undefined;
62
+ query?: string;
63
+ body?: RequestInit["body"];
64
+ headers?: HeadersInit;
65
+ security?: SecurityState | null;
66
+ uaHeader?: string;
67
+ userAgent?: string | undefined;
68
+ timeoutMs?: number;
69
+ };
70
+
71
+ const gt: unknown = typeof globalThis === "undefined" ? null : globalThis;
72
+ const webWorkerLike = typeof gt === "object"
73
+ && gt != null
74
+ && "importScripts" in gt
75
+ && typeof gt["importScripts"] === "function";
76
+ const isBrowserLike = webWorkerLike
77
+ || (typeof navigator !== "undefined" && "serviceWorker" in navigator)
78
+ || (typeof window === "object" && typeof window.document !== "undefined");
79
+
80
+ export class ClientSDK {
81
+ readonly #httpClient: HTTPClient;
82
+ readonly #hooks: SDKHooks;
83
+ readonly #logger?: Logger | undefined;
84
+ public readonly _baseURL: URL | null;
85
+ public readonly _options: SDKOptions & { hooks?: SDKHooks };
86
+
87
+ constructor(options: SDKOptions = {}) {
88
+ const opt = options as unknown;
89
+ if (
90
+ typeof opt === "object"
91
+ && opt != null
92
+ && "hooks" in opt
93
+ && opt.hooks instanceof SDKHooks
94
+ ) {
95
+ this.#hooks = opt.hooks;
96
+ } else {
97
+ this.#hooks = new SDKHooks();
98
+ }
99
+ const defaultHttpClient = new HTTPClient();
100
+ options.httpClient = options.httpClient || defaultHttpClient;
101
+ options = this.#hooks.sdkInit(options);
102
+
103
+ const url = serverURLFromOptions(options);
104
+ if (url) {
105
+ url.pathname = url.pathname.replace(/\/+$/, "") + "/";
106
+ }
107
+ this._baseURL = url;
108
+ this.#httpClient = options.httpClient || defaultHttpClient;
109
+
110
+ this._options = { ...options, hooks: this.#hooks };
111
+
112
+ this.#logger = this._options.debugLogger;
113
+ }
114
+
115
+ public _createRequest(
116
+ context: HookContext,
117
+ conf: RequestConfig,
118
+ options?: RequestOptions,
119
+ ): Result<Request, InvalidRequestError | UnexpectedClientError> {
120
+ const { method, path, query, headers: opHeaders, security } = conf;
121
+
122
+ const base = conf.baseURL ?? this._baseURL;
123
+ if (!base) {
124
+ return ERR(new InvalidRequestError("No base URL provided for operation"));
125
+ }
126
+ const baseURL = new URL(base);
127
+ let reqURL: URL;
128
+ if (path) {
129
+ baseURL.pathname = baseURL.pathname.replace(/\/+$/, "") + "/";
130
+ reqURL = new URL(path, baseURL);
131
+ if (!reqURL.search && baseURL.search) {
132
+ reqURL.search = baseURL.search;
133
+ }
134
+ } else {
135
+ reqURL = baseURL;
136
+ }
137
+ reqURL.hash = "";
138
+
139
+ // Appends already-encoded query pairs to a query string, replacing any
140
+ // existing pairs with the same key so later sources take precedence.
141
+ const mergeQuery = (current: string, additions: string): string => {
142
+ if (!additions) {
143
+ return current;
144
+ }
145
+ const additionKeys = new Set(
146
+ additions
147
+ .split("&")
148
+ .filter((pair) => pair !== "")
149
+ .map((pair) => pair.split("=")[0] ?? ""),
150
+ );
151
+ const kept = current.split("&").filter((pair) => {
152
+ return pair !== "" && !additionKeys.has(pair.split("=")[0] ?? "");
153
+ });
154
+ return [...kept, additions].join("&");
155
+ };
156
+
157
+ const encodeQueryRecord = (record: Record<string, unknown>): string => {
158
+ return Object.entries(record)
159
+ .map(([k, v]) => {
160
+ if (v == null) {
161
+ return undefined;
162
+ }
163
+ const value = v;
164
+ return encodeForm(k, value, {
165
+ explode: Array.isArray(value),
166
+ charEncoding: "percent",
167
+ });
168
+ })
169
+ .filter((pair): pair is string => typeof pair !== "undefined")
170
+ .join("&");
171
+ };
172
+
173
+ const finalQuery = [
174
+ query || "",
175
+ encodeQueryRecord(security?.queryParams || {}),
176
+ ].reduce(mergeQuery, reqURL.search.slice(1));
177
+
178
+ if (finalQuery) {
179
+ reqURL.search = `?${finalQuery}`;
180
+ }
181
+
182
+ const headers = new Headers(opHeaders);
183
+
184
+ const username = security?.basic.username;
185
+ const password = security?.basic.password;
186
+ if (username != null || password != null) {
187
+ const encoded = stringToBase64(
188
+ [username || "", password || ""].join(":"),
189
+ );
190
+ headers.set("Authorization", `Basic ${encoded}`);
191
+ }
192
+
193
+ const securityHeaders = new Headers(security?.headers || {});
194
+ for (const [k, v] of securityHeaders) {
195
+ headers.set(k, v);
196
+ }
197
+
198
+ let cookie = headers.get("cookie") || "";
199
+ for (const [k, v] of Object.entries(security?.cookies || {})) {
200
+ cookie += `; ${k}=${v}`;
201
+ }
202
+ cookie = cookie.startsWith("; ") ? cookie.slice(2) : cookie;
203
+ headers.set("cookie", cookie);
204
+
205
+ const userHeaders = new Headers(
206
+ options?.headers ?? options?.fetchOptions?.headers,
207
+ );
208
+ for (const [k, v] of userHeaders) {
209
+ headers.set(k, v);
210
+ }
211
+
212
+ // Only set user agent header in non-browser-like environments since CORS
213
+ // policy disallows setting it in browsers e.g. Chrome throws an error.
214
+ if (!isBrowserLike) {
215
+ headers.set(
216
+ conf.uaHeader ?? "user-agent",
217
+ conf.userAgent ?? SDK_METADATA.userAgent,
218
+ );
219
+ }
220
+
221
+ const fetchOptions: Omit<RequestInit, "method" | "body"> = {
222
+ ...options?.fetchOptions,
223
+ ...options,
224
+ };
225
+ if (!fetchOptions?.signal && conf.timeoutMs != null && conf.timeoutMs > 0) {
226
+ context.timeoutMs = conf.timeoutMs;
227
+ }
228
+
229
+ if (conf.body instanceof ReadableStream) {
230
+ Object.assign(fetchOptions, { duplex: "half" });
231
+ }
232
+
233
+ let input;
234
+ try {
235
+ input = this.#hooks.beforeCreateRequest(context, {
236
+ url: reqURL,
237
+ options: {
238
+ ...fetchOptions,
239
+ body: conf.body ?? null,
240
+ headers,
241
+ method,
242
+ },
243
+ });
244
+ } catch (err: unknown) {
245
+ return ERR(
246
+ new UnexpectedClientError("Create request hook failed to execute", {
247
+ cause: err,
248
+ }),
249
+ );
250
+ }
251
+
252
+ return OK(new Request(input.url, input.options));
253
+ }
254
+
255
+ public async _do(
256
+ request: Request,
257
+ options: {
258
+ context: HookContext;
259
+ isErrorStatusCode: (statusCode: number) => boolean;
260
+ retryConfig: RetryConfig;
261
+ retryCodes: string[];
262
+ },
263
+ ): Promise<
264
+ Result<
265
+ Response,
266
+ | RequestAbortedError
267
+ | RequestTimeoutError
268
+ | ConnectionError
269
+ | UnexpectedClientError
270
+ >
271
+ > {
272
+ const { context, isErrorStatusCode } = options;
273
+ const timeoutMs = context.timeoutMs;
274
+
275
+ return retry(
276
+ async () => {
277
+ const cloned = request.clone();
278
+ let attempt = cloned;
279
+ if (timeoutMs != null && timeoutMs > 0) {
280
+ const timeoutSignal = AbortSignal.timeout(timeoutMs);
281
+ const combined = combineSignals(cloned.signal, timeoutSignal)
282
+ ?? timeoutSignal;
283
+ attempt = new Request(cloned, { signal: combined });
284
+ }
285
+ const req = await this.#hooks.beforeRequest(context, attempt);
286
+ await logRequest(this.#logger, req).catch((e) =>
287
+ this.#logger?.log("Failed to log request:", e)
288
+ );
289
+
290
+ let response = await this.#httpClient.request(req);
291
+
292
+ try {
293
+ if (isErrorStatusCode(response.status)) {
294
+ const result = await this.#hooks.afterError(
295
+ context,
296
+ response,
297
+ null,
298
+ );
299
+ if (result.error) {
300
+ throw result.error;
301
+ }
302
+ response = result.response || response;
303
+ } else {
304
+ response = await this.#hooks.afterSuccess(context, response);
305
+ }
306
+ } finally {
307
+ await logResponse(this.#logger, response, req)
308
+ .catch(e => this.#logger?.log("Failed to log response:", e));
309
+ }
310
+
311
+ return response;
312
+ },
313
+ { config: options.retryConfig, statusCodes: options.retryCodes },
314
+ ).then(
315
+ (r) => OK(r),
316
+ (err) => {
317
+ switch (true) {
318
+ case isAbortError(err):
319
+ return ERR(
320
+ new RequestAbortedError("Request aborted by client", {
321
+ cause: err,
322
+ }),
323
+ );
324
+ case isTimeoutError(err):
325
+ return ERR(
326
+ new RequestTimeoutError("Request timed out", { cause: err }),
327
+ );
328
+ case isConnectionError(err):
329
+ return ERR(
330
+ new ConnectionError("Unable to make request", { cause: err }),
331
+ );
332
+ default:
333
+ return ERR(
334
+ new UnexpectedClientError("Unexpected HTTP client error", {
335
+ cause: err,
336
+ }),
337
+ );
338
+ }
339
+ },
340
+ );
341
+ }
342
+ }
343
+
344
+ const jsonLikeContentTypeRE = /^(application|text)\/([^+]+\+)*json.*/;
345
+ const jsonlLikeContentTypeRE =
346
+ /^(application|text)\/([^+]+\+)*(jsonl|x-ndjson)\b.*/;
347
+ async function logRequest(logger: Logger | undefined, req: Request) {
348
+ if (!logger) {
349
+ return;
350
+ }
351
+
352
+ const contentType = req.headers.get("content-type");
353
+ const ct = contentType?.split(";")[0] || "";
354
+
355
+ logger.group(`> Request: ${req.method} ${req.url}`);
356
+
357
+ logger.group("Headers:");
358
+ for (const [k, v] of req.headers.entries()) {
359
+ logger.log(`${k}: ${v}`);
360
+ }
361
+ logger.groupEnd();
362
+
363
+ logger.group("Body:");
364
+ switch (true) {
365
+ case jsonLikeContentTypeRE.test(ct):
366
+ logger.log(await req.clone().json());
367
+ break;
368
+ case ct.startsWith("text/"):
369
+ logger.log(await req.clone().text());
370
+ break;
371
+ case ct === "multipart/form-data": {
372
+ const body = await req.clone().formData();
373
+ for (const [k, v] of body) {
374
+ const vlabel = v instanceof Blob ? "<Blob>" : v;
375
+ logger.log(`${k}: ${vlabel}`);
376
+ }
377
+ break;
378
+ }
379
+ default:
380
+ logger.log(`<${contentType}>`);
381
+ break;
382
+ }
383
+ logger.groupEnd();
384
+
385
+ logger.groupEnd();
386
+ }
387
+
388
+ async function logResponse(
389
+ logger: Logger | undefined,
390
+ res: Response,
391
+ req: Request,
392
+ ) {
393
+ if (!logger) {
394
+ return;
395
+ }
396
+
397
+ const contentType = res.headers.get("content-type");
398
+ const ct = contentType?.split(";")[0] || "";
399
+
400
+ logger.group(`< Response: ${req.method} ${req.url}`);
401
+ logger.log("Status Code:", res.status, res.statusText);
402
+
403
+ logger.group("Headers:");
404
+ for (const [k, v] of res.headers.entries()) {
405
+ logger.log(`${k}: ${v}`);
406
+ }
407
+ logger.groupEnd();
408
+
409
+ logger.group("Body:");
410
+ switch (true) {
411
+ case matchContentType(res, "application/json")
412
+ || jsonLikeContentTypeRE.test(ct) && !jsonlLikeContentTypeRE.test(ct):
413
+ logger.log(await res.clone().json());
414
+ break;
415
+ case matchContentType(res, "application/jsonl")
416
+ || jsonlLikeContentTypeRE.test(ct):
417
+ case matchContentType(res, "text/event-stream"):
418
+ logger.log(`<${contentType}>`);
419
+ break;
420
+ case matchContentType(res, "text/*"):
421
+ logger.log(await res.clone().text());
422
+ break;
423
+ case matchContentType(res, "multipart/form-data"): {
424
+ const body = await res.clone().formData();
425
+ for (const [k, v] of body) {
426
+ const vlabel = v instanceof Blob ? "<Blob>" : v;
427
+ logger.log(`${k}: ${vlabel}`);
428
+ }
429
+ break;
430
+ }
431
+ default:
432
+ logger.log(`<${contentType}>`);
433
+ break;
434
+ }
435
+ logger.groupEnd();
436
+
437
+ logger.groupEnd();
438
+ }
@@ -0,0 +1,274 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as models from "../models/index.js";
6
+
7
+ type OAuth2PasswordFlow = {
8
+ username: string;
9
+ password: string;
10
+ clientID?: string | undefined;
11
+ clientSecret?: string | undefined;
12
+ tokenURL: string;
13
+ };
14
+
15
+ export enum SecurityErrorCode {
16
+ Incomplete = "incomplete",
17
+ UnrecognisedSecurityType = "unrecognized_security_type",
18
+ }
19
+
20
+ export class SecurityError extends Error {
21
+ constructor(
22
+ public code: SecurityErrorCode,
23
+ message: string,
24
+ ) {
25
+ super(message);
26
+ this.name = "SecurityError";
27
+ }
28
+
29
+ static incomplete(): SecurityError {
30
+ return new SecurityError(
31
+ SecurityErrorCode.Incomplete,
32
+ "Security requirements not met in order to perform the operation",
33
+ );
34
+ }
35
+ static unrecognizedType(type: string): SecurityError {
36
+ return new SecurityError(
37
+ SecurityErrorCode.UnrecognisedSecurityType,
38
+ `Unrecognised security type: ${type}`,
39
+ );
40
+ }
41
+ }
42
+
43
+ export type SecurityState = {
44
+ basic: { username?: string | undefined; password?: string | undefined };
45
+ headers: Record<string, string>;
46
+ queryParams: Record<string, string>;
47
+ cookies: Record<string, string>;
48
+ oauth2: ({ type: "password" } & OAuth2PasswordFlow) | { type: "none" };
49
+ };
50
+
51
+ type SecurityInputBasic = {
52
+ type: "http:basic";
53
+ value:
54
+ | { username?: string | undefined; password?: string | undefined }
55
+ | null
56
+ | undefined;
57
+ };
58
+
59
+ type SecurityInputBearer = {
60
+ type: "http:bearer";
61
+ value: string | null | undefined;
62
+ fieldName: string;
63
+ };
64
+
65
+ type SecurityInputAPIKey = {
66
+ type: "apiKey:header" | "apiKey:query" | "apiKey:cookie";
67
+ value: string | null | undefined;
68
+ fieldName: string;
69
+ };
70
+
71
+ type SecurityInputOIDC = {
72
+ type: "openIdConnect";
73
+ value: string | null | undefined;
74
+ fieldName: string;
75
+ };
76
+
77
+ type SecurityInputOAuth2 = {
78
+ type: "oauth2";
79
+ value: string | null | undefined;
80
+ fieldName: string;
81
+ };
82
+
83
+ type SecurityInputOAuth2ClientCredentials = {
84
+ type: "oauth2:client_credentials";
85
+ value:
86
+ | {
87
+ clientID?: string | undefined;
88
+ clientSecret?: string | undefined;
89
+ }
90
+ | null
91
+ | string
92
+ | undefined;
93
+ fieldName?: string;
94
+ };
95
+
96
+ type SecurityInputOAuth2PasswordCredentials = {
97
+ type: "oauth2:password";
98
+ value:
99
+ | string
100
+ | null
101
+ | undefined;
102
+ fieldName?: string;
103
+ };
104
+
105
+ type SecurityInputCustom = {
106
+ type: "http:custom";
107
+ value: any | null | undefined;
108
+ fieldName?: string;
109
+ };
110
+
111
+ export type SecurityInput =
112
+ | SecurityInputBasic
113
+ | SecurityInputBearer
114
+ | SecurityInputAPIKey
115
+ | SecurityInputOAuth2
116
+ | SecurityInputOAuth2ClientCredentials
117
+ | SecurityInputOAuth2PasswordCredentials
118
+ | SecurityInputOIDC
119
+ | SecurityInputCustom;
120
+
121
+ export function resolveSecurity(
122
+ ...options: SecurityInput[][]
123
+ ): SecurityState | null {
124
+ const state: SecurityState = {
125
+ basic: {},
126
+ headers: {},
127
+ queryParams: {},
128
+ cookies: {},
129
+ oauth2: { type: "none" },
130
+ };
131
+
132
+ const option = options.find((opts) => {
133
+ return opts.every((o) => {
134
+ if (o.value == null) {
135
+ return false;
136
+ } else if (o.type === "http:basic") {
137
+ return o.value.username != null || o.value.password != null;
138
+ } else if (o.type === "http:custom") {
139
+ return null;
140
+ } else if (o.type === "oauth2:password") {
141
+ return (
142
+ typeof o.value === "string" && !!o.value
143
+ );
144
+ } else if (o.type === "oauth2:client_credentials") {
145
+ if (typeof o.value == "string") {
146
+ return !!o.value;
147
+ }
148
+ return o.value.clientID != null || o.value.clientSecret != null;
149
+ } else if (typeof o.value === "string") {
150
+ return !!o.value;
151
+ } else {
152
+ throw new Error(
153
+ `Unrecognized security type: ${o.type} (value type: ${typeof o
154
+ .value})`,
155
+ );
156
+ }
157
+ });
158
+ });
159
+ if (option == null) {
160
+ return null;
161
+ }
162
+
163
+ option.forEach((spec) => {
164
+ if (spec.value == null) {
165
+ return;
166
+ }
167
+
168
+ const { type } = spec;
169
+
170
+ switch (type) {
171
+ case "apiKey:header":
172
+ state.headers[spec.fieldName] = spec.value;
173
+ break;
174
+ case "apiKey:query":
175
+ state.queryParams[spec.fieldName] = spec.value;
176
+ break;
177
+ case "apiKey:cookie":
178
+ state.cookies[spec.fieldName] = spec.value;
179
+ break;
180
+ case "http:basic":
181
+ applyBasic(state, spec);
182
+ break;
183
+ case "http:custom":
184
+ break;
185
+ case "http:bearer":
186
+ applyBearer(state, spec);
187
+ break;
188
+ case "oauth2":
189
+ applyBearer(state, spec);
190
+ break;
191
+ case "oauth2:password":
192
+ applyBearer(state, spec);
193
+ break;
194
+ case "oauth2:client_credentials":
195
+ break;
196
+ case "openIdConnect":
197
+ applyBearer(state, spec);
198
+ break;
199
+ default:
200
+ throw SecurityError.unrecognizedType((spec satisfies never, type));
201
+ }
202
+ });
203
+
204
+ return state;
205
+ }
206
+
207
+ function applyBasic(
208
+ state: SecurityState,
209
+ spec: SecurityInputBasic,
210
+ ) {
211
+ if (spec.value == null) {
212
+ return;
213
+ }
214
+
215
+ state.basic = spec.value;
216
+ }
217
+
218
+ function applyBearer(
219
+ state: SecurityState,
220
+ spec:
221
+ | SecurityInputBearer
222
+ | SecurityInputOAuth2
223
+ | SecurityInputOIDC
224
+ | SecurityInputOAuth2PasswordCredentials,
225
+ ) {
226
+ if (typeof spec.value !== "string" || !spec.value) {
227
+ return;
228
+ }
229
+
230
+ let value = spec.value;
231
+ if (value.slice(0, 7).toLowerCase() !== "bearer ") {
232
+ value = `Bearer ${value}`;
233
+ }
234
+
235
+ if (spec.fieldName !== undefined) {
236
+ state.headers[spec.fieldName] = value;
237
+ }
238
+ }
239
+
240
+ export function resolveGlobalSecurity(
241
+ security: Partial<models.Security> | null | undefined,
242
+ allowedFields?: number[],
243
+ ): SecurityState | null {
244
+ let inputs: SecurityInput[][] = [
245
+ [
246
+ {
247
+ fieldName: "Authorization",
248
+ type: "http:bearer",
249
+ value: security?.bearerAuth,
250
+ },
251
+ ],
252
+ ];
253
+
254
+ if (allowedFields) {
255
+ inputs = allowedFields.map((i) => {
256
+ if (i < 0 || i >= inputs.length) {
257
+ throw new RangeError(`invalid allowedFields index ${i}`);
258
+ }
259
+ return inputs[i]!;
260
+ });
261
+ }
262
+
263
+ return resolveSecurity(...inputs);
264
+ }
265
+
266
+ export async function extractSecurity<
267
+ T extends string | Record<string, unknown>,
268
+ >(sec: T | (() => Promise<T>) | undefined): Promise<T | undefined> {
269
+ if (sec == null) {
270
+ return;
271
+ }
272
+
273
+ return typeof sec === "function" ? sec() : sec;
274
+ }