@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.
@@ -0,0 +1,430 @@
1
+ import * as _prisma_client from '.prisma/client';
2
+ import { PrismaClient } from '@prisma/client';
3
+ import { NextPageContext } from 'next';
4
+ import * as yup from 'yup';
5
+ import yup__default from 'yup';
6
+ import { PlayerDecisionType } from './generated/ops.js';
7
+ import 'graphql';
8
+ import '@graphql-typed-document-node/core';
9
+
10
+ declare enum UserRole {
11
+ PLAYER = "PLAYER",
12
+ ADMIN = "ADMIN"
13
+ }
14
+ declare enum LearningElementState {
15
+ NEW = "NEW",
16
+ ATTEMPTED = "ATTEMPTED",
17
+ SOLVED = "SOLVED"
18
+ }
19
+ declare type Notification<NotificationType> = {
20
+ type: NotificationType;
21
+ sub?: string;
22
+ facts?: any;
23
+ };
24
+ declare type Event<EventType> = {
25
+ type: EventType;
26
+ sub?: string;
27
+ facts?: any;
28
+ };
29
+ declare type Output<OutputType, NotificationType, EventType> = {
30
+ type: OutputType;
31
+ extras?: any;
32
+ result: any;
33
+ notifications: Notification<NotificationType>[];
34
+ events: Event<EventType>[];
35
+ actions?: any[];
36
+ isDirty: boolean;
37
+ };
38
+ declare type Action<ActionType, PayloadType, PrismaType> = {
39
+ type: ActionType;
40
+ payload: PayloadType;
41
+ ctx?: CtxWithPrisma<PrismaType>;
42
+ };
43
+ interface Reducer<StateType, ActionType, PayloadType, OutputType, NotificationType, EventType, PrismaType> {
44
+ apply: (state: StateType, action: Action<ActionType, PayloadType, PrismaType>) => Output<OutputType, NotificationType, EventType>;
45
+ ActionTypes: Record<string, string>;
46
+ }
47
+ interface Reducers<PrismaType> {
48
+ Actions: Reducer<any, any, any, any, any, any, PrismaType>;
49
+ Period: Reducer<any, any, any, any, any, any, PrismaType>;
50
+ PeriodResult: Reducer<any, any, any, any, any, any, PrismaType>;
51
+ Segment: Reducer<any, any, any, any, any, any, PrismaType>;
52
+ SegmentResult: Reducer<any, any, any, any, any, any, PrismaType>;
53
+ [key: string]: Reducer<any, any, any, any, any, any, PrismaType>;
54
+ }
55
+ interface CtxWithPrisma<PrismaType> extends NextPageContext {
56
+ prisma: PrismaType;
57
+ user: {
58
+ sub: string;
59
+ role: UserRole;
60
+ gameId?: number;
61
+ };
62
+ }
63
+ interface CtxWithFacts<FactsType, PrismaType> {
64
+ reducers: Reducers<PrismaType>;
65
+ }
66
+ interface CtxWithFactsAndSchema<FactsType, PrismaType> {
67
+ schema: yup__default.Schema<FactsType>;
68
+ reducers: Reducers<PrismaType>;
69
+ }
70
+ declare enum BaseGlobalNotificationType {
71
+ PERIOD_ACTIVATED = "PERIOD_ACTIVATED",
72
+ SEGMENT_ACTIVATED = "SEGMENT_ACTIVATED"
73
+ }
74
+ declare enum BaseUserNotificationType {
75
+ LEARNING_ELEMENT_SOLVED = "LEARNING_ELEMENT_SOLVED",
76
+ LEARNING_ELEMENT_INCORRECT = "LEARNING_ELEMENT_INCORRECT",
77
+ ACHIEVEMENT_RECEIVED = "ACHIEVEMENT_RECEIVED",
78
+ LEVEL_UP = "LEVEL_UP"
79
+ }
80
+
81
+ interface CreateLoginTokenArgs {
82
+ sub: string;
83
+ role: UserRole;
84
+ token?: string;
85
+ gameId?: number;
86
+ }
87
+ declare function createLoginToken({ sub, role, ...extra }: CreateLoginTokenArgs): string;
88
+ interface LoginAsTeamArgs {
89
+ token: string;
90
+ }
91
+ declare function loginAsTeam({ token }: LoginAsTeamArgs, ctx: CtxWithPrisma<PrismaClient>): Promise<(_prisma_client.Player & {
92
+ level: _prisma_client.PlayerLevel;
93
+ achievements: (_prisma_client.AchievementInstance & {
94
+ achievement: _prisma_client.Achievement;
95
+ })[];
96
+ }) | null>;
97
+
98
+ declare const AccountService_createLoginToken: typeof createLoginToken;
99
+ declare const AccountService_loginAsTeam: typeof loginAsTeam;
100
+ declare namespace AccountService {
101
+ export {
102
+ AccountService_createLoginToken as createLoginToken,
103
+ AccountService_loginAsTeam as loginAsTeam,
104
+ };
105
+ }
106
+
107
+ declare function receiveEvents({ events, ctx, prisma }: {
108
+ events: any;
109
+ ctx: any;
110
+ prisma: any;
111
+ }): Promise<any>;
112
+ declare function receiveEvent(event: any, definedEvents: any, definedLevels: any, prisma: any): Promise<any[]>;
113
+ declare function publishGlobalNotification(event: any): void;
114
+ declare function publishUserNotification(ctx: {
115
+ user: {
116
+ sub: string;
117
+ };
118
+ }, events?: any): void;
119
+
120
+ declare const EventService_receiveEvents: typeof receiveEvents;
121
+ declare const EventService_receiveEvent: typeof receiveEvent;
122
+ declare const EventService_publishGlobalNotification: typeof publishGlobalNotification;
123
+ declare const EventService_publishUserNotification: typeof publishUserNotification;
124
+ declare namespace EventService {
125
+ export {
126
+ EventService_receiveEvents as receiveEvents,
127
+ EventService_receiveEvent as receiveEvent,
128
+ EventService_publishGlobalNotification as publishGlobalNotification,
129
+ EventService_publishUserNotification as publishUserNotification,
130
+ };
131
+ }
132
+
133
+ declare type Context$1 = CtxWithPrisma<PrismaClient>;
134
+ interface CreateGameArgs {
135
+ name: string;
136
+ playerCount: number;
137
+ }
138
+ declare function createGame({ name, playerCount }: CreateGameArgs, ctx: Context$1, { roleAssigner }: {
139
+ roleAssigner: (ix: number) => any;
140
+ }): Promise<_prisma_client.Game & {
141
+ periods: _prisma_client.Period[];
142
+ players: _prisma_client.Player[];
143
+ }>;
144
+ interface AddGamePeriodArgs<T> {
145
+ gameId: number;
146
+ facts: T;
147
+ }
148
+ declare function addGamePeriod<TFacts>({ gameId, facts }: AddGamePeriodArgs<TFacts>, ctx: Context$1, { schema, reducers }: CtxWithFactsAndSchema<TFacts, PrismaClient>): Promise<(_prisma_client.Period & {
149
+ segments: (_prisma_client.PeriodSegment & {
150
+ storyElements: _prisma_client.StoryElement[];
151
+ learningElements: _prisma_client.LearningElement[];
152
+ })[];
153
+ }) | null>;
154
+ interface AddPeriodSegmentArgs<TFacts> {
155
+ gameId: number;
156
+ periodIx: number;
157
+ facts: TFacts;
158
+ learningElements?: string[];
159
+ storyElements?: string[];
160
+ }
161
+ declare function addPeriodSegment<TFacts>({ gameId, periodIx, facts, learningElements, storyElements, }: AddPeriodSegmentArgs<TFacts>, ctx: Context$1, { schema, reducers }: CtxWithFactsAndSchema<TFacts, PrismaClient>): Promise<(_prisma_client.PeriodSegment & {
162
+ storyElements: _prisma_client.StoryElement[];
163
+ learningElements: _prisma_client.LearningElement[];
164
+ }) | null>;
165
+ interface ActivateNextPeriodArgs {
166
+ gameId: number;
167
+ }
168
+ declare function activateNextPeriod({ gameId }: ActivateNextPeriodArgs, ctx: Context$1, { reducers }: CtxWithFacts<any, PrismaClient>): Promise<[_prisma_client.Game, _prisma_client.Period, ...any[]] | null>;
169
+ interface ActivateSegmentArgs {
170
+ gameId: number;
171
+ }
172
+ declare function activateNextSegment({ gameId }: ActivateSegmentArgs, ctx: Context$1, { reducers }: CtxWithFacts<any, PrismaClient>): Promise<[_prisma_client.Game, _prisma_client.Period, _prisma_client.PeriodSegment, ...any[]] | [_prisma_client.Game, _prisma_client.PeriodSegment & {
173
+ results: _prisma_client.PlayerResult[];
174
+ }, ...any[]] | null>;
175
+ declare const PlayerFactsSchema: yup.ObjectSchema<{
176
+ location: string;
177
+ }, yup.AnyObject, {
178
+ location: "Zurich";
179
+ }, "">;
180
+ interface PlayerFacts extends yup.InferType<typeof PlayerFactsSchema> {
181
+ }
182
+ interface UpdatePlayerDataArgs {
183
+ name?: string;
184
+ avatar?: string;
185
+ color?: string;
186
+ facts: PlayerFacts;
187
+ }
188
+ declare function updatePlayerData({ name, avatar, color, facts }: UpdatePlayerDataArgs, ctx: Context$1): Promise<(_prisma_client.Player & {
189
+ level: _prisma_client.PlayerLevel;
190
+ achievements: (_prisma_client.AchievementInstance & {
191
+ achievement: _prisma_client.Achievement;
192
+ })[];
193
+ }) | null>;
194
+ declare function getGames(args: any, ctx: Context$1): Promise<_prisma_client.Game[]>;
195
+ declare function getGame(args: any, ctx: Context$1): Promise<(_prisma_client.Game & {
196
+ periods: (_prisma_client.Period & {
197
+ segments: (_prisma_client.PeriodSegment & {
198
+ storyElements: _prisma_client.StoryElement[];
199
+ learningElements: _prisma_client.LearningElement[];
200
+ })[];
201
+ })[];
202
+ players: (_prisma_client.Player & {
203
+ level: _prisma_client.PlayerLevel;
204
+ achievements: _prisma_client.AchievementInstance[];
205
+ })[];
206
+ activePeriod: (_prisma_client.Period & {
207
+ segments: _prisma_client.PeriodSegment[];
208
+ activeSegment: _prisma_client.PeriodSegment | null;
209
+ }) | null;
210
+ }) | null>;
211
+ declare function getGameFromContext(ctx: Context$1): Promise<(_prisma_client.Game & {
212
+ activePeriod: _prisma_client.Period | null;
213
+ }) | null>;
214
+ declare function getLearningElements(args: any, ctx: Context$1): Promise<(_prisma_client.LearningElement & {
215
+ options: _prisma_client.LearningAnswerOption[];
216
+ })[]>;
217
+ declare function computePeriodStartResults({ results, players, activePeriodIx, gameId, periodFacts }: {
218
+ results: any;
219
+ players: any;
220
+ activePeriodIx: any;
221
+ gameId: any;
222
+ periodFacts: any;
223
+ }, ctx: any, { reducers }: {
224
+ reducers: any;
225
+ }): {
226
+ results: any;
227
+ extras: any[];
228
+ };
229
+ declare function computePeriodEndResults({ segmentResults, periodFacts, periodDecisions, segmentFacts, activePeriodIx, gameId, }: {
230
+ segmentResults: any;
231
+ periodFacts: any;
232
+ periodDecisions: any;
233
+ segmentFacts: any;
234
+ activePeriodIx: any;
235
+ gameId: any;
236
+ }, ctx: Context$1, { reducers }: {
237
+ reducers: any;
238
+ }): Promise<{
239
+ extras: any[];
240
+ results: any;
241
+ promises: Promise<any>[];
242
+ }>;
243
+ declare function computeSegmentStartResults(game: any, ctx: any, { reducers }: {
244
+ reducers: any;
245
+ }): {
246
+ results: any;
247
+ extras: any[];
248
+ };
249
+ declare function computeSegmentEndResults(game: any, ctx: any, { reducers }: {
250
+ reducers: any;
251
+ }): {
252
+ results: any;
253
+ extras: any[];
254
+ };
255
+
256
+ declare const GameService_createGame: typeof createGame;
257
+ declare const GameService_addGamePeriod: typeof addGamePeriod;
258
+ declare const GameService_addPeriodSegment: typeof addPeriodSegment;
259
+ declare const GameService_activateNextPeriod: typeof activateNextPeriod;
260
+ declare const GameService_activateNextSegment: typeof activateNextSegment;
261
+ type GameService_PlayerFacts = PlayerFacts;
262
+ declare const GameService_updatePlayerData: typeof updatePlayerData;
263
+ declare const GameService_getGames: typeof getGames;
264
+ declare const GameService_getGame: typeof getGame;
265
+ declare const GameService_getGameFromContext: typeof getGameFromContext;
266
+ declare const GameService_getLearningElements: typeof getLearningElements;
267
+ declare const GameService_computePeriodStartResults: typeof computePeriodStartResults;
268
+ declare const GameService_computePeriodEndResults: typeof computePeriodEndResults;
269
+ declare const GameService_computeSegmentStartResults: typeof computeSegmentStartResults;
270
+ declare const GameService_computeSegmentEndResults: typeof computeSegmentEndResults;
271
+ declare namespace GameService {
272
+ export {
273
+ GameService_createGame as createGame,
274
+ GameService_addGamePeriod as addGamePeriod,
275
+ GameService_addPeriodSegment as addPeriodSegment,
276
+ GameService_activateNextPeriod as activateNextPeriod,
277
+ GameService_activateNextSegment as activateNextSegment,
278
+ GameService_PlayerFacts as PlayerFacts,
279
+ GameService_updatePlayerData as updatePlayerData,
280
+ GameService_getGames as getGames,
281
+ GameService_getGame as getGame,
282
+ GameService_getGameFromContext as getGameFromContext,
283
+ GameService_getLearningElements as getLearningElements,
284
+ GameService_computePeriodStartResults as computePeriodStartResults,
285
+ GameService_computePeriodEndResults as computePeriodEndResults,
286
+ GameService_computeSegmentStartResults as computeSegmentStartResults,
287
+ GameService_computeSegmentEndResults as computeSegmentEndResults,
288
+ };
289
+ }
290
+
291
+ declare type Context = CtxWithPrisma<PrismaClient>;
292
+ interface PerformActionArgs<ActionTypes> {
293
+ gameId: number;
294
+ periodIx: number;
295
+ segmentIx: number;
296
+ playerId: string;
297
+ actionType: ActionTypes;
298
+ facts: any;
299
+ }
300
+ declare function performAction<ActionTypes>(args: PerformActionArgs<ActionTypes>, ctx: Context, { reducers }: any): Promise<(_prisma_client.PlayerResult & {
301
+ period: _prisma_client.Period;
302
+ }) | null>;
303
+ interface SaveDecisionsArgs {
304
+ decisionType: PlayerDecisionType;
305
+ facts: any;
306
+ }
307
+ declare function saveDecisions(args: SaveDecisionsArgs, ctx: Context): Promise<_prisma_client.PlayerDecision | null>;
308
+ interface GetPlayerResultArgs {
309
+ gameId: number;
310
+ playerId: string;
311
+ }
312
+ declare function getPlayerResult(args: GetPlayerResultArgs, ctx: Context): Promise<{
313
+ currentGame: _prisma_client.Game & {
314
+ periods: (_prisma_client.Period & {
315
+ segments: (_prisma_client.PeriodSegment & {
316
+ storyElements: _prisma_client.StoryElement[];
317
+ learningElements: _prisma_client.LearningElement[];
318
+ })[];
319
+ })[];
320
+ activePeriod: (_prisma_client.Period & {
321
+ segments: (_prisma_client.PeriodSegment & {
322
+ storyElements: _prisma_client.StoryElement[];
323
+ learningElements: _prisma_client.LearningElement[];
324
+ })[];
325
+ activeSegment: (_prisma_client.PeriodSegment & {
326
+ storyElements: _prisma_client.StoryElement[];
327
+ learningElements: _prisma_client.LearningElement[];
328
+ }) | null;
329
+ }) | null;
330
+ };
331
+ playerResult: (_prisma_client.PlayerResult & {
332
+ period: _prisma_client.Period;
333
+ player: _prisma_client.Player & {
334
+ completedLearningElements: _prisma_client.LearningElement[];
335
+ visitedStoryElements: _prisma_client.StoryElement[];
336
+ };
337
+ }) | null;
338
+ previousResults: _prisma_client.PrismaPromise<(_prisma_client.PlayerResult & {
339
+ period: _prisma_client.Period;
340
+ })[]>;
341
+ transactions: _prisma_client.PrismaPromise<_prisma_client.PlayerAction[]>;
342
+ } | null>;
343
+ interface GetPlayerDataArgs {
344
+ playerId: string;
345
+ }
346
+ declare function getPlayerData(args: GetPlayerDataArgs, ctx: Context): Promise<(_prisma_client.Player & {
347
+ level: _prisma_client.PlayerLevel;
348
+ achievements: (_prisma_client.AchievementInstance & {
349
+ achievement: _prisma_client.Achievement;
350
+ })[];
351
+ }) | null>;
352
+ interface GetLearningElementArgs {
353
+ id: string;
354
+ }
355
+ declare function getLearningElement(args: GetLearningElementArgs, ctx: Context): Promise<{
356
+ id: string;
357
+ element: {
358
+ feedback: string | null;
359
+ id: string;
360
+ title: string;
361
+ question: string;
362
+ motivation: string | null;
363
+ reward: _prisma_client.Prisma.JsonValue;
364
+ createdAt: Date;
365
+ updatedAt: Date;
366
+ options: _prisma_client.LearningAnswerOption[];
367
+ };
368
+ state: LearningElementState;
369
+ solution: string | null;
370
+ } | null>;
371
+ interface AttemptLearningElementArgs {
372
+ elementId: string;
373
+ selection: string;
374
+ }
375
+ declare function attemptLearningElement(args: AttemptLearningElementArgs, ctx: Context): Promise<{
376
+ id: string;
377
+ pointsAchieved: number;
378
+ pointsMax: number;
379
+ element: {
380
+ id: string;
381
+ feedback: string | null;
382
+ };
383
+ player: any;
384
+ } | null>;
385
+ interface MarkStoryElementArgs {
386
+ elementId: string;
387
+ }
388
+ declare function markStoryElement(args: MarkStoryElementArgs, ctx: Context): Promise<_prisma_client.Player | null>;
389
+ interface GetPlayerTransactionsArgs {
390
+ }
391
+ declare function getPlayerTransactions(args: GetPlayerTransactionsArgs, ctx: Context): Promise<_prisma_client.PlayerAction[]>;
392
+ declare function getPlayerResults(args: any, ctx: Context): Promise<(_prisma_client.PlayerResult & {
393
+ period: _prisma_client.Period;
394
+ segment: _prisma_client.PeriodSegment | null;
395
+ player: _prisma_client.Player;
396
+ })[]>;
397
+ declare function getPastResults(args: any, ctx: Context): Promise<(_prisma_client.PlayerResult & {
398
+ period: _prisma_client.Period;
399
+ player: _prisma_client.Player;
400
+ })[] | null>;
401
+ declare function updateReadyState(args: any, ctx: Context): Promise<_prisma_client.Player>;
402
+
403
+ declare const PlayService_performAction: typeof performAction;
404
+ declare const PlayService_saveDecisions: typeof saveDecisions;
405
+ declare const PlayService_getPlayerResult: typeof getPlayerResult;
406
+ declare const PlayService_getPlayerData: typeof getPlayerData;
407
+ declare const PlayService_getLearningElement: typeof getLearningElement;
408
+ declare const PlayService_attemptLearningElement: typeof attemptLearningElement;
409
+ declare const PlayService_markStoryElement: typeof markStoryElement;
410
+ declare const PlayService_getPlayerTransactions: typeof getPlayerTransactions;
411
+ declare const PlayService_getPlayerResults: typeof getPlayerResults;
412
+ declare const PlayService_getPastResults: typeof getPastResults;
413
+ declare const PlayService_updateReadyState: typeof updateReadyState;
414
+ declare namespace PlayService {
415
+ export {
416
+ PlayService_performAction as performAction,
417
+ PlayService_saveDecisions as saveDecisions,
418
+ PlayService_getPlayerResult as getPlayerResult,
419
+ PlayService_getPlayerData as getPlayerData,
420
+ PlayService_getLearningElement as getLearningElement,
421
+ PlayService_attemptLearningElement as attemptLearningElement,
422
+ PlayService_markStoryElement as markStoryElement,
423
+ PlayService_getPlayerTransactions as getPlayerTransactions,
424
+ PlayService_getPlayerResults as getPlayerResults,
425
+ PlayService_getPastResults as getPastResults,
426
+ PlayService_updateReadyState as updateReadyState,
427
+ };
428
+ }
429
+
430
+ export { AccountService, Action, BaseGlobalNotificationType, BaseUserNotificationType, CtxWithFacts, CtxWithFactsAndSchema, CtxWithPrisma, Event, EventService, GameService, LearningElementState, Notification, Output, PlayService, UserRole };