@outfoxx/sunday 1.1.0-beta.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (423) hide show
  1. package/README.md +2 -0
  2. package/build/date-time-types.d.ts +35 -0
  3. package/build/date-time-types.js +699 -0
  4. package/build/date-time-types.js.map +1 -0
  5. package/build/{esm/event-parser.d.ts → event-parser.d.ts} +1 -1
  6. package/build/{esm/event-parser.js → event-parser.js} +10 -12
  7. package/build/event-parser.js.map +1 -0
  8. package/build/{esm/fetch-event-source.d.ts → fetch-event-source.d.ts} +26 -18
  9. package/build/fetch-event-source.js +365 -0
  10. package/build/fetch-event-source.js.map +1 -0
  11. package/build/{esnext/fetch-request-factory.d.ts → fetch-request-factory.d.ts} +18 -20
  12. package/build/fetch-request-factory.js +316 -0
  13. package/build/fetch-request-factory.js.map +1 -0
  14. package/build/fetch.d.ts +9 -0
  15. package/build/fetch.js +140 -0
  16. package/build/fetch.js.map +1 -0
  17. package/build/{esnext/header-parameters.js → header-parameters.js} +31 -2
  18. package/build/header-parameters.js.map +1 -0
  19. package/build/index.d.ts +26 -0
  20. package/build/index.js +41 -0
  21. package/build/index.js.map +1 -0
  22. package/build/{main/logger.d.ts → logger.d.ts} +9 -0
  23. package/build/logger.js +36 -0
  24. package/build/logger.js.map +1 -0
  25. package/build/media-type-codecs/any-text-decoder.d.ts +7 -0
  26. package/build/{esnext/media-type-codecs/binary-encoder.js → media-type-codecs/any-text-decoder.js} +13 -10
  27. package/build/media-type-codecs/any-text-decoder.js.map +1 -0
  28. package/build/media-type-codecs/any-text-encoder.d.ts +6 -0
  29. package/build/{esm/media-type-codecs → media-type-codecs}/any-text-encoder.js +9 -5
  30. package/build/media-type-codecs/any-text-encoder.js.map +1 -0
  31. package/build/media-type-codecs/binary-decoder.d.ts +7 -0
  32. package/build/media-type-codecs/binary-decoder.js +33 -0
  33. package/build/media-type-codecs/binary-decoder.js.map +1 -0
  34. package/build/media-type-codecs/binary-encoder.d.ts +6 -0
  35. package/build/{esm/media-type-codecs → media-type-codecs}/binary-encoder.js +12 -8
  36. package/build/media-type-codecs/binary-encoder.js.map +1 -0
  37. package/build/media-type-codecs/cbor-decoder.d.ts +13 -0
  38. package/build/media-type-codecs/cbor-decoder.js +38 -0
  39. package/build/media-type-codecs/cbor-decoder.js.map +1 -0
  40. package/build/media-type-codecs/cbor-encoder.d.ts +12 -0
  41. package/build/media-type-codecs/cbor-encoder.js +36 -0
  42. package/build/media-type-codecs/cbor-encoder.js.map +1 -0
  43. package/build/{esm/media-type-codecs → media-type-codecs}/cbor-tags.d.ts +2 -0
  44. package/build/{esnext/media-type-codecs → media-type-codecs}/cbor-tags.js +2 -0
  45. package/build/media-type-codecs/cbor-tags.js.map +1 -0
  46. package/build/media-type-codecs/default-policies.d.ts +3 -0
  47. package/build/media-type-codecs/default-policies.js +33 -0
  48. package/build/media-type-codecs/default-policies.js.map +1 -0
  49. package/build/media-type-codecs/json-decoder.d.ts +14 -0
  50. package/build/media-type-codecs/json-decoder.js +40 -0
  51. package/build/media-type-codecs/json-decoder.js.map +1 -0
  52. package/build/media-type-codecs/json-encoder.d.ts +13 -0
  53. package/build/media-type-codecs/json-encoder.js +43 -0
  54. package/build/media-type-codecs/json-encoder.js.map +1 -0
  55. package/build/media-type-codecs/media-type-decoder.d.ts +14 -0
  56. package/build/{esm/media-type-codecs → media-type-codecs}/media-type-decoder.js +1 -2
  57. package/build/media-type-codecs/media-type-decoder.js.map +1 -0
  58. package/build/{main/media-type-codecs → media-type-codecs}/media-type-decoders.d.ts +6 -8
  59. package/build/media-type-codecs/media-type-decoders.js +63 -0
  60. package/build/media-type-codecs/media-type-decoders.js.map +1 -0
  61. package/build/{main/media-type-codecs → media-type-codecs}/media-type-encoder.d.ts +3 -3
  62. package/build/{esnext/media-type-codecs → media-type-codecs}/media-type-encoder.js +2 -4
  63. package/build/media-type-codecs/media-type-encoder.js.map +1 -0
  64. package/build/{esnext/media-type-codecs → media-type-codecs}/media-type-encoders.d.ts +6 -8
  65. package/build/media-type-codecs/media-type-encoders.js +65 -0
  66. package/build/media-type-codecs/media-type-encoders.js.map +1 -0
  67. package/build/media-type-codecs/www-form-url-encoder.d.ts +31 -0
  68. package/build/media-type-codecs/www-form-url-encoder.js +281 -0
  69. package/build/media-type-codecs/www-form-url-encoder.js.map +1 -0
  70. package/build/{esm/media-type.js → media-type.js} +23 -23
  71. package/build/media-type.js.map +1 -0
  72. package/build/problem.d.ts +35 -0
  73. package/build/problem.js +122 -0
  74. package/build/problem.js.map +1 -0
  75. package/build/request-adapters.d.ts +23 -0
  76. package/build/request-adapters.js +53 -0
  77. package/build/request-adapters.js.map +1 -0
  78. package/build/request-factory.d.ts +39 -0
  79. package/build/request-factory.js.map +1 -0
  80. package/build/result-response.js.map +1 -0
  81. package/build/schema-builtins.d.ts +21 -0
  82. package/build/schema-builtins.js +201 -0
  83. package/build/schema-builtins.js.map +1 -0
  84. package/build/schema-policy.d.ts +31 -0
  85. package/build/schema-policy.js +41 -0
  86. package/build/schema-policy.js.map +1 -0
  87. package/build/schema-runtime.d.ts +25 -0
  88. package/build/schema-runtime.js +77 -0
  89. package/build/schema-runtime.js.map +1 -0
  90. package/build/{esnext/sunday-error.d.ts → sunday-error.d.ts} +2 -3
  91. package/build/sunday-error.js +36 -0
  92. package/build/sunday-error.js.map +1 -0
  93. package/build/{esm/url-template.js → url-template.js} +5 -3
  94. package/build/url-template.js.map +1 -0
  95. package/build/util/async-iterables.d.ts +15 -0
  96. package/build/util/async-iterables.js +179 -0
  97. package/build/util/async-iterables.js.map +1 -0
  98. package/build/util/errors.js +65 -0
  99. package/build/util/errors.js.map +1 -0
  100. package/build/util/nullify.d.ts +5 -0
  101. package/build/util/nullify.js +37 -0
  102. package/build/util/nullify.js.map +1 -0
  103. package/build/util/numbers.d.ts +11 -0
  104. package/build/{esm/util/temporal.js → util/numbers.js} +14 -4
  105. package/build/util/numbers.js.map +1 -0
  106. package/build/util/subscriptions.d.ts +16 -0
  107. package/build/util/subscriptions.js +78 -0
  108. package/build/util/subscriptions.js.map +1 -0
  109. package/build/{esm/util/any.js → util/unknowns.js} +2 -3
  110. package/build/util/unknowns.js.map +1 -0
  111. package/package.json +58 -56
  112. package/build/esm/any-type.d.ts +0 -4
  113. package/build/esm/any-type.js +0 -15
  114. package/build/esm/any-type.js.map +0 -1
  115. package/build/esm/class-type.d.ts +0 -2
  116. package/build/esm/class-type.js +0 -15
  117. package/build/esm/class-type.js.map +0 -1
  118. package/build/esm/date-time-types.d.ts +0 -2
  119. package/build/esm/date-time-types.js +0 -16
  120. package/build/esm/date-time-types.js.map +0 -1
  121. package/build/esm/event-parser.js.map +0 -1
  122. package/build/esm/fetch-event-source.js +0 -290
  123. package/build/esm/fetch-event-source.js.map +0 -1
  124. package/build/esm/fetch-request-factory.d.ts +0 -34
  125. package/build/esm/fetch-request-factory.js +0 -190
  126. package/build/esm/fetch-request-factory.js.map +0 -1
  127. package/build/esm/fetch.d.ts +0 -7
  128. package/build/esm/fetch.js +0 -103
  129. package/build/esm/fetch.js.map +0 -1
  130. package/build/esm/header-parameters.js +0 -53
  131. package/build/esm/header-parameters.js.map +0 -1
  132. package/build/esm/index.d.ts +0 -26
  133. package/build/esm/index.js +0 -40
  134. package/build/esm/index.js.map +0 -1
  135. package/build/esm/logger.d.ts +0 -8
  136. package/build/esm/logger.js +0 -15
  137. package/build/esm/logger.js.map +0 -1
  138. package/build/esm/media-type-codecs/any-text-decoder.d.ts +0 -7
  139. package/build/esm/media-type-codecs/any-text-decoder.js +0 -40
  140. package/build/esm/media-type-codecs/any-text-decoder.js.map +0 -1
  141. package/build/esm/media-type-codecs/any-text-encoder.d.ts +0 -5
  142. package/build/esm/media-type-codecs/any-text-encoder.js.map +0 -1
  143. package/build/esm/media-type-codecs/binary-decoder.d.ts +0 -6
  144. package/build/esm/media-type-codecs/binary-decoder.js +0 -40
  145. package/build/esm/media-type-codecs/binary-decoder.js.map +0 -1
  146. package/build/esm/media-type-codecs/binary-encoder.d.ts +0 -5
  147. package/build/esm/media-type-codecs/binary-encoder.js.map +0 -1
  148. package/build/esm/media-type-codecs/cbor-decoder.d.ts +0 -39
  149. package/build/esm/media-type-codecs/cbor-decoder.js +0 -437
  150. package/build/esm/media-type-codecs/cbor-decoder.js.map +0 -1
  151. package/build/esm/media-type-codecs/cbor-encoder.d.ts +0 -43
  152. package/build/esm/media-type-codecs/cbor-encoder.js +0 -236
  153. package/build/esm/media-type-codecs/cbor-encoder.js.map +0 -1
  154. package/build/esm/media-type-codecs/cbor-tags.js +0 -18
  155. package/build/esm/media-type-codecs/cbor-tags.js.map +0 -1
  156. package/build/esm/media-type-codecs/json-decoder.d.ts +0 -39
  157. package/build/esm/media-type-codecs/json-decoder.js +0 -391
  158. package/build/esm/media-type-codecs/json-decoder.js.map +0 -1
  159. package/build/esm/media-type-codecs/json-encoder.d.ts +0 -44
  160. package/build/esm/media-type-codecs/json-encoder.js +0 -273
  161. package/build/esm/media-type-codecs/json-encoder.js.map +0 -1
  162. package/build/esm/media-type-codecs/media-type-decoder.d.ts +0 -11
  163. package/build/esm/media-type-codecs/media-type-decoder.js.map +0 -1
  164. package/build/esm/media-type-codecs/media-type-decoders.d.ts +0 -18
  165. package/build/esm/media-type-codecs/media-type-decoders.js +0 -58
  166. package/build/esm/media-type-codecs/media-type-decoders.js.map +0 -1
  167. package/build/esm/media-type-codecs/media-type-encoder.d.ts +0 -12
  168. package/build/esm/media-type-codecs/media-type-encoder.js +0 -24
  169. package/build/esm/media-type-codecs/media-type-encoder.js.map +0 -1
  170. package/build/esm/media-type-codecs/media-type-encoders.d.ts +0 -18
  171. package/build/esm/media-type-codecs/media-type-encoders.js +0 -60
  172. package/build/esm/media-type-codecs/media-type-encoders.js.map +0 -1
  173. package/build/esm/media-type-codecs/www-form-url-encoder.d.ts +0 -59
  174. package/build/esm/media-type-codecs/www-form-url-encoder.js +0 -192
  175. package/build/esm/media-type-codecs/www-form-url-encoder.js.map +0 -1
  176. package/build/esm/media-type.js.map +0 -1
  177. package/build/esm/problem.d.ts +0 -31
  178. package/build/esm/problem.js +0 -169
  179. package/build/esm/problem.js.map +0 -1
  180. package/build/esm/request-factory.d.ts +0 -44
  181. package/build/esm/request-factory.js.map +0 -1
  182. package/build/esm/result-response.js.map +0 -1
  183. package/build/esm/sunday-error.d.ts +0 -11
  184. package/build/esm/sunday-error.js +0 -42
  185. package/build/esm/sunday-error.js.map +0 -1
  186. package/build/esm/url-template.js.map +0 -1
  187. package/build/esm/util/any.js.map +0 -1
  188. package/build/esm/util/base64.d.ts +0 -5
  189. package/build/esm/util/base64.js +0 -77
  190. package/build/esm/util/base64.js.map +0 -1
  191. package/build/esm/util/error.js +0 -26
  192. package/build/esm/util/error.js.map +0 -1
  193. package/build/esm/util/hex.d.ts +0 -4
  194. package/build/esm/util/hex.js +0 -32
  195. package/build/esm/util/hex.js.map +0 -1
  196. package/build/esm/util/rxjs.d.ts +0 -5
  197. package/build/esm/util/rxjs.js +0 -31
  198. package/build/esm/util/rxjs.js.map +0 -1
  199. package/build/esm/util/stream-rxjs.d.ts +0 -2
  200. package/build/esm/util/stream-rxjs.js +0 -50
  201. package/build/esm/util/stream-rxjs.js.map +0 -1
  202. package/build/esm/util/temporal.d.ts +0 -2
  203. package/build/esm/util/temporal.js.map +0 -1
  204. package/build/esnext/any-type.d.ts +0 -4
  205. package/build/esnext/any-type.js +0 -15
  206. package/build/esnext/any-type.js.map +0 -1
  207. package/build/esnext/class-type.d.ts +0 -2
  208. package/build/esnext/class-type.js +0 -15
  209. package/build/esnext/class-type.js.map +0 -1
  210. package/build/esnext/date-time-types.d.ts +0 -2
  211. package/build/esnext/date-time-types.js +0 -16
  212. package/build/esnext/date-time-types.js.map +0 -1
  213. package/build/esnext/event-parser.d.ts +0 -17
  214. package/build/esnext/event-parser.js +0 -153
  215. package/build/esnext/event-parser.js.map +0 -1
  216. package/build/esnext/fetch-event-source.d.ts +0 -58
  217. package/build/esnext/fetch-event-source.js +0 -290
  218. package/build/esnext/fetch-event-source.js.map +0 -1
  219. package/build/esnext/fetch-request-factory.js +0 -190
  220. package/build/esnext/fetch-request-factory.js.map +0 -1
  221. package/build/esnext/fetch.d.ts +0 -7
  222. package/build/esnext/fetch.js +0 -103
  223. package/build/esnext/fetch.js.map +0 -1
  224. package/build/esnext/header-parameters.d.ts +0 -3
  225. package/build/esnext/header-parameters.js.map +0 -1
  226. package/build/esnext/index.d.ts +0 -26
  227. package/build/esnext/index.js +0 -40
  228. package/build/esnext/index.js.map +0 -1
  229. package/build/esnext/logger.d.ts +0 -8
  230. package/build/esnext/logger.js +0 -15
  231. package/build/esnext/logger.js.map +0 -1
  232. package/build/esnext/media-type-codecs/any-text-decoder.d.ts +0 -7
  233. package/build/esnext/media-type-codecs/any-text-decoder.js +0 -40
  234. package/build/esnext/media-type-codecs/any-text-decoder.js.map +0 -1
  235. package/build/esnext/media-type-codecs/any-text-encoder.d.ts +0 -5
  236. package/build/esnext/media-type-codecs/any-text-encoder.js +0 -23
  237. package/build/esnext/media-type-codecs/any-text-encoder.js.map +0 -1
  238. package/build/esnext/media-type-codecs/binary-decoder.d.ts +0 -6
  239. package/build/esnext/media-type-codecs/binary-decoder.js +0 -40
  240. package/build/esnext/media-type-codecs/binary-decoder.js.map +0 -1
  241. package/build/esnext/media-type-codecs/binary-encoder.d.ts +0 -5
  242. package/build/esnext/media-type-codecs/binary-encoder.js.map +0 -1
  243. package/build/esnext/media-type-codecs/cbor-decoder.d.ts +0 -39
  244. package/build/esnext/media-type-codecs/cbor-decoder.js +0 -437
  245. package/build/esnext/media-type-codecs/cbor-decoder.js.map +0 -1
  246. package/build/esnext/media-type-codecs/cbor-encoder.d.ts +0 -43
  247. package/build/esnext/media-type-codecs/cbor-encoder.js +0 -236
  248. package/build/esnext/media-type-codecs/cbor-encoder.js.map +0 -1
  249. package/build/esnext/media-type-codecs/cbor-tags.d.ts +0 -4
  250. package/build/esnext/media-type-codecs/cbor-tags.js.map +0 -1
  251. package/build/esnext/media-type-codecs/json-decoder.d.ts +0 -39
  252. package/build/esnext/media-type-codecs/json-decoder.js +0 -391
  253. package/build/esnext/media-type-codecs/json-decoder.js.map +0 -1
  254. package/build/esnext/media-type-codecs/json-encoder.d.ts +0 -44
  255. package/build/esnext/media-type-codecs/json-encoder.js +0 -273
  256. package/build/esnext/media-type-codecs/json-encoder.js.map +0 -1
  257. package/build/esnext/media-type-codecs/media-type-decoder.d.ts +0 -11
  258. package/build/esnext/media-type-codecs/media-type-decoder.js +0 -19
  259. package/build/esnext/media-type-codecs/media-type-decoder.js.map +0 -1
  260. package/build/esnext/media-type-codecs/media-type-decoders.d.ts +0 -18
  261. package/build/esnext/media-type-codecs/media-type-decoders.js +0 -58
  262. package/build/esnext/media-type-codecs/media-type-decoders.js.map +0 -1
  263. package/build/esnext/media-type-codecs/media-type-encoder.d.ts +0 -12
  264. package/build/esnext/media-type-codecs/media-type-encoder.js.map +0 -1
  265. package/build/esnext/media-type-codecs/media-type-encoders.js +0 -60
  266. package/build/esnext/media-type-codecs/media-type-encoders.js.map +0 -1
  267. package/build/esnext/media-type-codecs/www-form-url-encoder.d.ts +0 -59
  268. package/build/esnext/media-type-codecs/www-form-url-encoder.js +0 -192
  269. package/build/esnext/media-type-codecs/www-form-url-encoder.js.map +0 -1
  270. package/build/esnext/media-type.d.ts +0 -94
  271. package/build/esnext/media-type.js +0 -305
  272. package/build/esnext/media-type.js.map +0 -1
  273. package/build/esnext/problem.d.ts +0 -31
  274. package/build/esnext/problem.js +0 -169
  275. package/build/esnext/problem.js.map +0 -1
  276. package/build/esnext/request-factory.d.ts +0 -44
  277. package/build/esnext/request-factory.js +0 -15
  278. package/build/esnext/request-factory.js.map +0 -1
  279. package/build/esnext/result-response.d.ts +0 -4
  280. package/build/esnext/result-response.js +0 -15
  281. package/build/esnext/result-response.js.map +0 -1
  282. package/build/esnext/sunday-error.js +0 -42
  283. package/build/esnext/sunday-error.js.map +0 -1
  284. package/build/esnext/url-template.d.ts +0 -6
  285. package/build/esnext/url-template.js +0 -31
  286. package/build/esnext/url-template.js.map +0 -1
  287. package/build/esnext/util/any.d.ts +0 -2
  288. package/build/esnext/util/any.js +0 -24
  289. package/build/esnext/util/any.js.map +0 -1
  290. package/build/esnext/util/base64.d.ts +0 -5
  291. package/build/esnext/util/base64.js +0 -77
  292. package/build/esnext/util/base64.js.map +0 -1
  293. package/build/esnext/util/error.d.ts +0 -2
  294. package/build/esnext/util/error.js +0 -26
  295. package/build/esnext/util/error.js.map +0 -1
  296. package/build/esnext/util/hex.d.ts +0 -4
  297. package/build/esnext/util/hex.js +0 -32
  298. package/build/esnext/util/hex.js.map +0 -1
  299. package/build/esnext/util/rxjs.d.ts +0 -5
  300. package/build/esnext/util/rxjs.js +0 -31
  301. package/build/esnext/util/rxjs.js.map +0 -1
  302. package/build/esnext/util/stream-rxjs.d.ts +0 -2
  303. package/build/esnext/util/stream-rxjs.js +0 -50
  304. package/build/esnext/util/stream-rxjs.js.map +0 -1
  305. package/build/esnext/util/temporal.d.ts +0 -2
  306. package/build/esnext/util/temporal.js +0 -31
  307. package/build/esnext/util/temporal.js.map +0 -1
  308. package/build/main/any-type.d.ts +0 -4
  309. package/build/main/any-type.js +0 -16
  310. package/build/main/any-type.js.map +0 -1
  311. package/build/main/class-type.d.ts +0 -2
  312. package/build/main/class-type.js +0 -16
  313. package/build/main/class-type.js.map +0 -1
  314. package/build/main/date-time-types.d.ts +0 -2
  315. package/build/main/date-time-types.js +0 -27
  316. package/build/main/date-time-types.js.map +0 -1
  317. package/build/main/event-parser.d.ts +0 -17
  318. package/build/main/event-parser.js +0 -157
  319. package/build/main/event-parser.js.map +0 -1
  320. package/build/main/fetch-event-source.d.ts +0 -58
  321. package/build/main/fetch-event-source.js +0 -294
  322. package/build/main/fetch-event-source.js.map +0 -1
  323. package/build/main/fetch-request-factory.d.ts +0 -34
  324. package/build/main/fetch-request-factory.js +0 -194
  325. package/build/main/fetch-request-factory.js.map +0 -1
  326. package/build/main/fetch.d.ts +0 -7
  327. package/build/main/fetch.js +0 -107
  328. package/build/main/fetch.js.map +0 -1
  329. package/build/main/header-parameters.d.ts +0 -3
  330. package/build/main/header-parameters.js +0 -56
  331. package/build/main/header-parameters.js.map +0 -1
  332. package/build/main/index.d.ts +0 -26
  333. package/build/main/index.js +0 -52
  334. package/build/main/index.js.map +0 -1
  335. package/build/main/logger.js +0 -16
  336. package/build/main/logger.js.map +0 -1
  337. package/build/main/media-type-codecs/any-text-decoder.d.ts +0 -7
  338. package/build/main/media-type-codecs/any-text-decoder.js +0 -44
  339. package/build/main/media-type-codecs/any-text-decoder.js.map +0 -1
  340. package/build/main/media-type-codecs/any-text-encoder.d.ts +0 -5
  341. package/build/main/media-type-codecs/any-text-encoder.js +0 -27
  342. package/build/main/media-type-codecs/any-text-encoder.js.map +0 -1
  343. package/build/main/media-type-codecs/binary-decoder.d.ts +0 -6
  344. package/build/main/media-type-codecs/binary-decoder.js +0 -44
  345. package/build/main/media-type-codecs/binary-decoder.js.map +0 -1
  346. package/build/main/media-type-codecs/binary-encoder.d.ts +0 -5
  347. package/build/main/media-type-codecs/binary-encoder.js +0 -30
  348. package/build/main/media-type-codecs/binary-encoder.js.map +0 -1
  349. package/build/main/media-type-codecs/cbor-decoder.d.ts +0 -39
  350. package/build/main/media-type-codecs/cbor-decoder.js +0 -441
  351. package/build/main/media-type-codecs/cbor-decoder.js.map +0 -1
  352. package/build/main/media-type-codecs/cbor-encoder.d.ts +0 -43
  353. package/build/main/media-type-codecs/cbor-encoder.js +0 -240
  354. package/build/main/media-type-codecs/cbor-encoder.js.map +0 -1
  355. package/build/main/media-type-codecs/cbor-tags.d.ts +0 -4
  356. package/build/main/media-type-codecs/cbor-tags.js +0 -21
  357. package/build/main/media-type-codecs/cbor-tags.js.map +0 -1
  358. package/build/main/media-type-codecs/json-decoder.d.ts +0 -39
  359. package/build/main/media-type-codecs/json-decoder.js +0 -395
  360. package/build/main/media-type-codecs/json-decoder.js.map +0 -1
  361. package/build/main/media-type-codecs/json-encoder.d.ts +0 -44
  362. package/build/main/media-type-codecs/json-encoder.js +0 -277
  363. package/build/main/media-type-codecs/json-encoder.js.map +0 -1
  364. package/build/main/media-type-codecs/media-type-decoder.d.ts +0 -11
  365. package/build/main/media-type-codecs/media-type-decoder.js +0 -23
  366. package/build/main/media-type-codecs/media-type-decoder.js.map +0 -1
  367. package/build/main/media-type-codecs/media-type-decoders.js +0 -62
  368. package/build/main/media-type-codecs/media-type-decoders.js.map +0 -1
  369. package/build/main/media-type-codecs/media-type-encoder.js +0 -29
  370. package/build/main/media-type-codecs/media-type-encoder.js.map +0 -1
  371. package/build/main/media-type-codecs/media-type-encoders.d.ts +0 -18
  372. package/build/main/media-type-codecs/media-type-encoders.js +0 -64
  373. package/build/main/media-type-codecs/media-type-encoders.js.map +0 -1
  374. package/build/main/media-type-codecs/www-form-url-encoder.d.ts +0 -59
  375. package/build/main/media-type-codecs/www-form-url-encoder.js +0 -196
  376. package/build/main/media-type-codecs/www-form-url-encoder.js.map +0 -1
  377. package/build/main/media-type.d.ts +0 -94
  378. package/build/main/media-type.js +0 -309
  379. package/build/main/media-type.js.map +0 -1
  380. package/build/main/problem.d.ts +0 -31
  381. package/build/main/problem.js +0 -172
  382. package/build/main/problem.js.map +0 -1
  383. package/build/main/request-factory.d.ts +0 -44
  384. package/build/main/request-factory.js +0 -16
  385. package/build/main/request-factory.js.map +0 -1
  386. package/build/main/result-response.d.ts +0 -4
  387. package/build/main/result-response.js +0 -16
  388. package/build/main/result-response.js.map +0 -1
  389. package/build/main/sunday-error.d.ts +0 -11
  390. package/build/main/sunday-error.js +0 -46
  391. package/build/main/sunday-error.js.map +0 -1
  392. package/build/main/url-template.d.ts +0 -6
  393. package/build/main/url-template.js +0 -35
  394. package/build/main/url-template.js.map +0 -1
  395. package/build/main/util/any.d.ts +0 -2
  396. package/build/main/util/any.js +0 -29
  397. package/build/main/util/any.js.map +0 -1
  398. package/build/main/util/base64.d.ts +0 -5
  399. package/build/main/util/base64.js +0 -80
  400. package/build/main/util/base64.js.map +0 -1
  401. package/build/main/util/error.d.ts +0 -2
  402. package/build/main/util/error.js +0 -31
  403. package/build/main/util/error.js.map +0 -1
  404. package/build/main/util/hex.d.ts +0 -4
  405. package/build/main/util/hex.js +0 -35
  406. package/build/main/util/hex.js.map +0 -1
  407. package/build/main/util/rxjs.d.ts +0 -5
  408. package/build/main/util/rxjs.js +0 -36
  409. package/build/main/util/rxjs.js.map +0 -1
  410. package/build/main/util/stream-rxjs.d.ts +0 -2
  411. package/build/main/util/stream-rxjs.js +0 -54
  412. package/build/main/util/stream-rxjs.js.map +0 -1
  413. package/build/main/util/temporal.d.ts +0 -2
  414. package/build/main/util/temporal.js +0 -36
  415. package/build/main/util/temporal.js.map +0 -1
  416. /package/build/{esm/header-parameters.d.ts → header-parameters.d.ts} +0 -0
  417. /package/build/{esm/media-type.d.ts → media-type.d.ts} +0 -0
  418. /package/build/{esm/request-factory.js → request-factory.js} +0 -0
  419. /package/build/{esm/result-response.d.ts → result-response.d.ts} +0 -0
  420. /package/build/{esm/result-response.js → result-response.js} +0 -0
  421. /package/build/{esm/url-template.d.ts → url-template.d.ts} +0 -0
  422. /package/build/{esm/util/error.d.ts → util/errors.d.ts} +0 -0
  423. /package/build/{esm/util/any.d.ts → util/unknowns.d.ts} +0 -0
@@ -1,290 +0,0 @@
1
- // Copyright 2020 Outfox, Inc.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { EMPTY, map, of, switchMap, tap } from 'rxjs';
15
- import { EventParser } from './event-parser';
16
- import { validate } from './fetch';
17
- import { MediaType } from './media-type';
18
- import { unknownSet } from './util/any';
19
- import { fromStream } from './util/stream-rxjs';
20
- export class FetchEventSource extends EventTarget {
21
- constructor(url, eventSourceInit) {
22
- var _a, _b;
23
- super();
24
- this.CONNECTING = 0;
25
- this.OPEN = 1;
26
- this.CLOSED = 2;
27
- this.readyState = this.CLOSED;
28
- this.withCredentials = false;
29
- this.onerror = null;
30
- this.onmessage = null;
31
- this.onopen = null;
32
- this.internalRetryTime = 100;
33
- this.retryAttempt = 0;
34
- this.connectionAttemptTime = 0;
35
- this.lastEventReceivedTime = 0;
36
- this.eventParser = new EventParser();
37
- //
38
- // Event Dispatch
39
- //
40
- this.dispatchParsedEvent = (eventInfo) => {
41
- var _a, _b, _c, _d, _e, _f, _g, _h;
42
- this.lastEventReceivedTime = Date.now();
43
- if (eventInfo.retry) {
44
- const retryTime = Number.parseInt(eventInfo.retry, 10);
45
- if (Number.isSafeInteger(retryTime)) {
46
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'updating retry timeout', { retryTime });
47
- this.internalRetryTime = retryTime;
48
- }
49
- else {
50
- (_d = (_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug) === null || _d === void 0 ? void 0 : _d.call(_c, 'ignoring invalid retry timeout event', {
51
- eventInfo,
52
- });
53
- }
54
- }
55
- // skip empty events
56
- if (eventInfo.id == null &&
57
- eventInfo.event == null &&
58
- eventInfo.data == null) {
59
- // skip empty event
60
- return;
61
- }
62
- // Save last-event-id if the new id is valid
63
- if (eventInfo.id != null) {
64
- // Check for NULL as it is not allowed
65
- if (eventInfo.id.indexOf('\0') == -1) {
66
- this.lastEventId = eventInfo.id;
67
- }
68
- else {
69
- (_f = (_e = this.logger) === null || _e === void 0 ? void 0 : _e.debug) === null || _f === void 0 ? void 0 : _f.call(_e, 'event id contains null, unable to use for last-event-id');
70
- }
71
- }
72
- // Dispatch event
73
- const event = new MessageEvent((_g = eventInfo.event) !== null && _g !== void 0 ? _g : 'message', {
74
- data: eventInfo.data,
75
- lastEventId: this.lastEventId,
76
- origin: this.connectionOrigin,
77
- });
78
- (_h = this.onmessage) === null || _h === void 0 ? void 0 : _h.call(this, event);
79
- this.dispatchEvent(event);
80
- };
81
- this.url = url;
82
- this.adapter =
83
- (_a = eventSourceInit === null || eventSourceInit === void 0 ? void 0 : eventSourceInit.adapter) !== null && _a !== void 0 ? _a : ((_url, requestInit) => of(new Request(_url, requestInit)));
84
- this.eventTimeout =
85
- (_b = eventSourceInit === null || eventSourceInit === void 0 ? void 0 : eventSourceInit.eventTimeout) !== null && _b !== void 0 ? _b : FetchEventSource.EVENT_TIMEOUT_DEFAULT * 1000;
86
- this.logger = eventSourceInit === null || eventSourceInit === void 0 ? void 0 : eventSourceInit.logger;
87
- this.externalAbortController = eventSourceInit === null || eventSourceInit === void 0 ? void 0 : eventSourceInit.abortController;
88
- }
89
- get retryTime() {
90
- return this.internalRetryTime;
91
- }
92
- //
93
- // Connect
94
- //
95
- connect() {
96
- var _a, _b;
97
- if (this.readyState === this.CONNECTING || this.readyState === this.OPEN) {
98
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace) === null || _b === void 0 ? void 0 : _b.call(_a, 'skipping connect', { state: this.readyState });
99
- return;
100
- }
101
- this.internalConnect();
102
- }
103
- internalConnect() {
104
- var _a, _b, _c;
105
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'connecting');
106
- this.readyState = this.CONNECTING;
107
- const headers = new Headers({
108
- accept: MediaType.EventStream.toString(),
109
- });
110
- if (this.lastEventId) {
111
- headers.append(FetchEventSource.LAST_EVENT_ID_HEADER, this.lastEventId);
112
- }
113
- const abortController = (_c = this.externalAbortController) !== null && _c !== void 0 ? _c : new AbortController();
114
- const requestInit = {
115
- headers,
116
- cache: 'no-store',
117
- redirect: 'follow',
118
- signal: abortController.signal,
119
- };
120
- this.connectionAttemptTime = Date.now();
121
- this.connectionSubscription = this.adapter(this.url, requestInit)
122
- .pipe(switchMap((request) => fetch(request)), switchMap((response) => validate(response, true)), tap((response) => this.receivedHeaders(response)), switchMap((response) => {
123
- const body = response.body;
124
- if (!body) {
125
- return EMPTY;
126
- }
127
- return fromStream(body);
128
- }), map((value) => this.receivedData(value)))
129
- .subscribe({
130
- error: (error) => {
131
- this.receivedError(error);
132
- },
133
- complete: () => {
134
- this.receivedComplete();
135
- },
136
- });
137
- this.connectionSubscription.add(() => {
138
- abortController.abort();
139
- });
140
- }
141
- //
142
- // Close
143
- //
144
- close() {
145
- var _a, _b;
146
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'close requested');
147
- this.readyState = this.CLOSED;
148
- this.internalClose();
149
- }
150
- internalClose() {
151
- var _a;
152
- (_a = this.connectionSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
153
- this.connectionSubscription = undefined;
154
- this.clearReconnect();
155
- this.stopEventTimeoutCheck();
156
- }
157
- //
158
- // Event Timeout
159
- //
160
- startEventTimeoutCheck(lastEventReceivedTime) {
161
- var _a, _b;
162
- this.stopEventTimeoutCheck();
163
- if (!this.eventTimeout) {
164
- return;
165
- }
166
- this.lastEventReceivedTime = lastEventReceivedTime;
167
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace) === null || _b === void 0 ? void 0 : _b.call(_a, 'starting event timeout checks');
168
- this.eventTimeoutCheckHandle = window.setInterval(() => this.checkEventTimeout(), FetchEventSource.EVENT_TIMEOUT_CHECK_INTERVAL * 1000);
169
- }
170
- stopEventTimeoutCheck() {
171
- var _a, _b;
172
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace) === null || _b === void 0 ? void 0 : _b.call(_a, 'stopping event timeout checks');
173
- if (this.eventTimeoutCheckHandle) {
174
- clearInterval(this.eventTimeoutCheckHandle);
175
- }
176
- this.eventTimeoutCheckHandle = undefined;
177
- }
178
- checkEventTimeout() {
179
- var _a, _b, _c, _d;
180
- if (!this.eventTimeout) {
181
- this.stopEventTimeoutCheck();
182
- return;
183
- }
184
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace) === null || _b === void 0 ? void 0 : _b.call(_a, 'checking event timeout');
185
- // Check elapsed time since last received event
186
- const elapsed = Date.now() - this.lastEventReceivedTime;
187
- if (elapsed > this.eventTimeout) {
188
- (_d = (_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug) === null || _d === void 0 ? void 0 : _d.call(_c, 'event timeout reached', {
189
- elapsed,
190
- });
191
- this.fireErrorEvent(Error('EventTimeout'));
192
- this.scheduleReconnect();
193
- }
194
- }
195
- //
196
- // Connection Handlers
197
- //
198
- receivedHeaders(response) {
199
- var _a, _b, _c, _d, _e;
200
- if (this.readyState !== this.CONNECTING) {
201
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, 'invalid readyState for receivedHeaders', {
202
- readyState: this.readyState,
203
- });
204
- this.fireErrorEvent(Error('InvalidState'));
205
- this.scheduleReconnect();
206
- return;
207
- }
208
- (_d = (_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug) === null || _d === void 0 ? void 0 : _d.call(_c, 'opened');
209
- this.connectionOrigin = response.url;
210
- this.retryAttempt = 0;
211
- this.readyState = this.OPEN;
212
- // Start event timeout check, treating this
213
- // connect as last time we received an event
214
- this.startEventTimeoutCheck(Date.now());
215
- const event = new Event('open');
216
- (_e = this.onopen) === null || _e === void 0 ? void 0 : _e.call(this, event);
217
- this.dispatchEvent(event);
218
- }
219
- receivedData(buffer) {
220
- var _a, _b, _c, _d;
221
- if (this.readyState !== this.OPEN) {
222
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, 'invalid readyState for receiveData', {
223
- readyState: this.readyState,
224
- });
225
- this.fireErrorEvent(Error('InvalidState'));
226
- this.scheduleReconnect();
227
- return;
228
- }
229
- (_d = (_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug) === null || _d === void 0 ? void 0 : _d.call(_c, 'received data', { length: buffer.byteLength });
230
- this.eventParser.process(buffer, this.dispatchParsedEvent);
231
- }
232
- receivedError(error) {
233
- var _a, _b;
234
- if (this.readyState === this.CLOSED) {
235
- return;
236
- }
237
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'received error', { error });
238
- this.fireErrorEvent(error);
239
- if (this.readyState !== this.CLOSED) {
240
- this.scheduleReconnect();
241
- }
242
- }
243
- receivedComplete() {
244
- var _a, _b;
245
- if (this.readyState == this.CLOSED) {
246
- return;
247
- }
248
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'received complete');
249
- this.scheduleReconnect();
250
- }
251
- //
252
- // Reconnection
253
- //
254
- scheduleReconnect() {
255
- var _a, _b;
256
- this.internalClose();
257
- // calculate total delay
258
- const backOffDelay = Math.pow(this.retryAttempt, 2) * this.retryTime;
259
- let retryDelay = Math.min(this.retryTime + backOffDelay, this.retryTime * FetchEventSource.MAX_RETRY_TIME_MULTIPLE);
260
- // Adjust delay by amount of time last connect
261
- // cycle took, except on the first attempt
262
- if (this.retryAttempt > 0) {
263
- const connectionTime = Date.now() - this.connectionAttemptTime;
264
- // Ensure delay is at least as large as
265
- // minimum retry time interval
266
- retryDelay = Math.max(retryDelay - connectionTime, this.retryTime);
267
- }
268
- this.retryAttempt++;
269
- this.readyState = this.CONNECTING;
270
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'scheduling reconnect', { retryDelay });
271
- this.reconnectTimeoutHandle = window.setTimeout(() => this.internalConnect(), retryDelay);
272
- }
273
- clearReconnect() {
274
- if (this.reconnectTimeoutHandle) {
275
- clearTimeout(this.reconnectTimeoutHandle);
276
- }
277
- this.reconnectTimeoutHandle = undefined;
278
- }
279
- fireErrorEvent(error) {
280
- var _a;
281
- const event = new Event('error');
282
- unknownSet(event, 'error', error);
283
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, event);
284
- }
285
- }
286
- FetchEventSource.LAST_EVENT_ID_HEADER = 'Last-Event-ID';
287
- FetchEventSource.MAX_RETRY_TIME_MULTIPLE = 30;
288
- FetchEventSource.EVENT_TIMEOUT_DEFAULT = 75;
289
- FetchEventSource.EVENT_TIMEOUT_CHECK_INTERVAL = 2;
290
- //# sourceMappingURL=fetch-event-source.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch-event-source.js","sourceRoot":"","sources":["../../src/fetch-event-source.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAc,EAAE,EAAgB,SAAS,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChF,OAAO,EAAa,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAiBhD,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAuC/C,YACE,GAAW,EACX,eAKC;;QAED,KAAK,EAAE,CAAC;QA1CV,eAAU,GAAG,CAAC,CAAC;QACf,SAAI,GAAG,CAAC,CAAC;QACT,WAAM,GAAG,CAAC,CAAC;QAEX,eAAU,GAAW,IAAI,CAAC,MAAM,CAAC;QAEjC,oBAAe,GAAG,K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AC,GAAG,EAAE,GAAG,IAAI,CAAC,qBAAqB,CAAC;YAC/D,uCAAuC;YACvC,8BAA8B;YAC9B,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;SACpE;QAED,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAElC,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,KAAK,mDAAG,sBAAsB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QAE7D,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,UAAU,CAC7C,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,EAC5B,UAAU,CACX,CAAC;IACJ,CAAC;IAEO,cAAc;QACpB,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC/B,YAAY,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;SAC3C;QACD,IAAI,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAC1C,CAAC;IAwDD,cAAc,CAAC,KAAc;;QAC3B,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QACjC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAClC,MAAA,IAAI,CAAC,OAAO,+CAAZ,IAAI,EAAW,KAAK,CAAC,CAAC;IACxB,CAAC;;AA7Wc,qCAAoB,GAAG,eAAe,CAAC;AACvC,wCAAuB,GAAG,EAAE,CAAC;AAC7B,sCAAqB,GAAG,EAAE,CAAC;AAC3B,6CAA4B,GAAG,CAAC,CAAC"}
@@ -1,34 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { AnyType } from './any-type';
3
- import { ConstructableClassType } from './class-type';
4
- import { Logger } from './logger';
5
- import { TextMediaTypeDecoder } from './media-type-codecs/media-type-decoder';
6
- import { MediaTypeDecoders } from './media-type-codecs/media-type-decoders';
7
- import { MediaTypeEncoders } from './media-type-codecs/media-type-encoders';
8
- import { Problem } from './problem';
9
- import { ExtEventSource, RequestAdapter, RequestFactory, RequestSpec } from './request-factory';
10
- import { ResultResponse } from './result-response';
11
- import { URLTemplate } from './url-template';
12
- export declare class FetchRequestFactory implements RequestFactory {
13
- baseUrl: URLTemplate;
14
- adapter?: RequestAdapter;
15
- mediaTypeEncoders: MediaTypeEncoders;
16
- mediaTypeDecoders: MediaTypeDecoders;
17
- problemTypes: Map<string, ConstructableClassType<Problem>>;
18
- logger?: Logger;
19
- constructor(baseUrl: string | URLTemplate, options?: {
20
- adapter?: RequestAdapter;
21
- mediaTypeEncoders?: MediaTypeEncoders;
22
- mediaTypeDecoders?: MediaTypeDecoders;
23
- logger?: Logger;
24
- });
25
- registerProblem(type: URL | string, problemType: ConstructableClassType<Problem>): void;
26
- request(requestSpec: RequestSpec<unknown>, requestInit?: RequestInit): Observable<Request>;
27
- response(request: Request | RequestSpec<unknown>, dataExpected?: boolean): Observable<Response>;
28
- resultResponse<B, R>(requestSpec: RequestSpec<B>, resultType: AnyType): Observable<ResultResponse<R>>;
29
- resultResponse<B>(requestSpec: RequestSpec<B>): Observable<ResultResponse<void>>;
30
- result<B, R>(requestSpec: RequestSpec<B>, resultType: AnyType): Observable<R>;
31
- result<B>(requestSpec: RequestSpec<B>): Observable<void>;
32
- eventSource(requestSpec: RequestSpec<void>): ExtEventSource;
33
- eventStream<E>(requestSpec: RequestSpec<void>, decoder: (decoder: TextMediaTypeDecoder, event: string | undefined, id: string | undefined, data: string, logger?: Logger) => E | undefined): Observable<E>;
34
- }
@@ -1,190 +0,0 @@
1
- // Copyright 2020 Outfox, Inc.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- import { defer, map, Observable, of, switchMap } from 'rxjs';
24
- import { validate } from './fetch';
25
- import { FetchEventSource } from './fetch-event-source';
26
- import { HeaderParameters } from './header-parameters';
27
- import { MediaType } from './media-type';
28
- import { MediaTypeDecoders } from './media-type-codecs/media-type-decoders';
29
- import { isURLQueryParamsEncoder } from './media-type-codecs/media-type-encoder';
30
- import { MediaTypeEncoders } from './media-type-codecs/media-type-encoders';
31
- import { SundayError } from './sunday-error';
32
- import { URLTemplate } from './url-template';
33
- import { errorToMessage } from './util/error';
34
- export class FetchRequestFactory {
35
- constructor(baseUrl, options) {
36
- var _a, _b, _c;
37
- this.problemTypes = new Map();
38
- this.baseUrl =
39
- typeof baseUrl === 'string' ? new URLTemplate(baseUrl) : baseUrl;
40
- this.adapter = options === null || options === void 0 ? void 0 : options.adapter;
41
- this.mediaTypeEncoders =
42
- (_a = options === null || options === void 0 ? void 0 : options.mediaTypeEncoders) !== null && _a !== void 0 ? _a : MediaTypeEncoders.DEFAULT;
43
- this.mediaTypeDecoders =
44
- (_b = options === null || options === void 0 ? void 0 : options.mediaTypeDecoders) !== null && _b !== void 0 ? _b : MediaTypeDecoders.DEFAULT;
45
- this.logger = (_c = options === null || options === void 0 ? void 0 : options.logger) !== null && _c !== void 0 ? _c : console;
46
- }
47
- registerProblem(type, problemType) {
48
- const typeStr = type instanceof URL ? type.toString() : type;
49
- this.problemTypes.set(typeStr, problemType);
50
- }
51
- request(requestSpec, requestInit) {
52
- //
53
- return defer(() => {
54
- var _a, _b, _c, _d;
55
- const url = this.baseUrl.complete(requestSpec.pathTemplate, (_a = requestSpec.pathParameters) !== null && _a !== void 0 ? _a : {});
56
- if (requestSpec.queryParameters) {
57
- const encoder = this.mediaTypeEncoders.find(MediaType.WWWFormUrlEncoded);
58
- if (!isURLQueryParamsEncoder(encoder)) {
59
- throw Error(`MediaTypeEncoder for ${MediaType.WWWFormUrlEncoded} must be an instance of URLQueryParamsEncoder`);
60
- }
61
- url.search = `?${encoder.encodeQueryString(requestSpec.queryParameters)}`;
62
- }
63
- const headers = new Headers(HeaderParameters.encode(requestSpec.headers));
64
- // Determine & add accept header
65
- if (requestSpec.acceptTypes) {
66
- const supportedAcceptTypes = requestSpec.acceptTypes.filter((type) => this.mediaTypeDecoders.supports(type));
67
- if (!supportedAcceptTypes.length) {
68
- throw Error('None of the provided accept types has a reqistered decoder');
69
- }
70
- const accept = supportedAcceptTypes.join(' , ');
71
- headers.set('accept', accept);
72
- }
73
- // Determine content type
74
- const contentType = (_b = requestSpec.contentTypes) === null || _b === void 0 ? void 0 : _b.find((type) => this.mediaTypeEncoders.supports(type));
75
- // If matched, add content type (even if body is nil, to match any expected server requirements)
76
- if (contentType) {
77
- headers.set('content-type', contentType.toString());
78
- }
79
- // Encode & add body data
80
- let body;
81
- if (requestSpec.body) {
82
- if (!contentType) {
83
- throw Error('None of the provided content types has a registered encoder');
84
- }
85
- body = this.mediaTypeEncoders
86
- .find(contentType)
87
- .encode(requestSpec.body, requestSpec.bodyType);
88
- }
89
- const init = Object.assign({}, requestInit, {
90
- headers,
91
- body,
92
- method: requestSpec.method,
93
- });
94
- const request = new Request(url.toString(), init);
95
- return (_d = (_c = this.adapter) === null || _c === void 0 ? void 0 : _c.call(this, request)) !== null && _d !== void 0 ? _d : of(request);
96
- });
97
- }
98
- response(request, dataExpected) {
99
- const request$ = request instanceof Request ? of(request) : this.request(request);
100
- return request$.pipe(switchMap((req) => fetch(req)), switchMap((response) => validate(response, dataExpected !== null && dataExpected !== void 0 ? dataExpected : false, this.problemTypes)));
101
- }
102
- resultResponse(request, responseType) {
103
- const response$ = this.response(request, !!responseType);
104
- if (!responseType) {
105
- return response$.pipe(map((response) => {
106
- return {
107
- result: undefined,
108
- response,
109
- };
110
- }));
111
- }
112
- else {
113
- return response$.pipe(switchMap((response) => __awaiter(this, void 0, void 0, function* () {
114
- try {
115
- const contentType = MediaType.from(response.headers.get('content-type'), MediaType.OctetStream);
116
- const decoder = this.mediaTypeDecoders.find(contentType);
117
- const result = yield decoder.decode(response, responseType);
118
- return {
119
- result,
120
- response,
121
- };
122
- }
123
- catch (error) {
124
- throw yield SundayError.fromResponse(errorToMessage(error, 'Response Decoding Failed'), response);
125
- }
126
- })));
127
- }
128
- }
129
- result(request, responseType) {
130
- const response$ = this.response(request, !!responseType);
131
- if (!responseType) {
132
- return response$.pipe(map(() => undefined));
133
- }
134
- else {
135
- return response$.pipe(switchMap((response) => __awaiter(this, void 0, void 0, function* () {
136
- try {
137
- const contentType = MediaType.from(response.headers.get('content-type'), MediaType.OctetStream);
138
- const decoder = this.mediaTypeDecoders.find(contentType);
139
- return yield decoder.decode(response, responseType);
140
- }
141
- catch (error) {
142
- throw yield SundayError.fromResponse(errorToMessage(error, 'Response Decoding Failed'), response);
143
- }
144
- })));
145
- }
146
- }
147
- eventSource(requestSpec) {
148
- //
149
- const adapter = (url, requestInit) => {
150
- const eventSourceSpec = Object.assign({}, requestSpec, {
151
- pathTemplate: url,
152
- });
153
- return this.request(eventSourceSpec, requestInit);
154
- };
155
- return new FetchEventSource(requestSpec.pathTemplate, {
156
- logger: this.logger,
157
- adapter,
158
- });
159
- }
160
- eventStream(requestSpec, decoder) {
161
- const eventSource = this.eventSource(requestSpec);
162
- const jsonDecoder = this.mediaTypeDecoders.find(MediaType.JSON);
163
- return new Observable((subscriber) => {
164
- eventSource.onmessage = (event) => {
165
- if (!event.data) {
166
- return;
167
- }
168
- try {
169
- const decodedEvent = decoder(jsonDecoder, event.type, event.lastEventId, event.data, this.logger);
170
- if (!decodedEvent) {
171
- return;
172
- }
173
- subscriber.next(decodedEvent);
174
- }
175
- catch (error) {
176
- subscriber.error(error);
177
- }
178
- };
179
- eventSource.onerror = (event) => {
180
- var _a, _b;
181
- (_b = (_a = this.logger) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, { event }, 'event source error');
182
- };
183
- eventSource.connect();
184
- return () => {
185
- eventSource.close();
186
- };
187
- });
188
- }
189
- }
190
- //# sourceMappingURL=fetch-request-factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch-request-factory.js","sourceRoot":"","sources":["../../src/fetch-request-factory.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;;;;;;AAEjC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAG7D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAS5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBA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,EAAE,EAAE;gBACtD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;oBACf,OAAO;iBACR;gBAED,IAAI;oBACF,MAAM,YAAY,GAAG,OAAO,CAC1B,WAAW,EACX,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,IAAI,EACV,IAAI,CAAC,MAAM,CACZ,CAAC;oBACF,IAAI,CAAC,YAAY,EAAE;wBACjB,OAAO;qBACR;oBAED,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;iBAC/B;gBAAC,OAAO,KAAK,EAAE;oBACd,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACzB;YACH,CAAC,CAAC;YAEF,WAAW,CAAC,OAAO,GAAG,CAAC,KAAK,EAAE,EAAE;;gBAC9B,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,KAAK,mDAAG,EAAE,KAAK,EAAE,EAAE,oBAAoB,CAAC,CAAC;YACxD,CAAC,CAAC;YAEF,WAAW,CAAC,OAAO,EAAE,CAAC;YAEtB,OAAO,GAAG,EAAE;gBACV,WAAW,CAAC,KAAK,EAAE,CAAC;YACtB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,7 +0,0 @@
1
- import { ConstructableClassType } from './class-type';
2
- import { Problem } from './problem';
3
- export declare function validate(response: Response, dataExpected: boolean, problemTypes?: Map<string, ConstructableClassType<Problem>>): Promise<Response>;
4
- export declare namespace ResponseExample {
5
- function build(response: Response, bodyExample?: string): string;
6
- function bodyExcerpt(response: Response, maxLength: number): Promise<[string, unknown]>;
7
- }
@@ -1,103 +0,0 @@
1
- // Copyright 2020 Outfox, Inc.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- import { MediaType } from './media-type';
24
- import { Problem } from './problem';
25
- import { SundayError } from './sunday-error';
26
- import { Base64 } from './util/base64';
27
- import { errorToMessage } from './util/error';
28
- export function validate(response, dataExpected, problemTypes) {
29
- var _a, _b;
30
- return __awaiter(this, void 0, void 0, function* () {
31
- if (response.status < 200 || response.status >= 300) {
32
- const mediaType = MediaType.from(response.headers.get('content-type'), MediaType.OctetStream);
33
- const isProblem = (_a = mediaType === null || mediaType === void 0 ? void 0 : mediaType.compatible(MediaType.Problem)) !== null && _a !== void 0 ? _a : false;
34
- if (!isProblem) {
35
- throw yield Problem.fromResponse(response);
36
- }
37
- const problemData = yield response.json();
38
- const problemType = (_b = problemTypes === null || problemTypes === void 0 ? void 0 : problemTypes.get(problemData.type)) !== null && _b !== void 0 ? _b : Problem;
39
- if (problemType.name === 'Problem') {
40
- throw new Problem(problemData);
41
- }
42
- else {
43
- throw new problemType(problemData === null || problemData === void 0 ? void 0 : problemData.instance);
44
- }
45
- }
46
- if (dataExpected && (response.status === 204 || response.status === 205)) {
47
- throw yield SundayError.fromResponse('Unexpected Empty Response', response);
48
- }
49
- return response;
50
- });
51
- }
52
- export var ResponseExample;
53
- (function (ResponseExample) {
54
- function build(response, bodyExample) {
55
- return (`HTTP/?.? ${response.status} ${response.statusText}\n` +
56
- Array.from(response.headers.entries())
57
- .map(([name, value]) => `${name}: ${value}\n`)
58
- .join('') +
59
- '\n' +
60
- (bodyExample !== null && bodyExample !== void 0 ? bodyExample : '<none>'));
61
- }
62
- ResponseExample.build = build;
63
- function bodyExcerpt(response, maxLength) {
64
- var _a;
65
- return __awaiter(this, void 0, void 0, function* () {
66
- let body;
67
- let bodyExcerpt;
68
- try {
69
- if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.startsWith('text/')) {
70
- const text = yield response.text();
71
- body = text;
72
- if (text.length > maxLength) {
73
- const exampleText = text.slice(0, maxLength);
74
- const remainingTextLength = text.length - maxLength;
75
- bodyExcerpt = `${exampleText}<<... ${remainingTextLength} characters>>`;
76
- }
77
- else {
78
- bodyExcerpt = text;
79
- }
80
- }
81
- else {
82
- const blob = yield response.blob();
83
- body = blob;
84
- if (blob.size > maxLength) {
85
- bodyExcerpt = `<<binary data: ${blob.size} bytes>>`;
86
- }
87
- else {
88
- const dataSlice = yield blob.slice(0, maxLength).arrayBuffer();
89
- bodyExcerpt = Base64.encode(dataSlice);
90
- }
91
- }
92
- }
93
- catch (error) {
94
- // ignore errors
95
- const message = errorToMessage(error);
96
- body = bodyExcerpt = `<<error displaying response data: ${message}>>`;
97
- }
98
- return [bodyExcerpt, body];
99
- });
100
- }
101
- ResponseExample.bodyExcerpt = bodyExcerpt;
102
- })(ResponseExample || (ResponseExample = {}));
103
- //# sourceMappingURL=fetch.js.map