@gbl-uzh/platform 0.2.10 → 0.2.11
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 +17 -24
- package/dist/lib/apollo.js +4 -4
- package/dist/nexus.d.ts +21 -37
- package/dist/nexus.js +86 -112
- package/dist/schema.prisma +1 -1
- package/package.json +11 -12
package/dist/index.js
CHANGED
|
@@ -195,12 +195,10 @@ function prepareAchievementData({
|
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
async function receiveEvent(event, definedEvents, definedLevels, prisma) {
|
|
198
|
-
var _a;
|
|
199
198
|
const matchingEvent = definedEvents.find((item) => item.id === event.type);
|
|
200
|
-
if (matchingEvent &&
|
|
199
|
+
if (matchingEvent && matchingEvent.achievements?.length > 0) {
|
|
201
200
|
const awardedAchievements = await matchingEvent.achievements.reduce(
|
|
202
201
|
async (acc, achievement) => {
|
|
203
|
-
var _a2;
|
|
204
202
|
if (achievement.when === "FIRST" /* First */ && event.ctx.achievements.includes(achievement.id)) {
|
|
205
203
|
return acc;
|
|
206
204
|
}
|
|
@@ -250,7 +248,7 @@ async function receiveEvent(event, definedEvents, definedLevels, prisma) {
|
|
|
250
248
|
achievementKeys: [...acc.achievementKeys, achievement.id],
|
|
251
249
|
rewards: {
|
|
252
250
|
...acc.rewards,
|
|
253
|
-
xp: (acc.rewards.xp ?? 0) + (
|
|
251
|
+
xp: (acc.rewards.xp ?? 0) + (achievement.reward?.xp ?? 0)
|
|
254
252
|
}
|
|
255
253
|
};
|
|
256
254
|
},
|
|
@@ -439,7 +437,6 @@ async function createGame({ name, playerCount }, ctx, { roleAssigner }) {
|
|
|
439
437
|
});
|
|
440
438
|
}
|
|
441
439
|
async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
442
|
-
var _a, _b, _c, _d;
|
|
443
440
|
const validatedFacts = schema.validateSync(facts);
|
|
444
441
|
const game = await ctx.prisma.game.findUnique({
|
|
445
442
|
where: {
|
|
@@ -464,13 +461,13 @@ async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
|
464
461
|
});
|
|
465
462
|
if (!game)
|
|
466
463
|
return null;
|
|
467
|
-
const index =
|
|
464
|
+
const index = game.periods[0]?.index + 1 || 0;
|
|
468
465
|
const { result: initializedFacts } = reducers.Period.apply(validatedFacts, {
|
|
469
466
|
type: reducers.Period.ActionTypes.PERIOD_INITIALIZE,
|
|
470
467
|
payload: {
|
|
471
468
|
periodFacts: validatedFacts,
|
|
472
|
-
previousPeriodFacts:
|
|
473
|
-
previousSegmentFacts:
|
|
469
|
+
previousPeriodFacts: game.periods[0]?.facts,
|
|
470
|
+
previousSegmentFacts: game.periods[0]?.segments[0]?.facts,
|
|
474
471
|
periodIx: index
|
|
475
472
|
}
|
|
476
473
|
});
|
|
@@ -518,7 +515,6 @@ async function addPeriodSegment({
|
|
|
518
515
|
learningElements,
|
|
519
516
|
storyElements
|
|
520
517
|
}, ctx, { schema, reducers }) {
|
|
521
|
-
var _a, _b;
|
|
522
518
|
const validatedFacts = schema.validateSync(facts);
|
|
523
519
|
const period = await ctx.prisma.period.findUnique({
|
|
524
520
|
where: {
|
|
@@ -538,12 +534,12 @@ async function addPeriodSegment({
|
|
|
538
534
|
});
|
|
539
535
|
if (!period)
|
|
540
536
|
return null;
|
|
541
|
-
const index =
|
|
537
|
+
const index = period.segments[0]?.index + 1 || 0;
|
|
542
538
|
const { result: initializedFacts } = reducers.Segment.apply(validatedFacts, {
|
|
543
539
|
type: reducers.Segment.ActionTypes.SEGMENT_INITIALIZE,
|
|
544
540
|
payload: {
|
|
545
541
|
periodFacts: period.facts,
|
|
546
|
-
previousSegmentFacts:
|
|
542
|
+
previousSegmentFacts: period.segments[0]?.facts,
|
|
547
543
|
segmentIx: index,
|
|
548
544
|
segmentCount: 4,
|
|
549
545
|
periodIx
|
|
@@ -606,7 +602,6 @@ async function addPeriodSegment({
|
|
|
606
602
|
});
|
|
607
603
|
}
|
|
608
604
|
async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
609
|
-
var _a, _b, _c, _d, _e;
|
|
610
605
|
const game = await ctx.prisma.game.findUnique({
|
|
611
606
|
where: {
|
|
612
607
|
id: gameId
|
|
@@ -652,7 +647,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
652
647
|
if (!game)
|
|
653
648
|
return null;
|
|
654
649
|
const currentPeriodIx = game.activePeriodIx;
|
|
655
|
-
const currentSegmentIx =
|
|
650
|
+
const currentSegmentIx = game.activePeriod?.activeSegmentIx;
|
|
656
651
|
const nextPeriodIx = currentPeriodIx + 1;
|
|
657
652
|
switch (game.status) {
|
|
658
653
|
case "SCHEDULED" /* Scheduled */: {
|
|
@@ -662,7 +657,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
662
657
|
players: game.players,
|
|
663
658
|
activePeriodIx: currentPeriodIx,
|
|
664
659
|
gameId: game.id,
|
|
665
|
-
periodFacts:
|
|
660
|
+
periodFacts: game.periods?.[0].facts
|
|
666
661
|
},
|
|
667
662
|
ctx,
|
|
668
663
|
{ reducers }
|
|
@@ -703,7 +698,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
703
698
|
return result;
|
|
704
699
|
}
|
|
705
700
|
case "RUNNING" /* Running */: {
|
|
706
|
-
if (!
|
|
701
|
+
if (!game.activePeriod?.activeSegment || !currentSegmentIx)
|
|
707
702
|
return null;
|
|
708
703
|
const { results, extras } = computeSegmentEndResults(game, ctx, {
|
|
709
704
|
reducers
|
|
@@ -764,7 +759,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
764
759
|
return result;
|
|
765
760
|
}
|
|
766
761
|
case "CONSOLIDATION" /* Consolidation */: {
|
|
767
|
-
if (!
|
|
762
|
+
if (!game.activePeriod?.activeSegment)
|
|
768
763
|
return null;
|
|
769
764
|
const { results, extras, promises } = await computePeriodEndResults(
|
|
770
765
|
{
|
|
@@ -818,7 +813,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
818
813
|
return result;
|
|
819
814
|
}
|
|
820
815
|
case "RESULTS" /* Results */: {
|
|
821
|
-
if (!
|
|
816
|
+
if (!game.activePeriod?.nextPeriod) {
|
|
822
817
|
return null;
|
|
823
818
|
}
|
|
824
819
|
const { results, extras } = computePeriodStartResults(
|
|
@@ -863,7 +858,6 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
863
858
|
}
|
|
864
859
|
}
|
|
865
860
|
async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
866
|
-
var _a, _b;
|
|
867
861
|
const game = await ctx.prisma.game.findUnique({
|
|
868
862
|
where: {
|
|
869
863
|
id: gameId
|
|
@@ -893,7 +887,7 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
893
887
|
}
|
|
894
888
|
}
|
|
895
889
|
});
|
|
896
|
-
if (!
|
|
890
|
+
if (!game?.activePeriod)
|
|
897
891
|
return null;
|
|
898
892
|
const currentPeriodIx = game.activePeriodIx;
|
|
899
893
|
const currentSegmentIx = game.activePeriod.activeSegmentIx;
|
|
@@ -966,7 +960,7 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
966
960
|
return result;
|
|
967
961
|
}
|
|
968
962
|
case "RUNNING" /* Running */: {
|
|
969
|
-
if (!
|
|
963
|
+
if (!game.activePeriod?.activeSegment?.nextSegment) {
|
|
970
964
|
return null;
|
|
971
965
|
}
|
|
972
966
|
const { results, extras } = computeSegmentEndResults(game, ctx, {
|
|
@@ -1483,7 +1477,6 @@ __export(PlayService_exports, {
|
|
|
1483
1477
|
updateReadyState: () => updateReadyState
|
|
1484
1478
|
});
|
|
1485
1479
|
async function performAction(args, ctx, { reducers }) {
|
|
1486
|
-
var _a;
|
|
1487
1480
|
const periodIx_segmentIx_playerId_type = {
|
|
1488
1481
|
periodIx: args.periodIx,
|
|
1489
1482
|
segmentIx: args.segmentIx,
|
|
@@ -1510,7 +1503,7 @@ async function performAction(args, ctx, { reducers }) {
|
|
|
1510
1503
|
type: args.actionType,
|
|
1511
1504
|
payload: {
|
|
1512
1505
|
playerArgs: args.facts,
|
|
1513
|
-
segmentFacts:
|
|
1506
|
+
segmentFacts: previousResult.segment?.facts,
|
|
1514
1507
|
periodFacts: previousResult.period.facts
|
|
1515
1508
|
}
|
|
1516
1509
|
});
|
|
@@ -1595,7 +1588,7 @@ async function saveDecisions(args, ctx) {
|
|
|
1595
1588
|
}
|
|
1596
1589
|
}
|
|
1597
1590
|
});
|
|
1598
|
-
if (!
|
|
1591
|
+
if (!game?.activePeriod)
|
|
1599
1592
|
return null;
|
|
1600
1593
|
if (args.decisionType !== game.status) {
|
|
1601
1594
|
throw new Error("INVALID_DECISION");
|
|
@@ -1672,7 +1665,7 @@ async function getPlayerResult(args, ctx) {
|
|
|
1672
1665
|
}
|
|
1673
1666
|
}
|
|
1674
1667
|
});
|
|
1675
|
-
if (!
|
|
1668
|
+
if (!currentGame?.activePeriod)
|
|
1676
1669
|
return null;
|
|
1677
1670
|
const previousResults = ctx.prisma.playerResult.findMany({
|
|
1678
1671
|
where: {
|
package/dist/lib/apollo.js
CHANGED
|
@@ -33,7 +33,7 @@ module.exports = __toCommonJS(apollo_exports);
|
|
|
33
33
|
var import_client = require("@apollo/client");
|
|
34
34
|
var import_http = require("@apollo/client/link/http");
|
|
35
35
|
var import_utilities = require("@apollo/client/utilities");
|
|
36
|
-
var
|
|
36
|
+
var import_node_assert = __toESM(require("assert"));
|
|
37
37
|
var import_react = require("react");
|
|
38
38
|
|
|
39
39
|
// src/lib/SSELink.ts
|
|
@@ -69,15 +69,15 @@ var SSELink_default = SSELink;
|
|
|
69
69
|
// src/lib/apollo.ts
|
|
70
70
|
var apolloClient;
|
|
71
71
|
function createIsomorphLink() {
|
|
72
|
-
|
|
72
|
+
(0, import_node_assert.default)(typeof process.env.NEXT_PUBLIC_API_URL === "string");
|
|
73
73
|
const isBrowser = typeof window !== "undefined";
|
|
74
74
|
let httpLink = new import_http.HttpLink({
|
|
75
|
-
uri:
|
|
75
|
+
uri: process.env.NEXT_PUBLIC_API_URL,
|
|
76
76
|
credentials: "same-origin"
|
|
77
77
|
});
|
|
78
78
|
if (isBrowser) {
|
|
79
79
|
const sseLink = new SSELink_default({
|
|
80
|
-
url:
|
|
80
|
+
url: process.env.NEXT_PUBLIC_API_URL
|
|
81
81
|
});
|
|
82
82
|
httpLink = (0, import_client.split)(
|
|
83
83
|
({ query }) => {
|
package/dist/nexus.d.ts
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import * as nexus_dist_core from 'nexus/dist/core';
|
|
2
2
|
import * as yup from 'yup';
|
|
3
3
|
|
|
4
|
+
declare const PeriodFactsSchema: yup.ObjectSchema<{
|
|
5
|
+
stockTrend: number;
|
|
6
|
+
stockVariance: number;
|
|
7
|
+
stockGap: number;
|
|
8
|
+
}, yup.AnyObject, {
|
|
9
|
+
stockTrend: undefined;
|
|
10
|
+
stockVariance: undefined;
|
|
11
|
+
stockGap: undefined;
|
|
12
|
+
}, "">;
|
|
13
|
+
interface PeriodFacts extends yup.InferType<typeof PeriodFactsSchema> {
|
|
14
|
+
}
|
|
15
|
+
declare const PeriodFactsInput: nexus_dist_core.NexusInputObjectTypeDef<"PeriodFactsInput">;
|
|
16
|
+
declare const PeriodSegmentFactsSchema: yup.ObjectSchema<{
|
|
17
|
+
stockForecast: number | undefined;
|
|
18
|
+
}, yup.AnyObject, {
|
|
19
|
+
stockForecast: undefined;
|
|
20
|
+
}, "">;
|
|
21
|
+
interface PeriodSegmentFacts extends yup.InferType<typeof PeriodSegmentFactsSchema> {
|
|
22
|
+
}
|
|
23
|
+
declare const PeriodSegmentFactsInput: nexus_dist_core.NexusInputObjectTypeDef<"PeriodSegmentFactsInput">;
|
|
24
|
+
|
|
4
25
|
declare const GameStatus: nexus_dist_core.NexusEnumTypeDef<"GameStatus">;
|
|
5
26
|
declare const Game: nexus_dist_core.NexusObjectTypeDef<"Game">;
|
|
6
27
|
declare const Period: nexus_dist_core.NexusObjectTypeDef<"Period">;
|
|
@@ -18,43 +39,6 @@ interface GenerateBaseMutationsArgs {
|
|
|
18
39
|
declare function generateBaseMutations({ reducers, roleAssigner, }?: GenerateBaseMutationsArgs): nexus_dist_core.NexusObjectTypeDef<"Mutation">;
|
|
19
40
|
declare const Mutation: nexus_dist_core.NexusObjectTypeDef<"Mutation">;
|
|
20
41
|
|
|
21
|
-
declare const PeriodFactsSchema: yup.ObjectSchema<{
|
|
22
|
-
spotTradingEnabled: boolean;
|
|
23
|
-
futuresTradingEnabled: boolean;
|
|
24
|
-
optionsTradingEnabled: boolean;
|
|
25
|
-
interestRate: number;
|
|
26
|
-
convenienceYield: number;
|
|
27
|
-
storageCostPerItem: number;
|
|
28
|
-
initialSpotPrice: number | undefined;
|
|
29
|
-
randomSeed: number | undefined;
|
|
30
|
-
trendE: number;
|
|
31
|
-
trendGap: number;
|
|
32
|
-
}, yup.AnyObject, {
|
|
33
|
-
spotTradingEnabled: true;
|
|
34
|
-
futuresTradingEnabled: false;
|
|
35
|
-
optionsTradingEnabled: false;
|
|
36
|
-
interestRate: 0.01;
|
|
37
|
-
convenienceYield: 0.008;
|
|
38
|
-
storageCostPerItem: 50;
|
|
39
|
-
initialSpotPrice: undefined;
|
|
40
|
-
randomSeed: undefined;
|
|
41
|
-
trendE: 0.005;
|
|
42
|
-
trendGap: 0.02;
|
|
43
|
-
}, "">;
|
|
44
|
-
interface PeriodFacts extends yup.InferType<typeof PeriodFactsSchema> {
|
|
45
|
-
}
|
|
46
|
-
declare const PeriodFactsInput: nexus_dist_core.NexusInputObjectTypeDef<"PeriodFactsInput">;
|
|
47
|
-
declare const PeriodSegmentFactsSchema: yup.ObjectSchema<{
|
|
48
|
-
trendE: number | undefined;
|
|
49
|
-
trendGap: number | undefined;
|
|
50
|
-
}, yup.AnyObject, {
|
|
51
|
-
trendE: undefined;
|
|
52
|
-
trendGap: undefined;
|
|
53
|
-
}, "">;
|
|
54
|
-
interface PeriodSegmentFacts extends yup.InferType<typeof PeriodSegmentFactsSchema> {
|
|
55
|
-
}
|
|
56
|
-
declare const PeriodSegmentFactsInput: nexus_dist_core.NexusInputObjectTypeDef<"PeriodSegmentFactsInput">;
|
|
57
|
-
|
|
58
42
|
declare const PlayerDecisionType: nexus_dist_core.NexusEnumTypeDef<"PlayerDecisionType">;
|
|
59
43
|
declare const PlayerResultType: nexus_dist_core.NexusEnumTypeDef<"PlayerResultType">;
|
|
60
44
|
declare const PlayerLevel: nexus_dist_core.NexusObjectTypeDef<"PlayerLevel">;
|
package/dist/nexus.js
CHANGED
|
@@ -62,25 +62,51 @@ var DB5 = __toESM(require("@prisma/client"));
|
|
|
62
62
|
var import_graphql_scalars = require("graphql-scalars");
|
|
63
63
|
var import_nexus11 = require("nexus");
|
|
64
64
|
|
|
65
|
+
// ../../apps/demo-game/src/graphql/types/Period.ts
|
|
66
|
+
var import_nexus = require("nexus");
|
|
67
|
+
var yup = __toESM(require("yup"));
|
|
68
|
+
var PeriodFactsSchema = yup.object({
|
|
69
|
+
stockTrend: yup.number().required(),
|
|
70
|
+
stockVariance: yup.number().required(),
|
|
71
|
+
stockGap: yup.number().required()
|
|
72
|
+
});
|
|
73
|
+
var PeriodFactsInput = (0, import_nexus.inputObjectType)({
|
|
74
|
+
name: "PeriodFactsInput",
|
|
75
|
+
definition(t) {
|
|
76
|
+
t.nonNull.float("stockTrend");
|
|
77
|
+
t.nonNull.float("stockVariance");
|
|
78
|
+
t.nonNull.float("stockGap");
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
var PeriodSegmentFactsSchema = yup.object({
|
|
82
|
+
stockForecast: yup.number()
|
|
83
|
+
});
|
|
84
|
+
var PeriodSegmentFactsInput = (0, import_nexus.inputObjectType)({
|
|
85
|
+
name: "PeriodSegmentFactsInput",
|
|
86
|
+
definition(t) {
|
|
87
|
+
t.float("stockForecast");
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
65
91
|
// src/types/Game.ts
|
|
66
92
|
var DB4 = __toESM(require("@prisma/client"));
|
|
67
|
-
var
|
|
93
|
+
var import_nexus6 = require("nexus");
|
|
68
94
|
|
|
69
95
|
// src/types/LearningElement.ts
|
|
70
|
-
var
|
|
96
|
+
var import_nexus5 = require("nexus");
|
|
71
97
|
|
|
72
98
|
// src/types/Player.ts
|
|
73
99
|
var DB3 = __toESM(require("@prisma/client"));
|
|
74
|
-
var
|
|
100
|
+
var import_nexus4 = require("nexus");
|
|
75
101
|
|
|
76
102
|
// src/types/Achievement.ts
|
|
77
103
|
var DB = __toESM(require("@prisma/client"));
|
|
78
|
-
var
|
|
79
|
-
var AchievementFrequency2 = (0,
|
|
104
|
+
var import_nexus2 = require("nexus");
|
|
105
|
+
var AchievementFrequency2 = (0, import_nexus2.enumType)({
|
|
80
106
|
name: "AchievementFrequency",
|
|
81
107
|
members: Object.values(DB.AchievementFrequency)
|
|
82
108
|
});
|
|
83
|
-
var Achievement = (0,
|
|
109
|
+
var Achievement = (0, import_nexus2.objectType)({
|
|
84
110
|
name: "Achievement",
|
|
85
111
|
definition(t) {
|
|
86
112
|
t.nonNull.id("id");
|
|
@@ -95,7 +121,7 @@ var Achievement = (0, import_nexus.objectType)({
|
|
|
95
121
|
});
|
|
96
122
|
}
|
|
97
123
|
});
|
|
98
|
-
var AchievementInstance = (0,
|
|
124
|
+
var AchievementInstance = (0, import_nexus2.objectType)({
|
|
99
125
|
name: "AchievementInstance",
|
|
100
126
|
definition(t) {
|
|
101
127
|
t.nonNull.int("id");
|
|
@@ -108,12 +134,12 @@ var AchievementInstance = (0, import_nexus.objectType)({
|
|
|
108
134
|
|
|
109
135
|
// src/types/StoryElement.ts
|
|
110
136
|
var DB2 = __toESM(require("@prisma/client"));
|
|
111
|
-
var
|
|
112
|
-
var StoryElementType2 = (0,
|
|
137
|
+
var import_nexus3 = require("nexus");
|
|
138
|
+
var StoryElementType2 = (0, import_nexus3.enumType)({
|
|
113
139
|
name: "StoryElementType",
|
|
114
140
|
members: Object.values(DB2.StoryElementType)
|
|
115
141
|
});
|
|
116
|
-
var StoryElement = (0,
|
|
142
|
+
var StoryElement = (0, import_nexus3.objectType)({
|
|
117
143
|
name: "StoryElement",
|
|
118
144
|
definition(t) {
|
|
119
145
|
t.nonNull.id("id");
|
|
@@ -130,15 +156,15 @@ var StoryElement = (0, import_nexus2.objectType)({
|
|
|
130
156
|
});
|
|
131
157
|
|
|
132
158
|
// src/types/Player.ts
|
|
133
|
-
var PlayerDecisionType2 = (0,
|
|
159
|
+
var PlayerDecisionType2 = (0, import_nexus4.enumType)({
|
|
134
160
|
name: "PlayerDecisionType",
|
|
135
161
|
members: Object.values(DB3.PlayerDecisionType)
|
|
136
162
|
});
|
|
137
|
-
var PlayerResultType2 = (0,
|
|
163
|
+
var PlayerResultType2 = (0, import_nexus4.enumType)({
|
|
138
164
|
name: "PlayerResultType",
|
|
139
165
|
members: Object.values(DB3.PlayerResultType)
|
|
140
166
|
});
|
|
141
|
-
var PlayerLevel = (0,
|
|
167
|
+
var PlayerLevel = (0, import_nexus4.objectType)({
|
|
142
168
|
name: "PlayerLevel",
|
|
143
169
|
definition(t) {
|
|
144
170
|
t.nonNull.id("id");
|
|
@@ -147,7 +173,7 @@ var PlayerLevel = (0, import_nexus3.objectType)({
|
|
|
147
173
|
t.nonNull.int("requiredXP");
|
|
148
174
|
}
|
|
149
175
|
});
|
|
150
|
-
var PlayerState = (0,
|
|
176
|
+
var PlayerState = (0, import_nexus4.objectType)({
|
|
151
177
|
name: "PlayerState",
|
|
152
178
|
definition(t) {
|
|
153
179
|
t.field("playerResult", {
|
|
@@ -156,15 +182,15 @@ var PlayerState = (0, import_nexus3.objectType)({
|
|
|
156
182
|
t.field("currentGame", {
|
|
157
183
|
type: Game
|
|
158
184
|
});
|
|
159
|
-
t.list.field("previousResults", {
|
|
185
|
+
t.list.nonNull.field("previousResults", {
|
|
160
186
|
type: PlayerResult
|
|
161
187
|
});
|
|
162
|
-
t.list.field("transactions", {
|
|
188
|
+
t.list.nonNull.field("transactions", {
|
|
163
189
|
type: PlayerAction
|
|
164
190
|
});
|
|
165
191
|
}
|
|
166
192
|
});
|
|
167
|
-
var Player = (0,
|
|
193
|
+
var Player = (0, import_nexus4.objectType)({
|
|
168
194
|
name: "Player",
|
|
169
195
|
definition(t) {
|
|
170
196
|
t.nonNull.id("id");
|
|
@@ -175,7 +201,7 @@ var Player = (0, import_nexus3.objectType)({
|
|
|
175
201
|
t.nonNull.string("color");
|
|
176
202
|
t.nonNull.string("token");
|
|
177
203
|
t.nonNull.boolean("tutorialCompleted");
|
|
178
|
-
t.
|
|
204
|
+
t.string("role");
|
|
179
205
|
t.nonNull.int("experience");
|
|
180
206
|
t.nonNull.int("experienceToNext");
|
|
181
207
|
t.nonNull.field("facts", {
|
|
@@ -200,7 +226,7 @@ var Player = (0, import_nexus3.objectType)({
|
|
|
200
226
|
t.nonNull.list.nonNull.int("visitedStoryElementIds");
|
|
201
227
|
}
|
|
202
228
|
});
|
|
203
|
-
var PlayerResult = (0,
|
|
229
|
+
var PlayerResult = (0, import_nexus4.objectType)({
|
|
204
230
|
name: "PlayerResult",
|
|
205
231
|
definition(t) {
|
|
206
232
|
t.nonNull.id("id");
|
|
@@ -221,7 +247,7 @@ var PlayerResult = (0, import_nexus3.objectType)({
|
|
|
221
247
|
});
|
|
222
248
|
}
|
|
223
249
|
});
|
|
224
|
-
var PlayerAction = (0,
|
|
250
|
+
var PlayerAction = (0, import_nexus4.objectType)({
|
|
225
251
|
name: "PlayerAction",
|
|
226
252
|
definition(t) {
|
|
227
253
|
t.nonNull.id("id");
|
|
@@ -242,7 +268,7 @@ var PlayerAction = (0, import_nexus3.objectType)({
|
|
|
242
268
|
t.int("segmentIx");
|
|
243
269
|
}
|
|
244
270
|
});
|
|
245
|
-
var PlayerDecision = (0,
|
|
271
|
+
var PlayerDecision = (0, import_nexus4.objectType)({
|
|
246
272
|
name: "PlayerDecision",
|
|
247
273
|
definition(t) {
|
|
248
274
|
t.nonNull.id("id");
|
|
@@ -263,7 +289,7 @@ var PlayerDecision = (0, import_nexus3.objectType)({
|
|
|
263
289
|
});
|
|
264
290
|
|
|
265
291
|
// src/types/LearningElement.ts
|
|
266
|
-
var LearningAnswerOption = (0,
|
|
292
|
+
var LearningAnswerOption = (0, import_nexus5.objectType)({
|
|
267
293
|
name: "LearningAnswerOption",
|
|
268
294
|
definition(t) {
|
|
269
295
|
t.nonNull.id("id");
|
|
@@ -271,7 +297,7 @@ var LearningAnswerOption = (0, import_nexus4.objectType)({
|
|
|
271
297
|
t.nonNull.boolean("correct");
|
|
272
298
|
}
|
|
273
299
|
});
|
|
274
|
-
var LearningElementState = (0,
|
|
300
|
+
var LearningElementState = (0, import_nexus5.objectType)({
|
|
275
301
|
name: "LearningElementState",
|
|
276
302
|
definition(t) {
|
|
277
303
|
t.id("id");
|
|
@@ -282,7 +308,7 @@ var LearningElementState = (0, import_nexus4.objectType)({
|
|
|
282
308
|
t.string("solution");
|
|
283
309
|
}
|
|
284
310
|
});
|
|
285
|
-
var LearningElementAttempt = (0,
|
|
311
|
+
var LearningElementAttempt = (0, import_nexus5.objectType)({
|
|
286
312
|
name: "LearningElementAttempt",
|
|
287
313
|
definition(t) {
|
|
288
314
|
t.id("id");
|
|
@@ -296,7 +322,7 @@ var LearningElementAttempt = (0, import_nexus4.objectType)({
|
|
|
296
322
|
});
|
|
297
323
|
}
|
|
298
324
|
});
|
|
299
|
-
var LearningElement = (0,
|
|
325
|
+
var LearningElement = (0, import_nexus5.objectType)({
|
|
300
326
|
name: "LearningElement",
|
|
301
327
|
definition(t) {
|
|
302
328
|
t.nonNull.id("id");
|
|
@@ -314,11 +340,11 @@ var LearningElement = (0, import_nexus4.objectType)({
|
|
|
314
340
|
});
|
|
315
341
|
|
|
316
342
|
// src/types/Game.ts
|
|
317
|
-
var GameStatus2 = (0,
|
|
343
|
+
var GameStatus2 = (0, import_nexus6.enumType)({
|
|
318
344
|
name: "GameStatus",
|
|
319
345
|
members: Object.values(DB4.GameStatus)
|
|
320
346
|
});
|
|
321
|
-
var Game = (0,
|
|
347
|
+
var Game = (0, import_nexus6.objectType)({
|
|
322
348
|
name: "Game",
|
|
323
349
|
definition(t) {
|
|
324
350
|
t.nonNull.id("id");
|
|
@@ -336,12 +362,9 @@ var Game = (0, import_nexus5.objectType)({
|
|
|
336
362
|
t.nonNull.list.nonNull.field("periods", {
|
|
337
363
|
type: Period
|
|
338
364
|
});
|
|
339
|
-
t.nonNull.list.nonNull.field("segments", {
|
|
340
|
-
type: PeriodSegment
|
|
341
|
-
});
|
|
342
365
|
}
|
|
343
366
|
});
|
|
344
|
-
var Period = (0,
|
|
367
|
+
var Period = (0, import_nexus6.objectType)({
|
|
345
368
|
name: "Period",
|
|
346
369
|
definition(t) {
|
|
347
370
|
t.nonNull.id("id");
|
|
@@ -364,7 +387,7 @@ var Period = (0, import_nexus5.objectType)({
|
|
|
364
387
|
});
|
|
365
388
|
}
|
|
366
389
|
});
|
|
367
|
-
var PeriodSegment = (0,
|
|
390
|
+
var PeriodSegment = (0, import_nexus6.objectType)({
|
|
368
391
|
name: "PeriodSegment",
|
|
369
392
|
definition(t) {
|
|
370
393
|
t.nonNull.id("id");
|
|
@@ -502,7 +525,7 @@ var nanoid = (size = 21) => {
|
|
|
502
525
|
|
|
503
526
|
// src/services/GameService.ts
|
|
504
527
|
var import_ramda = require("ramda");
|
|
505
|
-
var
|
|
528
|
+
var yup2 = __toESM(require("yup"));
|
|
506
529
|
|
|
507
530
|
// src/lib/pubsub.ts
|
|
508
531
|
var import_graphql_yoga = require("graphql-yoga");
|
|
@@ -542,12 +565,10 @@ function prepareAchievementData({
|
|
|
542
565
|
};
|
|
543
566
|
}
|
|
544
567
|
async function receiveEvent(event, definedEvents, definedLevels, prisma) {
|
|
545
|
-
var _a;
|
|
546
568
|
const matchingEvent = definedEvents.find((item) => item.id === event.type);
|
|
547
|
-
if (matchingEvent &&
|
|
569
|
+
if (matchingEvent && matchingEvent.achievements?.length > 0) {
|
|
548
570
|
const awardedAchievements = await matchingEvent.achievements.reduce(
|
|
549
571
|
async (acc, achievement) => {
|
|
550
|
-
var _a2;
|
|
551
572
|
if (achievement.when === "FIRST" /* First */ && event.ctx.achievements.includes(achievement.id)) {
|
|
552
573
|
return acc;
|
|
553
574
|
}
|
|
@@ -597,7 +618,7 @@ async function receiveEvent(event, definedEvents, definedLevels, prisma) {
|
|
|
597
618
|
achievementKeys: [...acc.achievementKeys, achievement.id],
|
|
598
619
|
rewards: {
|
|
599
620
|
...acc.rewards,
|
|
600
|
-
xp: (acc.rewards.xp ?? 0) + (
|
|
621
|
+
xp: (acc.rewards.xp ?? 0) + (achievement.reward?.xp ?? 0)
|
|
601
622
|
}
|
|
602
623
|
};
|
|
603
624
|
},
|
|
@@ -732,7 +753,6 @@ async function createGame({ name, playerCount }, ctx, { roleAssigner }) {
|
|
|
732
753
|
});
|
|
733
754
|
}
|
|
734
755
|
async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
735
|
-
var _a, _b, _c, _d;
|
|
736
756
|
const validatedFacts = schema.validateSync(facts);
|
|
737
757
|
const game = await ctx.prisma.game.findUnique({
|
|
738
758
|
where: {
|
|
@@ -757,13 +777,13 @@ async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
|
757
777
|
});
|
|
758
778
|
if (!game)
|
|
759
779
|
return null;
|
|
760
|
-
const index =
|
|
780
|
+
const index = game.periods[0]?.index + 1 || 0;
|
|
761
781
|
const { result: initializedFacts } = reducers.Period.apply(validatedFacts, {
|
|
762
782
|
type: reducers.Period.ActionTypes.PERIOD_INITIALIZE,
|
|
763
783
|
payload: {
|
|
764
784
|
periodFacts: validatedFacts,
|
|
765
|
-
previousPeriodFacts:
|
|
766
|
-
previousSegmentFacts:
|
|
785
|
+
previousPeriodFacts: game.periods[0]?.facts,
|
|
786
|
+
previousSegmentFacts: game.periods[0]?.segments[0]?.facts,
|
|
767
787
|
periodIx: index
|
|
768
788
|
}
|
|
769
789
|
});
|
|
@@ -811,7 +831,6 @@ async function addPeriodSegment({
|
|
|
811
831
|
learningElements,
|
|
812
832
|
storyElements
|
|
813
833
|
}, ctx, { schema, reducers }) {
|
|
814
|
-
var _a, _b;
|
|
815
834
|
const validatedFacts = schema.validateSync(facts);
|
|
816
835
|
const period = await ctx.prisma.period.findUnique({
|
|
817
836
|
where: {
|
|
@@ -831,12 +850,12 @@ async function addPeriodSegment({
|
|
|
831
850
|
});
|
|
832
851
|
if (!period)
|
|
833
852
|
return null;
|
|
834
|
-
const index =
|
|
853
|
+
const index = period.segments[0]?.index + 1 || 0;
|
|
835
854
|
const { result: initializedFacts } = reducers.Segment.apply(validatedFacts, {
|
|
836
855
|
type: reducers.Segment.ActionTypes.SEGMENT_INITIALIZE,
|
|
837
856
|
payload: {
|
|
838
857
|
periodFacts: period.facts,
|
|
839
|
-
previousSegmentFacts:
|
|
858
|
+
previousSegmentFacts: period.segments[0]?.facts,
|
|
840
859
|
segmentIx: index,
|
|
841
860
|
segmentCount: 4,
|
|
842
861
|
periodIx
|
|
@@ -899,7 +918,6 @@ async function addPeriodSegment({
|
|
|
899
918
|
});
|
|
900
919
|
}
|
|
901
920
|
async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
902
|
-
var _a, _b, _c, _d, _e;
|
|
903
921
|
const game = await ctx.prisma.game.findUnique({
|
|
904
922
|
where: {
|
|
905
923
|
id: gameId
|
|
@@ -945,7 +963,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
945
963
|
if (!game)
|
|
946
964
|
return null;
|
|
947
965
|
const currentPeriodIx = game.activePeriodIx;
|
|
948
|
-
const currentSegmentIx =
|
|
966
|
+
const currentSegmentIx = game.activePeriod?.activeSegmentIx;
|
|
949
967
|
const nextPeriodIx = currentPeriodIx + 1;
|
|
950
968
|
switch (game.status) {
|
|
951
969
|
case "SCHEDULED" /* Scheduled */: {
|
|
@@ -955,7 +973,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
955
973
|
players: game.players,
|
|
956
974
|
activePeriodIx: currentPeriodIx,
|
|
957
975
|
gameId: game.id,
|
|
958
|
-
periodFacts:
|
|
976
|
+
periodFacts: game.periods?.[0].facts
|
|
959
977
|
},
|
|
960
978
|
ctx,
|
|
961
979
|
{ reducers }
|
|
@@ -996,7 +1014,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
996
1014
|
return result;
|
|
997
1015
|
}
|
|
998
1016
|
case "RUNNING" /* Running */: {
|
|
999
|
-
if (!
|
|
1017
|
+
if (!game.activePeriod?.activeSegment || !currentSegmentIx)
|
|
1000
1018
|
return null;
|
|
1001
1019
|
const { results, extras } = computeSegmentEndResults(game, ctx, {
|
|
1002
1020
|
reducers
|
|
@@ -1057,7 +1075,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1057
1075
|
return result;
|
|
1058
1076
|
}
|
|
1059
1077
|
case "CONSOLIDATION" /* Consolidation */: {
|
|
1060
|
-
if (!
|
|
1078
|
+
if (!game.activePeriod?.activeSegment)
|
|
1061
1079
|
return null;
|
|
1062
1080
|
const { results, extras, promises } = await computePeriodEndResults(
|
|
1063
1081
|
{
|
|
@@ -1111,7 +1129,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1111
1129
|
return result;
|
|
1112
1130
|
}
|
|
1113
1131
|
case "RESULTS" /* Results */: {
|
|
1114
|
-
if (!
|
|
1132
|
+
if (!game.activePeriod?.nextPeriod) {
|
|
1115
1133
|
return null;
|
|
1116
1134
|
}
|
|
1117
1135
|
const { results, extras } = computePeriodStartResults(
|
|
@@ -1156,7 +1174,6 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1156
1174
|
}
|
|
1157
1175
|
}
|
|
1158
1176
|
async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
1159
|
-
var _a, _b;
|
|
1160
1177
|
const game = await ctx.prisma.game.findUnique({
|
|
1161
1178
|
where: {
|
|
1162
1179
|
id: gameId
|
|
@@ -1186,7 +1203,7 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1186
1203
|
}
|
|
1187
1204
|
}
|
|
1188
1205
|
});
|
|
1189
|
-
if (!
|
|
1206
|
+
if (!game?.activePeriod)
|
|
1190
1207
|
return null;
|
|
1191
1208
|
const currentPeriodIx = game.activePeriodIx;
|
|
1192
1209
|
const currentSegmentIx = game.activePeriod.activeSegmentIx;
|
|
@@ -1259,7 +1276,7 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1259
1276
|
return result;
|
|
1260
1277
|
}
|
|
1261
1278
|
case "RUNNING" /* Running */: {
|
|
1262
|
-
if (!
|
|
1279
|
+
if (!game.activePeriod?.activeSegment?.nextSegment) {
|
|
1263
1280
|
return null;
|
|
1264
1281
|
}
|
|
1265
1282
|
const { results, extras } = computeSegmentEndResults(game, ctx, {
|
|
@@ -1297,8 +1314,8 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1297
1314
|
return null;
|
|
1298
1315
|
}
|
|
1299
1316
|
}
|
|
1300
|
-
var PlayerFactsSchema =
|
|
1301
|
-
location:
|
|
1317
|
+
var PlayerFactsSchema = yup2.object({
|
|
1318
|
+
location: yup2.string().default("Zurich")
|
|
1302
1319
|
});
|
|
1303
1320
|
async function updatePlayerData({ name, avatar, color, facts }, ctx) {
|
|
1304
1321
|
if ((0, import_ramda.none)(Boolean, [name, avatar, color, facts])) {
|
|
@@ -1762,7 +1779,6 @@ function computeSegmentEndResults(game, ctx, { reducers }) {
|
|
|
1762
1779
|
|
|
1763
1780
|
// src/services/PlayService.ts
|
|
1764
1781
|
async function performAction(args, ctx, { reducers }) {
|
|
1765
|
-
var _a;
|
|
1766
1782
|
const periodIx_segmentIx_playerId_type = {
|
|
1767
1783
|
periodIx: args.periodIx,
|
|
1768
1784
|
segmentIx: args.segmentIx,
|
|
@@ -1789,7 +1805,7 @@ async function performAction(args, ctx, { reducers }) {
|
|
|
1789
1805
|
type: args.actionType,
|
|
1790
1806
|
payload: {
|
|
1791
1807
|
playerArgs: args.facts,
|
|
1792
|
-
segmentFacts:
|
|
1808
|
+
segmentFacts: previousResult.segment?.facts,
|
|
1793
1809
|
periodFacts: previousResult.period.facts
|
|
1794
1810
|
}
|
|
1795
1811
|
});
|
|
@@ -1874,7 +1890,7 @@ async function saveDecisions(args, ctx) {
|
|
|
1874
1890
|
}
|
|
1875
1891
|
}
|
|
1876
1892
|
});
|
|
1877
|
-
if (!
|
|
1893
|
+
if (!game?.activePeriod)
|
|
1878
1894
|
return null;
|
|
1879
1895
|
if (args.decisionType !== game.status) {
|
|
1880
1896
|
throw new Error("INVALID_DECISION");
|
|
@@ -1951,7 +1967,7 @@ async function getPlayerResult(args, ctx) {
|
|
|
1951
1967
|
}
|
|
1952
1968
|
}
|
|
1953
1969
|
});
|
|
1954
|
-
if (!
|
|
1970
|
+
if (!currentGame?.activePeriod)
|
|
1955
1971
|
return null;
|
|
1956
1972
|
const previousResults = ctx.prisma.playerResult.findMany({
|
|
1957
1973
|
where: {
|
|
@@ -2198,48 +2214,6 @@ async function updateReadyState(args, ctx) {
|
|
|
2198
2214
|
});
|
|
2199
2215
|
}
|
|
2200
2216
|
|
|
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
2217
|
// src/types/Mutation.ts
|
|
2244
2218
|
var defaultReducers = {};
|
|
2245
2219
|
function generateBaseMutations({
|
|
@@ -2258,7 +2232,7 @@ function generateBaseMutations({
|
|
|
2258
2232
|
return updateReadyState(args, ctx);
|
|
2259
2233
|
}
|
|
2260
2234
|
});
|
|
2261
|
-
t.
|
|
2235
|
+
t.field("loginAsTeam", {
|
|
2262
2236
|
type: Player,
|
|
2263
2237
|
args: {
|
|
2264
2238
|
token: (0, import_nexus7.nonNull)((0, import_nexus7.stringArg)())
|
|
@@ -2267,7 +2241,7 @@ function generateBaseMutations({
|
|
|
2267
2241
|
return loginAsTeam(args, ctx);
|
|
2268
2242
|
}
|
|
2269
2243
|
});
|
|
2270
|
-
t.
|
|
2244
|
+
t.field("createGame", {
|
|
2271
2245
|
type: Game,
|
|
2272
2246
|
args: {
|
|
2273
2247
|
name: (0, import_nexus7.nonNull)((0, import_nexus7.stringArg)()),
|
|
@@ -2279,7 +2253,7 @@ function generateBaseMutations({
|
|
|
2279
2253
|
});
|
|
2280
2254
|
}
|
|
2281
2255
|
});
|
|
2282
|
-
t.
|
|
2256
|
+
t.field("addGamePeriod", {
|
|
2283
2257
|
type: Period,
|
|
2284
2258
|
args: {
|
|
2285
2259
|
gameId: (0, import_nexus7.nonNull)((0, import_nexus7.intArg)()),
|
|
@@ -2294,7 +2268,7 @@ function generateBaseMutations({
|
|
|
2294
2268
|
});
|
|
2295
2269
|
}
|
|
2296
2270
|
});
|
|
2297
|
-
t.
|
|
2271
|
+
t.field("addPeriodSegment", {
|
|
2298
2272
|
type: PeriodSegment,
|
|
2299
2273
|
args: {
|
|
2300
2274
|
gameId: (0, import_nexus7.nonNull)((0, import_nexus7.intArg)()),
|
|
@@ -2348,7 +2322,7 @@ function generateBaseMutations({
|
|
|
2348
2322
|
},
|
|
2349
2323
|
async resolve(_, args, ctx) {
|
|
2350
2324
|
const currentGame = await getGameFromContext(ctx);
|
|
2351
|
-
if (!
|
|
2325
|
+
if (!currentGame?.activePeriod)
|
|
2352
2326
|
return null;
|
|
2353
2327
|
const facts = JSON.parse(args.payload);
|
|
2354
2328
|
const result = await performAction(
|
|
@@ -2425,7 +2399,7 @@ function generateBaseQueries() {
|
|
|
2425
2399
|
return (0, import_nexus8.objectType)({
|
|
2426
2400
|
name: "Query",
|
|
2427
2401
|
definition(t) {
|
|
2428
|
-
t.nonNull.
|
|
2402
|
+
t.list.nonNull.field("games", {
|
|
2429
2403
|
type: Game,
|
|
2430
2404
|
async resolve(_, args, ctx) {
|
|
2431
2405
|
return getGames(args, ctx);
|
|
@@ -2455,7 +2429,7 @@ function generateBaseQueries() {
|
|
|
2455
2429
|
return getPlayerData({ playerId: ctx.user.sub }, ctx);
|
|
2456
2430
|
}
|
|
2457
2431
|
});
|
|
2458
|
-
t.nonNull.
|
|
2432
|
+
t.list.nonNull.field("learningElements", {
|
|
2459
2433
|
type: LearningElement,
|
|
2460
2434
|
async resolve(_, args, ctx) {
|
|
2461
2435
|
return getLearningElements(args, ctx);
|
|
@@ -2470,13 +2444,13 @@ function generateBaseQueries() {
|
|
|
2470
2444
|
return getLearningElement(args, ctx);
|
|
2471
2445
|
}
|
|
2472
2446
|
});
|
|
2473
|
-
t.list.field("results", {
|
|
2447
|
+
t.list.nonNull.field("results", {
|
|
2474
2448
|
type: PlayerResult,
|
|
2475
2449
|
async resolve(_, args, ctx) {
|
|
2476
2450
|
return getPlayerResults(args, ctx);
|
|
2477
2451
|
}
|
|
2478
2452
|
});
|
|
2479
|
-
t.list.field("pastResults", {
|
|
2453
|
+
t.list.nonNull.field("pastResults", {
|
|
2480
2454
|
type: PlayerResult,
|
|
2481
2455
|
async resolve(_, args, ctx) {
|
|
2482
2456
|
return getPastResults(args, ctx);
|
|
@@ -2492,7 +2466,7 @@ var import_nexus9 = require("nexus");
|
|
|
2492
2466
|
function generateBaseSubscriptions() {
|
|
2493
2467
|
return (0, import_nexus9.subscriptionType)({
|
|
2494
2468
|
definition(t) {
|
|
2495
|
-
t.list.field("eventsGlobal", {
|
|
2469
|
+
t.list.nonNull.field("eventsGlobal", {
|
|
2496
2470
|
type: Event,
|
|
2497
2471
|
async subscribe(_, args, ctx) {
|
|
2498
2472
|
return pubSub.subscribe("global:events");
|
|
@@ -2501,7 +2475,7 @@ function generateBaseSubscriptions() {
|
|
|
2501
2475
|
return payload;
|
|
2502
2476
|
}
|
|
2503
2477
|
});
|
|
2504
|
-
t.list.field("eventsUser", {
|
|
2478
|
+
t.list.nonNull.field("eventsUser", {
|
|
2505
2479
|
type: Event,
|
|
2506
2480
|
async subscribe(_, args, ctx) {
|
|
2507
2481
|
return pubSub.subscribe("user:events", String(ctx.user.sub));
|
package/dist/schema.prisma
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gbl-uzh/platform",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
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.6.1",
|
|
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.
|
|
41
|
+
"tsup": "6.4.0",
|
|
42
42
|
"typescript": "4.8.4"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@apollo/client": "^3.7.0",
|
|
46
|
-
"@prisma/client": "4.
|
|
46
|
+
"@prisma/client": "4.6.1",
|
|
47
47
|
"@uzh-bf/design-system": "^0.0.79",
|
|
48
48
|
"graphql": "^16.6.0",
|
|
49
49
|
"graphql-scalars": "^1.19.0",
|
|
50
50
|
"graphql-yoga": "^3.0.0-next.4",
|
|
51
51
|
"jsonwebtoken": "^8.5.1",
|
|
52
|
-
"next": "^
|
|
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"
|