@colisweb/rescript-toolkit 4.19.0 → 4.20.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.
- package/package.json +2 -1
- 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.
|
|
3
|
+
"version": "4.20.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rescript clean",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"lenses-ppx": "6.1.10",
|
|
47
47
|
"list-selectors": "2.0.1",
|
|
48
48
|
"lodash": "4.17.21",
|
|
49
|
+
"msw": "^2.0.0",
|
|
49
50
|
"postcss": "8.4.31",
|
|
50
51
|
"postcss-preset-env": "8.0.1",
|
|
51
52
|
"prismjs": "1.29.0",
|
package/src/vendors/Msw.res
CHANGED
|
@@ -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
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
43
|
+
type httpRequest = {
|
|
44
|
+
request: request,
|
|
45
|
+
params: Js.Dict.t<string>,
|
|
46
|
+
cookies: Js.Dict.t<string>,
|
|
22
47
|
}
|
|
23
48
|
|
|
24
|
-
module
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@module("msw") @scope("
|
|
28
|
-
external
|
|
29
|
-
@module("msw") @scope("
|
|
30
|
-
external
|
|
31
|
-
@module("msw") @scope("
|
|
32
|
-
external
|
|
33
|
-
@module("msw") @scope("
|
|
34
|
-
external
|
|
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
|
}
|