rescript-relay 3.5.0 → 4.0.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/CHANGELOG.md +10 -0
- package/README.md +14 -4
- package/package.json +12 -7
- package/ppx-linux +0 -0
- package/ppx-macos-arm64 +0 -0
- package/ppx-macos-latest +0 -0
- package/ppx-windows-latest +0 -0
- package/relay-compiler-linux-musl/relay +0 -0
- package/relay-compiler-linux-x64/relay +0 -0
- package/relay-compiler-macos-arm64/relay +0 -0
- package/relay-compiler-macos-x64/relay +0 -0
- package/relay-compiler-win-x64/relay.exe +0 -0
- package/src/RescriptRelay.bs.js +151 -167
- package/src/RescriptRelay.res +61 -63
- package/src/RescriptRelay.resi +84 -110
- package/src/RescriptRelayUtils.bs.js +44 -47
- package/src/RescriptRelayUtils.res +3 -3
- package/src/RescriptRelay_Fragment.bs.js +56 -81
- package/src/RescriptRelay_Fragment.res +60 -52
- package/src/RescriptRelay_Fragment.resi +5 -5
- package/src/RescriptRelay_Internal.bs.js +38 -47
- package/src/RescriptRelay_Internal.res +5 -5
- package/src/RescriptRelay_Internal.resi +2 -4
- package/src/RescriptRelay_Mutation.bs.js +28 -42
- package/src/RescriptRelay_Mutation.res +4 -4
- package/src/RescriptRelay_Query.bs.js +43 -64
- package/src/RescriptRelay_Query.res +16 -13
- package/src/RescriptRelay_Query.resi +1 -1
- package/src/RescriptRelay_RelayResolvers.bs.js +2 -4
- package/src/RescriptRelay_Subscriptions.bs.js +9 -15
- package/src/RescriptRelay_Subscriptions.res +1 -1
- package/src/RescriptRelay_Subscriptions.resi +1 -1
- package/src/ReactDOMExperimental.bs.js +0 -23
- package/src/ReactDOMExperimental.res +0 -16
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
let React = require("react");
|
|
5
|
+
let ReactRelay = require("react-relay");
|
|
6
|
+
let Primitive_option = require("@rescript/runtime/lib/js/Primitive_option.js");
|
|
7
|
+
let RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
|
|
8
|
+
let Experimental = require("relay-runtime/experimental");
|
|
9
|
+
let ResolverFragments = require("relay-runtime/lib/store/ResolverFragments");
|
|
10
10
|
|
|
11
11
|
function useFragment(node, convertFragment, fRef) {
|
|
12
|
-
|
|
13
|
-
return RescriptRelay_Internal.internal_useConvertedValue(convertFragment, __x);
|
|
12
|
+
return RescriptRelay_Internal.internal_useConvertedValue(convertFragment, ReactRelay.useFragment(node, fRef));
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
function useFragmentOpt(fRef, node, convertFragment) {
|
|
17
|
-
|
|
18
|
-
return React.useMemo((
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}), [(data == null) ? undefined : Caml_option.some(data)]);
|
|
16
|
+
let data = ReactRelay.useFragment(node, fRef);
|
|
17
|
+
return React.useMemo(() => {
|
|
18
|
+
if (!(data == null)) {
|
|
19
|
+
return Primitive_option.some(convertFragment(data));
|
|
20
|
+
}
|
|
21
|
+
}, [(data == null) ? undefined : Primitive_option.some(data)]);
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
function readInlineData(node, convertFragment, fRef) {
|
|
@@ -31,85 +29,62 @@ function read(node, convertFragment, fRef) {
|
|
|
31
29
|
return convertFragment(ResolverFragments.readFragment(node, fRef));
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
function internal_makeRefetchableFnOpts(fetchPolicy, onComplete, param) {
|
|
35
|
-
return {
|
|
36
|
-
fetchPolicy: fetchPolicy,
|
|
37
|
-
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
32
|
function usePaginationFragment(node, fRef, convertFragment, convertRefetchVariables) {
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
let p = ReactRelay.usePaginationFragment(node, fRef);
|
|
34
|
+
let data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data);
|
|
44
35
|
return {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
hasPrevious: p.hasPrevious,
|
|
62
|
-
isLoadingNext: p.isLoadingNext,
|
|
63
|
-
isLoadingPrevious: p.isLoadingPrevious,
|
|
64
|
-
refetch: React.useMemo((function () {
|
|
65
|
-
return function (variables, fetchPolicy, onComplete) {
|
|
66
|
-
return p.refetch(RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertRefetchVariables(variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
|
|
67
|
-
};
|
|
68
|
-
}), [p.refetch])
|
|
69
|
-
};
|
|
36
|
+
data: data,
|
|
37
|
+
loadNext: React.useMemo(() => ((count, onComplete) => p.loadNext(count, {
|
|
38
|
+
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
39
|
+
})), [p.loadNext]),
|
|
40
|
+
loadPrevious: React.useMemo(() => ((count, onComplete) => p.loadPrevious(count, {
|
|
41
|
+
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
42
|
+
})), [p.loadPrevious]),
|
|
43
|
+
hasNext: p.hasNext,
|
|
44
|
+
hasPrevious: p.hasPrevious,
|
|
45
|
+
isLoadingNext: p.isLoadingNext,
|
|
46
|
+
isLoadingPrevious: p.isLoadingPrevious,
|
|
47
|
+
refetch: React.useMemo(() => ((variables, fetchPolicy, onComplete) => p.refetch(RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertRefetchVariables(variables)), {
|
|
48
|
+
fetchPolicy: fetchPolicy,
|
|
49
|
+
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
50
|
+
})), [p.refetch])
|
|
51
|
+
};
|
|
70
52
|
}
|
|
71
53
|
|
|
72
54
|
function usePrefetchableForwardPagination(node, fRef, convertEdges, convertFragment, convertRefetchVariables, bufferSize, initialSize, prefetchingLoadMoreOptions, minimumFetchSize) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
let p = ReactRelay.usePrefetchableForwardPaginationFragment(node, fRef, bufferSize, initialSize !== undefined ? Primitive_option.valFromOption(initialSize) : undefined, prefetchingLoadMoreOptions !== undefined ? Primitive_option.valFromOption(prefetchingLoadMoreOptions) : undefined, minimumFetchSize !== undefined ? Primitive_option.valFromOption(minimumFetchSize) : undefined);
|
|
56
|
+
let data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data);
|
|
57
|
+
let edges = RescriptRelay_Internal.internal_useConvertedValue(convertEdges, p.edges);
|
|
76
58
|
return {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return function (variables, fetchPolicy, onComplete) {
|
|
90
|
-
return p.refetch(RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertRefetchVariables(variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
|
|
91
|
-
};
|
|
92
|
-
}), [p.refetch])
|
|
93
|
-
};
|
|
59
|
+
data: data,
|
|
60
|
+
edges: edges,
|
|
61
|
+
loadNext: React.useMemo(() => ((count, onComplete) => p.loadNext(count, {
|
|
62
|
+
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
63
|
+
})), [p.loadNext]),
|
|
64
|
+
hasNext: p.hasNext,
|
|
65
|
+
isLoadingNext: p.isLoadingNext,
|
|
66
|
+
refetch: React.useMemo(() => ((variables, fetchPolicy, onComplete) => p.refetch(RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertRefetchVariables(variables)), {
|
|
67
|
+
fetchPolicy: fetchPolicy,
|
|
68
|
+
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
69
|
+
})), [p.refetch])
|
|
70
|
+
};
|
|
94
71
|
}
|
|
95
72
|
|
|
96
73
|
function useRefetchableFragment(node, convertFragment, convertRefetchVariables, fRef) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
74
|
+
let match = ReactRelay.useRefetchableFragment(node, fRef);
|
|
75
|
+
let refetchFn = match[1];
|
|
76
|
+
let data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, match[0]);
|
|
100
77
|
return [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
];
|
|
78
|
+
data,
|
|
79
|
+
React.useMemo(() => ((variables, fetchPolicy, onComplete) => refetchFn(RescriptRelay_Internal.internal_removeUndefinedAndConvertNullsRaw(convertRefetchVariables(variables)), {
|
|
80
|
+
fetchPolicy: fetchPolicy,
|
|
81
|
+
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
82
|
+
})), [refetchFn])
|
|
83
|
+
];
|
|
108
84
|
}
|
|
109
85
|
|
|
110
86
|
async function waitForFragmentData(environment, node, convertFragment, fRef) {
|
|
111
|
-
|
|
112
|
-
return convertFragment(fragmentData);
|
|
87
|
+
return convertFragment(await Experimental.waitForFragmentData(environment, node, fRef));
|
|
113
88
|
}
|
|
114
89
|
|
|
115
90
|
exports.useFragment = useFragment;
|
|
@@ -15,14 +15,11 @@ let useFragment = (~node, ~convertFragment: 'fragment => 'fragment, ~fRef) => {
|
|
|
15
15
|
User @inline {...}`) and then use `Fragment.readInline`. \
|
|
16
16
|
This will allow you to get the fragment data, but outside \
|
|
17
17
|
of React's render.*/
|
|
18
|
-
(
|
|
19
|
-
useFragment_(node, fRef)
|
|
20
|
-
->(RescriptRelay_Internal.internal_useConvertedValue(convertFragment, _))
|
|
21
|
-
)
|
|
18
|
+
(useFragment_(node, fRef)->RescriptRelay_Internal.internal_useConvertedValue(convertFragment, _))
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
@module("react-relay")
|
|
25
|
-
external useFragmentOpt_: (fragmentNode<'node>, option<'fragmentRef>) =>
|
|
22
|
+
external useFragmentOpt_: (fragmentNode<'node>, option<'fragmentRef>) => Nullable.t<'fragment> =
|
|
26
23
|
"useFragment"
|
|
27
24
|
|
|
28
25
|
let useFragmentOpt = (~fRef, ~node, ~convertFragment: 'fragment => 'fragment) => {
|
|
@@ -33,7 +30,7 @@ let useFragmentOpt = (~fRef, ~node, ~convertFragment: 'fragment => 'fragment) =>
|
|
|
33
30
|
back. Useful for scenarios where you don't have the \
|
|
34
31
|
fragmentRefs yet.*/
|
|
35
32
|
let data =
|
|
36
|
-
useFragmentOpt_(node, fRef)->
|
|
33
|
+
useFragmentOpt_(node, fRef)->Nullable.toOption
|
|
37
34
|
React.useMemo1(() => {
|
|
38
35
|
switch data {
|
|
39
36
|
| Some(data) => Some(convertFragment(data))
|
|
@@ -64,16 +61,16 @@ let read = (~node, ~convertFragment: 'fragment => 'fragment, ~fRef) => {
|
|
|
64
61
|
|
|
65
62
|
type refetchableFnOpts = {
|
|
66
63
|
fetchPolicy?: fetchPolicy,
|
|
67
|
-
onComplete?:
|
|
64
|
+
onComplete?: Nullable.t<JsExn.t> => unit,
|
|
68
65
|
}
|
|
69
66
|
|
|
70
67
|
let internal_makeRefetchableFnOpts = (~fetchPolicy=?, ~onComplete=?, ()) => {
|
|
71
68
|
?fetchPolicy,
|
|
72
|
-
onComplete: ?onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler,
|
|
69
|
+
onComplete: ?(onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler),
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
type paginationLoadMoreOptions = {onComplete?:
|
|
76
|
-
type paginationLoadMoreFn = (~count: int, ~onComplete: option<
|
|
72
|
+
type paginationLoadMoreOptions = {onComplete?: Nullable.t<JsExn.t> => unit}
|
|
73
|
+
type paginationLoadMoreFn = (~count: int, ~onComplete: option<JsExn.t> => unit=?) => Disposable.t
|
|
77
74
|
type paginationFragmentReturnRaw<'fragment, 'refetchVariables> = {
|
|
78
75
|
data: 'fragment,
|
|
79
76
|
loadNext: (int, paginationLoadMoreOptions) => Disposable.t,
|
|
@@ -95,7 +92,7 @@ type paginationFragmentReturn<'fragment, 'refetchVariables> = {
|
|
|
95
92
|
refetch: (
|
|
96
93
|
~variables: 'refetchVariables,
|
|
97
94
|
~fetchPolicy: fetchPolicy=?,
|
|
98
|
-
~onComplete: option<
|
|
95
|
+
~onComplete: option<JsExn.t> => unit=?,
|
|
99
96
|
) => Disposable.t,
|
|
100
97
|
}
|
|
101
98
|
|
|
@@ -116,30 +113,36 @@ let usePaginationFragment = (
|
|
|
116
113
|
let data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data)
|
|
117
114
|
{
|
|
118
115
|
data,
|
|
119
|
-
loadNext: React.useMemo1(() =>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
116
|
+
loadNext: React.useMemo1(() =>
|
|
117
|
+
(~count, ~onComplete=?) => {
|
|
118
|
+
p.loadNext(
|
|
119
|
+
count,
|
|
120
|
+
{onComplete: ?(onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler)},
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
, [p.loadNext]),
|
|
124
|
+
loadPrevious: React.useMemo1(() =>
|
|
125
|
+
(~count, ~onComplete=?) => {
|
|
126
|
+
p.loadPrevious(
|
|
127
|
+
count,
|
|
128
|
+
{onComplete: ?(onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler)},
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
, [p.loadPrevious]),
|
|
131
132
|
hasNext: p.hasNext,
|
|
132
133
|
hasPrevious: p.hasPrevious,
|
|
133
134
|
isLoadingNext: p.isLoadingNext,
|
|
134
135
|
isLoadingPrevious: p.isLoadingPrevious,
|
|
135
|
-
refetch: React.useMemo1(() =>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
refetch: React.useMemo1(() =>
|
|
137
|
+
(~variables, ~fetchPolicy=?, ~onComplete=?) => {
|
|
138
|
+
p.refetch(
|
|
139
|
+
RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(
|
|
140
|
+
variables->convertRefetchVariables,
|
|
141
|
+
),
|
|
142
|
+
internal_makeRefetchableFnOpts(~onComplete?, ~fetchPolicy?, ()),
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
, [p.refetch]),
|
|
143
146
|
}
|
|
144
147
|
}
|
|
145
148
|
|
|
@@ -160,7 +163,7 @@ type prefetchableForwardPaginationFragmentReturn<'fragment, 'edges, 'refetchVari
|
|
|
160
163
|
refetch: (
|
|
161
164
|
~variables: 'refetchVariables,
|
|
162
165
|
~fetchPolicy: fetchPolicy=?,
|
|
163
|
-
~onComplete: option<
|
|
166
|
+
~onComplete: option<JsExn.t> => unit=?,
|
|
164
167
|
) => Disposable.t,
|
|
165
168
|
}
|
|
166
169
|
|
|
@@ -200,22 +203,26 @@ let usePrefetchableForwardPagination = (
|
|
|
200
203
|
{
|
|
201
204
|
data,
|
|
202
205
|
edges,
|
|
203
|
-
loadNext: React.useMemo1(() =>
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
loadNext: React.useMemo1(() =>
|
|
207
|
+
(~count, ~onComplete=?) => {
|
|
208
|
+
p.loadNext(
|
|
209
|
+
count,
|
|
210
|
+
{onComplete: ?(onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler)},
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
, [p.loadNext]),
|
|
209
214
|
hasNext: p.hasNext,
|
|
210
215
|
isLoadingNext: p.isLoadingNext,
|
|
211
|
-
refetch: React.useMemo1(() =>
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
refetch: React.useMemo1(() =>
|
|
217
|
+
(~variables, ~fetchPolicy=?, ~onComplete=?) => {
|
|
218
|
+
p.refetch(
|
|
219
|
+
RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(
|
|
220
|
+
variables->convertRefetchVariables,
|
|
221
|
+
),
|
|
222
|
+
internal_makeRefetchableFnOpts(~onComplete?, ~fetchPolicy?, ()),
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
, [p.refetch]),
|
|
219
226
|
}
|
|
220
227
|
}
|
|
221
228
|
|
|
@@ -247,13 +254,14 @@ let useRefetchableFragment = (
|
|
|
247
254
|
(
|
|
248
255
|
data,
|
|
249
256
|
React.useMemo1(
|
|
250
|
-
() =>
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
257
|
+
() =>
|
|
258
|
+
(~variables: 'refetchVariables, ~fetchPolicy=?, ~onComplete=?) =>
|
|
259
|
+
refetchFn(
|
|
260
|
+
RescriptRelay_Internal.internal_removeUndefinedAndConvertNullsRaw(
|
|
261
|
+
variables->convertRefetchVariables,
|
|
262
|
+
),
|
|
263
|
+
internal_makeRefetchableFnOpts(~fetchPolicy?, ~onComplete?, ()),
|
|
254
264
|
),
|
|
255
|
-
internal_makeRefetchableFnOpts(~fetchPolicy?, ~onComplete?, ()),
|
|
256
|
-
),
|
|
257
265
|
[refetchFn],
|
|
258
266
|
),
|
|
259
267
|
)
|
|
@@ -24,9 +24,9 @@ let read: (
|
|
|
24
24
|
~fRef: 'b,
|
|
25
25
|
) => 'fragment
|
|
26
26
|
|
|
27
|
-
type paginationLoadMoreOptions = {onComplete?:
|
|
27
|
+
type paginationLoadMoreOptions = {onComplete?: Nullable.t<JsExn.t> => unit}
|
|
28
28
|
|
|
29
|
-
type paginationLoadMoreFn = (~count: int, ~onComplete: option<
|
|
29
|
+
type paginationLoadMoreFn = (~count: int, ~onComplete: option<JsExn.t> => unit=?) => Disposable.t
|
|
30
30
|
|
|
31
31
|
type paginationFragmentReturn<'fragment, 'refetchVariables> = {
|
|
32
32
|
data: 'fragment,
|
|
@@ -39,7 +39,7 @@ type paginationFragmentReturn<'fragment, 'refetchVariables> = {
|
|
|
39
39
|
refetch: (
|
|
40
40
|
~variables: 'refetchVariables,
|
|
41
41
|
~fetchPolicy: fetchPolicy=?,
|
|
42
|
-
~onComplete: option<
|
|
42
|
+
~onComplete: option<JsExn.t> => unit=?,
|
|
43
43
|
) => Disposable.t,
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -59,7 +59,7 @@ type prefetchableForwardPaginationFragmentReturn<'fragment, 'edges, 'refetchVari
|
|
|
59
59
|
refetch: (
|
|
60
60
|
~variables: 'refetchVariables,
|
|
61
61
|
~fetchPolicy: fetchPolicy=?,
|
|
62
|
-
~onComplete: option<
|
|
62
|
+
~onComplete: option<JsExn.t> => unit=?,
|
|
63
63
|
) => Disposable.t,
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -85,7 +85,7 @@ let useRefetchableFragment: (
|
|
|
85
85
|
(
|
|
86
86
|
~variables: 'refetchVariables,
|
|
87
87
|
~fetchPolicy: fetchPolicy=?,
|
|
88
|
-
~onComplete: option<
|
|
88
|
+
~onComplete: option<JsExn.t> => unit=?,
|
|
89
89
|
) => Disposable.t,
|
|
90
90
|
)
|
|
91
91
|
|
|
@@ -1,74 +1,65 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
4
|
+
let React = require("react");
|
|
5
|
+
let Stdlib_Array = require("@rescript/runtime/lib/js/Stdlib_Array.js");
|
|
6
|
+
let Stdlib_Option = require("@rescript/runtime/lib/js/Stdlib_Option.js");
|
|
7
|
+
let Primitive_object = require("@rescript/runtime/lib/js/Primitive_object.js");
|
|
8
|
+
let Primitive_option = require("@rescript/runtime/lib/js/Primitive_option.js");
|
|
10
9
|
|
|
11
10
|
function internal_keepMapFieldsRaw(record, f) {
|
|
12
|
-
return
|
|
13
|
-
return Js_dict.fromArray(Belt_Array.keepMap(Js_dict.entries(obj), f));
|
|
14
|
-
}));
|
|
11
|
+
return Stdlib_Option.map(record, obj => Object.fromEntries(Stdlib_Array.filterMap(Object.entries(obj), f)));
|
|
15
12
|
}
|
|
16
13
|
|
|
17
14
|
function internal_cleanObjectFromUndefinedRaw(record) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}));
|
|
15
|
+
let v = internal_keepMapFieldsRaw(record, param => {
|
|
16
|
+
let value = param[1];
|
|
17
|
+
if (value !== undefined) {
|
|
18
|
+
return [
|
|
19
|
+
param[0],
|
|
20
|
+
Primitive_option.valFromOption(value)
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
28
24
|
if (v !== undefined) {
|
|
29
|
-
return
|
|
25
|
+
return Primitive_option.valFromOption(v);
|
|
30
26
|
} else {
|
|
31
27
|
return {};
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
function internal_removeUndefinedAndConvertNullsRaw(record) {
|
|
36
|
-
return internal_keepMapFieldsRaw(record,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
return internal_keepMapFieldsRaw(record, param => {
|
|
33
|
+
let value = param[1];
|
|
34
|
+
let key = param[0];
|
|
35
|
+
let match = Primitive_object.equal(value, Primitive_option.some(undefined));
|
|
36
|
+
if (value !== undefined) {
|
|
37
|
+
return [
|
|
38
|
+
key,
|
|
39
|
+
Primitive_option.valFromOption(value)
|
|
40
|
+
];
|
|
41
|
+
} else if (match) {
|
|
42
|
+
return [
|
|
43
|
+
key,
|
|
44
|
+
null
|
|
45
|
+
];
|
|
46
|
+
} else {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
function internal_useConvertedValue(convert, v) {
|
|
57
|
-
return React.useMemo((
|
|
58
|
-
return convert(v);
|
|
59
|
-
}), [v]);
|
|
53
|
+
return React.useMemo(() => convert(v), [v]);
|
|
60
54
|
}
|
|
61
55
|
|
|
62
56
|
function internal_nullableToOptionalExnHandler(x) {
|
|
63
57
|
if (x !== undefined) {
|
|
64
|
-
return (
|
|
65
|
-
return x((maybeExn == null) ? undefined : Caml_option.some(maybeExn));
|
|
66
|
-
});
|
|
58
|
+
return maybeExn => x((maybeExn == null) ? undefined : Primitive_option.some(maybeExn));
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
}
|
|
70
61
|
|
|
71
|
-
|
|
62
|
+
let unwrapUnion = (function unwrapUnion(union, members) {
|
|
72
63
|
if (union != null && members.indexOf(union.__typename) === -1) {
|
|
73
64
|
return Object.assign({}, union, {__typename: "__unselected"});
|
|
74
65
|
}
|
|
@@ -80,7 +71,7 @@ function wrapUnion(union) {
|
|
|
80
71
|
return union;
|
|
81
72
|
}
|
|
82
73
|
|
|
83
|
-
|
|
74
|
+
let applyCodesplitMetadata = (function applyCodesplitMetadata(node, meta) {
|
|
84
75
|
if (node != null && node.params != null) {
|
|
85
76
|
let metadata = node.params.metadata;
|
|
86
77
|
if (metadata == null) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
let internal_keepMapFieldsRaw = (record, f) =>
|
|
2
2
|
record
|
|
3
3
|
->Obj.magic
|
|
4
|
-
->
|
|
4
|
+
->Option.map(obj => obj->Dict.toArray->Array.filterMap(f)->Dict.fromArray)
|
|
5
5
|
->Obj.magic
|
|
6
6
|
|
|
7
7
|
// we need to do this until we can use @obj on record types
|
|
@@ -20,8 +20,8 @@ let internal_cleanObjectFromUndefinedRaw = record =>
|
|
|
20
20
|
let internal_removeUndefinedAndConvertNullsRaw = record =>
|
|
21
21
|
internal_keepMapFieldsRaw(record, ((key, value)) => {
|
|
22
22
|
switch (value, value == Some(None)) {
|
|
23
|
-
| (Some(value), _) => Some((key,
|
|
24
|
-
| (_, true) => Some((key,
|
|
23
|
+
| (Some(value), _) => Some((key, Nullable.make(value)))
|
|
24
|
+
| (_, true) => Some((key, Nullable.null))
|
|
25
25
|
| (None, _) => None
|
|
26
26
|
}
|
|
27
27
|
})
|
|
@@ -31,7 +31,7 @@ let internal_useConvertedValue = (convert, v) => React.useMemo1(() => convert(v)
|
|
|
31
31
|
let internal_nullableToOptionalExnHandler = x =>
|
|
32
32
|
switch x {
|
|
33
33
|
| None => None
|
|
34
|
-
| Some(handler) => Some(maybeExn => maybeExn->
|
|
34
|
+
| Some(handler) => Some(maybeExn => maybeExn->Nullable.toOption->handler)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
@live @unboxed type rec arg = Arg(_): arg
|
|
@@ -56,7 +56,7 @@ external internal_resolverFragmentRefsToFragmentRefsPlural: RescriptRelay.resolv
|
|
|
56
56
|
'a,
|
|
57
57
|
> => array<RescriptRelay.fragmentRefs<'a>> = "%identity"
|
|
58
58
|
|
|
59
|
-
let applyCodesplitMetadata: ('node, array<(string, dict<
|
|
59
|
+
let applyCodesplitMetadata: ('node, array<(string, dict<JSON.t> => unit)>) => 'node = %raw(`
|
|
60
60
|
function applyCodesplitMetadata(node, meta) {
|
|
61
61
|
if (node != null && node.params != null) {
|
|
62
62
|
let metadata = node.params.metadata;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
let internal_useConvertedValue: ('a => 'a, 'a) => 'a
|
|
2
2
|
let internal_cleanObjectFromUndefinedRaw: 't => 't
|
|
3
3
|
let internal_removeUndefinedAndConvertNullsRaw: 't => 't
|
|
4
|
-
let internal_nullableToOptionalExnHandler: option<option<'b> => 'a> => option<
|
|
5
|
-
Js.Nullable.t<'b> => 'a,
|
|
6
|
-
>
|
|
4
|
+
let internal_nullableToOptionalExnHandler: option<option<'b> => 'a> => option<Nullable.t<'b> => 'a>
|
|
7
5
|
@live @unboxed type rec arg = Arg(_): arg
|
|
8
6
|
|
|
9
7
|
let unwrapUnion: ('a, array<string>) => 'a
|
|
@@ -17,4 +15,4 @@ external internal_resolverFragmentRefsToFragmentRefsPlural: RescriptRelay.resolv
|
|
|
17
15
|
'a,
|
|
18
16
|
> => array<RescriptRelay.fragmentRefs<'a>> = "%identity"
|
|
19
17
|
|
|
20
|
-
let applyCodesplitMetadata: ('node, array<(string, dict<
|
|
18
|
+
let applyCodesplitMetadata: ('node, array<(string, dict<JSON.t> => unit)>) => 'node
|