@gbl-uzh/platform 0.4.11 → 0.4.12

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
@@ -264,6 +264,7 @@ declare function addGamePeriod<TFacts>({ gameId, facts }: AddGamePeriodArgs<TFac
264
264
  id: number;
265
265
  index: number;
266
266
  facts: DB.Prisma.JsonValue;
267
+ countdownExpiresAt: Date | null;
267
268
  periodId: number;
268
269
  periodIx: number;
269
270
  gameId: number;
@@ -314,6 +315,7 @@ declare function addPeriodSegment<TFacts>({ gameId, periodIx, facts, learningEle
314
315
  id: number;
315
316
  index: number;
316
317
  facts: DB.Prisma.JsonValue;
318
+ countdownExpiresAt: Date | null;
317
319
  periodId: number;
318
320
  periodIx: number;
319
321
  gameId: number;
@@ -330,6 +332,7 @@ declare function activateNextPeriod({ gameId }: ActivateNextPeriodArgs, ctx: Con
330
332
  id: number;
331
333
  index: number;
332
334
  facts: DB.Prisma.JsonValue;
335
+ countdownExpiresAt: Date | null;
333
336
  periodId: number;
334
337
  periodIx: number;
335
338
  gameId: number;
@@ -377,6 +380,7 @@ declare function activateNextSegment({ gameId }: ActivateSegmentArgs, ctx: Conte
377
380
  id: number;
378
381
  index: number;
379
382
  facts: DB.Prisma.JsonValue;
383
+ countdownExpiresAt: Date | null;
380
384
  periodId: number;
381
385
  periodIx: number;
382
386
  gameId: number;
@@ -441,6 +445,7 @@ declare function activateNextSegment({ gameId }: ActivateSegmentArgs, ctx: Conte
441
445
  id: number;
442
446
  index: number;
443
447
  facts: DB.Prisma.JsonValue;
448
+ countdownExpiresAt: Date | null;
444
449
  periodId: number;
445
450
  periodIx: number;
446
451
  gameId: number;
@@ -453,6 +458,7 @@ declare function activateNextSegment({ gameId }: ActivateSegmentArgs, ctx: Conte
453
458
  id: number;
454
459
  index: number;
455
460
  facts: DB.Prisma.JsonValue;
461
+ countdownExpiresAt: Date | null;
456
462
  periodId: number;
457
463
  periodIx: number;
458
464
  gameId: number;
@@ -521,6 +527,7 @@ declare function activateNextSegment({ gameId }: ActivateSegmentArgs, ctx: Conte
521
527
  id: number;
522
528
  index: number;
523
529
  facts: DB.Prisma.JsonValue;
530
+ countdownExpiresAt: Date | null;
524
531
  periodId: number;
525
532
  periodIx: number;
526
533
  gameId: number;
@@ -672,6 +679,7 @@ declare function getGame(args: any, ctx: Context$1): Promise<({
672
679
  id: number;
673
680
  index: number;
674
681
  facts: DB.Prisma.JsonValue;
682
+ countdownExpiresAt: Date | null;
675
683
  periodId: number;
676
684
  periodIx: number;
677
685
  gameId: number;
@@ -695,6 +703,7 @@ declare function getGame(args: any, ctx: Context$1): Promise<({
695
703
  id: number;
696
704
  index: number;
697
705
  facts: DB.Prisma.JsonValue;
706
+ countdownExpiresAt: Date | null;
698
707
  periodId: number;
699
708
  periodIx: number;
700
709
  gameId: number;
@@ -706,6 +715,7 @@ declare function getGame(args: any, ctx: Context$1): Promise<({
706
715
  id: number;
707
716
  index: number;
708
717
  facts: DB.Prisma.JsonValue;
718
+ countdownExpiresAt: Date | null;
709
719
  periodId: number;
710
720
  periodIx: number;
711
721
  gameId: number;
@@ -930,6 +940,7 @@ declare function getPlayerResult(args: GetPlayerResultArgs, ctx: Context): Promi
930
940
  id: number;
931
941
  index: number;
932
942
  facts: DB.Prisma.JsonValue;
943
+ countdownExpiresAt: Date | null;
933
944
  periodId: number;
934
945
  periodIx: number;
935
946
  gameId: number;
@@ -962,6 +973,7 @@ declare function getPlayerResult(args: GetPlayerResultArgs, ctx: Context): Promi
962
973
  id: number;
963
974
  index: number;
964
975
  facts: DB.Prisma.JsonValue;
976
+ countdownExpiresAt: Date | null;
965
977
  periodId: number;
966
978
  periodIx: number;
967
979
  gameId: number;
@@ -1006,6 +1018,7 @@ declare function getPlayerResult(args: GetPlayerResultArgs, ctx: Context): Promi
1006
1018
  id: number;
1007
1019
  index: number;
1008
1020
  facts: DB.Prisma.JsonValue;
1021
+ countdownExpiresAt: Date | null;
1009
1022
  periodId: number;
1010
1023
  periodIx: number;
1011
1024
  gameId: number;
@@ -1119,6 +1132,7 @@ declare function getPlayerResult(args: GetPlayerResultArgs, ctx: Context): Promi
1119
1132
  id: number;
1120
1133
  index: number;
1121
1134
  facts: DB.Prisma.JsonValue;
1135
+ countdownExpiresAt: Date | null;
1122
1136
  periodId: number;
1123
1137
  periodIx: number;
1124
1138
  gameId: number;
@@ -1326,6 +1340,7 @@ declare function getPlayerResults(args: any, ctx: Context): Promise<({
1326
1340
  id: number;
1327
1341
  index: number;
1328
1342
  facts: DB.Prisma.JsonValue;
1343
+ countdownExpiresAt: Date | null;
1329
1344
  periodId: number;
1330
1345
  periodIx: number;
1331
1346
  gameId: number;
@@ -1425,7 +1440,9 @@ declare function updateReadyState(args: any, ctx: Context): Promise<_prisma_clie
1425
1440
  createdAt: Date;
1426
1441
  updatedAt: Date;
1427
1442
  }, unknown> & {}>;
1443
+ declare function addCountdown(args: any, ctx: Context): Promise<true | null>;
1428
1444
 
1445
+ declare const PlayService_addCountdown: typeof addCountdown;
1429
1446
  declare const PlayService_attemptLearningElement: typeof attemptLearningElement;
1430
1447
  declare const PlayService_getLearningElement: typeof getLearningElement;
1431
1448
  declare const PlayService_getPastResults: typeof getPastResults;
@@ -1439,6 +1456,7 @@ declare const PlayService_saveDecisions: typeof saveDecisions;
1439
1456
  declare const PlayService_updateReadyState: typeof updateReadyState;
1440
1457
  declare namespace PlayService {
1441
1458
  export {
1459
+ PlayService_addCountdown as addCountdown,
1442
1460
  PlayService_attemptLearningElement as attemptLearningElement,
1443
1461
  PlayService_getLearningElement as getLearningElement,
1444
1462
  PlayService_getPastResults as getPastResults,
package/dist/index.js CHANGED
@@ -1499,6 +1499,7 @@ function computeSegmentEndResults(game, ctx, { reducers }) {
1499
1499
  // src/services/PlayService.ts
1500
1500
  var PlayService_exports = {};
1501
1501
  __export(PlayService_exports, {
1502
+ addCountdown: () => addCountdown,
1502
1503
  attemptLearningElement: () => attemptLearningElement,
1503
1504
  getLearningElement: () => getLearningElement,
1504
1505
  getPastResults: () => getPastResults,
@@ -1974,6 +1975,29 @@ async function updateReadyState(args, ctx) {
1974
1975
  }
1975
1976
  });
1976
1977
  }
1978
+ async function addCountdown(args, ctx) {
1979
+ const currentGame = await ctx.prisma.game.findUnique({
1980
+ where: { id: args.gameId },
1981
+ include: {
1982
+ activePeriod: {
1983
+ include: {
1984
+ activeSegment: true
1985
+ }
1986
+ }
1987
+ }
1988
+ });
1989
+ if (!currentGame?.activePeriod?.activeSegment)
1990
+ return null;
1991
+ await ctx.prisma.periodSegment.update({
1992
+ where: {
1993
+ id: currentGame.activePeriod.activeSegment.id
1994
+ },
1995
+ data: {
1996
+ countdownExpiresAt: new Date(Date.now() + args.seconds * 1e3)
1997
+ }
1998
+ });
1999
+ return true;
2000
+ }
1977
2001
  // Annotate the CommonJS export names for ESM import in node:
1978
2002
  0 && (module.exports = {
1979
2003
  AccountService,
package/dist/nexus.js CHANGED
@@ -370,6 +370,9 @@ var PeriodSegment = (0, import_nexus5.objectType)({
370
370
  t.nonNull.id("id");
371
371
  t.nonNull.int("index");
372
372
  t.nonNull.int("periodIx");
373
+ t.field("countdownExpiresAt", {
374
+ type: "DateTime"
375
+ });
373
376
  t.nonNull.list.nonNull.field("actions", {
374
377
  type: PlayerAction
375
378
  });
@@ -2239,6 +2242,29 @@ async function updateReadyState(args, ctx) {
2239
2242
  }
2240
2243
  });
2241
2244
  }
2245
+ async function addCountdown(args, ctx) {
2246
+ const currentGame = await ctx.prisma.game.findUnique({
2247
+ where: { id: args.gameId },
2248
+ include: {
2249
+ activePeriod: {
2250
+ include: {
2251
+ activeSegment: true
2252
+ }
2253
+ }
2254
+ }
2255
+ });
2256
+ if (!currentGame?.activePeriod?.activeSegment)
2257
+ return null;
2258
+ await ctx.prisma.periodSegment.update({
2259
+ where: {
2260
+ id: currentGame.activePeriod.activeSegment.id
2261
+ },
2262
+ data: {
2263
+ countdownExpiresAt: new Date(Date.now() + args.seconds * 1e3)
2264
+ }
2265
+ });
2266
+ return true;
2267
+ }
2242
2268
 
2243
2269
  // src/types/Mutation.ts
2244
2270
  var defaultReducers = {};
@@ -2423,6 +2449,15 @@ function generateBaseMutations({
2423
2449
  );
2424
2450
  }
2425
2451
  });
2452
+ t.boolean("addCountdown", {
2453
+ args: {
2454
+ gameId: (0, import_nexus6.nonNull)((0, import_nexus6.intArg)()),
2455
+ seconds: (0, import_nexus6.nonNull)((0, import_nexus6.intArg)())
2456
+ },
2457
+ async resolve(_, args, ctx) {
2458
+ return addCountdown(args, ctx);
2459
+ }
2460
+ });
2426
2461
  }
2427
2462
  });
2428
2463
  }
@@ -3,6 +3,8 @@ fragment SegmentData on PeriodSegment {
3
3
 
4
4
  index
5
5
 
6
+ countdownExpiresAt
7
+
6
8
  facts
7
9
 
8
10
  learningElements {
@@ -0,0 +1,3 @@
1
+ mutation AddCountdown($gameId: Int!, $seconds: Int!) {
2
+ addCountdown(gameId: $gameId, seconds: $seconds)
3
+ }
@@ -8,6 +8,10 @@ query Game($id: Int) {
8
8
  activePeriod {
9
9
  id
10
10
  activeSegmentIx
11
+ activeSegment {
12
+ id
13
+ countdownExpiresAt
14
+ }
11
15
  segments {
12
16
  id
13
17
  }
@@ -28,6 +28,7 @@ query Result {
28
28
  id
29
29
  index
30
30
  facts
31
+ countdownExpiresAt
31
32
  learningElements {
32
33
  id
33
34
  title
@@ -151,6 +151,8 @@ model PeriodSegment {
151
151
 
152
152
  facts Json
153
153
 
154
+ countdownExpiresAt DateTime?
155
+
154
156
  actions PlayerAction[]
155
157
  results PlayerResult[]
156
158
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gbl-uzh/platform",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "license": "LGPL-3.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",