@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 +96 -94
- package/dist/index.js +77 -74
- package/dist/lib/util.d.ts +12 -1
- package/dist/lib/util.js +39 -0
- package/dist/nexus.d.ts +1 -1
- package/dist/nexus.js +81 -75
- package/package.json +14 -20
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<
|
|
138
|
-
|
|
139
|
-
|
|
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<(
|
|
146
|
-
segments: (
|
|
147
|
-
|
|
148
|
-
|
|
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<(
|
|
159
|
-
|
|
160
|
-
|
|
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<[
|
|
166
|
-
periods: (
|
|
167
|
-
segments:
|
|
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
|
-
},
|
|
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<[
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
periods: (
|
|
180
|
-
segments:
|
|
182
|
+
}, DB.Period, DB.PeriodSegment, ...any[]] | [DB.Game & {
|
|
183
|
+
players: DB.Player[];
|
|
184
|
+
periods: (DB.Period & {
|
|
185
|
+
segments: DB.PeriodSegment[];
|
|
181
186
|
})[];
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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<(
|
|
200
|
-
level:
|
|
201
|
-
achievements: (
|
|
202
|
-
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<
|
|
206
|
-
declare function getGame(args: any, ctx: Context$1): Promise<(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
periods: (DB.Period & {
|
|
216
|
+
segments: (DB.PeriodSegment & {
|
|
217
|
+
learningElements: DB.LearningElement[];
|
|
218
|
+
storyElements: DB.StoryElement[];
|
|
219
|
+
})[];
|
|
216
220
|
})[];
|
|
217
|
-
activePeriod: (
|
|
218
|
-
segments:
|
|
219
|
-
activeSegment:
|
|
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<(
|
|
223
|
-
activePeriod:
|
|
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<(
|
|
226
|
-
options:
|
|
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
|
-
|
|
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<(
|
|
317
|
-
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<
|
|
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:
|
|
330
|
-
periods: (
|
|
331
|
-
segments: (
|
|
332
|
-
|
|
333
|
-
|
|
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: (
|
|
337
|
-
segments: (
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
activePeriod: (DB.Period & {
|
|
337
|
+
segments: (DB.PeriodSegment & {
|
|
338
|
+
learningElements: DB.LearningElement[];
|
|
339
|
+
storyElements: DB.StoryElement[];
|
|
340
340
|
})[];
|
|
341
|
-
activeSegment: (
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
activeSegment: (DB.PeriodSegment & {
|
|
342
|
+
learningElements: DB.LearningElement[];
|
|
343
|
+
storyElements: DB.StoryElement[];
|
|
344
344
|
}) | null;
|
|
345
345
|
}) | null;
|
|
346
346
|
};
|
|
347
|
-
playerResult: (
|
|
348
|
-
period:
|
|
349
|
-
player:
|
|
350
|
-
completedLearningElements:
|
|
351
|
-
visitedStoryElements:
|
|
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:
|
|
355
|
-
period:
|
|
354
|
+
previousResults: DB.Prisma.PrismaPromise<(DB.PlayerResult & {
|
|
355
|
+
period: DB.Period;
|
|
356
356
|
})[]>;
|
|
357
|
-
transactions:
|
|
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<(
|
|
363
|
-
level:
|
|
364
|
-
achievements: (
|
|
365
|
-
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:
|
|
379
|
+
reward: DB.Prisma.JsonValue;
|
|
380
380
|
createdAt: Date;
|
|
381
381
|
updatedAt: Date;
|
|
382
|
-
options:
|
|
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<
|
|
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<
|
|
408
|
-
declare function getPlayerResults(args: any, ctx: Context): Promise<(
|
|
409
|
-
period:
|
|
410
|
-
|
|
411
|
-
|
|
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<(
|
|
414
|
-
period:
|
|
415
|
-
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<
|
|
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 };
|