forked from reactplay/react-play
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch-plays.js
79 lines (73 loc) · 1.39 KB
/
fetch-plays.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
70
71
72
73
74
75
76
77
78
79
export function FetchPlaysSimple() {
return { ...BasiFetchParam };
}
export function FetchPlaysByID(id) {
const payload = { ...DetailedFetchParam };
payload.where = {
clause: {
conditions: [
{
field: "id",
operator: "eq",
value: id,
},
],
},
};
return payload;
}
export function FetchPlaysBySlugAndUser(playslug, username) {
const payload = { ...DetailedFetchParam };
payload.where = {
clause: {
operator: "and",
conditions: [
{
field: "slug",
operator: "ilike",
value: playslug,
type: "string",
},
{
field: "github",
operator: "ilike",
value: username,
type: "string",
},
],
},
};
return payload;
}
const BasiFetchParam = {
display: "Simple fetch play",
name: "Fetch_Plays",
function: "plays",
write: false,
return: [
"component",
"cover",
"description",
"featured",
"dev_mode",
"github",
"language",
{ play_like: ["liked", "play_id", "user_id"] },
"name",
"slug",
{ user: ["id", "displayName", "avatarUrl"] },
],
};
const DetailedFetchParam = {
...BasiFetchParam,
...{
return: [
...BasiFetchParam.return,
"blog",
"id",
{ level: ["name"] },
"video",
{ play_tags: { tag: ["name"] } },
],
},
};