@gbl-uzh/platform 0.3.1 → 0.4.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/dist/index.d.ts CHANGED
@@ -1,9 +1,13 @@
1
+ import winston from 'winston';
1
2
  import * as _prisma_client from '.prisma/client';
3
+ import * as DB from '@prisma/client';
2
4
  import { PrismaClient } from '@prisma/client';
3
5
  import { NextPageContext } from 'next';
4
6
  import * as yup from 'yup';
5
7
  import yup__default from 'yup';
6
8
 
9
+ declare const logger: winston.Logger;
10
+
7
11
  declare enum UserRole {
8
12
  PLAYER = "PLAYER",
9
13
  ADMIN = "ADMIN"
@@ -134,18 +138,18 @@ interface CreateGameArgs {
134
138
  }
135
139
  declare function createGame({ name, playerCount }: CreateGameArgs, ctx: Context$1, { roleAssigner }: {
136
140
  roleAssigner: (ix: number) => any;
137
- }): Promise<_prisma_client.Game & {
138
- periods: _prisma_client.Period[];
139
- players: _prisma_client.Player[];
141
+ }): Promise<DB.Game & {
142
+ players: DB.Player[];
143
+ periods: DB.Period[];
140
144
  }>;
141
145
  interface AddGamePeriodArgs<T> {
142
146
  gameId: number;
143
147
  facts: T;
144
148
  }
145
- declare function addGamePeriod<TFacts>({ gameId, facts }: AddGamePeriodArgs<TFacts>, ctx: Context$1, { schema, reducers }: CtxWithFactsAndSchema<TFacts, PrismaClient>): Promise<(_prisma_client.Period & {
146
- segments: (_prisma_client.PeriodSegment & {
147
- storyElements: _prisma_client.StoryElement[];
148
- learningElements: _prisma_client.LearningElement[];
149
+ declare function addGamePeriod<TFacts>({ gameId, facts }: AddGamePeriodArgs<TFacts>, ctx: Context$1, { schema, reducers }: CtxWithFactsAndSchema<TFacts, PrismaClient>): Promise<(DB.Period & {
150
+ segments: (DB.PeriodSegment & {
151
+ learningElements: DB.LearningElement[];
152
+ storyElements: DB.StoryElement[];
149
153
  })[];
150
154
  }) | null>;
151
155
  interface AddPeriodSegmentArgs<TFacts> {
@@ -155,34 +159,34 @@ interface AddPeriodSegmentArgs<TFacts> {
155
159
  learningElements?: string[];
156
160
  storyElements?: string[];
157
161
  }
158
- declare function addPeriodSegment<TFacts>({ gameId, periodIx, facts, learningElements, storyElements, }: AddPeriodSegmentArgs<TFacts>, ctx: Context$1, { schema, reducers }: CtxWithFactsAndSchema<TFacts, PrismaClient>): Promise<(_prisma_client.PeriodSegment & {
159
- storyElements: _prisma_client.StoryElement[];
160
- learningElements: _prisma_client.LearningElement[];
162
+ declare function addPeriodSegment<TFacts>({ gameId, periodIx, facts, learningElements, storyElements, }: AddPeriodSegmentArgs<TFacts>, ctx: Context$1, { schema, reducers }: CtxWithFactsAndSchema<TFacts, PrismaClient>): Promise<(DB.PeriodSegment & {
163
+ learningElements: DB.LearningElement[];
164
+ storyElements: DB.StoryElement[];
161
165
  }) | null>;
162
166
  interface ActivateNextPeriodArgs {
163
167
  gameId: number;
164
168
  }
165
- declare function activateNextPeriod({ gameId }: ActivateNextPeriodArgs, ctx: Context$1, { reducers }: CtxWithFacts<any, PrismaClient>): Promise<[_prisma_client.Game & {
166
- periods: (_prisma_client.Period & {
167
- segments: _prisma_client.PeriodSegment[];
169
+ declare function activateNextPeriod({ gameId }: ActivateNextPeriodArgs, ctx: Context$1, { reducers }: CtxWithFacts<any, PrismaClient>): Promise<[DB.Game & {
170
+ periods: (DB.Period & {
171
+ segments: DB.PeriodSegment[];
168
172
  })[];
169
- }, _prisma_client.Period, ...any[]] | null>;
173
+ }, DB.Period, ...any[]] | null>;
170
174
  interface ActivateSegmentArgs {
171
175
  gameId: number;
172
176
  }
173
- declare function activateNextSegment({ gameId }: ActivateSegmentArgs, ctx: Context$1, { reducers }: CtxWithFacts<any, PrismaClient>): Promise<[_prisma_client.Game & {
174
- periods: (_prisma_client.Period & {
175
- segments: _prisma_client.PeriodSegment[];
177
+ declare function activateNextSegment({ gameId }: ActivateSegmentArgs, ctx: Context$1, { reducers }: CtxWithFacts<any, PrismaClient>): Promise<[DB.Game & {
178
+ players: DB.Player[];
179
+ periods: (DB.Period & {
180
+ segments: DB.PeriodSegment[];
176
181
  })[];
177
- players: _prisma_client.Player[];
178
- }, _prisma_client.Period, _prisma_client.PeriodSegment, ...any[]] | [_prisma_client.Game & {
179
- periods: (_prisma_client.Period & {
180
- segments: _prisma_client.PeriodSegment[];
182
+ }, DB.Period, DB.PeriodSegment, ...any[]] | [DB.Game & {
183
+ players: DB.Player[];
184
+ periods: (DB.Period & {
185
+ segments: DB.PeriodSegment[];
181
186
  })[];
182
- players: _prisma_client.Player[];
183
- }, _prisma_client.PeriodSegment & {
184
- results: _prisma_client.PlayerResult[];
185
- }, ...any[]] | null>;
187
+ }, DB.PeriodSegment & {
188
+ results: DB.PlayerResult[];
189
+ }, DB.Prisma.BatchPayload, ...any[]] | null>;
186
190
  declare const PlayerFactsSchema: yup.ObjectSchema<{
187
191
  location: string;
188
192
  }, yup.AnyObject, {
@@ -196,34 +200,34 @@ interface UpdatePlayerDataArgs {
196
200
  color?: string;
197
201
  facts: PlayerFacts;
198
202
  }
199
- declare function updatePlayerData({ name, avatar, color, facts }: UpdatePlayerDataArgs, ctx: Context$1): Promise<(_prisma_client.Player & {
200
- level: _prisma_client.PlayerLevel;
201
- achievements: (_prisma_client.AchievementInstance & {
202
- achievement: _prisma_client.Achievement;
203
+ declare function updatePlayerData({ name, avatar, color, facts }: UpdatePlayerDataArgs, ctx: Context$1): Promise<(DB.Player & {
204
+ level: DB.PlayerLevel;
205
+ achievements: (DB.AchievementInstance & {
206
+ achievement: DB.Achievement;
203
207
  })[];
204
208
  }) | null>;
205
- declare function getGames(args: any, ctx: Context$1): Promise<_prisma_client.Game[]>;
206
- declare function getGame(args: any, ctx: Context$1): Promise<(_prisma_client.Game & {
207
- periods: (_prisma_client.Period & {
208
- segments: (_prisma_client.PeriodSegment & {
209
- storyElements: _prisma_client.StoryElement[];
210
- learningElements: _prisma_client.LearningElement[];
211
- })[];
209
+ declare function getGames(args: any, ctx: Context$1): Promise<DB.Game[]>;
210
+ declare function getGame(args: any, ctx: Context$1): Promise<(DB.Game & {
211
+ players: (DB.Player & {
212
+ level: DB.PlayerLevel;
213
+ achievements: DB.AchievementInstance[];
212
214
  })[];
213
- players: (_prisma_client.Player & {
214
- level: _prisma_client.PlayerLevel;
215
- achievements: _prisma_client.AchievementInstance[];
215
+ periods: (DB.Period & {
216
+ segments: (DB.PeriodSegment & {
217
+ learningElements: DB.LearningElement[];
218
+ storyElements: DB.StoryElement[];
219
+ })[];
216
220
  })[];
217
- activePeriod: (_prisma_client.Period & {
218
- segments: _prisma_client.PeriodSegment[];
219
- activeSegment: _prisma_client.PeriodSegment | null;
221
+ activePeriod: (DB.Period & {
222
+ segments: DB.PeriodSegment[];
223
+ activeSegment: DB.PeriodSegment | null;
220
224
  }) | null;
221
225
  }) | null>;
222
- declare function getGameFromContext(ctx: Context$1): Promise<(_prisma_client.Game & {
223
- activePeriod: _prisma_client.Period | null;
226
+ declare function getGameFromContext(ctx: Context$1): Promise<(DB.Game & {
227
+ activePeriod: DB.Period | null;
224
228
  }) | null>;
225
- declare function getLearningElements(args: any, ctx: Context$1): Promise<(_prisma_client.LearningElement & {
226
- options: _prisma_client.LearningAnswerOption[];
229
+ declare function getLearningElements(args: any, ctx: Context$1): Promise<(DB.LearningElement & {
230
+ options: DB.LearningAnswerOption[];
227
231
  })[]>;
228
232
  declare function computePeriodStartResults({ results, players, activePeriodIx, gameId, periodFacts }: {
229
233
  results: any;
@@ -237,12 +241,13 @@ declare function computePeriodStartResults({ results, players, activePeriodIx, g
237
241
  results: any;
238
242
  extras: any[];
239
243
  };
240
- declare function computePeriodEndResults({ segmentResults, periodFacts, periodDecisions, segmentFacts, activePeriodIx, gameId, }: {
244
+ declare function computePeriodEndResults({ segmentResults, periodFacts, periodDecisions, segmentFacts, activePeriodIx, activeSegmentIx, gameId, }: {
241
245
  segmentResults: any;
242
246
  periodFacts: any;
243
247
  periodDecisions: any;
244
248
  segmentFacts: any;
245
249
  activePeriodIx: any;
250
+ activeSegmentIx: any;
246
251
  gameId: any;
247
252
  }, ctx: Context$1, { reducers }: {
248
253
  reducers: any;
@@ -299,12 +304,7 @@ declare namespace GameService {
299
304
  };
300
305
  }
301
306
 
302
- declare enum PlayerDecisionType {
303
- Consolidation = "CONSOLIDATION",
304
- Preparation = "PREPARATION"
305
- }
306
-
307
- type Context = CtxWithPrisma<PrismaClient>;
307
+ type Context = CtxWithPrisma<DB.PrismaClient>;
308
308
  interface PerformActionArgs<ActionTypes> {
309
309
  gameId: number;
310
310
  periodIx: number;
@@ -313,56 +313,56 @@ interface PerformActionArgs<ActionTypes> {
313
313
  actionType: ActionTypes;
314
314
  facts: any;
315
315
  }
316
- declare function performAction<ActionTypes>(args: PerformActionArgs<ActionTypes>, ctx: Context, { reducers }: any): Promise<(_prisma_client.PlayerResult & {
317
- period: _prisma_client.Period;
316
+ declare function performAction<ActionTypes>(args: PerformActionArgs<ActionTypes>, ctx: Context, { reducers }: any): Promise<(DB.PlayerResult & {
317
+ period: DB.Period;
318
318
  }) | null>;
319
319
  interface SaveDecisionsArgs {
320
- decisionType: PlayerDecisionType;
320
+ decisionType: DB.PlayerDecisionType;
321
321
  facts: any;
322
322
  }
323
- declare function saveDecisions(args: SaveDecisionsArgs, ctx: Context): Promise<_prisma_client.PlayerDecision | null>;
323
+ declare function saveDecisions(args: SaveDecisionsArgs, ctx: Context): Promise<DB.PlayerDecision | null>;
324
324
  interface GetPlayerResultArgs {
325
325
  gameId: number;
326
326
  playerId: string;
327
327
  }
328
328
  declare function getPlayerResult(args: GetPlayerResultArgs, ctx: Context): Promise<{
329
- currentGame: _prisma_client.Game & {
330
- periods: (_prisma_client.Period & {
331
- segments: (_prisma_client.PeriodSegment & {
332
- storyElements: _prisma_client.StoryElement[];
333
- learningElements: _prisma_client.LearningElement[];
329
+ currentGame: DB.Game & {
330
+ periods: (DB.Period & {
331
+ segments: (DB.PeriodSegment & {
332
+ learningElements: DB.LearningElement[];
333
+ storyElements: DB.StoryElement[];
334
334
  })[];
335
335
  })[];
336
- activePeriod: (_prisma_client.Period & {
337
- segments: (_prisma_client.PeriodSegment & {
338
- storyElements: _prisma_client.StoryElement[];
339
- learningElements: _prisma_client.LearningElement[];
336
+ activePeriod: (DB.Period & {
337
+ segments: (DB.PeriodSegment & {
338
+ learningElements: DB.LearningElement[];
339
+ storyElements: DB.StoryElement[];
340
340
  })[];
341
- activeSegment: (_prisma_client.PeriodSegment & {
342
- storyElements: _prisma_client.StoryElement[];
343
- learningElements: _prisma_client.LearningElement[];
341
+ activeSegment: (DB.PeriodSegment & {
342
+ learningElements: DB.LearningElement[];
343
+ storyElements: DB.StoryElement[];
344
344
  }) | null;
345
345
  }) | null;
346
346
  };
347
- playerResult: (_prisma_client.PlayerResult & {
348
- period: _prisma_client.Period;
349
- player: _prisma_client.Player & {
350
- completedLearningElements: _prisma_client.LearningElement[];
351
- visitedStoryElements: _prisma_client.StoryElement[];
347
+ playerResult: (DB.PlayerResult & {
348
+ period: DB.Period;
349
+ player: DB.Player & {
350
+ completedLearningElements: DB.LearningElement[];
351
+ visitedStoryElements: DB.StoryElement[];
352
352
  };
353
353
  }) | null;
354
- previousResults: _prisma_client.Prisma.PrismaPromise<(_prisma_client.PlayerResult & {
355
- period: _prisma_client.Period;
354
+ previousResults: DB.Prisma.PrismaPromise<(DB.PlayerResult & {
355
+ period: DB.Period;
356
356
  })[]>;
357
- transactions: _prisma_client.Prisma.PrismaPromise<_prisma_client.PlayerAction[]>;
357
+ transactions: DB.Prisma.PrismaPromise<DB.PlayerAction[]>;
358
358
  } | null>;
359
359
  interface GetPlayerDataArgs {
360
360
  playerId: string;
361
361
  }
362
- declare function getPlayerData(args: GetPlayerDataArgs, ctx: Context): Promise<(_prisma_client.Player & {
363
- level: _prisma_client.PlayerLevel;
364
- achievements: (_prisma_client.AchievementInstance & {
365
- achievement: _prisma_client.Achievement;
362
+ declare function getPlayerData(args: GetPlayerDataArgs, ctx: Context): Promise<(DB.Player & {
363
+ level: DB.PlayerLevel;
364
+ achievements: (DB.AchievementInstance & {
365
+ achievement: DB.Achievement;
366
366
  })[];
367
367
  }) | null>;
368
368
  interface GetLearningElementArgs {
@@ -376,10 +376,10 @@ declare function getLearningElement(args: GetLearningElementArgs, ctx: Context):
376
376
  title: string;
377
377
  question: string;
378
378
  motivation: string | null;
379
- reward: _prisma_client.Prisma.JsonValue;
379
+ reward: DB.Prisma.JsonValue;
380
380
  createdAt: Date;
381
381
  updatedAt: Date;
382
- options: _prisma_client.LearningAnswerOption[];
382
+ options: DB.LearningAnswerOption[];
383
383
  };
384
384
  state: LearningElementState;
385
385
  solution: string | null;
@@ -401,20 +401,22 @@ declare function attemptLearningElement(args: AttemptLearningElementArgs, ctx: C
401
401
  interface MarkStoryElementArgs {
402
402
  elementId: string;
403
403
  }
404
- declare function markStoryElement(args: MarkStoryElementArgs, ctx: Context): Promise<_prisma_client.Player | null>;
404
+ declare function markStoryElement(args: MarkStoryElementArgs, ctx: Context): Promise<DB.Player | null>;
405
405
  interface GetPlayerTransactionsArgs {
406
406
  }
407
- declare function getPlayerTransactions(args: GetPlayerTransactionsArgs, ctx: Context): Promise<_prisma_client.PlayerAction[]>;
408
- declare function getPlayerResults(args: any, ctx: Context): Promise<(_prisma_client.PlayerResult & {
409
- period: _prisma_client.Period;
410
- segment: _prisma_client.PeriodSegment | null;
411
- player: _prisma_client.Player;
407
+ declare function getPlayerTransactions(args: GetPlayerTransactionsArgs, ctx: Context): Promise<DB.PlayerAction[]>;
408
+ declare function getPlayerResults(args: any, ctx: Context): Promise<(DB.PlayerResult & {
409
+ period: DB.Period;
410
+ player: DB.Player;
411
+ segment: DB.PeriodSegment | null;
412
412
  })[]>;
413
- declare function getPastResults(args: any, ctx: Context): Promise<(_prisma_client.PlayerResult & {
414
- period: _prisma_client.Period;
415
- player: _prisma_client.Player;
413
+ declare function getPastResults(args: any, ctx: Context): Promise<(DB.PlayerResult & {
414
+ period: DB.Period;
415
+ player: DB.Player & {
416
+ level: DB.PlayerLevel;
417
+ };
416
418
  })[] | null>;
417
- declare function updateReadyState(args: any, ctx: Context): Promise<_prisma_client.Player>;
419
+ declare function updateReadyState(args: any, ctx: Context): Promise<DB.Player>;
418
420
 
419
421
  declare const PlayService_attemptLearningElement: typeof attemptLearningElement;
420
422
  declare const PlayService_getLearningElement: typeof getLearningElement;
@@ -443,4 +445,4 @@ declare namespace PlayService {
443
445
  };
444
446
  }
445
447
 
446
- export { AccountService, Action, BaseGlobalNotificationType, BaseUserNotificationType, CtxWithFacts, CtxWithFactsAndSchema, CtxWithPrisma, Event, EventService, GameService, LearningElementState, Notification, Output, PlayService, UserRole };
448
+ export { AccountService, Action, BaseGlobalNotificationType, BaseUserNotificationType, CtxWithFacts, CtxWithFactsAndSchema, CtxWithPrisma, Event, EventService, GameService, LearningElementState, Notification, Output, PlayService, UserRole, logger as log };