@colisweb/rescript-toolkit 2.9.1-mobile → 2.10.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/media/image.jpg +0 -0
- package/package.json +2 -2
- package/src/request/Toolkit__Request.res +0 -34
- package/src/request/Toolkit__Request2.res +12 -0
- package/src/unleash/Toolkit__Unleash.res +6 -15
- package/src/vendors/Axios2.res +203 -0
- package/.env +0 -1
- package/.merlin +0 -66
- package/yarn-error.log +0 -12445
package/media/image.jpg
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colisweb/rescript-toolkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"clean": "rescript clean",
|
|
6
6
|
"build": "rescript build",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"reschema": "1.3.1",
|
|
66
66
|
"rescript": "9.1.4",
|
|
67
67
|
"rescript-classnames": "6.0.0",
|
|
68
|
-
"rescript-logger": "2.0.
|
|
68
|
+
"rescript-logger": "2.0.2",
|
|
69
69
|
"rescript-react-update": "5.0.0",
|
|
70
70
|
"restorative": "0.4.0-beta.1",
|
|
71
71
|
"sanitize-html": "2.6.1",
|
|
@@ -203,37 +203,3 @@ let delete = (
|
|
|
203
203
|
| Some(c) =>
|
|
204
204
|
request->Axios.Instance.deletec(url, c)->toResult(~mapError?, ~errorDecoder?, mapData)
|
|
205
205
|
}
|
|
206
|
-
|
|
207
|
-
module Error = {
|
|
208
|
-
type rec errorType = [
|
|
209
|
-
| #overlappingActivations(array<activation>)
|
|
210
|
-
| #compileError(string)
|
|
211
|
-
| #accessRefused
|
|
212
|
-
| #unknown
|
|
213
|
-
]
|
|
214
|
-
@decco and activation = {ruleTitle: string}
|
|
215
|
-
|
|
216
|
-
let encoder: Decco.encoder<errorType> = _v => ""->Decco.stringToJson
|
|
217
|
-
|
|
218
|
-
let decoder: Decco.decoder<errorType> = json => {
|
|
219
|
-
let error = json->Obj.magic
|
|
220
|
-
let value = switch error["code"] {
|
|
221
|
-
| Some("OVERLAPPING_ACTIVATIONS") =>
|
|
222
|
-
#overlappingActivations(
|
|
223
|
-
error["overlapped"]->Obj.magic->Array.map(a => a->activation_decode->Result.getExn),
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
| Some("COMPILE_ERROR") => #compileError(error["compileError"]->Obj.magic)
|
|
227
|
-
| Some("ACCESS_REFUSED") => #accessRefused
|
|
228
|
-
|
|
229
|
-
| _ => #unknown
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
value->Ok
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
let codec: Decco.codec<errorType> = (encoder, decoder)
|
|
236
|
-
|
|
237
|
-
@decco
|
|
238
|
-
type t = @decco.codec(codec) errorType
|
|
239
|
-
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module type Config = {
|
|
2
|
+
type argument
|
|
3
|
+
type response
|
|
4
|
+
type error
|
|
5
|
+
let exec: argument => Promise.promise<
|
|
6
|
+
result<response, Axios2.WithResult.customError<error, 'res, 'header, 'req>>,
|
|
7
|
+
>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module Make = (Config: Config) => {
|
|
11
|
+
include Config
|
|
12
|
+
}
|
|
@@ -27,19 +27,10 @@ module MakeFeature = (C: Config) => {
|
|
|
27
27
|
type t = config<C.argument>
|
|
28
28
|
|
|
29
29
|
let exec = (var: C.input) =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
%log.error(
|
|
37
|
-
"unleash decode"
|
|
38
|
-
("err", _err)
|
|
39
|
-
)
|
|
40
|
-
Js.Promise.reject(Js.Exn.raiseError(C.featureName ++ " : parse error"))
|
|
41
|
-
}
|
|
42
|
-
)
|
|
43
|
-
|> Promise.Js.fromBsPromise
|
|
44
|
-
|> Promise.Js.toResult)->Promise.mapOk(C.exec(var))
|
|
30
|
+
Axios2.get(C.envUrl ++ C.featureName, ())
|
|
31
|
+
->Promise.Js.toResult
|
|
32
|
+
->Promise.flatMapOk(({data}) => {
|
|
33
|
+
Promise.resolved(t_decode(data))
|
|
34
|
+
})
|
|
35
|
+
->Promise.mapOk(C.exec(var))
|
|
45
36
|
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
type config
|
|
2
|
+
|
|
3
|
+
module Headers = {
|
|
4
|
+
type t
|
|
5
|
+
|
|
6
|
+
external fromObj: Js.t<{..}> => t = "%identity"
|
|
7
|
+
external fromDict: Js.Dict.t<string> => t = "%identity"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module CancelToken = {
|
|
11
|
+
type t
|
|
12
|
+
|
|
13
|
+
@module("axios")
|
|
14
|
+
external source: unit => t = "source"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type requestTransformer<'data, 'a, 'transformedData> = ('data, Js.t<'a>) => 'transformedData
|
|
18
|
+
type responseTransformer<'data, 'transformedData> = 'data => 'transformedData
|
|
19
|
+
type paramsSerializer<'params, 'serializedParams> = 'params => 'serializedParams
|
|
20
|
+
type auth = {
|
|
21
|
+
username: string,
|
|
22
|
+
password: string,
|
|
23
|
+
}
|
|
24
|
+
type proxy = {host: int, port: int, auth: auth}
|
|
25
|
+
|
|
26
|
+
type response<'data, 'header> = {
|
|
27
|
+
data: 'data,
|
|
28
|
+
status: int,
|
|
29
|
+
statusText: string,
|
|
30
|
+
headers: Js.t<'header>,
|
|
31
|
+
config: config,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type error<'responseData, 'responseHeader, 'request> = {
|
|
35
|
+
request: option<'request>,
|
|
36
|
+
response: option<response<'responseData, 'responseHeader>>,
|
|
37
|
+
message: string,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type adapter<'a, 'b, 'err> = config => Promise.Js.t<response<'a, 'b>, 'err>
|
|
41
|
+
|
|
42
|
+
@module("axios")
|
|
43
|
+
external isAxiosError: error<'a, 'b, 'c> => bool = "isAxiosError"
|
|
44
|
+
|
|
45
|
+
@obj
|
|
46
|
+
external makeConfig: (
|
|
47
|
+
~url: string=?,
|
|
48
|
+
~_method: string=?,
|
|
49
|
+
~baseURL: string=?,
|
|
50
|
+
~transformRequest: array<requestTransformer<'data, Js.t<'a>, 'tranformedData>>=?,
|
|
51
|
+
~transformResponse: array<responseTransformer<'data, 'tranformedData>>=?,
|
|
52
|
+
~headers: Headers.t=?,
|
|
53
|
+
~params: Js.t<'params>=?,
|
|
54
|
+
~paramsSerializer: paramsSerializer<'params, 'serializedParams>=?,
|
|
55
|
+
~data: Js.t<'data>=?,
|
|
56
|
+
~timeout: int=?,
|
|
57
|
+
~withCredentials: bool=?,
|
|
58
|
+
~adapter: adapter<'a, 'b, 'err>=?,
|
|
59
|
+
~auth: auth=?,
|
|
60
|
+
~responseType: string=?,
|
|
61
|
+
~xsrfCookieName: string=?,
|
|
62
|
+
~xsrfHeaderName: string=?,
|
|
63
|
+
~onUploadProgress: 'uploadProgress => unit=?,
|
|
64
|
+
~onDownloadProgress: 'downloadProgress => unit=?,
|
|
65
|
+
~maxContentLength: int=?,
|
|
66
|
+
~validateStatus: int => bool=?,
|
|
67
|
+
~maxRedirects: int=?,
|
|
68
|
+
~socketPath: string=?,
|
|
69
|
+
~proxy: proxy=?,
|
|
70
|
+
~cancelToken: CancelToken.t=?,
|
|
71
|
+
unit,
|
|
72
|
+
) => config = ""
|
|
73
|
+
|
|
74
|
+
@module("axios")
|
|
75
|
+
external get: (string, ~config: config=?, unit) => Promise.Js.t<response<'data, 'headers>, 'err> =
|
|
76
|
+
"get"
|
|
77
|
+
|
|
78
|
+
@module("axios")
|
|
79
|
+
external post: (
|
|
80
|
+
string,
|
|
81
|
+
~data: 'a,
|
|
82
|
+
~config: config=?,
|
|
83
|
+
unit,
|
|
84
|
+
) => Promise.Js.t<response<'data, 'headers>, 'err> = "post"
|
|
85
|
+
|
|
86
|
+
@module("axios")
|
|
87
|
+
external put: (
|
|
88
|
+
string,
|
|
89
|
+
~data: 'a,
|
|
90
|
+
~config: config=?,
|
|
91
|
+
unit,
|
|
92
|
+
) => Promise.Js.t<response<'data, 'headers>, 'err> = "put"
|
|
93
|
+
|
|
94
|
+
@module("axios")
|
|
95
|
+
external patch: (
|
|
96
|
+
string,
|
|
97
|
+
~data: 'a,
|
|
98
|
+
~config: config=?,
|
|
99
|
+
unit,
|
|
100
|
+
) => Promise.Js.t<response<'data, 'headers>, 'err> = "patch"
|
|
101
|
+
|
|
102
|
+
@module("axios")
|
|
103
|
+
external delete: (
|
|
104
|
+
string,
|
|
105
|
+
~config: config=?,
|
|
106
|
+
unit,
|
|
107
|
+
) => Promise.Js.t<response<'data, 'headers>, 'err> = "delete"
|
|
108
|
+
|
|
109
|
+
@module("axios")
|
|
110
|
+
external options: (
|
|
111
|
+
string,
|
|
112
|
+
~config: config=?,
|
|
113
|
+
unit,
|
|
114
|
+
) => Promise.Js.t<response<'data, 'headers>, 'err> = "options"
|
|
115
|
+
|
|
116
|
+
module Interceptors = {
|
|
117
|
+
@module("axios") @scope(("default", "interceptors", "request"))
|
|
118
|
+
external requestInterceptor: ('config => Promise.Js.t<'updatedConfig, 'error>) => unit = "use"
|
|
119
|
+
|
|
120
|
+
@module("axios") @scope(("default", "interceptors", "response"))
|
|
121
|
+
external responseInterceptor: ('response => Promise.Js.t<'updatedResponse, 'error>) => unit =
|
|
122
|
+
"use"
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
module WithResult = {
|
|
126
|
+
type customError<'apiError, 'response, 'headers, 'request> = [
|
|
127
|
+
| #default(error<'response, 'headers, 'request>)
|
|
128
|
+
| #decodeError(Decco.decodeError)
|
|
129
|
+
| #custom('apiError)
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
type decodeData<'newData, 'err> = Js.Json.t => result<'newData, 'err>
|
|
133
|
+
|
|
134
|
+
type mapError<'a, 'response, 'headers, 'request> = error<
|
|
135
|
+
'response,
|
|
136
|
+
'headers,
|
|
137
|
+
'request,
|
|
138
|
+
> => customError<'a, 'response, 'headers, 'request>
|
|
139
|
+
|
|
140
|
+
let toResult = (promise, ~mapError, ~decodeData) =>
|
|
141
|
+
promise
|
|
142
|
+
->Promise.Js.toResult
|
|
143
|
+
->Promise.mapError(err => mapError->Option.mapWithDefault(#default(err), fn => fn(err)))
|
|
144
|
+
->Promise.flatMapOk(response => {
|
|
145
|
+
Promise.resolved(
|
|
146
|
+
switch decodeData(response.data) {
|
|
147
|
+
| Ok(_) as ok => ok
|
|
148
|
+
| Error(decodeError) => Error(#decodeError(decodeError))
|
|
149
|
+
},
|
|
150
|
+
)
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
let get = (
|
|
154
|
+
string,
|
|
155
|
+
~config=?,
|
|
156
|
+
~decodeData: decodeData<'newData, 'err>,
|
|
157
|
+
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
158
|
+
unit,
|
|
159
|
+
) => get(string, ~config?, unit)->toResult(~decodeData, ~mapError)
|
|
160
|
+
|
|
161
|
+
let post = (
|
|
162
|
+
string,
|
|
163
|
+
~data,
|
|
164
|
+
~config=?,
|
|
165
|
+
~decodeData: decodeData<'newData, 'err>,
|
|
166
|
+
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
167
|
+
unit,
|
|
168
|
+
) => post(string, ~data, ~config?, unit)->toResult(~decodeData, ~mapError)
|
|
169
|
+
|
|
170
|
+
let put = (
|
|
171
|
+
string,
|
|
172
|
+
~data,
|
|
173
|
+
~config=?,
|
|
174
|
+
~decodeData: decodeData<'newData, 'err>,
|
|
175
|
+
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
176
|
+
unit,
|
|
177
|
+
) => put(string, ~data, ~config?, unit)->toResult(~decodeData, ~mapError)
|
|
178
|
+
|
|
179
|
+
let patch = (
|
|
180
|
+
string,
|
|
181
|
+
~data,
|
|
182
|
+
~config=?,
|
|
183
|
+
~decodeData: decodeData<'newData, 'err>,
|
|
184
|
+
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
185
|
+
unit,
|
|
186
|
+
) => patch(string, ~data, ~config?, unit)->toResult(~decodeData, ~mapError)
|
|
187
|
+
|
|
188
|
+
let delete = (
|
|
189
|
+
string,
|
|
190
|
+
~config=?,
|
|
191
|
+
~decodeData: decodeData<'newData, 'err>,
|
|
192
|
+
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
193
|
+
unit,
|
|
194
|
+
) => delete(string, ~config?, unit)->toResult(~decodeData, ~mapError)
|
|
195
|
+
|
|
196
|
+
let options = (
|
|
197
|
+
string,
|
|
198
|
+
~config=?,
|
|
199
|
+
~decodeData: decodeData<'newData, 'err>,
|
|
200
|
+
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
201
|
+
unit,
|
|
202
|
+
) => options(string, ~config?, unit)->toResult(~decodeData, ~mapError)
|
|
203
|
+
}
|
package/.env
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
STORYBOOK_HERE_API_KEY=XdOccRM258JaG5yYFTQYOwqSE_hrosqcWHugsLUOrIg
|
package/.merlin
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
####{BSB GENERATED: NO EDIT
|
|
2
|
-
FLG -ppx /Users/colisweb/Projects/rescript-toolkit/node_modules/decco/ppx
|
|
3
|
-
FLG -ppx /Users/colisweb/Projects/rescript-toolkit/node_modules/lenses-ppx/ppx
|
|
4
|
-
FLG -ppx /Users/colisweb/Projects/rescript-toolkit/node_modules/rescript-logger/ppx
|
|
5
|
-
FLG -ppx '/Users/colisweb/Projects/rescript-toolkit/node_modules/rescript/darwin/bsc.exe -as-ppx -bs-jsx 3'
|
|
6
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/rescript/lib/ocaml
|
|
7
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/rescript/lib/ocaml
|
|
8
|
-
FLG -open Belt -open Cx
|
|
9
|
-
FLG -w +a-4-9-20-40-41-42-50-61-102-44-30-32-40-42-61
|
|
10
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/bs-css/lib/ocaml
|
|
11
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/bs-css/lib/ocaml
|
|
12
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/bs-css-emotion/lib/ocaml
|
|
13
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/bs-css-emotion/lib/ocaml
|
|
14
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/@rescript/react/lib/ocaml
|
|
15
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/@rescript/react/lib/ocaml
|
|
16
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/bs-axios/lib/ocaml
|
|
17
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/bs-axios/lib/ocaml
|
|
18
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/reason-promise/lib/ocaml
|
|
19
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/reason-promise/lib/ocaml
|
|
20
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/reason-react/lib/ocaml
|
|
21
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/reason-react/lib/ocaml
|
|
22
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/decco/lib/ocaml
|
|
23
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/decco/lib/ocaml
|
|
24
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/rescript-classnames/lib/ocaml
|
|
25
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/rescript-classnames/lib/ocaml
|
|
26
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/rescript-logger/lib/ocaml
|
|
27
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/rescript-logger/lib/ocaml
|
|
28
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/reschema/lib/ocaml
|
|
29
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/reschema/lib/ocaml
|
|
30
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/rescript-react-update/lib/ocaml
|
|
31
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/rescript-react-update/lib/ocaml
|
|
32
|
-
S /Users/colisweb/Projects/rescript-toolkit/node_modules/restorative/lib/ocaml
|
|
33
|
-
B /Users/colisweb/Projects/rescript-toolkit/node_modules/restorative/lib/ocaml
|
|
34
|
-
S stories
|
|
35
|
-
B lib/bs/stories
|
|
36
|
-
S src
|
|
37
|
-
B lib/bs/src
|
|
38
|
-
S src/router
|
|
39
|
-
B lib/bs/src/router
|
|
40
|
-
S src/unleash
|
|
41
|
-
B lib/bs/src/unleash
|
|
42
|
-
S src/sentry
|
|
43
|
-
B lib/bs/src/sentry
|
|
44
|
-
S src/request
|
|
45
|
-
B lib/bs/src/request
|
|
46
|
-
S src/decoders
|
|
47
|
-
B lib/bs/src/decoders
|
|
48
|
-
S src/hooks
|
|
49
|
-
B lib/bs/src/hooks
|
|
50
|
-
S src/identifier
|
|
51
|
-
B lib/bs/src/identifier
|
|
52
|
-
S src/primitives
|
|
53
|
-
B lib/bs/src/primitives
|
|
54
|
-
S src/utils
|
|
55
|
-
B lib/bs/src/utils
|
|
56
|
-
S src/fetcher
|
|
57
|
-
B lib/bs/src/fetcher
|
|
58
|
-
S src/form
|
|
59
|
-
B lib/bs/src/form
|
|
60
|
-
S src/vendors
|
|
61
|
-
B lib/bs/src/vendors
|
|
62
|
-
S src/vendors/reach-ui
|
|
63
|
-
B lib/bs/src/vendors/reach-ui
|
|
64
|
-
S src/ui
|
|
65
|
-
B lib/bs/src/ui
|
|
66
|
-
####BSB GENERATED: NO EDIT}
|