@colisweb/rescript-toolkit 5.8.0 → 5.8.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.
- package/.gitlab-ci.yml +1 -1
- package/.secure_files/{ci-functions-v17.7.2 → ci-functions-v17.12.0} +116 -64
- package/.secure_files/{ci-functions-v17.7.0 → ci-functions-v17.12.0-feat-add-mysql-service-1.0.1beta} +138 -83
- package/.secure_files/{ci-functions-v17.7.1 → ci-functions-v17.12.0-feat-add-mysql-service-1.0.2beta} +138 -83
- package/.secure_files/{ci-functions-v17.2.4 → ci-functions-v17.12.0-feat-add-mysql-service-1.0.3beta} +214 -103
- package/.secure_files/ci-functions-v17.12.0-feat-add-mysql-service-1.0.4beta +2658 -0
- package/.secure_files/ci-functions-v17.12.0-feat-add-mysql-service-1.0.5beta +2658 -0
- package/.secure_files/ci-functions-v17.12.0-feat-add-mysql-service-1.0.6beta +2658 -0
- package/.secure_files/ci-functions-v17.12.0-feat-add-mysql-service-1.0.7beta +2658 -0
- package/.secure_files/ci-functions-v17.13.0 +2659 -0
- package/.secure_files/ci-functions-v17.14.0 +2659 -0
- package/package.json +2 -2
- package/src/request/index.md +79 -82
- package/.secure_files/ci-functions-v17.2.1 +0 -2547
- package/.secure_files/ci-functions-v17.2.2 +0 -2547
- package/.secure_files/ci-functions-v17.2.3 +0 -2547
- package/.secure_files/ci-functions-v17.3.0 +0 -2547
- package/.secure_files/ci-functions-v17.3.1 +0 -2547
- package/.secure_files/ci-functions-v17.3.2 +0 -2547
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colisweb/rescript-toolkit",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rescript clean",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@colisweb/bs-react-intl-extractor-bin": "0.12.2",
|
|
31
31
|
"@datadog/browser-rum": "5.8.0",
|
|
32
|
-
"@dck/rescript-ky": "2.0.
|
|
32
|
+
"@dck/rescript-ky": "2.0.4",
|
|
33
33
|
"@dck/rescript-promise": "1.1.0",
|
|
34
34
|
"@dck/restorative": "1.1.0",
|
|
35
35
|
"@greenlabs/ppx-spice": "0.2.1",
|
package/src/request/index.md
CHANGED
|
@@ -4,100 +4,97 @@
|
|
|
4
4
|
|
|
5
5
|
```rescript
|
|
6
6
|
module API = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[@spice]
|
|
12
|
-
type response = array(user)
|
|
13
|
-
[@spice]
|
|
14
|
-
and user = {
|
|
15
|
-
name: string
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type error = string;
|
|
19
|
-
|
|
20
|
-
let exec = clientId => {
|
|
21
|
-
request->Request.get(baseUrl(~clientId), response_decode);
|
|
22
|
-
};
|
|
23
|
-
};
|
|
7
|
+
let kyInstance = Ky.Instance.create({
|
|
8
|
+
prefixUrl: `${ColiswebApi__Env.v6ApiUrl}`,
|
|
9
|
+
timeout: ColiswebApi__Env.isNodeDevelopment ? 5000 : 20000,
|
|
10
|
+
})
|
|
24
11
|
|
|
25
|
-
|
|
12
|
+
module FetchUsers = {
|
|
13
|
+
type argument = ()
|
|
14
|
+
|
|
15
|
+
@spice
|
|
16
|
+
type user = {
|
|
17
|
+
id: string,
|
|
18
|
+
name: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@spice
|
|
22
|
+
type response = {
|
|
23
|
+
users: array<user>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type error = unit
|
|
27
|
+
|
|
28
|
+
let config = () => {
|
|
29
|
+
kyInstance,
|
|
30
|
+
requestOptions: {
|
|
31
|
+
method: Ky.HttpMethod.GET,
|
|
32
|
+
},
|
|
33
|
+
key: [
|
|
34
|
+
"FetchUser"
|
|
35
|
+
],
|
|
36
|
+
path: `/users`,
|
|
37
|
+
}
|
|
26
38
|
};
|
|
27
39
|
};
|
|
28
40
|
|
|
29
|
-
API.FetchUsers
|
|
41
|
+
let (data, isLoading, _) = Request.useFetcher(module(API.FetchUsers), Some())
|
|
42
|
+
|
|
43
|
+
Request.fetchAPI(module(API.FetchUsers), Some())
|
|
44
|
+
->Promise.tapOk(({users}) => Js.log(users))
|
|
30
45
|
```
|
|
31
46
|
|
|
32
47
|
### Handle custom error
|
|
33
48
|
|
|
34
49
|
```rescript
|
|
35
50
|
module API = {
|
|
51
|
+
let kyInstance = Ky.Instance.create({
|
|
52
|
+
prefixUrl: `${ColiswebApi__Env.v6ApiUrl}`,
|
|
53
|
+
timeout: ColiswebApi__Env.isNodeDevelopment ? 5000 : 20000,
|
|
54
|
+
})
|
|
55
|
+
|
|
36
56
|
module FetchUsers = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
let codec: Spice.codec(errorType) = (encoder, decoder);
|
|
70
|
-
|
|
71
|
-
[@spice]
|
|
72
|
-
type t = [@spice.codec codec] errorType;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
module Config = {
|
|
76
|
-
type argument = unit;
|
|
77
|
-
|
|
78
|
-
[@spice]
|
|
79
|
-
type response = array(user)
|
|
80
|
-
[@spice]
|
|
81
|
-
and user = {
|
|
82
|
-
name: string
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
[@spice]
|
|
86
|
-
type error = Error.t;
|
|
87
|
-
|
|
88
|
-
let exec = clientId => {
|
|
89
|
-
request->Request.get(baseUrl(~clientId), ~errorDecoder=error_decode,response_decode);
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
module Request = Toolkit.Request.Make(Config);
|
|
57
|
+
type argument = ()
|
|
58
|
+
|
|
59
|
+
@spice
|
|
60
|
+
type user = {
|
|
61
|
+
id: string,
|
|
62
|
+
name: string
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@spice
|
|
66
|
+
type response = {
|
|
67
|
+
users: array<user>
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
type error = Anything
|
|
71
|
+
|
|
72
|
+
let config = () => {
|
|
73
|
+
kyInstance,
|
|
74
|
+
requestOptions: {
|
|
75
|
+
method: Ky.HttpMethod.GET,
|
|
76
|
+
},
|
|
77
|
+
key: [
|
|
78
|
+
"FetchUser"
|
|
79
|
+
],
|
|
80
|
+
path: `/users`,
|
|
81
|
+
mapCustomErrors: error =>
|
|
82
|
+
switch error.response {
|
|
83
|
+
| Some({status: 409}) => Custom(Anything)
|
|
84
|
+
| _ => Unknown(error)
|
|
85
|
+
}->Promise.resolved,
|
|
86
|
+
}
|
|
94
87
|
};
|
|
95
88
|
};
|
|
96
89
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
|
|
91
|
+
Request.fetchAPI(module(API.FetchUsers), Some())
|
|
92
|
+
->Promise.tapOk(({users}) => Js.log(users))
|
|
93
|
+
->Promise.tapError(error => {
|
|
94
|
+
switch error {
|
|
95
|
+
| Custom(Anything) => ...
|
|
96
|
+
| DecodeError(spiceError) => ...
|
|
97
|
+
| Unknown(kyError) => ...
|
|
98
|
+
}
|
|
99
|
+
})
|
|
103
100
|
```
|