decap-cms-backend-github 2.15.0-beta.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 +817 -0
- package/LICENSE +22 -0
- package/README.md +17 -0
- package/dist/decap-cms-backend-github.js +312 -0
- package/dist/decap-cms-backend-github.js.LICENSE.txt +23 -0
- package/dist/decap-cms-backend-github.js.map +1 -0
- package/dist/esm/API.js +1217 -0
- package/dist/esm/AuthenticationPage.js +192 -0
- package/dist/esm/GraphQLAPI.js +807 -0
- package/dist/esm/fragmentTypes.js +947 -0
- package/dist/esm/fragments.js +98 -0
- package/dist/esm/implementation.js +585 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/mutations.js +117 -0
- package/dist/esm/queries.js +212 -0
- package/dist/esm/types/semaphore.d.js +1 -0
- package/package.json +44 -0
- package/scripts/createFragmentTypes.js +48 -0
- package/src/API.ts +1468 -0
- package/src/AuthenticationPage.js +151 -0
- package/src/GraphQLAPI.ts +709 -0
- package/src/__tests__/API.spec.js +833 -0
- package/src/__tests__/GraphQLAPI.spec.js +69 -0
- package/src/__tests__/implementation.spec.js +361 -0
- package/src/fragmentTypes.js +1 -0
- package/src/fragments.ts +92 -0
- package/src/implementation.tsx +672 -0
- package/src/index.ts +10 -0
- package/src/mutations.ts +110 -0
- package/src/queries.ts +213 -0
- package/src/types/semaphore.d.ts +5 -0
- package/webpack.config.js +3 -0
package/src/mutations.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag';
|
|
2
|
+
|
|
3
|
+
import * as fragments from './fragments';
|
|
4
|
+
|
|
5
|
+
// updateRef only works for branches at the moment
|
|
6
|
+
export const updateBranch = gql`
|
|
7
|
+
mutation updateRef($input: UpdateRefInput!) {
|
|
8
|
+
updateRef(input: $input) {
|
|
9
|
+
branch: ref {
|
|
10
|
+
...BranchParts
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
${fragments.branch}
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
// deleteRef only works for branches at the moment
|
|
18
|
+
const deleteRefMutationPart = `
|
|
19
|
+
deleteRef(input: $deleteRefInput) {
|
|
20
|
+
clientMutationId
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
export const deleteBranch = gql`
|
|
24
|
+
mutation deleteRef($deleteRefInput: DeleteRefInput!) {
|
|
25
|
+
${deleteRefMutationPart}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const closePullRequestMutationPart = `
|
|
30
|
+
closePullRequest(input: $closePullRequestInput) {
|
|
31
|
+
clientMutationId
|
|
32
|
+
pullRequest {
|
|
33
|
+
...PullRequestParts
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
export const closePullRequest = gql`
|
|
39
|
+
mutation closePullRequestAndDeleteBranch($closePullRequestInput: ClosePullRequestInput!) {
|
|
40
|
+
${closePullRequestMutationPart}
|
|
41
|
+
}
|
|
42
|
+
${fragments.pullRequest}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
export const closePullRequestAndDeleteBranch = gql`
|
|
46
|
+
mutation closePullRequestAndDeleteBranch(
|
|
47
|
+
$closePullRequestInput: ClosePullRequestInput!
|
|
48
|
+
$deleteRefInput: DeleteRefInput!
|
|
49
|
+
) {
|
|
50
|
+
${closePullRequestMutationPart}
|
|
51
|
+
${deleteRefMutationPart}
|
|
52
|
+
}
|
|
53
|
+
${fragments.pullRequest}
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const createPullRequestMutationPart = `
|
|
57
|
+
createPullRequest(input: $createPullRequestInput) {
|
|
58
|
+
clientMutationId
|
|
59
|
+
pullRequest {
|
|
60
|
+
...PullRequestParts
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
|
|
65
|
+
export const createPullRequest = gql`
|
|
66
|
+
mutation createPullRequest($createPullRequestInput: CreatePullRequestInput!) {
|
|
67
|
+
${createPullRequestMutationPart}
|
|
68
|
+
}
|
|
69
|
+
${fragments.pullRequest}
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
export const createBranch = gql`
|
|
73
|
+
mutation createBranch($createRefInput: CreateRefInput!) {
|
|
74
|
+
createRef(input: $createRefInput) {
|
|
75
|
+
branch: ref {
|
|
76
|
+
...BranchParts
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
${fragments.branch}
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
// createRef only works for branches at the moment
|
|
84
|
+
export const createBranchAndPullRequest = gql`
|
|
85
|
+
mutation createBranchAndPullRequest(
|
|
86
|
+
$createRefInput: CreateRefInput!
|
|
87
|
+
$createPullRequestInput: CreatePullRequestInput!
|
|
88
|
+
) {
|
|
89
|
+
createRef(input: $createRefInput) {
|
|
90
|
+
branch: ref {
|
|
91
|
+
...BranchParts
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
${createPullRequestMutationPart}
|
|
95
|
+
}
|
|
96
|
+
${fragments.branch}
|
|
97
|
+
${fragments.pullRequest}
|
|
98
|
+
`;
|
|
99
|
+
|
|
100
|
+
export const reopenPullRequest = gql`
|
|
101
|
+
mutation reopenPullRequest($reopenPullRequestInput: ReopenPullRequestInput!) {
|
|
102
|
+
reopenPullRequest(input: $reopenPullRequestInput) {
|
|
103
|
+
clientMutationId
|
|
104
|
+
pullRequest {
|
|
105
|
+
...PullRequestParts
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
${fragments.pullRequest}
|
|
110
|
+
`;
|
package/src/queries.ts
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag';
|
|
2
|
+
import { oneLine } from 'common-tags';
|
|
3
|
+
|
|
4
|
+
import * as fragments from './fragments';
|
|
5
|
+
|
|
6
|
+
export const repoPermission = gql`
|
|
7
|
+
query repoPermission($owner: String!, $name: String!) {
|
|
8
|
+
repository(owner: $owner, name: $name) {
|
|
9
|
+
...RepositoryParts
|
|
10
|
+
viewerPermission
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
${fragments.repository}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
export const user = gql`
|
|
17
|
+
query {
|
|
18
|
+
viewer {
|
|
19
|
+
id
|
|
20
|
+
avatar_url: avatarUrl
|
|
21
|
+
name
|
|
22
|
+
login
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export const blob = gql`
|
|
28
|
+
query blob($owner: String!, $name: String!, $expression: String!) {
|
|
29
|
+
repository(owner: $owner, name: $name) {
|
|
30
|
+
...RepositoryParts
|
|
31
|
+
object(expression: $expression) {
|
|
32
|
+
... on Blob {
|
|
33
|
+
...BlobWithTextParts
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
${fragments.repository}
|
|
39
|
+
${fragments.blobWithText}
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
export const statues = gql`
|
|
43
|
+
query statues($owner: String!, $name: String!, $sha: GitObjectID!) {
|
|
44
|
+
repository(owner: $owner, name: $name) {
|
|
45
|
+
...RepositoryParts
|
|
46
|
+
object(oid: $sha) {
|
|
47
|
+
...ObjectParts
|
|
48
|
+
... on Commit {
|
|
49
|
+
status {
|
|
50
|
+
id
|
|
51
|
+
contexts {
|
|
52
|
+
id
|
|
53
|
+
context
|
|
54
|
+
state
|
|
55
|
+
target_url: targetUrl
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
${fragments.repository}
|
|
63
|
+
${fragments.object}
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
function buildFilesQuery(depth = 1) {
|
|
67
|
+
const PLACE_HOLDER = 'PLACE_HOLDER';
|
|
68
|
+
let query = oneLine`
|
|
69
|
+
...ObjectParts
|
|
70
|
+
... on Tree {
|
|
71
|
+
entries {
|
|
72
|
+
...FileEntryParts
|
|
73
|
+
${PLACE_HOLDER}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
for (let i = 0; i < depth - 1; i++) {
|
|
79
|
+
query = query.replace(
|
|
80
|
+
PLACE_HOLDER,
|
|
81
|
+
oneLine`
|
|
82
|
+
object {
|
|
83
|
+
... on Tree {
|
|
84
|
+
entries {
|
|
85
|
+
...FileEntryParts
|
|
86
|
+
${PLACE_HOLDER}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
query = query.replace(PLACE_HOLDER, '');
|
|
95
|
+
|
|
96
|
+
return query;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function files(depth: number) {
|
|
100
|
+
return gql`
|
|
101
|
+
query files($owner: String!, $name: String!, $expression: String!) {
|
|
102
|
+
repository(owner: $owner, name: $name) {
|
|
103
|
+
...RepositoryParts
|
|
104
|
+
object(expression: $expression) {
|
|
105
|
+
${buildFilesQuery(depth)}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
${fragments.repository}
|
|
110
|
+
${fragments.object}
|
|
111
|
+
${fragments.fileEntry}
|
|
112
|
+
`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const branchQueryPart = `
|
|
116
|
+
branch: ref(qualifiedName: $qualifiedName) {
|
|
117
|
+
...BranchParts
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
120
|
+
|
|
121
|
+
export const branch = gql`
|
|
122
|
+
query branch($owner: String!, $name: String!, $qualifiedName: String!) {
|
|
123
|
+
repository(owner: $owner, name: $name) {
|
|
124
|
+
...RepositoryParts
|
|
125
|
+
${branchQueryPart}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
${fragments.repository}
|
|
129
|
+
${fragments.branch}
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
export const openAuthoringBranches = gql`
|
|
133
|
+
query openAuthoringBranches($owner: String!, $name: String!, $refPrefix: String!) {
|
|
134
|
+
repository(owner: $owner, name: $name) {
|
|
135
|
+
...RepositoryParts
|
|
136
|
+
refs(refPrefix: $refPrefix, last: 100) {
|
|
137
|
+
nodes {
|
|
138
|
+
...BranchParts
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
${fragments.repository}
|
|
144
|
+
${fragments.branch}
|
|
145
|
+
`;
|
|
146
|
+
|
|
147
|
+
export const repository = gql`
|
|
148
|
+
query repository($owner: String!, $name: String!) {
|
|
149
|
+
repository(owner: $owner, name: $name) {
|
|
150
|
+
...RepositoryParts
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
${fragments.repository}
|
|
154
|
+
`;
|
|
155
|
+
|
|
156
|
+
const pullRequestQueryPart = `
|
|
157
|
+
pullRequest(number: $number) {
|
|
158
|
+
...PullRequestParts
|
|
159
|
+
}
|
|
160
|
+
`;
|
|
161
|
+
|
|
162
|
+
export const pullRequest = gql`
|
|
163
|
+
query pullRequest($owner: String!, $name: String!, $number: Int!) {
|
|
164
|
+
repository(owner: $owner, name: $name) {
|
|
165
|
+
id
|
|
166
|
+
${pullRequestQueryPart}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
${fragments.pullRequest}
|
|
170
|
+
`;
|
|
171
|
+
|
|
172
|
+
export const pullRequests = gql`
|
|
173
|
+
query pullRequests($owner: String!, $name: String!, $head: String, $states: [PullRequestState!]) {
|
|
174
|
+
repository(owner: $owner, name: $name) {
|
|
175
|
+
id
|
|
176
|
+
pullRequests(last: 100, headRefName: $head, states: $states) {
|
|
177
|
+
nodes {
|
|
178
|
+
...PullRequestParts
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
${fragments.pullRequest}
|
|
184
|
+
`;
|
|
185
|
+
|
|
186
|
+
export const pullRequestAndBranch = gql`
|
|
187
|
+
query pullRequestAndBranch($owner: String!, $name: String!, $originRepoOwner: String!, $originRepoName: String!, $qualifiedName: String!, $number: Int!) {
|
|
188
|
+
repository(owner: $owner, name: $name) {
|
|
189
|
+
...RepositoryParts
|
|
190
|
+
${branchQueryPart}
|
|
191
|
+
}
|
|
192
|
+
origin: repository(owner: $originRepoOwner, name: $originRepoName) {
|
|
193
|
+
...RepositoryParts
|
|
194
|
+
${pullRequestQueryPart}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
${fragments.repository}
|
|
198
|
+
${fragments.branch}
|
|
199
|
+
${fragments.pullRequest}
|
|
200
|
+
`;
|
|
201
|
+
|
|
202
|
+
export const fileSha = gql`
|
|
203
|
+
query fileSha($owner: String!, $name: String!, $expression: String!) {
|
|
204
|
+
repository(owner: $owner, name: $name) {
|
|
205
|
+
...RepositoryParts
|
|
206
|
+
file: object(expression: $expression) {
|
|
207
|
+
...ObjectParts
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
${fragments.repository}
|
|
212
|
+
${fragments.object}
|
|
213
|
+
`;
|