0 | module Web.Raw.Fetch
  1 |
  2 | import JS
  3 | import Web.Internal.FetchPrim
  4 | import Web.Internal.Types
  5 |
  6 | %default total
  7 |
  8 |
  9 | --------------------------------------------------------------------------------
 10 | --          Interfaces
 11 | --------------------------------------------------------------------------------
 12 |
 13 | namespace Headers
 14 |
 15 |   export
 16 |   new' :
 17 |        (init : Optional
 18 |                  (HSum
 19 |                     [Array (Array ByteString), Record ByteString ByteString]))
 20 |     -> JSIO Headers
 21 |   new' a = primJS $ Headers.prim__new (toFFI a)
 22 |
 23 |   export
 24 |   new : JSIO Headers
 25 |   new = primJS $ Headers.prim__new undef
 26 |
 27 |
 28 |   export
 29 |   append :
 30 |        (obj : Headers)
 31 |     -> (name : ByteString)
 32 |     -> (value : ByteString)
 33 |     -> JSIO ()
 34 |   append a b c = primJS $ Headers.prim__append a b c
 35 |
 36 |
 37 |   export
 38 |   delete : (obj : Headers) -> (name : ByteString) -> JSIO ()
 39 |   delete a b = primJS $ Headers.prim__delete a b
 40 |
 41 |
 42 |   export
 43 |   get : (obj : Headers) -> (name : ByteString) -> JSIO (Maybe ByteString)
 44 |   get a b = tryJS "Headers.get" $ Headers.prim__get a b
 45 |
 46 |
 47 |   export
 48 |   has : (obj : Headers) -> (name : ByteString) -> JSIO Bool
 49 |   has a b = tryJS "Headers.has" $ Headers.prim__has a b
 50 |
 51 |
 52 |   export
 53 |   set :
 54 |        (obj : Headers)
 55 |     -> (name : ByteString)
 56 |     -> (value : ByteString)
 57 |     -> JSIO ()
 58 |   set a b c = primJS $ Headers.prim__set a b c
 59 |
 60 |
 61 |
 62 | namespace Request
 63 |
 64 |   export
 65 |   new' :
 66 |        {auto 0 _ : JSType t2}
 67 |     -> {auto 0 _ : Elem RequestInit (Types t2)}
 68 |     -> (input : HSum [Request, String])
 69 |     -> (init : Optional t2)
 70 |     -> JSIO Request
 71 |   new' a b = primJS $ Request.prim__new (toFFI a) (optUp b)
 72 |
 73 |   export
 74 |   new : (input : HSum [Request, String]) -> JSIO Request
 75 |   new a = primJS $ Request.prim__new (toFFI a) undef
 76 |
 77 |
 78 |   export
 79 |   cache : (obj : Request) -> JSIO RequestCache
 80 |   cache a = tryJS "Request.cache" $ Request.prim__cache a
 81 |
 82 |
 83 |   export
 84 |   credentials : (obj : Request) -> JSIO RequestCredentials
 85 |   credentials a = tryJS "Request.credentials" $ Request.prim__credentials a
 86 |
 87 |
 88 |   export
 89 |   destination : (obj : Request) -> JSIO RequestDestination
 90 |   destination a = tryJS "Request.destination" $ Request.prim__destination a
 91 |
 92 |
 93 |   export
 94 |   headers : (obj : Request) -> JSIO Headers
 95 |   headers a = primJS $ Request.prim__headers a
 96 |
 97 |
 98 |   export
 99 |   integrity : (obj : Request) -> JSIO String
100 |   integrity a = primJS $ Request.prim__integrity a
101 |
102 |
103 |   export
104 |   isHistoryNavigation : (obj : Request) -> JSIO Bool
105 |   isHistoryNavigation a = tryJS "Request.isHistoryNavigation" $
106 |     Request.prim__isHistoryNavigation a
107 |
108 |
109 |   export
110 |   isReloadNavigation : (obj : Request) -> JSIO Bool
111 |   isReloadNavigation a = tryJS "Request.isReloadNavigation" $
112 |     Request.prim__isReloadNavigation a
113 |
114 |
115 |   export
116 |   keepalive : (obj : Request) -> JSIO Bool
117 |   keepalive a = tryJS "Request.keepalive" $ Request.prim__keepalive a
118 |
119 |
120 |   export
121 |   method : (obj : Request) -> JSIO ByteString
122 |   method a = primJS $ Request.prim__method a
123 |
124 |
125 |   export
126 |   mode : (obj : Request) -> JSIO RequestMode
127 |   mode a = tryJS "Request.mode" $ Request.prim__mode a
128 |
129 |
130 |   export
131 |   redirect : (obj : Request) -> JSIO RequestRedirect
132 |   redirect a = tryJS "Request.redirect" $ Request.prim__redirect a
133 |
134 |
135 |   export
136 |   referrer : (obj : Request) -> JSIO String
137 |   referrer a = primJS $ Request.prim__referrer a
138 |
139 |
140 |   export
141 |   referrerPolicy : (obj : Request) -> JSIO ReferrerPolicy
142 |   referrerPolicy a = tryJS "Request.referrerPolicy" $
143 |     Request.prim__referrerPolicy a
144 |
145 |
146 |   export
147 |   signal : (obj : Request) -> JSIO AbortSignal
148 |   signal a = primJS $ Request.prim__signal a
149 |
150 |
151 |   export
152 |   url : (obj : Request) -> JSIO String
153 |   url a = primJS $ Request.prim__url a
154 |
155 |
156 |   export
157 |   clone : (obj : Request) -> JSIO Request
158 |   clone a = primJS $ Request.prim__clone a
159 |
160 |
161 |
162 | namespace Response
163 |
164 |   export
165 |   new' :
166 |        {auto 0 _ : JSType t2}
167 |     -> {auto 0 _ : Elem ResponseInit (Types t2)}
168 |     -> (body : Optional
169 |                  (Maybe
170 |                     (HSum
171 |                        [ ReadableStream
172 |                        , Blob
173 |                        , Int8Array
174 |                        , Int16Array
175 |                        , Int32Array
176 |                        , UInt8Array
177 |                        , UInt8Array
178 |                        , UInt8Array
179 |                        , UInt8ClampedArray
180 |                        , Float32Array
181 |                        , Float64Array
182 |                        , DataView
183 |                        , ArrayBuffer
184 |                        , FormData
185 |                        , URLSearchParams
186 |                        , String
187 |                        ])))
188 |     -> (init : Optional t2)
189 |     -> JSIO Response
190 |   new' a b = primJS $ Response.prim__new (toFFI a) (optUp b)
191 |
192 |   export
193 |   new : JSIO Response
194 |   new = primJS $ Response.prim__new undef undef
195 |
196 |
197 |   export
198 |   error : JSIO Response
199 |   error = primJS $ Response.prim__error
200 |
201 |
202 |   export
203 |   redirect' : (url : String) -> (status : Optional Bits16) -> JSIO Response
204 |   redirect' a b = primJS $ Response.prim__redirect a (toFFI b)
205 |
206 |   export
207 |   redirect : (url : String) -> JSIO Response
208 |   redirect a = primJS $ Response.prim__redirect a undef
209 |
210 |
211 |   export
212 |   headers : (obj : Response) -> JSIO Headers
213 |   headers a = primJS $ Response.prim__headers a
214 |
215 |
216 |   export
217 |   ok : (obj : Response) -> JSIO Bool
218 |   ok a = tryJS "Response.ok" $ Response.prim__ok a
219 |
220 |
221 |   export
222 |   redirected : (obj : Response) -> JSIO Bool
223 |   redirected a = tryJS "Response.redirected" $ Response.prim__redirected a
224 |
225 |
226 |   export
227 |   status : (obj : Response) -> JSIO Bits16
228 |   status a = primJS $ Response.prim__status a
229 |
230 |
231 |   export
232 |   statusText : (obj : Response) -> JSIO ByteString
233 |   statusText a = primJS $ Response.prim__statusText a
234 |
235 |
236 |   export
237 |   type : (obj : Response) -> JSIO ResponseType
238 |   type a = tryJS "Response.type" $ Response.prim__type a
239 |
240 |
241 |   export
242 |   url : (obj : Response) -> JSIO String
243 |   url a = primJS $ Response.prim__url a
244 |
245 |
246 |   export
247 |   clone : (obj : Response) -> JSIO Response
248 |   clone a = primJS $ Response.prim__clone a
249 |
250 |
251 |
252 |
253 | --------------------------------------------------------------------------------
254 | --          Mixins
255 | --------------------------------------------------------------------------------
256 |
257 | namespace Body
258 |
259 |   export
260 |   body :
261 |        {auto 0 _ : JSType t1}
262 |     -> {auto 0 _ : Elem Body (Types t1)}
263 |     -> (obj : t1)
264 |     -> JSIO (Maybe ReadableStream)
265 |   body a = tryJS "Body.body" $ Body.prim__body (up a)
266 |
267 |
268 |   export
269 |   bodyUsed :
270 |        {auto 0 _ : JSType t1}
271 |     -> {auto 0 _ : Elem Body (Types t1)}
272 |     -> (obj : t1)
273 |     -> JSIO Bool
274 |   bodyUsed a = tryJS "Body.bodyUsed" $ Body.prim__bodyUsed (up a)
275 |
276 |
277 |   export
278 |   arrayBuffer :
279 |        {auto 0 _ : JSType t1}
280 |     -> {auto 0 _ : Elem Body (Types t1)}
281 |     -> (obj : t1)
282 |     -> JSIO (Promise ArrayBuffer)
283 |   arrayBuffer a = primJS $ Body.prim__arrayBuffer (up a)
284 |
285 |
286 |   export
287 |   blob :
288 |        {auto 0 _ : JSType t1}
289 |     -> {auto 0 _ : Elem Body (Types t1)}
290 |     -> (obj : t1)
291 |     -> JSIO (Promise Blob)
292 |   blob a = primJS $ Body.prim__blob (up a)
293 |
294 |
295 |   export
296 |   formData :
297 |        {auto 0 _ : JSType t1}
298 |     -> {auto 0 _ : Elem Body (Types t1)}
299 |     -> (obj : t1)
300 |     -> JSIO (Promise FormData)
301 |   formData a = primJS $ Body.prim__formData (up a)
302 |
303 |
304 |   export
305 |   json :
306 |        {auto 0 _ : JSType t1}
307 |     -> {auto 0 _ : Elem Body (Types t1)}
308 |     -> (obj : t1)
309 |     -> JSIO (Promise AnyPtr)
310 |   json a = primJS $ Body.prim__json (up a)
311 |
312 |
313 |   export
314 |   text :
315 |        {auto 0 _ : JSType t1}
316 |     -> {auto 0 _ : Elem Body (Types t1)}
317 |     -> (obj : t1)
318 |     -> JSIO (Promise String)
319 |   text a = primJS $ Body.prim__text (up a)
320 |
321 |
322 |
323 |
324 | --------------------------------------------------------------------------------
325 | --          Dictionaries
326 | --------------------------------------------------------------------------------
327 |
328 | namespace RequestInit
329 |
330 |   export
331 |   new' :
332 |        (method : Optional ByteString)
333 |     -> (headers : Optional
334 |                     (HSum
335 |                        [ Array (Array ByteString)
336 |                        , Record ByteString ByteString
337 |                        ]))
338 |     -> (body : Optional
339 |                  (Maybe
340 |                     (HSum
341 |                        [ ReadableStream
342 |                        , Blob
343 |                        , Int8Array
344 |                        , Int16Array
345 |                        , Int32Array
346 |                        , UInt8Array
347 |                        , UInt8Array
348 |                        , UInt8Array
349 |                        , UInt8ClampedArray
350 |                        , Float32Array
351 |                        , Float64Array
352 |                        , DataView
353 |                        , ArrayBuffer
354 |                        , FormData
355 |                        , URLSearchParams
356 |                        , String
357 |                        ])))
358 |     -> (referrer : Optional String)
359 |     -> (referrerPolicy : Optional ReferrerPolicy)
360 |     -> (mode : Optional RequestMode)
361 |     -> (credentials : Optional RequestCredentials)
362 |     -> (cache : Optional RequestCache)
363 |     -> (redirect : Optional RequestRedirect)
364 |     -> (integrity : Optional String)
365 |     -> (keepalive : Optional Bool)
366 |     -> (signal : Optional (Maybe AbortSignal))
367 |     -> (window : Optional Any)
368 |     -> JSIO RequestInit
369 |   new' a b c d e f g h i j k l m = primJS $
370 |     RequestInit.prim__new
371 |       (toFFI a)
372 |       (toFFI b)
373 |       (toFFI c)
374 |       (toFFI d)
375 |       (toFFI e)
376 |       (toFFI f)
377 |       (toFFI g)
378 |       (toFFI h)
379 |       (toFFI i)
380 |       (toFFI j)
381 |       (toFFI k)
382 |       (toFFI l)
383 |       (toFFI m)
384 |
385 |   export
386 |   new : JSIO RequestInit
387 |   new = primJS $
388 |     RequestInit.prim__new
389 |       undef
390 |       undef
391 |       undef
392 |       undef
393 |       undef
394 |       undef
395 |       undef
396 |       undef
397 |       undef
398 |       undef
399 |       undef
400 |       undef
401 |       undef
402 |
403 |
404 |   export
405 |   body :
406 |        {auto 0 _ : JSType t}
407 |     -> {auto 0 _ : Elem RequestInit (Types t)}
408 |     -> t
409 |     -> Attribute False Optional (Maybe
410 |                                    (Union16
411 |                                       ReadableStream
412 |                                       Blob
413 |                                       Int8Array
414 |                                       Int16Array
415 |                                       Int32Array
416 |                                       UInt8Array
417 |                                       UInt8Array
418 |                                       UInt8Array
419 |                                       UInt8ClampedArray
420 |                                       Float32Array
421 |                                       Float64Array
422 |                                       DataView
423 |                                       ArrayBuffer
424 |                                       FormData
425 |                                       URLSearchParams
426 |                                       String))
427 |   body v = fromUndefOrPrimNoDefault
428 |              "RequestInit.getbody"
429 |              prim__body
430 |              prim__setBody
431 |              (v :> RequestInit)
432 |
433 |
434 |   export
435 |   cache :
436 |        {auto 0 _ : JSType t}
437 |     -> {auto 0 _ : Elem RequestInit (Types t)}
438 |     -> t
439 |     -> Attribute False Optional RequestCache
440 |   cache v = fromUndefOrPrimNoDefault
441 |               "RequestInit.getcache"
442 |               prim__cache
443 |               prim__setCache
444 |               (v :> RequestInit)
445 |
446 |
447 |   export
448 |   credentials :
449 |        {auto 0 _ : JSType t}
450 |     -> {auto 0 _ : Elem RequestInit (Types t)}
451 |     -> t
452 |     -> Attribute False Optional RequestCredentials
453 |   credentials v = fromUndefOrPrimNoDefault
454 |                     "RequestInit.getcredentials"
455 |                     prim__credentials
456 |                     prim__setCredentials
457 |                     (v :> RequestInit)
458 |
459 |
460 |   export
461 |   headers :
462 |        {auto 0 _ : JSType t}
463 |     -> {auto 0 _ : Elem RequestInit (Types t)}
464 |     -> t
465 |     -> Attribute False Optional (Union2
466 |                                    (Array (Array ByteString))
467 |                                    (Record ByteString ByteString))
468 |   headers v = fromUndefOrPrimNoDefault
469 |                 "RequestInit.getheaders"
470 |                 prim__headers
471 |                 prim__setHeaders
472 |                 (v :> RequestInit)
473 |
474 |
475 |   export
476 |   integrity :
477 |        {auto 0 _ : JSType t}
478 |     -> {auto 0 _ : Elem RequestInit (Types t)}
479 |     -> t
480 |     -> Attribute False Optional String
481 |   integrity v = fromUndefOrPrimNoDefault
482 |                   "RequestInit.getintegrity"
483 |                   prim__integrity
484 |                   prim__setIntegrity
485 |                   (v :> RequestInit)
486 |
487 |
488 |   export
489 |   keepalive :
490 |        {auto 0 _ : JSType t}
491 |     -> {auto 0 _ : Elem RequestInit (Types t)}
492 |     -> t
493 |     -> Attribute False Optional Bool
494 |   keepalive v = fromUndefOrPrimNoDefault
495 |                   "RequestInit.getkeepalive"
496 |                   prim__keepalive
497 |                   prim__setKeepalive
498 |                   (v :> RequestInit)
499 |
500 |
501 |   export
502 |   method :
503 |        {auto 0 _ : JSType t}
504 |     -> {auto 0 _ : Elem RequestInit (Types t)}
505 |     -> t
506 |     -> Attribute False Optional ByteString
507 |   method v = fromUndefOrPrimNoDefault
508 |                "RequestInit.getmethod"
509 |                prim__method
510 |                prim__setMethod
511 |                (v :> RequestInit)
512 |
513 |
514 |   export
515 |   mode :
516 |        {auto 0 _ : JSType t}
517 |     -> {auto 0 _ : Elem RequestInit (Types t)}
518 |     -> t
519 |     -> Attribute False Optional RequestMode
520 |   mode v = fromUndefOrPrimNoDefault
521 |              "RequestInit.getmode"
522 |              prim__mode
523 |              prim__setMode
524 |              (v :> RequestInit)
525 |
526 |
527 |   export
528 |   redirect :
529 |        {auto 0 _ : JSType t}
530 |     -> {auto 0 _ : Elem RequestInit (Types t)}
531 |     -> t
532 |     -> Attribute False Optional RequestRedirect
533 |   redirect v = fromUndefOrPrimNoDefault
534 |                  "RequestInit.getredirect"
535 |                  prim__redirect
536 |                  prim__setRedirect
537 |                  (v :> RequestInit)
538 |
539 |
540 |   export
541 |   referrer :
542 |        {auto 0 _ : JSType t}
543 |     -> {auto 0 _ : Elem RequestInit (Types t)}
544 |     -> t
545 |     -> Attribute False Optional String
546 |   referrer v = fromUndefOrPrimNoDefault
547 |                  "RequestInit.getreferrer"
548 |                  prim__referrer
549 |                  prim__setReferrer
550 |                  (v :> RequestInit)
551 |
552 |
553 |   export
554 |   referrerPolicy :
555 |        {auto 0 _ : JSType t}
556 |     -> {auto 0 _ : Elem RequestInit (Types t)}
557 |     -> t
558 |     -> Attribute False Optional ReferrerPolicy
559 |   referrerPolicy v = fromUndefOrPrimNoDefault
560 |                        "RequestInit.getreferrerPolicy"
561 |                        prim__referrerPolicy
562 |                        prim__setReferrerPolicy
563 |                        (v :> RequestInit)
564 |
565 |
566 |   export
567 |   signal :
568 |        {auto 0 _ : JSType t}
569 |     -> {auto 0 _ : Elem RequestInit (Types t)}
570 |     -> t
571 |     -> Attribute False Optional (Maybe AbortSignal)
572 |   signal v = fromUndefOrPrimNoDefault
573 |                "RequestInit.getsignal"
574 |                prim__signal
575 |                prim__setSignal
576 |                (v :> RequestInit)
577 |
578 |
579 |   export
580 |   window :
581 |        {auto 0 _ : JSType t}
582 |     -> {auto 0 _ : Elem RequestInit (Types t)}
583 |     -> t
584 |     -> Attribute False Optional Any
585 |   window v = fromUndefOrPrimNoDefault
586 |                "RequestInit.getwindow"
587 |                prim__window
588 |                prim__setWindow
589 |                (v :> RequestInit)
590 |
591 |
592 |
593 | namespace ResponseInit
594 |
595 |   export
596 |   new' :
597 |        (status : Optional Bits16)
598 |     -> (statusText : Optional ByteString)
599 |     -> (headers : Optional
600 |                     (HSum
601 |                        [ Array (Array ByteString)
602 |                        , Record ByteString ByteString
603 |                        ]))
604 |     -> JSIO ResponseInit
605 |   new' a b c = primJS $ ResponseInit.prim__new (toFFI a) (toFFI b) (toFFI c)
606 |
607 |   export
608 |   new : JSIO ResponseInit
609 |   new = primJS $ ResponseInit.prim__new undef undef undef
610 |
611 |
612 |   export
613 |   headers :
614 |        {auto 0 _ : JSType t}
615 |     -> {auto 0 _ : Elem ResponseInit (Types t)}
616 |     -> t
617 |     -> Attribute False Optional (Union2
618 |                                    (Array (Array ByteString))
619 |                                    (Record ByteString ByteString))
620 |   headers v = fromUndefOrPrimNoDefault
621 |                 "ResponseInit.getheaders"
622 |                 prim__headers
623 |                 prim__setHeaders
624 |                 (v :> ResponseInit)
625 |
626 |
627 |   export
628 |   status :
629 |        {auto 0 _ : JSType t}
630 |     -> {auto 0 _ : Elem ResponseInit (Types t)}
631 |     -> t
632 |     -> Attribute True Optional Bits16
633 |   status v = fromUndefOrPrim
634 |                "ResponseInit.getstatus"
635 |                prim__status
636 |                prim__setStatus
637 |                200
638 |                (v :> ResponseInit)
639 |
640 |
641 |   export
642 |   statusText :
643 |        {auto 0 _ : JSType t}
644 |     -> {auto 0 _ : Elem ResponseInit (Types t)}
645 |     -> t
646 |     -> Attribute False Optional ByteString
647 |   statusText v = fromUndefOrPrimNoDefault
648 |                    "ResponseInit.getstatusText"
649 |                    prim__statusText
650 |                    prim__setStatusText
651 |                    (v :> ResponseInit)
652 |