@gbl-uzh/platform 0.2.10
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/dist/generated/ops.d.ts +1555 -0
- package/dist/generated/ops.js +168 -0
- package/dist/index.d.ts +430 -0
- package/dist/index.js +1941 -0
- package/dist/lib/apollo.d.ts +4 -0
- package/dist/lib/apollo.js +119 -0
- package/dist/lib/util.d.ts +4 -0
- package/dist/lib/util.js +44 -0
- package/dist/nexus.d.ts +78 -0
- package/dist/nexus.js +2563 -0
- package/dist/schema.prisma +428 -0
- package/package.json +63 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
datasource db {
|
|
2
|
+
provider = "postgres"
|
|
3
|
+
url = env("DATABASE_URL")
|
|
4
|
+
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
generator client {
|
|
8
|
+
provider = "prisma-client-js"
|
|
9
|
+
previewFeatures = ["interactiveTransactions"]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
model Account {
|
|
13
|
+
id Int @id @default(autoincrement())
|
|
14
|
+
type String
|
|
15
|
+
provider String
|
|
16
|
+
providerAccountId String
|
|
17
|
+
refresh_token String? @map("refreshToken")
|
|
18
|
+
refresh_token_expires_in Int? @map("refreshTokenExpiresIn")
|
|
19
|
+
access_token String? @map("accessToken")
|
|
20
|
+
expires_at Int? @map("expiresAt")
|
|
21
|
+
token_type String? @map("tokenType")
|
|
22
|
+
scope String?
|
|
23
|
+
id_token String? @map("idToken")
|
|
24
|
+
session_state String? @map("sessionState")
|
|
25
|
+
oauth_token_secret String? @map("oauthTokenSecret")
|
|
26
|
+
oauth_token String? @map("oauthToken")
|
|
27
|
+
|
|
28
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
29
|
+
userId String @db.Uuid
|
|
30
|
+
|
|
31
|
+
createdAt DateTime @default(now())
|
|
32
|
+
updatedAt DateTime @updatedAt
|
|
33
|
+
|
|
34
|
+
@@unique([provider, providerAccountId])
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
model Session {
|
|
38
|
+
id Int @id @default(autoincrement())
|
|
39
|
+
sessionToken String @unique
|
|
40
|
+
expires DateTime
|
|
41
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
42
|
+
userId String @db.Uuid
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
enum UserRole {
|
|
46
|
+
ADMIN
|
|
47
|
+
MASTER
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
model User {
|
|
51
|
+
id String @id @default(uuid()) @db.Uuid
|
|
52
|
+
name String?
|
|
53
|
+
email String? @unique
|
|
54
|
+
emailVerified DateTime?
|
|
55
|
+
image String?
|
|
56
|
+
role UserRole @default(ADMIN)
|
|
57
|
+
|
|
58
|
+
accounts Account[]
|
|
59
|
+
sessions Session[]
|
|
60
|
+
games Game[]
|
|
61
|
+
|
|
62
|
+
createdAt DateTime @default(now())
|
|
63
|
+
updatedAt DateTime @updatedAt
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
model VerificationToken {
|
|
67
|
+
identifier String @id
|
|
68
|
+
token String @unique
|
|
69
|
+
expires DateTime
|
|
70
|
+
|
|
71
|
+
@@unique([identifier, token])
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
enum GameStatus {
|
|
75
|
+
SCHEDULED
|
|
76
|
+
|
|
77
|
+
PREPARATION
|
|
78
|
+
RUNNING
|
|
79
|
+
PAUSED
|
|
80
|
+
CONSOLIDATION
|
|
81
|
+
RESULTS
|
|
82
|
+
|
|
83
|
+
COMPLETED
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
model Game {
|
|
87
|
+
id Int @id @default(autoincrement())
|
|
88
|
+
|
|
89
|
+
status GameStatus @default(SCHEDULED)
|
|
90
|
+
|
|
91
|
+
name String
|
|
92
|
+
|
|
93
|
+
decisions PlayerDecision[]
|
|
94
|
+
actions PlayerAction[]
|
|
95
|
+
players Player[]
|
|
96
|
+
periods Period[]
|
|
97
|
+
results PlayerResult[]
|
|
98
|
+
|
|
99
|
+
activePeriodIx Int @default(-1)
|
|
100
|
+
activePeriodId Int?
|
|
101
|
+
activePeriod Period? @relation("activePeriod", fields: [activePeriodId], references: [id], onUpdate: NoAction, onDelete: NoAction)
|
|
102
|
+
|
|
103
|
+
segments PeriodSegment[]
|
|
104
|
+
|
|
105
|
+
achievements AchievementInstance[]
|
|
106
|
+
|
|
107
|
+
ownerId String @db.Uuid
|
|
108
|
+
owner User @relation(fields: [ownerId], references: [id])
|
|
109
|
+
|
|
110
|
+
createdAt DateTime @default(now())
|
|
111
|
+
updatedAt DateTime @updatedAt
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
model Period {
|
|
115
|
+
id Int @id @default(autoincrement())
|
|
116
|
+
|
|
117
|
+
index Int
|
|
118
|
+
|
|
119
|
+
facts Json
|
|
120
|
+
|
|
121
|
+
segments PeriodSegment[]
|
|
122
|
+
|
|
123
|
+
activeSegmentIx Int @default(-1)
|
|
124
|
+
activeSegmentId Int?
|
|
125
|
+
activeSegment PeriodSegment? @relation("activeSegment", fields: [activeSegmentId], references: [id], onUpdate: NoAction, onDelete: NoAction)
|
|
126
|
+
|
|
127
|
+
decisions PlayerDecision[]
|
|
128
|
+
results PlayerResult[]
|
|
129
|
+
actions PlayerAction[]
|
|
130
|
+
achievements AchievementInstance[]
|
|
131
|
+
|
|
132
|
+
previousPeriod Period[] @relation("periodSequence")
|
|
133
|
+
nextPeriodId Int?
|
|
134
|
+
nextPeriod Period? @relation("periodSequence", fields: [nextPeriodId], references: [id], onUpdate: NoAction, onDelete: NoAction)
|
|
135
|
+
|
|
136
|
+
gameId Int
|
|
137
|
+
game Game @relation(fields: [gameId], references: [id])
|
|
138
|
+
|
|
139
|
+
Game Game[] @relation("activePeriod")
|
|
140
|
+
|
|
141
|
+
createdAt DateTime @default(now())
|
|
142
|
+
updatedAt DateTime @updatedAt
|
|
143
|
+
|
|
144
|
+
@@unique([gameId, index])
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
model PeriodSegment {
|
|
148
|
+
id Int @id @default(autoincrement())
|
|
149
|
+
|
|
150
|
+
index Int
|
|
151
|
+
|
|
152
|
+
facts Json
|
|
153
|
+
|
|
154
|
+
actions PlayerAction[]
|
|
155
|
+
results PlayerResult[]
|
|
156
|
+
|
|
157
|
+
learningElements LearningElement[]
|
|
158
|
+
storyElements StoryElement[]
|
|
159
|
+
|
|
160
|
+
period Period @relation(fields: [periodId], references: [id])
|
|
161
|
+
periodId Int
|
|
162
|
+
periodIx Int
|
|
163
|
+
|
|
164
|
+
Period Period[] @relation("activeSegment")
|
|
165
|
+
|
|
166
|
+
gameId Int
|
|
167
|
+
game Game @relation(fields: [gameId], references: [id])
|
|
168
|
+
|
|
169
|
+
previousSegment PeriodSegment[] @relation("segmentSequence")
|
|
170
|
+
nextSegmentId Int?
|
|
171
|
+
nextSegment PeriodSegment? @relation("segmentSequence", fields: [nextSegmentId], references: [id], onUpdate: NoAction, onDelete: NoAction)
|
|
172
|
+
|
|
173
|
+
createdAt DateTime @default(now())
|
|
174
|
+
updatedAt DateTime @updatedAt
|
|
175
|
+
|
|
176
|
+
@@unique([gameId, periodIx, index])
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
model Player {
|
|
180
|
+
id String @id @default(uuid()) @db.Uuid
|
|
181
|
+
|
|
182
|
+
name String @default("Cocoa AG")
|
|
183
|
+
avatar String @default("")
|
|
184
|
+
location String @default("")
|
|
185
|
+
color String @default("White")
|
|
186
|
+
isReady Boolean @default(false)
|
|
187
|
+
|
|
188
|
+
experience Int @default(0)
|
|
189
|
+
experienceToNext Int @default(100)
|
|
190
|
+
level PlayerLevel @relation(fields: [levelIx], references: [index])
|
|
191
|
+
levelIx Int
|
|
192
|
+
tutorialCompleted Boolean @default(false)
|
|
193
|
+
|
|
194
|
+
facts Json
|
|
195
|
+
|
|
196
|
+
role String @default("unset")
|
|
197
|
+
|
|
198
|
+
token String @unique
|
|
199
|
+
|
|
200
|
+
actions PlayerAction[]
|
|
201
|
+
results PlayerResult[]
|
|
202
|
+
decisions PlayerDecision[]
|
|
203
|
+
|
|
204
|
+
achievementKeys String[]
|
|
205
|
+
achievementIds String[]
|
|
206
|
+
achievements AchievementInstance[]
|
|
207
|
+
|
|
208
|
+
completedLearningElements LearningElement[]
|
|
209
|
+
completedLearningElementIds String[]
|
|
210
|
+
|
|
211
|
+
visitedStoryElements StoryElement[]
|
|
212
|
+
visitedStoryElementIds String[]
|
|
213
|
+
|
|
214
|
+
gameId Int
|
|
215
|
+
game Game @relation(fields: [gameId], references: [id])
|
|
216
|
+
|
|
217
|
+
createdAt DateTime @default(now())
|
|
218
|
+
updatedAt DateTime @updatedAt
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
model PlayerAction {
|
|
222
|
+
id Int @id @default(autoincrement())
|
|
223
|
+
|
|
224
|
+
type String
|
|
225
|
+
facts Json
|
|
226
|
+
|
|
227
|
+
gameId Int
|
|
228
|
+
game Game @relation(fields: [gameId], references: [id])
|
|
229
|
+
|
|
230
|
+
playerId String @db.Uuid
|
|
231
|
+
player Player @relation(fields: [playerId], references: [id])
|
|
232
|
+
|
|
233
|
+
periodId Int
|
|
234
|
+
periodIx Int
|
|
235
|
+
period Period @relation(fields: [periodId], references: [id])
|
|
236
|
+
|
|
237
|
+
segmentId Int?
|
|
238
|
+
segmentIx Int?
|
|
239
|
+
segment PeriodSegment? @relation(fields: [segmentId], references: [id])
|
|
240
|
+
|
|
241
|
+
createdAt DateTime @default(now())
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
enum PlayerResultType {
|
|
245
|
+
PERIOD_START
|
|
246
|
+
SEGMENT_START
|
|
247
|
+
SEGMENT_END
|
|
248
|
+
PERIOD_END
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
model PlayerResult {
|
|
252
|
+
id Int @id @default(autoincrement())
|
|
253
|
+
|
|
254
|
+
type PlayerResultType
|
|
255
|
+
|
|
256
|
+
facts Json
|
|
257
|
+
|
|
258
|
+
playerId String @db.Uuid
|
|
259
|
+
player Player @relation(fields: [playerId], references: [id])
|
|
260
|
+
|
|
261
|
+
gameId Int
|
|
262
|
+
game Game @relation(fields: [gameId], references: [id])
|
|
263
|
+
|
|
264
|
+
periodId Int
|
|
265
|
+
periodIx Int
|
|
266
|
+
period Period @relation(fields: [periodId], references: [id])
|
|
267
|
+
|
|
268
|
+
segmentId Int?
|
|
269
|
+
segmentIx Int?
|
|
270
|
+
segment PeriodSegment? @relation(fields: [segmentId], references: [id])
|
|
271
|
+
|
|
272
|
+
createdAt DateTime @default(now())
|
|
273
|
+
updatedAt DateTime @updatedAt
|
|
274
|
+
|
|
275
|
+
@@unique([periodIx, segmentIx, playerId, type])
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
enum PlayerDecisionType {
|
|
279
|
+
PREPARATION
|
|
280
|
+
CONSOLIDATION
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
model PlayerDecision {
|
|
284
|
+
id Int @id @default(autoincrement())
|
|
285
|
+
|
|
286
|
+
type PlayerDecisionType
|
|
287
|
+
|
|
288
|
+
facts Json
|
|
289
|
+
|
|
290
|
+
gameId Int
|
|
291
|
+
game Game @relation(fields: [gameId], references: [id])
|
|
292
|
+
|
|
293
|
+
playerId String @db.Uuid
|
|
294
|
+
player Player @relation(fields: [playerId], references: [id])
|
|
295
|
+
|
|
296
|
+
periodId Int
|
|
297
|
+
periodIx Int
|
|
298
|
+
period Period @relation(fields: [periodId], references: [id])
|
|
299
|
+
|
|
300
|
+
createdAt DateTime @default(now())
|
|
301
|
+
updatedAt DateTime @updatedAt
|
|
302
|
+
|
|
303
|
+
@@unique([playerId, periodIx, type])
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
model PlayerLevel {
|
|
307
|
+
id Int @id @default(autoincrement())
|
|
308
|
+
|
|
309
|
+
index Int @unique
|
|
310
|
+
|
|
311
|
+
description String
|
|
312
|
+
image String
|
|
313
|
+
|
|
314
|
+
requiredXP Int
|
|
315
|
+
|
|
316
|
+
players Player[]
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
model Event {
|
|
320
|
+
id String @id
|
|
321
|
+
|
|
322
|
+
achievements Achievement[]
|
|
323
|
+
|
|
324
|
+
createdAt DateTime @default(now())
|
|
325
|
+
updatedAt DateTime @updatedAt
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
enum AchievementFrequency {
|
|
329
|
+
FIRST
|
|
330
|
+
EACH
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
model Achievement {
|
|
334
|
+
id String @id
|
|
335
|
+
|
|
336
|
+
name String
|
|
337
|
+
description String
|
|
338
|
+
image String?
|
|
339
|
+
|
|
340
|
+
onEventId String
|
|
341
|
+
onEvent Event @relation(fields: [onEventId], references: [id])
|
|
342
|
+
when AchievementFrequency
|
|
343
|
+
|
|
344
|
+
reward Json?
|
|
345
|
+
|
|
346
|
+
instances AchievementInstance[]
|
|
347
|
+
|
|
348
|
+
createdAt DateTime @default(now())
|
|
349
|
+
updatedAt DateTime @updatedAt
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
model AchievementInstance {
|
|
353
|
+
id Int @id @default(autoincrement())
|
|
354
|
+
|
|
355
|
+
count Int @default(1)
|
|
356
|
+
|
|
357
|
+
achievement Achievement @relation(fields: [achievementId], references: [id])
|
|
358
|
+
achievementId String
|
|
359
|
+
|
|
360
|
+
playerId String @db.Uuid
|
|
361
|
+
player Player @relation(fields: [playerId], references: [id])
|
|
362
|
+
|
|
363
|
+
periodId Int
|
|
364
|
+
period Period @relation(fields: [periodId], references: [id])
|
|
365
|
+
|
|
366
|
+
gameId Int
|
|
367
|
+
game Game @relation(fields: [gameId], references: [id])
|
|
368
|
+
|
|
369
|
+
createdAt DateTime @default(now())
|
|
370
|
+
updatedAt DateTime @updatedAt
|
|
371
|
+
|
|
372
|
+
@@index([playerId, achievementId])
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
model LearningAnswerOption {
|
|
376
|
+
id Int @id @default(autoincrement())
|
|
377
|
+
|
|
378
|
+
content String
|
|
379
|
+
correct Boolean
|
|
380
|
+
feedback String?
|
|
381
|
+
|
|
382
|
+
learningElement LearningElement @relation(fields: [learningElementSlug], references: [id])
|
|
383
|
+
learningElementSlug String
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
model LearningElement {
|
|
387
|
+
id String @id
|
|
388
|
+
|
|
389
|
+
title String
|
|
390
|
+
question String
|
|
391
|
+
options LearningAnswerOption[]
|
|
392
|
+
feedback String?
|
|
393
|
+
motivation String?
|
|
394
|
+
|
|
395
|
+
reward Json?
|
|
396
|
+
|
|
397
|
+
periodSegments PeriodSegment[]
|
|
398
|
+
|
|
399
|
+
players Player[]
|
|
400
|
+
|
|
401
|
+
createdAt DateTime @default(now())
|
|
402
|
+
updatedAt DateTime @updatedAt
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
enum StoryElementType {
|
|
406
|
+
GENERIC
|
|
407
|
+
ROLE_BASED
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
model StoryElement {
|
|
411
|
+
id String @id
|
|
412
|
+
|
|
413
|
+
title String
|
|
414
|
+
|
|
415
|
+
type StoryElementType @default(GENERIC)
|
|
416
|
+
|
|
417
|
+
content String?
|
|
418
|
+
contentRole Json?
|
|
419
|
+
|
|
420
|
+
reward Json?
|
|
421
|
+
|
|
422
|
+
periodSegments PeriodSegment[]
|
|
423
|
+
|
|
424
|
+
players Player[]
|
|
425
|
+
|
|
426
|
+
createdAt DateTime @default(now())
|
|
427
|
+
updatedAt DateTime @updatedAt
|
|
428
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gbl-uzh/platform",
|
|
3
|
+
"version": "0.2.10",
|
|
4
|
+
"license": "AGPL-3.0",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prebuild": "npm run generate",
|
|
12
|
+
"build": "npm-run-all build:nexus build:graphql build:ts build:copy",
|
|
13
|
+
"build:nexus": "ts-node --esm --transpile-only src/nexus.ts",
|
|
14
|
+
"build:graphql": "graphql-codegen --config codegen.ts",
|
|
15
|
+
"build:ts": "NODE_ENV=production tsup",
|
|
16
|
+
"build:copy": "ts-node src/lib/copy.ts",
|
|
17
|
+
"dev": "NODE_ENV=development tsup --watch",
|
|
18
|
+
"generate": "prisma generate"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@graphql-codegen/cli": "2.13.7",
|
|
25
|
+
"@graphql-codegen/fragment-matcher": "3.3.1",
|
|
26
|
+
"@graphql-codegen/introspection": "2.2.1",
|
|
27
|
+
"@graphql-codegen/typed-document-node": "2.3.4",
|
|
28
|
+
"@graphql-codegen/typescript": "2.7.4",
|
|
29
|
+
"@graphql-codegen/typescript-operations": "2.5.4",
|
|
30
|
+
"@graphql-codegen/typescript-resolvers": "2.7.4",
|
|
31
|
+
"@tsconfig/node18": "1.0.1",
|
|
32
|
+
"@tsconfig/recommended": "1.0.1",
|
|
33
|
+
"@types/jest": "^29.2.2",
|
|
34
|
+
"@types/node": "^18.11.9",
|
|
35
|
+
"jest": "29.3.1",
|
|
36
|
+
"npm-run-all": "4.1.5",
|
|
37
|
+
"prisma": "4.5.0",
|
|
38
|
+
"rollup-plugin-copy": "3.4.0",
|
|
39
|
+
"ts-jest": "29.0.3",
|
|
40
|
+
"ts-node": "10.9.1",
|
|
41
|
+
"tsup": "6.2.3",
|
|
42
|
+
"typescript": "4.8.4"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@apollo/client": "^3.7.0",
|
|
46
|
+
"@prisma/client": "4.5.0",
|
|
47
|
+
"@uzh-bf/design-system": "^0.0.79",
|
|
48
|
+
"graphql": "^16.6.0",
|
|
49
|
+
"graphql-scalars": "^1.19.0",
|
|
50
|
+
"graphql-yoga": "^3.0.0-next.4",
|
|
51
|
+
"jsonwebtoken": "^8.5.1",
|
|
52
|
+
"next": "^12.0.0",
|
|
53
|
+
"nexus": "^1.3.0",
|
|
54
|
+
"nookies": "^2.5.2",
|
|
55
|
+
"ramda": "^0.28.0",
|
|
56
|
+
"react": "^18.0.0",
|
|
57
|
+
"ts-pattern": "^4.0.5",
|
|
58
|
+
"yup": "^1.0.0-beta.7"
|
|
59
|
+
},
|
|
60
|
+
"volta": {
|
|
61
|
+
"extends": "../../package.json"
|
|
62
|
+
}
|
|
63
|
+
}
|