@gbl-uzh/platform 0.4.11 → 0.4.13

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.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
@@ -6,7 +6,7 @@ datasource db {
6
6
 
7
7
  generator client {
8
8
  provider = "prisma-client-js"
9
- previewFeatures = ["fullTextSearch", "fullTextIndex", "postgresqlExtensions", "fieldReference", "extendedWhereUnique"]
9
+ previewFeatures = ["fullTextSearch", "fullTextIndex", "postgresqlExtensions"]
10
10
  }
11
11
 
12
12
  model Account {
@@ -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,59 +1,59 @@
1
1
  {
2
2
  "name": "@gbl-uzh/platform",
3
- "version": "0.4.11",
3
+ "version": "0.4.13",
4
4
  "license": "LGPL-3.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
8
8
  "dist"
9
9
  ],
10
- "scripts": {
11
- "prebuild": "npm run generate",
12
- "build": "npm-run-all build:nexus build:ts",
13
- "build:nexus": "ts-node --esm --transpile-only src/nexus.ts",
14
- "build:ts": "cross-env NODE_ENV=production tsup",
15
- "dev": "cross-env NODE_ENV=development tsup --watch",
16
- "generate": "prisma generate"
17
- },
18
- "engines": {
19
- "node": ">=18"
10
+ "dependencies": {
11
+ "nanoid": "3.3.6",
12
+ "random-js": "2.1.0",
13
+ "winston": "3.9.0"
20
14
  },
21
15
  "devDependencies": {
22
- "@tsconfig/node18": "1.0.1",
16
+ "@tsconfig/node18": "18.2.1",
23
17
  "@tsconfig/recommended": "1.0.2",
24
18
  "@types/jest": "^29.2.2",
25
19
  "@types/node": "^18.11.9",
26
20
  "cross-env": "7.0.3",
27
21
  "fs-extra": "11.1.1",
28
- "jest": "29.5.0",
22
+ "jest": "29.6.4",
29
23
  "npm-run-all": "4.1.5",
30
- "ts-jest": "29.1.0",
24
+ "ts-jest": "29.1.1",
31
25
  "ts-node": "10.9.1",
32
26
  "tsup": "7.1.0",
33
- "typescript": "5.1.6"
27
+ "typescript": "5.2.2"
34
28
  },
35
29
  "peerDependencies": {
36
- "@apollo/client": "^3.7.0",
37
- "@prisma/client": "^4.16.1",
38
- "@uzh-bf/design-system": "^1.0.0",
39
- "graphql": "^16.6.0",
40
- "graphql-scalars": "^1.19.0",
41
- "graphql-sse": "^2.0.0",
42
- "graphql-yoga": "^4.0.0",
43
- "jsonwebtoken": "^9.0.0",
44
- "next": "^13.0.0",
45
- "next-auth": "^4.0.0",
46
- "nexus": "^1.3.0",
47
- "nookies": "^2.5.2",
48
- "prisma": "^4.16.1",
49
- "ramda": "^0.29.0",
50
- "react": "^18.0.0",
51
- "yup": "^1.0.0"
30
+ "@apollo/client": "3.8.2",
31
+ "@prisma/client": "5.2.0",
32
+ "@uzh-bf/design-system": "1.8.0",
33
+ "graphql": "16.8.0",
34
+ "graphql-scalars": "1.19.0",
35
+ "graphql-sse": "2.2.3",
36
+ "graphql-yoga": "4.0.4",
37
+ "jsonwebtoken": "9.0.2",
38
+ "next": "13.4.19",
39
+ "next-auth": "4.23.1",
40
+ "nexus": "1.3.0",
41
+ "nookies": "2.5.2",
42
+ "prisma": "5.2.0",
43
+ "ramda": "0.29.0",
44
+ "react": "18.2.0",
45
+ "yup": "1.2.0"
52
46
  },
53
- "dependencies": {
54
- "nanoid": "3.3.6",
55
- "random-js": "2.1.0",
56
- "winston": "3.9.0"
47
+ "scripts": {
48
+ "build": "npm-run-all build:nexus build:ts",
49
+ "build:nexus": "ts-node --esm --transpile-only src/nexus.ts",
50
+ "build:ts": "cross-env NODE_ENV=production tsup",
51
+ "dev": "cross-env NODE_ENV=development tsup --watch",
52
+ "generate": "prisma generate",
53
+ "prebuild": "npm run generate"
54
+ },
55
+ "engines": {
56
+ "node": ">=18"
57
57
  },
58
58
  "volta": {
59
59
  "extends": "../../package.json"
@@ -1,166 +0,0 @@
1
- type Maybe<T> = T | null;
2
- /** All built-in and custom scalars, mapped to their actual values */
3
- type Scalars = {
4
- ID: string;
5
- String: string;
6
- Boolean: boolean;
7
- Int: number;
8
- Float: number;
9
- /** A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar. */
10
- DateTime: any;
11
- /** The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */
12
- JSONObject: any;
13
- };
14
- type Achievement = {
15
- __typename?: 'Achievement';
16
- description: Scalars['String'];
17
- id: Scalars['ID'];
18
- image?: Maybe<Scalars['String']>;
19
- name: Scalars['String'];
20
- reward?: Maybe<Scalars['JSONObject']>;
21
- when: AchievementFrequency;
22
- };
23
- declare enum AchievementFrequency {
24
- Each = "EACH",
25
- First = "FIRST"
26
- }
27
- type AchievementInstance = {
28
- __typename?: 'AchievementInstance';
29
- achievement: Achievement;
30
- count: Scalars['Int'];
31
- id: Scalars['Int'];
32
- };
33
- type Game = {
34
- __typename?: 'Game';
35
- activePeriod?: Maybe<Period>;
36
- activePeriodIx?: Maybe<Scalars['Int']>;
37
- id: Scalars['ID'];
38
- name: Scalars['String'];
39
- periods: Array<Period>;
40
- players: Array<Player>;
41
- segments: Array<PeriodSegment>;
42
- status: GameStatus;
43
- };
44
- declare enum GameStatus {
45
- Completed = "COMPLETED",
46
- Consolidation = "CONSOLIDATION",
47
- Paused = "PAUSED",
48
- Preparation = "PREPARATION",
49
- Results = "RESULTS",
50
- Running = "RUNNING",
51
- Scheduled = "SCHEDULED"
52
- }
53
- type LearningAnswerOption = {
54
- __typename?: 'LearningAnswerOption';
55
- content: Scalars['String'];
56
- correct: Scalars['Boolean'];
57
- id: Scalars['ID'];
58
- };
59
- type LearningElement = {
60
- __typename?: 'LearningElement';
61
- feedback?: Maybe<Scalars['String']>;
62
- id: Scalars['ID'];
63
- motivation?: Maybe<Scalars['String']>;
64
- options: Array<LearningAnswerOption>;
65
- question: Scalars['String'];
66
- reward?: Maybe<Scalars['JSONObject']>;
67
- title: Scalars['String'];
68
- };
69
- type Period = {
70
- __typename?: 'Period';
71
- actions: Array<PlayerAction>;
72
- activeSegment?: Maybe<PeriodSegment>;
73
- activeSegmentIx?: Maybe<Scalars['Int']>;
74
- facts: Scalars['JSONObject'];
75
- id: Scalars['ID'];
76
- index: Scalars['Int'];
77
- results: Array<PlayerResult>;
78
- segments: Array<PeriodSegment>;
79
- };
80
- type PeriodSegment = {
81
- __typename?: 'PeriodSegment';
82
- actions: Array<PlayerAction>;
83
- facts: Scalars['JSONObject'];
84
- id: Scalars['ID'];
85
- index: Scalars['Int'];
86
- learningElements: Array<LearningElement>;
87
- periodIx: Scalars['Int'];
88
- results: Array<PlayerResult>;
89
- storyElements: Array<StoryElement>;
90
- };
91
- type Player = {
92
- __typename?: 'Player';
93
- achievementIds: Array<Scalars['String']>;
94
- achievementKeys: Array<Scalars['String']>;
95
- achievements: Array<AchievementInstance>;
96
- avatar: Scalars['String'];
97
- color: Scalars['String'];
98
- completedLearningElementIds: Array<Scalars['Int']>;
99
- completedLearningElements: Array<LearningElement>;
100
- experience: Scalars['Int'];
101
- experienceToNext: Scalars['Int'];
102
- facts: Scalars['JSONObject'];
103
- id: Scalars['ID'];
104
- isReady: Scalars['Boolean'];
105
- level: PlayerLevel;
106
- levelIx: Scalars['Int'];
107
- location: Scalars['String'];
108
- name: Scalars['String'];
109
- role: Scalars['String'];
110
- token: Scalars['String'];
111
- tutorialCompleted: Scalars['Boolean'];
112
- visitedStoryElementIds: Array<Scalars['Int']>;
113
- visitedStoryElements: Array<StoryElement>;
114
- };
115
- type PlayerAction = {
116
- __typename?: 'PlayerAction';
117
- facts?: Maybe<Scalars['JSONObject']>;
118
- id: Scalars['ID'];
119
- period: Period;
120
- periodIx: Scalars['Int'];
121
- player: Player;
122
- segment?: Maybe<PeriodSegment>;
123
- segmentIx?: Maybe<Scalars['Int']>;
124
- type: Scalars['String'];
125
- };
126
- declare enum PlayerDecisionType {
127
- Consolidation = "CONSOLIDATION",
128
- Preparation = "PREPARATION"
129
- }
130
- type PlayerLevel = {
131
- __typename?: 'PlayerLevel';
132
- description: Scalars['String'];
133
- id: Scalars['ID'];
134
- index: Scalars['Int'];
135
- requiredXP: Scalars['Int'];
136
- };
137
- type PlayerResult = {
138
- __typename?: 'PlayerResult';
139
- facts?: Maybe<Scalars['JSONObject']>;
140
- id: Scalars['ID'];
141
- period: Period;
142
- player: Player;
143
- segment?: Maybe<PeriodSegment>;
144
- type?: Maybe<PlayerResultType>;
145
- };
146
- declare enum PlayerResultType {
147
- PeriodEnd = "PERIOD_END",
148
- PeriodStart = "PERIOD_START",
149
- SegmentEnd = "SEGMENT_END",
150
- SegmentStart = "SEGMENT_START"
151
- }
152
- type StoryElement = {
153
- __typename?: 'StoryElement';
154
- content?: Maybe<Scalars['String']>;
155
- contentRole?: Maybe<Scalars['String']>;
156
- id: Scalars['ID'];
157
- reward?: Maybe<Scalars['JSONObject']>;
158
- title: Scalars['String'];
159
- type: StoryElementType;
160
- };
161
- declare enum StoryElementType {
162
- Generic = "GENERIC",
163
- RoleBased = "ROLE_BASED"
164
- }
165
-
166
- export { Game as G, PlayerDecisionType as P, Period as a };