@gbl-uzh/platform 0.2.10 → 0.2.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/generated/ops.d.ts +129 -129
- package/dist/index.d.ts +6 -6
- package/dist/index.js +17 -24
- package/dist/lib/apollo.js +4 -4
- package/dist/nexus.d.ts +4 -40
- package/dist/nexus.js +76 -132
- package/dist/schema.prisma +2 -2
- package/package.json +14 -15
package/dist/nexus.js
CHANGED
|
@@ -37,11 +37,7 @@ __export(nexus_exports, {
|
|
|
37
37
|
LearningElementState: () => LearningElementState,
|
|
38
38
|
Mutation: () => Mutation,
|
|
39
39
|
Period: () => Period,
|
|
40
|
-
PeriodFactsInput: () => PeriodFactsInput,
|
|
41
|
-
PeriodFactsSchema: () => PeriodFactsSchema,
|
|
42
40
|
PeriodSegment: () => PeriodSegment,
|
|
43
|
-
PeriodSegmentFactsInput: () => PeriodSegmentFactsInput,
|
|
44
|
-
PeriodSegmentFactsSchema: () => PeriodSegmentFactsSchema,
|
|
45
41
|
Player: () => Player,
|
|
46
42
|
PlayerAction: () => PlayerAction,
|
|
47
43
|
PlayerDecision: () => PlayerDecision,
|
|
@@ -60,7 +56,7 @@ __export(nexus_exports, {
|
|
|
60
56
|
module.exports = __toCommonJS(nexus_exports);
|
|
61
57
|
var DB5 = __toESM(require("@prisma/client"));
|
|
62
58
|
var import_graphql_scalars = require("graphql-scalars");
|
|
63
|
-
var
|
|
59
|
+
var import_nexus10 = require("nexus");
|
|
64
60
|
|
|
65
61
|
// src/types/Game.ts
|
|
66
62
|
var DB4 = __toESM(require("@prisma/client"));
|
|
@@ -156,10 +152,10 @@ var PlayerState = (0, import_nexus3.objectType)({
|
|
|
156
152
|
t.field("currentGame", {
|
|
157
153
|
type: Game
|
|
158
154
|
});
|
|
159
|
-
t.list.field("previousResults", {
|
|
155
|
+
t.list.nonNull.field("previousResults", {
|
|
160
156
|
type: PlayerResult
|
|
161
157
|
});
|
|
162
|
-
t.list.field("transactions", {
|
|
158
|
+
t.list.nonNull.field("transactions", {
|
|
163
159
|
type: PlayerAction
|
|
164
160
|
});
|
|
165
161
|
}
|
|
@@ -175,7 +171,7 @@ var Player = (0, import_nexus3.objectType)({
|
|
|
175
171
|
t.nonNull.string("color");
|
|
176
172
|
t.nonNull.string("token");
|
|
177
173
|
t.nonNull.boolean("tutorialCompleted");
|
|
178
|
-
t.
|
|
174
|
+
t.string("role");
|
|
179
175
|
t.nonNull.int("experience");
|
|
180
176
|
t.nonNull.int("experienceToNext");
|
|
181
177
|
t.nonNull.field("facts", {
|
|
@@ -336,9 +332,6 @@ var Game = (0, import_nexus5.objectType)({
|
|
|
336
332
|
t.nonNull.list.nonNull.field("periods", {
|
|
337
333
|
type: Period
|
|
338
334
|
});
|
|
339
|
-
t.nonNull.list.nonNull.field("segments", {
|
|
340
|
-
type: PeriodSegment
|
|
341
|
-
});
|
|
342
335
|
}
|
|
343
336
|
});
|
|
344
337
|
var Period = (0, import_nexus5.objectType)({
|
|
@@ -389,7 +382,7 @@ var PeriodSegment = (0, import_nexus5.objectType)({
|
|
|
389
382
|
});
|
|
390
383
|
|
|
391
384
|
// src/types/Mutation.ts
|
|
392
|
-
var
|
|
385
|
+
var import_nexus6 = require("nexus");
|
|
393
386
|
|
|
394
387
|
// src/generated/ops.ts
|
|
395
388
|
var GameDataFragmentDoc = { "kind": "Document", "definitions": [{ "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "GameData" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "Game" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "status" } }, { "kind": "Field", "name": { "kind": "Name", "value": "name" } }, { "kind": "Field", "name": { "kind": "Name", "value": "activePeriodIx" } }] } }] };
|
|
@@ -542,12 +535,10 @@ function prepareAchievementData({
|
|
|
542
535
|
};
|
|
543
536
|
}
|
|
544
537
|
async function receiveEvent(event, definedEvents, definedLevels, prisma) {
|
|
545
|
-
var _a;
|
|
546
538
|
const matchingEvent = definedEvents.find((item) => item.id === event.type);
|
|
547
|
-
if (matchingEvent &&
|
|
539
|
+
if (matchingEvent && matchingEvent.achievements?.length > 0) {
|
|
548
540
|
const awardedAchievements = await matchingEvent.achievements.reduce(
|
|
549
541
|
async (acc, achievement) => {
|
|
550
|
-
var _a2;
|
|
551
542
|
if (achievement.when === "FIRST" /* First */ && event.ctx.achievements.includes(achievement.id)) {
|
|
552
543
|
return acc;
|
|
553
544
|
}
|
|
@@ -597,7 +588,7 @@ async function receiveEvent(event, definedEvents, definedLevels, prisma) {
|
|
|
597
588
|
achievementKeys: [...acc.achievementKeys, achievement.id],
|
|
598
589
|
rewards: {
|
|
599
590
|
...acc.rewards,
|
|
600
|
-
xp: (acc.rewards.xp ?? 0) + (
|
|
591
|
+
xp: (acc.rewards.xp ?? 0) + (achievement.reward?.xp ?? 0)
|
|
601
592
|
}
|
|
602
593
|
};
|
|
603
594
|
},
|
|
@@ -732,7 +723,6 @@ async function createGame({ name, playerCount }, ctx, { roleAssigner }) {
|
|
|
732
723
|
});
|
|
733
724
|
}
|
|
734
725
|
async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
735
|
-
var _a, _b, _c, _d;
|
|
736
726
|
const validatedFacts = schema.validateSync(facts);
|
|
737
727
|
const game = await ctx.prisma.game.findUnique({
|
|
738
728
|
where: {
|
|
@@ -757,13 +747,13 @@ async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
|
757
747
|
});
|
|
758
748
|
if (!game)
|
|
759
749
|
return null;
|
|
760
|
-
const index =
|
|
750
|
+
const index = game.periods[0]?.index + 1 || 0;
|
|
761
751
|
const { result: initializedFacts } = reducers.Period.apply(validatedFacts, {
|
|
762
752
|
type: reducers.Period.ActionTypes.PERIOD_INITIALIZE,
|
|
763
753
|
payload: {
|
|
764
754
|
periodFacts: validatedFacts,
|
|
765
|
-
previousPeriodFacts:
|
|
766
|
-
previousSegmentFacts:
|
|
755
|
+
previousPeriodFacts: game.periods[0]?.facts,
|
|
756
|
+
previousSegmentFacts: game.periods[0]?.segments[0]?.facts,
|
|
767
757
|
periodIx: index
|
|
768
758
|
}
|
|
769
759
|
});
|
|
@@ -811,7 +801,6 @@ async function addPeriodSegment({
|
|
|
811
801
|
learningElements,
|
|
812
802
|
storyElements
|
|
813
803
|
}, ctx, { schema, reducers }) {
|
|
814
|
-
var _a, _b;
|
|
815
804
|
const validatedFacts = schema.validateSync(facts);
|
|
816
805
|
const period = await ctx.prisma.period.findUnique({
|
|
817
806
|
where: {
|
|
@@ -831,12 +820,12 @@ async function addPeriodSegment({
|
|
|
831
820
|
});
|
|
832
821
|
if (!period)
|
|
833
822
|
return null;
|
|
834
|
-
const index =
|
|
823
|
+
const index = period.segments[0]?.index + 1 || 0;
|
|
835
824
|
const { result: initializedFacts } = reducers.Segment.apply(validatedFacts, {
|
|
836
825
|
type: reducers.Segment.ActionTypes.SEGMENT_INITIALIZE,
|
|
837
826
|
payload: {
|
|
838
827
|
periodFacts: period.facts,
|
|
839
|
-
previousSegmentFacts:
|
|
828
|
+
previousSegmentFacts: period.segments[0]?.facts,
|
|
840
829
|
segmentIx: index,
|
|
841
830
|
segmentCount: 4,
|
|
842
831
|
periodIx
|
|
@@ -899,7 +888,6 @@ async function addPeriodSegment({
|
|
|
899
888
|
});
|
|
900
889
|
}
|
|
901
890
|
async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
902
|
-
var _a, _b, _c, _d, _e;
|
|
903
891
|
const game = await ctx.prisma.game.findUnique({
|
|
904
892
|
where: {
|
|
905
893
|
id: gameId
|
|
@@ -945,7 +933,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
945
933
|
if (!game)
|
|
946
934
|
return null;
|
|
947
935
|
const currentPeriodIx = game.activePeriodIx;
|
|
948
|
-
const currentSegmentIx =
|
|
936
|
+
const currentSegmentIx = game.activePeriod?.activeSegmentIx;
|
|
949
937
|
const nextPeriodIx = currentPeriodIx + 1;
|
|
950
938
|
switch (game.status) {
|
|
951
939
|
case "SCHEDULED" /* Scheduled */: {
|
|
@@ -955,7 +943,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
955
943
|
players: game.players,
|
|
956
944
|
activePeriodIx: currentPeriodIx,
|
|
957
945
|
gameId: game.id,
|
|
958
|
-
periodFacts:
|
|
946
|
+
periodFacts: game.periods?.[0].facts
|
|
959
947
|
},
|
|
960
948
|
ctx,
|
|
961
949
|
{ reducers }
|
|
@@ -996,7 +984,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
996
984
|
return result;
|
|
997
985
|
}
|
|
998
986
|
case "RUNNING" /* Running */: {
|
|
999
|
-
if (!
|
|
987
|
+
if (!game.activePeriod?.activeSegment || !currentSegmentIx)
|
|
1000
988
|
return null;
|
|
1001
989
|
const { results, extras } = computeSegmentEndResults(game, ctx, {
|
|
1002
990
|
reducers
|
|
@@ -1057,7 +1045,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1057
1045
|
return result;
|
|
1058
1046
|
}
|
|
1059
1047
|
case "CONSOLIDATION" /* Consolidation */: {
|
|
1060
|
-
if (!
|
|
1048
|
+
if (!game.activePeriod?.activeSegment)
|
|
1061
1049
|
return null;
|
|
1062
1050
|
const { results, extras, promises } = await computePeriodEndResults(
|
|
1063
1051
|
{
|
|
@@ -1111,7 +1099,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1111
1099
|
return result;
|
|
1112
1100
|
}
|
|
1113
1101
|
case "RESULTS" /* Results */: {
|
|
1114
|
-
if (!
|
|
1102
|
+
if (!game.activePeriod?.nextPeriod) {
|
|
1115
1103
|
return null;
|
|
1116
1104
|
}
|
|
1117
1105
|
const { results, extras } = computePeriodStartResults(
|
|
@@ -1156,7 +1144,6 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1156
1144
|
}
|
|
1157
1145
|
}
|
|
1158
1146
|
async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
1159
|
-
var _a, _b;
|
|
1160
1147
|
const game = await ctx.prisma.game.findUnique({
|
|
1161
1148
|
where: {
|
|
1162
1149
|
id: gameId
|
|
@@ -1186,7 +1173,7 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1186
1173
|
}
|
|
1187
1174
|
}
|
|
1188
1175
|
});
|
|
1189
|
-
if (!
|
|
1176
|
+
if (!game?.activePeriod)
|
|
1190
1177
|
return null;
|
|
1191
1178
|
const currentPeriodIx = game.activePeriodIx;
|
|
1192
1179
|
const currentSegmentIx = game.activePeriod.activeSegmentIx;
|
|
@@ -1259,7 +1246,7 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1259
1246
|
return result;
|
|
1260
1247
|
}
|
|
1261
1248
|
case "RUNNING" /* Running */: {
|
|
1262
|
-
if (!
|
|
1249
|
+
if (!game.activePeriod?.activeSegment?.nextSegment) {
|
|
1263
1250
|
return null;
|
|
1264
1251
|
}
|
|
1265
1252
|
const { results, extras } = computeSegmentEndResults(game, ctx, {
|
|
@@ -1762,7 +1749,6 @@ function computeSegmentEndResults(game, ctx, { reducers }) {
|
|
|
1762
1749
|
|
|
1763
1750
|
// src/services/PlayService.ts
|
|
1764
1751
|
async function performAction(args, ctx, { reducers }) {
|
|
1765
|
-
var _a;
|
|
1766
1752
|
const periodIx_segmentIx_playerId_type = {
|
|
1767
1753
|
periodIx: args.periodIx,
|
|
1768
1754
|
segmentIx: args.segmentIx,
|
|
@@ -1789,7 +1775,7 @@ async function performAction(args, ctx, { reducers }) {
|
|
|
1789
1775
|
type: args.actionType,
|
|
1790
1776
|
payload: {
|
|
1791
1777
|
playerArgs: args.facts,
|
|
1792
|
-
segmentFacts:
|
|
1778
|
+
segmentFacts: previousResult.segment?.facts,
|
|
1793
1779
|
periodFacts: previousResult.period.facts
|
|
1794
1780
|
}
|
|
1795
1781
|
});
|
|
@@ -1874,7 +1860,7 @@ async function saveDecisions(args, ctx) {
|
|
|
1874
1860
|
}
|
|
1875
1861
|
}
|
|
1876
1862
|
});
|
|
1877
|
-
if (!
|
|
1863
|
+
if (!game?.activePeriod)
|
|
1878
1864
|
return null;
|
|
1879
1865
|
if (args.decisionType !== game.status) {
|
|
1880
1866
|
throw new Error("INVALID_DECISION");
|
|
@@ -1951,7 +1937,7 @@ async function getPlayerResult(args, ctx) {
|
|
|
1951
1937
|
}
|
|
1952
1938
|
}
|
|
1953
1939
|
});
|
|
1954
|
-
if (!
|
|
1940
|
+
if (!currentGame?.activePeriod)
|
|
1955
1941
|
return null;
|
|
1956
1942
|
const previousResults = ctx.prisma.playerResult.findMany({
|
|
1957
1943
|
where: {
|
|
@@ -2198,80 +2184,42 @@ async function updateReadyState(args, ctx) {
|
|
|
2198
2184
|
});
|
|
2199
2185
|
}
|
|
2200
2186
|
|
|
2201
|
-
// src/types/Period.ts
|
|
2202
|
-
var import_nexus6 = require("nexus");
|
|
2203
|
-
var yup2 = __toESM(require("yup"));
|
|
2204
|
-
var PeriodFactsSchema = yup2.object({
|
|
2205
|
-
spotTradingEnabled: yup2.boolean().default(true),
|
|
2206
|
-
futuresTradingEnabled: yup2.boolean().default(false),
|
|
2207
|
-
optionsTradingEnabled: yup2.boolean().default(false),
|
|
2208
|
-
interestRate: yup2.number().default(0.01),
|
|
2209
|
-
convenienceYield: yup2.number().default(8e-3),
|
|
2210
|
-
storageCostPerItem: yup2.number().default(50),
|
|
2211
|
-
initialSpotPrice: yup2.number(),
|
|
2212
|
-
randomSeed: yup2.number(),
|
|
2213
|
-
trendE: yup2.number().default(5e-3),
|
|
2214
|
-
trendGap: yup2.number().default(0.02)
|
|
2215
|
-
});
|
|
2216
|
-
var PeriodFactsInput = (0, import_nexus6.inputObjectType)({
|
|
2217
|
-
name: "PeriodFactsInput",
|
|
2218
|
-
definition(t) {
|
|
2219
|
-
t.boolean("spotTradingEnabled");
|
|
2220
|
-
t.boolean("futuresTradingEnabled");
|
|
2221
|
-
t.boolean("optionsTradingEnabled");
|
|
2222
|
-
t.float("interestRate");
|
|
2223
|
-
t.float("convenienceYield");
|
|
2224
|
-
t.int("storageCostPerItem");
|
|
2225
|
-
t.int("initialSpotPrice");
|
|
2226
|
-
t.int("randomSeed");
|
|
2227
|
-
t.float("trendE");
|
|
2228
|
-
t.float("trendGap");
|
|
2229
|
-
}
|
|
2230
|
-
});
|
|
2231
|
-
var PeriodSegmentFactsSchema = yup2.object({
|
|
2232
|
-
trendE: yup2.number(),
|
|
2233
|
-
trendGap: yup2.number()
|
|
2234
|
-
});
|
|
2235
|
-
var PeriodSegmentFactsInput = (0, import_nexus6.inputObjectType)({
|
|
2236
|
-
name: "PeriodSegmentFactsInput",
|
|
2237
|
-
definition(t) {
|
|
2238
|
-
t.float("trendE");
|
|
2239
|
-
t.float("trendGap");
|
|
2240
|
-
}
|
|
2241
|
-
});
|
|
2242
|
-
|
|
2243
2187
|
// src/types/Mutation.ts
|
|
2244
2188
|
var defaultReducers = {};
|
|
2189
|
+
var defaultSchemas = {};
|
|
2190
|
+
var defaultInputTypes = {};
|
|
2245
2191
|
function generateBaseMutations({
|
|
2246
2192
|
reducers = defaultReducers,
|
|
2247
|
-
roleAssigner = () => "UNSET"
|
|
2193
|
+
roleAssigner = () => "UNSET",
|
|
2194
|
+
schemas = defaultSchemas,
|
|
2195
|
+
inputTypes = defaultInputTypes
|
|
2248
2196
|
} = {}) {
|
|
2249
|
-
return (0,
|
|
2197
|
+
return (0, import_nexus6.objectType)({
|
|
2250
2198
|
name: "Mutation",
|
|
2251
2199
|
definition(t) {
|
|
2252
2200
|
t.field("updateReadyState", {
|
|
2253
2201
|
type: Player,
|
|
2254
2202
|
args: {
|
|
2255
|
-
isReady: (0,
|
|
2203
|
+
isReady: (0, import_nexus6.nonNull)((0, import_nexus6.booleanArg)())
|
|
2256
2204
|
},
|
|
2257
2205
|
async resolve(_, args, ctx) {
|
|
2258
2206
|
return updateReadyState(args, ctx);
|
|
2259
2207
|
}
|
|
2260
2208
|
});
|
|
2261
|
-
t.
|
|
2209
|
+
t.field("loginAsTeam", {
|
|
2262
2210
|
type: Player,
|
|
2263
2211
|
args: {
|
|
2264
|
-
token: (0,
|
|
2212
|
+
token: (0, import_nexus6.nonNull)((0, import_nexus6.stringArg)())
|
|
2265
2213
|
},
|
|
2266
2214
|
async resolve(_, args, ctx) {
|
|
2267
2215
|
return loginAsTeam(args, ctx);
|
|
2268
2216
|
}
|
|
2269
2217
|
});
|
|
2270
|
-
t.
|
|
2218
|
+
t.field("createGame", {
|
|
2271
2219
|
type: Game,
|
|
2272
2220
|
args: {
|
|
2273
|
-
name: (0,
|
|
2274
|
-
playerCount: (0,
|
|
2221
|
+
name: (0, import_nexus6.nonNull)((0, import_nexus6.stringArg)()),
|
|
2222
|
+
playerCount: (0, import_nexus6.nonNull)((0, import_nexus6.intArg)())
|
|
2275
2223
|
},
|
|
2276
2224
|
async resolve(_, args, ctx) {
|
|
2277
2225
|
return createGame(args, ctx, {
|
|
@@ -2279,35 +2227,35 @@ function generateBaseMutations({
|
|
|
2279
2227
|
});
|
|
2280
2228
|
}
|
|
2281
2229
|
});
|
|
2282
|
-
t.
|
|
2230
|
+
t.field("addGamePeriod", {
|
|
2283
2231
|
type: Period,
|
|
2284
2232
|
args: {
|
|
2285
|
-
gameId: (0,
|
|
2286
|
-
facts: (0,
|
|
2287
|
-
type: (0,
|
|
2233
|
+
gameId: (0, import_nexus6.nonNull)((0, import_nexus6.intArg)()),
|
|
2234
|
+
facts: (0, import_nexus6.arg)({
|
|
2235
|
+
type: (0, import_nexus6.nonNull)(inputTypes.PeriodFactsInput)
|
|
2288
2236
|
})
|
|
2289
2237
|
},
|
|
2290
2238
|
async resolve(_, args, ctx) {
|
|
2291
2239
|
return addGamePeriod(args, ctx, {
|
|
2292
|
-
schema: PeriodFactsSchema,
|
|
2240
|
+
schema: schemas.PeriodFactsSchema,
|
|
2293
2241
|
reducers
|
|
2294
2242
|
});
|
|
2295
2243
|
}
|
|
2296
2244
|
});
|
|
2297
|
-
t.
|
|
2245
|
+
t.field("addPeriodSegment", {
|
|
2298
2246
|
type: PeriodSegment,
|
|
2299
2247
|
args: {
|
|
2300
|
-
gameId: (0,
|
|
2301
|
-
periodIx: (0,
|
|
2302
|
-
facts: (0,
|
|
2303
|
-
type: (0,
|
|
2248
|
+
gameId: (0, import_nexus6.nonNull)((0, import_nexus6.intArg)()),
|
|
2249
|
+
periodIx: (0, import_nexus6.nonNull)((0, import_nexus6.intArg)()),
|
|
2250
|
+
facts: (0, import_nexus6.arg)({
|
|
2251
|
+
type: (0, import_nexus6.nonNull)(inputTypes.PeriodSegmentFactsInput)
|
|
2304
2252
|
}),
|
|
2305
|
-
storyElements: (0,
|
|
2306
|
-
learningElements: (0,
|
|
2253
|
+
storyElements: (0, import_nexus6.list)((0, import_nexus6.stringArg)()),
|
|
2254
|
+
learningElements: (0, import_nexus6.list)((0, import_nexus6.stringArg)())
|
|
2307
2255
|
},
|
|
2308
2256
|
async resolve(_, args, ctx) {
|
|
2309
2257
|
return addPeriodSegment(args, ctx, {
|
|
2310
|
-
schema: PeriodSegmentFactsSchema,
|
|
2258
|
+
schema: schemas.PeriodSegmentFactsSchema,
|
|
2311
2259
|
reducers
|
|
2312
2260
|
});
|
|
2313
2261
|
}
|
|
@@ -2315,7 +2263,7 @@ function generateBaseMutations({
|
|
|
2315
2263
|
t.field("activateNextPeriod", {
|
|
2316
2264
|
type: Game,
|
|
2317
2265
|
args: {
|
|
2318
|
-
gameId: (0,
|
|
2266
|
+
gameId: (0, import_nexus6.nonNull)((0, import_nexus6.intArg)())
|
|
2319
2267
|
},
|
|
2320
2268
|
async resolve(_, args, ctx) {
|
|
2321
2269
|
const results = await activateNextPeriod(args, ctx, {
|
|
@@ -2329,7 +2277,7 @@ function generateBaseMutations({
|
|
|
2329
2277
|
t.field("activateNextSegment", {
|
|
2330
2278
|
type: Game,
|
|
2331
2279
|
args: {
|
|
2332
|
-
gameId: (0,
|
|
2280
|
+
gameId: (0, import_nexus6.nonNull)((0, import_nexus6.intArg)())
|
|
2333
2281
|
},
|
|
2334
2282
|
async resolve(_, args, ctx) {
|
|
2335
2283
|
const results = await activateNextSegment(args, ctx, {
|
|
@@ -2343,12 +2291,12 @@ function generateBaseMutations({
|
|
|
2343
2291
|
t.field("performAction", {
|
|
2344
2292
|
type: PlayerResult,
|
|
2345
2293
|
args: {
|
|
2346
|
-
type: (0,
|
|
2347
|
-
payload: (0,
|
|
2294
|
+
type: (0, import_nexus6.nonNull)((0, import_nexus6.stringArg)()),
|
|
2295
|
+
payload: (0, import_nexus6.nonNull)((0, import_nexus6.stringArg)())
|
|
2348
2296
|
},
|
|
2349
2297
|
async resolve(_, args, ctx) {
|
|
2350
2298
|
const currentGame = await getGameFromContext(ctx);
|
|
2351
|
-
if (!
|
|
2299
|
+
if (!currentGame?.activePeriod)
|
|
2352
2300
|
return null;
|
|
2353
2301
|
const facts = JSON.parse(args.payload);
|
|
2354
2302
|
const result = await performAction(
|
|
@@ -2369,8 +2317,8 @@ function generateBaseMutations({
|
|
|
2369
2317
|
t.field("attemptLearningElement", {
|
|
2370
2318
|
type: LearningElementAttempt,
|
|
2371
2319
|
args: {
|
|
2372
|
-
elementId: (0,
|
|
2373
|
-
selection: (0,
|
|
2320
|
+
elementId: (0, import_nexus6.nonNull)((0, import_nexus6.idArg)()),
|
|
2321
|
+
selection: (0, import_nexus6.nonNull)((0, import_nexus6.stringArg)())
|
|
2374
2322
|
},
|
|
2375
2323
|
async resolve(_, args, ctx) {
|
|
2376
2324
|
return attemptLearningElement(args, ctx);
|
|
@@ -2379,7 +2327,7 @@ function generateBaseMutations({
|
|
|
2379
2327
|
t.field("markStoryElement", {
|
|
2380
2328
|
type: Player,
|
|
2381
2329
|
args: {
|
|
2382
|
-
elementId: (0,
|
|
2330
|
+
elementId: (0, import_nexus6.nonNull)((0, import_nexus6.idArg)())
|
|
2383
2331
|
},
|
|
2384
2332
|
async resolve(_, args, ctx) {
|
|
2385
2333
|
return markStoryElement(args, ctx);
|
|
@@ -2388,10 +2336,10 @@ function generateBaseMutations({
|
|
|
2388
2336
|
t.field("updatePlayerData", {
|
|
2389
2337
|
type: Player,
|
|
2390
2338
|
args: {
|
|
2391
|
-
name: (0,
|
|
2392
|
-
avatar: (0,
|
|
2393
|
-
color: (0,
|
|
2394
|
-
facts: (0,
|
|
2339
|
+
name: (0, import_nexus6.stringArg)(),
|
|
2340
|
+
avatar: (0, import_nexus6.stringArg)(),
|
|
2341
|
+
color: (0, import_nexus6.stringArg)(),
|
|
2342
|
+
facts: (0, import_nexus6.stringArg)()
|
|
2395
2343
|
},
|
|
2396
2344
|
async resolve(_, args, ctx) {
|
|
2397
2345
|
const facts = args.facts ? JSON.parse(args.facts) : {};
|
|
@@ -2401,7 +2349,7 @@ function generateBaseMutations({
|
|
|
2401
2349
|
t.field("saveConsolidationDecision", {
|
|
2402
2350
|
type: PlayerDecision,
|
|
2403
2351
|
args: {
|
|
2404
|
-
payload: (0,
|
|
2352
|
+
payload: (0, import_nexus6.nonNull)((0, import_nexus6.stringArg)())
|
|
2405
2353
|
},
|
|
2406
2354
|
async resolve(_, args, ctx) {
|
|
2407
2355
|
const facts = JSON.parse(args.payload);
|
|
@@ -2420,12 +2368,12 @@ function generateBaseMutations({
|
|
|
2420
2368
|
var Mutation = generateBaseMutations();
|
|
2421
2369
|
|
|
2422
2370
|
// src/types/Query.ts
|
|
2423
|
-
var
|
|
2371
|
+
var import_nexus7 = require("nexus");
|
|
2424
2372
|
function generateBaseQueries() {
|
|
2425
|
-
return (0,
|
|
2373
|
+
return (0, import_nexus7.objectType)({
|
|
2426
2374
|
name: "Query",
|
|
2427
2375
|
definition(t) {
|
|
2428
|
-
t.nonNull.
|
|
2376
|
+
t.list.nonNull.field("games", {
|
|
2429
2377
|
type: Game,
|
|
2430
2378
|
async resolve(_, args, ctx) {
|
|
2431
2379
|
return getGames(args, ctx);
|
|
@@ -2434,7 +2382,7 @@ function generateBaseQueries() {
|
|
|
2434
2382
|
t.field("game", {
|
|
2435
2383
|
type: Game,
|
|
2436
2384
|
args: {
|
|
2437
|
-
id: (0,
|
|
2385
|
+
id: (0, import_nexus7.intArg)()
|
|
2438
2386
|
},
|
|
2439
2387
|
async resolve(_, args, ctx) {
|
|
2440
2388
|
return getGame(args, ctx);
|
|
@@ -2455,7 +2403,7 @@ function generateBaseQueries() {
|
|
|
2455
2403
|
return getPlayerData({ playerId: ctx.user.sub }, ctx);
|
|
2456
2404
|
}
|
|
2457
2405
|
});
|
|
2458
|
-
t.nonNull.
|
|
2406
|
+
t.list.nonNull.field("learningElements", {
|
|
2459
2407
|
type: LearningElement,
|
|
2460
2408
|
async resolve(_, args, ctx) {
|
|
2461
2409
|
return getLearningElements(args, ctx);
|
|
@@ -2464,19 +2412,19 @@ function generateBaseQueries() {
|
|
|
2464
2412
|
t.field("learningElement", {
|
|
2465
2413
|
type: LearningElementState,
|
|
2466
2414
|
args: {
|
|
2467
|
-
id: (0,
|
|
2415
|
+
id: (0, import_nexus7.nonNull)((0, import_nexus7.idArg)())
|
|
2468
2416
|
},
|
|
2469
2417
|
async resolve(_, args, ctx) {
|
|
2470
2418
|
return getLearningElement(args, ctx);
|
|
2471
2419
|
}
|
|
2472
2420
|
});
|
|
2473
|
-
t.list.field("results", {
|
|
2421
|
+
t.list.nonNull.field("results", {
|
|
2474
2422
|
type: PlayerResult,
|
|
2475
2423
|
async resolve(_, args, ctx) {
|
|
2476
2424
|
return getPlayerResults(args, ctx);
|
|
2477
2425
|
}
|
|
2478
2426
|
});
|
|
2479
|
-
t.list.field("pastResults", {
|
|
2427
|
+
t.list.nonNull.field("pastResults", {
|
|
2480
2428
|
type: PlayerResult,
|
|
2481
2429
|
async resolve(_, args, ctx) {
|
|
2482
2430
|
return getPastResults(args, ctx);
|
|
@@ -2488,11 +2436,11 @@ function generateBaseQueries() {
|
|
|
2488
2436
|
var Query = generateBaseQueries();
|
|
2489
2437
|
|
|
2490
2438
|
// src/types/Subscription.ts
|
|
2491
|
-
var
|
|
2439
|
+
var import_nexus8 = require("nexus");
|
|
2492
2440
|
function generateBaseSubscriptions() {
|
|
2493
|
-
return (0,
|
|
2441
|
+
return (0, import_nexus8.subscriptionType)({
|
|
2494
2442
|
definition(t) {
|
|
2495
|
-
t.list.field("eventsGlobal", {
|
|
2443
|
+
t.list.nonNull.field("eventsGlobal", {
|
|
2496
2444
|
type: Event,
|
|
2497
2445
|
async subscribe(_, args, ctx) {
|
|
2498
2446
|
return pubSub.subscribe("global:events");
|
|
@@ -2501,7 +2449,7 @@ function generateBaseSubscriptions() {
|
|
|
2501
2449
|
return payload;
|
|
2502
2450
|
}
|
|
2503
2451
|
});
|
|
2504
|
-
t.list.field("eventsUser", {
|
|
2452
|
+
t.list.nonNull.field("eventsUser", {
|
|
2505
2453
|
type: Event,
|
|
2506
2454
|
async subscribe(_, args, ctx) {
|
|
2507
2455
|
return pubSub.subscribe("user:events", String(ctx.user.sub));
|
|
@@ -2516,13 +2464,13 @@ function generateBaseSubscriptions() {
|
|
|
2516
2464
|
var Subscription = generateBaseSubscriptions();
|
|
2517
2465
|
|
|
2518
2466
|
// src/nexus.ts
|
|
2519
|
-
var JsonScalar = (0,
|
|
2520
|
-
var DateScalar = (0,
|
|
2521
|
-
var UserRole3 = (0,
|
|
2467
|
+
var JsonScalar = (0, import_nexus10.asNexusMethod)(import_graphql_scalars.JSONObjectResolver, "json");
|
|
2468
|
+
var DateScalar = (0, import_nexus10.asNexusMethod)(import_graphql_scalars.DateTimeResolver, "date");
|
|
2469
|
+
var UserRole3 = (0, import_nexus10.enumType)({
|
|
2522
2470
|
name: "UserRole",
|
|
2523
2471
|
members: Object.values(DB5.UserRole)
|
|
2524
2472
|
});
|
|
2525
|
-
var Event = (0,
|
|
2473
|
+
var Event = (0, import_nexus10.objectType)({
|
|
2526
2474
|
name: "Event",
|
|
2527
2475
|
definition(t) {
|
|
2528
2476
|
t.string("type");
|
|
@@ -2541,11 +2489,7 @@ var Event = (0, import_nexus11.objectType)({
|
|
|
2541
2489
|
LearningElementState,
|
|
2542
2490
|
Mutation,
|
|
2543
2491
|
Period,
|
|
2544
|
-
PeriodFactsInput,
|
|
2545
|
-
PeriodFactsSchema,
|
|
2546
2492
|
PeriodSegment,
|
|
2547
|
-
PeriodSegmentFactsInput,
|
|
2548
|
-
PeriodSegmentFactsSchema,
|
|
2549
2493
|
Player,
|
|
2550
2494
|
PlayerAction,
|
|
2551
2495
|
PlayerDecision,
|
package/dist/schema.prisma
CHANGED
|
@@ -6,7 +6,7 @@ datasource db {
|
|
|
6
6
|
|
|
7
7
|
generator client {
|
|
8
8
|
provider = "prisma-client-js"
|
|
9
|
-
previewFeatures = ["
|
|
9
|
+
previewFeatures = ["fullTextSearch", "fullTextIndex", "postgresqlExtensions", "fieldReference", "orderByNulls", "extendedWhereUnique"]
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
model Account {
|
|
@@ -193,7 +193,7 @@ model Player {
|
|
|
193
193
|
|
|
194
194
|
facts Json
|
|
195
195
|
|
|
196
|
-
role String
|
|
196
|
+
role String?
|
|
197
197
|
|
|
198
198
|
token String @unique
|
|
199
199
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gbl-uzh/platform",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,41 +21,40 @@
|
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@graphql-codegen/cli": "2.13.
|
|
24
|
+
"@graphql-codegen/cli": "2.13.11",
|
|
25
25
|
"@graphql-codegen/fragment-matcher": "3.3.1",
|
|
26
26
|
"@graphql-codegen/introspection": "2.2.1",
|
|
27
|
-
"@graphql-codegen/typed-document-node": "2.3.
|
|
28
|
-
"@graphql-codegen/typescript": "2.
|
|
29
|
-
"@graphql-codegen/typescript-operations": "2.5.
|
|
30
|
-
"@graphql-codegen/typescript-resolvers": "2.7.
|
|
27
|
+
"@graphql-codegen/typed-document-node": "2.3.6",
|
|
28
|
+
"@graphql-codegen/typescript": "2.8.1",
|
|
29
|
+
"@graphql-codegen/typescript-operations": "2.5.6",
|
|
30
|
+
"@graphql-codegen/typescript-resolvers": "2.7.6",
|
|
31
31
|
"@tsconfig/node18": "1.0.1",
|
|
32
32
|
"@tsconfig/recommended": "1.0.1",
|
|
33
33
|
"@types/jest": "^29.2.2",
|
|
34
34
|
"@types/node": "^18.11.9",
|
|
35
35
|
"jest": "29.3.1",
|
|
36
36
|
"npm-run-all": "4.1.5",
|
|
37
|
-
"prisma": "4.
|
|
37
|
+
"prisma": "4.8.0",
|
|
38
38
|
"rollup-plugin-copy": "3.4.0",
|
|
39
39
|
"ts-jest": "29.0.3",
|
|
40
40
|
"ts-node": "10.9.1",
|
|
41
|
-
"tsup": "6.
|
|
42
|
-
"typescript": "4.
|
|
41
|
+
"tsup": "6.5.0",
|
|
42
|
+
"typescript": "4.9.4"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@apollo/client": "^3.7.0",
|
|
46
|
-
"@prisma/client": "4.
|
|
46
|
+
"@prisma/client": "^4.8.0",
|
|
47
47
|
"@uzh-bf/design-system": "^0.0.79",
|
|
48
48
|
"graphql": "^16.6.0",
|
|
49
49
|
"graphql-scalars": "^1.19.0",
|
|
50
|
-
"graphql-yoga": "^3.0.0
|
|
51
|
-
"jsonwebtoken": "^
|
|
52
|
-
"next": "^
|
|
50
|
+
"graphql-yoga": "^3.0.0",
|
|
51
|
+
"jsonwebtoken": "^9.0.0",
|
|
52
|
+
"next": "^13.0.0",
|
|
53
53
|
"nexus": "^1.3.0",
|
|
54
54
|
"nookies": "^2.5.2",
|
|
55
55
|
"ramda": "^0.28.0",
|
|
56
56
|
"react": "^18.0.0",
|
|
57
|
-
"
|
|
58
|
-
"yup": "^1.0.0-beta.7"
|
|
57
|
+
"yup": "^1.0.0-beta.8"
|
|
59
58
|
},
|
|
60
59
|
"volta": {
|
|
61
60
|
"extends": "../../package.json"
|