@colisweb/rescript-toolkit 4.19.0 → 4.20.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 (2) hide show
  1. package/package.json +5 -1
  2. package/src/vendors/Msw.res +42 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "4.19.0",
3
+ "version": "4.20.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -26,6 +26,9 @@
26
26
  ],
27
27
  "author": "Colisweb",
28
28
  "license": "MIT",
29
+ "resolutions": {
30
+ "graphql": "16.7.1"
31
+ },
29
32
  "dependencies": {
30
33
  "@colisweb/bs-react-intl-extractor-bin": "0.12.2",
31
34
  "@colisweb/restorative": "1.0.0",
@@ -46,6 +49,7 @@
46
49
  "lenses-ppx": "6.1.10",
47
50
  "list-selectors": "2.0.1",
48
51
  "lodash": "4.17.21",
52
+ "msw": "^2.0.0",
49
53
  "postcss": "8.4.31",
50
54
  "postcss-preset-env": "8.0.1",
51
55
  "prismjs": "1.29.0",
@@ -4,7 +4,7 @@ type worker
4
4
  @module("msw") @variadic
5
5
  external setupWorker: array<mock> => worker = "setupWorker"
6
6
 
7
- type rec startOptions = {serviceWorker?: serviceWorker}
7
+ type rec startOptions = {serviceWorker?: serviceWorker, quiet?: bool}
8
8
  and serviceWorker = {url: string}
9
9
 
10
10
  @send
@@ -12,24 +12,49 @@ external start: (worker, startOptions) => unit = "start"
12
12
  @send
13
13
  external stop: worker => unit = "stop"
14
14
 
15
- module Ctx = {
15
+ @module("msw")
16
+ external passthrough: unit => mock = "passthrough"
17
+
18
+ @module("msw")
19
+ external delay: unit => Promise.Js.t<unit, unit> = "delay"
20
+ @module("msw")
21
+ external delayCustom: int => Promise.Js.t<unit, unit> = "delay"
22
+
23
+ module HttpResponse = {
16
24
  type t
25
+ type options = {
26
+ status?: int,
27
+ statusText?: string,
28
+ headers?: Js.Dict.t<string>,
29
+ }
30
+
31
+ @module("msw") @scope("HttpResponse")
32
+ external json: Js.Json.t => t = "json"
33
+
34
+ @module("msw") @scope("HttpResponse")
35
+ external jsonWithOptions: (Js.Json.t, options) => t = "json"
36
+ }
37
+
38
+ type request = {
39
+ method: string,
40
+ url: string,
41
+ }
17
42
 
18
- @send
19
- external json: (t, 'a) => 'b = "json"
20
- @send
21
- external status: (t, 'a) => 'b = "status"
43
+ type httpRequest = {
44
+ request: request,
45
+ params: Js.Dict.t<string>,
46
+ cookies: Js.Dict.t<string>,
22
47
  }
23
48
 
24
- module Rest = {
25
- type req<'params> = {params: 'params}
26
-
27
- @module("msw") @scope("rest")
28
- external get: (string, (req<'params>, @uncurry ('z => 't), Ctx.t) => 'a) => mock = "get"
29
- @module("msw") @scope("rest")
30
- external put: (string, (req<'params>, @uncurry ('z => 't), Ctx.t) => 'a) => mock = "put"
31
- @module("msw") @scope("rest")
32
- external post: (string, (req<'params>, @uncurry ('z => 't), Ctx.t) => 'a) => mock = "post"
33
- @module("msw") @scope("rest")
34
- external delete: (string, (req<'params>, @uncurry ('z => 't), Ctx.t) => 'a) => mock = "delete"
49
+ module Http = {
50
+ @module("msw") @scope("http")
51
+ external get: (string, httpRequest => HttpResponse.t) => mock = "get"
52
+ @module("msw") @scope("http")
53
+ external put: (string, httpRequest => HttpResponse.t) => mock = "put"
54
+ @module("msw") @scope("http")
55
+ external post: (string, httpRequest => HttpResponse.t) => mock = "post"
56
+ @module("msw") @scope("http")
57
+ external delete: (string, httpRequest => HttpResponse.t) => mock = "delete"
58
+ @module("msw") @scope("http")
59
+ external all: (string, httpRequest => HttpResponse.t) => mock = "all"
35
60
  }