-
Notifications
You must be signed in to change notification settings - Fork 13
/
schema.js
463 lines (382 loc) · 9.18 KB
/
schema.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
const { makeExecutableSchema } = require('@graphql-tools/schema')
const resolvers = require('./resolvers/index.js')
const typeDefs = `#graphql
scalar JSON
scalar JSONObject
scalar EmailAddress
scalar JWT
scalar DateTime
scalar HexColorCode
scalar String
scalar ID
scalar Int
scalar Boolean
enum AuthType {
oidc
local
}
type UserSearch {
_id: ID
displayName: String
email: EmailAddress
firstName: String
lastName: String
}
input UserFilter {
email: String!
}
type UserStats {
myArticlesCount: Int
contributedArticlesCount: Int
}
type User {
_id: ID
displayName: String
username: String
authType: AuthType
authTypes: [AuthType]
email: EmailAddress
firstName: String
lastName: String
institution: String
tags(limit: Int, page: Int): [Tag]
permissions: [UserPermission]
acquintances(limit: Int, page: Int): [User]
articles(limit: Int, page: Int): [Article]
workspaces: [Workspace!]
admin: Boolean
zoteroToken: String
createdAt: DateTime
updatedAt: DateTime
apiToken: JWT
addContact(userId: ID!): User
removeContact(userId: ID!): User
stats: UserStats
}
type UserPermission {
scope: String!
user: User!
roles: [String]
}
type Tag {
_id: ID!
name: String!
owner: ID
description: String
color: HexColorCode
articles: [Article]
createdAt: DateTime
updatedAt: DateTime
}
type WorkingVersion {
bib: String
bibPreview: String
md: String
metadata: JSON
yaml (options: YamlFormattingInput): String
}
type Version {
_id: ID!
name: String
version: Int
revision: Int
md: String
sommaire: String
type: String
metadata: JSON
yaml (options: YamlFormattingInput): String
bib: String
bibPreview: String
message: String
article: Article
owner: User
createdAt: DateTime
updatedAt: DateTime
rename(name: String): Boolean
}
input ArticleVersionInput {
userId: ID!
major: Boolean
message: String
}
type CollaborativeSession {
id: ID
creator: User
createdAt: DateTime
}
type SoloSession {
id: ID
creator: User
creatorUsername: String
createdAt: DateTime
}
type Article {
_id: ID!
title: String
zoteroLink: String
owner: User
contributors: [ArticleContributor]!
workingVersion: WorkingVersion
versions(limit: Int, page: Int): [Version!]
tags(limit: Int, page: Int): [Tag!]!
preview: ArticlePreviewSettings
collaborativeSession: CollaborativeSession
soloSession: SoloSession
createdAt: DateTime
updatedAt: DateTime
addTags(tags: [ID]!): [Tag]
delete(dryRun: Boolean): Boolean
removeTags(tags: [ID]!): [Tag]
rename(title: String!): Boolean
setPreviewSettings(settings: ArticlePreviewInput!): Article
setZoteroLink(zotero: String!): Boolean
updateWorkingVersion(content: WorkingVersionInput!): Article
workspaces: [Workspace!]
addContributor(userId: ID!): Article
removeContributor(userId: ID!): Article
createVersion(articleVersionInput: ArticleVersionInput!): Article
startCollaborativeSession: CollaborativeSession!
startSoloSession: SoloSession!
takeOverSoloSession: SoloSession!
stopCollaborativeSession: Article
stopSoloSession: Article
}
type ArticlePreviewSettings {
stylesheet: String!
template: String
}
input ArticlePreviewInput {
stylesheet: String
template: String
}
type ArticleContributor {
user: User!
roles: [String]
}
type InstanceUsageStats {
version: String
users: InstanceUserStats
articles: InstanceArticleStats
}
interface InstanceObjectUsageStats {
total: Int!
# currentYear: Int!
years: [InstanceObjectUsageYearlyStats]
}
type InstanceObjectUsageYearlyStats {
year: Int
count: Int
# variation: Int
}
type InstanceUserStats implements InstanceObjectUsageStats {
total: Int!
# currentYear: Int!
local: Int
openid: Int
years: [InstanceObjectUsageYearlyStats]
}
type InstanceArticleStats implements InstanceObjectUsageStats {
total: Int!
# currentYear: Int!
years: [InstanceObjectUsageYearlyStats]
}
input WorkingVersionInput {
bib: String,
md: String,
metadata: JSON,
}
input YamlFormattingInput {
strip_markdown: Boolean
}
input NewUserInput {
email: EmailAddress!
username: String!
password: String!
passwordC: String!
displayName: String
firstName: String
lastName: String
institution: String
}
input UserProfileInput {
displayName: String
firstName: String
lastName: String
institution: String
zoteroToken: String
}
type WorkspaceArticle {
workspace: Workspace!
article: Article
# mutation
remove: Workspace!
}
type WorkspaceMember {
workspace: Workspace!
user: User
role: String
# mutation
remove: Workspace!
}
type WorkspaceStats {
articlesCount: Int
membersCount: Int
}
type Workspace {
_id: String!
name: String!
description: String
color: HexColorCode!
bibliographyStyle: String
members: [User!]!
articles: [Article!]!
corpus: [Corpus!]!
creator: User!
createdAt: DateTime
updatedAt: DateTime
article(articleId: ID!): WorkspaceArticle
member(userId: ID!): WorkspaceMember
stats: WorkspaceStats
# mutations
leave: Workspace
inviteMember(userId: ID!, role: String): Workspace
addArticle(articleId: ID!): Workspace
}
"Input to create a new workspace"
input CreateWorkspaceInput {
name: String!
color: String!
description: String
}
type CorpusArticle {
corpus: Corpus!
article: Article
order: Int
# mutation
remove: Corpus!
move(order: Int): Corpus
}
input ArticleOrder {
articleId: ID!
order: Int!
}
input UpdateCorpusInput {
name: String!
description: String
metadata: JSON
}
type Corpus {
_id: String!
name: String!
description: String
metadata: JSON
workspace: String
articles: [CorpusArticle!]!
creator: User!
createdAt: DateTime
updatedAt: DateTime
article(articleId: ID!): CorpusArticle
# mutations
addArticle(articleId: ID!): Corpus
rename(name: String!): Corpus
updateMetadata(metadata: JSON!): Corpus
updateArticlesOrder(articlesOrderInput: [ArticleOrder!]!): Corpus
delete: Corpus!
update(updateCorpusInput: UpdateCorpusInput!): Corpus!
}
input CreateCorpusInput {
name: String!
description: String
metadata: String
workspace: String
}
input FilterCorpusInput {
workspaceId: String
corpusId: ID
}
type Query {
"Fetch all users [Reserved for admins]"
users: [User]
"""
Get authenticated user info.
"""
user(user: ID): User
getUser(filter: UserFilter): User
"Fetch tagged articles for a given user"
tags(user: ID): [Tag]
"Fetch tagged articles for a given user"
tag(user: ID, tag: ID!): Tag
"Fetch a given user articles"
articles (user: ID): [Article]
"Fetch article info [need to have access to this article]"
article(user: ID, article: ID!): Article
"Fetch version info"
version(version: ID!): Version
"Fetch instance stats"
stats: InstanceUsageStats
"Get a given workspace"
workspace(workspaceId: ID!): Workspace
"Get a list of workspaces for the authenticated user"
workspaces: [Workspace!]
"""
Get a list of corpus with an optional filter
"""
corpus(filter: FilterCorpusInput): [Corpus!]
}
type Mutation {
"Create user + password + default article"
createUser(details: NewUserInput!): User!
"Add an email to your acquintances [need to be authentificated as user]"
addAcquintance(email: EmailAddress!, user: ID): User
"Change password"
changePassword(old: String!, new: String!, user: ID): User
"Change user information"
updateUser(user: ID, details: UserProfileInput!): User
"Give access to a user using a password's email"
addCredential(email: EmailAddress!, user: ID): User
# If need to create new user: createUser + addCredential
"Remove access to a user using a password's email (can't be the main email)"
removeCredential(email: EmailAddress!, user: ID): User
"Create article for specified user [need to be authenticated as specified user]"
createArticle(title: String!, user: ID, tags: [ID]): Article
"Create tag [need to be authenticated as specified user]"
createTag(
name: String!
description: String
user: ID
color: HexColorCode!
): Tag
"update name and description of a tag [need to be authenticated as specified user]"
updateTag(
name: String
description: String
color: HexColorCode
tag: ID!
user: ID
): Tag
"Delete tag, and remove it from all related articles"
deleteTag(tag: ID!, user: ID): Boolean
"add a user to an article"
shareArticle(article: ID!, to: ID!, user: ID): Article
"remove a user to an article"
unshareArticle(article: ID!, to: ID!, user: ID): Article
"Duplicate the working version of an article, with someone, or yourself"
duplicateArticle(article: ID!, to: ID!, user: ID): Article
"Create a new workspace"
createWorkspace(createWorkspaceInput: CreateWorkspaceInput!): Workspace
"Get a workspace for mutation"
workspace(workspaceId: ID!): Workspace
"""
Get an article for a given id.
Returns an error if the corpus does not exist or cannot be accessed.
"""
article(articleId: ID!): Article
"""
Get a corpus for a given id.
Returns an error if the corpus does not exist or cannot be accessed.
"""
corpus(corpusId: ID!): Corpus
"Create a new corpus"
createCorpus(createCorpusInput: CreateCorpusInput!): Corpus
}`
module.exports = makeExecutableSchema({ typeDefs, resolvers })